netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/7] net: airoha: Introduce NPU callbacks for wlan offloading
@ 2025-07-05 21:09 Lorenzo Bianconi
  2025-07-05 21:09 ` [PATCH net-next v2 1/7] dt-bindings: net: airoha: npu: Add memory regions used for wlan offload Lorenzo Bianconi
                   ` (6 more replies)
  0 siblings, 7 replies; 19+ messages in thread
From: Lorenzo Bianconi @ 2025-07-05 21:09 UTC (permalink / raw)
  To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lorenzo Bianconi
  Cc: linux-arm-kernel, linux-mediatek, netdev, devicetree,
	Simon Horman

Similar to wired traffic, EN7581 SoC allows to offload traffic to/from
the MT76 wireless NIC configuring the NPU module via the Netfilter
flowtable. This series introduces the necessary NPU callback used by
the MT76 driver in order to enable the offloading.
Subsequent patches will introduce the required MT76 support.

---
Changes in v2:
- Introduce binding for memory regions used for wlan offload
- Rely on of_reserved_mem_region_to_resource_byname
- Export just wlan_{send,get}_msg NPU callback for MT76
- Improve commit messages
- Link to v1: https://lore.kernel.org/r/20250702-airoha-en7581-wlan-offlaod-v1-0-803009700b38@kernel.org

---
Lorenzo Bianconi (7):
      dt-bindings: net: airoha: npu: Add memory regions used for wlan offload
      net: airoha: npu: Add NPU wlan memory initialization commands
      net: airoha: npu: Add wlan_{send,get}_msg NPU callbacks
      net: airoha: npu: Add wlan irq management callbacks
      net: airoha: npu: Read NPU wlan interrupt lines from the DTS
      net: airoha: npu: Enable core 3 for WiFi offloading
      net: airoha: Add airoha_offload.h header

 .../devicetree/bindings/net/airoha,en7581-npu.yaml |  20 +-
 drivers/net/ethernet/airoha/airoha_npu.c           | 180 ++++++++++++++-
 drivers/net/ethernet/airoha/airoha_npu.h           |  36 ---
 drivers/net/ethernet/airoha/airoha_ppe.c           |   2 +-
 include/linux/soc/airoha/airoha_offload.h          | 256 +++++++++++++++++++++
 5 files changed, 450 insertions(+), 44 deletions(-)
---
base-commit: 6b9fd8857b9fc4dd62e7cd300327f0e48dd76642
change-id: 20250701-airoha-en7581-wlan-offlaod-67c9daff8473

Best regards,
-- 
Lorenzo Bianconi <lorenzo@kernel.org>


^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH net-next v2 1/7] dt-bindings: net: airoha: npu: Add memory regions used for wlan offload
  2025-07-05 21:09 [PATCH net-next v2 0/7] net: airoha: Introduce NPU callbacks for wlan offloading Lorenzo Bianconi
@ 2025-07-05 21:09 ` Lorenzo Bianconi
  2025-07-07  7:05   ` Krzysztof Kozlowski
  2025-07-05 21:09 ` [PATCH net-next v2 2/7] net: airoha: npu: Add NPU wlan memory initialization commands Lorenzo Bianconi
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 19+ messages in thread
From: Lorenzo Bianconi @ 2025-07-05 21:09 UTC (permalink / raw)
  To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lorenzo Bianconi
  Cc: linux-arm-kernel, linux-mediatek, netdev, devicetree

Document memory regions used by Airoha EN7581 NPU for wlan traffic
offloading.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 .../devicetree/bindings/net/airoha,en7581-npu.yaml   | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/airoha,en7581-npu.yaml b/Documentation/devicetree/bindings/net/airoha,en7581-npu.yaml
index 76dd97c3fb4004674dc30a54c039c1cc19afedb3..db9269d1801bafa9be3b6c199a9e30cd23f4aea9 100644
--- a/Documentation/devicetree/bindings/net/airoha,en7581-npu.yaml
+++ b/Documentation/devicetree/bindings/net/airoha,en7581-npu.yaml
@@ -41,15 +41,25 @@ properties:
       - description: wlan irq line5
 
   memory-region:
-    maxItems: 1
-    description:
-      Memory used to store NPU firmware binary.
+    items:
+      - description: NPU firmware binary region
+      - description: NPU wlan offload RX buffers region
+      - description: NPU wlan offload TX buffers region
+      - description: NPU wlan offload TX packet identifiers region
+
+  memory-region-names:
+    items:
+      - const: binary
+      - const: pkt
+      - const: tx-pkt
+      - const: tx-bufid
 
 required:
   - compatible
   - reg
   - interrupts
   - memory-region
+  - memory-region-names
 
 additionalProperties: false
 
@@ -79,6 +89,8 @@ examples:
                      <GIC_SPI 121 IRQ_TYPE_LEVEL_HIGH>,
                      <GIC_SPI 122 IRQ_TYPE_LEVEL_HIGH>,
                      <GIC_SPI 123 IRQ_TYPE_LEVEL_HIGH>;
-        memory-region = <&npu_binary>;
+        memory-region = <&npu_binary>, <&npu_pkt>, <&npu_txpkt>,
+                        <&npu_txbufid>;
+        memory-region-names = "binary", "pkt", "tx-pkt", "tx-bufid";
       };
     };

-- 
2.50.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH net-next v2 2/7] net: airoha: npu: Add NPU wlan memory initialization commands
  2025-07-05 21:09 [PATCH net-next v2 0/7] net: airoha: Introduce NPU callbacks for wlan offloading Lorenzo Bianconi
  2025-07-05 21:09 ` [PATCH net-next v2 1/7] dt-bindings: net: airoha: npu: Add memory regions used for wlan offload Lorenzo Bianconi
