FreeBSD kernel usb device Code
if_axe.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/malloc.h>
#include <sys/mbuf.h>
#include <sys/module.h>
#include <sys/mutex.h>
#include <sys/socket.h>
#include <sys/sockio.h>
#include <sys/sysctl.h>
#include <sys/sx.h>
#include <net/if.h>
#include <net/if_var.h>
#include <net/ethernet.h>
#include <net/if_types.h>
#include <net/if_media.h>
#include <net/if_vlan_var.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_axereg.h>
#include "miibus_if.h"
Include dependency graph for if_axe.c:

Go to the source code of this file.

Macros

#define USB_DEBUG_VAR   axe_debug
 
#define AXE_178_MAX_FRAME_BURST   1
 
#define AXE_CSUM_FEATURES   (CSUM_IP | CSUM_TCP | CSUM_UDP)
 
#define AXE_DEV(v, p, i)   { USB_VPI(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, i) }
 
#define AXE_GPIO_WRITE(x, y)
 

Functions

 __FBSDID ("$FreeBSD$")
 
static int axe_attach_post_sub (struct usb_ether *)
 
static int axe_ifmedia_upd (struct ifnet *)
 
static void axe_ifmedia_sts (struct ifnet *, struct ifmediareq *)
 
static int axe_cmd (struct axe_softc *, int, int, int, void *)
 
static void axe_ax88178_init (struct axe_softc *)
 
static void axe_ax88772_init (struct axe_softc *)
 
static void axe_ax88772_phywake (struct axe_softc *)
 
static void axe_ax88772a_init (struct axe_softc *)
 
static void axe_ax88772b_init (struct axe_softc *)
 
static int axe_get_phyno (struct axe_softc *, int)
 
static int axe_ioctl (struct ifnet *, u_long, caddr_t)
 
static int axe_rx_frame (struct usb_ether *, struct usb_page_cache *, int)
 
static int axe_rxeof (struct usb_ether *, struct usb_page_cache *, unsigned int offset, unsigned int, struct axe_csum_hdr *)
 
static void axe_csum_cfg (struct usb_ether *)
 
 DRIVER_MODULE (axe, uhub, axe_driver, axe_devclass, NULL, 0)
 
 DRIVER_MODULE (miibus, axe, miibus_driver, miibus_devclass, 0, 0)
 
 MODULE_DEPEND (axe, uether, 1, 1, 1)
 
 MODULE_DEPEND (axe, usb, 1, 1, 1)
 
 MODULE_DEPEND (axe, ether, 1, 1, 1)
 
 MODULE_DEPEND (axe, miibus, 1, 1, 1)
 
 MODULE_VERSION (axe, 1)
 
 USB_PNP_HOST_INFO (axe_devs)
 
static int axe_miibus_readreg (device_t dev, int phy, int reg)
 
static int axe_miibus_writereg (device_t dev, int phy, int reg, int val)
 
static void axe_miibus_statchg (device_t dev)
 
static u_int axe_hash_maddr (void *arg, struct sockaddr_dl *sdl, u_int cnt)
 
static void axe_setmulti (struct usb_ether *ue)
 
static void axe_reset (struct axe_softc *sc)
 
static void axe_attach_post (struct usb_ether *ue)
 
static int axe_probe (device_t dev)
 
static int axe_attach (device_t dev)
 
static int axe_detach (device_t dev)
 
static void axe_bulk_read_callback (struct usb_xfer *xfer, usb_error_t error)
 
static void axe_bulk_write_callback (struct usb_xfer *xfer, usb_error_t error)
 
static void axe_tick (struct usb_ether *ue)
 
static void axe_start (struct usb_ether *ue)
 
static void axe_init (struct usb_ether *ue)
 
static void axe_setpromisc (struct usb_ether *ue)
 
static void axe_stop (struct usb_ether *ue)
 

Variables

static const STRUCT_USB_HOST_ID axe_devs []
 
static device_probe_t axe_probe
 
static device_attach_t axe_attach
 
static device_detach_t axe_detach
 
static usb_callback_t axe_bulk_read_callback
 
static usb_callback_t axe_bulk_write_callback
 
static miibus_readreg_t axe_miibus_readreg
 
