qcacld-3.0: Add sysfs entry for enable_dcm and get_dcm

Add the sysfs entry for enable_dcm and get_dcm.
Previously these commands would be queried via iwpriv
--> iwpriv wlan0 enable_dcm [0/1]
--> iwpriv wlan0 get_dcm
it is now changed to support via sysfs:
--> echo [0/1] > /sys/class/net/wlanxx/dcm
--> cat /sys/class/net/wlanxx/dcm

Change-Id: I6f7d2e93c362b4d3018d7f5698dd1bba01123600
CRs-Fixed: 2685960
This commit is contained in:
Min Liu 2020-05-14 12:27:49 +08:00 • committed by nshrivas
commit 2e78a9226a
5 changed files with 236 additions and 0 deletions

4
Kbuild
View file

@ -285,6 +285,9 @@ endif
ifeq ($(CONFIG_WLAN_SCAN_DISABLE), y)
HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_scan_disable.o
endif
ifeq ($(CONFIG_WLAN_SYSFS_DCM), y)
HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_dcm.o
endif
ifeq ($(CONFIG_WLAN_WOW_ITO), y)
HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_wow_ito.o
endif
@ -2586,6 +2589,7 @@ 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_DCM) += -DWLAN_SYSFS_DCM
cppflags-$(CONFIG_WLAN_SYSFS_GET_STA_INFO) += -DWLAN_SYSFS_GET_STA_INFO
ifeq ($(CONFIG_LEAK_DETECTION), y)

View file

@ -181,6 +181,7 @@ ifeq ($(CONFIG_WLAN_SYSFS), y)
CONFIG_WLAN_REASSOC := y
CONFIG_WLAN_SYSFS_CONNECT_INFO := y
CONFIG_WLAN_SCAN_DISABLE := y
CONFIG_WLAN_SYSFS_DCM := y
CONFIG_WLAN_WOW_ITO := y
CONFIG_WLAN_WOWL_ADD_PTRN := y
CONFIG_WLAN_WOWL_DEL_PTRN := y

View file

@ -47,6 +47,7 @@
#include "wlan_hdd_sysfs_modify_acl.h"
#include "wlan_hdd_sysfs_connect_info.h"
#include <wlan_hdd_sysfs_scan_disable.h>
#include "wlan_hdd_sysfs_dcm.h"
#include <wlan_hdd_sysfs_wow_ito.h>
#include <wlan_hdd_sysfs_wowl_add_ptrn.h>
#include <wlan_hdd_sysfs_wowl_del_ptrn.h>
@ -644,6 +645,7 @@ hdd_sysfs_create_sta_adapter_root_obj(struct hdd_adapter *adapter)
hdd_sysfs_resume_create(adapter);
hdd_sysfs_unit_test_target_create(adapter);
hdd_sysfs_connect_info_interface_create(adapter);
hdd_sysfs_dcm_create(adapter);
hdd_sysfs_wowl_add_ptrn_create(adapter);
hdd_sysfs_wowl_del_ptrn_create(adapter);
hdd_sysfs_get_tx_stbc_create(adapter);
@ -673,6 +675,7 @@ hdd_sysfs_destroy_sta_adapter_root_obj(struct hdd_adapter *adapter)
hdd_sysfs_get_tx_stbc_destroy(adapter);
hdd_sysfs_wowl_del_ptrn_destroy(adapter);
hdd_sysfs_wowl_add_ptrn_destroy(adapter);
hdd_sysfs_dcm_destroy(adapter);
hdd_sysfs_connect_info_interface_destroy(adapter);
hdd_sysfs_unit_test_target_destroy(adapter);
hdd_sysfs_resume_destroy(adapter);
@ -698,6 +701,7 @@ hdd_sysfs_create_sap_adapter_root_obj(struct hdd_adapter *adapter)
hdd_sysfs_get_stats_create(adapter);
hdd_sysfs_txrx_fw_st_rst_create(adapter);
hdd_sysfs_gtx_bw_mask_create(adapter);
hdd_sysfs_dcm_create(adapter);
hdd_sysfs_set_radar_create(adapter);
hdd_sysfs_txrx_fw_stats_create(adapter);
hdd_sysfs_txrx_stats_create(adapter);
@ -711,6 +715,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_dcm_destroy(adapter);
hdd_sysfs_gtx_bw_mask_destroy(adapter);
hdd_sysfs_txrx_fw_st_rst_destroy(adapter);
hdd_sysfs_get_stats_destroy(adapter);