@ 2025-07-05 21:09 ` Lorenzo Bianconi
  2025-07-07  7:09   ` Krzysztof Kozlowski
  2025-07-05 21:09 ` [PATCH net-next v2 3/7] net: airoha: npu: Add wlan_{send,get}_msg NPU callbacks Lorenzo Bianconi
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 19+ messages in thread
From: Lorenzo Bianconi @ 2025-07-05 21:09 UTC (permalink / raw)
  To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lorenzo Bianconi
  Cc: linux-arm-kernel, linux-mediatek, netdev, devicetree,
	Simon Horman

Introduce wlan_init_reserved_memory callback used by MT76 driver during
NPU wlan offloading setup.
This is a preliminary patch to enable wlan flowtable offload for EN7581
SoC with MT76 driver.

Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 drivers/net/ethernet/airoha/airoha_npu.c | 81 ++++++++++++++++++++++++++++++++
 drivers/net/ethernet/airoha/airoha_npu.h | 38 +++++++++++++++
 2 files changed, 119 insertions(+)

diff --git a/drivers/net/ethernet/airoha/airoha_npu.c b/drivers/net/ethernet/airoha/airoha_npu.c
index 0e5b8c21b9aa8bacdfb2e1572afe4324003e8279..8c5031a00f54ce64ded5950dafefe5f28d54e79a 100644
--- a/drivers/net/ethernet/airoha/airoha_npu.c
+++ b/drivers/net/ethernet/airoha/airoha_npu.c
@@ -124,6 +124,17 @@ struct ppe_mbox_data {
 	};
 };
 
+#define WLAN_MAX_STATS_SIZE	4408
+struct wlan_mbox_data {
+	u32 ifindex:4;
+	u32 func_type:4;
+	u32 func_id;
+	union {
+		u32 data;
+		u8 stats[WLAN_MAX_STATS_SIZE];
+	};
+};
+
 static int airoha_npu_send_msg(struct airoha_npu *npu, int func_id,
 			       void *p, int size)
 {
@@ -390,6 +401,75 @@ static int airoha_npu_stats_setup(struct airoha_npu *npu,
 	return err;
 }
 
+static int airoha_npu_wlan_msg_send(struct airoha_npu *npu, int ifindex,
+				    enum airoha_npu_wlan_set_cmd func_id,
+				    u32 data, gfp_t gfp)
+{
+	struct wlan_mbox_data *wlan_data;
+	int err;
+
+	wlan_data = kzalloc(sizeof(*wlan_data), gfp);
+	if (!wlan_data)
+		return -ENOMEM;
+
+	wlan_data->ifindex = ifindex;
+	wlan_data->func_type = NPU_OP_SET;
+	wlan_data->func_id = func_id;
+	wlan_data->data = data;
+
+	err = airoha_npu_send_msg(npu, NPU_FUNC_WIFI, wlan_data,
+				  sizeof(*wlan_data));
+	kfree(wlan_data);
+
+	return err;
+}
+
+static int
+airoha_npu_wlan_set_reserved_memory(struct airoha_npu *npu,
+				    int ifindex, const char *name,
+				    enum airoha_npu_wlan_set_cmd func_id)
+{
+	struct device *dev = npu->dev;
+	struct resource res;
+	int err;
+
+	err = of_reserved_mem_region_to_resource_byname(dev->of_node, name,
+							&res);
+	if (err)
+		return err;
+
+	return airoha_npu_wlan_msg_send(npu, ifindex, func_id, res.start,
+					GFP_KERNEL);
+}
+
+static int airoha_npu_wlan_init_memory(struct airoha_npu *npu)
+{
+	enum airoha_npu_wlan_set_cmd cmd = WLAN_FUNC_SET_WAIT_NPU_BAND0_ONCPU;
+	int err;
+
+	err = airoha_npu_wlan_msg_send(npu, 1, cmd, 0, GFP_KERNEL);
+	if (err)
+		return err;
+
+	cmd = WLAN_FUNC_SET_WAIT_TX_BUF_CHECK_ADDR;
+	err = airoha_npu_wlan_set_reserved_memory(npu, 0, "tx-bufid", cmd);
+	if (err)
+		return err;
+
+	cmd = WLAN_FUNC_SET_WAIT_PKT_BUF_ADDR;
+	err = airoha_npu_wlan_set_reserved_memory(npu, 0, "pkt", cmd);
+	if (err)
+		return err;
+
+	cmd = WLAN_FUNC_SET_WAIT_TX_PKT_BUF_ADDR;
+	err = airoha_npu_wlan_set_reserved_memory(npu, 0, "tx-pkt", cmd);
+	if (err)
+		return err;
+
+	cmd = WLAN_FUNC_SET_WAIT_IS_FORCE_TO_CPU;
+	return airoha_npu_wlan_msg_send(npu, 0, cmd, 0, GFP_KERNEL);
+}
+
 struct airoha_npu *airoha_npu_get(struct device *dev, dma_addr_t *stats_addr)
 {
 	struct platform_device *pdev;
@@ -493,6 +573,7 @@ static int airoha_npu_probe(struct platform_device *pdev)
 	npu->ops.ppe_deinit = airoha_npu_ppe_deinit;
 	npu->ops.ppe_flush_sram_entries = airoha_npu_ppe_flush_sram_entries;
 	npu->ops.ppe_foe_commit_entry = airoha_npu_foe_commit_entry;
+	npu->ops.wlan_init_reserved_memory = airoha_npu_wlan_init_memory;
 
 	npu->regmap = devm_regmap_init_mmio(dev, base, &regmap_config);
 	if (IS_ERR(npu->regmap))
diff --git a/drivers/net/ethernet/airoha/airoha_npu.h b/drivers/net/ethernet/airoha/airoha_npu.h
index 98ec3be74ce450bf4fa8bc771d19d174e8c157e5..58f4ee04e17161acbe513779638c23fe79a83a78 100644
--- a/drivers/net/ethernet/airoha/airoha_npu.h
+++ b/drivers/net/ethernet/airoha/airoha_npu.h
@@ -6,6 +6,43 @@
 
 #define NPU_NUM_CORES		8
 
+enum airoha_npu_wlan_set_cmd {
+	WLAN_FUNC_SET_WAIT_PCIE_ADDR,
+	WLAN_FUNC_SET_WAIT_DESC,
+	WLAN_FUNC_SET_WAIT_NPU_INIT_DONE,
+	WLAN_FUNC_SET_WAIT_TRAN_TO_CPU,
+	WLAN_FUNC_SET_WAIT_BA_WIN_SIZE,
+	WLAN_FUNC_SET_WAIT_DRIVER_MODEL,
+	WLAN_FUNC_SET_WAIT_DEL_STA,
+	WLAN_FUNC_SET_WAIT_DRAM_BA_NODE_ADDR,
+	WLAN_FUNC_SET_WAIT_PKT_BUF_ADDR,
+	WLAN_FUNC_SET_WAIT_IS_TEST_NOBA,
+	WLAN_FUNC_SET_WAIT_FLUSHONE_TIMEOUT,
+	WLAN_FUNC_SET_WAIT_FLUSHALL_TIMEOUT,
+	WLAN_FUNC_SET_WAIT_IS_FORCE_TO_CPU,
+	WLAN_FUNC_SET_WAIT_PCIE_STATE,
+	WLAN_FUNC_SET_WAIT_PCIE_PORT_TYPE,
+	WLAN_FUNC_SET_WAIT_ERROR_RETRY_TIMES,
+	WLAN_FUNC_SET_WAIT_BAR_INFO,
+	WLAN_FUNC_SET_WAIT_FAST_FLAG,
+	WLAN_FUNC_SET_WAIT_NPU_BAND0_ONCPU,
+	WLAN_FUNC_SET_WAIT_TX_RING_PCIE_ADDR,
+	WLAN_FUNC_SET_WAIT_TX_DESC_HW_BASE,
+	WLAN_FUNC_SET_WAIT_TX_BUF_SPACE_HW_BASE,
+	WLAN_FUNC_SET_WAIT_RX_RING_FOR_TXDONE_HW_BASE,
+	WLAN_FUNC_SET_WAIT_TX_PKT_BUF_ADDR,
+	WLAN_FUNC_SET_WAIT_INODE_TXRX_REG_ADDR,
+	WLAN_FUNC_SET_WAIT_INODE_DEBUG_FLAG,
+	WLAN_FUNC_SET_WAIT_INODE_HW_CFG_INFO,
+	WLAN_FUNC_SET_WAIT_INODE_STOP_ACTION,
+	WLAN_FUNC_SET_WAIT_INODE_PCIE_SWAP,
+	WLAN_FUNC_SET_WAIT_RATELIMIT_CTRL,
+	WLAN_FUNC_SET_WAIT_HWNAT_INIT,
+	WLAN_FUNC_SET_WAIT_ARHT_CHIP_INFO,
+	WLAN_FUNC_SET_WAIT_TX_BUF_CHECK_ADDR,
+	WLAN_FUNC_SET_WAIT_DEBUG_ARRAY_ADDR,
+};
+
 struct airoha_npu {
 	struct device *dev;
 	struct regmap *regmap;
@@ -29,6 +66,7 @@ struct airoha_npu {
 					    dma_addr_t foe_addr,
 					    u32 entry_size, u32 hash,
 					    bool ppe2);
+		int (*wlan_init_reserved_memory)(struct airoha_npu *npu);
 	} ops;
 };
 

-- 
2.50.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH net-next v2 3/7] net: airoha: npu: Add wlan_{send,get}_msg NPU callbacks
  2025-07-05 21:09 [PATCH net-next v2 0/7] net: airoha: Introduce NPU callbacks for wlan offloading Lorenzo Bianconi
  2025-07-05 21:09 ` [PATCH net-next v2 1/7] dt-bindings: net: airoha: npu: Add memory regions used for wlan offload Lorenzo Bianconi
  2025-07-05 21:09 ` [PATCH net-next v2 2/7] net: airoha: npu: Add NPU wlan memory initialization commands Lorenzo Bianconi
@ 2025-07-05 21:09 ` Lorenzo Bianconi
  2025-07-05 21:09 ` [PATCH net-next v2 4/7] net: airoha: npu: Add wlan irq management callbacks Lorenzo Bianconi
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 19+ messages in thread
From: Lorenzo Bianconi @ 2025-07-05 21:09 UTC (permalink / raw)
  To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lorenzo Bianconi
  Cc: linux-arm-kernel, linux-mediatek, netdev, devicetree

Introduce wlan_send_msg() and wlan_get_msg() NPU wlan callbacks used
by the wlan driver (MT76) to initialize NPU module registers in order to
offload wireless-wired traffic.
This is a preliminary patch to enable wlan flowtable offload for EN7581
SoC with MT76 driver.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 drivers/net/ethernet/airoha/airoha_npu.c | 58 ++++++++++++++++++++++++++++++++
 drivers/net/ethernet/airoha/airoha_npu.h | 21 ++++++++++++
 2 files changed, 79 insertions(+)

diff --git a/drivers/net/ethernet/airoha/airoha_npu.c b/drivers/net/ethernet/airoha/airoha_npu.c
index 8c5031a00f54ce64ded5950dafefe5f28d54e79a..a1568233edcb180c7d19245051f0c409664b5242 100644
--- a/drivers/net/ethernet/airoha/airoha_npu.c
+++ b/drivers/net/ethernet/airoha/airoha_npu.c
@@ -42,6 +42,22 @@
 #define REG_CR_MBQ8_CTRL(_n)		(NPU_MBOX_BASE_ADDR + 0x0b0 + ((_n) << 2))
 #define REG_CR_NPU_MIB(_n)		(NPU_MBOX_BASE_ADDR + 0x140 + ((_n) << 2))
 
+#define NPU_WLAN_BASE_ADDR		0x30d000
+
+#define REG_IRQ_STATUS			(NPU_WLAN_BASE_ADDR + 0x030)
+#define REG_IRQ_RXDONE(_n)		(NPU_WLAN_BASE_ADDR + ((_n) << 2) + 0x034)
+#define NPU_IRQ_RX_MASK(_n)		((_n) == 1 ? BIT(17) : BIT(16))
+
+#define REG_TX_BASE(_n)			(NPU_WLAN_BASE_ADDR + ((_n) << 4) + 0x080)
+#define REG_TX_DSCP_NUM(_n)		(NPU_WLAN_BASE_ADDR + ((_n) << 4) + 0x084)
+#define REG_TX_CPU_IDX(_n)		(NPU_WLAN_BASE_ADDR + ((_n) << 4) + 0x088)
+#define REG_TX_DMA_IDX(_n)		(NPU_WLAN_BASE_ADDR + ((_n) << 4) + 0x08c)
+
+#define REG_RX_BASE(_n)			(NPU_WLAN_BASE_ADDR + ((_n) << 4) + 0x180)
+#define REG_RX_DSCP_NUM(_n)		(NPU_WLAN_BASE_ADDR + ((_n) << 4) + 0x184)
+#define REG_RX_CPU_IDX(_n)		(NPU_WLAN_BASE_ADDR + ((_n) << 4) + 0x188)
+#define REG_RX_DMA_IDX(_n)		(NPU_WLAN_BASE_ADDR + ((_n) << 4) + 0x18c)
+
 #define NPU_TIMER_BASE_ADDR		0x310100
 #define REG_WDT_TIMER_CTRL(_n)		(NPU_TIMER_BASE_ADDR + ((_n) * 0x100))
 #define WDT_EN_MASK			BIT(25)
@@ -131,6 +147,12 @@ struct wlan_mbox_data {
 	u32 func_id;
 	union {
 		u32 data;
+		struct {
+			u32 dir;
+			u32 in_counter_addr;
+			u32 out_status_addr;
+			u32 out_counter_addr;
+		} txrx_addr;
 		u8 stats[WLAN_MAX_STATS_SIZE];
 	};
 };
@@ -424,6 +446,30 @@ static int airoha_npu_wlan_msg_send(struct airoha_npu *npu, int ifindex,
 	return err;
 }
 
+static int airoha_npu_wlan_msg_get(struct airoha_npu *npu, int ifindex,
+				   enum airoha_npu_wlan_get_cmd func_id,
+				   u32 *data)
+{
+	struct wlan_mbox_data *wlan_data;
+	int err;
+
+	wlan_data = kzalloc(sizeof(*wlan_data), GFP_ATOMIC);
+	if (!wlan_data)
+		return -ENOMEM;
+
+	wlan_data->ifindex = ifindex;
+	wlan_data->func_type = NPU_OP_GET;
+	wlan_data->func_id = func_id;
+
+	err = airoha_npu_send_msg(npu, NPU_FUNC_WIFI, wlan_data,
+				  sizeof(*wlan_data));
+	if (!err)
+		*data = wlan_data->data;
+	kfree(wlan_data);
+
+	return err;
+}
+
 static int
 airoha_npu_wlan_set_reserved_memory(struct airoha_npu *npu,
 				    int ifindex, const char *name,
@@ -470,6 +516,15 @@ static int airoha_npu_wlan_init_memory(struct airoha_npu *npu)
 	return airoha_npu_wlan_msg_send(npu, 0, cmd, 0, GFP_KERNEL);
 }
 
+static u32 airoha_npu_wlan_queue_addr_get(struct airoha_npu *npu, int qid,
+					  bool xmit)
+{
+	if (xmit)
+		return REG_TX_BASE(qid + 2);
+
+	return REG_RX_BASE(qid);
+}
+
 struct airoha_npu *airoha_npu_get(struct device *dev, dma_addr_t *stats_addr)
 {
 	struct platform_device *pdev;
@@ -574,6 +629,9 @@ static int airoha_npu_probe(struct platform_device *pdev)
 	npu->ops.ppe_flush_sram_entries = airoha_npu_ppe_flush_sram_entries;
 	npu->ops.ppe_foe_commit_entry = airoha_npu_foe_commit_entry;
 	npu->ops.wlan_init_reserved_memory = airoha_npu_wlan_init_memory;
+	npu->ops.wlan_send_msg = airoha_npu_wlan_msg_send;
+	npu->ops.wlan_get_msg = airoha_npu_wlan_msg_get;
+	npu->ops.wlan_get_queue_addr = airoha_npu_wlan_queue_addr_get;
 
 	npu->regmap = devm_regmap_init_mmio(dev, base, &regmap_config);
 	if (IS_ERR(npu->regmap))
diff --git a/drivers/net/ethernet/airoha/airoha_npu.h b/drivers/net/ethernet/airoha/airoha_npu.h
index 58f4ee04e17161acbe513779638c23fe79a83a78..6a9cb1425f48ad8b01daf191ace4e443d22949dc 100644
--- a/drivers/net/ethernet/airoha/airoha_npu.h
+++ b/drivers/net/ethernet/airoha/airoha_npu.h
@@ -43,6 +43,19 @@ enum airoha_npu_wlan_set_cmd {
 	WLAN_FUNC_SET_WAIT_DEBUG_ARRAY_ADDR,
 };
 
+enum airoha_npu_wlan_get_cmd {
+	WLAN_FUNC_GET_WAIT_NPU_INFO,
+	WLAN_FUNC_GET_WAIT_LAST_RATE,
+	WLAN_FUNC_GET_WAIT_COUNTER,
+	WLAN_FUNC_GET_WAIT_DBG_COUNTER,
+	WLAN_FUNC_GET_WAIT_RXDESC_BASE,
+	WLAN_FUNC_GET_WAIT_WCID_DBG_COUNTER,
+	WLAN_FUNC_GET_WAIT_DMA_ADDR,
+	WLAN_FUNC_GET_WAIT_RING_SIZE,
+	WLAN_FUNC_GET_WAIT_NPU_SUPPORT_MAP,
+	WLAN_FUNC_GET_WAIT_MDC_LOCK_ADDRESS,
+};
+
 struct airoha_npu {
 	struct device *dev;
 	struct regmap *regmap;
@@ -67,6 +80,14 @@ struct airoha_npu {
 					    u32 entry_size, u32 hash,
 					    bool ppe2);
 		int (*wlan_init_reserved_memory)(struct airoha_npu *npu);
+		int (*wlan_send_msg)(struct airoha_npu *npu, int ifindex,
+				     enum airoha_npu_wlan_set_cmd func_id,
+				     u32 data, gfp_t gfp);
+		int (*wlan_get_msg)(struct airoha_npu *npu, int ifindex,
+				    enum airoha_npu_wlan_get_cmd func_id,
+				    u32 *data);
+		u32 (*wlan_get_queue_addr)(struct airoha_npu *npu, int qid,
+					   bool xmit);
 	} ops;
 };
 

-- 
2.50.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH net-next v2 4/7] net: airoha: npu: Add wlan irq management callbacks
  2025-07-05 21:09 [PATCH net-next v2 0/7] net: airoha: Introduce NPU callbacks for wlan offloading Lorenzo Bianconi
                   ` (2 preceding siblings ...)
  2025-07-05 21:09 ` [PATCH net-next v2 3/7] net: airoha: npu: Add wlan_{send,get}_msg NPU callbacks Lorenzo Bianconi
@ 2025-07-05 21:09 ` Lorenzo Bianconi
  2025-07-05 21:09 ` [PATCH net-next v2 5/7] net: airoha: npu: Read NPU wlan interrupt lines from the DTS Lorenzo Bianconi
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 19+ messages in thread
From: Lorenzo Bianconi @ 2025-07-05 21:09 UTC (permalink / raw)
  To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lorenzo Bianconi
  Cc: linux-arm-kernel, linux-mediatek, netdev, devicetree,
	Simon Horman

Introduce callbacks used by the MT76 driver to configure NPU SoC
interrupts. This is a preliminary patch to enable wlan flowtable
offload for EN7581 SoC with MT76 driver.

Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 drivers/net/ethernet/airoha/airoha_npu.c | 27 +++++++++++++++++++++++++++
 drivers/net/ethernet/airoha/airoha_npu.h |  4 ++++
 2 files changed, 31 insertions(+)

diff --git a/drivers/net/ethernet/airoha/airoha_npu.c b/drivers/net/ethernet/airoha/airoha_npu.c
index a1568233edcb180c7d19245051f0c409664b5242..aa7edb60e5d1d19fbfc0675bae623cab346bf211 100644
--- a/drivers/net/ethernet/airoha/airoha_npu.c
+++ b/drivers/net/ethernet/airoha/airoha_npu.c
@@ -525,6 +525,29 @@ static u32 airoha_npu_wlan_queue_addr_get(struct airoha_npu *npu, int qid,
 	return REG_RX_BASE(qid);
 }
 
+static void airoha_npu_wlan_irq_status_set(struct airoha_npu *npu, u32 val)
+{
+	regmap_write(npu->regmap, REG_IRQ_STATUS, val);
+}
+
+static u32 airoha_npu_wlan_irq_status_get(struct airoha_npu *npu, int q)
+{
+	u32 val;
+
+	regmap_read(npu->regmap, REG_IRQ_STATUS, &val);
+	return val;
+}
+
+static void airoha_npu_wlan_irq_enable(struct airoha_npu *npu, int q)
+{
+	regmap_set_bits(npu->regmap, REG_IRQ_RXDONE(q), NPU_IRQ_RX_MASK(q));
+}
+
+static void airoha_npu_wlan_irq_disable(struct airoha_npu *npu, int q)
+{
+	regmap_clear_bits(npu->regmap, REG_IRQ_RXDONE(q), NPU_IRQ_RX_MASK(q));
+}
+
 struct airoha_npu *airoha_npu_get(struct device *dev, dma_addr_t *stats_addr)
 {
 	struct platform_device *pdev;
@@ -632,6 +655,10 @@ static int airoha_npu_probe(struct platform_device *pdev)
 	npu->ops.wlan_send_msg = airoha_npu_wlan_msg_send;
 	npu->ops.wlan_get_msg = airoha_npu_wlan_msg_get;
 	npu->ops.wlan_get_queue_addr = airoha_npu_wlan_queue_addr_get;
+	npu->ops.wlan_set_irq_status = airoha_npu_wlan_irq_status_set;
+	npu->ops.wlan_get_irq_status = airoha_npu_wlan_irq_status_get;
+	npu->ops.wlan_enable_irq = airoha_npu_wlan_irq_enable;
+	npu->ops.wlan_disable_irq = airoha_npu_wlan_irq_disable;
 
 	npu->regmap = devm_regmap_init_mmio(dev, base, &regmap_config);
 	if (IS_ERR(npu->regmap))
diff --git a/drivers/net/ethernet/airoha/airoha_npu.h b/drivers/net/ethernet/airoha/airoha_npu.h
index 6a9cb1425f48ad8b01daf191ace4e443d22949dc..9e225df8b6c94b40386cc015cc086e9de7489a53 100644
--- a/drivers/net/ethernet/airoha/airoha_npu.h
+++ b/drivers/net/ethernet/airoha/airoha_npu.h
@@ -88,6 +88,10 @@ struct airoha_npu {
 				    u32 *data);
 		u32 (*wlan_get_queue_addr)(struct airoha_npu *npu, int qid,
 					   bool xmit);
+		void (*wlan_set_irq_status)(struct airoha_npu *npu, u32 val);
+		u32 (*wlan_get_irq_status)(struct airoha_npu *npu, int q);
+		void (*wlan_enable_irq)(struct airoha_npu *npu, int q);
+		void (*wlan_disable_irq)(struct airoha_npu *npu, int q);
 	} ops;
 };
 

-- 
2.50.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH net-next v2 5/7] net: airoha: npu: Read NPU wlan interrupt lines from the DTS
  2025-07-05 21:09 [PATCH net-next v2 0/7] net: airoha: Introduce NPU callbacks for wlan offloading Lorenzo Bianconi
                   ` (3 preceding siblings ...)
  2025-07-05 21:09 ` [PATCH net-next v2 4/7] net: airoha: npu: Add wlan irq management callbacks Lorenzo Bianconi
@ 2025-07-05 21:09 ` Lorenzo Bianconi
  2025-07-05 21:09 ` [PATCH net-next v2 6/7] net: airoha: npu: Enable core 3 for WiFi offloading Lorenzo Bianconi
  2025-07-05 21:09 ` [PATCH net-next v2 7/7] net: airoha: Add airoha_offload.h header Lorenzo Bianconi
  6 siblings, 0 replies; 19+ messages in thread
