FreeBSD kernel usb device Code
if_smsc.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/kernel.h>
#include <sys/bus.h>
#include <sys/module.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/condvar.h>
#include <sys/socket.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 <sys/random.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 <netinet/in.h>
#include <netinet/ip.h>
#include "opt_platform.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_smscreg.h>
#include "miibus_if.h"
Include dependency graph for if_smsc.c:

Go to the source code of this file.

Macros

#define USB_DEBUG_VAR   smsc_debug
 
#define SMSC_DEV(p, i)   { USB_VPI(USB_VENDOR_SMC2, USB_PRODUCT_SMC2_##p, i) }
 
#define smsc_dbg_printf(sc, fmt, args...)   do { } while (0)
 
#define smsc_warn_printf(sc, fmt, args...)    device_printf((sc)->sc_ue.ue_dev, "warning: " fmt, ##args)
 
#define smsc_err_printf(sc, fmt, args...)    device_printf((sc)->sc_ue.ue_dev, "error: " fmt, ##args)
 
#define ETHER_IS_VALID(addr)    (!ETHER_IS_MULTICAST(addr) && !ETHER_IS_ZERO(addr))
 

Functions

 __FBSDID ("$FreeBSD$")
 
 SYSCTL_NODE (_hw_usb, OID_AUTO, smsc, CTLFLAG_RW|CTLFLAG_MPSAFE, 0, "USB smsc")
 
 SYSCTL_BOOL (_hw_usb_smsc, OID_AUTO, smsc_rx_packet_batching, CTLFLAG_RDTUN, &smsc_rx_packet_batching, 0, "If set, allows packet batching to increase throughput and latency. " "Else throughput and latency is decreased.")
 
static int smsc_attach_post_sub (struct usb_ether *ue)
 
static int smsc_ifmedia_upd (struct ifnet *)
 
static void smsc_ifmedia_sts (struct ifnet *, struct ifmediareq *)
 
static int smsc_chip_init (struct smsc_softc *sc)
 
static int smsc_ioctl (struct ifnet *ifp, u_long cmd, caddr_t data)
 
static int smsc_read_reg (struct smsc_softc *sc, uint32_t off, uint32_t *data)
 
static int smsc_write_reg (struct smsc_softc *sc, uint32_t off, uint32_t data)
 
static int smsc_wait_for_bits (struct smsc_softc *sc, uint32_t reg, uint32_t bits)
 
static int smsc_eeprom_read (struct smsc_softc *sc, uint16_t off, uint8_t *buf, uint16_t buflen)
 
static int smsc_miibus_readreg (device_t dev, int phy, int reg)
 
static int smsc_miibus_writereg (device_t dev, int phy, int reg, int val)
 
static void smsc_miibus_statchg (device_t dev)
 
static uint32_t smsc_hash (uint8_t addr[ETHER_ADDR_LEN])
 
static u_int smsc_hash_maddr (void *arg, struct sockaddr_dl *sdl, u_int cnt)
 
static void smsc_setmulti (struct usb_ether *ue)
 
static void smsc_setpromisc (struct usb_ether *ue)
 
static int smsc_sethwcsum (struct smsc_softc *sc)
 
static int smsc_setmacaddress (struct smsc_softc *sc, const uint8_t *addr)
 
static void smsc_reset (struct smsc_softc *sc)
 
static void smsc_init (struct usb_ether *ue)
 
static void smsc_bulk_read_callback (struct usb_xfer *xfer, usb_error_t error)
 
static void smsc_bulk_write_callback (struct usb_xfer *xfer, usb_error_t error)
 
static void smsc_tick (struct usb_ether *ue)
 
static void smsc_start (struct usb_ether *ue)
 
static void smsc_stop (struct usb_ether *ue)
 
static int smsc_phy_init (struct smsc_softc *sc)
 
static void smsc_attach_post (struct usb_ether *ue)
 
static int smsc_probe (device_t dev)
 
static int smsc_attach (device_t dev)
 
static int smsc_detach (device_t dev)
 
 DRIVER_MODULE (smsc, uhub, smsc_driver, smsc_devclass, NULL, 0)
 
 DRIVER_MODULE (miibus, smsc, miibus_driver, miibus_devclass, 0, 0)
 
 MODULE_DEPEND (smsc, uether, 1, 1, 1)
 
 MODULE_DEPEND (smsc, usb, 1, 1, 1)
 
 MODULE_DEPEND (smsc, ether, 1, 1, 1)
 
 MODULE_DEPEND (smsc, miibus, 1, 1, 1)
 
 MODULE_VERSION (smsc, 1)
 
 USB_PNP_HOST_INFO (smsc_devs)
 

Variables

static bool smsc_rx_packet_batching = 1
 
static const struct usb_device_id smsc_devs []
 
