diff --git a/core/hdd/src/wlan_hdd_hostapd.c b/core/hdd/src/wlan_hdd_hostapd.c index d4113abc4e20..85a91ab8522d 100644 --- a/core/hdd/src/wlan_hdd_hostapd.c +++ b/core/hdd/src/wlan_hdd_hostapd.c @@ -8431,6 +8431,10 @@ static int __wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy, struct hdd_hostapd_state *hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter); + /* Set the stop_bss_in_progress flag */ + wlansap_set_stop_bss_inprogress( + WLAN_HDD_GET_SAP_CTX_PTR(adapter), true); + qdf_event_reset(&hostapd_state->qdf_stop_bss_event); status = wlansap_stop_bss(WLAN_HDD_GET_SAP_CTX_PTR(adapter)); if (QDF_IS_STATUS_SUCCESS(status)) { @@ -8445,6 +8449,11 @@ static int __wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy, } } clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); + + /* Clear the stop_bss_in_progress flag */ + wlansap_set_stop_bss_inprogress( + WLAN_HDD_GET_SAP_CTX_PTR(adapter), false); + /*BSS stopped, clear the active sessions for this device mode*/ policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, adapter->device_mode, diff --git a/core/sap/inc/sap_api.h b/core/sap/inc/sap_api.h index fe9a34d964a7..5bd3a24f9ef5 100644 --- a/core/sap/inc/sap_api.h +++ b/core/sap/inc/sap_api.h @@ -1425,6 +1425,20 @@ void sap_dfs_set_current_channel(void *sap_ctx); */ void wlansap_cleanup_cac_timer(struct sap_context *sap_ctx); +/** + * wlansap_set_stop_bss_inprogress - sets the stop_bss_in_progress flag + * + * @sap_ctx: Pointer to the global SAP ctx + * @in_progress: the value to be set to the stop_bss_in_progress_flag + * + * This function sets the value in in_progress parameter to the + * stop_bss_in_progress flag in sap_context. + * + * Return: None + */ +void wlansap_set_stop_bss_inprogress(struct sap_context *sap_ctx, + bool in_progress); + #ifdef __cplusplus } #endif diff --git a/core/sap/src/sap_api_link_cntl.c b/core/sap/src/sap_api_link_cntl.c index 39b50df796cc..6263239a4d9b 100644 --- a/core/sap/src/sap_api_link_cntl.c +++ b/core/sap/src/sap_api_link_cntl.c @@ -439,9 +439,20 @@ wlansap_roam_process_ch_change_success(tpAniSirGlobal mac_ctx, FL("sapdfs: changing target channel to [%d]"), mac_ctx->sap.SapDfsInfo.target_channel); sap_ctx->channel = mac_ctx->sap.SapDfsInfo.target_channel; - /* Identify if this is channel change in radar detected state */ - if (eSAP_DISCONNECTING != sap_ctx->sapsMachine) + + /* + * Identify if this is channel change in radar detected state + * Also if we are waiting for sap to stop, don't proceed further + * to restart SAP again. + */ + if ((eSAP_DISCONNECTING != sap_ctx->sapsMachine) || + sap_ctx->stop_bss_in_progress) { + QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO, + FL("sapdfs: state [%d] Stop BSS in progress [%d], not starting SAP after channel change"), + sap_ctx->sapsMachine, + sap_ctx->stop_bss_in_progress); return; + } if (sap_ctx->ch_params.ch_width == CH_WIDTH_160MHZ) { is_ch_dfs = true; diff --git a/core/sap/src/sap_fsm.c b/core/sap/src/sap_fsm.c index 3fa2168fec89..94edaee8f15f 100644 --- a/core/sap/src/sap_fsm.c +++ b/core/sap/src/sap_fsm.c @@ -2704,7 +2704,7 @@ static QDF_STATUS sap_fsm_state_disconnecting(struct sap_context *sap_ctx, QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO, FL("in state %s, event msg %d result %d"), "eSAP_DISCONNECTING ", msg, sap_event->u2); - sap_goto_disconnecting(sap_ctx); + qdf_status = sap_goto_disconnecting(sap_ctx); } else { QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR, FL("in state %s, invalid event msg %d"), diff --git a/core/sap/src/sap_internal.h b/core/sap/src/sap_internal.h index 12d14eaf51c8..c9ac56d1014b 100644 --- a/core/sap/src/sap_internal.h +++ b/core/sap/src/sap_internal.h @@ -257,6 +257,7 @@ struct sap_context { uint8_t sap_sta_id; bool dfs_cac_offload; bool is_chan_change_inprogress; + bool stop_bss_in_progress; }; /*---------------------------------------------------------------------------- diff --git a/core/sap/src/sap_module.c b/core/sap/src/sap_module.c index 1f7acf0b1f4a..5d1a5a73628a 100644 --- a/core/sap/src/sap_module.c +++ b/core/sap/src/sap_module.c @@ -671,6 +671,7 @@ QDF_STATUS wlansap_start_bss(struct sap_context *sap_ctx, sap_ctx->dfs_cac_offload = pConfig->dfs_cac_offload; sap_ctx->isCacEndNotified = false; sap_ctx->is_chan_change_inprogress = false; + sap_ctx->stop_bss_in_progress = false; /* Set the BSSID to your "self MAC Addr" read the mac address from Configuation ITEM received from HDD */ sap_ctx->csr_roamProfile.BSSIDs.numOfBSSIDs = 1; @@ -798,6 +799,21 @@ QDF_STATUS wlansap_set_mac_acl(struct sap_context *sap_ctx, return qdf_status; } /* wlansap_set_mac_acl */ +void wlansap_set_stop_bss_inprogress(struct sap_context *sap_ctx, + bool in_progress) +{ + if (!sap_ctx) { + QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR, + "%s: Invalid SAP pointer from ctx", __func__); + return; + } + + QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_DEBUG, + "%s: Set stop_bss_in_progress to %d", + __func__, in_progress); + sap_ctx->stop_bss_in_progress = in_progress; +} + QDF_STATUS wlansap_stop_bss(struct sap_context *sap_ctx) { tWLAN_SAPEvent sapEvent; /* State machine event */ diff --git a/core/sme/src/csr/csr_api_roam.c b/core/sme/src/csr/csr_api_roam.c index 0658216926af..33882785ba73 100644 --- a/core/sme/src/csr/csr_api_roam.c +++ b/core/sme/src/csr/csr_api_roam.c @@ -10359,6 +10359,10 @@ void csr_roaming_state_msg_processor(tpAniSirGlobal pMac, void *pMsgBuf) csr_sae_callback(pMac, pSmeRsp); break; + case eWNI_SME_SETCONTEXT_RSP: + csr_roam_check_for_link_status_change(pMac, pSmeRsp); + break; + default: sme_debug("Unexpected message type: %d[0x%X] received in substate %s", pSmeRsp->messageType, pSmeRsp->messageType,