diff --git a/umac/dfs/dispatcher/src/wlan_dfs_tgt_api.c b/umac/dfs/dispatcher/src/wlan_dfs_tgt_api.c index e4f66c891b5c..83f301d78369 100644 --- a/umac/dfs/dispatcher/src/wlan_dfs_tgt_api.c +++ b/umac/dfs/dispatcher/src/wlan_dfs_tgt_api.c @@ -425,6 +425,8 @@ QDF_STATUS tgt_dfs_set_agile_precac_state(struct wlan_objmgr_pdev *pdev, int agile_precac_state) { struct wlan_dfs *dfs; + struct dfs_soc_priv_obj *dfs_soc; + bool is_precac_running_on_given_pdev = false; int i; if (!tgt_dfs_is_pdev_5ghz(pdev)) @@ -436,13 +438,30 @@ QDF_STATUS tgt_dfs_set_agile_precac_state(struct wlan_objmgr_pdev *pdev, return QDF_STATUS_E_FAILURE; } - dfs->dfs_soc_obj->precac_state_started = agile_precac_state; - if (!dfs->dfs_soc_obj->precac_state_started) { - for (i = 0; i < dfs->dfs_soc_obj->num_dfs_privs; i++) - dfs->dfs_soc_obj->dfs_priv[i].agile_precac_active = 0; - dfs->dfs_agile_precac_freq_mhz = 0; + dfs_soc = dfs->dfs_soc_obj; + for (i = 0; i < dfs_soc->num_dfs_privs; i++) { + if (dfs_soc->dfs_priv[i].dfs == dfs) { + /* Set the pdev state to given value. */ + dfs_soc->dfs_priv[i].agile_precac_active = + agile_precac_state; + /* If the pdev state is changed to inactive, + * reset the agile channel. + */ + if (!agile_precac_state) + dfs->dfs_agile_precac_freq_mhz = 0; + if (dfs_soc->cur_precac_dfs_index == i) + is_precac_running_on_given_pdev = true; + } } + /* If preCAC is running on this pdev and the agile_precac_state + * is set to false, set the global state in dfs_soc_obj to false. + * If this global state is not set to false, then preCAC will not be + * started the next time this pdev becomes active. + */ + if (is_precac_running_on_given_pdev && !agile_precac_state) + dfs_soc->precac_state_started = PRECAC_NOT_STARTED; + return QDF_STATUS_SUCCESS; } #else @@ -451,6 +470,8 @@ QDF_STATUS tgt_dfs_set_agile_precac_state(struct wlan_objmgr_pdev *pdev, int agile_precac_state) { struct wlan_dfs *dfs; + struct dfs_soc_priv_obj *dfs_soc; + bool is_precac_running_on_given_pdev = false; int i; if (!tgt_dfs_is_pdev_5ghz(pdev)) @@ -462,13 +483,30 @@ QDF_STATUS tgt_dfs_set_agile_precac_state(struct wlan_objmgr_pdev *pdev, return QDF_STATUS_E_FAILURE; } - dfs->dfs_soc_obj->precac_state_started = agile_precac_state; - if (!dfs->dfs_soc_obj->precac_state_started) { - for (i = 0; i < dfs->dfs_soc_obj->num_dfs_privs; i++) - dfs->dfs_soc_obj->dfs_priv[i].agile_precac_active = 0; - dfs->dfs_agile_precac_freq = 0; + dfs_soc = dfs->dfs_soc_obj; + for (i = 0; i < dfs_soc->num_dfs_privs; i++) { + if (dfs_soc->dfs_priv[i].dfs == dfs) { + /* Set the pdev state to given value. */ + dfs_soc->dfs_priv[i].agile_precac_active = + agile_precac_state; + /* If the pdev state is changed to inactive, + * reset the agile channel. + */ + if (!agile_precac_state) + dfs->dfs_agile_precac_freq = 0; + if (dfs_soc->cur_precac_dfs_index == i) + is_precac_running_on_given_pdev = true; + } } + /* If preCAC is running on this pdev and the agile_precac_state + * is set to false, set the global state in dfs_soc_obj to false. + * If this global state is not set to false, then preCAC will not be + * started the next time this pdev becomes active. + */ + if (is_precac_running_on_given_pdev && !agile_precac_state) + dfs_soc->precac_state_started = PRECAC_NOT_STARTED; + return QDF_STATUS_SUCCESS; } #endif