Ver Fonte

qcacmn: Add API to init/deinit chipset stats

Add API to init/deinit chipset stats

Change-Id: I71d01c6cebabe2cf250438f4fc5423d6bc159fdf
CRs-Fixed: 3782270
Prasanna JS há 1 ano atrás
pai
commit
67d9279244

+ 90 - 0
umac/cp_stats/core/src/wlan_cp_stats_chipset_stats.c

@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2024, Qualcomm Innovation Center, Inc. All rights reserved.
+ * SPDX-License-Identifier: ISC
+ */
+
+/**
+ * DOC: This file contains chipset stats implementstion
+ */
+
+#ifdef WLAN_CHIPSET_STATS
+#include <qdf_mem.h>
+#include <qdf_types.h>
+#include <qdf_status.h>
+#include <qdf_trace.h>
+#include <qdf_time.h>
+#include <qdf_mc_timer.h>
+#include <qdf_lock.h>
+#include <qdf_str.h>
+#include <qdf_module.h>
+#include <wlan_nlink_common.h>
+#include <wlan_cp_stats_chipset_stats.h>
+
+struct chipset_stats cstats;
+static struct cstats_node *gcstats_buffer[CSTATS_MAX_TYPE];
+
+QDF_STATUS wlan_cp_stats_cstats_init(void)
+{
+	qdf_list_node_t *tmp_node = NULL;
+	int i, j, k;
+
+	for (i = 0; i < CSTATS_MAX_TYPE; i++) {
+		qdf_spinlock_create(&cstats.cstats_lock[i]);
+
+		gcstats_buffer[i] = qdf_mem_valloc(MAX_CSTATS_NODE_COUNT *
+						   sizeof(struct cstats_node));
+		if (!gcstats_buffer[i]) {
+			qdf_err("Could not allocate memory for chipset stats");
+			for (k = 0; k < i ; k++) {
+				qdf_spin_lock_bh(&cstats.cstats_lock[k]);
+				cstats.ccur_node[k] = NULL;
+				qdf_spin_unlock_bh(&cstats.cstats_lock[k]);
+
+				if (gcstats_buffer[k])
+					qdf_mem_vfree(gcstats_buffer[k]);
+			}
+
+			return QDF_STATUS_E_NOMEM;
+		}
+
+		qdf_mem_zero(gcstats_buffer[i], MAX_CSTATS_NODE_COUNT *
+			     sizeof(struct cstats_node));
+
+		qdf_spin_lock_bh(&cstats.cstats_lock[i]);
+		qdf_init_list_head(&cstats.cstat_free_list[i].anchor);
+		qdf_init_list_head(&cstats.cstat_filled_list[i].anchor);
+
+		for (j = 0; j < MAX_CSTATS_NODE_COUNT; j++) {
+			qdf_list_insert_front(&cstats.cstat_free_list[i],
+					      &gcstats_buffer[i][j].node);
+			gcstats_buffer[i][j].index = j;
+		}
+
+		qdf_list_remove_front(&cstats.cstat_free_list[i], &tmp_node);
+
+		cstats.ccur_node[i] =
+			qdf_container_of(tmp_node, struct cstats_node, node);
+		cstats.cstats_no_flush[i] = true;
+		qdf_spin_unlock_bh(&cstats.cstats_lock[i]);
+	}
+
+	return 0;
+}
+
+void wlan_cp_stats_cstats_deinit(void)
+{
+	int i;
+
+	for (i = 0; i < CSTATS_MAX_TYPE; i++) {
+		qdf_spin_lock_bh(&cstats.cstats_lock[i]);
+		cstats.ccur_node[i] = NULL;
+		cstats.cstat_drop_cnt[i] = 0;
+		qdf_spin_unlock_bh(&cstats.cstats_lock[i]);
+
+		if (gcstats_buffer[i]) {
+			qdf_mem_vfree(gcstats_buffer[i]);
+			gcstats_buffer[i] = NULL;
+		}
+	}
+}
+#endif /* WLAN_CHIPSET_STATS */

+ 108 - 0
umac/cp_stats/dispatcher/inc/wlan_cp_stats_chipset_stats.h

