Переглянути джерело

qcacmn: Handle INVALID_CHANNEL_NUM

Currently 'wlan_reg_max_5ghz_ch_num'returns
INVALID_CHANNEL_NUM for countries other than US
as MAX_5 GHZ_CHANNEL maps to INVALID_CHANNEL_NUM
for other countries in their respective channel_map
structure.

To fix this issue of INVALID_CHANNEL_NUM for
MAX_5 GHZ_CHANNEL,instead of taking value from
channel_map[].chan_num, with fixed index of MAX_5 GHZ_CHANNEL,
check for channel_map[].cha_num with index starting from
MAX_5 GHZ_CHANNEL down to 5 GHz channels,
consider the first hit of chan_num which is not
INVALID_CHANNEL_NUM.

Change-Id: I364500f8e13cc42350103c5d236b12d71e28a4a6
CRs-Fixed: 3396340
Divyajyothi Goparaju 2 роки тому
батько
коміт
3c4a739d9c

+ 19 - 1
umac/regulatory/core/src/reg_services_common.c

@@ -49,6 +49,7 @@
 #endif
 
 const struct chan_map *channel_map;
+uint8_t g_reg_max_5g_chan_num;
 
 #ifdef WLAN_FEATURE_11BE
 static bool reg_is_chan_bit_punctured(uint16_t input_punc_bitmap,
@@ -1297,6 +1298,21 @@ const struct chan_map channel_map_china[NUM_CHANNELS] = {
 #endif /* CONFIG_BAND_6GHZ */
 };
 
+static uint8_t reg_calculate_max_5gh_enum(void)
+{
+	int16_t idx;
+	uint8_t max_valid_ieee_chan = INVALID_CHANNEL_NUM;
+
+	for (idx = MAX_5GHZ_CHANNEL; idx >= 0; idx--) {
+		if (channel_map[idx].chan_num != INVALID_CHANNEL_NUM) {
+			max_valid_ieee_chan = channel_map[idx].chan_num;
+			break;
+		}
+	}
+
+	return max_valid_ieee_chan;
+}
+
 void reg_init_channel_map(enum dfs_reg dfs_region)
 {
 	switch (dfs_region) {
@@ -1321,6 +1337,8 @@ void reg_init_channel_map(enum dfs_reg dfs_region)
 		channel_map = channel_map_global;
 		break;
 	}
+
+	g_reg_max_5g_chan_num = reg_calculate_max_5gh_enum();
 }
 
 #ifdef WLAN_FEATURE_11BE
@@ -3017,7 +3035,7 @@ qdf_freq_t reg_ch_to_freq(uint32_t ch_enum)
 
 uint8_t reg_max_5ghz_ch_num(void)
 {
-	return REG_MAX_5GHZ_CH_NUM;
+	return g_reg_max_5g_chan_num;
 }
 
 #ifdef CONFIG_CHAN_FREQ_API

+ 1 - 1
umac/regulatory/core/src/reg_services_common.h

@@ -41,7 +41,7 @@
 #define NUM_20_MHZ_CHAN_IN_160_MHZ_CHAN    8
 #define NUM_20_MHZ_CHAN_IN_320_MHZ_CHAN    16
 
-#define REG_MAX_5GHZ_CH_NUM channel_map[MAX_5GHZ_CHANNEL].chan_num
+#define REG_MAX_5GHZ_CH_NUM reg_max_5ghz_ch_num()
 
 #define REG_MIN_24GHZ_CH_FREQ channel_map[MIN_24GHZ_CHANNEL].center_freq
 #define REG_MAX_24GHZ_CH_FREQ channel_map[MAX_24GHZ_CHANNEL].center_freq