Skip to contentSkip to conversation

ath10k: implement debugfs interface for Transmit Power Control stats

PATCH Applied Kalle Valo 1 participant 4 messages Sep 18, 2015 – Oct 6, 2015 Qualcomm Atheros ATH10K wireless driver

lore
Share & tools
lore

Kalle Valo

author
#0 lore raw

cover ath10k: implement debugfs interface for Transmit Power Control stats

This implements a simple interface for debugging TPC stats. I did a small hack to sparse to check endian usage with signed 32 bit values.

---

Kalle Valo (1):

      ath10k: add a_sle32_to_cpu()

Maharaja Kennadyrajan (1):
ath10k: implement debugfs interface for Transmit Power Control stats

 drivers/net/wireless/ath/ath10k/core.h    |   29 +++
 drivers/net/wireless/ath/ath10k/debug.c   |  233 +++++++++++++++++++++++++
 drivers/net/wireless/ath/ath10k/debug.h   |    8 +
 drivers/net/wireless/ath/ath10k/wmi-ops.h |   19 ++
 drivers/net/wireless/ath/ath10k/wmi.c     |  269 +++++++++++++++++++++++++++++
 drivers/net/wireless/ath/ath10k/wmi.h     |   36 ++++
 6 files changed, 592 insertions(+), 2 deletions(-)
author
#1 lore raw

PATCH 1/2 ath10k: add a_sle32_to_cpu()

Copy a_sle32_to_cpu() from ath6kl so that we can easily handle signed __le32 values. This is needed in struct wmi_pdev_tpc_config_event.

---
 drivers/net/wireless/ath/ath10k/wmi.h |   21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath10k/wmi.h +20 -1
