FreeBSD kernel usb device Code
if_aue.c
Go to the documentation of this file.
1/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (c) 1997, 1998, 1999, 2000
5 * Bill Paul <wpaul@ee.columbia.edu>. All rights reserved.
6 *
7 * Copyright (c) 2006
8 * Alfred Perlstein <alfred@FreeBSD.org>. All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by Bill Paul.
21 * 4. Neither the name of the author nor the names of any co-contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
29 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
35 * THE POSSIBILITY OF SUCH DAMAGE.
36 */
37
38#include <sys/cdefs.h>
39__FBSDID("$FreeBSD$");
40
41/*
42 * ADMtek AN986 Pegasus and AN8511 Pegasus II USB to ethernet driver.
43 * Datasheet is available from http://www.admtek.com.tw.
44 *
45 * Written by Bill Paul <wpaul@ee.columbia.edu>
46 * Electrical Engineering Department
47 * Columbia University, New York City
48 *
49 * SMP locking by Alfred Perlstein <alfred@FreeBSD.org>.
50 * RED Inc.
51 */
52
53/*
54 * The Pegasus chip uses four USB "endpoints" to provide 10/100 ethernet
55 * support: the control endpoint for reading/writing registers, burst
56 * read endpoint for packet reception, burst write for packet transmission
57 * and one for "interrupts." The chip uses the same RX filter scheme
58 * as the other ADMtek ethernet parts: one perfect filter entry for the
59 * the station address and a 64-bit multicast hash table. The chip supports
60 * both MII and HomePNA attachments.
61 *
62 * Since the maximum data transfer speed of USB is supposed to be 12Mbps,
63 * you're never really going to get 100Mbps speeds from this device. I
64 * think the idea is to allow the device to connect to 10 or 100Mbps
65 * networks, not necessarily to provide 100Mbps performance. Also, since
66 * the controller uses an external PHY chip, it's possible that board
67 * designers might simply choose a 10Mbps PHY.
68 *
69 * Registers are accessed using uether_do_request(). Packet
70 * transfers are done using usbd_transfer() and friends.
71 */
72
73#include <sys/stdint.h>
74#include <sys/stddef.h>
75#include <sys/param.h>
76#include <sys/queue.h>
77#include <sys/types.h>
78#include <sys/systm.h>
79#include <sys/socket.h>
80#include <sys/kernel.h>
81#include <sys/bus.h>
82#include <sys/module.h>
83#include <sys/lock.h>
84#include <sys/mutex.h>
85#include <sys/condvar.h>
86#include <sys/sysctl.h>
87#include <sys/sx.h>
88#include <sys/unistd.h>
89#include <sys/callout.h>
90#include <sys/malloc.h>
91#include <sys/priv.h>
92
93#include <net/if.h>
94#include <net/if_var.h>
95#include <net/if_media.h>
96
97#include <dev/mii/mii.h>
98#include <dev/mii/miivar.h>
99
100#include <dev/usb/usb.h>
101#include <dev/usb/usbdi.h>
102#include <dev/usb/usbdi_util.h>
103#include "usbdevs.h"
104
105#define USB_DEBUG_VAR aue_debug
106#include <dev/usb/usb_debug.h>
107#include <dev/usb/usb_process.h>
108
111
112#include "miibus_if.h"
113
114#ifdef USB_DEBUG
115static int aue_debug = 0;
116
117static SYSCTL_NODE(_hw_usb, OID_AUTO, aue, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
118 "USB aue");
119SYSCTL_INT(_hw_usb_aue, OID_AUTO, debug, CTLFLAG_RWTUN, &aue_debug, 0,
120 "Debug level");
121#endif
122
123/*
124 * Various supported device vendors/products.
125 */
126static const STRUCT_USB_HOST_ID aue_devs[] = {
127#define AUE_DEV(v,p,i) { USB_VPI(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, i) }
128 AUE_DEV(3COM, 3C460B, AUE_FLAG_PII),
129 AUE_DEV(ABOCOM, DSB650TX_PNA, 0),
130 AUE_DEV(ABOCOM, UFE1000, AUE_FLAG_LSYS),
131 AUE_DEV(ABOCOM, XX10, 0),
132 AUE_DEV(ABOCOM, XX1, AUE_FLAG_PNA | AUE_FLAG_PII),
133 AUE_DEV(ABOCOM, XX2, AUE_FLAG_PII),
134 AUE_DEV(ABOCOM, XX4, AUE_FLAG_PNA),
135 AUE_DEV(ABOCOM, XX5, AUE_FLAG_PNA),
136 AUE_DEV(ABOCOM, XX6, AUE_FLAG_PII),
137 AUE_DEV(ABOCOM, XX7, AUE_FLAG_PII),
138 AUE_DEV(ABOCOM, XX8, AUE_FLAG_PII),
139 AUE_DEV(ABOCOM, XX9, AUE_FLAG_PNA),
140 AUE_DEV(ACCTON, SS1001, AUE_FLAG_PII),
141 AUE_DEV(ACCTON, USB320_EC, 0),
142 AUE_DEV(ADMTEK, PEGASUSII_2, AUE_FLAG_PII),
143 AUE_DEV(ADMTEK, PEGASUSII_3, AUE_FLAG_PII),
144 AUE_DEV(ADMTEK, PEGASUSII_4, AUE_FLAG_PII),
145 AUE_DEV(ADMTEK, PEGASUSII, AUE_FLAG_PII),
146 AUE_DEV(ADMTEK, PEGASUS, AUE_FLAG_PNA | AUE_FLAG_DUAL_PHY),
147 AUE_DEV(AEI, FASTETHERNET, AUE_FLAG_PII),
148 AUE_DEV(ALLIEDTELESYN, ATUSB100, AUE_FLAG_PII),
149 AUE_DEV(ATEN, UC110T, AUE_FLAG_PII),
150 AUE_DEV(BELKIN, USB2LAN, AUE_FLAG_PII),
151 AUE_DEV(BILLIONTON, USB100, 0),
152 AUE_DEV(BILLIONTON, USBE100, AUE_FLAG_PII),
153 AUE_DEV(BILLIONTON, USBEL100, 0),
154 AUE_DEV(BILLIONTON, USBLP100, AUE_FLAG_PNA),
155 AUE_DEV(COREGA, FETHER_USB_TXS, AUE_FLAG_PII),
156 AUE_DEV(COREGA, FETHER_USB_TX, 0),
157 AUE_DEV(DLINK, DSB650TX1, AUE_FLAG_LSYS),
158 AUE_DEV(DLINK, DSB650TX2, AUE_FLAG_LSYS | AUE_FLAG_PII),
159 AUE_DEV(DLINK, DSB650TX3, AUE_FLAG_LSYS | AUE_FLAG_PII),
160 AUE_DEV(DLINK, DSB650TX4, AUE_FLAG_LSYS | AUE_FLAG_PII),
161 AUE_DEV(DLINK, DSB650TX_PNA, AUE_FLAG_PNA),
162 AUE_DEV(DLINK, DSB650TX, AUE_FLAG_LSYS),
163 AUE_DEV(DLINK, DSB650, AUE_FLAG_LSYS),
164 AUE_DEV(ELCON, PLAN, AUE_FLAG_PNA | AUE_FLAG_PII),
165 AUE_DEV(ELECOM, LDUSB20, AUE_FLAG_PII),
166 AUE_DEV(ELECOM, LDUSBLTX, AUE_FLAG_PII),
167 AUE_DEV(ELECOM, LDUSBTX0, 0),
168 AUE_DEV(ELECOM, LDUSBTX1, AUE_FLAG_LSYS),
169 AUE_DEV(ELECOM, LDUSBTX2, 0),
170 AUE_DEV(ELECOM, LDUSBTX3, AUE_FLAG_LSYS),
171 AUE_DEV(ELSA, USB2ETHERNET, 0),
172 AUE_DEV(GIGABYTE, GNBR402W, 0),
173 AUE_DEV(HAWKING, UF100, AUE_FLAG_PII),
174 AUE_DEV(HP, HN210E, AUE_FLAG_PII),
175 AUE_DEV(IODATA, USBETTXS, AUE_FLAG_PII),
176 AUE_DEV(IODATA, USBETTX, 0),
177 AUE_DEV(KINGSTON, KNU101TX, 0),
178 AUE_DEV(LINKSYS, USB100H1, AUE_FLAG_LSYS | AUE_FLAG_PNA),
179 AUE_DEV(LINKSYS, USB100TX, AUE_FLAG_LSYS),
180 AUE_DEV(LINKSYS, USB10TA, AUE_FLAG_LSYS),
181 AUE_DEV(LINKSYS, USB10TX1, AUE_FLAG_LSYS | AUE_FLAG_PII),
182 AUE_DEV(LINKSYS, USB10TX2, AUE_FLAG_LSYS | AUE_FLAG_PII),
183 AUE_DEV(LINKSYS, USB10T, AUE_FLAG_LSYS),
184 AUE_DEV(MELCO, LUA2TX5, AUE_FLAG_PII),
185 AUE_DEV(MELCO, LUATX1, 0),
186 AUE_DEV(MELCO, LUATX5, 0),
187 AUE_DEV(MICROSOFT, MN110, AUE_FLAG_PII),
188 AUE_DEV(NETGEAR, FA101, AUE_FLAG_PII),
189 AUE_DEV(SIEMENS, SPEEDSTREAM, AUE_FLAG_PII),
190 AUE_DEV(SIIG2, USBTOETHER, AUE_FLAG_PII),
191 AUE_DEV(SMARTBRIDGES, SMARTNIC, AUE_FLAG_PII),
192 AUE_DEV(SMC, 2202USB, 0),
193 AUE_DEV(SMC, 2206USB, AUE_FLAG_PII),
194 AUE_DEV(SOHOWARE, NUB100, 0),
195 AUE_DEV(SOHOWARE, NUB110, AUE_FLAG_PII),
196#undef AUE_DEV
197};
198
199/* prototypes */
200
201static device_probe_t aue_probe;
202static device_attach_t aue_attach;
203static device_detach_t aue_detach;
204static miibus_readreg_t aue_miibus_readreg;
205static miibus_writereg_t aue_miibus_writereg;
206static miibus_statchg_t aue_miibus_statchg;
207
211
219
220static uint8_t aue_csr_read_1(struct aue_softc *, uint16_t);
221static uint16_t aue_csr_read_2(struct aue_softc *, uint16_t);
222static void aue_csr_write_1(struct aue_softc *, uint16_t, uint8_t);
223static void aue_csr_write_2(struct aue_softc *, uint16_t, uint16_t);
224static uint16_t aue_eeprom_getword(struct aue_softc *, int);
225static void aue_reset(struct aue_softc *);
226static void aue_reset_pegasus_II(struct aue_softc *);
227
228static int aue_ifmedia_upd(struct ifnet *);
229static void aue_ifmedia_sts(struct ifnet *, struct ifmediareq *);
230
231static const struct usb_config aue_config[AUE_N_TRANSFER] = {
232 [AUE_BULK_DT_WR] = {
233 .type = UE_BULK,
234 .endpoint = UE_ADDR_ANY,
235 .direction = UE_DIR_OUT,
236 .bufsize = (MCLBYTES + 2),
237 .flags = {.pipe_bof = 1,.force_short_xfer = 1,},
238 .callback = aue_bulk_write_callback,
239 .timeout = 10000, /* 10 seconds */
240 },
241
242 [AUE_BULK_DT_RD] = {
243 .type = UE_BULK,
244 .endpoint = UE_ADDR_ANY,
245 .direction = UE_DIR_IN,
246 .bufsize = (MCLBYTES + 4 + ETHER_CRC_LEN),
247 .flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
248 .callback = aue_bulk_read_callback,
249 },
250
251 [AUE_INTR_DT_RD] = {
252 .type = UE_INTERRUPT,
253 .endpoint = UE_ADDR_ANY,
254 .direction = UE_DIR_IN,
255 .flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
256 .bufsize = 0, /* use wMaxPacketSize */
257 .callback = aue_intr_callback,
258 },
259};
260
261static device_method_t aue_methods[] = {
262 /* Device interface */
263 DEVMETHOD(device_probe, aue_probe),
264 DEVMETHOD(device_attach, aue_attach),
265 DEVMETHOD(device_detach, aue_detach),
266
267 /* MII interface */
268 DEVMETHOD(miibus_readreg, aue_miibus_readreg),
269 DEVMETHOD(miibus_writereg, aue_miibus_writereg),
270 DEVMETHOD(miibus_statchg, aue_miibus_statchg),
271
272 DEVMETHOD_END
273};
274
275static driver_t aue_driver = {
276 .name = "aue",
277 .methods = aue_methods,
278 .size = sizeof(struct aue_softc)
279};
280
281static devclass_t aue_devclass;
282
284DRIVER_MODULE(miibus, aue, miibus_driver, miibus_devclass, 0, 0);
285MODULE_DEPEND(aue, uether, 1, 1, 1);
286MODULE_DEPEND(aue, usb, 1, 1, 1);
287MODULE_DEPEND(aue, ether, 1, 1, 1);
288MODULE_DEPEND(aue, miibus, 1, 1, 1);
291
292static const struct usb_ether_methods aue_ue_methods = {
294 .ue_start = aue_start,
295 .ue_init = aue_init,
296 .ue_stop = aue_stop,
297 .ue_tick = aue_tick,
298 .ue_setmulti = aue_setmulti,
299 .ue_setpromisc = aue_setpromisc,
300 .ue_mii_upd = aue_ifmedia_upd,
301 .ue_mii_sts = aue_ifmedia_sts,
302};
303
304#define AUE_SETBIT(sc, reg, x) \
305 aue_csr_write_1(sc, reg, aue_csr_read_1(sc, reg) | (x))
306
307#define AUE_CLRBIT(sc, reg, x) \
308 aue_csr_write_1(sc, reg, aue_csr_read_1(sc, reg) & ~(x))
309
310static uint8_t
311aue_csr_read_1(struct aue_softc *sc, uint16_t reg)
312{
313 struct usb_device_request req;
314 usb_error_t err;
315 uint8_t val;
316
317 req.bmRequestType = UT_READ_VENDOR_DEVICE;
318 req.bRequest = AUE_UR_READREG;
319 USETW(req.wValue, 0);
320 USETW(req.wIndex, reg);
321 USETW(req.wLength, 1);
322
323 err = uether_do_request(&sc->sc_ue, &req, &val, 1000);
324 if (err)
325 return (0);
326 return (val);
327}
328
329static uint16_t
330aue_csr_read_2(struct aue_softc *sc, uint16_t reg)
331{
332 struct usb_device_request req;
333 usb_error_t err;
334 uint16_t val;
335
336 req.bmRequestType = UT_READ_VENDOR_DEVICE;
337 req.bRequest = AUE_UR_READREG;
338 USETW(req.wValue, 0);
339 USETW(req.wIndex, reg);
340 USETW(req.wLength, 2);
341
342 err = uether_do_request(&sc->sc_ue, &req, &val, 1000);
343 if (err)
344 return (0);
345 return (le16toh(val));
346}
347
348static void
349aue_csr_write_1(struct aue_softc *sc, uint16_t reg, uint8_t val)
350{
351 struct usb_device_request req;
352
353 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
354 req.bRequest = AUE_UR_WRITEREG;
355 req.wValue[0] = val;
356 req.wValue[1] = 0;
357 USETW(req.wIndex, reg);
358 USETW(req.wLength, 1);
359
360 if (uether_do_request(&sc->sc_ue, &req, &val, 1000)) {
361 /* error ignored */
362 }
363}
364
365static void
366aue_csr_write_2(struct aue_softc *sc, uint16_t reg, uint16_t val)
367{
368 struct usb_device_request req;
369
370 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
371 req.bRequest = AUE_UR_WRITEREG;
372 USETW(req.wValue, val);
373 USETW(req.wIndex, reg);
374 USETW(req.wLength, 2);
375
376 val = htole16(val);
377
378 if (uether_do_request(&sc->sc_ue, &req, &val, 1000)) {
379 /* error ignored */
380 }
381}
382
383/*
384 * Read a word of data stored in the EEPROM at address 'addr.'
385 */
386static uint16_t
387aue_eeprom_getword(struct aue_softc *sc, int addr)
388{
389 int i;
390
393
394 for (i = 0; i != AUE_TIMEOUT; i++) {
396 break;
397 if (uether_pause(&sc->sc_ue, hz / 100))
398 break;
399 }
400
401 if (i == AUE_TIMEOUT)
402 device_printf(sc->sc_ue.ue_dev, "EEPROM read timed out\n");
403
404 return (aue_csr_read_2(sc, AUE_EE_DATA));
405}
406
407/*
408 * Read station address(offset 0) from the EEPROM.
409 */
410static void
411aue_read_mac(struct aue_softc *sc, uint8_t *eaddr)
412{
413 int i, offset;
414 uint16_t word;
415
416 for (i = 0, offset = 0; i < ETHER_ADDR_LEN / 2; i++) {
417 word = aue_eeprom_getword(sc, offset + i);
418 eaddr[i * 2] = (uint8_t)word;
419 eaddr[i * 2 + 1] = (uint8_t)(word >> 8);
420 }
421}
422
423static int
424aue_miibus_readreg(device_t dev, int phy, int reg)
425{
426 struct aue_softc *sc = device_get_softc(dev);
427 int i, locked;
428 uint16_t val = 0;
429
430 locked = mtx_owned(&sc->sc_mtx);
431 if (!locked)
432 AUE_LOCK(sc);
433
434 /*
435 * The Am79C901 HomePNA PHY actually contains two transceivers: a 1Mbps
436 * HomePNA PHY and a 10Mbps full/half duplex ethernet PHY with NWAY
437 * autoneg. However in the ADMtek adapter, only the 1Mbps PHY is
438 * actually connected to anything, so we ignore the 10Mbps one. It
439 * happens to be configured for MII address 3, so we filter that out.
440 */
441 if (sc->sc_flags & AUE_FLAG_DUAL_PHY) {
442 if (phy == 3)
443 goto done;
444#if 0
445 if (phy != 1)
446 goto done;
447#endif
448 }
451
452 for (i = 0; i != AUE_TIMEOUT; i++) {
454 break;
455 if (uether_pause(&sc->sc_ue, hz / 100))
456 break;
457 }
458
459 if (i == AUE_TIMEOUT)
460 device_printf(sc->sc_ue.ue_dev, "MII read timed out\n");
461
463
464done:
465 if (!locked)
466 AUE_UNLOCK(sc);
467 return (val);
468}
469
470static int
471aue_miibus_writereg(device_t dev, int phy, int reg, int data)
472{
473 struct aue_softc *sc = device_get_softc(dev);
474 int i;
475 int locked;
476
477 if (phy == 3)
478 return (0);
479
480 locked = mtx_owned(&sc->sc_mtx);
481 if (!locked)
482 AUE_LOCK(sc);
483
487
488 for (i = 0; i != AUE_TIMEOUT; i++) {
490 break;
491 if (uether_pause(&sc->sc_ue, hz / 100))
492 break;
493 }
494
495 if (i == AUE_TIMEOUT)
496 device_printf(sc->sc_ue.ue_dev, "MII write timed out\n");
497
498 if (!locked)
499 AUE_UNLOCK(sc);
500 return (0);
501}
502
503static void
505{
506 struct aue_softc *sc = device_get_softc(dev);
507 struct mii_data *mii = GET_MII(sc);
508 int locked;
509
510 locked = mtx_owned(&sc->sc_mtx);
511 if (!locked)
512 AUE_LOCK(sc);
513
515 if (IFM_SUBTYPE(mii->mii_media_active) == IFM_100_TX)
517 else
519
520 if ((mii->mii_media_active & IFM_GMASK) == IFM_FDX)
522 else
524
526
527 /*
528 * Set the LED modes on the LinkSys adapter.
529 * This turns on the 'dual link LED' bin in the auxmode
530 * register of the Broadcom PHY.
531 */
532 if (sc->sc_flags & AUE_FLAG_LSYS) {
533 uint16_t auxmode;
534
535 auxmode = aue_miibus_readreg(dev, 0, 0x1b);
536 aue_miibus_writereg(dev, 0, 0x1b, auxmode | 0x04);
537 }
538 if (!locked)
539 AUE_UNLOCK(sc);
540}
541
542#define AUE_BITS 6
543static u_int
544aue_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
545{
546 uint8_t *hashtbl = arg;
547 uint32_t h;
548
549 h = ether_crc32_le(LLADDR(sdl), ETHER_ADDR_LEN) & ((1 << AUE_BITS) - 1);
550 hashtbl[(h >> 3)] |= 1 << (h & 0x7);
551
552 return (1);
553}
554
555static void
557{
558 struct aue_softc *sc = uether_getsc(ue);
559 struct ifnet *ifp = uether_getifp(ue);
560 uint32_t i;
561 uint8_t hashtbl[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
562
563 AUE_LOCK_ASSERT(sc, MA_OWNED);
564
565 if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC) {
567 return;
568 }
569
571
572 /* now program new ones */
573 if_foreach_llmaddr(ifp, aue_hash_maddr, hashtbl);
574
575 /* write the hashtable */
576 for (i = 0; i != 8; i++)
577 aue_csr_write_1(sc, AUE_MAR0 + i, hashtbl[i]);
578}
579
580static void
582{
583 /* Magic constants taken from Linux driver. */
586#if 0
587 if ((sc->sc_flags & HAS_HOME_PNA) && mii_mode)
589 else
590#endif
592}
593
594static void
596{
597 int i;
598
600
601 for (i = 0; i != AUE_TIMEOUT; i++) {
603 break;
604 if (uether_pause(&sc->sc_ue, hz / 100))
605 break;
606 }
607
608 if (i == AUE_TIMEOUT)
609 device_printf(sc->sc_ue.ue_dev, "reset failed\n");
610
611 /*
612 * The PHY(s) attached to the Pegasus chip may be held
613 * in reset until we flip on the GPIO outputs. Make sure
614 * to set the GPIO pins high so that the PHY(s) will
615 * be enabled.
616 *
617 * NOTE: We used to force all of the GPIO pins low first and then
618 * enable the ones we want. This has been changed to better
619 * match the ADMtek's reference design to avoid setting the
620 * power-down configuration line of the PHY at the same time
621 * it is reset.
622 */
625
626 if (sc->sc_flags & AUE_FLAG_LSYS) {
627 /* Grrr. LinkSys has to be different from everyone else. */
631 }
632 if (sc->sc_flags & AUE_FLAG_PII)
634
635 /* Wait a little while for the chip to get its brains in order: */
636 uether_pause(&sc->sc_ue, hz / 100);
637}
638
639static void
641{
642 struct aue_softc *sc = uether_getsc(ue);
643
644 /* reset the adapter */
645 aue_reset(sc);
646
647 /* get station address from the EEPROM */
648 aue_read_mac(sc, ue->ue_eaddr);
649}
650
651/*
652 * Probe for a Pegasus chip.
653 */
654static int
655aue_probe(device_t dev)
656{
657 struct usb_attach_arg *uaa = device_get_ivars(dev);
658
659 if (uaa->usb_mode != USB_MODE_HOST)
660 return (ENXIO);
662 return (ENXIO);
663 if (uaa->info.bIfaceIndex != AUE_IFACE_IDX)
664 return (ENXIO);
665 /*
666 * Belkin USB Bluetooth dongles of the F8T012xx1 model series conflict
667 * with older Belkin USB2LAN adapters. Skip if_aue if we detect one of
668 * the devices that look like Bluetooth adapters.
669 */
670 if (uaa->info.idVendor == USB_VENDOR_BELKIN &&
671 uaa->info.idProduct == USB_PRODUCT_BELKIN_F8T012 &&
672 uaa->info.bcdDevice == 0x0413)
673 return (ENXIO);
674
675 return (usbd_lookup_id_by_uaa(aue_devs, sizeof(aue_devs), uaa));
676}
677
678/*
679 * Attach the interface. Allocate softc structures, do ifmedia
680 * setup and ethernet/BPF attach.
681 */
682static int
683aue_attach(device_t dev)
684{
685 struct usb_attach_arg *uaa = device_get_ivars(dev);
686 struct aue_softc *sc = device_get_softc(dev);
687 struct usb_ether *ue = &sc->sc_ue;
688 uint8_t iface_index;
689 int error;
690
691 sc->sc_flags = USB_GET_DRIVER_INFO(uaa);
692
693 if (uaa->info.bcdDevice >= 0x0201) {
694 /* XXX currently undocumented */
696 }
697
699 mtx_init(&sc->sc_mtx, device_get_nameunit(dev), NULL, MTX_DEF);
700
701 iface_index = AUE_IFACE_IDX;
702 error = usbd_transfer_setup(uaa->device, &iface_index,
704 sc, &sc->sc_mtx);
705 if (error) {
706 device_printf(dev, "allocating USB transfers failed\n");
707 goto detach;
708 }
709
710 ue->ue_sc = sc;
711 ue->ue_dev = dev;
712 ue->ue_udev = uaa->device;
713 ue->ue_mtx = &sc->sc_mtx;
715
717 if (error) {
718 device_printf(dev, "could not attach interface\n");
719 goto detach;
720 }
721 return (0); /* success */
722
723detach:
725 return (ENXIO); /* failure */
726}
727
728static int
729aue_detach(device_t dev)
730{
731 struct aue_softc *sc = device_get_softc(dev);
732 struct usb_ether *ue = &sc->sc_ue;
733
735 uether_ifdetach(ue);
736 mtx_destroy(&sc->sc_mtx);
737
738 return (0);
739}
740
741static void
743{
744 struct aue_softc *sc = usbd_xfer_softc(xfer);
745 struct ifnet *ifp = uether_getifp(&sc->sc_ue);
746 struct aue_intrpkt pkt;
747 struct usb_page_cache *pc;
748 int actlen;
749
750 usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
751
752 switch (USB_GET_STATE(xfer)) {
754
755 if ((ifp->if_drv_flags & IFF_DRV_RUNNING) &&
756 actlen >= (int)sizeof(pkt)) {
757 pc = usbd_xfer_get_frame(xfer, 0);
758 usbd_copy_out(pc, 0, &pkt, sizeof(pkt));
759
760 if (pkt.aue_txstat0)
761 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
764 if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1);
765 }
766 /* FALLTHROUGH */
767 case USB_ST_SETUP:
768tr_setup:
771 return;
772
773 default: /* Error */
774 if (error != USB_ERR_CANCELLED) {
775 /* try to clear stall first */
777 goto tr_setup;
778 }
779 return;
780 }
781}
782
783static void
785{
786 struct aue_softc *sc = usbd_xfer_softc(xfer);
787 struct usb_ether *ue = &sc->sc_ue;
788 struct ifnet *ifp = uether_getifp(ue);
789 struct aue_rxpkt stat;
790 struct usb_page_cache *pc;
791 int actlen;
792
793 usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
794 pc = usbd_xfer_get_frame(xfer, 0);
795
796 switch (USB_GET_STATE(xfer)) {
798 DPRINTFN(11, "received %d bytes\n", actlen);
799
800 if (sc->sc_flags & AUE_FLAG_VER_2) {
801 if (actlen == 0) {
802 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
803 goto tr_setup;
804 }
805 } else {
806 if (actlen <= (int)(sizeof(stat) + ETHER_CRC_LEN)) {
807 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
808 goto tr_setup;
809 }
810 usbd_copy_out(pc, actlen - sizeof(stat), &stat,
811 sizeof(stat));
812
813 /*
814 * turn off all the non-error bits in the rx status
815 * word:
816 */
818 if (stat.aue_rxstat) {
819 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
820 goto tr_setup;
821 }
822 /* No errors; receive the packet. */
823 actlen -= (sizeof(stat) + ETHER_CRC_LEN);
824 }
825 uether_rxbuf(ue, pc, 0, actlen);
826
827 /* FALLTHROUGH */
828 case USB_ST_SETUP:
829tr_setup:
832 uether_rxflush(ue);
833 return;
834
835 default: /* Error */
836 DPRINTF("bulk read error, %s\n",
838
839 if (error != USB_ERR_CANCELLED) {
840 /* try to clear stall first */
842 goto tr_setup;
843 }
844 return;
845 }
846}
847
848static void
850{
851 struct aue_softc *sc = usbd_xfer_softc(xfer);
852 struct ifnet *ifp = uether_getifp(&sc->sc_ue);
853 struct usb_page_cache *pc;
854 struct mbuf *m;
855 uint8_t buf[2];
856 int actlen;
857
858 usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
859 pc = usbd_xfer_get_frame(xfer, 0);
860
861 switch (USB_GET_STATE(xfer)) {
863 DPRINTFN(11, "transfer of %d bytes complete\n", actlen);
864 if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
865
866 /* FALLTHROUGH */
867 case USB_ST_SETUP:
868tr_setup:
869 if ((sc->sc_flags & AUE_FLAG_LINK) == 0) {
870 /*
871 * don't send anything if there is no link !
872 */
873 return;
874 }
875 IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
876
877 if (m == NULL)
878 return;
879 if (m->m_pkthdr.len > MCLBYTES)
880 m->m_pkthdr.len = MCLBYTES;
881 if (sc->sc_flags & AUE_FLAG_VER_2) {
882 usbd_xfer_set_frame_len(xfer, 0, m->m_pkthdr.len);
883
884 usbd_m_copy_in(pc, 0, m, 0, m->m_pkthdr.len);
885
886 } else {
887 usbd_xfer_set_frame_len(xfer, 0, (m->m_pkthdr.len + 2));
888
889 /*
890 * The ADMtek documentation says that the
891 * packet length is supposed to be specified
892 * in the first two bytes of the transfer,
893 * however it actually seems to ignore this
894 * info and base the frame size on the bulk
895 * transfer length.
896 */
897 buf[0] = (uint8_t)(m->m_pkthdr.len);
898 buf[1] = (uint8_t)(m->m_pkthdr.len >> 8);
899
900 usbd_copy_in(pc, 0, buf, 2);
901 usbd_m_copy_in(pc, 2, m, 0, m->m_pkthdr.len);
902 }
903
904 /*
905 * if there's a BPF listener, bounce a copy
906 * of this frame to him:
907 */
908 BPF_MTAP(ifp, m);
909
910 m_freem(m);
911
913 return;
914
915 default: /* Error */
916 DPRINTFN(11, "transfer error, %s\n",
918
919 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
920
921 if (error != USB_ERR_CANCELLED) {
922 /* try to clear stall first */
924 goto tr_setup;
925 }
926 return;
927 }
928}
929
930static void
932{
933 struct aue_softc *sc = uether_getsc(ue);
934 struct mii_data *mii = GET_MII(sc);
935
936 AUE_LOCK_ASSERT(sc, MA_OWNED);
937
938 mii_tick(mii);
939 if ((sc->sc_flags & AUE_FLAG_LINK) == 0
940 && mii->mii_media_status & IFM_ACTIVE &&
941 IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE) {
942 sc->sc_flags |= AUE_FLAG_LINK;
943 aue_start(ue);
944 }
945}
946
947static void
949{
950 struct aue_softc *sc = uether_getsc(ue);
951
952 /*
953 * start the USB transfers, if not already started:
954 */
958}
959
960static void
962{
963 struct aue_softc *sc = uether_getsc(ue);
964 struct ifnet *ifp = uether_getifp(ue);
965 int i;
966
967 AUE_LOCK_ASSERT(sc, MA_OWNED);
968
969 /*
970 * Cancel pending I/O
971 */
972 aue_reset(sc);
973
974 /* Set MAC address */
975 for (i = 0; i != ETHER_ADDR_LEN; i++)
976 aue_csr_write_1(sc, AUE_PAR0 + i, IF_LLADDR(ifp)[i]);
977
978 /* update promiscuous setting */
979 aue_setpromisc(ue);
980
981 /* Load the multicast filter. */
982 aue_setmulti(ue);
983
984 /* Enable RX and TX */
988
990
991 ifp->if_drv_flags |= IFF_DRV_RUNNING;
992 aue_start(ue);
993}
994
995static void
997{
998 struct aue_softc *sc = uether_getsc(ue);
999 struct ifnet *ifp = uether_getifp(ue);
1000
1001 AUE_LOCK_ASSERT(sc, MA_OWNED);
1002
1003 /* if we want promiscuous mode, set the allframes bit: */
1004 if (ifp->if_flags & IFF_PROMISC)
1006 else
1008}
1009
1010/*
1011 * Set media options.
1012 */
1013static int
1014aue_ifmedia_upd(struct ifnet *ifp)
1015{
1016 struct aue_softc *sc = ifp->if_softc;
1017 struct mii_data *mii = GET_MII(sc);
1018 struct mii_softc *miisc;
1019 int error;
1020
1021 AUE_LOCK_ASSERT(sc, MA_OWNED);
1022
1023 sc->sc_flags &= ~AUE_FLAG_LINK;
1024 LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
1025 PHY_RESET(miisc);
1026 error = mii_mediachg(mii);
1027 return (error);
1028}
1029
1030/*
1031 * Report current media status.
1032 */
1033static void
1034aue_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
1035{
1036 struct aue_softc *sc = ifp->if_softc;
1037 struct mii_data *mii = GET_MII(sc);
1038
1039 AUE_LOCK(sc);
1040 mii_pollstat(mii);
1041 ifmr->ifm_active = mii->mii_media_active;
1042 ifmr->ifm_status = mii->mii_media_status;
1043 AUE_UNLOCK(sc);
1044}
1045
1046/*
1047 * Stop the adapter and free any mbufs allocated to the
1048 * RX and TX lists.
1049 */
1050static void
1052{
1053 struct aue_softc *sc = uether_getsc(ue);
1054 struct ifnet *ifp = uether_getifp(ue);
1055
1056 AUE_LOCK_ASSERT(sc, MA_OWNED);
1057
1058 ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
1059 sc->sc_flags &= ~AUE_FLAG_LINK;
1060
1061 /*
1062 * stop all the transfers, if not already stopped:
1063 */
1067
1068 aue_csr_write_1(sc, AUE_CTL0, 0);
1069 aue_csr_write_1(sc, AUE_CTL1, 0);
1070 aue_reset(sc);
1071}
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+")
static uint16_t aue_eeprom_getword(struct aue_softc *, int)
Definition: if_aue.c:387
#define AUE_CLRBIT(sc, reg, x)
Definition: if_aue.c:307
static uether_fn_t aue_setpromisc
Definition: if_aue.c:218
MODULE_DEPEND(aue, uether, 1, 1, 1)
static driver_t aue_driver
Definition: if_aue.c:275
static void aue_reset(struct aue_softc *)
Definition: if_aue.c:595
static usb_callback_t aue_bulk_write_callback
Definition: if_aue.c:210
static void aue_read_mac(struct aue_softc *sc, uint8_t *eaddr)
Definition: if_aue.c:411
static uether_fn_t aue_tick
Definition: if_aue.c:216
static const struct usb_ether_methods aue_ue_methods
Definition: if_aue.c:292
static uether_fn_t aue_attach_post
Definition: if_aue.c:212
static uether_fn_t aue_start
Definition: if_aue.c:215
static device_method_t aue_methods[]
Definition: if_aue.c:261
static void aue_csr_write_2(struct aue_softc *, uint16_t, uint16_t)
Definition: if_aue.c:366
static devclass_t aue_devclass
Definition: if_aue.c:281
static const STRUCT_USB_HOST_ID aue_devs[]
Definition: if_aue.c:126
#define AUE_SETBIT(sc, reg, x)
Definition: if_aue.c:304
static const struct usb_config aue_config[AUE_N_TRANSFER]
Definition: if_aue.c:231
static void aue_ifmedia_sts(struct ifnet *, struct ifmediareq *)
Definition: if_aue.c:1034
DRIVER_MODULE(aue, uhub, aue_driver, aue_devclass, NULL, 0)
static miibus_readreg_t aue_miibus_readreg
Definition: if_aue.c:204
__FBSDID("$FreeBSD$")
static uether_fn_t aue_init
Definition: if_aue.c:213
static usb_callback_t aue_bulk_read_callback
Definition: if_aue.c:209
static usb_callback_t aue_intr_callback
Definition: if_aue.c:208
#define AUE_BITS
Definition: if_aue.c:542
static void aue_reset_pegasus_II(struct aue_softc *)
Definition: if_aue.c:581
static device_attach_t aue_attach
Definition: if_aue.c:202
static void aue_csr_write_1(struct aue_softc *, uint16_t, uint8_t)
Definition: if_aue.c:349
static device_detach_t aue_detach
Definition: if_aue.c:203
static int aue_ifmedia_upd(struct ifnet *)
Definition: if_aue.c:1014
static uether_fn_t aue_stop
Definition: if_aue.c:214
static miibus_statchg_t aue_miibus_statchg
Definition: if_aue.c:206
static uint16_t aue_csr_read_2(struct aue_softc *, uint16_t)
Definition: if_aue.c:330
USB_PNP_HOST_INFO(aue_devs)
MODULE_VERSION(aue, 1)
static uether_fn_t aue_setmulti
Definition: if_aue.c:217
static u_int aue_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
Definition: if_aue.c:544
static miibus_writereg_t aue_miibus_writereg
Definition: if_aue.c:205
static device_probe_t aue_probe
Definition: if_aue.c:201
#define AUE_DEV(v, p, i)
static uint8_t aue_csr_read_1(struct aue_softc *, uint16_t)
Definition: if_aue.c:311
#define AUE_GPIO_SEL0
Definition: if_auereg.h:173
#define AUE_CTL0
Definition: if_auereg.h:74
#define AUE_CTL0_ALLMULTI
Definition: if_auereg.h:124
#define AUE_LOCK(_sc)
Definition: if_auereg.h:220
#define AUE_PHY_ADDR
Definition: if_auereg.h:104
#define AUE_PAR0
Definition: if_auereg.h:86
#define AUE_CTL1_SPEEDSEL
Definition: if_auereg.h:134
#define AUE_GPIO_OUT0
Definition: if_auereg.h:172
#define AUE_FLAG_PNA
Definition: if_auereg.h:213
#define AUE_EECTL_READ
Definition: if_auereg.h:146
#define AUE_EECTL_DONE
Definition: if_auereg.h:147
#define AUE_EE_REG
Definition: if_auereg.h:99
#define AUE_REG_1D
Definition: if_auereg.h:98
#define AUE_FLAG_PII
Definition: if_auereg.h:214
#define AUE_UR_READREG
Definition: if_auereg.h:51
#define AUE_FLAG_LINK
Definition: if_auereg.h:215
#define AUE_UR_WRITEREG
Definition: if_auereg.h:52
#define AUE_CTL1_DUPLEX
Definition: if_auereg.h:135
#define AUE_CTL2
Definition: if_auereg.h:76
#define AUE_PHY_DATA
Definition: if_auereg.h:107
#define AUE_CTL0_RX_ENB
Definition: if_auereg.h:129
#define AUE_PHYCTL_READ
Definition: if_auereg.h:151
#define AUE_TXSTAT0_EXCESSCOLL
Definition: if_auereg.h:161
#define AUE_RXSTAT_MASK
Definition: if_auereg.h:186
#define AUE_LOCK_ASSERT(_sc, t)
Definition: if_auereg.h:222
#define AUE_TIMEOUT
Definition: if_auereg.h:178
#define AUE_CONFIG_INDEX
Definition: if_auereg.h:54
#define AUE_FLAG_LSYS
Definition: if_auereg.h:212
#define AUE_UNLOCK(_sc)
Definition: if_auereg.h:221
#define AUE_GPIO_SEL1
Definition: if_auereg.h:176
#define AUE_REG_7B
Definition: if_auereg.h:118
#define AUE_TXSTAT0_LATECOLL
Definition: if_auereg.h:160
#define AUE_GPIO0
Definition: if_auereg.h:119
#define AUE_REG_81
Definition: if_auereg.h:121
#define AUE_PHYCTL_DONE
Definition: if_auereg.h:152
#define AUE_CTL1_RESETMAC
Definition: if_auereg.h:133
#define AUE_CTL2_EP3_CLR
Definition: if_auereg.h:138
#define AUE_FLAG_VER_2
Definition: if_auereg.h:216
#define AUE_CTL0_TX_ENB
Definition: if_auereg.h:130
#define AUE_MAR0
Definition: if_auereg.h:77
#define AUE_PHYCTL_WRITE
Definition: if_auereg.h:150
#define AUE_CTL1
Definition: if_auereg.h:75
#define GET_MII(sc)
Definition: if_auereg.h:188
#define AUE_CTL2_RX_PROMISC
Definition: if_auereg.h:140
#define AUE_FLAG_DUAL_PHY
Definition: if_auereg.h:217
@ AUE_BULK_DT_WR
Definition: if_auereg.h:66
@ AUE_N_TRANSFER
Definition: if_auereg.h:69
@ AUE_INTR_DT_RD
Definition: if_auereg.h:68
@ AUE_BULK_DT_RD
Definition: if_auereg.h:67
#define AUE_PHY_CTL
Definition: if_auereg.h:108
#define AUE_CTL0_RXSTAT_APPEND
Definition: if_auereg.h:126
#define AUE_EE_DATA
Definition: if_auereg.h:102
#define AUE_IFACE_IDX
Definition: if_auereg.h:55
#define AUE_EE_CTL
Definition: if_auereg.h:103
uint32_t reg
Definition: if_rum.c:283
uint32_t val
Definition: if_rum.c:284
struct @109 error
uint16_t data
device_t dev
uint64_t * addr
uint8_t aue_txstat0
Definition: if_auereg.h:191
uint8_t aue_rxstat
Definition: if_auereg.h:202
struct usb_ether sc_ue
Definition: if_auereg.h:207
struct usb_xfer * sc_xfer[AUE_N_TRANSFER]
Definition: if_auereg.h:209
struct mtx sc_mtx
Definition: if_auereg.h:208
int sc_flags
Definition: if_auereg.h:211
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 pipe_bof
Definition: usbdi.h:200
uint16_t idProduct
Definition: usbdi.h:409
uint8_t bIfaceIndex
Definition: usbdi.h:417
uint8_t bConfigIndex
Definition: usbdi.h:419
uint16_t idVendor
Definition: usbdi.h:408
uint16_t bcdDevice
Definition: usbdi.h:410
#define DPRINTF(...)
Definition: umass.c:179
#define UE_INTERRUPT
Definition: usb.h:544
#define UE_ADDR_ANY
Definition: usb.h:537
#define UE_BULK
Definition: usb.h:543
#define UT_WRITE_VENDOR_DEVICE
Definition: usb.h:184
#define UT_READ_VENDOR_DEVICE
Definition: usb.h:180
#define UE_DIR_IN
Definition: usb.h:531
#define UE_DIR_OUT
Definition: usb.h:532
@ USB_MODE_HOST
Definition: usb.h:778
void usbd_copy_in(struct usb_page_cache *cache, usb_frlength_t offset, const void *ptr, usb_frlength_t len)
Definition: usb_busdma.c:166
void usbd_copy_out(struct usb_page_cache *cache, usb_frlength_t offset, void *ptr, usb_frlength_t len)
Definition: usb_busdma.c:283
#define USETW(w, v)
Definition: usb_endian.h:77
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
void uether_ifdetach(struct usb_ether *ue)
Definition: usb_ethernet.c:302
void * uether_getsc(struct usb_ether *ue)
Definition: usb_ethernet.c:148
int uether_rxbuf(struct usb_ether *ue, struct usb_page_cache *pc, unsigned int offset, unsigned int len)
Definition: usb_ethernet.c:616
struct ifnet * uether_getifp(struct usb_ether *ue)
Definition: usb_ethernet.c:136
uint8_t uether_pause(struct usb_ether *ue, unsigned int _ticks)
Definition: usb_ethernet.c:94
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
uint16_t offset
Definition: usb_if.m:54
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_transfer_unsetup(struct usb_xfer **pxfer, uint16_t n_setup)
void usbd_xfer_set_frame_len(struct usb_xfer *xfer, usb_frcount_t frindex, usb_frlength_t len)
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_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)
usb_frlength_t usbd_xfer_max_len(struct usb_xfer *xfer)
void device_set_usb_desc(device_t dev)
Definition: usb_util.c:73
#define USB_ST_SETUP
Definition: usbdi.h:502
usb_error_t
Definition: usbdi.h:45
@ USB_ERR_CANCELLED
Definition: usbdi.h:51
#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)
void() usb_callback_t(struct usb_xfer *, usb_error_t)
Definition: usbdi.h:94
#define STRUCT_USB_HOST_ID
Definition: usbdi.h:258
#define USB_GET_DRIVER_INFO(did)
Definition: usbdi.h:400
#define USB_GET_STATE(xfer)
Definition: usbdi.h:515