From 82bd127e2d001a943cefaab3774414368fff44ee Mon Sep 17 00:00:00 2001 From: Asutosh Mohapatra Date: Wed, 11 Oct 2023 23:23:29 +0530 Subject: [PATCH] qcacmn: Do not allow connection if STA VLP not supported If country code for AP and STA are same and if STA does not support VLP mode for a particular channel and if AP power type is misconfigured to VLP mode, do not allow connection to that AP as per regulatory guidelines. Change-Id: Ie3bb980df25a15c4d9d7e566663e28950414f733 CRs-Fixed: 3362142 --- umac/regulatory/core/src/reg_utils.c | 34 +++++++++++++++++-- umac/regulatory/core/src/reg_utils.h | 3 ++ .../dispatcher/inc/wlan_reg_services_api.h | 3 ++ .../dispatcher/src/wlan_reg_services_api.c | 3 +- 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/umac/regulatory/core/src/reg_utils.c b/umac/regulatory/core/src/reg_utils.c index e46d47262744..d759460a8926 100644 --- a/umac/regulatory/core/src/reg_utils.c +++ b/umac/regulatory/core/src/reg_utils.c @@ -374,20 +374,36 @@ QDF_STATUS reg_get_domain_from_country_code(v_REGDOMAIN_t *reg_domain_ptr, } #ifdef CONFIG_REG_CLIENT +#ifdef CONFIG_BAND_6GHZ QDF_STATUS reg_get_6g_power_type_for_ctry(struct wlan_objmgr_psoc *psoc, + struct wlan_objmgr_pdev *pdev, uint8_t *ap_ctry, uint8_t *sta_ctry, enum reg_6g_ap_type *pwr_type_6g, bool *ctry_code_match, enum reg_6g_ap_type ap_pwr_type) { - *pwr_type_6g = REG_INDOOR_AP; + struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj; - reg_debug("Country IE:%c%c, STA country:%c%c", ap_ctry[0], - ap_ctry[1], sta_ctry[0], sta_ctry[1]); + *pwr_type_6g = REG_INDOOR_AP; + pdev_priv_obj = reg_get_pdev_obj(pdev); + if (!pdev_priv_obj) { + reg_err("pdev priv obj null"); + return QDF_STATUS_E_FAILURE; + } + + reg_debug("STA country: %c%c, AP country: %c%c, AP power type: %d", + sta_ctry[0], sta_ctry[1], ap_ctry[0], ap_ctry[1], + ap_pwr_type); if (!qdf_mem_cmp(ap_ctry, sta_ctry, REG_ALPHA2_LEN)) { *ctry_code_match = true; + if (ap_pwr_type == REG_VERY_LOW_POWER_AP) { + if (!pdev_priv_obj->reg_rules.num_of_6g_client_reg_rules[ap_pwr_type]) { + reg_err("VLP not supported, can't connect"); + return QDF_STATUS_E_NOSUPPORT; + } + } return QDF_STATUS_SUCCESS; } @@ -425,6 +441,18 @@ reg_get_6g_power_type_for_ctry(struct wlan_objmgr_psoc *psoc, return QDF_STATUS_SUCCESS; } +#else +QDF_STATUS +reg_get_6g_power_type_for_ctry(struct wlan_objmgr_psoc *psoc, + struct wlan_objmgr_pdev *pdev, + uint8_t *ap_ctry, uint8_t *sta_ctry, + enum reg_6g_ap_type *pwr_type_6g, + bool *ctry_code_match, + enum reg_6g_ap_type ap_pwr_type) +{ + return QDF_STATUS_SUCCESS; +} +#endif #endif #ifdef CONFIG_CHAN_NUM_API diff --git a/umac/regulatory/core/src/reg_utils.h b/umac/regulatory/core/src/reg_utils.h index 8b2852e8876a..069a04220aed 100644 --- a/umac/regulatory/core/src/reg_utils.h +++ b/umac/regulatory/core/src/reg_utils.h @@ -300,6 +300,8 @@ QDF_STATUS reg_get_domain_from_country_code(v_REGDOMAIN_t *reg_domain_ptr, #ifdef CONFIG_REG_CLIENT /** * reg_get_6g_power_type_for_ctry() - Return power type for 6G based on cntry IE + * @psoc: pointer to psoc + * @pdev: pointer to pdev * @ap_ctry: ptr to country string in country IE * @sta_ctry: ptr to sta programmed country * @pwr_type_6g: ptr to 6G power type @@ -309,6 +311,7 @@ QDF_STATUS reg_get_domain_from_country_code(v_REGDOMAIN_t *reg_domain_ptr, */ QDF_STATUS reg_get_6g_power_type_for_ctry(struct wlan_objmgr_psoc *psoc, + struct wlan_objmgr_pdev *pdev, uint8_t *ap_ctry, uint8_t *sta_ctry, enum reg_6g_ap_type *pwr_type_6g, bool *ctry_code_match, diff --git a/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h b/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h index 187708519c04..5019ea4e8afe 100644 --- a/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h +++ b/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h @@ -543,6 +543,8 @@ QDF_STATUS wlan_reg_read_current_country(struct wlan_objmgr_psoc *psoc, /** * wlan_reg_get_6g_power_type_for_ctry() - Return power type for 6G based * on country IE + * @psoc: pointer to psoc + * @pdev: pointer to pdev * @ap_ctry: ptr to country string in country IE * @sta_ctry: ptr to sta programmed country * @pwr_type_6g: ptr to 6G power type @@ -552,6 +554,7 @@ QDF_STATUS wlan_reg_read_current_country(struct wlan_objmgr_psoc *psoc, */ QDF_STATUS wlan_reg_get_6g_power_type_for_ctry(struct wlan_objmgr_psoc *psoc, + struct wlan_objmgr_pdev *pdev, uint8_t *ap_ctry, uint8_t *sta_ctry, enum reg_6g_ap_type *pwr_type_6g, bool *ctry_code_match, diff --git a/umac/regulatory/dispatcher/src/wlan_reg_services_api.c b/umac/regulatory/dispatcher/src/wlan_reg_services_api.c index ff2c1bf67ceb..95ed22420a5b 100644 --- a/umac/regulatory/dispatcher/src/wlan_reg_services_api.c +++ b/umac/regulatory/dispatcher/src/wlan_reg_services_api.c @@ -88,12 +88,13 @@ QDF_STATUS wlan_reg_get_max_5g_bw_from_regdomain(uint16_t regdmn, #ifdef CONFIG_REG_CLIENT QDF_STATUS wlan_reg_get_6g_power_type_for_ctry(struct wlan_objmgr_psoc *psoc, + struct wlan_objmgr_pdev *pdev, uint8_t *ap_ctry, uint8_t *sta_ctry, enum reg_6g_ap_type *pwr_type_6g, bool *ctry_code_match, enum reg_6g_ap_type ap_pwr_type) { - return reg_get_6g_power_type_for_ctry(psoc, ap_ctry, sta_ctry, + return reg_get_6g_power_type_for_ctry(psoc, pdev, ap_ctry, sta_ctry, pwr_type_6g, ctry_code_match, ap_pwr_type); }