]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: mt76: mt7925: add link handling in mt7925_txwi_free
authorSean Wang <sean.wang@mediatek.com>
Sat, 6 Jul 2024 08:27:56 +0000 (01:27 -0700)
committerFelix Fietkau <nbd@nbd.name>
Tue, 9 Jul 2024 21:02:04 +0000 (23:02 +0200)
add link handling in mt7925_txwi_free.

MT7996 should have the similar the logic, we try to copy from there to
ensure consistency between both.

Co-developed-by: Ming Yen Hsieh <mingyen.hsieh@mediatek.com>
Signed-off-by: Ming Yen Hsieh <mingyen.hsieh@mediatek.com>
Co-developed-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Link: https://patch.msgid.link/f8084e19d388c6b0807618ac6d1bb8ac633dc8cd.1720248331.git.sean.wang@kernel.org
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7925/mac.c
drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h
drivers/net/wireless/mediatek/mt76/mt7925/pci_mac.c

index 6f5f2130420e4dd2701f315938bad66485e45109..0cb9031e9fdd25e8280d477e9a6d2797e323e44c 100644 (file)
@@ -839,27 +839,53 @@ mt7925_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi,
 }
 EXPORT_SYMBOL_GPL(mt7925_mac_write_txwi);
 
-static void mt7925_tx_check_aggr(struct ieee80211_sta *sta, __le32 *txwi)
+static void mt7925_tx_check_aggr(struct ieee80211_sta *sta, struct sk_buff *skb,
+                                struct mt76_wcid *wcid)
 {
+       struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
+       struct ieee80211_link_sta *link_sta;
+       struct mt792x_link_sta *mlink;
        struct mt792x_sta *msta;
+       bool is_8023;
        u16 fc, tid;
-       u32 val;
 
-       if (!sta || !(sta->deflink.ht_cap.ht_supported || sta->deflink.he_cap.has_he))
+       link_sta = rcu_dereference(sta->link[wcid->link_id]);
+       if (!link_sta)
                return;
 
-       tid = le32_get_bits(txwi[1], MT_TXD1_TID);
-       if (tid >= 6) /* skip VO queue */
+       if (!sta || !(link_sta->ht_cap.ht_supported || link_sta->he_cap.has_he))
                return;
 
-       val = le32_to_cpu(txwi[2]);
-       fc = FIELD_GET(MT_TXD2_FRAME_TYPE, val) << 2 |
-            FIELD_GET(MT_TXD2_SUB_TYPE, val) << 4;
+       tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK;
+       is_8023 = info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP;
+
+       if (is_8023) {
+               fc = IEEE80211_FTYPE_DATA |
+                    (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
+                * condition anyway.
+                */
+
+               struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
+
+               fc = le16_to_cpu(hdr->frame_control) &
+                    (IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE);
+       }
+
        if (unlikely(fc != (IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_DATA)))
                return;
 
        msta = (struct mt792x_sta *)sta->drv_priv;
-       if (!test_and_set_bit(tid, &msta->deflink.wcid.ampdu_state))
+
+       if (sta->mlo && msta->deflink_id != IEEE80211_LINK_UNSPECIFIED)
+               mlink = rcu_dereference(msta->link[msta->deflink_id]);
+       else
+               mlink = &msta->deflink;
+
+       if (!test_and_set_bit(tid, &mlink->wcid.ampdu_state))
                ieee80211_start_tx_ba_session(sta, tid, 0);
 }
 
@@ -1039,7 +1065,7 @@ out:
 }
 
 void mt7925_txwi_free(struct mt792x_dev *dev, struct mt76_txwi_cache *t,
-                     struct ieee80211_sta *sta, bool clear_status,
+                     struct ieee80211_sta *sta, struct mt76_wcid *wcid,
                      struct list_head *free_list)
 {
        struct mt76_dev *mdev = &dev->mt76;
@@ -1052,10 +1078,8 @@ void mt7925_txwi_free(struct mt792x_dev *dev, struct mt76_txwi_cache *t,
 
        txwi = (__le32 *)mt76_get_txwi_ptr(mdev, t);
        if (sta) {
-               struct mt76_wcid *wcid = (struct mt76_wcid *)sta->drv_priv;
-
                if (likely(t->skb->protocol != cpu_to_be16(ETH_P_PAE)))
-                       mt7925_tx_check_aggr(sta, txwi);
+                       mt7925_tx_check_aggr(sta, t->skb, wcid);
 
                wcid_idx = wcid->idx;
        } else {
@@ -1140,7 +1164,7 @@ mt7925_mac_tx_free(struct mt792x_dev *dev, void *data, int len)
                        if (!txwi)
                                continue;
 
-                       mt7925_txwi_free(dev, txwi, sta, 0, &free_list);
+                       mt7925_txwi_free(dev, txwi, sta, wcid, &free_list);
                }
        }
 
@@ -1426,7 +1450,7 @@ void mt7925_usb_sdio_tx_complete_skb(struct mt76_dev *mdev,
        sta = wcid_to_sta(wcid);
 
        if (sta && likely(e->skb->protocol != cpu_to_be16(ETH_P_PAE)))
-               mt7925_tx_check_aggr(sta, txwi);
+               mt76_connac2_tx_check_aggr(sta, txwi);
 
        skb_pull(e->skb, headroom);
        mt76_tx_complete_skb(mdev, e->wcid, e->skb);
index dbc9e3d426e931c1b0da4c7a830ad0e5d76a9ab0..bcf8541fa31dee5c15601e3bcb13350fff9195f6 100644 (file)
@@ -260,7 +260,7 @@ void mt7925_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi,
                           struct ieee80211_key_conf *key, int pid,
                           enum mt76_txq_id qid, u32 changed);
 void mt7925_txwi_free(struct mt792x_dev *dev, struct mt76_txwi_cache *t,
-                     struct ieee80211_sta *sta, bool clear_status,
+                     struct ieee80211_sta *sta, struct mt76_wcid *wcid,
                      struct list_head *free_list);
 int mt7925_mcu_parse_response(struct mt76_dev *mdev, int cmd,
                              struct sk_buff *skb, int seq);
index ef631a68005dba1b7c341efdfbef467d31b6b1d9..faedbf766d1a01df5d34f4af45f10f6359a0a777 100644 (file)
@@ -60,7 +60,7 @@ void mt7925_tx_token_put(struct mt792x_dev *dev)
 
        spin_lock_bh(&dev->mt76.token_lock);
        idr_for_each_entry(&dev->mt76.token, txwi, id) {
-               mt7925_txwi_free(dev, txwi, NULL, false, NULL);
+               mt7925_txwi_free(dev, txwi, NULL, NULL, NULL);
                dev->mt76.token_count--;
        }
        spin_unlock_bh(&dev->mt76.token_lock);