[PATCH v2 2/2] wifi: ath12k: Add support to rx retry stats

Hari Chandrakanthan
2024-03-19T13:45:34Z

Add support to count station level rx retries.
It denotes the number of data frames(MPDUs) received with rx retry bit
set.

The rx retry stats helps in understanding the medium during
UL transmission.

Tested-on: QCN9274 hw1.0 PCI WLAN.WBE.1.2.1-00148-QCAHKSWPL_SILICONZ-1

Signed-off-by: Hari Chandrakanthan <quic_haric@quicinc.com>
---
v2: Rebased the patch
---
drivers/net/wireless/ath/ath12k/core.h | 1 +
drivers/net/wireless/ath/ath12k/dp_mon.c | 8 ++++++++
drivers/net/wireless/ath/ath12k/hal_rx.h | 7 ++++++-
drivers/net/wireless/ath/ath12k/mac.c | 3 +++
4 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath12k/core.h b/drivers/net/wireless/ath/ath12k/core.h
index 97e5a0ccd233..8ffa9feb58d9 100644
--- a/drivers/net/wireless/ath/ath12k/core.h
+++ b/drivers/net/wireless/ath/ath12k/core.h
@@ -425,6 +425,7 @@ struct ath12k_sta {
struct ath12k_rx_peer_stats *rx_stats;
struct ath12k_wbm_tx_stats *wbm_tx_stats;
u32 bw_prev;
+ u32 rx_retries;
};

#define ATH12K_MIN_5G_FREQ 4150
diff --git a/drivers/net/wireless/ath/ath12k/dp_mon.c b/drivers/net/wireless/ath/ath12k/dp_mon.c
index 2d56913a75d0..eb2f156b3e82 100644
--- a/drivers/net/wireless/ath/ath12k/dp_mon.c
+++ b/drivers/net/wireless/ath/ath12k/dp_mon.c
@@ -774,9 +774,11 @@ ath12k_dp_mon_rx_parse_status_tlv(struct ath12k_base *ab,
u16 peer_id;

info[1] = __le32_to_cpu(mpdu_start->info1);
+ info[3] = __le32_to_cpu(mpdu_start->info3);
peer_id = u32_get_bits(info[1], HAL_RX_MPDU_START_INFO1_PEERID);
if (peer_id)
ppdu_info->peer_id = peer_id;
+ ppdu_info->mpdu_retry = info[3] & HAL_RX_MPDU_START_INFO3_MPDU_RETRY;

ppdu_info->mpdu_len += u32_get_bits(info[1],
HAL_RX_MPDU_START_INFO2_MPDU_LEN);
@@ -785,6 +787,9 @@ ath12k_dp_mon_rx_parse_status_tlv(struct ath12k_base *ab,
ppdu_info->userid = userid;
ppdu_info->ampdu_id[userid] =
u32_get_bits(info[0], HAL_RX_MPDU_START_INFO1_PEERID);
+ ppdu_info->userstats[userid].mpdu_retry =
+ info[3] & HAL_RX_MPDU_START_INFO3_MPDU_RETRY;
+
}

mon_mpdu = kzalloc(sizeof(*mon_mpdu), GFP_ATOMIC);
@@ -2209,6 +2214,8 @@ static void ath12k_dp_mon_rx_update_peer_su_stats(struct ath12k *ar,
struct ath12k_rx_peer_stats *rx_stats = arsta->rx_stats;
u32 num_msdu;

+ arsta->rx_retries += ppdu_info->mpdu_retry;
+
if (!rx_stats)
return;

@@ -2378,6 +2385,7 @@ ath12k_dp_mon_rx_update_user_stats(struct ath12k *ar,

arsta = ath12k_sta_to_arsta(peer->sta);
rx_stats = arsta->rx_stats;
+ arsta->rx_retries = user_stats->mpdu_retry;

if (!rx_stats)
return;
diff --git a/drivers/net/wireless/ath/ath12k/hal_rx.h b/drivers/net/wireless/ath/ath12k/hal_rx.h
index 095216eabc01..ea2b89896abd 100644
--- a/drivers/net/wireless/ath/ath12k/hal_rx.h
+++ b/drivers/net/wireless/ath/ath12k/hal_rx.h
@@ -143,6 +143,7 @@ struct hal_rx_user_status {
u32 mpdu_fcs_ok_bitmap[HAL_RX_NUM_WORDS_PER_PPDU_BITMAP];
u32 mpdu_ok_byte_count;
u32 mpdu_err_byte_count;
+ bool mpdu_retry;
};

#define HAL_MAX_UL_MU_USERS 37
@@ -230,6 +231,7 @@ struct hal_rx_mon_ppdu_info {
bool first_msdu_in_mpdu;
bool is_ampdu;
u8 medium_prot_type;
+ bool mpdu_retry;
};

#define HAL_RX_PPDU_START_INFO0_PPDU_ID GENMASK(15, 0)
@@ -447,10 +449,13 @@ struct hal_rx_phyrx_rssi_legacy_info {
#define HAL_RX_MPDU_START_INFO0_PPDU_ID GENMASK(31, 16)
#define HAL_RX_MPDU_START_INFO1_PEERID GENMASK(31, 16)
#define HAL_RX_MPDU_START_INFO2_MPDU_LEN GENMASK(13, 0)
+#define HAL_RX_MPDU_START_INFO3_MPDU_RETRY BIT(19)
struct hal_rx_mpdu_start {
__le32 info0;
__le32 info1;
- __le32 rsvd1[11];
+ __le32 rsvd1[8];
+ __le32 info3;
+ __le32 rsvd3[2];
__le32 info2;
__le32 rsvd2[9];
} __packed;
diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index 52a5fb8b03e9..f050c5079e80 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -7467,6 +7467,9 @@ static void ath12k_mac_op_sta_statistics(struct ieee80211_hw *hw,
sinfo->txrate.flags = arsta->txrate.flags;
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BITRATE);

+ sinfo->rx_retries = arsta->rx_retries;
+ sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_RETRIES);
+
/* TODO: Use real NF instead of default one. */
sinfo->signal = arsta->rssi_comb + ATH12K_DEFAULT_NOISE_FLOOR;
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL);
--
2.34.1