Bläddra i källkod

qcacld-3.0: Add sysfs entry for dumpStats and clearStats

Add the sysfs entry for dumpStats and clearStats.
Previously these commands would be queried via iwpriv
--> iwpriv wlan0 dumpStats [stats_id]
--> iwpriv wlan0 clearStats [stats_id]
it is now changed to support via sysfs:
--> echo [stats_id] > /sys/class/net/wlanxx/dump_stats
--> cat /sys/class/net/wlanxx/dump_stats
--> echo [stats_id] > /sys/class/net/wlanxx/clear_stats

Change-Id: If8e4d997bc621df98732461802fdd9cea89bd1ce
CRs-Fixed: 2685995
Min Liu 4 år sedan
förälder
incheckning
efc4350044

+ 4 - 0
Kbuild

@@ -328,6 +328,9 @@ endif
 ifeq ($(CONFIG_WLAN_SYSFS_DP_TRACE), y)
 HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_dp_trace.o
 endif
+ifeq ($(CONFIG_WLAN_SYSFS_STATS), y)
+HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_stats.o
+endif
 ifeq ($(CONFIG_WLAN_GET_RANGE_EXT), y)
 HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_get_range_ext.o
 endif
@@ -2592,6 +2595,7 @@ cppflags-$(CONFIG_WLAN_SYSFS_RTS_CTS) += -DWLAN_SYSFS_RTS_CTS
 cppflags-$(CONFIG_WLAN_TXRX_FW_STATS) += -DCONFIG_WLAN_TXRX_FW_STATS
 cppflags-$(CONFIG_WLAN_TXRX_STATS) += -DCONFIG_WLAN_TXRX_STATS
 cppflags-$(CONFIG_WLAN_SYSFS_DP_TRACE) += -DWLAN_SYSFS_DP_TRACE
+cppflags-$(CONFIG_WLAN_SYSFS_STATS) += -DWLAN_SYSFS_STATS
 cppflags-$(CONFIG_WLAN_GET_RANGE_EXT) += -DCONFIG_WLAN_GET_RANGE_EXT
 cppflags-$(CONFIG_WLAN_GET_TEMP) += -DCONFIG_WLAN_GET_TEMP
 cppflags-$(CONFIG_WLAN_THERMAL_CFG) += -DCONFIG_WLAN_THERMAL_CFG

+ 1 - 0
configs/default_defconfig

@@ -199,6 +199,7 @@ ifeq ($(CONFIG_WLAN_SYSFS), y)
 ifeq ($(CONFIG_DP_TRACE), y)
 	CONFIG_WLAN_SYSFS_DP_TRACE := y
 endif
+	CONFIG_WLAN_SYSFS_STATS := y
 	CONFIG_WLAN_GET_RANGE_EXT := y
 ifeq ($(CONFIG_QCOM_TDLS), y)
 	CONFIG_WLAN_GET_TDLS_PEERS := y

+ 24 - 1
core/hdd/inc/wlan_hdd_main.h

@@ -3014,7 +3014,30 @@ static inline void wlan_hdd_mod_fc_timer(struct hdd_adapter *adapter,
 }
 #endif /* QCA_HL_NETDEV_FLOW_CONTROL */
 
-int hdd_wlan_dump_stats(struct hdd_adapter *adapter, int value);
+/**
+ * hdd_wlan_dump_stats() - display dump Stats
+ * @adapter: adapter handle
+ * @stats_id: stats id from user
+ *
+ * Return: 0 => success, error code on failure
+ */
+int hdd_wlan_dump_stats(struct hdd_adapter *adapter, int stats_id);
+
+/**
+ * hdd_wlan_clear_stats() - clear Stats
+ * @adapter: adapter handle
+ * @stats_id: stats id from user
+ *
+ * Return: 0 => success, error code on failure
+ */
+int hdd_wlan_clear_stats(struct hdd_adapter *adapter, int stats_id);
+
+/**
+ * wlan_hdd_display_tx_rx_histogram() - display tx rx histogram
+ * @hdd_ctx: hdd context
+ *
+ * Return: none
+ */
 void wlan_hdd_display_tx_rx_histogram(struct hdd_context *hdd_ctx);
 void wlan_hdd_clear_tx_rx_histogram(struct hdd_context *hdd_ctx);
 

+ 104 - 3
core/hdd/src/wlan_hdd_main.c

@@ -9316,13 +9316,114 @@ static uint8_t *convert_level_to_string(uint32_t level)
 	}
 }
 
