[PATCH ath-next 1/6] wifi: ath12k: generalize GI and LTF fixed rate functions

Muna Sinada
2025-10-24T00:19:45Z

Currently, functions in mac.c for setting GI and LTF rates are
specifically for HE rates.

Remove any mention of "HE" in such functions in order to allow for
other modes to utilize the functions. The intention is to prepare for
the addition of EHT GI and LTF fixed rate settings.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1

Signed-off-by: Muna Sinada <muna.sinada@oss.qualcomm.com>
---
drivers/net/wireless/ath/ath12k/mac.c | 77 ++++++++++++++-------------
drivers/net/wireless/ath/ath12k/mac.h | 14 ++++-
drivers/net/wireless/ath/ath12k/wmi.h | 12 ++---
3 files changed, 60 insertions(+), 43 deletions(-)

diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index d7bc19cea2a6..fd49a0953470 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -12043,55 +12043,57 @@ ath12k_mac_get_single_legacy_rate(struct ath12k *ar,
}

static int
-ath12k_mac_set_fixed_rate_gi_ltf(struct ath12k_link_vif *arvif, u8 he_gi, u8 he_ltf)
+ath12k_mac_set_fixed_rate_gi_ltf(struct ath12k_link_vif *arvif, u8 gi, u8 ltf)
{
struct ath12k *ar = arvif->ar;
- int ret;
+ int param, ret;

lockdep_assert_wiphy(ath12k_ar_to_hw(ar)->wiphy);

/* 0.8 = 0, 1.6 = 2 and 3.2 = 3. */
- if (he_gi && he_gi != 0xFF)
- he_gi += 1;
+ if (gi && gi != 0xFF)
+ gi += 1;

ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id,
- WMI_VDEV_PARAM_SGI, he_gi);
+ WMI_VDEV_PARAM_SGI, gi);
if (ret) {
- ath12k_warn(ar->ab, "failed to set HE GI:%d, error:%d\n",
- he_gi, ret);
+ ath12k_warn(ar->ab, "failed to set GI:%d, error:%d\n",
+ gi, ret);
return ret;
}
/* start from 1 */
- if (he_ltf != 0xFF)
- he_ltf += 1;
+ if (ltf != 0xFF)
+ ltf += 1;
+
+ param = WMI_VDEV_PARAM_HE_LTF;

ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id,
- WMI_VDEV_PARAM_HE_LTF, he_ltf);
+ param, ltf);
if (ret) {
- ath12k_warn(ar->ab, "failed to set HE LTF:%d, error:%d\n",
- he_ltf, ret);
+ ath12k_warn(ar->ab, "failed to set LTF:%d, error:%d\n",
+ ltf, ret);
return ret;
}
return 0;
}

