Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e10e82a3 authored by Amar Singhal's avatar Amar Singhal Committed by Akash Patel
Browse files

qcacld-3.0: Change regulatory data structures style

Change regulatory data structures and APIs to linux style.
Change the references to the data structures accordingly.
Leave data structures that would be deleted in subsequent
iterations as is.

Change-Id: I68dcd3485d3fb3d98f648b5844508356c3f3c29d
CRs-Fixed: 856727
parent 666bbb33
Loading
Loading
Loading
Loading
+55 −54
Original line number Diff line number Diff line
@@ -41,6 +41,36 @@
#define CDS_COUNTRY_CODE_LEN  2
#define CDS_MAC_ADDRESS_LEN   6

#define CDS_CHANNEL_STATE(enum) reg_channels[enum].enabled
#define CDS_CHANNEL_NUM(enum) chan_mapping[enum].chan_num
#define CDS_CHANNEL_FREQ(enum) chan_mapping[enum].center_freq
#define CDS_IS_DFS_CH(chan_num) (cds_get_channel_state((chan_num)) == \
				CHANNEL_STATE_DFS)

#define CDS_IS_PASSIVE_OR_DISABLE_CH(chan_num) \
	(cds_get_channel_state(chan_num) != CHANNEL_STATE_ENABLE)

#define CDS_MIN_24GHZ_CHANNEL_NUMBER			\
	chan_mapping[MIN_24GHZ_CHANNEL].chan_num
#define CDS_MAX_24GHZ_CHANNEL_NUMBER			\
	chan_mapping[MAX_24GHZ_CHANNEL].chan_num
#define CDS_MIN_5GHZ_CHANNEL_NUMBER  chan_mapping[MIN_5GHZ_CHANNEL].chan_num
#define CDS_MAX_5GHZ_CHANNEL_NUMBER  chan_mapping[MAX_5GHZ_CHANNEL].chan_num

#define CDS_IS_CHANNEL_5GHZ(chan_num) \
	((chan_num >= CDS_MIN_5GHZ_CHANNEL_NUMBER) && \
	 (chan_num <= CDS_MAX_5GHZ_CHANNEL_NUMBER))

#define CDS_IS_CHANNEL_24GHZ(chan_num) \
	((chan_num >= CDS_MIN_24GHZ_CHANNEL_NUMBER) && \
	 (chan_num <= CDS_MAX_24GHZ_CHANNEL_NUMBER))

#define CDS_IS_SAME_BAND_CHANNELS(ch1, ch2) \
	(ch1 && ch2 && \
	(CDS_IS_CHANNEL_5GHZ(ch1) == CDS_IS_CHANNEL_5GHZ(ch2)))

#define CDS_MIN_11P_CHANNEL chan_mapping[MIN_59GHZ_CHANNEL].chan_num

