FreeBSD kernel usb device Code
if_aue.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 <net/if_media.h>
#include <dev/mii/mii.h>
#include <dev/mii/miivar.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_auereg.h>
#include "miibus_if.h"
Include dependency graph for if_aue.c:

Go to the source code of this file.

Macros

#define USB_DEBUG_VAR   aue_debug
 
#define AUE_DEV(v, p, i)   { USB_VPI(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, i) }
 
#define AUE_SETBIT(sc, reg, x)    aue_csr_write_1(sc, reg, aue_csr_read_1(sc, reg) | (x))
 
#define AUE_CLRBIT(sc, reg, x)    aue_csr_write_1(sc, reg, aue_csr_read_1(sc, reg) & ~(x))
 
#define AUE_BITS   6
 

Functions

 __FBSDID ("$FreeBSD$")
 
static uint8_t aue_csr_read_1 (struct aue_softc *, uint16_t)
 
static uint16_t aue_csr_read_2 (struct aue_softc *, uint16_t)
 
static void aue_csr_write_1 (struct aue_softc *, uint16_t, uint8_t)
 
static void aue_csr_write_2 (struct aue_softc *, uint16_t, uint16_t)
 
static uint16_t aue_eeprom_getword (struct aue_softc *, int)
 
static void aue_reset (struct aue_softc *)
 
static void aue_reset_pegasus_II (struct aue_softc *)
 
static int aue_ifmedia_upd (struct ifnet *)
 
static void aue_ifmedia_sts (struct ifnet *, struct ifmediareq *)
 
 DRIVER_MODULE (aue, uhub, aue_driver, aue_devclass, NULL, 0)
 
 DRIVER_MODULE (miibus, aue, miibus_driver, miibus_devclass, 0, 0)
 
 MODULE_DEPEND (aue, uether, 1, 1, 1)
 
 MODULE_DEPEND (aue, usb, 1, 1, 1)
 
 MODULE_DEPEND (aue, ether, 1, 1, 1)
 
 MODULE_DEPEND (aue, miibus, 1, 1, 1)
 
 MODULE_VERSION (aue, 1)
 
 USB_PNP_HOST_INFO (aue_devs)
 
static void aue_read_mac (struct aue_softc *sc, uint8_t *eaddr)
 
static int aue_miibus_readreg (device_t dev, int phy, int reg)
 
static int aue_miibus_writereg (device_t dev, int phy, int reg, int data)
 
static void aue_miibus_statchg (device_t dev)
 
static u_int aue_hash_maddr (void *arg, struct sockaddr_dl *sdl, u_int cnt)
 
static void aue_setmulti (struct usb_ether *ue)
 
static void aue_attach_post (struct usb_ether *ue)
 
static int aue_probe (device_t dev)
 
static int aue_attach (device_t dev)
 
static int aue_detach (device_t dev)
 
static void aue_intr_callback (struct usb_xfer *xfer, usb_error_t error)
 
static void aue_bulk_read_callback (struct usb_xfer *xfer, usb_error_t error)
 
static void aue_bulk_write_callback (struct usb_xfer *xfer, usb_error_t error)
 
static void aue_tick (struct usb_ether *ue)
 
static void aue_start (struct usb_ether *ue)
 
static void aue_init (struct usb_ether *ue)
 
static void aue_setpromisc (struct usb_ether *ue)
 
static void aue_stop (struct usb_ether *ue)
 

Variables

static const STRUCT_USB_HOST_ID aue_devs []
 
static device_probe_t aue_probe
 
static device_attach_t aue_attach
 
static device_detach_t aue_detach
 
static miibus_readreg_t aue_miibus_readreg
 
static miibus_writereg_t aue_miibus_writereg
 
static miibus_statchg_t aue_miibus_statchg
 
static usb_callback_t aue_intr_callback
 
static usb_callback_t aue_bulk_read_callback
 
static usb_callback_t aue_bulk_write_callback
 
static uether_fn_t aue_attach_post
 
static uether_fn_t aue_init
 
static uether_fn_t aue_stop
 
static uether_fn_t aue_start
 
static uether_fn_t aue_tick
 
static uether_fn_t aue_setmulti
 
static uether_fn_t aue_setpromisc
 
static const struct usb_config aue_config [AUE_N_TRANSFER]
 
static device_method_t aue_methods []
 
static driver_t aue_driver
 
static devclass_t aue_devclass
 
static const struct usb_ether_methods aue_ue_methods
 

Macro Definition Documentation

◆ AUE_BITS

#define AUE_BITS   6

Definition at line 542 of file if_aue.c.

◆ AUE_CLRBIT

