blob: 9ce1f1182f2ccf2a97d5f85decc2c1648323c51e [file] [log] [blame]
developerd0c89452024-10-11 16:53:27 +08001From ff2647b012eddbe530dd4b900506911fa91c8329 Mon Sep 17 00:00:00 2001
developer05f3b2b2024-08-19 19:17:34 +08002From: Peter Chiu <chui-hao.chiu@mediatek.com>
3Date: Tue, 11 Jun 2024 18:09:57 +0800
developerd0c89452024-10-11 16:53:27 +08004Subject: [PATCH 142/223] mtk: mt76: mt7996: add link information when dump
developer05f3b2b2024-08-19 19:17:34 +08005 station
6
7Report following per-link information to mac80211:
8- RSSI
9- RX rate
10- TX/RX byte counts
11- TX MPDU failed/retried counts
12- TX/RX airtime
13- per-link per-antenna average data-frame RSSI to mac80211.
14
developerd0c89452024-10-11 16:53:27 +080015Change-Id: I3a0c5e014dcad4683cf19859e452e771c49d4ba6
16Change-Id: I5c7c282b97ec8a82b0a54ff5e9bbf0858461c832
developer05f3b2b2024-08-19 19:17:34 +080017Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
18Signed-off-by: Benjamin Lin <benjamin-jw.lin@mediatek.com>
19---
20 mt7996/main.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++
21 1 file changed, 78 insertions(+)
22
23diff --git a/mt7996/main.c b/mt7996/main.c
developerd0c89452024-10-11 16:53:27 +080024index 05917cc8..380a6ca0 100644
developer05f3b2b2024-08-19 19:17:34 +080025--- a/mt7996/main.c
26+++ b/mt7996/main.c
developerd0c89452024-10-11 16:53:27 +080027@@ -1817,6 +1817,83 @@ out:
developer05f3b2b2024-08-19 19:17:34 +080028 mutex_unlock(&dev->mt76.mutex);
29 }
30
31+static void mt7996_sta_link_statistics(struct ieee80211_hw *hw,
32+ struct ieee80211_vif *vif,
33+ struct ieee80211_sta *sta,
34+ unsigned int link_id,
35+ struct station_link_info *linfo)
36+{
37+ struct mt7996_dev *dev = mt7996_hw_dev(hw);
38+ struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
39+ struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
40+ struct mt7996_link_sta *mlink;
41+ struct mt7996_bss_conf *mconf;
42+ struct mt76_sta_stats *stats;
43+ int i;
44+
45+ mutex_lock(&dev->mt76.mutex);
46+ mlink = mlink_dereference_protected(msta, link_id);
47+ if (!mlink)
48+ goto out;
49+ stats = &mlink->wcid.stats;
50+
51+ mconf = mconf_dereference_protected(mvif, link_id);
52+ if (!mconf)
53+ goto out;
54+
55+ linfo->signal = (s8)mlink->signal;
56+ linfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL);
57+
58+ linfo->chains = mconf->phy->mt76->antenna_mask;
59+ memcpy(linfo->chain_signal, mlink->chain_signal, IEEE80211_MAX_CHAINS);
60+ linfo->filled |= BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL);
61+
62+ linfo->signal_avg = -(s8)ewma_avg_signal_read(&mlink->signal_avg);
63+ linfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL_AVG);
64+
65+ for (i = 0; i < IEEE80211_MAX_CHAINS; ++i)
66+ linfo->chain_signal_avg[i] = -(s8)ewma_avg_signal_read(mlink->chain_signal_avg + i);
67+ linfo->filled |= BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL_AVG);
68+
69+ linfo->ack_signal = (s8)mlink->ack_signal;
70+ linfo->filled |= BIT_ULL(NL80211_STA_INFO_ACK_SIGNAL);
71+
72+ linfo->avg_ack_signal = -(s8)ewma_avg_signal_read(&mlink->avg_ack_signal);
73+ linfo->filled |= BIT_ULL(NL80211_STA_INFO_ACK_SIGNAL_AVG);
74+
75+ linfo->txrate = mlink->wcid.rate;
76+ linfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BITRATE);
77+
78+ linfo->rxrate = mlink->wcid.rx_rate;
79+ linfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_BITRATE);
80+
81+ linfo->tx_bytes = stats->tx_bytes;
82+ linfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BYTES64);
83+
84+ linfo->rx_bytes = stats->rx_bytes;
85+ linfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_BYTES64);
86+
87+ linfo->tx_failed = stats->tx_failed;
88+ linfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_FAILED);
89+
90+ linfo->tx_retries = stats->tx_retries;
91+ linfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_RETRIES);
92+
93+ linfo->rx_mpdu_count = stats->rx_mpdus;
94+ linfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_MPDUS);
95+
96+ linfo->fcs_err_count = stats->rx_fcs_err;
97+ linfo->filled |= BIT_ULL(NL80211_STA_INFO_FCS_ERROR_COUNT);
98+
99+ linfo->tx_duration = stats->tx_airtime;
100+ linfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_DURATION);
101+
102+ linfo->rx_duration = stats->rx_airtime;
103+ linfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_DURATION);
104+out:
105+ mutex_unlock(&dev->mt76.mutex);
106+}
107+
108 static void mt7996_sta_rc_work(void *data, struct ieee80211_sta *sta)
109 {
110 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
developerd0c89452024-10-11 16:53:27 +0800111@@ -2936,6 +3013,7 @@ const struct ieee80211_ops mt7996_ops = {
developer05f3b2b2024-08-19 19:17:34 +0800112 .set_bitrate_mask = mt7996_set_bitrate_mask,
113 .set_coverage_class = mt7996_set_coverage_class,
114 .sta_statistics = mt7996_sta_statistics,
115+ .sta_link_statistics = mt7996_sta_link_statistics,
116 .sta_set_4addr = mt7996_sta_set_4addr,
117 .sta_set_decap_offload = mt7996_sta_set_decap_offload,
118 .add_twt_setup = mt7996_mac_add_twt_setup,
119--
developerd0c89452024-10-11 16:53:27 +08001202.45.2
developer05f3b2b2024-08-19 19:17:34 +0800121