]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: mt76: connac: adjust phy capabilities based on band constraints
authorHoward Hsu <howard-yh.hsu@mediatek.com>
Tue, 14 Jan 2025 10:10:22 +0000 (18:10 +0800)
committerFelix Fietkau <nbd@nbd.name>
Tue, 14 Jan 2025 12:42:30 +0000 (13:42 +0100)
Adjust HE and EHT phy capabilities based on the band constraints.
For 2g band, we shall not enable the capabilities above 40MHz.

Signed-off-by: Howard Hsu <howard-yh.hsu@mediatek.com>
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Link: https://patch.msgid.link/20250114101026.3587702-5-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/mt7915/init.c
drivers/net/wireless/mediatek/mt76/mt7921/main.c
drivers/net/wireless/mediatek/mt76/mt7925/main.c
drivers/net/wireless/mediatek/mt76/mt7996/init.c

index f7766a9815fe075afc2090de732049d9ae9ea02a..455979476d114ad874b1db051c898e00068ce8a0 100644 (file)
@@ -405,7 +405,7 @@ mt76_connac_mutex_release(struct mt76_dev *dev, struct mt76_connac_pm *pm)
        mutex_unlock(&dev->mutex);
 }
 
-void mt76_connac_gen_ppe_thresh(u8 *he_ppet, int nss);
+void mt76_connac_gen_ppe_thresh(u8 *he_ppet, int nss, enum nl80211_band band);
 int mt76_connac_init_tx_queues(struct mt76_phy *phy, int idx, int n_desc,
                               int ring_base, void *wed, u32 flags);
 
index 6d30f4fc352660ae880b18cc85965043df60da7f..e9ac8a7317a11ccec0255b9e31fce52332356553 100644 (file)
@@ -9,10 +9,13 @@
 #define HE_PREP(f, m, v)       le16_encode_bits(le32_get_bits(v, MT_CRXV_HE_##m),\
                                                 IEEE80211_RADIOTAP_HE_##f)
 
