qcacld-3.0: Add a sysfs replacement for getStats

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

file path: /sys/class/net/wlanxx/get_stats
	where wlanxx is adapter name

example: cat /sys/class/net/wlanxx/get_stats

Change-Id: I762f61304407876b61b6970688e3715612c60d35
CRs-Fixed: 2685602
This commit is contained in:
Aditya Kodukula 2020-05-13 15:26:56 -07:00 committed by nshrivas
parent e514533315
commit f527f9aeb6
5 changed files with 239 additions and 0 deletions

4
Kbuild
View File

@ -297,6 +297,9 @@ endif
ifeq ($(CONFIG_WLAN_GET_TX_STBC), y)
HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_get_tx_stbc.o
endif
ifeq ($(CONFIG_WLAN_GET_STATS), y)
HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_get_stats.o
endif
ifeq ($(CONFIG_WLAN_SET_SCAN_CFG), y)
HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_set_scan_cfg.o
endif
@ -2559,6 +2562,7 @@ cppflags-$(CONFIG_WLAN_WOW_ITO) += -DCONFIG_WLAN_WOW_ITO
cppflags-$(CONFIG_WLAN_WOWL_ADD_PTRN) += -DCONFIG_WLAN_WOWL_ADD_PTRN
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_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

View File

@ -185,6 +185,7 @@ ifeq ($(CONFIG_WLAN_SYSFS), y)
CONFIG_WLAN_WOWL_ADD_PTRN := y
CONFIG_WLAN_WOWL_DEL_PTRN := y
CONFIG_WLAN_GET_TX_STBC := y
CONFIG_WLAN_GET_STATS := y
CONFIG_WLAN_SET_SCAN_CFG := y
CONFIG_WLAN_SET_MON_CHAN := y
CONFIG_WLAN_SET_RADAR := y

View File

