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