iPXE
Data Structures | Defines | Functions | Variables
smsc75xx.h File Reference

SMSC LAN75xx USB Ethernet driver. More...

#include "smscusb.h"

Go to the source code of this file.

Data Structures

struct  smsc75xx_rx_header
 Receive packet header. More...
struct  smsc75xx_tx_header
 Transmit packet header. More...
struct  smsc75xx_byte_statistics
 Byte count statistics. More...
struct  smsc75xx_frame_statistics
 Frame count statistics. More...
struct  smsc75xx_rx_error_statistics
 Receive error statistics. More...
struct  smsc75xx_rx_statistics
 Receive statistics. More...
struct  smsc75xx_tx_error_statistics
 Transmit error statistics. More...
struct  smsc75xx_tx_statistics
 Transmit statistics. More...
struct  smsc75xx_statistics
 Statistics. More...

Defines

#define SMSC75XX_INT_STS   0x00c
 Interrupt status register.
#define SMSC75XX_INT_STS_RDFO_INT   0x00400000UL
 RX FIFO overflow.
#define SMSC75XX_INT_STS_PHY_INT   0x00020000UL
 PHY interrupt.
#define SMSC75XX_HW_CFG   0x010
 Hardware configuration register.
#define SMSC75XX_HW_CFG_BIR   0x00000080UL
 Bulk IN use NAK.
#define SMSC75XX_HW_CFG_LRST   0x00000002UL
 Soft lite reset.
#define SMSC75XX_INT_EP_CTL   0x038
 Interrupt endpoint control register.
#define SMSC75XX_INT_EP_CTL_RDFO_EN   0x00400000UL
 RX FIFO overflow.
#define SMSC75XX_INT_EP_CTL_PHY_EN   0x00020000UL
 PHY interrupt.
#define SMSC75XX_BULK_IN_DLY   0x03c
 Bulk IN delay register.
#define SMSC75XX_BULK_IN_DLY_SET(ticks)   ( (ticks) << 0 )
 Delay / 16.7ns.
#define SMSC75XX_E2P_BASE   0x040
 EEPROM register base.
#define SMSC75XX_RFE_CTL   0x060
 Receive filtering engine control register.
#define SMSC75XX_RFE_CTL_AB   0x00000400UL
 Accept broadcast.
#define SMSC75XX_RFE_CTL_AM   0x00000200UL
 Accept multicast.
#define SMSC75XX_RFE_CTL_AU   0x00000100UL
 Accept unicast.
#define SMSC75XX_FCT_RX_CTL   0x090
 FIFO controller RX FIFO control register.
#define SMSC75XX_FCT_RX_CTL_EN   0x80000000UL
 FCT RX enable.
#define SMSC75XX_FCT_RX_CTL_BAD   0x02000000UL
 Store bad frames.
#define SMSC75XX_FCT_TX_CTL   0x094
 FIFO controller TX FIFO control register.
#define SMSC75XX_FCT_TX_CTL_EN   0x80000000UL
 FCT TX enable.
#define SMSC75XX_MAC_RX   0x104
 MAC receive register.
#define SMSC75XX_MAC_RX_MAX_SIZE(mtu)   ( (mtu) << 16 )
 Max frame size.
#define SMSC75XX_MAC_RX_MAX_SIZE_DEFAULT   SMSC75XX_MAC_RX_MAX_SIZE ( ETH_FRAME_LEN + 4 /* VLAN */ + 4 /* CRC */ )
#define SMSC75XX_MAC_RX_FCS   0x00000010UL
 FCS stripping.
#define SMSC75XX_MAC_RX_EN   0x00000001UL
 RX enable.
#define SMSC75XX_MAC_TX   0x108
 MAC transmit register.
#define SMSC75XX_MAC_TX_EN   0x00000001UL
 TX enable.
#define SMSC75XX_RX_ADDR_BASE   0x118
 MAC receive address register base.
#define SMSC75XX_MII_BASE   0x120
 MII register base.
#define SMSC75XX_MII_PHY_INTR_SOURCE   29
 PHY interrupt source MII register.
#define SMSC75XX_MII_PHY_INTR_MASK   30
 PHY interrupt mask MII register.
#define SMSC75XX_PHY_INTR_ANEG_DONE   0x0040
 PHY interrupt: auto-negotiation complete.
