diff --git a/Kbuild b/Kbuild index 965666ead85c..372d9f07ec1c 100644 --- a/Kbuild +++ b/Kbuild @@ -303,6 +303,7 @@ ifneq ($(TARGET_BUILD_VARIANT),user) 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 @@ ccflags-y += -DTRACE_RECORD \ -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 ff3ec981123a..fe9993c797da 100644 --- a/core/hdd/inc/qc_sap_ioctl.h +++ b/core/hdd/inc/qc_sap_ioctl.h @@ -141,9 +141,7 @@ struct channel_list_info { #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 61c43d389349..ce3daadbe407 100644 --- a/core/hdd/inc/wlan_hdd_wext.h +++ b/core/hdd/inc/wlan_hdd_wext.h @@ -340,4 +340,27 @@ int hdd_check_private_wext_control(struct hdd_context *hdd_ctx, */ 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 204d333f9185..4256393acaff 100644 --- a/core/hdd/src/wlan_hdd_hostapd.c +++ b/core/hdd/src/wlan_hdd_hostapd.c @@ -3055,24 +3055,9 @@ static int __iw_softap_set_two_ints_getnone(struct net_device *dev, 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 @@ static const struct iw_priv_args hostapd_private_args[] = { } , /* 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 e341bf4cd6e8..e8cc4c9d53ca 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 @@ static void hdd_ioctl_log_buffer(int log_id, uint32_t count) } } +#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 @@ static int __iw_set_two_ints_getnone(struct net_device *dev, | 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 @@ static const struct iw_priv_args we_private_args[] = { 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,