blob: ec3a0a3ad21745182f3874f7097e377d1c460419 [file] [log] [blame]
developer29344f12022-10-17 12:01:44 +08001From 3c7f7b7883ce2dd0f185488d1f67d689330213d4 Mon Sep 17 00:00:00 2001
developer8ec491f2022-08-22 19:48:44 +08002From: Yi-Chia Hsieh <Yi-Chia.Hsieh@mediatek.com>
3Date: Fri, 5 Aug 2022 13:58:11 -0700
developer29344f12022-10-17 12:01:44 +08004Subject: [PATCH 3006/3011] mt76: mt7915: add statistic for H/W Rx Path
developer8ec491f2022-08-22 19:48:44 +08005
6Change-Id: Id94d663f08e91c83d296bd57e5e9b65a505ae1c7
7---
developerc8592942022-10-31 14:07:50 +08008 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(-)
developer8ec491f2022-08-22 19:48:44 +080014
15diff --git a/mt76.h b/mt76.h
developer29344f12022-10-17 12:01:44 +080016index 3530d213..47a92132 100644
developer8ec491f2022-08-22 19:48:44 +080017--- a/mt76.h
18+++ b/mt76.h
developer33907d42022-09-19 14:33:58 +080019@@ -278,6 +278,10 @@ struct mt76_sta_stats {
developer8ec491f2022-08-22 19:48:44 +080020 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
developer33907d42022-09-19 14:33:58 +080029 enum mt76_wcid_flags {
developer8ec491f2022-08-22 19:48:44 +080030diff --git a/mt7915/mac.c b/mt7915/mac.c
developer29344f12022-10-17 12:01:44 +080031index e78f30fc..7fb161db 100644
developer8ec491f2022-08-22 19:48:44 +080032--- a/mt7915/mac.c
33+++ b/mt7915/mac.c
developer29344f12022-10-17 12:01:44 +080034@@ -942,6 +942,31 @@ void mt7915_wed_trigger_ser(struct mtk_wed_device *wed)
developer8ec491f2022-08-22 19:48:44 +080035 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 {
developer8ec491f2022-08-22 19:48:44 +080066diff --git a/mt7915/main.c b/mt7915/main.c
developer29344f12022-10-17 12:01:44 +080067index 5e37c4c8..01d64b2f 100644
developer8ec491f2022-08-22 19:48:44 +080068--- a/mt7915/main.c
69+++ b/mt7915/main.c
developerf1313102022-10-11 11:02:55 +080070@@ -1050,7 +1050,8 @@ static void mt7915_sta_statistics(struct ieee80211_hw *hw,
developer8ec491f2022-08-22 19:48:44 +080071 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);
developerf1313102022-10-11 11:02:55 +080080@@ -1087,6 +1088,12 @@ static void mt7915_sta_statistics(struct ieee80211_hw *hw,
developer8ec491f2022-08-22 19:48:44 +080081
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
developer8ec491f2022-08-22 19:48:44 +080093diff --git a/mt7915/mmio.c b/mt7915/mmio.c
developer29344f12022-10-17 12:01:44 +080094index 6a1877d4..cd8326b0 100644
developer8ec491f2022-08-22 19:48:44 +080095--- 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
developer29344f12022-10-17 12:01:44 +0800103 static bool wed_enable = true;
developer8ec491f2022-08-22 19:48:44 +0800104 module_param(wed_enable, bool, 0644);
developer29344f12022-10-17 12:01:44 +0800105@@ -618,6 +619,8 @@ int mt7915_mmio_wed_init(struct mt7915_dev *dev, void *pdev_ptr,
developer8ec491f2022-08-22 19:48:44 +0800106
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;
developerf1313102022-10-11 11:02:55 +0800112 if (mtk_wed_device_attach(wed))
developer8ec491f2022-08-22 19:48:44 +0800113 return 0;
developerc8592942022-10-31 14:07:50 +0800114@@ -630,6 +633,20 @@ int mt7915_mmio_wed_init(struct mt7915_dev *dev, void *pdev_ptr,
developer8ec491f2022-08-22 19:48:44 +0800115 if (ret)
116 return ret;
117
developerc8592942022-10-31 14:07:50 +0800118+ 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+ }
developer8ec491f2022-08-22 19:48:44 +0800131+
132 return 1;
133 #else
134 return 0;
135diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
developer29344f12022-10-17 12:01:44 +0800136index 3a81261b..b1fbbae9 100644
developer8ec491f2022-08-22 19:48:44 +0800137--- a/mt7915/mt7915.h
138+++ b/mt7915/mt7915.h
developerf1313102022-10-11 11:02:55 +0800139@@ -548,6 +548,8 @@ u32 mt7915_wed_init_rx_buf(struct mtk_wed_device *wed,
developer8ec491f2022-08-22 19:48:44 +0800140 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);
developer29344f12022-10-17 12:01:44 +0800147 void mt7915_eeprom_rebonding(struct mt7915_dev *dev);
developer8ec491f2022-08-22 19:48:44 +0800148--
developer29344f12022-10-17 12:01:44 +08001492.25.1
developer8ec491f2022-08-22 19:48:44 +0800150