developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 1 | From 74a76d638bf234a888a94a607aadeb0fda232abd Mon Sep 17 00:00:00 2001 |
developer | 45fae41 | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 2 | From: Yi-Chia Hsieh <Yi-Chia.Hsieh@mediatek.com> |
| 3 | Date: Fri, 5 Aug 2022 13:58:11 -0700 |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 4 | Subject: [PATCH 3006/3010] mt76: mt7915: add statistic for H/W Rx Path |
developer | 45fae41 | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 5 | |
| 6 | Change-Id: Id94d663f08e91c83d296bd57e5e9b65a505ae1c7 |
| 7 | --- |
| 8 | mt76.h | 4 ++++ |
| 9 | mt76_connac.h | 5 +++++ |
| 10 | mt76_connac_mcu.h | 35 +++++++++++++++++++++++++++++++++++ |
developer | 4b17052 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 11 | mt7915/mac.c | 25 +++++++++++++++++++++++++ |
developer | 45fae41 | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 12 | mt7915/main.c | 9 ++++++++- |
| 13 | mt7915/mcu.c | 21 +++++++++++++++++++++ |
| 14 | mt7915/mmio.c | 6 ++++++ |
| 15 | mt7915/mt7915.h | 3 +++ |
developer | 4b17052 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 16 | 8 files changed, 107 insertions(+), 1 deletion(-) |
developer | 45fae41 | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 17 | |
| 18 | diff --git a/mt76.h b/mt76.h |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 19 | index 3530d21..47a9213 100644 |
developer | 45fae41 | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 20 | --- a/mt76.h |
| 21 | +++ b/mt76.h |
developer | 4b17052 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 22 | @@ -278,6 +278,10 @@ struct mt76_sta_stats { |
developer | 45fae41 | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 23 | u32 tx_packets; |
| 24 | u32 tx_retries; |
| 25 | u32 tx_failed; |
| 26 | + u64 rx_bytes; |
| 27 | + u32 rx_packets; |
| 28 | + u32 rx_error; |
| 29 | + u32 rx_drop; |
| 30 | }; |
| 31 | |
developer | 4b17052 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 32 | enum mt76_wcid_flags { |
developer | 45fae41 | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 33 | diff --git a/mt76_connac.h b/mt76_connac.h |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 34 | index 9a46887..7ecc725 100644 |
developer | 45fae41 | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 35 | --- a/mt76_connac.h |
| 36 | +++ b/mt76_connac.h |
developer | 28b11e2 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 37 | @@ -224,6 +224,11 @@ static inline bool is_mt76_fw_txp(struct mt76_dev *dev) |
developer | 45fae41 | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 38 | } |
| 39 | } |
| 40 | |
| 41 | +static inline bool is_wo_mcu(struct mt76_dev *dev) |
| 42 | +{ |
| 43 | + return is_mt7986(dev); |
| 44 | +} |
| 45 | + |
| 46 | static inline u8 mt76_connac_chan_bw(struct cfg80211_chan_def *chandef) |
| 47 | { |
| 48 | static const u8 width_to_bw[] = { |
| 49 | diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 50 | index 27a3624..475c391 100644 |
developer | 45fae41 | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 51 | --- a/mt76_connac_mcu.h |
| 52 | +++ b/mt76_connac_mcu.h |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 53 | @@ -1211,6 +1211,41 @@ enum { |
developer | 45fae41 | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 54 | MCU_CE_CMD_GET_TXPWR = 0xd0, |
| 55 | }; |
| 56 | |
| 57 | +enum wo_event_id { |
| 58 | + WO_EVT_LOG_DUMP = 0x1, |
| 59 | + WO_EVT_PROFILING = 0x2, |
| 60 | + WO_EVT_RXCNT_INFO = 0x3 |
| 61 | +}; |
| 62 | + |
| 63 | +enum wo_cmd_id { |
| 64 | + WO_CMD_WED_CFG = 0, |
| 65 | + WO_CMD_WED_RX_STAT, |
| 66 | + WO_CMD_RRO_SER, |
| 67 | + WO_CMD_DBG_INFO, |
| 68 | + WO_CMD_DEV_INFO, |
| 69 | + WO_CMD_BSS_INFO, |
| 70 | + WO_CMD_STA_REC, |
| 71 | + WO_CMD_DEV_INFO_DUMP, |
| 72 | + WO_CMD_BSS_INFO_DUMP, |
| 73 | + WO_CMD_STA_REC_DUMP, |
| 74 | + WO_CMD_BA_INFO_DUMP, |
| 75 | + WO_CMD_FBCMD_Q_DUMP, |
| 76 | + WO_CMD_FW_LOG_CTRL, |
| 77 | + WO_CMD_LOG_FLUSH, |
| 78 | + WO_CMD_CHANGE_STATE, |
| 79 | + WO_CMD_CPU_STATS_ENABLE, |
| 80 | + WO_CMD_CPU_STATS_DUMP, |
| 81 | + WO_CMD_EXCEPTION_INIT, |
| 82 | + WO_CMD_PROF_CTRL, |
| 83 | + WO_CMD_STA_BA_DUMP, |
| 84 | + WO_CMD_BA_CTRL_DUMP, |
| 85 | + WO_CMD_RXCNT_CTRL, |
| 86 | + WO_CMD_RXCNT_INFO, |
| 87 | + WO_CMD_SET_CAP, |
| 88 | + WO_CMD_CCIF_RING_DUMP, |
| 89 | + WO_CMD_WED_END |
| 90 | +}; |
| 91 | + |
| 92 | enum { |
| 93 | PATCH_SEM_RELEASE, |
| 94 | PATCH_SEM_GET |
| 95 | diff --git a/mt7915/mac.c b/mt7915/mac.c |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 96 | index 544d166..bfc6c52 100644 |
developer | 45fae41 | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 97 | --- a/mt7915/mac.c |
| 98 | +++ b/mt7915/mac.c |
developer | 28b11e2 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 99 | @@ -940,6 +940,31 @@ void mt7915_wed_trigger_ser(struct mtk_wed_device *wed) |
developer | 45fae41 | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 100 | return; |
| 101 | } |
| 102 | |
| 103 | +void mt7915_wed_update_wo_rxcnt(struct mtk_wed_device *wed, |
| 104 | + struct wo_cmd_rxcnt_t *rxcnt) |
| 105 | +{ |
| 106 | + struct mt7915_dev *dev; |
| 107 | + struct mt76_wcid *wcid; |
| 108 | + |
| 109 | + dev = container_of(wed, struct mt7915_dev, mt76.mmio.wed); |
| 110 | + if (rxcnt->wlan_idx >= mt7915_wtbl_size(dev)) |
| 111 | + return; |
| 112 | + |
| 113 | + rcu_read_lock(); |
| 114 | + |
| 115 | + wcid = rcu_dereference(dev->mt76.wcid[rxcnt->wlan_idx]); |
| 116 | + if (!wcid) |
| 117 | + goto out; |
| 118 | + |
| 119 | + wcid->stats.rx_bytes += rxcnt->rx_byte_cnt; |
| 120 | + wcid->stats.rx_packets += rxcnt->rx_pkt_cnt; |
| 121 | + wcid->stats.rx_error += rxcnt->rx_err_cnt; |
| 122 | + wcid->stats.rx_drop += rxcnt->rx_drop_cnt; |
| 123 | + |
| 124 | +out: |
| 125 | + rcu_read_unlock(); |
| 126 | +} |
| 127 | + |
| 128 | static void |
| 129 | mt7915_tx_check_aggr(struct ieee80211_sta *sta, __le32 *txwi) |
| 130 | { |
developer | 45fae41 | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 131 | diff --git a/mt7915/main.c b/mt7915/main.c |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 132 | index d5360ce..3e8142e 100644 |
developer | 45fae41 | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 133 | --- a/mt7915/main.c |
| 134 | +++ b/mt7915/main.c |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 135 | @@ -1050,7 +1050,8 @@ static void mt7915_sta_statistics(struct ieee80211_hw *hw, |
developer | 45fae41 | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 136 | struct rate_info *txrate = &msta->wcid.rate; |
| 137 | struct rate_info rxrate = {}; |
| 138 | |
| 139 | - if (is_mt7915(&phy->dev->mt76) && |
| 140 | + if ((is_mt7915(&phy->dev->mt76) || |
| 141 | + mtk_wed_device_active(&phy->dev->mt76.mmio.wed)) && |
| 142 | !mt7915_mcu_get_rx_rate(phy, vif, sta, &rxrate)) { |
| 143 | sinfo->rxrate = rxrate; |
| 144 | sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_BITRATE); |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 145 | @@ -1087,6 +1088,12 @@ static void mt7915_sta_statistics(struct ieee80211_hw *hw, |
developer | 45fae41 | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 146 | |
| 147 | sinfo->tx_retries = msta->wcid.stats.tx_retries; |
| 148 | sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_RETRIES); |
| 149 | + |
| 150 | + sinfo->rx_bytes = msta->wcid.stats.rx_bytes; |
| 151 | + sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_BYTES64); |
| 152 | + |
| 153 | + sinfo->rx_packets = msta->wcid.stats.rx_packets; |
| 154 | + sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_PACKETS); |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | diff --git a/mt7915/mcu.c b/mt7915/mcu.c |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 159 | index a405bfd..48305b4 100644 |
developer | 45fae41 | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 160 | --- a/mt7915/mcu.c |
| 161 | +++ b/mt7915/mcu.c |
| 162 | @@ -293,6 +293,27 @@ int mt7915_mcu_wa_cmd(struct mt7915_dev *dev, int cmd, u32 a1, u32 a2, u32 a3) |
| 163 | return mt76_mcu_send_msg(&dev->mt76, cmd, &req, sizeof(req), false); |
| 164 | } |
| 165 | |
| 166 | +int mt7915_mcu_wo_cmd(struct mt7915_dev *dev, int cmd, u32 a1, u32 a2) |
| 167 | +{ |
| 168 | + struct mtk_wed_device *wed = &dev->mt76.mmio.wed; |
| 169 | + struct { |
| 170 | + __le32 args[2]; |
| 171 | + } req = { |
| 172 | + .args = { |
| 173 | + cpu_to_le32(a1), |
| 174 | + cpu_to_le32(a2), |
| 175 | + }, |
| 176 | + }; |
| 177 | + |
| 178 | + if (!mtk_wed_device_active(wed)) |
| 179 | + return -1; |
| 180 | + |
| 181 | + if (!is_wo_mcu(&dev->mt76)) |
| 182 | + return -1; |
| 183 | + |
| 184 | + return mtk_soc_wed_ops->msg_update(wed, cmd, (void *)&req, sizeof(req)); |
| 185 | +} |
| 186 | + |
| 187 | static void |
| 188 | mt7915_mcu_csa_finish(void *priv, u8 *mac, struct ieee80211_vif *vif) |
| 189 | { |
| 190 | diff --git a/mt7915/mmio.c b/mt7915/mmio.c |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 191 | index 11c7e94..1f794df 100644 |
developer | 45fae41 | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 192 | --- a/mt7915/mmio.c |
| 193 | +++ b/mt7915/mmio.c |
| 194 | @@ -9,6 +9,7 @@ |
| 195 | #include "mt7915.h" |
| 196 | #include "mac.h" |
| 197 | #include "../trace.h" |
| 198 | +#include "../mt76_connac_mcu.h" |
| 199 | |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 200 | static bool wed_enable; |
developer | 45fae41 | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 201 | module_param(wed_enable, bool, 0644); |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 202 | @@ -611,6 +612,8 @@ int mt7915_mmio_wed_init(struct mt7915_dev *dev, void *pdev_ptr, |
developer | 45fae41 | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 203 | |
| 204 | wed->wlan.ser_trigger = mt7915_wed_trigger_ser; |
| 205 | |
| 206 | + wed->wlan.update_wo_rxcnt = mt7915_wed_update_wo_rxcnt; |
| 207 | + |
| 208 | dev->mt76.rx_token_size = wed->wlan.rx_pkt; |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 209 | if (mtk_wed_device_attach(wed)) |
developer | 45fae41 | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 210 | return 0; |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 211 | @@ -622,6 +625,9 @@ int mt7915_mmio_wed_init(struct mt7915_dev *dev, void *pdev_ptr, |
developer | 45fae41 | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 212 | if (ret) |
| 213 | return ret; |
| 214 | |
| 215 | + if (is_wo_mcu(&dev->mt76)) |
| 216 | + mt7915_mcu_wo_cmd(dev, WO_CMD_RXCNT_CTRL, 1, 6); |
| 217 | + |
| 218 | return 1; |
| 219 | #else |
| 220 | return 0; |
| 221 | diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 222 | index 1a32e82..c2a7f35 100644 |
developer | 45fae41 | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 223 | --- a/mt7915/mt7915.h |
| 224 | +++ b/mt7915/mt7915.h |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 225 | @@ -548,6 +548,8 @@ u32 mt7915_wed_init_rx_buf(struct mtk_wed_device *wed, |
developer | 45fae41 | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 226 | int pkt_num); |
| 227 | void mt7915_wed_release_rx_buf(struct mtk_wed_device *wed); |
| 228 | void mt7915_wed_trigger_ser(struct mtk_wed_device *wed); |
| 229 | +void mt7915_wed_update_wo_rxcnt(struct mtk_wed_device *wed, |
| 230 | + struct wo_cmd_rxcnt_t *rxcnt); |
| 231 | int mt7915_register_device(struct mt7915_dev *dev); |
| 232 | void mt7915_unregister_device(struct mt7915_dev *dev); |
| 233 | int mt7915_eeprom_init(struct mt7915_dev *dev); |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 234 | @@ -632,6 +634,7 @@ int mt7915_mcu_rdd_background_enable(struct mt7915_phy *phy, |
developer | 45fae41 | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 235 | struct cfg80211_chan_def *chandef); |
| 236 | int mt7915_mcu_rf_regval(struct mt7915_dev *dev, u32 regidx, u32 *val, bool set); |
| 237 | int mt7915_mcu_wa_cmd(struct mt7915_dev *dev, int cmd, u32 a1, u32 a2, u32 a3); |
| 238 | +int mt7915_mcu_wo_cmd(struct mt7915_dev *dev, int cmd, u32 a1, u32 a2); |
| 239 | int mt7915_mcu_fw_log_2_host(struct mt7915_dev *dev, u8 type, u8 ctrl); |
| 240 | int mt7915_mcu_fw_dbg_ctrl(struct mt7915_dev *dev, u32 module, u8 level); |
| 241 | void mt7915_mcu_rx_event(struct mt7915_dev *dev, struct sk_buff *skb); |
| 242 | -- |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 243 | 2.18.0 |
developer | 45fae41 | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 244 | |