1 /* 2 * Copyright (c) 2014-2019, 2021 The Linux Foundation. All rights reserved. 3 * Copyright (c) 2022-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 #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_USER_TRIGGER: 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 candidate 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_UNKNOWN: Roam sub-reason unknown/unspecified 144 * @DIAG_ROAM_SUB_REASON_PERIODIC_TIMER: Roam scan triggered due to periodic 145 * timer expiry 146 * @DIAG_ROAM_SUB_REASON_INACTIVITY_TIMER_LOW_RSSI: Roam scan trigger due 147 * to no candidate found during LOW RSSI trigger. 148 * @DIAG_ROAM_SUB_REASON_BTM_DI_TIMER: Roam scan triggered due to BTM Disassoc 149 * Imminent timeout 150 * @DIAG_ROAM_SUB_REASON_FULL_SCAN: Roam scan triggered due to partial scan 151 * failure 152 * @DIAG_ROAM_SUB_REASON_LOW_RSSI_PERIODIC: Roam trigger due to 153 * emergency like deauth/disassoc. 154 * @DIAG_ROAM_SUB_REASON_CU_PERIODIC: Roam trigger due to 155 * BSS transition management request. 156 * @DIAG_ROAM_SUB_REASON_PERIODIC_TIMER_AFTER_INACTIVITY_LOW_RSSI: 157 * Roam scan triggered due to Low RSSI periodic timer 158 * @DIAG_ROAM_SUB_REASON_PERIODIC_TIMER_AFTER_INACTIVITY_CU: 159 * Roam trigger due to periodic timer after no candidate found during CU 160 * inactivity timer scan. 161 * @DIAG_ROAM_SUB_REASON_INACTIVITY_TIMER_CU: Roam trigger due to no candidate 162 * found in high CU roam trigger. 163 */ 164 165 enum diag_roam_sub_reason { 166 DIAG_ROAM_SUB_REASON_UNKNOWN = 0, 167 DIAG_ROAM_SUB_REASON_PERIODIC_TIMER = 1, 168 DIAG_ROAM_SUB_REASON_INACTIVITY_TIMER_LOW_RSSI = 2, 169 DIAG_ROAM_SUB_REASON_BTM_DI_TIMER = 3, 170 DIAG_ROAM_SUB_REASON_FULL_SCAN = 4, 171 DIAG_ROAM_SUB_REASON_LOW_RSSI_PERIODIC = 5, 172 DIAG_ROAM_SUB_REASON_CU_PERIODIC = 6, 173 DIAG_ROAM_SUB_REASON_PERIODIC_TIMER_AFTER_INACTIVITY_LOW_RSSI = 7, 174 DIAG_ROAM_SUB_REASON_PERIODIC_TIMER_AFTER_INACTIVITY_CU = 8, 175 DIAG_ROAM_SUB_REASON_INACTIVITY_TIMER_CU = 9, 176 }; 177 #endif 178 179 /*------------------------------------------------------------------------- 180 Function declarations and documentation 181 ------------------------------------------------------------------------*/ 182 #ifdef FEATURE_WLAN_DIAG_SUPPORT 183 void host_diag_log_wlock(uint32_t reason, const char *wake_lock_name, 184 uint32_t timeout, uint32_t status); 185 #else host_diag_log_wlock(uint32_t reason,const char * wake_lock_name,uint32_t timeout,uint32_t status)186 static inline void host_diag_log_wlock(uint32_t reason, 187 const char *wake_lock_name, 188 uint32_t timeout, uint32_t status) 189 { 190 191 } 192 #endif /* FEATURE_WLAN_DIAG_SUPPORT */ 193 194 #ifdef FEATURE_WLAN_DIAG_SUPPORT 195 void host_log_low_resource_failure(uint8_t event_sub_type); 196 #else host_log_low_resource_failure(uint8_t event_sub_type)197 static inline void host_log_low_resource_failure(uint8_t event_sub_type) 198 { 199 200 } 201 #endif /* FEATURE_WLAN_DIAG_SUPPORT */ 202 203 #ifdef FEATURE_WLAN_DIAG_SUPPORT 204 /** 205 * host_log_rsn_info() - This function is used to send 206 * requested rsn info in assoc request 207 * @ucast_cipher: Unicast ciphers used in assoc request 208 * @mcast_cipher: Group ciphers used in assoc request 209 * @auth_suite: Gives information about akm suites used in assoc request 210 * @gp_mgmt_cipher: Requested group mgmt cipher suite 211 * 212 * This function is used to send RSN info used in assoc req to user space 213 * 214 * Return: None 215 * 216 */ 217 void host_log_rsn_info(uint8_t *ucast_cipher, uint8_t *mcast_cipher, 218 uint8_t *auth_suite, uint8_t *gp_mgmt_cipher); 219 220 #else host_log_rsn_info(uint8_t * ucast_cipher,uint8_t * mcast_cipher,uint8_t * auth_suite,uint8_t * gp_mgmt_cipher)221 static inline void host_log_rsn_info(uint8_t *ucast_cipher, 222 uint8_t *mcast_cipher, 223 uint8_t *auth_suite, 224 uint8_t *gp_mgmt_cipher) 225 { 226 227 } 228 229 #endif /* FEATURE_WLAN_DIAG_SUPPORT */ 230 231 #ifdef FEATURE_WLAN_DIAG_SUPPORT 232 /** 233 * host_log_wlan_auth_info() - This function is used to send 234 * algo num, seq num and status code for auth request 235 * @auth_algo_num: Gives information about algo num used in auth request 236 * @auth_tx_seq_num: seq num of auth request 237 * @auth_status_code: status code of auth request 238 * 239 * This function is used to send send algo num, seq num and status code 240 * for auth request 241 * 242 * Return: None 243 * 244 */ 245 void 246 host_log_wlan_auth_info(uint16_t auth_algo_num, uint16_t auth_tx_seq_num, 247 uint16_t auth_status_code); 248 249 #else 250 static inline void host_log_wlan_auth_info(uint16_t auth_algo_num,uint16_t auth_tx_seq_num,uint16_t auth_status_code)251 host_log_wlan_auth_info(uint16_t auth_algo_num, uint16_t auth_tx_seq_num, 252 uint16_t auth_status_code) 253 { 254 } 255 256 #endif /* FEATURE_WLAN_DIAG_SUPPORT */ 257 258 #ifdef FEATURE_WLAN_DIAG_SUPPORT 259 void qdf_wow_wakeup_host_event(uint8_t wow_wakeup_cause); 260 261 /** 262 * host_log_acs_req_event() - ACS request event indication 263 * @intf: network interface name for WLAN 264 * @hw_mode: hw mode configured by hostapd 265 * @bw: channel bandwidth (MHz) 266 * @ht: a flag indicating whether HT phy mode is enabled 267 * @vht: a flag indicating whether VHT phy mode is enabled 268 * @chan_start: starting channel number for ACS scan 269 * @chan_end: ending channel number for ACS scan 270 * 271 * Indicates the diag event for ACS request with payload related 272 * to parameters populated by hostapd 273 * 274 * Return: None 275 */ 276 void host_log_acs_req_event(uint8_t *intf, const uint8_t *hw_mode, 277 uint16_t bw, uint8_t ht, uint8_t vht, 278 uint16_t chan_start, uint16_t chan_end); 279 280 /** 281 * host_log_acs_scan_start() - ACS scan start event indication 282 * @scan_id: scan request ID 283 * @vdev_id: vdev/session ID 284 * 285 * Indicates the diag event for ACS scan start request 286 * 287 * Return: None 288 */ 289 void host_log_acs_scan_start(uint32_t scan_id, uint8_t vdev_id); 290 291 /** 292 * host_log_acs_scan_done() - ACS scan done event indication 293 * @status: indicating whether ACS scan is successful 294 * @vdev_id: vdev/session ID 295 * @scan_id: scan request ID 296 * 297 * Indicates the diag event for ACS scan done 298 * 299 * Return: None 300 */ 301 void host_log_acs_scan_done(const uint8_t *status, uint8_t vdev_id, 302 uint32_t scan_id); 303 304 /** 305 * host_log_acs_chan_spect_weight() - ACS channel spectral weight indication 306 * weight event indication 307 * @chan: channel number 308 * @weight: channel weight 309 * @rssi: RSSI value obtained after scanning 310 * @bss_count: number of BSS detected on this channel 311 * 312 * Indicates a diag event for ACS channel weight evaluation result 313 * 314 * Return: None 315 */ 316 void host_log_acs_chan_spect_weight(uint16_t chan, uint16_t weight, 317 int32_t rssi, uint16_t bss_count); 318 319 /** 320 * host_log_acs_best_chan() - ACS best channel event indication 321 * @chan: channel number 322 * @weight: channel weight 323 * 324 * Indicates the best channel has been selected after ACS 325 * 326 * Return: None 327 */ 328 void host_log_acs_best_chan(uint16_t chan, uint16_t weight); 329 330 /** 331 * host_log_device_status() - device status indication 332 * @status_code: status code from enum wlan_bringup_status 333 * 334 * Indicates device status 335 * 336 * Return: None 337 */ 338 void host_log_device_status(uint16_t status_code); 339 340 #else qdf_wow_wakeup_host_event(uint8_t wow_wakeup_cause)341 static inline void qdf_wow_wakeup_host_event(uint8_t wow_wakeup_cause) 342 { 343 return; 344 } 345 host_log_acs_req_event(uint8_t * intf,const uint8_t * hw_mode,uint16_t bw,uint8_t ht,uint8_t vht,uint16_t chan_start,uint16_t chan_end)346 static inline void host_log_acs_req_event(uint8_t *intf, const uint8_t *hw_mode, 347 uint16_t bw, uint8_t ht, uint8_t vht, 348 uint16_t chan_start, 349 uint16_t chan_end) 350 { 351 } 352 host_log_acs_scan_start(uint32_t scan_id,uint8_t vdev_id)353 static inline void host_log_acs_scan_start(uint32_t scan_id, uint8_t vdev_id) 354 { 355 } 356 host_log_acs_scan_done(const uint8_t * status,uint8_t vdev_id,uint32_t scan_id)357 static inline void host_log_acs_scan_done(const uint8_t *status, 358 uint8_t vdev_id, uint32_t scan_id) 359 { 360 } 361 host_log_acs_chan_spect_weight(uint16_t chan,uint16_t weight,int32_t rssi,uint16_t bss_count)362 static inline void host_log_acs_chan_spect_weight(uint16_t chan, 363 uint16_t weight, int32_t rssi, 364 uint16_t bss_count) 365 { 366 } 367 host_log_acs_best_chan(uint16_t chan,uint32_t weight)368 static inline void host_log_acs_best_chan(uint16_t chan, uint32_t weight) 369 { 370 } 371 host_log_device_status(uint16_t status_code)372 static inline void host_log_device_status(uint16_t status_code) 373 { 374 } 375 #endif /* FEATURE_WLAN_DIAG_SUPPORT */ 376 #ifdef __cplusplus 377 } 378 #endif /* __cplusplus */ 379 #endif /* __I_HOST_DIAG_CORE_EVENT_H */ 380