static device_probe_t smsc_probe
 
static device_attach_t smsc_attach
 
static device_detach_t smsc_detach
 
static usb_callback_t smsc_bulk_read_callback
 
static usb_callback_t smsc_bulk_write_callback
 
static miibus_readreg_t smsc_miibus_readreg
 
static miibus_writereg_t smsc_miibus_writereg
 
static miibus_statchg_t smsc_miibus_statchg
 
static uether_fn_t smsc_attach_post
 
static uether_fn_t smsc_init
 
static uether_fn_t smsc_stop
 
static uether_fn_t smsc_start
 
static uether_fn_t smsc_tick
 
static uether_fn_t smsc_setmulti
 
static uether_fn_t smsc_setpromisc
 
static const struct usb_config smsc_config [SMSC_N_TRANSFER]
 
static const struct usb_ether_methods smsc_ue_methods
 
static device_method_t smsc_methods []
 
static driver_t smsc_driver
 
static devclass_t smsc_devclass
 

Macro Definition Documentation

◆ ETHER_IS_VALID

#define ETHER_IS_VALID (   addr)     (!ETHER_IS_MULTICAST(addr) && !ETHER_IS_ZERO(addr))

Definition at line 181 of file if_smsc.c.

◆ smsc_dbg_printf

#define smsc_dbg_printf (   sc,
  fmt,
  args... 
)    do { } while (0)

Definition at line 172 of file if_smsc.c.

◆ SMSC_DEV

