Message ID | TY3P286MB2611CB2F4F5FA27D782AA80A98BC2@TY3P286MB2611.JPNP286.PROD.OUTLOOK.COM (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Felix Fietkau |
Headers | show |
Series | [v5] wifi: mt76: mt7915: add wds support when wed is enabled | expand |
Hi Shengyu, kernel test robot noticed the following build errors: [auto build test ERROR on wireless-next/main] [also build test ERROR on wireless/main linus/master v6.11-rc1 next-20240802] [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#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Shengyu-Qu/wifi-mt76-mt7915-add-wds-support-when-wed-is-enabled/20240803-231632 base: https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git main patch link: https://lore.kernel.org/r/TY3P286MB2611CB2F4F5FA27D782AA80A98BC2%40TY3P286MB2611.JPNP286.PROD.OUTLOOK.COM patch subject: [PATCH v5] wifi: mt76: mt7915: add wds support when wed is enabled config: x86_64-buildonly-randconfig-003-20240804 (https://download.01.org/0day-ci/archive/20240804/202408041039.BqVRJOqp-lkp@intel.com/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240804/202408041039.BqVRJOqp-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202408041039.BqVRJOqp-lkp@intel.com/ All errors (new ones prefixed by >>): drivers/net/wireless/mediatek/mt76/mt7915/mcu.c: In function 'mt7915_mcu_init_firmware': >> drivers/net/wireless/mediatek/mt76/mt7915/mcu.c:2363:67: error: 'struct mtk_wed_device' has no member named 'rev_id' 2363 | dev->mt76.mmio.wed.rev_id, 0); | ^ vim +2363 drivers/net/wireless/mediatek/mt76/mt7915/mcu.c 2322 2323 int mt7915_mcu_init_firmware(struct mt7915_dev *dev) 2324 { 2325 int ret; 2326 2327 /* force firmware operation mode into normal state, 2328 * which should be set before firmware download stage. 2329 */ 2330 mt76_wr(dev, MT_SWDEF_MODE, MT_SWDEF_NORMAL_MODE); 2331 2332 ret = mt7915_driver_own(dev, 0); 2333 if (ret) 2334 return ret; 2335 /* set driver own for band1 when two hif exist */ 2336 if (dev->hif2) { 2337 ret = mt7915_driver_own(dev, 1); 2338 if (ret) 2339 return ret; 2340 } 2341 2342 ret = mt7915_load_firmware(dev); 2343 if (ret) 2344 return ret; 2345 2346 set_bit(MT76_STATE_MCU_RUNNING, &dev->mphy.state); 2347 ret = mt7915_mcu_fw_log_2_host(dev, MCU_FW_LOG_WM, 0); 2348 if (ret) 2349 return ret; 2350 2351 ret = mt7915_mcu_fw_log_2_host(dev, MCU_FW_LOG_WA, 0); 2352 if (ret) 2353 return ret; 2354 2355 if (mtk_wed_device_active(&dev->mt76.mmio.wed)) { 2356 if (is_mt7915(&dev->mt76) || 2357 !mtk_wed_get_rx_capa(&dev->mt76.mmio.wed)) 2358 ret = mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(CAPABILITY), 2359 0, 0, 0); 2360 else 2361 ret = mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET), 2362 MCU_WA_PARAM_WED_VERSION, > 2363 dev->mt76.mmio.wed.rev_id, 0); 2364 if (ret) 2365 return ret; 2366 } 2367 2368 ret = mt7915_mcu_set_mwds(dev, 1); 2369 if (ret) 2370 return ret; 2371 2372 ret = mt7915_mcu_set_muru_ctrl(dev, MURU_SET_PLATFORM_TYPE, 2373 MURU_PLATFORM_TYPE_PERF_LEVEL_2); 2374 if (ret) 2375 return ret; 2376 2377 ret = mt7915_mcu_init_rx_airtime(dev); 2378 if (ret) 2379 return ret; 2380 2381 return mt7915_mcu_set_red(dev, mtk_wed_device_active(&dev->mt76.mmio.wed)); 2382 } 2383
This error report is a false warning. "struct mtk_wed_device" needs "CONFIG_NET_MEDIATEK_SOC_WED" to be defined. Best regards, Shengyu 在 2024/8/4 10:43, kernel test robot 写道: > Hi Shengyu, > > kernel test robot noticed the following build errors: > > [auto build test ERROR on wireless-next/main] > [also build test ERROR on wireless/main linus/master v6.11-rc1 next-20240802] > [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#_base_tree_information] > > url: https://github.com/intel-lab-lkp/linux/commits/Shengyu-Qu/wifi-mt76-mt7915-add-wds-support-when-wed-is-enabled/20240803-231632 > base: https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git main > patch link: https://lore.kernel.org/r/TY3P286MB2611CB2F4F5FA27D782AA80A98BC2%40TY3P286MB2611.JPNP286.PROD.OUTLOOK.COM > patch subject: [PATCH v5] wifi: mt76: mt7915: add wds support when wed is enabled > config: x86_64-buildonly-randconfig-003-20240804 (https://download.01.org/0day-ci/archive/20240804/202408041039.BqVRJOqp-lkp@intel.com/config) > compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240804/202408041039.BqVRJOqp-lkp@intel.com/reproduce) > > If you fix the issue in a separate patch/commit (i.e. not just a new version of > the same patch/commit), kindly add following tags > | Reported-by: kernel test robot <lkp@intel.com> > | Closes: https://lore.kernel.org/oe-kbuild-all/202408041039.BqVRJOqp-lkp@intel.com/ > > All errors (new ones prefixed by >>): > > drivers/net/wireless/mediatek/mt76/mt7915/mcu.c: In function 'mt7915_mcu_init_firmware': >>> drivers/net/wireless/mediatek/mt76/mt7915/mcu.c:2363:67: error: 'struct mtk_wed_device' has no member named 'rev_id' > 2363 | dev->mt76.mmio.wed.rev_id, 0); > | ^ > > > vim +2363 drivers/net/wireless/mediatek/mt76/mt7915/mcu.c > > 2322 > 2323 int mt7915_mcu_init_firmware(struct mt7915_dev *dev) > 2324 { > 2325 int ret; > 2326 > 2327 /* force firmware operation mode into normal state, > 2328 * which should be set before firmware download stage. > 2329 */ > 2330 mt76_wr(dev, MT_SWDEF_MODE, MT_SWDEF_NORMAL_MODE); > 2331 > 2332 ret = mt7915_driver_own(dev, 0); > 2333 if (ret) > 2334 return ret; > 2335 /* set driver own for band1 when two hif exist */ > 2336 if (dev->hif2) { > 2337 ret = mt7915_driver_own(dev, 1); > 2338 if (ret) > 2339 return ret; > 2340 } > 2341 > 2342 ret = mt7915_load_firmware(dev); > 2343 if (ret) > 2344 return ret; > 2345 > 2346 set_bit(MT76_STATE_MCU_RUNNING, &dev->mphy.state); > 2347 ret = mt7915_mcu_fw_log_2_host(dev, MCU_FW_LOG_WM, 0); > 2348 if (ret) > 2349 return ret; > 2350 > 2351 ret = mt7915_mcu_fw_log_2_host(dev, MCU_FW_LOG_WA, 0); > 2352 if (ret) > 2353 return ret; > 2354 > 2355 if (mtk_wed_device_active(&dev->mt76.mmio.wed)) { > 2356 if (is_mt7915(&dev->mt76) || > 2357 !mtk_wed_get_rx_capa(&dev->mt76.mmio.wed)) > 2358 ret = mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(CAPABILITY), > 2359 0, 0, 0); > 2360 else > 2361 ret = mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET), > 2362 MCU_WA_PARAM_WED_VERSION, >> 2363 dev->mt76.mmio.wed.rev_id, 0); > 2364 if (ret) > 2365 return ret; > 2366 } > 2367 > 2368 ret = mt7915_mcu_set_mwds(dev, 1); > 2369 if (ret) > 2370 return ret; > 2371 > 2372 ret = mt7915_mcu_set_muru_ctrl(dev, MURU_SET_PLATFORM_TYPE, > 2373 MURU_PLATFORM_TYPE_PERF_LEVEL_2); > 2374 if (ret) > 2375 return ret; > 2376 > 2377 ret = mt7915_mcu_init_rx_airtime(dev); > 2378 if (ret) > 2379 return ret; > 2380 > 2381 return mt7915_mcu_set_red(dev, mtk_wed_device_active(&dev->mt76.mmio.wed)); > 2382 } > 2383 >
Shengyu Qu <wiagn233@outlook.com> writes: > This error report is a false warning. "struct mtk_wed_device" needs > "CONFIG_NET_MEDIATEK_SOC_WED" to be defined. I didn't investigate anything but based on your description that sounds wrong. The code should should not be compiled if it depends on CONFIG_NET_MEDIATEK_SOC_WED but that's not set. We have zero rule for compilation errors or warnings.
You are right. I'm thinking about changing the code like this: #ifdef CONFIG_NET_MEDIATEK_SOC_WED if (mtk_wed_device_active(&dev->mt76.mmio.wed)) { if (is_mt7915(&dev->mt76) || !mtk_wed_get_rx_capa(&dev->mt76.mmio.wed)) ret = mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(CAPABILITY), 0, 0, 0); else ret = mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET), MCU_WA_PARAM_WED_VERSION, dev->mt76.mmio.wed.rev_id, 0); if (ret) return ret; } #endif Do you think this is ok? Best regards, Shengyu 在 2024/8/4 17:56, Kalle Valo 写道: > Shengyu Qu <wiagn233@outlook.com> writes: > >> This error report is a false warning. "struct mtk_wed_device" needs >> "CONFIG_NET_MEDIATEK_SOC_WED" to be defined. > > I didn't investigate anything but based on your description that sounds > wrong. The code should should not be compiled if it depends on > CONFIG_NET_MEDIATEK_SOC_WED but that's not set. We have zero rule for > compilation errors or warnings. >
diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h index 4a58a78d5ed25..1186a4998faff 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76.h +++ b/drivers/net/wireless/mediatek/mt76/mt76.h @@ -28,6 +28,9 @@ #define MT76_TOKEN_FREE_THR 64 +#define MT76_WED_WDS_MIN 256 +#define MT76_WED_WDS_MAX 272 + #define MT_QFLAG_WED_RING GENMASK(1, 0) #define MT_QFLAG_WED_TYPE GENMASK(4, 2) #define MT_QFLAG_WED BIT(5) @@ -71,6 +74,12 @@ enum mt76_wed_type { MT76_WED_RRO_Q_IND, }; +enum mt76_wed_state { + MT76_WED_DEFAULT, + MT76_WED_ACTIVE, + MT76_WED_WDS_ACTIVE, +}; + struct mt76_bus_ops { u32 (*rr)(struct mt76_dev *dev, u32 offset); void (*wr)(struct mt76_dev *dev, u32 offset, u32 val); diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/main.c b/drivers/net/wireless/mediatek/mt76/mt7915/main.c index 049223df9beb1..dc4d87e004a0f 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/main.c @@ -745,8 +745,15 @@ int mt7915_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif, bool ext_phy = mvif->phy != &dev->phy; int ret, idx; u32 addr; + u8 flags = MT76_WED_DEFAULT; - idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7915_WTBL_STA); + if (mtk_wed_device_active(&dev->mt76.mmio.wed) && + !is_mt7915(&dev->mt76)) { + flags = test_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags) ? + MT76_WED_WDS_ACTIVE : MT76_WED_ACTIVE; + } + + idx = __mt76_wcid_alloc(mdev->wcid_mask, MT7915_WTBL_STA, flags); if (idx < 0) return -ENOSPC; @@ -1201,12 +1208,27 @@ static void mt7915_sta_set_4addr(struct ieee80211_hw *hw, { struct mt7915_dev *dev = mt7915_hw_dev(hw); struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; + int min = MT76_WED_WDS_MIN, max = MT76_WED_WDS_MAX; if (enabled) set_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags); else clear_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags); + if (mtk_wed_device_active(&dev->mt76.mmio.wed) && + !is_mt7915(&dev->mt76) && + (msta->wcid.idx < min || msta->wcid.idx > max - 1)) { + struct ieee80211_sta *pre_sta; + + pre_sta = kzalloc(sizeof(*sta) + sizeof(*msta), GFP_KERNEL); + mt76_sta_pre_rcu_remove(hw, vif, sta); + memmove(pre_sta, sta, sizeof(*sta) + sizeof(*msta)); + mt7915_sta_add(hw, vif, sta); + synchronize_rcu(); + mt7915_sta_remove(hw, vif, pre_sta); + kfree(pre_sta); + } + mt76_connac_mcu_wtbl_update_hdr_trans(&dev->mt76, vif, sta); } @@ -1644,15 +1666,19 @@ mt7915_net_fill_forward_path(struct ieee80211_hw *hw, if (!mtk_wed_device_active(wed)) return -ENODEV; - if (msta->wcid.idx > 0xff) + if (msta->wcid.idx > MT7915_WTBL_STA) 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->mt76.idx; - path->mtk_wdma.wcid = is_mt7915(&dev->mt76) ? msta->wcid.idx : 0x3ff; path->mtk_wdma.queue = phy != &dev->phy; + if (test_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags) || + is_mt7915(&dev->mt76)) + path->mtk_wdma.wcid = msta->wcid.idx; + else + path->mtk_wdma.wcid = 0x3ff; ctx->dev = NULL; diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c index 2185cd24e2e1c..0f715a4c21ada 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c @@ -2352,10 +2352,18 @@ int mt7915_mcu_init_firmware(struct mt7915_dev *dev) if (ret) return ret; - if ((mtk_wed_device_active(&dev->mt76.mmio.wed) && - is_mt7915(&dev->mt76)) || - !mtk_wed_get_rx_capa(&dev->mt76.mmio.wed)) - mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(CAPABILITY), 0, 0, 0); + if (mtk_wed_device_active(&dev->mt76.mmio.wed)) { + if (is_mt7915(&dev->mt76) || + !mtk_wed_get_rx_capa(&dev->mt76.mmio.wed)) + ret = mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(CAPABILITY), + 0, 0, 0); + else + ret = mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET), + MCU_WA_PARAM_WED_VERSION, + dev->mt76.mmio.wed.rev_id, 0); + if (ret) + return ret; + } ret = mt7915_mcu_set_mwds(dev, 1); if (ret) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.h b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.h index b41ac4aaced7f..b2bf5472b2d70 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.h @@ -279,6 +279,7 @@ enum { MCU_WA_PARAM_CPU_UTIL = 0x0b, MCU_WA_PARAM_RED = 0x0e, MCU_WA_PARAM_RED_SETTING = 0x40, + MCU_WA_PARAM_WED_VERSION = 0x32, }; enum mcu_mmps_mode { diff --git a/drivers/net/wireless/mediatek/mt76/util.c b/drivers/net/wireless/mediatek/mt76/util.c index d6c01a2dd1988..461b74068fc30 100644 --- a/drivers/net/wireless/mediatek/mt76/util.c +++ b/drivers/net/wireless/mediatek/mt76/util.c @@ -42,9 +42,11 @@ bool ____mt76_poll_msec(struct mt76_dev *dev, u32 offset, u32 mask, u32 val, } EXPORT_SYMBOL_GPL(____mt76_poll_msec); -int mt76_wcid_alloc(u32 *mask, int size) +int __mt76_wcid_alloc(u32 *mask, int size, u8 flag) { int i, idx = 0, cur; + int min = MT76_WED_WDS_MIN; + int max = MT76_WED_WDS_MAX; for (i = 0; i < DIV_ROUND_UP(size, 32); i++) { idx = ffs(~mask[i]); @@ -53,16 +55,45 @@ int mt76_wcid_alloc(u32 *mask, int size) idx--; cur = i * 32 + idx; - if (cur >= size) + + switch (flag) { + case MT76_WED_ACTIVE: + if (cur >= min && cur < max) + continue; + + if (cur >= size) { + u32 end = max - min - 1; + + i = min / 32; + idx = ffs(~mask[i] & GENMASK(end, 0)); + if (!idx) + goto error; + idx--; + cur = min + idx; + } + break; + case MT76_WED_WDS_ACTIVE: + if (cur < min) + continue; + if (cur >= max) + goto error; + + break; + default: + if (cur >= size) + goto error; + break; + } mask[i] |= BIT(idx); return cur; } +error: return -1; } -EXPORT_SYMBOL_GPL(mt76_wcid_alloc); +EXPORT_SYMBOL_GPL(__mt76_wcid_alloc); int mt76_get_min_avg_rssi(struct mt76_dev *dev, bool ext_phy) { diff --git a/drivers/net/wireless/mediatek/mt76/util.h b/drivers/net/wireless/mediatek/mt76/util.h index 260965dde94cf..99b7263c0a205 100644 --- a/drivers/net/wireless/mediatek/mt76/util.h +++ b/drivers/net/wireless/mediatek/mt76/util.h @@ -27,7 +27,12 @@ enum { #define MT76_INCR(_var, _size) \ (_var = (((_var) + 1) % (_size))) -int mt76_wcid_alloc(u32 *mask, int size); +int __mt76_wcid_alloc(u32 *mask, int size, u8 flags); + +static inline int mt76_wcid_alloc(u32 *mask, int size) +{ + return __mt76_wcid_alloc(mask, size, 0); +} static inline void mt76_wcid_mask_set(u32 *mask, int idx)