00001
00002 #ifndef __EEPRO100_H_
00003 #define __EEPRO100_H_
00004
00005 FILE_LICENCE ( GPL2_OR_LATER );
00006
00007 #define CONGENB 0
00008 #define TX_FIFO 8
00009 #define RX_FIFO 8
00010 #define TX_DMA_COUNT 0
00011 #define RX_DMA_COUNT 0
00012 #define CU_CMD_TIMEOUT 1000
00013 #define LINK_CHECK_PERIOD 1000
00014
00015 #define RFD_PACKET_LEN 1518
00016 #define RFD_IOB_LEN 1536
00017 #define RFD_HEADER_LEN 16
00018 #define CB_ALIGN 2
00019
00020 #define RFD_COUNT 4
00021 #define TCB_COUNT 4
00022 #define RX_RING_BYTES ( RFD_COUNT * sizeof ( struct ifec_rfd ) )
00023 #define TX_RING_BYTES ( TCB_COUNT * sizeof ( struct ifec_tcb ) )
00024
00025
00026 #define EEPROM_ADDR_MAC_0 0
00027 #define EEPROM_ADDR_MDIO_REGISTER 6
00028
00029
00030 enum CSROffsets {
00031 SCBStatus=0, SCBCmd=2, SCBPointer = 4,
00032 CSRPort=8, CSRFlash=12, CSREeprom = 14,
00033 CSRCtrlMDI=16, CSREarlyRx=20
00034 };
00035
00036
00037 enum SCBCmdBits {
00038
00039 SCBMaskCmdDone=0x8000, SCBMaskRxDone=0x4000, SCBMaskCmdIdle=0x2000,
00040 SCBMaskRxSuspend=0x1000, SCBMaskEarlyRx=0x0800, SCBMaskFlowCtl=0x0400,
00041 SCBTriggerIntr=0x0200, SCBMaskAll=0x0100,
00042
00043 CUStart=0x0010, CUResume=0x0020, CUStatsAddr=0x0040,
00044 CUShowStats=0x0050, CUCmdBase=0x0060, CUDumpStats=0x0070,
00045 RUStart=0x0001, RUResume=0x0002, RUAbort=0x0004,
00046 RUAddrLoad=0x0006, RUResumeNoResources=0x0007
00047 };
00048
00049 enum SCBPortCmds {
00050 PortReset=0, PortSelfTest=1, PortPartialReset=2, PortDump=3
00051 };
00052
00053
00054 enum ActionCommands {
00055 CmdNOp = 0, CmdIASetup = 1, CmdConfigure = 2,
00056 CmdMulticastList = 3, CmdTx = 4, CmdTDR = 5,
00057 CmdDump = 6, CmdDiagnose = 7,
00058
00059 CmdEndOfList = 0x8000,
00060 CmdSuspend = 0x4000, CmdIntr = 0x2000, CmdTxFlex = 0x0008
00061 };
00062
00063 enum TCBBits {
00064 TCB_C=0x8000, TCB_OK=0x2000, TCB_U=0x1000
00065 };
00066
00067 enum RFDBits {
00068
00069 RFDRxCol=0x0001, RFDIAMatch=0x0002, RFDNoMatch=0x0004,
00070 RFDReserved3=0x0008, RFDRxErr=0x0010, RFDEthType=0x0020,
00071 RFDReserved6=0x0040, RFDShort=0x0080, RFDDMAOverrun=0x0100,
00072 RFDNoBufs=0x0200, RFDCRCAlign=0x0400, RFDCRCError=0x0800,
00073 RFDReserved12=0x1000, RFD_OK=0x2000, RFDComplete=0x8000,
00074
00075
00076
00077 RFDMaskCount=0x3FFF
00078 };
00079
00080 enum phy_chips {
00081 NonSuchPhy=0, I82553AB, I82553C,
00082 I82503, DP83840, S80C240,
00083 S80C24, PhyUndefined, DP83840A=10
00084 };
00085
00086
00087
00088
00089 #define EE_SHIFT_CLK 0x01
00090 #define EE_CS 0x02
00091 #define EE_DATA_WRITE 0x04
00092 #define EE_DATA_READ 0x08
00093 #define EE_ENB ( 0x4800 | EE_CS )
00094
00095
00096 struct ifec_stats {
00097 u32
00098 tx_good_frames, tx_coll16_errs, tx_late_colls,
00099 tx_underruns, tx_lost_carrier, tx_deferred,
00100 tx_one_colls, tx_multi_colls, tx_total_colls,
00101 rx_good_frames, rx_crc_errs, rx_align_errs,
00102 rx_resource_errs, rx_overrun_errs, rx_colls_errs,
00103 rx_runt_errs, done_marker;
00104 };
00105
00106 struct ifec_tcb {
00107 volatile s16 status;
00108 u16 command;
00109 u32 link;
00110 u32 tbda_addr;
00111 s32 count;
00112
00113
00114 u32 tbd_addr0;
00115 s32 tbd_size0;
00116
00117 struct io_buffer *iob;
00118 struct ifec_tcb *next;
00119 };
00120
00121 struct ifec_rfd {
00122 volatile s16 status;
00123 s16 command;
00124 u32 link;
00125 u32 rx_buf_addr;
00126 u16 count;
00127 u16 size;
00128 char packet[RFD_PACKET_LEN];
00129 };
00130
00131 struct ifec_ias {
00132 volatile s16 status;
00133 u16 command;
00134 u32 link;
00135 u8 ia[6];
00136 };
00137
00138 struct ifec_cfg {
00139 volatile s16 status;
00140 u16 command;
00141 u32 link;
00142 u8 byte[22];
00143 };
00144
00145 struct ifec_private {
00146 unsigned long ioaddr;
00147 struct ifec_stats stats;
00148 unsigned short mdio_register;
00149
00150 struct ifec_tcb *tcbs;
00151 struct ifec_rfd *rfds[RFD_COUNT];
00152 struct ifec_tcb *tcb_head, *tcb_tail;
00153 struct io_buffer *tx_iobs[TCB_COUNT];
00154 struct io_buffer *rx_iobs[RFD_COUNT];
00155 int cur_rx;
00156 int tx_curr;
00157 int tx_tail;
00158 int tx_cnt;
00159
00160
00161
00162
00163
00164
00165 int configured;
00166 struct spi_bit_basher spi;
00167 struct spi_device eeprom;
00168
00169 };
00170
00171
00172
00173
00174 static int ifec_pci_probe ( struct pci_device*, const struct pci_device_id*);
00175 static void ifec_pci_remove ( struct pci_device *pci );
00176
00177
00178 static void ifec_net_close ( struct net_device* );
00179 static void ifec_net_irq ( struct net_device*, int enable );
00180 static int ifec_net_open ( struct net_device* );
00181 static void ifec_net_poll ( struct net_device* );
00182 static int ifec_net_transmit ( struct net_device*, struct io_buffer *iobuf );
00183
00184
00185 static void ifec_init_eeprom ( struct net_device * );
00186 static int ifec_link_check ( struct net_device * );
00187 static void ifec_link_update ( struct net_device * );
00188 static int ifec_mdio_read ( struct net_device *, int phy, int location );
00189 static void ifec_mdio_setup ( struct net_device *, int options );
00190 static int ifec_mdio_write ( struct net_device *, int phy, int loc, int val);
00191 static void ifec_reset ( struct net_device * );
00192 static void ifec_free ( struct net_device * );
00193 static void ifec_rfd_init ( struct ifec_rfd *rfd, s16 command, u32 link );
00194 static void ifec_rx_process ( struct net_device * );
00195 static void ifec_reprime_ru ( struct net_device * );
00196 static void ifec_check_ru_status ( struct net_device *, unsigned short );
00197 static int ifec_get_rx_desc ( struct net_device *, int ,int ,int );
00198 static void ifec_refill_rx_ring ( struct net_device * );
00199 static int ifec_rx_setup ( struct net_device * );
00200 static int ifec_scb_cmd ( struct net_device *, u32 ptr, u8 cmd );
00201 static int ifec_scb_cmd_wait ( struct net_device * );
00202 static void ifec_tx_process ( struct net_device * );
00203 static int ifec_tx_setup ( struct net_device * );
00204 static void ifec_tx_wake ( struct net_device * );
00205
00206 #endif