mt7996_mac_sta_remove_link() clears deflink_id when it removes the primary link and no secondary link is left to take its place. If the removed link then comes back, mt7996_mac_sta_add_links() finds its existing msta_link and only marks it valid again. deflink_id stays IEEE80211_LINK_UNSPECIFIED, so the station has no primary link: the TXQs keep the WLAN index that they had before, seclink_id stays unspecified, mt7996_sta_rate_ctrl_update() finds no primary link, and mt7996_sta_set_4addr() treats every link as a secondary link. Make a returning link the primary link when the station has none, in the same way as mt7996_mac_sta_init_link() does for a new link. Move the two steps that set the primary link, and the switch to the secondary link on removal, to helpers. Fixes: e8c819df0243 ("wifi: mt76: mt7996: Destroy active sta links in mt7996_mac_sta_remove()") Signed-off-by: Felix Fietkau --- .../net/wireless/mediatek/mt76/mt7996/main.c | 55 +++++++++++++------ 1 file changed, 37 insertions(+), 18 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/main.c b/drivers/net/wireless/mediatek/mt76/mt7996/main.c index 9de455939125..8f483b1de852 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7996/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7996/main.c @@ -1133,6 +1133,38 @@ mt7996_sta_init_txq_wcid(struct ieee80211_sta *sta, int idx) } } +static void +mt7996_sta_deflink_set(struct ieee80211_sta *sta, unsigned int link_id, + int idx) +{ + struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; + + msta->deflink_id = link_id; + mt7996_sta_init_txq_wcid(sta, idx); +} + +static void +mt7996_sta_deflink_release(struct mt7996_dev *dev, struct ieee80211_sta *sta, + unsigned int link_id) +{ + struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; + struct mt7996_sta_link *msta_seclink; + + if (msta->deflink_id != link_id) + return; + + msta->deflink_id = IEEE80211_LINK_UNSPECIFIED; + if (msta->seclink_id == link_id) + return; + + /* switch to the secondary link */ + msta_seclink = mt76_dereference(msta->link[msta->seclink_id], + &dev->mt76); + if (msta_seclink) + mt7996_sta_deflink_set(sta, msta->seclink_id, + msta_seclink->wcid.idx); +} + static u8 mt7996_sta_seclink_get(struct mt7996_dev *dev, struct mt7996_sta *msta) { @@ -1180,8 +1212,7 @@ mt7996_mac_sta_init_link(struct mt7996_dev *dev, if (msta->deflink_id == IEEE80211_LINK_UNSPECIFIED) { msta_link = &msta->deflink; - msta->deflink_id = link_id; - mt7996_sta_init_txq_wcid(sta, idx); + mt7996_sta_deflink_set(sta, link_id, idx); } else { msta_link = kzalloc_obj(*msta_link); if (!msta_link) { @@ -1242,22 +1273,7 @@ void mt7996_mac_sta_remove_link(struct mt7996_dev *dev, mt7996_mac_wtbl_update(dev, msta_link->wcid.idx, MT_WTBL_UPDATE_ADM_COUNT_CLEAR); - if (msta->deflink_id == link_id) { - msta->deflink_id = IEEE80211_LINK_UNSPECIFIED; - if (msta->seclink_id != link_id) { - struct mt7996_sta_link *msta_seclink; - - /* switch to the secondary link */ - msta_seclink = mt76_dereference( - msta->link[msta->seclink_id], - &dev->mt76); - if (msta_seclink) { - msta->deflink_id = msta->seclink_id; - mt7996_sta_init_txq_wcid(sta, - msta_seclink->wcid.idx); - } - } - } + mt7996_sta_deflink_release(dev, sta, link_id); msta_link->wcid.link_valid = false; msta->seclink_id = mt7996_sta_seclink_get(dev, msta); } @@ -1336,6 +1352,9 @@ mt7996_mac_sta_add_links(struct mt7996_dev *dev, struct ieee80211_vif *vif, msta_link = mt76_dereference(msta->link[link_id], &dev->mt76); if (msta_link) { msta_link->wcid.link_valid = true; + if (msta->deflink_id == IEEE80211_LINK_UNSPECIFIED) + mt7996_sta_deflink_set(sta, link_id, + msta_link->wcid.idx); msta->seclink_id = mt7996_sta_seclink_get(dev, msta); continue; } -- 2.47.3