-
+#define HDD_DUMP_STAT_HELP(STAT_ID) \
+	hdd_nofl_debug("%u -- %s", STAT_ID, (# STAT_ID))
 /**
- * wlan_hdd_display_tx_rx_histogram() - display tx rx histogram
- * @hdd_ctx: hdd context
+ * hdd_display_stats_help() - print statistics help
  *
  * Return: none
  */
+static void hdd_display_stats_help(void)
+{
+	hdd_nofl_debug("iwpriv wlan0 dumpStats [option] - dump statistics");
+	hdd_nofl_debug("iwpriv wlan0 clearStats [option] - clear statistics");
+	hdd_nofl_debug("options:");
+	HDD_DUMP_STAT_HELP(CDP_TXRX_PATH_STATS);
+	HDD_DUMP_STAT_HELP(CDP_TXRX_HIST_STATS);
+	HDD_DUMP_STAT_HELP(CDP_TXRX_TSO_STATS);
+	HDD_DUMP_STAT_HELP(CDP_HDD_NETIF_OPER_HISTORY);
+	HDD_DUMP_STAT_HELP(CDP_DUMP_TX_FLOW_POOL_INFO);
+	HDD_DUMP_STAT_HELP(CDP_TXRX_DESC_STATS);
+	HDD_DUMP_STAT_HELP(CDP_HIF_STATS);
+	HDD_DUMP_STAT_HELP(CDP_NAPI_STATS);
+	HDD_DUMP_STAT_HELP(CDP_DP_NAPI_STATS);
+	HDD_DUMP_STAT_HELP(CDP_DP_RX_THREAD_STATS);
+}
+
+int hdd_wlan_dump_stats(struct hdd_adapter *adapter, int stats_id)
+{
+	int ret = 0;
+	QDF_STATUS status;
+	struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
+
+	hdd_debug("stats_id %d", stats_id);
+
+	switch (stats_id) {
+	case CDP_TXRX_HIST_STATS:
+		wlan_hdd_display_tx_rx_histogram(hdd_ctx);
+		break;
+	case CDP_HDD_NETIF_OPER_HISTORY:
+		wlan_hdd_display_adapter_netif_queue_history(adapter);
+		break;
+	case CDP_HIF_STATS:
+		hdd_display_hif_stats();
+		break;
+	case CDP_LRO_STATS:
+		hdd_lro_display_stats(hdd_ctx);
+		break;
+	case CDP_NAPI_STATS:
+		if (hdd_display_napi_stats()) {
+			hdd_err("error displaying napi stats");
+			ret = -EFAULT;
+		}
+		break;
+	case CDP_DP_RX_THREAD_STATS:
+		dp_txrx_ext_dump_stats(cds_get_context(QDF_MODULE_ID_SOC),
+				       CDP_DP_RX_THREAD_STATS);
+		break;
+	case CDP_DISCONNECT_STATS:
+		sme_display_disconnect_stats(hdd_ctx->mac_handle,
+					     adapter->vdev_id);
+		break;
+	default:
+		status = cdp_display_stats(cds_get_context(QDF_MODULE_ID_SOC),
+					   stats_id,
+					   QDF_STATS_VERBOSITY_LEVEL_HIGH);
+		if (status == QDF_STATUS_E_INVAL) {
+			hdd_display_stats_help();
+			ret = -EINVAL;
+		}
+		break;
+	}
+	return ret;
+}
+
+int hdd_wlan_clear_stats(struct hdd_adapter *adapter, int stats_id)
+{
+	QDF_STATUS status;
+
+	hdd_debug("stats_id %d", stats_id);
+
+	switch (stats_id) {
+	case CDP_HDD_STATS:
+		memset(&adapter->stats, 0, sizeof(adapter->stats));
+		memset(&adapter->hdd_stats, 0, sizeof(adapter->hdd_stats));
+		break;
+	case CDP_TXRX_HIST_STATS:
+		wlan_hdd_clear_tx_rx_histogram(adapter->hdd_ctx);
+		break;
+	case CDP_HDD_NETIF_OPER_HISTORY:
+		wlan_hdd_clear_netif_queue_history(adapter->hdd_ctx);
+		break;
+	case CDP_HIF_STATS:
+		hdd_clear_hif_stats();
+		break;
+	case CDP_NAPI_STATS:
+		hdd_clear_napi_stats();
+		break;
+	default:
+		status = cdp_clear_stats(cds_get_context(QDF_MODULE_ID_SOC),
+					 OL_TXRX_PDEV_ID,
+					 stats_id);
+		if (status != QDF_STATUS_SUCCESS)
+			hdd_debug("Failed to dump stats for stats_id: %d",
+				  stats_id);
+		break;
+	}
+
+	return 0;
+}
+
 void wlan_hdd_display_tx_rx_histogram(struct hdd_context *hdd_ctx)
 {
 	int i;

+ 5 - 0
core/hdd/src/wlan_hdd_sysfs.c

@@ -64,6 +64,7 @@
 #include <wlan_hdd_sysfs_txrx_fw_stats.h>
 #include <wlan_hdd_sysfs_txrx_stats.h>
 #include <wlan_hdd_sysfs_dp_trace.h>
+#include <wlan_hdd_sysfs_stats.h>
 #include <wlan_hdd_sysfs_get_range_ext.h>
 #include <wlan_hdd_sysfs_get_tdls_peers.h>
 #include <wlan_hdd_sysfs_get_temp.h>
@@ -654,6 +655,7 @@ hdd_sysfs_create_sta_adapter_root_obj(struct hdd_adapter *adapter)
 	hdd_sysfs_txrx_fw_st_rst_create(adapter);
 	hdd_sysfs_gtx_bw_mask_create(adapter);
 	hdd_sysfs_rts_cts_create(adapter);
+	hdd_sysfs_stats_create(adapter);
 	hdd_sysfs_txrx_fw_stats_create(adapter);
 	hdd_sysfs_txrx_stats_create(adapter);
 	hdd_sysfs_get_range_ext_create(adapter);
@@ -673,6 +675,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_stats_destroy(adapter);
 	hdd_sysfs_rts_cts_destroy(adapter);
 	hdd_sysfs_gtx_bw_mask_destroy(adapter);
 	hdd_sysfs_txrx_fw_st_rst_destroy(adapter);
@@ -708,6 +711,7 @@ hdd_sysfs_create_sap_adapter_root_obj(struct hdd_adapter *adapter)
 	hdd_sysfs_dcm_create(adapter);
 	hdd_sysfs_set_radar_create(adapter);
 	hdd_sysfs_rts_cts_create(adapter);
+	hdd_sysfs_stats_create(adapter);
 	hdd_sysfs_txrx_fw_stats_create(adapter);
 	hdd_sysfs_txrx_stats_create(adapter);
 	hdd_sysfs_get_temp_create(adapter);
@@ -721,6 +725,7 @@ hdd_sysfs_destroy_sap_adapter_root_obj(struct hdd_adapter *adapter)
 	hdd_sysfs_get_temp_destroy(adapter);
 	hdd_sysfs_txrx_stats_destroy(adapter);
 	hdd_sysfs_txrx_fw_stats_destroy(adapter);
+	hdd_sysfs_stats_destroy(adapter);
 	hdd_sysfs_rts_cts_destroy(adapter);
 	hdd_sysfs_set_radar_destroy(adapter);
 	hdd_sysfs_dcm_destroy(adapter);

+ 232 - 0
core/hdd/src/wlan_hdd_sysfs_stats.c

@@ -0,0 +1,232 @@
+/*
+ * 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_stats.c
+ *
+ * implementation for creating sysfs files:
+ *
+ *   dump_stats
+ *   clear_stats
+ */
+
+#include <wlan_hdd_includes.h>
+#include "osif_vdev_sync.h"
+#include <wlan_hdd_sysfs.h>
+#include "wlan_hdd_sysfs_stats.h"
+
+static int stats_id = -1;
+
+static ssize_t
+__wlan_hdd_sysfs_dump_stats_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("dump_stats %d", value);
+
+	stats_id = value;
+
+	return count;
+}
+
+static ssize_t wlan_hdd_sysfs_dump_stats_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_dump_stats_store(net_dev, buf, count);
+
+	osif_vdev_sync_op_stop(vdev_sync);
+
+	return err_size;
+}
+
+static ssize_t
+__wlan_hdd_sysfs_dump_stats_show(struct net_device *net_dev, char *buf)
+{
+	struct hdd_adapter *adapter = netdev_priv(net_dev);
+	struct hdd_context *hdd_ctx;
+	int 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_wlan_dump_stats(adapter, stats_id);
+
+	return ret;
+}
+
+static ssize_t wlan_hdd_sysfs_dump_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 = __wlan_hdd_sysfs_dump_stats_show(net_dev, buf);
+
+	osif_vdev_sync_op_stop(vdev_sync);
+
+	return err_size;
+}
+
+static DEVICE_ATTR(dump_stats, 0660, wlan_hdd_sysfs_dump_stats_show,
+		   wlan_hdd_sysfs_dump_stats_store);
+
+static ssize_t
+__wlan_hdd_sysfs_clear_stats_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("clear_stats %d", value);
+
+	ret = hdd_wlan_clear_stats(adapter, value);
+	if (ret) {
+		hdd_err_rl("Failed to clear stats");
+		return ret;
+	}
+
+	return count;
+}
+
+static ssize_t wlan_hdd_sysfs_clear_stats_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_clear_stats_store(net_dev, buf, count);
+
+	osif_vdev_sync_op_stop(vdev_sync);
+
+	return err_size;
+}
+
+static DEVICE_ATTR(clear_stats, 0220, NULL,
+		   wlan_hdd_sysfs_clear_stats_store);
+
+int hdd_sysfs_stats_create(struct hdd_adapter *adapter)
+{
+	int error;
+
+	error = device_create_file(&adapter->dev->dev, &dev_attr_dump_stats);
+	if (error)
+		hdd_err("could not create dump_stats sysfs file");
+
+	error = device_create_file(&adapter->dev->dev, &dev_attr_clear_stats);
+	if (error)
+		hdd_err("could not create clear_stats sysfs file");
+
+	return error;
+}
+
+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);
+}

