via-velocity.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
00003  * All rights reserved.
00004  *
00005  * This software may be redistributed and/or modified under
00006  * the terms of the GNU General Public License as published by the Free
00007  * Software Foundation; either version 2 of the License, or
00008  * any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful, but
00011  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
00012  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
00013  * for more details.
00014  *
00015  * File: via-velocity.h
00016  *
00017  * Purpose: Header file to define driver's private structures.
00018  *
00019  * Author: Chuang Liang-Shing, AJ Jiang
00020  *
00021  * Date: Jan 24, 2003
00022  *
00023  * Changes for Etherboot Port: 
00024  *       Copyright (c) 2006 by Timothy Legge <tlegge@rogers.com>
00025  */
00026 
00027 #ifndef VELOCITY_H
00028 #define VELOCITY_H
00029 
00030 #define VELOCITY_TX_CSUM_SUPPORT
00031 
00032 #define VELOCITY_NAME          "via-velocity"
00033 #define VELOCITY_FULL_DRV_NAM  "VIA Networking Velocity Family Gigabit Ethernet Adapter Driver"
00034 #define VELOCITY_VERSION       "1.13"
00035 
00036 #define PKT_BUF_SZ          1564
00037 
00038 #define MAX_UNITS           8
00039 #define OPTION_DEFAULT      { [0 ... MAX_UNITS-1] = -1}
00040 
00041 #define REV_ID_VT6110       (0)
00042 
00043 #define BYTE_REG_BITS_ON(x,p)       do { writeb(readb((p))|(x),(p));} while (0)
00044 #define WORD_REG_BITS_ON(x,p)       do { writew(readw((p))|(x),(p));} while (0)
00045 #define DWORD_REG_BITS_ON(x,p)      do { writel(readl((p))|(x),(p));} while (0)
00046 
00047 #define BYTE_REG_BITS_IS_ON(x,p)    (readb((p)) & (x))
00048 #define WORD_REG_BITS_IS_ON(x,p)    (readw((p)) & (x))
00049 #define DWORD_REG_BITS_IS_ON(x,p)   (readl((p)) & (x))
00050 
00051 #define BYTE_REG_BITS_OFF(x,p)      do { writeb(readb((p)) & (~(x)),(p));} while (0)
00052 #define WORD_REG_BITS_OFF(x,p)      do { writew(readw((p)) & (~(x)),(p));} while (0)
00053 #define DWORD_REG_BITS_OFF(x,p)     do { writel(readl((p)) & (~(x)),(p));} while (0)
00054 
00055 #define BYTE_REG_BITS_SET(x,m,p)    do { writeb( (readb((p)) & (~(m))) |(x),(p));} while (0)
00056 #define WORD_REG_BITS_SET(x,m,p)    do { writew( (readw((p)) & (~(m))) |(x),(p));} while (0)
00057 #define DWORD_REG_BITS_SET(x,m,p)   do { writel( (readl((p)) & (~(m)))|(x),(p));}  while (0)
00058 
00059 #define VAR_USED(p)     do {(p)=(p);} while (0)
00060 
00061 /*
00062  * Purpose: Structures for MAX RX/TX descriptors.
00063  */
00064 
00065 
00066 #define B_OWNED_BY_CHIP     1
00067 #define B_OWNED_BY_HOST     0
00068 
00069 /*
00070  * Bits in the RSR0 register
00071  */
00072 
00073 #define RSR_DETAG          0x0080
00074 #define RSR_SNTAG          0x0040
00075 #define RSR_RXER           0x0020
00076 #define RSR_RL             0x0010
00077 #define RSR_CE             0x0008
00078 #define RSR_FAE            0x0004
00079 #define RSR_CRC            0x0002
00080 #define RSR_VIDM           0x0001
00081 
00082 /*
00083  * Bits in the RSR1 register
00084  */
00085 
00086 #define RSR_RXOK           0x8000       // rx OK
00087 #define RSR_PFT            0x4000       // Perfect filtering address match
00088 #define RSR_MAR            0x2000       // MAC accept multicast address packet
00089 #define RSR_BAR            0x1000       // MAC accept broadcast address packet
00090 #define RSR_PHY            0x0800       // MAC accept physical address packet
00091 #define RSR_VTAG           0x0400       // 802.1p/1q tagging packet indicator
00092 #define RSR_STP            0x0200       // start of packet
00093 #define RSR_EDP            0x0100       // end of packet
00094 
00095 /*
00096  * Bits in the RSR1 register
00097  */
00098 
00099 #define RSR1_RXOK           0x80        // rx OK
00100 #define RSR1_PFT            0x40        // Perfect filtering address match
00101 #define RSR1_MAR            0x20        // MAC accept multicast address packet
00102 #define RSR1_BAR            0x10        // MAC accept broadcast address packet
00103 #define RSR1_PHY            0x08        // MAC accept physical address packet
00104 #define RSR1_VTAG           0x04        // 802.1p/1q tagging packet indicator
00105 #define RSR1_STP            0x02        // start of packet
00106 #define RSR1_EDP            0x01        // end of packet
00107 
00108 /*
00109  * Bits in the CSM register
00110  */
00111 
00112 #define CSM_IPOK            0x40        //IP Checkusm validatiaon ok
00113 #define CSM_TUPOK           0x20        //TCP/UDP Checkusm validatiaon ok
00114 #define CSM_FRAG            0x10        //Fragment IP datagram
00115 #define CSM_IPKT            0x04        //Received an IP packet
00116 #define CSM_TCPKT           0x02        //Received a TCP packet
00117 #define CSM_UDPKT           0x01        //Received a UDP packet
00118 
00119 /*
00120  * Bits in the TSR0 register
00121  */
00122 
00123 #define TSR0_ABT            0x0080      // Tx abort because of excessive collision
00124 #define TSR0_OWT            0x0040      // Jumbo frame Tx abort
00125 #define TSR0_OWC            0x0020      // Out of window collision
00126 #define TSR0_COLS           0x0010      // experience collision in this transmit event
00127 #define TSR0_NCR3           0x0008      // collision retry counter[3]
00128 #define TSR0_NCR2           0x0004      // collision retry counter[2]
00129 #define TSR0_NCR1           0x0002      // collision retry counter[1]
00130 #define TSR0_NCR0           0x0001      // collision retry counter[0]
00131 #define TSR0_TERR           0x8000      //
00132 #define TSR0_FDX            0x4000      // current transaction is serviced by full duplex mode
00133 #define TSR0_GMII           0x2000      // current transaction is serviced by GMII mode
00134 #define TSR0_LNKFL          0x1000      // packet serviced during link down
00135 #define TSR0_SHDN           0x0400      // shutdown case
00136 #define TSR0_CRS            0x0200      // carrier sense lost
00137 #define TSR0_CDH            0x0100      // AQE test fail (CD heartbeat)
00138 
00139 /*
00140  * Bits in the TSR1 register
00141  */
00142 
00143 #define TSR1_TERR           0x80        //
00144 #define TSR1_FDX            0x40        // current transaction is serviced by full duplex mode
00145 #define TSR1_GMII           0x20        // current transaction is serviced by GMII mode
00146 #define TSR1_LNKFL          0x10        // packet serviced during link down
00147 #define TSR1_SHDN           0x04        // shutdown case
00148 #define TSR1_CRS            0x02        // carrier sense lost
00149 #define TSR1_CDH            0x01        // AQE test fail (CD heartbeat)
00150 
00151 //
00152 // Bits in the TCR0 register
00153 //
00154 #define TCR0_TIC            0x80        // assert interrupt immediately while descriptor has been send complete
00155 #define TCR0_PIC            0x40        // priority interrupt request, INA# is issued over adaptive interrupt scheme
00156 #define TCR0_VETAG          0x20        // enable VLAN tag
00157 #define TCR0_IPCK           0x10        // request IP  checksum calculation.
00158 #define TCR0_UDPCK          0x08        // request UDP checksum calculation.
00159 #define TCR0_TCPCK          0x04        // request TCP checksum calculation.
00160 #define TCR0_JMBO           0x02        // indicate a jumbo packet in GMAC side
00161 #define TCR0_CRC            0x01        // disable CRC generation
00162 
00163 #define TCPLS_NORMAL        3
00164 #define TCPLS_START         2
00165 #define TCPLS_END           1
00166 #define TCPLS_MED           0
00167 
00168 
00169 // max transmit or receive buffer size
00170 #define CB_RX_BUF_SIZE     2048UL       // max buffer size
00171                                         // NOTE: must be multiple of 4
00172 
00173 #define CB_MAX_RD_NUM       512 // MAX # of RD
00174 #define CB_MAX_TD_NUM       256 // MAX # of TD
00175 
00176 #define CB_INIT_RD_NUM_3119 128 // init # of RD, for setup VT3119
00177 #define CB_INIT_TD_NUM_3119 64  // init # of TD, for setup VT3119
00178 
00179 #define CB_INIT_RD_NUM      128 // init # of RD, for setup default
00180 #define CB_INIT_TD_NUM      64  // init # of TD, for setup default
00181 
00182 // for 3119
00183 #define CB_TD_RING_NUM      4   // # of TD rings.
00184 #define CB_MAX_SEG_PER_PKT  7   // max data seg per packet (Tx)
00185 
00186 
00187 /*
00188  *      If collisions excess 15 times , tx will abort, and
00189  *      if tx fifo underflow, tx will fail
00190  *      we should try to resend it
00191  */
00192 
00193 #define CB_MAX_TX_ABORT_RETRY   3
00194 
00195 /*
00196  *      Receive descriptor
00197  */
00198 
00199 struct rdesc0 {
00200         u16 RSR;                /* Receive status */
00201         u16 len:14;             /* Received packet length */
00202         u16 reserved:1;
00203         u16 owner:1;            /* Who owns this buffer ? */
00204 };
00205 
00206 struct rdesc1 {
00207         u16 PQTAG;
00208         u8 CSM;
00209         u8 IPKT;
00210 };
00211 
00212 struct rx_desc {
00213         struct rdesc0 rdesc0;
00214         struct rdesc1 rdesc1;
00215         u32 pa_low;             /* Low 32 bit PCI address */
00216         u16 pa_high;            /* Next 16 bit PCI address (48 total) */
00217         u16 len:15;             /* Frame size */
00218         u16 inten:1;            /* Enable interrupt */
00219 } __attribute__ ((__packed__));
00220 
00221 /*
00222  *      Transmit descriptor
00223  */
00224 
00225 struct tdesc0 {
00226         u16 TSR;                /* Transmit status register */
00227         u16 pktsize:14;         /* Size of frame */
00228         u16 reserved:1;
00229         u16 owner:1;            /* Who owns the buffer */
00230 };
00231 
00232 struct pqinf {                  /* Priority queue info */
00233         u16 VID:12;
00234         u16 CFI:1;
00235         u16 priority:3;
00236 } __attribute__ ((__packed__));
00237 
00238 struct tdesc1 {
00239         struct pqinf pqinf;
00240         u8 TCR;
00241         u8 TCPLS:2;
00242         u8 reserved:2;
00243         u8 CMDZ:4;
00244 } __attribute__ ((__packed__));
00245 
00246 struct td_buf {
00247         u32 pa_low;
00248         u16 pa_high;
00249         u16 bufsize:14;
00250         u16 reserved:1;
00251         u16 queue:1;
00252 } __attribute__ ((__packed__));
00253 
00254 struct tx_desc {
00255         struct tdesc0 tdesc0;
00256         struct tdesc1 tdesc1;
00257         struct td_buf td_buf[7];
00258 };
00259 
00260 #ifdef LINUX
00261 struct velocity_rd_info {
00262         struct sk_buff *skb;
00263         dma_addr_t skb_dma;
00264 };
00265 
00266 
00267 /**
00268  *      alloc_rd_info           -       allocate an rd info block
00269  *
00270  *      Alocate and initialize a receive info structure used for keeping
00271  *      track of kernel side information related to each receive
00272  *      descriptor we are using
00273  */
00274 
00275 static inline struct velocity_rd_info *alloc_rd_info(void)
00276 {
00277         struct velocity_rd_info *ptr;
00278         if ((ptr =
00279              kmalloc(sizeof(struct velocity_rd_info), GFP_ATOMIC)) == NULL)
00280                 return NULL;
00281         else {
00282                 memset(ptr, 0, sizeof(struct velocity_rd_info));
00283                 return ptr;
00284         }
00285 }
00286 
00287 /*
00288  *      Used to track transmit side buffers.
00289  */
00290 
00291 struct velocity_td_info {
00292         struct sk_buff *skb;
00293         u8 *buf;
00294         int nskb_dma;
00295         dma_addr_t skb_dma[7];
00296         dma_addr_t buf_dma;
00297 };
00298 
00299 #endif
00300 enum {
00301         OWNED_BY_HOST = 0,
00302         OWNED_BY_NIC = 1
00303 } velocity_owner;
00304 
00305 
00306 /*
00307  *      MAC registers and macros.
00308  */
00309 
00310 
00311 #define MCAM_SIZE           64
00312 #define VCAM_SIZE           64
00313 #define TX_QUEUE_NO         4
00314 
00315 #define MAX_HW_MIB_COUNTER  32
00316 #define VELOCITY_MIN_MTU    (1514-14)
00317 #define VELOCITY_MAX_MTU    (9000)
00318 
00319 /*
00320  *      Registers in the MAC
00321  */
00322 
00323 #define MAC_REG_PAR         0x00        // physical address
00324 #define MAC_REG_RCR         0x06
00325 #define MAC_REG_TCR         0x07
00326 #define MAC_REG_CR0_SET     0x08
00327 #define MAC_REG_CR1_SET     0x09
00328 #define MAC_REG_CR2_SET     0x0A
00329 #define MAC_REG_CR3_SET     0x0B
00330 #define MAC_REG_CR0_CLR     0x0C
00331 #define MAC_REG_CR1_CLR     0x0D
00332 #define MAC_REG_CR2_CLR     0x0E
00333 #define MAC_REG_CR3_CLR     0x0F
00334 #define MAC_REG_MAR         0x10
00335 #define MAC_REG_CAM         0x10
00336 #define MAC_REG_DEC_BASE_HI 0x18
00337 #define MAC_REG_DBF_BASE_HI 0x1C
00338 #define MAC_REG_ISR_CTL     0x20
00339 #define MAC_REG_ISR_HOTMR   0x20
00340 #define MAC_REG_ISR_TSUPTHR 0x20
00341 #define MAC_REG_ISR_RSUPTHR 0x20
00342 #define MAC_REG_ISR_CTL1    0x21
00343 #define MAC_REG_TXE_SR      0x22
00344 #define MAC_REG_RXE_SR      0x23
00345 #define MAC_REG_ISR         0x24
00346 #define MAC_REG_ISR0        0x24
00347 #define MAC_REG_ISR1        0x25
00348 #define MAC_REG_ISR2        0x26
00349 #define MAC_REG_ISR3        0x27
00350 #define MAC_REG_IMR         0x28
00351 #define MAC_REG_IMR0        0x28
00352 #define MAC_REG_IMR1        0x29
00353 #define MAC_REG_IMR2        0x2A
00354 #define MAC_REG_IMR3        0x2B
00355 #define MAC_REG_TDCSR_SET   0x30
00356 #define MAC_REG_RDCSR_SET   0x32
00357 #define MAC_REG_TDCSR_CLR   0x34
00358 #define MAC_REG_RDCSR_CLR   0x36
00359 #define MAC_REG_RDBASE_LO   0x38
00360 #define MAC_REG_RDINDX      0x3C
00361 #define MAC_REG_TDBASE_LO   0x40
00362 #define MAC_REG_RDCSIZE     0x50
00363 #define MAC_REG_TDCSIZE     0x52
00364 #define MAC_REG_TDINDX      0x54
00365 #define MAC_REG_TDIDX0      0x54
00366 #define MAC_REG_TDIDX1      0x56
00367 #define MAC_REG_TDIDX2      0x58
00368 #define MAC_REG_TDIDX3      0x5A
00369 #define MAC_REG_PAUSE_TIMER 0x5C
00370 #define MAC_REG_RBRDU       0x5E
00371 #define MAC_REG_FIFO_TEST0  0x60
00372 #define MAC_REG_FIFO_TEST1  0x64
00373 #define MAC_REG_CAMADDR     0x68
00374 #define MAC_REG_CAMCR       0x69
00375 #define MAC_REG_GFTEST      0x6A
00376 #define MAC_REG_FTSTCMD     0x6B
00377 #define MAC_REG_MIICFG      0x6C
00378 #define MAC_REG_MIISR       0x6D
00379 #define MAC_REG_PHYSR0      0x6E
00380 #define MAC_REG_PHYSR1      0x6F
00381 #define MAC_REG_MIICR       0x70
00382 #define MAC_REG_MIIADR      0x71
00383 #define MAC_REG_MIIDATA     0x72
00384 #define MAC_REG_SOFT_TIMER0 0x74
00385 #define MAC_REG_SOFT_TIMER1 0x76
00386 #define MAC_REG_CFGA        0x78
00387 #define MAC_REG_CFGB        0x79
00388 #define MAC_REG_CFGC        0x7A
00389 #define MAC_REG_CFGD        0x7B
00390 #define MAC_REG_DCFG0       0x7C
00391 #define MAC_REG_DCFG1       0x7D
00392 #define MAC_REG_MCFG0       0x7E
00393 #define MAC_REG_MCFG1       0x7F
00394 
00395 #define MAC_REG_TBIST       0x80
00396 #define MAC_REG_RBIST       0x81
00397 #define MAC_REG_PMCC        0x82
00398 #define MAC_REG_STICKHW     0x83
00399 #define MAC_REG_MIBCR       0x84
00400 #define MAC_REG_EERSV       0x85
00401 #define MAC_REG_REVID       0x86
00402 #define MAC_REG_MIBREAD     0x88
00403 #define MAC_REG_BPMA        0x8C
00404 #define MAC_REG_EEWR_DATA   0x8C
00405 #define MAC_REG_BPMD_WR     0x8F
00406 #define MAC_REG_BPCMD       0x90
00407 #define MAC_REG_BPMD_RD     0x91
00408 #define MAC_REG_EECHKSUM    0x92
00409 #define MAC_REG_EECSR       0x93
00410 #define MAC_REG_EERD_DATA   0x94
00411 #define MAC_REG_EADDR       0x96
00412 #define MAC_REG_EMBCMD      0x97
00413 #define MAC_REG_JMPSR0      0x98
00414 #define MAC_REG_JMPSR1      0x99
00415 #define MAC_REG_JMPSR2      0x9A
00416 #define MAC_REG_JMPSR3      0x9B
00417 #define MAC_REG_CHIPGSR     0x9C
00418 #define MAC_REG_TESTCFG     0x9D
00419 #define MAC_REG_DEBUG       0x9E
00420 #define MAC_REG_CHIPGCR     0x9F
00421 #define MAC_REG_WOLCR0_SET  0xA0
00422 #define MAC_REG_WOLCR1_SET  0xA1
00423 #define MAC_REG_PWCFG_SET   0xA2
00424 #define MAC_REG_WOLCFG_SET  0xA3
00425 #define MAC_REG_WOLCR0_CLR  0xA4
00426 #define MAC_REG_WOLCR1_CLR  0xA5
00427 #define MAC_REG_PWCFG_CLR   0xA6
00428 #define MAC_REG_WOLCFG_CLR  0xA7
00429 #define MAC_REG_WOLSR0_SET  0xA8
00430 #define MAC_REG_WOLSR1_SET  0xA9
00431 #define MAC_REG_WOLSR0_CLR  0xAC
00432 #define MAC_REG_WOLSR1_CLR  0xAD
00433 #define MAC_REG_PATRN_CRC0  0xB0
00434 #define MAC_REG_PATRN_CRC1  0xB2
00435 #define MAC_REG_PATRN_CRC2  0xB4
00436 #define MAC_REG_PATRN_CRC3  0xB6
00437 #define MAC_REG_PATRN_CRC4  0xB8
00438 #define MAC_REG_PATRN_CRC5  0xBA
00439 #define MAC_REG_PATRN_CRC6  0xBC
00440 #define MAC_REG_PATRN_CRC7  0xBE
00441 #define MAC_REG_BYTEMSK0_0  0xC0
00442 #define MAC_REG_BYTEMSK0_1  0xC4
00443 #define MAC_REG_BYTEMSK0_2  0xC8
00444 #define MAC_REG_BYTEMSK0_3  0xCC
00445 #define MAC_REG_BYTEMSK1_0  0xD0
00446 #define MAC_REG_BYTEMSK1_1  0xD4
00447 #define MAC_REG_BYTEMSK1_2  0xD8
00448 #define MAC_REG_BYTEMSK1_3  0xDC
00449 #define MAC_REG_BYTEMSK2_0  0xE0
00450 #define MAC_REG_BYTEMSK2_1  0xE4
00451 #define MAC_REG_BYTEMSK2_2  0xE8
00452 #define MAC_REG_BYTEMSK2_3  0xEC
00453 #define MAC_REG_BYTEMSK3_0  0xF0
00454 #define MAC_REG_BYTEMSK3_1  0xF4
00455 #define MAC_REG_BYTEMSK3_2  0xF8
00456 #define MAC_REG_BYTEMSK3_3  0xFC
00457 
00458 /*
00459  *      Bits in the RCR register
00460  */
00461 
00462 #define RCR_AS              0x80
00463 #define RCR_AP              0x40
00464 #define RCR_AL              0x20
00465 #define RCR_PROM            0x10
00466 #define RCR_AB              0x08
00467 #define RCR_AM              0x04
00468 #define RCR_AR              0x02
00469 #define RCR_SEP             0x01
00470 
00471 /*
00472  *      Bits in the TCR register
00473  */
00474 
00475 #define TCR_TB2BDIS         0x80
00476 #define TCR_COLTMC1         0x08
00477 #define TCR_COLTMC0         0x04
00478 #define TCR_LB1             0x02        /* loopback[1] */
00479 #define TCR_LB0             0x01        /* loopback[0] */
00480 
00481 /*
00482  *      Bits in the CR0 register
00483  */
00484 
00485 #define CR0_TXON            0x00000008UL
00486 #define CR0_RXON            0x00000004UL
00487 #define CR0_STOP            0x00000002UL        /* stop MAC, default = 1 */
00488 #define CR0_STRT            0x00000001UL        /* start MAC */
00489 #define CR0_SFRST           0x00008000UL        /* software reset */
00490 #define CR0_TM1EN           0x00004000UL
00491 #define CR0_TM0EN           0x00002000UL
00492 #define CR0_DPOLL           0x00000800UL        /* disable rx/tx auto polling */
00493 #define CR0_DISAU           0x00000100UL
00494 #define CR0_XONEN           0x00800000UL
00495 #define CR0_FDXTFCEN        0x00400000UL        /* full-duplex TX flow control enable */
00496 #define CR0_FDXRFCEN        0x00200000UL        /* full-duplex RX flow control enable */
00497 #define CR0_HDXFCEN         0x00100000UL        /* half-duplex flow control enable */
00498 #define CR0_XHITH1          0x00080000UL        /* TX XON high threshold 1 */
00499 #define CR0_XHITH0          0x00040000UL        /* TX XON high threshold 0 */
00500 #define CR0_XLTH1           0x00020000UL        /* TX pause frame low threshold 1 */
00501 #define CR0_XLTH0           0x00010000UL        /* TX pause frame low threshold 0 */
00502 #define CR0_GSPRST          0x80000000UL
00503 #define CR0_FORSRST         0x40000000UL
00504 #define CR0_FPHYRST         0x20000000UL
00505 #define CR0_DIAG            0x10000000UL
00506 #define CR0_INTPCTL         0x04000000UL
00507 #define CR0_GINTMSK1        0x02000000UL
00508 #define CR0_GINTMSK0        0x01000000UL
00509 
00510 /*
00511  *      Bits in the CR1 register
00512  */
00513 
00514 #define CR1_SFRST           0x80        /* software reset */
00515 #define CR1_TM1EN           0x40
00516 #define CR1_TM0EN           0x20
00517 #define CR1_DPOLL           0x08        /* disable rx/tx auto polling */
00518 #define CR1_DISAU           0x01
00519 
00520 /*
00521  *      Bits in the CR2 register
00522  */
00523 
00524 #define CR2_XONEN           0x80
00525 #define CR2_FDXTFCEN        0x40        /* full-duplex TX flow control enable */
00526 #define CR2_FDXRFCEN        0x20        /* full-duplex RX flow control enable */
00527 #define CR2_HDXFCEN         0x10        /* half-duplex flow control enable */
00528 #define CR2_XHITH1          0x08        /* TX XON high threshold 1 */
00529 #define CR2_XHITH0          0x04        /* TX XON high threshold 0 */
00530 #define CR2_XLTH1           0x02        /* TX pause frame low threshold 1 */
00531 #define CR2_XLTH0           0x01        /* TX pause frame low threshold 0 */
00532 
00533 /*
00534  *      Bits in the CR3 register
00535  */
00536 
00537 #define CR3_GSPRST          0x80
00538 #define CR3_FORSRST         0x40
00539 #define CR3_FPHYRST         0x20
00540 #define CR3_DIAG            0x10
00541 #define CR3_INTPCTL         0x04
00542 #define CR3_GINTMSK1        0x02
00543 #define CR3_GINTMSK0        0x01
00544 
00545 #define ISRCTL_UDPINT       0x8000
00546 #define ISRCTL_TSUPDIS      0x4000
00547 #define ISRCTL_RSUPDIS      0x2000
00548 #define ISRCTL_PMSK1        0x1000
00549 #define ISRCTL_PMSK0        0x0800
00550 #define ISRCTL_INTPD        0x0400
00551 #define ISRCTL_HCRLD        0x0200
00552 #define ISRCTL_SCRLD        0x0100
00553 
00554 /*
00555  *      Bits in the ISR_CTL1 register
00556  */
00557 
00558 #define ISRCTL1_UDPINT      0x80
00559 #define ISRCTL1_TSUPDIS     0x40
00560 #define ISRCTL1_RSUPDIS     0x20
00561 #define ISRCTL1_PMSK1       0x10
00562 #define ISRCTL1_PMSK0       0x08
00563 #define ISRCTL1_INTPD       0x04
00564 #define ISRCTL1_HCRLD       0x02
00565 #define ISRCTL1_SCRLD       0x01
00566 
00567 /*
00568  *      Bits in the TXE_SR register
00569  */
00570 
00571 #define TXESR_TFDBS         0x08
00572 #define TXESR_TDWBS         0x04
00573 #define TXESR_TDRBS         0x02
00574 #define TXESR_TDSTR         0x01
00575 
00576 /*
00577  *      Bits in the RXE_SR register
00578  */
00579 
00580 #define RXESR_RFDBS         0x08
00581 #define RXESR_RDWBS         0x04
00582 #define RXESR_RDRBS         0x02
00583 #define RXESR_RDSTR         0x01
00584 
00585 /*
00586  *      Bits in the ISR register
00587  */
00588 
00589 #define ISR_ISR3            0x80000000UL
00590 #define ISR_ISR2            0x40000000UL
00591 #define ISR_ISR1            0x20000000UL
00592 #define ISR_ISR0            0x10000000UL
00593 #define ISR_TXSTLI          0x02000000UL
00594 #define ISR_RXSTLI          0x01000000UL
00595 #define ISR_HFLD            0x00800000UL
00596 #define ISR_UDPI            0x00400000UL
00597 #define ISR_MIBFI           0x00200000UL
00598 #define ISR_SHDNI           0x00100000UL
00599 #define ISR_PHYI            0x00080000UL
00600 #define ISR_PWEI            0x00040000UL
00601 #define ISR_TMR1I           0x00020000UL
00602 #define ISR_TMR0I           0x00010000UL
00603 #define ISR_SRCI            0x00008000UL
00604 #define ISR_LSTPEI          0x00004000UL
00605 #define ISR_LSTEI           0x00002000UL
00606 #define ISR_OVFI            0x00001000UL
00607 #define ISR_FLONI           0x00000800UL
00608 #define ISR_RACEI           0x00000400UL
00609 #define ISR_TXWB1I          0x00000200UL
00610 #define ISR_TXWB0I          0x00000100UL
00611 #define ISR_PTX3I           0x00000080UL
00612 #define ISR_PTX2I           0x00000040UL
00613 #define ISR_PTX1I           0x00000020UL
00614 #define ISR_PTX0I           0x00000010UL
00615 #define ISR_PTXI            0x00000008UL
00616 #define ISR_PRXI            0x00000004UL
00617 #define ISR_PPTXI           0x00000002UL
00618 #define ISR_PPRXI           0x00000001UL
00619 
00620 /*
00621  *      Bits in the IMR register
00622  */
00623 
00624 #define IMR_TXSTLM          0x02000000UL
00625 #define IMR_UDPIM           0x00400000UL
00626 #define IMR_MIBFIM          0x00200000UL
00627 #define IMR_SHDNIM          0x00100000UL
00628 #define IMR_PHYIM           0x00080000UL
00629 #define IMR_PWEIM           0x00040000UL
00630 #define IMR_TMR1IM          0x00020000UL
00631 #define IMR_TMR0IM          0x00010000UL
00632 
00633 #define IMR_SRCIM           0x00008000UL
00634 #define IMR_LSTPEIM         0x00004000UL
00635 #define IMR_LSTEIM          0x00002000UL
00636 #define IMR_OVFIM           0x00001000UL
00637 #define IMR_FLONIM          0x00000800UL
00638 #define IMR_RACEIM          0x00000400UL
00639 #define IMR_TXWB1IM         0x00000200UL
00640 #define IMR_TXWB0IM         0x00000100UL
00641 
00642 #define IMR_PTX3IM          0x00000080UL
00643 #define IMR_PTX2IM          0x00000040UL
00644 #define IMR_PTX1IM          0x00000020UL
00645 #define IMR_PTX0IM          0x00000010UL
00646 #define IMR_PTXIM           0x00000008UL
00647 #define IMR_PRXIM           0x00000004UL
00648 #define IMR_PPTXIM          0x00000002UL
00649 #define IMR_PPRXIM          0x00000001UL
00650 
00651 /* 0x0013FB0FUL  =  initial value of IMR */
00652 
00653 #define INT_MASK_DEF        ( IMR_PPTXIM|IMR_PPRXIM| IMR_PTXIM|IMR_PRXIM | \
00654                             IMR_PWEIM|IMR_TXWB0IM|IMR_TXWB1IM|IMR_FLONIM|  \
00655                             IMR_OVFIM|IMR_LSTEIM|IMR_LSTPEIM|IMR_SRCIM|IMR_MIBFIM|\
00656                             IMR_SHDNIM |IMR_TMR1IM|IMR_TMR0IM|IMR_TXSTLM )
00657 
00658 /*
00659  *      Bits in the TDCSR0/1, RDCSR0 register
00660  */
00661 
00662 #define TRDCSR_DEAD         0x0008
00663 #define TRDCSR_WAK          0x0004
00664 #define TRDCSR_ACT          0x0002
00665 #define TRDCSR_RUN          0x0001
00666 
00667 /*
00668  *      Bits in the CAMADDR register
00669  */
00670 
00671 #define CAMADDR_CAMEN       0x80
00672 #define CAMADDR_VCAMSL      0x40
00673 
00674 /*
00675  *      Bits in the CAMCR register
00676  */
00677 
00678 #define CAMCR_PS1           0x80
00679 #define CAMCR_PS0           0x40
00680 #define CAMCR_AITRPKT       0x20
00681 #define CAMCR_AITR16        0x10
00682 #define CAMCR_CAMRD         0x08
00683 #define CAMCR_CAMWR         0x04
00684 #define CAMCR_PS_CAM_MASK   0x40
00685 #define CAMCR_PS_CAM_DATA   0x80
00686 #define CAMCR_PS_MAR        0x00
00687 
00688 /*
00689  *      Bits in the MIICFG register
00690  */
00691 
00692 #define MIICFG_MPO1         0x80
00693 #define MIICFG_MPO0         0x40
00694 #define MIICFG_MFDC         0x20
00695 
00696 /*
00697  *      Bits in the MIISR register
00698  */
00699 
00700 #define MIISR_MIDLE         0x80
00701 
00702 /*
00703  *       Bits in the PHYSR0 register
00704  */
00705 
00706 #define PHYSR0_PHYRST       0x80
00707 #define PHYSR0_LINKGD       0x40
00708 #define PHYSR0_FDPX         0x10
00709 #define PHYSR0_SPDG         0x08
00710 #define PHYSR0_SPD10        0x04
00711 #define PHYSR0_RXFLC        0x02
00712 #define PHYSR0_TXFLC        0x01
00713 
00714 /*
00715  *      Bits in the PHYSR1 register
00716  */
00717 
00718 #define PHYSR1_PHYTBI       0x01
00719 
00720 /*
00721  *      Bits in the MIICR register
00722  */
00723 
00724 #define MIICR_MAUTO         0x80
00725 #define MIICR_RCMD          0x40
00726 #define MIICR_WCMD          0x20
00727 #define MIICR_MDPM          0x10
00728 #define MIICR_MOUT          0x08
00729 #define MIICR_MDO           0x04
00730 #define MIICR_MDI           0x02
00731 #define MIICR_MDC           0x01
00732 
00733 /*
00734  *      Bits in the MIIADR register
00735  */
00736 
00737 #define MIIADR_SWMPL        0x80
00738 
00739 /*
00740  *      Bits in the CFGA register
00741  */
00742 
00743 #define CFGA_PMHCTG         0x08
00744 #define CFGA_GPIO1PD        0x04
00745 #define CFGA_ABSHDN         0x02
00746 #define CFGA_PACPI          0x01
00747 
00748 /*
00749  *      Bits in the CFGB register
00750  */
00751 
00752 #define CFGB_GTCKOPT        0x80
00753 #define CFGB_MIIOPT         0x40
00754 #define CFGB_CRSEOPT        0x20
00755 #define CFGB_OFSET          0x10
00756 #define CFGB_CRANDOM        0x08
00757 #define CFGB_CAP            0x04
00758 #define CFGB_MBA            0x02
00759 #define CFGB_BAKOPT         0x01
00760 
00761 /*
00762  *      Bits in the CFGC register
00763  */
00764 
00765 #define CFGC_EELOAD         0x80
00766 #define CFGC_BROPT          0x40
00767 #define CFGC_DLYEN          0x20
00768 #define CFGC_DTSEL          0x10
00769 #define CFGC_BTSEL          0x08
00770 #define CFGC_BPS2           0x04        /* bootrom select[2] */
00771 #define CFGC_BPS1           0x02        /* bootrom select[1] */
00772 #define CFGC_BPS0           0x01        /* bootrom select[0] */
00773 
00774 /*
00775  * Bits in the CFGD register
00776  */
00777 
00778 #define CFGD_IODIS          0x80
00779 #define CFGD_MSLVDACEN      0x40
00780 #define CFGD_CFGDACEN       0x20
00781 #define CFGD_PCI64EN        0x10
00782 #define CFGD_HTMRL4         0x08
00783 
00784 /*
00785  *      Bits in the DCFG1 register
00786  */
00787 
00788 #define DCFG_XMWI           0x8000
00789 #define DCFG_XMRM           0x4000
00790 #define DCFG_XMRL           0x2000
00791 #define DCFG_PERDIS         0x1000
00792 #define DCFG_MRWAIT         0x0400
00793 #define DCFG_MWWAIT         0x0200
00794 #define DCFG_LATMEN         0x0100
00795 
00796 /*
00797  *      Bits in the MCFG0 register
00798  */
00799 
00800 #define MCFG_RXARB          0x0080
00801 #define MCFG_RFT1           0x0020
00802 #define MCFG_RFT0           0x0010
00803 #define MCFG_LOWTHOPT       0x0008
00804 #define MCFG_PQEN           0x0004
00805 #define MCFG_RTGOPT         0x0002
00806 #define MCFG_VIDFR          0x0001
00807 
00808 /*
00809  *      Bits in the MCFG1 register
00810  */
00811 
00812 #define MCFG_TXARB          0x8000
00813 #define MCFG_TXQBK1         0x0800
00814 #define MCFG_TXQBK0         0x0400
00815 #define MCFG_TXQNOBK        0x0200
00816 #define MCFG_SNAPOPT        0x0100
00817 
00818 /*
00819  *      Bits in the PMCC  register
00820  */
00821 
00822 #define PMCC_DSI            0x80
00823 #define PMCC_D2_DIS         0x40
00824 #define PMCC_D1_DIS         0x20
00825 #define PMCC_D3C_EN         0x10
00826 #define PMCC_D3H_EN         0x08
00827 #define PMCC_D2_EN          0x04
00828 #define PMCC_D1_EN          0x02
00829 #define PMCC_D0_EN          0x01
00830 
00831 /*
00832  *      Bits in STICKHW
00833  */
00834 
00835 #define STICKHW_SWPTAG      0x10
00836 #define STICKHW_WOLSR       0x08
00837 #define STICKHW_WOLEN       0x04
00838 #define STICKHW_DS1         0x02        /* R/W by software/cfg cycle */
00839 #define STICKHW_DS0         0x01        /* suspend well DS write port */
00840 
00841 /*
00842  *      Bits in the MIBCR register
00843  */
00844 
00845 #define MIBCR_MIBISTOK      0x80
00846 #define MIBCR_MIBISTGO      0x40
00847 #define MIBCR_MIBINC        0x20
00848 #define MIBCR_MIBHI         0x10
00849 #define MIBCR_MIBFRZ        0x08
00850 #define MIBCR_MIBFLSH       0x04
00851 #define MIBCR_MPTRINI       0x02
00852 #define MIBCR_MIBCLR        0x01
00853 
00854 /*
00855  *      Bits in the EERSV register
00856  */
00857 
00858 #define EERSV_BOOT_RPL      ((u8) 0x01) /* Boot method selection for VT6110 */
00859 
00860 #define EERSV_BOOT_MASK     ((u8) 0x06)
00861 #define EERSV_BOOT_INT19    ((u8) 0x00)
00862 #define EERSV_BOOT_INT18    ((u8) 0x02)
00863 #define EERSV_BOOT_LOCAL    ((u8) 0x04)
00864 #define EERSV_BOOT_BEV      ((u8) 0x06)
00865 
00866 
00867 /*
00868  *      Bits in BPCMD
00869  */
00870 
00871 #define BPCMD_BPDNE         0x80
00872 #define BPCMD_EBPWR         0x02
00873 #define BPCMD_EBPRD         0x01
00874 
00875 /*
00876  *      Bits in the EECSR register
00877  */
00878 
00879 #define EECSR_EMBP          0x40        /* eeprom embeded programming */
00880 #define EECSR_RELOAD        0x20        /* eeprom content reload */
00881 #define EECSR_DPM           0x10        /* eeprom direct programming */
00882 #define EECSR_ECS           0x08        /* eeprom CS pin */
00883 #define EECSR_ECK           0x04        /* eeprom CK pin */
00884 #define EECSR_EDI           0x02        /* eeprom DI pin */
00885 #define EECSR_EDO           0x01        /* eeprom DO pin */
00886 
00887 /*
00888  *      Bits in the EMBCMD register
00889  */
00890 
00891 #define EMBCMD_EDONE        0x80
00892 #define EMBCMD_EWDIS        0x08
00893 #define EMBCMD_EWEN         0x04
00894 #define EMBCMD_EWR          0x02
00895 #define EMBCMD_ERD          0x01
00896 
00897 /*
00898  *      Bits in TESTCFG register
00899  */
00900 
00901 #define TESTCFG_HBDIS       0x80
00902 
00903 /*
00904  *      Bits in CHIPGCR register
00905  */
00906 
00907 #define CHIPGCR_FCGMII      0x80
00908 #define CHIPGCR_FCFDX       0x40
00909 #define CHIPGCR_FCRESV      0x20
00910 #define CHIPGCR_FCMODE      0x10
00911 #define CHIPGCR_LPSOPT      0x08
00912 #define CHIPGCR_TM1US       0x04
00913 #define CHIPGCR_TM0US       0x02
00914 #define CHIPGCR_PHYINTEN    0x01
00915 
00916 /*
00917  *      Bits in WOLCR0
00918  */
00919 
00920 #define WOLCR_MSWOLEN7      0x0080      /* enable pattern match filtering */
00921 #define WOLCR_MSWOLEN6      0x0040
00922 #define WOLCR_MSWOLEN5      0x0020
00923 #define WOLCR_MSWOLEN4      0x0010
00924 #define WOLCR_MSWOLEN3      0x0008
00925 #define WOLCR_MSWOLEN2      0x0004
00926 #define WOLCR_MSWOLEN1      0x0002
00927 #define WOLCR_MSWOLEN0      0x0001
00928 #define WOLCR_ARP_EN        0x0001
00929 
00930 /*
00931  *      Bits in WOLCR1
00932  */
00933 
00934 #define WOLCR_LINKOFF_EN      0x0800    /* link off detected enable */
00935 #define WOLCR_LINKON_EN       0x0400    /* link on detected enable */
00936 #define WOLCR_MAGIC_EN        0x0200    /* magic packet filter enable */
00937 #define WOLCR_UNICAST_EN      0x0100    /* unicast filter enable */
00938 
00939 
00940 /*
00941  *      Bits in PWCFG
00942  */
00943 
00944 #define PWCFG_PHYPWOPT          0x80    /* internal MII I/F timing */
00945 #define PWCFG_PCISTICK          0x40    /* PCI sticky R/W enable */
00946 #define PWCFG_WOLTYPE           0x20    /* pulse(1) or button (0) */
00947 #define PWCFG_LEGCY_WOL         0x10
00948 #define PWCFG_PMCSR_PME_SR      0x08
00949 #define PWCFG_PMCSR_PME_EN      0x04    /* control by PCISTICK */
00950 #define PWCFG_LEGACY_WOLSR      0x02    /* Legacy WOL_SR shadow */
00951 #define PWCFG_LEGACY_WOLEN      0x01    /* Legacy WOL_EN shadow */
00952 
00953 /*
00954  *      Bits in WOLCFG
00955  */
00956 
00957 #define WOLCFG_PMEOVR           0x80    /* for legacy use, force PMEEN always */
00958 #define WOLCFG_SAM              0x20    /* accept multicast case reset, default=0 */
00959 #define WOLCFG_SAB              0x10    /* accept broadcast case reset, default=0 */
00960 #define WOLCFG_SMIIACC          0x08    /* ?? */
00961 #define WOLCFG_SGENWH           0x02
00962 #define WOLCFG_PHYINTEN         0x01    /* 0:PHYINT trigger enable, 1:use internal MII
00963                                            to report status change */
00964 /*
00965  *      Bits in WOLSR1
00966  */
00967 
00968 #define WOLSR_LINKOFF_INT      0x0800
00969 #define WOLSR_LINKON_INT       0x0400
00970 #define WOLSR_MAGIC_INT        0x0200
00971 #define WOLSR_UNICAST_INT      0x0100
00972 
00973 /*
00974  *      Ethernet address filter type
00975  */
00976 
00977 #define PKT_TYPE_NONE               0x0000      /* Turn off receiver */
00978 #define PKT_TYPE_DIRECTED           0x0001      /* obselete, directed address is always accepted */
00979 #define PKT_TYPE_MULTICAST          0x0002
00980 #define PKT_TYPE_ALL_MULTICAST      0x0004
00981 #define PKT_TYPE_BROADCAST          0x0008
00982 #define PKT_TYPE_PROMISCUOUS        0x0020
00983 #define PKT_TYPE_LONG               0x2000      /* NOTE.... the definition of LONG is >2048 bytes in our chip */
00984 #define PKT_TYPE_RUNT               0x4000
00985 #define PKT_TYPE_ERROR              0x8000      /* Accept error packets, e.g. CRC error */
00986 
00987 /*
00988  *      Loopback mode
00989  */
00990 
00991 #define MAC_LB_NONE         0x00
00992 #define MAC_LB_INTERNAL     0x01
00993 #define MAC_LB_EXTERNAL     0x02
00994 
00995 /*
00996  *      Enabled mask value of irq
00997  */
00998 
00999 #if defined(_SIM)
01000 #define IMR_MASK_VALUE      0x0033FF0FUL        /* initial value of IMR
01001                                                    set IMR0 to 0x0F according to spec */
01002 
01003 #else
01004 #define IMR_MASK_VALUE      0x0013FB0FUL        /* initial value of IMR
01005                                                    ignore MIBFI,RACEI to
01006                                                    reduce intr. frequency
01007                                                    NOTE.... do not enable NoBuf int mask at driver driver
01008                                                    when (1) NoBuf -> RxThreshold = SF
01009                                                    (2) OK    -> RxThreshold = original value
01010                                                  */
01011 #endif
01012 
01013 /*
01014  *      Revision id
01015  */
01016 
01017 #define REV_ID_VT3119_A0        0x00
01018 #define REV_ID_VT3119_A1        0x01
01019 #define REV_ID_VT3216_A0        0x10
01020 
01021 /*
01022  *      Max time out delay time
01023  */
01024 
01025 #define W_MAX_TIMEOUT       0x0FFFU
01026 
01027 
01028 /*
01029  *      MAC registers as a structure. Cannot be directly accessed this
01030  *      way but generates offsets for readl/writel() calls
01031  */
01032 
01033 struct mac_regs {
01034         volatile u8 PAR[6];     /* 0x00 */
01035         volatile u8 RCR;
01036         volatile u8 TCR;
01037 
01038         volatile u32 CR0Set;    /* 0x08 */
01039         volatile u32 CR0Clr;    /* 0x0C */
01040 
01041         volatile u8 MARCAM[8];  /* 0x10 */
01042 
01043         volatile u32 DecBaseHi; /* 0x18 */
01044         volatile u16 DbfBaseHi; /* 0x1C */
01045         volatile u16 reserved_1E;
01046 
01047         volatile u16 ISRCTL;    /* 0x20 */
01048         volatile u8 TXESR;
01049         volatile u8 RXESR;
01050 
01051         volatile u32 ISR;       /* 0x24 */
01052         volatile u32 IMR;
01053 
01054         volatile u32 TDStatusPort;      /* 0x2C */
01055 
01056         volatile u16 TDCSRSet;  /* 0x30 */
01057         volatile u8 RDCSRSet;
01058         volatile u8 reserved_33;
01059         volatile u16 TDCSRClr;
01060         volatile u8 RDCSRClr;
01061         volatile u8 reserved_37;
01062 
01063         volatile u32 RDBaseLo;  /* 0x38 */
01064         volatile u16 RDIdx;     /* 0x3C */
01065         volatile u16 reserved_3E;
01066 
01067         volatile u32 TDBaseLo[4];       /* 0x40 */
01068 
01069         volatile u16 RDCSize;   /* 0x50 */
01070         volatile u16 TDCSize;   /* 0x52 */
01071         volatile u16 TDIdx[4];  /* 0x54 */
01072         volatile u16 tx_pause_timer;    /* 0x5C */
01073         volatile u16 RBRDU;     /* 0x5E */
01074 
01075         volatile u32 FIFOTest0; /* 0x60 */
01076         volatile u32 FIFOTest1; /* 0x64 */
01077 
01078         volatile u8 CAMADDR;    /* 0x68 */
01079         volatile u8 CAMCR;      /* 0x69 */
01080         volatile u8 GFTEST;     /* 0x6A */
01081         volatile u8 FTSTCMD;    /* 0x6B */
01082 
01083         volatile u8 MIICFG;     /* 0x6C */
01084         volatile u8 MIISR;
01085         volatile u8 PHYSR0;
01086         volatile u8 PHYSR1;
01087         volatile u8 MIICR;
01088         volatile u8 MIIADR;
01089         volatile u16 MIIDATA;
01090 
01091         volatile u16 SoftTimer0;        /* 0x74 */
01092         volatile u16 SoftTimer1;
01093 
01094         volatile u8 CFGA;       /* 0x78 */
01095         volatile u8 CFGB;
01096         volatile u8 CFGC;
01097         volatile u8 CFGD;
01098 
01099         volatile u16 DCFG;      /* 0x7C */
01100         volatile u16 MCFG;
01101 
01102         volatile u8 TBIST;      /* 0x80 */
01103         volatile u8 RBIST;
01104         volatile u8 PMCPORT;
01105         volatile u8 STICKHW;
01106 
01107         volatile u8 MIBCR;      /* 0x84 */
01108         volatile u8 reserved_85;
01109         volatile u8 rev_id;
01110         volatile u8 PORSTS;
01111 
01112         volatile u32 MIBData;   /* 0x88 */
01113 
01114         volatile u16 EEWrData;
01115 
01116         volatile u8 reserved_8E;
01117         volatile u8 BPMDWr;
01118         volatile u8 BPCMD;
01119         volatile u8 BPMDRd;
01120 
01121         volatile u8 EECHKSUM;   /* 0x92 */
01122         volatile u8 EECSR;
01123 
01124         volatile u16 EERdData;  /* 0x94 */
01125         volatile u8 EADDR;
01126         volatile u8 EMBCMD;
01127 
01128 
01129         volatile u8 JMPSR0;     /* 0x98 */
01130         volatile u8 JMPSR1;
01131         volatile u8 JMPSR2;
01132         volatile u8 JMPSR3;
01133         volatile u8 CHIPGSR;    /* 0x9C */
01134         volatile u8 TESTCFG;
01135         volatile u8 DEBUG;
01136         volatile u8 CHIPGCR;
01137 
01138         volatile u16 WOLCRSet;  /* 0xA0 */
01139         volatile u8 PWCFGSet;
01140         volatile u8 WOLCFGSet;
01141 
01142         volatile u16 WOLCRClr;  /* 0xA4 */
01143         volatile u8 PWCFGCLR;
01144         volatile u8 WOLCFGClr;
01145 
01146         volatile u16 WOLSRSet;  /* 0xA8 */
01147         volatile u16 reserved_AA;
01148 
01149         volatile u16 WOLSRClr;  /* 0xAC */
01150         volatile u16 reserved_AE;
01151 
01152         volatile u16 PatternCRC[8];     /* 0xB0 */
01153         volatile u32 ByteMask[4][4];    /* 0xC0 */
01154 } __attribute__ ((__packed__));
01155 
01156 
01157 enum hw_mib {
01158         HW_MIB_ifRxAllPkts = 0,
01159         HW_MIB_ifRxOkPkts,
01160         HW_MIB_ifTxOkPkts,
01161         HW_MIB_ifRxErrorPkts,
01162         HW_MIB_ifRxRuntOkPkt,
01163         HW_MIB_ifRxRuntErrPkt,
01164         HW_MIB_ifRx64Pkts,
01165         HW_MIB_ifTx64Pkts,
01166         HW_MIB_ifRx65To127Pkts,
01167         HW_MIB_ifTx65To127Pkts,
01168         HW_MIB_ifRx128To255Pkts,
01169         HW_MIB_ifTx128To255Pkts,
01170         HW_MIB_ifRx256To511Pkts,
01171         HW_MIB_ifTx256To511Pkts,
01172         HW_MIB_ifRx512To1023Pkts,
01173         HW_MIB_ifTx512To1023Pkts,
01174         HW_MIB_ifRx1024To1518Pkts,
01175         HW_MIB_ifTx1024To1518Pkts,
01176         HW_MIB_ifTxEtherCollisions,
01177         HW_MIB_ifRxPktCRCE,
01178         HW_MIB_ifRxJumboPkts,
01179         HW_MIB_ifTxJumboPkts,
01180         HW_MIB_ifRxMacControlFrames,
01181         HW_MIB_ifTxMacControlFrames,
01182         HW_MIB_ifRxPktFAE,
01183         HW_MIB_ifRxLongOkPkt,
01184         HW_MIB_ifRxLongPktErrPkt,
01185         HW_MIB_ifTXSQEErrors,
01186         HW_MIB_ifRxNobuf,
01187         HW_MIB_ifRxSymbolErrors,
01188         HW_MIB_ifInRangeLengthErrors,
01189         HW_MIB_ifLateCollisions,
01190         HW_MIB_SIZE
01191 };
01192 
01193 enum chip_type {
01194         CHIP_TYPE_VT6110 = 1,
01195 };
01196 
01197 struct velocity_info_tbl {
01198         enum chip_type chip_id;
01199         char *name;
01200         int io_size;
01201         int txqueue;
01202         u32 flags;
01203 };
01204 
01205 static struct velocity_info_tbl *info;
01206 
01207 #define mac_hw_mibs_init(regs) {\
01208         BYTE_REG_BITS_ON(MIBCR_MIBFRZ,&((regs)->MIBCR));\
01209         BYTE_REG_BITS_ON(MIBCR_MIBCLR,&((regs)->MIBCR));\
01210         do {}\
01211                 while (BYTE_REG_BITS_IS_ON(MIBCR_MIBCLR,&((regs)->MIBCR)));\
01212         BYTE_REG_BITS_OFF(MIBCR_MIBFRZ,&((regs)->MIBCR));\
01213 }
01214 
01215 #define mac_read_isr(regs)              readl(&((regs)->ISR))
01216 #define mac_write_isr(regs, x)          writel((x),&((regs)->ISR))
01217 #define mac_clear_isr(regs)             writel(0xffffffffL,&((regs)->ISR))
01218 
01219 #define mac_write_int_mask(mask, regs)  writel((mask),&((regs)->IMR));
01220 #define mac_disable_int(regs)           writel(CR0_GINTMSK1,&((regs)->CR0Clr))
01221 #define mac_enable_int(regs)            writel(CR0_GINTMSK1,&((regs)->CR0Set))
01222 
01223 #define mac_hw_mibs_read(regs, MIBs) {\
01224         int i;\
01225         BYTE_REG_BITS_ON(MIBCR_MPTRINI,&((regs)->MIBCR));\
01226         for (i=0;i<HW_MIB_SIZE;i++) {\
01227                 (MIBs)[i]=readl(&((regs)->MIBData));\
01228         }\
01229 }
01230 
01231 #define mac_set_dma_length(regs, n) {\
01232         BYTE_REG_BITS_SET((n),0x07,&((regs)->DCFG));\
01233 }
01234 
01235 #define mac_set_rx_thresh(regs, n) {\
01236         BYTE_REG_BITS_SET((n),(MCFG_RFT0|MCFG_RFT1),&((regs)->MCFG));\
01237 }
01238 
01239 #define mac_rx_queue_run(regs) {\
01240         writeb(TRDCSR_RUN, &((regs)->RDCSRSet));\
01241 }
01242 
01243 #define mac_rx_queue_wake(regs) {\
01244         writeb(TRDCSR_WAK, &((regs)->RDCSRSet));\
01245 }
01246 
01247 #define mac_tx_queue_run(regs, n) {\
01248         writew(TRDCSR_RUN<<((n)*4),&((regs)->TDCSRSet));\
01249 }
01250 
01251 #define mac_tx_queue_wake(regs, n) {\
01252         writew(TRDCSR_WAK<<(n*4),&((regs)->TDCSRSet));\
01253 }
01254 
01255 #define mac_eeprom_reload(regs) {\
01256         int i=0;\
01257         BYTE_REG_BITS_ON(EECSR_RELOAD,&((regs)->EECSR));\
01258         do {\
01259                 udelay(10);\
01260                 if (i++>0x1000) {\
01261                         break;\
01262                 }\
01263         }while (BYTE_REG_BITS_IS_ON(EECSR_RELOAD,&((regs)->EECSR)));\
01264 }
01265 
01266 enum velocity_cam_type {
01267         VELOCITY_VLAN_ID_CAM = 0,
01268         VELOCITY_MULTICAST_CAM
01269 };
01270 
01271 /**
01272  *      mac_get_cam_mask        -       Read a CAM mask
01273  *      @regs: register block for this velocity
01274  *      @mask: buffer to store mask
01275  *      @cam_type: CAM to fetch
01276  *
01277  *      Fetch the mask bits of the selected CAM and store them into the
01278  *      provided mask buffer.
01279  */
01280 
01281 static inline void mac_get_cam_mask(struct mac_regs *regs, u8 * mask,
01282                                     enum velocity_cam_type cam_type)
01283 {
01284         int i;
01285         /* Select CAM mask */
01286         BYTE_REG_BITS_SET(CAMCR_PS_CAM_MASK, CAMCR_PS1 | CAMCR_PS0,
01287                           &regs->CAMCR);
01288 
01289         if (cam_type == VELOCITY_VLAN_ID_CAM)
01290                 writeb(CAMADDR_VCAMSL, &regs->CAMADDR);
01291         else
01292                 writeb(0, &regs->CAMADDR);
01293 
01294         /* read mask */
01295         for (i = 0; i < 8; i++)
01296                 *mask++ = readb(&(regs->MARCAM[i]));
01297 
01298         /* disable CAMEN */
01299         writeb(0, &regs->CAMADDR);
01300 
01301         /* Select mar */
01302         BYTE_REG_BITS_SET(CAMCR_PS_MAR, CAMCR_PS1 | CAMCR_PS0,
01303                           &regs->CAMCR);
01304 
01305 }
01306 
01307 /**
01308  *      mac_set_cam_mask        -       Set a CAM mask
01309  *      @regs: register block for this velocity
01310  *      @mask: CAM mask to load
01311  *      @cam_type: CAM to store
01312  *
01313  *      Store a new mask into a CAM
01314  */
01315 
01316 static inline void mac_set_cam_mask(struct mac_regs *regs, u8 * mask,
01317                                     enum velocity_cam_type cam_type)
01318 {
01319         int i;
01320         /* Select CAM mask */
01321         BYTE_REG_BITS_SET(CAMCR_PS_CAM_MASK, CAMCR_PS1 | CAMCR_PS0,
01322                           &regs->CAMCR);
01323 
01324         if (cam_type == VELOCITY_VLAN_ID_CAM)
01325                 writeb(CAMADDR_CAMEN | CAMADDR_VCAMSL, &regs->CAMADDR);
01326         else
01327                 writeb(CAMADDR_CAMEN, &regs->CAMADDR);
01328 
01329         for (i = 0; i < 8; i++) {
01330                 writeb(*mask++, &(regs->MARCAM[i]));
01331         }
01332         /* disable CAMEN */
01333         writeb(0, &regs->CAMADDR);
01334 
01335         /* Select mar */
01336         BYTE_REG_BITS_SET(CAMCR_PS_MAR, CAMCR_PS1 | CAMCR_PS0,
01337                           &regs->CAMCR);
01338 }
01339 
01340 /**
01341  *      mac_set_cam     -       set CAM data
01342  *      @regs: register block of this velocity
01343  *      @idx: Cam index
01344  *      @addr: 2 or 6 bytes of CAM data
01345  *      @cam_type: CAM to load
01346  *
01347  *      Load an address or vlan tag into a CAM
01348  */
01349 
01350 static inline void mac_set_cam(struct mac_regs *regs, int idx, u8 * addr,
01351                                enum velocity_cam_type cam_type)
01352 {
01353         int i;
01354 
01355         /* Select CAM mask */
01356         BYTE_REG_BITS_SET(CAMCR_PS_CAM_DATA, CAMCR_PS1 | CAMCR_PS0,
01357                           &regs->CAMCR);
01358 
01359         idx &= (64 - 1);
01360 
01361         if (cam_type == VELOCITY_VLAN_ID_CAM)
01362                 writeb(CAMADDR_CAMEN | CAMADDR_VCAMSL | idx,
01363                        &regs->CAMADDR);
01364         else
01365                 writeb(CAMADDR_CAMEN | idx, &regs->CAMADDR);
01366 
01367         if (cam_type == VELOCITY_VLAN_ID_CAM)
01368                 writew(*((u16 *) addr), &regs->MARCAM[0]);
01369         else {
01370                 for (i = 0; i < 6; i++) {
01371                         writeb(*addr++, &(regs->MARCAM[i]));
01372                 }
01373         }
01374         BYTE_REG_BITS_ON(CAMCR_CAMWR, &regs->CAMCR);
01375 
01376         udelay(10);
01377 
01378         writeb(0, &regs->CAMADDR);
01379 
01380         /* Select mar */
01381         BYTE_REG_BITS_SET(CAMCR_PS_MAR, CAMCR_PS1 | CAMCR_PS0,
01382                           &regs->CAMCR);
01383 }
01384 
01385 /**
01386  *      mac_get_cam     -       fetch CAM data
01387  *      @regs: register block of this velocity
01388  *      @idx: Cam index
01389  *      @addr: buffer to hold up to 6 bytes of CAM data
01390  *      @cam_type: CAM to load
01391  *
01392  *      Load an address or vlan tag from a CAM into the buffer provided by
01393  *      the caller. VLAN tags are 2 bytes the address cam entries are 6.
01394  */
01395 
01396 static inline void mac_get_cam(struct mac_regs *regs, int idx, u8 * addr,
01397                                enum velocity_cam_type cam_type)
01398 {
01399         int i;
01400 
01401         /* Select CAM mask */
01402         BYTE_REG_BITS_SET(CAMCR_PS_CAM_DATA, CAMCR_PS1 | CAMCR_PS0,
01403                           &regs->CAMCR);
01404 
01405         idx &= (64 - 1);
01406 
01407         if (cam_type == VELOCITY_VLAN_ID_CAM)
01408                 writeb(CAMADDR_CAMEN | CAMADDR_VCAMSL | idx,
01409                        &regs->CAMADDR);
01410         else
01411                 writeb(CAMADDR_CAMEN | idx, &regs->CAMADDR);
01412 
01413         BYTE_REG_BITS_ON(CAMCR_CAMRD, &regs->CAMCR);
01414 
01415         udelay(10);
01416 
01417         if (cam_type == VELOCITY_VLAN_ID_CAM)
01418                 *((u16 *) addr) = readw(&(regs->MARCAM[0]));
01419         else
01420                 for (i = 0; i < 6; i++, addr++)
01421                         *((u8 *) addr) = readb(&(regs->MARCAM[i]));
01422 
01423         writeb(0, &regs->CAMADDR);
01424 
01425         /* Select mar */
01426         BYTE_REG_BITS_SET(CAMCR_PS_MAR, CAMCR_PS1 | CAMCR_PS0,
01427                           &regs->CAMCR);
01428 }
01429 
01430 /**
01431  *      mac_wol_reset   -       reset WOL after exiting low power
01432  *      @regs: register block of this velocity
01433  *
01434  *      Called after we drop out of wake on lan mode in order to
01435  *      reset the Wake on lan features. This function doesn't restore
01436  *      the rest of the logic from the result of sleep/wakeup
01437  */
01438 
01439 inline static void mac_wol_reset(struct mac_regs *regs)
01440 {
01441 
01442         /* Turn off SWPTAG right after leaving power mode */
01443         BYTE_REG_BITS_OFF(STICKHW_SWPTAG, &regs->STICKHW);
01444         /* clear sticky bits */
01445         BYTE_REG_BITS_OFF((STICKHW_DS1 | STICKHW_DS0), &regs->STICKHW);
01446 
01447         BYTE_REG_BITS_OFF(CHIPGCR_FCGMII, &regs->CHIPGCR);
01448         BYTE_REG_BITS_OFF(CHIPGCR_FCMODE, &regs->CHIPGCR);
01449         /* disable force PME-enable */
01450         writeb(WOLCFG_PMEOVR, &regs->WOLCFGClr);
01451         /* disable power-event config bit */
01452         writew(0xFFFF, &regs->WOLCRClr);
01453         /* clear power status */
01454         writew(0xFFFF, &regs->WOLSRClr);
01455 }
01456 
01457 
01458 /*
01459  * Header for WOL definitions. Used to compute hashes
01460  */
01461 
01462 typedef u8 MCAM_ADDR[ETH_ALEN];
01463 
01464 struct arp_packet {
01465         u8 dest_mac[ETH_ALEN];
01466         u8 src_mac[ETH_ALEN];
01467         u16 type;
01468         u16 ar_hrd;
01469         u16 ar_pro;
01470         u8 ar_hln;
01471         u8 ar_pln;
01472         u16 ar_op;
01473         u8 ar_sha[ETH_ALEN];
01474         u8 ar_sip[4];
01475         u8 ar_tha[ETH_ALEN];
01476         u8 ar_tip[4];
01477 } __attribute__ ((__packed__));
01478 
01479 struct _magic_packet {
01480         u8 dest_mac[6];
01481         u8 src_mac[6];
01482         u16 type;
01483         u8 MAC[16][6];
01484         u8 password[6];
01485 } __attribute__ ((__packed__));
01486 
01487 /*
01488  *      Store for chip context when saving and restoring status. Not
01489  *      all fields are saved/restored currently.
01490  */
01491 
01492 struct velocity_context {
01493         u8 mac_reg[256];
01494         MCAM_ADDR cam_addr[MCAM_SIZE];
01495         u16 vcam[VCAM_SIZE];
01496         u32 cammask[2];
01497         u32 patcrc[2];
01498         u32 pattern[8];
01499 };
01500 
01501 
01502 /*
01503  *      MII registers.
01504  */
01505 
01506 
01507 /*
01508  *      Registers in the MII (offset unit is WORD)
01509  */
01510 
01511 #define MII_REG_BMCR        0x00        // physical address
01512 #define MII_REG_BMSR        0x01        //
01513 #define MII_REG_PHYID1      0x02        // OUI
01514 #define MII_REG_PHYID2      0x03        // OUI + Module ID + REV ID
01515 #define MII_REG_ANAR        0x04        //
01516 #define MII_REG_ANLPAR      0x05        //
01517 #define MII_REG_G1000CR     0x09        //
01518 #define MII_REG_G1000SR     0x0A        //
01519 #define MII_REG_MODCFG      0x10        //
01520 #define MII_REG_TCSR        0x16        //
01521 #define MII_REG_PLED        0x1B        //
01522 // NS, MYSON only
01523 #define MII_REG_PCR         0x17        //
01524 // ESI only
01525 #define MII_REG_PCSR        0x17        //
01526 #define MII_REG_AUXCR       0x1C        //
01527 
01528 // Marvell 88E1000/88E1000S
01529 #define MII_REG_PSCR        0x10        // PHY specific control register
01530 
01531 //
01532 // Bits in the BMCR register
01533 //
01534 #define BMCR_RESET          0x8000      //
01535 #define BMCR_LBK            0x4000      //
01536 #define BMCR_SPEED100       0x2000      //
01537 #define BMCR_AUTO           0x1000      //
01538 #define BMCR_PD             0x0800      //
01539 #define BMCR_ISO            0x0400      //
01540 #define BMCR_REAUTO         0x0200      //
01541 #define BMCR_FDX            0x0100      //
01542 #define BMCR_SPEED1G        0x0040      //
01543 //
01544 // Bits in the BMSR register
01545 //
01546 #define BMSR_AUTOCM         0x0020      //
01547 #define BMSR_LNK            0x0004      //
01548 
01549 //
01550 // Bits in the ANAR register
01551 //
01552 #define ANAR_ASMDIR         0x0800      // Asymmetric PAUSE support
01553 #define ANAR_PAUSE          0x0400      // Symmetric PAUSE Support
01554 #define ANAR_T4             0x0200      //
01555 #define ANAR_TXFD           0x0100      //
01556 #define ANAR_TX             0x0080      //
01557 #define ANAR_10FD           0x0040      //
01558 #define ANAR_10             0x0020      //
01559 //
01560 // Bits in the ANLPAR register
01561 //
01562 #define ANLPAR_ASMDIR       0x0800      // Asymmetric PAUSE support
01563 #define ANLPAR_PAUSE        0x0400      // Symmetric PAUSE Support
01564 #define ANLPAR_T4           0x0200      //
01565 #define ANLPAR_TXFD         0x0100      //
01566 #define ANLPAR_TX           0x0080      //
01567 #define ANLPAR_10FD         0x0040      //
01568 #define ANLPAR_10           0x0020      //
01569 
01570 //
01571 // Bits in the G1000CR register
01572 //
01573 #define G1000CR_1000FD      0x0200      // PHY is 1000-T Full-duplex capable
01574 #define G1000CR_1000        0x0100      // PHY is 1000-T Half-duplex capable
01575 
01576 //
01577 // Bits in the G1000SR register
01578 //
01579 #define G1000SR_1000FD      0x0800      // LP PHY is 1000-T Full-duplex capable
01580 #define G1000SR_1000        0x0400      // LP PHY is 1000-T Half-duplex capable
01581 
01582 #define TCSR_ECHODIS        0x2000      //
01583 #define AUXCR_MDPPS         0x0004      //
01584 
01585 // Bits in the PLED register
01586 #define PLED_LALBE                      0x0004  //
01587 
01588 // Marvell 88E1000/88E1000S Bits in the PHY specific control register (10h)
01589 #define PSCR_ACRSTX         0x0800      // Assert CRS on Transmit
01590 
01591 #define PHYID_CICADA_CS8201 0x000FC410UL
01592 #define PHYID_VT3216_32BIT  0x000FC610UL
01593 #define PHYID_VT3216_64BIT  0x000FC600UL
01594 #define PHYID_MARVELL_1000  0x01410C50UL
01595 #define PHYID_MARVELL_1000S 0x01410C40UL
01596 
01597 #define PHYID_REV_ID_MASK   0x0000000FUL
01598 
01599 #define PHYID_GET_PHY_REV_ID(i)     ((i) & PHYID_REV_ID_MASK)
01600 #define PHYID_GET_PHY_ID(i)         ((i) & ~PHYID_REV_ID_MASK)
01601 
01602 #define MII_REG_BITS_ON(x,i,p) do {\
01603     u16 w;\
01604     velocity_mii_read((p),(i),&(w));\
01605     (w)|=(x);\
01606     velocity_mii_write((p),(i),(w));\
01607 } while (0)
01608 
01609 #define MII_REG_BITS_OFF(x,i,p) do {\
01610     u16 w;\
01611     velocity_mii_read((p),(i),&(w));\
01612     (w)&=(~(x));\
01613     velocity_mii_write((p),(i),(w));\
01614 } while (0)
01615 
01616 #define MII_REG_BITS_IS_ON(x,i,p) ({\
01617     u16 w;\
01618     velocity_mii_read((p),(i),&(w));\
01619     ((int) ((w) & (x)));})
01620 
01621 #define MII_GET_PHY_ID(p) ({\
01622     u32 id;  \
01623     u16 id2; \
01624     u16 id1; \
01625     velocity_mii_read((p),MII_REG_PHYID2, &id2);\
01626     velocity_mii_read((p),MII_REG_PHYID1, &id1);\
01627     id = ( ( (u32)id2 ) << 16 ) | id1;          \
01628     (id);})
01629 
01630 #ifdef LINUX
01631 /*
01632  * Inline debug routine
01633  */
01634 
01635 
01636 enum velocity_msg_level {
01637         MSG_LEVEL_ERR = 0,      //Errors that will cause abnormal operation.
01638         MSG_LEVEL_NOTICE = 1,   //Some errors need users to be notified.
01639         MSG_LEVEL_INFO = 2,     //Normal message.
01640         MSG_LEVEL_VERBOSE = 3,  //Will report all trival errors.
01641         MSG_LEVEL_DEBUG = 4     //Only for debug purpose.
01642 };
01643 
01644 #ifdef VELOCITY_DEBUG
01645 #define ASSERT(x) { \
01646         if (!(x)) { \
01647                 printk(KERN_ERR "assertion %s failed: file %s line %d\n", #x,\
01648                         __FUNCTION__, __LINE__);\
01649                 BUG(); \
01650         }\
01651 }
01652 #define VELOCITY_DBG(p,args...) printk(p, ##args)
01653 #else
01654 #define ASSERT(x)
01655 #define VELOCITY_DBG(x)
01656 #endif
01657 
01658 #define VELOCITY_PRT(l, p, args...) do {if (l<=msglevel) printf( p ,##args);} while (0)
01659 
01660 #define VELOCITY_PRT_CAMMASK(p,t) {\
01661         int i;\
01662         if ((t)==VELOCITY_MULTICAST_CAM) {\
01663                 for (i=0;i<(MCAM_SIZE/8);i++)\
01664                         printk("%02X",(p)->mCAMmask[i]);\
01665         }\
01666         else {\
01667                 for (i=0;i<(VCAM_SIZE/8);i++)\
01668                         printk("%02X",(p)->vCAMmask[i]);\
01669         }\
01670         printk("\n");\
01671 }
01672 
01673 #endif
01674 
01675 #define     VELOCITY_WOL_MAGIC             0x00000000UL
01676 #define     VELOCITY_WOL_PHY               0x00000001UL
01677 #define     VELOCITY_WOL_ARP               0x00000002UL
01678 #define     VELOCITY_WOL_UCAST             0x00000004UL
01679 #define     VELOCITY_WOL_BCAST             0x00000010UL
01680 #define     VELOCITY_WOL_MCAST             0x00000020UL
01681 #define     VELOCITY_WOL_MAGIC_SEC         0x00000040UL
01682 
01683 /*
01684  *      Flags for options
01685  */
01686 
01687 #define     VELOCITY_FLAGS_TAGGING         0x00000001UL
01688 #define     VELOCITY_FLAGS_TX_CSUM         0x00000002UL
01689 #define     VELOCITY_FLAGS_RX_CSUM         0x00000004UL
01690 #define     VELOCITY_FLAGS_IP_ALIGN        0x00000008UL
01691 #define     VELOCITY_FLAGS_VAL_PKT_LEN     0x00000010UL
01692 
01693 #define     VELOCITY_FLAGS_FLOW_CTRL       0x01000000UL
01694 
01695 /*
01696  *      Flags for driver status
01697  */
01698 
01699 #define     VELOCITY_FLAGS_OPENED          0x00010000UL
01700 #define     VELOCITY_FLAGS_VMNS_CONNECTED  0x00020000UL
01701 #define     VELOCITY_FLAGS_VMNS_COMMITTED  0x00040000UL
01702 #define     VELOCITY_FLAGS_WOL_ENABLED     0x00080000UL
01703 
01704 /*
01705  *      Flags for MII status
01706  */
01707 
01708 #define     VELOCITY_LINK_FAIL             0x00000001UL
01709 #define     VELOCITY_SPEED_10              0x00000002UL
01710 #define     VELOCITY_SPEED_100             0x00000004UL
01711 #define     VELOCITY_SPEED_1000            0x00000008UL
01712 #define     VELOCITY_DUPLEX_FULL           0x00000010UL
01713 #define     VELOCITY_AUTONEG_ENABLE        0x00000020UL
01714 #define     VELOCITY_FORCED_BY_EEPROM      0x00000040UL
01715 
01716 /*
01717  *      For velocity_set_media_duplex
01718  */
01719 
01720 #define     VELOCITY_LINK_CHANGE           0x00000001UL
01721 
01722 enum speed_opt {
01723         SPD_DPX_AUTO = 0,
01724         SPD_DPX_100_HALF = 1,
01725         SPD_DPX_100_FULL = 2,
01726         SPD_DPX_10_HALF = 3,
01727         SPD_DPX_10_FULL = 4
01728 };
01729 
01730 enum velocity_init_type {
01731         VELOCITY_INIT_COLD = 0,
01732         VELOCITY_INIT_RESET,
01733         VELOCITY_INIT_WOL
01734 };
01735 
01736 enum velocity_flow_cntl_type {
01737         FLOW_CNTL_DEFAULT = 1,
01738         FLOW_CNTL_TX,
01739         FLOW_CNTL_RX,
01740         FLOW_CNTL_TX_RX,
01741         FLOW_CNTL_DISABLE,
01742 };
01743 
01744 struct velocity_opt {
01745         int numrx;              /* Number of RX descriptors */
01746         int numtx;              /* Number of TX descriptors */
01747         enum speed_opt spd_dpx; /* Media link mode */
01748         int vid;                /* vlan id */
01749         int DMA_length;         /* DMA length */
01750         int rx_thresh;          /* RX_THRESH */
01751         int flow_cntl;
01752         int wol_opts;           /* Wake on lan options */
01753         int td_int_count;
01754         int int_works;
01755         int rx_bandwidth_hi;
01756         int rx_bandwidth_lo;
01757         int rx_bandwidth_en;
01758         u32 flags;
01759 };
01760 
01761 #define RX_DESC_MIN     4
01762 #define RX_DESC_MAX     255
01763 #define RX_DESC_DEF     RX_DESC_MIN
01764 
01765 #define TX_DESC_MIN     1
01766 #define TX_DESC_MAX     256
01767 #define TX_DESC_DEF     TX_DESC_MIN
01768 
01769 static struct velocity_info {
01770 //      struct list_head list;
01771 
01772         struct pci_device *pdev;
01773 //      struct net_device *dev;
01774 //      struct net_device_stats stats;
01775 
01776 #ifdef CONFIG_PM
01777         u32 pci_state[16];
01778 #endif
01779 
01780 //      dma_addr_t rd_pool_dma;
01781 //      dma_addr_t td_pool_dma[TX_QUEUE_NO];
01782 
01783 //      dma_addr_t tx_bufs_dma;
01784         u8 *tx_bufs;
01785 
01786         u8 ip_addr[4];
01787         enum chip_type chip_id;
01788 
01789         struct mac_regs *mac_regs;
01790         unsigned long memaddr;
01791         unsigned long ioaddr;
01792         u32 io_size;
01793 
01794         u8 rev_id;
01795 
01796 #define AVAIL_TD(p,q)   ((p)->options.numtx-((p)->td_used[(q)]))
01797 
01798         int num_txq;
01799 
01800         volatile int td_used[TX_QUEUE_NO];
01801         int td_curr;
01802         int td_tail[TX_QUEUE_NO];
01803         unsigned char *TxDescArrays;    /* Index of Tx Descriptor buffer */
01804         unsigned char *RxDescArrays;    /* Index of Rx Descriptor buffer */
01805         unsigned char *tx_buffs;
01806         unsigned char *rx_buffs;
01807 
01808         unsigned char *txb;
01809         unsigned char *rxb;
01810         struct tx_desc *td_rings;
01811         struct velocity_td_info *td_infos[TX_QUEUE_NO];
01812 
01813         int rd_curr;
01814         int rd_dirty;
01815         u32 rd_filled;
01816         struct rx_desc *rd_ring;
01817         struct velocity_rd_info *rd_info;       /* It's an array */
01818 
01819 #define GET_RD_BY_IDX(vptr, idx)   (vptr->rd_ring[idx])
01820         u32 mib_counter[MAX_HW_MIB_COUNTER];
01821         struct velocity_opt options;
01822 
01823         u32 int_mask;
01824 
01825         u32 flags;
01826 
01827         int rx_buf_sz;
01828         u32 mii_status;
01829         u32 phy_id;
01830         int multicast_limit;
01831 
01832         u8 vCAMmask[(VCAM_SIZE / 8)];
01833         u8 mCAMmask[(MCAM_SIZE / 8)];
01834 
01835 //      spinlock_t lock;
01836 
01837         int wol_opts;
01838         u8 wol_passwd[6];
01839 
01840         struct velocity_context context;
01841 
01842         u32 ticks;
01843         u32 rx_bytes;
01844 
01845 } vptx;
01846 
01847 static struct velocity_info *vptr;
01848 
01849 #ifdef LINUX
01850 /**
01851  *      velocity_get_ip         -       find an IP address for the device
01852  *      @vptr: Velocity to query
01853  *
01854  *      Dig out an IP address for this interface so that we can
01855  *      configure wakeup with WOL for ARP. If there are multiple IP
01856  *      addresses on this chain then we use the first - multi-IP WOL is not
01857  *      supported.
01858  *
01859  *      CHECK ME: locking
01860  */
01861 
01862 inline static int velocity_get_ip(struct velocity_info *vptr)
01863 {
01864         struct in_device *in_dev = (struct in_device *) vptr->dev->ip_ptr;
01865         struct in_ifaddr *ifa;
01866 
01867         if (in_dev != NULL) {
01868                 ifa = (struct in_ifaddr *) in_dev->ifa_list;
01869                 if (ifa != NULL) {
01870                         memcpy(vptr->ip_addr, &ifa->ifa_address, 4);
01871                         return 0;
01872                 }
01873         }
01874         return -ENOENT;
01875 }
01876 
01877 /**
01878  *      velocity_update_hw_mibs -       fetch MIB counters from chip
01879  *      @vptr: velocity to update
01880  *
01881  *      The velocity hardware keeps certain counters in the hardware
01882  *      side. We need to read these when the user asks for statistics
01883  *      or when they overflow (causing an interrupt). The read of the
01884  *      statistic clears it, so we keep running master counters in user
01885  *      space.
01886  */
01887 
01888 static inline void velocity_update_hw_mibs(struct velocity_info *vptr)
01889 {
01890         u32 tmp;
01891         int i;
01892         BYTE_REG_BITS_ON(MIBCR_MIBFLSH, &(vptr->mac_regs->MIBCR));
01893 
01894         while (BYTE_REG_BITS_IS_ON
01895                (MIBCR_MIBFLSH, &(vptr->mac_regs->MIBCR)));
01896 
01897         BYTE_REG_BITS_ON(MIBCR_MPTRINI, &(vptr->mac_regs->MIBCR));
01898         for (i = 0; i < HW_MIB_SIZE; i++) {
01899                 tmp = readl(&(vptr->mac_regs->MIBData)) & 0x00FFFFFFUL;
01900                 vptr->mib_counter[i] += tmp;
01901         }
01902 }
01903 #endif
01904 /**
01905  *      init_flow_control_register      -       set up flow control
01906  *      @vptr: velocity to configure
01907  *
01908  *      Configure the flow control registers for this velocity device.
01909  */
01910 
01911 static inline void init_flow_control_register(struct velocity_info *vptr)
01912 {
01913         struct mac_regs *regs = vptr->mac_regs;
01914 
01915         /* Set {XHITH1, XHITH0, XLTH1, XLTH0} in FlowCR1 to {1, 0, 1, 1}
01916            depend on RD=64, and Turn on XNOEN in FlowCR1 */
01917         writel((CR0_XONEN | CR0_XHITH1 | CR0_XLTH1 | CR0_XLTH0),
01918                &regs->CR0Set);
01919         writel((CR0_FDXTFCEN | CR0_FDXRFCEN | CR0_HDXFCEN | CR0_XHITH0),
01920                &regs->CR0Clr);
01921 
01922         /* Set TxPauseTimer to 0xFFFF */
01923         writew(0xFFFF, &regs->tx_pause_timer);
01924 
01925         /* Initialize RBRDU to Rx buffer count. */
01926         writew(vptr->options.numrx, &regs->RBRDU);
01927 }
01928 
01929 
01930 #endif

Generated on Tue Apr 6 20:01:05 2010 for gPXE by  doxygen 1.5.7.1