blob: dc435f89cc4e52a0f02c92f96273877ddb17a5ab [file] [log] [blame]
From 10e5cdcde26b21026db4460ded6e0b11c045a96a Mon Sep 17 00:00:00 2001
From: "Allen.Ye" <allen.ye@mediatek.com>
Date: Thu, 25 Aug 2022 17:27:06 +0800
Subject: [PATCH] HAL: add set STBC enable function
---
source/wifi/wifi_hal.c | 61 ++++++++++++++++++++++++++++++++++++++++--
1 file changed, 59 insertions(+), 2 deletions(-)
diff --git a/source/wifi/wifi_hal.c b/source/wifi/wifi_hal.c
index 8ec1d0e..34989ea 100644
--- a/source/wifi/wifi_hal.c
+++ b/source/wifi/wifi_hal.c
@@ -4049,8 +4049,65 @@ INT wifi_setRadioFragmentationThreshold(INT apIndex, UINT threshold)
// enable STBC mode in the hardwarwe, 0 == not enabled, 1 == enabled
INT wifi_setRadioSTBCEnable(INT radioIndex, BOOL STBC_Enable)
{
- //Save config and Apply instantly
- return RETURN_ERR;
+ char config_file[64] = {'\0'};
+ char cmd[128] = {'\0'};
+ char buf[64] = {'\0'};
+ char stbc_config[16] = {'\0'};
+ wifi_band band;
+ int iterator = 0;
+ BOOL current_stbc = FALSE;
+
+ WIFI_ENTRY_EXIT_DEBUG("Inside %s:%d\n",__func__, __LINE__);
+
+ band = wifi_index_to_band(radioIndex);
+ if (band == band_invalid)
+ return RETURN_ERR;
+
+ if (band == band_2_4)
+ iterator = 1;
+ else if (band == band_5)
+ iterator = 2;
+ else
+ return RETURN_OK;
+
+ snprintf(config_file, sizeof(config_file), "%s%d.conf", CONFIG_PREFIX, radioIndex);
+
+ // set ht and vht config
+ for (int i = 0; i < iterator; i++) {
+ memset(stbc_config, 0, sizeof(stbc_config));
+ memset(cmd, 0, sizeof(cmd));
+ memset(buf, 0, sizeof(buf));
+ snprintf(stbc_config, sizeof(stbc_config), "%sht_capab", (i == 0)?"":"v");
+ snprintf(cmd, sizeof(cmd), "cat %s | grep -E '^%s' | grep 'STBC'", config_file, stbc_config);
+ _syscmd(cmd, buf, sizeof(buf));
+ if (strlen(buf) != 0)
+ current_stbc = TRUE;
+ if (current_stbc == STBC_Enable)
+ continue;
+
+ if (STBC_Enable == TRUE) {
+ // Append the STBC flags in capab config
+ memset(cmd, 0, sizeof(cmd));
+ if (i == 0)
+ snprintf(cmd, sizeof(cmd), "sed -E -i '/^ht_capab=.*/s/$/[TX-STBC][RX-STBC1]/' %s", config_file);
+ else
+ snprintf(cmd, sizeof(cmd), "sed -E -i '/^vht_capab=.*/s/$/[TX-STBC-2BY1][RX-STBC-1]/' %s", config_file);
+ _syscmd(cmd, buf, sizeof(buf));
+ } else if (STBC_Enable == FALSE) {
+ // Remove the STBC flags and remain other flags in capab
+ memset(cmd, 0, sizeof(cmd));
+ snprintf(cmd, sizeof(cmd), "sed -E -i 's/\\[TX-STBC(-2BY1)?*\\]//' %s", config_file);
+ _syscmd(cmd, buf, sizeof(buf));
+ memset(cmd, 0, sizeof(cmd));
+ snprintf(cmd, sizeof(cmd), "sed -E -i 's/\\[RX-STBC-?[1-3]*\\]//' %s", config_file);
+ _syscmd(cmd, buf, sizeof(buf));
+ }
+ }
+
+ wifi_reloadAp(radioIndex);
+
+ WIFI_ENTRY_EXIT_DEBUG("Exiting %s:%d\n",__func__, __LINE__);
+ return RETURN_OK;
}
// outputs A-MSDU enable status, 0 == not enabled, 1 == enabled
--
2.18.0