index 3e5a1591f772..95fdc723a996 100644
@@ -73,6 +73,25 @@ struct wmi_cmd_hdr {
 #define HTC_PROTOCOL_VERSION    0x0002
 #define WMI_PROTOCOL_VERSION    0x0002
 
+/*
+ * There is no signed version of __le32, so for a temporary solution come
+ * up with our own version. The idea is from fs/ntfs/types.h.
+ *
+ * Use a_ prefix so that it doesn't conflict if we get proper support to
+ * linux/types.h.
+ */
+typedef __s32 __bitwise a_sle32;
+
+static inline a_sle32 a_cpu_to_sle32(s32 val)
+{
+	return (__force a_sle32) cpu_to_le32(val);
+}
+
+static inline s32 a_sle32_to_cpu(a_sle32 val)
+{
+	return le32_to_cpu((__force __le32) val);
+}
+
 enum wmi_service {
 	WMI_SERVICE_BEACON_OFFLOAD = 0,
 	WMI_SERVICE_SCAN_OFFLOAD,
@@ -3657,7 +3676,7 @@ struct wmi_pdev_tpc_config_event {
 	__le32 phy_mode;
 	__le32 twice_antenna_reduction;
 	__le32 twice_max_rd_power;
-	s32 twice_antenna_gain;
+	a_sle32 twice_antenna_gain;
 	__le32 power_limit;
 	__le32 rate_max;
 	__le32 num_tx_chain;
author
#2 lore raw

PATCH 2/2 ath10k: implement debugfs interface for Transmit Power Control stats

In reply to Kalle Valo

From: Maharaja Kennadyrajan <[email protected]>

The Transmit Power Control (TPC) dump will show the power control values for each rate which makes it easier to debug calibration problems.

Example usage:

# cat /sys/kernel/debug/ieee80211/phy0/ath10k/tpc_stats
TPC config for channel  5180  mode  10
CTL             = 0x10 Reg. Domain              = 58
Antenna Gain    = 1    Reg. Max Antenna Gain    = 0
Power Limit     = 34   Reg. Max Power           = 34
Num tx chains   = 3    Num supported rates      = 155

**********CDD POWER TABLE*******

No. Preamble Rate_code tpc_valu1 tpc_value2 tpc_value3

0       CCK     0x40       0            0       0
1       CCk     0x41       0            0       0

[...]

154 HTCUP 0x 0 24 0 0
**********STBC POWER TABLE******
No. Preamble Rate_code tpc_valu1 tpc_value2 tpc_value3
0 CCK 0x40 0 0 0

[...]

154 HTCUP 0x 0 24 24 0
**********TXBF POWER TABLE******

is used to dump the tx power control stats.

---
 drivers/net/wireless/ath/ath10k/core.h    |   29 +++
 drivers/net/wireless/ath/ath10k/debug.c   |  233 +++++++++++++++++++++++++
 drivers/net/wireless/ath/ath10k/debug.h   |    8 +
 drivers/net/wireless/ath/ath10k/wmi-ops.h |   19 ++
 drivers/net/wireless/ath/ath10k/wmi.c     |  269 +++++++++++++++++++++++++++++
 drivers/net/wireless/ath/ath10k/wmi.h     |   15 ++
 6 files changed, 572 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath10k/core.h +29 -0
index 04e040a06cb1..002de7113e63 100644
@@ -250,6 +250,30 @@ struct ath10k_fw_stats {
 	struct list_head peers;
 };
 
+#define ATH10K_TPC_TABLE_TYPE_FLAG	1
+#define ATH10K_TPC_PREAM_TABLE_END	0xFFFF
+
+struct ath10k_tpc_table {
+	u32 pream_idx[WMI_TPC_RATE_MAX];
+	u8 rate_code[WMI_TPC_RATE_MAX];
+	char tpc_value[WMI_TPC_RATE_MAX][WMI_TPC_TX_N_CHAIN * WMI_TPC_BUF_SIZE];
+};
+
+struct ath10k_tpc_stats {
+	u32 reg_domain;
+	u32 chan_freq;
+	u32 phy_mode;
+	u32 twice_antenna_reduction;
+	u32 twice_max_rd_power;
+	s32 twice_antenna_gain;
+	u32 power_limit;
+	u32 num_tx_chain;
+	u32 ctl;
+	u32 rate_max;
+	u8 flag[WMI_TPC_FLAG];
+	struct ath10k_tpc_table tpc_table[WMI_TPC_FLAG];
+};
+
 struct ath10k_dfs_stats {
 	u32 phy_errors;
 	u32 pulses_total;
@@ -378,6 +402,11 @@ struct ath10k_debug {
 	struct ath10k_dfs_stats dfs_stats;
 	struct ath_dfs_pool_stats dfs_pool_stats;
 
+	/* used for tpc-dump storage, protected by data-lock */
+	struct ath10k_tpc_stats *tpc_stats;
+
+	struct completion tpc_complete;
+
 	/* protected by conf_mutex */
 	u32 fw_dbglog_mask;
 	u32 fw_dbglog_level;
drivers/net/wireless/ath/ath10k/debug.c +233 -0

257 lines not on this page · raw message

drivers/net/wireless/ath/ath10k/debug.h +8 -0
index 53bd6a19eab6..b07639e9b082 100644
@@ -70,6 +70,8 @@ void ath10k_debug_destroy(struct ath10k *ar);
 int ath10k_debug_register(struct ath10k *ar);
 void ath10k_debug_unregister(struct ath10k *ar);
 void ath10k_debug_fw_stats_process(struct ath10k *ar, struct sk_buff *skb);
+void ath10k_debug_tpc_stats_process(struct ath10k *ar,
+				    struct ath10k_tpc_stats *tpc_stats);
 struct ath10k_fw_crash_data *
 ath10k_debug_get_new_fw_crash_data(struct ath10k *ar);
 
@@ -117,6 +119,12 @@ static inline void ath10k_debug_fw_stats_process(struct ath10k *ar,
 {
 }
 
+static inline void ath10k_debug_tpc_stats_process(struct ath10k *ar,
+						  struct ath10k_tpc_stats *tpc_stats)
+{
+	kfree(tpc_stats);
+}
+
 static inline void ath10k_debug_dbglog_add(struct ath10k *ar, u8 *buffer,
 					   int len)
 {
drivers/net/wireless/ath/ath10k/wmi-ops.h +19 -0
index 248ffc3d6620..d3bc6df861e4 100644
@@ -177,6 +177,8 @@ struct wmi_ops {
 						const struct wmi_tdls_peer_capab_arg *cap,
 						const struct wmi_channel_arg *chan);
 	struct sk_buff *(*gen_adaptive_qcs)(struct ath10k *ar, bool enable);
+	struct sk_buff *(*gen_pdev_get_tpc_config)(struct ath10k *ar,
+						   u32 param);
 };
 
 int ath10k_wmi_cmd_send(struct ath10k *ar, struct sk_buff *skb, u32 cmd_id);
@@ -1270,4 +1272,21 @@ ath10k_wmi_adaptive_qcs(struct ath10k *ar, bool enable)
 	return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->adaptive_qcs_cmdid);
 }
 
+static inline int
+ath10k_wmi_pdev_get_tpc_config(struct ath10k *ar, u32 param)
+{
+	struct sk_buff *skb;
+
+	if (!ar->wmi.ops->gen_pdev_get_tpc_config)
+		return -EOPNOTSUPP;
+
+	skb = ar->wmi.ops->gen_pdev_get_tpc_config(ar, param);
+
+	if (IS_ERR(skb))
+		return PTR_ERR(skb);
+
+	return ath10k_wmi_cmd_send(ar, skb,
+				   ar->wmi.cmd->pdev_get_tpc_config_cmdid);
+}
+
 #endif
drivers/net/wireless/ath/ath10k/wmi.c +268 -1

289 lines not on this page · raw message

drivers/net/wireless/ath/ath10k/wmi.h +15 -0
index 95fdc723a996..9e9e222c5a37 100644
@@ -3661,8 +3661,18 @@ struct wmi_pdev_get_tpc_config_cmd {
 	__le32 param;
 } __packed;
 
+#define WMI_TPC_CONFIG_PARAM		1
 #define WMI_TPC_RATE_MAX		160
 #define WMI_TPC_TX_N_CHAIN		4
+#define WMI_TPC_PREAM_TABLE_MAX		10
+#define WMI_TPC_FLAG			3
+#define WMI_TPC_BUF_SIZE		10
+
+enum wmi_tpc_table_type {
+	WMI_TPC_TABLE_TYPE_CDD = 0,
+	WMI_TPC_TABLE_TYPE_STBC = 1,
+	WMI_TPC_TABLE_TYPE_TXBF = 2,
+};
 
 enum wmi_tpc_config_event_flag {
 	WMI_TPC_CONFIG_EVENT_FLAG_TABLE_CDD	= 0x1,
@@ -4272,6 +4282,11 @@ enum wmi_rate_preamble {
 	WMI_RATE_PREAMBLE_VHT,
 };
 
+#define ATH10K_HW_NSS(rate)		(1 + (((rate) >> 4) & 0x3))
+#define ATH10K_HW_PREAMBLE(rate)	(((rate) >> 6) & 0x3)
+#define ATH10K_HW_RATECODE(rate, nss, preamble)	\
+	(((preamble) << 6) | ((nss) << 4) | (rate))
+
 /* Value to disable fixed rate setting */
 #define WMI_FIXED_RATE_NONE    (0xff)
 
author Applied
#3 lore raw
In reply to Kalle Valo
Quoted 10 lines · Kalle Valo

This implements a simple interface for debugging TPC stats. I did a small hack to sparse to check endian usage with signed 32 bit values.

---

Kalle Valo (1):

      ath10k: add a_sle32_to_cpu()

Maharaja Kennadyrajan (1):
ath10k: implement debugfs interface for Transmit Power Control stats

Applied.

Signature · 1 line
Kalle Valo