FreeBSD kernel usb device Code
if_axge.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/condvar.h>
#include <sys/endian.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/module.h>
#include <sys/mutex.h>
#include <sys/socket.h>
#include <sys/sysctl.h>
#include <sys/unistd.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_axgereg.h>
#include "miibus_if.h"
Include dependency graph for if_axge.c:

Go to the source code of this file.

Macros

#define USB_DEBUG_VAR   axge_debug
 
#define AXGE_DEV(v, p)   { USB_VP(USB_VENDOR_##v, USB_PRODUCT_##v##_##p) }
 
#define AXGE_CSUM_FEATURES   (CSUM_IP | CSUM_TCP | CSUM_UDP)
 

Functions

 __FBSDID ("$FreeBSD$")
 
static int axge_read_mem (struct axge_softc *, uint8_t, uint16_t, uint16_t, void *, int)
 
static void axge_write_mem (struct axge_softc *, uint8_t, uint16_t, uint16_t, void *, int)
 
static uint8_t axge_read_cmd_1 (struct axge_softc *, uint8_t, uint16_t)
 
static uint16_t axge_read_cmd_2 (struct axge_softc *, uint8_t, uint16_t, uint16_t)
 
static void axge_write_cmd_1 (struct axge_softc *, uint8_t, uint16_t, uint8_t)
 
static void axge_write_cmd_2 (struct axge_softc *, uint8_t, uint16_t, uint16_t, uint16_t)
 
static void axge_chip_init (struct axge_softc *)
 
static void axge_reset (struct axge_softc *)
 
static int axge_attach_post_sub (struct usb_ether *)
 
static int axge_ifmedia_upd (struct ifnet *)
 
static void axge_ifmedia_sts (struct ifnet *, struct ifmediareq *)
 
static int axge_ioctl (struct ifnet *, u_long, caddr_t)
 
static void axge_rx_frame (struct usb_ether *, struct usb_page_cache *, int)
 
static void axge_rxeof (struct usb_ether *, struct usb_page_cache *, unsigned int, unsigned int, uint32_t)
 
static void axge_csum_cfg (struct usb_ether *)
 
 DRIVER_MODULE (axge, uhub, axge_driver, axge_devclass, NULL, NULL)
 
 DRIVER_MODULE (miibus, axge, miibus_driver, miibus_devclass, NULL, NULL)
 
 MODULE_DEPEND (axge, uether, 1, 1, 1)
 
 MODULE_DEPEND (axge, usb, 1, 1, 1)
 
 MODULE_DEPEND (axge, ether, 1, 1, 1)
 
 MODULE_DEPEND (axge, miibus, 1, 1, 1)
 
 MODULE_VERSION (axge, 1)
 
 USB_PNP_HOST_INFO (axge_devs)
 
static int axge_miibus_readreg (device_t dev, int phy, int reg)
 
static int axge_miibus_writereg (device_t dev, int phy, int reg, int val)
 
static void axge_miibus_statchg (device_t dev)
 
static void axge_attach_post (struct usb_ether *ue)
 
static int axge_probe (device_t dev)
 
static int axge_attach (device_t dev)
 
static int axge_detach (device_t dev)
 
static void axge_bulk_read_callback (struct usb_xfer *xfer, usb_error_t error)
 
static void axge_bulk_write_callback (struct usb_xfer *xfer, usb_error_t error)
 
static void axge_tick (struct usb_ether *ue)
 
static u_int axge_hash_maddr (void *arg, struct sockaddr_dl *sdl, u_int cnt)
 
static void axge_rxfilter (struct usb_ether *ue)
 
static void axge_start (struct usb_ether *ue)
 
static void axge_init (struct usb_ether *ue)
 
static void axge_stop (struct usb_ether *ue)
 

Variables

static const STRUCT_USB_HOST_ID axge_devs []
 
struct {
   uint8_t   ctrl
 
   uint8_t   timer_l
 
   uint8_t   timer_h
 
   uint8_t   size
 
