1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25#ifndef VELOCITY_H
26#define VELOCITY_H
27
28#define VELOCITY_TX_CSUM_SUPPORT
29
30#define VELOCITY_NAME "via-velocity"
31#define VELOCITY_FULL_DRV_NAM "VIA Networking Velocity Family Gigabit Ethernet Adapter Driver"
32#define VELOCITY_VERSION "1.13"
33
34#define PKT_BUF_SZ 1540
35
36#define MAX_UNITS 8
37#define OPTION_DEFAULT { [0 ... MAX_UNITS-1] = -1}
38
39#define REV_ID_VT6110 (0)
40#define DEVICE_ID (0x3119)
41
42#define BYTE_REG_BITS_ON(x,p) do { writeb(readb((p))|(x),(p));} while (0)
43#define WORD_REG_BITS_ON(x,p) do { writew(readw((p))|(x),(p));} while (0)
44#define DWORD_REG_BITS_ON(x,p) do { writel(readl((p))|(x),(p));} while (0)
45
46#define BYTE_REG_BITS_IS_ON(x,p) (readb((p)) & (x))
47#define WORD_REG_BITS_IS_ON(x,p) (readw((p)) & (x))
48#define DWORD_REG_BITS_IS_ON(x,p) (readl((p)) & (x))
49
50#define BYTE_REG_BITS_OFF(x,p) do { writeb(readb((p)) & (~(x)),(p));} while (0)
51#define WORD_REG_BITS_OFF(x,p) do { writew(readw((p)) & (~(x)),(p));} while (0)
52#define DWORD_REG_BITS_OFF(x,p) do { writel(readl((p)) & (~(x)),(p));} while (0)
53
54#define BYTE_REG_BITS_SET(x,m,p) do { writeb( (readb((p)) & (~(m))) |(x),(p));} while (0)
55#define WORD_REG_BITS_SET(x,m,p) do { writew( (readw((p)) & (~(m))) |(x),(p));} while (0)
56#define DWORD_REG_BITS_SET(x,m,p) do { writel( (readl((p)) & (~(m)))|(x),(p));} while (0)
57
58#define VAR_USED(p) do {(p)=(p);} while (0)
59
60
61
62
63
64
65#define B_OWNED_BY_CHIP 1
66#define B_OWNED_BY_HOST 0
67
68
69
70
71
72#define RSR_DETAG 0x0080
73#define RSR_SNTAG 0x0040
74#define RSR_RXER 0x0020
75#define RSR_RL 0x0010
76#define RSR_CE 0x0008
77#define RSR_FAE 0x0004
78#define RSR_CRC 0x0002
79#define RSR_VIDM 0x0001
80
81
82
83
84
85#define RSR_RXOK 0x8000
86#define RSR_PFT 0x4000
87#define RSR_MAR 0x2000
88#define RSR_BAR 0x1000
89#define RSR_PHY 0x0800
90#define RSR_VTAG 0x0400
91#define RSR_STP 0x0200
92#define RSR_EDP 0x0100
93
94
95
96
97
98#define RSR1_RXOK 0x80
99#define RSR1_PFT 0x40
100#define RSR1_MAR 0x20
101#define RSR1_BAR 0x10
102#define RSR1_PHY 0x08
103#define RSR1_VTAG 0x04
104#define RSR1_STP 0x02
105#define RSR1_EDP 0x01
106
107
108
109
110
111#define CSM_IPOK 0x40
112#define CSM_TUPOK 0x20
113#define CSM_FRAG 0x10
114#define CSM_IPKT 0x04
115#define CSM_TCPKT 0x02
116#define CSM_UDPKT 0x01
117
118
119
120
121
122#define TSR0_ABT 0x0080
123#define TSR0_OWT 0x0040
124#define TSR0_OWC 0x0020
125#define TSR0_COLS 0x0010
126#define TSR0_NCR3 0x0008
127#define TSR0_NCR2 0x0004
128#define TSR0_NCR1 0x0002
129#define TSR0_NCR0 0x0001
130#define TSR0_TERR 0x8000
131#define TSR0_FDX 0x4000
132#define TSR0_GMII 0x2000
133#define TSR0_LNKFL 0x1000
134#define TSR0_SHDN 0x0400
135#define TSR0_CRS 0x0200
136#define TSR0_CDH 0x0100
137
138
139
140
141
142#define TSR1_TERR 0x80
143#define TSR1_FDX 0x40
144#define TSR1_GMII 0x20
145#define TSR1_LNKFL 0x10
146#define TSR1_SHDN 0x04
147#define TSR1_CRS 0x02
148#define TSR1_CDH 0x01
149
150
151
152
153#define TCR0_TIC 0x80
154#define TCR0_PIC 0x40
155#define TCR0_VETAG 0x20
156#define TCR0_IPCK 0x10
157#define TCR0_UDPCK 0x08
158#define TCR0_TCPCK 0x04
159#define TCR0_JMBO 0x02
160#define TCR0_CRC 0x01
161
162#define TCPLS_NORMAL 3
163#define TCPLS_START 2
164#define TCPLS_END 1
165#define TCPLS_MED 0
166
167
168
169#define CB_RX_BUF_SIZE 2048UL
170
171
172#define CB_MAX_RD_NUM 512
173#define CB_MAX_TD_NUM 256
174
175#define CB_INIT_RD_NUM_3119 128
176#define CB_INIT_TD_NUM_3119 64
177
178#define CB_INIT_RD_NUM 128
179#define CB_INIT_TD_NUM 64
180
181
182#define CB_TD_RING_NUM 4
183#define CB_MAX_SEG_PER_PKT 7
184
185
186
187
188
189
190
191
192#define CB_MAX_TX_ABORT_RETRY 3
193
194
195
196
197
198struct rdesc0 {
199 u16 RSR;
200 u16 len:14;
201 u16 reserved:1;
202 u16 owner:1;
203};
204
205struct rdesc1 {
206 u16 PQTAG;
207 u8 CSM;
208 u8 IPKT;
209};
210
211struct rx_desc {
212 struct rdesc0 rdesc0;
213 struct rdesc1 rdesc1;
214 u32 pa_low;
215 u16 pa_high;
216 u16 len:15;
217 u16 inten:1;
218} __attribute__ ((__packed__));
219
220
221
222
223
224struct tdesc0 {
225 u16 TSR;
226 u16 pktsize:14;
227 u16 reserved:1;
228 u16 owner:1;
229};
230
231struct pqinf {
232 u16 VID:12;
233 u16 CFI:1;
234 u16 priority:3;
235} __attribute__ ((__packed__));
236
237struct tdesc1 {
238 struct pqinf pqinf;
239 u8 TCR;
240 u8 TCPLS:2;
241 u8 reserved:2;
242 u8 CMDZ:4;
243} __attribute__ ((__packed__));
244
245struct td_buf {
246 u32 pa_low;
247 u16 pa_high;
248 u16 bufsize:14;
249 u16 reserved:1;
250 u16 queue:1;
251} __attribute__ ((__packed__));
252
253struct tx_desc {
254 struct tdesc0 tdesc0;
255 struct tdesc1 tdesc1;
256 struct td_buf td_buf[7];
257};
258
259struct velocity_rd_info {
260 struct sk_buff *skb;
261 dma_addr_t skb_dma;
262};
263
264
265
266
267
268
269
270
271
272static inline struct velocity_rd_info *alloc_rd_info(void)
273{
274 struct velocity_rd_info *ptr;
275 if ((ptr = kmalloc(sizeof(struct velocity_rd_info), GFP_ATOMIC)) == NULL)
276 return NULL;
277 else {
278 memset(ptr, 0, sizeof(struct velocity_rd_info));
279 return ptr;
280 }
281}
282
283
284
285
286
287struct velocity_td_info {
288 struct sk_buff *skb;
289 u8 *buf;
290 int nskb_dma;
291 dma_addr_t skb_dma[7];
292 dma_addr_t buf_dma;
293};
294
295enum {
296 OWNED_BY_HOST = 0,
297 OWNED_BY_NIC = 1
298} velocity_owner;
299
300
301
302
303
304
305
306#define MCAM_SIZE 64
307#define VCAM_SIZE 64
308#define TX_QUEUE_NO 4
309
310#define MAX_HW_MIB_COUNTER 32
311#define VELOCITY_MIN_MTU (1514-14)
312#define VELOCITY_MAX_MTU (9000)
313
314
315
316
317
318#define MAC_REG_PAR 0x00
319#define MAC_REG_RCR 0x06
320#define MAC_REG_TCR 0x07
321#define MAC_REG_CR0_SET 0x08
322#define MAC_REG_CR1_SET 0x09
323#define MAC_REG_CR2_SET 0x0A
324#define MAC_REG_CR3_SET 0x0B
325#define MAC_REG_CR0_CLR 0x0C
326#define MAC_REG_CR1_CLR 0x0D
327#define MAC_REG_CR2_CLR 0x0E
328#define MAC_REG_CR3_CLR 0x0F
329#define MAC_REG_MAR 0x10
330#define MAC_REG_CAM 0x10
331#define MAC_REG_DEC_BASE_HI 0x18
332#define MAC_REG_DBF_BASE_HI 0x1C
333#define MAC_REG_ISR_CTL 0x20
334#define MAC_REG_ISR_HOTMR 0x20
335#define MAC_REG_ISR_TSUPTHR 0x20
336#define MAC_REG_ISR_RSUPTHR 0x20
337#define MAC_REG_ISR_CTL1 0x21
338#define MAC_REG_TXE_SR 0x22
339#define MAC_REG_RXE_SR 0x23
340#define MAC_REG_ISR 0x24
341#define MAC_REG_ISR0 0x24
342#define MAC_REG_ISR1 0x25
343#define MAC_REG_ISR2 0x26
344#define MAC_REG_ISR3 0x27
345#define MAC_REG_IMR 0x28
346#define MAC_REG_IMR0 0x28
347#define MAC_REG_IMR1 0x29
348#define MAC_REG_IMR2 0x2A
349#define MAC_REG_IMR3 0x2B
350#define MAC_REG_TDCSR_SET 0x30
351#define MAC_REG_RDCSR_SET 0x32
352#define MAC_REG_TDCSR_CLR 0x34
353#define MAC_REG_RDCSR_CLR 0x36
354#define MAC_REG_RDBASE_LO 0x38
355#define MAC_REG_RDINDX 0x3C
356#define MAC_REG_TDBASE_LO 0x40
357#define MAC_REG_RDCSIZE 0x50
358#define MAC_REG_TDCSIZE 0x52
359#define MAC_REG_TDINDX 0x54
360#define MAC_REG_TDIDX0 0x54
361#define MAC_REG_TDIDX1 0x56
362#define MAC_REG_TDIDX2 0x58
363#define MAC_REG_TDIDX3 0x5A
364#define MAC_REG_PAUSE_TIMER 0x5C
365#define MAC_REG_RBRDU 0x5E
366#define MAC_REG_FIFO_TEST0 0x60
367#define MAC_REG_FIFO_TEST1 0x64
368#define MAC_REG_CAMADDR 0x68
369#define MAC_REG_CAMCR 0x69
370#define MAC_REG_GFTEST 0x6A
371#define MAC_REG_FTSTCMD 0x6B
372#define MAC_REG_MIICFG 0x6C
373#define MAC_REG_MIISR 0x6D
374#define MAC_REG_PHYSR0 0x6E
375#define MAC_REG_PHYSR1 0x6F
376#define MAC_REG_MIICR 0x70
377#define MAC_REG_MIIADR 0x71
378#define MAC_REG_MIIDATA 0x72
379#define MAC_REG_SOFT_TIMER0 0x74
380#define MAC_REG_SOFT_TIMER1 0x76
381#define MAC_REG_CFGA 0x78
382#define MAC_REG_CFGB 0x79
383#define MAC_REG_CFGC 0x7A
384#define MAC_REG_CFGD 0x7B
385#define MAC_REG_DCFG0 0x7C
386#define MAC_REG_DCFG1 0x7D
387#define MAC_REG_MCFG0 0x7E
388#define MAC_REG_MCFG1 0x7F
389
390#define MAC_REG_TBIST 0x80
391#define MAC_REG_RBIST 0x81
392#define MAC_REG_PMCC 0x82
393#define MAC_REG_STICKHW 0x83
394#define MAC_REG_MIBCR 0x84
395#define MAC_REG_EERSV 0x85
396#define MAC_REG_REVID 0x86
397#define MAC_REG_MIBREAD 0x88
398#define MAC_REG_BPMA 0x8C
399#define MAC_REG_EEWR_DATA 0x8C
400#define MAC_REG_BPMD_WR 0x8F
401#define MAC_REG_BPCMD 0x90
402#define MAC_REG_BPMD_RD 0x91
403#define MAC_REG_EECHKSUM 0x92
404#define MAC_REG_EECSR 0x93
405#define MAC_REG_EERD_DATA 0x94
406#define MAC_REG_EADDR 0x96
407#define MAC_REG_EMBCMD 0x97
408#define MAC_REG_JMPSR0 0x98
409#define MAC_REG_JMPSR1 0x99
410#define MAC_REG_JMPSR2 0x9A
411#define MAC_REG_JMPSR3 0x9B
412#define MAC_REG_CHIPGSR 0x9C
413#define MAC_REG_TESTCFG 0x9D
414#define MAC_REG_DEBUG 0x9E
415#define MAC_REG_CHIPGCR 0x9F
416#define MAC_REG_WOLCR0_SET 0xA0
417#define MAC_REG_WOLCR1_SET 0xA1
418#define MAC_REG_PWCFG_SET 0xA2
419#define MAC_REG_WOLCFG_SET 0xA3
420#define MAC_REG_WOLCR0_CLR 0xA4
421#define MAC_REG_WOLCR1_CLR 0xA5
422#define MAC_REG_PWCFG_CLR 0xA6
423#define MAC_REG_WOLCFG_CLR 0xA7
424#define MAC_REG_WOLSR0_SET 0xA8
425#define MAC_REG_WOLSR1_SET 0xA9
426#define MAC_REG_WOLSR0_CLR 0xAC
427#define MAC_REG_WOLSR1_CLR 0xAD
428#define MAC_REG_PATRN_CRC0 0xB0
429#define MAC_REG_PATRN_CRC1 0xB2
430#define MAC_REG_PATRN_CRC2 0xB4
431#define MAC_REG_PATRN_CRC3 0xB6
432#define MAC_REG_PATRN_CRC4 0xB8
433#define MAC_REG_PATRN_CRC5 0xBA
434#define MAC_REG_PATRN_CRC6 0xBC
435#define MAC_REG_PATRN_CRC7 0xBE
436#define MAC_REG_BYTEMSK0_0 0xC0
437#define MAC_REG_BYTEMSK0_1 0xC4
438#define MAC_REG_BYTEMSK0_2 0xC8
439#define MAC_REG_BYTEMSK0_3 0xCC
440#define MAC_REG_BYTEMSK1_0 0xD0
441#define MAC_REG_BYTEMSK1_1 0xD4
442#define MAC_REG_BYTEMSK1_2 0xD8
443#define MAC_REG_BYTEMSK1_3 0xDC
444#define MAC_REG_BYTEMSK2_0 0xE0
445#define MAC_REG_BYTEMSK2_1 0xE4
446#define MAC_REG_BYTEMSK2_2 0xE8
447#define MAC_REG_BYTEMSK2_3 0xEC
448#define MAC_REG_BYTEMSK3_0 0xF0
449#define MAC_REG_BYTEMSK3_1 0xF4
450#define MAC_REG_BYTEMSK3_2 0xF8
451#define MAC_REG_BYTEMSK3_3 0xFC
452
453
454
455
456
457#define RCR_AS 0x80
458#define RCR_AP 0x40
459#define RCR_AL 0x20
460#define RCR_PROM 0x10
461#define RCR_AB 0x08
462#define RCR_AM 0x04
463#define RCR_AR 0x02
464#define RCR_SEP 0x01
465
466
467
468
469
470#define TCR_TB2BDIS 0x80
471#define TCR_COLTMC1 0x08
472#define TCR_COLTMC0 0x04
473#define TCR_LB1 0x02
474#define TCR_LB0 0x01
475
476
477
478
479
480#define CR0_TXON 0x00000008UL
481#define CR0_RXON 0x00000004UL
482#define CR0_STOP 0x00000002UL
483#define CR0_STRT 0x00000001UL
484#define CR0_SFRST 0x00008000UL
485#define CR0_TM1EN 0x00004000UL
486#define CR0_TM0EN 0x00002000UL
487#define CR0_DPOLL 0x00000800UL
488#define CR0_DISAU 0x00000100UL
489#define CR0_XONEN 0x00800000UL
490#define CR0_FDXTFCEN 0x00400000UL
491#define CR0_FDXRFCEN 0x00200000UL
492#define CR0_HDXFCEN 0x00100000UL
493#define CR0_XHITH1 0x00080000UL
494#define CR0_XHITH0 0x00040000UL
495#define CR0_XLTH1 0x00020000UL
496#define CR0_XLTH0 0x00010000UL
497#define CR0_GSPRST 0x80000000UL
498#define CR0_FORSRST 0x40000000UL
499#define CR0_FPHYRST 0x20000000UL
500#define CR0_DIAG 0x10000000UL
501#define CR0_INTPCTL 0x04000000UL
502#define CR0_GINTMSK1 0x02000000UL
503#define CR0_GINTMSK0 0x01000000UL
504
505
506
507
508
509#define CR1_SFRST 0x80
510#define CR1_TM1EN 0x40
511#define CR1_TM0EN 0x20
512#define CR1_DPOLL 0x08
513#define CR1_DISAU 0x01
514
515
516
517
518
519#define CR2_XONEN 0x80
520#define CR2_FDXTFCEN 0x40
521#define CR2_FDXRFCEN 0x20
522#define CR2_HDXFCEN 0x10
523#define CR2_XHITH1 0x08
524#define CR2_XHITH0 0x04
525#define CR2_XLTH1 0x02
526#define CR2_XLTH0 0x01
527
528
529
530
531
532#define CR3_GSPRST 0x80
533#define CR3_FORSRST 0x40
534#define CR3_FPHYRST 0x20
535#define CR3_DIAG 0x10
536#define CR3_INTPCTL 0x04
537#define CR3_GINTMSK1 0x02
538#define CR3_GINTMSK0 0x01
539
540#define ISRCTL_UDPINT 0x8000
541#define ISRCTL_TSUPDIS 0x4000
542#define ISRCTL_RSUPDIS 0x2000
543#define ISRCTL_PMSK1 0x1000
544#define ISRCTL_PMSK0 0x0800
545#define ISRCTL_INTPD 0x0400
546#define ISRCTL_HCRLD 0x0200
547#define ISRCTL_SCRLD 0x0100
548
549
550
551
552
553#define ISRCTL1_UDPINT 0x80
554#define ISRCTL1_TSUPDIS 0x40
555#define ISRCTL1_RSUPDIS 0x20
556#define ISRCTL1_PMSK1 0x10
557#define ISRCTL1_PMSK0 0x08
558#define ISRCTL1_INTPD 0x04
559#define ISRCTL1_HCRLD 0x02
560#define ISRCTL1_SCRLD 0x01
561
562
563
564
565
566#define TXESR_TFDBS 0x08
567#define TXESR_TDWBS 0x04
568#define TXESR_TDRBS 0x02
569#define TXESR_TDSTR 0x01
570
571
572
573
574
575#define RXESR_RFDBS 0x08
576#define RXESR_RDWBS 0x04
577#define RXESR_RDRBS 0x02
578#define RXESR_RDSTR 0x01
579
580
581
582
583
584#define ISR_ISR3 0x80000000UL
585#define ISR_ISR2 0x40000000UL
586#define ISR_ISR1 0x20000000UL
587#define ISR_ISR0 0x10000000UL
588#define ISR_TXSTLI 0x02000000UL
589#define ISR_RXSTLI 0x01000000UL
590#define ISR_HFLD 0x00800000UL
591#define ISR_UDPI 0x00400000UL
592#define ISR_MIBFI 0x00200000UL
593#define ISR_SHDNI 0x00100000UL
594#define ISR_PHYI 0x00080000UL
595#define ISR_PWEI 0x00040000UL
596#define ISR_TMR1I 0x00020000UL
597#define ISR_TMR0I 0x00010000UL
598#define ISR_SRCI 0x00008000UL
599#define ISR_LSTPEI 0x00004000UL
600#define ISR_LSTEI 0x00002000UL
601#define ISR_OVFI 0x00001000UL
602#define ISR_FLONI 0x00000800UL
603#define ISR_RACEI 0x00000400UL
604#define ISR_TXWB1I 0x00000200UL
605#define ISR_TXWB0I 0x00000100UL
606#define ISR_PTX3I 0x00000080UL
607#define ISR_PTX2I 0x00000040UL
608#define ISR_PTX1I 0x00000020UL
609#define ISR_PTX0I 0x00000010UL
610#define ISR_PTXI 0x00000008UL
611#define ISR_PRXI 0x00000004UL
612#define ISR_PPTXI 0x00000002UL
613#define ISR_PPRXI 0x00000001UL
614
615
616
617
618
619#define IMR_TXSTLM 0x02000000UL
620#define IMR_UDPIM 0x00400000UL
621#define IMR_MIBFIM 0x00200000UL
622#define IMR_SHDNIM 0x00100000UL
623#define IMR_PHYIM 0x00080000UL
624#define IMR_PWEIM 0x00040000UL
625#define IMR_TMR1IM 0x00020000UL
626#define IMR_TMR0IM 0x00010000UL
627
628#define IMR_SRCIM 0x00008000UL
629#define IMR_LSTPEIM 0x00004000UL
630#define IMR_LSTEIM 0x00002000UL
631#define IMR_OVFIM 0x00001000UL
632#define IMR_FLONIM 0x00000800UL
633#define IMR_RACEIM 0x00000400UL
634#define IMR_TXWB1IM 0x00000200UL
635#define IMR_TXWB0IM 0x00000100UL
636
637#define IMR_PTX3IM 0x00000080UL
638#define IMR_PTX2IM 0x00000040UL
639#define IMR_PTX1IM 0x00000020UL
640#define IMR_PTX0IM 0x00000010UL
641#define IMR_PTXIM 0x00000008UL
642#define IMR_PRXIM 0x00000004UL
643#define IMR_PPTXIM 0x00000002UL
644#define IMR_PPRXIM 0x00000001UL
645
646
647
648#define INT_MASK_DEF (IMR_PPTXIM|IMR_PPRXIM|IMR_PTXIM|IMR_PRXIM|\
649 IMR_PWEIM|IMR_TXWB0IM|IMR_TXWB1IM|IMR_FLONIM|\
650 IMR_OVFIM|IMR_LSTEIM|IMR_LSTPEIM|IMR_SRCIM|IMR_MIBFIM|\
651 IMR_SHDNIM|IMR_TMR1IM|IMR_TMR0IM|IMR_TXSTLM)
652
653
654
655
656
657#define TRDCSR_DEAD 0x0008
658#define TRDCSR_WAK 0x0004
659#define TRDCSR_ACT 0x0002
660#define TRDCSR_RUN 0x0001
661
662
663
664
665
666#define CAMADDR_CAMEN 0x80
667#define CAMADDR_VCAMSL 0x40
668
669
670
671
672
673#define CAMCR_PS1 0x80
674#define CAMCR_PS0 0x40
675#define CAMCR_AITRPKT 0x20
676#define CAMCR_AITR16 0x10
677#define CAMCR_CAMRD 0x08
678#define CAMCR_CAMWR 0x04
679#define CAMCR_PS_CAM_MASK 0x40
680#define CAMCR_PS_CAM_DATA 0x80
681#define CAMCR_PS_MAR 0x00
682
683
684
685
686
687#define MIICFG_MPO1 0x80
688#define MIICFG_MPO0 0x40
689#define MIICFG_MFDC 0x20
690
691
692
693
694
695#define MIISR_MIDLE 0x80
696
697
698
699
700
701#define PHYSR0_PHYRST 0x80
702#define PHYSR0_LINKGD 0x40
703#define PHYSR0_FDPX 0x10
704#define PHYSR0_SPDG 0x08
705#define PHYSR0_SPD10 0x04
706#define PHYSR0_RXFLC 0x02
707#define PHYSR0_TXFLC 0x01
708
709
710
711
712
713#define PHYSR1_PHYTBI 0x01
714
715
716
717
718
719#define MIICR_MAUTO 0x80
720#define MIICR_RCMD 0x40
721#define MIICR_WCMD 0x20
722#define MIICR_MDPM 0x10
723#define MIICR_MOUT 0x08
724#define MIICR_MDO 0x04
725#define MIICR_MDI 0x02
726#define MIICR_MDC 0x01
727
728
729
730
731
732#define MIIADR_SWMPL 0x80
733
734
735
736
737
738#define CFGA_PMHCTG 0x08
739#define CFGA_GPIO1PD 0x04
740#define CFGA_ABSHDN 0x02
741#define CFGA_PACPI 0x01
742
743
744
745
746
747#define CFGB_GTCKOPT 0x80
748#define CFGB_MIIOPT 0x40
749#define CFGB_CRSEOPT 0x20
750#define CFGB_OFSET 0x10
751#define CFGB_CRANDOM 0x08
752#define CFGB_CAP 0x04
753#define CFGB_MBA 0x02
754#define CFGB_BAKOPT 0x01
755
756
757
758
759
760#define CFGC_EELOAD 0x80
761#define CFGC_BROPT 0x40
762#define CFGC_DLYEN 0x20
763#define CFGC_DTSEL 0x10
764#define CFGC_BTSEL 0x08
765#define CFGC_BPS2 0x04
766#define CFGC_BPS1 0x02
767#define CFGC_BPS0 0x01
768
769
770
771
772
773#define CFGD_IODIS 0x80
774#define CFGD_MSLVDACEN 0x40
775#define CFGD_CFGDACEN 0x20
776#define CFGD_PCI64EN 0x10
777#define CFGD_HTMRL4 0x08
778
779
780
781
782
783#define DCFG_XMWI 0x8000
784#define DCFG_XMRM 0x4000
785#define DCFG_XMRL 0x2000
786#define DCFG_PERDIS 0x1000
787#define DCFG_MRWAIT 0x0400
788#define DCFG_MWWAIT 0x0200
789#define DCFG_LATMEN 0x0100
790
791
792
793
794
795#define MCFG_RXARB 0x0080
796#define MCFG_RFT1 0x0020
797#define MCFG_RFT0 0x0010
798#define MCFG_LOWTHOPT 0x0008
799#define MCFG_PQEN 0x0004
800#define MCFG_RTGOPT 0x0002
801#define MCFG_VIDFR 0x0001
802
803
804
805
806
807#define MCFG_TXARB 0x8000
808#define MCFG_TXQBK1 0x0800
809#define MCFG_TXQBK0 0x0400
810#define MCFG_TXQNOBK 0x0200
811#define MCFG_SNAPOPT 0x0100
812
813
814
815
816
817#define PMCC_DSI 0x80
818#define PMCC_D2_DIS 0x40
819#define PMCC_D1_DIS 0x20
820#define PMCC_D3C_EN 0x10
821#define PMCC_D3H_EN 0x08
822#define PMCC_D2_EN 0x04
823#define PMCC_D1_EN 0x02
824#define PMCC_D0_EN 0x01
825
826
827
828
829
830#define STICKHW_SWPTAG 0x10
831#define STICKHW_WOLSR 0x08
832#define STICKHW_WOLEN 0x04
833#define STICKHW_DS1 0x02
834#define STICKHW_DS0 0x01
835
836
837
838
839
840#define MIBCR_MIBISTOK 0x80
841#define MIBCR_MIBISTGO 0x40
842#define MIBCR_MIBINC 0x20
843#define MIBCR_MIBHI 0x10
844#define MIBCR_MIBFRZ 0x08
845#define MIBCR_MIBFLSH 0x04
846#define MIBCR_MPTRINI 0x02
847#define MIBCR_MIBCLR 0x01
848
849
850
851
852
853#define EERSV_BOOT_RPL ((u8) 0x01)
854
855#define EERSV_BOOT_MASK ((u8) 0x06)
856#define EERSV_BOOT_INT19 ((u8) 0x00)
857#define EERSV_BOOT_INT18 ((u8) 0x02)
858#define EERSV_BOOT_LOCAL ((u8) 0x04)
859#define EERSV_BOOT_BEV ((u8) 0x06)
860
861
862
863
864
865
866#define BPCMD_BPDNE 0x80
867#define BPCMD_EBPWR 0x02
868#define BPCMD_EBPRD 0x01
869
870
871
872
873
874#define EECSR_EMBP 0x40
875#define EECSR_RELOAD 0x20
876#define EECSR_DPM 0x10
877#define EECSR_ECS 0x08
878#define EECSR_ECK 0x04
879#define EECSR_EDI 0x02
880#define EECSR_EDO 0x01
881
882
883
884
885
886#define EMBCMD_EDONE 0x80
887#define EMBCMD_EWDIS 0x08
888#define EMBCMD_EWEN 0x04
889#define EMBCMD_EWR 0x02
890#define EMBCMD_ERD 0x01
891
892
893
894
895
896#define TESTCFG_HBDIS 0x80
897
898
899
900
901
902#define CHIPGCR_FCGMII 0x80
903#define CHIPGCR_FCFDX 0x40
904#define CHIPGCR_FCRESV 0x20
905#define CHIPGCR_FCMODE 0x10
906#define CHIPGCR_LPSOPT 0x08
907#define CHIPGCR_TM1US 0x04
908#define CHIPGCR_TM0US 0x02
909#define CHIPGCR_PHYINTEN 0x01
910
911
912
913
914
915#define WOLCR_MSWOLEN7 0x0080
916#define WOLCR_MSWOLEN6 0x0040
917#define WOLCR_MSWOLEN5 0x0020
918#define WOLCR_MSWOLEN4 0x0010
919#define WOLCR_MSWOLEN3 0x0008
920#define WOLCR_MSWOLEN2 0x0004
921#define WOLCR_MSWOLEN1 0x0002
922#define WOLCR_MSWOLEN0 0x0001
923#define WOLCR_ARP_EN 0x0001
924
925
926
927
928
929#define WOLCR_LINKOFF_EN 0x0800
930#define WOLCR_LINKON_EN 0x0400
931#define WOLCR_MAGIC_EN 0x0200
932#define WOLCR_UNICAST_EN 0x0100
933
934
935
936
937
938
939#define PWCFG_PHYPWOPT 0x80
940#define PWCFG_PCISTICK 0x40
941#define PWCFG_WOLTYPE 0x20
942#define PWCFG_LEGCY_WOL 0x10
943#define PWCFG_PMCSR_PME_SR 0x08
944#define PWCFG_PMCSR_PME_EN 0x04
945#define PWCFG_LEGACY_WOLSR 0x02
946#define PWCFG_LEGACY_WOLEN 0x01
947
948
949
950
951
952#define WOLCFG_PMEOVR 0x80
953#define WOLCFG_SAM 0x20
954#define WOLCFG_SAB 0x10
955#define WOLCFG_SMIIACC 0x08
956#define WOLCFG_SGENWH 0x02
957#define WOLCFG_PHYINTEN 0x01
958
959
960
961
962
963#define WOLSR_LINKOFF_INT 0x0800
964#define WOLSR_LINKON_INT 0x0400
965#define WOLSR_MAGIC_INT 0x0200
966#define WOLSR_UNICAST_INT 0x0100
967
968
969
970
971
972#define PKT_TYPE_NONE 0x0000
973#define PKT_TYPE_DIRECTED 0x0001
974#define PKT_TYPE_MULTICAST 0x0002
975#define PKT_TYPE_ALL_MULTICAST 0x0004
976#define PKT_TYPE_BROADCAST 0x0008
977#define PKT_TYPE_PROMISCUOUS 0x0020
978#define PKT_TYPE_LONG 0x2000
979#define PKT_TYPE_RUNT 0x4000
980#define PKT_TYPE_ERROR 0x8000
981
982
983
984
985
986#define MAC_LB_NONE 0x00
987#define MAC_LB_INTERNAL 0x01
988#define MAC_LB_EXTERNAL 0x02
989
990
991
992
993
994#if defined(_SIM)
995#define IMR_MASK_VALUE 0x0033FF0FUL
996
997
998#else
999#define IMR_MASK_VALUE 0x0013FB0FUL
1000
1001
1002
1003
1004
1005
1006#endif
1007
1008
1009
1010
1011
1012#define REV_ID_VT3119_A0 0x00
1013#define REV_ID_VT3119_A1 0x01
1014#define REV_ID_VT3216_A0 0x10
1015
1016
1017
1018
1019
1020#define W_MAX_TIMEOUT 0x0FFFU
1021
1022
1023
1024
1025
1026
1027
1028struct mac_regs {
1029 volatile u8 PAR[6];
1030 volatile u8 RCR;
1031 volatile u8 TCR;
1032
1033 volatile u32 CR0Set;
1034 volatile u32 CR0Clr;
1035
1036 volatile u8 MARCAM[8];
1037
1038 volatile u32 DecBaseHi;
1039 volatile u16 DbfBaseHi;
1040 volatile u16 reserved_1E;
1041
1042 volatile u16 ISRCTL;
1043 volatile u8 TXESR;
1044 volatile u8 RXESR;
1045
1046 volatile u32 ISR;
1047 volatile u32 IMR;
1048
1049 volatile u32 TDStatusPort;
1050
1051 volatile u16 TDCSRSet;
1052 volatile u8 RDCSRSet;
1053 volatile u8 reserved_33;
1054 volatile u16 TDCSRClr;
1055 volatile u8 RDCSRClr;
1056 volatile u8 reserved_37;
1057
1058 volatile u32 RDBaseLo;
1059 volatile u16 RDIdx;
1060 volatile u16 reserved_3E;
1061
1062 volatile u32 TDBaseLo[4];
1063
1064 volatile u16 RDCSize;
1065 volatile u16 TDCSize;
1066 volatile u16 TDIdx[4];
1067 volatile u16 tx_pause_timer;
1068 volatile u16 RBRDU;
1069
1070 volatile u32 FIFOTest0;
1071 volatile u32 FIFOTest1;
1072
1073 volatile u8 CAMADDR;
1074 volatile u8 CAMCR;
1075 volatile u8 GFTEST;
1076 volatile u8 FTSTCMD;
1077
1078 volatile u8 MIICFG;
1079 volatile u8 MIISR;
1080 volatile u8 PHYSR0;
1081 volatile u8 PHYSR1;
1082 volatile u8 MIICR;
1083 volatile u8 MIIADR;
1084 volatile u16 MIIDATA;
1085
1086 volatile u16 SoftTimer0;
1087 volatile u16 SoftTimer1;
1088
1089 volatile u8 CFGA;
1090 volatile u8 CFGB;
1091 volatile u8 CFGC;
1092 volatile u8 CFGD;
1093
1094 volatile u16 DCFG;
1095 volatile u16 MCFG;
1096
1097 volatile u8 TBIST;
1098 volatile u8 RBIST;
1099 volatile u8 PMCPORT;
1100 volatile u8 STICKHW;
1101
1102 volatile u8 MIBCR;
1103 volatile u8 reserved_85;
1104 volatile u8 rev_id;
1105 volatile u8 PORSTS;
1106
1107 volatile u32 MIBData;
1108
1109 volatile u16 EEWrData;
1110
1111 volatile u8 reserved_8E;
1112 volatile u8 BPMDWr;
1113 volatile u8 BPCMD;
1114 volatile u8 BPMDRd;
1115
1116 volatile u8 EECHKSUM;
1117 volatile u8 EECSR;
1118
1119 volatile u16 EERdData;
1120 volatile u8 EADDR;
1121 volatile u8 EMBCMD;
1122
1123
1124 volatile u8 JMPSR0;
1125 volatile u8 JMPSR1;
1126 volatile u8 JMPSR2;
1127 volatile u8 JMPSR3;
1128 volatile u8 CHIPGSR;
1129 volatile u8 TESTCFG;
1130 volatile u8 DEBUG;
1131 volatile u8 CHIPGCR;
1132
1133 volatile u16 WOLCRSet;
1134 volatile u8 PWCFGSet;
1135 volatile u8 WOLCFGSet;
1136
1137 volatile u16 WOLCRClr;
1138 volatile u8 PWCFGCLR;
1139 volatile u8 WOLCFGClr;
1140
1141 volatile u16 WOLSRSet;
1142 volatile u16 reserved_AA;
1143
1144 volatile u16 WOLSRClr;
1145 volatile u16 reserved_AE;
1146
1147 volatile u16 PatternCRC[8];
1148 volatile u32 ByteMask[4][4];
1149} __attribute__ ((__packed__));
1150
1151
1152enum hw_mib {
1153 HW_MIB_ifRxAllPkts = 0,
1154 HW_MIB_ifRxOkPkts,
1155 HW_MIB_ifTxOkPkts,
1156 HW_MIB_ifRxErrorPkts,
1157 HW_MIB_ifRxRuntOkPkt,
1158 HW_MIB_ifRxRuntErrPkt,
1159 HW_MIB_ifRx64Pkts,
1160 HW_MIB_ifTx64Pkts,
1161 HW_MIB_ifRx65To127Pkts,
1162 HW_MIB_ifTx65To127Pkts,
1163 HW_MIB_ifRx128To255Pkts,
1164 HW_MIB_ifTx128To255Pkts,
1165 HW_MIB_ifRx256To511Pkts,
1166 HW_MIB_ifTx256To511Pkts,
1167 HW_MIB_ifRx512To1023Pkts,
1168 HW_MIB_ifTx512To1023Pkts,
1169 HW_MIB_ifRx1024To1518Pkts,
1170 HW_MIB_ifTx1024To1518Pkts,
1171 HW_MIB_ifTxEtherCollisions,
1172 HW_MIB_ifRxPktCRCE,
1173 HW_MIB_ifRxJumboPkts,
1174 HW_MIB_ifTxJumboPkts,
1175 HW_MIB_ifRxMacControlFrames,
1176 HW_MIB_ifTxMacControlFrames,
1177 HW_MIB_ifRxPktFAE,
1178 HW_MIB_ifRxLongOkPkt,
1179 HW_MIB_ifRxLongPktErrPkt,
1180 HW_MIB_ifTXSQEErrors,
1181 HW_MIB_ifRxNobuf,
1182 HW_MIB_ifRxSymbolErrors,
1183 HW_MIB_ifInRangeLengthErrors,
1184 HW_MIB_ifLateCollisions,
1185 HW_MIB_SIZE
1186};
1187
1188enum chip_type {
1189 CHIP_TYPE_VT6110 = 1,
1190};
1191
1192struct velocity_info_tbl {
1193 enum chip_type chip_id;
1194 char *name;
1195 int io_size;
1196 int txqueue;
1197 u32 flags;
1198};
1199
1200#define mac_hw_mibs_init(regs) {\
1201 BYTE_REG_BITS_ON(MIBCR_MIBFRZ,&((regs)->MIBCR));\
1202 BYTE_REG_BITS_ON(MIBCR_MIBCLR,&((regs)->MIBCR));\
1203 do {}\
1204 while (BYTE_REG_BITS_IS_ON(MIBCR_MIBCLR,&((regs)->MIBCR)));\
1205 BYTE_REG_BITS_OFF(MIBCR_MIBFRZ,&((regs)->MIBCR));\
1206}
1207
1208#define mac_read_isr(regs) readl(&((regs)->ISR))
1209#define mac_write_isr(regs, x) writel((x),&((regs)->ISR))
1210#define mac_clear_isr(regs) writel(0xffffffffL,&((regs)->ISR))
1211
1212#define mac_write_int_mask(mask, regs) writel((mask),&((regs)->IMR));
1213#define mac_disable_int(regs) writel(CR0_GINTMSK1,&((regs)->CR0Clr))
1214#define mac_enable_int(regs) writel(CR0_GINTMSK1,&((regs)->CR0Set))
1215
1216#define mac_hw_mibs_read(regs, MIBs) {\
1217 int i;\
1218 BYTE_REG_BITS_ON(MIBCR_MPTRINI,&((regs)->MIBCR));\
1219 for (i=0;i<HW_MIB_SIZE;i++) {\
1220 (MIBs)[i]=readl(&((regs)->MIBData));\
1221 }\
1222}
1223
1224#define mac_set_dma_length(regs, n) {\
1225 BYTE_REG_BITS_SET((n),0x07,&((regs)->DCFG));\
1226}
1227
1228#define mac_set_rx_thresh(regs, n) {\
1229 BYTE_REG_BITS_SET((n),(MCFG_RFT0|MCFG_RFT1),&((regs)->MCFG));\
1230}
1231
1232#define mac_rx_queue_run(regs) {\
1233 writeb(TRDCSR_RUN, &((regs)->RDCSRSet));\
1234}
1235
1236#define mac_rx_queue_wake(regs) {\
1237 writeb(TRDCSR_WAK, &((regs)->RDCSRSet));\
1238}
1239
1240#define mac_tx_queue_run(regs, n) {\
1241 writew(TRDCSR_RUN<<((n)*4),&((regs)->TDCSRSet));\
1242}
1243
1244#define mac_tx_queue_wake(regs, n) {\
1245 writew(TRDCSR_WAK<<(n*4),&((regs)->TDCSRSet));\
1246}
1247
1248#define mac_eeprom_reload(regs) {\
1249 int i=0;\
1250 BYTE_REG_BITS_ON(EECSR_RELOAD,&((regs)->EECSR));\
1251 do {\
1252 udelay(10);\
1253 if (i++>0x1000) {\
1254 break;\
1255 }\
1256 }while (BYTE_REG_BITS_IS_ON(EECSR_RELOAD,&((regs)->EECSR)));\
1257}
1258
1259enum velocity_cam_type {
1260 VELOCITY_VLAN_ID_CAM = 0,
1261 VELOCITY_MULTICAST_CAM
1262};
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274static inline void mac_get_cam_mask(struct mac_regs * regs, u8 * mask, enum velocity_cam_type cam_type)
1275{
1276 int i;
1277
1278 BYTE_REG_BITS_SET(CAMCR_PS_CAM_MASK, CAMCR_PS1 | CAMCR_PS0, ®s->CAMCR);
1279
1280 if (cam_type == VELOCITY_VLAN_ID_CAM)
1281 writeb(CAMADDR_VCAMSL, ®s->CAMADDR);
1282 else
1283 writeb(0, ®s->CAMADDR);
1284
1285
1286 for (i = 0; i < 8; i++)
1287 *mask++ = readb(&(regs->MARCAM[i]));
1288
1289
1290 writeb(0, ®s->CAMADDR);
1291
1292
1293 BYTE_REG_BITS_SET(CAMCR_PS_MAR, CAMCR_PS1 | CAMCR_PS0, ®s->CAMCR);
1294
1295}
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306static inline void mac_set_cam_mask(struct mac_regs * regs, u8 * mask, enum velocity_cam_type cam_type)
1307{
1308 int i;
1309
1310 BYTE_REG_BITS_SET(CAMCR_PS_CAM_MASK, CAMCR_PS1 | CAMCR_PS0, ®s->CAMCR);
1311
1312 if (cam_type == VELOCITY_VLAN_ID_CAM)
1313 writeb(CAMADDR_CAMEN | CAMADDR_VCAMSL, ®s->CAMADDR);
1314 else
1315 writeb(CAMADDR_CAMEN, ®s->CAMADDR);
1316
1317 for (i = 0; i < 8; i++) {
1318 writeb(*mask++, &(regs->MARCAM[i]));
1319 }
1320
1321 writeb(0, ®s->CAMADDR);
1322
1323
1324 BYTE_REG_BITS_SET(CAMCR_PS_MAR, CAMCR_PS1 | CAMCR_PS0, ®s->CAMCR);
1325}
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337static inline void mac_set_cam(struct mac_regs * regs, int idx, u8 *addr, enum velocity_cam_type cam_type)
1338{
1339 int i;
1340
1341
1342 BYTE_REG_BITS_SET(CAMCR_PS_CAM_DATA, CAMCR_PS1 | CAMCR_PS0, ®s->CAMCR);
1343
1344 idx &= (64 - 1);
1345
1346 if (cam_type == VELOCITY_VLAN_ID_CAM)
1347 writeb(CAMADDR_CAMEN | CAMADDR_VCAMSL | idx, ®s->CAMADDR);
1348 else
1349 writeb(CAMADDR_CAMEN | idx, ®s->CAMADDR);
1350
1351 if (cam_type == VELOCITY_VLAN_ID_CAM)
1352 writew(*((u16 *) addr), ®s->MARCAM[0]);
1353 else {
1354 for (i = 0; i < 6; i++) {
1355 writeb(*addr++, &(regs->MARCAM[i]));
1356 }
1357 }
1358 BYTE_REG_BITS_ON(CAMCR_CAMWR, ®s->CAMCR);
1359
1360 udelay(10);
1361
1362 writeb(0, ®s->CAMADDR);
1363
1364
1365 BYTE_REG_BITS_SET(CAMCR_PS_MAR, CAMCR_PS1 | CAMCR_PS0, ®s->CAMCR);
1366}
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379static inline void mac_get_cam(struct mac_regs * regs, int idx, u8 *addr, enum velocity_cam_type cam_type)
1380{
1381 int i;
1382
1383
1384 BYTE_REG_BITS_SET(CAMCR_PS_CAM_DATA, CAMCR_PS1 | CAMCR_PS0, ®s->CAMCR);
1385
1386 idx &= (64 - 1);
1387
1388 if (cam_type == VELOCITY_VLAN_ID_CAM)
1389 writeb(CAMADDR_CAMEN | CAMADDR_VCAMSL | idx, ®s->CAMADDR);
1390 else
1391 writeb(CAMADDR_CAMEN | idx, ®s->CAMADDR);
1392
1393 BYTE_REG_BITS_ON(CAMCR_CAMRD, ®s->CAMCR);
1394
1395 udelay(10);
1396
1397 if (cam_type == VELOCITY_VLAN_ID_CAM)
1398 *((u16 *) addr) = readw(&(regs->MARCAM[0]));
1399 else
1400 for (i = 0; i < 6; i++, addr++)
1401 *((u8 *) addr) = readb(&(regs->MARCAM[i]));
1402
1403 writeb(0, ®s->CAMADDR);
1404
1405
1406 BYTE_REG_BITS_SET(CAMCR_PS_MAR, CAMCR_PS1 | CAMCR_PS0, ®s->CAMCR);
1407}
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418inline static void mac_wol_reset(struct mac_regs * regs)
1419{
1420
1421
1422 BYTE_REG_BITS_OFF(STICKHW_SWPTAG, ®s->STICKHW);
1423
1424 BYTE_REG_BITS_OFF((STICKHW_DS1 | STICKHW_DS0), ®s->STICKHW);
1425
1426 BYTE_REG_BITS_OFF(CHIPGCR_FCGMII, ®s->CHIPGCR);
1427 BYTE_REG_BITS_OFF(CHIPGCR_FCMODE, ®s->CHIPGCR);
1428
1429 writeb(WOLCFG_PMEOVR, ®s->WOLCFGClr);
1430
1431 writew(0xFFFF, ®s->WOLCRClr);
1432
1433 writew(0xFFFF, ®s->WOLSRClr);
1434}
1435
1436
1437
1438
1439
1440
1441typedef u8 MCAM_ADDR[ETH_ALEN];
1442
1443struct arp_packet {
1444 u8 dest_mac[ETH_ALEN];
1445 u8 src_mac[ETH_ALEN];
1446 u16 type;
1447 u16 ar_hrd;
1448 u16 ar_pro;
1449 u8 ar_hln;
1450 u8 ar_pln;
1451 u16 ar_op;
1452 u8 ar_sha[ETH_ALEN];
1453 u8 ar_sip[4];
1454 u8 ar_tha[ETH_ALEN];
1455 u8 ar_tip[4];
1456} __attribute__ ((__packed__));
1457
1458struct _magic_packet {
1459 u8 dest_mac[6];
1460 u8 src_mac[6];
1461 u16 type;
1462 u8 MAC[16][6];
1463 u8 password[6];
1464} __attribute__ ((__packed__));
1465
1466
1467
1468
1469
1470
1471struct velocity_context {
1472 u8 mac_reg[256];
1473 MCAM_ADDR cam_addr[MCAM_SIZE];
1474 u16 vcam[VCAM_SIZE];
1475 u32 cammask[2];
1476 u32 patcrc[2];
1477 u32 pattern[8];
1478};
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490#define MII_REG_BMCR 0x00
1491#define MII_REG_BMSR 0x01
1492#define MII_REG_PHYID1 0x02
1493#define MII_REG_PHYID2 0x03
1494#define MII_REG_ANAR 0x04
1495#define MII_REG_ANLPAR 0x05
1496#define MII_REG_G1000CR 0x09
1497#define MII_REG_G1000SR 0x0A
1498#define MII_REG_MODCFG 0x10
1499#define MII_REG_TCSR 0x16
1500#define MII_REG_PLED 0x1B
1501
1502#define MII_REG_PCR 0x17
1503
1504#define MII_REG_PCSR 0x17
1505#define MII_REG_AUXCR 0x1C
1506
1507
1508#define MII_REG_PSCR 0x10
1509
1510
1511
1512
1513#define BMCR_RESET 0x8000
1514#define BMCR_LBK 0x4000
1515#define BMCR_SPEED100 0x2000
1516#define BMCR_AUTO 0x1000
1517#define BMCR_PD 0x0800
1518#define BMCR_ISO 0x0400
1519#define BMCR_REAUTO 0x0200
1520#define BMCR_FDX 0x0100
1521#define BMCR_SPEED1G 0x0040
1522
1523
1524
1525#define BMSR_AUTOCM 0x0020
1526#define BMSR_LNK 0x0004
1527
1528
1529
1530
1531#define ANAR_ASMDIR 0x0800
1532#define ANAR_PAUSE 0x0400
1533#define ANAR_T4 0x0200
1534#define ANAR_TXFD 0x0100
1535#define ANAR_TX 0x0080
1536#define ANAR_10FD 0x0040
1537#define ANAR_10 0x0020
1538
1539
1540
1541#define ANLPAR_ASMDIR 0x0800
1542#define ANLPAR_PAUSE 0x0400
1543#define ANLPAR_T4 0x0200
1544#define ANLPAR_TXFD 0x0100
1545#define ANLPAR_TX 0x0080
1546#define ANLPAR_10FD 0x0040
1547#define ANLPAR_10 0x0020
1548
1549
1550
1551
1552#define G1000CR_1000FD 0x0200
1553#define G1000CR_1000 0x0100
1554
1555
1556
1557
1558#define G1000SR_1000FD 0x0800
1559#define G1000SR_1000 0x0400
1560
1561#define TCSR_ECHODIS 0x2000
1562#define AUXCR_MDPPS 0x0004
1563
1564
1565#define PLED_LALBE 0x0004
1566
1567
1568#define PSCR_ACRSTX 0x0800
1569
1570#define PHYID_CICADA_CS8201 0x000FC410UL
1571#define PHYID_VT3216_32BIT 0x000FC610UL
1572#define PHYID_VT3216_64BIT 0x000FC600UL
1573#define PHYID_MARVELL_1000 0x01410C50UL
1574#define PHYID_MARVELL_1000S 0x01410C40UL
1575
1576#define PHYID_REV_ID_MASK 0x0000000FUL
1577
1578#define PHYID_GET_PHY_REV_ID(i) ((i) & PHYID_REV_ID_MASK)
1579#define PHYID_GET_PHY_ID(i) ((i) & ~PHYID_REV_ID_MASK)
1580
1581#define MII_REG_BITS_ON(x,i,p) do {\
1582 u16 w;\
1583 velocity_mii_read((p),(i),&(w));\
1584 (w)|=(x);\
1585 velocity_mii_write((p),(i),(w));\
1586} while (0)
1587
1588#define MII_REG_BITS_OFF(x,i,p) do {\
1589 u16 w;\
1590 velocity_mii_read((p),(i),&(w));\
1591 (w)&=(~(x));\
1592 velocity_mii_write((p),(i),(w));\
1593} while (0)
1594
1595#define MII_REG_BITS_IS_ON(x,i,p) ({\
1596 u16 w;\
1597 velocity_mii_read((p),(i),&(w));\
1598 ((int) ((w) & (x)));})
1599
1600#define MII_GET_PHY_ID(p) ({\
1601 u32 id;\
1602 velocity_mii_read((p),MII_REG_PHYID2,(u16 *) &id);\
1603 velocity_mii_read((p),MII_REG_PHYID1,((u16 *) &id)+1);\
1604 (id);})
1605
1606
1607
1608
1609
1610
1611enum velocity_msg_level {
1612 MSG_LEVEL_ERR = 0,
1613 MSG_LEVEL_NOTICE = 1,
1614 MSG_LEVEL_INFO = 2,
1615 MSG_LEVEL_VERBOSE = 3,
1616 MSG_LEVEL_DEBUG = 4
1617};
1618
1619#ifdef VELOCITY_DEBUG
1620#define ASSERT(x) { \
1621 if (!(x)) { \
1622 printk(KERN_ERR "assertion %s failed: file %s line %d\n", #x,\
1623 __FUNCTION__, __LINE__);\
1624 BUG(); \
1625 }\
1626}
1627#define VELOCITY_DBG(p,args...) printk(p, ##args)
1628#else
1629#define ASSERT(x)
1630#define VELOCITY_DBG(x)
1631#endif
1632
1633#define VELOCITY_PRT(l, p, args...) do {if (l<=msglevel) printk( p ,##args);} while (0)
1634
1635#define VELOCITY_PRT_CAMMASK(p,t) {\
1636 int i;\
1637 if ((t)==VELOCITY_MULTICAST_CAM) {\
1638 for (i=0;i<(MCAM_SIZE/8);i++)\
1639 printk("%02X",(p)->mCAMmask[i]);\
1640 }\
1641 else {\
1642 for (i=0;i<(VCAM_SIZE/8);i++)\
1643 printk("%02X",(p)->vCAMmask[i]);\
1644 }\
1645 printk("\n");\
1646}
1647
1648
1649
1650#define VELOCITY_WOL_MAGIC 0x00000000UL
1651#define VELOCITY_WOL_PHY 0x00000001UL
1652#define VELOCITY_WOL_ARP 0x00000002UL
1653#define VELOCITY_WOL_UCAST 0x00000004UL
1654#define VELOCITY_WOL_BCAST 0x00000010UL
1655#define VELOCITY_WOL_MCAST 0x00000020UL
1656#define VELOCITY_WOL_MAGIC_SEC 0x00000040UL
1657
1658
1659
1660
1661
1662#define VELOCITY_FLAGS_TAGGING 0x00000001UL
1663#define VELOCITY_FLAGS_TX_CSUM 0x00000002UL
1664#define VELOCITY_FLAGS_RX_CSUM 0x00000004UL
1665#define VELOCITY_FLAGS_IP_ALIGN 0x00000008UL
1666#define VELOCITY_FLAGS_VAL_PKT_LEN 0x00000010UL
1667
1668#define VELOCITY_FLAGS_FLOW_CTRL 0x01000000UL
1669
1670
1671
1672
1673
1674#define VELOCITY_FLAGS_OPENED 0x00010000UL
1675#define VELOCITY_FLAGS_VMNS_CONNECTED 0x00020000UL
1676#define VELOCITY_FLAGS_VMNS_COMMITTED 0x00040000UL
1677#define VELOCITY_FLAGS_WOL_ENABLED 0x00080000UL
1678
1679
1680
1681
1682
1683#define VELOCITY_LINK_FAIL 0x00000001UL
1684#define VELOCITY_SPEED_10 0x00000002UL
1685#define VELOCITY_SPEED_100 0x00000004UL
1686#define VELOCITY_SPEED_1000 0x00000008UL
1687#define VELOCITY_DUPLEX_FULL 0x00000010UL
1688#define VELOCITY_AUTONEG_ENABLE 0x00000020UL
1689#define VELOCITY_FORCED_BY_EEPROM 0x00000040UL
1690
1691
1692
1693
1694
1695#define VELOCITY_LINK_CHANGE 0x00000001UL
1696
1697enum speed_opt {
1698 SPD_DPX_AUTO = 0,
1699 SPD_DPX_100_HALF = 1,
1700 SPD_DPX_100_FULL = 2,
1701 SPD_DPX_10_HALF = 3,
1702 SPD_DPX_10_FULL = 4
1703};
1704
1705enum velocity_init_type {
1706 VELOCITY_INIT_COLD = 0,
1707 VELOCITY_INIT_RESET,
1708 VELOCITY_INIT_WOL
1709};
1710
1711enum velocity_flow_cntl_type {
1712 FLOW_CNTL_DEFAULT = 1,
1713 FLOW_CNTL_TX,
1714 FLOW_CNTL_RX,
1715 FLOW_CNTL_TX_RX,
1716 FLOW_CNTL_DISABLE,
1717};
1718
1719struct velocity_opt {
1720 int numrx;
1721 int numtx;
1722 enum speed_opt spd_dpx;
1723 int vid;
1724 int DMA_length;
1725 int rx_thresh;
1726 int flow_cntl;
1727 int wol_opts;
1728 int td_int_count;
1729 int int_works;
1730 int rx_bandwidth_hi;
1731 int rx_bandwidth_lo;
1732 int rx_bandwidth_en;
1733 u32 flags;
1734};
1735
1736struct velocity_info {
1737 struct velocity_info *next;
1738 struct velocity_info *prev;
1739
1740 struct pci_dev *pdev;
1741 struct net_device *dev;
1742 struct net_device_stats stats;
1743
1744#if CONFIG_PM
1745 u32 pci_state[16];
1746#endif
1747
1748 dma_addr_t rd_pool_dma;
1749 dma_addr_t td_pool_dma[TX_QUEUE_NO];
1750
1751 dma_addr_t tx_bufs_dma;
1752 u8 *tx_bufs;
1753
1754 u8 ip_addr[4];
1755 enum chip_type chip_id;
1756
1757 struct mac_regs * mac_regs;
1758 unsigned long memaddr;
1759 unsigned long ioaddr;
1760 u32 io_size;
1761
1762 u8 rev_id;
1763
1764#define AVAIL_TD(p,q) ((p)->options.numtx-((p)->td_used[(q)]))
1765
1766 int num_txq;
1767
1768 volatile int td_used[TX_QUEUE_NO];
1769 int td_curr[TX_QUEUE_NO];
1770 int td_tail[TX_QUEUE_NO];
1771 struct tx_desc *td_rings[TX_QUEUE_NO];
1772 struct velocity_td_info *td_infos[TX_QUEUE_NO];
1773
1774 int rd_curr;
1775 int rd_used;
1776 struct rx_desc *rd_ring;
1777 struct velocity_rd_info *rd_info;
1778
1779#define GET_RD_BY_IDX(vptr, idx) (vptr->rd_ring[idx])
1780 u32 mib_counter[MAX_HW_MIB_COUNTER];
1781 struct velocity_opt options;
1782
1783 u32 int_mask;
1784
1785 u32 flags;
1786
1787 int rx_buf_sz;
1788 u32 mii_status;
1789 u32 phy_id;
1790 int multicast_limit;
1791
1792 u8 vCAMmask[(VCAM_SIZE / 8)];
1793 u8 mCAMmask[(MCAM_SIZE / 8)];
1794
1795 spinlock_t lock;
1796 spinlock_t xmit_lock;
1797
1798 int wol_opts;
1799 u8 wol_passwd[6];
1800
1801 struct velocity_context context;
1802
1803 u32 ticks;
1804 u32 rx_bytes;
1805
1806};
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820inline static int velocity_get_ip(struct velocity_info *vptr)
1821{
1822 struct in_device *in_dev = (struct in_device *) vptr->dev->ip_ptr;
1823 struct in_ifaddr *ifa;
1824
1825 if (in_dev != NULL) {
1826 ifa = (struct in_ifaddr *) in_dev->ifa_list;
1827 if (ifa != NULL) {
1828 memcpy(vptr->ip_addr, &ifa->ifa_address, 4);
1829 return 0;
1830 }
1831 }
1832 return -ENOENT;
1833}
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846static inline void velocity_update_hw_mibs(struct velocity_info *vptr)
1847{
1848 u32 tmp;
1849 int i;
1850 BYTE_REG_BITS_ON(MIBCR_MIBFLSH, &(vptr->mac_regs->MIBCR));
1851
1852 while (BYTE_REG_BITS_IS_ON(MIBCR_MIBFLSH, &(vptr->mac_regs->MIBCR)));
1853
1854 BYTE_REG_BITS_ON(MIBCR_MPTRINI, &(vptr->mac_regs->MIBCR));
1855 for (i = 0; i < HW_MIB_SIZE; i++) {
1856 tmp = readl(&(vptr->mac_regs->MIBData)) & 0x00FFFFFFUL;
1857 vptr->mib_counter[i] += tmp;
1858 }
1859}
1860
1861
1862
1863
1864
1865
1866
1867
1868static inline void init_flow_control_register(struct velocity_info *vptr)
1869{
1870 struct mac_regs * regs = vptr->mac_regs;
1871
1872
1873
1874 writel((CR0_XONEN | CR0_XHITH1 | CR0_XLTH1 | CR0_XLTH0), ®s->CR0Set);
1875 writel((CR0_FDXTFCEN | CR0_FDXRFCEN | CR0_HDXFCEN | CR0_XHITH0), ®s->CR0Clr);
1876
1877
1878 writew(0xFFFF, ®s->tx_pause_timer);
1879
1880
1881 writew(vptr->options.numrx, ®s->RBRDU);
1882}
1883
1884
1885#endif
1886