From 987834feb760db160a87269503ec91f5d04d1b21 Mon Sep 17 00:00:00 2001 From: Srinivas Girigowda Date: Mon, 13 Jul 2020 17:52:22 -0700 Subject: [PATCH] qcacld-3.0: Rename file name and function name for sysfs 'stats' Rename file name and modify function names to keep it inline with sysfs attribute name 'stats' Change-Id: Iffc390d4865977f9eff72a6a4bcf708c014f482e CRs-Fixed: 2731064 --- Kbuild | 3 - configs/default_defconfig | 1 - core/hdd/src/wlan_hdd_sysfs.c | 5 - core/hdd/src/wlan_hdd_sysfs_get_stats.c | 167 ------------------------ core/hdd/src/wlan_hdd_sysfs_get_stats.h | 62 --------- core/hdd/src/wlan_hdd_sysfs_stats.c | 131 ++++++++++++++++++- core/hdd/src/wlan_hdd_sysfs_stats.h | 5 +- 7 files changed, 134 insertions(+), 240 deletions(-) delete mode 100644 core/hdd/src/wlan_hdd_sysfs_get_stats.c delete mode 100644 core/hdd/src/wlan_hdd_sysfs_get_stats.h diff --git a/Kbuild b/Kbuild index 4134d29b857f..95b241e24842 100644 --- a/Kbuild +++ b/Kbuild @@ -304,9 +304,6 @@ endif ifeq ($(CONFIG_WLAN_SYSFS_TX_STBC), y) HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_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_SYSFS_SCAN_CFG), y) HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_scan_config.o endif diff --git a/configs/default_defconfig b/configs/default_defconfig index 0b13bfb1896c..83d9ccfb4014 100644 --- a/configs/default_defconfig +++ b/configs/default_defconfig @@ -207,7 +207,6 @@ ifeq ($(CONFIG_WLAN_SYSFS), y) CONFIG_WLAN_WOWL_ADD_PTRN := y CONFIG_WLAN_WOWL_DEL_PTRN := y CONFIG_WLAN_SYSFS_TX_STBC := y - CONFIG_WLAN_GET_STATS := y CONFIG_WLAN_SYSFS_WLAN_DBG := y CONFIG_WLAN_TXRX_FW_ST_RST := y CONFIG_WLAN_GTX_BW_MASK := y diff --git a/core/hdd/src/wlan_hdd_sysfs.c b/core/hdd/src/wlan_hdd_sysfs.c index f0b84353b1da..826ff69cfacd 100644 --- a/core/hdd/src/wlan_hdd_sysfs.c +++ b/core/hdd/src/wlan_hdd_sysfs.c @@ -53,7 +53,6 @@ #include #include #include -#include #include #include #include @@ -656,7 +655,6 @@ 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_tx_stbc_create(adapter); - hdd_sysfs_get_stats_create(adapter); hdd_sysfs_txrx_fw_st_rst_create(adapter); hdd_sysfs_gtx_bw_mask_create(adapter); hdd_sysfs_rts_cts_create(adapter); @@ -682,7 +680,6 @@ hdd_sysfs_destroy_sta_adapter_root_obj(struct hdd_adapter *adapter) hdd_sysfs_rts_cts_destroy(adapter); hdd_sysfs_gtx_bw_mask_destroy(adapter); hdd_sysfs_txrx_fw_st_rst_destroy(adapter); - hdd_sysfs_get_stats_destroy(adapter); hdd_sysfs_tx_stbc_destroy(adapter); hdd_sysfs_wowl_del_ptrn_destroy(adapter); hdd_sysfs_wowl_add_ptrn_destroy(adapter); @@ -708,7 +705,6 @@ 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_tx_stbc_create(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); @@ -738,7 +734,6 @@ hdd_sysfs_destroy_sap_adapter_root_obj(struct hdd_adapter *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); hdd_sysfs_tx_stbc_destroy(adapter); hdd_sysfs_connect_info_interface_destroy(adapter); hdd_sysfs_modify_acl_destroy(adapter); diff --git a/core/hdd/src/wlan_hdd_sysfs_get_stats.c b/core/hdd/src/wlan_hdd_sysfs_get_stats.c deleted file mode 100644 index 58acb4c0a959..000000000000 --- a/core/hdd/src/wlan_hdd_sysfs_get_stats.c +++ /dev/null @@ -1,167 +0,0 @@ -/* - * 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 stats - */ - -#include -#include -#include "osif_vdev_sync.h" -#include "sme_api.h" -#include "cdp_txrx_stats.h" -#include - -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(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_stats); - if (error) - hdd_err("could not create stats sysfs file"); - - return error; -} - -void hdd_sysfs_get_stats_destroy(struct hdd_adapter *adapter) -{ - device_remove_file(&adapter->dev->dev, &dev_attr_stats); -} diff --git a/core/hdd/src/wlan_hdd_sysfs_get_stats.h b/core/hdd/src/wlan_hdd_sysfs_get_stats.h deleted file mode 100644 index 0e0e3de22a2f..000000000000 --- a/core/hdd/src/wlan_hdd_sysfs_get_stats.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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 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 stats sysfs file - * @adapter: pointer to adapter - * - * this file is created per adapter. - * file path: /sys/class/net/wlanxx/stats - * where wlanxx is adapter name - * - * usage: - * cat /sys/class/net/wlanxx/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 stats sysfs file - * @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 */ diff --git a/core/hdd/src/wlan_hdd_sysfs_stats.c b/core/hdd/src/wlan_hdd_sysfs_stats.c index af5ec3a4c50a..658dc92bce9b 100644 --- a/core/hdd/src/wlan_hdd_sysfs_stats.c +++ b/core/hdd/src/wlan_hdd_sysfs_stats.c @@ -17,8 +17,9 @@ /** * DOC: wlan_hdd_sysfs_stats.c * - * implementation for creating sysfs files: + * Implementation for creating sysfs files: * + * stats * dump_stats * clear_stats */ @@ -27,9 +28,132 @@ #include "osif_vdev_sync.h" #include #include "wlan_hdd_sysfs_stats.h" +#include "cdp_txrx_stats.h" static int stats_id = -1; +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_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_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_stats_show(net_dev, buf); + + osif_vdev_sync_op_stop(vdev_sync); + + return err_size; +} + +static DEVICE_ATTR(stats, 0440, + hdd_sysfs_stats_show, NULL); + static ssize_t __wlan_hdd_sysfs_dump_stats_store(struct net_device *net_dev, char const *buf, size_t count) @@ -222,6 +346,10 @@ int hdd_sysfs_stats_create(struct hdd_adapter *adapter) if (error) hdd_err("could not create clear_stats sysfs file"); + error = device_create_file(&adapter->dev->dev, &dev_attr_stats); + if (error) + hdd_err("could not create stats sysfs file"); + return error; } @@ -229,4 +357,5 @@ void hdd_sysfs_stats_destroy(struct hdd_adapter *adapter) { device_remove_file(&adapter->dev->dev, &dev_attr_dump_stats); device_remove_file(&adapter->dev->dev, &dev_attr_clear_stats); + device_remove_file(&adapter->dev->dev, &dev_attr_stats); } diff --git a/core/hdd/src/wlan_hdd_sysfs_stats.h b/core/hdd/src/wlan_hdd_sysfs_stats.h index 28f43a9e6912..00ade11975d1 100644 --- a/core/hdd/src/wlan_hdd_sysfs_stats.h +++ b/core/hdd/src/wlan_hdd_sysfs_stats.h @@ -17,8 +17,9 @@ /** * DOC: wlan_hdd_sysfs_stats.h * - * implementation for creating sysfs files: + * Implementation for creating sysfs files: * + * stats * dump_stats * clear_stats */ @@ -35,12 +36,14 @@ * file path: * /sys/class/net/wlanxx/dump_stats * /sys/class/net/wlanxx/clear_stats + * /sys/class/net/wlanxx/stats * where wlanxx is adapter name * * usage: * echo [stats_id] > dump_stats * cat dump_stats * echo [stats_id] > clear_stats + * cat /sys/class/net/wlanxx/stats * * Return: 0 on success and errno on failure */