qcacld-3.0: Add a sysfs replacement for crash_inject
As part of WEXT replacement, replace crash_inject with a sysfs file. file path: /sys/class/net/wlanxx/crash_inject wlanxx is adapter name example: echo 1 1 > crash_inject Change-Id: Ica3e2c0941e9217b42ed7cd3194fe98c8f0d0aa9 CRs-Fixed: 2680684
This commit is contained in:
parent
53af32a7d9
commit
4accf73e7b
6
Kbuild
6
Kbuild
@ -122,9 +122,6 @@ HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_debugfs_unit_test.o
|
||||
ifeq ($(CONFIG_WLAN_MWS_INFO_DEBUGFS), y)
|
||||
HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_debugfs_coex.o
|
||||
endif
|
||||
ifeq ($(CONFIG_WLAN_DEBUG_CRASH_INJECT), y)
|
||||
HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_debugfs_crash_inject.o
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_WLAN_CONV_SPECTRAL_ENABLE),y)
|
||||
@ -269,6 +266,9 @@ endif
|
||||
ifeq ($(CONFIG_WLAN_REASSOC), y)
|
||||
HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_reassoc.o
|
||||
endif
|
||||
ifeq ($(CONFIG_WLAN_DEBUG_CRASH_INJECT), y)
|
||||
HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_crash_inject.o
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_QCACLD_FEATURE_FW_STATE), y)
|
||||
|
@ -35,7 +35,6 @@
|
||||
#include <wlan_hdd_debugfs_llstat.h>
|
||||
#include <wlan_hdd_debugfs_mibstat.h>
|
||||
#include "wlan_hdd_debugfs_unit_test.h"
|
||||
#include "wlan_hdd_debugfs_crash_inject.h"
|
||||
|
||||
|
||||
#define MAX_USER_COMMAND_SIZE_WOWL_ENABLE 8
|
||||
@ -566,9 +565,6 @@ QDF_STATUS hdd_debugfs_init(struct hdd_adapter *adapter)
|
||||
if (wlan_hdd_debugfs_resume_create(adapter))
|
||||
return QDF_STATUS_E_FAILURE;
|
||||
|
||||
if (wlan_hdd_debugfs_crash_inject_create(adapter))
|
||||
return QDF_STATUS_E_FAILURE;
|
||||
|
||||
return QDF_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1,164 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2020 The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for
|
||||
* any purpose with or without fee is hereby granted, provided that the
|
||||
* above copyright notice and this permission notice appear in all
|
||||
* copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
|
||||
* AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* DOC: wlan_hdd_debugfs_crash_inject.c
|
||||
*
|
||||
* implementation for creating debugfs file crash_inject
|
||||
*/
|
||||
|
||||
#include <wlan_hdd_includes.h>
|
||||
#include "osif_vdev_sync.h"
|
||||
#include "wlan_hdd_debugfs_crash_inject.h"
|
||||
|
||||
/* strlen("1 1") + 1(\n) */
|
||||
#define MIN_USER_COMMAND_SIZE_CRASH_INJECT 4
|
||||
#define MAX_USER_COMMAND_SIZE_CRASH_INJECT 32
|
||||
|
||||
/**
|
||||
* __wlan_hdd_write_crash_inject_debugfs()
|
||||
* - crash inject test debugfs handler
|
||||
*
|
||||
* @net_dev: net_device context used to register the debugfs file
|
||||
* @buf: text being written to the debugfs
|
||||
* @count: size of @buf
|
||||
* @ppos: (unused) offset into the virtual file system
|
||||
*
|
||||
* Return: number of bytes processed
|
||||
*/
|
||||
static ssize_t __wlan_hdd_write_crash_inject_debugfs(
|
||||
struct net_device *net_dev,
|
||||
const char __user *buf, size_t count,
|
||||
loff_t *ppos)
|
||||
{
|
||||
struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(net_dev);
|
||||
struct hdd_context *hdd_ctx;
|
||||
char buf_local[MAX_USER_COMMAND_SIZE_CRASH_INJECT + 1];
|
||||
char *sptr, *token;
|
||||
uint32_t val1, val2;
|
||||
int ret;
|
||||
|
||||
if (hdd_validate_adapter(adapter)) {
|
||||
hdd_err_rl("adapter validate fail");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
hdd_ctx = WLAN_HDD_GET_CTX(adapter);
|
||||
ret = wlan_hdd_validate_context(hdd_ctx);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
if (!wlan_hdd_validate_modules_state(hdd_ctx))
|
||||
return -EINVAL;
|
||||
|
||||
if (count < MIN_USER_COMMAND_SIZE_CRASH_INJECT ||
|
||||
count > MAX_USER_COMMAND_SIZE_CRASH_INJECT) {
|
||||
hdd_err_rl("Command length (%zu) is invalid, expected [%d, %d]",
|
||||
count,
|
||||
MIN_USER_COMMAND_SIZE_CRASH_INJECT,
|
||||
MAX_USER_COMMAND_SIZE_CRASH_INJECT);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Get command from user */
|
||||
if (copy_from_user(buf_local, buf, count))
|
||||
return -EFAULT;
|
||||
/* default 'echo' cmd takes new line character to here*/
|
||||
if (buf_local[count - 1] == '\n')
|
||||
buf_local[count - 1] = '\0';
|
||||
else
|
||||
buf_local[count] = '\0';
|
||||
|
||||
sptr = buf_local;
|
||||
hdd_nofl_info("unit_test: count %zu buf_local:(%s) net_devname %s",
|
||||
count, buf_local, net_dev->name);
|
||||
|
||||
/* Get val1 */
|
||||
token = strsep(&sptr, " ");
|
||||
if (!token)
|
||||
return -EINVAL;
|
||||
if (kstrtou32(token, 0, &val1))
|
||||
return -EINVAL;
|
||||
|
||||
/* Get val2 */
|
||||
token = strsep(&sptr, " ");
|
||||
if (!token)
|
||||
return -EINVAL;
|
||||
if (kstrtou32(token, 0, &val2))
|
||||
return -EINVAL;
|
||||
|
||||
ret = hdd_crash_inject(adapter, val1, val2);
|
||||
if (ret != 0) {
|
||||
hdd_err_rl("hdd_crash_inject returned %d", ret);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* wlan_hdd_write_crash_inject_debugfs()
|
||||
* - wrapper for __wlan_hdd_write_crash_inject_debugfs
|
||||
*
|
||||
* @file: file pointer
|
||||
* @buf: buffer
|
||||
* @count: count
|
||||
* @ppos: position pointer
|
||||
*
|
||||
* Return: number of bytes processed or errno
|
||||
*/
|
||||
static ssize_t wlan_hdd_write_crash_inject_debugfs(
|
||||
struct file *file,
|
||||
const char __user *buf,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
struct net_device *net_dev = file_inode(file)->i_private;
|
||||
struct osif_vdev_sync *vdev_sync;
|
||||
ssize_t errno_size;
|
||||
|
||||
errno_size = osif_vdev_sync_op_start(net_dev, &vdev_sync);
|
||||
if (errno_size)
|
||||
return errno_size;
|
||||
|
||||
errno_size = __wlan_hdd_write_crash_inject_debugfs(
|
||||
net_dev, buf, count, ppos);
|
||||
if (errno_size < 0)
|
||||
hdd_err_rl("errno_size %zd", errno_size);
|
||||
|
||||
osif_vdev_sync_op_stop(vdev_sync);
|
||||
|
||||
return errno_size;
|
||||
}
|
||||
|
||||
static const struct file_operations fops_crash_inject_debugfs = {
|
||||
.write = wlan_hdd_write_crash_inject_debugfs,
|
||||
.owner = THIS_MODULE,
|
||||
.llseek = default_llseek,
|
||||
};
|
||||
|
||||
int wlan_hdd_debugfs_crash_inject_create(struct hdd_adapter *adapter)
|
||||
{
|
||||
struct net_device *net_dev = adapter->dev;
|
||||
|
||||
if (!debugfs_create_file("crash_inject", 00400 | 00200,
|
||||
adapter->debugfs_phy,
|
||||
net_dev, &fops_crash_inject_debugfs))
|
||||
return -EINVAL;
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2020 The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for
|
||||
* any purpose with or without fee is hereby granted, provided that the
|
||||
* above copyright notice and this permission notice appear in all
|
||||
* copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
|
||||
* AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* DOC: wlan_hdd_debugfs_crash_inject.h
|
||||
*
|
||||
* implementation for creating debugfs file crash_inject
|
||||
*/
|
||||
|
||||
#ifndef _WLAN_HDD_DEBUGFS_CRASH_INJECT_H
|
||||
#define _WLAN_HDD_DEBUGFS_CRASH_INJECT_H
|
||||
|
||||
#if defined(WLAN_DEBUGFS) && defined(CONFIG_WLAN_DEBUG_CRASH_INJECT)
|
||||
/**
|
||||
* wlan_hdd_debugfs_crash_inject_create() - API to create crash_inject
|
||||
* @adapter: hdd adapter
|
||||
*
|
||||
* this file is created per adapter.
|
||||
* file path: /sys/kernel/debug/wlan_xx/crash_inject
|
||||
* (wlan_xx is adapter name)
|
||||
* usage:
|
||||
* echo [arg_0] [arg_1] > crash_inject
|
||||
*
|
||||
* Return: 0 on success and errno on failure
|
||||
*/
|
||||
int wlan_hdd_debugfs_crash_inject_create(struct hdd_adapter *adapter);
|
||||
#else
|
||||
static inline int
|
||||
wlan_hdd_debugfs_crash_inject_create(struct hdd_adapter *adapter)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#endif /* #ifndef _WLAN_HDD_DEBUGFS_CRASH_INJECT_H */
|
@ -39,6 +39,8 @@
|
||||
#include "osif_sync.h"
|
||||
#include <wlan_hdd_sysfs_set_fw_mode_cfg.h>
|
||||
#include <wlan_hdd_sysfs_reassoc.h>
|
||||
#include "wlan_hdd_sysfs_crash_inject.h"
|
||||
|
||||
|
||||
#define MAX_PSOC_ID_SIZE 10
|
||||
|
||||
@ -611,11 +613,13 @@ hdd_sysfs_create_sta_adapter_root_obj(struct hdd_adapter *adapter)
|
||||
{
|
||||
hdd_sysfs_create_bcn_reception_interface(adapter);
|
||||
hdd_sysfs_reassoc_create(adapter);
|
||||
hdd_sysfs_crash_inject_create(adapter);
|
||||
}
|
||||
|
||||
static void
|
||||
hdd_sysfs_destroy_sta_adapter_root_obj(struct hdd_adapter *adapter)
|
||||
{
|
||||
hdd_sysfs_crash_inject_destroy(adapter);
|
||||
hdd_sysfs_reassoc_destroy(adapter);
|
||||
hdd_sysfs_destroy_bcn_reception_interface(adapter);
|
||||
}
|
||||
@ -623,11 +627,13 @@ hdd_sysfs_destroy_sta_adapter_root_obj(struct hdd_adapter *adapter)
|
||||
static void
|
||||
hdd_sysfs_create_sap_adapter_root_obj(struct hdd_adapter *adapter)
|
||||
{
|
||||
hdd_sysfs_crash_inject_create(adapter);
|
||||
}
|
||||
|
||||
static void
|
||||
hdd_sysfs_destroy_sap_adapter_root_obj(struct hdd_adapter *adapter)
|
||||
{
|
||||
hdd_sysfs_crash_inject_destroy(adapter);
|
||||
}
|
||||
|
||||
void hdd_create_sysfs_files(struct hdd_context *hdd_ctx)
|
||||
|
125
core/hdd/src/wlan_hdd_sysfs_crash_inject.c
Normal file
125
core/hdd/src/wlan_hdd_sysfs_crash_inject.c
Normal file
@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Copyright (c) 2020, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* DOC: wlan_hdd_sysfs_crash_inject.c
|
||||
*
|
||||
* implementation for creating sysfs file crash_inject
|
||||
*/
|
||||
|
||||
#include <wlan_hdd_includes.h>
|
||||
#include "osif_vdev_sync.h"
|
||||
#include "wlan_hdd_sysfs.h"
|
||||
#include "wlan_hdd_sysfs_crash_inject.h"
|
||||
|
||||
static ssize_t __hdd_sysfs_crash_inject_store(
|
||||
struct net_device *net_dev,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(net_dev);
|
||||
struct hdd_context *hdd_ctx;
|
||||
char buf_local[MAX_SYSFS_USER_COMMAND_SIZE_LENGTH + 1];
|
||||
char *sptr, *token;
|
||||
uint32_t val1, val2;
|
||||
int ret;
|
||||
|
||||
if (hdd_validate_adapter(adapter)) {
|
||||
hdd_err_rl("adapter validate fail");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
hdd_ctx = WLAN_HDD_GET_CTX(adapter);
|
||||
ret = wlan_hdd_validate_context(hdd_ctx);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
if (!wlan_hdd_validate_modules_state(hdd_ctx))
|
||||
return -EINVAL;
|
||||
|
||||
ret = hdd_sysfs_validate_and_copy_buf(buf_local, sizeof(buf_local),
|
||||
buf, count);
|
||||
if (ret) {
|
||||
hdd_err_rl("invalid input");
|
||||
return ret;
|
||||
}
|
||||
|
||||
hdd_nofl_info("crash_inject: count %zu buf_local:(%s) net_devname %s",
|
||||
count, buf_local, net_dev->name);
|
||||
|
||||
sptr = buf_local;
|
||||
/* Get val1 */
|
||||
token = strsep(&sptr, " ");
|
||||
if (!token)
|
||||
return -EINVAL;
|
||||
if (kstrtou32(token, 0, &val1))
|
||||
return -EINVAL;
|
||||
|
||||
/* Get val2 */
|
||||
token = strsep(&sptr, " ");
|
||||
if (!token)
|
||||
return -EINVAL;
|
||||
if (kstrtou32(token, 0, &val2))
|
||||
return -EINVAL;
|
||||
|
||||
ret = hdd_crash_inject(adapter, val1, val2);
|
||||
if (ret != 0) {
|
||||
hdd_err_rl("hdd_crash_inject returned %d", ret);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t hdd_sysfs_crash_inject_store(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char const *buf, size_t count)
|
||||
{
|
||||
struct net_device *net_dev = container_of(dev, struct net_device, dev);
|
||||
struct osif_vdev_sync *vdev_sync;
|
||||
ssize_t errno_size;
|
||||
|
||||
errno_size = osif_vdev_sync_op_start(net_dev, &vdev_sync);
|
||||
if (errno_size)
|
||||
return errno_size;
|
||||
|
||||
errno_size = __hdd_sysfs_crash_inject_store(
|
||||
net_dev, buf, count);
|
||||
if (errno_size < 0)
|
||||
hdd_err_rl("errno_size %zd", errno_size);
|
||||
|
||||
osif_vdev_sync_op_stop(vdev_sync);
|
||||
|
||||
return errno_size;
|
||||
}
|
||||
|
||||
static DEVICE_ATTR(crash_inject, 0220,
|
||||
NULL, hdd_sysfs_crash_inject_store);
|
||||
|
||||
int hdd_sysfs_crash_inject_create(struct hdd_adapter *adapter)
|
||||
{
|
||||
int error;
|
||||
|
||||
error = device_create_file(&adapter->dev->dev, &dev_attr_crash_inject);
|
||||
if (error)
|
||||
hdd_err("could not create crash_inject sysfs file");
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
void hdd_sysfs_crash_inject_destroy(struct hdd_adapter *adapter)
|
||||
{
|
||||
device_remove_file(&adapter->dev->dev, &dev_attr_crash_inject);
|
||||
}
|
61
core/hdd/src/wlan_hdd_sysfs_crash_inject.h
Normal file
61
core/hdd/src/wlan_hdd_sysfs_crash_inject.h
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2020, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* DOC: wlan_hdd_sysfs_crash_inject.h
|
||||
*
|
||||
* implementation for creating sysfs file crash_inject
|
||||
*/
|
||||
|
||||
#ifndef _WLAN_HDD_SYSFS_CRASH_INJECT_H
|
||||
#define _WLAN_HDD_SYSFS_CRASH_INJECT_H
|
||||
|
||||
#if defined(WLAN_SYSFS) && defined(CONFIG_WLAN_DEBUG_CRASH_INJECT)
|
||||
/**
|
||||
* hdd_sysfs_crash_inject_create() - API to create crash_inject
|
||||
* @adapter: hdd adapter
|
||||
*
|
||||
* this file is created per adapter.
|
||||
* file path: /sys/class/net/wlan_xx/crash_inject
|
||||
* (wlan_xx is adapter name)
|
||||
* usage:
|
||||
* echo [arg_0] [arg_1] > crash_inject
|
||||
*
|
||||
* Return: 0 on success and errno on failure
|
||||
*/
|
||||
int hdd_sysfs_crash_inject_create(struct hdd_adapter *adapter);
|
||||
|
||||
/**
|
||||
* hdd_sysfs_crash_inject_destroy() -
|
||||
* API to destroy crash_inject sys file
|
||||
* @adapter: pointer to adapter
|
||||
*
|
||||
* Return: none
|
||||
*/
|
||||
void hdd_sysfs_crash_inject_destroy(struct hdd_adapter *adapter);
|
||||
#else
|
||||
static inline int
|
||||
hdd_sysfs_crash_inject_create(struct hdd_adapter *adapter)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void
|
||||
hdd_sysfs_crash_inject_destroy(struct hdd_adapter *adapter)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
#endif /* #ifndef _WLAN_HDD_SYSFS_CRASH_INJECT_H */
|
Loading…
Reference in New Issue
Block a user