Browse Source

qcacld-3.0: Add support for RF test mode and safe mode config

Add RF test mode and safe mode configuration support for 6GHz.

Change-Id: Icb6382f425b21e89a8cb2481c8f7bf480c4f6c19
CRs-Fixed: 2904749
Kiran Kumar Lokere 4 years ago
parent
commit
c702414dd6

+ 1 - 1
components/mlme/core/src/wlan_mlme_main.c

@@ -425,7 +425,7 @@ static void mlme_init_generic_cfg(struct wlan_objmgr_psoc *psoc,
 	gen->wls_6ghz_capable = cfg_get(psoc, CFG_WLS_6GHZ_CAPABLE);
 	mlme_init_pmf_cfg(psoc, gen);
 	mlme_init_lpass_support_cfg(psoc, gen);
-
+	gen->enabled_rf_test_mode = cfg_default(CFG_RF_TEST_MODE_SUPP_ENABLED);
 	gen->enabled_11h = cfg_get(psoc, CFG_11H_SUPPORT_ENABLED);
 	gen->enabled_11d = cfg_get(psoc, CFG_11D_SUPPORT_ENABLED);
 	gen->enable_beacon_reception_stats =

+ 18 - 0
components/mlme/dispatcher/inc/cfg_mlme_generic.h

@@ -160,6 +160,23 @@ enum wlan_wds_mode {
 		1, \
 		"11d Enable Flag")
 
+/*
+ * rf_test_mode_enabled - Enable rf test mode support
+ * @Min: 0
+ * @Max: 1
+ * @Default: 1
+ *
+ * This cfg is used to set rf test mode support flag
+ *
+ * Related: None
+ *
+ * Supported Feature: STA
+ */
+#define CFG_RF_TEST_MODE_SUPP_ENABLED CFG_BOOL( \
+		"rf_test_mode_enabled", \
+		1, \
+		"rf test mode Enable Flag")
+
 /*
  * <ini>
  * BandCapability - Preferred band (0: 2.4G, 5G, and 6G,
@@ -906,5 +923,6 @@ enum wlan_wds_mode {
 	CFG(CFG_SAE_CONNECION_RETRIES) \
 	CFG(CFG_WLS_6GHZ_CAPABLE) \
 	CFG(CFG_MONITOR_MODE_CONCURRENCY) \
+	CFG(CFG_RF_TEST_MODE_SUPP_ENABLED) \
 	CFG_WDS_MODE_ALL
 #endif /* __CFG_MLME_GENERIC_H */

+ 20 - 0
components/mlme/dispatcher/inc/wlan_mlme_api.h

@@ -2126,6 +2126,26 @@ wlan_mlme_is_11d_enabled(struct wlan_objmgr_psoc *psoc, bool *value);
 QDF_STATUS
 wlan_mlme_set_11d_enabled(struct wlan_objmgr_psoc *psoc, bool value);
 
