iPXE
smsc75xx.h
Go to the documentation of this file.
00001 #ifndef _SMSC75XX_H
00002 #define _SMSC75XX_H
00003 
00004 /** @file
00005  *
00006  * SMSC LAN75xx USB Ethernet driver
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00011 
00012 #include "smscusb.h"
00013 
00014 /** Interrupt status register */
00015 #define SMSC75XX_INT_STS 0x00c
00016 #define SMSC75XX_INT_STS_RDFO_INT       0x00400000UL    /**< RX FIFO overflow */
00017 #define SMSC75XX_INT_STS_PHY_INT        0x00020000UL    /**< PHY interrupt */
00018 
00019 /** Hardware configuration register */
00020 #define SMSC75XX_HW_CFG 0x010
00021 #define SMSC75XX_HW_CFG_BIR             0x00000080UL    /**< Bulk IN use NAK */
00022 #define SMSC75XX_HW_CFG_LRST            0x00000002UL    /**< Soft lite reset */
00023 
00024 /** Interrupt endpoint control register */
00025 #define SMSC75XX_INT_EP_CTL 0x038
00026 #define SMSC75XX_INT_EP_CTL_RDFO_EN     0x00400000UL    /**< RX FIFO overflow */
00027 #define SMSC75XX_INT_EP_CTL_PHY_EN      0x00020000UL    /**< PHY interrupt */
00028 
00029 /** Bulk IN delay register */
00030 #define SMSC75XX_BULK_IN_DLY 0x03c
00031 #define SMSC75XX_BULK_IN_DLY_SET(ticks) ( (ticks) << 0 ) /**< Delay / 16.7ns */
00032 
00033 /** EEPROM register base */
00034 #define SMSC75XX_E2P_BASE 0x040
00035 
00036 /** Receive filtering engine control register */
00037 #define SMSC75XX_RFE_CTL 0x060
00038 #define SMSC75XX_RFE_CTL_AB             0x00000400UL    /**< Accept broadcast */
00039 #define SMSC75XX_RFE_CTL_AM             0x00000200UL    /**< Accept multicast */
00040 #define SMSC75XX_RFE_CTL_AU             0x00000100UL    /**< Accept unicast */
00041 
00042 /** FIFO controller RX FIFO control register */
00043 #define SMSC75XX_FCT_RX_CTL 0x090
00044 #define SMSC75XX_FCT_RX_CTL_EN          0x80000000UL    /**< FCT RX enable */
00045 #define SMSC75XX_FCT_RX_CTL_BAD         0x02000000UL    /**< Store bad frames */
00046 
00047 /** FIFO controller TX FIFO control register */
00048 #define SMSC75XX_FCT_TX_CTL 0x094
00049 #define SMSC75XX_FCT_TX_CTL_EN          0x80000000UL    /**< FCT TX enable */
00050 
00051 /** MAC receive register */
00052 #define SMSC75XX_MAC_RX 0x104
00053 #define SMSC75XX_MAC_RX_MAX_SIZE(mtu)   ( (mtu) << 16 ) /**< Max frame size */
00054 #define SMSC75XX_MAC_RX_MAX_SIZE_DEFAULT \
00055         SMSC75XX_MAC_RX_MAX_SIZE ( ETH_FRAME_LEN + 4 /* VLAN */ + 4 /* CRC */ )
00056 #define SMSC75XX_MAC_RX_FCS             0x00000010UL    /**< FCS stripping */
00057 #define SMSC75XX_MAC_RX_EN              0x00000001UL    /**< RX enable */
00058 
00059 /** MAC transmit register */
00060 #define SMSC75XX_MAC_TX 0x108
00061 #define SMSC75XX_MAC_TX_EN              0x00000001UL    /**< TX enable */
00062 
00063 /** MAC receive address register base */
00064 #define SMSC75XX_RX_ADDR_BASE 0x118
00065 
00066 /** MII register base */
00067 #define SMSC75XX_MII_BASE 0x120
00068 
00069 /** PHY interrupt source MII register */
00070 #define SMSC75XX_MII_PHY_INTR_SOURCE 29
00071 
00072 /** PHY interrupt mask MII register */
00073 #define SMSC75XX_MII_PHY_INTR_MASK 30
00074 
00075 /** PHY interrupt: auto-negotiation complete */
00076 #define SMSC75XX_PHY_INTR_ANEG_DONE 0x0040
00077 
00078 /** PHY interrupt: link down */
00079 #define SMSC75XX_PHY_INTR_LINK_DOWN 0x0010
00080 
00081 /** MAC address perfect filter register base */
00082 #define SMSC75XX_ADDR_FILT_BASE 0x300
00083 
00084 /** Receive packet header */
00085 struct smsc75xx_rx_header {
00086         /** RX command word */
00087         uint32_t command;
00088         /** VLAN tag */
00089         uint16_t vtag;
00090         /** Checksum */
00091         uint16_t csum;
00092         /** Two-byte padding used to align Ethernet payload */
00093         uint16_t pad;
00094 } __attribute__ (( packed ));
00095 
00096 /** Receive error detected */
00097 #define SMSC75XX_RX_RED 0x00400000UL
00098 
00099 /** Transmit packet header */
00100 struct smsc75xx_tx_header {
00101         /** TX command word */
00102         uint32_t command;
00103         /** VLAN tag */
00104         uint16_t tag;
00105         /** Maximum segment size */
00106         uint16_t mss;
00107 } __attribute__ (( packed ));
00108 
00109 /** Insert frame checksum and pad */
00110 #define SMSC75XX_TX_FCS 0x00400000UL
00111 
00112 /** Byte count statistics */
00113 struct smsc75xx_byte_statistics {
00114         /** Unicast byte count */
00115         uint32_t unicast;
00116         /** Broadcast byte count */
00117         uint32_t broadcast;
00118         /** Multicast byte count */
00119         uint32_t multicast;
00120 } __attribute__ (( packed ));
00121 
00122 /** Frame count statistics */
00123 struct smsc75xx_frame_statistics {
00124         /** Unicast frames */
00125         uint32_t unicast;
00126         /** Broadcast frames */
00127         uint32_t broadcast;
00128         /** Multicast frames */
00129         uint32_t multicast;
00130         /** Pause frames */
00131         uint32_t pause;
00132         /** Frames by length category */
00133         uint32_t len[7];
00134 } __attribute__ (( packed ));
00135 
00136 /** Receive error statistics */
00137 struct smsc75xx_rx_error_statistics {
00138         /** FCS errors */
00139         uint32_t fcs;
00140         /** Alignment errors */
00141         uint32_t alignment;
00142         /** Fragment errors */
00143         uint32_t fragment;
00144         /** Jabber errors */
00145         uint32_t jabber;
00146         /** Undersize frame errors */
00147         uint32_t undersize;
00148         /** Oversize frame errors */
00149         uint32_t oversize;
00150         /** Dropped frame errors */
00151         uint32_t dropped;
00152 } __attribute__ (( packed ));
00153 
00154 /** Receive statistics */
00155 struct smsc75xx_rx_statistics {
00156         /** Error statistics */
00157         struct smsc75xx_rx_error_statistics err;
00158         /** Byte count statistics */
00159         struct smsc75xx_byte_statistics byte;
00160         /** Frame count statistics */
00161         struct smsc75xx_frame_statistics frame;
00162 } __attribute__ (( packed ));
00163 
00164 /** Transmit error statistics */
00165 struct smsc75xx_tx_error_statistics {
00166         /** FCS errors */
00167         uint32_t fcs;
00168         /** Excess deferral errors */
00169         uint32_t deferral;
00170         /** Carrier errors */
00171         uint32_t carrier;
00172         /** Bad byte count */
00173         uint32_t count;
00174         /** Single collisions */
00175         uint32_t single;
00176         /** Multiple collisions */
00177         uint32_t multiple;
00178         /** Excession collisions */
00179         uint32_t excessive;
00180         /** Late collisions */
00181         uint32_t late;
00182 } __attribute__ (( packed ));
00183 
00184 /** Transmit statistics */
00185 struct smsc75xx_tx_statistics {
00186         /** Error statistics */
00187         struct smsc75xx_tx_error_statistics err;
00188         /** Byte count statistics */
00189         struct smsc75xx_byte_statistics byte;
00190         /** Frame count statistics */
00191         struct smsc75xx_frame_statistics frame;
00192 } __attribute__ (( packed ));
00193 
00194 /** Statistics */
00195 struct smsc75xx_statistics {
00196         /** Receive statistics */
00197         struct smsc75xx_rx_statistics rx;
00198         /** Transmit statistics */
00199         struct smsc75xx_tx_statistics tx;
00200 } __attribute__ (( packed ));
00201 
00202 /** Maximum time to wait for reset (in milliseconds) */
00203 #define SMSC75XX_RESET_MAX_WAIT_MS 100
00204 
00205 /** Bulk IN maximum fill level
00206  *
00207  * This is a policy decision.
00208  */
00209 #define SMSC75XX_IN_MAX_FILL 8
00210 
00211 /** Bulk IN buffer size */
00212 #define SMSC75XX_IN_MTU                                         \
00213         ( sizeof ( struct smsc75xx_rx_header ) +                \
00214           ETH_FRAME_LEN + 4 /* possible VLAN header */ )
00215 
00216 extern struct usb_endpoint_driver_operations smsc75xx_in_operations;
00217 
00218 extern int smsc75xx_dump_statistics ( struct smscusb_device *smscusb );
00219 extern int smsc75xx_transmit ( struct net_device *netdev,
00220                                struct io_buffer *iobuf );
00221 extern void smsc75xx_poll ( struct net_device *netdev );
00222 
00223 #endif /* _SMSC75XX_H */