#define SMSC75XX_PHY_INTR_LINK_DOWN   0x0010
 PHY interrupt: link down.
#define SMSC75XX_ADDR_FILT_BASE   0x300
 MAC address perfect filter register base.
#define SMSC75XX_RX_RED   0x00400000UL
 Receive error detected.
#define SMSC75XX_TX_FCS   0x00400000UL
 Insert frame checksum and pad.
#define SMSC75XX_RESET_MAX_WAIT_MS   100
 Maximum time to wait for reset (in milliseconds)
#define SMSC75XX_IN_MAX_FILL   8
 Bulk IN maximum fill level.
#define SMSC75XX_IN_MTU
 Bulk IN buffer size.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
int smsc75xx_dump_statistics (struct smscusb_device *smscusb)
 Dump statistics (for debugging)
int smsc75xx_transmit (struct net_device *netdev, struct io_buffer *iobuf)
 Transmit packet.
void smsc75xx_poll (struct net_device *netdev)
 Poll for completed and received packets.

Variables

struct
usb_endpoint_driver_operations 
smsc75xx_in_operations
 Bulk IN endpoint operations.

Detailed Description

SMSC LAN75xx USB Ethernet driver.

Definition in file smsc75xx.h.


Define Documentation

#define SMSC75XX_INT_STS   0x00c

Interrupt status register.

Definition at line 15 of file smsc75xx.h.

Referenced by smsc75xx_poll().

#define SMSC75XX_INT_STS_RDFO_INT   0x00400000UL

RX FIFO overflow.

Definition at line 16 of file smsc75xx.h.

Referenced by smsc75xx_poll().

#define SMSC75XX_INT_STS_PHY_INT   0x00020000UL

PHY interrupt.

Definition at line 17 of file smsc75xx.h.

Referenced by smsc75xx_poll().

#define SMSC75XX_HW_CFG   0x010

Hardware configuration register.

Definition at line 20 of file smsc75xx.h.

Referenced by smsc75xx_open(), and smsc75xx_reset().

#define SMSC75XX_HW_CFG_BIR   0x00000080UL

Bulk IN use NAK.

Definition at line 21 of file smsc75xx.h.

Referenced by smsc75xx_open().

#define SMSC75XX_HW_CFG_LRST   0x00000002UL

Soft lite reset.

Definition at line 22 of file smsc75xx.h.

Referenced by smsc75xx_reset().

#define SMSC75XX_INT_EP_CTL   0x038

Interrupt endpoint control register.

Definition at line 25 of file smsc75xx.h.

Referenced by smsc75xx_open().

#define SMSC75XX_INT_EP_CTL_RDFO_EN   0x00400000UL

RX FIFO overflow.

Definition at line 26 of file smsc75xx.h.

Referenced by smsc75xx_open().

#define SMSC75XX_INT_EP_CTL_PHY_EN   0x00020000UL

PHY interrupt.

Definition at line 27 of file smsc75xx.h.

Referenced by smsc75xx_open().

#define SMSC75XX_BULK_IN_DLY   0x03c

Bulk IN delay register.

Definition at line 30 of file smsc75xx.h.

Referenced by smsc75xx_open().

#define SMSC75XX_BULK_IN_DLY_SET (   ticks)    ( (ticks) << 0 )

Delay / 16.7ns.

Definition at line 31 of file smsc75xx.h.

Referenced by smsc75xx_open().

#define SMSC75XX_E2P_BASE   0x040

EEPROM register base.

Definition at line 34 of file smsc75xx.h.

Referenced by smsc75xx_probe().

#define SMSC75XX_RFE_CTL   0x060

Receive filtering engine control register.

Definition at line 37 of file smsc75xx.h.

Referenced by smsc75xx_open().

#define SMSC75XX_RFE_CTL_AB   0x00000400UL

Accept broadcast.

Definition at line 38 of file smsc75xx.h.

Referenced by smsc75xx_open().

#define SMSC75XX_RFE_CTL_AM   0x00000200UL

Accept multicast.

Definition at line 39 of file smsc75xx.h.

Referenced by smsc75xx_open().

#define SMSC75XX_RFE_CTL_AU   0x00000100UL

Accept unicast.

Definition at line 40 of file smsc75xx.h.

Referenced by smsc75xx_open().

