Lines Matching refs:pipe

205  * enum cvmx_usb_pipe_flags - internal flags for a pipe.
207 * @CVMX_USB_PIPE_FLAGS_SCHEDULED: Used internally to determine if a pipe is
210 * pipe is in the ping state.
257 * to form a list of pending requests for a pipe.
259 * @node: List node for transactions in the pipe.
260 * @type: Type of transaction, duplicated of the pipe.
292 * struct cvmx_usb_pipe - a pipe represents a virtual connection between Octeon
296 * @node: List node for pipe list
301 * @next_tx_frame: The next frame this pipe is allowed to transmit on
302 * @flags: State flags for this pipe
303 * @device_speed: Speed of device connected to this pipe
304 * @transfer_type: Type of transaction supported by this pipe
308 * @device_addr: USB device address at other end of pipe
309 * @endpoint_num: USB endpoint number at other end of pipe
314 * @channel: Hardware DMA channel for this pipe
358 * pipe: Storage for pipes.
469 if (usb_pipeisoc(urb->pipe))
546 * Return non zero if this pipe connects to a non HIGH speed
550 * @pipe: Pipe to check
555 struct cvmx_usb_pipe *pipe)
557 return pipe->device_speed != CVMX_USB_SPEED_HIGH &&
562 * Trivial utility function to return the correct PID for a pipe
564 * @pipe: pipe to check
566 * Returns: PID for pipe
568 static inline int cvmx_usb_get_data_pid(struct cvmx_usb_pipe *pipe)
570 if (pipe->pid_toggle)
1034 * Open a virtual pipe between the host and a USB device. A pipe
1040 * USB device address to open the pipe to
1043 * USB endpoint number to open the pipe to
1046 * The speed of the device the pipe is going
1055 * The type of transfer this pipe is for.
1057 * The direction the pipe is in. This is not
1083 * Returns: A non-NULL value is a pipe. NULL means an error.
1099 struct cvmx_usb_pipe *pipe;
1101 pipe = kzalloc(sizeof(*pipe), GFP_ATOMIC);
1102 if (!pipe)
1107 pipe->flags |= CVMX_USB_PIPE_FLAGS_NEED_PING;
1108 pipe->device_addr = device_addr;
1109 pipe->endpoint_num = endpoint_num;
1110 pipe->device_speed = device_speed;
1111 pipe->max_packet = max_packet;
1112 pipe->transfer_type = transfer_type;
1113 pipe->transfer_dir = transfer_dir;
1114 INIT_LIST_HEAD(&pipe->transactions);
1122 if (cvmx_usb_pipe_needs_split(usb, pipe)) {
1123 pipe->interval = interval * 8;
1125 pipe->next_tx_frame = ((usb->frame_number + 7) & ~7) +
1126 pipe->interval;
1128 pipe->interval = interval;
1129 pipe->next_tx_frame = usb->frame_number + pipe->interval;
1131 pipe->multi_count = multi_count;
1132 pipe->hub_device_addr = hub_device_addr;
1133 pipe->hub_port = hub_port;
1134 pipe->pid_toggle = 0;
1135 pipe->split_sc_frame = -1;
1136 list_add_tail(&pipe->node, &usb->idle_pipes);
1139 * We don't need to tell the hardware about this pipe yet since
1143 return pipe;
1346 * @pipe: Pipe for control transaction
1350 struct cvmx_usb_pipe *pipe)
1355 list_first_entry(&pipe->transactions, typeof(*transaction),
1399 usbc_hctsiz.s.pid = cvmx_usb_get_data_pid(pipe);
1400 if (cvmx_usb_pipe_needs_split(usb, pipe)) {
1403 else if (bytes_to_transfer > pipe->max_packet)
1404 bytes_to_transfer = pipe->max_packet;
1413 usbc_hctsiz.s.pid = cvmx_usb_get_data_pid(pipe);
1425 usbc_hctsiz.s.pid = cvmx_usb_get_data_pid(pipe);
1434 usbc_hctsiz.s.pid = cvmx_usb_get_data_pid(pipe);
1452 bytes_to_transfer = MAX_TRANSFER_BYTES / pipe->max_packet;
1453 bytes_to_transfer *= pipe->max_packet;
1461 pipe->max_packet);
1472 bytes_to_transfer = packets_to_transfer * pipe->max_packet;
1479 bytes_to_transfer = packets_to_transfer * pipe->max_packet;
1490 * Start a channel to perform the pipe's head transaction
1494 * @pipe: Pipe to start
1497 struct cvmx_usb_pipe *pipe)
1500 list_first_entry(&pipe->transactions, typeof(*transaction),
1506 /* Attach the channel to the pipe */
1507 usb->pipe_for_channel[channel] = pipe;
1508 pipe->channel = channel;
1509 pipe->flags |= CVMX_USB_PIPE_FLAGS_SCHEDULED;
1539 if (cvmx_usb_pipe_needs_split(usb, pipe)) {
1574 if (pipe->transfer_dir == CVMX_USB_DIRECTION_OUT)
1602 if (cvmx_usb_pipe_needs_split(usb, pipe)) {
1611 pipe->split_sc_frame =
1614 pipe->split_sc_frame =
1617 pipe->split_sc_frame = -1;
1621 usbc_hcsplt.s.hubaddr = pipe->hub_device_addr;
1622 usbc_hcsplt.s.prtaddr = pipe->hub_port;
1631 if (bytes_to_transfer > pipe->max_packet)
1632 bytes_to_transfer = pipe->max_packet;
1640 (pipe->transfer_dir == CVMX_USB_DIRECTION_OUT) &&
1641 (pipe->transfer_type ==
1647 pipe->split_sc_frame = -1;
1695 pipe->max_packet;
1696 bytes_to_transfer *= pipe->max_packet;
1704 DIV_ROUND_UP(bytes_to_transfer, pipe->max_packet);
1718 pipe->max_packet;
1726 pipe->max_packet;
1733 usbc_hctsiz.s.pid = cvmx_usb_get_data_pid(pipe);
1737 if (pipe->flags & CVMX_USB_PIPE_FLAGS_NEED_PING)
1764 if (cvmx_usb_pipe_needs_split(usb, pipe))
1766 else if (pipe->multi_count < 1)
1768 else if (pipe->multi_count > 3)
1771 usbc_hcchar.s.ec = pipe->multi_count;
1774 usbc_hcchar.s.devaddr = pipe->device_addr;
1777 (pipe->device_speed == CVMX_USB_SPEED_LOW);
1778 usbc_hcchar.s.epdir = pipe->transfer_dir;
1779 usbc_hcchar.s.epnum = pipe->endpoint_num;
1780 usbc_hcchar.s.mps = pipe->max_packet;
1789 cvmx_usb_start_channel_control(usb, channel, pipe);
1795 if (!cvmx_usb_pipe_needs_split(usb, pipe)) {
1800 if (pipe->transfer_dir == CVMX_USB_DIRECTION_OUT) {
1801 if (pipe->multi_count < 2) /* Need DATA0 */
1825 if (cvmx_usb_pipe_needs_split(usb, pipe))
1834 * Find a pipe that is ready to be scheduled to hardware.
1845 struct cvmx_usb_pipe *pipe;
1847 list_for_each_entry(pipe, list, node) {
1849 list_first_entry(&pipe->transactions, typeof(*t),
1851 if (!(pipe->flags & CVMX_USB_PIPE_FLAGS_SCHEDULED) && t &&
1852 (pipe->next_tx_frame <= current_frame) &&
1853 ((pipe->split_sc_frame == -1) ||
1854 ((((int)current_frame - pipe->split_sc_frame) & 0x7f) <
1858 return pipe;
1867 struct cvmx_usb_pipe *pipe;
1869 /* Find a pipe needing service. */
1876 pipe = cvmx_usb_find_ready_pipe(usb,
1878 if (pipe)
1879 return pipe;
1880 pipe = cvmx_usb_find_ready_pipe(usb,
1882 if (pipe)
1883 return pipe;
1885 pipe = cvmx_usb_find_ready_pipe(usb, CVMX_USB_TRANSFER_CONTROL);
1886 if (pipe)
1887 return pipe;
1892 * Called whenever a pipe might need to be scheduled to the
1901 struct cvmx_usb_pipe *pipe;
1930 pipe = cvmx_usb_next_pipe(usb, is_sof);
1931 if (!pipe)
1934 cvmx_usb_start_channel(usb, channel, pipe);
1945 list_for_each_entry(pipe, &usb->active_pipes[ttype], node) {
1946 if (pipe->next_tx_frame > usb->frame_number) {
1958 struct cvmx_usb_pipe *pipe,
1977 if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) {
1995 dev_dbg(dev, "ISOCHRONOUS packet=%d of %d status=%d pipe=%p transaction=%p size=%d\n",
1997 iso_packet[i].status, pipe,
2016 dev_dbg(dev, "status=stall pipe=%p transaction=%p size=%d\n",
2017 pipe, transaction, bytes_transferred);
2021 dev_dbg(dev, "status=babble pipe=%p transaction=%p size=%d\n",
2022 pipe, transaction, bytes_transferred);
2026 dev_dbg(dev, "status=short pipe=%p transaction=%p size=%d\n",
2027 pipe, transaction, bytes_transferred);
2034 dev_dbg(dev, "status=%d pipe=%p transaction=%p size=%d\n",
2035 status, pipe, transaction, bytes_transferred);
2047 * transaction will be removed from the pipe transaction list.
2050 * @pipe: Pipe the transaction is on
2057 struct cvmx_usb_pipe *pipe,
2091 /* Remove the transaction from the pipe list */
2093 if (list_empty(&pipe->transactions))
2094 list_move_tail(&pipe->node, &usb->idle_pipes);
2095 octeon_usb_urb_complete_callback(usb, complete_code, pipe,
2103 * Submit a usb transaction to a pipe. Called for all types
2107 * @pipe: Which pipe to submit to.
2126 struct cvmx_usb_pipe *pipe,
2138 if (unlikely(pipe->transfer_type != type))
2159 if (!list_empty(&pipe->transactions)) {
2160 list_add_tail(&transaction->node, &pipe->transactions);
2162 list_add_tail(&transaction->node, &pipe->transactions);
2163 list_move_tail(&pipe->node,
2164 &usb->active_pipes[pipe->transfer_type]);
2167 * We may need to schedule the pipe if this was the head of the
2168 * pipe.
2177 * Call to submit a USB Bulk transfer to a pipe.
2180 * @pipe: Handle to the pipe for the transfer.
2187 struct cvmx_usb_pipe *pipe,
2190 return cvmx_usb_submit_transaction(usb, pipe, CVMX_USB_TRANSFER_BULK,
2201 * Call to submit a USB Interrupt transfer to a pipe.
2204 * @pipe: Handle to the pipe for the transfer.
2211 struct cvmx_usb_pipe *pipe,
2214 return cvmx_usb_submit_transaction(usb, pipe,
2226 * Call to submit a USB Control transfer to a pipe.
2229 * @pipe: Handle to the pipe for the transfer.
2236 struct cvmx_usb_pipe *pipe,
2246 return cvmx_usb_submit_transaction(usb, pipe,
2257 * Call to submit a USB Isochronous transfer to a pipe.
2260 * @pipe: Handle to the pipe for the transfer.
2267 struct cvmx_usb_pipe *pipe,
2273 return cvmx_usb_submit_transaction(usb, pipe,
2284 * Cancel one outstanding request in a pipe. Canceling a request
2291 * @pipe: Pipe to cancel requests in.
2297 struct cvmx_usb_pipe *pipe,
2304 if (list_first_entry(&pipe->transactions, typeof(*transaction), node) ==
2305 transaction && (pipe->flags & CVMX_USB_PIPE_FLAGS_SCHEDULED)) {
2308 usb->pipe_for_channel[pipe->channel] = NULL;
2309 pipe->flags &= ~CVMX_USB_PIPE_FLAGS_SCHEDULED;
2314 CVMX_USBCX_HCCHARX(pipe->channel,
2323 CVMX_USBCX_HCCHARX(pipe->channel,
2328 cvmx_usb_complete(usb, pipe, transaction, CVMX_USB_STATUS_CANCEL);
2333 * Cancel all outstanding requests in a pipe. Logically all this
2337 * @pipe: Pipe to cancel requests in.
2342 struct cvmx_usb_pipe *pipe)
2347 list_for_each_entry_safe(transaction, next, &pipe->transactions, node) {
2348 int result = cvmx_usb_cancel(usb, pipe, transaction);
2357 * Close a pipe created with cvmx_usb_open_pipe().
2360 * @pipe: Pipe to close.
2362 * Returns: 0 or a negative error code. EBUSY is returned if the pipe has
2366 struct cvmx_usb_pipe *pipe)
2368 /* Fail if the pipe has pending transactions */
2369 if (!list_empty(&pipe->transactions))
2372 list_del(&pipe->node);
2373 kfree(pipe);
2396 struct cvmx_usb_pipe *pipe,
2406 cvmx_usb_complete(usb, pipe, transaction,
2410 pipe->pid_toggle = 1;
2411 if (cvmx_usb_pipe_needs_split(usb, pipe)) {
2434 if (cvmx_usb_pipe_needs_split(usb, pipe)) {
2443 if (buffer_space_left < pipe->max_packet)
2448 pipe->max_packet;
2451 (bytes_in_last_packet < pipe->max_packet)) {
2452 pipe->pid_toggle = 1;
2458 (bytes_in_last_packet < pipe->max_packet)) {
2459 pipe->pid_toggle = 1;
2466 if (cvmx_usb_pipe_needs_split(usb, pipe))
2470 cvmx_usb_complete(usb, pipe, transaction,
2474 cvmx_usb_complete(usb, pipe, transaction, CVMX_USB_STATUS_OK);
2480 struct cvmx_usb_pipe *pipe,
2491 if (cvmx_usb_pipe_needs_split(usb, pipe)) {
2496 (bytes_in_last_packet == pipe->max_packet))
2499 cvmx_usb_complete(usb, pipe, transaction,
2502 if ((pipe->device_speed == CVMX_USB_SPEED_HIGH) &&
2503 (pipe->transfer_dir == CVMX_USB_DIRECTION_OUT) &&
2505 pipe->flags |= CVMX_USB_PIPE_FLAGS_NEED_PING;
2507 (bytes_in_last_packet < pipe->max_packet))
2508 cvmx_usb_complete(usb, pipe, transaction,
2514 struct cvmx_usb_pipe *pipe,
2519 if (cvmx_usb_pipe_needs_split(usb, pipe)) {
2524 (bytes_in_last_packet == pipe->max_packet)) {
2527 pipe->next_tx_frame += pipe->interval;
2528 cvmx_usb_complete(usb, pipe, transaction,
2532 (bytes_in_last_packet < pipe->max_packet)) {
2533 pipe->next_tx_frame += pipe->interval;
2534 cvmx_usb_complete(usb, pipe, transaction, CVMX_USB_STATUS_OK);
2539 struct cvmx_usb_pipe *pipe,
2545 if (cvmx_usb_pipe_needs_split(usb, pipe)) {
2550 * the pipe sleeps until the next schedule interval.
2552 if (pipe->transfer_dir == CVMX_USB_DIRECTION_OUT) {
2559 pipe->next_tx_frame += pipe->interval;
2560 cvmx_usb_complete(usb, pipe, transaction,
2572 (bytes_in_last_packet < pipe->max_packet)) {
2573 pipe->next_tx_frame += pipe->interval;
2574 cvmx_usb_complete(usb, pipe, transaction,
2582 pipe->next_tx_frame += pipe->interval;
2583 cvmx_usb_complete(usb, pipe, transaction, CVMX_USB_STATUS_OK);
2602 struct cvmx_usb_pipe *pipe;
2673 /* Make sure this channel is tied to a valid pipe */
2674 pipe = usb->pipe_for_channel[channel];
2675 prefetch(pipe);
2676 if (!pipe)
2678 transaction = list_first_entry(&pipe->transactions,
2684 * Disconnect this pipe from the HW channel. Later the schedule
2685 * function will figure out which pipe needs to go
2688 pipe->flags &= ~CVMX_USB_PIPE_FLAGS_SCHEDULED;
2761 pipe->pid_toggle = !(usbc_hctsiz.s.pid == 0);
2768 if ((pipe->device_speed == CVMX_USB_SPEED_HIGH) &&
2769 (pipe->transfer_type == CVMX_USB_TRANSFER_BULK) &&
2770 (pipe->transfer_dir == CVMX_USB_DIRECTION_OUT))
2771 pipe->flags |= CVMX_USB_PIPE_FLAGS_NEED_PING;
2779 cvmx_usb_complete(usb, pipe, transaction,
2791 pipe->pid_toggle = 0;
2792 cvmx_usb_complete(usb, pipe, transaction,
2800 cvmx_usb_complete(usb, pipe, transaction,
2804 cvmx_usb_complete(usb, pipe, transaction,
2808 cvmx_usb_complete(usb, pipe, transaction,
2817 if (!cvmx_usb_pipe_needs_split(usb, pipe)) {
2824 (bytes_in_last_packet < pipe->max_packet))
2825 cvmx_usb_complete(usb, pipe,
2841 pipe->split_sc_frame = -1;
2855 * this pipe
2857 pipe->flags &= ~CVMX_USB_PIPE_FLAGS_NEED_PING;
2861 cvmx_usb_transfer_control(usb, pipe, transaction,
2867 cvmx_usb_transfer_bulk(usb, pipe, transaction,
2872 cvmx_usb_transfer_intr(usb, pipe, transaction,
2877 cvmx_usb_transfer_isoc(usb, pipe, transaction,
2897 pipe->next_tx_frame += pipe->interval;
2898 if (pipe->next_tx_frame < usb->frame_number)
2899 pipe->next_tx_frame = usb->frame_number +
2900 pipe->interval -
2901 (usb->frame_number - pipe->next_tx_frame) %
2902 pipe->interval;
2915 cvmx_usb_complete(usb, pipe, transaction,
3074 struct cvmx_usb_pipe *pipe;
3095 switch (usb_pipetype(urb->pipe)) {
3151 pipe = cvmx_usb_open_pipe(usb, usb_pipedevice(urb->pipe),
3152 usb_pipeendpoint(urb->pipe), speed,
3156 usb_pipein(urb->pipe) ?
3163 if (!pipe) {
3166 dev_dbg(dev, "Failed to create pipe\n");
3169 ep->hcpriv = pipe;
3171 pipe = ep->hcpriv;
3174 switch (usb_pipetype(urb->pipe)) {
3177 usb_pipedevice(urb->pipe),
3178 usb_pipeendpoint(urb->pipe));
3203 pipe, urb);
3216 usb_pipedevice(urb->pipe),
3217 usb_pipeendpoint(urb->pipe));
3218 transaction = cvmx_usb_submit_interrupt(usb, pipe, urb);
3222 usb_pipedevice(urb->pipe),
3223 usb_pipeendpoint(urb->pipe));
3224 transaction = cvmx_usb_submit_control(usb, pipe, urb);
3228 usb_pipedevice(urb->pipe),
3229 usb_pipeendpoint(urb->pipe));
3230 transaction = cvmx_usb_submit_bulk(usb, pipe, urb);
3277 struct cvmx_usb_pipe *pipe = ep->hcpriv;
3281 cvmx_usb_cancel_all(usb, pipe);
3282 if (cvmx_usb_close_pipe(usb, pipe))
3283 dev_dbg(dev, "Closing pipe %p failed\n", pipe);