Преглед изворни кода

qcacmn: Add support for adaptive dwell scan time

Dwell time can be modify based on channel congestion per scan
request.
Add changes to enable firmware to use scan control flag and select
dwell time optimization algorithm based on ini values.

Change-Id: Iea3de57c1b7d087442e4b8984b4184d24bb8c930
CRs-Fixed: 994443
Gupta, Kapil пре 9 година
родитељ
комит
86ab171ae4

+ 3 - 0
wmi/inc/wmi_unified_api.h

@@ -1229,4 +1229,7 @@ QDF_STATUS wmi_extract_vdev_extd_stats(void *wmi_hdl, void *evt_buf,
 
 QDF_STATUS wmi_unified_send_power_dbg_cmd(void *wmi_hdl,
 				struct wmi_power_dbg_params *param);
+QDF_STATUS wmi_unified_send_adapt_dwelltime_params_cmd(void *wmi_hdl,
+				   struct wmi_adaptive_dwelltime_params *
+				   wmi_param);
 #endif /* _WMI_UNIFIED_API_H_ */

+ 45 - 0
wmi/inc/wmi_unified_param.h

@@ -259,6 +259,22 @@ typedef enum {
 } WMI_HOST_WLAN_PHY_MODE;
 
 
+/**
+ * enum wmi_dwelltime_adaptive_mode: dwelltime_mode
+ * @WMI_DWELL_MODE_DEFAULT: Use firmware default mode
+ * @WMI_DWELL_MODE_CONSERVATIVE: Conservative adaptive mode
+ * @WMI_DWELL_MODE_MODERATE: Moderate adaptive mode
+ * @WMI_DWELL_MODE_AGGRESSIVE: Aggressive adaptive mode
+ * @WMI_DWELL_MODE_STATIC: static adaptive mode
+ */
+enum wmi_dwelltime_adaptive_mode {
+	WMI_DWELL_MODE_DEFAULT = 0,
+	WMI_DWELL_MODE_CONSERVATIVE = 1,
+	WMI_DWELL_MODE_MODERATE = 2,
+	WMI_DWELL_MODE_AGGRESSIVE = 3,
+	WMI_DWELL_MODE_STATIC = 4
+};
+
 #define MAX_NUM_CHAN 128
 
 /**
@@ -1840,6 +1856,13 @@ struct pno_nw_type {
  * @p24GProbeTemplate: 2.4G probe template
  * @us5GProbeTemplateLen: 5G probe template length
  * @p5GProbeTemplate: 5G probe template
+ * @pno_channel_prediction: PNO channel prediction feature status
+ * @top_k_num_of_channels: top K number of channels are used for tanimoto
+ * distance calculation.
+ * @stationary_thresh: threshold value to determine that the STA is stationary.
+ * @pnoscan_adaptive_dwell_mode: adaptive dwelltime mode for pno scan
+ * @channel_prediction_full_scan: periodic timer upon which a full scan needs
+ * to be triggered.
  */
 struct pno_scan_req_params {
 	uint8_t enable;
@@ -1862,6 +1885,7 @@ struct pno_scan_req_params {
 	bool pno_channel_prediction;
 	uint8_t top_k_num_of_channels;
 	uint8_t stationary_thresh;
+	enum wmi_dwelltime_adaptive_mode pnoscan_adaptive_dwell_mode;
 	uint32_t channel_prediction_full_scan;
 #endif
 };
@@ -1976,6 +2000,7 @@ struct wifi_scan_bucket_params {
  * @min_dwell_time_passive: per bucket minimum passive dwell time
  * @max_dwell_time_passive: per bucket maximum passive dwell time
  * @configuration_flags: configuration flags
+ * @extscan_adaptive_dwell_mode: adaptive dwelltime mode for extscan
  * @buckets: buckets array
  */
 struct wifi_scan_cmd_req_params {
@@ -1994,6 +2019,7 @@ struct wifi_scan_cmd_req_params {
 	uint32_t min_dwell_time_passive;
 	uint32_t max_dwell_time_passive;
 	uint32_t configuration_flags;
+	enum wmi_dwelltime_adaptive_mode extscan_adaptive_dwell_mode;
 	struct wifi_scan_bucket_params buckets[WMI_WLAN_EXTSCAN_MAX_BUCKETS];
 };
 
@@ -6303,5 +6329,24 @@ struct wmi_power_dbg_params {
 	uint32_t args[WMI_MAX_POWER_DBG_ARGS];
 };
 
+/**
+ * struct wmi_adaptive_dwelltime_params - the adaptive dwelltime params
+ * @vdev_id: vdev id
+ * @is_enabled: Adaptive dwell time is enabled/disabled
+ * @dwelltime_mode: global default adaptive dwell mode
+ * @lpf_weight: weight to calculate the average low pass
+ * filter for channel congestion
+ * @passive_mon_intval: intval to monitor wifi activity in passive scan in msec
+ * @wifi_act_threshold: % of wifi activity used in passive scan 0-100
+ *
+ */
+struct wmi_adaptive_dwelltime_params {
+	uint32_t vdev_id;
+	bool is_enabled;
+	enum wmi_dwelltime_adaptive_mode dwelltime_mode;
+	uint8_t lpf_weight;
+	uint8_t passive_mon_intval;
+	uint8_t wifi_act_threshold;
+};
 #endif /* _WMI_UNIFIED_PARAM_H_ */
 

+ 3 - 0
wmi/inc/wmi_unified_priv.h

@@ -1099,6 +1099,9 @@ QDF_STATUS (*extract_vdev_extd_stats)(wmi_unified_t wmi_handle, void *evt_buf,
 
 QDF_STATUS (*send_power_dbg_cmd)(wmi_unified_t wmi_handle,
 				struct wmi_power_dbg_params *param);
+
+QDF_STATUS (*send_adapt_dwelltime_params_cmd)(wmi_unified_t wmi_handle,
+			struct wmi_adaptive_dwelltime_params *dwelltime_params);
 };
 
 struct target_abi_version {

+ 20 - 0
wmi/src/wmi_unified_api.c

@@ -6016,6 +6016,26 @@ QDF_STATUS wmi_extract_vdev_extd_stats(void *wmi_hdl, void *evt_buf,
 	if (wmi_handle->ops->extract_vdev_extd_stats)
 		return wmi_handle->ops->extract_vdev_extd_stats(wmi_handle,
 				evt_buf, index, vdev_extd_stats);
+	return QDF_STATUS_E_FAILURE;
+}
+
+/**
+ * wmi_unified_send_adapt_dwelltime_params_cmd() - send wmi cmd of
+ * adaptive dwelltime configuration params
+ * @wma_handle:  wma handler
+ * @dwelltime_params: pointer to dwelltime_params
+ *
+ * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
+ */
+QDF_STATUS wmi_unified_send_adapt_dwelltime_params_cmd(void *wmi_hdl,
+			struct wmi_adaptive_dwelltime_params *dwelltime_params)
+{
+	wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl;
+
+	if (wmi_handle->ops->send_adapt_dwelltime_params_cmd)
+		return wmi_handle->ops->
+			send_adapt_dwelltime_params_cmd(wmi_handle,
+				  dwelltime_params);
 
 	return QDF_STATUS_E_FAILURE;
 }

+ 69 - 0
wmi/src/wmi_unified_tlv.c

@@ -4231,6 +4231,69 @@ QDF_STATUS send_roam_scan_offload_rssi_thresh_cmd_tlv(wmi_unified_t wmi_handle,
 	return status;
 }
 
+/**
+ * send_adapt_dwelltime_params_cmd_tlv() - send wmi cmd of adaptive dwelltime
+ * configuration params
+ * @wma_handle:  wma handler
+ * @dwelltime_params: pointer to dwelltime_params
+ *
+ * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
+ */
+QDF_STATUS send_adapt_dwelltime_params_cmd_tlv(wmi_unified_t wmi_handle,
+		struct wmi_adaptive_dwelltime_params *dwelltime_params)
+{
+	wmi_scan_adaptive_dwell_config_fixed_param *dwell_param;
+	wmi_scan_adaptive_dwell_parameters_tlv *cmd;
+	wmi_buf_t buf;
+	uint8_t *buf_ptr;
+	int32_t err;
+	int len;
+
+	len = sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
+	len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
+	len += sizeof(wmi_scan_adaptive_dwell_parameters_tlv);
+	buf = wmi_buf_alloc(wmi_handle, len);
+	if (!buf) {
+		WMI_LOGE("%s :Failed to allocate buffer to send cmd",
+				__func__);
+		return QDF_STATUS_E_NOMEM;
+	}
+	buf_ptr = (uint8_t *) wmi_buf_data(buf);
+	dwell_param = (wmi_scan_adaptive_dwell_config_fixed_param *) buf_ptr;
+	WMITLV_SET_HDR(&dwell_param->tlv_header,
+		WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_config_fixed_param,
+		WMITLV_GET_STRUCT_TLVLEN
+		(wmi_scan_adaptive_dwell_config_fixed_param));
+
+	dwell_param->enable = dwelltime_params->is_enabled;
+	buf_ptr += sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
+	WMITLV_SET_HDR(buf_ptr,
+			WMITLV_TAG_ARRAY_STRUC,
+			sizeof(wmi_scan_adaptive_dwell_parameters_tlv));
+	buf_ptr += WMI_TLV_HDR_SIZE;
+
+	cmd = (wmi_scan_adaptive_dwell_parameters_tlv *) buf_ptr;
+	WMITLV_SET_HDR(&cmd->tlv_header,
+			WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_parameters_tlv,
+			WMITLV_GET_STRUCT_TLVLEN(
+				wmi_scan_adaptive_dwell_parameters_tlv));
+
+	cmd->default_adaptive_dwell_mode = dwelltime_params->dwelltime_mode;
+	cmd->adapative_lpf_weight = dwelltime_params->lpf_weight;
+	cmd->passive_monitor_interval_ms = dwelltime_params->passive_mon_intval;
+	cmd->wifi_activity_threshold_pct = dwelltime_params->wifi_act_threshold;
+	err = wmi_unified_cmd_send(wmi_handle, buf,
+			len, WMI_SCAN_ADAPTIVE_DWELL_CONFIG_CMDID);
+	if (err) {
+		WMI_LOGE("Failed to send adapt dwelltime cmd err=%d", err);
+		wmi_buf_free(buf);
+		return QDF_STATUS_E_FAILURE;
+	}
+
+	return QDF_STATUS_SUCCESS;
+}
+
+
 /**
  * send_roam_scan_filter_cmd_tlv() - Filter to be applied while roaming
  * @wmi_handle:     wmi handle
@@ -4979,6 +5042,8 @@ QDF_STATUS wmi_get_buf_extscan_start_cmd(wmi_unified_t wmi_handle,
 			       WMI_SCAN_ADD_OFDM_RATES |
 			       WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ |
 			       WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
+	WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
+			pstart->extscan_adaptive_dwell_mode);
 	cmd->scan_priority = WMI_SCAN_PRIORITY_HIGH;
 	cmd->num_ssids = 0;
 	cmd->num_bssid = 0;
@@ -5425,6 +5490,8 @@ QDF_STATUS send_pno_start_cmd_tlv(wmi_unified_t wmi_handle,
 	cmd->vdev_id = pno->sessionId;
 	cmd->flags = WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN;
 
+	WMI_SCAN_SET_DWELL_MODE(cmd->flags,
+			pno->pnoscan_adaptive_dwell_mode);
 	/* Current FW does not support min-max range for dwell time */
 	cmd->active_dwell_time = pno->active_max_time;
 	cmd->passive_dwell_time = pno->passive_max_time;
@@ -11673,6 +11740,8 @@ struct wmi_ops tlv_ops =  {
 		 send_roam_scan_offload_rssi_change_cmd_tlv,
 	.send_get_buf_extscan_hotlist_cmd =
 		 send_get_buf_extscan_hotlist_cmd_tlv,
+	.send_adapt_dwelltime_params_cmd =
+		send_adapt_dwelltime_params_cmd_tlv,
 	.init_cmd_send = init_cmd_send_tlv,
 	.get_target_cap_from_service_ready = extract_service_ready_tlv,
 	.extract_hal_reg_cap = extract_hal_reg_cap_tlv,