kernel: bump 6.1 to 6.1.63
[openwrt/openwrt.git] / target / linux / generic / pending-6.1 / 736-04-net-ethernet-mediatek-fix-ppe-flow-accounting-for-L2.patch
index fdc3d520c119fc29e090ea9fc1af1818195b627a..d1c153c086b9b6d4f99bb999c56becff989e5813 100644 (file)
@@ -27,7 +27,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
  
        if (ret)
                dev_err(ppe->dev, "MIB table busy");
-@@ -90,18 +90,32 @@ static int mtk_ppe_mib_wait_busy(struct
+@@ -90,17 +90,31 @@ static int mtk_ppe_mib_wait_busy(struct
        return ret;
  }
  
@@ -43,7 +43,6 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
 +
 +struct mtk_foe_accounting *mtk_ppe_mib_entry_read(struct mtk_ppe *ppe, u16 index)
  {
-       u32 byte_cnt_low, byte_cnt_high, pkt_cnt_low, pkt_cnt_high;
        u32 val, cnt_r0, cnt_r1, cnt_r2;
 +      struct mtk_foe_accounting *acct;
        int ret;
@@ -62,25 +61,35 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
  
        cnt_r0 = readl(ppe->base + MTK_PPE_MIB_SER_R0);
        cnt_r1 = readl(ppe->base + MTK_PPE_MIB_SER_R1);
-@@ -111,10 +125,11 @@ static int mtk_mib_entry_read(struct mtk
-       byte_cnt_high = FIELD_GET(MTK_PPE_MIB_SER_R1_BYTE_CNT_HIGH, cnt_r1);
-       pkt_cnt_low = FIELD_GET(MTK_PPE_MIB_SER_R1_PKT_CNT_LOW, cnt_r1);
-       pkt_cnt_high = FIELD_GET(MTK_PPE_MIB_SER_R2_PKT_CNT_HIGH, cnt_r2);
--      *bytes = ((u64)byte_cnt_high << 32) | byte_cnt_low;
--      *packets = (pkt_cnt_high << 16) | pkt_cnt_low;
+@@ -109,19 +123,19 @@ static int mtk_mib_entry_read(struct mtk
+       if (mtk_is_netsys_v3_or_greater(ppe->eth)) {
+               /* 64 bit for each counter */
+               u32 cnt_r3 = readl(ppe->base + MTK_PPE_MIB_SER_R3);
+-              *bytes = ((u64)cnt_r1 << 32) | cnt_r0;
+-              *packets = ((u64)cnt_r3 << 32) | cnt_r2;
++              acct->bytes += ((u64)cnt_r1 << 32) | cnt_r0;
++              acct->packets += ((u64)cnt_r3 << 32) | cnt_r2;
+       } else {
+               /* 48 bit byte counter, 40 bit packet counter */
+               u32 byte_cnt_low = FIELD_GET(MTK_PPE_MIB_SER_R0_BYTE_CNT_LOW, cnt_r0);
+               u32 byte_cnt_high = FIELD_GET(MTK_PPE_MIB_SER_R1_BYTE_CNT_HIGH, cnt_r1);
+               u32 pkt_cnt_low = FIELD_GET(MTK_PPE_MIB_SER_R1_PKT_CNT_LOW, cnt_r1);
+               u32 pkt_cnt_high = FIELD_GET(MTK_PPE_MIB_SER_R2_PKT_CNT_HIGH, cnt_r2);
+-              *bytes = ((u64)byte_cnt_high << 32) | byte_cnt_low;
+-              *packets = (pkt_cnt_high << 16) | pkt_cnt_low;
++              acct->bytes += ((u64)byte_cnt_high << 32) | byte_cnt_low;
++              acct->packets += (pkt_cnt_high << 16) | pkt_cnt_low;
+       }
  
 -      return 0;
-+      acct->bytes += ((u64)byte_cnt_high << 32) | byte_cnt_low;
-+      acct->packets += (pkt_cnt_high << 16) | pkt_cnt_low;
-+
 +      return acct;
  }
  
  static void mtk_ppe_cache_clear(struct mtk_ppe *ppe)
-@@ -508,13 +523,6 @@ __mtk_foe_entry_clear(struct mtk_ppe *pp
-               hwe->ib1 &= ~MTK_FOE_IB1_STATE;
+@@ -520,13 +534,6 @@ __mtk_foe_entry_clear(struct mtk_ppe *pp
                hwe->ib1 |= FIELD_PREP(MTK_FOE_IB1_STATE, MTK_FOE_STATE_INVALID);
                dma_wmb();
+               mtk_ppe_cache_clear(ppe);
 -              if (ppe->accounting) {
 -                      struct mtk_foe_accounting *acct;
 -
@@ -91,7 +100,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
        }
        entry->hash = 0xffff;
  
-@@ -539,11 +547,14 @@ static int __mtk_foe_entry_idle_time(str
+@@ -551,11 +558,14 @@ static int __mtk_foe_entry_idle_time(str
  }
  
  static bool
@@ -107,7 +116,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
        int len;
  
        if (hash == 0xffff)
-@@ -554,18 +565,35 @@ mtk_flow_entry_update(struct mtk_ppe *pp
+@@ -566,18 +576,35 @@ mtk_flow_entry_update(struct mtk_ppe *pp
        memcpy(&foe, hwe, len);
  
        if (!mtk_flow_entry_match(ppe->eth, entry, &foe, len) ||
@@ -146,7 +155,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
        struct mtk_flow_entry *cur;
        struct hlist_node *tmp;
        int idle;
-@@ -574,7 +602,9 @@ mtk_flow_entry_update_l2(struct mtk_ppe
+@@ -586,7 +613,9 @@ mtk_flow_entry_update_l2(struct mtk_ppe
        hlist_for_each_entry_safe(cur, tmp, &entry->l2_flows, l2_list) {
                int cur_idle;
  
@@ -157,7 +166,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
                        __mtk_foe_entry_clear(ppe, entry, false);
                        continue;
                }
-@@ -589,10 +619,29 @@ mtk_flow_entry_update_l2(struct mtk_ppe
+@@ -601,10 +630,29 @@ mtk_flow_entry_update_l2(struct mtk_ppe
        }
  }
  
@@ -187,7 +196,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
        struct mtk_eth *eth = ppe->eth;
        u16 timestamp = mtk_eth_timestamp(eth);
        struct mtk_foe_entry *hwe;
-@@ -617,6 +666,12 @@ __mtk_foe_entry_commit(struct mtk_ppe *p
+@@ -635,6 +683,12 @@ __mtk_foe_entry_commit(struct mtk_ppe *p
  
        dma_wmb();
  
@@ -200,7 +209,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
        mtk_ppe_cache_clear(ppe);
  }
  
-@@ -781,21 +836,6 @@ out:
+@@ -799,21 +853,6 @@ out:
        spin_unlock_bh(&ppe_lock);
  }
  
@@ -222,7 +231,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
  int mtk_ppe_prepare_reset(struct mtk_ppe *ppe)
  {
        if (!ppe)
-@@ -823,32 +863,6 @@ int mtk_ppe_prepare_reset(struct mtk_ppe
+@@ -841,32 +880,6 @@ int mtk_ppe_prepare_reset(struct mtk_ppe
        return mtk_ppe_wait_busy(ppe);
  }
  
@@ -257,7 +266,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
        bool accounting = eth->soc->has_accounting;
 --- a/drivers/net/ethernet/mediatek/mtk_ppe.h
 +++ b/drivers/net/ethernet/mediatek/mtk_ppe.h
-@@ -283,6 +283,8 @@ struct mtk_flow_entry {
+@@ -304,6 +304,8 @@ struct mtk_flow_entry {
        struct mtk_foe_entry data;
        struct rhash_head node;
        unsigned long cookie;
@@ -266,7 +275,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
  };
  
  struct mtk_mib_entry {
-@@ -325,6 +327,7 @@ struct mtk_ppe *mtk_ppe_init(struct mtk_
+@@ -348,6 +350,7 @@ void mtk_ppe_deinit(struct mtk_eth *eth)
  void mtk_ppe_start(struct mtk_ppe *ppe);
  int mtk_ppe_stop(struct mtk_ppe *ppe);
  int mtk_ppe_prepare_reset(struct mtk_ppe *ppe);
@@ -274,7 +283,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
  
  void __mtk_ppe_check_skb(struct mtk_ppe *ppe, struct sk_buff *skb, u16 hash);
  
-@@ -373,9 +376,8 @@ int mtk_foe_entry_set_queue(struct mtk_e
+@@ -396,9 +399,8 @@ int mtk_foe_entry_set_queue(struct mtk_e
                            unsigned int queue);
  int mtk_foe_entry_commit(struct mtk_ppe *ppe, struct mtk_flow_entry *entry);
  void mtk_foe_entry_clear(struct mtk_ppe *ppe, struct mtk_flow_entry *entry);
@@ -295,11 +304,11 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
 -              acct = mtk_foe_entry_get_mib(ppe, i, NULL);
 +              acct = mtk_ppe_mib_entry_read(ppe, i);
  
-               type = FIELD_GET(MTK_FOE_IB1_PACKET_TYPE, entry->ib1);
+               type = mtk_get_ib1_pkt_type(ppe->eth, entry->ib1);
                seq_printf(m, "%05x %s %7s", i,
 --- a/drivers/net/ethernet/mediatek/mtk_ppe_offload.c
 +++ b/drivers/net/ethernet/mediatek/mtk_ppe_offload.c
-@@ -499,24 +499,21 @@ static int
+@@ -501,24 +501,21 @@ static int
  mtk_flow_offload_stats(struct mtk_eth *eth, struct flow_cls_offload *f)
  {
        struct mtk_flow_entry *entry;