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