static miibus_writereg_t axe_miibus_writereg
 
static miibus_statchg_t axe_miibus_statchg
 
static uether_fn_t axe_attach_post
 
static uether_fn_t axe_init
 
static uether_fn_t axe_stop
 
static uether_fn_t axe_start
 
static uether_fn_t axe_tick
 
static uether_fn_t axe_setmulti
 
static uether_fn_t axe_setpromisc
 
static const struct usb_config axe_config [AXE_N_TRANSFER]
 
static const struct ax88772b_mfb ax88772b_mfb_table []
 
static device_method_t axe_methods []
 
static driver_t axe_driver
 
static devclass_t axe_devclass
 
static const struct usb_ether_methods axe_ue_methods
 

Macro Definition Documentation

◆ AXE_178_MAX_FRAME_BURST

#define AXE_178_MAX_FRAME_BURST   1

Definition at line 134 of file if_axe.c.

◆ AXE_CSUM_FEATURES

#define AXE_CSUM_FEATURES   (CSUM_IP | CSUM_TCP | CSUM_UDP)

Definition at line 136 of file if_axe.c.

◆ AXE_DEV

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

◆ AXE_GPIO_WRITE

#define AXE_GPIO_WRITE (   x,
 
)
Value:
do { \
axe_cmd(sc, AXE_CMD_WRITE_GPIO, 0, (x), NULL); \
uether_pause(ue, (y)); \
} while (0)
#define AXE_CMD_WRITE_GPIO
Definition: if_axereg.h:91

Definition at line 546 of file if_axe.c.

◆ USB_DEBUG_VAR

#define USB_DEBUG_VAR   axe_debug

Definition at line 112 of file if_axe.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ axe_attach()

◆ axe_attach_post()

◆ axe_attach_post_sub()

◆ axe_ax88178_init()

◆ axe_ax88772_init()

static void axe_ax88772_init ( struct axe_softc sc)
static

Definition at line 669 of file if_axe.c.

References AXE_772_PHY_NO_EPHY, axe_cmd(), AXE_CMD_RXCTL_WRITE, AXE_CMD_SW_PHY_SELECT, AXE_CMD_SW_RESET_REG, AXE_CMD_WRITE_GPIO, AXE_SW_RESET_CLEAR, AXE_SW_RESET_IPPD, AXE_SW_RESET_IPRL, AXE_SW_RESET_PRL, axe_softc::sc_phyno, axe_softc::sc_ue, and uether_pause().

Referenced by axe_attach_post(), and axe_reset().

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

◆ axe_ax88772_phywake()

static void axe_ax88772_phywake ( struct axe_softc sc)
static

◆ axe_ax88772a_init()

static void axe_ax88772a_init ( struct axe_softc sc)
static

Definition at line 740 of file if_axe.c.

References axe_ax88772_phywake(), axe_cmd(), AXE_CMD_RXCTL_WRITE, AXE_GPIO_RELOAD_EEPROM, AXE_GPIO_WRITE, and axe_softc::sc_ue.

Referenced by axe_attach_post(), and axe_reset().

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

◆ axe_ax88772b_init()

static void axe_ax88772b_init ( struct axe_softc sc)
static

Definition at line 753 of file if_axe.c.

References axe_ax88772_phywake(), axe_cmd(), AXE_CMD_RXCTL_WRITE, AXE_CMD_SROM_READ, AXE_EEPROM_772B_NODE_ID, AXE_EEPROM_772B_PHY_PWRCFG, AXE_GPIO_RELOAD_EEPROM, AXE_GPIO_WRITE, axe_softc::sc_pwrcfg, axe_softc::sc_ue, and usb_ether::ue_eaddr.

Referenced by axe_attach_post(), and axe_reset().

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

◆ axe_bulk_read_callback()

◆ axe_bulk_write_callback()

◆ axe_cmd()

◆ axe_csum_cfg()

static void axe_csum_cfg ( struct usb_ether ue)
static

◆ axe_detach()

static int axe_detach ( device_t  dev)
static

Definition at line 977 of file if_axe.c.

References AXE_N_TRANSFER, dev, axe_softc::sc_mtx, axe_softc::sc_ue, axe_softc::sc_xfer, uether_ifdetach(), and usbd_transfer_unsetup().

