1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Wed, 24 Mar 2021 02:30:52 +0100
3 Subject: [PATCH] net: ethernet: mtk_eth_soc: fix parsing packets in GDM
5 When using DSA, set the special tag in GDM ingress control to allow the MAC
6 to parse packets properly earlier. This affects rx DMA source port reporting.
8 Signed-off-by: Felix Fietkau <nbd@nbd.name>
9 Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
12 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
13 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
15 #include <linux/interrupt.h>
16 #include <linux/pinctrl/devinfo.h>
17 #include <linux/phylink.h>
20 #include "mtk_eth_soc.h"
22 @@ -1285,13 +1286,12 @@ static int mtk_poll_rx(struct napi_struc
25 /* find out which mac the packet come from. values start at 1 */
26 - if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628)) {
27 + if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628) ||
28 + (trxd.rxd4 & RX_DMA_SPECIAL_TAG))
31 - mac = (trxd.rxd4 >> RX_DMA_FPORT_SHIFT) &
36 + mac = ((trxd.rxd4 >> RX_DMA_FPORT_SHIFT) &
37 + RX_DMA_FPORT_MASK) - 1;
39 if (unlikely(mac < 0 || mac >= MTK_MAC_COUNT ||
41 @@ -2257,6 +2257,9 @@ static void mtk_gdm_config(struct mtk_et
45 + if (!i && eth->netdev[0] && netdev_uses_dsa(eth->netdev[0]))
46 + val |= MTK_GDMA_SPECIAL_TAG;
48 mtk_w32(eth, val, MTK_GDMA_FWD_CFG(i));
50 /* Reset and enable PSE */
51 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
52 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
55 /* GDM Exgress Control Register */
56 #define MTK_GDMA_FWD_CFG(x) (0x500 + (x * 0x1000))
57 +#define MTK_GDMA_SPECIAL_TAG BIT(24)
58 #define MTK_GDMA_ICS_EN BIT(22)
59 #define MTK_GDMA_TCS_EN BIT(21)
60 #define MTK_GDMA_UCS_EN BIT(20)
62 #define RX_DMA_L4_VALID_PDMA BIT(30) /* when PDMA is used */
63 #define RX_DMA_FPORT_SHIFT 19
64 #define RX_DMA_FPORT_MASK 0x7
65 +#define RX_DMA_SPECIAL_TAG BIT(22)
67 /* PHY Indirect Access Control registers */
68 #define MTK_PHY_IAC 0x10004