From 70259d625264cae705fdab13ab49ad29e6e7dd44 Mon Sep 17 00:00:00 2001 From: Amar Singhal Date: Wed, 12 Feb 2020 12:07:12 -0800 Subject: [PATCH] qcacmn: Define a new regulatory API for frequency check Given country from country IE and operating class, check whether a channel frequency belongs to that pair. Change-Id: I9bf711b2c52ad230a3066113a5aa7b8959219754 CRs-Fixed: 2620767 --- umac/regulatory/core/src/reg_opclass.c | 27 +++++++++++++++++++ umac/regulatory/core/src/reg_opclass.h | 25 ++++++++++++++++- .../dispatcher/inc/wlan_reg_services_api.h | 15 +++++++++++ .../dispatcher/src/wlan_reg_services_api.c | 9 +++++++ 4 files changed, 75 insertions(+), 1 deletion(-) diff --git a/umac/regulatory/core/src/reg_opclass.c b/umac/regulatory/core/src/reg_opclass.c index 27d0db4006df..bf440bfd75f4 100644 --- a/umac/regulatory/core/src/reg_opclass.c +++ b/umac/regulatory/core/src/reg_opclass.c @@ -526,6 +526,32 @@ void reg_freq_to_chan_op_class(struct wlan_objmgr_pdev *pdev, op_class, chan_num); } + +bool reg_country_opclass_freq_check(struct wlan_objmgr_pdev *pdev, + const uint8_t country[3], + uint8_t op_class, + qdf_freq_t chan_freq) +{ + const struct reg_dmn_op_class_map_t *op_class_tbl; + uint8_t i; + + 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) { + for (i = 0; (i < REG_MAX_CHANNELS_PER_OPERATING_CLASS && + op_class_tbl->channels[i]); i++) { + if (op_class_tbl->channels[i] * + FREQ_TO_CHAN_SCALE + + op_class_tbl->start_freq == chan_freq) + return true; + } + } + op_class_tbl++; + } + return false; +} + #endif uint16_t reg_get_op_class_width(struct wlan_objmgr_pdev *pdev, @@ -781,4 +807,5 @@ QDF_STATUS reg_get_opclass_details(struct wlan_objmgr_pdev *pdev, return QDF_STATUS_SUCCESS; } + #endif diff --git a/umac/regulatory/core/src/reg_opclass.h b/umac/regulatory/core/src/reg_opclass.h index 3b5c8dcf3446..2c0fca0044b7 100644 --- a/umac/regulatory/core/src/reg_opclass.h +++ b/umac/regulatory/core/src/reg_opclass.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2020 The Linux Foundation. All rights reserved. * * * Permission to use, copy, modify, and/or distribute this software for @@ -145,6 +145,21 @@ void reg_freq_to_chan_op_class(struct wlan_objmgr_pdev *pdev, uint16_t behav_limit, uint8_t *op_class, uint8_t *chan_num); + +/** + * reg_country_opclass_freq_check() - check for frequency in (tbl, oper class) + * + * @pdev: pdev pointer + * @country: country from country IE + * @op_class: operating class + * @chan_freq: channel frequency in mhz + * + * Return: bool + */ +bool reg_country_opclass_freq_check(struct wlan_objmgr_pdev *pdev, + const uint8_t country[3], + uint8_t op_class, + qdf_freq_t chan_freq); #endif /** @@ -243,6 +258,14 @@ reg_freq_to_chan_op_class(struct wlan_objmgr_pdev *pdev, { } +static inline bool +reg_country_opclass_freq_check(struct wlan_objmgr_pdev *pdev, + const uint8_t country[3], + uint8_t op_class, + uint16_t chan_freq) +{ +} + #endif static inline uint16_t reg_get_op_class_width(struct wlan_objmgr_pdev *pdev, diff --git a/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h b/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h index 0d6c6f81e5d4..a15392a1d584 100644 --- a/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h +++ b/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h @@ -1171,6 +1171,21 @@ void wlan_reg_freq_to_chan_op_class(struct wlan_objmgr_pdev *pdev, uint8_t *op_class, uint8_t *chan_num); +/** + * wlan_reg_country_opclass_freq_check() - checks frequency in (ctry, op class) + * pair + * @pdev: pdev ptr + * @country: country information + * @op_class: operating class + * @chan_freq: channel frequency + * + * Return: bool + */ +bool wlan_reg_country_opclass_freq_check(struct wlan_objmgr_pdev *pdev, + const uint8_t country[3], + uint8_t op_class, + qdf_freq_t chan_freq); + /** * wlan_reg_get_5g_bonded_channel_and_state_for_freq()- Return the channel * state for a 5G or 6G channel frequency based on the channel width and diff --git a/umac/regulatory/dispatcher/src/wlan_reg_services_api.c b/umac/regulatory/dispatcher/src/wlan_reg_services_api.c index 04fa78e76b17..ada6101a9c04 100644 --- a/umac/regulatory/dispatcher/src/wlan_reg_services_api.c +++ b/umac/regulatory/dispatcher/src/wlan_reg_services_api.c @@ -1009,6 +1009,15 @@ void wlan_reg_freq_to_chan_op_class(struct wlan_objmgr_pdev *pdev, chan_num); } +bool wlan_reg_country_opclass_freq_check(struct wlan_objmgr_pdev *pdev, + const uint8_t country[3], + uint8_t op_class, + qdf_freq_t chan_freq) +{ + return reg_country_opclass_freq_check(pdev, country, + op_class, chan_freq); +} + enum channel_state wlan_reg_get_5g_bonded_channel_and_state_for_freq(struct wlan_objmgr_pdev *pdev, uint16_t freq,