1*4882a593Smuzhiyun /* 2*4882a593Smuzhiyun * EVENT_LOG system definitions 3*4882a593Smuzhiyun * 4*4882a593Smuzhiyun * Copyright (C) 2020, Broadcom. 5*4882a593Smuzhiyun * 6*4882a593Smuzhiyun * Unless you and Broadcom execute a separate written software license 7*4882a593Smuzhiyun * agreement governing use of this software, this software is licensed to you 8*4882a593Smuzhiyun * under the terms of the GNU General Public License version 2 (the "GPL"), 9*4882a593Smuzhiyun * available at http://www.broadcom.com/licenses/GPLv2.php, with the 10*4882a593Smuzhiyun * following added to such license: 11*4882a593Smuzhiyun * 12*4882a593Smuzhiyun * As a special exception, the copyright holders of this software give you 13*4882a593Smuzhiyun * permission to link this software with independent modules, and to copy and 14*4882a593Smuzhiyun * distribute the resulting executable under terms of your choice, provided that 15*4882a593Smuzhiyun * you also meet, for each linked independent module, the terms and conditions of 16*4882a593Smuzhiyun * the license of that module. An independent module is a module which is not 17*4882a593Smuzhiyun * derived from this software. The special exception does not apply to any 18*4882a593Smuzhiyun * modifications of the software. 19*4882a593Smuzhiyun * 20*4882a593Smuzhiyun * 21*4882a593Smuzhiyun * <<Broadcom-WL-IPTag/Dual:>> 22*4882a593Smuzhiyun */ 23*4882a593Smuzhiyun 24*4882a593Smuzhiyun #ifndef _EVENT_LOG_H_ 25*4882a593Smuzhiyun #define _EVENT_LOG_H_ 26*4882a593Smuzhiyun 27*4882a593Smuzhiyun #include <typedefs.h> 28*4882a593Smuzhiyun #include <event_log_set.h> 29*4882a593Smuzhiyun #include <event_log_tag.h> 30*4882a593Smuzhiyun #include <event_log_payload.h> 31*4882a593Smuzhiyun 32*4882a593Smuzhiyun /* logstrs header */ 33*4882a593Smuzhiyun #define LOGSTRS_MAGIC 0x4C4F4753 34*4882a593Smuzhiyun #define LOGSTRS_VERSION 0x1 35*4882a593Smuzhiyun 36*4882a593Smuzhiyun /* max log size */ 37*4882a593Smuzhiyun #define EVENT_LOG_MAX_SIZE (64u * 1024u) 38*4882a593Smuzhiyun 39*4882a593Smuzhiyun /* We make sure that the block size will fit in a single packet 40*4882a593Smuzhiyun * (allowing for a bit of overhead on each packet 41*4882a593Smuzhiyun */ 42*4882a593Smuzhiyun #if defined(BCMPCIEDEV) 43*4882a593Smuzhiyun #define EVENT_LOG_MAX_BLOCK_SIZE 1648 44*4882a593Smuzhiyun #else 45*4882a593Smuzhiyun #define EVENT_LOG_MAX_BLOCK_SIZE 1400 46*4882a593Smuzhiyun #endif 47*4882a593Smuzhiyun 48*4882a593Smuzhiyun #define EVENT_LOG_BLOCK_SIZE_1K 0x400u 49*4882a593Smuzhiyun #define EVENT_LOG_WL_BLOCK_SIZE 0x200 50*4882a593Smuzhiyun #define EVENT_LOG_PSM_BLOCK_SIZE 0x200 51*4882a593Smuzhiyun #define EVENT_LOG_MEM_API_BLOCK_SIZE 0x200 52*4882a593Smuzhiyun #define EVENT_LOG_BUS_BLOCK_SIZE 0x200 53*4882a593Smuzhiyun #define EVENT_LOG_ERROR_BLOCK_SIZE 0x400 54*4882a593Smuzhiyun #define EVENT_LOG_MSCH_BLOCK_SIZE 0x400 55*4882a593Smuzhiyun #define EVENT_LOG_WBUS_BLOCK_SIZE 0x100 56*4882a593Smuzhiyun #define EVENT_LOG_PRSV_PERIODIC_BLOCK_SIZE (0x200u) 57*4882a593Smuzhiyun 58*4882a593Smuzhiyun #define EVENT_LOG_WL_BUF_SIZE (EVENT_LOG_WL_BLOCK_SIZE * 3u) 59*4882a593Smuzhiyun 60*4882a593Smuzhiyun #define EVENT_LOG_TOF_INLINE_BLOCK_SIZE 1300u 61*4882a593Smuzhiyun #define EVENT_LOG_TOF_INLINE_BUF_SIZE (EVENT_LOG_TOF_INLINE_BLOCK_SIZE * 3u) 62*4882a593Smuzhiyun 63*4882a593Smuzhiyun #define EVENT_LOG_PRSRV_BUF_SIZE (EVENT_LOG_MAX_BLOCK_SIZE * 2) 64*4882a593Smuzhiyun #define EVENT_LOG_BUS_PRSRV_BUF_SIZE (EVENT_LOG_BUS_BLOCK_SIZE * 2) 65*4882a593Smuzhiyun #define EVENT_LOG_WBUS_PRSRV_BUF_SIZE (EVENT_LOG_WBUS_BLOCK_SIZE * 2) 66*4882a593Smuzhiyun 67*4882a593Smuzhiyun #define EVENT_LOG_BLOCK_SIZE_PRSRV_CHATTY (EVENT_LOG_MAX_BLOCK_SIZE * 1) 68*4882a593Smuzhiyun #define EVENT_LOG_BLOCK_SIZE_BUS_PRSRV_CHATTY (EVENT_LOG_MAX_BLOCK_SIZE * 1) 69*4882a593Smuzhiyun 70*4882a593Smuzhiyun /* Maximum event log record payload size = 1016 bytes or 254 words. */ 71*4882a593Smuzhiyun #define EVENT_LOG_MAX_RECORD_PAYLOAD_SIZE 254 72*4882a593Smuzhiyun 73*4882a593Smuzhiyun #define EVENT_LOG_EXT_HDR_IND (0x01) 74*4882a593Smuzhiyun #define EVENT_LOG_EXT_HDR_BIN_DATA_IND (0x01 << 1) 75*4882a593Smuzhiyun /* Format number to send binary data with extended event log header */ 76*4882a593Smuzhiyun #define EVENT_LOG_EXT_HDR_BIN_FMT_NUM (0x3FFE << 2) 77*4882a593Smuzhiyun 78*4882a593Smuzhiyun #define EVENT_LOGSET_ID_MASK 0x3F 79*4882a593Smuzhiyun /* For event_log_get iovar, set values from 240 to 255 mean special commands for a group of sets */ 80*4882a593Smuzhiyun #define EVENT_LOG_GET_IOV_CMD_MASK (0xF0u) 81*4882a593Smuzhiyun #define EVENT_LOG_GET_IOV_CMD_ID_MASK (0xFu) 82*4882a593Smuzhiyun #define EVENT_LOG_GET_IOV_CMD_ID_FORCE_FLUSH_PRSRV (0xEu) /* 240 + 14 = 254 */ 83*4882a593Smuzhiyun #define EVENT_LOG_GET_IOV_CMD_ID_FORCE_FLUSH_ALL (0xFu) /* 240 + 15 = 255 */ 84*4882a593Smuzhiyun 85*4882a593Smuzhiyun /* 86*4882a593Smuzhiyun * There are multiple levels of objects define here: 87*4882a593Smuzhiyun * event_log_set - a set of buffers 88*4882a593Smuzhiyun * event log groups - every event log call is part of just one. All 89*4882a593Smuzhiyun * event log calls in a group are handled the 90*4882a593Smuzhiyun * same way. Each event log group is associated 91*4882a593Smuzhiyun * with an event log set or is off. 92*4882a593Smuzhiyun */ 93*4882a593Smuzhiyun 94*4882a593Smuzhiyun #ifndef __ASSEMBLER__ 95*4882a593Smuzhiyun 96*4882a593Smuzhiyun /* On the external system where the dumper is we need to make sure 97*4882a593Smuzhiyun * that these types are the same size as they are on the ARM the 98*4882a593Smuzhiyun * produced them 99*4882a593Smuzhiyun */ 100*4882a593Smuzhiyun #ifdef EVENT_LOG_DUMPER 101*4882a593Smuzhiyun #define _EL_BLOCK_PTR uint32 102*4882a593Smuzhiyun #define _EL_TYPE_PTR uint32 103*4882a593Smuzhiyun #define _EL_SET_PTR uint32 104*4882a593Smuzhiyun #define _EL_TOP_PTR uint32 105*4882a593Smuzhiyun #else 106*4882a593Smuzhiyun #define _EL_BLOCK_PTR struct event_log_block * 107*4882a593Smuzhiyun #define _EL_TYPE_PTR uint32 * 108*4882a593Smuzhiyun #define _EL_SET_PTR struct event_log_set ** 109*4882a593Smuzhiyun #define _EL_TOP_PTR struct event_log_top * 110*4882a593Smuzhiyun #endif /* EVENT_LOG_DUMPER */ 111*4882a593Smuzhiyun 112*4882a593Smuzhiyun /* Event log sets (a logical circurlar buffer) consist of one or more 113*4882a593Smuzhiyun * event_log_blocks. The blocks themselves form a logical circular 114*4882a593Smuzhiyun * list. The log entries are placed in each event_log_block until it 115*4882a593Smuzhiyun * is full. Logging continues with the next event_log_block in the 116*4882a593Smuzhiyun * event_set until the last event_log_block is reached and then 117*4882a593Smuzhiyun * logging starts over with the first event_log_block in the 118*4882a593Smuzhiyun * event_set. 119*4882a593Smuzhiyun */ 120*4882a593Smuzhiyun typedef struct event_log_block { 121*4882a593Smuzhiyun _EL_BLOCK_PTR next_block; 122*4882a593Smuzhiyun _EL_BLOCK_PTR prev_block; 123*4882a593Smuzhiyun _EL_TYPE_PTR end_ptr; 124*4882a593Smuzhiyun 125*4882a593Smuzhiyun /* Start of packet sent for log tracing */ 126*4882a593Smuzhiyun uint16 pktlen; /* Size of rest of block */ 127*4882a593Smuzhiyun uint16 count; /* Logtrace counter */ 128*4882a593Smuzhiyun uint32 extra_hdr_info; /* LSB: 6 bits set id. MSB 24 bits reserved */ 129*4882a593Smuzhiyun uint32 event_logs; /* Pointer to BEGINNING of event logs */ 130*4882a593Smuzhiyun /* Event logs go here. Do not put extra fields below. */ 131*4882a593Smuzhiyun } event_log_block_t; 132*4882a593Smuzhiyun 133*4882a593Smuzhiyun /* Relative offset of extra_hdr_info field frpm pktlen field in log block */ 134*4882a593Smuzhiyun #define EVENT_LOG_BUF_EXTRA_HDR_INFO_REL_PKTLEN_OFFSET \ 135*4882a593Smuzhiyun (OFFSETOF(event_log_block_t, extra_hdr_info) - OFFSETOF(event_log_block_t, pktlen)) 136*4882a593Smuzhiyun 137*4882a593Smuzhiyun #define EVENT_LOG_SETID_MASK (0x3Fu) 138*4882a593Smuzhiyun 139*4882a593Smuzhiyun #define EVENT_LOG_BLOCK_HDRLEN (sizeof(((event_log_block_t *) 0)->pktlen) \ 140*4882a593Smuzhiyun + sizeof(((event_log_block_t *) 0)->count) \ 141*4882a593Smuzhiyun + sizeof(((event_log_block_t *) 0)->extra_hdr_info)) 142*4882a593Smuzhiyun #define EVENT_LOG_BLOCK_LEN (EVENT_LOG_BLOCK_HDRLEN + sizeof(event_log_hdr_t)) 143*4882a593Smuzhiyun 144*4882a593Smuzhiyun #define EVENT_LOG_PRESERVE_BLOCK (1 << 0) 145*4882a593Smuzhiyun #define EVENT_LOG_BLOCK_FLAG_MASK 0xff000000u 146*4882a593Smuzhiyun #define EVENT_LOG_BLOCK_FLAG_SHIFT 24u 147*4882a593Smuzhiyun 148*4882a593Smuzhiyun #define EVENT_LOG_BLOCK_GET_PREV_BLOCK(block) ((_EL_BLOCK_PTR)(((uint32)((block)->prev_block)) & \ 149*4882a593Smuzhiyun ~EVENT_LOG_BLOCK_FLAG_MASK)) 150*4882a593Smuzhiyun #define EVENT_LOG_BLOCK_SET_PREV_BLOCK(block, prev) ((block)->prev_block = \ 151*4882a593Smuzhiyun ((_EL_BLOCK_PTR)((((uint32)(block)->prev_block) & EVENT_LOG_BLOCK_FLAG_MASK) | \ 152*4882a593Smuzhiyun (((uint32)(prev)) & ~EVENT_LOG_BLOCK_FLAG_MASK)))) 153*4882a593Smuzhiyun #define EVENT_LOG_BLOCK_GET_FLAG(block) ((((uint32)(block)->prev_block) & \ 154*4882a593Smuzhiyun EVENT_LOG_BLOCK_FLAG_MASK) >> EVENT_LOG_BLOCK_FLAG_SHIFT) 155*4882a593Smuzhiyun #define EVENT_LOG_BLOCK_SET_FLAG(block, flag) ((block)->prev_block = \ 156*4882a593Smuzhiyun (_EL_BLOCK_PTR)(((uint32)EVENT_LOG_BLOCK_GET_PREV_BLOCK(block)) | flag)) 157*4882a593Smuzhiyun #define EVENT_LOG_BLOCK_OR_FLAG(block, flag) EVENT_LOG_BLOCK_SET_FLAG(block, \ 158*4882a593Smuzhiyun (EVENT_LOG_BLOCK_GET_FLAG(block) | flag) << EVENT_LOG_BLOCK_FLAG_SHIFT) 159*4882a593Smuzhiyun 160*4882a593Smuzhiyun typedef enum { 161*4882a593Smuzhiyun SET_DESTINATION_INVALID = -1, 162*4882a593Smuzhiyun SET_DESTINATION_HOST = 0, /* Eventlog buffer is sent out to host once filled. */ 163*4882a593Smuzhiyun SET_DESTINATION_NONE = 1, /* The buffer is not sent out, and it will be overwritten 164*4882a593Smuzhiyun * with new messages. 165*4882a593Smuzhiyun */ 166*4882a593Smuzhiyun SET_DESTINATION_FORCE_FLUSH_TO_HOST = 2, /* Buffers are sent to host once and then the 167*4882a593Smuzhiyun * value is reset back to SET_DESTINATION_NONE. 168*4882a593Smuzhiyun */ 169*4882a593Smuzhiyun SET_DESTINATION_FLUSH_ON_WATERMARK = 3, /* Buffers are sent to host when the watermark is 170*4882a593Smuzhiyun * reached, defined by the feature /chip 171*4882a593Smuzhiyun */ 172*4882a593Smuzhiyun SET_DESTINATION_MAX 173*4882a593Smuzhiyun } event_log_set_destination_t; 174*4882a593Smuzhiyun 175*4882a593Smuzhiyun /* sub destination for routing at the host */ 176*4882a593Smuzhiyun typedef enum { 177*4882a593Smuzhiyun SET_SUB_DESTINATION_0 = 0, 178*4882a593Smuzhiyun SET_SUB_DESTINATION_1 = 1, 179*4882a593Smuzhiyun SET_SUB_DESTINATION_2 = 2, 180*4882a593Smuzhiyun SET_SUB_DESTINATION_3 = 3, 181*4882a593Smuzhiyun SET_SUB_DESTINATION_DEFAULT = SET_SUB_DESTINATION_0 182*4882a593Smuzhiyun } event_log_set_sub_destination_t; 183*4882a593Smuzhiyun 184*4882a593Smuzhiyun /* There can be multiple event_sets with each logging a set of 185*4882a593Smuzhiyun * associated events (i.e, "fast" and "slow" events). 186*4882a593Smuzhiyun */ 187*4882a593Smuzhiyun typedef struct event_log_set { 188*4882a593Smuzhiyun _EL_BLOCK_PTR first_block; /* Pointer to first event_log block */ 189*4882a593Smuzhiyun _EL_BLOCK_PTR last_block; /* Pointer to last event_log block */ 190*4882a593Smuzhiyun _EL_BLOCK_PTR logtrace_block; /* next block traced */ 191*4882a593Smuzhiyun _EL_BLOCK_PTR cur_block; /* Pointer to current event_log block */ 192*4882a593Smuzhiyun _EL_TYPE_PTR cur_ptr; /* Current event_log pointer */ 193*4882a593Smuzhiyun uint32 blockcount; /* Number of blocks */ 194*4882a593Smuzhiyun uint16 logtrace_count; /* Last count for logtrace */ 195*4882a593Smuzhiyun uint16 blockfill_count; /* Fill count for logtrace */ 196*4882a593Smuzhiyun uint32 timestamp; /* Last timestamp event */ 197*4882a593Smuzhiyun uint32 cyclecount; /* Cycles at last timestamp event */ 198*4882a593Smuzhiyun event_log_set_destination_t destination; 199*4882a593Smuzhiyun uint16 size; /* same size for all buffers in one set */ 200*4882a593Smuzhiyun uint16 flags; 201*4882a593Smuzhiyun uint16 num_preserve_blocks; 202*4882a593Smuzhiyun event_log_set_sub_destination_t sub_destination; 203*4882a593Smuzhiyun uint16 water_mark; /* not used yet: threshold to flush host in percent */ 204*4882a593Smuzhiyun uint32 period; /* period to flush host in ms */ 205*4882a593Smuzhiyun uint32 last_rpt_ts; /* last time to flush in ms */ 206*4882a593Smuzhiyun } event_log_set_t; 207*4882a593Smuzhiyun 208*4882a593Smuzhiyun /* Definition of flags in set */ 209*4882a593Smuzhiyun #define EVENT_LOG_SET_SHRINK_ACTIVE (1 << 0) 210*4882a593Smuzhiyun #define EVENT_LOG_SET_CONFIG_PARTIAL_BLK_SEND (0x1 << 1) 211*4882a593Smuzhiyun #define EVENT_LOG_SET_CHECK_LOG_RATE (1 << 2) 212*4882a593Smuzhiyun #define EVENT_LOG_SET_PERIODIC (1 << 3) 213*4882a593Smuzhiyun #define EVENT_LOG_SET_D3PRSV (1 << 4) 214*4882a593Smuzhiyun 215*4882a593Smuzhiyun /* Top data structure for access to everything else */ 216*4882a593Smuzhiyun typedef struct event_log_top { 217*4882a593Smuzhiyun uint32 magic; 218*4882a593Smuzhiyun #define EVENT_LOG_TOP_MAGIC 0x474C8669 /* 'EVLG' */ 219*4882a593Smuzhiyun uint32 version; 220*4882a593Smuzhiyun #define EVENT_LOG_VERSION 1 221*4882a593Smuzhiyun uint32 num_sets; 222*4882a593Smuzhiyun uint32 logstrs_size; /* Size of lognums + logstrs area */ 223*4882a593Smuzhiyun uint32 timestamp; /* Last timestamp event */ 224*4882a593Smuzhiyun uint32 cyclecount; /* Cycles at last timestamp event */ 225*4882a593Smuzhiyun _EL_SET_PTR sets; /* Ptr to array of <num_sets> set ptrs */ 226*4882a593Smuzhiyun uint16 log_count; /* Number of event logs from last flush */ 227*4882a593Smuzhiyun uint16 rate_hc; /* Max number of prints per second */ 228*4882a593Smuzhiyun uint32 hc_timestamp; /* Timestamp of last hc window starting */ 229*4882a593Smuzhiyun bool cpu_freq_changed; /* Set to TRUE when CPU freq changed */ 230*4882a593Smuzhiyun bool hostmem_access_enabled; /* Is host memory access enabled for log delivery */ 231*4882a593Smuzhiyun bool event_trace_enabled; /* WLC_E_TRACE enabled/disabled */ 232*4882a593Smuzhiyun } event_log_top_t; 233*4882a593Smuzhiyun 234*4882a593Smuzhiyun /* structure of the trailing 3 words in logstrs.bin */ 235*4882a593Smuzhiyun typedef struct { 236*4882a593Smuzhiyun uint32 fw_id; /* FWID will be written by tool later */ 237*4882a593Smuzhiyun uint32 flags; /* 0th bit indicates whether encrypted or not */ 238*4882a593Smuzhiyun /* Keep version and magic last since "header" is appended to the end of logstrs file. */ 239*4882a593Smuzhiyun uint32 version; /* Header version */ 240*4882a593Smuzhiyun uint32 log_magic; /* MAGIC number for verification 'LOGS' */ 241*4882a593Smuzhiyun } logstr_trailer_t; 242*4882a593Smuzhiyun 243*4882a593Smuzhiyun /* Data structure of Keeping the Header from logstrs.bin */ 244*4882a593Smuzhiyun typedef struct { 245*4882a593Smuzhiyun uint32 logstrs_size; /* Size of the file */ 246*4882a593Smuzhiyun uint32 rom_lognums_offset; /* Offset to the ROM lognum */ 247*4882a593Smuzhiyun uint32 ram_lognums_offset; /* Offset to the RAM lognum */ 248*4882a593Smuzhiyun uint32 rom_logstrs_offset; /* Offset to the ROM logstr */ 249*4882a593Smuzhiyun uint32 ram_logstrs_offset; /* Offset to the RAM logstr */ 250*4882a593Smuzhiyun uint32 fw_id; /* FWID will be written by tool later */ 251*4882a593Smuzhiyun uint32 flags; /* 0th bit indicates whether encrypted or not */ 252*4882a593Smuzhiyun /* Keep version and magic last since "header" is appended to the end of logstrs file. */ 253*4882a593Smuzhiyun uint32 version; /* Header version */ 254*4882a593Smuzhiyun uint32 log_magic; /* MAGIC number for verification 'LOGS' */ 255*4882a593Smuzhiyun } logstr_header_t; 256*4882a593Smuzhiyun 257*4882a593Smuzhiyun /* Data structure of Keeping the Header from logstrs.bin */ 258*4882a593Smuzhiyun typedef struct { 259*4882a593Smuzhiyun uint32 logstrs_size; /* Size of the file */ 260*4882a593Smuzhiyun uint32 rom_lognums_offset; /* Offset to the ROM lognum */ 261*4882a593Smuzhiyun uint32 ram_lognums_offset; /* Offset to the RAM lognum */ 262*4882a593Smuzhiyun uint32 rom_logstrs_offset; /* Offset to the ROM logstr */ 263*4882a593Smuzhiyun uint32 ram_logstrs_offset; /* Offset to the RAM logstr */ 264*4882a593Smuzhiyun /* Keep version and magic last since "header" is appended to the end of logstrs file. */ 265*4882a593Smuzhiyun uint32 version; /* Header version */ 266*4882a593Smuzhiyun uint32 log_magic; /* MAGIC number for verification 'LOGS' */ 267*4882a593Smuzhiyun } logstr_header_v1_t; 268*4882a593Smuzhiyun 269*4882a593Smuzhiyun /* Event log configuration table */ 270*4882a593Smuzhiyun typedef struct evt_log_tag_entry { 271*4882a593Smuzhiyun uint16 tag; /* Tag value. */ 272*4882a593Smuzhiyun uint8 set; /* Set number. */ 273*4882a593Smuzhiyun uint8 refcnt; /* Ref_count if sdc is used */ 274*4882a593Smuzhiyun } evt_log_tag_entry_t; 275*4882a593Smuzhiyun 276*4882a593Smuzhiyun #ifdef BCMDRIVER 277*4882a593Smuzhiyun /* !!! The following section is for kernel mode code only !!! */ 278*4882a593Smuzhiyun #include <osl_decl.h> 279*4882a593Smuzhiyun 280*4882a593Smuzhiyun extern bool d3_preserve_enab; 281*4882a593Smuzhiyun #if defined(ROM_ENAB_RUNTIME_CHECK) 282*4882a593Smuzhiyun #define D3_PRESERVE_ENAB() (d3_preserve_enab) 283*4882a593Smuzhiyun #elif defined(EVENTLOG_D3_PRESERVE_DISABLED) 284*4882a593Smuzhiyun #define D3_PRESERVE_ENAB() (0) 285*4882a593Smuzhiyun #else 286*4882a593Smuzhiyun #define D3_PRESERVE_ENAB() (1) 287*4882a593Smuzhiyun #endif 288*4882a593Smuzhiyun 289*4882a593Smuzhiyun #if defined(EVENTLOG_PRSV_PERIODIC) 290*4882a593Smuzhiyun extern bool prsv_periodic_enab; 291*4882a593Smuzhiyun #if defined(ROM_ENAB_RUNTIME_CHECK) 292*4882a593Smuzhiyun #define PRSV_PRD_ENAB() (prsv_periodic_enab) 293*4882a593Smuzhiyun #elif defined(EVENTLOG_PRSV_PERIODIC_DISABLED) 294*4882a593Smuzhiyun #define PRSV_PRD_ENAB() (0) 295*4882a593Smuzhiyun #else 296*4882a593Smuzhiyun #define PRSV_PRD_ENAB() (1) 297*4882a593Smuzhiyun #endif 298*4882a593Smuzhiyun #endif /* EVENTLOG_PRSV_PERIODIC */ 299*4882a593Smuzhiyun 300*4882a593Smuzhiyun /* 301*4882a593Smuzhiyun * Use the following macros for generating log events. 302*4882a593Smuzhiyun * 303*4882a593Smuzhiyun * The FAST versions check the enable of the tag before evaluating the arguments and calling the 304*4882a593Smuzhiyun * event_log function. This adds 5 instructions. The COMPACT versions evaluate the arguments 305*4882a593Smuzhiyun * and call the event_log function unconditionally. The event_log function will then skip logging 306*4882a593Smuzhiyun * if this tag is disabled. 307*4882a593Smuzhiyun * 308*4882a593Smuzhiyun * To support easy usage of existing debugging (e.g. msglevel) via macro re-definition there are 309*4882a593Smuzhiyun * two variants of these macros to help. 310*4882a593Smuzhiyun * 311*4882a593Smuzhiyun * First there are the CAST versions. The event_log function normally logs uint32 values or else 312*4882a593Smuzhiyun * they have to be cast to uint32. The CAST versions blindly cast for you so you don't have to edit 313*4882a593Smuzhiyun * any existing code. 314*4882a593Smuzhiyun * 315*4882a593Smuzhiyun * Second there are the PAREN_ARGS versions. These expect the logging format string and arguments 316*4882a593Smuzhiyun * to be enclosed in parentheses. This allows us to make the following mapping of an existing 317*4882a593Smuzhiyun * msglevel macro: 318*4882a593Smuzhiyun * #define WL_ERROR(args) EVENT_LOG_CAST_PAREN_ARGS(EVENT_LOG_TAG_WL_ERROR, args) 319*4882a593Smuzhiyun * 320*4882a593Smuzhiyun * The versions of the macros without FAST or COMPACT in their name are just synonyms for the 321*4882a593Smuzhiyun * COMPACT versions. 322*4882a593Smuzhiyun * 323*4882a593Smuzhiyun * You should use the COMPACT macro (or its synonym) in cases where there is some preceding logic 324*4882a593Smuzhiyun * that prevents the execution of the macro, e.g. WL_ERROR by definition rarely gets executed. 325*4882a593Smuzhiyun * Use the FAST macro in performance sensitive paths. The key concept here is that you should be 326*4882a593Smuzhiyun * assuming that your macro usage is compiled into ROM and can't be changed ... so choose wisely. 327*4882a593Smuzhiyun * 328*4882a593Smuzhiyun */ 329*4882a593Smuzhiyun 330*4882a593Smuzhiyun #if !defined(EVENT_LOG_DUMPER) && !defined(DHD_EFI) 331*4882a593Smuzhiyun 332*4882a593Smuzhiyun #ifndef EVENT_LOG_COMPILE 333*4882a593Smuzhiyun 334*4882a593Smuzhiyun /* Null define if no tracing */ 335*4882a593Smuzhiyun #define EVENT_LOG(tag, fmt, ...) 336*4882a593Smuzhiyun #define EVENT_LOG_FAST(tag, fmt, ...) 337*4882a593Smuzhiyun #define EVENT_LOG_COMPACT(tag, fmt, ...) 338*4882a593Smuzhiyun 339*4882a593Smuzhiyun #define EVENT_LOG_CAST(tag, fmt, ...) 340*4882a593Smuzhiyun #define EVENT_LOG_FAST_CAST(tag, fmt, ...) 341*4882a593Smuzhiyun #define EVENT_LOG_COMPACT_CAST(tag, fmt, ...) 342*4882a593Smuzhiyun 343*4882a593Smuzhiyun #define EVENT_LOG_CAST_PAREN_ARGS(tag, pargs) 344*4882a593Smuzhiyun #define EVENT_LOG_FAST_CAST_PAREN_ARGS(tag, pargs) 345*4882a593Smuzhiyun #define EVENT_LOG_COMPACT_CAST_PAREN_ARGS(tag, pargs) 346*4882a593Smuzhiyun 347*4882a593Smuzhiyun #define EVENT_LOG_IF_READY(tag, fmt, ...) 348*4882a593Smuzhiyun #define EVENT_LOG_IS_ON(tag) 0 349*4882a593Smuzhiyun #define EVENT_LOG_IS_LOG_ON(tag) 0 350*4882a593Smuzhiyun 351*4882a593Smuzhiyun #define EVENT_LOG_BUFFER(tag, buf, size) 352*4882a593Smuzhiyun #define EVENT_LOG_PRSRV_FLUSH() 353*4882a593Smuzhiyun #define EVENT_LOG_FORCE_FLUSH_ALL() 354*4882a593Smuzhiyun #define EVENT_LOG_FORCE_FLUSH_PRSRV_LOG_ALL() 355*4882a593Smuzhiyun 356*4882a593Smuzhiyun #else /* EVENT_LOG_COMPILE */ 357*4882a593Smuzhiyun 358*4882a593Smuzhiyun /* The first few _EVENT_LOGX() macros are special because they can be done more 359*4882a593Smuzhiyun * efficiently this way and they are the common case. Once there are too many 360*4882a593Smuzhiyun * parameters the code size starts to be an issue and a loop is better 361*4882a593Smuzhiyun * The trailing arguments to the _EVENT_LOGX() macros are the format string, 'fmt', 362*4882a593Smuzhiyun * followed by the variable parameters for the format. The format string is not 363*4882a593Smuzhiyun * needed in the event_logX() replacement text, so fmt is dropped in all cases. 364*4882a593Smuzhiyun */ 365*4882a593Smuzhiyun #define _EVENT_LOG0(tag, fmt_num, fmt) \ 366*4882a593Smuzhiyun event_log0(tag, fmt_num) 367*4882a593Smuzhiyun #define _EVENT_LOG1(tag, fmt_num, fmt, t1) \ 368*4882a593Smuzhiyun event_log1(tag, fmt_num, t1) 369*4882a593Smuzhiyun #define _EVENT_LOG2(tag, fmt_num, fmt, t1, t2) \ 370*4882a593Smuzhiyun event_log2(tag, fmt_num, t1, t2) 371*4882a593Smuzhiyun #define _EVENT_LOG3(tag, fmt_num, fmt, t1, t2, t3) \ 372*4882a593Smuzhiyun event_log3(tag, fmt_num, t1, t2, t3) 373*4882a593Smuzhiyun #define _EVENT_LOG4(tag, fmt_num, fmt, t1, t2, t3, t4) \ 374*4882a593Smuzhiyun event_log4(tag, fmt_num, t1, t2, t3, t4) 375*4882a593Smuzhiyun 376*4882a593Smuzhiyun /* The rest call the generic routine that takes a count */ 377*4882a593Smuzhiyun #define _EVENT_LOG5(tag, fmt_num, fmt, ...) event_logn(5, tag, fmt_num, __VA_ARGS__) 378*4882a593Smuzhiyun #define _EVENT_LOG6(tag, fmt_num, fmt, ...) event_logn(6, tag, fmt_num, __VA_ARGS__) 379*4882a593Smuzhiyun #define _EVENT_LOG7(tag, fmt_num, fmt, ...) event_logn(7, tag, fmt_num, __VA_ARGS__) 380*4882a593Smuzhiyun #define _EVENT_LOG8(tag, fmt_num, fmt, ...) event_logn(8, tag, fmt_num, __VA_ARGS__) 381*4882a593Smuzhiyun #define _EVENT_LOG9(tag, fmt_num, fmt, ...) event_logn(9, tag, fmt_num, __VA_ARGS__) 382*4882a593Smuzhiyun #define _EVENT_LOGA(tag, fmt_num, fmt, ...) event_logn(10, tag, fmt_num, __VA_ARGS__) 383*4882a593Smuzhiyun #define _EVENT_LOGB(tag, fmt_num, fmt, ...) event_logn(11, tag, fmt_num, __VA_ARGS__) 384*4882a593Smuzhiyun #define _EVENT_LOGC(tag, fmt_num, fmt, ...) event_logn(12, tag, fmt_num, __VA_ARGS__) 385*4882a593Smuzhiyun #define _EVENT_LOGD(tag, fmt_num, fmt, ...) event_logn(13, tag, fmt_num, __VA_ARGS__) 386*4882a593Smuzhiyun #define _EVENT_LOGE(tag, fmt_num, fmt, ...) event_logn(14, tag, fmt_num, __VA_ARGS__) 387*4882a593Smuzhiyun #define _EVENT_LOGF(tag, fmt_num, fmt, ...) event_logn(15, tag, fmt_num, __VA_ARGS__) 388*4882a593Smuzhiyun 389*4882a593Smuzhiyun /* Casting low level macros */ 390*4882a593Smuzhiyun #define _EVENT_LOG_CAST0(tag, fmt_num, fmt) \ 391*4882a593Smuzhiyun event_log0(tag, fmt_num) 392*4882a593Smuzhiyun #define _EVENT_LOG_CAST1(tag, fmt_num, fmt, t1) \ 393*4882a593Smuzhiyun event_log1(tag, fmt_num, (uint32)(t1)) 394*4882a593Smuzhiyun #define _EVENT_LOG_CAST2(tag, fmt_num, fmt, t1, t2) \ 395*4882a593Smuzhiyun event_log2(tag, fmt_num, (uint32)(t1), (uint32)(t2)) 396*4882a593Smuzhiyun #define _EVENT_LOG_CAST3(tag, fmt_num, fmt, t1, t2, t3) \ 397*4882a593Smuzhiyun event_log3(tag, fmt_num, (uint32)(t1), (uint32)(t2), (uint32)(t3)) 398*4882a593Smuzhiyun #define _EVENT_LOG_CAST4(tag, fmt_num, fmt, t1, t2, t3, t4) \ 399*4882a593Smuzhiyun event_log4(tag, fmt_num, (uint32)(t1), (uint32)(t2), (uint32)(t3), (uint32)(t4)) 400*4882a593Smuzhiyun 401*4882a593Smuzhiyun /* The rest call the generic routine that takes a count */ 402*4882a593Smuzhiyun #define _EVENT_LOG_CAST5(tag, fmt_num, ...) _EVENT_LOG5(tag, fmt_num, __VA_ARGS__) 403*4882a593Smuzhiyun #define _EVENT_LOG_CAST6(tag, fmt_num, ...) _EVENT_LOG6(tag, fmt_num, __VA_ARGS__) 404*4882a593Smuzhiyun #define _EVENT_LOG_CAST7(tag, fmt_num, ...) _EVENT_LOG7(tag, fmt_num, __VA_ARGS__) 405*4882a593Smuzhiyun #define _EVENT_LOG_CAST8(tag, fmt_num, ...) _EVENT_LOG8(tag, fmt_num, __VA_ARGS__) 406*4882a593Smuzhiyun #define _EVENT_LOG_CAST9(tag, fmt_num, ...) _EVENT_LOG9(tag, fmt_num, __VA_ARGS__) 407*4882a593Smuzhiyun #define _EVENT_LOG_CASTA(tag, fmt_num, ...) _EVENT_LOGA(tag, fmt_num, __VA_ARGS__) 408*4882a593Smuzhiyun #define _EVENT_LOG_CASTB(tag, fmt_num, ...) _EVENT_LOGB(tag, fmt_num, __VA_ARGS__) 409*4882a593Smuzhiyun #define _EVENT_LOG_CASTC(tag, fmt_num, ...) _EVENT_LOGC(tag, fmt_num, __VA_ARGS__) 410*4882a593Smuzhiyun #define _EVENT_LOG_CASTD(tag, fmt_num, ...) _EVENT_LOGD(tag, fmt_num, __VA_ARGS__) 411*4882a593Smuzhiyun #define _EVENT_LOG_CASTE(tag, fmt_num, ...) _EVENT_LOGE(tag, fmt_num, __VA_ARGS__) 412*4882a593Smuzhiyun #define _EVENT_LOG_CASTF(tag, fmt_num, ...) _EVENT_LOGF(tag, fmt_num, __VA_ARGS__) 413*4882a593Smuzhiyun 414*4882a593Smuzhiyun /* Hack to make the proper routine call when variadic macros get 415*4882a593Smuzhiyun * passed. Note the max of 15 arguments. More than that can't be 416*4882a593Smuzhiyun * handled by the event_log entries anyways so best to catch it at compile 417*4882a593Smuzhiyun * time 418*4882a593Smuzhiyun * 419*4882a593Smuzhiyun * Here is what happens with this macro: when _EVENT_LOG expands this macro, 420*4882a593Smuzhiyun * its __VA_ARGS__ argument is expanded. If __VA_ARGS__ contains only ONE 421*4882a593Smuzhiyun * argument, for example, then F maps to _1, E maps to _2, and so on, so that 422*4882a593Smuzhiyun * N maps to 0, and the macro expands to BASE ## N or BASE ## 0 which is 423*4882a593Smuzhiyun * EVENT_LOG0. If __VA_ARGS__ contains two arguments, then everything is 424*4882a593Smuzhiyun * shifted down by one, because the second argument in __VA_ARGS__ now maps 425*4882a593Smuzhiyun * to _1, so F maps to _2, E maps to _3, and so on, and 1 (instead of 0) maps 426*4882a593Smuzhiyun * to N, and this macro expands to become _EVENT_LOG1. This continues all 427*4882a593Smuzhiyun * the way up until __VA_ARGS__ has 15 arguments, in which case, stuff in 428*4882a593Smuzhiyun * __VA_ARGS__ maps to all of the values _1 through _F, which makes F (in' 429*4882a593Smuzhiyun * the _EVENT_LOG macro) map to N, and this macro then expands to EVENT_LOGF. 430*4882a593Smuzhiyun */ 431*4882a593Smuzhiyun 432*4882a593Smuzhiyun #define _EVENT_LOG_VA_NUM_ARGS(BASE, _FMT, _1, _2, _3, _4, _5, _6, _7, _8, _9, \ 433*4882a593Smuzhiyun _A, _B, _C, _D, _E, _F, N, ...) BASE ## N 434*4882a593Smuzhiyun 435*4882a593Smuzhiyun /* Take a variable number of args and replace with only the first */ 436*4882a593Smuzhiyun #define FIRST_ARG(a1, ...) a1 437*4882a593Smuzhiyun 438*4882a593Smuzhiyun /* base = _EVENT_LOG for no casting 439*4882a593Smuzhiyun * base = _EVENT_LOG_CAST for casting of fmt arguments to uint32. 440*4882a593Smuzhiyun * Only first 4 arguments are cast to uint32. event_logn() is called 441*4882a593Smuzhiyun * if more than 4 arguments are present. This function internally assumes 442*4882a593Smuzhiyun * all arguments are uint32 443*4882a593Smuzhiyun * 444*4882a593Smuzhiyun * The variable args in this call are the format string followed by the variable 445*4882a593Smuzhiyun * parameters for the format. E.g. 446*4882a593Smuzhiyun * 447*4882a593Smuzhiyun * __VA_ARGS__ = "answer: %d", 42 448*4882a593Smuzhiyun * 449*4882a593Smuzhiyun * This means __VA_ARGS__ always has one or more arguments. Guaranteeing a non-empty 450*4882a593Smuzhiyun * __VA_ARGS__ means the special use of " , ## __VA_ARGS__" is not required to deal 451*4882a593Smuzhiyun * with a dangling comma --- the comma will always be followed with at leaset the format 452*4882a593Smuzhiyun * string. The use of ## caused issues when the format args contained a function like 453*4882a593Smuzhiyun * macro that expanded to more than one arg. The ## prevented macro expansion, so the 454*4882a593Smuzhiyun * _EVENT_LOG_VA_NUM_ARGS() calculation of the number of args was incorrect. 455*4882a593Smuzhiyun * Without the ##, the __VA_ARGS__ are macro replaced, and the num args calculation is 456*4882a593Smuzhiyun * accurate. 457*4882a593Smuzhiyun * 458*4882a593Smuzhiyun * This macro is setup so that if __VA_ARGS__ is as short as possible, then the "0" will 459*4882a593Smuzhiyun * map to "N" in the _EVENT_LOG_VA_NUM_ARGS macro, and that macro then expands to become 460*4882a593Smuzhiyun * _EVENT_LOG0. As __VA_ARGS__ gets longer, then the item that gets mapped to "N" gets 461*4882a593Smuzhiyun * pushed further and further up, so that by the time __VA_ARGS__ has 15 additional 462*4882a593Smuzhiyun * arguments, then "F" maps to "N" in the _EVENT_LOG_VA_NUM_ARGS macro. 463*4882a593Smuzhiyun */ 464*4882a593Smuzhiyun #define _EVENT_LOG(base, tag, ...) \ 465*4882a593Smuzhiyun static char logstr[] __attribute__ ((section(".logstrs"))) = FIRST_ARG(__VA_ARGS__); \ 466*4882a593Smuzhiyun static uint32 fmtnum __attribute__ ((section(".lognums"))) = (uint32) &logstr; \ 467*4882a593Smuzhiyun _EVENT_LOG_VA_NUM_ARGS(base, __VA_ARGS__, \ 468*4882a593Smuzhiyun F, E, D, C, B, A, 9, 8, \ 469*4882a593Smuzhiyun 7, 6, 5, 4, 3, 2, 1, 0) \ 470*4882a593Smuzhiyun (tag, (int) &fmtnum, __VA_ARGS__) 471*4882a593Smuzhiyun 472*4882a593Smuzhiyun #define EVENT_LOG_FAST(tag, ...) \ 473*4882a593Smuzhiyun do { \ 474*4882a593Smuzhiyun if (event_log_tag_sets != NULL) { \ 475*4882a593Smuzhiyun uint8 tag_flag = *(event_log_tag_sets + tag); \ 476*4882a593Smuzhiyun if ((tag_flag & ~EVENT_LOG_TAG_FLAG_SET_MASK) != 0) { \ 477*4882a593Smuzhiyun _EVENT_LOG(_EVENT_LOG, tag, __VA_ARGS__); \ 478*4882a593Smuzhiyun } \ 479*4882a593Smuzhiyun } \ 480*4882a593Smuzhiyun } while (0) 481*4882a593Smuzhiyun 482*4882a593Smuzhiyun #define EVENT_LOG_COMPACT(tag, ...) \ 483*4882a593Smuzhiyun do { \ 484*4882a593Smuzhiyun _EVENT_LOG(_EVENT_LOG, tag, __VA_ARGS__); \ 485*4882a593Smuzhiyun } while (0) 486*4882a593Smuzhiyun 487*4882a593Smuzhiyun /* Event log macro with casting to uint32 of arguments */ 488*4882a593Smuzhiyun #define EVENT_LOG_FAST_CAST(tag, ...) \ 489*4882a593Smuzhiyun do { \ 490*4882a593Smuzhiyun if (event_log_tag_sets != NULL) { \ 491*4882a593Smuzhiyun uint8 tag_flag = *(event_log_tag_sets + tag); \ 492*4882a593Smuzhiyun if ((tag_flag & ~EVENT_LOG_TAG_FLAG_SET_MASK) != 0) { \ 493*4882a593Smuzhiyun _EVENT_LOG(_EVENT_LOG_CAST, tag, __VA_ARGS__); \ 494*4882a593Smuzhiyun } \ 495*4882a593Smuzhiyun } \ 496*4882a593Smuzhiyun } while (0) 497*4882a593Smuzhiyun 498*4882a593Smuzhiyun #define EVENT_LOG_COMPACT_CAST(tag, ...) \ 499*4882a593Smuzhiyun do { \ 500*4882a593Smuzhiyun _EVENT_LOG(_EVENT_LOG_CAST, tag, __VA_ARGS__); \ 501*4882a593Smuzhiyun } while (0) 502*4882a593Smuzhiyun 503*4882a593Smuzhiyun #define EVENT_LOG(tag, ...) EVENT_LOG_COMPACT(tag, __VA_ARGS__) 504*4882a593Smuzhiyun 505*4882a593Smuzhiyun #define EVENT_LOG_CAST(tag, ...) EVENT_LOG_COMPACT_CAST(tag, __VA_ARGS__) 506*4882a593Smuzhiyun 507*4882a593Smuzhiyun #define _EVENT_LOG_REMOVE_PAREN(...) __VA_ARGS__ 508*4882a593Smuzhiyun #define EVENT_LOG_REMOVE_PAREN(args) _EVENT_LOG_REMOVE_PAREN args 509*4882a593Smuzhiyun 510*4882a593Smuzhiyun #define EVENT_LOG_CAST_PAREN_ARGS(tag, pargs) \ 511*4882a593Smuzhiyun EVENT_LOG_CAST(tag, EVENT_LOG_REMOVE_PAREN(pargs)) 512*4882a593Smuzhiyun 513*4882a593Smuzhiyun #define EVENT_LOG_FAST_CAST_PAREN_ARGS(tag, pargs) \ 514*4882a593Smuzhiyun EVENT_LOG_FAST_CAST(tag, EVENT_LOG_REMOVE_PAREN(pargs)) 515*4882a593Smuzhiyun 516*4882a593Smuzhiyun #define EVENT_LOG_COMPACT_CAST_PAREN_ARGS(tag, pargs) \ 517*4882a593Smuzhiyun EVENT_LOG_COMPACT_CAST(tag, EVENT_LOG_REMOVE_PAREN(pargs)) 518*4882a593Smuzhiyun 519*4882a593Smuzhiyun /* Minimal event logging. Event log internally calls event_logx() 520*4882a593Smuzhiyun * log return address in caller. 521*4882a593Smuzhiyun * Note that the if(0){..} below is to avoid compiler warnings 522*4882a593Smuzhiyun * due to unused variables caused by this macro 523*4882a593Smuzhiyun */ 524*4882a593Smuzhiyun #define EVENT_LOG_RA(tag, args) \ 525*4882a593Smuzhiyun do { \ 526*4882a593Smuzhiyun if (0) { \ 527*4882a593Smuzhiyun EVENT_LOG_COMPACT_CAST_PAREN_ARGS(tag, args); \ 528*4882a593Smuzhiyun } \ 529*4882a593Smuzhiyun event_log_caller_return_address(tag); \ 530*4882a593Smuzhiyun } while (0) 531*4882a593Smuzhiyun 532*4882a593Smuzhiyun #define EVENT_LOG_IF_READY(_tag, ...) \ 533*4882a593Smuzhiyun do { \ 534*4882a593Smuzhiyun if (event_log_is_ready()) { \ 535*4882a593Smuzhiyun EVENT_LOG(_tag, __VA_ARGS__); \ 536*4882a593Smuzhiyun } \ 537*4882a593Smuzhiyun } \ 538*4882a593Smuzhiyun while (0) 539*4882a593Smuzhiyun 540*4882a593Smuzhiyun #define EVENT_LOG_IS_ON(tag) (*(event_log_tag_sets + (tag)) & ~EVENT_LOG_TAG_FLAG_SET_MASK) 541*4882a593Smuzhiyun #define EVENT_LOG_IS_LOG_ON(tag) (*(event_log_tag_sets + (tag)) & EVENT_LOG_TAG_FLAG_LOG) 542*4882a593Smuzhiyun 543*4882a593Smuzhiyun #define EVENT_LOG_BUFFER(tag, buf, size) event_log_buffer(tag, buf, size) 544*4882a593Smuzhiyun #define EVENT_DUMP event_log_buffer 545*4882a593Smuzhiyun 546*4882a593Smuzhiyun /* EVENT_LOG_PRSRV_FLUSH() will be deprecated. Use EVENT_LOG_FORCE_FLUSH_ALL instead */ 547*4882a593Smuzhiyun #define EVENT_LOG_PRSRV_FLUSH() event_log_force_flush_all() 548*4882a593Smuzhiyun #define EVENT_LOG_FORCE_FLUSH_ALL() event_log_force_flush_all() 549*4882a593Smuzhiyun 550*4882a593Smuzhiyun #ifdef PRESERVE_LOG 551*4882a593Smuzhiyun #define EVENT_LOG_FORCE_FLUSH_PRSRV_LOG_ALL() event_log_force_flush_preserve_all() 552*4882a593Smuzhiyun #else 553*4882a593Smuzhiyun #define EVENT_LOG_FORCE_FLUSH_PRSRV_LOG_ALL() 554*4882a593Smuzhiyun #endif /* PRESERVE_LOG */ 555*4882a593Smuzhiyun 556*4882a593Smuzhiyun extern uint8 *event_log_tag_sets; 557*4882a593Smuzhiyun 558*4882a593Smuzhiyun extern int event_log_init(osl_t *osh); 559*4882a593Smuzhiyun extern int event_log_set_init(osl_t *osh, int set_num, int size); 560*4882a593Smuzhiyun extern int event_log_set_expand(osl_t *osh, int set_num, int size); 561*4882a593Smuzhiyun extern int event_log_set_shrink(osl_t *osh, int set_num, int size); 562*4882a593Smuzhiyun 563*4882a593Smuzhiyun extern int event_log_tag_start(int tag, int set_num, int flags); 564*4882a593Smuzhiyun extern int event_log_tag_set_retrieve(int tag); 565*4882a593Smuzhiyun extern int event_log_tag_flags_retrieve(int tag); 566*4882a593Smuzhiyun extern int event_log_tag_stop(int tag); 567*4882a593Smuzhiyun 568*4882a593Smuzhiyun typedef void (*event_log_logtrace_trigger_fn_t)(void *ctx); 569*4882a593Smuzhiyun void event_log_set_logtrace_trigger_fn(event_log_logtrace_trigger_fn_t fn, void *ctx); 570*4882a593Smuzhiyun 571*4882a593Smuzhiyun event_log_top_t *event_log_get_top(void); 572*4882a593Smuzhiyun 573*4882a593Smuzhiyun extern int event_log_get(int set_num, int buflen, void *buf); 574*4882a593Smuzhiyun 575*4882a593Smuzhiyun extern uint8 *event_log_next_logtrace(int set_num); 576*4882a593Smuzhiyun extern uint32 event_log_logtrace_max_buf_count(int set_num); 577*4882a593Smuzhiyun extern int event_log_set_type(int set_num, uint8 *type, int is_get); 578*4882a593Smuzhiyun extern int event_log_flush_set(wl_el_set_flush_prsrv_t *flush, int is_set); 579*4882a593Smuzhiyun 580*4882a593Smuzhiyun extern void event_log0(int tag, int fmtNum); 581*4882a593Smuzhiyun extern void event_log1(int tag, int fmtNum, uint32 t1); 582*4882a593Smuzhiyun extern void event_log2(int tag, int fmtNum, uint32 t1, uint32 t2); 583*4882a593Smuzhiyun extern void event_log3(int tag, int fmtNum, uint32 t1, uint32 t2, uint32 t3); 584*4882a593Smuzhiyun extern void event_log4(int tag, int fmtNum, uint32 t1, uint32 t2, uint32 t3, uint32 t4); 585*4882a593Smuzhiyun extern void event_logn(int num_args, int tag, int fmtNum, ...); 586*4882a593Smuzhiyun #ifdef ROM_COMPAT_MSCH_PROFILER 587*4882a593Smuzhiyun /* For compatibility with ROM, for old msch event log function to pass parameters in stack */ 588*4882a593Smuzhiyun extern void event_logv(int num_args, int tag, int fmtNum, va_list ap); 589*4882a593Smuzhiyun #endif /* ROM_COMPAT_MSCH_PROFILER */ 590*4882a593Smuzhiyun 591*4882a593Smuzhiyun extern void event_log_time_sync(uint32 ms); 592*4882a593Smuzhiyun extern bool event_log_time_sync_required(void); 593*4882a593Smuzhiyun extern void event_log_cpu_freq_changed(void); 594*4882a593Smuzhiyun extern void event_log_buffer(int tag, const uint8 *buf, int size); 595*4882a593Smuzhiyun extern void event_log_caller_return_address(int tag); 596*4882a593Smuzhiyun extern int event_log_set_destination_set(int set, event_log_set_destination_t dest); 597*4882a593Smuzhiyun extern event_log_set_destination_t event_log_set_destination_get(int set); 598*4882a593Smuzhiyun extern int event_log_set_sub_destination_set(uint set, event_log_set_sub_destination_t dest); 599*4882a593Smuzhiyun extern event_log_set_sub_destination_t event_log_set_sub_destination_get(uint set); 600*4882a593Smuzhiyun extern int event_log_flush_log_buffer(int set); 601*4882a593Smuzhiyun extern int event_log_force_flush_all(void); 602*4882a593Smuzhiyun extern int event_log_force_flush(int set); 603*4882a593Smuzhiyun 604*4882a593Smuzhiyun extern uint16 event_log_get_available_space(int set); 605*4882a593Smuzhiyun extern bool event_log_is_tag_valid(int tag); 606*4882a593Smuzhiyun /* returns number of blocks available for writing */ 607*4882a593Smuzhiyun extern int event_log_free_blocks_get(int set); 608*4882a593Smuzhiyun extern bool event_log_is_ready(void); 609*4882a593Smuzhiyun extern bool event_log_is_preserve_active(uint set); 610*4882a593Smuzhiyun extern uint event_log_get_percentage_available_space(uint set); 611*4882a593Smuzhiyun extern bool event_log_set_watermark_reached(int set_num); 612*4882a593Smuzhiyun 613*4882a593Smuzhiyun extern void event_log_set_config(int set, uint32 period, uint16 watermark, uint32 config_flags); 614*4882a593Smuzhiyun #ifdef EVENTLOG_D3_PRESERVE 615*4882a593Smuzhiyun #define EVENT_LOG_PRESERVE_EXPAND_SIZE 5u 616*4882a593Smuzhiyun extern int event_log_preserve_set_shrink(osl_t *osh, int set_num); 617*4882a593Smuzhiyun extern void event_log_d3_preserve_active_set(osl_t* osh, int set, bool active); 618*4882a593Smuzhiyun extern void event_log_d3_prsv_set_all(osl_t *osh, bool active); 619*4882a593Smuzhiyun #endif /* EVENTLOG_D3_PRESERVE */ 620*4882a593Smuzhiyun 621*4882a593Smuzhiyun #ifdef EVENTLOG_PRSV_PERIODIC 622*4882a593Smuzhiyun #define EVENT_LOG_SET_SIZE_INVALID 0xFFFFFFFFu 623*4882a593Smuzhiyun #define EVENT_LOG_DEFAULT_PERIOD 3000u 624*4882a593Smuzhiyun extern void event_log_prsv_periodic_wd_trigger(osl_t *osh); 625*4882a593Smuzhiyun #endif /* EVENTLOG_PRSV_PERIODIC */ 626*4882a593Smuzhiyun 627*4882a593Smuzhiyun /* Enable/disable rate health check for a set */ 628*4882a593Smuzhiyun #ifdef EVENT_LOG_RATE_HC 629*4882a593Smuzhiyun extern int event_log_enable_hc_for_set(int set_num, bool enable); 630*4882a593Smuzhiyun extern void event_log_set_hc_rate(uint16 num_prints); 631*4882a593Smuzhiyun extern uint16 event_log_get_hc_rate(void); 632*4882a593Smuzhiyun #endif /* EVENT_LOG_RATE_HC */ 633*4882a593Smuzhiyun 634*4882a593Smuzhiyun /* Configure a set with ability to send partial log blocks */ 635*4882a593Smuzhiyun extern int event_log_send_partial_block_set(int set_num); 636*4882a593Smuzhiyun 637*4882a593Smuzhiyun /* Get number of log blocks associated to a log set */ 638*4882a593Smuzhiyun extern int event_log_num_blocks_get(int set, uint32 *num_blocks); 639*4882a593Smuzhiyun 640*4882a593Smuzhiyun /* Get a log buffer of a desired set */ 641*4882a593Smuzhiyun extern int event_log_block_get(int set, uint32 **buf, uint16 *len); 642*4882a593Smuzhiyun extern uint32 event_log_get_maxsets(void); 643*4882a593Smuzhiyun 644*4882a593Smuzhiyun /* For all other non-logtrace consumers */ 645*4882a593Smuzhiyun extern int event_log_set_is_valid(int set); 646*4882a593Smuzhiyun 647*4882a593Smuzhiyun /* To be used by logtrace only */ 648*4882a593Smuzhiyun extern int event_log_get_num_sets(void); 649*4882a593Smuzhiyun 650*4882a593Smuzhiyun /* Given a buffer, return to which set it belongs to */ 651*4882a593Smuzhiyun extern int event_log_get_set_for_buffer(const void *buf); 652*4882a593Smuzhiyun 653*4882a593Smuzhiyun extern int event_log_flush_multiple_sets(const int *sets, uint16 num_sets); 654*4882a593Smuzhiyun extern int event_log_force_flush_preserve_all(void); 655*4882a593Smuzhiyun extern int event_log_get_iovar_handler(int set); 656*4882a593Smuzhiyun extern int event_log_enable_hostmem_access(bool hostmem_access_enabled); 657*4882a593Smuzhiyun extern int event_log_enable_event_trace(bool event_trace_enabled); 658*4882a593Smuzhiyun #endif /* EVENT_LOG_COMPILE */ 659*4882a593Smuzhiyun 660*4882a593Smuzhiyun #endif /* !EVENT_LOG_DUMPER && !DHD_EFI */ 661*4882a593Smuzhiyun 662*4882a593Smuzhiyun #endif /* BCMDRIVER */ 663*4882a593Smuzhiyun 664*4882a593Smuzhiyun #endif /* __ASSEMBLER__ */ 665*4882a593Smuzhiyun 666*4882a593Smuzhiyun #endif /* _EVENT_LOG_H_ */ 667