Quellcode durchsuchen

qcacld-3.0: Replace regulatory apis with reg component apis

Replace the legacy regulatory apis with regulatory component
public service apis

Change-Id: Ifd8c93fc8f57116cfc432b853248b35fd7ed1b94
CRs-Fixed: 2008013
Kiran Kumar Lokere vor 8 Jahren
Ursprung
Commit
a3de226328
55 geänderte Dateien mit 752 neuen und 1565 gelöschten Zeilen
  1. 10 117
      core/cds/inc/cds_reg_service.h
  2. 2 10
      core/cds/inc/cds_regdomain.h
  3. 38 732
      core/cds/src/cds_reg_service.c
  4. 0 219
      core/cds/src/cds_regdomain.c
  5. 1 1
      core/hdd/inc/wlan_hdd_cfg.h
  6. 1 1
      core/hdd/inc/wlan_hdd_tdls.h
  7. 59 44
      core/hdd/src/wlan_hdd_cfg80211.c
  8. 1 1
      core/hdd/src/wlan_hdd_cfg80211.h
  9. 26 27
      core/hdd/src/wlan_hdd_conc_ut.c
  10. 25 16
      core/hdd/src/wlan_hdd_ext_scan.c
  11. 41 27
      core/hdd/src/wlan_hdd_hostapd.c
  12. 1 1
      core/hdd/src/wlan_hdd_ioctl.c
  13. 25 23
      core/hdd/src/wlan_hdd_main.c
  14. 2 0
      core/hdd/src/wlan_hdd_object_manager.c
  15. 4 3
      core/hdd/src/wlan_hdd_oemdata.c
  16. 6 5
      core/hdd/src/wlan_hdd_regulatory.c
  17. 6 5
      core/hdd/src/wlan_hdd_scan.c
  18. 4 3
      core/hdd/src/wlan_hdd_tdls.c
  19. 4 2
      core/hdd/src/wlan_hdd_wext.c
  20. 1 0
      core/mac/inc/ani_global.h
  21. 2 2
      core/mac/inc/sir_api.h
  22. 1 1
      core/mac/src/pe/lim/lim_link_monitoring_algo.c
  23. 6 4
      core/mac/src/pe/lim/lim_process_action_frame.c
  24. 2 1
      core/mac/src/pe/lim/lim_process_message_queue.c
  25. 12 8
      core/mac/src/pe/lim/lim_process_mlm_req_messages.c
  26. 7 6
      core/mac/src/pe/lim/lim_process_mlm_rsp_messages.c
  27. 3 3
      core/mac/src/pe/lim/lim_process_sme_req_messages.c
  28. 8 9
      core/mac/src/pe/lim/lim_process_tdls.c
  29. 8 4
      core/mac/src/pe/lim/lim_send_messages.c
  30. 17 13
      core/mac/src/pe/lim/lim_send_sme_rsp_messages.c
  31. 5 3
      core/mac/src/pe/lim/lim_utils.c
  32. 2 1
      core/mac/src/pe/lim/lim_utils.h
  33. 3 3
      core/mac/src/sys/legacy/src/utils/src/parser_api.c
  34. 3 2
      core/sap/dfs/inc/dfs.h
  35. 2 3
      core/sap/inc/sap_api.h
  36. 16 7
      core/sap/src/sap_api_link_cntl.c
  37. 36 14
      core/sap/src/sap_ch_select.c
  38. 47 34
      core/sap/src/sap_fsm.c
  39. 1 1
      core/sap/src/sap_internal.h
  40. 26 15
      core/sap/src/sap_module.c
  41. 2 2
      core/sme/inc/csr_api.h
  42. 1 1
      core/sme/inc/csr_internal.h
  43. 17 2
      core/sme/inc/sme_api.h
  44. 1 1
      core/sme/inc/sme_inside.h
  45. 67 26
      core/sme/src/common/sme_api.c
  46. 77 76
      core/sme/src/csr/csr_api_roam.c
  47. 33 37
      core/sme/src/csr/csr_api_scan.c
  48. 9 10
      core/sme/src/csr/csr_util.c
  49. 1 0
      core/wma/inc/wma.h
  50. 18 1
      core/wma/inc/wma_api.h
  51. 1 1
      core/wma/inc/wma_dfs_interface.h
  52. 26 1
      core/wma/src/wma_dev_if.c
  53. 25 30
      core/wma/src/wma_features.c
  54. 4 3
      core/wma/src/wma_main.c
  55. 6 3
      core/wma/src/wma_scan_roam.c

+ 10 - 117
core/cds/inc/cds_reg_service.h

@@ -48,126 +48,19 @@
 #define HT40MINUS_2G_CH_START        5
 #define HT40MINUS_2G_CH_END          13
 
-
-#define CDS_CHANNEL_STATE(chan_enum) reg_channels[chan_enum].state
-#define CDS_CHANNEL_NUM(chan_enum) channel_map[chan_enum].chan_num
-#define CDS_CHANNEL_FREQ(chan_enum) channel_map[chan_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 channel_map[MIN_24GHZ_CHANNEL].chan_num
-#define CDS_MAX_24GHZ_CHANNEL_NUMBER channel_map[MAX_24GHZ_CHANNEL].chan_num
-#define CDS_MIN_5GHZ_CHANNEL_NUMBER channel_map[MIN_5GHZ_CHANNEL].chan_num
-#define CDS_MAX_5GHZ_CHANNEL_NUMBER channel_map[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(chan_num1, chan_num2) \
-	(chan_num1 && chan_num2 && \
-	(CDS_IS_CHANNEL_5GHZ(chan_num1) == CDS_IS_CHANNEL_5GHZ(chan_num2)))
-
-#define CDS_IS_CHANNEL_VALID_5G_SBS(curchan, newchan) \
-	(curchan > newchan ? \
-	CDS_CHANNEL_FREQ(cds_get_channel_enum(curchan)) \
-	- CDS_CHANNEL_FREQ(cds_get_channel_enum(newchan)) \
-	 > CDS_SBS_SEPARATION_THRESHOLD : \
-	CDS_CHANNEL_FREQ(cds_get_channel_enum(newchan)) \
-	- CDS_CHANNEL_FREQ(cds_get_channel_enum(curchan)) \
-	 > CDS_SBS_SEPARATION_THRESHOLD)
-
-extern const struct chan_map channel_map[NUM_CHANNELS];
-
-extern struct regulatory_channel reg_channels[NUM_CHANNELS];
-
-QDF_STATUS cds_get_reg_domain_from_country_code(v_REGDOMAIN_t *pRegDomain,
-						const uint8_t *country_alpha2,
-						enum country_src source);
-
-/**
- * cds_is_fcc_regdomian() - is the regdomain FCC
- *
- * Return: true on FCC regdomain, false otherwise
- */
-bool cds_is_fcc_regdomain(void);
-
-QDF_STATUS cds_read_default_country(uint8_t *default_country);
-
-QDF_STATUS cds_get_channel_list_with_power(struct channel_power
-					   *base_channels,
-					   uint8_t *num_base_channels);
-
-enum channel_enum cds_get_channel_enum(uint32_t chan_num);
-
-enum channel_state cds_get_channel_state(uint32_t chan_num);
-
-/**
- * cds_get_channel_reg_power() - get max power based on regulatory
- * @chan_num: channel number
- *
- * Return: tx power
- */
-int8_t cds_get_channel_reg_power(uint32_t chan_num);
-
-/**
- * cds_get_channel_flags() - This API returns regulatory channel flags
- * @chan_num: channel number
- *
- * Return: channel flags
- */
-uint32_t cds_get_channel_flags(uint32_t chan_num);
-
 /**
  * cds_get_vendor_reg_flags() - This API returns vendor specific regulatory
  * channel flags
- * @chan_num: channel number
- *
+ * @pdev: pdev pointer
+ * @chan: channel number
+ * @bandwidth: channel BW
+ * @is_ht_enabled: HT enabled/disabled flag
+ * @is_vht_enabled: VHT enabled/disabled flag
+ * @sub_20_channel_width: Sub 20 channel bandwidth
  * Return: channel flags
  */
-uint32_t cds_get_vendor_reg_flags(uint32_t chan, uint16_t bandwidth,
-				bool is_ht_enabled, bool is_vht_enabled,
-				uint8_t is_sub_20_channel_width);
-
-/**
- * cds_get_channel_freq() - This API returns frequency for channel
- * @chan_num: channel number
- *
- * Return: frequency
- */
-uint32_t cds_get_channel_freq(uint32_t chan_num);
-
-bool cds_is_dsrc_channel(uint16_t center_freq);
-enum channel_state cds_get_5g_bonded_channel_state(uint16_t chan_num,
-						 enum phy_ch_width chan_width);
-
-enum channel_state cds_get_2g_bonded_channel_state(uint16_t chan_num,
-						   enum phy_ch_width chan_width,
-						   uint16_t sec_ch);
-/**
- * cds_get_2g_bonded_channel_state() - get the channel bonded channel state
- * @oper_ch: operating channel
- * @ch_width: channel width
- * @sec_ch: secondary channel
- *
- * Return: channel state
- */
-enum channel_state cds_get_bonded_channel_state(uint16_t oper_ch,
-						enum phy_ch_width ch_width,
-						uint16_t sec_ch);
-void cds_set_channel_params(uint16_t oper_ch, uint16_t ht_offset_2g,
-			    struct ch_params *ch_params);
-
-QDF_STATUS cds_set_reg_domain(void *client_ctxt, v_REGDOMAIN_t reg_domain);
-QDF_STATUS cds_put_default_country(uint8_t *def_country);
-uint16_t cds_bw_value(enum phy_ch_width bw);
-uint8_t cds_skip_dfs_and_2g(uint32_t rf_channel);
-
+uint32_t cds_get_vendor_reg_flags(struct wlan_objmgr_pdev *pdev, uint32_t chan,
+				  uint16_t bandwidth,
+				  bool is_ht_enabled, bool is_vht_enabled,
+				  uint8_t sub_20_channel_width);
 #endif /* __CDS_REG_SERVICE_H */

+ 2 - 10
core/cds/inc/cds_regdomain.h

@@ -71,8 +71,8 @@
 #ifndef __CDS_REGDOMAIN_H
 #define __CDS_REGDOMAIN_H
 
-#define MAX_CHANNELS_PER_OPERATING_CLASS  25
-#define CDS_MAX_SUPP_OPER_CLASSES 32
+#include <reg_services_public_struct.h>
+
 #define MIN_TX_PWR_CAP    8
 #define MAX_TX_PWR_CAP    22
 
@@ -539,13 +539,5 @@ int32_t cds_fill_some_regulatory_info(struct regulatory *reg);
 int32_t cds_get_country_from_alpha2(uint8_t *alpha2);
 void cds_fill_and_send_ctl_to_fw(struct regulatory *reg);
 void cds_set_wma_dfs_region(uint8_t dfs_region);
-uint16_t cds_reg_dmn_get_opclass_from_channel(uint8_t *country,
-					      uint8_t channel,
-					      uint8_t offset);
-uint16_t cds_reg_dmn_get_chanwidth_from_opclass(uint8_t *country,
-						uint8_t channel,
-						uint8_t opclass);
-uint16_t cds_reg_dmn_set_curr_opclasses(uint8_t num_classes, uint8_t *class);
-uint16_t cds_reg_dmn_get_curr_opclasses(uint8_t *num_classes, uint8_t *class);
 
 #endif /* __CDS_REGDOMAIN_H */

+ 38 - 732
core/cds/src/cds_reg_service.c

@@ -31,187 +31,23 @@
    DEPENDENCIES: None
    ============================================================================*/
 
-#include <net/cfg80211.h>
 #include "qdf_types.h"
 #include "qdf_trace.h"
-#include "cds_api.h"
+#include "wlan_reg_services_api.h"
 #include "cds_reg_service.h"
-#include "cds_regdomain.h"
 #include "cds_ieee80211_common_i.h"
-#include "sme_api.h"
-#include "wlan_hdd_main.h"
+#include "cds_config.h"
 
