From 3f9b04cf46478eb2c2ff7aab0e284ebdc4e58f4a Mon Sep 17 00:00:00 2001 From: Ganesh Kondabattini Date: Tue, 8 Aug 2017 12:19:00 +0530 Subject: [PATCH] qcacmn: Initialize SAP mandatory chan list Initialize SAP mandatory chan list. Change-Id: I126d67da1bfe8426cd3a7b031e97aba907e6155a CRs-Fixed: 2089122 --- .../policy_mgr/inc/wlan_policy_mgr_api.h | 74 ++++++++++ .../policy_mgr/src/wlan_policy_mgr_core.c | 126 ++++++++++++++++++ .../policy_mgr/src/wlan_policy_mgr_i.h | 1 + 3 files changed, 201 insertions(+) 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 ffe2fe12c80c..94668d76e366 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 @@ -2011,4 +2011,78 @@ bool policy_mgr_disallow_mcc(struct wlan_objmgr_psoc *psoc, */ uint8_t policy_mgr_mode_specific_get_channel( struct wlan_objmgr_psoc *psoc, enum policy_mgr_con_mode mode); + +/** + * policy_mgr_enable_disable_sap_mandatory_chan_list() - Update the value of + * enable_sap_mandatory_chan_list + * @psoc: Pointer to soc + * @val: value of enable_sap_mandatory_chan_list + * + * Update the value of enable_sap_mandatory_chan_list + * + * Return: void + */ +void policy_mgr_enable_disable_sap_mandatory_chan_list( + struct wlan_objmgr_psoc *psoc, bool val); + +/** + * policy_mgr_add_sap_mandatory_chan() - Add chan to SAP mandatory channel + * list + * @psoc: Pointer to soc + * @chan: Channel to be added + * + * Add chan to SAP mandatory channel list + * + * Return: None + */ +void policy_mgr_add_sap_mandatory_chan(struct wlan_objmgr_psoc *psoc, + uint8_t chan); + +/** + * policy_mgr_is_sap_mandatory_chan_list_enabled() - Return the SAP mandatory + * channel list enabled status + * @psoc: Pointer to soc + * + * Get the SAP mandatory channel list enabled status + * + * Return: Enable or Disable + */ +bool policy_mgr_is_sap_mandatory_chan_list_enabled( + struct wlan_objmgr_psoc *psoc); + +/** + * policy_mgr_get_sap_mandatory_chan_list_len() - Return the SAP mandatory + * channel list len + * @psoc: Pointer to soc + * + * Get the SAP mandatory channel list len + * + * Return: Channel list length + */ +uint32_t policy_mgr_get_sap_mandatory_chan_list_len( + struct wlan_objmgr_psoc *psoc); + +/** + * policy_mgr_init_sap_mandatory_2g_chan() - Init 2.4G SAP mandatory channel + * list + * @psoc: Pointer to soc + * + * Initialize the 2.4G SAP mandatory channels + * + * Return: None + */ +void policy_mgr_init_sap_mandatory_2g_chan(struct wlan_objmgr_psoc *psoc); + +/** + * policy_mgr_remove_sap_mandatory_chan() - Remove channel from SAP mandatory + * channel list + * @psoc: Pointer to soc + * @chan: channel to be removed from mandatory channel list + * + * Remove channel from SAP mandatory channel list + * + * Return: None + */ +void policy_mgr_remove_sap_mandatory_chan(struct wlan_objmgr_psoc *psoc, + uint8_t chan); #endif /* __WLAN_POLICY_MGR_API_H */ 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 a8a92b446df3..04535e2775db 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 @@ -2681,3 +2681,129 @@ QDF_STATUS policy_mgr_reset_sap_mandatory_channels( return QDF_STATUS_SUCCESS; } + +void policy_mgr_enable_disable_sap_mandatory_chan_list( + struct wlan_objmgr_psoc *psoc, bool val) +{ + struct policy_mgr_psoc_priv_obj *pm_ctx; + + pm_ctx = policy_mgr_get_context(psoc); + if (!pm_ctx) { + policy_mgr_err("Invalid Context"); + return; + } + + pm_ctx->enable_sap_mandatory_chan_list = val; +} + +void policy_mgr_add_sap_mandatory_chan(struct wlan_objmgr_psoc *psoc, + uint8_t chan) +{ + int i; + struct policy_mgr_psoc_priv_obj *pm_ctx; + + pm_ctx = policy_mgr_get_context(psoc); + if (!pm_ctx) { + policy_mgr_err("Invalid Context"); + return; + } + + for (i = 0; i < pm_ctx->sap_mandatory_channels_len; i++) { + if (chan == pm_ctx->sap_mandatory_channels[i]) + return; + } + + policy_mgr_debug("chan %hu", chan); + pm_ctx->sap_mandatory_channels[pm_ctx->sap_mandatory_channels_len++] + = chan; +} + +bool policy_mgr_is_sap_mandatory_chan_list_enabled( + struct wlan_objmgr_psoc *psoc) +{ + struct policy_mgr_psoc_priv_obj *pm_ctx; + + pm_ctx = policy_mgr_get_context(psoc); + if (!pm_ctx) { + policy_mgr_err("Invalid Context"); + return false; + } + + return pm_ctx->enable_sap_mandatory_chan_list; +} + +uint32_t policy_mgr_get_sap_mandatory_chan_list_len( + struct wlan_objmgr_psoc *psoc) +{ + struct policy_mgr_psoc_priv_obj *pm_ctx; + + pm_ctx = policy_mgr_get_context(psoc); + if (!pm_ctx) { + policy_mgr_err("Invalid Context"); + return 0; + } + + return pm_ctx->sap_mandatory_channels_len; +} + +void policy_mgr_init_sap_mandatory_2g_chan(struct wlan_objmgr_psoc *psoc) +{ + uint8_t chan_list[QDF_MAX_NUM_CHAN] = {0}; + uint32_t len = 0; + int i; + QDF_STATUS status; + 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 = policy_mgr_get_valid_chans(psoc, chan_list, &len); + if (QDF_IS_STATUS_ERROR(status)) { + policy_mgr_err("Error in getting valid channels"); + return; + } + for (i = 0; i < len; i++) { + if (WLAN_REG_IS_24GHZ_CH(chan_list[i])) { + policy_mgr_debug("Add chan %hu to mandatory list", + chan_list[i]); + pm_ctx->sap_mandatory_channels[ + pm_ctx->sap_mandatory_channels_len++] = + chan_list[i]; + } + } +} + +void policy_mgr_remove_sap_mandatory_chan(struct wlan_objmgr_psoc *psoc, + uint8_t chan) +{ + uint8_t chan_list[QDF_MAX_NUM_CHAN] = {0}; + uint32_t num_chan = 0; + int i; + struct policy_mgr_psoc_priv_obj *pm_ctx; + + pm_ctx = policy_mgr_get_context(psoc); + if (!pm_ctx) { + policy_mgr_err("Invalid Context"); + return; + } + + if (pm_ctx->sap_mandatory_channels_len >= QDF_MAX_NUM_CHAN) { + policy_mgr_err("Invalid channel len %d ", + pm_ctx->sap_mandatory_channels_len); + return; + } + + for (i = 0; i < pm_ctx->sap_mandatory_channels_len; i++) { + if (chan == pm_ctx->sap_mandatory_channels[i]) + continue; + chan_list[num_chan++] = pm_ctx->sap_mandatory_channels[i]; + } + + qdf_mem_zero(pm_ctx->sap_mandatory_channels, + pm_ctx->sap_mandatory_channels_len); + qdf_mem_copy(pm_ctx->sap_mandatory_channels, chan_list, num_chan); + pm_ctx->sap_mandatory_channels_len = num_chan; +} 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 2b2fcd88292a..fd5ab69f5846 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 @@ -251,6 +251,7 @@ struct policy_mgr_psoc_priv_obj { struct policy_mgr_wma_cbacks wma_cbacks; struct policy_mgr_tdls_cbacks tdls_cbacks; struct policy_mgr_cdp_cbacks cdp_cbacks; + bool enable_sap_mandatory_chan_list; uint8_t sap_mandatory_channels[QDF_MAX_NUM_CHAN]; uint32_t sap_mandatory_channels_len; bool do_hw_mode_change;