From 499d20b63be809fccd096a74ee2f6dac79abc2e7 Mon Sep 17 00:00:00 2001 From: Amar Singhal Date: Wed, 18 Sep 2019 15:17:41 -0700 Subject: [PATCH] qcacmn: Re-implement IEEE80211 operating classes Add starting frequency to each operating class. Further add behavior limit to each operating class, if any. Behaviour limit is used for 80p80, 40 mhz low primary, etc operating class identification. Also add 6-ghz operating classes 131-135 to the global operating class. Also add APIs that are based on frequency instead of channel number. Change-Id: Ic8756aada6c31ed2164f767ff1ae584b8bf055d2 CRs-Fixed: 2533419 --- umac/regulatory/core/src/reg_opclass.c | 384 ++++++++++++++---- umac/regulatory/core/src/reg_opclass.h | 87 ++++ .../inc/reg_services_public_struct.h | 30 +- .../dispatcher/inc/wlan_reg_services_api.h | 53 +++ .../dispatcher/src/wlan_reg_services_api.c | 37 ++ 5 files changed, 512 insertions(+), 79 deletions(-) diff --git a/umac/regulatory/core/src/reg_opclass.c b/umac/regulatory/core/src/reg_opclass.c index 4ad5fc572e1b..c603dcbc5c6a 100644 --- a/umac/regulatory/core/src/reg_opclass.c +++ b/umac/regulatory/core/src/reg_opclass.c @@ -33,94 +33,199 @@ #include #include "reg_build_chan_list.h" #include "reg_opclass.h" +#include "reg_services_common.h" #ifdef HOST_OPCLASS static struct reg_dmn_supp_op_classes reg_dmn_curr_supp_opp_classes = { 0 }; #endif static const struct reg_dmn_op_class_map_t global_op_class[] = { - {81, 25, BW20, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13} }, - {82, 25, BW20, {14} }, - {83, 40, BW40_LOW_PRIMARY, {1, 2, 3, 4, 5, 6, 7, 8, 9} }, - {84, 40, BW40_HIGH_PRIMARY, {5, 6, 7, 8, 9, 10, 11, 12, 13} }, - {115, 20, BW20, {36, 40, 44, 48} }, - {116, 40, BW40_LOW_PRIMARY, {36, 44} }, - {117, 40, BW40_HIGH_PRIMARY, {40, 48} }, - {118, 20, BW20, {52, 56, 60, 64} }, - {119, 40, BW40_LOW_PRIMARY, {52, 60} }, - {120, 40, BW40_HIGH_PRIMARY, {56, 64} }, - {121, 20, BW20, - {100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140} }, - {122, 40, BW40_LOW_PRIMARY, {100, 108, 116, 124, 132} }, - {123, 40, BW40_HIGH_PRIMARY, {104, 112, 120, 128, 136} }, - {125, 20, BW20, {149, 153, 157, 161, 165, 169} }, - {126, 40, BW40_LOW_PRIMARY, {149, 157} }, - {127, 40, BW40_HIGH_PRIMARY, {153, 161} }, - {128, 80, BW80, {36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, - 112, 116, 120, 124, 128, 132, 136, 140, 144, - 149, 153, 157, 161} }, - {0, 0, 0, {0} }, + {81, 25, BW20, BIT(BEHAV_NONE), 2407, + {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13} }, + {82, 25, BW20, BIT(BEHAV_NONE), 2414, + {14} }, + {83, 40, BW40_LOW_PRIMARY, BIT(BEHAV_BW40_LOW_PRIMARY), 2407, + {1, 2, 3, 4, 5, 6, 7, 8, 9} }, + {84, 40, BW40_HIGH_PRIMARY, BIT(BEHAV_BW40_HIGH_PRIMARY), 2407, + {5, 6, 7, 8, 9, 10, 11, 12, 13} }, + {115, 20, BW20, BIT(BEHAV_NONE), 5000, + {36, 40, 44, 48} }, + {116, 40, BW40_LOW_PRIMARY, BIT(BEHAV_BW40_LOW_PRIMARY), 5000, + {36, 44} }, + {117, 40, BW40_HIGH_PRIMARY, BIT(BEHAV_BW40_HIGH_PRIMARY), 5000, + {40, 48} }, + {118, 20, BW20, BIT(BEHAV_NONE), 5000, + {52, 56, 60, 64} }, + {119, 40, BW40_LOW_PRIMARY, BIT(BEHAV_BW40_LOW_PRIMARY), 5000, + {52, 60} }, + {120, 40, BW40_HIGH_PRIMARY, BIT(BEHAV_BW40_HIGH_PRIMARY), 5000, + {56, 64} }, + {121, 20, BW20, BIT(BEHAV_NONE), 5000, + {100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144} }, + {122, 40, BW40_LOW_PRIMARY, BIT(BEHAV_BW40_LOW_PRIMARY), 5000, + {100, 108, 116, 124, 132, 140} }, + {123, 40, BW40_HIGH_PRIMARY, BIT(BEHAV_BW40_HIGH_PRIMARY), 5000, + {104, 112, 120, 128, 136, 144} }, + {125, 20, BW20, BIT(BEHAV_NONE), 5000, + {149, 153, 157, 161, 165, 169} }, + {126, 40, BW40_LOW_PRIMARY, BIT(BEHAV_BW40_LOW_PRIMARY), 5000, + {149, 157} }, + {127, 40, BW40_HIGH_PRIMARY, BIT(BEHAV_BW40_HIGH_PRIMARY), 5000, + {153, 161} }, + {128, 80, BW80, BIT(BEHAV_NONE), 5000, + {36, 40, 44, 48, 52, 56, 60, 64, + 100, 104, 108, 112, 116, 120, 124, + 128, 132, 136, 140, 144, + 149, 153, 157, 161} }, + +#ifdef CONFIG_BAND_6GHZ + {131, 20, BW20, BIT(BEHAV_NONE), 5940, + {1, 5, 9, 13, 17, 21, 25, 29, 33, + 37, 41, 45, 49, 53, 57, 61, 65, 69, + 73, 77, 81, 85, 89, 93, 97, + 101, 105, 109, 113, 117, 121, 125, + 129, 133, 137, 141, 145, 149, 153, + 157, 161, 165, 169, 173, 177, 181, + 185, 189, 193, 197, 201, 205, 209, + 213, 217, 221, 225, 229, 233} }, + + {132, 40, BW40_LOW_PRIMARY, BIT(BEHAV_NONE), 5940, + {1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, + 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97, + 101, 105, 109, 113, 117, 121, 125, 129, 133, 137, + 141, 145, 149, 153, 157, 161, 165, 169, 173, 177, + 181, 185, 189, 193, 197, 201, 205, 209, 213, 217, + 221, 225, 229, 233} }, + + {133, 80, BW80, BIT(BEHAV_NONE), 5940, + {1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, + 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97, + 101, 105, 109, 113, 117, 121, 125, 129, 133, 137, + 141, 145, 149, 153, 157, 161, 165, 169, 173, + 177, 181, 185, 189, 193, 197, 201, 205, 209, 213, + 217, 221, 225, 229, 233} }, + + {134, 160, BW80, BIT(BEHAV_NONE), 5940, + {1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, + 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, + 93, 97, 101, 105, 109, 113, 117, 121, 125, + 129, 133, 137, 141, 145, 149, 153, 157, 161, + 165, 169, 173, 177, 181, 185, 189, 193, 197, + 201, 205, 209, 213, 217, 221, 225, 229, 233} }, + + {135, 80, BW80, BIT(BEHAV_BW80_PLUS), 5940, + {1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, + 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, + 85, 89, 93, 97, 101, 105, 109, 113, 117, + 121, 125, 129, 133, 137, 141, 145, 149, + 153, 157, 161, 165, 169, 173, 177, 181, + 185, 189, 193, 197, 201, 205, 209, 213, + 217, 221, 225, 229, 233} }, +#endif + {0, 0, 0, 0, 0, {0} }, }; static const struct reg_dmn_op_class_map_t us_op_class[] = { - {1, 20, BW20, {36, 40, 44, 48} }, - {2, 20, BW20, {52, 56, 60, 64} }, - {4, 20, BW20, {100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, - 144} }, - {5, 20, BW20, {149, 153, 157, 161, 165} }, - {12, 25, BW20, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} }, - {22, 40, BW40_LOW_PRIMARY, {36, 44} }, - {23, 40, BW40_LOW_PRIMARY, {52, 60} }, - {24, 40, BW40_LOW_PRIMARY, {100, 108, 116, 124, 132} }, - {26, 40, BW40_LOW_PRIMARY, {149, 157} }, - {27, 40, BW40_HIGH_PRIMARY, {40, 48} }, - {28, 40, BW40_HIGH_PRIMARY, {56, 64} }, - {29, 40, BW40_HIGH_PRIMARY, {104, 112, 120, 128, 136} }, - {30, 40, BW40_HIGH_PRIMARY, {153, 161} }, - {31, 40, BW40_HIGH_PRIMARY, {153, 161} }, - {32, 40, BW40_LOW_PRIMARY, {1, 2, 3, 4, 5, 6, 7} }, - {33, 40, BW40_HIGH_PRIMARY, {5, 6, 7, 8, 9, 10, 11} }, - {128, 80, BW80, {36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, - 112, 116, 120, 124, 128, 132, 136, 140, 144, - 149, 153, 157, 161} }, - {0, 0, 0, {0} }, + {1, 20, BW20, BIT(BEHAV_NONE), 5000, + {36, 40, 44, 48} }, + {2, 20, BW20, BIT(BEHAV_NONE), 5000, + {52, 56, 60, 64} }, + {4, 20, BW20, BIT(BEHAV_NONE), 5000, + {100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144} }, + {5, 20, BW20, BIT(BEHAV_NONE), 5000, + {149, 153, 157, 161, 165} }, + {12, 25, BW20, BIT(BEHAV_NONE), 2407, + {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} }, + {22, 40, BW40_LOW_PRIMARY, BIT(BEHAV_BW40_LOW_PRIMARY), 5000, + {36, 44} }, + {23, 40, BW40_LOW_PRIMARY, BIT(BEHAV_BW40_LOW_PRIMARY), 5000, + {52, 60} }, + {24, 40, BW40_LOW_PRIMARY, BIT(BEHAV_BW40_LOW_PRIMARY), 5000, + {100, 108, 116, 124, 132} }, + {26, 40, BW40_LOW_PRIMARY, BIT(BEHAV_BW40_LOW_PRIMARY), 5000, + {149, 157} }, + {27, 40, BW40_HIGH_PRIMARY, BIT(BEHAV_BW40_HIGH_PRIMARY), 5000, + {40, 48} }, + {28, 40, BW40_HIGH_PRIMARY, BIT(BEHAV_BW40_HIGH_PRIMARY), 5000, + {56, 64} }, + {29, 40, BW40_HIGH_PRIMARY, BIT(BEHAV_BW40_HIGH_PRIMARY), 5000, + {104, 112, 120, 128, 136} }, + {30, 40, BW40_HIGH_PRIMARY, BIT(BEHAV_BW40_HIGH_PRIMARY), 5000, + {153, 161} }, + {31, 40, BW40_HIGH_PRIMARY, BIT(BEHAV_BW40_HIGH_PRIMARY), 5000, + {153, 161} }, + {32, 40, BW40_LOW_PRIMARY, BIT(BEHAV_BW40_LOW_PRIMARY), 2407, + {1, 2, 3, 4, 5, 6, 7} }, + {33, 40, BW40_HIGH_PRIMARY, BIT(BEHAV_BW40_HIGH_PRIMARY), 2407, + {5, 6, 7, 8, 9, 10, 11} }, + {128, 80, BW80, BIT(BEHAV_NONE), 5000, + {36, 40, 44, 48, 52, 56, 60, 64, 100, + 104, 108, 112, 116, 120, 124, 128, 132, + 136, 140, 144, 149, 153, 157, 161} }, + {0, 0, 0, 0, 0, {0} }, }; static const struct reg_dmn_op_class_map_t euro_op_class[] = { - {1, 20, BW20, {36, 40, 44, 48} }, - {2, 20, BW20, {52, 56, 60, 64} }, - {3, 20, BW20, {100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140} }, - {4, 25, BW20, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13} }, - {5, 40, BW40_LOW_PRIMARY, {36, 44} }, - {6, 40, BW40_LOW_PRIMARY, {52, 60} }, - {7, 40, BW40_LOW_PRIMARY, {100, 108, 116, 124, 132} }, - {8, 40, BW40_HIGH_PRIMARY, {40, 48} }, - {9, 40, BW40_HIGH_PRIMARY, {56, 64} }, - {10, 40, BW40_HIGH_PRIMARY, {104, 112, 120, 128, 136} }, - {11, 40, BW40_LOW_PRIMARY, {1, 2, 3, 4, 5, 6, 7, 8, 9} }, - {12, 40, BW40_HIGH_PRIMARY, {5, 6, 7, 8, 9, 10, 11, 12, 13} }, - {17, 20, BW20, {149, 153, 157, 161, 165, 169} }, - {128, 80, BW80, {36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, - 116, 120, 124, 128} }, - {0, 0, 0, {0} }, + {1, 20, BW20, BIT(BEHAV_NONE), 5000, + {36, 40, 44, 48} }, + {2, 20, BW20, BIT(BEHAV_NONE), 5000, + {52, 56, 60, 64} }, + {3, 20, BW20, BIT(BEHAV_NONE), 5000, + {100, 104, 108, 112, 116, 120, + 124, 128, 132, 136, 140} }, + {4, 25, BW20, BIT(BEHAV_NONE), 2407, + {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13} }, + {5, 40, BW40_LOW_PRIMARY, BIT(BEHAV_BW40_LOW_PRIMARY), 5000, + {36, 44} }, + {6, 40, BW40_LOW_PRIMARY, BIT(BEHAV_BW40_LOW_PRIMARY), 5000, + {52, 60} }, + {7, 40, BW40_LOW_PRIMARY, BIT(BEHAV_BW40_LOW_PRIMARY), 5000, + {100, 108, 116, 124, 132} }, + {8, 40, BW40_HIGH_PRIMARY, BIT(BEHAV_BW40_HIGH_PRIMARY), 5000, + {40, 48} }, + {9, 40, BW40_HIGH_PRIMARY, BIT(BEHAV_BW40_HIGH_PRIMARY), 5000, + {56, 64} }, + {10, 40, BW40_HIGH_PRIMARY, BIT(BEHAV_BW40_HIGH_PRIMARY), 5000, + {104, 112, 120, 128, 136} }, + {11, 40, BW40_LOW_PRIMARY, BIT(BEHAV_BW40_LOW_PRIMARY), 2407, + {1, 2, 3, 4, 5, 6, 7, 8, 9} }, + {12, 40, BW40_HIGH_PRIMARY, BIT(BEHAV_BW40_HIGH_PRIMARY), 2407, + {5, 6, 7, 8, 9, 10, 11, 12, 13} }, + {17, 20, BW20, BIT(BEHAV_NONE), 5000, + {149, 153, 157, 161, 165, 169} }, + {128, 80, BW80, BIT(BEHAV_NONE), 5000, + {36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, + 124, 128} }, + {0, 0, 0, 0, 0, {0} }, }; static const struct reg_dmn_op_class_map_t japan_op_class[] = { - {1, 20, BW20, {36, 40, 44, 48} }, - {30, 25, BW20, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13} }, - {31, 25, BW20, {14} }, - {32, 20, BW20, {52, 56, 60, 64} }, - {34, 20, BW20, - {100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140} }, - {36, 40, BW40_LOW_PRIMARY, {36, 44} }, - {37, 40, BW40_LOW_PRIMARY, {52, 60} }, - {39, 40, BW40_LOW_PRIMARY, {100, 108, 116, 124, 132} }, - {41, 40, BW40_HIGH_PRIMARY, {40, 48} }, - {42, 40, BW40_HIGH_PRIMARY, {56, 64} }, - {44, 40, BW40_HIGH_PRIMARY, {104, 112, 120, 128, 136} }, - {128, 80, BW80, {36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, - 116, 120, 124, 128} }, - {0, 0, 0, {0} }, + {1, 20, BW20, BIT(BEHAV_NONE), 5000, + {36, 40, 44, 48} }, + {30, 25, BW20, BIT(BEHAV_NONE), 2407, + {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13} }, + {31, 25, BW20, BIT(BEHAV_NONE), 2407, + {14} }, + {32, 20, BW20, BIT(BEHAV_NONE), 5000, + {52, 56, 60, 64} }, + {34, 20, BW20, BIT(BEHAV_NONE), 5000, + {100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140} }, + {36, 40, BW40_LOW_PRIMARY, BIT(BEHAV_BW40_LOW_PRIMARY), 5000, + {36, 44} }, + {37, 40, BW40_LOW_PRIMARY, BIT(BEHAV_BW40_LOW_PRIMARY), 5000, + {52, 60} }, + {39, 40, BW40_LOW_PRIMARY, BIT(BEHAV_BW40_LOW_PRIMARY), 5000, + {100, 108, 116, 124, 132} }, + {41, 40, BW40_HIGH_PRIMARY, BIT(BEHAV_BW40_HIGH_PRIMARY), 5000, + {40, 48} }, + {42, 40, BW40_HIGH_PRIMARY, BIT(BEHAV_BW40_HIGH_PRIMARY), 5000, + {56, 64} }, + {44, 40, BW40_HIGH_PRIMARY, BIT(BEHAV_BW40_HIGH_PRIMARY), 5000, + {104, 112, 120, 128, 136} }, + {128, 80, BW80, BIT(BEHAV_NONE), 5000, + {36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, + 124, 128} }, + {0, 0, 0, 0, 0, {0} }, }; #ifdef HOST_OPCLASS @@ -130,9 +235,8 @@ static const struct reg_dmn_op_class_map_t japan_op_class[] = { * * Return: class. */ -static -const struct reg_dmn_op_class_map_t *reg_get_class_from_country(uint8_t - *country) +static const +struct reg_dmn_op_class_map_t *reg_get_class_from_country(uint8_t *country) { const struct reg_dmn_op_class_map_t *class = NULL; @@ -182,7 +286,7 @@ uint16_t reg_dmn_get_chanwidth_from_opclass(uint8_t *country, uint8_t channel, for (i = 0; (i < REG_MAX_CHANNELS_PER_OPERATING_CLASS && class->channels[i]); i++) { if (channel == class->channels[i]) - return class->ch_spacing; + return class->chan_spacing; } } class++; @@ -274,4 +378,130 @@ uint16_t reg_dmn_get_curr_opclasses(uint8_t *num_classes, uint8_t *class) return 0; } + +#ifdef CONFIG_CHAN_FREQ_API +void reg_freq_width_to_chan_op_class(struct wlan_objmgr_pdev *pdev, + uint16_t freq, + uint16_t chan_width, + bool global_tbl_lookup, + uint16_t behav_limit, + uint8_t *op_class, + uint8_t *chan_num) +{ + const struct reg_dmn_op_class_map_t *op_class_tbl; + enum channel_enum chan_enum; + uint16_t i; + + chan_enum = reg_get_chan_enum_for_freq(freq); + + if (chan_enum == INVALID_CHANNEL) { + reg_err(" channel enumeration is invalid %d", chan_enum); + return; + } + + if (global_tbl_lookup) { + op_class_tbl = global_op_class; + } else { + if (channel_map == channel_map_us) + op_class_tbl = us_op_class; + else if (channel_map == channel_map_eu) + op_class_tbl = euro_op_class; + else if (channel_map == channel_map_china) + op_class_tbl = us_op_class; + else if (channel_map == channel_map_jp) + op_class_tbl = japan_op_class; + else + op_class_tbl = global_op_class; + } + + while (op_class_tbl->op_class) { + if (op_class_tbl->chan_spacing >= chan_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 || + behav_limit == BIT(BEHAV_NONE))) { + *chan_num = op_class_tbl->channels[i]; + *op_class = op_class_tbl->op_class; + return; + } + } + } + op_class_tbl++; + } + + reg_err_rl("invalid frequency %d", freq); +} + +void reg_freq_to_chan_op_class(struct wlan_objmgr_pdev *pdev, + uint16_t freq, + bool global_tbl_lookup, + uint16_t behav_limit, + uint8_t *op_class, + uint8_t *chan_num) +{ + enum channel_enum chan_enum; + uint16_t chan_width; + struct regulatory_channel *cur_chan_list; + struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj; + + pdev_priv_obj = reg_get_pdev_obj(pdev); + + if (!IS_VALID_PDEV_REG_OBJ(pdev_priv_obj)) { + reg_err("pdev reg obj is NULL"); + return; + } + + cur_chan_list = pdev_priv_obj->cur_chan_list; + + chan_enum = reg_get_chan_enum_for_freq(freq); + + if (chan_enum == INVALID_CHANNEL) { + reg_err(" channel enumeration is invalid %d", chan_enum); + return; + } + + chan_width = cur_chan_list[chan_enum].max_bw; + + reg_freq_width_to_chan_op_class(pdev, freq, + chan_width, + global_tbl_lookup, + behav_limit, + op_class, + chan_num); +} +#endif + +uint16_t reg_get_op_class_width(struct wlan_objmgr_pdev *pdev, + uint8_t op_class, + bool global_tbl_lookup) +{ + const struct reg_dmn_op_class_map_t *op_class_tbl; + + if (global_tbl_lookup) { + op_class_tbl = global_op_class; + } else { + if (channel_map == channel_map_us) + op_class_tbl = us_op_class; + else if (channel_map == channel_map_eu) + op_class_tbl = euro_op_class; + else if (channel_map == channel_map_china) + op_class_tbl = us_op_class; + else if (channel_map == channel_map_jp) + op_class_tbl = japan_op_class; + else + op_class_tbl = global_op_class; + } + + while (op_class_tbl->op_class) { + if (op_class_tbl->op_class == op_class) + return op_class_tbl->chan_spacing; + op_class_tbl++; + } + + return 0; +} + #endif diff --git a/umac/regulatory/core/src/reg_opclass.h b/umac/regulatory/core/src/reg_opclass.h index 8b2ffd969a68..fa3845248843 100644 --- a/umac/regulatory/core/src/reg_opclass.h +++ b/umac/regulatory/core/src/reg_opclass.h @@ -74,6 +74,61 @@ uint16_t reg_dmn_set_curr_opclasses(uint8_t num_classes, uint8_t *class); */ uint16_t reg_dmn_get_curr_opclasses(uint8_t *num_classes, uint8_t *class); +#ifdef CONFIG_CHAN_FREQ_API + +/** + * reg_freq_width_to_chan_op_class() - convert frequency to oper class, + * channel + * @pdev: pdev pointer + * @freq: channel frequency in mhz + * @chan_width: channel width + * @global_tbl_lookup: whether to lookup global op class tbl + * @behav_limit: behavior limit + * @op_class: operating class + * @chan_num: channel number + * + * Return: Void. + */ +void reg_freq_width_to_chan_op_class(struct wlan_objmgr_pdev *pdev, + uint16_t freq, + uint16_t chan_width, + bool global_tbl_lookup, + uint16_t behav_limit, + uint8_t *op_class, + uint8_t *chan_num); + +/** + * reg_freq_to_chan_op_class() - convert frequency to oper class, + * channel + * @pdev: pdev pointer + * @freq: channel frequency in mhz + * @global_tbl_lookup: whether to lookup global op class tbl + * @behav_limit: behavior limit + * @op_class: operating class + * @chan_num: channel number + * + * Return: Void. + */ +void reg_freq_to_chan_op_class(struct wlan_objmgr_pdev *pdev, + uint16_t freq, + bool global_tbl_lookup, + uint16_t behav_limit, + uint8_t *op_class, + uint8_t *chan_num); +#endif + +/** + * reg_get_op_class_width() - get oper class width + * + * @pdev: pdev pointer + * @global_tbl_lookup: whether to lookup global op class tbl + * @op_class: operating class + * Return: uint16 + */ +uint16_t reg_get_op_class_width(struct wlan_objmgr_pdev *pdev, + uint8_t op_class, + bool global_tbl_lookup); + #else static inline uint16_t reg_dmn_get_chanwidth_from_opclass( @@ -105,5 +160,37 @@ static inline void reg_dmn_print_channels_in_opclass(uint8_t *country, { } +#ifdef CONFIG_CHAN_FREQ_API + +static inline void +reg_freq_width_to_chan_op_class(struct wlan_objmgr_pdev *pdev, + uint16_t freq, + uint16_t chan_width, + bool global_tbl_lookup, + uint16_t behav_limit, + uint8_t *op_class, + uint8_t *chan_num) +{ +} + +static inline void +reg_freq_to_chan_op_class(struct wlan_objmgr_pdev *pdev, + uint16_t freq, + bool global_tbl_lookup, + uint16_t behav_limit, + uint8_t *op_class, + uint8_t *chan_num) +{ +} + +#endif + +uint16_t reg_get_op_class_width(struct wlan_objmgr_pdev *pdev, + uint8_t op_class, + bool global_tbl_lookup) +{ + return 0; +} + #endif #endif diff --git a/umac/regulatory/dispatcher/inc/reg_services_public_struct.h b/umac/regulatory/dispatcher/inc/reg_services_public_struct.h index a12d72738d46..b3966d8152f4 100644 --- a/umac/regulatory/dispatcher/inc/reg_services_public_struct.h +++ b/umac/regulatory/dispatcher/inc/reg_services_public_struct.h @@ -25,7 +25,13 @@ #define __REG_SERVICES_PUBLIC_STRUCT_H_ #define REG_SBS_SEPARATION_THRESHOLD 100 + +#ifdef CONFIG_BAND_6GHZ +#define REG_MAX_CHANNELS_PER_OPERATING_CLASS 70 +#else #define REG_MAX_CHANNELS_PER_OPERATING_CLASS 25 +#endif + #define REG_MAX_SUPP_OPER_CLASSES 32 #define REG_MAX_CHAN_CHANGE_CBKS 30 #define MAX_STA_VDEV_CNT 4 @@ -539,17 +545,37 @@ enum offset_t { BW_INVALID = 0xFF }; +/** + * enum behav_limit - behavior limit + * @BEHAV_NONE: none + * @BEHAV_BW40_LOW_PRIMARY: BW40 low primary + * @BEHAV_BW40_HIGH_PRIMARY: BW40 high primary + * @BEHAV_BW80_PLUS: BW 80 plus + * @BEHAV_INVALID: invalid behavior + */ +enum behav_limit { + BEHAV_NONE, + BEHAV_BW40_LOW_PRIMARY, + BEHAV_BW40_HIGH_PRIMARY, + BEHAV_BW80_PLUS, + BEHAV_INVALID = 0xFF +}; + /** * struct reg_dmn_op_class_map_t: operating class * @op_class: operating class number - * @ch_spacing: channel spacing + * @chan_spacing: channel spacing * @offset: offset + * @behav_limit: OR of bitmaps of enum behav_limit + * @start_freq: starting frequency * @channels: channel set */ struct reg_dmn_op_class_map_t { uint8_t op_class; - uint8_t ch_spacing; + uint8_t chan_spacing; enum offset_t offset; + uint16_t behav_limit; + uint16_t start_freq; uint8_t channels[REG_MAX_CHANNELS_PER_OPERATING_CLASS]; }; diff --git a/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h b/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h index 75cb15bad6e6..65a98cdf17be 100644 --- a/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h +++ b/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h @@ -1102,5 +1102,58 @@ uint16_t wlan_reg_min_chan_freq(void); */ uint16_t wlan_reg_max_chan_freq(void); +/** + * wlan_reg_freq_width_to_chan_op_class () - get op class from freq + * @pdev: pdev ptr + * @freq: channel frequency + * @chan_width: channel width + * @global_tbl_lookup: whether to look up global table + * @behav_limit: behavior limit + * @op_class: operating class + * @chan_num: channel number + * + * Return: void + */ +void wlan_reg_freq_width_to_chan_op_class(struct wlan_objmgr_pdev *pdev, + uint16_t freq, + uint16_t chan_width, + bool global_tbl_lookup, + uint16_t behav_limit, + uint8_t *op_class, + uint8_t *chan_num); + +/** + * wlan_reg_freq_to_chan_and_op_class () - converts freq to oper class + * @pdev: pdev ptr + * @freq: channel frequency + * @global_tbl_lookup: whether to look up global table + * @behav_limit: behavior limit + * @op_class: operating class + * @chan_num: channel number + * + * Return: void + */ +void wlan_reg_freq_to_chan_op_class(struct wlan_objmgr_pdev *pdev, + uint16_t freq, + bool global_tbl_lookup, + uint16_t behav_limit, + uint8_t *op_class, + uint8_t *chan_num); + #endif /*CONFIG_CHAN_FREQ_API */ + +/** + * wlan_reg_get_op_class_width () - get operating class chan width + * @pdev: pdev ptr + * @freq: channel frequency + * @global_tbl_lookup: whether to look up global table + * @op_class: operating class + * @chan_num: channel number + * + * Return: channel width of op class + */ +uint16_t wlan_reg_get_op_class_width(struct wlan_objmgr_pdev *pdev, + uint8_t op_class, + bool global_tbl_lookup); + #endif diff --git a/umac/regulatory/dispatcher/src/wlan_reg_services_api.c b/umac/regulatory/dispatcher/src/wlan_reg_services_api.c index 13eb907e2a3b..d2ecff972458 100644 --- a/umac/regulatory/dispatcher/src/wlan_reg_services_api.c +++ b/umac/regulatory/dispatcher/src/wlan_reg_services_api.c @@ -974,4 +974,41 @@ uint16_t wlan_reg_max_chan_freq(void) return reg_max_chan_freq(); } +void wlan_reg_freq_width_to_chan_op_class(struct wlan_objmgr_pdev *pdev, + uint16_t freq, + uint16_t chan_width, + bool global_tbl_lookup, + uint16_t behav_limit, + uint8_t *op_class, + uint8_t *chan_num) +{ + return reg_freq_width_to_chan_op_class(pdev, freq, chan_width, + global_tbl_lookup, + behav_limit, + op_class, + chan_num); +} + +void wlan_reg_freq_to_chan_op_class(struct wlan_objmgr_pdev *pdev, + uint16_t freq, + bool global_tbl_lookup, + uint16_t behav_limit, + uint8_t *op_class, + uint8_t *chan_num) +{ + return reg_freq_to_chan_op_class(pdev, freq, + global_tbl_lookup, + behav_limit, + op_class, + chan_num); +} + #endif /* CONFIG CHAN FREQ API */ + +uint16_t wlan_reg_get_op_class_width(struct wlan_objmgr_pdev *pdev, + uint8_t op_class, + bool global_tbl_lookup) +{ + return reg_get_op_class_width(pdev, op_class, + global_tbl_lookup); +}