forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/drivers/net/ethernet/stmicro/stmmac/hwif.h
....@@ -1,4 +1,4 @@
1
-// SPDX-License-Identifier: (GPL-2.0 OR MIT)
1
+/* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
22 // Copyright (c) 2018 Synopsys, Inc. and/or its affiliates.
33 // stmmac HW Interface Callbacks
44
....@@ -6,6 +6,7 @@
66 #define __STMMAC_HWIF_H__
77
88 #include <linux/netdevice.h>
9
+#include <linux/stmmac.h>
910
1011 #define stmmac_do_void_callback(__priv, __module, __cname, __arg0, __args...) \
1112 ({ \
....@@ -28,6 +29,7 @@
2829 struct stmmac_safety_stats;
2930 struct dma_desc;
3031 struct dma_extended_desc;
32
+struct dma_edesc;
3133
3234 /* Descriptors helpers */
3335 struct stmmac_desc_ops {
....@@ -76,7 +78,8 @@
7678 /* get rx timestamp status */
7779 int (*get_rx_timestamp_status)(void *desc, void *next_desc, u32 ats);
7880 /* Display ring */
79
- void (*display_ring)(void *head, unsigned int size, bool rx);
81
+ void (*display_ring)(void *head, unsigned int size, bool rx,
82
+ dma_addr_t dma_rx_phy, unsigned int desc_size);
8083 /* set MSS via context descriptor */
8184 void (*set_mss)(struct dma_desc *p, unsigned int mss);
8285 /* get descriptor skbuff address */
....@@ -85,6 +88,16 @@
8588 void (*set_addr)(struct dma_desc *p, dma_addr_t addr);
8689 /* clear descriptor */
8790 void (*clear)(struct dma_desc *p);
91
+ /* RSS */
92
+ int (*get_rx_hash)(struct dma_desc *p, u32 *hash,
93
+ enum pkt_hash_types *type);
94
+ void (*get_rx_header_len)(struct dma_desc *p, unsigned int *len);
95
+ void (*set_sec_addr)(struct dma_desc *p, dma_addr_t addr, bool buf2_valid);
96
+ void (*set_sarc)(struct dma_desc *p, u32 sarc_type);
97
+ void (*set_vlan_tag)(struct dma_desc *p, u16 tag, u16 inner_tag,
98
+ u32 inner_type);
99
+ void (*set_vlan)(struct dma_desc *p, u32 type);
100
+ void (*set_tbs)(struct dma_edesc *p, u32 sec, u32 nsec);
88101 };
89102
90103 #define stmmac_init_rx_desc(__priv, __args...) \
....@@ -135,6 +148,20 @@
135148 stmmac_do_void_callback(__priv, desc, set_addr, __args)
136149 #define stmmac_clear_desc(__priv, __args...) \
137150 stmmac_do_void_callback(__priv, desc, clear, __args)
151
+#define stmmac_get_rx_hash(__priv, __args...) \
152
+ stmmac_do_callback(__priv, desc, get_rx_hash, __args)
153
+#define stmmac_get_rx_header_len(__priv, __args...) \
154
+ stmmac_do_void_callback(__priv, desc, get_rx_header_len, __args)
155
+#define stmmac_set_desc_sec_addr(__priv, __args...) \
156
+ stmmac_do_void_callback(__priv, desc, set_sec_addr, __args)
157
+#define stmmac_set_desc_sarc(__priv, __args...) \
158
+ stmmac_do_void_callback(__priv, desc, set_sarc, __args)
159
+#define stmmac_set_desc_vlan_tag(__priv, __args...) \
160
+ stmmac_do_void_callback(__priv, desc, set_vlan_tag, __args)
161
+#define stmmac_set_desc_vlan(__priv, __args...) \
162
+ stmmac_do_void_callback(__priv, desc, set_vlan, __args)
163
+#define stmmac_set_desc_tbs(__priv, __args...) \
164
+ stmmac_do_void_callback(__priv, desc, set_tbs, __args)
138165
139166 struct stmmac_dma_cfg;
140167 struct dma_features;
....@@ -149,10 +176,10 @@
149176 struct stmmac_dma_cfg *dma_cfg, u32 chan);
150177 void (*init_rx_chan)(void __iomem *ioaddr,
151178 struct stmmac_dma_cfg *dma_cfg,
152
- u32 dma_rx_phy, u32 chan);
179
+ dma_addr_t phy, u32 chan);
153180 void (*init_tx_chan)(void __iomem *ioaddr,
154181 struct stmmac_dma_cfg *dma_cfg,
155
- u32 dma_tx_phy, u32 chan);
182
+ dma_addr_t phy, u32 chan);
156183 /* Configure the AXI Bus Mode Register */
157184 void (*axi)(void __iomem *ioaddr, struct stmmac_axi *axi);
158185 /* Dump DMA registers */
....@@ -165,8 +192,10 @@
165192 void (*dma_diagnostic_fr) (void *data, struct stmmac_extra_stats *x,
166193 void __iomem *ioaddr);
167194 void (*enable_dma_transmission) (void __iomem *ioaddr);
168
- void (*enable_dma_irq)(void __iomem *ioaddr, u32 chan);
169
- void (*disable_dma_irq)(void __iomem *ioaddr, u32 chan);
195
+ void (*enable_dma_irq)(void __iomem *ioaddr, u32 chan,
196
+ bool rx, bool tx);
197
+ void (*disable_dma_irq)(void __iomem *ioaddr, u32 chan,
198
+ bool rx, bool tx);
170199 void (*start_tx)(void __iomem *ioaddr, u32 chan);
171200 void (*stop_tx)(void __iomem *ioaddr, u32 chan);
172201 void (*start_rx)(void __iomem *ioaddr, u32 chan);
....@@ -174,8 +203,8 @@
174203 int (*dma_interrupt) (void __iomem *ioaddr,
175204 struct stmmac_extra_stats *x, u32 chan);
176205 /* If supported then get the optional core features */
177
- void (*get_hw_feature)(void __iomem *ioaddr,
178
- struct dma_features *dma_cap);
206
+ int (*get_hw_feature)(void __iomem *ioaddr,
207
+ struct dma_features *dma_cap);
179208 /* Program the HW RX Watchdog */
180209 void (*rx_watchdog)(void __iomem *ioaddr, u32 riwt, u32 number_chan);
181210 void (*set_tx_ring_len)(void __iomem *ioaddr, u32 len, u32 chan);
....@@ -185,6 +214,8 @@
185214 void (*enable_tso)(void __iomem *ioaddr, bool en, u32 chan);
186215 void (*qmode)(void __iomem *ioaddr, u32 channel, u8 qmode);
187216 void (*set_bfsize)(void __iomem *ioaddr, int bfsize, u32 chan);
217
+ void (*enable_sph)(void __iomem *ioaddr, bool en, u32 chan);
218
+ int (*enable_tbs)(void __iomem *ioaddr, bool en, u32 chan);
188219 };
189220
190221 #define stmmac_reset(__priv, __args...) \
....@@ -224,7 +255,7 @@
224255 #define stmmac_dma_interrupt_status(__priv, __args...) \
225256 stmmac_do_callback(__priv, dma, dma_interrupt, __args)
226257 #define stmmac_get_hw_feature(__priv, __args...) \
227
- stmmac_do_void_callback(__priv, dma, get_hw_feature, __args)
258
+ stmmac_do_callback(__priv, dma, get_hw_feature, __args)
228259 #define stmmac_rx_watchdog(__priv, __args...) \
229260 stmmac_do_void_callback(__priv, dma, rx_watchdog, __args)
230261 #define stmmac_set_tx_ring_len(__priv, __args...) \
....@@ -241,6 +272,10 @@
241272 stmmac_do_void_callback(__priv, dma, qmode, __args)
242273 #define stmmac_set_dma_bfsize(__priv, __args...) \
243274 stmmac_do_void_callback(__priv, dma, set_bfsize, __args)
275
+#define stmmac_enable_sph(__priv, __args...) \
276
+ stmmac_do_void_callback(__priv, dma, enable_sph, __args)
277
+#define stmmac_enable_tbs(__priv, __args...) \
278
+ stmmac_do_callback(__priv, dma, enable_tbs, __args)
244279
245280 struct mac_device_info;
246281 struct net_device;
....@@ -248,6 +283,8 @@
248283 struct stmmac_safety_stats;
249284 struct stmmac_tc_entry;
250285 struct stmmac_pps_cfg;
286
+struct stmmac_rss;
287
+struct stmmac_est;
251288
252289 /* Helpers to program the MAC core */
253290 struct stmmac_ops {
....@@ -324,6 +361,39 @@
324361 int (*flex_pps_config)(void __iomem *ioaddr, int index,
325362 struct stmmac_pps_cfg *cfg, bool enable,
326363 u32 sub_second_inc, u32 systime_flags);
364
+ /* Loopback for selftests */
365
+ void (*set_mac_loopback)(void __iomem *ioaddr, bool enable);
366
+ /* RSS */
367
+ int (*rss_configure)(struct mac_device_info *hw,
368
+ struct stmmac_rss *cfg, u32 num_rxq);
369
+ /* VLAN */
370
+ void (*update_vlan_hash)(struct mac_device_info *hw, u32 hash,
371
+ __le16 perfect_match, bool is_double);
372
+ void (*enable_vlan)(struct mac_device_info *hw, u32 type);
373
+ int (*add_hw_vlan_rx_fltr)(struct net_device *dev,
374
+ struct mac_device_info *hw,
375
+ __be16 proto, u16 vid);
376
+ int (*del_hw_vlan_rx_fltr)(struct net_device *dev,
377
+ struct mac_device_info *hw,
378
+ __be16 proto, u16 vid);
379
+ void (*restore_hw_vlan_rx_fltr)(struct net_device *dev,
380
+ struct mac_device_info *hw);
381
+ /* TX Timestamp */
382
+ int (*get_mac_tx_timestamp)(struct mac_device_info *hw, u64 *ts);
383
+ /* Source Address Insertion / Replacement */
384
+ void (*sarc_configure)(void __iomem *ioaddr, int val);
385
+ /* Filtering */
386
+ int (*config_l3_filter)(struct mac_device_info *hw, u32 filter_no,
387
+ bool en, bool ipv6, bool sa, bool inv,
388
+ u32 match);
389
+ int (*config_l4_filter)(struct mac_device_info *hw, u32 filter_no,
390
+ bool en, bool udp, bool sa, bool inv,
391
+ u32 match);
392
+ void (*set_arp_offload)(struct mac_device_info *hw, bool en, u32 addr);
393
+ int (*est_configure)(void __iomem *ioaddr, struct stmmac_est *cfg,
394
+ unsigned int ptp_rate);
395
+ void (*fpe_configure)(void __iomem *ioaddr, u32 num_txq, u32 num_rxq,
396
+ bool enable);
327397 };
328398
329399 #define stmmac_core_init(__priv, __args...) \
....@@ -392,6 +462,34 @@
392462 stmmac_do_callback(__priv, mac, rxp_config, __args)
393463 #define stmmac_flex_pps_config(__priv, __args...) \
394464 stmmac_do_callback(__priv, mac, flex_pps_config, __args)
465
+#define stmmac_set_mac_loopback(__priv, __args...) \
466
+ stmmac_do_void_callback(__priv, mac, set_mac_loopback, __args)
467
+#define stmmac_rss_configure(__priv, __args...) \
468
+ stmmac_do_callback(__priv, mac, rss_configure, __args)
469
+#define stmmac_update_vlan_hash(__priv, __args...) \
470
+ stmmac_do_void_callback(__priv, mac, update_vlan_hash, __args)
471
+#define stmmac_enable_vlan(__priv, __args...) \
472
+ stmmac_do_void_callback(__priv, mac, enable_vlan, __args)
473
+#define stmmac_add_hw_vlan_rx_fltr(__priv, __args...) \
474
+ stmmac_do_callback(__priv, mac, add_hw_vlan_rx_fltr, __args)
475
+#define stmmac_del_hw_vlan_rx_fltr(__priv, __args...) \
476
+ stmmac_do_callback(__priv, mac, del_hw_vlan_rx_fltr, __args)
477
+#define stmmac_restore_hw_vlan_rx_fltr(__priv, __args...) \
478
+ stmmac_do_void_callback(__priv, mac, restore_hw_vlan_rx_fltr, __args)
479
+#define stmmac_get_mac_tx_timestamp(__priv, __args...) \
480
+ stmmac_do_callback(__priv, mac, get_mac_tx_timestamp, __args)
481
+#define stmmac_sarc_configure(__priv, __args...) \
482
+ stmmac_do_void_callback(__priv, mac, sarc_configure, __args)
483
+#define stmmac_config_l3_filter(__priv, __args...) \
484
+ stmmac_do_callback(__priv, mac, config_l3_filter, __args)
485
+#define stmmac_config_l4_filter(__priv, __args...) \
486
+ stmmac_do_callback(__priv, mac, config_l4_filter, __args)
487
+#define stmmac_set_arp_offload(__priv, __args...) \
488
+ stmmac_do_void_callback(__priv, mac, set_arp_offload, __args)
489
+#define stmmac_est_configure(__priv, __args...) \
490
+ stmmac_do_callback(__priv, mac, est_configure, __args)
491
+#define stmmac_fpe_configure(__priv, __args...) \
492
+ stmmac_do_void_callback(__priv, mac, fpe_configure, __args)
395493
396494 /* PTP and HW Timer helpers */
397495 struct stmmac_hwtimestamp {
....@@ -448,6 +546,9 @@
448546 struct stmmac_priv;
449547 struct tc_cls_u32_offload;
450548 struct tc_cbs_qopt_offload;
549
+struct flow_cls_offload;
550
+struct tc_taprio_qopt_offload;
551
+struct tc_etf_qopt_offload;
451552
452553 struct stmmac_tc_ops {
453554 int (*init)(struct stmmac_priv *priv);
....@@ -455,6 +556,12 @@
455556 struct tc_cls_u32_offload *cls);
456557 int (*setup_cbs)(struct stmmac_priv *priv,
457558 struct tc_cbs_qopt_offload *qopt);
559
+ int (*setup_cls)(struct stmmac_priv *priv,
560
+ struct flow_cls_offload *cls);
561
+ int (*setup_taprio)(struct stmmac_priv *priv,
562
+ struct tc_taprio_qopt_offload *qopt);
563
+ int (*setup_etf)(struct stmmac_priv *priv,
564
+ struct tc_etf_qopt_offload *qopt);
458565 };
459566
460567 #define stmmac_tc_init(__priv, __args...) \
....@@ -463,6 +570,39 @@
463570 stmmac_do_callback(__priv, tc, setup_cls_u32, __args)
464571 #define stmmac_tc_setup_cbs(__priv, __args...) \
465572 stmmac_do_callback(__priv, tc, setup_cbs, __args)
573
+#define stmmac_tc_setup_cls(__priv, __args...) \
574
+ stmmac_do_callback(__priv, tc, setup_cls, __args)
575
+#define stmmac_tc_setup_taprio(__priv, __args...) \
576
+ stmmac_do_callback(__priv, tc, setup_taprio, __args)
577
+#define stmmac_tc_setup_etf(__priv, __args...) \
578
+ stmmac_do_callback(__priv, tc, setup_etf, __args)
579
+
580
+struct stmmac_counters;
581
+
582
+struct stmmac_mmc_ops {
583
+ void (*ctrl)(void __iomem *ioaddr, unsigned int mode);
584
+ void (*intr_all_mask)(void __iomem *ioaddr);
585
+ void (*read)(void __iomem *ioaddr, struct stmmac_counters *mmc);
586
+};
587
+
588
+#define stmmac_mmc_ctrl(__priv, __args...) \
589
+ stmmac_do_void_callback(__priv, mmc, ctrl, __args)
590
+#define stmmac_mmc_intr_all_mask(__priv, __args...) \
591
+ stmmac_do_void_callback(__priv, mmc, intr_all_mask, __args)
592
+#define stmmac_mmc_read(__priv, __args...) \
593
+ stmmac_do_void_callback(__priv, mmc, read, __args)
594
+
595
+/* XPCS callbacks */
596
+#define stmmac_xpcs_validate(__priv, __args...) \
597
+ stmmac_do_callback(__priv, xpcs, validate, __args)
598
+#define stmmac_xpcs_config(__priv, __args...) \
599
+ stmmac_do_callback(__priv, xpcs, config, __args)
600
+#define stmmac_xpcs_get_state(__priv, __args...) \
601
+ stmmac_do_callback(__priv, xpcs, get_state, __args)
602
+#define stmmac_xpcs_link_up(__priv, __args...) \
603
+ stmmac_do_callback(__priv, xpcs, link_up, __args)
604
+#define stmmac_xpcs_probe(__priv, __args...) \
605
+ stmmac_do_callback(__priv, xpcs, probe, __args)
466606
467607 struct stmmac_regs_off {
468608 u32 ptp_off;
....@@ -480,8 +620,11 @@
480620 extern const struct stmmac_ops dwmac510_ops;
481621 extern const struct stmmac_tc_ops dwmac510_tc_ops;
482622 extern const struct stmmac_ops dwxgmac210_ops;
623
+extern const struct stmmac_ops dwxlgmac2_ops;
483624 extern const struct stmmac_dma_ops dwxgmac210_dma_ops;
484625 extern const struct stmmac_desc_ops dwxgmac210_desc_ops;
626
+extern const struct stmmac_mmc_ops dwmac_mmc_ops;
627
+extern const struct stmmac_mmc_ops dwxgmac_mmc_ops;
485628
486629 #define GMAC_VERSION 0x00000020 /* GMAC CORE Version */
487630 #define GMAC4_VERSION 0x00000110 /* GMAC4+ CORE Version */