wifi: mt76: mt7925: add link handling to txwi
authorSean Wang <sean.wang@mediatek.com>
Sat, 6 Jul 2024 08:27:51 +0000 (01:27 -0700)
committerFelix Fietkau <nbd@nbd.name>
Tue, 9 Jul 2024 21:02:03 +0000 (23:02 +0200)
add link handling to mt792x_tx and writing txwi.

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/c0a7c0b33ea2640bcb4f13a5f79a8976b73fa8f2.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/mt792x_core.c

index 2be2ab914411f52b9aaeb3f10c75ce1aff312a35..6f5f2130420e4dd2701f315938bad66485e45109 100644 (file)
@@ -740,8 +740,12 @@ mt7925_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi,
                                    BSS_CHANGED_BEACON_ENABLED));
        bool inband_disc = !!(changed & (BSS_CHANGED_UNSOL_BCAST_PROBE_RESP |
                                         BSS_CHANGED_FILS_DISCOVERY));
+       struct mt792x_bss_conf *mconf;
+
+       mconf = vif ? mt792x_vif_to_link((struct mt792x_vif *)vif->drv_priv,
+                                        wcid->link_id) : NULL;
+       mvif = mconf ? (struct mt76_vif *)&mconf->mt76 : NULL;
 
-       mvif = vif ? (struct mt76_vif *)vif->drv_priv : NULL;
        if (mvif) {
                omac_idx = mvif->omac_idx;
                wmm_idx = mvif->wmm_idx;
@@ -802,8 +806,10 @@ mt7925_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi,
 
        txwi[5] = cpu_to_le32(val);
 
-       val = MT_TXD6_DIS_MAT | MT_TXD6_DAS |
-             FIELD_PREP(MT_TXD6_MSDU_CNT, 1);
+       val = MT_TXD6_DAS | FIELD_PREP(MT_TXD6_MSDU_CNT, 1);
+       if (!ieee80211_vif_is_mld(vif) ||
+           (q_idx >= MT_LMAC_ALTX0 && q_idx <= MT_LMAC_BCN0))
+               val |= MT_TXD6_DIS_MAT;
        txwi[6] = cpu_to_le32(val);
        txwi[7] = 0;
 
index 62f471b5498f71e03cd75ca02104c03f223f4312..ae2ac146a7f7a777698c10cea0025badb2c9571d 100644 (file)
@@ -59,13 +59,17 @@ void mt792x_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control,
        struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
        struct ieee80211_vif *vif = info->control.vif;
        struct mt76_wcid *wcid = &dev->mt76.global_wcid;
+       u8 link_id;
        int qid;
 
        if (control->sta) {
+               struct mt792x_link_sta *mlink;
                struct mt792x_sta *sta;
-
+               link_id = u32_get_bits(info->control.flags,
+                                      IEEE80211_TX_CTRL_MLO_LINK);
                sta = (struct mt792x_sta *)control->sta->drv_priv;
-               wcid = &sta->deflink.wcid;
+               mlink = mt792x_sta_to_link(sta, link_id);
+               wcid = &mlink->wcid;
        }
 
        if (vif && !control->sta) {
@@ -75,6 +79,24 @@ void mt792x_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control,
                wcid = &mvif->sta.deflink.wcid;
        }
 
+       if (vif && control->sta && ieee80211_vif_is_mld(vif)) {
+               struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
+               struct ieee80211_link_sta *link_sta;
+               struct ieee80211_bss_conf *conf;
+
+               link_id = wcid->link_id;
+               rcu_read_lock();
+               conf = rcu_dereference(vif->link_conf[link_id]);
+               memcpy(hdr->addr2, conf->addr, ETH_ALEN);
+
+               link_sta = rcu_dereference(control->sta->link[link_id]);
+               memcpy(hdr->addr1, link_sta->addr, ETH_ALEN);
+
+               if (vif->type == NL80211_IFTYPE_STATION)
+                       memcpy(hdr->addr3, conf->bssid, ETH_ALEN);
+               rcu_read_unlock();
+       }
+
        if (mt76_connac_pm_ref(mphy, &dev->pm)) {
                mt76_tx(mphy, control->sta, wcid, skb);
                mt76_connac_pm_unref(mphy, &dev->pm);