FreeBSD kernel usb device Code
if_cue.c File Reference
#include <sys/cdefs.h>
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
#include <sys/queue.h>
#include <sys/types.h>
#include <sys/systm.h>
#include <sys/socket.h>
#include <sys/kernel.h>
#include <sys/bus.h>
#include <sys/module.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/condvar.h>
#include <sys/sysctl.h>
#include <sys/sx.h>
#include <sys/unistd.h>
#include <sys/callout.h>
#include <sys/malloc.h>
#include <sys/priv.h>
#include <net/if.h>
#include <net/if_var.h>
#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
#include <dev/usb/usbdi_util.h>
#include "usbdevs.h"
#include <dev/usb/usb_debug.h>
#include <dev/usb/usb_process.h>
#include <dev/usb/net/usb_ethernet.h>
#include <dev/usb/net/if_cuereg.h>
Include dependency graph for if_cue.c:

Go to the source code of this file.

Macros

#define USB_DEBUG_VAR   cue_debug
 
#define CUE_DEV(v, p)   { USB_VP(USB_VENDOR_##v, USB_PRODUCT_##v##_##p) }
 
#define CUE_SETBIT(sc, reg, x)    cue_csr_write_1(sc, reg, cue_csr_read_1(sc, reg) | (x))
 
#define CUE_CLRBIT(sc, reg, x)    cue_csr_write_1(sc, reg, cue_csr_read_1(sc, reg) & ~(x))
 
#define CUE_BITS   9
 

Functions

 __FBSDID ("$FreeBSD$")
 
static uint8_t cue_csr_read_1 (struct cue_softc *, uint16_t)
 
static uint16_t cue_csr_read_2 (struct cue_softc *, uint8_t)
 
static int cue_csr_write_1 (struct cue_softc *, uint16_t, uint16_t)
 
static int cue_mem (struct cue_softc *, uint8_t, uint16_t, void *, int)
 
static int cue_getmac (struct cue_softc *, void *)
 
static uint32_t cue_mchash (const uint8_t *)
 
static void cue_reset (struct cue_softc *)
 
 DRIVER_MODULE (cue, uhub, cue_driver, cue_devclass, NULL, 0)
 
 MODULE_DEPEND (cue, uether, 1, 1, 1)
 
 MODULE_DEPEND (cue, usb, 1, 1, 1)
 
 MODULE_DEPEND (cue, ether, 1, 1, 1)
 
 MODULE_VERSION (cue, 1)
 
 USB_PNP_HOST_INFO (cue_devs)
 
static void cue_setpromisc (struct usb_ether *ue)
 
static u_int cue_hash_maddr (void *arg, struct sockaddr_dl *sdl, u_int cnt)
 
static void cue_setmulti (struct usb_ether *ue)
 
static void cue_attach_post (struct usb_ether *ue)
 
static int cue_probe (device_t dev)
 
static int cue_attach (device_t dev)
 
static int cue_detach (device_t dev)
 
static void cue_bulk_read_callback (struct usb_xfer *xfer, usb_error_t error)
 
static void cue_bulk_write_callback (struct usb_xfer *xfer, usb_error_t error)
 
static void cue_tick (struct usb_ether *ue)
 
static void cue_start (struct usb_ether *ue)
 
static void cue_init (struct usb_ether *ue)
 
static void cue_stop (struct usb_ether *ue)
 

Variables

static const STRUCT_USB_HOST_ID cue_devs []
 
static device_probe_t cue_probe
 
static device_attach_t cue_attach
 
static device_detach_t cue_detach
 
static usb_callback_t cue_bulk_read_callback
 
static usb_callback_t cue_bulk_write_callback
 
static uether_fn_t cue_attach_post
 
static uether_fn_t cue_init
 
static uether_fn_t cue_stop
 
static uether_fn_t cue_start
 
static uether_fn_t cue_tick
 
static uether_fn_t cue_setmulti
 
static uether_fn_t cue_setpromisc
 
static const struct usb_config cue_config [CUE_N_TRANSFER]
 
static device_method_t cue_methods []
 
static driver_t cue_driver
 
