wifi: mt76: mt7925: configure NAN PHY setting on enable

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.

Fixes: 0f3605e4f8de ("wifi: mt76: mt7925: wire up NAN operations")
Co-developed-by: Sean Wang <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Stella Liu <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Felix Fietkau <[email protected]>
This commit is contained in:
Stella Liu
2026-08-25 11:25:29 +02:00
committed by Felix Fietkau
parent 33a39c2ce2
commit c09c19fe7c
3 changed files with 108 additions and 1 deletions
+5 -1
View File
@@ -2593,8 +2593,12 @@ static int mt7925_start_nan(struct ieee80211_hw *hw,
goto out; goto out;
err = mt7925_nan_enable(vif, dev, conf); err = mt7925_nan_enable(vif, dev, conf);
if (err) if (err) {
mt7925_mcu_add_bss_info(&dev->phy, NULL, link_conf, NULL, false); mt7925_mcu_add_bss_info(&dev->phy, NULL, link_conf, NULL, false);
goto out;
}
err = mt7925_nan_update_phy_setting(dev);
out: out:
mt792x_mutex_release(dev); mt792x_mutex_release(dev);
+74
View File
@@ -193,6 +193,80 @@ mt7925_nan_sync_rssi_tlv(struct sk_buff *skb, struct cfg80211_nan_conf *conf)
return 0; 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, int mt7925_nan_enable(struct ieee80211_vif *vif,
struct mt792x_dev *dev, struct mt792x_dev *dev,
struct cfg80211_nan_conf *conf) struct cfg80211_nan_conf *conf)
+29
View File
@@ -84,6 +84,7 @@ enum nan_uni_cmd_tag {
NAN_UNI_CMD_MANAGE_PEER_SCH_RECORD = 12, NAN_UNI_CMD_MANAGE_PEER_SCH_RECORD = 12,
NAN_UNI_CMD_MAP_STA_RECORD = 13, NAN_UNI_CMD_MAP_STA_RECORD = 13,
NAN_UNI_CMD_UPDATE_ULW = 16, NAN_UNI_CMD_UPDATE_ULW = 16,
NAN_UNI_CMD_UPDATE_PHY_SETTING = 18,
NAN_UNI_CMD_UPDATE_AVAILABILITY_CTRL = 20, NAN_UNI_CMD_UPDATE_AVAILABILITY_CTRL = 20,
NAN_UNI_CMD_UPDATE_PEER_CAPABILITY = 21, NAN_UNI_CMD_UPDATE_PEER_CAPABILITY = 21,
NAN_UNI_CMD_CHANGE_NMI_ADDRESS = 24, NAN_UNI_CMD_CHANGE_NMI_ADDRESS = 24,
@@ -440,6 +441,34 @@ struct mt7925_nan_sched_map_sta_rec_tlv {
u8 reserved[2]; u8 reserved[2];
} __packed __aligned(4); } __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, int mt7925_nan_enable(struct ieee80211_vif *vif,
struct mt792x_dev *dev, struct mt792x_dev *dev,
struct cfg80211_nan_conf *conf); struct cfg80211_nan_conf *conf);