FreeBSD kernel usb device Code
usb_ethernet.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/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/usb_process.h>
#include <dev/usb/net/usb_ethernet.h>
Include dependency graph for usb_ethernet.c:

Go to the source code of this file.

Macros

#define UE_LOCK(_ue)   mtx_lock((_ue)->ue_mtx)
 
#define UE_UNLOCK(_ue)   mtx_unlock((_ue)->ue_mtx)
 
#define UE_LOCK_ASSERT(_ue, t)   mtx_assert((_ue)->ue_mtx, t)
 

Functions

 __FBSDID ("$FreeBSD$")
 
static SYSCTL_NODE (_net, OID_AUTO, ue, CTLFLAG_RD|CTLFLAG_MPSAFE, 0, "USB Ethernet parameters")
 
 MODULE_DEPEND (uether, usb, 1, 1, 1)
 
 MODULE_DEPEND (uether, miibus, 1, 1, 1)
 
static void ue_init (void *)
 
static void ue_start (struct ifnet *)
 
static int ue_ifmedia_upd (struct ifnet *)
 
static void ue_watchdog (void *)
 
uint8_t uether_pause (struct usb_ether *ue, unsigned int _ticks)
 
static void ue_queue_command (struct usb_ether *ue, usb_proc_callback_t *fn, struct usb_proc_msg *t0, struct usb_proc_msg *t1)
 
struct ifnet * uether_getifp (struct usb_ether *ue)
 
struct mii_data * uether_getmii (struct usb_ether *ue)
 
void * uether_getsc (struct usb_ether *ue)
 
static int ue_sysctl_parent (SYSCTL_HANDLER_ARGS)
 
int uether_ifattach (struct usb_ether *ue)
 
void uether_ifattach_wait (struct usb_ether *ue)
 
static void ue_attach_post_task (struct usb_proc_msg *_task)
 
void uether_ifdetach (struct usb_ether *ue)
 
uint8_t uether_is_gone (struct usb_ether *ue)
 
void uether_init (void *arg)
 
static void ue_start_task (struct usb_proc_msg *_task)
 
static void ue_stop_task (struct usb_proc_msg *_task)
 
void uether_start (struct ifnet *ifp)
 
static void ue_promisc_task (struct usb_proc_msg *_task)
 
static void ue_setmulti_task (struct usb_proc_msg *_task)
 
int uether_ifmedia_upd (struct ifnet *ifp)
 
static void ue_ifmedia_task (struct usb_proc_msg *_task)
 
static void ue_tick_task (struct usb_proc_msg *_task)
 
int uether_ioctl (struct ifnet *ifp, u_long command, caddr_t data)
 
static int uether_modevent (module_t mod, int type, void *data)
 
struct mbuf * uether_newbuf (void)
 
int uether_rxmbuf (struct usb_ether *ue, struct mbuf *m, unsigned int len)
 
int uether_rxbuf (struct usb_ether *ue, struct usb_page_cache *pc, unsigned int offset, unsigned int len)
 
void uether_rxflush (struct usb_ether *ue)
 
 DECLARE_MODULE (uether, uether_mod, SI_SUB_DRIVERS, SI_ORDER_ANY)
 
 MODULE_VERSION (uether, 1)
 

Variables

static struct unrhdr * ueunit
 
static usb_proc_callback_t ue_attach_post_task
 
static usb_proc_callback_t ue_promisc_task
 
static usb_proc_callback_t ue_setmulti_task
 
static usb_proc_callback_t ue_ifmedia_task
 
static usb_proc_callback_t ue_tick_task
 
static usb_proc_callback_t ue_start_task
 
static usb_proc_callback_t ue_stop_task
 
static moduledata_t uether_mod
 

Macro Definition Documentation

◆ UE_LOCK

#define UE_LOCK (   _ue)    mtx_lock((_ue)->ue_mtx)

Definition at line 66 of file usb_ethernet.c.

◆ UE_LOCK_ASSERT

#define UE_LOCK_ASSERT (   _ue,
 
)    mtx_assert((_ue)->ue_mtx, t)

Definition at line 68 of file usb_ethernet.c.

◆ UE_UNLOCK

#define UE_UNLOCK (   _ue)    mtx_unlock((_ue)->ue_mtx)

Definition at line 67 of file usb_ethernet.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ DECLARE_MODULE()

DECLARE_MODULE ( uether  ,
uether_mod  ,
SI_SUB_DRIVERS  ,
SI_ORDER_ANY   
)

◆ MODULE_DEPEND() [1/2]

MODULE_DEPEND ( uether  ,
miibus  ,
,
,
 
)

◆ MODULE_DEPEND() [2/2]

MODULE_DEPEND ( uether  ,
usb  ,
,
,
 
)

◆ MODULE_VERSION()

MODULE_VERSION ( uether  ,
 
)

◆ SYSCTL_NODE()

static SYSCTL_NODE ( _net  ,
OID_AUTO  ,
ue  ,
CTLFLAG_RD|  CTLFLAG_MPSAFE,
,
"USB Ethernet parameters"   
)
static

◆ ue_attach_post_task()

◆ ue_ifmedia_task()

static void ue_ifmedia_task ( struct usb_proc_msg _task)
static

◆ ue_ifmedia_upd()

static int ue_ifmedia_upd ( struct ifnet *  ifp)
static

Definition at line 457 of file usb_ethernet.c.

References usb_ether_cfg_task::hdr, ue_ifmedia_task, UE_LOCK, usb_ether::ue_media_task, ue_queue_command(), and UE_UNLOCK.

Referenced by ue_attach_post_task(), and uether_ifmedia_upd().

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

◆ ue_init()

static void ue_init ( void *  arg)
static

Definition at line 365 of file usb_ethernet.c.

References usb_ether_cfg_task::hdr, UE_LOCK, ue_queue_command(), ue_start_task, usb_ether::ue_sync_task, and UE_UNLOCK.

Referenced by ue_attach_post_task(), and uether_init().

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

◆ ue_promisc_task()

static void ue_promisc_task ( struct usb_proc_msg _task)
static

◆ ue_queue_command()

static void ue_queue_command ( struct usb_ether ue,
usb_proc_callback_t fn,
struct usb_proc_msg t0,
struct usb_proc_msg t1 
)
static

Definition at line 105 of file usb_ethernet.c.

References usb_ether_cfg_task::hdr, usb_proc_msg::pm_callback, usb_ether_cfg_task::ue, UE_LOCK_ASSERT, ue_start_task, ue_stop_task, usb_ether::ue_tq, usb_proc_is_gone(), usb_proc_msignal(), and usb_proc_mwait().

Referenced by ue_ifmedia_upd(), ue_init(), ue_watchdog(), uether_ifattach(), and uether_ioctl().

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

◆ ue_setmulti_task()

static void ue_setmulti_task ( struct usb_proc_msg _task)
static

◆ ue_start()

static void ue_start ( struct ifnet *  ifp)
static

Definition at line 417 of file usb_ethernet.c.

References UE_LOCK, usb_ether::ue_methods, usb_ether_methods::ue_start, and UE_UNLOCK.

Referenced by ue_attach_post_task(), and uether_start().

Here is the caller graph for this function:

◆ ue_start_task()

static void ue_start_task ( struct usb_proc_msg _task)
static

◆ ue_stop_task()

static void ue_stop_task ( struct usb_proc_msg _task)
static

◆ ue_sysctl_parent()

static int ue_sysctl_parent ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 154 of file usb_ethernet.c.

References name, req, and usb_ether::ue_dev.

Referenced by ue_attach_post_task().

Here is the caller graph for this function:

◆ ue_tick_task()

static void ue_tick_task ( struct usb_proc_msg _task)
static

◆ ue_watchdog()

static void ue_watchdog ( void *  arg)
static

Definition at line 483 of file usb_ethernet.c.

References usb_ether_cfg_task::hdr, usb_ether::ue_ifp, ue_queue_command(), ue_tick_task, usb_ether::ue_tick_task, ue_watchdog(), usb_ether::ue_watchdog, and usb_callout_reset.

Referenced by ue_start_task(), and ue_watchdog().

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

◆ uether_getifp()

struct ifnet * uether_getifp ( struct usb_ether ue)

Definition at line 136 of file usb_ethernet.c.

References usb_ether::ue_ifp.