-/**
- * struct bonded_chan
- * @start_ch: start channel
- * @end_ch: end channel
- */
-struct bonded_chan {
-	uint16_t start_ch;
-	uint16_t end_ch;
-};
-
-static const struct bonded_chan bonded_chan_40mhz_array[] = {
-	{36, 40},
-	{44, 48},
-	{52, 56},
-	{60, 64},
-	{100, 104},
-	{108, 112},
-	{116, 120},
-	{124, 128},
-	{132, 136},
-	{140, 144},
-	{149, 153},
-	{157, 161}
-};
-
-static const struct bonded_chan bonded_chan_80mhz_array[] = {
-	{36, 48},
-	{52, 64},
-	{100, 112},
-	{116, 128},
-	{132, 144},
-	{149, 161}
-};
-
-static const struct bonded_chan bonded_chan_160mhz_array[] = {
-	{36, 64},
-	{100, 128}
-};
-
-static const enum phy_ch_width next_lower_bw[] = {
-	[CH_WIDTH_80P80MHZ] = CH_WIDTH_160MHZ,
-	[CH_WIDTH_160MHZ] = CH_WIDTH_80MHZ,
-	[CH_WIDTH_80MHZ] = CH_WIDTH_40MHZ,
-	[CH_WIDTH_40MHZ] = CH_WIDTH_20MHZ,
-	[CH_WIDTH_20MHZ] = CH_WIDTH_10MHZ,
-	[CH_WIDTH_10MHZ] = CH_WIDTH_5MHZ,
-	[CH_WIDTH_5MHZ] = CH_WIDTH_INVALID
-};
-
-struct regulatory_channel reg_channels[NUM_CHANNELS];
-static uint8_t default_country[CDS_COUNTRY_CODE_LEN + 1];
-
-/**
- * cds_get_channel_list_with_power() - retrieve channel list with power
- * @base_channels: base channels
- * @num_base_channels: number of base channels
- *
- * Return: QDF_STATUS_SUCCESS
- */
-QDF_STATUS cds_get_channel_list_with_power(struct channel_power
-					   *base_channels,
-					   uint8_t *num_base_channels)
-{
-	QDF_STATUS status = QDF_STATUS_SUCCESS;
-	int i, count;
-
-	if (base_channels && num_base_channels) {
-		count = 0;
-		for (i = 0; i < NUM_CHANNELS; i++) {
-			if (reg_channels[i].state) {
-				base_channels[count].chan_num =
-					channel_map[i].chan_num;
-				base_channels[count++].tx_power =
-					reg_channels[i].tx_power;
-			}
-		}
-		*num_base_channels = count;
-	}
-
-	return status;
-}
-
-/**
- * cds_read_default_country() - set the default country
- * @def_ctry: default country
- *
- * Return: QDF_STATUS
- */
-QDF_STATUS cds_read_default_country(uint8_t *def_ctry)
-{
-	memcpy(def_ctry,
-	       default_country,
-	       CDS_COUNTRY_CODE_LEN + 1);
-
-	QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_INFO,
-		  "default country is %c%c\n",
-		  def_ctry[0],
-		  def_ctry[1]);
-
-	return QDF_STATUS_SUCCESS;
-}
-
-/**
- * cds_get_channel_enum() - get the channel enumeration
- * @chan_num: channel number
- *
- * Return: enum for the channel
- */
-enum channel_enum cds_get_channel_enum(uint32_t chan_num)
-{
-	uint32_t loop;
-
-	for (loop = 0; loop < NUM_CHANNELS; loop++)
-		if (channel_map[loop].chan_num == chan_num)
-			return loop;
-
-	QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
-		  "invalid channel number %d", chan_num);
-
-	return INVALID_CHANNEL;
-}
-
-
-/**
- * cds_get_channel_state() - get the channel state
- * @chan_num: channel number
- *
- * Return: channel state
- */
-enum channel_state cds_get_channel_state(uint32_t chan_num)
-{
-	enum channel_enum chan_enum;
-
-	chan_enum = cds_get_channel_enum(chan_num);
-	if (INVALID_CHANNEL == chan_enum)
-		return CHANNEL_STATE_INVALID;
-	else
-		return reg_channels[chan_enum].state;
-}
-
-int8_t cds_get_channel_reg_power(uint32_t chan_num)
-{
-	enum channel_enum chan_enum;
-
-	chan_enum = cds_get_channel_enum(chan_num);
-	if (chan_enum == INVALID_CHANNEL)
-		return CHANNEL_STATE_INVALID;
-	else
-		return reg_channels[chan_enum].tx_power;
-}
-
-uint32_t cds_get_channel_flags(uint32_t chan_num)
-{
-	enum channel_enum chan_enum;
-
-	chan_enum = cds_get_channel_enum(chan_num);
-	if (chan_enum == INVALID_CHANNEL)
-		return CHANNEL_STATE_INVALID;
-	else
-		return reg_channels[chan_enum].chan_flags;
-}
-
-uint32_t cds_get_vendor_reg_flags(uint32_t chan, uint16_t bandwidth,
-				bool is_ht_enabled, bool is_vht_enabled,
-				uint8_t sub_20_channel_width)
+uint32_t cds_get_vendor_reg_flags(struct wlan_objmgr_pdev *pdev,
+		uint32_t chan, uint16_t bandwidth,
+		bool is_ht_enabled, bool is_vht_enabled,
+		uint8_t sub_20_channel_width)
 {
 	uint32_t flags = 0;
 	enum channel_state state;
 	struct ch_params ch_params;
 
-	state = cds_get_channel_state(chan);
+	state = wlan_reg_get_channel_state(pdev, chan);
 	if (state == CHANNEL_STATE_INVALID)
 		return flags;
 	if (state == CHANNEL_STATE_DFS) {
@@ -221,616 +57,86 @@ uint32_t cds_get_vendor_reg_flags(uint32_t chan, uint16_t bandwidth,
 	if (state == CHANNEL_STATE_DISABLE)
 		flags |= IEEE80211_CHAN_BLOCKED;
 
-	if (CDS_IS_CHANNEL_24GHZ(chan)) {
+	if (WLAN_REG_IS_24GHZ_CH(chan)) {
 		if ((bandwidth == CH_WIDTH_80P80MHZ) ||
-			(bandwidth == CH_WIDTH_160MHZ) ||
-			(bandwidth == CH_WIDTH_80MHZ)) {
+		    (bandwidth == CH_WIDTH_160MHZ) ||
+		    (bandwidth == CH_WIDTH_80MHZ)) {
 			bandwidth = CH_WIDTH_40MHZ;
 		}
 	}
 
 	switch (bandwidth) {
-
 	case CH_WIDTH_80P80MHZ:
-		if (cds_get_5g_bonded_channel_state(chan,
-				  bandwidth) != CHANNEL_STATE_INVALID) {
+		if (wlan_reg_get_5g_bonded_channel_state(pdev, chan,
+					bandwidth) != CHANNEL_STATE_INVALID) {
 			if (is_vht_enabled)
 				flags |= IEEE80211_CHAN_VHT80_80;
 		}
 		bandwidth = CH_WIDTH_160MHZ;
-		/* FALLTHROUGH */
+	/* FALLTHROUGH */
 	case CH_WIDTH_160MHZ:
-		if (cds_get_5g_bonded_channel_state(chan,
-				  bandwidth) != CHANNEL_STATE_INVALID) {
+		if (wlan_reg_get_5g_bonded_channel_state(pdev, chan,
+					bandwidth) != CHANNEL_STATE_INVALID) {
 			if (is_vht_enabled)
 				flags |= IEEE80211_CHAN_VHT160;
 		}
 		bandwidth = CH_WIDTH_80MHZ;
-		/* FALLTHROUGH */
+	/* FALLTHROUGH */
 	case CH_WIDTH_80MHZ:
-		if (cds_get_5g_bonded_channel_state(chan,
-				  bandwidth) != CHANNEL_STATE_INVALID) {
+		if (wlan_reg_get_5g_bonded_channel_state(pdev, chan,
+					bandwidth) != CHANNEL_STATE_INVALID) {
 			if (is_vht_enabled)
 				flags |= IEEE80211_CHAN_VHT80;
 		}
 		bandwidth = CH_WIDTH_40MHZ;
-		/* FALLTHROUGH */
+	/* FALLTHROUGH */
 	case CH_WIDTH_40MHZ:
 		qdf_mem_zero(&ch_params, sizeof(ch_params));
 		ch_params.ch_width = bandwidth;
-		cds_set_channel_params(chan, 0, &ch_params);
+		wlan_reg_set_channel_params(pdev, chan, 0, &ch_params);
 
-		if (cds_get_bonded_channel_state(chan, bandwidth,
-		    ch_params.sec_ch_offset) != CHANNEL_STATE_INVALID) {
-			if (ch_params.sec_ch_offset ==
-			    PHY_DOUBLE_CHANNEL_LOW_PRIMARY) {
+		if (wlan_reg_get_bonded_channel_state(pdev, chan, bandwidth,
+					ch_params.sec_ch_offset) !=
+				CHANNEL_STATE_INVALID) {
+			if (ch_params.sec_ch_offset == LOW_PRIMARY_CH) {
 				flags |= IEEE80211_CHAN_HT40PLUS;
 				if (is_vht_enabled)
 					flags |= IEEE80211_CHAN_VHT40PLUS;
 			} else if (ch_params.sec_ch_offset ==
-				   PHY_DOUBLE_CHANNEL_HIGH_PRIMARY) {
+					HIGH_PRIMARY_CH) {
 				flags |= IEEE80211_CHAN_HT40MINUS;
 				if (is_vht_enabled)
 					flags |= IEEE80211_CHAN_VHT40MINUS;
 			}
 		}
-
 		bandwidth = CH_WIDTH_20MHZ;
-		/* FALLTHROUGH */
+	/* FALLTHROUGH */
 	case CH_WIDTH_20MHZ:
 		if (is_vht_enabled)
 			flags |= IEEE80211_CHAN_VHT20;
 		if (is_ht_enabled)
 			flags |= IEEE80211_CHAN_HT20;
 		bandwidth = CH_WIDTH_10MHZ;
-		/* FALLTHROUGH */
+	/* FALLTHROUGH */
 	case CH_WIDTH_10MHZ:
-		if ((cds_get_bonded_channel_state(chan,
-			bandwidth, 0) != CHANNEL_STATE_INVALID) &&
-			(sub_20_channel_width ==
-				WLAN_SUB_20_CH_WIDTH_10))
+		if ((wlan_reg_get_bonded_channel_state(pdev, chan, bandwidth,
+						0) != CHANNEL_STATE_INVALID) &&
+				(sub_20_channel_width ==
+				 WLAN_SUB_20_CH_WIDTH_10))
 			flags |= IEEE80211_CHAN_HALF;
-		/* FALLTHROUGH */
+	/* FALLTHROUGH */
 	case CH_WIDTH_5MHZ:
-		if ((cds_get_bonded_channel_state(chan,
-			bandwidth, 0) != CHANNEL_STATE_INVALID) &&
-			(sub_20_channel_width ==
-				WLAN_SUB_20_CH_WIDTH_5))
+		if ((wlan_reg_get_bonded_channel_state(pdev, chan, bandwidth,
+						0) != CHANNEL_STATE_INVALID) &&
+				(sub_20_channel_width ==
+				 WLAN_SUB_20_CH_WIDTH_5))
 			flags |= IEEE80211_CHAN_QUARTER;
 		break;
 	default:
-	QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_INFO,
-		"invalid channel width value %d", bandwidth);
+		QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_INFO,
+				"invalid channel width value %d", bandwidth);
 	}
 
 	return flags;
 }
 
-uint32_t cds_get_channel_freq(uint32_t chan_num)
-{
-	enum channel_enum chan_enum;
-
-	chan_enum = cds_get_channel_enum(chan_num);
-	if (chan_enum == INVALID_CHANNEL)
-		return CHANNEL_STATE_INVALID;
-	else
-		return channel_map[chan_enum].center_freq;
-}
-
-/**
- * cds_search_5g_bonded_chan_array() - get ptr to bonded channel
- * @oper_ch: operating channel number
- * @bonded_chan_ar: bonded channel array
- * @bonded_chan_ptr_ptr: bonded channel ptr ptr
- *
- * Return: bonded channel state
- */
-static enum channel_state cds_search_5g_bonded_chan_array(uint32_t oper_chan,
-							const struct bonded_chan
-							bonded_chan_ar[],
-							uint16_t array_size,
-							const struct bonded_chan
-							**bonded_chan_ptr_ptr)
-{
-	int i;
-	uint8_t chan_num;
-	const struct bonded_chan *bonded_chan_ptr = NULL;
-	enum channel_state chan_state = CHANNEL_STATE_INVALID;
-	enum channel_state temp_chan_state;
-
-	for (i = 0; i < array_size; i++) {
-		if ((oper_chan >= bonded_chan_ar[i].start_ch) &&
-		    (oper_chan <= bonded_chan_ar[i].end_ch)) {
-			bonded_chan_ptr =  &(bonded_chan_ar[i]);
-			break;
-		}
-	}
-
-	if (NULL == bonded_chan_ptr)
-		return chan_state;
-
-	*bonded_chan_ptr_ptr = bonded_chan_ptr;
-	chan_num =  bonded_chan_ptr->start_ch;
-	while (chan_num <= bonded_chan_ptr->end_ch) {
-		temp_chan_state = cds_get_channel_state(chan_num);
-		if (temp_chan_state < chan_state)
-			chan_state = temp_chan_state;
-		chan_num = chan_num + 4;
-	}
-
-	return chan_state;
-}
-
-/**
- * cds_search_5g_bonded_channel() - get the 5G bonded channel state
- * @chan_num: channel number
- * @ch_width: channel width
- * @bonded_chan_ptr_ptr: bonded channel ptr ptr
- *
- * Return: channel state
- */
-static enum channel_state cds_search_5g_bonded_channel(uint32_t chan_num,
-						enum phy_ch_width ch_width,
-						const struct bonded_chan
-						**bonded_chan_ptr_ptr)
-{
-
-	if (CH_WIDTH_80P80MHZ == ch_width)
-		return cds_search_5g_bonded_chan_array(chan_num,
-						       bonded_chan_80mhz_array,
-						       QDF_ARRAY_SIZE(bonded_chan_80mhz_array),
-						       bonded_chan_ptr_ptr);
-	else if (CH_WIDTH_160MHZ == ch_width)
-		return cds_search_5g_bonded_chan_array(chan_num,
-						       bonded_chan_160mhz_array,
-						       QDF_ARRAY_SIZE(bonded_chan_160mhz_array),
-						       bonded_chan_ptr_ptr);
-	else if (CH_WIDTH_80MHZ == ch_width)
-		return cds_search_5g_bonded_chan_array(chan_num,
-						       bonded_chan_80mhz_array,
-						       QDF_ARRAY_SIZE(bonded_chan_80mhz_array),
-						       bonded_chan_ptr_ptr);
-	else if (CH_WIDTH_40MHZ == ch_width)
-		return cds_search_5g_bonded_chan_array(chan_num,
-						       bonded_chan_40mhz_array,
-						       QDF_ARRAY_SIZE(bonded_chan_40mhz_array),
-						       bonded_chan_ptr_ptr);
-	else
-		return cds_get_channel_state(chan_num);
-}
-
-enum channel_state cds_get_bonded_channel_state(uint16_t oper_ch,
-						enum phy_ch_width ch_width,
-						uint16_t sec_ch)
-{
-	if (CDS_IS_CHANNEL_5GHZ(oper_ch))
-		return cds_get_5g_bonded_channel_state(oper_ch,
-							ch_width);
-	else
-		return cds_get_2g_bonded_channel_state(oper_ch,
-							ch_width, sec_ch);
-}
-
-/**
- * cds_get_2g_bonded_channel_state() - get the 2G bonded channel state
- * @oper_ch: operating channel
- * @ch_width: channel width
- * @sec_ch: secondary channel
- *
- * Return: channel state
- */
-enum channel_state cds_get_2g_bonded_channel_state(uint16_t oper_ch,
-						  enum phy_ch_width ch_width,
-						  uint16_t sec_ch)
-{
-	enum channel_enum chan_enum;
-	enum channel_state chan_state;
-	bool bw_enabled = false;
-	enum channel_state chan_state2 = CHANNEL_STATE_INVALID;
-
-	if (CH_WIDTH_40MHZ < ch_width)
-		return CHANNEL_STATE_INVALID;
-
-	if (CH_WIDTH_40MHZ == ch_width) {
-		if ((sec_ch + 4 != oper_ch) &&
-		    (oper_ch + 4 != sec_ch))
-			return CHANNEL_STATE_INVALID;
-		chan_state2 = cds_get_channel_state(sec_ch);
-		if (CHANNEL_STATE_INVALID == chan_state2)
-			return chan_state2;
-	}
-
-	chan_state = cds_get_channel_state(oper_ch);
-	if (chan_state2 < chan_state)
-		chan_state = chan_state2;
-
-	if ((CHANNEL_STATE_INVALID == chan_state) ||
-	    (CHANNEL_STATE_DISABLE == chan_state))
-		return chan_state;
-
-	chan_enum = cds_get_channel_enum(oper_ch);
-	if (CH_WIDTH_5MHZ == ch_width)
-		bw_enabled = true;
-	else if (CH_WIDTH_10MHZ == ch_width)
-		bw_enabled = !(reg_channels[chan_enum].chan_flags &
-			       IEEE80211_CHAN_NO_10MHZ);
-	else if (CH_WIDTH_20MHZ == ch_width)
-		bw_enabled = !(reg_channels[chan_enum].chan_flags &
-			       IEEE80211_CHAN_NO_20MHZ);
-	else if (CH_WIDTH_40MHZ == ch_width)
-		bw_enabled = !((reg_channels[chan_enum].chan_flags &
-				IEEE80211_CHAN_NO_HT40) == IEEE80211_CHAN_NO_HT40);
-
-	if (bw_enabled)
-		return chan_state;
-	else
-		return CHANNEL_STATE_DISABLE;
-}
-
-/**
- * cds_get_5g_bonded_channel_state() - get the 5G bonded channel state
- * @chan_num: channel number
- * @ch_width: channel width
- *
- * Return: channel state
- */
-enum channel_state cds_get_5g_bonded_channel_state(
-	uint16_t chan_num,
-	enum phy_ch_width ch_width)
-{
-	enum channel_enum chan_enum;
-	enum channel_state chan_state;
-	bool bw_enabled = false;
-	const struct bonded_chan *bonded_chan_ptr = NULL;
-
-	if (CH_WIDTH_80P80MHZ < ch_width)
-		return CHANNEL_STATE_INVALID;
-
-	chan_state = cds_search_5g_bonded_channel(chan_num, ch_width,
-						  &bonded_chan_ptr);
-
-	if ((CHANNEL_STATE_INVALID == chan_state) ||
-	    (CHANNEL_STATE_DISABLE == chan_state))
-		return chan_state;
-
-	chan_enum = cds_get_channel_enum(chan_num);
-	if (CH_WIDTH_5MHZ == ch_width)
-		bw_enabled = true;
-	else if (CH_WIDTH_10MHZ == ch_width)
-		bw_enabled = !(reg_channels[chan_enum].chan_flags &
-			       IEEE80211_CHAN_NO_10MHZ);
-	else if (CH_WIDTH_20MHZ == ch_width)
-		bw_enabled = !(reg_channels[chan_enum].chan_flags &
-			       IEEE80211_CHAN_NO_20MHZ);
-	else if (CH_WIDTH_40MHZ == ch_width)
-		bw_enabled = !((reg_channels[chan_enum].chan_flags &
-				IEEE80211_CHAN_NO_HT40) == IEEE80211_CHAN_NO_HT40);
-	else if (CH_WIDTH_80MHZ == ch_width)
-		bw_enabled = !(reg_channels[chan_enum].chan_flags &
-			       IEEE80211_CHAN_NO_80MHZ);
-	else if (CH_WIDTH_160MHZ == ch_width)
-		bw_enabled = !(reg_channels[chan_enum].chan_flags &
-			       IEEE80211_CHAN_NO_160MHZ);
-	else if (CH_WIDTH_80P80MHZ == ch_width)
-		bw_enabled = !(reg_channels[chan_enum].chan_flags &
-			       IEEE80211_CHAN_NO_80MHZ);
-
-	if (bw_enabled)
-		return chan_state;
-	else
-		return CHANNEL_STATE_DISABLE;
-}
-
-/**
- * cds_combine_channel_states() - combine channel states
- * @chan_state1: channel state1
- * @chan_state2: channel state2
- *
- * Return: enum channel_state
- */
- static enum channel_state cds_combine_channel_states(
-		 enum channel_state chan_state1,
-		 enum channel_state chan_state2)
-{
-	if ((CHANNEL_STATE_INVALID == chan_state1) ||
-	    (CHANNEL_STATE_INVALID == chan_state2))
-		return CHANNEL_STATE_INVALID;
-	else
-		return min(chan_state1, chan_state2);
-}
-
-/**
- * cds_set_5g_channel_params() - set the 5G bonded channel parameters
- * @oper_ch: opetrating channel
- * @ch_params: channel parameters
- *
- * Return: void
- */
-static void cds_set_5g_channel_params(uint16_t oper_ch,
-				      struct ch_params *ch_params)
-{
-	enum channel_state chan_state = CHANNEL_STATE_ENABLE;
-	enum channel_state chan_state2 = CHANNEL_STATE_ENABLE;
-	const struct bonded_chan *bonded_chan_ptr = NULL;
-	const struct bonded_chan *bonded_chan_ptr2 = NULL;
-
-	if (CH_WIDTH_MAX <= ch_params->ch_width) {
-		if (0 != ch_params->center_freq_seg1)
-			ch_params->ch_width = CH_WIDTH_80P80MHZ;
-		else
-			ch_params->ch_width = CH_WIDTH_160MHZ;
-	}
-
-	while (ch_params->ch_width != CH_WIDTH_INVALID) {
-		bonded_chan_ptr = NULL;
-		bonded_chan_ptr2 = NULL;
-		chan_state = cds_search_5g_bonded_channel(oper_ch,
-							  ch_params->ch_width,
-							  &bonded_chan_ptr);
-
-		chan_state = cds_get_5g_bonded_channel_state(oper_ch,
-							  ch_params->ch_width);
-
-		if (CH_WIDTH_80P80MHZ == ch_params->ch_width) {
-			chan_state2 = cds_get_5g_bonded_channel_state(
-				ch_params->center_freq_seg1 - 2,
-				CH_WIDTH_80MHZ);
-
-			chan_state = cds_combine_channel_states(chan_state,
-								chan_state2);
-		}
-
-		if ((CHANNEL_STATE_ENABLE == chan_state) ||
-		    (CHANNEL_STATE_DFS == chan_state)) {
-			if (CH_WIDTH_20MHZ >= ch_params->ch_width) {
-				ch_params->sec_ch_offset
-					= PHY_SINGLE_CHANNEL_CENTERED;
-				ch_params->center_freq_seg0 = oper_ch;
-				break;
-			} else if (CH_WIDTH_40MHZ <= ch_params->ch_width) {
-				cds_search_5g_bonded_chan_array(oper_ch,
-							bonded_chan_40mhz_array,
-					QDF_ARRAY_SIZE(bonded_chan_40mhz_array),
-							     &bonded_chan_ptr2);
-				if (bonded_chan_ptr && bonded_chan_ptr2) {
-					if (oper_ch ==
-					    bonded_chan_ptr2->start_ch)
-						ch_params->sec_ch_offset =
-						PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
-					else
-						ch_params->sec_ch_offset =
-						PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
-
-					ch_params->center_freq_seg0 =
-						(bonded_chan_ptr->start_ch +
-						 bonded_chan_ptr->end_ch)/2;
-					break;
-				}
-			}
-		}
-		ch_params->ch_width = next_lower_bw[ch_params->ch_width];
-	}
-	if (CH_WIDTH_160MHZ == ch_params->ch_width) {
-		ch_params->center_freq_seg1 = ch_params->center_freq_seg0;
-		chan_state = cds_search_5g_bonded_channel(oper_ch,
-							  CH_WIDTH_80MHZ,
-							  &bonded_chan_ptr);
-		if (bonded_chan_ptr)
-			ch_params->center_freq_seg0 =
-				(bonded_chan_ptr->start_ch +
-				 bonded_chan_ptr->end_ch)/2;
-	}
-	QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_DEBUG,
-			"ch: %d ch_wd: %d freq0: %d freq1: %d", oper_ch,
-			ch_params->ch_width, ch_params->center_freq_seg0,
-			ch_params->center_freq_seg1);
-}
-
-/**
- * cds_set_2g_channel_params() - set the 2.4G bonded channel parameters
- * @oper_ch: operating channel
- * @ch_params: channel parameters
- * @sec_ch_2g: 2.4G secondary channel
- *
- * Return: void
- */
-static void cds_set_2g_channel_params(uint16_t oper_ch,
-			       struct ch_params *ch_params,
-			       uint16_t sec_ch_2g)
-{
-	enum channel_state chan_state = CHANNEL_STATE_ENABLE;
-
-	if (CH_WIDTH_MAX <= ch_params->ch_width)
-		ch_params->ch_width = CH_WIDTH_40MHZ;
-
-	if ((cds_bw_value(ch_params->ch_width) > 20) && !sec_ch_2g) {
-		if (oper_ch >= 1 && oper_ch <= 5)
-			sec_ch_2g = oper_ch + 4;
-		else if (oper_ch >= 6 && oper_ch <= 13)
-			sec_ch_2g = oper_ch - 4;
-	}
-
-	while (ch_params->ch_width != CH_WIDTH_INVALID) {
-		chan_state = cds_get_2g_bonded_channel_state(oper_ch,
-							    ch_params->ch_width,
-							    sec_ch_2g);
-		if (CHANNEL_STATE_ENABLE == chan_state) {
-			if (CH_WIDTH_40MHZ == ch_params->ch_width) {
-				if (oper_ch < sec_ch_2g)
-					ch_params->sec_ch_offset =
-						PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
-				else
-					ch_params->sec_ch_offset =
-						PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
-				ch_params->center_freq_seg0 =
-					(oper_ch + sec_ch_2g)/2;
-			} else
-				ch_params->sec_ch_offset =
-					PHY_SINGLE_CHANNEL_CENTERED;
-			break;
-		}
-
-		ch_params->ch_width = next_lower_bw[ch_params->ch_width];
-	}
-}
-
-/**
- * cds_set_channel_params() - set the bonded channel parameters
- * @oper_ch: operating channel
- * @sec_ch_2g: 2.4G secondary channel
- * @ch_params: chanel parameters
- *
- * Return: void
- */
-void cds_set_channel_params(uint16_t oper_ch, uint16_t sec_ch_2g,
-			    struct ch_params *ch_params)
-{
-	if (CDS_IS_CHANNEL_5GHZ(oper_ch))
-		cds_set_5g_channel_params(oper_ch, ch_params);
-	else if  (CDS_IS_CHANNEL_24GHZ(oper_ch))
-		cds_set_2g_channel_params(oper_ch, ch_params, sec_ch_2g);
-}
-
-/**
- * cds_get_reg_domain_from_country_code() - get the regulatory domain
- * @reg_domain_ptr: ptr to store regulatory domain
- *
- * Return: QDF_STATUS_SUCCESS on success
- *         QDF_STATUS_E_FAULT on error
- *         QDF_STATUS_E_EMPTY country table empty
- */
-QDF_STATUS cds_get_reg_domain_from_country_code(v_REGDOMAIN_t *reg_domain_ptr,
-						const uint8_t *country_alpha2,
-						enum country_src source)
-{
-	if (NULL == reg_domain_ptr) {
-		QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
-			  "Invalid reg domain pointer");
-		return QDF_STATUS_E_FAULT;
-	}
-
-	*reg_domain_ptr = 0;
-
-	if (SOURCE_QUERY == source)
-		return QDF_STATUS_SUCCESS;
-
-	if (NULL == country_alpha2) {
-		QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
-			  "Country code array is NULL");
-		return QDF_STATUS_E_FAULT;
-	}
-
-	if (cds_is_driver_recovering()) {
-		QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
-			  "SSR in progress, return");
-		return QDF_STATUS_SUCCESS;
-	}
-
-	if (SOURCE_11D == source || SOURCE_USERSPACE == source)
-		regulatory_hint_user(country_alpha2,
-				     NL80211_USER_REG_HINT_USER);
-
-	return QDF_STATUS_SUCCESS;
-}
-
-/**
- * cds_is_fcc_regdomian() - is the regdomain FCC
- *
- * Return: true on FCC regdomain, false otherwise
- */
-bool cds_is_fcc_regdomain(void)
-{
-	v_REGDOMAIN_t domainId;
-	hdd_context_t *hdd_ctx;
-
-	hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
-	if (wlan_hdd_validate_context(hdd_ctx))
-		return false;
-	cds_get_reg_domain_from_country_code(&domainId,
-			hdd_ctx->reg.alpha2, SOURCE_QUERY);
-	if (REGDOMAIN_FCC == domainId)
-		return true;
-	return false;
-}
-
-/*
- * cds_is_dsrc_channel() - is the channel DSRC
- * @center_freq: center freq of the channel
- *
- * Return: true if dsrc channel
- *         false otherwise
- */
-bool cds_is_dsrc_channel(uint16_t center_freq)
-{
-	if (center_freq >= 5852 &&
-	    center_freq <= 5920)
-		return true;
-
-	return false;
-}
-
-/**
- * cds_set_reg_domain() - set regulatory domain
- * @client_ctxt: client context
- * @reg_domain: regulatory domain
- *
- * Return: QDF_STATUS
- */
-QDF_STATUS cds_set_reg_domain(void *client_ctxt, v_REGDOMAIN_t reg_domain)
-{
-	if (reg_domain >= REGDOMAIN_COUNT) {
-		QDF_TRACE(QDF_MODULE_ID_QDF_DEVICE, QDF_TRACE_LEVEL_ERROR,
-			  "CDS set reg domain, invalid REG domain ID %d",
-			  reg_domain);
-		return QDF_STATUS_E_INVAL;
-	}
-
-	return QDF_STATUS_SUCCESS;
-}
-
-/**
- * cds_put_default_country() - save the default country
- * @dfs_country: default country
- *
- * Return: QDF_STATUS
- */
-QDF_STATUS cds_put_default_country(uint8_t *def_country)
-{
-	default_country[0] = def_country[0];
-	default_country[1] = def_country[1];
-
-	return QDF_STATUS_SUCCESS;
-}
-
-/**
- * cds_bw_value() - give bandwidth value
- * bw: bandwidth enum
- *
- * Return: uint16_t
- */
-uint16_t cds_bw_value(enum phy_ch_width bw)
-{
-	switch (bw) {
-	case CH_WIDTH_20MHZ:
-		return 20;
-	case CH_WIDTH_40MHZ:
-		return 40;
-	case CH_WIDTH_80MHZ:
-		return 80;
-	case CH_WIDTH_160MHZ:
-		return 160;
-	case CH_WIDTH_80P80MHZ:
-		return 160;
-	case CH_WIDTH_INVALID:
-		return 0;
-	case CH_WIDTH_5MHZ:
-		return 10;
-	case CH_WIDTH_10MHZ:
-		return 5;
-	case CH_WIDTH_MAX:
-		return 160;
-	default:
-		return 0;
-	}
-}
-

+ 0 - 219
core/cds/src/cds_regdomain.c

@@ -69,91 +69,6 @@
 #include "wma.h"
 #include "cds_regdomain.h"
 
-static struct reg_dmn_supp_op_classes reg_dmn_curr_supp_opp_classes = { 0 };
-
-static const struct reg_dmn_op_class_map_t global_op_class[] = {
-	{81, 25, BW20, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13} },
-	{82, 25, BW20, {14} },
-	{83, 40, BW40_LOW_PRIMARY, {1, 2, 3, 4, 5, 6, 7, 8, 9} },
-	{84, 40, BW40_HIGH_PRIMARY, {5, 6, 7, 8, 9, 10, 11, 12, 13} },
-	{115, 20, BW20, {36, 40, 44, 48} },
-	{116, 40, BW40_LOW_PRIMARY, {36, 44} },
-	{117, 40, BW40_HIGH_PRIMARY, {40, 48} },
-	{118, 20, BW20, {52, 56, 60, 64} },
-	{119, 40, BW40_LOW_PRIMARY, {52, 60} },
-	{120, 40, BW40_HIGH_PRIMARY, {56, 64} },
-	{121, 20, BW20,
-	 {100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140} },
-	{122, 40, BW40_LOW_PRIMARY, {100, 108, 116, 124, 132} },
-	{123, 40, BW40_HIGH_PRIMARY, {104, 112, 120, 128, 136} },
-	{125, 20, BW20, {149, 153, 157, 161, 165, 169} },
-	{126, 40, BW40_LOW_PRIMARY, {149, 157} },
-	{127, 40, BW40_HIGH_PRIMARY, {153, 161} },
-	{128, 80, BW80, {36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108,
-			   112, 116, 120, 124, 128, 132, 136, 140, 144,
-			   149, 153, 157, 161} },
-	{0, 0, 0, {0} },
-};
-
-static const struct reg_dmn_op_class_map_t us_op_class[] = {
-	{1, 20, BW20, {36, 40, 44, 48} },
-	{2, 20, BW20, {52, 56, 60, 64} },
-	{4, 20, BW20, {100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140,
-		       144} },
-	{5, 20, BW20, {149, 153, 157, 161, 165} },
-	{12, 25, BW20, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} },
-	{22, 40, BW40_LOW_PRIMARY, {36, 44} },
-	{23, 40, BW40_LOW_PRIMARY, {52, 60} },
-	{24, 40, BW40_LOW_PRIMARY, {100, 108, 116, 124, 132} },
-	{26, 40, BW40_LOW_PRIMARY, {149, 157} },
-	{27, 40, BW40_HIGH_PRIMARY, {40, 48} },
-	{28, 40, BW40_HIGH_PRIMARY, {56, 64} },
-	{29, 40, BW40_HIGH_PRIMARY, {104, 112, 120, 128, 136} },
-	{31, 40, BW40_HIGH_PRIMARY, {153, 161} },
-	{32, 40, BW40_LOW_PRIMARY, {1, 2, 3, 4, 5, 6, 7} },
-	{33, 40, BW40_HIGH_PRIMARY, {5, 6, 7, 8, 9, 10, 11} },
-	{128, 80, BW80, {36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108,
-			 112, 116, 120, 124, 128, 132, 136, 140, 144,
-			 149, 153, 157, 161} },
-	{0, 0, 0, {0} },
-};
-
-static const struct reg_dmn_op_class_map_t euro_op_class[] = {
-	{1, 20, BW20, {36, 40, 44, 48} },
-	{2, 20, BW20, {52, 56, 60, 64} },
-	{3, 20, BW20, {100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140} },
-	{4, 25, BW20, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13} },
-	{5, 40, BW40_LOW_PRIMARY, {36, 44} },
-	{6, 40, BW40_LOW_PRIMARY, {52, 60} },
-	{7, 40, BW40_LOW_PRIMARY, {100, 108, 116, 124, 132} },
-	{8, 40, BW40_HIGH_PRIMARY, {40, 48} },
-	{9, 40, BW40_HIGH_PRIMARY, {56, 64} },
-	{10, 40, BW40_HIGH_PRIMARY, {104, 112, 120, 128, 136} },
-	{11, 40, BW40_LOW_PRIMARY, {1, 2, 3, 4, 5, 6, 7, 8, 9} },
-	{12, 40, BW40_HIGH_PRIMARY, {5, 6, 7, 8, 9, 10, 11, 12, 13} },
-	{17, 20, BW20, {149, 153, 157, 161, 165, 169} },
-	{128, 80, BW80, {36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112,
-			 116, 120, 124, 128} },
-	{0, 0, 0, {0} },
-};
-
-static const struct reg_dmn_op_class_map_t japan_op_class[] = {
-	{1, 20, BW20, {36, 40, 44, 48} },
-	{30, 25, BW20, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13} },
-	{31, 25, BW20, {14} },
-	{32, 20, BW20, {52, 56, 60, 64} },
-	{34, 20, BW20,
-		{100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140} },
-	{36, 40, BW40_LOW_PRIMARY, {36, 44} },
-	{37, 40, BW40_LOW_PRIMARY, {52, 60} },
-	{39, 40, BW40_LOW_PRIMARY, {100, 108, 116, 124, 132} },
-	{41, 40, BW40_HIGH_PRIMARY, {40, 48} },
-	{42, 40, BW40_HIGH_PRIMARY, {56, 64} },
-	{44, 40, BW40_HIGH_PRIMARY, {104, 112, 120, 128, 136} },
-	{128, 80, BW80, {36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112,
-			 116, 120, 124, 128} },
-	{0, 0, 0, {0} },
-};
 
 static const struct reg_dmn_pair g_reg_dmn_pairs[] = {
 	{NO_ENUMRD, FCC8, FCCA, CTRY_DEFAULT},
@@ -764,137 +679,3 @@ void cds_set_wma_dfs_region(uint8_t dfs_region)
 	wma_set_dfs_region(wma, dfs_region);
 }
 
-/**
- * cds_reg_dmn_get_chanwidth_from_opclass() - return chan width based on opclass
- * @country: country name
- * @channel: operating channel
- * @opclass: operating class
- *
- * Given a value of country, channel and opclass this API will return value of
- * channel width.
- *
- * Return: channel width
- *
- */
-uint16_t cds_reg_dmn_get_chanwidth_from_opclass(uint8_t *country,
-						uint8_t channel,
-						uint8_t opclass)
-{
-	const struct reg_dmn_op_class_map_t *class;
-	uint16_t i;
-
-	if (!qdf_mem_cmp(country, "US", 2))
-		class = us_op_class;
-	else if (!qdf_mem_cmp(country, "EU", 2))
-		class = euro_op_class;
-	else if (!qdf_mem_cmp(country, "JP", 2))
-		class = japan_op_class;
-	else
-		class = global_op_class;
-
-	while (class->op_class) {
-		if (opclass == class->op_class) {
-			for (i = 0;
-			  (i < MAX_CHANNELS_PER_OPERATING_CLASS &&
-			   class->channels[i]);
-			   i++) {
-				if (channel == class->channels[i])
-					return class->ch_spacing;
-			}
-		}
-		class++;
-	}
-
-	return 0;
-}
-
-
-/**
- * cds_reg_dmn_get_opclass_from_channel() - get operating class from channel
- * @country: the complete reg domain
- * @channel: channel number
- * @offset: the value of offset
- *
- * Return: operating class
- */
-uint16_t cds_reg_dmn_get_opclass_from_channel(uint8_t *country, uint8_t channel,
-					      uint8_t offset)
-{
-	const struct reg_dmn_op_class_map_t *class = NULL;
-	uint16_t i = 0;
-
-	if (!qdf_mem_cmp(country, "US", 2)) {
-		class = us_op_class;
-	} else if (!qdf_mem_cmp(country, "EU", 2)) {
-		class = euro_op_class;
-	} else if (!qdf_mem_cmp(country, "JP", 2)) {
-		class = japan_op_class;
-	} else {
-		class = global_op_class;
-	}
-
-	while (class->op_class) {
-		if ((offset == class->offset) || (offset == BWALL)) {
-			for (i = 0;
-			     (i < MAX_CHANNELS_PER_OPERATING_CLASS &&
-			      class->channels[i]); i++) {
-				if (channel == class->channels[i])
-					return class->op_class;
-			}
-		}
-		class++;
-	}
-
-	return 0;
-}
-
-/**
- * cds_reg_dmn_set_curr_opclasses() - set the current operating class
- * @num_classes: number of classes
- * @class: operating class
- *
- * Return: error code
- */
-uint16_t cds_reg_dmn_set_curr_opclasses(uint8_t num_classes, uint8_t *class)
-{
-	uint8_t i;
-
-	if (CDS_MAX_SUPP_OPER_CLASSES < num_classes) {
-		QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
-			  "invalid num classes %d", num_classes);
-		return -1;
-	}
-
-	for (i = 0; i < num_classes; i++) {
-		reg_dmn_curr_supp_opp_classes.classes[i] = class[i];
-	}
-
-	reg_dmn_curr_supp_opp_classes.num_classes = num_classes;
-
-	return 0;
-}
-
-/**
- * cds_reg_dmn_get_curr_opclasses() - get the current operating class
- * @num_classes: number of classes
- * @class: operating class
- *
- * Return: error code
- */
-uint16_t cds_reg_dmn_get_curr_opclasses(uint8_t *num_classes, uint8_t *class)
-{
-	uint8_t i;
-
-	if (!num_classes || !class) {
-		QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
-			  "either num_classes or class is null");
-		return -1;
-	}
-
-	for (i = 0; i < reg_dmn_curr_supp_opp_classes.num_classes; i++)
-		class[i] = reg_dmn_curr_supp_opp_classes.classes[i];
-
-	*num_classes = reg_dmn_curr_supp_opp_classes.num_classes;
-
-	return 0;
-}

+ 1 - 1
core/hdd/inc/wlan_hdd_cfg.h