static devclass_t cue_devclass
 
static const struct usb_ether_methods cue_ue_methods
 

Macro Definition Documentation

◆ CUE_BITS

#define CUE_BITS   9

Definition at line 279 of file if_cue.c.

◆ CUE_CLRBIT

#define CUE_CLRBIT (   sc,
  reg,
 
)     cue_csr_write_1(sc, reg, cue_csr_read_1(sc, reg) & ~(x))

Definition at line 197 of file if_cue.c.

◆ CUE_DEV

#define CUE_DEV (   v,
 
)    { USB_VP(USB_VENDOR_##v, USB_PRODUCT_##v##_##p) }

◆ CUE_SETBIT

#define CUE_SETBIT (   sc,
  reg,
 
)     cue_csr_write_1(sc, reg, cue_csr_read_1(sc, reg) | (x))

Definition at line 194 of file if_cue.c.

◆ USB_DEBUG_VAR

#define USB_DEBUG_VAR   cue_debug

Definition at line 84 of file if_cue.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ cue_attach()

◆ cue_attach_post()

static void cue_attach_post ( struct usb_ether ue)
static

Definition at line 377 of file if_cue.c.

References cue_getmac(), usb_ether::ue_eaddr, and uether_getsc().

Here is the call graph for this function:

◆ cue_bulk_read_callback()

◆ cue_bulk_write_callback()

static void cue_bulk_write_callback ( struct usb_xfer xfer,
usb_error_t  error 
)
static

◆ cue_csr_read_1()

static uint8_t cue_csr_read_1 ( struct cue_softc sc,
uint16_t  reg 
)
static

◆ cue_csr_read_2()

static uint16_t cue_csr_read_2 ( struct cue_softc sc,
uint8_t  reg 
)
static

Definition at line 219 of file if_cue.c.

References CUE_CMD_READREG, reg, req, cue_softc::sc_ue, uether_do_request, USETW, UT_READ_VENDOR_DEVICE, and val.

Referenced by cue_tick().

Here is the caller graph for this function:

◆ cue_csr_write_1()

static int cue_csr_write_1 ( struct cue_softc sc,
uint16_t  reg,
uint16_t  val 
)
static

Definition at line 235 of file if_cue.c.

References CUE_CMD_WRITEREG, reg, req, cue_softc::sc_ue, uether_do_request, USETW, UT_WRITE_VENDOR_DEVICE, and val.

Referenced by cue_init(), and cue_stop().

Here is the caller graph for this function:

◆ cue_detach()

static int cue_detach ( device_t  dev)
static

Definition at line 442 of file if_cue.c.

References CUE_N_TRANSFER, dev, cue_softc::sc_mtx, cue_softc::sc_ue, cue_softc::sc_xfer, uether_ifdetach(), and usbd_transfer_unsetup().

Here is the call graph for this function:

◆ cue_getmac()

static int cue_getmac ( struct cue_softc sc,
void *  buf 
)
static

Definition at line 266 of file if_cue.c.

References CUE_CMD_GET_MACADDR, req, cue_softc::sc_ue, uether_do_request, USETW, and UT_READ_VENDOR_DEVICE.

Referenced by cue_attach_post().

Here is the caller graph for this function:

◆ cue_hash_maddr()

static u_int cue_hash_maddr ( void *  arg,
struct sockaddr_dl *  sdl,
u_int  cnt 
)
static

Definition at line 311 of file if_cue.c.

References cue_mchash().

Referenced by cue_setmulti().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cue_init()

◆ cue_mchash()

static uint32_t cue_mchash ( const uint8_t *  addr)
static

Definition at line 282 of file if_cue.c.

References addr, and CUE_BITS.

Referenced by cue_hash_maddr(), and cue_setmulti().

Here is the caller graph for this function:

◆ cue_mem()

static int cue_mem ( struct cue_softc sc,
uint8_t  cmd,
uint16_t  addr,
void *  buf,
int  len 
)
static

Definition at line 249 of file if_cue.c.

References addr, CUE_CMD_READSRAM, len, req, cue_softc::sc_ue, uether_do_request, USETW, UT_READ_VENDOR_DEVICE, and UT_WRITE_VENDOR_DEVICE.

Referenced by cue_setmulti().

Here is the caller graph for this function:

◆ cue_probe()

static int cue_probe ( device_t  dev)
static

◆ cue_reset()

static void cue_reset ( struct cue_softc sc)
static

Definition at line 356 of file if_cue.c.

References CUE_CMD_RESET, req, cue_softc::sc_ue, uether_do_request, uether_pause(), USETW, and UT_WRITE_VENDOR_DEVICE.

Referenced by cue_init(), and cue_stop().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cue_setmulti()

static void cue_setmulti ( struct usb_ether ue)
static

Definition at line 323 of file if_cue.c.

References CUE_CMD_WRITESRAM, cue_hash_maddr(), CUE_LOCK_ASSERT, CUE_MCAST_TABLE_ADDR, cue_mchash(), cue_mem(), uether_getifp(), and uether_getsc().

Here is the call graph for this function:

◆ cue_setpromisc()

static void cue_setpromisc ( struct usb_ether ue)
static

Definition at line 293 of file if_cue.c.

References CUE_CLRBIT, CUE_ETHCTL, CUE_ETHCTL_PROMISC, CUE_LOCK_ASSERT, CUE_SETBIT, cue_setmulti, uether_getifp(), and uether_getsc().

Here is the call graph for this function:

◆ cue_start()

static void cue_start ( struct usb_ether ue)
static

Definition at line 580 of file if_cue.c.

References CUE_BULK_DT_RD, CUE_BULK_DT_WR, cue_softc::sc_xfer, uether_getsc(), and usbd_transfer_start().

Here is the call graph for this function:

◆ cue_stop()

static void cue_stop ( struct usb_ether ue)
static

Definition at line 642 of file if_cue.c.

References CUE_BULK_DT_RD, CUE_BULK_DT_WR, cue_csr_write_1(), CUE_ETHCTL, CUE_LOCK_ASSERT, cue_reset(), cue_softc::sc_xfer, uether_getifp(), uether_getsc(), and usbd_transfer_stop().

Here is the call graph for this function:

◆ cue_tick()

static void cue_tick ( struct usb_ether ue)
static

Definition at line 564 of file if_cue.c.

References cue_csr_read_2(), CUE_LOCK_ASSERT, CUE_RX_FRAMEERR, CUE_TX_EXCESSCOLL, CUE_TX_MULTICOLL, CUE_TX_SINGLECOLL, uether_getifp(), and uether_getsc().

Here is the call graph for this function:

◆ DRIVER_MODULE()

DRIVER_MODULE ( cue  ,
uhub  ,
cue_driver  ,
cue_devclass  ,
NULL  ,
 
)

◆ MODULE_DEPEND() [1/3]

MODULE_DEPEND ( cue  ,
ether  ,
,
,
 
)

◆ MODULE_DEPEND() [2/3]

MODULE_DEPEND ( cue  ,
uether  ,
,
,
 
)

◆ MODULE_DEPEND() [3/3]

MODULE_DEPEND ( cue  ,
usb  ,
,
,
 
)

◆ MODULE_VERSION()

MODULE_VERSION ( cue  ,
 
)

◆ USB_PNP_HOST_INFO()

USB_PNP_HOST_INFO ( cue_devs  )

Variable Documentation

◆ cue_attach

device_attach_t cue_attach
static

Definition at line 108 of file if_cue.c.

◆ cue_attach_post

uether_fn_t cue_attach_post
static

Definition at line 114 of file if_cue.c.

◆ cue_bulk_read_callback

usb_callback_t cue_bulk_read_callback
static

Definition at line 111 of file if_cue.c.

◆ cue_bulk_write_callback

usb_callback_t cue_bulk_write_callback
static

Definition at line 112 of file if_cue.c.

◆ cue_config

const struct usb_config cue_config[CUE_N_TRANSFER]
static
Initial value:
= {
.type = UE_BULK,
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_OUT,
.bufsize = (MCLBYTES + 2),
.flags = {.pipe_bof = 1,},
.timeout = 10000,
},
.type = UE_BULK,
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_IN,
.bufsize = (MCLBYTES + 2),
.flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
},
}
static usb_callback_t cue_bulk_write_callback
Definition: if_cue.c:112
static usb_callback_t cue_bulk_read_callback
Definition: if_cue.c:111
@ CUE_BULK_DT_WR
Definition: if_cuereg.h:118
@ CUE_BULK_DT_RD
Definition: if_cuereg.h:119
#define UE_ADDR_ANY
Definition: usb.h:537
#define UE_BULK
Definition: usb.h:543
#define UE_DIR_IN
Definition: usb.h:531
#define UE_DIR_OUT
Definition: usb.h:532

