FreeBSD kernel usb device Code
if_cue.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 * 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 * CATC USB-EL1210A USB to ethernet driver. Used in the CATC Netmate
40 * adapters and others.
41 *
42 * Written by Bill Paul <wpaul@ee.columbia.edu>
43 * Electrical Engineering Department
44 * Columbia University, New York City
45 */
46
47/*
48 * The CATC USB-EL1210A provides USB ethernet support at 10Mbps. The
49 * RX filter uses a 512-bit multicast hash table, single perfect entry
50 * for the station address, and promiscuous mode. Unlike the ADMtek
51 * and KLSI chips, the CATC ASIC supports read and write combining
52 * mode where multiple packets can be transferred using a single bulk
53 * transaction, which helps performance a great deal.
54 */
55
56#include <sys/stdint.h>
57#include <sys/stddef.h>
58#include <sys/param.h>
59#include <sys/queue.h>
60#include <sys/types.h>
61#include <sys/systm.h>
62#include <sys/socket.h>
63#include <sys/kernel.h>
64#include <sys/bus.h>
65#include <sys/module.h>
66#include <sys/lock.h>
67#include <sys/mutex.h>
68#include <sys/condvar.h>
69#include <sys/sysctl.h>
70#include <sys/sx.h>
71#include <sys/unistd.h>
72#include <sys/callout.h>
73#include <sys/malloc.h>
74#include <sys/priv.h>
75
76#include <net/if.h>
77#include <net/if_var.h>
78
79#include <dev/usb/usb.h>
80#include <dev/usb/usbdi.h>
81#include <dev/usb/usbdi_util.h>
82#include "usbdevs.h"
83
84#define USB_DEBUG_VAR cue_debug
85#include <dev/usb/usb_debug.h>
86#include <dev/usb/usb_process.h>
87
90
91/*
92 * Various supported device vendors/products.
93 */
94
95/* Belkin F5U111 adapter covered by NETMATE entry */
96
97static const STRUCT_USB_HOST_ID cue_devs[] = {
98#define CUE_DEV(v,p) { USB_VP(USB_VENDOR_##v, USB_PRODUCT_##v##_##p) }
99 CUE_DEV(CATC, NETMATE),
100 CUE_DEV(CATC, NETMATE2),
101 CUE_DEV(SMARTBRIDGES, SMARTLINK),
102#undef CUE_DEV
103};
104
105/* prototypes */
106
107static device_probe_t cue_probe;
108static device_attach_t cue_attach;
109static device_detach_t cue_detach;
110
113
121
122static uint8_t cue_csr_read_1(struct cue_softc *, uint16_t);
123static uint16_t cue_csr_read_2(struct cue_softc *, uint8_t);
124static int cue_csr_write_1(struct cue_softc *, uint16_t, uint16_t);
125static int cue_mem(struct cue_softc *, uint8_t, uint16_t, void *, int);
126static int cue_getmac(struct cue_softc *, void *);
127static uint32_t cue_mchash(const uint8_t *);
128static void cue_reset(struct cue_softc *);
129
130#ifdef USB_DEBUG
131static int cue_debug = 0;
132
133static SYSCTL_NODE(_hw_usb, OID_AUTO, cue, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
134 "USB cue");
135SYSCTL_INT(_hw_usb_cue, OID_AUTO, debug, CTLFLAG_RWTUN, &cue_debug, 0,
136 "Debug level");
137#endif
138
139static const struct usb_config cue_config[CUE_N_TRANSFER] = {
140 [CUE_BULK_DT_WR] = {
141 .type = UE_BULK,
142 .endpoint = UE_ADDR_ANY,
143 .direction = UE_DIR_OUT,
144 .bufsize = (MCLBYTES + 2),
145 .flags = {.pipe_bof = 1,},
146 .callback = cue_bulk_write_callback,
147 .timeout = 10000, /* 10 seconds */
148 },
149
150 [CUE_BULK_DT_RD] = {
151 .type = UE_BULK,
152 .endpoint = UE_ADDR_ANY,
153 .direction = UE_DIR_IN,
154 .bufsize = (MCLBYTES + 2),
155 .flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
156 .callback = cue_bulk_read_callback,
157 },
158};
159
160static device_method_t cue_methods[] = {
161 /* Device interface */
162 DEVMETHOD(device_probe, cue_probe),
163 DEVMETHOD(device_attach, cue_attach),
164 DEVMETHOD(device_detach, cue_detach),
165
166 DEVMETHOD_END
167};
168
169static driver_t cue_driver = {
170 .name = "cue",
171 .methods = cue_methods,
172 .size = sizeof(struct cue_softc),
173};
174
175static devclass_t cue_devclass;
176
178MODULE_DEPEND(cue, uether, 1, 1, 1);
179MODULE_DEPEND(cue, usb, 1, 1, 1);
180MODULE_DEPEND(cue, ether, 1, 1, 1);
183
184static const struct usb_ether_methods cue_ue_methods = {
186 .ue_start = cue_start,
187 .ue_init = cue_init,
188 .ue_stop = cue_stop,
189 .ue_tick = cue_tick,
190 .ue_setmulti = cue_setmulti,
191 .ue_setpromisc = cue_setpromisc,
192};
193
194#define CUE_SETBIT(sc, reg, x) \
195 cue_csr_write_1(sc, reg, cue_csr_read_1(sc, reg) | (x))
196
197#define CUE_CLRBIT(sc, reg, x) \
198 cue_csr_write_1(sc, reg, cue_csr_read_1(sc, reg) & ~(x))
199
200static uint8_t
201cue_csr_read_1(struct cue_softc *sc, uint16_t reg)
202{
203 struct usb_device_request req;
204 uint8_t val;
205
206 req.bmRequestType = UT_READ_VENDOR_DEVICE;
207 req.bRequest = CUE_CMD_READREG;
208 USETW(req.wValue, 0);
209 USETW(req.wIndex, reg);
210 USETW(req.wLength, 1);
211
212 if (uether_do_request(&sc->sc_ue, &req, &val, 1000)) {
213 /* ignore any errors */
214 }
215 return (val);
216}
217
218static uint16_t
219cue_csr_read_2(struct cue_softc *sc, uint8_t reg)
220{
221 struct usb_device_request req;
222 uint16_t val;
223
224 req.bmRequestType = UT_READ_VENDOR_DEVICE;
225 req.bRequest = CUE_CMD_READREG;
226 USETW(req.wValue, 0);
227 USETW(req.wIndex, reg);
228 USETW(req.wLength, 2);
229
230 (void)uether_do_request(&sc->sc_ue, &req, &val, 1000);
231 return (le16toh(val));
232}
233
234static int
235cue_csr_write_1(struct cue_softc *sc, uint16_t reg, uint16_t val)
236{
237 struct usb_device_request req;
238
239 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
240 req.bRequest = CUE_CMD_WRITEREG;
241 USETW(req.wValue, val);
242 USETW(req.wIndex, reg);
243 USETW(req.wLength, 0);
244
245 return (uether_do_request(&sc->sc_ue, &req, NULL, 1000));
246}
247
248static int
249cue_mem(struct cue_softc *sc, uint8_t cmd, uint16_t addr, void *buf, int len)
250{
251 struct usb_device_request req;
252
253 if (cmd == CUE_CMD_READSRAM)
254 req.bmRequestType = UT_READ_VENDOR_DEVICE;
255 else
256 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
257 req.bRequest = cmd;
258 USETW(req.wValue, 0);
259 USETW(req.wIndex, addr);
260 USETW(req.wLength, len);
261
262 return (uether_do_request(&sc->sc_ue, &req, buf, 1000));
263}
264
265static int
266cue_getmac(struct cue_softc *sc, void *buf)
267{
268 struct usb_device_request req;
269
270 req.bmRequestType = UT_READ_VENDOR_DEVICE;
271 req.bRequest = CUE_CMD_GET_MACADDR;
272 USETW(req.wValue, 0);
273 USETW(req.wIndex, 0);
274 USETW(req.wLength, ETHER_ADDR_LEN);
275
276 return (uether_do_request(&sc->sc_ue, &req, buf, 1000));
277}
278
279#define CUE_BITS 9
280
281static uint32_t
282cue_mchash(const uint8_t *addr)
283{
284 uint32_t crc;
285
286 /* Compute CRC for the address value. */
287 crc = ether_crc32_le(addr, ETHER_ADDR_LEN);
288
289 return (crc & ((1 << CUE_BITS) - 1));
290}
291
292static void
294{
295 struct cue_softc *sc = uether_getsc(ue);
296 struct ifnet *ifp = uether_getifp(ue);
297
298 CUE_LOCK_ASSERT(sc, MA_OWNED);
299
300 /* if we want promiscuous mode, set the allframes bit */
301 if (ifp->if_flags & IFF_PROMISC)
303 else
305
306 /* write multicast hash-bits */
307 cue_setmulti(ue);
308}
309
310static u_int
311cue_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
312{
313 uint8_t *hashtbl = arg;
314 uint32_t h;
315
316 h = cue_mchash(LLADDR(sdl));
317 hashtbl[h >> 3] |= 1 << (h & 0x7);
318
319 return (1);
320}
321
322static void
324{
325 struct cue_softc *sc = uether_getsc(ue);
326 struct ifnet *ifp = uether_getifp(ue);
327 uint32_t h, i;
328 uint8_t hashtbl[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
329
330 CUE_LOCK_ASSERT(sc, MA_OWNED);
331
332 if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC) {
333 for (i = 0; i < 8; i++)
334 hashtbl[i] = 0xff;
336 &hashtbl, 8);
337 return;
338 }
339
340 /* now program new ones */
341 if_foreach_llmaddr(ifp, cue_hash_maddr, hashtbl);
342
343 /*
344 * Also include the broadcast address in the filter
345 * so we can receive broadcast frames.
346 */
347 if (ifp->if_flags & IFF_BROADCAST) {
348 h = cue_mchash(ifp->if_broadcastaddr);
349 hashtbl[h >> 3] |= 1 << (h & 0x7);
350 }
351
353}
354
355static void
357{
358 struct usb_device_request req;
359
360 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
361 req.bRequest = CUE_CMD_RESET;
362 USETW(req.wValue, 0);
363 USETW(req.wIndex, 0);
364 USETW(req.wLength, 0);
365
366 if (uether_do_request(&sc->sc_ue, &req, NULL, 1000)) {
367 /* ignore any errors */
368 }
369
370 /*
371 * wait a little while for the chip to get its brains in order:
372 */
373 uether_pause(&sc->sc_ue, hz / 100);
374}
375
376static void
378{
379 struct cue_softc *sc = uether_getsc(ue);
380
381 cue_getmac(sc, ue->ue_eaddr);
382}
383
384static int
385cue_probe(device_t dev)
386{
387 struct usb_attach_arg *uaa = device_get_ivars(dev);
388
389 if (uaa->usb_mode != USB_MODE_HOST)
390 return (ENXIO);
391 if (uaa->info.bConfigIndex != CUE_CONFIG_IDX)
392 return (ENXIO);
393 if (uaa->info.bIfaceIndex != CUE_IFACE_IDX)
394 return (ENXIO);
395
396 return (usbd_lookup_id_by_uaa(cue_devs, sizeof(cue_devs), uaa));
397}
398
399/*
400 * Attach the interface. Allocate softc structures, do ifmedia
401 * setup and ethernet/BPF attach.
402 */
403static int
404cue_attach(device_t dev)
405{
406 struct usb_attach_arg *uaa = device_get_ivars(dev);
407 struct cue_softc *sc = device_get_softc(dev);
408 struct usb_ether *ue = &sc->sc_ue;
409 uint8_t iface_index;
410 int error;
411
413 mtx_init(&sc->sc_mtx, device_get_nameunit(dev), NULL, MTX_DEF);
414
415 iface_index = CUE_IFACE_IDX;
416 error = usbd_transfer_setup(uaa->device, &iface_index,
417 sc->sc_xfer, cue_config, CUE_N_TRANSFER, sc, &sc->sc_mtx);
418 if (error) {
419 device_printf(dev, "allocating USB transfers failed\n");
420 goto detach;
421 }
422
423 ue->ue_sc = sc;
424 ue->ue_dev = dev;
425 ue->ue_udev = uaa->device;
426 ue->ue_mtx = &sc->sc_mtx;
428
430 if (error) {
431 device_printf(dev, "could not attach interface\n");
432 goto detach;
433 }
434 return (0); /* success */
435
436detach:
438 return (ENXIO); /* failure */
439}
440
441static int
442cue_detach(device_t dev)
443{
444 struct cue_softc *sc = device_get_softc(dev);
445 struct usb_ether *ue = &sc->sc_ue;
446
448 uether_ifdetach(ue);
449 mtx_destroy(&sc->sc_mtx);
450
451 return (0);
452}
453
454static void
456{
457 struct cue_softc *sc = usbd_xfer_softc(xfer);
458 struct usb_ether *ue = &sc->sc_ue;
459 struct ifnet *ifp = uether_getifp(ue);
460 struct usb_page_cache *pc;
461 uint8_t buf[2];
462 int len;
463 int actlen;
464
465 usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
466
467 switch (USB_GET_STATE(xfer)) {
469
470 if (actlen <= (int)(2 + sizeof(struct ether_header))) {
471 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
472 goto tr_setup;
473 }
474 pc = usbd_xfer_get_frame(xfer, 0);
475 usbd_copy_out(pc, 0, buf, 2);
476 actlen -= 2;
477 len = buf[0] | (buf[1] << 8);
478 len = min(actlen, len);
479
480 uether_rxbuf(ue, pc, 2, len);
481 /* FALLTHROUGH */
482 case USB_ST_SETUP:
483tr_setup:
486 uether_rxflush(ue);
487 return;
488
489 default: /* Error */
490 DPRINTF("bulk read error, %s\n",
492
493 if (error != USB_ERR_CANCELLED) {
494 /* try to clear stall first */
496 goto tr_setup;
497 }
498 return;
499 }
500}
501
502static void
504{
505 struct cue_softc *sc = usbd_xfer_softc(xfer);
506 struct ifnet *ifp = uether_getifp(&sc->sc_ue);
507 struct usb_page_cache *pc;
508 struct mbuf *m;
509 uint8_t buf[2];
510
511 switch (USB_GET_STATE(xfer)) {
513 DPRINTFN(11, "transfer complete\n");
514 if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
515
516 /* FALLTHROUGH */
517 case USB_ST_SETUP:
518tr_setup:
519 IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
520
521 if (m == NULL)
522 return;
523 if (m->m_pkthdr.len > MCLBYTES)
524 m->m_pkthdr.len = MCLBYTES;
525 usbd_xfer_set_frame_len(xfer, 0, (m->m_pkthdr.len + 2));
526
527 /* the first two bytes are the frame length */
528
529 buf[0] = (uint8_t)(m->m_pkthdr.len);
530 buf[1] = (uint8_t)(m->m_pkthdr.len >> 8);
531
532 pc = usbd_xfer_get_frame(xfer, 0);
533 usbd_copy_in(pc, 0, buf, 2);
534 usbd_m_copy_in(pc, 2, m, 0, m->m_pkthdr.len);
535
536 /*
537 * If there's a BPF listener, bounce a copy of this frame
538 * to him.
539 */
540 BPF_MTAP(ifp, m);
541
542 m_freem(m);
543
545
546 return;
547
548 default: /* Error */
549 DPRINTFN(11, "transfer error, %s\n",
551
552 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
553
554 if (error != USB_ERR_CANCELLED) {
555 /* try to clear stall first */
557 goto tr_setup;
558 }
559 return;
560 }
561}
562
563static void
565{
566 struct cue_softc *sc = uether_getsc(ue);
567 struct ifnet *ifp = uether_getifp(ue);
568
569 CUE_LOCK_ASSERT(sc, MA_OWNED);
570
571 if_inc_counter(ifp, IFCOUNTER_COLLISIONS, cue_csr_read_2(sc, CUE_TX_SINGLECOLL));
572 if_inc_counter(ifp, IFCOUNTER_COLLISIONS, cue_csr_read_2(sc, CUE_TX_MULTICOLL));
573 if_inc_counter(ifp, IFCOUNTER_COLLISIONS, cue_csr_read_2(sc, CUE_TX_EXCESSCOLL));
574
576 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
577}
578
579static void
581{
582 struct cue_softc *sc = uether_getsc(ue);
583
584 /*
585 * start the USB transfers, if not already started:
586 */
589}
590
591static void
593{
594 struct cue_softc *sc = uether_getsc(ue);
595 struct ifnet *ifp = uether_getifp(ue);
596 int i;
597
598 CUE_LOCK_ASSERT(sc, MA_OWNED);
599
600 /*
601 * Cancel pending I/O and free all RX/TX buffers.
602 */
603 cue_stop(ue);
604#if 0
605 cue_reset(sc);
606#endif
607 /* Set MAC address */
608 for (i = 0; i < ETHER_ADDR_LEN; i++)
609 cue_csr_write_1(sc, CUE_PAR0 - i, IF_LLADDR(ifp)[i]);
610
611 /* Enable RX logic. */
613
614 /* Load the multicast filter */
615 cue_setpromisc(ue);
616
617 /*
618 * Set the number of RX and TX buffers that we want
619 * to reserve inside the ASIC.
620 */
623
624 /* Set advanced operation modes. */
626 CUE_AOP_EMBED_RXLEN | 0x01);/* 1 wait state */
627
628 /* Program the LED operation. */
630
632
633 ifp->if_drv_flags |= IFF_DRV_RUNNING;
634 cue_start(ue);
635}
636
637/*
638 * Stop the adapter and free any mbufs allocated to the
639 * RX and TX lists.
640 */
641static void
643{
644 struct cue_softc *sc = uether_getsc(ue);
645 struct ifnet *ifp = uether_getifp(ue);
646
647 CUE_LOCK_ASSERT(sc, MA_OWNED);
648
649 ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
650
651 /*
652 * stop all the transfers, if not already stopped:
653 */
656
658 cue_reset(sc);
659}
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 const STRUCT_USB_HOST_ID cue_devs[]
Definition: if_cue.c:97
#define CUE_BITS
Definition: if_cue.c:279
DRIVER_MODULE(cue, uhub, cue_driver, cue_devclass, NULL, 0)
static device_attach_t cue_attach
Definition: if_cue.c:108
MODULE_DEPEND(cue, uether, 1, 1, 1)
static device_detach_t cue_detach
Definition: if_cue.c:109
static uether_fn_t cue_setpromisc
Definition: if_cue.c:120
static driver_t cue_driver
Definition: if_cue.c:169
static uint8_t cue_csr_read_1(struct cue_softc *, uint16_t)
Definition: if_cue.c:201
static void cue_reset(struct cue_softc *)
Definition: if_cue.c:356
static uether_fn_t cue_init
Definition: if_cue.c:115
#define CUE_DEV(v, p)
static int cue_mem(struct cue_softc *, uint8_t, uint16_t, void *, int)
Definition: if_cue.c:249
static device_probe_t cue_probe
Definition: if_cue.c:107
static const struct usb_ether_methods cue_ue_methods
Definition: if_cue.c:184
static device_method_t cue_methods[]
Definition: if_cue.c:160
static int cue_csr_write_1(struct cue_softc *, uint16_t, uint16_t)
Definition: if_cue.c:235
MODULE_VERSION(cue, 1)
static u_int cue_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
Definition: if_cue.c:311
static uether_fn_t cue_start
Definition: if_cue.c:117
static uether_fn_t cue_stop
Definition: if_cue.c:116
#define CUE_SETBIT(sc, reg, x)
Definition: if_cue.c:194
static uether_fn_t cue_attach_post
Definition: if_cue.c:114
__FBSDID("$FreeBSD$")
static uether_fn_t cue_tick
Definition: if_cue.c:118
static uint16_t cue_csr_read_2(struct cue_softc *, uint8_t)
Definition: if_cue.c:219
static usb_callback_t cue_bulk_write_callback
Definition: if_cue.c:112
USB_PNP_HOST_INFO(cue_devs)
static uint32_t cue_mchash(const uint8_t *)
Definition: if_cue.c:282
static devclass_t cue_devclass
Definition: if_cue.c:175
static const struct usb_config cue_config[CUE_N_TRANSFER]
Definition: if_cue.c:139
static int cue_getmac(struct cue_softc *, void *)
Definition: if_cue.c:266
static uether_fn_t cue_setmulti
Definition: if_cue.c:119
static usb_callback_t cue_bulk_read_callback
Definition: if_cue.c:111
#define CUE_CLRBIT(sc, reg, x)
Definition: if_cue.c:197
@ CUE_N_TRANSFER
Definition: if_cuereg.h:120
@ CUE_BULK_DT_WR
Definition: if_cuereg.h:118
@ CUE_BULK_DT_RD
Definition: if_cuereg.h:119
#define CUE_CMD_RESET
Definition: if_cuereg.h:42
#define CUE_TX_EXCESSCOLL
Definition: if_cuereg.h:66
#define CUE_CMD_WRITEREG
Definition: if_cuereg.h:44
#define CUE_RX_FRAMES
Definition: if_cuereg.h:107
#define CUE_LOCK_ASSERT(_sc, t)
Definition: if_cuereg.h:134
#define CUE_TX_BUFPKTS
Definition: if_cuereg.h:52
#define CUE_PAR0
Definition: if_cuereg.h:62
#define CUE_LEDCTL
Definition: if_cuereg.h:68
#define CUE_ETHCTL
Definition: if_cuereg.h:55
#define CUE_CONFIG_IDX
Definition: if_cuereg.h:113
#define CUE_TX_MULTICOLL
Definition: if_cuereg.h:65
#define CUE_CMD_GET_MACADDR
Definition: if_cuereg.h:43
#define CUE_ETHCTL_MCAST_ON
Definition: if_cuereg.h:80
#define CUE_TX_SINGLECOLL
Definition: if_cuereg.h:64
#define CUE_ETHCTL_RX_ON
Definition: if_cuereg.h:77
#define CUE_LEDCTL_FOLLOW_LINK
Definition: if_cuereg.h:95
#define CUE_TX_FRAMES
Definition: if_cuereg.h:108
#define CUE_AOP_EMBED_RXLEN
Definition: if_cuereg.h:71
#define CUE_ETHCTL_PROMISC
Definition: if_cuereg.h:81
#define CUE_CMD_READSRAM
Definition: if_cuereg.h:46
#define CUE_RX_BUFPKTS
Definition: if_cuereg.h:53
#define CUE_CMD_WRITESRAM
Definition: if_cuereg.h:47
#define CUE_RX_FRAMEERR
Definition: if_cuereg.h:67
#define CUE_ADVANCED_OPMODES
Definition: if_cuereg.h:51
#define CUE_CMD_READREG
Definition: if_cuereg.h:45
#define CUE_IFACE_IDX
Definition: if_cuereg.h:114
#define CUE_MCAST_TABLE_ADDR
Definition: if_cuereg.h:103
uint32_t reg
Definition: if_rum.c:283
uint32_t val
Definition: if_rum.c:284
struct @109 error
device_t dev
uint64_t * addr
struct usb_xfer * sc_xfer[CUE_N_TRANSFER]
Definition: if_cuereg.h:126
struct mtx sc_mtx
Definition: if_cuereg.h:125
struct usb_ether sc_ue
Definition: if_cuereg.h:124
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
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
#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
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_STATE(xfer)
Definition: usbdi.h:515