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