From 9ebd4a4298b0d171e3ce95720459028c47b9db2c Mon Sep 17 00:00:00 2001 From: Lorenzo Bianconi Date: Sun, 15 Jun 2025 10:41:08 +0200 Subject: [PATCH 1/5] net: airoha: Use 1KB for QDMA1 reserved mermory size Signed-off-by: Lorenzo Bianconi --- target/linux/airoha/dts/an7581.dtsi | 14 ++++---- ...rentiate-hwfd-buffer-size-for-QDMA0-.patch | 33 ++++++++++++------- ...62-net-airoha-Enable-RX-queues-16-31.patch | 7 +--- 3 files changed, 30 insertions(+), 24 deletions(-) diff --git a/target/linux/airoha/dts/an7581.dtsi b/target/linux/airoha/dts/an7581.dtsi index ace5c8b661e1e9..1a3a304d4f3df5 100644 --- a/target/linux/airoha/dts/an7581.dtsi +++ b/target/linux/airoha/dts/an7581.dtsi @@ -30,22 +30,22 @@ qdma1_buf: qdma1-buf@89000000 { no-map; - reg = <0x0 0x89000000 0x0 0x400000>; + reg = <0x0 0x89000000 0x0 0x1000000>; }; - npu_pkt: npu-pkt@89400000 { + npu_pkt: npu-pkt@8a000000 { no-map; - reg = <0x0 0x89400000 0x0 0x2c00000>; + reg = <0x0 0x8a000000 0x0 0x2c00000>; }; - npu_txpkt: npu-txpkt@8c000000 { + npu_txpkt: npu-txpkt@8cc00000 { no-map; - reg = <0x0 0x8c000000 0x0 0x4000000>; + reg = <0x0 0x8cc00000 0x0 0x4000000>; }; - npu_txbufid: npu-txbufid@90000000 { + npu_txbufid: npu-txbufid@90c00000 { no-map; - reg = <0x0 0x90000000 0x0 0x6800>; + reg = <0x0 0x90c00000 0x0 0x6800>; }; }; diff --git a/target/linux/airoha/patches-6.6/999-61-net-airoha-Differentiate-hwfd-buffer-size-for-QDMA0-.patch b/target/linux/airoha/patches-6.6/999-61-net-airoha-Differentiate-hwfd-buffer-size-for-QDMA0-.patch index cf4c7f1a6d3153..6546cc230e9ff0 100644 --- a/target/linux/airoha/patches-6.6/999-61-net-airoha-Differentiate-hwfd-buffer-size-for-QDMA0-.patch +++ b/target/linux/airoha/patches-6.6/999-61-net-airoha-Differentiate-hwfd-buffer-size-for-QDMA0-.patch @@ -18,12 +18,11 @@ Signed-off-by: Lorenzo Bianconi --- a/drivers/net/ethernet/airoha/airoha_eth.c +++ b/drivers/net/ethernet/airoha/airoha_eth.c -@@ -1219,15 +1219,18 @@ static int airoha_qdma_init_hfwd_queues( - { +@@ -1220,20 +1220,24 @@ static int airoha_qdma_init_hfwd_queues( int size, index, num_desc = HW_DSCP_NUM; struct airoha_eth *eth = qdma->eth; -+ u32 status, buf_size, buf_size_val; int id = qdma - ð->qdma[0]; ++ u32 status, buf_size; dma_addr_t dma_addr; const char *name; - u32 status; @@ -32,13 +31,20 @@ Signed-off-by: Lorenzo Bianconi if (!name) return -ENOMEM; -+ buf_size = id ? AIROHA_MAX_PACKET_SIZE / 8 : AIROHA_MAX_PACKET_SIZE; -+ buf_size_val = id ? 3 : 0; /* QDMA0: 2KB. QDMA1: 256B */ -+ ++ buf_size = id ? AIROHA_MAX_PACKET_SIZE / 2 : AIROHA_MAX_PACKET_SIZE; index = of_property_match_string(eth->dev->of_node, "memory-region-names", name); if (index >= 0) { -@@ -1245,9 +1248,9 @@ static int airoha_qdma_init_hfwd_queues( + struct reserved_mem *rmem; + struct device_node *np; + ++ /* Consume reserved memory for hw forwarding buffers queue if ++ * available in the DTS ++ */ + np = of_parse_phandle(eth->dev->of_node, "memory-region", + index); + if (!np) +@@ -1245,9 +1249,9 @@ static int airoha_qdma_init_hfwd_queues( /* Compute the number of hw descriptors according to the * reserved memory size and the payload buffer size */ @@ -50,13 +56,18 @@ Signed-off-by: Lorenzo Bianconi if (!dmam_alloc_coherent(eth->dev, size, &dma_addr, GFP_KERNEL)) return -ENOMEM; -@@ -1262,7 +1265,8 @@ static int airoha_qdma_init_hfwd_queues( +@@ -1260,12 +1264,12 @@ static int airoha_qdma_init_hfwd_queues( + return -ENOMEM; + airoha_qdma_wr(qdma, REG_FWD_DSCP_BASE, dma_addr); ++ /* QDMA0: 2KB. QDMA1: 1KB */ airoha_qdma_rmw(qdma, REG_HW_FWD_DSCP_CFG, HW_FWD_DSCP_PAYLOAD_SIZE_MASK, - FIELD_PREP(HW_FWD_DSCP_PAYLOAD_SIZE_MASK, 0)); -+ FIELD_PREP(HW_FWD_DSCP_PAYLOAD_SIZE_MASK, -+ buf_size_val)); ++ FIELD_PREP(HW_FWD_DSCP_PAYLOAD_SIZE_MASK, !!id)); airoha_qdma_rmw(qdma, REG_FWD_DSCP_LOW_THR, FWD_DSCP_LOW_THR_MASK, FIELD_PREP(FWD_DSCP_LOW_THR_MASK, 128)); - +- + airoha_qdma_rmw(qdma, REG_LMGR_INIT_CFG, + LMGR_INIT_START | LMGR_SRAM_MODE_MASK | + HW_FWD_DESC_NUM_MASK, diff --git a/target/linux/airoha/patches-6.6/999-62-net-airoha-Enable-RX-queues-16-31.patch b/target/linux/airoha/patches-6.6/999-62-net-airoha-Enable-RX-queues-16-31.patch index b608944940eeea..47a0a28197d3ac 100644 --- a/target/linux/airoha/patches-6.6/999-62-net-airoha-Enable-RX-queues-16-31.patch +++ b/target/linux/airoha/patches-6.6/999-62-net-airoha-Enable-RX-queues-16-31.patch @@ -12,11 +12,9 @@ Signed-off-by: Lorenzo Bianconi drivers/net/ethernet/airoha/airoha_regs.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -diff --git a/drivers/net/ethernet/airoha/airoha_regs.h b/drivers/net/ethernet/airoha/airoha_regs.h -index 04187eb40ec6..150c85995cc1 100644 --- a/drivers/net/ethernet/airoha/airoha_regs.h +++ b/drivers/net/ethernet/airoha/airoha_regs.h -@@ -614,8 +614,9 @@ +@@ -635,8 +635,9 @@ RX19_DONE_INT_MASK | RX18_DONE_INT_MASK | \ RX17_DONE_INT_MASK | RX16_DONE_INT_MASK) @@ -27,6 +25,3 @@ index 04187eb40ec6..150c85995cc1 100644 #define INT_RX2_MASK(_n) \ ((RX_NO_CPU_DSCP_HIGH_INT_MASK & (_n)) | \ --- -2.49.0 - From 43f7ab82c3b06adb25a30a1d76fdf5dc26885661 Mon Sep 17 00:00:00 2001 From: Lorenzo Bianconi Date: Sun, 15 Jun 2025 12:39:15 +0200 Subject: [PATCH 2/5] net: airoha: bind flow in airoha_ppe_foe_commit() Signed-off-by: Lorenzo Bianconi --- ...PE-entry-state-in-airoha_ppe_foe_com.patch | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 target/linux/airoha/patches-6.6/999-63-net-airoha-Set-PPE-entry-state-in-airoha_ppe_foe_com.patch diff --git a/target/linux/airoha/patches-6.6/999-63-net-airoha-Set-PPE-entry-state-in-airoha_ppe_foe_com.patch b/target/linux/airoha/patches-6.6/999-63-net-airoha-Set-PPE-entry-state-in-airoha_ppe_foe_com.patch new file mode 100644 index 00000000000000..7fa44be2a5b362 --- /dev/null +++ b/target/linux/airoha/patches-6.6/999-63-net-airoha-Set-PPE-entry-state-in-airoha_ppe_foe_com.patch @@ -0,0 +1,78 @@ +From eeaed4b179cb508affa2c7c501ec48c4ee6f9c0e Mon Sep 17 00:00:00 2001 +Message-ID: +From: Lorenzo Bianconi +Date: Thu, 12 Jun 2025 22:45:44 +0200 +Subject: [PATCH net] net: airoha: Set PPE entry state in + airoha_ppe_foe_commit_entry() + +Signed-off-by: Lorenzo Bianconi +--- + drivers/net/ethernet/airoha/airoha_eth.h | 2 +- + drivers/net/ethernet/airoha/airoha_ppe.c | 15 ++++++++------- + 2 files changed, 9 insertions(+), 8 deletions(-) + +--- a/drivers/net/ethernet/airoha/airoha_eth.h ++++ b/drivers/net/ethernet/airoha/airoha_eth.h +@@ -240,7 +240,7 @@ struct airoha_hw_stats { + u64 rx_len[7]; + }; + +-enum { ++enum airoha_foe_state { + AIROHA_FOE_STATE_INVALID, + AIROHA_FOE_STATE_UNBIND, + AIROHA_FOE_STATE_BIND, +--- a/drivers/net/ethernet/airoha/airoha_ppe.c ++++ b/drivers/net/ethernet/airoha/airoha_ppe.c +@@ -615,7 +615,8 @@ static bool airoha_ppe_foe_compare_entry + + static int airoha_ppe_foe_commit_entry(struct airoha_ppe *ppe, + struct airoha_foe_entry *e, +- u32 hash, bool rx_wlan) ++ u32 hash, bool rx_wlan, ++ enum airoha_foe_state state) + { + struct airoha_foe_entry *hwe = ppe->foe + hash * sizeof(*hwe); + u32 ts = airoha_ppe_get_timestamp(ppe); +@@ -629,6 +630,8 @@ static int airoha_ppe_foe_commit_entry(s + e->ib1 &= ~AIROHA_FOE_IB1_BIND_TIMESTAMP; + e->ib1 |= FIELD_PREP(AIROHA_FOE_IB1_BIND_TIMESTAMP, ts); + hwe->ib1 = e->ib1; ++ hwe->ib1 &= ~AIROHA_FOE_IB1_BIND_STATE; ++ hwe->ib1 |= FIELD_PREP(AIROHA_FOE_IB1_BIND_STATE, state); + + rcu_read_lock(); + +@@ -662,10 +665,8 @@ static void airoha_ppe_foe_remove_flow(s + + hlist_del_init(&e->list); + if (e->hash != 0xffff) { +- e->data.ib1 &= ~AIROHA_FOE_IB1_BIND_STATE; +- e->data.ib1 |= FIELD_PREP(AIROHA_FOE_IB1_BIND_STATE, +- AIROHA_FOE_STATE_INVALID); +- airoha_ppe_foe_commit_entry(ppe, &e->data, e->hash, false); ++ airoha_ppe_foe_commit_entry(ppe, &e->data, e->hash, false, ++ AIROHA_FOE_STATE_INVALID); + e->hash = 0xffff; + } + if (e->type == FLOW_TYPE_L2_SUBFLOW) { +@@ -743,7 +744,8 @@ airoha_ppe_foe_commit_subflow_entry(stru + } + + hwe.bridge.data = e->data.bridge.data; +- airoha_ppe_foe_commit_entry(ppe, &hwe, hash, rx_wlan); ++ airoha_ppe_foe_commit_entry(ppe, &hwe, hash, rx_wlan, ++ AIROHA_FOE_STATE_BIND); + + return 0; + } +@@ -785,7 +787,8 @@ static void airoha_ppe_foe_insert_entry( + continue; + } + +- airoha_ppe_foe_commit_entry(ppe, &e->data, hash, rx_wlan); ++ airoha_ppe_foe_commit_entry(ppe, &e->data, hash, rx_wlan, ++ AIROHA_FOE_STATE_BIND); + commit_done = true; + e->hash = hash; + } From 7ded759000fdb94a7aba83bb4a644952eaa7d9a2 Mon Sep 17 00:00:00 2001 From: Lorenzo Bianconi Date: Mon, 16 Jun 2025 14:57:36 +0200 Subject: [PATCH 3/5] net: airoha: align to upstream Signed-off-by: Lorenzo Bianconi --- ...1-net-airoha-Differentiate-hwfd-buffer-size-for-QDMA0-.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/linux/airoha/patches-6.6/999-61-net-airoha-Differentiate-hwfd-buffer-size-for-QDMA0-.patch b/target/linux/airoha/patches-6.6/999-61-net-airoha-Differentiate-hwfd-buffer-size-for-QDMA0-.patch index 6546cc230e9ff0..522f162ebf8335 100644 --- a/target/linux/airoha/patches-6.6/999-61-net-airoha-Differentiate-hwfd-buffer-size-for-QDMA0-.patch +++ b/target/linux/airoha/patches-6.6/999-61-net-airoha-Differentiate-hwfd-buffer-size-for-QDMA0-.patch @@ -49,7 +49,7 @@ Signed-off-by: Lorenzo Bianconi * reserved memory size and the payload buffer size */ - num_desc = rmem->size / AIROHA_MAX_PACKET_SIZE; -+ num_desc = rmem->size / buf_size; ++ num_desc = div_u64(rmem->size, buf_size); } else { - size = AIROHA_MAX_PACKET_SIZE * num_desc; + size = buf_size * num_desc; From 9f7d417e6ca2e4c535bd59febbf0ae237f186289 Mon Sep 17 00:00:00 2001 From: Lorenzo Bianconi Date: Wed, 18 Jun 2025 15:47:31 +0200 Subject: [PATCH 4/5] net: airoha: remove patch 999-63 for the time being Signed-off-by: Lorenzo Bianconi --- ...PE-entry-state-in-airoha_ppe_foe_com.patch | 78 ------------------- 1 file changed, 78 deletions(-) delete mode 100644 target/linux/airoha/patches-6.6/999-63-net-airoha-Set-PPE-entry-state-in-airoha_ppe_foe_com.patch diff --git a/target/linux/airoha/patches-6.6/999-63-net-airoha-Set-PPE-entry-state-in-airoha_ppe_foe_com.patch b/target/linux/airoha/patches-6.6/999-63-net-airoha-Set-PPE-entry-state-in-airoha_ppe_foe_com.patch deleted file mode 100644 index 7fa44be2a5b362..00000000000000 --- a/target/linux/airoha/patches-6.6/999-63-net-airoha-Set-PPE-entry-state-in-airoha_ppe_foe_com.patch +++ /dev/null @@ -1,78 +0,0 @@ -From eeaed4b179cb508affa2c7c501ec48c4ee6f9c0e Mon Sep 17 00:00:00 2001 -Message-ID: -From: Lorenzo Bianconi -Date: Thu, 12 Jun 2025 22:45:44 +0200 -Subject: [PATCH net] net: airoha: Set PPE entry state in - airoha_ppe_foe_commit_entry() - -Signed-off-by: Lorenzo Bianconi ---- - drivers/net/ethernet/airoha/airoha_eth.h | 2 +- - drivers/net/ethernet/airoha/airoha_ppe.c | 15 ++++++++------- - 2 files changed, 9 insertions(+), 8 deletions(-) - ---- a/drivers/net/ethernet/airoha/airoha_eth.h -+++ b/drivers/net/ethernet/airoha/airoha_eth.h -@@ -240,7 +240,7 @@ struct airoha_hw_stats { - u64 rx_len[7]; - }; - --enum { -+enum airoha_foe_state { - AIROHA_FOE_STATE_INVALID, - AIROHA_FOE_STATE_UNBIND, - AIROHA_FOE_STATE_BIND, ---- a/drivers/net/ethernet/airoha/airoha_ppe.c -+++ b/drivers/net/ethernet/airoha/airoha_ppe.c -@@ -615,7 +615,8 @@ static bool airoha_ppe_foe_compare_entry - - static int airoha_ppe_foe_commit_entry(struct airoha_ppe *ppe, - struct airoha_foe_entry *e, -- u32 hash, bool rx_wlan) -+ u32 hash, bool rx_wlan, -+ enum airoha_foe_state state) - { - struct airoha_foe_entry *hwe = ppe->foe + hash * sizeof(*hwe); - u32 ts = airoha_ppe_get_timestamp(ppe); -@@ -629,6 +630,8 @@ static int airoha_ppe_foe_commit_entry(s - e->ib1 &= ~AIROHA_FOE_IB1_BIND_TIMESTAMP; - e->ib1 |= FIELD_PREP(AIROHA_FOE_IB1_BIND_TIMESTAMP, ts); - hwe->ib1 = e->ib1; -+ hwe->ib1 &= ~AIROHA_FOE_IB1_BIND_STATE; -+ hwe->ib1 |= FIELD_PREP(AIROHA_FOE_IB1_BIND_STATE, state); - - rcu_read_lock(); - -@@ -662,10 +665,8 @@ static void airoha_ppe_foe_remove_flow(s - - hlist_del_init(&e->list); - if (e->hash != 0xffff) { -- e->data.ib1 &= ~AIROHA_FOE_IB1_BIND_STATE; -- e->data.ib1 |= FIELD_PREP(AIROHA_FOE_IB1_BIND_STATE, -- AIROHA_FOE_STATE_INVALID); -- airoha_ppe_foe_commit_entry(ppe, &e->data, e->hash, false); -+ airoha_ppe_foe_commit_entry(ppe, &e->data, e->hash, false, -+ AIROHA_FOE_STATE_INVALID); - e->hash = 0xffff; - } - if (e->type == FLOW_TYPE_L2_SUBFLOW) { -@@ -743,7 +744,8 @@ airoha_ppe_foe_commit_subflow_entry(stru - } - - hwe.bridge.data = e->data.bridge.data; -- airoha_ppe_foe_commit_entry(ppe, &hwe, hash, rx_wlan); -+ airoha_ppe_foe_commit_entry(ppe, &hwe, hash, rx_wlan, -+ AIROHA_FOE_STATE_BIND); - - return 0; - } -@@ -785,7 +787,8 @@ static void airoha_ppe_foe_insert_entry( - continue; - } - -- airoha_ppe_foe_commit_entry(ppe, &e->data, hash, rx_wlan); -+ airoha_ppe_foe_commit_entry(ppe, &e->data, hash, rx_wlan, -+ AIROHA_FOE_STATE_BIND); - commit_done = true; - e->hash = hash; - } From eba389050e83b045f186b90683a5a11f63eccf11 Mon Sep 17 00:00:00 2001 From: Lorenzo Bianconi Date: Wed, 18 Jun 2025 16:35:32 +0200 Subject: [PATCH 5/5] mt76: npu: Add npu_enable module parameter Signed-off-by: Lorenzo Bianconi --- .../kernel/mt76/patches/0155-npu-param.patch | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 package/kernel/mt76/patches/0155-npu-param.patch diff --git a/package/kernel/mt76/patches/0155-npu-param.patch b/package/kernel/mt76/patches/0155-npu-param.patch new file mode 100644 index 00000000000000..023d2e13db8ce9 --- /dev/null +++ b/package/kernel/mt76/patches/0155-npu-param.patch @@ -0,0 +1,30 @@ +--- a/npu.c ++++ b/npu.c +@@ -3,6 +3,7 @@ + * Copyright (c) 2025 AIROHA Inc + * Author: Lorenzo Bianconi + */ ++#include + #include + #include + +@@ -13,6 +14,9 @@ + #define MT76_NPU_RX_BUF_SIZE (1800 + \ + SKB_DATA_ALIGN(sizeof(struct skb_shared_info))) + ++static bool npu_enable = true; ++module_param(npu_enable, bool, 0644); ++ + static int mt76_npu_fill_rx_queue(struct mt76_dev *dev, struct mt76_queue *q) + { + int nframes = 0; +@@ -504,6 +508,9 @@ int mt76_npu_init(struct mt76_dev *dev) + if (!is_mt7992(dev)) + return -EINVAL; + ++ if (!npu_enable) ++ return -EINVAL; ++ + mutex_lock(&dev->mutex); + + npu = airoha_npu_get(dev->dev, NULL);