Эх сурвалжийг харах

qcacmn: debugfs support for sm history

SM history is redirected to debugfs for user to redirect
it to a file

Change-Id: I7670be9dbccaaef868e472062c1ee97635bd29d5
CRs-Fixed: 2613250
Srinivas Pitla 5 жил өмнө
parent
commit
9632da7583

+ 13 - 1
umac/cmn_services/sm_engine/inc/wlan_sm_engine_dbg.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2018-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
@@ -137,6 +137,18 @@ void wlan_sm_history_delete(struct wlan_sm *sm);
  */
 void wlan_sm_print_history(struct wlan_sm *sm);
 
+#if SM_HIST_DEBUGFS_SUPPORT
+/**
+ * wlan_sm_print_fs_history() - API to print SM history in proc
+ * @sm: state machine handle
+ * @m: debug fs file handle
+ *
+ * Prints SM history through proc
+ *
+ * Return: void
+ */
+void wlan_sm_print_fs_history(struct wlan_sm *sm, qdf_debugfs_file_t m);
+#endif
 #else /* SM_ENG_HIST_ENABLE */
 
 /**

+ 61 - 1
umac/cmn_services/sm_engine/src/wlan_sm_engine_dbg.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2018-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
@@ -116,3 +116,63 @@ void wlan_sm_print_history(struct wlan_sm *sm)
 
 	qdf_spin_unlock_bh(&p_sm_history->sm_history_lock);
 }
+
+#if SM_HIST_DEBUGFS_SUPPORT
+static void wlan_sm_print_fs_history_entry(struct wlan_sm *sm,
+					   struct wlan_sm_history_info *ent,
+					   uint16_t i, qdf_debugfs_file_t m)
+{
+	const char *event_name = NULL;
+
+	if (sm->event_names) {
+		if (ent->event_type < sm->num_event_names)
+			event_name = sm->event_names[ent->event_type];
+
+		if (!ent->trace_type)
+			return;
+
+		qdf_debugfs_printf(m,
+				   "|%6d |%11d |%23s[%3d] |%19s[%2d] |%19s[%2d] |\n",
+				   i, ent->trace_type,
+				   event_name ? event_name : "UNKNOWN_EVENT",
+				   ent->event_type,
+				   sm->state_info[ent->initial_state].name,
+				   ent->initial_state,
+				   sm->state_info[ent->final_state].name,
+				   ent->final_state);
+	} else {
+		qdf_debugfs_printf(m,
+				   "|%6d |%11d |%28d |%19s[%2d] |%19s[%2d] |\n",
+				   i, ent->trace_type,
+				   ent->event_type,
+				   sm->state_info[ent->initial_state].name,
+				   ent->initial_state,
+				   sm->state_info[ent->final_state].name,
+				   ent->final_state);
+	}
+}
+
+void wlan_sm_print_fs_history(struct wlan_sm *sm, qdf_debugfs_file_t m)
+{
+	struct wlan_sm_history *p_sm_history = &sm->history;
+	uint8_t i;
+	uint8_t idx;
+
+	/*
+	 * History saved in circular buffer.
+	 * Save a pointer to next write location and increment pointer.
+	 */
+	qdf_spin_lock_bh(&p_sm_history->sm_history_lock);
+	qdf_debugfs_printf(m, "|%6s |%11s |%28s |%23s |%23s |\n", "Index",
+			   "Trace Type", "Event",
+			   "Initial State", "Final State");
+
+	for (i = 0; i < WLAN_SM_ENGINE_HISTORY_SIZE; i++) {
+		idx = (p_sm_history->index + i) % WLAN_SM_ENGINE_HISTORY_SIZE;
+		wlan_sm_print_fs_history_entry(sm, &p_sm_history->data[idx],
+					       idx, m);
+	}
+
+	qdf_spin_unlock_bh(&p_sm_history->sm_history_lock);
+}
+#endif