1 From 5d8d05fbf804b4485646d39551ac27452e45afd3 Mon Sep 17 00:00:00 2001
2 From: Lorenzo Bianconi <lorenzo@kernel.org>
3 Date: Tue, 25 Jul 2023 01:52:02 +0100
4 Subject: [PATCH 099/250] net: ethernet: mtk_eth_soc: add version in
7 Introduce version field in mtk_soc_data data structure in order to
8 make mtk_eth driver easier to maintain for chipset configuration
9 codebase. Get rid of MTK_NETSYS_V2 bit in chip capabilities.
10 This is a preliminary patch to introduce support for MT7988 SoC.
12 Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
13 Signed-off-by: Daniel Golle <daniel@makrotopia.org>
14 Link: https://lore.kernel.org/r/e52fae302ca135436e5cdd26d38d87be2da63055.1690246066.git.daniel@makrotopia.org
15 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
17 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 55 +++++++++++--------
18 drivers/net/ethernet/mediatek/mtk_eth_soc.h | 36 +++++++-----
19 drivers/net/ethernet/mediatek/mtk_ppe.c | 18 +++---
20 .../net/ethernet/mediatek/mtk_ppe_offload.c | 2 +-
21 drivers/net/ethernet/mediatek/mtk_wed.c | 4 +-
22 5 files changed, 66 insertions(+), 49 deletions(-)
24 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
25 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
26 @@ -537,7 +537,7 @@ static void mtk_set_queue_speed(struct m
27 FIELD_PREP(MTK_QTX_SCH_MIN_RATE_MAN, 1) |
28 FIELD_PREP(MTK_QTX_SCH_MIN_RATE_EXP, 4) |
29 MTK_QTX_SCH_LEAKY_BUCKET_SIZE;
30 - if (!MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2))
31 + if (mtk_is_netsys_v1(eth))
32 val |= MTK_QTX_SCH_LEAKY_BUCKET_EN;
34 if (IS_ENABLED(CONFIG_SOC_MT7621)) {
35 @@ -912,7 +912,7 @@ static bool mtk_rx_get_desc(struct mtk_e
36 rxd->rxd1 = READ_ONCE(dma_rxd->rxd1);
37 rxd->rxd3 = READ_ONCE(dma_rxd->rxd3);
38 rxd->rxd4 = READ_ONCE(dma_rxd->rxd4);
39 - if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) {
40 + if (mtk_is_netsys_v2_or_greater(eth)) {
41 rxd->rxd5 = READ_ONCE(dma_rxd->rxd5);
42 rxd->rxd6 = READ_ONCE(dma_rxd->rxd6);
44 @@ -970,7 +970,7 @@ static int mtk_init_fq_dma(struct mtk_et
46 txd->txd3 = TX_DMA_PLEN0(MTK_QDMA_PAGE_SIZE);
48 - if (MTK_HAS_CAPS(soc->caps, MTK_NETSYS_V2)) {
49 + if (mtk_is_netsys_v2_or_greater(eth)) {
53 @@ -1159,7 +1159,7 @@ static void mtk_tx_set_dma_desc(struct n
54 struct mtk_mac *mac = netdev_priv(dev);
55 struct mtk_eth *eth = mac->hw;
57 - if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2))
58 + if (mtk_is_netsys_v2_or_greater(eth))
59 mtk_tx_set_dma_desc_v2(dev, txd, info);
61 mtk_tx_set_dma_desc_v1(dev, txd, info);
62 @@ -1466,7 +1466,7 @@ static void mtk_update_rx_cpu_idx(struct
64 static bool mtk_page_pool_enabled(struct mtk_eth *eth)
66 - return MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2);
67 + return eth->soc->version == 2;
70 static struct page_pool *mtk_create_page_pool(struct mtk_eth *eth,
71 @@ -1806,7 +1806,7 @@ static int mtk_poll_rx(struct napi_struc
74 /* find out which mac the packet come from. values start at 1 */
75 - if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2))
76 + if (mtk_is_netsys_v2_or_greater(eth))
77 mac = RX_DMA_GET_SPORT_V2(trxd.rxd5) - 1;
78 else if (!MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628) &&
79 !(trxd.rxd4 & RX_DMA_SPECIAL_TAG))
80 @@ -1902,7 +1902,7 @@ static int mtk_poll_rx(struct napi_struc
84 - if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) {
85 + if (mtk_is_netsys_v2_or_greater(eth)) {
86 reason = FIELD_GET(MTK_RXD5_PPE_CPU_REASON, trxd.rxd5);
87 hash = trxd.rxd5 & MTK_RXD5_FOE_ENTRY;
88 if (hash != MTK_RXD5_FOE_ENTRY)
89 @@ -1927,8 +1927,8 @@ static int mtk_poll_rx(struct napi_struc
90 /* When using VLAN untagging in combination with DSA, the
91 * hardware treats the MTK special tag as a VLAN and untags it.
93 - if (!MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2) &&
94 - (trxd.rxd2 & RX_DMA_VTAG) && netdev_uses_dsa(netdev)) {
95 + if (mtk_is_netsys_v1(eth) && (trxd.rxd2 & RX_DMA_VTAG) &&
96 + netdev_uses_dsa(netdev)) {
97 unsigned int port = RX_DMA_VPID(trxd.rxd3) & GENMASK(2, 0);
99 if (port < ARRAY_SIZE(eth->dsa_meta) &&
100 @@ -2232,7 +2232,7 @@ static int mtk_tx_alloc(struct mtk_eth *
101 txd->txd2 = next_ptr;
102 txd->txd3 = TX_DMA_LS0 | TX_DMA_OWNER_CPU;
104 - if (MTK_HAS_CAPS(soc->caps, MTK_NETSYS_V2)) {
105 + if (mtk_is_netsys_v2_or_greater(eth)) {
109 @@ -2285,14 +2285,14 @@ static int mtk_tx_alloc(struct mtk_eth *
110 FIELD_PREP(MTK_QTX_SCH_MIN_RATE_MAN, 1) |
111 FIELD_PREP(MTK_QTX_SCH_MIN_RATE_EXP, 4) |
112 MTK_QTX_SCH_LEAKY_BUCKET_SIZE;
113 - if (!MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2))
114 + if (mtk_is_netsys_v1(eth))
115 val |= MTK_QTX_SCH_LEAKY_BUCKET_EN;
116 mtk_w32(eth, val, soc->reg_map->qdma.qtx_sch + ofs);
117 ofs += MTK_QTX_OFFSET;
119 val = MTK_QDMA_TX_SCH_MAX_WFQ | (MTK_QDMA_TX_SCH_MAX_WFQ << 16);
120 mtk_w32(eth, val, soc->reg_map->qdma.tx_sch_rate);
121 - if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2))
122 + if (mtk_is_netsys_v2_or_greater(eth))
123 mtk_w32(eth, val, soc->reg_map->qdma.tx_sch_rate + 4);
125 mtk_w32(eth, ring->phys_pdma, MT7628_TX_BASE_PTR0);
126 @@ -2419,7 +2419,7 @@ static int mtk_rx_alloc(struct mtk_eth *
130 - if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) {
131 + if (mtk_is_netsys_v2_or_greater(eth)) {
135 @@ -2970,7 +2970,7 @@ static int mtk_start_dma(struct mtk_eth
136 MTK_TX_BT_32DWORDS | MTK_NDP_CO_PRO |
137 MTK_RX_2B_OFFSET | MTK_TX_WB_DDONE;
139 - if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2))
140 + if (mtk_is_netsys_v2_or_greater(eth))
141 val |= MTK_MUTLI_CNT | MTK_RESV_BUF |
142 MTK_WCOMP_EN | MTK_DMAD_WR_WDONE |
143 MTK_CHK_DDONE_EN | MTK_LEAKY_BUCKET_EN;
144 @@ -3114,7 +3114,7 @@ static int mtk_open(struct net_device *d
145 phylink_start(mac->phylink);
146 netif_tx_start_all_queues(dev);
148 - if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2))
149 + if (mtk_is_netsys_v2_or_greater(eth))
152 if (mtk_uses_dsa(dev) && !eth->prog) {
153 @@ -3379,7 +3379,7 @@ static void mtk_hw_reset(struct mtk_eth
157 - if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) {
158 + if (mtk_is_netsys_v2_or_greater(eth)) {
159 regmap_write(eth->ethsys, ETHSYS_FE_RST_CHK_IDLE_EN, 0);
160 val = RSTCTRL_PPE0_V2;
162 @@ -3391,7 +3391,7 @@ static void mtk_hw_reset(struct mtk_eth
164 ethsys_reset(eth, RSTCTRL_ETH | RSTCTRL_FE | val);
166 - if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2))
167 + if (mtk_is_netsys_v2_or_greater(eth))
168 regmap_write(eth->ethsys, ETHSYS_FE_RST_CHK_IDLE_EN,
171 @@ -3417,7 +3417,7 @@ static void mtk_hw_warm_reset(struct mtk
175 - if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2))
176 + if (mtk_is_netsys_v2_or_greater(eth))
177 rst_mask = RSTCTRL_ETH | RSTCTRL_PPE0_V2;
179 rst_mask = RSTCTRL_ETH | RSTCTRL_PPE0;
180 @@ -3587,7 +3587,7 @@ static int mtk_hw_init(struct mtk_eth *e
184 - if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) {
185 + if (mtk_is_netsys_v2_or_greater(eth)) {
186 /* Set FE to PDMAv2 if necessary */
187 val = mtk_r32(eth, MTK_FE_GLO_MISC);
188 mtk_w32(eth, val | BIT(4), MTK_FE_GLO_MISC);
189 @@ -3624,7 +3624,7 @@ static int mtk_hw_init(struct mtk_eth *e
191 val = mtk_r32(eth, MTK_CDMQ_IG_CTRL);
192 mtk_w32(eth, val | MTK_CDMQ_STAG_EN, MTK_CDMQ_IG_CTRL);
193 - if (!MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) {
194 + if (mtk_is_netsys_v1(eth)) {
195 val = mtk_r32(eth, MTK_CDMP_IG_CTRL);
196 mtk_w32(eth, val | MTK_CDMP_STAG_EN, MTK_CDMP_IG_CTRL);
198 @@ -3646,7 +3646,7 @@ static int mtk_hw_init(struct mtk_eth *e
199 mtk_w32(eth, eth->soc->txrx.rx_irq_done_mask, reg_map->qdma.int_grp + 4);
200 mtk_w32(eth, 0x21021000, MTK_FE_INT_GRP);
202 - if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) {
203 + if (mtk_is_netsys_v2_or_greater(eth)) {
204 /* PSE should not drop port8 and port9 packets from WDMA Tx */
205 mtk_w32(eth, 0x00000300, PSE_DROP_CFG);
207 @@ -4435,7 +4435,7 @@ static int mtk_probe(struct platform_dev
211 - if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) {
212 + if (mtk_is_netsys_v2_or_greater(eth)) {
213 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
216 @@ -4543,9 +4543,8 @@ static int mtk_probe(struct platform_dev
219 if (eth->soc->offload_version) {
221 + u32 num_ppe = mtk_is_netsys_v2_or_greater(eth) ? 2 : 1;
223 - num_ppe = MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2) ? 2 : 1;
224 num_ppe = min_t(u32, ARRAY_SIZE(eth->ppe), num_ppe);
225 for (i = 0; i < num_ppe; i++) {
226 u32 ppe_addr = eth->soc->reg_map->ppe_base + i * 0x400;
227 @@ -4639,6 +4638,7 @@ static const struct mtk_soc_data mt2701_
228 .hw_features = MTK_HW_FEATURES,
229 .required_clks = MT7623_CLKS_BITMAP,
230 .required_pctl = true,
233 .txd_size = sizeof(struct mtk_tx_dma),
234 .rxd_size = sizeof(struct mtk_rx_dma),
235 @@ -4655,6 +4655,7 @@ static const struct mtk_soc_data mt7621_
236 .hw_features = MTK_HW_FEATURES,
237 .required_clks = MT7621_CLKS_BITMAP,
238 .required_pctl = false,
240 .offload_version = 1,
242 .foe_entry_size = MTK_FOE_ENTRY_V1_SIZE,
243 @@ -4675,6 +4676,7 @@ static const struct mtk_soc_data mt7622_
244 .hw_features = MTK_HW_FEATURES,
245 .required_clks = MT7622_CLKS_BITMAP,
246 .required_pctl = false,
248 .offload_version = 2,
250 .has_accounting = true,
251 @@ -4695,6 +4697,7 @@ static const struct mtk_soc_data mt7623_
252 .hw_features = MTK_HW_FEATURES,
253 .required_clks = MT7623_CLKS_BITMAP,
254 .required_pctl = true,
256 .offload_version = 1,
258 .foe_entry_size = MTK_FOE_ENTRY_V1_SIZE,
259 @@ -4717,6 +4720,7 @@ static const struct mtk_soc_data mt7629_
260 .required_clks = MT7629_CLKS_BITMAP,
261 .required_pctl = false,
262 .has_accounting = true,
265 .txd_size = sizeof(struct mtk_tx_dma),
266 .rxd_size = sizeof(struct mtk_rx_dma),
267 @@ -4734,6 +4738,7 @@ static const struct mtk_soc_data mt7981_
268 .hw_features = MTK_HW_FEATURES,
269 .required_clks = MT7981_CLKS_BITMAP,
270 .required_pctl = false,
272 .offload_version = 2,
274 .has_accounting = true,
275 @@ -4755,6 +4760,7 @@ static const struct mtk_soc_data mt7986_
276 .hw_features = MTK_HW_FEATURES,
277 .required_clks = MT7986_CLKS_BITMAP,
278 .required_pctl = false,
280 .offload_version = 2,
282 .has_accounting = true,
283 @@ -4775,6 +4781,7 @@ static const struct mtk_soc_data rt5350_
284 .hw_features = MTK_HW_FEATURES_MT7628,
285 .required_clks = MT7628_CLKS_BITMAP,
286 .required_pctl = false,
289 .txd_size = sizeof(struct mtk_tx_dma),
290 .rxd_size = sizeof(struct mtk_rx_dma),
291 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
292 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
293 @@ -817,7 +817,6 @@ enum mkt_eth_capabilities {
295 MTK_TRGMII_MT7621_CLK_BIT,
299 MTK_RSTCTRL_PPE1_BIT,
301 @@ -852,7 +851,6 @@ enum mkt_eth_capabilities {
302 #define MTK_SHARED_INT BIT(MTK_SHARED_INT_BIT)
303 #define MTK_TRGMII_MT7621_CLK BIT(MTK_TRGMII_MT7621_CLK_BIT)
304 #define MTK_QDMA BIT(MTK_QDMA_BIT)
305 -#define MTK_NETSYS_V2 BIT(MTK_NETSYS_V2_BIT)
306 #define MTK_SOC_MT7628 BIT(MTK_SOC_MT7628_BIT)
307 #define MTK_RSTCTRL_PPE1 BIT(MTK_RSTCTRL_PPE1_BIT)
308 #define MTK_U3_COPHY_V2 BIT(MTK_U3_COPHY_V2_BIT)
309 @@ -931,11 +929,11 @@ enum mkt_eth_capabilities {
310 #define MT7981_CAPS (MTK_GMAC1_SGMII | MTK_GMAC2_SGMII | MTK_GMAC2_GEPHY | \
311 MTK_MUX_GMAC12_TO_GEPHY_SGMII | MTK_QDMA | \
312 MTK_MUX_U3_GMAC2_TO_QPHY | MTK_U3_COPHY_V2 | \
313 - MTK_NETSYS_V2 | MTK_RSTCTRL_PPE1)
316 #define MT7986_CAPS (MTK_GMAC1_SGMII | MTK_GMAC2_SGMII | \
317 MTK_MUX_GMAC12_TO_GEPHY_SGMII | MTK_QDMA | \
318 - MTK_NETSYS_V2 | MTK_RSTCTRL_PPE1)
321 struct mtk_tx_dma_desc_info {
323 @@ -1006,6 +1004,7 @@ struct mtk_reg_map {
324 * @required_pctl A bool value to show whether the SoC requires
325 * the extra setup for those pins used by GMAC.
326 * @hash_offset Flow table hash offset.
327 + * @version SoC version.
328 * @foe_entry_size Foe table entry size.
329 * @has_accounting Bool indicating support for accounting of
331 @@ -1024,6 +1023,7 @@ struct mtk_soc_data {
337 netdev_features_t hw_features;
339 @@ -1180,6 +1180,16 @@ struct mtk_mac {
340 /* the struct describing the SoC. these are declared in the soc_xyz.c files */
341 extern const struct of_device_id of_mtk_match[];
343 +static inline bool mtk_is_netsys_v1(struct mtk_eth *eth)
345 + return eth->soc->version == 1;
348 +static inline bool mtk_is_netsys_v2_or_greater(struct mtk_eth *eth)
350 + return eth->soc->version > 1;
353 static inline struct mtk_foe_entry *
354 mtk_foe_get_entry(struct mtk_ppe *ppe, u16 hash)
356 @@ -1190,7 +1200,7 @@ mtk_foe_get_entry(struct mtk_ppe *ppe, u
358 static inline u32 mtk_get_ib1_ts_mask(struct mtk_eth *eth)
360 - if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2))
361 + if (mtk_is_netsys_v2_or_greater(eth))
362 return MTK_FOE_IB1_BIND_TIMESTAMP_V2;
364 return MTK_FOE_IB1_BIND_TIMESTAMP;
365 @@ -1198,7 +1208,7 @@ static inline u32 mtk_get_ib1_ts_mask(st
367 static inline u32 mtk_get_ib1_ppoe_mask(struct mtk_eth *eth)
369 - if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2))
370 + if (mtk_is_netsys_v2_or_greater(eth))
371 return MTK_FOE_IB1_BIND_PPPOE_V2;
373 return MTK_FOE_IB1_BIND_PPPOE;
374 @@ -1206,7 +1216,7 @@ static inline u32 mtk_get_ib1_ppoe_mask(
376 static inline u32 mtk_get_ib1_vlan_tag_mask(struct mtk_eth *eth)
378 - if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2))
379 + if (mtk_is_netsys_v2_or_greater(eth))
380 return MTK_FOE_IB1_BIND_VLAN_TAG_V2;
382 return MTK_FOE_IB1_BIND_VLAN_TAG;
383 @@ -1214,7 +1224,7 @@ static inline u32 mtk_get_ib1_vlan_tag_m
385 static inline u32 mtk_get_ib1_vlan_layer_mask(struct mtk_eth *eth)
387 - if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2))
388 + if (mtk_is_netsys_v2_or_greater(eth))
389 return MTK_FOE_IB1_BIND_VLAN_LAYER_V2;
391 return MTK_FOE_IB1_BIND_VLAN_LAYER;
392 @@ -1222,7 +1232,7 @@ static inline u32 mtk_get_ib1_vlan_layer
394 static inline u32 mtk_prep_ib1_vlan_layer(struct mtk_eth *eth, u32 val)
396 - if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2))
397 + if (mtk_is_netsys_v2_or_greater(eth))
398 return FIELD_PREP(MTK_FOE_IB1_BIND_VLAN_LAYER_V2, val);
400 return FIELD_PREP(MTK_FOE_IB1_BIND_VLAN_LAYER, val);
401 @@ -1230,7 +1240,7 @@ static inline u32 mtk_prep_ib1_vlan_laye
403 static inline u32 mtk_get_ib1_vlan_layer(struct mtk_eth *eth, u32 val)
405 - if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2))
406 + if (mtk_is_netsys_v2_or_greater(eth))
407 return FIELD_GET(MTK_FOE_IB1_BIND_VLAN_LAYER_V2, val);
409 return FIELD_GET(MTK_FOE_IB1_BIND_VLAN_LAYER, val);
410 @@ -1238,7 +1248,7 @@ static inline u32 mtk_get_ib1_vlan_layer
412 static inline u32 mtk_get_ib1_pkt_type_mask(struct mtk_eth *eth)
414 - if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2))
415 + if (mtk_is_netsys_v2_or_greater(eth))
416 return MTK_FOE_IB1_PACKET_TYPE_V2;
418 return MTK_FOE_IB1_PACKET_TYPE;
419 @@ -1246,7 +1256,7 @@ static inline u32 mtk_get_ib1_pkt_type_m
421 static inline u32 mtk_get_ib1_pkt_type(struct mtk_eth *eth, u32 val)
423 - if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2))
424 + if (mtk_is_netsys_v2_or_greater(eth))
425 return FIELD_GET(MTK_FOE_IB1_PACKET_TYPE_V2, val);
427 return FIELD_GET(MTK_FOE_IB1_PACKET_TYPE, val);
428 @@ -1254,7 +1264,7 @@ static inline u32 mtk_get_ib1_pkt_type(s
430 static inline u32 mtk_get_ib2_multicast_mask(struct mtk_eth *eth)
432 - if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2))
433 + if (mtk_is_netsys_v2_or_greater(eth))
434 return MTK_FOE_IB2_MULTICAST_V2;
436 return MTK_FOE_IB2_MULTICAST;
437 --- a/drivers/net/ethernet/mediatek/mtk_ppe.c
438 +++ b/drivers/net/ethernet/mediatek/mtk_ppe.c
439 @@ -207,7 +207,7 @@ int mtk_foe_entry_prepare(struct mtk_eth
441 memset(entry, 0, sizeof(*entry));
443 - if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) {
444 + if (mtk_is_netsys_v2_or_greater(eth)) {
445 val = FIELD_PREP(MTK_FOE_IB1_STATE, MTK_FOE_STATE_BIND) |
446 FIELD_PREP(MTK_FOE_IB1_PACKET_TYPE_V2, type) |
447 FIELD_PREP(MTK_FOE_IB1_UDP, l4proto == IPPROTO_UDP) |
448 @@ -271,7 +271,7 @@ int mtk_foe_entry_set_pse_port(struct mt
449 u32 *ib2 = mtk_foe_entry_ib2(eth, entry);
452 - if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) {
453 + if (mtk_is_netsys_v2_or_greater(eth)) {
454 val &= ~MTK_FOE_IB2_DEST_PORT_V2;
455 val |= FIELD_PREP(MTK_FOE_IB2_DEST_PORT_V2, port);
457 @@ -422,7 +422,7 @@ int mtk_foe_entry_set_wdma(struct mtk_et
458 struct mtk_foe_mac_info *l2 = mtk_foe_entry_l2(eth, entry);
459 u32 *ib2 = mtk_foe_entry_ib2(eth, entry);
461 - if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) {
462 + if (mtk_is_netsys_v2_or_greater(eth)) {
463 *ib2 &= ~MTK_FOE_IB2_PORT_MG_V2;
464 *ib2 |= FIELD_PREP(MTK_FOE_IB2_RX_IDX, txq) |
465 MTK_FOE_IB2_WDMA_WINFO_V2;
466 @@ -452,7 +452,7 @@ int mtk_foe_entry_set_queue(struct mtk_e
468 u32 *ib2 = mtk_foe_entry_ib2(eth, entry);
470 - if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) {
471 + if (mtk_is_netsys_v2_or_greater(eth)) {
472 *ib2 &= ~MTK_FOE_IB2_QID_V2;
473 *ib2 |= FIELD_PREP(MTK_FOE_IB2_QID_V2, queue);
474 *ib2 |= MTK_FOE_IB2_PSE_QOS_V2;
475 @@ -607,7 +607,7 @@ __mtk_foe_entry_commit(struct mtk_ppe *p
476 struct mtk_foe_entry *hwe;
479 - if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) {
480 + if (mtk_is_netsys_v2_or_greater(eth)) {
481 entry->ib1 &= ~MTK_FOE_IB1_BIND_TIMESTAMP_V2;
482 entry->ib1 |= FIELD_PREP(MTK_FOE_IB1_BIND_TIMESTAMP_V2,
484 @@ -623,7 +623,7 @@ __mtk_foe_entry_commit(struct mtk_ppe *p
485 hwe->ib1 = entry->ib1;
487 if (ppe->accounting) {
488 - if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2))
489 + if (mtk_is_netsys_v2_or_greater(eth))
490 val = MTK_FOE_IB2_MIB_CNT_V2;
492 val = MTK_FOE_IB2_MIB_CNT;
493 @@ -971,7 +971,7 @@ void mtk_ppe_start(struct mtk_ppe *ppe)
494 MTK_PPE_SCAN_MODE_KEEPALIVE_AGE) |
495 FIELD_PREP(MTK_PPE_TB_CFG_ENTRY_NUM,
496 MTK_PPE_ENTRIES_SHIFT);
497 - if (MTK_HAS_CAPS(ppe->eth->soc->caps, MTK_NETSYS_V2))
498 + if (mtk_is_netsys_v2_or_greater(ppe->eth))
499 val |= MTK_PPE_TB_CFG_INFO_SEL;
500 ppe_w32(ppe, MTK_PPE_TB_CFG, val);
502 @@ -987,7 +987,7 @@ void mtk_ppe_start(struct mtk_ppe *ppe)
503 MTK_PPE_FLOW_CFG_IP4_NAPT |
504 MTK_PPE_FLOW_CFG_IP4_DSLITE |
505 MTK_PPE_FLOW_CFG_IP4_NAT_FRAG;
506 - if (MTK_HAS_CAPS(ppe->eth->soc->caps, MTK_NETSYS_V2))
507 + if (mtk_is_netsys_v2_or_greater(ppe->eth))
508 val |= MTK_PPE_MD_TOAP_BYP_CRSN0 |
509 MTK_PPE_MD_TOAP_BYP_CRSN1 |
510 MTK_PPE_MD_TOAP_BYP_CRSN2 |
511 @@ -1029,7 +1029,7 @@ void mtk_ppe_start(struct mtk_ppe *ppe)
513 ppe_w32(ppe, MTK_PPE_DEFAULT_CPU_PORT, 0);
515 - if (MTK_HAS_CAPS(ppe->eth->soc->caps, MTK_NETSYS_V2)) {
516 + if (mtk_is_netsys_v2_or_greater(ppe->eth)) {
517 ppe_w32(ppe, MTK_PPE_DEFAULT_CPU_PORT1, 0xcb777);
518 ppe_w32(ppe, MTK_PPE_SBW_CTRL, 0x7f);
520 --- a/drivers/net/ethernet/mediatek/mtk_ppe_offload.c
521 +++ b/drivers/net/ethernet/mediatek/mtk_ppe_offload.c
522 @@ -193,7 +193,7 @@ mtk_flow_set_output_device(struct mtk_et
523 if (mtk_flow_get_wdma_info(dev, dest_mac, &info) == 0) {
524 mtk_foe_entry_set_wdma(eth, foe, info.wdma_idx, info.queue,
525 info.bss, info.wcid);
526 - if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) {
527 + if (mtk_is_netsys_v2_or_greater(eth)) {
528 switch (info.wdma_idx) {
531 --- a/drivers/net/ethernet/mediatek/mtk_wed.c
532 +++ b/drivers/net/ethernet/mediatek/mtk_wed.c
533 @@ -1091,7 +1091,7 @@ mtk_wed_rx_reset(struct mtk_wed_device *
535 struct mtk_eth *eth = dev->hw->eth;
537 - if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2))
538 + if (mtk_is_netsys_v2_or_greater(eth))
539 wed_set(dev, MTK_WED_RESET_IDX,
540 MTK_WED_RESET_IDX_RX_V2);
542 @@ -1813,7 +1813,7 @@ void mtk_wed_add_hw(struct device_node *
546 - hw->version = MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2) ? 2 : 1;
547 + hw->version = mtk_is_netsys_v1(eth) ? 1 : 2;
549 if (hw->version == 1) {
550 hw->mirror = syscon_regmap_lookup_by_phandle(eth_np,