From a5e630ef458ce7b91bf522247ef3320ed5845e2a Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 21 Aug 2024 16:50:05 +0200 Subject: [PATCH] wifi: mt76: mt7916: fix regression in .sta_state migration - initialize and use per-sta wcid entry instead of vif wcid - set wcid flags for 4addr/offload - fix 'newly' argument for vif sta entry update Signed-off-by: Felix Fietkau --- mac80211.c | 3 +-- mt76.h | 16 ---------------- mt7915/main.c | 39 ++++++++++++++++++--------------------- mt7915/mcu.c | 18 ++++++++++-------- 4 files changed, 29 insertions(+), 47 deletions(-) diff --git a/mac80211.c b/mac80211.c index 1d0e60c6..7934b5aa 100644 --- a/mac80211.c +++ b/mac80211.c @@ -1450,8 +1450,7 @@ mt76_sta_add(struct mt76_phy *phy, struct ieee80211_vif *vif, continue; mtxq = (struct mt76_txq *)sta->txq[i]->drv_priv; - if (!mtxq->wcid) - mtxq->wcid = wcid->idx; + mtxq->wcid = wcid->idx; } ewma_signal_init(&wcid->rssi); diff --git a/mt76.h b/mt76.h index 7e402f17..56cc2f95 100644 --- a/mt76.h +++ b/mt76.h @@ -1270,22 +1270,6 @@ mtxq_to_txq(struct mt76_txq *mtxq) return container_of(ptr, struct ieee80211_txq, drv_priv); } -static inline void -mt76_sta_set_txq_wcid(struct ieee80211_sta *sta, int idx) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(sta->txq); i++) { - struct mt76_txq *mtxq; - - if (!sta->txq[i]) - continue; - - mtxq = (struct mt76_txq *)sta->txq[i]->drv_priv; - mtxq->wcid = idx; - } -} - static inline struct ieee80211_sta * wcid_to_sta(struct mt76_wcid *wcid) { diff --git a/mt7915/main.c b/mt7915/main.c index 126aa60b..834b7ced 100644 --- a/mt7915/main.c +++ b/mt7915/main.c @@ -625,7 +625,7 @@ static void mt7915_bss_info_changed(struct ieee80211_hw *hw, if (set_bss_info == 1) mt7915_mcu_add_bss_info(phy, vif, true); if (set_sta == 1) - mt7915_mcu_add_sta(dev, vif, NULL, CONN_STATE_PORT_SECURE, true); + mt7915_mcu_add_sta(dev, vif, NULL, CONN_STATE_PORT_SECURE, false); if (changed & BSS_CHANGED_ERP_CTS_PROT) mt7915_mac_enable_rtscts(dev, vif, info->use_cts_prot); @@ -660,7 +660,7 @@ static void mt7915_bss_info_changed(struct ieee80211_hw *hw, if (set_bss_info == 0) mt7915_mcu_add_bss_info(phy, vif, false); if (set_sta == 0) - mt7915_mcu_add_sta(dev, vif, NULL, CONN_STATE_DISCONNECT, true); + mt7915_mcu_add_sta(dev, vif, NULL, CONN_STATE_DISCONNECT, false); mutex_unlock(&dev->mt76.mutex); } @@ -698,7 +698,7 @@ mt7915_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif, err = mt7915_mcu_add_bss_info(phy, vif, true); if (err) goto out; - err = mt7915_mcu_add_sta(dev, vif, NULL, CONN_STATE_PORT_SECURE, true); + err = mt7915_mcu_add_sta(dev, vif, NULL, CONN_STATE_PORT_SECURE, false); out: mutex_unlock(&dev->mt76.mutex); @@ -712,7 +712,7 @@ mt7915_stop_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct mt7915_dev *dev = mt7915_hw_dev(hw); mutex_lock(&dev->mt76.mutex); - mt7915_mcu_add_sta(dev, vif, NULL, CONN_STATE_DISCONNECT, true); + mt7915_mcu_add_sta(dev, vif, NULL, CONN_STATE_DISCONNECT, false); mutex_unlock(&dev->mt76.mutex); } @@ -744,16 +744,16 @@ int mt7915_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif, INIT_LIST_HEAD(&msta->rc_list); INIT_LIST_HEAD(&msta->wcid.poll_list); msta->vif = mvif; + msta->wcid.sta_disabled = 1; msta->wcid.idx = idx; msta->wcid.phy_idx = ext_phy; - msta->wcid.tx_info |= MT_WCID_TX_INFO_SET; msta->jiffies = jiffies; ewma_avg_signal_init(&msta->avg_ack_signal); mt7915_mac_wtbl_update(dev, idx, MT_WTBL_UPDATE_ADM_COUNT_CLEAR); - mt76_sta_set_txq_wcid(sta, mvif->sta.wcid.idx); + mt7915_mcu_add_sta(dev, vif, sta, CONN_STATE_DISCONNECT, true); return 0; } @@ -762,10 +762,9 @@ int mt7915_mac_sta_event(struct mt76_dev *mdev, struct ieee80211_vif *vif, struct ieee80211_sta *sta, enum mt76_sta_event ev) { struct mt7915_dev *dev = container_of(mdev, struct mt7915_dev, mt76); - struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; + int i, ret; u32 addr; - int ret; switch (ev) { case MT76_STA_EVENT_ASSOC: @@ -780,9 +779,9 @@ int mt7915_mac_sta_event(struct mt76_dev *mdev, struct ieee80211_vif *vif, if (ret) return ret; + msta->wcid.tx_info |= MT_WCID_TX_INFO_SET; msta->wcid.sta = 1; msta->wcid.sta_disabled = 0; - mt76_sta_set_txq_wcid(sta, msta->wcid.idx); return 0; @@ -790,8 +789,10 @@ int mt7915_mac_sta_event(struct mt76_dev *mdev, struct ieee80211_vif *vif, return mt7915_mcu_add_sta(dev, vif, sta, CONN_STATE_PORT_SECURE, false); case MT76_STA_EVENT_DISASSOC: + for (i = 0; i < ARRAY_SIZE(msta->twt.flow); i++) + mt7915_mac_twt_teardown_flow(dev, msta, i); + mt7915_mcu_add_sta(dev, vif, sta, CONN_STATE_DISCONNECT, false); - mt76_sta_set_txq_wcid(sta, mvif->sta.wcid.idx); msta->wcid.sta_disabled = 1; msta->wcid.sta = 0; return 0; @@ -805,14 +806,10 @@ void mt7915_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif, { struct mt7915_dev *dev = container_of(mdev, struct mt7915_dev, mt76); struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; - int i; mt7915_mac_wtbl_update(dev, msta->wcid.idx, MT_WTBL_UPDATE_ADM_COUNT_CLEAR); - for (i = 0; i < ARRAY_SIZE(msta->twt.flow); i++) - mt7915_mac_twt_teardown_flow(dev, msta, i); - spin_lock_bh(&mdev->sta_poll_lock); if (!list_empty(&msta->wcid.poll_list)) list_del_init(&msta->wcid.poll_list); @@ -838,7 +835,7 @@ static void mt7915_tx(struct ieee80211_hw *hw, wcid = &sta->wcid; } - if (vif && !wcid->sta) { + if (vif && !control->sta) { struct mt7915_vif *mvif; mvif = (struct mt7915_vif *)vif->drv_priv; @@ -1213,14 +1210,14 @@ static void mt7915_sta_set_4addr(struct ieee80211_hw *hw, struct mt7915_dev *dev = mt7915_hw_dev(hw); struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; - if (!msta->wcid.sta) - return; - if (enabled) set_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags); else clear_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags); + if (!msta->wcid.sta) + return; + mt76_connac_mcu_wtbl_update_hdr_trans(&dev->mt76, vif, sta); } @@ -1232,14 +1229,14 @@ static void mt7915_sta_set_decap_offload(struct ieee80211_hw *hw, struct mt7915_dev *dev = mt7915_hw_dev(hw); struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; - if (!msta->wcid.sta) - return; - if (enabled) set_bit(MT_WCID_FLAG_HDR_TRANS, &msta->wcid.flags); else clear_bit(MT_WCID_FLAG_HDR_TRANS, &msta->wcid.flags); + if (!msta->wcid.sta) + return; + mt76_connac_mcu_wtbl_update_hdr_trans(&dev->mt76, vif, sta); } diff --git a/mt7915/mcu.c b/mt7915/mcu.c index 0d42ea52..99ee62d3 100644 --- a/mt7915/mcu.c +++ b/mt7915/mcu.c @@ -1678,11 +1678,8 @@ int mt7915_mcu_add_sta(struct mt7915_dev *dev, struct ieee80211_vif *vif, /* starec basic */ mt76_connac_mcu_sta_basic_tlv(&dev->mt76, skb, vif, link_sta, conn_state, newly); - if (conn_state == CONN_STATE_DISCONNECT) - goto out; - /* tag order is in accordance with firmware dependency. */ - if (sta) { + if (sta && conn_state != CONN_STATE_DISCONNECT) { /* starec bfer */ mt7915_mcu_sta_bfer_tlv(dev, skb, vif, sta); /* starec ht */ @@ -1693,12 +1690,17 @@ int mt7915_mcu_add_sta(struct mt7915_dev *dev, struct ieee80211_vif *vif, mt76_connac_mcu_sta_uapsd(skb, vif, sta); } - ret = mt7915_mcu_sta_wtbl_tlv(dev, skb, vif, sta); - if (ret) { - dev_kfree_skb(skb); - return ret; + if (newly || conn_state != CONN_STATE_DISCONNECT) { + ret = mt7915_mcu_sta_wtbl_tlv(dev, skb, vif, sta); + if (ret) { + dev_kfree_skb(skb); + return ret; + } } + if (conn_state == CONN_STATE_DISCONNECT) + goto out; + if (sta) { /* starec amsdu */ mt7915_mcu_sta_amsdu_tlv(dev, skb, vif, sta);