blob: ec3a0a3ad21745182f3874f7097e377d1c460419 [file] [log] [blame]
From 3c7f7b7883ce2dd0f185488d1f67d689330213d4 Mon Sep 17 00:00:00 2001
From: Yi-Chia Hsieh <Yi-Chia.Hsieh@mediatek.com>
Date: Fri, 5 Aug 2022 13:58:11 -0700
Subject: [PATCH 3006/3011] mt76: mt7915: add statistic for H/W Rx Path
Change-Id: Id94d663f08e91c83d296bd57e5e9b65a505ae1c7
---
mt76.h | 4 ++++
mt7915/mac.c | 25 +++++++++++++++++++++++++
mt7915/main.c | 9 ++++++++-
mt7915/mmio.c | 17 +++++++++++++++++
mt7915/mt7915.h | 2 ++
5 files changed, 56 insertions(+), 1 deletion(-)
diff --git a/mt76.h b/mt76.h
index 3530d213..47a92132 100644
--- a/mt76.h
+++ b/mt76.h
@@ -278,6 +278,10 @@ struct mt76_sta_stats {
u32 tx_packets;
u32 tx_retries;
u32 tx_failed;
+ u64 rx_bytes;
+ u32 rx_packets;
+ u32 rx_error;
+ u32 rx_drop;
};
enum mt76_wcid_flags {
diff --git a/mt7915/mac.c b/mt7915/mac.c
index e78f30fc..7fb161db 100644
--- a/mt7915/mac.c
+++ b/mt7915/mac.c
@@ -942,6 +942,31 @@ void mt7915_wed_trigger_ser(struct mtk_wed_device *wed)
return;
}
+void mt7915_wed_update_wo_rxcnt(struct mtk_wed_device *wed,
+ struct wo_cmd_rxcnt_t *rxcnt)
+{
+ struct mt7915_dev *dev;
+ struct mt76_wcid *wcid;
+
+ dev = container_of(wed, struct mt7915_dev, mt76.mmio.wed);
+ if (rxcnt->wlan_idx >= mt7915_wtbl_size(dev))
+ return;
+
+ rcu_read_lock();
+
+ wcid = rcu_dereference(dev->mt76.wcid[rxcnt->wlan_idx]);
+ if (!wcid)
+ goto out;
+
+ wcid->stats.rx_bytes += rxcnt->rx_byte_cnt;
+ wcid->stats.rx_packets += rxcnt->rx_pkt_cnt;
+ wcid->stats.rx_error += rxcnt->rx_err_cnt;
+ wcid->stats.rx_drop += rxcnt->rx_drop_cnt;
+
+out:
+ rcu_read_unlock();
+}
+
static void
mt7915_tx_check_aggr(struct ieee80211_sta *sta, __le32 *txwi)
{
diff --git a/mt7915/main.c b/mt7915/main.c
index 5e37c4c8..01d64b2f 100644
--- a/mt7915/main.c
+++ b/mt7915/main.c
@@ -1050,7 +1050,8 @@ static void mt7915_sta_statistics(struct ieee80211_hw *hw,
struct rate_info *txrate = &msta->wcid.rate;
struct rate_info rxrate = {};
- if (is_mt7915(&phy->dev->mt76) &&
+ if ((is_mt7915(&phy->dev->mt76) ||
+ mtk_wed_device_active(&phy->dev->mt76.mmio.wed)) &&
!mt7915_mcu_get_rx_rate(phy, vif, sta, &rxrate)) {
sinfo->rxrate = rxrate;
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_BITRATE);
@@ -1087,6 +1088,12 @@ static void mt7915_sta_statistics(struct ieee80211_hw *hw,
sinfo->tx_retries = msta->wcid.stats.tx_retries;
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_RETRIES);
+
+ sinfo->rx_bytes = msta->wcid.stats.rx_bytes;
+ sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_BYTES64);
+
+ sinfo->rx_packets = msta->wcid.stats.rx_packets;
+ sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_PACKETS);
}
}
diff --git a/mt7915/mmio.c b/mt7915/mmio.c
index 6a1877d4..cd8326b0 100644
--- a/mt7915/mmio.c
+++ b/mt7915/mmio.c
@@ -9,6 +9,7 @@
#include "mt7915.h"
#include "mac.h"
#include "../trace.h"
+#include "../mt76_connac_mcu.h"
static bool wed_enable = true;
module_param(wed_enable, bool, 0644);
@@ -618,6 +619,8 @@ int mt7915_mmio_wed_init(struct mt7915_dev *dev, void *pdev_ptr,
wed->wlan.ser_trigger = mt7915_wed_trigger_ser;
+ wed->wlan.update_wo_rxcnt = mt7915_wed_update_wo_rxcnt;
+
dev->mt76.rx_token_size = wed->wlan.rx_pkt;
if (mtk_wed_device_attach(wed))
return 0;
@@ -630,6 +633,20 @@ int mt7915_mmio_wed_init(struct mt7915_dev *dev, void *pdev_ptr,
if (ret)
return ret;
+ if (wed->ver != 1) {
+ struct {
+ __le32 args[2];
+ } req = {
+ .args = {
+ cpu_to_le32(1),
+ cpu_to_le32(6),
+ },
+ };
+
+ mtk_wed_device_update_msg(wed, WED_WO_RXCNT_CTRL,
+ (void *)&req, sizeof(req));
+ }
+
return 1;
#else
return 0;
diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
index 3a81261b..b1fbbae9 100644
--- a/mt7915/mt7915.h
+++ b/mt7915/mt7915.h
@@ -548,6 +548,8 @@ u32 mt7915_wed_init_rx_buf(struct mtk_wed_device *wed,
int pkt_num);
void mt7915_wed_release_rx_buf(struct mtk_wed_device *wed);
void mt7915_wed_trigger_ser(struct mtk_wed_device *wed);
+void mt7915_wed_update_wo_rxcnt(struct mtk_wed_device *wed,
+ struct wo_cmd_rxcnt_t *rxcnt);
int mt7915_register_device(struct mt7915_dev *dev);
void mt7915_unregister_device(struct mt7915_dev *dev);
void mt7915_eeprom_rebonding(struct mt7915_dev *dev);
--
2.25.1