ソースを参照

qcacld-3.0: Add new sysfs entry to enable tx_delay

Add new sysfs entry to enable or disable capture of
datapath tx delay stats per vdev.

Enable HW_TX_DELAY_STATS config flag for Lithium targets
to support capture of tx delay stats at runtime.

Change-Id: I838961daf27e08c4b6e693852c62f9f894f499a5
CRs-Fixed: 2981004
Yeshwanth Sriram Guntuka 3 年 前
コミット
e64efc518f

+ 8 - 0
Kbuild

@@ -515,6 +515,10 @@ ifeq ($(CONFIG_FEATURE_WDS), y)
 HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_wds.o
 endif
 
+ifeq ($(CONFIG_DP_HW_TX_DELAY_STATS_ENABLE), y)
+HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_dp_tx_delay_stats.o
+endif
+
 $(call add-wlan-objs,hdd,$(HDD_OBJS))
 
 ###### OSIF_SYNC ########
@@ -4353,6 +4357,10 @@ ccflags-y += -DWLAN_MCC_MIN_CHANNEL_QUOTA=$(CONFIG_WLAN_MCC_MIN_CHANNEL_QUOTA)
 endif
 endif
 
+ifeq ($(CONFIG_DP_HW_TX_DELAY_STATS_ENABLE), y)
+cppflags-y += -DHW_TX_DELAY_STATS_ENABLE
+endif
+
 KBUILD_CPPFLAGS += $(cppflags-y)
 
 # Currently, for versions of gcc which support it, the kernel Makefile

+ 1 - 0
configs/default_defconfig

@@ -1288,6 +1288,7 @@ ifeq (y,$(filter y,$(CONFIG_LITHIUM) $(CONFIG_BERYLLIUM)))
 		CONFIG_QDF_NBUF_HISTORY_SIZE := 8192
 		CONFIG_DP_RX_REFILL_CPU_PERF_AFFINE_MASK := y
 	endif
+	CONFIG_DP_HW_TX_DELAY_STATS_ENABLE := y
 	CONFIG_WLAN_FEATURE_DP_EVENT_HISTORY := y
 	CONFIG_ALLOW_PKT_DROPPING := y
 	CONFIG_DYNAMIC_RX_AGGREGATION := y

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