View file

@ -0,0 +1,163 @@
/*
* 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_dcm.c
*
* implementation for creating sysfs file dcm
*/
#include <wlan_hdd_includes.h>
#include "osif_vdev_sync.h"
#include <wlan_hdd_sysfs.h>
#include "wlan_hdd_sysfs_dcm.h"
#include <wma_api.h>
static ssize_t
__wlan_hdd_sysfs_dcm_store(struct net_device *net_dev, char const *buf,
size_t count)
{
struct hdd_adapter *adapter = netdev_priv(net_dev);
struct hdd_context *hdd_ctx;
char buf_local[MAX_SYSFS_USER_COMMAND_SIZE_LENGTH + 1];
char *sptr, *token;
int value, 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;
token = strsep(&sptr, " ");
if (!token)
return -EINVAL;
if (kstrtou32(token, 0, &value))
return -EINVAL;
hdd_debug("dcm %d", value);
ret = wma_cli_set_command(adapter->vdev_id, WMI_VDEV_PARAM_HE_DCM,
value, VDEV_CMD);
if (ret) {
hdd_err_rl("Failed to set dcm, errno %d", ret);
return ret;
}
return count;
}
static ssize_t wlan_hdd_sysfs_dcm_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 err_size;
err_size = osif_vdev_sync_op_start(net_dev, &vdev_sync);
if (err_size)
return err_size;
err_size = __wlan_hdd_sysfs_dcm_store(net_dev, buf, count);
osif_vdev_sync_op_stop(vdev_sync);
return err_size;
}
static ssize_t
__wlan_hdd_sysfs_dcm_show(struct net_device *net_dev, char *buf)
{
struct hdd_adapter *adapter = netdev_priv(net_dev);
struct hdd_context *hdd_ctx;
int ret, value;
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;
value = wma_cli_get_command(adapter->vdev_id, WMI_VDEV_PARAM_HE_DCM,
VDEV_CMD);
hdd_debug("dcm %d", value);
ret = scnprintf(buf, PAGE_SIZE, "%d", value);
return ret;
}
static ssize_t wlan_hdd_sysfs_dcm_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct net_device *net_dev = container_of(dev, struct net_device, dev);
struct osif_vdev_sync *vdev_sync;
ssize_t err_size;
err_size = osif_vdev_sync_op_start(net_dev, &vdev_sync);
if (err_size)
return err_size;
err_size = __wlan_hdd_sysfs_dcm_show(net_dev, buf);
osif_vdev_sync_op_stop(vdev_sync);
return err_size;
}
static DEVICE_ATTR(dcm, 0664, wlan_hdd_sysfs_dcm_show,
wlan_hdd_sysfs_dcm_store);
int hdd_sysfs_dcm_create(struct hdd_adapter *adapter)
{
int error;
error = device_create_file(&adapter->dev->dev, &dev_attr_dcm);
if (error)
hdd_err("could not create dcm sysfs file");
return error;
}
void hdd_sysfs_dcm_destroy(struct hdd_adapter *adapter)
{
device_remove_file(&adapter->dev->dev, &dev_attr_dcm);
}

View file

@ -0,0 +1,63 @@
/*
* 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_dcm.h
*
* implementation for creating sysfs file dcm
*/
#ifndef _WLAN_HDD_SYSFS_DCM_H
#define _WLAN_HDD_SYSFS_DCM_H
#if defined(WLAN_SYSFS) && defined(WLAN_SYSFS_DCM)
/**
* hdd_sysfs_dcm_create() - API to create dcm
* @adapter: pointer to adapter
*
* this file is created per adapter.
* file path: /sys/class/net/wlanxx/dcm
* where wlanxx is adapter name
*
* usage:
* echo [0/1] > dcm
* cat dcm
*
* Return: 0 on success and errno on failure
*/
int hdd_sysfs_dcm_create(struct hdd_adapter *adapter);
/**
* hdd_sysfs_dcm_destroy() -
* API to destroy dcm
* @adapter: pointer to adapter
*
* Return: none
*/
void hdd_sysfs_dcm_destroy(struct hdd_adapter *adapter);
#else
static inline int
hdd_sysfs_dcm_create(struct hdd_adapter *adapter)
{
return 0;
}
static inline void
hdd_sysfs_dcm_destroy(struct hdd_adapter *adapter)
{
}
#endif
#endif /* #ifndef _WLAN_HDD_SYSFS_DCM_H */