diff --git a/target_if/core/src/target_if_main.c b/target_if/core/src/target_if_main.c index 64cda921e2..7af4ae1691 100644 --- a/target_if/core/src/target_if_main.c +++ b/target_if/core/src/target_if_main.c @@ -577,6 +577,7 @@ QDF_STATUS target_if_free_psoc_tgt_info(struct wlan_objmgr_psoc *psoc) return QDF_STATUS_E_INVAL; } init_deinit_chainmask_table_free(ext_param); + init_deinit_rf_characterization_entries_free(ext_param); init_deinit_dbr_ring_cap_free(tgt_psoc_info); init_deinit_spectral_scaling_params_free(tgt_psoc_info); diff --git a/target_if/init_deinit/inc/service_ready_param.h b/target_if/init_deinit/inc/service_ready_param.h index 1108d0147e..8d3c2fb127 100644 --- a/target_if/init_deinit/inc/service_ready_param.h +++ b/target_if/init_deinit/inc/service_ready_param.h @@ -24,6 +24,10 @@ #define _SERVICE_READY_PARAM_H_ #include "qdf_types.h" +#ifdef WLAN_SUPPORT_RF_CHARACTERIZATION +#include "wmi_unified_param.h" +#endif + /** * struct wlan_psoc_hal_reg_capability - hal reg table in psoc @@ -285,6 +289,20 @@ struct wlan_psoc_host_chainmask_table { struct wlan_psoc_host_chainmask_capabilities *cap_list; }; +#ifdef WLAN_SUPPORT_RF_CHARACTERIZATION +/** + * struct wlan_psoc_host_rf_characterization_entry - rf characterization table + * @freq: center frequency of primary channel + * @bw: bandwidth of primary channel + * @chan_metric: primary channel-specific metric + */ +struct wlan_psoc_host_rf_characterization_entry { + uint16_t freq; + wmi_host_channel_width bw; + uint8_t chan_metric; +}; +#endif + /** * struct wlan_psoc_host_service_ext_param - EXT service base params in event * @default_conc_scan_config_bits: Default concurrenct scan config @@ -304,6 +322,8 @@ struct wlan_psoc_host_chainmask_table { * @max_bssid_indicator: Maximum number of VAPs in MBSS IE * @num_bin_scaling_params: Number of Spectral bin scaling parameters * @chainmask_table: Available chain mask tables. + * @num_rf_characterization_entries: Number of RF characterization info entries + * @rf_characterization_entries: Channel RF characterization information entries * @sar_version: SAR version info */ struct wlan_psoc_host_service_ext_param { @@ -322,6 +342,11 @@ struct wlan_psoc_host_service_ext_param { uint32_t num_bin_scaling_params; struct wlan_psoc_host_chainmask_table chainmask_table[PSOC_MAX_CHAINMASK_TABLES]; +#ifdef WLAN_SUPPORT_RF_CHARACTERIZATION + uint32_t num_rf_characterization_entries; + struct wlan_psoc_host_rf_characterization_entry + *rf_characterization_entries; +#endif uint32_t sar_version; }; diff --git a/target_if/init_deinit/inc/service_ready_util.h b/target_if/init_deinit/inc/service_ready_util.h index 898cdc05ad..a542a3699c 100644 --- a/target_if/init_deinit/inc/service_ready_util.h +++ b/target_if/init_deinit/inc/service_ready_util.h @@ -27,6 +27,50 @@ #include "service_ready_param.h" #include "target_if.h" +#ifdef WLAN_SUPPORT_RF_CHARACTERIZATION +/** + * init_deinit_populate_rf_characterization_entries() + * - allocates space for and populates the RF characterization information + * @handle: WMI handle pointer + * @evt: event buffer received from FW + * @service_ext_param: pointer to server ext param + * + * Allocates space for and populates the RF characterization information + * + * Return: QDF Status + */ +QDF_STATUS init_deinit_populate_rf_characterization_entries(void *handle, + uint8_t *evt, + struct wlan_psoc_host_service_ext_param *service_ext_par); + +/** + * init_deinit_rf_characterization_entries_free() + * - free RF characterization information + * @service_ext_param: pointer to server ext param + * + * Frees RF characterization information + * + * Return: QDF Status + */ +QDF_STATUS init_deinit_rf_characterization_entries_free( + struct wlan_psoc_host_service_ext_param *service_ext_par); +#else +static inline +QDF_STATUS init_deinit_populate_rf_characterization_entries(void *handle, + uint8_t *evt, + struct wlan_psoc_host_service_ext_param *ser_ext_par) +{ + return QDF_STATUS_SUCCESS; +} + +static inline +QDF_STATUS init_deinit_rf_characterization_entries_free( + struct wlan_psoc_host_service_ext_param *ser_ext_par) +{ + return QDF_STATUS_SUCCESS; +} +#endif + /** * init_deinit_chainmask_table_alloc() * - allocate chainmask table capability list. diff --git a/target_if/init_deinit/src/init_event_handler.c b/target_if/init_deinit/src/init_event_handler.c index c0e4205cb4..96626eebf9 100644 --- a/target_if/init_deinit/src/init_event_handler.c +++ b/target_if/init_deinit/src/init_event_handler.c @@ -270,6 +270,13 @@ static int init_deinit_service_ext_ready_event_handler(ol_scn_t scn_handle, goto exit; } + err_code = init_deinit_populate_rf_characterization_entries( + wmi_handle, + event, + &info->service_ext_param); + if (err_code) + goto exit; + err_code = init_deinit_populate_dbr_ring_cap(psoc, wmi_handle, event, info); if (err_code) diff --git a/target_if/init_deinit/src/service_ready_util.c b/target_if/init_deinit/src/service_ready_util.c index 08aa44c661..91a627fe3c 100644 --- a/target_if/init_deinit/src/service_ready_util.c +++ b/target_if/init_deinit/src/service_ready_util.c @@ -26,6 +26,51 @@ #include #include +#ifdef WLAN_SUPPORT_RF_CHARACTERIZATION +QDF_STATUS init_deinit_populate_rf_characterization_entries(void *handle, + uint8_t *evt, + struct wlan_psoc_host_service_ext_param *ser_ext_par) +{ + uint32_t alloc_size; + QDF_STATUS status = QDF_STATUS_SUCCESS; + + if (ser_ext_par->num_rf_characterization_entries == 0) + return QDF_STATUS_SUCCESS; + + alloc_size = (sizeof(struct wlan_psoc_host_rf_characterization_entry) * + ser_ext_par->num_rf_characterization_entries); + + ser_ext_par->rf_characterization_entries = qdf_mem_malloc(alloc_size); + if (!ser_ext_par->rf_characterization_entries) { + init_deinit_rf_characterization_entries_free(ser_ext_par); + return QDF_STATUS_E_NOMEM; + } + + status = wmi_extract_rf_characterization_entries(handle, evt, + ser_ext_par->rf_characterization_entries); + if (QDF_IS_STATUS_ERROR(status)) { + target_if_err("failed to parse wmi service ready ext param"); + init_deinit_rf_characterization_entries_free(ser_ext_par); + } + + return status; +} + +qdf_export_symbol(init_deinit_populate_rf_characterization_entries); + +QDF_STATUS init_deinit_rf_characterization_entries_free( + struct wlan_psoc_host_service_ext_param *ser_ext_par) +{ + qdf_mem_free(ser_ext_par->rf_characterization_entries); + ser_ext_par->rf_characterization_entries = NULL; + ser_ext_par->num_rf_characterization_entries = 0; + + return QDF_STATUS_SUCCESS; +} + +qdf_export_symbol(init_deinit_rf_characterization_entries_free); +#endif + QDF_STATUS init_deinit_chainmask_table_alloc( struct wlan_psoc_host_service_ext_param *ser_ext_par) { diff --git a/wmi/inc/wmi_unified_api.h b/wmi/inc/wmi_unified_api.h index 8ee2723e86..eb62edc3e7 100644 --- a/wmi/inc/wmi_unified_api.h +++ b/wmi/inc/wmi_unified_api.h @@ -1361,6 +1361,21 @@ QDF_STATUS wmi_extract_pdev_qvit_event(void *wmi_hdl, uint8_t *evt_buf, struct wmi_host_pdev_qvit_event *param); +#ifdef WLAN_SUPPORT_RF_CHARACTERIZATION +/** + * wmi_extract_rf_characterziation_entries - Extract RF characterization metrics + * received through extended service ready event. + * @wmi_hdl: WMI handle + * @evt_buf: Event buffer + * @rf_characterization_entries: Pointer to RF characterization metrics + * + * Return: QDF status of operation + */ +QDF_STATUS wmi_extract_rf_characterization_entries(wmi_unified_t wmi_hdl, + uint8_t *evt_buf, + struct wlan_psoc_host_rf_characterization_entry *rf_characterization_entries); +#endif + QDF_STATUS wmi_extract_chainmask_tables(void *wmi_hdl, uint8_t *evt_buf, struct wlan_psoc_host_chainmask_table *chainmask_table); /** diff --git a/wmi/inc/wmi_unified_priv.h b/wmi/inc/wmi_unified_priv.h index 6d45d8de12..464c9377a0 100644 --- a/wmi/inc/wmi_unified_priv.h +++ b/wmi/inc/wmi_unified_priv.h @@ -1738,6 +1738,12 @@ QDF_STATUS (*extract_reg_ch_avoid_event)(wmi_unified_t wmi_handle, struct ch_avoid_ind_type *ch_avoid_event, uint32_t len); +#ifdef WLAN_SUPPORT_RF_CHARACTERIZATION +QDF_STATUS (*extract_rf_characterization_entries)(wmi_unified_t wmi_handle, + uint8_t *evt_buf, + struct wlan_psoc_host_rf_characterization_entry *rf_characterization_entries); +#endif + QDF_STATUS (*extract_chainmask_tables)(wmi_unified_t wmi_handle, uint8_t *evt_buf, struct wlan_psoc_host_chainmask_table *chainmask_table); diff --git a/wmi/src/wmi_unified_api.c b/wmi/src/wmi_unified_api.c index d646e06bca..4818084630 100644 --- a/wmi/src/wmi_unified_api.c +++ b/wmi/src/wmi_unified_api.c @@ -4237,6 +4237,19 @@ wmi_unified_dfs_phyerr_offload_dis_cmd(void *wmi_hdl, return QDF_STATUS_E_FAILURE; } +#ifdef WLAN_SUPPORT_RF_CHARACTERIZATION +QDF_STATUS wmi_extract_rf_characterization_entries(wmi_unified_t wmi_hdl, + uint8_t *evt_buf, + struct wlan_psoc_host_rf_characterization_entry *rf_characterization_entries) +{ + if (wmi_hdl->ops->extract_rf_characterization_entries) + return wmi_hdl->ops->extract_rf_characterization_entries(wmi_hdl, + evt_buf, rf_characterization_entries); + + return QDF_STATUS_E_FAILURE; +} +#endif + /* * wmi_extract_chainmask_tables_tlv() - extract chain mask tables * @wmi_handle: wmi handle diff --git a/wmi/src/wmi_unified_tlv.c b/wmi/src/wmi_unified_tlv.c index b5648b3454..8dc6294204 100644 --- a/wmi/src/wmi_unified_tlv.c +++ b/wmi/src/wmi_unified_tlv.c @@ -9312,6 +9312,48 @@ static QDF_STATUS extract_pdev_utf_event_tlv(wmi_unified_t wmi_handle, return QDF_STATUS_SUCCESS; } +#ifdef WLAN_SUPPORT_RF_CHARACTERIZATION +static QDF_STATUS extract_rf_characterization_entries_tlv(wmi_unified_t wmi_handle, + uint8_t *event, + struct wlan_psoc_host_rf_characterization_entry *rf_characterization_entries) +{ + WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf; + WMI_CHAN_RF_CHARACTERIZATION_INFO *wmi_rf_characterization_entry; + uint8_t ix; + + param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *)event; + if (!param_buf) + return QDF_STATUS_E_INVAL; + + wmi_rf_characterization_entry = + param_buf->wmi_chan_rf_characterization_info; + if (!wmi_rf_characterization_entry) + return QDF_STATUS_E_INVAL; + + for (ix = 0; ix < param_buf->num_wmi_chan_rf_characterization_info; ix++) { + rf_characterization_entries[ix].freq = + WMI_CHAN_RF_CHARACTERIZATION_FREQ_GET( + &wmi_rf_characterization_entry[ix]); + + rf_characterization_entries[ix].bw = + WMI_CHAN_RF_CHARACTERIZATION_BW_GET( + &wmi_rf_characterization_entry[ix]); + + rf_characterization_entries[ix].chan_metric = + WMI_CHAN_RF_CHARACTERIZATION_CHAN_METRIC_GET( + &wmi_rf_characterization_entry[ix]); + + wmi_nofl_debug("rf_characterization_entries[%u]: freq: %u, " + "bw: %u, chan_metric: %u", + ix, rf_characterization_entries[ix].freq, + rf_characterization_entries[ix].bw, + rf_characterization_entries[ix].chan_metric); + } + + return QDF_STATUS_SUCCESS; +} +#endif + /** * extract_chainmask_tables_tlv() - extract chain mask tables from event * @wmi_handle: wmi handle @@ -9417,6 +9459,22 @@ static QDF_STATUS extract_chainmask_tables_tlv(wmi_unified_t wmi_handle, return QDF_STATUS_SUCCESS; } +#ifdef WLAN_SUPPORT_RF_CHARACTERIZATION +static void populate_num_rf_characterization_entries( + struct wlan_psoc_host_service_ext_param *param, + WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf) +{ + param->num_rf_characterization_entries = + param_buf->num_wmi_chan_rf_characterization_info; +} +#else +static void populate_num_rf_characterization_entries( + struct wlan_psoc_host_service_ext_param *param, + WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf) +{ +} +#endif + /** * extract_service_ready_ext_tlv() - extract basic extended service ready params * from event @@ -9455,6 +9513,7 @@ static QDF_STATUS extract_service_ready_ext_tlv(wmi_unified_t wmi_handle, param->num_dbr_ring_caps = param_buf->num_dma_ring_caps; param->num_bin_scaling_params = param_buf->num_wmi_bin_scaling_params; param->max_bssid_indicator = ev->max_bssid_indicator; + populate_num_rf_characterization_entries(param, param_buf); qdf_mem_copy(¶m->ppet, &ev->ppet, sizeof(param->ppet)); hw_caps = param_buf->soc_hw_mode_caps; @@ -11825,6 +11884,10 @@ struct wmi_ops tlv_ops = { .send_dfs_phyerr_offload_dis_cmd = send_dfs_phyerr_offload_dis_cmd_tlv, .extract_reg_chan_list_update_event = extract_reg_chan_list_update_event_tlv, +#ifdef WLAN_SUPPORT_RF_CHARACTERIZATION + .extract_rf_characterization_entries = + extract_rf_characterization_entries_tlv, +#endif .extract_chainmask_tables = extract_chainmask_tables_tlv, .extract_thermal_stats = extract_thermal_stats_tlv,