]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
wifi: mt76: connac: introduce mt76_connac_spe_idx()
authorShayne Chen <shayne.chen@mediatek.com>
Fri, 30 Sep 2022 15:13:13 +0000 (23:13 +0800)
committerFelix Fietkau <nbd@nbd.name>
Thu, 1 Dec 2022 16:29:12 +0000 (17:29 +0100)
Add mt76_connac_spe_idx() for antenna mask to spatial extension
index conversion. This is used to support flexible control of
tx antenna.

Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt76_connac.h
drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h

index 635192c878cb4b9422d42af13145a21f16ce65b7..0915eb579539a0a9f52caaa7d225ce3062fa69c4 100644 (file)
@@ -261,6 +261,17 @@ mt76_connac_txwi_to_txp(struct mt76_dev *dev, struct mt76_txwi_cache *t)
        return (void *)(txwi + MT_TXD_SIZE);
 }
 
+static inline u8 mt76_connac_spe_idx(u8 antenna_mask)
+{
+       static const u8 ant_to_spe[] = {0, 0, 1, 0, 3, 2, 4, 0,
+                                       9, 8, 6, 10, 16, 12, 18, 0};
+
+       if (antenna_mask >= sizeof(ant_to_spe))
+               return 0;
+
+       return ant_to_spe[antenna_mask];
+}
+
 int mt76_connac_pm_wake(struct mt76_phy *phy, struct mt76_connac_pm *pm);
 void mt76_connac_power_save_sched(struct mt76_phy *phy,
                                  struct mt76_connac_pm *pm);
index 34ac3d81a510256f055cff164393afe32b808c3a..8b7ec64abc95e809ad092c2799dfa86b08f179d7 100644 (file)
@@ -417,9 +417,6 @@ mt76_connac2_mac_write_txwi_80211(struct mt76_dev *dev, __le32 *txwi,
        if (ieee80211_is_beacon(fc)) {
                txwi[3] &= ~cpu_to_le32(MT_TXD3_SW_POWER_MGMT);
                txwi[3] |= cpu_to_le32(MT_TXD3_REM_TX_COUNT);
-               if (!is_mt7921(dev))
-                       txwi[7] |= cpu_to_le32(FIELD_PREP(MT_TXD7_SPE_IDX,
-                                                         0x18));
        }
 
        if (info->flags & IEEE80211_TX_CTL_INJECTED) {
@@ -550,6 +547,14 @@ void mt76_connac2_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi,
                val |= FIELD_PREP(MT_TXD6_TX_RATE, rate);
                txwi[6] |= cpu_to_le32(val);
                txwi[3] |= cpu_to_le32(MT_TXD3_BA_DISABLE);
+
+               if (!is_mt7921(dev)) {
+                       u8 spe_idx = mt76_connac_spe_idx(mphy->antenna_mask);
+
+                       if (!spe_idx)
+                               spe_idx = 24 + phy_idx;
+                       txwi[7] |= cpu_to_le32(FIELD_PREP(MT_TXD7_SPE_IDX, spe_idx));
+               }
        }
 }
 EXPORT_SYMBOL_GPL(mt76_connac2_mac_write_txwi);
index 718f427d8f6b260702bbffc86cba46aaaae8f059..cf4ce3b1fc2134bbcd61b0b849ecfa5d33966e80 100644 (file)
@@ -580,7 +580,7 @@ struct sta_rec_ra_fixed {
 
        struct sta_phy phy;
 
-       u8 spe_en;
+       u8 spe_idx;
        u8 short_preamble;
        u8 is_5g;
        u8 mmps_mode;