From a006a3010f5b56d575ab90de62fe5a59ee7f0c7d Mon Sep 17 00:00:00 2001 From: Kiran Kumar Lokere Date: Wed, 7 Mar 2018 20:58:13 -0800 Subject: [PATCH] qcacld-3.0: Add support to configure HE LTF Add support for configuring HE LTF. Change-Id: Ieabe844729c32c47403a7c94864cb689fa7fb8aa CRs-Fixed: 2201837 --- core/hdd/inc/wlan_hdd_wext.h | 2 + core/hdd/src/wlan_hdd_cfg80211.c | 19 +++++ core/hdd/src/wlan_hdd_wext.c | 25 +++++-- core/mac/inc/ani_global.h | 2 + core/mac/inc/sir_api.h | 19 +++++ .../sys/legacy/src/system/src/mac_init_api.c | 3 +- core/sme/inc/sme_api.h | 22 ++++++ core/sme/src/common/sme_api.c | 72 +++++++++++++++++++ 8 files changed, 156 insertions(+), 8 deletions(-) diff --git a/core/hdd/inc/wlan_hdd_wext.h b/core/hdd/inc/wlan_hdd_wext.h index d5f947e4734b..61c43d389349 100644 --- a/core/hdd/inc/wlan_hdd_wext.h +++ b/core/hdd/inc/wlan_hdd_wext.h @@ -173,6 +173,8 @@ enum hdd_wlan_wmm_ts_info_ack_policy { #define HDD_RTSCTS_ENABLE 1 #define HDD_CTS_ENABLE 2 +#define HDD_AUTO_RATE_SGI 0x8 + #define WPS_OUI_TYPE "\x00\x50\xf2\x04" #define WPS_OUI_TYPE_SIZE 4 diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c index 77acb0e2636e..294093c5da9f 100644 --- a/core/hdd/src/wlan_hdd_cfg80211.c +++ b/core/hdd/src/wlan_hdd_cfg80211.c @@ -6322,6 +6322,8 @@ wlan_hdd_wifi_test_config_policy[ .type = NLA_U8}, [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_NO_ACK_AC] = { .type = NLA_U8}, + [QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_HE_LTF] = { + .type = NLA_U8}, }; /** @@ -7472,6 +7474,23 @@ __wlan_hdd_cfg80211_set_wifi_test_config(struct wiphy *wiphy, adapter->session_id, cfg_val, ac); } + if (tb[QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_HE_LTF]) { + cfg_val = nla_get_u8(tb[ + QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_HE_LTF]); + hdd_debug("Set HE LTF to %d", cfg_val); + ret_val = sme_set_auto_rate_he_ltf(hdd_ctx->hHal, + adapter->session_id, + cfg_val); + if (ret_val) + sme_err("Failed to set auto rate HE LTF"); + + ret_val = wma_cli_set_command(adapter->session_id, + WMI_VDEV_PARAM_HE_LTF, + cfg_val, VDEV_CMD); + if (ret_val) + goto send_err; + } + if (update_sme_cfg) sme_update_config(hdd_ctx->hHal, sme_config); diff --git a/core/hdd/src/wlan_hdd_wext.c b/core/hdd/src/wlan_hdd_wext.c index 0ae8b70ab949..b3dcec4e01bf 100644 --- a/core/hdd/src/wlan_hdd_wext.c +++ b/core/hdd/src/wlan_hdd_wext.c @@ -291,13 +291,14 @@ #define WE_SET_RX_STBC 14 /* * - * shortgi - Enables or disables a short-guard interval + * shortgi - Sets the short-guard interval * - * @INPUT: Int 0 – Disable, 1 - Enable + * @INPUT: Fixed Rate: 0 - 400ns, 1 - 800ns, 2 - 1600ns, 3 - 3200us + * Auto Rate: 8 - 400ns, 9 - 800ns, 10 - 1600ns, 11 - 3200us * * @OUTPUT: None * - * This IOCTL enables or disables a short-guard interval. + * This IOCTL sets the short-guard interval. * * @E.g: iwpriv wlan0 shortgi * @@ -3667,6 +3668,7 @@ int hdd_set_11ax_rate(struct hdd_adapter *adapter, int set_value, { uint8_t preamble = 0, nss = 0, rix = 0; int ret; + tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter); if (!sap_config) { if (!sme_is_feature_supported_by_fw(DOT11AX)) { @@ -3686,6 +3688,9 @@ int hdd_set_11ax_rate(struct hdd_adapter *adapter, int set_value, nss = HT_RC_2_STREAMS_11AX(set_value); set_value = hdd_assemble_rate_code(preamble, nss, rix); + } else { + ret = sme_set_auto_rate_he_ltf(hal, adapter->session_id, + QCA_WLAN_HE_LTF_AUTO); } hdd_info("SET_11AX_RATE val %d rix %d preamble %x nss %d", @@ -4492,11 +4497,17 @@ static int __iw_setint_getnone(struct net_device *dev, return -EINVAL; hdd_debug("WMI_VDEV_PARAM_SGI val %d", set_value); - ret = sme_update_ht_config(hHal, adapter->session_id, - WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ, - set_value); + if (set_value & HDD_AUTO_RATE_SGI) + ret = sme_set_auto_rate_he_sgi(hHal, + adapter->session_id, + set_value); + else + ret = sme_update_ht_config(hHal, adapter->session_id, + WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ, + set_value); if (ret) - hdd_err("Failed to set ShortGI value"); + hdd_err("Failed to set ShortGI value %d", set_value); + break; } diff --git a/core/mac/inc/ani_global.h b/core/mac/inc/ani_global.h index f8de3461cc73..15f8dbed3e36 100644 --- a/core/mac/inc/ani_global.h +++ b/core/mac/inc/ani_global.h @@ -94,6 +94,7 @@ #define LOW_SEQ_NUM_MASK 0x000F #define HIGH_SEQ_NUM_MASK 0x0FF0 #define HIGH_SEQ_NUM_OFFSET 4 +#define DEF_HE_AUTO_SGI_LTF 0x0F07 /* vendor element ID */ #define IE_EID_VENDOR (221) /* 0xDD */ @@ -947,6 +948,7 @@ typedef struct sAniSirGlobal { uint8_t reject_addba_req; uint16_t usr_cfg_ba_buff_size; uint8_t no_ack_policy_cfg[MAX_NUM_AC]; + uint32_t he_sgi_ltf_cfg_bit_mask; } tAniSirGlobal; diff --git a/core/mac/inc/sir_api.h b/core/mac/inc/sir_api.h index 4667eb6d5de9..b3970b171dc3 100644 --- a/core/mac/inc/sir_api.h +++ b/core/mac/inc/sir_api.h @@ -7187,6 +7187,24 @@ struct wow_enable_params { enum wow_resume_trigger resume_trigger; }; +#define HE_LTF_1X 0 +#define HE_LTF_2X 1 +#define HE_LTF_4X 2 + +#define HE_LTF_ALL 0x7 +#define HE_SGI_MASK 0xFF00 + +#define AUTO_RATE_GI_400NS 8 +#define AUTO_RATE_GI_800NS 9 +#define AUTO_RATE_GI_1600NS 10 +#define AUTO_RATE_GI_3200NS 11 + +#define SET_AUTO_RATE_SGI_VAL(set_val, bit_mask) \ + (set_val = (set_val & HE_LTF_ALL) | bit_mask) + +#define SET_AUTO_RATE_HE_LTF_VAL(set_val, bit_mask) \ + (set_val = (set_val & HE_SGI_MASK) | bit_mask) + #ifdef WLAN_FEATURE_11AX #define HE_CAP_OUI_TYPE "\x23" #define HE_CAP_OUI_SIZE 1 @@ -7246,6 +7264,7 @@ struct ppet_hdr { #define HE_MCS_0_9 0x1 #define HE_MCS_0_11 0x2 #define HE_MCS_DISABLE 0x3 + /* * Following formuala has been arrived at using karnaugh map and unit tested * with sample code. Take MCS for each NSS as 2 bit value first and solve for diff --git a/core/mac/src/sys/legacy/src/system/src/mac_init_api.c b/core/mac/src/sys/legacy/src/system/src/mac_init_api.c index c02924aa30b9..79580b25f6ea 100644 --- a/core/mac/src/sys/legacy/src/system/src/mac_init_api.c +++ b/core/mac/src/sys/legacy/src/system/src/mac_init_api.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2017 The Linux Foundation. All rights reserved. + * Copyright (c) 2011-2018 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -146,6 +146,7 @@ tSirRetStatus mac_open(struct wlan_objmgr_psoc *psoc, tHalHandle *pHalHandle, /* FW: 0 to 2047 and Host: 2048 to 4095 */ p_mac->mgmtSeqNum = WLAN_HOST_SEQ_NUM_MIN - 1; p_mac->first_scan_done = false; + p_mac->he_sgi_ltf_cfg_bit_mask = DEF_HE_AUTO_SGI_LTF; status = pe_open(p_mac, cds_cfg); if (eSIR_SUCCESS != status) { diff --git a/core/sme/inc/sme_api.h b/core/sme/inc/sme_api.h index 3af9f1efadcd..e12217d27ce9 100644 --- a/core/sme/inc/sme_api.h +++ b/core/sme/inc/sme_api.h @@ -2107,6 +2107,28 @@ int sme_send_addba_req(tHalHandle hal, uint8_t session_id, uint8_t tid, int sme_set_no_ack_policy(tHalHandle hal, uint8_t session_id, uint8_t val, uint8_t ac); +/** + * sme_set_auto_rate_he_sgi() - Sets SGI for auto rate + * @hal: Pointer to HAL + * @session_id: SME session id + * @cfg_val: SGI configuration value + * + * Return: 0 on success else err code + */ +int sme_set_auto_rate_he_sgi(tHalHandle hal, uint8_t session_id, + uint8_t cfg_val); + +/** + * sme_set_auto_rate_he_ltf() - Sets HE LTF for auto rate + * @hal: Pointer to HAL + * @session_id: SME session id + * @cfg_val: LTF configuration value + * + * Return: 0 on success else err code + */ +int sme_set_auto_rate_he_ltf(tHalHandle hal, uint8_t session_id, + uint8_t cfg_val); + #ifdef WLAN_FEATURE_11AX /** * sme_update_he_cap_nss() - sets the nss based on user request diff --git a/core/sme/src/common/sme_api.c b/core/sme/src/common/sme_api.c index 04bea8fd43b9..498d72ba1c93 100644 --- a/core/sme/src/common/sme_api.c +++ b/core/sme/src/common/sme_api.c @@ -9814,6 +9814,78 @@ int sme_set_no_ack_policy(tHalHandle hal, uint8_t session_id, return 0; } +int sme_set_auto_rate_he_ltf(tHalHandle hal, uint8_t session_id, + uint8_t cfg_val) +{ + tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal); + uint32_t set_val; + uint32_t bit_mask = 0; + int status; + + if (cfg_val > QCA_WLAN_HE_LTF_4X) { + sme_err("invalid HE LTF cfg %d", cfg_val); + return -EINVAL; + } + + /*set the corresponding HE LTF cfg BIT*/ + if (cfg_val == QCA_WLAN_HE_LTF_AUTO) + bit_mask = HE_LTF_ALL; + else + bit_mask = (1 << (cfg_val - 1)); + + set_val = mac_ctx->he_sgi_ltf_cfg_bit_mask; + + SET_AUTO_RATE_HE_LTF_VAL(set_val, bit_mask); + + mac_ctx->he_sgi_ltf_cfg_bit_mask = set_val; + status = wma_cli_set_command(session_id, + WMI_VDEV_PARAM_AUTORATE_MISC_CFG, + set_val, VDEV_CMD); + if (status) { + sme_err("failed to set he_ltf_sgi"); + return status; + } + + sme_debug("HE SGI_LTF is set to 0x%08X", + mac_ctx->he_sgi_ltf_cfg_bit_mask); + + return 0; +} + +int sme_set_auto_rate_he_sgi(tHalHandle hal, uint8_t session_id, + uint8_t cfg_val) +{ + tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal); + uint32_t set_val; + uint32_t sgi_bit_mask = 0; + int status; + + if ((cfg_val > AUTO_RATE_GI_3200NS) || + (cfg_val < AUTO_RATE_GI_400NS)) { + sme_err("invalid auto rate GI cfg %d", cfg_val); + return -EINVAL; + } + + sgi_bit_mask = (1 << cfg_val); + + set_val = mac_ctx->he_sgi_ltf_cfg_bit_mask; + SET_AUTO_RATE_SGI_VAL(set_val, sgi_bit_mask); + + mac_ctx->he_sgi_ltf_cfg_bit_mask = set_val; + status = wma_cli_set_command(session_id, + WMI_VDEV_PARAM_AUTORATE_MISC_CFG, + set_val, VDEV_CMD); + if (status) { + sme_err("failed to set he_ltf_sgi"); + return status; + } + + sme_debug("auto rate HE SGI_LTF is set to 0x%08X", + mac_ctx->he_sgi_ltf_cfg_bit_mask); + + return 0; +} + #define HT20_SHORT_GI_MCS7_RATE 722 /* * sme_send_rate_update_ind() -