From 5bb4215e503ae59def68e089029604ffbd4e3af9 Mon Sep 17 00:00:00 2001 From: Aditya Kodukula Date: Thu, 14 May 2020 16:11:17 -0700 Subject: [PATCH] qcacld-3.0: Add a sysfs replacement for txrx_fw_st_rst As part of WEXT replacement, replace txrx_fw_st_rst with a sysfs file. file path: /sys/class/net/wlanxx/txrx_fw_st_rst wlanxx is adapter name example: echo 1 > txrx_fw_st_rst Change-Id: I654ea8b66e7067f0e1d23ff053fa4b8d163d878c CRs-Fixed: 2686665 --- Kbuild | 5 +- configs/default_defconfig | 1 + core/hdd/src/wlan_hdd_sysfs.c | 5 + core/hdd/src/wlan_hdd_sysfs_txrx_fw_st_rst.c | 139 +++++++++++++++++++ core/hdd/src/wlan_hdd_sysfs_txrx_fw_st_rst.h | 61 ++++++++ 5 files changed, 210 insertions(+), 1 deletion(-) create mode 100644 core/hdd/src/wlan_hdd_sysfs_txrx_fw_st_rst.c create mode 100644 core/hdd/src/wlan_hdd_sysfs_txrx_fw_st_rst.h diff --git a/Kbuild b/Kbuild index 6003a841a1f5..5ce11fe82c32 100644 --- a/Kbuild +++ b/Kbuild @@ -336,6 +336,9 @@ endif ifeq ($(CONFIG_WLAN_SET_WLAN_DBG), y) HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_set_wlan_dbg.o endif +ifeq ($(CONFIG_WLAN_TXRX_FW_ST_RST), y) +HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_txrx_fw_st_rst.o +endif endif ifeq ($(CONFIG_QCACLD_FEATURE_FW_STATE), y) @@ -2567,6 +2570,7 @@ cppflags-$(CONFIG_WLAN_WOWL_DEL_PTRN) += -DCONFIG_WLAN_WOWL_DEL_PTRN cppflags-$(CONFIG_WLAN_GET_TX_STBC) += -DCONFIG_WLAN_GET_TX_STBC cppflags-$(CONFIG_WLAN_GET_STATS) += -DCONFIG_WLAN_GET_STATS cppflags-$(CONFIG_WLAN_SET_WLAN_DBG) += -DCONFIG_WLAN_SET_WLAN_DBG +cppflags-$(CONFIG_WLAN_TXRX_FW_ST_RST) += -DCONFIG_WLAN_TXRX_FW_ST_RST cppflags-$(CONFIG_WLAN_SET_SCAN_CFG) += -DCONFIG_WLAN_SET_SCAN_CFG cppflags-$(CONFIG_WLAN_SET_MON_CHAN) += -DCONFIG_WLAN_SET_MON_CHAN cppflags-$(CONFIG_WLAN_SET_RADAR) += -DCONFIG_WLAN_SET_RADAR @@ -2578,7 +2582,6 @@ cppflags-$(CONFIG_WLAN_GET_TEMP) += -DCONFIG_WLAN_GET_TEMP cppflags-$(CONFIG_WLAN_THERMAL_CFG) += -DCONFIG_WLAN_THERMAL_CFG cppflags-$(CONFIG_FEATURE_UNIT_TEST_SUSPEND) += -DWLAN_SUSPEND_RESUME_TEST cppflags-$(CONFIG_FEATURE_WLM_STATS) += -DFEATURE_WLM_STATS - cppflags-$(CONFIG_WLAN_SYSFS_GET_STA_INFO) += -DWLAN_SYSFS_GET_STA_INFO ifeq ($(CONFIG_LEAK_DETECTION), y) diff --git a/configs/default_defconfig b/configs/default_defconfig index e18c18043164..27a387e7adac 100644 --- a/configs/default_defconfig +++ b/configs/default_defconfig @@ -187,6 +187,7 @@ ifeq ($(CONFIG_WLAN_SYSFS), y) CONFIG_WLAN_GET_TX_STBC := y CONFIG_WLAN_GET_STATS := y CONFIG_WLAN_SET_WLAN_DBG := y + CONFIG_WLAN_TXRX_FW_ST_RST := y CONFIG_WLAN_SET_SCAN_CFG := y CONFIG_WLAN_SET_MON_CHAN := y CONFIG_WLAN_SET_RADAR := y diff --git a/core/hdd/src/wlan_hdd_sysfs.c b/core/hdd/src/wlan_hdd_sysfs.c index 80afa3bc3450..ab96f3415d16 100644 --- a/core/hdd/src/wlan_hdd_sysfs.c +++ b/core/hdd/src/wlan_hdd_sysfs.c @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include @@ -646,6 +647,7 @@ hdd_sysfs_create_sta_adapter_root_obj(struct hdd_adapter *adapter) hdd_sysfs_wowl_del_ptrn_create(adapter); hdd_sysfs_get_tx_stbc_create(adapter); hdd_sysfs_get_stats_create(adapter); + hdd_sysfs_txrx_fw_st_rst_create(adapter); hdd_sysfs_txrx_fw_stats_create(adapter); hdd_sysfs_txrx_stats_create(adapter); hdd_sysfs_get_range_ext_create(adapter); @@ -663,6 +665,7 @@ hdd_sysfs_destroy_sta_adapter_root_obj(struct hdd_adapter *adapter) hdd_sysfs_get_range_ext_destroy(adapter); hdd_sysfs_txrx_stats_destroy(adapter); hdd_sysfs_txrx_fw_stats_destroy(adapter); + hdd_sysfs_txrx_fw_st_rst_destroy(adapter); hdd_sysfs_get_stats_destroy(adapter); hdd_sysfs_get_tx_stbc_destroy(adapter); hdd_sysfs_wowl_del_ptrn_destroy(adapter); @@ -690,6 +693,7 @@ hdd_sysfs_create_sap_adapter_root_obj(struct hdd_adapter *adapter) hdd_sysfs_connect_info_interface_create(adapter); hdd_sysfs_get_tx_stbc_create(adapter); hdd_sysfs_get_stats_create(adapter); + hdd_sysfs_txrx_fw_st_rst_create(adapter); hdd_sysfs_set_radar_create(adapter); hdd_sysfs_txrx_fw_stats_create(adapter); hdd_sysfs_txrx_stats_create(adapter); @@ -703,6 +707,7 @@ hdd_sysfs_destroy_sap_adapter_root_obj(struct hdd_adapter *adapter) hdd_sysfs_txrx_stats_destroy(adapter); hdd_sysfs_txrx_fw_stats_destroy(adapter); hdd_sysfs_set_radar_destroy(adapter); + hdd_sysfs_txrx_fw_st_rst_destroy(adapter); hdd_sysfs_get_stats_destroy(adapter); hdd_sysfs_get_tx_stbc_destroy(adapter); hdd_sysfs_connect_info_interface_destroy(adapter); diff --git a/core/hdd/src/wlan_hdd_sysfs_txrx_fw_st_rst.c b/core/hdd/src/wlan_hdd_sysfs_txrx_fw_st_rst.c new file mode 100644 index 000000000000..f1a3b1508e9f --- /dev/null +++ b/core/hdd/src/wlan_hdd_sysfs_txrx_fw_st_rst.c @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2011-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_txrx_fw_st_rst.c + * + * implementation for creating sysfs file txrx_fw_st_rst + */ + +#include +#include "osif_vdev_sync.h" +#include +#include +#include "wma.h" +#include "wma_api.h" + +static int hdd_sysfs_set_vdev(struct hdd_adapter *adapter, + int id, const char *id_string, + int value) +{ + int errno; + + hdd_debug("%s %d", id_string, value); + errno = wma_cli_set_command(adapter->vdev_id, id, value, VDEV_CMD); + if (errno) + hdd_err("Failed to set firmware, errno %d", errno); + + return errno; +} + +#define hdd_sysfs_set_vdev(adapter, id, value) \ + hdd_sysfs_set_vdev(adapter, id, #id, value) + +static ssize_t +__hdd_sysfs_txrx_fw_st_rst_store(struct net_device *net_dev, + char const *buf, size_t count) +{ + struct hdd_adapter *adapter = netdev_priv(net_dev); + char buf_local[MAX_SYSFS_USER_COMMAND_SIZE_LENGTH + 1]; + struct hdd_context *hdd_ctx; + char *sptr, *token; + uint32_t value; + 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; + } + + sptr = buf_local; + hdd_debug("txrx_fw_st_rst: count %zu buf_local:(%s) net_devname %s", + count, buf_local, net_dev->name); + + /* Get value */ + token = strsep(&sptr, " "); + if (!token) + return -EINVAL; + if (kstrtou32(token, 0, &value)) + return -EINVAL; + + ret = hdd_sysfs_set_vdev(adapter, + WMA_VDEV_TXRX_FWSTATS_RESET_CMDID, value); + + if (ret) { + hdd_err_rl("failed to set txrx fw stats reset: %d", ret); + return ret; + } + + return count; +} + +static ssize_t +hdd_sysfs_txrx_fw_st_rst_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_txrx_fw_st_rst_store(net_dev, buf, count); + + osif_vdev_sync_op_stop(vdev_sync); + + return errno_size; +} + +static DEVICE_ATTR(txrx_fw_st_rst, 0220, + NULL, hdd_sysfs_txrx_fw_st_rst_store); + +int hdd_sysfs_txrx_fw_st_rst_create(struct hdd_adapter *adapter) +{ + int error; + + error = device_create_file(&adapter->dev->dev, + &dev_attr_txrx_fw_st_rst); + if (error) + hdd_err("could not create txrx_fw_st_rst sysfs file"); + + return error; +} + +void hdd_sysfs_txrx_fw_st_rst_destroy(struct hdd_adapter *adapter) +{ + device_remove_file(&adapter->dev->dev, &dev_attr_txrx_fw_st_rst); +} diff --git a/core/hdd/src/wlan_hdd_sysfs_txrx_fw_st_rst.h b/core/hdd/src/wlan_hdd_sysfs_txrx_fw_st_rst.h new file mode 100644 index 000000000000..f3b74454f176 --- /dev/null +++ b/core/hdd/src/wlan_hdd_sysfs_txrx_fw_st_rst.h @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2011-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_txrx_fw_st_rst.h + * + * implementation for creating sysfs file txrx_fw_st_rst + */ + +#ifndef _WLAN_HDD_SYSFS_TXRX_FW_ST_RST_H +#define _WLAN_HDD_SYSFS_TXRX_FW_ST_RST_H + +#if defined(WLAN_SYSFS) && defined(CONFIG_WLAN_TXRX_FW_ST_RST) +/** + * wlan_hdd_sysfs_txrx_fw_st_rst_create() - API to create txrx_fw_st_rst + * @adapter: hdd adapter + * + * this file is created per adapter. + * file path: /sys/class/net/wlanxx/txrx_fw_st_rst + * (wlanxx is adapter name) + * usage: + * echo [arg_0] > txrx_fw_st_rst + * + * Return: 0 on success and errno on failure + */ +int hdd_sysfs_txrx_fw_st_rst_create(struct hdd_adapter *adapter); + +/** + * hdd_sysfs_txrx_fw_st_rst_destroy() - + * API to destroy txrx_fw_st_rst + * @adapter: pointer to adapter + * + * Return: none + */ +void hdd_sysfs_txrx_fw_st_rst_destroy(struct hdd_adapter *adapter); +#else +static inline int +hdd_sysfs_txrx_fw_st_rst_create(struct hdd_adapter *adapter) +{ + return 0; +} + +static inline void +hdd_sysfs_txrx_fw_st_rst_destroy(struct hdd_adapter *adapter) +{ +} +#endif +#endif /* #ifndef _WLAN_HDD_SYSFS_TXRX_FW_ST_RST_H */