#define SMSC75XX_FCT_RX_CTL   0x090

FIFO controller RX FIFO control register.

Definition at line 43 of file smsc75xx.h.

Referenced by smsc75xx_open().

#define SMSC75XX_FCT_RX_CTL_EN   0x80000000UL

FCT RX enable.

Definition at line 44 of file smsc75xx.h.

Referenced by smsc75xx_open().

#define SMSC75XX_FCT_RX_CTL_BAD   0x02000000UL

Store bad frames.

Definition at line 45 of file smsc75xx.h.

Referenced by smsc75xx_open().

#define SMSC75XX_FCT_TX_CTL   0x094

FIFO controller TX FIFO control register.

Definition at line 48 of file smsc75xx.h.

Referenced by smsc75xx_open().

#define SMSC75XX_FCT_TX_CTL_EN   0x80000000UL

FCT TX enable.

Definition at line 49 of file smsc75xx.h.

Referenced by smsc75xx_open().

#define SMSC75XX_MAC_RX   0x104

MAC receive register.

Definition at line 52 of file smsc75xx.h.

Referenced by smsc75xx_open().

#define SMSC75XX_MAC_RX_MAX_SIZE (   mtu)    ( (mtu) << 16 )

Max frame size.

Definition at line 53 of file smsc75xx.h.

#define SMSC75XX_MAC_RX_MAX_SIZE_DEFAULT   SMSC75XX_MAC_RX_MAX_SIZE ( ETH_FRAME_LEN + 4 /* VLAN */ + 4 /* CRC */ )

Definition at line 54 of file smsc75xx.h.

Referenced by smsc75xx_open().

#define SMSC75XX_MAC_RX_FCS   0x00000010UL

FCS stripping.

Definition at line 56 of file smsc75xx.h.

Referenced by smsc75xx_open().

#define SMSC75XX_MAC_RX_EN   0x00000001UL

RX enable.

Definition at line 57 of file smsc75xx.h.

Referenced by smsc75xx_open().

#define SMSC75XX_MAC_TX   0x108

MAC transmit register.

Definition at line 60 of file smsc75xx.h.

Referenced by smsc75xx_open().

#define SMSC75XX_MAC_TX_EN   0x00000001UL

TX enable.

Definition at line 61 of file smsc75xx.h.

Referenced by smsc75xx_open().

#define SMSC75XX_RX_ADDR_BASE   0x118

MAC receive address register base.

Definition at line 64 of file smsc75xx.h.

Referenced by smsc75xx_open().

#define SMSC75XX_MII_BASE   0x120

MII register base.

Definition at line 67 of file smsc75xx.h.

Referenced by smsc75xx_probe().

PHY interrupt source MII register.

Definition at line 70 of file smsc75xx.h.

Referenced by smsc75xx_probe().

#define SMSC75XX_MII_PHY_INTR_MASK   30

PHY interrupt mask MII register.

Definition at line 73 of file smsc75xx.h.

Referenced by smsc75xx_open().

#define SMSC75XX_PHY_INTR_ANEG_DONE   0x0040

PHY interrupt: auto-negotiation complete.

Definition at line 76 of file smsc75xx.h.

Referenced by smsc75xx_open().

#define SMSC75XX_PHY_INTR_LINK_DOWN   0x0010

PHY interrupt: link down.

Definition at line 79 of file smsc75xx.h.

Referenced by smsc75xx_open().

#define SMSC75XX_ADDR_FILT_BASE   0x300

MAC address perfect filter register base.

Definition at line 82 of file smsc75xx.h.

Referenced by smsc75xx_open().

#define SMSC75XX_RX_RED   0x00400000UL

Receive error detected.

Definition at line 97 of file smsc75xx.h.

Referenced by smsc75xx_in_complete().

#define SMSC75XX_TX_FCS   0x00400000UL

Insert frame checksum and pad.

Definition at line 110 of file smsc75xx.h.

Referenced by smsc75xx_out_transmit().

#define SMSC75XX_RESET_MAX_WAIT_MS   100

Maximum time to wait for reset (in milliseconds)

Definition at line 203 of file smsc75xx.h.

Referenced by smsc75xx_reset().

#define SMSC75XX_IN_MAX_FILL   8

Bulk IN maximum fill level.

This is a policy decision.

Definition at line 209 of file smsc75xx.h.

