blob: 057f0c40a3500e1e59f8cd8454ec787b375a7f34 [file] [log] [blame]
developer05f3b2b2024-08-19 19:17:34 +08001From 4eda4a37c2d5fee71c5f7b4d4a3b5baa57252c14 Mon Sep 17 00:00:00 2001
2From: Peter Chiu <chui-hao.chiu@mediatek.com>
3Date: Tue, 11 Jun 2024 18:09:57 +0800
4Subject: [PATCH 154/199] mtk: mt76: mt7996: add link information when dump
5 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
15Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
16Signed-off-by: Benjamin Lin <benjamin-jw.lin@mediatek.com>
17---
18 mt7996/main.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++
19 1 file changed, 78 insertions(+)
20
21diff --git a/mt7996/main.c b/mt7996/main.c
22index fa60b889..8c162987 100644
23--- a/mt7996/main.c
24+++ b/mt7996/main.c
25@@ -1813,6 +1813,83 @@ out:
26 mutex_unlock(&dev->mt76.mutex);
27 }
28
29+static void mt7996_sta_link_statistics(struct ieee80211_hw *hw,
30+ struct ieee80211_vif *vif,
31+ struct ieee80211_sta *sta,
32+ unsigned int link_id,
33+ struct station_link_info *linfo)
34+{
35+ struct mt7996_dev *dev = mt7996_hw_dev(hw);
36+ struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
37+ struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
38+ struct mt7996_link_sta *mlink;
39+ struct mt7996_bss_conf *mconf;
40+ struct mt76_sta_stats *stats;
41+ int i;
42+
43+ mutex_lock(&dev->mt76.mutex);
44+ mlink = mlink_dereference_protected(msta, link_id);
45+ if (!mlink)
46+ goto out;
47+ stats = &mlink->wcid.stats;
48+
49+ mconf = mconf_dereference_protected(mvif, link_id);
50+ if (!mconf)
51+ goto out;
52+
53+ linfo->signal = (s8)mlink->signal;
54+ linfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL);
55+
56+ linfo->chains = mconf->phy->mt76->antenna_mask;
57+ memcpy(linfo->chain_signal, mlink->chain_signal, IEEE80211_MAX_CHAINS);
58+ linfo->filled |= BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL);
59+
60+ linfo->signal_avg = -(s8)ewma_avg_signal_read(&mlink->signal_avg);
61+ linfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL_AVG);
62+
63+ for (i = 0; i < IEEE80211_MAX_CHAINS; ++i)
64+ linfo->chain_signal_avg[i] = -(s8)ewma_avg_signal_read(mlink->chain_signal_avg + i);
65+ linfo->filled |= BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL_AVG);
66+
67+ linfo->ack_signal = (s8)mlink->ack_signal;
68+ linfo->filled |= BIT_ULL(NL80211_STA_INFO_ACK_SIGNAL);
69+
70+ linfo->avg_ack_signal = -(s8)ewma_avg_signal_read(&mlink->avg_ack_signal);
71+ linfo->filled |= BIT_ULL(NL80211_STA_INFO_ACK_SIGNAL_AVG);
72+
73+ linfo->txrate = mlink->wcid.rate;
74+ linfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BITRATE);
75+
76+ linfo->rxrate = mlink->wcid.rx_rate;
77+ linfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_BITRATE);
78+
79+ linfo->tx_bytes = stats->tx_bytes;
80+ linfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BYTES64);
81+
82+ linfo->rx_bytes = stats->rx_bytes;
83+ linfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_BYTES64);
84+
85+ linfo->tx_failed = stats->tx_failed;
86+ linfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_FAILED);
87+
88+ linfo->tx_retries = stats->tx_retries;
89+ linfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_RETRIES);
90+
91+ linfo->rx_mpdu_count = stats->rx_mpdus;
92+ linfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_MPDUS);
93+
94+ linfo->fcs_err_count = stats->rx_fcs_err;
95+ linfo->filled |= BIT_ULL(NL80211_STA_INFO_FCS_ERROR_COUNT);
96+
97+ linfo->tx_duration = stats->tx_airtime;
98+ linfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_DURATION);
99+
100+ linfo->rx_duration = stats->rx_airtime;
101+ linfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_DURATION);
102+out:
103+ mutex_unlock(&dev->mt76.mutex);
104+}
105+
106 static void mt7996_sta_rc_work(void *data, struct ieee80211_sta *sta)
107 {
108 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
109@@ -2932,6 +3009,7 @@ const struct ieee80211_ops mt7996_ops = {
110 .set_bitrate_mask = mt7996_set_bitrate_mask,
111 .set_coverage_class = mt7996_set_coverage_class,
112 .sta_statistics = mt7996_sta_statistics,
113+ .sta_link_statistics = mt7996_sta_link_statistics,
114 .sta_set_4addr = mt7996_sta_set_4addr,
115 .sta_set_decap_offload = mt7996_sta_set_decap_offload,
116 .add_twt_setup = mt7996_mac_add_twt_setup,
117--
1182.18.0
119