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,
Sean Wang <sean.wang@mediatek.com>
Subject: [PATCH 13/15] wifi: mt76: mt7925: configure NAN PHY setting on enable
Date: Mon, 24 Aug 2026 14:52:25 -0500 [thread overview]
Message-ID: <20260824195227.12589-14-sean.wang@kernel.org> (raw)
In-Reply-To: <20260824195227.12589-1-sean.wang@kernel.org>
From: Stella Liu <yu-ching.liu@mediatek.com>
Implement NAN_UNI_CMD_UPDATE_PHY_SETTING (tag=18) to configure the
BSS-level PHY parameters that the FW NAN scheduler uses when it
switches channels.
The command carries separate 2G and 5G PHY settings, each with its
own phy type, rate sets and protection modes.
Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Stella Liu <yu-ching.liu@mediatek.com>
---
.../net/wireless/mediatek/mt76/mt7925/main.c | 6 +-
.../net/wireless/mediatek/mt76/mt7925/nan.c | 74 +++++++++++++++++++
.../net/wireless/mediatek/mt76/mt7925/nan.h | 29 ++++++++
3 files changed, 108 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index 77420bb6f977..93de42c2bfd9 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -2593,8 +2593,12 @@ static int mt7925_start_nan(struct ieee80211_hw *hw,
goto out;
err = mt7925_nan_enable(vif, dev, conf);
- if (err)
+ if (err) {
mt7925_mcu_add_bss_info(&dev->phy, NULL, link_conf, NULL, false);
+ goto out;
+ }
+
+ err = mt7925_nan_update_phy_setting(dev);
out:
mt792x_mutex_release(dev);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/nan.c b/drivers/net/wireless/mediatek/mt76/mt7925/nan.c
index 53736b156f69..1f695f0c4473 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/nan.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/nan.c
@@ -193,6 +193,80 @@ mt7925_nan_sync_rssi_tlv(struct sk_buff *skb, struct cfg80211_nan_conf *conf)
return 0;
}
+/* FW rate set bit definitions (matches FW wlan_def_cmm.h) */
+#define NAN_RATE_SET_BIT_1M BIT(0)
+#define NAN_RATE_SET_BIT_2M BIT(1)
+#define NAN_RATE_SET_BIT_5_5M BIT(2)
+#define NAN_RATE_SET_BIT_11M BIT(3)
+#define NAN_RATE_SET_BIT_6M BIT(6)
+#define NAN_RATE_SET_BIT_9M BIT(7)
+#define NAN_RATE_SET_BIT_12M BIT(8)
+#define NAN_RATE_SET_BIT_18M BIT(9)
+#define NAN_RATE_SET_BIT_24M BIT(10)
+#define NAN_RATE_SET_BIT_36M BIT(11)
+#define NAN_RATE_SET_BIT_48M BIT(12)
+#define NAN_RATE_SET_BIT_54M BIT(13)
+
+#define NAN_RATE_SET_ALL_A (NAN_RATE_SET_BIT_6M | NAN_RATE_SET_BIT_9M | \
+ NAN_RATE_SET_BIT_12M | NAN_RATE_SET_BIT_18M | \
+ NAN_RATE_SET_BIT_24M | NAN_RATE_SET_BIT_36M | \
+ NAN_RATE_SET_BIT_48M | NAN_RATE_SET_BIT_54M)
+
+/* 5G basic: 6M+12M+24M (OFDM) */
+#define NAN_BASIC_RATE_SET_5G (NAN_RATE_SET_BIT_6M | NAN_RATE_SET_BIT_12M | \
+ NAN_RATE_SET_BIT_24M)
+
+/* GF_MODE_DISALLOWED = 2, RIFS_MODE_DISALLOWED = 1 */
+#define NAN_GF_MODE_DISALLOWED 2
+#define NAN_RIFS_MODE_DISALLOWED 1
+
+int mt7925_nan_update_phy_setting(struct mt792x_dev *dev)
+{
+ struct mt76_phy *mphy = &dev->mphy;
+ struct ieee80211_supported_band *sband_5g;
+ struct mt7925_nan_phy_setting *phy;
+ struct {
+ u8 rsv[4];
+ struct mt7925_nan_update_phy_setting_tlv tlv;
+ } req = {};
+
+ sband_5g = mphy->hw->wiphy->bands[NL80211_BAND_5GHZ];
+
+ req.tlv.tag = cpu_to_le16(NAN_UNI_CMD_UPDATE_PHY_SETTING);
+ req.tlv.len = cpu_to_le16(sizeof(req.tlv));
+
+ /* 2G: ERP + HT (no CCK/HR_DSSS - NAN uses OFDM only) */
+ phy = &req.tlv.phy_2g;
+ phy->phy_type_set = PHY_TYPE_BIT_ERP | PHY_TYPE_BIT_HT;
+ phy->non_ht_basic_phy_type = PHY_TYPE_ERP_INDEX;
+ phy->use_short_preamble = 1;
+ phy->use_short_slot_time = 1;
+ phy->operational_rate_set = cpu_to_le16(NAN_RATE_SET_ALL_A);
+ phy->bss_basic_rate_set = cpu_to_le16(NAN_BASIC_RATE_SET_5G);
+ phy->gf_operation_mode = cpu_to_le32(NAN_GF_MODE_DISALLOWED);
+ phy->rifs_operation_mode = cpu_to_le32(NAN_RIFS_MODE_DISALLOWED);
+
+ /* 5G: OFDM + HT + VHT (NAN_MODE_11A) */
+ phy = &req.tlv.phy_5g;
+ phy->phy_type_set = PHY_TYPE_BIT_OFDM | PHY_TYPE_BIT_HT |
+ PHY_TYPE_BIT_VHT;
+ phy->non_ht_basic_phy_type = PHY_TYPE_OFDM_INDEX;
+ phy->use_short_preamble = 1;
+ phy->use_short_slot_time = 1;
+ phy->operational_rate_set = cpu_to_le16(NAN_RATE_SET_ALL_A);
+ phy->bss_basic_rate_set = cpu_to_le16(NAN_BASIC_RATE_SET_5G);
+ phy->gf_operation_mode = cpu_to_le32(NAN_GF_MODE_DISALLOWED);
+ phy->rifs_operation_mode = cpu_to_le32(NAN_RIFS_MODE_DISALLOWED);
+
+ /* VHT basic MCS set from sband capability */
+ if (sband_5g && sband_5g->vht_cap.vht_supported)
+ phy->vht_basic_mcs_set =
+ sband_5g->vht_cap.vht_mcs.rx_mcs_map;
+
+ return mt76_mcu_send_msg(&dev->mt76, MCU_UNI_CMD(NAN),
+ &req, sizeof(req), true);
+}
+
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 c9207b5c899e..1e8f5b76fc3d 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/nan.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/nan.h
@@ -83,6 +83,7 @@ enum nan_uni_cmd_tag {
NAN_UNI_CMD_MANAGE_PEER_SCH_RECORD = 12,
NAN_UNI_CMD_MAP_STA_RECORD = 13,
NAN_UNI_CMD_UPDATE_ULW = 16,
+ NAN_UNI_CMD_UPDATE_PHY_SETTING = 18,
NAN_UNI_CMD_UPDATE_AVAILABILITY_CTRL = 20,
NAN_UNI_CMD_UPDATE_PEER_CAPABILITY = 21,
NAN_UNI_CMD_CHANGE_NMI_ADDRESS = 24,
@@ -439,6 +440,34 @@ struct mt7925_nan_sched_map_sta_rec_tlv {
u8 reserved[2];
} __packed __aligned(4);
+/* Matches FW NAN_PHY_SETTING_T (enum fields are 4 bytes on ARM) */
+struct mt7925_nan_phy_setting {
+ u8 phy_type_set;
+ u8 non_ht_basic_phy_type;
+ u8 use_short_preamble;
+ u8 use_short_slot_time;
+ __le16 operational_rate_set;
+ __le16 bss_basic_rate_set;
+ __le16 vht_basic_mcs_set;
+ u8 erp_protect_mode;
+ u8 ht_op_info1;
+ __le16 ht_op_info2;
+ __le16 ht_op_info3;
+ __le32 ht_protect_mode;
+ __le32 gf_operation_mode;
+ __le32 rifs_operation_mode;
+} __packed;
+
+/* Matches FW NAN_SCHED_CMD_UPDATE_PHY_PARAM_T */
+struct mt7925_nan_update_phy_setting_tlv {
+ __le16 tag;
+ __le16 len;
+ struct mt7925_nan_phy_setting phy_2g;
+ struct mt7925_nan_phy_setting phy_5g;
+} __packed __aligned(4);
+
+int mt7925_nan_update_phy_setting(struct mt792x_dev *dev);
+
int mt7925_nan_enable(struct ieee80211_vif *vif,
struct mt792x_dev *dev,
struct cfg80211_nan_conf *conf);
--
2.43.0
next 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 ` Sean Wang [this message]
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 ` [PATCH 15/15] wifi: mt76: mt7925: fix HT/VHT caps and rates for NAN NDP peers Sean Wang
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-14-sean.wang@kernel.org \
--to=sean.wang@kernel.org \
--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