diff --git a/umac/cmn_services/policy_mgr/inc/wlan_policy_mgr_api.h b/umac/cmn_services/policy_mgr/inc/wlan_policy_mgr_api.h index f9160f9300..4b77fca93d 100644 --- a/umac/cmn_services/policy_mgr/inc/wlan_policy_mgr_api.h +++ b/umac/cmn_services/policy_mgr/inc/wlan_policy_mgr_api.h @@ -1079,6 +1079,16 @@ QDF_STATUS policy_mgr_reset_connection_update(struct wlan_objmgr_psoc *psoc); */ QDF_STATUS policy_mgr_set_connection_update(struct wlan_objmgr_psoc *psoc); +/** + * policy_mgr_set_opportunistic_update() - Set opportunistic + * update event + * @psoc: PSOC object information + * Sets the opportunistic update event + * + * Return: QDF_STATUS + */ +QDF_STATUS policy_mgr_set_opportunistic_update(struct wlan_objmgr_psoc *psoc); + /** * policy_mgr_restart_opportunistic_timer() - Restarts opportunistic timer * @psoc: PSOC object information @@ -2163,6 +2173,7 @@ uint8_t policy_mgr_get_cur_conc_system_pref(struct wlan_objmgr_psoc *psoc); * state of opportunistic timer, if running, stop it and take * action * @psoc: soc pointer + * @id: Session/vdev id * * Get the current state of opportunistic timer, if it is * running, stop it and take action. @@ -2170,7 +2181,7 @@ uint8_t policy_mgr_get_cur_conc_system_pref(struct wlan_objmgr_psoc *psoc); * Return: None */ void policy_mgr_check_and_stop_opportunistic_timer( - struct wlan_objmgr_psoc *psoc); + struct wlan_objmgr_psoc *psoc, uint8_t id); /** * policy_mgr_set_weight_of_dfs_passive_channels_to_zero() - set weight of dfs diff --git a/umac/cmn_services/policy_mgr/src/wlan_policy_mgr_action.c b/umac/cmn_services/policy_mgr/src/wlan_policy_mgr_action.c index 607d1b0ef9..7e57b359ef 100644 --- a/umac/cmn_services/policy_mgr/src/wlan_policy_mgr_action.c +++ b/umac/cmn_services/policy_mgr/src/wlan_policy_mgr_action.c @@ -995,6 +995,28 @@ QDF_STATUS policy_mgr_set_connection_update(struct wlan_objmgr_psoc *psoc) return QDF_STATUS_SUCCESS; } +QDF_STATUS policy_mgr_set_opportunistic_update(struct wlan_objmgr_psoc *psoc) +{ + QDF_STATUS status; + struct policy_mgr_psoc_priv_obj *policy_mgr_context; + + policy_mgr_context = policy_mgr_get_context(psoc); + if (!policy_mgr_context) { + policy_mgr_err("Invalid context"); + return QDF_STATUS_E_FAILURE; + } + + status = qdf_event_set( + &policy_mgr_context->opportunistic_update_done_evt); + + if (!QDF_IS_STATUS_SUCCESS(status)) { + policy_mgr_err("set event failed"); + return QDF_STATUS_E_FAILURE; + } + + return QDF_STATUS_SUCCESS; +} + QDF_STATUS policy_mgr_restart_opportunistic_timer( struct wlan_objmgr_psoc *psoc, bool check_state) { @@ -1103,9 +1125,11 @@ void policy_mgr_checkn_update_hw_mode_single_mac_mode( } void policy_mgr_check_and_stop_opportunistic_timer( - struct wlan_objmgr_psoc *psoc) + struct wlan_objmgr_psoc *psoc, uint8_t id) { struct policy_mgr_psoc_priv_obj *pm_ctx; + enum policy_mgr_conc_next_action action = PM_NOP; + QDF_STATUS status = QDF_STATUS_E_FAILURE; pm_ctx = policy_mgr_get_context(psoc); if (!pm_ctx) { @@ -1115,7 +1139,23 @@ void policy_mgr_check_and_stop_opportunistic_timer( if (QDF_TIMER_STATE_RUNNING == pm_ctx->dbs_opportunistic_timer.state) { qdf_mc_timer_stop(&pm_ctx->dbs_opportunistic_timer); - pm_dbs_opportunistic_timer_handler((void *)psoc); + action = policy_mgr_need_opportunistic_upgrade(psoc); + if (action) { + status = policy_mgr_next_actions(psoc, id, action, + POLICY_MGR_UPDATE_REASON_OPPORTUNISTIC); + if (status != QDF_STATUS_SUCCESS) { + policy_mgr_err("Failed in policy_mgr_next_actions"); + return; + } + status = qdf_wait_single_event( + &pm_ctx->opportunistic_update_done_evt, + CONNECTION_UPDATE_TIMEOUT); + + if (!QDF_IS_STATUS_SUCCESS(status)) { + policy_mgr_err("wait for event failed"); + return; + } + } } } diff --git a/umac/cmn_services/policy_mgr/src/wlan_policy_mgr_core.c b/umac/cmn_services/policy_mgr/src/wlan_policy_mgr_core.c index c707cdac8a..9ff2bb4db8 100644 --- a/umac/cmn_services/policy_mgr/src/wlan_policy_mgr_core.c +++ b/umac/cmn_services/policy_mgr/src/wlan_policy_mgr_core.c @@ -811,8 +811,12 @@ void policy_mgr_pdev_set_hw_mode_cb(uint32_t status, if (PM_NOP != next_action) policy_mgr_next_actions(context, session_id, next_action, reason); - else + else { policy_mgr_debug("No action needed right now"); + ret = policy_mgr_set_opportunistic_update(context); + if (!QDF_IS_STATUS_SUCCESS(ret)) + policy_mgr_err("ERROR: set opportunistic_update event failed"); + } return; } @@ -2379,6 +2383,7 @@ static void policy_mgr_nss_update_cb(struct wlan_objmgr_psoc *psoc, enum policy_mgr_conn_update_reason reason) { uint32_t conn_index = 0; + QDF_STATUS ret; if (QDF_STATUS_SUCCESS != tx_status) policy_mgr_err("nss update failed(%d) for vdev %d", @@ -2394,7 +2399,14 @@ static void policy_mgr_nss_update_cb(struct wlan_objmgr_psoc *psoc, } policy_mgr_debug("nss update successful for vdev:%d", vdev_id); - policy_mgr_next_actions(psoc, vdev_id, next_action, reason); + if (PM_NOP != next_action) + policy_mgr_next_actions(psoc, vdev_id, next_action, reason); + else { + policy_mgr_debug("No action needed right now"); + ret = policy_mgr_set_opportunistic_update(psoc); + if (!QDF_IS_STATUS_SUCCESS(ret)) + policy_mgr_err("ERROR: set opportunistic_update event failed"); + } return; } diff --git a/umac/cmn_services/policy_mgr/src/wlan_policy_mgr_i.h b/umac/cmn_services/policy_mgr/src/wlan_policy_mgr_i.h index 16d38fabdd..e8b21092a4 100644 --- a/umac/cmn_services/policy_mgr/src/wlan_policy_mgr_i.h +++ b/umac/cmn_services/policy_mgr/src/wlan_policy_mgr_i.h @@ -239,6 +239,8 @@ struct sta_ap_intf_check_work_ctx { * @unsafe_channel_list: LTE coex channel avoidance list * @unsafe_channel_count: LTE coex channel avoidance list count * @sta_ap_intf_check_work_info: Info related to sta_ap_intf_check_work + * @opportunistic_update_done_evt: qdf event to synchronize host + * & FW HW mode */ struct policy_mgr_psoc_priv_obj { struct wlan_objmgr_psoc *psoc; @@ -272,6 +274,7 @@ struct policy_mgr_psoc_priv_obj { struct sta_ap_intf_check_work_ctx *sta_ap_intf_check_work_info; uint8_t cur_conc_system_pref; uint8_t sta_sap_scc_on_dfs_chan_allowed; + qdf_event_t opportunistic_update_done_evt; }; /** diff --git a/umac/cmn_services/policy_mgr/src/wlan_policy_mgr_init_deinit.c b/umac/cmn_services/policy_mgr/src/wlan_policy_mgr_init_deinit.c index 08513de35a..74f9e54892 100644 --- a/umac/cmn_services/policy_mgr/src/wlan_policy_mgr_init_deinit.c +++ b/umac/cmn_services/policy_mgr/src/wlan_policy_mgr_init_deinit.c @@ -406,6 +406,12 @@ QDF_STATUS policy_mgr_psoc_enable(struct wlan_objmgr_psoc *psoc) return status; } + status = qdf_event_create(&pm_ctx->opportunistic_update_done_evt); + if (!QDF_IS_STATUS_SUCCESS(status)) { + policy_mgr_err("opportunistic_update_done_evt init failed"); + return status; + } + pm_ctx->do_hw_mode_change = false; pm_ctx->hw_mode_change_in_progress = POLICY_MGR_HW_MODE_NOT_IN_PROGRESS; /* reset sap mandatory channels */ @@ -473,6 +479,14 @@ QDF_STATUS policy_mgr_psoc_disable(struct wlan_objmgr_psoc *psoc) QDF_ASSERT(0); } + /* destroy opportunistic_update_done_evt */ + if (!QDF_IS_STATUS_SUCCESS(qdf_event_destroy + (&pm_ctx->opportunistic_update_done_evt))) { + policy_mgr_err("Failed to destroy opportunistic_update_done_evt"); + status = QDF_STATUS_E_FAILURE; + QDF_ASSERT(0); + } + /* deallocate dbs_opportunistic_timer */ if (QDF_TIMER_STATE_RUNNING == qdf_mc_timer_get_current_state(