+ 69 - 0
core/hdd/src/wlan_hdd_sysfs_stats.h

@@ -0,0 +1,69 @@
+/*
+ * 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_stats.h
+ *
+ * implementation for creating sysfs files:
+ *
+ * dump_stats
+ * clear_stats
+ */
+
+#ifndef _WLAN_HDD_SYSFS_STATS_H
+#define _WLAN_HDD_SYSFS_STATS_H
+
+#if defined(WLAN_SYSFS) && defined(WLAN_SYSFS_STATS)
+/**
+ * hdd_sysfs_stats_create() - API to create stats files
+ * @adapter: pointer to adapter
+ *
+ * these files are created per adapter.
+ * file path:
+ *   /sys/class/net/wlanxx/dump_stats
+ *   /sys/class/net/wlanxx/clear_stats
+ * where wlanxx is adapter name
+ *
+ * usage:
+ *      echo [stats_id] > dump_stats
+ *      cat dump_stats
+ *      echo [stats_id] > clear_stats
+ *
+ * Return: 0 on success and errno on failure
+ */
+int hdd_sysfs_stats_create(struct hdd_adapter *adapter);
+
+/**
+ * hdd_sysfs_stats_destroy() -
+ *   API to destroy stats
+ * @adapter: pointer to adapter
+ *
+ * Return: none
+ */
+void hdd_sysfs_stats_destroy(struct hdd_adapter *adapter);
+#else
+static inline int
+hdd_sysfs_stats_create(struct hdd_adapter *adapter)
+{
+	return 0;
+}
+
+static inline void
+hdd_sysfs_stats_destroy(struct hdd_adapter *adapter)
+{
+}
+#endif
+#endif /* #ifndef _WLAN_HDD_SYSFS_STATS_H */

