Browse Source

qcacld-3.0: add hdd_dump_log_buffer output to sysfs

Current code doesn't allow output of hdd_dump_log_buffer to sysfs.
Fix this by adding sysfs output functionality.

Change-Id: I077c10e379e542ac99d8ebe01d68fe76a7470e39
CRs-Fixed: 3426193
Mohammed Ahmed 2 years ago
parent
commit
5600f0123e

+ 5 - 0
Kbuild

@@ -478,6 +478,10 @@ ifeq ($(CONFIG_BUS_AUTO_SUSPEND), y)
 HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_runtime_pm.o
 endif
 
+ifeq ($(CONFIG_WLAN_SYSFS_LOG_BUFFER), y)
+HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_log_buffer.o
+endif
+
 endif # CONFIG_WLAN_SYSFS
 
 ifeq ($(CONFIG_QCACLD_FEATURE_FW_STATE), y)
@@ -3505,6 +3509,7 @@ cppflags-$(CONFIG_QCA_MONITOR_PKT_SUPPORT) += -DQCA_MONITOR_PKT_SUPPORT
 cppflags-$(CONFIG_MONITOR_MODULARIZED_ENABLE) += -DMONITOR_MODULARIZED_ENABLE
 cppflags-$(CONFIG_DP_PKT_ADD_TIMESTAMP) += -DCONFIG_DP_PKT_ADD_TIMESTAMP
 cppflags-$(CONFIG_WLAN_PDEV_VDEV_SEND_MULTI_PARAM) += -DWLAN_PDEV_VDEV_SEND_MULTI_PARAM
+cppflags-$(CONFIG_WLAN_SYSFS_LOG_BUFFER) += -DFEATURE_SYSFS_LOG_BUFFER
 
 cppflags-$(CONFIG_ENABLE_VALLOC_REPLACE_MALLOC) += -DENABLE_VALLOC_REPLACE_MALLOC
 

+ 1 - 0
configs/default_defconfig

@@ -396,6 +396,7 @@ endif
 	CONFIG_WLAN_BMISS := y
 	CONFIG_WLAN_FREQ_LIST := y
 	CONFIG_DP_PKT_ADD_TIMESTAMP := y
+	CONFIG_WLAN_SYSFS_LOG_BUFFER := y
 endif
 CONFIG_WLAN_PDEV_VDEV_SEND_MULTI_PARAM := y
 CONFIG_WLAN_POWER_DEBUG := y

+ 1 - 0
configs/peach_defconfig

@@ -317,6 +317,7 @@ endif
 	CONFIG_WLAN_SYSFS_RANGE_EXT := y
 	# Enable EHT rate sysfs entry
 	CONFIG_WLAN_SYSFS_EHT_RATE := y
+	CONFIG_WLAN_SYSFS_LOG_BUFFER := y
 endif
 CONFIG_WLAN_PDEV_VDEV_SEND_MULTI_PARAM := y
 CONFIG_WLAN_POWER_DEBUG := y

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

@@ -90,6 +90,7 @@
 #include <wlan_hdd_sysfs_eht_rate.h>
 #include <wlan_hdd_sysfs_direct_link_ut_cmd.h>
 #include <wlan_hdd_sysfs_runtime_pm.h>
+#include <wlan_hdd_sysfs_log_buffer.h>
 
 #define MAX_PSOC_ID_SIZE 10
 
@@ -939,12 +940,14 @@ void hdd_create_sysfs_files(struct hdd_context *hdd_ctx)
 		hdd_sysfs_get_valid_freq_for_power_create(driver_kobject);
 		hdd_sysfs_dp_pkt_add_ts_create(driver_kobject);
 		hdd_sysfs_runtime_pm_create(driver_kobject);
+		hdd_sysfs_log_buffer_create(driver_kobject);
 	}
 }
 
 void hdd_destroy_sysfs_files(void)
 {
 	if  (QDF_GLOBAL_MISSION_MODE == hdd_get_conparam()) {
+		hdd_sysfs_log_buffer_destroy(driver_kobject);
 		hdd_sysfs_runtime_pm_destroy(driver_kobject);
 		hdd_sysfs_dp_pkt_add_ts_destroy(driver_kobject);
 		hdd_sysfs_get_valid_freq_for_power_destroy(driver_kobject);

+ 65 - 0
core/hdd/src/wlan_hdd_sysfs_log_buffer.c

@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2023 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.
+ */
+
+#include <wlan_hdd_includes.h>
+#include "osif_psoc_sync.h"
+#include <wlan_hdd_sysfs.h>
+#include <wlan_hdd_sysfs_log_buffer.h>
+#include <wlan_hdd_ioctl.h>
+
+static ssize_t hdd_sysfs_log_buffer_show(struct kobject *kobj,
+					 struct kobj_attribute *attr,
+					 char *buf)
+{
+	struct hdd_sysfs_print_ctx ctx;
+
+	ctx.buf = buf;
+	ctx.idx = 0;
+	ctx.new_line = true;
+	hdd_dump_log_buffer(&ctx, &hdd_sysfs_print);
+	return ctx.idx;
+}
+
+static struct kobj_attribute log_buffer_attribute =
+	__ATTR(log_buffer, 0440, hdd_sysfs_log_buffer_show,
+	       NULL);
+
+int hdd_sysfs_log_buffer_create(struct kobject *driver_kobject)
+{
+	int error;
+
+	if (!driver_kobject) {
+		hdd_err("could not get driver kobject!");
+		return -EINVAL;
+	}
+
+	error = sysfs_create_file(driver_kobject,
+				  &log_buffer_attribute.attr);
+	if (error)
+		hdd_err("could not create log_buffer sysfs file");
+
+	return error;
+}
+
+void
+hdd_sysfs_log_buffer_destroy(struct kobject *driver_kobject)
+{
+	if (!driver_kobject) {
+		hdd_err("could not get driver kobject!");
+		return;
+	}
+	sysfs_remove_file(driver_kobject, &log_buffer_attribute.attr);
+}

+ 58 - 0
core/hdd/src/wlan_hdd_sysfs_log_buffer.h

@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2023 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.
+ */
+
+#ifndef _WLAN_HDD_SYSFS_LOG_BUFFER_H
+#define _WLAN_HDD_SYSFS_LOG_BUFFER_H
+
+#if defined(WLAN_SYSFS) && defined(FEATURE_SYSFS_LOG_BUFFER)
+
+/**
+ * hdd_sysfs_log_buffer_create() - API to create log_buffer sysfs file
+ * @driver_kobject: sysfs driver kobject
+ *
+ * file path: /sys/kernel/kiwi_v2/log_buffer
+ *
+ * usage:
+ *      cat log_buffer
+ *
+ * Return: 0 on success and errno on failure
+ */
+int hdd_sysfs_log_buffer_create(struct kobject *driver_kobject);
+
+/**
+ * hdd_sysfs_log_buffer_destroy(): destroy hdd log buffer sysfs node
+ * @driver_kobject: pointer to driver kobject
+ *
+ * Return: void
+ *
+ */
+void
+hdd_sysfs_log_buffer_destroy(struct kobject *driver_kobject);
+
+#else
+
+static inline int
+hdd_sysfs_log_buffer_create(struct kobject *driver_kobject)
+{
+	return 0;
+}
+
+static inline void
+hdd_sysfs_log_buffer_destroy(struct kobject *driver_kobject)
+{
+}
+#endif
+#endif