@@ -1516,37 +1516,39 @@ void mt76_rx_poll_complete(struct mt76_dev *dev, enum mt76_rxq_id q,
}
EXPORT_SYMBOL_GPL(mt76_rx_poll_complete);
-static int
-mt76_sta_add(struct mt76_phy *phy, struct ieee80211_vif *vif,
- struct ieee80211_sta *sta)
+void __mt76_sta_common_init(struct mt76_phy *phy, struct mt76_wcid *wcid,
+ struct ieee80211_sta *sta, bool primary_link)
{
- struct mt76_wcid *wcid = (struct mt76_wcid *)sta->drv_priv;
struct mt76_dev *dev = phy->dev;
- int ret;
int i;
- mutex_lock(&dev->mutex);
-
- ret = dev->drv->sta_add(dev, vif, sta);
- if (ret)
- goto out;
+ if (primary_link) {
+ for (i = 0; i < ARRAY_SIZE(sta->txq); i++) {
+ struct mt76_txq *mtxq;
- for (i = 0; i < ARRAY_SIZE(sta->txq); i++) {
- struct mt76_txq *mtxq;
+ if (!sta->txq[i])
+ continue;
- if (!sta->txq[i])
- continue;
-
- mtxq = (struct mt76_txq *)sta->txq[i]->drv_priv;
- mtxq->wcid = wcid->idx;
+ mtxq = (struct mt76_txq *)sta->txq[i]->drv_priv;
+ mtxq->wcid = wcid->idx;
+ }
+ phy->num_sta++;
}
-
ewma_signal_init(&wcid->rssi);
rcu_assign_pointer(dev->wcid[wcid->idx], wcid);
- phy->num_sta++;
-
mt76_wcid_init(wcid, phy->band_idx);
-out:
+}
+EXPORT_SYMBOL_GPL(__mt76_sta_common_init);
+
+static int
+mt76_sta_add(struct mt76_phy *phy, struct ieee80211_vif *vif,
+ struct ieee80211_sta *sta)
+{
+ struct mt76_dev *dev = phy->dev;
+ int ret;
+
+ mutex_lock(&dev->mutex);
+ ret = dev->drv->sta_add(dev, vif, sta);
mutex_unlock(&dev->mutex);
return ret;
@@ -1471,6 +1471,15 @@ mt76_tx_complete_skb(struct mt76_dev *dev, u16 wcid, struct sk_buff *skb)
}
void mt76_tx_status_check(struct mt76_dev *dev, bool flush);
+void __mt76_sta_common_init(struct mt76_phy *phy, struct mt76_wcid *wcid,
+ struct ieee80211_sta *sta, bool primary_link);
+static inline void mt76_sta_common_init(struct mt76_phy *phy,
+ struct mt76_wcid *wcid,
+ struct ieee80211_sta *sta)
+{
+ __mt76_sta_common_init(phy, wcid, sta, true);
+}
+
int mt76_sta_state(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
struct ieee80211_sta *sta,
enum ieee80211_sta_state old_state,
@@ -350,6 +350,8 @@ mt7603_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
if (vif->type == NL80211_IFTYPE_AP)
set_bit(MT_WCID_FLAG_CHECK_PS, &msta->wcid.flags);
+ mt76_sta_common_init(&dev->mphy, &msta->wcid, sta);
+
return ret;
}
@@ -666,6 +666,7 @@ int mt7615_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
if (err)
return err;
+ mt76_sta_common_init(phy->mt76, &msta->wcid, sta);
mt76_connac_power_save_sched(phy->mt76, &dev->pm);
return err;
@@ -260,6 +260,8 @@ int mt76x02_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
if (vif->type == NL80211_IFTYPE_AP)
set_bit(MT_WCID_FLAG_CHECK_PS, &msta->wcid.flags);
+ mt76_sta_common_init(&dev->mphy, &msta->wcid, sta);
+
return 0;
}
EXPORT_SYMBOL_GPL(mt76x02_sta_add);
@@ -763,6 +763,7 @@ int mt7915_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
mt7915_mac_wtbl_update(dev, idx,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
mt7915_mcu_add_sta(dev, vif, sta, CONN_STATE_DISCONNECT, true);
+ mt76_sta_common_init(mvif->phy->mt76, &msta->wcid, sta);
return 0;
}
@@ -829,6 +829,7 @@ int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
mt7921_regd_set_6ghz_power_type(vif, true);
+ mt76_sta_common_init(&dev->mphy, &msta->deflink.wcid, sta);
mt76_connac_power_save_sched(&dev->mphy, &dev->pm);
return 0;
@@ -972,6 +972,7 @@ int mt7925_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
} else {
err = mt7925_mac_link_sta_add(mdev, vif, &sta->deflink);
}
+ mt76_sta_common_init(&dev->mphy, &msta->deflink.wcid, sta);
return err;
}
@@ -795,7 +795,8 @@ int mt7996_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
struct mt7996_sta_link *msta_link = &msta->deflink;
struct mt7996_vif_link *link = &mvif->deflink;
- u8 band_idx = link->phy->mt76->band_idx;
+ struct mt7996_phy *phy = link->phy;
+ u8 band_idx = phy->mt76->band_idx;
int idx;
idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7996_WTBL_STA);
@@ -816,6 +817,7 @@ int mt7996_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
mt7996_mcu_add_sta(dev, vif, &link->mt76, sta, CONN_STATE_DISCONNECT,
true);
+ mt76_sta_common_init(phy->mt76, &msta_link->wcid, sta);
return 0;
}
Move sta common initialization in sta_add callback introducing mt76_sta_common_init utility routine. This change is needed to allow the SoC driver to select the proper wcid identifying the sta link. This is a preliminary patch to add MLO support for MT7996 driver. Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> --- drivers/net/wireless/mediatek/mt76/mac80211.c | 44 ++++++++++++----------- drivers/net/wireless/mediatek/mt76/mt76.h | 9 +++++ drivers/net/wireless/mediatek/mt76/mt7603/main.c | 2 ++ drivers/net/wireless/mediatek/mt76/mt7615/main.c | 1 + drivers/net/wireless/mediatek/mt76/mt76x02_util.c | 2 ++ drivers/net/wireless/mediatek/mt76/mt7915/main.c | 1 + drivers/net/wireless/mediatek/mt76/mt7921/main.c | 1 + drivers/net/wireless/mediatek/mt76/mt7925/main.c | 1 + drivers/net/wireless/mediatek/mt76/mt7996/main.c | 4 ++- 9 files changed, 43 insertions(+), 22 deletions(-)