From 15b40a23a9c738f86029fefa208ee3ced0534c97 Mon Sep 17 00:00:00 2001 From: Rajeev Kumar Date: Thu, 12 Apr 2018 11:45:24 -0700 Subject: [PATCH] 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 --- core/hdd/inc/wlan_hdd_cfg.h | 17 +++++++++++++++++ core/hdd/src/wlan_hdd_cfg.c | 11 +++++++++++ core/hdd/src/wlan_hdd_power.c | 20 +++++++++++++++++++- core/hdd/src/wlan_hdd_wext.c | 4 +--- 4 files changed, 48 insertions(+), 4 deletions(-) diff --git a/core/hdd/inc/wlan_hdd_cfg.h b/core/hdd/inc/wlan_hdd_cfg.h index bf10d821fc..3463e16c0d 100644 --- a/core/hdd/inc/wlan_hdd_cfg.h +++ b/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) +/* + * + * gEnableUnitTestFramework - Enable/Disable unit test framework + * @Min: 0 + * @Max: 1 + * @Default: 0 + * + * Usage: Internal (only for dev and test team) + * + * + */ +#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)) diff --git a/core/hdd/src/wlan_hdd_cfg.c b/core/hdd/src/wlan_hdd_cfg.c index eb205c3a7e..594699cafd 100644 --- a/core/hdd/src/wlan_hdd_cfg.c +++ b/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); } diff --git a/core/hdd/src/wlan_hdd_power.c b/core/hdd/src/wlan_hdd_power.c index b6d837abca..7ae2749ab3 100644 --- a/core/hdd/src/wlan_hdd_power.c +++ b/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) { diff --git a/core/hdd/src/wlan_hdd_wext.c b/core/hdd/src/wlan_hdd_wext.c index ecdaa82f51..0ae8b70ab9 100644 --- a/core/hdd/src/wlan_hdd_wext.c +++ b/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;