8525 some more manpage spelling errors
[unleashed.git] / usr / src / man / man9e / usba_hcdi_pipe_isoc_xfer.9e
bloba1b90640b3b07fe1755a74a2ee4ac35843d8c555
1 .\"
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
5 .\" 1.0 of the CDDL.
6 .\"
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.
10 .\"
11 .\"
12 .\" Copyright 2016 Joyent, Inc.
13 .\"
14 .Dd Dec 22, 2016
15 .Dt USBA_HCDI_PIPE_ISOC_XFER 9E
16 .Os
17 .Sh NAME
18 .Nm usba_hcdi_pipe_isoc_xfer
19 .Nd perform a USB isochronous transfer
20 .Sh SYNOPSIS
21 .In sys/usb/usba/hcdi.h
22 .Ft int
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"
27 .Fc
28 .Sh INTERFACE LEVEL
29 .Sy Volatile -
30 illumos USB HCD private function
31 .Pp
32 This is a private function that is not part of the stable DDI.
33 It may be removed or changed at any time.
34 .Sh PARAMETERS
35 .Bl -tag -width Fa
36 .It Fa ph
37 A pointer to a USB pipe handle as defined in
38 .Xr usba_pipe_handle_data 9S .
39 .It Fa usrp
40 A pointer to a USB isochronous transfer request.
41 The structure's members are documented in
42 .Xr usb_isoc_req 9S .
43 .It Fa usb_flags
44 Flags which describe how allocations should be performed.
45 Valid flags are:
46 .Bl -tag -width Sy
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
53 available.
54 .Pp
55 Note, the request may still fail even if
56 .Sy USB_FLAGS_SLEEP
57 is specified.
58 .El
59 .El
60 .Sh DESCRIPTION
61 The
62 .Fn usba_hcdi_pipe_isoc_xfer
63 entry point is used to initiate an
64 .Em asynchronous
65 USB isochronous transfer on the pipe
66 .Fa ph .
67 The specific USB interrupt transfer is provided in
68 .Fa uirp .
69 For more background on transfer types, see
70 .Xr usba_hcdi 9E .
71 .Pp
72 The host controller driver should first check the USB address of the
73 pipe handle.
74 It may correspond to the root hub.
75 If it does, the driver should return
76 .Sy USB_NOT_SUPPORTED .
77 .Pp
78 Isochronous transfers happen once a period.
79 Isochronous transfers may just be told to start as son as possible or to line up
80 to a specific frame.
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
84 flag be set in the
85 .Sy isoc_attributes
86 member of the
87 .Fa usrp
88 argument.
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 .
92 .Pp
93 Isochronous-IN transfers are
94 .Em always periodic .
95 Isochronous-OUT transfers are one shot transfers.
96 Periodic transfers have slightly different handling and behavior.
97 .Pp
98 Isochronous transfers may send data to the device or receive data from
99 the device.
100 A given isochronous endpoint is uni-directional.
101 The direction can be determined from the endpoint address based on the
102 .Sy p_ep
103 member of
104 .Fa ubrp .
106 .Xr usb_ep_descr 9S
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
111 .Xr mblk 9S
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
124 .Fa usb_flags
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
134 .Sy USB_SUCCESS .
135 When the I/O completes, it must call
136 .Xr usba_hcdi_cb 9F
137 with
138 .Fa usrp .
139 If the transfer fails, but the driver returned
140 .Sy USB_SUCCESS ,
141 it still must call
142 .Xr usba_hcdi_cb 9F
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
152 should call the
153 .Xr usba_hcdi_cb 9F
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
164 request,
165 .Fa usrp .
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
172 conditions:
173 .Bl -bullet
175 A pipe reset request came in from the
176 .Xr usba_hcdi_pipe_rest 9E
177 entry point.
179 A request to stop polling came in from the
180 .Xr usba_hcdi_pipe_stop_isoc_polling 9E
181 entry point.
183 A request to close the pipe came in from the
184 .Xr usba_hcdi_pipe_close 9E
185 entry point.
187 An out of memory condition occurred.
188 The caller should call
189 .Xr usba_hcdi_cb 9F
190 with the code
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
198 callback:
199 .Sy USB_SUCCESS .
200 Otherwise, it should return the appropriate USB error.
201 If uncertain, use
202 .Sy USB_FAILURE .
203 .Bl -bullet
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
208 .Sy USB_CR_TIMEOUT
209 with
210 .Xr usba_hcdi_cb 9F .
212 If the transfer failed, it should find the appropriate error and call
213 .Xr usba_hcdi_cb 9F
214 with that error.
216 If the transfer succeeded, but less data was transferred than expected,
217 consult the
218 .Sy isoc_attributes
219 member of the
220 .Fa usrp .
221 If the
222 .Sy USB_ATTRS_SHORT_XFER_OK
223 flag is not present, then the driver should call
224 .Xr usba_hcdi_cb 9F
225 with the error
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
230 .Sy b_wptr
231 member of the
232 .Xr mblk 9S .
234 The driver should update the
235 .Sy isoc_pkt_actual_length
236 member of the
237 .Sy isoc_pkt_descr
238 array of the
239 .Xr usb_isoc_req 9S
240 structure with the actual transfer amounts.
242 If everything was successful, call
243 .Xr usba_hcdi_cb 9F
244 with the code
245 .Sy USB_CR_OK .
247 If this was a periodic transfer, it should reschedule the transfer.
249 .Sh RETURN VALUES
250 Upon successful completion, the
251 .Fn usba_hcdi_pipe_isoc_xfer
252 function should return
253 function should return
254 .Sy USB_SUCCESS .
255 Otherwise, it should return the appropriate USB error.
256 If uncertain, use
257 .Sy USB_FAILURE .
258 .Sh SEE ALSO
259 .Xr usba_hcdi 9E ,
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 ,
265 .Xr mblk 9S ,
266 .Xr usb_ep_descr 9S ,
267 .Xr usb_isoc_req 9S ,
268 .Xr usba_pipe_handle_data 9S