0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef VELOCITY_H
0017 #define VELOCITY_H
0018
0019 #define VELOCITY_TX_CSUM_SUPPORT
0020
0021 #define VELOCITY_NAME "via-velocity"
0022 #define VELOCITY_FULL_DRV_NAM "VIA Networking Velocity Family Gigabit Ethernet Adapter Driver"
0023 #define VELOCITY_VERSION "1.15"
0024
0025 #define VELOCITY_IO_SIZE 256
0026
0027 #define PKT_BUF_SZ 1540
0028
0029 #define MAX_UNITS 8
0030 #define OPTION_DEFAULT { [0 ... MAX_UNITS-1] = -1}
0031
0032 #define REV_ID_VT6110 (0)
0033
0034 #define BYTE_REG_BITS_ON(x,p) do { writeb(readb((p))|(x),(p));} while (0)
0035 #define WORD_REG_BITS_ON(x,p) do { writew(readw((p))|(x),(p));} while (0)
0036 #define DWORD_REG_BITS_ON(x,p) do { writel(readl((p))|(x),(p));} while (0)
0037
0038 #define BYTE_REG_BITS_IS_ON(x,p) (readb((p)) & (x))
0039 #define WORD_REG_BITS_IS_ON(x,p) (readw((p)) & (x))
0040 #define DWORD_REG_BITS_IS_ON(x,p) (readl((p)) & (x))
0041
0042 #define BYTE_REG_BITS_OFF(x,p) do { writeb(readb((p)) & (~(x)),(p));} while (0)
0043 #define WORD_REG_BITS_OFF(x,p) do { writew(readw((p)) & (~(x)),(p));} while (0)
0044 #define DWORD_REG_BITS_OFF(x,p) do { writel(readl((p)) & (~(x)),(p));} while (0)
0045
0046 #define BYTE_REG_BITS_SET(x,m,p) do { writeb( (readb((p)) & (~(m))) |(x),(p));} while (0)
0047 #define WORD_REG_BITS_SET(x,m,p) do { writew( (readw((p)) & (~(m))) |(x),(p));} while (0)
0048 #define DWORD_REG_BITS_SET(x,m,p) do { writel( (readl((p)) & (~(m)))|(x),(p));} while (0)
0049
0050 #define VAR_USED(p) do {(p)=(p);} while (0)
0051
0052
0053
0054
0055
0056
0057 #define B_OWNED_BY_CHIP 1
0058 #define B_OWNED_BY_HOST 0
0059
0060
0061
0062
0063
0064 #define RSR_DETAG cpu_to_le16(0x0080)
0065 #define RSR_SNTAG cpu_to_le16(0x0040)
0066 #define RSR_RXER cpu_to_le16(0x0020)
0067 #define RSR_RL cpu_to_le16(0x0010)
0068 #define RSR_CE cpu_to_le16(0x0008)
0069 #define RSR_FAE cpu_to_le16(0x0004)
0070 #define RSR_CRC cpu_to_le16(0x0002)
0071 #define RSR_VIDM cpu_to_le16(0x0001)
0072
0073
0074
0075
0076
0077 #define RSR_RXOK cpu_to_le16(0x8000)
0078 #define RSR_PFT cpu_to_le16(0x4000)
0079 #define RSR_MAR cpu_to_le16(0x2000)
0080 #define RSR_BAR cpu_to_le16(0x1000)
0081 #define RSR_PHY cpu_to_le16(0x0800)
0082 #define RSR_VTAG cpu_to_le16(0x0400)
0083 #define RSR_STP cpu_to_le16(0x0200)
0084 #define RSR_EDP cpu_to_le16(0x0100)
0085
0086
0087
0088
0089
0090 #define CSM_IPOK 0x40
0091 #define CSM_TUPOK 0x20
0092 #define CSM_FRAG 0x10
0093 #define CSM_IPKT 0x04
0094 #define CSM_TCPKT 0x02
0095 #define CSM_UDPKT 0x01
0096
0097
0098
0099
0100
0101 #define TSR0_ABT cpu_to_le16(0x0080)
0102 #define TSR0_OWT cpu_to_le16(0x0040)
0103 #define TSR0_OWC cpu_to_le16(0x0020)
0104 #define TSR0_COLS cpu_to_le16(0x0010)
0105 #define TSR0_NCR3 cpu_to_le16(0x0008)
0106 #define TSR0_NCR2 cpu_to_le16(0x0004)
0107 #define TSR0_NCR1 cpu_to_le16(0x0002)
0108 #define TSR0_NCR0 cpu_to_le16(0x0001)
0109 #define TSR0_TERR cpu_to_le16(0x8000)
0110 #define TSR0_FDX cpu_to_le16(0x4000)
0111 #define TSR0_GMII cpu_to_le16(0x2000)
0112 #define TSR0_LNKFL cpu_to_le16(0x1000)
0113 #define TSR0_SHDN cpu_to_le16(0x0400)
0114 #define TSR0_CRS cpu_to_le16(0x0200)
0115 #define TSR0_CDH cpu_to_le16(0x0100)
0116
0117
0118
0119
0120 #define TCR0_TIC 0x80
0121 #define TCR0_PIC 0x40
0122 #define TCR0_VETAG 0x20
0123 #define TCR0_IPCK 0x10
0124 #define TCR0_UDPCK 0x08
0125 #define TCR0_TCPCK 0x04
0126 #define TCR0_JMBO 0x02
0127 #define TCR0_CRC 0x01
0128
0129 #define TCPLS_NORMAL 3
0130 #define TCPLS_START 2
0131 #define TCPLS_END 1
0132 #define TCPLS_MED 0
0133
0134
0135
0136 #define CB_RX_BUF_SIZE 2048UL
0137
0138
0139 #define CB_MAX_RD_NUM 512
0140 #define CB_MAX_TD_NUM 256
0141
0142 #define CB_INIT_RD_NUM_3119 128
0143 #define CB_INIT_TD_NUM_3119 64
0144
0145 #define CB_INIT_RD_NUM 128
0146 #define CB_INIT_TD_NUM 64
0147
0148
0149 #define CB_TD_RING_NUM 4
0150 #define CB_MAX_SEG_PER_PKT 7
0151
0152
0153
0154
0155
0156
0157
0158
0159 #define CB_MAX_TX_ABORT_RETRY 3
0160
0161
0162
0163
0164
0165 struct rdesc0 {
0166 __le16 RSR;
0167 __le16 len;
0168 };
0169
0170 struct rdesc1 {
0171 __le16 PQTAG;
0172 u8 CSM;
0173 u8 IPKT;
0174 };
0175
0176 enum {
0177 RX_INTEN = cpu_to_le16(0x8000)
0178 };
0179
0180 struct rx_desc {
0181 struct rdesc0 rdesc0;
0182 struct rdesc1 rdesc1;
0183 __le32 pa_low;
0184 __le16 pa_high;
0185 __le16 size;
0186 } __packed;
0187
0188
0189
0190
0191
0192 struct tdesc0 {
0193 __le16 TSR;
0194 __le16 len;
0195 };
0196
0197 struct tdesc1 {
0198 __le16 vlan;
0199 u8 TCR;
0200 u8 cmd;
0201 } __packed;
0202
0203 enum {
0204 TD_QUEUE = cpu_to_le16(0x8000)
0205 };
0206
0207 struct td_buf {
0208 __le32 pa_low;
0209 __le16 pa_high;
0210 __le16 size;
0211 } __packed;
0212
0213 struct tx_desc {
0214 struct tdesc0 tdesc0;
0215 struct tdesc1 tdesc1;
0216 struct td_buf td_buf[7];
0217 };
0218
0219 struct velocity_rd_info {
0220 struct sk_buff *skb;
0221 dma_addr_t skb_dma;
0222 };
0223
0224
0225
0226
0227
0228 struct velocity_td_info {
0229 struct sk_buff *skb;
0230 int nskb_dma;
0231 dma_addr_t skb_dma[7];
0232 };
0233
0234 enum velocity_owner {
0235 OWNED_BY_HOST = 0,
0236 OWNED_BY_NIC = cpu_to_le16(0x8000)
0237 };
0238
0239
0240
0241
0242
0243
0244
0245 #define MCAM_SIZE 64
0246 #define VCAM_SIZE 64
0247 #define TX_QUEUE_NO 4
0248
0249 #define MAX_HW_MIB_COUNTER 32
0250 #define VELOCITY_MIN_MTU (64)
0251 #define VELOCITY_MAX_MTU (9000)
0252
0253
0254
0255
0256
0257 #define MAC_REG_PAR 0x00
0258 #define MAC_REG_RCR 0x06
0259 #define MAC_REG_TCR 0x07
0260 #define MAC_REG_CR0_SET 0x08
0261 #define MAC_REG_CR1_SET 0x09
0262 #define MAC_REG_CR2_SET 0x0A
0263 #define MAC_REG_CR3_SET 0x0B
0264 #define MAC_REG_CR0_CLR 0x0C
0265 #define MAC_REG_CR1_CLR 0x0D
0266 #define MAC_REG_CR2_CLR 0x0E
0267 #define MAC_REG_CR3_CLR 0x0F
0268 #define MAC_REG_MAR 0x10
0269 #define MAC_REG_CAM 0x10
0270 #define MAC_REG_DEC_BASE_HI 0x18
0271 #define MAC_REG_DBF_BASE_HI 0x1C
0272 #define MAC_REG_ISR_CTL 0x20
0273 #define MAC_REG_ISR_HOTMR 0x20
0274 #define MAC_REG_ISR_TSUPTHR 0x20
0275 #define MAC_REG_ISR_RSUPTHR 0x20
0276 #define MAC_REG_ISR_CTL1 0x21
0277 #define MAC_REG_TXE_SR 0x22
0278 #define MAC_REG_RXE_SR 0x23
0279 #define MAC_REG_ISR 0x24
0280 #define MAC_REG_ISR0 0x24
0281 #define MAC_REG_ISR1 0x25
0282 #define MAC_REG_ISR2 0x26
0283 #define MAC_REG_ISR3 0x27
0284 #define MAC_REG_IMR 0x28
0285 #define MAC_REG_IMR0 0x28
0286 #define MAC_REG_IMR1 0x29
0287 #define MAC_REG_IMR2 0x2A
0288 #define MAC_REG_IMR3 0x2B
0289 #define MAC_REG_TDCSR_SET 0x30
0290 #define MAC_REG_RDCSR_SET 0x32
0291 #define MAC_REG_TDCSR_CLR 0x34
0292 #define MAC_REG_RDCSR_CLR 0x36
0293 #define MAC_REG_RDBASE_LO 0x38
0294 #define MAC_REG_RDINDX 0x3C
0295 #define MAC_REG_TDBASE_LO 0x40
0296 #define MAC_REG_RDCSIZE 0x50
0297 #define MAC_REG_TDCSIZE 0x52
0298 #define MAC_REG_TDINDX 0x54
0299 #define MAC_REG_TDIDX0 0x54
0300 #define MAC_REG_TDIDX1 0x56
0301 #define MAC_REG_TDIDX2 0x58
0302 #define MAC_REG_TDIDX3 0x5A
0303 #define MAC_REG_PAUSE_TIMER 0x5C
0304 #define MAC_REG_RBRDU 0x5E
0305 #define MAC_REG_FIFO_TEST0 0x60
0306 #define MAC_REG_FIFO_TEST1 0x64
0307 #define MAC_REG_CAMADDR 0x68
0308 #define MAC_REG_CAMCR 0x69
0309 #define MAC_REG_GFTEST 0x6A
0310 #define MAC_REG_FTSTCMD 0x6B
0311 #define MAC_REG_MIICFG 0x6C
0312 #define MAC_REG_MIISR 0x6D
0313 #define MAC_REG_PHYSR0 0x6E
0314 #define MAC_REG_PHYSR1 0x6F
0315 #define MAC_REG_MIICR 0x70
0316 #define MAC_REG_MIIADR 0x71
0317 #define MAC_REG_MIIDATA 0x72
0318 #define MAC_REG_SOFT_TIMER0 0x74
0319 #define MAC_REG_SOFT_TIMER1 0x76
0320 #define MAC_REG_CFGA 0x78
0321 #define MAC_REG_CFGB 0x79
0322 #define MAC_REG_CFGC 0x7A
0323 #define MAC_REG_CFGD 0x7B
0324 #define MAC_REG_DCFG0 0x7C
0325 #define MAC_REG_DCFG1 0x7D
0326 #define MAC_REG_MCFG0 0x7E
0327 #define MAC_REG_MCFG1 0x7F
0328
0329 #define MAC_REG_TBIST 0x80
0330 #define MAC_REG_RBIST 0x81
0331 #define MAC_REG_PMCC 0x82
0332 #define MAC_REG_STICKHW 0x83
0333 #define MAC_REG_MIBCR 0x84
0334 #define MAC_REG_EERSV 0x85
0335 #define MAC_REG_REVID 0x86
0336 #define MAC_REG_MIBREAD 0x88
0337 #define MAC_REG_BPMA 0x8C
0338 #define MAC_REG_EEWR_DATA 0x8C
0339 #define MAC_REG_BPMD_WR 0x8F
0340 #define MAC_REG_BPCMD 0x90
0341 #define MAC_REG_BPMD_RD 0x91
0342 #define MAC_REG_EECHKSUM 0x92
0343 #define MAC_REG_EECSR 0x93
0344 #define MAC_REG_EERD_DATA 0x94
0345 #define MAC_REG_EADDR 0x96
0346 #define MAC_REG_EMBCMD 0x97
0347 #define MAC_REG_JMPSR0 0x98
0348 #define MAC_REG_JMPSR1 0x99
0349 #define MAC_REG_JMPSR2 0x9A
0350 #define MAC_REG_JMPSR3 0x9B
0351 #define MAC_REG_CHIPGSR 0x9C
0352 #define MAC_REG_TESTCFG 0x9D
0353 #define MAC_REG_DEBUG 0x9E
0354 #define MAC_REG_CHIPGCR 0x9F
0355 #define MAC_REG_WOLCR0_SET 0xA0
0356 #define MAC_REG_WOLCR1_SET 0xA1
0357 #define MAC_REG_PWCFG_SET 0xA2
0358 #define MAC_REG_WOLCFG_SET 0xA3
0359 #define MAC_REG_WOLCR0_CLR 0xA4
0360 #define MAC_REG_WOLCR1_CLR 0xA5
0361 #define MAC_REG_PWCFG_CLR 0xA6
0362 #define MAC_REG_WOLCFG_CLR 0xA7
0363 #define MAC_REG_WOLSR0_SET 0xA8
0364 #define MAC_REG_WOLSR1_SET 0xA9
0365 #define MAC_REG_WOLSR0_CLR 0xAC
0366 #define MAC_REG_WOLSR1_CLR 0xAD
0367 #define MAC_REG_PATRN_CRC0 0xB0
0368 #define MAC_REG_PATRN_CRC1 0xB2
0369 #define MAC_REG_PATRN_CRC2 0xB4
0370 #define MAC_REG_PATRN_CRC3 0xB6
0371 #define MAC_REG_PATRN_CRC4 0xB8
0372 #define MAC_REG_PATRN_CRC5 0xBA
0373 #define MAC_REG_PATRN_CRC6 0xBC
0374 #define MAC_REG_PATRN_CRC7 0xBE
0375 #define MAC_REG_BYTEMSK0_0 0xC0
0376 #define MAC_REG_BYTEMSK0_1 0xC4
0377 #define MAC_REG_BYTEMSK0_2 0xC8
0378 #define MAC_REG_BYTEMSK0_3 0xCC
0379 #define MAC_REG_BYTEMSK1_0 0xD0
0380 #define MAC_REG_BYTEMSK1_1 0xD4
0381 #define MAC_REG_BYTEMSK1_2 0xD8
0382 #define MAC_REG_BYTEMSK1_3 0xDC
0383 #define MAC_REG_BYTEMSK2_0 0xE0
0384 #define MAC_REG_BYTEMSK2_1 0xE4
0385 #define MAC_REG_BYTEMSK2_2 0xE8
0386 #define MAC_REG_BYTEMSK2_3 0xEC
0387 #define MAC_REG_BYTEMSK3_0 0xF0
0388 #define MAC_REG_BYTEMSK3_1 0xF4
0389 #define MAC_REG_BYTEMSK3_2 0xF8
0390 #define MAC_REG_BYTEMSK3_3 0xFC
0391
0392
0393
0394
0395
0396 #define RCR_AS 0x80
0397 #define RCR_AP 0x40
0398 #define RCR_AL 0x20
0399 #define RCR_PROM 0x10
0400 #define RCR_AB 0x08
0401 #define RCR_AM 0x04
0402 #define RCR_AR 0x02
0403 #define RCR_SEP 0x01
0404
0405
0406
0407
0408
0409 #define TCR_TB2BDIS 0x80
0410 #define TCR_COLTMC1 0x08
0411 #define TCR_COLTMC0 0x04
0412 #define TCR_LB1 0x02
0413 #define TCR_LB0 0x01
0414
0415
0416
0417
0418
0419 #define CR0_TXON 0x00000008UL
0420 #define CR0_RXON 0x00000004UL
0421 #define CR0_STOP 0x00000002UL
0422 #define CR0_STRT 0x00000001UL
0423 #define CR0_SFRST 0x00008000UL
0424 #define CR0_TM1EN 0x00004000UL
0425 #define CR0_TM0EN 0x00002000UL
0426 #define CR0_DPOLL 0x00000800UL
0427 #define CR0_DISAU 0x00000100UL
0428 #define CR0_XONEN 0x00800000UL
0429 #define CR0_FDXTFCEN 0x00400000UL
0430 #define CR0_FDXRFCEN 0x00200000UL
0431 #define CR0_HDXFCEN 0x00100000UL
0432 #define CR0_XHITH1 0x00080000UL
0433 #define CR0_XHITH0 0x00040000UL
0434 #define CR0_XLTH1 0x00020000UL
0435 #define CR0_XLTH0 0x00010000UL
0436 #define CR0_GSPRST 0x80000000UL
0437 #define CR0_FORSRST 0x40000000UL
0438 #define CR0_FPHYRST 0x20000000UL
0439 #define CR0_DIAG 0x10000000UL
0440 #define CR0_INTPCTL 0x04000000UL
0441 #define CR0_GINTMSK1 0x02000000UL
0442 #define CR0_GINTMSK0 0x01000000UL
0443
0444
0445
0446
0447
0448 #define CR1_SFRST 0x80
0449 #define CR1_TM1EN 0x40
0450 #define CR1_TM0EN 0x20
0451 #define CR1_DPOLL 0x08
0452 #define CR1_DISAU 0x01
0453
0454
0455
0456
0457
0458 #define CR2_XONEN 0x80
0459 #define CR2_FDXTFCEN 0x40
0460 #define CR2_FDXRFCEN 0x20
0461 #define CR2_HDXFCEN 0x10
0462 #define CR2_XHITH1 0x08
0463 #define CR2_XHITH0 0x04
0464 #define CR2_XLTH1 0x02
0465 #define CR2_XLTH0 0x01
0466
0467
0468
0469
0470
0471 #define CR3_GSPRST 0x80
0472 #define CR3_FORSRST 0x40
0473 #define CR3_FPHYRST 0x20
0474 #define CR3_DIAG 0x10
0475 #define CR3_INTPCTL 0x04
0476 #define CR3_GINTMSK1 0x02
0477 #define CR3_GINTMSK0 0x01
0478
0479 #define ISRCTL_UDPINT 0x8000
0480 #define ISRCTL_TSUPDIS 0x4000
0481 #define ISRCTL_RSUPDIS 0x2000
0482 #define ISRCTL_PMSK1 0x1000
0483 #define ISRCTL_PMSK0 0x0800
0484 #define ISRCTL_INTPD 0x0400
0485 #define ISRCTL_HCRLD 0x0200
0486 #define ISRCTL_SCRLD 0x0100
0487
0488
0489
0490
0491
0492 #define ISRCTL1_UDPINT 0x80
0493 #define ISRCTL1_TSUPDIS 0x40
0494 #define ISRCTL1_RSUPDIS 0x20
0495 #define ISRCTL1_PMSK1 0x10
0496 #define ISRCTL1_PMSK0 0x08
0497 #define ISRCTL1_INTPD 0x04
0498 #define ISRCTL1_HCRLD 0x02
0499 #define ISRCTL1_SCRLD 0x01
0500
0501
0502
0503
0504
0505 #define TXESR_TFDBS 0x08
0506 #define TXESR_TDWBS 0x04
0507 #define TXESR_TDRBS 0x02
0508 #define TXESR_TDSTR 0x01
0509
0510
0511
0512
0513
0514 #define RXESR_RFDBS 0x08
0515 #define RXESR_RDWBS 0x04
0516 #define RXESR_RDRBS 0x02
0517 #define RXESR_RDSTR 0x01
0518
0519
0520
0521
0522
0523 #define ISR_ISR3 0x80000000UL
0524 #define ISR_ISR2 0x40000000UL
0525 #define ISR_ISR1 0x20000000UL
0526 #define ISR_ISR0 0x10000000UL
0527 #define ISR_TXSTLI 0x02000000UL
0528 #define ISR_RXSTLI 0x01000000UL
0529 #define ISR_HFLD 0x00800000UL
0530 #define ISR_UDPI 0x00400000UL
0531 #define ISR_MIBFI 0x00200000UL
0532 #define ISR_SHDNI 0x00100000UL
0533 #define ISR_PHYI 0x00080000UL
0534 #define ISR_PWEI 0x00040000UL
0535 #define ISR_TMR1I 0x00020000UL
0536 #define ISR_TMR0I 0x00010000UL
0537 #define ISR_SRCI 0x00008000UL
0538 #define ISR_LSTPEI 0x00004000UL
0539 #define ISR_LSTEI 0x00002000UL
0540 #define ISR_OVFI 0x00001000UL
0541 #define ISR_FLONI 0x00000800UL
0542 #define ISR_RACEI 0x00000400UL
0543 #define ISR_TXWB1I 0x00000200UL
0544 #define ISR_TXWB0I 0x00000100UL
0545 #define ISR_PTX3I 0x00000080UL
0546 #define ISR_PTX2I 0x00000040UL
0547 #define ISR_PTX1I 0x00000020UL
0548 #define ISR_PTX0I 0x00000010UL
0549 #define ISR_PTXI 0x00000008UL
0550 #define ISR_PRXI 0x00000004UL
0551 #define ISR_PPTXI 0x00000002UL
0552 #define ISR_PPRXI 0x00000001UL
0553
0554
0555
0556
0557
0558 #define IMR_TXSTLM 0x02000000UL
0559 #define IMR_UDPIM 0x00400000UL
0560 #define IMR_MIBFIM 0x00200000UL
0561 #define IMR_SHDNIM 0x00100000UL
0562 #define IMR_PHYIM 0x00080000UL
0563 #define IMR_PWEIM 0x00040000UL
0564 #define IMR_TMR1IM 0x00020000UL
0565 #define IMR_TMR0IM 0x00010000UL
0566
0567 #define IMR_SRCIM 0x00008000UL
0568 #define IMR_LSTPEIM 0x00004000UL
0569 #define IMR_LSTEIM 0x00002000UL
0570 #define IMR_OVFIM 0x00001000UL
0571 #define IMR_FLONIM 0x00000800UL
0572 #define IMR_RACEIM 0x00000400UL
0573 #define IMR_TXWB1IM 0x00000200UL
0574 #define IMR_TXWB0IM 0x00000100UL
0575
0576 #define IMR_PTX3IM 0x00000080UL
0577 #define IMR_PTX2IM 0x00000040UL
0578 #define IMR_PTX1IM 0x00000020UL
0579 #define IMR_PTX0IM 0x00000010UL
0580 #define IMR_PTXIM 0x00000008UL
0581 #define IMR_PRXIM 0x00000004UL
0582 #define IMR_PPTXIM 0x00000002UL
0583 #define IMR_PPRXIM 0x00000001UL
0584
0585
0586
0587 #define INT_MASK_DEF (IMR_PPTXIM|IMR_PPRXIM|IMR_PTXIM|IMR_PRXIM|\
0588 IMR_PWEIM|IMR_TXWB0IM|IMR_TXWB1IM|IMR_FLONIM|\
0589 IMR_OVFIM|IMR_LSTEIM|IMR_LSTPEIM|IMR_SRCIM|IMR_MIBFIM|\
0590 IMR_SHDNIM|IMR_TMR1IM|IMR_TMR0IM|IMR_TXSTLM)
0591
0592
0593
0594
0595
0596 #define TRDCSR_DEAD 0x0008
0597 #define TRDCSR_WAK 0x0004
0598 #define TRDCSR_ACT 0x0002
0599 #define TRDCSR_RUN 0x0001
0600
0601
0602
0603
0604
0605 #define CAMADDR_CAMEN 0x80
0606 #define CAMADDR_VCAMSL 0x40
0607
0608
0609
0610
0611
0612 #define CAMCR_PS1 0x80
0613 #define CAMCR_PS0 0x40
0614 #define CAMCR_AITRPKT 0x20
0615 #define CAMCR_AITR16 0x10
0616 #define CAMCR_CAMRD 0x08
0617 #define CAMCR_CAMWR 0x04
0618 #define CAMCR_PS_CAM_MASK 0x40
0619 #define CAMCR_PS_CAM_DATA 0x80
0620 #define CAMCR_PS_MAR 0x00
0621
0622
0623
0624
0625
0626 #define MIICFG_MPO1 0x80
0627 #define MIICFG_MPO0 0x40
0628 #define MIICFG_MFDC 0x20
0629
0630
0631
0632
0633
0634 #define MIISR_MIDLE 0x80
0635
0636
0637
0638
0639
0640 #define PHYSR0_PHYRST 0x80
0641 #define PHYSR0_LINKGD 0x40
0642 #define PHYSR0_FDPX 0x10
0643 #define PHYSR0_SPDG 0x08
0644 #define PHYSR0_SPD10 0x04
0645 #define PHYSR0_RXFLC 0x02
0646 #define PHYSR0_TXFLC 0x01
0647
0648
0649
0650
0651
0652 #define PHYSR1_PHYTBI 0x01
0653
0654
0655
0656
0657
0658 #define MIICR_MAUTO 0x80
0659 #define MIICR_RCMD 0x40
0660 #define MIICR_WCMD 0x20
0661 #define MIICR_MDPM 0x10
0662 #define MIICR_MOUT 0x08
0663 #define MIICR_MDO 0x04
0664 #define MIICR_MDI 0x02
0665 #define MIICR_MDC 0x01
0666
0667
0668
0669
0670
0671 #define MIIADR_SWMPL 0x80
0672
0673
0674
0675
0676
0677 #define CFGA_PMHCTG 0x08
0678 #define CFGA_GPIO1PD 0x04
0679 #define CFGA_ABSHDN 0x02
0680 #define CFGA_PACPI 0x01
0681
0682
0683
0684
0685
0686 #define CFGB_GTCKOPT 0x80
0687 #define CFGB_MIIOPT 0x40
0688 #define CFGB_CRSEOPT 0x20
0689 #define CFGB_OFSET 0x10
0690 #define CFGB_CRANDOM 0x08
0691 #define CFGB_CAP 0x04
0692 #define CFGB_MBA 0x02
0693 #define CFGB_BAKOPT 0x01
0694
0695
0696
0697
0698
0699 #define CFGC_EELOAD 0x80
0700 #define CFGC_BROPT 0x40
0701 #define CFGC_DLYEN 0x20
0702 #define CFGC_DTSEL 0x10
0703 #define CFGC_BTSEL 0x08
0704 #define CFGC_BPS2 0x04
0705 #define CFGC_BPS1 0x02
0706 #define CFGC_BPS0 0x01
0707
0708
0709
0710
0711
0712 #define CFGD_IODIS 0x80
0713 #define CFGD_MSLVDACEN 0x40
0714 #define CFGD_CFGDACEN 0x20
0715 #define CFGD_PCI64EN 0x10
0716 #define CFGD_HTMRL4 0x08
0717
0718
0719
0720
0721
0722 #define DCFG_XMWI 0x8000
0723 #define DCFG_XMRM 0x4000
0724 #define DCFG_XMRL 0x2000
0725 #define DCFG_PERDIS 0x1000
0726 #define DCFG_MRWAIT 0x0400
0727 #define DCFG_MWWAIT 0x0200
0728 #define DCFG_LATMEN 0x0100
0729
0730
0731
0732
0733
0734 #define MCFG_RXARB 0x0080
0735 #define MCFG_RFT1 0x0020
0736 #define MCFG_RFT0 0x0010
0737 #define MCFG_LOWTHOPT 0x0008
0738 #define MCFG_PQEN 0x0004
0739 #define MCFG_RTGOPT 0x0002
0740 #define MCFG_VIDFR 0x0001
0741
0742
0743
0744
0745
0746 #define MCFG_TXARB 0x8000
0747 #define MCFG_TXQBK1 0x0800
0748 #define MCFG_TXQBK0 0x0400
0749 #define MCFG_TXQNOBK 0x0200
0750 #define MCFG_SNAPOPT 0x0100
0751
0752
0753
0754
0755
0756 #define PMCC_DSI 0x80
0757 #define PMCC_D2_DIS 0x40
0758 #define PMCC_D1_DIS 0x20
0759 #define PMCC_D3C_EN 0x10
0760 #define PMCC_D3H_EN 0x08
0761 #define PMCC_D2_EN 0x04
0762 #define PMCC_D1_EN 0x02
0763 #define PMCC_D0_EN 0x01
0764
0765
0766
0767
0768
0769 #define STICKHW_SWPTAG 0x10
0770 #define STICKHW_WOLSR 0x08
0771 #define STICKHW_WOLEN 0x04
0772 #define STICKHW_DS1 0x02
0773 #define STICKHW_DS0 0x01
0774
0775
0776
0777
0778
0779 #define MIBCR_MIBISTOK 0x80
0780 #define MIBCR_MIBISTGO 0x40
0781 #define MIBCR_MIBINC 0x20
0782 #define MIBCR_MIBHI 0x10
0783 #define MIBCR_MIBFRZ 0x08
0784 #define MIBCR_MIBFLSH 0x04
0785 #define MIBCR_MPTRINI 0x02
0786 #define MIBCR_MIBCLR 0x01
0787
0788
0789
0790
0791
0792 #define EERSV_BOOT_RPL ((u8) 0x01)
0793
0794 #define EERSV_BOOT_MASK ((u8) 0x06)
0795 #define EERSV_BOOT_INT19 ((u8) 0x00)
0796 #define EERSV_BOOT_INT18 ((u8) 0x02)
0797 #define EERSV_BOOT_LOCAL ((u8) 0x04)
0798 #define EERSV_BOOT_BEV ((u8) 0x06)
0799
0800
0801
0802
0803
0804
0805 #define BPCMD_BPDNE 0x80
0806 #define BPCMD_EBPWR 0x02
0807 #define BPCMD_EBPRD 0x01
0808
0809
0810
0811
0812
0813 #define EECSR_EMBP 0x40
0814 #define EECSR_RELOAD 0x20
0815 #define EECSR_DPM 0x10
0816 #define EECSR_ECS 0x08
0817 #define EECSR_ECK 0x04
0818 #define EECSR_EDI 0x02
0819 #define EECSR_EDO 0x01
0820
0821
0822
0823
0824
0825 #define EMBCMD_EDONE 0x80
0826 #define EMBCMD_EWDIS 0x08
0827 #define EMBCMD_EWEN 0x04
0828 #define EMBCMD_EWR 0x02
0829 #define EMBCMD_ERD 0x01
0830
0831
0832
0833
0834
0835 #define TESTCFG_HBDIS 0x80
0836
0837
0838
0839
0840
0841 #define CHIPGCR_FCGMII 0x80
0842 #define CHIPGCR_FCFDX 0x40
0843 #define CHIPGCR_FCRESV 0x20
0844 #define CHIPGCR_FCMODE 0x10
0845 #define CHIPGCR_LPSOPT 0x08
0846 #define CHIPGCR_TM1US 0x04
0847 #define CHIPGCR_TM0US 0x02
0848 #define CHIPGCR_PHYINTEN 0x01
0849
0850
0851
0852
0853
0854 #define WOLCR_MSWOLEN7 0x0080
0855 #define WOLCR_MSWOLEN6 0x0040
0856 #define WOLCR_MSWOLEN5 0x0020
0857 #define WOLCR_MSWOLEN4 0x0010
0858 #define WOLCR_MSWOLEN3 0x0008
0859 #define WOLCR_MSWOLEN2 0x0004
0860 #define WOLCR_MSWOLEN1 0x0002
0861 #define WOLCR_MSWOLEN0 0x0001
0862 #define WOLCR_ARP_EN 0x0001
0863
0864
0865
0866
0867
0868 #define WOLCR_LINKOFF_EN 0x0800
0869 #define WOLCR_LINKON_EN 0x0400
0870 #define WOLCR_MAGIC_EN 0x0200
0871 #define WOLCR_UNICAST_EN 0x0100
0872
0873
0874
0875
0876
0877
0878 #define PWCFG_PHYPWOPT 0x80
0879 #define PWCFG_PCISTICK 0x40
0880 #define PWCFG_WOLTYPE 0x20
0881 #define PWCFG_LEGCY_WOL 0x10
0882 #define PWCFG_PMCSR_PME_SR 0x08
0883 #define PWCFG_PMCSR_PME_EN 0x04
0884 #define PWCFG_LEGACY_WOLSR 0x02
0885 #define PWCFG_LEGACY_WOLEN 0x01
0886
0887
0888
0889
0890
0891 #define WOLCFG_PMEOVR 0x80
0892 #define WOLCFG_SAM 0x20
0893 #define WOLCFG_SAB 0x10
0894 #define WOLCFG_SMIIACC 0x08
0895 #define WOLCFG_SGENWH 0x02
0896 #define WOLCFG_PHYINTEN 0x01
0897
0898
0899
0900
0901
0902 #define WOLSR_LINKOFF_INT 0x0800
0903 #define WOLSR_LINKON_INT 0x0400
0904 #define WOLSR_MAGIC_INT 0x0200
0905 #define WOLSR_UNICAST_INT 0x0100
0906
0907
0908
0909
0910
0911 #define PKT_TYPE_NONE 0x0000
0912 #define PKT_TYPE_DIRECTED 0x0001
0913 #define PKT_TYPE_MULTICAST 0x0002
0914 #define PKT_TYPE_ALL_MULTICAST 0x0004
0915 #define PKT_TYPE_BROADCAST 0x0008
0916 #define PKT_TYPE_PROMISCUOUS 0x0020
0917 #define PKT_TYPE_LONG 0x2000
0918 #define PKT_TYPE_RUNT 0x4000
0919 #define PKT_TYPE_ERROR 0x8000
0920
0921
0922
0923
0924
0925 #define MAC_LB_NONE 0x00
0926 #define MAC_LB_INTERNAL 0x01
0927 #define MAC_LB_EXTERNAL 0x02
0928
0929
0930
0931
0932
0933 #if defined(_SIM)
0934 #define IMR_MASK_VALUE 0x0033FF0FUL
0935
0936
0937 #else
0938 #define IMR_MASK_VALUE 0x0013FB0FUL
0939
0940
0941
0942
0943
0944
0945 #endif
0946
0947
0948
0949
0950
0951 #define REV_ID_VT3119_A0 0x00
0952 #define REV_ID_VT3119_A1 0x01
0953 #define REV_ID_VT3216_A0 0x10
0954
0955
0956
0957
0958
0959 #define W_MAX_TIMEOUT 0x0FFFU
0960
0961
0962
0963
0964
0965
0966
0967 struct mac_regs {
0968 volatile u8 PAR[6];
0969 volatile u8 RCR;
0970 volatile u8 TCR;
0971
0972 volatile __le32 CR0Set;
0973 volatile __le32 CR0Clr;
0974
0975 volatile u8 MARCAM[8];
0976
0977 volatile __le32 DecBaseHi;
0978 volatile __le16 DbfBaseHi;
0979 volatile __le16 reserved_1E;
0980
0981 volatile __le16 ISRCTL;
0982 volatile u8 TXESR;
0983 volatile u8 RXESR;
0984
0985 volatile __le32 ISR;
0986 volatile __le32 IMR;
0987
0988 volatile __le32 TDStatusPort;
0989
0990 volatile __le16 TDCSRSet;
0991 volatile u8 RDCSRSet;
0992 volatile u8 reserved_33;
0993 volatile __le16 TDCSRClr;
0994 volatile u8 RDCSRClr;
0995 volatile u8 reserved_37;
0996
0997 volatile __le32 RDBaseLo;
0998 volatile __le16 RDIdx;
0999 volatile u8 TQETMR;
1000 volatile u8 RQETMR;
1001
1002 volatile __le32 TDBaseLo[4];
1003
1004 volatile __le16 RDCSize;
1005 volatile __le16 TDCSize;
1006 volatile __le16 TDIdx[4];
1007 volatile __le16 tx_pause_timer;
1008 volatile __le16 RBRDU;
1009
1010 volatile __le32 FIFOTest0;
1011 volatile __le32 FIFOTest1;
1012
1013 volatile u8 CAMADDR;
1014 volatile u8 CAMCR;
1015 volatile u8 GFTEST;
1016 volatile u8 FTSTCMD;
1017
1018 volatile u8 MIICFG;
1019 volatile u8 MIISR;
1020 volatile u8 PHYSR0;
1021 volatile u8 PHYSR1;
1022 volatile u8 MIICR;
1023 volatile u8 MIIADR;
1024 volatile __le16 MIIDATA;
1025
1026 volatile __le16 SoftTimer0;
1027 volatile __le16 SoftTimer1;
1028
1029 volatile u8 CFGA;
1030 volatile u8 CFGB;
1031 volatile u8 CFGC;
1032 volatile u8 CFGD;
1033
1034 volatile __le16 DCFG;
1035 volatile __le16 MCFG;
1036
1037 volatile u8 TBIST;
1038 volatile u8 RBIST;
1039 volatile u8 PMCPORT;
1040 volatile u8 STICKHW;
1041
1042 volatile u8 MIBCR;
1043 volatile u8 reserved_85;
1044 volatile u8 rev_id;
1045 volatile u8 PORSTS;
1046
1047 volatile __le32 MIBData;
1048
1049 volatile __le16 EEWrData;
1050
1051 volatile u8 reserved_8E;
1052 volatile u8 BPMDWr;
1053 volatile u8 BPCMD;
1054 volatile u8 BPMDRd;
1055
1056 volatile u8 EECHKSUM;
1057 volatile u8 EECSR;
1058
1059 volatile __le16 EERdData;
1060 volatile u8 EADDR;
1061 volatile u8 EMBCMD;
1062
1063
1064 volatile u8 JMPSR0;
1065 volatile u8 JMPSR1;
1066 volatile u8 JMPSR2;
1067 volatile u8 JMPSR3;
1068 volatile u8 CHIPGSR;
1069 volatile u8 TESTCFG;
1070 volatile u8 DEBUG;
1071 volatile u8 CHIPGCR;
1072
1073 volatile __le16 WOLCRSet;
1074 volatile u8 PWCFGSet;
1075 volatile u8 WOLCFGSet;
1076
1077 volatile __le16 WOLCRClr;
1078 volatile u8 PWCFGCLR;
1079 volatile u8 WOLCFGClr;
1080
1081 volatile __le16 WOLSRSet;
1082 volatile __le16 reserved_AA;
1083
1084 volatile __le16 WOLSRClr;
1085 volatile __le16 reserved_AE;
1086
1087 volatile __le16 PatternCRC[8];
1088 volatile __le32 ByteMask[4][4];
1089 };
1090
1091
1092 enum hw_mib {
1093 HW_MIB_ifRxAllPkts = 0,
1094 HW_MIB_ifRxOkPkts,
1095 HW_MIB_ifTxOkPkts,
1096 HW_MIB_ifRxErrorPkts,
1097 HW_MIB_ifRxRuntOkPkt,
1098 HW_MIB_ifRxRuntErrPkt,
1099 HW_MIB_ifRx64Pkts,
1100 HW_MIB_ifTx64Pkts,
1101 HW_MIB_ifRx65To127Pkts,
1102 HW_MIB_ifTx65To127Pkts,
1103 HW_MIB_ifRx128To255Pkts,
1104 HW_MIB_ifTx128To255Pkts,
1105 HW_MIB_ifRx256To511Pkts,
1106 HW_MIB_ifTx256To511Pkts,
1107 HW_MIB_ifRx512To1023Pkts,
1108 HW_MIB_ifTx512To1023Pkts,
1109 HW_MIB_ifRx1024To1518Pkts,
1110 HW_MIB_ifTx1024To1518Pkts,
1111 HW_MIB_ifTxEtherCollisions,
1112 HW_MIB_ifRxPktCRCE,
1113 HW_MIB_ifRxJumboPkts,
1114 HW_MIB_ifTxJumboPkts,
1115 HW_MIB_ifRxMacControlFrames,
1116 HW_MIB_ifTxMacControlFrames,
1117 HW_MIB_ifRxPktFAE,
1118 HW_MIB_ifRxLongOkPkt,
1119 HW_MIB_ifRxLongPktErrPkt,
1120 HW_MIB_ifTXSQEErrors,
1121 HW_MIB_ifRxNobuf,
1122 HW_MIB_ifRxSymbolErrors,
1123 HW_MIB_ifInRangeLengthErrors,
1124 HW_MIB_ifLateCollisions,
1125 HW_MIB_SIZE
1126 };
1127
1128 enum chip_type {
1129 CHIP_TYPE_VT6110 = 1,
1130 };
1131
1132 struct velocity_info_tbl {
1133 enum chip_type chip_id;
1134 const char *name;
1135 int txqueue;
1136 u32 flags;
1137 };
1138
1139 #define mac_hw_mibs_init(regs) {\
1140 BYTE_REG_BITS_ON(MIBCR_MIBFRZ,&((regs)->MIBCR));\
1141 BYTE_REG_BITS_ON(MIBCR_MIBCLR,&((regs)->MIBCR));\
1142 do {}\
1143 while (BYTE_REG_BITS_IS_ON(MIBCR_MIBCLR,&((regs)->MIBCR)));\
1144 BYTE_REG_BITS_OFF(MIBCR_MIBFRZ,&((regs)->MIBCR));\
1145 }
1146
1147 #define mac_read_isr(regs) readl(&((regs)->ISR))
1148 #define mac_write_isr(regs, x) writel((x),&((regs)->ISR))
1149 #define mac_clear_isr(regs) writel(0xffffffffL,&((regs)->ISR))
1150
1151 #define mac_write_int_mask(mask, regs) writel((mask),&((regs)->IMR));
1152 #define mac_disable_int(regs) writel(CR0_GINTMSK1,&((regs)->CR0Clr))
1153 #define mac_enable_int(regs) writel(CR0_GINTMSK1,&((regs)->CR0Set))
1154
1155 #define mac_set_dma_length(regs, n) {\
1156 BYTE_REG_BITS_SET((n),0x07,&((regs)->DCFG));\
1157 }
1158
1159 #define mac_set_rx_thresh(regs, n) {\
1160 BYTE_REG_BITS_SET((n),(MCFG_RFT0|MCFG_RFT1),&((regs)->MCFG));\
1161 }
1162
1163 #define mac_rx_queue_run(regs) {\
1164 writeb(TRDCSR_RUN, &((regs)->RDCSRSet));\
1165 }
1166
1167 #define mac_rx_queue_wake(regs) {\
1168 writeb(TRDCSR_WAK, &((regs)->RDCSRSet));\
1169 }
1170
1171 #define mac_tx_queue_run(regs, n) {\
1172 writew(TRDCSR_RUN<<((n)*4),&((regs)->TDCSRSet));\
1173 }
1174
1175 #define mac_tx_queue_wake(regs, n) {\
1176 writew(TRDCSR_WAK<<(n*4),&((regs)->TDCSRSet));\
1177 }
1178
1179 static inline void mac_eeprom_reload(struct mac_regs __iomem * regs) {
1180 int i=0;
1181
1182 BYTE_REG_BITS_ON(EECSR_RELOAD,&(regs->EECSR));
1183 do {
1184 udelay(10);
1185 if (i++>0x1000)
1186 break;
1187 } while (BYTE_REG_BITS_IS_ON(EECSR_RELOAD,&(regs->EECSR)));
1188 }
1189
1190
1191
1192
1193
1194 typedef u8 MCAM_ADDR[ETH_ALEN];
1195
1196 struct arp_packet {
1197 u8 dest_mac[ETH_ALEN];
1198 u8 src_mac[ETH_ALEN];
1199 __be16 type;
1200 __be16 ar_hrd;
1201 __be16 ar_pro;
1202 u8 ar_hln;
1203 u8 ar_pln;
1204 __be16 ar_op;
1205 u8 ar_sha[ETH_ALEN];
1206 u8 ar_sip[4];
1207 u8 ar_tha[ETH_ALEN];
1208 u8 ar_tip[4];
1209 } __packed;
1210
1211 struct _magic_packet {
1212 u8 dest_mac[6];
1213 u8 src_mac[6];
1214 __be16 type;
1215 u8 MAC[16][6];
1216 u8 password[6];
1217 } __packed;
1218
1219
1220
1221
1222
1223
1224 struct velocity_context {
1225 u8 mac_reg[256];
1226 MCAM_ADDR cam_addr[MCAM_SIZE];
1227 u16 vcam[VCAM_SIZE];
1228 u32 cammask[2];
1229 u32 patcrc[2];
1230 u32 pattern[8];
1231 };
1232
1233
1234
1235
1236
1237
1238 #define MII_REG_PSCR 0x10
1239
1240
1241
1242
1243
1244 #define TCSR_ECHODIS 0x2000
1245 #define AUXCR_MDPPS 0x0004
1246
1247
1248 #define PLED_LALBE 0x0004
1249
1250
1251 #define PSCR_ACRSTX 0x0800
1252
1253 #define PHYID_CICADA_CS8201 0x000FC410UL
1254 #define PHYID_VT3216_32BIT 0x000FC610UL
1255 #define PHYID_VT3216_64BIT 0x000FC600UL
1256 #define PHYID_MARVELL_1000 0x01410C50UL
1257 #define PHYID_MARVELL_1000S 0x01410C40UL
1258 #define PHYID_ICPLUS_IP101A 0x02430C54UL
1259 #define PHYID_REV_ID_MASK 0x0000000FUL
1260
1261 #define PHYID_GET_PHY_ID(i) ((i) & ~PHYID_REV_ID_MASK)
1262
1263 #define MII_REG_BITS_ON(x,i,p) do {\
1264 u16 w;\
1265 velocity_mii_read((p),(i),&(w));\
1266 (w)|=(x);\
1267 velocity_mii_write((p),(i),(w));\
1268 } while (0)
1269
1270 #define MII_REG_BITS_OFF(x,i,p) do {\
1271 u16 w;\
1272 velocity_mii_read((p),(i),&(w));\
1273 (w)&=(~(x));\
1274 velocity_mii_write((p),(i),(w));\
1275 } while (0)
1276
1277 #define MII_REG_BITS_IS_ON(x,i,p) ({\
1278 u16 w;\
1279 velocity_mii_read((p),(i),&(w));\
1280 ((int) ((w) & (x)));})
1281
1282 #define MII_GET_PHY_ID(p) ({\
1283 u32 id;\
1284 velocity_mii_read((p),MII_PHYSID2,(u16 *) &id);\
1285 velocity_mii_read((p),MII_PHYSID1,((u16 *) &id)+1);\
1286 (id);})
1287
1288 #define VELOCITY_WOL_MAGIC 0x00000000UL
1289 #define VELOCITY_WOL_PHY 0x00000001UL
1290 #define VELOCITY_WOL_ARP 0x00000002UL
1291 #define VELOCITY_WOL_UCAST 0x00000004UL
1292 #define VELOCITY_WOL_BCAST 0x00000010UL
1293 #define VELOCITY_WOL_MCAST 0x00000020UL
1294 #define VELOCITY_WOL_MAGIC_SEC 0x00000040UL
1295
1296
1297
1298
1299
1300 #define VELOCITY_FLAGS_TAGGING 0x00000001UL
1301 #define VELOCITY_FLAGS_RX_CSUM 0x00000004UL
1302 #define VELOCITY_FLAGS_IP_ALIGN 0x00000008UL
1303 #define VELOCITY_FLAGS_VAL_PKT_LEN 0x00000010UL
1304
1305 #define VELOCITY_FLAGS_FLOW_CTRL 0x01000000UL
1306
1307
1308
1309
1310
1311 #define VELOCITY_FLAGS_OPENED 0x00010000UL
1312 #define VELOCITY_FLAGS_VMNS_CONNECTED 0x00020000UL
1313 #define VELOCITY_FLAGS_VMNS_COMMITTED 0x00040000UL
1314 #define VELOCITY_FLAGS_WOL_ENABLED 0x00080000UL
1315
1316
1317
1318
1319
1320 #define VELOCITY_LINK_FAIL 0x00000001UL
1321 #define VELOCITY_SPEED_10 0x00000002UL
1322 #define VELOCITY_SPEED_100 0x00000004UL
1323 #define VELOCITY_SPEED_1000 0x00000008UL
1324 #define VELOCITY_DUPLEX_FULL 0x00000010UL
1325 #define VELOCITY_AUTONEG_ENABLE 0x00000020UL
1326 #define VELOCITY_FORCED_BY_EEPROM 0x00000040UL
1327
1328
1329
1330
1331
1332 #define VELOCITY_LINK_CHANGE 0x00000001UL
1333
1334 enum speed_opt {
1335 SPD_DPX_AUTO = 0,
1336 SPD_DPX_100_HALF = 1,
1337 SPD_DPX_100_FULL = 2,
1338 SPD_DPX_10_HALF = 3,
1339 SPD_DPX_10_FULL = 4,
1340 SPD_DPX_1000_FULL = 5
1341 };
1342
1343 enum velocity_init_type {
1344 VELOCITY_INIT_COLD = 0,
1345 VELOCITY_INIT_RESET,
1346 VELOCITY_INIT_WOL
1347 };
1348
1349 enum velocity_flow_cntl_type {
1350 FLOW_CNTL_DEFAULT = 1,
1351 FLOW_CNTL_TX,
1352 FLOW_CNTL_RX,
1353 FLOW_CNTL_TX_RX,
1354 FLOW_CNTL_DISABLE,
1355 };
1356
1357 struct velocity_opt {
1358 int numrx;
1359 int numtx;
1360 enum speed_opt spd_dpx;
1361
1362 int DMA_length;
1363 int rx_thresh;
1364 int flow_cntl;
1365 int wol_opts;
1366 int td_int_count;
1367 int int_works;
1368 int rx_bandwidth_hi;
1369 int rx_bandwidth_lo;
1370 int rx_bandwidth_en;
1371 int rxqueue_timer;
1372 int txqueue_timer;
1373 int tx_intsup;
1374 int rx_intsup;
1375 u32 flags;
1376 };
1377
1378 #define AVAIL_TD(p,q) ((p)->options.numtx-((p)->tx.used[(q)]))
1379
1380 #define GET_RD_BY_IDX(vptr, idx) (vptr->rd_ring[idx])
1381
1382 struct velocity_info {
1383 struct device *dev;
1384 struct pci_dev *pdev;
1385 struct net_device *netdev;
1386 int no_eeprom;
1387
1388 unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
1389 u8 ip_addr[4];
1390 enum chip_type chip_id;
1391
1392 struct mac_regs __iomem * mac_regs;
1393 unsigned long memaddr;
1394 unsigned long ioaddr;
1395
1396 struct tx_info {
1397 int numq;
1398
1399
1400 int used[TX_QUEUE_NO];
1401 int curr[TX_QUEUE_NO];
1402 int tail[TX_QUEUE_NO];
1403 struct tx_desc *rings[TX_QUEUE_NO];
1404 struct velocity_td_info *infos[TX_QUEUE_NO];
1405 dma_addr_t pool_dma[TX_QUEUE_NO];
1406 } tx;
1407
1408 struct rx_info {
1409 int buf_sz;
1410
1411 int dirty;
1412 int curr;
1413 u32 filled;
1414 struct rx_desc *ring;
1415 struct velocity_rd_info *info;
1416 dma_addr_t pool_dma;
1417 } rx;
1418
1419 u32 mib_counter[MAX_HW_MIB_COUNTER];
1420 struct velocity_opt options;
1421
1422 u32 int_mask;
1423
1424 u32 flags;
1425
1426 u32 mii_status;
1427 u32 phy_id;
1428 int multicast_limit;
1429
1430 u8 vCAMmask[(VCAM_SIZE / 8)];
1431 u8 mCAMmask[(MCAM_SIZE / 8)];
1432
1433 spinlock_t lock;
1434
1435 int wol_opts;
1436 u8 wol_passwd[6];
1437
1438 struct velocity_context context;
1439
1440 u32 ticks;
1441 u32 ethtool_ops_nesting;
1442
1443 u8 rev_id;
1444
1445 struct napi_struct napi;
1446 };
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459 static inline int velocity_get_ip(struct velocity_info *vptr)
1460 {
1461 struct in_device *in_dev;
1462 struct in_ifaddr *ifa;
1463 int res = -ENOENT;
1464
1465 rcu_read_lock();
1466 in_dev = __in_dev_get_rcu(vptr->netdev);
1467 if (in_dev != NULL) {
1468 ifa = rcu_dereference(in_dev->ifa_list);
1469 if (ifa != NULL) {
1470 memcpy(vptr->ip_addr, &ifa->ifa_address, 4);
1471 res = 0;
1472 }
1473 }
1474 rcu_read_unlock();
1475 return res;
1476 }
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489 static inline void velocity_update_hw_mibs(struct velocity_info *vptr)
1490 {
1491 u32 tmp;
1492 int i;
1493 BYTE_REG_BITS_ON(MIBCR_MIBFLSH, &(vptr->mac_regs->MIBCR));
1494
1495 while (BYTE_REG_BITS_IS_ON(MIBCR_MIBFLSH, &(vptr->mac_regs->MIBCR)));
1496
1497 BYTE_REG_BITS_ON(MIBCR_MPTRINI, &(vptr->mac_regs->MIBCR));
1498 for (i = 0; i < HW_MIB_SIZE; i++) {
1499 tmp = readl(&(vptr->mac_regs->MIBData)) & 0x00FFFFFFUL;
1500 vptr->mib_counter[i] += tmp;
1501 }
1502 }
1503
1504
1505
1506
1507
1508
1509
1510
1511 static inline void init_flow_control_register(struct velocity_info *vptr)
1512 {
1513 struct mac_regs __iomem * regs = vptr->mac_regs;
1514
1515
1516
1517 writel((CR0_XONEN | CR0_XHITH1 | CR0_XLTH1 | CR0_XLTH0), ®s->CR0Set);
1518 writel((CR0_FDXTFCEN | CR0_FDXRFCEN | CR0_HDXFCEN | CR0_XHITH0), ®s->CR0Clr);
1519
1520
1521 writew(0xFFFF, ®s->tx_pause_timer);
1522
1523
1524 writew(vptr->options.numrx, ®s->RBRDU);
1525 }
1526
1527
1528 #endif