xref: /wlan-dirver/qca-wifi-host-cmn/utils/logging/inc/wlan_roam_debug.h (revision 2f4b444fb7e689b83a4ab0e7b3b38f0bf4def8e0)
1 /*
2  * Copyright (c) 2013-2019, 2021 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: Roaming debug log operations declarations
20  */
21 #ifndef _WLAN_ROAM_DEBUG_H_
22 #define _WLAN_ROAM_DEBUG_H_
23 
24 #define roam_debug(args ...) \
25 		QDF_TRACE_DEBUG_NO_FL(QDF_MODULE_ID_ROAM_DEBUG, ## args)
26 #define roam_info(args ...) \
27 		QDF_TRACE_INFO_NO_FL(QDF_MODULE_ID_ROAM_DEBUG, ## args)
28 
29 #define wlan_rec_conn_info(vdev_id, op, mac_addr, arg1, arg2) \
30 	wlan_rec_debug_log(REC_CONN, vdev_id, op, 0, mac_addr, 0, arg1,\
31 			   arg2)
32 
33 #ifndef WLAN_ROAM_DEBUG_MAX_REC
34 #define WLAN_ROAM_DEBUG_MAX_REC 128
35 #endif
36 
37 typedef enum {
38 	REC_ROAM,
39 	REC_CONN,
40 	REC_MAX,
41 } wlan_rec_type;
42 
43 /**
44  * @DEBUG_PEER_CREATE_SEND: sent peer_create command to firmware
45  * @DEBUG_PEER_CREATE_RESP: received peer create response
46  * @DEBUG_PEER_DELETE_SEND: sent peer delete command to firmware
47  * @DEBUG_PEER_DELETE_RESP: received peer delete response
48  * @DEBUG_PEER_MAP_EVENT: received peer map event
49  * @DEBUG_PEER_UNMAP_EVENT: received peer unmap event
50  * @DEBUG_PEER_UNREF_DELETE: peer reference is decremented
51  * @DEBUG_DELETING_PEER_OBJ: peer object is deleted
52  * @DEBUG_ROAM_SYNCH_IND: received roam offload sync indication
53  * @DEBUG_ROAM_SYNCH_CNF: sent roam offload sync confirmation
54  * @DEBUG_ROAM_SYNCH_FAIL: received roam sync failure indication
55  * @DEBUG_ROAM_EVENT: received roam event
56  * @DEBUG_BUS_SUSPEND: host going into suspend mode
57  * @DEBUG_BUS_RESUME: host operation resumed
58  * @DEBUG_CONN_CONNECTING: trace connecting to bssid
59  * @DEBUG_CONN_ASSOCIATION: trace association completion
60  * @DEBUG_CONN_CONNECT_RESULT: trace connect result to os
61  * @DEBUG_CONN_ROAMING: trace station roaming propagtion
62  * @DEBUG_CONN_ROAMED: trace roamed to bssid
63  * @DEBUG_CONN_ROAMED_IND: trace roam indication
64  * @DEBUG_CONN_DISCONNECT: trace station disconnect
65  * @DEBUG_CONN_DISCONNECT_HANDLER: trace disconnect handler
66  * @DEBUG_CONN_DISCONNECT_IND: trace disconnect indication
67  */
68 enum peer_debug_op {
69 	DEBUG_PEER_CREATE_SEND = 0,
70 	DEBUG_PEER_CREATE_RESP,
71 	DEBUG_PEER_DELETE_SEND,
72 	DEBUG_PEER_DELETE_RESP,
73 	DEBUG_PEER_MAP_EVENT,
74 	DEBUG_PEER_UNMAP_EVENT,
75 	DEBUG_PEER_UNREF_DELETE,
76 	DEBUG_DELETING_PEER_OBJ,
77 	DEBUG_ROAM_SYNCH_IND,
78 	DEBUG_ROAM_SYNCH_CNF,
79 	DEBUG_ROAM_SYNCH_FAIL,
80 	DEBUG_ROAM_EVENT,
81 	DEBUG_WOW_ROAM_EVENT,
82 	DEBUG_BUS_SUSPEND,
83 	DEBUG_BUS_RESUME,
84 	DEBUG_WOW_REASON,
85 	DEBUG_CONN_CONNECTING,
86 	DEBUG_CONN_ASSOCIATION,
87 	DEBUG_CONN_CONNECT_RESULT,
88 	DEBUG_CONN_ROAMING,
89 	DEBUG_CONN_ROAMED,
90 	DEBUG_CONN_ROAMED_IND,
91 	DEBUG_CONN_DISCONNECT,
92 	DEBUG_CONN_DISCONNECT_HANDLER,
93 	DEBUG_CONN_DISCONNECT_IND,
94 };
95 
96 /**
97  * struct wlan_roam_debug_rec - roam debug information record definition
98  * @time: timestamp when record was added
99  * @operation: identifier for operation, command, event, etc.
100  * @vdev_id: vdev identifier
101  * @peer_id: peer_id. Range 0 - 255, 0xffff is invalid peer_id.
102  * @mac_addr: mac address of peer
103  * @peer_obj: pointer to peer object
104  * @arg1: Optional argument #1
105  * @arg2: Opttional argument #2
106  */
107 struct wlan_roam_debug_rec {
108 	uint64_t time;
109 	enum peer_debug_op operation;
110 	uint8_t vdev_id;
111 	uint16_t peer_id;
112 	struct qdf_mac_addr mac_addr;
113 	void *peer_obj;
114 	uint32_t arg1;
115 	uint32_t arg2;
116 };
117 
118 /**
119  * struct wlan_roam_debug_info - Buffer to store the wma debug records
120  * @index: index of the most recent entry in the circular buffer
121  * @num_max_rec: maximum records stored in the records array
122  * @rec: array to store wma debug records, used in circular fashion
123  */
124 struct wlan_roam_debug_info {
125 	qdf_atomic_t index;
126 	uint32_t num_max_rec;
127 	void (*rec_print)(struct wlan_roam_debug_rec *dbg_rec,
128 			  uint32_t idx, uint32_t delta,
129 			  bool to_kernel);
130 	struct wlan_roam_debug_rec rec[WLAN_ROAM_DEBUG_MAX_REC];
131 };
132 
133 #define DEBUG_INVALID_PEER_ID 0xffff
134 #define DEBUG_INVALID_VDEV_ID 0xff
135 
136 #ifdef FEATURE_ROAM_DEBUG
137 /**
138  * wlan_roam_debug_log() - Add a debug log entry to wlan roam debug records
139  * @vdev_id: vdev identifier
140  * @op: operation identifier
141  * @peer_id: peer id
142  * @mac_addr: mac address of peer, can be NULL
143  * @peer_obj: peer object address, can be NULL
144  * @arg1: extra argument #1
145  * @arg2: extra argument #2
146  *
147  * Return: none
148  */
149 void wlan_roam_debug_log(uint8_t vdev_id, uint8_t op,
150 			uint16_t peer_id, void *mac_addr,
151 			void *peer_obj, uint32_t arg1, uint32_t arg2);
152 /**
153  * wlan_rec_debug_log() - Add a debug log entry to wlan debug records
154  * @rec_type: record type
155  * @vdev_id: vdev identifier
156  * @op: operation identifier
157  * @peer_id: peer id
158  * @mac_addr: mac address of peer, can be NULL
159  * @peer_obj: peer object address, can be NULL
160  * @arg1: extra argument #1
161  * @arg2: extra argument #2
162  *
163  * Return: none
164  */
165 void wlan_rec_debug_log(wlan_rec_type rec_type, uint8_t vdev_id, uint8_t op,
166 			uint16_t peer_id, const void *mac_addr,
167 			void *peer_obj, uint32_t arg1, uint32_t arg2);
168 
169 /**
170  * wlan_roam_debug_dump_table() - Print the roam debug log records
171  * print all the valid debug records in the order of timestamp
172  *
173  * Return: none
174  */
175 void wlan_roam_debug_dump_table(void);
176 
177 /**
178  * wlan_rec_debug_dump_table() - Print the wlan roam debug log records
179  * @rec_type: recorad type
180  * @count: count of records to print
181  * @to_kernel: print to kernel or not
182  *
183  * print all the valid debug records in the order of timestamp
184  *
185  * Return: none
186  */
187 void wlan_rec_debug_dump_table(wlan_rec_type rec_type, uint32_t count,
188 			       bool to_kernel);
189 
190 #ifdef WLAN_LOGGING_BUFFERS_DYNAMICALLY
191 /**
192  * wlan_roam_debug_init() - Allocate log buffer dynamically
193  *
194  * Return: none
195  */
196 void wlan_roam_debug_init(void);
197 /**
198  * wlan_roam_debug_deinit() - Free log buffer allocated dynamically
199  *
200  * Return: none
201  */
202 void wlan_roam_debug_deinit(void);
203 #else /* WLAN_LOGGING_BUFFERS_DYNAMICALLY */
204 static inline void wlan_roam_debug_init(void)
205 {
206 }
207 
208 static inline void wlan_roam_debug_deinit(void)
209 {
210 }
211 #endif /* WLAN_LOGGING_BUFFERS_DYNAMICALLY */
212 
213 #else /* FEATURE_ROAM_DEBUG */
214 static inline void
215 wlan_roam_debug_log(uint8_t vdev_id, uint8_t op,
216 		    uint16_t peer_id, void *mac_addr,
217 		    void *peer_obj, uint32_t arg1, uint32_t arg2)
218 {
219 }
220 
221 static inline void wlan_rec_debug_log(
222 			wlan_rec_type rec_type, uint8_t vdev_id, uint8_t op,
223 			uint16_t peer_id, const void *mac_addr,
224 			void *peer_obj, uint32_t arg1, uint32_t arg2)
225 {
226 }
227 
228 static inline void wlan_roam_debug_dump_table(void)
229 {
230 }
231 
232 static inline void wlan_rec_debug_dump_table(wlan_rec_type rec_type,
233 					     uint32_t count,
234 					     bool to_kernel)
235 {
236 }
237 
238 static inline void wlan_roam_debug_init(void)
239 {
240 }
241 
242 static inline void wlan_roam_debug_deinit(void)
243 {
244 }
245 #endif /* FEATURE_ROAM_DEBUG */
246 
247 #endif /* _WLAN_ROAM_DEBUG_H_ */
248