xref: /wlan-dirver/qca-wifi-host-cmn/utils/host_diag_log/src/i_host_diag_core_event.h (revision d0c05845839e5f2ba5a8dcebe0cd3e4cd4e8dfcf)
1 /*
2  * Copyright (c) 2014-2019, 2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022 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 #if !defined(__I_HOST_DIAG_CORE_EVENT_H)
21 #define __I_HOST_DIAG_CORE_EVENT_H
22 
23 /**=========================================================================
24 
25    \file  i_host_diag_core_event.h
26 
27    \brief Android specific definitions for WLAN UTIL DIAG events
28 
29    ========================================================================*/
30 
31 /* $Header$ */
32 
33 /*--------------------------------------------------------------------------
34    Include Files
35    ------------------------------------------------------------------------*/
36 #include <qdf_types.h>
37 #ifdef FEATURE_WLAN_DIAG_SUPPORT
38 #include <host_diag_event_defs.h>
39 #endif
40 
41 /*--------------------------------------------------------------------------
42    Preprocessor definitions and constants
43    ------------------------------------------------------------------------*/
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif /* __cplusplus */
48 
49 #ifdef FEATURE_WLAN_DIAG_SUPPORT
50 
51 void host_diag_event_report_payload(uint16_t event_Id, uint16_t length,
52 				    void *pPayload);
53 /*---------------------------------------------------------------------------
54    Allocate an event payload holder
55    ---------------------------------------------------------------------------*/
56 #define WLAN_HOST_DIAG_EVENT_DEF(payload_name, payload_type) \
57 	payload_type(payload_name)
58 
59 /*---------------------------------------------------------------------------
60    Report the event
61    ---------------------------------------------------------------------------*/
62 #define WLAN_HOST_DIAG_EVENT_REPORT(payload_ptr, ev_id) \
63 	do {							\
64 		host_diag_event_report_payload(ev_id,		\
65 						sizeof(*(payload_ptr)),			\
66 						(void *)(payload_ptr));			\
67 	} while (0)
68 
69 #else                           /* FEATURE_WLAN_DIAG_SUPPORT */
70 
71 #define WLAN_HOST_DIAG_EVENT_DEF(payload_name, payload_type)
72 #define WLAN_HOST_DIAG_EVENT_REPORT(payload_ptr, ev_id)
73 
74 #endif /* FEATURE_WLAN_DIAG_SUPPORT */
75 
76 /**
77  * enum auth_timeout_type - authentication timeout type
78  * @AUTH_FAILURE_TIMEOUT: auth failure timeout
79  * @AUTH_RESPONSE_TIMEOUT: auth response timeout
80  */
81 enum auth_timeout_type {
82 	AUTH_FAILURE_TIMEOUT,
83 	AUTH_RESPONSE_TIMEOUT,
84 };
85 
86 #ifdef CONNECTIVITY_DIAG_EVENT
87 /**
88  * enum diag_roam_reason - Represents the reason codes for roaming.
89  * @DIAG_ROAM_REASON_UNKNOWN: Any reason that do not classify under the below
90  * reasons.
91  * @DIAG_ROAM_REASON_PER: Roam triggered when packet error rates(PER) breached
92  * the configured threshold.
93  * @DIAG_ROAM_REASON_BEACON_MISS: Roam triggered due to the continuous
94  * configured beacon misses from the then connected AP.
95  * @DIAG_ROAM_REASON_POOR_RSSI: Roam triggered due to the poor RSSI reported
96  * by the connected AP.
97  * @DIAG_ROAM_REASON_BETTER_RSSI: Roam triggered for finding a BSSID with a
98  * better RSSI than the connected BSSID. Here the RSSI of the current BSSID is
99  * not poor.
100  * @DIAG_ROAM_REASON_CONGESTION: Roam triggered considering the connected
101  * channel or environment being very noisy / congested.
102  * @DIAG_ROAM_REASON_EXPLICIT_REQUEST: Roam triggered due to an explicit request
103  * from the user (user space).
104  * @DIAG_ROAM_REASON_BTM: Roam triggered due to BTM request frame received from
105  * connected AP.
106  * @DIAG_ROAM_REASON_BSS_LOAD: Roam triggered due to the channel utilization
107  * breaching out the configured threshold.
108  * @DIAG_ROAM_REASON_WTC: Roam triggered due to Wireless to Cellular BSS
109  * transition request.
110  * @DIAG_ROAM_REASON_IDLE: Roam triggered when device is suspended,
111  * there is no data activity with the AP and the current rssi falls below a
112  * certain threshold.
113  * @DIAG_ROAM_REASON_DISCONNECTION: Roam triggered due to
114  * deauthentication or disassociation frames received from the connected AP.
115  * @DIAG_ROAM_REASON_PERIODIC_TIMER: Roam triggered as part of the periodic
116  * scan that happens when there is no candiate AP found during the poor
117  * RSSI scan trigger.
118  * @DIAG_ROAM_REASON_BACKGROUND_SCAN: Roam triggered based on the scan
119  * results obtained from an external scan (not aimed at roaming).
120  * @DIAG_ROAM_REASON_BT_ACTIVITY: Roam triggered due to bluetooth
121  * connection is established when the station is connected in 2.4 Ghz band.
122  */
123 enum diag_roam_reason {
124 	DIAG_ROAM_REASON_UNKNOWN,
125 	DIAG_ROAM_REASON_PER,
126 	DIAG_ROAM_REASON_BEACON_MISS,
127 	DIAG_ROAM_REASON_POOR_RSSI,
128 	DIAG_ROAM_REASON_BETTER_RSSI,
129 	DIAG_ROAM_REASON_CONGESTION,
130 	DIAG_ROAM_REASON_USER_TRIGGER,
131 	DIAG_ROAM_REASON_BTM,
132 	DIAG_ROAM_REASON_BSS_LOAD,
133 	DIAG_ROAM_REASON_WTC,
134 	DIAG_ROAM_REASON_IDLE,
135 	DIAG_ROAM_REASON_DISCONNECTION,
136 	DIAG_ROAM_REASON_PERIODIC_TIMER,
137 	DIAG_ROAM_REASON_BACKGROUND_SCAN,
138 	DIAG_ROAM_REASON_BT_ACTIVITY
139 };
140 
141 /**
142  * enum diag_roam_sub_reason - Used by attribute
143  * @DIAG_ROAM_SUB_REASON_PERIODIC_TIMER: Roam scan triggered due to periodic
144  * timer expiry
145  * @DIAG_ROAM_SUB_REASON_INACTIVITY_TIMER_LOW_RSSI: Roam scan trigger due
146  * to no candidate found during LOW RSSI trigger.
147  * @DIAG_ROAM_SUB_REASON_BTM_DI_TIMER: Roam scan triggered due to BTM Disassoc
148  * Imminent timeout
149  * @DIAG_ROAM_SUB_REASON_FULL_SCAN: Roam scan triggered due to partial scan
150  * failure
151  * @DIAG_ROAM_SUB_REASON_LOW_RSSI_PERIODIC: Roam trigger due to
152  * emergency like deauth/disassoc.
153  * @DIAG_ROAM_SUB_REASON_CU_PERIODIC: Roam trigger due to
154  * BSS transition management request.
155  * @DIAG_ROAM_SUB_REASON_PERIODIC_TIMER_AFTER_INACTIVITY_LOW_RSSI:
156  * Roam scan triggered due to Low RSSI periodic timer
157  * @DIAG_ROAM_SUB_REASON_PERIODIC_TIMER_AFTER_INACTIVITY_CU:
158  * Roam trigger due to periodic timer after no candidate found during CU
159  * inactivity timer scan.
160  * @DIAG_ROAM_SUB_REASON_INACTIVITY_TIMER_CU: Roam trigger due to no candidate
161  * found in high CU roam trigger.
162  */
163 
164 enum diag_roam_sub_reason {
165 	DIAG_ROAM_SUB_REASON_UNKNOWN = 0,
166 	DIAG_ROAM_SUB_REASON_PERIODIC_TIMER = 1,
167 	DIAG_ROAM_SUB_REASON_INACTIVITY_TIMER_LOW_RSSI = 2,
168 	DIAG_ROAM_SUB_REASON_BTM_DI_TIMER = 3,
169 	DIAG_ROAM_SUB_REASON_FULL_SCAN = 4,
170 	DIAG_ROAM_SUB_REASON_LOW_RSSI_PERIODIC = 5,
171 	DIAG_ROAM_SUB_REASON_CU_PERIODIC = 6,
172 	DIAG_ROAM_SUB_REASON_PERIODIC_TIMER_AFTER_INACTIVITY_LOW_RSSI = 7,
173 	DIAG_ROAM_SUB_REASON_PERIODIC_TIMER_AFTER_INACTIVITY_CU = 8,
174 	DIAG_ROAM_SUB_REASON_INACTIVITY_TIMER_CU = 9,
175 };
176 #endif
177 
178 /*-------------------------------------------------------------------------
179    Function declarations and documenation
180    ------------------------------------------------------------------------*/
181 #ifdef FEATURE_WLAN_DIAG_SUPPORT
182 void host_diag_log_wlock(uint32_t reason, const char *wake_lock_name,
183 		uint32_t timeout, uint32_t status);
184 #else
185 static inline void host_diag_log_wlock(uint32_t reason,
186 		const char *wake_lock_name,
187 		uint32_t timeout, uint32_t status)
188 {
189 
190 }
191 #endif /* FEATURE_WLAN_DIAG_SUPPORT */
192 
193 #ifdef FEATURE_WLAN_DIAG_SUPPORT
194 void host_log_low_resource_failure(uint8_t event_sub_type);
195 #else
196 static inline void host_log_low_resource_failure(uint8_t event_sub_type)
197 {
198 
199 }
200 #endif /* FEATURE_WLAN_DIAG_SUPPORT */
201 
202 #ifdef FEATURE_WLAN_DIAG_SUPPORT
203 /**
204  * host_log_rsn_info() - This function is used to send
205  * requested rsn info in assoc request
206  * @ucast_cipher: Unicast ciphers used in assoc request
207  * @mcast_cipher: Group ciphers used in assoc request
208  * @akm_suite: Gives information about akm suites used in assoc request
209  * @group_mgmt: Requested group mgmt cipher suite
210  *
211  * This function is used to send RSN info used in assoc req to user space
212  *
213  * Return: None
214  *
215  */
216 void host_log_rsn_info(uint8_t *ucast_cipher, uint8_t *mcast_cipher,
217 		       uint8_t *auth_suite, uint8_t *gp_mgmt_cipher);
218 
219 #else
220 static inline void host_log_rsn_info(uint8_t *ucast_cipher,
221 				     uint8_t *mcast_cipher,
222 				     uint8_t *auth_suite,
223 				     uint8_t *gp_mgmt_cipher)
224 {
225 
226 }
227 
228 #endif /* FEATURE_WLAN_DIAG_SUPPORT */
229 
230 #ifdef FEATURE_WLAN_DIAG_SUPPORT
231 /**
232  * host_log_wlan_auth_info() - This function is used to send
233  * algo num, seq num and status code for auth request
234  * @auth_algo_num: Gives information about algo num used in auth request
235  * @auth_tx_seq_num: seq num of auth request
236  * @auth_status_code: status code of auth request
237  *
238  * This function is used to send send algo num, seq num and status code
239  * for auth request
240  *
241  * Return: None
242  *
243  */
244 void
245 host_log_wlan_auth_info(uint16_t auth_algo_num, uint16_t auth_tx_seq_num,
246 			uint16_t auth_status_code);
247 
248 #else
249 static inline void
250 host_log_wlan_auth_info(uint16_t auth_algo_num, uint16_t auth_tx_seq_num,
251 			uint16_t auth_status_code)
252 {
253 }
254 
255 #endif /* FEATURE_WLAN_DIAG_SUPPORT */
256 
257 #ifdef FEATURE_WLAN_DIAG_SUPPORT
258 void qdf_wow_wakeup_host_event(uint8_t wow_wakeup_cause);
259 
260 /**
261  * host_log_acs_req_event() - ACS request event indication
262  * @intf: network interface name for WLAN
263  * @hw_mode: hw mode configured by hostapd
264  * @bw: channel bandwidth (MHz)
265  * @ht: a flag indicating whether HT phy mode is enabled
266  * @vht: a flag indicating whether VHT phy mode is enabled
267  * @chan_start: starting channel number for ACS scan
268  * @chan_end: ending channel number for ACS scan
269  *
270  * Indicates the diag event for ACS request with payload related
271  * to parameters populated by hostapd
272  *
273  * Return: None
274  */
275 void host_log_acs_req_event(uint8_t *intf, const uint8_t *hw_mode,
276 			    uint16_t bw, uint8_t ht, uint8_t vht,
277 			    uint16_t chan_start, uint16_t chan_end);
278 
279 /**
280  * host_log_acs_scan_start() - ACS scan start event indication
281  * @scan_id: scan request ID
282  * @vdev_id: vdev/session ID
283  *
284  * Indicates the diag event for ACS scan start request
285  *
286  * Return: None
287  */
288 void host_log_acs_scan_start(uint32_t scan_id, uint8_t vdev_id);
289 
290 /**
291  * host_log_acs_scan_done() - ACS scan done event indication
292  * @status: indicating whether ACS scan is successful
293  * @vdev_id: vdev/session ID
294  * @scan_id: scan request ID
295  *
296  * Indicates the diag event for ACS scan done
297  *
298  * Return: None
299  */
300 void host_log_acs_scan_done(const uint8_t *status, uint8_t vdev_id,
301 			    uint32_t scan_id);
302 
303 /**
304  * host_log_acs_chan_spect_weight() - ACS channel spectral weight indication
305  * weight event indication
306  * @chan: channel number
307  * @weight: channel weight
308  * @rssi: RSSI value obtained after scanning
309  * @bss_count: number of BSS detected on this channel
310  *
311  * Indicates a diag event for ACS channel weight evaluation result
312  *
313  * Return: None
314  */
315 void host_log_acs_chan_spect_weight(uint16_t chan, uint16_t weight,
316 				    int32_t rssi, uint16_t bss_count);
317 
318 /**
319  * host_log_acs_best_chan() - ACS best channel event indication
320  * @chan: channel number
321  * @weight: channel weight
322  *
323  * Indicates the best channel has been selected after ACS
324  *
325  * Return: None
326  */
327 void host_log_acs_best_chan(uint16_t chan, uint16_t weight);
328 
329 /**
330  * host_log_device_status() - device status indication
331  * @status_code: status code from enum wlan_bringup_status
332  *
333  * Indicates device status
334  *
335  * Return: None
336  */
337 void host_log_device_status(uint16_t status_code);
338 
339 #else
340 static inline void qdf_wow_wakeup_host_event(uint8_t wow_wakeup_cause)
341 {
342 	return;
343 }
344 
345 static inline void host_log_acs_req_event(uint8_t *intf, const uint8_t *hw_mode,
346 					  uint16_t bw, uint8_t ht, uint8_t vht,
347 					  uint16_t chan_start,
348 					  uint16_t chan_end)
349 {
350 }
351 
352 static inline void host_log_acs_scan_start(uint32_t scan_id, uint8_t vdev_id)
353 {
354 }
355 
356 static inline void host_log_acs_scan_done(const uint8_t *status,
357 					  uint8_t vdev_id, uint32_t scan_id)
358 {
359 }
360 
361 static inline void host_log_acs_chan_spect_weight(uint16_t chan,
362 						  uint16_t weight, int32_t rssi,
363 						  uint16_t bss_count)
364 {
365 }
366 
367 static inline void host_log_acs_best_chan(uint16_t chan, uint32_t weight)
368 {
369 }
370 
371 static inline void host_log_device_status(uint16_t status_code)
372 {
373 }
374 #endif /* FEATURE_WLAN_DIAG_SUPPORT */
375 #ifdef __cplusplus
376 }
377 #endif /* __cplusplus */
378 #endif /* __I_HOST_DIAG_CORE_EVENT_H */
379