Definition at line 139 of file if_cue.c.

Referenced by cue_attach().

◆ cue_detach

device_detach_t cue_detach
static

Definition at line 109 of file if_cue.c.

Referenced by cue_attach().

◆ cue_devclass

devclass_t cue_devclass
static

Definition at line 175 of file if_cue.c.

◆ cue_devs

const STRUCT_USB_HOST_ID cue_devs[]
static
Initial value:
= {
#define CUE_DEV(v,p)
CUE_DEV(CATC, NETMATE),
CUE_DEV(CATC, NETMATE2),
CUE_DEV(SMARTBRIDGES, SMARTLINK),
}
#define CUE_DEV(v, p)

Definition at line 97 of file if_cue.c.

Referenced by cue_probe().

◆ cue_driver

driver_t cue_driver
static
Initial value:
= {
.name = "cue",
.methods = cue_methods,
.size = sizeof(struct cue_softc),
}
static device_method_t cue_methods[]
Definition: if_cue.c:160

Definition at line 169 of file if_cue.c.

◆ cue_init

uether_fn_t cue_init
static

Definition at line 115 of file if_cue.c.

◆ cue_methods

device_method_t cue_methods[]
static
Initial value:
= {
DEVMETHOD(device_probe, cue_probe),
DEVMETHOD(device_attach, cue_attach),
DEVMETHOD(device_detach, cue_detach),
DEVMETHOD_END
}
static device_attach_t cue_attach
Definition: if_cue.c:108
static device_detach_t cue_detach
Definition: if_cue.c:109
static device_probe_t cue_probe
Definition: if_cue.c:107