   uint8_t   ifg
 
axge_bulk_size []
 
static device_probe_t axge_probe
 
static device_attach_t axge_attach
 
static device_detach_t axge_detach
 
static usb_callback_t axge_bulk_read_callback
 
static usb_callback_t axge_bulk_write_callback
 
static miibus_readreg_t axge_miibus_readreg
 
static miibus_writereg_t axge_miibus_writereg
 
static miibus_statchg_t axge_miibus_statchg
 
static uether_fn_t axge_attach_post
 
static uether_fn_t axge_init
 
static uether_fn_t axge_stop
 
static uether_fn_t axge_start
 
static uether_fn_t axge_tick
 
static uether_fn_t axge_rxfilter
 
static const struct usb_config axge_config [AXGE_N_TRANSFER]
 
static device_method_t axge_methods []
 
static driver_t axge_driver
 
static devclass_t axge_devclass
 
static const struct usb_ether_methods axge_ue_methods
 

Macro Definition Documentation

◆ AXGE_CSUM_FEATURES

#define AXGE_CSUM_FEATURES   (CSUM_IP | CSUM_TCP | CSUM_UDP)

Definition at line 141 of file if_axge.c.

◆ AXGE_DEV

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

◆ USB_DEBUG_VAR

#define USB_DEBUG_VAR   axge_debug

Definition at line 61 of file if_axge.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ axge_attach()

◆ axge_attach_post()

static void axge_attach_post ( struct usb_ether ue)
static

Definition at line 440 of file if_axge.c.

References AXGE_ACCESS_MAC, axge_chip_init(), AXGE_NIDR, axge_read_mem(), usb_ether::ue_eaddr, and uether_getsc().

Here is the call graph for this function:

◆ axge_attach_post_sub()

static int axge_attach_post_sub ( struct usb_ether ue)
static

◆ axge_bulk_read_callback()

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

◆ axge_bulk_write_callback()

◆ axge_chip_init()

static void axge_chip_init ( struct axge_softc sc)
static

Definition at line 408 of file if_axge.c.

References AXGE_ACCESS_MAC, AXGE_CLK_SELECT, AXGE_CLK_SELECT_ACS, AXGE_CLK_SELECT_BCS, AXGE_EPPRCR, axge_write_cmd_1(), axge_write_cmd_2(), EPPRCR_IPRL, axge_softc::sc_ue, and uether_pause().

Referenced by axge_attach_post(), and axge_reset().

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

◆ axge_csum_cfg()

static void axge_csum_cfg ( struct usb_ether ue)
static

Definition at line 1047 of file if_axge.c.

References AXGE_ACCESS_MAC, AXGE_CRCR, AXGE_CTCR, AXGE_LOCK_ASSERT, axge_write_cmd_1(), CRCR_IP, CRCR_TCP, CRCR_UDP, CTCR_IP, CTCR_TCP, CTCR_UDP, uether_getifp(), and uether_getsc().

Referenced by axge_init().

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

◆ axge_detach()

◆ axge_hash_maddr()

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

Definition at line 758 of file if_axge.c.

Referenced by axge_rxfilter().

Here is the caller graph for this function:

◆ axge_ifmedia_sts()

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

Definition at line 506 of file if_axge.c.

References AXGE_LOCK, AXGE_UNLOCK, and GET_MII.

◆ axge_ifmedia_upd()

static int axge_ifmedia_upd ( struct ifnet *  ifp)
static

Definition at line 484 of file if_axge.c.

References AXGE_LOCK_ASSERT, error, and GET_MII.

Referenced by axge_init().

Here is the caller graph for this function:

◆ axge_init()

◆ axge_ioctl()

static int axge_ioctl ( struct ifnet *  ifp,
u_long  cmd,
caddr_t  data 
)
static

Definition at line 902 of file if_axge.c.

References AXGE_CSUM_FEATURES, AXGE_LOCK, AXGE_UNLOCK, data, error, uether_getsc(), uether_init(), and uether_ioctl().

Referenced by axge_attach_post_sub().

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

◆ axge_miibus_readreg()

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

Definition at line 290 of file if_axge.c.

References AXGE_ACCESS_PHY, AXGE_LOCK, axge_read_cmd_2(), AXGE_UNLOCK, dev, reg, axge_softc::sc_mtx, and val.

Here is the call graph for this function:

◆ axge_miibus_statchg()

◆ axge_miibus_writereg()

static int axge_miibus_writereg ( device_t  dev,
int  phy,
int  reg,
int  val 
)
static

Definition at line 310 of file if_axge.c.

References AXGE_ACCESS_PHY, AXGE_LOCK, AXGE_UNLOCK, axge_write_cmd_2(), dev, reg, axge_softc::sc_mtx, and val.

Here is the call graph for this function:

◆ axge_probe()

static int axge_probe ( device_t  dev)
static

◆ axge_read_cmd_1()

static uint8_t axge_read_cmd_1 ( struct axge_softc sc,
uint8_t  cmd,
uint16_t  reg 
)
static

Definition at line 255 of file if_axge.c.

References axge_read_mem(), reg, and val.

Referenced by axge_init(), and axge_miibus_statchg().

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

◆ axge_read_cmd_2()

static uint16_t axge_read_cmd_2 ( struct axge_softc sc,
uint8_t  cmd,
uint16_t  index,
uint16_t  reg 
)
static

Definition at line 264 of file if_axge.c.

References axge_read_mem(), index, reg, UGETW, and val.

Referenced by axge_detach(), axge_miibus_readreg(), and axge_stop().

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

◆ axge_read_mem()

static int axge_read_mem ( struct axge_softc sc,
uint8_t  cmd,
uint16_t  index,
uint16_t  val,
void *  buf,
int  len 
)
static

Definition at line 219 of file if_axge.c.

References AXGE_LOCK_ASSERT, index, len, req, axge_softc::sc_ue, uether_do_request, USETW, UT_READ_VENDOR_DEVICE, and val.

Referenced by axge_attach_post(), axge_read_cmd_1(), and axge_read_cmd_2().

Here is the caller graph for this function:

◆ axge_reset()

static void axge_reset ( struct axge_softc sc)
static

Definition at line 420 of file if_axge.c.

References axge_chip_init(), usb_config_descriptor::bConfigurationValue, DPRINTF, axge_softc::sc_mtx, axge_softc::sc_ue, usb_ether::ue_udev, uether_pause(), usbd_get_config_descriptor(), and usbd_req_set_config().

Referenced by axge_init().

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

◆ axge_rx_frame()

static void axge_rx_frame ( struct usb_ether ue,
struct usb_page_cache pc,
int  actlen 
)
static

Definition at line 945 of file if_axge.c.

References AXGE_RX_ERR, AXGE_RXBYTES, axge_rxeof(), DPRINTF, axge_frame_rxhdr::status, usb_ether::ue_ifp, and usbd_copy_out().

Referenced by axge_bulk_read_callback().

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

◆ axge_rxeof()

static void axge_rxeof ( struct usb_ether ue,
struct usb_page_cache pc,
unsigned int  offset,
unsigned int  len,
uint32_t  status 
)
static

Definition at line 1002 of file if_axge.c.

References AXGE_RX_L3_CSUM_ERR, AXGE_RX_L3_TYPE_IPV4, AXGE_RX_L3_TYPE_MASK, AXGE_RX_L4_CSUM_ERR, AXGE_RX_L4_TYPE_MASK, AXGE_RX_L4_TYPE_TCP, AXGE_RX_L4_TYPE_UDP, len, offset, status, usb_ether::ue_ifp, usb_ether::ue_rxq, and usbd_copy_out().

Referenced by axge_rx_frame().

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

◆ axge_rxfilter()

static void axge_rxfilter ( struct usb_ether ue)
static

◆ axge_start()

static void axge_start ( struct usb_ether ue)
static

Definition at line 808 of file if_axge.c.

References AXGE_BULK_DT_RD, AXGE_BULK_DT_WR, axge_softc::sc_xfer, uether_getsc(), and usbd_transfer_start().

Here is the call graph for this function:

◆ axge_stop()

static void axge_stop ( struct usb_ether ue)
static

◆ axge_tick()

static void axge_tick ( struct usb_ether ue)
static

Definition at line 745 of file if_axge.c.

References AXGE_LOCK_ASSERT, GET_MII, and uether_getsc().

Here is the call graph for this function:

◆ axge_write_cmd_1()

static void axge_write_cmd_1 ( struct axge_softc sc,
uint8_t  cmd,
uint16_t  reg,
uint8_t  val 
)
static

Definition at line 274 of file if_axge.c.

References axge_write_mem(), reg, and val.

Referenced by axge_chip_init(), axge_csum_cfg(), axge_detach(), and axge_init().

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

◆ axge_write_cmd_2()

static void axge_write_cmd_2 ( struct axge_softc sc,
uint8_t  cmd,
uint16_t  index,
uint16_t  reg,
uint16_t  val 
)
static

Definition at line 280 of file if_axge.c.

References axge_write_mem(), index, reg, USETW, and val.

Referenced by axge_chip_init(), axge_detach(), axge_init(), axge_miibus_statchg(), axge_miibus_writereg(), axge_rxfilter(), and axge_stop().

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

◆ axge_write_mem()

static void axge_write_mem ( struct axge_softc sc,
uint8_t  cmd,
uint16_t  index,
uint16_t  val,
void *  buf,
int  len 
)
static

Definition at line 236 of file if_axge.c.

References AXGE_LOCK_ASSERT, index, len, req, axge_softc::sc_ue, uether_do_request, USETW, UT_WRITE_VENDOR_DEVICE, and val.

Referenced by axge_init(), axge_miibus_statchg(), axge_rxfilter(), axge_write_cmd_1(), and axge_write_cmd_2().

Here is the caller graph for this function:

◆ DRIVER_MODULE() [1/2]

DRIVER_MODULE ( axge  ,
uhub  ,
axge_driver  ,
axge_devclass  ,
NULL  ,
NULL   
)

◆ DRIVER_MODULE() [2/2]

DRIVER_MODULE ( miibus  ,
axge  ,
miibus_driver  ,
miibus_devclass  ,
NULL  ,
NULL   
)

◆ MODULE_DEPEND() [1/4]

MODULE_DEPEND ( axge  ,
ether  ,
,
,
 
)

◆ MODULE_DEPEND() [2/4]

MODULE_DEPEND ( axge  ,
miibus  ,
,
,
 
)

◆ MODULE_DEPEND() [3/4]

MODULE_DEPEND ( axge  ,
uether  ,
,
,
 
)

◆ MODULE_DEPEND() [4/4]

MODULE_DEPEND ( axge  ,
usb  ,
,
,
 
)

◆ MODULE_VERSION()

MODULE_VERSION ( axge  ,
 
)

◆ USB_PNP_HOST_INFO()

USB_PNP_HOST_INFO ( axge_devs  )

Variable Documentation

◆ axge_attach

device_attach_t axge_attach
static

Definition at line 101 of file if_axge.c.

◆ axge_attach_post

uether_fn_t axge_attach_post
static

Definition at line 111 of file if_axge.c.

◆ axge_bulk_read_callback

usb_callback_t axge_bulk_read_callback
static

Definition at line 104 of file if_axge.c.

◆ 

const struct { ... } axge_bulk_size[]
Initial value:
= {
{ 7, 0x4f, 0x00, 0x12, 0xff },
{ 7, 0x20, 0x03, 0x16, 0xff },
{ 7, 0xae, 0x07, 0x18, 0xff },
{ 7, 0xcc, 0x4c, 0x18, 0x08 }
}

Referenced by axge_miibus_statchg().

◆ axge_bulk_write_callback

usb_callback_t axge_bulk_write_callback
static

Definition at line 105 of file if_axge.c.

◆ axge_config

const struct usb_config axge_config[AXGE_N_TRANSFER]
static
Initial value:
= {
.type = UE_BULK,
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_OUT,
.frames = AXGE_N_FRAMES,
.bufsize = AXGE_N_FRAMES * MCLBYTES,
.flags = {.pipe_bof = 1,.force_short_xfer = 1,},
.timeout = 10000,
},
.type = UE_BULK,
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_IN,
.bufsize = 65536,
.flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
.timeout = 0,
},
}
static usb_callback_t axge_bulk_write_callback
Definition: if_axge.c:105
static usb_callback_t axge_bulk_read_callback
Definition: if_axge.c:104
#define AXGE_N_FRAMES
Definition: if_axgereg.h:156
@ AXGE_BULK_DT_RD
Definition: if_axgereg.h:152
@ AXGE_BULK_DT_WR
Definition: if_axgereg.h:151
#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 152 of file if_axge.c.

