From 6a6183457cd8a46df13872c875ddb4de99bfb239 Mon Sep 17 00:00:00 2001
From: Venkateswara Rao Naralasetty <vnaralas@codeaurora.org>
Date: Tue, 27 Oct 2020 15:11:26 +0530
Subject: [PATCH] ath11k: add htt stats support for new stats

This change is to add htt stats supports for,

29-ATH11K_DBG_HTT_EXT_STATS_PEER_CTRL_PATH_TXRX_STATS:
Used to dump the control path txrx stats for each connected peer.
Usage: echo 29 > /sys/kernel/debug/ieee80211/phyx/ath11k/htt_stats_type
       cat /sys/kernel/debug/ieee80211/phyx/netdev\:wlan0/stations/<sta mac>/htt_peer_stats.

31-ATH11K_DBG_HTT_EXT_STATS_PDEV_TX_RATE_TXBF_STATS:
Used to dump the per pdev tx rate txbf stats.
Usage: echo 31 > /sys/kernel/debug/ieee80211/phyx/ath11k/htt_stats_type
       cat /sys/kernel/debug/ieee80211/phyx/ath11k/htt_stats

32-ATH11k_DBG_HTT_EXT_STATS_TXBF_OFDMA:
Used to dump the TXBF ofdma stats for all ofdma users.
Usage: echo 32 > /sys/kernel/debug/ieee80211/phyx/ath11k/htt_stats_type
       cat /sys/kernel/debug/ieee80211/phyx/ath11k/htt_stats

37-ATH11K_DBG_HTT_EXT_PHY_COUNTERS_AND_PHY_STATS:
Used to dump the mac and phy txrx counts and phy stats like per chain rssi
and ANI level.
Usage: echo 37 > /sys/kernel/debug/ieee80211/phyx/ath11k/htt_stats_type
       cat /sys/kernel/debug/ieee80211/phyx/ath11k/htt_stats

Signed-off-by: Venkateswara Rao Naralasetty <vnaralas@codeaurora.org>
---
 drivers/net/wireless/ath/ath11k/debugfs.h           |   3 +
 drivers/net/wireless/ath/ath11k/debugfs_htt_stats.c | 382 +++++++++++++++++++++-
 drivers/net/wireless/ath/ath11k/debugfs_htt_stats.h |  89 +++++
 drivers/net/wireless/ath/ath11k/debugfs_sta.c     |   8 +-
 4 files changed, 478 insertions(+), 4 deletions(-)

--- a/drivers/net/wireless/ath/ath11k/debugfs.h
+++ b/drivers/net/wireless/ath/ath11k/debugfs.h
@@ -44,6 +44,9 @@ enum ath11k_dbg_htt_ext_stats_type {
 	ATH11K_DBG_HTT_EXT_STATS_FSE_RX                     =  28,
 	ATH11K_DBG_HTT_EXT_STATS_PEER_CTRL_PATH_TXRX_STATS  =  29,
 	ATH11K_DBG_HTT_EXT_STATS_PDEV_RX_RATE_EXT           =  30,
+	ATH11K_DBG_HTT_EXT_STATS_PDEV_TX_RATE_TXBF_STATS    =  31,
+	ATH11k_DBG_HTT_EXT_STATS_TXBF_OFDMA		    =  32,
+	ATH11K_DBG_HTT_EXT_PHY_COUNTERS_AND_PHY_STATS	    =  37,
 
 	/* keep this last */
 	ATH11K_DBG_HTT_NUM_EXT_STATS,
--- a/drivers/net/wireless/ath/ath11k/debugfs_htt_stats.c
+++ b/drivers/net/wireless/ath/ath11k/debugfs_htt_stats.c
@@ -4229,6 +4229,348 @@ static inline void htt_print_rx_pdev_rat
 	stats_req->buf_len = len;
 }
 