@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2024, Qualcomm Innovation Center, Inc. All rights reserved.
+ * SPDX-License-Identifier: ISC
+ */
+
+/**
+ * DOC: This file contains chipset stats implementstion
+ */
+
+#ifndef __WLAN_CP_STATS_CHIPSET_STATS__
+#define __WLAN_CP_STATS_CHIPSET_STATS__
+
+#include <wlan_cmn.h>
+#include <qdf_status.h>
+#include <qdf_trace.h>
+
+#define MAX_CSTATS_NODE_LENGTH 2048
+#define MAX_CSTATS_NODE_COUNT 256
+
+#define ANI_NL_MSG_CSTATS_HOST_LOG_TYPE 110
+#define ANI_NL_MSG_CSTATS_FW_LOG_TYPE 111
+
+#define CSTATS_MARKER_SZ 6
+#define CSTATS_HOST_START_MARKER "CS_HSM"
+#define CSTATS_HOST_END_MARKER "CS_HEM"
+#define CSTATS_FW_START_MARKER "CS_FSM"
+#define CSTATS_FW_END_MARKER  "CS_FEM"
+
+#ifdef QDF_LITTLE_ENDIAN_MACHINE
+#define CHIPSET_STATS_MACHINE_ENDIANNESS (0)
+#else
+#define CHIPSET_STATS_MACHINE_ENDIANNESS (1)
+#endif
+
+#define CSTATS_SET_BIT(value, mask) ((value) |= (1 << (mask)))
+
+#define CSTATS_MAC_COPY(to, from) \
+	do {\
+		to[0] = from[0]; \
+		to[1] = from[1]; \
+		to[2] = from[2]; \
+		to[3] = from[5]; \
+	} while (0)
+
+/**
+ * enum cstats_types - Types of chipset stats
+ * @CSTATS_HOST_TYPE : Host related chipset stats
+ * @CSTATS_FW_TYPE : Firmware related chipset stats
+ * @CSTATS_MAX_TYPE : Invalid
+ */
+enum cstats_types {
+	CSTATS_HOST_TYPE,
+	CSTATS_FW_TYPE,
+	CSTATS_MAX_TYPE,
+};
+
+struct cstats_tx_rx_ops {
+	int (*cstats_send_data_to_usr)(char *buff, unsigned int len,
+				       enum cstats_types type);
+};
+
+struct cstats_node {
+	qdf_list_node_t node;
+	unsigned int radio;
+	unsigned int index;
+	unsigned int filled_length;
+	char logbuf[MAX_CSTATS_NODE_LENGTH];
+};
+
+struct chipset_stats {
+	qdf_list_t cstat_free_list[CSTATS_MAX_TYPE];
+	qdf_list_t cstat_filled_list[CSTATS_MAX_TYPE];
+
+	/* Lock to synchronize access to shared cstats resource */
+	qdf_spinlock_t cstats_lock[CSTATS_MAX_TYPE];
+	struct cstats_node *ccur_node[CSTATS_MAX_TYPE];
+	unsigned int cstat_drop_cnt[CSTATS_MAX_TYPE];
+
+	/* Dont move filled list nodes to free list after flush to user space */
+	bool cstats_no_flush[CSTATS_MAX_TYPE];
+	struct cstats_tx_rx_ops ops;
+};
+
+#ifdef WLAN_CHIPSET_STATS
+/**
+ * wlan_cp_stats_cstats_init() - Initialize chipset stats infra
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS wlan_cp_stats_cstats_init(void);
+
+/**
+ * wlan_cp_stats_cstats_deinit() - Deinitialize chipset stats infra
+ *
+ * Return: void
+ */
+void wlan_cp_stats_cstats_deinit(void);
+#else
+static inline QDF_STATUS wlan_cp_stats_cstats_init(void)
+{
+	return 0;
+}
+
+static inline void wlan_cp_stats_cstats_deinit(void)
+{
+}
+#endif /* WLAN_CHIPSET_STATS */
+#endif /* __WLAN_CP_STATS_CHIPSET_STATS__ */

+ 10 - 1
umac/cp_stats/dispatcher/src/wlan_cp_stats_utils_api.c

@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2018 The Linux Foundation. All rights reserved.
- * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2022-2024 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
@@ -28,6 +28,7 @@
 #include "../../core/src/wlan_cp_stats_comp_handler.h"
 #include <wlan_cp_stats_utils_api.h>
 #include <wlan_cp_stats_ucfg_api.h>
+#include <wlan_cp_stats_chipset_stats.h>
 
 QDF_STATUS wlan_cp_stats_init(void)
 {
@@ -105,6 +106,12 @@ QDF_STATUS wlan_cp_stats_init(void)
 		goto wlan_cp_stats_peer_init_fail2;
 	}
 
