qcacld-3.0: Add a sysfs replacement for set_fw_mode_cfg

As part of WEXT replacement, replace set_fw_mode_cfg with a sysfs file.

file path: /sys/kernel/wifi/set_fw_mode_cfg

example: echo 1 1 > set_fw_mode_cfg

Change-Id: I851df440f9eb5f73798deaf3b4d0f128f6925f26
CRs-Fixed: 2675570
This commit is contained in:
Alan Chen
2020-04-30 11:47:46 -07:00
committed by nshrivas
parent 6932d7009c
commit 549fb49793
7 changed files with 325 additions and 100 deletions

4
Kbuild
View File

@@ -263,6 +263,9 @@ endif
ifeq ($(CONFIG_WLAN_SYSFS), y)
HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs.o
ifeq ($(CONFIG_WLAN_SET_FW_MODE_CFG), y)
HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_set_fw_mode_cfg.o
endif
endif
ifeq ($(CONFIG_QCACLD_FEATURE_FW_STATE), y)
@@ -2489,6 +2492,7 @@ endif
endif
cppflags-$(CONFIG_UNIT_TEST) += -DWLAN_UNIT_TEST
cppflags-$(CONFIG_WLAN_DEBUG_CRASH_INJECT) += -DCONFIG_WLAN_DEBUG_CRASH_INJECT
cppflags-$(CONFIG_WLAN_SET_FW_MODE_CFG) += -DCONFIG_WLAN_SET_FW_MODE_CFG
cppflags-$(CONFIG_FEATURE_UNIT_TEST_SUSPEND) += -DWLAN_SUSPEND_RESUME_TEST
cppflags-$(CONFIG_FEATURE_WLM_STATS) += -DFEATURE_WLM_STATS

View File

@@ -173,6 +173,11 @@ ifneq ($(CONFIG_MOBILE_ROUTER), y)
CONFIG_QCOM_TDLS := y
CONFIG_WLAN_SYSFS := y
ifeq ($(CONFIG_WLAN_SYSFS), y)
CONFIG_WLAN_SET_FW_MODE_CFG := y
endif
CONFIG_WLAN_POWER_DEBUG := y
#Enable Beacon Reception Stats
CONFIG_FEATURE_BECN_STATS := y
@@ -514,9 +519,6 @@ endif
ifeq ($(CONFIG_WLAN_DEBUGFS), y)
CONFIG_WLAN_MWS_INFO_DEBUGFS := y
CONFIG_WLAN_FEATURE_MIB_STATS := y
else
CONFIG_WLAN_MWS_INFO_DEBUGFS := n
CONFIG_WLAN_FEATURE_MIB_STATS := n
endif
# Feature flags which are not (currently) configurable via Kconfig

View File

