FreeBSD kernel usb device Code
if_axe.c
Go to the documentation of this file.
1/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (c) 1997, 1998, 1999, 2000-2003
5 * Bill Paul <wpaul@windriver.com>. 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 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Bill Paul.
18 * 4. Neither the name of the author nor the names of any co-contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
26 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 * THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35#include <sys/cdefs.h>
36__FBSDID("$FreeBSD$");
37
38/*
39 * ASIX Electronics AX88172/AX88178/AX88778 USB 2.0 ethernet driver.
40 * Used in the LinkSys USB200M and various other adapters.
41 *
42 * Manuals available from:
43 * http://www.asix.com.tw/datasheet/mac/Ax88172.PDF
44 * Note: you need the manual for the AX88170 chip (USB 1.x ethernet
45 * controller) to find the definitions for the RX control register.
46 * http://www.asix.com.tw/datasheet/mac/Ax88170.PDF
47 *
48 * Written by Bill Paul <wpaul@windriver.com>
49 * Senior Engineer
50 * Wind River Systems
51 */
52
53/*
54 * The AX88172 provides USB ethernet supports at 10 and 100Mbps.
55 * It uses an external PHY (reference designs use a RealTek chip),
56 * and has a 64-bit multicast hash filter. There is some information
57 * missing from the manual which one needs to know in order to make
58 * the chip function:
59 *
60 * - You must set bit 7 in the RX control register, otherwise the
61 * chip won't receive any packets.
62 * - You must initialize all 3 IPG registers, or you won't be able
63 * to send any packets.
64 *
65 * Note that this device appears to only support loading the station
66 * address via autload from the EEPROM (i.e. there's no way to manually
67 * set it).
68 *
69 * (Adam Weinberger wanted me to name this driver if_gir.c.)
70 */
71
72/*
73 * Ax88178 and Ax88772 support backported from the OpenBSD driver.
74 * 2007/02/12, J.R. Oldroyd, fbsd@opal.com
75 *
76 * Manual here:
77 * http://www.asix.com.tw/FrootAttach/datasheet/AX88178_datasheet_Rev10.pdf
78 * http://www.asix.com.tw/FrootAttach/datasheet/AX88772_datasheet_Rev10.pdf
79 */
80
81#include <sys/param.h>
82#include <sys/systm.h>
83#include <sys/bus.h>
84#include <sys/condvar.h>
85#include <sys/endian.h>
86#include <sys/kernel.h>
87#include <sys/lock.h>
88#include <sys/malloc.h>
89#include <sys/mbuf.h>
90#include <sys/module.h>
91#include <sys/mutex.h>
92#include <sys/socket.h>
93#include <sys/sockio.h>
94#include <sys/sysctl.h>
95#include <sys/sx.h>
96
97#include <net/if.h>
98#include <net/if_var.h>
99#include <net/ethernet.h>
100#include <net/if_types.h>
101#include <net/if_media.h>
102#include <net/if_vlan_var.h>
103
104#include <dev/mii/mii.h>
105#include <dev/mii/miivar.h>
106
107#include <dev/usb/usb.h>
108#include <dev/usb/usbdi.h>
109#include <dev/usb/usbdi_util.h>
110#include "usbdevs.h"
111
112#define USB_DEBUG_VAR axe_debug
113#include <dev/usb/usb_debug.h>
114#include <dev/usb/usb_process.h>
115
118
119#include "miibus_if.h"
120
121/*
122 * AXE_178_MAX_FRAME_BURST
123 * max frame burst size for Ax88178 and Ax88772
124 * 0 2048 bytes
125 * 1 4096 bytes
126 * 2 8192 bytes
127 * 3 16384 bytes
128 * use the largest your system can handle without USB stalling.
129 *
130 * NB: 88772 parts appear to generate lots of input errors with
131 * a 2K rx buffer and 8K is only slightly faster than 4K on an
132 * EHCI port on a T42 so change at your own risk.
133 */
134#define AXE_178_MAX_FRAME_BURST 1
135
136#define AXE_CSUM_FEATURES (CSUM_IP | CSUM_TCP | CSUM_UDP)
137
138#ifdef USB_DEBUG
139static int axe_debug = 0;
140
141static SYSCTL_NODE(_hw_usb, OID_AUTO, axe, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
142 "USB axe");
143SYSCTL_INT(_hw_usb_axe, OID_AUTO, debug, CTLFLAG_RWTUN, &axe_debug, 0,
144 "Debug level");
145#endif
146
147/*
148 * Various supported device vendors/products.
149 */
150static const STRUCT_USB_HOST_ID axe_devs[] = {
151#define AXE_DEV(v,p,i) { USB_VPI(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, i) }
152 AXE_DEV(ABOCOM, UF200, 0),
153 AXE_DEV(ACERCM, EP1427X2, 0),
154 AXE_DEV(APPLE, ETHERNET, AXE_FLAG_772),
155 AXE_DEV(ASIX, AX88172, 0),
156 AXE_DEV(ASIX, AX88178, AXE_FLAG_178),
157 AXE_DEV(ASIX, AX88772, AXE_FLAG_772),
158 AXE_DEV(ASIX, AX88772A, AXE_FLAG_772A),
159 AXE_DEV(ASIX, AX88772B, AXE_FLAG_772B),
160 AXE_DEV(ASIX, AX88772B_1, AXE_FLAG_772B),
161 AXE_DEV(ATEN, UC210T, 0),
162 AXE_DEV(BELKIN, F5D5055, AXE_FLAG_178),
163 AXE_DEV(BILLIONTON, USB2AR, 0),
164 AXE_DEV(CISCOLINKSYS, USB200MV2, AXE_FLAG_772A),
165 AXE_DEV(COREGA, FETHER_USB2_TX, 0),
166 AXE_DEV(DLINK, DUBE100, 0),
167 AXE_DEV(DLINK, DUBE100B1, AXE_FLAG_772),
168 AXE_DEV(DLINK, DUBE100C1, AXE_FLAG_772B),
169 AXE_DEV(GOODWAY, GWUSB2E, 0),
170 AXE_DEV(IODATA, ETGUS2, AXE_FLAG_178),
171 AXE_DEV(JVC, MP_PRX1, 0),
172 AXE_DEV(LENOVO, ETHERNET, AXE_FLAG_772B),
173 AXE_DEV(LINKSYS2, USB200M, 0),
174 AXE_DEV(LINKSYS4, USB1000, AXE_FLAG_178),
175 AXE_DEV(LOGITEC, LAN_GTJU2A, AXE_FLAG_178),
176 AXE_DEV(MELCO, LUAU2KTX, 0),
177 AXE_DEV(MELCO, LUA3U2AGT, AXE_FLAG_178),
178 AXE_DEV(NETGEAR, FA120, 0),
179 AXE_DEV(OQO, ETHER01PLUS, AXE_FLAG_772),
180 AXE_DEV(PLANEX3, GU1000T, AXE_FLAG_178),
181 AXE_DEV(SITECOM, LN029, 0),
182 AXE_DEV(SITECOMEU, LN028, AXE_FLAG_178),
183 AXE_DEV(SITECOMEU, LN031, AXE_FLAG_178),
184 AXE_DEV(SYSTEMTALKS, SGCX2UL, 0),
185#undef AXE_DEV
186};
187
188static device_probe_t axe_probe;
189static device_attach_t axe_attach;
190static device_detach_t axe_detach;
191
194
195static miibus_readreg_t axe_miibus_readreg;
196static miibus_writereg_t axe_miibus_writereg;
197static miibus_statchg_t axe_miibus_statchg;
198
206
207static int axe_attach_post_sub(struct usb_ether *);
208static int axe_ifmedia_upd(struct ifnet *);
209static void axe_ifmedia_sts(struct ifnet *, struct ifmediareq *);
210static int axe_cmd(struct axe_softc *, int, int, int, void *);
211static void axe_ax88178_init(struct axe_softc *);
212static void axe_ax88772_init(struct axe_softc *);
213static void axe_ax88772_phywake(struct axe_softc *);
214static void axe_ax88772a_init(struct axe_softc *);
215static void axe_ax88772b_init(struct axe_softc *);
216static int axe_get_phyno(struct axe_softc *, int);
217static int axe_ioctl(struct ifnet *, u_long, caddr_t);
218static int axe_rx_frame(struct usb_ether *, struct usb_page_cache *, int);
219static int axe_rxeof(struct usb_ether *, struct usb_page_cache *,
220 unsigned int offset, unsigned int, struct axe_csum_hdr *);
221static void axe_csum_cfg(struct usb_ether *);
222
223static const struct usb_config axe_config[AXE_N_TRANSFER] = {
224 [AXE_BULK_DT_WR] = {
225 .type = UE_BULK,
226 .endpoint = UE_ADDR_ANY,
227 .direction = UE_DIR_OUT,
228 .frames = 16,
229 .bufsize = 16 * MCLBYTES,
230 .flags = {.pipe_bof = 1,.force_short_xfer = 1,},
231 .callback = axe_bulk_write_callback,
232 .timeout = 10000, /* 10 seconds */
233 },
234
235 [AXE_BULK_DT_RD] = {
236 .type = UE_BULK,
237 .endpoint = UE_ADDR_ANY,
238 .direction = UE_DIR_IN,
239 .bufsize = 16384, /* bytes */
240 .flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
241 .callback = axe_bulk_read_callback,
242 .timeout = 0, /* no timeout */
243 },
244};
245
246static const struct ax88772b_mfb ax88772b_mfb_table[] = {
247 { 0x8000, 0x8001, 2048 },
248 { 0x8100, 0x8147, 4096},
249 { 0x8200, 0x81EB, 6144},
250 { 0x8300, 0x83D7, 8192},
251 { 0x8400, 0x851E, 16384},
252 { 0x8500, 0x8666, 20480},
253 { 0x8600, 0x87AE, 24576},
254 { 0x8700, 0x8A3D, 32768}
255};
256
257static device_method_t axe_methods[] = {
258 /* Device interface */
259 DEVMETHOD(device_probe, axe_probe),
260 DEVMETHOD(device_attach, axe_attach),
261 DEVMETHOD(device_detach, axe_detach),
262
263 /* MII interface */
264 DEVMETHOD(miibus_readreg, axe_miibus_readreg),
265 DEVMETHOD(miibus_writereg, axe_miibus_writereg),
266 DEVMETHOD(miibus_statchg, axe_miibus_statchg),
267
268 DEVMETHOD_END
269};
270
271static driver_t axe_driver = {
272 .name = "axe",
273 .methods = axe_methods,
274 .size = sizeof(struct axe_softc),
275};
276
277static devclass_t axe_devclass;
278
280DRIVER_MODULE(miibus, axe, miibus_driver, miibus_devclass, 0, 0);
281MODULE_DEPEND(axe, uether, 1, 1, 1);
282MODULE_DEPEND(axe, usb, 1, 1, 1);
283MODULE_DEPEND(axe, ether, 1, 1, 1);
284MODULE_DEPEND(axe, miibus, 1, 1, 1);
287
288static const struct usb_ether_methods axe_ue_methods = {
290 .ue_attach_post_sub = axe_attach_post_sub,
291 .ue_start = axe_start,
292 .ue_init = axe_init,
293 .ue_stop = axe_stop,
294 .ue_tick = axe_tick,
295 .ue_setmulti = axe_setmulti,
296 .ue_setpromisc = axe_setpromisc,
297 .ue_mii_upd = axe_ifmedia_upd,
298 .ue_mii_sts = axe_ifmedia_sts,
299};
300
301static int
302axe_cmd(struct axe_softc *sc, int cmd, int index, int val, void *buf)
303{
304 struct usb_device_request req;
305 usb_error_t err;
306
307 AXE_LOCK_ASSERT(sc, MA_OWNED);
308
309 req.bmRequestType = (AXE_CMD_IS_WRITE(cmd) ?
312 req.bRequest = AXE_CMD_CMD(cmd);
313 USETW(req.wValue, val);
314 USETW(req.wIndex, index);
315 USETW(req.wLength, AXE_CMD_LEN(cmd));
316
317 err = uether_do_request(&sc->sc_ue, &req, buf, 1000);
318
319 return (err);
320}
321
322static int
323axe_miibus_readreg(device_t dev, int phy, int reg)
324{
325 struct axe_softc *sc = device_get_softc(dev);
326 uint16_t val;
327 int locked;
328
329 locked = mtx_owned(&sc->sc_mtx);
330 if (!locked)
331 AXE_LOCK(sc);
332
333 axe_cmd(sc, AXE_CMD_MII_OPMODE_SW, 0, 0, NULL);
334 axe_cmd(sc, AXE_CMD_MII_READ_REG, reg, phy, &val);
335 axe_cmd(sc, AXE_CMD_MII_OPMODE_HW, 0, 0, NULL);
336
337 val = le16toh(val);
338 if (AXE_IS_772(sc) && reg == MII_BMSR) {
339 /*
340 * BMSR of AX88772 indicates that it supports extended
341 * capability but the extended status register is
342 * revered for embedded ethernet PHY. So clear the
343 * extended capability bit of BMSR.
344 */
345 val &= ~BMSR_EXTCAP;
346 }
347
348 if (!locked)
349 AXE_UNLOCK(sc);
350 return (val);
351}
352
353static int
354axe_miibus_writereg(device_t dev, int phy, int reg, int val)
355{
356 struct axe_softc *sc = device_get_softc(dev);
357 int locked;
358
359 val = htole32(val);
360 locked = mtx_owned(&sc->sc_mtx);
361 if (!locked)
362 AXE_LOCK(sc);
363
364 axe_cmd(sc, AXE_CMD_MII_OPMODE_SW, 0, 0, NULL);
366 axe_cmd(sc, AXE_CMD_MII_OPMODE_HW, 0, 0, NULL);
367
368 if (!locked)
369 AXE_UNLOCK(sc);
370 return (0);
371}
372
373static void
375{
376 struct axe_softc *sc = device_get_softc(dev);
377 struct mii_data *mii = GET_MII(sc);
378 struct ifnet *ifp;
379 uint16_t val;
380 int err, locked;
381
382 locked = mtx_owned(&sc->sc_mtx);
383 if (!locked)
384 AXE_LOCK(sc);
385
386 ifp = uether_getifp(&sc->sc_ue);
387 if (mii == NULL || ifp == NULL ||
388 (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
389 goto done;
390
391 sc->sc_flags &= ~AXE_FLAG_LINK;
392 if ((mii->mii_media_status & (IFM_ACTIVE | IFM_AVALID)) ==
393 (IFM_ACTIVE | IFM_AVALID)) {
394 switch (IFM_SUBTYPE(mii->mii_media_active)) {
395 case IFM_10_T:
396 case IFM_100_TX:
397 sc->sc_flags |= AXE_FLAG_LINK;
398 break;
399 case IFM_1000_T:
400 if ((sc->sc_flags & AXE_FLAG_178) == 0)
401 break;
402 sc->sc_flags |= AXE_FLAG_LINK;
403 break;
404 default:
405 break;
406 }
407 }
408
409 /* Lost link, do nothing. */
410 if ((sc->sc_flags & AXE_FLAG_LINK) == 0)
411 goto done;
412
413 val = 0;
414 if ((IFM_OPTIONS(mii->mii_media_active) & IFM_FDX) != 0) {
416 if (AXE_IS_178_FAMILY(sc)) {
417 if ((IFM_OPTIONS(mii->mii_media_active) &
418 IFM_ETH_TXPAUSE) != 0)
420 if ((IFM_OPTIONS(mii->mii_media_active) &
421 IFM_ETH_RXPAUSE) != 0)
423 }
424 }
425 if (AXE_IS_178_FAMILY(sc)) {
427 if ((sc->sc_flags & AXE_FLAG_178) != 0)
429 switch (IFM_SUBTYPE(mii->mii_media_active)) {
430 case IFM_1000_T:
432 break;
433 case IFM_100_TX:
435 break;
436 case IFM_10_T:
437 /* doesn't need to be handled */
438 break;
439 }
440 }
441 err = axe_cmd(sc, AXE_CMD_WRITE_MEDIA, 0, val, NULL);
442 if (err)
443 device_printf(dev, "media change failed, error %d\n", err);
444done:
445 if (!locked)
446 AXE_UNLOCK(sc);
447}
448
449/*
450 * Set media options.
451 */
452static int
453axe_ifmedia_upd(struct ifnet *ifp)
454{
455 struct axe_softc *sc = ifp->if_softc;
456 struct mii_data *mii = GET_MII(sc);
457 struct mii_softc *miisc;
458 int error;
459
460 AXE_LOCK_ASSERT(sc, MA_OWNED);
461
462 LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
463 PHY_RESET(miisc);
464 error = mii_mediachg(mii);
465 return (error);
466}
467
468/*
469 * Report current media status.
470 */
471static void
472axe_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
473{
474 struct axe_softc *sc = ifp->if_softc;
475 struct mii_data *mii = GET_MII(sc);
476
477 AXE_LOCK(sc);
478 mii_pollstat(mii);
479 ifmr->ifm_active = mii->mii_media_active;
480 ifmr->ifm_status = mii->mii_media_status;
481 AXE_UNLOCK(sc);
482}
483
484static u_int
485axe_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
486{
487 uint8_t *hashtbl = arg;
488 uint32_t h;
489
490 h = ether_crc32_be(LLADDR(sdl), ETHER_ADDR_LEN) >> 26;
491 hashtbl[h / 8] |= 1 << (h % 8);
492
493 return (1);
494}
495
496static void
498{
499 struct axe_softc *sc = uether_getsc(ue);
500 struct ifnet *ifp = uether_getifp(ue);
501 uint16_t rxmode;
502 uint8_t hashtbl[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
503
504 AXE_LOCK_ASSERT(sc, MA_OWNED);
505
506 axe_cmd(sc, AXE_CMD_RXCTL_READ, 0, 0, &rxmode);
507 rxmode = le16toh(rxmode);
508
509 if (ifp->if_flags & (IFF_ALLMULTI | IFF_PROMISC)) {
510 rxmode |= AXE_RXCMD_ALLMULTI;
511 axe_cmd(sc, AXE_CMD_RXCTL_WRITE, 0, rxmode, NULL);
512 return;
513 }
514 rxmode &= ~AXE_RXCMD_ALLMULTI;
515
516 if_foreach_llmaddr(ifp, axe_hash_maddr, &hashtbl);
517
518 axe_cmd(sc, AXE_CMD_WRITE_MCAST, 0, 0, (void *)&hashtbl);
519 axe_cmd(sc, AXE_CMD_RXCTL_WRITE, 0, rxmode, NULL);
520}
521
522static int
523axe_get_phyno(struct axe_softc *sc, int sel)
524{
525 int phyno;
526
527 switch (AXE_PHY_TYPE(sc->sc_phyaddrs[sel])) {
529 case PHY_TYPE_GIG:
530 phyno = AXE_PHY_NO(sc->sc_phyaddrs[sel]);
531 break;
532 case PHY_TYPE_SPECIAL:
533 /* FALLTHROUGH */
534 case PHY_TYPE_RSVD:
535 /* FALLTHROUGH */
536 case PHY_TYPE_NON_SUP:
537 /* FALLTHROUGH */
538 default:
539 phyno = -1;
540 break;
541 }
542
543 return (phyno);
544}
545
546#define AXE_GPIO_WRITE(x, y) do { \
547 axe_cmd(sc, AXE_CMD_WRITE_GPIO, 0, (x), NULL); \
548 uether_pause(ue, (y)); \
549} while (0)
550
551static void
553{
554 struct usb_ether *ue;
555 int gpio0, ledmode, phymode;
556 uint16_t eeprom, val;
557
558 ue = &sc->sc_ue;
559 axe_cmd(sc, AXE_CMD_SROM_WR_ENABLE, 0, 0, NULL);
560 /* XXX magic */
561 axe_cmd(sc, AXE_CMD_SROM_READ, 0, 0x0017, &eeprom);
562 eeprom = le16toh(eeprom);
563 axe_cmd(sc, AXE_CMD_SROM_WR_DISABLE, 0, 0, NULL);
564
565 /* if EEPROM is invalid we have to use to GPIO0 */
566 if (eeprom == 0xffff) {
567 phymode = AXE_PHY_MODE_MARVELL;
568 gpio0 = 1;
569 ledmode = 0;
570 } else {
571 phymode = eeprom & 0x7f;
572 gpio0 = (eeprom & 0x80) ? 0 : 1;
573 ledmode = eeprom >> 8;
574 }
575
576 if (bootverbose)
577 device_printf(sc->sc_ue.ue_dev,
578 "EEPROM data : 0x%04x, phymode : 0x%02x\n", eeprom,
579 phymode);
580 /* Program GPIOs depending on PHY hardware. */
581 switch (phymode) {
583 if (gpio0 == 1) {
585 hz / 32);
587 hz / 32);
590 hz / 32);
591 } else {
593 AXE_GPIO1_EN, hz / 3);
594 if (ledmode == 1) {
597 hz / 3);
598 } else {
600 AXE_GPIO2 | AXE_GPIO2_EN, hz / 32);
602 AXE_GPIO2_EN, hz / 4);
604 AXE_GPIO2 | AXE_GPIO2_EN, hz / 32);
605 }
606 }
607 break;
611 if (gpio0 == 1)
613 AXE_GPIO0_EN, hz / 32);
614 else
616 AXE_GPIO1_EN, hz / 32);
617 break;
620 AXE_GPIO1_EN, hz / 32);
622 AXE_GPIO2_EN, hz / 32);
625 AXE_GPIO2_EN, hz / 32);
626 break;
630 val = gpio0 == 1 ? AXE_GPIO0 | AXE_GPIO0_EN :
632 AXE_GPIO_WRITE(val, hz / 32);
636 if (phymode == AXE_PHY_MODE_REALTEK_8211CL) {
638 0x1F, 0x0005);
640 0x0C, 0x0000);
642 0x0001);
644 0x01, val | 0x0080);
646 0x1F, 0x0000);
647 }
648 break;
649 default:
650 /* Unknown PHY model or no need to program GPIOs. */
651 break;
652 }
653
654 /* soft reset */
656 uether_pause(ue, hz / 4);
657
660 uether_pause(ue, hz / 4);
661 /* Enable MII/GMII/RGMII interface to work with external PHY. */
662 axe_cmd(sc, AXE_CMD_SW_PHY_SELECT, 0, 0, NULL);
663 uether_pause(ue, hz / 4);
664
665 axe_cmd(sc, AXE_CMD_RXCTL_WRITE, 0, 0, NULL);
666}
667
668static void
670{
671 axe_cmd(sc, AXE_CMD_WRITE_GPIO, 0, 0x00b0, NULL);
672 uether_pause(&sc->sc_ue, hz / 16);
673
674 if (sc->sc_phyno == AXE_772_PHY_NO_EPHY) {
675 /* ask for the embedded PHY */
676 axe_cmd(sc, AXE_CMD_SW_PHY_SELECT, 0, 0x01, NULL);
677 uether_pause(&sc->sc_ue, hz / 64);
678
679 /* power down and reset state, pin reset state */
681 AXE_SW_RESET_CLEAR, NULL);
682 uether_pause(&sc->sc_ue, hz / 16);
683
684 /* power down/reset state, pin operating state */
687 uether_pause(&sc->sc_ue, hz / 4);
688
689 /* power up, reset */
691
692 /* power up, operating */
695 } else {
696 /* ask for external PHY */
697 axe_cmd(sc, AXE_CMD_SW_PHY_SELECT, 0, 0x00, NULL);
698 uether_pause(&sc->sc_ue, hz / 64);
699
700 /* power down internal PHY */
703 }
704
705 uether_pause(&sc->sc_ue, hz / 4);
706 axe_cmd(sc, AXE_CMD_RXCTL_WRITE, 0, 0, NULL);
707}
708
709static void
711{
712 if (sc->sc_phyno == AXE_772_PHY_NO_EPHY) {
713 /* Manually select internal(embedded) PHY - MAC mode. */
716 NULL);
717 uether_pause(&sc->sc_ue, hz / 32);
718 } else {
719 /*
720 * Manually select external PHY - MAC mode.
721 * Reverse MII/RMII is for AX88772A PHY mode.
722 */
725 uether_pause(&sc->sc_ue, hz / 32);
726 }
727 /* Take PHY out of power down. */
729 AXE_SW_RESET_IPRL, NULL);
730 uether_pause(&sc->sc_ue, hz / 4);
732 uether_pause(&sc->sc_ue, hz);
734 uether_pause(&sc->sc_ue, hz / 32);
736 uether_pause(&sc->sc_ue, hz / 32);
737}
738
739static void
741{
742 struct usb_ether *ue;
743
744 ue = &sc->sc_ue;
745 /* Reload EEPROM. */
748 /* Stop MAC. */
749 axe_cmd(sc, AXE_CMD_RXCTL_WRITE, 0, 0, NULL);
750}
751
752static void
754{
755 struct usb_ether *ue;
756 uint16_t eeprom;
757 uint8_t *eaddr;
758 int i;
759
760 ue = &sc->sc_ue;
761 /* Reload EEPROM. */
763 /*
764 * Save PHY power saving configuration(high byte) and
765 * clear EEPROM checksum value(low byte).
766 */
768 sc->sc_pwrcfg = le16toh(eeprom) & 0xFF00;
769
770 /*
771 * Auto-loaded default station address from internal ROM is
772 * 00:00:00:00:00:00 such that an explicit access to EEPROM
773 * is required to get real station address.
774 */
775 eaddr = ue->ue_eaddr;
776 for (i = 0; i < ETHER_ADDR_LEN / 2; i++) {
778 &eeprom);
779 eeprom = le16toh(eeprom);
780 *eaddr++ = (uint8_t)(eeprom & 0xFF);
781 *eaddr++ = (uint8_t)((eeprom >> 8) & 0xFF);
782 }
783 /* Wakeup PHY. */
785 /* Stop MAC. */
786 axe_cmd(sc, AXE_CMD_RXCTL_WRITE, 0, 0, NULL);
787}
788
789#undef AXE_GPIO_WRITE
790
791static void
793{
794 struct usb_config_descriptor *cd;
795 usb_error_t err;
796
798
799 err = usbd_req_set_config(sc->sc_ue.ue_udev, &sc->sc_mtx,
801 if (err)
802 DPRINTF("reset failed (ignored)\n");
803
804 /* Wait a little while for the chip to get its brains in order. */
805 uether_pause(&sc->sc_ue, hz / 100);
806
807 /* Reinitialize controller to achieve full reset. */
808 if (sc->sc_flags & AXE_FLAG_178)
810 else if (sc->sc_flags & AXE_FLAG_772)
812 else if (sc->sc_flags & AXE_FLAG_772A)
814 else if (sc->sc_flags & AXE_FLAG_772B)
816}
817
818static void
820{
821 struct axe_softc *sc = uether_getsc(ue);
822
823 /*
824 * Load PHY indexes first. Needed by axe_xxx_init().
825 */
826 axe_cmd(sc, AXE_CMD_READ_PHYID, 0, 0, sc->sc_phyaddrs);
827 if (bootverbose)
828 device_printf(sc->sc_ue.ue_dev, "PHYADDR 0x%02x:0x%02x\n",
829 sc->sc_phyaddrs[0], sc->sc_phyaddrs[1]);
831 if (sc->sc_phyno == -1)
833 if (sc->sc_phyno == -1) {
834 device_printf(sc->sc_ue.ue_dev,
835 "no valid PHY address found, assuming PHY address 0\n");
836 sc->sc_phyno = 0;
837 }
838
839 /* Initialize controller and get station address. */
840 if (sc->sc_flags & AXE_FLAG_178) {
843 } else if (sc->sc_flags & AXE_FLAG_772) {
846 } else if (sc->sc_flags & AXE_FLAG_772A) {
849 } else if (sc->sc_flags & AXE_FLAG_772B) {
851 } else
853
854 /*
855 * Fetch IPG values.
856 */
857 if (sc->sc_flags & (AXE_FLAG_772A | AXE_FLAG_772B)) {
858 /* Set IPG values. */
859 sc->sc_ipgs[0] = 0x15;
860 sc->sc_ipgs[1] = 0x16;
861 sc->sc_ipgs[2] = 0x1A;
862 } else
863 axe_cmd(sc, AXE_CMD_READ_IPG012, 0, 0, sc->sc_ipgs);
864}
865
866static int
868{
869 struct axe_softc *sc;
870 struct ifnet *ifp;
871 u_int adv_pause;
872 int error;
873
874 sc = uether_getsc(ue);
875 ifp = ue->ue_ifp;
876 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
877 ifp->if_start = uether_start;
878 ifp->if_ioctl = axe_ioctl;
879 ifp->if_init = uether_init;
880 IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen);
881 ifp->if_snd.ifq_drv_maxlen = ifqmaxlen;
882 IFQ_SET_READY(&ifp->if_snd);
883
884 if (AXE_IS_178_FAMILY(sc))
885 ifp->if_capabilities |= IFCAP_VLAN_MTU;
886 if (sc->sc_flags & AXE_FLAG_772B) {
887 ifp->if_capabilities |= IFCAP_TXCSUM | IFCAP_RXCSUM;
888 ifp->if_hwassist = AXE_CSUM_FEATURES;
889 /*
890 * Checksum offloading of AX88772B also works with VLAN
891 * tagged frames but there is no way to take advantage
892 * of the feature because vlan(4) assumes
893 * IFCAP_VLAN_HWTAGGING is prerequisite condition to
894 * support checksum offloading with VLAN. VLAN hardware
895 * tagging support of AX88772B is very limited so it's
896 * not possible to announce IFCAP_VLAN_HWTAGGING.
897 */
898 }
899 ifp->if_capenable = ifp->if_capabilities;
901 adv_pause = MIIF_DOPAUSE;
902 else
903 adv_pause = 0;
904 bus_topo_lock();
905 error = mii_attach(ue->ue_dev, &ue->ue_miibus, ifp,
907 BMSR_DEFCAPMASK, sc->sc_phyno, MII_OFFSET_ANY, adv_pause);
908 bus_topo_unlock();
909
910 return (error);
911}
912
913/*
914 * Probe for a AX88172 chip.
915 */
916static int
917axe_probe(device_t dev)
918{
919 struct usb_attach_arg *uaa = device_get_ivars(dev);
920
921 if (uaa->usb_mode != USB_MODE_HOST)
922 return (ENXIO);
923 if (uaa->info.bConfigIndex != AXE_CONFIG_IDX)
924 return (ENXIO);
925 if (uaa->info.bIfaceIndex != AXE_IFACE_IDX)
926 return (ENXIO);
927
928 return (usbd_lookup_id_by_uaa(axe_devs, sizeof(axe_devs), uaa));
929}
930
931/*
932 * Attach the interface. Allocate softc structures, do ifmedia
933 * setup and ethernet/BPF attach.
934 */
935static int
936axe_attach(device_t dev)
937{
938 struct usb_attach_arg *uaa = device_get_ivars(dev);
939 struct axe_softc *sc = device_get_softc(dev);
940 struct usb_ether *ue = &sc->sc_ue;
941 uint8_t iface_index;
942 int error;
943
944 sc->sc_flags = USB_GET_DRIVER_INFO(uaa);
945
947
948 mtx_init(&sc->sc_mtx, device_get_nameunit(dev), NULL, MTX_DEF);
949
950 iface_index = AXE_IFACE_IDX;
951 error = usbd_transfer_setup(uaa->device, &iface_index, sc->sc_xfer,
952 axe_config, AXE_N_TRANSFER, sc, &sc->sc_mtx);
953 if (error) {
954 device_printf(dev, "allocating USB transfers failed\n");
955 goto detach;
956 }
957
958 ue->ue_sc = sc;
959 ue->ue_dev = dev;
960 ue->ue_udev = uaa->device;
961 ue->ue_mtx = &sc->sc_mtx;
963
965 if (error) {
966 device_printf(dev, "could not attach interface\n");
967 goto detach;
968 }
969 return (0); /* success */
970
971detach:
973 return (ENXIO); /* failure */
974}
975
976static int
977axe_detach(device_t dev)
978{
979 struct axe_softc *sc = device_get_softc(dev);
980 struct usb_ether *ue = &sc->sc_ue;
981
983 uether_ifdetach(ue);
984 mtx_destroy(&sc->sc_mtx);
985
986 return (0);
987}
988
989#if (AXE_BULK_BUF_SIZE >= 0x10000)
990#error "Please update axe_bulk_read_callback()!"
991#endif
992
993static void
995{
996 struct axe_softc *sc = usbd_xfer_softc(xfer);
997 struct usb_ether *ue = &sc->sc_ue;
998 struct usb_page_cache *pc;
999 int actlen;
1000
1001 usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
1002
1003 switch (USB_GET_STATE(xfer)) {
1004 case USB_ST_TRANSFERRED:
1005 pc = usbd_xfer_get_frame(xfer, 0);
1006 axe_rx_frame(ue, pc, actlen);
1007
1008 /* FALLTHROUGH */
1009 case USB_ST_SETUP:
1010tr_setup:
1013 uether_rxflush(ue);
1014 return;
1015
1016 default: /* Error */
1017 DPRINTF("bulk read error, %s\n", usbd_errstr(error));
1018
1019 if (error != USB_ERR_CANCELLED) {
1020 /* try to clear stall first */
1021 usbd_xfer_set_stall(xfer);
1022 goto tr_setup;
1023 }
1024 return;
1025 }
1026}
1027
1028static int
1029axe_rx_frame(struct usb_ether *ue, struct usb_page_cache *pc, int actlen)
1030{
1031 struct axe_softc *sc;
1032 struct axe_sframe_hdr hdr;
1033 struct axe_csum_hdr csum_hdr;
1034 int error, len, pos;
1035
1036 sc = uether_getsc(ue);
1037 pos = 0;
1038 len = 0;
1039 error = 0;
1040 if ((sc->sc_flags & AXE_FLAG_STD_FRAME) != 0) {
1041 while (pos < actlen) {
1042 if ((int)(pos + sizeof(hdr)) > actlen) {
1043 /* too little data */
1044 error = EINVAL;
1045 break;
1046 }
1047 usbd_copy_out(pc, pos, &hdr, sizeof(hdr));
1048
1049 if ((hdr.len ^ hdr.ilen) != sc->sc_lenmask) {
1050 /* we lost sync */
1051 error = EINVAL;
1052 break;
1053 }
1054 pos += sizeof(hdr);
1055 len = le16toh(hdr.len);
1056 if (pos + len > actlen) {
1057 /* invalid length */
1058 error = EINVAL;
1059 break;
1060 }
1061 axe_rxeof(ue, pc, pos, len, NULL);
1062 pos += len + (len % 2);
1063 }
1064 } else if ((sc->sc_flags & AXE_FLAG_CSUM_FRAME) != 0) {
1065 while (pos < actlen) {
1066 if ((int)(pos + sizeof(csum_hdr)) > actlen) {
1067 /* too little data */
1068 error = EINVAL;
1069 break;
1070 }
1071 usbd_copy_out(pc, pos, &csum_hdr, sizeof(csum_hdr));
1072
1073 csum_hdr.len = le16toh(csum_hdr.len);
1074 csum_hdr.ilen = le16toh(csum_hdr.ilen);
1075 csum_hdr.cstatus = le16toh(csum_hdr.cstatus);
1076 if ((AXE_CSUM_RXBYTES(csum_hdr.len) ^
1077 AXE_CSUM_RXBYTES(csum_hdr.ilen)) !=
1078 sc->sc_lenmask) {
1079 /* we lost sync */
1080 error = EINVAL;
1081 break;
1082 }
1083 /*
1084 * Get total transferred frame length including
1085 * checksum header. The length should be multiple
1086 * of 4.
1087 */
1088 len = sizeof(csum_hdr) + AXE_CSUM_RXBYTES(csum_hdr.len);
1089 len = (len + 3) & ~3;
1090 if (pos + len > actlen) {
1091 /* invalid length */
1092 error = EINVAL;
1093 break;
1094 }
1095 axe_rxeof(ue, pc, pos + sizeof(csum_hdr),
1096 AXE_CSUM_RXBYTES(csum_hdr.len), &csum_hdr);
1097 pos += len;
1098 }
1099 } else
1100 axe_rxeof(ue, pc, 0, actlen, NULL);
1101
1102 if (error != 0)
1103 if_inc_counter(ue->ue_ifp, IFCOUNTER_IERRORS, 1);
1104 return (error);
1105}
1106
1107static int
1108axe_rxeof(struct usb_ether *ue, struct usb_page_cache *pc, unsigned int offset,
1109 unsigned int len, struct axe_csum_hdr *csum_hdr)
1110{
1111 struct ifnet *ifp = ue->ue_ifp;
1112 struct mbuf *m;
1113
1114 if (len < ETHER_HDR_LEN || len > MCLBYTES - ETHER_ALIGN) {
1115 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
1116 return (EINVAL);
1117 }
1118
1119 m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
1120 if (m == NULL) {
1121 if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1);
1122 return (ENOMEM);
1123 }
1124 m->m_len = m->m_pkthdr.len = MCLBYTES;
1125 m_adj(m, ETHER_ALIGN);
1126
1127 usbd_copy_out(pc, offset, mtod(m, uint8_t *), len);
1128
1129 if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
1130 m->m_pkthdr.rcvif = ifp;
1131 m->m_pkthdr.len = m->m_len = len;
1132
1133 if (csum_hdr != NULL && csum_hdr->cstatus & AXE_CSUM_HDR_L3_TYPE_IPV4) {
1134 if ((csum_hdr->cstatus & (AXE_CSUM_HDR_L4_CSUM_ERR |
1135 AXE_CSUM_HDR_L3_CSUM_ERR)) == 0) {
1136 m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED |
1137 CSUM_IP_VALID;
1138 if ((csum_hdr->cstatus & AXE_CSUM_HDR_L4_TYPE_MASK) ==
1140 (csum_hdr->cstatus & AXE_CSUM_HDR_L4_TYPE_MASK) ==
1142 m->m_pkthdr.csum_flags |=
1143 CSUM_DATA_VALID | CSUM_PSEUDO_HDR;
1144 m->m_pkthdr.csum_data = 0xffff;
1145 }
1146 }
1147 }
1148
1149 (void)mbufq_enqueue(&ue->ue_rxq, m);
1150 return (0);
1151}
1152
1153#if ((AXE_BULK_BUF_SIZE >= 0x10000) || (AXE_BULK_BUF_SIZE < (MCLBYTES+4)))
1154#error "Please update axe_bulk_write_callback()!"
1155#endif
1156
1157static void
1159{
1160 struct axe_softc *sc = usbd_xfer_softc(xfer);
1161 struct axe_sframe_hdr hdr;
1162 struct ifnet *ifp = uether_getifp(&sc->sc_ue);
1163 struct usb_page_cache *pc;
1164 struct mbuf *m;
1165 int nframes, pos;
1166
1167 switch (USB_GET_STATE(xfer)) {
1168 case USB_ST_TRANSFERRED:
1169 DPRINTFN(11, "transfer complete\n");
1170 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
1171 /* FALLTHROUGH */
1172 case USB_ST_SETUP:
1173tr_setup:
1174 if ((sc->sc_flags & AXE_FLAG_LINK) == 0 ||
1175 (ifp->if_drv_flags & IFF_DRV_OACTIVE) != 0) {
1176 /*
1177 * Don't send anything if there is no link or
1178 * controller is busy.
1179 */
1180 return;
1181 }
1182
1183 for (nframes = 0; nframes < 16 &&
1184 !IFQ_DRV_IS_EMPTY(&ifp->if_snd); nframes++) {
1185 IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
1186 if (m == NULL)
1187 break;
1188 usbd_xfer_set_frame_offset(xfer, nframes * MCLBYTES,
1189 nframes);
1190 pos = 0;
1191 pc = usbd_xfer_get_frame(xfer, nframes);
1192 if (AXE_IS_178_FAMILY(sc)) {
1193 hdr.len = htole16(m->m_pkthdr.len);
1194 hdr.ilen = ~hdr.len;
1195 /*
1196 * If upper stack computed checksum, driver
1197 * should tell controller not to insert
1198 * computed checksum for checksum offloading
1199 * enabled controller.
1200 */
1201 if (ifp->if_capabilities & IFCAP_TXCSUM) {
1202 if ((m->m_pkthdr.csum_flags &
1203 AXE_CSUM_FEATURES) != 0)
1204 hdr.len |= htole16(
1206 else
1207 hdr.len |= htole16(
1209 }
1210 usbd_copy_in(pc, pos, &hdr, sizeof(hdr));
1211 pos += sizeof(hdr);
1212 usbd_m_copy_in(pc, pos, m, 0, m->m_pkthdr.len);
1213 pos += m->m_pkthdr.len;
1214 if ((pos % 512) == 0) {
1215 hdr.len = 0;
1216 hdr.ilen = 0xffff;
1217 usbd_copy_in(pc, pos, &hdr,
1218 sizeof(hdr));
1219 pos += sizeof(hdr);
1220 }
1221 } else {
1222 usbd_m_copy_in(pc, pos, m, 0, m->m_pkthdr.len);
1223 pos += m->m_pkthdr.len;
1224 }
1225
1226 /*
1227 * XXX
1228 * Update TX packet counter here. This is not
1229 * correct way but it seems that there is no way
1230 * to know how many packets are sent at the end
1231 * of transfer because controller combines
1232 * multiple writes into single one if there is
1233 * room in TX buffer of controller.
1234 */
1235 if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
1236
1237 /*
1238 * if there's a BPF listener, bounce a copy
1239 * of this frame to him:
1240 */
1241 BPF_MTAP(ifp, m);
1242
1243 m_freem(m);
1244
1245 /* Set frame length. */
1246 usbd_xfer_set_frame_len(xfer, nframes, pos);
1247 }
1248 if (nframes != 0) {
1249 usbd_xfer_set_frames(xfer, nframes);
1251 ifp->if_drv_flags |= IFF_DRV_OACTIVE;
1252 }
1253 return;
1254 /* NOTREACHED */
1255 default: /* Error */
1256 DPRINTFN(11, "transfer error, %s\n",
1258
1259 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
1260 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
1261
1262 if (error != USB_ERR_CANCELLED) {
1263 /* try to clear stall first */
1264 usbd_xfer_set_stall(xfer);
1265 goto tr_setup;
1266 }
1267 return;
1268 }
1269}
1270
1271static void
1273{
1274 struct axe_softc *sc = uether_getsc(ue);
1275 struct mii_data *mii = GET_MII(sc);
1276
1277 AXE_LOCK_ASSERT(sc, MA_OWNED);
1278
1279 mii_tick(mii);
1280 if ((sc->sc_flags & AXE_FLAG_LINK) == 0) {
1282 if ((sc->sc_flags & AXE_FLAG_LINK) != 0)
1283 axe_start(ue);
1284 }
1285}
1286
1287static void
1289{
1290 struct axe_softc *sc = uether_getsc(ue);
1291
1292 /*
1293 * start the USB transfers, if not already started:
1294 */
1297}
1298
1299static void
1301{
1302 struct axe_softc *sc;
1303 struct ifnet *ifp;
1304 uint16_t csum1, csum2;
1305
1306 sc = uether_getsc(ue);
1307 AXE_LOCK_ASSERT(sc, MA_OWNED);
1308
1309 if ((sc->sc_flags & AXE_FLAG_772B) != 0) {
1310 ifp = uether_getifp(ue);
1311 csum1 = 0;
1312 csum2 = 0;
1313 if ((ifp->if_capenable & IFCAP_TXCSUM) != 0)
1314 csum1 |= AXE_TXCSUM_IP | AXE_TXCSUM_TCP |
1316 axe_cmd(sc, AXE_772B_CMD_WRITE_TXCSUM, csum2, csum1, NULL);
1317 csum1 = 0;
1318 csum2 = 0;
1319 if ((ifp->if_capenable & IFCAP_RXCSUM) != 0)
1320 csum1 |= AXE_RXCSUM_IP | AXE_RXCSUM_IPVE |
1323 axe_cmd(sc, AXE_772B_CMD_WRITE_RXCSUM, csum2, csum1, NULL);
1324 }
1325}
1326
1327static void
1329{
1330 struct axe_softc *sc = uether_getsc(ue);
1331 struct ifnet *ifp = uether_getifp(ue);
1332 uint16_t rxmode;
1333
1334 AXE_LOCK_ASSERT(sc, MA_OWNED);
1335
1336 if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0)
1337 return;
1338
1339 /* Cancel pending I/O */
1340 axe_stop(ue);
1341
1342 axe_reset(sc);
1343
1344 /* Set MAC address and transmitter IPG values. */
1345 if (AXE_IS_178_FAMILY(sc)) {
1346 axe_cmd(sc, AXE_178_CMD_WRITE_NODEID, 0, 0, IF_LLADDR(ifp));
1348 (sc->sc_ipgs[1] << 8) | (sc->sc_ipgs[0]), NULL);
1349 } else {
1350 axe_cmd(sc, AXE_172_CMD_WRITE_NODEID, 0, 0, IF_LLADDR(ifp));
1351 axe_cmd(sc, AXE_172_CMD_WRITE_IPG0, 0, sc->sc_ipgs[0], NULL);
1352 axe_cmd(sc, AXE_172_CMD_WRITE_IPG1, 0, sc->sc_ipgs[1], NULL);
1353 axe_cmd(sc, AXE_172_CMD_WRITE_IPG2, 0, sc->sc_ipgs[2], NULL);
1354 }
1355
1356 if (AXE_IS_178_FAMILY(sc)) {
1358 if ((sc->sc_flags & AXE_FLAG_772B) != 0 &&
1359 (ifp->if_capenable & IFCAP_RXCSUM) != 0) {
1362 } else {
1365 }
1366 }
1367
1368 /* Configure TX/RX checksum offloading. */
1369 axe_csum_cfg(ue);
1370
1371 if (sc->sc_flags & AXE_FLAG_772B) {
1372 /* AX88772B uses different maximum frame burst configuration. */
1375 ax88772b_mfb_table[AX88772B_MFB_16K].byte_cnt, NULL);
1376 }
1377
1378 /* Enable receiver, set RX mode. */
1380 if (AXE_IS_178_FAMILY(sc)) {
1381 if (sc->sc_flags & AXE_FLAG_772B) {
1382 /*
1383 * Select RX header format type 1. Aligning IP
1384 * header on 4 byte boundary is not needed when
1385 * checksum offloading feature is not used
1386 * because we always copy the received frame in
1387 * RX handler. When RX checksum offloading is
1388 * active, aligning IP header is required to
1389 * reflect actual frame length including RX
1390 * header size.
1391 */
1392 rxmode |= AXE_772B_RXCMD_HDR_TYPE_1;
1393 if ((ifp->if_capenable & IFCAP_RXCSUM) != 0)
1395 } else {
1396 /*
1397 * Default Rx buffer size is too small to get
1398 * maximum performance.
1399 */
1400 rxmode |= AXE_178_RXCMD_MFB_16384;
1401 }
1402 } else {
1403 rxmode |= AXE_172_RXCMD_UNICAST;
1404 }
1405
1406 /* If we want promiscuous mode, set the allframes bit. */
1407 if (ifp->if_flags & IFF_PROMISC)
1408 rxmode |= AXE_RXCMD_PROMISC;
1409
1410 if (ifp->if_flags & IFF_BROADCAST)
1411 rxmode |= AXE_RXCMD_BROADCAST;
1412
1413 axe_cmd(sc, AXE_CMD_RXCTL_WRITE, 0, rxmode, NULL);
1414
1415 /* Load the multicast filter. */
1416 axe_setmulti(ue);
1417
1419
1420 ifp->if_drv_flags |= IFF_DRV_RUNNING;
1421 /* Switch to selected media. */
1422 axe_ifmedia_upd(ifp);
1423}
1424
1425static void
1427{
1428 struct axe_softc *sc = uether_getsc(ue);
1429 struct ifnet *ifp = uether_getifp(ue);
1430 uint16_t rxmode;
1431
1432 axe_cmd(sc, AXE_CMD_RXCTL_READ, 0, 0, &rxmode);
1433
1434 rxmode = le16toh(rxmode);
1435
1436 if (ifp->if_flags & IFF_PROMISC) {
1437 rxmode |= AXE_RXCMD_PROMISC;
1438 } else {
1439 rxmode &= ~AXE_RXCMD_PROMISC;
1440 }
1441
1442 axe_cmd(sc, AXE_CMD_RXCTL_WRITE, 0, rxmode, NULL);
1443
1444 axe_setmulti(ue);
1445}
1446
1447static void
1449{
1450 struct axe_softc *sc = uether_getsc(ue);
1451 struct ifnet *ifp = uether_getifp(ue);
1452
1453 AXE_LOCK_ASSERT(sc, MA_OWNED);
1454
1455 ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
1456 sc->sc_flags &= ~AXE_FLAG_LINK;
1457
1458 /*
1459 * stop all the transfers, if not already stopped:
1460 */
1463}
1464
1465static int
1466axe_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
1467{
1468 struct usb_ether *ue = ifp->if_softc;
1469 struct axe_softc *sc;
1470 struct ifreq *ifr;
1471 int error, mask, reinit;
1472
1473 sc = uether_getsc(ue);
1474 ifr = (struct ifreq *)data;
1475 error = 0;
1476 reinit = 0;
1477 if (cmd == SIOCSIFCAP) {
1478 AXE_LOCK(sc);
1479 mask = ifr->ifr_reqcap ^ ifp->if_capenable;
1480 if ((mask & IFCAP_TXCSUM) != 0 &&
1481 (ifp->if_capabilities & IFCAP_TXCSUM) != 0) {
1482 ifp->if_capenable ^= IFCAP_TXCSUM;
1483 if ((ifp->if_capenable & IFCAP_TXCSUM) != 0)
1484 ifp->if_hwassist |= AXE_CSUM_FEATURES;
1485 else
1486 ifp->if_hwassist &= ~AXE_CSUM_FEATURES;
1487 reinit++;
1488 }
1489 if ((mask & IFCAP_RXCSUM) != 0 &&
1490 (ifp->if_capabilities & IFCAP_RXCSUM) != 0) {
1491 ifp->if_capenable ^= IFCAP_RXCSUM;
1492 reinit++;
1493 }
1494 if (reinit > 0 && ifp->if_drv_flags & IFF_DRV_RUNNING)
1495 ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
1496 else
1497 reinit = 0;
1498 AXE_UNLOCK(sc);
1499 if (reinit > 0)
1500 uether_init(ue);
1501 } else
1502 error = uether_ioctl(ifp, cmd, data);
1503
1504 return (error);
1505}
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
#define GET_MII(sc)
Definition: if_auereg.h:188
static uether_fn_t axe_attach_post
Definition: if_axe.c:199
static int axe_get_phyno(struct axe_softc *, int)
Definition: if_axe.c:523
MODULE_VERSION(axe, 1)
static void axe_ax88772a_init(struct axe_softc *)
Definition: if_axe.c:740
static miibus_statchg_t axe_miibus_statchg
Definition: if_axe.c:197
static u_int axe_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
Definition: if_axe.c:485
static int axe_cmd(struct axe_softc *, int, int, int, void *)
Definition: if_axe.c:302
static device_probe_t axe_probe
Definition: if_axe.c:188
static const STRUCT_USB_HOST_ID axe_devs[]
Definition: if_axe.c:150
static uether_fn_t axe_stop
Definition: if_axe.c:201
static uether_fn_t axe_start
Definition: if_axe.c:202
static int axe_rx_frame(struct usb_ether *, struct usb_page_cache *, int)
Definition: if_axe.c:1029
static void axe_ax88772_init(struct axe_softc *)
Definition: if_axe.c:669
static usb_callback_t axe_bulk_read_callback
Definition: if_axe.c:192
static usb_callback_t axe_bulk_write_callback
Definition: if_axe.c:193
static void axe_ax88772b_init(struct axe_softc *)
Definition: if_axe.c:753
#define AXE_CSUM_FEATURES
Definition: if_axe.c:136
static const struct usb_ether_methods axe_ue_methods
Definition: if_axe.c:288
static int axe_attach_post_sub(struct usb_ether *)
Definition: if_axe.c:867
DRIVER_MODULE(axe, uhub, axe_driver, axe_devclass, NULL, 0)
static void axe_ax88772_phywake(struct axe_softc *)
Definition: if_axe.c:710
MODULE_DEPEND(axe, uether, 1, 1, 1)
static device_method_t axe_methods[]
Definition: if_axe.c:257
__FBSDID("$FreeBSD$")
static void axe_reset(struct axe_softc *sc)
Definition: if_axe.c:792
static int axe_ioctl(struct ifnet *, u_long, caddr_t)
Definition: if_axe.c:1466
static void axe_ax88178_init(struct axe_softc *)
Definition: if_axe.c:552
static devclass_t axe_devclass
Definition: if_axe.c:277
static int axe_rxeof(struct usb_ether *, struct usb_page_cache *, unsigned int offset, unsigned int, struct axe_csum_hdr *)
Definition: if_axe.c:1108
static device_detach_t axe_detach
Definition: if_axe.c:190
static void axe_ifmedia_sts(struct ifnet *, struct ifmediareq *)
Definition: if_axe.c:472
static const struct usb_config axe_config[AXE_N_TRANSFER]
Definition: if_axe.c:223
static const struct ax88772b_mfb ax88772b_mfb_table[]
Definition: if_axe.c:246
static uether_fn_t axe_setpromisc
Definition: if_axe.c:205
static uether_fn_t axe_tick
Definition: if_axe.c:203
static miibus_readreg_t axe_miibus_readreg
Definition: if_axe.c:195
#define AXE_GPIO_WRITE(x, y)
Definition: if_axe.c:546
static driver_t axe_driver
Definition: if_axe.c:271
static device_attach_t axe_attach
Definition: if_axe.c:189
static uether_fn_t axe_init
Definition: if_axe.c:200
static uether_fn_t axe_setmulti
Definition: if_axe.c:204
static int axe_ifmedia_upd(struct ifnet *)
Definition: if_axe.c:453
static void axe_csum_cfg(struct usb_ether *)
Definition: if_axe.c:1300
USB_PNP_HOST_INFO(axe_devs)
static miibus_writereg_t axe_miibus_writereg
Definition: if_axe.c:196
#define AXE_DEV(v, p, i)
#define AXE_178_CMD_WRITE_NODEID
Definition: if_axereg.h:78
#define AXE_772B_CMD_WRITE_RXCSUM
Definition: if_axereg.h:103
#define AXE_CSUM_HDR_L4_CSUM_ERR
Definition: if_axereg.h:301
#define AXE_PHY_MODE_REALTEK_8211CL
Definition: if_axereg.h:188
#define AXE_SW_RESET_PRL
Definition: if_axereg.h:111
#define AXE_178_MEDIA_RX_EN
Definition: if_axereg.h:132
#define AXE_CSUM_HDR_L3_TYPE_IPV4
Definition: if_axereg.h:309
#define PHY_TYPE_SPECIAL
Definition: if_axereg.h:165
#define AXE_RXCSUM_IPVE
Definition: if_axereg.h:209
#define AXE_IFACE_IDX
Definition: if_axereg.h:248
#define AXE_SW_PHY_SELECT_EXT
Definition: if_axereg.h:194
#define AXE_CMD_MII_READ_REG
Definition: if_axereg.h:62
#define AXE_CMD_LEN(x)
Definition: if_axereg.h:53
#define AXE_178_MEDIA_GMII
Definition: if_axereg.h:119
#define AXE_FLAG_LINK
Definition: if_axereg.h:342
#define AXE_178_MEDIA_TXFLOW_CONTROL_EN
Definition: if_axereg.h:129
#define AXE_CMD_RXCTL_WRITE
Definition: if_axereg.h:71
#define AXE_CMD_MII_OPMODE_SW
Definition: if_axereg.h:61
#define AXE_TX_CSUM_PSEUDO_HDR
Definition: if_axereg.h:274
#define AXE_SW_RESET_IPRL
Definition: if_axereg.h:113
#define AXE_HDR_LEN_MASK
Definition: if_axereg.h:270
#define AXE_172_CMD_WRITE_IPG2
Definition: if_axereg.h:77
#define AXE_PHY_MODE_REALTEK_8251CL
Definition: if_axereg.h:190
#define AXE_PHY_MODE_CICADA_V2
Definition: if_axereg.h:185
#define AXE_EEPROM_772B_NODE_ID
Definition: if_axereg.h:251
#define AXE_PHY_MODE_CICADA_V2_ASIX
Definition: if_axereg.h:187
#define AXE_LOCK_ASSERT(_sc, t)
Definition: if_axereg.h:365
#define AXE_CMD_SROM_READ
Definition: if_axereg.h:66
#define AXE_CMD_SW_RESET_REG
Definition: if_axereg.h:93
#define AXE_RXCSUM_UDP
Definition: if_axereg.h:212
#define AXE_CSUM_HDR_L4_TYPE_UDP
Definition: if_axereg.h:303
#define AXE_TXCSUM_UDP
Definition: if_axereg.h:229
#define AXE_GPIO0
Definition: if_axereg.h:175
#define AXE_CMD_READ_PHYID
Definition: if_axereg.h:84
#define AXE_CMD_MII_WRITE_REG
Definition: if_axereg.h:63
#define AXE_172_CMD_WRITE_IPG1
Definition: if_axereg.h:75
#define AXE_772B_RXCMD_HDR_TYPE_1
Definition: if_axereg.h:151
#define AXE_GPIO0_EN
Definition: if_axereg.h:174
#define AXE_PHY_SEL_SEC
Definition: if_axereg.h:157
#define AXE_178_MEDIA_100TX
Definition: if_axereg.h:133
#define AXE_SW_RESET_IPPD
Definition: if_axereg.h:114
#define AXE_772B_CMD_WRITE_TXCSUM
Definition: if_axereg.h:105
#define AXE_178_RXCMD_MFB_16384
Definition: if_axereg.h:149
#define AXE_LOCK(_sc)
Definition: if_axereg.h:363
#define AXE_CMD_READ_IPG012
Definition: if_axereg.h:72
#define AXE_FLAG_772
Definition: if_axereg.h:345
#define AXE_RXCMD_ALLMULTI
Definition: if_axereg.h:138
#define AXE_172_CMD_WRITE_IPG0
Definition: if_axereg.h:73
#define AXE_CMD_SW_PHY_SELECT
Definition: if_axereg.h:95
#define AXE_GPIO1
Definition: if_axereg.h:177
#define AXE_FLAG_178
Definition: if_axereg.h:348
#define AXE_TXCSUM_IP
Definition: if_axereg.h:227
#define AXE_178_MEDIA_RXFLOW_CONTROL_EN
Definition: if_axereg.h:128
#define AXE_SW_PHY_SELECT_SS_ENB
Definition: if_axereg.h:200
#define AXE_CMD_WRITE_MCAST
Definition: if_axereg.h:80
#define AXE_PHY_MODE_CICADA
Definition: if_axereg.h:183
#define PHY_TYPE_NON_SUP
Definition: if_axereg.h:167
#define AXE_CSUM_HDR_L4_TYPE_TCP
Definition: if_axereg.h:306
#define AXE_RXCMD_MULTICAST
Definition: if_axereg.h:142
#define AXE_SW_PHY_SELECT_SS_MII
Definition: if_axereg.h:197
@ AXE_N_TRANSFER
Definition: if_axereg.h:332
@ AXE_BULK_DT_WR
Definition: if_axereg.h:330
@ AXE_BULK_DT_RD
Definition: if_axereg.h:331
#define AXE_FLAG_CSUM_FRAME
Definition: if_axereg.h:344
#define AXE_EEPROM_772B_PHY_PWRCFG
Definition: if_axereg.h:252
#define AXE_772_PHY_NO_EPHY
Definition: if_axereg.h:172
#define AXE_FLAG_772A
Definition: if_axereg.h:346
#define AXE_SW_RESET_CLEAR
Definition: if_axereg.h:107
#define AXE_178_CMD_READ_NODEID
Definition: if_axereg.h:76
#define AXE_CMD_WRITE_MEDIA
Definition: if_axereg.h:87
#define AXE_FLAG_772B
Definition: if_axereg.h:347
#define AXE_772B_CMD_RXCTL_WRITE_CFG
Definition: if_axereg.h:101
#define AXE_GPIO_RELOAD_EEPROM
Definition: if_axereg.h:180
#define AXE_CSUM_HDR_L4_TYPE_MASK
Definition: if_axereg.h:308
#define AXE_178_MEDIA_ENCK
Definition: if_axereg.h:126
#define AXE_178_RESET_MAGIC
Definition: if_axereg.h:117
#define PHY_TYPE_GIG
Definition: if_axereg.h:164
#define AXE_RXCMD_PROMISC
Definition: if_axereg.h:137
#define AXE_RXCSUM_IGMP
Definition: if_axereg.h:214
#define AXE_CSUM_HDR_LEN_MASK
Definition: if_axereg.h:291
#define AXE_PHY_NO(x)
Definition: if_axereg.h:170
#define PHY_TYPE_RSVD
Definition: if_axereg.h:166
#define AXE_PHY_MODE_REALTEK_8211BN
Definition: if_axereg.h:189
#define AX88772B_MFB_16K
Definition: if_axereg.h:263
#define AXE_CSUM_RXBYTES(x)
Definition: if_axereg.h:324
#define AXE_FLAG_STD_FRAME
Definition: if_axereg.h:343
#define AXE_RXCSUM_IP
Definition: if_axereg.h:208
#define AXE_CMD_MII_OPMODE_HW
Definition: if_axereg.h:65
#define AXE_IS_772(sc)
Definition: if_axereg.h:360
#define AXE_178_CMD_WRITE_IPG012
Definition: if_axereg.h:74
#define AXE_172_CMD_READ_NODEID
Definition: if_axereg.h:81
#define AXE_CMD_SROM_WR_DISABLE
Definition: if_axereg.h:69
#define AXE_CSUM_HDR_L3_CSUM_ERR
Definition: if_axereg.h:302
#define AXE_IS_178_FAMILY(sc)
Definition: if_axereg.h:356
#define AXE_178_MEDIA_MAGIC
Definition: if_axereg.h:124
#define AXE_CMD_WRITE_GPIO
Definition: if_axereg.h:91
#define AXE_RXCMD_BROADCAST
Definition: if_axereg.h:141
#define AXE_TX_CSUM_DIS
Definition: if_axereg.h:275
#define AXE_CMD_RXCTL_READ
Definition: if_axereg.h:70
#define AXE_TXCSUM_TCP
Definition: if_axereg.h:228
#define AXE_GPIO2_EN
Definition: if_axereg.h:178
#define AXE_172_CMD_WRITE_NODEID
Definition: if_axereg.h:82
#define AXE_PHY_SEL_PRI
Definition: if_axereg.h:156
#define AXE_MEDIA_FULL_DUPLEX
Definition: if_axereg.h:120
#define PHY_TYPE_100_HOME
Definition: if_axereg.h:163
#define AXE_CMD_SROM_WR_ENABLE
Definition: if_axereg.h:68
#define AXE_PHY_MODE_AGERE
Definition: if_axereg.h:184
#define AXE_RXCMD_ENABLE
Definition: if_axereg.h:144
#define AXE_PHY_MODE_MARVELL
Definition: if_axereg.h:182
#define AXE_GPIO1_EN
Definition: if_axereg.h:176
#define AXE_CONFIG_IDX
Definition: if_axereg.h:247
#define AXE_RXCSUM_ICMP
Definition: if_axereg.h:213
#define AXE_772B_RXCMD_IPHDR_ALIGN
Definition: if_axereg.h:152
#define AXE_SW_PHY_SELECT_EMBEDDED
Definition: if_axereg.h:195
#define AXE_CMD_CMD(x)
Definition: if_axereg.h:54
#define AXE_PHY_TYPE(x)
Definition: if_axereg.h:160
#define AXE_GPIO2
Definition: if_axereg.h:179
#define AXE_RXCSUM_TCP
Definition: if_axereg.h:211
#define AXE_172_RXCMD_UNICAST
Definition: if_axereg.h:139
#define AXE_CMD_IS_WRITE(x)
Definition: if_axereg.h:52
#define AXE_UNLOCK(_sc)
Definition: if_axereg.h:364
uint32_t reg
Definition: if_rum.c:283
uint32_t val
Definition: if_rum.c:284
struct @109 error
uint16_t data
u_int index
device_t dev
uint16_t len
Definition: if_axereg.h:290
uint16_t cstatus
Definition: if_axereg.h:297
uint16_t ilen
Definition: if_axereg.h:296
uint16_t ilen
Definition: if_axereg.h:271
uint16_t len
Definition: if_axereg.h:269
int sc_phyno
Definition: if_axereg.h:339
int sc_flags
Definition: if_axereg.h:341
struct mtx sc_mtx
Definition: if_axereg.h:337
struct usb_ether sc_ue
Definition: if_axereg.h:336
uint8_t sc_phyaddrs[2]
Definition: if_axereg.h:351
uint8_t sc_ipgs[3]
Definition: if_axereg.h:350
struct usb_xfer * sc_xfer[AXE_N_TRANSFER]
Definition: if_axereg.h:338
uint16_t sc_pwrcfg
Definition: if_axereg.h:352
uint16_t sc_lenmask
Definition: if_axereg.h:353
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
uByte bConfigurationValue
Definition: usb.h:390
uint8_t type
Definition: usbdi.h:238
void(* ue_mii_sts)(struct ifnet *, struct ifmediareq *)
Definition: usb_ethernet.h:66
uether_fn_t * ue_attach_post
Definition: usb_ethernet.h:58
const struct usb_ether_methods * ue_methods
Definition: usb_ethernet.h:81
struct ifnet * ue_ifp
Definition: usb_ethernet.h:79
struct usb_device * ue_udev
Definition: usb_ethernet.h:84
struct mbufq ue_rxq
Definition: usb_ethernet.h:90
device_t ue_miibus
Definition: usb_ethernet.h:86
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 bIfaceIndex
Definition: usbdi.h:417
uint8_t bConfigIndex
Definition: usbdi.h:419
#define DPRINTF(...)
Definition: umass.c:179
#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
struct usb_config_descriptor * usbd_get_config_descriptor(struct usb_device *udev)
Definition: usb_device.c:2616
#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
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_ifmedia_upd(struct ifnet *ifp)
Definition: usb_ethernet.c:450
void uether_init(void *arg)
Definition: usb_ethernet.c:358
int uether_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
Definition: usb_ethernet.c:513
int uether_ifattach(struct usb_ether *ue)
Definition: usb_ethernet.c:164
void uether_start(struct ifnet *ifp)
Definition: usb_ethernet.c:410
#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
usb_error_t usbd_req_set_config(struct usb_device *udev, struct mtx *mtx, uint8_t conf)
Definition: usb_request.c:1920
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_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_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)
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