Bläddra i källkod

qcacmn: Use formula to get IEEE from frequency

Instead of looping through the current channel list, which takes O(N),
use the existing formula to directly convert frequency to
IEEE channel number, which will take O(1). This will reduce the CPU load.

CRs-Fixed: 3230932
Change-Id: I38e3a67c6ef4295cea3a8a57f3a853651445f0b5
Vignesh Mohan 3 år sedan
förälder
incheckning
216322b1de

+ 28 - 0
umac/regulatory/core/src/reg_services_common.c

@@ -1525,18 +1525,46 @@ void reg_set_dfs_region(struct wlan_objmgr_pdev *pdev,
 	reg_init_channel_map(dfs_reg);
 	reg_init_channel_map(dfs_reg);
 }
 }
 
 
+static uint8_t reg_freq_to_chan_direct(qdf_freq_t freq)
+{
+	if (freq >= TWOG_CHAN_1_IN_MHZ && freq <= TWOG_CHAN_13_IN_MHZ)
+		return IEEE_2GHZ_CH1 +
+			(freq - TWOG_CHAN_1_IN_MHZ) / IEEE_CH_SEP;
+
+	if (freq == TWOG_CHAN_14_IN_MHZ)
+		return IEEE_2GHZ_CH14;
+
+	if (freq >= FIVEG_CHAN_36_IN_MHZ && freq <= FIVEG_CHAN_177_IN_MHZ)
+		return IEEE_5GHZ_CH36 +
+			(freq - FIVEG_CHAN_36_IN_MHZ) / IEEE_CH_SEP;
+
+	if (freq == SIXG_CHAN_2_IN_MHZ)
+		return IEEE_6GHZ_CH2;
+
+	if (freq >= SIXG_CHAN_1_IN_MHZ && freq <= SIXG_CHAN_233_IN_MHZ)
+		return IEEE_6GHZ_CH1 +
+			(freq - SIXG_CHAN_1_IN_MHZ) / IEEE_CH_SEP;
+
+	return 0;
+}
+
 static uint8_t
 static uint8_t
 reg_freq_to_chan_for_chlist(struct regulatory_channel *chan_list,
 reg_freq_to_chan_for_chlist(struct regulatory_channel *chan_list,
 			    qdf_freq_t freq,
 			    qdf_freq_t freq,
 			    enum channel_enum num_chans)
 			    enum channel_enum num_chans)
 {
 {
 	uint32_t count;
 	uint32_t count;
+	uint8_t chan_ieee;
 
 
 	if (num_chans > NUM_CHANNELS) {
 	if (num_chans > NUM_CHANNELS) {
 		reg_err_rl("invalid num_chans");
 		reg_err_rl("invalid num_chans");
 		return 0;
 		return 0;
 	}
 	}
 
 
+	chan_ieee = reg_freq_to_chan_direct(freq);
+	if (chan_ieee)
+		return chan_ieee;
+
 	for (count = 0; count < num_chans; count++) {
 	for (count = 0; count < num_chans; count++) {
 		if (chan_list[count].center_freq >= freq)
 		if (chan_list[count].center_freq >= freq)
 			break;
 			break;

+ 14 - 2
umac/regulatory/dispatcher/inc/reg_services_public_struct.h

@@ -1716,8 +1716,20 @@ struct reg_sched_payload {
 #define TWOG_CHAN_6_IN_MHZ         2437
 #define TWOG_CHAN_6_IN_MHZ         2437
 #define TWOG_CHAN_9_IN_MHZ         2452
 #define TWOG_CHAN_9_IN_MHZ         2452
 #define TWOG_CHAN_13_IN_MHZ        2472
 #define TWOG_CHAN_13_IN_MHZ        2472
-
-#define HT40_SEC_OFFSET            20
+#define FIVEG_CHAN_36_IN_MHZ       5180
+#define FIVEG_CHAN_177_IN_MHZ      5885
+#define SIXG_CHAN_2_IN_MHZ         5935
+#define SIXG_CHAN_1_IN_MHZ         5955
+#define SIXG_CHAN_233_IN_MHZ       7115
+
+#define HT40_SEC_OFFSET              20
+
+#define IEEE_2GHZ_CH1                 1
+#define IEEE_2GHZ_CH14               14
+#define IEEE_5GHZ_CH36               36
+#define IEEE_6GHZ_CH1                 1
+#define IEEE_6GHZ_CH2                 2
+#define IEEE_CH_SEP                   5
 
 
 /**
 /**
  * struct reg_ctl_params - reg ctl and regd info
  * struct reg_ctl_params - reg ctl and regd info