mirror of
https://github.com/outbackdingo/mt76.git
synced 2026-10-24 13:26:48 +00:00
wifi: mt76: mt7996: Destroy active sta links in mt7996_mac_sta_remove()
Similar to vif link management, postpone sta link destuction in mt7996_mac_sta_remove() introducing mt7996_mac_sta_remove_link utility routine and just disable sta link running mt7996_mac_sta_remove_links routine. This is a preliminary patch in order to support MLO link reconfiguration in MT7996 driver. Signed-off-by: Lorenzo Bianconi <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Felix Fietkau <[email protected]>
This commit is contained in:
committed by
Felix Fietkau
parent
a4c790aef4
commit
018f60316d
+2
-20
@@ -2372,26 +2372,8 @@ mt7996_mac_reset_sta_iter(void *data, struct ieee80211_sta *sta)
|
|||||||
struct mt7996_dev *dev = data;
|
struct mt7996_dev *dev = data;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(msta->link); i++) {
|
for (i = 0; i < ARRAY_SIZE(msta->link); i++)
|
||||||
struct mt7996_sta_link *msta_link = NULL;
|
mt7996_mac_sta_remove_link(dev, sta, i, true);
|
||||||
struct mt7996_phy *phy;
|
|
||||||
|
|
||||||
msta_link = rcu_replace_pointer(msta->link[i], msta_link,
|
|
||||||
lockdep_is_held(&dev->mt76.mutex));
|
|
||||||
if (!msta_link)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
mt7996_mac_sta_deinit_link(dev, msta_link);
|
|
||||||
phy = __mt7996_phy(dev, msta_link->wcid.phy_idx);
|
|
||||||
if (phy)
|
|
||||||
phy->mt76->num_sta--;
|
|
||||||
|
|
||||||
if (msta_link != &msta->deflink)
|
|
||||||
kfree_rcu(msta_link, rcu_head);
|
|
||||||
}
|
|
||||||
|
|
||||||
msta->deflink_id = IEEE80211_LINK_UNSPECIFIED;
|
|
||||||
msta->seclink_id = msta->deflink_id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
+40
-27
@@ -1177,9 +1177,17 @@ mt7996_mac_sta_init_link(struct mt7996_dev *dev,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mt7996_mac_sta_deinit_link(struct mt7996_dev *dev,
|
void mt7996_mac_sta_remove_link(struct mt7996_dev *dev,
|
||||||
struct mt7996_sta_link *msta_link)
|
struct ieee80211_sta *sta,
|
||||||
|
unsigned int link_id, bool flush)
|
||||||
{
|
{
|
||||||
|
struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
|
||||||
|
struct mt7996_sta_link *msta_link;
|
||||||
|
|
||||||
|
msta_link = mt76_dereference(msta->link[link_id], &dev->mt76);
|
||||||
|
if (!msta_link)
|
||||||
|
return;
|
||||||
|
|
||||||
spin_lock_bh(&dev->mt76.sta_poll_lock);
|
spin_lock_bh(&dev->mt76.sta_poll_lock);
|
||||||
if (!list_empty(&msta_link->wcid.poll_list))
|
if (!list_empty(&msta_link->wcid.poll_list))
|
||||||
list_del_init(&msta_link->wcid.poll_list);
|
list_del_init(&msta_link->wcid.poll_list);
|
||||||
@@ -1187,31 +1195,13 @@ void mt7996_mac_sta_deinit_link(struct mt7996_dev *dev,
|
|||||||
list_del_init(&msta_link->rc_list);
|
list_del_init(&msta_link->rc_list);
|
||||||
spin_unlock_bh(&dev->mt76.sta_poll_lock);
|
spin_unlock_bh(&dev->mt76.sta_poll_lock);
|
||||||
|
|
||||||
rcu_assign_pointer(dev->mt76.wcid[msta_link->wcid.idx], NULL);
|
|
||||||
mt76_wcid_cleanup(&dev->mt76, &msta_link->wcid);
|
mt76_wcid_cleanup(&dev->mt76, &msta_link->wcid);
|
||||||
mt76_wcid_mask_clear(dev->mt76.wcid_mask, msta_link->wcid.idx);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
if (msta_link->wcid.link_valid) {
|
||||||
mt7996_mac_sta_remove_links(struct mt7996_dev *dev, struct ieee80211_vif *vif,
|
|
||||||
struct ieee80211_sta *sta, unsigned long links)
|
|
||||||
{
|
|
||||||
struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
|
|
||||||
struct mt76_dev *mdev = &dev->mt76;
|
|
||||||
unsigned int link_id;
|
|
||||||
|
|
||||||
for_each_set_bit(link_id, &links, IEEE80211_MLD_MAX_NUM_LINKS) {
|
|
||||||
struct mt7996_sta_link *msta_link = NULL;
|
|
||||||
struct mt7996_phy *phy;
|
struct mt7996_phy *phy;
|
||||||
|
|
||||||
msta_link = rcu_replace_pointer(msta->link[link_id], msta_link,
|
|
||||||
lockdep_is_held(&mdev->mutex));
|
|
||||||
if (!msta_link)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
mt7996_mac_wtbl_update(dev, msta_link->wcid.idx,
|
mt7996_mac_wtbl_update(dev, msta_link->wcid.idx,
|
||||||
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
|
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
|
||||||
mt7996_mac_sta_deinit_link(dev, msta_link);
|
|
||||||
|
|
||||||
phy = __mt7996_phy(dev, msta_link->wcid.phy_idx);
|
phy = __mt7996_phy(dev, msta_link->wcid.phy_idx);
|
||||||
if (phy)
|
if (phy)
|
||||||
@@ -1228,7 +1218,7 @@ mt7996_mac_sta_remove_links(struct mt7996_dev *dev, struct ieee80211_vif *vif,
|
|||||||
/* switch to the secondary link */
|
/* switch to the secondary link */
|
||||||
msta_seclink = mt76_dereference(
|
msta_seclink = mt76_dereference(
|
||||||
msta->link[msta->seclink_id],
|
msta->link[msta->seclink_id],
|
||||||
mdev);
|
&dev->mt76);
|
||||||
if (msta_seclink) {
|
if (msta_seclink) {
|
||||||
msta->deflink_id = msta->seclink_id;
|
msta->deflink_id = msta->seclink_id;
|
||||||
mt7996_sta_init_txq_wcid(sta,
|
mt7996_sta_init_txq_wcid(sta,
|
||||||
@@ -1238,12 +1228,29 @@ mt7996_mac_sta_remove_links(struct mt7996_dev *dev, struct ieee80211_vif *vif,
|
|||||||
} else if (msta->seclink_id == link_id) {
|
} else if (msta->seclink_id == link_id) {
|
||||||
msta->seclink_id = msta->deflink_id;
|
msta->seclink_id = msta->deflink_id;
|
||||||
}
|
}
|
||||||
|
msta_link->wcid.link_valid = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flush) {
|
||||||
|
rcu_assign_pointer(msta->link[link_id], NULL);
|
||||||
|
rcu_assign_pointer(dev->mt76.wcid[msta_link->wcid.idx], NULL);
|
||||||
|
mt76_wcid_mask_clear(dev->mt76.wcid_mask, msta_link->wcid.idx);
|
||||||
if (msta_link != &msta->deflink)
|
if (msta_link != &msta->deflink)
|
||||||
kfree_rcu(msta_link, rcu_head);
|
kfree_rcu(msta_link, rcu_head);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
mt7996_mac_sta_remove_links(struct mt7996_dev *dev, struct ieee80211_vif *vif,
|
||||||
|
struct ieee80211_sta *sta, unsigned long links,
|
||||||
|
bool flush)
|
||||||
|
{
|
||||||
|
unsigned int link_id;
|
||||||
|
|
||||||
|
for_each_set_bit(link_id, &links, IEEE80211_MLD_MAX_NUM_LINKS)
|
||||||
|
mt7996_mac_sta_remove_link(dev, sta, link_id, flush);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
mt7996_mac_sta_add_links(struct mt7996_dev *dev, struct ieee80211_vif *vif,
|
mt7996_mac_sta_add_links(struct mt7996_dev *dev, struct ieee80211_vif *vif,
|
||||||
struct ieee80211_sta *sta, unsigned long new_links)
|
struct ieee80211_sta *sta, unsigned long new_links)
|
||||||
@@ -1255,11 +1262,15 @@ mt7996_mac_sta_add_links(struct mt7996_dev *dev, struct ieee80211_vif *vif,
|
|||||||
for_each_set_bit(link_id, &new_links, IEEE80211_MLD_MAX_NUM_LINKS) {
|
for_each_set_bit(link_id, &new_links, IEEE80211_MLD_MAX_NUM_LINKS) {
|
||||||
struct ieee80211_bss_conf *link_conf;
|
struct ieee80211_bss_conf *link_conf;
|
||||||
struct ieee80211_link_sta *link_sta;
|
struct ieee80211_link_sta *link_sta;
|
||||||
|
struct mt7996_sta_link *msta_link;
|
||||||
struct mt7996_vif_link *link;
|
struct mt7996_vif_link *link;
|
||||||
struct mt76_phy *mphy;
|
struct mt76_phy *mphy;
|
||||||
|
|
||||||
if (rcu_access_pointer(msta->link[link_id]))
|
msta_link = mt76_dereference(msta->link[link_id], &dev->mt76);
|
||||||
|
if (msta_link) {
|
||||||
|
msta_link->wcid.link_valid = true;
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
link_conf = link_conf_dereference_protected(vif, link_id);
|
link_conf = link_conf_dereference_protected(vif, link_id);
|
||||||
if (!link_conf) {
|
if (!link_conf) {
|
||||||
@@ -1296,7 +1307,7 @@ mt7996_mac_sta_add_links(struct mt7996_dev *dev, struct ieee80211_vif *vif,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error_unlink:
|
error_unlink:
|
||||||
mt7996_mac_sta_remove_links(dev, vif, sta, new_links);
|
mt7996_mac_sta_remove_links(dev, vif, sta, new_links, true);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@@ -1313,7 +1324,7 @@ mt7996_mac_sta_change_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
|||||||
|
|
||||||
mutex_lock(&dev->mt76.mutex);
|
mutex_lock(&dev->mt76.mutex);
|
||||||
|
|
||||||
mt7996_mac_sta_remove_links(dev, vif, sta, rem);
|
mt7996_mac_sta_remove_links(dev, vif, sta, rem, false);
|
||||||
ret = mt7996_mac_sta_add_links(dev, vif, sta, add);
|
ret = mt7996_mac_sta_add_links(dev, vif, sta, add);
|
||||||
|
|
||||||
mutex_unlock(&dev->mt76.mutex);
|
mutex_unlock(&dev->mt76.mutex);
|
||||||
@@ -1422,10 +1433,12 @@ static void
|
|||||||
mt7996_mac_sta_remove(struct mt7996_dev *dev, struct ieee80211_vif *vif,
|
mt7996_mac_sta_remove(struct mt7996_dev *dev, struct ieee80211_vif *vif,
|
||||||
struct ieee80211_sta *sta)
|
struct ieee80211_sta *sta)
|
||||||
{
|
{
|
||||||
unsigned long links = sta->valid_links ? sta->valid_links : BIT(0);
|
struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
|
||||||
|
int i;
|
||||||
|
|
||||||
mutex_lock(&dev->mt76.mutex);
|
mutex_lock(&dev->mt76.mutex);
|
||||||
mt7996_mac_sta_remove_links(dev, vif, sta, links);
|
for (i = 0; i < ARRAY_SIZE(msta->link); i++)
|
||||||
|
mt7996_mac_sta_remove_link(dev, sta, i, true);
|
||||||
mutex_unlock(&dev->mt76.mutex);
|
mutex_unlock(&dev->mt76.mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -886,8 +886,9 @@ void mt7996_mac_twt_teardown_flow(struct mt7996_dev *dev,
|
|||||||
struct mt7996_vif_link *link,
|
struct mt7996_vif_link *link,
|
||||||
struct mt7996_sta_link *msta_link,
|
struct mt7996_sta_link *msta_link,
|
||||||
u8 flowid);
|
u8 flowid);
|
||||||
void mt7996_mac_sta_deinit_link(struct mt7996_dev *dev,
|
void mt7996_mac_sta_remove_link(struct mt7996_dev *dev,
|
||||||
struct mt7996_sta_link *msta_link);
|
struct ieee80211_sta *sta,
|
||||||
|
unsigned int link_id, bool flush);
|
||||||
void mt7996_mac_add_twt_setup(struct ieee80211_hw *hw,
|
void mt7996_mac_add_twt_setup(struct ieee80211_hw *hw,
|
||||||
struct ieee80211_sta *sta,
|
struct ieee80211_sta *sta,
|
||||||
struct ieee80211_twt_setup *twt);
|
struct ieee80211_twt_setup *twt);
|
||||||
|
|||||||
Reference in New Issue
Block a user