From: Lorenzo Bianconi @ 2025-07-05 21:09 UTC (permalink / raw)
  To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lorenzo Bianconi
  Cc: linux-arm-kernel, linux-mediatek, netdev, devicetree

Read all NPU wlan IRQ lines from the NPU device-tree node.
NPU module fires wlan irq lines when the traffic to/from the WiFi NIC is
not hw accelerated (these interrupts will be consumed by the MT76 driver
in subsequent patches).
This is a preliminary patch to enable wlan flowtable offload for EN7581
SoC.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 drivers/net/ethernet/airoha/airoha_npu.c | 9 +++++++++
 drivers/net/ethernet/airoha/airoha_npu.h | 3 +++
 2 files changed, 12 insertions(+)

diff --git a/drivers/net/ethernet/airoha/airoha_npu.c b/drivers/net/ethernet/airoha/airoha_npu.c
index aa7edb60e5d1d19fbfc0675bae623cab346bf211..8c31df5b760730814ccfaa9fffff6c6aa8742f01 100644
--- a/drivers/net/ethernet/airoha/airoha_npu.c
+++ b/drivers/net/ethernet/airoha/airoha_npu.c
@@ -701,6 +701,15 @@ static int airoha_npu_probe(struct platform_device *pdev)
 		INIT_WORK(&core->wdt_work, airoha_npu_wdt_work);
 	}
 
+	/* wlan IRQ lines */
+	for (i = 0; i < ARRAY_SIZE(npu->irqs); i++) {
+		irq = platform_get_irq(pdev, i + ARRAY_SIZE(npu->cores) + 1);
+		if (irq < 0)
+			return irq;
+
+		npu->irqs[i] = irq;
+	}
+
 	err = dma_set_coherent_mask(dev, DMA_BIT_MASK(32));
 	if (err)
 		return err;
diff --git a/drivers/net/ethernet/airoha/airoha_npu.h b/drivers/net/ethernet/airoha/airoha_npu.h
index 9e225df8b6c94b40386cc015cc086e9de7489a53..72b1d41d99e798ed32e8abdaa443e4775c6defd1 100644
--- a/drivers/net/ethernet/airoha/airoha_npu.h
+++ b/drivers/net/ethernet/airoha/airoha_npu.h
@@ -5,6 +5,7 @@
  */
 
 #define NPU_NUM_CORES		8