static int
-ath12k_mac_set_auto_rate_gi_ltf(struct ath12k_link_vif *arvif, u16 he_gi, u8 he_ltf)
+ath12k_mac_set_auto_rate_gi_ltf(struct ath12k_link_vif *arvif, u16 gi, u8 ltf)
{
struct ath12k *ar = arvif->ar;
int ret;
- u32 he_ar_gi_ltf;
+ u32 ar_gi_ltf;

- if (he_gi != 0xFF) {
- switch (he_gi) {
- case NL80211_RATE_INFO_HE_GI_0_8:
- he_gi = WMI_AUTORATE_800NS_GI;
+ if (gi != 0xFF) {
+ switch (gi) {
+ case ATH12K_RATE_INFO_GI_0_8:
+ gi = WMI_AUTORATE_800NS_GI;
break;
- case NL80211_RATE_INFO_HE_GI_1_6:
- he_gi = WMI_AUTORATE_1600NS_GI;
+ case ATH12K_RATE_INFO_GI_1_6:
+ gi = WMI_AUTORATE_1600NS_GI;
break;
- case NL80211_RATE_INFO_HE_GI_3_2:
- he_gi = WMI_AUTORATE_3200NS_GI;
+ case ATH12K_RATE_INFO_GI_3_2:
+ gi = WMI_AUTORATE_3200NS_GI;
break;
default:
ath12k_warn(ar->ab, "Invalid GI\n");
@@ -12099,16 +12101,16 @@ ath12k_mac_set_auto_rate_gi_ltf(struct ath12k_link_vif *arvif, u16 he_gi, u8 he_
}
}

- if (he_ltf != 0xFF) {
- switch (he_ltf) {
- case NL80211_RATE_INFO_HE_1XLTF:
- he_ltf = WMI_HE_AUTORATE_LTF_1X;
+ if (ltf != 0xFF) {
+ switch (ltf) {
+ case ATH12K_RATE_INFO_1XLTF:
+ ltf = WMI_AUTORATE_LTF_1X;
break;
- case NL80211_RATE_INFO_HE_2XLTF:
- he_ltf = WMI_HE_AUTORATE_LTF_2X;
+ case ATH12K_RATE_INFO_2XLTF:
+ ltf = WMI_AUTORATE_LTF_2X;
break;
- case NL80211_RATE_INFO_HE_4XLTF:
- he_ltf = WMI_HE_AUTORATE_LTF_4X;
+ case ATH12K_RATE_INFO_4XLTF:
+ ltf = WMI_AUTORATE_LTF_4X;
break;
default:
ath12k_warn(ar->ab, "Invalid LTF\n");
@@ -12116,15 +12118,15 @@ ath12k_mac_set_auto_rate_gi_ltf(struct ath12k_link_vif *arvif, u16 he_gi, u8 he_
}
}

- he_ar_gi_ltf = he_gi | he_ltf;
+ ar_gi_ltf = gi | ltf;

ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id,
WMI_VDEV_PARAM_AUTORATE_MISC_CFG,
- he_ar_gi_ltf);
+ ar_gi_ltf);
if (ret) {
ath12k_warn(ar->ab,
- "failed to set HE autorate GI:%u, LTF:%u params, error:%d\n",
- he_gi, he_ltf, ret);
+ "failed to set autorate GI:%u, LTF:%u params, error:%d\n",
+ gi, ltf, ret);
return ret;
}

@@ -12149,10 +12151,10 @@ static int ath12k_mac_set_rate_params(struct ath12k_link_vif *arvif,
{
struct ieee80211_bss_conf *link_conf;
struct ath12k *ar = arvif->ar;
+ bool he_support, gi_ltf_set = false;
u32 vdev_param;
u32 param_value;
int ret;
- bool he_support;

lockdep_assert_wiphy(ath12k_ar_to_hw(ar)->wiphy);

@@ -12206,7 +12208,10 @@ static int ath12k_mac_set_rate_params(struct ath12k_link_vif *arvif,
ret = ath12k_mac_set_auto_rate_gi_ltf(arvif, he_gi, he_ltf);
if (ret)
return ret;
- } else {
+ gi_ltf_set = true;
+ }
+
+ if (!gi_ltf_set) {
vdev_param = WMI_VDEV_PARAM_SGI;
param_value = ath12k_mac_nlgi_to_wmigi(sgi);
ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id,
diff --git a/drivers/net/wireless/ath/ath12k/mac.h b/drivers/net/wireless/ath/ath12k/mac.h
index c05af40bd7a2..1f689e367c8a 100644
--- a/drivers/net/wireless/ath/ath12k/mac.h
+++ b/drivers/net/wireless/ath/ath12k/mac.h
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: BSD-3-Clause-Clear */
/*
* Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
- * Copyright (c) 2021-2025 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
*/

#ifndef ATH12K_MAC_H
@@ -84,6 +84,18 @@ enum ath12k_supported_bw {
ATH12K_BW_320 = 4,
};

+enum ath12k_gi {
+ ATH12K_RATE_INFO_GI_0_8,
+ ATH12K_RATE_INFO_GI_1_6,
+ ATH12K_RATE_INFO_GI_3_2,
+};
+
+enum ath12k_ltf {
+ ATH12K_RATE_INFO_1XLTF,
+ ATH12K_RATE_INFO_2XLTF,
+ ATH12K_RATE_INFO_4XLTF,
+};
+
struct ath12k_mac_get_any_chanctx_conf_arg {
struct ath12k *ar;
struct ieee80211_chanctx_conf *chanctx_conf;
diff --git a/drivers/net/wireless/ath/ath12k/wmi.h b/drivers/net/wireless/ath/ath12k/wmi.h
index 64bd968989c8..01b2a865f103 100644
--- a/drivers/net/wireless/ath/ath12k/wmi.h
+++ b/drivers/net/wireless/ath/ath12k/wmi.h
@@ -223,15 +223,15 @@ enum WMI_HOST_WLAN_BAND {
};

/* Parameters used for WMI_VDEV_PARAM_AUTORATE_MISC_CFG command.
- * Used only for HE auto rate mode.
+ * Used for HE and EHT auto rate mode.
*/
enum {
- /* HE LTF related configuration */
- WMI_HE_AUTORATE_LTF_1X = BIT(0),
- WMI_HE_AUTORATE_LTF_2X = BIT(1),
- WMI_HE_AUTORATE_LTF_4X = BIT(2),
+ /* LTF related configuration */
+ WMI_AUTORATE_LTF_1X = BIT(0),
+ WMI_AUTORATE_LTF_2X = BIT(1),
+ WMI_AUTORATE_LTF_4X = BIT(2),

- /* HE GI related configuration */
+ /* GI related configuration */
WMI_AUTORATE_400NS_GI = BIT(8),
WMI_AUTORATE_800NS_GI = BIT(9),
WMI_AUTORATE_1600NS_GI = BIT(10),
--
2.34.1