| From 4eda4a37c2d5fee71c5f7b4d4a3b5baa57252c14 Mon Sep 17 00:00:00 2001 |
| From: Peter Chiu <chui-hao.chiu@mediatek.com> |
| Date: Tue, 11 Jun 2024 18:09:57 +0800 |
| Subject: [PATCH 154/199] mtk: mt76: mt7996: add link information when dump |
| station |
| |
| Report following per-link information to mac80211: |
| - RSSI |
| - RX rate |
| - TX/RX byte counts |
| - TX MPDU failed/retried counts |
| - TX/RX airtime |
| - per-link per-antenna average data-frame RSSI to mac80211. |
| |
| Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com> |
| Signed-off-by: Benjamin Lin <benjamin-jw.lin@mediatek.com> |
| --- |
| mt7996/main.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 1 file changed, 78 insertions(+) |
| |
| diff --git a/mt7996/main.c b/mt7996/main.c |
| index fa60b889..8c162987 100644 |
| --- a/mt7996/main.c |
| +++ b/mt7996/main.c |
| @@ -1813,6 +1813,83 @@ out: |
| mutex_unlock(&dev->mt76.mutex); |
| } |
| |
| +static void mt7996_sta_link_statistics(struct ieee80211_hw *hw, |
| + struct ieee80211_vif *vif, |
| + struct ieee80211_sta *sta, |
| + unsigned int link_id, |
| + struct station_link_info *linfo) |
| +{ |
| + struct mt7996_dev *dev = mt7996_hw_dev(hw); |
| + struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
| + struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| + struct mt7996_link_sta *mlink; |
| + struct mt7996_bss_conf *mconf; |
| + struct mt76_sta_stats *stats; |
| + int i; |
| + |
| + mutex_lock(&dev->mt76.mutex); |
| + mlink = mlink_dereference_protected(msta, link_id); |
| + if (!mlink) |
| + goto out; |
| + stats = &mlink->wcid.stats; |
| + |
| + mconf = mconf_dereference_protected(mvif, link_id); |
| + if (!mconf) |
| + goto out; |
| + |
| + linfo->signal = (s8)mlink->signal; |
| + linfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL); |
| + |
| + linfo->chains = mconf->phy->mt76->antenna_mask; |
| + memcpy(linfo->chain_signal, mlink->chain_signal, IEEE80211_MAX_CHAINS); |
| + linfo->filled |= BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL); |
| + |
| + linfo->signal_avg = -(s8)ewma_avg_signal_read(&mlink->signal_avg); |
| + linfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL_AVG); |
| + |
| + for (i = 0; i < IEEE80211_MAX_CHAINS; ++i) |
| + linfo->chain_signal_avg[i] = -(s8)ewma_avg_signal_read(mlink->chain_signal_avg + i); |
| + linfo->filled |= BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL_AVG); |
| + |
| + linfo->ack_signal = (s8)mlink->ack_signal; |
| + linfo->filled |= BIT_ULL(NL80211_STA_INFO_ACK_SIGNAL); |
| + |
| + linfo->avg_ack_signal = -(s8)ewma_avg_signal_read(&mlink->avg_ack_signal); |
| + linfo->filled |= BIT_ULL(NL80211_STA_INFO_ACK_SIGNAL_AVG); |
| + |
| + linfo->txrate = mlink->wcid.rate; |
| + linfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BITRATE); |
| + |
| + linfo->rxrate = mlink->wcid.rx_rate; |
| + linfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_BITRATE); |
| + |
| + linfo->tx_bytes = stats->tx_bytes; |
| + linfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BYTES64); |
| + |
| + linfo->rx_bytes = stats->rx_bytes; |
| + linfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_BYTES64); |
| + |
| + linfo->tx_failed = stats->tx_failed; |
| + linfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_FAILED); |
| + |
| + linfo->tx_retries = stats->tx_retries; |
| + linfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_RETRIES); |
| + |
| + linfo->rx_mpdu_count = stats->rx_mpdus; |
| + linfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_MPDUS); |
| + |
| + linfo->fcs_err_count = stats->rx_fcs_err; |
| + linfo->filled |= BIT_ULL(NL80211_STA_INFO_FCS_ERROR_COUNT); |
| + |
| + linfo->tx_duration = stats->tx_airtime; |
| + linfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_DURATION); |
| + |
| + linfo->rx_duration = stats->rx_airtime; |
| + linfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_DURATION); |
| +out: |
| + mutex_unlock(&dev->mt76.mutex); |
| +} |
| + |
| static void mt7996_sta_rc_work(void *data, struct ieee80211_sta *sta) |
| { |
| struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
| @@ -2932,6 +3009,7 @@ const struct ieee80211_ops mt7996_ops = { |
| .set_bitrate_mask = mt7996_set_bitrate_mask, |
| .set_coverage_class = mt7996_set_coverage_class, |
| .sta_statistics = mt7996_sta_statistics, |
| + .sta_link_statistics = mt7996_sta_link_statistics, |
| .sta_set_4addr = mt7996_sta_set_4addr, |
| .sta_set_decap_offload = mt7996_sta_set_decap_offload, |
| .add_twt_setup = mt7996_mac_add_twt_setup, |
| -- |
| 2.18.0 |
| |