#define SMSC_DEV (   p,
 
)    { USB_VPI(USB_VENDOR_SMC2, USB_PRODUCT_SMC2_##p, i) }

◆ smsc_err_printf

#define smsc_err_printf (   sc,
  fmt,
  args... 
)     device_printf((sc)->sc_ue.ue_dev, "error: " fmt, ##args)

Definition at line 178 of file if_smsc.c.

◆ smsc_warn_printf

#define smsc_warn_printf (   sc,
  fmt,
  args... 
)     device_printf((sc)->sc_ue.ue_dev, "warning: " fmt, ##args)

Definition at line 175 of file if_smsc.c.

◆ USB_DEBUG_VAR

#define USB_DEBUG_VAR   smsc_debug

Definition at line 112 of file if_smsc.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ DRIVER_MODULE() [1/2]

DRIVER_MODULE ( miibus  ,
smsc  ,
miibus_driver  ,
miibus_devclass  ,
,
 
)

◆ DRIVER_MODULE() [2/2]

DRIVER_MODULE ( smsc  ,
uhub  ,
smsc_driver  ,
smsc_devclass  ,
NULL  ,
 
)

◆ MODULE_DEPEND() [1/4]

MODULE_DEPEND ( smsc  ,
ether  ,
,
,
 
)

◆ MODULE_DEPEND() [2/4]

MODULE_DEPEND ( smsc  ,
miibus  ,
,
,
 
)

◆ MODULE_DEPEND() [3/4]

MODULE_DEPEND ( smsc  ,
uether  ,
,
,
 
)

◆ MODULE_DEPEND() [4/4]

MODULE_DEPEND ( smsc  ,
usb  ,
,
,
 
)

◆ MODULE_VERSION()

MODULE_VERSION ( smsc  ,
 
)

◆ smsc_attach()

static int smsc_attach ( device_t  dev)
static

smsc_attach - Attach the interface. @dev: smsc device handle

Allocate softc structures, do ifmedia setup and ethernet/BPF attach.

RETURNS: Returns 0 on success or a negative error code.

Definition at line 1687 of file if_smsc.c.

References dev, usb_attach_arg::device, device_set_usb_desc(), smsc_softc::sc_flags, smsc_softc::sc_mtx, smsc_softc::sc_ue, smsc_softc::sc_xfer, smsc_config, smsc_detach, SMSC_IFACE_IDX, SMSC_N_TRANSFER, smsc_ue_methods, usb_ether::ue_dev, usb_ether::ue_methods, usb_ether::ue_mtx, usb_ether::ue_sc, usb_ether::ue_udev, uether_ifattach(), USB_GET_DRIVER_INFO, and usbd_transfer_setup().

Here is the call graph for this function:

◆ smsc_attach_post()

static void smsc_attach_post ( struct usb_ether ue)
static

smsc_attach_post - Called after the driver attached to the USB interface @ue: the USB ethernet device

This is where the chip is intialised for the first time. This is different from the smsc_init() function in that that one is designed to setup the H/W to match the UE settings and can be called after a reset.

Definition at line 1554 of file if_smsc.c.

References ETHER_IS_VALID, smsc_softc::sc_phyno, smsc_softc::sc_ue, smsc_chip_init(), smsc_dbg_printf, smsc_eeprom_read(), SMSC_MAC_ADDRH, SMSC_MAC_ADDRL, smsc_read_reg(), usb_ether::ue_dev, usb_ether::ue_eaddr, uether_getsc(), and usb_fdt_get_mac_addr().

Here is the call graph for this function:

◆ smsc_attach_post_sub()

static int smsc_attach_post_sub ( struct usb_ether ue)
static

smsc_attach_post_sub - Called after the driver attached to the USB interface @ue: the USB ethernet device

Most of this is boilerplate code and copied from the base USB ethernet driver. It has been overriden so that we can indicate to the system that the chip supports H/W checksumming.

RETURNS: Returns 0 on success or a negative error code.

Definition at line 1614 of file if_smsc.c.

References error, smsc_softc::sc_phyno, smsc_ioctl(), usb_ether::ue_dev, usb_ether::ue_ifp, usb_ether::ue_methods, usb_ether_methods::ue_mii_sts, usb_ether::ue_miibus, uether_getsc(), uether_ifmedia_upd(), uether_init(), and uether_start().

Here is the call graph for this function:

◆ smsc_bulk_read_callback()

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

smsc_bulk_read_callback - Read callback used to process the USB URB @xfer: the USB transfer @error:

Reads the URB data which can contain one or more ethernet frames, the frames are copyed into a mbuf and given to the system.

LOCKING: No locking required, doesn't access internal driver settings.

Definition at line 948 of file if_smsc.c.

References error, smsc_softc::sc_ue, smsc_dbg_printf, SMSC_RX_STAT_COLLISION, SMSC_RX_STAT_ERROR, SMSC_RX_STAT_FRM_LENGTH, smsc_warn_printf, uether_getifp(), uether_newbuf(), uether_rxflush(), uether_rxmbuf(), USB_ERR_CANCELLED, USB_GET_STATE, USB_ST_SETUP, USB_ST_TRANSFERRED, usbd_copy_out(), usbd_errstr(), usbd_transfer_submit(), usbd_xfer_get_frame(), usbd_xfer_max_len(), usbd_xfer_set_frame_len(), usbd_xfer_set_stall(), usbd_xfer_softc(), and usbd_xfer_status().

Here is the call graph for this function:

◆ smsc_bulk_write_callback()

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

smsc_bulk_write_callback - Write callback used to send ethernet frame(s) @xfer: the USB transfer @error: error code if the transfers is in an errored state

The main write function that pulls ethernet frames off the queue and sends them out.

LOCKING:

Definition at line 1119 of file if_smsc.c.

References error, smsc_softc::sc_flags, smsc_softc::sc_ue, smsc_err_printf, SMSC_FLAG_LINK, SMSC_TX_CTRL_0_BUF_SIZE, SMSC_TX_CTRL_0_FIRST_SEG, SMSC_TX_CTRL_0_LAST_SEG, SMSC_TX_CTRL_1_PKT_LENGTH, uether_getifp(), USB_ERR_CANCELLED, USB_GET_STATE, USB_ST_SETUP, USB_ST_TRANSFERRED, usbd_copy_in(), usbd_errstr(), usbd_m_copy_in(), usbd_transfer_submit(), usbd_xfer_get_frame(), usbd_xfer_set_frame_len(), usbd_xfer_set_frame_offset(), usbd_xfer_set_frames(), usbd_xfer_set_stall(), and usbd_xfer_softc().

Here is the call graph for this function:

◆ smsc_chip_init()

◆ smsc_detach()

static int smsc_detach ( device_t  dev)
static

smsc_detach - Detach the interface. @dev: smsc device handle

RETURNS: Returns 0.

Definition at line 1736 of file if_smsc.c.

References dev, smsc_softc::sc_mtx, smsc_softc::sc_ue, smsc_softc::sc_xfer, SMSC_N_TRANSFER, uether_ifdetach(), and usbd_transfer_unsetup().

Here is the call graph for this function:

◆ smsc_eeprom_read()

static int smsc_eeprom_read ( struct smsc_softc sc,
uint16_t  off,
uint8_t *  buf,
uint16_t  buflen 
)
static

smsc_eeprom_read - Reads the attached EEPROM @sc: soft context @off: the eeprom address offset @buf: stores the bytes @buflen: the number of bytes to read

Simply reads bytes from an attached eeprom.

LOCKING: The function takes and releases the device lock if it is not already held.

RETURNS: 0 on success, or a USB_ERR_?? error code on failure.

Definition at line 374 of file if_smsc.c.

References smsc_softc::sc_mtx, smsc_softc::sc_ue, SMSC_EEPROM_CMD, SMSC_EEPROM_CMD_ADDR_MASK, SMSC_EEPROM_CMD_BUSY, SMSC_EEPROM_CMD_TIMEOUT, SMSC_EEPROM_DATA, SMSC_LOCK, smsc_read_reg(), SMSC_UNLOCK, smsc_wait_for_bits(), smsc_warn_printf, smsc_write_reg(), uether_pause(), USB_ERR_IOERROR, USB_MS_TO_TICKS, and val.

Referenced by smsc_attach_post().

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

◆ smsc_hash()

static uint32_t smsc_hash ( uint8_t  addr[ETHER_ADDR_LEN])
inlinestatic

smsc_hash - Calculate the hash of a mac address @addr: The mac address to calculate the hash on

This function is used when configuring a range of m'cast mac addresses to filter on. The hash of the mac address is put in the device's mac hash table.

RETURNS: Returns a value from 0-63 value which is the hash of the mac address.

Definition at line 685 of file if_smsc.c.

References addr.

Referenced by smsc_hash_maddr().

Here is the caller graph for this function:

◆ smsc_hash_maddr()

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

Definition at line 691 of file if_smsc.c.

References smsc_hash().

Referenced by smsc_setmulti().

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

◆ smsc_ifmedia_sts()

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

smsc_ifmedia_sts - Report current media status @ifp: inet interface pointer @ifmr: interface media request

Basically boilerplate code that simply calls the mii functions to get the media status.

LOCKING: Internally takes and releases the device lock.

Definition at line 661 of file if_smsc.c.

References smsc_softc::sc_ue, SMSC_LOCK, SMSC_UNLOCK, and uether_getmii().

Here is the call graph for this function:

◆ smsc_ifmedia_upd()

static int smsc_ifmedia_upd ( struct ifnet *  ifp)
static

smsc_ifmedia_upd - Set media options @ifp: interface pointer

Basically boilerplate code that simply calls the mii functions to set the media options.

LOCKING: The device lock must be held before this function is called.

RETURNS: Returns 0 on success or a negative error code.

Definition at line 634 of file if_smsc.c.

References smsc_softc::sc_ue, SMSC_LOCK_ASSERT, and uether_getmii().

Referenced by smsc_init().

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

◆ smsc_init()

static void smsc_init ( struct usb_ether ue)
static

smsc_init - Initialises the LAN95xx chip @ue: USB ether interface

Called when the interface is brought up (i.e. ifconfig ue0 up), this initialise the interface and the rx/tx pipes.

LOCKING: Should be called with the SMSC lock held.

Definition at line 901 of file if_smsc.c.

References smsc_softc::sc_xfer, SMSC_BULK_DT_WR, smsc_dbg_printf, smsc_ifmedia_upd(), SMSC_LOCK_ASSERT, smsc_reset(), smsc_sethwcsum(), smsc_setmacaddress(), smsc_setmulti, smsc_start, smsc_stop, uether_getifp(), uether_getsc(), and usbd_xfer_set_stall().

Here is the call graph for this function:

◆ smsc_ioctl()

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

smsc_ioctl - ioctl function for the device @ifp: interface pointer @cmd: the ioctl command @data: data passed in the ioctl call, typically a pointer to struct ifreq.

The ioctl routine is overridden to detect change requests for the H/W checksum capabilities.

RETURNS: 0 on success and an error code on failure.

Definition at line 1501 of file if_smsc.c.

References data, SMSC_LOCK, SMSC_UNLOCK, uether_getsc(), uether_init(), and uether_ioctl().

Referenced by smsc_attach_post_sub().

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

◆ smsc_miibus_readreg()

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

smsc_miibus_readreg - Reads a MII/MDIO register @dev: usb ether device @phy: the number of phy reading from @reg: the register address

Attempts to read a phy register over the MII bus.

LOCKING: Takes and releases the device mutex lock if not already held.

RETURNS: Returns the 16-bits read from the MII register, if this function fails 0 is returned.

Definition at line 444 of file if_smsc.c.

References addr, dev, reg, smsc_softc::sc_mtx, SMSC_LOCK, SMSC_MII_ADDR, SMSC_MII_BUSY, SMSC_MII_DATA, SMSC_MII_READ, smsc_read_reg(), SMSC_UNLOCK, smsc_wait_for_bits(), smsc_warn_printf, smsc_write_reg(), and val.

Here is the call graph for this function:

◆ smsc_miibus_statchg()

static void smsc_miibus_statchg ( device_t  dev)
static

smsc_miibus_statchg - Called to detect phy status change @dev: usb ether device

This function is called periodically by the system to poll for status changes of the link.

LOCKING: Takes and releases the device mutex lock if not already held.

Definition at line 536 of file if_smsc.c.

References dev, smsc_softc::sc_flags, smsc_softc::sc_mac_csr, smsc_softc::sc_mtx, smsc_softc::sc_ue, SMSC_AFC_CFG, smsc_dbg_printf, SMSC_FLAG_LINK, SMSC_FLOW, SMSC_LOCK, SMSC_MAC_CSR, SMSC_MAC_CSR_FDPX, SMSC_MAC_CSR_RCVOWN, smsc_read_reg(), SMSC_UNLOCK, smsc_warn_printf, smsc_write_reg(), uether_getifp(), and uether_getmii().

Here is the call graph for this function:

◆ smsc_miibus_writereg()

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

smsc_miibus_writereg - Writes a MII/MDIO register @dev: usb ether device @phy: the number of phy writing to @reg: the register address @val: the value to write

Attempts to write a phy register over the MII bus.

LOCKING: Takes and releases the device mutex lock if not already held.

RETURNS: Always returns 0 regardless of success or failure.

Definition at line 492 of file if_smsc.c.

References addr, dev, reg, smsc_softc::sc_mtx, smsc_softc::sc_phyno, SMSC_LOCK, SMSC_MII_ADDR, SMSC_MII_BUSY, SMSC_MII_DATA, SMSC_MII_WRITE, SMSC_UNLOCK, smsc_wait_for_bits(), smsc_warn_printf, smsc_write_reg(), and val.

Here is the call graph for this function:

◆ smsc_phy_init()

static int smsc_phy_init ( struct smsc_softc sc)
static

smsc_phy_init - Initialises the in-built SMSC phy @sc: driver soft context

Resets the PHY part of the chip and then initialises it to default values. The 'link down' and 'auto-negotiation complete' interrupts from the PHY are also enabled, however we don't monitor the interrupt endpoints for the moment.

RETURNS: Returns 0 on success or EIO if failed to reset the PHY.

Definition at line 1282 of file if_smsc.c.

References smsc_softc::sc_phyno, smsc_softc::sc_ue, smsc_err_printf, SMSC_LOCK_ASSERT, smsc_miibus_readreg, smsc_miibus_writereg, SMSC_PHY_INTR_ANEG_COMP, SMSC_PHY_INTR_LINK_DOWN, SMSC_PHY_INTR_MASK, SMSC_PHY_INTR_STAT, usb_ether::ue_dev, uether_pause(), and USB_MS_TO_TICKS.

Referenced by smsc_chip_init().

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

◆ smsc_probe()

static int smsc_probe ( device_t  dev)
static

smsc_probe - Probe the interface. @dev: smsc device handle

Checks if the device is a match for this driver.

RETURNS: Returns 0 on success or an error code on failure.

Definition at line 1663 of file if_smsc.c.

References usbd_lookup_info::bConfigIndex, usbd_lookup_info::bIfaceIndex, dev, usb_attach_arg::info, SMSC_CONFIG_INDEX, smsc_devs, SMSC_IFACE_IDX, usb_attach_arg::usb_mode, USB_MODE_HOST, and usbd_lookup_id_by_uaa().

Here is the call graph for this function:

◆ smsc_read_reg()

static int smsc_read_reg ( struct smsc_softc sc,
uint32_t  off,
uint32_t *  data 
)
static

smsc_read_reg - Reads a 32-bit register on the device @sc: driver soft context @off: offset of the register @data: pointer a value that will be populated with the register value

LOCKING: The device lock must be held before calling this function.

RETURNS: 0 on success, a USB_ERR_?? error code on failure.

Definition at line 264 of file if_smsc.c.

References data, req, smsc_softc::sc_ue, SMSC_LOCK_ASSERT, SMSC_UR_READ_REG, smsc_warn_printf, uether_do_request, USETW, and UT_READ_VENDOR_DEVICE.

Referenced by smsc_attach_post(), smsc_chip_init(), smsc_eeprom_read(), smsc_miibus_readreg(), smsc_miibus_statchg(), smsc_sethwcsum(), and smsc_wait_for_bits().

Here is the caller graph for this function:

◆ smsc_reset()

static void smsc_reset ( struct smsc_softc sc)
static

smsc_reset - Reset the SMSC chip @sc: device soft context

LOCKING: Should be called with the SMSC lock held.

Definition at line 871 of file if_smsc.c.

References usb_config_descriptor::bConfigurationValue, smsc_softc::sc_mtx, smsc_softc::sc_ue, smsc_chip_init(), smsc_warn_printf, usb_ether::ue_udev, uether_pause(), usbd_get_config_descriptor(), and usbd_req_set_config().

Referenced by smsc_init().

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

◆ smsc_sethwcsum()

static int smsc_sethwcsum ( struct smsc_softc sc)
static

smsc_sethwcsum - Enable or disable H/W UDP and TCP checksumming @sc: driver soft context

LOCKING: Should be called with the SMSC lock held.

RETURNS: Returns 0 on success or a negative error code.

Definition at line 789 of file if_smsc.c.

References smsc_softc::sc_ue, SMSC_COE_CTRL, SMSC_COE_CTRL_RX_EN, SMSC_COE_CTRL_TX_EN, SMSC_LOCK_ASSERT, smsc_read_reg(), smsc_warn_printf, smsc_write_reg(), uether_getifp(), and val.

Referenced by smsc_init().

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

◆ smsc_setmacaddress()

static int smsc_setmacaddress ( struct smsc_softc sc,
const uint8_t *  addr 
)
static

smsc_setmacaddress - Sets the mac address in the device @sc: driver soft context @addr: pointer to array contain at least 6 bytes of the mac

Writes the MAC address into the device, usually the MAC is programmed with values from the EEPROM.

LOCKING: Should be called with the SMSC lock held.

RETURNS: Returns 0 on success or a negative error code.

Definition at line 842 of file if_smsc.c.

References addr, smsc_dbg_printf, SMSC_LOCK_ASSERT, SMSC_MAC_ADDRH, SMSC_MAC_ADDRL, smsc_write_reg(), and val.

Referenced by smsc_chip_init(), and smsc_init().

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

◆ smsc_setmulti()

static void smsc_setmulti ( struct usb_ether ue)
static

smsc_setmulti - Setup multicast @ue: usb ethernet device context

Tells the device to either accept frames with a multicast mac address, a select group of m'cast mac addresses or just the devices mac address.

LOCKING: Should be called with the SMSC lock held.

Definition at line 712 of file if_smsc.c.

References smsc_softc::sc_mac_csr, smsc_dbg_printf, smsc_hash_maddr(), SMSC_HASHH, SMSC_HASHL, SMSC_LOCK_ASSERT, SMSC_MAC_CSR, SMSC_MAC_CSR_HPFILT, SMSC_MAC_CSR_MCPAS, SMSC_MAC_CSR_PRMS, smsc_write_reg(), uether_getifp(), and uether_getsc().

Here is the call graph for this function:

◆ smsc_setpromisc()

static void smsc_setpromisc ( struct usb_ether ue)
static

smsc_setpromisc - Enables/disables promiscuous mode @ue: usb ethernet device context

LOCKING: Should be called with the SMSC lock held.

Definition at line 761 of file if_smsc.c.

References smsc_softc::sc_mac_csr, smsc_dbg_printf, SMSC_LOCK_ASSERT, SMSC_MAC_CSR, SMSC_MAC_CSR_PRMS, smsc_write_reg(), uether_getifp(), and uether_getsc().

Here is the call graph for this function:

◆ smsc_start()

static void smsc_start ( struct usb_ether ue)
static

smsc_start - Starts communication with the LAN95xx chip @ue: USB ether interface

Definition at line 1233 of file if_smsc.c.

References smsc_softc::sc_xfer, SMSC_BULK_DT_RD, SMSC_BULK_DT_WR, uether_getsc(), and usbd_transfer_start().

Here is the call graph for this function:

◆ smsc_stop()

static void smsc_stop ( struct usb_ether ue)
static

smsc_stop - Stops communication with the LAN95xx chip @ue: USB ether interface

Definition at line 1252 of file if_smsc.c.

References smsc_softc::sc_flags, smsc_softc::sc_xfer, SMSC_BULK_DT_RD, SMSC_BULK_DT_WR, SMSC_LOCK_ASSERT, uether_getifp(), uether_getsc(), and usbd_transfer_stop().

Here is the call graph for this function:

◆ smsc_tick()

static void smsc_tick ( struct usb_ether ue)
static

smsc_tick - Called periodically to monitor the state of the LAN95xx chip @ue: USB ether interface

Simply calls the mii status functions to check the state of the link.

LOCKING: Should be called with the SMSC lock held.

Definition at line 1210 of file if_smsc.c.

References smsc_softc::sc_flags, smsc_softc::sc_ue, SMSC_FLAG_LINK, SMSC_LOCK_ASSERT, smsc_miibus_statchg, smsc_start, usb_ether::ue_dev, uether_getmii(), and uether_getsc().

Here is the call graph for this function:

◆ smsc_wait_for_bits()

static int smsc_wait_for_bits ( struct smsc_softc sc,
uint32_t  reg,
uint32_t  bits 
)
static

smsc_wait_for_bits - Polls on a register value until bits are cleared @sc: soft context @reg: offset of the register @bits: if the bits are clear the function returns

LOCKING: The device lock must be held before calling this function.

RETURNS: 0 on success, or a USB_ERR_?? error code on failure.

Definition at line 336 of file if_smsc.c.

References reg, smsc_softc::sc_ue, SMSC_LOCK_ASSERT, smsc_read_reg(), uether_pause(), USB_ERR_TIMEOUT, USB_MS_TO_TICKS, and val.

Referenced by smsc_chip_init(), smsc_eeprom_read(), smsc_miibus_readreg(), and smsc_miibus_writereg().

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

◆ smsc_write_reg()

static int smsc_write_reg ( struct smsc_softc sc,
uint32_t  off,
uint32_t  data 
)
static

smsc_write_reg - Writes a 32-bit register on the device @sc: driver soft context @off: offset of the register @data: the 32-bit value to write into the register

LOCKING: The device lock must be held before calling this function.

RETURNS: 0 on success, a USB_ERR_?? error code on failure.

Definition at line 300 of file if_smsc.c.

References data, req, smsc_softc::sc_ue, SMSC_LOCK_ASSERT, SMSC_UR_WRITE_REG, smsc_warn_printf, uether_do_request, USETW, and UT_WRITE_VENDOR_DEVICE.

Referenced by smsc_chip_init(), smsc_eeprom_read(), smsc_miibus_readreg(), smsc_miibus_statchg(), smsc_miibus_writereg(), smsc_sethwcsum(), smsc_setmacaddress(), smsc_setmulti(), and smsc_setpromisc().

Here is the caller graph for this function:

◆ SYSCTL_BOOL()

SYSCTL_BOOL ( _hw_usb_smsc  ,
OID_AUTO  ,
smsc_rx_packet_batching  ,
CTLFLAG_RDTUN  ,
smsc_rx_packet_batching,
,
"If  set,
allows packet batching to increase throughput and latency. " "Else throughput and latency is decreased."   
)

◆ SYSCTL_NODE()

SYSCTL_NODE ( _hw_usb  ,
OID_AUTO  ,
smsc  ,
CTLFLAG_RW|  CTLFLAG_MPSAFE,
,
"USB smsc"   
)

◆ USB_PNP_HOST_INFO()

USB_PNP_HOST_INFO ( smsc_devs  )

Variable Documentation

◆ smsc_attach

device_attach_t smsc_attach
static

Definition at line 185 of file if_smsc.c.

◆ smsc_attach_post

uether_fn_t smsc_attach_post
static

Definition at line 196 of file if_smsc.c.

◆ smsc_bulk_read_callback

usb_callback_t smsc_bulk_read_callback
static

Definition at line 188 of file if_smsc.c.

◆ smsc_bulk_write_callback

usb_callback_t smsc_bulk_write_callback
static

Definition at line 189 of file if_smsc.c.

◆ smsc_config

const struct usb_config smsc_config[SMSC_N_TRANSFER]
static
Initial value:
= {
.type = UE_BULK,
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_OUT,
.frames = 16,
.bufsize = 16 * (MCLBYTES + 16),
.flags = {.pipe_bof = 1,.force_short_xfer = 1,},
.timeout = 10000,
},
.type = UE_BULK,
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_IN,
.bufsize = 20480,
.flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
.timeout = 0,
},
}
static usb_callback_t smsc_bulk_write_callback
Definition: if_smsc.c:189
static usb_callback_t smsc_bulk_read_callback
Definition: if_smsc.c:188
@ SMSC_BULK_DT_RD
Definition: if_smscreg.h:249
@ SMSC_BULK_DT_WR
Definition: if_smscreg.h:250
#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 210 of file if_smsc.c.

