From 40f177fad456d25f65f4dea03c4e4f0c37d5fdbf Mon Sep 17 00:00:00 2001 From: Lincoln Tran Date: Tue, 26 Jan 2021 14:11:39 -0800 Subject: [PATCH] qcacmn: Add logic to decide AP pwr mode when starting Add logic to decide which power mode the AP should start in Change-Id: I59b64e6ca26d47e395575ab129f35b97ddcc6737 CRs-fixed: 2863552 --- umac/regulatory/core/src/reg_db.c | 14 ------- umac/regulatory/core/src/reg_db.h | 22 ++++++++++- .../regulatory/core/src/reg_services_common.c | 38 +++++++++++++++++++ .../regulatory/core/src/reg_services_common.h | 15 ++++++++ .../dispatcher/inc/wlan_reg_services_api.h | 18 +++++++++ .../dispatcher/src/wlan_reg_services_api.c | 6 +++ 6 files changed, 97 insertions(+), 16 deletions(-) diff --git a/umac/regulatory/core/src/reg_db.c b/umac/regulatory/core/src/reg_db.c index 2ee8d4f051ad..60c2c8a936f8 100644 --- a/umac/regulatory/core/src/reg_db.c +++ b/umac/regulatory/core/src/reg_db.c @@ -1601,20 +1601,6 @@ const struct regdomain regdomains_5g[] = { }; #if defined(CONFIG_BAND_6GHZ) && defined(COMPILE_REGDB_6G) -/** - * enum reg_super_domain_6g - 6G Super Domain enumeration - * @FCC1_6G: Super domain FCC1_6G - * @ETSI1_6G: Super domain ETSI1_6G - * @ETSI2_6G: Super domain ETSI2_6G - * @APL1_6G: Super domain APL1_6G - */ -enum reg_super_domain_6g { - FCC1_6G = 0x01, - ETSI1_6G = 0x02, - ETSI2_6G = 0x03, - APL1_6G = 0x04, -}; - /** * List of 6G Sub Domains. * diff --git a/umac/regulatory/core/src/reg_db.h b/umac/regulatory/core/src/reg_db.h index 7ec887178aac..21136bbe1a26 100644 --- a/umac/regulatory/core/src/reg_db.h +++ b/umac/regulatory/core/src/reg_db.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2020 The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2021 The Linux Foundation. All rights reserved. * * * Permission to use, copy, modify, and/or distribute this software for @@ -160,7 +160,24 @@ struct reg_domain_pair { uint8_t dmn_id_2g; }; -#if defined(CONFIG_BAND_6GHZ) && defined(COMPILE_REGDB_6G) +#if defined(CONFIG_BAND_6GHZ) +/** + * enum reg_super_domain_6g - 6G Super Domain enumeration + * @FCC1_6G: Super domain FCC1_6G for US + * @ETSI1_6G: Super domain ETSI1_6G + * @ETSI2_6G: Super domain ETSI2_6G + * @APL1_6G: Super domain APL1_6G + * @FCC1_6G_CL: Super domain FCC1_6G for Chile + */ +enum reg_super_domain_6g { + FCC1_6G = 0x01, + ETSI1_6G = 0x02, + ETSI2_6G = 0x03, + APL1_6G = 0x04, + FCC1_6G_CL = 0x05, +}; + +#if defined(COMPILE_REGDB_6G) /** * struct sixghz_super_to_subdomains * @reg_6ghz_super_dmn_id: 6G super domain id. @@ -181,6 +198,7 @@ struct sixghz_super_to_subdomains { uint8_t reg_domain_6g_id_client_vlp[REG_MAX_CLIENT_TYPE - 1]; }; #endif +#endif QDF_STATUS reg_get_num_countries(int *num_countries); diff --git a/umac/regulatory/core/src/reg_services_common.c b/umac/regulatory/core/src/reg_services_common.c index 3cb6a6852989..ea623d4925e8 100644 --- a/umac/regulatory/core/src/reg_services_common.c +++ b/umac/regulatory/core/src/reg_services_common.c @@ -4476,6 +4476,9 @@ QDF_STATUS reg_get_client_power_for_6ghz_ap(struct wlan_objmgr_pdev *pdev, return QDF_STATUS_E_FAILURE; } + if (ap_pwr_type >= REG_CURRENT_MAX_AP_TYPE) + return QDF_STATUS_E_FAILURE; + master_chan_list = pdev_priv_obj-> mas_chan_list_6g_client[ap_pwr_type][client_type]; @@ -4491,4 +4494,39 @@ QDF_STATUS reg_get_client_power_for_6ghz_ap(struct wlan_objmgr_pdev *pdev, return status; } +/** + * reg_is_afc_available() - check if the automated frequency control system is + * available, function will need to be updated once AFC is implemented + * @pdev: Pointer to pdev structure + * + * Return: false since the AFC system is not yet available + */ +static bool reg_is_afc_available(struct wlan_objmgr_pdev *pdev) +{ + return false; +} + +enum reg_6g_ap_type reg_decide_6g_ap_pwr_type(struct wlan_objmgr_pdev *pdev) +{ + struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj; + enum reg_6g_ap_type ap_pwr_type = REG_INDOOR_AP; + + pdev_priv_obj = reg_get_pdev_obj(pdev); + if (!IS_VALID_PDEV_REG_OBJ(pdev_priv_obj)) { + reg_err("pdev reg component is NULL"); + return REG_VERY_LOW_POWER_AP; + } + + if (reg_is_afc_available(pdev)) + ap_pwr_type = REG_STANDARD_POWER_AP; + else if (pdev_priv_obj->indoor_chan_enabled) + ap_pwr_type = REG_INDOOR_AP; + else if (pdev_priv_obj->reg_6g_superid != FCC1_6G && + pdev_priv_obj->reg_6g_superid != FCC1_6G_CL) + ap_pwr_type = REG_VERY_LOW_POWER_AP; + + reg_set_cur_6g_ap_pwr_type(pdev, ap_pwr_type); + + return ap_pwr_type; +} #endif diff --git a/umac/regulatory/core/src/reg_services_common.h b/umac/regulatory/core/src/reg_services_common.h index 3c11f3123cb8..0f860d5add83 100644 --- a/umac/regulatory/core/src/reg_services_common.h +++ b/umac/regulatory/core/src/reg_services_common.h @@ -1435,6 +1435,15 @@ QDF_STATUS reg_get_client_power_for_6ghz_ap(struct wlan_objmgr_pdev *pdev, qdf_freq_t chan_freq, bool *is_psd, uint16_t *tx_power, uint16_t *eirp_psd_power); + +/** + * reg_decide_6g_ap_pwr_type() - Decide which power mode AP should operate in + * + * @pdev: pdev ptr + * + * Return: AP power type + */ +enum reg_6g_ap_type reg_decide_6g_ap_pwr_type(struct wlan_objmgr_pdev *pdev); #else static inline QDF_STATUS reg_set_cur_6g_ap_pwr_type(struct wlan_objmgr_pdev *pdev, @@ -1520,5 +1529,11 @@ QDF_STATUS reg_get_client_power_for_6ghz_ap(struct wlan_objmgr_pdev *pdev, *eirp_psd_power = 0; return QDF_STATUS_E_NOSUPPORT; } + +static inline enum reg_6g_ap_type +reg_decide_6g_ap_pwr_type(struct wlan_objmgr_pdev *pdev) +{ + return REG_INDOOR_AP; +} #endif #endif diff --git a/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h b/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h index 8fc347c6dde2..68207f02df8e 100644 --- a/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h +++ b/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h @@ -1718,6 +1718,17 @@ wlan_reg_get_client_power_for_6ghz_ap(struct wlan_objmgr_pdev *pdev, qdf_freq_t chan_freq, bool *is_psd, uint16_t *tx_power, uint16_t *eirp_psd_power); + +/** + * wlan_reg_decide_6g_ap_pwr_type() - Decide which power mode AP should operate + * in + * + * @pdev: pdev ptr + * + * Return: AP power type + */ +enum reg_6g_ap_type +wlan_reg_decide_6g_ap_pwr_type(struct wlan_objmgr_pdev *pdev); #else static inline QDF_STATUS wlan_reg_get_cur_6g_client_type(struct wlan_objmgr_pdev *pdev, @@ -1787,5 +1798,12 @@ wlan_reg_get_client_power_for_6ghz_ap(struct wlan_objmgr_pdev *pdev, *eirp_psd_power = 0; return QDF_STATUS_E_NOSUPPORT; } + +static inline +enum reg_6g_ap_type +wlan_reg_decide_6g_ap_pwr_type(struct wlan_objmgr_pdev *pdev) +{ + return REG_INDOOR_AP; +} #endif #endif diff --git a/umac/regulatory/dispatcher/src/wlan_reg_services_api.c b/umac/regulatory/dispatcher/src/wlan_reg_services_api.c index 840955c42eaa..2db75f2cbc4a 100644 --- a/umac/regulatory/dispatcher/src/wlan_reg_services_api.c +++ b/umac/regulatory/dispatcher/src/wlan_reg_services_api.c @@ -1361,4 +1361,10 @@ wlan_reg_get_client_power_for_6ghz_ap(struct wlan_objmgr_pdev *pdev, is_psd, tx_power, eirp_psd_power); } + +enum reg_6g_ap_type +wlan_reg_decide_6g_ap_pwr_type(struct wlan_objmgr_pdev *pdev) +{ + return reg_decide_6g_ap_pwr_type(pdev); +} #endif