+/**
+ * wlan_mlme_is_rf_test_mode_enabled() - Get the rf test mode flag
+ * @psoc: psoc context
+ * @value: Enable/Disable value ptr.
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+wlan_mlme_is_rf_test_mode_enabled(struct wlan_objmgr_psoc *psoc, bool *value);
+
+/**
+ * wlan_mlme_set_rf_test_mode_enabled() - Set the rf test mode flag
+ * @psoc: psoc context
+ * @value: Enable/Disable value.
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+wlan_mlme_set_rf_test_mode_enabled(struct wlan_objmgr_psoc *psoc, bool value);
+
 /**
  * wlan_mlme_get_sta_miracast_mcc_rest_time() - Get STA/MIRACAST MCC rest time
  *

+ 2 - 0
components/mlme/dispatcher/inc/wlan_mlme_public_struct.h

@@ -1304,6 +1304,7 @@ struct wlan_mlme_ratemask {
  * @dual_sta_roam_fw_support: Firmware support for dual sta roaming feature
  * @sae_connect_retries: sae connect retry bitmask
  * @wls_6ghz_capable: wifi location service(WLS) is 6ghz capable
+ * @enabled_rf_test_mode: Enable/disable the RF test mode config
  * @monitor_mode_concurrency: Monitor mode concurrency supported
  * @ocv_support: FW supports OCV or not
  * @wds_mode: wds mode supported
@@ -1348,6 +1349,7 @@ struct wlan_mlme_generic {
 	bool dual_sta_roam_fw_support;
 	uint32_t sae_connect_retries;
 	bool wls_6ghz_capable;
+	bool enabled_rf_test_mode;
 	enum monitor_mode_concurrency monitor_mode_concurrency;
 	bool ocv_support;
 	enum wlan_wds_mode wds_mode;

+ 30 - 0
components/mlme/dispatcher/inc/wlan_mlme_ucfg_api.h

@@ -2641,6 +2641,36 @@ ucfg_mlme_set_11d_enabled(struct wlan_objmgr_psoc *psoc, bool value)
 	return wlan_mlme_set_11d_enabled(psoc, value);
 }
 
+/**
+ * ucfg_mlme_is_rf_test_mode_enabled() - Get rf test mode flag
+ * @psoc: pointer to psoc object
+ * @value: Value that needs to be set from the caller
+ *
+ * Inline UCFG API to be used by HDD/OSIF callers
+ *
+ * Return: QDF Status
+ */
+static inline QDF_STATUS
+ucfg_mlme_is_rf_test_mode_enabled(struct wlan_objmgr_psoc *psoc, bool *value)
+{
+	return wlan_mlme_is_rf_test_mode_enabled(psoc, value);
+}
+
+/**
+ * ucfg_mlme_set_rf_test_mode_enabled() - Set rf test mode flag
+ * @psoc: pointer to psoc object
+ * @value: Value that needs to be set from the caller
+ *
+ * Inline UCFG API to be used by HDD/OSIF callers
+ *
+ * Return: QDF Status
+ */
+static inline QDF_STATUS
+ucfg_mlme_set_rf_test_mode_enabled(struct wlan_objmgr_psoc *psoc, bool value)
+{
+	return wlan_mlme_set_rf_test_mode_enabled(psoc, value);
+}
+
 /**
  * ucfg_mlme_get_opr_rate() - Get operational rate set
  * @psoc: pointer to vdev object

+ 28 - 0
components/mlme/dispatcher/src/wlan_mlme_api.c

@@ -2680,6 +2680,34 @@ wlan_mlme_set_11d_enabled(struct wlan_objmgr_psoc *psoc, bool value)
 	return QDF_STATUS_SUCCESS;
 }
 
+QDF_STATUS
+wlan_mlme_is_rf_test_mode_enabled(struct wlan_objmgr_psoc *psoc, bool *value)
+{
+	struct wlan_mlme_psoc_ext_obj *mlme_obj;
+
+	mlme_obj = mlme_get_psoc_ext_obj(psoc);
+	if (!mlme_obj)
+		return QDF_STATUS_E_FAILURE;
+
+	*value = mlme_obj->cfg.gen.enabled_rf_test_mode;
+
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS
+wlan_mlme_set_rf_test_mode_enabled(struct wlan_objmgr_psoc *psoc, bool value)
+{
+	struct wlan_mlme_psoc_ext_obj *mlme_obj;
+
+	mlme_obj = mlme_get_psoc_ext_obj(psoc);
+	if (!mlme_obj)
+		return QDF_STATUS_E_FAILURE;
+
+	mlme_obj->cfg.gen.enabled_rf_test_mode = value;
+
+	return QDF_STATUS_SUCCESS;
+}
+
 QDF_STATUS
 wlan_mlme_cfg_set_vht_chan_width(struct wlan_objmgr_psoc *psoc, uint8_t value)
 {

+ 8 - 0
core/hdd/inc/wlan_hdd_main.h

@@ -4184,6 +4184,14 @@ void hdd_unregister_notifiers(struct hdd_context *hdd_ctx);
  */
 int hdd_dbs_scan_selection_init(struct hdd_context *hdd_ctx);
 
