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