1
2
3
4
5
6
7
8
9
10
11
12
13
14#ifndef __UCC_GETH_H__
15#define __UCC_GETH_H__
16
17#include <linux/kernel.h>
18#include <linux/list.h>
19#include <linux/if_ether.h>
20
21#include <soc/fsl/qe/immap_qe.h>
22#include <soc/fsl/qe/qe.h>
23
24#include <soc/fsl/qe/ucc.h>
25#include <soc/fsl/qe/ucc_fast.h>
26
27#define DRV_DESC "QE UCC Gigabit Ethernet Controller"
28#define DRV_NAME "ucc_geth"
29
30#define NUM_TX_QUEUES 8
31#define NUM_RX_QUEUES 8
32#define NUM_BDS_IN_PREFETCHED_BDS 4
33#define TX_IP_OFFSET_ENTRY_MAX 8
34#define NUM_OF_PADDRS 4
35#define ENET_INIT_PARAM_MAX_ENTRIES_RX 9
36#define ENET_INIT_PARAM_MAX_ENTRIES_TX 8
37
38struct ucc_geth {
39 struct ucc_fast uccf;
40 u8 res0[0x100 - sizeof(struct ucc_fast)];
41
42 u32 maccfg1;
43 u32 maccfg2;
44 u32 ipgifg;
45 u32 hafdup;
46 u8 res1[0x10];
47 u8 miimng[0x18];
48 u32 ifctl;
49 u32 ifstat;
50 u32 macstnaddr1;
51 u32 macstnaddr2;
52 u8 res2[0x8];
53 u32 uempr;
54 u32 utbipar;
55 u16 uescr;
56 u8 res3[0x180 - 0x15A];
57 u32 tx64;
58
59
60
61
62 u32 tx127;
63
64
65
66 u32 tx255;
67
68
69 u32 rx64;
70
71
72 u32 rx127;
73
74
75 u32 rx255;
76
77
78 u32 txok;
79
80
81 u16 txcf;
82
83 u8 res4[0x2];
84 u32 tmca;
85
86
87 u32 tbca;
88
89
90 u32 rxfok;
91 u32 rxbok;
92 u32 rbyt;
93
94
95
96 u32 rmca;
97
98
99 u32 rbca;
100
101
102 u32 scar;
103 u32 scam;
104 u8 res5[0x200 - 0x1c4];
105} __packed;
106
107
108#define TEMODER_TX_RMON_STATISTICS_ENABLE 0x0100
109
110#define TEMODER_SCHEDULER_ENABLE 0x2000
111#define TEMODER_IP_CHECKSUM_GENERATE 0x0400
112
113#define TEMODER_PERFORMANCE_OPTIMIZATION_MODE1 0x0200
114
115
116#define TEMODER_RMON_STATISTICS 0x0100
117
118#define TEMODER_NUM_OF_QUEUES_SHIFT (15-15)
119
120
121
122#define REMODER_RX_RMON_STATISTICS_ENABLE 0x00001000
123
124#define REMODER_RX_EXTENDED_FEATURES 0x80000000
125
126
127#define REMODER_VLAN_OPERATION_TAGGED_SHIFT (31-9 )
128
129#define REMODER_VLAN_OPERATION_NON_TAGGED_SHIFT (31-10)
130
131#define REMODER_RX_QOS_MODE_SHIFT (31-15)
132
133#define REMODER_RMON_STATISTICS 0x00001000
134
135#define REMODER_RX_EXTENDED_FILTERING 0x00000800
136
137
138
139
140#define REMODER_NUM_OF_QUEUES_SHIFT (31-23)
141
142#define REMODER_DYNAMIC_MAX_FRAME_LENGTH 0x00000008
143
144
145
146#define REMODER_DYNAMIC_MIN_FRAME_LENGTH 0x00000004
147
148
149
150#define REMODER_IP_CHECKSUM_CHECK 0x00000002
151
152#define REMODER_IP_ADDRESS_ALIGNMENT 0x00000001
153
154
155
156
157
158#define UCCE_TXB (UCC_GETH_UCCE_TXB7 | UCC_GETH_UCCE_TXB6 | \
159 UCC_GETH_UCCE_TXB5 | UCC_GETH_UCCE_TXB4 | \
160 UCC_GETH_UCCE_TXB3 | UCC_GETH_UCCE_TXB2 | \
161 UCC_GETH_UCCE_TXB1 | UCC_GETH_UCCE_TXB0)
162
163#define UCCE_RXB (UCC_GETH_UCCE_RXB7 | UCC_GETH_UCCE_RXB6 | \
164 UCC_GETH_UCCE_RXB5 | UCC_GETH_UCCE_RXB4 | \
165 UCC_GETH_UCCE_RXB3 | UCC_GETH_UCCE_RXB2 | \
166 UCC_GETH_UCCE_RXB1 | UCC_GETH_UCCE_RXB0)
167
168#define UCCE_RXF (UCC_GETH_UCCE_RXF7 | UCC_GETH_UCCE_RXF6 | \
169 UCC_GETH_UCCE_RXF5 | UCC_GETH_UCCE_RXF4 | \
170 UCC_GETH_UCCE_RXF3 | UCC_GETH_UCCE_RXF2 | \
171 UCC_GETH_UCCE_RXF1 | UCC_GETH_UCCE_RXF0)
172
173#define UCCE_OTHER (UCC_GETH_UCCE_SCAR | UCC_GETH_UCCE_GRA | \
174 UCC_GETH_UCCE_CBPR | UCC_GETH_UCCE_BSY | \
175 UCC_GETH_UCCE_RXC | UCC_GETH_UCCE_TXC | UCC_GETH_UCCE_TXE)
176
177#define UCCE_RX_EVENTS (UCCE_RXF | UCC_GETH_UCCE_BSY)
178#define UCCE_TX_EVENTS (UCCE_TXB | UCC_GETH_UCCE_TXE)
179
180
181#define ENET_TBI_MII_CR 0x00
182#define ENET_TBI_MII_SR 0x01
183#define ENET_TBI_MII_ANA 0x04
184#define ENET_TBI_MII_ANLPBPA 0x05
185#define ENET_TBI_MII_ANEX 0x06
186#define ENET_TBI_MII_ANNPT 0x07
187#define ENET_TBI_MII_ANLPANP 0x08
188#define ENET_TBI_MII_EXST 0x0F
189#define ENET_TBI_MII_JD 0x10
190#define ENET_TBI_MII_TBICON 0x11
191
192
193#define TBISR_LSTATUS 0x0004
194#define TBICON_CLK_SELECT 0x0020
195#define TBIANA_ASYMMETRIC_PAUSE 0x0100
196#define TBIANA_SYMMETRIC_PAUSE 0x0080
197#define TBIANA_HALF_DUPLEX 0x0040
198#define TBIANA_FULL_DUPLEX 0x0020
199#define TBICR_PHY_RESET 0x8000
200#define TBICR_ANEG_ENABLE 0x1000
201#define TBICR_RESTART_ANEG 0x0200
202#define TBICR_FULL_DUPLEX 0x0100
203#define TBICR_SPEED1_SET 0x0040
204
205#define TBIANA_SETTINGS ( \
206 TBIANA_ASYMMETRIC_PAUSE \
207 | TBIANA_SYMMETRIC_PAUSE \
208 | TBIANA_FULL_DUPLEX \
209 )
210#define TBICR_SETTINGS ( \
211 TBICR_PHY_RESET \
212 | TBICR_ANEG_ENABLE \
213 | TBICR_FULL_DUPLEX \
214 | TBICR_SPEED1_SET \
215 )
216
217
218#define MACCFG1_FLOW_RX 0x00000020
219
220#define MACCFG1_FLOW_TX 0x00000010
221
222#define MACCFG1_ENABLE_SYNCHED_RX 0x00000008
223
224
225
226#define MACCFG1_ENABLE_RX 0x00000004
227#define MACCFG1_ENABLE_SYNCHED_TX 0x00000002
228
229
230
231#define MACCFG1_ENABLE_TX 0x00000001
232
233
234#define MACCFG2_PREL_SHIFT (31 - 19)
235
236
237#define MACCFG2_PREL_MASK 0x0000f000
238
239#define MACCFG2_SRP 0x00000080
240
241#define MACCFG2_STP 0x00000040
242
243
244#define MACCFG2_RESERVED_1 0x00000020
245
246
247#define MACCFG2_LC 0x00000010
248
249#define MACCFG2_MPE 0x00000008
250
251#define MACCFG2_FDX 0x00000001
252#define MACCFG2_FDX_MASK 0x00000001
253
254#define MACCFG2_PAD_CRC 0x00000004
255#define MACCFG2_CRC_EN 0x00000002
256#define MACCFG2_PAD_AND_CRC_MODE_NONE 0x00000000
257
258
259
260#define MACCFG2_PAD_AND_CRC_MODE_CRC_ONLY 0x00000002
261
262#define MACCFG2_PAD_AND_CRC_MODE_PAD_AND_CRC 0x00000004
263#define MACCFG2_INTERFACE_MODE_NIBBLE 0x00000100
264
265
266#define MACCFG2_INTERFACE_MODE_BYTE 0x00000200
267
268
269#define MACCFG2_INTERFACE_MODE_MASK 0x00000300
270
271
272
273
274
275#define IPGIFG_NON_BACK_TO_BACK_IFG_PART1_SHIFT (31 - 7)
276
277
278
279
280#define IPGIFG_NON_BACK_TO_BACK_IFG_PART2_SHIFT (31 - 15)
281
282
283
284
285#define IPGIFG_MINIMUM_IFG_ENFORCEMENT_SHIFT (31 - 23)
286
287
288#define IPGIFG_BACK_TO_BACK_IFG_SHIFT (31 - 31)
289
290
291
292#define IPGIFG_NON_BACK_TO_BACK_IFG_PART1_MAX 127
293
294
295#define IPGIFG_NON_BACK_TO_BACK_IFG_PART2_MAX 127
296
297
298#define IPGIFG_MINIMUM_IFG_ENFORCEMENT_MAX 255
299
300#define IPGIFG_BACK_TO_BACK_IFG_MAX 127
301
302#define IPGIFG_NBTB_CS_IPG_MASK 0x7F000000
303#define IPGIFG_NBTB_IPG_MASK 0x007F0000
304#define IPGIFG_MIN_IFG_MASK 0x0000FF00
305#define IPGIFG_BTB_IPG_MASK 0x0000007F
306
307
308#define HALFDUP_ALT_BEB_TRUNCATION_SHIFT (31 - 11)
309
310
311
312
313
314#define HALFDUP_ALT_BEB_TRUNCATION_MAX 0xf
315
316
317#define HALFDUP_ALT_BEB 0x00080000
318
319
320
321#define HALFDUP_BACK_PRESSURE_NO_BACKOFF 0x00040000
322
323
324#define HALFDUP_NO_BACKOFF 0x00020000
325#define HALFDUP_EXCESSIVE_DEFER 0x00010000
326
327#define HALFDUP_MAX_RETRANSMISSION_SHIFT (31 - 19)
328
329
330#define HALFDUP_MAX_RETRANSMISSION_MAX 0xf
331
332
333#define HALFDUP_COLLISION_WINDOW_SHIFT (31 - 31)
334
335
336#define HALFDUP_COLLISION_WINDOW_MAX 0x3f
337
338#define HALFDUP_ALT_BEB_TR_MASK 0x00F00000
339#define HALFDUP_RETRANS_MASK 0x0000F000
340#define HALFDUP_COL_WINDOW_MASK 0x0000003F
341
342
343#define UCCS_BPR 0x02
344
345#define UCCS_PAU 0x02
346
347#define UCCS_MPD 0x01
348
349
350
351#define IFSTAT_EXCESS_DEFER 0x00000200
352
353
354
355
356#define MACSTNADDR1_OCTET_6_SHIFT (31 - 7)
357
358
359
360#define MACSTNADDR1_OCTET_5_SHIFT (31 - 15)
361
362
363
364#define MACSTNADDR1_OCTET_4_SHIFT (31 - 23)
365
366
367
368#define MACSTNADDR1_OCTET_3_SHIFT (31 - 31)
369
370
371
372
373
374#define MACSTNADDR2_OCTET_2_SHIFT (31 - 7)
375
376
377
378#define MACSTNADDR2_OCTET_1_SHIFT (31 - 15)
379
380
381
382
383
384#define UEMPR_PAUSE_TIME_VALUE_SHIFT (31 - 15)
385
386
387#define UEMPR_EXTENDED_PAUSE_TIME_VALUE_SHIFT (31 - 31)
388
389
390
391
392
393#define UTBIPAR_PHY_ADDRESS_SHIFT (31 - 31)
394
395#define UTBIPAR_PHY_ADDRESS_MASK 0x0000001f
396
397
398
399#define UESCR_AUTOZ 0x8000
400
401
402
403#define UESCR_CLRCNT 0x4000
404
405#define UESCR_MAXCOV_SHIFT (15 - 7)
406
407
408
409#define UESCR_SCOV_SHIFT (15 - 15)
410
411
412
413
414
415#define UDSR_MAGIC 0x067E
416
417struct ucc_geth_thread_data_tx {
418 u8 res0[104];
419} __packed;
420
421struct ucc_geth_thread_data_rx {
422 u8 res0[40];
423} __packed;
424
425
426struct ucc_geth_send_queue_qd {
427 u32 bd_ring_base;
428 u8 res0[0x8];
429 u32 last_bd_completed_address;
430 u8 res1[0x30];
431} __packed;
432
433struct ucc_geth_send_queue_mem_region {
434 struct ucc_geth_send_queue_qd sqqd[NUM_TX_QUEUES];
435} __packed;
436
437struct ucc_geth_thread_tx_pram {
438 u8 res0[64];
439} __packed;
440
441struct ucc_geth_thread_rx_pram {
442 u8 res0[128];
443} __packed;
444
445#define THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING 64
446#define THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING_8 64
447#define THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING_16 96
448
449struct ucc_geth_scheduler {
450 u16 cpucount0;
451 u16 cpucount1;
452 u16 cecount0;
453 u16 cecount1;
454 u16 cpucount2;
455 u16 cpucount3;
456 u16 cecount2;
457 u16 cecount3;
458 u16 cpucount4;
459 u16 cpucount5;
460 u16 cecount4;
461 u16 cecount5;
462 u16 cpucount6;
463 u16 cpucount7;
464 u16 cecount6;
465 u16 cecount7;
466 u32 weightstatus[NUM_TX_QUEUES];
467 u32 rtsrshadow;
468 u32 time;
469 u32 ttl;
470 u32 mblinterval;
471 u16 nortsrbytetime;
472 u8 fracsiz;
473
474 u8 res0[1];
475 u8 strictpriorityq;
476 u8 txasap;
477 u8 extrabw;
478 u8 oldwfqmask;
479 u8 weightfactor[NUM_TX_QUEUES];
480
481 u32 minw;
482 u8 res1[0x70 - 0x64];
483} __packed;
484
485struct ucc_geth_tx_firmware_statistics_pram {
486 u32 sicoltx;
487 u32 mulcoltx;
488 u32 latecoltxfr;
489 u32 frabortduecol;
490 u32 frlostinmactxer;
491
492
493 u32 carriersenseertx;
494 u32 frtxok;
495 u32 txfrexcessivedefer;
496
497 u32 txpkts256;
498
499 u32 txpkts512;
500
501 u32 txpkts1024;
502
503 u32 txpktsjumbo;
504
505} __packed;
506
507struct ucc_geth_rx_firmware_statistics_pram {
508 u32 frrxfcser;
509 u32 fraligner;
510 u32 inrangelenrxer;
511 u32 outrangelenrxer;
512 u32 frtoolong;
513 u32 runt;
514 u32 verylongevent;
515 u32 symbolerror;
516 u32 dropbsy;
517 u8 res0[0x8];
518 u32 mismatchdrop;
519
520 u32 underpkts;
521 u32 pkts256;
522
523 u32 pkts512;
524
525 u32 pkts1024;
526
527 u32 pktsjumbo;
528
529 u32 frlossinmacer;
530
531 u32 pausefr;
532 u8 res1[0x4];
533 u32 removevlan;
534
535 u32 replacevlan;
536
537 u32 insertvlan;
538
539} __packed;
540
541struct ucc_geth_rx_interrupt_coalescing_entry {
542 u32 interruptcoalescingmaxvalue;
543
544 u32 interruptcoalescingcounter;
545
546
547} __packed;
548
549struct ucc_geth_rx_interrupt_coalescing_table {
550 struct ucc_geth_rx_interrupt_coalescing_entry coalescingentry[NUM_RX_QUEUES];
551
552} __packed;
553
554struct ucc_geth_rx_prefetched_bds {
555 struct qe_bd bd[NUM_BDS_IN_PREFETCHED_BDS];
556} __packed;
557
558struct ucc_geth_rx_bd_queues_entry {
559 u32 bdbaseptr;
560 u32 bdptr;
561 u32 externalbdbaseptr;
562 u32 externalbdptr;
563} __packed;
564
565struct ucc_geth_tx_global_pram {
566 u16 temoder;
567 u8 res0[0x38 - 0x02];
568 u32 sqptr;
569 u32 schedulerbasepointer;
570
571 u32 txrmonbaseptr;
572 u32 tstate;
573
574 u8 iphoffset[TX_IP_OFFSET_ENTRY_MAX];
575 u32 vtagtable[0x8];
576 u32 tqptr;
577
578 u8 res2[0x78 - 0x74];
579 u64 snums_en;
580 u32 l2l3baseptr;
581
582 u16 mtu[8];
583 u8 res3[0xa8 - 0x94];
584 u32 wrrtablebase;
585 u8 res4[0xc0 - 0xac];
586} __packed;
587
588
589struct ucc_geth_exf_global_pram {
590 u32 l2pcdptr;
591 u8 res0[0x10 - 0x04];
592} __packed;
593
594struct ucc_geth_rx_global_pram {
595 u32 remoder;
596 u32 rqptr;
597 u32 res0[0x1];
598 u8 res1[0x20 - 0xC];
599 u16 typeorlen;
600
601 u8 res2[0x1];
602 u8 rxgstpack;
603 u32 rxrmonbaseptr;
604 u8 res3[0x30 - 0x28];
605 u32 intcoalescingptr;
606 u8 res4[0x36 - 0x34];
607 u8 rstate;
608
609 u8 res5[0x46 - 0x37];
610 u16 mrblr;
611 u32 rbdqptr;
612
613 u16 mflr;
614 u16 minflr;
615 u16 maxd1;
616 u16 maxd2;
617 u32 ecamptr;
618 u32 l2qt;
619 u32 l3qt[0x8];
620 u16 vlantype;
621 u16 vlantci;
622 u8 addressfiltering[64];
623 u32 exfGlobalParam;
624
625 u8 res6[0x100 - 0xC4];
626} __packed;
627
628#define GRACEFUL_STOP_ACKNOWLEDGE_RX 0x01
629
630
631struct ucc_geth_init_pram {
632 u8 resinit1;
633 u8 resinit2;
634 u8 resinit3;
635 u8 resinit4;
636 u16 resinit5;
637 u8 res1[0x1];
638 u8 largestexternallookupkeysize;
639 u32 rgftgfrxglobal;
640 u32 rxthread[ENET_INIT_PARAM_MAX_ENTRIES_RX];
641 u8 res2[0x38 - 0x30];
642 u32 txglobal;
643 u32 txthread[ENET_INIT_PARAM_MAX_ENTRIES_TX];
644 u8 res3[0x1];
645} __packed;
646
647#define ENET_INIT_PARAM_RGF_SHIFT (32 - 4)
648#define ENET_INIT_PARAM_TGF_SHIFT (32 - 8)
649
650#define ENET_INIT_PARAM_RISC_MASK 0x0000003f
651#define ENET_INIT_PARAM_PTR_MASK 0x00ffffc0
652#define ENET_INIT_PARAM_SNUM_MASK 0xff000000
653#define ENET_INIT_PARAM_SNUM_SHIFT 24
654
655#define ENET_INIT_PARAM_MAGIC_RES_INIT1 0x06
656#define ENET_INIT_PARAM_MAGIC_RES_INIT2 0x30
657#define ENET_INIT_PARAM_MAGIC_RES_INIT3 0xff
658#define ENET_INIT_PARAM_MAGIC_RES_INIT4 0x00
659#define ENET_INIT_PARAM_MAGIC_RES_INIT5 0x0400
660
661
662struct ucc_geth_82xx_enet_address {
663 u8 res1[0x2];
664 u16 h;
665 u16 m;
666 u16 l;
667} __packed;
668
669
670struct ucc_geth_82xx_address_filtering_pram {
671 u32 iaddr_h;
672 u32 iaddr_l;
673 u32 gaddr_h;
674 u32 gaddr_l;
675 struct ucc_geth_82xx_enet_address __iomem taddr;
676 struct ucc_geth_82xx_enet_address __iomem paddr[NUM_OF_PADDRS];
677 u8 res0[0x40 - 0x38];
678} __packed;
679
680
681
682struct ucc_geth_tx_firmware_statistics {
683 u32 sicoltx;
684 u32 mulcoltx;
685 u32 latecoltxfr;
686 u32 frabortduecol;
687 u32 frlostinmactxer;
688
689
690 u32 carriersenseertx;
691 u32 frtxok;
692 u32 txfrexcessivedefer;
693
694 u32 txpkts256;
695
696 u32 txpkts512;
697
698 u32 txpkts1024;
699
700 u32 txpktsjumbo;
701
702} __packed;
703
704
705
706struct ucc_geth_rx_firmware_statistics {
707 u32 frrxfcser;
708 u32 fraligner;
709 u32 inrangelenrxer;
710 u32 outrangelenrxer;
711 u32 frtoolong;
712 u32 runt;
713 u32 verylongevent;
714 u32 symbolerror;
715 u32 dropbsy;
716 u8 res0[0x8];
717 u32 mismatchdrop;
718
719 u32 underpkts;
720 u32 pkts256;
721
722 u32 pkts512;
723
724 u32 pkts1024;
725
726 u32 pktsjumbo;
727
728 u32 frlossinmacer;
729
730 u32 pausefr;
731 u8 res1[0x4];
732 u32 removevlan;
733
734 u32 replacevlan;
735
736 u32 insertvlan;
737
738} __packed;
739
740
741
742struct ucc_geth_hardware_statistics {
743 u32 tx64;
744
745
746
747
748 u32 tx127;
749
750
751
752 u32 tx255;
753
754
755 u32 rx64;
756
757
758 u32 rx127;
759
760
761 u32 rx255;
762
763
764 u32 txok;
765
766
767 u16 txcf;
768
769 u32 tmca;
770
771
772 u32 tbca;
773
774
775 u32 rxfok;
776 u32 rxbok;
777 u32 rbyt;
778
779
780
781 u32 rmca;
782
783
784 u32 rbca;
785
786
787} __packed;
788
789
790#define TX_ERRORS_DEF 0x0200
791#define TX_ERRORS_EXDEF 0x0100
792#define TX_ERRORS_LC 0x0080
793#define TX_ERRORS_RL 0x0040
794#define TX_ERRORS_RC_MASK 0x003C
795#define TX_ERRORS_RC_SHIFT 2
796#define TX_ERRORS_UN 0x0002
797#define TX_ERRORS_CSL 0x0001
798
799
800#define RX_ERRORS_CMR 0x0200
801#define RX_ERRORS_M 0x0100
802#define RX_ERRORS_BC 0x0080
803#define RX_ERRORS_MC 0x0040
804
805
806#define T_VID 0x003c0000
807#define T_DEF (((u32) TX_ERRORS_DEF ) << 16)
808#define T_EXDEF (((u32) TX_ERRORS_EXDEF ) << 16)
809#define T_LC (((u32) TX_ERRORS_LC ) << 16)
810#define T_RL (((u32) TX_ERRORS_RL ) << 16)
811#define T_RC_MASK (((u32) TX_ERRORS_RC_MASK ) << 16)
812#define T_UN (((u32) TX_ERRORS_UN ) << 16)
813#define T_CSL (((u32) TX_ERRORS_CSL ) << 16)
814#define T_ERRORS_REPORT (T_DEF | T_EXDEF | T_LC | T_RL | T_RC_MASK \
815 | T_UN | T_CSL)
816
817
818#define R_LG 0x00200000
819#define R_NO 0x00100000
820#define R_SH 0x00080000
821#define R_CR 0x00040000
822#define R_OV 0x00020000
823#define R_IPCH 0x00010000
824#define R_CMR (((u32) RX_ERRORS_CMR ) << 16)
825#define R_M (((u32) RX_ERRORS_M ) << 16)
826#define R_BC (((u32) RX_ERRORS_BC ) << 16)
827#define R_MC (((u32) RX_ERRORS_MC ) << 16)
828#define R_ERRORS_REPORT (R_CMR | R_M | R_BC | R_MC)
829
830#define R_ERRORS_FATAL (R_LG | R_NO | R_SH | R_CR | \
831 R_OV | R_IPCH)
832
833
834#define UCC_GETH_RX_GLOBAL_PRAM_ALIGNMENT 256
835#define UCC_GETH_TX_GLOBAL_PRAM_ALIGNMENT 128
836#define UCC_GETH_THREAD_RX_PRAM_ALIGNMENT 128
837#define UCC_GETH_THREAD_TX_PRAM_ALIGNMENT 64
838#define UCC_GETH_THREAD_DATA_ALIGNMENT 256
839
840
841
842
843#define UCC_GETH_SEND_QUEUE_QUEUE_DESCRIPTOR_ALIGNMENT 32
844#define UCC_GETH_SCHEDULER_ALIGNMENT 8
845#define UCC_GETH_TX_STATISTICS_ALIGNMENT 4
846#define UCC_GETH_RX_STATISTICS_ALIGNMENT 4
847#define UCC_GETH_RX_INTERRUPT_COALESCING_ALIGNMENT 64
848#define UCC_GETH_RX_BD_QUEUES_ALIGNMENT 8
849#define UCC_GETH_RX_PREFETCHED_BDS_ALIGNMENT 128
850#define UCC_GETH_RX_EXTENDED_FILTERING_GLOBAL_PARAMETERS_ALIGNMENT 8
851
852
853
854#define UCC_GETH_RX_BD_RING_ALIGNMENT 32
855#define UCC_GETH_TX_BD_RING_ALIGNMENT 32
856#define UCC_GETH_MRBLR_ALIGNMENT 128
857#define UCC_GETH_RX_BD_RING_SIZE_ALIGNMENT 4
858#define UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT 32
859#define UCC_GETH_RX_DATA_BUF_ALIGNMENT 64
860
861#define UCC_GETH_TAD_EF 0x80
862#define UCC_GETH_TAD_V 0x40
863#define UCC_GETH_TAD_REJ 0x20
864#define UCC_GETH_TAD_VTAG_OP_RIGHT_SHIFT 2
865#define UCC_GETH_TAD_VTAG_OP_SHIFT 6
866#define UCC_GETH_TAD_V_NON_VTAG_OP 0x20
867#define UCC_GETH_TAD_RQOS_SHIFT 0
868#define UCC_GETH_TAD_V_PRIORITY_SHIFT 5
869#define UCC_GETH_TAD_CFI 0x10
870
871#define UCC_GETH_VLAN_PRIORITY_MAX 8
872#define UCC_GETH_IP_PRIORITY_MAX 64
873#define UCC_GETH_TX_VTAG_TABLE_ENTRY_MAX 8
874#define UCC_GETH_RX_BD_RING_SIZE_MIN 8
875#define UCC_GETH_TX_BD_RING_SIZE_MIN 2
876#define UCC_GETH_BD_RING_SIZE_MAX 0xffff
877
878#define UCC_GETH_SIZE_OF_BD QE_SIZEOF_BD
879
880
881#define TX_BD_RING_LEN 0x10
882#define RX_BD_RING_LEN 0x20
883
884#define TX_RING_MOD_MASK(size) (size-1)
885#define RX_RING_MOD_MASK(size) (size-1)
886
887#define ENET_GROUP_ADDR 0x01
888
889
890
891#define TX_TIMEOUT (1*HZ)
892#define PHY_INIT_TIMEOUT 100000
893#define PHY_CHANGE_TIME 2
894
895
896#define UCC_GETH_URFS_INIT 512
897
898#define UCC_GETH_URFET_INIT 256
899#define UCC_GETH_URFSET_INIT 384
900#define UCC_GETH_UTFS_INIT 512
901
902#define UCC_GETH_UTFET_INIT 256
903#define UCC_GETH_UTFTT_INIT 256
904
905
906#define UCC_GETH_URFS_GIGA_INIT 4096
907
908#define UCC_GETH_URFET_GIGA_INIT 2048
909#define UCC_GETH_URFSET_GIGA_INIT 3072
910#define UCC_GETH_UTFS_GIGA_INIT 4096
911
912#define UCC_GETH_UTFET_GIGA_INIT 2048
913#define UCC_GETH_UTFTT_GIGA_INIT 4096
914
915
916#define UCC_GETH_REMODER_INIT 0
917
918#define UCC_GETH_TEMODER_INIT 0xC000
919
920
921#define UCC_GETH_UPSMR_INIT UCC_GETH_UPSMR_RES1
922
923#define UCC_GETH_MACCFG1_INIT 0
924#define UCC_GETH_MACCFG2_INIT (MACCFG2_RESERVED_1)
925
926
927enum enet_addr_type {
928 ENET_ADDR_TYPE_INDIVIDUAL,
929 ENET_ADDR_TYPE_GROUP,
930 ENET_ADDR_TYPE_BROADCAST
931};
932
933
934enum ucc_geth_enet_address_recognition_location {
935 UCC_GETH_ENET_ADDRESS_RECOGNITION_LOCATION_STATION_ADDRESS,
936
937 UCC_GETH_ENET_ADDRESS_RECOGNITION_LOCATION_PADDR_FIRST,
938
939
940
941 UCC_GETH_ENET_ADDRESS_RECOGNITION_LOCATION_PADDR2,
942
943
944
945 UCC_GETH_ENET_ADDRESS_RECOGNITION_LOCATION_PADDR3,
946
947
948
949 UCC_GETH_ENET_ADDRESS_RECOGNITION_LOCATION_PADDR_LAST,
950
951
952
953 UCC_GETH_ENET_ADDRESS_RECOGNITION_LOCATION_GROUP_HASH,
954 UCC_GETH_ENET_ADDRESS_RECOGNITION_LOCATION_INDIVIDUAL_HASH
955
956};
957
958
959enum ucc_geth_vlan_operation_tagged {
960 UCC_GETH_VLAN_OPERATION_TAGGED_NOP = 0x0,
961 UCC_GETH_VLAN_OPERATION_TAGGED_REPLACE_VID_PORTION_OF_Q_TAG
962 = 0x1,
963 UCC_GETH_VLAN_OPERATION_TAGGED_IF_VID0_REPLACE_VID_WITH_DEFAULT_VALUE
964 = 0x2,
965 UCC_GETH_VLAN_OPERATION_TAGGED_EXTRACT_Q_TAG_FROM_FRAME
966 = 0x3
967};
968
969
970enum ucc_geth_vlan_operation_non_tagged {
971 UCC_GETH_VLAN_OPERATION_NON_TAGGED_NOP = 0x0,
972 UCC_GETH_VLAN_OPERATION_NON_TAGGED_Q_TAG_INSERT = 0x1
973
974
975};
976
977
978enum ucc_geth_qos_mode {
979 UCC_GETH_QOS_MODE_DEFAULT = 0x0,
980 UCC_GETH_QOS_MODE_QUEUE_NUM_FROM_L2_CRITERIA = 0x1,
981
982
983
984 UCC_GETH_QOS_MODE_QUEUE_NUM_FROM_L3_CRITERIA = 0x2
985
986
987
988};
989
990
991
992enum ucc_geth_statistics_gathering_mode {
993 UCC_GETH_STATISTICS_GATHERING_MODE_NONE = 0x00000000,
994
995
996 UCC_GETH_STATISTICS_GATHERING_MODE_HARDWARE = 0x00000001,
997
998
999
1000
1001 UCC_GETH_STATISTICS_GATHERING_MODE_FIRMWARE_TX = 0x00000004,
1002
1003
1004
1005
1006
1007 UCC_GETH_STATISTICS_GATHERING_MODE_FIRMWARE_RX = 0x00000008
1008
1009
1010
1011
1012
1013};
1014
1015
1016enum ucc_geth_maccfg2_pad_and_crc_mode {
1017 UCC_GETH_PAD_AND_CRC_MODE_NONE
1018 = MACCFG2_PAD_AND_CRC_MODE_NONE,
1019
1020
1021 UCC_GETH_PAD_AND_CRC_MODE_CRC_ONLY
1022 = MACCFG2_PAD_AND_CRC_MODE_CRC_ONLY,
1023
1024 UCC_GETH_PAD_AND_CRC_MODE_PAD_AND_CRC =
1025 MACCFG2_PAD_AND_CRC_MODE_PAD_AND_CRC
1026};
1027
1028
1029enum ucc_geth_flow_control_mode {
1030 UPSMR_AUTOMATIC_FLOW_CONTROL_MODE_NONE = 0x00000000,
1031
1032
1033 UPSMR_AUTOMATIC_FLOW_CONTROL_MODE_PAUSE_WHEN_EMERGENCY
1034 = 0x00004000
1035
1036};
1037
1038
1039enum ucc_geth_num_of_threads {
1040 UCC_GETH_NUM_OF_THREADS_1 = 0x1,
1041 UCC_GETH_NUM_OF_THREADS_2 = 0x2,
1042 UCC_GETH_NUM_OF_THREADS_4 = 0x0,
1043 UCC_GETH_NUM_OF_THREADS_6 = 0x3,
1044 UCC_GETH_NUM_OF_THREADS_8 = 0x4
1045};
1046
1047
1048enum ucc_geth_num_of_station_addresses {
1049 UCC_GETH_NUM_OF_STATION_ADDRESSES_1,
1050 UCC_GETH_NUM_OF_STATION_ADDRESSES_5
1051};
1052
1053
1054struct enet_addr_container {
1055 u8 address[ETH_ALEN];
1056 enum ucc_geth_enet_address_recognition_location location;
1057
1058
1059
1060 struct list_head node;
1061};
1062
1063#define ENET_ADDR_CONT_ENTRY(ptr) list_entry(ptr, struct enet_addr_container, node)
1064
1065
1066struct ucc_geth_tad_params {
1067 int rx_non_dynamic_extended_features_mode;
1068 int reject_frame;
1069 enum ucc_geth_vlan_operation_tagged vtag_op;
1070 enum ucc_geth_vlan_operation_non_tagged vnontag_op;
1071 enum ucc_geth_qos_mode rqos;
1072 u8 vpri;
1073 u16 vid;
1074};
1075
1076
1077struct ucc_geth_info {
1078 struct ucc_fast_info uf_info;
1079 int ipCheckSumCheck;
1080 int ipCheckSumGenerate;
1081 int rxExtendedFiltering;
1082 u32 extendedFilteringChainPointer;
1083 u16 typeorlen;
1084 int dynamicMaxFrameLength;
1085 int dynamicMinFrameLength;
1086 u8 nonBackToBackIfgPart1;
1087 u8 nonBackToBackIfgPart2;
1088 u8 miminumInterFrameGapEnforcement;
1089 u8 backToBackInterFrameGap;
1090 int ipAddressAlignment;
1091 int lengthCheckRx;
1092 u32 mblinterval;
1093 u16 nortsrbytetime;
1094 u8 fracsiz;
1095 u8 strictpriorityq;
1096 u8 txasap;
1097 u8 extrabw;
1098 int miiPreambleSupress;
1099 u8 altBebTruncation;
1100 int altBeb;
1101 int backPressureNoBackoff;
1102 int noBackoff;
1103 int excessDefer;
1104 u8 maxRetransmission;
1105 u8 collisionWindow;
1106 int pro;
1107 int cap;
1108 int rsh;
1109 int rlpb;
1110 int cam;
1111 int bro;
1112 int ecm;
1113 int receiveFlowControl;
1114 int transmitFlowControl;
1115 u8 maxGroupAddrInHash;
1116 u8 maxIndAddrInHash;
1117 u8 prel;
1118 u16 maxFrameLength;
1119 u16 minFrameLength;
1120 u16 maxD1Length;
1121 u16 maxD2Length;
1122 u16 vlantype;
1123 u16 vlantci;
1124 u32 ecamptr;
1125 u32 eventRegMask;
1126 u16 pausePeriod;
1127 u16 extensionField;
1128 struct device_node *phy_node;
1129 struct device_node *tbi_node;
1130 u8 weightfactor[NUM_TX_QUEUES];
1131 u8 interruptcoalescingmaxvalue[NUM_RX_QUEUES];
1132 u8 l2qt[UCC_GETH_VLAN_PRIORITY_MAX];
1133 u8 l3qt[UCC_GETH_IP_PRIORITY_MAX];
1134 u32 vtagtable[UCC_GETH_TX_VTAG_TABLE_ENTRY_MAX];
1135 u8 iphoffset[TX_IP_OFFSET_ENTRY_MAX];
1136 u16 bdRingLenTx[NUM_TX_QUEUES];
1137 u16 bdRingLenRx[NUM_RX_QUEUES];
1138 enum ucc_geth_num_of_station_addresses numStationAddresses;
1139 enum qe_fltr_largest_external_tbl_lookup_key_size
1140 largestexternallookupkeysize;
1141 enum ucc_geth_statistics_gathering_mode statisticsMode;
1142 enum ucc_geth_vlan_operation_tagged vlanOperationTagged;
1143 enum ucc_geth_vlan_operation_non_tagged vlanOperationNonTagged;
1144 enum ucc_geth_qos_mode rxQoSMode;
1145 enum ucc_geth_flow_control_mode aufc;
1146 enum ucc_geth_maccfg2_pad_and_crc_mode padAndCrc;
1147 enum ucc_geth_num_of_threads numThreadsTx;
1148 enum ucc_geth_num_of_threads numThreadsRx;
1149 unsigned int riscTx;
1150 unsigned int riscRx;
1151};
1152
1153
1154struct ucc_geth_private {
1155 struct ucc_geth_info *ug_info;
1156 struct ucc_fast_private *uccf;
1157 struct device *dev;
1158 struct net_device *ndev;
1159 struct napi_struct napi;
1160 struct work_struct timeout_work;
1161 struct ucc_geth __iomem *ug_regs;
1162 struct ucc_geth_init_pram *p_init_enet_param_shadow;
1163 struct ucc_geth_exf_global_pram __iomem *p_exf_glbl_param;
1164 u32 exf_glbl_param_offset;
1165 struct ucc_geth_rx_global_pram __iomem *p_rx_glbl_pram;
1166 struct ucc_geth_tx_global_pram __iomem *p_tx_glbl_pram;
1167 struct ucc_geth_send_queue_mem_region __iomem *p_send_q_mem_reg;
1168 u32 send_q_mem_reg_offset;
1169 struct ucc_geth_thread_data_tx __iomem *p_thread_data_tx;
1170 u32 thread_dat_tx_offset;
1171 struct ucc_geth_thread_data_rx __iomem *p_thread_data_rx;
1172 u32 thread_dat_rx_offset;
1173 struct ucc_geth_scheduler __iomem *p_scheduler;
1174 u32 scheduler_offset;
1175 struct ucc_geth_tx_firmware_statistics_pram __iomem *p_tx_fw_statistics_pram;
1176 u32 tx_fw_statistics_pram_offset;
1177 struct ucc_geth_rx_firmware_statistics_pram __iomem *p_rx_fw_statistics_pram;
1178 u32 rx_fw_statistics_pram_offset;
1179 struct ucc_geth_rx_interrupt_coalescing_table __iomem *p_rx_irq_coalescing_tbl;
1180 u32 rx_irq_coalescing_tbl_offset;
1181 struct ucc_geth_rx_bd_queues_entry __iomem *p_rx_bd_qs_tbl;
1182 u32 rx_bd_qs_tbl_offset;
1183 u8 __iomem *p_tx_bd_ring[NUM_TX_QUEUES];
1184 u8 __iomem *p_rx_bd_ring[NUM_RX_QUEUES];
1185 u8 __iomem *confBd[NUM_TX_QUEUES];
1186 u8 __iomem *txBd[NUM_TX_QUEUES];
1187 u8 __iomem *rxBd[NUM_RX_QUEUES];
1188 int badFrame[NUM_RX_QUEUES];
1189 u16 cpucount[NUM_TX_QUEUES];
1190 u16 __iomem *p_cpucount[NUM_TX_QUEUES];
1191 int indAddrRegUsed[NUM_OF_PADDRS];
1192 u8 paddr[NUM_OF_PADDRS][ETH_ALEN];
1193 u8 numGroupAddrInHash;
1194 u8 numIndAddrInHash;
1195 u8 numIndAddrInReg;
1196 int rx_extended_features;
1197 int rx_non_dynamic_extended_features;
1198 struct list_head conf_skbs;
1199 struct list_head group_hash_q;
1200 struct list_head ind_hash_q;
1201 u32 saved_uccm;
1202 spinlock_t lock;
1203
1204 struct sk_buff **tx_skbuff[NUM_TX_QUEUES];
1205 struct sk_buff **rx_skbuff[NUM_RX_QUEUES];
1206
1207 u16 skb_curtx[NUM_TX_QUEUES];
1208 u16 skb_currx[NUM_RX_QUEUES];
1209
1210 u16 skb_dirtytx[NUM_TX_QUEUES];
1211
1212 struct ugeth_mii_info *mii_info;
1213 struct phy_device *phydev;
1214 phy_interface_t phy_interface;
1215 int max_speed;
1216 uint32_t msg_enable;
1217 int oldspeed;
1218 int oldduplex;
1219 int oldlink;
1220 int wol_en;
1221
1222 struct device_node *node;
1223};
1224
1225void uec_set_ethtool_ops(struct net_device *netdev);
1226int init_flow_control_params(u32 automatic_flow_control_mode,
1227 int rx_flow_control_enable, int tx_flow_control_enable,
1228 u16 pause_period, u16 extension_field,
1229 u32 __iomem *upsmr_register, u32 __iomem *uempr_register,
1230 u32 __iomem *maccfg1_register);
1231
1232
1233#endif
1234