Referenced by axge_attach().

◆ axge_detach

device_detach_t axge_detach
static

Definition at line 102 of file if_axge.c.

Referenced by axge_attach().

◆ axge_devclass

devclass_t axge_devclass
static

Definition at line 194 of file if_axge.c.

◆ axge_devs

const STRUCT_USB_HOST_ID axge_devs[]
static
Initial value:
= {
#define AXGE_DEV(v,p)
AXGE_DEV(ASIX, AX88178A),
AXGE_DEV(ASIX, AX88179),
AXGE_DEV(BELKIN, B2B128),
AXGE_DEV(DLINK, DUB1312),
AXGE_DEV(LENOVO, GIGALAN),
AXGE_DEV(SITECOMEU, LN032),
}
#define AXGE_DEV(v, p)

Definition at line 74 of file if_axge.c.

Referenced by axge_probe().

◆ axge_driver

driver_t axge_driver
static
Initial value:
= {
.name = "axge",
.methods = axge_methods,
.size = sizeof(struct axge_softc),
}
static device_method_t axge_methods[]
Definition: if_axge.c:174

Definition at line 188 of file if_axge.c.

◆ axge_init

uether_fn_t axge_init
static

Definition at line 112 of file if_axge.c.

◆ axge_methods

device_method_t axge_methods[]
static
Initial value:
= {
DEVMETHOD(device_probe, axge_probe),
DEVMETHOD(device_attach, axge_attach),
DEVMETHOD(device_detach, axge_detach),
DEVMETHOD(miibus_readreg, axge_miibus_readreg),
DEVMETHOD(miibus_writereg, axge_miibus_writereg),
DEVMETHOD(miibus_statchg, axge_miibus_statchg),
DEVMETHOD_END
}
static miibus_writereg_t axge_miibus_writereg
Definition: if_axge.c:108
static device_probe_t axge_probe
Definition: if_axge.c:100
static device_detach_t axge_detach
Definition: if_axge.c:102
static miibus_readreg_t axge_miibus_readreg
Definition: if_axge.c:107
static device_attach_t axge_attach
Definition: if_axge.c:101
static miibus_statchg_t axge_miibus_statchg
Definition: if_axge.c:109

