Prerequisite Refactoring for Enabling MLO on MT7925
Subsystems (3)
cover Prerequisite Refactoring for Enabling MLO on MT7925
From: Sean Wang <[email protected]>
I'm submitting some patches that are essential preliminary steps for getting Multi-Link Operation (MLO) up and running smoothly on the MT7925 driver.
Before we can activate MLO, we need to do some necessary refactoring work. This involves adjusting how the driver handles certain commands and data to support per-link STA and per-BSS operations. It's like laying down a strong foundation so that MLO can seamlessly integrate with our existing setup.
It's important to note that these patches focus solely on refactoring work. We're not changing any of the current functions or logic; we're just making sure everything is structured properly to support MLO when it's enabled.
I've tested these patches to make sure they're reliable and won't mess up anything that's already working.
Deren Wu (5):
wifi: mt76: mt792x: add struct mt792x_bss_conf
wifi: mt76: mt792x: add struct mt792x_link_sta
wifi: mt76: mt792x: add struct mt792x_chanctx
wifi: mt76: mt7925: support for split bss_info_changed method
wifi: mt76: mt7925: extend mt7925_mcu_set_tx with for per-link BSS
Sean Wang (42):
wifi: mt76: mt792x: extend mt76_connac_mcu_uni_add_dev for per-link
BSS
wifi: mt76: mt7925: extend mt7925_mcu_add_bss_info for per-link BSS
wifi: mt76: mt7925: extend mt7925_mcu_set_timing for per-link BSS
wifi: mt76: mt7925: extend mt7925_mcu_bss_ifs_tlv for per-link BSS
wifi: mt76: mt7925: extend mt7925_mcu_bss_color_tlv for per-link BSS
wifi: mt76: mt7925: extend mt7925_mcu_bss_he_tlv for per-link BSS
wifi: mt76: mt7925: extend mt7925_mcu_bss_qos_tlv for per-link BSS
wifi: mt76: mt7925: extend mt7925_mcu_bss_mld_tlv for per-link BSS
wifi: mt76: mt7925: extend mt7925_mcu_bss_bmc_tlv for per-link BSS
wifi: mt76: mt7925: remove unused parameters in mt7925_mcu_bss_bmc_tlv
wifi: mt76: mt7925: extend mt7925_mcu_bss_sec_tlv for per-link BSS
wifi: mt76: mt7925: extend mt7925_mcu_bss_basic_tlv for per-link BSS
wifi: mt76: mt7925: extend mt7925_mcu_set_bss_pm for per-link BSS
wifi: mt76: mt7925: extend mt7925_mcu_[abort, set]_roc for per-link
BSS
wifi: mt76: mt7925: extend mt7925_mcu_uni_bss_bcnft for per-link BSS
wifi: mt76: mt7925: extend mt7925_mcu_uni_bss_ps for per-link BSS
wifi: mt76: mt7925: add mt7925_mcu_bss_rlm_tlv to constitue the RLM
TLV
wifi: mt76: mt7925: mt7925_mcu_set_chctx rely on
mt7925_mcu_bss_rlm_tlv
wifi: mt76: mt7925: extend mt7925_mcu_sta_update for per-link STA
wifi: mt76: mt7925: extend mt7925_mcu_sta_state_v2_tlv for per-link
STA
wifi: mt76: mt7925: extend mt7925_mcu_sta_rate_ctrl_tlv with per-link
STA
wifi: mt76: mt7925: extend mt7925_mcu_sta_eht_tlv for per-link STA
wifi: mt76: mt7925: extend mt7925_mcu_sta_he_6g_tlv for per-link STA
wifi: mt76: mt7925: extend mt7925_mcu_sta_he_tlv for per-link STA
wifi: mt76: mt7925: extend mt7925_mcu_sta_amsdu_tlv for per-link STA
wifi: mt76: mt7925: extend mt7925_mcu_sta_vht_tlv for per-link STA
wifi: mt76: mt7925: extend mt7925_mcu_sta_ht_tlv for per-link STA
wifi: mt76: mt7925: extend mt7925_mcu_sta_phy_tlv for per-link STA
wifi: mt76: mt7925: extend mt7925_get_phy_mode_ext for per-link STA
wifi: mt76: mt7925: extend mt7925_get_phy_mode for per-link STA
wifi: mt76: mt792x: extend mt76_connac_get_phy_mode_v2 for per-link
STA
wifi: mt76: mt762x: extend mt76_connac_mcu_sta_basic_tlv for per-link
STA
wifi: mt76: mt7925: extend mt7925_mcu_sta_hdr_trans_tlv for per-link
STA
wifi: mt76: mt7925: extend mt7925_mcu_add_bss_info for per-link STA
wifi: mt76: mt7925: extend mt7925_mcu_bss_mld_tlv for per-link STA
wifi: mt76: mt7925: extend mt7925_mcu_bss_basic_tlv for per-link STA
wifi: mt76: mt7925: add mt7925_mac_link_sta_add to create per-link STA
wifi: mt76: mt7925: add mt7925_mac_link_sta_assoc to associate
per-link STA
wifi: mt76: mt7925: add mt7925_mac_link_sta_remove to remove per-link
STA
wifi: mt76: mt7925: add mt7925_mac_link_bss_add to create per-link BSS
wifi: mt76: mt7925: add mt7925_mac_link_bss_remove to remove per-link
BSS
wifi: mt76: mt7925: simpify mt7925_mcu_sta_cmd logic by removing
fw_offload
.../net/wireless/mediatek/mt76/mt7615/mcu.c | 8 +- .../wireless/mediatek/mt76/mt76_connac_mcu.c | 56 +- .../wireless/mediatek/mt76/mt76_connac_mcu.h | 19 +- .../net/wireless/mediatek/mt76/mt7915/mcu.c | 4 +- .../net/wireless/mediatek/mt76/mt7921/mac.c | 66 +-- .../net/wireless/mediatek/mt76/mt7921/main.c | 143 +++-- .../net/wireless/mediatek/mt76/mt7921/mcu.c | 46 +- .../wireless/mediatek/mt76/mt7921/pci_mac.c | 4 +- .../net/wireless/mediatek/mt76/mt7925/mac.c | 69 +-- .../net/wireless/mediatek/mt76/mt7925/main.c | 452 +++++++++------- .../net/wireless/mediatek/mt76/mt7925/mcu.c | 500 ++++++++++-------- .../net/wireless/mediatek/mt76/mt7925/mcu.h | 25 +- .../wireless/mediatek/mt76/mt7925/mt7925.h | 15 +- .../wireless/mediatek/mt76/mt7925/pci_mac.c | 4 +- drivers/net/wireless/mediatek/mt76/mt792x.h | 78 ++- .../net/wireless/mediatek/mt76/mt792x_core.c | 70 ++- .../net/wireless/mediatek/mt76/mt792x_mac.c | 8 +- .../net/wireless/mediatek/mt76/mt7996/mcu.c | 2 +- 18 files changed, 896 insertions(+), 673 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/47 wifi: mt76: mt792x: add struct mt792x_bss_conf
From: Deren Wu <[email protected]>
We are introducing a new structure, mt792x_bss_conf, to manage per-link configurations in preparation for future STA support of Multi-Link Operation (MLO).
The patch does not include any logic changes, only structural changes.
We have moved relevant parameters from the mt7921x_vif structure such as to mt76 of mt76_vif structure, rssi and Tx queue parameters to mt7921x_bss_conf structure. We can access those members to configure the BSS for this interface, whether it is our own BSS or the one we are associated with.
However, we have not yet created the per-link BSS configuration indexed by link ID for Multi-Link Device (MLD) support. This step needs to be extended before adding MLD support for AP mode.
--- .../net/wireless/mediatek/mt76/mt7921/main.c | 42 +++++++------- .../net/wireless/mediatek/mt76/mt7921/mcu.c | 42 +++++++------- .../net/wireless/mediatek/mt76/mt7925/main.c | 56 +++++++++---------- .../net/wireless/mediatek/mt76/mt7925/mcu.c | 56 +++++++++---------- drivers/net/wireless/mediatek/mt76/mt792x.h | 12 ++-- .../net/wireless/mediatek/mt76/mt792x_core.c | 18 +++--- .../net/wireless/mediatek/mt76/mt792x_mac.c | 2 +- 7 files changed, 115 insertions(+), 113 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7921/main.c +21 -21
@@ -295,30 +295,30 @@ mt7921_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)mt792x_mutex_acquire (dev); - mvif->mt76.idx =__ffs64 (~dev->mt76.vif_mask); -if (mvif->mt76.idx >= MT792x_MAX_INTERFACES) { + mvif->bss_conf.mt76.idx =__ffs64 (~dev->mt76.vif_mask); +if (mvif->bss_conf.mt76.idx >= MT792x_MAX_INTERFACES) { ret = -ENOSPC ; goto out; } - mvif->mt76.omac_idx = mvif->mt76.idx; + mvif->bss_conf.mt76.omac_idx = mvif->bss_conf.mt76.idx; mvif->phy = phy; - mvif->mt76.band_idx =0 ; - mvif->mt76.wmm_idx = mvif->mt76.idx %MT76_CONNAC_MAX_WMM_SETS ; + 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, &mvif->sta.wcid, true);if (ret) goto out; - dev->mt76.vif_mask |=BIT_ULL (mvif->mt76.idx); - phy->omac_mask |=BIT_ULL (mvif->mt76.omac_idx); + dev->mt76.vif_mask |=BIT_ULL (mvif->bss_conf.mt76.idx); + phy->omac_mask |=BIT_ULL (mvif->bss_conf.mt76.omac_idx); - idx = MT792x_WTBL_RESERVED - mvif->mt76.idx; + idx = MT792x_WTBL_RESERVED - mvif->bss_conf.mt76.idx;INIT_LIST_HEAD (&mvif->sta.wcid.poll_list); mvif->sta.wcid.idx = idx; - mvif->sta.wcid.phy_idx = mvif->mt76.band_idx; + mvif->sta.wcid.phy_idx = mvif->bss_conf.mt76.band_idx; mvif->sta.wcid.hw_key_idx =-1 ; mvif->sta.wcid.tx_info |=MT_WCID_TX_INFO_SET ;mt76_wcid_init (&mvif->sta.wcid);
@@ -326,7 +326,7 @@ mt7921_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)mt7921_mac_wtbl_update (dev, idx,MT_WTBL_UPDATE_ADM_COUNT_CLEAR ); -ewma_rssi_init (&mvif->rssi); +ewma_rssi_init (&mvif->bss_conf.rssi);rcu_assign_pointer (dev->mt76.wcid[idx], &mvif->sta.wcid);if (vif->txq) {
@@ -718,7 +718,7 @@ static void mt7921_bss_info_changed(struct ieee80211_hw *hw,if (changed &BSS_CHANGED_ARP_FILTER ) {struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; -mt76_connac_mcu_update_arp_filter (&dev->mt76, &mvif->mt76, +mt76_connac_mcu_update_arp_filter (&dev->mt76, &mvif->bss_conf.mt76, info); }
@@ -803,7 +803,7 @@ int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif, msta->vif = mvif; msta->wcid.sta =1 ; msta->wcid.idx = idx; - msta->wcid.phy_idx = mvif->mt76.band_idx; + msta->wcid.phy_idx = mvif->bss_conf.mt76.band_idx; msta->wcid.tx_info |=MT_WCID_TX_INFO_SET ; msta->last_txs = jiffies;
@@ -841,7 +841,7 @@ void mt7921_mac_sta_assoc(struct mt76_dev *mdev, struct ieee80211_vif *vif,if (vif->type ==NL80211_IFTYPE_STATION && !sta->tdls)mt76_connac_mcu_uni_add_bss (&dev->mphy, vif, &mvif->sta.wcid, - true, mvif->mt76.ctx); + true, mvif->bss_conf.mt76.ctx);ewma_avg_signal_init (&msta->avg_ack_signal);
@@ -872,11 +872,11 @@ void mt7921_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; mvif->wep_sta =NULL ; -ewma_rssi_init (&mvif->rssi); +ewma_rssi_init (&mvif->bss_conf.rssi);if (!sta->tdls)mt76_connac_mcu_uni_add_bss (&dev->mphy, vif, &mvif->sta.wcid, false, - mvif->mt76.ctx); + mvif->bss_conf.mt76.ctx); }spin_lock_bh (&dev->mt76.sta_poll_lock);
@@ -1196,7 +1196,7 @@ static void mt7921_ipv6_addr_change(struct ieee80211_hw *hw,struct mt76_connac_arpns_tlv arpns; } req_hdr = { .hdr = { - .bss_idx = mvif->mt76.idx, + .bss_idx = mvif->bss_conf.mt76.idx, }, .arpns = { .tag = cpu_to_le16(UNI_OFFLOAD_OFFLOAD_ND),
@@ -1295,7 +1295,7 @@ mt7921_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif,mt792x_mutex_acquire (dev); err =mt76_connac_mcu_uni_add_bss (phy->mt76, vif, &mvif->sta.wcid, - true, mvif->mt76.ctx); + true, mvif->bss_conf.mt76.ctx);if (err) goto out;
@@ -1327,7 +1327,7 @@ mt7921_stop_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif, goto out;mt76_connac_mcu_uni_add_bss (phy->mt76, vif, &mvif->sta.wcid, false, - mvif->mt76.ctx); + mvif->bss_conf.mt76.ctx); out:mt792x_mutex_release (dev);
@@ -1352,13 +1352,13 @@ static void mt7921_ctx_iter(void *priv, u8 *mac,struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;struct ieee80211_chanctx_conf *ctx = priv; -if (ctx != mvif->mt76.ctx) +if (ctx != mvif->bss_conf.mt76.ctx)return ;if (vif->type ==NL80211_IFTYPE_MONITOR )mt7921_mcu_config_sniffer (mvif, ctx);else -mt76_connac_mcu_uni_set_chctx (mvif->phy->mt76, &mvif->mt76, ctx); +mt76_connac_mcu_uni_set_chctx (mvif->phy->mt76, &mvif->bss_conf.mt76, ctx); } static void
@@ -1385,7 +1385,7 @@ static void mt7921_mgd_prepare_tx(struct ieee80211_hw *hw,jiffies_to_msecs (HZ );mt792x_mutex_acquire (dev); -mt7921_set_roc (mvif->phy, mvif, mvif->mt76.ctx->def.chan, duration, +mt7921_set_roc (mvif->phy, mvif, mvif->bss_conf.mt76.ctx->def.chan, duration,MT7921_ROC_REQ_JOIN );mt792x_mutex_release (dev); }
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +21 -21
153 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt7925/main.c +28 -28
167 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +28 -28
200 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt792x.h +7 -5
@@ -96,17 +96,19 @@ struct mt792x_sta {DECLARE_EWMA (rssi,10 ,8 ); -struct mt792x_vif { +struct mt792x_bss_conf {struct mt76_vif mt76;/* must be first */ +struct ewma_rssi rssi; +struct ieee80211_tx_queue_params queue_params[IEEE80211_NUM_ACS ]; +}; + +struct mt792x_vif { +struct mt792x_bss_conf bss_conf;/* must be first */ struct mt792x_sta sta;struct mt792x_sta *wep_sta;struct mt792x_phy *phy; - -struct ewma_rssi rssi; - -struct ieee80211_tx_queue_params queue_params[IEEE80211_NUM_ACS ]; };struct mt792x_phy {
drivers/net/wireless/mediatek/mt76/mt792x_core.c +9 -9
@@ -128,8 +128,8 @@ void mt792x_remove_interface(struct ieee80211_hw *hw,rcu_assign_pointer (dev->mt76.wcid[idx],NULL ); - dev->mt76.vif_mask &= ~BIT_ULL (mvif->mt76.idx); - phy->omac_mask &= ~BIT_ULL (mvif->mt76.omac_idx); + dev->mt76.vif_mask &= ~BIT_ULL (mvif->bss_conf.mt76.idx); + phy->omac_mask &= ~BIT_ULL (mvif->bss_conf.mt76.omac_idx);mt792x_mutex_release (dev);spin_lock_bh (&dev->mt76.sta_poll_lock);
@@ -149,7 +149,7 @@ int mt792x_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif,/* no need to update right away, we'll get BSS_CHANGED_QOS */ queue =mt76_connac_lmac_mapping (queue); - mvif->queue_params[queue] = *params; + mvif->bss_conf.queue_params[queue] = *params;return 0 ; }
@@ -178,7 +178,7 @@ u64 mt792x_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) {struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;struct mt792x_dev *dev =mt792x_hw_dev (hw); -u8 omac_idx = mvif->mt76.omac_idx; +u8 omac_idx = mvif->bss_conf.mt76.omac_idx;union {u64 t64;u32 t32[2 ];
@@ -204,7 +204,7 @@ void mt792x_set_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif, {struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;struct mt792x_dev *dev =mt792x_hw_dev (hw); -u8 omac_idx = mvif->mt76.omac_idx; +u8 omac_idx = mvif->bss_conf.mt76.omac_idx;union {u64 t64;u32 t32[2 ];
@@ -265,7 +265,7 @@ int mt792x_assign_vif_chanctx(struct ieee80211_hw *hw,struct mt792x_dev *dev =mt792x_hw_dev (hw);mutex_lock (&dev->mt76.mutex); - mvif->mt76.ctx = ctx; + mvif->bss_conf.mt76.ctx = ctx;mutex_unlock (&dev->mt76.mutex);return 0 ;
@@ -281,7 +281,7 @@ void mt792x_unassign_vif_chanctx(struct ieee80211_hw *hw,struct mt792x_dev *dev =mt792x_hw_dev (hw);mutex_lock (&dev->mt76.mutex); - mvif->mt76.ctx =NULL ; + mvif->bss_conf.mt76.ctx =NULL ;mutex_unlock (&dev->mt76.mutex); }EXPORT_SYMBOL_GPL (mt792x_unassign_vif_chanctx);
@@ -405,7 +405,7 @@ mt792x_ethtool_worker(void *wi_data, struct ieee80211_sta *sta)struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv;struct mt76_ethtool_worker_info *wi = wi_data; -if (msta->vif->mt76.idx != wi->idx) +if (msta->vif->bss_conf.mt76.idx != wi->idx)return ;mt76_ethtool_worker (wi, &msta->wcid.stats, true);
@@ -421,7 +421,7 @@ void mt792x_get_et_stats(struct ieee80211_hw *hw, struct ieee80211_vif *vif,struct mt76_mib_stats *mib = &phy->mib;struct mt76_ethtool_worker_info wi = { .data = data, - .idx = mvif->mt76.idx, + .idx = mvif->bss_conf.mt76.idx, };int i, ei =0 ;
drivers/net/wireless/mediatek/mt76/mt792x_mac.c +1 -1
@@ -173,7 +173,7 @@ mt792x_mac_rssi_iter(void *priv, u8 *mac, struct ieee80211_vif *vif)if (!ether_addr_equal (vif->addr, hdr->addr1))return ; -ewma_rssi_add (&mvif->rssi, -status->signal); +ewma_rssi_add (&mvif->bss_conf.rssi, -status->signal); }void mt792x_mac_assoc_rssi (struct mt792x_dev *dev,struct sk_buff *skb)
Signature · 1 line
2.34.1
PATCH 2/47 wifi: mt76: mt792x: add struct mt792x_link_sta
In reply to [email protected]From: Deren Wu <[email protected]>
We are introducing a new structure, mt792x_link_sta, to manage per-link configurations in preparation for future station (STA) support of Multi-Link Operation (MLO).
This patch only includes structural changes and does not involve any logic changes.
We have moved relevant parameters, such as the wcid from the mt76_wcid structure, from the mt7921x_sta structure to the mt792x_link_sta structure.
For current drivers that do not support MLO, there is only one link STA, and link information is accessed via the deflink member.
However, we have not yet created the per-link BSS configuration indexed by link ID for Multi-Link Device (MLD) support in mt7921x_sta. This step needs to be completed before adding MLD support for STA mode.
--- .../net/wireless/mediatek/mt76/mt7921/mac.c | 65 ++++++++-------- .../net/wireless/mediatek/mt76/mt7921/main.c | 76 +++++++++---------- .../net/wireless/mediatek/mt76/mt7921/mcu.c | 4 +- .../wireless/mediatek/mt76/mt7921/pci_mac.c | 4 +- .../net/wireless/mediatek/mt76/mt7925/mac.c | 66 ++++++++-------- .../net/wireless/mediatek/mt76/mt7925/main.c | 66 ++++++++-------- .../net/wireless/mediatek/mt76/mt7925/mcu.c | 17 +++-- .../wireless/mediatek/mt76/mt7925/pci_mac.c | 4 +- drivers/net/wireless/mediatek/mt76/mt792x.h | 10 ++- .../net/wireless/mediatek/mt76/mt792x_core.c | 28 +++---- .../net/wireless/mediatek/mt76/mt792x_mac.c | 6 +- 11 files changed, 180 insertions(+), 166 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7921/mac.c +35 -30
@@ -39,6 +39,7 @@ static void mt7921_mac_sta_poll(struct mt792x_dev *dev) };struct ieee80211_sta *sta;struct mt792x_sta *msta; +struct mt792x_link_sta *mlink;u32 tx_time[IEEE80211_NUM_ACS ], rx_time[IEEE80211_NUM_ACS ];LIST_HEAD (sta_poll_list);struct rate_info *rate;
@@ -60,23 +61,25 @@ static void mt7921_mac_sta_poll(struct mt792x_dev *dev)spin_unlock_bh (&dev->mt76.sta_poll_lock);break ; } - msta =list_first_entry (&sta_poll_list, - struct mt792x_sta, wcid.poll_list); -list_del_init (&msta->wcid.poll_list); + mlink =list_first_entry (&sta_poll_list, + struct mt792x_link_sta, + wcid.poll_list); + msta = container_of(mlink, struct mt792x_sta, deflink); +list_del_init (&mlink->wcid.poll_list);spin_unlock_bh (&dev->mt76.sta_poll_lock); - idx = msta->wcid.idx; + idx = mlink->wcid.idx; addr =mt7921_mac_wtbl_lmac_addr (idx,MT_WTBL_AC0_CTT_OFFSET );for (i =0 ; i <IEEE80211_NUM_ACS ; i++) { -u32 tx_last = msta->airtime_ac[i]; -u32 rx_last = msta->airtime_ac[i +4 ]; +u32 tx_last = mlink->airtime_ac[i]; +u32 rx_last = mlink->airtime_ac[i +4 ]; - msta->airtime_ac[i] =mt76_rr (dev, addr); - msta->airtime_ac[i +4 ] =mt76_rr (dev, addr +4 ); + mlink->airtime_ac[i] =mt76_rr (dev, addr); + mlink->airtime_ac[i +4 ] =mt76_rr (dev, addr +4 ); - tx_time[i] = msta->airtime_ac[i] - tx_last; - rx_time[i] = msta->airtime_ac[i +4 ] - rx_last; + tx_time[i] = mlink->airtime_ac[i] - tx_last; + rx_time[i] = mlink->airtime_ac[i +4 ] - rx_last;if ((tx_last | rx_last) &BIT (30 )) clear = true;
@@ -87,10 +90,10 @@ static void mt7921_mac_sta_poll(struct mt792x_dev *dev)if (clear) {mt7921_mac_wtbl_update (dev, idx,MT_WTBL_UPDATE_ADM_COUNT_CLEAR ); -memset (msta->airtime_ac,0 ,sizeof (msta->airtime_ac)); +memset (mlink->airtime_ac,0 ,sizeof (mlink->airtime_ac)); } -if (!msta->wcid.sta) +if (!mlink->wcid.sta)continue ; sta = container_of((void *)msta, struct ieee80211_sta,
@@ -113,7 +116,7 @@ static void mt7921_mac_sta_poll(struct mt792x_dev *dev)* we need to make sure that flags match so polling GI * from per-sta counters directly. */ - rate = &msta->wcid.rate; + rate = &mlink->wcid.rate; addr =mt7921_mac_wtbl_lmac_addr (idx,MT_WTBL_TXRX_CAP_RATE_OFFSET ); val =mt76_rr (dev, addr);
@@ -154,10 +157,10 @@ static void mt7921_mac_sta_poll(struct mt792x_dev *dev) rssi[2 ] =to_rssi (GENMASK (23 ,16 ), val); rssi[3 ] =to_rssi (GENMASK (31 ,14 ), val); - msta->ack_signal = + mlink->ack_signal =mt76_rx_signal (msta->vif->phy->mt76->antenna_mask, rssi); -ewma_avg_signal_add (&msta->avg_ack_signal, -msta->ack_signal); +ewma_avg_signal_add (&mlink->avg_ack_signal, -mlink->ack_signal); } }
@@ -180,6 +183,7 @@ mt7921_mac_fill_rx(struct mt792x_dev *dev, struct sk_buff *skb)u32 rxd3 =le32_to_cpu (rxd[3 ]);u32 rxd4 =le32_to_cpu (rxd[4 ]);struct mt792x_sta *msta =NULL ; +struct mt792x_link_sta *mlink;u16 seq_ctrl =0 ;__le16 fc =0 ;u8 mode =0 ;
@@ -210,10 +214,11 @@ mt7921_mac_fill_rx(struct mt792x_dev *dev, struct sk_buff *skb) status->wcid =mt792x_rx_get_wcid (dev, idx, unicast);if (status->wcid) { - msta = container_of(status->wcid, struct mt792x_sta, wcid); + mlink = container_of(status->wcid, struct mt792x_link_sta, wcid); + msta = container_of(mlink, struct mt792x_sta, deflink);spin_lock_bh (&dev->mt76.sta_poll_lock); -if (list_empty (&msta->wcid.poll_list)) -list_add_tail (&msta->wcid.poll_list, +if (list_empty (&mlink->wcid.poll_list)) +list_add_tail (&mlink->wcid.poll_list, &dev->mt76.sta_poll_list);spin_unlock_bh (&dev->mt76.sta_poll_lock); }
@@ -444,7 +449,7 @@ mt7921_mac_fill_rx(struct mt792x_dev *dev, struct sk_buff *skb)void mt7921_mac_add_txs (struct mt792x_dev *dev,void *data) { -struct mt792x_sta *msta =NULL ; +struct mt792x_link_sta *mlink;struct mt76_wcid *wcid;__le32 *txs_data = data;u16 wcidx;
@@ -468,15 +473,15 @@ void mt7921_mac_add_txs(struct mt792x_dev *dev, void *data)if (!wcid) goto out; - msta = container_of(wcid, struct mt792x_sta, wcid); + mlink = container_of(wcid, struct mt792x_link_sta, wcid);mt76_connac2_mac_add_txs_skb (&dev->mt76, wcid, pid, txs_data);if (!wcid->sta) goto out;spin_lock_bh (&dev->mt76.sta_poll_lock); -if (list_empty (&msta->wcid.poll_list)) -list_add_tail (&msta->wcid.poll_list, &dev->mt76.sta_poll_list); +if (list_empty (&mlink->wcid.poll_list)) +list_add_tail (&mlink->wcid.poll_list, &dev->mt76.sta_poll_list);spin_unlock_bh (&dev->mt76.sta_poll_lock); out:
@@ -513,7 +518,7 @@ static void mt7921_mac_tx_free(struct mt792x_dev *dev, void *data, int len)* 1'b0: msdu_id with the same 'wcid pair' as above. */ if (info &MT_TX_FREE_PAIR ) { -struct mt792x_sta *msta; +struct mt792x_link_sta *mlink;u16 idx; count++;
@@ -523,10 +528,10 @@ static void mt7921_mac_tx_free(struct mt792x_dev *dev, void *data, int len)if (!sta)continue ; - msta = container_of(wcid, struct mt792x_sta, wcid); + mlink = container_of(wcid, struct mt792x_link_sta, wcid);spin_lock_bh (&mdev->sta_poll_lock); -if (list_empty (&msta->wcid.poll_list)) -list_add_tail (&msta->wcid.poll_list, +if (list_empty (&mlink->wcid.poll_list)) +list_add_tail (&mlink->wcid.poll_list, &mdev->sta_poll_list);spin_unlock_bh (&mdev->sta_poll_lock);continue ;
@@ -641,11 +646,11 @@ 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, &mvif->sta.wcid, true); +mt76_connac_mcu_uni_add_dev (&dev->mphy, vif, &mvif->sta.deflink.wcid, true);mt7921_mcu_set_tx (dev, vif);if (vif->type ==NL80211_IFTYPE_AP ) { -mt76_connac_mcu_uni_add_bss (dev->phy.mt76, vif, &mvif->sta.wcid, +mt76_connac_mcu_uni_add_bss (dev->phy.mt76, vif, &mvif->sta.deflink.wcid, true,NULL );mt7921_mcu_sta_update (dev,NULL , vif, true,MT76_STA_INFO_STATE_NONE );
@@ -784,9 +789,9 @@ int mt7921_usb_sdio_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,if (sta) {struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv; -if (time_after (jiffies, msta->last_txs +HZ /4 )) { +if (time_after (jiffies, msta->deflink.last_txs +HZ /4 )) { info->flags |=IEEE80211_TX_CTL_REQ_TX_STATUS ; - msta->last_txs = jiffies; + msta->deflink.last_txs = jiffies; } }
drivers/net/wireless/mediatek/mt76/mt7921/main.c +38 -38
193 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +2 -2
@@ -386,7 +386,7 @@ int mt7921_mcu_uni_tx_ba(struct mt792x_dev *dev,struct mt792x_sta *msta = (struct mt792x_sta *)params->sta->drv_priv;if (enable && !params->amsdu) - msta->wcid.amsdu = false; + msta->deflink.wcid.amsdu = false; return mt76_connac_mcu_sta_ba(&dev->mt76, &msta->vif->bss_conf.mt76, params, MCU_UNI_CMD(STA_REC_UPDATE),
@@ -1055,7 +1055,7 @@ int mt7921_mcu_sta_update(struct mt792x_dev *dev, struct ieee80211_sta *sta,struct mt792x_sta *msta; msta = sta ? (struct mt792x_sta *)sta->drv_priv :NULL ; - info.wcid = msta ? &msta->wcid : &mvif->sta.wcid; + info.wcid = msta ? &msta->deflink.wcid : &mvif->sta.deflink.wcid; info.newly = msta ? state !=MT76_STA_INFO_STATE_ASSOC : true;return mt76_connac_mcu_sta_cmd (&dev->mphy, &info);
drivers/net/wireless/mediatek/mt76/mt7921/pci_mac.c +2 -2
@@ -34,9 +34,9 @@ int mt7921e_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,if (sta) {struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv; -if (time_after (jiffies, msta->last_txs +HZ /4 )) { +if (time_after (jiffies, msta->deflink.last_txs +HZ /4 )) { info->flags |=IEEE80211_TX_CTL_REQ_TX_STATUS ; - msta->last_txs = jiffies; + msta->deflink.last_txs = jiffies; } }
drivers/net/wireless/mediatek/mt76/mt7925/mac.c +34 -32
174 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt7925/main.c +33 -33
165 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +9 -8
@@ -544,7 +544,7 @@ int mt7925_mcu_uni_tx_ba(struct mt792x_dev *dev,struct mt792x_vif *mvif = msta->vif;if (enable && !params->amsdu) - msta->wcid.amsdu = false; + msta->deflink.wcid.amsdu = false;return mt7925_mcu_sta_ba (&dev->mt76, &mvif->bss_conf.mt76, params, enable, true);
@@ -867,7 +867,7 @@ mt7925_mcu_sta_hdr_trans_tlv(struct sk_buff *skb,if (sta) wcid = (struct mt76_wcid *)sta->drv_priv;else - wcid = &mvif->sta.wcid; + wcid = &mvif->sta.deflink.wcid;if (!wcid)return ;
@@ -890,7 +890,7 @@ int mt7925_mcu_wtbl_update_hdr_trans(struct mt792x_dev *dev, msta = sta ? (struct mt792x_sta *)sta->drv_priv : &mvif->sta; skb =__mt76_connac_mcu_alloc_sta_req (&dev->mt76, &mvif->bss_conf.mt76, - &msta->wcid, + &msta->deflink.wcid,MT7925_STA_UPDATE_MAX_SIZE );if (IS_ERR (skb))return PTR_ERR (skb);
@@ -962,7 +962,8 @@ mt7925_mcu_sta_key_tlv(struct mt76_wcid *wcid, struct ieee80211_key_conf *key, enum set_key_cmd cmd) { - struct mt792x_sta *msta = container_of(wcid, struct mt792x_sta, wcid); + struct mt792x_link_sta *mlink = container_of(wcid, struct mt792x_link_sta, wcid); + struct mt792x_sta *msta = container_of(mlink, struct mt792x_sta, deflink);struct sta_rec_sec_uni *sec;struct mt792x_vif *mvif = msta->vif;struct ieee80211_sta *sta;
@@ -1480,7 +1481,7 @@ mt7925_mcu_sta_amsdu_tlv(struct sk_buff *skb, amsdu = (struct sta_rec_amsdu *)tlv; amsdu->max_amsdu_num =8 ; amsdu->amsdu_en = true; - msta->wcid.amsdu = true; + msta->deflink.wcid.amsdu = true;switch (sta->deflink.agg.max_amsdu_len) {case IEEE80211_MAX_MPDU_LEN_VHT_11454 :
@@ -1668,7 +1669,7 @@ int mt7925_mcu_sta_update(struct mt792x_dev *dev, struct ieee80211_sta *sta,struct mt792x_sta *msta; msta = sta ? (struct mt792x_sta *)sta->drv_priv :NULL ; - info.wcid = msta ? &msta->wcid : &mvif->sta.wcid; + info.wcid = msta ? &msta->deflink.wcid : &mvif->sta.deflink.wcid; info.newly = msta ? state !=MT76_STA_INFO_STATE_ASSOC : true;return mt7925_mcu_sta_cmd (&dev->mphy, &info);
@@ -2096,7 +2097,7 @@ mt7925_mcu_bss_basic_tlv(struct sk_buff *skb, basic_req->bcn_interval =cpu_to_le16 (vif->bss_conf.beacon_int); basic_req->dtim_period = vif->bss_conf.dtim_period; basic_req->bmc_tx_wlan_idx =cpu_to_le16 (wlan_idx); - basic_req->sta_idx =cpu_to_le16 (msta->wcid.idx); + basic_req->sta_idx =cpu_to_le16 (msta->deflink.wcid.idx); basic_req->omac_idx = mvif->bss_conf.mt76.omac_idx; basic_req->band_idx = mvif->bss_conf.mt76.band_idx; basic_req->wmm_idx = mvif->bss_conf.mt76.wmm_idx;
@@ -2330,7 +2331,7 @@ int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,/* bss_basic must be first */ mt7925_mcu_bss_basic_tlv (skb, vif, sta, ctx, phy->mt76, - mvif->sta.wcid.idx, enable); + mvif->sta.deflink.wcid.idx, enable);mt7925_mcu_bss_sec_tlv (skb, vif);mt7925_mcu_bss_bmc_tlv (skb, phy, ctx, vif, sta);
drivers/net/wireless/mediatek/mt76/mt7925/pci_mac.c +2 -2
@@ -34,9 +34,9 @@ int mt7925e_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,if (sta) {struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv; -if (time_after (jiffies, msta->last_txs +HZ /4 )) { +if (time_after (jiffies, msta->deflink.last_txs +HZ /4 )) { info->flags |=IEEE80211_TX_CTL_REQ_TX_STATUS ; - msta->last_txs = jiffies; + msta->deflink.last_txs = jiffies; } }
drivers/net/wireless/mediatek/mt76/mt792x.h +7 -3
@@ -79,11 +79,9 @@ enum mt792x_reg_power_type { DECLARE_EWMA(avg_signal, 10, 8) -struct mt792x_sta { +struct mt792x_link_sta {struct mt76_wcid wcid;/* must be first */ -struct mt792x_vif *vif; -u32 airtime_ac[8 ];int ack_signal;
@@ -94,6 +92,12 @@ struct mt792x_sta {struct mt76_connac_sta_key_conf bip; }; +struct mt792x_sta { +struct mt792x_link_sta deflink;/* must be first */ + +struct mt792x_vif *vif; +}; +DECLARE_EWMA (rssi,10 ,8 );struct mt792x_bss_conf {
drivers/net/wireless/mediatek/mt76/mt792x_core.c +14 -14
@@ -65,14 +65,14 @@ void mt792x_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control,struct mt792x_sta *sta; sta = (struct mt792x_sta *)control->sta->drv_priv; - wcid = &sta->wcid; + wcid = &sta->deflink.wcid; }if (vif && !control->sta) {struct mt792x_vif *mvif; mvif = (struct mt792x_vif *)vif->drv_priv; - wcid = &mvif->sta.wcid; + wcid = &mvif->sta.deflink.wcid; }if (mt76_connac_pm_ref (mphy, &dev->pm)) {
@@ -120,11 +120,11 @@ void mt792x_remove_interface(struct ieee80211_hw *hw,struct mt792x_sta *msta = &mvif->sta;struct mt792x_dev *dev =mt792x_hw_dev (hw);struct mt792x_phy *phy =mt792x_hw_phy (hw); -int idx = msta->wcid.idx; +int idx = msta->deflink.wcid.idx;mt792x_mutex_acquire (dev); -mt76_connac_free_pending_tx_skbs (&dev->pm, &msta->wcid); -mt76_connac_mcu_uni_add_dev (&dev->mphy, vif, &mvif->sta.wcid, false); +mt76_connac_free_pending_tx_skbs (&dev->pm, &msta->deflink.wcid); +mt76_connac_mcu_uni_add_dev (&dev->mphy, vif, &mvif->sta.deflink.wcid, false);rcu_assign_pointer (dev->mt76.wcid[idx],NULL );
@@ -133,11 +133,11 @@ void mt792x_remove_interface(struct ieee80211_hw *hw,mt792x_mutex_release (dev);spin_lock_bh (&dev->mt76.sta_poll_lock); -if (!list_empty (&msta->wcid.poll_list)) -list_del_init (&msta->wcid.poll_list); +if (!list_empty (&msta->deflink.wcid.poll_list)) +list_del_init (&msta->deflink.wcid.poll_list);spin_unlock_bh (&dev->mt76.sta_poll_lock); -mt76_wcid_cleanup (&dev->mt76, &msta->wcid); +mt76_wcid_cleanup (&dev->mt76, &msta->deflink.wcid); }EXPORT_SYMBOL_GPL (mt792x_remove_interface);
@@ -408,7 +408,7 @@ mt792x_ethtool_worker(void *wi_data, struct ieee80211_sta *sta)if (msta->vif->bss_conf.mt76.idx != wi->idx)return ; -mt76_ethtool_worker (wi, &msta->wcid.stats, true); +mt76_ethtool_worker (wi, &msta->deflink.wcid.stats, true); } void mt792x_get_et_stats(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
@@ -487,7 +487,7 @@ void mt792x_sta_statistics(struct ieee80211_hw *hw, struct station_info *sinfo) {struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv; -struct rate_info *txrate = &msta->wcid.rate; +struct rate_info *txrate = &msta->deflink.wcid.rate;if (!txrate->legacy && !txrate->flags)return ;
@@ -502,19 +502,19 @@ void mt792x_sta_statistics(struct ieee80211_hw *hw, sinfo->txrate.he_dcm = txrate->he_dcm; sinfo->txrate.he_ru_alloc = txrate->he_ru_alloc; } - sinfo->tx_failed = msta->wcid.stats.tx_failed; + sinfo->tx_failed = msta->deflink.wcid.stats.tx_failed; sinfo->filled |=BIT_ULL (NL80211_STA_INFO_TX_FAILED ); - sinfo->tx_retries = msta->wcid.stats.tx_retries; + sinfo->tx_retries = msta->deflink.wcid.stats.tx_retries; sinfo->filled |=BIT_ULL (NL80211_STA_INFO_TX_RETRIES ); sinfo->txrate.flags = txrate->flags; sinfo->filled |=BIT_ULL (NL80211_STA_INFO_TX_BITRATE ); - sinfo->ack_signal = (s8 )msta->ack_signal; + sinfo->ack_signal = (s8 )msta->deflink.ack_signal; sinfo->filled |=BIT_ULL (NL80211_STA_INFO_ACK_SIGNAL ); - sinfo->avg_ack_signal = -(s8 )ewma_avg_signal_read (&msta->avg_ack_signal); + sinfo->avg_ack_signal = -(s8 )ewma_avg_signal_read (&msta->deflink.avg_ack_signal); sinfo->filled |=BIT_ULL (NL80211_STA_INFO_ACK_SIGNAL_AVG ); }EXPORT_SYMBOL_GPL (mt792x_sta_statistics);
drivers/net/wireless/mediatek/mt76/mt792x_mac.c +4 -2
@@ -138,6 +138,7 @@ EXPORT_SYMBOL_GPL(mt792x_mac_update_mib_stats);struct mt76_wcid *mt792x_rx_get_wcid (struct mt792x_dev *dev,u16 idx,bool unicast) { +struct mt792x_link_sta *link;struct mt792x_sta *sta;struct mt76_wcid *wcid;
@@ -151,11 +152,12 @@ struct mt76_wcid *mt792x_rx_get_wcid(struct mt792x_dev *dev, u16 idx,if (!wcid->sta)return NULL ; - sta = container_of(wcid, struct mt792x_sta, wcid); + link = container_of(wcid, struct mt792x_link_sta, wcid); + sta = container_of(link, struct mt792x_sta, deflink);if (!sta->vif)return NULL ; -return &sta->vif->sta.wcid; +return &sta->vif->sta.deflink.wcid; }EXPORT_SYMBOL_GPL (mt792x_rx_get_wcid);
Signature · 1 line
2.34.1
PATCH 3/47 wifi: mt76: mt792x: add struct mt792x_chanctx
In reply to [email protected]From: Deren Wu <[email protected]>
We are introducing a new structure, mt792x_chanctx, to quickly identify the linked BSS it is working on. This eliminates the need to search in mt7921_ctx_iter() or mt7925_ctx_iter() when the channel context changes.
--- .../net/wireless/mediatek/mt76/mt7921/main.c | 31 ++++++++----------- .../net/wireless/mediatek/mt76/mt7925/main.c | 31 ++++++++----------- drivers/net/wireless/mediatek/mt76/mt792x.h | 4 +++ .../net/wireless/mediatek/mt76/mt792x_core.c | 5 +++ 4 files changed, 35 insertions(+), 36 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7921/main.c +13 -18
@@ -1346,32 +1346,27 @@ mt7921_remove_chanctx(struct ieee80211_hw *hw, { } -static void mt7921_ctx_iter (void *priv,u8 *mac, -struct ieee80211_vif *vif) -{ -struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; -struct ieee80211_chanctx_conf *ctx = priv; - -if (ctx != mvif->bss_conf.mt76.ctx) -return ; - -if (vif->type ==NL80211_IFTYPE_MONITOR ) -mt7921_mcu_config_sniffer (mvif, ctx); -else -mt76_connac_mcu_uni_set_chctx (mvif->phy->mt76, &mvif->bss_conf.mt76, ctx); -} -static void mt7921_change_chanctx (struct ieee80211_hw *hw,struct ieee80211_chanctx_conf *ctx,u32 changed) { +struct mt792x_chanctx *mctx = (struct mt792x_chanctx *)ctx->drv_priv;struct mt792x_phy *phy =mt792x_hw_phy (hw); +struct ieee80211_vif *vif; +struct mt792x_vif *mvif; + +if (!mctx->bss_conf) +return ; + + mvif = container_of(mctx->bss_conf, struct mt792x_vif, bss_conf); + vif = container_of((void *)mvif, struct ieee80211_vif, drv_priv);mt792x_mutex_acquire (phy->dev); -ieee80211_iterate_active_interfaces (phy->mt76->hw, -IEEE80211_IFACE_ITER_ACTIVE , - mt7921_ctx_iter, ctx); +if (vif->type ==NL80211_IFTYPE_MONITOR ) +mt7921_mcu_config_sniffer (mvif, ctx); +else +mt76_connac_mcu_uni_set_chctx (mvif->phy->mt76, &mvif->bss_conf.mt76, ctx);mt792x_mutex_release (phy->dev); }
drivers/net/wireless/mediatek/mt76/mt7925/main.c +13 -18
@@ -1354,34 +1354,29 @@ mt7925_remove_chanctx(struct ieee80211_hw *hw, { } -static void mt7925_ctx_iter (void *priv,u8 *mac, -struct ieee80211_vif *vif) +static void +mt7925_change_chanctx (struct ieee80211_hw *hw, +struct ieee80211_chanctx_conf *ctx, +u32 changed) { -struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; -struct ieee80211_chanctx_conf *ctx = priv; +struct mt792x_chanctx *mctx = (struct mt792x_chanctx *)ctx->drv_priv; +struct mt792x_phy *phy =mt792x_hw_phy (hw); +struct ieee80211_vif *vif; +struct mt792x_vif *mvif; -if (ctx != mvif->bss_conf.mt76.ctx) +if (!mctx->bss_conf)return ; + mvif = container_of(mctx->bss_conf, struct mt792x_vif, bss_conf); + vif = container_of((void *)mvif, struct ieee80211_vif, drv_priv); + +mt792x_mutex_acquire (phy->dev);if (vif->type ==NL80211_IFTYPE_MONITOR ) {mt7925_mcu_set_sniffer (mvif->phy->dev, vif, true);mt7925_mcu_config_sniffer (mvif, ctx); }else {mt7925_mcu_set_chctx (mvif->phy->mt76, &mvif->bss_conf.mt76, ctx); } -} - -static void -mt7925_change_chanctx (struct ieee80211_hw *hw, -struct ieee80211_chanctx_conf *ctx, -u32 changed) -{ -struct mt792x_phy *phy =mt792x_hw_phy (hw); - -mt792x_mutex_acquire (phy->dev); -ieee80211_iterate_active_interfaces (phy->mt76->hw, -IEEE80211_IFACE_ITER_ACTIVE , - mt7925_ctx_iter, ctx);mt792x_mutex_release (phy->dev); }
drivers/net/wireless/mediatek/mt76/mt792x.h +4 -0
@@ -100,6 +100,10 @@ struct mt792x_sta {DECLARE_EWMA (rssi,10 ,8 ); +struct mt792x_chanctx { +struct mt792x_bss_conf *bss_conf; +}; +struct mt792x_bss_conf {struct mt76_vif mt76;/* must be first */ struct ewma_rssi rssi;
drivers/net/wireless/mediatek/mt76/mt792x_core.c +5 -0
@@ -261,11 +261,13 @@ int mt792x_assign_vif_chanctx(struct ieee80211_hw *hw,struct ieee80211_bss_conf *link_conf, struct ieee80211_chanctx_conf *ctx) { + 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);mutex_lock (&dev->mt76.mutex); mvif->bss_conf.mt76.ctx = ctx; + mctx->bss_conf = &mvif->bss_conf;mutex_unlock (&dev->mt76.mutex);return 0 ;
@@ -277,10 +279,12 @@ void mt792x_unassign_vif_chanctx(struct ieee80211_hw *hw,struct ieee80211_bss_conf *link_conf, struct ieee80211_chanctx_conf *ctx) { + 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);mutex_lock (&dev->mt76.mutex); + mctx->bss_conf =NULL ; mvif->bss_conf.mt76.ctx =NULL ;mutex_unlock (&dev->mt76.mutex); }
@@ -556,6 +560,7 @@ int mt792x_init_wiphy(struct ieee80211_hw *hw) hw->sta_data_size =sizeof (struct mt792x_sta ); hw->vif_data_size =sizeof (struct mt792x_vif ); + hw->chanctx_data_size =sizeof (struct mt792x_chanctx );if (dev->fw_features & MT792x_FW_CAP_CNM) { wiphy->flags |=WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL ;
Signature · 1 line
2.34.1
PATCH 4/47 wifi: mt76: mt7925: support for split bss_info_changed method
In reply to [email protected]From: Deren Wu <[email protected]>
The .bss_info_changed method is being split into .vif_cfg_changed and .link_info_changed to support MLD devices, but it will still support non-MLD devices.
--- .../net/wireless/mediatek/mt76/mt7925/main.c | 132 ++++++++++-------- .../net/wireless/mediatek/mt76/mt7925/mcu.c | 7 +- .../net/wireless/mediatek/mt76/mt7925/mcu.h | 3 +- 3 files changed, 76 insertions(+), 66 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/main.c +72 -60
@@ -695,65 +695,6 @@ mt7925_get_rates_table(struct ieee80211_hw *hw, struct ieee80211_vif *vif,return mvif->basic_rates_idx; } -static void mt7925_bss_info_changed (struct ieee80211_hw *hw, -struct ieee80211_vif *vif, -struct ieee80211_bss_conf *info, -u64 changed) -{ -struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv; -struct mt792x_phy *phy =mt792x_hw_phy (hw); -struct mt792x_dev *dev =mt792x_hw_dev (hw); - -mt792x_mutex_acquire (dev); - -if (changed &BSS_CHANGED_ERP_SLOT ) { -int slottime = info->use_short_slot ?9 :20 ; - -if (slottime != phy->slottime) { - phy->slottime = slottime; -mt7925_mcu_set_timing (phy, vif); - } - } - -if (changed &BSS_CHANGED_MCAST_RATE ) - mvif->mcast_rates_idx = -mt7925_get_rates_table (hw, vif, false, true); - -if (changed &BSS_CHANGED_BASIC_RATES ) - mvif->basic_rates_idx = -mt7925_get_rates_table (hw, vif, false, false); - -if (changed & (BSS_CHANGED_BEACON | -BSS_CHANGED_BEACON_ENABLED )) { - mvif->beacon_rates_idx = -mt7925_get_rates_table (hw, vif, true, false); - -mt7925_mcu_uni_add_beacon_offload (dev, hw, vif, - info->enable_beacon); - } - -/* ensure that enable txcmd_mode after bss_info */ -if (changed & (BSS_CHANGED_QOS |BSS_CHANGED_BEACON_ENABLED )) -mt7925_mcu_set_tx (dev, vif); - -if (changed &BSS_CHANGED_PS ) -mt7925_mcu_uni_bss_ps (dev, vif); - -if (changed &BSS_CHANGED_ASSOC ) { -mt7925_mcu_sta_update (dev,NULL , vif, true, -MT76_STA_INFO_STATE_ASSOC ); -mt7925_mcu_set_beacon_filter (dev, vif, vif->cfg.assoc); - } - -if (changed &BSS_CHANGED_ARP_FILTER ) { -struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; - -mt7925_mcu_update_arp_filter (&dev->mt76, &mvif->bss_conf.mt76, info); - } - -mt792x_mutex_release (dev); -} -int mt7925_mac_sta_add (struct mt76_dev *mdev,struct ieee80211_vif *vif,struct ieee80211_sta *sta) {
@@ -1404,6 +1345,76 @@ static void mt7925_mgd_complete_tx(struct ieee80211_hw *hw,mt7925_abort_roc (mvif->phy, mvif); } +static void mt7925_vif_cfg_changed (struct ieee80211_hw *hw, +struct ieee80211_vif *vif, +u64 changed) +{ +struct mt792x_dev *dev =mt792x_hw_dev (hw); + +mt792x_mutex_acquire (dev); + +if (changed &BSS_CHANGED_ASSOC ) { +mt7925_mcu_sta_update (dev,NULL , vif, true, +MT76_STA_INFO_STATE_ASSOC ); +mt7925_mcu_set_beacon_filter (dev, vif, vif->cfg.assoc); + } + +if (changed &BSS_CHANGED_ARP_FILTER ) { +struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; + +mt7925_mcu_update_arp_filter (&dev->mt76, &mvif->bss_conf.mt76); + } + +if (changed &BSS_CHANGED_PS ) +mt7925_mcu_uni_bss_ps (dev, vif); + +mt792x_mutex_release (dev); +} + +static void mt7925_link_info_changed (struct ieee80211_hw *hw, +struct ieee80211_vif *vif, +struct ieee80211_bss_conf *info, +u64 changed) +{ +struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv; +struct mt792x_phy *phy =mt792x_hw_phy (hw); +struct mt792x_dev *dev =mt792x_hw_dev (hw); + +mt792x_mutex_acquire (dev); + +if (changed &BSS_CHANGED_ERP_SLOT ) { +int slottime = info->use_short_slot ?9 :20 ; + +if (slottime != phy->slottime) { + phy->slottime = slottime; +mt7925_mcu_set_timing (phy, vif); + } + } + +if (changed &BSS_CHANGED_MCAST_RATE ) + mvif->mcast_rates_idx = +mt7925_get_rates_table (hw, vif, false, true); + +if (changed &BSS_CHANGED_BASIC_RATES ) + mvif->basic_rates_idx = +mt7925_get_rates_table (hw, vif, false, false); + +if (changed & (BSS_CHANGED_BEACON | +BSS_CHANGED_BEACON_ENABLED )) { + mvif->beacon_rates_idx = +mt7925_get_rates_table (hw, vif, true, false); + +mt7925_mcu_uni_add_beacon_offload (dev, hw, vif, + info->enable_beacon); + } + +/* ensure that enable txcmd_mode after bss_info */ +if (changed & (BSS_CHANGED_QOS |BSS_CHANGED_BEACON_ENABLED )) +mt7925_mcu_set_tx (dev, vif); + +mt792x_mutex_release (dev); +} +const struct ieee80211_ops mt7925_ops = { .tx = mt792x_tx, .start = mt7925_start,
@@ -1413,7 +1424,6 @@ const struct ieee80211_ops mt7925_ops = { .config = mt7925_config, .conf_tx = mt7925_conf_tx, .configure_filter = mt7925_configure_filter, - .bss_info_changed = mt7925_bss_info_changed, .start_ap = mt7925_start_ap, .stop_ap = mt7925_stop_ap, .sta_state = mt76_sta_state,
@@ -1461,6 +1471,8 @@ const struct ieee80211_ops mt7925_ops = { .unassign_vif_chanctx = mt792x_unassign_vif_chanctx, .mgd_prepare_tx = mt7925_mgd_prepare_tx, .mgd_complete_tx = mt7925_mgd_complete_tx, + .vif_cfg_changed = mt7925_vif_cfg_changed, + .link_info_changed = mt7925_link_info_changed, };EXPORT_SYMBOL_GPL (mt7925_ops);
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +3 -4
@@ -121,11 +121,10 @@ int mt7925_mcu_regval(struct mt792x_dev *dev, u32 regidx, u32 *val, bool set)EXPORT_SYMBOL_GPL (mt7925_mcu_regval);int mt7925_mcu_update_arp_filter (struct mt76_dev *dev, -struct mt76_vif *vif, -struct ieee80211_bss_conf *info) +struct mt76_vif *vif) { - struct ieee80211_vif *mvif = container_of(info, struct ieee80211_vif, - bss_conf); + struct ieee80211_vif *mvif = container_of((void *)vif, struct ieee80211_vif, + drv_priv);struct sk_buff *skb;int i, len =min_t (int, mvif->cfg.arp_addr_cnt,IEEE80211_BSS_ARP_ADDR_LIST_LEN );
drivers/net/wireless/mediatek/mt76/mt7925/mcu.h +1 -2
@@ -590,6 +590,5 @@ int mt7925_mcu_set_chctx(struct mt76_phy *phy, struct mt76_vif *mvif, struct ieee80211_chanctx_conf *ctx);int mt7925_mcu_set_rate_txpower (struct mt76_phy *phy);int mt7925_mcu_update_arp_filter (struct mt76_dev *dev, -struct mt76_vif *vif, -struct ieee80211_bss_conf *info); +struct mt76_vif *vif);#endif
Signature · 1 line
2.34.1
PATCH 5/47 wifi: mt76: mt792x: extend mt76_connac_mcu_uni_add_dev for per-link BSS
In reply to [email protected]From: Sean Wang <[email protected]>
Extend mt76_connac_mcu_uni_add_dev with per-link BSS configuration.
The patch we created is a prerequisite to enable the MLO function in the driver. It is purely a refactoring patch so the functionality should remain unchanged.
We also extend link_idx field in mt76_connac_bss_basic_tlv for the firmware to able to identify the link index in the MLO mode that is not harmful for the current non-MLO mode.
--- drivers/net/wireless/mediatek/mt76/mt7615/mcu.c | 4 ++-- drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c | 12 +++++++----- drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h | 4 ++-- drivers/net/wireless/mediatek/mt76/mt7921/mac.c | 3 ++- drivers/net/wireless/mediatek/mt76/mt7921/main.c | 4 ++-- drivers/net/wireless/mediatek/mt76/mt7925/mac.c | 3 ++- drivers/net/wireless/mediatek/mt76/mt7925/main.c | 4 ++-- drivers/net/wireless/mediatek/mt76/mt792x_core.c | 2 +- 8 files changed, 20 insertions(+), 16 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c +2 -2
@@ -1109,8 +1109,8 @@ mt7615_mcu_uni_add_dev(struct mt7615_phy *phy, struct ieee80211_vif *vif, {struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv; -return mt76_connac_mcu_uni_add_dev (phy->mt76, vif, &mvif->sta.wcid, - enable); +return mt76_connac_mcu_uni_add_dev (phy->mt76, &vif->bss_conf, + &mvif->sta.wcid, enable); } static int
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +7 -5
@@ -1125,11 +1125,11 @@ void mt76_connac_mcu_wtbl_ba_tlv(struct mt76_dev *dev, struct sk_buff *skb,EXPORT_SYMBOL_GPL (mt76_connac_mcu_wtbl_ba_tlv);int mt76_connac_mcu_uni_add_dev (struct mt76_phy *phy, -struct ieee80211_vif *vif, +struct ieee80211_bss_conf *bss_conf,struct mt76_wcid *wcid,bool enable) { -struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv; +struct mt76_vif *mvif = (struct mt76_vif *)bss_conf->vif->drv_priv;struct mt76_dev *dev = phy->dev; struct { struct {
@@ -1141,7 +1141,7 @@ int mt76_connac_mcu_uni_add_dev(struct mt76_phy *phy,__le16 tag;__le16 len;u8 active; -u8 pad; +u8 link_idx;/* not link_id */ u8 omac_addr[ETH_ALEN ]; }__packed tlv; } dev_req = {
@@ -1153,6 +1153,7 @@ int mt76_connac_mcu_uni_add_dev(struct mt76_phy *phy, .tag = cpu_to_le16(DEV_INFO_ACTIVE), .len = cpu_to_le16(sizeof(struct req_tlv)), .active = enable, + .link_idx = mvif->idx, }, }; struct {
@@ -1175,12 +1176,13 @@ int mt76_connac_mcu_uni_add_dev(struct mt76_phy *phy, .bmc_tx_wlan_idx = cpu_to_le16(wcid->idx), .sta_idx = cpu_to_le16(wcid->idx), .conn_state = 1, + .link_idx = mvif->idx, }, };int err, idx, cmd, len;void *data; -switch (vif->type) { +switch (bss_conf->vif->type) {case NL80211_IFTYPE_MESH_POINT :case NL80211_IFTYPE_MONITOR :case NL80211_IFTYPE_AP :
@@ -1200,7 +1202,7 @@ int mt76_connac_mcu_uni_add_dev(struct mt76_phy *phy, idx = mvif->omac_idx >EXT_BSSID_START ?HW_BSSID_0 : mvif->omac_idx; basic_req.basic.hw_bss_idx = idx; -memcpy (dev_req.tlv.omac_addr, vif->addr,ETH_ALEN ); +memcpy (dev_req.tlv.omac_addr, bss_conf->vif->addr,ETH_ALEN ); cmd = enable ?MCU_UNI_CMD (DEV_INFO_UPDATE ) :MCU_UNI_CMD (BSS_INFO_UPDATE ); data = enable ? (void *)&dev_req : (void *)&basic_req;
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +2 -2
@@ -1436,7 +1436,7 @@ struct mt76_connac_bss_basic_tlv {__le16 sta_idx;__le16 nonht_basic_phy;u8 phymode_ext;/* bit(0) AX_6G */ -u8 pad[1 ]; +u8 link_idx; } __packed;struct mt76_connac_bss_qos_tlv {
@@ -1910,7 +1910,7 @@ void mt76_connac_mcu_sta_ba_tlv(struct sk_buff *skb,struct ieee80211_ampdu_params *params, bool enable, bool tx);int mt76_connac_mcu_uni_add_dev (struct mt76_phy *phy, -struct ieee80211_vif *vif, +struct ieee80211_bss_conf *bss_conf,struct mt76_wcid *wcid,bool enable); int mt76_connac_mcu_sta_ba(struct mt76_dev *dev, struct mt76_vif *mvif,
drivers/net/wireless/mediatek/mt76/mt7921/mac.c +2 -1
@@ -646,7 +646,8 @@ 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, &mvif->sta.deflink.wcid, true); +mt76_connac_mcu_uni_add_dev (&dev->mphy, &vif->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 -2
@@ -306,8 +306,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, &mvif->sta.deflink.wcid, - true); + ret =mt76_connac_mcu_uni_add_dev (&dev->mphy, &vif->bss_conf, + &mvif->sta.deflink.wcid, true);if (ret) goto out;
drivers/net/wireless/mediatek/mt76/mt7925/mac.c +2 -1
@@ -1243,7 +1243,8 @@ mt7925_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, &mvif->sta.deflink.wcid, true); +mt76_connac_mcu_uni_add_dev (&dev->mphy, &vif->bss_conf, + &mvif->sta.deflink.wcid, true);mt7925_mcu_set_tx (dev, vif);if (vif->type ==NL80211_IFTYPE_AP ) {
drivers/net/wireless/mediatek/mt76/mt7925/main.c +2 -2
@@ -344,8 +344,8 @@ mt7925_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)else mvif->bss_conf.mt76.basic_rates_idx = MT792x_BASIC_RATES_TBL; - ret =mt76_connac_mcu_uni_add_dev (&dev->mphy, vif, &mvif->sta.deflink.wcid, - true); + ret =mt76_connac_mcu_uni_add_dev (&dev->mphy, &vif->bss_conf, + &mvif->sta.deflink.wcid, true);if (ret) goto out;
drivers/net/wireless/mediatek/mt76/mt792x_core.c +1 -1
@@ -124,7 +124,7 @@ void mt792x_remove_interface(struct ieee80211_hw *hw,mt792x_mutex_acquire (dev);mt76_connac_free_pending_tx_skbs (&dev->pm, &msta->deflink.wcid); -mt76_connac_mcu_uni_add_dev (&dev->mphy, vif, &mvif->sta.deflink.wcid, false); +mt76_connac_mcu_uni_add_dev (&dev->mphy, &vif->bss_conf, &mvif->sta.deflink.wcid, false);rcu_assign_pointer (dev->mt76.wcid[idx],NULL );
Signature · 1 line
2.34.1
PATCH 6/47 wifi: mt76: mt7925: extend mt7925_mcu_set_tx with for per-link BSS
In reply to [email protected]From: Deren Wu <[email protected]>
Extend mt7925_mcu_set_tx with per-link BSS configuration.
The patch we created is a prerequisite to enable the MLO function in the driver. It is purely a refactoring patch so the functionality should remain unchanged.
--- .../net/wireless/mediatek/mt76/mt7925/mac.c | 2 +- .../net/wireless/mediatek/mt76/mt7925/main.c | 2 +- .../net/wireless/mediatek/mt76/mt7925/mcu.c | 9 ++++--- .../wireless/mediatek/mt76/mt7925/mt7925.h | 2 +- drivers/net/wireless/mediatek/mt76/mt792x.h | 25 +++++++++++++++++++ 5 files changed, 33 insertions(+), 7 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/mac.c +1 -1
@@ -1245,7 +1245,7 @@ mt7925_vif_connect_iter(void *priv, u8 *mac,mt76_connac_mcu_uni_add_dev (&dev->mphy, &vif->bss_conf, &mvif->sta.deflink.wcid, true); -mt7925_mcu_set_tx (dev, vif); +mt7925_mcu_set_tx (dev, &vif->bss_conf);if (vif->type ==NL80211_IFTYPE_AP ) { mt76_connac_mcu_uni_add_bss(dev->phy.mt76, vif, &mvif->sta.deflink.wcid,
drivers/net/wireless/mediatek/mt76/mt7925/main.c +1 -1
@@ -1410,7 +1410,7 @@ static void mt7925_link_info_changed(struct ieee80211_hw *hw,/* ensure that enable txcmd_mode after bss_info */ if (changed & (BSS_CHANGED_QOS |BSS_CHANGED_BEACON_ENABLED )) -mt7925_mcu_set_tx (dev, vif); +mt7925_mcu_set_tx (dev, info);mt792x_mutex_release (dev); }
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +5 -4
@@ -900,7 +900,8 @@ int mt7925_mcu_wtbl_update_hdr_trans(struct mt792x_dev *dev, MCU_WMWA_UNI_CMD(STA_REC_UPDATE), true); } -int mt7925_mcu_set_tx (struct mt792x_dev *dev,struct ieee80211_vif *vif) +int mt7925_mcu_set_tx (struct mt792x_dev *dev, +struct ieee80211_bss_conf *bss_conf) {#define MCU_EDCA_AC_PARAM 0#define WMM_AIFS_SET BIT(0)
@@ -909,12 +910,12 @@ int mt7925_mcu_set_tx(struct mt792x_dev *dev, struct ieee80211_vif *vif)#define WMM_TXOP_SET BIT(3)#define WMM_PARAM_SET (WMM_AIFS_SET | WMM_CW_MIN_SET | \ WMM_CW_MAX_SET | WMM_TXOP_SET) -struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; +struct mt792x_bss_conf *mconf =mt792x_link_conf_to_mconf (bss_conf);struct {u8 bss_idx;u8 __rsv[3 ]; } __packed hdr = { - .bss_idx = mvif->bss_conf.mt76.idx, + .bss_idx = mconf->mt76.idx, };struct sk_buff *skb;int len =sizeof (hdr) +IEEE80211_NUM_ACS *sizeof (struct edca );
@@ -927,7 +928,7 @@ int mt7925_mcu_set_tx(struct mt792x_dev *dev, struct ieee80211_vif *vif)skb_put_data (skb, &hdr,sizeof (hdr));for (ac =0 ; ac <IEEE80211_NUM_ACS ; ac++) { -struct ieee80211_tx_queue_params *q = &mvif->bss_conf.queue_params[ac]; +struct ieee80211_tx_queue_params *q = &mconf->queue_params[ac];struct edca *e;struct tlv *tlv;
drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h +1 -1
@@ -198,7 +198,7 @@ int mt7925_mcu_sta_update(struct mt792x_dev *dev, struct ieee80211_sta *sta, struct ieee80211_vif *vif, bool enable, 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_vif *vif); +int mt7925_mcu_set_tx (struct mt792x_dev *dev,struct ieee80211_bss_conf *bss_conf);int mt7925_mcu_set_eeprom (struct mt792x_dev *dev);int mt7925_mcu_get_rx_rate (struct mt792x_phy *phy,struct ieee80211_vif *vif,struct ieee80211_sta *sta,struct rate_info *rate);
drivers/net/wireless/mediatek/mt76/mt792x.h +25 -0
@@ -112,6 +112,7 @@ struct mt792x_bss_conf {struct mt792x_vif {struct mt792x_bss_conf bss_conf;/* must be first */ +struct mt792x_bss_conf __rcu *link_conf[IEEE80211_MLD_MAX_NUM_LINKS ];struct mt792x_sta sta;struct mt792x_sta *wep_sta;
@@ -219,6 +220,30 @@ struct mt792x_dev {u32 backup_l2; }; +static inline struct mt792x_bss_conf * +mt792x_vif_to_link (struct mt792x_vif *mvif,u8 link_id) +{ +struct ieee80211_vif *vif; + + vif = container_of((void *)mvif, struct ieee80211_vif, drv_priv); + +if (!ieee80211_vif_is_mld (vif) || + link_id >=IEEE80211_LINK_UNSPECIFIED ) +return &mvif->bss_conf; + +return rcu_dereference_protected (mvif->link_conf[link_id], +lockdep_is_held (&mvif->phy->dev->mt76.mutex)); +} + +static inline struct mt792x_bss_conf * +mt792x_link_conf_to_mconf (struct ieee80211_bss_conf *link_conf) +{ +struct ieee80211_vif *vif = link_conf->vif; +struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; + +return mt792x_vif_to_link (mvif, link_conf->link_id); +} +static inline struct mt792x_dev *mt792x_hw_dev (struct ieee80211_hw *hw) {
Signature · 1 line
2.34.1
PATCH 7/47 wifi: mt76: mt7925: extend mt7925_mcu_add_bss_info for per-link BSS
In reply to [email protected]From: Sean Wang <[email protected]>
Extend mt7925_mcu_add_bss_info with per-link BSS configuration.
The patch we created is a prerequisite to enable the MLO function in the driver. It is purely a refactoring patch so the functionality should remain unchanged.
--- .../net/wireless/mediatek/mt76/mt7925/main.c | 35 +++++++++++++------ .../net/wireless/mediatek/mt76/mt7925/mcu.c | 22 ++++++------ .../net/wireless/mediatek/mt76/mt7925/mcu.h | 2 +- drivers/net/wireless/mediatek/mt76/mt792x.h | 10 ++++++ 4 files changed, 46 insertions(+), 23 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/main.c +24 -11
@@ -487,9 +487,12 @@ static int mt7925_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,struct mt792x_sta *msta = sta ? (struct mt792x_sta *)sta->drv_priv : &mvif->sta;struct mt76_wcid *wcid = &msta->deflink.wcid; +struct ieee80211_bss_conf *link_conf;u8 *wcid_keyidx = &wcid->hw_key_idx;int idx = key->keyidx, err =0 ; + link_conf =mt792x_vif_to_bss_conf (vif, vif->bss_conf.link_id); +/* The hardware does not support per-STA RX GTK, fallback * to software mode for these. */
@@ -528,7 +531,8 @@ static int mt7925_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,struct mt792x_phy *phy =mt792x_hw_phy (hw); mvif->bss_conf.mt76.cipher =mt7925_mcu_get_cipher (key->cipher); -mt7925_mcu_add_bss_info (phy, mvif->bss_conf.mt76.ctx, vif, sta, true); +mt7925_mcu_add_bss_info (phy, mvif->bss_conf.mt76.ctx, link_conf, + sta, true); }if (cmd ==SET_KEY )
@@ -701,6 +705,7 @@ int mt7925_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif, struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76);struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv;struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; +struct ieee80211_bss_conf *link_conf;int ret, idx; idx =mt76_wcid_alloc (dev->mt76.wcid_mask, MT792x_WTBL_STA -1 );
@@ -725,10 +730,12 @@ int mt7925_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,mt7925_mac_wtbl_update (dev, idx,MT_WTBL_UPDATE_ADM_COUNT_CLEAR ); + link_conf =mt792x_vif_to_bss_conf (vif, vif->bss_conf.link_id); +/* should update bss info before STA add */ if (vif->type ==NL80211_IFTYPE_STATION && !sta->tdls) -mt7925_mcu_add_bss_info (&dev->phy, mvif->bss_conf.mt76.ctx, vif, sta, - false); +mt7925_mcu_add_bss_info (&dev->phy, mvif->bss_conf.mt76.ctx, + link_conf, sta, false); ret =mt7925_mcu_sta_update (dev, sta, vif, true,MT76_STA_INFO_STATE_NONE );
@@ -747,12 +754,15 @@ void mt7925_mac_sta_assoc(struct mt76_dev *mdev, struct ieee80211_vif *vif, struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76);struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv;struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; +struct ieee80211_bss_conf *link_conf;mt792x_mutex_acquire (dev); + link_conf =mt792x_vif_to_bss_conf (vif, vif->bss_conf.link_id); +if (vif->type ==NL80211_IFTYPE_STATION && !sta->tdls) -mt7925_mcu_add_bss_info (&dev->phy, mvif->bss_conf.mt76.ctx, vif, sta, - true); +mt7925_mcu_add_bss_info (&dev->phy, mvif->bss_conf.mt76.ctx, + link_conf, sta, true);ewma_avg_signal_init (&msta->deflink.avg_ack_signal);
@@ -771,6 +781,7 @@ void mt7925_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif, { struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76);struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv; +struct ieee80211_bss_conf *link_conf;mt76_connac_free_pending_tx_skbs (&dev->pm, &msta->deflink.wcid);mt76_connac_pm_wake (&dev->mphy, &dev->pm);
@@ -779,14 +790,16 @@ void mt7925_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,mt7925_mac_wtbl_update (dev, msta->deflink.wcid.idx,MT_WTBL_UPDATE_ADM_COUNT_CLEAR ); + link_conf =mt792x_vif_to_bss_conf (vif, vif->bss_conf.link_id); +if (vif->type ==NL80211_IFTYPE_STATION ) {struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; mvif->wep_sta =NULL ;ewma_rssi_init (&mvif->bss_conf.rssi);if (!sta->tdls) -mt7925_mcu_add_bss_info (&dev->phy, mvif->bss_conf.mt76.ctx, vif, sta, - false); +mt7925_mcu_add_bss_info (&dev->phy, mvif->bss_conf.mt76.ctx, + link_conf, sta, false); }spin_lock_bh (&mdev->sta_poll_lock);
@@ -1244,8 +1257,8 @@ mt7925_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif,mt792x_mutex_acquire (dev); - err =mt7925_mcu_add_bss_info (&dev->phy, mvif->bss_conf.mt76.ctx, vif,NULL , - true); + err =mt7925_mcu_add_bss_info (&dev->phy, mvif->bss_conf.mt76.ctx, + link_conf,NULL , true);if (err) goto out;
@@ -1275,8 +1288,8 @@ mt7925_stop_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif,if (err) goto out; -mt7925_mcu_add_bss_info (&dev->phy, mvif->bss_conf.mt76.ctx, vif,NULL , - false); +mt7925_mcu_add_bss_info (&dev->phy, mvif->bss_conf.mt76.ctx, link_conf, +NULL , false); out:mt792x_mutex_release (dev);
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +11 -11
@@ -2315,11 +2315,11 @@ int mt7925_mcu_set_timing(struct mt792x_phy *phy,int mt7925_mcu_add_bss_info (struct mt792x_phy *phy,struct ieee80211_chanctx_conf *ctx, -struct ieee80211_vif *vif, +struct ieee80211_bss_conf *link_conf,struct ieee80211_sta *sta,int enable) { -struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; +struct mt792x_vif *mvif = (struct mt792x_vif *)link_conf->vif->drv_priv;struct mt792x_dev *dev = phy->dev;struct sk_buff *skb;int err;
@@ -2330,18 +2330,18 @@ int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,return PTR_ERR (skb);/* bss_basic must be first */ -mt7925_mcu_bss_basic_tlv (skb, vif, sta, ctx, phy->mt76, +mt7925_mcu_bss_basic_tlv (skb, link_conf->vif, sta, ctx, phy->mt76, mvif->sta.deflink.wcid.idx, enable); -mt7925_mcu_bss_sec_tlv (skb, vif); +mt7925_mcu_bss_sec_tlv (skb, link_conf->vif); -mt7925_mcu_bss_bmc_tlv (skb, phy, ctx, vif, sta); -mt7925_mcu_bss_qos_tlv (skb, vif); -mt7925_mcu_bss_mld_tlv (skb, vif, sta); -mt7925_mcu_bss_ifs_tlv (skb, vif); +mt7925_mcu_bss_bmc_tlv (skb, phy, ctx, link_conf->vif, sta); +mt7925_mcu_bss_qos_tlv (skb, link_conf->vif); +mt7925_mcu_bss_mld_tlv (skb, link_conf->vif, sta); +mt7925_mcu_bss_ifs_tlv (skb, link_conf->vif); -if (vif->bss_conf.he_support) { -mt7925_mcu_bss_he_tlv (skb, vif, phy); -mt7925_mcu_bss_color_tlv (skb, vif, enable); +if (link_conf->he_support) { +mt7925_mcu_bss_he_tlv (skb, link_conf->vif, phy); +mt7925_mcu_bss_color_tlv (skb, link_conf->vif, enable); } err = mt76_mcu_skb_send_msg(&dev->mt76, skb,
drivers/net/wireless/mediatek/mt76/mt7925/mcu.h +1 -1
@@ -578,7 +578,7 @@ int mt7925_mcu_sched_scan_enable(struct mt76_phy *phy, bool enable);int mt7925_mcu_add_bss_info (struct mt792x_phy *phy,struct ieee80211_chanctx_conf *ctx, -struct ieee80211_vif *vif, +struct ieee80211_bss_conf *link_conf,struct ieee80211_sta *sta,int enable); int mt7925_mcu_set_timing(struct mt792x_phy *phy,
drivers/net/wireless/mediatek/mt76/mt792x.h +10 -0
@@ -244,6 +244,16 @@ mt792x_link_conf_to_mconf(struct ieee80211_bss_conf *link_conf)return mt792x_vif_to_link (mvif, link_conf->link_id); } +static inline struct ieee80211_bss_conf * +mt792x_vif_to_bss_conf (struct ieee80211_vif *vif,unsigned int link_id) +{ +if (!ieee80211_vif_is_mld (vif) || + link_id >=IEEE80211_LINK_UNSPECIFIED ) +return &vif->bss_conf; + +return link_conf_dereference_protected (vif, link_id); +} +static inline struct mt792x_dev *mt792x_hw_dev (struct ieee80211_hw *hw) {
Signature · 1 line
2.34.1
PATCH 8/47 wifi: mt76: mt7925: extend mt7925_mcu_set_timing for per-link BSS
In reply to [email protected]From: Sean Wang <[email protected]>
Extend mt7925_mcu_set_timing with per-link BSS configuration.
The patch we created is a prerequisite to enable the MLO function in the driver. It is purely a refactoring patch so the functionality should remain unchanged.
--- drivers/net/wireless/mediatek/mt76/mt7925/main.c | 2 +- drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 6 +++--- drivers/net/wireless/mediatek/mt76/mt7925/mcu.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/main.c +1 -1
@@ -1400,7 +1400,7 @@ static void mt7925_link_info_changed(struct ieee80211_hw *hw,if (slottime != phy->slottime) { phy->slottime = slottime; -mt7925_mcu_set_timing (phy, vif); +mt7925_mcu_set_timing (phy, info); } }
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +3 -3
@@ -2296,9 +2296,9 @@ mt7925_mcu_bss_ifs_tlv(struct sk_buff *skb, struct ieee80211_vif *vif) }int mt7925_mcu_set_timing (struct mt792x_phy *phy, -struct ieee80211_vif *vif) +struct ieee80211_bss_conf *link_conf) { -struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; +struct mt792x_vif *mvif = (struct mt792x_vif *)link_conf->vif->drv_priv;struct mt792x_dev *dev = phy->dev;struct sk_buff *skb;
@@ -2307,7 +2307,7 @@ int mt7925_mcu_set_timing(struct mt792x_phy *phy,if (IS_ERR (skb))return PTR_ERR (skb); -mt7925_mcu_bss_ifs_tlv (skb, vif); +mt7925_mcu_bss_ifs_tlv (skb, link_conf->vif);return mt76_mcu_skb_send_msg (&dev->mt76, skb,MCU_UNI_CMD (BSS_INFO_UPDATE ), true);
drivers/net/wireless/mediatek/mt76/mt7925/mcu.h +1 -1
@@ -582,7 +582,7 @@ int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,struct ieee80211_sta *sta, int enable);int mt7925_mcu_set_timing (struct mt792x_phy *phy, -struct ieee80211_vif *vif); +struct ieee80211_bss_conf *link_conf);int mt7925_mcu_set_deep_sleep (struct mt792x_dev *dev,bool enable);int mt7925_mcu_set_channel_domain (struct mt76_phy *phy);int mt7925_mcu_set_radio_en (struct mt792x_phy *phy,bool enable);
Signature · 1 line
2.34.1
PATCH 9/47 wifi: mt76: mt7925: extend mt7925_mcu_bss_ifs_tlv for per-link BSS
In reply to [email protected]From: Sean Wang <[email protected]>
Extend mt7925_mcu_bss_ifs_tlv with per-link BSS configuration.
The patch we created is a prerequisite to enable the MLO function in the driver. It is purely a refactoring patch so the functionality should remain unchanged.
--- drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +5 -4
@@ -2282,9 +2282,10 @@ mt7925_mcu_bss_color_tlv(struct sk_buff *skb, struct ieee80211_vif *vif, }static void -mt7925_mcu_bss_ifs_tlv (struct sk_buff *skb,struct ieee80211_vif *vif) +mt7925_mcu_bss_ifs_tlv (struct sk_buff *skb, +struct ieee80211_bss_conf *link_conf) { -struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; +struct mt792x_vif *mvif = (struct mt792x_vif *)link_conf->vif->drv_priv;struct mt792x_phy *phy = mvif->phy;struct bss_ifs_time_tlv *ifs_time;struct tlv *tlv;
@@ -2307,7 +2308,7 @@ int mt7925_mcu_set_timing(struct mt792x_phy *phy,if (IS_ERR (skb))return PTR_ERR (skb); -mt7925_mcu_bss_ifs_tlv (skb, link_conf->vif); +mt7925_mcu_bss_ifs_tlv (skb, link_conf);return mt76_mcu_skb_send_msg (&dev->mt76, skb,MCU_UNI_CMD (BSS_INFO_UPDATE ), true);
@@ -2337,7 +2338,7 @@ int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,mt7925_mcu_bss_bmc_tlv (skb, phy, ctx, link_conf->vif, sta);mt7925_mcu_bss_qos_tlv (skb, link_conf->vif);mt7925_mcu_bss_mld_tlv (skb, link_conf->vif, sta); -mt7925_mcu_bss_ifs_tlv (skb, link_conf->vif); +mt7925_mcu_bss_ifs_tlv (skb, link_conf);if (link_conf->he_support) {mt7925_mcu_bss_he_tlv (skb, link_conf->vif, phy);
Signature · 1 line
2.34.1
PATCH 10/47 wifi: mt76: mt7925: extend mt7925_mcu_bss_color_tlv for per-link BSS
In reply to [email protected]From: Sean Wang <[email protected]>
Extend mt7925_mcu_bss_color_tlv with per-link BSS configuration.
The patch we created is a prerequisite to enable the MLO function in the driver. It is purely a refactoring patch so the functionality should remain unchanged.
--- drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +4 -4
@@ -2266,7 +2266,7 @@ mt7925_mcu_bss_he_tlv(struct sk_buff *skb, struct ieee80211_vif *vif, }static void -mt7925_mcu_bss_color_tlv (struct sk_buff *skb,struct ieee80211_vif *vif, +mt7925_mcu_bss_color_tlv (struct sk_buff *skb,struct ieee80211_bss_conf *link_conf,bool enable) {struct bss_info_uni_bss_color *color;
@@ -2276,9 +2276,9 @@ mt7925_mcu_bss_color_tlv(struct sk_buff *skb, struct ieee80211_vif *vif, color = (struct bss_info_uni_bss_color *)tlv; color->enable = enable ? - vif->bss_conf.he_bss_color.enabled :0 ; + link_conf->he_bss_color.enabled :0 ; color->bss_color = enable ? - vif->bss_conf.he_bss_color.color :0 ; + link_conf->he_bss_color.color :0 ; } static void
@@ -2342,7 +2342,7 @@ int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,if (link_conf->he_support) {mt7925_mcu_bss_he_tlv (skb, link_conf->vif, phy); -mt7925_mcu_bss_color_tlv (skb, link_conf->vif, enable); +mt7925_mcu_bss_color_tlv (skb, link_conf, enable); } err = mt76_mcu_skb_send_msg(&dev->mt76, skb,
Signature · 1 line
2.34.1
PATCH 11/47 wifi: mt76: mt7925: extend mt7925_mcu_bss_he_tlv for per-link BSS
In reply to [email protected]From: Sean Wang <[email protected]>
Extend mt7925_mcu_bss_he_tlv with per-link BSS configuration.
The patch we created is a prerequisite to enable the MLO function in the driver. It is purely a refactoring patch so the functionality should remain unchanged.
--- drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +5 -5
@@ -2238,7 +2238,7 @@ mt7925_mcu_bss_qos_tlv(struct sk_buff *skb, struct ieee80211_vif *vif) }static void -mt7925_mcu_bss_he_tlv (struct sk_buff *skb,struct ieee80211_vif *vif, +mt7925_mcu_bss_he_tlv (struct sk_buff *skb,struct ieee80211_bss_conf *link_conf,struct mt792x_phy *phy) {#define DEFAULT_HE_PE_DURATION 4
@@ -2247,16 +2247,16 @@ mt7925_mcu_bss_he_tlv(struct sk_buff *skb, struct ieee80211_vif *vif,struct bss_info_uni_he *he;struct tlv *tlv; - cap =mt76_connac_get_he_phy_cap (phy->mt76, vif); + cap =mt76_connac_get_he_phy_cap (phy->mt76, link_conf->vif); tlv =mt76_connac_mcu_add_tlv (skb,UNI_BSS_INFO_HE_BASIC ,sizeof (*he)); he = (struct bss_info_uni_he *)tlv; - he->he_pe_duration = vif->bss_conf.htc_trig_based_pkt_ext; + he->he_pe_duration = link_conf->htc_trig_based_pkt_ext;if (!he->he_pe_duration) he->he_pe_duration =DEFAULT_HE_PE_DURATION ; - he->he_rts_thres =cpu_to_le16 (vif->bss_conf.frame_time_rts_th); + he->he_rts_thres =cpu_to_le16 (link_conf->frame_time_rts_th);if (!he->he_rts_thres) he->he_rts_thres =cpu_to_le16 (DEFAULT_HE_DURATION_RTS_THRES );
@@ -2341,7 +2341,7 @@ int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,mt7925_mcu_bss_ifs_tlv (skb, link_conf);if (link_conf->he_support) { -mt7925_mcu_bss_he_tlv (skb, link_conf->vif, phy); +mt7925_mcu_bss_he_tlv (skb, link_conf, phy);mt7925_mcu_bss_color_tlv (skb, link_conf, enable); }
Signature · 1 line
2.34.1
PATCH 12/47 wifi: mt76: mt7925: extend mt7925_mcu_bss_qos_tlv for per-link BSS
In reply to [email protected]From: Sean Wang <[email protected]>
Extend mt7925_mcu_bss_qos_tlv with per-link BSS configuration.
The patch we created is a prerequisite to enable the MLO function in the driver. It is purely a refactoring patch so the functionality should remain unchanged.
--- drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +3 -3
@@ -2227,14 +2227,14 @@ mt7925_mcu_bss_mld_tlv(struct sk_buff *skb, }static void -mt7925_mcu_bss_qos_tlv (struct sk_buff *skb,struct ieee80211_vif *vif) +mt7925_mcu_bss_qos_tlv (struct sk_buff *skb,struct ieee80211_bss_conf *link_conf) {struct mt76_connac_bss_qos_tlv *qos;struct tlv *tlv; tlv =mt76_connac_mcu_add_tlv (skb,UNI_BSS_INFO_QBSS ,sizeof (*qos)); qos = (struct mt76_connac_bss_qos_tlv *)tlv; - qos->qos = vif->bss_conf.qos; + qos->qos = link_conf->qos; } static void
@@ -2336,7 +2336,7 @@ int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,mt7925_mcu_bss_sec_tlv (skb, link_conf->vif);mt7925_mcu_bss_bmc_tlv (skb, phy, ctx, link_conf->vif, sta); -mt7925_mcu_bss_qos_tlv (skb, link_conf->vif); +mt7925_mcu_bss_qos_tlv (skb, link_conf);mt7925_mcu_bss_mld_tlv (skb, link_conf->vif, sta);mt7925_mcu_bss_ifs_tlv (skb, link_conf);
Signature · 1 line
2.34.1
PATCH 13/47 wifi: mt76: mt7925: extend mt7925_mcu_bss_mld_tlv for per-link BSS
In reply to [email protected]From: Sean Wang <[email protected]>
Extend mt7925_mcu_bss_mld_tlv with per-link BSS configuration.
The patch we created is a prerequisite to enable the MLO function in the driver. It is purely a refactoring patch so the functionality should remain unchanged.
--- drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +7 -7
@@ -2206,20 +2206,20 @@ 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_vif *vif, +struct ieee80211_bss_conf *link_conf,struct ieee80211_sta *sta) { -struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; -bool is_mld =ieee80211_vif_is_mld (vif); +struct mt792x_bss_conf *mconf =mt792x_link_conf_to_mconf (link_conf); +bool is_mld =ieee80211_vif_is_mld (link_conf->vif);struct bss_mld_tlv *mld;struct tlv *tlv; tlv =mt76_connac_mcu_add_tlv (skb,UNI_BSS_INFO_MLD ,sizeof (*mld)); mld = (struct bss_mld_tlv *)tlv; - mld->link_id = sta ? (is_mld ? vif->bss_conf.link_id :0 ) :0xff ; - mld->group_mld_id = is_mld ? mvif->bss_conf.mt76.idx :0xff ; - mld->own_mld_id = mvif->bss_conf.mt76.idx +32 ; + mld->link_id = sta ? (is_mld ? link_conf->link_id :0 ) :0xff ; + mld->group_mld_id = is_mld ? mconf->mt76.idx :0xff ; + mld->own_mld_id = mconf->mt76.idx +32 ; mld->remap_idx =0xff ;if (sta)
@@ -2337,7 +2337,7 @@ int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,mt7925_mcu_bss_bmc_tlv (skb, phy, ctx, link_conf->vif, sta);mt7925_mcu_bss_qos_tlv (skb, link_conf); -mt7925_mcu_bss_mld_tlv (skb, link_conf->vif, sta); +mt7925_mcu_bss_mld_tlv (skb, link_conf, sta);mt7925_mcu_bss_ifs_tlv (skb, link_conf);if (link_conf->he_support) {
Signature · 1 line
2.34.1
PATCH 14/47 wifi: mt76: mt7925: extend mt7925_mcu_bss_bmc_tlv for per-link BSS
In reply to [email protected]From: Sean Wang <[email protected]>
Extend mt7925_mcu_bss_bmc_tlv with per-link BSS configuration.
The patch we created is a prerequisite to enable the MLO function in the driver. It is purely a refactoring patch so the functionality should remain unchanged.
--- drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +4 -3
@@ -2179,12 +2179,13 @@ mt7925_mcu_bss_sec_tlv(struct sk_buff *skb, struct ieee80211_vif *vif)static void mt7925_mcu_bss_bmc_tlv (struct sk_buff *skb,struct mt792x_phy *phy,struct ieee80211_chanctx_conf *ctx, -struct ieee80211_vif *vif, +struct ieee80211_bss_conf *link_conf,struct ieee80211_sta *sta) {struct cfg80211_chan_def *chandef = ctx ? &ctx->def : &phy->mt76->chandef; -struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv; +struct mt792x_bss_conf *mconf =mt792x_link_conf_to_mconf (link_conf);enum nl80211_band band = chandef->chan->band; +struct mt76_vif *mvif = &mconf->mt76;struct bss_rate_tlv *bmc;struct tlv *tlv; u8 idx = mvif->mcast_rates_idx ?
@@ -2335,7 +2336,7 @@ int mt7925_mcu_add_bss_info(struct mt792x_phy *phy, mvif->sta.deflink.wcid.idx, enable);mt7925_mcu_bss_sec_tlv (skb, link_conf->vif); -mt7925_mcu_bss_bmc_tlv (skb, phy, ctx, link_conf->vif, sta); +mt7925_mcu_bss_bmc_tlv (skb, phy, ctx, link_conf, sta);mt7925_mcu_bss_qos_tlv (skb, link_conf);mt7925_mcu_bss_mld_tlv (skb, link_conf, sta);mt7925_mcu_bss_ifs_tlv (skb, link_conf);
Signature · 1 line
2.34.1
PATCH 15/47 wifi: mt76: mt7925: remove unused parameters in mt7925_mcu_bss_bmc_tlv
In reply to [email protected]From: Sean Wang <[email protected]>
remove unused parameters in mt7925_mcu_bss_bmc_tlv
--- drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +2 -3
@@ -2179,8 +2179,7 @@ mt7925_mcu_bss_sec_tlv(struct sk_buff *skb, struct ieee80211_vif *vif)static void mt7925_mcu_bss_bmc_tlv (struct sk_buff *skb,struct mt792x_phy *phy,struct ieee80211_chanctx_conf *ctx, -struct ieee80211_bss_conf *link_conf, -struct ieee80211_sta *sta) +struct ieee80211_bss_conf *link_conf) {struct cfg80211_chan_def *chandef = ctx ? &ctx->def : &phy->mt76->chandef;struct mt792x_bss_conf *mconf =mt792x_link_conf_to_mconf (link_conf);
@@ -2336,7 +2335,7 @@ int mt7925_mcu_add_bss_info(struct mt792x_phy *phy, mvif->sta.deflink.wcid.idx, enable);mt7925_mcu_bss_sec_tlv (skb, link_conf->vif); -mt7925_mcu_bss_bmc_tlv (skb, phy, ctx, link_conf, sta); +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, sta);mt7925_mcu_bss_ifs_tlv (skb, link_conf);
Signature · 1 line
2.34.1
PATCH 16/47 wifi: mt76: mt7925: extend mt7925_mcu_bss_sec_tlv for per-link BSS
In reply to [email protected]From: Sean Wang <[email protected]>
Extend mt7925_mcu_bss_sec_tlv with per-link BSS configuration.
The patch we created is a prerequisite to enable the MLO function in the driver. It is purely a refactoring patch so the functionality should remain unchanged.
--- drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +5 -3
@@ -2132,9 +2132,11 @@ mt7925_mcu_bss_basic_tlv(struct sk_buff *skb, }static void -mt7925_mcu_bss_sec_tlv (struct sk_buff *skb,struct ieee80211_vif *vif) +mt7925_mcu_bss_sec_tlv (struct sk_buff *skb, +struct ieee80211_bss_conf *link_conf) { -struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv; +struct mt792x_bss_conf *mconf =mt792x_link_conf_to_mconf (link_conf); +struct mt76_vif *mvif = &mconf->mt76;struct bss_sec_tlv {__le16 tag;__le16 len;
@@ -2333,7 +2335,7 @@ int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,/* bss_basic must be first */ mt7925_mcu_bss_basic_tlv (skb, link_conf->vif, sta, ctx, phy->mt76, mvif->sta.deflink.wcid.idx, enable); -mt7925_mcu_bss_sec_tlv (skb, link_conf->vif); +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);
Signature · 1 line
2.34.1
PATCH 17/47 wifi: mt76: mt7925: extend mt7925_mcu_bss_basic_tlv for per-link BSS
In reply to [email protected]From: Sean Wang <[email protected]>
Extend mt7925_mcu_bss_basic_tlv with per-link BSS configuration.
The patch we created is a prerequisite to enable the MLO function in the driver. It is purely a refactoring patch so the functionality should remain unchanged.
--- .../net/wireless/mediatek/mt76/mt7925/main.c | 1 + .../net/wireless/mediatek/mt76/mt7925/mcu.c | 25 ++++++++++--------- drivers/net/wireless/mediatek/mt76/mt792x.h | 1 + 3 files changed, 15 insertions(+), 12 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/main.c +1 -0
@@ -338,6 +338,7 @@ mt7925_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) mvif->phy = phy; mvif->bss_conf.mt76.band_idx =0 ; mvif->bss_conf.mt76.wmm_idx = mvif->bss_conf.mt76.idx %MT76_CONNAC_MAX_WMM_SETS ; + mvif->bss_conf.vif = mvif;if (phy->mt76->chandef.chan->band !=NL80211_BAND_2GHZ ) mvif->bss_conf.mt76.basic_rates_idx = MT792x_BASIC_RATES_TBL +4 ;
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +13 -12
@@ -2062,15 +2062,16 @@ mt7925_get_phy_mode_ext(struct mt76_phy *phy, struct ieee80211_vif *vif,static void mt7925_mcu_bss_basic_tlv (struct sk_buff *skb, -struct ieee80211_vif *vif, +struct ieee80211_bss_conf *link_conf,struct ieee80211_sta *sta,struct ieee80211_chanctx_conf *ctx,struct mt76_phy *phy,u16 wlan_idx,bool enable) { -struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; +struct ieee80211_vif *vif = link_conf->vif; +struct mt792x_bss_conf *mconf =mt792x_link_conf_to_mconf (link_conf);struct mt792x_sta *msta = sta ? (struct mt792x_sta *)sta->drv_priv : - &mvif->sta; + &mconf->vif->sta;struct cfg80211_chan_def *chandef = ctx ? &ctx->def : &phy->chandef;enum nl80211_band band = chandef->chan->band;struct mt76_connac_bss_basic_tlv *basic_req;
@@ -2081,8 +2082,8 @@ mt7925_mcu_bss_basic_tlv(struct sk_buff *skb, tlv =mt76_connac_mcu_add_tlv (skb,UNI_BSS_INFO_BASIC ,sizeof (*basic_req)); basic_req = (struct mt76_connac_bss_basic_tlv *)tlv; - idx = mvif->bss_conf.mt76.omac_idx >EXT_BSSID_START ?HW_BSSID_0 : - mvif->bss_conf.mt76.omac_idx; + idx = mconf->mt76.omac_idx >EXT_BSSID_START ?HW_BSSID_0 : + mconf->mt76.omac_idx; basic_req->hw_bss_idx = idx; basic_req->phymode_ext =mt7925_get_phy_mode_ext (phy, vif, band, sta);
@@ -2092,15 +2093,15 @@ mt7925_mcu_bss_basic_tlv(struct sk_buff *skb,else basic_req->nonht_basic_phy =cpu_to_le16 (PHY_TYPE_OFDM_INDEX ); -memcpy (basic_req->bssid, vif->bss_conf.bssid,ETH_ALEN ); +memcpy (basic_req->bssid, link_conf->bssid,ETH_ALEN ); basic_req->phymode =mt76_connac_get_phy_mode (phy, vif, band, sta); - basic_req->bcn_interval =cpu_to_le16 (vif->bss_conf.beacon_int); - basic_req->dtim_period = vif->bss_conf.dtim_period; + basic_req->bcn_interval =cpu_to_le16 (link_conf->beacon_int); + basic_req->dtim_period = link_conf->dtim_period; basic_req->bmc_tx_wlan_idx =cpu_to_le16 (wlan_idx); basic_req->sta_idx =cpu_to_le16 (msta->deflink.wcid.idx); - basic_req->omac_idx = mvif->bss_conf.mt76.omac_idx; - basic_req->band_idx = mvif->bss_conf.mt76.band_idx; - basic_req->wmm_idx = mvif->bss_conf.mt76.wmm_idx; + basic_req->omac_idx = mconf->mt76.omac_idx; + basic_req->band_idx = mconf->mt76.band_idx; + basic_req->wmm_idx = mconf->mt76.wmm_idx; basic_req->conn_state = !enable;switch (vif->type) {
@@ -2333,7 +2334,7 @@ int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,return PTR_ERR (skb);/* bss_basic must be first */ -mt7925_mcu_bss_basic_tlv (skb, link_conf->vif, sta, ctx, phy->mt76, +mt7925_mcu_bss_basic_tlv (skb, link_conf, sta, ctx, phy->mt76, mvif->sta.deflink.wcid.idx, enable);mt7925_mcu_bss_sec_tlv (skb, link_conf);
drivers/net/wireless/mediatek/mt76/mt792x.h +1 -0
@@ -106,6 +106,7 @@ struct mt792x_chanctx {struct mt792x_bss_conf {struct mt76_vif mt76;/* must be first */ +struct mt792x_vif *vif;struct ewma_rssi rssi;struct ieee80211_tx_queue_params queue_params[IEEE80211_NUM_ACS ]; };
Signature · 1 line
2.34.1
PATCH 18/47 wifi: mt76: mt7925: extend mt7925_mcu_set_bss_pm for per-link BSS
In reply to [email protected]From: Sean Wang <[email protected]>
Extend mt7925_mcu_set_bss_pm with per-link BSS configuration.
The patch we created is a prerequisite to enable the MLO function in the driver. It is purely a refactoring patch so the functionality should remain unchanged.
--- drivers/net/wireless/mediatek/mt76/mt7925/main.c | 4 ++-- drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 15 ++++++++------- .../net/wireless/mediatek/mt76/mt7925/mt7925.h | 3 ++- 3 files changed, 12 insertions(+), 10 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/main.c +2 -2
@@ -1263,7 +1263,7 @@ mt7925_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif,if (err) goto out; - err =mt7925_mcu_set_bss_pm (dev, vif, true); + err =mt7925_mcu_set_bss_pm (dev, link_conf, true);if (err) goto out;
@@ -1285,7 +1285,7 @@ mt7925_stop_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif,mt792x_mutex_acquire (dev); - err =mt7925_mcu_set_bss_pm (dev, vif, false); + err =mt7925_mcu_set_bss_pm (dev, link_conf, false);if (err) goto out;
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +8 -7
@@ -1319,10 +1319,11 @@ mt7925_mcu_uni_bss_bcnft(struct mt792x_dev *dev, struct ieee80211_vif *vif, } int -mt7925_mcu_set_bss_pm(struct mt792x_dev *dev, struct ieee80211_vif *vif, +mt7925_mcu_set_bss_pm(struct mt792x_dev *dev, + struct ieee80211_bss_conf *link_conf, bool enable) { - struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; + struct mt792x_bss_conf *mconf = mt792x_link_conf_to_mconf(link_conf); struct { struct { u8 bss_idx;
@@ -1339,13 +1340,13 @@ mt7925_mcu_set_bss_pm(struct mt792x_dev *dev, struct ieee80211_vif *vif, }__packed enable; } req = { .hdr = { - .bss_idx = mvif->bss_conf.mt76.idx, + .bss_idx = mconf->mt76.idx, }, .enable = { .tag = cpu_to_le16(UNI_BSS_INFO_BCNFT), .len = cpu_to_le16(sizeof(struct bcnft_tlv)), - .dtim_period = vif->bss_conf.dtim_period, - .bcn_interval = cpu_to_le16(vif->bss_conf.beacon_int), + .dtim_period = link_conf->dtim_period, + .bcn_interval = cpu_to_le16(link_conf->beacon_int), }, };struct {
@@ -1359,7 +1360,7 @@ mt7925_mcu_set_bss_pm(struct mt792x_dev *dev, struct ieee80211_vif *vif, }__packed disable; } req1 = { .hdr = { - .bss_idx = mvif->bss_conf.mt76.idx, + .bss_idx = mconf->mt76.idx, }, .disable = { .tag = cpu_to_le16(UNI_BSS_INFO_PM_DISABLE),
@@ -1693,7 +1694,7 @@ int mt7925_mcu_set_beacon_filter(struct mt792x_dev *dev, MT_WF_RFCR_DROP_OTHER_BEACON); } - err =mt7925_mcu_set_bss_pm (dev, vif, false); + err =mt7925_mcu_set_bss_pm (dev, &vif->bss_conf, false);if (err)return err;
drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h +2 -1
@@ -192,7 +192,8 @@ int __mt7925_start(struct mt792x_phy *phy);int mt7925_register_device (struct mt792x_dev *dev);void mt7925_unregister_device (struct mt792x_dev *dev);int mt7925_run_firmware (struct mt792x_dev *dev); -int mt7925_mcu_set_bss_pm (struct mt792x_dev *dev,struct ieee80211_vif *vif, +int mt7925_mcu_set_bss_pm (struct mt792x_dev *dev, +struct ieee80211_bss_conf *link_conf,bool enable); int mt7925_mcu_sta_update(struct mt792x_dev *dev, struct ieee80211_sta *sta, struct ieee80211_vif *vif, bool enable,
Signature · 1 line
2.34.1
PATCH 19/47 wifi: mt76: mt7925: extend mt7925_mcu_[abort, set]_roc for per-link BSS
In reply to [email protected]From: Sean Wang <[email protected]>
The channel context has to be bound with the per-link BSS, thus, we extend mt7925_mcu_[abort, set]_roc to work with the per-link BSS configuration.
The patch we created is a prerequisite to enable the MLO function in the driver. It is purely a refactoring patch so the functionality should remain unchanged.
--- .../net/wireless/mediatek/mt76/mt7925/main.c | 23 +++++++++++-------- .../net/wireless/mediatek/mt76/mt7925/mcu.c | 8 +++---- .../wireless/mediatek/mt76/mt7925/mt7925.h | 4 ++-- 3 files changed, 19 insertions(+), 16 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/main.c +13 -10
@@ -387,7 +387,7 @@ static void mt7925_roc_iter(void *priv, u8 *mac,struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;struct mt792x_phy *phy = priv; -mt7925_mcu_abort_roc (phy, mvif, phy->roc_token_id); +mt7925_mcu_abort_roc (phy, &mvif->bss_conf, phy->roc_token_id); }void mt7925_roc_work (struct work_struct *work)
@@ -408,7 +408,8 @@ void mt7925_roc_work(struct work_struct *work)ieee80211_remain_on_channel_expired (phy->mt76->hw); } -static int mt7925_abort_roc (struct mt792x_phy *phy,struct mt792x_vif *vif) +static int mt7925_abort_roc (struct mt792x_phy *phy, +struct mt792x_bss_conf *mconf) {int err =0 ;
@@ -417,14 +418,14 @@ static int mt7925_abort_roc(struct mt792x_phy *phy, struct mt792x_vif *vif)mt792x_mutex_acquire (phy->dev);if (test_and_clear_bit (MT76_STATE_ROC , &phy->mt76->state)) - err =mt7925_mcu_abort_roc (phy, vif, phy->roc_token_id); + err =mt7925_mcu_abort_roc (phy, mconf, phy->roc_token_id);mt792x_mutex_release (phy->dev);return err; }static int mt7925_set_roc (struct mt792x_phy *phy, -struct mt792x_vif *vif, +struct mt792x_bss_conf *mconf,struct ieee80211_channel *chan,int duration,enum mt7925_roc_req type)
@@ -436,7 +437,7 @@ static int mt7925_set_roc(struct mt792x_phy *phy, phy->roc_grant = false; - err =mt7925_mcu_set_roc (phy, vif, chan, duration, type, + err =mt7925_mcu_set_roc (phy, mconf, chan, duration, type, ++phy->roc_token_id);if (err <0 ) {clear_bit (MT76_STATE_ROC , &phy->mt76->state);
@@ -444,7 +445,7 @@ static int mt7925_set_roc(struct mt792x_phy *phy, }if (!wait_event_timeout (phy->roc_wait, phy->roc_grant,4 *HZ )) { -mt7925_mcu_abort_roc (phy, vif, phy->roc_token_id); +mt7925_mcu_abort_roc (phy, mconf, phy->roc_token_id);clear_bit (MT76_STATE_ROC , &phy->mt76->state); err = -ETIMEDOUT ; }
@@ -464,7 +465,8 @@ static int mt7925_remain_on_channel(struct ieee80211_hw *hw,int err;mt792x_mutex_acquire (phy->dev); - err =mt7925_set_roc (phy, mvif, chan, duration,MT7925_ROC_REQ_ROC ); + err =mt7925_set_roc (phy, &mvif->bss_conf, + chan, duration,MT7925_ROC_REQ_ROC );mt792x_mutex_release (phy->dev);return err;
@@ -476,7 +478,7 @@ static int mt7925_cancel_remain_on_channel(struct ieee80211_hw *hw,struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;struct mt792x_phy *phy =mt792x_hw_phy (hw); -return mt7925_abort_roc (phy, mvif); +return mt7925_abort_roc (phy, &mvif->bss_conf); } static int mt7925_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
@@ -1345,7 +1347,8 @@ static void mt7925_mgd_prepare_tx(struct ieee80211_hw *hw,jiffies_to_msecs (HZ );mt792x_mutex_acquire (dev); -mt7925_set_roc (mvif->phy, mvif, mvif->bss_conf.mt76.ctx->def.chan, duration, +mt7925_set_roc (mvif->phy, &mvif->bss_conf, + mvif->bss_conf.mt76.ctx->def.chan, duration,MT7925_ROC_REQ_JOIN );mt792x_mutex_release (dev); }
@@ -1356,7 +1359,7 @@ static void mt7925_mgd_complete_tx(struct ieee80211_hw *hw, {struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; -mt7925_abort_roc (mvif->phy, mvif); +mt7925_abort_roc (mvif->phy, &mvif->bss_conf); } static void mt7925_vif_cfg_changed(struct ieee80211_hw *hw,
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +4 -4
@@ -1050,7 +1050,7 @@ int mt7925_mcu_add_key(struct mt76_dev *dev, struct ieee80211_vif *vif,return mt76_mcu_skb_send_msg (dev, skb, mcu_cmd, true); } -int mt7925_mcu_set_roc (struct mt792x_phy *phy,struct mt792x_vif *vif, +int mt7925_mcu_set_roc (struct mt792x_phy *phy,struct mt792x_bss_conf *mconf,struct ieee80211_channel *chan,int duration,enum mt7925_roc_req type,u8 token_id) {
@@ -1086,7 +1086,7 @@ int mt7925_mcu_set_roc(struct mt792x_phy *phy, struct mt792x_vif *vif, .tokenid = token_id, .reqtype = type, .maxinterval = cpu_to_le32(duration), - .bss_idx = vif->bss_conf.mt76.idx, + .bss_idx = mconf->mt76.idx, .control_channel = chan->hw_value, .bw = CMD_CBW_20MHZ, .bw_from_ap = CMD_CBW_20MHZ,
@@ -1117,7 +1117,7 @@ int mt7925_mcu_set_roc(struct mt792x_phy *phy, struct mt792x_vif *vif, &req, sizeof(req), false); } -int mt7925_mcu_abort_roc (struct mt792x_phy *phy,struct mt792x_vif *vif, +int mt7925_mcu_abort_roc (struct mt792x_phy *phy,struct mt792x_bss_conf *mconf,u8 token_id) {struct mt792x_dev *dev = phy->dev;
@@ -1138,7 +1138,7 @@ int mt7925_mcu_abort_roc(struct mt792x_phy *phy, struct mt792x_vif *vif, .tag = cpu_to_le16(UNI_ROC_ABORT), .len = cpu_to_le16(sizeof(struct roc_abort_tlv)), .tokenid = token_id, - .bss_idx = vif->bss_conf.mt76.idx, + .bss_idx = mconf->mt76.idx, .dbdcband = 0xff, /* auto*/ }, };
drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h +2 -2
@@ -292,10 +292,10 @@ int mt7925_set_tx_sar_pwr(struct ieee80211_hw *hw,int mt7925_mcu_regval (struct mt792x_dev *dev,u32 regidx,u32 *val,bool set);int mt7925_mcu_set_clc (struct mt792x_dev *dev,u8 *alpha2,enum environment_cap env_cap); -int mt7925_mcu_set_roc (struct mt792x_phy *phy,struct mt792x_vif *vif, +int mt7925_mcu_set_roc (struct mt792x_phy *phy,struct mt792x_bss_conf *mconf,struct ieee80211_channel *chan,int duration,enum mt7925_roc_req type,u8 token_id); -int mt7925_mcu_abort_roc (struct mt792x_phy *phy,struct mt792x_vif *vif, +int mt7925_mcu_abort_roc (struct mt792x_phy *phy,struct mt792x_bss_conf *mconf,u8 token_id);int mt7925_mcu_fill_message (struct mt76_dev *mdev,struct sk_buff *skb,int cmd,int *wait_seq);
Signature · 1 line
2.34.1
PATCH 20/47 wifi: mt76: mt7925: extend mt7925_mcu_uni_bss_bcnft for per-link BSS
In reply to [email protected]From: Sean Wang <[email protected]>
Extend mt7925_mcu_uni_bss_bcnft with per-link BSS configuration.
The patch we created is a prerequisite to enable the MLO function in the driver. It is purely a refactoring patch so the functionality should remain unchanged.
--- drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +8 -8
@@ -1281,10 +1281,10 @@ int mt7925_mcu_uni_bss_ps(struct mt792x_dev *dev, struct ieee80211_vif *vif) } static int -mt7925_mcu_uni_bss_bcnft(struct mt792x_dev *dev, struct ieee80211_vif *vif, - bool enable) +mt7925_mcu_uni_bss_bcnft(struct mt792x_dev *dev, + struct ieee80211_bss_conf *link_conf, bool enable) { - struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; + struct mt792x_bss_conf *mconf = mt792x_link_conf_to_mconf(link_conf); struct { struct { u8 bss_idx;
@@ -1301,17 +1301,17 @@ mt7925_mcu_uni_bss_bcnft(struct mt792x_dev *dev, struct ieee80211_vif *vif, }__packed bcnft; }__packed bcnft_req = { .hdr = { - .bss_idx = mvif->bss_conf.mt76.idx, + .bss_idx = mconf->mt76.idx, }, .bcnft = { .tag =cpu_to_le16 (UNI_BSS_INFO_BCNFT ), .len =cpu_to_le16 (sizeof (struct bcnft_tlv )), - .bcn_interval =cpu_to_le16 (vif->bss_conf.beacon_int), - .dtim_period = vif->bss_conf.dtim_period, + .bcn_interval =cpu_to_le16 (link_conf->beacon_int), + .dtim_period = link_conf->dtim_period, }, }; -if (vif->type !=NL80211_IFTYPE_STATION ) +if (link_conf->vif->type !=NL80211_IFTYPE_STATION )return 0 ; return mt76_mcu_send_msg(&dev->mt76, MCU_UNI_CMD(BSS_INFO_UPDATE),
@@ -1685,7 +1685,7 @@ int mt7925_mcu_set_beacon_filter(struct mt792x_dev *dev,int err =0 ;if (enable) { - err =mt7925_mcu_uni_bss_bcnft (dev, vif, true); + err =mt7925_mcu_uni_bss_bcnft (dev, &vif->bss_conf, true);if (err)return err;
Signature · 1 line
2.34.1
PATCH 21/47 wifi: mt76: mt7925: extend mt7925_mcu_uni_bss_ps for per-link BSS
In reply to [email protected]From: Sean Wang <[email protected]>
Extend mt7925_mcu_uni_bss_ps with per-link BSS configuration.
The patch we created is a prerequisite to enable the MLO function in the driver. It is purely a refactoring patch so the functionality should remain unchanged.
--- drivers/net/wireless/mediatek/mt76/mt7925/main.c | 2 +- drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 11 ++++++----- drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h | 3 ++- 3 files changed, 9 insertions(+), 7 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/main.c +1 -1
@@ -1383,7 +1383,7 @@ static void mt7925_vif_cfg_changed(struct ieee80211_hw *hw, }if (changed &BSS_CHANGED_PS ) -mt7925_mcu_uni_bss_ps (dev, vif); +mt7925_mcu_uni_bss_ps (dev, &vif->bss_conf);mt792x_mutex_release (dev); }
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +6 -5
@@ -1243,9 +1243,10 @@ int mt7925_mcu_set_eeprom(struct mt792x_dev *dev) }EXPORT_SYMBOL_GPL (mt7925_mcu_set_eeprom); -int mt7925_mcu_uni_bss_ps(struct mt792x_dev *dev, struct ieee80211_vif *vif) +int mt7925_mcu_uni_bss_ps(struct mt792x_dev *dev, + struct ieee80211_bss_conf *link_conf) { - struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; + struct mt792x_bss_conf *mconf = mt792x_link_conf_to_mconf(link_conf); struct { struct { u8 bss_idx;
@@ -1264,16 +1265,16 @@ int mt7925_mcu_uni_bss_ps(struct mt792x_dev *dev, struct ieee80211_vif *vif) }__packed ps; }__packed ps_req = { .hdr = { - .bss_idx = mvif->bss_conf.mt76.idx, + .bss_idx = mconf->mt76.idx, }, .ps = { .tag =cpu_to_le16 (UNI_BSS_INFO_PS ), .len =cpu_to_le16 (sizeof (struct ps_tlv )), - .ps_state = vif->cfg.ps ?2 :0 , + .ps_state = link_conf->vif->cfg.ps ?2 :0 , }, }; -if (vif->type !=NL80211_IFTYPE_STATION ) +if (link_conf->vif->type !=NL80211_IFTYPE_STATION )return -EOPNOTSUPP ; return mt76_mcu_send_msg(&dev->mt76, MCU_UNI_CMD(BSS_INFO_UPDATE),
drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h +2 -1
@@ -242,7 +242,8 @@ int mt7925_mcu_uni_rx_ba(struct mt792x_dev *dev, bool enable);void mt7925_scan_work (struct work_struct *work);void mt7925_roc_work (struct work_struct *work); -int mt7925_mcu_uni_bss_ps (struct mt792x_dev *dev,struct ieee80211_vif *vif); +int mt7925_mcu_uni_bss_ps (struct mt792x_dev *dev, +struct ieee80211_bss_conf *link_conf);void mt7925_coredump_work (struct work_struct *work);int mt7925_get_txpwr_info (struct mt792x_dev *dev,u8 band_idx,struct mt7925_txpwr *txpwr);
Signature · 1 line
2.34.1
PATCH 22/47 wifi: mt76: mt7925: add mt7925_mcu_bss_rlm_tlv to constitue the RLM TLV
In reply to [email protected]From: Sean Wang <[email protected]>
add mt7925_mcu_bss_rlm_tlv to maintain consistency with the other TLVs that constitute the command for creating the per-link BSS.
--- .../net/wireless/mediatek/mt76/mt7925/mcu.c | 64 +++++++++++++++++-- .../net/wireless/mediatek/mt76/mt7925/mcu.h | 16 +++++ 2 files changed, 74 insertions(+), 6 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +58 -6
@@ -1921,6 +1921,59 @@ mt7925_mcu_uni_add_beacon_offload(struct mt792x_dev *dev, &req, sizeof(req), true); } +static +void mt7925_mcu_bss_rlm_tlv (struct sk_buff *skb,struct mt76_phy *phy, +struct ieee80211_chanctx_conf *ctx) +{ +struct cfg80211_chan_def *chandef = ctx ? &ctx->def : &phy->chandef; +int freq1 = chandef->center_freq1, freq2 = chandef->center_freq2; +enum nl80211_band band = chandef->chan->band; +struct bss_rlm_tlv *req; +struct tlv *tlv; + + tlv =mt76_connac_mcu_add_tlv (skb,UNI_BSS_INFO_RLM ,sizeof (*req)); + req = (struct bss_rlm_tlv *)tlv; + req->control_channel = chandef->chan->hw_value, + req->center_chan =ieee80211_frequency_to_channel (freq1), + req->center_chan2 =ieee80211_frequency_to_channel (freq2), + req->tx_streams =hweight8 (phy->antenna_mask), + req->ht_op_info =4 ,/* set HT 40M allowed */ + req->rx_streams =hweight8 (phy->antenna_mask), + req->band = band; + +switch (chandef->width) { +case NL80211_CHAN_WIDTH_40 : + req->bw =CMD_CBW_40MHZ ; +break ; +case NL80211_CHAN_WIDTH_80 : + req->bw =CMD_CBW_80MHZ ; +break ; +case NL80211_CHAN_WIDTH_80P80 : + req->bw =CMD_CBW_8080MHZ ; +break ; +case NL80211_CHAN_WIDTH_160 : + req->bw =CMD_CBW_160MHZ ; +break ; +case NL80211_CHAN_WIDTH_5 : + req->bw =CMD_CBW_5MHZ ; +break ; +case NL80211_CHAN_WIDTH_10 : + req->bw =CMD_CBW_10MHZ ; +break ; +case NL80211_CHAN_WIDTH_20_NOHT : +case NL80211_CHAN_WIDTH_20 : +default : + req->bw =CMD_CBW_20MHZ ; + req->ht_op_info =0 ; +break ; + } + +if (req->control_channel < req->center_chan) + req->sco =1 ;/* SCA */ +else if (req->control_channel > req->center_chan) + req->sco =3 ;/* SCB */ +} +int mt7925_mcu_set_chctx (struct mt76_phy *phy,struct mt76_vif *mvif,struct ieee80211_chanctx_conf *ctx) {
@@ -2326,9 +2379,10 @@ int mt7925_mcu_add_bss_info(struct mt792x_phy *phy, int enable) {struct mt792x_vif *mvif = (struct mt792x_vif *)link_conf->vif->drv_priv; +struct mt792x_bss_conf *mconf =mt792x_vif_to_link (mvif, + link_conf->link_id);struct mt792x_dev *dev = phy->dev;struct sk_buff *skb; -int err; skb =__mt7925_mcu_alloc_bss_req (&dev->mt76, &mvif->bss_conf.mt76,MT7925_BSS_UPDATE_MAX_SIZE );
@@ -2350,12 +2404,10 @@ int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,mt7925_mcu_bss_color_tlv (skb, link_conf, enable); } - err =mt76_mcu_skb_send_msg (&dev->mt76, skb, -MCU_UNI_CMD (BSS_INFO_UPDATE ), true); -if (err <0 ) -return err; +mt7925_mcu_bss_rlm_tlv (skb, phy->mt76, mconf->mt76.ctx); -return mt7925_mcu_set_chctx (phy->mt76, &mvif->bss_conf.mt76, ctx); +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)
drivers/net/wireless/mediatek/mt76/mt7925/mcu.h +16 -0
@@ -456,6 +456,21 @@ struct bss_ifs_time_tlv {__le16 eifs_cck_time; } __packed; +struct bss_rlm_tlv { +__le16 tag; +__le16 len; +u8 control_channel; +u8 center_chan; +u8 center_chan2; +u8 bw; +u8 tx_streams; +u8 rx_streams; +u8 ht_op_info; +u8 sco; +u8 band; +u8 pad[3 ]; +} __packed; +#define MT7925_STA_UPDATE_MAX_SIZE (sizeof(struct sta_req_hdr) + \ sizeof(struct sta_rec_basic) + \ sizeof(struct sta_rec_bf) + \
@@ -484,6 +499,7 @@ struct bss_ifs_time_tlv {sizeof (struct bss_info_uni_he ) + \sizeof (struct bss_info_uni_bss_color ) + \sizeof (struct bss_ifs_time_tlv ) + \ +sizeof (struct bss_rlm_tlv ) + \ sizeof(struct tlv)) #define MT_CONNAC3_SKU_POWER_LIMIT 449
Signature · 1 line
2.34.1
PATCH 23/47 wifi: mt76: mt7925: mt7925_mcu_set_chctx rely on mt7925_mcu_bss_rlm_tlv
In reply to [email protected]From: Sean Wang <[email protected]>
make mt7925_mcu_set_chctx rely on mt7925_mcu_bss_rlm_tlv to get rid of the redundant code.
--- .../net/wireless/mediatek/mt76/mt7925/mcu.c | 95 ++++--------------- 1 file changed, 16 insertions(+), 79 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +16 -79
@@ -1974,85 +1974,6 @@ void mt7925_mcu_bss_rlm_tlv(struct sk_buff *skb, struct mt76_phy *phy, req->sco =3 ;/* SCB */ } -int mt7925_mcu_set_chctx (struct mt76_phy *phy,struct mt76_vif *mvif, -struct ieee80211_chanctx_conf *ctx) -{ -struct cfg80211_chan_def *chandef = ctx ? &ctx->def : &phy->chandef; -int freq1 = chandef->center_freq1, freq2 = chandef->center_freq2; -enum nl80211_band band = chandef->chan->band; -struct mt76_dev *mdev = phy->dev; -struct { -struct { -u8 bss_idx; -u8 pad[3 ]; - } __packed hdr; -struct rlm_tlv { -__le16 tag; -__le16 len; -u8 control_channel; -u8 center_chan; -u8 center_chan2; -u8 bw; -u8 tx_streams; -u8 rx_streams; -u8 ht_op_info; -u8 sco; -u8 band; -u8 pad[3 ]; - } __packed rlm; - } __packed rlm_req = { - .hdr = { - .bss_idx = mvif->idx, - }, - .rlm = { - .tag =cpu_to_le16 (UNI_BSS_INFO_RLM ), - .len =cpu_to_le16 (sizeof (struct rlm_tlv )), - .control_channel = chandef->chan->hw_value, - .center_chan =ieee80211_frequency_to_channel (freq1), - .center_chan2 =ieee80211_frequency_to_channel (freq2), - .tx_streams =hweight8 (phy->antenna_mask), - .ht_op_info =4 ,/* set HT 40M allowed */ - .rx_streams =hweight8 (phy->antenna_mask), - .band = band, - }, - }; - -switch (chandef->width) { -case NL80211_CHAN_WIDTH_40 : - rlm_req.rlm.bw =CMD_CBW_40MHZ ; -break ; -case NL80211_CHAN_WIDTH_80 : - rlm_req.rlm.bw =CMD_CBW_80MHZ ; -break ; -case NL80211_CHAN_WIDTH_80P80 : - rlm_req.rlm.bw =CMD_CBW_8080MHZ ; -break ; -case NL80211_CHAN_WIDTH_160 : - rlm_req.rlm.bw =CMD_CBW_160MHZ ; -break ; -case NL80211_CHAN_WIDTH_5 : - rlm_req.rlm.bw =CMD_CBW_5MHZ ; -break ; -case NL80211_CHAN_WIDTH_10 : - rlm_req.rlm.bw =CMD_CBW_10MHZ ; -break ; -case NL80211_CHAN_WIDTH_20_NOHT : -case NL80211_CHAN_WIDTH_20 : -default : - rlm_req.rlm.bw =CMD_CBW_20MHZ ; - rlm_req.rlm.ht_op_info =0 ; -break ; - } - -if (rlm_req.rlm.control_channel < rlm_req.rlm.center_chan) - rlm_req.rlm.sco =1 ;/* SCA */ -else if (rlm_req.rlm.control_channel > rlm_req.rlm.center_chan) - rlm_req.rlm.sco =3 ;/* SCB */ - -return mt76_mcu_send_msg (mdev,MCU_UNI_CMD (BSS_INFO_UPDATE ), &rlm_req, -sizeof (rlm_req), true); -} -static struct sk_buff *__mt7925_mcu_alloc_bss_req (struct mt76_dev *dev,struct mt76_vif *mvif,int len) {
@@ -2070,6 +1991,22 @@ __mt7925_mcu_alloc_bss_req(struct mt76_dev *dev, struct mt76_vif *mvif, int len)return skb; } +int mt7925_mcu_set_chctx (struct mt76_phy *phy,struct mt76_vif *mvif, +struct ieee80211_chanctx_conf *ctx) +{ +struct sk_buff *skb; + + skb =__mt7925_mcu_alloc_bss_req (phy->dev, mvif, +MT7925_BSS_UPDATE_MAX_SIZE ); +if (IS_ERR (skb)) +return PTR_ERR (skb); + +mt7925_mcu_bss_rlm_tlv (skb, phy, ctx); + +return mt76_mcu_skb_send_msg (phy->dev, skb, +MCU_UNI_CMD (BSS_INFO_UPDATE ), true); +} +static u8 mt7925_get_phy_mode_ext (struct mt76_phy *phy,struct ieee80211_vif *vif,enum nl80211_band band,struct ieee80211_sta *sta)
Signature · 1 line
2.34.1
PATCH 24/47 wifi: mt76: mt7925: extend mt7925_mcu_sta_update for per-link STA
In reply to [email protected]From: Sean Wang <[email protected]>
Extend mt7925_mcu_sta_update with the per-link STA configuration.
The patch we created is a prerequisite to enable the MLO function in the driver. It is purely a refactoring patch so the functionality should remain unchanged.
--- .../wireless/mediatek/mt76/mt76_connac_mcu.h | 5 +- .../net/wireless/mediatek/mt76/mt7925/main.c | 6 +-- .../net/wireless/mediatek/mt76/mt7925/mcu.c | 53 +++++++++++-------- .../wireless/mediatek/mt76/mt7925/mt7925.h | 3 +- drivers/net/wireless/mediatek/mt76/mt792x.h | 16 ++++++ 5 files changed, 57 insertions(+), 26 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +4 -1
@@ -1726,7 +1726,10 @@ enum mt76_sta_info_state { };struct mt76_sta_cmd_info { -struct ieee80211_sta *sta; +union { +struct ieee80211_sta *sta; +struct ieee80211_link_sta *link_sta; + };struct mt76_wcid *wcid;struct ieee80211_vif *vif;
drivers/net/wireless/mediatek/mt76/mt7925/main.c +3 -3
@@ -740,7 +740,7 @@ int mt7925_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,mt7925_mcu_add_bss_info (&dev->phy, mvif->bss_conf.mt76.ctx, link_conf, sta, false); - ret =mt7925_mcu_sta_update (dev, sta, vif, true, + ret =mt7925_mcu_sta_update (dev, &sta->deflink, vif, true,MT76_STA_INFO_STATE_NONE );if (ret)return ret;
@@ -773,7 +773,7 @@ void mt7925_mac_sta_assoc(struct mt76_dev *mdev, struct ieee80211_vif *vif, MT_WTBL_UPDATE_ADM_COUNT_CLEAR);memset (msta->deflink.airtime_ac,0 ,sizeof (msta->deflink.airtime_ac)); -mt7925_mcu_sta_update (dev, sta, vif, true,MT76_STA_INFO_STATE_ASSOC ); +mt7925_mcu_sta_update (dev, &sta->deflink, vif, true,MT76_STA_INFO_STATE_ASSOC );mt792x_mutex_release (dev); }
@@ -789,7 +789,7 @@ void mt7925_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,mt76_connac_free_pending_tx_skbs (&dev->pm, &msta->deflink.wcid);mt76_connac_pm_wake (&dev->mphy, &dev->pm); -mt7925_mcu_sta_update (dev, sta, vif, false,MT76_STA_INFO_STATE_NONE ); +mt7925_mcu_sta_update (dev, &sta->deflink, vif, false,MT76_STA_INFO_STATE_NONE );mt7925_mac_wtbl_update (dev, msta->deflink.wcid.idx,MT_WTBL_UPDATE_ADM_COUNT_CLEAR );
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +32 -21
81 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h +2 -1
@@ -195,7 +195,8 @@ int mt7925_run_firmware(struct mt792x_dev *dev);int mt7925_mcu_set_bss_pm (struct mt792x_dev *dev,struct ieee80211_bss_conf *link_conf,bool enable); -int mt7925_mcu_sta_update (struct mt792x_dev *dev,struct ieee80211_sta *sta, +int mt7925_mcu_sta_update (struct mt792x_dev *dev, +struct ieee80211_link_sta *link_sta,struct ieee80211_vif *vif,bool enable,enum mt76_sta_info_state state);int mt7925_mcu_set_chan_info (struct mt792x_phy *phy,u16 tag);
drivers/net/wireless/mediatek/mt76/mt792x.h +16 -0
@@ -94,6 +94,7 @@ struct mt792x_link_sta {struct mt792x_sta {struct mt792x_link_sta deflink;/* must be first */ +struct mt792x_link_sta __rcu *link[IEEE80211_MLD_MAX_NUM_LINKS ];struct mt792x_vif *vif; };
@@ -236,6 +237,21 @@ mt792x_vif_to_link(struct mt792x_vif *mvif, u8 link_id) lockdep_is_held(&mvif->phy->dev->mt76.mutex)); } +static inline struct mt792x_link_sta * +mt792x_sta_to_link (struct mt792x_sta *msta,u8 link_id) +{ +struct ieee80211_vif *vif; + + vif = container_of((void *)msta->vif, struct ieee80211_vif, drv_priv); + +if (!ieee80211_vif_is_mld (vif) || + link_id >=IEEE80211_LINK_UNSPECIFIED ) +return &msta->deflink; + +return rcu_dereference_protected (msta->link[link_id], +lockdep_is_held (&msta->vif->phy->dev->mt76.mutex)); +} +static inline struct mt792x_bss_conf *mt792x_link_conf_to_mconf (struct ieee80211_bss_conf *link_conf) {
Signature · 1 line
2.34.1
PATCH 25/47 wifi: mt76: mt7925: extend mt7925_mcu_sta_state_v2_tlv for per-link STA
In reply to [email protected]From: Sean Wang <[email protected]>
Extend mt7925_mcu_sta_state_v2_tlv with the per-link STA configuration.
The patch we created is a prerequisite to enable the MLO function in the driver. It is purely a refactoring patch so the functionality should remain unchanged.
--- drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +5 -5
@@ -1540,7 +1540,7 @@ mt7925_mcu_sta_phy_tlv(struct sk_buff *skb,static void mt7925_mcu_sta_state_v2_tlv (struct mt76_phy *mphy,struct sk_buff *skb, -struct ieee80211_sta *sta, +struct ieee80211_link_sta *link_sta,struct ieee80211_vif *vif,u8 rcpi,u8 sta_state) {
@@ -1560,9 +1560,9 @@ mt7925_mcu_sta_state_v2_tlv(struct mt76_phy *mphy, struct sk_buff *skb, state = (struct sta_rec_state_v2 *)tlv; state->state = sta_state; -if (sta->deflink.vht_cap.vht_supported) { - state->vht_opmode = sta->deflink.bandwidth; - state->vht_opmode |= sta->deflink.rx_nss << +if (link_sta->vht_cap.vht_supported) { + state->vht_opmode = link_sta->bandwidth; + state->vht_opmode |= link_sta->rx_nss <<IEEE80211_OPMODE_NOTIF_RX_NSS_SHIFT ; } }
@@ -1643,7 +1643,7 @@ mt7925_mcu_sta_cmd(struct mt76_phy *phy,mt7925_mcu_sta_eht_tlv (skb, info->link_sta->sta);mt7925_mcu_sta_rate_ctrl_tlv (skb, info->vif, info->link_sta->sta); -mt7925_mcu_sta_state_v2_tlv (phy, skb, info->link_sta->sta, +mt7925_mcu_sta_state_v2_tlv (phy, skb, info->link_sta, info->vif, info->rcpi, info->state);mt7925_mcu_sta_mld_tlv (skb, info->vif, info->link_sta->sta);
Signature · 1 line
2.34.1
PATCH 26/47 wifi: mt76: mt7925: extend mt7925_mcu_sta_rate_ctrl_tlv with per-link STA
In reply to [email protected]From: Sean Wang <[email protected]>
Extend mt7925_mcu_sta_rate_ctrl_tlv with the per-link STA configuration.
The patch we created is a prerequisite to enable the MLO function in the driver. It is purely a refactoring patch so the functionality should remain unchanged.
--- drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +6 -5
@@ -1569,7 +1569,8 @@ mt7925_mcu_sta_state_v2_tlv(struct mt76_phy *mphy, struct sk_buff *skb,static void mt7925_mcu_sta_rate_ctrl_tlv (struct sk_buff *skb, -struct ieee80211_vif *vif,struct ieee80211_sta *sta) +struct ieee80211_vif *vif, +struct ieee80211_link_sta *link_sta) {struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;struct cfg80211_chan_def *chandef = &mvif->bss_conf.mt76.ctx->def;
@@ -1581,7 +1582,7 @@ mt7925_mcu_sta_rate_ctrl_tlv(struct sk_buff *skb, tlv =mt76_connac_mcu_add_tlv (skb,STA_REC_RA ,sizeof (*ra_info)); ra_info = (struct sta_rec_ra_info *)tlv; - supp_rates = sta->deflink.supp_rates[band]; + supp_rates = link_sta->supp_rates[band];if (band ==NL80211_BAND_2GHZ ) supp_rates =FIELD_PREP (RA_LEGACY_OFDM , supp_rates >>4 ) |FIELD_PREP (RA_LEGACY_CCK , supp_rates &0xf );
@@ -1590,9 +1591,9 @@ mt7925_mcu_sta_rate_ctrl_tlv(struct sk_buff *skb, ra_info->legacy =cpu_to_le16 (supp_rates); -if (sta->deflink.ht_cap.ht_supported) +if (link_sta->ht_cap.ht_supported)memcpy (ra_info->rx_mcs_bitmask, - sta->deflink.ht_cap.mcs.rx_mask, + link_sta->ht_cap.mcs.rx_mask,HT_MCS_MASK_NUM ); }
@@ -1642,7 +1643,7 @@ mt7925_mcu_sta_cmd(struct mt76_phy *phy,mt7925_mcu_sta_he_6g_tlv (skb, info->link_sta->sta);mt7925_mcu_sta_eht_tlv (skb, info->link_sta->sta);mt7925_mcu_sta_rate_ctrl_tlv (skb, info->vif, - info->link_sta->sta); + info->link_sta);mt7925_mcu_sta_state_v2_tlv (phy, skb, info->link_sta, info->vif, info->rcpi, info->state);
Signature · 1 line
2.34.1
PATCH 27/47 wifi: mt76: mt7925: extend mt7925_mcu_sta_eht_tlv for per-link STA
In reply to [email protected]From: Sean Wang <[email protected]>
Extend mt7925_mcu_sta_eht_tlv with the per-link STA configuration.
The patch we created is a prerequisite to enable the MLO function in the driver. It is purely a refactoring patch so the functionality should remain unchanged.
--- drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +6 -6
@@ -1404,18 +1404,18 @@ mt7925_mcu_sta_he_6g_tlv(struct sk_buff *skb, struct ieee80211_sta *sta) }static void -mt7925_mcu_sta_eht_tlv (struct sk_buff *skb,struct ieee80211_sta *sta) +mt7925_mcu_sta_eht_tlv (struct sk_buff *skb,struct ieee80211_link_sta *link_sta) {struct ieee80211_eht_mcs_nss_supp *mcs_map;struct ieee80211_eht_cap_elem_fixed *elem;struct sta_rec_eht *eht;struct tlv *tlv; -if (!sta->deflink.eht_cap.has_eht) +if (!link_sta->eht_cap.has_eht)return ; - mcs_map = &sta->deflink.eht_cap.eht_mcs_nss_supp; - elem = &sta->deflink.eht_cap.eht_cap_elem; + mcs_map = &link_sta->eht_cap.eht_mcs_nss_supp; + elem = &link_sta->eht_cap.eht_cap_elem; tlv =mt76_connac_mcu_add_tlv (skb,STA_REC_EHT ,sizeof (*eht));
@@ -1425,7 +1425,7 @@ mt7925_mcu_sta_eht_tlv(struct sk_buff *skb, struct ieee80211_sta *sta) eht->phy_cap =cpu_to_le64 (*(u64 *)elem->phy_cap_info); eht->phy_cap_ext =cpu_to_le64 (elem->phy_cap_info[8 ]); -if (sta->deflink.bandwidth ==IEEE80211_STA_RX_BW_20 ) +if (link_sta->bandwidth ==IEEE80211_STA_RX_BW_20 )memcpy (eht->mcs_map_bw20, &mcs_map->only_20mhz,sizeof (eht->mcs_map_bw20));memcpy (eht->mcs_map_bw80, &mcs_map->bw._80,sizeof (eht->mcs_map_bw80));memcpy (eht->mcs_map_bw160, &mcs_map->bw._160,sizeof (eht->mcs_map_bw160));
@@ -1641,7 +1641,7 @@ mt7925_mcu_sta_cmd(struct mt76_phy *phy,mt7925_mcu_sta_amsdu_tlv (skb, info->vif, info->link_sta->sta);mt7925_mcu_sta_he_tlv (skb, info->link_sta->sta);mt7925_mcu_sta_he_6g_tlv (skb, info->link_sta->sta); -mt7925_mcu_sta_eht_tlv (skb, info->link_sta->sta); +mt7925_mcu_sta_eht_tlv (skb, info->link_sta);mt7925_mcu_sta_rate_ctrl_tlv (skb, info->vif, info->link_sta); mt7925_mcu_sta_state_v2_tlv(phy, skb, info->link_sta,
Signature · 1 line
2.34.1
PATCH 28/47 wifi: mt76: mt7925: extend mt7925_mcu_sta_he_6g_tlv for per-link STA
In reply to [email protected]From: Sean Wang <[email protected]>
Extend mt7925_mcu_sta_he_6g_tlv with the per-link STA configuration.
The patch we created is a prerequisite to enable the MLO function in the driver. It is purely a refactoring patch so the functionality should remain unchanged.
--- drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +5 -4
@@ -1389,18 +1389,19 @@ mt7925_mcu_sta_he_tlv(struct sk_buff *skb, struct ieee80211_sta *sta) }static void -mt7925_mcu_sta_he_6g_tlv (struct sk_buff *skb,struct ieee80211_sta *sta) +mt7925_mcu_sta_he_6g_tlv (struct sk_buff *skb, +struct ieee80211_link_sta *link_sta) {struct sta_rec_he_6g_capa *he_6g;struct tlv *tlv; -if (!sta->deflink.he_6ghz_capa.capa) +if (!link_sta->he_6ghz_capa.capa)return ; tlv =mt76_connac_mcu_add_tlv (skb,STA_REC_HE_6G ,sizeof (*he_6g)); he_6g = (struct sta_rec_he_6g_capa *)tlv; - he_6g->capa = sta->deflink.he_6ghz_capa.capa; + he_6g->capa = link_sta->he_6ghz_capa.capa; } static void
@@ -1640,7 +1641,7 @@ mt7925_mcu_sta_cmd(struct mt76_phy *phy,mt76_connac_mcu_sta_uapsd (skb, info->vif, info->link_sta->sta);mt7925_mcu_sta_amsdu_tlv (skb, info->vif, info->link_sta->sta);mt7925_mcu_sta_he_tlv (skb, info->link_sta->sta); -mt7925_mcu_sta_he_6g_tlv (skb, info->link_sta->sta); +mt7925_mcu_sta_he_6g_tlv (skb, info->link_sta);mt7925_mcu_sta_eht_tlv (skb, info->link_sta);mt7925_mcu_sta_rate_ctrl_tlv (skb, info->vif, info->link_sta);
Signature · 1 line
2.34.1
PATCH 29/47 wifi: mt76: mt7925: extend mt7925_mcu_sta_he_tlv for per-link STA
In reply to [email protected]From: Sean Wang <[email protected]>
Extend mt7925_mcu_sta_he_tlv with the per-link STA configuration.
The patch we created is a prerequisite to enable the MLO function in the driver. It is purely a refactoring patch so the functionality should remain unchanged.
--- drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +4 -4
@@ -1380,12 +1380,12 @@ mt7925_mcu_set_bss_pm(struct mt792x_dev *dev, }static void -mt7925_mcu_sta_he_tlv (struct sk_buff *skb,struct ieee80211_sta *sta) +mt7925_mcu_sta_he_tlv (struct sk_buff *skb,struct ieee80211_link_sta *link_sta) { -if (!sta->deflink.he_cap.has_he) +if (!link_sta->he_cap.has_he)return ; -mt76_connac_mcu_sta_he_tlv_v2 (skb, sta); +mt76_connac_mcu_sta_he_tlv_v2 (skb, link_sta->sta); } static void
@@ -1640,7 +1640,7 @@ mt7925_mcu_sta_cmd(struct mt76_phy *phy,mt7925_mcu_sta_vht_tlv (skb, info->link_sta->sta);mt76_connac_mcu_sta_uapsd (skb, info->vif, info->link_sta->sta);mt7925_mcu_sta_amsdu_tlv (skb, info->vif, info->link_sta->sta); -mt7925_mcu_sta_he_tlv (skb, info->link_sta->sta); +mt7925_mcu_sta_he_tlv (skb, info->link_sta);mt7925_mcu_sta_he_6g_tlv (skb, info->link_sta);mt7925_mcu_sta_eht_tlv (skb, info->link_sta); mt7925_mcu_sta_rate_ctrl_tlv(skb, info->vif,
Signature · 1 line
2.34.1
PATCH 30/47 wifi: mt76: mt7925: extend mt7925_mcu_sta_amsdu_tlv for per-link STA
In reply to [email protected]From: Sean Wang <[email protected]>
Extend mt7925_mcu_sta_amsdu_tlv with the per-link STA configuration.
The patch we created is a prerequisite to enable the MLO function in the driver. It is purely a refactoring patch so the functionality should remain unchanged.
--- drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +10 -6
@@ -1467,9 +1467,11 @@ mt7925_mcu_sta_vht_tlv(struct sk_buff *skb, struct ieee80211_sta *sta)static void mt7925_mcu_sta_amsdu_tlv (struct sk_buff *skb, -struct ieee80211_vif *vif,struct ieee80211_sta *sta) +struct ieee80211_vif *vif, +struct ieee80211_link_sta *link_sta) { -struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv; +struct mt792x_sta *msta = (struct mt792x_sta *)link_sta->sta->drv_priv; +struct mt792x_link_sta *mlink;struct sta_rec_amsdu *amsdu;struct tlv *tlv;
@@ -1477,16 +1479,18 @@ mt7925_mcu_sta_amsdu_tlv(struct sk_buff *skb, vif->type != NL80211_IFTYPE_AP)return ; -if (!sta->deflink.agg.max_amsdu_len) +if (!link_sta->agg.max_amsdu_len)return ; tlv =mt76_connac_mcu_add_tlv (skb,STA_REC_HW_AMSDU ,sizeof (*amsdu)); amsdu = (struct sta_rec_amsdu *)tlv; amsdu->max_amsdu_num =8 ; amsdu->amsdu_en = true; - msta->deflink.wcid.amsdu = true; -switch (sta->deflink.agg.max_amsdu_len) { + mlink =mt792x_sta_to_link (msta, link_sta->link_id); + mlink->wcid.amsdu = true; + +switch (link_sta->agg.max_amsdu_len) {case IEEE80211_MAX_MPDU_LEN_VHT_11454 : amsdu->max_mpdu_size =IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454 ;
@@ -1639,7 +1643,7 @@ mt7925_mcu_sta_cmd(struct mt76_phy *phy,mt7925_mcu_sta_ht_tlv (skb, info->link_sta->sta);mt7925_mcu_sta_vht_tlv (skb, info->link_sta->sta);mt76_connac_mcu_sta_uapsd (skb, info->vif, info->link_sta->sta); -mt7925_mcu_sta_amsdu_tlv (skb, info->vif, info->link_sta->sta); +mt7925_mcu_sta_amsdu_tlv (skb, info->vif, info->link_sta);mt7925_mcu_sta_he_tlv (skb, info->link_sta);mt7925_mcu_sta_he_6g_tlv (skb, info->link_sta);mt7925_mcu_sta_eht_tlv (skb, info->link_sta);
Signature · 1 line
2.34.1
PATCH 31/47 wifi: mt76: mt7925: extend mt7925_mcu_sta_vht_tlv for per-link STA
In reply to [email protected]From: Sean Wang <[email protected]>
Extend mt7925_mcu_sta_vht_tlv with the per-link STA configuration.
The patch we created is a prerequisite to enable the MLO function in the driver. It is purely a refactoring patch so the functionality should remain unchanged.
--- drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +6 -6
@@ -1448,21 +1448,21 @@ mt7925_mcu_sta_ht_tlv(struct sk_buff *skb, struct ieee80211_sta *sta) }static void -mt7925_mcu_sta_vht_tlv (struct sk_buff *skb,struct ieee80211_sta *sta) +mt7925_mcu_sta_vht_tlv (struct sk_buff *skb,struct ieee80211_link_sta *link_sta) {struct sta_rec_vht *vht;struct tlv *tlv;/* For 6G band, this tlv is necessary to let hw work normally */ -if (!sta->deflink.he_6ghz_capa.capa && !sta->deflink.vht_cap.vht_supported) +if (!link_sta->he_6ghz_capa.capa && !link_sta->vht_cap.vht_supported)return ; tlv =mt76_connac_mcu_add_tlv (skb,STA_REC_VHT ,sizeof (*vht)); vht = (struct sta_rec_vht *)tlv; - vht->vht_cap =cpu_to_le32 (sta->deflink.vht_cap.cap); - vht->vht_rx_mcs_map = sta->deflink.vht_cap.vht_mcs.rx_mcs_map; - vht->vht_tx_mcs_map = sta->deflink.vht_cap.vht_mcs.tx_mcs_map; + vht->vht_cap =cpu_to_le32 (link_sta->vht_cap.cap); + vht->vht_rx_mcs_map = link_sta->vht_cap.vht_mcs.rx_mcs_map; + vht->vht_tx_mcs_map = link_sta->vht_cap.vht_mcs.tx_mcs_map; } static void
@@ -1641,7 +1641,7 @@ mt7925_mcu_sta_cmd(struct mt76_phy *phy,if (info->link_sta && info->enable) {mt7925_mcu_sta_phy_tlv (skb, info->vif, info->link_sta->sta);mt7925_mcu_sta_ht_tlv (skb, info->link_sta->sta); -mt7925_mcu_sta_vht_tlv (skb, info->link_sta->sta); +mt7925_mcu_sta_vht_tlv (skb, info->link_sta);mt76_connac_mcu_sta_uapsd (skb, info->vif, info->link_sta->sta);mt7925_mcu_sta_amsdu_tlv (skb, info->vif, info->link_sta);mt7925_mcu_sta_he_tlv (skb, info->link_sta);
Signature · 1 line
2.34.1
PATCH 32/47 wifi: mt76: mt7925: extend mt7925_mcu_sta_ht_tlv for per-link STA
In reply to [email protected]From: Sean Wang <[email protected]>
Extend mt7925_mcu_sta_ht_tlv with the per-link STA configuration.
The patch we created is a prerequisite to enable the MLO function in the driver. It is purely a refactoring patch so the functionality should remain unchanged.
--- drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +4 -4
@@ -1433,18 +1433,18 @@ mt7925_mcu_sta_eht_tlv(struct sk_buff *skb, struct ieee80211_link_sta *link_sta) }static void -mt7925_mcu_sta_ht_tlv (struct sk_buff *skb,struct ieee80211_sta *sta) +mt7925_mcu_sta_ht_tlv (struct sk_buff *skb,struct ieee80211_link_sta *link_sta) {struct sta_rec_ht *ht;struct tlv *tlv; -if (!sta->deflink.ht_cap.ht_supported) +if (!link_sta->ht_cap.ht_supported)return ; tlv =mt76_connac_mcu_add_tlv (skb,STA_REC_HT ,sizeof (*ht)); ht = (struct sta_rec_ht *)tlv; - ht->ht_cap =cpu_to_le16 (sta->deflink.ht_cap.cap); + ht->ht_cap =cpu_to_le16 (link_sta->ht_cap.cap); } static void
@@ -1640,7 +1640,7 @@ mt7925_mcu_sta_cmd(struct mt76_phy *phy, info->enable, info->newly);if (info->link_sta && info->enable) {mt7925_mcu_sta_phy_tlv (skb, info->vif, info->link_sta->sta); -mt7925_mcu_sta_ht_tlv (skb, info->link_sta->sta); +mt7925_mcu_sta_ht_tlv (skb, info->link_sta);mt7925_mcu_sta_vht_tlv (skb, info->link_sta);mt76_connac_mcu_sta_uapsd (skb, info->vif, info->link_sta->sta);mt7925_mcu_sta_amsdu_tlv (skb, info->vif, info->link_sta);
Signature · 1 line
2.34.1
PATCH 33/47 wifi: mt76: mt7925: extend mt7925_mcu_sta_phy_tlv for per-link STA
In reply to [email protected]From: Sean Wang <[email protected]>
Extend mt7925_mcu_sta_phy_tlv with per-link STA configuration.
The patch we created is a prerequisite to enable the MLO function in the driver. It is purely a refactoring patch so the functionality should remain unchanged.
--- .../net/wireless/mediatek/mt76/mt7925/mcu.c | 35 ++++++++++++------- 1 file changed, 22 insertions(+), 13 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +22 -13
@@ -1507,34 +1507,43 @@ mt7925_mcu_sta_amsdu_tlv(struct sk_buff *skb,static void mt7925_mcu_sta_phy_tlv (struct sk_buff *skb, -struct ieee80211_vif *vif,struct ieee80211_sta *sta) +struct ieee80211_vif *vif, +struct ieee80211_link_sta *link_sta) {struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; -struct cfg80211_chan_def *chandef = &mvif->bss_conf.mt76.ctx->def; +struct ieee80211_bss_conf *link_conf; +struct cfg80211_chan_def *chandef; +struct mt792x_bss_conf *mconf;struct sta_rec_phy *phy;struct tlv *tlv;u8 af =0 , mm =0 ; + link_conf =mt792x_vif_to_bss_conf (vif, link_sta->link_id); + mconf =mt792x_vif_to_link (mvif, link_sta->link_id); + chandef = &mconf->mt76.ctx->def; + tlv =mt76_connac_mcu_add_tlv (skb,STA_REC_PHY ,sizeof (*phy)); phy = (struct sta_rec_phy *)tlv; - phy->phy_type =mt76_connac_get_phy_mode_v2 (mvif->phy->mt76, vif, chandef->chan->band, sta); - phy->basic_rate =cpu_to_le16 ((u16 )vif->bss_conf.basic_rates); -if (sta->deflink.ht_cap.ht_supported) { - af = sta->deflink.ht_cap.ampdu_factor; - mm = sta->deflink.ht_cap.ampdu_density; + phy->phy_type =mt76_connac_get_phy_mode_v2 (mvif->phy->mt76, vif, + chandef->chan->band, + link_sta->sta); + phy->basic_rate =cpu_to_le16 ((u16 )link_conf->basic_rates); +if (link_sta->ht_cap.ht_supported) { + af = link_sta->ht_cap.ampdu_factor; + mm = link_sta->ht_cap.ampdu_density; } -if (sta->deflink.vht_cap.vht_supported) { +if (link_sta->vht_cap.vht_supported) {u8 vht_af =FIELD_GET (IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK , - sta->deflink.vht_cap.cap); + link_sta->vht_cap.cap); af =max_t (u8, af, vht_af); } -if (sta->deflink.he_6ghz_capa.capa) { - af =le16_get_bits (sta->deflink.he_6ghz_capa.capa, +if (link_sta->he_6ghz_capa.capa) { + af =le16_get_bits (link_sta->he_6ghz_capa.capa,IEEE80211_HE_6GHZ_CAP_MAX_AMPDU_LEN_EXP ); - mm =le16_get_bits (sta->deflink.he_6ghz_capa.capa, + mm =le16_get_bits (link_sta->he_6ghz_capa.capa,IEEE80211_HE_6GHZ_CAP_MIN_MPDU_START ); }
@@ -1639,7 +1648,7 @@ mt7925_mcu_sta_cmd(struct mt76_phy *phy, info->link_sta->sta, info->enable, info->newly);if (info->link_sta && info->enable) { -mt7925_mcu_sta_phy_tlv (skb, info->vif, info->link_sta->sta); +mt7925_mcu_sta_phy_tlv (skb, info->vif, info->link_sta);mt7925_mcu_sta_ht_tlv (skb, info->link_sta);mt7925_mcu_sta_vht_tlv (skb, info->link_sta);mt76_connac_mcu_sta_uapsd (skb, info->vif, info->link_sta->sta);
Signature · 1 line
2.34.1
PATCH 34/47 wifi: mt76: mt7925: extend mt7925_get_phy_mode_ext for per-link STA
In reply to [email protected]From: Sean Wang <[email protected]>
Extend mt7925_get_phy_mode_ext with the per-link STA configuration.
The patch we created is a prerequisite to enable the MLO function in the driver. It is purely a refactoring patch so the functionality should remain unchanged.
--- drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +7 -5
@@ -2035,16 +2035,17 @@ int mt7925_mcu_set_chctx(struct mt76_phy *phy, struct mt76_vif *mvif,static u8 mt7925_get_phy_mode_ext (struct mt76_phy *phy,struct ieee80211_vif *vif, -enum nl80211_band band,struct ieee80211_sta *sta) +enum nl80211_band band, +struct ieee80211_link_sta *link_sta) {struct ieee80211_he_6ghz_capa *he_6ghz_capa;const struct ieee80211_sta_eht_cap *eht_cap;__le16 capa =0 ;u8 mode =0 ; -if (sta) { - he_6ghz_capa = &sta->deflink.he_6ghz_capa; - eht_cap = &sta->deflink.eht_cap; +if (link_sta) { + he_6ghz_capa = &link_sta->he_6ghz_capa; + eht_cap = &link_sta->eht_cap; }else {struct ieee80211_supported_band *sband;
@@ -2104,7 +2105,8 @@ mt7925_mcu_bss_basic_tlv(struct sk_buff *skb, mconf->mt76.omac_idx; basic_req->hw_bss_idx = idx; - basic_req->phymode_ext =mt7925_get_phy_mode_ext (phy, vif, band, sta); + basic_req->phymode_ext =mt7925_get_phy_mode_ext (phy, vif, band, + &sta->deflink);if (band ==NL80211_BAND_2GHZ ) basic_req->nonht_basic_phy =cpu_to_le16 (PHY_TYPE_ERP_INDEX );
Signature · 1 line
2.34.1
PATCH 35/47 wifi: mt76: mt7925: extend mt7925_get_phy_mode for per-link STA
In reply to [email protected]From: Sean Wang <[email protected]>
Extend mt7925_get_phy_mode with the per-link STA configuration.
The patch we created is a prerequisite to enable the MLO function in the driver. It is purely a refactoring patch so the functionality should remain unchanged.
--- drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c | 11 ++++++----- drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h | 3 ++- drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 2 +- drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 3 ++- 4 files changed, 11 insertions(+), 8 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +6 -5
@@ -1300,7 +1300,8 @@ int mt76_connac_mcu_sta_ba(struct mt76_dev *dev, struct mt76_vif *mvif,EXPORT_SYMBOL_GPL (mt76_connac_mcu_sta_ba);u8 mt76_connac_get_phy_mode (struct mt76_phy *phy,struct ieee80211_vif *vif, -enum nl80211_band band,struct ieee80211_sta *sta) +enum nl80211_band band, +struct ieee80211_link_sta *link_sta) {struct mt76_dev *dev = phy->dev;const struct ieee80211_sta_he_cap *he_cap;
@@ -1311,10 +1312,10 @@ u8 mt76_connac_get_phy_mode(struct mt76_phy *phy, struct ieee80211_vif *vif,if (is_connac_v1 (dev))return 0x38 ; -if (sta) { - ht_cap = &sta->deflink.ht_cap; - vht_cap = &sta->deflink.vht_cap; - he_cap = &sta->deflink.he_cap; +if (link_sta) { + ht_cap = &link_sta->ht_cap; + vht_cap = &link_sta->vht_cap; + he_cap = &link_sta->he_cap; }else {struct ieee80211_supported_band *sband;
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +2 -1
@@ -1988,7 +1988,8 @@ mt76_connac_get_he_phy_cap(struct mt76_phy *phy, struct ieee80211_vif *vif);const struct ieee80211_sta_eht_cap *mt76_connac_get_eht_phy_cap (struct mt76_phy *phy,struct ieee80211_vif *vif);u8 mt76_connac_get_phy_mode (struct mt76_phy *phy,struct ieee80211_vif *vif, -enum nl80211_band band,struct ieee80211_sta *sta); +enum nl80211_band band, +struct ieee80211_link_sta *sta);u8 mt76_connac_get_phy_mode_ext (struct mt76_phy *phy,struct ieee80211_vif *vif,enum nl80211_band band);
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +1 -1
@@ -1503,7 +1503,7 @@ mt7915_mcu_sta_rate_ctrl_tlv(struct sk_buff *skb, struct mt7915_dev *dev, ra->valid = true; ra->auto_rate = true; - ra->phy_mode =mt76_connac_get_phy_mode (mphy, vif, band, sta); + ra->phy_mode =mt76_connac_get_phy_mode (mphy, vif, band, &sta->deflink); ra->channel = chandef->chan->hw_value; ra->bw = sta->deflink.bandwidth; ra->phy.bw = sta->deflink.bandwidth;
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +2 -1
@@ -2114,7 +2114,8 @@ mt7925_mcu_bss_basic_tlv(struct sk_buff *skb, basic_req->nonht_basic_phy =cpu_to_le16 (PHY_TYPE_OFDM_INDEX );memcpy (basic_req->bssid, link_conf->bssid,ETH_ALEN ); - basic_req->phymode =mt76_connac_get_phy_mode (phy, vif, band, sta); + basic_req->phymode =mt76_connac_get_phy_mode (phy, vif, band, + &sta->deflink); basic_req->bcn_interval =cpu_to_le16 (link_conf->beacon_int); basic_req->dtim_period = link_conf->dtim_period; basic_req->bmc_tx_wlan_idx =cpu_to_le16 (wlan_idx);
Signature · 1 line
2.34.1
PATCH 36/47 wifi: mt76: mt792x: extend mt76_connac_get_phy_mode_v2 for per-link STA
In reply to [email protected]From: Sean Wang <[email protected]>
Extend mt76_connac_get_phy_mode_v2 with the per-link STA configuration.
The patch we created is a prerequisite to enable the MLO function in the driver. It is purely a refactoring patch so the functionality should remain unchanged.
--- .../net/wireless/mediatek/mt76/mt76_connac_mcu.c | 16 +++++++++------- .../net/wireless/mediatek/mt76/mt76_connac_mcu.h | 3 ++- drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +9 -7
@@ -786,7 +786,8 @@ EXPORT_SYMBOL_GPL(mt76_connac_mcu_sta_he_tlv_v2);u8 mt76_connac_get_phy_mode_v2 (struct mt76_phy *mphy,struct ieee80211_vif *vif, -enum nl80211_band band,struct ieee80211_sta *sta) +enum nl80211_band band, +struct ieee80211_link_sta *link_sta) {struct ieee80211_sta_ht_cap *ht_cap;struct ieee80211_sta_vht_cap *vht_cap;
@@ -794,11 +795,11 @@ mt76_connac_get_phy_mode_v2(struct mt76_phy *mphy, struct ieee80211_vif *vif,const struct ieee80211_sta_eht_cap *eht_cap;u8 mode =0 ; -if (sta) { - ht_cap = &sta->deflink.ht_cap; - vht_cap = &sta->deflink.vht_cap; - he_cap = &sta->deflink.he_cap; - eht_cap = &sta->deflink.eht_cap; +if (link_sta) { + ht_cap = &link_sta->ht_cap; + vht_cap = &link_sta->vht_cap; + he_cap = &link_sta->he_cap; + eht_cap = &link_sta->eht_cap; }else {struct ieee80211_supported_band *sband;
@@ -904,7 +905,8 @@ void mt76_connac_mcu_sta_tlv(struct mt76_phy *mphy, struct sk_buff *skb, tlv =mt76_connac_mcu_add_tlv (skb,STA_REC_PHY ,sizeof (*phy)); phy = (struct sta_rec_phy *)tlv; - phy->phy_type =mt76_connac_get_phy_mode_v2 (mphy, vif, band, sta); + phy->phy_type =mt76_connac_get_phy_mode_v2 (mphy, vif, band, + &sta->deflink); phy->basic_rate =cpu_to_le16 ((u16 )vif->bss_conf.basic_rates); phy->rcpi = rcpi; phy->ampdu = FIELD_PREP(IEEE80211_HT_AMPDU_PARM_FACTOR,
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +2 -1
@@ -1894,7 +1894,8 @@ int mt76_connac_mcu_sta_update_hdr_trans(struct mt76_dev *dev, struct mt76_wcid *wcid, int cmd);void mt76_connac_mcu_sta_he_tlv_v2 (struct sk_buff *skb,struct ieee80211_sta *sta);u8 mt76_connac_get_phy_mode_v2 (struct mt76_phy *mphy,struct ieee80211_vif *vif, -enum nl80211_band band,struct ieee80211_sta *sta); +enum nl80211_band band, +struct ieee80211_link_sta *link_sta);int mt76_connac_mcu_wtbl_update_hdr_trans (struct mt76_dev *dev,struct ieee80211_vif *vif,struct ieee80211_sta *sta);
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +1 -1
@@ -1526,7 +1526,7 @@ mt7925_mcu_sta_phy_tlv(struct sk_buff *skb, phy = (struct sta_rec_phy *)tlv; phy->phy_type =mt76_connac_get_phy_mode_v2 (mvif->phy->mt76, vif, chandef->chan->band, - link_sta->sta); + link_sta); phy->basic_rate =cpu_to_le16 ((u16 )link_conf->basic_rates);if (link_sta->ht_cap.ht_supported) { af = link_sta->ht_cap.ampdu_factor;
Signature · 1 line
2.34.1
PATCH 37/47 wifi: mt76: mt762x: extend mt76_connac_mcu_sta_basic_tlv for per-link STA
In reply to [email protected]From: Sean Wang <[email protected]>
Extend mt76_connac_mcu_sta_basic_tlv with the per-link STA configuration.
The patch we created is a prerequisite to enable the MLO function in the driver. It is purely a refactoring patch so the functionality should remain unchanged.
--- drivers/net/wireless/mediatek/mt76/mt7615/mcu.c | 4 ++-- .../wireless/mediatek/mt76/mt76_connac_mcu.c | 17 +++++++++-------- .../wireless/mediatek/mt76/mt76_connac_mcu.h | 4 ++-- drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 2 +- drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 2 +- drivers/net/wireless/mediatek/mt76/mt7996/mcu.c | 2 +- 6 files changed, 16 insertions(+), 15 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c +2 -2
@@ -861,8 +861,8 @@ mt7615_mcu_wtbl_sta_add(struct mt7615_phy *phy, struct ieee80211_vif *vif,else mvif->sta_added = true; } -mt76_connac_mcu_sta_basic_tlv (&dev->mt76, sskb, vif, sta, enable, - new_entry); +mt76_connac_mcu_sta_basic_tlv (&dev->mt76, sskb, vif, &sta->deflink, + enable, new_entry);if (enable && sta)mt76_connac_mcu_sta_tlv (phy->mt76, sskb, sta, vif,0 ,MT76_STA_INFO_STATE_ASSOC );
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +9 -8
@@ -370,7 +370,7 @@ EXPORT_SYMBOL_GPL(mt76_connac_mcu_bss_omac_tlv);void mt76_connac_mcu_sta_basic_tlv (struct mt76_dev *dev,struct sk_buff *skb,struct ieee80211_vif *vif, -struct ieee80211_sta *sta, +struct ieee80211_link_sta *link_sta,bool enable,bool newly) {struct sta_rec_basic *basic;
@@ -390,7 +390,7 @@ void mt76_connac_mcu_sta_basic_tlv(struct mt76_dev *dev, struct sk_buff *skb, basic->conn_state =CONN_STATE_DISCONNECT ; } -if (!sta) { +if (!link_sta) { basic->conn_type =cpu_to_le32 (CONNECTION_INFRA_BC );eth_broadcast_addr (basic->peer_addr);return ;
@@ -404,7 +404,7 @@ void mt76_connac_mcu_sta_basic_tlv(struct mt76_dev *dev, struct sk_buff *skb,else conn_type =CONNECTION_INFRA_STA ; basic->conn_type =cpu_to_le32 (conn_type); - basic->aid =cpu_to_le16 (sta->aid); + basic->aid =cpu_to_le16 (link_sta->sta->aid);break ;case NL80211_IFTYPE_STATION :if (vif->p2p && !is_mt7921 (dev))
@@ -416,15 +416,15 @@ void mt76_connac_mcu_sta_basic_tlv(struct mt76_dev *dev, struct sk_buff *skb,break ;case NL80211_IFTYPE_ADHOC : basic->conn_type =cpu_to_le32 (CONNECTION_IBSS_ADHOC ); - basic->aid =cpu_to_le16 (sta->aid); + basic->aid =cpu_to_le16 (link_sta->sta->aid);break ;default :WARN_ON (1 );break ; } -memcpy (basic->peer_addr, sta->addr,ETH_ALEN ); - basic->qos = sta->wme; +memcpy (basic->peer_addr, link_sta->addr,ETH_ALEN ); + basic->qos = link_sta->sta->wme; }EXPORT_SYMBOL_GPL (mt76_connac_mcu_sta_basic_tlv);
@@ -1049,8 +1049,9 @@ int mt76_connac_mcu_sta_cmd(struct mt76_phy *phy,return PTR_ERR (skb);if (info->sta || !info->offload_fw) -mt76_connac_mcu_sta_basic_tlv (dev, skb, info->vif, info->sta, - info->enable, info->newly); +mt76_connac_mcu_sta_basic_tlv (dev, skb, info->vif, + &info->sta->deflink, info->enable, + info->newly);if (info->sta && info->enable) mt76_connac_mcu_sta_tlv(phy, skb, info->sta, info->vif, info->rcpi,
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +2 -2
@@ -1879,8 +1879,8 @@ int mt76_connac_mcu_set_channel_domain(struct mt76_phy *phy);int mt76_connac_mcu_set_vif_ps (struct mt76_dev *dev,struct ieee80211_vif *vif);void mt76_connac_mcu_sta_basic_tlv (struct mt76_dev *dev,struct sk_buff *skb,struct ieee80211_vif *vif, -struct ieee80211_sta *sta,bool enable, -bool newly); +struct ieee80211_link_sta *link_sta, +bool enable,bool newly); void mt76_connac_mcu_wtbl_generic_tlv(struct mt76_dev *dev, struct sk_buff *skb, struct ieee80211_vif *vif, struct ieee80211_sta *sta, void *sta_wtbl,
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +1 -1
@@ -1668,7 +1668,7 @@ int mt7915_mcu_add_sta(struct mt7915_dev *dev, struct ieee80211_vif *vif,return PTR_ERR (skb);/* starec basic */ -mt76_connac_mcu_sta_basic_tlv (&dev->mt76, skb, vif, sta, enable, +mt76_connac_mcu_sta_basic_tlv (&dev->mt76, skb, vif, &sta->deflink, enable, !rcu_access_pointer (dev->mt76.wcid[msta->wcid.idx]));if (!enable) goto out;
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +1 -1
@@ -1645,7 +1645,7 @@ mt7925_mcu_sta_cmd(struct mt76_phy *phy,if (info->link_sta || !info->offload_fw)mt76_connac_mcu_sta_basic_tlv (dev, skb, info->vif, - info->link_sta->sta, + info->link_sta, info->enable, info->newly);if (info->link_sta && info->enable) {mt7925_mcu_sta_phy_tlv (skb, info->vif, info->link_sta);
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c +1 -1
@@ -2152,7 +2152,7 @@ int mt7996_mcu_add_sta(struct mt7996_dev *dev, struct ieee80211_vif *vif,return PTR_ERR (skb);/* starec basic */ -mt76_connac_mcu_sta_basic_tlv (&dev->mt76, skb, vif, sta, enable, +mt76_connac_mcu_sta_basic_tlv (&dev->mt76, skb, vif, &sta->deflink, enable, !rcu_access_pointer (dev->mt76.wcid[msta->wcid.idx]));if (!enable) goto out;
Signature · 1 line
2.34.1
Felix Fietkau
maintainerRe: [PATCH 37/47] wifi: mt76: mt762x: extend mt76_connac_mcu_sta_basic_tlv for per-link STA
Quoted 8 lines · On 13.06.24 05:02, [email protected] wrote:
From: Sean Wang <[email protected]>
Extend
mt76_connac_mcu_sta_basic_tlvwith the per-link STA configuration.The patch we created is a prerequisite to enable the MLO function in the driver. It is purely a refactoring patch so the functionality should remain unchanged.
Quoted 5 lines
Co-developed-by Ming Yen Hsieh <[email protected]>Signed-off-by Ming Yen Hsieh <[email protected]>Co-developed-by Deren Wu <[email protected]>Signed-off-by Deren Wu <[email protected]>Signed-off-by Sean Wang <[email protected]>
This patch is broken on non-mt762x drivers, because the functions that call mt76_connac_mcu_sta_basic_tlv may be called with sta == NULL.
I've seen it crash on mt7996 because of that, but mt7915 and mt7615 are likely equally affected.
- Felix
Felix Fietkau
maintainerRe: [PATCH 37/47] wifi: mt76: mt762x: extend mt76_connac_mcu_sta_basic_tlv for per-link STA
Quoted 15 lines · Felix Fietkau
Quoted 8 lines · On 13.06.24 05:02, [email protected] wrote:
From: Sean Wang <[email protected]>
Extend
mt76_connac_mcu_sta_basic_tlvwith the per-link STA configuration.The patch we created is a prerequisite to enable the MLO function in the driver. It is purely a refactoring patch so the functionality should remain unchanged.
Quoted 5 lines
Co-developed-by Ming Yen Hsieh <[email protected]>Signed-off-by Ming Yen Hsieh <[email protected]>Co-developed-by Deren Wu <[email protected]>Signed-off-by Deren Wu <[email protected]>Signed-off-by Sean Wang <[email protected]>
Quoted 5 lines
This patch is broken on non-mt762x drivers, because the functions that call
mt76_connac_mcu_sta_basic_tlvmay be called with sta == NULL.I've seen it crash on mt7996 because of that, but mt7915 and mt7615 are likely equally affected.
I've pushed a fixed version to my tree. Please check if it looks correct to you.
Thanks,
- Felix
Re: [PATCH 37/47] wifi: mt76: mt762x: extend mt76_connac_mcu_sta_basic_tlv for per-link STA
Hi Felix,
Thank you for making the changes. They look correct to me. I appreciate your help with this!
Sean
Quoted 30 lines · Felix Fietkau
Quoted 15 lines · Felix Fietkau
Quoted 8 lines · On 13.06.24 05:02, [email protected] wrote:
From: Sean Wang <[email protected]>
Extend
mt76_connac_mcu_sta_basic_tlvwith the per-link STA configuration.The patch we created is a prerequisite to enable the MLO function in the driver. It is purely a refactoring patch so the functionality should remain unchanged.
Quoted 5 lines
Co-developed-by Ming Yen Hsieh <[email protected]>Signed-off-by Ming Yen Hsieh <[email protected]>Co-developed-by Deren Wu <[email protected]>Signed-off-by Deren Wu <[email protected]>Signed-off-by Sean Wang <[email protected]>Quoted 5 lines
This patch is broken on non-mt762x drivers, because the functions that call
mt76_connac_mcu_sta_basic_tlvmay be called with sta == NULL.I've seen it crash on mt7996 because of that, but mt7915 and mt7615 are likely equally affected.
I've pushed a fixed version to my tree. Please check if it looks correct to you.
Thanks,
- Felix
PATCH 38/47 wifi: mt76: mt7925: extend mt7925_mcu_sta_hdr_trans_tlv for per-link STA
In reply to [email protected]From: Sean Wang <[email protected]>
Extend mt7925_mcu_sta_hdr_trans_tlv with per-link STA configuration.
The patch we created is a prerequisite to enable the MLO function in the driver. It is purely a refactoring patch so the functionality should remain unchanged.
--- drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +6 -10
@@ -847,7 +847,7 @@ EXPORT_SYMBOL_GPL(mt7925_run_firmware);static void mt7925_mcu_sta_hdr_trans_tlv (struct sk_buff *skb,struct ieee80211_vif *vif, -struct ieee80211_sta *sta) +struct ieee80211_link_sta *link_sta) {struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;struct sta_rec_hdr_trans *hdr_trans;
@@ -863,8 +863,8 @@ mt7925_mcu_sta_hdr_trans_tlv(struct sk_buff *skb,else hdr_trans->from_ds = true; -if (sta) - wcid = (struct mt76_wcid *)sta->drv_priv; +if (link_sta) + wcid = (struct mt76_wcid *)link_sta->sta->drv_priv;else wcid = &mvif->sta.deflink.wcid;
@@ -895,7 +895,7 @@ int mt7925_mcu_wtbl_update_hdr_trans(struct mt792x_dev *dev,return PTR_ERR (skb);/* starec hdr trans */ -mt7925_mcu_sta_hdr_trans_tlv (skb, vif, sta); +mt7925_mcu_sta_hdr_trans_tlv (skb, vif, &sta->deflink);return mt76_mcu_skb_send_msg (&dev->mt76, skb,MCU_WMWA_UNI_CMD (STA_REC_UPDATE ), true); }
@@ -1664,12 +1664,8 @@ mt7925_mcu_sta_cmd(struct mt76_phy *phy,mt7925_mcu_sta_mld_tlv (skb, info->vif, info->link_sta->sta); } -if (info->enable) { -struct ieee80211_sta *sta = info->link_sta ? - info->link_sta->sta :NULL ; - -mt7925_mcu_sta_hdr_trans_tlv (skb, info->vif, sta); - } +if (info->enable) +mt7925_mcu_sta_hdr_trans_tlv (skb, info->vif, info->link_sta);return mt76_mcu_skb_send_msg (dev, skb, info->cmd, true); }
Signature · 1 line
2.34.1
PATCH 39/47 wifi: mt76: mt7925: extend mt7925_mcu_add_bss_info for per-link STA
In reply to [email protected]From: Sean Wang <[email protected]>
Extend mt7925_mcu_add_bss_info with the per-link STA configuration.
The patch we created is a prerequisite to enable the MLO function in the driver. It is purely a refactoring patch so the functionality should remain unchanged.
--- drivers/net/wireless/mediatek/mt76/mt7925/main.c | 8 ++++---- drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 6 +++--- drivers/net/wireless/mediatek/mt76/mt7925/mcu.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/main.c +4 -4
@@ -535,7 +535,7 @@ static int mt7925_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, mvif->bss_conf.mt76.cipher =mt7925_mcu_get_cipher (key->cipher);mt7925_mcu_add_bss_info (phy, mvif->bss_conf.mt76.ctx, link_conf, - sta, true); + &sta->deflink, true); }if (cmd ==SET_KEY )
@@ -738,7 +738,7 @@ int mt7925_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,/* should update bss info before STA add */ if (vif->type ==NL80211_IFTYPE_STATION && !sta->tdls)mt7925_mcu_add_bss_info (&dev->phy, mvif->bss_conf.mt76.ctx, - link_conf, sta, false); + link_conf, &sta->deflink, false); ret =mt7925_mcu_sta_update (dev, &sta->deflink, vif, true,MT76_STA_INFO_STATE_NONE );
@@ -765,7 +765,7 @@ void mt7925_mac_sta_assoc(struct mt76_dev *mdev, struct ieee80211_vif *vif,if (vif->type ==NL80211_IFTYPE_STATION && !sta->tdls)mt7925_mcu_add_bss_info (&dev->phy, mvif->bss_conf.mt76.ctx, - link_conf, sta, true); + link_conf, &sta->deflink, true);ewma_avg_signal_init (&msta->deflink.avg_ack_signal);
@@ -802,7 +802,7 @@ void mt7925_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,ewma_rssi_init (&mvif->bss_conf.rssi);if (!sta->tdls)mt7925_mcu_add_bss_info (&dev->phy, mvif->bss_conf.mt76.ctx, - link_conf, sta, false); + link_conf, &sta->deflink, false); }spin_lock_bh (&mdev->sta_poll_lock);
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +3 -3
@@ -2337,7 +2337,7 @@ int mt7925_mcu_set_timing(struct mt792x_phy *phy,int mt7925_mcu_add_bss_info (struct mt792x_phy *phy,struct ieee80211_chanctx_conf *ctx,struct ieee80211_bss_conf *link_conf, -struct ieee80211_sta *sta, +struct ieee80211_link_sta *link_sta,int enable) {struct mt792x_vif *mvif = (struct mt792x_vif *)link_conf->vif->drv_priv;
@@ -2352,13 +2352,13 @@ int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,return PTR_ERR (skb);/* bss_basic must be first */ -mt7925_mcu_bss_basic_tlv (skb, link_conf, sta, ctx, phy->mt76, +mt7925_mcu_bss_basic_tlv (skb, link_conf, link_sta->sta, ctx, phy->mt76, mvif->sta.deflink.wcid.idx, enable);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, sta); +mt7925_mcu_bss_mld_tlv (skb, link_conf, link_sta->sta);mt7925_mcu_bss_ifs_tlv (skb, link_conf);if (link_conf->he_support) {
drivers/net/wireless/mediatek/mt76/mt7925/mcu.h +1 -1
@@ -595,7 +595,7 @@ int mt7925_mcu_sched_scan_enable(struct mt76_phy *phy,int mt7925_mcu_add_bss_info (struct mt792x_phy *phy,struct ieee80211_chanctx_conf *ctx,struct ieee80211_bss_conf *link_conf, -struct ieee80211_sta *sta, +struct ieee80211_link_sta *link_sta,int enable);int mt7925_mcu_set_timing (struct mt792x_phy *phy,struct ieee80211_bss_conf *link_conf);
Signature · 1 line
2.34.1
PATCH 40/47 wifi: mt76: mt7925: extend mt7925_mcu_bss_mld_tlv for per-link STA
In reply to [email protected]From: Sean Wang <[email protected]>
Extend mt7925_mcu_bss_mld_tlv with the per-link STA configuration.
--- drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +5 -5
@@ -2227,7 +2227,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_sta *sta) +struct ieee80211_link_sta *link_sta) {struct mt792x_bss_conf *mconf =mt792x_link_conf_to_mconf (link_conf);bool is_mld =ieee80211_vif_is_mld (link_conf->vif);
@@ -2237,13 +2237,13 @@ mt7925_mcu_bss_mld_tlv(struct sk_buff *skb, tlv =mt76_connac_mcu_add_tlv (skb,UNI_BSS_INFO_MLD ,sizeof (*mld)); mld = (struct bss_mld_tlv *)tlv; - mld->link_id = sta ? (is_mld ? link_conf->link_id :0 ) :0xff ; + mld->link_id = link_sta ? (is_mld ? link_conf->link_id :0 ) :0xff ; mld->group_mld_id = is_mld ? mconf->mt76.idx :0xff ; mld->own_mld_id = mconf->mt76.idx +32 ; mld->remap_idx =0xff ; -if (sta) -memcpy (mld->mac_addr, sta->addr,ETH_ALEN ); +if (link_sta) +memcpy (mld->mac_addr, link_sta->addr,ETH_ALEN ); } static void
@@ -2358,7 +2358,7 @@ int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,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, link_sta->sta); +mt7925_mcu_bss_mld_tlv (skb, link_conf, link_sta);mt7925_mcu_bss_ifs_tlv (skb, link_conf);if (link_conf->he_support) {
Signature · 1 line
2.34.1
PATCH 41/47 wifi: mt76: mt7925: extend mt7925_mcu_bss_basic_tlv for per-link STA
In reply to [email protected]From: Sean Wang <[email protected]>
Extend mt7925_mcu_bss_basic_tlv with the per-link STA configuration.
--- .../net/wireless/mediatek/mt76/mt7925/mcu.c | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +17 -8
@@ -2078,18 +2078,17 @@ mt7925_get_phy_mode_ext(struct mt76_phy *phy, struct ieee80211_vif *vif,static void mt7925_mcu_bss_basic_tlv (struct sk_buff *skb,struct ieee80211_bss_conf *link_conf, -struct ieee80211_sta *sta, +struct ieee80211_link_sta *link_sta,struct ieee80211_chanctx_conf *ctx,struct mt76_phy *phy,u16 wlan_idx,bool enable) {struct ieee80211_vif *vif = link_conf->vif;struct mt792x_bss_conf *mconf =mt792x_link_conf_to_mconf (link_conf); -struct mt792x_sta *msta = sta ? (struct mt792x_sta *)sta->drv_priv : - &mconf->vif->sta;struct cfg80211_chan_def *chandef = ctx ? &ctx->def : &phy->chandef;enum nl80211_band band = chandef->chan->band;struct mt76_connac_bss_basic_tlv *basic_req; +struct mt792x_link_sta *mlink;struct tlv *tlv;int conn_type;u8 idx;
@@ -2102,7 +2101,7 @@ mt7925_mcu_bss_basic_tlv(struct sk_buff *skb, basic_req->hw_bss_idx = idx; basic_req->phymode_ext =mt7925_get_phy_mode_ext (phy, vif, band, - &sta->deflink); + link_sta);if (band ==NL80211_BAND_2GHZ ) basic_req->nonht_basic_phy =cpu_to_le16 (PHY_TYPE_ERP_INDEX );
@@ -2110,12 +2109,22 @@ mt7925_mcu_bss_basic_tlv(struct sk_buff *skb, basic_req->nonht_basic_phy =cpu_to_le16 (PHY_TYPE_OFDM_INDEX );memcpy (basic_req->bssid, link_conf->bssid,ETH_ALEN ); - basic_req->phymode =mt76_connac_get_phy_mode (phy, vif, band, - &sta->deflink); + basic_req->phymode =mt76_connac_get_phy_mode (phy, vif, band, link_sta); basic_req->bcn_interval =cpu_to_le16 (link_conf->beacon_int); basic_req->dtim_period = link_conf->dtim_period; basic_req->bmc_tx_wlan_idx =cpu_to_le16 (wlan_idx); - basic_req->sta_idx =cpu_to_le16 (msta->deflink.wcid.idx); + +if (link_sta) { +struct mt792x_sta *msta; + + msta = (struct mt792x_sta *)link_sta->sta->drv_priv; + mlink =mt792x_sta_to_link (msta, link_sta->link_id); + + }else { + mlink = &mconf->vif->sta.deflink; + } + + basic_req->sta_idx =cpu_to_le16 (mlink->wcid.idx); basic_req->omac_idx = mconf->mt76.omac_idx; basic_req->band_idx = mconf->mt76.band_idx; basic_req->wmm_idx = mconf->mt76.wmm_idx;
@@ -2352,7 +2361,7 @@ int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,return PTR_ERR (skb);/* bss_basic must be first */ -mt7925_mcu_bss_basic_tlv (skb, link_conf, link_sta->sta, ctx, phy->mt76, +mt7925_mcu_bss_basic_tlv (skb, link_conf, link_sta, ctx, phy->mt76, mvif->sta.deflink.wcid.idx, enable);mt7925_mcu_bss_sec_tlv (skb, link_conf);
Signature · 1 line
2.34.1
PATCH 42/47 wifi: mt76: mt7925: add mt7925_mac_link_sta_add to create per-link STA
In reply to [email protected]From: Sean Wang <[email protected]>
The mt7925_mac_link_sta_add function currently adds the per-link STA. We will extend this function when we implement the MLO functionality.
This patch only includes structural changes and does not involve any logic changes.
--- .../net/wireless/mediatek/mt76/mt7925/main.c | 47 ++++++++++++------- 1 file changed, 31 insertions(+), 16 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/main.c +31 -16
@@ -702,45 +702,46 @@ mt7925_get_rates_table(struct ieee80211_hw *hw, struct ieee80211_vif *vif,return mvif->basic_rates_idx; } -int mt7925_mac_sta_add (struct mt76_dev *mdev,struct ieee80211_vif *vif, -struct ieee80211_sta *sta) +static int mt7925_mac_link_sta_add (struct mt76_dev *mdev, +struct ieee80211_vif *vif, +struct ieee80211_link_sta *link_sta) { struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76); -struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv;struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;struct ieee80211_bss_conf *link_conf; +struct mt792x_link_sta *mlink; +struct mt792x_sta *msta;int ret, idx; + msta = (struct mt792x_sta *)link_sta->sta->drv_priv; + mlink =mt792x_sta_to_link (msta, link_sta->link_id); + idx =mt76_wcid_alloc (dev->mt76.wcid_mask, MT792x_WTBL_STA -1 );if (idx <0 )return -ENOSPC ; -INIT_LIST_HEAD (&msta->deflink.wcid.poll_list); - msta->vif = mvif; - msta->deflink.wcid.sta =1 ; - msta->deflink.wcid.idx = idx; - msta->deflink.wcid.phy_idx = mvif->bss_conf.mt76.band_idx; - msta->deflink.wcid.tx_info |=MT_WCID_TX_INFO_SET ; - msta->deflink.last_txs = jiffies; +INIT_LIST_HEAD (&mlink->wcid.poll_list); + mlink->wcid.sta =1 ; + mlink->wcid.idx = idx; + mlink->wcid.phy_idx = mvif->bss_conf.mt76.band_idx; + mlink->wcid.tx_info |=MT_WCID_TX_INFO_SET ; + mlink->last_txs = jiffies; ret =mt76_connac_pm_wake (&dev->mphy, &dev->pm);if (ret)return ret; -if (vif->type ==NL80211_IFTYPE_STATION ) - mvif->wep_sta = msta; -mt7925_mac_wtbl_update (dev, idx,MT_WTBL_UPDATE_ADM_COUNT_CLEAR ); link_conf =mt792x_vif_to_bss_conf (vif, vif->bss_conf.link_id);/* should update bss info before STA add */ -if (vif->type ==NL80211_IFTYPE_STATION && !sta->tdls) +if (vif->type ==NL80211_IFTYPE_STATION && !link_sta->sta->tdls)mt7925_mcu_add_bss_info (&dev->phy, mvif->bss_conf.mt76.ctx, - link_conf, &sta->deflink, false); + link_conf, link_sta, false); - ret =mt7925_mcu_sta_update (dev, &sta->deflink, vif, true, + ret =mt7925_mcu_sta_update (dev, link_sta, vif, true,MT76_STA_INFO_STATE_NONE );if (ret)return ret;
@@ -749,6 +750,20 @@ int mt7925_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,return 0 ; } + +int mt7925_mac_sta_add (struct mt76_dev *mdev,struct ieee80211_vif *vif, +struct ieee80211_sta *sta) +{ +struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; +struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv; + + msta->vif = mvif; + +if (vif->type ==NL80211_IFTYPE_STATION ) + mvif->wep_sta = msta; + +return mt7925_mac_link_sta_add (mdev, vif, &sta->deflink); +}EXPORT_SYMBOL_GPL (mt7925_mac_sta_add); void mt7925_mac_sta_assoc(struct mt76_dev *mdev, struct ieee80211_vif *vif,
Signature · 1 line
2.34.1
PATCH 43/47 wifi: mt76: mt7925: add mt7925_mac_link_sta_assoc to associate per-link STA
In reply to [email protected]From: Sean Wang <[email protected]>
The mt7925_mac_link_sta_add function currently associates the per-link STA. We will extend this function when we implement the MLO functionality.
This patch only includes structural changes and does not involve any logic changes.
--- .../net/wireless/mediatek/mt76/mt7925/main.c | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/main.c +20 -9
@@ -766,32 +766,43 @@ int mt7925_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif, }EXPORT_SYMBOL_GPL (mt7925_mac_sta_add); -void mt7925_mac_sta_assoc (struct mt76_dev *mdev,struct ieee80211_vif *vif, -struct ieee80211_sta *sta) +static void mt7925_mac_link_sta_assoc (struct mt76_dev *mdev, +struct ieee80211_vif *vif, +struct ieee80211_link_sta *link_sta) { struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76); -struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv;struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;struct ieee80211_bss_conf *link_conf; +struct mt792x_link_sta *mlink; +struct mt792x_sta *msta; + + msta = (struct mt792x_sta *)link_sta->sta->drv_priv; + mlink =mt792x_sta_to_link (msta, link_sta->link_id);mt792x_mutex_acquire (dev); link_conf =mt792x_vif_to_bss_conf (vif, vif->bss_conf.link_id); -if (vif->type ==NL80211_IFTYPE_STATION && !sta->tdls) +if (vif->type ==NL80211_IFTYPE_STATION && !link_sta->sta->tdls)mt7925_mcu_add_bss_info (&dev->phy, mvif->bss_conf.mt76.ctx, - link_conf, &sta->deflink, true); + link_conf, link_sta, true); -ewma_avg_signal_init (&msta->deflink.avg_ack_signal); +ewma_avg_signal_init (&mlink->avg_ack_signal); -mt7925_mac_wtbl_update (dev, msta->deflink.wcid.idx, +mt7925_mac_wtbl_update (dev, mlink->wcid.idx,MT_WTBL_UPDATE_ADM_COUNT_CLEAR ); -memset (msta->deflink.airtime_ac,0 ,sizeof (msta->deflink.airtime_ac)); +memset (mlink->airtime_ac,0 ,sizeof (mlink->airtime_ac)); -mt7925_mcu_sta_update (dev, &sta->deflink, vif, true,MT76_STA_INFO_STATE_ASSOC ); +mt7925_mcu_sta_update (dev, link_sta, vif, true,MT76_STA_INFO_STATE_ASSOC );mt792x_mutex_release (dev); } + +void mt7925_mac_sta_assoc (struct mt76_dev *mdev,struct ieee80211_vif *vif, +struct ieee80211_sta *sta) +{ +mt7925_mac_link_sta_assoc (mdev, vif, &sta->deflink); +}EXPORT_SYMBOL_GPL (mt7925_mac_sta_assoc); void mt7925_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
Signature · 1 line
2.34.1
PATCH 44/47 wifi: mt76: mt7925: add mt7925_mac_link_sta_remove to remove per-link STA
In reply to [email protected]From: Sean Wang <[email protected]>
The mt7925_mac_link_sta_remove function currently removes the per-link STA. We will extend this function when we implement the MLO functionality.
This patch only includes structural changes and does not involve any logic changes.
--- .../net/wireless/mediatek/mt76/mt7925/main.c | 46 +++++++++++++------ 1 file changed, 31 insertions(+), 15 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/main.c +31 -15
@@ -805,39 +805,55 @@ void mt7925_mac_sta_assoc(struct mt76_dev *mdev, struct ieee80211_vif *vif, }EXPORT_SYMBOL_GPL (mt7925_mac_sta_assoc); -void mt7925_mac_sta_remove (struct mt76_dev *mdev,struct ieee80211_vif *vif, -struct ieee80211_sta *sta) +static void mt7925_mac_link_sta_remove (struct mt76_dev *mdev, +struct ieee80211_vif *vif, +struct ieee80211_link_sta *link_sta) { struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76); -struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv;struct ieee80211_bss_conf *link_conf; +struct mt792x_link_sta *mlink; +struct mt792x_sta *msta; -mt76_connac_free_pending_tx_skbs (&dev->pm, &msta->deflink.wcid); + msta = (struct mt792x_sta *)link_sta->sta->drv_priv; + mlink =mt792x_sta_to_link (msta, link_sta->link_id); + +mt76_connac_free_pending_tx_skbs (&dev->pm, &mlink->wcid);mt76_connac_pm_wake (&dev->mphy, &dev->pm); -mt7925_mcu_sta_update (dev, &sta->deflink, vif, false,MT76_STA_INFO_STATE_NONE ); -mt7925_mac_wtbl_update (dev, msta->deflink.wcid.idx, +mt7925_mcu_sta_update (dev, link_sta, vif, false, +MT76_STA_INFO_STATE_NONE ); +mt7925_mac_wtbl_update (dev, mlink->wcid.idx,MT_WTBL_UPDATE_ADM_COUNT_CLEAR ); link_conf =mt792x_vif_to_bss_conf (vif, vif->bss_conf.link_id); -if (vif->type ==NL80211_IFTYPE_STATION ) { +if (vif->type ==NL80211_IFTYPE_STATION && !link_sta->sta->tdls) {struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; - - mvif->wep_sta =NULL ; -ewma_rssi_init (&mvif->bss_conf.rssi); -if (!sta->tdls) -mt7925_mcu_add_bss_info (&dev->phy, mvif->bss_conf.mt76.ctx, - link_conf, &sta->deflink, false); +mt7925_mcu_add_bss_info (&dev->phy, + mvif->bss_conf.mt76.ctx, link_conf, + link_sta, false); }spin_lock_bh (&mdev->sta_poll_lock); -if (!list_empty (&msta->deflink.wcid.poll_list)) -list_del_init (&msta->deflink.wcid.poll_list); +if (!list_empty (&mlink->wcid.poll_list)) +list_del_init (&mlink->wcid.poll_list);spin_unlock_bh (&mdev->sta_poll_lock);mt76_connac_power_save_sched (&dev->mphy, &dev->pm); } + +void mt7925_mac_sta_remove (struct mt76_dev *mdev,struct ieee80211_vif *vif, +struct ieee80211_sta *sta) +{ +mt7925_mac_link_sta_remove (mdev, vif, &sta->deflink); + +if (vif->type ==NL80211_IFTYPE_STATION ) { +struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; + + mvif->wep_sta =NULL ; +ewma_rssi_init (&mvif->bss_conf.rssi); + } +}EXPORT_SYMBOL_GPL (mt7925_mac_sta_remove);static int mt7925_set_rts_threshold (struct ieee80211_hw *hw,u32 val)
Signature · 1 line
2.34.1
PATCH 45/47 wifi: mt76: mt7925: add mt7925_mac_link_bss_add to create per-link BSS
In reply to [email protected]From: Sean Wang <[email protected]>
The mt7925_mac_link_bss_add function currently creates the per-link BSS. We will extend this function when we implement the MLO functionality.
This patch only includes structural changes and does not involve any logic changes.
--- .../net/wireless/mediatek/mt76/mt7925/main.c | 80 ++++++++++++------- 1 file changed, 49 insertions(+), 31 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/main.c +49 -31
@@ -317,63 +317,81 @@ static int mt7925_start(struct ieee80211_hw *hw)return err; } -static int -mt7925_add_interface (struct ieee80211_hw *hw,struct ieee80211_vif *vif) +static int mt7925_mac_link_bss_add (struct mt792x_dev *dev, +struct ieee80211_bss_conf *link_conf, +struct mt792x_link_sta *mlink) { -struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; -struct mt792x_dev *dev =mt792x_hw_dev (hw); -struct mt792x_phy *phy =mt792x_hw_phy (hw); +struct mt792x_bss_conf *mconf =mt792x_link_conf_to_mconf (link_conf); +struct ieee80211_vif *vif = link_conf->vif; +struct mt792x_vif *mvif = mconf->vif;struct mt76_txq *mtxq;int idx, ret =0 ; -mt792x_mutex_acquire (dev); - - mvif->bss_conf.mt76.idx =__ffs64 (~dev->mt76.vif_mask); -if (mvif->bss_conf.mt76.idx >= MT792x_MAX_INTERFACES) { + mconf->mt76.idx =__ffs64 (~dev->mt76.vif_mask); +if (mconf->mt76.idx >= MT792x_MAX_INTERFACES) { ret = -ENOSPC ; goto out; } - mvif->bss_conf.mt76.omac_idx = mvif->bss_conf.mt76.idx; - mvif->phy = phy; - mvif->bss_conf.mt76.band_idx =0 ; - mvif->bss_conf.mt76.wmm_idx = mvif->bss_conf.mt76.idx %MT76_CONNAC_MAX_WMM_SETS ; - mvif->bss_conf.vif = mvif; + mconf->mt76.omac_idx = mconf->mt76.idx; + mconf->mt76.band_idx =0 ; + mconf->mt76.wmm_idx = mconf->mt76.idx %MT76_CONNAC_MAX_WMM_SETS ; -if (phy->mt76->chandef.chan->band !=NL80211_BAND_2GHZ ) - mvif->bss_conf.mt76.basic_rates_idx = MT792x_BASIC_RATES_TBL +4 ; +if (mvif->phy->mt76->chandef.chan->band !=NL80211_BAND_2GHZ ) + mconf->mt76.basic_rates_idx = MT792x_BASIC_RATES_TBL +4 ;else - mvif->bss_conf.mt76.basic_rates_idx = MT792x_BASIC_RATES_TBL; + mconf->mt76.basic_rates_idx = MT792x_BASIC_RATES_TBL; - ret =mt76_connac_mcu_uni_add_dev (&dev->mphy, &vif->bss_conf, - &mvif->sta.deflink.wcid, true); + ret =mt76_connac_mcu_uni_add_dev (&dev->mphy, link_conf, + &mlink->wcid, true);if (ret) goto out; - dev->mt76.vif_mask |=BIT_ULL (mvif->bss_conf.mt76.idx); - phy->omac_mask |=BIT_ULL (mvif->bss_conf.mt76.omac_idx); + dev->mt76.vif_mask |=BIT_ULL (mconf->mt76.idx); + mvif->phy->omac_mask |=BIT_ULL (mconf->mt76.omac_idx); - idx = MT792x_WTBL_RESERVED - mvif->bss_conf.mt76.idx; + idx = MT792x_WTBL_RESERVED - mconf->mt76.idx; -INIT_LIST_HEAD (&mvif->sta.deflink.wcid.poll_list); - mvif->sta.deflink.wcid.idx = idx; - mvif->sta.deflink.wcid.phy_idx = mvif->bss_conf.mt76.band_idx; - mvif->sta.deflink.wcid.hw_key_idx =-1 ; - mvif->sta.deflink.wcid.tx_info |=MT_WCID_TX_INFO_SET ; - mvif->sta.vif = mvif; -mt76_wcid_init (&mvif->sta.deflink.wcid); +INIT_LIST_HEAD (&mlink->wcid.poll_list); + mlink->wcid.idx = idx; + mlink->wcid.phy_idx = mconf->mt76.band_idx; + mlink->wcid.hw_key_idx =-1 ; + mlink->wcid.tx_info |=MT_WCID_TX_INFO_SET ; +mt76_wcid_init (&mlink->wcid);mt7925_mac_wtbl_update (dev, idx,MT_WTBL_UPDATE_ADM_COUNT_CLEAR ); -ewma_rssi_init (&mvif->bss_conf.rssi); +ewma_rssi_init (&mconf->rssi); -rcu_assign_pointer (dev->mt76.wcid[idx], &mvif->sta.deflink.wcid); +rcu_assign_pointer (dev->mt76.wcid[idx], &mlink->wcid);if (vif->txq) { mtxq = (struct mt76_txq *)vif->txq->drv_priv; mtxq->wcid = idx; } +out: +return ret; +} + +static int +mt7925_add_interface (struct ieee80211_hw *hw,struct ieee80211_vif *vif) +{ +struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; +struct mt792x_dev *dev =mt792x_hw_dev (hw); +struct mt792x_phy *phy =mt792x_hw_phy (hw); +int ret =0 ; + +mt792x_mutex_acquire (dev); + + mvif->phy = phy; + mvif->bss_conf.vif = mvif; + mvif->sta.vif = mvif; + + ret =mt7925_mac_link_bss_add (dev, &vif->bss_conf, &mvif->sta.deflink); +if (ret <0 ) + goto out; + vif->driver_flags |=IEEE80211_VIF_BEACON_FILTER ; out:mt792x_mutex_release (dev);
Signature · 1 line
2.34.1
PATCH 46/47 wifi: mt76: mt7925: add mt7925_mac_link_bss_remove to remove per-link BSS
In reply to [email protected]From: Sean Wang <[email protected]>
The mt7925_mac_link_bss_remove function currently removes the per-link BSS. We will extend this function when we implement the MLO functionality.
This patch only includes structural changes and does not involve any logic changes.
--- .../net/wireless/mediatek/mt76/mt792x_core.c | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-)
drivers/net/wireless/mediatek/mt76/mt792x_core.c +21 -14
@@ -113,31 +113,38 @@ void mt792x_stop(struct ieee80211_hw *hw) }EXPORT_SYMBOL_GPL (mt792x_stop); -void mt792x_remove_interface (struct ieee80211_hw *hw, -struct ieee80211_vif *vif) +static void mt792x_mac_link_bss_remove (struct mt792x_dev *dev, +struct ieee80211_bss_conf *link_conf, +struct mt792x_link_sta *mlink) { -struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; -struct mt792x_sta *msta = &mvif->sta; -struct mt792x_dev *dev =mt792x_hw_dev (hw); -struct mt792x_phy *phy =mt792x_hw_phy (hw); -int idx = msta->deflink.wcid.idx; +struct mt792x_bss_conf *mconf =mt792x_link_conf_to_mconf (link_conf); +int idx = mlink->wcid.idx;mt792x_mutex_acquire (dev); -mt76_connac_free_pending_tx_skbs (&dev->pm, &msta->deflink.wcid); -mt76_connac_mcu_uni_add_dev (&dev->mphy, &vif->bss_conf, &mvif->sta.deflink.wcid, false); +mt76_connac_free_pending_tx_skbs (&dev->pm, &mlink->wcid); +mt76_connac_mcu_uni_add_dev (&dev->mphy, link_conf, &mlink->wcid, false);rcu_assign_pointer (dev->mt76.wcid[idx],NULL ); - dev->mt76.vif_mask &= ~BIT_ULL (mvif->bss_conf.mt76.idx); - phy->omac_mask &= ~BIT_ULL (mvif->bss_conf.mt76.omac_idx); + dev->mt76.vif_mask &= ~BIT_ULL (mconf->mt76.idx); + mconf->vif->phy->omac_mask &= ~BIT_ULL (mconf->mt76.omac_idx);mt792x_mutex_release (dev);spin_lock_bh (&dev->mt76.sta_poll_lock); -if (!list_empty (&msta->deflink.wcid.poll_list)) -list_del_init (&msta->deflink.wcid.poll_list); +if (!list_empty (&mlink->wcid.poll_list)) +list_del_init (&mlink->wcid.poll_list);spin_unlock_bh (&dev->mt76.sta_poll_lock); -mt76_wcid_cleanup (&dev->mt76, &msta->deflink.wcid); +mt76_wcid_cleanup (&dev->mt76, &mlink->wcid); +} + +void mt792x_remove_interface (struct ieee80211_hw *hw, +struct ieee80211_vif *vif) +{ +struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; +struct mt792x_dev *dev =mt792x_hw_dev (hw); + +mt792x_mac_link_bss_remove (dev, &vif->bss_conf, &mvif->sta.deflink); }EXPORT_SYMBOL_GPL (mt792x_remove_interface);
Signature · 1 line
2.34.1
patch 46/47 causes NULL pointer deref on mt7921
Since linux-next-20240711 my linux system fails to start with a NULL pointer error. Hardware: MSI Alpha 15 Laptop Ryzen 5800H with
04:00.0 Network controller: MEDIATEK Corp. MT7921K (RZ608) Wi-Fi 6E 80MHz
[ T843] BUG: unable to handle page fault for address: ffffffffffffffa0 [ T843] #PF: supervisor read access in kernel mode [ T843] #PF: error_code(0x0000) - not-present page [ T843] PGD e5c81a067 P4D e5c81a067 PUD e5c81c067 PMD 0 [ T843] Oops: Oops: 0000 [#1] PREEMPT SMP NOPTI [ T843] CPU: 2 UID: 0 PID: 843 Comm: NetworkManager Not tainted 6.10.0-rc7-next-20240711-dirty #9 [ T843] Hardware name: Micro-Star International Co., Ltd. Alpha 15 B5EEK/MS-158L, BIOS E158LAMS.107 11/10/2021 [ T843] RIP: 0010:mt792x_mac_link_bss_remove+0x24/0x110 [mt792x_lib] [ T843] Code: 84 00 00 00 00 00 f3 0f 1e fa 41 56 41 55 41 54 49 89 f4 55 48 89 fd 53 48 8b 46 18 48 89 d3 44 0f b7 aa b8 00 00 00 8b 56 60 <66> 83 78 a0 00 74 0f 83 fa 0e 77 0a 4c 8b b4 d0 28 ff ff ff eb 07 [ T843] RSP: 0018:ffffbc1b43b3b688 EFLAGS: 00010282 [ T843] RAX: 0000000000000000 RBX: ffff906ab80a9f00 RCX: 000fffffffe00000 [ T843] RDX: 0000000000000000 RSI: ffff906ab80a9e20 RDI: ffff9069c1712000 [ T843] RBP: ffff9069c1712000 R08: ffff9069c0402018 R09: ffffffffab226720 [ T843] R10: 0000000000000000 R11: 0000000000000000 R12: ffff906ab80a9e20 [ T843] R13: 0000000000000013 R14: 0000000000000000 R15: ffff906ab80a9990 [ T843] FS: 00007fb2edd7b500(0000) GS:ffff90786e680000(0000) knlGS:0000000000000000 [ T843] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ T843] CR2: ffffffffffffffa0 CR3: 000000010a104000 CR4: 0000000000750ef0 [ T843] PKRU: 55555554 [ T843] Call Trace: [ T843] <TASK> [ T843] ? __die+0x1e/0x60 [ T843] ? page_fault_oops+0x157/0x450 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? search_bpf_extables+0x5a/0x80 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? exc_page_fault+0x2bb/0x670 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? lock_timer_base+0x71/0x90 [ T843] ? asm_exc_page_fault+0x26/0x30 [ T843] ? mt792x_mac_link_bss_remove+0x24/0x110 [mt792x_lib] [ T843] ? mt792x_remove_interface+0x6e/0x90 [mt792x_lib] [ T843] ? ieee80211_do_stop+0x507/0x7e0 [mac80211] [ T843] ? ieee80211_stop+0x53/0x190 [mac80211] [ T843] ? __dev_close_many+0xa5/0x120 [ T843] ? __dev_change_flags+0x18c/0x220 [ T843] ? dev_change_flags+0x21/0x60 [ T843] ? do_setlink+0xdf9/0x11d0 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? security_sock_rcv_skb+0x33/0x50 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? __nla_validate_parse+0x61/0xd10 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? genl_done+0x53/0x80 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? netlink_dump+0x357/0x410 [ T843] ? __rtnl_newlink+0x5d6/0x980 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? genl_family_rcv_msg_dumpit+0xdf/0xf0 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? __kmalloc_cache_noprof+0x44/0x210 [ T843] ? rtnl_newlink+0x42/0x60 [ T843] ? rtnetlink_rcv_msg+0x152/0x3f0 [ T843] ? mptcp_pm_nl_dump_addr+0x180/0x180 [ T843] ? rtnl_calcit.isra.0+0x130/0x130 [ T843] ? netlink_rcv_skb+0x56/0x100 [ T843] ? netlink_unicast+0x199/0x290 [ T843] ? netlink_sendmsg+0x21d/0x490 [ T843] ? __sock_sendmsg+0x78/0x80 [ T843] ? ____sys_sendmsg+0x23f/0x2e0 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? copy_msghdr_from_user+0x68/0xa0 [ T843] ? ___sys_sendmsg+0x81/0xd0 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? crng_fast_key_erasure+0xbc/0xf0 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? get_random_bytes_user+0x126/0x140 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? __fdget+0xb1/0xe0 [ T843] ? __sys_sendmsg+0x56/0xa0 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? do_syscall_64+0x5f/0x170 [ T843] ? entry_SYSCALL_64_after_hwframe+0x55/0x5d [ T843] </TASK> [ T843] Modules linked in: bnep nls_ascii nls_cp437 vfat fat snd_ctl_led snd_hda_codec_realtek snd_hda_codec_generic snd_hda_scodec_component snd_hda_codec_hdmi btusb btrtl btintel snd_hda_intel uvcvideo btbcm snd_intel_dspcfg btmtk snd_hda_codec snd_soc_dmic snd_acp3x_pdm_dma snd_acp3x_rn videobuf2_vmalloc snd_hwdep uvc bluetooth videobuf2_memops snd_soc_core snd_hda_core videobuf2_v4l2 snd_pcm_oss snd_mixer_oss videodev snd_pcm snd_rn_pci_acp3x videobuf2_common snd_acp_config snd_timer msi_wmi snd_soc_acpi ecdh_generic amd_atl mc ecc sparse_keymap edac_mce_amd wmi_bmof snd ccp k10temp snd_pci_acp3x soundcore ac battery button hid_sensor_prox hid_sensor_gyro_3d hid_sensor_als hid_sensor_accel_3d hid_sensor_magn_3d hid_sensor_trigger industrialio_triggered_buffer joydev kfifo_buf industrialio amd_pmc hid_sensor_iio_common evdev hid_multitouch serio_raw mt7921e mt7921_common mt792x_lib mt76_connac_lib mt76 mac80211 libarc4 cfg80211 rfkill msr fuse nvme_fabrics configfs efi_pstore efivarfs autofs4 ext4 [ T843] crc32c_generic mbcache jbd2 usbhid amdgpu i2c_algo_bit drm_ttm_helper xhci_pci ttm drm_exec drm_suballoc_helper xhci_hcd amdxcp drm_buddy hid_sensor_hub usbcore nvme gpu_sched mfd_core hid_generic crc32c_intel psmouse drm_display_helper amd_sfh i2c_piix4 usb_common nvme_core crc16 r8169 i2c_hid_acpi i2c_hid hid i2c_designware_platform i2c_designware_core [ T843] CR2: ffffffffffffffa0 [ T843] ---[ end trace 0000000000000000 ]---
I bisected the error between linux-6.10-rc7 and linux-next-20240711 and the first offending commit which showed a NULL pointer error was
https://lore.kernel.org/all/[email protected]/
but the error is actually a different but most likely related NULL pointer error. To debug this I added some printk to the offending commit:
drivers/net/wireless/mediatek/mt76/mt792x.h +2 -0
@@ -230,6 +230,7 @@ mt792x_vif_to_link(struct mt792x_vif *mvif, u8 link_id)struct ieee80211_vif *vif; vif = container_of((void *)mvif, struct ieee80211_vif, drv_priv); +printk (KERN_INFO "%s %d: vif = %px\n" , __func__, __LINE__, vif);if (!ieee80211_vif_is_mld (vif) || link_id >=IEEE80211_LINK_UNSPECIFIED )
@@ -259,6 +260,7 @@ mt792x_link_conf_to_mconf(struct ieee80211_bss_conf *link_conf) {struct ieee80211_vif *vif = link_conf->vif;struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; +printk (KERN_INFO "%s %d: vif = %px mvif = %px\n" , __func__, __LINE__, vif, mvif);return mt792x_vif_to_link (mvif, link_conf->link_id); }
drivers/net/wireless/mediatek/mt76/mt792x_core.c +13 -0
@@ -119,23 +119,34 @@ static void mt792x_mac_link_bss_remove(struct mt792x_dev *dev, {struct mt792x_bss_conf *mconf =mt792x_link_conf_to_mconf (link_conf);int idx = mlink->wcid.idx; +printk (KERN_INFO "%s %d\n" , __func__, __LINE__);mt792x_mutex_acquire (dev); +printk (KERN_INFO "%s %d\n" , __func__, __LINE__);mt76_connac_free_pending_tx_skbs (&dev->pm, &mlink->wcid); +printk (KERN_INFO "%s %d\n" , __func__, __LINE__);mt76_connac_mcu_uni_add_dev (&dev->mphy, link_conf, &mlink->wcid, false); +printk (KERN_INFO "%s %d\n" , __func__, __LINE__);rcu_assign_pointer (dev->mt76.wcid[idx],NULL ); +printk (KERN_INFO "%s %d\n" , __func__, __LINE__); dev->mt76.vif_mask &= ~BIT_ULL (mconf->mt76.idx); +printk (KERN_INFO "%s %d: mconf->vif = %px\n" , __func__, __LINE__, mconf->vif); mconf->vif->phy->omac_mask &= ~BIT_ULL (mconf->mt76.omac_idx); +printk (KERN_INFO "%s %d\n" , __func__, __LINE__);mt792x_mutex_release (dev); +printk (KERN_INFO "%s %d\n" , __func__, __LINE__);spin_lock_bh (&dev->mt76.sta_poll_lock); +printk (KERN_INFO "%s %d\n" , __func__, __LINE__);if (!list_empty (&mlink->wcid.poll_list))list_del_init (&mlink->wcid.poll_list);spin_unlock_bh (&dev->mt76.sta_poll_lock); +printk (KERN_INFO "%s %d\n" , __func__, __LINE__);mt76_wcid_cleanup (&dev->mt76, &mlink->wcid); +printk (KERN_INFO "%s %d\n" , __func__, __LINE__); } void mt792x_remove_interface(struct ieee80211_hw *hw,
@@ -143,6 +154,8 @@ void mt792x_remove_interface(struct ieee80211_hw *hw, {struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;struct mt792x_dev *dev =mt792x_hw_dev (hw); +printk (KERN_INFO "%s %d: hw = %px vif = %px mvif = %px dev = %px\n" , + __func__, __LINE__, hw, vif, mvif, dev);mt792x_mac_link_bss_remove (dev, &vif->bss_conf, &mvif->sta.deflink); }
With these I get the following error message on startup:
[ T858] mt792x_remove_interface 157: hw = ffff92dc11560900 vif = ffff92dbe072d970 mvif = ffff92dbe072de00 dev = ffff92dc11562000 [ T858] mt792x_link_conf_to_mconf 263: vif = ffff92dbe072d970 mvif = ffff92dbe072de00 [ T858] mt792x_vif_to_link 233: vif = ffff92dbe072d970 [ T858] mt792x_mac_link_bss_remove 122 [ T858] mt792x_mac_link_bss_remove 125 [ T858] mt792x_mac_link_bss_remove 127 [ T858] mt792x_mac_link_bss_remove 129 [ T858] mt792x_mac_link_bss_remove 132 [ T858] mt792x_mac_link_bss_remove 135: mconf->vif = 0000000000000000 [ T858] BUG: kernel NULL pointer dereference, address: 00000000000004b8 [ T858] #PF: supervisor read access in kernel mode [ T858] #PF: error_code(0x0000) - not-present page [ T858] PGD 0 P4D 0 [ T858] Oops: Oops: 0000 [#1] PREEMPT SMP NOPTI [ T858] CPU: 0 PID: 858 Comm: NetworkManager Not tainted 6.10.0-rc5-debug-01238-g1541d63c5fe2-dirty #30 [ T858] Hardware name: Micro-Star International Co., Ltd. Alpha 15 B5EEK/MS-158L, BIOS E158LAMS.107 11/10/2021 [ T858] RIP: 0010:mt792x_remove_interface+0x1df/0x2e0 [mt792x_lib] [ T858] Code: 85 f0 30 00 00 49 8b 4f 18 e8 5d 4f f0 f7 49 8b 47 18 41 0f b6 4f 01 ba 89 00 00 00 48 c7 c6 90 24 05 c1 48 c7 c7 36 33 05 c1 <48> 8b 80 b8 04 00 00 49 d3 e4 49 f7 d4 4c 21 a0 10 27 00 00 4c 8d [ T858] RSP: 0018:ffff9fcf03db7698 EFLAGS: 00010246 [ T858] RAX: 0000000000000000 RBX: ffff92dbe072d970 RCX: 0000000000000000 [ T858] RDX: 0000000000000089 RSI: ffffffffc1052490 RDI: ffffffffc1053336 [ T858] RBP: ffff92dc11562000 R08: 0000000000000000 R09: 0000000000000003 [ T858] R10: ffff9fcf03db7550 R11: ffffffffba099d28 R12: 0000000000000001 [ T858] R13: ffff92dbe072ded8 R14: ffff92dc1156a150 R15: ffff92dbe072de00 [ T858] FS: 00007fa13c515500(0000) GS:ffff92ea6e600000(0000) knlGS:0000000000000000 [ T858] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ T858] CR2: 00000000000004b8 CR3: 00000001046a2000 CR4: 0000000000750ef0 [ T858] PKRU: 55555554 [ T858] Call Trace: [ T858] <TASK> [ T858] ? __die+0x1e/0x60 [ T858] ? page_fault_oops+0x157/0x450 [ T858] ? _prb_read_valid+0x273/0x2e0 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? exc_page_fault+0x331/0x670 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? prb_read_valid+0x16/0x20 [ T858] ? asm_exc_page_fault+0x26/0x30 [ T858] ? mt792x_remove_interface+0x1df/0x2e0 [mt792x_lib] [ T858] ? mt792x_remove_interface+0x1c3/0x2e0 [mt792x_lib] [ T858] ? ieee80211_do_stop+0x507/0x7e0 [mac80211] [ T858] ? ieee80211_stop+0x53/0x190 [mac80211] [ T858] ? __dev_close_many+0xa5/0x120 [ T858] ? __dev_change_flags+0x18c/0x220 [ T858] ? dev_change_flags+0x21/0x60 [ T858] ? do_setlink+0xdf9/0x11d0 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? __kmalloc_large_node+0x7e/0xb0 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? security_sock_rcv_skb+0x33/0x50 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? __nla_validate_parse+0x61/0xd10 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? genl_done+0x53/0x80 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? netlink_dump+0x357/0x410 [ T858] ? __rtnl_newlink+0x5d1/0x980 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? genl_family_rcv_msg_dumpit+0xdf/0xf0 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? kmalloc_trace_noprof+0x44/0x210 [ T858] ? rtnl_newlink+0x42/0x60 [ T858] ? rtnetlink_rcv_msg+0x14d/0x3f0 [ T858] ? mptcp_pm_nl_dump_addr+0x180/0x180 [ T858] ? rtnl_calcit.isra.0+0x130/0x130 [ T858] ? netlink_rcv_skb+0x56/0x100 [ T858] ? netlink_unicast+0x199/0x290 [ T858] ? netlink_sendmsg+0x21d/0x490 [ T858] ? __sock_sendmsg+0x78/0x80 [ T858] ? ____sys_sendmsg+0x23f/0x2e0 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? copy_msghdr_from_user+0x68/0xa0 [ T858] ? ___sys_sendmsg+0x81/0xd0 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? crng_fast_key_erasure+0xbc/0xf0 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? get_random_bytes_user+0x126/0x140 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? __fdget+0xb1/0xe0 [ T858] ? __sys_sendmsg+0x56/0xa0 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? do_syscall_64+0x5f/0x170 [ T858] ? entry_SYSCALL_64_after_hwframe+0x55/0x5d [ T858] </TASK> [ T858] Modules linked in: cmac bnep nls_ascii nls_cp437 vfat fat snd_ctl_led snd_hda_codec_realtek snd_hda_codec_generic snd_hda_scodec_component btusb snd_hda_codec_hdmi btrtl btintel btbcm btmtk snd_hda_intel amd_atl snd_intel_dspcfg bluetooth snd_acp3x_pdm_dma snd_soc_dmic snd_acp3x_rn snd_hda_codec uvcvideo snd_soc_core videobuf2_vmalloc uvc snd_hwdep videobuf2_memops videobuf2_v4l2 snd_hda_core videodev snd_pcm_oss snd_mixer_oss snd_pcm snd_rn_pci_acp3x snd_acp_config videobuf2_common snd_timer msi_wmi snd_soc_acpi ecdh_generic ecc mc sparse_keymap edac_mce_amd snd wmi_bmof k10temp ccp snd_pci_acp3x soundcore battery ac button joydev hid_sensor_magn_3d hid_sensor_gyro_3d hid_sensor_als hid_sensor_accel_3d hid_sensor_prox hid_sensor_trigger industrialio_triggered_buffer kfifo_buf industrialio amd_pmc hid_sensor_iio_common evdev hid_multitouch serio_raw mt7921e mt7921_common mt792x_lib mt76_connac_lib mt76 mac80211 libarc4 cfg80211 rfkill msr fuse nvme_fabrics efi_pstore configfs efivarfs autofs4 ext4 [ T858] crc32c_generic crc16 mbcache jbd2 usbhid amdgpu i2c_algo_bit xhci_pci drm_ttm_helper ttm xhci_hcd drm_exec drm_suballoc_helper amdxcp nvme drm_buddy hid_sensor_hub usbcore gpu_sched nvme_core mfd_core hid_generic crc32c_intel psmouse amd_sfh i2c_piix4 usb_common t10_pi drm_display_helper r8169 i2c_hid_acpi i2c_hid hid i2c_designware_platform i2c_designware_core [ T858] CR2: 00000000000004b8 [ T858] ---[ end trace 0000000000000000 ]---
So the problem is here that mconf->vif is still NULL probably because on mt7921 nobody is bothering to set it.
I did a similar investigation for the error in linux-next-20240711
void mt792x_mac_link_bss_remove(struct mt792x_dev *dev,
struct mt792x_bss_conf *mconf, struct mt792x_link_sta *mlink)
{
struct ieee80211_vif *vif = container_of((void *)mconf->vif,
struct ieee80211_vif, drv_priv);
struct ieee80211_bss_conf *link_conf;
int idx = mlink->wcid.idx;
printk(KERN_INFO "%s %d: dev = %px mconf = %px mlink = %px vif = %px\n",
__func__, __LINE__, dev, mconf, mlink, vif);
link_conf = mt792x_vif_to_bss_conf(vif, mconf->link_id);This leads to the following message on startup
[ T848] mt792x_mac_link_bss_remove 147: dev = ffff9403c1672000 mconf = ffff9403c1a35e20 mlink = ffff9403c1a35f00 vif = fffffffffffffb70 [ T848] BUG: unable to handle page fault for address: ffffffffffffffa0 [ T848] #PF: supervisor read access in kernel mode [ T848] #PF: error_code(0x0000) - not-present page
[skipped backtrace]
showing that vif is an invalid (though not NULL) pointer here, too.
Bert Karwatzki
Re: patch 46/47 causes NULL pointer deref on mt7921
The mt7925_ops struct contains these four ieee80211_ops which are not present in the mt7921_ops struct. In mt7925_change_vif_links mconf->vif is set.
from drivers/net/wireless/mediatek/mt76/mt7925/main.c:
.vif_cfg_changed = mt7925_vif_cfg_changed, .link_info_changed = mt7925_link_info_changed, .change_vif_links = mt7925_change_vif_links, .change_sta_links = mt7925_change_sta_links,
So I think you're probably breaking generic code (i. e. code that is also used on mt7921) with mt7925 specific changes.
Bert Karwatzki
Re: patch 46/47 causes NULL pointer deref on mt7921
In reply to Bert KarwatzkiHi Bert,
Thanks for the detailed debug log. I've quickly made a change to fix the issue. Right now, I can't access the test environment, but I'll test it and send it out as soon as possible. Here's the patch.
(quoted diff) +0 -0
b/drivers/net/wireless/mediatek/mt76/mt7921/main.c index 2e6268cb06c0..1bab93d049df 100644
drivers/net/wireless/mediatek/mt76/mt7921/main.c +0 -0
@@ -303,6 +303,7 @@ mt7921_add_interface(struct ieee80211_hw *hw,
struct ieee80211_vif *vif)
mvif->bss_conf.mt76.omac_idx = mvif->bss_conf.mt76.idx;
mvif->phy = phy;
+ mvif->bss_conf.vif = mvif;
mvif->bss_conf.mt76.band_idx = 0;
mvif->bss_conf.mt76.wmm_idx = mvif->bss_conf.mt76.idx %MT76_CONNAC_MAX_WMM_SETS;
Quoted 284 lines · Bert Karwatzki
Since linux-next-20240711 my linux system fails to start with a NULL pointer error. Hardware: MSI Alpha 15 Laptop Ryzen 5800H with
04:00.0 Network controller: MEDIATEK Corp. MT7921K (RZ608) Wi-Fi 6E 80MHz[ T843] BUG: unable to handle page fault for address: ffffffffffffffa0 [ T843] #PF: supervisor read access in kernel mode [ T843] #PF: error_code(0x0000) - not-present page [ T843] PGD e5c81a067 P4D e5c81a067 PUD e5c81c067 PMD 0 [ T843] Oops: Oops: 0000 [#1] PREEMPT SMP NOPTI [ T843] CPU: 2 UID: 0 PID: 843 Comm: NetworkManager Not tainted 6.10.0-rc7-next-20240711-dirty #9 [ T843] Hardware name: Micro-Star International Co., Ltd. Alpha 15 B5EEK/MS-158L, BIOS E158LAMS.107 11/10/2021 [ T843] RIP: 0010:mt792x_mac_link_bss_remove+0x24/0x110 [mt792x_lib] [ T843] Code: 84 00 00 00 00 00 f3 0f 1e fa 41 56 41 55 41 54 49 89 f4 55 48 89 fd 53 48 8b 46 18 48 89 d3 44 0f b7 aa b8 00 00 00 8b 56 60 <66> 83 78 a0 00 74 0f 83 fa 0e 77 0a 4c 8b b4 d0 28 ff ff ff eb 07 [ T843] RSP: 0018:ffffbc1b43b3b688 EFLAGS: 00010282 [ T843] RAX: 0000000000000000 RBX: ffff906ab80a9f00 RCX: 000fffffffe00000 [ T843] RDX: 0000000000000000 RSI: ffff906ab80a9e20 RDI: ffff9069c1712000 [ T843] RBP: ffff9069c1712000 R08: ffff9069c0402018 R09: ffffffffab226720 [ T843] R10: 0000000000000000 R11: 0000000000000000 R12: ffff906ab80a9e20 [ T843] R13: 0000000000000013 R14: 0000000000000000 R15: ffff906ab80a9990 [ T843] FS: 00007fb2edd7b500(0000) GS:ffff90786e680000(0000) knlGS:0000000000000000 [ T843] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ T843] CR2: ffffffffffffffa0 CR3: 000000010a104000 CR4: 0000000000750ef0 [ T843] PKRU: 55555554 [ T843] Call Trace: [ T843] <TASK> [ T843] ? __die+0x1e/0x60 [ T843] ? page_fault_oops+0x157/0x450 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? search_bpf_extables+0x5a/0x80 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? exc_page_fault+0x2bb/0x670 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? lock_timer_base+0x71/0x90 [ T843] ? asm_exc_page_fault+0x26/0x30 [ T843] ? mt792x_mac_link_bss_remove+0x24/0x110 [mt792x_lib] [ T843] ? mt792x_remove_interface+0x6e/0x90 [mt792x_lib] [ T843] ? ieee80211_do_stop+0x507/0x7e0 [mac80211] [ T843] ? ieee80211_stop+0x53/0x190 [mac80211] [ T843] ? __dev_close_many+0xa5/0x120 [ T843] ? __dev_change_flags+0x18c/0x220 [ T843] ? dev_change_flags+0x21/0x60 [ T843] ? do_setlink+0xdf9/0x11d0 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? security_sock_rcv_skb+0x33/0x50 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? __nla_validate_parse+0x61/0xd10 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? genl_done+0x53/0x80 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? netlink_dump+0x357/0x410 [ T843] ? __rtnl_newlink+0x5d6/0x980 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? genl_family_rcv_msg_dumpit+0xdf/0xf0 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? __kmalloc_cache_noprof+0x44/0x210 [ T843] ? rtnl_newlink+0x42/0x60 [ T843] ? rtnetlink_rcv_msg+0x152/0x3f0 [ T843] ? mptcp_pm_nl_dump_addr+0x180/0x180 [ T843] ? rtnl_calcit.isra.0+0x130/0x130 [ T843] ? netlink_rcv_skb+0x56/0x100 [ T843] ? netlink_unicast+0x199/0x290 [ T843] ? netlink_sendmsg+0x21d/0x490 [ T843] ? __sock_sendmsg+0x78/0x80 [ T843] ? ____sys_sendmsg+0x23f/0x2e0 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? copy_msghdr_from_user+0x68/0xa0 [ T843] ? ___sys_sendmsg+0x81/0xd0 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? crng_fast_key_erasure+0xbc/0xf0 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? get_random_bytes_user+0x126/0x140 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? __fdget+0xb1/0xe0 [ T843] ? __sys_sendmsg+0x56/0xa0 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? do_syscall_64+0x5f/0x170 [ T843] ? entry_SYSCALL_64_after_hwframe+0x55/0x5d [ T843] </TASK> [ T843] Modules linked in: bnep nls_ascii nls_cp437 vfat fat snd_ctl_led snd_hda_codec_realtek snd_hda_codec_generic snd_hda_scodec_component snd_hda_codec_hdmi btusb btrtl btintel snd_hda_intel uvcvideo btbcm snd_intel_dspcfg btmtk snd_hda_codec snd_soc_dmic snd_acp3x_pdm_dma snd_acp3x_rn videobuf2_vmalloc snd_hwdep uvc bluetooth videobuf2_memops snd_soc_core snd_hda_core videobuf2_v4l2 snd_pcm_oss snd_mixer_oss videodev snd_pcm snd_rn_pci_acp3x videobuf2_common snd_acp_config snd_timer msi_wmi snd_soc_acpi ecdh_generic amd_atl mc ecc sparse_keymap edac_mce_amd wmi_bmof snd ccp k10temp snd_pci_acp3x soundcore ac battery button hid_sensor_prox hid_sensor_gyro_3d hid_sensor_als hid_sensor_accel_3d hid_sensor_magn_3d hid_sensor_trigger industrialio_triggered_buffer joydev kfifo_buf industrialio amd_pmc hid_sensor_iio_common evdev hid_multitouch serio_raw mt7921e mt7921_common mt792x_lib mt76_connac_lib mt76 mac80211 libarc4 cfg80211 rfkill msr fuse nvme_fabrics configfs efi_pstore efivarfs autofs4 ext4 [ T843] crc32c_generic mbcache jbd2 usbhid amdgpu i2c_algo_bit drm_ttm_helper xhci_pci ttm drm_exec drm_suballoc_helper xhci_hcd amdxcp drm_buddy hid_sensor_hub usbcore nvme gpu_sched mfd_core hid_generic crc32c_intel psmouse drm_display_helper amd_sfh i2c_piix4 usb_common nvme_core crc16 r8169 i2c_hid_acpi i2c_hid hid i2c_designware_platform i2c_designware_core [ T843] CR2: ffffffffffffffa0 [ T843] ---[ end trace 0000000000000000 ]---I bisected the error between linux-6.10-rc7 and linux-next-20240711 and the first offending commit which showed a NULL pointer error was
https://lore.kernel.org/all/[email protected]/
but the error is actually a different but most likely related NULL pointer error. To debug this I added some printk to the offending commit:drivers/net/wireless/mediatek/mt76/mt792x.h +2
-0@@ -230,6 +230,7 @@ mt792x_vif_to_link(struct mt792x_vif *mvif, u8 link_id)struct ieee80211_vif *vif; vif = container_of((void *)mvif, struct ieee80211_vif, drv_priv); +printk (KERN_INFO "%s %d: vif = %px\n" , __func__, __LINE__, vif);if (!ieee80211_vif_is_mld (vif) || link_id >=IEEE80211_LINK_UNSPECIFIED )@@ -259,6 +260,7 @@ mt792x_link_conf_to_mconf(struct ieee80211_bss_conf *link_conf) {struct ieee80211_vif *vif = link_conf->vif;struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; +printk (KERN_INFO "%s %d: vif = %px mvif = %px\n" , __func__, __LINE__, vif, mvif);return mt792x_vif_to_link (mvif, link_conf->link_id); }drivers/net/wireless/mediatek/mt76/mt792x_core.c +13
-0@@ -119,23 +119,34 @@ static void mt792x_mac_link_bss_remove(struct mt792x_dev *dev, {struct mt792x_bss_conf *mconf =mt792x_link_conf_to_mconf (link_conf);int idx = mlink->wcid.idx; +printk (KERN_INFO "%s %d\n" , __func__, __LINE__);mt792x_mutex_acquire (dev); +printk (KERN_INFO "%s %d\n" , __func__, __LINE__);mt76_connac_free_pending_tx_skbs (&dev->pm, &mlink->wcid); +printk (KERN_INFO "%s %d\n" , __func__, __LINE__);mt76_connac_mcu_uni_add_dev (&dev->mphy, link_conf, &mlink->wcid, false); +printk (KERN_INFO "%s %d\n" , __func__, __LINE__);rcu_assign_pointer (dev->mt76.wcid[idx],NULL ); +printk (KERN_INFO "%s %d\n" , __func__, __LINE__); dev->mt76.vif_mask &= ~BIT_ULL (mconf->mt76.idx); +printk (KERN_INFO "%s %d: mconf->vif = %px\n" , __func__, __LINE__, mconf->vif); mconf->vif->phy->omac_mask &= ~BIT_ULL (mconf->mt76.omac_idx); +printk (KERN_INFO "%s %d\n" , __func__, __LINE__);mt792x_mutex_release (dev); +printk (KERN_INFO "%s %d\n" , __func__, __LINE__);spin_lock_bh (&dev->mt76.sta_poll_lock); +printk (KERN_INFO "%s %d\n" , __func__, __LINE__);if (!list_empty (&mlink->wcid.poll_list))list_del_init (&mlink->wcid.poll_list);spin_unlock_bh (&dev->mt76.sta_poll_lock); +printk (KERN_INFO "%s %d\n" , __func__, __LINE__);mt76_wcid_cleanup (&dev->mt76, &mlink->wcid); +printk (KERN_INFO "%s %d\n" , __func__, __LINE__); } void mt792x_remove_interface(struct ieee80211_hw *hw,@@ -143,6 +154,8 @@ void mt792x_remove_interface(struct ieee80211_hw *hw, {struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;struct mt792x_dev *dev =mt792x_hw_dev (hw); +printk (KERN_INFO "%s %d: hw = %px vif = %px mvif = %px dev = %px\n" , + __func__, __LINE__, hw, vif, mvif, dev);mt792x_mac_link_bss_remove (dev, &vif->bss_conf, &mvif->sta.deflink); }With these I get the following error message on startup:
[ T858] mt792x_remove_interface 157: hw = ffff92dc11560900 vif = ffff92dbe072d970 mvif = ffff92dbe072de00 dev = ffff92dc11562000 [ T858] mt792x_link_conf_to_mconf 263: vif = ffff92dbe072d970 mvif = ffff92dbe072de00 [ T858] mt792x_vif_to_link 233: vif = ffff92dbe072d970 [ T858] mt792x_mac_link_bss_remove 122 [ T858] mt792x_mac_link_bss_remove 125 [ T858] mt792x_mac_link_bss_remove 127 [ T858] mt792x_mac_link_bss_remove 129 [ T858] mt792x_mac_link_bss_remove 132 [ T858] mt792x_mac_link_bss_remove 135: mconf->vif = 0000000000000000 [ T858] BUG: kernel NULL pointer dereference, address: 00000000000004b8 [ T858] #PF: supervisor read access in kernel mode [ T858] #PF: error_code(0x0000) - not-present page [ T858] PGD 0 P4D 0 [ T858] Oops: Oops: 0000 [#1] PREEMPT SMP NOPTI [ T858] CPU: 0 PID: 858 Comm: NetworkManager Not tainted 6.10.0-rc5-debug-01238-g1541d63c5fe2-dirty #30 [ T858] Hardware name: Micro-Star International Co., Ltd. Alpha 15 B5EEK/MS-158L, BIOS E158LAMS.107 11/10/2021 [ T858] RIP: 0010:mt792x_remove_interface+0x1df/0x2e0 [mt792x_lib] [ T858] Code: 85 f0 30 00 00 49 8b 4f 18 e8 5d 4f f0 f7 49 8b 47 18 41 0f b6 4f 01 ba 89 00 00 00 48 c7 c6 90 24 05 c1 48 c7 c7 36 33 05 c1 <48> 8b 80 b8 04 00 00 49 d3 e4 49 f7 d4 4c 21 a0 10 27 00 00 4c 8d [ T858] RSP: 0018:ffff9fcf03db7698 EFLAGS: 00010246 [ T858] RAX: 0000000000000000 RBX: ffff92dbe072d970 RCX: 0000000000000000 [ T858] RDX: 0000000000000089 RSI: ffffffffc1052490 RDI: ffffffffc1053336 [ T858] RBP: ffff92dc11562000 R08: 0000000000000000 R09: 0000000000000003 [ T858] R10: ffff9fcf03db7550 R11: ffffffffba099d28 R12: 0000000000000001 [ T858] R13: ffff92dbe072ded8 R14: ffff92dc1156a150 R15: ffff92dbe072de00 [ T858] FS: 00007fa13c515500(0000) GS:ffff92ea6e600000(0000) knlGS:0000000000000000 [ T858] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ T858] CR2: 00000000000004b8 CR3: 00000001046a2000 CR4: 0000000000750ef0 [ T858] PKRU: 55555554 [ T858] Call Trace: [ T858] <TASK> [ T858] ? __die+0x1e/0x60 [ T858] ? page_fault_oops+0x157/0x450 [ T858] ? _prb_read_valid+0x273/0x2e0 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? exc_page_fault+0x331/0x670 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? prb_read_valid+0x16/0x20 [ T858] ? asm_exc_page_fault+0x26/0x30 [ T858] ? mt792x_remove_interface+0x1df/0x2e0 [mt792x_lib] [ T858] ? mt792x_remove_interface+0x1c3/0x2e0 [mt792x_lib] [ T858] ? ieee80211_do_stop+0x507/0x7e0 [mac80211] [ T858] ? ieee80211_stop+0x53/0x190 [mac80211] [ T858] ? __dev_close_many+0xa5/0x120 [ T858] ? __dev_change_flags+0x18c/0x220 [ T858] ? dev_change_flags+0x21/0x60 [ T858] ? do_setlink+0xdf9/0x11d0 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? __kmalloc_large_node+0x7e/0xb0 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? security_sock_rcv_skb+0x33/0x50 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? __nla_validate_parse+0x61/0xd10 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? genl_done+0x53/0x80 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? netlink_dump+0x357/0x410 [ T858] ? __rtnl_newlink+0x5d1/0x980 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? genl_family_rcv_msg_dumpit+0xdf/0xf0 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? kmalloc_trace_noprof+0x44/0x210 [ T858] ? rtnl_newlink+0x42/0x60 [ T858] ? rtnetlink_rcv_msg+0x14d/0x3f0 [ T858] ? mptcp_pm_nl_dump_addr+0x180/0x180 [ T858] ? rtnl_calcit.isra.0+0x130/0x130 [ T858] ? netlink_rcv_skb+0x56/0x100 [ T858] ? netlink_unicast+0x199/0x290 [ T858] ? netlink_sendmsg+0x21d/0x490 [ T858] ? __sock_sendmsg+0x78/0x80 [ T858] ? ____sys_sendmsg+0x23f/0x2e0 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? copy_msghdr_from_user+0x68/0xa0 [ T858] ? ___sys_sendmsg+0x81/0xd0 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? crng_fast_key_erasure+0xbc/0xf0 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? get_random_bytes_user+0x126/0x140 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? __fdget+0xb1/0xe0 [ T858] ? __sys_sendmsg+0x56/0xa0 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? do_syscall_64+0x5f/0x170 [ T858] ? entry_SYSCALL_64_after_hwframe+0x55/0x5d [ T858] </TASK> [ T858] Modules linked in: cmac bnep nls_ascii nls_cp437 vfat fat snd_ctl_led snd_hda_codec_realtek snd_hda_codec_generic snd_hda_scodec_component btusb snd_hda_codec_hdmi btrtl btintel btbcm btmtk snd_hda_intel amd_atl snd_intel_dspcfg bluetooth snd_acp3x_pdm_dma snd_soc_dmic snd_acp3x_rn snd_hda_codec uvcvideo snd_soc_core videobuf2_vmalloc uvc snd_hwdep videobuf2_memops videobuf2_v4l2 snd_hda_core videodev snd_pcm_oss snd_mixer_oss snd_pcm snd_rn_pci_acp3x snd_acp_config videobuf2_common snd_timer msi_wmi snd_soc_acpi ecdh_generic ecc mc sparse_keymap edac_mce_amd snd wmi_bmof k10temp ccp snd_pci_acp3x soundcore battery ac button joydev hid_sensor_magn_3d hid_sensor_gyro_3d hid_sensor_als hid_sensor_accel_3d hid_sensor_prox hid_sensor_trigger industrialio_triggered_buffer kfifo_buf industrialio amd_pmc hid_sensor_iio_common evdev hid_multitouch serio_raw mt7921e mt7921_common mt792x_lib mt76_connac_lib mt76 mac80211 libarc4 cfg80211 rfkill msr fuse nvme_fabrics efi_pstore configfs efivarfs autofs4 ext4 [ T858] crc32c_generic crc16 mbcache jbd2 usbhid amdgpu i2c_algo_bit xhci_pci drm_ttm_helper ttm xhci_hcd drm_exec drm_suballoc_helper amdxcp nvme drm_buddy hid_sensor_hub usbcore gpu_sched nvme_core mfd_core hid_generic crc32c_intel psmouse amd_sfh i2c_piix4 usb_common t10_pi drm_display_helper r8169 i2c_hid_acpi i2c_hid hid i2c_designware_platform i2c_designware_core [ T858] CR2: 00000000000004b8 [ T858] ---[ end trace 0000000000000000 ]---So the problem is here that
mconf->vifis still NULL probably because on mt7921 nobody is bothering to set it.I did a similar investigation for the error in linux-next-20240711
void mt792x_mac_link_bss_remove(struct
mt792x_dev*dev,
structmt792x_bss_conf*mconf, structmt792x_link_sta*mlink){ struct ieee80211_vif *vif = container_of((void *)mconf->vif, struct ieee80211_vif, drv_priv); struct ieee80211_bss_conf *link_conf; int idx = mlink->wcid.idx; printk(KERN_INFO "%s %d: dev = %px mconf = %px mlink = %px vif = %px\n", __func__, __LINE__, dev, mconf, mlink, vif); link_conf = mt792x_vif_to_bss_conf(vif, mconf->link_id);This leads to the following message on startup
[ T848] mt792x_mac_link_bss_remove 147: dev = ffff9403c1672000 mconf = ffff9403c1a35e20 mlink = ffff9403c1a35f00 vif = fffffffffffffb70 [ T848] BUG: unable to handle page fault for address: ffffffffffffffa0 [ T848] #PF: supervisor read access in kernel mode [ T848] #PF: error_code(0x0000) - not-present page[skipped backtrace]
showing that vif is an invalid (though not NULL) pointer here, too.
Bert Karwatzki
Re: patch 46/47 causes NULL pointer deref on mt7921
Am Donnerstag, dem 11.07.2024 um 18:40 -0500 schrieb Sean Wang:
Quoted 19 lines
Hi Bert,
Thanks for the detailed debug log. I've quickly made a change to fix the issue. Right now, I can't access the test environment, but I'll test it and send it out as soon as possible. Here's the patch.
drivers/net/wireless/mediatek/mt76/mt7921/main.c +1
-0@@ -303,6 +303,7 @@ mt7921_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) mvif->bss_conf.mt76.omac_idx = mvif->bss_conf.mt76.idx; mvif->phy = phy; + mvif->bss_conf.vif = mvif; mvif->bss_conf.mt76.band_idx =0 ; mvif->bss_conf.mt76.wmm_idx = mvif->bss_conf.mt76.idx %
Quoted 2 lines
MT76_CONNAC_MAX_WMM_SETS;
I tested your patch with linux-next-20240711 where it works fine and with linux- next-20240712 where the mediatek related error are solved, too, but gdm hangs on startup (with no related log messages, which I'm sure is a different problem).
Bert Karwatzki
Re: patch 46/47 causes NULL pointer deref on mt7921
In reply to Sean WangAm Donnerstag, dem 11.07.2024 um 18:40 -0500 schrieb Sean Wang:
Quoted 19 lines
Hi Bert,
Thanks for the detailed debug log. I've quickly made a change to fix the issue. Right now, I can't access the test environment, but I'll test it and send it out as soon as possible. Here's the patch.
drivers/net/wireless/mediatek/mt76/mt7921/main.c +1
-0@@ -303,6 +303,7 @@ mt7921_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) mvif->bss_conf.mt76.omac_idx = mvif->bss_conf.mt76.idx; mvif->phy = phy; + mvif->bss_conf.vif = mvif; mvif->bss_conf.mt76.band_idx =0 ; mvif->bss_conf.mt76.wmm_idx = mvif->bss_conf.mt76.idx %
Quoted 2 lines
MT76_CONNAC_MAX_WMM_SETS;
I wrote earlier that this patch works fine with linux-next-20240711 and at first it did, but then another NULL pointer error occured. I'm not sure if I can bisect this as it does not trigger automatically it seems. Also I'm currently bisecting the problem with linux-20240712
Bert Karwatzki
[ T853] BUG: kernel NULL pointer dereference, address: 0000000000000008 [ T853] #PF: supervisor read access in kernel mode [ T853] #PF: error_code(0x0000) - not-present page [ T853] PGD 0 P4D 0 [ T853] Oops: Oops: 0000 [#1] PREEMPT SMP NOPTI [ T853] CPU: 7 UID: 0 PID: 853 Comm: NetworkManager Not tainted 6.10.0-rc7-
next-20240711-debug-dirty #32
[ T853] Hardware name: Micro-Star International Co., Ltd. Alpha 15 B5EEK/MS- 158L, BIOS E158LAMS.107 11/10/2021
[ T853] RIP: 0010:mt7921_ipv6_addr_change+0x3b/0x1d0 [mt7921_common] [ T853] Code: 68 02 00 00 41 54 4c 89 ef 53 48 89 d3 48 83 e4 f0 48 83 ec 60 65 48 8b 04 25 28 00 00 00 48 89 44 24 58 48 8b 86 70 09 00 00 <4c> 8b 60 08 0f b6 86 90 04 00 00 48 c7 44 24 05 00 00 00 00 88 44
[ T853] RSP: 0018:ffffb1d203ef35e0 EFLAGS: 00010282 [ T853] RAX: 0000000000000000 RBX: ffff8c73c1ada000 RCX: 0000000000000000 [ T853] RDX: ffff8c73c1ada000 RSI: ffff8c73849d9990 RDI: ffff8c73c1ada268 [ T853] RBP: ffffb1d203ef3668 R08: ffff8c73c19703c0 R09: 0000000000000000 [ T853] R10: ffffb1d203ef36b0 R11: 0000000000000000 R12: 0000000000000002 [ T853] R13: ffff8c73c1ada268 R14: 00000000ffffffff R15: ffff8c73846b08d8 [ T853] FS: 00007f640a9e6500(0000) GS:ffff8c822e5c0000(0000) knlGS:0000000000000000 [ T853] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ T853] CR2: 0000000000000008 CR3: 00000001043e0000 CR4: 0000000000750ef0 [ T853] PKRU: 55555554 [ T853] Call Trace: [ T853] <TASK> [ T853] ? __die+0x1e/0x60 [ T853] ? page_fault_oops+0x157/0x450 [ T853] ? srso_alias_return_thunk+0x5/0xfbef5 [ T853] ? pollwake+0x73/0xa0 [ T853] ? wake_up_state+0x10/0x10 [ T853] ? exc_page_fault+0x331/0x670 [ T853] ? asm_exc_page_fault+0x26/0x30 [ T853] ? mt7921_ipv6_addr_change+0x3b/0x1d0 [mt7921_common] [ T853] ? srso_alias_return_thunk+0x5/0xfbef5 [ T853] ? __ipv6_ifa_notify+0x16f/0x4d0 [ T853] ? ieee80211_ifa6_changed+0x5e/0x70 [mac80211] [ T853] ? atomic_notifier_call_chain+0x51/0x80 [ T853] ? addrconf_ifdown.isra.0+0x43f/0x810 [ T853] ? srso_alias_return_thunk+0x5/0xfbef5 [ T853] ? addrconf_notify+0x15d/0x760 [ T853] ? __timer_delete_sync+0x70/0xd0 [ T853] ? raw_notifier_call_chain+0x43/0x60 [ T853] ? __dev_notify_flags+0x91/0xf0 [ T853] ? dev_change_flags+0x4f/0x60 [ T853] ? do_setlink+0xdf9/0x11d0 [ T853] ? __skb_flow_dissect+0xc30/0x1a40 [ T853] ? drain_stock+0x63/0xa0 [ T853] ? srso_alias_return_thunk+0x5/0xfbef5 [ T853] ? __nla_validate_parse+0x61/0xd10 [ T853] ? srso_alias_return_thunk+0x5/0xfbef5 [ T853] ? update_load_avg+0x77/0x6d0 [ T853] ? __rtnl_newlink+0x5d6/0x980 [ T853] ? __entry_text_end+0x102398/0x10239b [ T853] ? srso_alias_return_thunk+0x5/0xfbef5 [ T853] ? kmem_cache_alloc_node_noprof+0x4c/0x220 [ T853] ? srso_alias_return_thunk+0x5/0xfbef5 [ T853] ? srso_alias_return_thunk+0x5/0xfbef5 [ T853] ? __kmalloc_cache_noprof+0x44/0x210 [ T853] ? rtnl_newlink+0x42/0x60 [ T853] ? rtnetlink_rcv_msg+0x152/0x3f0 [ T853] ? srso_alias_return_thunk+0x5/0xfbef5 [ T853] ? netlink_unicast+0x238/0x290 [ T853] ? rtnl_calcit.isra.0+0x130/0x130 [ T853] ? netlink_rcv_skb+0x56/0x100 [ T853] ? netlink_unicast+0x199/0x290 [ T853] ? netlink_sendmsg+0x21d/0x490 [ T853] ? __sock_sendmsg+0x78/0x80 [ T853] ? ____sys_sendmsg+0x23f/0x2e0 [ T853] ? srso_alias_return_thunk+0x5/0xfbef5 [ T853] ? copy_msghdr_from_user+0x68/0xa0 [ T853] ? ___sys_sendmsg+0x81/0xd0 [ T853] ? srso_alias_return_thunk+0x5/0xfbef5 [ T853] ? crng_fast_key_erasure+0xbc/0xf0 [ T853] ? srso_alias_return_thunk+0x5/0xfbef5 [ T853] ? get_random_bytes_user+0x126/0x140 [ T853] ? srso_alias_return_thunk+0x5/0xfbef5 [ T853] ? __fdget+0xb1/0xe0 [ T853] ? __sys_sendmsg+0x56/0xa0 [ T853] ? srso_alias_return_thunk+0x5/0xfbef5 [ T853] ? do_syscall_64+0x5f/0x170 [ T853] ? entry_SYSCALL_64_after_hwframe+0x55/0x5d [ T853] </TASK> [ T853] Modules linked in: ccm snd_seq_dummy snd_hrtimer snd_seq_midi
snd_seq_midi_event snd_rawmidi snd_seq snd_seq_device rfcomm cmac bnep nls_ascii nls_cp437 vfat fat snd_ctl_led snd_hda_codec_realtek snd_hda_codec_generic snd_hda_scodec_component snd_hda_codec_hdmi btusb btrtl btintel snd_hda_intel btbcm btmtk snd_intel_dspcfg snd_hda_codec snd_soc_dmic snd_acp3x_pdm_dma snd_acp3x_rn bluetooth snd_soc_core uvcvideo snd_hwdep snd_hda_core videobuf2_vmalloc uvc videobuf2_memops videobuf2_v4l2 snd_pcm_oss videodev snd_mixer_oss snd_pcm snd_rn_pci_acp3x hid_sensor_gyro_3d hid_sensor_magn_3d hid_sensor_accel_3d hid_sensor_als hid_sensor_prox snd_acp_config videobuf2_common snd_timer hid_sensor_trigger msi_wmi snd_soc_acpi ecdh_generic amd_atl ecc mc snd edac_mce_amd wmi_bmof sparse_keymap ccp soundcore k10temp snd_pci_acp3x button industrialio_triggered_buffer battery joydev ac kfifo_buf industrialio hid_sensor_iio_common amd_pmc evdev hid_multitouch serio_raw mt7921e mt7921_common mt792x_lib mt76_connac_lib mt76
[ T853] mac80211 libarc4 cfg80211 rfkill msr fuse nvme_fabrics efi_pstore configfs efivarfs autofs4 ext4 crc32c_generic mbcache jbd2 usbhid amdgpu i2c_algo_bit drm_ttm_helper ttm drm_exec xhci_pci drm_suballoc_helper amdxcp drm_buddy xhci_hcd gpu_sched hid_sensor_hub drm_display_helper usbcore nvme mfd_core hid_generic crc32c_intel psmouse amd_sfh i2c_piix4 usb_common crc16 nvme_core r8169 i2c_hid_acpi i2c_hid hid i2c_designware_platform i2c_designware_core
[ T853] CR2: 0000000000000008
[ T853] ---[ end trace 0000000000000000 ]---
Re: patch 46/47 causes NULL pointer deref on mt7921
Am Freitag, dem 12.07.2024 um 13:06 +0200 schrieb Bert Karwatzki:
Quoted 28 lines
Am Donnerstag, dem 11.07.2024 um 18:40 -0500 schrieb Sean Wang:
Quoted 19 lines
Hi Bert,
Thanks for the detailed debug log. I've quickly made a change to fix the issue. Right now, I can't access the test environment, but I'll test it and send it out as soon as possible. Here's the patch.
drivers/net/wireless/mediatek/mt76/mt7921/main.c +1
-0@@ -303,6 +303,7 @@ mt7921_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) mvif->bss_conf.mt76.omac_idx = mvif->bss_conf.mt76.idx; mvif->phy = phy; + mvif->bss_conf.vif = mvif; mvif->bss_conf.mt76.band_idx =0 ; mvif->bss_conf.mt76.wmm_idx = mvif->bss_conf.mt76.idx %Quoted 2 lines
MT76_CONNAC_MAX_WMM_SETS;I wrote earlier that this patch works fine with linux-next-20240711 and at first it did, but then another NULL pointer error occured. I'm not sure if I can bisect this as it does not trigger automatically it seems. Also I'm currently bisecting the problem with linux-20240712
Quoted 1 line
Bert Karwatzki
Now the above mentioned NULL pointer dereference has happended again, this time on linux-next-20240716. It cann be triggered by repeatedly turning the Wifi off and on again. For further investigation I created this patch:
(quoted diff) +0 -0
b/drivers/net/wireless/mediatek/mt76/mt7921/main.c index 2e6268cb06c0..3ecedf7bc9f3 100644
drivers/net/wireless/mediatek/mt76/mt7921/main.c +0 -0
@@ -303,6 +303,8 @@ mt7921_add_interface(struct ieee80211_hw *hw, struct
ieee80211_vif *vif)
mvif->bss_conf.mt76.omac_idx = mvif->bss_conf.mt76.idx; mvif->phy = phy;
+ WARN(!phy, "%s: phy = NULL\n", __func__);
+ mvif->bss_conf.vif = mvif;
mvif->bss_conf.mt76.band_idx = 0; mvif->bss_conf.mt76.wmm_idx = mvif->bss_conf.mt76.idx %MT76_CONNAC_MAX_WMM_SETS;
@@ -1182,6 +1184,12 @@ static void mt7921_ipv6_addr_change(struct ieee80211_hw *hw,
struct inet6_dev *idev)
{
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
+ printk(KERN_INFO "%s: mvif = %px\n", __func__, mvif);
+ printk(KERN_INFO "%s: mvif->phy = %px\n", __func__, mvif->phy);
+ if (!mvif->phy) {
+ printk(KERN_INFO "%s: mvif->phy = NULL\n", __func__);
+ return;
+ }
struct mt792x_dev *dev = mvif->phy->dev;
struct inet6_ifaddr *ifa;
struct in6_addr ns_addrs[IEEE80211_BSS_ARP_ADDR_LIST_LEN];
And the result is this (the WARN in mt7921_add_interface did not trigger):
[ 367.121740] [ T861] wlp4s0: deauthenticating from 54:67:51:3d:a2:d2 by local choice (Reason: 3=DEAUTH_LEAVING) [ 367.209603] [ T861] mt7921_ipv6_addr_change: mvif = ffff954e7500de40 [ 367.209615] [ T861] mt7921_ipv6_addr_change: mvif->phy = 0000000000000000 [ 367.209621] [ T861] mt7921_ipv6_addr_change: mvif->phy = NULL [ 367.250026] [ T861] mt7921_ipv6_addr_change: mvif = ffff954e7500de40 [ 367.250034] [ T861] mt7921_ipv6_addr_change: mvif->phy = ffff954e44427768 [ 367.251537] [ T861] mt7921_ipv6_addr_change: mvif = ffff954e7500de40 [ 367.251542] [ T861] mt7921_ipv6_addr_change: mvif->phy = ffff954e44427768 [ 369.977123] [ T862] wlp4s0: authenticate with 54:67:51:3d:a2:d2 (local address=c8:94:02:c1:bd:69) [ 369.984864] [ T862] wlp4s0: send auth to 54:67:51:3d:a2:d2 (try 1/3) [ 370.006199] [ T104] wlp4s0: authenticated [ 370.006680] [ T104] wlp4s0: associate with 54:67:51:3d:a2:d2 (try 1/3) [ 370.059080] [ T98] wlp4s0: RX AssocResp from 54:67:51:3d:a2:d2 (capab=0x511 status=0 aid=2) [ 370.064067] [ T98] wlp4s0: associated
So mvif->phy can be NULL at the start of mt7921_ipv6_addr_change. The early return in that case avoids the NULL pointer and mvif->phy has its usual value again on the next call to mt7921_ipv6_addr_change so Wifi is working again. I don't know how this could happen but perhaps you have an idea.
Bert Karwatzki
Felix Fietkau
maintainerRe: patch 46/47 causes NULL pointer deref on mt7921
Quoted 86 lines · Bert Karwatzki
Am Freitag, dem 12.07.2024 um 13:06 +0200 schrieb Bert Karwatzki:
Quoted 28 lines
Am Donnerstag, dem 11.07.2024 um 18:40 -0500 schrieb Sean Wang:
Quoted 19 lines
Hi Bert,
Thanks for the detailed debug log. I've quickly made a change to fix the issue. Right now, I can't access the test environment, but I'll test it and send it out as soon as possible. Here's the patch.
drivers/net/wireless/mediatek/mt76/mt7921/main.c +1
-0@@ -303,6 +303,7 @@ mt7921_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) mvif->bss_conf.mt76.omac_idx = mvif->bss_conf.mt76.idx; mvif->phy = phy; + mvif->bss_conf.vif = mvif; mvif->bss_conf.mt76.band_idx =0 ; mvif->bss_conf.mt76.wmm_idx = mvif->bss_conf.mt76.idx %Quoted 2 lines
MT76_CONNAC_MAX_WMM_SETS;I wrote earlier that this patch works fine with linux-next-20240711 and at first it did, but then another NULL pointer error occured. I'm not sure if I can bisect this as it does not trigger automatically it seems. Also I'm currently bisecting the problem with linux-20240712
Quoted 1 line
Bert Karwatzki
Now the above mentioned NULL pointer dereference has happended again, this time on linux-next-20240716. It cann be triggered by repeatedly turning the Wifi off and on again. For further investigation I created this patch:
drivers/net/wireless/mediatek/mt76/mt7921/main.c +2
-0@@ -303,6 +303,8 @@ mt7921_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) mvif->bss_conf.mt76.omac_idx = mvif->bss_conf.mt76.idx; mvif->phy = phy; +WARN (!phy,"%s: phy = NULL\n" , __func__); + mvif->bss_conf.vif = mvif; mvif->bss_conf.mt76.band_idx =0 ; mvif->bss_conf.mt76.wmm_idx = mvif->bss_conf.mt76.idx %
MT76_CONNAC_MAX_WMM_SETS;drivers/net/wireless/mediatek/mt76/mt7921/main.c +6
-0@@ -1182,6 +1184,12 @@ static void mt7921_ipv6_addr_change(struct ieee80211_hw *hw, struct inet6_dev *idev) {struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; +printk (KERN_INFO "%s: mvif = %px\n" , __func__, mvif); +printk (KERN_INFO "%s: mvif->phy = %px\n" , __func__, mvif->phy); +if (!mvif->phy) { +printk (KERN_INFO "%s: mvif->phy = NULL\n" , __func__); +return ; + }struct mt792x_dev *dev = mvif->phy->dev;struct inet6_ifaddr *ifa;struct in6_addr ns_addrs[IEEE80211_BSS_ARP_ADDR_LIST_LEN];And the result is this (the WARN in
mt7921_add_interfacedid not trigger):[ 367.121740] [ T861] wlp4s0: deauthenticating from 54:67:51:3d:a2:d2 by local choice (Reason: 3=DEAUTH_LEAVING) [ 367.209603] [ T861] mt7921_ipv6_addr_change: mvif = ffff954e7500de40 [ 367.209615] [ T861] mt7921_ipv6_addr_change: mvif->phy = 0000000000000000 [ 367.209621] [ T861] mt7921_ipv6_addr_change: mvif->phy = NULL [ 367.250026] [ T861] mt7921_ipv6_addr_change: mvif = ffff954e7500de40 [ 367.250034] [ T861] mt7921_ipv6_addr_change: mvif->phy = ffff954e44427768 [ 367.251537] [ T861] mt7921_ipv6_addr_change: mvif = ffff954e7500de40 [ 367.251542] [ T861] mt7921_ipv6_addr_change: mvif->phy = ffff954e44427768 [ 369.977123] [ T862] wlp4s0: authenticate with 54:67:51:3d:a2:d2 (local address=c8:94:02:c1:bd:69) [ 369.984864] [ T862] wlp4s0: send auth to 54:67:51:3d:a2:d2 (try 1/3) [ 370.006199] [ T104] wlp4s0: authenticated [ 370.006680] [ T104] wlp4s0: associate with 54:67:51:3d:a2:d2 (try 1/3) [ 370.059080] [ T98] wlp4s0: RX AssocResp from 54:67:51:3d:a2:d2 (capab=0x511 status=0 aid=2) [ 370.064067] [ T98] wlp4s0: associated
Quoted 4 lines
So
mvif->phycan be NULL at the start ofmt7921_ipv6_addr_change. The early return in that case avoids the NULL pointer andmvif->phyhas its usual value again on the next call tomt7921_ipv6_addr_changeso Wifi is working again. I don't know how this could happen but perhaps you have an idea.
This change should fix it: https://nbd.name/p/0747f54f
Please test.
Thanks,
- Felix
Re: patch 46/47 causes NULL pointer deref on mt7921
Am Mittwoch, dem 17.07.2024 um 17:25 +0200 schrieb Felix Fietkau:
Quoted 95 lines · Bert Karwatzki
Quoted 86 lines
Am Freitag, dem 12.07.2024 um 13:06 +0200 schrieb Bert Karwatzki:
Quoted 28 lines
Am Donnerstag, dem 11.07.2024 um 18:40 -0500 schrieb Sean Wang:
Quoted 19 lines
Hi Bert,
Thanks for the detailed debug log. I've quickly made a change to fix the issue. Right now, I can't access the test environment, but I'll test it and send it out as soon as possible. Here's the patch.
drivers/net/wireless/mediatek/mt76/mt7921/main.c +1
-0@@ -303,6 +303,7 @@ mt7921_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) mvif->bss_conf.mt76.omac_idx = mvif->bss_conf.mt76.idx; mvif->phy = phy; + mvif->bss_conf.vif = mvif; mvif->bss_conf.mt76.band_idx =0 ; mvif->bss_conf.mt76.wmm_idx = mvif->bss_conf.mt76.idx %Quoted 2 lines
MT76_CONNAC_MAX_WMM_SETS;I wrote earlier that this patch works fine with linux-next-20240711 and at first it did, but then another NULL pointer error occured. I'm not sure if I can bisect this as it does not trigger automatically it seems. Also I'm currently bisecting the problem with linux-20240712
Quoted 1 line
Bert Karwatzki
Now the above mentioned NULL pointer dereference has happended again, this time on linux-next-20240716. It cann be triggered by repeatedly turning the Wifi off and on again. For further investigation I created this patch:
drivers/net/wireless/mediatek/mt76/mt7921/main.c +2
-0@@ -303,6 +303,8 @@ mt7921_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) mvif->bss_conf.mt76.omac_idx = mvif->bss_conf.mt76.idx; mvif->phy = phy; +WARN (!phy,"%s: phy = NULL\n" , __func__); + mvif->bss_conf.vif = mvif; mvif->bss_conf.mt76.band_idx =0 ; mvif->bss_conf.mt76.wmm_idx = mvif->bss_conf.mt76.idx %
MT76_CONNAC_MAX_WMM_SETS;drivers/net/wireless/mediatek/mt76/mt7921/main.c +6
-0@@ -1182,6 +1184,12 @@ static void mt7921_ipv6_addr_change(struct ieee80211_hw *hw, struct inet6_dev *idev) {struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; +printk (KERN_INFO "%s: mvif = %px\n" , __func__, mvif); +printk (KERN_INFO "%s: mvif->phy = %px\n" , __func__, mvif->phy); +if (!mvif->phy) { +printk (KERN_INFO "%s: mvif->phy = NULL\n" , __func__); +return ; + }struct mt792x_dev *dev = mvif->phy->dev;struct inet6_ifaddr *ifa;struct in6_addr ns_addrs[IEEE80211_BSS_ARP_ADDR_LIST_LEN];And the result is this (the WARN in
mt7921_add_interfacedid not trigger):[ 367.121740] [ T861] wlp4s0: deauthenticating from 54:67:51:3d:a2:d2 by local choice (Reason: 3=DEAUTH_LEAVING) [ 367.209603] [ T861] mt7921_ipv6_addr_change: mvif = ffff954e7500de40 [ 367.209615] [ T861] mt7921_ipv6_addr_change: mvif->phy = 0000000000000000 [ 367.209621] [ T861] mt7921_ipv6_addr_change: mvif->phy = NULL [ 367.250026] [ T861] mt7921_ipv6_addr_change: mvif = ffff954e7500de40 [ 367.250034] [ T861] mt7921_ipv6_addr_change: mvif->phy = ffff954e44427768 [ 367.251537] [ T861] mt7921_ipv6_addr_change: mvif = ffff954e7500de40 [ 367.251542] [ T861] mt7921_ipv6_addr_change: mvif->phy = ffff954e44427768 [ 369.977123] [ T862] wlp4s0: authenticate with 54:67:51:3d:a2:d2 (local address=c8:94:02:c1:bd:69) [ 369.984864] [ T862] wlp4s0: send auth to 54:67:51:3d:a2:d2 (try 1/3) [ 370.006199] [ T104] wlp4s0: authenticated [ 370.006680] [ T104] wlp4s0: associate with 54:67:51:3d:a2:d2 (try 1/3) [ 370.059080] [ T98] wlp4s0: RX AssocResp from 54:67:51:3d:a2:d2 (capab=0x511 status=0 aid=2) [ 370.064067] [ T98] wlp4s0: associatedQuoted 4 lines
So
mvif->phycan be NULL at the start ofmt7921_ipv6_addr_change. The early return in that case avoids the NULL pointer andmvif->phyhas its usual value again on the next call tomt7921_ipv6_addr_changeso Wifi is working again. I don't know how this could happen but perhaps you have an idea.This change should fix it: https://nbd.name/p/0747f54f
Please test.
Quoted 4 lines
Thanks,
- Felix
Your fix works. (I added a WARN() statement on the early return, to see if mvif-
Quoted 1 line
phy actually was NULL during testing).
Bert Karwatzki
Re: patch 46/47 causes NULL pointer deref on mt7921
Am Mittwoch, dem 17.07.2024 um 19:05 +0200 schrieb Bert Karwatzki:
Quoted 7 lines
Am
Your fix works. (I added a
WARN()statement on the early return, to see if mvif-Quoted 1 line
phy actually was NULL during testing).
Bert Karwatzki
While your fix works there was still the question why the driver is suddenly forgetting mvif->phy? So I've been testing with this script:
#!/bin/sh
for i in $(seq 1 100);
do
nmcli radio wifi off
nmcli radio wifi on
# wait for wifi
sleep 3
done
together with this patch:
(quoted diff) +0 -0
b/drivers/net/wireless/mediatek/mt76/mt7921/main.c index 4f30426afbb7..206f10473d92 100644
drivers/net/wireless/mediatek/mt76/mt7921/main.c +0 -0
@@ -1182,6 +1182,10 @@ static void mt7921_ipv6_addr_change(struct ieee80211_hw
*hw,
struct inet6_dev *idev)
{
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;+ if (!mvif->phy) {
+ WARN(1, "mvif->phy == NULL\n");
+ return;
+ }
struct mt792x_dev *dev = mvif->phy->dev;
struct inet6_ifaddr *ifa;
struct in6_addr ns_addrs[IEEE80211_BSS_ARP_ADDR_LIST_LEN];On linux-6.10 the script can be run several times without triggering a warning while on linux-next-20240716 running the script will trigger several warnings. In the end the result of a bisection is this as the first commit to trigger the warning:
commit 574e609c4e6a0843a9ed53de79e00da8fb3e7437
Author: Felix Fietkau <[email protected]> Date: Thu Jul 4 15:09:47 2024 +0200
wifi: mac80211: clear vif drv_priv after remove_interface when stopping
Avoid reusing stale driver data when an interface is brought down and up again. In order to avoid having to duplicate the memset in every single driver, do it here.
net/mac80211/iface.c +0 -0
@@ -689,8 +689,12 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data
*sdata, bool going_do
fallthrough;
default:
- if (going_down)
- drv_remove_interface(local, sdata);
+ if (!going_down)
+ break;
+ drv_remove_interface(local, sdata);
+
+ /* Clear private driver data to prevent reuse */
+ memset(sdata->vif.drv_priv, 0, local->hw.vif_data_size);
}
ieee80211_recalc_ps(local);
As this is in generic mac80211 code this could probably also affect other drivers and their ipv6_addr_change function. (which in turn could easily be fixed by an early exit when mvif->phy == NULL)
Bert Karwatzki
Re: patch 46/47 causes NULL pointer deref on mt7921
I looked more close at the call trace of the warning and it seems that the problems occur when shutting down the interface:
[ T847] Call Trace: [ T847] <TASK> [ T847] ? __warn+0x6a/0xc0 [ T847] ? mt7921_ipv6_addr_change+0x1d0/0x1f0 [mt7921_common] [ T847] ? report_bug+0x142/0x180 [ T847] ? handle_bug+0x3a/0x70 [ T847] ? exc_invalid_op+0x17/0x70 [ T847] ? asm_exc_invalid_op+0x1a/0x20 [ T847] ? mt7921_ipv6_addr_change+0x1d0/0x1f0 [mt7921_common] [ T847] ? srso_alias_return_thunk+0x5/0xfbef5 [ T847] ? __ipv6_ifa_notify+0x16f/0x4d0 [ T847] ? ieee80211_ifa6_changed+0x5e/0x70 [mac80211] [ T847] ? atomic_notifier_call_chain+0x51/0x80 [ T847] ? addrconf_ifdown.isra.0+0x43f/0x810 [ T847] ? srso_alias_return_thunk+0x5/0xfbef5 [ T847] ? addrconf_notify+0x15d/0x760 [ T847] ? __timer_delete_sync+0x70/0xd0 [ T847] ? raw_notifier_call_chain+0x43/0x60 [ T847] ? dev_close_many+0xea/0x160 [ T847] ? dev_close+0x65/0x80 [ T847] ? cfg80211_shutdown_all_interfaces+0x48/0xe0 [cfg80211] [ T847] ? cfg80211_rfkill_set_block+0x25/0x40 [cfg80211] [ T847] ? rfkill_set_block+0x8f/0x160 [rfkill] [ T847] ? rfkill_fop_write+0x14e/0x1e0 [rfkill] [ T847] ? vfs_write+0xf3/0x420 [ T847] ? srso_alias_return_thunk+0x5/0xfbef5 [ T847] ? ksys_write+0xae/0xe0 [ T847] ? do_syscall_64+0x5f/0x170 [ T847] ? entry_SYSCALL_64_after_hwframe+0x55/0x5d [ T847] </TASK> [ T847] ---[ end trace 0000000000000000 ]---
I think there's a race happening on shutdown between ipv6_addr_change (which uses mvif->phy) and ieee80211_do_stop (which zeros the private data including mvif->phy).
Bert Karwatzki
Re: patch 46/47 causes NULL pointer deref on mt7921
In reply to Bert KarwatzkiI looked more close at the call trace of the warning and it seems that the problems
occur when shutting down the interface:
[ T847] Call Trace: [ T847] <TASK> [ T847] ? __warn+0x6a/0xc0 [ T847] ? mt7921_ipv6_addr_change+0x1d0/0x1f0 [mt7921_common] [ T847] ? report_bug+0x142/0x180 [ T847] ? handle_bug+0x3a/0x70 [ T847] ? exc_invalid_op+0x17/0x70 [ T847] ? asm_exc_invalid_op+0x1a/0x20 [ T847] ? mt7921_ipv6_addr_change+0x1d0/0x1f0 [mt7921_common] [ T847] ? srso_alias_return_thunk+0x5/0xfbef5 [ T847] ? __ipv6_ifa_notify+0x16f/0x4d0 [ T847] ? ieee80211_ifa6_changed+0x5e/0x70 [mac80211] [ T847] ? atomic_notifier_call_chain+0x51/0x80 [ T847] ? addrconf_ifdown.isra.0+0x43f/0x810 [ T847] ? srso_alias_return_thunk+0x5/0xfbef5 [ T847] ? addrconf_notify+0x15d/0x760 [ T847] ? __timer_delete_sync+0x70/0xd0 [ T847] ? raw_notifier_call_chain+0x43/0x60 [ T847] ? dev_close_many+0xea/0x160 [ T847] ? dev_close+0x65/0x80 [ T847] ? cfg80211_shutdown_all_interfaces+0x48/0xe0 [cfg80211] [ T847] ? cfg80211_rfkill_set_block+0x25/0x40 [cfg80211] [ T847] ? rfkill_set_block+0x8f/0x160 [rfkill] [ T847] ? rfkill_fop_write+0x14e/0x1e0 [rfkill] [ T847] ? vfs_write+0xf3/0x420 [ T847] ? srso_alias_return_thunk+0x5/0xfbef5 [ T847] ? ksys_write+0xae/0xe0 [ T847] ? do_syscall_64+0x5f/0x170 [ T847] ? entry_SYSCALL_64_after_hwframe+0x55/0x5d [ T847] </TASK> [ T847] ---[ end trace 0000000000000000 ]---
I think there's a race happening on shutdown between ipv6_addr_change (which uses mvif->phy)
and ieee80211_do_stop (which zeros the private data including mvif->phy).
Resend with fixed formatting.
Bert Karwatzki
Re: patch 46/47 causes NULL pointer deref on mt7921
In reply to Felix FietkauAm Mittwoch, dem 17.07.2024 um 17:25 +0200 schrieb Felix Fietkau:
Quoted 95 lines · Bert Karwatzki
Quoted 86 lines
Am Freitag, dem 12.07.2024 um 13:06 +0200 schrieb Bert Karwatzki:
Quoted 28 lines
Am Donnerstag, dem 11.07.2024 um 18:40 -0500 schrieb Sean Wang:
Quoted 19 lines
Hi Bert,
Thanks for the detailed debug log. I've quickly made a change to fix the issue. Right now, I can't access the test environment, but I'll test it and send it out as soon as possible. Here's the patch.
drivers/net/wireless/mediatek/mt76/mt7921/main.c +1
-0@@ -303,6 +303,7 @@ mt7921_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) mvif->bss_conf.mt76.omac_idx = mvif->bss_conf.mt76.idx; mvif->phy = phy; + mvif->bss_conf.vif = mvif; mvif->bss_conf.mt76.band_idx =0 ; mvif->bss_conf.mt76.wmm_idx = mvif->bss_conf.mt76.idx %Quoted 2 lines
MT76_CONNAC_MAX_WMM_SETS;I wrote earlier that this patch works fine with linux-next-20240711 and at first it did, but then another NULL pointer error occured. I'm not sure if I can bisect this as it does not trigger automatically it seems. Also I'm currently bisecting the problem with linux-20240712
Quoted 1 line
Bert Karwatzki
Now the above mentioned NULL pointer dereference has happended again, this time on linux-next-20240716. It cann be triggered by repeatedly turning the Wifi off and on again. For further investigation I created this patch:
drivers/net/wireless/mediatek/mt76/mt7921/main.c +2
-0@@ -303,6 +303,8 @@ mt7921_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) mvif->bss_conf.mt76.omac_idx = mvif->bss_conf.mt76.idx; mvif->phy = phy; +WARN (!phy,"%s: phy = NULL\n" , __func__); + mvif->bss_conf.vif = mvif; mvif->bss_conf.mt76.band_idx =0 ; mvif->bss_conf.mt76.wmm_idx = mvif->bss_conf.mt76.idx %
MT76_CONNAC_MAX_WMM_SETS;drivers/net/wireless/mediatek/mt76/mt7921/main.c +6
-0@@ -1182,6 +1184,12 @@ static void mt7921_ipv6_addr_change(struct ieee80211_hw *hw, struct inet6_dev *idev) {struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; +printk (KERN_INFO "%s: mvif = %px\n" , __func__, mvif); +printk (KERN_INFO "%s: mvif->phy = %px\n" , __func__, mvif->phy); +if (!mvif->phy) { +printk (KERN_INFO "%s: mvif->phy = NULL\n" , __func__); +return ; + }struct mt792x_dev *dev = mvif->phy->dev;struct inet6_ifaddr *ifa;struct in6_addr ns_addrs[IEEE80211_BSS_ARP_ADDR_LIST_LEN];And the result is this (the WARN in
mt7921_add_interfacedid not trigger):[ 367.121740] [ T861] wlp4s0: deauthenticating from 54:67:51:3d:a2:d2 by local choice (Reason: 3=DEAUTH_LEAVING) [ 367.209603] [ T861] mt7921_ipv6_addr_change: mvif = ffff954e7500de40 [ 367.209615] [ T861] mt7921_ipv6_addr_change: mvif->phy = 0000000000000000 [ 367.209621] [ T861] mt7921_ipv6_addr_change: mvif->phy = NULL [ 367.250026] [ T861] mt7921_ipv6_addr_change: mvif = ffff954e7500de40 [ 367.250034] [ T861] mt7921_ipv6_addr_change: mvif->phy = ffff954e44427768 [ 367.251537] [ T861] mt7921_ipv6_addr_change: mvif = ffff954e7500de40 [ 367.251542] [ T861] mt7921_ipv6_addr_change: mvif->phy = ffff954e44427768 [ 369.977123] [ T862] wlp4s0: authenticate with 54:67:51:3d:a2:d2 (local address=c8:94:02:c1:bd:69) [ 369.984864] [ T862] wlp4s0: send auth to 54:67:51:3d:a2:d2 (try 1/3) [ 370.006199] [ T104] wlp4s0: authenticated [ 370.006680] [ T104] wlp4s0: associate with 54:67:51:3d:a2:d2 (try 1/3) [ 370.059080] [ T98] wlp4s0: RX AssocResp from 54:67:51:3d:a2:d2 (capab=0x511 status=0 aid=2) [ 370.064067] [ T98] wlp4s0: associatedQuoted 4 lines
So
mvif->phycan be NULL at the start ofmt7921_ipv6_addr_change. The early return in that case avoids the NULL pointer andmvif->phyhas its usual value again on the next call tomt7921_ipv6_addr_changeso Wifi is working again. I don't know how this could happen but perhaps you have an idea.This change should fix it: https://nbd.name/p/0747f54f
Please test.
Quoted 4 lines
Thanks,
- Felix
The BUG is still present in linux-6.11-rc1.
Bert Karwatzki
Re: patch 46/47 causes NULL pointer deref on mt7921
Quoted 9 lines · Bert Karwatzki
Am Mittwoch, dem 17.07.2024 um 17:25 +0200 schrieb Felix Fietkau:
Quoted 7 lines · Bert Karwatzki
Quoted 5 lines
So
mvif->phycan be NULL at the start ofmt7921_ipv6_addr_change. The early return in that case avoids the NULL pointer andmvif->phyhas its usual value again on the next call tomt7921_ipv6_addr_changeso Wifi is working again. I don't know how this could happen but perhaps you have an idea.
Quoted 4 lines
Quoted 2 lines
This change should fix it: https://nbd.name/p/0747f54f
Please test.The BUG is still present in linux-6.11-rc1.
I'm not sure what's the status with this. There's one mt76 patch going to v6.11-rc2:
But that looks to be a fix for a different problem, right? Felix, are you planning to submit that 0747f54f as a proper patch? I could then take it to wireless tree.
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Re: patch 46/47 causes NULL pointer deref on mt7921
Am Mittwoch, dem 31.07.2024 um 11:51 +0300 schrieb Kalle Valo:
Quoted 16 lines
Quoted 9 lines · Bert Karwatzki
Am Mittwoch, dem 17.07.2024 um 17:25 +0200 schrieb Felix Fietkau:
Quoted 7 lines · Bert Karwatzki
Quoted 5 lines
So
mvif->phycan be NULL at the start ofmt7921_ipv6_addr_change. The early return in that case avoids the NULL pointer andmvif->phyhas its usual value again on the next call tomt7921_ipv6_addr_changeso Wifi is working again. I don't know how this could happen but perhaps you have an idea.Quoted 4 lines
Quoted 2 lines
This change should fix it: https://nbd.name/p/0747f54f
Please test.The BUG is still present in linux-6.11-rc1.
Quoted 9 lines
I'm not sure what's the status with this. There's one mt76 patch going to v6.11-rc2:
But that looks to be a fix for a different problem, right? Felix, are you planning to submit that
0747f54fas a proper patch? I could then take it to wireless tree.
The Bug is still present in linux-6.11-rc2 and linux-next-20240806. Also the mvif->phy NULL check in the original patch is not neccessary (and feels a little out of place as mvif->phy is not needed anymore). This patch is sufficient to fix the NULL pointer dereference:
(quoted diff) +0 -0
b/drivers/net/wireless/mediatek/mt76/mt7921/main.c index 1bab93d049df..23b228804289 100644
drivers/net/wireless/mediatek/mt76/mt7921/main.c +0 -0
@@ -1183,7 +1183,7 @@ static void mt7921_ipv6_addr_change(struct ieee80211_hw
*hw,
struct inet6_dev *idev)
{
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
- struct mt792x_dev *dev = mvif->phy->dev;
+ struct mt792x_dev *dev = mt792x_hw_dev(hw);
struct inet6_ifaddr *ifa;
struct in6_addr ns_addrs[IEEE80211_BSS_ARP_ADDR_LIST_LEN];
struct sk_buff *skb;Bert Karwatzki
Re: patch 46/47 causes NULL pointer deref on mt7921
Am Dienstag, dem 06.08.2024 um 13:22 +0200 schrieb Bert Karwatzki:
Quoted 46 lines
Am Mittwoch, dem 31.07.2024 um 11:51 +0300 schrieb Kalle Valo:
Quoted 16 lines
Quoted 9 lines · Bert Karwatzki
Am Mittwoch, dem 17.07.2024 um 17:25 +0200 schrieb Felix Fietkau:
Quoted 7 lines · Bert Karwatzki
Quoted 5 lines
So
mvif->phycan be NULL at the start ofmt7921_ipv6_addr_change. The early return in that case avoids the NULL pointer andmvif->phyhas its usual value again on the next call tomt7921_ipv6_addr_changeso Wifi is working again. I don't know how this could happen but perhaps you have an idea.Quoted 4 lines
Quoted 2 lines
This change should fix it: https://nbd.name/p/0747f54f
Please test.The BUG is still present in linux-6.11-rc1.
Quoted 9 lines
I'm not sure what's the status with this. There's one mt76 patch going to v6.11-rc2:
But that looks to be a fix for a different problem, right? Felix, are you planning to submit that
0747f54fas a proper patch? I could then take it to wireless tree.The Bug is still present in linux-6.11-rc2 and linux-next-20240806. Also the
mvif->phyNULL check in the original patch is not neccessary (and feels a little out of place asmvif->phyis not needed anymore). This patch is sufficient to fix the NULL pointer dereference:drivers/net/wireless/mediatek/mt76/mt7921/main.c +1
-1@@ -1183,7 +1183,7 @@ static void mt7921_ipv6_addr_change(struct ieee80211_hw *hw, struct inet6_dev *idev) {struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; -struct mt792x_dev *dev = mvif->phy->dev; +struct mt792x_dev *dev =mt792x_hw_dev (hw);struct inet6_ifaddr *ifa;struct in6_addr ns_addrs[IEEE80211_BSS_ARP_ADDR_LIST_LEN ];struct sk_buff *skb;
Quoted 1 line
Bert Karwatzki
This error is still present in v6.11-rc3.
Bert Karwatzki
Re: patch 46/47 causes NULL pointer deref on mt7921
Quoted 49 lines · Bert Karwatzki
Am Dienstag, dem 06.08.2024 um 13:22 +0200 schrieb Bert Karwatzki:
Quoted 48 lines
Am Mittwoch, dem 31.07.2024 um 11:51 +0300 schrieb Kalle Valo:
Quoted 18 lines
Quoted 11 lines · Bert Karwatzki
Am Mittwoch, dem 17.07.2024 um 17:25 +0200 schrieb Felix Fietkau:
Quoted 9 lines · Bert Karwatzki
Quoted 7 lines
So
mvif->phycan be NULL at the start ofmt7921_ipv6_addr_change. The early return in that case avoids the NULL pointer andmvif->phy
has its usual value
again on the next call tomt7921_ipv6_addr_changeso Wifi is working again. I
don't know how this could happen but perhaps you have an idea.Quoted 4 lines
Quoted 2 lines
This change should fix it: https://nbd.name/p/0747f54f
Please test.The BUG is still present in linux-6.11-rc1.
Quoted 9 lines
I'm not sure what's the status with this. There's one mt76 patch going to v6.11-rc2:
But that looks to be a fix for a different problem, right? Felix, are you planning to submit that
0747f54fas a proper patch? I could then take it to wireless tree.The Bug is still present in linux-6.11-rc2 and linux-next-20240806. Also the
mvif->phyNULL check in the original patch is not neccessary (and feels a little out of place asmvif->phyis not needed anymore). This patch is sufficient to fix the NULL pointer dereference:drivers/net/wireless/mediatek/mt76/mt7921/main.c +1
-1@@ -1183,7 +1183,7 @@ static void mt7921_ipv6_addr_change(struct ieee80211_hw *hw, struct inet6_dev *idev) {struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; -struct mt792x_dev *dev = mvif->phy->dev; +struct mt792x_dev *dev =mt792x_hw_dev (hw);struct inet6_ifaddr *ifa;struct in6_addr ns_addrs[IEEE80211_BSS_ARP_ADDR_LIST_LEN ];struct sk_buff *skb;
Quoted 3 lines
Quoted 1 line
Bert Karwatzki
This error is still present in v6.11-rc3.
Bert, can you send your fix as a proper patch? More information in the wiki below and please mark it for wireless tree.
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Re: [PATCH 46/47] wifi: mt76: mt7925: add mt7925_mac_link_bss_remove to remove per-link BSS
In reply to [email protected]Since linux-next-20240711 my linux system fails to start with a NULL pointer error. Hardware: MSI Alpha 15 Laptop Ryzen 5800H with
04:00.0 Network controller: MEDIATEK Corp. MT7921K (RZ608) Wi-Fi 6E 80MHz
[ T843] BUG: unable to handle page fault for address: ffffffffffffffa0 [ T843] #PF: supervisor read access in kernel mode [ T843] #PF: error_code(0x0000) - not-present page [ T843] PGD e5c81a067 P4D e5c81a067 PUD e5c81c067 PMD 0 [ T843] Oops: Oops: 0000 [#1] PREEMPT SMP NOPTI [ T843] CPU: 2 UID: 0 PID: 843 Comm: NetworkManager Not tainted 6.10.0-rc7-next-20240711-dirty #9 [ T843] Hardware name: Micro-Star International Co., Ltd. Alpha 15 B5EEK/MS-158L, BIOS E158LAMS.107 11/10/2021 [ T843] RIP: 0010:mt792x_mac_link_bss_remove+0x24/0x110 [mt792x_lib] [ T843] Code: 84 00 00 00 00 00 f3 0f 1e fa 41 56 41 55 41 54 49 89 f4 55 48 89 fd 53 48 8b 46 18 48 89 d3 44 0f b7 aa b8 00 00 00 8b 56 60 <66> 83 78 a0 00 74 0f 83 fa 0e 77 0a 4c 8b b4 d0 28 ff ff ff eb 07 [ T843] RSP: 0018:ffffbc1b43b3b688 EFLAGS: 00010282 [ T843] RAX: 0000000000000000 RBX: ffff906ab80a9f00 RCX: 000fffffffe00000 [ T843] RDX: 0000000000000000 RSI: ffff906ab80a9e20 RDI: ffff9069c1712000 [ T843] RBP: ffff9069c1712000 R08: ffff9069c0402018 R09: ffffffffab226720 [ T843] R10: 0000000000000000 R11: 0000000000000000 R12: ffff906ab80a9e20 [ T843] R13: 0000000000000013 R14: 0000000000000000 R15: ffff906ab80a9990 [ T843] FS: 00007fb2edd7b500(0000) GS:ffff90786e680000(0000) knlGS:0000000000000000 [ T843] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ T843] CR2: ffffffffffffffa0 CR3: 000000010a104000 CR4: 0000000000750ef0 [ T843] PKRU: 55555554 [ T843] Call Trace: [ T843] <TASK> [ T843] ? __die+0x1e/0x60 [ T843] ? page_fault_oops+0x157/0x450 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? search_bpf_extables+0x5a/0x80 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? exc_page_fault+0x2bb/0x670 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? lock_timer_base+0x71/0x90 [ T843] ? asm_exc_page_fault+0x26/0x30 [ T843] ? mt792x_mac_link_bss_remove+0x24/0x110 [mt792x_lib] [ T843] ? mt792x_remove_interface+0x6e/0x90 [mt792x_lib] [ T843] ? ieee80211_do_stop+0x507/0x7e0 [mac80211] [ T843] ? ieee80211_stop+0x53/0x190 [mac80211] [ T843] ? __dev_close_many+0xa5/0x120 [ T843] ? __dev_change_flags+0x18c/0x220 [ T843] ? dev_change_flags+0x21/0x60 [ T843] ? do_setlink+0xdf9/0x11d0 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? security_sock_rcv_skb+0x33/0x50 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? __nla_validate_parse+0x61/0xd10 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? genl_done+0x53/0x80 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? netlink_dump+0x357/0x410 [ T843] ? __rtnl_newlink+0x5d6/0x980 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? genl_family_rcv_msg_dumpit+0xdf/0xf0 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? __kmalloc_cache_noprof+0x44/0x210 [ T843] ? rtnl_newlink+0x42/0x60 [ T843] ? rtnetlink_rcv_msg+0x152/0x3f0 [ T843] ? mptcp_pm_nl_dump_addr+0x180/0x180 [ T843] ? rtnl_calcit.isra.0+0x130/0x130 [ T843] ? netlink_rcv_skb+0x56/0x100 [ T843] ? netlink_unicast+0x199/0x290 [ T843] ? netlink_sendmsg+0x21d/0x490 [ T843] ? __sock_sendmsg+0x78/0x80 [ T843] ? ____sys_sendmsg+0x23f/0x2e0 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? copy_msghdr_from_user+0x68/0xa0 [ T843] ? ___sys_sendmsg+0x81/0xd0 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? crng_fast_key_erasure+0xbc/0xf0 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? get_random_bytes_user+0x126/0x140 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? __fdget+0xb1/0xe0 [ T843] ? __sys_sendmsg+0x56/0xa0 [ T843] ? srso_alias_return_thunk+0x5/0xfbef5 [ T843] ? do_syscall_64+0x5f/0x170 [ T843] ? entry_SYSCALL_64_after_hwframe+0x55/0x5d [ T843] </TASK> [ T843] Modules linked in: bnep nls_ascii nls_cp437 vfat fat snd_ctl_led snd_hda_codec_realtek snd_hda_codec_generic snd_hda_scodec_component snd_hda_codec_hdmi btusb btrtl btintel snd_hda_intel uvcvideo btbcm snd_intel_dspcfg btmtk snd_hda_codec snd_soc_dmic snd_acp3x_pdm_dma snd_acp3x_rn videobuf2_vmalloc snd_hwdep uvc bluetooth videobuf2_memops snd_soc_core snd_hda_core videobuf2_v4l2 snd_pcm_oss snd_mixer_oss videodev snd_pcm snd_rn_pci_acp3x videobuf2_common snd_acp_config snd_timer msi_wmi snd_soc_acpi ecdh_generic amd_atl mc ecc sparse_keymap edac_mce_amd wmi_bmof snd ccp k10temp snd_pci_acp3x soundcore ac battery button hid_sensor_prox hid_sensor_gyro_3d hid_sensor_als hid_sensor_accel_3d hid_sensor_magn_3d hid_sensor_trigger industrialio_triggered_buffer joydev kfifo_buf industrialio amd_pmc hid_sensor_iio_common evdev hid_multitouch serio_raw mt7921e mt7921_common mt792x_lib mt76_connac_lib mt76 mac80211 libarc4 cfg80211 rfkill msr fuse nvme_fabrics configfs efi_pstore efivarfs autofs4 ext4 [ T843] crc32c_generic mbcache jbd2 usbhid amdgpu i2c_algo_bit drm_ttm_helper xhci_pci ttm drm_exec drm_suballoc_helper xhci_hcd amdxcp drm_buddy hid_sensor_hub usbcore nvme gpu_sched mfd_core hid_generic crc32c_intel psmouse drm_display_helper amd_sfh i2c_piix4 usb_common nvme_core crc16 r8169 i2c_hid_acpi i2c_hid hid i2c_designware_platform i2c_designware_core [ T843] CR2: ffffffffffffffa0 [ T843] ---[ end trace 0000000000000000 ]---
I bisected the error between linux-6.10-rc7 and linux-next-20240711 and the first offending commit which showed a NULL pointer error was
https://lore.kernel.org/all/[email protected]/
but the error is actually a different but most likely related NULL pointer error. To debug this I added some printk to the offending commit:
drivers/net/wireless/mediatek/mt76/mt792x.h +2 -0
@@ -230,6 +230,7 @@ mt792x_vif_to_link(struct mt792x_vif *mvif, u8 link_id)struct ieee80211_vif *vif; vif = container_of((void *)mvif, struct ieee80211_vif, drv_priv); +printk (KERN_INFO "%s %d: vif = %px\n" , __func__, __LINE__, vif);if (!ieee80211_vif_is_mld (vif) || link_id >=IEEE80211_LINK_UNSPECIFIED )
@@ -259,6 +260,7 @@ mt792x_link_conf_to_mconf(struct ieee80211_bss_conf *link_conf) {struct ieee80211_vif *vif = link_conf->vif;struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; +printk (KERN_INFO "%s %d: vif = %px mvif = %px\n" , __func__, __LINE__, vif, mvif);return mt792x_vif_to_link (mvif, link_conf->link_id); }
drivers/net/wireless/mediatek/mt76/mt792x_core.c +13 -0
@@ -119,23 +119,34 @@ static void mt792x_mac_link_bss_remove(struct mt792x_dev *dev, {struct mt792x_bss_conf *mconf =mt792x_link_conf_to_mconf (link_conf);int idx = mlink->wcid.idx; +printk (KERN_INFO "%s %d\n" , __func__, __LINE__);mt792x_mutex_acquire (dev); +printk (KERN_INFO "%s %d\n" , __func__, __LINE__);mt76_connac_free_pending_tx_skbs (&dev->pm, &mlink->wcid); +printk (KERN_INFO "%s %d\n" , __func__, __LINE__);mt76_connac_mcu_uni_add_dev (&dev->mphy, link_conf, &mlink->wcid, false); +printk (KERN_INFO "%s %d\n" , __func__, __LINE__);rcu_assign_pointer (dev->mt76.wcid[idx],NULL ); +printk (KERN_INFO "%s %d\n" , __func__, __LINE__); dev->mt76.vif_mask &= ~BIT_ULL (mconf->mt76.idx); +printk (KERN_INFO "%s %d: mconf->vif = %px\n" , __func__, __LINE__, mconf->vif); mconf->vif->phy->omac_mask &= ~BIT_ULL (mconf->mt76.omac_idx); +printk (KERN_INFO "%s %d\n" , __func__, __LINE__);mt792x_mutex_release (dev); +printk (KERN_INFO "%s %d\n" , __func__, __LINE__);spin_lock_bh (&dev->mt76.sta_poll_lock); +printk (KERN_INFO "%s %d\n" , __func__, __LINE__);if (!list_empty (&mlink->wcid.poll_list))list_del_init (&mlink->wcid.poll_list);spin_unlock_bh (&dev->mt76.sta_poll_lock); +printk (KERN_INFO "%s %d\n" , __func__, __LINE__);mt76_wcid_cleanup (&dev->mt76, &mlink->wcid); +printk (KERN_INFO "%s %d\n" , __func__, __LINE__); } void mt792x_remove_interface(struct ieee80211_hw *hw,
@@ -143,6 +154,8 @@ void mt792x_remove_interface(struct ieee80211_hw *hw, {struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;struct mt792x_dev *dev =mt792x_hw_dev (hw); +printk (KERN_INFO "%s %d: hw = %px vif = %px mvif = %px dev = %px\n" , + __func__, __LINE__, hw, vif, mvif, dev);mt792x_mac_link_bss_remove (dev, &vif->bss_conf, &mvif->sta.deflink); }
With these I get the following error message on startup:
[ T858] mt792x_remove_interface 157: hw = ffff92dc11560900 vif = ffff92dbe072d970 mvif = ffff92dbe072de00 dev = ffff92dc11562000 [ T858] mt792x_link_conf_to_mconf 263: vif = ffff92dbe072d970 mvif = ffff92dbe072de00 [ T858] mt792x_vif_to_link 233: vif = ffff92dbe072d970 [ T858] mt792x_mac_link_bss_remove 122 [ T858] mt792x_mac_link_bss_remove 125 [ T858] mt792x_mac_link_bss_remove 127 [ T858] mt792x_mac_link_bss_remove 129 [ T858] mt792x_mac_link_bss_remove 132 [ T858] mt792x_mac_link_bss_remove 135: mconf->vif = 0000000000000000 [ T858] BUG: kernel NULL pointer dereference, address: 00000000000004b8 [ T858] #PF: supervisor read access in kernel mode [ T858] #PF: error_code(0x0000) - not-present page [ T858] PGD 0 P4D 0 [ T858] Oops: Oops: 0000 [#1] PREEMPT SMP NOPTI [ T858] CPU: 0 PID: 858 Comm: NetworkManager Not tainted 6.10.0-rc5-debug-01238-g1541d63c5fe2-dirty #30 [ T858] Hardware name: Micro-Star International Co., Ltd. Alpha 15 B5EEK/MS-158L, BIOS E158LAMS.107 11/10/2021 [ T858] RIP: 0010:mt792x_remove_interface+0x1df/0x2e0 [mt792x_lib] [ T858] Code: 85 f0 30 00 00 49 8b 4f 18 e8 5d 4f f0 f7 49 8b 47 18 41 0f b6 4f 01 ba 89 00 00 00 48 c7 c6 90 24 05 c1 48 c7 c7 36 33 05 c1 <48> 8b 80 b8 04 00 00 49 d3 e4 49 f7 d4 4c 21 a0 10 27 00 00 4c 8d [ T858] RSP: 0018:ffff9fcf03db7698 EFLAGS: 00010246 [ T858] RAX: 0000000000000000 RBX: ffff92dbe072d970 RCX: 0000000000000000 [ T858] RDX: 0000000000000089 RSI: ffffffffc1052490 RDI: ffffffffc1053336 [ T858] RBP: ffff92dc11562000 R08: 0000000000000000 R09: 0000000000000003 [ T858] R10: ffff9fcf03db7550 R11: ffffffffba099d28 R12: 0000000000000001 [ T858] R13: ffff92dbe072ded8 R14: ffff92dc1156a150 R15: ffff92dbe072de00 [ T858] FS: 00007fa13c515500(0000) GS:ffff92ea6e600000(0000) knlGS:0000000000000000 [ T858] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ T858] CR2: 00000000000004b8 CR3: 00000001046a2000 CR4: 0000000000750ef0 [ T858] PKRU: 55555554 [ T858] Call Trace: [ T858] <TASK> [ T858] ? __die+0x1e/0x60 [ T858] ? page_fault_oops+0x157/0x450 [ T858] ? _prb_read_valid+0x273/0x2e0 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? exc_page_fault+0x331/0x670 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? prb_read_valid+0x16/0x20 [ T858] ? asm_exc_page_fault+0x26/0x30 [ T858] ? mt792x_remove_interface+0x1df/0x2e0 [mt792x_lib] [ T858] ? mt792x_remove_interface+0x1c3/0x2e0 [mt792x_lib] [ T858] ? ieee80211_do_stop+0x507/0x7e0 [mac80211] [ T858] ? ieee80211_stop+0x53/0x190 [mac80211] [ T858] ? __dev_close_many+0xa5/0x120 [ T858] ? __dev_change_flags+0x18c/0x220 [ T858] ? dev_change_flags+0x21/0x60 [ T858] ? do_setlink+0xdf9/0x11d0 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? __kmalloc_large_node+0x7e/0xb0 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? security_sock_rcv_skb+0x33/0x50 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? __nla_validate_parse+0x61/0xd10 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? genl_done+0x53/0x80 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? netlink_dump+0x357/0x410 [ T858] ? __rtnl_newlink+0x5d1/0x980 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? genl_family_rcv_msg_dumpit+0xdf/0xf0 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? kmalloc_trace_noprof+0x44/0x210 [ T858] ? rtnl_newlink+0x42/0x60 [ T858] ? rtnetlink_rcv_msg+0x14d/0x3f0 [ T858] ? mptcp_pm_nl_dump_addr+0x180/0x180 [ T858] ? rtnl_calcit.isra.0+0x130/0x130 [ T858] ? netlink_rcv_skb+0x56/0x100 [ T858] ? netlink_unicast+0x199/0x290 [ T858] ? netlink_sendmsg+0x21d/0x490 [ T858] ? __sock_sendmsg+0x78/0x80 [ T858] ? ____sys_sendmsg+0x23f/0x2e0 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? copy_msghdr_from_user+0x68/0xa0 [ T858] ? ___sys_sendmsg+0x81/0xd0 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? crng_fast_key_erasure+0xbc/0xf0 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? get_random_bytes_user+0x126/0x140 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? __fdget+0xb1/0xe0 [ T858] ? __sys_sendmsg+0x56/0xa0 [ T858] ? srso_alias_return_thunk+0x5/0xfbef5 [ T858] ? do_syscall_64+0x5f/0x170 [ T858] ? entry_SYSCALL_64_after_hwframe+0x55/0x5d [ T858] </TASK> [ T858] Modules linked in: cmac bnep nls_ascii nls_cp437 vfat fat snd_ctl_led snd_hda_codec_realtek snd_hda_codec_generic snd_hda_scodec_component btusb snd_hda_codec_hdmi btrtl btintel btbcm btmtk snd_hda_intel amd_atl snd_intel_dspcfg bluetooth snd_acp3x_pdm_dma snd_soc_dmic snd_acp3x_rn snd_hda_codec uvcvideo snd_soc_core videobuf2_vmalloc uvc snd_hwdep videobuf2_memops videobuf2_v4l2 snd_hda_core videodev snd_pcm_oss snd_mixer_oss snd_pcm snd_rn_pci_acp3x snd_acp_config videobuf2_common snd_timer msi_wmi snd_soc_acpi ecdh_generic ecc mc sparse_keymap edac_mce_amd snd wmi_bmof k10temp ccp snd_pci_acp3x soundcore battery ac button joydev hid_sensor_magn_3d hid_sensor_gyro_3d hid_sensor_als hid_sensor_accel_3d hid_sensor_prox hid_sensor_trigger industrialio_triggered_buffer kfifo_buf industrialio amd_pmc hid_sensor_iio_common evdev hid_multitouch serio_raw mt7921e mt7921_common mt792x_lib mt76_connac_lib mt76 mac80211 libarc4 cfg80211 rfkill msr fuse nvme_fabrics efi_pstore configfs efivarfs autofs4 ext4 [ T858] crc32c_generic crc16 mbcache jbd2 usbhid amdgpu i2c_algo_bit xhci_pci drm_ttm_helper ttm xhci_hcd drm_exec drm_suballoc_helper amdxcp nvme drm_buddy hid_sensor_hub usbcore gpu_sched nvme_core mfd_core hid_generic crc32c_intel psmouse amd_sfh i2c_piix4 usb_common t10_pi drm_display_helper r8169 i2c_hid_acpi i2c_hid hid i2c_designware_platform i2c_designware_core [ T858] CR2: 00000000000004b8 [ T858] ---[ end trace 0000000000000000 ]---
So the problem is here that mconf->vif is still NULL probably because on mt7921 nobody is bothering to set it.
I did a similar investigation for the error in linux-next-20240711
void mt792x_mac_link_bss_remove(struct mt792x_dev *dev,
struct mt792x_bss_conf *mconf, struct mt792x_link_sta *mlink)
{
struct ieee80211_vif *vif = container_of((void *)mconf->vif,
struct ieee80211_vif, drv_priv);
struct ieee80211_bss_conf *link_conf;
int idx = mlink->wcid.idx;
printk(KERN_INFO "%s %d: dev = %px mconf = %px mlink = %px vif = %px\n",
__func__, __LINE__, dev, mconf, mlink, vif);
link_conf = mt792x_vif_to_bss_conf(vif, mconf->link_id);This leads to the following message on startup
[ T848] mt792x_mac_link_bss_remove 147: dev = ffff9403c1672000 mconf = ffff9403c1a35e20 mlink = ffff9403c1a35f00 vif = fffffffffffffb70 [ T848] BUG: unable to handle page fault for address: ffffffffffffffa0 [ T848] #PF: supervisor read access in kernel mode [ T848] #PF: error_code(0x0000) - not-present page
[skipped backtrace]
showing that vif is an invalid (though not NULL) pointer here, too.
The mt7925_ops struct contains these four ieee80211_ops which are not present in the mt7921_ops struct. In mt7925_change_vif_links mconf->vif is set.
from drivers/net/wireless/mediatek/mt76/mt7925/main.c:
.vif_cfg_changed = mt7925_vif_cfg_changed, .link_info_changed = mt7925_link_info_changed, .change_vif_links = mt7925_change_vif_links, .change_sta_links = mt7925_change_sta_links,
So I think you're probably breaking generic code (i. e. code that is also used on mt7921) with mt7925 specific changes.
(resend with fixed subject)
Bert Karwatzki
PATCH 47/47 wifi: mt76: mt7925: simpify mt7925_mcu_sta_cmd logic by removing fw_offload
In reply to [email protected]From: Sean Wang <[email protected]>
The mt7925 only supports offload firmware making the fw_offload check redundant. This update simplifies the logic in "mt7925_mcu_sta_cmd" by removing the unnecessary check for fw_offoad.
--- drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +1 -1
@@ -1643,7 +1643,7 @@ mt7925_mcu_sta_cmd(struct mt76_phy *phy,if (IS_ERR (skb))return PTR_ERR (skb); -if (info->link_sta || !info->offload_fw) +if (info->link_sta)mt76_connac_mcu_sta_basic_tlv (dev, skb, info->vif, info->link_sta, info->enable, info->newly);
Signature · 1 line
2.34.1