+#define NPU_NUM_IRQ		6
 
 enum airoha_npu_wlan_set_cmd {
 	WLAN_FUNC_SET_WAIT_PCIE_ADDR,
@@ -67,6 +68,8 @@ struct airoha_npu {
 		struct work_struct wdt_work;
 	} cores[NPU_NUM_CORES];
 
+	int irqs[NPU_NUM_IRQ];
+
 	struct airoha_foe_stats __iomem *stats;
 
 	struct {

-- 
2.50.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH net-next v2 6/7] net: airoha: npu: Enable core 3 for WiFi offloading
  2025-07-05 21:09 [PATCH net-next v2 0/7] net: airoha: Introduce NPU callbacks for wlan offloading Lorenzo Bianconi
                   ` (4 preceding siblings ...)
  2025-07-05 21:09 ` [PATCH net-next v2 5/7] net: airoha: npu: Read NPU wlan interrupt lines from the DTS Lorenzo Bianconi
@ 2025-07-05 21:09 ` Lorenzo Bianconi
  2025-07-05 21:09 ` [PATCH net-next v2 7/7] net: airoha: Add airoha_offload.h header Lorenzo Bianconi
  6 siblings, 0 replies; 19+ messages in thread
From: Lorenzo Bianconi @ 2025-07-05 21:09 UTC (permalink / raw)
  To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lorenzo Bianconi
  Cc: linux-arm-kernel, linux-mediatek, netdev, devicetree,
	Simon Horman

NPU core 3 is responsible for WiFi offloading so enable it during NPU
probe.

Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 drivers/net/ethernet/airoha/airoha_npu.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/airoha/airoha_npu.c b/drivers/net/ethernet/airoha/airoha_npu.c
index 8c31df5b760730814ccfaa9fffff6c6aa8742f01..cbd81394cfb6d512d131f1c805f5c15d95d08634 100644
--- a/drivers/net/ethernet/airoha/airoha_npu.c
+++ b/drivers/net/ethernet/airoha/airoha_npu.c
@@ -731,8 +731,7 @@ static int airoha_npu_probe(struct platform_device *pdev)
 	usleep_range(1000, 2000);
 
 	/* enable NPU cores */
-	/* do not start core3 since it is used for WiFi offloading */
-	regmap_write(npu->regmap, REG_CR_BOOT_CONFIG, 0xf7);
+	regmap_write(npu->regmap, REG_CR_BOOT_CONFIG, 0xff);
 	regmap_write(npu->regmap, REG_CR_BOOT_TRIGGER, 0x1);
 	msleep(100);
 

-- 
2.50.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH net-next v2 7/7] net: airoha: Add airoha_offload.h header
  2025-07-05 21:09 [PATCH net-next v2 0/7] net: airoha: Introduce NPU callbacks for wlan offloading Lorenzo Bianconi
                   ` (5 preceding siblings ...)
  2025-07-05 21:09 ` [PATCH net-next v2 6/7] net: airoha: npu: Enable core 3 for WiFi offloading Lorenzo Bianconi
@ 2025-07-05 21:09 ` Lorenzo Bianconi
  6 siblings, 0 replies; 19+ messages in thread
From: Lorenzo Bianconi @ 2025-07-05 21:09 UTC (permalink / raw)
  To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lorenzo Bianconi
  Cc: linux-arm-kernel, linux-mediatek, netdev, devicetree

Move NPU definitions to airoha_offload.h in include/linux/soc/airoha/ in
order to allow the MT76 driver to access the callback definitions.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 drivers/net/ethernet/airoha/airoha_npu.c  |   2 +-
 drivers/net/ethernet/airoha/airoha_npu.h  | 102 ------------
 drivers/net/ethernet/airoha/airoha_ppe.c  |   2 +-
 include/linux/soc/airoha/airoha_offload.h | 256 ++++++++++++++++++++++++++++++
 4 files changed, 258 insertions(+), 104 deletions(-)

diff --git a/drivers/net/ethernet/airoha/airoha_npu.c b/drivers/net/ethernet/airoha/airoha_npu.c
index cbd81394cfb6d512d131f1c805f5c15d95d08634..c3782de5dcdab158076fc1c2c8fb155f13b26fb2 100644
--- a/drivers/net/ethernet/airoha/airoha_npu.c
+++ b/drivers/net/ethernet/airoha/airoha_npu.c
@@ -11,9 +11,9 @@
 #include <linux/of_platform.h>
 #include <linux/of_reserved_mem.h>
 #include <linux/regmap.h>
+#include <linux/soc/airoha/airoha_offload.h>
 
 #include "airoha_eth.h"
-#include "airoha_npu.h"
 
 #define NPU_EN7581_FIRMWARE_DATA		"airoha/en7581_npu_data.bin"
 #define NPU_EN7581_FIRMWARE_RV32		"airoha/en7581_npu_rv32.bin"
diff --git a/drivers/net/ethernet/airoha/airoha_npu.h b/drivers/net/ethernet/airoha/airoha_npu.h
deleted file mode 100644
index 72b1d41d99e798ed32e8abdaa443e4775c6defd1..0000000000000000000000000000000000000000
--- a/drivers/net/ethernet/airoha/airoha_npu.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Copyright (c) 2025 AIROHA Inc
- * Author: Lorenzo Bianconi <lorenzo@kernel.org>
- */
-
-#define NPU_NUM_CORES		8
-#define NPU_NUM_IRQ		6
-
-enum airoha_npu_wlan_set_cmd {
-	WLAN_FUNC_SET_WAIT_PCIE_ADDR,
-	WLAN_FUNC_SET_WAIT_DESC,
-	WLAN_FUNC_SET_WAIT_NPU_INIT_DONE,
-	WLAN_FUNC_SET_WAIT_TRAN_TO_CPU,
-	WLAN_FUNC_SET_WAIT_BA_WIN_SIZE,
-	WLAN_FUNC_SET_WAIT_DRIVER_MODEL,
-	WLAN_FUNC_SET_WAIT_DEL_STA,
-	WLAN_FUNC_SET_WAIT_DRAM_BA_NODE_ADDR,
-	WLAN_FUNC_SET_WAIT_PKT_BUF_ADDR,
-	WLAN_FUNC_SET_WAIT_IS_TEST_NOBA,
-	WLAN_FUNC_SET_WAIT_FLUSHONE_TIMEOUT,
-	WLAN_FUNC_SET_WAIT_FLUSHALL_TIMEOUT,
-	WLAN_FUNC_SET_WAIT_IS_FORCE_TO_CPU,
-	WLAN_FUNC_SET_WAIT_PCIE_STATE,
-	WLAN_FUNC_SET_WAIT_PCIE_PORT_TYPE,
-	WLAN_FUNC_SET_WAIT_ERROR_RETRY_TIMES,
-	WLAN_FUNC_SET_WAIT_BAR_INFO,
-	WLAN_FUNC_SET_WAIT_FAST_FLAG,
-	WLAN_FUNC_SET_WAIT_NPU_BAND0_ONCPU,
-	WLAN_FUNC_SET_WAIT_TX_RING_PCIE_ADDR,
-	WLAN_FUNC_SET_WAIT_TX_DESC_HW_BASE,
-	WLAN_FUNC_SET_WAIT_TX_BUF_SPACE_HW_BASE,
-	WLAN_FUNC_SET_WAIT_RX_RING_FOR_TXDONE_HW_BASE,
-	WLAN_FUNC_SET_WAIT_TX_PKT_BUF_ADDR,
-	WLAN_FUNC_SET_WAIT_INODE_TXRX_REG_ADDR,
-	WLAN_FUNC_SET_WAIT_INODE_DEBUG_FLAG,
-	WLAN_FUNC_SET_WAIT_INODE_HW_CFG_INFO,
-	WLAN_FUNC_SET_WAIT_INODE_STOP_ACTION,
-	WLAN_FUNC_SET_WAIT_INODE_PCIE_SWAP,
-	WLAN_FUNC_SET_WAIT_RATELIMIT_CTRL,
-	WLAN_FUNC_SET_WAIT_HWNAT_INIT,
-	WLAN_FUNC_SET_WAIT_ARHT_CHIP_INFO,
-	WLAN_FUNC_SET_WAIT_TX_BUF_CHECK_ADDR,
-	WLAN_FUNC_SET_WAIT_DEBUG_ARRAY_ADDR,
-};
-
-enum airoha_npu_wlan_get_cmd {
-	WLAN_FUNC_GET_WAIT_NPU_INFO,
-	WLAN_FUNC_GET_WAIT_LAST_RATE,
-	WLAN_FUNC_GET_WAIT_COUNTER,
-	WLAN_FUNC_GET_WAIT_DBG_COUNTER,
-	WLAN_FUNC_GET_WAIT_RXDESC_BASE,
-	WLAN_FUNC_GET_WAIT_WCID_DBG_COUNTER,
-	WLAN_FUNC_GET_WAIT_DMA_ADDR,
-	WLAN_FUNC_GET_WAIT_RING_SIZE,
-	WLAN_FUNC_GET_WAIT_NPU_SUPPORT_MAP,
-	WLAN_FUNC_GET_WAIT_MDC_LOCK_ADDRESS,
-};
-
-struct airoha_npu {
-	struct device *dev;
-	struct regmap *regmap;
-
-	struct airoha_npu_core {
-		struct airoha_npu *npu;
-		/* protect concurrent npu memory accesses */
-		spinlock_t lock;
-		struct work_struct wdt_work;
-	} cores[NPU_NUM_CORES];
-
-	int irqs[NPU_NUM_IRQ];
-
-	struct airoha_foe_stats __iomem *stats;
-
-	struct {
-		int (*ppe_init)(struct airoha_npu *npu);
-		int (*ppe_deinit)(struct airoha_npu *npu);
-		int (*ppe_flush_sram_entries)(struct airoha_npu *npu,
-					      dma_addr_t foe_addr,
-					      int sram_num_entries);
-		int (*ppe_foe_commit_entry)(struct airoha_npu *npu,
-					    dma_addr_t foe_addr,
-					    u32 entry_size, u32 hash,
-					    bool ppe2);
-		int (*wlan_init_reserved_memory)(struct airoha_npu *npu);
-		int (*wlan_send_msg)(struct airoha_npu *npu, int ifindex,
-				     enum airoha_npu_wlan_set_cmd func_id,
-				     u32 data, gfp_t gfp);
-		int (*wlan_get_msg)(struct airoha_npu *npu, int ifindex,
-				    enum airoha_npu_wlan_get_cmd func_id,
-				    u32 *data);
-		u32 (*wlan_get_queue_addr)(struct airoha_npu *npu, int qid,
-					   bool xmit);
-		void (*wlan_set_irq_status)(struct airoha_npu *npu, u32 val);
-		u32 (*wlan_get_irq_status)(struct airoha_npu *npu, int q);
-		void (*wlan_enable_irq)(struct airoha_npu *npu, int q);
-		void (*wlan_disable_irq)(struct airoha_npu *npu, int q);
-	} ops;
-};
-
-struct airoha_npu *airoha_npu_get(struct device *dev, dma_addr_t *stats_addr);
-void airoha_npu_put(struct airoha_npu *npu);
diff --git a/drivers/net/ethernet/airoha/airoha_ppe.c b/drivers/net/ethernet/airoha/airoha_ppe.c
index c354d536bc66e97ab853792e4ab4273283d2fb91..5d12bde6b20a89b3037ae4405b383d75307e8239 100644
--- a/drivers/net/ethernet/airoha/airoha_ppe.c
+++ b/drivers/net/ethernet/airoha/airoha_ppe.c
@@ -7,10 +7,10 @@
 #include <linux/ip.h>
 #include <linux/ipv6.h>
 #include <linux/rhashtable.h>
+#include <linux/soc/airoha/airoha_offload.h>
 #include <net/ipv6.h>
 #include <net/pkt_cls.h>
 
-#include "airoha_npu.h"
 #include "airoha_regs.h"
 #include "airoha_eth.h"
 
diff --git a/include/linux/soc/airoha/airoha_offload.h b/include/linux/soc/airoha/airoha_offload.h
new file mode 100644
index 0000000000000000000000000000000000000000..5b15e4b3d53385c84ac5ac4fb33cb57f03c663fc
--- /dev/null
+++ b/include/linux/soc/airoha/airoha_offload.h
@@ -0,0 +1,256 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) 2025 AIROHA Inc
+ * Author: Lorenzo Bianconi <lorenzo@kernel.org>
+ */
+#ifndef AIROHA_OFFLOAD_H
+#define AIROHA_OFFLOAD_H
+
+#define NPU_NUM_CORES		8
+#define NPU_NUM_IRQ		6
+#define NPU_RX0_DESC_NUM	512
+#define NPU_RX1_DESC_NUM	512
+
+/* CTRL */
+#define NPU_RX_DMA_DESC_LAST_MASK	BIT(29)
+#define NPU_RX_DMA_DESC_LEN_MASK	GENMASK(28, 15)
+#define NPU_RX_DMA_DESC_CUR_LEN_MASK	GENMASK(14, 1)
+#define NPU_RX_DMA_DESC_DONE_MASK	BIT(0)
+/* INFO */
+#define NPU_RX_DMA_PKT_COUNT_MASK	GENMASK(31, 28)
+#define NPU_RX_DMA_PKT_ID_MASK		GENMASK(28, 26)
+#define NPU_RX_DMA_SRC_PORT_MASK	GENMASK(25, 21)
+#define NPU_RX_DMA_CRSN_MASK		GENMASK(20, 16)
+#define NPU_RX_DMA_FOE_ID_MASK		GENMASK(15, 0)
+/* DATA */
+#define NPU_RX_DMA_SID_MASK		GENMASK(31, 16)
+#define NPU_RX_DMA_FRAG_TYPE_MASK	GENMASK(15, 14)
+#define NPU_RX_DMA_PRIORITY_MASK	GENMASK(13, 10)
+#define NPU_RX_DMA_RADIO_ID_MASK	GENMASK(9, 6)
+#define NPU_RX_DMA_VAP_ID_MASK		GENMASK(5, 2)
+#define NPU_RX_DMA_FRAME_TYPE_MASK	GENMASK(1, 0)
+
+struct airoha_npu_rx_dma_desc {
+	u32 ctrl;
+	u32 info;
+	u32 data;
+	u32 addr;
+	u64 rsv;
+} __packed;
+
+/* CTRL */
+#define NPU_TX_DMA_DESC_SCHED_MASK	BIT(31)
+#define NPU_TX_DMA_DESC_LEN_MASK	GENMASK(30, 18)
+#define NPU_TX_DMA_DESC_VEND_LEN_MASK	GENMASK(17, 1)
+#define NPU_TX_DMA_DESC_DONE_MASK	BIT(0)
+
+#define NPU_TXWI_LEN	192
+
+struct airoha_npu_tx_dma_desc {
+	u32 ctrl;
+	u32 addr;
+	u64 rsv;
+	u8 txwi[NPU_TXWI_LEN];
+} __packed;
+
+enum airoha_npu_wlan_set_cmd {
+	WLAN_FUNC_SET_WAIT_PCIE_ADDR,
+	WLAN_FUNC_SET_WAIT_DESC,
+	WLAN_FUNC_SET_WAIT_NPU_INIT_DONE,
+	WLAN_FUNC_SET_WAIT_TRAN_TO_CPU,
+	WLAN_FUNC_SET_WAIT_BA_WIN_SIZE,
+	WLAN_FUNC_SET_WAIT_DRIVER_MODEL,
+	WLAN_FUNC_SET_WAIT_DEL_STA,
+	WLAN_FUNC_SET_WAIT_DRAM_BA_NODE_ADDR,
+	WLAN_FUNC_SET_WAIT_PKT_BUF_ADDR,
+	WLAN_FUNC_SET_WAIT_IS_TEST_NOBA,
+	WLAN_FUNC_SET_WAIT_FLUSHONE_TIMEOUT,
+	WLAN_FUNC_SET_WAIT_FLUSHALL_TIMEOUT,
+	WLAN_FUNC_SET_WAIT_IS_FORCE_TO_CPU,
+	WLAN_FUNC_SET_WAIT_PCIE_STATE,
+	WLAN_FUNC_SET_WAIT_PCIE_PORT_TYPE,
+	WLAN_FUNC_SET_WAIT_ERROR_RETRY_TIMES,
+	WLAN_FUNC_SET_WAIT_BAR_INFO,
+	WLAN_FUNC_SET_WAIT_FAST_FLAG,
+	WLAN_FUNC_SET_WAIT_NPU_BAND0_ONCPU,
+	WLAN_FUNC_SET_WAIT_TX_RING_PCIE_ADDR,
+	WLAN_FUNC_SET_WAIT_TX_DESC_HW_BASE,
+	WLAN_FUNC_SET_WAIT_TX_BUF_SPACE_HW_BASE,
+	WLAN_FUNC_SET_WAIT_RX_RING_FOR_TXDONE_HW_BASE,
+	WLAN_FUNC_SET_WAIT_TX_PKT_BUF_ADDR,
+	WLAN_FUNC_SET_WAIT_INODE_TXRX_REG_ADDR,
+	WLAN_FUNC_SET_WAIT_INODE_DEBUG_FLAG,
+	WLAN_FUNC_SET_WAIT_INODE_HW_CFG_INFO,
+	WLAN_FUNC_SET_WAIT_INODE_STOP_ACTION,
+	WLAN_FUNC_SET_WAIT_INODE_PCIE_SWAP,
+	WLAN_FUNC_SET_WAIT_RATELIMIT_CTRL,
+	WLAN_FUNC_SET_WAIT_HWNAT_INIT,
+	WLAN_FUNC_SET_WAIT_ARHT_CHIP_INFO,
+	WLAN_FUNC_SET_WAIT_TX_BUF_CHECK_ADDR,
+	WLAN_FUNC_SET_WAIT_DEBUG_ARRAY_ADDR,
+};
+
+enum airoha_npu_wlan_get_cmd {
+	WLAN_FUNC_GET_WAIT_NPU_INFO,
+	WLAN_FUNC_GET_WAIT_LAST_RATE,
+	WLAN_FUNC_GET_WAIT_COUNTER,
+	WLAN_FUNC_GET_WAIT_DBG_COUNTER,
+	WLAN_FUNC_GET_WAIT_RXDESC_BASE,
+	WLAN_FUNC_GET_WAIT_WCID_DBG_COUNTER,
+	WLAN_FUNC_GET_WAIT_DMA_ADDR,
+	WLAN_FUNC_GET_WAIT_RING_SIZE,
+	WLAN_FUNC_GET_WAIT_NPU_SUPPORT_MAP,
+	WLAN_FUNC_GET_WAIT_MDC_LOCK_ADDRESS,
+};
+
+struct airoha_npu {
+#if (IS_BUILTIN(CONFIG_NET_AIROHA_NPU) || IS_MODULE(CONFIG_NET_AIROHA_NPU))
+	struct device *dev;
+	struct regmap *regmap;
+
+	struct airoha_npu_core {
+		struct airoha_npu *npu;
+		/* protect concurrent npu memory accesses */
+		spinlock_t lock;
+		struct work_struct wdt_work;
+	} cores[NPU_NUM_CORES];
+
+	int irqs[NPU_NUM_IRQ];
+
+	struct airoha_foe_stats __iomem *stats;
+
+	struct {
+		int (*ppe_init)(struct airoha_npu *npu);
+		int (*ppe_deinit)(struct airoha_npu *npu);
+		int (*ppe_flush_sram_entries)(struct airoha_npu *npu,
+					      dma_addr_t foe_addr,
+					      int sram_num_entries);
+		int (*ppe_foe_commit_entry)(struct airoha_npu *npu,
+					    dma_addr_t foe_addr,
+					    u32 entry_size, u32 hash,
+					    bool ppe2);
+		int (*wlan_init_reserved_memory)(struct airoha_npu *npu);
+		int (*wlan_send_msg)(struct airoha_npu *npu, int ifindex,
+				     enum airoha_npu_wlan_set_cmd func_id,
+				     u32 data, gfp_t gfp);
+		int (*wlan_get_msg)(struct airoha_npu *npu, int ifindex,
+				    enum airoha_npu_wlan_get_cmd func_id,
+				    u32 *data);
+		u32 (*wlan_get_queue_addr)(struct airoha_npu *npu, int qid,
+					   bool xmit);
+		void (*wlan_set_irq_status)(struct airoha_npu *npu, u32 val);
+		u32 (*wlan_get_irq_status)(struct airoha_npu *npu, int q);
+		void (*wlan_enable_irq)(struct airoha_npu *npu, int q);
+		void (*wlan_disable_irq)(struct airoha_npu *npu, int q);
+	} ops;
+#endif
+};
+
+#if (IS_BUILTIN(CONFIG_NET_AIROHA_NPU) || IS_MODULE(CONFIG_NET_AIROHA_NPU))
+struct airoha_npu *airoha_npu_get(struct device *dev, dma_addr_t *stats_addr);
+void airoha_npu_put(struct airoha_npu *npu);
+
+static inline int airoha_npu_wlan_init_reserved_memory(struct airoha_npu *npu)
+{
+	return npu->ops.wlan_init_reserved_memory(npu);
+}
+
+static inline int airoha_npu_wlan_send_msg(struct airoha_npu *npu,
+					   int ifindex,
+					   enum airoha_npu_wlan_set_cmd cmd,
+					   u32 data, gfp_t gfp)
+{
+	return npu->ops.wlan_send_msg(npu, ifindex, cmd, data, gfp);
+}
+
+static inline int airoha_npu_wlan_get_msg(struct airoha_npu *npu, int ifindex,
+					  enum airoha_npu_wlan_get_cmd cmd,
+					  u32 *data)
+{
+	return npu->ops.wlan_get_msg(npu, ifindex, cmd, data);
+}
+
+static inline u32 airoha_npu_wlan_get_queue_addr(struct airoha_npu *npu,
+						 int qid, bool xmit)
+{
+	return npu->ops.wlan_get_queue_addr(npu, qid, xmit);
+}
+
+static inline void airoha_npu_wlan_set_irq_status(struct airoha_npu *npu,
+						  u32 val)
+{
+	npu->ops.wlan_set_irq_status(npu, val);
+}
+
+static inline u32 airoha_npu_wlan_get_irq_status(struct airoha_npu *npu, int q)
+{
+	return npu->ops.wlan_get_irq_status(npu, q);
+}
+
+static inline void airoha_npu_wlan_enable_irq(struct airoha_npu *npu, int q)
+{
+	npu->ops.wlan_enable_irq(npu, q);
+}
+
+static inline void airoha_npu_wlan_disable_irq(struct airoha_npu *npu, int q)
+{
+	npu->ops.wlan_disable_irq(npu, q);
+}
+#else
+static inline struct airoha_npu *airoha_npu_get(struct device *dev,
+						dma_addr_t *foe_stats_addr)
+{
+	return NULL;
+}
+
+static inline void airoha_npu_put(struct airoha_npu *npu)
+{
+}
+
+static inline int airoha_npu_wlan_init_reserved_memory(struct airoha_npu *npu)
+{
+	return -EOPNOTSUPP;
+}
+
+static inline int airoha_npu_wlan_send_msg(struct airoha_npu *npu,
+					   int ifindex,
+					   enum airoha_npu_wlan_set_cmd cmd,
+					   u32 data, gfp_t gfp)
+{
+	return -EOPNOTSUPP;
+}
+
+static inline int airoha_npu_wlan_get_msg(struct airoha_npu *npu, int ifindex,
+					  enum airoha_npu_wlan_get_cmd cmd,
+					  u32 *data)
+{
+	return -EOPNOTSUPP;
+}
+
+static inline u32 airoha_npu_wlan_get_queue_addr(struct airoha_npu *npu,
+						 int qid, bool xmit)
+{
+	return 0;
+}
+
+static inline void airoha_npu_wlan_set_irq_status(struct airoha_npu *npu,
+						  u32 val)
+{
+}
+
+static inline u32 airoha_npu_wlan_get_irq_status(struct airoha_npu *npu,
+						 int q)
+{
+	return 0;
+}
+
+static inline void airoha_npu_wlan_enable_irq(struct airoha_npu *npu, int q)
+{
+}
+
+static inline void airoha_npu_wlan_disable_irq(struct airoha_npu *npu, int q)
+{
+}
+#endif
+
+#endif /* AIROHA_OFFLOAD_H */

-- 
2.50.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [PATCH net-next v2 1/7] dt-bindings: net: airoha: npu: Add memory regions used for wlan offload
  2025-07-05 21:09 ` [PATCH net-next v2 1/7] dt-bindings: net: airoha: npu: Add memory regions used for wlan offload Lorenzo Bianconi
