mbox series

[v4,0/2] wifi: ath12k: Support Transmit Power Control Stats

Message ID 20250127073255.3374341-1-quic_rdevanat@quicinc.com
Headers show
Series wifi: ath12k: Support Transmit Power Control Stats | expand

Message

Roopni Devanathan Jan. 27, 2025, 7:32 a.m. UTC
Add support to print Transmit Power Control Stats. Add support for basic
infrastructure necessary for enabling TPC stats via debugfs. This patch
series brings support to request stats type from firmware and dump the
corresponding stats.

Schema for an ath12k device:
ath12k
-- pci-0000:06:00.0
    -- mac0
        -- tpc_stats
        -- tpc_stats_type

Sample TPC logs:
*************** TPC config **************
* powers are in 0.25 dBm steps
reg domain-22           chan freq-5955
power limit-126         max reg-domain Power-252
No.of tx chain-4        No.of rates-1164
**************** SU WITH TXBF ****************
                                TPC values for Active chains
Rate idx Preamble Rate code     1-Chain 2-Chain 3-Chain 4-Chain
4        OFDM    0x000          39      15      1       -9
5        OFDM    0x001          39      15      1       -9
.....
12       HT20    0x200          40      16      2       -8
13       HT20    0x201          40      16      2       -8
.....
44       HT40    0x200          88      88      88      88
45       HT40    0x201          88      88      88      88
.....
76       VHT20   0x300          40      16      2       -8
77       VHT20   0x301          40      16      2       -8
.....
172      VHT40   0x300          88      88      88      88
173      VHT40   0x301          88      88      88      88
.....

Note:
MCC firmware version -
WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3 does not print stats
because MCC firmware will not respond to the event passed from host,
resulting in timeout.

v4:
 - Rebased on ToT. No change in code.
v3:
 - Fixed datatype conversion warnings in v2.
v2:
 - Fixed compilation issues in v1.


Sowmiya Sree Elavalagan (2):
  wifi: ath12k: Add Support to Parse TPC Event from Firmware
  wifi: ath12k: Add Support to Calculate and Display TPC  Values

 drivers/net/wireless/ath/ath12k/core.h    |   4 +
 drivers/net/wireless/ath/ath12k/debugfs.c | 715 ++++++++++++++++++++++
 drivers/net/wireless/ath/ath12k/debugfs.h |  86 +++
 drivers/net/wireless/ath/ath12k/wmi.c     | 458 ++++++++++++++
 drivers/net/wireless/ath/ath12k/wmi.h     | 140 ++++-
 5 files changed, 1402 insertions(+), 1 deletion(-)


base-commit: 5e40b6ac64339a78a5fbf1009581aa43eb46c352

Comments

Aditya Kumar Singh Jan. 28, 2025, 4:44 a.m. UTC | #1
On 1/27/25 13:02, Roopni Devanathan wrote:
> 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:
> echo 1 > /sys/kernel/debug/ath12k/pci-0000\:06\:00.0/mac0/tpc_stats_type

This patch is adding tpc_stats alone. So usage of this file should be 
mentioned here instead of tpc_stats_type which is added in next patch?

[..]

> +static int ath12k_wmi_tpc_stats_subtlv_parser(struct ath12k_base *ab,
> +					      u16 tag, u16 len,
> +					      const void *ptr, void *data)
> +{
> +	struct wmi_tpc_rates_array_fixed_params *tpc_rates_array;
> +	struct wmi_max_reg_power_fixed_params *tpc_reg_pwr;
> +	struct wmi_tpc_ctl_pwr_fixed_params *tpc_ctl_pwr;
> +	struct wmi_tpc_stats_info *tpc_stats = data;
> +	struct wmi_tpc_config_params *tpc_config;
> +	int ret = 0;
> +
> +	if (!tpc_stats) {
> +		ath12k_warn(ab, "tpc stats memory unavailable\n");
> +		return -EINVAL;
> +	}
> +
> +	switch (tag) {
> +	case WMI_TAG_TPC_STATS_CONFIG_EVENT:
> +		tpc_config = (struct wmi_tpc_config_params *)ptr;
> +		memcpy(&tpc_stats->tpc_config, tpc_config,
> +		       sizeof(struct wmi_tpc_config_params));
> +		break;
> +

extra line break not needed?

> +	case WMI_TAG_TPC_STATS_REG_PWR_ALLOWED:
> +		tpc_reg_pwr = (struct wmi_max_reg_power_fixed_params *)ptr;
> +		ret = ath12k_tpc_get_reg_pwr(ab, tpc_stats, tpc_reg_pwr);
> +		break;
> +	case WMI_TAG_TPC_STATS_RATES_ARRAY:
> +		tpc_rates_array = (struct wmi_tpc_rates_array_fixed_params *)ptr;
> +		ret = ath12k_tpc_get_rate_array(ab, tpc_stats, tpc_rates_array);
> +		break;
> +

same here

> +	case WMI_TAG_TPC_STATS_CTL_PWR_TABLE_EVENT:
> +		tpc_ctl_pwr = (struct wmi_tpc_ctl_pwr_fixed_params *)ptr;
> +		ret = ath12k_tpc_get_ctl_pwr_tbl(ab, tpc_stats, tpc_ctl_pwr);
> +		break;
> +

same here

> +	default:
> +		ath12k_warn(ab,
> +			    "Received invalid tag for tpc stats in subtlvs\n");
> +		return -EINVAL;
> +	}
> +	return ret;
> +}

