forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-02-19 1c055e55a242a33e574e48be530e06770a210dcd
kernel/drivers/net/wireless/rockchip_wlan/cywdhd/bcmdhd/include/event_log.h
....@@ -1,15 +1,16 @@
1
-/* SPDX-License-Identifier: GPL-2.0 */
21 /*
32 * EVENT_LOG system definitions
43 *
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
+ *
78 * Unless you and Broadcom execute a separate written software license
89 * agreement governing use of this software, this software is licensed to you
910 * under the terms of the GNU General Public License version 2 (the "GPL"),
1011 * available at http://www.broadcom.com/licenses/GPLv2.php, with the
1112 * following added to such license:
12
- *
13
+ *
1314 * As a special exception, the copyright holders of this software give you
1415 * permission to link this software with independent modules, and to copy and
1516 * distribute the resulting executable under terms of your choice, provided that
....@@ -17,7 +18,7 @@
1718 * the license of that module. An independent module is a module which is not
1819 * derived from this software. The special exception does not apply to any
1920 * modifications of the software.
20
- *
21
+ *
2122 * Notwithstanding the above, under no circumstances may you combine this
2223 * software in any way with any other Broadcom software provided under a license
2324 * other than the GPL, without Broadcom's express prior written consent.
....@@ -25,15 +26,17 @@
2526 *
2627 * <<Broadcom-WL-IPTag/Open:>>
2728 *
28
- * $Id: event_log.h 241182 2011-02-17 21:50:03Z $
29
+ * $Id: event_log.h 692339 2017-03-27 17:04:27Z $
2930 */
3031
3132 #ifndef _EVENT_LOG_H_
3233 #define _EVENT_LOG_H_
3334
3435 #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>
3740
3841 /* logstrs header */
3942 #define LOGSTRS_MAGIC 0x4C4F4753
....@@ -42,11 +45,17 @@
4245 /* We make sure that the block size will fit in a single packet
4346 * (allowing for a bit of overhead on each packet
4447 */
48
+#if defined(BCMPCIEDEV)
49
+#define EVENT_LOG_MAX_BLOCK_SIZE 1648
50
+#else
4551 #define EVENT_LOG_MAX_BLOCK_SIZE 1400
52
+#endif // endif
4653 #define EVENT_LOG_WL_BLOCK_SIZE 0x200
4754 #define EVENT_LOG_PSM_BLOCK_SIZE 0x200
4855 #define EVENT_LOG_BUS_BLOCK_SIZE 0x200
4956 #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
5059
5160 /*
5261 * There are multiple levels of objects define here:
....@@ -91,9 +100,19 @@
91100 /* Start of packet sent for log tracing */
92101 uint16 pktlen; /* Size of rest of block */
93102 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 */
95104 uint32 event_logs;
96105 } 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;
97116
98117 /* There can be multiple event_sets with each logging a set of
99118 * associated events (i.e, "fast" and "slow" events).
....@@ -109,7 +128,12 @@
109128 uint16 blockfill_count; /* Fill count for logtrace */
110129 uint32 timestamp; /* Last timestamp event */
111130 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 */
112133 } event_log_set_t;
134
+
135
+/* logstr_hdr_flags */
136
+#define LOGSTRS_ENCRYPTED 0x1
113137
114138 /* Top data structure for access to everything else */
115139 typedef struct event_log_top {
....@@ -121,10 +145,29 @@
121145 uint32 logstrs_size; /* Size of lognums + logstrs area */
122146 uint32 timestamp; /* Last timestamp event */
123147 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 */
125149 } event_log_top_t;
126150
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
+
127160 /* 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 */
128171 typedef struct {
129172 uint32 logstrs_size; /* Size of the file */
130173 uint32 rom_lognums_offset; /* Offset to the ROM lognum */
....@@ -134,7 +177,7 @@
134177 /* Keep version and magic last since "header" is appended to the end of logstrs file. */
135178 uint32 version; /* Header version */
136179 uint32 log_magic; /* MAGIC number for verification 'LOGS' */
137
-} logstr_header_t;
180
+} logstr_header_v1_t;
138181
139182 /*
140183 * Use the following macros for generating log events.
....@@ -166,7 +209,7 @@
166209 *
167210 */
168211
169
-#ifndef EVENT_LOG_DUMPER
212
+#if !defined(EVENT_LOG_DUMPER)
170213
171214 #ifndef EVENT_LOG_COMPILE
172215
....@@ -183,7 +226,10 @@
183226 #define EVENT_LOG_FAST_CAST_PAREN_ARGS(tag, pargs)
184227 #define EVENT_LOG_COMPACT_CAST_PAREN_ARGS(tag, pargs)
185228
229
+#define EVENT_LOG_IS_ON(tag) 0
186230 #define EVENT_LOG_IS_LOG_ON(tag) 0
231
+
232
+#define EVENT_LOG_BUFFER(tag, buf, size)
187233
188234 #else /* EVENT_LOG_COMPILE */
189235
....@@ -214,7 +260,6 @@
214260 #define _EVENT_LOGD(tag, fmt_num, ...) event_logn(13, tag, fmt_num, __VA_ARGS__)
215261 #define _EVENT_LOGE(tag, fmt_num, ...) event_logn(14, tag, fmt_num, __VA_ARGS__)
216262 #define _EVENT_LOGF(tag, fmt_num, ...) event_logn(15, tag, fmt_num, __VA_ARGS__)
217
-
218263
219264 /* Casting low level macros */
220265 #define _EVENT_LOG_CAST0(tag, fmt_num) \
....@@ -264,12 +309,11 @@
264309 7, 6, 5, 4, 3, 2, 1, 0) \
265310 (tag, (int) &fmtnum , ## __VA_ARGS__)
266311
267
-
268312 #define EVENT_LOG_FAST(tag, fmt, ...) \
269313 do { \
270314 if (event_log_tag_sets != NULL) { \
271315 uint8 tag_flag = *(event_log_tag_sets + tag); \
272
- if (tag_flag != 0) { \
316
+ if ((tag_flag & ~EVENT_LOG_TAG_FLAG_SET_MASK) != 0) { \
273317 _EVENT_LOG(_EVENT_LOG, tag, fmt , ## __VA_ARGS__); \
274318 } \
275319 } \
....@@ -285,7 +329,7 @@
285329 do { \
286330 if (event_log_tag_sets != NULL) { \
287331 uint8 tag_flag = *(event_log_tag_sets + tag); \
288
- if (tag_flag != 0) { \
332
+ if ((tag_flag & ~EVENT_LOG_TAG_FLAG_SET_MASK) != 0) { \
289333 _EVENT_LOG(_EVENT_LOG_CAST, tag, fmt , ## __VA_ARGS__); \
290334 } \
291335 } \
....@@ -295,7 +339,6 @@
295339 do { \
296340 _EVENT_LOG(_EVENT_LOG_CAST, tag, fmt , ## __VA_ARGS__); \
297341 } while (0)
298
-
299342
300343 #define EVENT_LOG(tag, fmt, ...) EVENT_LOG_COMPACT(tag, fmt , ## __VA_ARGS__)
301344
....@@ -313,23 +356,44 @@
313356 #define EVENT_LOG_COMPACT_CAST_PAREN_ARGS(tag, pargs) \
314357 EVENT_LOG_COMPACT_CAST(tag, EVENT_LOG_REMOVE_PAREN(pargs))
315358
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)
316371
372
+#define EVENT_LOG_IS_ON(tag) (*(event_log_tag_sets + (tag)) & ~EVENT_LOG_TAG_FLAG_SET_MASK)
317373 #define EVENT_LOG_IS_LOG_ON(tag) (*(event_log_tag_sets + (tag)) & EVENT_LOG_TAG_FLAG_LOG)
318374
375
+#define EVENT_LOG_BUFFER(tag, buf, size) event_log_buffer(tag, buf, size)
319376 #define EVENT_DUMP event_log_buffer
320377
321378 extern uint8 *event_log_tag_sets;
322379
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);
324384
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);
329385 extern int event_log_tag_start(int tag, int set_num, int flags);
386
+extern int event_log_tag_set_retrieve(int tag);
330387 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
+
331394 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);
333397
334398 extern void event_log0(int tag, int fmtNum);
335399 extern void event_log1(int tag, int fmtNum, uint32 t1);
....@@ -340,6 +404,16 @@
340404
341405 extern void event_log_time_sync(uint32 ms);
342406 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);
343417
344418 #endif /* EVENT_LOG_DUMPER */
345419
....@@ -347,4 +421,4 @@
347421
348422 #endif /* __ASSEMBLER__ */
349423
350
-#endif /* _EVENT_LOG_H */
424
+#endif /* _EVENT_LOG_H_ */