@ 2025-07-07  7:05   ` Krzysztof Kozlowski
  2025-07-07  7:25     ` Lorenzo Bianconi
  0 siblings, 1 reply; 19+ messages in thread
From: Krzysztof Kozlowski @ 2025-07-07  7:05 UTC (permalink / raw)
  To: Lorenzo Bianconi
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	linux-arm-kernel, linux-mediatek, netdev, devicetree

On Sat, Jul 05, 2025 at 11:09:45PM +0200, Lorenzo Bianconi wrote:
> Document memory regions used by Airoha EN7581 NPU for wlan traffic
> offloading.
> 
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
>  .../devicetree/bindings/net/airoha,en7581-npu.yaml   | 20 ++++++++++++++++----
>  1 file changed, 16 insertions(+), 4 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/net/airoha,en7581-npu.yaml b/Documentation/devicetree/bindings/net/airoha,en7581-npu.yaml
> index 76dd97c3fb4004674dc30a54c039c1cc19afedb3..db9269d1801bafa9be3b6c199a9e30cd23f4aea9 100644
> --- a/Documentation/devicetree/bindings/net/airoha,en7581-npu.yaml
> +++ b/Documentation/devicetree/bindings/net/airoha,en7581-npu.yaml
> @@ -41,15 +41,25 @@ properties:
>        - description: wlan irq line5
>  
>    memory-region:
> -    maxItems: 1
> -    description:
> -      Memory used to store NPU firmware binary.
> +    items:
> +      - description: NPU firmware binary region
> +      - description: NPU wlan offload RX buffers region
> +      - description: NPU wlan offload TX buffers region
> +      - description: NPU wlan offload TX packet identifiers region
> +
> +  memory-region-names:
> +    items:
> +      - const: binary

Rather: firmware

> +      - const: pkt
> +      - const: tx-pkt
> +      - const: tx-bufid
>  
>  required:
>    - compatible
>    - reg
>    - interrupts
>    - memory-region
> +  - memory-region-names

That's ABI break.

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH net-next v2 2/7] net: airoha: npu: Add NPU wlan memory initialization commands
  2025-07-05 21:09 ` [PATCH net-next v2 2/7] net: airoha: npu: Add NPU wlan memory initialization commands Lorenzo Bianconi
@ 2025-07-07  7:09   ` Krzysztof Kozlowski
  2025-07-07  7:24     ` Lorenzo Bianconi
  0 siblings, 1 reply; 19+ messages in thread
From: Krzysztof Kozlowski @ 2025-07-07  7:09 UTC (permalink / raw)
  To: Lorenzo Bianconi
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	linux-arm-kernel, linux-mediatek, netdev, devicetree,
	Simon Horman

On Sat, Jul 05, 2025 at 11:09:46PM +0200, Lorenzo Bianconi wrote:
> +
>  struct airoha_npu *airoha_npu_get(struct device *dev, dma_addr_t *stats_addr)
>  {
>  	struct platform_device *pdev;
> @@ -493,6 +573,7 @@ static int airoha_npu_probe(struct platform_device *pdev)
>  	npu->ops.ppe_deinit = airoha_npu_ppe_deinit;
>  	npu->ops.ppe_flush_sram_entries = airoha_npu_ppe_flush_sram_entries;
>  	npu->ops.ppe_foe_commit_entry = airoha_npu_foe_commit_entry;
> +	npu->ops.wlan_init_reserved_memory = airoha_npu_wlan_init_memory;

I cannot find in your code single place calling this (later you add a
wrapper... which is not called either).

All this looks like dead code...

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH net-next v2 2/7] net: airoha: npu: Add NPU wlan memory initialization commands
  2025-07-07  7:09   ` Krzysztof Kozlowski
@ 2025-07-07  7:24     ` Lorenzo Bianconi
  2025-07-07 15:04       ` Krzysztof Kozlowski
  0 siblings, 1 reply; 19+ messages in thread
From: Lorenzo Bianconi @ 2025-07-07  7:24 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	linux-arm-kernel, linux-mediatek, netdev, devicetree,
	Simon Horman, Felix Fietkau