Definition at line 174 of file if_axge.c.

◆ axge_miibus_readreg

miibus_readreg_t axge_miibus_readreg
static

Definition at line 107 of file if_axge.c.

◆ axge_miibus_statchg

miibus_statchg_t axge_miibus_statchg
static

Definition at line 109 of file if_axge.c.

◆ axge_miibus_writereg

miibus_writereg_t axge_miibus_writereg
static

Definition at line 108 of file if_axge.c.

◆ axge_probe

device_probe_t axge_probe
static

Definition at line 100 of file if_axge.c.

◆ axge_rxfilter

uether_fn_t axge_rxfilter
static

Definition at line 116 of file if_axge.c.

Referenced by axge_init().

◆ axge_start

uether_fn_t axge_start
static

Definition at line 114 of file if_axge.c.

◆ axge_stop

uether_fn_t axge_stop
static

Definition at line 113 of file if_axge.c.

Referenced by axge_detach(), and axge_init().

◆ axge_tick

uether_fn_t axge_tick
static

Definition at line 115 of file if_axge.c.

◆ axge_ue_methods

const struct usb_ether_methods axge_ue_methods
static
Initial value:
= {
.ue_attach_post = axge_attach_post,
.ue_attach_post_sub = axge_attach_post_sub,
.ue_start = axge_start,
.ue_init = axge_init,
.ue_stop = axge_stop,
.ue_tick = axge_tick,
.ue_setmulti = axge_rxfilter,
.ue_setpromisc = axge_rxfilter,
.ue_mii_upd = axge_ifmedia_upd,
.ue_mii_sts = axge_ifmedia_sts,
}
static void axge_ifmedia_sts(struct ifnet *, struct ifmediareq *)
Definition: if_axge.c:506
static uether_fn_t axge_rxfilter
Definition: if_axge.c:116
static uether_fn_t axge_start
Definition: if_axge.c:114
static int axge_ifmedia_upd(struct ifnet *)
Definition: if_axge.c:484
static int axge_attach_post_sub(struct usb_ether *)
Definition: if_axge.c:453
static uether_fn_t axge_stop
Definition: if_axge.c:113
static uether_fn_t axge_init
Definition: if_axge.c:112
static uether_fn_t axge_tick
Definition: if_axge.c:115
static uether_fn_t axge_attach_post
Definition: if_axge.c:111

Definition at line 205 of file if_axge.c.

Referenced by axge_attach().

◆ ctrl

uint8_t ctrl

Definition at line 86 of file if_axge.c.

◆ ifg

uint8_t ifg

Definition at line 90 of file if_axge.c.

◆ size

◆ timer_h

uint8_t timer_h

Definition at line 88 of file if_axge.c.

◆ timer_l

uint8_t timer_l

Definition at line 87 of file if_axge.c.