Referenced by aue_bulk_read_callback(), aue_bulk_write_callback(), aue_init(), aue_intr_callback(), aue_setmulti(), aue_setpromisc(), aue_stop(), axe_bulk_write_callback(), axe_csum_cfg(), axe_init(), axe_miibus_statchg(), axe_setmulti(), axe_setpromisc(), axe_stop(), axge_bulk_write_callback(), axge_csum_cfg(), axge_init(), axge_miibus_statchg(), axge_rxfilter(), axge_stop(), cdce_attach_post_sub(), cdce_bulk_write_callback(), cdce_init(), cdce_intr_read_callback(), cdce_set_filter(), cdce_stop(), cdceem_bulk_write_callback(), cdceem_handle_data(), cdceem_init(), cdceem_send_data(), cdceem_stop(), cue_bulk_read_callback(), cue_bulk_write_callback(), cue_init(), cue_setmulti(), cue_setpromisc(), cue_stop(), cue_tick(), ipheth_bulk_write_callback(), ipheth_init(), kue_bulk_read_callback(), kue_bulk_write_callback(), kue_init(), kue_setmulti(), kue_setpromisc(), kue_stop(), lan78xx_miibus_statchg(), mos_bulk_read_callback(), mos_bulk_write_callback(), mos_init(), mos_intr_callback(), mos_setmulti(), mos_setpromisc(), mos_stop(), muge_bulk_read_callback(), muge_bulk_write_callback(), muge_init(), muge_sethwcsum(), muge_setmulti(), muge_setpromisc(), muge_stop(), rue_bulk_read_callback(), rue_bulk_write_callback(), rue_init(), rue_intr_callback(), rue_setmulti(), rue_setpromisc(), rue_stop(), smsc_bulk_read_callback(), smsc_bulk_write_callback(), smsc_init(), smsc_miibus_statchg(), smsc_sethwcsum(), smsc_setmulti(), smsc_setpromisc(), smsc_stop(), udav_bulk_read_callback(), udav_bulk_write_callback(), udav_init(), udav_setmulti(), udav_setpromisc(), udav_stop(), ure_bulk_read_callback(), ure_bulk_write_callback(), ure_init(), ure_link_state(), ure_miibus_statchg(), ure_rtl8153b_nic_reset(), ure_rxfilter(), ure_stop(), ure_tick(), urndis_bulk_read_callback(), urndis_bulk_write_callback(), urndis_init(), and urndis_stop().

◆ uether_getmii()

struct mii_data * uether_getmii ( struct usb_ether ue)

Definition at line 142 of file usb_ethernet.c.

References usb_ether::ue_miibus.

Referenced by lan78xx_miibus_statchg(), muge_ifmedia_sts(), muge_ifmedia_upd(), muge_tick(), smsc_ifmedia_sts(), smsc_ifmedia_upd(), smsc_miibus_statchg(), and smsc_tick().

Here is the caller graph for this function:

◆ uether_getsc()

void * uether_getsc ( struct usb_ether ue)

Definition at line 148 of file usb_ethernet.c.

References usb_ether::ue_sc.

Referenced by aue_attach_post(), aue_init(), aue_setmulti(), aue_setpromisc(), aue_start(), aue_stop(), aue_tick(), axe_attach_post(), axe_attach_post_sub(), axe_csum_cfg(), axe_init(), axe_ioctl(), axe_rx_frame(), axe_setmulti(), axe_setpromisc(), axe_start(), axe_stop(), axe_tick(), axge_attach_post(), axge_csum_cfg(), axge_init(), axge_ioctl(), axge_rxfilter(), axge_start(), axge_stop(), axge_tick(), cdce_attach_post_sub(), cdce_init(), cdce_ioctl(), cdce_set_filter(), cdce_start(), cdce_stop(), cdceem_init(), cdceem_start(), cdceem_stop(), cue_attach_post(), cue_init(), cue_setmulti(), cue_setpromisc(), cue_start(), cue_stop(), cue_tick(), ipheth_init(), ipheth_start(), ipheth_stop(), ipheth_tick(), kue_attach_post(), kue_init(), kue_setmulti(), kue_setpromisc(), kue_start(), kue_stop(), mos_attach_post(), mos_init(), mos_setmulti(), mos_setpromisc(), mos_start(), mos_stop(), mos_tick(), muge_attach_post(), muge_attach_post_sub(), muge_init(), muge_ioctl(), muge_set_leds(), muge_set_mac_addr(), muge_setmulti(), muge_setpromisc(), muge_start(), muge_stop(), muge_tick(), rue_attach_post(), rue_init(), rue_setmulti(), rue_setpromisc(), rue_start(), rue_stop(), rue_tick(), smsc_attach_post(), smsc_attach_post_sub(), smsc_init(), smsc_ioctl(), smsc_setmulti(), smsc_setpromisc(), smsc_start(), smsc_stop(), smsc_tick(), udav_attach_post(), ure_attach_post(), ure_attach_post_sub(), ure_init(), ure_ioctl(), ure_rxfilter(), ure_start(), ure_stop(), ure_tick(), urndis_init(), urndis_start(), and urndis_stop().

◆ uether_ifattach()

◆ uether_ifattach_wait()

void uether_ifattach_wait ( struct usb_ether ue)

Definition at line 194 of file usb_ethernet.c.

References usb_ether_cfg_task::hdr, UE_LOCK, usb_ether::ue_sync_task, usb_ether::ue_tq, UE_UNLOCK, and usb_proc_mwait().

Referenced by muge_attach().

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

◆ uether_ifdetach()

