mirror of
https://github.com/outbackdingo/mt76.git
synced 2026-10-24 13:26:48 +00:00
wifi: mt76: mt7996: Destroy vif active links in mt7996_remove_interface()
MT7996 hw requires to remove active links from the mcu BSSINFO table destroying the interface. For this reason introduce mt7996_vif_link_destroy routine and remove active (non-offchannel) vif links running mt7996_remove_interface routine. This is a preliminary patch in order to support MLO link reconfiguration in MT7996 driver. Co-developed-by: Shayne Chen <[email protected]> Signed-off-by: Shayne Chen <[email protected]> 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
ade83e44ed
commit
efebeea5c0
+72
-36
@@ -305,6 +305,10 @@ int mt7996_vif_link_add(struct mt76_phy *mphy, struct ieee80211_vif *vif,
|
|||||||
};
|
};
|
||||||
int mld_idx, idx, ret;
|
int mld_idx, idx, ret;
|
||||||
|
|
||||||
|
if ((mvif->mt76.valid_links & BIT(link_conf->link_id)) &&
|
||||||
|
!mlink->offchannel)
|
||||||
|
return 0;
|
||||||
|
|
||||||
mlink->idx = __ffs64(~dev->mt76.vif_mask);
|
mlink->idx = __ffs64(~dev->mt76.vif_mask);
|
||||||
if (mlink->idx >= mt7996_max_interface_num(dev))
|
if (mlink->idx >= mt7996_max_interface_num(dev))
|
||||||
return -ENOSPC;
|
return -ENOSPC;
|
||||||
@@ -392,65 +396,40 @@ int mt7996_vif_link_add(struct mt76_phy *mphy, struct ieee80211_vif *vif,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mt7996_vif_link_remove(struct mt76_phy *mphy, struct ieee80211_vif *vif,
|
static void mt7996_vif_link_destroy(struct mt7996_phy *phy,
|
||||||
struct ieee80211_bss_conf *link_conf,
|
struct mt7996_vif_link *link,
|
||||||
struct mt76_vif_link *mlink)
|
struct ieee80211_vif *vif,
|
||||||
|
struct ieee80211_bss_conf *link_conf)
|
||||||
{
|
{
|
||||||
struct mt7996_vif_link *link = container_of(mlink, struct mt7996_vif_link, mt76);
|
|
||||||
struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
|
struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
|
||||||
struct mt7996_sta_link *msta_link = &link->msta_link;
|
struct mt7996_sta_link *msta_link = &link->msta_link;
|
||||||
unsigned int link_id = msta_link->wcid.link_id;
|
unsigned int link_id = msta_link->wcid.link_id;
|
||||||
struct mt7996_phy *phy = mphy->priv;
|
struct mt76_vif_link *mlink = &link->mt76;
|
||||||
struct mt7996_dev *dev = phy->dev;
|
|
||||||
struct mt7996_key_iter_data it = {
|
struct mt7996_key_iter_data it = {
|
||||||
.cmd = SET_KEY,
|
.cmd = SET_KEY,
|
||||||
.link_id = link_id,
|
.link_id = link_id,
|
||||||
};
|
};
|
||||||
|
struct mt7996_dev *dev = phy->dev;
|
||||||
int idx = msta_link->wcid.idx;
|
int idx = msta_link->wcid.idx;
|
||||||
|
|
||||||
if (!mlink->wcid->offchannel)
|
|
||||||
ieee80211_iter_keys(mphy->hw, vif, mt7996_key_iter, &it);
|
|
||||||
|
|
||||||
if (!link_conf)
|
if (!link_conf)
|
||||||
link_conf = &vif->bss_conf;
|
link_conf = &vif->bss_conf;
|
||||||
|
|
||||||
|
if (!mlink->wcid->offchannel)
|
||||||
|
ieee80211_iter_keys(phy->mt76->hw, vif, mt7996_key_iter, &it);
|
||||||
|
|
||||||
mt7996_mcu_add_sta(dev, link_conf, NULL, link, NULL,
|
mt7996_mcu_add_sta(dev, link_conf, NULL, link, NULL,
|
||||||
CONN_STATE_DISCONNECT, false);
|
CONN_STATE_DISCONNECT, false);
|
||||||
mt7996_mcu_add_bss_info(phy, vif, link_conf, mlink, msta_link, false);
|
mt7996_mcu_add_bss_info(phy, vif, link_conf, mlink, msta_link, false);
|
||||||
|
|
||||||
mt7996_mcu_add_dev_info(phy, vif, link_conf, mlink, false);
|
mt7996_mcu_add_dev_info(phy, vif, link_conf, mlink, false);
|
||||||
|
|
||||||
rcu_assign_pointer(dev->mt76.wcid[idx], NULL);
|
rcu_assign_pointer(dev->mt76.wcid[idx], NULL);
|
||||||
|
|
||||||
if (!mlink->wcid->offchannel) {
|
|
||||||
if (vif->txq && mvif->mt76.deflink_id == link_id) {
|
|
||||||
struct ieee80211_bss_conf *iter;
|
|
||||||
struct mt76_txq *mtxq;
|
|
||||||
|
|
||||||
mvif->mt76.deflink_id = IEEE80211_LINK_UNSPECIFIED;
|
|
||||||
mtxq = (struct mt76_txq *)vif->txq->drv_priv;
|
|
||||||
/* Primary link will be removed, look for a new one */
|
|
||||||
for_each_vif_active_link(vif, iter, link_id) {
|
|
||||||
struct mt7996_vif_link *link;
|
|
||||||
|
|
||||||
if (link_id == msta_link->wcid.link_id)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
link = mt7996_vif_link(dev, vif, link_id);
|
|
||||||
if (!link)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
mtxq->wcid = link->msta_link.wcid.idx;
|
|
||||||
mvif->mt76.deflink_id = link_id;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mvif->mt76.valid_links &= ~BIT(link_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
dev->mt76.vif_mask &= ~BIT_ULL(mlink->idx);
|
dev->mt76.vif_mask &= ~BIT_ULL(mlink->idx);
|
||||||
dev->mld_idx_mask &= ~BIT_ULL(link->mld_idx);
|
dev->mld_idx_mask &= ~BIT_ULL(link->mld_idx);
|
||||||
phy->omac_mask &= ~BIT_ULL(mlink->omac_idx);
|
phy->omac_mask &= ~BIT_ULL(mlink->omac_idx);
|
||||||
|
if (!mlink->wcid->offchannel)
|
||||||
|
mvif->mt76.valid_links &= ~BIT(link_id);
|
||||||
|
|
||||||
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))
|
||||||
@@ -466,6 +445,44 @@ void mt7996_vif_link_remove(struct mt76_phy *mphy, struct ieee80211_vif *vif,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mt7996_vif_link_remove(struct mt76_phy *mphy, struct ieee80211_vif *vif,
|
||||||
|
struct ieee80211_bss_conf *link_conf,
|
||||||
|
struct mt76_vif_link *mlink)
|
||||||
|
{
|
||||||
|
struct mt7996_vif_link *link = container_of(mlink, struct mt7996_vif_link, mt76);
|
||||||
|
struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
|
||||||
|
struct mt7996_sta_link *msta_link = &link->msta_link;
|
||||||
|
struct mt7996_phy *phy = mphy->priv;
|
||||||
|
|
||||||
|
/* Hw requires to destroy active links tearing down the interface, so
|
||||||
|
* postpone it removing the interface.
|
||||||
|
*/
|
||||||
|
if (mlink->wcid->offchannel) {
|
||||||
|
mt7996_vif_link_destroy(phy, link, vif, link_conf);
|
||||||
|
} else if (vif->txq &&
|
||||||
|
mvif->mt76.deflink_id == msta_link->wcid.link_id) {
|
||||||
|
struct ieee80211_bss_conf *iter;
|
||||||
|
struct mt76_txq *mtxq;
|
||||||
|
unsigned int link_id;
|
||||||
|
|
||||||
|
mvif->mt76.deflink_id = IEEE80211_LINK_UNSPECIFIED;
|
||||||
|
mtxq = (struct mt76_txq *)vif->txq->drv_priv;
|
||||||
|
/* Primary link will be removed, look for a new one */
|
||||||
|
for_each_vif_active_link(vif, iter, link_id) {
|
||||||
|
if (link_id == msta_link->wcid.link_id)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
link = mt7996_vif_link(phy->dev, vif, link_id);
|
||||||
|
if (!link)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
mtxq->wcid = link->msta_link.wcid.idx;
|
||||||
|
mvif->mt76.deflink_id = link_id;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void mt7996_phy_set_rxfilter(struct mt7996_phy *phy)
|
static void mt7996_phy_set_rxfilter(struct mt7996_phy *phy)
|
||||||
{
|
{
|
||||||
struct mt7996_dev *dev = phy->dev;
|
struct mt7996_dev *dev = phy->dev;
|
||||||
@@ -569,10 +586,29 @@ static void mt7996_remove_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
|
|||||||
static void mt7996_remove_interface(struct ieee80211_hw *hw,
|
static void mt7996_remove_interface(struct ieee80211_hw *hw,
|
||||||
struct ieee80211_vif *vif)
|
struct ieee80211_vif *vif)
|
||||||
{
|
{
|
||||||
|
struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
|
||||||
|
unsigned long rem_links = mvif->mt76.valid_links;
|
||||||
struct mt7996_dev *dev = mt7996_hw_dev(hw);
|
struct mt7996_dev *dev = mt7996_hw_dev(hw);
|
||||||
struct mt7996_radio_data rdata = {};
|
struct mt7996_radio_data rdata = {};
|
||||||
|
unsigned int link_id;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
/* Remove all active links */
|
||||||
|
for_each_set_bit(link_id, &rem_links, IEEE80211_MLD_MAX_NUM_LINKS) {
|
||||||
|
struct mt7996_vif_link *link;
|
||||||
|
struct mt7996_phy *phy;
|
||||||
|
|
||||||
|
link = mt7996_vif_link(dev, vif, link_id);
|
||||||
|
if (!link)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
phy = __mt7996_phy(dev, link->msta_link.wcid.phy_idx);
|
||||||
|
if (!phy)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
mt7996_vif_link_destroy(phy, link, vif, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
ieee80211_iterate_active_interfaces_mtx(hw, 0, mt7996_remove_iter,
|
ieee80211_iterate_active_interfaces_mtx(hw, 0, mt7996_remove_iter,
|
||||||
&rdata);
|
&rdata);
|
||||||
mt76_vif_cleanup(&dev->mt76, vif);
|
mt76_vif_cleanup(&dev->mt76, vif);
|
||||||
|
|||||||
Reference in New Issue
Block a user