qcacld-3.0: Better featurize the SSR injection debug code
The driver supports a "SSR injection" feature that is used during
testing to validate certain recovery features. Currently this feature
is protected by a generic WLAN_DEBUG feature flag, and in addition
there are two separate debug ioctl handlers which have duplicate
code. In order to better support a finer level of configurability
introduce a new configuration flag and consolidate to a single
implementation of the feature under that flag.
Change-Id: I73e8dd4580ca53d129ae0181ffc46d011699f3dc
CRs-Fixed: 2224815
diff --git a/Kbuild b/Kbuild
index 965666e..372d9f0 100644
--- a/Kbuild
+++ b/Kbuild
@@ -303,6 +303,7 @@
else
CONFIG_FEATURE_PKTLOG := y
endif
+ CONFIG_WLAN_DEBUG_CRASH_INJECT := y
endif
#Enable WLAN/Power debugfs feature only if debug_fs is enabled
@@ -2063,7 +2064,7 @@
-DHDD_TRACE_RECORD
endif
endif
-
+ccflags-$(CONFIG_WLAN_DEBUG_CRASH_INJECT) += -DCONFIG_WLAN_DEBUG_CRASH_INJECT
ccflags-$(CONFIG_FEATURE_UNIT_TEST_SUSPEND) += -DWLAN_SUSPEND_RESUME_TEST
ifeq ($(CONFIG_LEAK_DETECTION), y)
diff --git a/core/hdd/inc/qc_sap_ioctl.h b/core/hdd/inc/qc_sap_ioctl.h
index ff3ec98..fe9993c 100644
--- a/core/hdd/inc/qc_sap_ioctl.h
+++ b/core/hdd/inc/qc_sap_ioctl.h
@@ -141,9 +141,7 @@
#define QCSAP_IOCTL_GET_INI_CFG (SIOCIWFIRSTPRIV + 25)
#define QCSAP_IOCTL_SET_INI_CFG (SIOCIWFIRSTPRIV + 26)
#define QCSAP_IOCTL_SET_TWO_INT_GET_NONE (SIOCIWFIRSTPRIV + 28)
-#ifdef WLAN_DEBUG
#define QCSAP_IOCTL_SET_FW_CRASH_INJECT 1
-#endif
#define QCSAP_IOCTL_DUMP_DP_TRACE_LEVEL 2
#define QCSAP_ENABLE_FW_PROFILE 3
#define QCSAP_SET_FW_PROFILE_HIST_INTVL 4
diff --git a/core/hdd/inc/wlan_hdd_wext.h b/core/hdd/inc/wlan_hdd_wext.h
index 61c43d3..ce3daad 100644
--- a/core/hdd/inc/wlan_hdd_wext.h
+++ b/core/hdd/inc/wlan_hdd_wext.h
@@ -340,4 +340,27 @@
*/
int wlan_hdd_set_mon_chan(struct hdd_adapter *adapter, uint32_t chan,
uint32_t bandwidth);
+
+/**
+ * hdd_crash_inject() - Inject a crash
+ * @adapter: Adapter upon which the command was received
+ * @v1: first value to inject
+ * @v2: second value to inject
+ *
+ * This function is the handler for the crash inject debug feature.
+ * This feature only exists for internal testing and must not be
+ * enabled on a production device.
+ *
+ * Return: result of the command
+ */
+#ifdef CONFIG_WLAN_DEBUG_CRASH_INJECT
+int hdd_crash_inject(struct hdd_adapter *adapter, uint32_t v1, uint32_t v2);
+#else
+static inline
+int hdd_crash_inject(struct hdd_adapter *adapter, uint32_t v1, uint32_t v2)
+{
+ return -ENOTSUPP;
+}
+#endif
+
#endif /* __WEXT_IW_H__ */
diff --git a/core/hdd/src/wlan_hdd_hostapd.c b/core/hdd/src/wlan_hdd_hostapd.c
index 204d333..4256393 100644
--- a/core/hdd/src/wlan_hdd_hostapd.c
+++ b/core/hdd/src/wlan_hdd_hostapd.c
@@ -3055,24 +3055,9 @@
return ret;
switch (sub_cmd) {
-#ifdef WLAN_DEBUG
case QCSAP_IOCTL_SET_FW_CRASH_INJECT:
- hdd_err("WE_SET_FW_CRASH_INJECT: %d %d",
- value[1], value[2]);
- if (!hdd_ctx->config->crash_inject_enabled) {
- hdd_err("Crash Inject ini disabled, Ignore Crash Inject");
- return 0;
- }
- if (value[1] == 3) {
- cds_trigger_recovery(QDF_REASON_UNSPECIFIED);
- return 0;
- }
- ret = wma_cli_set2_command(adapter->session_id,
- GEN_PARAM_CRASH_INJECT,
- value[1], value[2],
- GEN_CMD);
+ ret = hdd_crash_inject(adapter, value[1], value[2]);
break;
-#endif
case QCSAP_IOCTL_DUMP_DP_TRACE_LEVEL:
hdd_debug("WE_DUMP_DP_TRACE: %d %d",
value[1], value[2]);
@@ -5868,7 +5853,7 @@
}
,
/* handlers for sub-ioctl */
-#ifdef WLAN_DEBUG
+#ifdef CONFIG_WLAN_DEBUG_CRASH_INJECT
{
QCSAP_IOCTL_SET_FW_CRASH_INJECT,
IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
diff --git a/core/hdd/src/wlan_hdd_wext.c b/core/hdd/src/wlan_hdd_wext.c
index e341bf4..e8cc4c9 100644
--- a/core/hdd/src/wlan_hdd_wext.c
+++ b/core/hdd/src/wlan_hdd_wext.c
@@ -2786,9 +2786,7 @@
/* Private ioctls and their sub-ioctls */
#define WLAN_PRIV_SET_TWO_INT_GET_NONE (SIOCIWFIRSTPRIV + 28)
#define WE_SET_SMPS_PARAM 1
-#ifdef WLAN_DEBUG
#define WE_SET_FW_CRASH_INJECT 2
-#endif
#define WE_DUMP_DP_TRACE_LEVEL 3
/* Private sub ioctl for enabling and setting histogram interval of profiling */
#define WE_ENABLE_FW_PROFILE 4
@@ -9314,6 +9312,32 @@
}
}
+#ifdef CONFIG_WLAN_DEBUG_CRASH_INJECT
+int hdd_crash_inject(struct hdd_adapter *adapter, uint32_t v1, uint32_t v2)
+{
+ struct hdd_context *hdd_ctx;
+ int ret;
+
+ hdd_debug("WE_SET_FW_CRASH_INJECT: %d %d",
+ v1, v2);
+ pr_err("SSR is triggered by iwpriv CRASH_INJECT: %d %d\n",
+ v1, v2);
+ hdd_ctx = WLAN_HDD_GET_CTX(adapter);
+ if (!hdd_ctx->config->crash_inject_enabled) {
+ hdd_err("Crash Inject ini disabled, Ignore Crash Inject");
+ return 0;
+ }
+ if (v1 == 3) {
+ cds_trigger_recovery(QDF_REASON_UNSPECIFIED);
+ return 0;
+ }
+ ret = wma_cli_set2_command(adapter->session_id,
+ GEN_PARAM_CRASH_INJECT,
+ v1, v2, GEN_CMD);
+ return ret;
+}
+#endif
+
static int __iw_set_two_ints_getnone(struct net_device *dev,
struct iw_request_info *info,
union iwreq_data *wrqu, char *extra)
@@ -9343,25 +9367,9 @@
| value[2],
VDEV_CMD);
break;
-#ifdef WLAN_DEBUG
case WE_SET_FW_CRASH_INJECT:
- hdd_debug("WE_SET_FW_CRASH_INJECT: %d %d",
- value[1], value[2]);
- pr_err("SSR is triggered by iwpriv CRASH_INJECT: %d %d\n",
- value[1], value[2]);
- if (!hdd_ctx->config->crash_inject_enabled) {
- hdd_err("Crash Inject ini disabled, Ignore Crash Inject");
- return 0;
- }
- if (value[1] == 3) {
- cds_trigger_recovery(QDF_REASON_UNSPECIFIED);
- return 0;
- }
- ret = wma_cli_set2_command(adapter->session_id,
- GEN_PARAM_CRASH_INJECT,
- value[1], value[2], GEN_CMD);
+ ret = hdd_crash_inject(adapter, value[1], value[2]);
break;
-#endif
case WE_ENABLE_FW_PROFILE:
hdd_err("WE_ENABLE_FW_PROFILE: %d %d",
value[1], value[2]);
@@ -10585,18 +10593,18 @@
IW_PRIV_TYPE_BYTE | sizeof(struct dot11p_channel_sched),
0, "set_dot11p" }
,
-#ifdef WLAN_DEBUG
+#ifdef CONFIG_WLAN_DEBUG_CRASH_INJECT
{WE_SET_FW_CRASH_INJECT,
IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
0, "crash_inject"}
,
+#endif
#if defined(WMI_INTERFACE_EVENT_LOGGING) || defined(FEATURE_HTC_CREDIT_HISTORY)
{WE_LOG_BUFFER,
IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
0, "log_buffer"}
,
#endif
-#endif
#ifdef WLAN_SUSPEND_RESUME_TEST
{WE_SET_WLAN_SUSPEND,
IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,