@@ -20,91 +20,23 @@
#define _WLAN_HDD_SYSFS_H_
#ifdef WLAN_SYSFS
/**
* hdd_sysfs_create_driver_root_obj() - create driver root kobject
*
* Return: none
*/
void hdd_sysfs_create_driver_root_obj(void);
#define MAX_SYSFS_USER_COMMAND_SIZE_LENGTH (32)
/**
* hdd_sysfs_destroy_driver_root_obj() - destroy driver root kobject
* hdd_sys_validate_and_copy_buf() - validate sysfs input buf and copy into
* destination buffer
* @dest_buf - pointer to destination buffer where data should be copied
* @dest_buf_size - size of destination buffer
* @src_buf - pointer to constant sysfs source buffer
* @src_buf_size - size of source buffer
*
* Return: none
* Return: 0 for success and error code for failure
*/
void hdd_sysfs_destroy_driver_root_obj(void);
int
hdd_sysfs_validate_and_copy_buf(char *dest_buf, size_t dest_buf_size,
char const *src_buf, size_t src_buf_size);
/**
* hdd_sysfs_create_version_interface() - create version interface
* @psoc: PSOC ptr
*
* Return: none
*/
void hdd_sysfs_create_version_interface(struct wlan_objmgr_psoc *psoc);
/**
* hdd_sysfs_destroy_version_interface() - destroy version interface
*
* Return: none
*/
void hdd_sysfs_destroy_version_interface(void);
#ifdef WLAN_POWER_DEBUG
/**
* hdd_sysfs_create_powerstats_interface() - create power_stats interface
*
* Return: none
*/
void hdd_sysfs_create_powerstats_interface(void);
/**
* hdd_sysfs_destroy_powerstats_interface() - destroy power_stats interface
*
* Return: none
*/
void hdd_sysfs_destroy_powerstats_interface(void);
#else
static inline
void hdd_sysfs_create_powerstats_interface(void)
{
}
static inline
void hdd_sysfs_destroy_powerstats_interface(void)
{
}
#endif /*End of WLAN_POWER_DEBUG */
#else
static inline
void hdd_sysfs_create_driver_root_obj(void)
{
}
static inline
void hdd_sysfs_destroy_driver_root_obj(void)
{
}
static inline
void hdd_sysfs_create_powerstats_interface(void)
{
}
static inline
void hdd_sysfs_destroy_powerstats_interface(void)
{
}
static inline
void hdd_sysfs_create_version_interface(struct wlan_objmgr_psoc *psoc)
{
}
static inline
void hdd_sysfs_destroy_version_interface(void)
{
}
#endif
#ifdef WLAN_FEATURE_BEACON_RECEPTION_STATS
/**
* hdd_sysfs_create_adapter_root_obj() - create adapter sysfs entries
* @adapter: HDD adapter
@@ -119,7 +51,38 @@ void hdd_sysfs_create_adapter_root_obj(struct hdd_adapter *adapter);
* Return: none
*/
void hdd_sysfs_destroy_adapter_root_obj(struct hdd_adapter *adapter);
/**
* hdd_create_sysfs_files() - create sysfs files
* @hdd_ctx: pointer to hdd context
*
* Return: none
*/
void hdd_create_sysfs_files(struct hdd_context *hdd_ctx);
/**
* hdd_destroy_sysfs_files() - destroy sysfs files
*
* Return: none
*/
void hdd_destroy_sysfs_files(void);
#else
static inline int
hdd_sysfs_validate_and_copy_buf(char *dest_buf, size_t dest_buf_size,
char const *src_buf, size_t src_buf_size)
{
return -EPERM;
}
static void hdd_create_sysfs_files(struct hdd_context *hdd_ctx)
{
}
static void hdd_destroy_sysfs_files(void)
{
}
static inline
void hdd_sysfs_create_adapter_root_obj(struct hdd_adapter *adapter)
{
@@ -129,5 +92,8 @@ static inline
void hdd_sysfs_destroy_adapter_root_obj(struct hdd_adapter *adapter)
{
}
#endif
#endif
#endif /* End of WLAN SYSFS*/
#endif /* End of _WLAN_HDD_SYSFS_H_ */

View File

@@ -3784,9 +3784,7 @@ int hdd_wlan_start_modules(struct hdd_context *hdd_ctx, bool reinit)
*/
hdd_spectral_register_to_dbr(hdd_ctx);
hdd_sysfs_create_driver_root_obj();
hdd_sysfs_create_version_interface(hdd_ctx->psoc);
hdd_sysfs_create_powerstats_interface();
hdd_create_sysfs_files(hdd_ctx);
hdd_update_hw_sw_info(hdd_ctx);
if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) {
@@ -3827,9 +3825,7 @@ int hdd_wlan_start_modules(struct hdd_context *hdd_ctx, bool reinit)
return 0;
destroy_driver_sysfs:
hdd_sysfs_destroy_powerstats_interface();
hdd_sysfs_destroy_version_interface();
hdd_sysfs_destroy_driver_root_obj();
hdd_destroy_sysfs_files();
cds_post_disable();
unregister_notifiers:
@@ -12867,9 +12863,7 @@ int hdd_wlan_stop_modules(struct hdd_context *hdd_ctx, bool ftm_mode)
goto done;
}
hdd_sysfs_destroy_powerstats_interface();
hdd_sysfs_destroy_version_interface();
hdd_sysfs_destroy_driver_root_obj();
hdd_destroy_sysfs_files();
hdd_debug("Closing CDS modules!");
if (hdd_get_conparam() != QDF_GLOBAL_EPPING_MODE) {

View File

@@ -37,6 +37,7 @@
#include <sir_api.h>
#endif
#include "osif_sync.h"
#include <wlan_hdd_sysfs_set_fw_mode_cfg.h>
#define MAX_PSOC_ID_SIZE 10
@@ -51,6 +52,28 @@ static struct kobject *driver_kobject;
static struct kobject *fw_kobject;
static struct kobject *psoc_kobject;
int
hdd_sysfs_validate_and_copy_buf(char *dest_buf, size_t dest_buf_size,
char const *source_buf, size_t source_buf_size)
{
if (source_buf_size > (dest_buf_size - 1)) {
hdd_err_rl("Command length is larger than %zu bytes",
dest_buf_size);
return -EINVAL;
}
/* sysfs already provides kernel space buffer so copy from user
* is not needed. Doing this extra copy operation just to ensure
* the local buf is properly null-terminated.
*/
strlcpy(dest_buf, source_buf, dest_buf_size);
/* default 'echo' cmd takes new line character to here */
if (dest_buf[source_buf_size - 1] == '\n')
dest_buf[source_buf_size - 1] = '\0';
return 0;
}
static ssize_t __show_driver_version(char *buf)
{
return scnprintf(buf, PAGE_SIZE, QWLAN_VERSIONSTR);
@@ -440,7 +463,7 @@ static struct kobj_attribute power_stats_attribute =
__ATTR(power_stats, 0444, show_device_power_stats, NULL);
#endif
void hdd_sysfs_create_version_interface(struct wlan_objmgr_psoc *psoc)
static void hdd_sysfs_create_version_interface(struct wlan_objmgr_psoc *psoc)
{
int error = 0;
uint32_t psoc_id;
@@ -489,7 +512,7 @@ free_fw_kobj:
fw_kobject = NULL;
}
void hdd_sysfs_destroy_version_interface(void)
static void hdd_sysfs_destroy_version_interface(void)
{
if (psoc_kobject) {
kobject_put(psoc_kobject);
@@ -500,7 +523,7 @@ void hdd_sysfs_destroy_version_interface(void)
}
#ifdef WLAN_POWER_DEBUG
void hdd_sysfs_create_powerstats_interface(void)
static void hdd_sysfs_create_powerstats_interface(void)
{
int error;
@@ -514,7 +537,7 @@ void hdd_sysfs_create_powerstats_interface(void)
hdd_err("could not create power_stats sysfs file");
}
void hdd_sysfs_destroy_powerstats_interface(void)
static void hdd_sysfs_destroy_powerstats_interface(void)
{
if (!driver_kobject) {
hdd_err("could not get driver kobject!");
@@ -522,9 +545,17 @@ void hdd_sysfs_destroy_powerstats_interface(void)
}
sysfs_remove_file(driver_kobject, &power_stats_attribute.attr);
}
#else
static void hdd_sysfs_create_powerstats_interface(void)
{
}
static void hdd_sysfs_destroy_powerstats_interface(void)
{
}
#endif
void hdd_sysfs_create_driver_root_obj(void)
static void hdd_sysfs_create_driver_root_obj(void)
{
driver_kobject = kobject_create_and_add(DRIVER_NAME, kernel_kobj);
if (!driver_kobject) {
@@ -540,7 +571,7 @@ void hdd_sysfs_create_driver_root_obj(void)
}
}
void hdd_sysfs_destroy_driver_root_obj(void)
static void hdd_sysfs_destroy_driver_root_obj(void)
{
if (wlan_kobject) {
kobject_put(wlan_kobject);
@@ -582,3 +613,20 @@ void hdd_sysfs_destroy_adapter_root_obj(struct hdd_adapter *adapter)
hdd_sysfs_destroy_bcn_reception_interface(adapter);
}
#endif
void hdd_create_sysfs_files(struct hdd_context *hdd_ctx)
{
hdd_sysfs_create_driver_root_obj();
hdd_sysfs_create_version_interface(hdd_ctx->psoc);
hdd_sysfs_create_powerstats_interface();
hdd_sysfs_set_fw_mode_cfg_create(driver_kobject);
}
void hdd_destroy_sysfs_files(void)
{
hdd_sysfs_set_fw_mode_cfg_destroy(driver_kobject);
hdd_sysfs_destroy_powerstats_interface();
hdd_sysfs_destroy_version_interface();
hdd_sysfs_destroy_driver_root_obj();
}

View File

@@ -0,0 +1,149 @@
/*
* 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_set_fw_mode_cfg.c
*
* implementation for creating sysfs file set_fw_mode_cfg
*/
#include <wlan_hdd_includes.h>
#include "osif_psoc_sync.h"
#include <wlan_hdd_sysfs.h>
#include <wlan_hdd_sysfs_set_fw_mode_cfg.h>
#include "wlan_policy_mgr_ucfg.h"
static ssize_t
__wlan_hdd_store_set_fw_mode_cfg_sysfs(struct hdd_context *hdd_ctx,
struct kobj_attribute *attr,
const char *buf,
size_t count)
{
uint8_t dual_mac_feature = DISABLE_DBS_CXN_AND_SCAN;
char buf_local[MAX_SYSFS_USER_COMMAND_SIZE_LENGTH + 1];
char *sptr, *token;
uint32_t val1, val2;
QDF_STATUS status;
int ret;
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_debug("set_fw_mode_cfg: count %zu buf_local:(%s)",
count, buf_local);
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;
hdd_debug("Sysfs to set dual fw mode config");
status = ucfg_policy_mgr_get_dual_mac_feature(hdd_ctx->psoc,
&dual_mac_feature);
if (status != QDF_STATUS_SUCCESS)
hdd_err_rl("can't get dual mac feature val, use def");
if (dual_mac_feature == DISABLE_DBS_CXN_AND_SCAN) {
hdd_err_rl("Dual mac feature is disabled from INI");
return -EPERM;
}
hdd_debug("%d %d", val1, val2);
policy_mgr_set_dual_mac_fw_mode_config(hdd_ctx->psoc,
val1, val2);
return count;
}
static ssize_t
wlan_hdd_store_set_fw_mode_cfg_sysfs(struct kobject *kobj,
struct kobj_attribute *attr,
const char *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;
int ret;
ret = wlan_hdd_validate_context(hdd_ctx);
if (ret != 0)
return ret;
errno_size = osif_psoc_sync_op_start(wiphy_dev(hdd_ctx->wiphy),
&psoc_sync);
if (errno_size)
return errno_size;
errno_size = __wlan_hdd_store_set_fw_mode_cfg_sysfs(hdd_ctx, attr,
buf, count);
osif_psoc_sync_op_stop(psoc_sync);
return errno_size;
}
static struct kobj_attribute set_fw_mode_cfg_attribute =
__ATTR(set_fw_mode_cfg, 0220, NULL,
wlan_hdd_store_set_fw_mode_cfg_sysfs);
int hdd_sysfs_set_fw_mode_cfg_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,
&set_fw_mode_cfg_attribute.attr);
if (error)
hdd_err("could not create set_fw_mode_cfg sysfs file");
return error;
}
void
hdd_sysfs_set_fw_mode_cfg_destroy(struct kobject *driver_kobject)
{
if (!driver_kobject) {
hdd_err("could not get driver kobject!");
return;
}
sysfs_remove_file(driver_kobject, &set_fw_mode_cfg_attribute.attr);
}

View File

@@ -0,0 +1,62 @@
/*
* 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_set_fw_mode_cfg.h
*
* implementation for creating sysfs file set_fw_mode_cfg
*/
#ifndef _WLAN_HDD_SYSFS_SET_FW_MODE_CFG_H
#define _WLAN_HDD_SYSFS_SET_FW_MODE_CFG_H
#if defined(WLAN_SYSFS) && defined(CONFIG_WLAN_SET_FW_MODE_CFG)
/**
* hdd_sysfs_set_fw_mode_cfg_create() - API to create set_fw_mode_cfg
* @driver_kobject: sysfs driver kobject
*
* file path: /sys/kernel/wifi/set_fw_mode_cfg
*
* usage:
* echo [arg_0] [arg_1] > set_fw_mode_cfg
*
* Return: 0 on success and errno on failure
*/
int hdd_sysfs_set_fw_mode_cfg_create(struct kobject *driver_kobject);
/**
* hdd_sysfs_set_fw_mode_cfg_destroy() -
* API to destroy set_fw_mode_cfg
*
* Return: none
*/
void
hdd_sysfs_set_fw_mode_cfg_destroy(struct kobject *driver_kobject);
#else
static inline int
hdd_sysfs_set_fw_mode_cfg_create(struct kobject *driver_kobject)
{
return 0;
}
static inline void
hdd_sysfs_set_fw_mode_cfg_destroy(struct kobject *driver_kobject)
{
}
#endif
#endif /* #ifndef _WLAN_HDD_SYSFS_SET_FW_MODE_CFG_H */