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
This commit is contained in:
Vignesh Mohan
2022-06-15 12:41:42 +05:30
committed by Madan Koyyalamudi
parent bf46176516
commit 216322b1de
2 changed files with 41 additions and 1 deletions

View File

@@ -1525,18 +1525,46 @@ void reg_set_dfs_region(struct wlan_objmgr_pdev *pdev,
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
reg_freq_to_chan_for_chlist(struct regulatory_channel *chan_list,
qdf_freq_t freq,
enum channel_enum num_chans)
{
uint32_t count;
uint8_t chan_ieee;
if (num_chans > NUM_CHANNELS) {
reg_err_rl("invalid num_chans");
return 0;
}
chan_ieee = reg_freq_to_chan_direct(freq);
if (chan_ieee)
return chan_ieee;
for (count = 0; count < num_chans; count++) {
if (chan_list[count].center_freq >= freq)
break;

View File

@@ -1716,8 +1716,20 @@ struct reg_sched_payload {
#define TWOG_CHAN_6_IN_MHZ 2437
#define TWOG_CHAN_9_IN_MHZ 2452
#define TWOG_CHAN_13_IN_MHZ 2472
#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 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