diff options
| author | Jeff Johnson <jjohnson@codeaurora.org> | 2017-12-14 15:50:16 -0800 |
|---|---|---|
| committer | snandini <snandini@codeaurora.org> | 2018-01-08 16:36:03 -0800 |
| commit | ceb4d61074ed9e180bc3e650f5d98df3d61e85d8 (patch) | |
| tree | 83d2cab6460bf6a06b4d9afe97a5bbcafe02c9be | |
| parent | 4e887a6e0a74ebf50b9eb672b9915439fdfb7d5c (diff) | |
qcacmn: Add support to retrieve SAR power limits
Recently change "qcacmn: Add SAR power limit configuration"
(Change-Id: I0a214a2af780e9dd8c381c4e9eaa7d8cab6ef853) added the
ability to dynamically configure Specific Absorption Rate (SAR) power
limits. Now add the ability to retrieve the current active power
limits.
Change-Id: I7a6071dee71300daa3a217780ff3523604a11795
CRs-Fixed: 2161451
| -rw-r--r-- | wmi/inc/wmi_unified_api.h | 34 | ||||
| -rw-r--r-- | wmi/inc/wmi_unified_param.h | 43 | ||||
| -rw-r--r-- | wmi/inc/wmi_unified_priv.h | 9 | ||||
| -rw-r--r-- | wmi/src/wmi_unified_api.c | 26 | ||||
| -rw-r--r-- | wmi/src/wmi_unified_tlv.c | 95 |
5 files changed, 199 insertions, 8 deletions
diff --git a/wmi/inc/wmi_unified_api.h b/wmi/inc/wmi_unified_api.h index ce313caa9c00..ab275c11217e 100644 --- a/wmi/inc/wmi_unified_api.h +++ b/wmi/inc/wmi_unified_api.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2017 The Linux Foundation. All rights reserved. + * Copyright (c) 2013-2018 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -1390,8 +1390,38 @@ QDF_STATUS wmi_extract_vdev_extd_stats(void *wmi_hdl, void *evt_buf, QDF_STATUS wmi_unified_send_power_dbg_cmd(void *wmi_hdl, struct wmi_power_dbg_params *param); + +/** + * wmi_unified_send_sar_limit_cmd() - send sar limit cmd to fw + * @wmi_hdl: wmi handle + * @params: sar limit command params + * + * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure + */ QDF_STATUS wmi_unified_send_sar_limit_cmd(void *wmi_hdl, - struct sar_limit_cmd_params *params); + struct sar_limit_cmd_params *params); + +/** + * wmi_unified_get_sar_limit_cmd() - request current SAR limits from FW + * @wmi_hdl: wmi handle + * + * Return: QDF_STATUS_SUCCESS for success or error code + */ +QDF_STATUS wmi_unified_get_sar_limit_cmd(void *wmi_hdl); + +/** + * wmi_unified_extract_sar_limit_event() - extract SAR limits from FW event + * @wmi_hdl: wmi handle + * @evt_buf: event buffer received from firmware + * @event: SAR limit event which is to be populated by data extracted from + * the @evt_buf buffer + * + * Return: QDF_STATUS_SUCCESS for success or error code + */ +QDF_STATUS wmi_unified_extract_sar_limit_event(void *wmi_hdl, + uint8_t *evt_buf, + struct sar_limit_event *event); + QDF_STATUS wmi_unified_send_adapt_dwelltime_params_cmd(void *wmi_hdl, struct wmi_adaptive_dwelltime_params * wmi_param); diff --git a/wmi/inc/wmi_unified_param.h b/wmi/inc/wmi_unified_param.h index 7cb1934e7d3b..253db75450b1 100644 --- a/wmi/inc/wmi_unified_param.h +++ b/wmi/inc/wmi_unified_param.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2017 The Linux Foundation. All rights reserved. + * Copyright (c) 2016-2018 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -5297,6 +5297,7 @@ typedef enum { wmi_tx_data_traffic_ctrl_event_id, wmi_update_rcpi_event_id, wmi_get_arp_stats_req_id, + wmi_sar_get_limits_event_id, wmi_events_max, } wmi_conv_event_id; @@ -7211,12 +7212,15 @@ struct encrypt_decrypt_req_params { #define MAX_SAR_LIMIT_ROWS_SUPPORTED 64 /** - * struct sar_limit_cmd_row - sar limts row + * struct sar_limit_cmd_row - sar limits row * @band_id: Optional param for frequency band + * See %enum wmi_sar_band_id_flags for possible values * @chain_id: Optional param for antenna chain id * @mod_id: Optional param for modulation scheme + * See %enum wmi_sar_mod_id_flags for possible values * @limit_value: Mandatory param providing power limits in steps of 0.5 dbm * @validity_bitmap: bitmap of valid optional params in sar_limit_cmd_row struct + * See WMI_SAR_*_VALID_MASK for possible values */ struct sar_limit_cmd_row { uint32_t band_id; @@ -7227,8 +7231,9 @@ struct sar_limit_cmd_row { }; /** - * struct sar_limit_cmd_params - sar limts params + * struct sar_limit_cmd_params - sar limits params * @sar_enable: flag to enable SAR + * See %enum wmi_sar_feature_state_flags for possible values * @num_limit_rows: number of items in sar_limits * @commit_limits: indicates firmware to start apply new SAR values * @sar_limit_row_list: pointer to array of sar limit rows @@ -7241,6 +7246,38 @@ struct sar_limit_cmd_params { }; /** + * struct sar_limit_event_row - sar limits row + * @band_id: Frequency band. + * See %enum wmi_sar_band_id_flags for possible values + * @chain_id: Chain id + * @mod_id: Modulation scheme + * See %enum wmi_sar_mod_id_flags for possible values + * @limit_value: Power limits in steps of 0.5 dbm that is currently active for + * the given @band_id, @chain_id, and @mod_id + */ +struct sar_limit_event_row { + uint32_t band_id; + uint32_t chain_id; + uint32_t mod_id; + uint32_t limit_value; +}; + +/** + * struct sar_limit_event - sar limits params + * @sar_enable: Current status of SAR enablement. + * See %enum wmi_sar_feature_state_flags for possible values + * @num_limit_rows: number of items in sar_limits + * @sar_limit_row: array of sar limit rows. Only @num_limit_rows + * should be considered valid. + */ +struct sar_limit_event { + uint32_t sar_enable; + uint32_t num_limit_rows; + struct sar_limit_event_row + sar_limit_row[MAX_SAR_LIMIT_ROWS_SUPPORTED]; +}; + +/** * enum rcpi_measurement_type - for identifying type of rcpi measurement * @RCPI_MEASUREMENT_TYPE_AVG_MGMT: avg rcpi of mgmt frames * @RCPI_MEASUREMENT_TYPE_AVG_DATA: avg rcpi of data frames diff --git a/wmi/inc/wmi_unified_priv.h b/wmi/inc/wmi_unified_priv.h index a7babc87e3e4..27f9f57949c3 100644 --- a/wmi/inc/wmi_unified_priv.h +++ b/wmi/inc/wmi_unified_priv.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2017 The Linux Foundation. All rights reserved. + * Copyright (c) 2013-2018 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -1200,6 +1200,13 @@ QDF_STATUS (*send_action_oui_cmd)(wmi_unified_t wmi_handle, QDF_STATUS (*send_sar_limit_cmd)(wmi_unified_t wmi_handle, struct sar_limit_cmd_params *params); + +QDF_STATUS (*get_sar_limit_cmd)(wmi_unified_t wmi_handle); + +QDF_STATUS (*extract_sar_limit_event)(wmi_unified_t wmi_handle, + uint8_t *evt_buf, + struct sar_limit_event *event); + uint16_t (*wmi_set_htc_tx_tag)(wmi_unified_t wmi_handle, wmi_buf_t buf, uint32_t cmd_id); diff --git a/wmi/src/wmi_unified_api.c b/wmi/src/wmi_unified_api.c index fe3174c67f27..976d17124587 100644 --- a/wmi/src/wmi_unified_api.c +++ b/wmi/src/wmi_unified_api.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2017 The Linux Foundation. All rights reserved. + * Copyright (c) 2016-2018 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -6362,6 +6362,30 @@ QDF_STATUS wmi_unified_send_sar_limit_cmd(void *wmi_hdl, return QDF_STATUS_E_FAILURE; } +QDF_STATUS wmi_unified_get_sar_limit_cmd(void *wmi_hdl) +{ + wmi_unified_t wmi_handle = wmi_hdl; + + if (wmi_handle->ops->get_sar_limit_cmd) + return wmi_handle->ops->get_sar_limit_cmd(wmi_handle); + + return QDF_STATUS_E_FAILURE; +} + +QDF_STATUS wmi_unified_extract_sar_limit_event(void *wmi_hdl, + uint8_t *evt_buf, + struct sar_limit_event *event) +{ + wmi_unified_t wmi_handle = wmi_hdl; + + if (wmi_handle->ops->extract_sar_limit_event) + return wmi_handle->ops->extract_sar_limit_event(wmi_handle, + evt_buf, + event); + + return QDF_STATUS_E_FAILURE; +} + /** * wmi_unified_encrypt_decrypt_send_cmd() - send encryptdecrypt cmd to fw * @wmi_hdl: wmi handle diff --git a/wmi/src/wmi_unified_tlv.c b/wmi/src/wmi_unified_tlv.c index 69b29214b436..fa58de8ba701 100644 --- a/wmi/src/wmi_unified_tlv.c +++ b/wmi/src/wmi_unified_tlv.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2017 The Linux Foundation. All rights reserved. + * Copyright (c) 2016-2018 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -4016,6 +4016,95 @@ end: return qdf_status; } +static QDF_STATUS get_sar_limit_cmd_tlv(wmi_unified_t wmi_handle) +{ + wmi_sar_get_limits_cmd_fixed_param *cmd; + wmi_buf_t wmi_buf; + uint32_t len; + QDF_STATUS status; + + WMI_LOGD(FL("Enter")); + + len = sizeof(*cmd); + wmi_buf = wmi_buf_alloc(wmi_handle, len); + if (!wmi_buf) { + WMI_LOGP(FL("failed to allocate memory for msg")); + return QDF_STATUS_E_NOMEM; + } + + cmd = (wmi_sar_get_limits_cmd_fixed_param *)wmi_buf_data(wmi_buf); + + WMITLV_SET_HDR(&cmd->tlv_header, + WMITLV_TAG_STRUC_wmi_sar_get_limits_cmd_fixed_param, + WMITLV_GET_STRUCT_TLVLEN + (wmi_sar_get_limits_cmd_fixed_param)); + + cmd->reserved = 0; + + status = wmi_unified_cmd_send(wmi_handle, wmi_buf, len, + WMI_SAR_GET_LIMITS_CMDID); + if (QDF_IS_STATUS_ERROR(status)) { + WMI_LOGE(FL("Failed to send get SAR limit cmd: %d"), status); + wmi_buf_free(wmi_buf); + } + + WMI_LOGD(FL("Exit")); + + return status; +} + +static QDF_STATUS extract_sar_limit_event_tlv(wmi_unified_t wmi_handle, + uint8_t *evt_buf, + struct sar_limit_event *event) +{ + wmi_sar_get_limits_event_fixed_param *fixed_param; + WMI_SAR_GET_LIMITS_EVENTID_param_tlvs *param_buf; + wmi_sar_get_limit_event_row *row_in; + struct sar_limit_event_row *row_out; + uint32_t row; + + if (!evt_buf) { + WMI_LOGE(FL("input event is NULL")); + return QDF_STATUS_E_INVAL; + } + if (!event) { + WMI_LOGE(FL("output event is NULL")); + return QDF_STATUS_E_INVAL; + } + + param_buf = (WMI_SAR_GET_LIMITS_EVENTID_param_tlvs *)evt_buf; + + fixed_param = param_buf->fixed_param; + if (!fixed_param) { + WMI_LOGE(FL("Invalid fixed param")); + return QDF_STATUS_E_INVAL; + } + + event->sar_enable = fixed_param->sar_enable; + event->num_limit_rows = fixed_param->num_limit_rows; + + if (event->num_limit_rows > MAX_SAR_LIMIT_ROWS_SUPPORTED) { + QDF_ASSERT(0); + WMI_LOGE(FL("Num rows %d exceeds max of %d"), + event->num_limit_rows, + MAX_SAR_LIMIT_ROWS_SUPPORTED); + event->num_limit_rows = MAX_SAR_LIMIT_ROWS_SUPPORTED; + } + + row_in = param_buf->sar_get_limits; + row_out = &event->sar_limit_row[0]; + for (row = 0; row < event->num_limit_rows; row++) { + row_out->band_id = row_in->band_id; + row_out->chain_id = row_in->chain_id; + row_out->mod_id = row_in->mod_id; + row_out->limit_value = row_in->limit_value; + row_out++; + row_in++; + } + + return QDF_STATUS_SUCCESS; +} + /** * send_encrypt_decrypt_send_cmd() - send encrypt/decrypt cmd to fw * @wmi_handle: wmi handle @@ -14596,6 +14685,8 @@ struct wmi_ops tlv_ops = { .send_encrypt_decrypt_send_cmd = send_encrypt_decrypt_send_cmd_tlv, .send_sar_limit_cmd = send_sar_limit_cmd_tlv, + .get_sar_limit_cmd = get_sar_limit_cmd_tlv, + .extract_sar_limit_event = extract_sar_limit_event_tlv, .send_per_roam_config_cmd = send_per_roam_config_cmd_tlv, .send_action_oui_cmd = send_action_oui_cmd_tlv, .wmi_set_htc_tx_tag = wmi_set_htc_tx_tag_tlv, @@ -14962,6 +15053,8 @@ static void populate_tlv_events_id(uint32_t *event_ids) WMI_SOC_SET_DUAL_MAC_CONFIG_RESP_EVENTID; event_ids[wmi_update_rcpi_event_id] = WMI_UPDATE_RCPI_EVENTID; event_ids[wmi_get_arp_stats_req_id] = WMI_VDEV_GET_ARP_STATS_EVENTID; + event_ids[wmi_sar_get_limits_event_id] = WMI_SAR_GET_LIMITS_EVENTID; +} } /** |