@@ -1,6 +1,7 @@
 /*
  * Copyright (c) 2017-2021 The Linux Foundation. All rights reserved.
  * Copyright (c) 2022 Qualcomm Innovation Center, Inc. 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
@@ -83,6 +84,7 @@
 #include "wlan_hdd_eht.h"
 #include <wlan_hdd_sysfs_bmiss.h>
 #include <wlan_hdd_sysfs_get_freq_for_pwr.h>
+#include <wlan_hdd_sysfs_dp_tx_delay_stats.h>
 
 #define MAX_PSOC_ID_SIZE 10
 
@@ -733,11 +735,13 @@ hdd_sysfs_create_sta_adapter_root_obj(struct hdd_adapter *adapter)
 	hdd_sysfs_dl_modes_create(adapter);
 	hdd_sysfs_11be_rate_create(adapter);
 	hdd_sysfs_bmiss_create(adapter);
+	hdd_sysfs_dp_tx_delay_stats_create(adapter);
 }
 
 static void
 hdd_sysfs_destroy_sta_adapter_root_obj(struct hdd_adapter *adapter)
 {
+	hdd_sysfs_dp_tx_delay_stats_destroy(adapter);
 	hdd_sysfs_bmiss_destroy(adapter);
 	hdd_sysfs_11be_rate_destroy(adapter);
 	hdd_sysfs_dl_modes_destroy(adapter);
@@ -790,11 +794,13 @@ hdd_sysfs_create_sap_adapter_root_obj(struct hdd_adapter *adapter)
 	hdd_sysfs_ipa_create(adapter);
 	hdd_sysfs_dl_modes_create(adapter);
 	hdd_sysfs_11be_rate_create(adapter);
+	hdd_sysfs_dp_tx_delay_stats_create(adapter);
 }
 
 static void
 hdd_sysfs_destroy_sap_adapter_root_obj(struct hdd_adapter *adapter)
 {
+	hdd_sysfs_dp_tx_delay_stats_destroy(adapter);
 	hdd_sysfs_11be_rate_destroy(adapter);
 	hdd_sysfs_dl_modes_destroy(adapter);
 	hdd_sysfs_ipa_destroy(adapter);

+ 159 - 0
core/hdd/src/wlan_hdd_sysfs_dp_tx_delay_stats.c

@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. 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_dp_tx_delay_stats.c
+ *
+ * implementation for creating sysfs files:
+ *
+ * dp_tx_delay_stats
+ */
+#include <wlan_hdd_includes.h>
+#include "osif_vdev_sync.h"
+#include "wlan_hdd_object_manager.h"
+#include <wlan_hdd_sysfs.h>
+#include <wlan_hdd_sysfs_dp_tx_delay_stats.h>
+#include <cdp_txrx_host_stats.h>
+
+static ssize_t
+__hdd_sysfs_dp_tx_delay_stats_show(struct net_device *net_dev,
+				   char *buf)
+{
+	struct hdd_adapter *adapter = netdev_priv(net_dev);
+	ol_txrx_soc_handle dp_soc = cds_get_context(QDF_MODULE_ID_SOC);
+	uint8_t value;
+	int ret;
+
+	if (hdd_validate_adapter(adapter) || !dp_soc)
+		return -EINVAL;
+
+	ret = wlan_hdd_validate_context(adapter->hdd_ctx);
+	if (ret)
+		return ret;
+
+	if (!wlan_hdd_validate_modules_state(adapter->hdd_ctx))
+		return -EINVAL;
+
+	value = cdp_vdev_is_tx_delay_stats_enabled(dp_soc, adapter->vdev_id);
+
+	hdd_debug("vdev_id: %d tx_delay_stats: %d", adapter->vdev_id, value);
+
+	return scnprintf(buf, PAGE_SIZE, "%d\n", value);
+}
+
+static ssize_t hdd_sysfs_dp_tx_delay_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_dp_tx_delay_stats_show(net_dev, buf);
+
+	osif_vdev_sync_op_stop(vdev_sync);
+
+	return err_size;
+}
+
+static ssize_t
+__hdd_sysfs_dp_tx_delay_stats_store(struct net_device *net_dev, const char *buf,
+				    size_t count)
+{
+	struct hdd_adapter *adapter = netdev_priv(net_dev);
+	char buf_local[MAX_SYSFS_USER_COMMAND_SIZE_LENGTH + 1];
+	ol_txrx_soc_handle dp_soc = cds_get_context(QDF_MODULE_ID_SOC);
+	char *sptr, *token;
+	uint8_t value;
+	int ret;
+
+	if (hdd_validate_adapter(adapter) || !dp_soc)
+		return -EINVAL;
+
+	ret = wlan_hdd_validate_context(adapter->hdd_ctx);
+	if (ret)
+		return ret;
+
+	if (!wlan_hdd_validate_modules_state(adapter->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 (kstrtou8(token, 0, &value))
+		return -EINVAL;
+
+	hdd_debug("vdev_id: %d tx_delay_stats: %d", adapter->vdev_id, value);
+
+	cdp_enable_disable_vdev_tx_delay_stats(dp_soc, adapter->vdev_id, value);
+
+	return count;
+}
+
+static ssize_t
+hdd_sysfs_dp_tx_delay_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 errno_size;
+
+	errno_size = osif_vdev_sync_op_start(net_dev, &vdev_sync);
+	if (errno_size)
+		return errno_size;
+
+	errno_size = __hdd_sysfs_dp_tx_delay_stats_store(net_dev, buf, count);
+
+	osif_vdev_sync_op_stop(vdev_sync);
+
+	return errno_size;
+}
+
+static DEVICE_ATTR(dp_tx_delay_stats, 0660,
+		   hdd_sysfs_dp_tx_delay_stats_show,
+		   hdd_sysfs_dp_tx_delay_stats_store);
+
+int hdd_sysfs_dp_tx_delay_stats_create(struct hdd_adapter *adapter)
+{
+	int error;
+
+	error = device_create_file(&adapter->dev->dev,
+				   &dev_attr_dp_tx_delay_stats);
+	if (error)
+		hdd_err("could not create dp_tx_delay_stats sysfs file");
+
+	return error;
+}
+
+void
+hdd_sysfs_dp_tx_delay_stats_destroy(struct hdd_adapter *adapter)
+{
+	device_remove_file(&adapter->dev->dev, &dev_attr_dp_tx_delay_stats);
+}

+ 66 - 0
core/hdd/src/wlan_hdd_sysfs_dp_tx_delay_stats.h

@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. 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_dp_tx_delay_stats.h
+ *
+ * implementation for creating sysfs files:
+ *
+ * dp_tx_delay_stats
+ */
+
+#ifndef _WLAN_HDD_SYSFS_DP_TX_DELAY_STATS_H
+#define _WLAN_HDD_SYSFS_DP_TX_DELAY_STATS_H
+
+#ifdef HW_TX_DELAY_STATS_ENABLE
+/**
+ * hdd_sysfs_dp_tx_delay_stats_create() - API to create dp tx delay stats
+ *  related sysfs entry
+ * @adapter: hdd adapter
+ *
+ * file path: /sys/class/net/wlanxx/dp_tx_delay_stats
+ * This sysfs entry is created per adapter
+ *
+ * usage:
+ *      echo [0/1] > dp_tx_delay_stats
+ *
+ * Return: 0 on success and errno on failure
+ */
+int
+hdd_sysfs_dp_tx_delay_stats_create(struct hdd_adapter *adapter);
+
+/**
+ * hdd_sysfs_dp_tx_delay_stats_destroy() - API to destroy dp tx delay stats
+ *  related sysfs entry
+ * @adapter: hdd adapter
+ *
+ * Return: None
+ */
+void
+hdd_sysfs_dp_tx_delay_stats_destroy(struct hdd_adapter *adapter);
+#else
+static inline int
+hdd_sysfs_dp_tx_delay_stats_create(struct hdd_adapter *adapter)
+{
+	return 0;
+}
+
+static inline void
+hdd_sysfs_dp_tx_delay_stats_destroy(struct hdd_adapter *adapter)
+{
+}
+#endif
+#endif