qcacld-3.0: Enable EXTSCAN based on converged extscan component

Enable EXTSCAN based on converged cfg component and remove
legacy codes.

Change-Id: Ia4af89c6a898a936c89c6f3f155609a9c3d98541
CRs-Fixed: 2302197
diff --git a/Kbuild b/Kbuild
index 4447cb9..f5f129d 100644
--- a/Kbuild
+++ b/Kbuild
@@ -618,6 +618,10 @@
 		$(WLAN_COMMON_ROOT)/os_if/linux/wlan_cfg80211.o \
 		$(WLAN_COMMON_ROOT)/target_if/scan/src/target_if_scan.o
 
+ifeq ($(CONFIG_FEATURE_WLAN_EXTSCAN), y)
+UMAC_SCAN_OBJS += $(UMAC_SCAN_DISP_DIR)/wlan_extscan_api.o
+endif
+
 ############# UMAC_SPECTRAL_SCAN ############
 UMAC_SPECTRAL_DIR := spectral
 UMAC_SPECTRAL_DISP_INC_DIR := $(UMAC_SPECTRAL_DIR)/dispatcher/inc
diff --git a/core/hdd/inc/wlan_hdd_cfg.h b/core/hdd/inc/wlan_hdd_cfg.h
index 72408f3..5e0408b 100644
--- a/core/hdd/inc/wlan_hdd_cfg.h
+++ b/core/hdd/inc/wlan_hdd_cfg.h
@@ -881,127 +881,6 @@
 #define CFG_SCAN_PROBE_REPEAT_TIME_MAX        (30)
 #define CFG_SCAN_PROBE_REPEAT_TIME_DEFAULT    (0)
 
