1 /* 2 * Copyright (c) 2014-2018 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_LOG_H) 21 #define __I_HOST_DIAG_CORE_LOG_H 22 23 #include <log_codes.h> 24 25 /**========================================================================= 26 27 \file i_host_diag_core_event.h 28 29 \brief android-specific definitions for WLAN UTIL DIAG logs 30 31 ========================================================================*/ 32 33 /* $Header$ */ 34 35 /*-------------------------------------------------------------------------- 36 Include Files 37 ------------------------------------------------------------------------*/ 38 #include <qdf_types.h> 39 #include <qdf_mem.h> 40 41 /*-------------------------------------------------------------------------- 42 Preprocessor definitions and constants 43 ------------------------------------------------------------------------*/ 44 /* FIXME To be removed when DIAG support is added. This definition should be */ 45 /* picked from log.h file above. */ 46 typedef struct { 47 /* Specifies the length, in bytes of the entry, including this header. */ 48 uint16_t len; 49 50 /* Specifies the log code for the entry */ 51 uint16_t code; 52 53 /*Time Stamp lo */ 54 uint32_t ts_lo; 55 56 /*Time Stamp hi */ 57 uint32_t ts_hi; 58 } __packed log_hdr_type; 59 60 #ifdef __cplusplus 61 extern "C" { 62 #endif /* __cplusplus */ 63 64 #ifdef FEATURE_WLAN_DIAG_SUPPORT 65 void host_diag_log_set_code(void *ptr, uint16_t code); 66 void host_diag_log_set_length(void *ptr, uint16_t length); 67 void host_diag_log_set_timestamp(void *plog_hdr_ptr); 68 void host_diag_log_submit(void *plog_hdr_ptr); 69 70 /*--------------------------------------------------------------------------- 71 Allocate an event payload holder 72 ---------------------------------------------------------------------------*/ 73 74 #define WLAN_HOST_DIAG_LOG_ALLOC(payload_ptr, payload_type, log_code) \ 75 do { \ 76 payload_ptr = (payload_type *)qdf_mem_malloc(sizeof(payload_type)); \ 77 if (payload_ptr) { \ 78 host_diag_log_set_code(payload_ptr, log_code); \ 79 host_diag_log_set_length(payload_ptr, sizeof(payload_type)); \ 80 } \ 81 } while (0) 82 83 /*--------------------------------------------------------------------------- 84 Report the event 85 ---------------------------------------------------------------------------*/ 86 #define WLAN_HOST_DIAG_LOG_REPORT(payload_ptr) \ 87 do { \ 88 if (payload_ptr) { \ 89 host_diag_log_submit(payload_ptr); \ 90 qdf_mem_free(payload_ptr); \ 91 } \ 92 } while (0) 93 94 /*--------------------------------------------------------------------------- 95 Free the payload 96 ---------------------------------------------------------------------------*/ 97 #define WLAN_HOST_DIAG_LOG_FREE(payload_ptr) \ 98 do { \ 99 if (payload_ptr) { \ 100 qdf_mem_free(payload_ptr); \ 101 } \ 102 } while (0) 103 104 #else /* FEATURE_WLAN_DIAG_SUPPORT */ 105 106 #define WLAN_HOST_DIAG_LOG_ALLOC(payload_ptr, payload_type, log_code) 107 #define WLAN_HOST_DIAG_LOG_REPORT(payload_ptr) 108 #define WLAN_HOST_DIAG_LOG_FREE(payload_ptr) 109 110 static inline void host_diag_log_set_code(void *ptr, uint16_t code) 111 { 112 } 113 114 static inline void host_diag_log_set_length(void *ptr, uint16_t length) 115 { 116 } 117 #endif /* FEATURE_WLAN_DIAG_SUPPORT */ 118 119 /*------------------------------------------------------------------------- 120 Function declarations and documentation 121 ------------------------------------------------------------------------*/ 122 123 #ifdef __cplusplus 124 } 125 #endif /* __cplusplus */ 126 #endif /* __I_HOST_DIAG_CORE_LOG_H */ 127