Referenced by lan78xx_probe(), and smsc75xx_probe().

#define SMSC75XX_IN_MTU
Value:
( sizeof ( struct smsc75xx_rx_header ) +                \
          ETH_FRAME_LEN + 4 /* possible VLAN header */ )

Bulk IN buffer size.

Definition at line 212 of file smsc75xx.h.

Referenced by lan78xx_probe(), and smsc75xx_probe().


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
int smsc75xx_dump_statistics ( struct smscusb_device smscusb)

Dump statistics (for debugging)

Parameters:
smscusbSMSC USB device
Return values:
rcReturn status code

Definition at line 63 of file smsc75xx.c.

References smsc75xx_rx_error_statistics::alignment, smsc75xx_byte_statistics::broadcast, smsc75xx_frame_statistics::broadcast, smsc75xx_rx_statistics::byte, smsc75xx_tx_statistics::byte, smsc75xx_tx_error_statistics::carrier, smsc75xx_tx_error_statistics::count, DBG_LOG, DBGC, smsc75xx_tx_error_statistics::deferral, smsc75xx_rx_error_statistics::dropped, smsc75xx_rx_statistics::err, smsc75xx_tx_statistics::err, smsc75xx_tx_error_statistics::excessive, smsc75xx_rx_error_statistics::fcs, smsc75xx_tx_error_statistics::fcs, smsc75xx_rx_error_statistics::fragment, smsc75xx_rx_statistics::frame, smsc75xx_tx_statistics::frame, smsc75xx_rx_error_statistics::jabber, smsc75xx_tx_error_statistics::late, le32_to_cpu, smsc75xx_byte_statistics::multicast, smsc75xx_frame_statistics::multicast, smsc75xx_tx_error_statistics::multiple, smsc75xx_rx_error_statistics::oversize, smsc75xx_frame_statistics::pause, rc, smsc75xx_statistics::rx, smsc75xx_tx_error_statistics::single, smscusb_get_statistics(), strerror(), smsc75xx_statistics::tx, smsc75xx_rx_error_statistics::undersize, smsc75xx_byte_statistics::unicast, and smsc75xx_frame_statistics::unicast.

Referenced by lan78xx_close(), and smsc75xx_close().

                                                                {
        struct smsc75xx_statistics stats;
        int rc;

        /* Do nothing unless debugging is enabled */
        if ( ! DBG_LOG )
                return 0;

        /* Get statistics */
        if ( ( rc = smscusb_get_statistics ( smscusb, 0, &stats,
                                             sizeof ( stats ) ) ) != 0 ) {
                DBGC ( smscusb, "SMSC75XX %p could not get statistics: "
                       "%s\n", smscusb, strerror ( rc ) );
                return rc;
        }

        /* Dump statistics */
        DBGC ( smscusb, "SMSC75XX %p RXE fcs %d aln %d frg %d jab %d und %d "
               "ovr %d drp %d\n", smscusb, le32_to_cpu ( stats.rx.err.fcs ),
               le32_to_cpu ( stats.rx.err.alignment ),
               le32_to_cpu ( stats.rx.err.fragment ),
               le32_to_cpu ( stats.rx.err.jabber ),
               le32_to_cpu ( stats.rx.err.undersize ),
               le32_to_cpu ( stats.rx.err.oversize ),
               le32_to_cpu ( stats.rx.err.dropped ) );
        DBGC ( smscusb, "SMSC75XX %p RXB ucast %d bcast %d mcast %d\n",
               smscusb, le32_to_cpu ( stats.rx.byte.unicast ),
               le32_to_cpu ( stats.rx.byte.broadcast ),
               le32_to_cpu ( stats.rx.byte.multicast ) );
        DBGC ( smscusb, "SMSC75XX %p RXF ucast %d bcast %d mcast %d pause "
               "%d\n", smscusb, le32_to_cpu ( stats.rx.frame.unicast ),
               le32_to_cpu ( stats.rx.frame.broadcast ),
               le32_to_cpu ( stats.rx.frame.multicast ),
               le32_to_cpu ( stats.rx.frame.pause ) );
        DBGC ( smscusb, "SMSC75XX %p TXE fcs %d def %d car %d cnt %d sgl %d "
               "mul %d exc %d lat %d\n", smscusb,
               le32_to_cpu ( stats.tx.err.fcs ),
               le32_to_cpu ( stats.tx.err.deferral ),
               le32_to_cpu ( stats.tx.err.carrier ),
               le32_to_cpu ( stats.tx.err.count ),
               le32_to_cpu ( stats.tx.err.single ),
               le32_to_cpu ( stats.tx.err.multiple ),
               le32_to_cpu ( stats.tx.err.excessive ),
               le32_to_cpu ( stats.tx.err.late ) );
        DBGC ( smscusb, "SMSC75XX %p TXB ucast %d bcast %d mcast %d\n",
               smscusb, le32_to_cpu ( stats.tx.byte.unicast ),
               le32_to_cpu ( stats.tx.byte.broadcast ),
               le32_to_cpu ( stats.tx.byte.multicast ) );
        DBGC ( smscusb, "SMSC75XX %p TXF ucast %d bcast %d mcast %d pause "
               "%d\n", smscusb, le32_to_cpu ( stats.tx.frame.unicast ),
               le32_to_cpu ( stats.tx.frame.broadcast ),
               le32_to_cpu ( stats.tx.frame.multicast ),
               le32_to_cpu ( stats.tx.frame.pause ) );

        return 0;
}
int smsc75xx_transmit ( struct net_device netdev,
struct io_buffer iobuf 
)

