summaryrefslogtreecommitdiff
path: root/usr/src/man/man9f/usb_alloc_request.9f
blob: 9e5baeadde11985e0c98184614132a11545fae2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
'\" te
.\" Copyright (c) 2004, Sun Microsystems, Inc., All Rights Reserved
.\" 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.
.\" 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.
.\" 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]
.TH USB_ALLOC_REQUEST 9F "Jul 25, 2004"
.SH NAME
usb_alloc_request, usb_alloc_ctrl_req, usb_free_ctrl_req, usb_alloc_bulk_req,
usb_free_bulk_req, usb_alloc_intr_req, usb_free_intr_req, usb_alloc_isoc_req,
usb_free_isoc_req \- Allocate and free USB transfer requests
.SH SYNOPSIS
.nf
#include <sys/usb/usba.h>

\fBusb_ctrl_req_t *\fR\fBusb_alloc_ctrl_req\fR(\fBdev_info_t *\fR\fIdip\fR, \fBsize_t\fR \fIlen\fR,
     \fBusb_flags_t\fR \fIflags\fR);
.fi

.LP
.nf
\fBvoid\fR \fBusb_free_ctrl_req\fR(\fBusb_ctrl_req_t *\fR\fIrequest\fR);
.fi

.LP
.nf
\fBusb_bulk_req_t *\fR\fBusb_alloc_bulk_req\fR(\fBdev_info_t\fR \fIdip\fR, \fBsize_t\fR \fIlen\fR,
     \fBusb_flags_t\fR \fIflags\fR);
.fi

.LP
.nf
\fBvoid\fR \fBusb_free_bulk_req\fR(\fBusb_bulk_req_t *\fR\fIrequest\fR);
.fi

.LP
.nf
\fBusb_intr_req_t *\fR\fBusb_alloc_intr_req\fR(\fBdev_info_t *\fR\fIdip\fR, \fBsize_t\fR \fIlen\fR,
     \fBusb_flags_t\fR \fIflags\fR);
.fi

.LP
.nf
\fBvoid\fR \fBusb_free_intr_req\fR(\fBusb_intr_req_t *\fR\fIrequest\fR);
.fi

.LP
.nf
\fBusb_isoc_req_t *\fR\fBusb_alloc_isoc_req\fR(\fBdev_info_t *\fR\fIdip\fR,
     \fBuint_t\fR \fIisoc_pkts_count\fR, \fBsize_t\fR \fIlen\fR, \fBusb_flags_t\fR \fIflags\fR);
.fi

.LP
.nf
\fBvoid\fR \fBusb_free_isoc_req\fR(\fBusb_isoc_req_t *\fR\fIrequest\fR);
.fi

.SH INTERFACE LEVEL
illumos DDI specific (illumos DDI)
.SH PARAMETERS
For \fBusb_alloc_ctrl_req()\fR, \fBusb_alloc_bulk_req()\fR and
\fBusb_alloc_intr_req()\fR:
.sp
.ne 2
.na
\fB\fIdip\fR\fR
.ad
.RS 9n
Pointer to the device's dev_info structure.
.RE

.sp
.ne 2
.na
\fB\fIlen\fR\fR
.ad
.RS 9n
Length of \fIdata\fR for this request.
.RE

.sp
.ne 2
.na
\fB\fIflags\fR\fR
.ad
.RS 9n
Only USB_FLAGS_SLEEP is recognized. Wait for resources if not immediately
available.
.RE

.sp
.LP
For \fBusb_alloc_isoc_req()\fR:
.sp
.ne 2
.na
\fB\fIdip\fR\fR
.ad
.RS 19n
Pointer to the device's dev_info structure.
.RE

.sp
.ne 2
.na
\fB\fIisoc_pkts_count\fR\fR
.ad
.RS 19n
Number of isochronous packet descriptors to associate with this request. Must
be greater than zero.
.RE

.sp
.ne 2
.na
\fB\fIlen\fR\fR
.ad
.RS 19n
Length of \fIdata\fR for this isochronous request.
.RE

.sp
.ne 2
.na
\fB\fIflags\fR\fR
.ad
.RS 19n
Only USB_FLAGS_SLEEP is recognized. Wait for resources if not immediately
available.
.RE

