xref: /wlan-dirver/qca-wifi-host-cmn/umac/cmn_services/sm_engine/inc/wlan_sm_engine_dbg.h (revision 97f44cd39e4ff816eaa1710279d28cf6b9e65ad9)
1 /*
2  * Copyright (c) 2018-2020 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18  /**
19   * DOC: Define the debug data structure of UMAC SM
20   */
21 #ifndef _WLAN_SM_ENGINE_DBG_H_
22 #define _WLAN_SM_ENGINE_DBG_H_
23 
24 #include <qdf_types.h>
25 #include <qdf_trace.h>
26 
27 #define sm_engine_alert(params...) \
28 		QDF_TRACE_FATAL(QDF_MODULE_ID_SM_ENGINE, params)
29 
30 #define sm_engine_err(params...) \
31 		QDF_TRACE_ERROR(QDF_MODULE_ID_SM_ENGINE, params)
32 
33 #define sm_engine_warn(params...) \
34 		QDF_TRACE_WARN(QDF_MODULE_ID_SM_ENGINE, params)
35 
36 #define sm_engine_info(params...) \
37 		QDF_TRACE_INFO(QDF_MODULE_ID_SM_ENGINE, params)
38 
39 #define sm_engine_debug(params...) \
40 		QDF_TRACE_DEBUG(QDF_MODULE_ID_SM_ENGINE, params)
41 
42 #define sm_engine_nofl_alert(params...) \
43 	QDF_TRACE_FATAL_NO_FL(QDF_MODULE_ID_SM_ENGINE, params)
44 #define sm_engine_nofl_err(params...) \
45 	QDF_TRACE_ERROR_NO_FL(QDF_MODULE_ID_SM_ENGINE, params)
46 #define sm_engine_nofl_warn(params...) \
47 	QDF_TRACE_WARN_NO_FL(QDF_MODULE_ID_SM_ENGINE, params)
48 #define sm_engine_nofl_info(params...) \
49 	QDF_TRACE_INFO_NO_FL(QDF_MODULE_ID_SM_ENGINE, params)
50 #define sm_engine_nofl_debug(params...) \
51 	QDF_TRACE_DEBUG_NO_FL(QDF_MODULE_ID_SM_ENGINE, params)
52 
53 #define WLAN_SM_ENGINE_HISTORY_SIZE  50
54 struct wlan_sm;
55 /**
56  * enum wlan_sm_trace_type - history element type
57  * @SM_EVENT_STATE_TRANSITION - Represents state transition
58  * @SM_EVENT_MSG_PROCESSING - Represents event processing
59  */
60 enum wlan_sm_trace_type {
61 	SM_EVENT_STATE_TRANSITION = 1,
62 	SM_EVENT_MSG_PROCESSING,
63 };
64 
65 #ifdef SM_ENG_HIST_ENABLE
66 
67 /**
68  * struct wlan_sm_history_info - history element structure
69  * @trace_type:      history element type
70  * @event_type:      Type of the event
71  * @initial_state:   Current state (state/sub-state)
72  * @final_state:     New state
73  */
74 struct wlan_sm_history_info {
75 	enum wlan_sm_trace_type trace_type;
76 	uint8_t event_type;
77 	uint8_t initial_state;
78 	uint8_t final_state;
79 	uint64_t time;
80 };
81 
82 /**
83  * struct wlan_sm_history - history structure
84  * @sm_history_lock: SM history lock
85  * @index:           Last updated entry index
86  * @data:            Histoy elements array
87  */
88 struct wlan_sm_history {
89 	qdf_spinlock_t sm_history_lock;
90 	uint8_t index;
91 	struct wlan_sm_history_info data[WLAN_SM_ENGINE_HISTORY_SIZE];
92 };
93 
94 /**
95  * wlan_sm_save_history() - API to save SM history
96  * @sm: state machine handle
97  * @trace_type: type of operation
98  * @initial_state: current state
99  * @final_state: Resultant state
100  * @event_type: Event id
101  *
102  * Stores the SM state transition and event processing
103  *
104  * Return: void
105  */
106 void wlan_sm_save_history(struct wlan_sm *sm,
107 			  enum wlan_sm_trace_type trace_type,
108 			  uint8_t initial_state, uint8_t final_state,
109 			  uint16_t event_type);
110 
111 /**
112  * wlan_sm_history_init() - API to initialize SM history module
113  * @sm: state machine handle
114  *
115  * Initializes SM history module
116  *
117  * Return: void
118  */
119 void wlan_sm_history_init(struct wlan_sm *sm);
120 
121 /**
122  * wlan_sm_history_delete() - API to delete SM history module
123  * @sm: state machine handle
124  *
125  * Deletes SM history module
126  *
127  * Return: void
128  */
129 void wlan_sm_history_delete(struct wlan_sm *sm);
130 
131 /**
132  * wlan_sm_print_history() - API to print SM history
133  * @sm: state machine handle
134  *
135  * Prints SM history
136  *
137  * Return: void
138  */
139 void wlan_sm_print_history(struct wlan_sm *sm);
140 
141 #if SM_HIST_DEBUGFS_SUPPORT
142 /**
143  * wlan_sm_print_fs_history() - API to print SM history in proc
144  * @sm: state machine handle
145  * @m: debug fs file handle
146  *
147  * Prints SM history through proc
148  *
149  * Return: void
150  */
151 void wlan_sm_print_fs_history(struct wlan_sm *sm, qdf_debugfs_file_t m);
152 #endif
153 #else /* SM_ENG_HIST_ENABLE */
154 
155 /**
156  * wlan_sm_save_history() - API to save SM history
157  * @sm: state machine handle
158  * @trace_type: type of operation
159  * @initial_state: current state
160  * @final_state: Resultant state
161  * @event_type: Event id
162  *
163  * Stores the SM state transition and event processing
164  *
165  * Return: void
166  */
167 static inline void wlan_sm_save_history(struct wlan_sm *sm,
168 					enum wlan_sm_trace_type trace_type,
169 					uint8_t initial_state,
170 					uint8_t final_state,
171 					uint16_t event_type)
172 {
173 }
174 
175 /**
176  * wlan_sm_history_init() - API to initialize SM history module
177  * @sm: state machine handle
178  *
179  * Initializes SM history module
180  *
181  * Return: void
182  */
183 static inline void wlan_sm_history_init(struct wlan_sm *sm)
184 {
185 }
186 
187 /**
188  * wlan_sm_history_delete() - API to delete SM history module
189  * @sm: state machine handle
190  *
191  * Deletes SM history module
192  *
193  * Return: void
194  */
195 static inline void wlan_sm_history_delete(struct wlan_sm *sm)
196 {
197 }
198 
199 /**
200  * wlan_sm_print_history() - API to print SM history
201  * @sm: state machine handle
202  *
203  * Prints SM history
204  *
205  * Return: void
206  */
207 static inline void wlan_sm_print_history(struct wlan_sm *sm)
208 {
209 }
210 
211 #endif    /* SM_ENG_HIST_ENABLE */
212 #endif    /* _WLAN_SM_ENGINE_DBG_H_ */
213