#define AUE_CLRBIT (   sc,
  reg,
 
)     aue_csr_write_1(sc, reg, aue_csr_read_1(sc, reg) & ~(x))

Definition at line 307 of file if_aue.c.

◆ AUE_DEV

#define AUE_DEV (   v,
  p,
 
)    { USB_VPI(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, i) }

◆ AUE_SETBIT

#define AUE_SETBIT (   sc,
  reg,
 
)     aue_csr_write_1(sc, reg, aue_csr_read_1(sc, reg) | (x))

Definition at line 304 of file if_aue.c.

◆ USB_DEBUG_VAR

#define USB_DEBUG_VAR   aue_debug

Definition at line 105 of file if_aue.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ aue_attach()

◆ aue_attach_post()

static void aue_attach_post ( struct usb_ether ue)
static

Definition at line 640 of file if_aue.c.

References aue_read_mac(), aue_reset(), usb_ether::ue_eaddr, and uether_getsc().

Here is the call graph for this function:

◆ aue_bulk_read_callback()

◆ aue_bulk_write_callback()

◆ aue_csr_read_1()

static uint8_t aue_csr_read_1 ( struct aue_softc sc,
uint16_t  reg 
)
static

Definition at line 311 of file if_aue.c.

References AUE_UR_READREG, reg, req, aue_softc::sc_ue, uether_do_request, USETW, UT_READ_VENDOR_DEVICE, and val.

Referenced by aue_eeprom_getword(), aue_miibus_readreg(), aue_miibus_writereg(), and aue_reset().

Here is the caller graph for this function:

◆ aue_csr_read_2()

static uint16_t aue_csr_read_2 ( struct aue_softc sc,
uint16_t  reg 
)
static

Definition at line 330 of file if_aue.c.

References AUE_UR_READREG, reg, req, aue_softc::sc_ue, uether_do_request, USETW, UT_READ_VENDOR_DEVICE, and val.

Referenced by aue_eeprom_getword(), and aue_miibus_readreg().

Here is the caller graph for this function:

◆ aue_csr_write_1()

static void aue_csr_write_1 ( struct aue_softc sc,
uint16_t  reg,
uint8_t  val 
)
static

◆ aue_csr_write_2()

static void aue_csr_write_2 ( struct aue_softc sc,
uint16_t  reg,
uint16_t  val 
)
static

Definition at line 366 of file if_aue.c.

References AUE_UR_WRITEREG, reg, req, aue_softc::sc_ue, uether_do_request, USETW, UT_WRITE_VENDOR_DEVICE, and val.

Referenced by aue_miibus_writereg().

Here is the caller graph for this function:

◆ aue_detach()

static int aue_detach ( device_t  dev)
static

Definition at line 729 of file if_aue.c.

References AUE_N_TRANSFER, dev, aue_softc::sc_mtx, aue_softc::sc_ue, aue_softc::sc_xfer, uether_ifdetach(), and usbd_transfer_unsetup().

Here is the call graph for this function:

◆ aue_eeprom_getword()

static uint16_t aue_eeprom_getword ( struct aue_softc sc,
int  addr 
)
static

Definition at line 387 of file if_aue.c.

References addr, aue_csr_read_1(), aue_csr_read_2(), aue_csr_write_1(), AUE_EE_CTL, AUE_EE_DATA, AUE_EE_REG, AUE_EECTL_DONE, AUE_EECTL_READ, AUE_TIMEOUT, aue_softc::sc_ue, usb_ether::ue_dev, and uether_pause().

Referenced by aue_read_mac().

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

◆ aue_hash_maddr()

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

Definition at line 544 of file if_aue.c.

References AUE_BITS.

Referenced by aue_setmulti().

Here is the caller graph for this function:

◆ aue_ifmedia_sts()

static void aue_ifmedia_sts ( struct ifnet *  ifp,
struct ifmediareq *  ifmr 
)
static

Definition at line 1034 of file if_aue.c.

References AUE_LOCK, AUE_UNLOCK, and GET_MII.

◆ aue_ifmedia_upd()

static int aue_ifmedia_upd ( struct ifnet *  ifp)
static

Definition at line 1014 of file if_aue.c.

References AUE_LOCK_ASSERT, error, GET_MII, and aue_softc::sc_flags.

◆ aue_init()

◆ aue_intr_callback()

◆ aue_miibus_readreg()

static int aue_miibus_readreg ( device_t  dev,
int  phy,
int  reg 
)
static

◆ aue_miibus_statchg()

◆ aue_miibus_writereg()

static int aue_miibus_writereg ( device_t  dev,
int  phy,
int  reg,
int  data 
)
static

◆ aue_probe()