Transmit packet.

Parameters:
netdevNetwork device
iobufI/O buffer
Return values:
rcReturn status code

Definition at line 403 of file smsc75xx.c.

References net_device::priv, rc, and smsc75xx_out_transmit().

                                                                             {
        struct smscusb_device *smscusb = netdev->priv;
        int rc;

        /* Transmit packet */
        if ( ( rc = smsc75xx_out_transmit ( smscusb, iobuf ) ) != 0 )
                return rc;

        return 0;
}
void smsc75xx_poll ( struct net_device netdev)

Poll for completed and received packets.

Parameters:
netdevNetwork device

Definition at line 419 of file smsc75xx.c.

References smscusb_device::bus, DBGC, DBGC2, ENOBUFS, ENOTTY, smscusb_device::int_sts, netdev_rx_err(), NULL, net_device::priv, rc, SMSC75XX_INT_STS, SMSC75XX_INT_STS_PHY_INT, SMSC75XX_INT_STS_RDFO_INT, smscusb_mii_check_link(), smscusb_writel(), usb_poll(), smscusb_device::usbnet, and usbnet_refill().

                                                 {
        struct smscusb_device *smscusb = netdev->priv;
        uint32_t int_sts;
        int rc;

        /* Poll USB bus */
        usb_poll ( smscusb->bus );

        /* Refill endpoints */
        if ( ( rc = usbnet_refill ( &smscusb->usbnet ) ) != 0 )
                netdev_rx_err ( netdev, NULL, rc );

        /* Do nothing more unless there are interrupts to handle */
        int_sts = smscusb->int_sts;
        if ( ! int_sts )
                return;

        /* Check link status if applicable */
        if ( int_sts & SMSC75XX_INT_STS_PHY_INT ) {
                smscusb_mii_check_link ( smscusb );
                int_sts &= ~SMSC75XX_INT_STS_PHY_INT;
        }

        /* Record RX FIFO overflow if applicable */
        if ( int_sts & SMSC75XX_INT_STS_RDFO_INT ) {
                DBGC2 ( smscusb, "SMSC75XX %p RX FIFO overflowed\n", smscusb );
                netdev_rx_err ( netdev, NULL, -ENOBUFS );
                int_sts &= ~SMSC75XX_INT_STS_RDFO_INT;
        }

        /* Check for unexpected interrupts */
        if ( int_sts ) {
                DBGC ( smscusb, "SMSC75XX %p unexpected interrupt %#08x\n",
                       smscusb, int_sts );
                netdev_rx_err ( netdev, NULL, -ENOTTY );
        }

        /* Clear interrupts */
        if ( ( rc = smscusb_writel ( smscusb, SMSC75XX_INT_STS,
                                     smscusb->int_sts ) ) != 0 )
                netdev_rx_err ( netdev, NULL, rc );
        smscusb->int_sts = 0;
}

Variable Documentation

Bulk IN endpoint operations.

Definition at line 233 of file smsc75xx.c.

Referenced by lan78xx_probe().