diff --git a/Kbuild b/Kbuild index 83ba1b6df2..61a9f3d5dd 100644 --- a/Kbuild +++ b/Kbuild @@ -310,6 +310,9 @@ endif ifeq ($(CONFIG_WLAN_SET_MON_CHAN), y) HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_set_mon_chan.o endif +ifeq ($(CONFIG_WLAN_SET_RANGE_EXT), y) +HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_set_range_ext.o +endif ifeq ($(CONFIG_WLAN_SET_RADAR), y) HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_set_radar.o endif @@ -2624,6 +2627,7 @@ endif #normally, TDLS negative behavior is not needed cppflags-$(CONFIG_QCOM_TDLS) += -DFEATURE_WLAN_TDLS cppflags-$(CONFIG_WLAN_GET_TDLS_PEERS) += -DWLAN_GET_TDLS_PEERS +cppflags-$(CONFIG_WLAN_SET_RANGE_EXT) += -DWLAN_SET_RANGE_EXT cppflags-$(CONFIG_QCACLD_WLAN_LFR3) += -DWLAN_FEATURE_ROAM_OFFLOAD diff --git a/configs/default_defconfig b/configs/default_defconfig index ad626b3175..a6a3c05a7e 100644 --- a/configs/default_defconfig +++ b/configs/default_defconfig @@ -392,6 +392,12 @@ ifeq ($(CONFIG_SLUB_DEBUG), y) CONFIG_LOCK_STATS_ON:= y endif +ifeq ($(CONFIG_WLAN_SYSFS), y) +ifeq ($(CONFIG_MPC_UT_FRAMEWORK), y) + CONFIG_WLAN_SET_RANGE_EXT := y +endif +endif + ifeq (y,$(findstring y,$(CONFIG_QCA_WIFI_SDIO) $(CONFIG_HIF_USB))) CONFIG_HL_DP_SUPPORT := y else diff --git a/core/hdd/inc/wlan_hdd_sysfs_set_range_ext.h b/core/hdd/inc/wlan_hdd_sysfs_set_range_ext.h new file mode 100644 index 0000000000..25802fd02f --- /dev/null +++ b/core/hdd/inc/wlan_hdd_sysfs_set_range_ext.h @@ -0,0 +1,59 @@ +/* + * 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_set_range_ext.h + * + * implementation for creating sysfs file range_ext + */ + +#ifndef _WLAN_HDD_SYSFS_SET_RANGE_EXT_H +#define _WLAN_HDD_SYSFS_SET_RANGE_EXT_H + +#if defined(WLAN_SYSFS) && defined(WLAN_SET_RANGE_EXT) +/** + * wlan_hdd_sysfs_range_ext_create() - API to create range_ext + * @adapter: hdd adapter + * + * this file is created per adapter. + * file path: /sys/class/net/wlanxx/range_ext + * (wlanxx is adapter name) + * usage: + * echo 1 > range_ext + * + * Return: none + */ +void hdd_sysfs_range_ext_create(struct hdd_adapter *adapter); + +/** + * hdd_sysfs_range_ext_destroy() - API to destroy range_ext + * @adapter: pointer to adapter + * + * Return: none + */ +void hdd_sysfs_range_ext_destroy(struct hdd_adapter *adapter); +#else +static inline void +hdd_sysfs_range_ext_create(struct hdd_adapter *adapter) +{ +} + +static inline void +hdd_sysfs_range_ext_destroy(struct hdd_adapter *adapter) +{ +} +#endif +#endif /* #ifndef _WLAN_HDD_SYSFS_SET_RANGE_EXT_H */ diff --git a/core/hdd/src/wlan_hdd_sysfs.c b/core/hdd/src/wlan_hdd_sysfs.c index bd5a2b137e..7dcc88d2ec 100644 --- a/core/hdd/src/wlan_hdd_sysfs.c +++ b/core/hdd/src/wlan_hdd_sysfs.c @@ -58,6 +58,7 @@ #include #include #include +#include #include #include #include @@ -659,11 +660,13 @@ hdd_sysfs_create_sta_adapter_root_obj(struct hdd_adapter *adapter) hdd_sysfs_get_tdls_peers_interface_create(adapter); hdd_sysfs_get_temp_create(adapter); hdd_sysfs_motion_detection_create(adapter); + hdd_sysfs_range_ext_create(adapter); } static void hdd_sysfs_destroy_sta_adapter_root_obj(struct hdd_adapter *adapter) { + hdd_sysfs_range_ext_destroy(adapter); hdd_sysfs_motion_detection_destroy(adapter); hdd_sysfs_get_temp_destroy(adapter); hdd_sysfs_get_tdls_peers_interface_destroy(adapter); @@ -708,11 +711,13 @@ hdd_sysfs_create_sap_adapter_root_obj(struct hdd_adapter *adapter) hdd_sysfs_txrx_fw_stats_create(adapter); hdd_sysfs_txrx_stats_create(adapter); hdd_sysfs_get_temp_create(adapter); + hdd_sysfs_range_ext_create(adapter); } static void hdd_sysfs_destroy_sap_adapter_root_obj(struct hdd_adapter *adapter) { + hdd_sysfs_range_ext_destroy(adapter); hdd_sysfs_get_temp_destroy(adapter); hdd_sysfs_txrx_stats_destroy(adapter); hdd_sysfs_txrx_fw_stats_destroy(adapter); diff --git a/core/hdd/src/wlan_hdd_sysfs_set_range_ext.c b/core/hdd/src/wlan_hdd_sysfs_set_range_ext.c new file mode 100644 index 0000000000..a0b6b8731c --- /dev/null +++ b/core/hdd/src/wlan_hdd_sysfs_set_range_ext.c @@ -0,0 +1,115 @@ +/* + * 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_range_ext.c + * + * implementation for creating sysfs file range_ext + */ + +#include +#include "osif_vdev_sync.h" +#include +#include "wma_api.h" +#include "wlan_hdd_sysfs_set_range_ext.h" + +static ssize_t __hdd_sysfs_range_ext_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, errno; + + 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("range_ext: 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; + + hdd_debug("WMI_VDEV_PARAM_HE_RANGE_EXT %d", value); + errno = wma_cli_set_command(adapter->vdev_id, + WMI_VDEV_PARAM_HE_RANGE_EXT, + value, VDEV_CMD); + if (errno) + hdd_err("Failed to set he_range_ext firmware param, errno %d", + errno); + + return count; +} + +static ssize_t +hdd_sysfs_range_ext_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_range_ext_store(net_dev, buf, count); + + osif_vdev_sync_op_stop(vdev_sync); + + return errno_size; +} + +static DEVICE_ATTR(range_ext, 0220, NULL, hdd_sysfs_range_ext_store); + +void hdd_sysfs_range_ext_create(struct hdd_adapter *adapter) +{ + int error; + + error = device_create_file(&adapter->dev->dev, &dev_attr_range_ext); + if (error) + hdd_err("could not create range_ext sysfs file"); +} + +void hdd_sysfs_range_ext_destroy(struct hdd_adapter *adapter) +{ + device_remove_file(&adapter->dev->dev, &dev_attr_range_ext); +}