]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
mt76: mt7921: fix mgmt frame using unexpected bitrate
authorSean Wang <sean.wang@mediatek.com>
Tue, 13 Jul 2021 20:16:00 +0000 (04:16 +0800)
committerFelix Fietkau <nbd@nbd.name>
Wed, 20 Oct 2021 08:36:28 +0000 (10:36 +0200)
Fix the current driver mgmt frame is not respecting the basic rates field
provided by the AP and then unconditionally is using the lowest (1 or 6
Mbps) rate.

For example, if the AP only supported basic rate {24, 36, 48, 54} Mbps,
mt7921 cannot send mgmt frame with the rate not in the group. So,
instead, we pick up the lowest basic rate the AP can support to send.

Fixes: 163f4d22c118 ("mt76: mt7921: add MAC support")
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7921/mac.c
drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h

index 11c2f88c0d71c07ed2cd82febda6ca4d245a32c1..d64a266279d67f87dadc7a33f854dbba7b5eb7dc 100644 (file)
@@ -811,15 +811,15 @@ void mt7921_mac_write_txwi(struct mt7921_dev *dev, __le32 *txwi,
                mt7921_mac_write_txwi_80211(dev, txwi, skb, key);
 
        if (txwi[2] & cpu_to_le32(MT_TXD2_FIX_RATE)) {
-               u16 rate;
+               u16 rate, mode;
 
                /* hardware won't add HTC for mgmt/ctrl frame */
                txwi[2] |= cpu_to_le32(MT_TXD2_HTC_VLD);
 
-               if (mphy->chandef.chan->band == NL80211_BAND_5GHZ)
-                       rate = MT7921_5G_RATE_DEFAULT;
-               else
-                       rate = MT7921_2G_RATE_DEFAULT;
+               rate = mt76_default_basic_rate(mphy, vif);
+               mode = rate >> 8;
+               rate &= GENMASK(7, 0);
+               rate |= FIELD_PREP(MT_TX_RATE_MODE, mode);
 
                val = MT_TXD6_FIXED_BW |
                      FIELD_PREP(MT_TXD6_TX_RATE, rate);
index ac0b414ccd92283281a842deedf14f7f7266e50e..6e9e4dfb3928fdac7c8f382e4e5f69c45a11dd4a 100644 (file)
@@ -38,8 +38,6 @@
 
 #define MT7921_CFEND_RATE_DEFAULT      0x49    /* OFDM 24M */
 #define MT7921_CFEND_RATE_11B          0x03    /* 11B LP, 11M */
-#define MT7921_5G_RATE_DEFAULT         0x4b    /* OFDM 6M */
-#define MT7921_2G_RATE_DEFAULT         0x0     /* CCK 1M */
 
 #define MT7921_SKU_RATE_NUM            161
 #define MT7921_SKU_MAX_DELTA_IDX       MT7921_SKU_RATE_NUM