| From 3e111fa2be564cc27c213471242f6b6b920e253c 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 085/116] 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 dd4f3a711..c330dd479 100644 |
| --- a/mt7996/main.c |
| +++ b/mt7996/main.c |
| @@ -784,7 +784,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; |
| @@ -802,23 +802,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: |
| @@ -839,6 +826,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) |
| { |
| @@ -958,22 +964,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) |
| @@ -1877,8 +1867,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 6028182e1..6abbcb68e 100644 |
| --- a/mt7996/mmio.c |
| +++ b/mt7996/mmio.c |
| @@ -655,6 +655,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 84aafb404..2b266d18b 100644 |
| --- a/mt7996/mt7996.h |
| +++ b/mt7996/mt7996.h |
| @@ -966,6 +966,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 |
| |