浏览代码

qcacld-3.0: Add CFG INI item to control various unit test features

Suspend/Resume unit test IOCTLs and other unit test features are only
enabled in defconfig debug builds and always disabled in production
builds. Add CFG INI item to disable these test IOCTLs even in defconfig
build such that by default on all build combinations unit test IOCTLs
are always disabled.

Change-Id: I71a63d2b85800b630d7c18eb77a3cffddcd66fbb
CRs-Fixed: 2221874
Rajeev Kumar 7 年之前
父节点
当前提交
15b40a23a9
共有 4 个文件被更改,包括 48 次插入4 次删除
  1. 17 0
      core/hdd/inc/wlan_hdd_cfg.h
  2. 11 0
      core/hdd/src/wlan_hdd_cfg.c
  3. 19 1
      core/hdd/src/wlan_hdd_power.c
  4. 1 3
      core/hdd/src/wlan_hdd_wext.c

+ 17 - 0
core/hdd/inc/wlan_hdd_cfg.h

@@ -13919,6 +13919,22 @@ enum hdd_external_acs_freq_band {
 #define CFG_TX_SCH_DELAY_MAX           (5)
 #define CFG_TX_SCH_DELAY_DEFAULT       (2)
 
+/*
+ * <ini>
+ * gEnableUnitTestFramework - Enable/Disable unit test framework
+ * @Min: 0
+ * @Max: 1
+ * @Default: 0
+ *
+ * Usage: Internal (only for dev and test team)
+ *
+ * </ini>
+ */
+#define CFG_ENABLE_UNIT_TEST_FRAMEWORK_NAME    "gEnableUnitTestFramework"
+#define CFG_ENABLE_UNIT_TEST_FRAMEWORK_MIN     (0)
+#define CFG_ENABLE_UNIT_TEST_FRAMEWORK_MAX     (1)
+#define CFG_ENABLE_UINT_TEST_FRAMEWORK_DEFAULT (0)
+
 /*
  * Type declarations
  */
@@ -14795,6 +14811,7 @@ struct hdd_config {
 	bool enable_bt_chain_separation;
 	uint8_t enable_tx_sch_delay;
 	HDD_GREEN_AP_CFG_FIELDS
+	bool is_unit_test_framework_enabled;
 };
 
 #define VAR_OFFSET(_Struct, _Var) (offsetof(_Struct, _Var))

+ 11 - 0
core/hdd/src/wlan_hdd_cfg.c

@@ -5330,6 +5330,14 @@ struct reg_table_entry g_registry_table[] = {
 		     CFG_TX_SCH_DELAY_MAX),
 
 	HDD_GREEN_AP_REG_VARIABLES
+
+	REG_VARIABLE(CFG_ENABLE_UNIT_TEST_FRAMEWORK_NAME,
+		     WLAN_PARAM_Integer,
+		     struct hdd_config, is_unit_test_framework_enabled,
+		     VAR_FLAGS_OPTIONAL | VAR_FLAGS_RANGE_CHECK_ASSUME_DEFAULT,
+		     CFG_ENABLE_UINT_TEST_FRAMEWORK_DEFAULT,
+		     CFG_ENABLE_UNIT_TEST_FRAMEWORK_MIN,
+		     CFG_ENABLE_UNIT_TEST_FRAMEWORK_MAX),
 };
 
 
@@ -7203,6 +7211,9 @@ void hdd_cfg_print(struct hdd_context *hdd_ctx)
 		  hdd_ctx->config->channel_select_logic_conc);
 
 	hdd_nud_cfg_print(hdd_ctx);
+	hdd_debug("Name = [%s] value = [0x%x]",
+		  CFG_ENABLE_UNIT_TEST_FRAMEWORK_NAME,
+		  hdd_ctx->config->is_unit_test_framework_enabled);
 }
 
 

+ 19 - 1
core/hdd/src/wlan_hdd_power.c

@@ -2285,15 +2285,24 @@ int hdd_wlan_fake_apps_suspend(struct wiphy *wiphy, struct net_device *dev,
 			       enum wow_interface_pause pause_setting,
 			       enum wow_resume_trigger resume_setting)
 {
+	int errno;
 	qdf_device_t qdf_dev;
 	struct hif_opaque_softc *hif_ctx;
-	int errno;
+	struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
 	struct wow_enable_params wow_params = {
 		.is_unit_test = true,
 		.interface_pause = pause_setting,
 		.resume_trigger = resume_setting
 	};
 
+	if (wlan_hdd_validate_context(hdd_ctx))
+		return -EINVAL;
+
+	if (!hdd_ctx->config->is_unit_test_framework_enabled) {
+		hdd_warn_rl("UT framework is disabled");
+		return -EINVAL;
+	}
+
 	hdd_info("Unit-test suspend WLAN");
 
 	if (pause_setting < WOW_INTERFACE_PAUSE_DEFAULT ||
@@ -2393,6 +2402,15 @@ link_down:
 int hdd_wlan_fake_apps_resume(struct wiphy *wiphy, struct net_device *dev)
 {
 	struct hif_opaque_softc *hif_ctx;
+	struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
+
+	if (wlan_hdd_validate_context(hdd_ctx))
+		return -EINVAL;
+
+	if (!hdd_ctx->config->is_unit_test_framework_enabled) {
+		hdd_warn_rl("UT framework is disabled");
+		return -EINVAL;
+	}
 
 	hif_ctx = cds_get_context(QDF_MODULE_ID_HIF);
 	if (!hif_ctx) {

+ 1 - 3
core/hdd/src/wlan_hdd_wext.c

@@ -9354,12 +9354,10 @@ static int __iw_set_two_ints_getnone(struct net_device *dev,
 	case WE_SET_MON_MODE_CHAN:
 		ret = wlan_hdd_set_mon_chan(adapter, value[1], value[2]);
 		break;
-	case WE_SET_WLAN_SUSPEND: {
-		hdd_info("STA unit-test suspend(%d, %d)", value[1], value[2]);
+	case WE_SET_WLAN_SUSPEND:
 		ret = hdd_wlan_fake_apps_suspend(hdd_ctx->wiphy, dev,
 						 value[1], value[2]);
 		break;
-	}
 	case WE_SET_WLAN_RESUME:
 		ret = hdd_wlan_fake_apps_resume(hdd_ctx->wiphy, dev);
 		break;