blob: 8af548bdc0f485a5c0901744cd4e930f1da11709 [file] [log] [blame]
From 25ff83d103d13952ffeb4cddac9c366b91eb0416 Mon Sep 17 00:00:00 2001
From: Shayne Chen <shayne.chen@mediatek.com>
Date: Wed, 8 Nov 2023 18:52:26 +0800
Subject: [PATCH 100/120] wifi: mt76: mt7996: use .sta_state to replace
.sta_add and .sta_remove
MAC80211 mostly uses MLD address through TX path, and leaves the header
translation procedure to driver. To perform address translation, driver
needs to get the setup link address at early stage (i.e., state 1),
however, when using .sta_add/.sta_remove callbacks, driver can only get
the link address at state 3, so it's necessary to switch to .sta_state
callback to meet this requirement.
This is a preliminary patch to add MLO support for mt7996 chipsets.
Change-Id: I8a0faef919843f2c7d5ff3256702a3bf8384ea60
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
---
mt7996/main.c | 53 ++++++++++++++++++++-----------------------------
mt7996/mmio.c | 1 +
mt7996/mt7996.h | 2 ++
3 files changed, 24 insertions(+), 32 deletions(-)
diff --git a/mt7996/main.c b/mt7996/main.c
index aa52f5d32..66376e27c 100644
--- a/mt7996/main.c
+++ b/mt7996/main.c
@@ -782,7 +782,7 @@ int mt7996_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
u8 band_idx = mvif->phy->mt76->band_idx;
- int ret, idx;
+ int idx;
#ifdef CONFIG_MTK_VENDOR
struct mt7996_phy *phy = &dev->phy;
@@ -800,23 +800,10 @@ int mt7996_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
msta->wcid.phy_idx = band_idx;
msta->wcid.tx_info |= MT_WCID_TX_INFO_SET;
- ewma_avg_signal_init(&msta->avg_ack_signal);
-
- mt7996_mac_wtbl_update(dev, idx,
- MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
-
#ifdef CONFIG_MTK_VENDOR
mt7996_vendor_amnt_sta_remove(mvif->phy, sta);
#endif
- ret = mt7996_mcu_add_sta(dev, vif, sta, true, true);
- if (ret)
- return ret;
-
- ret = mt7996_mcu_add_rate_ctrl(dev, vif, sta, false);
- if (ret)
- return ret;
-
#ifdef CONFIG_MTK_VENDOR
switch (band_idx) {
case MT_BAND1:
@@ -837,6 +824,25 @@ int mt7996_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
return 0;
}
+void mt7996_mac_sta_assoc(struct mt76_dev *mdev, struct ieee80211_vif *vif,
+ struct ieee80211_sta *sta)
+{
+ struct mt7996_dev *dev = container_of(mdev, struct mt7996_dev, mt76);
+ struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
+
+ mutex_lock(&dev->mt76.mutex);
+
+ mt7996_mac_wtbl_update(dev, msta->wcid.idx,
+ MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
+
+ mt7996_mcu_add_sta(dev, vif, sta, true, true);
+ mt7996_mcu_add_rate_ctrl(dev, vif, sta, false);
+
+ ewma_avg_signal_init(&msta->avg_ack_signal);
+
+ mutex_unlock(&dev->mt76.mutex);
+}
+
void mt7996_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
struct ieee80211_sta *sta)
{
@@ -956,22 +962,6 @@ mt7996_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
return ret;
}
-static int
-mt7996_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
- struct ieee80211_sta *sta)
-{
- return mt76_sta_state(hw, vif, sta, IEEE80211_STA_NOTEXIST,
- IEEE80211_STA_NONE);
-}
-
-static int
-mt7996_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
- struct ieee80211_sta *sta)
-{
- return mt76_sta_state(hw, vif, sta, IEEE80211_STA_NONE,
- IEEE80211_STA_NOTEXIST);
-}
-
static int
mt7996_get_stats(struct ieee80211_hw *hw,
struct ieee80211_low_level_stats *stats)
@@ -1864,8 +1854,7 @@ const struct ieee80211_ops mt7996_ops = {
.conf_tx = mt7996_conf_tx,
.configure_filter = mt7996_configure_filter,
.bss_info_changed = mt7996_bss_info_changed,
- .sta_add = mt7996_sta_add,
- .sta_remove = mt7996_sta_remove,
+ .sta_state = mt76_sta_state,
.sta_pre_rcu_remove = mt76_sta_pre_rcu_remove,
.sta_rc_update = mt7996_sta_rc_update,
.set_key = mt7996_set_key,
diff --git a/mt7996/mmio.c b/mt7996/mmio.c
index 764c12445..61b1d7d62 100644
--- a/mt7996/mmio.c
+++ b/mt7996/mmio.c
@@ -644,6 +644,7 @@ struct mt7996_dev *mt7996_mmio_probe(struct device *pdev,
.rx_check = mt7996_rx_check,
.rx_poll_complete = mt7996_rx_poll_complete,
.sta_add = mt7996_mac_sta_add,
+ .sta_assoc = mt7996_mac_sta_assoc,
.sta_remove = mt7996_mac_sta_remove,
.update_survey = mt7996_update_channel,
};
diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h
index 08c27d37d..110979452 100644
--- a/mt7996/mt7996.h
+++ b/mt7996/mt7996.h
@@ -961,6 +961,8 @@ void mt7996_mac_write_txwi(struct mt7996_dev *dev, __le32 *txwi,
void mt7996_mac_set_coverage_class(struct mt7996_phy *phy);
int mt7996_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
struct ieee80211_sta *sta);
+void mt7996_mac_sta_assoc(struct mt76_dev *mdev, struct ieee80211_vif *vif,
+ struct ieee80211_sta *sta);
void mt7996_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
struct ieee80211_sta *sta);
void mt7996_mac_work(struct work_struct *work);
--
2.39.2