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