Definition at line 160 of file if_cue.c.

◆ cue_probe

device_probe_t cue_probe
static

Definition at line 107 of file if_cue.c.

◆ cue_setmulti

uether_fn_t cue_setmulti
static

Definition at line 119 of file if_cue.c.

Referenced by cue_setpromisc().

◆ cue_setpromisc

uether_fn_t cue_setpromisc
static

Definition at line 120 of file if_cue.c.

Referenced by cue_init().

◆ cue_start

uether_fn_t cue_start
static

Definition at line 117 of file if_cue.c.

Referenced by cue_init().

◆ cue_stop

uether_fn_t cue_stop
static

Definition at line 116 of file if_cue.c.

Referenced by cue_init().

◆ cue_tick

uether_fn_t cue_tick
static

Definition at line 118 of file if_cue.c.

◆ cue_ue_methods

const struct usb_ether_methods cue_ue_methods
static
Initial value:
= {
.ue_attach_post = cue_attach_post,
.ue_start = cue_start,
.ue_init = cue_init,
.ue_stop = cue_stop,
.ue_tick = cue_tick,
.ue_setmulti = cue_setmulti,
.ue_setpromisc = cue_setpromisc,
}
static uether_fn_t cue_setpromisc
Definition: if_cue.c:120
static uether_fn_t cue_init
Definition: if_cue.c:115
static uether_fn_t cue_start
Definition: if_cue.c:117
static uether_fn_t cue_stop
Definition: if_cue.c:116
static uether_fn_t cue_attach_post
Definition: if_cue.c:114
static uether_fn_t cue_tick
Definition: if_cue.c:118
static uether_fn_t cue_setmulti
Definition: if_cue.c:119

Definition at line 184 of file if_cue.c.

Referenced by cue_attach().