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_INTR_XFER 9E
18 .Nm usba_hcdi_pipe_intr_xfer
19 .Nd perform a USB interrupt transfer
21 .In sys/usb/usba/hcdi.h
23 .Fo prefix_hcdi_pipe_intr_xfer
24 .Fa "usba_pipe_handle_data_t *ph"
25 .Fa "usb_intr_req_t *uirp"
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 interrupt 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_intr_xfer
63 entry point is used to initiate an
65 USB interrupt 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, rather than initiating an I/O transfer, the driver may need to
78 Unlike other transfers, interrupt transfers may be periodic.
79 If the transfer is meant to be a one-shot, then the
80 .Sy USB_ATTRS_ONE_XFER
81 flag will be set in the
87 .Sy USB_ATTRS_ONE_XFER
88 flag is not set, then the transfer begins a periodic transfer.
89 Periodic transfers have different handling and behavior.
91 Interrupt transfers may send data to the device or receive data from the device.
92 A given interrupt endpoint is uni-directional.
93 The direction can be determined from the endpoint address based on the
99 for more information on how to determine the direction of the endpoint.
101 The device driver should allocate memory, whether memory suitable for a
102 DMA transfer or otherwise, to perform the transfer.
103 For all memory allocated, it should honor the values in
105 to determine whether or not it should block for allocations.
107 The length of the interrupt transfer and its data can be found in the
116 structure that should not be used directly and data should be copied to
117 or from the data buffer that will go the controller.
119 Unlike bulk and control transfers, the
121 member may not be allocated for interrupt-IN transfers.
122 In such cases, the device driver is required to allocate the message block
123 through something like
129 If the driver successfully schedules the I/O, then it should return
131 When the I/O completes, it must call
135 If the transfer fails, but the driver returned
139 and should specify an error there.
141 It is the driver's responsibility to time out one-shot interrupt transfer
143 If the timeout in the request as indicated in the
147 is set to zero, then the driver should use the USBA default timeout of
148 .Sy HCDI_DEFAULT_TIMEOUT .
149 All timeout values are in
151 .Ss Periodic Transfers
153 .Sy USB_ATTRS_ONE_XFER
154 flag is not present, it indicates that a periodic interrupt transfer is
156 Once a periodic interrupt transfer is initiated, every time data is received the
159 with the updated data.
161 When a periodic transfer is initiated, many controller drivers will
162 allocate multiple transfers up front and schedule them all.
163 Many drivers do this to ensure that data isn't lost between servicing the first
164 transfer and scheduling the next.
165 The number of such transfers used depends on the polling frequency specified in
166 the endpoint descriptor.
168 Unless an error occurs, the driver must not use the original interrupt
171 Instead, it should duplicate the request through the
172 .Xr usba_hcdi_dup_intr_req 9F
173 function before calling
174 .Xr usba_hcdi_cb 9F .
176 The driver should return the original transfer in one of the following
180 A pipe reset request came in from the
181 .Xr usba_hcdi_pipe_reset 9E
184 A request to stop polling came in from the
185 .Xr usba_hcdi_pipe_stop_intr_polling 9E
188 A request to close the pipe came in from the
189 .Xr usba_hcdi_pipe_close 9E
192 An out of memory condition occurred.
193 The caller should call
196 .Sy USB_CR_NO_RESOURCES .
198 Some other transfer error occurred.
201 If the periodic interrupt transfer is for the root hub, the driver will
202 need to emulate the behavior of a hub as specified in the USB
204 For more information, see the
205 .Sx Root Hub Management
208 .Ss Callback Handling
209 When the interrupt transfer completes, the driver should consider the
210 following items to determine what actions it should take on the
213 Otherwise, it should return the appropriate USB error.
218 If the transfer timed out, it should remove the transfer from the
219 outstanding list, queue the next transfer, and return the transfer back
220 to the OS with the error code
223 .Xr usba_hcdi_cb 9F .
225 If the transfer failed, it should find the appropriate error and call
229 If the transfer succeeded, but less data was transferred than expected,
235 .Sy USB_ATTRS_SHORT_XFER_OK
236 flag is not present, then the driver should call
239 .Sy USB_CR_DATA_UNDERRUN .
241 If the transfer was going to the host, then the driver should copy the
242 data into the transfer's message block and update the
247 If everything was successful, call
252 If this was a periodic transfer, it should reschedule the transfer.
255 Upon successful completion, the
256 .Fn usba_hcdi_pipe_intr_xfer
257 function should return
258 function should return
260 Otherwise, it should return the appropriate USB error.
265 .Xr usba_hcdi_pipe_close 9E ,
266 .Xr usba_hcdi_pipe_reset 9E ,
267 .Xr usba_hcdi_pipe_stop_intr_polling 9E ,
269 .Xr usba_hcdi_cb 9F ,
270 .Xr usba_hcdi_dup_intr_req 9F ,
272 .Xr usb_ep_descr 9S ,
273 .Xr usb_intr_req 9S ,
274 .Xr usba_pipe_handle_data 9S