diff options
| author | Padma, Santhosh Kumar <skpadma@codeaurora.org> | 2016-10-28 15:25:51 +0530 |
|---|---|---|
| committer | Anjaneedevi Kapparapu <akappa@codeaurora.org> | 2016-11-16 18:40:48 +0530 |
| commit | 2c8685a39b892d68acaedc757b7bd5934eac861c (patch) | |
| tree | fca8ceffeb2962dee3090d8457ba0db81b2cc868 | |
| parent | c987164936eef830a31fba3ab0c6296c0e3c85fb (diff) | |
qcacld-2.0: Send max tx power per band via SME queue
prima to qcacld-2.0 propagation
Currently for set max tx power per band, driver doesn't check for
current power state and directly passes that to firmware. This can
lead to crash if device is in IMPS state as firmware tries to
access phy register in chip power down state. Fix this by sending
max tx power per band request via SME queue.
Change-Id: Ic09744e0caef73ac450f5016076afa49d397bc33
CRs-Fixed: 1077944
| -rw-r--r-- | CORE/HDD/src/wlan_hdd_wext.c | 10 | ||||
| -rw-r--r-- | CORE/SME/inc/csrApi.h | 11 | ||||
| -rw-r--r-- | CORE/SME/inc/smeInside.h | 2 | ||||
| -rw-r--r-- | CORE/SME/inc/smeInternal.h | 1 | ||||
| -rw-r--r-- | CORE/SME/inc/sme_Api.h | 22 | ||||
| -rw-r--r-- | CORE/SME/src/sme_common/sme_Api.c | 148 |
6 files changed, 143 insertions, 51 deletions
diff --git a/CORE/HDD/src/wlan_hdd_wext.c b/CORE/HDD/src/wlan_hdd_wext.c index b20019077ec6..b0ab7ae3f223 100644 --- a/CORE/HDD/src/wlan_hdd_wext.c +++ b/CORE/HDD/src/wlan_hdd_wext.c @@ -6119,10 +6119,13 @@ static int __iw_setint_getnone(struct net_device *dev, } case WE_SET_MAX_TX_POWER_2_4: { + if (NULL == hHal) + return -EINVAL; + hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm for 2.4 GHz band", __func__, set_value); - if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value) != + if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value, hHal) != eHAL_STATUS_SUCCESS) { hddLog(VOS_TRACE_LEVEL_ERROR, @@ -6135,10 +6138,13 @@ static int __iw_setint_getnone(struct net_device *dev, } case WE_SET_MAX_TX_POWER_5_0: { + if (NULL == hHal) + return -EINVAL; + hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm for 5.0 GHz band", __func__, set_value); - if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value) != + if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value, hHal) != eHAL_STATUS_SUCCESS) { hddLog(VOS_TRACE_LEVEL_ERROR, diff --git a/CORE/SME/inc/csrApi.h b/CORE/SME/inc/csrApi.h index f1b99b69f1fb..9fd7275ea93f 100644 --- a/CORE/SME/inc/csrApi.h +++ b/CORE/SME/inc/csrApi.h @@ -1730,6 +1730,17 @@ struct tagCsrDelStaParams }; /** + * struct csr_set_tx_max_pwr_per_band - Req params to + * set max tx power per band + * @band: band for which power to be set + * @power: power to set in dB + */ +struct csr_set_tx_max_pwr_per_band { + eCsrBand band; + tPowerdBm power; +}; + +/** * struct wep_update_default_key_idx: wep default key index structure * * @session_id: session ID for the connection session diff --git a/CORE/SME/inc/smeInside.h b/CORE/SME/inc/smeInside.h index e8693b6cf406..72ed6bcade70 100644 --- a/CORE/SME/inc/smeInside.h +++ b/CORE/SME/inc/smeInside.h @@ -214,6 +214,8 @@ typedef struct tagSmeCmd tTdlsCmd tdlsCmd; #endif struct s_ani_set_tx_max_pwr set_tx_max_pwr; + struct csr_set_tx_max_pwr_per_band set_tx_max_pwr_per_band; + #ifdef WLAN_FEATURE_NAN_DATAPATH struct ndp_initiator_req initiator_req; struct ndp_responder_req responder_req; diff --git a/CORE/SME/inc/smeInternal.h b/CORE/SME/inc/smeInternal.h index b21e58083e56..eb6fd44e0e28 100644 --- a/CORE/SME/inc/smeInternal.h +++ b/CORE/SME/inc/smeInternal.h @@ -70,6 +70,7 @@ typedef enum eSmeCommandType eSmeCommandAddStaSession, eSmeCommandDelStaSession, eSmeCommandSetMaxTxPower, + eSmeCommandSetMaxTxPowerPerBand, #ifdef FEATURE_WLAN_TDLS //eSmeTdlsCommandMask = 0x80000, //To identify TDLS commands <TODO> //These can be considered as csr commands. diff --git a/CORE/SME/inc/sme_Api.h b/CORE/SME/inc/sme_Api.h index cf3acf035e43..b57053999f03 100644 --- a/CORE/SME/inc/sme_Api.h +++ b/CORE/SME/inc/sme_Api.h @@ -2500,15 +2500,19 @@ tANI_BOOLEAN sme_IsChannelValid(tHalHandle hHal, tANI_U8 channel); eHalStatus sme_SetMaxTxPower(tHalHandle hHal, tSirMacAddr pBssid, tSirMacAddr pSelfMacAddress, v_S7_t dB); -/* --------------------------------------------------------------------------- - \fn sme_SetMaxTxPowerPerBand - \brief Used to set the Maximum Transmit Power for - specific band dynamically. Note: this setting will not persist over reboots - \param band - \param power to set in dB - \- return eHalStatus - -------------------------------------------------------------------------*/ -eHalStatus sme_SetMaxTxPowerPerBand(eCsrBand band, v_S7_t db); +/** + * sme_SetMaxTxPowerPerBand() - Set the Maximum Transmit Power + * specific to band dynamically + * @band: Band for which power needs to be applied + * @dB: power to set in dB + * @hal: HAL handle + * + * Set the maximum transmit power dynamically per band + * + * Return: eHalStatus + */ +eHalStatus sme_SetMaxTxPowerPerBand(eCsrBand band, v_S7_t dB, + tHalHandle hal); /* --------------------------------------------------------------------------- \fn sme_SetTxPower diff --git a/CORE/SME/src/sme_common/sme_Api.c b/CORE/SME/src/sme_common/sme_Api.c index 1d72d08d60d8..e5bc5161bc17 100644 --- a/CORE/SME/src/sme_common/sme_Api.c +++ b/CORE/SME/src/sme_common/sme_Api.c @@ -131,6 +131,9 @@ eHalStatus sme_ProcessChannelChangeResp(tpAniSirGlobal pMac, v_U16_t msg_type,void *pMsgBuf); eHalStatus sme_process_set_max_tx_power(tpAniSirGlobal pMac, tSmeCmd *command); +eHalStatus +sme_process_set_max_tx_power_per_band(tpAniSirGlobal mac_ctx, + tSmeCmd *command); //Internal SME APIs eHalStatus sme_AcquireGlobalLock( tSmeStruct *psSme) @@ -1078,6 +1081,18 @@ sme_process_cmd: csrReleaseCommand(pMac, pCommand); } break; + case eSmeCommandSetMaxTxPowerPerBand: + csrLLUnlock(&pMac->sme.smeCmdActiveList); + sme_process_set_max_tx_power_per_band(pMac, + pCommand); + /* We need to re-run the command */ + fContinue = eANI_BOOLEAN_TRUE; + /* No Rsp expected, free cmd from active list */ + if (csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, + &pCommand->Link, LL_ACCESS_LOCK)) { + csrReleaseCommand(pMac, pCommand); + } + break; #ifdef FEATURE_OEM_DATA_SUPPORT case eSmeCommandOemDataReq: @@ -5372,6 +5387,49 @@ eHalStatus sme_process_set_max_tx_power(tpAniSirGlobal pMac, return eHAL_STATUS_SUCCESS; } +/** + * sme_process_set_max_tx_power_per_band() - Set the Maximum Transmit Power + * specific to band dynamically + * @mac_ctx: mac context + * @command: cmd param containing band, and power in db + * + * Set the maximum transmit power dynamically per band + * + * Return: eHalStatus + */ +eHalStatus sme_process_set_max_tx_power_per_band(tpAniSirGlobal mac_ctx, + tSmeCmd *command) +{ + vos_msg_t msg; + tMaxTxPowerPerBandParams *max_tx_params_per_band; + + max_tx_params_per_band = + vos_mem_malloc(sizeof(*max_tx_params_per_band)); + if (max_tx_params_per_band == NULL) { + smsLog(mac_ctx, LOGE, + FL("fail to allocate memory")); + return eHAL_STATUS_FAILURE; + } + + max_tx_params_per_band->bandInfo = + command->u.set_tx_max_pwr_per_band.band; + max_tx_params_per_band->power = + command->u.set_tx_max_pwr_per_band.power; + + msg.type = WDA_SET_MAX_TX_POWER_PER_BAND_REQ; + msg.reserved = 0; + msg.bodyptr = max_tx_params_per_band; + + if (VOS_STATUS_SUCCESS != + vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)) { + smsLog(mac_ctx, LOGE, + FL("Unable to post message to WDA")); + vos_mem_free(max_tx_params_per_band); + return eHAL_STATUS_FAILURE; + } + return eHAL_STATUS_SUCCESS; +} + /* --------------------------------------------------------------------------- \fn sme_QueryPowerState \brief Returns the current power state of the device. @@ -9687,50 +9745,60 @@ eHalStatus sme_WakeReasonIndCallback (tHalHandle hHal, void* pMsg) } #endif // WLAN_WAKEUP_EVENTS - -/* --------------------------------------------------------------------------- - \fn sme_SetMaxTxPowerPerBand - - \brief Set the Maximum Transmit Power specific to band dynamically. - Note: this setting will not persist over reboots. - - \param band - \param power to set in dB - \- return eHalStatus - - ----------------------------------------------------------------------------*/ -eHalStatus sme_SetMaxTxPowerPerBand(eCsrBand band, v_S7_t dB) +/** + * sme_SetMaxTxPowerPerBand() - Set the Maximum Transmit Power + * specific to band dynamically + * @band: Band for which power needs to be applied + * @dB: power to set in dB + * @hal: HAL handle + * + * Set the maximum transmit power dynamically per band + * + * Return: eHalStatus + */ +eHalStatus sme_SetMaxTxPowerPerBand(eCsrBand band, v_S7_t dB, + tHalHandle hal) { - vos_msg_t msg; - tpMaxTxPowerPerBandParams pMaxTxPowerPerBandParams = NULL; - - pMaxTxPowerPerBandParams = vos_mem_malloc(sizeof(tMaxTxPowerPerBandParams)); - if (NULL == pMaxTxPowerPerBandParams) - { - VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, - "%s:Not able to allocate memory for pMaxTxPowerPerBandParams", - __func__); - return eHAL_STATUS_FAILURE; - } + vos_msg_t msg; + eHalStatus status; + tSmeCmd *set_max_tx_pwr_per_band; + tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal); - pMaxTxPowerPerBandParams->power = dB; - pMaxTxPowerPerBandParams->bandInfo = band; + smsLog(mac_ctx, LOG1, + FL("band : %d power %d dB"), + band, dB); - msg.type = WDA_SET_MAX_TX_POWER_PER_BAND_REQ; - msg.reserved = 0; - msg.bodyptr = pMaxTxPowerPerBandParams; - MTRACE(vos_trace(VOS_MODULE_ID_SME, TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, - msg.type)); - if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)) - { - VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, - "%s:Not able to post WDA_SET_MAX_TX_POWER_PER_BAND_REQ", - __func__); - vos_mem_free(pMaxTxPowerPerBandParams); - return eHAL_STATUS_FAILURE; - } + MTRACE(vos_trace(VOS_MODULE_ID_SME, + TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, msg.type)); - return eHAL_STATUS_SUCCESS; + status = sme_AcquireGlobalLock(&mac_ctx->sme); + if (HAL_STATUS_SUCCESS(status)) { + set_max_tx_pwr_per_band = csrGetCommandBuffer(mac_ctx); + if (set_max_tx_pwr_per_band) { + set_max_tx_pwr_per_band->command = + eSmeCommandSetMaxTxPowerPerBand; + set_max_tx_pwr_per_band->u. + set_tx_max_pwr_per_band.band = band; + set_max_tx_pwr_per_band->u. + set_tx_max_pwr_per_band.power = dB; + status = csrQueueSmeCommand(mac_ctx, + set_max_tx_pwr_per_band, + eANI_BOOLEAN_TRUE); + if (!HAL_STATUS_SUCCESS(status)) { + smsLog(mac_ctx, LOGE, + FL("fail to send msg status = %d"), + status); + csrReleaseCommand(mac_ctx, + set_max_tx_pwr_per_band); + } + } else { + smsLog(mac_ctx, LOGE, + FL("can not obtain a common buffer")); + status = eHAL_STATUS_RESOURCES; + } + sme_ReleaseGlobalLock(&mac_ctx->sme); + } + return status; } /** |
