xref: /wlan-dirver/qca-wifi-host-cmn/umac/cmn_services/sm_engine/inc/wlan_sm_engine_dbg.h (revision f28396d060cff5c6519f883cb28ae0116ce479f1)
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 };
80 
81 /**
82  * struct wlan_sm_history - history structure
83  * @sm_history_lock: SM history lock
84  * @index:           Last updated entry index
85  * @data:            Histoy elements array
86  */
87 struct wlan_sm_history {
88 	qdf_spinlock_t sm_history_lock;
89 	uint8_t index;
90 	struct wlan_sm_history_info data[WLAN_SM_ENGINE_HISTORY_SIZE];
91 };
92 
93 /**
94  * wlan_sm_save_history() - API to save SM history
95  * @sm: state machine handle
96  * @trace_type: type of operation
97  * @initial_state: current state
98  * @final_state: Resultant state
99  * @event_type: Event id
100  *
101  * Stores the SM state transition and event processing
102  *
103  * Return: void
104  */
105 void wlan_sm_save_history(struct wlan_sm *sm,
106 			  enum wlan_sm_trace_type trace_type,
107 			  uint8_t initial_state, uint8_t final_state,
108 			  uint16_t event_type);
109 
110 /**
111  * wlan_sm_history_init() - API to initialize SM history module
112  * @sm: state machine handle
113  *
114  * Initializes SM history module
115  *
116  * Return: void
117  */
118 void wlan_sm_history_init(struct wlan_sm *sm);
119 
120 /**
121  * wlan_sm_history_delete() - API to delete SM history module
122  * @sm: state machine handle
123  *
124  * Deletes SM history module
125  *
126  * Return: void
127  */
128 void wlan_sm_history_delete(struct wlan_sm *sm);
129 
130 /**
131  * wlan_sm_print_history() - API to print SM history
132  * @sm: state machine handle
133  *
134  * Prints SM history
135  *
136  * Return: void
137  */
138 void wlan_sm_print_history(struct wlan_sm *sm);
139 
140 #if SM_HIST_DEBUGFS_SUPPORT
141 /**
142  * wlan_sm_print_fs_history() - API to print SM history in proc
143  * @sm: state machine handle
144  * @m: debug fs file handle
145  *
146  * Prints SM history through proc
147  *
148  * Return: void
149  */
150 void wlan_sm_print_fs_history(struct wlan_sm *sm, qdf_debugfs_file_t m);
151 #endif
152 #else /* SM_ENG_HIST_ENABLE */
153 
154 /**
155  * wlan_sm_save_history() - API to save SM history
156  * @sm: state machine handle
157  * @trace_type: type of operation
158  * @initial_state: current state
159  * @final_state: Resultant state
160  * @event_type: Event id
161  *
162  * Stores the SM state transition and event processing
163  *
164  * Return: void
165  */
166 static inline void wlan_sm_save_history(struct wlan_sm *sm,
167 					enum wlan_sm_trace_type trace_type,
168 					uint8_t initial_state,
169 					uint8_t final_state,
170 					uint16_t event_type)
171 {
172 }
173 
174 /**
175  * wlan_sm_history_init() - API to initialize SM history module
176  * @sm: state machine handle
177  *
178  * Initializes SM history module
179  *
180  * Return: void
181  */
182 static inline void wlan_sm_history_init(struct wlan_sm *sm)
183 {
184 }
185 
186 /**
187  * wlan_sm_history_delete() - API to delete SM history module
188  * @sm: state machine handle
189  *
190  * Deletes SM history module
191  *
192  * Return: void
193  */
194 static inline void wlan_sm_history_delete(struct wlan_sm *sm)
195 {
196 }
197 
198 /**
199  * wlan_sm_print_history() - API to print SM history
200  * @sm: state machine handle
201  *
202  * Prints SM history
203  *
204  * Return: void
205  */
206 static inline void wlan_sm_print_history(struct wlan_sm *sm)
207 {
208 }
209 
210 #endif    /* SM_ENG_HIST_ENABLE */
211 #endif    /* _WLAN_SM_ENGINE_DBG_H_ */
212