From fbcfb7f7afe8dd73ee40e8210f2727d7b6f7940e Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Thu, 23 Mar 2023 10:38:24 +0100 Subject: [PATCH] kernel: update mtk ppe flow accounting patch to the latest version Signed-off-by: Felix Fietkau --- ...iatek-ppe-add-support-for-flow-accou.patch | 83 +++++++++++-------- ..._eth_soc-ppe-fix-L2-offloading-with-.patch | 2 +- ..._eth_soc-fix-flow_offload-related-re.patch | 4 +- ..._wed-move-cpuboot-in-a-dedicated-dts.patch | 9 +- ...tk_wed-move-ilm-a-dedicated-dts-node.patch | 15 ++-- 5 files changed, 56 insertions(+), 57 deletions(-) diff --git a/target/linux/generic/pending-5.15/731-net-ethernet-mediatek-ppe-add-support-for-flow-accou.patch b/target/linux/generic/pending-5.15/731-net-ethernet-mediatek-ppe-add-support-for-flow-accou.patch index 9c169fe357..d3aca7f849 100644 --- a/target/linux/generic/pending-5.15/731-net-ethernet-mediatek-ppe-add-support-for-flow-accou.patch +++ b/target/linux/generic/pending-5.15/731-net-ethernet-mediatek-ppe-add-support-for-flow-accou.patch @@ -53,18 +53,18 @@ v2: fix wrong variable name in return value check spotted by Denis Kirjanov --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -4586,7 +4586,9 @@ static int mtk_probe(struct platform_dev +@@ -4585,8 +4585,8 @@ static int mtk_probe(struct platform_dev + for (i = 0; i < num_ppe; i++) { u32 ppe_addr = eth->soc->reg_map->ppe_base + i * 0x400; - eth->ppe[i] = mtk_ppe_init(eth, eth->base + ppe_addr, +- eth->ppe[i] = mtk_ppe_init(eth, eth->base + ppe_addr, - eth->soc->offload_version, i); -+ eth->soc->offload_version, i, -+ eth->soc->has_accounting); ++ eth->ppe[i] = mtk_ppe_init(eth, eth->base + ppe_addr, i); + if (!eth->ppe[i]) { err = -ENOMEM; goto err_free_dev; -@@ -4711,6 +4713,7 @@ static const struct mtk_soc_data mt7622_ +@@ -4711,6 +4711,7 @@ static const struct mtk_soc_data mt7622_ .required_pctl = false, .offload_version = 2, .hash_offset = 2, @@ -72,7 +72,7 @@ v2: fix wrong variable name in return value check spotted by Denis Kirjanov .foe_entry_size = sizeof(struct mtk_foe_entry) - 16, .txrx = { .txd_size = sizeof(struct mtk_tx_dma), -@@ -4748,6 +4751,7 @@ static const struct mtk_soc_data mt7629_ +@@ -4748,6 +4749,7 @@ static const struct mtk_soc_data mt7629_ .hw_features = MTK_HW_FEATURES, .required_clks = MT7629_CLKS_BITMAP, .required_pctl = false, @@ -80,7 +80,7 @@ v2: fix wrong variable name in return value check spotted by Denis Kirjanov .txrx = { .txd_size = sizeof(struct mtk_tx_dma), .rxd_size = sizeof(struct mtk_rx_dma), -@@ -4768,6 +4772,7 @@ static const struct mtk_soc_data mt7986_ +@@ -4768,6 +4770,7 @@ static const struct mtk_soc_data mt7986_ .offload_version = 2, .hash_offset = 4, .foe_entry_size = sizeof(struct mtk_foe_entry), @@ -90,7 +90,16 @@ v2: fix wrong variable name in return value check spotted by Denis Kirjanov .rxd_size = sizeof(struct mtk_rx_dma_v2), --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h -@@ -1042,6 +1042,7 @@ struct mtk_soc_data { +@@ -1025,6 +1025,8 @@ struct mtk_reg_map { + * the extra setup for those pins used by GMAC. + * @hash_offset Flow table hash offset. + * @foe_entry_size Foe table entry size. ++ * @has_accounting Bool indicating support for accounting of ++ * offloaded flows. + * @txd_size Tx DMA descriptor size. + * @rxd_size Rx DMA descriptor size. + * @rx_irq_done_mask Rx irq done register mask. +@@ -1042,6 +1044,7 @@ struct mtk_soc_data { u8 hash_offset; u16 foe_entry_size; netdev_features_t hw_features; @@ -100,7 +109,7 @@ v2: fix wrong variable name in return value check spotted by Denis Kirjanov u32 rxd_size; --- a/drivers/net/ethernet/mediatek/mtk_ppe.c +++ b/drivers/net/ethernet/mediatek/mtk_ppe.c -@@ -74,6 +74,46 @@ static int mtk_ppe_wait_busy(struct mtk_ +@@ -74,6 +74,48 @@ static int mtk_ppe_wait_busy(struct mtk_ return ret; } @@ -121,14 +130,16 @@ v2: fix wrong variable name in return value check spotted by Denis Kirjanov + +static int mtk_mib_entry_read(struct mtk_ppe *ppe, u16 index, u64 *bytes, u64 *packets) +{ -+ u32 val, cnt_r0, cnt_r1, cnt_r2; + u32 byte_cnt_low, byte_cnt_high, pkt_cnt_low, pkt_cnt_high; ++ u32 val, cnt_r0, cnt_r1, cnt_r2; ++ int ret; + + val = FIELD_PREP(MTK_PPE_MIB_SER_CR_ADDR, index) | MTK_PPE_MIB_SER_CR_ST; + ppe_w32(ppe, MTK_PPE_MIB_SER_CR, val); + -+ if (mtk_ppe_mib_wait_busy(ppe)) -+ return -ETIMEDOUT; ++ ret = mtk_ppe_mib_wait_busy(ppe); ++ if (ret) ++ return ret; + + cnt_r0 = readl(ppe->base + MTK_PPE_MIB_SER_R0); + cnt_r1 = readl(ppe->base + MTK_PPE_MIB_SER_R1); @@ -147,7 +158,7 @@ v2: fix wrong variable name in return value check spotted by Denis Kirjanov static void mtk_ppe_cache_clear(struct mtk_ppe *ppe) { ppe_set(ppe, MTK_PPE_CACHE_CTL, MTK_PPE_CACHE_CTL_CLEAR); -@@ -464,6 +504,13 @@ __mtk_foe_entry_clear(struct mtk_ppe *pp +@@ -464,6 +506,13 @@ __mtk_foe_entry_clear(struct mtk_ppe *pp hwe->ib1 &= ~MTK_FOE_IB1_STATE; hwe->ib1 |= FIELD_PREP(MTK_FOE_IB1_STATE, MTK_FOE_STATE_INVALID); dma_wmb(); @@ -161,7 +172,7 @@ v2: fix wrong variable name in return value check spotted by Denis Kirjanov } entry->hash = 0xffff; -@@ -571,6 +618,9 @@ __mtk_foe_entry_commit(struct mtk_ppe *p +@@ -571,6 +620,9 @@ __mtk_foe_entry_commit(struct mtk_ppe *p wmb(); hwe->ib1 = entry->ib1; @@ -171,10 +182,12 @@ v2: fix wrong variable name in return value check spotted by Denis Kirjanov dma_wmb(); mtk_ppe_cache_clear(ppe); -@@ -762,14 +812,42 @@ int mtk_ppe_prepare_reset(struct mtk_ppe +@@ -762,11 +814,39 @@ int mtk_ppe_prepare_reset(struct mtk_ppe return mtk_ppe_wait_busy(ppe); } +-struct mtk_ppe *mtk_ppe_init(struct mtk_eth *eth, void __iomem *base, +- int version, int index) +struct mtk_foe_accounting *mtk_foe_entry_get_mib(struct mtk_ppe *ppe, u32 index, + struct mtk_foe_accounting *diff) +{ @@ -201,29 +214,27 @@ v2: fix wrong variable name in return value check spotted by Denis Kirjanov + return acct; +} + - struct mtk_ppe *mtk_ppe_init(struct mtk_eth *eth, void __iomem *base, -- int version, int index) -+ int version, int index, bool accounting) ++struct mtk_ppe *mtk_ppe_init(struct mtk_eth *eth, void __iomem *base, int index) { ++ bool accounting = eth->soc->has_accounting; const struct mtk_soc_data *soc = eth->soc; ++ struct mtk_foe_accounting *acct; struct device *dev = eth->dev; ++ struct mtk_mib_entry *mib; struct mtk_ppe *ppe; u32 foe_flow_size; void *foe; -+ struct mtk_mib_entry *mib; -+ struct mtk_foe_accounting *acct; - - ppe = devm_kzalloc(dev, sizeof(*ppe), GFP_KERNEL); - if (!ppe) -@@ -784,6 +862,7 @@ struct mtk_ppe *mtk_ppe_init(struct mtk_ +@@ -783,7 +863,8 @@ struct mtk_ppe *mtk_ppe_init(struct mtk_ + ppe->base = base; ppe->eth = eth; ppe->dev = dev; - ppe->version = version; +- ppe->version = version; ++ ppe->version = eth->soc->offload_version; + ppe->accounting = accounting; foe = dmam_alloc_coherent(ppe->dev, MTK_PPE_ENTRIES * soc->foe_entry_size, -@@ -799,6 +878,25 @@ struct mtk_ppe *mtk_ppe_init(struct mtk_ +@@ -799,6 +880,23 @@ struct mtk_ppe *mtk_ppe_init(struct mtk_ if (!ppe->foe_flow) return NULL; @@ -233,8 +244,6 @@ v2: fix wrong variable name in return value check spotted by Denis Kirjanov + if (!mib) + return NULL; + -+ memset(mib, 0, MTK_PPE_ENTRIES * sizeof(*mib)); -+ + ppe->mib_table = mib; + + acct = devm_kzalloc(dev, MTK_PPE_ENTRIES * sizeof(*acct), @@ -311,16 +320,17 @@ v2: fix wrong variable name in return value check spotted by Denis Kirjanov u16 foe_check_time[MTK_PPE_ENTRIES]; struct hlist_head *foe_flow; -@@ -304,7 +323,7 @@ struct mtk_ppe { +@@ -303,8 +322,7 @@ struct mtk_ppe { + void *acct_table; }; - struct mtk_ppe *mtk_ppe_init(struct mtk_eth *eth, void __iomem *base, +-struct mtk_ppe *mtk_ppe_init(struct mtk_eth *eth, void __iomem *base, - int version, int index); -+ int version, int index, bool accounting); ++struct mtk_ppe *mtk_ppe_init(struct mtk_eth *eth, void __iomem *base, int index); 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); -@@ -358,5 +377,7 @@ int mtk_foe_entry_commit(struct mtk_ppe +@@ -358,5 +376,7 @@ int mtk_foe_entry_commit(struct mtk_ppe void mtk_foe_entry_clear(struct mtk_ppe *ppe, struct mtk_flow_entry *entry); int mtk_foe_entry_idle_time(struct mtk_ppe *ppe, struct mtk_flow_entry *entry); int mtk_ppe_debugfs_init(struct mtk_ppe *ppe, int index); @@ -353,7 +363,7 @@ v2: fix wrong variable name in return value check spotted by Denis Kirjanov seq_printf(m, " eth=%pM->%pM etype=%04x" - " vlan=%d,%d ib1=%08x ib2=%08x\n", + " vlan=%d,%d ib1=%08x ib2=%08x" -+ " packets=%lld bytes=%lld\n", ++ " packets=%llu bytes=%llu\n", h_source, h_dest, ntohs(l2->etype), - l2->vlan1, l2->vlan2, entry->ib1, ib2); + l2->vlan1, l2->vlan2, entry->ib1, ib2, @@ -371,12 +381,13 @@ v2: fix wrong variable name in return value check spotted by Denis Kirjanov u32 idle; entry = rhashtable_lookup(ð->flow_table, &f->cookie, -@@ -507,6 +508,12 @@ mtk_flow_offload_stats(struct mtk_eth *e +@@ -507,6 +508,13 @@ mtk_flow_offload_stats(struct mtk_eth *e idle = mtk_foe_entry_idle_time(eth->ppe[entry->ppe_index], entry); f->stats.lastused = jiffies - idle * HZ; -+ if (entry->hash != 0xFFFF) { -+ mtk_foe_entry_get_mib(eth->ppe[entry->ppe_index], entry->hash, &diff); ++ if (entry->hash != 0xFFFF && ++ mtk_foe_entry_get_mib(eth->ppe[entry->ppe_index], entry->hash, ++ &diff)) { + f->stats.pkts += diff.packets; + f->stats.bytes += diff.bytes; + } diff --git a/target/linux/generic/pending-5.15/734-net-ethernet-mtk_eth_soc-ppe-fix-L2-offloading-with-.patch b/target/linux/generic/pending-5.15/734-net-ethernet-mtk_eth_soc-ppe-fix-L2-offloading-with-.patch index 3fdee298d9..9ef65ec16f 100644 --- a/target/linux/generic/pending-5.15/734-net-ethernet-mtk_eth_soc-ppe-fix-L2-offloading-with-.patch +++ b/target/linux/generic/pending-5.15/734-net-ethernet-mtk_eth_soc-ppe-fix-L2-offloading-with-.patch @@ -20,7 +20,7 @@ Signed-off-by: Felix Fietkau #include #include "mtk_eth_soc.h" #include "mtk_ppe.h" -@@ -755,7 +756,9 @@ void __mtk_ppe_check_skb(struct mtk_ppe +@@ -757,7 +758,9 @@ void __mtk_ppe_check_skb(struct mtk_ppe skb->dev->dsa_ptr->tag_ops->proto != DSA_TAG_PROTO_MTK) goto out; diff --git a/target/linux/generic/pending-5.15/735-net-ethernet-mtk_eth_soc-fix-flow_offload-related-re.patch b/target/linux/generic/pending-5.15/735-net-ethernet-mtk_eth_soc-fix-flow_offload-related-re.patch index b7304906c0..95dc633320 100644 --- a/target/linux/generic/pending-5.15/735-net-ethernet-mtk_eth_soc-fix-flow_offload-related-re.patch +++ b/target/linux/generic/pending-5.15/735-net-ethernet-mtk_eth_soc-fix-flow_offload-related-re.patch @@ -14,7 +14,7 @@ Signed-off-by: Felix Fietkau --- a/drivers/net/ethernet/mediatek/mtk_ppe_offload.c +++ b/drivers/net/ethernet/mediatek/mtk_ppe_offload.c -@@ -583,6 +583,7 @@ mtk_eth_setup_tc_block(struct net_device +@@ -584,6 +584,7 @@ mtk_eth_setup_tc_block(struct net_device if (IS_ERR(block_cb)) return PTR_ERR(block_cb); @@ -22,7 +22,7 @@ Signed-off-by: Felix Fietkau flow_block_cb_add(block_cb, f); list_add_tail(&block_cb->driver_list, &block_cb_list); return 0; -@@ -591,7 +592,7 @@ mtk_eth_setup_tc_block(struct net_device +@@ -592,7 +593,7 @@ mtk_eth_setup_tc_block(struct net_device if (!block_cb) return -ENOENT; diff --git a/target/linux/mediatek/patches-5.15/942-net-ethernet-mtk_wed-move-cpuboot-in-a-dedicated-dts.patch b/target/linux/mediatek/patches-5.15/942-net-ethernet-mtk_wed-move-cpuboot-in-a-dedicated-dts.patch index 57f8afe474..3de1b27622 100644 --- a/target/linux/mediatek/patches-5.15/942-net-ethernet-mtk_wed-move-cpuboot-in-a-dedicated-dts.patch +++ b/target/linux/mediatek/patches-5.15/942-net-ethernet-mtk_wed-move-cpuboot-in-a-dedicated-dts.patch @@ -21,8 +21,6 @@ Signed-off-by: Lorenzo Bianconi drivers/net/ethernet/mediatek/mtk_wed_wo.h | 3 +- 2 files changed, 30 insertions(+), 7 deletions(-) -diff --git a/drivers/net/ethernet/mediatek/mtk_wed_mcu.c b/drivers/net/ethernet/mediatek/mtk_wed_mcu.c -index 6624f6d6abdd..797c3b412ab6 100644 --- a/drivers/net/ethernet/mediatek/mtk_wed_mcu.c +++ b/drivers/net/ethernet/mediatek/mtk_wed_mcu.c @@ -18,12 +18,23 @@ @@ -51,7 +49,7 @@ index 6624f6d6abdd..797c3b412ab6 100644 } static struct sk_buff * -@@ -316,10 +327,21 @@ mtk_wed_mcu_load_firmware(struct mtk_wed_wo *wo) +@@ -316,10 +327,21 @@ mtk_wed_mcu_load_firmware(struct mtk_wed return ret; } @@ -77,8 +75,6 @@ index 6624f6d6abdd..797c3b412ab6 100644 /* set dummy cr */ wed_w32(wo->hw->wed_dev, MTK_WED_SCR0 + 4 * MTK_WED_DUMMY_CR_FWDL, -diff --git a/drivers/net/ethernet/mediatek/mtk_wed_wo.h b/drivers/net/ethernet/mediatek/mtk_wed_wo.h -index dbcf42ce9173..c03071203cc0 100644 --- a/drivers/net/ethernet/mediatek/mtk_wed_wo.h +++ b/drivers/net/ethernet/mediatek/mtk_wed_wo.h @@ -227,7 +227,8 @@ struct mtk_wed_wo_queue { @@ -91,6 +87,3 @@ index dbcf42ce9173..c03071203cc0 100644 struct mtk_wed_wo_queue q_tx; struct mtk_wed_wo_queue q_rx; --- -2.39.2 - diff --git a/target/linux/mediatek/patches-5.15/943-net-ethernet-mtk_wed-move-ilm-a-dedicated-dts-node.patch b/target/linux/mediatek/patches-5.15/943-net-ethernet-mtk_wed-move-ilm-a-dedicated-dts-node.patch index e83daeb9f0..7b6c5d1e27 100644 --- a/target/linux/mediatek/patches-5.15/943-net-ethernet-mtk_wed-move-ilm-a-dedicated-dts-node.patch +++ b/target/linux/mediatek/patches-5.15/943-net-ethernet-mtk_wed-move-ilm-a-dedicated-dts-node.patch @@ -18,15 +18,12 @@ Signed-off-by: Lorenzo Bianconi drivers/net/ethernet/mediatek/mtk_wed_mcu.c | 55 ++++++++++++++++++--- 1 file changed, 49 insertions(+), 6 deletions(-) -diff --git a/drivers/net/ethernet/mediatek/mtk_wed_mcu.c b/drivers/net/ethernet/mediatek/mtk_wed_mcu.c -index 797c3b412ab6..976946a3653a 100644 --- a/drivers/net/ethernet/mediatek/mtk_wed_mcu.c +++ b/drivers/net/ethernet/mediatek/mtk_wed_mcu.c -@@ -299,6 +299,52 @@ mtk_wed_mcu_run_firmware(struct mtk_wed_wo *wo, const struct firmware *fw, - return -EINVAL; +@@ -300,6 +300,52 @@ next: } -+static int + static int +mtk_wed_mcu_load_memory_regions(struct mtk_wed_wo *wo, + struct mtk_wed_wo_memory_region *region) +{ @@ -72,10 +69,11 @@ index 797c3b412ab6..976946a3653a 100644 + ®ion[MTK_WED_WO_REGION_ILM]); +} + - static int ++static int mtk_wed_mcu_load_firmware(struct mtk_wed_wo *wo) { -@@ -320,12 +366,9 @@ mtk_wed_mcu_load_firmware(struct mtk_wed_wo *wo) + static struct mtk_wed_wo_memory_region mem_region[] = { +@@ -320,12 +366,9 @@ mtk_wed_mcu_load_firmware(struct mtk_wed u32 val, boot_cr; int ret, i; @@ -91,6 +89,3 @@ index 797c3b412ab6..976946a3653a 100644 wo->boot_regmap = syscon_regmap_lookup_by_phandle(wo->hw->node, "mediatek,wo-cpuboot"); --- -2.39.2 - -- 2.30.2