typedef enum {
	REGDOMAIN_FCC,
	REGDOMAIN_ETSI,
@@ -50,7 +80,6 @@ typedef enum {
} v_REGDOMAIN_t;

typedef enum {
	/* 2.4GHz Band */
	RF_CHAN_1 = 0,
	RF_CHAN_2,
	RF_CHAN_3,
@@ -66,7 +95,6 @@ typedef enum {
	RF_CHAN_13,
	RF_CHAN_14,

	/* 4.9GHz Band */
	RF_CHAN_240,
	RF_CHAN_244,
	RF_CHAN_248,
@@ -75,7 +103,6 @@ typedef enum {
	RF_CHAN_212,
	RF_CHAN_216,

	/* 5GHz Low & Mid U-NII Band */
	RF_CHAN_36,
	RF_CHAN_40,
	RF_CHAN_44,
@@ -85,7 +112,6 @@ typedef enum {
	RF_CHAN_60,
	RF_CHAN_64,

	/* 5GHz Mid Band - ETSI & FCC */
	RF_CHAN_100,
	RF_CHAN_104,
	RF_CHAN_108,
@@ -97,17 +123,14 @@ typedef enum {
	RF_CHAN_132,
	RF_CHAN_136,
	RF_CHAN_140,

	RF_CHAN_144,

	/* 5GHz High U-NII Band */
	RF_CHAN_149,
	RF_CHAN_153,
	RF_CHAN_157,
	RF_CHAN_161,
	RF_CHAN_165,

	/* 802.11p */
	RF_CHAN_170,
	RF_CHAN_171,
	RF_CHAN_172,
@@ -134,19 +157,19 @@ typedef enum {
	RF_CHAN_BOND_9,
	RF_CHAN_BOND_10,
	RF_CHAN_BOND_11,
	RF_CHAN_BOND_242,       /* 4.9GHz Band */
	RF_CHAN_BOND_242,
	RF_CHAN_BOND_246,
	RF_CHAN_BOND_250,
	RF_CHAN_BOND_210,
	RF_CHAN_BOND_214,
	RF_CHAN_BOND_38,        /* 5GHz Low & Mid U-NII Band */
	RF_CHAN_BOND_38,
	RF_CHAN_BOND_42,
	RF_CHAN_BOND_46,
	RF_CHAN_BOND_50,
	RF_CHAN_BOND_54,
	RF_CHAN_BOND_58,
	RF_CHAN_BOND_62,
	RF_CHAN_BOND_102,       /* 5GHz Mid Band - ETSI & FCC */
	RF_CHAN_BOND_102,
	RF_CHAN_BOND_106,
	RF_CHAN_BOND_110,
	RF_CHAN_BOND_114,
@@ -156,21 +179,19 @@ typedef enum {
	RF_CHAN_BOND_130,
	RF_CHAN_BOND_134,
	RF_CHAN_BOND_138,

	RF_CHAN_BOND_142,

	RF_CHAN_BOND_151,       /* 5GHz High U-NII Band */
	RF_CHAN_BOND_151,
	RF_CHAN_BOND_155,
	RF_CHAN_BOND_159,
	RF_CHAN_BOND_163,

	NUM_RF_CHANNELS,

	MIN_2_4GHZ_CHANNEL = RF_CHAN_1,
	MAX_2_4GHZ_CHANNEL = RF_CHAN_14,
	NUM_24GHZ_CHANNELS = (MAX_2_4GHZ_CHANNEL - MIN_2_4GHZ_CHANNEL + 1),
	MIN_24GHZ_CHANNEL = RF_CHAN_1,
	MAX_24GHZ_CHANNEL = RF_CHAN_14,
	NUM_24GHZ_CHANNELS = (MAX_24GHZ_CHANNEL - MIN_24GHZ_CHANNEL + 1),

	MIN_5GHZ_CHANNEL = RF_CHAN_240,
	MIN_5GHZ_CHANNEL = RF_CHAN_36,
	MAX_5GHZ_CHANNEL = RF_CHAN_184,
	NUM_5GHZ_CHANNELS = (MAX_5GHZ_CHANNEL - MIN_5GHZ_CHANNEL + 1),

@@ -184,8 +205,8 @@ typedef enum {
	NUM_40MHZ_RF_CHANNELS =
		(MAX_40MHZ_RF_CHANNEL - MIN_40MHZ_RF_CHANNEL + 1),

	MIN_5_9GHZ_CHANNEL = RF_CHAN_170,
	MAX_5_9GHZ_CHANNEL = RF_CHAN_184,
	MIN_59GHZ_CHANNEL = RF_CHAN_170,
	MAX_59GHZ_CHANNEL = RF_CHAN_184,

	INVALID_RF_CHANNEL = 0xBAD,
	RF_CHANNEL_INVALID_MAX_FIELD = 0x7FFFFFFF
@@ -200,16 +221,16 @@ typedef enum {

typedef int8_t tPowerdBm;

typedef struct {
struct regulatory_channel {
	uint32_t enabled:4;
	uint32_t flags:28;
	tPowerdBm pwrLimit;
} sRegulatoryChannel;
	tPowerdBm pwr_limit;
};

typedef struct {
	uint16_t targetFreq;
	uint16_t channelNum;
} tRfChannelProps;
struct chan_map {
	uint16_t center_freq;
	uint16_t chan_num;
};

typedef struct {
	uint8_t chanId;
@@ -272,6 +293,8 @@ enum channel_width {
 */
typedef uint8_t country_code_t[CDS_COUNTRY_CODE_LEN + 1];

extern struct regulatory_channel reg_channels[NUM_RF_CHANNELS];
extern const struct chan_map chan_mapping[NUM_RF_CHANNELS];

CDF_STATUS cds_get_reg_domain_from_country_code(v_REGDOMAIN_t *pRegDomain,
						const country_code_t countryCode,
@@ -280,44 +303,22 @@ CDF_STATUS cds_get_reg_domain_from_country_code(v_REGDOMAIN_t *pRegDomain,
CDF_STATUS cds_read_default_country(country_code_t default_country);

CDF_STATUS cds_get_channel_list_with_power(tChannelListWithPower
					   *pChannels20MHz,
					   uint8_t *pNum20MHzChannelsFound,
					   *base_channels,
					   uint8_t *num_base_channels,
					   tChannelListWithPower
					   *pChannels40MHz,
					   uint8_t *pNum40MHzChannelsFound);
					   uint8_t *);

CDF_STATUS cds_set_reg_domain(void *clientCtxt, v_REGDOMAIN_t regId);
CDF_STATUS cds_set_reg_domain(void *client_ctxt, v_REGDOMAIN_t reg_domain);

CHANNEL_STATE cds_get_channel_state(uint32_t rfChannel);
CHANNEL_STATE cds_get_channel_state(uint32_t chan_num);

CDF_STATUS cds_regulatory_init(void);
CDF_STATUS cds_get_dfs_region(uint8_t *dfs_region);
CDF_STATUS cds_set_dfs_region(uint8_t dfs_region);
bool cds_is_dsrc_channel(uint16_t);
CHANNEL_STATE cds_get_bonded_channel_state(uint32_t chan_num,
					   enum channel_width ch_width);
					   enum channel_width chan_width);
enum channel_width cds_get_max_channel_bw(uint32_t chan_num);


#define CDS_IS_DFS_CH(channel) (cds_get_channel_state((channel)) == \
				CHANNEL_STATE_DFS)

#define CDS_IS_PASSIVE_OR_DISABLE_CH(channel) \
    (cds_get_channel_state((channel)) != CHANNEL_STATE_ENABLE)

#define CDS_MAX_24GHz_CHANNEL_NUMBER \
    (rf_channels[MAX_2_4GHZ_CHANNEL].channelNum)
#define CDS_MIN_5GHz_CHANNEL_NUMBER  (rf_channels[RF_CHAN_36].channelNum)
#define CDS_MAX_5GHz_CHANNEL_NUMBER  (rf_channels[MAX_5GHZ_CHANNEL].channelNum)

#define CDS_IS_CHANNEL_5GHZ(chnNum) \
	(((chnNum) >= CDS_MIN_5GHz_CHANNEL_NUMBER) && ((chnNum) <= CDS_MAX_5GHz_CHANNEL_NUMBER))

#define CDS_IS_CHANNEL_24GHZ(chnNum) \
	(((chnNum) > 0) && ((chnNum) <= CDS_MAX_24GHz_CHANNEL_NUMBER))

#define CDS_IS_SAME_BAND_CHANNELS(ch1, ch2) \
	(ch1 && ch2 && \
	(CDS_IS_CHANNEL_5GHZ(ch1) == CDS_IS_CHANNEL_5GHZ(ch2)))

#endif /* __CDS_REG_SERVICE_H */
+21 −28
Original line number Diff line number Diff line
@@ -42,21 +42,13 @@

#define WORLD_SKU_MASK          0x00F0
#define WORLD_SKU_PREFIX        0x0060
#define MAX_COUNTRY_COUNT       300
#define REG_WAIT_TIME           50

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) || defined(WITH_BACKPORTS)
#define IEEE80211_CHAN_PASSIVE_SCAN IEEE80211_CHAN_NO_IR
#define IEEE80211_CHAN_NO_IBSS IEEE80211_CHAN_NO_IR
#endif

/* true if init happens thru init time driver hint */
static bool init_by_driver = false;
/* true if init happens thru init time  callback from regulatory core.
   this should be set to true during driver reload */
static bool init_by_reg_core = false;

#define REG_WAIT_TIME   50

#define REG_RULE_2412_2462    REG_RULE(2412-10, 2462+10, 40, 0, 20, 0)

#define REG_RULE_2467_2472    REG_RULE(2467-10, 2472+10, 40, 0, 20, \
@@ -131,7 +123,7 @@ static const struct ieee80211_regdomain cds_world_regdom_67_68_6A_6C = {
	}
};

const tRfChannelProps rf_channels[NUM_RF_CHANNELS] = {
const struct chan_map chan_mapping[NUM_RF_CHANNELS] = {
	{2412, 1},
	{2417, 2},
	{2422, 3},
@@ -231,7 +223,10 @@ const tRfChannelProps rf_channels[NUM_RF_CHANNELS] = {
	{5815, 163},
};

sRegulatoryChannel reg_channels[NUM_RF_CHANNELS];
static bool init_by_driver;
static bool init_by_reg_core;

struct regulatory_channel reg_channels[NUM_RF_CHANNELS];

/**
 * cds_is_wwr_sku() - is regdomain world sku
@@ -400,17 +395,17 @@ CDF_STATUS cds_get_channel_list_with_power(tChannelListWithPower *
		for (i = 0; i <= RF_CHAN_14; i++) {
			if (reg_channels[i].enabled) {
				base_channels[count].chanId =
					rf_channels[i].channelNum;
					chan_mapping[i].chan_num;
				base_channels[count++].pwr =
					reg_channels[i].pwrLimit;
					reg_channels[i].pwr_limit;
			}
		}
		for (i = RF_CHAN_36; i <= RF_CHAN_184; i++) {
			if (reg_channels[i].enabled) {
				base_channels[count].chanId =
					rf_channels[i].channelNum;
					chan_mapping[i].chan_num;
				base_channels[count++].pwr =
					reg_channels[i].pwrLimit;
					reg_channels[i].pwr_limit;
			}
		}
		*num_base_channels = count;
@@ -422,18 +417,18 @@ CDF_STATUS cds_get_channel_list_with_power(tChannelListWithPower *
		for (i = RF_CHAN_BOND_3; i <= RF_CHAN_BOND_11; i++) {
			if (reg_channels[i].enabled) {
				channels_40mhz[count].chanId =
					rf_channels[i].channelNum;
					chan_mapping[i].chan_num;
				channels_40mhz[count++].pwr =
					reg_channels[i].pwrLimit;
					reg_channels[i].pwr_limit;
			}
		}

		for (i = RF_CHAN_BOND_38; i <= RF_CHAN_BOND_163; i++) {
			if (reg_channels[i].enabled) {
				channels_40mhz[count].chanId =
					rf_channels[i].channelNum;
					chan_mapping[i].chan_num;
				channels_40mhz[count++].pwr =
					reg_channels[i].pwrLimit;
					reg_channels[i].pwr_limit;
			}
		}
		*num_40mhz_channels = count;
@@ -482,7 +477,7 @@ static eRfChannels cds_get_channel_enum(uint32_t chan_num)
	uint32_t loop;

	for (loop = 0; loop <= RF_CHAN_184; loop++)
		if (rf_channels[loop].channelNum == chan_num)
		if (chan_mapping[loop].chan_num == chan_num)
			return loop;

	CDF_TRACE(CDF_MODULE_ID_CDF, CDF_TRACE_LEVEL_ERROR,
@@ -494,7 +489,7 @@ static eRfChannels cds_get_channel_enum(uint32_t chan_num)

/**
 * cds_get_channel_state() - get the channel state
 * @channel_num: channel number
 * @chan_num: channel number
 *
 * Return: CHANNEL_STATE
 */
@@ -795,9 +790,7 @@ static int cds_process_regulatory_data(struct wiphy *wiphy,
	hdd_context_t *hdd_ctx;
	const struct ieee80211_reg_rule *reg_rule;
	struct ieee80211_channel *chan;
	sRegulatoryChannel *temp_chan_k;
	sRegulatoryChannel *temp_chan_n;
	sRegulatoryChannel *temp_chan;
	struct regulatory_channel *temp_chan_k, *temp_chan_n, *temp_chan;

	hdd_ctx = cds_get_context(CDF_MODULE_ID_HDD);
	if (NULL == hdd_ctx) {
@@ -927,7 +920,7 @@ static int cds_process_regulatory_data(struct wiphy *wiphy,
						IEEE80211_CHAN_PASSIVE_SCAN;
#endif
				temp_chan_k->enabled = CHANNEL_STATE_DFS;
				temp_chan_k->pwrLimit =
				temp_chan_k->pwr_limit =
					chan->max_power;
				temp_chan_k->flags = chan->flags;

@@ -940,7 +933,7 @@ static int cds_process_regulatory_data(struct wiphy *wiphy,
					} else {
						temp_chan_n->enabled =
							CHANNEL_STATE_DFS;
						temp_chan_n->pwrLimit =
						temp_chan_n->pwr_limit =
							 chan->max_power-3;
					}
					temp_chan_n->flags = chan->flags;
@@ -950,7 +943,7 @@ static int cds_process_regulatory_data(struct wiphy *wiphy,
					hdd_ctx->isVHT80Allowed = 1;
			} else {
				temp_chan_k->enabled = CHANNEL_STATE_ENABLE;
				temp_chan_k->pwrLimit = chan->max_power;
				temp_chan_k->pwr_limit = chan->max_power;
				temp_chan_k->flags = chan->flags;
				if (n != -1) {
					if ((chan->flags &
@@ -961,7 +954,7 @@ static int cds_process_regulatory_data(struct wiphy *wiphy,
					} else {
						temp_chan_n->enabled =
							CHANNEL_STATE_ENABLE;
						temp_chan_n->pwrLimit =
						temp_chan_n->pwr_limit =
							chan->max_power - 3;
					}
					temp_chan_n->flags = chan->flags;
+9 −9
Original line number Diff line number Diff line
@@ -1275,20 +1275,20 @@ static void wlan_hdd_set_acs_ch_range(tsap_Config_t *sap_cfg, bool ht_enabled,
	int i;
	if (sap_cfg->acs_cfg.hw_mode == QCA_ACS_MODE_IEEE80211B) {
		sap_cfg->acs_cfg.hw_mode = eCSR_DOT11_MODE_11b;
		sap_cfg->acs_cfg.start_ch = rf_channels[RF_CHAN_1].channelNum;
		sap_cfg->acs_cfg.end_ch = rf_channels[RF_CHAN_14].channelNum;
		sap_cfg->acs_cfg.start_ch = CDS_CHANNEL_NUM(RF_CHAN_1);
		sap_cfg->acs_cfg.end_ch = CDS_CHANNEL_NUM(RF_CHAN_14);
	} else if (sap_cfg->acs_cfg.hw_mode == QCA_ACS_MODE_IEEE80211G) {
		sap_cfg->acs_cfg.hw_mode = eCSR_DOT11_MODE_11g;
		sap_cfg->acs_cfg.start_ch = rf_channels[RF_CHAN_1].channelNum;
		sap_cfg->acs_cfg.end_ch = rf_channels[RF_CHAN_13].channelNum;
		sap_cfg->acs_cfg.start_ch = CDS_CHANNEL_NUM(RF_CHAN_1);
		sap_cfg->acs_cfg.end_ch = CDS_CHANNEL_NUM(RF_CHAN_13);
	} else if (sap_cfg->acs_cfg.hw_mode == QCA_ACS_MODE_IEEE80211A) {
		sap_cfg->acs_cfg.hw_mode = eCSR_DOT11_MODE_11a;
		sap_cfg->acs_cfg.start_ch = rf_channels[RF_CHAN_36].channelNum;
		sap_cfg->acs_cfg.end_ch = rf_channels[RF_CHAN_165].channelNum;
		sap_cfg->acs_cfg.start_ch = CDS_CHANNEL_NUM(RF_CHAN_36);
		sap_cfg->acs_cfg.end_ch = CDS_CHANNEL_NUM(RF_CHAN_165);
	} else if (sap_cfg->acs_cfg.hw_mode == QCA_ACS_MODE_IEEE80211ANY) {
		sap_cfg->acs_cfg.hw_mode = eCSR_DOT11_MODE_abg;
		sap_cfg->acs_cfg.start_ch = rf_channels[RF_CHAN_1].channelNum;
		sap_cfg->acs_cfg.end_ch = rf_channels[RF_CHAN_165].channelNum;
		sap_cfg->acs_cfg.start_ch = CDS_CHANNEL_NUM(RF_CHAN_1);
		sap_cfg->acs_cfg.end_ch = CDS_CHANNEL_NUM(RF_CHAN_165);
	}

	if (ht_enabled)
@@ -5772,7 +5772,7 @@ CDF_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,
	if (hdd_pConfig_ini->sapAllowAllChannel) {
		/* Validate the channel */
		for (count = RF_CHAN_1; count <= RF_CHAN_165; count++) {
			if (channel == rf_channels[count].channelNum) {
			if (channel == CDS_CHANNEL_NUM(count)) {
				fValidChannel = true;
				break;
			}
+3 −3
Original line number Diff line number Diff line
@@ -3629,10 +3629,10 @@ static int __iw_softap_get_channel_list(struct net_device *dev,
	       curBand, bandStartChannel, bandEndChannel);

	for (i = bandStartChannel; i <= bandEndChannel; i++) {
		if ((CHANNEL_STATE_ENABLE == reg_channels[i].enabled) ||
		    (CHANNEL_STATE_DFS == reg_channels[i].enabled)) {
		if ((CHANNEL_STATE_ENABLE == CDS_CHANNEL_STATE(i)) ||
		    (CHANNEL_STATE_DFS == CDS_CHANNEL_STATE(i))) {
			channel_list->channels[num_channels] =
				rf_channels[i].channelNum;
				CDS_CHANNEL_NUM(i);
			num_channels++;
		}
	}
+7 −7
Original line number Diff line number Diff line
@@ -4603,7 +4603,7 @@ static uint8_t hdd_find_prefd_safe_chnl(hdd_context_t *hdd_ctxt,
		is_unsafe = 0;
		for (channel_loop = 0;
		     channel_loop < unsafe_channel_count; channel_loop++) {
			if (rf_channels[i].channelNum ==
			if (CDS_CHANNEL_NUM(i) ==
			    hdd_ctxt->unsafe_channel_list[channel_loop]) {
				is_unsafe = 1;
				break;
@@ -4611,7 +4611,7 @@ static uint8_t hdd_find_prefd_safe_chnl(hdd_context_t *hdd_ctxt,
		}
		if (!is_unsafe) {
			safe_channels[safe_channel_count] =
				rf_channels[i].channelNum;
			  CDS_CHANNEL_NUM(i);
			hddLog(CDF_TRACE_LEVEL_INFO_HIGH,
			       FL("safe channel %d"),
			       safe_channels[safe_channel_count]);
@@ -4773,7 +4773,7 @@ static void hdd_ch_avoid_cb(void *hdd_context, void *indi_param)

		for (channel_loop = MIN_20MHZ_RF_CHANNEL; channel_loop <=
					MAX_20MHZ_RF_CHANNEL; channel_loop++) {
			if (rf_channels[channel_loop].targetFreq >=
			if (CDS_CHANNEL_FREQ(channel_loop) >=
						ch_avoid_indi->avoid_freq_range[
						range_loop].start_freq) {
				start_channel_idx = channel_loop;
@@ -4782,11 +4782,11 @@ static void hdd_ch_avoid_cb(void *hdd_context, void *indi_param)
		}
		for (channel_loop = MIN_20MHZ_RF_CHANNEL; channel_loop <=
					MAX_20MHZ_RF_CHANNEL; channel_loop++) {
			if (rf_channels[channel_loop].targetFreq >=
			if (CDS_CHANNEL_FREQ(channel_loop) >=
						ch_avoid_indi->avoid_freq_range[
						range_loop].end_freq) {
				end_channel_idx = channel_loop;
				if (rf_channels[channel_loop].targetFreq >
				if (CDS_CHANNEL_FREQ(channel_loop) >
						ch_avoid_indi->avoid_freq_range[
						range_loop].end_freq)
					end_channel_idx--;
@@ -4802,7 +4802,7 @@ static void hdd_ch_avoid_cb(void *hdd_context, void *indi_param)
					end_channel_idx; channel_loop++) {
			hdd_ctxt->unsafe_channel_list[
				hdd_ctxt->unsafe_channel_count++] =
					rf_channels[channel_loop].channelNum;
				CDS_CHANNEL_FREQ(channel_loop);
			if (hdd_ctxt->unsafe_channel_count >=
							NUM_20MHZ_RF_CHANNELS) {
				hddLog(LOGW, FL("LTECoex unsafe ch list full"));
Loading