Here is the call graph for this function:

◆ axe_get_phyno()

static int axe_get_phyno ( struct axe_softc sc,
int  sel 
)
static

Definition at line 523 of file if_axe.c.

References AXE_PHY_NO, AXE_PHY_TYPE, PHY_TYPE_100_HOME, PHY_TYPE_GIG, PHY_TYPE_NON_SUP, PHY_TYPE_RSVD, PHY_TYPE_SPECIAL, and axe_softc::sc_phyaddrs.

Referenced by axe_attach_post().

Here is the caller graph for this function:

◆ axe_hash_maddr()

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

Definition at line 485 of file if_axe.c.

Referenced by axe_setmulti().

Here is the caller graph for this function:

◆ axe_ifmedia_sts()

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

Definition at line 472 of file if_axe.c.

References AXE_LOCK, AXE_UNLOCK, and GET_MII.

◆ axe_ifmedia_upd()

static int axe_ifmedia_upd ( struct ifnet *  ifp)
static

Definition at line 453 of file if_axe.c.

References AXE_LOCK_ASSERT, error, and GET_MII.

Referenced by axe_init().

Here is the caller graph for this function:

◆ axe_init()

◆ axe_ioctl()

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

Definition at line 1466 of file if_axe.c.

References AXE_CSUM_FEATURES, AXE_LOCK, AXE_UNLOCK, data, error, uether_getsc(), uether_init(), and uether_ioctl().

Referenced by axe_attach_post_sub().

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

◆ axe_miibus_readreg()

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

Definition at line 323 of file if_axe.c.

References axe_cmd(), AXE_CMD_MII_OPMODE_HW, AXE_CMD_MII_OPMODE_SW, AXE_CMD_MII_READ_REG, AXE_IS_772, AXE_LOCK, AXE_UNLOCK, dev, reg, axe_softc::sc_mtx, and val.

Here is the call graph for this function:

◆ axe_miibus_statchg()

◆ axe_miibus_writereg()

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

Definition at line 354 of file if_axe.c.

References axe_cmd(), AXE_CMD_MII_OPMODE_HW, AXE_CMD_MII_OPMODE_SW, AXE_CMD_MII_WRITE_REG, AXE_LOCK, AXE_UNLOCK, dev, reg, axe_softc::sc_mtx, and val.

Here is the call graph for this function:

◆ axe_probe()

static int axe_probe ( device_t  dev)
static

◆ axe_reset()

static void axe_reset ( struct axe_softc sc)
static

◆ axe_rx_frame()

static int axe_rx_frame ( struct usb_ether ue,
struct usb_page_cache pc,
int  actlen 
)
static

◆ axe_rxeof()

static int axe_rxeof ( struct usb_ether ue,
struct usb_page_cache pc,
unsigned int  offset,
unsigned int  len,
struct axe_csum_hdr csum_hdr 
)
static

Definition at line 1108 of file if_axe.c.

References AXE_CSUM_HDR_L3_CSUM_ERR, AXE_CSUM_HDR_L3_TYPE_IPV4, AXE_CSUM_HDR_L4_CSUM_ERR, AXE_CSUM_HDR_L4_TYPE_MASK, AXE_CSUM_HDR_L4_TYPE_TCP, AXE_CSUM_HDR_L4_TYPE_UDP, axe_csum_hdr::cstatus, len, offset, usb_ether::ue_ifp, usb_ether::ue_rxq, and usbd_copy_out().

Referenced by axe_rx_frame().

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

◆ axe_setmulti()

static void axe_setmulti ( struct usb_ether ue)
static

Definition at line 497 of file if_axe.c.

References axe_cmd(), AXE_CMD_RXCTL_READ, AXE_CMD_RXCTL_WRITE, AXE_CMD_WRITE_MCAST, axe_hash_maddr(), AXE_LOCK_ASSERT, AXE_RXCMD_ALLMULTI, uether_getifp(), and uether_getsc().

Here is the call graph for this function:

◆ axe_setpromisc()

static void axe_setpromisc ( struct usb_ether ue)
static

Definition at line 1426 of file if_axe.c.