Referenced by smsc_attach().

◆ smsc_detach

device_detach_t smsc_detach
static

Definition at line 186 of file if_smsc.c.

Referenced by smsc_attach().

◆ smsc_devclass

devclass_t smsc_devclass
static

Definition at line 1772 of file if_smsc.c.

◆ smsc_devs

const struct usb_device_id smsc_devs[]
static
Initial value:
= {
#define SMSC_DEV(p,i)
SMSC_DEV(LAN89530_ETH, 0),
SMSC_DEV(LAN9500_ETH, 0),
SMSC_DEV(LAN9500_ETH_2, 0),
SMSC_DEV(LAN9500A_ETH, 0),
SMSC_DEV(LAN9500A_ETH_2, 0),
SMSC_DEV(LAN9505_ETH, 0),
SMSC_DEV(LAN9505A_ETH, 0),
SMSC_DEV(LAN9514_ETH, 0),
SMSC_DEV(LAN9514_ETH_2, 0),
SMSC_DEV(LAN9530_ETH, 0),
SMSC_DEV(LAN9730_ETH, 0),
SMSC_DEV(LAN9500_SAL10, 0),
SMSC_DEV(LAN9505_SAL10, 0),
SMSC_DEV(LAN9500A_SAL10, 0),
SMSC_DEV(LAN9505A_SAL10, 0),
SMSC_DEV(LAN9514_SAL10, 0),
SMSC_DEV(LAN9500A_HAL, 0),
SMSC_DEV(LAN9505A_HAL, 0),
}
#define SMSC_DEV(p, i)