◆ aue_read_mac()

static void aue_read_mac ( struct aue_softc sc,
uint8_t *  eaddr 
)
static

Definition at line 411 of file if_aue.c.

References aue_eeprom_getword(), and offset.

Referenced by aue_attach_post().

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

◆ aue_reset()

static void aue_reset ( struct aue_softc sc)
static

◆ aue_reset_pegasus_II()

static void aue_reset_pegasus_II ( struct aue_softc sc)
static

Definition at line 581 of file if_aue.c.

References aue_csr_write_1(), AUE_REG_1D, AUE_REG_7B, AUE_REG_81, and aue_softc::sc_flags.

Referenced by aue_reset().

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

◆ aue_setmulti()

static void aue_setmulti ( struct usb_ether ue)
static

Definition at line 556 of file if_aue.c.

References AUE_CLRBIT, aue_csr_write_1(), AUE_CTL0, AUE_CTL0_ALLMULTI, aue_hash_maddr(), AUE_LOCK_ASSERT, AUE_MAR0, AUE_SETBIT, uether_getifp(), and uether_getsc().

Here is the call graph for this function:

◆ aue_setpromisc()

static void aue_setpromisc ( struct usb_ether ue)
static

Definition at line 996 of file if_aue.c.

References AUE_CLRBIT, AUE_CTL2, AUE_CTL2_RX_PROMISC, AUE_LOCK_ASSERT, AUE_SETBIT, uether_getifp(), and uether_getsc().

Here is the call graph for this function:

◆ aue_start()

static void aue_start ( struct usb_ether ue)
static

Definition at line 948 of file if_aue.c.

References AUE_BULK_DT_RD, AUE_BULK_DT_WR, AUE_INTR_DT_RD, aue_softc::sc_xfer, uether_getsc(), and usbd_transfer_start().

Here is the call graph for this function:

◆ aue_stop()

static void aue_stop ( struct usb_ether ue)
static

◆ aue_tick()

static void aue_tick ( struct usb_ether ue)
static

Definition at line 931 of file if_aue.c.

References AUE_FLAG_LINK, AUE_LOCK_ASSERT, aue_start, GET_MII, aue_softc::sc_flags, and uether_getsc().

Here is the call graph for this function:

◆ DRIVER_MODULE() [1/2]

DRIVER_MODULE ( aue  ,
uhub  ,
aue_driver  ,
aue_devclass  ,
NULL  ,
 
)

◆ DRIVER_MODULE() [2/2]

DRIVER_MODULE ( miibus  ,
aue  ,
miibus_driver  ,
miibus_devclass  ,
,
 
)

◆ MODULE_DEPEND() [1/4]

MODULE_DEPEND ( aue  ,
ether  ,
,
,
 
)

◆ MODULE_DEPEND() [2/4]

MODULE_DEPEND ( aue  ,
miibus  ,
,
,
 
)

◆ MODULE_DEPEND() [3/4]

MODULE_DEPEND ( aue  ,
uether  ,
,
,
 
)

◆ MODULE_DEPEND() [4/4]

MODULE_DEPEND ( aue  ,
usb  ,
,
,
 
)

◆ MODULE_VERSION()

MODULE_VERSION ( aue  ,
 
)

◆ USB_PNP_HOST_INFO()

USB_PNP_HOST_INFO ( aue_devs  )

Variable Documentation

◆ aue_attach

device_attach_t aue_attach
static

Definition at line 202 of file if_aue.c.

◆ aue_attach_post

uether_fn_t aue_attach_post
static

Definition at line 212 of file if_aue.c.

◆ aue_bulk_read_callback

usb_callback_t aue_bulk_read_callback
static

Definition at line 209 of file if_aue.c.

◆ aue_bulk_write_callback

usb_callback_t aue_bulk_write_callback
static

Definition at line 210 of file if_aue.c.

◆ aue_config

const struct usb_config aue_config[AUE_N_TRANSFER]
static
Initial value:
= {
.type = UE_BULK,
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_OUT,
.bufsize = (MCLBYTES + 2),
.flags = {.pipe_bof = 1,.force_short_xfer = 1,},
.timeout = 10000,
},
.type = UE_BULK,
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_IN,
.bufsize = (MCLBYTES + 4 + ETHER_CRC_LEN),
.flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
},
.type = UE_INTERRUPT,
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_IN,
.flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
.bufsize = 0,
.callback = aue_intr_callback,
},
}
static usb_callback_t aue_bulk_write_callback
Definition: if_aue.c:210
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
@ AUE_BULK_DT_WR
Definition: if_auereg.h:66
@ AUE_INTR_DT_RD
Definition: if_auereg.h:68
@ AUE_BULK_DT_RD
Definition: if_auereg.h:67
#define UE_INTERRUPT
Definition: usb.h:544
#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 231 of file if_aue.c.

