net: mtk_eth_soc: mediatek: fix ppe flow accounting for v1 hardware
authorFelix Fietkau <nbd@nbd.name>
Thu, 20 Apr 2023 21:06:42 +0000 (22:06 +0100)
committerDavid S. Miller <davem@davemloft.net>
Sun, 23 Apr 2023 12:25:49 +0000 (13:25 +0100)
Older chips (like MT7622) use a different bit in ib2 to enable hardware
counter support. Add macros for both and select the appropriate bit.

Fixes: 3fbe4d8c0e53 ("net: ethernet: mtk_eth_soc: ppe: add support for flow accounting")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mediatek/mtk_ppe.c
drivers/net/ethernet/mediatek/mtk_ppe.h

index dd9581334b054ff21e72390cd1c622b3ad23c62e..9129821f3ab8fecd1d4cdbefff090057babddfb5 100644 (file)
@@ -601,6 +601,7 @@ __mtk_foe_entry_commit(struct mtk_ppe *ppe, struct mtk_foe_entry *entry,
        struct mtk_eth *eth = ppe->eth;
        u16 timestamp = mtk_eth_timestamp(eth);
        struct mtk_foe_entry *hwe;
+       u32 val;
 
        if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) {
                entry->ib1 &= ~MTK_FOE_IB1_BIND_TIMESTAMP_V2;
@@ -617,8 +618,13 @@ __mtk_foe_entry_commit(struct mtk_ppe *ppe, struct mtk_foe_entry *entry,
        wmb();
        hwe->ib1 = entry->ib1;
 
-       if (ppe->accounting)
-               *mtk_foe_entry_ib2(eth, hwe) |= MTK_FOE_IB2_MIB_CNT;
+       if (ppe->accounting) {
+               if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2))
+                       val = MTK_FOE_IB2_MIB_CNT_V2;
+               else
+                       val = MTK_FOE_IB2_MIB_CNT;
+               *mtk_foe_entry_ib2(eth, hwe) |= val;
+       }
 
        dma_wmb();
 
index e1aab2e8e262971b0d69aace0f3021da92adebdb..e51de31a52ec6371b1d34e4f5aea8289c498822d 100644 (file)
@@ -55,9 +55,10 @@ enum {
 #define MTK_FOE_IB2_PSE_QOS            BIT(4)
 #define MTK_FOE_IB2_DEST_PORT          GENMASK(7, 5)
 #define MTK_FOE_IB2_MULTICAST          BIT(8)
+#define MTK_FOE_IB2_MIB_CNT            BIT(10)
 
 #define MTK_FOE_IB2_WDMA_QID2          GENMASK(13, 12)
-#define MTK_FOE_IB2_MIB_CNT            BIT(15)
+#define MTK_FOE_IB2_MIB_CNT_V2         BIT(15)
 #define MTK_FOE_IB2_WDMA_DEVIDX                BIT(16)
 #define MTK_FOE_IB2_WDMA_WINFO         BIT(17)