xref: /wlan-dirver/qca-wifi-host-cmn/utils/logging/inc/wlan_roam_debug.h (revision 503663c6daafffe652fa360bde17243568cd6d2a)
1 /*
2  * Copyright (c) 2013-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: Roaming debug log operations declarations
20  */
21 #ifndef _WLAN_ROAM_DEBUG_H_
22 #define _WLAN_ROAM_DEBUG_H_
23 
24 
25 #define roam_debug(args ...) \
26 		QDF_TRACE_DEBUG(QDF_MODULE_ID_ROAM_DEBUG, ## args)
27 
28 /**
29  * struct wlan_roam_debug_rec - roam debug information record definition
30  * @time: timestamp when record was added
31  * @operation: identifier for operation, command, event, etc.
32  * @vdev_id: vdev identifier
33  * @peer_id: peer_id. Range 0 - 255, 0xffff is invalid peer_id.
34  * @mac_addr: mac address of peer
35  * @peer_obj: pointer to peer object
36  * @arg1: Optional argument #1
37  * @arg2: Opttional argument #2
38  */
39 struct wlan_roam_debug_rec {
40 	uint64_t time;
41 	uint8_t operation;
42 	uint8_t vdev_id;
43 	uint16_t peer_id;
44 	struct qdf_mac_addr mac_addr;
45 	void *peer_obj;
46 	uint32_t arg1;
47 	uint32_t arg2;
48 };
49 
50 #ifndef WLAN_ROAM_DEBUG_MAX_REC
51 #define WLAN_ROAM_DEBUG_MAX_REC 256
52 #endif
53 
54 /**
55  * struct wlan_roam_debug_info - Buffer to store the wma debug records
56  * @index: index of the most recent entry in the circular buffer
57  * @num_max_rec: maximum records stored in the records array
58  * @rec: array to store wma debug records, used in circular fashion
59  */
60 struct wlan_roam_debug_info {
61 	qdf_atomic_t index;
62 	uint32_t num_max_rec;
63 	struct wlan_roam_debug_rec rec[WLAN_ROAM_DEBUG_MAX_REC];
64 };
65 
66 /**
67  * @DEBUG_PEER_CREATE_SEND: sent peer_create command to firmware
68  * @DEBUG_PEER_CREATE_RESP: received peer create response
69  * @DEBUG_PEER_DELETE_SEND: sent peer delete command to firmware
70  * @DEBUG_PEER_DELETE_RESP: received peer delete response
71  * @DEBUG_PEER_MAP_EVENT: received peer map event
72  * @DEBUG_PEER_UNMAP_EVENT: received peer unmap event
73  * @DEBUG_PEER_UNREF_DELETE: peer reference is decremented
74  * @DEBUG_DELETING_PEER_OBJ: peer object is deleted
75  * @DEBUG_ROAM_SYNCH_IND: received roam offload sync indication
76  * @DEBUG_ROAM_SYNCH_CNF: sent roam offload sync confirmation
77  * @DEBUG_ROAM_SYNCH_FAIL: received roam sync failure indication
78  * @DEBUG_ROAM_EVENT: received roam event
79  * @DEBUG_BUS_SUSPEND: host going into suspend mode
80  * @DEBUG_BUS_RESUME: host operation resumed
81  */
82 
83 enum peer_debug_op {
84 	DEBUG_PEER_CREATE_SEND = 0,
85 	DEBUG_PEER_CREATE_RESP,
86 	DEBUG_PEER_DELETE_SEND,
87 	DEBUG_PEER_DELETE_RESP,
88 	DEBUG_PEER_MAP_EVENT,
89 	DEBUG_PEER_UNMAP_EVENT,
90 	DEBUG_PEER_UNREF_DELETE,
91 	DEBUG_DELETING_PEER_OBJ,
92 	DEBUG_ROAM_SYNCH_IND,
93 	DEBUG_ROAM_SYNCH_CNF,
94 	DEBUG_ROAM_SYNCH_FAIL,
95 	DEBUG_ROAM_EVENT,
96 	DEBUG_WOW_ROAM_EVENT,
97 	DEBUG_BUS_SUSPEND,
98 	DEBUG_BUS_RESUME,
99 	DEBUG_WOW_REASON,
100 };
101 
102 #define DEBUG_INVALID_PEER_ID 0xffff
103 #define DEBUG_INVALID_VDEV_ID 0xff
104 
105 #ifdef FEATURE_ROAM_DEBUG
106 /**
107  * wlan_roam_debug_log() - Add a debug log entry to wlan roam debug records
108  * @vdev_id: vdev identifier
109  * @op: operation identifier
110  * @peer_id: peer id
111  * @mac_addr: mac address of peer, can be NULL
112  * @peer_obj: peer object address, can be NULL
113  * @arg1: extra argument #1
114  * @arg2: extra argument #2
115  *
116  * Return: none
117  */
118 void wlan_roam_debug_log(uint8_t vdev_id, uint8_t op,
119 			uint16_t peer_id, void *mac_addr,
120 			void *peer_obj, uint32_t arg1, uint32_t arg2);
121 
122 /**
123  * wlan_roam_debug_dump_table() - Print the roam debug log records
124  * print all the valid debug records in the order of timestamp
125  *
126  * Return: none
127  */
128 void wlan_roam_debug_dump_table(void);
129 
130 #ifdef WLAN_LOGGING_BUFFERS_DYNAMICALLY
131 /**
132  * wlan_roam_debug_init() - Allocate log buffer dynamically
133  *
134  * Return: none
135  */
136 void wlan_roam_debug_init(void);
137 /**
138  * wlan_roam_debug_deinit() - Free log buffer allocated dynamically
139  *
140  * Return: none
141  */
142 void wlan_roam_debug_deinit(void);
143 #else /* WLAN_LOGGING_BUFFERS_DYNAMICALLY */
144 static inline void wlan_roam_debug_init(void)
145 {
146 }
147 
148 static inline void wlan_roam_debug_deinit(void)
149 {
150 }
151 #endif /* WLAN_LOGGING_BUFFERS_DYNAMICALLY */
152 
153 #else /* FEATURE_ROAM_DEBUG */
154 static inline void
155 wlan_roam_debug_log(uint8_t vdev_id, uint8_t op,
156 		    uint16_t peer_id, void *mac_addr,
157 		    void *peer_obj, uint32_t arg1, uint32_t arg2)
158 {
159 }
160 
161 static inline void wlan_roam_debug_dump_table(void)
162 {
163 }
164 
165 static inline void wlan_roam_debug_init(void)
166 {
167 }
168 
169 static inline void wlan_roam_debug_deinit(void)
170 {
171 }
172 #endif /* FEATURE_ROAM_DEBUG */
173 
174 #endif /* _WLAN_ROAM_DEBUG_H_ */
175