wifi: mt76: mt7925: add MLO hybrid and EMLSR support
Subsystems (3)
cover wifi: mt76: mt7925: add MLO hybrid and EMLSR support
This series adds station-mode multi-link operation to the mt7925 driver:
three-link hybrid MLO (one link per band) and EMLSR for APs on a vendor OUI allowlist. Hybrid MLO and EMLSR are gated by the chip capabilities the firmware reports.
Patches 1-8 fix the basic rate sent in the STA phy TLV and a sub-link memory leak on disconnect, both with Fixes tags, then prepare the series with no functional change: named constants for chip_cap, the DBDC band and the HT secondary channel offset, a link STA wcid unwind helper, and a gated mt792x_mcu_set_dev_active() also used by mt7921.
Patches 9-10 deactivate the DEV and BSS on disconnect and reactivate the DEV before a reconnect, scan or off-channel operation. This covers the MLO to legacy switch fixed by commit 8f9e5807671e ("wifi: mt76: mt7925:
restore the legacy BSS after MLO teardown") and replaces its BSS re-add.
Patches 11-19 add the firmware interfaces the link setup needs (the third-link band limit, the EMLSR OUI allowlist and a multi-link remain-on-channel) and keep the MLD consistent as links are added. Patch 14 replaces the pending link parameter of commit dd3f17ef69ed ("wifi: mt76: mt7925: keep MLD membership consistent during link add").
Patches 20-28 bring up all links at authorization with one MLO ROC, install the existing keys on the added links, apply the link state the firmware reports, remap hybrid MLO TX to the primary link OMAC, and add a hm_alg_ctrl debugfs file to override the firmware link plan.
The series is based on mt76 commit 8739e5b44b23 ("wifi: mt76: connac:
bound the scan IEs in mt76_connac_mcu_hw_scan()").
Emery Hsin (28):
wifi: mt76: mt7925: fix the basic rate sent in the STA phy TLV
wifi: mt76: mt7925: fix MLO sub-link memory leak on disconnect
wifi: mt76: mt792x: turn chip_cap bits into an enum of bit positions
wifi: mt76: mt792x: use named constants for the DBDC band
wifi: mt76: use named constants for the HT secondary channel offset
wifi: mt76: mt7925: factor out mt7925_mac_link_sta_free_wcid()
wifi: mt76: mt792x: add a gated mt792x_mcu_set_dev_active() helper
wifi: mt76: mt792x: route DEV (de)activation through
mt792x_mcu_set_dev_active()
wifi: mt76: mt7925: deactivate the DEV and BSS on disconnect
wifi: mt76: mt7925: reactivate the DEV before (re)connect, scan and
off-channel
wifi: mt76: mt7925: parse the FW hybrid-MLO third-link band limit
wifi: mt76: mt7925: gate EMLSR by AP vendor OUI allowlist
wifi: mt76: mt7925: support multi-link hybrid/EMLSR remain-on-channel
wifi: mt76: mt7925: describe the whole MLD in the STA/BSS MLD TLVs
wifi: mt76: mt7925: assign a per-MLD firmware link index
wifi: mt76: mt7925: share the primary OMAC across MLO links
wifi: mt76: mt7925: carry the STA decap offload to later links
wifi: mt76: mt7925: split link sta add into alloc and commit phases
wifi: mt76: mt7925: publish every link before sending any STA_REC
wifi: mt76: mt7925: add mt7925_mcu_add_bss_sec() helper
wifi: mt76: mt7925: only refresh the SEC tag when setting the first
key
wifi: mt76: mt7925: add mt7925_set_links_key_iter() helper
wifi: mt76: mt7925: bring up all MLO links on authorization
wifi: mt76: mt7925: skip re-adding the primary MLD BSS_INFO in chanctx
ops
wifi: mt76: mt7925: apply FW-reported MLO link state
wifi: mt76: mt7925: remap hybrid-MLO TX to the primary link OMAC
wifi: mt76: mt7925: clear the MLD BSS tag on deactivate
wifi: mt76: mt7925: add hm_alg_ctrl debugfs to override the MLO link
plan
.../wireless/mediatek/mt76/mt76_connac_mcu.c | 4 +- .../wireless/mediatek/mt76/mt76_connac_mcu.h | 2 + .../net/wireless/mediatek/mt76/mt7921/mac.c | 7 +- .../net/wireless/mediatek/mt76/mt7921/main.c | 9 +- .../net/wireless/mediatek/mt76/mt7921/mcu.c | 14 +- .../net/wireless/mediatek/mt76/mt7921/pci.c | 2 +- .../net/wireless/mediatek/mt76/mt7921/regd.c | 4 +- .../net/wireless/mediatek/mt76/mt7921/regd.h | 2 +- .../wireless/mediatek/mt76/mt7925/debugfs.c | 41 + .../net/wireless/mediatek/mt76/mt7925/mac.c | 23 +- .../net/wireless/mediatek/mt76/mt7925/main.c | 843 +++++++++++++----- .../net/wireless/mediatek/mt76/mt7925/mcu.c | 628 +++++++++---- .../net/wireless/mediatek/mt76/mt7925/mcu.h | 26 +- .../wireless/mediatek/mt76/mt7925/mt7925.h | 33 +- .../net/wireless/mediatek/mt76/mt7925/pci.c | 4 +- .../net/wireless/mediatek/mt76/mt7925/regd.c | 4 +- .../net/wireless/mediatek/mt76/mt7925/regd.h | 2 +- drivers/net/wireless/mediatek/mt76/mt792x.h | 56 +- .../net/wireless/mediatek/mt76/mt792x_core.c | 23 +- 19 files changed, 1251 insertions(+), 476 deletions(-)
Signature · 1 line
2.45.2
PATCH 1/28 wifi: mt76: mt7925: fix the basic rate sent in the STA phy TLV
phy->basic_rate was set from link_conf->basic_rates, a mac80211 band-relative index, but the firmware reads it as an absolute HW rate-set and pinned the MMPDU rate to CCK 1M (illegal on 5/6 GHz). Send the band's HW basic-rate set instead, like the BMC path.
--- drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +3 -1
@@ -2059,7 +2059,9 @@ mt7925_mcu_sta_phy_tlv(struct sk_buff *skb, link_sta); } - phy->basic_rate =cpu_to_le16 ((u16 )link_conf->basic_rates); +/* Firmware expects the HW basic-rate bitmap, not mac80211's band-relative one. */ + phy->basic_rate =cpu_to_le16 (chandef->chan->band ==NL80211_BAND_2GHZ ? +HR_DSSS_ERP_BASIC_RATE :OFDM_BASIC_RATE );if (link_sta->ht_cap.ht_supported) { af = link_sta->ht_cap.ampdu_factor; mm = link_sta->ht_cap.ampdu_density;
Signature · 1 line
2.45.2
PATCH 2/28 wifi: mt76: mt7925: fix MLO sub-link memory leak on disconnect
In reply to Emery Hsinmt7925_change_vif_links() resolved removed links through mt792x_vif_to_link(), which falls back to the deflink after mac80211 clears vif->valid_links, so sub-link mconf/mlink were leaked.
--- drivers/net/wireless/mediatek/mt76/mt7925/main.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/main.c +8 -4
@@ -2383,14 +2383,18 @@ mt7925_change_vif_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif,mt792x_mutex_acquire (dev);for_each_set_bit (link_id, &rem,IEEE80211_MLD_MAX_NUM_LINKS ) { - mconf =mt792x_vif_to_link (mvif, link_id); - mlink =mt792x_sta_to_link (&mvif->sta, link_id); + mconf =rcu_access_pointer (mvif->link_conf[link_id]); + mlink =rcu_access_pointer (mvif->sta.link[link_id]);if (!mconf || !mlink)continue ; -if (mconf != &mvif->bss_conf) { -mt792x_mac_link_bss_remove (dev, mconf, mlink); +if (link_id != mvif->deflink_id) { +/* STATION already deactivated the sub-link FW BSS in +* mt7925_mac_sta_remove(); AP has no such path. +*/ +if (vif->type !=NL80211_IFTYPE_STATION ) +mt792x_mac_link_bss_remove (dev, mconf, mlink);mt7925_p2p_bmc_remove (dev, mconf);devm_kfree (dev->mt76.dev, mconf);devm_kfree (dev->mt76.dev, mlink);
Signature · 1 line
2.45.2
PATCH 3/28 wifi: mt76: mt792x: turn chip_cap bits into an enum of bit positions
In reply to Emery HsinReplace the MT792x_CHIP_CAP_* shifted-mask #defines with an enum of bit positions, tested with BIT(): chip_cap & BIT(MT792x_CHIP_CAP_x). New bits can be added by index without hand-shifting masks.
No functional change.
This is a preparation patch before the MT7925 MLO hybrid/EMLSR work.
--- .../net/wireless/mediatek/mt76/mt7921/main.c | 4 ++-- .../net/wireless/mediatek/mt76/mt7921/mcu.c | 2 +- .../net/wireless/mediatek/mt76/mt7921/pci.c | 2 +- .../net/wireless/mediatek/mt76/mt7921/regd.c | 4 ++-- .../net/wireless/mediatek/mt76/mt7921/regd.h | 2 +- .../net/wireless/mediatek/mt76/mt7925/main.c | 6 ++--- .../net/wireless/mediatek/mt76/mt7925/mcu.c | 2 +- .../net/wireless/mediatek/mt76/mt7925/pci.c | 4 ++-- .../net/wireless/mediatek/mt76/mt7925/regd.c | 4 ++-- .../net/wireless/mediatek/mt76/mt7925/regd.h | 2 +- drivers/net/wireless/mediatek/mt76/mt792x.h | 22 ++++++++++++------- 11 files changed, 30 insertions(+), 24 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7921/main.c +2 -2
@@ -260,7 +260,7 @@ int __mt7921_start(struct mt792x_phy *phy)return err; } -if (phy->chip_cap & MT792x_CHIP_CAP_WF_RF_PIN_CTRL_EVT_EN) { +if (phy->chip_cap &BIT (MT792x_CHIP_CAP_WF_RF_PIN_CTRL_EVT_EN)) {mt7921_mcu_wf_rf_pin_ctrl (phy,WF_RF_PIN_INIT );wiphy_rfkill_start_polling (mphy->hw->wiphy); }
@@ -348,7 +348,7 @@ mt7921_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) } vif->driver_flags |=IEEE80211_VIF_BEACON_FILTER ; -if (phy->chip_cap & MT792x_CHIP_CAP_RSSI_NOTIFY_EVT_EN) +if (phy->chip_cap &BIT (MT792x_CHIP_CAP_RSSI_NOTIFY_EVT_EN)) vif->driver_flags |=IEEE80211_VIF_SUPPORTS_CQM_RSSI ;INIT_WORK (&mvif->csa_work, mt7921_csa_work);
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +1 -1
@@ -1417,7 +1417,7 @@ int __mt7921_mcu_set_clc(struct mt792x_dev *dev, u8 *alpha2,if (!clc)return 0 ; -if (dev->phy.chip_cap & MT792x_CHIP_CAP_CLC_EVT_EN) +if (dev->phy.chip_cap &BIT (MT792x_CHIP_CAP_CLC_EVT_EN)) req.cap |=CLC_CAP_EVT_EN ; np =mt76_find_power_limits_node (&dev->mt76);
drivers/net/wireless/mediatek/mt76/mt7921/pci.c +1 -1
@@ -47,7 +47,7 @@ static void mt7921e_unregister_device(struct mt792x_dev *dev)struct pci_dev *pdev =to_pci_dev (dev->mt76.dev);struct ieee80211_hw *hw =mt76_hw (dev); -if (dev->phy.chip_cap & MT792x_CHIP_CAP_WF_RF_PIN_CTRL_EVT_EN) +if (dev->phy.chip_cap &BIT (MT792x_CHIP_CAP_WF_RF_PIN_CTRL_EVT_EN))wiphy_rfkill_stop_polling (hw->wiphy);mt7921_unregister_device (dev);
drivers/net/wireless/mediatek/mt76/mt7921/regd.c +2 -2
@@ -392,7 +392,7 @@ int mt7921_regd_change(struct mt792x_phy *phy, char *alpha2)if (MT7921_REGD_SUPPORTED (phy))return mt7921_regd_update (phy, alpha2); -else if (phy->chip_cap & MT792x_CHIP_CAP_11D_EN) +else if (phy->chip_cap &BIT (MT792x_CHIP_CAP_11D_EN))return regulatory_hint (wiphy, alpha2);else return mt7921_mcu_set_clc (dev, alpha2,ENVIRON_INDOOR );
@@ -409,7 +409,7 @@ int mt7921_regd_init(struct mt792x_phy *phy) wiphy->regulatory_flags |=REGULATORY_WIPHY_SELF_MANAGED |REGULATORY_DISABLE_BEACON_HINTS ;return mt7921_regd_update (phy,"00" ); - }else if (phy->chip_cap & MT792x_CHIP_CAP_11D_EN) + }else if (phy->chip_cap &BIT (MT792x_CHIP_CAP_11D_EN)) wiphy->regulatory_flags |=REGULATORY_COUNTRY_IE_IGNORE |REGULATORY_DISABLE_BEACON_HINTS ;else
drivers/net/wireless/mediatek/mt76/mt7921/regd.h +1 -1
@@ -53,7 +53,7 @@ struct mt7921_regd_query_req { };#define MT7921_REGD_SUPPORTED (phy) \ - (((phy)->chip_cap & MT792x_CHIP_CAP_REGD_EN) && \ + (((phy)->chip_cap & BIT(MT792x_CHIP_CAP_FWREGDCH_EN)) && \ (phy)->clc[MT792x_CLC_REGD]) int mt7921_mcu_regd_update(struct mt792x_dev *dev, u8 *alpha2,
drivers/net/wireless/mediatek/mt76/mt7925/main.c +3 -3
@@ -282,7 +282,7 @@ int mt7925_init_mlo_caps(struct mt792x_phy *phy) }, }; -if (!(phy->chip_cap & MT792x_CHIP_CAP_MLO_EN)) +if (!(phy->chip_cap &BIT (MT792x_CHIP_CAP_MLO_EN)))return 0 ; ext_capab[0 ].eml_capabilities = phy->eml_cap;
@@ -357,7 +357,7 @@ int __mt7925_start(struct mt792x_phy *phy)ieee80211_queue_delayed_work (mphy->hw, &mphy->mac_work, MT792x_WATCHDOG_TIME); -if (phy->chip_cap & MT792x_CHIP_CAP_WF_RF_PIN_CTRL_EVT_EN) +if (phy->chip_cap &BIT (MT792x_CHIP_CAP_WF_RF_PIN_CTRL_EVT_EN))wiphy_rfkill_start_polling (mphy->hw->wiphy);return 0 ;
@@ -483,7 +483,7 @@ mt7925_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) goto out; vif->driver_flags |=IEEE80211_VIF_BEACON_FILTER ; -if (phy->chip_cap & MT792x_CHIP_CAP_RSSI_NOTIFY_EVT_EN) +if (phy->chip_cap &BIT (MT792x_CHIP_CAP_RSSI_NOTIFY_EVT_EN)) vif->driver_flags |=IEEE80211_VIF_SUPPORTS_CQM_RSSI ;INIT_WORK (&mvif->csa_work, mt7925_csa_work);
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +1 -1
@@ -3065,7 +3065,7 @@ mt7925_mcu_bss_mld_tlv(struct sk_buff *skb, mld->own_mld_id = mconf->mt76.idx +32 ; mld->remap_idx =0xff ; -if (phy->chip_cap & MT792x_CHIP_CAP_MLO_EML_EN) { +if (phy->chip_cap &BIT (MT792x_CHIP_CAP_MLO_EML_EN)) { mld->eml_enable = !!(link_conf->vif->cfg.eml_cap &IEEE80211_EML_CAP_EMLSR_SUPP ); }else {
drivers/net/wireless/mediatek/mt76/mt7925/pci.c +2 -2
@@ -45,7 +45,7 @@ static int mt7925e_init_reset(struct mt792x_dev *dev)*/ void mt7925e_axidma_cal_cache_init (struct mt792x_dev *dev) { -if (!(dev->phy.chip_cap & MT792x_CHIP_CAP_AXIDMA_EN)) +if (!(dev->phy.chip_cap &BIT (MT792x_CHIP_CAP_AXIDMA_EN)))return ;if (dev->cached_cal.va) {
@@ -101,7 +101,7 @@ static void mt7925e_unregister_device(struct mt792x_dev *dev)struct mt76_connac_pm *pm = &dev->pm;struct ieee80211_hw *hw =mt76_hw (dev); -if (dev->phy.chip_cap & MT792x_CHIP_CAP_WF_RF_PIN_CTRL_EVT_EN) +if (dev->phy.chip_cap &BIT (MT792x_CHIP_CAP_WF_RF_PIN_CTRL_EVT_EN))wiphy_rfkill_stop_polling (hw->wiphy);cancel_work_sync (&dev->init_work);
drivers/net/wireless/mediatek/mt76/mt7925/regd.c +2 -2
@@ -450,7 +450,7 @@ int mt7925_regd_change(struct mt792x_phy *phy, char *alpha2)if (MT7925_REGD_SUPPORTED (phy)) {return mt7925_regd_update (phy, alpha2); - }else if (phy->chip_cap & MT792x_CHIP_CAP_11D_EN) { + }else if (phy->chip_cap &BIT (MT792x_CHIP_CAP_11D_EN)) {return regulatory_hint (wiphy, alpha2); }else {return mt7925_mcu_set_clc (dev, alpha2,ENVIRON_INDOOR );
@@ -469,7 +469,7 @@ int mt7925_regd_init(struct mt792x_phy *phy) wiphy->regulatory_flags |=REGULATORY_WIPHY_SELF_MANAGED |REGULATORY_DISABLE_BEACON_HINTS ;return mt7925_regd_update (phy,"00" ); - }else if (phy->chip_cap & MT792x_CHIP_CAP_11D_EN) { + }else if (phy->chip_cap &BIT (MT792x_CHIP_CAP_11D_EN)) { wiphy->regulatory_flags |=REGULATORY_COUNTRY_IE_IGNORE |REGULATORY_DISABLE_BEACON_HINTS ; }else {
drivers/net/wireless/mediatek/mt76/mt7925/regd.h +1 -1
@@ -56,7 +56,7 @@ struct mt7925_regd_query_req { };#define MT7925_REGD_SUPPORTED (phy) \ - (((phy)->chip_cap & MT792x_CHIP_CAP_REGD_EN) && \ + (((phy)->chip_cap & BIT(MT792x_CHIP_CAP_FWREGDCH_EN)) && \ (phy)->clc[MT792x_CLC_REGD]) int mt7925_mcu_regd_update(struct mt792x_dev *dev, u8 *alpha2,
drivers/net/wireless/mediatek/mt76/mt792x.h +14 -8
@@ -26,14 +26,20 @@#define MT792x_FW_CAP_NAN BIT(5)#define MT792x_FW_CAP_CNM BIT(7) -#define MT792x_CHIP_CAP_CLC_EVT_EN BIT(0) -#define MT792x_CHIP_CAP_RSSI_NOTIFY_EVT_EN BIT(1) -#define MT792x_CHIP_CAP_WF_RF_PIN_CTRL_EVT_EN BIT(3) -#define MT792x_CHIP_CAP_11D_EN BIT(4) -#define MT792x_CHIP_CAP_REGD_EN BIT(5) -#define MT792x_CHIP_CAP_MLO_EN BIT(8) -#define MT792x_CHIP_CAP_MLO_EML_EN BIT(9) -#define MT792x_CHIP_CAP_AXIDMA_EN BIT(16) +/* Chip capability bit positions reported by firmware. +* Use with BIT(): chip_cap & BIT(MT792x_CHIP_CAP_x). +*/ +enum mt792x_chip_cap { + MT792x_CHIP_CAP_CLC_EVT_EN =0 ,/* FWREGD_EVENT_SUPPORT */ + MT792x_CHIP_CAP_RSSI_NOTIFY_EVT_EN =1 , + MT792x_CHIP_CAP_WF_RF_PIN_CTRL_EVT_EN =3 , + MT792x_CHIP_CAP_11D_EN =4 ,/* WF_DYNAMIC_11D_SUPPORT */ + MT792x_CHIP_CAP_FWREGDCH_EN =5 ,/* WF_REGDCH_SUPPORT */ + MT792x_CHIP_CAP_MLO_EN =8 ,/* MLO_MLSR_SUPPORT */ + MT792x_CHIP_CAP_MLO_EML_EN =9 ,/* MLO_EMLSR_SUPPORT */ + MT792x_CHIP_CAP_MLO_HYBRID_EN =10 ,/* MLO_HYBRID_SUPPORT */ + MT792x_CHIP_CAP_AXIDMA_EN =16 ,/* WF_AXIDMA_SUPPORT */ +};/* NOTE: used to map mt76_rates. idx may change if firmware expands table */ #define MT792x_BASIC_RATES_TBL 14
Signature · 1 line
2.45.2
PATCH 4/28 wifi: mt76: mt792x: use named constants for the DBDC band
In reply to Emery HsinReplace the hard-coded 0xfe/0xff DBDC band values with a shared mt792x_band_idx enum, covering the host band_idx and the mt7925/mt7921 ROC command band fields. No functional change.
This is a preparation patch before the MT7925 MLO hybrid/EMLSR work.
--- drivers/net/wireless/mediatek/mt76/mt7921/mcu.c | 4 ++-- drivers/net/wireless/mediatek/mt76/mt7925/mac.c | 2 +- drivers/net/wireless/mediatek/mt76/mt7925/main.c | 4 ++-- drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 12 ++++++------ drivers/net/wireless/mediatek/mt76/mt792x.h | 12 ++++++++++++ 5 files changed, 23 insertions(+), 11 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +2 -2
@@ -875,7 +875,7 @@ int mt7921_mcu_set_roc(struct mt792x_phy *phy, struct mt792x_vif *vif, .bw_from_ap = CMD_CBW_20MHZ, .center_chan = center_ch, .center_chan_from_ap = center_ch, - .dbdcband = 0xff, /* auto */ + .dbdcband = MT792x_BAND_AUTO, }, };
@@ -922,7 +922,7 @@ int mt7921_mcu_abort_roc(struct mt792x_phy *phy, struct mt792x_vif *vif, .len = cpu_to_le16(sizeof(struct roc_abort_tlv)), .tokenid = token_id, .bss_idx = vif->bss_conf.mt76.idx, - .dbdcband = 0xff, /* auto*/ + .dbdcband = MT792x_BAND_AUTO, }, };
drivers/net/wireless/mediatek/mt76/mt7925/mac.c +1 -1
@@ -800,7 +800,7 @@ mt7925_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi,FIELD_PREP (MT_TXD1_OWN_MAC , omac_idx);/* 0xff means BAND_AUTO to the firmware, and TGID cannot encode it */ -if (band_idx && band_idx !=0xff ) +if (band_idx && band_idx != MT792x_BAND_AUTO) val |=FIELD_PREP (MT_TXD1_TGID , band_idx); txwi[1 ] =cpu_to_le32 (val);
drivers/net/wireless/mediatek/mt76/mt7925/main.c +2 -2
@@ -399,7 +399,7 @@ static int mt7925_mac_link_bss_add(struct mt792x_dev *dev, mconf->mt76.omac_idx =ieee80211_vif_is_mld (vif) ?0 : mconf->mt76.idx; - mconf->mt76.band_idx =0xff ; + mconf->mt76.band_idx = MT792x_BAND_AUTO; mconf->absent = false;
@@ -2075,7 +2075,7 @@ mt7925_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif,if (!err) roc_taken = true;else if (!is_mt7927 (&dev->mt76)) - mconf->mt76.band_idx =0xff ; + mconf->mt76.band_idx = MT792x_BAND_AUTO; } err = mt7925_mcu_add_bss_info(&dev->phy, mconf->mt76.ctx,
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +6 -6
@@ -1592,10 +1592,10 @@ int mt7925_mcu_set_mlo_roc(struct mt792x_phy *phy, struct mt792x_bss_conf *mconf req.roc[i].center_chan2 =0 ; req.roc[i].center_chan2_from_ap =0 ; -/* STR : 0xfe indicates BAND_ALL with enabling DBDC -* EMLSR : 0xff indicates (BAND_AUTO) without DBDC -*/ - req.roc[i].dbdcband = type ==MT7925_ROC_REQ_JOIN ?0xfe :0xff ; +/* STR enables DBDC on all bands; otherwise let firmware pick */ + req.roc[i].dbdcband = type ==MT7925_ROC_REQ_JOIN ? + MT792x_BAND_ALL : + MT792x_BAND_AUTO;if (chan->hw_value < center_ch) req.roc[i].sco =1 ;/* SCA */
@@ -1666,7 +1666,7 @@ int mt7925_mcu_set_roc(struct mt792x_phy *phy, struct mt792x_bss_conf *mconf, .maxinterval = cpu_to_le32(duration), .bss_idx = mconf->mt76.idx, .control_channel = chan->hw_value, - .dbdcband = 0xff, /* auto */ + .dbdcband = MT792x_BAND_AUTO, }, };struct cfg80211_chan_def chandef;
@@ -1735,7 +1735,7 @@ int mt7925_mcu_abort_roc(struct mt792x_phy *phy, struct mt792x_bss_conf *mconf, .len = cpu_to_le16(sizeof(struct roc_abort_tlv)), .tokenid = token_id, .bss_idx = mconf->mt76.idx, - .dbdcband = 0xff, /* auto*/ + .dbdcband = MT792x_BAND_AUTO, }, };
drivers/net/wireless/mediatek/mt76/mt792x.h +12 -0
@@ -26,6 +26,18 @@#define MT792x_FW_CAP_NAN BIT(5)#define MT792x_FW_CAP_CNM BIT(7) +/* DBDC band index; 0xff lets firmware pick the band */ +enum mt792x_band_idx { + MT792x_BAND_0 =0 , + MT792x_BAND_1 =1 , + MT792x_BAND_2 =2 , + MT792x_BAND_3 =3 , + MT792x_BAND_LIT =3 , + MT792x_BAND_NUM, + MT792x_BAND_ALL =0xfe , + MT792x_BAND_AUTO =0xff , +}; +/* Chip capability bit positions reported by firmware. * Use with BIT(): chip_cap & BIT(MT792x_CHIP_CAP_x). */
Signature · 1 line
2.45.2
PATCH 5/28 wifi: mt76: use named constants for the HT secondary channel offset
In reply to Emery HsinReplace the hard-coded 0/1/3 sco values with the standard IEEE80211_HT_PARAM_CHA_SEC_NONE/ABOVE/BELOW constants. No functional change.
This is a preparation patch before the MT7925 MLO hybrid/EMLSR work.
--- .../wireless/mediatek/mt76/mt76_connac_mcu.c | 4 ++-- .../net/wireless/mediatek/mt76/mt7921/mcu.c | 8 ++++---- .../net/wireless/mediatek/mt76/mt7925/mcu.c | 19 ++++++++++--------- 3 files changed, 16 insertions(+), 15 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +2 -2
@@ -1601,9 +1601,9 @@ int mt76_connac_mcu_uni_set_chctx(struct mt76_phy *phy, struct mt76_vif_link *mv }if (rlm_req.rlm.control_channel < rlm_req.rlm.center_chan) - rlm_req.rlm.sco =1 ;/* SCA */ + rlm_req.rlm.sco =IEEE80211_HT_PARAM_CHA_SEC_ABOVE ;else if (rlm_req.rlm.control_channel > rlm_req.rlm.center_chan) - rlm_req.rlm.sco =3 ;/* SCB */ + rlm_req.rlm.sco =IEEE80211_HT_PARAM_CHA_SEC_BELOW ;return mt76_mcu_send_msg (mdev,MCU_UNI_CMD (BSS_INFO_UPDATE ), &rlm_req,sizeof (rlm_req), true);
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +4 -4
@@ -880,9 +880,9 @@ int mt7921_mcu_set_roc(struct mt792x_phy *phy, struct mt792x_vif *vif, };if (chan->hw_value < center_ch) - req.roc.sco =1 ;/* SCA */ + req.roc.sco =IEEE80211_HT_PARAM_CHA_SEC_ABOVE ;else if (chan->hw_value > center_ch) - req.roc.sco =3 ;/* SCB */ + req.roc.sco =IEEE80211_HT_PARAM_CHA_SEC_BELOW ;switch (chan->band) {case NL80211_BAND_6GHZ :
@@ -1293,9 +1293,9 @@ int mt7921_mcu_config_sniffer(struct mt792x_vif *vif, req.tlv.center_ch2 =ieee80211_frequency_to_channel (freq2);if (req.tlv.control_ch < req.tlv.center_ch) - req.tlv.sco =1 ;/* SCA */ + req.tlv.sco =IEEE80211_HT_PARAM_CHA_SEC_ABOVE ;else if (req.tlv.control_ch > req.tlv.center_ch) - req.tlv.sco =3 ;/* SCB */ + req.tlv.sco =IEEE80211_HT_PARAM_CHA_SEC_BELOW ;return mt76_mcu_send_msg (vif->phy->mt76->dev,MCU_UNI_CMD (SNIFFER ), &req,sizeof (req), true);
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +10 -9
@@ -1598,9 +1598,9 @@ int mt7925_mcu_set_mlo_roc(struct mt792x_phy *phy, struct mt792x_bss_conf *mconf MT792x_BAND_AUTO;if (chan->hw_value < center_ch) - req.roc[i].sco =1 ;/* SCA */ + req.roc[i].sco =IEEE80211_HT_PARAM_CHA_SEC_ABOVE ;else if (chan->hw_value > center_ch) - req.roc[i].sco =3 ;/* SCB */ + req.roc[i].sco =IEEE80211_HT_PARAM_CHA_SEC_BELOW ; req.roc[i].band = ch_band[chan->band]; }
@@ -1689,12 +1689,13 @@ int mt7925_mcu_set_roc(struct mt792x_phy *phy, struct mt792x_bss_conf *mconf, req.roc.center_chan2_from_ap = center_ch2; } -/* 1 = SCA, 3 = SCB */ if (nl80211_chan_width_to_mhz (chandef.width) >=40 ) { pri40_freq =cfg80211_chandef_primary (&chandef,NL80211_CHAN_WIDTH_40 ,NULL );if (pri40_freq >0 ) - req.roc.sco = chan->center_freq < pri40_freq ?1 :3 ; + req.roc.sco = chan->center_freq < pri40_freq ? +IEEE80211_HT_PARAM_CHA_SEC_ABOVE : +IEEE80211_HT_PARAM_CHA_SEC_BELOW ; }switch (chan->band) {
@@ -2546,9 +2547,9 @@ int mt7925_mcu_config_sniffer(struct mt792x_vif *vif, req.tlv.center_ch2 =ieee80211_frequency_to_channel (freq2);if (req.tlv.control_ch < req.tlv.center_ch) - req.tlv.sco =1 ;/* SCA */ + req.tlv.sco =IEEE80211_HT_PARAM_CHA_SEC_ABOVE ;else if (req.tlv.control_ch > req.tlv.center_ch) - req.tlv.sco =3 ;/* SCB */ + req.tlv.sco =IEEE80211_HT_PARAM_CHA_SEC_BELOW ;return mt76_mcu_send_msg (mphy->dev,MCU_UNI_CMD (SNIFFER ), &req,sizeof (req), true);
@@ -2671,7 +2672,7 @@ void mt7925_mcu_bss_rlm_tlv(struct sk_buff *skb, struct mt76_phy *phy, req->ht_op_info =4 ;/* set HT 40M allowed */ req->rx_streams =hweight8 (phy->antenna_mask); req->center_chan2 =0 ; - req->sco =0 ; + req->sco =IEEE80211_HT_PARAM_CHA_SEC_NONE ; req->band =1 ;switch (band) {
@@ -2721,9 +2722,9 @@ void mt7925_mcu_bss_rlm_tlv(struct sk_buff *skb, struct mt76_phy *phy, }if (req->control_channel < req->center_chan) - req->sco =1 ;/* SCA */ + req->sco =IEEE80211_HT_PARAM_CHA_SEC_ABOVE ;else if (req->control_channel > req->center_chan) - req->sco =3 ;/* SCB */ + req->sco =IEEE80211_HT_PARAM_CHA_SEC_BELOW ; } static struct sk_buff *
Signature · 1 line
2.45.2
PATCH 6/28 wifi: mt76: mt7925: factor out mt7925_mac_link_sta_free_wcid()
In reply to Emery HsinThe host-side wcid unwind (clear the rcu wcid pointer, run mt76_wcid_cleanup() and release the wcid mask bit) was open-coded in three places. Pull it into a single helper and call it from all of them.
No functional change.
This is a preparation patch before the MT7925 MLO hybrid/EMLSR work.
--- .../net/wireless/mediatek/mt76/mt7925/main.c | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/main.c +15 -16
@@ -1001,6 +1001,17 @@ mt7925_get_rates_table(struct ieee80211_hw *hw, struct ieee80211_vif *vif,return mvif->basic_rates_idx; } +/* Undo the host-side wcid publish done by mt7925_mac_link_sta_alloc(). */ +static void mt7925_mac_link_sta_free_wcid (struct mt76_dev *mdev, +struct mt792x_link_sta *mlink) +{ +struct mt76_wcid *wcid = &mlink->wcid; + +rcu_assign_pointer (mdev->wcid[wcid->idx],NULL ); +mt76_wcid_cleanup (mdev, wcid); +mt76_wcid_mask_clear (mdev->wcid_mask, wcid->idx); +} + static int mt7925_mac_link_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif, struct ieee80211_link_sta *link_sta,
@@ -1131,13 +1142,8 @@ static int mt7925_mac_link_sta_add(struct mt76_dev *mdev,if (pm_woken)mt76_connac_power_save_sched (&dev->mphy, &dev->pm); out_wcid: -if (wcid_published) { -u16 idx = wcid->idx; - -rcu_assign_pointer (dev->mt76.wcid[idx],NULL ); -mt76_wcid_cleanup (mdev, wcid); -mt76_wcid_mask_clear (mdev->wcid_mask, wcid->idx); - } +if (wcid_published) +mt7925_mac_link_sta_free_wcid (mdev, mlink);return ret; }
@@ -1159,7 +1165,6 @@ mt7925_mac_sta_unwind_links_host(struct mt792x_dev *dev,for_each_set_bit (link_id, &links,IEEE80211_MLD_MAX_NUM_LINKS ) {struct mt792x_link_sta *mlink; -u16 idx; mlink =rcu_replace_pointer (msta->link[link_id],NULL ,lockdep_is_held (&dev->mt76.mutex));
@@ -1170,10 +1175,7 @@ mt7925_mac_sta_unwind_links_host(struct mt792x_dev *dev,if (msta->deflink_id == link_id) msta->deflink_id =IEEE80211_LINK_UNSPECIFIED ; - idx = mlink->wcid.idx; -rcu_assign_pointer (dev->mt76.wcid[idx],NULL ); -mt76_wcid_cleanup (&dev->mt76, &mlink->wcid); -mt76_wcid_mask_clear (dev->mt76.wcid_mask, idx); +mt7925_mac_link_sta_free_wcid (&dev->mt76, mlink);if (mlink != &msta->deflink)kfree_rcu (mlink, rcu_head);
@@ -1385,7 +1387,6 @@ static void mt7925_mac_link_sta_remove(struct mt76_dev *mdev,struct mt76_wcid *wcid = &mlink->wcid;struct ieee80211_bss_conf *link_conf;u8 link_id = link_sta->link_id; -u16 idx = wcid->idx;mt7925_roc_abort_sync (dev);
@@ -1416,9 +1417,7 @@ static void mt7925_mac_link_sta_remove(struct mt76_dev *mdev,list_del_init (&mlink->wcid.poll_list);spin_unlock_bh (&mdev->sta_poll_lock); -rcu_assign_pointer (dev->mt76.wcid[idx],NULL ); -mt76_wcid_cleanup (mdev, wcid); -mt76_wcid_mask_clear (mdev->wcid_mask, idx); +mt7925_mac_link_sta_free_wcid (mdev, mlink);mt76_connac_power_save_sched (&dev->mphy, &dev->pm); }
Signature · 1 line
2.45.2
PATCH 7/28 wifi: mt76: mt792x: add a gated mt792x_mcu_set_dev_active() helper
In reply to Emery HsinAdd a per-vif dev_active flag and a wrapper around mt76_connac_mcu_uni_add_dev() that skips a redundant DEV (de)activation command and keeps the flag in sync with the firmware DEV state.
This is a preparation patch before the MT7925 MLO DEV (de)activation work.
--- drivers/net/wireless/mediatek/mt76/mt792x.h | 5 +++++ .../net/wireless/mediatek/mt76/mt792x_core.c | 20 +++++++++++++++++++ 2 files changed, 25 insertions(+)
drivers/net/wireless/mediatek/mt76/mt792x.h +5 -0
@@ -181,6 +181,7 @@ struct mt792x_bss_conf {struct ewma_rssi rssi;struct ieee80211_tx_queue_params queue_params[IEEE80211_NUM_ACS ];unsigned int link_id; +bool dev_active;bool absent;
@@ -586,6 +587,10 @@ int mt792x_mcu_fw_pmctrl(struct mt792x_dev *dev);void mt792x_mac_link_bss_remove (struct mt792x_dev *dev,struct mt792x_bss_conf *mconf,struct mt792x_link_sta *mlink); +int mt792x_mcu_set_dev_active (struct mt792x_dev *dev, +struct ieee80211_bss_conf *link_conf, +struct mt792x_bss_conf *mconf, +struct mt76_wcid *wcid,bool enable);void mt792x_config_mac_addr_list (struct mt792x_dev *dev);static inline char *mt792x_ram_name (struct mt792x_dev *dev)
drivers/net/wireless/mediatek/mt76/mt792x_core.c +20 -0
@@ -302,6 +302,26 @@ void mt792x_mac_link_bss_remove(struct mt792x_dev *dev, }EXPORT_SYMBOL_GPL (mt792x_mac_link_bss_remove); +int mt792x_mcu_set_dev_active (struct mt792x_dev *dev, +struct ieee80211_bss_conf *link_conf, +struct mt792x_bss_conf *mconf, +struct mt76_wcid *wcid,bool enable) +{ +int ret; + +/* skip a redundant command when already in the requested state */ +if (mconf->dev_active == enable) +return 0 ; + + ret =mt76_connac_mcu_uni_add_dev (&dev->mphy, link_conf, + &mconf->mt76, wcid, enable); +if (!ret) + mconf->dev_active = enable; + +return ret; +} +EXPORT_SYMBOL_GPL (mt792x_mcu_set_dev_active); +void mt792x_remove_interface (struct ieee80211_hw *hw,struct ieee80211_vif *vif) {
Signature · 1 line
2.45.2
PATCH 8/28 wifi: mt76: mt792x: route DEV (de)activation through mt792x_mcu_set_dev_active()
In reply to Emery HsinConvert the mt7921 and mt7925 DEV (de)activation call sites, including mt792x_mac_link_bss_remove(), to the gated helper so the per-link dev_active flag stays in sync. The firmware-reset reconnect paths clear the flag first to force the reactivation. No functional change.
This is a preparation patch before the MT7925 MLO hybrid/EMLSR work.
--- drivers/net/wireless/mediatek/mt76/mt7921/mac.c | 7 ++++--- drivers/net/wireless/mediatek/mt76/mt7921/main.c | 5 ++--- drivers/net/wireless/mediatek/mt76/mt7925/mac.c | 6 ++++-- drivers/net/wireless/mediatek/mt76/mt7925/main.c | 14 ++++++-------- drivers/net/wireless/mediatek/mt76/mt792x_core.c | 3 +-- 5 files changed, 17 insertions(+), 18 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7921/mac.c +4 -3
@@ -632,9 +632,10 @@ mt7921_vif_connect_iter(void *priv, u8 *mac,if (vif->type ==NL80211_IFTYPE_STATION )ieee80211_disconnect (vif, true); -mt76_connac_mcu_uni_add_dev (&dev->mphy, &vif->bss_conf, - &mvif->bss_conf.mt76, - &mvif->sta.deflink.wcid, true); +/* firmware was reset: force the DEV reactivation */ + mvif->bss_conf.dev_active = false; +mt792x_mcu_set_dev_active (dev, &vif->bss_conf, &mvif->bss_conf, + &mvif->sta.deflink.wcid, true);mt7921_mcu_set_tx (dev, vif);if (vif->type ==NL80211_IFTYPE_AP ) {
drivers/net/wireless/mediatek/mt76/mt7921/main.c +2 -3
@@ -320,9 +320,8 @@ mt7921_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) mvif->bss_conf.mt76.band_idx =0 ; mvif->bss_conf.mt76.wmm_idx = mvif->bss_conf.mt76.idx %MT76_CONNAC_MAX_WMM_SETS ; - ret =mt76_connac_mcu_uni_add_dev (&dev->mphy, &vif->bss_conf, - &mvif->bss_conf.mt76, - &mvif->sta.deflink.wcid, true); + ret =mt792x_mcu_set_dev_active (dev, &vif->bss_conf, &mvif->bss_conf, + &mvif->sta.deflink.wcid, true);if (ret) goto out;
drivers/net/wireless/mediatek/mt76/mt7925/mac.c +4 -2
@@ -1506,8 +1506,10 @@ mt7925_vif_connect_iter(void *priv, u8 *mac, mconf =mt792x_vif_to_link (mvif, i); mconf->absent = false; -mt76_connac_mcu_uni_add_dev (&dev->mphy, bss_conf, &mconf->mt76, - &mvif->sta.deflink.wcid, true); +/* firmware was reset: force the DEV reactivation */ + mconf->dev_active = false; +mt792x_mcu_set_dev_active (dev, bss_conf, mconf, + &mvif->sta.deflink.wcid, true);mt7925_mcu_set_tx (dev, bss_conf); }
drivers/net/wireless/mediatek/mt76/mt7925/main.c +6 -8
@@ -446,8 +446,8 @@ static int mt7925_mac_link_bss_add(struct mt792x_dev *dev,rcu_assign_pointer (dev->mt76.wcid[idx], &mlink->wcid); - ret =mt76_connac_mcu_uni_add_dev (&dev->mphy, link_conf, &mconf->mt76, - &mlink->wcid, true); + ret =mt792x_mcu_set_dev_active (dev, link_conf, mconf, + &mlink->wcid, true);if (ret) {mt7925_p2p_bmc_remove (dev, mconf); goto out;
@@ -2526,17 +2526,15 @@ mt7927_reconfig_band(struct mt792x_dev *dev, struct ieee80211_vif *vif,struct mt792x_link_sta *mlink = &mvif->sta.deflink;int ret; - ret =mt76_connac_mcu_uni_add_dev (&dev->mphy, link_conf, - &mconf->mt76, &mlink->wcid, - false); + ret =mt792x_mcu_set_dev_active (dev, link_conf, mconf, + &mlink->wcid, false);if (ret)return ret; mconf->mt76.band_idx = band_idx; -return mt76_connac_mcu_uni_add_dev (&dev->mphy, link_conf, - &mconf->mt76, &mlink->wcid, - true); +return mt792x_mcu_set_dev_active (dev, link_conf, mconf, + &mlink->wcid, true); } static int mt7925_assign_vif_chanctx(struct ieee80211_hw *hw,
drivers/net/wireless/mediatek/mt76/mt792x_core.c +1 -2
@@ -285,8 +285,7 @@ void mt792x_mac_link_bss_remove(struct mt792x_dev *dev, link_conf =mt792x_vif_to_bss_conf (vif, mconf->link_id);mt76_connac_free_pending_tx_skbs (&dev->pm, &mlink->wcid); -mt76_connac_mcu_uni_add_dev (&dev->mphy, link_conf, &mconf->mt76, - &mlink->wcid, false); +mt792x_mcu_set_dev_active (dev, link_conf, mconf, &mlink->wcid, false);rcu_assign_pointer (dev->mt76.wcid[idx],NULL );
Signature · 1 line
2.45.2
PATCH 9/28 wifi: mt76: mt7925: deactivate the DEV and BSS on disconnect
In reply to Emery HsinOn disconnect the BSS is marked disconnected but stays active, so the firmware keeps its old band binding and a later connection can get the stale band. Also deactivate the DEV and BSS and reset the band to auto.
This is a preparation patch before the MT7925 MLO hybrid/EMLSR work.
--- .../net/wireless/mediatek/mt76/mt7925/main.c | 25 +++++++-- .../net/wireless/mediatek/mt76/mt7925/mcu.c | 56 ------------------- .../net/wireless/mediatek/mt76/mt7925/mcu.h | 2 - 3 files changed, 21 insertions(+), 62 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/main.c +21 -4
@@ -1401,15 +1401,30 @@ static void mt7925_mac_link_sta_remove(struct mt76_dev *mdev, link_conf =mt792x_vif_to_bss_conf (vif, link_id);if (vif->type ==NL80211_IFTYPE_STATION && !link_sta->sta->tdls) { +struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;struct mt792x_bss_conf *mconf; mconf =mt792x_link_conf_to_mconf (link_conf); -if (ieee80211_vif_is_mld (vif)) -mt792x_mac_link_bss_remove (dev, mconf, mlink); -else +/* reset to auto band so the deactivate drops the band binding */ + mconf->mt76.band_idx = MT792x_BAND_AUTO; + +if (ieee80211_vif_is_mld (vif)) { +/* Sub-links are removed. The primary link is kept for +* reconnect but deactivated in firmware. +*/ +if (mconf != &mvif->bss_conf) +mt792x_mac_link_bss_remove (dev, mconf, mlink); +else +mt792x_mcu_set_dev_active (dev, link_conf, mconf, + &mlink->wcid, false); + }else { +/* deactivate DEV and BSS, re-activated on the next connect */ mt7925_mcu_add_bss_info (&dev->phy, mconf->mt76.ctx, link_conf, link_sta, false); +mt792x_mcu_set_dev_active (dev, link_conf, mconf, + &mlink->wcid, false); + } }spin_lock_bh (&mdev->sta_poll_lock);
@@ -1457,6 +1472,9 @@ mt7925_mac_sta_remove_links(struct mt792x_dev *dev, struct ieee80211_vif *vif, mconf =mt792x_link_conf_to_mconf (link_conf); +/* reset to auto band before the disconnect command */ + mconf->mt76.band_idx = MT792x_BAND_AUTO; +mt7925_mcu_add_bss_info (&dev->phy, mconf->mt76.ctx, link_conf, link_sta, false); }
@@ -1529,7 +1547,6 @@ void mt7925_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,if (ieee80211_vif_is_mld (vif)) {mt7925_mac_sta_remove_links (dev, vif, sta, msta->valid_links); -mt7925_mcu_del_dev (mdev, vif); }else {mt7925_mac_link_sta_remove (mdev, vif, &sta->deflink, &msta->deflink);
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +0 -56
62 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt7925/mcu.h +0 -2
@@ -730,8 +730,6 @@ int mt7925_mcu_sched_scan_req(struct mt76_phy *phy,int mt7925_mcu_sched_scan_enable (struct mt76_phy *phy,struct ieee80211_vif *vif,bool enable); -void mt7925_mcu_del_dev (struct mt76_dev *mdev, -struct ieee80211_vif *vif); int mt7925_mcu_add_bss_info(struct mt792x_phy *phy, struct ieee80211_chanctx_conf *ctx, struct ieee80211_bss_conf *link_conf,
Signature · 1 line
2.45.2
PATCH 10/28 wifi: mt76: mt7925: reactivate the DEV before (re)connect, scan and off-channel
In reply to Emery HsinOn disconnect the DEV is deactivated and firmware then drops the BSS management frames, so a legacy reconnect, a scan or an off-channel operation fails. Reactivate the DEV first through the gated helper.
The MLO to legacy switch fixed by commit 8f9e5807671e ("wifi: mt76:
mt7925: restore the legacy BSS after MLO teardown") is now covered by this and the previous patch. Keep only a DEV deactivate on teardown for a failed connection setup, and restore the legacy WMM index.
This is a preparation patch before the MT7925 MLO hybrid/EMLSR work.
--- .../net/wireless/mediatek/mt76/mt7925/main.c | 42 +++++++++++++------ 1 file changed, 30 insertions(+), 12 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/main.c +30 -12
@@ -699,6 +699,8 @@ static int mt7925_remain_on_channel(struct ieee80211_hw *hw,int err;mt792x_mutex_acquire (phy->dev); +mt792x_mcu_set_dev_active (phy->dev, &vif->bss_conf, &mvif->bss_conf, + &mvif->sta.deflink.wcid, true); err =mt7925_set_roc (phy, &mvif->bss_conf, chan, duration,MT7925_ROC_REQ_ROC );mt792x_mutex_release (phy->dev);
@@ -1408,16 +1410,20 @@ static void mt7925_mac_link_sta_remove(struct mt76_dev *mdev,/* reset to auto band so the deactivate drops the band binding */ mconf->mt76.band_idx = MT792x_BAND_AUTO; +/* back to the legacy WMM index, MLO uses 0 */ + mconf->mt76.wmm_idx = mconf->mt76.idx % +MT76_CONNAC_MAX_WMM_SETS ;if (ieee80211_vif_is_mld (vif)) {/* Sub-links are removed. The primary link is kept for * reconnect but deactivated in firmware. */ -if (mconf != &mvif->bss_conf) +if (mconf != &mvif->bss_conf) {mt792x_mac_link_bss_remove (dev, mconf, mlink); -else + }else {mt792x_mcu_set_dev_active (dev, link_conf, mconf, &mlink->wcid, false); + } }else {/* deactivate DEV and BSS, re-activated on the next connect */ mt7925_mcu_add_bss_info(&dev->phy, mconf->mt76.ctx, link_conf,
@@ -1732,10 +1738,13 @@ mt7925_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_scan_request *req) {struct mt792x_dev *dev =mt792x_hw_dev (hw); +struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;struct mt76_phy *mphy = hw->priv;int err;mt792x_mutex_acquire (dev); +mt792x_mcu_set_dev_active (dev, &vif->bss_conf, &mvif->bss_conf, + &mvif->sta.deflink.wcid, true); err =mt7925_mcu_hw_scan (mphy, vif, req);mt792x_mutex_release (dev);
@@ -1759,11 +1768,15 @@ mt7925_start_sched_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_scan_ies *ies) {struct mt792x_dev *dev =mt792x_hw_dev (hw); +struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;struct mt76_phy *mphy = hw->priv;int err;mt792x_mutex_acquire (dev); +mt792x_mcu_set_dev_active (dev, &vif->bss_conf, &mvif->bss_conf, + &mvif->sta.deflink.wcid, true); + err =mt7925_mcu_sched_scan_req (mphy, vif, req, ies);if (err <0 ) goto out;
@@ -2471,16 +2484,18 @@ mt7925_change_vif_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif, mvif->valid_links = new_links; -/* Restore the legacy BSS after disabling MLO */ -if (old_links && !new_links) { -mt792x_mac_link_bss_remove (dev, &mvif->bss_conf, - &mvif->sta.deflink); - err =mt7925_mac_link_bss_add (dev, &vif->bss_conf, - &mvif->sta.deflink); -if (err <0 ) { -mt792x_mutex_release (dev); -return err; - } +/* The normal MLO to legacy switch is handled on the sta_remove path, +* which deactivates the DEV and restores the legacy WMM index; the +* next connect, scan or off-channel reactivates the DEV with the +* legacy address. This only covers a failed connection setup in +* ieee80211_prep_connection(), where the links are torn down without +* a station removal. +*/ +if (!new_links) { + mvif->bss_conf.mt76.wmm_idx = mvif->bss_conf.mt76.idx % +MT76_CONNAC_MAX_WMM_SETS ; +mt792x_mcu_set_dev_active (dev, &vif->bss_conf, &mvif->bss_conf, + &mvif->sta.deflink.wcid, false); }mt792x_mutex_release (dev);
@@ -2579,6 +2594,9 @@ static int mt7925_assign_vif_chanctx(struct ieee80211_hw *hw, }else { mconf = &mvif->bss_conf; +mt792x_mcu_set_dev_active (dev, link_conf, mconf, + &mvif->sta.deflink.wcid, true); +if (is_mt7927 (&dev->mt76)) { band_idx =mt7927_band_idx (ctx->def.chan->band);
Signature · 1 line
2.45.2
PATCH 11/28 wifi: mt76: mt7925: parse the FW hybrid-MLO third-link band limit
In reply to Emery HsinThe EML capability TLV also carries a bitmap of the bands the firmware forbids as the third (virtual) hybrid-MLO link. Store it so the multi-link setup can keep those bands off the firmware virtual link.
--- drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 5 ++++- drivers/net/wireless/mediatek/mt76/mt792x.h | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +4 -1
@@ -1127,8 +1127,10 @@ mt7925_mcu_parse_phy_cap(struct mt792x_dev *dev, char *data, int len)static void mt7925_mcu_parse_eml_cap (struct mt792x_dev *dev,char *data,int len) { +/* The TLV also carries the third-link band limit for hybrid MLO at offset 3. */ struct mt7925_mcu_eml_cap { -u8 rsv[4 ]; +u8 rsv[3 ]; +u8 third_link_band_limit;__le16 eml_cap;u8 rsv2[6 ]; } __packed * cap;
@@ -1139,6 +1141,7 @@ mt7925_mcu_parse_eml_cap(struct mt792x_dev *dev, char *data, int len) cap = (struct mt7925_mcu_eml_cap *)data; dev->phy.eml_cap =le16_to_cpu (cap->eml_cap); + dev->phy.mlo_third_link_band_limit = cap->third_link_band_limit; } static int
drivers/net/wireless/mediatek/mt76/mt792x.h +8 -0
@@ -228,6 +228,12 @@ struct mt792x_vif {struct mt792x_nan nan; }; +/* Bands the firmware forbids as the hybrid-MLO 3rd (virtual) link. +* 6 GHz is never restricted, so it has no bit here. +*/ +#define MT792x_THIRD_LINK_LIMIT_2G BIT(0) +#define MT792x_THIRD_LINK_LIMIT_5G BIT(1) +struct mt792x_phy {struct mt76_phy *mt76;struct mt792x_dev *dev;
@@ -259,6 +265,8 @@ struct mt792x_phy {void *clc[MT792x_CLC_MAX_NUM];u64 chip_cap;u16 eml_cap; +/* bands not allowed as the 3rd link */ +u8 mlo_third_link_band_limit;struct work_struct roc_work;struct timer_list roc_timer;
Signature · 1 line
2.45.2
PATCH 12/28 wifi: mt76: mt7925: gate EMLSR by AP vendor OUI allowlist
In reply to Emery HsinTo avoid unexpected IOT issues, only enable EMLSR for APs that advertise a vendor IE whose OUI is on an allowlist. The emlsr_ap_gating and emlsr_oui module parameters disable or extend it.
--- .../net/wireless/mediatek/mt76/mt7925/mcu.c | 76 ++++++++++++++++++- 1 file changed, 75 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +75 -1
@@ -20,6 +20,75 @@ static bool mt7925_vif_is_nan(struct ieee80211_vif *vif) vif->type ==NL80211_IFTYPE_NAN_DATA ; } +/* Only APs advertising a vendor IE with one of these OUIs may use EMLSR. */ +static bool mt7925_emlsr_ap_gating = true; +module_param_named (emlsr_ap_gating, mt7925_emlsr_ap_gating, bool,0644 ); +MODULE_PARM_DESC (emlsr_ap_gating, +"gate EMLSR by the AP OUI allowlist (default on; set 0 to allow all)" ); + +static u32 mt7925_emlsr_oui_allowlist_extra[8 ]; +static unsigned int mt7925_emlsr_oui_num; +module_param_array_named (emlsr_oui, mt7925_emlsr_oui_allowlist_extra, uint, + &mt7925_emlsr_oui_num,0644 ); +MODULE_PARM_DESC (emlsr_oui, +"extra EMLSR-permitted AP OUIs, e.g. 0x000ce7,0x00037f" ); + +static const u32 mt7925_emlsr_oui_allowlist_default[] = { +0x000ce7 ,0x000a00 ,0x0017a5 ,0x000c43 ,0x00620b ,0x5c6f69 , +0xbc97e1 ,0x001be9 ,0x0005b5 ,0x8c8474 ,0x1423f3 ,0x405b7f , +0xd404e6 ,0xe03e44 ,0x6c92cf ,0x043201 ,0x70b7e4 ,0x1423f2 , +0x4857d2 ,0x9c2183 ,0x84160c ,0xe43d1a ,0x000db6 ,0x000af7 , +0xd40129 ,0x6c8375 ,0xb02628 ,0x001018 ,0x18c086 ,0x38bab0 , +}; + +static bool mt7925_emlsr_oui_match (const struct cfg80211_bss_ies *ies, +const u32 *oui,unsigned int num) +{ +unsigned int i; + +/* oui_type -1 matches any vendor-specific type */ +for (i =0 ; i < num; i++) { +if (cfg80211_find_vendor_ie (oui[i],-1 , ies->data, ies->len)) +return true; + } + +return false; +} + +/* Return true if EMLSR is permitted for the associated AP. */ +static bool mt7925_emlsr_oui_allowed (struct wiphy *wiphy, +struct ieee80211_channel *chan, +const u8 *bssid) +{ +const struct cfg80211_bss_ies *ies; +struct cfg80211_bss *bss; +bool allowed = false; + +if (!mt7925_emlsr_ap_gating) +return true; + +/* a NULL chan matches the BSS on any channel */ + bss =cfg80211_get_bss (wiphy, chan, bssid,NULL ,0 , +IEEE80211_BSS_TYPE_ESS ,IEEE80211_PRIVACY_ANY ); +if (!bss) +return false; + +rcu_read_lock (); + ies =rcu_dereference (bss->beacon_ies); +if (!ies) + ies =rcu_dereference (bss->ies); +if (ies) + allowed =mt7925_emlsr_oui_match (ies, mt7925_emlsr_oui_allowlist_default, +ARRAY_SIZE (mt7925_emlsr_oui_allowlist_default)) || +mt7925_emlsr_oui_match (ies, mt7925_emlsr_oui_allowlist_extra, + mt7925_emlsr_oui_num); +rcu_read_unlock (); + +cfg80211_put_bss (wiphy, bss); + +return allowed; +} +int mt7925_mcu_parse_response (struct mt76_dev *mdev,int cmd,struct sk_buff *skb,int seq) {
@@ -3056,6 +3125,7 @@ mt7925_mcu_bss_mld_tlv(struct sk_buff *skb,struct bss_mld_tlv *mld;struct tlv *tlv;bool is_mld; +bool is_supported_ap = false; is_mld =ieee80211_vif_is_mld (link_conf->vif) || (hweight16 (mvif->valid_links) >1 );
@@ -3070,8 +3140,12 @@ mt7925_mcu_bss_mld_tlv(struct sk_buff *skb, mld->remap_idx =0xff ;if (phy->chip_cap &BIT (MT792x_CHIP_CAP_MLO_EML_EN)) { + is_supported_ap =mt7925_emlsr_oui_allowed (phy->mt76->hw->wiphy, + link_conf->chanreq.oper.chan, + link_conf->bssid); mld->eml_enable = !!(link_conf->vif->cfg.eml_cap & -IEEE80211_EML_CAP_EMLSR_SUPP ); +IEEE80211_EML_CAP_EMLSR_SUPP ) && + is_supported_ap; }else { mld->eml_enable =0 ; }
Signature · 1 line
2.45.2
PATCH 13/28 wifi: mt76: mt7925: support multi-link hybrid/EMLSR remain-on-channel
In reply to Emery HsinProgram the primary link first, then up to two more links, and select the firmware channel-privilege request type from the negotiated links: HYBRID for three links, MLSR otherwise. Add the roc_acquire_tlv cnm_func_mask and extra_info fields and per-link band grants for the multi-link request.
--- .../net/wireless/mediatek/mt76/mt7925/main.c | 59 ++++++- .../net/wireless/mediatek/mt76/mt7925/mcu.c | 158 +++++++++++++----- .../net/wireless/mediatek/mt76/mt7925/mcu.h | 4 +- .../wireless/mediatek/mt76/mt7925/mt7925.h | 7 + drivers/net/wireless/mediatek/mt76/mt792x.h | 2 + 5 files changed, 174 insertions(+), 56 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/main.c +50 -9
@@ -637,6 +637,10 @@ static int mt7925_set_roc(struct mt792x_phy *phy,return -EBUSY ; token = ++phy->roc_token_id; + +/* plain ROC, see mt7925_set_mlo_roc() */ + phy->roc_is_mlo = false; + phy->roc_mconf = mconf; phy->roc_grant = false; phy->roc_notify = type ==MT7925_ROC_REQ_ROC ;
@@ -662,16 +666,38 @@ static int mt7925_set_mlo_roc(struct mt792x_phy *phy, u16 sel_links) {int err; -u8 token; -if (WARN_ON_ONCE (test_and_set_bit (MT76_STATE_ROC , &phy->mt76->state))) -return -EBUSY ; +/* The plain and MLO ROC share MT76_STATE_ROC. Clear it with test_and_clear +* so a concurrent mt7925_roc_work() self-no-ops before taking the mt792x +* mutex this caller holds, otherwise the cancel_work_sync() below would +* deadlock on it. +*/ +if (WARN_ON_ONCE (test_and_clear_bit (MT76_STATE_ROC , &phy->mt76->state))) { +struct mt792x_bss_conf *old = phy->roc_mconf; - token = ++phy->roc_token_id; +if (!phy->roc_is_mlo) +/* the ROC being taken over told mac80211 it is ready; +* notify expiry so its state machine can move on +*/ +ieee80211_remain_on_channel_expired (phy->mt76->hw); + +timer_delete_sync (&phy->roc_timer); +cancel_work_sync (&phy->roc_work); +/* abort on the link the previous ROC was started on; using the +* new request's mconf would carry the wrong bss_idx +*/ +mt7925_mcu_abort_roc (phy, old, phy->roc_token_id); + } + +set_bit (MT76_STATE_ROC , &phy->mt76->state); + + phy->roc_is_mlo = true; + phy->roc_mconf = mconf; phy->roc_grant = false; phy->roc_notify = false; - err =mt7925_mcu_set_mlo_roc (phy, mconf, sel_links,5 , token); + err =mt7925_mcu_set_mlo_roc (phy, mconf, sel_links,5 , + ++phy->roc_token_id);if (err <0 ) {clear_bit (MT76_STATE_ROC , &phy->mt76->state); goto out;
@@ -2236,6 +2262,7 @@ static void mt7925_mgd_prepare_tx(struct ieee80211_hw *hw, {struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;struct mt792x_dev *dev =mt792x_hw_dev (hw); +struct mt792x_bss_conf *mconf;u16 duration = info->duration ? info->duration :jiffies_to_msecs (HZ );
@@ -2246,9 +2273,14 @@ static void mt7925_mgd_prepare_tx(struct ieee80211_hw *hw, duration =MT7925_P2P_GC_JOIN_CH_REQ_INTERVAL_MS ;mt792x_mutex_acquire (dev); -mt7925_set_roc (mvif->phy, &mvif->bss_conf, - mvif->bss_conf.mt76.ctx->def.chan, duration, -MT7925_ROC_REQ_JOIN ); + + mconf =mt792x_vif_to_link (mvif, info->link_id); + +/* an inactive MLO link may have no chanctx */ +if (mconf->mt76.ctx) +mt7925_set_roc (mvif->phy, mconf, mconf->mt76.ctx->def.chan, + duration,MT7925_ROC_REQ_JOIN ); +mt792x_mutex_release (dev); }
@@ -2257,6 +2289,8 @@ static void mt7925_mgd_complete_tx(struct ieee80211_hw *hw, struct ieee80211_prep_tx_info *info) {struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; +struct mt792x_dev *dev =mt792x_hw_dev (hw); +struct mt792x_bss_conf *mconf;if (info->was_assoc)return ;
@@ -2274,7 +2308,14 @@ static void mt7925_mgd_complete_tx(struct ieee80211_hw *hw,return ; } -mt7925_abort_roc (mvif->phy, &mvif->bss_conf); +/* abort on the link the ROC was started on; mt792x_vif_to_link needs +* the mt76 mutex, drop it before mt7925_abort_roc re-takes it +*/ +mt792x_mutex_acquire (dev); + mconf =mt792x_vif_to_link (mvif, info->link_id); +mt792x_mutex_release (dev); + +mt7925_abort_roc (mvif->phy, mconf); } static void mt7925_vif_cfg_changed(struct ieee80211_hw *hw,
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +112 -46
249 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt7925/mcu.h +3 -1
@@ -628,7 +628,9 @@ struct roc_acquire_tlv {u8 reqtype;__le32 maxinterval;u8 dbdcband; -u8 rsv[3 ]; +u8 cnm_func_mask; +u8 extra_info; +u8 rsv[1 ]; } __packed;enum ENUM_CMD_TEST_CTRL_ACT {
drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h +7 -0
@@ -79,6 +79,8 @@ enum mt7925_roc_req {MT7925_ROC_REQ_DFS_CAC =4 ,MT7925_ROC_REQ_MLSR_AG =10 ,MT7925_ROC_REQ_MLSR_AA , +MT7925_ROC_REQ_HYBRID =12 ,/* CH_REQ_TYPE_HYBRID_MLO_MLSR_JOIN, 3-link */ +MT7925_ROC_REQ_EMLSR =13 ,/* CH_REQ_TYPE_MLO_EMLSR_JOIN, needs FW support */ MT7925_ROC_REQ_NUM };
@@ -86,6 +88,11 @@ enum mt7925_roc_req {#define MT7925_P2P_CHNL_HOLD_TIME_MS 3000#define MT7925_P2P_GC_JOIN_CH_REQ_INTERVAL_MS 4000 +/* roc_acquire_tlv extra_info bits */ +enum { +MT7925_ROC_EXTRA_INFO_MULTI_LINK ,/* BIT(0): MLO channel request */ +MT7925_ROC_EXTRA_INFO_EMLSR ,/* BIT(1): unused by FW, kept for parity */ +};enum {UNI_EVENT_ROC_GRANT =0 ,UNI_EVENT_ROC_GRANT_SUB_LINK =4 ,
drivers/net/wireless/mediatek/mt76/mt792x.h +2 -0
@@ -274,6 +274,8 @@ struct mt792x_phy {u8 roc_token_id;bool roc_grant;bool roc_notify;/* mac80211 expects the expiry of this ROC */ +bool roc_is_mlo; +struct mt792x_bss_conf *roc_mconf; };struct mt792x_irq_map {
Signature · 1 line
2.45.2
PATCH 14/28 wifi: mt76: mt7925: describe the whole MLD in the STA/BSS MLD TLVs
In reply to Emery HsinThe firmware drops a per-link STAREC update with link_num == 1, so mid-add links were never registered. Describe every existing link in the MLD TLV (now up to 3 links), and limit EMLSR to fewer than 3 links.
This replaces the pending link parameter added by commit dd3f17ef69ed ("wifi: mt76: mt7925: keep MLD membership consistent during link add").
--- .../net/wireless/mediatek/mt76/mt7925/mac.c | 2 +- .../net/wireless/mediatek/mt76/mt7925/main.c | 14 +- .../net/wireless/mediatek/mt76/mt7925/mcu.c | 126 ++++++++---------- .../net/wireless/mediatek/mt76/mt7925/mcu.h | 2 +- .../wireless/mediatek/mt76/mt7925/mt7925.h | 3 +- 5 files changed, 69 insertions(+), 78 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/mac.c +1 -1
@@ -1518,7 +1518,7 @@ mt7925_vif_connect_iter(void *priv, u8 *mac, true, NULL);mt7925_mcu_sta_update (dev,NULL , vif, &mvif->sta.deflink, true, -MT76_STA_INFO_STATE_NONE ,NULL ); +MT76_STA_INFO_STATE_NONE );mt7925_mcu_uni_add_beacon_offload (dev, hw, vif, true); } }
drivers/net/wireless/mediatek/mt76/mt7925/main.c +7 -7
@@ -1130,7 +1130,7 @@ static int mt7925_mac_link_sta_add(struct mt76_dev *mdev,if (!is_secondary_link_sta) { ret =mt7925_mcu_sta_update (dev, link_sta, vif, mlink, true, -MT76_STA_INFO_STATE_NONE ,NULL ); +MT76_STA_INFO_STATE_NONE );if (ret) goto out_pm; }else {
@@ -1151,13 +1151,13 @@ static int mt7925_mac_link_sta_add(struct mt76_dev *mdev, ret =mt7925_mcu_sta_update (dev, mlink->pri_link, vif, pri_mlink, true, -MT76_STA_INFO_STATE_ASSOC , mlink); +MT76_STA_INFO_STATE_ASSOC );if (ret) goto out_pm; ret =mt7925_mcu_sta_update (dev, link_sta, vif, mlink, true, -MT76_STA_INFO_STATE_ASSOC , mlink); +MT76_STA_INFO_STATE_ASSOC );if (ret) goto out_pm; }
@@ -1356,7 +1356,7 @@ static void mt7925_mac_link_sta_assoc(struct mt76_dev *mdev,memset (mlink->airtime_ac,0 ,sizeof (mlink->airtime_ac));mt7925_mcu_sta_update (dev, link_sta, vif, mlink, true, -MT76_STA_INFO_STATE_ASSOC ,NULL ); +MT76_STA_INFO_STATE_ASSOC );mt792x_mutex_release (dev); }
@@ -1422,7 +1422,7 @@ static void mt7925_mac_link_sta_remove(struct mt76_dev *mdev,mt76_connac_pm_wake (&dev->mphy, &dev->pm);mt7925_mcu_sta_update (dev, link_sta, vif, mlink, false, -MT76_STA_INFO_STATE_NONE ,NULL ); +MT76_STA_INFO_STATE_NONE );mt7925_mac_wtbl_update (dev, mlink->wcid.idx,MT_WTBL_UPDATE_ADM_COUNT_CLEAR );
@@ -2144,7 +2144,7 @@ mt7925_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif, err =mt7925_mcu_sta_update (dev,NULL , vif, &mvif->sta.deflink, true, -MT76_STA_INFO_STATE_NONE ,NULL ); +MT76_STA_INFO_STATE_NONE ); out:mt792x_mutex_release (dev);
@@ -2334,7 +2334,7 @@ static void mt7925_vif_cfg_changed(struct ieee80211_hw *hw,if (changed &BSS_CHANGED_ASSOC ) {mt7925_mcu_sta_update (dev,NULL , vif, &mvif->sta.deflink, true, -MT76_STA_INFO_STATE_ASSOC ,NULL ); +MT76_STA_INFO_STATE_ASSOC );mt7925_mcu_set_beacon_filter (dev, vif, vif->cfg.assoc);if (ieee80211_vif_is_mld (vif))
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +59 -67
188 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt7925/mcu.h +1 -1
@@ -479,7 +479,7 @@ struct sta_rec_mld {__le16 wlan_id;u8 bss_idx;u8 rsv; - }__packed link[2 ]; + }__packed link[3 ]; } __packed;struct sta_rec_eht_mld {
drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h +1 -2
@@ -315,8 +315,7 @@ int mt7925_mcu_sta_update(struct mt792x_dev *dev,struct ieee80211_vif *vif, struct mt792x_link_sta *mlink, bool enable, - enum mt76_sta_info_state state, - struct mt792x_link_sta *pending); + enum mt76_sta_info_state state);int mt7925_mcu_set_chan_info (struct mt792x_phy *phy,u16 tag);int mt7925_mcu_set_tx (struct mt792x_dev *dev,struct ieee80211_bss_conf *bss_conf);int mt7925_mcu_set_eeprom (struct mt792x_dev *dev);
Signature · 1 line
2.45.2
PATCH 15/28 wifi: mt76: mt7925: assign a per-MLD firmware link index
In reply to Emery Hsinvalid_links is only updated after the whole add loop, so links added in the same batch all read hweight16(valid_links) == 0 and collided on one firmware link index. Pass a 0-based per-MLD index from the caller in link order instead, independent of the device-wide BSS index.
--- drivers/net/wireless/mediatek/mt76/mt7925/main.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/main.c +9 -4
@@ -378,7 +378,8 @@ static int mt7925_start(struct ieee80211_hw *hw)static int mt7925_mac_link_bss_add (struct mt792x_dev *dev,struct ieee80211_bss_conf *link_conf, -struct mt792x_link_sta *mlink) +struct mt792x_link_sta *mlink, +u8 link_idx) {struct mt792x_bss_conf *mconf =mt792x_link_conf_to_mconf (link_conf);struct ieee80211_vif *vif = link_conf->vif;
@@ -416,7 +417,10 @@ static int mt7925_mac_link_bss_add(struct mt792x_dev *dev, mconf->mt76.wmm_idx =ieee80211_vif_is_mld (vif) ?0 : mconf->mt76.idx %MT76_CONNAC_MAX_WMM_SETS ; - mconf->mt76.link_idx =hweight16 (mvif->valid_links); +/* Per-MLD 0-based link index for the firmware, independent of the +* device-wide BSS index (mt76.idx). +*/ + mconf->mt76.link_idx =ieee80211_vif_is_mld (vif) ? link_idx :0 ;if (mvif->phy->mt76->chandef.chan && mvif->phy->mt76->chandef.chan->band !=NL80211_BAND_2GHZ )
@@ -478,7 +482,7 @@ mt7925_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) mvif->deflink_id =IEEE80211_LINK_UNSPECIFIED ; mvif->mlo_pm_state = MT792x_MLO_LINK_DISASSOC; - ret =mt7925_mac_link_bss_add (dev, &vif->bss_conf, &mvif->sta.deflink); + ret =mt7925_mac_link_bss_add (dev, &vif->bss_conf, &mvif->sta.deflink,0 );if (ret <0 ) goto out;
@@ -2444,6 +2448,7 @@ mt7925_change_vif_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif,struct mt792x_dev *dev =mt792x_hw_dev (hw);struct mt792x_phy *phy =mt792x_hw_phy (hw);struct ieee80211_bss_conf *link_conf; +u8 link_idx =hweight16 (old_links);unsigned int link_id;int err;
@@ -2511,7 +2516,7 @@ mt7925_change_vif_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif,rcu_assign_pointer (mvif->link_conf[link_id], mconf);rcu_assign_pointer (mvif->sta.link[link_id], mlink); - err =mt7925_mac_link_bss_add (dev, link_conf, mlink); + err =mt7925_mac_link_bss_add (dev, link_conf, mlink, link_idx++);if (err <0 ) goto free;
Signature · 1 line
2.45.2
PATCH 16/28 wifi: mt76: mt7925: share the primary OMAC across MLO links
In reply to Emery HsinPreviously every MLD link used OMAC 0, which can clash with another interface. Make each link reuse the primary link OMAC instead; only a 3-link hybrid MLD gives every link its own OMAC so each band's own MAC is programmed independently.
--- drivers/net/wireless/mediatek/mt76/mt7925/main.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/main.c +11 -5
@@ -379,7 +379,7 @@ static int mt7925_start(struct ieee80211_hw *hw)static int mt7925_mac_link_bss_add (struct mt792x_dev *dev,struct ieee80211_bss_conf *link_conf,struct mt792x_link_sta *mlink, -u8 link_idx) +bool share_omac,u8 link_idx) {struct mt792x_bss_conf *mconf =mt792x_link_conf_to_mconf (link_conf);struct ieee80211_vif *vif = link_conf->vif;
@@ -398,8 +398,11 @@ static int mt7925_mac_link_bss_add(struct mt792x_dev *dev, } } - mconf->mt76.omac_idx =ieee80211_vif_is_mld (vif) ? -0 : mconf->mt76.idx; +/* Links share the primary OMAC except in 3-link hybrid mode. */ +if (share_omac) + mconf->mt76.omac_idx = mvif->bss_conf.mt76.idx; +else + mconf->mt76.omac_idx = mconf->mt76.idx; mconf->mt76.band_idx = MT792x_BAND_AUTO; mconf->absent = false;
@@ -482,7 +485,8 @@ mt7925_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) mvif->deflink_id =IEEE80211_LINK_UNSPECIFIED ; mvif->mlo_pm_state = MT792x_MLO_LINK_DISASSOC; - ret =mt7925_mac_link_bss_add (dev, &vif->bss_conf, &mvif->sta.deflink,0 ); + ret =mt7925_mac_link_bss_add (dev, &vif->bss_conf, &mvif->sta.deflink, + true,0 );if (ret <0 ) goto out;
@@ -2516,7 +2520,9 @@ mt7925_change_vif_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif,rcu_assign_pointer (mvif->link_conf[link_id], mconf);rcu_assign_pointer (mvif->sta.link[link_id], mlink); - err =mt7925_mac_link_bss_add (dev, link_conf, mlink, link_idx++); + err =mt7925_mac_link_bss_add (dev, link_conf, mlink, +hweight16 (new_links) !=3 , + link_idx++);if (err <0 ) goto free;
Signature · 1 line
2.45.2
PATCH 17/28 wifi: mt76: mt7925: carry the STA decap offload to later links
In reply to Emery Hsin.sta_set_decap_offload() runs once with only the first link present. Remember the setting on the sta and iterate msta->valid_links so a link added later inherits it. Iterating the sta's links also avoids a NULL
deref: a vif link may exist before its per-sta link_sta is set up.
--- drivers/net/wireless/mediatek/mt76/mt7925/main.c | 12 ++++++++++-- drivers/net/wireless/mediatek/mt76/mt792x.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/main.c +10 -2
@@ -1087,6 +1087,10 @@ static int mt7925_mac_link_sta_add(struct mt76_dev *mdev,if (link_sta->sta->tdls)set_bit (MT_WCID_FLAG_TDLS_PEER , &mlink->wcid.flags); +/* links added later inherit the sta decap offload setting */ +if (msta->decap_offload) +set_bit (MT_WCID_FLAG_HDR_TRANS , &mlink->wcid.flags); + wcid = &mlink->wcid;ewma_signal_init (&wcid->rssi);rcu_assign_pointer (dev->mt76.wcid[wcid->idx], wcid);
@@ -1932,7 +1936,7 @@ static void mt7925_sta_set_decap_offload(struct ieee80211_hw *hw,struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv;struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;struct mt792x_dev *dev =mt792x_hw_dev (hw); -unsigned long valid = mvif->valid_links; +unsigned long valid;u8 i;if (!msta->vif)
@@ -1940,7 +1944,11 @@ static void mt7925_sta_set_decap_offload(struct ieee80211_hw *hw,mt792x_mutex_acquire (dev); - valid =ieee80211_vif_is_mld (vif) ? mvif->valid_links :BIT (0 ); +/* remember the setting, links added later inherit it */ + msta->decap_offload = enabled; + +/* iterate the sta's links, a vif link may not have a link_sta yet */ + valid =ieee80211_vif_is_mld (vif) ? msta->valid_links :BIT (0 );for_each_set_bit (i, &valid,IEEE80211_MLD_MAX_NUM_LINKS ) {struct mt792x_bss_conf *mconf;
drivers/net/wireless/mediatek/mt76/mt792x.h +1 -0
@@ -167,6 +167,7 @@ struct mt792x_sta {/* NAN peer schedule */ struct mt792x_sta_nan_sched nan_sched; +bool decap_offload;/* remembered, applied to links added later */ };DECLARE_EWMA (rssi,10 ,8 );
Signature · 1 line
2.45.2
PATCH 18/28 wifi: mt76: mt7925: split link sta add into alloc and commit phases
In reply to Emery HsinSplit mt7925_mac_link_sta_add() into a host-only alloc half (allocates and publishes the wcid) and the STAREC/BSS half. The commit half now only raises STATE_NONE; the STATE_ASSOC transition moves to the add-links caller. Published links are freed by the unwind path, not here.
--- .../net/wireless/mediatek/mt76/mt7925/main.c | 132 +++++++++--------- 1 file changed, 63 insertions(+), 69 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/main.c +63 -69
@@ -1048,33 +1048,23 @@ static void mt7925_mac_link_sta_free_wcid(struct mt76_dev *mdev,mt76_wcid_mask_clear (mdev->wcid_mask, wcid->idx); } -static int mt7925_mac_link_sta_add (struct mt76_dev *mdev, -struct ieee80211_vif *vif, -struct ieee80211_link_sta *link_sta, -struct mt792x_link_sta *mlink) +/* Allocate and publish the wcid only; no MCU command is sent. +* On failure the caller unwinds with mt7925_mac_link_sta_free_wcid(). +*/ +static int mt7925_mac_link_sta_alloc (struct mt76_dev *mdev, +struct ieee80211_vif *vif, +struct ieee80211_link_sta *link_sta, +struct mt792x_link_sta *mlink) { struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76); -struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; -struct ieee80211_bss_conf *link_conf; -struct mt792x_bss_conf *mconf; -u8 link_id = link_sta->link_id; -bool wcid_published = false; -bool is_secondary_link_sta; -struct mt792x_sta *msta; -struct mt76_wcid *wcid; -bool pm_woken = false; -int ret, idx; - - msta = (struct mt792x_sta *)link_sta->sta->drv_priv; - -if (WARN_ON_ONCE (!mlink)) -return -EINVAL ; +struct mt792x_sta *msta = (struct mt792x_sta *)link_sta->sta->drv_priv; +struct mt76_wcid *wcid = &mlink->wcid; +int idx; idx =mt76_wcid_alloc (dev->mt76.wcid_mask, MT792x_WTBL_STA -1 );if (idx <0 )return -ENOSPC ; - mconf =mt792x_vif_to_link (mvif, link_id);mt76_wcid_init (&mlink->wcid,0 ); mlink->wcid.sta =1 ; mlink->wcid.idx = idx;
@@ -1094,21 +1084,44 @@ static int mt7925_mac_link_sta_add(struct mt76_dev *mdev, wcid = &mlink->wcid;ewma_signal_init (&wcid->rssi);rcu_assign_pointer (dev->mt76.wcid[wcid->idx], wcid); - wcid_published = true;ewma_avg_signal_init (&mlink->avg_ack_signal);memset (mlink->airtime_ac,0 ,sizeof (msta->deflink.airtime_ac)); +return 0 ; +} + +/* Program BSS_INFO and the STATE_NONE STAREC of one link. The wcid must +* already be allocated and published by mt7925_mac_link_sta_alloc(). +* On failure the caller unwinds the published state. +*/ +static int mt7925_mac_link_sta_add (struct mt76_dev *mdev, +struct ieee80211_vif *vif, +struct ieee80211_link_sta *link_sta, +struct mt792x_link_sta *mlink) +{ + struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76); +struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; +struct ieee80211_bss_conf *link_conf; +struct mt792x_bss_conf *mconf; +u8 link_id = link_sta->link_id; +bool pm_woken = false; +int ret; + +if (WARN_ON_ONCE (!mlink)) +return -EINVAL ; + + mconf =mt792x_vif_to_link (mvif, link_id); + ret =mt76_connac_pm_wake (&dev->mphy, &dev->pm);if (ret) - goto out_wcid; +return ret; pm_woken = true; -mt7925_mac_wtbl_update (dev, idx, +mt7925_mac_wtbl_update (dev, mlink->wcid.idx,MT_WTBL_UPDATE_ADM_COUNT_CLEAR ); link_conf =mt792x_vif_to_bss_conf (vif, link_id); - is_secondary_link_sta =ieee80211_vif_is_mld (vif) && link_sta != mlink->pri_link;/* NAN_DATA (NDI) peers skip association - fill link_sta caps * from sband and push BSS_INFO with correct phymode + RLM.
@@ -1134,45 +1147,16 @@ static int mt7925_mac_link_sta_add(struct mt76_dev *mdev, link_conf, link_sta, mconf->mt76.bmc_wcid ?: mlink_bc->wcid.idx, mlink->wcid.idx, - is_secondary_link_sta); + false);if (ret) goto out_pm; } -if (!is_secondary_link_sta) { - ret =mt7925_mcu_sta_update (dev, link_sta, vif, - mlink, true, -MT76_STA_INFO_STATE_NONE ); -if (ret) - goto out_pm; - }else { -struct mt792x_link_sta *pri_mlink; -struct mt76_wcid *pri_wcid; - -/* alternative lookup via def_wcid */ - pri_wcid = mlink->wcid.def_wcid; - - pri_mlink = pri_wcid ? - container_of(pri_wcid, struct mt792x_link_sta, wcid) : -NULL ; - -if (WARN_ON_ONCE (!pri_mlink)) { - ret = -EINVAL ; - goto out_pm; - } - - ret =mt7925_mcu_sta_update (dev, mlink->pri_link, vif, - pri_mlink, true, -MT76_STA_INFO_STATE_ASSOC ); -if (ret) - goto out_pm; - - ret =mt7925_mcu_sta_update (dev, link_sta, vif, - mlink, true, -MT76_STA_INFO_STATE_ASSOC ); -if (ret) - goto out_pm; - } +/* Raise this link's STAREC to STATE_NONE, after its BSS_INFO. */ + ret =mt7925_mcu_sta_update (dev, link_sta, vif, mlink, true, +MT76_STA_INFO_STATE_NONE ); +if (ret) + goto out_pm;mt76_connac_power_save_sched (&dev->mphy, &dev->pm);
@@ -1181,9 +1165,6 @@ static int mt7925_mac_link_sta_add(struct mt76_dev *mdev, out_pm:if (pm_woken)mt76_connac_power_save_sched (&dev->mphy, &dev->pm); -out_wcid: -if (wcid_published) -mt7925_mac_link_sta_free_wcid (mdev, mlink);return ret; }
@@ -1252,20 +1233,26 @@ mt7925_mac_sta_add_links(struct mt792x_dev *dev, struct ieee80211_vif *vif, mlink->wcid.def_wcid = &msta->deflink.wcid; link_sta =mt792x_sta_to_link_sta (vif, sta, link_id); - err =mt7925_mac_link_sta_add (&dev->mt76, vif, link_sta, mlink); + err =mt7925_mac_link_sta_alloc (&dev->mt76, vif, link_sta, + mlink);if (err) {if (!is_deflink) -kfree_rcu (mlink, rcu_head); +kfree (mlink);break ; } -if (is_deflink) - msta->deflink_id = link_id; -rcu_assign_pointer (msta->link[link_id], mlink); msta->valid_links |=BIT (link_id); +if (is_deflink) + msta->deflink_id = link_id; +/* published into msta->link[]; let the unwind path free it */ added_links |=BIT (link_id); + + err =mt7925_mac_link_sta_add (&dev->mt76, vif, link_sta, + mlink); +if (err) +break ; }if (err && added_links)
@@ -1292,8 +1279,15 @@ int mt7925_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif, err =mt7925_mac_sta_add_links (dev, vif, sta, sta->valid_links); }else { - err =mt7925_mac_link_sta_add (mdev, vif, &sta->deflink, - &msta->deflink); + err =mt7925_mac_link_sta_alloc (mdev, vif, &sta->deflink, + &msta->deflink); +if (!err) { + err =mt7925_mac_link_sta_add (mdev, vif, &sta->deflink, + &msta->deflink); +if (err) +mt7925_mac_link_sta_free_wcid (mdev, + &msta->deflink); + } }return err;
Signature · 1 line
2.45.2
PATCH 19/28 wifi: mt76: mt7925: publish every link before sending any STA_REC
In reply to Emery HsinThe MLD setup TLV is built from msta->link[], so a STA_REC sent while later links are missing carries a partial MLD. Publish every link first, then program them primary first. A single link to MLD upgrade re-adds the primary with a new wcid on the reused deflink storage.
--- .../net/wireless/mediatek/mt76/mt7925/main.c | 60 +++++++++++++++++-- 1 file changed, 56 insertions(+), 4 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/main.c +56 -4
@@ -1212,6 +1212,9 @@ mt7925_mac_sta_add_links(struct mt792x_dev *dev, struct ieee80211_vif *vif,unsigned int link_id;int err =0 ; +/* Publish every link before sending any STAREC, so the MLD setup TLV +* describes the whole MLD. +*/ for_each_set_bit (link_id, &new_links,IEEE80211_MLD_MAX_NUM_LINKS ) {struct ieee80211_link_sta *link_sta;struct mt792x_link_sta *mlink;
@@ -1220,6 +1223,26 @@ mt7925_mac_sta_add_links(struct mt792x_dev *dev, struct ieee80211_vif *vif,if (msta->deflink_id ==IEEE80211_LINK_UNSPECIFIED ) { mlink = &msta->deflink; is_deflink = true; + }else if (link_id == msta->deflink_id && +rcu_access_pointer (msta->link[link_id]) == + &msta->deflink) { +/* Single link to MLD upgrade: re-add the primary with +* a new wcid so it binds to the granted band. This runs +* from the AUTHORIZE transition before mac80211 sets +* WLAN_STA_AUTHORIZED, so no data is being sent on this +* sta and reusing the deflink storage is safe. +*/ + link_sta =mt792x_sta_to_link_sta (vif, sta, link_id); +if (mt7925_mcu_sta_update (dev, link_sta, vif, + &msta->deflink, false, +MT76_STA_INFO_STATE_NONE )) +dev_dbg (dev->mt76.dev, +"failed to tear down the old STA_REC\n" ); +mt7925_mac_link_sta_free_wcid (&dev->mt76, + &msta->deflink); +synchronize_rcu (); + mlink = &msta->deflink; + is_deflink = true; }else { mlink =kzalloc_obj (*mlink);if (!mlink) {
@@ -1236,8 +1259,17 @@ mt7925_mac_sta_add_links(struct mt792x_dev *dev, struct ieee80211_vif *vif, err =mt7925_mac_link_sta_alloc (&dev->mt76, vif, link_sta, mlink);if (err) { -if (!is_deflink) +if (!is_deflink) {kfree (mlink); + }else if (link_id == msta->deflink_id) { +/* the upgrade path above already freed the +* deflink wcid, so unpublish it here instead +* of freeing the shared wcid a second time +*/ +rcu_assign_pointer (msta->link[link_id],NULL ); + msta->valid_links &= ~BIT (link_id); + msta->deflink_id =IEEE80211_LINK_UNSPECIFIED ; + }break ; }
@@ -1246,13 +1278,33 @@ mt7925_mac_sta_add_links(struct mt792x_dev *dev, struct ieee80211_vif *vif,if (is_deflink) msta->deflink_id = link_id; -/* published into msta->link[]; let the unwind path free it */ added_links |=BIT (link_id); + } + +/* Configure the primary link first, it anchors the MLD. */ +if (!err && msta->deflink_id !=IEEE80211_LINK_UNSPECIFIED && + (added_links &BIT (msta->deflink_id))) { +struct mt792x_link_sta *mlink = +mt792x_sta_to_link (msta, msta->deflink_id); +struct ieee80211_link_sta *link_sta = +mt792x_sta_to_link_sta (vif, sta, msta->deflink_id); + + err =mt7925_mac_link_sta_add (&dev->mt76, vif, link_sta, mlink); + } +for_each_set_bit (link_id, &added_links, +IEEE80211_MLD_MAX_NUM_LINKS ) { +struct ieee80211_link_sta *link_sta; +struct mt792x_link_sta *mlink; - err =mt7925_mac_link_sta_add (&dev->mt76, vif, link_sta, - mlink);if (err)break ; +if (link_id == msta->deflink_id) +continue ; + + mlink =mt792x_sta_to_link (msta, link_id); + link_sta =mt792x_sta_to_link_sta (vif, sta, link_id); + err =mt7925_mac_link_sta_add (&dev->mt76, vif, link_sta, + mlink); }if (err && added_links)
Signature · 1 line
2.45.2
PATCH 20/28 wifi: mt76: mt7925: add mt7925_mcu_add_bss_sec() helper
In reply to Emery HsinAdd a helper that pushes only the SEC (cipher) TLV of an active BSS via BSS_INFO_UPDATE instead of re-sending the whole BSS_INFO; the firmware processes BSS_INFO TLVs independently. The MLO set_key path will use it.
--- .../net/wireless/mediatek/mt76/mt7925/mcu.c | 22 +++++++++++++++++++ .../net/wireless/mediatek/mt76/mt7925/mcu.h | 2 ++ 2 files changed, 24 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +22 -0
@@ -3391,6 +3391,28 @@ int mt7925_mcu_add_bss_info(struct mt792x_phy *phy, mlink->wcid.idx, enable); } +/* Update only the SEC (cipher) tag of an active BSS, without re-pushing the +* whole BSS_INFO. The firmware processes BSS_INFO TLVs independently, so a +* SEC-only update leaves the rest untouched. Used by the set_key path. +*/ +int mt7925_mcu_add_bss_sec (struct mt792x_phy *phy, +struct ieee80211_bss_conf *link_conf) +{ +struct mt792x_bss_conf *mconf =mt792x_link_conf_to_mconf (link_conf); +struct mt792x_dev *dev = phy->dev; +struct sk_buff *skb; + + skb =__mt7925_mcu_alloc_bss_req (&dev->mt76, &mconf->mt76, +MT7925_BSS_UPDATE_MAX_SIZE ); +if (IS_ERR (skb)) +return PTR_ERR (skb); + +mt7925_mcu_bss_sec_tlv (skb, link_conf); + +return mt76_mcu_skb_send_msg (&dev->mt76, skb, +MCU_UNI_CMD (BSS_INFO_UPDATE ), true); +} +int mt7925_mcu_set_dbdc (struct mt76_phy *phy,bool enable) {struct mt76_dev *mdev = phy->dev;
drivers/net/wireless/mediatek/mt76/mt7925/mcu.h +2 -0
@@ -737,6 +737,8 @@ int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,struct ieee80211_bss_conf *link_conf, struct ieee80211_link_sta *link_sta, int enable); +int mt7925_mcu_add_bss_sec (struct mt792x_phy *phy, +struct ieee80211_bss_conf *link_conf); int mt7925_mcu_add_bss_info_sta(struct mt792x_phy *phy, struct ieee80211_chanctx_conf *ctx, struct ieee80211_bss_conf *link_conf,
Signature · 1 line
2.45.2
PATCH 21/28 wifi: mt76: mt7925: only refresh the SEC tag when setting the first key
In reply to Emery HsinWhen the first key is installed the cipher is latched and the firmware only needs the updated SEC tag, not a full BSS_INFO re-send. Use mt7925_mcu_add_bss_sec() so a key install no longer reprograms the BSS.
--- drivers/net/wireless/mediatek/mt76/mt7925/main.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/main.c +2 -4
@@ -761,14 +761,12 @@ static int mt7925_set_link_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,struct mt792x_sta *msta = sta ? (struct mt792x_sta *)sta->drv_priv : &mvif->sta;struct ieee80211_bss_conf *link_conf; -struct ieee80211_link_sta *link_sta;int idx = key->keyidx, err =0 ;struct mt792x_bss_conf *mconf;struct mt76_wcid *wcid;u8 *wcid_keyidx; link_conf =mt792x_vif_to_bss_conf (vif, link_id); - link_sta = sta ?mt792x_sta_to_link_sta (vif, sta, link_id) :NULL ; mconf =mt792x_vif_to_link (mvif, link_id); wcid = &mlink->wcid; wcid_keyidx = &wcid->hw_key_idx;
@@ -799,8 +797,8 @@ static int mt7925_set_link_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,struct mt792x_phy *phy =mt792x_hw_phy (hw); mconf->mt76.cipher =mt7925_mcu_get_cipher (key->cipher); -mt7925_mcu_add_bss_info (phy, mconf->mt76.ctx, link_conf, - link_sta, true); +/* only refresh the SEC (cipher) tag, not the whole BSS_INFO */ +mt7925_mcu_add_bss_sec (phy, link_conf); }if (cmd ==SET_KEY )
Signature · 1 line
2.45.2
PATCH 22/28 wifi: mt76: mt7925: add mt7925_set_links_key_iter() helper
In reply to Emery HsinAdd a key iterator that (re)installs the existing keys on a given set of MLO links, used when later links are brought up after the first key was already programmed on the primary link.
This is a preparation patch before the MT7925 MLO hybrid/EMLSR work.
--- .../net/wireless/mediatek/mt76/mt7925/main.c | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7925/main.c +29 -0
@@ -1377,6 +1377,35 @@ mt7925_mac_set_links(struct mt76_dev *mdev, struct ieee80211_vif *vif)ieee80211_set_active_links_async (vif, sel_links); } +struct mt7925_set_links_key_iter { +unsigned long links; +}; + +/* Install the existing keys on the given links. */ +static void +mt7925_set_links_key_iter (struct ieee80211_hw *hw,struct ieee80211_vif *vif, +struct ieee80211_sta *sta, +struct ieee80211_key_conf *key,void *data) +{ +struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; +struct mt792x_sta *msta = sta ? (struct mt792x_sta *)sta->drv_priv : + &mvif->sta; +struct mt7925_set_links_key_iter *it = data; +unsigned long links = key->link_id !=-1 ?BIT (key->link_id) : it->links; +unsigned int link_id; + + links &= it->links; + +for_each_set_bit (link_id, &links,IEEE80211_MLD_MAX_NUM_LINKS ) { +struct mt792x_link_sta *mlink =mt792x_sta_to_link (msta, link_id); + +if (!mlink) +continue ; + +mt7925_set_link_key (hw,SET_KEY , vif, sta, key, link_id, mlink); + } +} +static void mt7925_mac_link_sta_assoc (struct mt76_dev *mdev,struct ieee80211_vif *vif,struct ieee80211_link_sta *link_sta)
Signature · 1 line
2.45.2
PATCH 23/28 wifi: mt76: mt7925: bring up all MLO links on authorization
In reply to Emery HsinBring up the MLO links at authorization instead of association: one MLO ROC for the whole link set, then BSS_INFO and STA_REC for every link, and re-install the keys that were set while only the primary link existed. The links are no longer activated with ieee80211_set_active_links_async().
--- .../net/wireless/mediatek/mt76/mt7925/main.c | 390 +++++++++++++----- 1 file changed, 297 insertions(+), 93 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/main.c +297 -93
@@ -484,6 +484,7 @@ mt7925_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) mvif->sta.vif = mvif; mvif->deflink_id =IEEE80211_LINK_UNSPECIFIED ; mvif->mlo_pm_state = MT792x_MLO_LINK_DISASSOC; + mvif->valid_links =0 ; ret =mt7925_mac_link_bss_add (dev, &vif->bss_conf, &mvif->sta.deflink, true,0 );
@@ -1344,39 +1345,6 @@ int mt7925_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif, }EXPORT_SYMBOL_GPL (mt7925_mac_sta_add); -static void -mt7925_mac_set_links (struct mt76_dev *mdev,struct ieee80211_vif *vif) -{ - struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76); -struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; -struct ieee80211_bss_conf *link_conf = -mt792x_vif_to_bss_conf (vif, mvif->deflink_id); -struct cfg80211_chan_def *chandef = &link_conf->chanreq.oper; -enum nl80211_band band = chandef->chan->band, secondary_band; - -u16 sel_links =mt76_select_links (vif,2 ); -u8 secondary_link_id =__ffs (~BIT (mvif->deflink_id) & sel_links); - -if (!ieee80211_vif_is_mld (vif) ||hweight16 (sel_links) <2 ) -return ; - - link_conf =mt792x_vif_to_bss_conf (vif, secondary_link_id); - secondary_band = link_conf->chanreq.oper.chan->band; - -if (band ==NL80211_BAND_2GHZ || - (band ==NL80211_BAND_5GHZ && secondary_band ==NL80211_BAND_6GHZ )) { -mt7925_abort_roc (mvif->phy, &mvif->bss_conf); - -mt792x_mutex_acquire (dev); - -mt7925_set_mlo_roc (mvif->phy, &mvif->bss_conf, sel_links); - -mt792x_mutex_release (dev); - } - -ieee80211_set_active_links_async (vif, sel_links); -} -struct mt7925_set_links_key_iter {unsigned long links; };
@@ -1446,50 +1414,98 @@ static void mt7925_mac_link_sta_assoc(struct mt76_dev *mdev,mt792x_mutex_release (dev); } -int mt7925_mac_sta_event (struct mt76_dev *mdev,struct ieee80211_vif *vif, -struct ieee80211_sta *sta,enum mt76_sta_event ev) +/* Re-send each link's BSS_INFO after its STATE_NONE STAREC, then raise +* every link to STATE_ASSOC, primary first. +*/ +static int mt7925_mac_multi_links_sta_assoc (struct mt76_dev *mdev, +struct ieee80211_vif *vif, +struct ieee80211_sta *sta, +unsigned long new_links) { struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76); -struct ieee80211_link_sta *link_sta = &sta->deflink; -struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; +struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv; +unsigned int link_id; +int err; -if (mvif->roc_join_held && !sta->tdls && - (ev ==MT76_STA_EVENT_AUTHORIZE || ev ==MT76_STA_EVENT_DISASSOC )) { - mvif->roc_join_held = false; -mt7925_abort_roc (mvif->phy, &mvif->bss_conf); - } +if (vif->type !=NL80211_IFTYPE_STATION ) +return 0 ; -switch (ev) { -case MT76_STA_EVENT_ASSOC : -if (ieee80211_vif_is_mld (vif)) { -struct mt792x_sta *msta = - (struct mt792x_sta *)sta->drv_priv; +if (msta->deflink_id !=IEEE80211_LINK_UNSPECIFIED && + (new_links &BIT (msta->deflink_id))) { +struct ieee80211_bss_conf *link_conf = +mt792x_vif_to_bss_conf (vif, msta->deflink_id); +struct ieee80211_link_sta *link_sta = +mt792x_sta_to_link_sta (vif, sta, msta->deflink_id); - link_sta =mt792x_sta_to_link_sta (vif, sta, - msta->deflink_id); -mt7925_mac_set_links (mdev, vif); +if (link_conf && link_sta) { +struct mt792x_bss_conf *mconf = +mt792x_link_conf_to_mconf (link_conf); + + err =mt7925_mcu_add_bss_info (&dev->phy, + mconf->mt76.ctx, + link_conf, link_sta, + true); +if (err) +return err; } + } -mt7925_mac_link_sta_assoc (mdev, vif, link_sta); -break ; -case MT76_STA_EVENT_AUTHORIZE : -if (vif->type ==NL80211_IFTYPE_NAN_DATA ) { -int ret; +for_each_set_bit (link_id, &new_links,IEEE80211_MLD_MAX_NUM_LINKS ) { +struct ieee80211_bss_conf *link_conf; +struct ieee80211_link_sta *link_sta; +struct mt792x_bss_conf *mconf; -mt792x_mutex_acquire (dev); - ret =mt792x_nan_map_sta_rec (mdev, vif, sta); -mt792x_mutex_release (dev); +if (link_id == msta->deflink_id) +continue ; -return ret; + link_conf =mt792x_vif_to_bss_conf (vif, link_id); + link_sta =mt792x_sta_to_link_sta (vif, sta, link_id); +if (!link_conf || !link_sta) +continue ; + mconf =mt792x_link_conf_to_mconf (link_conf); + + err =mt7925_mcu_add_bss_info (&dev->phy, mconf->mt76.ctx, + link_conf, link_sta, true); +if (err) +return err; + } + +if (msta->deflink_id !=IEEE80211_LINK_UNSPECIFIED && + (new_links &BIT (msta->deflink_id))) { +struct mt792x_link_sta *mlink = +mt792x_sta_to_link (msta, msta->deflink_id); +struct ieee80211_link_sta *link_sta = +mt792x_sta_to_link_sta (vif, sta, msta->deflink_id); + +if (mlink && link_sta) { + err =mt7925_mcu_sta_update (dev, link_sta, vif, + mlink, true, +MT76_STA_INFO_STATE_ASSOC ); +if (err) +return err; } -break ; -default : -break ; + } + +for_each_set_bit (link_id, &new_links,IEEE80211_MLD_MAX_NUM_LINKS ) { +struct ieee80211_link_sta *link_sta; +struct mt792x_link_sta *mlink; + +if (link_id == msta->deflink_id) +continue ; + + mlink =mt792x_sta_to_link (msta, link_id); + link_sta =mt792x_sta_to_link_sta (vif, sta, link_id); +if (!mlink || !link_sta) +continue ; + + err =mt7925_mcu_sta_update (dev, link_sta, vif, mlink, true, +MT76_STA_INFO_STATE_ASSOC ); +if (err) +return err; }return 0 ; } -EXPORT_SYMBOL_GPL (mt7925_mac_sta_event); static void mt7925_mac_link_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
@@ -1625,6 +1641,203 @@ mt7925_mac_sta_remove_links(struct mt792x_dev *dev, struct ieee80211_vif *vif,return 0 ; } +/* Bring up all selected links at once: one MLO ROC for the whole set, +* then add every link on its granted band. Keys were installed when only +* the primary link existed, so re-install them on all links afterwards. +*/ +static void +mt7925_mac_set_links (struct mt76_dev *mdev,struct ieee80211_vif *vif, +struct ieee80211_sta *sta) +{ +struct mt792x_bss_conf *mconfs[IEEE80211_MLD_MAX_NUM_LINKS ] = {}, *mconf; +struct mt792x_link_sta *mlinks[IEEE80211_MLD_MAX_NUM_LINKS ] = {}, *mlink; + struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76); +struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; +struct mt792x_bss_conf *pri_mconf = &mvif->bss_conf; +struct mt7925_set_links_key_iter key_it = { }; +struct ieee80211_bss_conf *link_conf; +u8 order[IEEE80211_MLD_MAX_NUM_LINKS ]; +unsigned long sel_links, add, bss_done =0 ; +unsigned int link_id, i; +int nadd =0 , err; +u8 max_links; + + max_links = (dev->phy.chip_cap &BIT (MT792x_CHIP_CAP_MLO_HYBRID_EN)) ?3 :2 ; + sel_links =mt76_select_links (vif, max_links); + +if (!ieee80211_vif_is_mld (vif) ||hweight16 (sel_links) <2 ) +return ; + + add = sel_links & ~vif->active_links; +if (!add) +return ; + +mt792x_mutex_acquire (dev); + +/* allocate and publish the added sub-links' bss_conf / link_sta */ +for_each_set_bit (link_id, &add,IEEE80211_MLD_MAX_NUM_LINKS ) { + mconf =devm_kzalloc (dev->mt76.dev,sizeof (*mconf),GFP_KERNEL ); + mlink =devm_kzalloc (dev->mt76.dev,sizeof (*mlink),GFP_KERNEL ); +if (!mconf || !mlink) + goto free; + + mconfs[link_id] = mconf; + mlinks[link_id] = mlink; + mconf->link_id = link_id; + mconf->vif = mvif; + mlink->wcid.link_id = link_id; + mlink->wcid.link_valid = !!vif->valid_links; + mlink->wcid.def_wcid = &mvif->sta.deflink.wcid; + } + +/* Keep bands the firmware does not allow as the third link off the +* last slot, which the firmware VLS treats as the virtual link. +*/ +for_each_set_bit (link_id, &add,IEEE80211_MLD_MAX_NUM_LINKS ) + order[nadd++] = link_id; + +if ((dev->phy.chip_cap &BIT (MT792x_CHIP_CAP_MLO_HYBRID_EN)) && +hweight16 (sel_links) ==3 && nadd >=2 ) { + link_conf =mt792x_vif_to_bss_conf (vif, order[nadd -1 ]); +if (link_conf && link_conf->chanreq.oper.chan) { +enum nl80211_band b = link_conf->chanreq.oper.chan->band; +u8 lim = dev->phy.mlo_third_link_band_limit; + +if ((b ==NL80211_BAND_5GHZ && (lim & MT792x_THIRD_LINK_LIMIT_5G)) || + (b ==NL80211_BAND_2GHZ && (lim & MT792x_THIRD_LINK_LIMIT_2G))) +swap (order[nadd -1 ], order[nadd -2 ]); + } + } + +for (i =0 ; i < nadd; i++) { + link_id = order[i]; + mconf = mconfs[link_id]; + mlink = mlinks[link_id]; + link_conf =mt792x_vif_to_bss_conf (vif, link_id); + +rcu_assign_pointer (mvif->link_conf[link_id], mconf); +rcu_assign_pointer (mvif->sta.link[link_id], mlink); + + err =mt7925_mac_link_bss_add (dev, link_conf, mlink, +hweight16 (sel_links) !=3 , + i +1 ); +if (err <0 ) + goto free_bss; + + bss_done |=BIT (link_id); + } + +/* roc_iter looks up links via valid_links, publish before the ROC */ + mvif->valid_links = sel_links; + +/* one channel request covering all links */ + err =mt7925_set_mlo_roc (&dev->phy, pri_mconf, sel_links); +if (err <0 ) + goto free_bss; + + err =mt7925_mac_sta_add_links (dev, vif, sta, sel_links); +if (err <0 ) + goto free_roc; + +/* Re-send BSS_INFO after the STAREC so firmware binds own_mld_id on +* every link, then raise every link to STATE_ASSOC. +*/ + err =mt7925_mac_multi_links_sta_assoc (mdev, vif, sta, sel_links); +if (err <0 ) + goto free_roc; + +/* Keys were installed when only the primary link existed; install +* them on all links. +*/ + key_it.links = sel_links; +ieee80211_iter_keys (mdev->hw, vif, mt7925_set_links_key_iter, &key_it); + +mt792x_mutex_release (dev); + +return ; + +free_roc: +if (test_and_clear_bit (MT76_STATE_ROC , &dev->phy.mt76->state)) +mt7925_mcu_abort_roc (&dev->phy, pri_mconf, + dev->phy.roc_token_id); +/* roll back the added sta links that mt7925_mac_sta_add_links() +* published. The primary link's STA_REC was reset to STATE_NONE during +* the upgrade and cannot be restored here, so drop the connection and +* let mac80211 reconnect instead of leaving it half torn down. +*/ +mt7925_mac_sta_remove_links (dev, vif, sta, add); +ieee80211_connection_loss (vif); +free_bss: +for_each_set_bit (link_id, &bss_done,IEEE80211_MLD_MAX_NUM_LINKS ) +mt792x_mac_link_bss_remove (dev, mconfs[link_id], + mlinks[link_id]); +free: +for_each_set_bit (link_id, &add,IEEE80211_MLD_MAX_NUM_LINKS ) { +rcu_assign_pointer (mvif->link_conf[link_id],NULL ); +rcu_assign_pointer (mvif->sta.link[link_id],NULL ); + } + +/* wait for the readers before freeing the links */ +synchronize_rcu (); + +for_each_set_bit (link_id, &add,IEEE80211_MLD_MAX_NUM_LINKS ) { +if (mconfs[link_id]) +devm_kfree (dev->mt76.dev, mconfs[link_id]); +if (mlinks[link_id]) +devm_kfree (dev->mt76.dev, mlinks[link_id]); + } + + mvif->valid_links = vif->active_links; + +mt792x_mutex_release (dev); +} + +int mt7925_mac_sta_event (struct mt76_dev *mdev,struct ieee80211_vif *vif, +struct ieee80211_sta *sta,enum mt76_sta_event ev) +{ + struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76); +struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; +struct ieee80211_link_sta *link_sta = &sta->deflink; + +if (mvif->roc_join_held && !sta->tdls && + (ev ==MT76_STA_EVENT_AUTHORIZE || ev ==MT76_STA_EVENT_DISASSOC )) { + mvif->roc_join_held = false; +mt7925_abort_roc (mvif->phy, &mvif->bss_conf); + } + +switch (ev) { +case MT76_STA_EVENT_ASSOC : +if (ieee80211_vif_is_mld (vif)) { +struct mt792x_sta *msta = + (struct mt792x_sta *)sta->drv_priv; + + link_sta =mt792x_sta_to_link_sta (vif, sta, + msta->deflink_id); + } +mt7925_mac_link_sta_assoc (mdev, vif, link_sta); +break ; +case MT76_STA_EVENT_AUTHORIZE : +if (vif->type ==NL80211_IFTYPE_NAN_DATA ) { +int ret; + +mt792x_mutex_acquire (dev); + ret =mt792x_nan_map_sta_rec (mdev, vif, sta); +mt792x_mutex_release (dev); + +return ret; + } + +if (ieee80211_vif_is_mld (vif)) +mt7925_mac_set_links (mdev, vif, sta); +break ; +default : +break ; + } + +return 0 ; +} +EXPORT_SYMBOL_GPL (mt7925_mac_sta_event); +void mt7925_mac_sta_remove (struct mt76_dev *mdev,struct ieee80211_vif *vif,struct ieee80211_sta *sta) {
@@ -2531,7 +2744,6 @@ mt7925_change_vif_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif,unsigned long add = new_links & ~old_links;unsigned long rem = old_links & ~new_links;struct mt792x_dev *dev =mt792x_hw_dev (hw); -struct mt792x_phy *phy =mt792x_hw_phy (hw);struct ieee80211_bss_conf *link_conf;u8 link_idx =hweight16 (old_links);unsigned int link_id;
@@ -2540,6 +2752,20 @@ mt7925_change_vif_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif,if (old_links == new_links)return 0 ; +/* The links already exist, so there is nothing to set up. Links are +* not added or removed dynamically; ML reconfiguration is not yet +* supported (TBD). +*/ +if (!(new_links & ~mvif->valid_links) && new_links) +return 0 ; + +/* On teardown mac80211 only passes the active links, but links that +* the firmware never reported active were never in active_links. Use +* the driver's own valid_links so every published sub-link is freed. +*/ +if (!new_links) + rem = mvif->valid_links; +mt792x_mutex_acquire (dev);for_each_set_bit (link_id, &rem,IEEE80211_MLD_MAX_NUM_LINKS ) {
@@ -2606,13 +2832,6 @@ mt7925_change_vif_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif, link_idx++);if (err <0 ) goto free; - -if (mconf != &mvif->bss_conf) { - err =mt7925_set_mlo_roc (phy, &mvif->bss_conf, - vif->active_links); -if (err <0 ) - goto free; - } } mvif->valid_links = new_links;
@@ -2657,28 +2876,13 @@ static int mt7925_change_sta_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_sta *sta, u16 old_links, u16 new_links) { - unsigned long add = new_links & ~old_links; -unsigned long rem = old_links & ~new_links; -struct mt792x_dev *dev =mt792x_hw_dev (hw); -int err =0 ; - -if (old_links == new_links) -return 0 ; - -mt792x_mutex_acquire (dev); - - err =mt7925_mac_sta_remove_links (dev, vif, sta, rem); -if (err <0 ) - goto out; - - err =mt7925_mac_sta_add_links (dev, vif, sta, add); -if (err <0 ) - goto out; - -out: -mt792x_mutex_release (dev); - -return err; + /* No-op: links are set up in one shot by mt7925_mac_set_links() at + * AUTHORIZE and torn down by mt7925_mac_sta_remove() on the sta_state + * path. Links are not added or removed dynamically here; ML + * reconfiguration is not yet supported (TBD). mac80211 requires the + * hook to be present. + */ + return 0; } static int
Signature · 1 line
2.45.2
PATCH 24/28 wifi: mt76: mt7925: skip re-adding the primary MLD BSS_INFO in chanctx ops
In reply to Emery HsinThe primary link BSS_INFO is already sent from the sta add, assoc and remove paths and from mt7925_mac_set_links(), so the chanctx ops no longer resend it for an MLD station.
--- .../net/wireless/mediatek/mt76/mt7925/main.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/main.c +2 -15
@@ -2914,7 +2914,6 @@ static int mt7925_assign_vif_chanctx(struct ieee80211_hw *hw,struct mt792x_chanctx *mctx = (struct mt792x_chanctx *)ctx->drv_priv;struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;struct mt792x_dev *dev =mt792x_hw_dev (hw); -struct ieee80211_bss_conf *pri_link_conf;struct mt792x_bss_conf *mconf;u8 band_idx;
@@ -2922,12 +2921,6 @@ static int mt7925_assign_vif_chanctx(struct ieee80211_hw *hw,if (ieee80211_vif_is_mld (vif)) { mconf =mt792x_vif_to_link (mvif, link_conf->link_id); - pri_link_conf =mt792x_vif_to_bss_conf (vif, mvif->deflink_id); - -if (vif->type ==NL80211_IFTYPE_STATION && - mconf == &mvif->bss_conf) -mt7925_mcu_add_bss_info (&dev->phy,NULL , pri_link_conf, -NULL , true); }else { mconf = &mvif->bss_conf;
@@ -2961,16 +2954,10 @@ static void mt7925_unassign_vif_chanctx(struct ieee80211_hw *hw,mutex_lock (&dev->mt76.mutex); -if (ieee80211_vif_is_mld (vif)) { +if (ieee80211_vif_is_mld (vif)) mconf =mt792x_vif_to_link (mvif, link_conf->link_id); - -if (vif->type ==NL80211_IFTYPE_STATION && - mconf == &mvif->bss_conf) -mt7925_mcu_add_bss_info (&dev->phy,NULL , link_conf, -NULL , false); - }else { +else mconf = &mvif->bss_conf; - } mctx->bss_conf =NULL ; mconf->mt76.ctx =NULL ;
Signature · 1 line
2.45.2
PATCH 25/28 wifi: mt76: mt7925: apply FW-reported MLO link state
In reply to Emery HsinHandle the UNI STAREC event (0x0f) carrying the MLO link-state TLV (tag 0x27) and fold the reported ACTIVE/INACTIVE state into vif->active_links via ieee80211_set_active_links_async().
--- .../wireless/mediatek/mt76/mt76_connac_mcu.h | 1 + .../net/wireless/mediatek/mt76/mt7925/main.c | 2 + .../net/wireless/mediatek/mt76/mt7925/mcu.c | 93 +++++++++++++++++++ .../wireless/mediatek/mt76/mt7925/mt7925.h | 23 +++++ drivers/net/wireless/mediatek/mt76/mt792x.h | 2 + 5 files changed, 121 insertions(+)
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +1 -0
@@ -1098,6 +1098,7 @@ enum {MCU_UNI_EVENT_BSS_BEACON_LOSS =0x0c ,MCU_UNI_EVENT_PS_SYNC =0x0d ,MCU_UNI_EVENT_SCAN_DONE =0x0e , +MCU_UNI_EVENT_STAREC =0x0f ,MCU_UNI_EVENT_RDD_REPORT =0x11 ,MCU_UNI_EVENT_SAP =0x1c , MCU_UNI_EVENT_ROC = 0x27,
drivers/net/wireless/mediatek/mt76/mt7925/main.c +2 -0
@@ -484,6 +484,7 @@ mt7925_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) mvif->sta.vif = mvif; mvif->deflink_id =IEEE80211_LINK_UNSPECIFIED ; mvif->mlo_pm_state = MT792x_MLO_LINK_DISASSOC; + mvif->delay_inactive_links =U16_MAX ; mvif->valid_links =0 ; ret = mt7925_mac_link_bss_add(dev, &vif->bss_conf, &mvif->sta.deflink,
@@ -1889,6 +1890,7 @@ void mt7925_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif, } mvif->mlo_pm_state = MT792x_MLO_LINK_DISASSOC; + mvif->delay_inactive_links =U16_MAX ; }EXPORT_SYMBOL_GPL (mt7925_mac_sta_remove);
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +93 -0
105 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h +23 -0
@@ -133,6 +133,29 @@ struct mt7925_uni_beacon_loss_event {struct mt7925_beacon_loss_tlv beacon_loss; } __packed; +/* STAREC event: MLO link state */ +#define MT7925_STAREC_TAG_MLO_LINK_STATE 0x27 + +/* link_state values */ +#define MT7925_MLO_LINK_STATE_ACTIVE 0 +#define MT7925_MLO_LINK_STATE_INACTIVE 1 + +struct mt7925_starec_mlo_link_state_tlv { +__le16 tag; +__le16 len; +u8 link_state; +u8 reason; +u8 pad[2 ]; +} __packed; + +struct mt7925_uni_starec_event { +struct { +__le16 wlan_idx; +u8 pad[2 ]; + } __packed hdr; +u8 tlv[]; +} __packed; +struct mt7925_uni_rssi_monitor_event {__le16 tag;__le16 len;
drivers/net/wireless/mediatek/mt76/mt792x.h +2 -0
@@ -220,6 +220,8 @@ struct mt792x_vif {struct mt792x_phy *phy;bool roc_join_held;/* join ROC kept until the STA is authorized */ u16 valid_links; +/* Links held back from being deactivated, U16_MAX when none is held. */ +u16 delay_inactive_links;u8 deflink_id;enum mt792x_mlo_pm_state mlo_pm_state;
Signature · 1 line
2.45.2
PATCH 26/28 wifi: mt76: mt7925: remap hybrid-MLO TX to the primary link OMAC
In reply to Emery HsinIn 3-link hybrid MLO the firmware aggregates all links under the primary link OMAC. Derive the TX OM-remap index from the current valid_links when the BSS MLD TLV is built, set it there and in the TXD with OM_MAP (BIT(9) on MT7925 and MT7928, BIT(8) otherwise). Without hybrid MLO the TXD is unchanged.
--- drivers/net/wireless/mediatek/mt76/mt7925/mac.c | 13 ++++++++++++- drivers/net/wireless/mediatek/mt76/mt7925/main.c | 7 +++++++ drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 15 ++++++++++++++- drivers/net/wireless/mediatek/mt76/mt792x.h | 4 ++++ 4 files changed, 37 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/mac.c +12 -1
@@ -761,6 +761,7 @@ mt7925_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi,bool inband_disc = !!(changed & (BSS_CHANGED_UNSOL_BCAST_PROBE_RESP |BSS_CHANGED_FILS_DISCOVERY ));struct mt792x_bss_conf *mconf; +u32 om_map =0 ; mconf = vif ?mt792x_vif_to_link ((struct mt792x_vif *)vif->drv_priv, wcid->link_id) :NULL ;
@@ -772,6 +773,16 @@ mt7925_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi, band_idx = mvif->band_idx; } +/* hybrid MLO: send every link under the primary OMAC via the OM remap +* table +*/ +if (mconf && mconf->om_remap_idx != MT792x_OM_REMAP_IDX_NONE) { + omac_idx = mconf->om_remap_idx; +/* OM_MAP is BIT(9) on MT7925/MT7928, BIT(8) on other chips */ + om_map =is_mt7925 (dev) ||is_mt7928 (dev) ? +MT_TXD2_OWN_MAC_MAP_V2 :MT_TXD2_OWN_MAC_MAP ; + } +if (inband_disc) { p_fmt =MT_TX_TYPE_FW ; q_idx =MT_LMAC_ALTX0 ;
@@ -804,7 +815,7 @@ mt7925_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi, val |=FIELD_PREP (MT_TXD1_TGID , band_idx); txwi[1 ] =cpu_to_le32 (val); - txwi[2 ] =0 ; + txwi[2 ] =cpu_to_le32 (om_map); val =FIELD_PREP (MT_TXD3_REM_TX_COUNT ,15 );
drivers/net/wireless/mediatek/mt76/mt7925/main.c +7 -0
@@ -403,6 +403,11 @@ static int mt7925_mac_link_bss_add(struct mt792x_dev *dev, mconf->mt76.omac_idx = mvif->bss_conf.mt76.idx; else mconf->mt76.omac_idx = mconf->mt76.idx; +/* The hybrid-MLO TX OM remap index is derived per BSS_INFO from the +* current valid_links in mt7925_mcu_bss_mld_tlv(), not here: the deflink +* is added before the MLD exists. +*/ + mconf->om_remap_idx = MT792x_OM_REMAP_IDX_NONE; mconf->mt76.band_idx = MT792x_BAND_AUTO; mconf->absent = false;
@@ -1538,6 +1543,7 @@ static void mt7925_mac_link_sta_remove(struct mt76_dev *mdev,/* reset to auto band so the deactivate drops the band binding */ mconf->mt76.band_idx = MT792x_BAND_AUTO; + mconf->om_remap_idx = MT792x_OM_REMAP_IDX_NONE;/* back to the legacy WMM index, MLO uses 0 */ mconf->mt76.wmm_idx = mconf->mt76.idx %MT76_CONNAC_MAX_WMM_SETS ;
@@ -1608,6 +1614,7 @@ mt7925_mac_sta_remove_links(struct mt792x_dev *dev, struct ieee80211_vif *vif,/* reset to auto band before the disconnect command */ mconf->mt76.band_idx = MT792x_BAND_AUTO; + mconf->om_remap_idx = MT792x_OM_REMAP_IDX_NONE;mt7925_mcu_add_bss_info (&dev->phy, mconf->mt76.ctx, link_conf, link_sta, false);
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +14 -1
@@ -3272,10 +3272,14 @@ mt7925_mcu_bss_mld_tlv(struct sk_buff *skb,struct bss_mld_tlv *mld;struct tlv *tlv;bool is_mld; +bool is_hybrid;bool is_supported_ap = false; is_mld =ieee80211_vif_is_mld (link_conf->vif) || (hweight16 (mvif->valid_links) >1 ); +/* three links means hybrid MLO */ + is_hybrid =hweight16 (mvif->valid_links) >=3 && + (phy->chip_cap &BIT (MT792x_CHIP_CAP_MLO_HYBRID_EN)); tlv =mt76_connac_mcu_add_tlv (skb,UNI_BSS_INFO_MLD ,sizeof (*mld)); mld = (struct bss_mld_tlv *)tlv;
@@ -3284,7 +3288,16 @@ mt7925_mcu_bss_mld_tlv(struct sk_buff *skb,/* apply the index of the primary link */ mld->group_mld_id = is_mld ? mvif->bss_conf.mt76.idx :0xff ; mld->own_mld_id = mconf->mt76.idx +32 ; - mld->remap_idx =0xff ; +/* Hybrid MLO remaps every link's TX OWN_MAC to the primary link OMAC; +* derive it here from the current valid_links so the deflink (added +* before the MLD existed) is covered too, and cache it for the TX path. +*/ + mld->remap_idx = is_hybrid ? mvif->bss_conf.mt76.omac_idx : + MT792x_OM_REMAP_IDX_NONE; + mconf->om_remap_idx = mld->remap_idx; + +/* enable hybrid MLO in firmware */ + mld->hybrid_mode = is_hybrid;/* single active link, STR is not supported */ mld->max_link_num =0 ;
drivers/net/wireless/mediatek/mt76/mt792x.h +4 -0
@@ -176,6 +176,9 @@ struct mt792x_chanctx {struct mt792x_bss_conf *bss_conf; }; +/* no OM remap */ +#define MT792x_OM_REMAP_IDX_NONE 0xff +struct mt792x_bss_conf {struct mt76_vif_link mt76;/* must be first */ struct mt792x_vif *vif;
@@ -189,6 +192,7 @@ struct mt792x_bss_conf {/* For group-addressed frames that are sent outside a TXQ */ struct mt792x_link_sta bmc;bool bmc_valid; +u8 om_remap_idx;/* TX OM remap index, 0xff if none */ };struct mt792x_nan_conf {
Signature · 1 line
2.45.2
PATCH 27/28 wifi: mt76: mt7925: clear the MLD BSS tag on deactivate
In reply to Emery HsinAdd an enable flag to mt7925_mcu_bss_mld_tlv(). On deactivate clear the MLD fields, otherwise the firmware keeps the hybrid-MLO OM remap and the deflink's TX OWN_MAC stays mapped to a dead MLO primary OMAC after reconnect.
--- drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +9 -5
@@ -3263,7 +3263,7 @@ mt7925_mcu_bss_bmc_tlv(struct sk_buff *skb, struct mt792x_phy *phy,static void mt7925_mcu_bss_mld_tlv (struct sk_buff *skb, -struct ieee80211_bss_conf *link_conf) +struct ieee80211_bss_conf *link_conf,bool enable) {struct ieee80211_vif *vif = link_conf->vif;struct mt792x_bss_conf *mconf =mt792x_link_conf_to_mconf (link_conf);
@@ -3275,10 +3275,14 @@ mt7925_mcu_bss_mld_tlv(struct sk_buff *skb,bool is_hybrid;bool is_supported_ap = false; - is_mld =ieee80211_vif_is_mld (link_conf->vif) || - (hweight16 (mvif->valid_links) >1 ); +/* On deactivate clear the MLD classification. Otherwise the FW +* keeps the hybrid-MLO OM remap and the deflink's TX OWN_MAC stays +* mapped to a dead MLO primary OMAC after reconnect. +*/ + is_mld = enable && (ieee80211_vif_is_mld (link_conf->vif) || + (hweight16 (mvif->valid_links) >1 ));/* three links means hybrid MLO */ - is_hybrid =hweight16 (mvif->valid_links) >=3 && + is_hybrid = enable &&hweight16 (mvif->valid_links) >=3 && (phy->chip_cap &BIT (MT792x_CHIP_CAP_MLO_HYBRID_EN)); tlv =mt76_connac_mcu_add_tlv (skb,UNI_BSS_INFO_MLD ,sizeof (*mld));
@@ -3450,7 +3454,7 @@ int mt7925_mcu_add_bss_info_sta(struct mt792x_phy *phy,mt7925_mcu_bss_sec_tlv (skb, link_conf);mt7925_mcu_bss_bmc_tlv (skb, phy, ctx, link_conf);mt7925_mcu_bss_qos_tlv (skb, link_conf); -mt7925_mcu_bss_mld_tlv (skb, link_conf); +mt7925_mcu_bss_mld_tlv (skb, link_conf, enable);mt7925_mcu_bss_ifs_tlv (skb, link_conf);if (link_conf->he_support) {
Signature · 1 line
2.45.2
PATCH 28/28 wifi: mt76: mt7925: add hm_alg_ctrl debugfs to override the MLO link plan
In reply to Emery HsinAdd a debugfs knob to override the firmware hybrid-MLO link plan for validation. Writing "<manual>-<obss>-<bt>-<plan>-<obss%>-<bt%>" to /sys/kernel/debug/ieee80211/phyN/mt76/hm_alg_ctrl sends the UNI_CMD_HM ALG_CTRL TLV to the firmware.
--- .../wireless/mediatek/mt76/mt76_connac_mcu.h | 1 + .../wireless/mediatek/mt76/mt7925/debugfs.c | 41 +++++++++++++++++++ .../net/wireless/mediatek/mt76/mt7925/mcu.c | 30 ++++++++++++++ .../net/wireless/mediatek/mt76/mt7925/mcu.h | 16 ++++++++ 4 files changed, 88 insertions(+)
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +1 -0
@@ -1364,6 +1364,7 @@ enum {MCU_UNI_CMD_ASSERT_DUMP =0x6f ,MCU_UNI_CMD_EXT_EEPROM_CTRL =0x74 ,MCU_UNI_CMD_FACT_CAL =0x7c , +MCU_UNI_CMD_HM =0x7d ,MCU_UNI_CMD_RADIO_STATUS =0x80 ,MCU_UNI_CMD_MLD =0x82 , MCU_UNI_CMD_PEER_MLD = 0x83,
drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c +41 -0
53 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +30 -0
@@ -4606,3 +4606,33 @@ int mt7925_mcu_set_rssimonitor(struct mt792x_dev *dev, struct ieee80211_vif *vifreturn mt76_mcu_send_msg (&dev->mt76,MCU_UNI_CMD (RSSI_MONITOR ), &req,sizeof (req), false); } + +int mt7925_mcu_set_hm_alg_ctrl (struct mt792x_dev *dev, +struct mt7925_hm_alg_ctrl *ctrl) +{ +struct { +u8 rsv[4 ];/* struct UNI_CMD_HM fixed field */ +__le16 tag; +__le16 len; +u8 manual_mode_en; +u8 force_obss; +u8 force_bt; +u8 force_plan; +u8 obss_time_pct; +u8 bt_pct; +u8 rsv2[6 ]; + } __packed req = { + .tag =cpu_to_le16 (UNI_CMD_HM_TAG_ALG_CTRL ), + .len =cpu_to_le16 (sizeof (req) - + offsetof(typeof (req ), tag)), + .manual_mode_en = ctrl->manual_mode_en, + .force_obss = ctrl->force_obss, + .force_bt = ctrl->force_bt, + .force_plan = ctrl->force_plan, + .obss_time_pct = ctrl->obss_time_pct, + .bt_pct = ctrl->bt_pct, + }; + +return mt76_mcu_send_msg (&dev->mt76,MCU_UNI_CMD (HM ), &req, +sizeof (req), true); +}
drivers/net/wireless/mediatek/mt76/mt7925/mcu.h +16 -0
@@ -764,4 +764,20 @@ int mt7925_mcu_update_arp_filter(struct mt76_dev *dev,int mt7925_mcu_uni_bss_bcnft (struct mt792x_dev *dev,struct ieee80211_bss_conf *link_conf,bool enable); +/* Hybrid-MLO algorithm control. Lets the host override the firmware's +* MLO link-plan decision for validation. +*/ +#define UNI_CMD_HM_TAG_ALG_CTRL 0 + +struct mt7925_hm_alg_ctrl { +u8 manual_mode_en; +u8 force_obss; +u8 force_bt; +u8 force_plan; +u8 obss_time_pct; +u8 bt_pct; +}; + +int mt7925_mcu_set_hm_alg_ctrl (struct mt792x_dev *dev, +struct mt7925_hm_alg_ctrl *ctrl);#endif
Signature · 1 line
2.45.2