+	status = wlan_cp_stats_cstats_init();
+	if (QDF_IS_STATUS_ERROR(status)) {
+		cp_stats_err("Failed to init chipset stats");
+		goto wlan_cp_stats_peer_init_fail2;
+	}
+
 	return QDF_STATUS_SUCCESS;
 
 wlan_cp_stats_peer_init_fail2:
@@ -150,6 +157,8 @@ QDF_STATUS wlan_cp_stats_deinit(void)
 {
 	QDF_STATUS status = QDF_STATUS_E_FAILURE;
 
+	wlan_cp_stats_cstats_deinit();
+
 	status = wlan_objmgr_unregister_psoc_create_handler
 				(WLAN_UMAC_COMP_CP_STATS,
 				 wlan_cp_stats_psoc_obj_create_handler,

+ 8 - 1
utils/logging/inc/wlan_logging_sock_svc.h

@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2014-2021 The Linux Foundation. All rights reserved.
- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2022,2024 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
@@ -180,4 +180,11 @@ enum tx_status {
 	tx_status_peer_del,
 };
 
+#ifdef WLAN_CHIPSET_STATS
+void wlan_set_chipset_stats_bit(void);
+#else
+static inline void wlan_set_chipset_stats_bit(void)
+{
+}
+#endif /* WLAN_CHIPSET_STATS */
 #endif /* WLAN_LOGGING_SOCK_SVC_H */

+ 14 - 0
utils/logging/src/wlan_logging_sock_svc.c

@@ -118,6 +118,8 @@
 #define HOST_LOG_PER_PKT_STATS           0x002
 #define HOST_LOG_FW_FLUSH_COMPLETE       0x003
 #define HOST_LOG_DRIVER_CONNECTIVITY_MSG 0x004
+#define HOST_LOG_CHIPSET_STATS           0x005
+#define FW_LOG_CHIPSET_STATS            0x006
 
 #define DIAG_TYPE_LOGS                 1
 #define PTT_MSG_DIAG_CMDS_TYPE    0x5050
@@ -1225,6 +1227,9 @@ int wlan_logging_sock_init_svc(void)
 	clear_bit(HOST_LOG_PER_PKT_STATS, &gwlan_logging.eventFlag);
 	clear_bit(HOST_LOG_FW_FLUSH_COMPLETE, &gwlan_logging.eventFlag);
 	clear_bit(HOST_LOG_DRIVER_CONNECTIVITY_MSG, &gwlan_logging.eventFlag);
+	clear_bit(HOST_LOG_CHIPSET_STATS, &gwlan_logging.eventFlag);
+	clear_bit(FW_LOG_CHIPSET_STATS, &gwlan_logging.eventFlag);
+
 	init_completion(&gwlan_logging.shutdown_comp);
 	gwlan_logging.thread = kthread_create(wlan_logging_thread, NULL,
 					      "wlan_logging_thread");
@@ -1293,6 +1298,8 @@ int wlan_logging_sock_deinit_svc(void)
 	clear_bit(HOST_LOG_PER_PKT_STATS, &gwlan_logging.eventFlag);
 	clear_bit(HOST_LOG_FW_FLUSH_COMPLETE, &gwlan_logging.eventFlag);
 	clear_bit(HOST_LOG_DRIVER_CONNECTIVITY_MSG, &gwlan_logging.eventFlag);
+	clear_bit(HOST_LOG_CHIPSET_STATS, &gwlan_logging.eventFlag);
+	clear_bit(FW_LOG_CHIPSET_STATS, &gwlan_logging.eventFlag);
 	wake_up_interruptible(&gwlan_logging.wait_queue);
 	wait_for_completion(&gwlan_logging.shutdown_comp);
 
@@ -1802,4 +1809,11 @@ void wlan_register_txrx_packetdump(uint8_t pdev_id)
 	csr_packetdump_timer_start();
 }
 #endif /* CONNECTIVITY_PKTLOG */
+#ifdef WLAN_CHIPSET_STATS
+void wlan_set_chipset_stats_bit(void)
+{
+	set_bit(HOST_LOG_CHIPSET_STATS, &gwlan_logging.eventFlag);
+	set_bit(FW_LOG_CHIPSET_STATS, &gwlan_logging.eventFlag);
+}
+#endif /* WLAN_CHIPSET_STATS */
 #endif /* WLAN_LOGGING_SOCK_SVC_ENABLE */