mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH mt76 1/2] Revert "wifi: mt76: mt792x: improve monitor interface handling"
@ 2025-10-27 11:18 Fedor Pchelkin
  2025-10-27 11:18 ` [PATCH mt76 2/2] wifi: mt76: adjust BSS conf pointer handling Fedor Pchelkin
  2025-11-21  5:42 ` [PATCH mt76 1/2] Revert "wifi: mt76: mt792x: improve monitor interface handling" Alex Gavin
  0 siblings, 2 replies; 3+ messages in thread
From: Fedor Pchelkin @ 2025-10-27 11:18 UTC (permalink / raw)
  To: Felix Fietkau, Lorenzo Bianconi, Ming Yen Hsieh
  Cc: Fedor Pchelkin, Ryder Lee, Shayne Chen, Sean Wang,
	linux-wireless, linux-kernel, linux-mediatek, Matvey Kovalev,
	lvc-project

This reverts commit 55e95ce469d0c61041bae48b2ebb7fcbf6d1ba7f.

mt792x drivers don't seem to support multi-radio devices yet.  At least
they don't mess with `struct wiphy_radio` at the moment.

Packet capturing on monitor interface doesn't work after the blamed patch:

  tcpdump -i wls6mon -n -vvv

Revert the NO_VIRTUAL_MONITOR feature for now to resolve the issue.

Found by Linux Verification Center (linuxtesting.org).

Fixes: 55e95ce469d0 ("wifi: mt76: mt792x: improve monitor interface handling")
Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
---

Can't answer exactly *why* the capturing doesn't work after the patch:
probably because the driver is just not prepared for NO_VIRTUAL_MONITOR.
The feature isn't too obvious, especially that for some reason it was set
in mt792x alongside WANT_MONITOR_VIF.  With a quick glance I might
conclude that NO_VIRTUAL_MONITOR overrides WANT_MONITOR_VIF, they don't
look compatible.

 drivers/net/wireless/mediatek/mt76/mt792x_core.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt792x_core.c b/drivers/net/wireless/mediatek/mt76/mt792x_core.c
index 5b50bf94996e..f2ed16feb6c1 100644
--- a/drivers/net/wireless/mediatek/mt76/mt792x_core.c
+++ b/drivers/net/wireless/mediatek/mt76/mt792x_core.c
@@ -688,7 +688,6 @@ int mt792x_init_wiphy(struct ieee80211_hw *hw)
 	ieee80211_hw_set(hw, SUPPORTS_DYNAMIC_PS);
 	ieee80211_hw_set(hw, SUPPORTS_VHT_EXT_NSS_BW);
 	ieee80211_hw_set(hw, CONNECTION_MONITOR);
-	ieee80211_hw_set(hw, NO_VIRTUAL_MONITOR);
 	ieee80211_hw_set(hw, SUPPORTS_MULTI_BSSID);
 	ieee80211_hw_set(hw, SUPPORTS_ONLY_HE_MULTI_BSSID);
 
-- 
2.51.0


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

* [PATCH mt76 2/2] wifi: mt76: adjust BSS conf pointer handling
  2025-10-27 11:18 [PATCH mt76 1/2] Revert "wifi: mt76: mt792x: improve monitor interface handling" Fedor Pchelkin
@ 2025-10-27 11:18 ` Fedor Pchelkin
  2025-11-21  5:42 ` [PATCH mt76 1/2] Revert "wifi: mt76: mt792x: improve monitor interface handling" Alex Gavin
  1 sibling, 0 replies; 3+ messages in thread
From: Fedor Pchelkin @ 2025-10-27 11:18 UTC (permalink / raw)
  To: Felix Fietkau, Lorenzo Bianconi, Ming Yen Hsieh
  Cc: Fedor Pchelkin, Ryder Lee, Shayne Chen, Sean Wang,
	linux-wireless, linux-kernel, linux-mediatek, Matvey Kovalev,
	lvc-project

Passing a BSS conf pointer to mt76_connac2_mac_tx_rate_val() currently has
two inconsistencies.

When called from mt76_connac2_mac_write_txwi(), BSS conf is got by
dereferencing a vif pointer.  A NULL vif isn't accounted for though the
function itself supposes it to be NULL and tries to handle this case in
previous checks.  This looks like a cosmetic change since the drivers
calling the function (namely, mt7915 and mt7921) set WANT_MONITOR_VIF flag
so judging by info->control.vif initialization inside ieee80211_tx_*()
routines it can't actually come as NULL here.

The same holds for the BSS conf pointer handling inside
mt76_connac2_mac_tx_rate_val().  It is dereferenced before being checked
for NULL.  The function supposes to handle the case so reorder the check
and dereference of the pointer.  Again, this looks like a syntax issue
only.

Found by Linux Verification Center (linuxtesting.org) with SVACE static
analysis tool.

Co-developed-by: Matvey Kovalev <matvey.kovalev@ispras.ru>
Signed-off-by: Matvey Kovalev <matvey.kovalev@ispras.ru>
Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
---
 .../wireless/mediatek/mt76/mt76_connac_mac.c  | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c b/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c
