diff --git a/umac/regulatory/core/src/reg_opclass.c b/umac/regulatory/core/src/reg_opclass.c index b742aff6a9f1..df7a7d7654be 100644 --- a/umac/regulatory/core/src/reg_opclass.c +++ b/umac/regulatory/core/src/reg_opclass.c @@ -972,4 +972,61 @@ QDF_STATUS reg_get_opclass_details(struct wlan_objmgr_pdev *pdev, return QDF_STATUS_SUCCESS; } +bool reg_is_6ghz_op_class(struct wlan_objmgr_pdev *pdev, uint8_t op_class) +{ + return ((op_class >= MIN_6GHZ_OPER_CLASS) && + (op_class <= MAX_6GHZ_OPER_CLASS)); +} + +/** + * reg_is_opclass_band_found - Check if the input opclass is 2G or 5G. + * + * @country - Pointer to country. + * @op_class - Operating class. + * @bandmask = Bitmask for band. + * + * Return : Return true if the input opclass' band (2Ghz or 5Ghz) matches one + * of bandmask's band. + */ +static bool reg_is_opclass_band_found(const uint8_t *country, + uint8_t op_class, + uint8_t bandmask) +{ + const struct reg_dmn_op_class_map_t *op_class_tbl; + + op_class_tbl = reg_get_class_from_country((uint8_t *)country); + + while (op_class_tbl && op_class_tbl->op_class) { + if (op_class_tbl->op_class == op_class) { + qdf_freq_t freq = op_class_tbl->start_freq + + (op_class_tbl->channels[0] * FREQ_TO_CHAN_SCALE); + + if ((bandmask & BIT(REG_BAND_5G)) && + REG_IS_5GHZ_FREQ(freq)) + return true; + + if ((bandmask & BIT(REG_BAND_2G)) && + REG_IS_24GHZ_CH_FREQ(freq)) + return true; + + return false; + } + + op_class_tbl++; + } + + reg_err_rl("Opclass %d is not found", op_class); + + return false; +} + +bool reg_is_5ghz_op_class(const uint8_t *country, uint8_t op_class) +{ + return reg_is_opclass_band_found(country, op_class, BIT(REG_BAND_5G)); +} + +bool reg_is_2ghz_op_class(const uint8_t *country, uint8_t op_class) +{ + return reg_is_opclass_band_found(country, op_class, BIT(REG_BAND_2G)); +} #endif diff --git a/umac/regulatory/core/src/reg_opclass.h b/umac/regulatory/core/src/reg_opclass.h index 53f27e66e94f..96f1650db6a9 100644 --- a/umac/regulatory/core/src/reg_opclass.h +++ b/umac/regulatory/core/src/reg_opclass.h @@ -119,6 +119,27 @@ QDF_STATUS reg_get_opclass_details(struct wlan_objmgr_pdev *pdev, uint8_t *n_opclasses, uint8_t max_supp_op_class, bool global_tbl_lookup); + +/** + * reg_is_5ghz_op_class() - Check if the input opclass is a 5GHz opclass. + * @country: Country code. + * @op_class: Operating class. + * + * Return: Return true if input the opclass is a 5GHz opclass, + * else return false. + */ +bool reg_is_5ghz_op_class(const uint8_t *country, uint8_t op_class); + +/** + * reg_is_2ghz_op_class() - Check if the input opclass is a 2.4GHz opclass. + * @country: Country code. + * @op_class: Operating class. + * + * Return: Return true if input the opclass is a 2.4GHz opclass, + * else return false. + */ +bool reg_is_2ghz_op_class(const uint8_t *country, uint8_t op_class); + #ifdef CONFIG_CHAN_FREQ_API /** @@ -316,6 +337,18 @@ QDF_STATUS reg_get_opclass_details(struct wlan_objmgr_pdev *pdev, return QDF_STATUS_E_FAILURE; } +static inline +bool reg_is_5ghz_op_class(const uint8_t *country, uint8_t op_class) +{ + return false; +} + +static inline +bool reg_is_2ghz_op_class(const uint8_t *country, uint8_t op_class) +{ + return false; +} + #ifdef CONFIG_CHAN_FREQ_API static inline void diff --git a/umac/regulatory/core/src/reg_services_common.c b/umac/regulatory/core/src/reg_services_common.c index 890252a6f8eb..072906a18aa7 100644 --- a/umac/regulatory/core/src/reg_services_common.c +++ b/umac/regulatory/core/src/reg_services_common.c @@ -3881,12 +3881,6 @@ reg_set_5dot9_ghz_supported(struct wlan_objmgr_psoc *psoc, bool val) return QDF_STATUS_SUCCESS; } -bool reg_is_6ghz_op_class(struct wlan_objmgr_pdev *pdev, uint8_t op_class) -{ - return ((op_class >= MIN_6GHZ_OPER_CLASS) && - (op_class <= MAX_6GHZ_OPER_CLASS)); -} - #ifdef CONFIG_REG_CLIENT bool reg_is_6ghz_supported(struct wlan_objmgr_psoc *psoc) { diff --git a/umac/regulatory/dispatcher/inc/reg_services_public_struct.h b/umac/regulatory/dispatcher/inc/reg_services_public_struct.h index fcaebfa36875..4a20cb2f3ed9 100644 --- a/umac/regulatory/dispatcher/inc/reg_services_public_struct.h +++ b/umac/regulatory/dispatcher/inc/reg_services_public_struct.h @@ -1139,13 +1139,13 @@ struct avoid_freq_ind_data { struct unsafe_ch_list chan_list; }; -#define FIVEG_STARTING_FREQ 5000 -#define TWOG_STARTING_FREQ 2407 -#define TWOG_CHAN_14_IN_MHZ 2484 -#define TWOG_CHAN_1_IN_MHZ 2412 -#define TWOG_CHAN_5_IN_MHZ 2432 -#define TWOG_CHAN_6_IN_MHZ 2437 -#define TWOG_CHAN_13_IN_MHZ 2472 +#define FIVEG_STARTING_FREQ 5000 +#define TWOG_STARTING_FREQ 2407 +#define TWOG_CHAN_14_IN_MHZ 2484 +#define TWOG_CHAN_1_IN_MHZ 2412 +#define TWOG_CHAN_5_IN_MHZ 2432 +#define TWOG_CHAN_6_IN_MHZ 2437 +#define TWOG_CHAN_13_IN_MHZ 2472 /** * struct reg_ctl_params - reg ctl and regd info diff --git a/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h b/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h index b19a52487543..84f35fcb74d7 100644 --- a/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h +++ b/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h @@ -1369,6 +1369,26 @@ uint16_t wlan_reg_get_op_class_width(struct wlan_objmgr_pdev *pdev, uint8_t op_class, bool global_tbl_lookup); +/** + * wlan_reg_is_5ghz_op_class() - Check if the input opclass is a 5GHz opclass. + * @country: Country code. + * @op_class: Operating class. + * + * Return: Return true if input the opclass is a 5GHz opclass, + * else return false. + */ +bool wlan_reg_is_5ghz_op_class(const uint8_t *country, uint8_t op_class); + +/** + * wlan_reg_is_2ghz_op_class() - Check if the input opclass is a 2.4GHz opclass. + * @country: Country code. + * @op_class: Operating class. + * + * Return: Return true if input the opclass is a 2.4GHz opclass, + * else return false. + */ +bool wlan_reg_is_2ghz_op_class(const uint8_t *country, uint8_t op_class); + /** * wlan_reg_is_6ghz_op_class() - Whether 6ghz oper class * @pdev: pdev ptr diff --git a/umac/regulatory/dispatcher/src/wlan_reg_services_api.c b/umac/regulatory/dispatcher/src/wlan_reg_services_api.c index 91cf76785d7a..ce884a729c2a 100644 --- a/umac/regulatory/dispatcher/src/wlan_reg_services_api.c +++ b/umac/regulatory/dispatcher/src/wlan_reg_services_api.c @@ -1155,6 +1155,16 @@ uint16_t wlan_reg_get_op_class_width(struct wlan_objmgr_pdev *pdev, global_tbl_lookup); } +bool wlan_reg_is_5ghz_op_class(const uint8_t *country, uint8_t op_class) +{ + return reg_is_5ghz_op_class(country, op_class); +} + +bool wlan_reg_is_2ghz_op_class(const uint8_t *country, uint8_t op_class) +{ + return reg_is_2ghz_op_class(country, op_class); +} + bool wlan_reg_is_6ghz_op_class(struct wlan_objmgr_pdev *pdev, uint8_t op_class) {