+ 4 - 109
core/hdd/src/wlan_hdd_wext.c

@@ -3177,83 +3177,9 @@ void hdd_wlan_list_fw_profile(uint16_t *length,
 	*length = len + 1;
 }
 
-#define HDD_DUMP_STAT_HELP(STAT_ID) \
-	hdd_nofl_info("%u -- %s", STAT_ID, (# STAT_ID))
-/**
- * hdd_display_stats_help() - print statistics help
- *
- * Return: none
- */
-static void hdd_display_stats_help(void)
+static int hdd_we_dump_stats(struct hdd_adapter *adapter, int value)
 {
-	hdd_nofl_info("iwpriv wlan0 dumpStats [option] - dump statistics");
-	hdd_nofl_info("iwpriv wlan0 clearStats [option] - clear statistics");
-	hdd_nofl_info("options:");
-	HDD_DUMP_STAT_HELP(CDP_TXRX_PATH_STATS);
-	HDD_DUMP_STAT_HELP(CDP_TXRX_HIST_STATS);
-	HDD_DUMP_STAT_HELP(CDP_TXRX_TSO_STATS);
-	HDD_DUMP_STAT_HELP(CDP_HDD_NETIF_OPER_HISTORY);
-	HDD_DUMP_STAT_HELP(CDP_DUMP_TX_FLOW_POOL_INFO);
-	HDD_DUMP_STAT_HELP(CDP_TXRX_DESC_STATS);
-	HDD_DUMP_STAT_HELP(CDP_HIF_STATS);
-	HDD_DUMP_STAT_HELP(CDP_NAPI_STATS);
-	HDD_DUMP_STAT_HELP(CDP_DP_NAPI_STATS);
-	HDD_DUMP_STAT_HELP(CDP_DP_RX_THREAD_STATS);
-}
-
-/**
- * hdd_wlan_dump_stats() - display dump Stats
- * @adapter: adapter handle
- * @value: value from user
- *
- * Return: 0 => success, error code on failure
- */
-int hdd_wlan_dump_stats(struct hdd_adapter *adapter, int value)
-{
-	int ret = 0;
-	QDF_STATUS status;
-	struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
-
-	hdd_debug("%d", value);
-
-	switch (value) {
-	case CDP_TXRX_HIST_STATS:
-		wlan_hdd_display_tx_rx_histogram(hdd_ctx);
-		break;
-	case CDP_HDD_NETIF_OPER_HISTORY:
-		wlan_hdd_display_adapter_netif_queue_history(adapter);
-		break;
-	case CDP_HIF_STATS:
-		hdd_display_hif_stats();
-		break;
-	case CDP_LRO_STATS:
-		hdd_lro_display_stats(hdd_ctx);
-		break;
-	case CDP_NAPI_STATS:
-		if (hdd_display_napi_stats()) {
-			hdd_err("error displaying napi stats");
-			ret = -EFAULT;
-		}
-		break;
-	case CDP_DP_RX_THREAD_STATS:
-		dp_txrx_ext_dump_stats(cds_get_context(QDF_MODULE_ID_SOC),
-				       CDP_DP_RX_THREAD_STATS);
-		break;
-	case CDP_DISCONNECT_STATS:
-		sme_display_disconnect_stats(hdd_ctx->mac_handle,
-					     adapter->vdev_id);
-		break;
-	default:
-		status = cdp_display_stats(cds_get_context(QDF_MODULE_ID_SOC),
-					   value,
-					   QDF_STATS_VERBOSITY_LEVEL_HIGH);
-		if (status == QDF_STATUS_E_INVAL) {
-			hdd_display_stats_help();
-			ret = -EINVAL;
-		}
-		break;
-	}
-	return ret;
+	return hdd_wlan_dump_stats(adapter, value);
 }
 
 /**
@@ -4652,38 +4578,7 @@ static int hdd_we_set_amsdu(struct hdd_adapter *adapter, int amsdu)
 
 static int hdd_we_clear_stats(struct hdd_adapter *adapter, int option)
 {
-	QDF_STATUS status;
-
-	hdd_debug("option %d", option);
-
-	switch (option) {
-	case CDP_HDD_STATS:
-		memset(&adapter->stats, 0, sizeof(adapter->stats));
-		memset(&adapter->hdd_stats, 0, sizeof(adapter->hdd_stats));
-		break;
-	case CDP_TXRX_HIST_STATS:
-		wlan_hdd_clear_tx_rx_histogram(adapter->hdd_ctx);
-		break;
-	case CDP_HDD_NETIF_OPER_HISTORY:
-		wlan_hdd_clear_netif_queue_history(adapter->hdd_ctx);
-		break;
-	case CDP_HIF_STATS:
-		hdd_clear_hif_stats();
-		break;
-	case CDP_NAPI_STATS:
-		hdd_clear_napi_stats();
-		break;
-	default:
-		status = cdp_clear_stats(cds_get_context(QDF_MODULE_ID_SOC),
-					 OL_TXRX_PDEV_ID,
-					 option);
-		if (status != QDF_STATUS_SUCCESS)
-			hdd_debug("Failed to dump stats for option: %d",
-				  option);
-		break;
-	}
-
-	return 0;
+	return hdd_wlan_clear_stats(adapter, option);
 }
 
 static int hdd_we_set_green_tx_param(struct hdd_adapter *adapter,
@@ -5502,7 +5397,7 @@ static const setint_getnone_fn setint_getnone_cb[] = {
 	[WE_DBGLOG_REPORT_ENABLE] = hdd_we_dbglog_report_enable,
 	[WE_SET_TXRX_FWSTATS] = hdd_we_set_txrx_fwstats,
 	[WE_TXRX_FWSTATS_RESET] = hdd_we_txrx_fwstats_reset,
-	[WE_DUMP_STATS] = hdd_wlan_dump_stats,
+	[WE_DUMP_STATS] = hdd_we_dump_stats,
 	[WE_CLEAR_STATS] = hdd_we_clear_stats,
 	[WE_PPS_PAID_MATCH] = hdd_we_pps_paid_match,
 	[WE_PPS_GID_MATCH] = hdd_we_pps_gid_match,