+static inline void htt_print_pdev_tx_rate_txbf_stats_tlv(const void *tag_buf,
+							 struct debug_htt_stats_req *stats_req)
+{
+	const struct htt_pdev_txrate_txbf_stats_tlv *htt_stats_buf = tag_buf;
+	u8 *buf = stats_req->buf;
+	u32 len = stats_req->buf_len;
+	u32 buf_len = ATH11K_HTT_STATS_BUF_SIZE;
+	int i;
+
+	len += HTT_DBG_OUT(buf + len, buf_len - len, "HTT_STATS_PDEV_TX_RATE_TXBF_STATS:\n");
+	len += HTT_DBG_OUT(buf + len, buf_len - len, "tx_ol_mcs = ");
+	for (i = 0; i < HTT_TX_TXBF_RATE_STATS_NUM_MCS_COUNTERS; i++)
+		len += HTT_DBG_OUT(buf + len, buf_len - len,
+				   "%d:%u,", i, htt_stats_buf->tx_su_ol_mcs[i]);
+
+	len += HTT_DBG_OUT(buf + len, buf_len - len, "\ntx_ibf_mcs = ");
+	for (i = 0; i < HTT_TX_TXBF_RATE_STATS_NUM_MCS_COUNTERS; i++)
+		len += HTT_DBG_OUT(buf + len, buf_len - len,
+				   "%d:%u,", i, htt_stats_buf->tx_su_ibf_mcs[i]);
+
+	len += HTT_DBG_OUT(buf + len, buf_len - len, "\ntx_txbf_mcs =");
+	for (i = 0; i < HTT_TX_TXBF_RATE_STATS_NUM_MCS_COUNTERS; i++)
+		len += HTT_DBG_OUT(buf + len, buf_len - len,
+				   "%d:%u,", i, htt_stats_buf->tx_su_txbf_mcs[i]);
+
+	len += HTT_DBG_OUT(buf + len, buf_len - len, "\ntx_ol_nss = ");
+	for (i = 0; i < HTT_TX_PDEV_STATS_NUM_SPATIAL_STREAMS; i++)
+		len += HTT_DBG_OUT(buf + len, buf_len - len,
+				   "%d:%u,", i, htt_stats_buf->tx_su_ol_nss[i]);
+
+	len += HTT_DBG_OUT(buf + len, buf_len - len, "\ntx_ibf_nss = ");
+	for (i = 0; i < HTT_TX_PDEV_STATS_NUM_SPATIAL_STREAMS; i++)
+		len += HTT_DBG_OUT(buf + len, buf_len - len,
+				   "%d:%u,", i, htt_stats_buf->tx_su_ibf_nss[i]);
+
+	len += HTT_DBG_OUT(buf + len, buf_len - len, "\ntx_txbf_nss = ");
+	for (i = 0; i < HTT_TX_PDEV_STATS_NUM_SPATIAL_STREAMS; i++)
+		len += HTT_DBG_OUT(buf + len, buf_len - len,
+				   "%d:%u,", i, htt_stats_buf->tx_su_txbf_nss[i]);
+
+	len += HTT_DBG_OUT(buf + len, buf_len - len, "\ntx_ol_bw = ");
+	for (i = 0; i < HTT_TX_TXBF_RATE_STATS_NUM_BW_COUNTERS; i++)
+		len += HTT_DBG_OUT(buf + len, buf_len - len,
+				   "%d:%u,", i, htt_stats_buf->tx_su_ol_bw[i]);
+
+	len += HTT_DBG_OUT(buf + len, buf_len - len, "\ntx_ibf_bw = ");
+	for (i = 0; i < HTT_TX_TXBF_RATE_STATS_NUM_BW_COUNTERS; i++)
+		len += HTT_DBG_OUT(buf + len, buf_len - len,
+				   "%d:%u,", i, htt_stats_buf->tx_su_ibf_bw[i]);
+
+	len += HTT_DBG_OUT(buf + len, buf_len - len, "\ntx_txbf_bw = ");
+	for (i = 0; i < HTT_TX_TXBF_RATE_STATS_NUM_BW_COUNTERS; i++)
+		len += HTT_DBG_OUT(buf + len, buf_len - len,
+				   "%d:%u,", i, htt_stats_buf->tx_su_txbf_bw[i]);
+
+	len += HTT_DBG_OUT(buf + len, buf_len - len, "\n");
+
+	if (len >= buf_len)
+		buf[buf_len - 1] = 0;
+	else
+		buf[len] = 0;
+
+	stats_req->buf_len = len;
+}
+
+static inline void htt_print_txbf_ofdma_ndpa_stats_tlv(const void *tag_buf,
+						       struct debug_htt_stats_req *stats_req)
+{
+	const struct htt_txbf_ofdma_ndpa_stats_tlv *htt_stats_buf = tag_buf;
+        u8 *buf = stats_req->buf;
+        u32 len = stats_req->buf_len;
+        u32 buf_len = ATH11K_HTT_STATS_BUF_SIZE;
+        int i;
+
+	len += HTT_DBG_OUT(buf + len, buf_len - len, "HTT_TXBF_OFDMA_NDPA_STATS_TLV:\n");
+	for (i = 0; i < HTT_TX_PDEV_STATS_NUM_OFDMA_USER_STATS; i++) {
+		len += HTT_DBG_OUT(buf + len, buf_len - len,
+				   "ax_ofdma_ndpa_queued_user%d = %u\n",
+				   i, htt_stats_buf->ax_ofdma_ndpa_queued[i]);
+		len += HTT_DBG_OUT(buf + len, buf_len - len,
+				   "ax_ofdma_ndpa_tried_user%d = %u\n",
+				   i, htt_stats_buf->ax_ofdma_ndpa_tried[i]);
+		len += HTT_DBG_OUT(buf + len, buf_len - len,
+				   "ax_ofdma_ndpa_flushed_user%d = %u\n",
+				   i, htt_stats_buf->ax_ofdma_ndpa_flushed[i]);
+		len += HTT_DBG_OUT(buf + len, buf_len - len,
+				   "ax_ofdma_ndpa_err_user%d = %u\n",
+				   i, htt_stats_buf->ax_ofdma_ndpa_err[i]);
+		len += HTT_DBG_OUT(buf + len, buf_len - len, "\n");
+	}
+
+	if (len >= buf_len)
+		buf[buf_len - 1] = 0;
+	else
+		buf[len] = 0;
+
+	stats_req->buf_len = len;
+}
+
+static inline void htt_print_txbf_ofdma_ndp_stats_tlv(const void *tag_buf,
+						      struct debug_htt_stats_req *stats_req)
+{
+	const struct htt_txbf_ofdma_ndp_stats_tlv *htt_stats_buf = tag_buf;
+	u8 *buf = stats_req->buf;
+	u32 len = stats_req->buf_len;
+	u32 buf_len = ATH11K_HTT_STATS_BUF_SIZE;
+	int i;
+
+	len += HTT_DBG_OUT(buf + len, buf_len - len, "HTT_TXBF_OFDMA_NDP_STATS_TLV:\n");
+	for (i = 0; i < HTT_TX_PDEV_STATS_NUM_OFDMA_USER_STATS; i++) {
+		len += HTT_DBG_OUT(buf + len, buf_len - len,
+				   "ax_ofdma_ndp_queued_user%d = %u\n",
+				   i, htt_stats_buf->ax_ofdma_ndp_queued[i]);
+		len += HTT_DBG_OUT(buf + len, buf_len - len,
+				   "ax_ofdma_ndp_tried_user%d = %u\n",
+				   i, htt_stats_buf->ax_ofdma_ndp_tried[i]);
+		len += HTT_DBG_OUT(buf + len, buf_len - len,
+				   "ax_ofdma_ndp_flushed_user%d = %u\n",
+				   i, htt_stats_buf->ax_ofdma_ndp_flushed[i]);
+		len += HTT_DBG_OUT(buf + len, buf_len - len,
+				   "ax_ofdma_ndp_err_user%d = %u\n",
+				   i, htt_stats_buf->ax_ofdma_ndp_err[i]);
+		len += HTT_DBG_OUT(buf + len, buf_len - len, "\n");
+	}
+
+	if (len >= buf_len)
+		buf[buf_len - 1] = 0;
+	else
+		buf[len] = 0;
+
+	stats_req->buf_len = len;
+}
+
+static inline void htt_print_txbf_ofdma_brp_stats_tlv(const void *tag_buf,
+						      struct debug_htt_stats_req *stats_req)
+{
+	const struct htt_txbf_ofdma_brp_stats_tlv *htt_stats_buf = tag_buf;
+	u8 *buf = stats_req->buf;
+	u32 len = stats_req->buf_len;
+	u32 buf_len = ATH11K_HTT_STATS_BUF_SIZE;
+	int i;
+
+	len += HTT_DBG_OUT(buf + len, buf_len - len, "HTT_TXBF_OFDMA_BRP_STATS_TLV:\n");
+	for (i = 0; i < HTT_TX_PDEV_STATS_NUM_OFDMA_USER_STATS; i++) {
+		len += HTT_DBG_OUT(buf + len, buf_len - len,
+				   "ax_ofdma_brpoll_queued_user%d = %u\n",
+				   i, htt_stats_buf->ax_ofdma_brpoll_queued[i]);
+		len += HTT_DBG_OUT(buf + len, buf_len - len,
+				   "ax_ofdma_brpoll_tried_user%d = %u\n",
+				   i, htt_stats_buf->ax_ofdma_brpoll_tried[i]);
+		len += HTT_DBG_OUT(buf + len, buf_len - len,
+				   "ax_ofdma_brpoll_flushed_user%d = %u\n",
+				   i, htt_stats_buf->ax_ofdma_brpoll_flushed[i]);
+		len += HTT_DBG_OUT(buf + len, buf_len - len,
+				   "ax_ofdma_brp_err_user%d = %u\n",
+				   i, htt_stats_buf->ax_ofdma_brp_err[i]);
+		len += HTT_DBG_OUT(buf + len, buf_len - len,
+				   "ax_ofdma_brp_err_num_cbf_rcvd_user%d = %u\n",
+				   i, htt_stats_buf->ax_ofdma_brp_err_num_cbf_rcvd[i]);
+		len += HTT_DBG_OUT(buf + len, buf_len - len, "\n");
+	}
+
+	if (len >= buf_len)
+		buf[buf_len - 1] = 0;
+	else
+		buf[len] = 0;
+
+	stats_req->buf_len = len;
+}
+
+static inline void htt_print_txbf_ofdma_steer_stats_tlv(const void *tag_buf,
+							struct debug_htt_stats_req *stats_req)
+{
+	const struct htt_txbf_ofdma_steer_stats_tlv *htt_stats_buf = tag_buf;
+	u8 *buf = stats_req->buf;
+	u32 len = stats_req->buf_len;
+	u32 buf_len = ATH11K_HTT_STATS_BUF_SIZE;
+	int i;
+
+	len += HTT_DBG_OUT(buf + len, buf_len - len, "HTT_TXBF_OFDMA_STEER_STATS_TLV:\n");
+	for (i = 0; i < HTT_TX_PDEV_STATS_NUM_OFDMA_USER_STATS; i++) {
+		len += HTT_DBG_OUT(buf + len, buf_len - len,
+				   "ax_ofdma_num_ppdu_steer_user%d = %u\n",
+				   i, htt_stats_buf->ax_ofdma_num_ppdu_steer[i]);
+		len += HTT_DBG_OUT(buf + len, buf_len - len,
+				   "ax_ofdma_num_ppdu_ol_user%d = %u\n",
+				   i, htt_stats_buf->ax_ofdma_num_ppdu_ol[i]);
+		len += HTT_DBG_OUT(buf + len, buf_len - len,
+				   "ax_ofdma_num_usrs_prefetch_user%d = %u\n",
+				   i, htt_stats_buf->ax_ofdma_num_usrs_prefetch[i]);
+		len += HTT_DBG_OUT(buf + len, buf_len - len,
+				   "ax_ofdma_num_usrs_sound_user%d = %u\n",
+				   i, htt_stats_buf->ax_ofdma_num_usrs_sound[i]);
+		len += HTT_DBG_OUT(buf + len, buf_len - len,
+				   "ax_ofdma_num_usrs_force_sound_user%d = %u\n",
+				   i, htt_stats_buf->ax_ofdma_num_usrs_force_sound[i]);
+		len += HTT_DBG_OUT(buf + len, buf_len - len, "\n");
+	}
+
+	if (len >= buf_len)
+		buf[buf_len - 1] = 0;
+	else
+		buf[len] = 0;
+
+	stats_req->buf_len = len;
+
+}
+
+static inline void htt_print_phy_counters_tlv(const void *tag_buf,
+					      struct debug_htt_stats_req *stats_req)
+{
+	const struct htt_phy_counters_tlv *htt_stats_buf = tag_buf;
+	u8 *buf = stats_req->buf;
+	u32 len = stats_req->buf_len;
+	u32 buf_len = ATH11K_HTT_STATS_BUF_SIZE;
+	int i;
+
+	len += HTT_DBG_OUT(buf + len, buf_len - len, "HTT_PHY_COUNTERS_TLV:\n");
+	len += HTT_DBG_OUT(buf + len, buf_len - len, "rx_ofdma_timing_err_cnt = %u\n",
+			   htt_stats_buf->rx_ofdma_timing_err_cnt);
+	len += HTT_DBG_OUT(buf + len, buf_len - len, "rx_cck_fail_cnt = %u\n",
+			   htt_stats_buf->rx_cck_fail_cnt);
+	len += HTT_DBG_OUT(buf + len, buf_len - len, "mactx_abort_cnt = %u\n",
+			   htt_stats_buf->mactx_abort_cnt);
+	len += HTT_DBG_OUT(buf + len, buf_len - len, "macrx_abort_cnt = %u\n",
+			   htt_stats_buf->macrx_abort_cnt);
+	len += HTT_DBG_OUT(buf + len, buf_len - len, "phytx_abort_cnt = %u\n",
+			   htt_stats_buf->phytx_abort_cnt);
+	len += HTT_DBG_OUT(buf + len, buf_len - len, "phyrx_abort_cnt = %u\n",
+			   htt_stats_buf->phyrx_abort_cnt);
+	len += HTT_DBG_OUT(buf + len, buf_len - len, "phyrx_defer_abort_cnt = %u\n",
+			   htt_stats_buf->phyrx_defer_abort_cnt);
+	len += HTT_DBG_OUT(buf + len, buf_len - len, "rx_gain_adj_lstf_event_cnt = %u\n",
+			   htt_stats_buf->rx_gain_adj_lstf_event_cnt);
+	len += HTT_DBG_OUT(buf + len, buf_len - len, "rx_gain_adj_non_legacy_cnt = %u\n",
+			   htt_stats_buf->rx_gain_adj_non_legacy_cnt);
+
+	for (i = 0; i < HTT_MAX_RX_PKT_CNT; i++)
+		len += HTT_DBG_OUT(buf + len, buf_len - len, "rx_pkt_cnt[%d] = %u\n",
+				   i, htt_stats_buf->rx_pkt_cnt[i]);
+
+	for (i = 0; i < HTT_MAX_RX_PKT_CRC_PASS_CNT; i++)
+		len += HTT_DBG_OUT(buf + len, buf_len - len,
+				   "rx_pkt_crc_pass_cnt[%d] = %u\n",
+				   i, htt_stats_buf->rx_pkt_crc_pass_cnt[i]);
+
+	for (i = 0; i < HTT_MAX_PER_BLK_ERR_CNT; i++)
+		len += HTT_DBG_OUT(buf + len, buf_len - len,
+				   "per_blk_err_cnt[%d] = %u\n",
+				   i, htt_stats_buf->per_blk_err_cnt[i]);
+
+	for (i = 0; i < HTT_MAX_RX_OTA_ERR_CNT; i++)
+		len += HTT_DBG_OUT(buf + len, buf_len - len,
+				   "rx_ota_err_cnt[%d] = %u\n",
+				   i, htt_stats_buf->rx_ota_err_cnt[i]);
+
+	len += HTT_DBG_OUT(buf + len, buf_len - len,
+			   "=================================================\n");
+
+	if (len >= buf_len)
+		buf[buf_len - 1] = 0;
+	else
+		buf[len] = 0;
+
+	stats_req->buf_len = len;
+}
+
+static inline void htt_print_phy_stats_tlv(const void *tag_buf,
+					   struct debug_htt_stats_req *stats_req)
+{
+	const struct htt_phy_stats_tlv *htt_stats_buf = tag_buf;
+	u8 *buf = stats_req->buf;
+	u32 len = stats_req->buf_len;
+	u32 buf_len = ATH11K_HTT_STATS_BUF_SIZE;
+	int i;
+
+	len += HTT_DBG_OUT(buf + len, buf_len - len, "HTT_PHY_STATS_TLV:\n");
+	for (i = 0; i < HTT_STATS_MAX_CHAINS; i++)
+		len += HTT_DBG_OUT(buf + len, buf_len - len, "nf_chain[%d] = %d\n",
+				   i, htt_stats_buf->nf_chain[i]);
+
+	len += HTT_DBG_OUT(buf + len, buf_len - len, "false_radar_cnt = %u\n",
+			   htt_stats_buf->false_radar_cnt);
+	len += HTT_DBG_OUT(buf + len, buf_len - len, "radar_cs_cnt = %u\n",
+			   htt_stats_buf->radar_cs_cnt);
+	len += HTT_DBG_OUT(buf + len, buf_len - len, "ani_level = %d\n",
+			   htt_stats_buf->ani_level);
+	len += HTT_DBG_OUT(buf + len, buf_len - len, "fw_run_time = %u\n",
+			   htt_stats_buf->fw_run_time);
+
+	if (len >= buf_len)
+		buf[buf_len - 1] = 0;
+	else
+		buf[len] = 0;
+
+	stats_req->buf_len = len;
+}
+
+static inline void htt_print_peer_ctrl_path_txrx_stats_tlv(const void *tag_buf,
+							   struct debug_htt_stats_req *stats_req)
+{
+	const struct htt_peer_ctrl_path_txrx_stats_tlv *htt_stat_buf = tag_buf;
+	u8 *buf = stats_req->buf;
+	u32 len = stats_req->buf_len;
+	u32 buf_len = ATH11K_HTT_STATS_BUF_SIZE;
+	int i;
+	const char *mgmt_frm_type[ATH11K_STATS_MGMT_FRM_TYPE_MAX-1] = {"assoc_req", "assoc_resp",
+								       "reassoc_req", "reassoc_resp",
+								       "probe_req", "probe_resp",
+								       "timing_advertisement", "reserved",
+								       "beacon", "atim", "disassoc",
+								       "auth", "deauth", "action", "action_no_ack"};
+
+
+	len += HTT_DBG_OUT(buf + len, buf_len - len, "HTT_STATS_PEER_CTRL_PATH_TXRX_STATS_TAG:\n");
+	len += HTT_DBG_OUT(buf + len, buf_len - len, "peer_mac_addr = %02x:%02x:%02x:%02x:%02x:%02x\n",
+			   htt_stat_buf->peer_mac_addr[0], htt_stat_buf->peer_mac_addr[1],
+			   htt_stat_buf->peer_mac_addr[2], htt_stat_buf->peer_mac_addr[3],
+			   htt_stat_buf->peer_mac_addr[4], htt_stat_buf->peer_mac_addr[5]);
+
+	len += HTT_DBG_OUT(buf + len, buf_len - len, "peer_tx_mgmt_subtype:\n");
+	for (i = 0; i < ATH11K_STATS_MGMT_FRM_TYPE_MAX-1; i++)
+		len += HTT_DBG_OUT(buf + len, buf_len - len, "%s:%u\n",
+				   mgmt_frm_type[i],
+				   htt_stat_buf->peer_rx_mgmt_subtype[i]);
+
+	len += HTT_DBG_OUT(buf + len, buf_len - len, "peer_rx_mgmt_subtype:\n");
+	for (i = 0; i < ATH11K_STATS_MGMT_FRM_TYPE_MAX-1; i++)
+		len += HTT_DBG_OUT(buf + len, buf_len - len, "%s:%u\n",
+				   mgmt_frm_type[i],
+				   htt_stat_buf->peer_rx_mgmt_subtype[i]);
+
+	len += HTT_DBG_OUT(buf + len, buf_len - len,"\n");
+
+	if (len >= buf_len)
+		buf[buf_len - 1] = 0;
+	else
+		buf[len] = 0;
+
+	stats_req->buf_len = len;
+}
+
 static int ath11k_dbg_htt_ext_stats_parse(struct ath11k_base *ab,
 					  u16 tag, u16 len, const void *tag_buf,
 					  void *user_data)
