Skip to content

Commit f0c3bb7

Browse files
Sowmiya Sree Elavalaganjeff-t-johnson
authored andcommitted
wifi: ath12k: Add Support to Parse TPC Event from Firmware
Host receives four Transmit Power Control(TPC) events from firmware on sending TPC request. Fixed param TLV is present as part of all event to indicate the event count and end of event. TPC config parameters along with regulatory power array comes as first event. Rates array comes as second and third event as it cannot be packed in single event. Conformance Test Limit (CTL) power array comes as the fourth event. Firmware packs different sets of array params which includes array length and type inside master TLV as different subtlvs. And the actual content of array is packed one after the other inside a separate TLV as single buffer. Parse various events and save it in local structures. Create tpc_stats file using debugfs to store these local structures. Create function to handle TPC stats read to relay the information to the user. Command usage: cat > /sys/kernel/debug/ath12k/pci-0000\:06\:00.0/mac0/tpc_stats Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.1.1-00214-QCAHKSWPL_SILICONZ-1 Signed-off-by: Sowmiya Sree Elavalagan <quic_ssreeela@quicinc.com> Co-developed-by: Ramya Gnanasekar <quic_rgnanase@quicinc.com> Signed-off-by: Ramya Gnanasekar <quic_rgnanase@quicinc.com> Co-developed-by: Roopni Devanathan <quic_rdevanat@quicinc.com> Signed-off-by: Roopni Devanathan <quic_rdevanat@quicinc.com> Reviewed-by: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com> Link: https://patch.msgid.link/20250130061104.962124-2-quic_rdevanat@quicinc.com Signed-off-by: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
1 parent 7a3e8ee commit f0c3bb7

File tree

5 files changed

+696
-0
lines changed

5 files changed

+696
-0
lines changed

drivers/net/wireless/ath/ath12k/core.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,10 @@ struct ath12k_debug {
575575
struct dentry *debugfs_pdev;
576576
struct dentry *debugfs_pdev_symlink;
577577
struct ath12k_dbg_htt_stats htt_stats;
578+
enum wmi_halphy_ctrl_path_stats_id tpc_stats_type;
579+
bool tpc_request;
580+
struct completion tpc_complete;
581+
struct wmi_tpc_stats_arg *tpc_stats;
578582
};
579583

580584
struct ath12k_per_peer_tx_stats {

drivers/net/wireless/ath/ath12k/debugfs.c

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,99 @@ static const struct file_operations fops_simulate_radar = {
3232
.open = simple_open
3333
};
3434

35+
static int ath12k_debug_tpc_stats_request(struct ath12k *ar)
36+
{
37+
enum wmi_halphy_ctrl_path_stats_id tpc_stats_sub_id;
38+
struct ath12k_base *ab = ar->ab;
39+
int ret;
40+
41+
lockdep_assert_wiphy(ath12k_ar_to_hw(ar)->wiphy);
42+
43+
reinit_completion(&ar->debug.tpc_complete);
44+
45+
spin_lock_bh(&ar->data_lock);
46+
ar->debug.tpc_request = true;
47+
tpc_stats_sub_id = ar->debug.tpc_stats_type;
48+
spin_unlock_bh(&ar->data_lock);
49+
50+
ret = ath12k_wmi_send_tpc_stats_request(ar, tpc_stats_sub_id);
51+
if (ret) {
52+
ath12k_warn(ab, "failed to request pdev tpc stats: %d\n", ret);
53+
spin_lock_bh(&ar->data_lock);
54+
ar->debug.tpc_request = false;
55+
spin_unlock_bh(&ar->data_lock);
56+
return ret;
57+
}
58+
59+
return 0;
60+
}
61+
62+
static int ath12k_open_tpc_stats(struct inode *inode, struct file *file)
63+
{
64+
struct ath12k *ar = inode->i_private;
65+
struct ath12k_hw *ah = ath12k_ar_to_ah(ar);
66+
int ret;
67+
68+
guard(wiphy)(ath12k_ar_to_hw(ar)->wiphy);
69+
70+
if (ah->state != ATH12K_HW_STATE_ON) {
71+
ath12k_warn(ar->ab, "Interface not up\n");
72+
return -ENETDOWN;
73+
}
74+
75+
void *buf __free(kfree) = kzalloc(ATH12K_TPC_STATS_BUF_SIZE, GFP_KERNEL);
76+
if (!buf)
77+
return -ENOMEM;
78+
79+
ret = ath12k_debug_tpc_stats_request(ar);
80+
if (ret) {
81+
ath12k_warn(ar->ab, "failed to request tpc stats: %d\n",
82+
ret);
83+
return ret;
84+
}
85+
86+
if (!wait_for_completion_timeout(&ar->debug.tpc_complete, TPC_STATS_WAIT_TIME)) {
87+
spin_lock_bh(&ar->data_lock);
88+
ath12k_wmi_free_tpc_stats_mem(ar);
89+
ar->debug.tpc_request = false;
90+
spin_unlock_bh(&ar->data_lock);
91+
return -ETIMEDOUT;
92+
}
93+
94+
file->private_data = no_free_ptr(buf);
95+
96+
spin_lock_bh(&ar->data_lock);
97+
ath12k_wmi_free_tpc_stats_mem(ar);
98+
spin_unlock_bh(&ar->data_lock);
99+
100+
return 0;
101+
}
102+
103+
static ssize_t ath12k_read_tpc_stats(struct file *file,
104+
char __user *user_buf,
105+
size_t count, loff_t *ppos)
106+
{
107+
const char *buf = file->private_data;
108+
size_t len = strlen(buf);
109+
110+
return simple_read_from_buffer(user_buf, count, ppos, buf, len);
111+
}
112+
113+
static int ath12k_release_tpc_stats(struct inode *inode,
114+
struct file *file)
115+
{
116+
kfree(file->private_data);
117+
return 0;
118+
}
119+
120+
static const struct file_operations fops_tpc_stats = {
121+
.open = ath12k_open_tpc_stats,
122+
.release = ath12k_release_tpc_stats,
123+
.read = ath12k_read_tpc_stats,
124+
.owner = THIS_MODULE,
125+
.llseek = default_llseek,
126+
};
127+
35128
void ath12k_debugfs_soc_create(struct ath12k_base *ab)
36129
{
37130
bool dput_needed;
@@ -468,6 +561,9 @@ void ath12k_debugfs_register(struct ath12k *ar)
468561
&fops_simulate_radar);
469562
}
470563

564+
debugfs_create_file("tpc_stats", 0400, ar->debug.debugfs_pdev, ar,
565+
&fops_tpc_stats);
566+
471567
ath12k_debugfs_htt_stats_register(ar);
472568
ath12k_debugfs_fw_stats_register(ar);
473569
}

drivers/net/wireless/ath/ath12k/debugfs.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ void ath12k_debugfs_unregister(struct ath12k *ar);
1515
void ath12k_debugfs_fw_stats_process(struct ath12k *ar,
1616
struct ath12k_fw_stats *stats);
1717
void ath12k_debugfs_fw_stats_reset(struct ath12k *ar);
18+
19+
#define TPC_STATS_WAIT_TIME (1 * HZ)
20+
#define TPC_STATS_TOT_ROW 700
21+
#define TPC_STATS_TOT_COLUMN 100
22+
#define ATH12K_TPC_STATS_BUF_SIZE (TPC_STATS_TOT_ROW * TPC_STATS_TOT_COLUMN)
23+
1824
#else
1925
static inline void ath12k_debugfs_soc_create(struct ath12k_base *ab)
2026
{

0 commit comments

Comments
 (0)