wifi: mt76: mt7996: rework mt7996_mac_sta_rc_work to support MLO

Rework mt7996_mac_sta_rc_work routine in order to support multi-link
setup.

Co-developed-by: Bo Jiao <Bo.Jiao@mediatek.com>
Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com>
Co-developed-by: Peter Chiu <chui-hao.chiu@mediatek.com>
Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
Co-developed-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://patch.msgid.link/20250312-b4-mt7996-mlo-p2-v1-12-015b3d6fd928@kernel.org
Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
Lorenzo Bianconi 2025-03-12 12:13:56 +01:00 committed by Felix Fietkau
parent 601e4adc65
commit 0762bdd302
2 changed files with 52 additions and 18 deletions

View file

@ -2300,13 +2300,20 @@ void mt7996_mac_update_stats(struct mt7996_phy *phy)
void mt7996_mac_sta_rc_work(struct work_struct *work)
{
struct mt7996_dev *dev = container_of(work, struct mt7996_dev, rc_work);
struct ieee80211_bss_conf *link_conf;
struct ieee80211_link_sta *link_sta;
struct mt7996_sta_link *msta_link;
struct mt7996_vif_link *link;
struct mt76_vif_link *mlink;
struct ieee80211_sta *sta;
struct ieee80211_vif *vif;
struct mt7996_sta *msta;
u32 changed;
struct mt7996_vif *mvif;
LIST_HEAD(list);
u32 changed;
u8 link_id;
rcu_read_lock();
spin_lock_bh(&dev->mt76.sta_poll_lock);
list_splice_init(&dev->sta_rc_list, &list);
@ -2319,21 +2326,35 @@ void mt7996_mac_sta_rc_work(struct work_struct *work)
msta_link->changed = 0;
spin_unlock_bh(&dev->mt76.sta_poll_lock);
sta = wcid_to_sta(&msta_link->wcid);
link_id = msta_link->wcid.link_id;
msta = msta_link->sta;
sta = container_of((void *)msta, struct ieee80211_sta, drv_priv);
vif = container_of((void *)msta->vif, struct ieee80211_vif, drv_priv);
mvif = msta->vif;
vif = container_of((void *)mvif, struct ieee80211_vif, drv_priv);
mlink = rcu_dereference(mvif->mt76.link[link_id]);
if (!mlink)
continue;
link_sta = rcu_dereference(sta->link[link_id]);
if (!link_sta)
continue;
link_conf = rcu_dereference(vif->link_conf[link_id]);
if (!link_conf)
continue;
link = (struct mt7996_vif_link *)mlink;
if (changed & (IEEE80211_RC_SUPP_RATES_CHANGED |
IEEE80211_RC_NSS_CHANGED |
IEEE80211_RC_BW_CHANGED))
mt7996_mcu_add_rate_ctrl(dev, vif, &vif->bss_conf,
&sta->deflink,
&msta->vif->deflink,
msta_link, true);
mt7996_mcu_add_rate_ctrl(dev, vif, link_conf,
link_sta, link, msta_link,
true);
if (changed & IEEE80211_RC_SMPS_CHANGED)
mt7996_mcu_set_fixed_field(dev, &sta->deflink,
&msta->vif->deflink,
mt7996_mcu_set_fixed_field(dev, link_sta, link,
msta_link, NULL,
RATE_PARAM_MMPS_UPDATE);
@ -2341,6 +2362,7 @@ void mt7996_mac_sta_rc_work(struct work_struct *work)
}
spin_unlock_bh(&dev->mt76.sta_poll_lock);
rcu_read_unlock();
}
void mt7996_mac_work(struct work_struct *work)

View file

@ -304,6 +304,7 @@ int mt7996_vif_link_add(struct mt76_phy *mphy, struct ieee80211_vif *vif,
INIT_LIST_HEAD(&msta_link->rc_list);
msta_link->wcid.idx = idx;
msta_link->wcid.link_id = link_conf->link_id;
msta_link->wcid.tx_info |= MT_WCID_TX_INFO_SET;
mt76_wcid_init(&msta_link->wcid, band_idx);
@ -1521,29 +1522,39 @@ static void mt7996_sta_statistics(struct ieee80211_hw *hw,
}
}
static void mt7996_sta_rc_work(void *data, struct ieee80211_sta *sta)
static void mt7996_link_rate_ctrl_update(void *data, struct ieee80211_sta *sta)
{
struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
struct mt7996_dev *dev = msta->vif->deflink.phy->dev;
struct mt7996_sta_link *msta_link = &msta->deflink;
struct mt7996_sta_link *msta_link;
u32 *changed = data;
rcu_read_lock();
msta_link = rcu_dereference(msta->link[msta->deflink_id]);
if (!msta_link)
goto out;
spin_lock_bh(&dev->mt76.sta_poll_lock);
msta_link->changed |= *changed;
if (list_empty(&msta_link->rc_list))
list_add_tail(&msta_link->rc_list, &dev->sta_rc_list);
spin_unlock_bh(&dev->mt76.sta_poll_lock);
out:
rcu_read_unlock();
}
static void mt7996_sta_rc_update(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
struct ieee80211_link_sta *link_sta,
u32 changed)
static void mt7996_link_sta_rc_update(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
struct ieee80211_link_sta *link_sta,
u32 changed)
{
struct mt7996_dev *dev = mt7996_hw_dev(hw);
struct ieee80211_sta *sta = link_sta->sta;
mt7996_sta_rc_work(&changed, sta);
mt7996_link_rate_ctrl_update(&changed, sta);
ieee80211_queue_work(hw, &dev->rc_work);
}
@ -1565,7 +1576,8 @@ mt7996_set_bitrate_mask(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
* - multiple rates: if it's not in range format i.e 0-{7,8,9} for VHT
* then multiple MCS setting (MCS 4,5,6) is not supported.
*/
ieee80211_iterate_stations_atomic(hw, mt7996_sta_rc_work, &changed);
ieee80211_iterate_stations_atomic(hw, mt7996_link_rate_ctrl_update,
&changed);
ieee80211_queue_work(hw, &dev->rc_work);
return 0;
@ -2023,7 +2035,7 @@ const struct ieee80211_ops mt7996_ops = {
.link_info_changed = mt7996_link_info_changed,
.sta_state = mt7996_sta_state,
.sta_pre_rcu_remove = mt76_sta_pre_rcu_remove,
.link_sta_rc_update = mt7996_sta_rc_update,
.link_sta_rc_update = mt7996_link_sta_rc_update,
.set_key = mt7996_set_key,
.ampdu_action = mt7996_ampdu_action,
.set_rts_threshold = mt7996_set_rts_threshold,