-#ifdef FEATURE_WLAN_EXTSCAN
-/*
- * <ini>
- * gExtScanEnable - Enable external scan
- * @Min: 0
- * @Max: 1
- * @Default: 1
- *
- * This ini is used to control enabling of external scan
- * feature.
- *
- * Related: None
- *
- * Supported Feature: Scan
- *
- * Usage: External
- *
- * </ini>
- */
-#define CFG_EXTSCAN_ALLOWED_NAME                   "gExtScanEnable"
-#define CFG_EXTSCAN_ALLOWED_MIN                    (0)
-#define CFG_EXTSCAN_ALLOWED_MAX                    (1)
-#define CFG_EXTSCAN_ALLOWED_DEF                    (1)
-
-/*
- * <ini>
- * gExtScanPassiveMaxChannelTime - Set max channel time for external
- * passive scan
- * @Min: 0
- * @Max: 500
- * @Default: 110
- *
- * This ini is used to set maximum channel time  in secs spent in
- * external passive scan
- *
- * Related: None
- *
- * Supported Feature: Scan
- *
- * Usage: External
- *
- * </ini>
- */
-#define CFG_EXTSCAN_PASSIVE_MAX_CHANNEL_TIME_NAME      "gExtScanPassiveMaxChannelTime"
-#define CFG_EXTSCAN_PASSIVE_MAX_CHANNEL_TIME_MIN       (0)
-#define CFG_EXTSCAN_PASSIVE_MAX_CHANNEL_TIME_MAX       (500)
-#define CFG_EXTSCAN_PASSIVE_MAX_CHANNEL_TIME_DEFAULT   (110)
-
-/*
- * <ini>
- * gExtScanPassiveMinChannelTime - Set min channel time for external
- * passive scan
- * @Min: 0
- * @Max: 500
- * @Default: 60
- *
- * This ini is used to set minimum channel time in secs spent in
- * external passive scan
- *
- * Related: None
- *
- * Supported Feature: Scan
- *
- * Usage: External
- *
- * </ini>
- */
-#define CFG_EXTSCAN_PASSIVE_MIN_CHANNEL_TIME_NAME      "gExtScanPassiveMinChannelTime"
-#define CFG_EXTSCAN_PASSIVE_MIN_CHANNEL_TIME_MIN       (0)
-#define CFG_EXTSCAN_PASSIVE_MIN_CHANNEL_TIME_MAX       (500)
-#define CFG_EXTSCAN_PASSIVE_MIN_CHANNEL_TIME_DEFAULT   (60)
-
-/*
- * <ini>
- * gExtScanActiveMaxChannelTime - Set min channel time for external
- * active scan
- * @Min: 0
- * @Max: 110
- * @Default: 40
- *
- * This ini is used to set maximum channel time in secs spent in
- * external active scan
- *
- * Related: None
- *
- * Supported Feature: Scan
- *
- * Usage: External
- *
- * </ini>
- */
-#define CFG_EXTSCAN_ACTIVE_MAX_CHANNEL_TIME_NAME       "gExtScanActiveMaxChannelTime"
-#define CFG_EXTSCAN_ACTIVE_MAX_CHANNEL_TIME_MIN        (0)
-#define CFG_EXTSCAN_ACTIVE_MAX_CHANNEL_TIME_MAX        (110)
-#define CFG_EXTSCAN_ACTIVE_MAX_CHANNEL_TIME_DEFAULT    (40)
-
-/*
- * <ini>
- * gExtScanActiveMinChannelTime - Set min channel time for external
- * active scan
- * @Min: 0
- * @Max: 110
- * @Default: 20
- *
- * This ini is used to set minimum channel time in secs spent in
- * external active scan
- *
- * Related: None
- *
- * Supported Feature: Scan
- *
- * Usage: External
- *
- * </ini>
- */
-#define CFG_EXTSCAN_ACTIVE_MIN_CHANNEL_TIME_NAME       "gExtScanActiveMinChannelTime"
-#define CFG_EXTSCAN_ACTIVE_MIN_CHANNEL_TIME_MIN        (0)
-#define CFG_EXTSCAN_ACTIVE_MIN_CHANNEL_TIME_MAX        (110)
-#define CFG_EXTSCAN_ACTIVE_MIN_CHANNEL_TIME_DEFAULT    (20)
-#endif
-
 /*
  * <ini>
  * gChPredictionFullScanMs - Set periodic timer for channel
@@ -14208,13 +14087,6 @@
 	/* CPU affinity mask for rx_thread */
 	uint32_t rx_thread_affinity_mask;
 	uint8_t cpu_map_list[CFG_RPS_RX_QUEUE_CPU_MAP_LIST_LEN];
-#ifdef FEATURE_WLAN_EXTSCAN
-	bool     extscan_enabled;
-	uint32_t extscan_passive_max_chn_time;
-	uint32_t extscan_passive_min_chn_time;
-	uint32_t extscan_active_max_chn_time;
-	uint32_t extscan_active_min_chn_time;
-#endif
 	bool ce_classify_enabled;
 	uint32_t dual_mac_feature_disable;
 	uint8_t dbs_scan_selection[CFG_DBS_SCAN_PARAM_LENGTH];
diff --git a/core/hdd/src/wlan_hdd_cfg.c b/core/hdd/src/wlan_hdd_cfg.c
index c94d51d..39cd3e9 100644
--- a/core/hdd/src/wlan_hdd_cfg.c
+++ b/core/hdd/src/wlan_hdd_cfg.c
@@ -3269,48 +3269,6 @@
 		     CFG_ETSI13_SRD_CHAN_IN_MASTER_MODE_MIN,
 		     CFG_ETSI13_SRD_CHAN_IN_MASTER_MODE_MAX),
 
