wifi: mt76: mt7996: add support for EHT rate report
authorShayne Chen <shayne.chen@mediatek.com>
Tue, 31 Jan 2023 09:36:09 +0000 (17:36 +0800)
committerFelix Fietkau <nbd@nbd.name>
Fri, 3 Feb 2023 13:47:27 +0000 (14:47 +0100)
Currenly only EHT TX rate report is supported. EHT RX rate is temporally
reported with HE rate.

Co-developed-by: MeiChia Chiu <meichia.chiu@mediatek.com>
Signed-off-by: MeiChia Chiu <meichia.chiu@mediatek.com>
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7996/debugfs.c
drivers/net/wireless/mediatek/mt76/mt7996/mac.c

index 3d4fbbbcc2062e0f88523a47ee63880d03a968f5..9c5e9ac1c3351cca80049170f442b526f05654ed 100644 (file)
@@ -791,10 +791,10 @@ static ssize_t mt7996_sta_fixed_rate_set(struct file *file,
        else
                buf[count] = '\0';
 
-       /* mode - cck: 0, ofdm: 1, ht: 2, gf: 3, vht: 4, he_su: 8, he_er: 9
-        * bw - bw20: 0, bw40: 1, bw80: 2, bw160: 3
-        * nss - vht: 1~4, he: 1~4, others: ignore
-        * mcs - cck: 0~4, ofdm: 0~7, ht: 0~32, vht: 0~9, he_su: 0~11, he_er: 0~2
+       /* mode - cck: 0, ofdm: 1, ht: 2, gf: 3, vht: 4, he_su: 8, he_er: 9 EHT: 15
+        * bw - bw20: 0, bw40: 1, bw80: 2, bw160: 3, BW320: 4
+        * nss - vht: 1~4, he: 1~4, eht: 1~4, others: ignore
+        * mcs - cck: 0~4, ofdm: 0~7, ht: 0~32, vht: 0~9, he_su: 0~11, he_er: 0~2, eht: 0~13
         * gi - (ht/vht) lgi: 0, sgi: 1; (he) 0.8us: 0, 1.6us: 1, 3.2us: 2
         * preamble - short: 1, long: 0
         * ldpc - off: 0, on: 1
index 6f17b2dac6586ab7a1ab856d0278d8bc06a25eb8..c9a9f0e3177162ea31a15d24bf70b5f63233a29e 100644 (file)
@@ -189,6 +189,9 @@ static void mt7996_mac_sta_poll(struct mt7996_dev *dev)
                rate = &msta->wcid.rate;
 
                switch (rate->bw) {
+               case RATE_INFO_BW_320:
+                       bw = IEEE80211_STA_RX_BW_320;
+                       break;
                case RATE_INFO_BW_160:
                        bw = IEEE80211_STA_RX_BW_160;
                        break;
@@ -205,7 +208,11 @@ static void mt7996_mac_sta_poll(struct mt7996_dev *dev)
 
                addr = mt7996_mac_wtbl_lmac_addr(dev, idx, 6);
                val = mt76_rr(dev, addr);
-               if (rate->flags & RATE_INFO_FLAGS_HE_MCS) {
+               if (rate->flags & RATE_INFO_FLAGS_EHT_MCS) {
+                       addr = mt7996_mac_wtbl_lmac_addr(dev, idx, 5);
+                       val = mt76_rr(dev, addr);
+                       rate->eht_gi = FIELD_GET(GENMASK(25, 24), val);
+               } else if (rate->flags & RATE_INFO_FLAGS_HE_MCS) {
                        u8 offs = 24 + 2 * bw;
 
                        rate->he_gi = (val & (0x3 << offs)) >> offs;
@@ -560,6 +567,15 @@ mt7996_mac_fill_rx_rate(struct mt7996_dev *dev,
 
                status->he_dcm = dcm;
                break;
+       case MT_PHY_TYPE_EHT_SU:
+       case MT_PHY_TYPE_EHT_TRIG:
+       case MT_PHY_TYPE_EHT_MU:
+               /* TODO: currently report rx rate with HE rate */
+               status->nss = nss;
+               status->encoding = RX_ENC_HE;
+               bw = min_t(int, bw, IEEE80211_STA_RX_BW_160);
+               i = min_t(int, i & 0xf, 11);
+               break;
        default:
                return -EINVAL;
        }
@@ -584,6 +600,9 @@ mt7996_mac_fill_rx_rate(struct mt7996_dev *dev,
        case IEEE80211_STA_RX_BW_160:
                status->bw = RATE_INFO_BW_160;
                break;
+       case IEEE80211_STA_RX_BW_320:
+               status->bw = RATE_INFO_BW_320;
+               break;
        default:
                return -EINVAL;
        }
@@ -1378,6 +1397,15 @@ mt7996_mac_add_txs_skb(struct mt7996_dev *dev, struct mt76_wcid *wcid, int pid,
                rate.he_dcm = FIELD_GET(MT_TX_RATE_DCM, txrate);
                rate.flags = RATE_INFO_FLAGS_HE_MCS;
                break;
+       case MT_PHY_TYPE_EHT_SU:
+       case MT_PHY_TYPE_EHT_TRIG:
+       case MT_PHY_TYPE_EHT_MU:
+               if (rate.mcs > 13)
+                       goto out;
+
+               rate.eht_gi = wcid->rate.eht_gi;
+               rate.flags = RATE_INFO_FLAGS_EHT_MCS;
+               break;
        default:
                goto out;
        }
@@ -1385,6 +1413,10 @@ mt7996_mac_add_txs_skb(struct mt7996_dev *dev, struct mt76_wcid *wcid, int pid,
        stats->tx_mode[mode]++;
 
        switch (FIELD_GET(MT_TXS0_BW, txs)) {
+       case IEEE80211_STA_RX_BW_320:
+               rate.bw = RATE_INFO_BW_320;
+               stats->tx_bw[4]++;
+               break;
        case IEEE80211_STA_RX_BW_160:
                rate.bw = RATE_INFO_BW_160;
                stats->tx_bw[3]++;