@@ -4607,6 +4949,30 @@ static int ath11k_dbg_htt_ext_stats_pars
 	case HTT_STATS_RX_PDEV_RATE_EXT_STATS_TAG:
 		htt_print_rx_pdev_rate_ext_stats_tlv(tag_buf, stats_req);
 		break;
+	case HTT_STATS_PDEV_TX_RATE_TXBF_STATS_TAG:
+		htt_print_pdev_tx_rate_txbf_stats_tlv(tag_buf, stats_req);
+		break;
+	case HTT_STATS_TXBF_OFDMA_NDPA_STATS_TAG:
+		htt_print_txbf_ofdma_ndpa_stats_tlv(tag_buf, stats_req);
+		break;
+	case HTT_STATS_TXBF_OFDMA_NDP_STATS_TAG:
+		htt_print_txbf_ofdma_ndp_stats_tlv(tag_buf, stats_req);
+		break;
+	case HTT_STATS_TXBF_OFDMA_BRP_STATS_TAG:
+		htt_print_txbf_ofdma_brp_stats_tlv(tag_buf, stats_req);
+		break;
+	case HTT_STATS_TXBF_OFDMA_STEER_STATS_TAG:
+		htt_print_txbf_ofdma_steer_stats_tlv(tag_buf, stats_req);
+		break;
+	case HTT_STATS_PHY_COUNTERS_TAG:
+		htt_print_phy_counters_tlv(tag_buf, stats_req);
+		break;
+	case HTT_STATS_PHY_STATS_TAG:
+		htt_print_phy_stats_tlv(tag_buf, stats_req);
+		break;
+	case HTT_STATS_PEER_CTRL_PATH_TXRX_STATS_TAG:
+		htt_print_peer_ctrl_path_txrx_stats_tlv(tag_buf, stats_req);
+		break;
 	default:
 		break;
 	}
