diff --git a/package/kernel/mt76/Makefile b/package/kernel/mt76/Makefile index d6b27b328b5b8b..67a83fd72cb6c8 100644 --- a/package/kernel/mt76/Makefile +++ b/package/kernel/mt76/Makefile @@ -409,8 +409,10 @@ ifdef CONFIG_PACKAGE_MAC80211_MESH endif ifdef CONFIG_NET_AIROHA_NPU - NOSTDINC_FLAGS += -DCONFIG_NET_AIROHA_NPU - PKG_MAKE_FLAGS += CONFIG_NET_AIROHA_NPU=y + NOSTDINC_FLAGS += -DCONFIG_MT76_NPU + PKG_MAKE_FLAGS += CONFIG_MT76_NPU=y + NOSTDINC_FLAGS += -DCONFIG_MT7996_NPU + PKG_MAKE_FLAGS += CONFIG_MT7996_NPU=y endif ifdef CONFIG_PACKAGE_CFG80211_TESTMODE diff --git a/package/kernel/mt76/patches/0001-wifi-mt76-Move-Q_READ-Q_WRITE-definitions-in-dma.h.patch b/package/kernel/mt76/patches/0001-wifi-mt76-Move-Q_READ-Q_WRITE-definitions-in-dma.h.patch index 9a841e0bf5d6f6..692f8f529d283e 100644 --- a/package/kernel/mt76/patches/0001-wifi-mt76-Move-Q_READ-Q_WRITE-definitions-in-dma.h.patch +++ b/package/kernel/mt76/patches/0001-wifi-mt76-Move-Q_READ-Q_WRITE-definitions-in-dma.h.patch @@ -1,12 +1,12 @@ -From c74b9132cd2c958a00b4a2d42ecd47b3104e3065 Mon Sep 17 00:00:00 2001 -Message-ID: +From e134420e2a93d0febe112f1459b27b26a87017c4 Mon Sep 17 00:00:00 2001 +Message-ID: From: Lorenzo Bianconi Date: Mon, 14 Jul 2025 13:51:25 +0200 Subject: [PATCH 1/5] wifi: mt76: Move Q_READ/Q_WRITE definitions in dma.h This is a preliminary patch to enable traffic forward offloading between -the MT76 NIC and Airoha ethernet one via the Airoha NPU module available -on the Airoha EN7581 SoC. +the MT76 NIC and the Airoha ethernet one via the Airoha NPU module +available on the Airoha EN7581 SoC. Signed-off-by: Lorenzo Bianconi --- @@ -57,7 +57,7 @@ index 1fa7de1d..f21481d4 100644 mt76_alloc_txwi(struct mt76_dev *dev) { diff --git a/dma.h b/dma.h -index 17a80e17..d4e2e9c2 100644 +index 17a80e17..56bd53bf 100644 --- a/dma.h +++ b/dma.h @@ -46,6 +46,37 @@ @@ -72,7 +72,7 @@ index 17a80e17..d4e2e9c2 100644 + if ((_q)->flags & MT_QFLAG_WED) \ + _val = mtk_wed_device_reg_read((_q)->wed, \ + ((_q)->wed_regs + \ -+ _offset)); \ ++ _offset)); \ + else \ + _val = readl(&(_q)->regs->_field); \ + _val; \ diff --git a/package/kernel/mt76/patches/0002-wifi-mt76-Add-mt76_dev-pointer-in-mt76_queue-struct.patch b/package/kernel/mt76/patches/0002-wifi-mt76-Add-mt76_dev-pointer-in-mt76_queue-struct.patch index df60c9c4083470..9bd0eefe84082c 100644 --- a/package/kernel/mt76/patches/0002-wifi-mt76-Add-mt76_dev-pointer-in-mt76_queue-struct.patch +++ b/package/kernel/mt76/patches/0002-wifi-mt76-Add-mt76_dev-pointer-in-mt76_queue-struct.patch @@ -1,7 +1,7 @@ -From f20c286fe21ade165f9dea177788fefb3c30476f Mon Sep 17 00:00:00 2001 -Message-ID: -In-Reply-To: -References: +From 7e81db91e0f70abfde3a5f7a21cc6f9e9a5bd72f Mon Sep 17 00:00:00 2001 +Message-ID: <7e81db91e0f70abfde3a5f7a21cc6f9e9a5bd72f.1757512252.git.lorenzo@kernel.org> +In-Reply-To: +References: From: Lorenzo Bianconi Date: Mon, 14 Jul 2025 13:57:57 +0200 Subject: [PATCH 2/5] wifi: mt76: Add mt76_dev pointer in mt76_queue struct. diff --git a/package/kernel/mt76/patches/0003-wifi-mt76-Add-the-capability-to-set-TX-token-start-I.patch b/package/kernel/mt76/patches/0003-wifi-mt76-Add-the-capability-to-set-TX-token-start-I.patch index 3e8cb1d835f27c..03076a8765cb3f 100644 --- a/package/kernel/mt76/patches/0003-wifi-mt76-Add-the-capability-to-set-TX-token-start-I.patch +++ b/package/kernel/mt76/patches/0003-wifi-mt76-Add-the-capability-to-set-TX-token-start-I.patch @@ -1,7 +1,7 @@ -From 7aec87df650a9c19bb7ebfd6a00226eb6f3b2b2a Mon Sep 17 00:00:00 2001 -Message-ID: <7aec87df650a9c19bb7ebfd6a00226eb6f3b2b2a.1757494139.git.lorenzo@kernel.org> -In-Reply-To: -References: +From e3aede8127d0ecc160a2f421af00f762af78b083 Mon Sep 17 00:00:00 2001 +Message-ID: +In-Reply-To: +References: From: Lorenzo Bianconi Date: Fri, 25 Jul 2025 12:38:26 +0200 Subject: [PATCH 3/5] wifi: mt76: Add the capability to set TX token start ID diff --git a/package/kernel/mt76/patches/0004-wifi-mt76-Introduce-the-NPU-generic-layer.patch b/package/kernel/mt76/patches/0004-wifi-mt76-Introduce-the-NPU-generic-layer.patch index 834666b5dbbd11..7d54ee54155490 100644 --- a/package/kernel/mt76/patches/0004-wifi-mt76-Introduce-the-NPU-generic-layer.patch +++ b/package/kernel/mt76/patches/0004-wifi-mt76-Introduce-the-NPU-generic-layer.patch @@ -1,13 +1,13 @@ -From 253ac811053314189705fbd6cab86751e681ee99 Mon Sep 17 00:00:00 2001 -Message-ID: <253ac811053314189705fbd6cab86751e681ee99.1757494139.git.lorenzo@kernel.org> -In-Reply-To: -References: +From 6873311d009cc4c1fe8f26f979beaa492c2ffb1e Mon Sep 17 00:00:00 2001 +Message-ID: <6873311d009cc4c1fe8f26f979beaa492c2ffb1e.1757512252.git.lorenzo@kernel.org> +In-Reply-To: +References: From: Lorenzo Bianconi Date: Mon, 14 Jul 2025 15:16:13 +0200 Subject: [PATCH 4/5] wifi: mt76: Introduce the NPU generic layer Add the NPU generic layer in mt76 module. NPU will be used to enable -traffic forward offloading between the MT76 NIC and Airoha ethernet one +traffic forward offloading between the MT76 NIC and the Airoha ethernet one available on the Airoha EN7581 SoC using Netfilter Flowtable APIs. Signed-off-by: Lorenzo Bianconi @@ -22,14 +22,14 @@ Signed-off-by: Lorenzo Bianconi create mode 100644 npu.c diff --git a/Makefile b/Makefile -index a4663ccd..1c80cc83 100644 +index a4663ccd..1853f18b 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,7 @@ mt76-y := \ mmio.o util.o trace.o dma.o mac80211.o debugfs.o eeprom.o \ tx.o agg-rx.o mcu.o wed.o scan.o channel.o -+mt76-$(CONFIG_NET_AIROHA_NPU) += npu.o ++mt76-$(CONFIG_MT76_NPU) += npu.o mt76-$(CONFIG_PCI) += pci.o mt76-$(CONFIG_NL80211_TESTMODE) += testmode.o @@ -152,14 +152,14 @@ index a285fd0a..a7280c4f 100644 static void diff --git a/dma.h b/dma.h -index d4e2e9c2..5147749d 100644 +index 56bd53bf..d27ec18e 100644 --- a/dma.h +++ b/dma.h @@ -70,6 +70,42 @@ writel(_val, &(_q)->regs->_field); \ } while (0) -+#elif (IS_BUILTIN(CONFIG_NET_AIROHA_NPU) || IS_MODULE(CONFIG_NET_AIROHA_NPU)) ++#elif IS_ENABLED(CONFIG_MT76_NPU) + +#define Q_READ(_q, _field) ({ \ + u32 _offset = offsetof(struct mt76_queue_regs, _field); \ @@ -230,7 +230,7 @@ index a7e21693..42595b33 100644 else mt76_rx_aggr_reorder(skb, &frames); diff --git a/mt76.h b/mt76.h -index 2534587c..fba768b2 100644 +index 2534587c..f2f3df0b 100644 --- a/mt76.h +++ b/mt76.h @@ -13,6 +13,7 @@ @@ -287,7 +287,7 @@ index 2534587c..fba768b2 100644 int mt76_testmode_set_state(struct mt76_phy *phy, enum mt76_testmode_state state); int mt76_testmode_alloc_skb(struct mt76_phy *phy, u32 len); -+#if (IS_BUILTIN(CONFIG_NET_AIROHA_NPU) || IS_MODULE(CONFIG_NET_AIROHA_NPU)) ++#ifdef CONFIG_MT76_NPU +void mt76_npu_check_ppe(struct mt76_dev *dev, struct sk_buff *skb, + u32 info); +int mt76_npu_dma_add_buf(struct mt76_phy *phy, struct mt76_queue *q, @@ -362,7 +362,7 @@ index 2534587c..fba768b2 100644 +{ + return -EOPNOTSUPP; +} -+#endif /* CONFIG_NET_AIROHA_NPU */ ++#endif /* CONFIG_MT76_NPU */ + +static inline bool mt76_npu_device_active(struct mt76_dev *dev) +{ @@ -419,7 +419,7 @@ index 2534587c..fba768b2 100644 int mt76_token_consume(struct mt76_dev *dev, struct mt76_txwi_cache **ptxwi); diff --git a/npu.c b/npu.c new file mode 100644 -index 00000000..1efa7452 +index 00000000..7ba55fd8 --- /dev/null +++ b/npu.c @@ -0,0 +1,494 @@ @@ -704,7 +704,7 @@ index 00000000..1efa7452 + if (err) + goto out; + -+ name = devm_kasprintf(dev->dev, GFP_KERNEL, "mt76-npu" ".%d", index); ++ name = devm_kasprintf(dev->dev, GFP_KERNEL, "mt76-npu.%d", index); + if (!name) { + err = -ENOMEM; + goto out; diff --git a/package/kernel/mt76/patches/0005-wifi-mt76-mt7996-Add-NPU-offload-support-to-MT7996-d.patch b/package/kernel/mt76/patches/0005-wifi-mt76-mt7996-Add-NPU-offload-support-to-MT7996-d.patch index fff7ad87b7ecd7..098d5353d3c4b4 100644 --- a/package/kernel/mt76/patches/0005-wifi-mt76-mt7996-Add-NPU-offload-support-to-MT7996-d.patch +++ b/package/kernel/mt76/patches/0005-wifi-mt76-mt7996-Add-NPU-offload-support-to-MT7996-d.patch @@ -1,14 +1,14 @@ -From e2ace36c3548587f23d7782b0bd3ebe4c41f0d0b Mon Sep 17 00:00:00 2001 -Message-ID: -In-Reply-To: -References: +From 3c20cbfdbead23848075f882d1b117f2a9b200b5 Mon Sep 17 00:00:00 2001 +Message-ID: <3c20cbfdbead23848075f882d1b117f2a9b200b5.1757512252.git.lorenzo@kernel.org> +In-Reply-To: +References: From: Lorenzo Bianconi Date: Mon, 14 Jul 2025 16:25:38 +0200 Subject: [PATCH 5/5] wifi: mt76: mt7996: Add NPU offload support to MT7996 driver Introduce Airoha NPU support to MT7996 driver. NPU is used to enable -traffic forward offloading between the MT76 NIC and Airoha ethernet one +traffic forward offloading between the MT76 NIC and the Airoha ethernet one available on the Airoha EN7581 SoC using Netfilter Flowtable APIs. Signed-off-by: Lorenzo Bianconi @@ -26,14 +26,14 @@ Signed-off-by: Lorenzo Bianconi create mode 100644 mt7996/npu.c diff --git a/mt7996/Makefile b/mt7996/Makefile -index 07c8b555..c3783a23 100644 +index 07c8b555..21a5f33b 100644 --- a/mt7996/Makefile +++ b/mt7996/Makefile @@ -5,4 +5,5 @@ obj-$(CONFIG_MT7996E) += mt7996e.o mt7996e-y := pci.o init.o dma.o eeprom.o main.o mcu.o mac.o \ debugfs.o mmio.o -+mt7996e-$(CONFIG_NET_AIROHA_NPU) += npu.o ++mt7996e-$(CONFIG_MT7996_NPU) += npu.o mt7996e-$(CONFIG_DEV_COREDUMP) += coredump.o diff --git a/mt7996/dma.c b/mt7996/dma.c index 659015f9..1ec17e03 100644 @@ -179,7 +179,7 @@ index 374ffe1f..0001dfc2 100644 mt7996_for_each_phy(dev, phy) diff --git a/mt7996/main.c b/mt7996/main.c -index de92b706..062d3ccb 100644 +index de92b706..1aa00688 100644 --- a/mt7996/main.c +++ b/mt7996/main.c @@ -2141,7 +2141,6 @@ out: @@ -249,7 +249,7 @@ index de92b706..062d3ccb 100644 .net_fill_forward_path = mt7996_net_fill_forward_path, +#ifdef CONFIG_NET_MEDIATEK_SOC_WED .net_setup_tc = mt76_wed_net_setup_tc, -+#elif (IS_BUILTIN(CONFIG_NET_AIROHA_NPU) || IS_MODULE(CONFIG_NET_AIROHA_NPU)) ++#elifdef CONFIG_MT7996_NPU + .net_setup_tc = mt76_npu_net_setup_tc, #endif .change_vif_links = mt7996_change_vif_links, @@ -280,14 +280,14 @@ index d14b626e..bd837f91 100644 /* TODO: support 2/4/6/8 MSI-X vectors */ diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h -index be26e04b..41aa8774 100644 +index be26e04b..942e0522 100644 --- a/mt7996/mt7996.h +++ b/mt7996/mt7996.h @@ -867,4 +867,25 @@ int mt7996_mtk_init_debugfs(struct mt7996_phy *phy, struct dentry *dir); int mt7996_dma_rro_init(struct mt7996_dev *dev); -+#if (IS_BUILTIN(CONFIG_NET_AIROHA_NPU) || IS_MODULE(CONFIG_NET_AIROHA_NPU)) ++#ifdef CONFIG_MT7996_NPU +int mt7996_npu_hw_init(struct mt7996_dev *dev); +int mt7996_npu_hw_stop(struct mt7996_dev *dev); +int mt7996_npu_rx_queues_init(struct mt7996_dev *dev); @@ -306,7 +306,7 @@ index be26e04b..41aa8774 100644 +{ + return 0; +} -+#endif /* CONFIG_NET_AIROHA_NPU */ ++#endif /* CONFIG_MT7996_NPU */ + #endif diff --git a/mt7996/npu.c b/mt7996/npu.c