From 10a7b71eccd55594d73eb66df47da3f7eb5895f5 Mon Sep 17 00:00:00 2001 From: Dustin Brown Date: Fri, 7 Oct 2016 10:31:16 -0700 Subject: [PATCH] qcacld-3.0: Cleanup qpower vendor command The original qpower vendor command implementation incorrectly configured the qpower setting in firmware. Cleanup the implementation. Change-Id: Id84eb7cf579a29da30f3366edef24821fcd5be55 CRs-Fixed: 1075582 --- core/hdd/src/wlan_hdd_cfg80211.c | 2 +- core/hdd/src/wlan_hdd_power.c | 31 +++++++++---------------------- core/wma/inc/wma_api.h | 10 +++++++++- core/wma/src/wma_power.c | 24 +++++++++--------------- 4 files changed, 28 insertions(+), 39 deletions(-) diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c index ae1d71d7bf2b..eb8fedd49527 100644 --- a/core/hdd/src/wlan_hdd_cfg80211.c +++ b/core/hdd/src/wlan_hdd_cfg80211.c @@ -3933,7 +3933,7 @@ __wlan_hdd_cfg80211_wifi_configuration_set(struct wiphy *wiphy, u32 guard_time; uint8_t set_value; u32 ftm_capab; - uint8_t qpower; + u8 qpower; QDF_STATUS status; int attr_len; int access_policy = 0; diff --git a/core/hdd/src/wlan_hdd_power.c b/core/hdd/src/wlan_hdd_power.c index 0efc8cbf05d9..55caa12744d3 100644 --- a/core/hdd/src/wlan_hdd_power.c +++ b/core/hdd/src/wlan_hdd_power.c @@ -2343,40 +2343,27 @@ int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy, * Return: 0 on success; Errno on failure */ int hdd_set_qpower_config(hdd_context_t *hddctx, hdd_adapter_t *adapter, - uint8_t qpower) + u8 qpower) { - QDF_STATUS qdf_status; - int status; - bool is_timer_running; + QDF_STATUS status; if (!hddctx->config->enablePowersaveOffload) { hdd_err("qpower is disabled in configuration"); return -EINVAL; } + if (qpower > PS_DUTY_CYCLING_QPOWER || qpower < PS_LEGACY_NODEEPSLEEP) { - hdd_err("invalid qpower value=%d", qpower); + hdd_err("invalid qpower value: %d", qpower); return -EINVAL; } - hdd_info("updating qpower value=%d to wma", qpower); - qdf_status = wma_set_powersave_config(qpower); - if (qdf_status != QDF_STATUS_SUCCESS) { - hdd_err("failed to update qpower %d", - qdf_status); - return -EINVAL; - } - is_timer_running = sme_is_auto_ps_timer_running( - WLAN_HDD_GET_HAL_CTX(adapter), - adapter->sessionId); - if (!is_timer_running) { - status = wlan_hdd_set_powersave(adapter, true, 0); - if (status != 0) { - hdd_err("failed to put device in power save mode %d", - status); - return -EINVAL; - } + status = wma_set_qpower_config(adapter->sessionId, qpower); + if (status != QDF_STATUS_SUCCESS) { + hdd_err("failed to configure qpower: %d", status); + return -EINVAL; } + return 0; } diff --git a/core/wma/inc/wma_api.h b/core/wma/inc/wma_api.h index 890622b424e2..58d34ec38724 100644 --- a/core/wma/inc/wma_api.h +++ b/core/wma/inc/wma_api.h @@ -299,7 +299,6 @@ void wma_process_pdev_hw_mode_trans_ind(void *wma, wmi_pdev_hw_mode_transition_event_fixed_param *fixed_param, wmi_pdev_set_hw_mode_response_vdev_mac_entry *vdev_mac_entry, struct sir_hw_mode_trans_ind *hw_mode_trans_ind); -QDF_STATUS wma_set_powersave_config(uint8_t val); QDF_STATUS wma_encrypt_decrypt_msg(WMA_HANDLE wma, struct encrypt_decrypt_req_params *encrypt_decrypt_params); @@ -317,4 +316,13 @@ QDF_STATUS wma_set_cts2self_for_p2p_go(void *wma_handle, uint32_t cts2self_for_p2p_go); QDF_STATUS wma_set_tx_rx_aggregation_size (struct sir_set_tx_rx_aggregation_size *tx_rx_aggregation_size); + +/** + * wma_set_qpower_config() - update qpower config in wma + * @vdev_id: the Id of the vdev to configure + * @qpower: new qpower value + * + * Return: QDF_STATUS_SUCCESS on success, error number otherwise + */ +QDF_STATUS wma_set_qpower_config(uint8_t vdev_id, uint8_t qpower); #endif diff --git a/core/wma/src/wma_power.c b/core/wma/src/wma_power.c index 4c139f7b186a..e939c5267597 100644 --- a/core/wma/src/wma_power.c +++ b/core/wma/src/wma_power.c @@ -856,27 +856,21 @@ void wma_disable_sta_ps_mode(tp_wma_handle wma, tpDisablePsParams ps_req) } } -/** - * wma_set_powersave_config() - update power save config in wma - * @val: new power save value - * - * This function update qpower value in wma layer - * - * Return: QDF_STATUS_SUCCESS on success, error number otherwise - */ -QDF_STATUS wma_set_powersave_config(uint8_t val) +QDF_STATUS wma_set_qpower_config(uint8_t vdev_id, uint8_t qpower) { - tp_wma_handle wma_handle; + tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA); - wma_handle = cds_get_context(QDF_MODULE_ID_WMA); - - if (!wma_handle) { + if (!wma) { WMA_LOGE("%s: WMA context is invald!", __func__); return QDF_STATUS_E_INVAL; } - wma_handle->powersave_mode = val; - return QDF_STATUS_SUCCESS; + WMA_LOGI("configuring qpower: %d", qpower); + wma->powersave_mode = qpower; + return wma_unified_set_sta_ps_param(wma->wmi_handle, + vdev_id, + WMI_STA_PS_ENABLE_QPOWER, + wma_get_qpower_config(wma)); } /**