From d1cd4aed4ffdf1ee7419a6aa0917d06863879f44 Mon Sep 17 00:00:00 2001 From: Abhishek Singh Date: Fri, 10 May 2019 11:22:21 +0530 Subject: [PATCH] qcacld-3.0: Use new scan API to get scan results in ACS ACS used old csr API's to get scan results, move it to use converged scan API. Change-Id: Ic62ac940bb6a5cc2eb3ea0e9888807ed74974d3a CRs-Fixed: 2450559 --- core/sap/src/sap_api_link_cntl.c | 128 ++++++++++++++++++------------- core/sap/src/sap_ch_select.c | 110 +++++++++++++------------- core/sap/src/sap_internal.h | 4 +- 3 files changed, 131 insertions(+), 111 deletions(-) diff --git a/core/sap/src/sap_api_link_cntl.c b/core/sap/src/sap_api_link_cntl.c index 3aabb87b0de4..59423161a29b 100644 --- a/core/sap/src/sap_api_link_cntl.c +++ b/core/sap/src/sap_api_link_cntl.c @@ -49,6 +49,7 @@ #include #include #include "wlan_reg_services_api.h" +#include #include /*---------------------------------------------------------------------------- @@ -175,17 +176,81 @@ static const char *acs_scan_done_status_str(eCsrScanStatus status) } } +#ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE +static void wlansap_send_acs_success_event(struct sap_context *sap_ctx, + uint32_t scan_id) +{ + if (scan_id) { + QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_DEBUG, + FL("Sending ACS Scan skip event")); + sap_signal_hdd_event(sap_ctx, NULL, + eSAP_ACS_SCAN_SUCCESS_EVENT, + (void *)eSAP_STATUS_SUCCESS); + } else { + QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_DEBUG, + FL("ACS scanid: %d (skipped ACS SCAN)"), + scan_id); + } +} +#else +static inline void wlansap_send_acs_success_event(struct sap_context *sap_ctx, + uint32_t scan_id) +{ +} +#endif + +static uint8_t +wlansap_calculate_chan_from_scan_result(mac_handle_t mac_handle, + struct sap_context *sap_ctx, + uint32_t scan_id) +{ + struct mac_context *mac_ctx = MAC_CONTEXT(mac_handle); + qdf_list_t *list = NULL; + struct scan_filter *filter; + uint8_t oper_channel = SAP_CHANNEL_NOT_SELECTED; + + filter = qdf_mem_malloc(sizeof(*filter)); + + if (filter) + filter->age_threshold = qdf_get_time_of_the_day_ms() - + sap_ctx->acs_req_timestamp; + + list = ucfg_scan_get_result(mac_ctx->pdev, filter); + + if (filter) + qdf_mem_free(filter); + + if (list) + QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_DEBUG, + FL("num_entries %d"), qdf_list_size(list)); + if (!list || (list && !qdf_list_size(list))) { + sme_err("get scan result failed"); + QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR, + FL("Failed to get scan results")); + if (list) + ucfg_scan_purge_results(list); + /* + * No scan results So, set the operation channel not selected + * to allow the default channel to be set when reporting to HDD + */ + return oper_channel; + } + + wlansap_send_acs_success_event(sap_ctx, scan_id); + + oper_channel = sap_select_channel(mac_handle, sap_ctx, list); + ucfg_scan_purge_results(list); + + return oper_channel; +} + QDF_STATUS wlansap_pre_start_bss_acs_scan_callback(mac_handle_t mac_handle, struct sap_context *sap_ctx, uint8_t sessionid, uint32_t scanid, eCsrScanStatus scan_status) { - tScanResultHandle presult = NULL; - QDF_STATUS scan_get_result_status = QDF_STATUS_E_FAILURE; - uint8_t oper_channel = 0; - QDF_STATUS status = QDF_STATUS_E_FAILURE; - tCsrScanResultFilter *filter; + uint8_t oper_channel = SAP_CHANNEL_NOT_SELECTED; host_log_acs_scan_done(acs_scan_done_status_str(scan_status), sessionid, scanid); @@ -206,54 +271,8 @@ QDF_STATUS wlansap_pre_start_bss_acs_scan_callback(mac_handle_t mac_handle, QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH, FL("CSR scan_status = eCSR_SCAN_SUCCESS (%d)"), scan_status); - filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter)); - if (!filter) { - QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH, - FL("Memory allocation for filter failed")); - } else { - filter->csrPersona = QDF_SAP_MODE; - filter->age_threshold = qdf_get_time_of_the_day_ms() - - sap_ctx->acs_req_timestamp; - } - /* - * Now do - * 1. Get scan results - * 2. Run channel selection algorithm - * select channel and store in sap_context->Channel - */ - scan_get_result_status = sme_scan_get_result(mac_handle, - sap_ctx->sessionId, - filter, &presult); - if (filter) - qdf_mem_free(filter); - - if ((scan_get_result_status != QDF_STATUS_SUCCESS) && - (scan_get_result_status != QDF_STATUS_E_NULL_VALUE)) { - /* - * No scan results So, set the operation channel not selected - * to allow the default channel to be set when reporting to HDD - */ - oper_channel = SAP_CHANNEL_NOT_SELECTED; - QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR, - FL("Get scan result failed! ret = %d"), - scan_get_result_status); - } else { -#ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE - if (scanid != 0) { - QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH, - FL("Sending ACS Scan skip event")); - sap_signal_hdd_event(sap_ctx, NULL, - eSAP_ACS_SCAN_SUCCESS_EVENT, - (void *) eSAP_STATUS_SUCCESS); - } else { - QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH, - FL("ACS scanid: %d (skipped ACS SCAN)"), - scanid); - } -#endif - oper_channel = sap_select_channel(mac_handle, sap_ctx, presult); - sme_scan_result_purge(presult); - } + oper_channel = wlansap_calculate_chan_from_scan_result(mac_handle, + sap_ctx, scanid); if (oper_channel == SAP_CHANNEL_NOT_SELECTED) { QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO, @@ -286,7 +305,8 @@ close_session: } #endif sap_hdd_signal_event_handler(sap_ctx); - return status; + + return QDF_STATUS_SUCCESS; } /** diff --git a/core/sap/src/sap_ch_select.c b/core/sap/src/sap_ch_select.c index b159dd58a261..167e9277b381 100644 --- a/core/sap/src/sap_ch_select.c +++ b/core/sap/src/sap_ch_select.c @@ -48,6 +48,7 @@ #include "cds_utils.h" #include "pld_common.h" #include "wlan_reg_services_api.h" +#include /*-------------------------------------------------------------------------- Function definitions @@ -324,36 +325,39 @@ sap_check_n_add_overlapped_chnls(struct sap_context *sap_ctx, */ static void sap_process_avoid_ie(mac_handle_t mac_handle, struct sap_context *sap_ctx, - tScanResultHandle scan_result, + qdf_list_t *scan_list, tSapChSelSpectInfo *spect_info) { - uint32_t total_ie_len = 0; const uint8_t *temp_ptr = NULL; uint8_t i = 0; struct sAvoidChannelIE *avoid_ch_ie; - tCsrScanResultInfo *node = NULL; struct mac_context *mac_ctx = NULL; tSapSpectChInfo *spect_ch = NULL; + qdf_list_node_t *cur_lst = NULL, *next_lst = NULL; + struct scan_cache_node *cur_node = NULL; mac_ctx = MAC_CONTEXT(mac_handle); spect_ch = spect_info->pSpectCh; - node = sme_scan_result_get_first(mac_handle, scan_result); - while (node) { - total_ie_len = - GET_IE_LEN_IN_BSS(node->BssDescriptor.length); + qdf_list_peek_front(scan_list, &cur_lst); + while (cur_lst) { + cur_node = qdf_container_of(cur_lst, struct scan_cache_node, + node); + temp_ptr = wlan_get_vendor_ie_ptr_from_oui( SIR_MAC_QCOM_VENDOR_OUI, SIR_MAC_QCOM_VENDOR_SIZE, - ((uint8_t *)&node->BssDescriptor.ieFields), - total_ie_len); + util_scan_entry_ie_data(cur_node->entry), + util_scan_entry_ie_len(cur_node->entry)); if (temp_ptr) { avoid_ch_ie = (struct sAvoidChannelIE *)temp_ptr; if (avoid_ch_ie->type != QCOM_VENDOR_IE_MCC_AVOID_CH) { - node = sme_scan_result_get_next(mac_handle, - scan_result); + qdf_list_peek_next(scan_list, + cur_lst, &next_lst); + cur_lst = next_lst; + next_lst = NULL; continue; } @@ -386,7 +390,10 @@ static void sap_process_avoid_ie(mac_handle_t mac_handle, break; } } /* if (temp_ptr) */ - node = sme_scan_result_get_next(mac_handle, scan_result); + + qdf_list_peek_next(scan_list, cur_lst, &next_lst); + cur_lst = next_lst; + next_lst = NULL; } } #endif /* FEATURE_AP_MCC_CH_AVOIDANCE */ @@ -1511,13 +1518,12 @@ static bool ch_in_pcl(struct sap_context *sap_ctx, uint8_t channel) */ static void sap_compute_spect_weight(tSapChSelSpectInfo *pSpectInfoParams, mac_handle_t mac_handle, - tScanResultHandle pResult, + qdf_list_t *scan_list, struct sap_context *sap_ctx) { int8_t rssi = 0; uint8_t chn_num = 0; uint8_t channel_id = 0; - tCsrScanResultInfo *scan_result; tSapSpectChInfo *pSpectCh = pSpectInfoParams->pSpectCh; uint32_t operatingBand; uint16_t channelWidth; @@ -1527,15 +1533,16 @@ static void sap_compute_spect_weight(tSapChSelSpectInfo *pSpectInfoParams, bool found; uint16_t centerFreq_2 = 0; uint16_t vhtSupport; - uint32_t ieLen = 0; - tSirProbeRespBeacon *pBeaconStruct; + tSirProbeRespBeacon *bcn_struct; struct mac_context *mac = MAC_CONTEXT(mac_handle); tSapSpectChInfo *spectch_start = pSpectInfoParams->pSpectCh; tSapSpectChInfo *spectch_end = pSpectInfoParams->pSpectCh + pSpectInfoParams->numSpectChans; + qdf_list_node_t *cur_lst = NULL, *next_lst = NULL; + struct scan_cache_node *cur_node = NULL; - pBeaconStruct = qdf_mem_malloc(sizeof(tSirProbeRespBeacon)); - if (!pBeaconStruct) + bcn_struct = qdf_mem_malloc(sizeof(tSirProbeRespBeacon)); + if (!bcn_struct) return; QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH, @@ -1546,9 +1553,13 @@ static void sap_compute_spect_weight(tSapChSelSpectInfo *pSpectInfoParams, */ SET_ACS_BAND(operatingBand, sap_ctx); - scan_result = sme_scan_result_get_first(mac_handle, pResult); + qdf_list_peek_front(scan_list, &cur_lst); + while (cur_lst) { + uint32_t ie_len = 0; + uint8_t *ie_ptr; - while (scan_result) { + cur_node = qdf_container_of(cur_lst, struct scan_cache_node, + node); pSpectCh = pSpectInfoParams->pSpectCh; /* Defining the default values, so that any value will hold the default values */ channelWidth = eHT_CHANNEL_WIDTH_20MHZ; @@ -1556,19 +1567,15 @@ static void sap_compute_spect_weight(tSapChSelSpectInfo *pSpectInfoParams, vhtSupport = 0; centerFreq = 0; + ie_len = util_scan_entry_ie_len(cur_node->entry); + ie_ptr = util_scan_entry_ie_data(cur_node->entry); + qdf_mem_zero((uint8_t *)bcn_struct, + sizeof(tSirProbeRespBeacon)); - ieLen = GET_IE_LEN_IN_BSS( - scan_result->BssDescriptor.length); - qdf_mem_zero((uint8_t *) pBeaconStruct, - sizeof(tSirProbeRespBeacon)); - - - if ((sir_parse_beacon_ie - (mac, pBeaconStruct, (uint8_t *) - (scan_result->BssDescriptor.ieFields), - ieLen)) == QDF_STATUS_SUCCESS) + if ((sir_parse_beacon_ie(mac, bcn_struct, ie_ptr, ie_len)) == + QDF_STATUS_SUCCESS) sap_upd_chan_spec_params( - pBeaconStruct, + bcn_struct, &channelWidth, &secondaryChannelOffset, &vhtSupport, ¢erFreq, @@ -1578,22 +1585,14 @@ static void sap_compute_spect_weight(tSapChSelSpectInfo *pSpectInfoParams, for (chn_num = 0; chn_num < pSpectInfoParams->numSpectChans; chn_num++) { - /* - * If the Beacon has channel ID, use it other wise we - * will rely on the channelIdSelf - */ - if (scan_result->BssDescriptor.channelId == 0) - channel_id = - scan_result->BssDescriptor.channelIdSelf; - else - channel_id = - scan_result->BssDescriptor.channelId; + channel_id = + util_scan_entry_channel_num(cur_node->entry); if (pSpectCh && (channel_id == pSpectCh->chNum)) { if (pSpectCh->rssiAgr < - scan_result->BssDescriptor.rssi) + cur_node->entry->rssi_raw) pSpectCh->rssiAgr = - scan_result->BssDescriptor.rssi; + cur_node->entry->rssi_raw; ++pSpectCh->bssCount; /* Increment the count of BSS */ @@ -1639,13 +1638,11 @@ static void sap_compute_spect_weight(tSapChSelSpectInfo *pSpectInfoParams, QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH, - "In %s, bssdes.ch_self=%d, bssdes.ch_ID=%d, bssdes.rssi=%d, SpectCh.bssCount=%d, scan_result=%pK, ChannelWidth %d, secondaryChanOffset %d, center frequency %d", + "In %s, channel_id=%d, bssdes.rssi=%d, SpectCh.bssCount=%d, ChannelWidth %d, secondaryChanOffset %d, center frequency %d", __func__, - scan_result->BssDescriptor. - channelIdSelf, - scan_result->BssDescriptor.channelId, - scan_result->BssDescriptor.rssi, - pSpectCh->bssCount, scan_result, + channel_id, + cur_node->entry->rssi_raw, + pSpectCh->bssCount, pSpectCh->channelWidth, secondaryChannelOffset, centerFreq); pSpectCh++; @@ -1655,9 +1652,13 @@ static void sap_compute_spect_weight(tSapChSelSpectInfo *pSpectInfoParams, } } - scan_result = sme_scan_result_get_next(mac_handle, pResult); + qdf_list_peek_next(scan_list, cur_lst, &next_lst); + cur_lst = next_lst; + next_lst = NULL; } + qdf_mem_free(bcn_struct); + /* Calculate the weights for all channels in the spectrum pSpectCh */ pSpectCh = pSpectInfoParams->pSpectCh; @@ -1734,7 +1735,6 @@ debug_info: pSpectCh++; } sap_clear_channel_status(mac); - qdf_mem_free(pBeaconStruct); } /*========================================================================== @@ -2623,7 +2623,7 @@ static uint8_t sap_select_channel_no_scan_result(mac_handle_t mac_handle, uint8_t sap_select_channel(mac_handle_t mac_handle, struct sap_context *sap_ctx, - tScanResultHandle scan_result) + qdf_list_t *scan_list) { /* DFS param object holding all the data req by the algo */ tSapChSelSpectInfo spect_info_obj = { NULL, 0 }; @@ -2649,7 +2649,7 @@ uint8_t sap_select_channel(mac_handle_t mac_handle, * If ACS weight is not enabled on noise_floor/channel_free/tx_power, * then skip acs process if no bss found. */ - if (!scan_result && + if (!scan_list && !(sap_ctx->auto_channel_select_weight & 0xffff00)) { QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH, FL("No external AP present")); @@ -2668,11 +2668,11 @@ uint8_t sap_select_channel(mac_handle_t mac_handle, return SAP_CHANNEL_NOT_SELECTED; } /* Compute the weight of the entire spectrum in the operating band */ - sap_compute_spect_weight(spect_info, mac_handle, scan_result, sap_ctx); + sap_compute_spect_weight(spect_info, mac_handle, scan_list, sap_ctx); #ifdef FEATURE_AP_MCC_CH_AVOIDANCE /* process avoid channel IE to collect all channels to avoid */ - sap_process_avoid_ie(mac_handle, sap_ctx, scan_result, spect_info); + sap_process_avoid_ie(mac_handle, sap_ctx, scan_list, spect_info); #endif /* FEATURE_AP_MCC_CH_AVOIDANCE */ wlan_reg_read_current_country(mac_ctx->psoc, country); diff --git a/core/sap/src/sap_internal.h b/core/sap/src/sap_internal.h index 7a910056666f..1156e4d23452 100644 --- a/core/sap/src/sap_internal.h +++ b/core/sap/src/sap_internal.h @@ -285,7 +285,7 @@ QDF_STATUS wlansap_pre_start_bss_acs_scan_callback(mac_handle_t mac_handle, * sap_select_channel() - select SAP channel * @mac_handle: Opaque handle to the global MAC context * @sap_ctx: Sap context - * @scan_result: Handle to scan results + * @scan_list: scan entry list * * Runs a algorithm to select the best channel to operate in based on BSS * rssi and bss count on each channel @@ -293,7 +293,7 @@ QDF_STATUS wlansap_pre_start_bss_acs_scan_callback(mac_handle_t mac_handle, * Returns: channel number if success, 0 otherwise */ uint8_t sap_select_channel(mac_handle_t mac_handle, struct sap_context *sap_ctx, - tScanResultHandle scan_result); + qdf_list_t *scan_list); QDF_STATUS sap_signal_hdd_event(struct sap_context *sap_ctx,