FreeBSD kernel usb device Code
|
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/callout.h>
#include <sys/condvar.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/module.h>
#include <sys/mutex.h>
#include <sys/priv.h>
#include <sys/queue.h>
#include <sys/random.h>
#include <sys/socket.h>
#include <sys/stddef.h>
#include <sys/stdint.h>
#include <sys/sx.h>
#include <sys/sysctl.h>
#include <sys/systm.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 <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_mugereg.h>
#include "miibus_if.h"
Go to the source code of this file.
Data Structures | |
struct | muge_softc |
Macros | |
#define | USB_DEBUG_VAR lan78xx_debug |
#define | MUGE_DEFAULT_TX_CSUM_ENABLE (false) |
#define | MUGE_DEFAULT_TSO_ENABLE (false) |
#define | MUGE_DEV(p, i) { USB_VPI(USB_VENDOR_SMC2, USB_PRODUCT_SMC2_##p, i) } |
#define | muge_dbg_printf(sc, fmt, args...) do { } while (0) |
#define | muge_warn_printf(sc, fmt, args...) device_printf((sc)->sc_ue.ue_dev, "warning: " fmt, ##args) |
#define | muge_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)) |
#define | MUGE_FLAG_LINK 0x0001 |
#define | MUGE_FLAG_INIT_DONE 0x0002 |
#define | MUGE_IFACE_IDX 0 |
#define | MUGE_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx) |
#define | MUGE_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx) |
#define | MUGE_LOCK_ASSERT(_sc, t) mtx_assert(&(_sc)->sc_mtx, t) |
Enumerations | |
enum | { MUGE_BULK_DT_RD , MUGE_BULK_DT_WR , MUGE_N_TRANSFER } |
Functions | |
__FBSDID ("$FreeBSD$") | |
static int | muge_attach_post_sub (struct usb_ether *ue) |
static int | muge_ifmedia_upd (struct ifnet *) |
static void | muge_ifmedia_sts (struct ifnet *, struct ifmediareq *) |
static int | lan78xx_chip_init (struct muge_softc *sc) |
static int | muge_ioctl (struct ifnet *ifp, u_long cmd, caddr_t data) |
static int | lan78xx_read_reg (struct muge_softc *sc, uint32_t off, uint32_t *data) |
static int | lan78xx_write_reg (struct muge_softc *sc, uint32_t off, uint32_t data) |
static int | lan78xx_wait_for_bits (struct muge_softc *sc, uint32_t reg, uint32_t bits) |
static int | lan78xx_eeprom_read_raw (struct muge_softc *sc, uint16_t off, uint8_t *buf, uint16_t buflen) |
static bool | lan78xx_eeprom_present (struct muge_softc *sc) |
static int | lan78xx_otp_read_raw (struct muge_softc *sc, uint16_t off, uint8_t *buf, uint16_t buflen) |
static int | lan78xx_otp_read (struct muge_softc *sc, uint16_t off, uint8_t *buf, uint16_t buflen) |
static int | lan78xx_setmacaddress (struct muge_softc *sc, const uint8_t *addr) |
static int | lan78xx_set_rx_max_frame_length (struct muge_softc *sc, int size) |
static int | lan78xx_miibus_readreg (device_t dev, int phy, int reg) |
static int | lan78xx_miibus_writereg (device_t dev, int phy, int reg, int val) |
static void | lan78xx_miibus_statchg (device_t dev) |
static void | lan78xx_set_mdix_auto (struct muge_softc *sc) |
static int | lan78xx_phy_init (struct muge_softc *sc) |
static void | muge_bulk_read_callback (struct usb_xfer *xfer, usb_error_t error) |
static void | muge_bulk_write_callback (struct usb_xfer *xfer, usb_error_t error) |
static void | muge_set_mac_addr (struct usb_ether *ue) |
static void | muge_set_leds (struct usb_ether *ue) |
static void | muge_attach_post (struct usb_ether *ue) |
static void | muge_start (struct usb_ether *ue) |
static void | muge_reset (struct muge_softc *sc) |
static void | muge_set_addr_filter (struct muge_softc *sc, int index, uint8_t addr[ETHER_ADDR_LEN]) |
static int | lan78xx_dataport_write (struct muge_softc *sc, uint32_t ram_select, uint32_t addr, uint32_t length, uint32_t *buf) |
static void | muge_multicast_write (struct muge_softc *sc) |
static uint32_t | muge_hash (uint8_t addr[ETHER_ADDR_LEN]) |
static u_int | muge_hash_maddr (void *arg, struct sockaddr_dl *sdl, u_int cnt) |
static void | muge_setmulti (struct usb_ether *ue) |
static void | muge_setpromisc (struct usb_ether *ue) |
static int | muge_sethwcsum (struct muge_softc *sc) |
static void | muge_init (struct usb_ether *ue) |
static void | muge_stop (struct usb_ether *ue) |
static void | muge_tick (struct usb_ether *ue) |
static int | muge_probe (device_t dev) |
static int | muge_attach (device_t dev) |
static int | muge_detach (device_t dev) |
DRIVER_MODULE (muge, uhub, muge_driver, muge_devclass, NULL, NULL) | |
DRIVER_MODULE (miibus, muge, miibus_driver, miibus_devclass, NULL, NULL) | |
MODULE_DEPEND (muge, uether, 1, 1, 1) | |
MODULE_DEPEND (muge, usb, 1, 1, 1) | |
MODULE_DEPEND (muge, ether, 1, 1, 1) | |
MODULE_DEPEND (muge, miibus, 1, 1, 1) | |
MODULE_VERSION (muge, 1) | |
USB_PNP_HOST_INFO (lan78xx_devs) | |
Variables | |
static const struct usb_device_id | lan78xx_devs [] |
static device_probe_t | muge_probe |
static device_attach_t | muge_attach |
static device_detach_t | muge_detach |
static usb_callback_t | muge_bulk_read_callback |
static usb_callback_t | muge_bulk_write_callback |
static miibus_readreg_t | lan78xx_miibus_readreg |
static miibus_writereg_t | lan78xx_miibus_writereg |
static miibus_statchg_t | lan78xx_miibus_statchg |
static uether_fn_t | muge_attach_post |
static uether_fn_t | muge_init |
static uether_fn_t | muge_stop |
static uether_fn_t | muge_start |
static uether_fn_t | muge_tick |
static uether_fn_t | muge_setmulti |
static uether_fn_t | muge_setpromisc |
static const struct usb_config | muge_config [MUGE_N_TRANSFER] |
static const struct usb_ether_methods | muge_ue_methods |
static device_method_t | muge_methods [] |
static driver_t | muge_driver |
static devclass_t | muge_devclass |
#define muge_dbg_printf | ( | sc, | |
fmt, | |||
args... | |||
) | do { } while (0) |
#define MUGE_DEV | ( | p, | |
i | |||
) | { USB_VPI(USB_VENDOR_SMC2, USB_PRODUCT_SMC2_##p, i) } |
#define muge_err_printf | ( | sc, | |
fmt, | |||
args... | |||
) | device_printf((sc)->sc_ue.ue_dev, "error: " fmt, ##args) |
#define MUGE_LOCK_ASSERT | ( | _sc, | |
t | |||
) | mtx_assert(&(_sc)->sc_mtx, t) |
#define muge_warn_printf | ( | sc, | |
fmt, | |||
args... | |||
) | device_printf((sc)->sc_ue.ue_dev, "warning: " fmt, ##args) |
anonymous enum |
__FBSDID | ( | "$FreeBSD$" | ) |
DRIVER_MODULE | ( | miibus | , |
muge | , | ||
miibus_driver | , | ||
miibus_devclass | , | ||
NULL | , | ||
NULL | |||
) |
DRIVER_MODULE | ( | muge | , |
uhub | , | ||
muge_driver | , | ||
muge_devclass | , | ||
NULL | , | ||
NULL | |||
) |
|
static |
lan78xx_chip_init - Initialises the chip after power on @sc: driver soft context
This initialisation sequence is modelled on the procedure in the Linux driver.
RETURNS: Returns 0 on success or an error code on failure.
Definition at line 973 of file if_muge.c.
References muge_softc::chipid, muge_softc::chiprev, ETH_BULK_IN_DLY, ETH_BURST_CAP, ETH_FCT_FLOW, ETH_FCT_RX_CTL, ETH_FCT_RX_FIFO_END, ETH_FCT_TX_CTL, ETH_FCT_TX_CTL_EN_, ETH_FCT_TX_FIFO_END, ETH_FLOW, ETH_HW_CFG, ETH_HW_CFG_LRST_, ETH_HW_CFG_MEF_, ETH_ID_REV, ETH_ID_REV_CHIP_ID_7800_, ETH_ID_REV_CHIP_ID_7850_, ETH_ID_REV_CHIP_ID_MASK_, ETH_ID_REV_CHIP_REV_MASK_, ETH_INT_ENP_PHY_INT, ETH_INT_EP_CTL, ETH_INT_STS, ETH_INT_STS_CLEAR_ALL_, ETH_MAC_CR, ETH_MAC_CR_AUTO_DUPLEX_, ETH_MAC_CR_AUTO_SPEED_, ETH_MAC_RX, ETH_MAC_RX_EN_, ETH_MAC_TX, ETH_MAC_TX_TXEN_, ETH_PMT_CTL, ETH_PMT_CTL_PHY_RST_, ETH_RFE_CTL, ETH_RFE_CTL_BCAST_EN_, ETH_RFE_CTL_DA_PERFECT_, ETH_USB_CFG0, ETH_USB_CFG_BCE_, ETH_USB_CFG_BIR_, lan78xx_eeprom_present(), lan78xx_phy_init(), lan78xx_read_reg(), lan78xx_set_rx_max_frame_length(), lan78xx_setmacaddress(), lan78xx_wait_for_bits(), lan78xx_write_reg(), MUGE_DEFAULT_BULK_IN_DELAY, MUGE_DEFAULT_BURST_CAP_SIZE, muge_err_printf, MUGE_FLAG_INIT_DONE, MUGE_FS_USB_PKT_SIZE, MUGE_HS_USB_PKT_SIZE, MUGE_LOCK_ASSERT, MUGE_MAX_RX_FIFO_SIZE, MUGE_MAX_TX_FIFO_SIZE, MUGE_SS_USB_PKT_SIZE, muge_warn_printf, muge_softc::sc_flags, muge_softc::sc_ue, usb_ether::ue_dev, usb_ether::ue_eaddr, usb_ether::ue_udev, USB_SPEED_HIGH, USB_SPEED_SUPER, and usbd_get_speed().
Referenced by muge_attach_post(), and muge_reset().
|
static |
lan78xx_dataport_write - write to the selected RAM @sc: The device soft context. @ram_select: Select which RAM to access. @addr: Starting address to write to. @buf: word-sized buffer to write to RAM, starting at @addr. @length: length of @buf
RETURNS: 0 if write successful.
Definition at line 1788 of file if_muge.c.
References addr, ETH_DP_ADDR, ETH_DP_CMD, ETH_DP_CMD_WRITE_, ETH_DP_DATA, ETH_DP_SEL, ETH_DP_SEL_DPRDY_, lan78xx_read_reg(), lan78xx_wait_for_bits(), lan78xx_write_reg(), and MUGE_LOCK_ASSERT.
Referenced by muge_multicast_write().
|
static |
Definition at line 457 of file if_muge.c.
References ETH_E2P_INDICATOR, ETH_E2P_INDICATOR_OFFSET, and lan78xx_eeprom_read_raw().
Referenced by lan78xx_chip_init(), and muge_set_mac_addr().
|
static |
lan78xx_eeprom_read_raw - Read 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 not already held.
RETURNS: 0 on success, or a USB_ERR_?? error code on failure.
Definition at line 386 of file if_muge.c.
References muge_softc::chipid, ETH_E2P_CMD, ETH_E2P_CMD_ADDR_MASK_, ETH_E2P_CMD_BUSY_, ETH_E2P_CMD_READ_, ETH_E2P_CMD_TIMEOUT_, ETH_E2P_DATA, ETH_HW_CFG, ETH_HW_CFG_LED1_EN_, ETH_HW_CFG_LEDO_EN_, ETH_ID_REV_CHIP_ID_7800_, lan78xx_read_reg(), lan78xx_wait_for_bits(), lan78xx_write_reg(), MUGE_LOCK, MUGE_UNLOCK, muge_warn_printf, muge_softc::sc_mtx, muge_softc::sc_ue, uether_pause(), USB_ERR_IOERROR, USB_MS_TO_TICKS, and val.
Referenced by lan78xx_eeprom_present(), and muge_set_mac_addr().
|
static |
lan78xx_miibus_readreg - Read a MII/MDIO register @dev: usb ether device @phy: the number of phy reading from @reg: the register address
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 660 of file if_muge.c.
References addr, dev, ETH_MII_ACC, ETH_MII_ACC_MII_BUSY_, ETH_MII_ACC_MII_READ_, ETH_MII_DATA, lan78xx_read_reg(), lan78xx_wait_for_bits(), lan78xx_write_reg(), MUGE_LOCK, MUGE_UNLOCK, muge_warn_printf, reg, muge_softc::sc_mtx, and val.
|
static |
Definition at line 759 of file if_muge.c.
References dev, ETH_FCT_FLOW, ETH_FLOW, ETH_FLOW_CR_RX_FCEN_, ETH_FLOW_CR_TX_FCEN_, lan78xx_read_reg(), lan78xx_write_reg(), muge_dbg_printf, MUGE_FLAG_LINK, MUGE_LOCK, MUGE_UNLOCK, muge_warn_printf, muge_softc::sc_flags, muge_softc::sc_mtx, muge_softc::sc_ue, usb_ether::ue_udev, uether_getifp(), uether_getmii(), USB_SPEED_HIGH, USB_SPEED_SUPER, and usbd_get_speed().
|
static |
lan78xx_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 through the usb controller registers.
LOCKING: Takes and releases the device mutex lock if not already held.
RETURNS: Always returns 0 regardless of success or failure.
Definition at line 713 of file if_muge.c.
References addr, dev, ETH_MII_ACC, ETH_MII_ACC_MII_BUSY_, ETH_MII_ACC_MII_WRITE_, ETH_MII_DATA, lan78xx_wait_for_bits(), lan78xx_write_reg(), MUGE_LOCK, MUGE_UNLOCK, muge_warn_printf, reg, muge_softc::sc_mtx, muge_softc::sc_phyno, and val.
|
static |
lan78xx_otp_read @sc: soft context @off: the otp address offset @buf: stores the bytes @buflen: the number of bytes to read
Simply reads bytes from the otp.
LOCKING: The function takes and releases device lock if it is not already held.
RETURNS: 0 on success, or a USB_ERR_?? error code on failure.
Definition at line 549 of file if_muge.c.
References lan78xx_otp_read_raw(), OTP_INDICATOR_1, OTP_INDICATOR_2, and OTP_INDICATOR_OFFSET.
Referenced by muge_set_mac_addr().
|
static |
lan78xx_otp_read_raw @sc: soft context @off: the otp address offset @buf: stores the bytes @buflen: the number of bytes to read
Simply reads bytes from the OTP.
LOCKING: The function takes and releases the device lock if not already held.
RETURNS: 0 on success, or a USB_ERR_?? error code on failure.
Definition at line 483 of file if_muge.c.
References lan78xx_read_reg(), lan78xx_wait_for_bits(), lan78xx_write_reg(), MUGE_LOCK, MUGE_UNLOCK, muge_warn_printf, OTP_ADDR1, OTP_ADDR1_15_11, OTP_ADDR2, OTP_ADDR2_10_3, OTP_CMD_GO, OTP_CMD_GO_GO_, OTP_FUNC_CMD, OTP_FUNC_CMD_READ_, OTP_PWR_DN, OTP_PWR_DN_PWRDN_N, OTP_RD_DATA, OTP_STATUS, OTP_STATUS_BUSY_, muge_softc::sc_mtx, and val.
Referenced by lan78xx_otp_read().
|
static |
lan78xx_phy_init - Initialises the in-built MUGE 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 894 of file if_muge.c.
References ETH_HW_CFG, ETH_HW_CFG_LED1_EN_, ETH_HW_CFG_LED2_EN_, ETH_HW_CFG_LED3_EN_, ETH_HW_CFG_LEDO_EN_, lan78xx_miibus_readreg, lan78xx_miibus_writereg, lan78xx_read_reg(), lan78xx_set_mdix_auto(), lan78xx_write_reg(), muge_dbg_printf, muge_err_printf, MUGE_LOCK_ASSERT, MUGE_PHY_INTR_ANEG_COMP, MUGE_PHY_INTR_LINK_CHANGE, MUGE_PHY_INTR_MASK, MUGE_PHY_INTR_STAT, MUGE_PHY_LED_MODE, muge_softc::sc_led_modes, muge_softc::sc_led_modes_mask, muge_softc::sc_leds, muge_softc::sc_phyno, muge_softc::sc_ue, usb_ether::ue_dev, uether_pause(), and USB_MS_TO_TICKS.
Referenced by lan78xx_chip_init().
|
static |
lan78xx_read_reg - Read 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 280 of file if_muge.c.
References data, MUGE_LOCK_ASSERT, muge_warn_printf, req, muge_softc::sc_ue, uether_do_request, USETW, UT_READ_VENDOR_DEVICE, and UVR_READ_REG.
Referenced by lan78xx_chip_init(), lan78xx_dataport_write(), lan78xx_eeprom_read_raw(), lan78xx_miibus_readreg(), lan78xx_miibus_statchg(), lan78xx_otp_read_raw(), lan78xx_phy_init(), lan78xx_set_rx_max_frame_length(), lan78xx_wait_for_bits(), and muge_set_mac_addr().
|
static |
Definition at line 856 of file if_muge.c.
References lan78xx_miibus_readreg, lan78xx_miibus_writereg, MUGE_EXT_MODE_CTRL, MUGE_EXT_MODE_CTRL_AUTO_MDIX_, MUGE_EXT_PAGE_ACCESS, MUGE_EXT_PAGE_SPACE_0, MUGE_EXT_PAGE_SPACE_1, muge_warn_printf, muge_softc::sc_mdix_ctl, muge_softc::sc_phyno, muge_softc::sc_ue, and usb_ether::ue_dev.
Referenced by lan78xx_phy_init().
|
static |
lan78xx_set_rx_max_frame_length @sc: driver soft context @size: pointer to array contain at least 6 bytes of the mac
Sets the maximum frame length to be received. Frames bigger than this size are aborted.
RETURNS: Returns 0 on success or a negative error code.
Definition at line 615 of file if_muge.c.
References ETH_MAC_RX, ETH_MAC_RX_EN_, ETH_MAC_RX_MAX_FR_SIZE_MASK_, ETH_MAC_RX_MAX_FR_SIZE_SHIFT_, lan78xx_read_reg(), lan78xx_write_reg(), and size.
Referenced by lan78xx_chip_init().
|
static |
lan78xx_setmacaddress - Set the mac address in the device @sc: driver soft context @addr: pointer to array contain at least 6 bytes of the mac
LOCKING: Should be called with the MUGE lock held.
RETURNS: Returns 0 on success or a negative error code.
Definition at line 581 of file if_muge.c.
References addr, ETH_RX_ADDRH, ETH_RX_ADDRL, lan78xx_write_reg(), muge_dbg_printf, MUGE_LOCK_ASSERT, and val.
Referenced by lan78xx_chip_init(), and muge_init().
|
static |
lan78xx_wait_for_bits - Poll 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 349 of file if_muge.c.
References lan78xx_read_reg(), MUGE_LOCK_ASSERT, reg, muge_softc::sc_ue, uether_pause(), USB_ERR_TIMEOUT, USB_MS_TO_TICKS, and val.
Referenced by lan78xx_chip_init(), lan78xx_dataport_write(), lan78xx_eeprom_read_raw(), lan78xx_miibus_readreg(), lan78xx_miibus_writereg(), and lan78xx_otp_read_raw().
|
static |
lan78xx_write_reg - Write 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 314 of file if_muge.c.
References data, MUGE_LOCK_ASSERT, muge_warn_printf, req, muge_softc::sc_ue, uether_do_request, USETW, UT_WRITE_VENDOR_DEVICE, and UVR_WRITE_REG.
Referenced by lan78xx_chip_init(), lan78xx_dataport_write(), lan78xx_eeprom_read_raw(), lan78xx_miibus_readreg(), lan78xx_miibus_statchg(), lan78xx_miibus_writereg(), lan78xx_otp_read_raw(), lan78xx_phy_init(), lan78xx_set_rx_max_frame_length(), lan78xx_setmacaddress(), muge_multicast_write(), muge_sethwcsum(), muge_setmulti(), and muge_setpromisc().
MODULE_DEPEND | ( | muge | , |
ether | , | ||
1 | , | ||
1 | , | ||
1 | |||
) |
MODULE_DEPEND | ( | muge | , |
miibus | , | ||
1 | , | ||
1 | , | ||
1 | |||
) |
MODULE_DEPEND | ( | muge | , |
uether | , | ||
1 | , | ||
1 | , | ||
1 | |||
) |
MODULE_DEPEND | ( | muge | , |
usb | , | ||
1 | , | ||
1 | , | ||
1 | |||
) |
MODULE_VERSION | ( | muge | , |
1 | |||
) |
|
static |
muge_attach - Attach the interface. @dev: muge 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 2175 of file if_muge.c.
References dev, usb_attach_arg::device, device_set_usb_desc(), muge_config, MUGE_FLAG_INIT_DONE, MUGE_IFACE_IDX, MUGE_N_TRANSFER, muge_ue_methods, muge_softc::sc_flags, muge_softc::sc_mtx, muge_softc::sc_ue, muge_softc::sc_xfer, usb_ether::ue_dev, usb_ether::ue_methods, usb_ether::ue_mtx, usb_ether::ue_sc, usb_ether::ue_udev, uether_ifattach(), uether_ifattach_wait(), uether_ifdetach(), USB_GET_DRIVER_INFO, usbd_transfer_setup(), and usbd_transfer_unsetup().
|
static |
muge_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 muge_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 1567 of file if_muge.c.
References lan78xx_chip_init(), muge_dbg_printf, muge_set_leds(), muge_set_mac_addr(), muge_softc::sc_phyno, and uether_getsc().
|
static |
muge_attach_post_sub - Called after attach 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 1595 of file if_muge.c.
References error, muge_dbg_printf, MUGE_DEFAULT_TSO_ENABLE, MUGE_DEFAULT_TX_CSUM_ENABLE, muge_ioctl(), muge_softc::sc_phyno, 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().
|
static |
Definition at line 1164 of file if_muge.c.
References error, muge_dbg_printf, muge_warn_printf, RX_CMD_A_ICSM_, RX_CMD_A_LEN_MASK_, RX_CMD_A_RED_, muge_softc::sc_ue, 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().
|
static |
muge_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.
Definition at line 1360 of file if_muge.c.
References error, muge_dbg_printf, muge_err_printf, MUGE_FLAG_LINK, muge_softc::sc_flags, muge_softc::sc_ue, TX_CMD_A_FCS_, TX_CMD_A_LEN_MASK_, 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().
|
static |
muge_detach - Detach the interface. @dev: muge device handle
RETURNS: Returns 0.
Definition at line 2234 of file if_muge.c.
References dev, MUGE_N_TRANSFER, muge_softc::sc_mtx, muge_softc::sc_ue, muge_softc::sc_xfer, uether_ifdetach(), and usbd_transfer_unsetup().
|
inlinestatic |
muge_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 multicast 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 1856 of file if_muge.c.
References addr.
Referenced by muge_hash_maddr().
|
static |
Definition at line 1862 of file if_muge.c.
References ETH_RFE_CTL_MCAST_HASH_, muge_hash(), muge_set_addr_filter(), muge_softc::sc_mchash_table, and muge_softc::sc_rfe_ctl.
Referenced by muge_setmulti().
|
static |
muge_ifmedia_sts - Report current media status @ifp: inet interface pointer @ifmr: interface media request
Call the mii functions to get the media status.
LOCKING: Internally takes and releases the device lock.
Definition at line 2130 of file if_muge.c.
References MUGE_LOCK, MUGE_UNLOCK, muge_softc::sc_ue, and uether_getmii().
|
static |
muge_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 2009 of file if_muge.c.
References muge_dbg_printf, MUGE_LOCK_ASSERT, muge_softc::sc_ue, and uether_getmii().
Referenced by muge_init().
|
static |
muge_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 MUGE lock held.
Definition at line 2036 of file if_muge.c.
References lan78xx_setmacaddress(), MUGE_BULK_DT_WR, muge_dbg_printf, muge_ifmedia_upd(), MUGE_LOCK_ASSERT, muge_reset(), muge_sethwcsum(), muge_setmulti, muge_start, muge_stop, muge_softc::sc_xfer, uether_getifp(), uether_getsc(), and usbd_xfer_set_stall().
|
static |
muge_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 1680 of file if_muge.c.
References data, MUGE_LOCK, MUGE_UNLOCK, uether_getsc(), uether_init(), and uether_ioctl().
Referenced by muge_attach_post_sub().
|
static |
muge_multicast_write @sc: device's soft context
Writes perfect addres filters and hash address filters to their corresponding registers and RAMs.
Definition at line 1828 of file if_muge.c.
References ETH_DP_SEL_RSEL_VLAN_DA_, ETH_DP_SEL_VHF_HASH_LEN, ETH_DP_SEL_VHF_VLAN_LEN, lan78xx_dataport_write(), lan78xx_write_reg(), MUGE_NUM_PFILTER_ADDRS_, PFILTER_HI, PFILTER_LO, muge_softc::sc_mchash_table, and muge_softc::sc_pfilter_table.
Referenced by muge_setmulti().
|
static |
muge_probe - Probe the interface. @dev: muge 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 2152 of file if_muge.c.
References usbd_lookup_info::bConfigIndex, usbd_lookup_info::bIfaceIndex, dev, usb_attach_arg::info, lan78xx_devs, MUGE_CONFIG_INDEX, MUGE_IFACE_IDX, usb_attach_arg::usb_mode, USB_MODE_HOST, and usbd_lookup_id_by_uaa().
|
static |
muge_reset - Reset the SMSC chip @sc: device soft context
LOCKING: Should be called with the SMSC lock held.
Definition at line 1729 of file if_muge.c.
References usb_config_descriptor::bConfigurationValue, lan78xx_chip_init(), muge_warn_printf, muge_softc::sc_mtx, muge_softc::sc_ue, usb_ether::ue_udev, uether_pause(), usbd_get_config_descriptor(), and usbd_req_set_config().
Referenced by muge_init().
|
static |
muge_set_addr_filter
@sc: device soft context @index: index of the entry to the perfect address table @addr: address to be written
Definition at line 1757 of file if_muge.c.
References addr, ETH_MAF_HI_TYPE_DST_, ETH_MAF_HI_VALID_, index, MUGE_NUM_PFILTER_ADDRS_, and muge_softc::sc_pfilter_table.
Referenced by muge_hash_maddr().
|
static |
muge_set_leds - Initializes NIC LEDs pattern @ue: the USB ethernet device
Tries to store the LED modes. Supports only DTB blob like the Linux driver does.
Definition at line 1531 of file if_muge.c.
References count, ETH_HW_CFG_LED1_EN_, ETH_HW_CFG_LED2_EN_, ETH_HW_CFG_LED3_EN_, ETH_HW_CFG_LEDO_EN_, muge_dbg_printf, muge_softc::sc_led_modes, muge_softc::sc_led_modes_mask, muge_softc::sc_leds, usb_ether::ue_dev, usb_ether::ue_udev, uether_getsc(), and usb_fdt_get_node().
Referenced by muge_attach_post().
|
static |
muge_set_mac_addr - Initiailizes NIC MAC address @ue: the USB ethernet device
Tries to obtain MAC address from number of sources: registers, EEPROM, DTB blob. If all sources fail - generates random MAC.
Definition at line 1470 of file if_muge.c.
References ETH_E2P_MAC_OFFSET, ETH_RX_ADDRH, ETH_RX_ADDRL, ETHER_IS_VALID, lan78xx_eeprom_present(), lan78xx_eeprom_read_raw(), lan78xx_otp_read(), lan78xx_read_reg(), muge_dbg_printf, OTP_MAC_OFFSET, usb_ether::ue_dev, usb_ether::ue_eaddr, uether_getsc(), usb_fdt_get_mac_addr(), and val.
Referenced by muge_attach_post().
|
static |
muge_sethwcsum - Enable or disable H/W UDP and TCP checksumming @sc: driver soft context
LOCKING: Should be called with the MUGE lock held.
RETURNS: Returns 0 on success or a negative error code.
Definition at line 1962 of file if_muge.c.
References ETH_RFE_CTL, ETH_RFE_CTL_ICMP_COE_, ETH_RFE_CTL_IGMP_COE_, ETH_RFE_CTL_IP_COE_, ETH_RFE_CTL_TCPUDP_COE_, lan78xx_write_reg(), MUGE_LOCK_ASSERT, muge_warn_printf, muge_softc::sc_rfe_ctl, muge_softc::sc_ue, and uether_getifp().
Referenced by muge_init().
|
static |
muge_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 MUGE lock held.
Definition at line 1890 of file if_muge.c.
References ETH_DP_SEL_VHF_HASH_LEN, ETH_RFE_CTL, ETH_RFE_CTL_BCAST_EN_, ETH_RFE_CTL_DA_PERFECT_, ETH_RFE_CTL_MCAST_EN_, ETH_RFE_CTL_MCAST_HASH_, ETH_RFE_CTL_UCAST_EN_, lan78xx_write_reg(), muge_dbg_printf, muge_hash_maddr(), MUGE_LOCK_ASSERT, muge_multicast_write(), MUGE_NUM_PFILTER_ADDRS_, muge_softc::sc_mchash_table, muge_softc::sc_pfilter_table, muge_softc::sc_rfe_ctl, uether_getifp(), and uether_getsc().
|
static |
muge_setpromisc - Enables/disables promiscuous mode @ue: usb ethernet device context
LOCKING: Should be called with the MUGE lock held.
Definition at line 1933 of file if_muge.c.
References ETH_RFE_CTL, ETH_RFE_CTL_MCAST_EN_, ETH_RFE_CTL_UCAST_EN_, lan78xx_write_reg(), muge_dbg_printf, MUGE_LOCK_ASSERT, muge_softc::sc_rfe_ctl, uether_getifp(), and uether_getsc().
|
static |
muge_start - Starts communication with the LAN78xx chip @ue: USB ether interface
Definition at line 1655 of file if_muge.c.
References MUGE_BULK_DT_RD, MUGE_BULK_DT_WR, muge_softc::sc_xfer, uether_getsc(), and usbd_transfer_start().
|
static |
muge_stop - Stops communication with the LAN78xx chip @ue: USB ether interface
Definition at line 2076 of file if_muge.c.
References MUGE_BULK_DT_RD, MUGE_BULK_DT_WR, MUGE_LOCK_ASSERT, muge_softc::sc_flags, muge_softc::sc_xfer, uether_getifp(), uether_getsc(), and usbd_transfer_stop().
|
static |
muge_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 MUGE lock held.
Definition at line 2103 of file if_muge.c.
References lan78xx_miibus_statchg, MUGE_FLAG_LINK, MUGE_LOCK_ASSERT, muge_start, muge_softc::sc_flags, muge_softc::sc_ue, usb_ether::ue_dev, uether_getmii(), and uether_getsc().
USB_PNP_HOST_INFO | ( | lan78xx_devs | ) |
|
static |
|
static |
Definition at line 207 of file if_muge.c.
Referenced by lan78xx_phy_init(), and lan78xx_set_mdix_auto().
|
static |
Definition at line 209 of file if_muge.c.
Referenced by muge_tick().
|
static |
Definition at line 208 of file if_muge.c.
Referenced by lan78xx_phy_init(), and lan78xx_set_mdix_auto().
|
static |
|
static |
|
static |
|
static |
Definition at line 226 of file if_muge.c.
Referenced by muge_attach().
|
static |
|
static |
|
static |
|
static |
Definition at line 217 of file if_muge.c.
Referenced by muge_init().
|
static |
|
static |
Definition at line 215 of file if_muge.c.
Referenced by muge_init(), and muge_tick().
|
static |
Definition at line 214 of file if_muge.c.
Referenced by muge_init().
|
static |
|
static |
Definition at line 253 of file if_muge.c.
Referenced by muge_attach().