+/**
+ * hdd_update_scan_config - API to update scan configuration parameters
+ * @hdd_ctx: HDD context
+ *
+ * Return: 0 if success else err
+ */
+int hdd_update_scan_config(struct hdd_context *hdd_ctx);
+
 /**
  * hdd_start_complete()- complete the start event
  * @ret: return value for complete event.

+ 27 - 0
core/hdd/src/wlan_hdd_cfg80211.c

@@ -7102,6 +7102,8 @@ wlan_hdd_wifi_test_config_policy[
 			.type = NLA_U8},
 		[QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_RU_242_TONE_TX] = {
 			.type = NLA_U8},
+		[QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_6GHZ_SECURITY_TEST_MODE]
+			= {.type = NLA_U8},
 };
 
 /**
@@ -9845,6 +9847,7 @@ __wlan_hdd_cfg80211_set_wifi_test_config(struct wiphy *wiphy,
 	uint8_t value = 0;
 	uint8_t wmm_mode = 0;
 	uint32_t cmd_id;
+	bool rf_test_mode = false;
 	struct set_wfatest_params wfa_param = {0};
 	struct hdd_station_ctx *hdd_sta_ctx =
 		WLAN_HDD_GET_STATION_CTX_PTR(adapter);
@@ -10406,6 +10409,30 @@ __wlan_hdd_cfg80211_set_wifi_test_config(struct wiphy *wiphy,
 		ret_val = ucfg_send_wfatest_cmd(adapter->vdev, &wfa_param);
 	}
 
+	cmd_id = QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_6GHZ_SECURITY_TEST_MODE;
+	if (tb[cmd_id]) {
+		status = ucfg_mlme_is_rf_test_mode_enabled(hdd_ctx->psoc,
+							   &rf_test_mode);
+		if (!QDF_IS_STATUS_SUCCESS(status)) {
+			hdd_err("Get rf test mode failed");
+			return QDF_STATUS_E_FAILURE;
+		}
+		if (rf_test_mode) {
+			hdd_err("rf test mode is enabled, ignore setting");
+			return 0;
+		}
+		cfg_val = nla_get_u8(tb[cmd_id]);
+		hdd_debug("safe mode setting %d", cfg_val);
+		if (cfg_val) {
+			wlan_cm_set_check_6ghz_security(hdd_ctx->psoc, false);
+			wlan_cm_set_6ghz_key_mgmt_mask(hdd_ctx->psoc,
+						       DEFAULT_KEYMGMT_6G_MASK);
+		} else {
+			wlan_cm_set_check_6ghz_security(hdd_ctx->psoc, true);
+			wlan_cm_set_6ghz_key_mgmt_mask(hdd_ctx->psoc,
+						       ALLOWED_KEYMGMT_6G_MASK);
+		}
+	}
 	cmd_id = QCA_WLAN_VENDOR_ATTR_WIFI_TEST_CONFIG_OCI_OVERRIDE;
 	if (tb[cmd_id]) {
 		struct nlattr *tb2[QCA_WLAN_VENDOR_ATTR_OCI_OVERRIDE_MAX + 1];

+ 22 - 0
core/hdd/src/wlan_hdd_ioctl.c

@@ -6387,9 +6387,12 @@ static int drv_cmd_set_fcc_channel(struct hdd_adapter *adapter,
 				   struct hdd_priv_data *priv_data)
 {
 	QDF_STATUS status;
+	QDF_STATUS status_6G = QDF_STATUS_SUCCESS;
 	int8_t input_value;
 	bool fcc_constraint;
 	int err;
+	uint32_t band_bitmap = 0;
+	bool rf_test_mode;
 
 	/*
 	 * This command would be called by user-space when it detects WLAN
@@ -6412,9 +6415,28 @@ static int drv_cmd_set_fcc_channel(struct hdd_adapter *adapter,
 
 	status = ucfg_reg_set_fcc_constraint(hdd_ctx->pdev, fcc_constraint);
 
+	status_6G = ucfg_mlme_is_rf_test_mode_enabled(hdd_ctx->psoc,
+						      &rf_test_mode);
+	if (!QDF_IS_STATUS_SUCCESS(status_6G)) {
+		hdd_err("Get rf test mode failed");
+		goto send_status;
+	}
+
+	if (!rf_test_mode) {
+		if (fcc_constraint)
+			band_bitmap |= (BIT(REG_BAND_5G) | BIT(REG_BAND_2G));
+		else
+			band_bitmap = REG_BAND_MASK_ALL;
+		if (hdd_reg_set_band(adapter->dev, band_bitmap))
+			status_6G = QDF_STATUS_E_FAILURE;
+	}
+
+send_status:
 	if (QDF_IS_STATUS_ERROR(status))
 		hdd_err("Failed to %s tx power for channels 12/13",
 			fcc_constraint ? "restore" : "reduce");
+	else
+		status = status_6G;
 
 	return qdf_status_to_os_return(status);
 }

+ 14 - 1
core/hdd/src/wlan_hdd_main.c

@@ -13827,6 +13827,7 @@ static int hdd_features_init(struct hdd_context *hdd_ctx)
 	int ret;
 	mac_handle_t mac_handle;
 	bool b_cts2self, is_imps_enabled;
+	bool rf_test_mode;
 
 	hdd_enter();
 
@@ -13915,6 +13916,18 @@ static int hdd_features_init(struct hdd_context *hdd_ctx)
 	wlan_hdd_twt_init(hdd_ctx);
 	wlan_hdd_gpio_wakeup_init(hdd_ctx);
 
+	status = ucfg_mlme_is_rf_test_mode_enabled(hdd_ctx->psoc,
+						   &rf_test_mode);
+	if (!QDF_IS_STATUS_SUCCESS(status)) {
+		hdd_err("Get rf test mode failed");
+		return QDF_STATUS_E_FAILURE;
+	}
+	if (!rf_test_mode) {
+		wlan_cm_set_check_6ghz_security(hdd_ctx->psoc, true);
+		wlan_cm_set_6ghz_key_mgmt_mask(hdd_ctx->psoc,
+					       ALLOWED_KEYMGMT_6G_MASK);
+	}
+
 	hdd_exit();
 	return 0;
 }
@@ -18014,7 +18027,7 @@ static int hdd_update_dfs_config(struct hdd_context *hdd_ctx)
  *
  * Return: 0 if success else err
  */
-static int hdd_update_scan_config(struct hdd_context *hdd_ctx)
+int hdd_update_scan_config(struct hdd_context *hdd_ctx)
 {
 	struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc;
 	struct scan_user_cfg scan_cfg;