developer | b81e95d | 2022-11-08 10:16:29 +0800 | [diff] [blame^] | 1 | From 301353df129dc70115481141357c590b4362a5c8 Mon Sep 17 00:00:00 2001 |
developer | 8ec491f | 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 | b81e95d | 2022-11-08 10:16:29 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 3006/3010] mt76: mt7915: add statistic for H/W Rx Path |
developer | 8ec491f | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 5 | |
| 6 | Change-Id: Id94d663f08e91c83d296bd57e5e9b65a505ae1c7 |
developer | b81e95d | 2022-11-08 10:16:29 +0800 | [diff] [blame^] | 7 | Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
developer | 8ec491f | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 8 | --- |
developer | c859294 | 2022-10-31 14:07:50 +0800 | [diff] [blame] | 9 | mt76.h | 4 ++++ |
| 10 | mt7915/mac.c | 25 +++++++++++++++++++++++++ |
| 11 | mt7915/main.c | 9 ++++++++- |
| 12 | mt7915/mmio.c | 17 +++++++++++++++++ |
| 13 | mt7915/mt7915.h | 2 ++ |
| 14 | 5 files changed, 56 insertions(+), 1 deletion(-) |
developer | 8ec491f | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 15 | |
| 16 | diff --git a/mt76.h b/mt76.h |
developer | b81e95d | 2022-11-08 10:16:29 +0800 | [diff] [blame^] | 17 | index 13bdc08..14c58bc 100644 |
developer | 8ec491f | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 18 | --- a/mt76.h |
| 19 | +++ b/mt76.h |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 20 | @@ -278,6 +278,10 @@ struct mt76_sta_stats { |
developer | 8ec491f | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 21 | u32 tx_packets; |
| 22 | u32 tx_retries; |
| 23 | u32 tx_failed; |
| 24 | + u64 rx_bytes; |
| 25 | + u32 rx_packets; |
| 26 | + u32 rx_error; |
| 27 | + u32 rx_drop; |
| 28 | }; |
| 29 | |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 30 | enum mt76_wcid_flags { |
developer | 8ec491f | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 31 | diff --git a/mt7915/mac.c b/mt7915/mac.c |
developer | b81e95d | 2022-11-08 10:16:29 +0800 | [diff] [blame^] | 32 | index e78f30f..7fb161d 100644 |
developer | 8ec491f | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 33 | --- a/mt7915/mac.c |
| 34 | +++ b/mt7915/mac.c |
developer | 29344f1 | 2022-10-17 12:01:44 +0800 | [diff] [blame] | 35 | @@ -942,6 +942,31 @@ void mt7915_wed_trigger_ser(struct mtk_wed_device *wed) |
developer | 8ec491f | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 36 | return; |
| 37 | } |
| 38 | |
| 39 | +void mt7915_wed_update_wo_rxcnt(struct mtk_wed_device *wed, |
| 40 | + struct wo_cmd_rxcnt_t *rxcnt) |
| 41 | +{ |
| 42 | + struct mt7915_dev *dev; |
| 43 | + struct mt76_wcid *wcid; |
| 44 | + |
| 45 | + dev = container_of(wed, struct mt7915_dev, mt76.mmio.wed); |
| 46 | + if (rxcnt->wlan_idx >= mt7915_wtbl_size(dev)) |
| 47 | + return; |
| 48 | + |
| 49 | + rcu_read_lock(); |
| 50 | + |
| 51 | + wcid = rcu_dereference(dev->mt76.wcid[rxcnt->wlan_idx]); |
| 52 | + if (!wcid) |
| 53 | + goto out; |
| 54 | + |
| 55 | + wcid->stats.rx_bytes += rxcnt->rx_byte_cnt; |
| 56 | + wcid->stats.rx_packets += rxcnt->rx_pkt_cnt; |
| 57 | + wcid->stats.rx_error += rxcnt->rx_err_cnt; |
| 58 | + wcid->stats.rx_drop += rxcnt->rx_drop_cnt; |
| 59 | + |
| 60 | +out: |
| 61 | + rcu_read_unlock(); |
| 62 | +} |
| 63 | + |
| 64 | static void |
| 65 | mt7915_tx_check_aggr(struct ieee80211_sta *sta, __le32 *txwi) |
| 66 | { |
developer | 8ec491f | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 67 | diff --git a/mt7915/main.c b/mt7915/main.c |
developer | b81e95d | 2022-11-08 10:16:29 +0800 | [diff] [blame^] | 68 | index 5e37c4c..01d64b2 100644 |
developer | 8ec491f | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 69 | --- a/mt7915/main.c |
| 70 | +++ b/mt7915/main.c |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 71 | @@ -1050,7 +1050,8 @@ static void mt7915_sta_statistics(struct ieee80211_hw *hw, |
developer | 8ec491f | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 72 | struct rate_info *txrate = &msta->wcid.rate; |
| 73 | struct rate_info rxrate = {}; |
| 74 | |
| 75 | - if (is_mt7915(&phy->dev->mt76) && |
| 76 | + if ((is_mt7915(&phy->dev->mt76) || |
| 77 | + mtk_wed_device_active(&phy->dev->mt76.mmio.wed)) && |
| 78 | !mt7915_mcu_get_rx_rate(phy, vif, sta, &rxrate)) { |
| 79 | sinfo->rxrate = rxrate; |
| 80 | sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_BITRATE); |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 81 | @@ -1087,6 +1088,12 @@ static void mt7915_sta_statistics(struct ieee80211_hw *hw, |
developer | 8ec491f | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 82 | |
| 83 | sinfo->tx_retries = msta->wcid.stats.tx_retries; |
| 84 | sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_RETRIES); |
| 85 | + |
| 86 | + sinfo->rx_bytes = msta->wcid.stats.rx_bytes; |
| 87 | + sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_BYTES64); |
| 88 | + |
| 89 | + sinfo->rx_packets = msta->wcid.stats.rx_packets; |
| 90 | + sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_PACKETS); |
| 91 | } |
| 92 | } |
| 93 | |
developer | 8ec491f | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 94 | diff --git a/mt7915/mmio.c b/mt7915/mmio.c |
developer | b81e95d | 2022-11-08 10:16:29 +0800 | [diff] [blame^] | 95 | index 6a1877d..cd8326b 100644 |
developer | 8ec491f | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 96 | --- a/mt7915/mmio.c |
| 97 | +++ b/mt7915/mmio.c |
| 98 | @@ -9,6 +9,7 @@ |
| 99 | #include "mt7915.h" |
| 100 | #include "mac.h" |
| 101 | #include "../trace.h" |
| 102 | +#include "../mt76_connac_mcu.h" |
| 103 | |
developer | 29344f1 | 2022-10-17 12:01:44 +0800 | [diff] [blame] | 104 | static bool wed_enable = true; |
developer | 8ec491f | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 105 | module_param(wed_enable, bool, 0644); |
developer | 29344f1 | 2022-10-17 12:01:44 +0800 | [diff] [blame] | 106 | @@ -618,6 +619,8 @@ int mt7915_mmio_wed_init(struct mt7915_dev *dev, void *pdev_ptr, |
developer | 8ec491f | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 107 | |
| 108 | wed->wlan.ser_trigger = mt7915_wed_trigger_ser; |
| 109 | |
| 110 | + wed->wlan.update_wo_rxcnt = mt7915_wed_update_wo_rxcnt; |
| 111 | + |
| 112 | dev->mt76.rx_token_size = wed->wlan.rx_pkt; |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 113 | if (mtk_wed_device_attach(wed)) |
developer | 8ec491f | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 114 | return 0; |
developer | c859294 | 2022-10-31 14:07:50 +0800 | [diff] [blame] | 115 | @@ -630,6 +633,20 @@ int mt7915_mmio_wed_init(struct mt7915_dev *dev, void *pdev_ptr, |
developer | 8ec491f | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 116 | if (ret) |
| 117 | return ret; |
| 118 | |
developer | c859294 | 2022-10-31 14:07:50 +0800 | [diff] [blame] | 119 | + if (wed->ver != 1) { |
| 120 | + struct { |
| 121 | + __le32 args[2]; |
| 122 | + } req = { |
| 123 | + .args = { |
| 124 | + cpu_to_le32(1), |
| 125 | + cpu_to_le32(6), |
| 126 | + }, |
| 127 | + }; |
| 128 | + |
| 129 | + mtk_wed_device_update_msg(wed, WED_WO_RXCNT_CTRL, |
| 130 | + (void *)&req, sizeof(req)); |
| 131 | + } |
developer | 8ec491f | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 132 | + |
| 133 | return 1; |
| 134 | #else |
| 135 | return 0; |
| 136 | diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h |
developer | b81e95d | 2022-11-08 10:16:29 +0800 | [diff] [blame^] | 137 | index 412f4f4..9977162 100644 |
developer | 8ec491f | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 138 | --- a/mt7915/mt7915.h |
| 139 | +++ b/mt7915/mt7915.h |
developer | b81e95d | 2022-11-08 10:16:29 +0800 | [diff] [blame^] | 140 | @@ -549,6 +549,8 @@ u32 mt7915_wed_init_rx_buf(struct mtk_wed_device *wed, |
developer | 8ec491f | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 141 | int pkt_num); |
| 142 | void mt7915_wed_release_rx_buf(struct mtk_wed_device *wed); |
| 143 | void mt7915_wed_trigger_ser(struct mtk_wed_device *wed); |
| 144 | +void mt7915_wed_update_wo_rxcnt(struct mtk_wed_device *wed, |
| 145 | + struct wo_cmd_rxcnt_t *rxcnt); |
| 146 | int mt7915_register_device(struct mt7915_dev *dev); |
| 147 | void mt7915_unregister_device(struct mt7915_dev *dev); |
developer | 29344f1 | 2022-10-17 12:01:44 +0800 | [diff] [blame] | 148 | void mt7915_eeprom_rebonding(struct mt7915_dev *dev); |
developer | 8ec491f | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 149 | -- |
developer | b81e95d | 2022-11-08 10:16:29 +0800 | [diff] [blame^] | 150 | 2.18.0 |
developer | 8ec491f | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 151 | |