1 .\" Copyright (c) 2004, Sun Microsystems, Inc., All Rights Reserved
2 .\" Copyright 2016 Joyent, Inc.
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
12 .Nd Open a USB pipe to a device
18 .Fa "usb_ep_descr_t *endpoint"
19 .Fa "usb_pipe_policy_t *pipe_policy"
20 .Fa "usb_flags_t flags"
21 .Fa "usb_pipe_handle_t *pipe_handle"
26 .Fa "usb_ep_xdescr_t *extended_endpoint"
27 .Fa "usb_pipe_policy_t *pipe_policy"
28 .Fa "usb_flags_t flags"
29 .Fa "usb_pipe_handle_t *pipe_handle"
32 Solaris DDI specific (Solaris DDI)
36 Pointer to the device's
40 Pointer to endpoint descriptor.
41 .It Fa extended_endpoint
42 Pointer to an extended endpoint descriptor retrieved from calling
43 .Xr usb_ep_xdescr_fill 9F .
48 provides hints on pipe usage.
51 is only flag that is recognized.
52 Wait for memory resources if not immediately available.
54 Address to where new pipe handle is returned.
55 (The handle is opaque.)
58 A pipe is a logical connection to an endpoint on a USB device.
61 function creates such a logical connection and returns an
62 initialized handle which refers to that connection.
66 specification defines four endpoint types, each with a
67 corresponding type of pipe.
68 Each of the four types of pipes uses its physical connection resource
73 Used for bursty, non-periodic, reliable, host-initiated request/response
74 communication, such as for command/status operations.
75 These are guaranteed to get approximately 10% of frame time and will get more if
76 needed and if available, but there is no guarantee on transfer promptness.
79 Used for large, reliable, non-time-critical data transfers.
80 These get the bus on a bandwidth-available basis.
82 Sample uses include printer data.
84 Used for sending or receiving small amounts of reliable data infrequently but
85 with bounded service periods, as for interrupt handling.
87 .It Sy Isochronous Pipe
88 Used for large, unreliable, time-critical data transfers.
89 Boasts a guaranteed constant data rate as long as there is data, but there are
90 no retries of failed transfers.
91 Interrupt and isochronous data are together guaranteed 90% of frame time as
94 Sample uses include audio.
97 The type of endpoint to which a pipe connects (and therefore the pipe type) is
100 field of that pipe's endpoint descriptor.
108 specification, only the
110 was required to identify all of the attributes of a given pipe.
113 there are additional endpoint companion descriptors required to open a
115 To support SuperSpeed devices, the new
117 function must be used rather than the older
122 structure can be automatically filled out and obtained by calling the
123 .Xr usb_ep_xdescr_fill 9F
126 Opens to interrupt and isochronous pipes can fail if the required bandwidth
127 cannot be guaranteed.
129 The polling interval for periodic (interrupt or isochronous) pipes, carried by
130 the endpoint argument's bInterval field, must be within range.
133 Full speed: range of 1-255 maps to 1-255 ms.
135 Low speed: range of 10-255 maps to 10-255 ms.
137 High speed: range of 1-16 maps to (2**(bInterval-1)) * 125us.
139 Super speed: range of 1-16 maps to (2**(bInterval-1)) * 125us.
141 Adequate bandwidth during transfers is guaranteed for all periodic pipes which
142 are opened successfully.
143 Interrupt and isochronous pipes have guaranteed latency times, so bandwidth for
144 them is allocated when they are opened.
146 Please refer to Sections
153 which address isochronous and interrupt transfers.
155 Opens of interrupt and isochronous pipes fail if inadequate bandwidth is
156 available to support their guaranteed latency time.
157 Because periodic pipe bandwidth is allocated on pipe open, open periodic pipes
160 The bandwidth required by a device varies based on polling interval, the
162 .Pq Sy wMaxPacketSize
163 and the device speed.
164 Unallocated bandwidth remaining for new devices depends on the bandwidth already
165 allocated for previously opened periodic pipes.
169 parameter provides a hint as to pipe usage and must be specified.
171 .Em usb_pipe_policy_t
172 which contains the following fields:
173 .Bd -literal -offset indent
174 uchar_t pp_max_async_reqs:
178 .Sy pp_max_async_reqs
179 member is a hint indicating how many asynchronous operations requiring
180 their own kernel thread will be concurrently in progress, the highest
181 number of threads ever needed at one time.
182 Allow at least one for synchronous callback handling and as many as are needed
183 to accommodate the anticipated parallelism of asynchronous* calls to the
185 .Xr usb_pipe_close 9F ,
187 .Xr usb_set_alt_if 9F ,
188 .Xr usb_clr_feature 9F ,
189 .Xr usb_pipe_reset 9F ,
190 .Xr usb_pipe_drain_reqs 9F ,
191 .Xr usb_pipe_stop_intr_polling 9F ,
193 .Xr usb_pipe_stop_isoc_polling 9F .
195 Setting to too small a value can deadlock the pipe.
196 Asynchronous calls are calls made without the
199 Note that a large number of callbacks becomes an issue mainly when blocking
200 functions are called from callback handlers.
202 The control pipe to the default endpoints (endpoints for both directions with
203 addr 0, sometimes called the default control pipe or default pipe) comes
204 pre-opened by the hub.
205 A client driver receives the default control pipe handle through
206 .Xr usb_get_dev_data 9F .
207 A client driver cannot open the default
208 control pipe manually.
209 Note that the same control pipe may be shared among several drivers when a
210 device has multiple interfaces and each interface is operated by its own driver.
212 All explicit pipe opens are exclusive; attempts to open an opened pipe fail.
214 On success, the pipe_handle argument points to an opaque handle of the opened
216 On failure, it is set to NULL.
218 May be called from user or kernel context regardless of arguments.
219 May also be called from interrupt context if the
226 .It Sy USB_NO_RESOURCES
227 Insufficient resources were available.
228 .It Sy USB_NO_BANDWIDTH
229 Insufficient bandwidth available.
230 (isochronous and interrupt pipes).
231 .It Sy USB_INVALID_CONTEXT
232 Called from interrupt handler with USB_FLAGS_SLEEP set.
233 .It Sy USB_INVALID_ARGS
234 dip and/or pipe_handle is NULL.
236 .It Sy USB_INVALID_PERM
237 Endpoint is NULL, signifying the default control pipe.
238 A client driver cannot open the default control pipe.
239 .It Sy USB_NOT_SUPPORTED
240 Isochronous or interrupt endpoint with maximum packet size of zero is not
242 .It Sy USB_HC_HARDWARE_ERROR
243 Host controller is in an error state.
245 Pipe is already open.
246 Host controller not in an operational state.
248 .Pq Sy Bep_descr bInterval No field
249 is out of range (intr or isoc pipes).
251 The device referred to by
253 is at least a SuperSpeed device and the older
258 .Bd -literal -offset indent
259 usb_ep_data_t *ep_data;
260 usb_ep_xdescr_t ep_xdescr;
261 usb_pipe_policy_t policy;
262 usb_pipe_handle_t pipe;
263 usb_client_dev_data_t *reg_data;
264 uint8_t interface = 1;
265 uint8_t alternate = 1;
266 uint8_t first_ep_number = 0;
268 /* Initialize pipe policy. */
269 bzero(policy, sizeof(usb_pipe_policy_t));
270 policy.pp_max_async_requests = 2;
272 /* Get tree of descriptors for device. */
273 if (usb_get_dev_data(dip, USBDRV_VERSION, ®_data,
274 USB_FLAGS_ALL_DESCR, 0) != USB_SUCCESS) {
278 /* Get first interrupt-IN endpoint. */
279 ep_data = usb_lookup_ep_data(dip, reg_data, interface, alternate,
280 first_ep_number, USB_EP_ATTR_INTR, USB_EP_DIR_IN);
281 if (ep_data == NULL) {
285 /* Translate the ep_data into the filled in usb_ep_xdescr_t */
286 if (usb_ep_xdescr_fill(USB_EP_XDESCR_CURRENT_VERSION, dip,
287 ep_data, &ep_xdescr) != USB_SUCCESS) {
291 /* Open the pipe. Get handle to pipe back in 5th argument. */
292 if (usb_pipe_open(dip, &ep_data.ep_descr
293 &policy, USB_FLAGS_SLEEP, &pipe) != USB_SUCCESS) {
298 .Xr usb_get_alt_if 9F ,
300 .Xr usb_get_dev_data 9F ,
301 .Xr usb_get_status 9F ,
302 .Xr usb_pipe_bulk_xfer 9F ,
303 .Xr usb_pipe_close 9F ,
304 .Xr usb_pipe_ctrl_xfer 9F ,
305 .Xr usb_pipe_get_state 9F ,
306 .Xr usb_pipe_intr_xfer 9F ,
307 .Xr usb_pipe_isoc_xfer 9F ,
308 .Xr usb_pipe_reset 9F ,
309 .Xr usb_pipe_set_private 9F ,
310 .Xr usb_callback_flags 9S ,
313 .%T Universal Serial Bus 3.1 Specification
314 .%U http://www.usb.org