Ethernet->WLAN hardware flow offloading support on MT7622
Subsystems (7)
Felix Fietkau
maintainercover Ethernet->WLAN hardware flow offloading support on MT7622
This patch series adds hardware flow offloading for routing/NAT packets from ethernet to WLAN on MT7622 SoC, in combination with MT7915 WLAN devices This only offloads one direction, WLAN->Ethernet offload is not supported by MT7622 (but will be in newer SoC designs).
In order to make this work, the SoC contains a subsystem named Wireless Ethernet Dispatch. It intercepts access to the WLAN DMA register space and controls the DMA queues in order to be able to inject packets coming in from the packet processing engine (PPE). It also intercepts IRQs from PCIe.
Felix Fietkau (7):
mac80211: add support for .ndo_fill_forward_path
net: ethernet: mtk_eth_soc: add support for Wireless Ethernet Dispatch
(WED)
net: ethernet: mtk_eth_soc: implement flow offloading to WED devices
mt76: dma: add wrapper macro for accessing queue registers
mt76: make number of tokens configurable dynamically
mt76: mt7915: remove irq parameter from mt7915_mmio_init
mt76: mt7915: add Wireless Ethernet Dispatch support
arch/arm64/boot/dts/mediatek/mt7622.dtsi | 22 + drivers/net/ethernet/mediatek/Kconfig | 4 + drivers/net/ethernet/mediatek/Makefile | 5 + drivers/net/ethernet/mediatek/mtk_eth_soc.c | 23 + drivers/net/ethernet/mediatek/mtk_eth_soc.h | 3 + drivers/net/ethernet/mediatek/mtk_ppe.c | 18 + drivers/net/ethernet/mediatek/mtk_ppe.h | 14 +- .../net/ethernet/mediatek/mtk_ppe_offload.c | 67 +- drivers/net/ethernet/mediatek/mtk_wed.c | 837 ++++++++++++++++++ drivers/net/ethernet/mediatek/mtk_wed.h | 123 +++ .../net/ethernet/mediatek/mtk_wed_debugfs.c | 175 ++++ drivers/net/ethernet/mediatek/mtk_wed_ops.c | 8 + drivers/net/ethernet/mediatek/mtk_wed_regs.h | 248 ++++++ drivers/net/wireless/mediatek/mt76/dma.c | 111 ++- drivers/net/wireless/mediatek/mt76/mac80211.c | 5 +- drivers/net/wireless/mediatek/mt76/mmio.c | 9 +- drivers/net/wireless/mediatek/mt76/mt76.h | 36 +- .../net/wireless/mediatek/mt76/mt7603/dma.c | 8 +- .../net/wireless/mediatek/mt76/mt7615/dma.c | 6 +- .../net/wireless/mediatek/mt76/mt76x02_mmio.c | 4 +- .../net/wireless/mediatek/mt76/mt7915/dma.c | 38 +- .../net/wireless/mediatek/mt76/mt7915/mac.c | 123 ++- .../net/wireless/mediatek/mt76/mt7915/mac.h | 2 + .../net/wireless/mediatek/mt76/mt7915/main.c | 32 + .../net/wireless/mediatek/mt76/mt7915/mcu.c | 4 + .../net/wireless/mediatek/mt76/mt7915/mmio.c | 2 +- .../wireless/mediatek/mt76/mt7915/mt7915.h | 3 +- .../net/wireless/mediatek/mt76/mt7915/pci.c | 98 +- .../net/wireless/mediatek/mt76/mt7915/regs.h | 19 +- .../net/wireless/mediatek/mt76/mt7921/dma.c | 2 +- drivers/net/wireless/mediatek/mt76/tx.c | 21 +- include/linux/netdevice.h | 7 + include/linux/soc/mediatek/mtk_wed.h | 127 +++ include/net/mac80211.h | 5 + net/core/dev.c | 4 + net/mac80211/driver-ops.h | 22 + net/mac80211/ieee80211_i.h | 2 +- net/mac80211/iface.c | 58 ++ net/mac80211/trace.h | 7 + 39 files changed, 2187 insertions(+), 115 deletions(-) create mode 100644 drivers/net/ethernet/mediatek/mtk_wed.c create mode 100644 drivers/net/ethernet/mediatek/mtk_wed.h create mode 100644 drivers/net/ethernet/mediatek/mtk_wed_debugfs.c create mode 100644 drivers/net/ethernet/mediatek/mtk_wed_ops.c create mode 100644 drivers/net/ethernet/mediatek/mtk_wed_regs.h create mode 100644 include/linux/soc/mediatek/mtk_wed.h
Signature · 1 line
2.30.1
Felix Fietkau
maintainerRFC 1/7 mac80211: add support for .ndo_fill_forward_path
This allows drivers to provide a destination device + info for flow offload Only supported in combination with 802.3 encap offload
--- include/net/mac80211.h | 5 ++++ net/mac80211/driver-ops.h | 22 +++++++++++++++ net/mac80211/ieee80211_i.h | 2 +- net/mac80211/iface.c | 58 ++++++++++++++++++++++++++++++++++++++ net/mac80211/trace.h | 7 +++++ 5 files changed, 93 insertions(+), 1 deletion(-)
include/net/mac80211.h +5 -0
@@ -4242,6 +4242,11 @@ struct ieee80211_ops {void (*sta_set_decap_offload)(struct ieee80211_hw *hw,struct ieee80211_vif *vif,struct ieee80211_sta *sta,bool enabled); +int (*net_fill_forward_path)(struct ieee80211_hw *hw, +struct ieee80211_vif *vif, +struct ieee80211_sta *sta, +struct net_device_path_ctx *ctx, +struct net_device_path *path); };/**
net/mac80211/driver-ops.h +22 -0
@@ -1447,4 +1447,26 @@ static inline void drv_sta_set_decap_offload(struct ieee80211_local *local, trace_drv_return_void(local); } +static inline int drv_net_fill_forward_path (struct ieee80211_local *local, +struct ieee80211_sub_if_data *sdata, +struct ieee80211_sta *sta, +struct net_device_path_ctx *ctx, +struct net_device_path *path) +{ +int ret = -EOPNOTSUPP ; + + sdata =get_bss_sdata (sdata); +if (!check_sdata_in_driver (sdata)) +return -EIO ; + +trace_drv_net_fill_forward_path (local, sdata, sta); +if (local->ops->net_fill_forward_path) + ret = local->ops->net_fill_forward_path (&local->hw, + &sdata->vif, sta, + ctx, path); +trace_drv_return_int (local, ret); + +return ret; +} +#endif /* __MAC80211_DRIVER_OPS */
net/mac80211/ieee80211_i.h +1 -1
@@ -1451,7 +1451,7 @@ struct ieee80211_local { };static inline struct ieee80211_sub_if_data * -IEEE80211_DEV_TO_SUB_IF (struct net_device *dev) +IEEE80211_DEV_TO_SUB_IF (const struct net_device *dev) {return netdev_priv (dev); }
net/mac80211/iface.c +58 -0
70 lines not on this page · raw message
net/mac80211/trace.h +7 -0
@@ -2825,6 +2825,13 @@ DEFINE_EVENT(sta_flag_evt, drv_sta_set_decap_offload,TP_ARGS (local, sdata, sta, enabled) ); +DEFINE_EVENT (sta_event, drv_net_fill_forward_path, + TP_PROTO(struct ieee80211_local *local, + struct ieee80211_sub_if_data *sdata, + struct ieee80211_sta *sta), +TP_ARGS (local, sdata, sta) +); +#endif /* !__MAC80211_DRIVER_TRACE || TRACE_HEADER_MULTI_READ */ #undef TRACE_INCLUDE_PATH
Signature · 1 line
2.30.1
Johannes Berg
maintainerRe: [RFC 1/7] mac80211: add support for .ndo_fill_forward_path
Quoted 13 lines · Felix Fietkau
net/mac80211/iface.c +13
-0+ +static int ieee80211_netdev_fill_forward_path (struct net_device_path_ctx *ctx, +struct net_device_path *path) +{ +struct ieee80211_sub_if_data *sdata; +struct ieee80211_local *local; +struct sta_info *sta; +int ret = -ENOENT ; + + sdata =IEEE80211_DEV_TO_SUB_IF (ctx->dev); + local = sdata->local; + +if (!local->ops->net_fill_forward_path)
net/mac80211/iface.c static const struct net_device_ops ieee80211_monitorif_ops = { · line 784
Quoted 10 lines
net/mac80211/iface.c +10
-0+return -EOPNOTSUPP ; + +rcu_read_lock (); +switch (sdata->vif.type) { +case NL80211_IFTYPE_AP_VLAN : + sta =rcu_dereference (sdata->u.vlan.sta); +if (sta) +break ; +if (!sdata->wdev.use_4addr) + goto out;
Am I confusing things, or is this condition inverted? If it's not 4-addr then you won't have a u.vlan.sta, but you might still want to look up the station more generally, no?
net/mac80211/iface.c static const struct net_device_ops ieee80211_monitorif_ops = { · line 789
Quoted 5 lines
net/mac80211/iface.c +5
-0+ fallthrough; +case NL80211_IFTYPE_AP : +if (is_multicast_ether_addr (ctx->daddr)) + goto out; + sta =sta_info_get_bss (sdata, ctx->daddr);
Or maybe this shouldn't use _bss() here, but then you'd need to write a sta_info_get() also in the VLAN case, no?
Which might actually be better or even correct, because if the station is on the VLAN you probably *don't* want to find it here if the interface that's being passed is the AP, no?
johannes
kernel test robot
build botRe: [RFC 1/7] mac80211: add support for .ndo_fill_forward_path
In reply to Felix Fietkau[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch]
Hi Felix,
[FYI, it's a private test report for your RFC patch.]
[auto build test ERROR on wireless-drivers-next/master]
[also build test ERROR on wireless-drivers/master mac80211-next/master mac80211/master linus/master v5.14-rc1 next-20210713] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Felix-Fietkau/Ethernet-WLAN-hardware-flow-offloading-support-on-MT7622/20210714-001409 base: https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git master config: powerpc-randconfig-r003-20210713 (attached as .config) compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 8d69635ed9ecf36fd0ca85906bfde17949671cbe)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install powerpc cross compiling tool for clang build
# apt-get install binutils-powerpc-linux-gnu
# https://github.com/0day-ci/linux/commit/c531997b320959473fb8b8e72d837aff58970493
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Felix-Fietkau/Ethernet-WLAN-hardware-flow-offloading-support-on-MT7622/20210714-001409
git checkout c531997b320959473fb8b8e72d837aff58970493
# save the attached .config to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross O=build_dir ARCH=powerpc SHELL=/bin/bash drivers/net/wireless/mediatek/mt76/ net/mac80211/
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
In file included from net/mac80211/iface.c:13:
In file included from include/linux/slab.h:15:
In file included from include/linux/gfp.h:5:
In file included from include/linux/mmdebug.h:5:
In file included from include/linux/bug.h:5:
In file included from arch/powerpc/include/asm/bug.h:109:
In file included from include/asm-generic/bug.h:20:
In file included from include/linux/kernel.h:12:
In file included from include/linux/bitops.h:32:
In file included from arch/powerpc/include/asm/bitops.h:62:
arch/powerpc/include/asm/barrier.h:49:9: warning: '__lwsync' macro redefined [-Wmacro-redefined]
#define __lwsync() __asm__ __volatile__ (stringify_in_c(LWSYNC) : : :"memory")
^
<built-in>:309:9: note: previous definition is here
#define __lwsync __builtin_ppc_lwsync
^
>> net/mac80211/iface.c:718:27: error: use of undeclared identifier 'ieee80211_netdev_fill_forward_path' .ndo_fill_forward_path = ieee80211_netdev_fill_forward_path,
^
1 warning and 1 error generated.
vim +/ieee80211_netdev_fill_forward_path +718 net/mac80211/iface.c
708
709 static const struct net_device_ops ieee80211_dataif_ops = {
710 .ndo_open = ieee80211_open,
711 .ndo_stop = ieee80211_stop,
712 .ndo_uninit = ieee80211_uninit,
713 .ndo_start_xmit = ieee80211_subif_start_xmit,
714 .ndo_set_rx_mode = ieee80211_set_multicast_list,
715 .ndo_set_mac_address = ieee80211_change_mac,
716 .ndo_select_queue = ieee80211_netdev_select_queue,
717 .ndo_get_stats64 = ieee80211_get_stats64,
> 718 .ndo_fill_forward_path = ieee80211_netdev_fill_forward_path,
719 };
720
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
kernel test robot
build botRe: [RFC 1/7] mac80211: add support for .ndo_fill_forward_path
In reply to Felix Fietkau[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch]
Hi Felix,
[FYI, it's a private test report for your RFC patch.]
[auto build test ERROR on wireless-drivers-next/master]
[also build test ERROR on wireless-drivers/master mac80211-next/master mac80211/master linus/master v5.14-rc1 next-20210713] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Felix-Fietkau/Ethernet-WLAN-hardware-flow-offloading-support-on-MT7622/20210714-001409 base: https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git master config: sparc-randconfig-p002-20210713 (attached as .config) compiler: sparc-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/c531997b320959473fb8b8e72d837aff58970493
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Felix-Fietkau/Ethernet-WLAN-hardware-flow-offloading-support-on-MT7622/20210714-001409 git checkout c531997b320959473fb8b8e72d837aff58970493
# save the attached .config to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross O=build_dir ARCH=sparc SHELL=/bin/bash net/mac80211/
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
>> net/mac80211/iface.c:718:27: error: 'ieee80211_netdev_fill_forward_path' undeclared here (not in a function); did you mean 'drv_net_fill_forward_path'?
718 | .ndo_fill_forward_path = ieee80211_netdev_fill_forward_path,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| drv_net_fill_forward_path net/mac80211/iface.c:761:12: warning: 'ieee80211_netdev_fill_forward_path' defined but not used [-Wunused-function]
761 | static int ieee80211_netdev_fill_forward_path(struct net_device_path_ctx *ctx,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vim +718 net/mac80211/iface.c
708
709 static const struct net_device_ops ieee80211_dataif_ops = {
710 .ndo_open = ieee80211_open,
711 .ndo_stop = ieee80211_stop,
712 .ndo_uninit = ieee80211_uninit,
713 .ndo_start_xmit = ieee80211_subif_start_xmit,
714 .ndo_set_rx_mode = ieee80211_set_multicast_list,
715 .ndo_set_mac_address = ieee80211_change_mac,
716 .ndo_select_queue = ieee80211_netdev_select_queue,
717 .ndo_get_stats64 = ieee80211_get_stats64,
> 718 .ndo_fill_forward_path = ieee80211_netdev_fill_forward_path,
719 };
720
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Felix Fietkau
maintainerRFC 2/7 net: ethernet: mtk_eth_soc: add support for Wireless Ethernet Dispatch (WED)
In reply to Felix FietkauThe Wireless Ethernet Dispatch subsystem on the MT7622 SoC can be configured to intercept and handle access to the DMA queues and PCIe interrupts for a MT7615/MT7915 wireless card.
It can manage the internal WDMA (Wireless DMA) controller, which allows ethernet packets to be passed from the packet switch engine (PSE) to the wireless card, bypassing the CPU entirely.
This can be used to implement hardware flow offloading from ethernet to WLAN.
--- arch/arm64/boot/dts/mediatek/mt7622.dtsi | 22 + drivers/net/ethernet/mediatek/Kconfig | 4 + drivers/net/ethernet/mediatek/Makefile | 5 + drivers/net/ethernet/mediatek/mtk_eth_soc.c | 23 + drivers/net/ethernet/mediatek/mtk_eth_soc.h | 3 + drivers/net/ethernet/mediatek/mtk_wed.c | 837 ++++++++++++++++++ drivers/net/ethernet/mediatek/mtk_wed.h | 123 +++ .../net/ethernet/mediatek/mtk_wed_debugfs.c | 175 ++++ drivers/net/ethernet/mediatek/mtk_wed_ops.c | 8 + drivers/net/ethernet/mediatek/mtk_wed_regs.h | 248 ++++++ include/linux/soc/mediatek/mtk_wed.h | 127 +++ 11 files changed, 1575 insertions(+) create mode 100644 drivers/net/ethernet/mediatek/mtk_wed.c create mode 100644 drivers/net/ethernet/mediatek/mtk_wed.h create mode 100644 drivers/net/ethernet/mediatek/mtk_wed_debugfs.c create mode 100644 drivers/net/ethernet/mediatek/mtk_wed_ops.c create mode 100644 drivers/net/ethernet/mediatek/mtk_wed_regs.h create mode 100644 include/linux/soc/mediatek/mtk_wed.h
arch/arm64/boot/dts/mediatek/mt7622.dtsi +22 -0
@@ -911,6 +911,26 @@ hsdma: dma-controller@1b007000 { #dma-cells = <1>; }; + pcie_mirror: pcie-mirror@10000400 { + compatible = "mediatek,mt7622-pcie-mirror", + "syscon"; + reg = <0 0x10000400 0 0x10>; + }; + + wed0: wed@1020a000 { + compatible = "mediatek,mt7622-wed", + "syscon"; + reg = <0 0x1020a000 0 0x1000>; + interrupts = <GIC_SPI 214 IRQ_TYPE_LEVEL_LOW>; + }; + + wed1: wed@1020b000 { + compatible = "mediatek,mt7622-wed", + "syscon"; + reg = <0 0x1020b000 0 0x1000>; + interrupts = <GIC_SPI 215 IRQ_TYPE_LEVEL_LOW>; + }; + eth: ethernet@1b100000 { compatible = "mediatek,mt7622-eth", "mediatek,mt2701-eth",
@@ -937,6 +957,8 @@ eth: ethernet@1b100000 { power-domains = <&scpsys MT7622_POWER_DOMAIN_ETHSYS>; mediatek,ethsys = <ðsys>; mediatek,sgmiisys = <&sgmiisys>; + mediatek,wed = <&wed0>, <&wed1>; + mediatek,pcie-mirror = <&pcie_mirror>; #address-cells = <1>; #size-cells = <0>; status = "disabled";
drivers/net/ethernet/mediatek/Kconfig +4 -0
@@ -7,6 +7,10 @@ config NET_VENDOR_MEDIATEK if NET_VENDOR_MEDIATEK +config NET_MEDIATEK_SOC_WED + depends on ARCH_MEDIATEK + def_tristate NET_MEDIATEK_SOC + config NET_MEDIATEK_SOC tristate "MediaTek SoC Gigabit Ethernet support" depends on NET_DSA || !NET_DSA
drivers/net/ethernet/mediatek/Makefile +5 -0
@@ -5,4 +5,9 @@ obj-$(CONFIG_NET_MEDIATEK_SOC) += mtk_eth.o mtk_eth-y := mtk_eth_soc.o mtk_sgmii.o mtk_eth_path.o mtk_ppe.o mtk_ppe_debugfs.o mtk_ppe_offload.o +mtk_eth-$(CONFIG_NET_MEDIATEK_SOC_WED) += mtk_wed.o +ifdef CONFIG_DEBUG_FS +mtk_eth-$(CONFIG_NET_MEDIATEK_SOC_WED) += mtk_wed_debugfs.o +endif +obj-$(CONFIG_NET_MEDIATEK_SOC_WED) += mtk_wed_ops.o obj-$(CONFIG_NET_MEDIATEK_STAR_EMAC) += mtk_star_emac.o
drivers/net/ethernet/mediatek/mtk_eth_soc.c +23 -0
@@ -23,6 +23,7 @@#include <net/dsa.h> #include "mtk_eth_soc.h" +#include "mtk_wed.h" static int mtk_msg_level =-1 ;module_param_named (msg_level, mtk_msg_level, int,0 );
@@ -3132,6 +3133,28 @@ static int mtk_probe(struct platform_device *pdev) } } +for (i =0 ;; i++) { +struct device_node *np =of_parse_phandle (pdev->dev.of_node, +"mediatek,wed" , i); +static const u32 wdma_regs[] = { +MTK_WDMA0_BASE , +MTK_WDMA1_BASE + }; +struct regmap *mirror; +void __iomem *wdma; + +if (!np || i >=ARRAY_SIZE (wdma_regs)) +break ; + + mirror =syscon_regmap_lookup_by_phandle (pdev->dev.of_node, +"mediatek,pcie-mirror" ); +if (IS_ERR (mirror)) +break ; + + wdma = eth->base + wdma_regs[i]; +mtk_wed_add_hw (np, wdma, mirror, i); + } +for (i =0 ; i <3 ; i++) {if (MTK_HAS_CAPS (eth->soc->caps,MTK_SHARED_INT ) && i >0 ) eth->irq[i] = eth->irq[0 ];
drivers/net/ethernet/mediatek/mtk_eth_soc.h +3 -0
@@ -295,6 +295,9 @@#define MTK_GDM1_TX_GPCNT 0x2438#define MTK_STAT_OFFSET 0x40 +#define MTK_WDMA0_BASE 0x2800 +#define MTK_WDMA1_BASE 0x2c00 +/* QDMA descriptor txd4 */ #define TX_DMA_CHKSUM (0x7 << 29)#define TX_DMA_TSO BIT(28)
drivers/net/ethernet/mediatek/mtk_wed.c new file +837 -0
837 lines not on this page · raw message
drivers/net/ethernet/mediatek/mtk_wed.h new file +123 -0
123 lines not on this page · raw message
drivers/net/ethernet/mediatek/mtk_wed_debugfs.c new file +175 -0
175 lines not on this page · raw message
drivers/net/ethernet/mediatek/mtk_wed_ops.c new file +8 -0
@@ -0,0 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* Copyright (C) 2020 Felix Fietkau <[email protected]> */ + +#include <linux/kernel.h> +#include <linux/soc/mediatek/mtk_wed.h> + +const struct mtk_wed_ops __rcu *mtk_soc_wed_ops; +EXPORT_SYMBOL_GPL (mtk_soc_wed_ops);
drivers/net/ethernet/mediatek/mtk_wed_regs.h new file +248 -0
248 lines not on this page · raw message
include/linux/soc/mediatek/mtk_wed.h new file +127 -0
127 lines not on this page · raw message
Signature · 1 line
2.30.1
Re: [RFC 2/7] net: ethernet: mtk_eth_soc: add support for Wireless Ethernet Dispatch (WED)
drivers/net/ethernet/mediatek/mtk_wed.c line 34
Quoted 7 lines
drivers/net/ethernet/mediatek/mtk_wed.c +6
-0+ +static inline void +wed_m32 (struct mtk_wed_device *dev,u32 reg,u32 mask,u32 val) +{ +regmap_update_bits (dev->hw->regs, reg, mask | val, val); +}
Please don't use inline functions in .c files. Let the compiler decide.
drivers/net/ethernet/mediatek/mtk_wed.c line 77
Quoted 12 lines
drivers/net/ethernet/mediatek/mtk_wed.c +12
-0+static void +mtk_wed_reset (struct mtk_wed_device *dev,u32 mask) +{ +int i; + +wed_w32 (dev,MTK_WED_RESET , mask); +for (i =0 ; i <100 ; i++) { +if (wed_r32 (dev,MTK_WED_RESET ) & mask) +continue ; + +return ; + }
It may be better to use something from iopoll.h
drivers/net/ethernet/mediatek/mtk_wed.c
Quoted 6 lines
drivers/net/ethernet/mediatek/mtk_wed.c +6
-0+static inline int +mtk_wed_device_attach (struct mtk_wed_device *dev) +{ +int ret = -ENODEV ; + +#ifdef CONFIG_NET_MEDIATEK_SOC_WED
if (IS_ENABLED(CONFIG_NET_MEDIATEK_SOC_WED) is better, since it compiles the code, and then the optimizer throws away.
drivers/net/ethernet/mediatek/mtk_wed.c
Quoted 12 lines
drivers/net/ethernet/mediatek/mtk_wed.c +12
-0+rcu_read_lock (); + dev->ops =rcu_dereference (mtk_soc_wed_ops); +if (dev->ops) + ret = dev->ops->attach (dev); +rcu_read_unlock (); + +if (ret) + dev->ops =NULL ; +#endif + +return ret; +}
Andrew
Felix Fietkau
maintainerRe: [RFC 2/7] net: ethernet: mtk_eth_soc: add support for Wireless Ethernet Dispatch (WED)
Quoted 10 lines · Andrew Lunn
drivers/net/ethernet/mediatek/mtk_wed.c line 34
Quoted 7 lines
drivers/net/ethernet/mediatek/mtk_wed.c +6
-0+ +static inline void +wed_m32 (struct mtk_wed_device *dev,u32 reg,u32 mask,u32 val) +{ +regmap_update_bits (dev->hw->regs, reg, mask | val, val); +}Please don't use inline functions in .c files. Let the compiler decide.
Will drop inline
Quoted 6 lines
Quoted 6 lines
drivers/net/ethernet/mediatek/mtk_wed.c +6
-0+static void +mtk_wed_reset (struct mtk_wed_device *dev,u32 mask) +{ +int i; + +wed_w32 (dev,MTK_WED_RESET , mask);
Quoted 8 lines
drivers/net/ethernet/mediatek/mtk_wed.c line 77
Quoted 6 lines
drivers/net/ethernet/mediatek/mtk_wed.c +6
-0+for (i =0 ; i <100 ; i++) { +if (wed_r32 (dev,MTK_WED_RESET ) & mask) +continue ; + +return ; + }It may be better to use something from
iopoll.h
Will do
Quoted 9 lines
drivers/net/ethernet/mediatek/mtk_wed.c
Quoted 6 lines
drivers/net/ethernet/mediatek/mtk_wed.c +6
-0+static inline int +mtk_wed_device_attach (struct mtk_wed_device *dev) +{ +int ret = -ENODEV ; + +#ifdef CONFIG_NET_MEDIATEK_SOC_WED if (
IS_ENABLED(CONFIG_NET_MEDIATEK_SOC_WED)is better, since it compiles the code, and then the optimizer throws away.
This one is intentional, since struct mtk_wed_device will be empty if CONFIG_NET_MEDIATEK_SOC_WED is not set. The code would not compile without the #ifdef.
Thanks,
- Felix
Felix Fietkau
maintainerRFC 3/7 net: ethernet: mtk_eth_soc: implement flow offloading to WED devices
In reply to Felix FietkauThis allows hardware flow offloading from Ethernet to WLAN on MT7622 SoC
--- drivers/net/ethernet/mediatek/mtk_ppe.c | 18 +++++ drivers/net/ethernet/mediatek/mtk_ppe.h | 14 ++-- .../net/ethernet/mediatek/mtk_ppe_offload.c | 67 ++++++++++++------- include/linux/netdevice.h | 7 ++ net/core/dev.c | 4 ++ 5 files changed, 78 insertions(+), 32 deletions(-)
drivers/net/ethernet/mediatek/mtk_ppe.c +18 -0
@@ -329,6 +329,24 @@ int mtk_foe_entry_set_pppoe(struct mtk_foe_entry *entry, int sid)return 0 ; } +int mtk_foe_entry_set_wdma (struct mtk_foe_entry *entry,int wdma_idx,int txq, +int bss,int wcid) +{ +struct mtk_foe_mac_info *l2 =mtk_foe_entry_l2 (entry); +u32 *ib2 =mtk_foe_entry_ib2 (entry); + + *ib2 &= ~MTK_FOE_IB2_PORT_MG ; + *ib2 |=MTK_FOE_IB2_WDMA_WINFO ; +if (wdma_idx) + *ib2 |=MTK_FOE_IB2_WDMA_DEVIDX ; + + l2->vlan2 =FIELD_PREP (MTK_FOE_VLAN2_WINFO_BSS , bss) | +FIELD_PREP (MTK_FOE_VLAN2_WINFO_WCID , wcid) | +FIELD_PREP (MTK_FOE_VLAN2_WINFO_RING , txq); + +return 0 ; +} +static inline bool mtk_foe_entry_usable (struct mtk_foe_entry *entry) { return !(entry->ib1 & MTK_FOE_IB1_STATIC) &&
drivers/net/ethernet/mediatek/mtk_ppe.h +8 -6
@@ -48,9 +48,9 @@ enum {#define MTK_FOE_IB2_DEST_PORT GENMASK(7, 5)#define MTK_FOE_IB2_MULTICAST BIT(8) -#define MTK_FOE_IB2_WHNAT_QID2 GENMASK(13, 12) -#define MTK_FOE_IB2_WHNAT_DEVIDX BIT(16) -#define MTK_FOE_IB2_WHNAT_NAT BIT(17) +#define MTK_FOE_IB2_WDMA_QID2 GENMASK(13, 12) +#define MTK_FOE_IB2_WDMA_DEVIDX BIT(16) +#define MTK_FOE_IB2_WDMA_WINFO BIT(17)#define MTK_FOE_IB2_PORT_MG GENMASK(17, 12)
@@ -58,9 +58,9 @@ enum {#define MTK_FOE_IB2_DSCP GENMASK(31, 24) -#define MTK_FOE_VLAN2_WHNAT_BSS GEMMASK(5, 0) -#define MTK_FOE_VLAN2_WHNAT_WCID GENMASK(13, 6) -#define MTK_FOE_VLAN2_WHNAT_RING GENMASK(15, 14) +#define MTK_FOE_VLAN2_WINFO_BSS GENMASK(5, 0) +#define MTK_FOE_VLAN2_WINFO_WCID GENMASK(13, 6) +#define MTK_FOE_VLAN2_WINFO_RING GENMASK(15, 14)enum {MTK_FOE_STATE_INVALID ,
@@ -281,6 +281,8 @@ int mtk_foe_entry_set_ipv6_tuple(struct mtk_foe_entry *entry,int mtk_foe_entry_set_dsa (struct mtk_foe_entry *entry,int port);int mtk_foe_entry_set_vlan (struct mtk_foe_entry *entry,int vid);int mtk_foe_entry_set_pppoe (struct mtk_foe_entry *entry,int sid); +int mtk_foe_entry_set_wdma (struct mtk_foe_entry *entry,int wdma_idx,int txq, +int bss,int wcid);int mtk_foe_entry_commit (struct mtk_ppe *ppe,struct mtk_foe_entry *entry,u16 timestamp);int mtk_ppe_debugfs_init (struct mtk_ppe *ppe);
drivers/net/ethernet/mediatek/mtk_ppe_offload.c +41 -26
122 lines not on this page · raw message
include/linux/netdevice.h +7 -0
@@ -856,6 +856,7 @@ enum net_device_path_type {DEV_PATH_BRIDGE ,DEV_PATH_PPPOE ,DEV_PATH_DSA , + DEV_PATH_MTK_WDMA, }; struct net_device_path {
@@ -881,6 +882,12 @@ struct net_device_path {int port;u16 proto; } dsa; +struct { +u8 wdma_idx; +u8 queue; +u8 bss; +u8 wcid; + } mtk_wdma; }; };
net/core/dev.c +4 -0
@@ -885,6 +885,10 @@ int dev_fill_forward_path(const struct net_device *dev, const u8 *daddr,if (WARN_ON_ONCE (last_dev == ctx.dev))return -1 ; } + +if (!ctx.dev) +return ret; + path =dev_fwd_path (stack);if (!path)return -1 ;
Signature · 1 line
2.30.1
Re: [RFC 3/7] net: ethernet: mtk_eth_soc: implement flow offloading to WED devices
On Tue, Jul 13, 2021 at 06:07:41PM +0200, Felix Fietkau wrote:
[...]
net/core/dev.c int dev_fill_forward_path(const struct net_device *dev, const u8 *daddr, · line 890
Quoted 11 lines
net/core/dev.c +3
-0@@ -885,6 +885,10 @@ int dev_fill_forward_path(const struct net_device *dev, const u8 *daddr,if (WARN_ON_ONCE (last_dev == ctx.dev))return -1 ; } + +if (!ctx.dev) +return ret;
This is not a safety check, right? After this update ctx.dev might be NULL?
Quoted 7 lines
net/core/dev.c +1
-0+ path =dev_fwd_path (stack);if (!path)return -1 ;Signature · 1 line
2.30.1
Felix Fietkau
maintainerRe: [RFC 3/7] net: ethernet: mtk_eth_soc: implement flow offloading to WED devices
Quoted 15 lines · Pablo Neira Ayuso
On Tue, Jul 13, 2021 at 06:07:41PM +0200, Felix Fietkau wrote:
[...]net/core/dev.c int dev_fill_forward_path(const struct net_device *dev, const u8 *daddr, · line 890
Quoted 11 lines
net/core/dev.c +3
-0@@ -885,6 +885,10 @@ int dev_fill_forward_path(const struct net_device *dev, const u8 *daddr,if (WARN_ON_ONCE (last_dev == ctx.dev))return -1 ; } + +if (!ctx.dev) +return ret;This is not a safety check, right? After this update ctx.dev might be NULL?
Right. I added this check to be able to prevent dev_fill_forward_path from adding an extra DEV_PATH_ETHERNET entry, which is not applicable for wlan devices.
- Felix
Re: [RFC 3/7] net: ethernet: mtk_eth_soc: implement flow offloading to WED devices
In reply to Felix FietkauQuoted 118 lines · Felix Fietkau
This allows hardware flow offloading from Ethernet to WLAN on MT7622 SoC
Signed-off-by Felix Fietkau <[email protected]>--- drivers/net/ethernet/mediatek/mtk_ppe.c | 18 +++++ drivers/net/ethernet/mediatek/mtk_ppe.h | 14 ++-- .../net/ethernet/mediatek/mtk_ppe_offload.c | 67 ++++++++++++------- include/linux/netdevice.h | 7 ++ net/core/dev.c | 4 ++ 5 files changed, 78 insertions(+), 32 deletions(-)drivers/net/ethernet/mediatek/mtk_ppe.c +18
-0@@ -329,6 +329,24 @@ int mtk_foe_entry_set_pppoe(struct mtk_foe_entry *entry, int sid)return 0 ; } +int mtk_foe_entry_set_wdma (struct mtk_foe_entry *entry,int wdma_idx,int txq, +int bss,int wcid) +{ +struct mtk_foe_mac_info *l2 =mtk_foe_entry_l2 (entry); +u32 *ib2 =mtk_foe_entry_ib2 (entry); + + *ib2 &= ~MTK_FOE_IB2_PORT_MG ; + *ib2 |=MTK_FOE_IB2_WDMA_WINFO ; +if (wdma_idx) + *ib2 |=MTK_FOE_IB2_WDMA_DEVIDX ; + + l2->vlan2 =FIELD_PREP (MTK_FOE_VLAN2_WINFO_BSS , bss) | +FIELD_PREP (MTK_FOE_VLAN2_WINFO_WCID , wcid) | +FIELD_PREP (MTK_FOE_VLAN2_WINFO_RING , txq); + +return 0 ; +} +static inline bool mtk_foe_entry_usable (struct mtk_foe_entry *entry) { return !(entry->ib1 & MTK_FOE_IB1_STATIC) &&drivers/net/ethernet/mediatek/mtk_ppe.h +8
-6@@ -48,9 +48,9 @@ enum {#define MTK_FOE_IB2_DEST_PORT GENMASK(7, 5)#define MTK_FOE_IB2_MULTICAST BIT(8) -#define MTK_FOE_IB2_WHNAT_QID2 GENMASK(13, 12) -#define MTK_FOE_IB2_WHNAT_DEVIDX BIT(16) -#define MTK_FOE_IB2_WHNAT_NAT BIT(17) +#define MTK_FOE_IB2_WDMA_QID2 GENMASK(13, 12) +#define MTK_FOE_IB2_WDMA_DEVIDX BIT(16) +#define MTK_FOE_IB2_WDMA_WINFO BIT(17)#define MTK_FOE_IB2_PORT_MG GENMASK(17, 12)@@ -58,9 +58,9 @@ enum {#define MTK_FOE_IB2_DSCP GENMASK(31, 24) -#define MTK_FOE_VLAN2_WHNAT_BSS GEMMASK(5, 0) -#define MTK_FOE_VLAN2_WHNAT_WCID GENMASK(13, 6) -#define MTK_FOE_VLAN2_WHNAT_RING GENMASK(15, 14) +#define MTK_FOE_VLAN2_WINFO_BSS GENMASK(5, 0) +#define MTK_FOE_VLAN2_WINFO_WCID GENMASK(13, 6) +#define MTK_FOE_VLAN2_WINFO_RING GENMASK(15, 14)enum {MTK_FOE_STATE_INVALID ,@@ -281,6 +281,8 @@ int mtk_foe_entry_set_ipv6_tuple(struct mtk_foe_entry *entry,int mtk_foe_entry_set_dsa (struct mtk_foe_entry *entry,int port);int mtk_foe_entry_set_vlan (struct mtk_foe_entry *entry,int vid);int mtk_foe_entry_set_pppoe (struct mtk_foe_entry *entry,int sid); +int mtk_foe_entry_set_wdma (struct mtk_foe_entry *entry,int wdma_idx,int txq, +int bss,int wcid);int mtk_foe_entry_commit (struct mtk_ppe *ppe,struct mtk_foe_entry *entry,u16 timestamp);int mtk_ppe_debugfs_init (struct mtk_ppe *ppe);drivers/net/ethernet/mediatek/mtk_ppe_offload.c +6
-10@@ -10,6 +10,7 @@#include <net/pkt_cls.h> #include <net/dsa.h> #include "mtk_eth_soc.h" +#include "mtk_wed.h" struct mtk_flow_data {struct ethhdr eth;@@ -39,6 +40,7 @@ struct mtk_flow_entry {struct rhash_head node;unsigned long cookie;u16 hash; +s8 wed_index; };static const struct rhashtable_params mtk_flow_ht_params = {@@ -127,35 +129,38 @@ mtk_flow_mangle_ipv4(const struct flow_action_entry *act, }static int -mtk_flow_get_dsa_port (struct net_device **dev) +mtk_flow_set_output_device (struct mtk_eth *eth,struct mtk_foe_entry *foe, +struct net_device *dev,const u8 *dest_mac, +int *wed_index) { -#if IS_ENABLED (CONFIG_NET_DSA ) -struct dsa_port *dp; - - dp =dsa_port_from_netdev (*dev); -if (IS_ERR (dp)) -return -ENODEV ; - -if (dp->cpu_dp->tag_ops->proto !=DSA_TAG_PROTO_MTK ) -return -ENODEV ; +struct net_device_path_ctx ctx = {
drivers/net/ethernet/mediatek/mtk_ppe_offload.c mtk_flow_mangle_ipv4(const struct flow_action_entry *act, · line 145
Quoted 10 lines
drivers/net/ethernet/mediatek/mtk_ppe_offload.c +8
-1+ .dev = dev, + .daddr = dest_mac, + }; +struct net_device_path path = {}; +int pse_port; - *dev = dp->cpu_dp->master; +if (!dev->netdev_ops->ndo_fill_forward_path || + dev->netdev_ops->ndo_fill_forward_path (&ctx, &path) <0 ) + path.type =DEV_PATH_ETHERNET ;
Maybe expose this through flow offload API so there is no need to call ndo_fill_forward_path again from the driver?
drivers/net/ethernet/mediatek/mtk_ppe_offload.c mtk_flow_mangle_ipv4(const struct flow_action_entry *act, · line 148
Quoted 13 lines
drivers/net/ethernet/mediatek/mtk_ppe_offload.c +2
-11-return dp->index; -#else -return -ENODEV ; -#endif -} - -static int -mtk_flow_set_output_device (struct mtk_eth *eth,struct mtk_foe_entry *foe, -struct net_device *dev) -{ -int pse_port, dsa_port; +switch (path.type) { +case DEV_PATH_DSA :
This DSA update is not related, right?
Felix Fietkau
maintainerRe: [RFC 3/7] net: ethernet: mtk_eth_soc: implement flow offloading to WED devices
Quoted 125 lines · Pablo Neira Ayuso
Quoted 124 lines · Felix Fietkau
This allows hardware flow offloading from Ethernet to WLAN on MT7622 SoC
Signed-off-by Felix Fietkau <[email protected]>--- drivers/net/ethernet/mediatek/mtk_ppe.c | 18 +++++ drivers/net/ethernet/mediatek/mtk_ppe.h | 14 ++-- .../net/ethernet/mediatek/mtk_ppe_offload.c | 67 ++++++++++++------- include/linux/netdevice.h | 7 ++ net/core/dev.c | 4 ++ 5 files changed, 78 insertions(+), 32 deletions(-)drivers/net/ethernet/mediatek/mtk_ppe.c +18
-0@@ -329,6 +329,24 @@ int mtk_foe_entry_set_pppoe(struct mtk_foe_entry *entry, int sid)return 0 ; } +int mtk_foe_entry_set_wdma (struct mtk_foe_entry *entry,int wdma_idx,int txq, +int bss,int wcid) +{ +struct mtk_foe_mac_info *l2 =mtk_foe_entry_l2 (entry); +u32 *ib2 =mtk_foe_entry_ib2 (entry); + + *ib2 &= ~MTK_FOE_IB2_PORT_MG ; + *ib2 |=MTK_FOE_IB2_WDMA_WINFO ; +if (wdma_idx) + *ib2 |=MTK_FOE_IB2_WDMA_DEVIDX ; + + l2->vlan2 =FIELD_PREP (MTK_FOE_VLAN2_WINFO_BSS , bss) | +FIELD_PREP (MTK_FOE_VLAN2_WINFO_WCID , wcid) | +FIELD_PREP (MTK_FOE_VLAN2_WINFO_RING , txq); + +return 0 ; +} +static inline bool mtk_foe_entry_usable (struct mtk_foe_entry *entry) { return !(entry->ib1 & MTK_FOE_IB1_STATIC) &&drivers/net/ethernet/mediatek/mtk_ppe.h +8
-6@@ -48,9 +48,9 @@ enum {#define MTK_FOE_IB2_DEST_PORT GENMASK(7, 5)#define MTK_FOE_IB2_MULTICAST BIT(8) -#define MTK_FOE_IB2_WHNAT_QID2 GENMASK(13, 12) -#define MTK_FOE_IB2_WHNAT_DEVIDX BIT(16) -#define MTK_FOE_IB2_WHNAT_NAT BIT(17) +#define MTK_FOE_IB2_WDMA_QID2 GENMASK(13, 12) +#define MTK_FOE_IB2_WDMA_DEVIDX BIT(16) +#define MTK_FOE_IB2_WDMA_WINFO BIT(17)#define MTK_FOE_IB2_PORT_MG GENMASK(17, 12)@@ -58,9 +58,9 @@ enum {#define MTK_FOE_IB2_DSCP GENMASK(31, 24) -#define MTK_FOE_VLAN2_WHNAT_BSS GEMMASK(5, 0) -#define MTK_FOE_VLAN2_WHNAT_WCID GENMASK(13, 6) -#define MTK_FOE_VLAN2_WHNAT_RING GENMASK(15, 14) +#define MTK_FOE_VLAN2_WINFO_BSS GENMASK(5, 0) +#define MTK_FOE_VLAN2_WINFO_WCID GENMASK(13, 6) +#define MTK_FOE_VLAN2_WINFO_RING GENMASK(15, 14)enum {MTK_FOE_STATE_INVALID ,@@ -281,6 +281,8 @@ int mtk_foe_entry_set_ipv6_tuple(struct mtk_foe_entry *entry,int mtk_foe_entry_set_dsa (struct mtk_foe_entry *entry,int port);int mtk_foe_entry_set_vlan (struct mtk_foe_entry *entry,int vid);int mtk_foe_entry_set_pppoe (struct mtk_foe_entry *entry,int sid); +int mtk_foe_entry_set_wdma (struct mtk_foe_entry *entry,int wdma_idx,int txq, +int bss,int wcid);int mtk_foe_entry_commit (struct mtk_ppe *ppe,struct mtk_foe_entry *entry,u16 timestamp);int mtk_ppe_debugfs_init (struct mtk_ppe *ppe);drivers/net/ethernet/mediatek/mtk_ppe_offload.c +11
-10@@ -10,6 +10,7 @@#include <net/pkt_cls.h> #include <net/dsa.h> #include "mtk_eth_soc.h" +#include "mtk_wed.h" struct mtk_flow_data {struct ethhdr eth;@@ -39,6 +40,7 @@ struct mtk_flow_entry {struct rhash_head node;unsigned long cookie;u16 hash; +s8 wed_index; };static const struct rhashtable_params mtk_flow_ht_params = {@@ -127,35 +129,38 @@ mtk_flow_mangle_ipv4(const struct flow_action_entry *act, }static int -mtk_flow_get_dsa_port (struct net_device **dev) +mtk_flow_set_output_device (struct mtk_eth *eth,struct mtk_foe_entry *foe, +struct net_device *dev,const u8 *dest_mac, +int *wed_index) { -#if IS_ENABLED (CONFIG_NET_DSA ) -struct dsa_port *dp; - - dp =dsa_port_from_netdev (*dev); -if (IS_ERR (dp)) -return -ENODEV ; - -if (dp->cpu_dp->tag_ops->proto !=DSA_TAG_PROTO_MTK ) -return -ENODEV ; +struct net_device_path_ctx ctx = { + .dev = dev, + .daddr = dest_mac, + }; +struct net_device_path path = {}; +int pse_port;
Quoted 7 lines
drivers/net/ethernet/mediatek/mtk_ppe_offload.c mtk_flow_mangle_ipv4(const struct flow_action_entry *act, · line 145
Quoted 4 lines
drivers/net/ethernet/mediatek/mtk_ppe_offload.c +3
-1- *dev = dp->cpu_dp->master; +if (!dev->netdev_ops->ndo_fill_forward_path || + dev->netdev_ops->ndo_fill_forward_path (&ctx, &path) <0 ) + path.type =DEV_PATH_ETHERNET ;Maybe expose this through flow offload API so there is no need to call
ndo_fill_forward_pathagain from the driver?
Can you give me a pseudo-code example? I'm not sure how you want it to be exposed through the flow offload API.
To me it seems easier and cleaner to just have a single ndo_fill_forward_path call for the final output device to check the device types that don't have any corresponding sw offload.
Quoted 7 lines
Quoted 7 lines
drivers/net/ethernet/mediatek/mtk_ppe_offload.c +0
-7-return dp->index; -#else -return -ENODEV ; -#endif -} - -static int
Quoted 8 lines
drivers/net/ethernet/mediatek/mtk_ppe_offload.c mtk_flow_mangle_ipv4(const struct flow_action_entry *act, · line 148
Quoted 6 lines
drivers/net/ethernet/mediatek/mtk_ppe_offload.c +2
-4-mtk_flow_set_output_device(struct mtk_eth *eth, struct mtk_foe_entry *foe, - struct net_device *dev) -{ - int pse_port, dsa_port; +switch (path.type) { +case DEV_PATH_DSA :This DSA update is not related, right?
I consider it related. Since I'm calling ndo_fill_forward_path now, it's better to use it for both DSA and WLAN instead of having independent checks.
- Felix
Re: [RFC 3/7] net: ethernet: mtk_eth_soc: implement flow offloading to WED devices
Quoted 1 line · Felix Fietkau
On 2021-07-13 20:56, Pablo Neira Ayuso wrote:
[...]
Quoted 51 lines
Quoted 43 lines
Quoted 43 lines
drivers/net/ethernet/mediatek/mtk_ppe_offload.c +11
-10@@ -10,6 +10,7 @@#include <net/pkt_cls.h> #include <net/dsa.h> #include "mtk_eth_soc.h" +#include "mtk_wed.h" struct mtk_flow_data {struct ethhdr eth;@@ -39,6 +40,7 @@ struct mtk_flow_entry {struct rhash_head node;unsigned long cookie;u16 hash; +s8 wed_index; };static const struct rhashtable_params mtk_flow_ht_params = {@@ -127,35 +129,38 @@ mtk_flow_mangle_ipv4(const struct flow_action_entry *act, }static int -mtk_flow_get_dsa_port (struct net_device **dev) +mtk_flow_set_output_device (struct mtk_eth *eth,struct mtk_foe_entry *foe, +struct net_device *dev,const u8 *dest_mac, +int *wed_index) { -#if IS_ENABLED (CONFIG_NET_DSA ) -struct dsa_port *dp; - - dp =dsa_port_from_netdev (*dev); -if (IS_ERR (dp)) -return -ENODEV ; - -if (dp->cpu_dp->tag_ops->proto !=DSA_TAG_PROTO_MTK ) -return -ENODEV ; +struct net_device_path_ctx ctx = { + .dev = dev, + .daddr = dest_mac, + }; +struct net_device_path path = {}; +int pse_port;Quoted 7 lines
drivers/net/ethernet/mediatek/mtk_ppe_offload.c mtk_flow_mangle_ipv4(const struct flow_action_entry *act, · line 145
Quoted 4 lines
drivers/net/ethernet/mediatek/mtk_ppe_offload.c +3
-1- *dev = dp->cpu_dp->master; +if (!dev->netdev_ops->ndo_fill_forward_path || + dev->netdev_ops->ndo_fill_forward_path (&ctx, &path) <0 ) + path.type =DEV_PATH_ETHERNET ;Maybe expose this through flow offload API so there is no need to call
ndo_fill_forward_pathagain from the driver?
Quoted 2 lines
Can you give me a pseudo-code example? I'm not sure how you want it to be exposed through the flow offload API.
in a few steps:
1) Extend nft_dev_path_info() to deal with DEV_PATH_WDMA, it will just actually fetch a pointer to structure that is allocated by the driver.
- Update the net_device_path structure with this layout:
struct flow_action_wdma {
enum wdma_type type; // MTK_WDMA goes here
union {
struct {
...;
} mtk;
};
} wdma;Add:
struct flow_action_wdma *wdma;
to net_device_path.
2) Pass on this pointer to structure to the nf_flow_route wheelbarrow.
3) Store this information in the struct flow_offload_tuple, in a new struct flow_offload_hw *field to store all hardware offload specific information (not needed by software path). There is already hw_outdev that can be placed there.
4) Add a FLOW_ACTION_WDMA action to the flow offload API to pass on the flow_action_wdma structure.
It's a bit of work the first time to accomodate the requirements of new API, but then all drivers will benefit from this.
It's also a bit of layering, but with more drivers in the tree, this API can be simplified incrementally.
I can take a stab at it and send you a patch.
Quoted 3 lines
To me it seems easier and cleaner to just have a single
ndo_fill_forward_pathcall for the final output device to check the device types that don't have any corresponding sw offload.
It's simpler yes, but this results in two calls for ndo_fill_forward_path, one from the core and another from the driver. I think it's better there's a single point to call to ndo_fill_forward_path for consolidation.
My proposal requires a bit more plumbing, but all drivers will get the information that represents the offload in the same way.
Felix Fietkau
maintainerRe: [RFC 3/7] net: ethernet: mtk_eth_soc: implement flow offloading to WED devices
Quoted 82 lines · Pablo Neira Ayuso
Quoted 1 line · Felix Fietkau
On 2021-07-13 20:56, Pablo Neira Ayuso wrote:
[...]
Quoted 51 lines
Quoted 43 lines
Quoted 43 lines
drivers/net/ethernet/mediatek/mtk_ppe_offload.c +11
-10@@ -10,6 +10,7 @@#include <net/pkt_cls.h> #include <net/dsa.h> #include "mtk_eth_soc.h" +#include "mtk_wed.h" struct mtk_flow_data {struct ethhdr eth;@@ -39,6 +40,7 @@ struct mtk_flow_entry {struct rhash_head node;unsigned long cookie;u16 hash; +s8 wed_index; };static const struct rhashtable_params mtk_flow_ht_params = {@@ -127,35 +129,38 @@ mtk_flow_mangle_ipv4(const struct flow_action_entry *act, }static int -mtk_flow_get_dsa_port (struct net_device **dev) +mtk_flow_set_output_device (struct mtk_eth *eth,struct mtk_foe_entry *foe, +struct net_device *dev,const u8 *dest_mac, +int *wed_index) { -#if IS_ENABLED (CONFIG_NET_DSA ) -struct dsa_port *dp; - - dp =dsa_port_from_netdev (*dev); -if (IS_ERR (dp)) -return -ENODEV ; - -if (dp->cpu_dp->tag_ops->proto !=DSA_TAG_PROTO_MTK ) -return -ENODEV ; +struct net_device_path_ctx ctx = { + .dev = dev, + .daddr = dest_mac, + }; +struct net_device_path path = {}; +int pse_port;Quoted 7 lines
drivers/net/ethernet/mediatek/mtk_ppe_offload.c mtk_flow_mangle_ipv4(const struct flow_action_entry *act, · line 145
Quoted 4 lines
drivers/net/ethernet/mediatek/mtk_ppe_offload.c +3
-1- *dev = dp->cpu_dp->master; +if (!dev->netdev_ops->ndo_fill_forward_path || + dev->netdev_ops->ndo_fill_forward_path (&ctx, &path) <0 ) + path.type =DEV_PATH_ETHERNET ;Maybe expose this through flow offload API so there is no need to call
ndo_fill_forward_pathagain from the driver?Quoted 2 lines
Can you give me a pseudo-code example? I'm not sure how you want it to be exposed through the flow offload API.
in a few steps:
1) Extend
nft_dev_path_info()to deal withDEV_PATH_WDMA, it will just actually fetch a pointer to structure that is allocated by the driver.- Update the
net_device_pathstructure with this layout:struct flow_action_wdma { enum wdma_type type; // MTK_WDMA goes here union { struct { ...; } mtk; }; } wdma;Add:
struct flow_action_wdma *wdma;to
net_device_path.2) Pass on this pointer to structure to the
nf_flow_routewheelbarrow.
Quoted 7 lines
3) Store this information in the struct
flow_offload_tuple, in a new structflow_offload_hw*field to store all hardware offload specific information (not needed by software path). There is alreadyhw_outdevthat can be placed there.4) Add a
FLOW_ACTION_WDMAaction to the flow offload API to pass on theflow_action_wdmastructure.
I think it should probably be called FLOW_ACTION_MTK_WDMA (and be mediatek specific), or we should pick a more generic name for it.
Quoted 7 lines
It's a bit of work the first time to accomodate the requirements of new API, but then all drivers will benefit from this.
It's also a bit of layering, but with more drivers in the tree, this API can be simplified incrementally.
I can take a stab at it and send you a patch.
Thanks. If we do this for WDMA, shouldn't we also do it for DSA to keep things consistent?
- Felix
Felix Fietkau
maintainerRFC 4/7 mt76: dma: add wrapper macro for accessing queue registers
In reply to Felix FietkauPreparation for adding indirection used for Wireless Ethernet Dispatch support
--- drivers/net/wireless/mediatek/mt76/dma.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)
drivers/net/wireless/mediatek/mt76/dma.c +12 -8
@@ -7,6 +7,10 @@#include "mt76.h" #include "dma.h" +#define Q_READ (_dev, _q, _field) readl(&(_q)->regs->_field) +#define Q_WRITE (_dev, _q, _field, _val) writel(_val, &(_q)->regs->_field) + +static struct mt76_txwi_cache *mt76_alloc_txwi (struct mt76_dev *dev) {
@@ -82,9 +86,9 @@ mt76_free_pending_txwi(struct mt76_dev *dev)static void mt76_dma_sync_idx (struct mt76_dev *dev,struct mt76_queue *q) { -writel (q->desc_dma, &q->regs->desc_base); -writel (q->ndesc, &q->regs->ring_size); - q->head =readl (&q->regs->dma_idx); +Q_WRITE (dev, q, desc_base, q->desc_dma); +Q_WRITE (dev, q, ring_size, q->ndesc); + q->head =Q_READ (dev, q, dma_idx); q->tail = q->head; }
@@ -100,8 +104,8 @@ mt76_dma_queue_reset(struct mt76_dev *dev, struct mt76_queue *q)for (i =0 ; i < q->ndesc; i++) q->desc[i].ctrl =cpu_to_le32 (MT_DMA_CTL_DMA_DONE ); -writel (0 , &q->regs->cpu_idx); -writel (0 , &q->regs->dma_idx); +Q_WRITE (dev, q, cpu_idx,0 ); +Q_WRITE (dev, q, dma_idx,0 );mt76_dma_sync_idx (dev, q); }
@@ -224,7 +228,7 @@ static void mt76_dma_kick_queue(struct mt76_dev *dev, struct mt76_queue *q) {wmb (); -writel (q->head, &q->regs->cpu_idx); +Q_WRITE (dev, q, cpu_idx, q->head); } static void
@@ -240,7 +244,7 @@ mt76_dma_tx_cleanup(struct mt76_dev *dev, struct mt76_queue *q, bool flush)if (flush) last =-1 ;else - last =readl (&q->regs->dma_idx); + last =Q_READ (dev, q, dma_idx);while (q->queued >0 && q->tail != last) {mt76_dma_tx_cleanup_idx (dev, q, q->tail, &entry);
@@ -252,7 +256,7 @@ mt76_dma_tx_cleanup(struct mt76_dev *dev, struct mt76_queue *q, bool flush) }if (!flush && q->tail == last) - last =readl (&q->regs->dma_idx); + last =Q_READ (dev, q, dma_idx); }spin_unlock_bh (&q->cleanup_lock);
Signature · 1 line
2.30.1
Felix Fietkau
maintainerRFC 5/7 mt76: make number of tokens configurable dynamically
In reply to Felix FietkauPreparation for adding Wireless Ethernet Dispatch support
--- drivers/net/wireless/mediatek/mt76/mac80211.c | 1 + drivers/net/wireless/mediatek/mt76/mt76.h | 6 +++--- drivers/net/wireless/mediatek/mt76/tx.c | 7 +++---- 3 files changed, 7 insertions(+), 7 deletions(-)
drivers/net/wireless/mediatek/mt76/mac80211.c +1 -0
@@ -459,6 +459,7 @@ mt76_alloc_device(struct device *pdev, unsigned int size,idr_init (&dev->token);INIT_LIST_HEAD (&dev->txwi_cache); + dev->token_size = dev->drv->token_size;for (i =0 ; i <ARRAY_SIZE (dev->q_rx); i++)skb_queue_head_init (&dev->rx_skb[i]);
drivers/net/wireless/mediatek/mt76/mt76.h +3 -3
@@ -680,7 +680,8 @@ struct mt76_dev {spinlock_t token_lock;struct idr token; -int token_count; +u16 token_count; +u16 token_size;wait_queue_head_t tx_wait;struct sk_buff_head status_list;
@@ -1274,8 +1275,7 @@ mt76_token_get(struct mt76_dev *dev, struct mt76_txwi_cache **ptxwi)int token;spin_lock_bh (&dev->token_lock); - token =idr_alloc (&dev->token, *ptxwi,0 , dev->drv->token_size, -GFP_ATOMIC ); + token =idr_alloc (&dev->token, *ptxwi,0 , dev->token_size,GFP_ATOMIC );spin_unlock_bh (&dev->token_lock);return token;
drivers/net/wireless/mediatek/mt76/tx.c +3 -4
@@ -691,12 +691,11 @@ int mt76_token_consume(struct mt76_dev *dev, struct mt76_txwi_cache **ptxwi)spin_lock_bh (&dev->token_lock); - token =idr_alloc (&dev->token, *ptxwi,0 , dev->drv->token_size, -GFP_ATOMIC ); + token =idr_alloc (&dev->token, *ptxwi,0 , dev->token_size,GFP_ATOMIC );if (token >=0 ) dev->token_count++; -if (dev->token_count >= dev->drv->token_size -MT76_TOKEN_FREE_THR ) +if (dev->token_count >= dev->token_size -MT76_TOKEN_FREE_THR )__mt76_set_tx_blocked (dev, true);spin_unlock_bh (&dev->token_lock);
@@ -716,7 +715,7 @@ mt76_token_release(struct mt76_dev *dev, int token, bool *wake)if (txwi) dev->token_count--; -if (dev->token_count < dev->drv->token_size -MT76_TOKEN_FREE_THR && +if (dev->token_count < dev->token_size -MT76_TOKEN_FREE_THR && dev->phy.q_tx[0 ]->blocked) *wake = true;
Signature · 1 line
2.30.1
Felix Fietkau
maintainerRFC 6/7 mt76: mt7915: remove irq parameter from mt7915_mmio_init
In reply to Felix FietkauIt is unused
--- drivers/net/wireless/mediatek/mt76/mt7915/mmio.c | 2 +- drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h | 2 +- drivers/net/wireless/mediatek/mt76/mt7915/pci.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7915/mmio.c +1 -1
@@ -123,7 +123,7 @@ static u32 mt7915_rmw(struct mt76_dev *mdev, u32 offset, u32 mask, u32 val)return dev->bus_ops->rmw (mdev, addr, mask, val); } -int mt7915_mmio_init (struct mt76_dev *mdev,void __iomem *mem_base,int irq) +int mt7915_mmio_init (struct mt76_dev *mdev,void __iomem *mem_base) {struct mt76_bus_ops *bus_ops;struct mt7915_dev *dev;
drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +1 -1
@@ -418,7 +418,7 @@ void mt7915_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,void mt7915_mac_work (struct work_struct *work);void mt7915_mac_reset_work (struct work_struct *work);void mt7915_mac_sta_rc_work (struct work_struct *work); -int mt7915_mmio_init (struct mt76_dev *mdev,void __iomem *mem_base,int irq); +int mt7915_mmio_init (struct mt76_dev *mdev,void __iomem *mem_base); int mt7915_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, enum mt76_txq_id qid, struct mt76_wcid *wcid, struct ieee80211_sta *sta,
drivers/net/wireless/mediatek/mt76/mt7915/pci.c +1 -1
@@ -271,7 +271,7 @@ static int mt7915_pci_probe(struct pci_dev *pdev,if (ret <0 ) goto free; - ret =mt7915_mmio_init (mdev,pcim_iomap_table (pdev)[0 ], pdev->irq); + ret =mt7915_mmio_init (mdev,pcim_iomap_table (pdev)[0 ]);if (ret) goto error;
Signature · 1 line
2.30.1
Felix Fietkau
maintainerRFC 7/7 mt76: mt7915: add Wireless Ethernet Dispatch support
In reply to Felix FietkauThis is used to support hardware flow offloading from Ethernet to WLAN
--- drivers/net/wireless/mediatek/mt76/dma.c | 97 +++++++++++++- drivers/net/wireless/mediatek/mt76/mac80211.c | 4 +- drivers/net/wireless/mediatek/mt76/mmio.c | 9 +- drivers/net/wireless/mediatek/mt76/mt76.h | 30 ++++- .../net/wireless/mediatek/mt76/mt7603/dma.c | 8 +- .../net/wireless/mediatek/mt76/mt7615/dma.c | 6 +- .../net/wireless/mediatek/mt76/mt76x02_mmio.c | 4 +- .../net/wireless/mediatek/mt76/mt7915/dma.c | 38 +++++- .../net/wireless/mediatek/mt76/mt7915/mac.c | 123 +++++++++++++++--- .../net/wireless/mediatek/mt76/mt7915/mac.h | 2 + .../net/wireless/mediatek/mt76/mt7915/main.c | 32 +++++ .../net/wireless/mediatek/mt76/mt7915/mcu.c | 4 + .../wireless/mediatek/mt76/mt7915/mt7915.h | 1 + .../net/wireless/mediatek/mt76/mt7915/pci.c | 96 +++++++++++--- .../net/wireless/mediatek/mt76/mt7915/regs.h | 19 ++- .../net/wireless/mediatek/mt76/mt7921/dma.c | 2 +- drivers/net/wireless/mediatek/mt76/tx.c | 14 +- 17 files changed, 422 insertions(+), 67 deletions(-)
drivers/net/wireless/mediatek/mt76/dma.c +91 -6
@@ -7,9 +7,31 @@#include "mt76.h" #include "dma.h" -#define Q_READ (_dev, _q, _field) readl(&(_q)->regs->_field) -#define Q_WRITE (_dev, _q, _field, _val) writel(_val, &(_q)->regs->_field) - +#define Q_READ (_dev, _q, _field) ({ \ + u32 _offset = offsetof(struct mt76_queue_regs, _field); \ + u32 _val; \ + if (IS_ENABLED(CONFIG_NET_MEDIATEK_SOC_WED) && \ + (_q)->flags & MT_QFLAG_WED) \ + _val = mtk_wed_device_reg_read(&(_dev)->mmio.wed, \ + ((_q)->wed_regs + \ + _offset)); \ + else \ + _val = readl(&(_q)->regs->_field); \ + _val; \ +}) + +#define Q_WRITE (_dev, _q, _field, _val) do { \ + u32 _offset = offsetof(struct mt76_queue_regs, _field); \ + if (IS_ENABLED(CONFIG_NET_MEDIATEK_SOC_WED) && \ + (_q)->flags & MT_QFLAG_WED) \ + mtk_wed_device_reg_write(&(_dev)->mmio.wed, \ + ((_q)->wed_regs + _offset), \ + _val); \ + else \ + writel(_val, &(_q)->regs->_field); \ +} while (0) + +static int mt76_dma_rx_fill (struct mt76_dev *dev,struct mt76_queue *q);static struct mt76_txwi_cache *mt76_alloc_txwi (struct mt76_dev *dev)
@@ -109,12 +131,52 @@ mt76_dma_queue_reset(struct mt76_dev *dev, struct mt76_queue *q)mt76_dma_sync_idx (dev, q); } +static int +mt76_dma_wed_setup (struct mt76_dev *dev,struct mt76_queue *q) +{ +struct mtk_wed_device *wed = &dev->mmio.wed; +int ret, type, ring; +u8 flags = q->flags; + +if (!mtk_wed_device_active (wed)) + q->flags &= ~MT_QFLAG_WED ; + +if (!(q->flags &MT_QFLAG_WED )) +return 0 ; + + type =FIELD_GET (MT_QFLAG_WED_TYPE , q->flags); + ring =FIELD_GET (MT_QFLAG_WED_RING , q->flags); + +switch (type) { +case MT76_WED_Q_TX : + ret =mtk_wed_device_tx_ring_setup (wed, ring, q->regs); +if (!ret) + q->wed_regs = wed->tx_ring[ring].reg_base; +break ; +case MT76_WED_Q_TXFREE : +/* WED txfree queue needs ring to be initialized before setup */ + q->flags =0 ; +mt76_dma_queue_reset (dev, q); +mt76_dma_rx_fill (dev, q); + q->flags = flags; + + ret =mtk_wed_device_txfree_ring_setup (wed, q->regs); +if (!ret) + q->wed_regs = wed->txfree_ring.reg_base; +break ; +default : + ret = -EINVAL ; + } + +return ret; +} +static int mt76_dma_alloc_queue (struct mt76_dev *dev,struct mt76_queue *q,int idx,int n_desc,int bufsize,u32 ring_base) { -int size; +int ret, size;spin_lock_init (&q->lock);spin_lock_init (&q->cleanup_lock);
@@ -134,7 +196,12 @@ mt76_dma_alloc_queue(struct mt76_dev *dev, struct mt76_queue *q,if (!q->entry)return -ENOMEM ; -mt76_dma_queue_reset (dev, q); + ret =mt76_dma_wed_setup (dev, q); +if (ret) +return ret; + +if (q->flags !=MT_WED_Q_TXFREE ) +mt76_dma_queue_reset (dev, q);return 0 ; }
@@ -556,14 +623,29 @@ mt76_add_fragment(struct mt76_dev *dev, struct mt76_queue *q, void *data,static int mt76_dma_rx_process (struct mt76_dev *dev,struct mt76_queue *q,int budget) { -int len, data_len, done =0 ; +int len, data_len, done =0 , dma_idx;struct sk_buff *skb;unsigned char *data; +bool check_ddone = false;bool more; +if (IS_ENABLED (CONFIG_NET_MEDIATEK_SOC_WED ) && + q->flags ==MT_WED_Q_TXFREE ) { + dma_idx =Q_READ (dev, q, dma_idx); + check_ddone = true; + } +while (done < budget) {u32 info; +if (check_ddone) { +if (q->tail == dma_idx) + dma_idx =Q_READ (dev, q, dma_idx); + +if (q->tail == dma_idx) +break ; + } + data =mt76_dma_dequeue (dev, q, false, &len, &info, &more);if (!data)break ;
@@ -699,5 +781,8 @@ void mt76_dma_cleanup(struct mt76_dev *dev) }mt76_free_pending_txwi (dev); + +if (mtk_wed_device_active (&dev->mmio.wed)) +mtk_wed_device_detach (&dev->mmio.wed); }EXPORT_SYMBOL_GPL (mt76_dma_cleanup);
drivers/net/wireless/mediatek/mt76/mac80211.c +3 -1
@@ -1321,7 +1321,7 @@ EXPORT_SYMBOL_GPL(mt76_get_antenna);struct mt76_queue *mt76_init_queue (struct mt76_dev *dev,int qid,int idx,int n_desc, -int ring_base) +int ring_base,u32 flags) {struct mt76_queue *hwq;int err;
@@ -1330,6 +1330,8 @@ mt76_init_queue(struct mt76_dev *dev, int qid, int idx, int n_desc,if (!hwq)return ERR_PTR (-ENOMEM ); + hwq->flags = flags; + err = dev->queue_ops->alloc (dev, hwq, idx, n_desc,0 , ring_base);if (err <0 )return ERR_PTR (err);
drivers/net/wireless/mediatek/mt76/mmio.c +7 -2
@@ -73,8 +73,13 @@ void mt76_set_irq_mask(struct mt76_dev *dev, u32 addr,spin_lock_irqsave (&dev->mmio.irq_lock, flags); dev->mmio.irqmask &= ~clear; dev->mmio.irqmask |= set; -if (addr) -mt76_mmio_wr (dev, addr, dev->mmio.irqmask); +if (addr) { +if (mtk_wed_device_active (&dev->mmio.wed)) +mtk_wed_device_irq_set_mask (&dev->mmio.wed, + dev->mmio.irqmask); +else +mt76_mmio_wr (dev, addr, dev->mmio.irqmask); + }spin_unlock_irqrestore (&dev->mmio.irq_lock, flags); }EXPORT_SYMBOL_GPL (mt76_set_irq_mask);
drivers/net/wireless/mediatek/mt76/mt76.h +26 -4
@@ -13,6 +13,7 @@#include <linux/leds.h> #include <linux/usb.h> #include <linux/average.h> +#include <linux/soc/mediatek/mtk_wed.h> #include <net/mac80211.h> #include "util.h" #include "testmode.h"
@@ -26,6 +27,16 @@#define MT76_TOKEN_FREE_THR 64 +#define MT_QFLAG_WED_RING GENMASK(1, 0) +#define MT_QFLAG_WED_TYPE GENMASK(3, 2) +#define MT_QFLAG_WED BIT(4) + +#define __MT_WED_Q (_type, _n) (MT_QFLAG_WED | \ + FIELD_PREP(MT_QFLAG_WED_TYPE, _type) | \ + FIELD_PREP(MT_QFLAG_WED_RING, _n)) +#define MT_WED_Q_TX (_n) __MT_WED_Q(MT76_WED_Q_TX, _n) +#define MT_WED_Q_TXFREE __MT_WED_Q(MT76_WED_Q_TXFREE, 0) +struct mt76_dev ;struct mt76_phy ;struct mt76_wcid ;
@@ -41,6 +52,11 @@ enum mt76_bus_type { MT76_BUS_SDIO, }; +enum mt76_wed_type { +MT76_WED_Q_TX , +MT76_WED_Q_TXFREE , +}; +struct mt76_bus_ops {u32 (*rr)(struct mt76_dev *dev,u32 offset);void (*wr)(struct mt76_dev *dev,u32 offset,u32 val);
@@ -161,6 +177,9 @@ struct mt76_queue {u8 buf_offset;u8 hw_idx;u8 qid; +u8 flags; + +u32 wed_regs;dma_addr_t desc_dma;struct sk_buff *rx_head;
@@ -511,6 +530,8 @@ struct mt76_mmio {void __iomem *regs;spinlock_t irq_lock;u32 irqmask; + +struct mtk_wed_device wed; };struct mt76_rx_status {
@@ -680,6 +701,7 @@ struct mt76_dev {spinlock_t token_lock;struct idr token; +u16 wed_token_count;u16 token_count;u16 token_size;
@@ -881,13 +903,13 @@ int mt76_get_of_eeprom(struct mt76_dev *dev, void *data, int offset, int len);struct mt76_queue *mt76_init_queue (struct mt76_dev *dev,int qid,int idx,int n_desc, -int ring_base); +int ring_base,u32 flags);static inline int mt76_init_tx_queue (struct mt76_phy *phy,int qid,int idx, -int n_desc,int ring_base) +int n_desc,int ring_base,u32 flags) {struct mt76_queue *q; - q =mt76_init_queue (phy->dev, qid, idx, n_desc, ring_base); + q =mt76_init_queue (phy->dev, qid, idx, n_desc, ring_base, flags);if (IS_ERR (q))return PTR_ERR (q);
@@ -902,7 +924,7 @@ static inline int mt76_init_mcu_queue(struct mt76_dev *dev, int qid, int idx, {struct mt76_queue *q; - q =mt76_init_queue (dev, qid, idx, n_desc, ring_base); + q =mt76_init_queue (dev, qid, idx, n_desc, ring_base,0 );if (IS_ERR (q))return PTR_ERR (q);
drivers/net/wireless/mediatek/mt76/mt7603/dma.c +4 -4
@@ -173,13 +173,13 @@ int mt7603_dma_init(struct mt7603_dev *dev)for (i =0 ; i <ARRAY_SIZE (wmm_queue_map); i++) { ret =mt76_init_tx_queue (&dev->mphy, i, wmm_queue_map[i], -MT7603_TX_RING_SIZE ,MT_TX_RING_BASE ); +MT7603_TX_RING_SIZE ,MT_TX_RING_BASE ,0 );if (ret)return ret; } ret =mt76_init_tx_queue (&dev->mphy,MT_TXQ_PSD ,MT_TX_HW_QUEUE_MGMT , -MT7603_PSD_RING_SIZE ,MT_TX_RING_BASE ); +MT7603_PSD_RING_SIZE ,MT_TX_RING_BASE ,0 );if (ret)return ret;
@@ -189,12 +189,12 @@ int mt7603_dma_init(struct mt7603_dev *dev)return ret; ret =mt76_init_tx_queue (&dev->mphy,MT_TXQ_BEACON ,MT_TX_HW_QUEUE_BCN , -MT_MCU_RING_SIZE ,MT_TX_RING_BASE ); +MT_MCU_RING_SIZE ,MT_TX_RING_BASE ,0 );if (ret)return ret; ret =mt76_init_tx_queue (&dev->mphy,MT_TXQ_CAB ,MT_TX_HW_QUEUE_BMC , -MT_MCU_RING_SIZE ,MT_TX_RING_BASE ); +MT_MCU_RING_SIZE ,MT_TX_RING_BASE ,0 );if (ret)return ret;
drivers/net/wireless/mediatek/mt76/mt7615/dma.c +3 -3
@@ -26,14 +26,14 @@ mt7622_init_tx_queues_multi(struct mt7615_dev *dev)for (i =0 ; i <ARRAY_SIZE (wmm_queue_map); i++) { ret =mt76_init_tx_queue (&dev->mphy, i, wmm_queue_map[i],MT7615_TX_RING_SIZE /2 , -MT_TX_RING_BASE ); +MT_TX_RING_BASE ,0 );if (ret)return ret; } ret =mt76_init_tx_queue (&dev->mphy,MT_TXQ_PSD ,MT7622_TXQ_MGMT ,MT7615_TX_MGMT_RING_SIZE , -MT_TX_RING_BASE ); +MT_TX_RING_BASE ,0 );if (ret)return ret;
@@ -55,7 +55,7 @@ mt7615_init_tx_queues(struct mt7615_dev *dev)return mt7622_init_tx_queues_multi (dev); ret =mt76_init_tx_queue (&dev->mphy,0 ,0 ,MT7615_TX_RING_SIZE , -MT_TX_RING_BASE ); +MT_TX_RING_BASE ,0 );if (ret)return ret;
drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c +2 -2
@@ -191,13 +191,13 @@ int mt76x02_dma_init(struct mt76x02_dev *dev)for (i =0 ; i <IEEE80211_NUM_ACS ; i++) { ret =mt76_init_tx_queue (&dev->mphy, i,mt76_ac_to_hwq (i), MT76x02_TX_RING_SIZE, -MT_TX_RING_BASE ); +MT_TX_RING_BASE ,0 );if (ret)return ret; } ret =mt76_init_tx_queue (&dev->mphy,MT_TXQ_PSD ,MT_TX_HW_QUEUE_MGMT , - MT76x02_PSD_RING_SIZE,MT_TX_RING_BASE ); + MT76x02_PSD_RING_SIZE,MT_TX_RING_BASE ,0 );if (ret)return ret;
drivers/net/wireless/mediatek/mt76/mt7915/dma.c +34 -4
@@ -7,9 +7,16 @@int mt7915_init_tx_queues (struct mt7915_phy *phy,int idx,int n_desc) { +u32 base =MT_TX_RING_BASE ;int i, err; - err =mt76_init_tx_queue (phy->mt76,0 , idx, n_desc,MT_TX_RING_BASE ); +if (mtk_wed_device_active (&phy->dev->mt76.mmio.wed)) { + base =MT_WED_TX_RING_BASE ; + idx -=MT7915_TXQ_BAND0 ; + } + + err =mt76_init_tx_queue (phy->mt76,0 , idx, n_desc, base, +MT_WED_Q_TX (idx));if (err <0 )return err;
@@ -79,6 +86,9 @@ void mt7915_dma_prefetch(struct mt7915_dev *dev)int mt7915_dma_init (struct mt7915_dev *dev) { +u32 irq_mask =MT_INT_RX_DONE_ALL |MT_INT_TX_DONE_MCU | +MT_INT_MCU_CMD ; +u32 wa_rx_base =MT_RX_EVENT_RING_BASE ;u32 hif1_ofs =0 ;int ret;
@@ -112,6 +122,15 @@ int mt7915_dma_init(struct mt7915_dev *dev)mt76_wr (dev,MT_WFDMA1_PRI_DLY_INT_CFG0 + hif1_ofs,0 ); } +if (mtk_wed_device_active (&dev->mt76.mmio.wed)) { +mt76_set (dev,MT_WFDMA_HOST_CONFIG ,MT_WFDMA_HOST_CONFIG_WED ); + +mt76_wr (dev,MT_WFDMA_WED_RING_CONTROL , +FIELD_PREP (MT_WFDMA_WED_RING_CONTROL_TX0 ,18 ) | +FIELD_PREP (MT_WFDMA_WED_RING_CONTROL_TX1 ,19 ) | +FIELD_PREP (MT_WFDMA_WED_RING_CONTROL_RX1 ,1 )); + } +/* configure perfetch settings */ mt7915_dma_prefetch (dev);
@@ -147,9 +166,13 @@ int mt7915_dma_init(struct mt7915_dev *dev)return ret;/* event from WA */ +if (mtk_wed_device_active (&dev->mt76.mmio.wed)) { + wa_rx_base =MT_WED_RX_RING_BASE ; + dev->mt76.q_rx[MT_RXQ_MCU_WA ].flags =MT_WED_Q_TXFREE ; + } ret =mt76_queue_alloc (dev, &dev->mt76.q_rx[MT_RXQ_MCU_WA ],MT7915_RXQ_MCU_WA ,MT7915_RX_MCU_RING_SIZE , -MT_RX_BUF_SIZE ,MT_RX_EVENT_RING_BASE ); +MT_RX_BUF_SIZE , wa_rx_base);if (ret)return ret;
@@ -227,9 +250,16 @@ int mt7915_dma_init(struct mt7915_dev *dev) MT_WFDMA_HOST_CONFIG_PDMA_BAND); } +if (mtk_wed_device_active (&dev->mt76.mmio.wed)) { +u32 wed_irq_mask = irq_mask; + + wed_irq_mask |=MT_INT_TX_DONE_BAND0 |MT_INT_TX_DONE_BAND1 ; +mt76_wr (dev,MT_INT_WED_MASK_CSR , wed_irq_mask); +mtk_wed_device_start (&dev->mt76.mmio.wed, wed_irq_mask); + } +/* enable interrupts for TX/RX rings */ -mt7915_irq_enable (dev,MT_INT_RX_DONE_ALL |MT_INT_TX_DONE_MCU | -MT_INT_MCU_CMD ); +mt7915_irq_enable (dev, irq_mask);return 0 ; }
drivers/net/wireless/mediatek/mt76/mt7915/mac.c +104 -19
177 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt7915/mac.h +2 -0
@@ -23,6 +23,7 @@ enum rx_pkt_type {PKT_TYPE_RETRIEVE ,PKT_TYPE_TXRX_NOTIFY ,PKT_TYPE_RX_EVENT , + PKT_TYPE_TXRX_NOTIFY_V0 = 0x18, };/* RXD DW1 */
@@ -295,6 +296,7 @@ struct mt7915_tx_free { } __packed__aligned(4) ;#define MT_TX_FREE_MSDU_CNT GENMASK(9, 0) +#define MT_TX_FREE_MSDU_CNT_V0 GENMASK(6, 0)#define MT_TX_FREE_WLAN_ID GENMASK(23, 14)#define MT_TX_FREE_LATENCY GENMASK(12, 0)/* 0: success, others: dropped */
drivers/net/wireless/mediatek/mt76/mt7915/main.c +32 -0
@@ -1032,6 +1032,37 @@ static void mt7915_sta_set_decap_offload(struct ieee80211_hw *hw,mt7915_mcu_sta_update_hdr_trans (dev, vif, sta); } +static int +mt7915_net_fill_forward_path (struct ieee80211_hw *hw, +struct ieee80211_vif *vif, +struct ieee80211_sta *sta, +struct net_device_path_ctx *ctx, +struct net_device_path *path) +{ +struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; +struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; +struct mt7915_dev *dev =mt7915_hw_dev (hw); +struct mt7915_phy *phy =mt7915_hw_phy (hw); +struct mtk_wed_device *wed = &dev->mt76.mmio.wed; + +if (!mtk_wed_device_active (wed)) +return -ENODEV ; + +if (msta->wcid.idx >0xff ) +return -EIO ; + + path->type =DEV_PATH_MTK_WDMA ; + path->dev = ctx->dev; + path->mtk_wdma.wdma_idx = wed->wdma_idx; + path->mtk_wdma.bss = mvif->omac_idx; + path->mtk_wdma.wcid = msta->wcid.idx; + path->mtk_wdma.queue = phy != &dev->phy; + + ctx->dev =NULL ; + +return 0 ; +} +const struct ieee80211_ops mt7915_ops = { .tx = mt7915_tx, .start = mt7915_start,
@@ -1072,4 +1103,5 @@ const struct ieee80211_ops mt7915_ops = {#ifdef CONFIG_MAC80211_DEBUGFS .sta_add_debugfs = mt7915_sta_add_debugfs, #endif + .net_fill_forward_path = mt7915_net_fill_forward_path, };
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +4 -0
@@ -3011,6 +3011,10 @@ int mt7915_mcu_init(struct mt7915_dev *dev)return ret;set_bit (MT76_STATE_MCU_RUNNING , &dev->mphy.state); + +if (mtk_wed_device_active (&dev->mt76.mmio.wed)) +mt7915_mcu_wa_cmd (dev,MCU_WA_PARAM_CMD (CAPABILITY ),0 ,0 ,0 ); +mt7915_mcu_fw_log_2_host (dev,0 );mt7915_mcu_set_mwds (dev,1 );mt7915_mcu_wa_cmd (dev,MCU_WA_PARAM_CMD (SET ),MCU_WA_PARAM_RED ,0 ,0 );
drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +1 -0
@@ -294,6 +294,7 @@ extern const struct ieee80211_ops mt7915_ops;extern const struct mt76_testmode_ops mt7915_testmode_ops;u32 mt7915_reg_map (struct mt7915_dev *dev,u32 addr); +u32 mt7915_wed_init_buf (void *ptr,dma_addr_t phys,int token_id);int mt7915_register_device (struct mt7915_dev *dev);void mt7915_unregister_device (struct mt7915_dev *dev);
drivers/net/wireless/mediatek/mt76/mt7915/pci.c +79 -17
145 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt7915/regs.h +16 -3
@@ -334,7 +334,9 @@/* WFDMA CSR */ #define MT_WFDMA_EXT_CSR_BASE 0xd7000 +#define MT_WFDMA_EXT_CSR_PHYS_BASE 0x18027000#define MT_WFDMA_EXT_CSR (ofs) (MT_WFDMA_EXT_CSR_BASE + (ofs)) +#define MT_WFDMA_EXT_CSR_PHYS (ofs) (MT_WFDMA_EXT_CSR_PHYS_BASE + (ofs))#define MT_INT_SOURCE_CSR MT_WFDMA_EXT_CSR(0x10)#define MT_INT_MASK_CSR MT_WFDMA_EXT_CSR(0x14)
@@ -359,19 +361,30 @@ MT_INT_TX_DONE_MCU_WM | \ MT_INT_TX_DONE_FWDL) -#define MT_WFDMA_HOST_CONFIG MT_WFDMA_EXT_CSR(0x30) +#define MT_WFDMA_HOST_CONFIG MT_WFDMA_EXT_CSR_PHYS(0x30)#define MT_WFDMA_HOST_CONFIG_PDMA_BAND BIT(0) +#define MT_WFDMA_HOST_CONFIG_WED BIT(1) -#define MT_WFDMA_EXT_CSR_HIF_MISC MT_WFDMA_EXT_CSR(0x44) +#define MT_WFDMA_WED_RING_CONTROL MT_WFDMA_EXT_CSR_PHYS(0x34) +#define MT_WFDMA_WED_RING_CONTROL_TX0 GENMASK(4, 0) +#define MT_WFDMA_WED_RING_CONTROL_TX1 GENMASK(12, 8) +#define MT_WFDMA_WED_RING_CONTROL_RX1 GENMASK(20, 16) + +#define MT_WFDMA_EXT_CSR_HIF_MISC MT_WFDMA_EXT_CSR_PHYS(0x44)#define MT_WFDMA_EXT_CSR_HIF_MISC_BUSY BIT(0)#define MT_INT1_SOURCE_CSR MT_WFDMA_EXT_CSR(0x88)#define MT_INT1_MASK_CSR MT_WFDMA_EXT_CSR(0x8c) -#define MT_PCIE_RECOG_ID MT_WFDMA_EXT_CSR(0x90) +#define MT_PCIE_RECOG_ID MT_WFDMA_EXT_CSR_PHYS(0x90)#define MT_PCIE_RECOG_ID_MASK GENMASK(30, 0)#define MT_PCIE_RECOG_ID_SEM BIT(31) +#define MT_INT_WED_MASK_CSR MT_WFDMA_EXT_CSR(0x204) + +#define MT_WED_TX_RING_BASE MT_WFDMA_EXT_CSR(0x300) +#define MT_WED_RX_RING_BASE MT_WFDMA_EXT_CSR(0x400) +/* WFDMA0 PCIE1 */ #define MT_WFDMA0_PCIE1_BASE 0xd8000#define MT_WFDMA0_PCIE1 (ofs) (MT_WFDMA0_PCIE1_BASE + (ofs))
drivers/net/wireless/mediatek/mt76/mt7921/dma.c +1 -1
@@ -9,7 +9,7 @@ int mt7921_init_tx_queues(struct mt7921_phy *phy, int idx, int n_desc) {int i, err; - err =mt76_init_tx_queue (phy->mt76,0 , idx, n_desc,MT_TX_RING_BASE ); + err =mt76_init_tx_queue (phy->mt76,0 , idx, n_desc,MT_TX_RING_BASE ,0 );if (err <0 )return err;
drivers/net/wireless/mediatek/mt76/tx.c +13 -1
@@ -687,6 +687,7 @@ EXPORT_SYMBOL_GPL(__mt76_set_tx_blocked);int mt76_token_consume (struct mt76_dev *dev,struct mt76_txwi_cache **ptxwi) { +struct mtk_wed_device *wed = &dev->mmio.wed;int token;spin_lock_bh (&dev->token_lock);
@@ -695,6 +696,10 @@ int mt76_token_consume(struct mt76_dev *dev, struct mt76_txwi_cache **ptxwi)if (token >=0 ) dev->token_count++; +if (mtk_wed_device_active (wed) && + token >= wed->wlan.token_start) + dev->wed_token_count++; +if (dev->token_count >= dev->token_size -MT76_TOKEN_FREE_THR )__mt76_set_tx_blocked (dev, true);
@@ -707,14 +712,21 @@ EXPORT_SYMBOL_GPL(mt76_token_consume);struct mt76_txwi_cache *mt76_token_release (struct mt76_dev *dev,int token,bool *wake) { +struct mtk_wed_device *wed = &dev->mmio.wed;struct mt76_txwi_cache *txwi;spin_lock_bh (&dev->token_lock); txwi =idr_remove (&dev->token, token); -if (txwi) +if (txwi) { dev->token_count--; +if (mtk_wed_device_active (wed) && + token >= wed->wlan.token_start && + --dev->wed_token_count ==0 ) +wake_up (&dev->tx_wait); + } +if (dev->token_count < dev->token_size -MT76_TOKEN_FREE_THR && dev->phy.q_tx[0 ]->blocked) *wake = true;
Signature · 1 line
2.30.1
kernel test robot
build botRe: [RFC 7/7] mt76: mt7915: add Wireless Ethernet Dispatch support
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch]
Hi Felix,
[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on wireless-drivers-next/master]
[also build test WARNING on mac80211-next/master linus/master v5.14-rc1 next-20210713] [cannot apply to wireless-drivers/master mac80211/master]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Felix-Fietkau/Ethernet-WLAN-hardware-flow-offloading-support-on-MT7622/20210714-001409 base: https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git master config: xtensa-allyesconfig (attached as .config) compiler: xtensa-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/16ac1606c5b18e61fb25775d621cd218f17bb913
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Felix-Fietkau/Ethernet-WLAN-hardware-flow-offloading-support-on-MT7622/20210714-001409 git checkout 16ac1606c5b18e61fb25775d621cd218f17bb913
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=xtensa
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
drivers/net/wireless/mediatek/mt76/dma.c: In function 'mt76_dma_sync_idx':
drivers/net/wireless/mediatek/mt76/dma.c:24:6: warning: unused variable '_offset' [-Wunused-variable]
24 | u32 _offset = offsetof(struct mt76_queue_regs, _field); \
| ^~~~~~~
drivers/net/wireless/mediatek/mt76/dma.c:111:2: note: in expansion of macro 'Q_WRITE'
111 | Q_WRITE(dev, q, desc_base, q->desc_dma);
| ^~~~~~~
drivers/net/wireless/mediatek/mt76/dma.c:24:6: warning: unused variable '_offset' [-Wunused-variable]
24 | u32 _offset = offsetof(struct mt76_queue_regs, _field); \
| ^~~~~~~
drivers/net/wireless/mediatek/mt76/dma.c:112:2: note: in expansion of macro 'Q_WRITE'
112 | Q_WRITE(dev, q, ring_size, q->ndesc);
| ^~~~~~~
drivers/net/wireless/mediatek/mt76/dma.c:11:6: warning: unused variable '_offset' [-Wunused-variable]
11 | u32 _offset = offsetof(struct mt76_queue_regs, _field); \
| ^~~~~~~
drivers/net/wireless/mediatek/mt76/dma.c:113:12: note: in expansion of macro 'Q_READ'
113 | q->head = Q_READ(dev, q, dma_idx);
| ^~~~~~
drivers/net/wireless/mediatek/mt76/dma.c: In function 'mt76_dma_queue_reset':
drivers/net/wireless/mediatek/mt76/dma.c:24:6: warning: unused variable '_offset' [-Wunused-variable]
24 | u32 _offset = offsetof(struct mt76_queue_regs, _field); \
| ^~~~~~~
drivers/net/wireless/mediatek/mt76/dma.c:129:2: note: in expansion of macro 'Q_WRITE'
129 | Q_WRITE(dev, q, cpu_idx, 0);
| ^~~~~~~
drivers/net/wireless/mediatek/mt76/dma.c:24:6: warning: unused variable '_offset' [-Wunused-variable]
24 | u32 _offset = offsetof(struct mt76_queue_regs, _field); \
| ^~~~~~~
drivers/net/wireless/mediatek/mt76/dma.c:130:2: note: in expansion of macro 'Q_WRITE'
130 | Q_WRITE(dev, q, dma_idx, 0);
| ^~~~~~~
drivers/net/wireless/mediatek/mt76/dma.c: In function 'mt76_dma_wed_setup':
drivers/net/wireless/mediatek/mt76/dma.c:154:21: error: 'struct mtk_wed_device' has no member named 'tx_ring'
154 | q->wed_regs = wed->tx_ring[ring].reg_base;
| ^~
drivers/net/wireless/mediatek/mt76/dma.c:163:54: error: macro "mtk_wed_device_txfree_ring_setup" requires 3 arguments, but only 2 given
163 | ret = mtk_wed_device_txfree_ring_setup(wed, q->regs);
| ^
In file included from drivers/net/wireless/mediatek/mt76/mt76.h:16,
from drivers/net/wireless/mediatek/mt76/dma.c:7:
include/linux/soc/mediatek/mtk_wed.h:120: note: macro "mtk_wed_device_txfree_ring_setup" defined here
120 | #define mtk_wed_device_txfree_ring_setup(_dev, _ring, _regs) -ENODEV
|
drivers/net/wireless/mediatek/mt76/dma.c:163:9: error: 'mtk_wed_device_txfree_ring_setup' undeclared (first use in this function)
163 | ret = mtk_wed_device_txfree_ring_setup(wed, q->regs);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/wireless/mediatek/mt76/dma.c:163:9: note: each undeclared identifier is reported only once for each function it appears in
drivers/net/wireless/mediatek/mt76/dma.c:165:21: error: 'struct mtk_wed_device' has no member named 'txfree_ring'
165 | q->wed_regs = wed->txfree_ring.reg_base;
| ^~
>> drivers/net/wireless/mediatek/mt76/dma.c:138:17: warning: variable 'ring' set but not used [-Wunused-but-set-variable]
138 | int ret, type, ring;
| ^~~~
drivers/net/wireless/mediatek/mt76/dma.c: In function 'mt76_dma_kick_queue':
drivers/net/wireless/mediatek/mt76/dma.c:24:6: warning: unused variable '_offset' [-Wunused-variable]
24 | u32 _offset = offsetof(struct mt76_queue_regs, _field); \
| ^~~~~~~
drivers/net/wireless/mediatek/mt76/dma.c:298:2: note: in expansion of macro 'Q_WRITE'
298 | Q_WRITE(dev, q, cpu_idx, q->head);
| ^~~~~~~
drivers/net/wireless/mediatek/mt76/dma.c: In function 'mt76_dma_tx_cleanup':
drivers/net/wireless/mediatek/mt76/dma.c:11:6: warning: unused variable '_offset' [-Wunused-variable]
11 | u32 _offset = offsetof(struct mt76_queue_regs, _field); \
| ^~~~~~~
drivers/net/wireless/mediatek/mt76/dma.c:314:10: note: in expansion of macro 'Q_READ'
314 | last = Q_READ(dev, q, dma_idx);
| ^~~~~~
drivers/net/wireless/mediatek/mt76/dma.c:11:6: warning: unused variable '_offset' [-Wunused-variable]
11 | u32 _offset = offsetof(struct mt76_queue_regs, _field); \
| ^~~~~~~
drivers/net/wireless/mediatek/mt76/dma.c:326:11: note: in expansion of macro 'Q_READ'
326 | last = Q_READ(dev, q, dma_idx);
| ^~~~~~
drivers/net/wireless/mediatek/mt76/dma.c: In function 'mt76_dma_rx_process':
drivers/net/wireless/mediatek/mt76/dma.c:11:6: warning: unused variable '_offset' [-Wunused-variable]
11 | u32 _offset = offsetof(struct mt76_queue_regs, _field); \
| ^~~~~~~
drivers/net/wireless/mediatek/mt76/dma.c:634:13: note: in expansion of macro 'Q_READ'
634 | dma_idx = Q_READ(dev, q, dma_idx);
| ^~~~~~
drivers/net/wireless/mediatek/mt76/dma.c:11:6: warning: unused variable '_offset' [-Wunused-variable]
11 | u32 _offset = offsetof(struct mt76_queue_regs, _field); \
| ^~~~~~~
drivers/net/wireless/mediatek/mt76/dma.c:643:15: note: in expansion of macro 'Q_READ'
643 | dma_idx = Q_READ(dev, q, dma_idx);
| ^~~~~~vim +/ring +138 drivers/net/wireless/mediatek/mt76/dma.c
133
134 static int
135 mt76_dma_wed_setup(struct mt76_dev *dev, struct mt76_queue *q)
136 {
137 struct mtk_wed_device *wed = &dev->mmio.wed;
> 138 int ret, type, ring;
139 u8 flags = q->flags;
140
141 if (!mtk_wed_device_active(wed))
142 q->flags &= ~MT_QFLAG_WED;
143
144 if (!(q->flags & MT_QFLAG_WED))
145 return 0;
146
147 type = FIELD_GET(MT_QFLAG_WED_TYPE, q->flags);
148 ring = FIELD_GET(MT_QFLAG_WED_RING, q->flags);
149
150 switch (type) {
151 case MT76_WED_Q_TX:
152 ret = mtk_wed_device_tx_ring_setup(wed, ring, q->regs);
153 if (!ret)
154 q->wed_regs = wed->tx_ring[ring].reg_base;
155 break;
156 case MT76_WED_Q_TXFREE:
157 /* WED txfree queue needs ring to be initialized before setup */
158 q->flags = 0;
159 mt76_dma_queue_reset(dev, q);
160 mt76_dma_rx_fill(dev, q);
161 q->flags = flags;
162
163 ret = mtk_wed_device_txfree_ring_setup(wed, q->regs);
164 if (!ret)
165 q->wed_regs = wed->txfree_ring.reg_base;
166 break;
167 default:
168 ret = -EINVAL;
169 }
170
171 return ret;
172 }
173
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
kernel test robot
build botRe: [RFC 7/7] mt76: mt7915: add Wireless Ethernet Dispatch support
In reply to Felix Fietkau[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch]
Hi Felix,
[FYI, it's a private test report for your RFC patch.]
[auto build test ERROR on wireless-drivers-next/master]
[also build test ERROR on mac80211-next/master linus/master v5.14-rc1 next-20210713] [cannot apply to wireless-drivers/master mac80211/master]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Felix-Fietkau/Ethernet-WLAN-hardware-flow-offloading-support-on-MT7622/20210714-001409 base: https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git master config: powerpc-randconfig-r003-20210713 (attached as .config) compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 8d69635ed9ecf36fd0ca85906bfde17949671cbe)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install powerpc cross compiling tool for clang build
# apt-get install binutils-powerpc-linux-gnu
# https://github.com/0day-ci/linux/commit/16ac1606c5b18e61fb25775d621cd218f17bb913
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Felix-Fietkau/Ethernet-WLAN-hardware-flow-offloading-support-on-MT7622/20210714-001409 git checkout 16ac1606c5b18e61fb25775d621cd218f17bb913
# save the attached .config to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross O=build_dir ARCH=powerpc SHELL=/bin/bash drivers/net/wireless/mediatek/mt76/
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
In file included from drivers/net/wireless/mediatek/mt76/dma.c:6:
In file included from include/linux/dma-mapping.h:7:
In file included from include/linux/device.h:15:
In file included from include/linux/dev_printk.h:16:
In file included from include/linux/ratelimit.h:6:
In file included from include/linux/sched.h:14:
In file included from include/linux/pid.h:5:
In file included from include/linux/rculist.h:10:
In file included from include/linux/list.h:9:
In file included from include/linux/kernel.h:12:
In file included from include/linux/bitops.h:32:
In file included from arch/powerpc/include/asm/bitops.h:62:
arch/powerpc/include/asm/barrier.h:49:9: warning: '__lwsync' macro redefined [-Wmacro-redefined]
#define __lwsync() __asm__ __volatile__ (stringify_in_c(LWSYNC) : : :"memory")
^
<built-in>:309:9: note: previous definition is here
#define __lwsync __builtin_ppc_lwsync
^
drivers/net/wireless/mediatek/mt76/dma.c:111:2: warning: unused variable '_offset' [-Wunused-variable]
Q_WRITE(dev, q, desc_base, q->desc_dma);
^
drivers/net/wireless/mediatek/mt76/dma.c:24:6: note: expanded from macro 'Q_WRITE'
u32 _offset = offsetof(struct mt76_queue_regs, _field); \
^
drivers/net/wireless/mediatek/mt76/dma.c:112:2: warning: unused variable '_offset' [-Wunused-variable]
Q_WRITE(dev, q, ring_size, q->ndesc);
^
drivers/net/wireless/mediatek/mt76/dma.c:24:6: note: expanded from macro 'Q_WRITE'
u32 _offset = offsetof(struct mt76_queue_regs, _field); \
^
drivers/net/wireless/mediatek/mt76/dma.c:113:12: warning: unused variable '_offset' [-Wunused-variable]
q->head = Q_READ(dev, q, dma_idx);
^
drivers/net/wireless/mediatek/mt76/dma.c:11:6: note: expanded from macro 'Q_READ'
u32 _offset = offsetof(struct mt76_queue_regs, _field); \
^
drivers/net/wireless/mediatek/mt76/dma.c:129:2: warning: unused variable '_offset' [-Wunused-variable]
Q_WRITE(dev, q, cpu_idx, 0);
^
drivers/net/wireless/mediatek/mt76/dma.c:24:6: note: expanded from macro 'Q_WRITE'
u32 _offset = offsetof(struct mt76_queue_regs, _field); \
^
drivers/net/wireless/mediatek/mt76/dma.c:130:2: warning: unused variable '_offset' [-Wunused-variable]
Q_WRITE(dev, q, dma_idx, 0);
^
drivers/net/wireless/mediatek/mt76/dma.c:24:6: note: expanded from macro 'Q_WRITE'
u32 _offset = offsetof(struct mt76_queue_regs, _field); \
^
>> drivers/net/wireless/mediatek/mt76/dma.c:154:23: error: no member named 'tx_ring' in 'struct mtk_wed_device'
q->wed_regs = wed->tx_ring[ring].reg_base;
~~~ ^
>> drivers/net/wireless/mediatek/mt76/dma.c:163:54: error: too few arguments provided to function-like macro invocation
ret = mtk_wed_device_txfree_ring_setup(wed, q->regs);
^
include/linux/soc/mediatek/mtk_wed.h:120:9: note: macro 'mtk_wed_device_txfree_ring_setup' defined here
#define mtk_wed_device_txfree_ring_setup(_dev, _ring, _regs) -ENODEV
^
>> drivers/net/wireless/mediatek/mt76/dma.c:163:9: error: use of undeclared identifier 'mtk_wed_device_txfree_ring_setup'
ret = mtk_wed_device_txfree_ring_setup(wed, q->regs);
^
>> drivers/net/wireless/mediatek/mt76/dma.c:165:23: error: no member named 'txfree_ring' in 'struct mtk_wed_device'
q->wed_regs = wed->txfree_ring.reg_base;
~~~ ^
drivers/net/wireless/mediatek/mt76/dma.c:298:2: warning: unused variable '_offset' [-Wunused-variable]
Q_WRITE(dev, q, cpu_idx, q->head);
^
drivers/net/wireless/mediatek/mt76/dma.c:24:6: note: expanded from macro 'Q_WRITE'
u32 _offset = offsetof(struct mt76_queue_regs, _field); \
^
drivers/net/wireless/mediatek/mt76/dma.c:314:10: warning: unused variable '_offset' [-Wunused-variable]
last = Q_READ(dev, q, dma_idx);
^
drivers/net/wireless/mediatek/mt76/dma.c:11:6: note: expanded from macro 'Q_READ'
u32 _offset = offsetof(struct mt76_queue_regs, _field); \
^
drivers/net/wireless/mediatek/mt76/dma.c:326:11: warning: unused variable '_offset' [-Wunused-variable]
last = Q_READ(dev, q, dma_idx);
^
drivers/net/wireless/mediatek/mt76/dma.c:11:6: note: expanded from macro 'Q_READ'
u32 _offset = offsetof(struct mt76_queue_regs, _field); \
^
drivers/net/wireless/mediatek/mt76/dma.c:634:13: warning: unused variable '_offset' [-Wunused-variable]
dma_idx = Q_READ(dev, q, dma_idx);
^
drivers/net/wireless/mediatek/mt76/dma.c:11:6: note: expanded from macro 'Q_READ'
u32 _offset = offsetof(struct mt76_queue_regs, _field); \
^
drivers/net/wireless/mediatek/mt76/dma.c:643:15: warning: unused variable '_offset' [-Wunused-variable]
dma_idx = Q_READ(dev, q, dma_idx);
^
drivers/net/wireless/mediatek/mt76/dma.c:11:6: note: expanded from macro 'Q_READ'
u32 _offset = offsetof(struct mt76_queue_regs, _field); \
^ 11 warnings and 4 errors generated.
--
In file included from drivers/net/wireless/mediatek/mt76/tx.c:6:
In file included from drivers/net/wireless/mediatek/mt76/mt76.h:9:
In file included from include/linux/kernel.h:12:
In file included from include/linux/bitops.h:32:
In file included from arch/powerpc/include/asm/bitops.h:62:
arch/powerpc/include/asm/barrier.h:49:9: warning: '__lwsync' macro redefined [-Wmacro-redefined]
#define __lwsync() __asm__ __volatile__ (stringify_in_c(LWSYNC) : : :"memory")
^
<built-in>:309:9: note: previous definition is here
#define __lwsync __builtin_ppc_lwsync
^
>> drivers/net/wireless/mediatek/mt76/tx.c:700:20: error: no member named 'wlan' in 'struct mtk_wed_device'
token >= wed->wlan.token_start)
~~~ ^
drivers/net/wireless/mediatek/mt76/tx.c:725:21: error: no member named 'wlan' in 'struct mtk_wed_device'
token >= wed->wlan.token_start &&
~~~ ^ 1 warning and 2 errors generated.
--
In file included from drivers/net/wireless/mediatek/mt76/mt7915/pci.c:7:
In file included from include/linux/kernel.h:12:
In file included from include/linux/bitops.h:32:
In file included from arch/powerpc/include/asm/bitops.h:62:
arch/powerpc/include/asm/barrier.h:49:9: warning: '__lwsync' macro redefined [-Wmacro-redefined]
#define __lwsync() __asm__ __volatile__ (stringify_in_c(LWSYNC) : : :"memory")
^
<built-in>:309:9: note: previous definition is here
#define __lwsync __builtin_ppc_lwsync
^
drivers/net/wireless/mediatek/mt76/mt7915/pci.c:100:25: warning: unused variable 'wed' [-Wunused-variable]
struct mtk_wed_device *wed = &dev->mt76.mmio.wed;
^
drivers/net/wireless/mediatek/mt76/mt7915/pci.c:165:25: warning: unused variable 'wed' [-Wunused-variable]
struct mtk_wed_device *wed = &dev->mt76.mmio.wed;
^
>> drivers/net/wireless/mediatek/mt76/mt7915/pci.c:238:30: error: no member named 'wlan' in 'struct mtk_wed_device'
dev->mt76.token_size = wed->wlan.token_start;
~~~ ^
drivers/net/wireless/mediatek/mt76/mt7915/pci.c:322:7: error: no member named 'wlan' in 'struct mtk_wed_device'
wed->wlan.pci_dev = pdev;
~~~ ^
drivers/net/wireless/mediatek/mt76/mt7915/pci.c:323:7: error: no member named 'wlan' in 'struct mtk_wed_device'
wed->wlan.wpdma_phys = pci_resource_start(pdev, 0) +
~~~ ^
drivers/net/wireless/mediatek/mt76/mt7915/pci.c:325:7: error: no member named 'wlan' in 'struct mtk_wed_device'
wed->wlan.nbuf = 4096;
~~~ ^
drivers/net/wireless/mediatek/mt76/mt7915/pci.c:326:7: error: no member named 'wlan' in 'struct mtk_wed_device'
wed->wlan.token_start = MT7915_TOKEN_SIZE - wed->wlan.nbuf - 1;
~~~ ^
drivers/net/wireless/mediatek/mt76/mt7915/pci.c:326:51: error: no member named 'wlan' in 'struct mtk_wed_device'
wed->wlan.token_start = MT7915_TOKEN_SIZE - wed->wlan.nbuf - 1;
~~~ ^
drivers/net/wireless/mediatek/mt76/mt7915/pci.c:327:7: error: no member named 'wlan' in 'struct mtk_wed_device'
wed->wlan.init_buf = mt7915_wed_init_buf;
~~~ ^
drivers/net/wireless/mediatek/mt76/mt7915/pci.c:328:7: error: no member named 'wlan' in 'struct mtk_wed_device'
wed->wlan.offload_enable = mt7915_wed_offload_enable;
~~~ ^
drivers/net/wireless/mediatek/mt76/mt7915/pci.c:329:7: error: no member named 'wlan' in 'struct mtk_wed_device'
wed->wlan.offload_disable = mt7915_wed_offload_disable;
~~~ ^
>> drivers/net/wireless/mediatek/mt76/mt7915/pci.c:332:14: error: no member named 'irq' in 'struct mtk_wed_device'
irq = wed->irq;
~~~ ^ 3 warnings and 10 errors generated.
--
In file included from drivers/net/wireless/mediatek/mt76/mt7915/main.c:4:
In file included from include/linux/etherdevice.h:20:
In file included from include/linux/if_ether.h:19:
In file included from include/linux/skbuff.h:13:
In file included from include/linux/kernel.h:12:
In file included from include/linux/bitops.h:32:
In file included from arch/powerpc/include/asm/bitops.h:62:
arch/powerpc/include/asm/barrier.h:49:9: warning: '__lwsync' macro redefined [-Wmacro-redefined]
#define __lwsync() __asm__ __volatile__ (stringify_in_c(LWSYNC) : : :"memory")
^
<built-in>:309:9: note: previous definition is here
#define __lwsync __builtin_ppc_lwsync
^
>> drivers/net/wireless/mediatek/mt76/mt7915/main.c:1056:33: error: no member named 'wdma_idx' in 'struct mtk_wed_device'
path->mtk_wdma.wdma_idx = wed->wdma_idx;
~~~ ^1 warning and 1 error generated.
vim +154 drivers/net/wireless/mediatek/mt76/dma.c
22
23 #define Q_WRITE(_dev, _q, _field, _val) do { \
> 24 u32 _offset = offsetof(struct mt76_queue_regs, _field); \
25 if (IS_ENABLED(CONFIG_NET_MEDIATEK_SOC_WED) && \
26 (_q)->flags & MT_QFLAG_WED) \
27 mtk_wed_device_reg_write(&(_dev)->mmio.wed, \
28 ((_q)->wed_regs + _offset), \
29 _val); \
30 else \
31 writel(_val, &(_q)->regs->_field); \
32 } while (0)
33
34 static int mt76_dma_rx_fill(struct mt76_dev *dev, struct mt76_queue *q);
35
36 static struct mt76_txwi_cache *
37 mt76_alloc_txwi(struct mt76_dev *dev)
38 {
39 struct mt76_txwi_cache *t;
40 dma_addr_t addr;
41 u8 *txwi;
42 int size;
43
44 size = L1_CACHE_ALIGN(dev->drv->txwi_size + sizeof(*t));
45 txwi = devm_kzalloc(dev->dev, size, GFP_ATOMIC);
46 if (!txwi)
47 return NULL;
48
49 addr = dma_map_single(dev->dev, txwi, dev->drv->txwi_size,
50 DMA_TO_DEVICE);
51 t = (struct mt76_txwi_cache *)(txwi + dev->drv->txwi_size);
52 t->dma_addr = addr;
53
54 return t;
55 }
56
57 static struct mt76_txwi_cache *
58 __mt76_get_txwi(struct mt76_dev *dev)
59 {
60 struct mt76_txwi_cache *t = NULL;
61
62 spin_lock(&dev->lock);
63 if (!list_empty(&dev->txwi_cache)) {
64 t = list_first_entry(&dev->txwi_cache, struct mt76_txwi_cache,
65 list);
66 list_del(&t->list);
67 }
68 spin_unlock(&dev->lock);
69
70 return t;
71 }
72
73 static struct mt76_txwi_cache *
74 mt76_get_txwi(struct mt76_dev *dev)
75 {
76 struct mt76_txwi_cache *t = __mt76_get_txwi(dev);
77
78 if (t)
79 return t;
80
81 return mt76_alloc_txwi(dev);
82 }
83
84 void
85 mt76_put_txwi(struct mt76_dev *dev, struct mt76_txwi_cache *t)
86 {
87 if (!t)
88 return;
89
90 spin_lock(&dev->lock);
91 list_add(&t->list, &dev->txwi_cache);
92 spin_unlock(&dev->lock);
93 }
94 EXPORT_SYMBOL_GPL(mt76_put_txwi);
95
96 static void
97 mt76_free_pending_txwi(struct mt76_dev *dev)
98 {
99 struct mt76_txwi_cache *t;
100
101 local_bh_disable();
102 while ((t = __mt76_get_txwi(dev)) != NULL)
103 dma_unmap_single(dev->dev, t->dma_addr, dev->drv->txwi_size,
104 DMA_TO_DEVICE);
105 local_bh_enable();
106 }
107
108 static void
109 mt76_dma_sync_idx(struct mt76_dev *dev, struct mt76_queue *q)
110 {
111 Q_WRITE(dev, q, desc_base, q->desc_dma);
112 Q_WRITE(dev, q, ring_size, q->ndesc);
113 q->head = Q_READ(dev, q, dma_idx);
114 q->tail = q->head;
115 }
116
117 static void
118 mt76_dma_queue_reset(struct mt76_dev *dev, struct mt76_queue *q)
119 {
120 int i;
121
122 if (!q)
123 return;
124
125 /* clear descriptors */
126 for (i = 0; i < q->ndesc; i++)
127 q->desc[i].ctrl = cpu_to_le32(MT_DMA_CTL_DMA_DONE);
128
129 Q_WRITE(dev, q, cpu_idx, 0);
> 130 Q_WRITE(dev, q, dma_idx, 0);
131 mt76_dma_sync_idx(dev, q);
132 }
133
134 static int
135 mt76_dma_wed_setup(struct mt76_dev *dev, struct mt76_queue *q)
136 {
137 struct mtk_wed_device *wed = &dev->mmio.wed;
138 int ret, type, ring;
139 u8 flags = q->flags;
140
141 if (!mtk_wed_device_active(wed))
142 q->flags &= ~MT_QFLAG_WED;
143
144 if (!(q->flags & MT_QFLAG_WED))
145 return 0;
146
147 type = FIELD_GET(MT_QFLAG_WED_TYPE, q->flags);
148 ring = FIELD_GET(MT_QFLAG_WED_RING, q->flags);
149
150 switch (type) {
151 case MT76_WED_Q_TX:
152 ret = mtk_wed_device_tx_ring_setup(wed, ring, q->regs);
153 if (!ret)
> 154 q->wed_regs = wed->tx_ring[ring].reg_base;
155 break;
156 case MT76_WED_Q_TXFREE:
157 /* WED txfree queue needs ring to be initialized before setup */
158 q->flags = 0;
159 mt76_dma_queue_reset(dev, q);
160 mt76_dma_rx_fill(dev, q);
161 q->flags = flags;
162
> 163 ret = mtk_wed_device_txfree_ring_setup(wed, q->regs);
164 if (!ret)
> 165 q->wed_regs = wed->txfree_ring.reg_base; 166 break;
167 default:
168 ret = -EINVAL;
169 }
170
171 return ret;
172 }
173
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org