Definition at line 142 of file if_smsc.c.

Referenced by smsc_probe().

◆ smsc_driver

driver_t smsc_driver
static
Initial value:
= {
.name = "smsc",
.methods = smsc_methods,
.size = sizeof(struct smsc_softc),
}
static device_method_t smsc_methods[]
Definition: if_smsc.c:1748

Definition at line 1766 of file if_smsc.c.

◆ smsc_init

uether_fn_t smsc_init
static

Definition at line 197 of file if_smsc.c.

◆ smsc_methods

device_method_t smsc_methods[]
static
Initial value:
= {
DEVMETHOD(device_probe, smsc_probe),
DEVMETHOD(device_attach, smsc_attach),
DEVMETHOD(device_detach, smsc_detach),
DEVMETHOD(bus_print_child, bus_generic_print_child),
DEVMETHOD(bus_driver_added, bus_generic_driver_added),
DEVMETHOD(miibus_readreg, smsc_miibus_readreg),
DEVMETHOD(miibus_writereg, smsc_miibus_writereg),
DEVMETHOD(miibus_statchg, smsc_miibus_statchg),
DEVMETHOD_END
}
static device_probe_t smsc_probe
Definition: if_smsc.c:184
static miibus_statchg_t smsc_miibus_statchg
Definition: if_smsc.c:193
static miibus_writereg_t smsc_miibus_writereg
Definition: if_smsc.c:192
static device_detach_t smsc_detach
Definition: if_smsc.c:186
static device_attach_t smsc_attach
Definition: if_smsc.c:185
static miibus_readreg_t smsc_miibus_readreg
Definition: if_smsc.c:191

