xref: /OK3568_Linux_fs/kernel/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/include/bcm_fwtrace.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 
2 /*
3  * Firmware trace implementation common header file between DHD and the firmware.
4  *
5  *
6  * Broadcom Proprietary and Confidential. Copyright (C) 2020,
7  * All Rights Reserved.
8  *
9  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom;
10  * the contents of this file may not be disclosed to third parties,
11  * copied or duplicated in any form, in whole or in part, without
12  * the prior written permission of Broadcom.
13  *
14  *
15  * <<Broadcom-WL-IPTag/Secret:>>
16  */
17 
18 #ifndef _bcm_fwtrace_h
19 #define _bcm_fwtrace_h
20 
21 #include <bcmpcie.h>
22 #include <bcmmsgbuf.h>
23 
24 #define FWTRACE_VERSION		1u
25 
26 /*
27  * Number of trace entries per trace buffer.
28  * Both DHD and FW must use same number.
29  */
30 #define FWTRACE_NUM_ENTRIES		(2u * 1024u) /* 2KB, power of 2 */
31 /*
32  * Number of buffers provided by the host.
33  * DHD may allocate smaller number of trace buffers based on continuous memory availability.
34  */
35 #define FWTRACE_NUM_HOST_BUFFERS	32u
36 
37 /* Magic value to differentiate between regural trace data Vs other blobs */
38 #define FWTRACE_BLOB_MAGIC              (0xFFu)
39 #define FWTRACE_BLOB_MGIC_SHIFT         (24u)
40 
41 /* The lower 24 bits of the fwtrace_entry->func_ptr is used to push different type of
42  * information to host such as ACK bitmap, interrupts DPC is going to process etc.
43  */
44 #define FWTRACE_BLOB_TYPE_MASK          (0xFFFFFFu)
45 #define FWTRACE_BLOB_TYPE_SHIFT         (0)
46 
47 #define FWTRACE_BLOB_TYPE_NUM_PKTS         (0x1u)
48 #define FWTRACE_BLOB_TYPE_ACK_BMAP1        (0x2u)  /* Ack bits (0-31 )   */
49 #define FWTRACE_BLOB_TYPE_ACK_BMAP2        (0x4u)  /* Ack bits (32-63)   */
50 #define FWTRACE_BLOB_TYPE_ACK_BMAP3        (0x8u)  /* Ack bits (64-95)   */
51 #define FWTRACE_BLOB_TYPE_ACK_BMAP4        (0x10u) /* Ack bits (96-127)  */
52 #define FWTRACE_BLOB_TYPE_INTR1            (0x20u) /* interrupts the DPC is going to process */
53 #define FWTRACE_BLOB_TYPE_INTR2            (0x40u) /* interrupts the DPC is going to process */
54 /* The blob data for LFRAGS_INFO will contain
55  * Bit31-16: Available buffer/lfrags info
56  * Bit15-0 : # of lfrags requested by FW in the fetch request
57  */
58 #define FWTRACE_BLOB_TYPE_LFRAGS_INFO      (0x80u) /* Available and fetch requested lfrags */
59 
60 #define FWTRACE_BLOB_DATA_MASK             (0xFFFFFu)
61 
62 #define FWTRACE_BLOB_ADD_CUR       (0)  /* updates with in the existing trace entry */
63 #define FWTRACE_BLOB_ADD_NEW       (1u) /* Creates new trace entry */
64 
65 /*
66  * Host sends host memory location to FW via iovar.
67  * FW will push trace information here.
68  */
69 typedef struct fwtrace_hostaddr_info {
70 	bcm_addr64_t haddr;	/* host address for the firmware to DMA trace data */
71 	uint32       buf_len;
72 	uint32       num_bufs;	/* Number of trace buffers */
73 } fwtrace_hostaddr_info_t;
74 
75 /*
76  * Eact trace info buffer pushed to host will have this header.
77  */
78 typedef struct fwtrace_dma_header_info {
79 	uint16 length;	/* length in bytes */
80 	uint16 seq_num;	/* sequence number */
81 	uint32 version;
82 	uint32 hostmem_addr;
83 } fwtrace_dma_header_info_t;
84 
85 /*
86  * Content of each trace entry
87  */
88 typedef struct fwtrace_entry {
89 	uint32 func_ptr;
90 	/* How the pkts_cycle being used?
91 	 * Bit31-23: (If present) Used to indicate the number of packets processed by the
92 	 * current function
93 	 * Bit22-1 : Used to indicate the CPU cycles(in units of 2Cycles). So to get the actual
94 	 * cycles multiply the cycles by 2.
95 	 * Bit0    : Used to indicate whether this entry is valid or not
96 	 */
97 	uint32 pkts_cycles;
98 } fwtrace_entry_t;
99 
100 #define FWTRACE_CYCLES_VALID	(1u << 0u)
101 
102 /*
103  * Format of firmware trace buffer pushed to host memory
104  */
105 typedef struct fwtrace_buf {
106 	fwtrace_dma_header_info_t info;	/* includes the sequence number and the length */
107 	fwtrace_entry_t           entry[FWTRACE_NUM_ENTRIES];
108 } fwtrace_buf_t;
109 
110 void fwtracing_add_blob(uint32 update_type, uint32 trace_type, uint32 blob);
111 #endif	/* _bcm_fwtrace_h */
112