| .. | .. |
|---|
| 1 | | -/* SPDX-License-Identifier: GPL-2.0 */ |
|---|
| 2 | 1 | /* |
|---|
| 3 | 2 | * EVENT_LOG system definitions |
|---|
| 4 | 3 | * |
|---|
| 5 | | - * Copyright (C) 1999-2019, Broadcom Corporation |
|---|
| 6 | | - * |
|---|
| 4 | + * Portions of this code are copyright (c) 2022 Cypress Semiconductor Corporation |
|---|
| 5 | + * |
|---|
| 6 | + * Copyright (C) 1999-2017, Broadcom Corporation |
|---|
| 7 | + * |
|---|
| 7 | 8 | * Unless you and Broadcom execute a separate written software license |
|---|
| 8 | 9 | * agreement governing use of this software, this software is licensed to you |
|---|
| 9 | 10 | * under the terms of the GNU General Public License version 2 (the "GPL"), |
|---|
| 10 | 11 | * available at http://www.broadcom.com/licenses/GPLv2.php, with the |
|---|
| 11 | 12 | * following added to such license: |
|---|
| 12 | | - * |
|---|
| 13 | + * |
|---|
| 13 | 14 | * As a special exception, the copyright holders of this software give you |
|---|
| 14 | 15 | * permission to link this software with independent modules, and to copy and |
|---|
| 15 | 16 | * distribute the resulting executable under terms of your choice, provided that |
|---|
| .. | .. |
|---|
| 17 | 18 | * the license of that module. An independent module is a module which is not |
|---|
| 18 | 19 | * derived from this software. The special exception does not apply to any |
|---|
| 19 | 20 | * modifications of the software. |
|---|
| 20 | | - * |
|---|
| 21 | + * |
|---|
| 21 | 22 | * Notwithstanding the above, under no circumstances may you combine this |
|---|
| 22 | 23 | * software in any way with any other Broadcom software provided under a license |
|---|
| 23 | 24 | * other than the GPL, without Broadcom's express prior written consent. |
|---|
| .. | .. |
|---|
| 25 | 26 | * |
|---|
| 26 | 27 | * <<Broadcom-WL-IPTag/Open:>> |
|---|
| 27 | 28 | * |
|---|
| 28 | | - * $Id: event_log.h 241182 2011-02-17 21:50:03Z $ |
|---|
| 29 | + * $Id: event_log.h 692339 2017-03-27 17:04:27Z $ |
|---|
| 29 | 30 | */ |
|---|
| 30 | 31 | |
|---|
| 31 | 32 | #ifndef _EVENT_LOG_H_ |
|---|
| 32 | 33 | #define _EVENT_LOG_H_ |
|---|
| 33 | 34 | |
|---|
| 34 | 35 | #include <typedefs.h> |
|---|
| 35 | | -#include <proto/event_log_set.h> |
|---|
| 36 | | -#include <proto/event_log_tag.h> |
|---|
| 36 | +#include <event_log_set.h> |
|---|
| 37 | +#include <event_log_tag.h> |
|---|
| 38 | +#include <event_log_payload.h> |
|---|
| 39 | +#include <osl_decl.h> |
|---|
| 37 | 40 | |
|---|
| 38 | 41 | /* logstrs header */ |
|---|
| 39 | 42 | #define LOGSTRS_MAGIC 0x4C4F4753 |
|---|
| .. | .. |
|---|
| 42 | 45 | /* We make sure that the block size will fit in a single packet |
|---|
| 43 | 46 | * (allowing for a bit of overhead on each packet |
|---|
| 44 | 47 | */ |
|---|
| 48 | +#if defined(BCMPCIEDEV) |
|---|
| 49 | +#define EVENT_LOG_MAX_BLOCK_SIZE 1648 |
|---|
| 50 | +#else |
|---|
| 45 | 51 | #define EVENT_LOG_MAX_BLOCK_SIZE 1400 |
|---|
| 52 | +#endif // endif |
|---|
| 46 | 53 | #define EVENT_LOG_WL_BLOCK_SIZE 0x200 |
|---|
| 47 | 54 | #define EVENT_LOG_PSM_BLOCK_SIZE 0x200 |
|---|
| 48 | 55 | #define EVENT_LOG_BUS_BLOCK_SIZE 0x200 |
|---|
| 49 | 56 | #define EVENT_LOG_ERROR_BLOCK_SIZE 0x200 |
|---|
| 57 | +/* Maximum event log record payload size = 1016 bytes or 254 words. */ |
|---|
| 58 | +#define EVENT_LOG_MAX_RECORD_PAYLOAD_SIZE 254 |
|---|
| 50 | 59 | |
|---|
| 51 | 60 | /* |
|---|
| 52 | 61 | * There are multiple levels of objects define here: |
|---|
| .. | .. |
|---|
| 91 | 100 | /* Start of packet sent for log tracing */ |
|---|
| 92 | 101 | uint16 pktlen; /* Size of rest of block */ |
|---|
| 93 | 102 | uint16 count; /* Logtrace counter */ |
|---|
| 94 | | - uint32 timestamp; /* Timestamp at start of use */ |
|---|
| 103 | + uint32 extra_hdr_info; /* LSB: 6 bits set id. MSB 24 bits reserved */ |
|---|
| 95 | 104 | uint32 event_logs; |
|---|
| 96 | 105 | } event_log_block_t; |
|---|
| 106 | +#define EVENT_LOG_BLOCK_HDRLEN 8 /* pktlen 2 + count 2 + extra_hdr_info 4 */ |
|---|
| 107 | + |
|---|
| 108 | +#define EVENT_LOG_BLOCK_LEN 12 |
|---|
| 109 | + |
|---|
| 110 | +typedef enum { |
|---|
| 111 | + SET_DESTINATION_INVALID = -1, |
|---|
| 112 | + SET_DESTINATION_HOST = 0, |
|---|
| 113 | + SET_DESTINATION_NONE = 1, |
|---|
| 114 | + SET_DESTINATION_MAX |
|---|
| 115 | +} event_log_set_destination_t; |
|---|
| 97 | 116 | |
|---|
| 98 | 117 | /* There can be multiple event_sets with each logging a set of |
|---|
| 99 | 118 | * associated events (i.e, "fast" and "slow" events). |
|---|
| .. | .. |
|---|
| 109 | 128 | uint16 blockfill_count; /* Fill count for logtrace */ |
|---|
| 110 | 129 | uint32 timestamp; /* Last timestamp event */ |
|---|
| 111 | 130 | uint32 cyclecount; /* Cycles at last timestamp event */ |
|---|
| 131 | + event_log_set_destination_t destination; |
|---|
| 132 | + uint16 size; /* same size for all buffers in one set */ |
|---|
| 112 | 133 | } event_log_set_t; |
|---|
| 134 | + |
|---|
| 135 | +/* logstr_hdr_flags */ |
|---|
| 136 | +#define LOGSTRS_ENCRYPTED 0x1 |
|---|
| 113 | 137 | |
|---|
| 114 | 138 | /* Top data structure for access to everything else */ |
|---|
| 115 | 139 | typedef struct event_log_top { |
|---|
| .. | .. |
|---|
| 121 | 145 | uint32 logstrs_size; /* Size of lognums + logstrs area */ |
|---|
| 122 | 146 | uint32 timestamp; /* Last timestamp event */ |
|---|
| 123 | 147 | uint32 cyclecount; /* Cycles at last timestamp event */ |
|---|
| 124 | | - _EL_SET_PTR sets; /* Ptr to array of <num_sets> set ptrs */ |
|---|
| 148 | + _EL_SET_PTR sets; /* Ptr to array of <num_sets> set ptrs */ |
|---|
| 125 | 149 | } event_log_top_t; |
|---|
| 126 | 150 | |
|---|
| 151 | +/* structure of the trailing 3 words in logstrs.bin */ |
|---|
| 152 | +typedef struct { |
|---|
| 153 | + uint32 fw_id; /* FWID will be written by tool later */ |
|---|
| 154 | + uint32 flags; /* 0th bit indicates whether encrypted or not */ |
|---|
| 155 | + /* Keep version and magic last since "header" is appended to the end of logstrs file. */ |
|---|
| 156 | + uint32 version; /* Header version */ |
|---|
| 157 | + uint32 log_magic; /* MAGIC number for verification 'LOGS' */ |
|---|
| 158 | +} logstr_trailer_t; |
|---|
| 159 | + |
|---|
| 127 | 160 | /* Data structure of Keeping the Header from logstrs.bin */ |
|---|
| 161 | +typedef struct { |
|---|
| 162 | + uint32 logstrs_size; /* Size of the file */ |
|---|
| 163 | + uint32 rom_lognums_offset; /* Offset to the ROM lognum */ |
|---|
| 164 | + uint32 ram_lognums_offset; /* Offset to the RAM lognum */ |
|---|
| 165 | + uint32 rom_logstrs_offset; /* Offset to the ROM logstr */ |
|---|
| 166 | + uint32 ram_logstrs_offset; /* Offset to the RAM logstr */ |
|---|
| 167 | + logstr_trailer_t trailer; |
|---|
| 168 | +} logstr_header_t; |
|---|
| 169 | + |
|---|
| 170 | +/* Ver 1 Header from logstrs.bin */ |
|---|
| 128 | 171 | typedef struct { |
|---|
| 129 | 172 | uint32 logstrs_size; /* Size of the file */ |
|---|
| 130 | 173 | uint32 rom_lognums_offset; /* Offset to the ROM lognum */ |
|---|
| .. | .. |
|---|
| 134 | 177 | /* Keep version and magic last since "header" is appended to the end of logstrs file. */ |
|---|
| 135 | 178 | uint32 version; /* Header version */ |
|---|
| 136 | 179 | uint32 log_magic; /* MAGIC number for verification 'LOGS' */ |
|---|
| 137 | | -} logstr_header_t; |
|---|
| 180 | +} logstr_header_v1_t; |
|---|
| 138 | 181 | |
|---|
| 139 | 182 | /* |
|---|
| 140 | 183 | * Use the following macros for generating log events. |
|---|
| .. | .. |
|---|
| 166 | 209 | * |
|---|
| 167 | 210 | */ |
|---|
| 168 | 211 | |
|---|
| 169 | | -#ifndef EVENT_LOG_DUMPER |
|---|
| 212 | +#if !defined(EVENT_LOG_DUMPER) |
|---|
| 170 | 213 | |
|---|
| 171 | 214 | #ifndef EVENT_LOG_COMPILE |
|---|
| 172 | 215 | |
|---|
| .. | .. |
|---|
| 183 | 226 | #define EVENT_LOG_FAST_CAST_PAREN_ARGS(tag, pargs) |
|---|
| 184 | 227 | #define EVENT_LOG_COMPACT_CAST_PAREN_ARGS(tag, pargs) |
|---|
| 185 | 228 | |
|---|
| 229 | +#define EVENT_LOG_IS_ON(tag) 0 |
|---|
| 186 | 230 | #define EVENT_LOG_IS_LOG_ON(tag) 0 |
|---|
| 231 | + |
|---|
| 232 | +#define EVENT_LOG_BUFFER(tag, buf, size) |
|---|
| 187 | 233 | |
|---|
| 188 | 234 | #else /* EVENT_LOG_COMPILE */ |
|---|
| 189 | 235 | |
|---|
| .. | .. |
|---|
| 214 | 260 | #define _EVENT_LOGD(tag, fmt_num, ...) event_logn(13, tag, fmt_num, __VA_ARGS__) |
|---|
| 215 | 261 | #define _EVENT_LOGE(tag, fmt_num, ...) event_logn(14, tag, fmt_num, __VA_ARGS__) |
|---|
| 216 | 262 | #define _EVENT_LOGF(tag, fmt_num, ...) event_logn(15, tag, fmt_num, __VA_ARGS__) |
|---|
| 217 | | - |
|---|
| 218 | 263 | |
|---|
| 219 | 264 | /* Casting low level macros */ |
|---|
| 220 | 265 | #define _EVENT_LOG_CAST0(tag, fmt_num) \ |
|---|
| .. | .. |
|---|
| 264 | 309 | 7, 6, 5, 4, 3, 2, 1, 0) \ |
|---|
| 265 | 310 | (tag, (int) &fmtnum , ## __VA_ARGS__) |
|---|
| 266 | 311 | |
|---|
| 267 | | - |
|---|
| 268 | 312 | #define EVENT_LOG_FAST(tag, fmt, ...) \ |
|---|
| 269 | 313 | do { \ |
|---|
| 270 | 314 | if (event_log_tag_sets != NULL) { \ |
|---|
| 271 | 315 | uint8 tag_flag = *(event_log_tag_sets + tag); \ |
|---|
| 272 | | - if (tag_flag != 0) { \ |
|---|
| 316 | + if ((tag_flag & ~EVENT_LOG_TAG_FLAG_SET_MASK) != 0) { \ |
|---|
| 273 | 317 | _EVENT_LOG(_EVENT_LOG, tag, fmt , ## __VA_ARGS__); \ |
|---|
| 274 | 318 | } \ |
|---|
| 275 | 319 | } \ |
|---|
| .. | .. |
|---|
| 285 | 329 | do { \ |
|---|
| 286 | 330 | if (event_log_tag_sets != NULL) { \ |
|---|
| 287 | 331 | uint8 tag_flag = *(event_log_tag_sets + tag); \ |
|---|
| 288 | | - if (tag_flag != 0) { \ |
|---|
| 332 | + if ((tag_flag & ~EVENT_LOG_TAG_FLAG_SET_MASK) != 0) { \ |
|---|
| 289 | 333 | _EVENT_LOG(_EVENT_LOG_CAST, tag, fmt , ## __VA_ARGS__); \ |
|---|
| 290 | 334 | } \ |
|---|
| 291 | 335 | } \ |
|---|
| .. | .. |
|---|
| 295 | 339 | do { \ |
|---|
| 296 | 340 | _EVENT_LOG(_EVENT_LOG_CAST, tag, fmt , ## __VA_ARGS__); \ |
|---|
| 297 | 341 | } while (0) |
|---|
| 298 | | - |
|---|
| 299 | 342 | |
|---|
| 300 | 343 | #define EVENT_LOG(tag, fmt, ...) EVENT_LOG_COMPACT(tag, fmt , ## __VA_ARGS__) |
|---|
| 301 | 344 | |
|---|
| .. | .. |
|---|
| 313 | 356 | #define EVENT_LOG_COMPACT_CAST_PAREN_ARGS(tag, pargs) \ |
|---|
| 314 | 357 | EVENT_LOG_COMPACT_CAST(tag, EVENT_LOG_REMOVE_PAREN(pargs)) |
|---|
| 315 | 358 | |
|---|
| 359 | +/* Minimal event logging. Event log internally calls event_logx() |
|---|
| 360 | + * log return address in caller. |
|---|
| 361 | + * Note that the if(0){..} below is to avoid compiler warnings |
|---|
| 362 | + * due to unused variables caused by this macro |
|---|
| 363 | + */ |
|---|
| 364 | +#define EVENT_LOG_RA(tag, args) \ |
|---|
| 365 | + do { \ |
|---|
| 366 | + if (0) { \ |
|---|
| 367 | + EVENT_LOG_COMPACT_CAST_PAREN_ARGS(tag, args); \ |
|---|
| 368 | + } \ |
|---|
| 369 | + event_log_caller_return_address(tag); \ |
|---|
| 370 | + } while (0) |
|---|
| 316 | 371 | |
|---|
| 372 | +#define EVENT_LOG_IS_ON(tag) (*(event_log_tag_sets + (tag)) & ~EVENT_LOG_TAG_FLAG_SET_MASK) |
|---|
| 317 | 373 | #define EVENT_LOG_IS_LOG_ON(tag) (*(event_log_tag_sets + (tag)) & EVENT_LOG_TAG_FLAG_LOG) |
|---|
| 318 | 374 | |
|---|
| 375 | +#define EVENT_LOG_BUFFER(tag, buf, size) event_log_buffer(tag, buf, size) |
|---|
| 319 | 376 | #define EVENT_DUMP event_log_buffer |
|---|
| 320 | 377 | |
|---|
| 321 | 378 | extern uint8 *event_log_tag_sets; |
|---|
| 322 | 379 | |
|---|
| 323 | | -#include <siutils.h> |
|---|
| 380 | +extern int event_log_init(osl_t *osh); |
|---|
| 381 | +extern int event_log_set_init(osl_t *osh, int set_num, int size); |
|---|
| 382 | +extern int event_log_set_expand(osl_t *osh, int set_num, int size); |
|---|
| 383 | +extern int event_log_set_shrink(osl_t *osh, int set_num, int size); |
|---|
| 324 | 384 | |
|---|
| 325 | | -extern int event_log_init(si_t *sih); |
|---|
| 326 | | -extern int event_log_set_init(si_t *sih, int set_num, int size); |
|---|
| 327 | | -extern int event_log_set_expand(si_t *sih, int set_num, int size); |
|---|
| 328 | | -extern int event_log_set_shrink(si_t *sih, int set_num, int size); |
|---|
| 329 | 385 | extern int event_log_tag_start(int tag, int set_num, int flags); |
|---|
| 386 | +extern int event_log_tag_set_retrieve(int tag); |
|---|
| 330 | 387 | extern int event_log_tag_stop(int tag); |
|---|
| 388 | + |
|---|
| 389 | +typedef void (*event_log_logtrace_trigger_fn_t)(void *ctx); |
|---|
| 390 | +void event_log_set_logtrace_trigger_fn(event_log_logtrace_trigger_fn_t fn, void *ctx); |
|---|
| 391 | + |
|---|
| 392 | +event_log_top_t *event_log_get_top(void); |
|---|
| 393 | + |
|---|
| 331 | 394 | extern int event_log_get(int set_num, int buflen, void *buf); |
|---|
| 332 | | -extern uint8 * event_log_next_logtrace(int set_num); |
|---|
| 395 | + |
|---|
| 396 | +extern uint8 *event_log_next_logtrace(int set_num); |
|---|
| 333 | 397 | |
|---|
| 334 | 398 | extern void event_log0(int tag, int fmtNum); |
|---|
| 335 | 399 | extern void event_log1(int tag, int fmtNum, uint32 t1); |
|---|
| .. | .. |
|---|
| 340 | 404 | |
|---|
| 341 | 405 | extern void event_log_time_sync(uint32 ms); |
|---|
| 342 | 406 | extern void event_log_buffer(int tag, uint8 *buf, int size); |
|---|
| 407 | +extern void event_log_caller_return_address(int tag); |
|---|
| 408 | +extern int event_log_set_destination_set(int set, event_log_set_destination_t dest); |
|---|
| 409 | +extern event_log_set_destination_t event_log_set_destination_get(int set); |
|---|
| 410 | +extern int event_log_flush_log_buffer(int set); |
|---|
| 411 | +extern uint16 event_log_get_available_space(int set); |
|---|
| 412 | +extern bool event_log_is_set_configured(int set_num); |
|---|
| 413 | +extern bool event_log_is_tag_valid(int tag); |
|---|
| 414 | +/* returns number of blocks available for writing */ |
|---|
| 415 | +extern int event_log_free_blocks_get(int set); |
|---|
| 416 | +extern bool event_log_is_ready(void); |
|---|
| 343 | 417 | |
|---|
| 344 | 418 | #endif /* EVENT_LOG_DUMPER */ |
|---|
| 345 | 419 | |
|---|
| .. | .. |
|---|
| 347 | 421 | |
|---|
| 348 | 422 | #endif /* __ASSEMBLER__ */ |
|---|
| 349 | 423 | |
|---|
| 350 | | -#endif /* _EVENT_LOG_H */ |
|---|
| 424 | +#endif /* _EVENT_LOG_H_ */ |
|---|