这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions package/kernel/mt76/patches/0155-npu-param.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
--- a/npu.c
+++ b/npu.c
@@ -3,6 +3,7 @@
* Copyright (c) 2025 AIROHA Inc
* Author: Lorenzo Bianconi <lorenzo@kernel.org>
*/
+#include <linux/kernel.h>
#include <net/flow_offload.h>
#include <net/pkt_cls.h>

@@ -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);
14 changes: 7 additions & 7 deletions target/linux/airoha/dts/an7581.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>

--- 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 - &eth->qdma[0];
+ u32 status, buf_size;
dma_addr_t dma_addr;
const char *name;
- u32 status;
Expand All @@ -32,31 +31,43 @@ Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
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
*/
- 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;
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,
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
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)

Expand All @@ -27,6 +25,3 @@ index 04187eb40ec6..150c85995cc1 100644

#define INT_RX2_MASK(_n) \
((RX_NO_CPU_DSCP_HIGH_INT_MASK & (_n)) | \
--
2.49.0

Loading