[-- Attachment #1: Type: text/plain, Size: 1069 bytes --]

> On Sat, Jul 05, 2025 at 11:09:46PM +0200, Lorenzo Bianconi wrote:
> > +
> >  struct airoha_npu *airoha_npu_get(struct device *dev, dma_addr_t *stats_addr)
> >  {
> >  	struct platform_device *pdev;
> > @@ -493,6 +573,7 @@ static int airoha_npu_probe(struct platform_device *pdev)
> >  	npu->ops.ppe_deinit = airoha_npu_ppe_deinit;
> >  	npu->ops.ppe_flush_sram_entries = airoha_npu_ppe_flush_sram_entries;
> >  	npu->ops.ppe_foe_commit_entry = airoha_npu_foe_commit_entry;
> > +	npu->ops.wlan_init_reserved_memory = airoha_npu_wlan_init_memory;
> 
> I cannot find in your code single place calling this (later you add a
> wrapper... which is not called either).
> 
> All this looks like dead code...

As pointed out in the commit log, these callbacks will be used by MT76 driver
to initialize the NPU reserved memory and registers during driver probe in
order to initialize the WiFi offloading. Since MT76 patches are going via
the wireless tree, I needed to add these callbacks first.

Regards,
Lorenzo

> 
> Best regards,
> Krzysztof
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH net-next v2 1/7] dt-bindings: net: airoha: npu: Add memory regions used for wlan offload
  2025-07-07  7:05   ` Krzysztof Kozlowski
@ 2025-07-07  7:25     ` Lorenzo Bianconi
  0 siblings, 0 replies; 19+ messages in thread
From: Lorenzo Bianconi @ 2025-07-07  7:25 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	linux-arm-kernel, linux-mediatek, netdev, devicetree

[-- Attachment #1: Type: text/plain, Size: 1738 bytes --]

On Jul 07, Krzysztof Kozlowski wrote:
> On Sat, Jul 05, 2025 at 11:09:45PM +0200, Lorenzo Bianconi wrote:
> > Document memory regions used by Airoha EN7581 NPU for wlan traffic
> > offloading.
> > 
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> > ---
> >  .../devicetree/bindings/net/airoha,en7581-npu.yaml   | 20 ++++++++++++++++----
> >  1 file changed, 16 insertions(+), 4 deletions(-)
> > 
> > diff --git a/Documentation/devicetree/bindings/net/airoha,en7581-npu.yaml b/Documentation/devicetree/bindings/net/airoha,en7581-npu.yaml
> > index 76dd97c3fb4004674dc30a54c039c1cc19afedb3..db9269d1801bafa9be3b6c199a9e30cd23f4aea9 100644
> > --- a/Documentation/devicetree/bindings/net/airoha,en7581-npu.yaml
> > +++ b/Documentation/devicetree/bindings/net/airoha,en7581-npu.yaml
> > @@ -41,15 +41,25 @@ properties:
> >        - description: wlan irq line5
> >  
> >    memory-region:
> > -    maxItems: 1
> > -    description:
> > -      Memory used to store NPU firmware binary.
> > +    items:
> > +      - description: NPU firmware binary region
> > +      - description: NPU wlan offload RX buffers region
> > +      - description: NPU wlan offload TX buffers region
> > +      - description: NPU wlan offload TX packet identifiers region
> > +
> > +  memory-region-names:
> > +    items:
> > +      - const: binary
> 
> Rather: firmware

ack, I will fix it.

> 
> > +      - const: pkt
> > +      - const: tx-pkt
> > +      - const: tx-bufid
> >  
> >  required:
> >    - compatible
> >    - reg
> >    - interrupts
> >    - memory-region
> > +  - memory-region-names
> 
> That's ABI break.
> 

ack, I will fix it.

Regards,
Lorenzo

> Best regards,
> Krzysztof
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH net-next v2 2/7] net: airoha: npu: Add NPU wlan memory initialization commands
  2025-07-07  7:24     ` Lorenzo Bianconi
@ 2025-07-07 15:04       ` Krzysztof Kozlowski
  2025-07-07 15:06         ` Krzysztof Kozlowski
  2025-07-07 15:24         ` Lorenzo Bianconi
  0 siblings, 2 replies; 19+ messages in thread
From: Krzysztof Kozlowski @ 2025-07-07 15:04 UTC (permalink / raw)
  To: Lorenzo Bianconi
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	linux-arm-kernel, linux-mediatek, netdev, devicetree,
	Simon Horman, Felix Fietkau

On 07/07/2025 09:24, Lorenzo Bianconi wrote:
>> On Sat, Jul 05, 2025 at 11:09:46PM +0200, Lorenzo Bianconi wrote:
>>> +
>>>  struct airoha_npu *airoha_npu_get(struct device *dev, dma_addr_t *stats_addr)
>>>  {
>>>  	struct platform_device *pdev;
>>> @@ -493,6 +573,7 @@ static int airoha_npu_probe(struct platform_device *pdev)
>>>  	npu->ops.ppe_deinit = airoha_npu_ppe_deinit;
>>>  	npu->ops.ppe_flush_sram_entries = airoha_npu_ppe_flush_sram_entries;
>>>  	npu->ops.ppe_foe_commit_entry = airoha_npu_foe_commit_entry;
>>> +	npu->ops.wlan_init_reserved_memory = airoha_npu_wlan_init_memory;
>>
>> I cannot find in your code single place calling this (later you add a
>> wrapper... which is not called either).
>>
>> All this looks like dead code...
> 
> As pointed out in the commit log, these callbacks will be used by MT76 driver
> to initialize the NPU reserved memory and registers during driver probe in
> order to initialize the WiFi offloading. Since MT76 patches are going via
> the wireless tree, I needed to add these callbacks first.

Cover letter does not link to your NPU patchset. You cannot add dead
code to the kernel and now it is pure dead code. Post your user - in
this or separate patchset.

Your explanation of dependency is also confusing. If these are added to
wireless tree (considering last experience how they rebase and cannot
easily handle cross tree merges), how does it solve your problem? You
will have it in one tree but not in the other, so still nothing...
That's anyway separate problem, because main issue is you add code which
we cannot even verify how it is being used.

So far I see ABI break, but without user cannot judge. And that's the
hard reason this cannot be accepted.

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH net-next v2 2/7] net: airoha: npu: Add NPU wlan memory initialization commands
  2025-07-07 15:04       ` Krzysztof Kozlowski
@ 2025-07-07 15:06         ` Krzysztof Kozlowski
  2025-07-07 15:24         ` Lorenzo Bianconi
  1 sibling, 0 replies; 19+ messages in thread
From: Krzysztof Kozlowski @ 2025-07-07 15:06 UTC (permalink / raw)
  To: Lorenzo Bianconi
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	linux-arm-kernel, linux-mediatek, netdev, devicetree,
	Simon Horman, Felix Fietkau

On 07/07/2025 17:04, Krzysztof Kozlowski wrote:
> On 07/07/2025 09:24, Lorenzo Bianconi wrote:
>>> On Sat, Jul 05, 2025 at 11:09:46PM +0200, Lorenzo Bianconi wrote:
>>>> +
>>>>  struct airoha_npu *airoha_npu_get(struct device *dev, dma_addr_t *stats_addr)
>>>>  {
>>>>  	struct platform_device *pdev;
>>>> @@ -493,6 +573,7 @@ static int airoha_npu_probe(struct platform_device *pdev)
>>>>  	npu->ops.ppe_deinit = airoha_npu_ppe_deinit;
>>>>  	npu->ops.ppe_flush_sram_entries = airoha_npu_ppe_flush_sram_entries;
>>>>  	npu->ops.ppe_foe_commit_entry = airoha_npu_foe_commit_entry;
>>>> +	npu->ops.wlan_init_reserved_memory = airoha_npu_wlan_init_memory;
>>>
>>> I cannot find in your code single place calling this (later you add a
>>> wrapper... which is not called either).
>>>
>>> All this looks like dead code...
>>
>> As pointed out in the commit log, these callbacks will be used by MT76 driver
>> to initialize the NPU reserved memory and registers during driver probe in
>> order to initialize the WiFi offloading. Since MT76 patches are going via
>> the wireless tree, I needed to add these callbacks first.
> 
> Cover letter does not link to your NPU patchset. You cannot add dead
> code to the kernel and now it is pure dead code. Post your user - in
> this or separate patchset.
> 
> Your explanation of dependency is also confusing. If these are added to
> wireless tree (considering last experience how they rebase and cannot

... I think I mixed, that was Bluetooth tree which had rebases and
messed cross tree, not wifi. Apologies for confusion.

> easily handle cross tree merges), how does it solve your problem? You
> will have it in one tree but not in the other, so still nothing...
> That's anyway separate problem, because main issue is you add code which
> we cannot even verify how it is being used.
> 
> So far I see ABI break, but without user cannot judge. And that's the
> hard reason this cannot be accepted.

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH net-next v2 2/7] net: airoha: npu: Add NPU wlan memory initialization commands
  2025-07-07 15:04       ` Krzysztof Kozlowski
  2025-07-07 15:06         ` Krzysztof Kozlowski
@ 2025-07-07 15:24         ` Lorenzo Bianconi
  2025-07-08  6:26           ` Krzysztof Kozlowski
  1 sibling, 1 reply; 19+ messages in thread
From: Lorenzo Bianconi @ 2025-07-07 15:24 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	linux-arm-kernel, linux-mediatek, netdev, devicetree,
	Simon Horman, Felix Fietkau

[-- Attachment #1: Type: text/plain, Size: 2507 bytes --]

> On 07/07/2025 09:24, Lorenzo Bianconi wrote:
> >> On Sat, Jul 05, 2025 at 11:09:46PM +0200, Lorenzo Bianconi wrote:
> >>> +
> >>>  struct airoha_npu *airoha_npu_get(struct device *dev, dma_addr_t *stats_addr)
> >>>  {
> >>>  	struct platform_device *pdev;
> >>> @@ -493,6 +573,7 @@ static int airoha_npu_probe(struct platform_device *pdev)
> >>>  	npu->ops.ppe_deinit = airoha_npu_ppe_deinit;
> >>>  	npu->ops.ppe_flush_sram_entries = airoha_npu_ppe_flush_sram_entries;
> >>>  	npu->ops.ppe_foe_commit_entry = airoha_npu_foe_commit_entry;
> >>> +	npu->ops.wlan_init_reserved_memory = airoha_npu_wlan_init_memory;
> >>
> >> I cannot find in your code single place calling this (later you add a
> >> wrapper... which is not called either).
> >>
> >> All this looks like dead code...
> > 
> > As pointed out in the commit log, these callbacks will be used by MT76 driver
> > to initialize the NPU reserved memory and registers during driver probe in
> > order to initialize the WiFi offloading. Since MT76 patches are going via
> > the wireless tree, I needed to add these callbacks first.
> 
> Cover letter does not link to your NPU patchset. You cannot add dead
> code to the kernel and now it is pure dead code. Post your user - in
> this or separate patchset.

I guess you mean the related MT76 patches are not linked in the cover-letter,
right? I have not posted them yet.

> 
> Your explanation of dependency is also confusing. If these are added to
> wireless tree (considering last experience how they rebase and cannot
> easily handle cross tree merges), how does it solve your problem? You
> will have it in one tree but not in the other, so still nothing...
> That's anyway separate problem, because main issue is you add code which
> we cannot even verify how it is being used.

My main point here is wireless tree can't acutally merge the MT76 patches
since, without the net-next ones (this series), it will not compile (so I
posted net-next patches as preliminary ones for MT76 changes).
Moreover, this is the same approach we used when we added WED support to
mtk_eth_soc driver and the related MT76 support.
However, I am fine to post the MT76 changes as RFC and just refer to it in
this series cover-letter. Agree? 

> 
> So far I see ABI break, but without user cannot judge. And that's the
> hard reason this cannot be accepted.

if you mean the dts changes, I will fix them in v3.

Regards,
Lorenzo

> 
> Best regards,
> Krzysztof

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH net-next v2 2/7] net: airoha: npu: Add NPU wlan memory initialization commands
  2025-07-07 15:24         ` Lorenzo Bianconi
@ 2025-07-08  6:26           ` Krzysztof Kozlowski
  2025-07-08  7:33             ` Lorenzo Bianconi
  0 siblings, 1 reply; 19+ messages in thread
From: Krzysztof Kozlowski @ 2025-07-08  6:26 UTC (permalink / raw)
  To: Lorenzo Bianconi
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	linux-arm-kernel, linux-mediatek, netdev, devicetree,
	Simon Horman, Felix Fietkau

On 07/07/2025 17:24, Lorenzo Bianconi wrote:
>> On 07/07/2025 09:24, Lorenzo Bianconi wrote:
>>>> On Sat, Jul 05, 2025 at 11:09:46PM +0200, Lorenzo Bianconi wrote:
>>>>> +
>>>>>  struct airoha_npu *airoha_npu_get(struct device *dev, dma_addr_t *stats_addr)
>>>>>  {
>>>>>  	struct platform_device *pdev;
>>>>> @@ -493,6 +573,7 @@ static int airoha_npu_probe(struct platform_device *pdev)
>>>>>  	npu->ops.ppe_deinit = airoha_npu_ppe_deinit;
>>>>>  	npu->ops.ppe_flush_sram_entries = airoha_npu_ppe_flush_sram_entries;
>>>>>  	npu->ops.ppe_foe_commit_entry = airoha_npu_foe_commit_entry;
>>>>> +	npu->ops.wlan_init_reserved_memory = airoha_npu_wlan_init_memory;
>>>>
>>>> I cannot find in your code single place calling this (later you add a
>>>> wrapper... which is not called either).
>>>>
>>>> All this looks like dead code...
>>>
>>> As pointed out in the commit log, these callbacks will be used by MT76 driver
>>> to initialize the NPU reserved memory and registers during driver probe in
>>> order to initialize the WiFi offloading. Since MT76 patches are going via
>>> the wireless tree, I needed to add these callbacks first.
>>
>> Cover letter does not link to your NPU patchset. You cannot add dead
>> code to the kernel and now it is pure dead code. Post your user - in
>> this or separate patchset.
> 
> I guess you mean the related MT76 patches are not linked in the cover-letter,
> right? I have not posted them yet.
> 
>>
>> Your explanation of dependency is also confusing. If these are added to
>> wireless tree (considering last experience how they rebase and cannot
>> easily handle cross tree merges), how does it solve your problem? You
>> will have it in one tree but not in the other, so still nothing...
>> That's anyway separate problem, because main issue is you add code which
>> we cannot even verify how it is being used.
> 
> My main point here is wireless tree can't acutally merge the MT76 patches
> since, without the net-next ones (this series), it will not compile (so I

This does not explain hiding the other part. Again - there is nothing
weird in patchset dependencies. Weird is saying there is dependency, so
I will not post code.

> posted net-next patches as preliminary ones for MT76 changes).
> Moreover, this is the same approach we used when we added WED support to
> mtk_eth_soc driver and the related MT76 support.
> However, I am fine to post the MT76 changes as RFC and just refer to it in
> this series cover-letter. Agree? 
> 
>>
>> So far I see ABI break, but without user cannot judge. And that's the
>> hard reason this cannot be accepted.
> 
> if you mean the dts changes, I will fix them in v3.
> 
No, I mean driver.

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH net-next v2 2/7] net: airoha: npu: Add NPU wlan memory initialization commands
  2025-07-08  6:26           ` Krzysztof Kozlowski
@ 2025-07-08  7:33             ` Lorenzo Bianconi
  2025-07-14  7:39               ` Krzysztof Kozlowski
  0 siblings, 1 reply; 19+ messages in thread
From: Lorenzo Bianconi @ 2025-07-08  7:33 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	linux-arm-kernel, linux-mediatek, netdev, devicetree,
	Simon Horman, Felix Fietkau

[-- Attachment #1: Type: text/plain, Size: 3186 bytes --]

> On 07/07/2025 17:24, Lorenzo Bianconi wrote:
> >> On 07/07/2025 09:24, Lorenzo Bianconi wrote:
> >>>> On Sat, Jul 05, 2025 at 11:09:46PM +0200, Lorenzo Bianconi wrote:
> >>>>> +
> >>>>>  struct airoha_npu *airoha_npu_get(struct device *dev, dma_addr_t *stats_addr)
> >>>>>  {
> >>>>>  	struct platform_device *pdev;
> >>>>> @@ -493,6 +573,7 @@ static int airoha_npu_probe(struct platform_device *pdev)
> >>>>>  	npu->ops.ppe_deinit = airoha_npu_ppe_deinit;
> >>>>>  	npu->ops.ppe_flush_sram_entries = airoha_npu_ppe_flush_sram_entries;
> >>>>>  	npu->ops.ppe_foe_commit_entry = airoha_npu_foe_commit_entry;
> >>>>> +	npu->ops.wlan_init_reserved_memory = airoha_npu_wlan_init_memory;
> >>>>
> >>>> I cannot find in your code single place calling this (later you add a
> >>>> wrapper... which is not called either).
> >>>>
> >>>> All this looks like dead code...
> >>>
> >>> As pointed out in the commit log, these callbacks will be used by MT76 driver
> >>> to initialize the NPU reserved memory and registers during driver probe in
> >>> order to initialize the WiFi offloading. Since MT76 patches are going via
> >>> the wireless tree, I needed to add these callbacks first.
> >>
> >> Cover letter does not link to your NPU patchset. You cannot add dead
> >> code to the kernel and now it is pure dead code. Post your user - in
> >> this or separate patchset.
> > 
> > I guess you mean the related MT76 patches are not linked in the cover-letter,
> > right? I have not posted them yet.
> > 
> >>
> >> Your explanation of dependency is also confusing. If these are added to
> >> wireless tree (considering last experience how they rebase and cannot
> >> easily handle cross tree merges), how does it solve your problem? You
> >> will have it in one tree but not in the other, so still nothing...
> >> That's anyway separate problem, because main issue is you add code which
> >> we cannot even verify how it is being used.
> > 
> > My main point here is wireless tree can't acutally merge the MT76 patches
> > since, without the net-next ones (this series), it will not compile (so I
> 
> This does not explain hiding the other part. Again - there is nothing
> weird in patchset dependencies. Weird is saying there is dependency, so
> I will not post code.

I have a working patchset for MT76 support. I have not posted it yet just
because I need to clean it up.

> 
> > posted net-next patches as preliminary ones for MT76 changes).
> > Moreover, this is the same approach we used when we added WED support to
> > mtk_eth_soc driver and the related MT76 support.
> > However, I am fine to post the MT76 changes as RFC and just refer to it in
> > this series cover-letter. Agree? 
> > 
> >>
> >> So far I see ABI break, but without user cannot judge. And that's the
> >> hard reason this cannot be accepted.
> > 
> > if you mean the dts changes, I will fix them in v3.
> > 
> No, I mean driver.

Sorry, can you please explain what is the ABI break in the driver codebase?
airoha_npu_wlan_init_memory() is executed by MT76 driver and not during NPU
probe phase.

Regards,
Lorenzo

> 
> Best regards,
> Krzysztof

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH net-next v2 2/7] net: airoha: npu: Add NPU wlan memory initialization commands
  2025-07-08  7:33             ` Lorenzo Bianconi
@ 2025-07-14  7:39               ` Krzysztof Kozlowski
  2025-07-14 10:09                 ` Lorenzo Bianconi
  0 siblings, 1 reply; 19+ messages in thread
From: Krzysztof Kozlowski @ 2025-07-14  7:39 UTC (permalink / raw)
  To: Lorenzo Bianconi
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	linux-arm-kernel, linux-mediatek, netdev, devicetree,
	Simon Horman, Felix Fietkau

On 08/07/2025 09:33, Lorenzo Bianconi wrote:
> 
>>
>>> posted net-next patches as preliminary ones for MT76 changes).
>>> Moreover, this is the same approach we used when we added WED support to
>>> mtk_eth_soc driver and the related MT76 support.
>>> However, I am fine to post the MT76 changes as RFC and just refer to it in
>>> this series cover-letter. Agree? 
>>>
>>>>
>>>> So far I see ABI break, but without user cannot judge. And that's the
>>>> hard reason this cannot be accepted.
>>>
>>> if you mean the dts changes, I will fix them in v3.
>>>
>> No, I mean driver.
> 
> Sorry, can you please explain what is the ABI break in the driver codebase?
> airoha_npu_wlan_init_memory() is executed by MT76 driver and not during NPU
> probe phase.
> 