References axe_cmd(), AXE_CMD_RXCTL_READ, AXE_CMD_RXCTL_WRITE, AXE_RXCMD_PROMISC, axe_setmulti, uether_getifp(), and uether_getsc().

Here is the call graph for this function:

◆ axe_start()

static void axe_start ( struct usb_ether ue)
static

Definition at line 1288 of file if_axe.c.

References AXE_BULK_DT_RD, AXE_BULK_DT_WR, axe_softc::sc_xfer, uether_getsc(), and usbd_transfer_start().

Here is the call graph for this function:

◆ axe_stop()

static void axe_stop ( struct usb_ether ue)
static

Definition at line 1448 of file if_axe.c.

References AXE_BULK_DT_RD, AXE_BULK_DT_WR, AXE_LOCK_ASSERT, axe_softc::sc_flags, axe_softc::sc_xfer, uether_getifp(), uether_getsc(), and usbd_transfer_stop().

Here is the call graph for this function:

◆ axe_tick()

static void axe_tick ( struct usb_ether ue)
static

Definition at line 1272 of file if_axe.c.

References AXE_FLAG_LINK, AXE_LOCK_ASSERT, axe_miibus_statchg, axe_start, GET_MII, axe_softc::sc_flags, usb_ether::ue_dev, and uether_getsc().

Here is the call graph for this function:

◆ DRIVER_MODULE() [1/2]

DRIVER_MODULE ( axe  ,
uhub  ,
axe_driver  ,
axe_devclass  ,
NULL  ,
 
)

◆ DRIVER_MODULE() [2/2]

DRIVER_MODULE ( miibus  ,
axe  ,
miibus_driver  ,
miibus_devclass  ,
,
 
)

◆ MODULE_DEPEND() [1/4]

MODULE_DEPEND ( axe  ,
ether  ,
,
,
 
)

◆ MODULE_DEPEND() [2/4]

MODULE_DEPEND ( axe  ,
miibus  ,
,
,
 
)

◆ MODULE_DEPEND() [3/4]

MODULE_DEPEND ( axe  ,
uether  ,
,
,
 
)

◆ MODULE_DEPEND() [4/4]

MODULE_DEPEND ( axe  ,
usb  ,
,
,
 
)

◆ MODULE_VERSION()

MODULE_VERSION ( axe  ,
 
)

◆ USB_PNP_HOST_INFO()

USB_PNP_HOST_INFO ( axe_devs  )

Variable Documentation

◆ ax88772b_mfb_table

const struct ax88772b_mfb ax88772b_mfb_table[]
static
Initial value:
= {
{ 0x8000, 0x8001, 2048 },
{ 0x8100, 0x8147, 4096},
{ 0x8200, 0x81EB, 6144},
{ 0x8300, 0x83D7, 8192},
{ 0x8400, 0x851E, 16384},
{ 0x8500, 0x8666, 20480},
{ 0x8600, 0x87AE, 24576},
{ 0x8700, 0x8A3D, 32768}
}

Definition at line 246 of file if_axe.c.

Referenced by axe_init().

◆ axe_attach

device_attach_t axe_attach
static

Definition at line 189 of file if_axe.c.

◆ axe_attach_post

uether_fn_t axe_attach_post
static

Definition at line 199 of file if_axe.c.

◆ axe_bulk_read_callback

usb_callback_t axe_bulk_read_callback
static

Definition at line 192 of file if_axe.c.

◆ axe_bulk_write_callback

usb_callback_t axe_bulk_write_callback
static

Definition at line 193 of file if_axe.c.

◆ axe_config

const struct usb_config axe_config[AXE_N_TRANSFER]
static
Initial value:
= {
.type = UE_BULK,
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_OUT,
.frames = 16,
.bufsize = 16 * MCLBYTES,
.flags = {.pipe_bof = 1,.force_short_xfer = 1,},
.timeout = 10000,
},
.type = UE_BULK,
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_IN,
.bufsize = 16384,
.flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
.timeout = 0,
},
}
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
@ AXE_BULK_DT_WR
Definition: if_axereg.h:330
@ AXE_BULK_DT_RD
Definition: if_axereg.h:331
#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 223 of file if_axe.c.

