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 #define WLAN_SM_ENGINE_HISTORY_SIZE 50 55 struct wlan_sm; 56 /** 57 * enum wlan_sm_trace_type - history element type 58 * @SM_EVENT_STATE_TRANSITION: Represents state transition 59 * @SM_EVENT_MSG_PROCESSING: Represents event processing 60 */ 61 enum wlan_sm_trace_type { 62 SM_EVENT_STATE_TRANSITION = 1, 63 SM_EVENT_MSG_PROCESSING, 64 }; 65 66 #ifdef SM_ENG_HIST_ENABLE 67 68 /** 69 * struct wlan_sm_history_info - history element structure 70 * @trace_type: history element type 71 * @event_type: Type of the event 72 * @initial_state: Current state (state/sub-state) 73 * @final_state: New state 74 * @time: Timestamp 75 */ 76 struct wlan_sm_history_info { 77 enum wlan_sm_trace_type trace_type; 78 uint8_t event_type; 79 uint8_t initial_state; 80 uint8_t final_state; 81 uint64_t time; 82 }; 83 84 /** 85 * struct wlan_sm_history - history structure 86 * @sm_history_lock: SM history lock 87 * @index: Last updated entry index 88 * @data: Histoy elements array 89 */ 90 struct wlan_sm_history { 91 qdf_spinlock_t sm_history_lock; 92 uint8_t index; 93 struct wlan_sm_history_info data[WLAN_SM_ENGINE_HISTORY_SIZE]; 94 }; 95 96 /** 97 * wlan_sm_save_history() - API to save SM history 98 * @sm: state machine handle 99 * @trace_type: type of operation 100 * @initial_state: current state 101 * @final_state: Resultant state 102 * @event_type: Event id 103 * 104 * Stores the SM state transition and event processing 105 * 106 * Return: void 107 */ 108 void wlan_sm_save_history(struct wlan_sm *sm, 109 enum wlan_sm_trace_type trace_type, 110 uint8_t initial_state, uint8_t final_state, 111 uint16_t event_type); 112 113 /** 114 * wlan_sm_history_init() - API to initialize SM history module 115 * @sm: state machine handle 116 * 117 * Initializes SM history module 118 * 119 * Return: void 120 */ 121 void wlan_sm_history_init(struct wlan_sm *sm); 122 123 /** 124 * wlan_sm_history_delete() - API to delete SM history module 125 * @sm: state machine handle 126 * 127 * Deletes SM history module 128 * 129 * Return: void 130 */ 131 void wlan_sm_history_delete(struct wlan_sm *sm); 132 133 /** 134 * wlan_sm_print_history() - API to print SM history 135 * @sm: state machine handle 136 * 137 * Prints SM history 138 * 139 * Return: void 140 */ 141 void wlan_sm_print_history(struct wlan_sm *sm); 142 143 #if SM_HIST_DEBUGFS_SUPPORT 144 /** 145 * wlan_sm_print_fs_history() - API to print SM history in proc 146 * @sm: state machine handle 147 * @m: debug fs file handle 148 * 149 * Prints SM history through proc 150 * 151 * Return: void 152 */ 153 void wlan_sm_print_fs_history(struct wlan_sm *sm, qdf_debugfs_file_t m); 154 #endif 155 #else /* SM_ENG_HIST_ENABLE */ 156 157 /** 158 * wlan_sm_save_history() - API to save SM history 159 * @sm: state machine handle 160 * @trace_type: type of operation 161 * @initial_state: current state 162 * @final_state: Resultant state 163 * @event_type: Event id 164 * 165 * Stores the SM state transition and event processing 166 * 167 * Return: void 168 */ 169 static inline void wlan_sm_save_history(struct wlan_sm *sm, 170 enum wlan_sm_trace_type trace_type, 171 uint8_t initial_state, 172 uint8_t final_state, 173 uint16_t event_type) 174 { 175 } 176 177 /** 178 * wlan_sm_history_init() - API to initialize SM history module 179 * @sm: state machine handle 180 * 181 * Initializes SM history module 182 * 183 * Return: void 184 */ 185 static inline void wlan_sm_history_init(struct wlan_sm *sm) 186 { 187 } 188 189 /** 190 * wlan_sm_history_delete() - API to delete SM history module 191 * @sm: state machine handle 192 * 193 * Deletes SM history module 194 * 195 * Return: void 196 */ 197 static inline void wlan_sm_history_delete(struct wlan_sm *sm) 198 { 199 } 200 201 /** 202 * wlan_sm_print_history() - API to print SM history 203 * @sm: state machine handle 204 * 205 * Prints SM history 206 * 207 * Return: void 208 */ 209 static inline void wlan_sm_print_history(struct wlan_sm *sm) 210 { 211 } 212 213 #endif /* SM_ENG_HIST_ENABLE */ 214 #endif /* _WLAN_SM_ENGINE_DBG_H_ */ 215