-void mt76_connac_gen_ppe_thresh(u8 *he_ppet, int nss)
+void mt76_connac_gen_ppe_thresh(u8 *he_ppet, int nss, enum nl80211_band band)
 {
        static const u8 ppet16_ppet8_ru3_ru0[] = { 0x1c, 0xc7, 0x71 };
-       u8 i, ppet_bits, ppet_size, ru_bit_mask = 0x7; /* HE80 */
+       u8 i, ppet_bits, ppet_size, ru_bit_mask = 0xf;
+
+       if (band == NL80211_BAND_2GHZ)
+               ru_bit_mask = 0x3;
 
        he_ppet[0] = FIELD_PREP(IEEE80211_PPE_THRES_NSS_MASK, nss - 1) |
                     FIELD_PREP(IEEE80211_PPE_THRES_RU_INDEX_BITMASK_MASK,
index c530435b19b59d5558edc849b064f12c4975ebad..bee4beabc4eb75b9d6682d0f29f17093d8ae6392 100644 (file)
@@ -1126,7 +1126,7 @@ mt7915_init_he_caps(struct mt7915_phy *phy, enum nl80211_band band,
                memset(he_cap->ppe_thres, 0, sizeof(he_cap->ppe_thres));
                if (he_cap_elem->phy_cap_info[6] &
                    IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT) {
-                       mt76_connac_gen_ppe_thresh(he_cap->ppe_thres, nss);
+                       mt76_connac_gen_ppe_thresh(he_cap->ppe_thres, nss, band);
                } else {
                        he_cap_elem->phy_cap_info[9] |=
                                u8_encode_bits(IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_16US,
index fccefda3bdb5b7928dda35c8b16674c83de389ca..13e58c328aff4dda2c4bf81741c7c77460ec0926 100644 (file)
@@ -147,7 +147,7 @@ mt7921_init_he_caps(struct mt792x_phy *phy, enum nl80211_band band,
                memset(he_cap->ppe_thres, 0, sizeof(he_cap->ppe_thres));
                if (he_cap_elem->phy_cap_info[6] &
                    IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT) {
-                       mt76_connac_gen_ppe_thresh(he_cap->ppe_thres, nss);
+                       mt76_connac_gen_ppe_thresh(he_cap->ppe_thres, nss, band);
                } else {
                        he_cap_elem->phy_cap_info[9] |=
                                u8_encode_bits(IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_16US,
index 99b4879d9a5d385accb74019ad81b84f5d68f69a..98daf80ac131367b71ab925d3ed5c6064f0f3823 100644 (file)
@@ -130,7 +130,7 @@ mt7925_init_he_caps(struct mt792x_phy *phy, enum nl80211_band band,
 
        if (he_cap_elem->phy_cap_info[6] &
            IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT) {
-               mt76_connac_gen_ppe_thresh(he_cap->ppe_thres, nss);
+               mt76_connac_gen_ppe_thresh(he_cap->ppe_thres, nss, band);
        } else {
                he_cap_elem->phy_cap_info[9] |=
                        u8_encode_bits(IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_16US,
index f4dd3e6b3c2867e8c48609b530073174b26b0ca2..6b660424aedc3162a7848f3748afd61eb968da3d 100644 (file)
@@ -1080,10 +1080,12 @@ void mt7996_set_stream_vht_txbf_caps(struct mt7996_phy *phy)
 
 static void
 mt7996_set_stream_he_txbf_caps(struct mt7996_phy *phy,
-                              struct ieee80211_sta_he_cap *he_cap, int vif)
+                              struct ieee80211_sta_he_cap *he_cap, int vif,
+                              enum nl80211_band band)
 {
        struct ieee80211_he_cap_elem *elem = &he_cap->he_cap_elem;
        int sts = hweight16(phy->mt76->chainmask);
+       bool non_2g = band != NL80211_BAND_2GHZ;
        u8 c;
 
 #ifdef CONFIG_MAC80211_MESH
@@ -1113,10 +1115,10 @@ mt7996_set_stream_he_txbf_caps(struct mt7996_phy *phy,
 
        if (is_mt7996(phy->mt76->dev))
                c |= IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_4 |
-                    IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_4;
+                    (IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_4 * non_2g);
        else
                c |= IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_5 |
-                    IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_5;
+                    (IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_5 * non_2g);
 
        elem->phy_cap_info[4] |= c;
 
@@ -1142,8 +1144,9 @@ mt7996_set_stream_he_txbf_caps(struct mt7996_phy *phy,
 
        c = FIELD_PREP(IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_MASK,
                       sts - 1) |
-           FIELD_PREP(IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_MASK,
-                      sts - 1);
+           (FIELD_PREP(IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_MASK,
+                       sts - 1) * non_2g);
+
        elem->phy_cap_info[5] |= c;
 
        if (vif != NL80211_IFTYPE_AP)
@@ -1155,8 +1158,10 @@ mt7996_set_stream_he_txbf_caps(struct mt7996_phy *phy,
            IEEE80211_HE_PHY_CAP6_TRIG_MU_BEAMFORMING_PARTIAL_BW_FB;
        elem->phy_cap_info[6] |= c;
 
-       c = IEEE80211_HE_PHY_CAP7_STBC_TX_ABOVE_80MHZ |
-           IEEE80211_HE_PHY_CAP7_STBC_RX_ABOVE_80MHZ;
+       c = 0;
+       if (non_2g)
+               c |= IEEE80211_HE_PHY_CAP7_STBC_TX_ABOVE_80MHZ |
+                    IEEE80211_HE_PHY_CAP7_STBC_RX_ABOVE_80MHZ;
        elem->phy_cap_info[7] |= c;
 }
 
@@ -1262,12 +1267,12 @@ mt7996_init_he_caps(struct mt7996_phy *phy, enum nl80211_band band,
        he_mcs->rx_mcs_160 = cpu_to_le16(mcs_map);
        he_mcs->tx_mcs_160 = cpu_to_le16(mcs_map);
 
-       mt7996_set_stream_he_txbf_caps(phy, he_cap, iftype);
+       mt7996_set_stream_he_txbf_caps(phy, he_cap, iftype, band);
 
        memset(he_cap->ppe_thres, 0, sizeof(he_cap->ppe_thres));
        if (he_cap_elem->phy_cap_info[6] &
            IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT) {
-               mt76_connac_gen_ppe_thresh(he_cap->ppe_thres, nss);
+               mt76_connac_gen_ppe_thresh(he_cap->ppe_thres, nss, band);
        } else {
                he_cap_elem->phy_cap_info[9] |=
                        u8_encode_bits(IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_16US,
@@ -1326,13 +1331,20 @@ mt7996_init_eht_caps(struct mt7996_phy *phy, enum nl80211_band band,
 
        eht_cap_elem->phy_cap_info[1] =
                u8_encode_bits(u8_get_bits(val, GENMASK(2, 1)),
-                              IEEE80211_EHT_PHY_CAP1_BEAMFORMEE_SS_80MHZ_MASK) |
-               u8_encode_bits(val,
-                              IEEE80211_EHT_PHY_CAP1_BEAMFORMEE_SS_160MHZ_MASK);
+                              IEEE80211_EHT_PHY_CAP1_BEAMFORMEE_SS_80MHZ_MASK);
 
        eht_cap_elem->phy_cap_info[2] =
-               u8_encode_bits(sts - 1, IEEE80211_EHT_PHY_CAP2_SOUNDING_DIM_80MHZ_MASK) |
-               u8_encode_bits(sts - 1, IEEE80211_EHT_PHY_CAP2_SOUNDING_DIM_160MHZ_MASK);
+               u8_encode_bits(sts - 1, IEEE80211_EHT_PHY_CAP2_SOUNDING_DIM_80MHZ_MASK);
+
+       if (band != NL80211_BAND_2GHZ) {
+               eht_cap_elem->phy_cap_info[1] |=
+                       u8_encode_bits(val,
+                                      IEEE80211_EHT_PHY_CAP1_BEAMFORMEE_SS_160MHZ_MASK);
+
+               eht_cap_elem->phy_cap_info[2] |=
+                       u8_encode_bits(sts - 1,
+                                      IEEE80211_EHT_PHY_CAP2_SOUNDING_DIM_160MHZ_MASK);
+       }
 
        if (band == NL80211_BAND_6GHZ) {
                eht_cap_elem->phy_cap_info[0] |=
@@ -1393,8 +1405,13 @@ mt7996_init_eht_caps(struct mt7996_phy *phy, enum nl80211_band band,
 
        eht_cap_elem->phy_cap_info[7] =
                IEEE80211_EHT_PHY_CAP7_NON_OFDMA_UL_MU_MIMO_80MHZ |
+               IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_80MHZ;
+
+       if (band == NL80211_BAND_2GHZ)
+               return;
+
+       eht_cap_elem->phy_cap_info[7] |=
                IEEE80211_EHT_PHY_CAP7_NON_OFDMA_UL_MU_MIMO_160MHZ |
-               IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_80MHZ |
                IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_160MHZ;
 
        if (band != NL80211_BAND_6GHZ)