developer | c2cfe0f | 2023-09-22 04:11:09 +0800 | [diff] [blame^] | 1 | From 8d63150a261b6c9f3f19004e8f09dd0bdddffe24 Mon Sep 17 00:00:00 2001 |
| 2 | From: Benjamin Lin <benjamin-jw.lin@mediatek.com> |
| 3 | Date: Fri, 14 Jul 2023 09:43:53 +0800 |
| 4 | Subject: [PATCH 19/22] wifi: mt76: mt7996: fix incorrect report of TX GI |
| 5 | |
| 6 | --- |
| 7 | mt76_connac_mcu.h | 2 +- |
| 8 | mt7996/mac.c | 48 +++-------------------------------------------- |
| 9 | mt7996/main.c | 1 + |
| 10 | mt7996/mcu.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++ |
| 11 | mt7996/mcu.h | 22 ++++++++++++++++++++++ |
| 12 | 5 files changed, 74 insertions(+), 46 deletions(-) |
| 13 | |
| 14 | diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h |
| 15 | index e9dd9aa64..8562ca42a 100644 |
| 16 | --- a/mt76_connac_mcu.h |
| 17 | +++ b/mt76_connac_mcu.h |
| 18 | @@ -1327,7 +1327,7 @@ enum { |
| 19 | }; |
| 20 | |
| 21 | enum UNI_ALL_STA_INFO_TAG { |
| 22 | - UNI_ALL_STA_TX_RATE, |
| 23 | + UNI_ALL_STA_TXRX_RATE, |
| 24 | UNI_ALL_STA_TX_STAT, |
| 25 | UNI_ALL_STA_TXRX_ADM_STAT, |
| 26 | UNI_ALL_STA_TXRX_AIR_TIME, |
| 27 | diff --git a/mt7996/mac.c b/mt7996/mac.c |
| 28 | index d4d3cf5b7..e999cce39 100644 |
| 29 | --- a/mt7996/mac.c |
| 30 | +++ b/mt7996/mac.c |
| 31 | @@ -102,7 +102,6 @@ static void mt7996_mac_sta_poll(struct mt7996_dev *dev) |
| 32 | }; |
| 33 | struct ieee80211_sta *sta; |
| 34 | struct mt7996_sta *msta; |
| 35 | - struct rate_info *rate; |
| 36 | u32 tx_time[IEEE80211_NUM_ACS], rx_time[IEEE80211_NUM_ACS]; |
| 37 | LIST_HEAD(sta_poll_list); |
| 38 | int i; |
| 39 | @@ -118,7 +117,6 @@ static void mt7996_mac_sta_poll(struct mt7996_dev *dev) |
| 40 | u32 addr, val; |
| 41 | u16 idx; |
| 42 | s8 rssi[4]; |
| 43 | - u8 bw; |
| 44 | |
| 45 | spin_lock_bh(&dev->mt76.sta_poll_lock); |
| 46 | if (list_empty(&sta_poll_list)) { |
| 47 | @@ -174,49 +172,6 @@ static void mt7996_mac_sta_poll(struct mt7996_dev *dev) |
| 48 | ieee80211_sta_register_airtime(sta, tid, tx_cur, rx_cur); |
| 49 | } |
| 50 | |
| 51 | - /* We don't support reading GI info from txs packets. |
| 52 | - * For accurate tx status reporting and AQL improvement, |
| 53 | - * we need to make sure that flags match so polling GI |
| 54 | - * from per-sta counters directly. |
| 55 | - */ |
| 56 | - rate = &msta->wcid.rate; |
| 57 | - |
| 58 | - switch (rate->bw) { |
| 59 | - case RATE_INFO_BW_320: |
| 60 | - bw = IEEE80211_STA_RX_BW_320; |
| 61 | - break; |
| 62 | - case RATE_INFO_BW_160: |
| 63 | - bw = IEEE80211_STA_RX_BW_160; |
| 64 | - break; |
| 65 | - case RATE_INFO_BW_80: |
| 66 | - bw = IEEE80211_STA_RX_BW_80; |
| 67 | - break; |
| 68 | - case RATE_INFO_BW_40: |
| 69 | - bw = IEEE80211_STA_RX_BW_40; |
| 70 | - break; |
| 71 | - default: |
| 72 | - bw = IEEE80211_STA_RX_BW_20; |
| 73 | - break; |
| 74 | - } |
| 75 | - |
| 76 | - addr = mt7996_mac_wtbl_lmac_addr(dev, idx, 6); |
| 77 | - val = mt76_rr(dev, addr); |
| 78 | - if (rate->flags & RATE_INFO_FLAGS_EHT_MCS) { |
| 79 | - addr = mt7996_mac_wtbl_lmac_addr(dev, idx, 5); |
| 80 | - val = mt76_rr(dev, addr); |
| 81 | - rate->eht_gi = FIELD_GET(GENMASK(25, 24), val); |
| 82 | - } else if (rate->flags & RATE_INFO_FLAGS_HE_MCS) { |
| 83 | - u8 offs = 24 + 2 * bw; |
| 84 | - |
| 85 | - rate->he_gi = (val & (0x3 << offs)) >> offs; |
| 86 | - } else if (rate->flags & |
| 87 | - (RATE_INFO_FLAGS_VHT_MCS | RATE_INFO_FLAGS_MCS)) { |
| 88 | - if (val & BIT(12 + bw)) |
| 89 | - rate->flags |= RATE_INFO_FLAGS_SHORT_GI; |
| 90 | - else |
| 91 | - rate->flags &= ~RATE_INFO_FLAGS_SHORT_GI; |
| 92 | - } |
| 93 | - |
| 94 | /* get signal strength of resp frames (CTS/BA/ACK) */ |
| 95 | addr = mt7996_mac_wtbl_lmac_addr(dev, idx, 34); |
| 96 | val = mt76_rr(dev, addr); |
| 97 | @@ -1249,6 +1204,8 @@ mt7996_mac_add_txs_skb(struct mt7996_dev *dev, struct mt76_wcid *wcid, |
| 98 | goto out; |
| 99 | |
| 100 | rate.flags = RATE_INFO_FLAGS_VHT_MCS; |
| 101 | + if (wcid->rate.flags & RATE_INFO_FLAGS_SHORT_GI) |
| 102 | + rate.flags |= RATE_INFO_FLAGS_SHORT_GI; |
| 103 | break; |
| 104 | case MT_PHY_TYPE_HE_SU: |
| 105 | case MT_PHY_TYPE_HE_EXT_SU: |
| 106 | @@ -2222,6 +2179,7 @@ void mt7996_mac_work(struct work_struct *work) |
| 107 | |
| 108 | mt7996_mac_update_stats(phy); |
| 109 | |
| 110 | + mt7996_mcu_get_all_sta_info(phy, UNI_ALL_STA_TXRX_RATE); |
| 111 | mt7996_mcu_get_all_sta_info(phy, UNI_ALL_STA_TXRX_ADM_STAT); |
| 112 | mt7996_mcu_get_all_sta_info(phy, UNI_ALL_STA_TXRX_MSDU_COUNT); |
| 113 | } |
| 114 | diff --git a/mt7996/main.c b/mt7996/main.c |
| 115 | index 284fb373b..fa4a37f20 100644 |
| 116 | --- a/mt7996/main.c |
| 117 | +++ b/mt7996/main.c |
| 118 | @@ -990,6 +990,7 @@ static void mt7996_sta_statistics(struct ieee80211_hw *hw, |
| 119 | sinfo->txrate.he_gi = txrate->he_gi; |
| 120 | sinfo->txrate.he_dcm = txrate->he_dcm; |
| 121 | sinfo->txrate.he_ru_alloc = txrate->he_ru_alloc; |
| 122 | + sinfo->txrate.eht_gi = txrate->eht_gi; |
| 123 | } |
| 124 | sinfo->txrate.flags = txrate->flags; |
| 125 | sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BITRATE); |
| 126 | diff --git a/mt7996/mcu.c b/mt7996/mcu.c |
| 127 | index 146e284fc..dd28ae2de 100644 |
| 128 | --- a/mt7996/mcu.c |
| 129 | +++ b/mt7996/mcu.c |
| 130 | @@ -477,6 +477,43 @@ mt7996_mcu_rx_thermal_notify(struct mt7996_dev *dev, struct sk_buff *skb) |
| 131 | phy->throttle_state = n->duty_percent; |
| 132 | } |
| 133 | |
| 134 | +static int |
| 135 | +mt7996_mcu_update_tx_gi(struct rate_info *rate, struct all_sta_trx_rate *mcu_rate) |
| 136 | +{ |
| 137 | + switch (mcu_rate->tx_mode) { |
| 138 | + case MT_PHY_TYPE_CCK: |
| 139 | + case MT_PHY_TYPE_OFDM: |
| 140 | + break; |
| 141 | + case MT_PHY_TYPE_HT: |
| 142 | + case MT_PHY_TYPE_HT_GF: |
| 143 | + case MT_PHY_TYPE_VHT: |
| 144 | + if (mcu_rate->tx_gi) |
| 145 | + rate->flags |= RATE_INFO_FLAGS_SHORT_GI; |
| 146 | + else |
| 147 | + rate->flags &= ~RATE_INFO_FLAGS_SHORT_GI; |
| 148 | + break; |
| 149 | + case MT_PHY_TYPE_HE_SU: |
| 150 | + case MT_PHY_TYPE_HE_EXT_SU: |
| 151 | + case MT_PHY_TYPE_HE_TB: |
| 152 | + case MT_PHY_TYPE_HE_MU: |
| 153 | + if (mcu_rate->tx_gi > NL80211_RATE_INFO_HE_GI_3_2) |
| 154 | + return -EINVAL; |
| 155 | + rate->he_gi = mcu_rate->tx_gi; |
| 156 | + break; |
| 157 | + case MT_PHY_TYPE_EHT_SU: |
| 158 | + case MT_PHY_TYPE_EHT_TRIG: |
| 159 | + case MT_PHY_TYPE_EHT_MU: |
| 160 | + if (mcu_rate->tx_gi > NL80211_RATE_INFO_EHT_GI_3_2) |
| 161 | + return -EINVAL; |
| 162 | + rate->eht_gi = mcu_rate->tx_gi; |
| 163 | + break; |
| 164 | + default: |
| 165 | + return -EINVAL; |
| 166 | + } |
| 167 | + |
| 168 | + return 0; |
| 169 | +} |
| 170 | + |
| 171 | static void |
| 172 | mt7996_mcu_rx_all_sta_info_event(struct mt7996_dev *dev, struct sk_buff *skb) |
| 173 | { |
| 174 | @@ -493,6 +530,16 @@ mt7996_mcu_rx_all_sta_info_event(struct mt7996_dev *dev, struct sk_buff *skb) |
| 175 | struct mt76_wcid *wcid; |
| 176 | |
| 177 | switch (le16_to_cpu(res->tag)) { |
| 178 | + case UNI_ALL_STA_TXRX_RATE: |
| 179 | + wlan_idx = le16_to_cpu(res->rate[i].wlan_idx); |
| 180 | + wcid = rcu_dereference(dev->mt76.wcid[wlan_idx]); |
| 181 | + |
| 182 | + if (!wcid) |
| 183 | + break; |
| 184 | + |
| 185 | + if (mt7996_mcu_update_tx_gi(&wcid->rate, &res->rate[i])) |
| 186 | + dev_err(dev->mt76.dev, "Failed to update TX GI\n"); |
| 187 | + break; |
| 188 | case UNI_ALL_STA_TXRX_ADM_STAT: |
| 189 | wlan_idx = le16_to_cpu(res->adm_stat[i].wlan_idx); |
| 190 | wcid = rcu_dereference(dev->mt76.wcid[wlan_idx]); |
| 191 | diff --git a/mt7996/mcu.h b/mt7996/mcu.h |
| 192 | index 66af7a90f..ccc260c83 100644 |
| 193 | --- a/mt7996/mcu.h |
| 194 | +++ b/mt7996/mcu.h |
| 195 | @@ -191,6 +191,27 @@ struct mt7996_mcu_thermal_notify { |
| 196 | u8 __rsv2[4]; |
| 197 | } __packed; |
| 198 | |
| 199 | +struct all_sta_trx_rate { |
| 200 | + __le16 wlan_idx; |
| 201 | + u8 __rsv1[2]; |
| 202 | + u8 tx_mode; |
| 203 | + u8 flags; |
| 204 | + u8 tx_stbc; |
| 205 | + u8 tx_gi; |
| 206 | + u8 tx_bw; |
| 207 | + u8 tx_ldpc; |
| 208 | + u8 tx_mcs; |
| 209 | + u8 tx_nss; |
| 210 | + u8 rx_rate; |
| 211 | + u8 rx_mode; |
| 212 | + u8 rx_nsts; |
| 213 | + u8 rx_gi; |
| 214 | + u8 rx_coding; |
| 215 | + u8 rx_stbc; |
| 216 | + u8 rx_bw; |
| 217 | + u8 __rsv2; |
| 218 | +} __packed; |
| 219 | + |
| 220 | struct all_sta_trx_adm_stat { |
| 221 | __le16 wlan_idx; |
| 222 | u8 __rsv[2]; |
| 223 | @@ -215,6 +236,7 @@ struct mt7996_mcu_all_sta_info_event { |
| 224 | u8 __rsv3[2]; |
| 225 | |
| 226 | union { |
| 227 | + struct all_sta_trx_rate rate[0]; |
| 228 | struct all_sta_trx_adm_stat adm_stat[0]; |
| 229 | struct all_sta_trx_msdu_cnt msdu_cnt[0]; |
| 230 | }; |
| 231 | -- |
| 232 | 2.39.2 |
| 233 | |