Read the first problem I pointed out - no user. Your new ABI returns
error and you changed binding in incompatible way.

Binding change is ABI break and its impact is impossible to judge due to
missing code. I am speaking about this since beginning, but if you keep
insisting that the driver does not matter then this is a NAK because you
change ABI in the binding.


Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH net-next v2 2/7] net: airoha: npu: Add NPU wlan memory initialization commands
  2025-07-14  7:39               ` Krzysztof Kozlowski
@ 2025-07-14 10:09                 ` Lorenzo Bianconi
  0 siblings, 0 replies; 19+ messages in thread
From: Lorenzo Bianconi @ 2025-07-14 10:09 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	linux-arm-kernel, linux-mediatek, netdev, devicetree,
	Simon Horman, Felix Fietkau

[-- Attachment #1: Type: text/plain, Size: 1489 bytes --]

> On 08/07/2025 09:33, Lorenzo Bianconi wrote:
> > 
> >>
> >>> posted net-next patches as preliminary ones for MT76 changes).
> >>> Moreover, this is the same approach we used when we added WED support to
> >>> mtk_eth_soc driver and the related MT76 support.
> >>> However, I am fine to post the MT76 changes as RFC and just refer to it in
> >>> this series cover-letter. Agree? 
> >>>
> >>>>
> >>>> So far I see ABI break, but without user cannot judge. And that's the
> >>>> hard reason this cannot be accepted.
> >>>
> >>> if you mean the dts changes, I will fix them in v3.
> >>>
> >> No, I mean driver.
> > 
> > Sorry, can you please explain what is the ABI break in the driver codebase?
> > airoha_npu_wlan_init_memory() is executed by MT76 driver and not during NPU
> > probe phase.
> > 
> 
> Read the first problem I pointed out - no user. Your new ABI returns
> error and you changed binding in incompatible way.
> 
> Binding change is ABI break and its impact is impossible to judge due to
> missing code. I am speaking about this since beginning, but if you keep
> insisting that the driver does not matter then this is a NAK because you
> change ABI in the binding.

Please do not get me wrong, I was just trying to understand where the ABI
breakage is. I will post my MT76 changes as RFC and I will link that series
in the v3 cover letter so you can look at the new API user code.

Regards,
Lorenzo

> 
> 
> Best regards,
> Krzysztof

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2025-07-14 10:09 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-05 21:09 [PATCH net-next v2 0/7] net: airoha: Introduce NPU callbacks for wlan offloading Lorenzo Bianconi
2025-07-05 21:09 ` [PATCH net-next v2 1/7] dt-bindings: net: airoha: npu: Add memory regions used for wlan offload Lorenzo Bianconi
2025-07-07  7:05   ` Krzysztof Kozlowski
2025-07-07  7:25     ` Lorenzo Bianconi
2025-07-05 21:09 ` [PATCH net-next v2 2/7] net: airoha: npu: Add NPU wlan memory initialization commands Lorenzo Bianconi
2025-07-07  7:09   ` Krzysztof Kozlowski
2025-07-07  7:24     ` Lorenzo Bianconi
2025-07-07 15:04       ` Krzysztof Kozlowski
2025-07-07 15:06         ` Krzysztof Kozlowski
2025-07-07 15:24         ` Lorenzo Bianconi
2025-07-08  6:26           ` Krzysztof Kozlowski
2025-07-08  7:33             ` Lorenzo Bianconi
2025-07-14  7:39               ` Krzysztof Kozlowski
2025-07-14 10:09                 ` Lorenzo Bianconi
2025-07-05 21:09 ` [PATCH net-next v2 3/7] net: airoha: npu: Add wlan_{send,get}_msg NPU callbacks Lorenzo Bianconi
2025-07-05 21:09 ` [PATCH net-next v2 4/7] net: airoha: npu: Add wlan irq management callbacks Lorenzo Bianconi
2025-07-05 21:09 ` [PATCH net-next v2 5/7] net: airoha: npu: Read NPU wlan interrupt lines from the DTS Lorenzo Bianconi
2025-07-05 21:09 ` [PATCH net-next v2 6/7] net: airoha: npu: Enable core 3 for WiFi offloading Lorenzo Bianconi
2025-07-05 21:09 ` [PATCH net-next v2 7/7] net: airoha: Add airoha_offload.h header Lorenzo Bianconi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).