diff --git a/core/hdd/src/wlan_hdd_hostapd.c b/core/hdd/src/wlan_hdd_hostapd.c index 0cfd992f9448..5fd339d0169d 100644 --- a/core/hdd/src/wlan_hdd_hostapd.c +++ b/core/hdd/src/wlan_hdd_hostapd.c @@ -4555,6 +4555,13 @@ int wlan_hdd_cfg80211_start_bss(struct hdd_adapter *adapter, clear_bit(ACS_PENDING, &adapter->event_flags); clear_bit(ACS_IN_PROGRESS, &hdd_ctx->g_event_flags); + pConfig = &adapter->session.ap.sap_config; + if (!pConfig->channel) { + hdd_err("Invalid channel"); + ret = -EINVAL; + goto free; + } + /* Mark the indoor channel (passive) to disable */ if (iniConfig->force_ssc_disable_indoor_channel) { hdd_update_indoor_channel(hdd_ctx, true); @@ -4578,10 +4585,8 @@ int wlan_hdd_cfg80211_start_bss(struct hdd_adapter *adapter, hdd_check_and_disconnect_sta_on_invalid_channel( hdd_ctx); } - pConfig = &adapter->session.ap.sap_config; pBeacon = adapter->session.ap.beacon; - pMgmt_frame = (struct ieee80211_mgmt *)pBeacon->head; pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int; @@ -4670,28 +4675,22 @@ int wlan_hdd_cfg80211_start_bss(struct hdd_adapter *adapter, } } - /* - * If auto channel is configured i.e. channel is 0, - * so skip channel validation. - */ - if (AUTO_CHANNEL_SELECT != pConfig->channel) { - if (QDF_STATUS_SUCCESS != - wlan_hdd_validate_operation_channel(adapter, + if (QDF_STATUS_SUCCESS != + wlan_hdd_validate_operation_channel(adapter, pConfig->channel)) { - hdd_err("Invalid Channel: %d", pConfig->channel); - ret = -EINVAL; - goto error; - } + hdd_err("Invalid Channel: %d", pConfig->channel); + ret = -EINVAL; + goto error; + } - /* reject SAP if DFS channel scan is not allowed */ - if (!(hdd_ctx->config->enableDFSChnlScan) && - (CHANNEL_STATE_DFS == - wlan_reg_get_channel_state(hdd_ctx->hdd_pdev, - pConfig->channel))) { - hdd_err("No SAP start on DFS channel"); - ret = -EOPNOTSUPP; - goto error; - } + /* reject SAP if DFS channel scan is not allowed */ + if (!(hdd_ctx->config->enableDFSChnlScan) && + (CHANNEL_STATE_DFS == + wlan_reg_get_channel_state(hdd_ctx->hdd_pdev, + pConfig->channel))) { + hdd_err("No SAP start on DFS channel"); + ret = -EOPNOTSUPP; + goto error; } if (iniConfig->ignoreCAC || @@ -5570,6 +5569,11 @@ static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy, channel_width = wlan_hdd_get_channel_bw(params->chandef.width); channel = ieee80211_frequency_to_channel( params->chandef.chan->center_freq); + if (!channel) { + hdd_err("Invalid channel"); + return -EINVAL; + } + adapter->session.ap.sap_config.ch_params.center_freq_seg0 = cds_freq_to_chan(params->chandef.center_freq1); adapter->session.ap.sap_config.ch_params.center_freq_seg1 = @@ -5588,8 +5592,8 @@ static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy, /* if sta_sap_scc_on_dfs_chan ini is set, DFS master capability is * assumed disabled in the driver. */ - if (channel && (reg_get_channel_state(hdd_ctx->hdd_pdev, channel) == - CHANNEL_STATE_DFS) && sta_sap_scc_on_dfs_chan && !sta_cnt) { + if ((reg_get_channel_state(hdd_ctx->hdd_pdev, channel) == + CHANNEL_STATE_DFS) && sta_sap_scc_on_dfs_chan && !sta_cnt) { hdd_err("SAP not allowed on DFS channel!!"); return -EINVAL; } @@ -5599,11 +5603,6 @@ static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy, enum phy_ch_width sub_20_ch_width = CH_WIDTH_INVALID; tsap_config_t *sap_cfg = &adapter->session.ap.sap_config; - /* Avoid ACS/DFS, and overwrite ch wd to 20 */ - if (channel == 0) { - hdd_err("Can't start SAP-ACS (channel=0) with sub 20 MHz ch width"); - return -EINVAL; - } if (CHANNEL_STATE_DFS == wlan_reg_get_channel_state( hdd_ctx->hdd_pdev, channel)) { hdd_err("Can't start SAP-DFS (channel=%d)with sub 20 MHz ch wd", diff --git a/core/sap/src/sap_api_link_cntl.c b/core/sap/src/sap_api_link_cntl.c index 97bd859c445f..131fb07deff4 100644 --- a/core/sap/src/sap_api_link_cntl.c +++ b/core/sap/src/sap_api_link_cntl.c @@ -80,137 +80,6 @@ * Function Declarations and Documentation * -------------------------------------------------------------------------*/ -QDF_STATUS wlansap_scan_callback(tHalHandle hal_handle, - struct sap_context *sap_ctx, - uint8_t session_id, - uint32_t scan_id, eCsrScanStatus scan_status) -{ - tScanResultHandle result = NULL; - QDF_STATUS get_result_status = QDF_STATUS_E_FAILURE; - tWLAN_SAPEvent sapEvent; /* State machine event */ - uint8_t operChannel = 0; - QDF_STATUS sap_sm_status; - uint32_t event; - tpAniSirGlobal mac_ctx; - - - if (NULL != hal_handle) { - mac_ctx = PMAC_STRUCT(hal_handle); - } else { - QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR, - "In %s invalid hHal", __func__); - return QDF_STATUS_E_FAILURE; - } - if (sap_ctx->sapsMachine == eSAP_DISCONNECTED) { - QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_WARN, - "In %s BSS already stopped", __func__); - if (sap_ctx->channelList != NULL) { - qdf_mem_free(sap_ctx->channelList); - sap_ctx->channelList = NULL; - sap_ctx->num_of_channel = 0; - } - return QDF_STATUS_E_FAILURE; - } - - switch (scan_status) { - case eCSR_SCAN_SUCCESS: - /* sapScanCompleteCallback with eCSR_SCAN_SUCCESS */ - QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH, - "In %s, CSR scanStatus = %s (%d)", __func__, - "eCSR_SCAN_SUCCESS", scan_status); - - /** - * Get scan results, Run channel selection algorithm, - * select channel and keep in sap_ctx->Channel - */ - get_result_status = - sme_scan_get_result(hal_handle, sap_ctx->sessionId, NULL, - &result); - - event = eSAP_MAC_SCAN_COMPLETE; - - if ((get_result_status != QDF_STATUS_SUCCESS) - && (get_result_status != QDF_STATUS_E_NULL_VALUE)) { - /* No scan results */ - QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR, - "In %s, Get scan result failed! ret = %d", - __func__, get_result_status); - break; - } -#ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE - if (scan_id != 0) { - QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH, - "%s: Sending ACS Scan skip event", __func__); - 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, - "%s: ACS scan id: %d (skipped ACS SCAN)", - __func__, scan_id); -#endif - operChannel = sap_select_channel(hal_handle, sap_ctx, result); - sme_scan_result_purge(result); - break; - - default: - event = eSAP_CHANNEL_SELECTION_FAILED; - QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH, - "In %s, CSR scanStatus = %s (%d)", __func__, - "eCSR_SCAN_ABORT/FAILURE", scan_status); - } - - if (operChannel == SAP_CHANNEL_NOT_SELECTED) -#ifdef SOFTAP_CHANNEL_RANGE - { - QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH, - "%s: No suitable channel selected due to DFS, LTE" - "COEX and concurrent mode restrictions", __func__); - - sap_ctx->sapsMachine = eSAP_CH_SELECT; - event = eSAP_CHANNEL_SELECTION_FAILED; - } -#else - sap_ctx->channel = SAP_DEFAULT_24GHZ_CHANNEL; -#endif - else { - sap_ctx->channel = operChannel; - } - - sap_ctx->ch_params.ch_width = sap_ctx->acs_cfg->ch_width; - wlan_reg_set_channel_params(mac_ctx->pdev, sap_ctx->channel, - sap_ctx->secondary_ch, - &sap_ctx->ch_params); -#ifdef SOFTAP_CHANNEL_RANGE - if (sap_ctx->channelList != NULL) { - /* Always free up the memory for channel selection whatever - * the result */ - qdf_mem_free(sap_ctx->channelList); - sap_ctx->channelList = NULL; - sap_ctx->num_of_channel = 0; - } -#endif - - QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH, - "In %s, Channel selected = %d", __func__, - sap_ctx->channel); - - /* Fill in the event structure */ - sapEvent.event = event; - /* pCsrRoamInfo; */ - sapEvent.params = 0; - /* roamstatus */ - sapEvent.u1 = scan_status; - /* roamResult */ - sapEvent.u2 = 0; - - /* Handle event */ - sap_sm_status = sap_fsm(sap_ctx, &sapEvent); - - return sap_sm_status; -} /* wlansap_scan_callback */ - - /** * sap_config_acs_result : Generate ACS result params based on ch constraints * @sap_ctx: pointer to SAP context data struct @@ -1366,7 +1235,6 @@ void sap_scan_event_callback(struct wlan_objmgr_vdev *vdev, bool success = false; eCsrScanStatus scan_status = eCSR_SCAN_FAILURE; tHalHandle hal_handle; - struct sap_context *sap_ctx = arg; session_id = wlan_vdev_get_id(vdev); scan_id = event->scan_id; @@ -1383,11 +1251,7 @@ void sap_scan_event_callback(struct wlan_objmgr_vdev *vdev, if (success) scan_status = eCSR_SCAN_SUCCESS; - if (!sap_ctx->sap_acs_pre_start_bss) - wlansap_scan_callback(hal_handle, arg, session_id, scan_id, - scan_status); - else - wlansap_pre_start_bss_acs_scan_callback(hal_handle, - arg, session_id, - scan_id, scan_status); + wlansap_pre_start_bss_acs_scan_callback(hal_handle, + arg, session_id, + scan_id, scan_status); } diff --git a/core/sap/src/sap_fsm.c b/core/sap/src/sap_fsm.c index 5c0bb2b74cc4..86541b132ed0 100644 --- a/core/sap/src/sap_fsm.c +++ b/core/sap/src/sap_fsm.c @@ -811,45 +811,17 @@ uint8_t sap_select_default_oper_chan(struct sap_acs_cfg *acs_cfg) return channel; } -/** - * sap_goto_channel_sel - Function for initiating scan request for SME - * @sap_context: Sap Context value. - * @sap_event: State machine event - * @sap_do_acs_pre_start_bss: true, if ACS scan is issued pre start BSS - * false, if ACS scan is issued post start BSS. - * @check_for_connection_update: true, check and wait for connection update - * false, do not perform connection update - * - * Initiates sme scan for ACS to pick a channel. - * - * Return: The QDF_STATUS code associated with performing the operation. - */ -QDF_STATUS sap_goto_channel_sel(struct sap_context *sap_context, - ptWLAN_SAPEvent sap_event, - bool sap_do_acs_pre_start_bss, - bool check_for_connection_update) +QDF_STATUS +sap_validate_chan(struct sap_context *sap_context, + bool pre_start_bss, + bool check_for_connection_update) { - - /* Initiate a SCAN request */ - QDF_STATUS qdf_ret_status; - /* To be initialised if scan is required */ QDF_STATUS qdf_status = QDF_STATUS_SUCCESS; tpAniSirGlobal mac_ctx; - struct scan_start_request *req; - struct wlan_objmgr_vdev *vdev; - uint8_t i; - uint8_t pdev_id; bool is_dfs; bool is_safe; - -#ifdef SOFTAP_CHANNEL_RANGE - uint8_t *channel_list = NULL; - uint8_t num_of_channels = 0; -#endif tHalHandle h_hal; uint8_t con_ch; - uint8_t vdev_id; - uint32_t scan_id; bool sta_sap_scc_on_dfs_chan; h_hal = cds_get_context(QDF_MODULE_ID_SME); @@ -861,6 +833,12 @@ QDF_STATUS sap_goto_channel_sel(struct sap_context *sap_context, } mac_ctx = PMAC_STRUCT(h_hal); + if (!sap_context->channel) { + QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR, + FL("Invalid channel")); + return QDF_STATUS_E_FAILURE; + } + if (policy_mgr_concurrent_beaconing_sessions_running(mac_ctx->psoc) || ((sap_context->cc_switch_mode == QDF_MCC_TO_SCC_SWITCH_FORCE_PREFERRED_WITHOUT_DISCONNECTION) && @@ -871,11 +849,9 @@ QDF_STATUS sap_goto_channel_sel(struct sap_context *sap_context, con_ch = sme_get_concurrent_operation_channel(h_hal); #ifdef FEATURE_WLAN_STA_AP_MODE_DFS_DISABLE - if (con_ch && sap_context->channel == AUTO_CHANNEL_SELECT) { - sap_context->dfs_ch_disable = true; - } else if (con_ch && sap_context->channel != con_ch && - wlan_reg_is_dfs_ch(mac_ctx->pdev, - sap_context->channel)) { + if (con_ch && sap_context->channel != con_ch && + wlan_reg_is_dfs_ch(mac_ctx->pdev, + sap_context->channel)) { QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_WARN, FL("MCC DFS not supported in AP_AP Mode")); return QDF_STATUS_E_ABORTED; @@ -883,8 +859,7 @@ QDF_STATUS sap_goto_channel_sel(struct sap_context *sap_context, #endif #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH if (sap_context->cc_switch_mode != - QDF_MCC_TO_SCC_SWITCH_DISABLE && - sap_context->channel) { + QDF_MCC_TO_SCC_SWITCH_DISABLE) { /* * For ACS request ,the sapContext->channel is 0, * we skip below overlap checking. When the ACS @@ -934,10 +909,8 @@ QDF_STATUS sap_goto_channel_sel(struct sap_context *sap_context, (policy_mgr_get_concurrency_mode(mac_ctx->psoc) == (QDF_STA_MASK | QDF_P2P_GO_MASK)))) { #ifdef FEATURE_WLAN_STA_AP_MODE_DFS_DISABLE - if (sap_context->channel == AUTO_CHANNEL_SELECT) - sap_context->dfs_ch_disable = true; - else if (wlan_reg_is_dfs_ch(mac_ctx->pdev, - sap_context->channel)) { + if (wlan_reg_is_dfs_ch(mac_ctx->pdev, + sap_context->channel)) { QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_WARN, FL("DFS not supported in STA_AP Mode")); return QDF_STATUS_E_ABORTED; @@ -945,8 +918,7 @@ QDF_STATUS sap_goto_channel_sel(struct sap_context *sap_context, #endif #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH if (sap_context->cc_switch_mode != - QDF_MCC_TO_SCC_SWITCH_DISABLE && - sap_context->channel) { + QDF_MCC_TO_SCC_SWITCH_DISABLE) { QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO, FL("check for overlap: chan:%d mode:%d"), sap_context->channel, @@ -992,45 +964,139 @@ QDF_STATUS sap_goto_channel_sel(struct sap_context *sap_context, #endif } - if (sap_context->channel == AUTO_CHANNEL_SELECT) { + QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH, + FL("for configured channel, Ch= %d"), + sap_context->channel); + if (check_for_connection_update) { + /* This wait happens in the hostapd context. The event + * is set in the MC thread context. + */ + qdf_status = + policy_mgr_update_and_wait_for_connection_update( + mac_ctx->psoc, + sap_context->sessionId, + sap_context->channel, + POLICY_MGR_UPDATE_REASON_START_AP); + if (QDF_IS_STATUS_ERROR(qdf_status)) + return qdf_status; + } + + if (pre_start_bss) { + QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO, + FL("ACS end due to Ch override. Sel Ch = %d"), + sap_context->channel); + sap_context->acs_cfg->pri_ch = sap_context->channel; + sap_context->acs_cfg->ch_width = + sap_context->ch_width_orig; + sap_config_acs_result(h_hal, sap_context, 0); + return QDF_STATUS_E_CANCELED; + } + + return QDF_STATUS_SUCCESS; +} + +QDF_STATUS sap_channel_sel(struct sap_context *sap_context) +{ + QDF_STATUS qdf_ret_status; + tpAniSirGlobal mac_ctx; + struct scan_start_request *req; + struct wlan_objmgr_vdev *vdev; + uint8_t i; + uint8_t pdev_id; + +#ifdef SOFTAP_CHANNEL_RANGE + uint8_t *channel_list = NULL; + uint8_t num_of_channels = 0; +#endif + tHalHandle h_hal; + uint8_t con_ch; + uint8_t vdev_id; + uint32_t scan_id; + uint8_t *self_mac; + + h_hal = cds_get_context(QDF_MODULE_ID_SME); + if (!h_hal) { + /* we have a serious problem */ + QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_FATAL, + FL("invalid h_hal")); + return QDF_STATUS_E_FAULT; + } + + mac_ctx = PMAC_STRUCT(h_hal); + if (!mac_ctx) { + QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR, + FL("Invalid MAC context")); + return QDF_STATUS_E_FAILURE; + } + if (sap_context->channel) + return sap_validate_chan(sap_context, true, false); + + if (policy_mgr_concurrent_beaconing_sessions_running(mac_ctx->psoc) || + ((sap_context->cc_switch_mode == + QDF_MCC_TO_SCC_SWITCH_FORCE_PREFERRED_WITHOUT_DISCONNECTION) && + (policy_mgr_mode_specific_connection_count(mac_ctx->psoc, + PM_SAP_MODE, NULL) || + policy_mgr_mode_specific_connection_count(mac_ctx->psoc, + PM_P2P_GO_MODE, + NULL)))) { + con_ch = sme_get_concurrent_operation_channel(h_hal); +#ifdef FEATURE_WLAN_STA_AP_MODE_DFS_DISABLE + if (con_ch) + sap_context->dfs_ch_disable = true; +#endif + } + + if ((policy_mgr_get_concurrency_mode(mac_ctx->psoc) == + (QDF_STA_MASK | QDF_SAP_MASK)) || + ((sap_context->cc_switch_mode == + QDF_MCC_TO_SCC_SWITCH_FORCE_PREFERRED_WITHOUT_DISCONNECTION) && + (policy_mgr_get_concurrency_mode(mac_ctx->psoc) == + (QDF_STA_MASK | QDF_P2P_GO_MASK)))) { +#ifdef FEATURE_WLAN_STA_AP_MODE_DFS_DISABLE + sap_context->dfs_ch_disable = true; +#endif + } #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE - QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH, - FL("%s skip_acs_status = %d "), __func__, - sap_context->acs_cfg->skip_scan_status); - if (sap_context->acs_cfg->skip_scan_status != - eSAP_SKIP_ACS_SCAN) { + QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH, + FL("%s skip_acs_status = %d "), __func__, + sap_context->acs_cfg->skip_scan_status); + if (sap_context->acs_cfg->skip_scan_status != + eSAP_SKIP_ACS_SCAN) { #endif - req = qdf_mem_malloc(sizeof(*req)); - if (!req) { - QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH, + req = qdf_mem_malloc(sizeof(*req)); + if (!req) { + QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH, FL("Failed to allocate memory")); - return QDF_STATUS_E_NOMEM; - } + return QDF_STATUS_E_NOMEM; + } - pdev_id = wlan_objmgr_pdev_get_pdev_id(mac_ctx->pdev); - vdev = wlan_objmgr_get_vdev_by_macaddr_from_psoc(mac_ctx->psoc, - pdev_id, - sap_context->self_mac_addr, - WLAN_LEGACY_SME_ID); - if (!vdev) { - QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR, - FL("Invalid vdev objmgr")); - return QDF_STATUS_E_INVAL; - } + pdev_id = wlan_objmgr_pdev_get_pdev_id(mac_ctx->pdev); + self_mac = sap_context->self_mac_addr; + vdev = wlan_objmgr_get_vdev_by_macaddr_from_psoc(mac_ctx->psoc, + pdev_id, + self_mac, + WLAN_LEGACY_SME_ID); + if (!vdev) { + QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR, + FL("Invalid vdev objmgr")); + qdf_mem_free(req); + return QDF_STATUS_E_INVAL; + } + + /* Initiate a SCAN request */ + ucfg_scan_init_default_params(vdev, req); + req->scan_req.dwell_time_active = 0; + scan_id = ucfg_scan_get_scan_id(mac_ctx->psoc); + req->scan_req.scan_id = scan_id; + vdev_id = wlan_vdev_get_id(vdev); + req->scan_req.vdev_id = vdev_id; + req->scan_req.scan_req_id = sap_context->req_id; + req->scan_req.scan_priority = SCAN_PRIORITY_HIGH; + sap_get_channel_list(sap_context, &channel_list, &num_of_channels); - ucfg_scan_init_default_params(vdev, req); - req->scan_req.dwell_time_active = 0; - scan_id = ucfg_scan_get_scan_id(mac_ctx->psoc); - req->scan_req.scan_id = scan_id; - vdev_id = wlan_vdev_get_id(vdev); - req->scan_req.vdev_id = vdev_id; - req->scan_req.scan_req_id = sap_context->req_id; - req->scan_req.scan_priority = SCAN_PRIORITY_HIGH; - sap_get_channel_list(sap_context, &channel_list, - &num_of_channels); #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE - if (num_of_channels != 0) { + if (num_of_channels != 0) { #endif req->scan_req.chan_list.num_chan = num_of_channels; @@ -1045,19 +1111,16 @@ QDF_STATUS sap_goto_channel_sel(struct sap_context *sap_context, sap_context->channelList = channel_list; sap_context->num_of_channel = num_of_channels; /* Set requestType to Full scan */ - QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH, FL("calling ucfg_scan_start")); #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE if (sap_context->acs_cfg->skip_scan_status == - eSAP_DO_NEW_ACS_SCAN) + eSAP_DO_NEW_ACS_SCAN) #endif sme_scan_flush_result(h_hal); - sap_context->sap_acs_pre_start_bss = sap_do_acs_pre_start_bss; qdf_ret_status = ucfg_scan_start(req); wlan_objmgr_vdev_release_ref(vdev, WLAN_LEGACY_SME_ID); - - if (QDF_STATUS_SUCCESS != qdf_ret_status) { + if (qdf_ret_status != QDF_STATUS_SUCCESS) { QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR, FL("scan request fail %d!!!"), qdf_ret_status); @@ -1077,19 +1140,12 @@ QDF_STATUS sap_goto_channel_sel(struct sap_context *sap_context, sap_context->num_of_channel = 0; } #endif - if (true == sap_do_acs_pre_start_bss) { - /* - * In case of ACS req before start Bss, - * return failure so that the calling - * function can use the default channel. - */ - return QDF_STATUS_E_FAILURE; - } else { - /* Fill in the event structure */ - sap_event_init(sap_event); - /* Handle event */ - qdf_status = sap_fsm(sap_context, sap_event); - } + /* + * In case of ACS req before start Bss, + * return failure so that the calling + * function can use the default channel. + */ + return QDF_STATUS_E_FAILURE; } else { QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH, FL("return sme_ScanReq, scanID=%d, Ch=%d"), @@ -1106,55 +1162,11 @@ QDF_STATUS sap_goto_channel_sel(struct sap_context *sap_context, if (sap_context->acs_cfg->skip_scan_status == eSAP_SKIP_ACS_SCAN) { QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR, FL("## %s SKIPPED ACS SCAN"), __func__); - - if (true == sap_do_acs_pre_start_bss) wlansap_pre_start_bss_acs_scan_callback(h_hal, sap_context, sap_context->sessionId, 0, eCSR_SCAN_SUCCESS); - else - wlansap_scan_callback(h_hal, sap_context, - sap_context->sessionId, 0, eCSR_SCAN_SUCCESS); } #endif - } else { - QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH, - FL("for configured channel, Ch= %d"), - sap_context->channel); - - if (check_for_connection_update) { - /* This wait happens in the hostapd context. The event - * is set in the MC thread context. - */ - qdf_status = - policy_mgr_update_and_wait_for_connection_update( - mac_ctx->psoc, - sap_context->sessionId, - sap_context->channel, - POLICY_MGR_UPDATE_REASON_START_AP); - if (QDF_IS_STATUS_ERROR(qdf_status)) - return qdf_status; - } - - if (sap_do_acs_pre_start_bss == true) { - QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO, - FL("ACS end due to Ch override. Sel Ch = %d"), - sap_context->channel); - sap_context->acs_cfg->pri_ch = sap_context->channel; - sap_context->acs_cfg->ch_width = - sap_context->ch_width_orig; - sap_config_acs_result(h_hal, sap_context, 0); - return QDF_STATUS_E_CANCELED; - } else { - /* - * Fill in the event structure - * Eventhough scan was not done, - * means a user set channel was chosen - */ - sap_event_init(sap_event); - /* Handle event */ - qdf_status = sap_fsm(sap_context, sap_event); - } - } /* * If scan failed, get default channel and advance state @@ -1164,7 +1176,7 @@ QDF_STATUS sap_goto_channel_sel(struct sap_context *sap_context, * channel cannot advance state machine here as said above */ QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH, - FL("before exiting sap_goto_channel_sel channel=%d"), + FL("before exiting sap_channel_sel channel=%d"), sap_context->channel); return QDF_STATUS_SUCCESS; @@ -2142,6 +2154,32 @@ static QDF_STATUS sap_cac_end_notify(tHalHandle hHal, return qdf_status; } +static QDF_STATUS sap_switch_ch_sel(struct sap_context *sap_ctx) +{ + tWLAN_SAPEvent sap_event; + QDF_STATUS qdf_status; + + /* + * Fill in the event structure Eventhough scan was not done, + * means a user set channel was chosen + */ + sap_event_init(&sap_event); + /* Handle event */ + qdf_status = sap_fsm(sap_ctx, &sap_event); + + /* + * If scan failed, get default channel and advance state + * machine as success with default channel + * + * Have to wait for the call back to be called to get the + * channel cannot advance state machine here as said above + */ + QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH, + FL("before exiting sap_switch_ch_sel")); + + return qdf_status; +} + /** * sap_fsm_state_disconnected() - utility function called from sap fsm * @sap_ctx: SAP context @@ -2180,8 +2218,10 @@ static QDF_STATUS sap_fsm_state_disconnected(struct sap_context *sap_ctx, * Perform sme_ScanRequest. This scan request is post start bss * request so, set the third to false. */ - qdf_status = sap_goto_channel_sel(sap_ctx, sap_event, false, - true); + qdf_status = sap_validate_chan(sap_ctx, false, true); + if (qdf_status == QDF_STATUS_SUCCESS || + qdf_status == QDF_STATUS_E_CANCELED) + qdf_status = sap_switch_ch_sel(sap_ctx); } else if (msg == eSAP_DFS_CHANNEL_CAC_START) { /* * No need of state check here, caller is expected to perform @@ -2199,16 +2239,6 @@ static QDF_STATUS sap_fsm_state_disconnected(struct sap_context *sap_ctx, } qdf_status = sap_cac_start_notify(hal); - } else if (msg == eSAP_CHANNEL_SELECTION_RETRY) { - /* Set SAP device role */ - sap_ctx->sapsMachine = eSAP_CH_SELECT; - - /* - * Perform sme_ScanRequest. This scan request is post start bss - * request so, set the third to false. - */ - qdf_status = sap_goto_channel_sel(sap_ctx, sap_event, false, - false); } else { QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR, FL("in state %s, event msg %d"), diff --git a/core/sap/src/sap_fsm_ext.h b/core/sap/src/sap_fsm_ext.h index 9bbfb43e1bbd..7b84215d83b3 100644 --- a/core/sap/src/sap_fsm_ext.h +++ b/core/sap/src/sap_fsm_ext.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 The Linux Foundation. All rights reserved. + * Copyright (c) 2014, 2018 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -44,7 +44,6 @@ typedef enum { eSAP_DFS_CHANNEL_CAC_END, eSAP_DFS_CHNL_SWITCH_ANNOUNCEMENT_START, eSAP_OPERATING_CHANNEL_CHANGED, - eSAP_CHANNEL_SELECTION_RETRY, eSAP_CHANNEL_SWITCH_ANNOUNCEMENT_START, eSAP_NO_MSG diff --git a/core/sap/src/sap_internal.h b/core/sap/src/sap_internal.h index 6ed9c84f434b..d7b262a87e25 100644 --- a/core/sap/src/sap_internal.h +++ b/core/sap/src/sap_internal.h @@ -244,7 +244,6 @@ struct sap_context { tSirMacRateSet extended_rate_set; enum sap_acs_dfs_mode dfs_mode; wlan_scan_requester req_id; - uint8_t sap_acs_pre_start_bss; uint8_t sap_sta_id; bool dfs_cac_offload; bool is_chan_change_inprogress; @@ -276,23 +275,6 @@ typedef struct sWLAN_SAPEvent { QDF_STATUS wlansap_context_get(struct sap_context *ctx); void wlansap_context_put(struct sap_context *ctx); -/** - * wlansap_scan_callback() - Callback for Scan (scan results) Events - * @hal_handle: tHalHandle passed in with the scan request - * @sap_ctx: The sap context - * @session_id: ID of the current session - * @scan_id: ID assigned to the scan - * @scan_status: Status of the scan - * - * Callback for Scan (scan results) Events - * - * Return: Status - */ -QDF_STATUS wlansap_scan_callback(tHalHandle hal_handle, - struct sap_context *sap_ctx, - uint8_t session_id, - uint32_t scan_id, eCsrScanStatus scan_status); - /** * wlansap_pre_start_bss_acs_scan_callback() - callback for scan results * @hal_handle: the hal_handle passed in with the scan request @@ -383,11 +365,31 @@ bool sap_dfs_is_w53_invalid(tHalHandle hHal, uint8_t channelID); bool sap_dfs_is_channel_in_preferred_location(tHalHandle hHal, uint8_t channelID); -QDF_STATUS sap_goto_channel_sel( - struct sap_context *sapContext, - ptWLAN_SAPEvent sapEvent, - bool sap_do_acs_pre_start_bss, - bool check_for_connection_update); +/** + * sap_channel_sel - Function for initiating scan request for ACS + * @sap_context: Sap Context value. + * + * Initiates Scan for ACS to pick a channel. + * + * Return: The QDF_STATUS code associated with performing the operation. + */ +QDF_STATUS sap_channel_sel(struct sap_context *sapContext); + +/** + * sap_validate_chan - Function validate the channel and forces SCC + * @sap_context: Sap Context value. + * @pre_start_bss: if its called pre start BSS with valid channel. + * @check_for_connection_update: true, check and wait for connection update + * false, do not perform connection update + * + * validate and update the channel in case of force SCC. + * + * Return: The QDF_STATUS code associated with performing the operation. + */ +QDF_STATUS +sap_validate_chan(struct sap_context *sap_context, + bool pre_start_bss, + bool check_for_connection_update); /** * sap_check_in_avoid_ch_list() - checks if given channel present is channel diff --git a/core/sap/src/sap_module.c b/core/sap/src/sap_module.c index afc5893c6b91..ae65abe8b289 100644 --- a/core/sap/src/sap_module.c +++ b/core/sap/src/sap_module.c @@ -2483,7 +2483,6 @@ QDF_STATUS wlansap_acs_chselect(struct sap_context *sap_context, tHalHandle h_hal = NULL; QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE; tpAniSirGlobal pmac = NULL; - tWLAN_SAPEvent sapEvent; /* State machine event */ if (NULL == sap_context) { QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR, @@ -2534,7 +2533,7 @@ QDF_STATUS wlansap_acs_chselect(struct sap_context *sap_context, * different scan callback function to process * the results pre start BSS. */ - qdf_status = sap_goto_channel_sel(sap_context, &sapEvent, true, false); + qdf_status = sap_channel_sel(sap_context); if (QDF_STATUS_E_ABORTED == qdf_status) { QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,