diff --git a/Kbuild b/Kbuild index 9726e129c5..f52a5da73a 100644 --- a/Kbuild +++ b/Kbuild @@ -476,6 +476,10 @@ ifeq ($(CONFIG_WLAN_SYSFS_ROAM_TRIGGER_BITMAP), y) HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_roam_trigger_bitmap.o endif +ifeq ($(CONFIG_WLAN_SYSFS_RF_TEST_MODE), y) +HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_rf_test_mode.o +endif + endif # CONFIG_WLAN_SYSFS ifeq ($(CONFIG_QCACLD_FEATURE_FW_STATE), y) @@ -3661,6 +3665,7 @@ ccflags-$(CONFIG_WLAN_SYSFS_DFSNOL) += -DCONFIG_WLAN_SYSFS_DFSNOL ccflags-$(CONFIG_WLAN_SYSFS_WDS_MODE) += -DFEATURE_SYSFS_WDS_MODE ccflags-$(CONFIG_WLAN_SYSFS_ROAM_TRIGGER_BITMAP) += -DFEATURE_SYSFS_ROAM_TRIGGER_BITMAP cppflags-$(CONFIG_BCN_RATECODE_ENABLE) += -DWLAN_BCN_RATECODE_ENABLE +ccflags-$(CONFIG_WLAN_SYSFS_RF_TEST_MODE) += -DFEATURE_SYSFS_RF_TEST_MODE ifeq ($(CONFIG_LEAK_DETECTION), y) ccflags-y += \ diff --git a/Kconfig b/Kconfig index 93ae15ccbd..5c863a3d74 100644 --- a/Kconfig +++ b/Kconfig @@ -1895,4 +1895,8 @@ config QCA_WIFI_PEACH config BCN_RATECODE_ENABLE bool "enable CONFIG_BCN_RATECODE_ENABLE" default n + +config WLAN_SYSFS_RF_TEST_MODE + bool "enable CONFIG_WLAN_SYSFS_RF_TEST_MODE" + default n endif # QCA_CLD_WLAN diff --git a/configs/config_to_feature.h b/configs/config_to_feature.h index 90c241e984..2bc00f2ca2 100644 --- a/configs/config_to_feature.h +++ b/configs/config_to_feature.h @@ -924,6 +924,10 @@ #define FEATURE_SYSFS_ROAM_TRIGGER_BITMAP (1) #endif +#ifdef CONFIG_WLAN_SYSFS_RF_TEST_MODE +#define FEATURE_SYSFS_RF_TEST_MODE (1) +#endif + #ifdef CONFIG_RX_PERFORMANCE #define RX_PERFORMANCE (1) #endif diff --git a/configs/default_defconfig b/configs/default_defconfig index 4e79d463bf..8f89781d72 100644 --- a/configs/default_defconfig +++ b/configs/default_defconfig @@ -413,6 +413,7 @@ endif CONFIG_WLAN_SYSFS_DFSNOL := y CONFIG_WLAN_SYSFS_WDS_MODE := y CONFIG_WLAN_SYSFS_ROAM_TRIGGER_BITMAP := y + CONFIG_WLAN_SYSFS_RF_TEST_MODE := y endif CONFIG_WLAN_PDEV_VDEV_SEND_MULTI_PARAM := y CONFIG_WLAN_POWER_DEBUG := y diff --git a/configs/pineapple_gki_kiwi-v2_defconfig b/configs/pineapple_gki_kiwi-v2_defconfig index 74b07959fe..cf93d66212 100644 --- a/configs/pineapple_gki_kiwi-v2_defconfig +++ b/configs/pineapple_gki_kiwi-v2_defconfig @@ -328,6 +328,7 @@ CONFIG_WLAN_SYSFS_TEMPERATURE=y CONFIG_WLAN_SYSFS_TX_STBC=y CONFIG_WLAN_SYSFS_WLAN_DBG=y CONFIG_WLAN_SYSFS_BITRATES=y +CONFIG_WLAN_SYSFS_RF_TEST_MODE=y CONFIG_WLAN_THERMAL_CFG=y CONFIG_WLAN_THERMAL_MULTI_CLIENT_SUPPORT=y CONFIG_WLAN_TRACEPOINTS=y diff --git a/core/hdd/src/wlan_hdd_sysfs.c b/core/hdd/src/wlan_hdd_sysfs.c index 2044db5619..16d116bb87 100644 --- a/core/hdd/src/wlan_hdd_sysfs.c +++ b/core/hdd/src/wlan_hdd_sysfs.c @@ -95,6 +95,7 @@ #include #include #include +#include #define MAX_PSOC_ID_SIZE 10 @@ -966,12 +967,14 @@ void hdd_create_sysfs_files(struct hdd_context *hdd_ctx) hdd_sysfs_log_buffer_create(driver_kobject); hdd_sysfs_wds_mode_create(driver_kobject); hdd_sysfs_roam_trigger_bitmap_create(driver_kobject); + hdd_sysfs_rf_test_mode_create(driver_kobject); } } void hdd_destroy_sysfs_files(void) { if (QDF_GLOBAL_MISSION_MODE == hdd_get_conparam()) { + hdd_sysfs_rf_test_mode_destroy(driver_kobject); hdd_sysfs_roam_trigger_bitmap_destroy(driver_kobject); hdd_sysfs_wds_mode_destroy(driver_kobject); hdd_sysfs_log_buffer_destroy(driver_kobject); diff --git a/core/hdd/src/wlan_hdd_sysfs_rf_test_mode.c b/core/hdd/src/wlan_hdd_sysfs_rf_test_mode.c new file mode 100644 index 0000000000..c4d3a70590 --- /dev/null +++ b/core/hdd/src/wlan_hdd_sysfs_rf_test_mode.c @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. 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. + */ + +#include +#include "osif_psoc_sync.h" +#include +#include + +#define RF_TEST_MODE_ENABLE 1 + +static ssize_t __hdd_sysfs_rf_test_mode_show(struct hdd_context *hdd_ctx, + struct kobj_attribute *attr, + char *buf) +{ + int ret = 0; + bool value; + + if (!hdd_ctx || !hdd_ctx->psoc) { + hdd_err_rl("invalid input"); + return ret; + } + + ret = scnprintf(buf, PAGE_SIZE, "0x%x", + ucfg_mlme_is_rf_test_mode_enabled(hdd_ctx->psoc, + &value)); + + return ret; +} + +static ssize_t hdd_sysfs_rf_test_mode_show(struct kobject *kobj, + struct kobj_attribute *attr, + char *buf) +{ + struct osif_psoc_sync *psoc_sync; + struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); + ssize_t errno_size; + + errno_size = osif_psoc_sync_op_start(wiphy_dev(hdd_ctx->wiphy), + &psoc_sync); + if (errno_size) + return errno_size; + + errno_size = __hdd_sysfs_rf_test_mode_show(hdd_ctx, attr, buf); + + osif_psoc_sync_op_stop(psoc_sync); + + return errno_size; +} + +static ssize_t +__hdd_sysfs_rf_test_mode_store(struct hdd_context *hdd_ctx, + struct kobj_attribute *attr, + const char *buf, size_t count) +{ + char buf_local[MAX_SYSFS_USER_COMMAND_SIZE_LENGTH + 1]; + char *sptr, *token; + uint32_t value; + int ret = 0; + + if (!hdd_ctx || !hdd_ctx->psoc) { + hdd_err_rl("invalid hdd ctx"); + return ret; + } + + 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; + token = strsep(&sptr, " "); + if (!token) + return -EINVAL; + if (kstrtou32(token, 0, &value)) + return -EINVAL; + + hdd_debug("rf_test_mode: 0x%x", value); + + /* + * To enable rf_test_mode if value set is greater than one + * adjust this value as one by default + */ + if (value > RF_TEST_MODE_ENABLE) + value = RF_TEST_MODE_ENABLE; + + ucfg_mlme_set_rf_test_mode_enabled(hdd_ctx->psoc, value); + + return count; +} + +static ssize_t +hdd_sysfs_rf_test_mode_store(struct kobject *kobj, + struct kobj_attribute *attr, + char const *buf, size_t count) +{ + struct osif_psoc_sync *psoc_sync; + struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); + ssize_t errno_size; + + errno_size = osif_psoc_sync_op_start(wiphy_dev(hdd_ctx->wiphy), + &psoc_sync); + if (errno_size) + return errno_size; + + errno_size = __hdd_sysfs_rf_test_mode_store(hdd_ctx, attr, buf, + count); + + osif_psoc_sync_op_stop(psoc_sync); + + return errno_size; +} + +static struct kobj_attribute rf_test_mode_attribute = + __ATTR(rf_test_mode, 0664, hdd_sysfs_rf_test_mode_show, + hdd_sysfs_rf_test_mode_store); + +int hdd_sysfs_rf_test_mode_create(struct kobject *driver_kobject) +{ + int error; + + if (!driver_kobject) { + hdd_err("could not get driver kobject!"); + return -EINVAL; + } + + error = sysfs_create_file(driver_kobject, + &rf_test_mode_attribute.attr); + if (error) + hdd_err("could not create rf_test_mode sysfs file"); + + return error; +} + +void +hdd_sysfs_rf_test_mode_destroy(struct kobject *driver_kobject) +{ + if (!driver_kobject) { + hdd_err("could not get driver kobject!"); + return; + } + sysfs_remove_file(driver_kobject, &rf_test_mode_attribute.attr); +} diff --git a/core/hdd/src/wlan_hdd_sysfs_rf_test_mode.h b/core/hdd/src/wlan_hdd_sysfs_rf_test_mode.h new file mode 100644 index 0000000000..c4ffa92653 --- /dev/null +++ b/core/hdd/src/wlan_hdd_sysfs_rf_test_mode.h @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. 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. + */ + +#ifndef _WLAN_HDD_SYSFS_RF_TEST_MODE_H +#define _WLAN_HDD_SYSFS_RF_TEST_MODE_H + +#if defined(WLAN_SYSFS) && defined(FEATURE_SYSFS_RF_TEST_MODE) + +/** + * hdd_sysfs_rf_test_mode_create() - API to create rf_test_mode sysfs file + * + * @driver_kobject: sysfs driver kobject + * + * file path: /sys/kernel//rf_test_mode + * + * usage: + * echo [arg_0] > rf_test_mode + * + * Return: 0 on success and errno on failure + */ +int hdd_sysfs_rf_test_mode_create(struct kobject *driver_kobject); + +/** + * hdd_sysfs_rf_test_mode_destroy() - destroy hdd rf_test_mode sysfs node + * + * @driver_kobject: pointer to driver kobject + * + * Return: void + * + */ +void +hdd_sysfs_rf_test_mode_destroy(struct kobject *driver_kobject); + +#else + +static inline int +hdd_sysfs_rf_test_mode_create(struct kobject *driver_kobject) +{ + return 0; +} + +static inline void +hdd_sysfs_rf_test_mode_destroy(struct kobject *driver_kobject) +{ +} +#endif +#endif + diff --git a/wlan_qcacld3_modules.bzl b/wlan_qcacld3_modules.bzl index f8a9e3447c..030250ea49 100644 --- a/wlan_qcacld3_modules.bzl +++ b/wlan_qcacld3_modules.bzl @@ -1883,6 +1883,11 @@ _conditional_srcs = { "core/hdd/src/wlan_hdd_sysfs_roam_trigger_bitmap.c", ], }, + "CONFIG_WLAN_SYSFS_RF_TEST_MODE": { + True: [ + "core/hdd/src/wlan_hdd_sysfs_rf_test_mode.c", + ], + }, "CONFIG_WLAN_SYSFS_DP_STATS": { True: [ "core/hdd/src/wlan_hdd_sysfs_txrx_stats_console.c",