@ -51,6 +51,7 @@
#include <wlan_hdd_sysfs_wowl_add_ptrn.h>
#include <wlan_hdd_sysfs_wowl_del_ptrn.h>
#include <wlan_hdd_sysfs_get_tx_stbc.h>
#include <wlan_hdd_sysfs_get_stats.h>
#include <wlan_hdd_sysfs_set_scan_cfg.h>
#include <wlan_hdd_sysfs_set_mon_chan.h>
#include <wlan_hdd_sysfs_set_radar.h>
@ -643,6 +644,7 @@ hdd_sysfs_create_sta_adapter_root_obj(struct hdd_adapter *adapter)
hdd_sysfs_wowl_add_ptrn_create(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_stats_create(adapter);
hdd_sysfs_txrx_stats_create(adapter);
hdd_sysfs_get_range_ext_create(adapter);
@ -660,6 +662,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_get_stats_destroy(adapter);
hdd_sysfs_get_tx_stbc_destroy(adapter);
hdd_sysfs_wowl_del_ptrn_destroy(adapter);
hdd_sysfs_wowl_add_ptrn_destroy(adapter);
@ -685,6 +688,7 @@ hdd_sysfs_create_sap_adapter_root_obj(struct hdd_adapter *adapter)
hdd_sysfs_modify_acl_create(adapter);
hdd_sysfs_connect_info_interface_create(adapter);
hdd_sysfs_get_tx_stbc_create(adapter);
hdd_sysfs_get_stats_create(adapter);
hdd_sysfs_set_radar_create(adapter);
hdd_sysfs_txrx_fw_stats_create(adapter);
hdd_sysfs_txrx_stats_create(adapter);
@ -698,6 +702,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_get_stats_destroy(adapter);
hdd_sysfs_get_tx_stbc_destroy(adapter);
hdd_sysfs_connect_info_interface_destroy(adapter);
hdd_sysfs_modify_acl_destroy(adapter);

View File

@ -0,0 +1,167 @@
/*
* 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_get_stats.c
*
* implementation for creating sysfs file get_stats
*/
#include <wlan_hdd_includes.h>
#include <wlan_hdd_sysfs.h>
#include "osif_vdev_sync.h"
#include "sme_api.h"
#include "cdp_txrx_stats.h"
#include <wlan_hdd_sysfs_get_stats.h>
static void hdd_sysfs_get_stats(struct hdd_adapter *adapter, ssize_t *length,
char *buffer, size_t buf_len)
{
struct hdd_tx_rx_stats *stats = &adapter->hdd_stats.tx_rx_stats;
uint32_t len = 0;
uint32_t total_rx_pkt = 0, total_rx_dropped = 0;
uint32_t total_rx_delv = 0, total_rx_refused = 0;
int i = 0;
struct hdd_context *hdd_ctx = adapter->hdd_ctx;
for (; i < NUM_CPUS; i++) {
total_rx_pkt += stats->rx_packets[i];
total_rx_dropped += stats->rx_dropped[i];
total_rx_delv += stats->rx_delivered[i];
total_rx_refused += stats->rx_refused[i];
}
len = scnprintf(buffer, buf_len,
"\nTransmit[%lu] - "
"called %u, dropped %u orphan %u,"
"\n[dropped] BK %u, BE %u, VI %u, VO %u"
"\n[classified] BK %u, BE %u, VI %u, VO %u"
"\n\nReceive[%lu] - "
"packets %u, dropped %u, unsolict_arp_n_mcast_drp %u, delivered %u, refused %u\n"
"GRO - agg %u non-agg %u flush_skip %u low_tput_flush %u disabled(conc %u low-tput %u)\n",
qdf_system_ticks(),
stats->tx_called,
stats->tx_dropped,
stats->tx_orphaned,
stats->tx_dropped_ac[SME_AC_BK],
stats->tx_dropped_ac[SME_AC_BE],
stats->tx_dropped_ac[SME_AC_VI],
stats->tx_dropped_ac[SME_AC_VO],
stats->tx_classified_ac[SME_AC_BK],
stats->tx_classified_ac[SME_AC_BE],
stats->tx_classified_ac[SME_AC_VI],
stats->tx_classified_ac[SME_AC_VO],
qdf_system_ticks(),
total_rx_pkt, total_rx_dropped,
qdf_atomic_read(&stats->rx_usolict_arp_n_mcast_drp),
total_rx_delv,
total_rx_refused,
stats->rx_aggregated, stats->rx_non_aggregated,
stats->rx_gro_flush_skip,
stats->rx_gro_low_tput_flush,
qdf_atomic_read(&hdd_ctx->disable_rx_ol_in_concurrency),
qdf_atomic_read(&hdd_ctx->disable_rx_ol_in_low_tput));
for (i = 0; i < NUM_CPUS; i++) {
if (stats->rx_packets[i] == 0)
continue;
len += scnprintf(buffer + len, buf_len - len,
"Rx CPU[%d]:"
"packets %u, dropped %u, delivered %u, refused %u\n",
i, stats->rx_packets[i], stats->rx_dropped[i],
stats->rx_delivered[i], stats->rx_refused[i]);
}
len += scnprintf(buffer + len, buf_len - len,
"\nTX_FLOW"
"\nCurrent status: %s"
"\ntx-flow timer start count %u"
"\npause count %u, unpause count %u",
(stats->is_txflow_paused == true ? "PAUSED" : "UNPAUSED"),
stats->txflow_timer_cnt,
stats->txflow_pause_cnt,
stats->txflow_unpause_cnt);
len += cdp_stats(cds_get_context(QDF_MODULE_ID_SOC),
adapter->vdev_id, &buffer[len], (buf_len - len));
*length = len + 1;
}
static ssize_t
__hdd_sysfs_get_stats_show(struct net_device *net_dev, char *buf)
{
struct hdd_adapter *adapter = netdev_priv(net_dev);
struct hdd_context *hdd_ctx;
int ret;
ssize_t length = 0;
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)
return ret;
if (!wlan_hdd_validate_modules_state(hdd_ctx))
return -EINVAL;
hdd_sysfs_get_stats(adapter, &length, buf, PAGE_SIZE);
return length;
}
static ssize_t
hdd_sysfs_get_stats_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 = __hdd_sysfs_get_stats_show(net_dev, buf);
osif_vdev_sync_op_stop(vdev_sync);
return err_size;
}
static DEVICE_ATTR(get_stats, 0440,
hdd_sysfs_get_stats_show, NULL);
int hdd_sysfs_get_stats_create(struct hdd_adapter *adapter)
{
int error;
error = device_create_file(&adapter->dev->dev,
&dev_attr_get_stats);
if (error)
hdd_err("could not create get_stats sysfs file");
return error;
}
void hdd_sysfs_get_stats_destroy(struct hdd_adapter *adapter)
{
device_remove_file(&adapter->dev->dev, &dev_attr_get_stats);
}

View File

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