[PATCH ath-next v1 03/10] wifi: ath11k: request only the PPDU stats TLVs it reads
From: Julius Bairaktaris
Date: Mon Nov 23 2026 - 08:42:32 EST
The driver asks the firmware for eight PPDU stats TLVs on every PPDU, but
ath11k_htt_tlv_ppdu_stats_parse() keeps four of them: the common TLV (PPDU
airtime), the user rate TLV (rate, NSS and bandwidth of each user, which
the station rate and the airtime accounting use), the user completion
common TLV (MPDUs tried and succeeded) and the ack/BA status TLV (acked
bytes and MSDUs, TID). The user common, scheduler command status, flush
and user array TLVs are parsed by nothing, yet the firmware builds them
and the host walks them for every PPDU of every station.
Request the four the driver reads. The full pktlog, the extended TX
statistics and the monitor interface keep the default set and the lite
pktlog its own set, as before, so the mask is recomputed when any of them
is switched on or off.
Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.9.0.1-02146-QCAHKSWPL_SILICONZ-1
Signed-off-by: Julius Bairaktaris <julius@xxxxxxxxxxxxxx>
---
drivers/net/wireless/ath/ath11k/debugfs.c | 15 ++++++++--
drivers/net/wireless/ath/ath11k/debugfs.h | 10 +++++++
drivers/net/wireless/ath/ath11k/dp.h | 9 ++++++
drivers/net/wireless/ath/ath11k/dp_tx.c | 34 +++++++++++++++++++++++
drivers/net/wireless/ath/ath11k/dp_tx.h | 1 +
drivers/net/wireless/ath/ath11k/mac.c | 13 +++++++--
6 files changed, 77 insertions(+), 5 deletions(-)
diff --git a/drivers/net/wireless/ath/ath11k/debugfs.c b/drivers/net/wireless/ath/ath11k/debugfs.c
index 70922612d3fb..b936101d6fa5 100644
--- a/drivers/net/wireless/ath/ath11k/debugfs.c
+++ b/drivers/net/wireless/ath/ath11k/debugfs.c
@@ -460,7 +460,9 @@ static ssize_t ath11k_write_enable_extd_tx_stats(struct file *file,
}
ar->debug.extd_tx_stats = filter;
- ret = count;
+ ret = ath11k_dp_tx_htt_ppdu_stats_update(ar);
+ if (!ret)
+ ret = count;
out:
mutex_unlock(&ar->conf_mutex);
@@ -1010,6 +1012,13 @@ static ssize_t ath11k_write_pktlog_filter(struct file *file,
HTT_RX_FILTER_TLV_FLAGS_MPDU_START)
if (mode == ATH11K_PKTLOG_MODE_FULL) {
+ ret = ath11k_dp_tx_htt_h2t_ppdu_stats_req(ar,
+ HTT_PPDU_STATS_TAG_DEFAULT);
+ if (ret) {
+ ath11k_err(ar->ab, "failed to enable pktlog full: %d\n", ret);
+ goto out;
+ }
+
rx_filter = HTT_RX_FILTER_TLV_LITE_MODE |
HTT_RX_FILTER_TLV_FLAGS_MSDU_START |
HTT_RX_FILTER_TLV_FLAGS_MSDU_END |
@@ -1032,8 +1041,8 @@ static ssize_t ath11k_write_pktlog_filter(struct file *file,
tlv_filter = ath11k_mac_mon_status_filter_default;
rx_filter = tlv_filter.rx_filter;
- ret = ath11k_dp_tx_htt_h2t_ppdu_stats_req(ar,
- HTT_PPDU_STATS_TAG_DEFAULT);
+ ar->debug.pktlog_mode = mode;
+ ret = ath11k_dp_tx_htt_ppdu_stats_update(ar);
if (ret) {
ath11k_err(ar->ab, "failed to send htt ppdu stats req: %d\n",
ret);
diff --git a/drivers/net/wireless/ath/ath11k/debugfs.h b/drivers/net/wireless/ath/ath11k/debugfs.h
index 859071938a65..4bec01a85eae 100644
--- a/drivers/net/wireless/ath/ath11k/debugfs.h
+++ b/drivers/net/wireless/ath/ath11k/debugfs.h
@@ -279,6 +279,11 @@ static inline bool ath11k_debugfs_is_pktlog_lite_mode_enabled(struct ath11k *ar)
return (ar->debug.pktlog_mode == ATH11K_PKTLOG_MODE_LITE);
}
+static inline bool ath11k_debugfs_is_pktlog_enabled(struct ath11k *ar)
+{
+ return ar->debug.pktlog_mode;
+}
+
static inline bool ath11k_debugfs_is_pktlog_rx_stats_enabled(struct ath11k *ar)
{
return (!ar->debug.pktlog_peer_valid && ar->debug.pktlog_mode);
@@ -364,6 +369,11 @@ static inline bool ath11k_debugfs_is_pktlog_lite_mode_enabled(struct ath11k *ar)
return false;
}
+static inline bool ath11k_debugfs_is_pktlog_enabled(struct ath11k *ar)
+{
+ return false;
+}
+
static inline bool ath11k_debugfs_is_pktlog_rx_stats_enabled(struct ath11k *ar)
{
return false;
diff --git a/drivers/net/wireless/ath/ath11k/dp.h b/drivers/net/wireless/ath/ath11k/dp.h
index e6e05eb25692..5e973c337cb2 100644
--- a/drivers/net/wireless/ath/ath11k/dp.h
+++ b/drivers/net/wireless/ath/ath11k/dp.h
@@ -595,6 +595,15 @@ enum htt_ppdu_stats_tag_type {
| BIT(HTT_PPDU_STATS_TAG_USR_COMPLTN_FLUSH) \
| BIT(HTT_PPDU_STATS_TAG_USR_COMMON_ARRAY))
+/*
+ * The TLVs ath11k_htt_tlv_ppdu_stats_parse() keeps: the PPDU airtime, the
+ * rate of each user, the retry counts and the acked bytes.
+ */
+#define HTT_PPDU_STATS_TAG_USED (BIT(HTT_PPDU_STATS_TAG_COMMON) \
+ | BIT(HTT_PPDU_STATS_TAG_USR_RATE) \
+ | BIT(HTT_PPDU_STATS_TAG_USR_COMPLTN_COMMON) \
+ | BIT(HTT_PPDU_STATS_TAG_USR_COMPLTN_ACK_BA_STATUS))
+
#define HTT_PPDU_STATS_TAG_PKTLOG (BIT(HTT_PPDU_STATS_TAG_USR_MPDU_ENQ_BITMAP_64) | \
BIT(HTT_PPDU_STATS_TAG_USR_MPDU_ENQ_BITMAP_256) | \
BIT(HTT_PPDU_STATS_TAG_USR_COMPLTN_BA_BITMAP_64) | \
diff --git a/drivers/net/wireless/ath/ath11k/dp_tx.c b/drivers/net/wireless/ath/ath11k/dp_tx.c
index cac970c92806..9e21c7c3dba2 100644
--- a/drivers/net/wireless/ath/ath11k/dp_tx.c
+++ b/drivers/net/wireless/ath/ath11k/dp_tx.c
@@ -1033,6 +1033,40 @@ int ath11k_dp_tx_htt_h2t_ver_req_msg(struct ath11k_base *ab)
return 0;
}
+/*
+ * The TLVs the driver does not parse (user common, scheduler command status,
+ * flush, user array) go only to pktlog and the trace point. The pktlog lite
+ * mode asks for its own set, and the full pktlog, the monitor and the
+ * extended statistics debugfs file keep the whole default set.
+ */
+static u32 ath11k_dp_tx_htt_ppdu_stats_mask(struct ath11k *ar)
+{
+ if (ath11k_debugfs_is_pktlog_lite_mode_enabled(ar))
+ return HTT_PPDU_STATS_TAG_PKTLOG;
+
+ if (ath11k_debugfs_is_extd_tx_stats_enabled(ar) ||
+ ath11k_debugfs_is_pktlog_enabled(ar) ||
+ test_bit(ATH11K_FLAG_MONITOR_STARTED, &ar->monitor_flags))
+ return HTT_PPDU_STATS_TAG_DEFAULT;
+
+ return HTT_PPDU_STATS_TAG_USED;
+}
+
+/**
+ * ath11k_dp_tx_htt_ppdu_stats_update() - request the PPDU stats TLVs in use
+ * @ar: the radio, whose conf_mutex the caller holds
+ *
+ * Asks the firmware for the PPDU stats TLVs that the driver and the enabled
+ * debug features read, and only those.
+ *
+ * Return: 0 on success, or the error of the HTT request.
+ */
+int ath11k_dp_tx_htt_ppdu_stats_update(struct ath11k *ar)
+{
+ return ath11k_dp_tx_htt_h2t_ppdu_stats_req(ar,
+ ath11k_dp_tx_htt_ppdu_stats_mask(ar));
+}
+
int ath11k_dp_tx_htt_h2t_ppdu_stats_req(struct ath11k *ar, u32 mask)
{
struct ath11k_base *ab = ar->ab;
diff --git a/drivers/net/wireless/ath/ath11k/dp_tx.h b/drivers/net/wireless/ath/ath11k/dp_tx.h
index 9303b5ba6e01..934c9ab6acf5 100644
--- a/drivers/net/wireless/ath/ath11k/dp_tx.h
+++ b/drivers/net/wireless/ath/ath11k/dp_tx.h
@@ -29,6 +29,7 @@ int ath11k_dp_tx_send_reo_cmd(struct ath11k_base *ab, struct dp_rx_tid *rx_tid,
enum hal_reo_cmd_status));
int ath11k_dp_tx_htt_h2t_ppdu_stats_req(struct ath11k *ar, u32 mask);
+int ath11k_dp_tx_htt_ppdu_stats_update(struct ath11k *ar);
int
ath11k_dp_tx_htt_h2t_ext_stats_req(struct ath11k *ar, u8 type,
struct htt_ext_stats_cfg_params *cfg_params,
diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c
index 1a237adaa37d..79d5cf88f3b7 100644
--- a/drivers/net/wireless/ath/ath11k/mac.c
+++ b/drivers/net/wireless/ath/ath11k/mac.c
@@ -1195,6 +1195,11 @@ static int ath11k_mac_monitor_start(struct ath11k *ar)
return ret;
}
+ ret = ath11k_dp_tx_htt_ppdu_stats_update(ar);
+ if (ret)
+ ath11k_warn(ar->ab, "failed to req ppdu stats for monitor: %d\n",
+ ret);
+
ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "monitor started\n");
return 0;
@@ -1225,6 +1230,11 @@ static int ath11k_mac_monitor_stop(struct ath11k *ar)
return ret;
}
+ ret = ath11k_dp_tx_htt_ppdu_stats_update(ar);
+ if (ret)
+ ath11k_warn(ar->ab, "failed to req ppdu stats for monitor: %d\n",
+ ret);
+
ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "monitor stopped ret %d\n", ret);
return 0;
@@ -6694,8 +6704,7 @@ static int ath11k_mac_op_start(struct ieee80211_hw *hw)
goto err;
}
- ret = ath11k_dp_tx_htt_h2t_ppdu_stats_req(ar,
- HTT_PPDU_STATS_TAG_DEFAULT);
+ ret = ath11k_dp_tx_htt_ppdu_stats_update(ar);
if (ret) {
ath11k_err(ab, "failed to req ppdu stats: %d\n", ret);
goto err;
--
2.53.0