@@ -9848,7 +9848,7 @@ enum l1ss_sleep_allowed {
 #define CFG_ENABLE_REG_OFFLOAD_NAME      "enable_reg_offload"
 #define CFG_ENABLE_REG_OFFLOAD_MIN       (0)
 #define CFG_ENABLE_REG_OFFLOAD_MAX       (1)
-#define CFG_ENABLE_REG_OFFLOAD_DEFAULT   (0)
+#define CFG_ENABLE_REG_OFFLOAD_DEFAULT   (1)
 
 /*
  * <ini>

+ 1 - 1
core/hdd/inc/wlan_hdd_tdls.h

@@ -454,7 +454,7 @@ typedef struct _hddTdlsPeer_t {
 	uint8_t supported_channels_len;
 	uint8_t supported_channels[SIR_MAC_MAX_SUPP_CHANNELS];
 	uint8_t supported_oper_classes_len;
-	uint8_t supported_oper_classes[CDS_MAX_SUPP_OPER_CLASSES];
+	uint8_t supported_oper_classes[REG_MAX_SUPP_OPER_CLASSES];
 	bool isForcedPeer;
 	uint8_t op_class_for_pref_off_chan;
 	uint8_t pref_off_chan_num;

+ 59 - 44
core/hdd/src/wlan_hdd_cfg80211.c

@@ -74,6 +74,7 @@
 #include "sap_api.h"
 #include "csr_api.h"
 #include "pld_common.h"
+
 #ifdef WLAN_UMAC_CONVERGENCE
 #include "wlan_cfg80211.h"
 #endif
@@ -1200,6 +1201,11 @@ int wlan_hdd_sap_cfg_dfs_override(hdd_adapter_t *adapter)
 	int con_ch;
 	hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
 
+	if (!hdd_ctx) {
+		hdd_err("hdd context is NULL");
+		return 0;
+	}
+
 	/*
 	 * Check if AP+AP case, once primary AP chooses a DFS
 	 * channel secondary AP should always follow primary APs channel
@@ -1216,7 +1222,7 @@ int wlan_hdd_sap_cfg_dfs_override(hdd_adapter_t *adapter)
 	con_sap_config = &con_sap_adapter->sessionCtx.ap.sapConfig;
 	con_ch = con_sap_adapter->sessionCtx.ap.operatingChannel;
 
-	if (!CDS_IS_DFS_CH(con_ch))
+	if (!wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev, con_ch))
 		return 0;
 
 	hdd_debug("Only SCC AP-AP DFS Permitted (ch=%d, con_ch=%d)",
@@ -1280,20 +1286,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 = CDS_CHANNEL_NUM(CHAN_ENUM_1);
-		sap_cfg->acs_cfg.end_ch = CDS_CHANNEL_NUM(CHAN_ENUM_14);
+		sap_cfg->acs_cfg.start_ch = WLAN_REG_CH_NUM(CHAN_ENUM_1);
+		sap_cfg->acs_cfg.end_ch = WLAN_REG_CH_NUM(CHAN_ENUM_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 = CDS_CHANNEL_NUM(CHAN_ENUM_1);
-		sap_cfg->acs_cfg.end_ch = CDS_CHANNEL_NUM(CHAN_ENUM_13);
+		sap_cfg->acs_cfg.start_ch = WLAN_REG_CH_NUM(CHAN_ENUM_1);
+		sap_cfg->acs_cfg.end_ch = WLAN_REG_CH_NUM(CHAN_ENUM_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 = CDS_CHANNEL_NUM(CHAN_ENUM_36);
-		sap_cfg->acs_cfg.end_ch = CDS_CHANNEL_NUM(CHAN_ENUM_165);
+		sap_cfg->acs_cfg.start_ch = WLAN_REG_CH_NUM(CHAN_ENUM_36);
+		sap_cfg->acs_cfg.end_ch = WLAN_REG_CH_NUM(CHAN_ENUM_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 = CDS_CHANNEL_NUM(CHAN_ENUM_1);
-		sap_cfg->acs_cfg.end_ch = CDS_CHANNEL_NUM(CHAN_ENUM_165);
+		sap_cfg->acs_cfg.start_ch = WLAN_REG_CH_NUM(CHAN_ENUM_1);
+		sap_cfg->acs_cfg.end_ch = WLAN_REG_CH_NUM(CHAN_ENUM_165);
 	}
 
 	if (ht_enabled)
@@ -1495,9 +1501,10 @@ static int hdd_update_reg_chan_info(hdd_adapter_t *adapter,
 			bw_offset = 1 << BW_40_OFFSET_BIT;
 		else if (sap_config->acs_cfg.ch_width == CH_WIDTH_20MHZ)
 			bw_offset = 1 << BW_20_OFFSET_BIT;
-		icv->freq = cds_get_channel_freq(chan);
+		icv->freq = wlan_reg_get_channel_freq(hdd_ctx->hdd_pdev, chan);
 		icv->ieee_chan_number = chan;
-		icv->max_reg_power = cds_get_channel_reg_power(chan);
+		icv->max_reg_power = wlan_reg_get_channel_reg_power(
+				hdd_ctx->hdd_pdev, chan);
 
 		/* filling demo values */
 		icv->max_radio_power = HDD_MAX_TX_POWER;
@@ -1509,14 +1516,16 @@ static int hdd_update_reg_chan_info(hdd_adapter_t *adapter,
 					WLAN_HDD_GET_HAL_CTX(adapter),
 					chan, bw_offset);
 
-		if (CDS_IS_CHANNEL_5GHZ(chan)) {
+		if (WLAN_REG_IS_5GHZ_CH(chan)) {
 			ch_params.ch_width = sap_config->acs_cfg.ch_width;
-			cds_set_channel_params(chan, 0, &ch_params);
+			wlan_reg_set_channel_params(hdd_ctx->hdd_pdev, chan,
+					0, &ch_params);
 			icv->vht_center_freq_seg0 = ch_params.center_freq_seg0;
 			icv->vht_center_freq_seg1 = ch_params.center_freq_seg1;
 		}
+
 		icv->flags = 0;
-		icv->flags = cds_get_vendor_reg_flags(chan,
+		icv->flags = cds_get_vendor_reg_flags(hdd_ctx->hdd_pdev, chan,
 				sap_config->acs_cfg.ch_width,
 				sap_config->acs_cfg.is_ht_enabled,
 				sap_config->acs_cfg.is_vht_enabled,
@@ -3148,7 +3157,6 @@ static bool wlan_hdd_check_dfs_channel_for_adapter(hdd_context_t *hdd_ctx,
 
 	qdf_status = hdd_get_front_adapter(hdd_ctx,
 					   &adapter_node);
-
 	while ((NULL != adapter_node) &&
 	       (QDF_STATUS_SUCCESS == qdf_status)) {
 		adapter = adapter_node->pAdapter;
@@ -3165,9 +3173,9 @@ static bool wlan_hdd_check_dfs_channel_for_adapter(hdd_context_t *hdd_ctx,
 			 *  single radio. But then we can have multiple
 			 *  radios !!
 			 */
-			if (CHANNEL_STATE_DFS ==
-			    cds_get_channel_state(
-				    ap_ctx->operatingChannel)) {
+			if (CHANNEL_STATE_DFS == wlan_reg_get_channel_state(
+						hdd_ctx->hdd_pdev,
+						ap_ctx->operatingChannel)) {
 				hdd_err("SAP running on DFS channel");
 				return true;
 			}
@@ -3183,9 +3191,9 @@ static bool wlan_hdd_check_dfs_channel_for_adapter(hdd_context_t *hdd_ctx,
 			 *  do not disable scan on dfs channels
 			 */
 			if (hdd_conn_is_connected(sta_ctx) &&
-			    (CHANNEL_STATE_DFS ==
-			     cds_get_channel_state(
-				     sta_ctx->conn_info.operationChannel))) {
+				(CHANNEL_STATE_DFS ==
+				wlan_reg_get_channel_state(hdd_ctx->hdd_pdev,
+					sta_ctx->conn_info.operationChannel))) {
 				hdd_err("client connected on DFS channel");
 				return true;
 			}
@@ -7381,7 +7389,8 @@ static int wlan_hdd_validate_and_get_pre_cac_ch(hdd_context_t *hdd_ctx,
 			}
 			if (found)
 				continue;
-			if (CDS_IS_DFS_CH(channel_list[i])) {
+			if (wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev,
+						channel_list[i])) {
 				*pre_cac_chan = channel_list[i];
 				break;
 			}
@@ -7396,7 +7405,7 @@ static int wlan_hdd_validate_and_get_pre_cac_ch(hdd_context_t *hdd_ctx,
 		 * the user is expected to take care of this.
 		 */
 		if (!sme_is_channel_valid(hdd_ctx->hHal, channel) ||
-			!CDS_IS_DFS_CH(channel)) {
+			!wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev, channel)) {
 			hdd_err("Invalid channel for pre cac:%d", channel);
 			return -EINVAL;
 		}
@@ -7466,13 +7475,14 @@ int wlan_hdd_request_pre_cac(uint8_t channel)
 		return -EINVAL;
 	}
 
-	if (CDS_IS_DFS_CH(hdd_ap_ctx->operatingChannel)) {
+	if (wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev,
+				hdd_ap_ctx->operatingChannel)) {
 		hdd_err("SAP is already on DFS channel:%d",
 			hdd_ap_ctx->operatingChannel);
 		return -EINVAL;
 	}
 
-	if (!CDS_IS_CHANNEL_24GHZ(hdd_ap_ctx->operatingChannel)) {
+	if (!WLAN_REG_IS_24GHZ_CH(hdd_ap_ctx->operatingChannel)) {
 		hdd_err("pre CAC alllowed only when SAP is in 2.4GHz:%d",
 			hdd_ap_ctx->operatingChannel);
 		return -EINVAL;
@@ -8096,7 +8106,8 @@ __wlan_hdd_cfg80211_sap_configuration_set(struct wiphy *wiphy,
 		ap_ctx->sapConfig.ch_params.ch_width =
 					ap_ctx->sapConfig.ch_width_orig;
 
-		cds_set_channel_params(ap_ctx->sapConfig.channel,
+		wlan_reg_set_channel_params(hdd_ctx->hdd_pdev,
+				ap_ctx->sapConfig.channel,
 				ap_ctx->sapConfig.sec_ch,
 				&ap_ctx->sapConfig.ch_params);
 
@@ -10153,13 +10164,13 @@ hdd_context_t *hdd_cfg80211_wiphy_alloc(int priv_size)
  * This function is called from the supplicant through a
  * private ioctl to change the band value
  */
-int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
+int wlan_hdd_cfg80211_update_band(hdd_context_t *hdd_ctx, struct wiphy *wiphy,
+		eCsrBand eBand)
 {
 	int i, j;
 	enum channel_state channelEnabledState;
 
 	ENTER();
-
 	for (i = 0; i < NUM_NL80211_BANDS; i++) {
 
 		if (NULL == wiphy->bands[i])
@@ -10168,9 +10179,9 @@ int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
 		for (j = 0; j < wiphy->bands[i]->n_channels; j++) {
 			struct ieee80211_supported_band *band = wiphy->bands[i];
 
-			channelEnabledState =
-				cds_get_channel_state(band->channels[j].
-								 hw_value);
+			channelEnabledState = wlan_reg_get_channel_state(
+					hdd_ctx->hdd_pdev,
+					band->channels[j].hw_value);
 
 			if (NL80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) {
 				/* 5G only */
@@ -10840,7 +10851,7 @@ QDF_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,
 	if (hdd_pConfig_ini->sapAllowAllChannel) {
 		/* Validate the channel */
 		for (count = CHAN_ENUM_1; count <= CHAN_ENUM_165; count++) {
-			if (channel == CDS_CHANNEL_NUM(count)) {
+			if (channel == WLAN_REG_CH_NUM(count)) {
 				fValidChannel = true;
 				break;
 			}
@@ -12766,13 +12777,14 @@ void hdd_select_cbmode(hdd_adapter_t *pAdapter, uint8_t operationChannel,
 	hdd_station_ctx_t *station_ctx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
 	struct hdd_mon_set_ch_info *ch_info = &station_ctx->ch_info;
 	uint8_t sec_ch = 0;
+	hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
 
 	/*
 	 * CDS api expects secondary channel for calculating
 	 * the channel params
 	 */
 	if ((ch_params->ch_width == CH_WIDTH_40MHZ) &&
-	    (CDS_IS_CHANNEL_24GHZ(operationChannel))) {
+	    (WLAN_REG_IS_24GHZ_CH(operationChannel))) {
 		if (operationChannel >= 1 && operationChannel <= 5)
 			sec_ch = operationChannel + 4;
 		else if (operationChannel >= 6 && operationChannel <= 13)
@@ -12780,7 +12792,8 @@ void hdd_select_cbmode(hdd_adapter_t *pAdapter, uint8_t operationChannel,
 	}
 
 	/* This call decides required channel bonding mode */
-	cds_set_channel_params(operationChannel, sec_ch, ch_params);
+	wlan_reg_set_channel_params(hdd_ctx->hdd_pdev, operationChannel,
+			sec_ch, ch_params);
 
 	if (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam()) {
 		enum hdd_dot11_mode hdd_dot11_mode;
@@ -12879,8 +12892,9 @@ static bool wlan_hdd_handle_sap_sta_dfs_conc(hdd_adapter_t *adapter,
 	}
 
 	/* sap is on non-dfs channel, nothing to handle */
-	if (!CDS_IS_DFS_CH(hdd_ap_ctx->operatingChannel)) {
-		hdd_debug("sap is on non-dfs channel, sta is allowed");
+	if (!wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev,
+				hdd_ap_ctx->operatingChannel)) {
+		hdd_info("sap is on non-dfs channel, sta is allowed");
 		return true;
 	}
 	/*
@@ -12894,8 +12908,8 @@ static bool wlan_hdd_handle_sap_sta_dfs_conc(hdd_adapter_t *adapter,
 	 * If the STA's channel is 2.4 GHz, then set pcl with only 2.4 GHz
 	 * channels for roaming case.
 	 */
-	if (CDS_IS_CHANNEL_24GHZ(channel)) {
-		hdd_debug("sap is on dfs, new sta conn on 2.4 is allowed");
+	if (WLAN_REG_IS_24GHZ_CH(channel)) {
+		hdd_info("sap is on dfs, new sta conn on 2.4 is allowed");
 		return true;
 	}
 
@@ -12905,7 +12919,7 @@ static bool wlan_hdd_handle_sap_sta_dfs_conc(hdd_adapter_t *adapter,
 	 * to STA's channel to make scc, so we have room for 3port MCC
 	 * scenario.
 	 */
-	if ((0 == channel) || CDS_IS_DFS_CH(channel))
+	if ((0 == channel) || wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev, channel))
 		channel = policy_mgr_get_nondfs_preferred_channel(
 			hdd_ctx->hdd_psoc, PM_SAP_MODE, true);
 
@@ -13186,7 +13200,7 @@ static int wlan_hdd_cfg80211_connect_start(hdd_adapter_t *pAdapter,
 			 * In IBSS mode while operating in 2.4 GHz,
 			 * the device supports only 20 MHz.
 			 */
-			if (CDS_IS_CHANNEL_24GHZ(operatingChannel))
+			if (WLAN_REG_IS_24GHZ_CH(operatingChannel))
 				pRoamProfile->ch_params.ch_width =
 					CH_WIDTH_20MHZ;
 			hdd_select_cbmode(pAdapter, operatingChannel,
@@ -16650,13 +16664,14 @@ static int __wlan_hdd_cfg80211_set_mon_ch(struct wiphy *wiphy,
 	 * the channel params
 	 */
 	if ((ch_params.ch_width == CH_WIDTH_40MHZ) &&
-	    (CDS_IS_CHANNEL_24GHZ(chan_num))) {
+	    (WLAN_REG_IS_24GHZ_CH(chan_num))) {
 		if (chan_num >= 1 && chan_num <= 5)
 			sec_ch = chan_num + 4;
 		else if (chan_num >= 6 && chan_num <= 13)
 			sec_ch = chan_num - 4;
 	}
-	cds_set_channel_params(chan_num, sec_ch, &ch_params);
+	wlan_reg_set_channel_params(hdd_ctx->hdd_pdev, chan_num,
+			sec_ch, &ch_params);
 	status = sme_roam_channel_change_req(hal_hdl, bssid, &ch_params,
 						 &roam_profile);
 	if (status) {
@@ -16855,8 +16870,8 @@ void wlan_hdd_init_chan_info(hdd_context_t *hdd_ctx)
 
 	num_5g = QDF_ARRAY_SIZE(hdd_channels_5_ghz);
 	for (; (index - num_2g) < num_5g; index++) {
-		if (cds_is_dsrc_channel(
-			hdd_channels_5_ghz[index - num_2g].center_freq))
+		if (WLAN_REG_IS_11P_CH(
+			    hdd_channels_5_ghz[index - num_2g].hw_value))
 			continue;
 		hdd_ctx->chan_info[index].freq =
 			hdd_channels_5_ghz[index - num_2g].center_freq;

+ 1 - 1
core/hdd/src/wlan_hdd_cfg80211.h

@@ -351,7 +351,7 @@ int wlan_hdd_disable_dfs_chan_scan(hdd_context_t *hdd_ctx,
 				   hdd_adapter_t *adapter,
 				   uint32_t no_dfs_flag);
 
-int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy,
+int wlan_hdd_cfg80211_update_band(hdd_context_t *hdd_ctx, struct wiphy *wiphy,
 				  eCsrBand eBand);
 
 /**

+ 26 - 27
core/hdd/src/wlan_hdd_conc_ut.c

@@ -38,7 +38,6 @@
 #include "qdf_types.h"
 #include "qdf_trace.h"
 #include "cds_utils.h"
-#include "cds_reg_service.h"
 #include "wma_types.h"
 #include "wma.h"
 #include "wma_api.h"
@@ -269,7 +268,7 @@ static bool wlan_hdd_validate_pcl(hdd_context_t *hdd_ctx,
 		break;
 	case PM_5G:
 		for (first_idx = 0; first_idx < pcl_len; first_idx++) {
-			if (!CDS_IS_CHANNEL_5GHZ(pcl[first_idx])) {
+			if (!WLAN_REG_IS_5GHZ_CH(pcl[first_idx])) {
 				snprintf(reason, reason_length,
 					"2G channel found");
 				return false;
@@ -278,7 +277,7 @@ static bool wlan_hdd_validate_pcl(hdd_context_t *hdd_ctx,
 		break;
 	case PM_24G:
 		for (first_idx = 0; first_idx < pcl_len; first_idx++) {
-			if (!CDS_IS_CHANNEL_24GHZ(pcl[first_idx])) {
+			if (!WLAN_REG_IS_24GHZ_CH(pcl[first_idx])) {
 				snprintf(reason, reason_length,
 					"5G channel found");
 				return false;
@@ -326,7 +325,7 @@ static bool wlan_hdd_validate_pcl(hdd_context_t *hdd_ctx,
 				"No SCC found");
 			return false;
 		}
-		if (!CDS_IS_CHANNEL_24GHZ(pcl[pcl_len-1])) {
+		if (!WLAN_REG_IS_24GHZ_CH(pcl[pcl_len - 1])) {
 			snprintf(reason, reason_length,
 				"No 2.4Ghz chnl");
 			return false;
@@ -344,14 +343,14 @@ static bool wlan_hdd_validate_pcl(hdd_context_t *hdd_ctx,
 				"No SCC found");
 			return false;
 		}
-		if (!CDS_IS_CHANNEL_5GHZ(pcl[pcl_len-1])) {
+		if (!WLAN_REG_IS_5GHZ_CH(pcl[pcl_len - 1])) {
 			snprintf(reason, reason_length,
 				"No 5Ghz chnl");
 			return false;
 		}
 		break;
 	case PM_24G_SCC_CH:
-		if (!CDS_IS_CHANNEL_24GHZ(pcl[0])) {
+		if (!WLAN_REG_IS_24GHZ_CH(pcl[0])) {
 			snprintf(reason, reason_length,
 				"No 2.4Ghz chnl");
 			return false;
@@ -369,7 +368,7 @@ static bool wlan_hdd_validate_pcl(hdd_context_t *hdd_ctx,
 		}
 		break;
 	case PM_5G_SCC_CH:
-		if (!CDS_IS_CHANNEL_5GHZ(pcl[0])) {
+		if (!WLAN_REG_IS_5GHZ_CH(pcl[0])) {
 			snprintf(reason, reason_length,
 				"No 5Ghz chnl");
 			return false;
@@ -401,7 +400,7 @@ static bool wlan_hdd_validate_pcl(hdd_context_t *hdd_ctx,
 				"MCC invalid");
 			return false;
 		}
-		if (!CDS_IS_CHANNEL_24GHZ(pcl[pcl_len-1])) {
+		if (!WLAN_REG_IS_24GHZ_CH(pcl[pcl_len - 1])) {
 			snprintf(reason, reason_length,
 				"No 24Ghz chnl");
 			return false;
@@ -422,14 +421,14 @@ static bool wlan_hdd_validate_pcl(hdd_context_t *hdd_ctx,
 				"MCC invalid");
 			return false;
 		}
-		if (!CDS_IS_CHANNEL_5GHZ(pcl[pcl_len-1])) {
+		if (!WLAN_REG_IS_5GHZ_CH(pcl[pcl_len - 1])) {
 			snprintf(reason, reason_length,
 				"No 5Ghz chnl");
 			return false;
 		}
 		break;
 	case PM_24G_MCC_CH:
-		if (!CDS_IS_CHANNEL_24GHZ(pcl[0])) {
+		if (!WLAN_REG_IS_24GHZ_CH(pcl[0])) {
 			snprintf(reason, reason_length,
 				"No 24Ghz chnl");
 			return false;
@@ -450,7 +449,7 @@ static bool wlan_hdd_validate_pcl(hdd_context_t *hdd_ctx,
 		}
 		break;
 	case PM_5G_MCC_CH:
-		if (!CDS_IS_CHANNEL_5GHZ(pcl[0])) {
+		if (!WLAN_REG_IS_5GHZ_CH(pcl[0])) {
 			snprintf(reason, reason_length,
 				"No 5Ghz chnl");
 			return false;
@@ -471,98 +470,98 @@ static bool wlan_hdd_validate_pcl(hdd_context_t *hdd_ctx,
 		}
 		break;
 	case PM_SCC_ON_5_SCC_ON_24_24G:
-		if (!CDS_IS_CHANNEL_5GHZ(pcl[0]) ||
+		if (!WLAN_REG_IS_5GHZ_CH(pcl[0]) ||
 			(pcl[0] != first_connection_chnl &&
 			 pcl[0] != second_connection_chnl)) {
 			snprintf(reason, reason_length,
 				"No 5Ghz chnl/scc");
 			return false;
 		}
-		if (!CDS_IS_CHANNEL_24GHZ(pcl[1]) ||
+		if (!WLAN_REG_IS_24GHZ_CH(pcl[1]) ||
 			(pcl[1] != first_connection_chnl &&
 			 pcl[1] != second_connection_chnl)) {
 			snprintf(reason, reason_length,
 				"No 24Ghz chnl/scc");
 			return false;
 		}
-		if (!CDS_IS_CHANNEL_24GHZ(pcl[pcl_len-1])) {
+		if (!WLAN_REG_IS_24GHZ_CH(pcl[pcl_len - 1])) {
 			snprintf(reason, reason_length,
 				"No 24Ghz chnls");
 			return false;
 		}
 		break;
 	case PM_SCC_ON_5_SCC_ON_24_5G:
-		if (!CDS_IS_CHANNEL_5GHZ(pcl[0]) ||
+		if (!WLAN_REG_IS_5GHZ_CH(pcl[0]) ||
 			(pcl[0] != first_connection_chnl &&
 			 pcl[0] != second_connection_chnl)) {
 			snprintf(reason, reason_length,
 				"No 5Ghz chnl/scc");
 			return false;
 		}
-		if (!CDS_IS_CHANNEL_24GHZ(pcl[1]) ||
+		if (!WLAN_REG_IS_24GHZ_CH(pcl[1]) ||
 			(pcl[1] != first_connection_chnl &&
 			 pcl[1] != second_connection_chnl)) {
 			snprintf(reason, reason_length,
 				"No 24Ghz chnl/scc");
 			return false;
 		}
-		if (!CDS_IS_CHANNEL_5GHZ(pcl[pcl_len-1])) {
+		if (!WLAN_REG_IS_5GHZ_CH(pcl[pcl_len - 1])) {
 			snprintf(reason, reason_length,
 				"No 5Ghz chnls");
 			return false;
 		}
 		break;
 	case PM_SCC_ON_24_SCC_ON_5_24G:
-		if (!CDS_IS_CHANNEL_24GHZ(pcl[0]) ||
+		if (!WLAN_REG_IS_24GHZ_CH(pcl[0]) ||
 			(pcl[0] != first_connection_chnl &&
 			 pcl[0] != second_connection_chnl)) {
 			snprintf(reason, reason_length,
 				"No 24Ghz chnl/scc");
 			return false;
 		}
-		if (!CDS_IS_CHANNEL_5GHZ(pcl[1]) ||
+		if (!WLAN_REG_IS_5GHZ_CH(pcl[1]) ||
 			(pcl[1] != first_connection_chnl &&
 			 pcl[1] != second_connection_chnl)) {
 			snprintf(reason, reason_length,
 				"No 5Ghz chnl/scc");
 			return false;
 		}
-		if (!CDS_IS_CHANNEL_24GHZ(pcl[pcl_len-1])) {
+		if (!WLAN_REG_IS_24GHZ_CH(pcl[pcl_len - 1])) {
 			snprintf(reason, reason_length,
 				"No 24Ghz chnls");
 			return false;
 		}
 		break;
 	case PM_SCC_ON_24_SCC_ON_5_5G:
-		if (!CDS_IS_CHANNEL_24GHZ(pcl[0]) ||
+		if (!WLAN_REG_IS_24GHZ_CH(pcl[0]) ||
 			(pcl[0] != first_connection_chnl &&
 			 pcl[0] != second_connection_chnl)) {
 			snprintf(reason, reason_length,
 				"No 24Ghz chnl/scc");
 			return false;
 		}
-		if (!CDS_IS_CHANNEL_5GHZ(pcl[1]) ||
+		if (!WLAN_REG_IS_5GHZ_CH(pcl[1]) ||
 			(pcl[1] != first_connection_chnl &&
 			 pcl[1] != second_connection_chnl)) {
 			snprintf(reason, reason_length,
 				"No 5Ghz chnl/scc");
 			return false;
 		}
-		if (!CDS_IS_CHANNEL_5GHZ(pcl[pcl_len-1])) {
+		if (!WLAN_REG_IS_5GHZ_CH(pcl[pcl_len - 1])) {
 			snprintf(reason, reason_length,
 				"No 5Ghz chnls");
 			return false;
 		}
 		break;
 	case PM_SCC_ON_5_SCC_ON_24:
-		if (!CDS_IS_CHANNEL_5GHZ(pcl[0]) ||
+		if (!WLAN_REG_IS_5GHZ_CH(pcl[0]) ||
 			(pcl[0] != first_connection_chnl &&
 			 pcl[0] != second_connection_chnl)) {
 			snprintf(reason, reason_length,
 				"No 5Ghz chnl/scc");
 			return false;
 		}
-		if (!CDS_IS_CHANNEL_24GHZ(pcl[1]) ||
+		if (!WLAN_REG_IS_24GHZ_CH(pcl[1]) ||
 			(pcl[1] != first_connection_chnl &&
 			 pcl[1] != second_connection_chnl)) {
 			snprintf(reason, reason_length,
@@ -576,14 +575,14 @@ static bool wlan_hdd_validate_pcl(hdd_context_t *hdd_ctx,
 		}
 		break;
 	case PM_SCC_ON_24_SCC_ON_5:
-		if (!CDS_IS_CHANNEL_24GHZ(pcl[0]) ||
+		if (!WLAN_REG_IS_24GHZ_CH(pcl[0]) ||
 			(pcl[0] != first_connection_chnl &&
 			 pcl[0] != second_connection_chnl)) {
 			snprintf(reason, reason_length,
 				"No 24Ghz chnl/scc");
 			return false;
 		}
-		if (!CDS_IS_CHANNEL_5GHZ(pcl[1]) ||
+		if (!WLAN_REG_IS_5GHZ_CH(pcl[1]) ||
 			(pcl[1] != first_connection_chnl &&
 			 pcl[1] != second_connection_chnl)) {
 			snprintf(reason, reason_length,

+ 25 - 16
core/hdd/src/wlan_hdd_ext_scan.c

@@ -2309,25 +2309,27 @@ int wlan_hdd_cfg80211_extscan_set_significant_change(struct wiphy *wiphy,
 
 /**
  * hdd_remove_dsrc_channels () - remove dsrc chanels
+ * @hdd_ctx: hdd context
  * @wiphy: Pointer to wireless phy
  * @chan_list: channel list
  * @num_channels: number of channels
  *
  * Return: none
  */
-static void hdd_remove_dsrc_channels(struct wiphy *wiphy, uint32_t *chan_list,
+static void hdd_remove_dsrc_channels(hdd_context_t *hdd_ctx,
+				     struct wiphy *wiphy, uint32_t *chan_list,
 				     uint8_t *num_channels)
 {
 	uint8_t num_chan_temp = 0;
 	int i;
 
 	for (i = 0; i < *num_channels; i++) {
-		if (!cds_is_dsrc_channel(chan_list[i])) {
+		if (!WLAN_REG_IS_11P_CH(wlan_reg_freq_to_chan(hdd_ctx->hdd_pdev,
+							      chan_list[i]))) {
 			chan_list[num_chan_temp] = chan_list[i];
 			num_chan_temp++;
 		}
 	}
-
 	*num_channels = num_chan_temp;
 }
 
@@ -2461,8 +2463,7 @@ __wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
 
 	num_channels = QDF_MIN(num_channels, maxChannels);
 
-	hdd_remove_dsrc_channels(wiphy, chan_list, &num_channels);
-
+	hdd_remove_dsrc_channels(pHddCtx, wiphy, chan_list, &num_channels);
 	if ((QDF_SAP_MODE == pAdapter->device_mode) ||
 	    !strncmp(hdd_get_fwpath(), "ap", 2))
 		hdd_remove_passive_channels(wiphy, chan_list,
@@ -2776,8 +2777,10 @@ static int hdd_extscan_start_fill_bucket_channel_spec(
 							chan_list[j];
 				req_msg->buckets[bkt_index].channels[j].
 							chnlClass = 0;
-				if (CDS_IS_PASSIVE_OR_DISABLE_CH(
-					cds_freq_to_chan(chan_list[j]))) {
+				if ((wlan_reg_get_channel_state(
+					hdd_ctx->hdd_pdev,
+					cds_freq_to_chan(chan_list[j]))) !=
+						CHANNEL_STATE_ENABLE) {
 					req_msg->buckets[bkt_index].channels[j].
 								passive = 1;
 					req_msg->buckets[bkt_index].channels[j].
@@ -2914,9 +2917,12 @@ static int hdd_extscan_start_fill_bucket_channel_spec(
 				hdd_debug("WiFi band is unspecified, dwellTime:%d",
 						req_msg->buckets[bkt_index].channels[j].dwellTimeMs);
 
-				if (CDS_IS_PASSIVE_OR_DISABLE_CH(
+				if ((wlan_reg_get_channel_state(
+					hdd_ctx->hdd_pdev,
 					cds_freq_to_chan(
-						req_msg->buckets[bkt_index].channels[j].channel))) {
+					req_msg->buckets[bkt_index].
+					channels[j].channel)))
+						!= CHANNEL_STATE_ENABLE) {
 					req_msg->buckets[bkt_index].channels[j].dwellTimeMs =
 						hdd_ctx->config->extscan_passive_max_chn_time;
 				} else {
@@ -2928,9 +2934,11 @@ static int hdd_extscan_start_fill_bucket_channel_spec(
 			hdd_debug("New Dwell time %u ms",
 				req_msg->buckets[bkt_index].channels[j].dwellTimeMs);
 
-			if (CDS_IS_PASSIVE_OR_DISABLE_CH(
-						cds_freq_to_chan(
-						req_msg->buckets[bkt_index].channels[j].channel))) {
+			if ((wlan_reg_get_channel_state(hdd_ctx->hdd_pdev,
+					cds_freq_to_chan(
+					req_msg->buckets[bkt_index].
+					channels[j].channel)))
+					!= CHANNEL_STATE_ENABLE) {
 				if (min_dwell_time_passive_bucket >
 						req_msg->buckets[bkt_index].channels[j].dwellTimeMs) {
 					min_dwell_time_passive_bucket =
@@ -2966,9 +2974,11 @@ static int hdd_extscan_start_fill_bucket_channel_spec(
 			hdd_debug("Chnl spec passive %u",
 				req_msg->buckets[bkt_index].channels[j].passive);
 			/* Override scan type if required */
-			if (CDS_IS_PASSIVE_OR_DISABLE_CH(
-				cds_freq_to_chan(
-					req_msg->buckets[bkt_index].channels[j].channel))) {
+			if ((wlan_reg_get_channel_state(hdd_ctx->hdd_pdev,
+					cds_freq_to_chan(
+					req_msg->buckets[bkt_index].
+					channels[j].channel)))
+					!= CHANNEL_STATE_ENABLE) {
 				req_msg->buckets[bkt_index].channels[j].passive = true;
 			} else {
 				req_msg->buckets[bkt_index].channels[j].passive = false;
@@ -3000,7 +3010,6 @@ static int hdd_extscan_start_fill_bucket_channel_spec(
 				req_msg->max_dwell_time_active,
 				req_msg->min_dwell_time_passive,
 				req_msg->max_dwell_time_passive);
-
 	return 0;
 }
 

+ 41 - 27
core/hdd/src/wlan_hdd_hostapd.c

@@ -82,7 +82,6 @@
 #include <qca_vendor.h>
 #include <cds_api.h>
 #include <cdp_txrx_stats.h>
-
 #include "wlan_hdd_he.h"
 
 #define    IS_UP(_dev) \
@@ -154,7 +153,8 @@ static void hdd_hostapd_channel_allow_suspend(hdd_adapter_t *pAdapter,
 	if (pHostapdState->bssState == BSS_STOP)
 		return;
 
-	if (CHANNEL_STATE_DFS != cds_get_channel_state(channel))
+	if (CHANNEL_STATE_DFS != wlan_reg_get_channel_state(pHddCtx->hdd_pdev,
+				channel))
 		return;
 
 	/* Release wakelock when no more DFS channels are used */
@@ -192,7 +192,8 @@ static void hdd_hostapd_channel_prevent_suspend(hdd_adapter_t *pAdapter,
 		(atomic_read(&pHddCtx->sap_dfs_ref_cnt) >= 1))
 		return;
 
-	if (CHANNEL_STATE_DFS != cds_get_channel_state(channel))
+	if (CHANNEL_STATE_DFS != wlan_reg_get_channel_state(pHddCtx->hdd_pdev,
+				channel))
 		return;
 
 	/* Acquire wakelock if we have at least one DFS channel in use */
@@ -1246,7 +1247,8 @@ QDF_STATUS hdd_hostapd_sap_event_cb(tpSap_Event pSapEvent,
 
 		/* DFS requirement: DO NOT transmit during CAC. */
 		if ((CHANNEL_STATE_DFS !=
-			cds_get_channel_state(pHddApCtx->operatingChannel))
+			wlan_reg_get_channel_state(pHddCtx->hdd_pdev,
+				pHddApCtx->operatingChannel))
 			|| ignoreCAC
 			|| pHddCtx->dev_dfs_cac_status == DFS_CAC_ALREADY_DONE)
 			pHddApCtx->dfs_cac_block_tx = false;
@@ -1257,8 +1259,9 @@ QDF_STATUS hdd_hostapd_sap_event_cb(tpSap_Event pSapEvent,
 				pHddApCtx->dfs_cac_block_tx, pHddApCtx,
 				pHostapdAdapter->sessionId);
 
-		if ((CHANNEL_STATE_DFS ==
-		     cds_get_channel_state(pHddApCtx->operatingChannel))
+		if ((CHANNEL_STATE_DFS == wlan_reg_get_channel_state(
+						pHddCtx->hdd_pdev,
+						pHddApCtx->operatingChannel))
 		    && (pHddCtx->config->IsSapDfsChSifsBurstEnabled == 0)) {
 
 			hdd_debug("Set SIFS Burst disable for DFS channel %d",
@@ -2382,6 +2385,7 @@ QDF_STATUS wlan_hdd_get_channel_for_sap_restart(
 	tHalHandle *hal_handle;
 	hdd_ap_ctx_t *hdd_ap_ctx;
 	uint16_t intf_ch = 0;
+	hdd_context_t *hdd_ctx;
 
 	hdd_adapter_t *ap_adapter = wlan_hdd_get_adapter_from_vdev(
 					psoc, vdev_id);
@@ -2411,6 +2415,7 @@ QDF_STATUS wlan_hdd_get_channel_for_sap_restart(
 		return QDF_STATUS_E_FAILURE;
 	}
 
+	hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter);
 	hdd_info("SAP restart orig chan: %d, new chan: %d",
 		 hdd_ap_ctx->sapConfig.channel, intf_ch);
 	hdd_ap_ctx->sapConfig.channel = intf_ch;
@@ -2418,9 +2423,10 @@ QDF_STATUS wlan_hdd_get_channel_for_sap_restart(
 		hdd_ap_ctx->sapConfig.ch_width_orig;
 	hdd_ap_ctx->bss_stop_reason = BSS_STOP_DUE_TO_MCC_SCC_SWITCH;
 
-	cds_set_channel_params(hdd_ap_ctx->sapConfig.channel,
-			       hdd_ap_ctx->sapConfig.sec_ch,
-			       &hdd_ap_ctx->sapConfig.ch_params);
+	wlan_reg_set_channel_params(hdd_ctx->hdd_pdev,
+			hdd_ap_ctx->sapConfig.channel,
+			hdd_ap_ctx->sapConfig.sec_ch,
+			&hdd_ap_ctx->sapConfig.ch_params);
 	*channel = hdd_ap_ctx->sapConfig.channel;
 	*sec_ch = hdd_ap_ctx->sapConfig.sec_ch;
 
@@ -3223,7 +3229,7 @@ static __iw_softap_setparam(struct net_device *dev,
 		int32_t dfs_radar_found;
 
 		isDfsch = (CHANNEL_STATE_DFS ==
-			   cds_get_channel_state(ch));
+			   wlan_reg_get_channel_state(pHddCtx->hdd_pdev, ch));
 
 		hdd_debug("Set QCASAP_SET_RADAR_CMD val %d", set_value);
 
@@ -4295,6 +4301,7 @@ static int __iw_get_channel_list(struct net_device *dev,
 		band_start_channel = CHAN_ENUM_36;
 		band_end_channel = CHAN_ENUM_184;
 	}
+
 	if (cur_band != eCSR_BAND_24) {
 		if (hdd_ctx->config->dot11p_mode)
 			band_end_channel = CHAN_ENUM_184;
@@ -4315,11 +4322,13 @@ static int __iw_get_channel_list(struct net_device *dev,
 			is_dfs_mode_enabled);
 
 	for (i = band_start_channel; i <= band_end_channel; i++) {
-		if ((CHANNEL_STATE_ENABLE == CDS_CHANNEL_STATE(i)) ||
+		if ((CHANNEL_STATE_ENABLE ==
+			wlan_reg_get_channel_state(hdd_ctx->hdd_pdev, i)) ||
 			(is_dfs_mode_enabled &&
-		     CHANNEL_STATE_DFS == CDS_CHANNEL_STATE(i))) {
+		     CHANNEL_STATE_DFS ==
+		     wlan_reg_get_channel_state(hdd_ctx->hdd_pdev, i))) {
 			channel_list->channels[num_channels] =
-				CDS_CHANNEL_NUM(i);
+				WLAN_REG_CH_NUM(i);
 			num_channels++;
 		}
 	}
@@ -7135,11 +7144,11 @@ QDF_STATUS wlan_hdd_config_acs(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter)
 			cur_sap_st_ch = sap_config->acs_cfg.start_ch;
 			cur_sap_end_ch = sap_config->acs_cfg.end_ch;
 
-			wlansap_extend_to_acs_range(
-					&cur_sap_st_ch, &cur_sap_end_ch,
-					&bandStartChannel, &bandEndChannel);
+			wlansap_extend_to_acs_range(hal, &cur_sap_st_ch,
+					&cur_sap_end_ch, &bandStartChannel,
+					&bandEndChannel);
 
-			wlansap_extend_to_acs_range(
+			wlansap_extend_to_acs_range(hal,
 					&con_sap_st_ch, &con_sap_end_ch,
 					&bandStartChannel, &bandEndChannel);
 
@@ -7269,7 +7278,7 @@ static int wlan_hdd_setup_driver_overrides(hdd_adapter_t *ap_adapter)
 				eHT_CHANNEL_WIDTH_20MHZ;
 	}
 	sap_cfg->ch_params.ch_width = sap_cfg->ch_width_orig;
-	cds_set_channel_params(sap_cfg->channel,
+	wlan_reg_set_channel_params(hdd_ctx->hdd_pdev, sap_cfg->channel,
 				sap_cfg->sec_ch, &sap_cfg->ch_params);
 
 	return 0;
@@ -7479,7 +7488,8 @@ int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
 			goto error;
 		} else {
 			if (ret == 0) {
-				if (CDS_IS_DFS_CH(pConfig->channel))
+				if (wlan_reg_is_dfs_ch(pHddCtx->hdd_pdev,
+							pConfig->channel))
 					pHddCtx->dev_dfs_cac_status =
 							DFS_CAC_NEVER_DONE;
 			}
@@ -7500,8 +7510,9 @@ int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
 
 			/* reject SAP if DFS channel scan is not allowed */
 			if (!(pHddCtx->config->enableDFSChnlScan) &&
-				(CHANNEL_STATE_DFS == cds_get_channel_state(
-					pConfig->channel))) {
+				(CHANNEL_STATE_DFS ==
+				 wlan_reg_get_channel_state(pHddCtx->hdd_pdev,
+					 pConfig->channel))) {
 				hdd_err("No SAP start on DFS channel");
 				ret = -EOPNOTSUPP;
 				goto error;
@@ -8315,7 +8326,8 @@ static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
 			hdd_err("Can't start SAP-ACS (channel=0) with sub 20 MHz ch width");
 			return -EINVAL;
 		}
-		if (CHANNEL_STATE_DFS == cds_get_channel_state(channel)) {
+		if (CHANNEL_STATE_DFS == wlan_reg_get_channel_state(
+					pHddCtx->hdd_pdev, channel)) {
 			hdd_err("Can't start SAP-DFS (channel=%d)with sub 20 MHz ch wd",
 				channel);
 			return -EINVAL;
@@ -8328,12 +8340,14 @@ static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
 			sub_20_ch_width = CH_WIDTH_5MHZ;
 		if (cds_is_10_mhz_enabled())
 			sub_20_ch_width = CH_WIDTH_10MHZ;
-		if (CDS_IS_CHANNEL_5GHZ(channel))
-			ch_state = cds_get_5g_bonded_channel_state(channel,
-							  sub_20_ch_width);
+		if (WLAN_REG_IS_5GHZ_CH(channel))
+			ch_state = wlan_reg_get_5g_bonded_channel_state(
+					pHddCtx->hdd_pdev, channel,
+					sub_20_ch_width);
 		else
-			ch_state = cds_get_2g_bonded_channel_state(channel,
-							  sub_20_ch_width, 0);
+			ch_state = wlan_reg_get_2g_bonded_channel_state(
+					pHddCtx->hdd_pdev, channel,
+					sub_20_ch_width, 0);
 		if (CHANNEL_STATE_DISABLE == ch_state) {
 			hdd_err("Given ch width not supported by reg domain");
 			return -EINVAL;

+ 1 - 1
core/hdd/src/wlan_hdd_ioctl.c

@@ -5959,7 +5959,7 @@ static int drv_cmd_tdls_off_channel(hdd_adapter_t *adapter,
 	if (ret != 1)
 		return -EINVAL;
 
-	if (CDS_IS_DFS_CH(set_value)) {
+	if (wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev, set_value)) {
 		hdd_err("DFS channel %d is passed for hdd_set_tdls_offchannel",
 		    set_value);
 		return -EINVAL;

+ 25 - 23
core/hdd/src/wlan_hdd_main.c

@@ -347,13 +347,13 @@ int hdd_validate_channel_and_bandwidth(hdd_adapter_t *adapter,
 		return -EOPNOTSUPP;
 	}
 
-	if ((!CDS_IS_CHANNEL_24GHZ(chan_number)) &&
-			(!CDS_IS_CHANNEL_5GHZ(chan_number))) {
+	if ((!WLAN_REG_IS_24GHZ_CH(chan_number)) &&
+			(!WLAN_REG_IS_5GHZ_CH(chan_number))) {
 		hdd_err("CH %d is not in 2.4GHz or 5GHz", chan_number);
 		return -EINVAL;
 	}
 
-	if (CDS_IS_CHANNEL_24GHZ(chan_number)) {
+	if (WLAN_REG_IS_24GHZ_CH(chan_number)) {
 		if (chan_bw == CH_WIDTH_80MHZ) {
 			hdd_err("BW80 not possible in 2.4GHz band");
 			return -EINVAL;
@@ -365,7 +365,7 @@ int hdd_validate_channel_and_bandwidth(hdd_adapter_t *adapter,
 		}
 	}
 
-	if (CDS_IS_CHANNEL_5GHZ(chan_number)) {
+	if (WLAN_REG_IS_5GHZ_CH(chan_number)) {
 		if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 165) &&
 				(chan_bw != CH_WIDTH_MAX)) {
 			hdd_err("Only BW20 possible on channel 165");
@@ -1403,6 +1403,7 @@ void hdd_update_tgt_cfg(void *context, void *param)
 			QDF_BUG(0);
 		}
 	}
+
 	if (cds_cfg) {
 		if (hdd_ctx->config->enable_sub_20_channel_width !=
 			WLAN_SUB_20_CH_WIDTH_NONE && !cfg->sub_20_support) {
@@ -1562,7 +1563,8 @@ bool hdd_dfs_indicate_radar(void *context, void *param)
 			if ((QDF_SAP_MODE == adapter->device_mode ||
 			     QDF_P2P_GO_MODE == adapter->device_mode) &&
 			     (CHANNEL_STATE_DFS ==
-			     cds_get_channel_state(ap_ctx->operatingChannel))) {
+			     wlan_reg_get_channel_state(hdd_ctx->hdd_pdev,
+				     ap_ctx->operatingChannel))) {
 				WLAN_HDD_GET_AP_CTX_PTR(adapter)->
 				dfs_cac_block_tx = true;
 				hdd_debug("tx blocked for session:%d",
@@ -6662,7 +6664,8 @@ void hdd_switch_sap_channel(hdd_adapter_t *adapter, uint8_t channel)
 	hdd_debug("chan:%d width:%d",
 		channel, hdd_ap_ctx->sapConfig.ch_width_orig);
 
-	cds_set_channel_params(hdd_ap_ctx->sapConfig.channel,
+	wlan_reg_set_channel_params(hdd_ctx->hdd_pdev,
+			hdd_ap_ctx->sapConfig.channel,
 			hdd_ap_ctx->sapConfig.sec_ch,
 			&hdd_ap_ctx->sapConfig.ch_params);
 
@@ -6859,23 +6862,23 @@ void hdd_ch_avoid_cb(void *hdd_context, void *indi_param)
 			continue;
 
 		for (channel_loop = CHAN_ENUM_1; channel_loop <=
-					CHAN_ENUM_184; channel_loop++) {
-			if (CDS_CHANNEL_FREQ(channel_loop) >=
-						ch_avoid_indi->avoid_freq_range[
-						range_loop].start_freq) {
+			     CHAN_ENUM_184; channel_loop++) {
+			if (WLAN_REG_CH_TO_FREQ(channel_loop) >=
+			    ch_avoid_indi->avoid_freq_range[
+				    range_loop].start_freq) {
 				start_channel_idx = channel_loop;
 				break;
 			}
 		}
 		for (channel_loop = CHAN_ENUM_1; channel_loop <=
-					CHAN_ENUM_184; channel_loop++) {
-			if (CDS_CHANNEL_FREQ(channel_loop) >=
-						ch_avoid_indi->avoid_freq_range[
-						range_loop].end_freq) {
+			     CHAN_ENUM_184; channel_loop++) {
+			if (WLAN_REG_CH_TO_FREQ(channel_loop) >=
+			    ch_avoid_indi->avoid_freq_range[
+				    range_loop].end_freq) {
 				end_channel_idx = channel_loop;
-				if (CDS_CHANNEL_FREQ(channel_loop) >
-						ch_avoid_indi->avoid_freq_range[
-						range_loop].end_freq)
+				if (WLAN_REG_CH_TO_FREQ(channel_loop) >
+				    ch_avoid_indi->avoid_freq_range[
+					    range_loop].end_freq)
 					end_channel_idx--;
 				break;
 			}
@@ -6889,7 +6892,7 @@ 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++] =
-				CDS_CHANNEL_NUM(channel_loop);
+				WLAN_REG_CH_NUM(channel_loop);
 			if (hdd_ctxt->unsafe_channel_count >=
 							NUM_CHANNELS) {
 				hdd_warn("LTECoex unsafe ch list full");
@@ -11648,11 +11651,10 @@ void hdd_check_and_restart_sap_with_non_dfs_acs(void)
 	}
 
 	ap_adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE);
-	if (ap_adapter != NULL &&
-			test_bit(SOFTAP_BSS_STARTED,
-				&ap_adapter->event_flags)
-			&& CDS_IS_DFS_CH(ap_adapter->sessionCtx.ap.
-				operatingChannel)) {
+	if (ap_adapter != NULL && test_bit(SOFTAP_BSS_STARTED,
+			&ap_adapter->event_flags) &&
+			wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev,
+				ap_adapter->sessionCtx.ap.operatingChannel)) {
 
 		cds_warn("STA-AP Mode DFS not supported. Restart SAP with Non DFS ACS");
 		ap_adapter->sessionCtx.ap.sapConfig.channel =

+ 2 - 0
core/hdd/src/wlan_hdd_object_manager.c

@@ -119,6 +119,7 @@ int hdd_objmgr_create_and_store_pdev(hdd_context_t *hdd_ctx)
 		return -ENOMEM;
 	}
 	hdd_ctx->hdd_pdev = pdev;
+	sme_store_pdev(hdd_ctx->hHal, hdd_ctx->hdd_pdev);
 	hdd_init_pdev_os_priv(hdd_ctx, priv);
 	wlan_pdev_obj_lock(pdev);
 	wlan_pdev_set_tgt_if_handle(pdev, psoc->tgt_if_handle);
@@ -133,6 +134,7 @@ int hdd_objmgr_release_and_destroy_pdev(hdd_context_t *hdd_ctx)
 
 	hdd_deinit_pdev_os_priv(hdd_ctx);
 	hdd_ctx->hdd_pdev = NULL;
+	sme_clear_pdev(hdd_ctx->hHal);
 	if (!pdev)
 		return -EINVAL;
 

+ 4 - 3
core/hdd/src/wlan_hdd_oemdata.c

@@ -414,8 +414,8 @@ static void hdd_update_channel_bw_info(hdd_context_t *hdd_ctx,
 	/* Passing CH_WIDTH_MAX will give the max bandwidth supported */
 	ch_params.ch_width = CH_WIDTH_MAX;
 
-	cds_set_channel_params(chan, sec_ch_2g, &ch_params);
-
+	wlan_reg_set_channel_params(hdd_ctx->hdd_pdev, chan,
+			sec_ch_2g, &ch_params);
 	if (ch_params.center_freq_seg0)
 		hdd_chan_info->band_center_freq1 =
 			cds_chan_to_freq(ch_params.center_freq_seg0);
@@ -512,7 +512,8 @@ static int oem_process_channel_info_req_msg(int numOfChannels, char *chanList)
 
 			hddChanInfo.info = 0;
 			if (CHANNEL_STATE_DFS ==
-			    cds_get_channel_state(chanId))
+			    wlan_reg_get_channel_state(p_hdd_ctx->hdd_pdev,
+				    chanId))
 				WMI_SET_CHANNEL_FLAG(&hddChanInfo,
 						     WMI_CHAN_FLAG_DFS);
 

+ 6 - 5
core/hdd/src/wlan_hdd_regulatory.c

@@ -36,8 +36,7 @@
 #include "wlan_hdd_main.h"
 #include "wlan_hdd_regulatory.h"
 #include <wlan_reg_ucfg_api.h>
-#include <wlan_reg_services_api.h>
-#include "cds_reg_service.h"
+#include "cds_regdomain.h"
 
 #define REG_RULE_2412_2462    REG_RULE(2412-10, 2462+10, 40, 0, 20, 0)
 
@@ -60,6 +59,8 @@
 static bool init_by_driver;
 static bool init_by_reg_core;
 
+struct regulatory_channel reg_channels[NUM_CHANNELS];
+
 static const struct ieee80211_regdomain
 hdd_world_regrules_60_61_62 = {
 	.n_reg_rules = 6,
@@ -129,7 +130,7 @@ hdd_world_regrules_67_68_6A_6C = {
  * Return: regulatory rules ptr
  */
 static const struct ieee80211_regdomain *hdd_get_world_regrules(
-struct regulatory *reg)
+	struct regulatory *reg)
 {
 	struct reg_dmn_pair *regpair =
 		(struct reg_dmn_pair *)reg->regpair;
@@ -462,7 +463,7 @@ static void hdd_process_regulatory_data(hdd_context_t *hdd_ctx,
 			wiphy_chan_144->flags |= IEEE80211_CHAN_DISABLED;
 	}
 
-	wlan_hdd_cfg80211_update_band(wiphy, band_capability);
+	wlan_hdd_cfg80211_update_band(hdd_ctx, wiphy, band_capability);
 }
 
 /**
@@ -531,7 +532,7 @@ static int hdd_regulatory_init_no_offload(hdd_context_t *hdd_ctx,
 
 	reg_info->cc_src = SOURCE_DRIVER;
 
-	cds_put_default_country(reg_info->alpha2);
+	wlan_reg_set_default_country(hdd_ctx->hdd_psoc, reg_info->alpha2);
 
 	cds_fill_and_send_ctl_to_fw(reg_info);
 

+ 6 - 5
core/hdd/src/wlan_hdd_scan.c

@@ -767,7 +767,7 @@ static int __iw_set_scan(struct net_device *dev, struct iw_request_info *info,
 	if (con_sap_adapter) {
 		con_dfs_ch = con_sap_adapter->sessionCtx.ap.operatingChannel;
 
-		if (CDS_IS_DFS_CH(con_dfs_ch)) {
+		if (wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev, con_dfs_ch)) {
 			hdd_warn("##In DFS Master mode. Scan aborted");
 			return -EOPNOTSUPP;
 		}
@@ -1563,8 +1563,8 @@ static int __wlan_hdd_cfg80211_scan(struct wiphy *wiphy,
 			con_dfs_ch =
 				con_sap_adapter->sessionCtx.ap.operatingChannel;
 
-		if (!policy_mgr_is_hw_dbs_capable(pHddCtx->hdd_psoc)
-			&& CDS_IS_DFS_CH(con_dfs_ch)) {
+		if (!policy_mgr_is_hw_dbs_capable(pHddCtx->hdd_psoc) &&
+			wlan_reg_is_dfs_ch(pHddCtx->hdd_pdev, con_dfs_ch)) {
 			/* Provide empty scan result during DFS operation since
 			 * scanning not supported during DFS. Reason is
 			 * following case:
@@ -1770,9 +1770,10 @@ static int __wlan_hdd_cfg80211_scan(struct wiphy *wiphy,
 			goto free_mem;
 		}
 		for (i = 0, len = 0; i < request->n_channels; i++) {
-			if (cds_is_dsrc_channel(cds_chan_to_freq(
-			    request->channels[i]->hw_value)))
+			if (WLAN_REG_IS_11P_CH(
+					pHddCrequest->channels[i]->hw_value))
 				continue;
+
 			channelList[num_chan] = request->channels[i]->hw_value;
 			len += snprintf(chList + len, 5, "%d ", channelList[i]);
 			num_chan++;

+ 4 - 3
core/hdd/src/wlan_hdd_tdls.c

@@ -4585,7 +4585,7 @@ int wlan_hdd_tdls_extctrl_config_peer(hdd_adapter_t *pAdapter,
 	pHddCtx->tdls_external_peer_count++;
 
 	/* validate if off channel is DFS channel */
-	if (CDS_IS_DFS_CH(chan)) {
+	if (wlan_reg_is_dfs_ch(pHddCtx->hdd_pdev, chan)) {
 		hdd_err("Resetting TDLS off-channel from %d to %d",
 		       chan, CFG_TDLS_PREFERRED_OFF_CHANNEL_NUM_DEFAULT);
 		chan = CFG_TDLS_PREFERRED_OFF_CHANNEL_NUM_DEFAULT;
@@ -5006,8 +5006,9 @@ static int __wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy,
 						pTdlsPeer->
 						op_class_for_pref_off_chan;
 
-				if (CDS_IS_DFS_CH(smeTdlsPeerStateParams.
-					peerCap.prefOffChanNum)) {
+				if (wlan_reg_is_dfs_ch(pHddCtx->hdd_pdev,
+						smeTdlsPeerStateParams.
+						peerCap.prefOffChanNum)) {
 					hdd_err("Resetting TDLS off-channel from %d to %d",
 					       smeTdlsPeerStateParams.peerCap.
 						prefOffChanNum,

+ 4 - 2
core/hdd/src/wlan_hdd_wext.c

@@ -12403,7 +12403,8 @@ int hdd_set_band(struct net_device *dev, u8 ui_band)
 				  band);
 			return -EINVAL;
 		}
-		wlan_hdd_cfg80211_update_band(pHddCtx->wiphy, (eCsrBand) band);
+		wlan_hdd_cfg80211_update_band(pHddCtx, pHddCtx->wiphy,
+				(eCsrBand)band);
 	}
 	return 0;
 }
@@ -12498,11 +12499,12 @@ static int wlan_hdd_set_mon_chan(hdd_adapter_t *adapter, uint32_t chan,
 		     QDF_MAC_ADDR_SIZE);
 
 	ch_params.ch_width = bandwidth;
-	cds_set_channel_params(chan, 0, &ch_params);
+	wlan_reg_set_channel_params(hdd_ctx->hdd_pdev, chan, 0, &ch_params);
 	if (ch_params.ch_width == CH_WIDTH_INVALID) {
 		hdd_err("Invalid capture channel or bandwidth for a country");
 		return -EINVAL;
 	}
+
 	status = sme_roam_channel_change_req(hal_hdl, bssid, &ch_params,
 					     &roam_profile);
 	if (status) {

+ 1 - 0
core/mac/inc/ani_global.h

@@ -968,6 +968,7 @@ typedef struct sAniSirGlobal {
 	uint8_t user_configured_nss;
 	bool sta_prefer_80MHz_over_160MHz;
 	struct wlan_objmgr_psoc *psoc;
+	struct wlan_objmgr_pdev *pdev;
 	enum  country_src reg_hint_src;
 	bool snr_monitor_enabled;
 	void (*chan_info_cb)(struct scan_chan_info *chan_info);

+ 2 - 2
core/mac/inc/sir_api.h

@@ -46,7 +46,6 @@ typedef struct sAniSirGlobal *tpAniSirGlobal;
 #endif
 
 #include "qdf_types.h"
-#include "cds_reg_service.h"
 #include "cds_regdomain.h"
 #include "sir_types.h"
 #include "sir_mac_prot_def.h"
@@ -56,6 +55,7 @@ typedef struct sAniSirGlobal *tpAniSirGlobal;
 #include "wmi_unified.h"
 #include "wmi_unified_param.h"
 #include "ol_txrx_htt_api.h"
+#include "wlan_reg_services_api.h"
 #include <dot11f.h>
 #include "wlan_policy_mgr_api.h"
 
@@ -3395,7 +3395,7 @@ typedef struct {
 	uint8_t supportedChannelsLen;
 	uint8_t supportedChannels[SIR_MAC_MAX_SUPP_CHANNELS];
 	uint8_t supportedOperClassesLen;
-	uint8_t supportedOperClasses[CDS_MAX_SUPP_OPER_CLASSES];
+	uint8_t supportedOperClasses[REG_MAX_SUPP_OPER_CLASSES];
 } tSirTdlsLinkEstablishReq, *tpSirTdlsLinkEstablishReq;
 
 /* TDLS Request struct SME-->PE */

+ 1 - 1
core/mac/src/pe/lim/lim_link_monitoring_algo.c

@@ -472,7 +472,7 @@ void lim_handle_heart_beat_failure(tpAniSirGlobal mac_ctx,
 		 * down the link
 		 */
 		curr_chan = session->currentOperChannel;
-		if (!lim_isconnected_on_dfs_channel(curr_chan)) {
+		if (!lim_isconnected_on_dfs_channel(mac_ctx, curr_chan)) {
 			/* Detected continuous Beacon Misses */
 			session->LimHBFailureStatus = true;
 

+ 6 - 4
core/mac/src/pe/lim/lim_process_action_frame.c

@@ -404,10 +404,12 @@ lim_process_ext_channel_switch_action_frame(tpAniSirGlobal mac_ctx,
 	 * and no concurrent session is running.
 	 */
 	if (!((session_entry->currentOperChannel != target_channel) &&
-	((cds_get_channel_state(target_channel)
-				== CHANNEL_STATE_ENABLE) ||
-	(cds_get_channel_state(target_channel) == CHANNEL_STATE_DFS &&
-	!policy_mgr_concurrent_open_sessions_running(mac_ctx->psoc))))) {
+		((wlan_reg_get_channel_state(mac_ctx->pdev, target_channel) ==
+		  CHANNEL_STATE_ENABLE) ||
+		 (wlan_reg_get_channel_state(mac_ctx->pdev, target_channel) ==
+		  CHANNEL_STATE_DFS &&
+		  !policy_mgr_concurrent_open_sessions_running(
+			  mac_ctx->psoc))))) {
 		lim_log(mac_ctx, LOGE, FL("Channel %d is not valid"),
 							target_channel);
 		return;

+ 2 - 1
core/mac/src/pe/lim/lim_process_message_queue.c

@@ -64,6 +64,7 @@
 #include "qdf_mem.h"
 #include "wlan_policy_mgr_api.h"
 #include "nan_datapath.h"
+#include "wlan_reg_services_api.h"
 
 void lim_log_session_states(tpAniSirGlobal pMac);
 static void lim_process_normal_hdd_msg(tpAniSirGlobal mac_ctx,
@@ -1837,7 +1838,7 @@ static void lim_process_messages(tpAniSirGlobal mac_ctx,
 			 *    restart, in such a case, beacon params will be
 			 *    reset and thus will not contain Q2Q IE, by default
 			 */
-			if (cds_get_channel_state(
+			if (wlan_reg_get_channel_state(mac_ctx->pdev,
 					session_entry->currentOperChannel)
 					!= CHANNEL_STATE_DFS) {
 				beacon_params.bssIdx = session_entry->bssIdx;

+ 12 - 8
core/mac/src/pe/lim/lim_process_mlm_req_messages.c

@@ -46,6 +46,7 @@
 #include "host_diag_core_log.h"
 #endif
 #include "wma_if.h"
+#include "wlan_reg_services_api.h"
 
 static void lim_process_mlm_start_req(tpAniSirGlobal, uint32_t *);
 static void lim_process_mlm_join_req(tpAniSirGlobal, uint32_t *);
@@ -288,7 +289,7 @@ void lim_set_dfs_channel_list(tpAniSirGlobal mac_ctx, uint8_t chan_num,
 		return;
 	}
 
-	if (true == lim_isconnected_on_dfs_channel(chan_num)) {
+	if (lim_isconnected_on_dfs_channel(mac_ctx, chan_num)) {
 		if (dfs_ch_list->timeStamp[chan_num] == 0) {
 			/*
 			 * Received first beacon;
@@ -576,15 +577,18 @@ lim_mlm_add_bss(tpAniSirGlobal mac_ctx,
 	if (session->ch_width == CH_WIDTH_160MHZ) {
 		is_ch_dfs = true;
 	} else if (session->ch_width == CH_WIDTH_80P80MHZ) {
-		if (cds_get_channel_state(mlm_start_req->channelNumber) ==
-							CHANNEL_STATE_DFS ||
-		    cds_get_channel_state(session->ch_center_freq_seg1 -
-					    SIR_80MHZ_START_CENTER_CH_DIFF) ==
-							CHANNEL_STATE_DFS)
+		if (wlan_reg_get_channel_state(mac_ctx->pdev,
+					mlm_start_req->channelNumber) ==
+				CHANNEL_STATE_DFS ||
+				wlan_reg_get_channel_state(mac_ctx->pdev,
+					session->ch_center_freq_seg1 -
+					SIR_80MHZ_START_CENTER_CH_DIFF) ==
+				CHANNEL_STATE_DFS)
 			is_ch_dfs = true;
 	} else {
-		if (cds_get_channel_state(mlm_start_req->channelNumber) ==
-							CHANNEL_STATE_DFS)
+		if (wlan_reg_get_channel_state(mac_ctx->pdev,
+					mlm_start_req->channelNumber) ==
+				CHANNEL_STATE_DFS)
 			is_ch_dfs = true;
 	}
 

+ 7 - 6
core/mac/src/pe/lim/lim_process_mlm_rsp_messages.c

@@ -50,6 +50,7 @@
 #include "lim_types.h"
 #include "wlan_policy_mgr_api.h"
 #include "nan_datapath.h"
+#include "wlan_reg_services_api.h"
 
 #define MAX_SUPPORTED_PEERS_WEP 16
 
@@ -235,16 +236,16 @@ void lim_process_mlm_start_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
 		if (psessionEntry->ch_width == CH_WIDTH_160MHZ) {
 			send_bcon_ind = false;
 		} else if (psessionEntry->ch_width == CH_WIDTH_80P80MHZ) {
-			if ((cds_get_channel_state(channelId) !=
-						CHANNEL_STATE_DFS) &&
-			    (cds_get_channel_state(psessionEntry->
-					ch_center_freq_seg1 -
+			if ((wlan_reg_get_channel_state(pMac->pdev, channelId)
+						!= CHANNEL_STATE_DFS) &&
+			    (wlan_reg_get_channel_state(pMac->pdev,
+					psessionEntry->ch_center_freq_seg1 -
 					SIR_80MHZ_START_CENTER_CH_DIFF) !=
 						CHANNEL_STATE_DFS))
 				send_bcon_ind = true;
 		} else {
-			if (cds_get_channel_state(channelId) !=
-							CHANNEL_STATE_DFS)
+			if (wlan_reg_get_channel_state(pMac->pdev, channelId)
+					!= CHANNEL_STATE_DFS)
 				send_bcon_ind = true;
 		}
 		if (send_bcon_ind) {

+ 3 - 3
core/mac/src/pe/lim/lim_process_sme_req_messages.c

@@ -1966,7 +1966,7 @@ __lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
 
 		/* Enable the spectrum management if this is a DFS channel */
 		if (session->country_info_present &&
-			lim_isconnected_on_dfs_channel(
+			lim_isconnected_on_dfs_channel(mac_ctx,
 					session->currentOperChannel))
 			session->spectrumMgtEnabled = true;
 
@@ -2315,7 +2315,7 @@ static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
 
 	/* Enable the spectrum management if this is a DFS channel */
 	if (session_entry->country_info_present &&
-		lim_isconnected_on_dfs_channel(
+			lim_isconnected_on_dfs_channel(mac_ctx,
 				session_entry->currentOperChannel))
 		session_entry->spectrumMgtEnabled = true;
 
@@ -5984,7 +5984,7 @@ static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
 	tpDphHashNode psta;
 
 
-	op_class = cds_reg_dmn_get_opclass_from_channel(
+	op_class = wlan_reg_dmn_get_opclass_from_channel(
 				mac_ctx->scan.countryCodeCurrent,
 				new_channel,
 				ch_bandwidth);

+ 8 - 9
core/mac/src/pe/lim/lim_process_tdls.c

@@ -78,6 +78,7 @@
 #include "wma_types.h"
 #include "cds_regdomain.h"
 #include "cds_utils.h"
+#include "wlan_reg_services_api.h"
 
 #ifdef CONVERGED_TDLS_ENABLE
 #include "wlan_tdls_tgt_api.h"
@@ -227,7 +228,7 @@ static void populate_dot11f_tdls_offchannel_params(
 	uint8_t chanOffset;
 	uint8_t op_class;
 	uint8_t numClasses;
-	uint8_t classes[CDS_MAX_SUPP_OPER_CLASSES];
+	uint8_t classes[REG_MAX_SUPP_OPER_CLASSES];
 	uint32_t band;
 	uint8_t nss_2g;
 	uint8_t nss_5g;
@@ -258,14 +259,13 @@ static void populate_dot11f_tdls_offchannel_params(
 		if ((band == eCSR_BAND_5G) &&
 		    (NSS_2x2_MODE == nss_5g) &&
 		    (NSS_1x1_MODE == nss_2g) &&
-		    (true == CDS_IS_DFS_CH(validChan[i]))) {
+		    (wlan_reg_is_dfs_ch(pMac->pdev, validChan[i]))) {
 			lim_log(pMac, LOGD,
 				FL("skipping channel %d, nss_5g: %d, nss_2g: %d"),
 				validChan[i], nss_5g, nss_2g);
 			continue;
 		} else {
-			if (true == cds_is_dsrc_channel(
-				cds_chan_to_freq(validChan[i]))) {
+			if (WLAN_REG_IS_11P_CH(validChan[i])) {
 				lim_log(pMac, LOGD,
 					FL("skipping channel %d from the valid channel list"),
 					validChan[i]);
@@ -300,10 +300,9 @@ static void populate_dot11f_tdls_offchannel_params(
 	default:
 		chanOffset = BWALL;
 		break;
-
 	}
 
-	op_class = cds_reg_dmn_get_opclass_from_channel(
+	op_class = wlan_reg_dmn_get_opclass_from_channel(
 		pMac->scan.countryCodeCurrent,
 		psessionEntry->currentOperChannel,
 		chanOffset);
@@ -328,11 +327,11 @@ static void populate_dot11f_tdls_offchannel_params(
 	suppOperClasses->present = 1;
 	suppOperClasses->classes[0] = op_class;
 
-	cds_reg_dmn_get_curr_opclasses(&numClasses, &classes[0]);
+	wlan_reg_dmn_get_curr_opclasses(&numClasses, &classes[0]);
 
-	for (i = 0; i < numClasses; i++) {
+	for (i = 0; i < numClasses; i++)
 		suppOperClasses->classes[i + 1] = classes[i];
-	}
+
 	/* add one for present operating class, added in the beginning */
 	suppOperClasses->num_classes = numClasses + 1;
 

+ 8 - 4
core/mac/src/pe/lim/lim_send_messages.c

@@ -39,6 +39,7 @@
 #include "lim_send_messages.h"
 #include "cfg_api.h"
 #include "lim_trace.h"
+#include "wlan_reg_services_api.h"
 #ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM    /* FEATURE_WLAN_DIAG_SUPPORT */
 #include "host_diag_core_log.h"
 #endif /* FEATURE_WLAN_DIAG_SUPPORT */
@@ -246,13 +247,16 @@ tSirRetStatus lim_send_switch_chnl_params(tpAniSirGlobal pMac,
 		pChnlParams->isDfsChannel = true;
 	} else if (ch_width == CH_WIDTH_80P80MHZ) {
 		pChnlParams->isDfsChannel = false;
-		if (cds_get_channel_state(chnlNumber) == CHANNEL_STATE_DFS ||
-		    cds_get_channel_state(pChnlParams->ch_center_freq_seg1 -
+		if (wlan_reg_get_channel_state(pMac->pdev, chnlNumber) ==
+				CHANNEL_STATE_DFS ||
+		    wlan_reg_get_channel_state(pMac->pdev,
+			    pChnlParams->ch_center_freq_seg1 -
 				SIR_80MHZ_START_CENTER_CH_DIFF) ==
 							CHANNEL_STATE_DFS)
 			pChnlParams->isDfsChannel = true;
 	} else {
-		if (cds_get_channel_state(chnlNumber) == CHANNEL_STATE_DFS)
+		if (wlan_reg_get_channel_state(pMac->pdev, chnlNumber) ==
+				CHANNEL_STATE_DFS)
 			pChnlParams->isDfsChannel = true;
 		else
 			pChnlParams->isDfsChannel = false;
@@ -853,7 +857,7 @@ tSirRetStatus lim_send_ht40_obss_scanind(tpAniSirGlobal mac_ctx,
 	ht40_obss_scanind->obss_activity_threshold =
 		session->obss_ht40_scanparam.obss_activity_threshold;
 	ht40_obss_scanind->current_operatingclass =
-		cds_reg_dmn_get_opclass_from_channel(
+		wlan_reg_dmn_get_opclass_from_channel(
 			mac_ctx->scan.countryCodeCurrent,
 			session->currentOperChannel,
 			session->ch_width);

+ 17 - 13
core/mac/src/pe/lim/lim_send_sme_rsp_messages.c

@@ -59,6 +59,7 @@
 #include "lim_send_messages.h"
 #include "nan_datapath.h"
 #include "lim_assoc_utils.h"
+#include "wlan_reg_services_api.h"
 
 #ifdef CONVERGED_TDLS_ENABLE
 #include "wlan_tdls_tgt_api.h"
@@ -2097,8 +2098,8 @@ static void lim_process_csa_wbw_ie(tpAniSirGlobal mac_ctx,
 	if ((ap_new_ch_width == CH_WIDTH_160MHZ) &&
 			!new_ch_width_dfn) {
 		ch_params.ch_width = CH_WIDTH_160MHZ;
-		cds_set_channel_params(csa_params->channel, 0,
-				&ch_params);
+		wlan_reg_set_channel_params(mac_ctx->pdev,
+					    csa_params->channel, 0, &ch_params);
 		ap_new_ch_width = ch_params.ch_width;
 		csa_params->new_ch_freq_seg1 = ch_params.center_freq_seg0;
 		csa_params->new_ch_freq_seg2 = ch_params.center_freq_seg1;
@@ -2227,7 +2228,7 @@ void lim_handle_csa_offload_msg(tpAniSirGlobal mac_ctx,
 		} else if (csa_params->ies_present_flag
 				& lim_xcsa_ie_present) {
 			chan_space =
-				cds_reg_dmn_get_chanwidth_from_opclass(
+				wlan_reg_dmn_get_chanwidth_from_opclass(
 						mac_ctx->scan.countryCodeCurrent,
 						csa_params->channel,
 						csa_params->new_op_class);
@@ -2249,8 +2250,8 @@ void lim_handle_csa_offload_msg(tpAniSirGlobal mac_ctx,
 
 			ch_params.ch_width =
 				chnl_switch_info->newChanWidth;
-			cds_set_channel_params(csa_params->channel,
-					0, &ch_params);
+			wlan_reg_set_channel_params(mac_ctx->pdev,
+					csa_params->channel, 0, &ch_params);
 			chnl_switch_info->newCenterChanFreq0 =
 				ch_params.center_freq_seg0;
 			/*
@@ -2277,7 +2278,7 @@ void lim_handle_csa_offload_msg(tpAniSirGlobal mac_ctx,
 		if (csa_params->ies_present_flag
 				& lim_xcsa_ie_present) {
 			chan_space =
-				cds_reg_dmn_get_chanwidth_from_opclass(
+				wlan_reg_dmn_get_chanwidth_from_opclass(
 						mac_ctx->scan.countryCodeCurrent,
 						csa_params->channel,
 						csa_params->new_op_class);
@@ -2290,7 +2291,7 @@ void lim_handle_csa_offload_msg(tpAniSirGlobal mac_ctx,
 					CH_WIDTH_40MHZ;
 				ch_params.ch_width =
 					chnl_switch_info->newChanWidth;
-				cds_set_channel_params(
+				wlan_reg_set_channel_params(mac_ctx->pdev,
 						csa_params->channel,
 						0, &ch_params);
 				lim_ch_switch->ch_center_freq_seg0 =
@@ -2313,8 +2314,8 @@ void lim_handle_csa_offload_msg(tpAniSirGlobal mac_ctx,
 			lim_ch_switch->state =
 				eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
 			ch_params.ch_width = CH_WIDTH_40MHZ;
-			cds_set_channel_params(csa_params->channel,
-					0, &ch_params);
+			wlan_reg_set_channel_params(mac_ctx->pdev,
+					csa_params->channel, 0, &ch_params);
 			lim_ch_switch->ch_center_freq_seg0 =
 				ch_params.center_freq_seg0;
 			lim_ch_switch->sec_ch_offset =
@@ -2563,13 +2564,16 @@ lim_send_sme_ap_channel_switch_resp(tpAniSirGlobal pMac,
 	if (ch_width == CH_WIDTH_160MHZ) {
 		is_ch_dfs = true;
 	} else if (ch_width == CH_WIDTH_80P80MHZ) {
-		if (cds_get_channel_state(channelId) == CHANNEL_STATE_DFS ||
-		    cds_get_channel_state(ch_center_freq_seg1 -
-					SIR_80MHZ_START_CENTER_CH_DIFF) ==
+		if (wlan_reg_get_channel_state(pMac->pdev, channelId) ==
+				CHANNEL_STATE_DFS ||
+		    wlan_reg_get_channel_state(pMac->pdev,
+			    ch_center_freq_seg1 -
+			    SIR_80MHZ_START_CENTER_CH_DIFF) ==
 							CHANNEL_STATE_DFS)
 			is_ch_dfs = true;
 	} else {
-		if (cds_get_channel_state(channelId) == CHANNEL_STATE_DFS)
+		if (wlan_reg_get_channel_state(pMac->pdev, channelId) ==
+				CHANNEL_STATE_DFS)
 			is_ch_dfs = true;
 	}
 

+ 5 - 3
core/mac/src/pe/lim/lim_utils.c

@@ -58,6 +58,7 @@
 #include "cds_reg_service.h"
 #include "nan_datapath.h"
 #include "wma.h"
+#include "wlan_reg_services_api.h"
 
 #ifdef WLAN_FEATURE_11W
 #include "wni_cfg.h"
@@ -5944,10 +5945,11 @@ bool lim_is_noa_insert_reqd(tpAniSirGlobal pMac)
 	return false;
 }
 
-bool lim_isconnected_on_dfs_channel(uint8_t currentChannel)
+bool lim_isconnected_on_dfs_channel(tpAniSirGlobal mac_ctx,
+		uint8_t currentChannel)
 {
 	if (CHANNEL_STATE_DFS ==
-	    cds_get_channel_state(currentChannel)) {
+	    wlan_reg_get_channel_state(mac_ctx->pdev, currentChannel)) {
 		return true;
 	} else {
 		return false;
@@ -6454,7 +6456,7 @@ static QDF_STATUS lim_send_ie(tpAniSirGlobal mac_ctx, uint32_t sme_session_id,
 static inline bool lim_get_rx_ldpc(tpAniSirGlobal mac_ctx, uint8_t ch)
 {
 	if (mac_ctx->roam.configParam.rxLdpcEnable &&
-		wma_is_rx_ldpc_supported_for_channel(CDS_CHANNEL_NUM(ch)))
+		wma_is_rx_ldpc_supported_for_channel(WLAN_REG_CH_NUM(ch)))
 		return true;
 	else
 		return false;

+ 2 - 1
core/mac/src/pe/lim/lim_utils.h

@@ -456,7 +456,8 @@ uint8_t lim_get_noa_attr_stream(tpAniSirGlobal pMac, uint8_t *pNoaStream,
 uint8_t lim_build_p2p_ie(tpAniSirGlobal pMac, uint8_t *ie, uint8_t *data,
 		uint8_t ie_len);
 bool lim_is_noa_insert_reqd(tpAniSirGlobal pMac);
-bool lim_isconnected_on_dfs_channel(uint8_t currentChannel);
+bool lim_isconnected_on_dfs_channel(tpAniSirGlobal mac_ctx,
+		uint8_t currentChannel);
 uint8_t lim_get_current_operating_channel(tpAniSirGlobal pMac);
 uint32_t lim_get_max_rate_flags(tpAniSirGlobal mac_ctx, tpDphHashNode sta_ds);
 

+ 3 - 3
core/mac/src/sys/legacy/src/utils/src/parser_api.c

@@ -189,7 +189,7 @@ void populate_dot_11_f_ext_chann_switch_ann(tpAniSirGlobal mac_ptr,
 		ch_offset = session_entry->gLimChannelSwitch.sec_ch_offset;
 
 	dot_11_ptr->switch_mode = session_entry->gLimChannelSwitch.switchMode;
-	dot_11_ptr->new_reg_class = cds_reg_dmn_get_opclass_from_channel(
+	dot_11_ptr->new_reg_class = wlan_reg_dmn_get_opclass_from_channel(
 			mac_ptr->scan.countryCodeCurrent,
 			session_entry->gLimChannelSwitch.primaryChannel,
 			ch_offset);
@@ -252,9 +252,9 @@ populate_dot11_supp_operating_classes(tpAniSirGlobal mac_ptr,
 		}
 	}
 
-	cds_reg_dmn_get_curr_opclasses(&dot_11_ptr->num_classes,
+	wlan_reg_dmn_get_curr_opclasses(&dot_11_ptr->num_classes,
 					&dot_11_ptr->classes[1]);
-	dot_11_ptr->classes[0] = cds_reg_dmn_get_opclass_from_channel(
+	dot_11_ptr->classes[0] = wlan_reg_dmn_get_opclass_from_channel(
 					mac_ptr->scan.countryCodeCurrent,
 					session_entry->currentOperChannel,
 					ch_bandwidth);

+ 3 - 2
core/sap/dfs/inc/dfs.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005-2016 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2005-2017 The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -62,7 +62,8 @@
 /* From wlan_modules/include/ */
 #include "ath_dfs_structs.h"
 /*DFS - Newly added File to interface cld UMAC and dfs data structures*/
-#include <wma_dfs_interface.h>
+#include "wlan_reg_services_api.h"
+#include "wma_dfs_interface.h"
 /*
    *TO DO DFS- Need to include this file later on
    #include "ah.h"

+ 2 - 3
core/sap/inc/sap_api.h

@@ -1001,9 +1001,8 @@ QDF_STATUS wlansap_update_sap_config_add_ie(tsap_Config_t *pConfig,
 		eUpdateIEsType updateType);
 QDF_STATUS wlansap_reset_sap_config_add_ie(tsap_Config_t *pConfig,
 			eUpdateIEsType updateType);
-void wlansap_extend_to_acs_range(uint8_t *startChannelNum,
-		uint8_t *endChannelNum,
-		uint8_t *bandStartChannel,
+void wlansap_extend_to_acs_range(tHalHandle hal, uint8_t *startChannelNum,
+		uint8_t *endChannelNum, uint8_t *bandStartChannel,
 		uint8_t *bandEndChannel);
 QDF_STATUS wlansap_get_dfs_nol(void *pSapCtx, uint8_t *nol, uint32_t *nol_len);
 QDF_STATUS wlansap_set_dfs_nol(void *pSapCtx, eSapDfsNolType conf);

+ 16 - 7
core/sap/src/sap_api_link_cntl.c

@@ -57,6 +57,8 @@
 #include "wma.h"
 #include <wlan_objmgr_vdev_obj.h>
 #include <wlan_objmgr_pdev_obj.h>
+#include "wlan_reg_services_api.h"
+
 /*----------------------------------------------------------------------------
  * Preprocessor Definitions and Constants
  * -------------------------------------------------------------------------*/
@@ -108,6 +110,7 @@ QDF_STATUS wlansap_scan_callback(tHalHandle hal_handle,
 	uint8_t operChannel = 0;
 	QDF_STATUS sap_sm_status;
 	uint32_t event;
+	tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
 
 
 	if (NULL == hal_handle) {
@@ -197,7 +200,7 @@ QDF_STATUS wlansap_scan_callback(tHalHandle hal_handle,
 	}
 
 	sap_ctx->ch_params.ch_width = sap_ctx->acs_cfg->ch_width;
-	cds_set_channel_params(sap_ctx->channel,
+	wlan_reg_set_channel_params(mac_ctx->pdev, sap_ctx->channel,
 		sap_ctx->secondary_ch,
 		&sap_ctx->ch_params);
 #ifdef SOFTAP_CHANNEL_RANGE
@@ -246,9 +249,11 @@ void sap_config_acs_result(tHalHandle hal, ptSapContext sap_ctx,
 {
 	uint32_t channel = sap_ctx->acs_cfg->pri_ch;
 	struct ch_params ch_params = {0};
+	tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
 
 	ch_params.ch_width = sap_ctx->acs_cfg->ch_width;
-	cds_set_channel_params(channel, sec_ch, &ch_params);
+	wlan_reg_set_channel_params(mac_ctx->pdev, channel, sec_ch,
+			&ch_params);
 	sap_ctx->acs_cfg->ch_width = ch_params.ch_width;
 	if (sap_ctx->acs_cfg->ch_width > CH_WIDTH_40MHZ)
 		sap_ctx->acs_cfg->vht_seg0_center_ch =
@@ -459,14 +464,17 @@ wlansap_roam_process_ch_change_success(tpAniSirGlobal mac_ctx,
 	if (sap_ctx->ch_params.ch_width == CH_WIDTH_160MHZ) {
 		is_ch_dfs = true;
 	} else if (sap_ctx->ch_params.ch_width == CH_WIDTH_80P80MHZ) {
-		if (cds_get_channel_state(sap_ctx->channel) ==
+		if (wlan_reg_get_channel_state(mac_ctx->pdev,
+					sap_ctx->channel) ==
 						CHANNEL_STATE_DFS ||
-		    cds_get_channel_state(sap_ctx->ch_params.center_freq_seg1 -
+		    wlan_reg_get_channel_state(mac_ctx->pdev,
+			    sap_ctx->ch_params.center_freq_seg1 -
 					  SIR_80MHZ_START_CENTER_CH_DIFF) ==
 							CHANNEL_STATE_DFS)
 			is_ch_dfs = true;
 	} else {
-		if (cds_get_channel_state(sap_ctx->channel) ==
+		if (wlan_reg_get_channel_state(mac_ctx->pdev,
+					sap_ctx->channel) ==
 						CHANNEL_STATE_DFS)
 			is_ch_dfs = true;
 	}
@@ -596,8 +604,9 @@ wlansap_roam_process_dfs_chansw_update(tHalHandle hHal,
 	 * currently. For e.g. 20/40/80 MHz operation
 	 */
 	if (mac_ctx->sap.SapDfsInfo.target_channel)
-		cds_set_channel_params(mac_ctx->sap.SapDfsInfo.target_channel,
-			0, &sap_ctx->ch_params);
+		wlan_reg_set_channel_params(mac_ctx->pdev,
+				mac_ctx->sap.SapDfsInfo.target_channel,
+				0, &sap_ctx->ch_params);
 
 	/*
 	 * Fetch the number of SAP interfaces. If the number of sap Interface

+ 36 - 14
core/sap/src/sap_ch_select.c

@@ -55,6 +55,7 @@
 #endif /* FEATURE_AP_MCC_CH_AVOIDANCE */
 #include "cds_utils.h"
 #include "pld_common.h"
+#include "wlan_reg_services_api.h"
 
 /*--------------------------------------------------------------------------
    Function definitions
@@ -371,11 +372,13 @@ static void sap_process_avoid_ie(tHalHandle hal,
    RETURN VALUE
     NULL
    ============================================================================*/
-void sap_update_unsafe_channel_list(ptSapContext pSapCtx)
+void sap_update_unsafe_channel_list(tHalHandle hal, ptSapContext pSapCtx)
 {
 	uint16_t i, j;
 	uint16_t unsafe_channel_list[NUM_CHANNELS];
 	uint16_t unsafe_channel_count = 0;
+	tpAniSirGlobal mac_ctx = NULL;
+
 	qdf_device_t qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE);
 
 	if (!qdf_ctx) {
@@ -383,6 +386,12 @@ void sap_update_unsafe_channel_list(ptSapContext pSapCtx)
 			  "qdf_ctx is NULL");
 		return;
 	}
+	mac_ctx = PMAC_STRUCT(hal);
+	if (!mac_ctx) {
+		QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_FATAL,
+			  "mac_ctx is NULL");
+		return;
+	}
 
 	/* Flush, default set all channel safe */
 	for (i = 0; i < NUM_CHANNELS; i++) {
@@ -393,7 +402,8 @@ void sap_update_unsafe_channel_list(ptSapContext pSapCtx)
 #if defined(FEATURE_WLAN_STA_AP_MODE_DFS_DISABLE)
 	for (i = 0; i < NUM_CHANNELS; i++) {
 		if (pSapCtx->dfs_ch_disable == true) {
-			if (CDS_IS_DFS_CH(safe_channels[i].channelNumber)) {
+			if (wlan_reg_is_dfs_ch(mac_ctx->pdev,
+					safe_channels[i].channelNumber)) {
 				safe_channels[i].isSafe = false;
 				QDF_TRACE(QDF_MODULE_ID_SAP,
 					QDF_TRACE_LEVEL_INFO_HIGH,
@@ -612,7 +622,7 @@ static bool sap_chan_sel_init(tHalHandle halHandle,
 		}
 
 		if (include_dfs_ch == false) {
-			if (CDS_IS_DFS_CH(*pChans)) {
+			if (wlan_reg_is_dfs_ch(pMac->pdev, *pChans)) {
 				chSafe = false;
 				QDF_TRACE(QDF_MODULE_ID_SAP,
 					  QDF_TRACE_LEVEL_INFO_HIGH,
@@ -643,7 +653,7 @@ static bool sap_chan_sel_init(tHalHandle halHandle,
 		}
 
 		/* Skip DSRC channels */
-		if (cds_is_dsrc_channel(cds_chan_to_freq(*pChans)))
+		if (WLAN_REG_IS_11P_CH(*pChans))
 			continue;
 
 		if (true == chSafe) {
@@ -1740,7 +1750,8 @@ static void sap_sort_chl_weight_vht160(tSapChSelSpectInfo *pSpectInfoParams)
  *
  * Return: none
  */
-static void sap_sort_chl_weight_ht40_24_g(tSapChSelSpectInfo *pSpectInfoParams)
+static void sap_sort_chl_weight_ht40_24_g(tSapChSelSpectInfo *pSpectInfoParams,
+		v_REGDOMAIN_t domain)
 {
 	uint8_t i, j;
 	tSapSpectChInfo *pSpectInfo;
@@ -1834,7 +1845,7 @@ static void sap_sort_chl_weight_ht40_24_g(tSapChSelSpectInfo *pSpectInfoParams)
 	 * channel. Mark the channel whose combination can't satisfy 40MHZ
 	 * as max value, so that it will be sorted to the bottom.
 	 */
-	if (cds_is_fcc_regdomain())
+	if (REGDOMAIN_FCC == domain)
 		ht40plus2gendch = HT40PLUS_2G_FCC_CH_END;
 	else
 		ht40plus2gendch = HT40PLUS_2G_EURJAP_CH_END;
@@ -1979,7 +1990,8 @@ static void sap_sort_chl_weight_ht40_5_g(tSapChSelSpectInfo *pSpectInfoParams)
    ============================================================================*/
 static void sap_sort_chl_weight_all(ptSapContext pSapCtx,
 				    tSapChSelSpectInfo *pSpectInfoParams,
-				    uint32_t operatingBand)
+				    uint32_t operatingBand,
+				    v_REGDOMAIN_t domain)
 {
 	tSapSpectChInfo *pSpectCh = NULL;
 	uint32_t j = 0;
@@ -1993,11 +2005,11 @@ static void sap_sort_chl_weight_all(ptSapContext pSapCtx,
 	switch (pSapCtx->acs_cfg->ch_width) {
 	case CH_WIDTH_40MHZ:
 		if (eCSR_DOT11_MODE_11g == operatingBand)
-			sap_sort_chl_weight_ht40_24_g(pSpectInfoParams);
+			sap_sort_chl_weight_ht40_24_g(pSpectInfoParams, domain);
 		else if (eCSR_DOT11_MODE_11a == operatingBand)
 			sap_sort_chl_weight_ht40_5_g(pSpectInfoParams);
 		else {
-			sap_sort_chl_weight_ht40_24_g(pSpectInfoParams);
+			sap_sort_chl_weight_ht40_24_g(pSpectInfoParams, domain);
 			sap_sort_chl_weight_ht40_5_g(pSpectInfoParams);
 		}
 		break;
@@ -2096,6 +2108,9 @@ static uint8_t sap_select_channel_no_scan_result(tHalHandle hal,
 	uint32_t dfs_master_cap_enabled;
 	uint32_t start_ch_num = sap_ctx->acs_cfg->start_ch;
 	uint32_t end_ch_num = sap_ctx->acs_cfg->end_ch;
+	tpAniSirGlobal mac_ctx = NULL;
+
+	mac_ctx = PMAC_STRUCT(hal);
 
 	QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH,
 		  FL("start - end: %d - %d"), start_ch_num, end_ch_num);
@@ -2124,7 +2139,8 @@ static uint8_t sap_select_channel_no_scan_result(tHalHandle hal,
 		    (safe_channels[i].channelNumber > end_ch_num))
 			continue;
 
-		ch_type = cds_get_channel_state(safe_channels[i].channelNumber);
+		ch_type = wlan_reg_get_channel_state(mac_ctx->pdev,
+				safe_channels[i].channelNumber);
 
 		if ((ch_type == CHANNEL_STATE_DISABLE) ||
 			(ch_type == CHANNEL_STATE_INVALID))
@@ -2194,15 +2210,20 @@ uint8_t sap_select_channel(tHalHandle hal, ptSapContext sap_ctx,
 	tSapChSelSpectInfo *spect_info = &spect_info_obj;
 	uint8_t best_ch_num = SAP_CHANNEL_NOT_SELECTED;
 	uint32_t ht40plus2gendch = 0;
+	v_REGDOMAIN_t domain;
+	uint8_t country[CDS_COUNTRY_CODE_LEN];
 #ifdef SOFTAP_CHANNEL_RANGE
 	uint8_t count;
 	uint32_t start_ch_num, end_ch_num, tmp_ch_num, operating_band = 0;
 #endif
+	tpAniSirGlobal mac_ctx;
+
+	mac_ctx = PMAC_STRUCT(hal);
 	QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH,
 		  "In %s, Running SAP Ch Select", __func__);
 
 #ifdef FEATURE_WLAN_CH_AVOID
-	sap_update_unsafe_channel_list(sap_ctx);
+	sap_update_unsafe_channel_list(hal, sap_ctx);
 #endif
 
 	if (NULL == scan_result) {
@@ -2230,6 +2251,8 @@ uint8_t sap_select_channel(tHalHandle hal, ptSapContext sap_ctx,
 	sap_process_avoid_ie(hal, sap_ctx, scan_result, spect_info);
 #endif /* FEATURE_AP_MCC_CH_AVOIDANCE */
 
+	wlan_reg_read_default_country(mac_ctx->psoc, country);
+	wlan_reg_get_domain_from_country_code(&domain, country, SOURCE_DRIVER);
 #ifdef SOFTAP_CHANNEL_RANGE
 	start_ch_num = sap_ctx->acs_cfg->start_ch;
 	end_ch_num = sap_ctx->acs_cfg->end_ch;
@@ -2239,7 +2262,7 @@ uint8_t sap_select_channel(tHalHandle hal, ptSapContext sap_ctx,
 	sap_ctx->acsBestChannelInfo.weight = SAP_ACS_WEIGHT_MAX;
 
 	/* Sort the ch lst as per the computed weights, lesser weight first. */
-	sap_sort_chl_weight_all(sap_ctx, spect_info, operating_band);
+	sap_sort_chl_weight_all(sap_ctx, spect_info, operating_band, domain);
 
 	/*Loop till get the best channel in the given range */
 	for (count = 0; count < spect_info->numSpectChans; count++) {
@@ -2335,8 +2358,7 @@ uint8_t sap_select_channel(tHalHandle hal, ptSapContext sap_ctx,
 	if ((operating_band != eCSR_DOT11_MODE_11g) ||
 	    (sap_ctx->acs_cfg->ch_width != CH_WIDTH_40MHZ))
 		goto sap_ch_sel_end;
-
-	if (cds_is_fcc_regdomain())
+	if (REGDOMAIN_FCC == domain)
 		ht40plus2gendch = HT40PLUS_2G_FCC_CH_END;
 	else
 		ht40plus2gendch = HT40PLUS_2G_EURJAP_CH_END;

+ 47 - 34
core/sap/src/sap_fsm.c

@@ -58,6 +58,7 @@
 #include <net/cfg80211.h>
 #include <qca_vendor.h>
 #include <wlan_scan_ucfg_api.h>
+#include "wlan_reg_services_api.h"
 
 /*----------------------------------------------------------------------------
  * Preprocessor Definitions and Constants
@@ -804,7 +805,8 @@ static QDF_STATUS sap_get_channel_list(ptSapContext sapContext,
 
    SIDE EFFECTS
    ============================================================================*/
-static QDF_STATUS sap_get_5ghz_channel_list(ptSapContext sapContext);
+static QDF_STATUS sap_get_5ghz_channel_list(tpAniSirGlobal mac_ctx,
+		ptSapContext sapContext);
 
 /*==========================================================================
    FUNCTION    sapStopDfsCacTimer
@@ -1479,7 +1481,8 @@ static uint8_t sap_apply_rules(ptSapContext sap_ctx)
 			}
 		}
 
-		if (cds_get_channel_state(ch_id) == CHANNEL_STATE_DFS) {
+		if (wlan_reg_get_channel_state(mac_ctx->pdev, ch_id) ==
+				CHANNEL_STATE_DFS) {
 			is_ch_nol = sap_dfs_is_channel_in_nol_list(sap_ctx,
 					ch_id, PHY_SINGLE_CHANNEL_CENTERED);
 			if (true == is_ch_nol) {
@@ -1547,7 +1550,7 @@ static uint8_t select_rand_from_lst(tpAniSirGlobal mac_ctx, uint8_t *ch_lst,
 	uint8_t non_dfs_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
 	if (num_ch) {
 		for (i = 0; i < num_ch; i++) {
-			if (CDS_IS_DFS_CH(ch_lst[i]))
+			if (wlan_reg_is_dfs_ch(mac_ctx->pdev, ch_lst[i]))
 				dfs_ch[dfs_num_ch++] = ch_lst[i];
 			else
 				non_dfs_ch[non_dfs_num_ch++] = ch_lst[i];
@@ -1784,7 +1787,7 @@ static uint8_t sap_random_channel_sel(ptSapContext sap_ctx)
 		ch_wd = mac_ctx->sap.SapDfsInfo.orig_chanWidth;
 	}
 
-	if (sap_get_5ghz_channel_list(sap_ctx)) {
+	if (sap_get_5ghz_channel_list(mac_ctx, sap_ctx)) {
 		QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_LOW,
 			  FL("Getting 5Ghz channel list failed"));
 		return 0;
@@ -2316,7 +2319,8 @@ QDF_STATUS sap_goto_channel_sel(ptSapContext sap_context,
 		if (con_ch && sap_context->channel == AUTO_CHANNEL_SELECT) {
 			sap_context->dfs_ch_disable = true;
 		} else if (con_ch && sap_context->channel != con_ch &&
-			   CDS_IS_DFS_CH(sap_context->channel)) {
+			   wlan_reg_is_dfs_ch(mac_ctx->pdev,
+				   sap_context->channel)) {
 			QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_WARN,
 				  FL("MCC DFS not supported in AP_AP Mode"));
 			return QDF_STATUS_E_ABORTED;
@@ -2346,7 +2350,8 @@ QDF_STATUS sap_goto_channel_sel(ptSapContext sap_context,
 					"%s: Override ch %d to %d due to CC Intf",
 					__func__, sap_context->channel, con_ch);
 				sap_context->channel = con_ch;
-				cds_set_channel_params(sap_context->channel, 0,
+				wlan_reg_set_channel_params(mac_ctx->pdev,
+						sap_context->channel, 0,
 						&sap_context->ch_params);
 			}
 		}
@@ -2358,7 +2363,8 @@ QDF_STATUS sap_goto_channel_sel(ptSapContext sap_context,
 #ifdef FEATURE_WLAN_STA_AP_MODE_DFS_DISABLE
 		if (sap_context->channel == AUTO_CHANNEL_SELECT)
 			sap_context->dfs_ch_disable = true;
-		else if (CDS_IS_DFS_CH(sap_context->channel)) {
+		else if (wlan_reg_is_dfs_ch(mac_ctx->pdev,
+					sap_context->channel)) {
 			QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_WARN,
 				  FL("DFS not supported in STA_AP Mode"));
 			return QDF_STATUS_E_ABORTED;
@@ -2376,13 +2382,15 @@ QDF_STATUS sap_goto_channel_sel(ptSapContext sap_context,
 					sap_context->channel,
 					sap_context->csr_roamProfile.phyMode,
 					sap_context->cc_switch_mode);
-			if (con_ch && !CDS_IS_DFS_CH(con_ch)) {
+			if (con_ch && !wlan_reg_is_dfs_ch(mac_ctx->pdev,
+						con_ch)) {
 				QDF_TRACE(QDF_MODULE_ID_SAP,
 					QDF_TRACE_LEVEL_ERROR,
 					"%s: Override ch %d to %d due to CC Intf",
 					__func__, sap_context->channel, con_ch);
 				sap_context->channel = con_ch;
-				cds_set_channel_params(sap_context->channel, 0,
+				wlan_reg_set_channel_params(mac_ctx->pdev,
+						sap_context->channel, 0,
 						&sap_context->ch_params);
 			}
 		}
@@ -3758,8 +3766,10 @@ static QDF_STATUS sap_fsm_state_ch_select(ptSapContext sap_ctx,
 				  sap_ctx->channel, ch);
 
 			sap_ctx->channel = ch;
-			cds_set_channel_params(sap_ctx->channel,
-				sap_ctx->secondary_ch, &sap_ctx->ch_params);
+			wlan_reg_set_channel_params(mac_ctx->pdev,
+					sap_ctx->channel,
+					sap_ctx->secondary_ch,
+					&sap_ctx->ch_params);
 		}
 		if (sap_ctx->channel > 14 &&
 		    (sap_ctx->csr_roamProfile.phyMode == eCSR_DOT11_MODE_11g ||
@@ -3778,7 +3788,7 @@ static QDF_STATUS sap_fsm_state_ch_select(ptSapContext sap_ctx,
 			uint16_t con_ch;
 
 			con_ch = sme_get_concurrent_operation_channel(hal);
-			if (con_ch && CDS_IS_DFS_CH(con_ch))
+			if (con_ch && wlan_reg_is_dfs_ch(mac_ctx->pdev, con_ch))
 				sap_ctx->channel = con_ch;
 		}
 
@@ -3873,7 +3883,7 @@ static QDF_STATUS sap_fsm_state_dfs_cac_wait(ptSapContext sap_ctx,
 		QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
 			  "ENTERTRED CAC WAIT STATE-->eSAP_DISCONNECTING\n");
 		if (mac_ctx->sap.SapDfsInfo.target_channel) {
-			cds_set_channel_params(
+			wlan_reg_set_channel_params(mac_ctx->pdev,
 				mac_ctx->sap.SapDfsInfo.target_channel, 0,
 				&sap_ctx->ch_params);
 		}
@@ -3983,15 +3993,17 @@ static QDF_STATUS sap_fsm_state_starting(ptSapContext sap_ctx,
 		if (sap_ctx->ch_params.ch_width == CH_WIDTH_160MHZ) {
 			is_dfs = true;
 		} else if (sap_ctx->ch_params.ch_width == CH_WIDTH_80P80MHZ) {
-			if (cds_get_channel_state(sap_ctx->channel) ==
+			if (wlan_reg_get_channel_state(mac_ctx->pdev,
+						sap_ctx->channel) ==
 			    CHANNEL_STATE_DFS ||
-			    cds_get_channel_state(sap_ctx->
-				ch_params.center_freq_seg1 -
+			    wlan_reg_get_channel_state(mac_ctx->pdev,
+				    sap_ctx->ch_params.center_freq_seg1 -
 				SIR_80MHZ_START_CENTER_CH_DIFF) ==
 					CHANNEL_STATE_DFS)
 				is_dfs = true;
 		} else {
-			if (cds_get_channel_state(sap_ctx->channel) ==
+			if (wlan_reg_get_channel_state(mac_ctx->pdev,
+						sap_ctx->channel) ==
 							CHANNEL_STATE_DFS)
 				is_dfs = true;
 		}
@@ -4704,7 +4716,7 @@ static QDF_STATUS sap_get_channel_list(ptSapContext sap_ctx,
 			start_ch_num, end_ch_num,
 			sap_ctx->acs_cfg->hw_mode);
 
-	wlansap_extend_to_acs_range(&start_ch_num, &end_ch_num,
+	wlansap_extend_to_acs_range(hal, &start_ch_num, &end_ch_num,
 					    &band_start_ch, &band_end_ch);
 
 	QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
@@ -4740,8 +4752,8 @@ static QDF_STATUS sap_get_channel_list(ptSapContext sap_ctx,
 	for (loop_count = band_start_ch; loop_count <= band_end_ch;
 	     loop_count++) {
 		/* go to next channel if rf_channel is out of range */
-		if ((start_ch_num > CDS_CHANNEL_NUM(loop_count)) ||
-		    (end_ch_num < CDS_CHANNEL_NUM(loop_count)))
+		if ((start_ch_num > WLAN_REG_CH_NUM(loop_count)) ||
+		    (end_ch_num < WLAN_REG_CH_NUM(loop_count)))
 			continue;
 		/*
 		 * go to next channel if none of these condition pass
@@ -4749,22 +4761,22 @@ static QDF_STATUS sap_get_channel_list(ptSapContext sap_ctx,
 		 * - DFS scan disable but chan in CHANNEL_STATE_ENABLE
 		 */
 		if (!(((eSAP_TRUE == mac_ctx->scan.fEnableDFSChnlScan) &&
-		      CDS_CHANNEL_STATE(loop_count)) ||
+		      wlan_reg_get_channel_state(mac_ctx->pdev, loop_count)) ||
 		    ((eSAP_FALSE == mac_ctx->scan.fEnableDFSChnlScan) &&
 		     (CHANNEL_STATE_ENABLE ==
-		      CDS_CHANNEL_STATE(loop_count)))))
+		      wlan_reg_get_channel_state(mac_ctx->pdev, loop_count)))))
 			continue;
 
 #ifdef FEATURE_WLAN_CH_AVOID
 		for (i = 0; i < NUM_CHANNELS; i++) {
 			if ((safe_channels[i].channelNumber ==
-			     CDS_CHANNEL_NUM(loop_count))) {
+			     WLAN_REG_CH_NUM(loop_count))) {
 				/* Check if channel is safe */
 				if (true == safe_channels[i].isSafe) {
 #endif
 #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE
 		uint8_t ch;
-		ch = CDS_CHANNEL_NUM(loop_count);
+		ch = WLAN_REG_CH_NUM(loop_count);
 		if ((sap_ctx->acs_cfg->skip_scan_status ==
 			eSAP_DO_PAR_ACS_SCAN)) {
 		    if ((ch >= sap_ctx->acs_cfg->skip_scan_range1_stch &&
@@ -4772,7 +4784,7 @@ static QDF_STATUS sap_get_channel_list(ptSapContext sap_ctx,
 			(ch >= sap_ctx->acs_cfg->skip_scan_range2_stch &&
 			 ch <= sap_ctx->acs_cfg->skip_scan_range2_endch)) {
 			list[ch_count] =
-				CDS_CHANNEL_NUM(loop_count);
+				WLAN_REG_CH_NUM(loop_count);
 			ch_count++;
 			QDF_TRACE(QDF_MODULE_ID_SAP,
 				QDF_TRACE_LEVEL_INFO,
@@ -4786,7 +4798,7 @@ static QDF_STATUS sap_get_channel_list(ptSapContext sap_ctx,
 		    }
 		} else {
 			list[ch_count] =
-				CDS_CHANNEL_NUM(loop_count);
+				WLAN_REG_CH_NUM(loop_count);
 			ch_count++;
 			QDF_TRACE(QDF_MODULE_ID_SAP,
 				QDF_TRACE_LEVEL_INFO,
@@ -4794,7 +4806,7 @@ static QDF_STATUS sap_get_channel_list(ptSapContext sap_ctx,
 				ch_count, ch);
 		}
 #else
-		list[ch_count] = CDS_CHANNEL_NUM(loop_count);
+		list[ch_count] = WLAN_REG_CH_NUM(loop_count);
 		ch_count++;
 #endif
 #ifdef FEATURE_WLAN_CH_AVOID
@@ -4837,14 +4849,14 @@ static QDF_STATUS sap_get_channel_list(ptSapContext sap_ctx,
  * Function for initializing list of  2.4/5 Ghz [NON-DFS/DFS]
  * available channels in the current regulatory domain.
  */
-static QDF_STATUS sap_get_5ghz_channel_list(ptSapContext sapContext)
+static QDF_STATUS sap_get_5ghz_channel_list(tpAniSirGlobal mac_ctx,
+		ptSapContext sapContext)
 {
 	uint8_t count = 0;
 	int i;
 	struct sir_pcl_list pcl;
 	QDF_STATUS status;
 	enum channel_state ch_state;
-	tpAniSirGlobal mac_ctx;
 	tHalHandle h_hal;
 
 	pcl.pcl_len = 0;
@@ -4856,7 +4868,6 @@ static QDF_STATUS sap_get_5ghz_channel_list(ptSapContext sapContext)
 		return QDF_STATUS_E_FAULT;
 	}
 
-	mac_ctx = PMAC_STRUCT(h_hal);
 	if (NULL == mac_ctx) {
 		QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
 		FL("Invalid MAC context"));
@@ -4899,8 +4910,9 @@ static QDF_STATUS sap_get_5ghz_channel_list(ptSapContext sapContext)
 		return status;
 	}
 	for (i = 0; i <= pcl.pcl_len; i++) {
-		if (CDS_IS_CHANNEL_5GHZ(pcl.pcl_list[i])) {
-			ch_state = cds_get_channel_state(pcl.pcl_list[i]);
+		if (WLAN_REG_IS_5GHZ_CH(pcl.pcl_list[i])) {
+			ch_state = wlan_reg_get_channel_state(mac_ctx->pdev,
+					pcl.pcl_list[i]);
 			if (!(ch_state == CHANNEL_STATE_ENABLE ||
 				ch_state == CHANNEL_STATE_DFS))
 				continue;
@@ -5206,12 +5218,13 @@ QDF_STATUS sap_init_dfs_channel_nol_list(ptSapContext sapContext)
 	}
 
 	for (i = CHAN_ENUM_36; i <= CHAN_ENUM_165; i++) {
-		if (CDS_CHANNEL_STATE(i) == CHANNEL_STATE_DFS) {
+		if (wlan_reg_get_channel_state(pMac->pdev, i) ==
+				CHANNEL_STATE_DFS) {
 			/* if dfs nol is not found, initialize it */
 			if (!bFound) {
 				pMac->sap.SapDfsInfo.sapDfsChannelNolList[count]
 				.dfs_channel_number =
-					CDS_CHANNEL_NUM(i);
+					WLAN_REG_CH_NUM(i);
 
 				QDF_TRACE(QDF_MODULE_ID_SAP,
 					  QDF_TRACE_LEVEL_INFO_LOW,

+ 1 - 1
core/sap/src/sap_internal.h

@@ -377,7 +377,7 @@ QDF_STATUS sap_acquire_global_lock(ptSapContext pSapCtx);
 QDF_STATUS sap_release_global_lock(ptSapContext pSapCtx);
 
 #ifdef FEATURE_WLAN_CH_AVOID
-void sap_update_unsafe_channel_list(ptSapContext pSapCtx);
+void sap_update_unsafe_channel_list(tHalHandle hal, ptSapContext pSapCtx);
 #endif /* FEATURE_WLAN_CH_AVOID */
 
 uint8_t

+ 26 - 15
core/sap/src/sap_module.c

@@ -56,6 +56,7 @@
 #include "cds_regdomain.h"
 #include "wlan_policy_mgr_api.h"
 #include <wlan_scan_ucfg_api.h>
+#include "wlan_reg_services_api.h"
 
 /*----------------------------------------------------------------------------
  * Preprocessor Definitions and Constants
@@ -1653,7 +1654,7 @@ static QDF_STATUS wlansap_update_csa_channel_params(ptSapContext sap_context,
 		for (; bw >= BW20; bw--) {
 			uint16_t op_class;
 
-			op_class = cds_reg_dmn_get_opclass_from_channel(
+			op_class = wlan_reg_dmn_get_opclass_from_channel(
 					mac_ctx->scan.countryCodeCurrent,
 					channel, bw);
 			if (!op_class)
@@ -1730,9 +1731,9 @@ wlansap_set_channel_change_with_csa(void *p_cds_gctx, uint32_t targetChannel,
 	 * current regulatory domain.
 	 */
 	if (sapContext->channel != targetChannel &&
-		((cds_get_channel_state(targetChannel) ==
+		((wlan_reg_get_channel_state(pMac->pdev, targetChannel) ==
 			CHANNEL_STATE_ENABLE) ||
-		(cds_get_channel_state(targetChannel) ==
+		(wlan_reg_get_channel_state(pMac->pdev, targetChannel) ==
 			CHANNEL_STATE_DFS &&
 		!policy_mgr_is_any_mode_active_on_band_along_with_session(
 			pMac->psoc, sapContext->sessionId,
@@ -1796,7 +1797,7 @@ wlansap_set_channel_change_with_csa(void *p_cds_gctx, uint32_t targetChannel,
 							new_ch_params.ch_width,
 							target_bw);
 			}
-			cds_set_channel_params(targetChannel,
+			wlan_reg_set_channel_params(pMac->pdev, targetChannel,
 				0, &pMac->sap.SapDfsInfo.new_ch_params);
 			/*
 			 * Set the CSA IE required flag.
@@ -2693,7 +2694,8 @@ wlansap_channel_change_request(void *pSapCtx, uint8_t target_channel)
 	 * which will result in channel width changing dynamically.
 	 */
 	ch_params = &mac_ctx->sap.SapDfsInfo.new_ch_params;
-	cds_set_channel_params(target_channel, 0, ch_params);
+	wlan_reg_set_channel_params(mac_ctx->pdev, target_channel,
+			0, ch_params);
 	sapContext->ch_params.ch_width = ch_params->ch_width;
 	/* Update the channel as this will be used to
 	 * send event to supplicant
@@ -2838,8 +2840,9 @@ QDF_STATUS wlansap_dfs_send_csa_ie_request(void *pSapCtx)
 
 	pMac->sap.SapDfsInfo.new_ch_params.ch_width =
 				pMac->sap.SapDfsInfo.new_chanWidth;
-	cds_set_channel_params(pMac->sap.SapDfsInfo.target_channel,
-				0, &pMac->sap.SapDfsInfo.new_ch_params);
+	wlan_reg_set_channel_params(pMac->pdev,
+			pMac->sap.SapDfsInfo.target_channel,
+			0, &pMac->sap.SapDfsInfo.new_ch_params);
 
 	QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
 			"%s: chan:%d req:%d width:%d off:%d",
@@ -3270,17 +3273,23 @@ wlansap_reset_sap_config_add_ie(tsap_Config_t *pConfig, eUpdateIEsType updateTyp
 
    SIDE EFFECTS
    ============================================================================*/
-void wlansap_extend_to_acs_range(uint8_t *startChannelNum,
-				 uint8_t *endChannelNum,
-				 uint8_t *bandStartChannel,
-				 uint8_t *bandEndChannel)
+void wlansap_extend_to_acs_range(tHalHandle hal, uint8_t *startChannelNum,
+		uint8_t *endChannelNum, uint8_t *bandStartChannel,
+		uint8_t *bandEndChannel)
 {
 #define ACS_WLAN_20M_CH_INC 4
 #define ACS_2G_EXTEND ACS_WLAN_20M_CH_INC
 #define ACS_5G_EXTEND (ACS_WLAN_20M_CH_INC * 3)
 
 	uint8_t tmp_startChannelNum = 0, tmp_endChannelNum = 0;
+	tpAniSirGlobal mac_ctx;
 
+	mac_ctx = PMAC_STRUCT(hal);
+	if (!mac_ctx) {
+		QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
+			"%s: Invalid mac_ctx", __func__);
+		return;
+	}
 	if (*startChannelNum <= 14 && *endChannelNum <= 14) {
 		*bandStartChannel = CHAN_ENUM_1;
 		*bandEndChannel = CHAN_ENUM_14;
@@ -3309,15 +3318,17 @@ void wlansap_extend_to_acs_range(uint8_t *startChannelNum,
 	* spikes in DFS specturm channels which is due to emission spill.
 	* Remove the active channels from extend ACS range for DFS only range
 	*/
-	if (CDS_IS_DFS_CH(*startChannelNum)) {
-		while (!CDS_IS_DFS_CH(tmp_startChannelNum) &&
+	if (wlan_reg_is_dfs_ch(mac_ctx->pdev, *startChannelNum)) {
+		while (!wlan_reg_is_dfs_ch(mac_ctx->pdev,
+					tmp_startChannelNum) &&
 			tmp_startChannelNum < *startChannelNum)
 			tmp_startChannelNum += ACS_WLAN_20M_CH_INC;
 
 		*startChannelNum = tmp_startChannelNum;
 	}
-	if (CDS_IS_DFS_CH(*endChannelNum)) {
-		while (!CDS_IS_DFS_CH(tmp_endChannelNum) &&
+	if (wlan_reg_is_dfs_ch(mac_ctx->pdev, *endChannelNum)) {
+		while (!wlan_reg_is_dfs_ch(mac_ctx->pdev,
+					tmp_endChannelNum) &&
 				 tmp_endChannelNum > *endChannelNum)
 			tmp_endChannelNum -= ACS_WLAN_20M_CH_INC;
 

+ 2 - 2
core/sme/inc/csr_api.h

@@ -267,7 +267,7 @@ typedef struct tagCsrStaParams {
 	uint8_t supported_channels_len;
 	uint8_t supported_channels[SIR_MAC_MAX_SUPP_CHANNELS];
 	uint8_t supported_oper_classes_len;
-	uint8_t supported_oper_classes[CDS_MAX_SUPP_OPER_CLASSES];
+	uint8_t supported_oper_classes[REG_MAX_SUPP_OPER_CLASSES];
 } tCsrStaParams;
 
 typedef struct tagCsrScanRequest {
@@ -1558,7 +1558,7 @@ typedef struct tagCsrLinkEstablishParams {
 	uint8_t supportedChannelsLen;
 	uint8_t supportedChannels[SIR_MAC_MAX_SUPP_CHANNELS];
 	uint8_t supportedOperClassesLen;
-	uint8_t supportedOperClasses[CDS_MAX_SUPP_OPER_CLASSES];
+	uint8_t supportedOperClasses[REG_MAX_SUPP_OPER_CLASSES];
 	uint8_t qos;
 } tCsrTdlsLinkEstablishParams;
 

+ 1 - 1
core/sme/inc/csr_internal.h

@@ -1146,7 +1146,7 @@ typedef struct tagCsrRoamStruct {
 	(CSR_IS_OPEARTING_DUAL_BAND((pMac)) || \
 		CSR_IS_RADIO_BG_ONLY((pMac)) || CSR_IS_24_BAND_ONLY((pMac)))
 #define CSR_GET_BAND(ch_num) \
-	((CDS_IS_CHANNEL_24GHZ(ch_num)) ? eCSR_BAND_24 : eCSR_BAND_5G)
+	((WLAN_REG_IS_24GHZ_CH(ch_num)) ? eCSR_BAND_24 : eCSR_BAND_5G)
 #define CSR_IS_11D_INFO_FOUND(pMac) \
 	(0 != (pMac)->scan.channelOf11dInfo)
 #define CSR_IS_ROAMING(pSession) \

+ 17 - 2
core/sme/inc/sme_api.h

@@ -41,7 +41,6 @@
 #include "qdf_lock.h"
 #include "qdf_types.h"
 #include "sir_api.h"
-#include "cds_reg_service.h"
 #include "p2p_api.h"
 #include "cds_regdomain.h"
 #include "sme_internal.h"
@@ -159,7 +158,7 @@ typedef struct _smeTdlsPeerStateParams {
 #define BW_40_OFFSET_BIT   1
 #define BW_80_OFFSET_BIT   2
 #define BW_160_OFFSET_BIT  3
-typedef struct sme_tdls_chan_switch_params_struct {
+typedef struct sme_tdls_chan_switch_param_struct {
 	uint32_t vdev_id;
 	tSirMacAddr peer_mac_addr;
 	uint16_t tdls_off_ch_bw_offset;/* Target Off Channel Bandwidth offset */
@@ -1470,4 +1469,20 @@ QDF_STATUS sme_register_set_connection_info_cb(tHalHandle hHal,
 				bool (*get_connection_info_cb)(uint8_t *session_id,
 				enum scan_reject_states *reason));
 
+/**
+ * sme_store_pdev() - store pdev
+ * @hal - MAC global handle
+ * @pdev - pdev ptr
+ *
+ * Return: QDF_STATUS
+ */
+void sme_store_pdev(tHalHandle hal, struct wlan_objmgr_pdev *pdev);
+
+/**
+ * sme_clear_pdev() - clear pdev
+ * @hal - MAC global handle
+ *
+ * Return: QDF_STATUS
+ */
+void sme_clear_pdev(tHalHandle hal);
 #endif /* #if !defined( __SME_API_H ) */

+ 1 - 1
core/sme/inc/sme_inside.h

@@ -115,7 +115,7 @@ typedef struct TdlsLinkEstablishInfo {
 	uint8_t supportedChannelsLen;
 	uint8_t supportedChannels[SIR_MAC_MAX_SUPP_CHANNELS];
 	uint8_t supportedOperClassesLen;
-	uint8_t supportedOperClasses[CDS_MAX_SUPP_OPER_CLASSES];
+	uint8_t supportedOperClasses[REG_MAX_SUPP_OPER_CLASSES];
 } tTdlsLinkEstablishCmdInfo;
 
 typedef struct TdlsAddStaInfo {

+ 67 - 26
core/sme/src/common/sme_api.c

@@ -61,6 +61,7 @@
 #include "sch_api.h"
 #include "sme_nan_datapath.h"
 #include "csr_api.h"
+#include "wlan_reg_services_api.h"
 
 #define LOG_SIZE 256
 
@@ -1707,7 +1708,8 @@ QDF_STATUS sme_set_plm_request(tHalHandle hHal, tpSirPlmReq pPlmReq)
 	for (count = 0; count < pPlmReq->plmNumCh; count++) {
 		ret = csr_is_supported_channel(pMac, pPlmReq->plmChList[count]);
 		if (ret && pPlmReq->plmChList[count] > 14) {
-			if (CHANNEL_STATE_DFS == cds_get_channel_state(
+			if (CHANNEL_STATE_DFS == wlan_reg_get_channel_state(
+						pMac->pdev,
 						pPlmReq->plmChList[count])) {
 				/* DFS channel is provided, no PLM bursts can be
 				 * transmitted. Ignoring these channels.
@@ -6789,7 +6791,8 @@ QDF_STATUS sme_handle_change_country_code(tpAniSirGlobal pMac, void *pMsgBuf)
 		pMac->roam.configParam.Is11dSupportEnabled =
 			pMac->roam.configParam.Is11dSupportEnabledOriginal;
 
-		qdf_status = cds_read_default_country(default_country);
+		qdf_status = wlan_reg_read_default_country(pMac->psoc,
+				default_country);
 
 		/* read the country code and use it */
 		if (QDF_IS_STATUS_SUCCESS(qdf_status)) {
@@ -6853,11 +6856,9 @@ QDF_STATUS sme_handle_change_country_code(tpAniSirGlobal pMac, void *pMsgBuf)
 		sme_warn("Country Code unrecognized by driver");
 	}
 
-	status = wma_set_reg_domain(pMac, domainIdIoctl);
-
-	if (status != QDF_STATUS_SUCCESS) {
-		sme_err("fail to set regId %d", domainIdIoctl);
-		return status;
+	if (domainIdIoctl >= REGDOMAIN_COUNT) {
+		sme_err("Invalid regId %d", domainIdIoctl);
+		return QDF_STATUS_E_FAILURE;
 	} else {
 		/* if 11d has priority, clear currentCountryBssid & countryCode11d to get */
 		/* set again if we find AP with 11d info during scan */
@@ -7780,7 +7781,7 @@ QDF_STATUS sme_ext_change_channel(tHalHandle h_hal, uint32_t channel,
 
 	sme_err("Set Channel: %d", channel);
 	channel_state =
-		cds_get_channel_state(channel);
+		wlan_reg_get_channel_state(mac_ctx->pdev, channel);
 
 	if (CHANNEL_STATE_DISABLE == channel_state) {
 		sme_err("Invalid channel: %d", channel);
@@ -9629,14 +9630,14 @@ QDF_STATUS sme_update_tdls_peer_state(tHalHandle hHal,
 		for (i = 0; i < peerStateParams->peerCap.peerChanLen; i++) {
 			chanId = peerStateParams->peerCap.peerChan[i];
 			if (csr_roam_is_channel_valid(pMac, chanId) &&
-			    !(cds_get_channel_state(chanId) ==
+			    !(wlan_reg_get_channel_state(pMac->pdev, chanId) ==
 			      CHANNEL_STATE_DFS) &&
-			    !cds_is_dsrc_channel(cds_chan_to_freq(chanId))) {
+			    !WLAN_REG_IS_11P_CH(chanId)) {
 				peer_cap->peerChan[num].chanId = chanId;
 				peer_cap->peerChan[num].pwr =
 					csr_get_cfg_max_tx_power(pMac, chanId);
 				peer_cap->peerChan[num].dfsSet = false;
-			num++;
+				num++;
 			}
 		}
 	} else {
@@ -12377,6 +12378,7 @@ QDF_STATUS sme_get_valid_channels_by_band(tHalHandle hHal,
 	uint8_t numChannels = 0;
 	uint8_t i = 0;
 	uint32_t totValidChannels = WNI_CFG_VALID_CHANNEL_LIST_LEN;
+	tpAniSirGlobal mac_ctx = PMAC_STRUCT(hHal);
 
 	if (!aValidChannels || !pNumChannels) {
 		sme_err("Output channel list/NumChannels is NULL");
@@ -12408,7 +12410,7 @@ QDF_STATUS sme_get_valid_channels_by_band(tHalHandle hHal,
 	case WIFI_BAND_BG:
 		sme_debug("WIFI_BAND_BG (2.4 GHz)");
 		for (i = 0; i < totValidChannels; i++) {
-			if (CDS_IS_CHANNEL_24GHZ(chanList[i])) {
+			if (WLAN_REG_IS_24GHZ_CH(chanList[i])) {
 				aValidChannels[numChannels++] =
 					cds_chan_to_freq(chanList[i]);
 			}
@@ -12418,8 +12420,8 @@ QDF_STATUS sme_get_valid_channels_by_band(tHalHandle hHal,
 	case WIFI_BAND_A:
 		sme_debug("WIFI_BAND_A (5 GHz without DFS)");
 		for (i = 0; i < totValidChannels; i++) {
-			if (CDS_IS_CHANNEL_5GHZ(chanList[i]) &&
-			    !CDS_IS_DFS_CH(chanList[i])) {
+			if (WLAN_REG_IS_5GHZ_CH(chanList[i]) &&
+			    !wlan_reg_is_dfs_ch(mac_ctx->pdev, chanList[i])) {
 				aValidChannels[numChannels++] =
 					cds_chan_to_freq(chanList[i]);
 			}
@@ -12429,9 +12431,9 @@ QDF_STATUS sme_get_valid_channels_by_band(tHalHandle hHal,
 	case WIFI_BAND_ABG:
 		sme_debug("WIFI_BAND_ABG (2.4 GHz + 5 GHz; no DFS)");
 		for (i = 0; i < totValidChannels; i++) {
-			if ((CDS_IS_CHANNEL_24GHZ(chanList[i]) ||
-			     CDS_IS_CHANNEL_5GHZ(chanList[i])) &&
-			    !CDS_IS_DFS_CH(chanList[i])) {
+			if ((WLAN_REG_IS_24GHZ_CH(chanList[i]) ||
+			     WLAN_REG_IS_5GHZ_CH(chanList[i])) &&
+			    !wlan_reg_is_dfs_ch(mac_ctx->pdev, chanList[i])) {
 				aValidChannels[numChannels++] =
 					cds_chan_to_freq(chanList[i]);
 			}
@@ -12441,8 +12443,8 @@ QDF_STATUS sme_get_valid_channels_by_band(tHalHandle hHal,
 	case WIFI_BAND_A_DFS_ONLY:
 		sme_debug("WIFI_BAND_A_DFS (5 GHz DFS only)");
 		for (i = 0; i < totValidChannels; i++) {
-			if (CDS_IS_CHANNEL_5GHZ(chanList[i]) &&
-			    CDS_IS_DFS_CH(chanList[i])) {
+			if (WLAN_REG_IS_5GHZ_CH(chanList[i]) &&
+			    wlan_reg_is_dfs_ch(mac_ctx->pdev, chanList[i])) {
 				aValidChannels[numChannels++] =
 					cds_chan_to_freq(chanList[i]);
 			}
@@ -12452,7 +12454,7 @@ QDF_STATUS sme_get_valid_channels_by_band(tHalHandle hHal,
 	case WIFI_BAND_A_WITH_DFS:
 		sme_debug("WIFI_BAND_A_WITH_DFS (5 GHz with DFS)");
 		for (i = 0; i < totValidChannels; i++) {
-			if (CDS_IS_CHANNEL_5GHZ(chanList[i])) {
+			if (WLAN_REG_IS_5GHZ_CH(chanList[i])) {
 				aValidChannels[numChannels++] =
 					cds_chan_to_freq(chanList[i]);
 			}
@@ -12462,8 +12464,8 @@ QDF_STATUS sme_get_valid_channels_by_band(tHalHandle hHal,
 	case WIFI_BAND_ABG_WITH_DFS:
 		sme_debug("WIFI_BAND_ABG_WITH_DFS (2.4 GHz+5 GHz with DFS)");
 		for (i = 0; i < totValidChannels; i++) {
-			if (CDS_IS_CHANNEL_24GHZ(chanList[i]) ||
-			    CDS_IS_CHANNEL_5GHZ(chanList[i])) {
+			if (WLAN_REG_IS_24GHZ_CH(chanList[i]) ||
+			    WLAN_REG_IS_5GHZ_CH(chanList[i])) {
 				aValidChannels[numChannels++] =
 					cds_chan_to_freq(chanList[i]);
 			}
@@ -14863,20 +14865,20 @@ void sme_get_opclass(tHalHandle hal, uint8_t channel, uint8_t bw_offset,
 	 * matching 20MHz, else for any BW.
 	 */
 	if (bw_offset & (1 << BW_40_OFFSET_BIT)) {
-		*opclass = cds_reg_dmn_get_opclass_from_channel(
+		*opclass = wlan_reg_dmn_get_opclass_from_channel(
 				mac_ctx->scan.countryCodeCurrent,
 				channel, BW40_LOW_PRIMARY);
 		if (!(*opclass)) {
-			*opclass = cds_reg_dmn_get_opclass_from_channel(
+			*opclass = wlan_reg_dmn_get_opclass_from_channel(
 					mac_ctx->scan.countryCodeCurrent,
 					channel, BW40_HIGH_PRIMARY);
 		}
 	} else if (bw_offset & (1 << BW_20_OFFSET_BIT)) {
-		*opclass = cds_reg_dmn_get_opclass_from_channel(
+		*opclass = wlan_reg_dmn_get_opclass_from_channel(
 				mac_ctx->scan.countryCodeCurrent,
 				channel, BW20);
 	} else {
-		*opclass = cds_reg_dmn_get_opclass_from_channel(
+		*opclass = wlan_reg_dmn_get_opclass_from_channel(
 				mac_ctx->scan.countryCodeCurrent,
 				channel, BWALL);
 	}
@@ -16141,3 +16143,42 @@ QDF_STATUS sme_rso_cmd_status_cb(tHalHandle hal,
 	sms_log(mac, LOG1, FL("Registered RSO command status callback"));
 	return status;
 }
+
+void sme_store_pdev(tHalHandle hal, struct wlan_objmgr_pdev *pdev)
+{
+	tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
+	void *wma_handle;
+	QDF_STATUS status;
+
+	status = wlan_objmgr_pdev_try_get_ref(pdev, WLAN_LEGACY_SME_ID);
+	if (QDF_STATUS_SUCCESS != status) {
+		mac_ctx->pdev = NULL;
+		return;
+	}
+	mac_ctx->pdev = pdev;
+	wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
+	if (!wma_handle) {
+		QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
+				"wma handle is NULL");
+		return;
+	}
+	wma_store_pdev(wma_handle, pdev);
+}
+
+void sme_clear_pdev(tHalHandle hal)
+{
+	tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
+	void *wma_handle;
+
+	if (mac_ctx->pdev) {
+		wlan_objmgr_pdev_release_ref(mac_ctx->pdev, WLAN_LEGACY_SME_ID);
+		mac_ctx->pdev = NULL;
+	}
+	wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
+	if (!wma_handle) {
+		QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
+				"wma handle is NULL");
+		return;
+	}
+	wma_clear_pdev(wma_handle);
+}

+ 77 - 76
core/sme/src/csr/csr_api_roam.c

@@ -56,6 +56,7 @@
 #include "wlan_policy_mgr_api.h"
 #include "sme_nan_datapath.h"
 #include "pld_common.h"
+#include "wlan_reg_services_api.h"
 #include <wlan_logging_sock_svc.h>
 #include "wlan_objmgr_psoc_obj.h"
 #include <wlan_scan_ucfg_api.h>
@@ -392,11 +393,9 @@ QDF_STATUS csr_set_reg_info(tHalHandle hHal, uint8_t *apCntryCode)
 			apCntryCode);
 		return status;
 	}
-	status = wma_set_reg_domain(hHal, regId);
-	if (status != QDF_STATUS_SUCCESS) {
-		sme_err("fail to get regId for country Code %.2s",
-			apCntryCode);
-		return status;
+	if (regId >= REGDOMAIN_COUNT) {
+		sme_err("Invalid regId for country Code %.2s", apCntryCode);
+		return QDF_STATUS_E_FAILURE;
 	}
 	pMac->scan.domainIdDefault = regId;
 	pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
@@ -508,8 +507,9 @@ static void csr_roam_arrange_ch_list(tpAniSirGlobal mac_ctx,
 
 	/* Fist copy Non-DFS 5g channels */
 	for (i = 0; i < num_channel; i++) {
-		if (CDS_IS_CHANNEL_5GHZ(chan_list[i].chanId) &&
-			!CDS_IS_DFS_CH(chan_list[i].chanId)) {
+		if (WLAN_REG_IS_5GHZ_CH(chan_list[i].chanId) &&
+			!wlan_reg_is_dfs_ch(mac_ctx->pdev,
+				chan_list[i].chanId)) {
 			qdf_mem_copy(&tmp_list[j++],
 				&chan_list[i], sizeof(tSirUpdateChanParam));
 			chan_list[i].chanId = INVALID_CHANNEL_ID;
@@ -518,7 +518,7 @@ static void csr_roam_arrange_ch_list(tpAniSirGlobal mac_ctx,
 	if (prefer_dfs) {
 		/* next copy DFS channels (remaining channels in 5G) */
 		for (i = 0; i < num_channel; i++) {
-			if (CDS_IS_CHANNEL_5GHZ(chan_list[i].chanId)) {
+			if (WLAN_REG_IS_5GHZ_CH(chan_list[i].chanId)) {
 				qdf_mem_copy(&tmp_list[j++], &chan_list[i],
 					sizeof(tSirUpdateChanParam));
 				chan_list[i].chanId = INVALID_CHANNEL_ID;
@@ -527,7 +527,7 @@ static void csr_roam_arrange_ch_list(tpAniSirGlobal mac_ctx,
 	} else {
 		/* next copy 2G channels */
 		for (i = 0; i < num_channel; i++) {
-			if (CDS_IS_CHANNEL_24GHZ(chan_list[i].chanId)) {
+			if (WLAN_REG_IS_24GHZ_CH(chan_list[i].chanId)) {
 				qdf_mem_copy(&tmp_list[j++], &chan_list[i],
 					sizeof(tSirUpdateChanParam));
 				chan_list[i].chanId = INVALID_CHANNEL_ID;
@@ -679,12 +679,12 @@ scan_list_sort_error:
 static QDF_STATUS csr_emu_chan_req(uint32_t channel)
 {
 	int i;
-	if (CDS_IS_CHANNEL_24GHZ(channel)) {
+	if (WLAN_REG_IS_24GHZ_CH(channel)) {
 		for (i = 0; i < QDF_ARRAY_SIZE(csr_start_ibss_channels24); i++) {
 			if (csr_start_ibss_channels24[i] == channel)
 				return QDF_STATUS_SUCCESS;
 		}
-	} else if (CDS_IS_CHANNEL_5GHZ(channel)) {
+	} else if (WLAN_REG_IS_5GHZ_CH(channel)) {
 		for (i = 0; i < QDF_ARRAY_SIZE(csr_start_ibss_channels50); i++) {
 			if (csr_start_ibss_channels50[i] == channel)
 				return QDF_STATUS_SUCCESS;
@@ -727,7 +727,8 @@ QDF_STATUS csr_update_channel_list(tpAniSirGlobal pMac)
 
 	if (CSR_IS_5G_BAND_ONLY(pMac)) {
 		for (i = 0; i < MAX_SOCIAL_CHANNELS; i++) {
-			if (cds_get_channel_state(social_channel[i])
+			if (wlan_reg_get_channel_state(pMac->pdev,
+						social_channel[i])
 			    == CHANNEL_STATE_ENABLE)
 				numChan++;
 		}
@@ -758,8 +759,7 @@ QDF_STATUS csr_update_channel_list(tpAniSirGlobal pMac)
 
 		channel = pScan->base_channels.channelList[i];
 
-		channel_state =
-			cds_get_channel_state(
+		channel_state = wlan_reg_get_channel_state(pMac->pdev,
 				pScan->base_channels.channelList[i]);
 		if ((CHANNEL_STATE_ENABLE == channel_state) ||
 		    pMac->scan.fEnableDFSChnlScan) {
@@ -783,10 +783,10 @@ QDF_STATUS csr_update_channel_list(tpAniSirGlobal pMac)
 					}
 				}
 				if ((is_unsafe_chan) &&
-				    ((CDS_IS_CHANNEL_24GHZ(channel) &&
+				    ((WLAN_REG_IS_24GHZ_CH(channel) &&
 				      roam_policy->sap_operating_band ==
 					eCSR_BAND_24) ||
-					(CDS_IS_CHANNEL_5GHZ(channel) &&
+					(WLAN_REG_IS_5GHZ_CH(channel) &&
 					 roam_policy->sap_operating_band ==
 					eCSR_BAND_5G))) {
 					QDF_TRACE(QDF_MODULE_ID_SME,
@@ -846,7 +846,8 @@ QDF_STATUS csr_update_channel_list(tpAniSirGlobal pMac)
 
 	if (CSR_IS_5G_BAND_ONLY(pMac)) {
 		for (j = 0; j < MAX_SOCIAL_CHANNELS; j++) {
-			if (cds_get_channel_state(social_channel[j])
+			if (wlan_reg_get_channel_state(pMac->pdev,
+						social_channel[j])
 			    != CHANNEL_STATE_ENABLE)
 				continue;
 			pChanList->chanParam[num_channel].chanId =
@@ -1635,7 +1636,7 @@ QDF_STATUS csr_create_roam_scan_channel_list(tpAniSirGlobal pMac,
 	}
 	if (eCSR_BAND_24 == eBand) {
 		for (i = 0; i < inNumChannels; i++) {
-			if (CDS_IS_CHANNEL_24GHZ(inPtr[i])
+			if (WLAN_REG_IS_24GHZ_CH(inPtr[i])
 			    && csr_roam_is_channel_valid(pMac, inPtr[i])) {
 				ChannelList[outNumChannels++] = inPtr[i];
 			}
@@ -1643,16 +1644,16 @@ QDF_STATUS csr_create_roam_scan_channel_list(tpAniSirGlobal pMac,
 	} else if (eCSR_BAND_5G == eBand) {
 		for (i = 0; i < inNumChannels; i++) {
 			/* Add 5G Non-DFS channel */
-			if (CDS_IS_CHANNEL_5GHZ(inPtr[i]) &&
+			if (WLAN_REG_IS_5GHZ_CH(inPtr[i]) &&
 			    csr_roam_is_channel_valid(pMac, inPtr[i]) &&
-			    !CDS_IS_DFS_CH(inPtr[i])) {
+			    !wlan_reg_is_dfs_ch(pMac->pdev, inPtr[i])) {
 				ChannelList[outNumChannels++] = inPtr[i];
 			}
 		}
 	} else if (eCSR_BAND_ALL == eBand) {
 		for (i = 0; i < inNumChannels; i++) {
 			if (csr_roam_is_channel_valid(pMac, inPtr[i]) &&
-			    !CDS_IS_DFS_CH(inPtr[i])) {
+			    !wlan_reg_is_dfs_ch(pMac->pdev, inPtr[i])) {
 				ChannelList[outNumChannels++] = inPtr[i];
 			}
 		}
@@ -1898,7 +1899,7 @@ csr_fetch_ch_lst_from_received_list(tpAniSirGlobal mac_ctx,
 		if ((!mac_ctx->roam.configParam.allowDFSChannelRoam ||
 		    (mac_ctx->roam.configParam.sta_roam_policy.dfs_mode ==
 			 CSR_STA_ROAM_POLICY_DFS_DISABLED)) &&
-		     (CDS_IS_DFS_CH(*ch_lst))) {
+		     (wlan_reg_is_dfs_ch(mac_ctx->pdev, *ch_lst))) {
 			QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
 				("ignoring dfs channel %d"), *ch_lst);
 			ch_lst++;
@@ -3181,13 +3182,13 @@ static void csr_prune_ch_list(tCsrChannel *ch_lst, bool is_24_GHz)
 	uint8_t idx = 0, num_channels = 0;
 	for ( ; idx < ch_lst->numChannels; idx++) {
 		if (is_24_GHz) {
-			if (CDS_IS_CHANNEL_24GHZ(ch_lst->channelList[idx])) {
+			if (WLAN_REG_IS_24GHZ_CH(ch_lst->channelList[idx])) {
 				ch_lst->channelList[num_channels] =
 					ch_lst->channelList[idx];
 				num_channels++;
 			}
 		} else {
-			if (CDS_IS_CHANNEL_5GHZ(ch_lst->channelList[idx])) {
+			if (WLAN_REG_IS_5GHZ_CH(ch_lst->channelList[idx])) {
 				ch_lst->channelList[num_channels] =
 					ch_lst->channelList[idx];
 				num_channels++;
@@ -3287,9 +3288,9 @@ QDF_STATUS csr_get_channel_and_power_list(tpAniSirGlobal pMac)
 	QDF_STATUS qdf_status;
 	uint8_t Index = 0;
 
-	qdf_status =
-		cds_get_channel_list_with_power(pMac->scan.defaultPowerTable,
-						&num20MHzChannelsFound);
+	qdf_status = wlan_reg_get_channel_list_with_power(pMac->pdev,
+				pMac->scan.defaultPowerTable,
+				&num20MHzChannelsFound);
 
 	if ((QDF_STATUS_SUCCESS != qdf_status) ||
 	    (num20MHzChannelsFound == 0)) {
@@ -4188,7 +4189,7 @@ QDF_STATUS csr_roam_prepare_bss_config(tpAniSirGlobal pMac,
 			return QDF_STATUS_E_FAILURE;
 		}
 	}
-	if (CDS_IS_CHANNEL_5GHZ(pBssDesc->channelId))
+	if (WLAN_REG_IS_5GHZ_CH(pBssDesc->channelId))
 		pBssConfig->eBand = eCSR_BAND_5G;
 	else
 		pBssConfig->eBand = eCSR_BAND_24;
@@ -5032,11 +5033,11 @@ QDF_STATUS csr_roam_set_bss_config_cfg(tpAniSirGlobal pMac, uint32_t sessionId,
 		}
 	}
 	if (0 != channel) {
-		if (CDS_IS_CHANNEL_24GHZ(channel)) {    /* for now if we are on 2.4 Ghz, CB will be always disabled */
+		/* for now if we are on 2.4 Ghz, CB will be always disabled */
+		if (WLAN_REG_IS_24GHZ_CH(channel))
 			cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
-		} else {
+		else
 			cfgCb = pBssConfig->cbMode;
-		}
 	}
 	/* Rate */
 	/* Fixed Rate */
@@ -12183,7 +12184,7 @@ csr_compute_mode_and_band(tpAniSirGlobal mac_ctx,
 			 * If the operating channel is in 2.4 GHz band, check
 			 * for INI item to disable VHT operation in 2.4 GHz band
 			 */
-			if (CDS_IS_CHANNEL_24GHZ(opr_ch) && !vht_24_ghz)
+			if (WLAN_REG_IS_24GHZ_CH(opr_ch) && !vht_24_ghz)
 				/* Disable 11AC operation */
 				*dot11_mode = eCSR_CFG_DOT11_MODE_11N;
 			else
@@ -12199,7 +12200,7 @@ csr_compute_mode_and_band(tpAniSirGlobal mac_ctx,
 			 * If the operating channel is in 2.4 GHz band, check
 			 * for INI item to disable VHT operation in 2.4 GHz band
 			 */
-			if (CDS_IS_CHANNEL_24GHZ(opr_ch) && !vht_24_ghz)
+			if (WLAN_REG_IS_24GHZ_CH(opr_ch) && !vht_24_ghz)
 				/* Disable 11AC operation */
 				*dot11_mode = eCSR_CFG_DOT11_MODE_11N;
 			else
@@ -12218,7 +12219,7 @@ csr_compute_mode_and_band(tpAniSirGlobal mac_ctx,
 			 * If the operating channel is in 2.4 GHz band, check
 			 * for INI item to disable VHT operation in 2.4 GHz band
 			 */
-			if (CDS_IS_CHANNEL_24GHZ(opr_ch) && !vht_24_ghz)
+			if (WLAN_REG_IS_24GHZ_CH(opr_ch) && !vht_24_ghz)
 				/* Disable 11AC operation */
 				*dot11_mode = eCSR_CFG_DOT11_MODE_11N;
 			else
@@ -12237,7 +12238,7 @@ csr_compute_mode_and_band(tpAniSirGlobal mac_ctx,
 			 * check for INI item to disable VHT operation
 			 * in 2.4 GHz band
 			 */
-			if (CDS_IS_CHANNEL_24GHZ(opr_ch)
+			if (WLAN_REG_IS_24GHZ_CH(opr_ch)
 				&& !vht_24_ghz)
 				/* Disable 11AC operation */
 				*dot11_mode = eCSR_CFG_DOT11_MODE_11N;
@@ -12257,7 +12258,7 @@ csr_compute_mode_and_band(tpAniSirGlobal mac_ctx,
 			*band = mac_ctx->roam.configParam.eBand;
 			if (eCSR_BAND_24 == *band) {
 				/*
-				 * See reason in else if ( CDS_IS_CHANNEL_24GHZ
+				 * See reason in else if ( WLAN_REG_IS_24GHZ_CH
 				 * (opr_ch) ) to pick 11B
 				 */
 				*dot11_mode = eCSR_CFG_DOT11_MODE_11B;
@@ -12266,7 +12267,7 @@ csr_compute_mode_and_band(tpAniSirGlobal mac_ctx,
 				*band = eCSR_BAND_5G;
 				*dot11_mode = eCSR_CFG_DOT11_MODE_11A;
 			}
-		} else if (CDS_IS_CHANNEL_24GHZ(opr_ch)) {
+		} else if (WLAN_REG_IS_24GHZ_CH(opr_ch)) {
 			/*
 			 * WiFi tests require IBSS networks to start in 11b mode
 			 * without any change to the default parameter settings
@@ -12372,7 +12373,7 @@ csr_roam_get_phy_mode_band_for_bss(tpAniSirGlobal mac_ctx,
 		&& ((eCSR_CFG_DOT11_MODE_11N == cfg_dot11_mode) ||
 	     (eCSR_CFG_DOT11_MODE_11AC == cfg_dot11_mode))) {
 		/* We cannot do 11n here */
-		if (CDS_IS_CHANNEL_24GHZ(opr_chn))
+		if (WLAN_REG_IS_24GHZ_CH(opr_chn))
 			cfg_dot11_mode = eCSR_CFG_DOT11_MODE_11G;
 		else
 			cfg_dot11_mode = eCSR_CFG_DOT11_MODE_11A;
@@ -12428,7 +12429,7 @@ QDF_STATUS csr_get_cfg_valid_channels(tpAniSirGlobal pMac, uint8_t *pChannels,
 		return QDF_STATUS_E_FAILURE;
 
 	for (i = 0; i < *pNumChan; i++) {
-		if (!cds_is_dsrc_channel(cds_chan_to_freq(pChannels[i]))) {
+		if (!WLAN_REG_IS_11P_CH(pChannels[i])) {
 			pChannels[num_chan_temp] = pChannels[i];
 			num_chan_temp++;
 		}
@@ -12449,10 +12450,10 @@ int8_t csr_get_cfg_max_tx_power(tpAniSirGlobal pMac, uint8_t channel)
 	uint8_t firstChannel;
 	uint8_t maxChannels;
 
-	if (CDS_IS_CHANNEL_5GHZ(channel)) {
+	if (WLAN_REG_IS_5GHZ_CH(channel)) {
 		cfgId = WNI_CFG_MAX_TX_POWER_5;
 		cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
-	} else if (CDS_IS_CHANNEL_24GHZ(channel)) {
+	} else if (WLAN_REG_IS_24GHZ_CH(channel)) {
 		cfgId = WNI_CFG_MAX_TX_POWER_2_4;
 		cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
 	} else
@@ -12521,7 +12522,7 @@ static ePhyChanBondState csr_get_cb_mode_from_ies(tpAniSirGlobal pMac,
 	ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
 	uint8_t centerChn;
 	uint32_t ChannelBondingMode;
-	if (CDS_IS_CHANNEL_24GHZ(primaryChn)) {
+	if (WLAN_REG_IS_24GHZ_CH(primaryChn)) {
 		ChannelBondingMode =
 			pMac->roam.configParam.channelBondingMode24GHz;
 	} else {
@@ -12765,7 +12766,7 @@ static uint8_t csr_roam_get_ibss_start_channel_number50(tpAniSirGlobal pMac)
 		if (!fFound) {
 			for (idxValidChannels = 0; idxValidChannels < len;
 			     idxValidChannels++) {
-				if (CDS_IS_CHANNEL_5GHZ(pMac->roam.
+				if (WLAN_REG_IS_5GHZ_CH(pMac->roam.
 					validChannelList[idxValidChannels])) {
 					/* the max channel# in 11g is 14 */
 					if (idxValidChannels <
@@ -13308,7 +13309,7 @@ void csr_roam_prepare_bss_params(tpAniSirGlobal pMac, uint32_t sessionId,
 						       &pSession->bssParams.
 						       operationalRateSet);
 		if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS(pProfile)) {
-			if (CDS_IS_CHANNEL_24GHZ(Channel)) {
+			if (WLAN_REG_IS_24GHZ_CH(Channel)) {
 				cbMode =
 					pMac->roam.configParam.
 					channelBondingMode24GHz;
@@ -13871,7 +13872,7 @@ static void csr_add_supported_5Ghz_channels(tpAniSirGlobal mac_ctx,
 				&size))) {
 		for (i = 0, j = 0; i < size; i++) {
 			/* Only add 5ghz channels.*/
-			if (CDS_IS_CHANNEL_5GHZ
+			if (WLAN_REG_IS_5GHZ_CH
 					(mac_ctx->roam.validChannelList[i])) {
 				chan_list[j]
 					= mac_ctx->roam.validChannelList[i];
@@ -14008,7 +14009,7 @@ QDF_STATUS csr_send_join_req_msg(tpAniSirGlobal pMac, uint32_t sessionId,
 	}
 	neigh_roam_info = &pMac->roam.neighborRoamInfo[sessionId];
 	if ((eWNI_SME_REASSOC_REQ == messageType) ||
-		CDS_IS_CHANNEL_5GHZ(pBssDescription->channelId) ||
+		WLAN_REG_IS_5GHZ_CH(pBssDescription->channelId) ||
 		(abs(pBssDescription->rssi) <
 		 (neigh_roam_info->cfgParams.neighborLookupThreshold -
 		  neigh_roam_info->cfgParams.hi_rssi_scan_rssi_delta))) {
@@ -14443,11 +14444,11 @@ QDF_STATUS csr_send_join_req_msg(tpAniSirGlobal pMac, uint32_t sessionId,
 		csr_join_req->txLdpcIniFeatureEnabled =
 			(uint8_t) pMac->roam.configParam.txLdpcEnable;
 
-		if ((csr_is11h_supported(pMac))
-		    && (CDS_IS_CHANNEL_5GHZ(pBssDescription->channelId))
-		    && (pIes->Country.present)
-		    && (!pMac->roam.configParam.
-			fSupplicantCountryCodeHasPriority)) {
+		if ((csr_is11h_supported(pMac)) &&
+			(WLAN_REG_IS_5GHZ_CH(pBssDescription->channelId)) &&
+			(pIes->Country.present) &&
+			(!pMac->roam.configParam.
+			 fSupplicantCountryCodeHasPriority)) {
 			csr_save_to_channel_power2_g_5_g(pMac,
 				pIes->Country.num_triplets *
 				sizeof(tSirMacChanInfo),
@@ -14643,18 +14644,17 @@ QDF_STATUS csr_send_join_req_msg(tpAniSirGlobal pMac, uint32_t sessionId,
 		 * same as STA's channel.
 		 */
 		if (pMac->roam.configParam.conc_custom_rule1) {
-			if ((0 ==
-			     pMac->
-			      roam.configParam.is_sta_connection_in_5gz_enabled)
-			     && CDS_IS_CHANNEL_5GHZ(pBssDescription->
-							channelId)) {
+			if ((0 == pMac->roam.configParam.
+				is_sta_connection_in_5gz_enabled) &&
+				WLAN_REG_IS_5GHZ_CH(pBssDescription->
+					channelId)) {
 				QDF_TRACE(QDF_MODULE_ID_SME,
 					  QDF_TRACE_LEVEL_ERROR,
 					 "STA-conn on 5G isn't allowed");
 				status = QDF_STATUS_E_FAILURE;
 				break;
 			}
-			if (!CDS_IS_CHANNEL_5GHZ(pBssDescription->channelId) &&
+			if (!WLAN_REG_IS_5GHZ_CH(pBssDescription->channelId) &&
 				(false == csr_is_conn_allow_2g_band(pMac,
 						pBssDescription->channelId))) {
 				status = QDF_STATUS_E_FAILURE;
@@ -14669,13 +14669,12 @@ QDF_STATUS csr_send_join_req_msg(tpAniSirGlobal pMac, uint32_t sessionId,
 		 * condition we are just adding sanity check to make sure that
 		 * by this time P2PGO's channel is same as STA's channel.
 		 */
-		if (pMac->roam.configParam.conc_custom_rule2) {
-			if (!CDS_IS_CHANNEL_24GHZ(pBssDescription->channelId) &&
-				(false == csr_is_conn_allow_5g_band(pMac,
-				pBssDescription->channelId))) {
-					status = QDF_STATUS_E_FAILURE;
-					break;
-			}
+		if (pMac->roam.configParam.conc_custom_rule2 &&
+			!WLAN_REG_IS_24GHZ_CH(pBssDescription->channelId) &&
+			(!csr_is_conn_allow_5g_band(pMac,
+						pBssDescription->channelId))) {
+			status = QDF_STATUS_E_FAILURE;
+			break;
 		}
 		status = umac_send_mb_message_to_mac(csr_join_req);
 		if (!QDF_IS_STATUS_SUCCESS(status)) {
@@ -16941,10 +16940,10 @@ csr_check_band_channel_match(eCsrBand band, uint8_t channel)
 	if (eCSR_BAND_ALL == band)
 		return true;
 
-	if (eCSR_BAND_24 == band && CDS_IS_CHANNEL_24GHZ(channel))
+	if (eCSR_BAND_24 == band && WLAN_REG_IS_24GHZ_CH(channel))
 		return true;
 
-	if (eCSR_BAND_5G == band && CDS_IS_CHANNEL_5GHZ(channel))
+	if (eCSR_BAND_5G == band && WLAN_REG_IS_5GHZ_CH(channel))
 		return true;
 
 	return false;
@@ -17003,7 +17002,7 @@ csr_fetch_ch_lst_from_ini(tpAniSirGlobal mac_ctx,
 		if ((!mac_ctx->roam.configParam.allowDFSChannelRoam ||
 		    (mac_ctx->roam.configParam.sta_roam_policy.dfs_mode ==
 			 CSR_STA_ROAM_POLICY_DFS_DISABLED)) &&
-		     (CDS_IS_DFS_CH(*ch_lst))) {
+		     (wlan_reg_is_dfs_ch(mac_ctx->pdev, *ch_lst))) {
 			QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
 				("ignoring dfs channel %d"), *ch_lst);
 			ch_lst++;
@@ -17084,7 +17083,7 @@ csr_fetch_ch_lst_from_occupied_lst(tpAniSirGlobal mac_ctx,
 		if ((!mac_ctx->roam.configParam.allowDFSChannelRoam ||
 		    (mac_ctx->roam.configParam.sta_roam_policy.dfs_mode ==
 			 CSR_STA_ROAM_POLICY_DFS_DISABLED)) &&
-		     (CDS_IS_DFS_CH(*ch_lst))) {
+		     (wlan_reg_is_dfs_ch(mac_ctx->pdev, *ch_lst))) {
 			QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
 				("ignoring dfs channel %d"), *ch_lst);
 			ch_lst++;
@@ -17116,7 +17115,9 @@ csr_fetch_ch_lst_from_occupied_lst(tpAniSirGlobal mac_ctx,
 			QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
 				"DFSRoam=%d, ChnlState=%d, Chnl=%d, num_ch=%d",
 				mac_ctx->roam.configParam.allowDFSChannelRoam,
-				cds_get_channel_state(*ch_lst), *ch_lst,
+				wlan_reg_get_channel_state(mac_ctx->pdev,
+					*ch_lst),
+				*ch_lst,
 				num_channels);
 		ch_lst++;
 	}
@@ -17186,7 +17187,7 @@ csr_fetch_valid_ch_lst(tpAniSirGlobal mac_ctx,
 		if ((!mac_ctx->roam.configParam.allowDFSChannelRoam ||
 		    (mac_ctx->roam.configParam.sta_roam_policy.dfs_mode ==
 			 CSR_STA_ROAM_POLICY_DFS_DISABLED)) &&
-		     (CDS_IS_DFS_CH(*ch_lst))) {
+		     (wlan_reg_is_dfs_ch(mac_ctx->pdev, *ch_lst))) {
 			QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
 				("ignoring dfs channel %d"), *ch_lst);
 			ch_lst++;
@@ -19396,11 +19397,11 @@ csr_update_op_class_array(tpAniSirGlobal mac_ctx,
 	sme_debug("Num of %s channels,  %d",
 		ch_name, num_channels);
 
-	for (idx = 0; idx < num_channels
-		&& *i < (CDS_MAX_SUPP_OPER_CLASSES - 1); idx++) {
+	for (idx = 0; idx < num_channels &&
+			*i < (REG_MAX_SUPP_OPER_CLASSES - 1); idx++) {
 		for (ch_bandwidth = BW20; ch_bandwidth < BWALL;
 			ch_bandwidth++) {
-			class = cds_reg_dmn_get_opclass_from_channel(
+			class = wlan_reg_dmn_get_opclass_from_channel(
 					mac_ctx->scan.countryCodeCurrent,
 					channel_info->channelList[idx],
 					ch_bandwidth);
@@ -19408,7 +19409,7 @@ csr_update_op_class_array(tpAniSirGlobal mac_ctx,
 				channel_info->channelList[idx], class);
 
 			found = false;
-			for (j = 0; j < CDS_MAX_SUPP_OPER_CLASSES - 1;
+			for (j = 0; j < REG_MAX_SUPP_OPER_CLASSES - 1;
 				j++) {
 				if (op_classes[j] == class) {
 					found = true;
@@ -19436,7 +19437,7 @@ void csr_init_operating_classes(tHalHandle hHal)
 	uint8_t j = 0;
 	uint8_t swap = 0;
 	uint8_t numClasses = 0;
-	uint8_t opClasses[CDS_MAX_SUPP_OPER_CLASSES] = {0,};
+	uint8_t opClasses[REG_MAX_SUPP_OPER_CLASSES] = {0,};
 	tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
 
 	sme_debug("Current Country = %c%c",
@@ -19470,7 +19471,7 @@ void csr_init_operating_classes(tHalHandle hHal)
 	/* Set the ordered list of op classes in regdomain
 	 * for use by other modules
 	 */
-	cds_reg_dmn_set_curr_opclasses(numClasses, &opClasses[0]);
+	wlan_reg_dmn_set_curr_opclasses(numClasses, &opClasses[0]);
 }
 
 /**

+ 33 - 37
core/sme/src/csr/csr_api_scan.c

@@ -62,6 +62,7 @@
 #include <wlan_objmgr_pdev_obj.h>
 #include <wlan_utility.h>
 #endif
+#include "wlan_reg_services_api.h"
 
 #define MIN_CHN_TIME_TO_FIND_GO 100
 #define MAX_CHN_TIME_TO_FIND_GO 100
@@ -1935,16 +1936,16 @@ QDF_STATUS csr_save_to_channel_power2_g_5_g(tpAniSirGlobal pMac,
 		 * Now set the inter-channel offset based on the frequency band
 		 * the channel set lies in
 		 */
-		if ((CDS_IS_CHANNEL_24GHZ(pChannelSet->firstChannel)) &&
+		if ((WLAN_REG_IS_24GHZ_CH(pChannelSet->firstChannel)) &&
 		    ((pChannelSet->firstChannel +
 		      (pChannelSet->numChannels - 1)) <=
-		     CDS_MAX_24GHZ_CHANNEL_NUMBER)) {
+		     WLAN_REG_MAX_24GHZ_CH_NUM)) {
 			pChannelSet->interChannelOffset = 1;
 			f2GHzInfoFound = true;
-		} else if ((CDS_IS_CHANNEL_5GHZ(pChannelSet->firstChannel))
+		} else if ((WLAN_REG_IS_5GHZ_CH(pChannelSet->firstChannel))
 		    && ((pChannelSet->firstChannel +
 		      ((pChannelSet->numChannels - 1) * 4)) <=
-		     CDS_MAX_5GHZ_CHANNEL_NUMBER)) {
+		     WLAN_REG_MAX_5GHZ_CH_NUM)) {
 			pChannelSet->interChannelOffset = 4;
 			f2GHzInfoFound = false;
 		} else {
@@ -2265,10 +2266,9 @@ void csr_apply_country_information(tpAniSirGlobal pMac)
 	if (pMac->scan.domainIdCurrent != domainId) {
 		sme_debug("Domain Changed Old %d, new %d",
 			pMac->scan.domainIdCurrent, domainId);
-		status = wma_set_reg_domain(pMac, domainId);
+		if (domainId >= REGDOMAIN_COUNT)
+			sme_err("fail to set regId %d", domainId);
 	}
-	if (status != QDF_STATUS_SUCCESS)
-		sme_err("fail to set regId %d", domainId);
 	pMac->scan.domainIdCurrent = domainId;
 	/* switch to active scans using this new channel list */
 	pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
@@ -2297,8 +2297,8 @@ void csr_save_channel_power_for_band(tpAniSirGlobal pMac, bool fill_5f)
 	ch_info_start = chan_info;
 	for (idx = 0; idx < max_ch_idx; idx++) {
 		ch = pMac->scan.defaultPowerTable[idx].chan_num;
-		tmp_bool =  (fill_5f && CDS_IS_CHANNEL_5GHZ(ch))
-			|| (!fill_5f && CDS_IS_CHANNEL_24GHZ(ch));
+		tmp_bool = (fill_5f && WLAN_REG_IS_5GHZ_CH(ch)) ||
+			(!fill_5f && WLAN_REG_IS_24GHZ_CH(ch));
 		if (!tmp_bool)
 			continue;
 
@@ -3608,7 +3608,7 @@ csr_issue_user_scan(tpAniSirGlobal mac_ctx, tSmeCmd *cmd)
 		j = 0;
 		for (i = 0; i < len; i++) {
 			new_ch_info.ChannelList[j++] = ch_lst[i];
-			if (CDS_MAX_24GHZ_CHANNEL_NUMBER >= ch_lst[i])
+			if (WLAN_REG_MAX_24GHZ_CH_NUM >= ch_lst[i])
 				new_ch_info.ChannelList[j++] = ch_lst[i];
 		}
 		if (NULL !=
@@ -3702,13 +3702,10 @@ static void csr_scan_copy_request_valid_channels_only(tpAniSirGlobal mac_ctx,
 		     ((eCSR_SCAN_P2P_DISCOVERY == src_req->requestType) &&
 		      CSR_IS_SOCIAL_CHANNEL(
 				src_req->ChannelInfo.ChannelList[index])))) {
-			if (((src_req->skipDfsChnlInP2pSearch || skip_dfs_chnl)
-				&& (CHANNEL_STATE_DFS ==
-				cds_get_channel_state(src_req->
-							ChannelInfo.
-							ChannelList
-							[index])))
-			) {
+			if (((src_req->skipDfsChnlInP2pSearch ||
+				skip_dfs_chnl) && (CHANNEL_STATE_DFS ==
+				wlan_reg_get_channel_state(mac_ctx->pdev,
+				src_req->ChannelInfo.ChannelList[index])))) {
 				sme_debug(
 					"reqType= %s (%d), numOfChannels=%d, ignoring DFS channel %d",
 					sme_request_type_to_string(
@@ -3738,7 +3735,7 @@ static void csr_scan_copy_request_valid_channels_only(tpAniSirGlobal mac_ctx,
 					mac_ctx->roam.configParam.
 					sta_roam_policy.sap_operating_band ==
 						eCSR_BAND_24) ||
-						(CDS_IS_CHANNEL_5GHZ(
+						(WLAN_REG_IS_5GHZ_CH(
 							src_req->ChannelInfo.
 							ChannelList[index]) &&
 					mac_ctx->roam.configParam.
@@ -3809,14 +3806,13 @@ static bool csr_scan_filter_given_chnl_band(tpAniSirGlobal mac_ctx,
 	for (i = 0; i < valid_chnl_len; i++) {
 		if (valid_chnl_list[i] >= WLAN_REG_MIN_11P_CH_NUM)
 			continue;
-
-		if (CDS_IS_CHANNEL_5GHZ(channel) &&
-			CDS_IS_CHANNEL_24GHZ(valid_chnl_list[i])) {
+		if (WLAN_REG_IS_5GHZ_CH(channel) &&
+			WLAN_REG_IS_24GHZ_CH(valid_chnl_list[i])) {
 			valid_chnl_list[filter_chnl_len] =
 					valid_chnl_list[i];
 			filter_chnl_len++;
-		} else if (CDS_IS_CHANNEL_24GHZ(channel) &&
-			CDS_IS_CHANNEL_5GHZ(valid_chnl_list[i])) {
+		} else if (WLAN_REG_IS_24GHZ_CH(channel) &&
+			WLAN_REG_IS_5GHZ_CH(valid_chnl_list[i])) {
 			valid_chnl_list[filter_chnl_len] =
 					valid_chnl_list[i];
 			filter_chnl_len++;
@@ -3914,22 +3910,22 @@ QDF_STATUS csr_scan_copy_request(tpAniSirGlobal mac_ctx,
 			(src_req->requestType == eCSR_SCAN_REQUEST_11D_SCAN)) {
 			for (index = 0; index < src_req->ChannelInfo.
 						numOfChannels; index++) {
-				channel_state =
-					cds_get_channel_state(src_req->
-							ChannelInfo.
-							ChannelList[index]);
+				channel_state = wlan_reg_get_channel_state(
+						mac_ctx->pdev,
+						src_req->ChannelInfo.
+						ChannelList[index]);
 				if (src_req->ChannelInfo.ChannelList[index] <
 				    WLAN_REG_MIN_11P_CH_NUM &&
 				    ((CHANNEL_STATE_ENABLE ==
-						channel_state) ||
-					((CHANNEL_STATE_DFS == channel_state) &&
-					!skip_dfs_chnl))) {
+				      channel_state) ||
+				     ((CHANNEL_STATE_DFS == channel_state) &&
+				      !skip_dfs_chnl))) {
 					dst_req->ChannelInfo.ChannelList
-							[new_index] =
-								src_req->
-								ChannelInfo.
-								ChannelList
-								[index];
+						[new_index] =
+						src_req->
+						ChannelInfo.
+						ChannelList
+						[index];
 					new_index++;
 				}
 			}
@@ -3948,7 +3944,7 @@ QDF_STATUS csr_scan_copy_request(tpAniSirGlobal mac_ctx,
 				"Couldn't get the valid Channel List, keeping requester's list");
 			new_index = 0;
 			for (index = 0; index < src_req->ChannelInfo.
-					numOfChannels; index++) {
+				     numOfChannels; index++) {
 				if (src_req->ChannelInfo.ChannelList[index] <
 				    WLAN_REG_MIN_11P_CH_NUM) {
 					dst_req->ChannelInfo.
@@ -5969,7 +5965,7 @@ static QDF_STATUS csr_fill_bss_from_scan_entry(tpAniSirGlobal mac_ctx,
 	bss_desc->beaconInterval = scan_entry->bcn_int;
 	bss_desc->capabilityInfo = scan_entry->cap_info.value;
 
-	if (CDS_IS_CHANNEL_5GHZ(scan_entry->channel.chan_idx))
+	if (WLAN_REG_IS_5GHZ_CH(scan_entry->channel.chan_idx))
 		bss_desc->nwType = eSIR_11A_NW_TYPE;
 	else if (scan_entry->phy_mode == WLAN_PHYMODE_11B)
 		bss_desc->nwType = eSIR_11B_NW_TYPE;

+ 9 - 10
core/sme/src/csr/csr_util.c

@@ -32,7 +32,6 @@
 
     Implementation supporting routines for CSR.
    ========================================================================== */
-
 #include "ani_global.h"
 
 #include "csr_support.h"
@@ -43,6 +42,7 @@
 #include "cds_utils.h"
 #include "wlan_policy_mgr_api.h"
 #include "wlan_serialization_legacy_api.h"
+#include "wlan_reg_services_api.h"
 
 
 uint8_t csr_wpa_oui[][CSR_WPA_OUI_SIZE] = {
@@ -2203,7 +2203,7 @@ bool csr_is_phy_mode_match(tpAniSirGlobal pMac, uint32_t phyMode,
 			phyMode2 = phyMode;
 		}
 		fMatch = csr_get_phy_mode_in_use(phyMode2, phyModeInBssDesc,
-				CDS_IS_CHANNEL_5GHZ(pSirBssDesc->channelId),
+				WLAN_REG_IS_5GHZ_CH(pSirBssDesc->channelId),
 				&cfgDot11ModeToUse);
 	} else {
 		bitMask = 1;
@@ -2212,7 +2212,7 @@ bool csr_is_phy_mode_match(tpAniSirGlobal pMac, uint32_t phyMode,
 			phyMode2 = (phyMode & (bitMask << loopCount++));
 			if (0 != phyMode2 && csr_get_phy_mode_in_use(phyMode2,
 						phyModeInBssDesc,
-						CDS_IS_CHANNEL_5GHZ
+						WLAN_REG_IS_5GHZ_CH
 						(pSirBssDesc->channelId),
 						&cfgDot11ModeToUse)) {
 				fMatch = true;
@@ -2238,7 +2238,7 @@ bool csr_is_phy_mode_match(tpAniSirGlobal pMac, uint32_t phyMode,
 					(eCSR_CFG_DOT11_MODE_11AX ==
 						cfgDot11ModeToUse))) {
 				/* We cannot do 11n here */
-				if (!CDS_IS_CHANNEL_5GHZ
+				if (!WLAN_REG_IS_5GHZ_CH
 						(pSirBssDesc->channelId)) {
 					cfgDot11ModeToUse =
 						eCSR_CFG_DOT11_MODE_11G;
@@ -5716,7 +5716,7 @@ tSirScanType csr_get_scan_type(tpAniSirGlobal pMac, uint8_t chnId)
 	tSirScanType scanType = eSIR_PASSIVE_SCAN;
 	enum channel_state channelEnabledType;
 
-	channelEnabledType = cds_get_channel_state(chnId);
+	channelEnabledType = wlan_reg_get_channel_state(pMac->pdev, chnId);
 	if (CHANNEL_STATE_ENABLE == channelEnabledType) {
 		scanType = eSIR_ACTIVE_SCAN;
 	}
@@ -5855,14 +5855,13 @@ QDF_STATUS csr_get_regulatory_domain_for_country(tpAniSirGlobal pMac,
 	if (pCountry) {
 		countryCode[0] = pCountry[0];
 		countryCode[1] = pCountry[1];
-		qdf_status = cds_get_reg_domain_from_country_code(&domainId,
+		qdf_status = wlan_reg_get_domain_from_country_code(&domainId,
 								  countryCode,
 								  source);
 
 		if (QDF_IS_STATUS_SUCCESS(qdf_status)) {
-			if (pDomainId) {
+			if (pDomainId)
 				*pDomainId = domainId;
-			}
 			status = QDF_STATUS_SUCCESS;
 		} else {
 			sme_warn("Couldn't find domain for country code %c%c",
@@ -5979,8 +5978,8 @@ uint16_t sme_chn_to_freq(uint8_t chanNum)
 	int i;
 
 	for (i = 0; i < NUM_CHANNELS; i++) {
-		if (CDS_CHANNEL_NUM(i) == chanNum)
-			return CDS_CHANNEL_FREQ(i);
+		if (WLAN_REG_CH_NUM(i) == chanNum)
+			return WLAN_REG_CH_TO_FREQ(i);
 	}
 
 	return 0;

+ 1 - 0
core/wma/inc/wma.h

@@ -1341,6 +1341,7 @@ typedef struct {
 	void *cds_context;
 	void *mac_context;
 	struct wlan_objmgr_psoc *psoc;
+	struct wlan_objmgr_pdev *pdev;
 	qdf_event_t wma_ready_event;
 	qdf_event_t wma_resume_event;
 	qdf_event_t target_suspend;

+ 18 - 1
core/wma/inc/wma_api.h

@@ -130,7 +130,6 @@ int wma_cli_set2_command(int vdev_id, int param_id, int sval1,
 			 int sval2, int vpdev);
 
 QDF_STATUS wma_set_htconfig(uint8_t vdev_id, uint16_t ht_capab, int value);
-QDF_STATUS wma_set_reg_domain(void *clientCtxt, v_REGDOMAIN_t regId);
 
 QDF_STATUS wma_get_wcnss_software_version(void *p_cds_gctx,
 					  uint8_t *pVersion,
@@ -287,4 +286,22 @@ static inline void wma_tx_failure_cb(void *ctx, uint32_t num_msdu,
 {
 }
 #endif
+
+/**
+ * wma_store_pdev() - store pdev
+ * @wma_ctx:	wma context
+ * @pdev:	pdev context
+ *
+ * Return: void
+ */
+void wma_store_pdev(void *wma_ctx, struct wlan_objmgr_pdev *pdev);
+
+/**
+ * wma_clear_pdev() - clear pdev
+ * @wma_ctx:	wma context
+ *
+ * Return: void
+ */
+void wma_clear_pdev(void *wma_ctx);
+
 #endif

+ 1 - 1
core/wma/inc/wma_dfs_interface.h

@@ -27,9 +27,9 @@
 
 #include "ath_dfs_structs.h"
 #include <qdf_lock.h>
-#include "cds_reg_service.h"
 #include "cds_regdomain.h"
 #include "cds_ieee80211_common.h"
+#include "wlan_reg_services_api.h"
 
 #define IEEE80211_CHAN_MAX      255
 

+ 26 - 1
core/wma/src/wma_dev_if.c

@@ -76,6 +76,7 @@
 #include "wlan_tgt_def_config.h"
 #include <cdp_txrx_handle.h>
 #include "wlan_pmo_ucfg_api.h"
+#include "wlan_reg_services_api.h"
 
 #include "wma_he.h"
 
@@ -1967,7 +1968,7 @@ QDF_STATUS wma_vdev_start(tp_wma_handle wma,
 
 	params.band_center_freq1 = params.chan_freq;
 
-	bw_val = cds_bw_value(req->chan_width);
+	bw_val = wlan_reg_get_bw_value(req->chan_width);
 	if (20 < bw_val)
 		params.band_center_freq1 =
 			cds_chan_to_freq(req->ch_center_freq_seg0);
@@ -4705,3 +4706,27 @@ void wma_set_vdev_intrabss_fwd(tp_wma_handle wma_handle,
 				    txrx_vdev,
 				    pdis_intra_fwd->disableintrabssfwd);
 }
+
+void wma_store_pdev(void *wma_ctx, struct wlan_objmgr_pdev *pdev)
+{
+	tp_wma_handle wma = (tp_wma_handle)wma_ctx;
+	QDF_STATUS status;
+
+	status = wlan_objmgr_pdev_try_get_ref(pdev, WLAN_LEGACY_WMA_ID);
+	if (QDF_STATUS_SUCCESS != status) {
+		wma->pdev = NULL;
+		return;
+	}
+
+	wma->pdev = pdev;
+}
+
+void wma_clear_pdev(void *wma_ctx)
+{
+	tp_wma_handle wma = (tp_wma_handle)wma_ctx;
+
+	if (wma->pdev) {
+		wlan_objmgr_pdev_release_ref(wma->pdev, WLAN_LEGACY_WMA_ID);
+		wma->pdev = NULL;
+	}
+}

+ 25 - 30
core/wma/src/wma_features.c

@@ -72,6 +72,7 @@
 #include <cdp_txrx_handle.h>
 #include "wlan_pmo_ucfg_api.h"
 #include <target_if_scan.h>
+#include "wlan_reg_services_api.h"
 
 #ifndef ARRAY_LENGTH
 #define ARRAY_LENGTH(a)         (sizeof(a) / sizeof((a)[0]))
@@ -551,9 +552,9 @@ WLAN_PHY_MODE wma_chan_phy_mode(u8 chan, enum phy_ch_width chan_width,
 				u8 dot11_mode)
 {
 	WLAN_PHY_MODE phymode = MODE_UNKNOWN;
-	uint16_t bw_val = cds_bw_value(chan_width);
+	uint16_t bw_val = wlan_reg_get_bw_value(chan_width);
 
-	if (CDS_IS_CHANNEL_24GHZ(chan)) {
+	if (WLAN_REG_IS_24GHZ_CH(chan)) {
 		if (((CH_WIDTH_5MHZ == chan_width) ||
 		     (CH_WIDTH_10MHZ == chan_width)) &&
 		    ((WNI_CFG_DOT11_MODE_11B == dot11_mode) ||
@@ -1385,13 +1386,15 @@ static int wma_unified_dfs_radar_rx_event_handler(void *handle,
 	if (IEEE80211_IS_CHAN_11AC_VHT160(chan)) {
 		is_ch_dfs = true;
 	} else if (IEEE80211_IS_CHAN_11AC_VHT80P80(chan)) {
-		if (cds_get_channel_state(chan->ic_ieee) == CHANNEL_STATE_DFS ||
-		    cds_get_channel_state(chan->ic_ieee_ext -
+		if (wlan_reg_get_channel_state(wma->pdev, chan->ic_ieee) ==
+				CHANNEL_STATE_DFS ||
+		    wlan_reg_get_channel_state(wma->pdev, chan->ic_ieee_ext -
 					  WMA_80MHZ_START_CENTER_CH_DIFF) ==
 							CHANNEL_STATE_DFS)
 			is_ch_dfs = true;
 	} else {
-		if (cds_get_channel_state(chan->ic_ieee) == CHANNEL_STATE_DFS)
+		if (wlan_reg_get_channel_state(wma->pdev, chan->ic_ieee) ==
+				CHANNEL_STATE_DFS)
 			is_ch_dfs = true;
 	}
 	if (!is_ch_dfs) {
@@ -4371,23 +4374,6 @@ QDF_STATUS wma_process_ch_avoid_update_req(tp_wma_handle wma_handle,
 	return status;
 }
 #endif /* FEATURE_WLAN_CH_AVOID */
-
-/**
- * wma_set_reg_domain() - set reg domain
- * @clientCtxt: client context
- * @regId: reg id
- *
- * Return: QDF status
- */
-QDF_STATUS wma_set_reg_domain(void *clientCtxt, v_REGDOMAIN_t regId)
-{
-	if (QDF_STATUS_SUCCESS !=
-	    cds_set_reg_domain(clientCtxt, regId))
-		return QDF_STATUS_E_INVAL;
-
-	return QDF_STATUS_SUCCESS;
-}
-
 /**
  * wma_send_regdomain_info_to_fw() - send regdomain info to fw
  * @reg_dmn: reg domain
@@ -5091,6 +5077,13 @@ struct dfs_ieee80211_channel *wma_dfs_configure_channel(
 						*req)
 {
 	uint8_t ext_channel;
+	tp_wma_handle wma;
+
+	wma = cds_get_context(QDF_MODULE_ID_WMA);
+	if (!wma) {
+		WMA_LOGE("%s: DFS- Invalid wma", __func__);
+		return NULL;
+	}
 
 	if (dfs_ic == NULL) {
 		WMA_LOGE("%s: DFS ic is Invalid", __func__);
@@ -5156,10 +5149,10 @@ struct dfs_ieee80211_channel *wma_dfs_configure_channel(
 
 		/* verify both the 80MHz are DFS bands or not */
 		if ((CHANNEL_STATE_DFS ==
-		     cds_get_5g_bonded_channel_state(req->chan ,
-						     CH_WIDTH_80MHZ)) &&
-		    (CHANNEL_STATE_DFS == cds_get_5g_bonded_channel_state(
-			    ext_channel - WMA_80MHZ_START_CENTER_CH_DIFF,
+		     wlan_reg_get_5g_bonded_channel_state(wma->pdev,
+			     req->chan, CH_WIDTH_80MHZ)) &&
+		    (CHANNEL_STATE_DFS == wlan_reg_get_5g_bonded_channel_state(
+			wma->pdev, ext_channel - WMA_80MHZ_START_CENTER_CH_DIFF,
 			    CH_WIDTH_80MHZ)))
 			dfs_ic->ic_curchan->ic_80p80_both_dfs = true;
 		break;
@@ -5221,8 +5214,9 @@ void wma_set_dfs_region(tp_wma_handle wma, enum dfs_reg dfs_region)
  *
  * Return: return number of channels
  */
-static int wma_get_channels(struct dfs_ieee80211_channel *ichan,
-			    struct wma_dfs_radar_channel_list *chan_list)
+static int wma_get_channels(tp_wma_handle wma,
+		struct dfs_ieee80211_channel *ichan,
+		struct wma_dfs_radar_channel_list *chan_list)
 {
 	uint8_t center_chan = cds_freq_to_chan(ichan->ic_vhtop_ch_freq_seg1);
 	int count = 0;
@@ -5250,7 +5244,8 @@ static int wma_get_channels(struct dfs_ieee80211_channel *ichan,
 		 */
 		start_channel = center_chan - WMA_160MHZ_START_CENTER_CH_DIFF;
 		for (loop = 0; loop < WMA_DFS_MAX_20M_SUB_CH; loop++) {
-			if (cds_get_channel_state(start_channel +
+			if (wlan_reg_get_channel_state(wma->pdev,
+						start_channel +
 				    (loop * WMA_NEXT_20MHZ_START_CH_DIFF)) ==
 							CHANNEL_STATE_DFS) {
 				chan_list->channels[count] = start_channel +
@@ -5375,7 +5370,7 @@ int wma_dfs_indicate_radar(struct ieee80211com *ic,
 		 * select a new channel and set CSA IE
 		 */
 		radar_event->vdev_id = ic->vdev_id;
-		wma_get_channels(ichan, &radar_event->chan_list);
+		wma_get_channels(wma, ichan, &radar_event->chan_list);
 		radar_event->dfs_radar_status = WMA_DFS_RADAR_FOUND;
 		radar_event->use_nol = ic->ic_dfs_usenol(ic);
 		wma_send_msg(wma, WMA_DFS_RADAR_IND, (void *)radar_event, 0);

+ 4 - 3
core/wma/src/wma_main.c

@@ -88,11 +88,12 @@
 #include "wma_he.h"
 #include "wlan_pmo_obj_mgmt_api.h"
 
+#include "wlan_reg_tgt_api.h"
+#include "wlan_reg_services_api.h"
 #include <cdp_txrx_handle.h>
 #include <wlan_pmo_ucfg_api.h>
 
 #define WMA_LOG_COMPLETION_TIMER 10000 /* 10 seconds */
-
 #define WMI_TLV_HEADROOM 128
 
 static uint32_t g_fw_wlan_feat_caps;
@@ -4979,7 +4980,7 @@ bool wma_is_rx_ldpc_supported_for_channel(uint32_t channel)
 	enum cds_band_type band;
 	bool status;
 
-	if (!CDS_IS_CHANNEL_24GHZ(channel))
+	if (!WLAN_REG_IS_24GHZ_CH(channel))
 		band = CDS_BAND_5GHZ;
 	else
 		band = CDS_BAND_2GHZ;
@@ -4989,7 +4990,7 @@ bool wma_is_rx_ldpc_supported_for_channel(uint32_t channel)
 						HW_MODE_DBS, band)) {
 		return false;
 	}
-	if (CDS_IS_CHANNEL_24GHZ(channel))
+	if (WLAN_REG_IS_24GHZ_CH(channel))
 		status = (!!(caps_per_phy.ht_2g & WMI_HT_CAP_RX_LDPC));
 	else
 		status = (!!(caps_per_phy.ht_5g & WMI_HT_CAP_RX_LDPC));

+ 6 - 3
core/wma/src/wma_scan_roam.c

@@ -69,6 +69,8 @@
 #include "dfs.h"
 #include "wma_internal.h"
 #include "wlan_tgt_def_config.h"
+#include "wlan_reg_services_api.h"
+
 /* This is temporary, should be removed */
 #include "ol_htt_api.h"
 #include <cdp_txrx_handle.h>
@@ -429,14 +431,15 @@ QDF_STATUS wma_get_buf_start_scan_cmd(tp_wma_handle wma_handle,
 					 WMA_ROAM_SCAN_CHANNEL_SWITCH_TIME));
 		if (!policy_mgr_is_hw_dbs_capable(wma_handle->psoc) ||
 			(policy_mgr_is_hw_dbs_capable(wma_handle->psoc) &&
-				CDS_IS_CHANNEL_5GHZ(
+				WLAN_REG_IS_5GHZ_CH(
 					policy_mgr_get_channel(wma_handle->psoc,
 						PM_SAP_MODE, NULL)))) {
 			cmd->dwell_time_passive = cmd->dwell_time_active;
 		}
 		cmd->burst_duration = 0;
-		if (CDS_IS_DFS_CH(policy_mgr_get_channel(wma_handle->psoc,
-			PM_SAP_MODE, NULL)))
+		if (wlan_reg_is_dfs_ch(wma_handle->pdev,
+				policy_mgr_get_channel(wma_handle->psoc,
+					PM_SAP_MODE, NULL)))
 			cmd->burst_duration =
 				WMA_BURST_SCAN_MAX_NUM_OFFCHANNELS *
 				scan_req->maxChannelTime;