qcacmn: Add 2G channel active dwell time CFG/INI items

Add ini item to configure active dwell time of 2.4GHz band channels,
This will help to reduce AP search failure probability & hence
connection latency in 2.4GHz band channels especially in noisy
condition by increasing active dwell time.

Change-Id: I05259a8f1fd4a5c67da42e516721a01d32fa652e
CRs-Fixed: 2283692
diff --git a/umac/scan/core/src/wlan_scan_main.h b/umac/scan/core/src/wlan_scan_main.h
index 4a29335..3acbe27 100644
--- a/umac/scan/core/src/wlan_scan_main.h
+++ b/umac/scan/core/src/wlan_scan_main.h
@@ -251,6 +251,7 @@
 /**
  * struct scan_default_params - default scan parameters to be used
  * @active_dwell: default active dwell time
+ * @active_dwell_2g: default active dwell time for 2G channels, if it's not zero
  * @passive_dwell:default passive dwell time
  * @max_rest_time: default max rest time
  * @sta_miracast_mcc_rest_time: max rest time for miracast and mcc
@@ -326,6 +327,7 @@
  */
 struct scan_default_params {
 	uint32_t active_dwell;
+	uint32_t active_dwell_2g;
 	uint32_t passive_dwell;
 	uint32_t max_rest_time;
 	uint32_t sta_miracast_mcc_rest_time;
diff --git a/umac/scan/dispatcher/inc/wlan_scan_cfg.h b/umac/scan/dispatcher/inc/wlan_scan_cfg.h
index 0ae2f5c..461af38 100644
--- a/umac/scan/dispatcher/inc/wlan_scan_cfg.h
+++ b/umac/scan/dispatcher/inc/wlan_scan_cfg.h
@@ -31,7 +31,7 @@
  * @Max: 10000
  * @Default: 40
  *
- * This ini is used to set maximum channel time in secs spent in
+ * This ini is used to set maximum channel time in msecs spent in
  * active scan
  *
  * Related: None
@@ -47,12 +47,34 @@
 
 /*
  * <ini>
+ * active_max_channel_time_2g - Set max time for active 2G channel scan
+ * @Min: 0
+ * @Max: 10000
+ * @Default: 80
+ *
+ * This ini is used to set maximum time in msecs spent in active 2G channel scan
+ * if it's not zero, in case of zero, CFG_ACTIVE_MAX_CHANNEL_TIME is used for 2G
+ * channels also.
+ *
+ * Related: None
+ *
+ * Usage: External
+ *
+ * </ini>
+ */
+#define CFG_ACTIVE_MAX_2G_CHANNEL_TIME CFG_INI_UINT(\
+		"active_max_channel_time_2g",\
+		0, 10000, MCL_OR_WIN_VALUE(80, 0),\
+		CFG_VALUE_OR_DEFAULT, "active dwell time for 2G channels")
+
+/*
+ * <ini>
  * gPassiveMaxChannelTime - Set max channel time for passive scan
  * @Min: 0
  * @Max: 10000
  * @Default: 110
  *
- * This ini is used to set maximum channel time in secs spent in
+ * This ini is used to set maximum channel time in msecs spent in
  * passive scan
  *
  * Related: None
@@ -137,6 +159,7 @@
 			0, 4, 2,\
 			CFG_VALUE_OR_DEFAULT,\
 			"Enable adaptive dwell mode")
+
 /*
  * <ini>
  * is_bssid_hint_priority - Set priority for connection with bssid_hint
@@ -164,6 +187,7 @@
 
 #define CFG_SCAN_ALL \
 	CFG(CFG_ACTIVE_MAX_CHANNEL_TIME) \
+	CFG(CFG_ACTIVE_MAX_2G_CHANNEL_TIME) \
 	CFG(CFG_PASSIVE_MAX_CHANNEL_TIME) \
 	CFG(CFG_SCAN_NUM_PROBES) \
 	CFG(CFG_SCAN_PROBE_REPEAT_TIME) \
diff --git a/umac/scan/dispatcher/inc/wlan_scan_public_structs.h b/umac/scan/dispatcher/inc/wlan_scan_public_structs.h
index d68c500..ddd9234 100644
--- a/umac/scan/dispatcher/inc/wlan_scan_public_structs.h
+++ b/umac/scan/dispatcher/inc/wlan_scan_public_structs.h
@@ -779,6 +779,7 @@
  * @scan_events: variable to read and set scan_ev_* flags in one shot
  *               can be used to dump all scan_ev_* flags for debug
  * @dwell_time_active: active dwell time
+ * @dwell_time_active_2g: active dwell time for 2G channels, if it's not zero
  * @dwell_time_passive: passive dwell time
  * @min_rest_time: min rest time
  * @max_rest_time: max rest time
@@ -857,6 +858,7 @@
 		uint32_t scan_events;
 	};
 	uint32_t dwell_time_active;
+	uint32_t dwell_time_active_2g;
 	uint32_t dwell_time_passive;
 	uint32_t min_rest_time;
 	uint32_t max_rest_time;
diff --git a/umac/scan/dispatcher/src/wlan_scan_ucfg_api.c b/umac/scan/dispatcher/src/wlan_scan_ucfg_api.c
index 3653a8d..76d6dd0 100644
--- a/umac/scan/dispatcher/src/wlan_scan_ucfg_api.c
+++ b/umac/scan/dispatcher/src/wlan_scan_ucfg_api.c
@@ -1428,6 +1428,8 @@
 	scan_obj->disable_timeout = false;
 	scan_obj->scan_def.active_dwell =
 			 cfg_get(psoc, CFG_ACTIVE_MAX_CHANNEL_TIME);
+	scan_obj->scan_def.active_dwell_2g =
+			 cfg_get(psoc, CFG_ACTIVE_MAX_2G_CHANNEL_TIME);
 	scan_obj->scan_def.passive_dwell =
 			 cfg_get(psoc, CFG_PASSIVE_MAX_CHANNEL_TIME);
 	scan_obj->scan_def.max_rest_time = SCAN_MAX_REST_TIME;
@@ -1571,6 +1573,7 @@
 	req->scan_req.p2p_scan_type = SCAN_NON_P2P_DEFAULT;
 	req->scan_req.scan_priority = def->scan_priority;
 	req->scan_req.dwell_time_active = def->active_dwell;
+	req->scan_req.dwell_time_active_2g = def->active_dwell_2g;
 	req->scan_req.dwell_time_passive = def->passive_dwell;
 	req->scan_req.min_rest_time = def->min_rest_time;
 	req->scan_req.max_rest_time = def->max_rest_time;
diff --git a/wmi/src/wmi_unified_tlv.c b/wmi/src/wmi_unified_tlv.c
index e4c7900..19b6273 100644
--- a/wmi/src/wmi_unified_tlv.c
+++ b/wmi/src/wmi_unified_tlv.c
@@ -2697,6 +2697,7 @@
 	copy_scan_event_cntrl_flags(cmd, params);
 
 	cmd->dwell_time_active = params->dwell_time_active;
+	cmd->dwell_time_active_2g = params->dwell_time_active_2g;
 	cmd->dwell_time_passive = params->dwell_time_passive;
 	cmd->min_rest_time = params->min_rest_time;
 	cmd->max_rest_time = params->max_rest_time;