◆ uether_ifmedia_upd()

int uether_ifmedia_upd ( struct ifnet *  ifp)

Definition at line 450 of file usb_ethernet.c.

References ue_ifmedia_upd().

Referenced by axe_attach_post_sub(), axge_attach_post_sub(), muge_attach_post_sub(), smsc_attach_post_sub(), and ure_attach_post_sub().

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

◆ uether_init()

void uether_init ( void *  arg)

Definition at line 358 of file usb_ethernet.c.

References ue_init().

Referenced by axe_attach_post_sub(), axe_ioctl(), axge_attach_post_sub(), axge_ioctl(), cdce_attach_post_sub(), muge_attach_post_sub(), muge_ioctl(), smsc_attach_post_sub(), smsc_ioctl(), ure_attach_post_sub(), and ure_ioctl().

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

◆ uether_ioctl()

int uether_ioctl ( struct ifnet *  ifp,
u_long  command,
caddr_t  data 
)

◆ uether_is_gone()

uint8_t uether_is_gone ( struct usb_ether ue)

Definition at line 352 of file usb_ethernet.c.

References usb_ether::ue_tq, and usb_proc_is_gone().

Here is the call graph for this function:

◆ uether_modevent()

static int uether_modevent ( module_t  mod,
int  type,
void *  data 
)
static

Definition at line 563 of file usb_ethernet.c.

References type, and ueunit.

◆ uether_newbuf()

struct mbuf * uether_newbuf ( void  )

Definition at line 584 of file usb_ethernet.c.

Referenced by cdce_bulk_read_callback(), cdceem_handle_data(), ipheth_bulk_read_callback(), muge_bulk_read_callback(), smsc_bulk_read_callback(), and uether_rxbuf().

Here is the caller graph for this function:

◆ uether_pause()

◆ uether_rxbuf()

int uether_rxbuf ( struct usb_ether ue,
struct usb_page_cache pc,
unsigned int  offset,
unsigned int  len 
)

Definition at line 616 of file usb_ethernet.c.

References len, offset, usb_ether::ue_ifp, UE_LOCK_ASSERT, usb_ether::ue_rxq, uether_newbuf(), and usbd_copy_out().

Referenced by aue_bulk_read_callback(), cue_bulk_read_callback(), kue_bulk_read_callback(), mos_bulk_read_callback(), rue_bulk_read_callback(), and udav_bulk_read_callback().

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

◆ uether_rxflush()

◆ uether_rxmbuf()

int uether_rxmbuf ( struct usb_ether ue,
struct mbuf *  m,
unsigned int  len 
)

◆ uether_start()

void uether_start ( struct ifnet *  ifp)

Definition at line 410 of file usb_ethernet.c.

References ue_start().

Referenced by axe_attach_post_sub(), axge_attach_post_sub(), cdce_attach_post_sub(), muge_attach_post_sub(), smsc_attach_post_sub(), and ure_attach_post_sub().

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

Variable Documentation

◆ ue_attach_post_task

usb_proc_callback_t ue_attach_post_task
static

Definition at line 75 of file usb_ethernet.c.

Referenced by uether_ifattach().

◆ ue_ifmedia_task

usb_proc_callback_t ue_ifmedia_task
static

Definition at line 78 of file usb_ethernet.c.

Referenced by ue_ifmedia_upd().

◆ ue_promisc_task

usb_proc_callback_t ue_promisc_task
static

Definition at line 76 of file usb_ethernet.c.

Referenced by uether_ioctl().

◆ ue_setmulti_task

usb_proc_callback_t ue_setmulti_task
static

Definition at line 77 of file usb_ethernet.c.

Referenced by uether_ioctl().

◆ ue_start_task

usb_proc_callback_t ue_start_task
static

Definition at line 80 of file usb_ethernet.c.

Referenced by ue_init(), ue_queue_command(), and uether_ioctl().

◆ ue_stop_task

usb_proc_callback_t ue_stop_task
static

Definition at line 81 of file usb_ethernet.c.

Referenced by ue_queue_command(), and uether_ioctl().

◆ ue_tick_task

usb_proc_callback_t ue_tick_task
static

Definition at line 79 of file usb_ethernet.c.

Referenced by ue_watchdog().

◆ uether_mod

moduledata_t uether_mod
static
Initial value:
= {
"uether",
0
}
static int uether_modevent(module_t mod, int type, void *data)
Definition: usb_ethernet.c:563

Definition at line 577 of file usb_ethernet.c.

◆ ueunit

struct unrhdr* ueunit
static

Definition at line 73 of file usb_ethernet.c.

Referenced by ue_attach_post_task(), uether_ifdetach(), and uether_modevent().