xref: /wlan-dirver/qca-wifi-host-cmn/umac/cmn_services/sm_engine/inc/wlan_sm_engine_dbg.h (revision dd4dc88b837a295134aa9869114a2efee0f4894b)
1 /*
2  * Copyright (c) 2018-2019 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 #else /* SM_ENG_HIST_ENABLE */
141 
142 /**
143  * wlan_sm_save_history() - API to save SM history
144  * @sm: state machine handle
145  * @trace_type: type of operation
146  * @initial_state: current state
147  * @final_state: Resultant state
148  * @event_type: Event id
149  *
150  * Stores the SM state transition and event processing
151  *
152  * Return: void
153  */
154 static inline void wlan_sm_save_history(struct wlan_sm *sm,
155 					enum wlan_sm_trace_type trace_type,
156 					uint8_t initial_state,
157 					uint8_t final_state,
158 					uint16_t event_type)
159 {
160 }
161 
162 /**
163  * wlan_sm_history_init() - API to initialize SM history module
164  * @sm: state machine handle
165  *
166  * Initializes SM history module
167  *
168  * Return: void
169  */
170 static inline void wlan_sm_history_init(struct wlan_sm *sm)
171 {
172 }
173 
174 /**
175  * wlan_sm_history_delete() - API to delete SM history module
176  * @sm: state machine handle
177  *
178  * Deletes SM history module
179  *
180  * Return: void
181  */
182 static inline void wlan_sm_history_delete(struct wlan_sm *sm)
183 {
184 }
185 
186 /**
187  * wlan_sm_print_history() - API to print SM history
188  * @sm: state machine handle
189  *
190  * Prints SM history
191  *
192  * Return: void
193  */
194 static inline void wlan_sm_print_history(struct wlan_sm *sm)
195 {
196 }
197 
198 #endif    /* SM_ENG_HIST_ENABLE */
199 #endif    /* _WLAN_SM_ENGINE_DBG_H_ */
200