2 .\" This file and its contents are supplied under the terms of the
3 .\" Common Development and Distribution License ("CDDL"), version 1.0.
4 .\" You may only use this file in accordance with the terms of version
7 .\" A full copy of the text of the CDDL should have accompanied this
8 .\" source. A copy of the CDDL is also available via the Internet at
9 .\" http://www.illumos.org/license/CDDL.
12 .\" Copyright 2016 Joyent, Inc.
15 .Dt USBA_HCDI_PIPE_ISOC_XFER 9E
18 .Nm usba_hcdi_pipe_isoc_xfer
19 .Nd perform a USB isochronous transfer
21 .In sys/usb/usba/hcdi.h
23 .Fo prefix_hcdi_pipe_isoc_xfer
24 .Fa "usba_pipe_handle_data_t *ph"
25 .Fa "usb_isoc_req_t *usrp"
26 .Fa "usb_flags_t usb_flags"
30 illumos USB HCD private function
32 This is a private function that is not part of the stable DDI.
33 It may be removed or changed at any time.
37 A pointer to a USB pipe handle as defined in
38 .Xr usba_pipe_handle_data 9S .
40 A pointer to a USB isochronous transfer request.
41 The structure's members are documented in
44 Flags which describe how allocations should be performed.
47 .It Sy USB_FLAGS_NOSLEEP
48 Do not block waiting for memory.
49 If memory is not available the allocation will fail.
50 .It Sy USB_FLAGS_SLEEP
51 Perform a blocking allocation.
52 If memory is not available, the function will wait until memory is made
55 Note, the request may still fail even if
62 .Fn usba_hcdi_pipe_isoc_xfer
63 entry point is used to initiate an
65 USB isochronous transfer on the pipe
67 The specific USB interrupt transfer is provided in
69 For more background on transfer types, see
72 The host controller driver should first check the USB address of the
74 It may correspond to the root hub.
75 If it does, the driver should return
76 .Sy USB_NOT_SUPPORTED .
78 Isochronous transfers happen once a period.
79 Isochronous transfers may just be told to start as son as possible or to line up
81 At this time, nothing in the system uses the later behavior.
82 It is reasonable for a new driver to require that the
83 .Sy USB_ATTRS_ISOC_XFER_ASAP
89 In the case where it's not set and the controller driver does not support
90 setting the frame, it should return
91 .Sy USB_NOT_SUPPORTED .
93 Isochronous-IN transfers are
95 Isochronous-OUT transfers are one shot transfers.
96 Periodic transfers have slightly different handling and behavior.
98 Isochronous transfers may send data to the device or receive data from
100 A given isochronous endpoint is uni-directional.
101 The direction can be determined from the endpoint address based on the
107 for more information on how to determine the direction of the endpoint.
109 Isochronous transfers are a little bit different from other transfers.
110 While there is still a single
112 structure that all the data goes to or from, the transfer may be broken
113 up into multiple packets.
114 All of these packets make up a single transfer request and each one represents
115 the data that is transferred during a single portion of a frame.
116 For the description of them, see
117 .Xr usb_isoc_req 9S .
118 Because of these data structures, the way that transfers are recorded is
119 different and will be discussed later on.
121 The device driver should allocate memory, whether memory suitable for a
122 DMA transfer or otherwise, to perform the transfer.
123 For all memory allocated, it should honor the values in
125 to determine whether or not it should block for allocations.
127 For isochronous-out transfers which are one-shot transfers, the driver
128 should verify that the sum of all of the individual packet counts
129 matches the message block length of the data.
130 If it does not, then the driver should return
131 .Sy USB_INVALID_ARGS .
133 If the driver successfully schedules the I/O, then it should return
135 When the I/O completes, it must call
139 If the transfer fails, but the driver returned
143 and should specify an error there.
145 The driver is responsible for timing out all one-shot outgoing requests.
146 As there is no timeout member in the isochronous request structure, then
147 the timeout should be set to
148 .Sy HCDI_DEFAULT_TIMEOUT .
149 .Ss Periodic Transfers
150 All isochronous-in transfers are periodic transfers.
151 Once a periodic transfer is initiated, every time data is received the driver
154 function with updated data.
156 When a periodic transfer is initiated, many controller drivers will
157 allocate multiple transfers up front and schedule them all.
158 Many drivers do this to ensure that data isn't lost between servicing the first
159 transfer and scheduling the next.
160 The number of such transfers used depends on the polling frequency specified in
161 the endpoint descriptor.
163 Unless an error occurs, the driver must not use the original isochronous
166 Instead, it should duplicate the request through the
167 .Xr usba_hcdi_dup_isoc_req 9F
168 function before calling
169 .Xr usba_hcdi_cb 9F .
171 The driver should return the original transfer in one of the following
175 A pipe reset request came in from the
176 .Xr usba_hcdi_pipe_rest 9E
179 A request to stop polling came in from the
180 .Xr usba_hcdi_pipe_stop_isoc_polling 9E
183 A request to close the pipe came in from the
184 .Xr usba_hcdi_pipe_close 9E
187 An out of memory condition occurred.
188 The caller should call
191 .Sy USB_CR_NO_RESOURCES .
193 Some other transfer error occurred.
195 .Ss Callback Handling
196 When the isochronous transfer completes, the driver should consider the
197 following items to determine what actions it should take on the
200 Otherwise, it should return the appropriate USB error.
205 If the transfer timed out, it should remove the transfer from the
206 outstanding list, queue the next transfer, and return the transfer back
207 to the OS with the error code
210 .Xr usba_hcdi_cb 9F .
212 If the transfer failed, it should find the appropriate error and call
216 If the transfer succeeded, but less data was transferred than expected,
222 .Sy USB_ATTRS_SHORT_XFER_OK
223 flag is not present, then the driver should call
226 .Sy USB_CR_DATA_UNDERRUN .
228 If the transfer was going to the host, then the driver should copy the
229 data into the transfer's message block and update the
234 The driver should update the
235 .Sy isoc_pkt_actual_length
240 structure with the actual transfer amounts.
242 If everything was successful, call
247 If this was a periodic transfer, it should reschedule the transfer.
250 Upon successful completion, the
251 .Fn usba_hcdi_pipe_isoc_xfer
252 function should return
253 function should return
255 Otherwise, it should return the appropriate USB error.
260 .Xr usba_hcdi_pipe_close 9E ,
261 .Xr usba_hcdi_pipe_rest 9E ,
262 .Xr usba_hcdi_pipe_stop_isoc_polling 9E ,
263 .Xr usba_hcdi_cb 9F ,
264 .Xr usba_hcdi_dup_isoc_req 9F ,
266 .Xr usb_ep_descr 9S ,
267 .Xr usb_isoc_req 9S ,
268 .Xr usba_pipe_handle_data 9S