Definition at line 1748 of file if_smsc.c.

◆ smsc_miibus_readreg

miibus_readreg_t smsc_miibus_readreg
static

Definition at line 191 of file if_smsc.c.

Referenced by smsc_phy_init().

◆ smsc_miibus_statchg

miibus_statchg_t smsc_miibus_statchg
static

Definition at line 193 of file if_smsc.c.

Referenced by smsc_tick().

◆ smsc_miibus_writereg

miibus_writereg_t smsc_miibus_writereg
static

Definition at line 192 of file if_smsc.c.

Referenced by smsc_phy_init().

◆ smsc_probe

device_probe_t smsc_probe
static

Definition at line 184 of file if_smsc.c.

◆ smsc_rx_packet_batching

bool smsc_rx_packet_batching = 1
static

Definition at line 125 of file if_smsc.c.

Referenced by smsc_chip_init().

◆ smsc_setmulti

uether_fn_t smsc_setmulti
static

Definition at line 201 of file if_smsc.c.

Referenced by smsc_init().

◆ smsc_setpromisc

uether_fn_t smsc_setpromisc
static

Definition at line 202 of file if_smsc.c.

◆ smsc_start

uether_fn_t smsc_start
static

Definition at line 199 of file if_smsc.c.

Referenced by smsc_init(), and smsc_tick().

