wifi: mt76: mt7921: skip the ND offload update of a vif not in the driver
Subsystems (2)
Felix Fietkau
maintainerPATCH 1/20 wifi: mt76: mt7921: skip the ND offload update of a vif not in the driver
mac80211 also reports an IPv6 address change of a station interface that is down, whose drv_priv ieee80211_do_stop() cleared. mt7921_ipv6_addr_change() then queues the ND offload addresses for bss_idx 0, which can be the BSS of another interface.
Skip the update while the interface is not added to the driver.
--- drivers/net/wireless/mediatek/mt76/mt7921/main.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7921/main.c +3 -0
@@ -1257,6 +1257,9 @@ static void mt7921_ipv6_addr_change(struct ieee80211_hw *hw, }, }; +if (!mvif->phy) +return ; +read_lock_bh (&idev->lock);list_for_each_entry (ifa, &idev->addr_list, if_list) {if (ifa->flags &IFA_F_TENTATIVE )
Signature · 1 line
2.47.3
Felix Fietkau
maintainerPATCH 2/20 wifi: mt76: mt7925: skip the ND offload update of a vif not in the driver
mac80211 also reports an IPv6 address change of a station interface that is down, whose drv_priv ieee80211_do_stop() cleared. For an interface without MLO, __mt7925_ipv6_addr_change() then queues the ND offload addresses for bss_idx 0, which can be the BSS of another interface.
Skip the update while the interface is not added to the driver.
--- drivers/net/wireless/mediatek/mt76/mt7925/main.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7925/main.c +3 -0
@@ -2081,6 +2081,9 @@ static void mt7925_ipv6_addr_change(struct ieee80211_hw *hw,struct ieee80211_bss_conf *bss_conf;int i; +if (!mvif->phy) +return ; +for_each_set_bit (i, &valid,IEEE80211_MLD_MAX_NUM_LINKS ) { bss_conf =mt792x_vif_to_bss_conf (vif, i);__mt7925_ipv6_addr_change (hw, bss_conf, idev);
Signature · 1 line
2.47.3
Felix Fietkau
maintainerPATCH 3/20 wifi: mt76: take the remaining wcids off the phy tx_list at reset
In reply to Felix Fietkaumt76_reset_device() runs INIT_LIST_HEAD() on each phy->tx_list while wcids that are not in dev->wcid[] can still be on it, such as a station between .sta_pre_rcu_remove and its removal. The later mt76_wcid_cleanup() of such a wcid then corrupts the list.
Take the remaining wcids off the list under the tx_lock.
--- drivers/net/wireless/mediatek/mt76/mac80211.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mac80211.c +5 -1
@@ -893,7 +893,11 @@ static void mt76_reset_phy(struct mt76_phy *phy)if (!phy)return ; -INIT_LIST_HEAD (&phy->tx_list); +spin_lock_bh (&phy->dev->tx_lock); +while (!list_empty (&phy->tx_list)) +list_del_init (phy->tx_list.next); +spin_unlock_bh (&phy->dev->tx_lock); + phy->num_sta =0 ; phy->chanctx =NULL ;mt76_roc_complete (phy);
Signature · 1 line
2.47.3
Felix Fietkau
maintainerPATCH 4/20 wifi: mt76: take the remaining wcids off sta_poll_list at reset
In reply to Felix Fietkaumt76_reset_device() runs INIT_LIST_HEAD() on dev->sta_poll_list while wcids that are not in dev->wcid[] can still be on it, such as a station between .sta_pre_rcu_remove and its removal. The later removal of such a station then corrupts the list.
Take the remaining wcids off the list under sta_poll_lock. While here, drop the comment in mt76_wcid_cleanup() that names the re-initialisation.
--- drivers/net/wireless/mediatek/mt76/mac80211.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/wireless/mediatek/mt76/mac80211.c +6 -6
@@ -922,7 +922,12 @@ void mt76_reset_device(struct mt76_dev *dev)rcu_read_unlock ();INIT_LIST_HEAD (&dev->wcid_list); -INIT_LIST_HEAD (&dev->sta_poll_list); + +spin_lock_bh (&dev->sta_poll_lock); +while (!list_empty (&dev->sta_poll_list)) +list_del_init (dev->sta_poll_list.next); +spin_unlock_bh (&dev->sta_poll_lock); + dev->vif_mask =0 ;memset (dev->wcid_mask,0 ,sizeof (dev->wcid_mask));
@@ -1864,11 +1869,6 @@ void mt76_wcid_cleanup(struct mt76_dev *dev, struct mt76_wcid *wcid)idr_destroy (&wcid->pktid);mt76_tx_status_unlock (dev, &list); -/* Remove from sta_poll_list to prevent list corruption after reset. -* Without this, mt76_reset_device() reinitializes sta_poll_list but -* leaves wcid->poll_list with stale pointers, causing list corruption -* when mt76_wcid_add_poll() checks list_empty(). -*/ spin_lock_bh (&dev->sta_poll_lock);if (!list_empty (&wcid->poll_list))list_del_init (&wcid->poll_list);
Signature · 1 line
2.47.3
Felix Fietkau
maintainerPATCH 5/20 wifi: mt76: mt7915: take the remaining stations off sta_rc_list at reset
In reply to Felix Fietkaumt7915_mac_full_reset() runs INIT_LIST_HEAD() on dev->sta_rc_list while stations can still be on it. A removal of such a station before the replay then corrupts the list.
Take the remaining stations off the list under sta_poll_lock, as mt76_reset_device() does for sta_poll_list.
--- drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7915/mac.c +5 -1
@@ -1471,7 +1471,11 @@ mt7915_mac_full_reset(struct mt7915_dev *dev)mt76_reset_device (&dev->mt76); -INIT_LIST_HEAD (&dev->sta_rc_list); +spin_lock_bh (&dev->mt76.sta_poll_lock); +while (!list_empty (&dev->sta_rc_list)) +list_del_init (dev->sta_rc_list.next); +spin_unlock_bh (&dev->mt76.sta_poll_lock); +INIT_LIST_HEAD (&dev->twt_list); i =mt76_wcid_alloc (dev->mt76.wcid_mask,MT7915_WTBL_STA );
Signature · 1 line
2.47.3
Felix Fietkau
maintainerPATCH 6/20 wifi: mt76: mt7996: list only published links on sta_rc_list
In reply to Felix Fietkaumt7996_mac_sta_remove_link() takes a link off dev->sta_rc_list while msta->link[] still names it. An rc update that looked the link up can thus list it again, and mt7996_mac_sta_rc_work() later uses the link after kfree_rcu() freed it. Reachable via an HT SMPS action frame that mac80211 receives while mt7996_mac_reset_sta_iter() runs.
Unpublish the link before it goes off the list, and only list a link that msta->link[] still names, tested under sta_poll_lock, as mt76_wcid_add_poll() does with dev->wcid[].
--- drivers/net/wireless/mediatek/mt76/mt7996/main.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7996/main.c +6 -3
@@ -1396,8 +1396,10 @@ void mt7996_mac_sta_remove_link(struct mt7996_dev *dev,if (!msta_link)return ; -if (flush) +if (flush) { +rcu_assign_pointer (msta->link[link_id],NULL );rcu_assign_pointer (dev->mt76.wcid[msta_link->wcid.idx],NULL ); + }spin_lock_bh (&dev->mt76.sta_poll_lock);if (!list_empty (&msta_link->wcid.poll_list))
@@ -1424,7 +1426,6 @@ void mt7996_mac_sta_remove_link(struct mt7996_dev *dev,if (phy) phy->mt76->num_sta--; -rcu_assign_pointer (msta->link[link_id],NULL );mt76_wcid_mask_clear (dev->mt76.wcid_mask, msta_link->wcid.idx);if (msta_link != &msta->deflink)kfree_rcu (msta_link, rcu_head);
@@ -2543,6 +2544,7 @@ static void mt7996_link_rate_ctrl_update(void *data, {struct mt7996_sta *msta = msta_link->sta;struct mt7996_phy *phy =mt7996_vif_link_phy (&msta->vif->deflink); +u8 link_id = msta_link->wcid.link_id;struct mt7996_dev *dev;u32 *changed = data;
@@ -2553,7 +2555,8 @@ static void mt7996_link_rate_ctrl_update(void *data,spin_lock_bh (&dev->mt76.sta_poll_lock); msta_link->changed |= *changed; -if (list_empty (&msta_link->rc_list)) +if (list_empty (&msta_link->rc_list) && +rcu_access_pointer (msta->link[link_id]) == msta_link)list_add_tail (&msta_link->rc_list, &dev->sta_rc_list);spin_unlock_bh (&dev->mt76.sta_poll_lock);
Signature · 1 line
2.47.3
Felix Fietkau
maintainerPATCH 7/20 wifi: mt76: mt7996: take the remaining links off sta_rc_list at reset
In reply to Felix Fietkaumt7996_mac_full_reset() runs INIT_LIST_HEAD() on dev->sta_rc_list while links can still be on it. mt7996_mac_reset_sta_iter() takes the links of a station off the list, but it does not see a station that mac80211 took off its station list before the reset. The later mt7996_mac_sta_remove() of such a station then corrupts the list.
Take the remaining links off the list under sta_poll_lock, as mt76_reset_device() does for sta_poll_list.
--- drivers/net/wireless/mediatek/mt76/mt7996/mac.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7996/mac.c +5 -1
@@ -2532,7 +2532,11 @@ mt7996_mac_full_reset(struct mt7996_dev *dev)IEEE80211_IFACE_SKIP_SDATA_NOT_IN_DRIVER , mt7996_mac_reset_vif_iter, dev); -INIT_LIST_HEAD (&dev->sta_rc_list); +spin_lock_bh (&dev->mt76.sta_poll_lock); +while (!list_empty (&dev->sta_rc_list)) +list_del_init (dev->sta_rc_list.next); +spin_unlock_bh (&dev->mt76.sta_poll_lock); +INIT_LIST_HEAD (&dev->twt_list);spin_lock_bh (&dev->wed_rro.lock);
Signature · 1 line
2.47.3
Felix Fietkau
maintainerPATCH 8/20 wifi: mt76: mt7915: take the TWT flows of a removed station off twt_list
In reply to Felix Fietkaumt7915_mac_twt_teardown_flow() keeps a flow on dev->twt_list if the delete command fails, for example while a reset is pending, and mt7915_mac_sta_remove() does not take the remaining flows off the list. The list then holds flows inside a station that mac80211 frees, and the next TWT setup reads them in mt7915_mac_twt_sched_list_add().
Take the remaining flows of a station off the list at its removal.
--- drivers/net/wireless/mediatek/mt76/mt7915/main.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7915/main.c +10 -0
@@ -876,10 +876,20 @@ void mt7915_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif, { struct mt7915_dev *dev = container_of(mdev, struct mt7915_dev, mt76);struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; +int i;mt7915_mac_wtbl_update (dev, msta->wcid.idx,MT_WTBL_UPDATE_ADM_COUNT_CLEAR ); +/* the firmware can still hold an agreement whose delete failed, so +* its table entry stays counted +*/ +for (i =0 ; i <ARRAY_SIZE (msta->twt.flow); i++) { +if (msta->twt.flowid_mask &BIT (i)) +list_del_init (&msta->twt.flow[i].list); + } + msta->twt.flowid_mask =0 ; +spin_lock_bh (&mdev->sta_poll_lock);if (!list_empty (&msta->wcid.poll_list))list_del_init (&msta->wcid.poll_list);
Signature · 1 line
2.47.3
Felix Fietkau
maintainerPATCH 9/20 wifi: mt76: mt7996: take the TWT flows of a removed station off twt_list
In reply to Felix Fietkaumt7996_mac_twt_teardown_flow() keeps a flow on dev->twt_list if the delete command fails, for example while a reset is pending, and mt7996_mac_sta_remove() does not take the remaining flows off the list. The list then holds flows inside a station that mac80211 frees, and the next TWT setup reads them in mt7996_mac_twt_sched_list_add().
Take the remaining flows of a station off the list at its removal.
--- drivers/net/wireless/mediatek/mt76/mt7996/main.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7996/main.c +11 -0
@@ -1985,9 +1985,20 @@ mt7996_mac_sta_remove(struct mt7996_dev *dev, struct ieee80211_vif *vif, struct ieee80211_sta *sta) {struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; +struct mt7996_sta_link *msta_link = &msta->deflink;int i;mutex_lock (&dev->mt76.mutex); + +/* the firmware can still hold an agreement whose delete failed, so +* its table entry stays counted +*/ +for (i =0 ; i <ARRAY_SIZE (msta_link->twt.flow); i++) { +if (msta_link->twt.flowid_mask &BIT (i)) +list_del_init (&msta_link->twt.flow[i].list); + } + msta_link->twt.flowid_mask =0 ; +for (i =0 ; i <ARRAY_SIZE (msta->link); i++)mt7996_mac_sta_remove_link (dev, sta, i, true);mutex_unlock (&dev->mt76.mutex);
Signature · 1 line
2.47.3
Felix Fietkau
maintainerPATCH 10/20 wifi: mt76: mt7915: drop the TWT agreements at a full reset
In reply to Felix FietkauThe firmware that a full reset reloads holds no TWT agreement, but mt7915_mac_full_reset() keeps those of the driver and only runs INIT_LIST_HEAD() on dev->twt_list. The disassociation or the removal of a station with a flow then corrupts the list.
Drop the TWT agreements of the driver at a full reset as well.
--- drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7915/mac.c +10 -1
@@ -1435,6 +1435,7 @@ mt7915_mac_restart(struct mt7915_dev *dev)static void mt7915_mac_full_reset (struct mt7915_dev *dev) { +struct mt7915_twt_flow *flow, *tmp;struct mt76_phy *ext_phy;struct mt7915_phy *phy2;int i;
@@ -1476,7 +1477,15 @@ mt7915_mac_full_reset(struct mt7915_dev *dev)list_del_init (dev->sta_rc_list.next);spin_unlock_bh (&dev->mt76.sta_poll_lock); -INIT_LIST_HEAD (&dev->twt_list); +list_for_each_entry_safe (flow, tmp, &dev->twt_list, list) { +struct mt7915_sta *msta; + + msta = container_of(flow, struct mt7915_sta, twt.flow[flow->id]); + msta->twt.flowid_mask &= ~BIT (flow->id); +list_del_init (&flow->list); + } + dev->twt.table_mask =0 ; + dev->twt.n_agrt =0 ; i =mt76_wcid_alloc (dev->mt76.wcid_mask,MT7915_WTBL_STA ); dev->mt76.global_wcid.idx = i;
Signature · 1 line
2.47.3
Felix Fietkau
maintainerPATCH 11/20 wifi: mt76: mt7996: drop the TWT agreements at a full reset
In reply to Felix FietkauThe firmware that a full reset reloads holds no TWT agreement, but mt7996_mac_full_reset() keeps those of the driver and only runs INIT_LIST_HEAD() on dev->twt_list. The disassociation or the removal of a station with a flow then corrupts the list.
Drop the TWT agreements of the driver at a full reset as well.
--- drivers/net/wireless/mediatek/mt76/mt7996/mac.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7996/mac.c +11 -1
@@ -2493,6 +2493,7 @@ static void mt7996_mac_full_reset(struct mt7996_dev *dev) {struct ieee80211_hw *hw =mt76_hw (dev); +struct mt7996_twt_flow *flow, *tmp;struct mt7996_phy *phy;LIST_HEAD (list);int i;
@@ -2537,7 +2538,16 @@ mt7996_mac_full_reset(struct mt7996_dev *dev)list_del_init (dev->sta_rc_list.next);spin_unlock_bh (&dev->mt76.sta_poll_lock); -INIT_LIST_HEAD (&dev->twt_list); +list_for_each_entry_safe (flow, tmp, &dev->twt_list, list) { +struct mt7996_sta_link *msta_link; + + msta_link = container_of(flow, struct mt7996_sta_link, + twt.flow[flow->id]); + msta_link->twt.flowid_mask &= ~BIT (flow->id); +list_del_init (&flow->list); + } + dev->twt.table_mask =0 ; + dev->twt.n_agrt =0 ;spin_lock_bh (&dev->wed_rro.lock);list_splice_init (&dev->wed_rro.poll_list, &list);
Signature · 1 line
2.47.3
Felix Fietkau
maintainerPATCH 12/20 wifi: mt76: mt7915: read twt_list under the mutex in twt_stats
In reply to Felix Fietkaumt7915_twt_stats() walks dev->twt_list under rcu_read_lock() alone, but the writers of the list use plain list operations under dev->mt76.mutex. A read during a teardown can thus loop without end. Reachable via the twt_stats debugfs file.
Hold dev->mt76.mutex for the walk, as the writers and mt7915_tx_stats_show() do.
--- drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c +3 -3
@@ -1227,11 +1227,11 @@ mt7915_twt_stats(struct seq_file *s, void *data)struct mt7915_dev *dev =dev_get_drvdata (s->private);struct mt7915_twt_flow *iter; -rcu_read_lock (); +mutex_lock (&dev->mt76.mutex);seq_puts (s," wcid | id | flags | exp | mantissa" );seq_puts (s," | duration | tsf |\n" ); -list_for_each_entry_rcu (iter, &dev->twt_list, list) +list_for_each_entry (iter, &dev->twt_list, list) seq_printf(s, "%9d | %8d | %5c%c%c%c | %8d | %8d | %8d | %14lld |\n", iter->wcid, iter->id,
@@ -1242,7 +1242,7 @@ mt7915_twt_stats(struct seq_file *s, void *data) iter->exp, iter->mantissa, iter->duration, iter->tsf); -rcu_read_unlock (); +mutex_unlock (&dev->mt76.mutex);return 0 ; }
Signature · 1 line
2.47.3
Felix Fietkau
maintainerPATCH 13/20 wifi: mt76: mt7996: read twt_list under the mutex in twt_stats
In reply to Felix Fietkaumt7996_twt_stats() walks dev->twt_list under rcu_read_lock() alone, but the writers of the list use plain list operations under dev->mt76.mutex. A read during a teardown can thus loop without end. Reachable via the twt_stats debugfs file.
Hold dev->mt76.mutex for the walk, as the writers and mt7996_tx_stats_show() do.
--- drivers/net/wireless/mediatek/mt76/mt7996/debugfs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7996/debugfs.c +3 -3
@@ -901,11 +901,11 @@ mt7996_twt_stats(struct seq_file *s, void *data)struct mt7996_dev *dev =dev_get_drvdata (s->private);struct mt7996_twt_flow *iter; -rcu_read_lock (); +mutex_lock (&dev->mt76.mutex);seq_puts (s," wcid | id | flags | exp | mantissa" );seq_puts (s," | duration | tsf |\n" ); -list_for_each_entry_rcu (iter, &dev->twt_list, list) +list_for_each_entry (iter, &dev->twt_list, list) seq_printf(s, "%9d | %8d | %5c%c%c%c | %8d | %8d | %8d | %14lld |\n", iter->wcid, iter->id,
@@ -916,7 +916,7 @@ mt7996_twt_stats(struct seq_file *s, void *data) iter->exp, iter->mantissa, iter->duration, iter->tsf); -rcu_read_unlock (); +mutex_unlock (&dev->mt76.mutex);return 0 ; }
Signature · 1 line
2.47.3
Felix Fietkau
maintainerPATCH 14/20 wifi: mt76: mt7915: publish the global wcid again after a full reset
In reply to Felix FietkauAfter a full reset, dev->wcid[] no longer holds the global wcid. mt76_reset_device() unpublishes it with every other wcid, and mt7915_mac_full_reset() only allocates its index again. A frame on the global wcid that requests a TX status then reports no ACK, since mt76_tx_status_skb_add() does not find the wcid in dev->wcid[].
Set up the global wcid in the full reset as at probe time.
--- .../net/wireless/mediatek/mt76/mt7915/init.c | 29 +++++++++++-------- .../net/wireless/mediatek/mt76/mt7915/mac.c | 3 +- .../wireless/mediatek/mt76/mt7915/mt7915.h | 1 + 3 files changed, 19 insertions(+), 14 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7915/init.c +17 -12
@@ -865,10 +865,25 @@ static bool mt7915_band_config(struct mt7915_dev *dev)return ret; } +int mt7915_global_wcid_init (struct mt7915_dev *dev) +{ +int idx =mt76_wcid_alloc (dev->mt76.wcid_mask,MT7915_WTBL_STA ); + +if (idx) +return -ENOSPC ; + + dev->mt76.global_wcid.idx = idx; + dev->mt76.global_wcid.hw_key_idx =-1 ; + dev->mt76.global_wcid.tx_info |=MT_WCID_TX_INFO_SET ; +rcu_assign_pointer (dev->mt76.wcid[idx], &dev->mt76.global_wcid); + +return 0 ; +} +static int mt7915_init_hardware (struct mt7915_dev *dev,struct mt7915_phy *phy2) { -int ret, idx; +int ret;mt76_wr (dev,MT_INT_MASK_CSR ,0 );mt76_wr (dev,MT_INT_SOURCE_CSR , ~0 );
@@ -895,17 +910,7 @@ mt7915_init_hardware(struct mt7915_dev *dev, struct mt7915_phy *phy2)return ret; } -/* Beacon and mgmt frames should occupy wcid 0 */ - idx =mt76_wcid_alloc (dev->mt76.wcid_mask,MT7915_WTBL_STA ); -if (idx) -return -ENOSPC ; - - dev->mt76.global_wcid.idx = idx; - dev->mt76.global_wcid.hw_key_idx =-1 ; - dev->mt76.global_wcid.tx_info |=MT_WCID_TX_INFO_SET ; -rcu_assign_pointer (dev->mt76.wcid[idx], &dev->mt76.global_wcid); - -return 0 ; +return mt7915_global_wcid_init (dev); }void mt7915_set_stream_vht_txbf_caps (struct mt7915_phy *phy)
drivers/net/wireless/mediatek/mt76/mt7915/mac.c +1 -2
@@ -1487,8 +1487,7 @@ mt7915_mac_full_reset(struct mt7915_dev *dev) dev->twt.table_mask =0 ; dev->twt.n_agrt =0 ; - i =mt76_wcid_alloc (dev->mt76.wcid_mask,MT7915_WTBL_STA ); - dev->mt76.global_wcid.idx = i; +mt7915_global_wcid_init (dev); dev->recovery.hw_full_reset = false;mutex_unlock (&dev->mt76.mutex);
drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +1 -0
@@ -455,6 +455,7 @@ u32 mt7915_wed_init_buf(void *ptr, dma_addr_t phys, int token_id);int mt7915_register_device (struct mt7915_dev *dev);void mt7915_unregister_device (struct mt7915_dev *dev); +int mt7915_global_wcid_init (struct mt7915_dev *dev);int mt7915_eeprom_init (struct mt7915_dev *dev);void mt7915_eeprom_parse_hw_cap (struct mt7915_dev *dev,struct mt7915_phy *phy);
Signature · 1 line
2.47.3
Felix Fietkau
maintainerPATCH 15/20 wifi: mt76: mt7996: publish the global wcid again after a full reset
In reply to Felix FietkauAfter a full reset, dev->wcid[] no longer holds the global wcid. mt76_reset_device() unpublishes it with every other wcid, and mt7996_mac_full_reset() only allocates its index again. A frame on the global wcid that requests a TX status then reports no ACK, since mt76_tx_status_skb_add() does not find the wcid in dev->wcid[].
Set up the global wcid in the full reset as at probe time.
--- .../net/wireless/mediatek/mt76/mt7996/init.c | 29 +++++++++++-------- .../net/wireless/mediatek/mt76/mt7996/mac.c | 3 +- .../wireless/mediatek/mt76/mt7996/mt7996.h | 1 + 3 files changed, 19 insertions(+), 14 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7996/init.c +17 -12
@@ -1265,9 +1265,24 @@ static int mt7996_variant_fem_init(struct mt7996_dev *dev)return 0 ; } +int mt7996_global_wcid_init (struct mt7996_dev *dev) +{ +int idx =mt76_wcid_alloc (dev->mt76.wcid_mask,MT7996_WTBL_STA ); + +if (idx) +return -ENOSPC ; + + dev->mt76.global_wcid.idx = idx; + dev->mt76.global_wcid.hw_key_idx =-1 ; + dev->mt76.global_wcid.tx_info |=MT_WCID_TX_INFO_SET ; +rcu_assign_pointer (dev->mt76.wcid[idx], &dev->mt76.global_wcid); + +return 0 ; +} +static int mt7996_init_hardware (struct mt7996_dev *dev) { -int ret, idx; +int ret;mt76_wr (dev,MT_INT_SOURCE_CSR , ~0 );if (is_mt7992 (&dev->mt76)) {
@@ -1306,17 +1321,7 @@ static int mt7996_init_hardware(struct mt7996_dev *dev)if (ret <0 )return ret; -/* Beacon and mgmt frames should occupy wcid 0 */ - idx =mt76_wcid_alloc (dev->mt76.wcid_mask,MT7996_WTBL_STA ); -if (idx) -return -ENOSPC ; - - dev->mt76.global_wcid.idx = idx; - dev->mt76.global_wcid.hw_key_idx =-1 ; - dev->mt76.global_wcid.tx_info |=MT_WCID_TX_INFO_SET ; -rcu_assign_pointer (dev->mt76.wcid[idx], &dev->mt76.global_wcid); - -return 0 ; +return mt7996_global_wcid_init (dev); }void mt7996_set_stream_vht_txbf_caps (struct mt7996_phy *phy)
drivers/net/wireless/mediatek/mt76/mt7996/mac.c +1 -2
@@ -2562,8 +2562,7 @@ mt7996_mac_full_reset(struct mt7996_dev *dev)kfree (e); } - i =mt76_wcid_alloc (dev->mt76.wcid_mask,MT7996_WTBL_STA ); - dev->mt76.global_wcid.idx = i; +mt7996_global_wcid_init (dev); dev->recovery.hw_full_reset = false;mutex_unlock (&dev->mt76.mutex);
drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h +1 -0
@@ -711,6 +711,7 @@ irqreturn_t mt7996_irq_handler(int irq, void *dev_instance);u64 __mt7996_get_tsf (struct ieee80211_hw *hw,struct mt7996_vif_link *link);int mt7996_register_device (struct mt7996_dev *dev);void mt7996_unregister_device (struct mt7996_dev *dev); +int mt7996_global_wcid_init (struct mt7996_dev *dev);int mt7996_vif_link_add (struct mt76_phy *mphy,struct ieee80211_vif *vif,struct ieee80211_bss_conf *link_conf,struct mt76_vif_link *mlink);
Signature · 1 line
2.47.3
Felix Fietkau
maintainerPATCH 16/20 wifi: mt76: mt7925: keep the antenna mask across a firmware reload
In reply to Felix Fietkaumt7925_mcu_parse_phy_cap() sets antenna_mask and chainmask to every chain that the firmware reports, also when the chip reset of mt7925_mac_reset_work() loads the firmware again. A mask that mt7925_set_antenna() set is thus lost, while the stream caps of each band still follow it.
Only set the mask of every chain at the first firmware load. On a reload, keep the current mask, limited to the chains of the reloaded firmware, and build the stream caps again if that limit changes it.
--- drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +14 -2
@@ -1122,16 +1122,28 @@ mt7925_mcu_parse_phy_cap(struct mt792x_dev *dev, char *data, int len)WF0_24G ,WF0_5G }; +bool changed; +u8 mask; if (len < offsetofend(struct mt7925_mcu_phy_cap, hw_path))return ; cap = (struct mt7925_mcu_phy_cap *)data; - mdev->phy.antenna_mask =BIT (cap->nss) -1 ; - mdev->phy.chainmask = mdev->phy.antenna_mask; + mask =BIT (cap->nss) -1 ; +if (dev->hw_init_done) + mask &= mdev->phy.antenna_mask; + changed = mask != mdev->phy.antenna_mask; + + mdev->phy.antenna_mask = mask; + mdev->phy.chainmask = mask; mdev->phy.cap.has_2ghz = cap->hw_path &BIT (WF0_24G ); mdev->phy.cap.has_5ghz = cap->hw_path &BIT (WF0_5G ); + +if (dev->hw_init_done && changed) { +mt76_set_stream_caps (mphy, true); +mt7925_set_stream_he_eht_caps (&dev->phy); + } } static void
Signature · 1 line
2.47.3
Felix Fietkau
maintainerPATCH 17/20 wifi: mt76: mt7925: remove mt7925_mcu_del_dev()
In reply to Felix FietkauAt the removal of a station of an MLD interface, mt7925_mcu_del_dev() activates the BSS of the default link again, with the connection type and the station and broadcast indexes at 0, and sets the interface address on its omac. For the AP station of an MLO connection, the firmware holds no BSS or DEV entry of any link at that point, and it refuses the BSS update at each disconnection. For a TDLS peer and for a client of an AP MLD, the command rewrites the BSS and the DEV entry of the default link, which the interface still uses.
Remove mt7925_mcu_del_dev(). Since commit 8f9e5807671e ("wifi: mt76:
mt7925: restore the legacy BSS after MLO teardown"), mt7925_change_vif_links() adds the legacy BSS with the interface address when mac80211 removes the last link, after the AP station.
--- .../net/wireless/mediatek/mt76/mt7925/main.c | 6 +- .../net/wireless/mediatek/mt76/mt7925/mcu.c | 56 ------------------- .../net/wireless/mediatek/mt76/mt7925/mcu.h | 2 - 3 files changed, 2 insertions(+), 62 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/main.c +2 -4
@@ -1640,13 +1640,11 @@ void mt7925_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,rcu_read_unlock (); } -if (ieee80211_vif_is_mld (vif)) { +if (ieee80211_vif_is_mld (vif))mt7925_mac_sta_remove_links (dev, vif, sta, msta->valid_links); -mt7925_mcu_del_dev (mdev, vif); - }else { +else mt7925_mac_link_sta_remove (mdev, vif, &sta->deflink, &msta->deflink); - }if (vif->type ==NL80211_IFTYPE_STATION ) { mvif->wep_sta =NULL ;
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +0 -56
62 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt7925/mcu.h +0 -2
@@ -741,8 +741,6 @@ int mt7925_mcu_sched_scan_req(struct mt76_phy *phy,int mt7925_mcu_sched_scan_enable (struct mt76_phy *phy,struct ieee80211_vif *vif,bool enable); -void mt7925_mcu_del_dev (struct mt76_dev *mdev, -struct ieee80211_vif *vif); int mt7925_mcu_add_bss_info(struct mt792x_phy *phy, struct ieee80211_chanctx_conf *ctx, struct ieee80211_bss_conf *link_conf,
Signature · 1 line
2.47.3
Felix Fietkau
maintainerPATCH 18/20 wifi: mt76: mt7921: keep the antenna mask across a firmware reload
In reply to Felix Fietkaumt7921_mcu_parse_phy_cap() sets antenna_mask and chainmask to every chain that the firmware reports, also when the chip reset of mt7921_mac_reset_work() loads the firmware again. A mask that mt7921_set_antenna() set is thus lost, while the stream caps of each band still follow it.
Only set the mask of every chain at the first firmware load. On a reload, keep the current mask, limited to the chains of the reloaded firmware, and build the stream caps again if that limit changes it.
--- .../net/wireless/mediatek/mt76/mt7921/mcu.c | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +18 -5
@@ -582,9 +582,10 @@ static void mt7921_mcu_parse_tx_resource(struct mt76_dev *dev, sdio->sched.deficit = tx_res->pp_padding; } -static void mt7921_mcu_parse_phy_cap (struct mt76_dev *dev, +static void mt7921_mcu_parse_phy_cap (struct mt76_dev *mdev,struct sk_buff *skb,int len) { + struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76);struct mt7921_phy_cap {u8 ht;u8 vht;
@@ -604,16 +605,28 @@ static void mt7921_mcu_parse_phy_cap(struct mt76_dev *dev,WF0_24G ,WF0_5G }; +bool changed; +u8 mask; if (len < offsetofend(struct mt7921_phy_cap, hw_path))return ; cap = (struct mt7921_phy_cap *)skb->data; - dev->phy.antenna_mask =BIT (cap->nss) -1 ; - dev->phy.chainmask = dev->phy.antenna_mask; - dev->phy.cap.has_2ghz = cap->hw_path &BIT (WF0_24G ); - dev->phy.cap.has_5ghz = cap->hw_path &BIT (WF0_5G ); + mask =BIT (cap->nss) -1 ; +if (dev->hw_init_done) + mask &= mdev->phy.antenna_mask; + changed = mask != mdev->phy.antenna_mask; + + mdev->phy.antenna_mask = mask; + mdev->phy.chainmask = mask; + mdev->phy.cap.has_2ghz = cap->hw_path &BIT (WF0_24G ); + mdev->phy.cap.has_5ghz = cap->hw_path &BIT (WF0_5G ); + +if (dev->hw_init_done && changed) { +mt76_set_stream_caps (&mdev->phy, true); +mt7921_set_stream_he_caps (&dev->phy); + } }static int mt7921_mcu_get_nic_capability (struct mt792x_phy *mphy)
Signature · 1 line
2.47.3
Felix Fietkau
maintainerPATCH 19/20 wifi: mt76: mt792x: flush frames that still wait for the TX worker
In reply to Felix Fietkaumt792x_flush() waits for the hardware queues alone, but since commit 0335c034e726 ("wifi: mt76: fix race condition related to checking tx queue fill status"), a frame can also wait on the pending list of its wcid until the TX worker moves it to a hardware queue. The flush can thus return before a frame that mac80211 flushes reaches the hardware. At a disconnection, the join ROC of the departure then ends before the Deauthentication goes out.
Also flush the frames on the pending lists, as __mt76_set_channel() does before a channel change, or drop them if mac80211 asks to drop frames. Hold the mutex for it, since a chip reset parks the TX worker under the mutex. A USB disconnect parks the worker without the mutex, so leave the worker alone while MT76_RESET is set, and set the bit under the mutex.
--- drivers/net/wireless/mediatek/mt76/mt76.h | 1 + .../net/wireless/mediatek/mt76/mt792x_core.c | 16 ++++++++++++++ .../net/wireless/mediatek/mt76/mt792x_usb.c | 2 ++ drivers/net/wireless/mediatek/mt76/tx.c | 21 +++++++++++++++++++ 4 files changed, 40 insertions(+)
drivers/net/wireless/mediatek/mt76/mt76.h +1 -0
@@ -1568,6 +1568,7 @@ void mt76_tx_check_agg_ssn(struct ieee80211_sta *sta, struct sk_buff *skb);void mt76_txq_schedule (struct mt76_phy *phy,enum mt76_txq_id qid);void mt76_txq_schedule_all (struct mt76_phy *phy);void mt76_txq_schedule_pending (struct mt76_phy *phy); +void mt76_txq_purge_pending (struct mt76_phy *phy);void mt76_tx_worker_run (struct mt76_dev *dev);void mt76_tx_worker (struct mt76_worker *w); void mt76_release_buffered_frames(struct ieee80211_hw *hw,
drivers/net/wireless/mediatek/mt76/mt792x_core.c +16 -0
@@ -435,9 +435,25 @@ void mt792x_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u32 queues, bool drop) {struct mt792x_dev *dev =mt792x_hw_dev (hw); +bool park; + +mt792x_mutex_acquire (dev); + + park = !test_bit (MT76_RESET , &dev->mphy.state); +if (park) { +mt76_worker_disable (&dev->mt76.tx_worker); +if (drop) +mt76_txq_purge_pending (&dev->mphy); +mt76_txq_schedule_pending (&dev->mphy); + }wait_event_timeout (dev->mt76.tx_wait, !mt76_has_tx_pending (&dev->mphy),HZ /2 ); + +if (park) +mt76_worker_enable (&dev->mt76.tx_worker); + +mt792x_mutex_release (dev); }EXPORT_SYMBOL_GPL (mt792x_flush);
drivers/net/wireless/mediatek/mt76/mt792x_usb.c +2 -0
@@ -501,7 +501,9 @@ void mt792xu_disconnect(struct usb_interface *usb_intf)if (!dev)return ; +mutex_lock (&dev->mt76.mutex);set_bit (MT76_RESET , &dev->mphy.state); +mutex_unlock (&dev->mt76.mutex);clear_bit (MT76_STATE_RUNNING , &dev->mphy.state);cancel_work_sync (&dev->init_work);
drivers/net/wireless/mediatek/mt76/tx.c +21 -0
@@ -804,6 +804,27 @@ void mt76_txq_schedule_pending(struct mt76_phy *phy)rcu_read_unlock ();local_bh_enable (); } +EXPORT_SYMBOL_GPL (mt76_txq_schedule_pending); + +void mt76_txq_purge_pending (struct mt76_phy *phy) +{ +struct mt76_dev *dev = phy->dev; +struct sk_buff_head list; +struct mt76_wcid *wcid; + +__skb_queue_head_init (&list); + +spin_lock_bh (&dev->tx_lock); +list_for_each_entry (wcid, &phy->tx_list, tx_list) { +spin_lock (&wcid->tx_pending.lock); +skb_queue_splice_tail_init (&wcid->tx_pending, &list); +spin_unlock (&wcid->tx_pending.lock); + } +spin_unlock_bh (&dev->tx_lock); + +ieee80211_purge_tx_queue (phy->hw, &list); +} +EXPORT_SYMBOL_GPL (mt76_txq_purge_pending);void mt76_txq_schedule_all (struct mt76_phy *phy) {
Signature · 1 line
2.47.3
Felix Fietkau
maintainerPATCH 20/20 wifi: mt76: mt7925: send the deauth of an MLD station on its AC queue
In reply to Felix FietkauSince commit dedf2ec30fe4 ("wifi: mt76: fix queue assignment for deauth packets"), the Deauthentication that an associated MLD station sends when it leaves goes out on the ALTX queue of its default link, without the MLD address translation. With single-radio MLO, the firmware holds the links that the radio does not serve in power save, and it drops an ALTX frame for such a link. The AP then keeps the station.
Send the Deauthentication of an associated MLD station on its AC queue with the address translation, like its Action frames. A Deauthentication that ends an authentication or an association stays on ALTX, since it goes out under the join ROC of mt7925_mgd_prepare_tx().
--- drivers/net/wireless/mediatek/mt76/mt7925/mac.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7925/mac.c +11 -1
@@ -765,6 +765,16 @@ mt7925_mac_write_txwi_80211(struct mt76_dev *dev, __le32 *txwi, } } +static bool +mt7925_mac_deauth_on_ac (struct ieee80211_vif *vif,struct sk_buff *skb) +{ +struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; + +return vif && vif->type ==NL80211_IFTYPE_STATION && +ieee80211_vif_is_mld (vif) && vif->cfg.assoc && +ieee80211_is_deauth (hdr->frame_control); +} + void mt7925_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi, struct sk_buff *skb, struct mt76_wcid *wcid,
@@ -799,7 +809,7 @@ mt7925_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi, }else if (beacon) { p_fmt =MT_TX_TYPE_FW ; q_idx =MT_LMAC_BCN0 ; - }else if (qid >=MT_TXQ_PSD ) { + }else if (qid >=MT_TXQ_PSD && !mt7925_mac_deauth_on_ac (vif, skb)) { p_fmt =mt76_is_mmio (dev) ?MT_TX_TYPE_CT :MT_TX_TYPE_SF ; q_idx =MT_LMAC_ALTX0 ; }else {
Signature · 1 line
2.47.3