1usb_alloc_request(9F)    Kernel Functions for Drivers    usb_alloc_request(9F)
2
3
4

NAME

6       usb_alloc_request,        usb_alloc_ctrl_req,        usb_free_ctrl_req,
7       usb_alloc_bulk_req,       usb_free_bulk_req,        usb_alloc_intr_req,
8       usb_free_intr_req, usb_alloc_isoc_req, usb_free_isoc_req - Allocate and
9       free USB transfer requests
10

SYNOPSIS

12       #include <sys/usb/usba.h>
13
14       usb_ctrl_req_t *usb_alloc_ctrl_req(dev_info_t *dip, size_t len,
15            usb_flags_t flags);
16
17
18       void usb_free_ctrl_req(usb_ctrl_req_t *request);
19
20
21       usb_bulk_req_t *usb_alloc_bulk_req(dev_info_t dip, size_t len,
22            usb_flags_t flags);
23
24
25       void usb_free_bulk_req(usb_bulk_req_t *request);
26
27
28       usb_intr_req_t *usb_alloc_intr_req(dev_info_t *dip, size_t len,
29            usb_flags_t flags);
30
31
32       void usb_free_intr_req(usb_intr_req_t *request);
33
34
35       usb_isoc_req_t *usb_alloc_isoc_req(dev_info_t *dip,
36            uint_t isoc_pkts_count, size_t len, usb_flags_t flags);
37
38
39       void usb_free_isoc_req(usb_isoc_req_t *request);
40
41

INTERFACE LEVEL

43       Solaris DDI specific (Solaris DDI)
44

PARAMETERS

46       For        usb_alloc_ctrl_req(),        usb_alloc_bulk_req()        and
47       usb_alloc_intr_req():
48
49       dip      Pointer to the device's dev_info structure.
50
51
52       len      Length of data for this request.
53
54
55       flags    Only  USB_FLAGS_SLEEP is recognized. Wait for resources if not
56                immediately available.
57
58
59
60       For usb_alloc_isoc_req():
61
62       dip                Pointer to the device's dev_info structure.
63
64
65       isoc_pkts_count    Number of isochronous packet  descriptors  to  asso‐
66                          ciate with this request. Must be greater than zero.
67
68
69       len                Length of data for this isochronous request.
70
71
72       flags              Only   USB_FLAGS_SLEEP   is   recognized.  Wait  for
73                          resources if not immediately available.
74
75
76
77       For usb_free_ctrl_req(), usb_free_bulk_req(),  usb_free_intr_req()  and
78       usb_free_isoc_req():
79
80       request    Pointer to the request structure to be freed. Can be NULL.
81
82

DESCRIPTION

84       The  usb_alloc_ctrl_req(),  usb_alloc_bulk_req(), usb_alloc_intr_req(),
85       and usb_alloc_isoc_req() functions allocate control,  bulk,  interrupt,
86       or     isochronous requests. Optionally, these functions can also allo‐
87       cate an mblk of the specified length to pass data associated  with  the
88       request.  (For  guidelines on mblk data allocation, see the manpage for
89       the relevant transfer function).
90
91
92       The  usb_alloc_isoc_req()  function  also   allocates   a   number   of
93       isochronous  packet  descriptors  (usb_isoc_pkt_descr_t)  specified  by
94       isoc_pkts_count to the end of the request proper (usb_isoc_req_t).  See
95       usb_isoc_request(9S)   for   more  information  on  isochronous  packet
96       descriptors.
97
98
99       These functions always succeed when the USB_FLAGS_SLEEP  flag  is  set,
100       provided  that they are given valid args and are not called from inter‐
101       rupt context.
102
103
104       The usb_free_ctrl_req(), usb_free_bulk_req(), usb_free_intr_req(),  and
105       usb_free_isoc_req()  functions free their corresponding request. If the
106       request's data block pointer is non-zero, the data block is also freed.
107       For isoc requests, the array of packet descriptors is freed.
108

RETURN VALUES

110       For  usb_alloc_ctrl_req(),  usb_alloc_bulk_req(),  usb_alloc_intr_req()
111       and usb_alloc_isoc_req():
112
113
114       On success: returns a pointer to the appropriate usb_xxx_request_t.
115
116
117       On failure: returns NULL. Fails because the dip  argument  is  invalid,
118       USB_FLAGS_SLEEP  is  not  set  and  memory  is not available or because
119       USB_FLAGS_SLEEP is set but the call was made in interrupt context.
120
121
122       For usb_free_ctrl_req(), usb_free_bulk_req(),  usb_free_intr_req()  and
123       usb_free_isoc_req(): None.
124

CONTEXT

126       The  allocation routines can always be called from kernel and user con‐
127       text. They may be called from interrupt context only if USB_FLAGS_SLEEP
128       is not specified.
129
130
131       The  free  routines may be called from kernel, user, and interrupt con‐
132       text.
133

EXAMPLES

135             /* This allocates and initializes an asynchronous control
136              * request which will pass no data.  Asynchronous requests
137              * are used when they cannot block the calling thread.
138              */
139
140             usb_ctrl_req_t *ctrl_req;
141
142             if ((ctrl_req = usb_alloc_ctrl_req(dip, 0, 0)) == NULL) {
143                     return (FAILURE);
144             }
145
146             /* Now initialize. */
147             ctrl_req->ctrl_bmRequestType = USB_DEV_REQ_DEV_TO_HOST |
148                 USB_DEV_REQ_STANDARD | USB_DEV_REQ_RCPT_DEV;
149
150             ctrl_req->ctrl_bRequest      = (uint8_t)USB_REQ_GET_STATUS;
151             ...
152             ...
153             ctrl_req->ctrl_callback     = normal_callback;
154             ctrl_req->ctrl_exc_callback = exception_callback;
155             ...
156             ...
157
158
159

ATTRIBUTES

161       See attributes(5) for descriptions of the following attributes:
162
163
164
165
166       ┌─────────────────────────────┬─────────────────────────────┐
167       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
168       ├─────────────────────────────┼─────────────────────────────┤
169       │Architecture                 │PCI-based systems            │
170       ├─────────────────────────────┼─────────────────────────────┤
171       │Interface stability          │Committed                    │
172       ├─────────────────────────────┼─────────────────────────────┤
173       │Availability                 │SUNWusb                      │
174       └─────────────────────────────┴─────────────────────────────┘
175

SEE ALSO

177       attributes(5),                        usb_get_current_frame_number(9F),
178       usb_get_max_pkts_per_isoc_request(9F),     usb_pipe_get_max_bulk_trans‐
179       fer_size(9F),      usb_pipe_bulk_xfer(9F),      usb_pipe_ctrl_xfer(9F),
180       usb_pipe_intr_xfer(9F),  usb_pipe_isoc_xfer(9F),  usb_bulk_request(9S),
181       usb_ctrl_request(9S), usb_intr_request(9S), usb_isoc_request(9S)
182
183
184
185SunOS 5.11                       25 July 2004            usb_alloc_request(9F)
Impressum