[..]

> +static void ath12k_process_tpc_stats(struct ath12k_base *ab,
> +				     struct sk_buff *skb)

Since this is WMI event processing function, name should have _wmi_ in it?

> +{
> +	struct ath12k_wmi_pdev_tpc_stats_event_fixed_params *fixed_param;
> +	struct wmi_tpc_stats_info *tpc_stats;

[..]

>   static void ath12k_wmi_op_rx(struct ath12k_base *ab, struct sk_buff *skb)
>   {
>   	struct wmi_cmd_hdr *cmd_hdr;
> @@ -8236,6 +8619,9 @@ static void ath12k_wmi_op_rx(struct ath12k_base *ab, struct sk_buff *skb)
>   		else
>   			ath12k_tm_wmi_event_unsegmented(ab, id, skb);
>   		break;
> +	case WMI_HALPHY_STATS_CTRL_PATH_EVENTID:
> +		ath12k_process_tpc_stats(ab, skb);
> +		break;

Can we add this above unsupported events comment? I see FTM elated event 
got missed and merged after it but okay, we can fix that later.

>   	default:
>   		ath12k_dbg(ab, ATH12K_DBG_WMI, "Unknown eventid: 0x%x\n", id);
>   		break;
> @@ -8372,6 +8758,78 @@ int ath12k_wmi_simulate_radar(struct ath12k *ar)
>   	return ath12k_wmi_send_unit_test_cmd(ar, wmi_ut, dfs_args);
>   }
>   
> +int ath12k_wmi_send_tpc_stats_request(struct ath12k *ar,
> +				      enum wmi_halphy_ctrl_path_stats_id tpc_stats_type)
> +{
> +	struct wmi_request_halphy_ctrl_path_stats_cmd_fixed_params *cmd;
> +	struct ath12k_wmi_pdev *wmi = ar->wmi;
> +	struct sk_buff *skb;
> +	struct wmi_tlv *tlv;
> +	__le32 *pdev_id;
> +	u32 buf_len;
> +	void *ptr;
> +	int ret;
> +
> +	buf_len = sizeof(*cmd) +
> +		  TLV_HDR_SIZE +
> +		  sizeof(u32) +
> +		  TLV_HDR_SIZE +
> +		  TLV_HDR_SIZE;
> +

Any specific reason each of these are split into multiple lines?

> +	skb = ath12k_wmi_alloc_skb(wmi->wmi_ab, buf_len);

[..]

> diff --git a/drivers/net/wireless/ath/ath12k/wmi.h b/drivers/net/wireless/ath/ath12k/wmi.h
> index 2934d9589007..f88f6a6bb15e 100644
> --- a/drivers/net/wireless/ath/ath12k/wmi.h
> +++ b/drivers/net/wireless/ath/ath12k/wmi.h

[..]

> @@ -5896,7 +6031,9 @@ int ath12k_wmi_set_bios_geo_cmd(struct ath12k_base *ab, const u8 *pgeo_table);
>   int ath12k_wmi_send_stats_request_cmd(struct ath12k *ar, u32 stats_id,
>   				      u32 vdev_id, u32 pdev_id);
>   __le32 ath12k_wmi_tlv_hdr(u32 cmd, u32 len);
> -

keep this empty line for better code readibility?

> +int ath12k_wmi_send_tpc_stats_request(struct ath12k *ar,
> +				      enum wmi_halphy_ctrl_path_stats_id tpc_stats_type);
> +void ath12k_wmi_free_tpc_stats_mem(struct ath12k *ar);
>   static inline u32
>   ath12k_wmi_caps_ext_get_pdev_id(const struct ath12k_wmi_caps_ext_params *param)
>   {