wifi: mt76: mt792x: advertise multicast management frame registration support
Subsystems (2)
PATCH 1/7 wifi: mt76: mt792x: advertise multicast management frame registration support
From: Sean Wang <[email protected]>
Advertise NL80211_EXT_FEATURE_MULTICAST_REGISTRATIONS so userspace can register to receive multicast management/action frames.
This capability is required for NAN discovery and related operations.
--- drivers/net/wireless/mediatek/mt76/mt792x_core.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/mediatek/mt76/mt792x_core.c +1 -0
@@ -678,6 +678,7 @@ int mt792x_init_wiphy(struct ieee80211_hw *hw)wiphy_ext_feature_set (wiphy,NL80211_EXT_FEATURE_BEACON_RATE_HE );wiphy_ext_feature_set (wiphy,NL80211_EXT_FEATURE_ACK_SIGNAL_SUPPORT );wiphy_ext_feature_set (wiphy,NL80211_EXT_FEATURE_CAN_REPLACE_PTK0 ); +wiphy_ext_feature_set (wiphy,NL80211_EXT_FEATURE_MULTICAST_REGISTRATIONS );ieee80211_hw_set (hw,SINGLE_SCAN_ON_ALL_BANDS );ieee80211_hw_set (hw,HAS_RATE_CONTROL );
Signature · 1 line
2.43.0
PATCH 2/7 wifi: mt76: mt7925: guard against NULL chandef in BSS RLM TLV
From: Sean Wang <[email protected]>
mt7925_mcu_bss_rlm_tlv() dereferences chandef->chan without verifying that chandef and chandef->chan are present.
While current callers normally provide a valid chandef, future call paths or partially configured interfaces may result in missing channel information and lead to a NULL pointer dereference.
Add a defensive check and bail out early when channel information is not available. This does not change behaviour for normal operation.
--- drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +9 -2
@@ -2291,11 +2291,18 @@ void mt7925_mcu_bss_rlm_tlv(struct sk_buff *skb, struct mt76_phy *phy, {struct cfg80211_chan_def *chandef = ctx ? &ctx->def : &link_conf->chanreq.oper; -int freq1 = chandef->center_freq1, freq2 = chandef->center_freq2; -enum nl80211_band band = chandef->chan->band;struct bss_rlm_tlv *req; +enum nl80211_band band; +int freq1, freq2;struct tlv *tlv; +if (WARN_ON_ONCE (!chandef || !chandef->chan)) +return ; + + freq1 = chandef->center_freq1; + freq2 = chandef->center_freq2; + band = chandef->chan->band; + tlv =mt76_connac_mcu_add_tlv (skb,UNI_BSS_INFO_RLM ,sizeof (*req)); req = (struct bss_rlm_tlv *)tlv; req->control_channel = chandef->chan->hw_value;
Signature · 1 line
2.43.0
PATCH 3/7 wifi: mt76: mt7925: guard HE 6 GHz capa lookup by HE iftype caps
In reply to Sean WangFrom: Sean Wang <[email protected]>
ieee80211_get_he_6ghz_capa() WARNs if the iftype has no sband iftype_data or lacks HE. Probe HE support first with ieee80211_get_he_iftype_cap() and only then query the 6 GHz capa. And initialize he_6ghz_capa/eht_cap to avoid uninitialized use.
--- drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +11 -4
@@ -2436,8 +2436,8 @@ mt7925_get_phy_mode_ext(struct mt76_phy *phy, struct ieee80211_vif *vif,enum nl80211_band band, struct ieee80211_link_sta *link_sta) { - struct ieee80211_he_6ghz_capa *he_6ghz_capa; -const struct ieee80211_sta_eht_cap *eht_cap; + struct ieee80211_he_6ghz_capa *he_6ghz_capa = NULL; +const struct ieee80211_sta_eht_cap *eht_cap =NULL ;__le16 capa =0 ;u8 mode =0 ;
@@ -2445,11 +2445,18 @@ mt7925_get_phy_mode_ext(struct mt76_phy *phy, struct ieee80211_vif *vif, he_6ghz_capa = &link_sta->he_6ghz_capa; eht_cap = &link_sta->eht_cap; }else { +const struct ieee80211_sta_he_cap *he_cap;struct ieee80211_supported_band *sband; sband = phy->hw->wiphy->bands[band]; - capa =ieee80211_get_he_6ghz_capa (sband, vif->type); - he_6ghz_capa = (struct ieee80211_he_6ghz_capa *)&capa; + + he_cap = (band ==NL80211_BAND_6GHZ ) ? +ieee80211_get_he_iftype_cap (sband, vif->type) :NULL ; + +if (he_cap) { + capa =ieee80211_get_he_6ghz_capa (sband, vif->type); + he_6ghz_capa = (struct ieee80211_he_6ghz_capa *)&capa; + } eht_cap =ieee80211_get_eht_iftype_cap (sband, vif->type); }
Signature · 1 line
2.43.0
PATCH 4/7 wifi: mt76: connac: add NAN connection type
In reply to Sean WangFrom: Sean Wang <[email protected]>
Introduce a dedicated NAN connection type for connac-based firmware.
This prepares driver support for NAN interfaces by allowing MCU device/BSS configuration to represent NAN roles using a distinct connection type.
No functional behaviour change yet as NAN is not exposed to userspace.
--- drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c | 11 +++++++++++ drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h | 2 ++ drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 4 ++++ 3 files changed, 17 insertions(+)
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +11 -0
@@ -422,6 +422,9 @@ void mt76_connac_mcu_sta_basic_tlv(struct mt76_dev *dev, struct sk_buff *skb, basic->conn_type =cpu_to_le32 (CONNECTION_IBSS_ADHOC ); basic->aid =cpu_to_le16 (link_sta->sta->aid);break ; +case NL80211_IFTYPE_NAN : + basic->conn_type =cpu_to_le32 (CONNECTION_NAN ); +break ;default :WARN_ON (1 );break ;
@@ -1212,6 +1215,10 @@ int mt76_connac_mcu_uni_add_dev(struct mt76_phy *phy,case NL80211_IFTYPE_ADHOC : basic_req.basic.conn_type =cpu_to_le32 (CONNECTION_IBSS_ADHOC );break ; +case NL80211_IFTYPE_NAN : + basic_req.basic.conn_type =cpu_to_le32 (CONNECTION_NAN ); + basic_req.basic.conn_state = !enable; +break ;default :WARN_ON (1 );break ;
@@ -1613,6 +1620,10 @@ int mt76_connac_mcu_uni_add_bss(struct mt76_phy *phy,case NL80211_IFTYPE_ADHOC : basic_req.basic.conn_type =cpu_to_le32 (CONNECTION_IBSS_ADHOC );break ; +case NL80211_IFTYPE_NAN : + basic_req.basic.conn_type =cpu_to_le32 (CONNECTION_NAN ); + basic_req.basic.active = enable; +break ;default :WARN_ON (1 );break ;
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +2 -0
@@ -876,6 +876,7 @@ enum {#define NETWORK_P2P BIT(17)#define NETWORK_IBSS BIT(18)#define NETWORK_WDS BIT(21) +#define NETWORK_NAN BIT(22)#define SCAN_FUNC_RANDOM_MAC BIT(0)#define SCAN_FUNC_RNR_SCAN BIT(3)
@@ -888,6 +889,7 @@ enum {#define CONNECTION_IBSS_ADHOC (STA_TYPE_ADHOC | NETWORK_IBSS)#define CONNECTION_WDS (STA_TYPE_WDS | NETWORK_WDS)#define CONNECTION_INFRA_BC (STA_TYPE_BC | NETWORK_INFRA) +#define CONNECTION_NAN (NETWORK_NAN)#define CONN_STATE_DISCONNECT 0#define CONN_STATE_CONNECT 1
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +4 -0
@@ -2563,6 +2563,10 @@ mt7925_mcu_bss_basic_tlv(struct sk_buff *skb, basic_req->conn_type =cpu_to_le32 (CONNECTION_IBSS_ADHOC ); basic_req->active = true;break ; +case NL80211_IFTYPE_NAN : + basic_req->conn_type =cpu_to_le32 (CONNECTION_NAN ); + basic_req->active = enable; +break ;default :WARN_ON (1 );break ;
Signature · 1 line
2.43.0
PATCH 5/7 wifi: mt76: mt7925: add NAN MCU ABI and basic cmd/event support
In reply to Sean WangFrom: Sean Wang <[email protected]>
Add initial Neighbor Awareness Networking (NAN) MCU ABI definitions for mt7925 and implement basic NAN control commands.
This introduces NAN command TLVs for enable/disable/configure, plus event parsing for NAN discovery engine indications. The new code also adds helper logic for configuring DW interval, cluster ID, RSSI thresholds and social channel scan parameters.
This change only adds the firmware-facing ABI and command/event plumbing; it does not yet adapt or expose NAN functionality to upper layers (cfg80211/mac80211) in mt76. Upper-layer integration will follow in subsequent patches.
--- .../wireless/mediatek/mt76/mt76_connac_mcu.h | 2 + .../wireless/mediatek/mt76/mt7925/Makefile | 2 +- .../net/wireless/mediatek/mt76/mt7925/mcu.c | 6 +- .../net/wireless/mediatek/mt76/mt7925/nan.c | 386 ++++++++++++++++++ .../net/wireless/mediatek/mt76/mt7925/nan.h | 200 +++++++++ .../net/wireless/mediatek/mt76/mt7925/regd.c | 30 ++ .../net/wireless/mediatek/mt76/mt7925/regd.h | 3 + 7 files changed, 627 insertions(+), 2 deletions(-) create mode 100644 drivers/net/wireless/mediatek/mt76/mt7925/nan.c create mode 100644 drivers/net/wireless/mediatek/mt76/mt7925/nan.h
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +2 -0
@@ -1075,6 +1075,7 @@ enum {MCU_UNI_EVENT_THERMAL =0x35 ,MCU_UNI_EVENT_RSSI_MONITOR =0x41 ,MCU_UNI_EVENT_NIC_CAPAB =0x43 , +MCU_UNI_EVENT_NAN =0x56 ,MCU_UNI_EVENT_WED_RRO =0x57 ,MCU_UNI_EVENT_PER_STA_INFO =0x6d , MCU_UNI_EVENT_ALL_STA_INFO = 0x6e,
@@ -1314,6 +1315,7 @@ enum {MCU_UNI_CMD_FIXED_RATE_TABLE =0x40 ,MCU_UNI_CMD_RSSI_MONITOR =0x41 ,MCU_UNI_CMD_TESTMODE_CTRL =0x46 , +MCU_UNI_CMD_NAN =0x56 ,MCU_UNI_CMD_RRO =0x57 ,MCU_UNI_CMD_OFFCH_SCAN_CTRL =0x58 , MCU_UNI_CMD_PER_STA_INFO = 0x6d,
drivers/net/wireless/mediatek/mt76/mt7925/Makefile +1 -1
@@ -4,7 +4,7 @@ obj-$(CONFIG_MT7925_COMMON) += mt7925-common.o obj-$(CONFIG_MT7925E) += mt7925e.o obj-$(CONFIG_MT7925U) += mt7925u.o -mt7925-common-y := mac.o mcu.o regd.o main.o init.o debugfs.o +mt7925-common-y := mac.o mcu.o regd.o main.o init.o debugfs.o nan.o mt7925-common-$(CONFIG_NL80211_TESTMODE) += testmode.o mt7925e-y := pci.o pci_mac.o pci_mcu.o mt7925u-y := usb.o
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +5 -1
@@ -7,6 +7,7 @@#include "regd.h" #include "mcu.h" #include "mac.h" +#include "nan.h" #define MT_STA_BFER BIT(0)#define MT_STA_BFEE BIT(1)
@@ -37,7 +38,8 @@ int mt7925_mcu_parse_response(struct mt76_dev *mdev, int cmd, cmd == MCU_UNI_CMD(BSS_INFO_UPDATE) || cmd == MCU_UNI_CMD(STA_REC_UPDATE) || cmd == MCU_UNI_CMD(OFFLOAD) || - cmd == MCU_UNI_CMD(SUSPEND)) { + cmd == MCU_UNI_CMD(SUSPEND) || + cmd == MCU_UNI_CMD(NAN)) {struct mt7925_mcu_uni_event *event;skb_pull (skb,sizeof (*rxd));
@@ -600,6 +602,8 @@ mt7925_mcu_uni_rx_unsolicited_event(struct mt792x_dev *dev, dev->fw_assert = true;mt76_connac_mcu_coredump_event (&dev->mt76, skb, &dev->coredump);return ; +case MCU_UNI_EVENT_NAN : +mt7925_nan_mcu_event (dev, skb);default :break ; }
drivers/net/wireless/mediatek/mt76/mt7925/nan.c new file +386 -0
386 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt7925/nan.h new file +200 -0
200 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt7925/regd.c +30 -0
@@ -217,6 +217,36 @@ mt7925_regd_is_valid_alpha2(const char *alpha2)return false; } +bool +mt7925_regd_is_valid_channel (struct mt792x_dev *dev, +enum nl80211_band band, +struct ieee80211_channel *chan) +{ +struct ieee80211_hw *hw =mt76_hw (dev); +struct wiphy *wiphy = hw->wiphy; +struct ieee80211_supported_band *sband; +struct ieee80211_channel *ch; +int i; + +if (!chan) +return false; + + sband = wiphy->bands[band]; +if (!sband) +return false; + +for (i =0 ; i < sband->n_channels; i++) { + ch = &sband->channels[i]; + +if (ch->hw_value == chan->hw_value && + ((ch->flags &IEEE80211_CHAN_DISABLED ) ==0 )) +return true; + } + +return false; +} +EXPORT_SYMBOL_GPL (mt7925_regd_is_valid_channel); +int mt7925_regd_change (struct mt792x_phy *phy,char *alpha2) {struct wiphy *wiphy = phy->mt76->hw->wiphy;
drivers/net/wireless/mediatek/mt76/mt7925/regd.h +3 -0
@@ -13,6 +13,9 @@ void mt7925_regd_be_ctrl(struct mt792x_dev *dev, u8 *alpha2);void mt7925_regd_notifier (struct wiphy *wiphy,struct regulatory_request *req);bool mt7925_regd_clc_supported (struct mt792x_dev *dev);int mt7925_regd_change (struct mt792x_phy *phy,char *alpha2); +bool mt7925_regd_is_valid_channel (struct mt792x_dev *dev, +enum nl80211_band band, +struct ieee80211_channel *chan);int mt7925_regd_init (struct mt792x_phy *phy);#endif
Signature · 1 line
2.43.0
PATCH 6/7 wifi: mt76: mt7925: add mac80211 NAN start/stop/change_conf ops
In reply to Sean WangFrom: Sean Wang <[email protected]>
Wire mac80211 NAN start/stop/change_conf callbacks to mt7925 NAN MCU enable/disable/config. Track the active NAN vif and notify mac80211 on cluster join events.
--- .../net/wireless/mediatek/mt76/mt7925/main.c | 69 +++++++++++++++++++ .../net/wireless/mediatek/mt76/mt7925/nan.c | 7 ++ drivers/net/wireless/mediatek/mt76/mt792x.h | 2 + 3 files changed, 78 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7925/main.c +69 -0
@@ -11,6 +11,7 @@#include "regd.h" #include "mcu.h" #include "mac.h" +#include "nan.h" static void mt7925_init_he_caps(struct mt792x_phy *phy, enum nl80211_band band,
@@ -442,6 +443,8 @@ mt7925_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)INIT_WORK (&mvif->csa_work, mt7925_csa_work);timer_setup (&mvif->csa_timer, mt792x_csa_timer,0 ); +if (vif->type ==NL80211_IFTYPE_NAN ) + dev->nan_vif = vif; out:mt792x_mutex_release (dev);
@@ -2297,6 +2300,69 @@ static void mt7925_channel_switch_rx_beacon(struct ieee80211_hw *hw, } } +static int mt7925_start_nan (struct ieee80211_hw *hw, +struct ieee80211_vif *vif, +struct cfg80211_nan_conf *conf) +{ +struct mt792x_dev *dev =mt792x_hw_dev (hw); +struct ieee80211_bss_conf *link_conf = &vif->bss_conf; +int err =0 ; + +mt792x_mutex_acquire (dev); + + link_conf->chanreq.oper.chan = conf->band_cfgs[NL80211_BAND_2GHZ ].chan; + + err =mt7925_mcu_add_bss_info (&dev->phy,NULL , link_conf, +NULL , true); +if (err <0 ) + goto out; + + err =mt7925_nan_enable (vif, dev, conf); + +out: +mt792x_mutex_release (dev); + +return err; +} + +static int mt7925_stop_nan (struct ieee80211_hw *hw, +struct ieee80211_vif *vif) +{ +struct ieee80211_bss_conf *link_conf = &vif->bss_conf; +struct mt792x_dev *dev =mt792x_hw_dev (hw); +int err =0 ; + +mt792x_mutex_acquire (dev); + + err =mt7925_nan_disable (vif, dev); +if (err <0 ) + goto out; + + err =mt7925_mcu_add_bss_info (&dev->phy,NULL , link_conf, +NULL , false); +out: +mt792x_mutex_release (dev); + +return err; +} + +static int mt7925_nan_change_conf (struct ieee80211_hw *hw, +struct ieee80211_vif *vif, +struct cfg80211_nan_conf *conf, +u32 changes) +{ +struct mt792x_dev *dev =mt792x_hw_dev (hw); +int err =0 ; + +mt792x_mutex_acquire (dev); + + err =mt7925_nan_change_configure (vif, dev, conf); + +mt792x_mutex_release (dev); + +return err; +} +const struct ieee80211_ops mt7925_ops = { .tx = mt792x_tx, .start = mt7925_start,
@@ -2366,6 +2432,9 @@ const struct ieee80211_ops mt7925_ops = { .channel_switch = mt7925_channel_switch, .abort_channel_switch = mt7925_abort_channel_switch, .channel_switch_rx_beacon = mt7925_channel_switch_rx_beacon, + .start_nan = mt7925_start_nan, + .stop_nan = mt7925_stop_nan, + .nan_change_conf = mt7925_nan_change_conf, };EXPORT_SYMBOL_GPL (mt7925_ops);
drivers/net/wireless/mediatek/mt76/mt7925/nan.c +7 -0
@@ -344,11 +344,18 @@ mt7925_nan_mcu_handle_de_event(struct mt792x_dev *dev, struct tlv *tlv)if (de_evt->event_type !=NAN_EVENT_ID_JOINED_CLUSTER )return ; +if (!ieee80211_vif_nan_started (dev->nan_vif)) { +dev_warn (dev->mt76.dev,"nan: joined-cluster event but NAN not started\n" ); +return ; + } +dev_dbg (dev->mt76.dev,"nan: anchor_master_rank=%*phN\n" ,NAN_ANCHOR_MASTER_RANK_NUM , de_evt->anchor_master_rank);dev_dbg (dev->mt76.dev,"nan: own_nmi=%pM master_nmi=%pM\n" , de_evt->own_nmi, de_evt->master_nmi); + +ieee80211_nan_cluster_joined (dev->nan_vif, cluster_id, true,GFP_KERNEL ); }void mt7925_nan_mcu_event (struct mt792x_dev *dev,struct sk_buff *skb)
drivers/net/wireless/mediatek/mt76/mt792x.h +2 -0
@@ -261,6 +261,8 @@ struct mt792x_dev {u32 backup_l2;struct ieee80211_chanctx_conf *new_ctx; + +struct ieee80211_vif *nan_vif; }; static inline struct mt792x_bss_conf *
Signature · 1 line
2.43.0
PATCH 7/7 wifi: mt76: mt792x: build iface combinations dynamically for optional NAN
In reply to Sean WangFrom: Sean Wang <[email protected]>
Expose NAN capability only when supported by firmware. Split chanctx interface combinations into base and NAN sets and dynamically append NAN combinations when available.
--- drivers/net/wireless/mediatek/mt76/mt792x.h | 4 + .../net/wireless/mediatek/mt76/mt792x_core.c | 113 ++++++++++++++++-- 2 files changed, 109 insertions(+), 8 deletions(-)
drivers/net/wireless/mediatek/mt76/mt792x.h +4 -0
@@ -23,6 +23,7 @@#define MT792x_CFEND_RATE_11B 0x03/* 11B LP, 11M */ #define MT792x_FW_TAG_FEATURE 4 +#define MT792x_FW_CAP_NAN BIT(5)#define MT792x_FW_CAP_CNM BIT(7)#define MT792x_CHIP_CAP_CLC_EVT_EN BIT(0)
@@ -263,6 +264,9 @@ struct mt792x_dev {struct ieee80211_chanctx_conf *new_ctx;struct ieee80211_vif *nan_vif; + +const struct ieee80211_iface_combination *iface_combinations; +int n_iface_combinations; }; static inline struct mt792x_bss_conf *
drivers/net/wireless/mediatek/mt76/mt792x_core.c +105 -8
151 lines not on this page · raw message
Signature · 1 line
2.43.0