.sp
.LP
For \fBusb_free_ctrl_req()\fR, \fBusb_free_bulk_req()\fR,
\fBusb_free_intr_req()\fR and \fBusb_free_isoc_req()\fR:
.sp
.ne 2
.na
\fB\fIrequest\fR\fR
.ad
.RS 11n
Pointer to the request structure to be freed. Can be \fBNULL\fR.
.RE

.SH DESCRIPTION
The \fBusb_alloc_ctrl_req()\fR, \fBusb_alloc_bulk_req()\fR,
\fBusb_alloc_intr_req()\fR, and \fBusb_alloc_isoc_req()\fR functions allocate
control, bulk, interrupt, or     isochronous requests. Optionally, these
functions can also allocate an mblk of the specified length to pass data
associated  with the request. (For guidelines on mblk data allocation, see the
manpage for the relevant transfer function).
.sp
.LP
The \fBusb_alloc_isoc_req()\fR function also allocates a number of isochronous
packet descriptors (usb_isoc_pkt_descr_t) specified by isoc_pkts_count to the
end of the request proper (usb_isoc_req_t).  See \fBusb_isoc_request\fR(9S) for
more information on isochronous packet descriptors.
.sp
.LP
These functions always succeed when the USB_FLAGS_SLEEP flag is set, provided
that they are given valid args and are not called from interrupt context.
.sp
.LP
The \fBusb_free_ctrl_req()\fR, \fBusb_free_bulk_req()\fR,
\fBusb_free_intr_req()\fR, and \fBusb_free_isoc_req()\fR functions free their
corresponding request. If the request's data block pointer is non-zero, the
data block is also freed. For isoc requests, the array of packet descriptors is
freed.
.SH RETURN VALUES
For \fBusb_alloc_ctrl_req()\fR, \fBusb_alloc_bulk_req()\fR,
\fBusb_alloc_intr_req()\fR and \fBusb_alloc_isoc_req()\fR:
.sp
.LP
On success: returns a pointer to the appropriate usb_xxx_request_t.
.sp
.LP
On failure: returns \fBNULL\fR. Fails because the dip argument is invalid,
USB_FLAGS_SLEEP is not set and memory is not available or because
USB_FLAGS_SLEEP is set but the call was made in interrupt context.
.sp
.LP
For \fBusb_free_ctrl_req()\fR, \fBusb_free_bulk_req()\fR,
\fBusb_free_intr_req()\fR and \fBusb_free_isoc_req()\fR: None.
.SH CONTEXT
The allocation routines can always be called from kernel and user context. They
may be called from interrupt context only if USB_FLAGS_SLEEP is not specified.
.sp
.LP
The free routines may be called from kernel, user, and interrupt context.
.SH EXAMPLES
.in +2
.nf
    /* This allocates and initializes an asynchronous control
     * request which will pass no data.  Asynchronous requests
     * are used when they cannot block the calling thread.
     */

    usb_ctrl_req_t *ctrl_req;

    if ((ctrl_req = usb_alloc_ctrl_req(dip, 0, 0)) == NULL) {
            return (FAILURE);
    }

    /* Now initialize. */
    ctrl_req->ctrl_bmRequestType = USB_DEV_REQ_DEV_TO_HOST |
        USB_DEV_REQ_STANDARD | USB_DEV_REQ_RCPT_DEV;

    ctrl_req->ctrl_bRequest      = (uint8_t)USB_REQ_GET_STATUS;
    ...
    ...
    ctrl_req->ctrl_callback     = normal_callback;
    ctrl_req->ctrl_exc_callback = exception_callback;
    ...
    ...

.fi
.in -2

.SH ATTRIBUTES
See \fBattributes\fR(5) for descriptions of the following attributes:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
Architecture	PCI-based systems
_
Interface stability	Committed
.TE

.SH SEE ALSO
\fBattributes\fR(5), \fBusb_get_current_frame_number\fR(9F),
\fBusb_get_max_pkts_per_isoc_request\fR(9F),
\fBusb_pipe_get_max_bulk_transfer_size\fR(9F), \fBusb_pipe_bulk_xfer\fR(9F),
\fBusb_pipe_ctrl_xfer\fR(9F), \fBusb_pipe_intr_xfer\fR(9F),
\fBusb_pipe_isoc_xfer\fR(9F), \fBusb_bulk_request\fR(9S),
\fBusb_ctrl_request\fR(9S), \fBusb_intr_request\fR(9S),
\fBusb_isoc_request\fR(9S)