Referenced by axe_attach().

◆ axe_detach

device_detach_t axe_detach
static

Definition at line 190 of file if_axe.c.

Referenced by axe_attach().

◆ axe_devclass

devclass_t axe_devclass
static

Definition at line 277 of file if_axe.c.

◆ axe_devs

const STRUCT_USB_HOST_ID axe_devs[]
static

Definition at line 150 of file if_axe.c.

Referenced by axe_probe().

◆ axe_driver

driver_t axe_driver
static
Initial value:
= {
.name = "axe",
.methods = axe_methods,
.size = sizeof(struct axe_softc),
}
static device_method_t axe_methods[]
Definition: if_axe.c:257

Definition at line 271 of file if_axe.c.

◆ axe_init

uether_fn_t axe_init
static

Definition at line 200 of file if_axe.c.

◆ axe_methods

device_method_t axe_methods[]
static
Initial value:
= {
DEVMETHOD(device_probe, axe_probe),
DEVMETHOD(device_attach, axe_attach),
DEVMETHOD(device_detach, axe_detach),
DEVMETHOD(miibus_readreg, axe_miibus_readreg),
DEVMETHOD(miibus_writereg, axe_miibus_writereg),
DEVMETHOD(miibus_statchg, axe_miibus_statchg),
DEVMETHOD_END
}
static miibus_statchg_t axe_miibus_statchg
Definition: if_axe.c:197
static device_probe_t axe_probe
Definition: if_axe.c:188
static device_detach_t axe_detach
Definition: if_axe.c:190
static miibus_readreg_t axe_miibus_readreg
Definition: if_axe.c:195
static device_attach_t axe_attach
Definition: if_axe.c:189
static miibus_writereg_t axe_miibus_writereg
Definition: if_axe.c:196

Definition at line 257 of file if_axe.c.

◆ axe_miibus_readreg

miibus_readreg_t axe_miibus_readreg
static

Definition at line 195 of file if_axe.c.

Referenced by axe_ax88178_init().

◆ axe_miibus_statchg

miibus_statchg_t axe_miibus_statchg
static

Definition at line 197 of file if_axe.c.

Referenced by axe_tick().

◆ axe_miibus_writereg

miibus_writereg_t axe_miibus_writereg
static

Definition at line 196 of file if_axe.c.

Referenced by axe_ax88178_init().

◆ axe_probe

device_probe_t axe_probe
static

Definition at line 188 of file if_axe.c.

◆ axe_setmulti

uether_fn_t axe_setmulti
static

Definition at line 204 of file if_axe.c.

Referenced by axe_init(), and axe_setpromisc().

◆ axe_setpromisc

uether_fn_t axe_setpromisc
static

Definition at line 205 of file if_axe.c.

◆ axe_start

uether_fn_t axe_start
static

Definition at line 202 of file if_axe.c.

Referenced by axe_tick().

◆ axe_stop

uether_fn_t axe_stop
static

Definition at line 201 of file if_axe.c.

Referenced by axe_init().

◆ axe_tick

uether_fn_t axe_tick
static

Definition at line 203 of file if_axe.c.

◆ axe_ue_methods

const struct usb_ether_methods axe_ue_methods
static
Initial value:
= {
.ue_attach_post = axe_attach_post,
.ue_attach_post_sub = axe_attach_post_sub,
.ue_start = axe_start,
.ue_init = axe_init,
.ue_stop = axe_stop,
.ue_tick = axe_tick,
.ue_setmulti = axe_setmulti,
.ue_setpromisc = axe_setpromisc,
.ue_mii_upd = axe_ifmedia_upd,
.ue_mii_sts = axe_ifmedia_sts,
}
static uether_fn_t axe_attach_post
Definition: if_axe.c:199
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_attach_post_sub(struct usb_ether *)
Definition: if_axe.c:867
static void axe_ifmedia_sts(struct ifnet *, struct ifmediareq *)
Definition: if_axe.c:472
static uether_fn_t axe_setpromisc
Definition: if_axe.c:205
static uether_fn_t axe_tick
Definition: if_axe.c:203
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

Definition at line 288 of file if_axe.c.

Referenced by axe_attach().