@@ -4694,8 +5060,7 @@ static ssize_t ath11k_write_htt_stats_ty
 	if (type >= ATH11K_DBG_HTT_NUM_EXT_STATS)
 		return -E2BIG;
 
-	if (type == ATH11K_DBG_HTT_EXT_STATS_RESET ||
-	    type == ATH11K_DBG_HTT_EXT_STATS_PEER_INFO)
+	if (type == ATH11K_DBG_HTT_EXT_STATS_RESET)
 		return -EPERM;
 
 	ar->debug.htt_stats.type = type;
@@ -4756,6 +5121,15 @@ static int ath11k_prep_htt_stats_cfg_par
 	case ATH11K_DBG_HTT_EXT_STATS_TX_SOUNDING_INFO:
 		cfg_params->cfg0 = HTT_STAT_DEFAULT_CFG0_ACTIVE_VDEVS;
 		break;
+	case ATH11K_DBG_HTT_EXT_STATS_PEER_CTRL_PATH_TXRX_STATS:
+		cfg_params->cfg0 = HTT_STAT_PEER_INFO_MAC_ADDR;
+		cfg_params->cfg1 |= FIELD_PREP(GENMASK(7, 0), mac_addr[0]);
+		cfg_params->cfg1 |= FIELD_PREP(GENMASK(15, 8), mac_addr[1]);
+		cfg_params->cfg1 |= FIELD_PREP(GENMASK(23, 16), mac_addr[2]);
+		cfg_params->cfg1 |= FIELD_PREP(GENMASK(31, 24), mac_addr[3]);
+		cfg_params->cfg2 |= FIELD_PREP(GENMASK(7, 0), mac_addr[4]);
+		cfg_params->cfg2 |= FIELD_PREP(GENMASK(15, 8), mac_addr[5]);
+		break;
 	default:
 		break;
 	}