-#ifdef FEATURE_WLAN_EXTSCAN
-	REG_VARIABLE(CFG_EXTSCAN_ALLOWED_NAME, WLAN_PARAM_Integer,
-		     struct hdd_config, extscan_enabled,
-		     VAR_FLAGS_OPTIONAL |
-		     VAR_FLAGS_RANGE_CHECK_ASSUME_DEFAULT,
-		     CFG_EXTSCAN_ALLOWED_DEF,
-		     CFG_EXTSCAN_ALLOWED_MIN,
-		     CFG_EXTSCAN_ALLOWED_MAX),
-
-	REG_VARIABLE(CFG_EXTSCAN_PASSIVE_MAX_CHANNEL_TIME_NAME,
-		     WLAN_PARAM_Integer,
-		     struct hdd_config, extscan_passive_max_chn_time,
-		     VAR_FLAGS_OPTIONAL | VAR_FLAGS_RANGE_CHECK_ASSUME_DEFAULT,
-		     CFG_EXTSCAN_PASSIVE_MAX_CHANNEL_TIME_DEFAULT,
-		     CFG_EXTSCAN_PASSIVE_MAX_CHANNEL_TIME_MIN,
-		     CFG_EXTSCAN_PASSIVE_MAX_CHANNEL_TIME_MAX),
-
-	REG_VARIABLE(CFG_EXTSCAN_PASSIVE_MIN_CHANNEL_TIME_NAME,
-		     WLAN_PARAM_Integer,
-		     struct hdd_config, extscan_passive_min_chn_time,
-		     VAR_FLAGS_OPTIONAL | VAR_FLAGS_RANGE_CHECK_ASSUME_DEFAULT,
-		     CFG_EXTSCAN_PASSIVE_MIN_CHANNEL_TIME_DEFAULT,
-		     CFG_EXTSCAN_PASSIVE_MIN_CHANNEL_TIME_MIN,
-		     CFG_EXTSCAN_PASSIVE_MIN_CHANNEL_TIME_MAX),
-
-	REG_VARIABLE(CFG_EXTSCAN_ACTIVE_MAX_CHANNEL_TIME_NAME,
-		     WLAN_PARAM_Integer,
-		     struct hdd_config, extscan_active_max_chn_time,
-		     VAR_FLAGS_OPTIONAL | VAR_FLAGS_RANGE_CHECK_ASSUME_DEFAULT,
-		     CFG_EXTSCAN_ACTIVE_MAX_CHANNEL_TIME_DEFAULT,
-		     CFG_EXTSCAN_ACTIVE_MAX_CHANNEL_TIME_MIN,
-		     CFG_EXTSCAN_ACTIVE_MAX_CHANNEL_TIME_MAX),
-
-	REG_VARIABLE(CFG_EXTSCAN_ACTIVE_MIN_CHANNEL_TIME_NAME,
-		     WLAN_PARAM_Integer,
-		     struct hdd_config, extscan_active_min_chn_time,
-		     VAR_FLAGS_OPTIONAL | VAR_FLAGS_RANGE_CHECK_ASSUME_DEFAULT,
-		     CFG_EXTSCAN_ACTIVE_MIN_CHANNEL_TIME_DEFAULT,
-		     CFG_EXTSCAN_ACTIVE_MIN_CHANNEL_TIME_MIN,
-		     CFG_EXTSCAN_ACTIVE_MIN_CHANNEL_TIME_MAX),
-#endif
-
 #ifdef WLAN_FEATURE_WOW_PULSE
 	REG_VARIABLE(CFG_WOW_PULSE_SUPPORT_NAME, WLAN_PARAM_Integer,
 		struct hdd_config, wow_pulse_support,
diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c
index 9baec1a..4d76504 100644
--- a/core/hdd/src/wlan_hdd_cfg80211.c
+++ b/core/hdd/src/wlan_hdd_cfg80211.c
@@ -119,6 +119,7 @@
 #include <wlan_hdd_ota_test.h>
 #include "wlan_mlme_ucfg_api.h"
 #include "wlan_mlme_public_struct.h"
+#include "wlan_extscan_ucfg_api.h"
 
 #define g_mode_rates_size (12)
 #define a_mode_rates_size (8)
@@ -3040,13 +3041,11 @@
 	/* HOTSPOT is a supplicant feature, enable it by default */
 	fset |= WIFI_FEATURE_HOTSPOT;
 
-#ifdef FEATURE_WLAN_EXTSCAN
-	if (hdd_ctx->config->extscan_enabled &&
+	if (ucfg_extscan_get_enable(hdd_ctx->hdd_psoc) &&
 	    sme_is_feature_supported_by_fw(EXTENDED_SCAN)) {
 		hdd_debug("EXTScan is supported by firmware");
 		fset |= WIFI_FEATURE_EXTSCAN | WIFI_FEATURE_HAL_EPNO;
 	}
-#endif
 	if (wlan_hdd_nan_is_supported(hdd_ctx)) {
 		hdd_debug("NAN is supported by firmware");
 		fset |= WIFI_FEATURE_NAN;
diff --git a/core/hdd/src/wlan_hdd_ext_scan.c b/core/hdd/src/wlan_hdd_ext_scan.c
index 5eca34d..2bbf1a6 100644
--- a/core/hdd/src/wlan_hdd_ext_scan.c
+++ b/core/hdd/src/wlan_hdd_ext_scan.c
@@ -30,6 +30,7 @@
 #include "cds_utils.h"
 #include "cds_sched.h"
 #include <qca_vendor.h>
+#include "wlan_extscan_ucfg_api.h"
 
 #define EXTSCAN_PARAM_MAX QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX
 
@@ -1451,7 +1452,7 @@
 	QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID
 #define PARAM_STATUS \
 	QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS
-#define MAX_SCAN_CACHE_SIZE \
+#define MAX_EXTSCAN_CACHE_SIZE \
 	QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_CACHE_SIZE
 #define MAX_SCAN_BUCKETS \
 	QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_BUCKETS
@@ -1550,7 +1551,8 @@
 
 	if (nla_put_u32(skb, PARAM_REQUEST_ID, data->requestId) ||
 	    nla_put_u32(skb, PARAM_STATUS, data->status) ||
-	    nla_put_u32(skb, MAX_SCAN_CACHE_SIZE, data->max_scan_cache_size) ||
+	    nla_put_u32(skb, MAX_EXTSCAN_CACHE_SIZE,
+					data->max_scan_cache_size) ||
 	    nla_put_u32(skb, MAX_SCAN_BUCKETS, data->max_scan_buckets) ||
 	    nla_put_u32(skb, MAX_AP_CACHE_PER_SCAN,
 			data->max_ap_cache_per_scan) ||
@@ -1589,7 +1591,7 @@
  */
 #undef PARAM_REQUEST_ID
 #undef PARAM_STATUS
-#undef MAX_SCAN_CACHE_SIZE
+#undef MAX_EXTSCAN_CACHE_SIZE
 #undef MAX_SCAN_BUCKETS
 #undef MAX_AP_CACHE_PER_SCAN
 #undef MAX_RSSI_SAMPLE_SIZE
@@ -1643,7 +1645,7 @@
 		return -EINVAL;
 	}
 
-	if (!hdd_ctx->config->extscan_enabled) {
+	if (!ucfg_extscan_get_enable(hdd_ctx->hdd_psoc)) {
 		hdd_err("extscan not supported");
 		return -ENOTSUPP;
 	}
@@ -1782,7 +1784,7 @@
 	if (0 != retval)
 		return -EINVAL;
 
-	if (!hdd_ctx->config->extscan_enabled) {
+	if (!ucfg_extscan_get_enable(hdd_ctx->hdd_psoc)) {
 		hdd_err("extscan not supported");
 		return -ENOTSUPP;
 	}
@@ -1981,7 +1983,7 @@
 	if (0 != retval)
 		return -EINVAL;
 
-	if (!hdd_ctx->config->extscan_enabled) {
+	if (!ucfg_extscan_get_enable(hdd_ctx->hdd_psoc)) {
 		hdd_err("extscan not supported");
 		return -ENOTSUPP;
 	}
@@ -2420,7 +2422,7 @@
 	if (0 != ret)
 		return -EINVAL;
 
-	if (!hdd_ctx->config->extscan_enabled) {
+	if (!ucfg_extscan_get_enable(hdd_ctx->hdd_psoc)) {
 		hdd_err("extscan not supported");
 		return -ENOTSUPP;
 	}
@@ -2642,23 +2644,27 @@
 	uint8_t bkt_index, j, num_channels, total_channels = 0;
 	uint32_t expected_buckets;
 	uint32_t chan_list[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
+	uint32_t extscan_active_min_chn_time;
+	uint32_t min_dwell_time_active_bucket;
+	uint32_t max_dwell_time_active_bucket;
+	uint32_t min_dwell_time_passive_bucket;
+	uint32_t max_dwell_time_passive_bucket;
 
-	uint32_t min_dwell_time_active_bucket =
-		hdd_ctx->config->extscan_active_max_chn_time;
-	uint32_t max_dwell_time_active_bucket =
-		hdd_ctx->config->extscan_active_max_chn_time;
-	uint32_t min_dwell_time_passive_bucket =
-		hdd_ctx->config->extscan_passive_max_chn_time;
-	uint32_t max_dwell_time_passive_bucket =
-		hdd_ctx->config->extscan_passive_max_chn_time;
+	ucfg_extscan_get_active_min_time(hdd_ctx->hdd_psoc,
+					&extscan_active_min_chn_time);
+	ucfg_extscan_get_active_max_time(hdd_ctx->hdd_psoc,
+					 &max_dwell_time_active_bucket);
+	ucfg_extscan_get_passive_max_time(hdd_ctx->hdd_psoc,
+					 &max_dwell_time_passive_bucket);
+
+	min_dwell_time_active_bucket = max_dwell_time_active_bucket;
+	min_dwell_time_passive_bucket = max_dwell_time_passive_bucket;
 
 	req_msg->min_dwell_time_active =
-		req_msg->max_dwell_time_active =
-			hdd_ctx->config->extscan_active_max_chn_time;
+		req_msg->max_dwell_time_active = max_dwell_time_active_bucket;
 
 	req_msg->min_dwell_time_passive =
-		req_msg->max_dwell_time_passive =
-			hdd_ctx->config->extscan_passive_max_chn_time;
+		req_msg->max_dwell_time_passive = max_dwell_time_passive_bucket;
 
 	expected_buckets = req_msg->numBuckets;
 	req_msg->numBuckets = 0;
@@ -2750,11 +2756,11 @@
 		/* start with known good values for bucket dwell times */
 		req_msg->buckets[bkt_index].min_dwell_time_active =
 		req_msg->buckets[bkt_index].max_dwell_time_active =
-			hdd_ctx->config->extscan_active_max_chn_time;
+						max_dwell_time_active_bucket;
 
 		req_msg->buckets[bkt_index].min_dwell_time_passive =
 		req_msg->buckets[bkt_index].max_dwell_time_passive =
-			hdd_ctx->config->extscan_passive_max_chn_time;
+						max_dwell_time_passive_bucket;
 
 		/* Framework shall pass the channel list if the input WiFi band
 		 * is WIFI_BAND_UNSPECIFIED.
@@ -2803,8 +2809,7 @@
 								passive = 1;
 					req_msg->buckets[bkt_index].channels[j].
 					dwellTimeMs =
-						hdd_ctx->config->
-						extscan_passive_max_chn_time;
+						max_dwell_time_passive_bucket;
 					/* reconfigure per-bucket dwell time */
 					if (min_dwell_time_passive_bucket >
 							req_msg->buckets[bkt_index].channels[j].dwellTimeMs) {
@@ -2822,7 +2827,7 @@
 							passive = 0;
 					req_msg->buckets[bkt_index].channels[j].
 					dwellTimeMs =
-						hdd_ctx->config->extscan_active_max_chn_time;
+						max_dwell_time_active_bucket;
 					/* reconfigure per-bucket dwell times */
 					if (min_dwell_time_active_bucket >
 							req_msg->buckets[bkt_index].channels[j].dwellTimeMs) {
@@ -2929,9 +2934,9 @@
 
 			/* Override dwell time if required */
 			if (req_msg->buckets[bkt_index].channels[j].dwellTimeMs <
-				hdd_ctx->config->extscan_active_min_chn_time ||
+				extscan_active_min_chn_time ||
 				req_msg->buckets[bkt_index].channels[j].dwellTimeMs >
-				hdd_ctx->config->extscan_active_max_chn_time) {
+				max_dwell_time_active_bucket) {
 				hdd_debug("WiFi band is unspecified, dwellTime:%d",
 						req_msg->buckets[bkt_index].channels[j].dwellTimeMs);
 
@@ -2941,11 +2946,13 @@
 					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;
+					req_msg->buckets[bkt_index].channels[j].
+						dwellTimeMs =
+						max_dwell_time_passive_bucket;
 				} else {
-					req_msg->buckets[bkt_index].channels[j].dwellTimeMs =
-						hdd_ctx->config->extscan_active_max_chn_time;
+					req_msg->buckets[bkt_index].channels[j].
+						dwellTimeMs =
+						max_dwell_time_active_bucket;
 				}
 			}
 
@@ -3118,7 +3125,7 @@
 	if (0 != retval)
 		return -EINVAL;
 
-	if (!hdd_ctx->config->extscan_enabled) {
+	if (!ucfg_extscan_get_enable(hdd_ctx->hdd_psoc)) {
 		hdd_err("extscan not supported");
 		return -ENOTSUPP;
 	}
@@ -3332,7 +3339,7 @@
 	if (0 != retval)
 		return -EINVAL;
 
-	if (!hdd_ctx->config->extscan_enabled) {
+	if (!ucfg_extscan_get_enable(hdd_ctx->hdd_psoc)) {
 		hdd_err("extscan not supported");
 		return -ENOTSUPP;
 	}
@@ -3460,7 +3467,7 @@
 	if (0 != retval)
 		return -EINVAL;
 
-	if (!hdd_ctx->config->extscan_enabled) {
+	if (!ucfg_extscan_get_enable(hdd_ctx->hdd_psoc)) {
 		hdd_err("extscan not supported");
 		return -ENOTSUPP;
 	}
@@ -3575,7 +3582,7 @@
 	if (0 != retval)
 		return -EINVAL;
 
-	if (!hdd_ctx->config->extscan_enabled) {
+	if (!ucfg_extscan_get_enable(hdd_ctx->hdd_psoc)) {
 		hdd_err("extscan not supported");
 		return -ENOTSUPP;
 	}
@@ -3785,7 +3792,7 @@
 	if (ret_val)
 		return ret_val;
 
-	if (!hdd_ctx->config->extscan_enabled) {
+	if (!ucfg_extscan_get_enable(hdd_ctx->hdd_psoc)) {
 		hdd_err("extscan not supported");
 		return -ENOTSUPP;
 	}
diff --git a/core/mac/src/include/sir_params.h b/core/mac/src/include/sir_params.h
index d037f8a..5b1ebd4 100644
--- a/core/mac/src/include/sir_params.h
+++ b/core/mac/src/include/sir_params.h
@@ -115,9 +115,7 @@
 	TDLS = 6,
 	P2P_GO_NOA_DECOUPLE_INIT_SCAN = 7,
 	WLANACTIVE_OFFLOAD = 8,
-#ifdef FEATURE_WLAN_EXTSCAN
 	EXTENDED_SCAN = 9,
-#endif
 #ifdef FEATURE_WLAN_SCAN_PNO
 	PNO = 10,
 #endif