blob: 4d886bef7680d9d74bc00ba526d64b887d3225dd [file] [log] [blame]
developer887da632022-10-28 09:35:38 +08001From 301353df129dc70115481141357c590b4362a5c8 Mon Sep 17 00:00:00 2001
developerb1b09452022-08-11 13:48:34 -07002From: Yi-Chia Hsieh <Yi-Chia.Hsieh@mediatek.com>
3Date: Fri, 5 Aug 2022 13:58:11 -0700
developer887da632022-10-28 09:35:38 +08004Subject: [PATCH 3006/3010] mt76: mt7915: add statistic for H/W Rx Path
developerb1b09452022-08-11 13:48:34 -07005
6Change-Id: Id94d663f08e91c83d296bd57e5e9b65a505ae1c7
developer887da632022-10-28 09:35:38 +08007Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
developerb1b09452022-08-11 13:48:34 -07008---
developerfaaa5162022-10-24 14:12:16 +08009 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(-)
developerb1b09452022-08-11 13:48:34 -070015
16diff --git a/mt76.h b/mt76.h
developer887da632022-10-28 09:35:38 +080017index 13bdc08..14c58bc 100644
developerb1b09452022-08-11 13:48:34 -070018--- a/mt76.h
19+++ b/mt76.h
developer20747c12022-09-16 14:09:40 +080020@@ -278,6 +278,10 @@ struct mt76_sta_stats {
developerb1b09452022-08-11 13:48:34 -070021 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
developer20747c12022-09-16 14:09:40 +080030 enum mt76_wcid_flags {
developerb1b09452022-08-11 13:48:34 -070031diff --git a/mt7915/mac.c b/mt7915/mac.c
developer887da632022-10-28 09:35:38 +080032index e78f30f..7fb161d 100644
developerb1b09452022-08-11 13:48:34 -070033--- a/mt7915/mac.c
34+++ b/mt7915/mac.c
developer81ca9d62022-10-14 11:23:22 +080035@@ -942,6 +942,31 @@ void mt7915_wed_trigger_ser(struct mtk_wed_device *wed)
developerb1b09452022-08-11 13:48:34 -070036 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 {
developerb1b09452022-08-11 13:48:34 -070067diff --git a/mt7915/main.c b/mt7915/main.c
developer887da632022-10-28 09:35:38 +080068index 5e37c4c..01d64b2 100644
developerb1b09452022-08-11 13:48:34 -070069--- a/mt7915/main.c
70+++ b/mt7915/main.c
developerc226de82022-10-03 12:24:57 +080071@@ -1050,7 +1050,8 @@ static void mt7915_sta_statistics(struct ieee80211_hw *hw,
developerb1b09452022-08-11 13:48:34 -070072 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);
developerc226de82022-10-03 12:24:57 +080081@@ -1087,6 +1088,12 @@ static void mt7915_sta_statistics(struct ieee80211_hw *hw,
developerb1b09452022-08-11 13:48:34 -070082
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
developerb1b09452022-08-11 13:48:34 -070094diff --git a/mt7915/mmio.c b/mt7915/mmio.c
developer887da632022-10-28 09:35:38 +080095index 6a1877d..cd8326b 100644
developerb1b09452022-08-11 13:48:34 -070096--- 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
developer81ca9d62022-10-14 11:23:22 +0800104 static bool wed_enable = true;
developerb1b09452022-08-11 13:48:34 -0700105 module_param(wed_enable, bool, 0644);
developer81ca9d62022-10-14 11:23:22 +0800106@@ -618,6 +619,8 @@ int mt7915_mmio_wed_init(struct mt7915_dev *dev, void *pdev_ptr,
developerb1b09452022-08-11 13:48:34 -0700107
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;
developerc226de82022-10-03 12:24:57 +0800113 if (mtk_wed_device_attach(wed))
developerb1b09452022-08-11 13:48:34 -0700114 return 0;
developerfaaa5162022-10-24 14:12:16 +0800115@@ -630,6 +633,20 @@ int mt7915_mmio_wed_init(struct mt7915_dev *dev, void *pdev_ptr,
developerb1b09452022-08-11 13:48:34 -0700116 if (ret)
117 return ret;
118
developerfaaa5162022-10-24 14:12:16 +0800119+ 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+ }
developerb1b09452022-08-11 13:48:34 -0700132+
133 return 1;
134 #else
135 return 0;
136diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
developer887da632022-10-28 09:35:38 +0800137index 412f4f4..9977162 100644
developerb1b09452022-08-11 13:48:34 -0700138--- a/mt7915/mt7915.h
139+++ b/mt7915/mt7915.h
developer887da632022-10-28 09:35:38 +0800140@@ -549,6 +549,8 @@ u32 mt7915_wed_init_rx_buf(struct mtk_wed_device *wed,
developerb1b09452022-08-11 13:48:34 -0700141 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);
developer81ca9d62022-10-14 11:23:22 +0800148 void mt7915_eeprom_rebonding(struct mt7915_dev *dev);
developerb1b09452022-08-11 13:48:34 -0700149--
developer887da632022-10-28 09:35:38 +08001502.18.0
developerb1b09452022-08-11 13:48:34 -0700151