qcacmn: Add frequency range check in reg_get_band_cap_from_op_class

When the operating class 82 is given as an input to the function
reg_get_band_cap_from_op_class, it is not found due to an
incorrect conditional logic that checks the starting frequency of a
band.

To address this problem, add a function
reg_get_band_cap_from_chan_set and call it within the function
reg_get_band_cap_from_op_class, to check if a channel in the channel
set, is within the frequency range of the band.

Change-Id: I7cbd8decf3c19f80e60a3153529b622b144feac9
CRs-Fixed: 2636367
This commit is contained in:
Hariharan Basuthkar
2020-03-05 17:23:43 +05:30
committed by nshrivas
parent a700ecf10e
commit cc9fb0cd68
2 changed files with 21 additions and 14 deletions

View File

@@ -369,6 +369,25 @@ uint8_t reg_dmn_get_opclass_from_freq_width(uint8_t *country,
return 0;
}
static void
reg_get_band_cap_from_chan_set(const struct reg_dmn_op_class_map_t
*op_class_tbl,
uint8_t *supported_band)
{
qdf_freq_t chan_freq = op_class_tbl->start_freq +
(op_class_tbl->channels[0] *
FREQ_TO_CHAN_SCALE);
if (reg_is_24ghz_ch_freq(chan_freq))
*supported_band |= BIT(REG_BAND_2G);
else if (reg_is_5ghz_ch_freq(chan_freq))
*supported_band |= BIT(REG_BAND_5G);
else if (reg_is_6ghz_chan_freq(chan_freq))
*supported_band |= BIT(REG_BAND_6G);
else
reg_err_rl("Unknown band");
}
uint8_t reg_get_band_cap_from_op_class(const uint8_t *country,
uint8_t num_of_opclass,
const uint8_t *opclass)
@@ -382,18 +401,8 @@ uint8_t reg_get_band_cap_from_op_class(const uint8_t *country,
for (opclassidx = 0; opclassidx < num_of_opclass;
opclassidx++) {
if (op_class_tbl->op_class == opclass[opclassidx]) {
if (op_class_tbl->start_freq ==
TWOG_START_FREQ) {
supported_band |= BIT(REG_BAND_2G);
} else if (op_class_tbl->start_freq ==
FIVEG_START_FREQ) {
supported_band |= BIT(REG_BAND_5G);
} else if (op_class_tbl->start_freq ==
SIXG_STARTING_FREQ) {
supported_band |= BIT(REG_BAND_6G);
} else {
reg_err_rl("Unknown band");
}
reg_get_band_cap_from_chan_set(op_class_tbl,
&supported_band);
}
}
op_class_tbl++;

View File

@@ -41,8 +41,6 @@
#define CH_AVOID_MAX_RANGE 4
#define REG_ALPHA2_LEN 2
#define MAX_REG_RULES 10
#define TWOG_START_FREQ 2407
#define FIVEG_START_FREQ 5000
#define REGULATORY_CHAN_DISABLED BIT(0)
#define REGULATORY_CHAN_NO_IR BIT(1)