00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
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
00063
00064
00065
00066 #define B_OWNED_BY_CHIP 1
00067 #define B_OWNED_BY_HOST 0
00068
00069
00070
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
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
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
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
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
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
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
00170 #define CB_RX_BUF_SIZE 2048UL // max buffer size
00171
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
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
00189
00190
00191
00192
00193 #define CB_MAX_TX_ABORT_RETRY 3
00194
00195
00196
00197
00198
00199 struct rdesc0 {
00200 u16 RSR;
00201 u16 len:14;
00202 u16 reserved:1;
00203 u16 owner:1;
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;
00216 u16 pa_high;
00217 u16 len:15;
00218 u16 inten:1;
00219 } __attribute__ ((__packed__));
00220
00221
00222
00223
00224
00225 struct tdesc0 {
00226 u16 TSR;
00227 u16 pktsize:14;
00228 u16 reserved:1;
00229 u16 owner:1;
00230 };
00231
00232 struct pqinf {
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
00269
00270
00271
00272
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
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
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
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
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
00473
00474
00475 #define TCR_TB2BDIS 0x80
00476 #define TCR_COLTMC1 0x08
00477 #define TCR_COLTMC0 0x04
00478 #define TCR_LB1 0x02
00479 #define TCR_LB0 0x01
00480
00481
00482
00483
00484
00485 #define CR0_TXON 0x00000008UL
00486 #define CR0_RXON 0x00000004UL
00487 #define CR0_STOP 0x00000002UL
00488 #define CR0_STRT 0x00000001UL
00489 #define CR0_SFRST 0x00008000UL
00490 #define CR0_TM1EN 0x00004000UL
00491 #define CR0_TM0EN 0x00002000UL
00492 #define CR0_DPOLL 0x00000800UL
00493 #define CR0_DISAU 0x00000100UL
00494 #define CR0_XONEN 0x00800000UL
00495 #define CR0_FDXTFCEN 0x00400000UL
00496 #define CR0_FDXRFCEN 0x00200000UL
00497 #define CR0_HDXFCEN 0x00100000UL
00498 #define CR0_XHITH1 0x00080000UL
00499 #define CR0_XHITH0 0x00040000UL
00500 #define CR0_XLTH1 0x00020000UL
00501 #define CR0_XLTH0 0x00010000UL
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
00512
00513
00514 #define CR1_SFRST 0x80
00515 #define CR1_TM1EN 0x40
00516 #define CR1_TM0EN 0x20
00517 #define CR1_DPOLL 0x08
00518 #define CR1_DISAU 0x01
00519
00520
00521
00522
00523
00524 #define CR2_XONEN 0x80
00525 #define CR2_FDXTFCEN 0x40
00526 #define CR2_FDXRFCEN 0x20
00527 #define CR2_HDXFCEN 0x10
00528 #define CR2_XHITH1 0x08
00529 #define CR2_XHITH0 0x04
00530 #define CR2_XLTH1 0x02
00531 #define CR2_XLTH0 0x01
00532
00533
00534
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
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
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
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
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
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
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
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
00669
00670
00671 #define CAMADDR_CAMEN 0x80
00672 #define CAMADDR_VCAMSL 0x40
00673
00674
00675
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
00690
00691
00692 #define MIICFG_MPO1 0x80
00693 #define MIICFG_MPO0 0x40
00694 #define MIICFG_MFDC 0x20
00695
00696
00697
00698
00699
00700 #define MIISR_MIDLE 0x80
00701
00702
00703
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
00716
00717
00718 #define PHYSR1_PHYTBI 0x01
00719
00720
00721
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
00735
00736
00737 #define MIIADR_SWMPL 0x80
00738
00739
00740
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
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
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
00771 #define CFGC_BPS1 0x02
00772 #define CFGC_BPS0 0x01
00773
00774
00775
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
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
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
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
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
00833
00834
00835 #define STICKHW_SWPTAG 0x10
00836 #define STICKHW_WOLSR 0x08
00837 #define STICKHW_WOLEN 0x04
00838 #define STICKHW_DS1 0x02
00839 #define STICKHW_DS0 0x01
00840
00841
00842
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
00856
00857
00858 #define EERSV_BOOT_RPL ((u8) 0x01)
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
00869
00870
00871 #define BPCMD_BPDNE 0x80
00872 #define BPCMD_EBPWR 0x02
00873 #define BPCMD_EBPRD 0x01
00874
00875
00876
00877
00878
00879 #define EECSR_EMBP 0x40
00880 #define EECSR_RELOAD 0x20
00881 #define EECSR_DPM 0x10
00882 #define EECSR_ECS 0x08
00883 #define EECSR_ECK 0x04
00884 #define EECSR_EDI 0x02
00885 #define EECSR_EDO 0x01
00886
00887
00888
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
00899
00900
00901 #define TESTCFG_HBDIS 0x80
00902
00903
00904
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
00918
00919
00920 #define WOLCR_MSWOLEN7 0x0080
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
00932
00933
00934 #define WOLCR_LINKOFF_EN 0x0800
00935 #define WOLCR_LINKON_EN 0x0400
00936 #define WOLCR_MAGIC_EN 0x0200
00937 #define WOLCR_UNICAST_EN 0x0100
00938
00939
00940
00941
00942
00943
00944 #define PWCFG_PHYPWOPT 0x80
00945 #define PWCFG_PCISTICK 0x40
00946 #define PWCFG_WOLTYPE 0x20
00947 #define PWCFG_LEGCY_WOL 0x10
00948 #define PWCFG_PMCSR_PME_SR 0x08
00949 #define PWCFG_PMCSR_PME_EN 0x04
00950 #define PWCFG_LEGACY_WOLSR 0x02
00951 #define PWCFG_LEGACY_WOLEN 0x01
00952
00953
00954
00955
00956
00957 #define WOLCFG_PMEOVR 0x80
00958 #define WOLCFG_SAM 0x20
00959 #define WOLCFG_SAB 0x10
00960 #define WOLCFG_SMIIACC 0x08
00961 #define WOLCFG_SGENWH 0x02
00962 #define WOLCFG_PHYINTEN 0x01
00963
00964
00965
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
00975
00976
00977 #define PKT_TYPE_NONE 0x0000
00978 #define PKT_TYPE_DIRECTED 0x0001
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
00984 #define PKT_TYPE_RUNT 0x4000
00985 #define PKT_TYPE_ERROR 0x8000
00986
00987
00988
00989
00990
00991 #define MAC_LB_NONE 0x00
00992 #define MAC_LB_INTERNAL 0x01
00993 #define MAC_LB_EXTERNAL 0x02
00994
00995
00996
00997
00998
00999 #if defined(_SIM)
01000 #define IMR_MASK_VALUE 0x0033FF0FUL
01001
01002
01003 #else
01004 #define IMR_MASK_VALUE 0x0013FB0FUL
01005
01006
01007
01008
01009
01010
01011 #endif
01012
01013
01014
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
01023
01024
01025 #define W_MAX_TIMEOUT 0x0FFFU
01026
01027
01028
01029
01030
01031
01032
01033 struct mac_regs {
01034 volatile u8 PAR[6];
01035 volatile u8 RCR;
01036 volatile u8 TCR;
01037
01038 volatile u32 CR0Set;
01039 volatile u32 CR0Clr;
01040
01041 volatile u8 MARCAM[8];
01042
01043 volatile u32 DecBaseHi;
01044 volatile u16 DbfBaseHi;
01045 volatile u16 reserved_1E;
01046
01047 volatile u16 ISRCTL;
01048 volatile u8 TXESR;
01049 volatile u8 RXESR;
01050
01051 volatile u32 ISR;
01052 volatile u32 IMR;
01053
01054 volatile u32 TDStatusPort;
01055
01056 volatile u16 TDCSRSet;
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;
01064 volatile u16 RDIdx;
01065 volatile u16 reserved_3E;
01066
01067 volatile u32 TDBaseLo[4];
01068
01069 volatile u16 RDCSize;
01070 volatile u16 TDCSize;
01071 volatile u16 TDIdx[4];
01072 volatile u16 tx_pause_timer;
01073 volatile u16 RBRDU;
01074
01075 volatile u32 FIFOTest0;
01076 volatile u32 FIFOTest1;
01077
01078 volatile u8 CAMADDR;
01079 volatile u8 CAMCR;
01080 volatile u8 GFTEST;
01081 volatile u8 FTSTCMD;
01082
01083 volatile u8 MIICFG;
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;
01092 volatile u16 SoftTimer1;
01093
01094 volatile u8 CFGA;
01095 volatile u8 CFGB;
01096 volatile u8 CFGC;
01097 volatile u8 CFGD;
01098
01099 volatile u16 DCFG;
01100 volatile u16 MCFG;
01101
01102 volatile u8 TBIST;
01103 volatile u8 RBIST;
01104 volatile u8 PMCPORT;
01105 volatile u8 STICKHW;
01106
01107 volatile u8 MIBCR;
01108 volatile u8 reserved_85;
01109 volatile u8 rev_id;
01110 volatile u8 PORSTS;
01111
01112 volatile u32 MIBData;
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;
01122 volatile u8 EECSR;
01123
01124 volatile u16 EERdData;
01125 volatile u8 EADDR;
01126 volatile u8 EMBCMD;
01127
01128
01129 volatile u8 JMPSR0;
01130 volatile u8 JMPSR1;
01131 volatile u8 JMPSR2;
01132 volatile u8 JMPSR3;
01133 volatile u8 CHIPGSR;
01134 volatile u8 TESTCFG;
01135 volatile u8 DEBUG;
01136 volatile u8 CHIPGCR;
01137
01138 volatile u16 WOLCRSet;
01139 volatile u8 PWCFGSet;
01140 volatile u8 WOLCFGSet;
01141
01142 volatile u16 WOLCRClr;
01143 volatile u8 PWCFGCLR;
01144 volatile u8 WOLCFGClr;
01145
01146 volatile u16 WOLSRSet;
01147 volatile u16 reserved_AA;
01148
01149 volatile u16 WOLSRClr;
01150 volatile u16 reserved_AE;
01151
01152 volatile u16 PatternCRC[8];
01153 volatile u32 ByteMask[4][4];
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
01273
01274
01275
01276
01277
01278
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
01286 BYTE_REG_BITS_SET(CAMCR_PS_CAM_MASK, CAMCR_PS1 | CAMCR_PS0,
01287 ®s->CAMCR);
01288
01289 if (cam_type == VELOCITY_VLAN_ID_CAM)
01290 writeb(CAMADDR_VCAMSL, ®s->CAMADDR);
01291 else
01292 writeb(0, ®s->CAMADDR);
01293
01294
01295 for (i = 0; i < 8; i++)
01296 *mask++ = readb(&(regs->MARCAM[i]));
01297
01298
01299 writeb(0, ®s->CAMADDR);
01300
01301
01302 BYTE_REG_BITS_SET(CAMCR_PS_MAR, CAMCR_PS1 | CAMCR_PS0,
01303 ®s->CAMCR);
01304
01305 }
01306
01307
01308
01309
01310
01311
01312
01313
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
01321 BYTE_REG_BITS_SET(CAMCR_PS_CAM_MASK, CAMCR_PS1 | CAMCR_PS0,
01322 ®s->CAMCR);
01323
01324 if (cam_type == VELOCITY_VLAN_ID_CAM)
01325 writeb(CAMADDR_CAMEN | CAMADDR_VCAMSL, ®s->CAMADDR);
01326 else
01327 writeb(CAMADDR_CAMEN, ®s->CAMADDR);
01328
01329 for (i = 0; i < 8; i++) {
01330 writeb(*mask++, &(regs->MARCAM[i]));
01331 }
01332
01333 writeb(0, ®s->CAMADDR);
01334
01335
01336 BYTE_REG_BITS_SET(CAMCR_PS_MAR, CAMCR_PS1 | CAMCR_PS0,
01337 ®s->CAMCR);
01338 }
01339
01340
01341
01342
01343
01344
01345
01346
01347
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
01356 BYTE_REG_BITS_SET(CAMCR_PS_CAM_DATA, CAMCR_PS1 | CAMCR_PS0,
01357 ®s->CAMCR);
01358
01359 idx &= (64 - 1);
01360
01361 if (cam_type == VELOCITY_VLAN_ID_CAM)
01362 writeb(CAMADDR_CAMEN | CAMADDR_VCAMSL | idx,
01363 ®s->CAMADDR);
01364 else
01365 writeb(CAMADDR_CAMEN | idx, ®s->CAMADDR);
01366
01367 if (cam_type == VELOCITY_VLAN_ID_CAM)
01368 writew(*((u16 *) addr), ®s->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, ®s->CAMCR);
01375
01376 udelay(10);
01377
01378 writeb(0, ®s->CAMADDR);
01379
01380
01381 BYTE_REG_BITS_SET(CAMCR_PS_MAR, CAMCR_PS1 | CAMCR_PS0,
01382 ®s->CAMCR);
01383 }
01384
01385
01386
01387
01388
01389
01390
01391
01392
01393
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
01402 BYTE_REG_BITS_SET(CAMCR_PS_CAM_DATA, CAMCR_PS1 | CAMCR_PS0,
01403 ®s->CAMCR);
01404
01405 idx &= (64 - 1);
01406
01407 if (cam_type == VELOCITY_VLAN_ID_CAM)
01408 writeb(CAMADDR_CAMEN | CAMADDR_VCAMSL | idx,
01409 ®s->CAMADDR);
01410 else
01411 writeb(CAMADDR_CAMEN | idx, ®s->CAMADDR);
01412
01413 BYTE_REG_BITS_ON(CAMCR_CAMRD, ®s->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, ®s->CAMADDR);
01424
01425
01426 BYTE_REG_BITS_SET(CAMCR_PS_MAR, CAMCR_PS1 | CAMCR_PS0,
01427 ®s->CAMCR);
01428 }
01429
01430
01431
01432
01433
01434
01435
01436
01437
01438
01439 inline static void mac_wol_reset(struct mac_regs *regs)
01440 {
01441
01442
01443 BYTE_REG_BITS_OFF(STICKHW_SWPTAG, ®s->STICKHW);
01444
01445 BYTE_REG_BITS_OFF((STICKHW_DS1 | STICKHW_DS0), ®s->STICKHW);
01446
01447 BYTE_REG_BITS_OFF(CHIPGCR_FCGMII, ®s->CHIPGCR);
01448 BYTE_REG_BITS_OFF(CHIPGCR_FCMODE, ®s->CHIPGCR);
01449
01450 writeb(WOLCFG_PMEOVR, ®s->WOLCFGClr);
01451
01452 writew(0xFFFF, ®s->WOLCRClr);
01453
01454 writew(0xFFFF, ®s->WOLSRClr);
01455 }
01456
01457
01458
01459
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
01489
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
01504
01505
01506
01507
01508
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
01523 #define MII_REG_PCR 0x17 //
01524
01525 #define MII_REG_PCSR 0x17 //
01526 #define MII_REG_AUXCR 0x1C //
01527
01528
01529 #define MII_REG_PSCR 0x10 // PHY specific control register
01530
01531
01532
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
01545
01546 #define BMSR_AUTOCM 0x0020 //
01547 #define BMSR_LNK 0x0004 //
01548
01549
01550
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
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
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
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
01586 #define PLED_LALBE 0x0004 //
01587
01588
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
01633
01634
01635
01636 enum velocity_msg_level {
01637 MSG_LEVEL_ERR = 0,
01638 MSG_LEVEL_NOTICE = 1,
01639 MSG_LEVEL_INFO = 2,
01640 MSG_LEVEL_VERBOSE = 3,
01641 MSG_LEVEL_DEBUG = 4
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
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
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
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
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;
01746 int numtx;
01747 enum speed_opt spd_dpx;
01748 int vid;
01749 int DMA_length;
01750 int rx_thresh;
01751 int flow_cntl;
01752 int wol_opts;
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
01771
01772 struct pci_device *pdev;
01773
01774
01775
01776 #ifdef CONFIG_PM
01777 u32 pci_state[16];
01778 #endif
01779
01780
01781
01782
01783
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;
01804 unsigned char *RxDescArrays;
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;
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
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
01852
01853
01854
01855
01856
01857
01858
01859
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
01879
01880
01881
01882
01883
01884
01885
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
01906
01907
01908
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
01916
01917 writel((CR0_XONEN | CR0_XHITH1 | CR0_XLTH1 | CR0_XLTH0),
01918 ®s->CR0Set);
01919 writel((CR0_FDXTFCEN | CR0_FDXRFCEN | CR0_HDXFCEN | CR0_XHITH0),
01920 ®s->CR0Clr);
01921
01922
01923 writew(0xFFFF, ®s->tx_pause_timer);
01924
01925
01926 writew(vptr->options.numrx, ®s->RBRDU);
01927 }
01928
01929
01930 #endif