Referenced by aue_attach().

◆ aue_detach

device_detach_t aue_detach
static

Definition at line 203 of file if_aue.c.

Referenced by aue_attach().

◆ aue_devclass

devclass_t aue_devclass
static

Definition at line 281 of file if_aue.c.

◆ aue_devs

const STRUCT_USB_HOST_ID aue_devs[]
static

Definition at line 126 of file if_aue.c.

Referenced by aue_probe().

◆ aue_driver

driver_t aue_driver
static
Initial value:
= {
.name = "aue",
.methods = aue_methods,
.size = sizeof(struct aue_softc)
}
static device_method_t aue_methods[]
Definition: if_aue.c:261

Definition at line 275 of file if_aue.c.

◆ aue_init

uether_fn_t aue_init
static

Definition at line 213 of file if_aue.c.

◆ aue_intr_callback

usb_callback_t aue_intr_callback
static

Definition at line 208 of file if_aue.c.

◆ aue_methods

device_method_t aue_methods[]
static
Initial value:
= {
DEVMETHOD(device_probe, aue_probe),
DEVMETHOD(device_attach, aue_attach),
DEVMETHOD(device_detach, aue_detach),
DEVMETHOD(miibus_readreg, aue_miibus_readreg),
DEVMETHOD(miibus_writereg, aue_miibus_writereg),
DEVMETHOD(miibus_statchg, aue_miibus_statchg),
DEVMETHOD_END
}
static miibus_readreg_t aue_miibus_readreg
Definition: if_aue.c:204
static device_attach_t aue_attach
Definition: if_aue.c:202
static device_detach_t aue_detach
Definition: if_aue.c:203
static miibus_statchg_t aue_miibus_statchg
Definition: if_aue.c:206
static miibus_writereg_t aue_miibus_writereg
Definition: if_aue.c:205
static device_probe_t aue_probe
Definition: if_aue.c:201

Definition at line 261 of file if_aue.c.

◆ aue_miibus_readreg

miibus_readreg_t aue_miibus_readreg
static

Definition at line 204 of file if_aue.c.

Referenced by aue_miibus_statchg().

◆ aue_miibus_statchg

miibus_statchg_t aue_miibus_statchg
static

Definition at line 206 of file if_aue.c.

◆ aue_miibus_writereg

miibus_writereg_t aue_miibus_writereg
static

Definition at line 205 of file if_aue.c.

Referenced by aue_miibus_statchg().

◆ aue_probe

device_probe_t aue_probe
static

Definition at line 201 of file if_aue.c.

◆ aue_setmulti

uether_fn_t aue_setmulti
static

Definition at line 217 of file if_aue.c.

Referenced by aue_init().

◆ aue_setpromisc

uether_fn_t aue_setpromisc
static

Definition at line 218 of file if_aue.c.

Referenced by aue_init().

◆ aue_start

uether_fn_t aue_start
static

Definition at line 215 of file if_aue.c.

Referenced by aue_init(), and aue_tick().

◆ aue_stop

uether_fn_t aue_stop
static

Definition at line 214 of file if_aue.c.

◆ aue_tick

uether_fn_t aue_tick
static

Definition at line 216 of file if_aue.c.

◆ aue_ue_methods

const struct usb_ether_methods aue_ue_methods
static
Initial value:
= {
.ue_attach_post = aue_attach_post,
.ue_start = aue_start,
.ue_init = aue_init,
.ue_stop = aue_stop,
.ue_tick = aue_tick,
.ue_setmulti = aue_setmulti,
.ue_setpromisc = aue_setpromisc,
.ue_mii_upd = aue_ifmedia_upd,
.ue_mii_sts = aue_ifmedia_sts,
}
static uether_fn_t aue_setpromisc
Definition: if_aue.c:218
static uether_fn_t aue_tick
Definition: if_aue.c:216
static uether_fn_t aue_attach_post
Definition: if_aue.c:212
static uether_fn_t aue_start
Definition: if_aue.c:215
static void aue_ifmedia_sts(struct ifnet *, struct ifmediareq *)
Definition: if_aue.c:1034
static uether_fn_t aue_init
Definition: if_aue.c:213
static int aue_ifmedia_upd(struct ifnet *)
Definition: if_aue.c:1014
static uether_fn_t aue_stop
Definition: if_aue.c:214
static uether_fn_t aue_setmulti
Definition: if_aue.c:217

Definition at line 292 of file if_aue.c.

Referenced by aue_attach().