developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 1 | From a7a99f2c82b7dfcc147eb45e695b2c04058ec8b4 Mon Sep 17 00:00:00 2001 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 2 | From: Benjamin Lin <benjamin-jw.lin@mediatek.com> |
| 3 | Date: Thu, 4 Jul 2024 14:00:16 +0800 |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 166/193] mtk: mt76: mt7996: add per-STA TX MSDU failed and |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 5 | retried counts |
| 6 | |
| 7 | Record per-STA TX MSDU failed and retried counts for debugging. |
| 8 | |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 9 | Change-Id: I888a86a8d858ff80d16fbb590229cb35ae07ce19 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 10 | Signed-off-by: Benjamin Lin <benjamin-jw.lin@mediatek.com> |
| 11 | --- |
| 12 | mt76.h | 2 ++ |
| 13 | mt76_connac_mcu.h | 3 ++ |
| 14 | mt7996/mac.c | 39 ++++++++++++++++++++++++- |
| 15 | mt7996/mcu.c | 74 +++++++++++------------------------------------ |
| 16 | mt7996/mcu.h | 8 +++++ |
| 17 | mt7996/mt7996.h | 1 - |
| 18 | 6 files changed, 68 insertions(+), 59 deletions(-) |
| 19 | |
| 20 | diff --git a/mt76.h b/mt76.h |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 21 | index c3b71cc..27c990d 100644 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 22 | --- a/mt76.h |
| 23 | +++ b/mt76.h |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 24 | @@ -364,6 +364,8 @@ struct mt76_sta_stats { |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 25 | u64 tx_bytes; |
| 26 | /* WED TX */ |
| 27 | u32 tx_packets; /* unit: MSDU */ |
| 28 | + u32 tx_packets_retried; |
| 29 | + u32 tx_packets_failed; |
| 30 | u32 tx_mpdus; |
| 31 | u32 tx_retries; |
| 32 | u32 tx_failed; |
| 33 | diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 34 | index cc644ed..302567e 100644 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 35 | --- a/mt76_connac_mcu.h |
| 36 | +++ b/mt76_connac_mcu.h |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 37 | @@ -1407,6 +1407,8 @@ enum { |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 38 | UNI_OFFLOAD_OFFLOAD_BMC_RPY_DETECT, |
| 39 | }; |
| 40 | |
| 41 | +#define PER_STA_INFO_MAX_NUM 90 |
| 42 | + |
| 43 | enum UNI_PER_STA_INFO_TAG { |
| 44 | UNI_PER_STA_RSSI, |
| 45 | UNI_PER_STA_CONTENTION_RX_RATE, |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 46 | @@ -1416,6 +1418,7 @@ enum UNI_PER_STA_INFO_TAG { |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 47 | UNI_PER_STA_TX_CNT, |
| 48 | UNI_PER_STA_TID_SN_GET, |
| 49 | UNI_PER_STA_TID_SN_SET, |
| 50 | + UNI_PER_STA_PKT_CNT, |
| 51 | UNI_PER_STA_MAX_NUM |
| 52 | }; |
| 53 | |
| 54 | diff --git a/mt7996/mac.c b/mt7996/mac.c |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 55 | index 1f22575..8c68e08 100644 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 56 | --- a/mt7996/mac.c |
| 57 | +++ b/mt7996/mac.c |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 58 | @@ -2443,6 +2443,43 @@ void mt7996_mac_sta_rc_work(struct work_struct *work) |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 59 | rcu_read_unlock(); |
| 60 | } |
| 61 | |
| 62 | +static int mt7996_mac_sta_poll(struct mt76_dev *dev) |
| 63 | +{ |
| 64 | + u16 sta_list[PER_STA_INFO_MAX_NUM]; |
| 65 | + struct mt7996_link_sta *mlink; |
| 66 | + int i, ret; |
| 67 | + |
| 68 | + spin_lock_bh(&dev->sta_poll_lock); |
| 69 | + for (i = 0; i < PER_STA_INFO_MAX_NUM; ++i) { |
| 70 | + if (list_empty(&dev->sta_poll_list)) |
| 71 | + break; |
| 72 | + |
| 73 | + mlink = list_first_entry(&dev->sta_poll_list, |
| 74 | + struct mt7996_link_sta, |
| 75 | + wcid.poll_list); |
| 76 | + list_del_init(&mlink->wcid.poll_list); |
| 77 | + sta_list[i] = mlink->wcid.idx; |
| 78 | + } |
| 79 | + spin_unlock_bh(&dev->sta_poll_lock); |
| 80 | + |
| 81 | + if (i == 0) |
| 82 | + return 0; |
| 83 | + |
| 84 | + ret = mt7996_mcu_get_per_sta_info(dev, UNI_PER_STA_RSSI, i, sta_list); |
| 85 | + if (ret) |
| 86 | + dev_err(dev->dev, "Failed to update RSSI of polled STAs.\n"); |
| 87 | + |
| 88 | + ret = mt7996_mcu_get_per_sta_info(dev, UNI_PER_STA_SNR, i, sta_list); |
| 89 | + if (ret) |
| 90 | + dev_err(dev->dev, "Failed to update SNR of polled STAs.\n"); |
| 91 | + |
| 92 | + ret = mt7996_mcu_get_per_sta_info(dev, UNI_PER_STA_PKT_CNT, i, sta_list); |
| 93 | + if (ret) |
| 94 | + dev_err(dev->dev, "Failed to update MSDU counts of polled STAs.\n"); |
| 95 | + |
| 96 | + return ret; |
| 97 | +} |
| 98 | + |
| 99 | void mt7996_mac_work(struct work_struct *work) |
| 100 | { |
| 101 | struct mt76_phy *mphy = (struct mt76_phy *)container_of(work, struct mt76_phy, |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 102 | @@ -2465,7 +2502,7 @@ void mt7996_mac_work(struct work_struct *work) |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 103 | if (i == mphy->band_idx) { |
| 104 | mt7996_mcu_get_all_sta_info(mdev, UNI_ALL_STA_TXRX_RATE); |
| 105 | mt7996_mcu_get_all_sta_info(mdev, UNI_ALL_STA_TXRX_AIRTIME); |
| 106 | - mt7996_mcu_get_signal_status(mdev); |
| 107 | + mt7996_mac_sta_poll(mdev); |
| 108 | // if (mtk_wed_device_active(&mdev->mmio.wed)) { |
| 109 | mt7996_mcu_get_all_sta_info(mdev, UNI_ALL_STA_TXRX_ADM_STAT); |
| 110 | mt7996_mcu_get_all_sta_info(mdev, UNI_ALL_STA_TXRX_MSDU_COUNT); |
| 111 | diff --git a/mt7996/mcu.c b/mt7996/mcu.c |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 112 | index e587051..cd2bab3 100644 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 113 | --- a/mt7996/mcu.c |
| 114 | +++ b/mt7996/mcu.c |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 115 | @@ -6027,7 +6027,6 @@ int mt7996_mcu_set_rro(struct mt7996_dev *dev, u16 tag, u16 val) |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 116 | int mt7996_mcu_get_per_sta_info(struct mt76_dev *dev, u16 tag, |
| 117 | u16 sta_num, u16 *sta_list) |
| 118 | { |
| 119 | -#define PER_STA_INFO_MAX_NUM 90 |
| 120 | struct mt7996_mcu_per_sta_info_event *res; |
| 121 | struct mt7996_link_sta *mlink; |
| 122 | struct mt76_wcid *wcid; |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 123 | @@ -6107,6 +6106,23 @@ int mt7996_mcu_get_per_sta_info(struct mt76_dev *dev, u16 tag, |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 124 | } |
| 125 | } |
| 126 | break; |
| 127 | + case UNI_PER_STA_PKT_CNT: |
| 128 | + for (i = 0; i < sta_num; ++i) { |
| 129 | + wlan_idx = le16_to_cpu(res->msdu_cnt[i].wlan_idx); |
| 130 | + wcid = rcu_dereference(dev->wcid[wlan_idx]); |
| 131 | + if (wcid) { |
| 132 | + u32 retries = le32_to_cpu(res->msdu_cnt[i].tx_retries), |
| 133 | + drops = le32_to_cpu(res->msdu_cnt[i].tx_drops); |
| 134 | + |
| 135 | + wcid->stats.tx_packets_retried += retries; |
| 136 | + wcid->stats.tx_packets_failed += retries + drops; |
| 137 | + } else { |
| 138 | + ret = -EINVAL; |
| 139 | + dev_err(dev->dev, "Failed to update MSDU counts for " |
| 140 | + "invalid WCID: %hu\n", wlan_idx); |
| 141 | + } |
| 142 | + } |
| 143 | + break; |
| 144 | default: |
| 145 | ret = -EINVAL; |
| 146 | dev_err(dev->dev, "Unknown UNI_PER_STA_INFO_TAG: %d\n", tag); |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 147 | @@ -6117,62 +6133,6 @@ out: |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 148 | return ret; |
| 149 | } |
| 150 | |
| 151 | -int mt7996_mcu_get_signal_status(struct mt76_dev *dev) |
| 152 | -{ |
| 153 | - u16 sta_list[PER_STA_INFO_MAX_NUM]; |
| 154 | - LIST_HEAD(sta_poll_list); |
| 155 | - struct mt7996_link_sta *mlink; |
| 156 | - int i, ret; |
| 157 | - bool empty = false; |
| 158 | - |
| 159 | - spin_lock_bh(&dev->sta_poll_lock); |
| 160 | - list_splice_init(&dev->sta_poll_list, &sta_poll_list); |
| 161 | - spin_unlock_bh(&dev->sta_poll_lock); |
| 162 | - |
| 163 | - while (!empty) { |
| 164 | - for (i = 0; i < PER_STA_INFO_MAX_NUM; ++i) { |
| 165 | - spin_lock_bh(&dev->sta_poll_lock); |
| 166 | - if (list_empty(&sta_poll_list)) { |
| 167 | - spin_unlock_bh(&dev->sta_poll_lock); |
| 168 | - |
| 169 | - if (i == 0) |
| 170 | - return 0; |
| 171 | - |
| 172 | - empty = true; |
| 173 | - break; |
| 174 | - } |
| 175 | - mlink = list_first_entry(&sta_poll_list, |
| 176 | - struct mt7996_link_sta, |
| 177 | - wcid.poll_list); |
| 178 | - list_del_init(&mlink->wcid.poll_list); |
| 179 | - spin_unlock_bh(&dev->sta_poll_lock); |
| 180 | - |
| 181 | - sta_list[i] = mlink->wcid.idx; |
| 182 | - } |
| 183 | - |
| 184 | - ret = mt7996_mcu_get_per_sta_info(dev, UNI_PER_STA_RSSI, |
| 185 | - i, sta_list); |
| 186 | - if (ret) |
| 187 | - break; |
| 188 | - |
| 189 | - ret = mt7996_mcu_get_per_sta_info(dev, UNI_PER_STA_SNR, |
| 190 | - i, sta_list); |
| 191 | - if (ret) |
| 192 | - break; |
| 193 | - } |
| 194 | - |
| 195 | - if (ret) { |
| 196 | - /* Add STAs, whose signal statuses have not been updated, |
| 197 | - * back to polling list. |
| 198 | - */ |
| 199 | - spin_lock_bh(&dev->sta_poll_lock); |
| 200 | - list_splice(&sta_poll_list, &dev->sta_poll_list); |
| 201 | - spin_unlock_bh(&dev->sta_poll_lock); |
| 202 | - } |
| 203 | - |
| 204 | - return ret; |
| 205 | -} |
| 206 | - |
| 207 | int mt7996_mcu_get_all_sta_info(struct mt76_dev *dev, u16 tag) |
| 208 | { |
| 209 | struct { |
| 210 | diff --git a/mt7996/mcu.h b/mt7996/mcu.h |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 211 | index 01eb0ea..739e357 100644 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 212 | --- a/mt7996/mcu.h |
| 213 | +++ b/mt7996/mcu.h |
| 214 | @@ -211,6 +211,13 @@ struct per_sta_snr { |
| 215 | s8 val[IEEE80211_MAX_CHAINS]; |
| 216 | } __packed; |
| 217 | |
| 218 | +struct per_sta_msdu_cnt { |
| 219 | + __le16 wlan_idx; |
| 220 | + u8 __rsv[2]; |
| 221 | + __le32 tx_drops; |
| 222 | + __le32 tx_retries; |
| 223 | +} __packed; |
| 224 | + |
| 225 | struct mt7996_mcu_per_sta_info_event { |
| 226 | u8 __rsv[4]; |
| 227 | |
| 228 | @@ -220,6 +227,7 @@ struct mt7996_mcu_per_sta_info_event { |
| 229 | union { |
| 230 | struct per_sta_rssi rssi[0]; |
| 231 | struct per_sta_snr snr[0]; |
| 232 | + struct per_sta_msdu_cnt msdu_cnt[0]; |
| 233 | }; |
| 234 | } __packed; |
| 235 | |
| 236 | diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 237 | index 755b4cf..a02e976 100644 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 238 | --- a/mt7996/mt7996.h |
| 239 | +++ b/mt7996/mt7996.h |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 240 | @@ -1138,7 +1138,6 @@ void mt7996_mcu_rx_event(struct mt7996_dev *dev, struct sk_buff *skb); |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 241 | void mt7996_mcu_exit(struct mt7996_dev *dev); |
| 242 | int mt7996_mcu_get_per_sta_info(struct mt76_dev *dev, u16 tag, |
| 243 | u16 sta_num, u16 *sta_list); |
| 244 | -int mt7996_mcu_get_signal_status(struct mt76_dev *dev); |
| 245 | int mt7996_mcu_get_all_sta_info(struct mt76_dev *dev, u16 tag); |
| 246 | int mt7996_mcu_wed_rro_reset_sessions(struct mt7996_dev *dev, u16 id); |
| 247 | int mt7996_mcu_set_tx_power_ctrl(struct mt7996_phy *phy, u8 power_ctrl_id, u8 data); |
| 248 | -- |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 249 | 2.45.2 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 250 | |