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