Skip to content

Commit d5c53da

Browse files
nbd168davem330
authored andcommitted
net: ethernet: mtk_eth_soc: fix parsing packets in GDM
When using DSA, set the special tag in GDM ingress control to allow the MAC to parse packets properly earlier. This affects rx DMA source port reporting. Signed-off-by: Felix Fietkau <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3fb24a4 commit d5c53da

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

drivers/net/ethernet/mediatek/mtk_eth_soc.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <linux/interrupt.h>
2020
#include <linux/pinctrl/devinfo.h>
2121
#include <linux/phylink.h>
22+
#include <net/dsa.h>
2223

2324
#include "mtk_eth_soc.h"
2425

@@ -1264,13 +1265,12 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget,
12641265
break;
12651266

12661267
/* find out which mac the packet come from. values start at 1 */
1267-
if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628)) {
1268+
if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628) ||
1269+
(trxd.rxd4 & RX_DMA_SPECIAL_TAG))
12681270
mac = 0;
1269-
} else {
1270-
mac = (trxd.rxd4 >> RX_DMA_FPORT_SHIFT) &
1271-
RX_DMA_FPORT_MASK;
1272-
mac--;
1273-
}
1271+
else
1272+
mac = ((trxd.rxd4 >> RX_DMA_FPORT_SHIFT) &
1273+
RX_DMA_FPORT_MASK) - 1;
12741274

12751275
if (unlikely(mac < 0 || mac >= MTK_MAC_COUNT ||
12761276
!eth->netdev[mac]))
@@ -2233,6 +2233,9 @@ static void mtk_gdm_config(struct mtk_eth *eth, u32 config)
22332233

22342234
val |= config;
22352235

2236+
if (!i && eth->netdev[0] && netdev_uses_dsa(eth->netdev[0]))
2237+
val |= MTK_GDMA_SPECIAL_TAG;
2238+
22362239
mtk_w32(eth, val, MTK_GDMA_FWD_CFG(i));
22372240
}
22382241
/* Reset and enable PSE */

drivers/net/ethernet/mediatek/mtk_eth_soc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282

8383
/* GDM Exgress Control Register */
8484
#define MTK_GDMA_FWD_CFG(x) (0x500 + (x * 0x1000))
85+
#define MTK_GDMA_SPECIAL_TAG BIT(24)
8586
#define MTK_GDMA_ICS_EN BIT(22)
8687
#define MTK_GDMA_TCS_EN BIT(21)
8788
#define MTK_GDMA_UCS_EN BIT(20)
@@ -305,6 +306,7 @@
305306
#define RX_DMA_L4_VALID_PDMA BIT(30) /* when PDMA is used */
306307
#define RX_DMA_FPORT_SHIFT 19
307308
#define RX_DMA_FPORT_MASK 0x7
309+
#define RX_DMA_SPECIAL_TAG BIT(22)
308310

309311
/* PHY Indirect Access Control registers */
310312
#define MTK_PHY_IAC 0x10004

0 commit comments

Comments
 (0)