[PATCH v4 1/2] wifi: ath12k: Add Support to Parse TPC Event from Firmware
Aditya Kumar Singh
aditya.kumar.singh at oss.qualcomm.com
Mon Jan 27 20:44:56 PST 2025
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)
> {
--
Aditya
More information about the ath12k
mailing list