Commit f6b24241 authored by Ping-Ke Shih's avatar Ping-Ke Shih Committed by Kalle Valo

wifi: rtw89: add RSSI statistics for the case of antenna diversity to debugfs

RSSI strength is only from PHY path A, but there are two antenna for the
module which supports antenna diversity. So, set RSSI value to index 1 of
RSSI array if current antenna is on antenna B. Then, debugfs can show
two RSSI values with a asterisk mark on selected antenna.

  RSSI: -23 dBm (raw=174, prev=173) [-26, -23*]
Signed-off-by: default avatarPing-Ke Shih <pkshih@realtek.com>
Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230418012820.5139-4-pkshih@realtek.com
parent f48453e0
...@@ -1244,10 +1244,22 @@ static void rtw89_core_rx_process_phy_ppdu_iter(void *data, ...@@ -1244,10 +1244,22 @@ static void rtw89_core_rx_process_phy_ppdu_iter(void *data,
struct rtw89_sta *rtwsta = (struct rtw89_sta *)sta->drv_priv; struct rtw89_sta *rtwsta = (struct rtw89_sta *)sta->drv_priv;
struct rtw89_rx_phy_ppdu *phy_ppdu = (struct rtw89_rx_phy_ppdu *)data; struct rtw89_rx_phy_ppdu *phy_ppdu = (struct rtw89_rx_phy_ppdu *)data;
struct rtw89_dev *rtwdev = rtwsta->rtwdev; struct rtw89_dev *rtwdev = rtwsta->rtwdev;
struct rtw89_hal *hal = &rtwdev->hal;
u8 ant_num = hal->ant_diversity ? 2 : rtwdev->chip->rf_path_num;
u8 ant_pos = U8_MAX;
int i; int i;
if (rtwsta->mac_id == phy_ppdu->mac_id && phy_ppdu->to_self) { if (rtwsta->mac_id != phy_ppdu->mac_id || !phy_ppdu->to_self)
ewma_rssi_add(&rtwsta->avg_rssi, phy_ppdu->rssi_avg); return;
if (hal->ant_diversity && hal->antenna_rx)
ant_pos = __ffs(hal->antenna_rx);
ewma_rssi_add(&rtwsta->avg_rssi, phy_ppdu->rssi_avg);
if (ant_pos < ant_num) {
ewma_rssi_add(&rtwsta->rssi[ant_pos], phy_ppdu->rssi[0]);
} else {
for (i = 0; i < rtwdev->chip->rf_path_num; i++) for (i = 0; i < rtwdev->chip->rf_path_num; i++)
ewma_rssi_add(&rtwsta->rssi[i], phy_ppdu->rssi[i]); ewma_rssi_add(&rtwsta->rssi[i], phy_ppdu->rssi[i]);
} }
...@@ -2764,6 +2776,8 @@ int rtw89_core_sta_add(struct rtw89_dev *rtwdev, ...@@ -2764,6 +2776,8 @@ int rtw89_core_sta_add(struct rtw89_dev *rtwdev,
{ {
struct rtw89_vif *rtwvif = (struct rtw89_vif *)vif->drv_priv; struct rtw89_vif *rtwvif = (struct rtw89_vif *)vif->drv_priv;
struct rtw89_sta *rtwsta = (struct rtw89_sta *)sta->drv_priv; struct rtw89_sta *rtwsta = (struct rtw89_sta *)sta->drv_priv;
struct rtw89_hal *hal = &rtwdev->hal;
u8 ant_num = hal->ant_diversity ? 2 : rtwdev->chip->rf_path_num;
int i; int i;
int ret; int ret;
...@@ -2777,7 +2791,7 @@ int rtw89_core_sta_add(struct rtw89_dev *rtwdev, ...@@ -2777,7 +2791,7 @@ int rtw89_core_sta_add(struct rtw89_dev *rtwdev,
rtw89_core_txq_init(rtwdev, sta->txq[i]); rtw89_core_txq_init(rtwdev, sta->txq[i]);
ewma_rssi_init(&rtwsta->avg_rssi); ewma_rssi_init(&rtwsta->avg_rssi);
for (i = 0; i < rtwdev->chip->rf_path_num; i++) for (i = 0; i < ant_num; i++)
ewma_rssi_init(&rtwsta->rssi[i]); ewma_rssi_init(&rtwsta->rssi[i]);
if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls) { if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls) {
......
...@@ -3206,6 +3206,8 @@ static void rtw89_sta_info_get_iter(void *data, struct ieee80211_sta *sta) ...@@ -3206,6 +3206,8 @@ static void rtw89_sta_info_get_iter(void *data, struct ieee80211_sta *sta)
struct seq_file *m = (struct seq_file *)data; struct seq_file *m = (struct seq_file *)data;
struct rtw89_dev *rtwdev = rtwsta->rtwdev; struct rtw89_dev *rtwdev = rtwsta->rtwdev;
struct rtw89_hal *hal = &rtwdev->hal; struct rtw89_hal *hal = &rtwdev->hal;
u8 ant_num = hal->ant_diversity ? 2 : rtwdev->chip->rf_path_num;
bool ant_asterisk = hal->tx_path_diversity || hal->ant_diversity;
u8 rssi; u8 rssi;
int i; int i;
...@@ -3256,11 +3258,11 @@ static void rtw89_sta_info_get_iter(void *data, struct ieee80211_sta *sta) ...@@ -3256,11 +3258,11 @@ static void rtw89_sta_info_get_iter(void *data, struct ieee80211_sta *sta)
rssi = ewma_rssi_read(&rtwsta->avg_rssi); rssi = ewma_rssi_read(&rtwsta->avg_rssi);
seq_printf(m, "RSSI: %d dBm (raw=%d, prev=%d) [", seq_printf(m, "RSSI: %d dBm (raw=%d, prev=%d) [",
RTW89_RSSI_RAW_TO_DBM(rssi), rssi, rtwsta->prev_rssi); RTW89_RSSI_RAW_TO_DBM(rssi), rssi, rtwsta->prev_rssi);
for (i = 0; i < rtwdev->chip->rf_path_num; i++) { for (i = 0; i < ant_num; i++) {
rssi = ewma_rssi_read(&rtwsta->rssi[i]); rssi = ewma_rssi_read(&rtwsta->rssi[i]);
seq_printf(m, "%d%s%s", RTW89_RSSI_RAW_TO_DBM(rssi), seq_printf(m, "%d%s%s", RTW89_RSSI_RAW_TO_DBM(rssi),
hal->tx_path_diversity && (hal->antenna_tx & BIT(i)) ? "*" : "", ant_asterisk && (hal->antenna_tx & BIT(i)) ? "*" : "",
i + 1 == rtwdev->chip->rf_path_num ? "" : ", "); i + 1 == ant_num ? "" : ", ");
} }
seq_puts(m, "]\n"); seq_puts(m, "]\n");
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment