FreeBSD kernel usb device Code
if_ipheth.c
Go to the documentation of this file.
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright (c) 2010 Hans Petter Selasky. All rights reserved.
5 * Copyright (c) 2009 Diego Giagio. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29/*
30 * Thanks to Diego Giagio for figuring out the programming details for
31 * the Apple iPhone Ethernet driver.
32 */
33
34#include <sys/cdefs.h>
35__FBSDID("$FreeBSD$");
36
37#include <sys/stdint.h>
38#include <sys/stddef.h>
39#include <sys/param.h>
40#include <sys/queue.h>
41#include <sys/types.h>
42#include <sys/systm.h>
43#include <sys/kernel.h>
44#include <sys/bus.h>
45#include <sys/module.h>
46#include <sys/lock.h>
47#include <sys/mutex.h>
48#include <sys/condvar.h>
49#include <sys/socket.h>
50#include <sys/sysctl.h>
51#include <sys/sx.h>
52#include <sys/unistd.h>
53#include <sys/callout.h>
54#include <sys/malloc.h>
55#include <sys/priv.h>
56
57#include <net/if.h>
58#include <net/if_var.h>
59
60#include <dev/usb/usb.h>
61#include <dev/usb/usbdi.h>
62#include <dev/usb/usbdi_util.h>
63#include "usbdevs.h"
64
65#define USB_DEBUG_VAR ipheth_debug
66#include <dev/usb/usb_debug.h>
67#include <dev/usb/usb_process.h>
68
71
72static device_probe_t ipheth_probe;
73static device_attach_t ipheth_attach;
74static device_detach_t ipheth_detach;
75
78
86
87#ifdef USB_DEBUG
88static int ipheth_debug = 0;
89
90static SYSCTL_NODE(_hw_usb, OID_AUTO, ipheth, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
91 "USB iPhone ethernet");
92SYSCTL_INT(_hw_usb_ipheth, OID_AUTO, debug, CTLFLAG_RWTUN, &ipheth_debug, 0, "Debug level");
93#endif
94
96 [IPHETH_BULK_RX] = {
97 .type = UE_BULK,
98 .endpoint = UE_ADDR_ANY,
99 .direction = UE_DIR_RX,
100 .frames = IPHETH_RX_FRAMES_MAX,
101 .bufsize = (IPHETH_RX_FRAMES_MAX * MCLBYTES),
102 .flags = {.short_frames_ok = 1,.short_xfer_ok = 1,.ext_buffer = 1,},
103 .callback = ipheth_bulk_read_callback,
104 .timeout = 0, /* no timeout */
105 },
106
107 [IPHETH_BULK_TX] = {
108 .type = UE_BULK,
109 .endpoint = UE_ADDR_ANY,
110 .direction = UE_DIR_TX,
111 .frames = IPHETH_TX_FRAMES_MAX,
113 .flags = {.force_short_xfer = 1,},
114 .callback = ipheth_bulk_write_callback,
115 .timeout = IPHETH_TX_TIMEOUT,
116 },
117};
118
119static device_method_t ipheth_methods[] = {
120 /* Device interface */
121 DEVMETHOD(device_probe, ipheth_probe),
122 DEVMETHOD(device_attach, ipheth_attach),
123 DEVMETHOD(device_detach, ipheth_detach),
124
125 DEVMETHOD_END
126};
127
128static driver_t ipheth_driver = {
129 .name = "ipheth",
130 .methods = ipheth_methods,
131 .size = sizeof(struct ipheth_softc),
132};
133
134static devclass_t ipheth_devclass;
135
137#if 0
138 {IPHETH_ID(USB_VENDOR_APPLE, USB_PRODUCT_APPLE_IPHONE,
141 {IPHETH_ID(USB_VENDOR_APPLE, USB_PRODUCT_APPLE_IPHONE_3G,
144 {IPHETH_ID(USB_VENDOR_APPLE, USB_PRODUCT_APPLE_IPHONE_3GS,
147 {IPHETH_ID(USB_VENDOR_APPLE, USB_PRODUCT_APPLE_IPHONE_4,
150 {IPHETH_ID(USB_VENDOR_APPLE, USB_PRODUCT_APPLE_IPHONE_4S,
153 {IPHETH_ID(USB_VENDOR_APPLE, USB_PRODUCT_APPLE_IPHONE_5,
156#else
157 /* product agnostic interface match */
158 {USB_VENDOR(USB_VENDOR_APPLE),
162#endif
163};
164
166MODULE_VERSION(ipheth, 1);
167MODULE_DEPEND(ipheth, uether, 1, 1, 1);
168MODULE_DEPEND(ipheth, usb, 1, 1, 1);
169MODULE_DEPEND(ipheth, ether, 1, 1, 1);
171
174 .ue_start = ipheth_start,
175 .ue_init = ipheth_init,
176 .ue_tick = ipheth_tick,
177 .ue_stop = ipheth_stop,
178 .ue_setmulti = ipheth_setmulti,
179 .ue_setpromisc = ipheth_setpromisc,
180};
181
182#define IPHETH_ID(v,p,c,sc,pt) \
183 USB_VENDOR(v), USB_PRODUCT(p), \
184 USB_IFACE_CLASS(c), USB_IFACE_SUBCLASS(sc), \
185 USB_IFACE_PROTOCOL(pt)
186
187static int
189{
190 struct usb_device_request req;
191 int error;
192
193 req.bmRequestType = UT_READ_VENDOR_DEVICE;
194 req.bRequest = IPHETH_CMD_GET_MACADDR;
195 req.wValue[0] = 0;
196 req.wValue[1] = 0;
197 req.wIndex[0] = sc->sc_iface_no;
198 req.wIndex[1] = 0;
199 req.wLength[0] = ETHER_ADDR_LEN;
200 req.wLength[1] = 0;
201
202 error = usbd_do_request(sc->sc_ue.ue_udev, NULL, &req, sc->sc_data);
203
204 if (error)
205 return (error);
206
207 memcpy(sc->sc_ue.ue_eaddr, sc->sc_data, ETHER_ADDR_LEN);
208
209 return (0);
210}
211
212static int
213ipheth_probe(device_t dev)
214{
215 struct usb_attach_arg *uaa = device_get_ivars(dev);
216
217 if (uaa->usb_mode != USB_MODE_HOST)
218 return (ENXIO);
219
220 return (usbd_lookup_id_by_uaa(ipheth_devs, sizeof(ipheth_devs), uaa));
221}
222
223static int
224ipheth_attach(device_t dev)
225{
226 struct ipheth_softc *sc = device_get_softc(dev);
227 struct usb_ether *ue = &sc->sc_ue;
228 struct usb_attach_arg *uaa = device_get_ivars(dev);
229 int error;
230
231 sc->sc_iface_no = uaa->info.bIfaceIndex;
232
234
235 mtx_init(&sc->sc_mtx, device_get_nameunit(dev), NULL, MTX_DEF);
236
239 if (error) {
240 device_printf(dev, "Cannot set alternate setting\n");
241 goto detach;
242 }
245 if (error) {
246 device_printf(dev, "Cannot setup USB transfers\n");
247 goto detach;
248 }
249 ue->ue_sc = sc;
250 ue->ue_dev = dev;
251 ue->ue_udev = uaa->device;
252 ue->ue_mtx = &sc->sc_mtx;
254
256 if (error) {
257 device_printf(dev, "Cannot get MAC address\n");
258 goto detach;
259 }
260
262 if (error) {
263 device_printf(dev, "could not attach interface\n");
264 goto detach;
265 }
266 return (0); /* success */
267
268detach:
270 return (ENXIO); /* failure */
271}
272
273static int
274ipheth_detach(device_t dev)
275{
276 struct ipheth_softc *sc = device_get_softc(dev);
277 struct usb_ether *ue = &sc->sc_ue;
278
279 /* stop all USB transfers first */
281
282 uether_ifdetach(ue);
283
284 mtx_destroy(&sc->sc_mtx);
285
286 return (0);
287}
288
289static void
291{
292 struct ipheth_softc *sc = uether_getsc(ue);
293
294 /*
295 * Start the USB transfers, if not already started:
296 */
299}
300
301static void
303{
304 struct ipheth_softc *sc = uether_getsc(ue);
305
306 /*
307 * Stop the USB transfers, if not already stopped:
308 */
311}
312
313static void
315{
316 struct ipheth_softc *sc = uether_getsc(ue);
317 struct usb_device_request req;
318 int error;
319
320 req.bmRequestType = UT_READ_VENDOR_DEVICE;
321 req.bRequest = IPHETH_CMD_CARRIER_CHECK;
322 req.wValue[0] = 0;
323 req.wValue[1] = 0;
324 req.wIndex[0] = sc->sc_iface_no;
325 req.wIndex[1] = 0;
326 req.wLength[0] = IPHETH_CTRL_BUF_SIZE;
327 req.wLength[1] = 0;
328
330
331 if (error)
332 return;
333
334 sc->sc_carrier_on =
335 (sc->sc_data[0] == IPHETH_CARRIER_ON);
336}
337
338static void
340{
341
342}
343
344static void
346{
347 struct ipheth_softc *sc = uether_getsc(ue);
348 struct ifnet *ifp = uether_getifp(ue);
349
350 IPHETH_LOCK_ASSERT(sc, MA_OWNED);
351
352 ifp->if_drv_flags |= IFF_DRV_RUNNING;
353
354 /* stall data write direction, which depends on USB mode */
356
357 /* start data transfers */
358 ipheth_start(ue);
359}
360
361static void
363{
364
365}
366
367static void
369{
370
371}
372
373static void
374ipheth_free_queue(struct mbuf **ppm, uint8_t n)
375{
376 uint8_t x;
377
378 for (x = 0; x != n; x++) {
379 if (ppm[x] != NULL) {
380 m_freem(ppm[x]);
381 ppm[x] = NULL;
382 }
383 }
384}
385
386static void
388{
389 struct ipheth_softc *sc = usbd_xfer_softc(xfer);
390 struct ifnet *ifp = uether_getifp(&sc->sc_ue);
391 struct usb_page_cache *pc;
392 struct mbuf *m;
393 uint8_t x;
394 int actlen;
395 int aframes;
396
397 usbd_xfer_status(xfer, &actlen, NULL, &aframes, NULL);
398
399 DPRINTFN(1, "\n");
400
401 switch (USB_GET_STATE(xfer)) {
403 DPRINTFN(11, "transfer complete: %u bytes in %u frames\n",
404 actlen, aframes);
405
406 if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
407
408 /* free all previous TX buffers */
410
411 /* FALLTHROUGH */
412 case USB_ST_SETUP:
413tr_setup:
414 for (x = 0; x != IPHETH_TX_FRAMES_MAX; x++) {
415 IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
416
417 if (m == NULL)
418 break;
419
421 x * IPHETH_BUF_SIZE, x);
422
423 pc = usbd_xfer_get_frame(xfer, x);
424
425 sc->sc_tx_buf[x] = m;
426
427 if (m->m_pkthdr.len > IPHETH_BUF_SIZE)
428 m->m_pkthdr.len = IPHETH_BUF_SIZE;
429
430 usbd_m_copy_in(pc, 0, m, 0, m->m_pkthdr.len);
431
433
434 if (IPHETH_BUF_SIZE != m->m_pkthdr.len) {
435 usbd_frame_zero(pc, m->m_pkthdr.len,
436 IPHETH_BUF_SIZE - m->m_pkthdr.len);
437 }
438
439 /*
440 * If there's a BPF listener, bounce a copy of
441 * this frame to him:
442 */
443 BPF_MTAP(ifp, m);
444 }
445 if (x != 0) {
446 usbd_xfer_set_frames(xfer, x);
447
449 }
450 break;
451
452 default: /* Error */
453 DPRINTFN(11, "transfer error, %s\n",
455
456 /* free all previous TX buffers */
458
459 /* count output errors */
460 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
461
462 if (error != USB_ERR_CANCELLED) {
463 /* try to clear stall first */
465 goto tr_setup;
466 }
467 break;
468 }
469}
470
471static void
473{
474 struct ipheth_softc *sc = usbd_xfer_softc(xfer);
475 struct mbuf *m;
476 uint8_t x;
477 int actlen;
478 int aframes;
479 int len;
480
481 usbd_xfer_status(xfer, &actlen, NULL, &aframes, NULL);
482
483 switch (USB_GET_STATE(xfer)) {
485
486 DPRINTF("received %u bytes in %u frames\n", actlen, aframes);
487
488 for (x = 0; x != aframes; x++) {
489 m = sc->sc_rx_buf[x];
490 sc->sc_rx_buf[x] = NULL;
491 len = usbd_xfer_frame_len(xfer, x);
492
493 if (len < (int)(sizeof(struct ether_header) +
494 IPHETH_RX_ADJ)) {
495 m_freem(m);
496 continue;
497 }
498
499 m_adj(m, IPHETH_RX_ADJ);
500
501 /* queue up mbuf */
503 }
504
505 /* FALLTHROUGH */
506 case USB_ST_SETUP:
507
508 for (x = 0; x != IPHETH_RX_FRAMES_MAX; x++) {
509 if (sc->sc_rx_buf[x] == NULL) {
510 m = uether_newbuf();
511 if (m == NULL)
512 goto tr_stall;
513
514 /* cancel alignment for ethernet */
515 m_adj(m, ETHER_ALIGN);
516
517 sc->sc_rx_buf[x] = m;
518 } else {
519 m = sc->sc_rx_buf[x];
520 }
521
522 usbd_xfer_set_frame_data(xfer, x, m->m_data, m->m_len);
523 }
524 /* set number of frames and start hardware */
525 usbd_xfer_set_frames(xfer, x);
527 /* flush any received frames */
528 uether_rxflush(&sc->sc_ue);
529 break;
530
531 default: /* Error */
532 DPRINTF("error = %s\n", usbd_errstr(error));
533
534 if (error != USB_ERR_CANCELLED) {
535 tr_stall:
536 /* try to clear stall first */
538 usbd_xfer_set_frames(xfer, 0);
540 break;
541 }
542 /* need to free the RX-mbufs when we are cancelled */
544 break;
545 }
546}
static int debug
Definition: cfumass.c:73
static SYSCTL_NODE(_hw_usb, OID_AUTO, dwc_otg, CTLFLAG_RW|CTLFLAG_MPSAFE, 0, "USB DWC OTG")
SYSCTL_INT(_hw_usb_dwc_otg, OID_AUTO, phy_type, CTLFLAG_RDTUN, &dwc_otg_phy_type, 0, "DWC OTG PHY TYPE - 0/1/2/3 - ULPI/HSIC/INTERNAL/UTMI+")
uint16_t len
Definition: ehci.h:41
static device_probe_t ipheth_probe
Definition: if_ipheth.c:72
static int ipheth_get_mac_addr(struct ipheth_softc *sc)
Definition: if_ipheth.c:188
MODULE_VERSION(ipheth, 1)
static const struct usb_ether_methods ipheth_ue_methods
Definition: if_ipheth.c:172
static device_method_t ipheth_methods[]
Definition: if_ipheth.c:119
static uether_fn_t ipheth_init
Definition: if_ipheth.c:81
static uether_fn_t ipheth_start
Definition: if_ipheth.c:83
static const STRUCT_USB_HOST_ID ipheth_devs[]
Definition: if_ipheth.c:136
static device_attach_t ipheth_attach
Definition: if_ipheth.c:73
static usb_callback_t ipheth_bulk_write_callback
Definition: if_ipheth.c:76
USB_PNP_HOST_INFO(ipheth_devs)
static device_detach_t ipheth_detach
Definition: if_ipheth.c:74
static driver_t ipheth_driver
Definition: if_ipheth.c:128
static uether_fn_t ipheth_attach_post
Definition: if_ipheth.c:79
static uether_fn_t ipheth_tick
Definition: if_ipheth.c:80
static uether_fn_t ipheth_setmulti
Definition: if_ipheth.c:84
__FBSDID("$FreeBSD$")
static const struct usb_config ipheth_config[IPHETH_N_TRANSFER]
Definition: if_ipheth.c:95
MODULE_DEPEND(ipheth, uether, 1, 1, 1)
DRIVER_MODULE(ipheth, uhub, ipheth_driver, ipheth_devclass, NULL, 0)
static uether_fn_t ipheth_setpromisc
Definition: if_ipheth.c:85
static usb_callback_t ipheth_bulk_read_callback
Definition: if_ipheth.c:77
static uether_fn_t ipheth_stop
Definition: if_ipheth.c:82
#define IPHETH_ID(v, p, c, sc, pt)
Definition: if_ipheth.c:182
static void ipheth_free_queue(struct mbuf **ppm, uint8_t n)
Definition: if_ipheth.c:374
static devclass_t ipheth_devclass
Definition: if_ipheth.c:134
#define IPHETH_TX_FRAMES_MAX
Definition: if_iphethvar.h:46
#define IPHETH_CMD_GET_MACADDR
Definition: if_iphethvar.h:58
#define IPHETH_USBINTF_CLASS
Definition: if_iphethvar.h:38
#define IPHETH_TX_TIMEOUT
Definition: if_iphethvar.h:43
#define IPHETH_ALT_INTFNUM
Definition: if_iphethvar.h:52
#define IPHETH_CMD_CARRIER_CHECK
Definition: if_iphethvar.h:59
#define IPHETH_RX_ADJ
Definition: if_iphethvar.h:48
#define IPHETH_CTRL_BUF_SIZE
Definition: if_iphethvar.h:55
@ IPHETH_BULK_RX
Definition: if_iphethvar.h:65
@ IPHETH_N_TRANSFER
Definition: if_iphethvar.h:66
@ IPHETH_BULK_TX
Definition: if_iphethvar.h:64
#define IPHETH_BUF_SIZE
Definition: if_iphethvar.h:42
#define IPHETH_LOCK_ASSERT(_sc, t)
Definition: if_iphethvar.h:84
#define IPHETH_USBINTF_PROTO
Definition: if_iphethvar.h:40
#define IPHETH_CTRL_TIMEOUT
Definition: if_iphethvar.h:56
#define IPHETH_CARRIER_ON
Definition: if_iphethvar.h:61
#define IPHETH_USBINTF_SUBCLASS
Definition: if_iphethvar.h:39
#define IPHETH_RX_FRAMES_MAX
Definition: if_iphethvar.h:45
uint8_t n
Definition: if_run.c:612
struct @109 error
device_t dev
struct usb_xfer * sc_xfer[IPHETH_N_TRANSFER]
Definition: if_iphethvar.h:73
struct usb_ether sc_ue
Definition: if_iphethvar.h:70
struct mbuf * sc_rx_buf[IPHETH_RX_FRAMES_MAX]
Definition: if_iphethvar.h:74
uint8_t sc_iface_no
Definition: if_iphethvar.h:78
struct mbuf * sc_tx_buf[IPHETH_TX_FRAMES_MAX]
Definition: if_iphethvar.h:75
uint8_t sc_data[IPHETH_CTRL_BUF_SIZE]
Definition: if_iphethvar.h:77
uint8_t sc_carrier_on
Definition: if_iphethvar.h:79
struct mtx sc_mtx
Definition: if_iphethvar.h:71
enum usb_hc_mode usb_mode
Definition: usbdi.h:432
struct usbd_lookup_info info
Definition: usbdi.h:426
struct usb_device * device
Definition: usbdi.h:430
struct usb_xfer_flags flags
Definition: usbdi.h:235
uint8_t type
Definition: usbdi.h:238
uether_fn_t * ue_attach_post
Definition: usb_ethernet.h:58
const struct usb_ether_methods * ue_methods
Definition: usb_ethernet.h:81
struct usb_device * ue_udev
Definition: usb_ethernet.h:84
uint8_t ue_eaddr[ETHER_ADDR_LEN]
Definition: usb_ethernet.h:101
device_t ue_dev
Definition: usb_ethernet.h:85
struct mtx * ue_mtx
Definition: usb_ethernet.h:80
void * ue_sc
Definition: usb_ethernet.h:83
uint8_t short_frames_ok
Definition: usbdi.h:199
uint8_t force_short_xfer
Definition: usbdi.h:196
uint8_t bIfaceIndex
Definition: usbdi.h:417
#define DPRINTF(...)
Definition: umass.c:179
#define UE_ADDR_ANY
Definition: usb.h:537
#define UE_BULK
Definition: usb.h:543
#define UT_READ_VENDOR_DEVICE
Definition: usb.h:180
#define UE_DIR_RX
Definition: usb.h:533
@ USB_MODE_HOST
Definition: usb.h:778
#define UE_DIR_TX
Definition: usb.h:534
void usbd_frame_zero(struct usb_page_cache *cache, usb_frlength_t offset, usb_frlength_t len)
Definition: usb_busdma.c:339
usb_error_t usbd_set_alt_interface_index(struct usb_device *udev, uint8_t iface_index, uint8_t alt_index)
Definition: usb_device.c:1034
const char * usbd_errstr(usb_error_t err)
Definition: usb_error.c:93
void uether_rxflush(struct usb_ether *ue)
Definition: usb_ethernet.c:646
struct mbuf * uether_newbuf(void)
Definition: usb_ethernet.c:584
void uether_ifdetach(struct usb_ether *ue)
Definition: usb_ethernet.c:302
void * uether_getsc(struct usb_ether *ue)
Definition: usb_ethernet.c:148
struct ifnet * uether_getifp(struct usb_ether *ue)
Definition: usb_ethernet.c:136
int uether_rxmbuf(struct usb_ether *ue, struct mbuf *m, unsigned int len)
Definition: usb_ethernet.c:598
int uether_ifattach(struct usb_ether *ue)
Definition: usb_ethernet.c:164
#define uether_do_request(ue, req, data, timo)
Definition: usb_ethernet.h:104
void() uether_fn_t(struct usb_ether *)
Definition: usb_ethernet.h:55
const void * req
Definition: usb_if.m:51
INTERFACE usb
Definition: usb_if.m:35
int usbd_lookup_id_by_uaa(const struct usb_device_id *id, usb_size_t sizeof_id, struct usb_attach_arg *uaa)
Definition: usb_lookup.c:143
void usbd_transfer_submit(struct usb_xfer *xfer)
void usbd_xfer_set_frames(struct usb_xfer *xfer, usb_frcount_t n)
void usbd_transfer_unsetup(struct usb_xfer **pxfer, uint16_t n_setup)
void usbd_xfer_set_frame_data(struct usb_xfer *xfer, usb_frcount_t frindex, void *ptr, usb_frlength_t len)
void usbd_xfer_set_frame_len(struct usb_xfer *xfer, usb_frcount_t frindex, usb_frlength_t len)
usb_frlength_t usbd_xfer_frame_len(struct usb_xfer *xfer, usb_frcount_t frindex)
struct usb_page_cache * usbd_xfer_get_frame(struct usb_xfer *xfer, usb_frcount_t frindex)
usb_error_t usbd_transfer_setup(struct usb_device *udev, const uint8_t *ifaces, struct usb_xfer **ppxfer, const struct usb_config *setup_start, uint16_t n_setup, void *priv_sc, struct mtx *xfer_mtx)
Definition: usb_transfer.c:987
void usbd_transfer_start(struct usb_xfer *xfer)
void usbd_xfer_set_frame_offset(struct usb_xfer *xfer, usb_frlength_t offset, usb_frcount_t frindex)
void * usbd_xfer_softc(struct usb_xfer *xfer)
void usbd_xfer_set_stall(struct usb_xfer *xfer)
void usbd_transfer_stop(struct usb_xfer *xfer)
void usbd_xfer_status(struct usb_xfer *xfer, int *actlen, int *sumlen, int *aframes, int *nframes)
void device_set_usb_desc(device_t dev)
Definition: usb_util.c:73
#define USB_IFACE_SUBCLASS(isc)
Definition: usbdi.h:388
#define USB_ST_SETUP
Definition: usbdi.h:502
usb_error_t
Definition: usbdi.h:45
@ USB_ERR_CANCELLED
Definition: usbdi.h:51
#define USB_IFACE_CLASS(ic)
Definition: usbdi.h:385
#define USB_ST_TRANSFERRED
Definition: usbdi.h:503
void usbd_m_copy_in(struct usb_page_cache *cache, usb_frlength_t dst_offset, struct mbuf *m, usb_size_t src_offset, usb_frlength_t src_len)
#define USB_IFACE_PROTOCOL(ip)
Definition: usbdi.h:391
void() usb_callback_t(struct usb_xfer *, usb_error_t)
Definition: usbdi.h:94
#define USB_VENDOR(vend)
Definition: usbdi.h:358
#define STRUCT_USB_HOST_ID
Definition: usbdi.h:258
#define USB_GET_STATE(xfer)
Definition: usbdi.h:515
#define usbd_do_request(u, m, r, d)
Definition: usbdi.h:596