@@ -4813,7 +5187,9 @@ static int ath11k_open_htt_stats(struct
 	u8 type = ar->debug.htt_stats.type;
 	int ret;
 
-	if (type == ATH11K_DBG_HTT_EXT_STATS_RESET)
+	if (type == ATH11K_DBG_HTT_EXT_STATS_RESET ||
+	    type == ATH11K_DBG_HTT_EXT_STATS_PEER_INFO ||
+	    type == ATH11K_DBG_HTT_EXT_STATS_PEER_CTRL_PATH_TXRX_STATS)
 		return -EPERM;
 
 	mutex_lock(&ar->conf_mutex);
--- a/drivers/net/wireless/ath/ath11k/debugfs_htt_stats.h
+++ b/drivers/net/wireless/ath/ath11k/debugfs_htt_stats.h
@@ -115,6 +115,13 @@ enum htt_tlv_tag_t {
 	HTT_STATS_PEER_CTRL_PATH_TXRX_STATS_TAG		    = 101,
 	HTT_STATS_PDEV_CTRL_PATH_TX_STATS_TAG		    = 102,
 	HTT_STATS_RX_PDEV_RATE_EXT_STATS_TAG		    = 103,
+	HTT_STATS_PDEV_TX_RATE_TXBF_STATS_TAG		    = 108,
+	HTT_STATS_TXBF_OFDMA_NDPA_STATS_TAG		    = 113,
+	HTT_STATS_TXBF_OFDMA_NDP_STATS_TAG		    = 114,
+	HTT_STATS_TXBF_OFDMA_BRP_STATS_TAG		    = 115,
+	HTT_STATS_TXBF_OFDMA_STEER_STATS_TAG		    = 116,
+	HTT_STATS_PHY_COUNTERS_TAG			    = 121,
+	HTT_STATS_PHY_STATS_TAG				    = 122,
 
 	HTT_STATS_MAX_TAG,
 };
@@ -1905,4 +1912,86 @@ struct htt_rx_pdev_rate_ext_stats_tlv {
 	u32 rx_11ax_dl_ofdma_mcs_ext[HTT_RX_PDEV_STATS_NUM_MCS_COUNTERS_EXT];
 };
 
+#define HTT_TX_TXBF_RATE_STATS_NUM_MCS_COUNTERS 14
+#define HTT_TX_TXBF_RATE_STATS_NUM_BW_COUNTERS 5
+#define HTT_TX_PDEV_STATS_NUM_SPATIAL_STREAMS 8
+
+struct htt_pdev_txrate_txbf_stats_tlv {
+	u32 tx_su_txbf_mcs[HTT_TX_TXBF_RATE_STATS_NUM_MCS_COUNTERS];
+	u32 tx_su_ibf_mcs[HTT_TX_TXBF_RATE_STATS_NUM_MCS_COUNTERS];
+	u32 tx_su_ol_mcs[HTT_TX_TXBF_RATE_STATS_NUM_MCS_COUNTERS];
+	u32 tx_su_txbf_nss[HTT_TX_PDEV_STATS_NUM_SPATIAL_STREAMS];
+	u32 tx_su_ibf_nss[HTT_TX_PDEV_STATS_NUM_SPATIAL_STREAMS];
+	u32 tx_su_ol_nss[HTT_TX_PDEV_STATS_NUM_SPATIAL_STREAMS];
+	u32 tx_su_txbf_bw[HTT_TX_TXBF_RATE_STATS_NUM_BW_COUNTERS];
+	u32 tx_su_ibf_bw[HTT_TX_TXBF_RATE_STATS_NUM_BW_COUNTERS];
+	u32 tx_su_ol_bw[HTT_TX_TXBF_RATE_STATS_NUM_BW_COUNTERS];
+};
+
+struct htt_txbf_ofdma_ndpa_stats_tlv {
+	u32 ax_ofdma_ndpa_queued[HTT_TX_PDEV_STATS_NUM_OFDMA_USER_STATS];
+	u32 ax_ofdma_ndpa_tried[HTT_TX_PDEV_STATS_NUM_OFDMA_USER_STATS];
+	u32 ax_ofdma_ndpa_flushed[HTT_TX_PDEV_STATS_NUM_OFDMA_USER_STATS];
+	u32 ax_ofdma_ndpa_err[HTT_TX_PDEV_STATS_NUM_OFDMA_USER_STATS];
+};
+
+struct htt_txbf_ofdma_ndp_stats_tlv {
+	u32 ax_ofdma_ndp_queued[HTT_TX_PDEV_STATS_NUM_OFDMA_USER_STATS];
+	u32 ax_ofdma_ndp_tried[HTT_TX_PDEV_STATS_NUM_OFDMA_USER_STATS];
+	u32 ax_ofdma_ndp_flushed[HTT_TX_PDEV_STATS_NUM_OFDMA_USER_STATS];
+	u32 ax_ofdma_ndp_err[HTT_TX_PDEV_STATS_NUM_OFDMA_USER_STATS];
+};
+
+struct htt_txbf_ofdma_brp_stats_tlv {
+	u32 ax_ofdma_brpoll_queued[HTT_TX_PDEV_STATS_NUM_OFDMA_USER_STATS];
+	u32 ax_ofdma_brpoll_tried[HTT_TX_PDEV_STATS_NUM_OFDMA_USER_STATS];
+	u32 ax_ofdma_brpoll_flushed[HTT_TX_PDEV_STATS_NUM_OFDMA_USER_STATS];
+	u32 ax_ofdma_brp_err[HTT_TX_PDEV_STATS_NUM_OFDMA_USER_STATS];
+	u32 ax_ofdma_brp_err_num_cbf_rcvd[HTT_TX_PDEV_STATS_NUM_OFDMA_USER_STATS+1];
+};
+
+struct htt_txbf_ofdma_steer_stats_tlv {
+	u32 ax_ofdma_num_ppdu_steer[HTT_TX_PDEV_STATS_NUM_OFDMA_USER_STATS];
+	u32 ax_ofdma_num_ppdu_ol[HTT_TX_PDEV_STATS_NUM_OFDMA_USER_STATS];
+	u32 ax_ofdma_num_usrs_prefetch[HTT_TX_PDEV_STATS_NUM_OFDMA_USER_STATS];
+	u32 ax_ofdma_num_usrs_sound[HTT_TX_PDEV_STATS_NUM_OFDMA_USER_STATS];
+	u32 ax_ofdma_num_usrs_force_sound[HTT_TX_PDEV_STATS_NUM_OFDMA_USER_STATS];
+};
+
+#define HTT_MAX_RX_PKT_CNT 8
+#define HTT_MAX_RX_PKT_CRC_PASS_CNT 8
+#define HTT_MAX_PER_BLK_ERR_CNT 20
+#define HTT_MAX_RX_OTA_ERR_CNT 14
+#define HTT_STATS_MAX_CHAINS 8
+
+struct htt_phy_counters_tlv {
+	u32 rx_ofdma_timing_err_cnt;
+	u32 rx_cck_fail_cnt;
+	u32 mactx_abort_cnt;
+	u32 macrx_abort_cnt;
+	u32 phytx_abort_cnt;
+	u32 phyrx_abort_cnt;
+	u32 phyrx_defer_abort_cnt;
+	u32 rx_gain_adj_lstf_event_cnt;
+	u32 rx_gain_adj_non_legacy_cnt;
+	u32 rx_pkt_cnt[HTT_MAX_RX_PKT_CNT];
+	u32 rx_pkt_crc_pass_cnt[HTT_MAX_RX_PKT_CRC_PASS_CNT];
+	u32 per_blk_err_cnt[HTT_MAX_PER_BLK_ERR_CNT];
+	u32 rx_ota_err_cnt[HTT_MAX_RX_OTA_ERR_CNT];
+};
+
+struct htt_phy_stats_tlv {
+	int nf_chain[HTT_STATS_MAX_CHAINS];
+	u32 false_radar_cnt;
+	u32 radar_cs_cnt;
+	int ani_level;
+	u32 fw_run_time;
+};
+
+struct htt_peer_ctrl_path_txrx_stats_tlv {
+	u8 peer_mac_addr[6];
+	u8 rsvd[2];
+	u32 peer_tx_mgmt_subtype[ATH11K_STATS_MGMT_FRM_TYPE_MAX];
+	u32 peer_rx_mgmt_subtype[ATH11K_STATS_MGMT_FRM_TYPE_MAX];
+};
 #endif
--- a/drivers/net/wireless/ath/ath11k/debugfs_sta.c
+++ b/drivers/net/wireless/ath/ath11k/debugfs_sta.c
@@ -654,15 +654,21 @@ ath11k_dbg_sta_open_htt_peer_stats(struc
 	struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
 	struct ath11k *ar = arsta->arvif->ar;
 	struct debug_htt_stats_req *stats_req;
+	int type = ar->debug.htt_stats.type;
 	int ret;
 
+	if ((type != ATH11K_DBG_HTT_EXT_STATS_PEER_INFO &&
+	    type != ATH11K_DBG_HTT_EXT_STATS_PEER_CTRL_PATH_TXRX_STATS) ||
+	    type == ATH11K_DBG_HTT_EXT_STATS_RESET)
+		return -EPERM;
+
 	stats_req = vzalloc(sizeof(*stats_req) + ATH11K_HTT_STATS_BUF_SIZE);
 	if (!stats_req)
 		return -ENOMEM;
 
 	mutex_lock(&ar->conf_mutex);
 	ar->debug.htt_stats.stats_req = stats_req;
-	stats_req->type = ATH11K_DBG_HTT_EXT_STATS_PEER_INFO;
+	stats_req->type = type;
 	memcpy(stats_req->peer_addr, sta->addr, ETH_ALEN);
 	ret = ath11k_debugfs_htt_stats_req(ar);
 	mutex_unlock(&ar->conf_mutex);
