From f8f30ced97843e47923b377e259abb3bb7285be9 Mon Sep 17 00:00:00 2001 From: Hariharan Basuthkar Date: Mon, 23 Dec 2019 17:35:55 +0530 Subject: [PATCH] qcacmn: Get opclass from freq and width given a country code Add the API wlan_reg_get_opclass_from_freq_width, to give country_iso, channel frequency, channel width and behaviour limit as input, and get the operating class as output. Change-Id: I96c39119ab855d10965b2603e8b15c21699daa68 CRs-Fixed: 2583789 --- umac/regulatory/core/src/reg_opclass.c | 28 +++++++++++++++++++ umac/regulatory/core/src/reg_opclass.h | 24 ++++++++++++++++ .../dispatcher/inc/wlan_reg_services_api.h | 15 ++++++++++ .../dispatcher/src/wlan_reg_services_api.c | 9 ++++++ 4 files changed, 76 insertions(+) diff --git a/umac/regulatory/core/src/reg_opclass.c b/umac/regulatory/core/src/reg_opclass.c index 4081ee79d523..d856f1397941 100644 --- a/umac/regulatory/core/src/reg_opclass.c +++ b/umac/regulatory/core/src/reg_opclass.c @@ -342,6 +342,34 @@ uint16_t reg_dmn_get_opclass_from_channel(uint8_t *country, uint8_t channel, return 0; } +uint8_t reg_dmn_get_opclass_from_freq_width(uint8_t *country, + qdf_freq_t freq, + uint8_t ch_width, + uint16_t behav_limit) +{ + const struct reg_dmn_op_class_map_t *op_class_tbl = NULL; + uint16_t i = 0; + + op_class_tbl = reg_get_class_from_country(country); + + while (op_class_tbl && op_class_tbl->op_class) { + if (op_class_tbl->chan_spacing == ch_width) { + for (i = 0; (i < REG_MAX_CHANNELS_PER_OPERATING_CLASS && + op_class_tbl->channels[i]); i++) { + if ((op_class_tbl->start_freq + + (FREQ_TO_CHAN_SCALE * + op_class_tbl->channels[i]) == freq) && + (behav_limit & op_class_tbl->behav_limit)) { + return op_class_tbl->op_class; + } + } + } + op_class_tbl++; + } + + return 0; +} + void reg_dmn_print_channels_in_opclass(uint8_t *country, uint8_t op_class) { const struct reg_dmn_op_class_map_t *class = NULL; diff --git a/umac/regulatory/core/src/reg_opclass.h b/umac/regulatory/core/src/reg_opclass.h index 28ea0f63869d..834f3d789ad5 100644 --- a/umac/regulatory/core/src/reg_opclass.h +++ b/umac/regulatory/core/src/reg_opclass.h @@ -47,6 +47,21 @@ uint16_t reg_dmn_get_chanwidth_from_opclass(uint8_t *country, uint8_t channel, */ uint16_t reg_dmn_get_opclass_from_channel(uint8_t *country, uint8_t channel, uint8_t offset); + +/** + * reg_dmn_get_opclass_from_freq_width() - Get operating class from frequency + * @country: Country code. + * @freq: Channel center frequency. + * @ch_width: Channel width. + * @behav_limit: Behaviour limit. + * + * Return: Error code. + */ +uint8_t reg_dmn_get_opclass_from_freq_width(uint8_t *country, + qdf_freq_t freq, + uint8_t ch_width, + uint16_t behav_limit); + /** * reg_dmn_get_opclass_from_channe() - Print channels in op class. * @country: Country code. @@ -166,6 +181,15 @@ static inline uint16_t reg_dmn_get_opclass_from_channel( return 0; } +static inline +uint8_t reg_dmn_get_opclass_from_freq_width(uint8_t *country, + qdf_freq_t freq, + uint8_t ch_width, + uint16_t behav_limit) +{ + return 0; +} + static inline void reg_dmn_print_channels_in_opclass(uint8_t *country, uint8_t op_class) { diff --git a/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h b/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h index ee262d003b7c..dc892342f6b7 100644 --- a/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h +++ b/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h @@ -546,6 +546,21 @@ QDF_STATUS wlan_reg_get_domain_from_country_code(v_REGDOMAIN_t *reg_domain_ptr, uint16_t wlan_reg_dmn_get_opclass_from_channel(uint8_t *country, uint8_t channel, uint8_t offset); + +/** + * wlan_reg_get_opclass_from_freq_width() - Get operating class from frequency + * @country: Country code. + * @freq: Channel center frequency. + * @ch_width: Channel width. + * @behav_limit: Behaviour limit. + * + * Return: Error code. + */ +uint8_t wlan_reg_get_opclass_from_freq_width(uint8_t *country, + qdf_freq_t freq, + uint8_t ch_width, + uint16_t behav_limit); + /** * wlan_reg_dmn_print_channels_in_opclass() - Print channels in op-class * @country: country alpha2 diff --git a/umac/regulatory/dispatcher/src/wlan_reg_services_api.c b/umac/regulatory/dispatcher/src/wlan_reg_services_api.c index 288b43b60c93..22f2482c6ac6 100644 --- a/umac/regulatory/dispatcher/src/wlan_reg_services_api.c +++ b/umac/regulatory/dispatcher/src/wlan_reg_services_api.c @@ -267,6 +267,15 @@ uint16_t wlan_reg_dmn_get_opclass_from_channel(uint8_t *country, offset); } +uint8_t wlan_reg_get_opclass_from_freq_width(uint8_t *country, + qdf_freq_t freq, + uint8_t ch_width, + uint16_t behav_limit) +{ + return reg_dmn_get_opclass_from_freq_width(country, freq, ch_width, + behav_limit); +} + void wlan_reg_dmn_print_channels_in_opclass(uint8_t *country, uint8_t opclass) {