index 7af6a578562f..3304b5971be0 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c
@@ -297,16 +297,18 @@ u16 mt76_connac2_mac_tx_rate_val(struct mt76_phy *mphy,
 				 struct ieee80211_bss_conf *conf,
 				 bool beacon, bool mcast)
 {
-	struct mt76_vif_link *mvif = mt76_vif_conf_link(mphy->dev, conf->vif, conf);
-	struct cfg80211_chan_def *chandef = mvif->ctx ?
-					    &mvif->ctx->def : &mphy->chandef;
-	u8 nss = 0, mode = 0, band = chandef->chan->band;
-	int rateidx = 0, mcast_rate;
-	int offset = 0;
+	u8 nss = 0, mode = 0, band = NL80211_BAND_2GHZ;
+	int rateidx = 0, offset = 0, mcast_rate;
+	struct cfg80211_chan_def *chandef;
+	struct mt76_vif_link *mvif;
 
 	if (!conf)
 		goto legacy;
 
+	mvif = mt76_vif_conf_link(mphy->dev, conf->vif, conf);
+	chandef = mvif->ctx ? &mvif->ctx->def : &mphy->chandef;
+	band = chandef->chan->band;
+
 	if (is_mt7921(mphy->dev)) {
 		rateidx = ffs(conf->basic_rates) - 1;
 		goto legacy;
@@ -584,8 +586,9 @@ void mt76_connac2_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi,
 		struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
 		bool multicast = ieee80211_is_data(hdr->frame_control) &&
 				 is_multicast_ether_addr(hdr->addr1);
-		u16 rate = mt76_connac2_mac_tx_rate_val(mphy, &vif->bss_conf, beacon,
-							multicast);
+		u16 rate = mt76_connac2_mac_tx_rate_val(mphy,
+							vif ? &vif->bss_conf : NULL,
+							beacon, multicast);
 		u32 val = MT_TXD6_FIXED_BW;
 
 		/* hardware won't add HTC for mgmt/ctrl frame */
-- 
2.51.0


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

* Re: [PATCH mt76 1/2] Revert "wifi: mt76: mt792x: improve monitor interface handling"
  2025-10-27 11:18 [PATCH mt76 1/2] Revert "wifi: mt76: mt792x: improve monitor interface handling" Fedor Pchelkin
  2025-10-27 11:18 ` [PATCH mt76 2/2] wifi: mt76: adjust BSS conf pointer handling Fedor Pchelkin
@ 2025-11-21  5:42 ` Alex Gavin
  1 sibling, 0 replies; 3+ messages in thread
From: Alex Gavin @ 2025-11-21  5:42 UTC (permalink / raw)
  To: Fedor Pchelkin, Felix Fietkau, Lorenzo Bianconi, Ming Yen Hsieh
  Cc: Ryder Lee, Shayne Chen, Sean Wang, linux-wireless, linux-kernel,
	linux-mediatek, Matvey Kovalev, lvc-project

On 10/27/25 04:18, Fedor Pchelkin wrote:
> This reverts commit 55e95ce469d0c61041bae48b2ebb7fcbf6d1ba7f.
> 
> mt792x drivers don't seem to support multi-radio devices yet.  At least
> they don't mess with `struct wiphy_radio` at the moment.
> 
> Packet capturing on monitor interface doesn't work after the blamed patch:
> 
>   tcpdump -i wls6mon -n -vvv
> 
> Revert the NO_VIRTUAL_MONITOR feature for now to resolve the issue.
> 
> Found by Linux Verification Center (linuxtesting.org).
> 
> Fixes: 55e95ce469d0 ("wifi: mt76: mt792x: improve monitor interface handling")
> Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
> ---
> 
> Can't answer exactly *why* the capturing doesn't work after the patch:
> probably because the driver is just not prepared for NO_VIRTUAL_MONITOR.
> The feature isn't too obvious, especially that for some reason it was set
> in mt792x alongside WANT_MONITOR_VIF.  With a quick glance I might
> conclude that NO_VIRTUAL_MONITOR overrides WANT_MONITOR_VIF, they don't
> look compatible.
> 
>  drivers/net/wireless/mediatek/mt76/mt792x_core.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt792x_core.c b/drivers/net/wireless/mediatek/mt76/mt792x_core.c
> index 5b50bf94996e..f2ed16feb6c1 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt792x_core.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt792x_core.c
> @@ -688,7 +688,6 @@ int mt792x_init_wiphy(struct ieee80211_hw *hw)
>  	ieee80211_hw_set(hw, SUPPORTS_DYNAMIC_PS);
>  	ieee80211_hw_set(hw, SUPPORTS_VHT_EXT_NSS_BW);
>  	ieee80211_hw_set(hw, CONNECTION_MONITOR);
> -	ieee80211_hw_set(hw, NO_VIRTUAL_MONITOR);
>  	ieee80211_hw_set(hw, SUPPORTS_MULTI_BSSID);
>  	ieee80211_hw_set(hw, SUPPORTS_ONLY_HE_MULTI_BSSID);
>  

This patch fixed monitor vif-only packet capture for me when using both mt7921 and mt7921au chipset
radios. Without it I was only seeing broadcast and multicast traffic I believe. Tested using vanilla
6.18.0-rc6 as base.


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

end of thread, other threads:[~2025-11-21  5:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-27 11:18 [PATCH mt76 1/2] Revert "wifi: mt76: mt792x: improve monitor interface handling" Fedor Pchelkin
2025-10-27 11:18 ` [PATCH mt76 2/2] wifi: mt76: adjust BSS conf pointer handling Fedor Pchelkin
2025-11-21  5:42 ` [PATCH mt76 1/2] Revert "wifi: mt76: mt792x: improve monitor interface handling" Alex Gavin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®