164
164
#define GEM_DCFG5 0x0290 /* Design Config 5 */
165
165
#define GEM_DCFG6 0x0294 /* Design Config 6 */
166
166
#define GEM_DCFG7 0x0298 /* Design Config 7 */
167
+ #define GEM_DCFG8 0x029C /* Design Config 8 */
167
168
168
169
#define GEM_TXBDCTRL 0x04cc /* TX Buffer Descriptor control register */
169
170
#define GEM_RXBDCTRL 0x04d0 /* RX Buffer Descriptor control register */
170
171
172
+ /* Screener Type 2 match registers */
173
+ #define GEM_SCRT2 0x540
174
+
175
+ /* EtherType registers */
176
+ #define GEM_ETHT 0x06E0
177
+
178
+ /* Type 2 compare registers */
179
+ #define GEM_T2CMPW0 0x0700
180
+ #define GEM_T2CMPW1 0x0704
181
+ #define T2CMP_OFST (t2idx ) (t2idx * 2)
182
+
183
+ /* type 2 compare registers
184
+ * each location requires 3 compare regs
185
+ */
186
+ #define GEM_IP4SRC_CMP (idx ) (idx * 3)
187
+ #define GEM_IP4DST_CMP (idx ) (idx * 3 + 1)
188
+ #define GEM_PORT_CMP (idx ) (idx * 3 + 2)
189
+
190
+ /* Which screening type 2 EtherType register will be used (0 - 7) */
191
+ #define SCRT2_ETHT 0
192
+
171
193
#define GEM_ISR (hw_q ) (0x0400 + ((hw_q) << 2))
172
194
#define GEM_TBQP (hw_q ) (0x0440 + ((hw_q) << 2))
173
195
#define GEM_TBQPH (hw_q ) (0x04C8)
174
196
#define GEM_RBQP (hw_q ) (0x0480 + ((hw_q) << 2))
197
+ #define GEM_RBQS (hw_q ) (0x04A0 + ((hw_q) << 2))
198
+ #define GEM_RBQPH (hw_q ) (0x04D4)
175
199
#define GEM_IER (hw_q ) (0x0600 + ((hw_q) << 2))
176
200
#define GEM_IDR (hw_q ) (0x0620 + ((hw_q) << 2))
177
201
#define GEM_IMR (hw_q ) (0x0640 + ((hw_q) << 2))
455
479
#define GEM_DAW64_OFFSET 23
456
480
#define GEM_DAW64_SIZE 1
457
481
482
+ /* Bitfields in DCFG8. */
483
+ #define GEM_T1SCR_OFFSET 24
484
+ #define GEM_T1SCR_SIZE 8
485
+ #define GEM_T2SCR_OFFSET 16
486
+ #define GEM_T2SCR_SIZE 8
487
+ #define GEM_SCR2ETH_OFFSET 8
488
+ #define GEM_SCR2ETH_SIZE 8
489
+ #define GEM_SCR2CMP_OFFSET 0
490
+ #define GEM_SCR2CMP_SIZE 8
491
+
458
492
/* Bitfields in TISUBN */
459
493
#define GEM_SUBNSINCR_OFFSET 0
460
494
#define GEM_SUBNSINCR_SIZE 16
483
517
#define GEM_RXTSMODE_OFFSET 4 /* RX Descriptor Timestamp Insertion mode */
484
518
#define GEM_RXTSMODE_SIZE 2
485
519
520
+ /* Bitfields in SCRT2 */
521
+ #define GEM_QUEUE_OFFSET 0 /* Queue Number */
522
+ #define GEM_QUEUE_SIZE 4
523
+ #define GEM_VLANPR_OFFSET 4 /* VLAN Priority */
524
+ #define GEM_VLANPR_SIZE 3
525
+ #define GEM_VLANEN_OFFSET 8 /* VLAN Enable */
526
+ #define GEM_VLANEN_SIZE 1
527
+ #define GEM_ETHT2IDX_OFFSET 9 /* Index to screener type 2 EtherType register */
528
+ #define GEM_ETHT2IDX_SIZE 3
529
+ #define GEM_ETHTEN_OFFSET 12 /* EtherType Enable */
530
+ #define GEM_ETHTEN_SIZE 1
531
+ #define GEM_CMPA_OFFSET 13 /* Compare A - Index to screener type 2 Compare register */
532
+ #define GEM_CMPA_SIZE 5
533
+ #define GEM_CMPAEN_OFFSET 18 /* Compare A Enable */
534
+ #define GEM_CMPAEN_SIZE 1
535
+ #define GEM_CMPB_OFFSET 19 /* Compare B - Index to screener type 2 Compare register */
536
+ #define GEM_CMPB_SIZE 5
537
+ #define GEM_CMPBEN_OFFSET 24 /* Compare B Enable */
538
+ #define GEM_CMPBEN_SIZE 1
539
+ #define GEM_CMPC_OFFSET 25 /* Compare C - Index to screener type 2 Compare register */
540
+ #define GEM_CMPC_SIZE 5
541
+ #define GEM_CMPCEN_OFFSET 30 /* Compare C Enable */
542
+ #define GEM_CMPCEN_SIZE 1
543
+
544
+ /* Bitfields in ETHT */
545
+ #define GEM_ETHTCMP_OFFSET 0 /* EtherType compare value */
546
+ #define GEM_ETHTCMP_SIZE 16
547
+
548
+ /* Bitfields in T2CMPW0 */
549
+ #define GEM_T2CMP_OFFSET 16 /* 0xFFFF0000 compare value */
550
+ #define GEM_T2CMP_SIZE 16
551
+ #define GEM_T2MASK_OFFSET 0 /* 0x0000FFFF compare value or mask */
552
+ #define GEM_T2MASK_SIZE 16
553
+
554
+ /* Bitfields in T2CMPW1 */
555
+ #define GEM_T2DISMSK_OFFSET 9 /* disable mask */
556
+ #define GEM_T2DISMSK_SIZE 1
557
+ #define GEM_T2CMPOFST_OFFSET 7 /* compare offset */
558
+ #define GEM_T2CMPOFST_SIZE 2
559
+ #define GEM_T2OFST_OFFSET 0 /* offset value */
560
+ #define GEM_T2OFST_SIZE 7
561
+
562
+ /* Offset for screener type 2 compare values (T2CMPOFST).
563
+ * Note the offset is applied after the specified point,
564
+ * e.g. GEM_T2COMPOFST_ETYPE denotes the EtherType field, so an offset
565
+ * of 12 bytes from this would be the source IP address in an IP header
566
+ */
567
+ #define GEM_T2COMPOFST_SOF 0
568
+ #define GEM_T2COMPOFST_ETYPE 1
569
+ #define GEM_T2COMPOFST_IPHDR 2
570
+ #define GEM_T2COMPOFST_TCPUDP 3
571
+
572
+ /* offset from EtherType to IP address */
573
+ #define ETYPE_SRCIP_OFFSET 12
574
+ #define ETYPE_DSTIP_OFFSET 16
575
+
576
+ /* offset from IP header to port */
577
+ #define IPHDR_SRCPORT_OFFSET 0
578
+ #define IPHDR_DSTPORT_OFFSET 2
579
+
486
580
/* Transmit DMA buffer descriptor Word 1 */
487
581
#define GEM_DMA_TXVALID_OFFSET 23 /* timestamp has been captured in the Buffer Descriptor */
488
582
#define GEM_DMA_TXVALID_SIZE 1
583
677
#define gem_writel (port , reg , value ) (port)->macb_reg_writel((port), GEM_##reg, (value))
584
678
#define queue_readl (queue , reg ) (queue)->bp->macb_reg_readl((queue)->bp, (queue)->reg)
585
679
#define queue_writel (queue , reg , value ) (queue)->bp->macb_reg_writel((queue)->bp, (queue)->reg, (value))
680
+ #define gem_readl_n (port , reg , idx ) (port)->macb_reg_readl((port), GEM_##reg + idx * 4)
681
+ #define gem_writel_n (port , reg , idx , value ) (port)->macb_reg_writel((port), GEM_##reg + idx * 4, (value))
586
682
587
683
#define PTP_TS_BUFFER_SIZE 128 /* must be power of 2 */
588
684
@@ -920,13 +1016,42 @@ static const struct gem_statistic gem_statistics[] = {
920
1016
921
1017
#define GEM_STATS_LEN ARRAY_SIZE(gem_statistics)
922
1018
1019
+ #define QUEUE_STAT_TITLE (title ) { \
1020
+ .stat_string = title, \
1021
+ }
1022
+
1023
+ /* per queue statistics, each should be unsigned long type */
1024
+ struct queue_stats {
1025
+ union {
1026
+ unsigned long first ;
1027
+ unsigned long rx_packets ;
1028
+ };
1029
+ unsigned long rx_bytes ;
1030
+ unsigned long rx_dropped ;
1031
+ unsigned long tx_packets ;
1032
+ unsigned long tx_bytes ;
1033
+ unsigned long tx_dropped ;
1034
+ };
1035
+
1036
+ static const struct gem_statistic queue_statistics [] = {
1037
+ QUEUE_STAT_TITLE ("rx_packets" ),
1038
+ QUEUE_STAT_TITLE ("rx_bytes" ),
1039
+ QUEUE_STAT_TITLE ("rx_dropped" ),
1040
+ QUEUE_STAT_TITLE ("tx_packets" ),
1041
+ QUEUE_STAT_TITLE ("tx_bytes" ),
1042
+ QUEUE_STAT_TITLE ("tx_dropped" ),
1043
+ };
1044
+
1045
+ #define QUEUE_STATS_LEN ARRAY_SIZE(queue_statistics)
1046
+
923
1047
struct macb ;
1048
+ struct macb_queue ;
924
1049
925
1050
struct macb_or_gem_ops {
926
1051
int (* mog_alloc_rx_buffers )(struct macb * bp );
927
1052
void (* mog_free_rx_buffers )(struct macb * bp );
928
1053
void (* mog_init_rings )(struct macb * bp );
929
- int (* mog_rx )(struct macb * bp , int budget );
1054
+ int (* mog_rx )(struct macb_queue * queue , int budget );
930
1055
};
931
1056
932
1057
/* MACB-PTP interface: adapt to platform needs. */
@@ -968,20 +1093,43 @@ struct macb_queue {
968
1093
unsigned int IMR ;
969
1094
unsigned int TBQP ;
970
1095
unsigned int TBQPH ;
1096
+ unsigned int RBQS ;
1097
+ unsigned int RBQP ;
1098
+ unsigned int RBQPH ;
971
1099
972
1100
unsigned int tx_head , tx_tail ;
973
1101
struct macb_dma_desc * tx_ring ;
974
1102
struct macb_tx_skb * tx_skb ;
975
1103
dma_addr_t tx_ring_dma ;
976
1104
struct work_struct tx_error_task ;
977
1105
1106
+ dma_addr_t rx_ring_dma ;
1107
+ dma_addr_t rx_buffers_dma ;
1108
+ unsigned int rx_tail ;
1109
+ unsigned int rx_prepared_head ;
1110
+ struct macb_dma_desc * rx_ring ;
1111
+ struct sk_buff * * rx_skbuff ;
1112
+ void * rx_buffers ;
1113
+ struct napi_struct napi ;
1114
+ struct queue_stats stats ;
1115
+
978
1116
#ifdef CONFIG_MACB_USE_HWSTAMP
979
1117
struct work_struct tx_ts_task ;
980
1118
unsigned int tx_ts_head , tx_ts_tail ;
981
1119
struct gem_tx_ts tx_timestamps [PTP_TS_BUFFER_SIZE ];
982
1120
#endif
983
1121
};
984
1122
1123
+ struct ethtool_rx_fs_item {
1124
+ struct ethtool_rx_flow_spec fs ;
1125
+ struct list_head list ;
1126
+ };
1127
+
1128
+ struct ethtool_rx_fs_list {
1129
+ struct list_head list ;
1130
+ unsigned int count ;
1131
+ };
1132
+
985
1133
struct macb {
986
1134
void __iomem * regs ;
987
1135
bool native_io ;
@@ -990,11 +1138,6 @@ struct macb {
990
1138
u32 (* macb_reg_readl )(struct macb * bp , int offset );
991
1139
void (* macb_reg_writel )(struct macb * bp , int offset , u32 value );
992
1140
993
- unsigned int rx_tail ;
994
- unsigned int rx_prepared_head ;
995
- struct macb_dma_desc * rx_ring ;
996
- struct sk_buff * * rx_skbuff ;
997
- void * rx_buffers ;
998
1141
size_t rx_buffer_size ;
999
1142
1000
1143
unsigned int rx_ring_size ;
@@ -1011,15 +1154,11 @@ struct macb {
1011
1154
struct clk * tx_clk ;
1012
1155
struct clk * rx_clk ;
1013
1156
struct net_device * dev ;
1014
- struct napi_struct napi ;
1015
1157
union {
1016
1158
struct macb_stats macb ;
1017
1159
struct gem_stats gem ;
1018
1160
} hw_stats ;
1019
1161
1020
- dma_addr_t rx_ring_dma ;
1021
- dma_addr_t rx_buffers_dma ;
1022
-
1023
1162
struct macb_or_gem_ops macbgem_ops ;
1024
1163
1025
1164
struct mii_bus * mii_bus ;
@@ -1040,7 +1179,7 @@ struct macb {
1040
1179
int skb_length ; /* saved skb length for pci_unmap_single */
1041
1180
unsigned int max_tx_length ;
1042
1181
1043
- u64 ethtool_stats [GEM_STATS_LEN ];
1182
+ u64 ethtool_stats [GEM_STATS_LEN + QUEUE_STATS_LEN * MACB_MAX_QUEUES ];
1044
1183
1045
1184
unsigned int rx_frm_len_mask ;
1046
1185
unsigned int jumbo_max_len ;
@@ -1057,6 +1196,11 @@ struct macb {
1057
1196
struct ptp_clock_info ptp_clock_info ;
1058
1197
struct tsu_incr tsu_incr ;
1059
1198
struct hwtstamp_config tstamp_config ;
1199
+
1200
+ /* RX queue filer rule set*/
1201
+ struct ethtool_rx_fs_list rx_fs_list ;
1202
+ spinlock_t rx_fs_lock ;
1203
+ unsigned int max_tuples ;
1060
1204
};
1061
1205
1062
1206
#ifdef CONFIG_MACB_USE_HWSTAMP
0 commit comments