From: Sean Wang <sean.wang@kernel.org>
To: nbd@nbd.name, lorenzo.bianconi@redhat.com
Cc: linux-wireless@vger.kernel.org,
linux-mediatek@lists.infradead.org, yu-ching.liu@mediatek.com,
jenhao.yang@mediatek.com, posh.sun@mediatek.com,
Jacobs Wu <jacobs.wu@mediatek.com>,
Sean Wang <sean.wang@mediatek.com>
Subject: [PATCH 15/15] wifi: mt76: mt7925: fix HT/VHT caps and rates for NAN NDP peers
Date: Mon, 24 Aug 2026 14:52:27 -0500 [thread overview]
Message-ID: <20260824195227.12589-16-sean.wang@kernel.org> (raw)
In-Reply-To: <20260824195227.12589-1-sean.wang@kernel.org>
From: Jacobs Wu <jacobs.wu@mediatek.com>
NAN NDP peers were added with bare link_sta caps: no HT cap or QoS
flag (so no BA/A-MPDU), no VHT cap / bandwidth / rx_nss, a data BSS
phy mode that still read legacy when the firmware built the peer's
rate table, and caps filtered down by the currently committed
schedule.
Push the NAN_DATA BSS phymode before sta_update, force the HT cap and
QoS flag, seed VHT80 / bandwidth / rx_nss=2 from the BSS RLM, fix the
NDP HT/VHT rate selection and stop filtering the link_sta caps by the
schedule, so rate control always sees the peer's real capabilities.
Bench (MT7925<->MT7925 NDP, 5 GHz ch149): 866.7M VHT80 MCS9 NSS2 link
rate, UDP ~290 Mbit/s.
Fixes: 0f3605e4f8de ("wifi: mt76: mt7925: wire up NAN operations")
Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Jacobs Wu <jacobs.wu@mediatek.com>
---
.../net/wireless/mediatek/mt76/mt7925/main.c | 19 +++++-
.../net/wireless/mediatek/mt76/mt7925/nan.c | 62 +++++++++++++++++++
.../net/wireless/mediatek/mt76/mt7925/nan.h | 4 ++
3 files changed, 83 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index e1c688af7c59..051a0c8aed58 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -964,6 +964,21 @@ static int mt7925_mac_link_sta_add(struct mt76_dev *mdev,
link_conf = mt792x_vif_to_bss_conf(vif, link_id);
+ /* NAN_DATA (NDI) peers skip association - fill link_sta caps
+ * from sband and push BSS_INFO with correct phymode + RLM.
+ */
+ if (vif->type == NL80211_IFTYPE_NAN_DATA) {
+ struct ieee80211_chanctx_conf *nan_ctx;
+
+ nan_ctx = mt7925_nan_seed_link_sta(dev, link_sta);
+ mconf->mt76.ctx = nan_ctx;
+
+ ret = mt7925_mcu_add_bss_info(&dev->phy, nan_ctx,
+ link_conf, link_sta, true);
+ if (ret)
+ goto out_pm;
+ }
+
/* should update bss info before STA add */
if (vif->type == NL80211_IFTYPE_STATION && !link_sta->sta->tdls) {
struct mt792x_link_sta *mlink_bc;
@@ -2587,8 +2602,8 @@ static int mt7925_start_nan(struct ieee80211_hw *hw,
cfg80211_chandef_create(&link_conf->chanreq.oper, chan,
NL80211_CHAN_NO_HT);
- err = mt7925_mcu_add_bss_info(&dev->phy, NULL, link_conf,
- NULL, true);
+ err = mt7925_mcu_add_bss_info(&dev->phy, NULL,
+ link_conf, NULL, true);
if (err < 0)
goto out;
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/nan.c b/drivers/net/wireless/mediatek/mt76/mt7925/nan.c
index 4b479edab018..8a59f7b1aee2 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/nan.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/nan.c
@@ -267,6 +267,68 @@ int mt7925_nan_update_phy_setting(struct mt792x_dev *dev)
&req, sizeof(req), true);
}
+struct ieee80211_chanctx_conf *
+mt7925_nan_seed_link_sta(struct mt792x_dev *dev,
+ struct ieee80211_link_sta *link_sta)
+{
+ struct ieee80211_supported_band *sband_2g, *sband_5g;
+ struct ieee80211_chanctx_conf *nan_ctx = NULL;
+ struct ieee80211_vif *nan_vif = dev->nan_vif;
+
+ /* Fill HT cap from 2G sband */
+ sband_2g = dev->mphy.hw->wiphy->bands[NL80211_BAND_2GHZ];
+ sband_5g = dev->mphy.hw->wiphy->bands[NL80211_BAND_5GHZ];
+ if (sband_2g)
+ link_sta->ht_cap = sband_2g->ht_cap;
+
+ link_sta->sta->wme = true;
+ link_sta->rx_nss = hweight8(dev->mphy.antenna_mask);
+
+ /* Get chanctx from NAN schedule.
+ * Prefer 5G committed slot for wider BW (VHT), fallback
+ * to first valid slot if no 5G data slot is scheduled.
+ */
+ if (nan_vif) {
+ struct ieee80211_nan_channel **slots =
+ nan_vif->cfg.nan_sched.schedule;
+ int i;
+
+ for (i = 0; i < CFG80211_NAN_SCHED_NUM_TIME_SLOTS; i++) {
+ struct ieee80211_chanctx_conf *ctx;
+
+ if (!slots[i] || IS_ERR(slots[i]) ||
+ !slots[i]->chanctx_conf)
+ continue;
+
+ ctx = slots[i]->chanctx_conf;
+ if (!nan_ctx)
+ nan_ctx = ctx;
+ if (ctx->def.chan->band == NL80211_BAND_5GHZ) {
+ nan_ctx = ctx;
+ break;
+ }
+ }
+ }
+
+ /* Capability describes what the device can do and must not be
+ * filtered by the current schedule - firmware gates the VHT rate
+ * mode per the data schedule and re-derives it on schedule
+ * change, which only works if the caps are present up front.
+ */
+ if (sband_5g)
+ link_sta->vht_cap = sband_5g->vht_cap;
+
+ /* Bandwidth here is the capability ceiling, not the operating
+ * width - the per-slot operating bandwidth follows the current
+ * slot channel via the firmware RLM sync, so deriving it from
+ * the schedule at STA-add time would cap a later 5 GHz schedule
+ * at the bring-up width.
+ */
+ link_sta->bandwidth = IEEE80211_STA_RX_BW_80;
+
+ return nan_ctx;
+}
+
int mt7925_nan_enable(struct ieee80211_vif *vif,
struct mt792x_dev *dev,
struct cfg80211_nan_conf *conf)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/nan.h b/drivers/net/wireless/mediatek/mt76/mt7925/nan.h
index c78a1350c456..d81d84a222d9 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/nan.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/nan.h
@@ -477,6 +477,10 @@ struct mt7925_nan_update_phy_setting_tlv {
int mt7925_nan_update_phy_setting(struct mt792x_dev *dev);
+struct ieee80211_chanctx_conf *
+mt7925_nan_seed_link_sta(struct mt792x_dev *dev,
+ struct ieee80211_link_sta *link_sta);
+
int mt7925_nan_enable(struct ieee80211_vif *vif,
struct mt792x_dev *dev,
struct cfg80211_nan_conf *conf);
--
2.43.0
prev parent reply other threads:[~2026-08-24 19:53 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-24 19:52 [PATCH 00/15] wifi: mt76: mt7925: fix NAN operation and NDP performance Sean Wang
2026-08-24 19:52 ` [PATCH 01/15] wifi: mt76: mt7925: fix NAN NDP STA record role index Sean Wang
2026-08-24 19:52 ` [PATCH 02/15] wifi: mt76: mt7925: fix NAN start failure Sean Wang
2026-08-24 19:52 ` [PATCH 03/15] wifi: mt76: mt7925: fix NAN committed CRB timeline layout Sean Wang
2026-08-24 19:52 ` [PATCH 04/15] wifi: mt76: mt7925: report only 2.4 GHz NAN supported band Sean Wang
2026-08-24 19:52 ` [PATCH 05/15] wifi: mt76: mt7925: drop unused NAN 2.4/5 GHz support config Sean Wang
2026-08-24 19:52 ` [PATCH 06/15] wifi: mt76: mt7925: drop deferred NAN local schedule update handling Sean Wang
2026-08-24 19:52 ` [PATCH 07/15] wifi: mt76: mt7925: use OFDM-only PHY mode for NAN STA records Sean Wang
2026-08-24 19:52 ` [PATCH 08/15] wifi: mt76: mt7925: share TLV setup for NAN enable command Sean Wang
2026-08-24 19:52 ` [PATCH 09/15] wifi: mt76: mt7925: replace NAN DW end event with DW start Sean Wang
2026-08-24 19:52 ` [PATCH 10/15] wifi: mt76: mt7925: fill all DW intervals in NAN avail_map Sean Wang
2026-08-24 19:52 ` [PATCH 11/15] wifi: mt76: mt7925: clear CRB before deactivating NAN peer record Sean Wang
2026-08-24 19:52 ` [PATCH 12/15] wifi: mt76: mt7925: add ULW event handling and peer ULW update Sean Wang
2026-08-24 19:52 ` [PATCH 13/15] wifi: mt76: mt7925: configure NAN PHY setting on enable Sean Wang
2026-08-24 19:52 ` [PATCH 14/15] wifi: mt76: mt7925: support deferred NAN schedule update and cluster events Sean Wang
2026-08-24 19:52 ` Sean Wang [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260824195227.12589-16-sean.wang@kernel.org \
--to=sean.wang@kernel.org \
--cc=jacobs.wu@mediatek.com \
--cc=jenhao.yang@mediatek.com \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-wireless@vger.kernel.org \
--cc=lorenzo.bianconi@redhat.com \
--cc=nbd@nbd.name \
--cc=posh.sun@mediatek.com \
--cc=sean.wang@mediatek.com \
--cc=yu-ching.liu@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox