]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
wifi: mt76: mt7996: Add MLO support to mt7996_tx_check_aggr()
authorLorenzo Bianconi <lorenzo@kernel.org>
Fri, 4 Jul 2025 13:08:12 +0000 (15:08 +0200)
committerFelix Fietkau <nbd@nbd.name>
Mon, 7 Jul 2025 16:03:30 +0000 (18:03 +0200)
Generalize mt7996_tx_check_aggr() and mt7996_txwi_free() routines to
introduce MLO support for MT7996 driver.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://patch.msgid.link/20250704-mt7996-mlo-fixes-v1-8-356456c73f43@kernel.org
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7996/mac.c

index 0844f27b8458fe53c0765ece70fe91acdfc6510a..02e10d744feb45048401ef15e74c3e03b53b5e08 100644 (file)
@@ -1129,15 +1129,14 @@ u32 mt7996_wed_init_buf(void *ptr, dma_addr_t phys, int token_id)
 }
 
 static void
-mt7996_tx_check_aggr(struct ieee80211_sta *sta, struct sk_buff *skb)
+mt7996_tx_check_aggr(struct ieee80211_link_sta *link_sta,
+                    struct mt76_wcid *wcid, struct sk_buff *skb)
 {
        struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
        bool is_8023 = info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP;
-       struct mt7996_sta_link *msta_link;
-       struct mt7996_sta *msta;
        u16 fc, tid;
 
-       if (!sta || !(sta->deflink.ht_cap.ht_supported || sta->deflink.he_cap.has_he))
+       if (!(link_sta->ht_cap.ht_supported || link_sta->he_cap.has_he))
                return;
 
        tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK;
@@ -1146,7 +1145,8 @@ mt7996_tx_check_aggr(struct ieee80211_sta *sta, struct sk_buff *skb)
 
        if (is_8023) {
                fc = IEEE80211_FTYPE_DATA |
-                    (sta->wme ? IEEE80211_STYPE_QOS_DATA : IEEE80211_STYPE_DATA);
+                    (link_sta->sta->wme ? IEEE80211_STYPE_QOS_DATA
+                                        : IEEE80211_STYPE_DATA);
        } else {
                /* No need to get precise TID for Action/Management Frame,
                 * since it will not meet the following Frame Control
@@ -1162,19 +1162,16 @@ mt7996_tx_check_aggr(struct ieee80211_sta *sta, struct sk_buff *skb)
        if (unlikely(fc != (IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_DATA)))
                return;
 
-       msta = (struct mt7996_sta *)sta->drv_priv;
-       msta_link = &msta->deflink;
-
-       if (!test_and_set_bit(tid, &msta_link->wcid.ampdu_state))
-               ieee80211_start_tx_ba_session(sta, tid, 0);
+       if (!test_and_set_bit(tid, &wcid->ampdu_state))
+               ieee80211_start_tx_ba_session(link_sta->sta, tid, 0);
 }
 
 static void
 mt7996_txwi_free(struct mt7996_dev *dev, struct mt76_txwi_cache *t,
-                struct ieee80211_sta *sta, struct list_head *free_list)
+                struct ieee80211_link_sta *link_sta,
+                struct mt76_wcid *wcid, struct list_head *free_list)
 {
        struct mt76_dev *mdev = &dev->mt76;
-       struct mt76_wcid *wcid;
        __le32 *txwi;
        u16 wcid_idx;
 
@@ -1183,12 +1180,10 @@ mt7996_txwi_free(struct mt7996_dev *dev, struct mt76_txwi_cache *t,
                goto out;
 
        txwi = (__le32 *)mt76_get_txwi_ptr(mdev, t);
-       if (sta) {
-               wcid = (struct mt76_wcid *)sta->drv_priv;
+       if (link_sta) {
                wcid_idx = wcid->idx;
-
                if (likely(t->skb->protocol != cpu_to_be16(ETH_P_PAE)))
-                       mt7996_tx_check_aggr(sta, t->skb);
+                       mt7996_tx_check_aggr(link_sta, wcid, t->skb);
        } else {
                wcid_idx = le32_get_bits(txwi[9], MT_TXD9_WLAN_IDX);
        }
@@ -1207,8 +1202,8 @@ mt7996_mac_tx_free(struct mt7996_dev *dev, void *data, int len)
        struct mt76_dev *mdev = &dev->mt76;
        struct mt76_phy *phy2 = mdev->phys[MT_BAND1];
        struct mt76_phy *phy3 = mdev->phys[MT_BAND2];
+       struct ieee80211_link_sta *link_sta = NULL;
        struct mt76_txwi_cache *txwi;
-       struct ieee80211_sta *sta = NULL;
        struct mt76_wcid *wcid = NULL;
        LIST_HEAD(free_list);
        struct sk_buff *skb, *tmp;
@@ -1245,7 +1240,7 @@ mt7996_mac_tx_free(struct mt7996_dev *dev, void *data, int len)
                 */
                info = le32_to_cpu(*cur_info);
                if (info & MT_TXFREE_INFO_PAIR) {
-                       struct mt7996_sta_link *msta_link;
+                       struct ieee80211_sta *sta;
                        u16 idx;
 
                        idx = FIELD_GET(MT_TXFREE_INFO_WLAN_ID, info);
@@ -1254,9 +1249,11 @@ mt7996_mac_tx_free(struct mt7996_dev *dev, void *data, int len)
                        if (!sta)
                                goto next;
 
-                       msta_link = container_of(wcid, struct mt7996_sta_link,
-                                                wcid);
-                       mt76_wcid_add_poll(&dev->mt76, &msta_link->wcid);
+                       link_sta = rcu_dereference(sta->link[wcid->link_id]);
+                       if (!link_sta)
+                               goto next;
+
+                       mt76_wcid_add_poll(&dev->mt76, wcid);
 next:
                        /* ver 7 has a new DW with pair = 1, skip it */
                        if (ver == 7 && ((void *)(cur_info + 1) < end) &&
@@ -1289,7 +1286,8 @@ next:
                        if (!txwi)
                                continue;
 
-                       mt7996_txwi_free(dev, txwi, sta, &free_list);
+                       mt7996_txwi_free(dev, txwi, link_sta, wcid,
+                                        &free_list);
                }
        }
 
@@ -1748,7 +1746,7 @@ void mt7996_tx_token_put(struct mt7996_dev *dev)
 
        spin_lock_bh(&dev->mt76.token_lock);
        idr_for_each_entry(&dev->mt76.token, txwi, id) {
-               mt7996_txwi_free(dev, txwi, NULL, NULL);
+               mt7996_txwi_free(dev, txwi, NULL, NULL, NULL);
                dev->mt76.token_count--;
        }
        spin_unlock_bh(&dev->mt76.token_lock);