◆ smsc_stop

uether_fn_t smsc_stop
static

Definition at line 198 of file if_smsc.c.

Referenced by smsc_init().

◆ smsc_tick

uether_fn_t smsc_tick
static

Definition at line 200 of file if_smsc.c.

◆ smsc_ue_methods

const struct usb_ether_methods smsc_ue_methods
static
Initial value:
= {
.ue_attach_post = smsc_attach_post,
.ue_attach_post_sub = smsc_attach_post_sub,
.ue_start = smsc_start,
.ue_ioctl = smsc_ioctl,
.ue_init = smsc_init,
.ue_stop = smsc_stop,
.ue_tick = smsc_tick,
.ue_setmulti = smsc_setmulti,
.ue_setpromisc = smsc_setpromisc,
.ue_mii_upd = smsc_ifmedia_upd,
.ue_mii_sts = smsc_ifmedia_sts,
}
static uether_fn_t smsc_stop
Definition: if_smsc.c:198
static uether_fn_t smsc_tick
Definition: if_smsc.c:200
static void smsc_ifmedia_sts(struct ifnet *, struct ifmediareq *)
Definition: if_smsc.c:661
static int smsc_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
Definition: if_smsc.c:1501
static uether_fn_t smsc_attach_post
Definition: if_smsc.c:196
static uether_fn_t smsc_setmulti
Definition: if_smsc.c:201
static int smsc_ifmedia_upd(struct ifnet *)
Definition: if_smsc.c:634
static uether_fn_t smsc_init
Definition: if_smsc.c:197
static uether_fn_t smsc_start
Definition: if_smsc.c:199
static uether_fn_t smsc_setpromisc
Definition: if_smsc.c:202
static int smsc_attach_post_sub(struct usb_ether *ue)
Definition: if_smsc.c:1614

Definition at line 237 of file if_smsc.c.

Referenced by smsc_attach().