diff --git a/src/wlan_policy_mgr_action.c b/src/wlan_policy_mgr_action.c index 4011622d1ce7..84d4c67d1410 100644 --- a/src/wlan_policy_mgr_action.c +++ b/src/wlan_policy_mgr_action.c @@ -275,7 +275,7 @@ QDF_STATUS policy_mgr_update_connection_info(struct wlan_objmgr_psoc *psoc, mode = policy_mgr_get_mode(conn_table_entry.type, conn_table_entry.sub_type); - chan = reg_freq_to_chan(conn_table_entry.mhz); + chan = wlan_reg_freq_to_chan(pm_ctx->pdev, conn_table_entry.mhz); status = policy_mgr_get_nss_for_vdev(psoc, mode, &nss_2g, &nss_5g); if (QDF_IS_STATUS_SUCCESS(status)) { if ((WLAN_REG_IS_24GHZ_CH(chan) && (nss_2g > 1)) || @@ -723,7 +723,7 @@ void policy_mgr_check_concurrent_intf_and_restart_sap( mcc_to_scc_switch, operating_channel); if ((mcc_to_scc_switch != QDF_MCC_TO_SCC_SWITCH_DISABLE) #ifdef FEATURE_WLAN_STA_AP_MODE_DFS_DISABLE - && !wlan_reg_is_dfs_ch(psoc, + && !wlan_reg_is_dfs_ch(pm_ctx->pdev, operating_channel) #endif ) { diff --git a/src/wlan_policy_mgr_core.c b/src/wlan_policy_mgr_core.c index 526b8093a90c..546bfdd4a16f 100644 --- a/src/wlan_policy_mgr_core.c +++ b/src/wlan_policy_mgr_core.c @@ -1529,7 +1529,7 @@ QDF_STATUS policy_mgr_get_connection_channels(struct wlan_objmgr_psoc *psoc, qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); if (POLICY_MGR_PCL_ORDER_NONE == order) { while (PM_CONC_CONNECTION_LIST_VALID_INDEX(conn_index)) { - if (skip_dfs_channel && wlan_reg_is_dfs_ch(psoc, + if (skip_dfs_channel && wlan_reg_is_dfs_ch(pm_ctx->pdev, pm_conc_connection_list[conn_index].chan)) { conn_index++; } else if (*index < weight_len) { @@ -1555,7 +1555,7 @@ QDF_STATUS policy_mgr_get_connection_channels(struct wlan_objmgr_psoc *psoc, } conn_index = 0; while (PM_CONC_CONNECTION_LIST_VALID_INDEX(conn_index)) { - if (skip_dfs_channel && wlan_reg_is_dfs_ch(psoc, + if (skip_dfs_channel && wlan_reg_is_dfs_ch(pm_ctx->pdev, pm_conc_connection_list[conn_index].chan)) { conn_index++; } else if (WLAN_REG_IS_5GHZ_CH( @@ -1571,7 +1571,7 @@ QDF_STATUS policy_mgr_get_connection_channels(struct wlan_objmgr_psoc *psoc, *len = num_channels; } else if (POLICY_MGR_PCL_ORDER_5G_THEN_2G == order) { while (PM_CONC_CONNECTION_LIST_VALID_INDEX(conn_index)) { - if (skip_dfs_channel && wlan_reg_is_dfs_ch(psoc, + if (skip_dfs_channel && wlan_reg_is_dfs_ch(pm_ctx->pdev, pm_conc_connection_list[conn_index].chan)) { conn_index++; } else if (WLAN_REG_IS_5GHZ_CH( @@ -1639,6 +1639,13 @@ QDF_STATUS policy_mgr_get_channel_list(struct wlan_objmgr_psoc *psoc, uint8_t sbs_channel_list[QDF_MAX_NUM_CHAN] = {0}; bool skip_dfs_channel = false; uint32_t i = 0, j = 0; + struct policy_mgr_psoc_priv_obj *pm_ctx; + + pm_ctx = policy_mgr_get_context(psoc); + if (!pm_ctx) { + policy_mgr_err("Invalid Context"); + return status; + } if ((NULL == pcl_channels) || (NULL == len)) { policy_mgr_err("pcl_channels or len is NULL"); @@ -1699,7 +1706,8 @@ QDF_STATUS policy_mgr_get_channel_list(struct wlan_objmgr_psoc *psoc, while ((chan_index < num_channels) && (chan_index_5 < QDF_MAX_NUM_CHAN)) { if ((true == skip_dfs_channel) && - wlan_reg_is_dfs_ch(psoc, channel_list[chan_index])) { + wlan_reg_is_dfs_ch(pm_ctx->pdev, + channel_list[chan_index])) { chan_index++; continue; } @@ -2177,11 +2185,11 @@ bool policy_mgr_is_5g_channel_allowed(struct wlan_objmgr_psoc *psoc, count = policy_mgr_mode_specific_connection_count(psoc, mode, list); qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); while (index < count) { - if (wlan_reg_is_dfs_ch(psoc, + if (wlan_reg_is_dfs_ch( + pm_ctx->pdev, pm_conc_connection_list[list[index]].chan) && - WLAN_REG_IS_5GHZ_CH(channel) && - (channel != - pm_conc_connection_list[list[index]].chan)) { + WLAN_REG_IS_5GHZ_CH(channel) && + (channel != pm_conc_connection_list[list[index]].chan)) { qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); policy_mgr_err("don't allow MCC if SAP/GO on DFS channel"); return false; diff --git a/src/wlan_policy_mgr_get_set_utils.c b/src/wlan_policy_mgr_get_set_utils.c index dad0bf96ba42..771f7e37442c 100644 --- a/src/wlan_policy_mgr_get_set_utils.c +++ b/src/wlan_policy_mgr_get_set_utils.c @@ -1199,7 +1199,7 @@ QDF_STATUS policy_mgr_incr_connection_count( mode = policy_mgr_get_mode(conn_table_entry.type, conn_table_entry.sub_type); - chan = reg_freq_to_chan(conn_table_entry.mhz); + chan = wlan_reg_freq_to_chan(pm_ctx->pdev, conn_table_entry.mhz); status = policy_mgr_get_nss_for_vdev(psoc, mode, &nss_2g, &nss_5g); if (QDF_IS_STATUS_SUCCESS(status)) { if ((WLAN_REG_IS_24GHZ_CH(chan) && (nss_2g > 1)) || @@ -1488,7 +1488,7 @@ bool policy_mgr_allow_concurrency(struct wlan_objmgr_psoc *psoc, goto done; if ((PM_P2P_GO_MODE == mode) || (PM_SAP_MODE == mode)) { - if (wlan_reg_is_dfs_ch(psoc, channel)) + if (wlan_reg_is_dfs_ch(pm_ctx->pdev, channel)) match = policy_mgr_disallow_mcc(psoc, channel); } if (true == match) { @@ -1512,7 +1512,7 @@ bool policy_mgr_allow_concurrency(struct wlan_objmgr_psoc *psoc, goto done; } if ((PM_IBSS_MODE == mode) && - (wlan_reg_is_dfs_ch(psoc, channel)) && count) { + (wlan_reg_is_dfs_ch(pm_ctx->pdev, channel)) && count) { policy_mgr_err("No IBSS + STA SCC/MCC, IBSS is on DFS channel"); goto done; } @@ -1565,7 +1565,7 @@ bool policy_mgr_allow_concurrency(struct wlan_objmgr_psoc *psoc, } qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); if (channel && - (wlan_reg_is_dfs_ch(psoc, + (wlan_reg_is_dfs_ch(pm_ctx->pdev, pm_conc_connection_list[0].chan)) && (WLAN_REG_IS_5GHZ_CH(channel))) { qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); @@ -2059,7 +2059,7 @@ bool policy_mgr_is_any_nondfs_chnl_present(struct wlan_objmgr_psoc *psoc, for (conn_index = 0; conn_index < MAX_NUMBER_OF_CONC_CONNECTIONS; conn_index++) { if (pm_conc_connection_list[conn_index].in_use && - !wlan_reg_is_dfs_ch(psoc, + !wlan_reg_is_dfs_ch(pm_ctx->pdev, pm_conc_connection_list[conn_index].chan)) { *channel = pm_conc_connection_list[conn_index].chan; status = true; @@ -2088,7 +2088,7 @@ bool policy_mgr_is_any_dfs_beaconing_session_present( conn_index++) { conn_info = &pm_conc_connection_list[conn_index]; if (conn_info->in_use && - wlan_reg_is_dfs_ch(psoc, conn_info->chan) && + wlan_reg_is_dfs_ch(pm_ctx->pdev, conn_info->chan) && (PM_SAP_MODE == conn_info->mode || PM_P2P_GO_MODE == conn_info->mode)) { *channel = pm_conc_connection_list[conn_index].chan; diff --git a/src/wlan_policy_mgr_i.h b/src/wlan_policy_mgr_i.h index a1a91be7ecd2..8dd4e4ddb457 100644 --- a/src/wlan_policy_mgr_i.h +++ b/src/wlan_policy_mgr_i.h @@ -33,36 +33,7 @@ #include "qdf_mc_timer.h" #include "qdf_lock.h" #include "qdf_defer.h" - -#include - -enum cds_band_type { - CDS_BAND_ALL = 0, - CDS_BAND_2GHZ = 1, - CDS_BAND_5GHZ = 2 -}; - -extern uint32_t cds_chan_to_freq(uint8_t chan); -extern uint8_t cds_freq_to_chan(uint32_t freq); -extern enum cds_band_type cds_chan_to_band(uint32_t chan); - -#define WLAN_REG_IS_24GHZ_CH(ch) CDS_IS_CHANNEL_24GHZ(ch) -#define WLAN_REG_IS_5GHZ_CH(ch) CDS_IS_CHANNEL_5GHZ(ch) -#define WLAN_REG_IS_SAME_BAND_CHANNELS(ch1, ch2) \ - CDS_IS_SAME_BAND_CHANNELS(ch1, ch2) -#define WLAN_REG_IS_CHANNEL_VALID_5G_SBS(curchan, newchan) \ - CDS_IS_CHANNEL_VALID_5G_SBS(curchan, newchan) -#define wlan_reg_is_dfs_ch(psoc, ch) CDS_IS_DFS_CH(ch) -#define wlan_reg_is_passive_or_disable_ch(ch) \ - CDS_IS_PASSIVE_OR_DISABLE_CH(ch) -#define WLAN_REG_MAX_24GHZ_CH_NUM CDS_MAX_24GHZ_CHANNEL_NUMBER -#define reg_chan_to_freq(chan_num) cds_chan_to_freq(chan_num) -#define reg_freq_to_chan(freq) cds_freq_to_chan(freq) -#define reg_chan_to_band(chan_num) cds_chan_to_band(chan_num) -#define BAND_2G CDS_BAND_2GHZ -#define BAND_5G CDS_BAND_5GHZ -#define BAND_ALL CDS_BAND_ALL - +#include "wlan_reg_services_api.h" #define MAX_NUMBER_OF_CONC_CONNECTIONS 3 #define DBS_OPPORTUNISTIC_TIME 10 @@ -213,6 +184,7 @@ extern enum policy_mgr_conc_next_action /** * struct policy_mgr_psoc_priv_obj - Policy manager private data * @psoc: pointer to PSOC object information + * @pdev: pointer to PDEV object information * @connection_update_done_evt: qdf event to synchronize * connection activities * @qdf_conc_list_lock: To protect connection table @@ -255,6 +227,7 @@ extern enum policy_mgr_conc_next_action */ struct policy_mgr_psoc_priv_obj { struct wlan_objmgr_psoc *psoc; + struct wlan_objmgr_pdev *pdev; qdf_event_t connection_update_done_evt; qdf_mutex_t qdf_conc_list_lock; qdf_mc_timer_t dbs_opportunistic_timer; diff --git a/src/wlan_policy_mgr_init_deinit.c b/src/wlan_policy_mgr_init_deinit.c index 63c7b43be190..9c2fde0ae2d3 100644 --- a/src/wlan_policy_mgr_init_deinit.c +++ b/src/wlan_policy_mgr_init_deinit.c @@ -86,6 +86,42 @@ static void policy_mgr_psoc_obj_status_cb(struct wlan_objmgr_psoc *psoc, return; } +static QDF_STATUS policy_mgr_pdev_obj_create_cb(struct wlan_objmgr_pdev *pdev, + void *data) +{ + struct policy_mgr_psoc_priv_obj *policy_mgr_ctx; + struct wlan_objmgr_psoc *psoc; + + psoc = wlan_pdev_get_psoc(pdev); + policy_mgr_ctx = policy_mgr_get_context(psoc); + if (!policy_mgr_ctx) { + policy_mgr_err("invalid context"); + return QDF_STATUS_E_FAILURE; + } + + policy_mgr_ctx->pdev = pdev; + + return QDF_STATUS_SUCCESS; +} + +static QDF_STATUS policy_mgr_pdev_obj_destroy_cb(struct wlan_objmgr_pdev *pdev, + void *data) +{ + struct policy_mgr_psoc_priv_obj *policy_mgr_ctx; + struct wlan_objmgr_psoc *psoc; + + psoc = wlan_pdev_get_psoc(pdev); + policy_mgr_ctx = policy_mgr_get_context(psoc); + if (!policy_mgr_ctx) { + policy_mgr_err("invalid context"); + return QDF_STATUS_E_FAILURE; + } + + policy_mgr_ctx->pdev = NULL; + + return QDF_STATUS_SUCCESS; +} + static QDF_STATUS policy_mgr_vdev_obj_create_cb(struct wlan_objmgr_vdev *vdev, void *data) { @@ -134,6 +170,24 @@ QDF_STATUS policy_mgr_init(void) goto err_psoc_status; } + status = wlan_objmgr_register_pdev_create_handler( + WLAN_UMAC_COMP_POLICY_MGR, + policy_mgr_pdev_obj_create_cb, + NULL); + if (status != QDF_STATUS_SUCCESS) { + policy_mgr_err("Failed to register pdev obj create cback"); + goto err_pdev_create; + } + + status = wlan_objmgr_register_pdev_destroy_handler( + WLAN_UMAC_COMP_POLICY_MGR, + policy_mgr_pdev_obj_destroy_cb, + NULL); + if (status != QDF_STATUS_SUCCESS) { + policy_mgr_err("Failed to register pdev obj delete cback"); + goto err_pdev_delete; + } + status = wlan_objmgr_register_vdev_create_handler( WLAN_UMAC_COMP_POLICY_MGR, policy_mgr_vdev_obj_create_cb, @@ -167,19 +221,32 @@ QDF_STATUS policy_mgr_init(void) err_vdev_status: wlan_objmgr_unregister_vdev_destroy_handler(WLAN_UMAC_COMP_POLICY_MGR, - policy_mgr_vdev_obj_destroy_cb, NULL); + policy_mgr_vdev_obj_destroy_cb, + NULL); err_vdev_delete: wlan_objmgr_unregister_vdev_create_handler(WLAN_UMAC_COMP_POLICY_MGR, - policy_mgr_vdev_obj_create_cb, NULL); + policy_mgr_vdev_obj_create_cb, + NULL); err_vdev_create: + wlan_objmgr_unregister_pdev_destroy_handler(WLAN_UMAC_COMP_POLICY_MGR, + policy_mgr_pdev_obj_destroy_cb, + NULL); +err_pdev_delete: + wlan_objmgr_unregister_pdev_create_handler(WLAN_UMAC_COMP_POLICY_MGR, + policy_mgr_pdev_obj_create_cb, + NULL); +err_pdev_create: wlan_objmgr_unregister_psoc_status_handler(WLAN_UMAC_COMP_POLICY_MGR, - policy_mgr_psoc_obj_status_cb, NULL); + policy_mgr_psoc_obj_status_cb, + NULL); err_psoc_status: wlan_objmgr_unregister_psoc_destroy_handler(WLAN_UMAC_COMP_POLICY_MGR, - policy_mgr_psoc_obj_destroy_cb, NULL); + policy_mgr_psoc_obj_destroy_cb, + NULL); err_psoc_delete: wlan_objmgr_unregister_psoc_create_handler(WLAN_UMAC_COMP_POLICY_MGR, - policy_mgr_psoc_obj_create_cb, NULL); + policy_mgr_psoc_obj_create_cb, + NULL); err_psoc_create: return status; } @@ -188,12 +255,12 @@ QDF_STATUS policy_mgr_deinit(void) { QDF_STATUS status; - status = wlan_objmgr_unregister_psoc_create_handler( + status = wlan_objmgr_unregister_psoc_status_handler( WLAN_UMAC_COMP_POLICY_MGR, - policy_mgr_psoc_obj_create_cb, + policy_mgr_psoc_obj_status_cb, NULL); if (status != QDF_STATUS_SUCCESS) - policy_mgr_err("Failed to deregister psoc obj create cback"); + policy_mgr_err("Failed to deregister psoc obj status cback"); status = wlan_objmgr_unregister_psoc_destroy_handler( WLAN_UMAC_COMP_POLICY_MGR, @@ -202,19 +269,33 @@ QDF_STATUS policy_mgr_deinit(void) if (status != QDF_STATUS_SUCCESS) policy_mgr_err("Failed to deregister psoc obj delete cback"); - status = wlan_objmgr_unregister_psoc_status_handler( + status = wlan_objmgr_unregister_psoc_create_handler( WLAN_UMAC_COMP_POLICY_MGR, - policy_mgr_psoc_obj_status_cb, + policy_mgr_psoc_obj_create_cb, NULL); if (status != QDF_STATUS_SUCCESS) - policy_mgr_err("Failed to deregister psoc obj status cback"); + policy_mgr_err("Failed to deregister psoc obj create cback"); - status = wlan_objmgr_unregister_vdev_create_handler( + status = wlan_objmgr_unregister_pdev_destroy_handler( WLAN_UMAC_COMP_POLICY_MGR, - policy_mgr_vdev_obj_create_cb, + policy_mgr_pdev_obj_destroy_cb, NULL); if (status != QDF_STATUS_SUCCESS) - policy_mgr_err("Failed to deregister vdev obj create cback"); + policy_mgr_err("Failed to deregister pdev obj delete cback"); + + status = wlan_objmgr_unregister_pdev_create_handler( + WLAN_UMAC_COMP_POLICY_MGR, + policy_mgr_pdev_obj_create_cb, + NULL); + if (status != QDF_STATUS_SUCCESS) + policy_mgr_err("Failed to deregister pdev obj create cback"); + + status = wlan_objmgr_unregister_vdev_status_handler( + WLAN_UMAC_COMP_POLICY_MGR, + policy_mgr_vdev_obj_status_cb, + NULL); + if (status != QDF_STATUS_SUCCESS) + policy_mgr_err("Failed to deregister vdev obj status cback"); status = wlan_objmgr_unregister_vdev_destroy_handler( WLAN_UMAC_COMP_POLICY_MGR, @@ -223,12 +304,12 @@ QDF_STATUS policy_mgr_deinit(void) if (status != QDF_STATUS_SUCCESS) policy_mgr_err("Failed to deregister vdev obj delete cback"); - status = wlan_objmgr_unregister_vdev_status_handler( + status = wlan_objmgr_unregister_vdev_create_handler( WLAN_UMAC_COMP_POLICY_MGR, - policy_mgr_vdev_obj_status_cb, + policy_mgr_vdev_obj_create_cb, NULL); if (status != QDF_STATUS_SUCCESS) - policy_mgr_err("Failed to deregister vdev obj status cback"); + policy_mgr_err("Failed to deregister vdev obj create cback"); policy_mgr_info("deregistered callbacks with obj mgr successfully"); diff --git a/src/wlan_policy_mgr_pcl.c b/src/wlan_policy_mgr_pcl.c index edc96138353e..364bced7357d 100644 --- a/src/wlan_policy_mgr_pcl.c +++ b/src/wlan_policy_mgr_pcl.c @@ -140,16 +140,18 @@ void policy_mgr_update_with_safe_channel_list(uint8_t *pcl_channels, } static QDF_STATUS policy_mgr_modify_pcl_based_on_enabled_channels( - uint8_t *pcl_list_org, - uint8_t *weight_list_org, - uint32_t *pcl_len_org) + struct policy_mgr_psoc_priv_obj *pm_ctx, + uint8_t *pcl_list_org, + uint8_t *weight_list_org, + uint32_t *pcl_len_org) { uint32_t i, pcl_len = 0; uint8_t pcl_list[QDF_MAX_NUM_CHAN]; uint8_t weight_list[QDF_MAX_NUM_CHAN]; for (i = 0; i < *pcl_len_org; i++) { - if (!wlan_reg_is_passive_or_disable_ch(pcl_list_org[i])) { + if (!wlan_reg_is_passive_or_disable_ch( + pm_ctx->pdev, pcl_list_org[i])) { pcl_list[pcl_len] = pcl_list_org[i]; weight_list[pcl_len++] = weight_list_org[i]; } @@ -320,7 +322,7 @@ QDF_STATUS policy_mgr_get_pcl(struct wlan_objmgr_psoc *psoc, if (mode == PM_P2P_GO_MODE) { status = policy_mgr_modify_pcl_based_on_enabled_channels( - pcl_channels, pcl_weight, len); + pm_ctx, pcl_channels, pcl_weight, len); if (QDF_IS_STATUS_ERROR(status)) { policy_mgr_err("failed to get modified pcl for GO"); return status; @@ -1104,6 +1106,7 @@ policy_mgr_get_nondfs_preferred_channel(struct wlan_objmgr_psoc *psoc, { uint8_t pcl_channels[QDF_MAX_NUM_CHAN]; uint8_t pcl_weight[QDF_MAX_NUM_CHAN]; + struct policy_mgr_psoc_priv_obj *pm_ctx; /* * in worst case if we can't find any channel at all @@ -1113,6 +1116,12 @@ policy_mgr_get_nondfs_preferred_channel(struct wlan_objmgr_psoc *psoc, uint8_t channel = PM_24_GHZ_CHANNEL_6; uint32_t i, pcl_len; + pm_ctx = policy_mgr_get_context(psoc); + if (!pm_ctx) { + policy_mgr_err("Invalid Context"); + return channel; + } + if (true == for_existing_conn) { /* * First try to see if there is any non-dfs channel already @@ -1136,7 +1145,7 @@ policy_mgr_get_nondfs_preferred_channel(struct wlan_objmgr_psoc *psoc, } for (i = 0; i < pcl_len; i++) { - if (wlan_reg_is_dfs_ch(psoc, pcl_channels[i])) { + if (wlan_reg_is_dfs_ch(pm_ctx->pdev, pcl_channels[i])) { continue; } else { channel = pcl_channels[i];