diff options
author | Srinivas Girigowda <sgirigow@codeaurora.org> | 2018-11-06 01:08:19 +0530 |
---|---|---|
committer | Ahmed ElArabawy <arabawy@google.com> | 2019-01-16 08:49:12 -0800 |
commit | 5bc44e7f281521a11656f2d55abbf4f262064195 (patch) | |
tree | 855f3ad8f5b526beb61a428663c8ea64dff95b86 /qcwcn/wifi_hal | |
parent | affb8bde8d8251d653867686fe5b58541f198312 (diff) | |
download | wlan-5bc44e7f281521a11656f2d55abbf4f262064195.tar.gz |
WiFi-Hal: Add support for Wi-Fi latency mode feature
Add support to set Wi-Fi latency mode in host driver using Wi-Fi HAL.
Supported latency modes are NORMAL, MODERATE, LOW and ULTRA LOW.
Bug: 118642535
Test: $ adb shell halutil -latency <mode (normal/low/ultra-low)>
Change-Id: I4028c2c3c1a5950e9b6bd79f4f04766b8ce309c8
Diffstat (limited to 'qcwcn/wifi_hal')
-rw-r--r-- | qcwcn/wifi_hal/wifi_hal.cpp | 1 | ||||
-rw-r--r-- | qcwcn/wifi_hal/wificonfig.cpp | 89 |
2 files changed, 90 insertions, 0 deletions
diff --git a/qcwcn/wifi_hal/wifi_hal.cpp b/qcwcn/wifi_hal/wifi_hal.cpp index 99e53ac..15dec42 100644 --- a/qcwcn/wifi_hal/wifi_hal.cpp +++ b/qcwcn/wifi_hal/wifi_hal.cpp @@ -424,6 +424,7 @@ wifi_error init_wifi_vendor_hal_func_table(wifi_hal_fn *fn) { fn->wifi_select_tx_power_scenario = wifi_select_tx_power_scenario; fn->wifi_reset_tx_power_scenario = wifi_reset_tx_power_scenario; fn->wifi_set_radio_mode_change_handler = wifi_set_radio_mode_change_handler; + fn->wifi_set_latency_mode = wifi_set_latency_mode; return WIFI_SUCCESS; } diff --git a/qcwcn/wifi_hal/wificonfig.cpp b/qcwcn/wifi_hal/wificonfig.cpp index 3073fce..40d765f 100644 --- a/qcwcn/wifi_hal/wificonfig.cpp +++ b/qcwcn/wifi_hal/wificonfig.cpp @@ -435,6 +435,95 @@ cleanup: return ret; } +wifi_error wifi_set_latency_mode(wifi_interface_handle handle, + wifi_latency_mode mode) { + wifi_error ret; + WiFiConfigCommand *wifiConfigCommand; + struct nlattr *nlData; + u32 latency_mode; + interface_info *ifaceInfo = getIfaceInfo(handle); + wifi_handle wifiHandle = getWifiHandle(handle); + hal_info *info = getHalInfo(wifiHandle); + + ALOGV("%s : latency mode:%d", __FUNCTION__, mode); + + /* Check Supported low-latency capability */ + if (!(info->supported_feature_set & WIFI_FEATURE_SET_LATENCY_MODE)) { + ALOGE("%s: Set latency mode feature not supported %x", __FUNCTION__, + info->supported_feature_set); + return WIFI_ERROR_NOT_SUPPORTED; + } + + wifiConfigCommand = new WiFiConfigCommand( + wifiHandle, + 1, + OUI_QCA, + QCA_NL80211_VENDOR_SUBCMD_SET_WIFI_CONFIGURATION); + if (wifiConfigCommand == NULL) { + ALOGE("%s: Error wifiConfigCommand NULL", __FUNCTION__); + return WIFI_ERROR_UNKNOWN; + } + + /* Create the NL message. */ + ret = wifiConfigCommand->create(); + if (ret != WIFI_SUCCESS) { + ALOGE("wifi_set_latency_mode: failed to create NL msg. Error:%d", ret); + goto cleanup; + } + + /* Set the interface Id of the message. */ + ret = wifiConfigCommand->set_iface_id(ifaceInfo->name); + if (ret != WIFI_SUCCESS) { + ALOGE("wifi_set_latency_mode: failed to set iface id. Error:%d", ret); + goto cleanup; + } + + /* Add the vendor specific attributes for the NL command. */ + nlData = wifiConfigCommand->attr_start(NL80211_ATTR_VENDOR_DATA); + if (!nlData) { + ret = WIFI_ERROR_UNKNOWN; + ALOGE("wifi_set_latency_mode: failed attr_start for VENDOR_DATA. " + "Error:%d", ret); + goto cleanup; + } + + switch(mode) { + case WIFI_LATENCY_MODE_NORMAL: + latency_mode = QCA_WLAN_VENDOR_ATTR_CONFIG_LATENCY_LEVEL_NORMAL; + break; + + case WIFI_LATENCY_MODE_LOW: + latency_mode = QCA_WLAN_VENDOR_ATTR_CONFIG_LATENCY_LEVEL_LOW; + break; + + default: + ALOGE("wifi_set_latency_mode: Invalid mode: %d", mode); + ret = WIFI_ERROR_UNKNOWN; + goto cleanup; + } + + if (wifiConfigCommand->put_u32( + QCA_WLAN_VENDOR_ATTR_CONFIG_LATENCY_LEVEL, + latency_mode)) { + ALOGE("wifi_set_latency_mode: failed to put latency mode"); + ret = WIFI_ERROR_UNKNOWN; + goto cleanup; + } + wifiConfigCommand->attr_end(nlData); + + /* Send the NL msg. */ + wifiConfigCommand->waitForRsp(false); + ret = wifiConfigCommand->requestEvent(); + if (ret != WIFI_SUCCESS) { + ALOGE("wifi_set_latency_mode: requestEvent Error:%d", ret); + goto cleanup; + } + +cleanup: + delete wifiConfigCommand; + return ret; +} + WiFiConfigCommand::WiFiConfigCommand(wifi_handle handle, int id, u32 vendor_id, u32 subcmd) |