xref: /wlan-driver/qcacld-3.0/uapi/linux/dbglog_common.h (revision 5113495b16420b49004c444715d2daae2066e7dc) !
1 /*
2  * Copyright (c) 2011, 2014-2015 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #ifndef _DBGLOG_COMMON_H_
21 #define _DBGLOG_COMMON_H_
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 #include "dbglog_id.h"
28 #include "dbglog.h"
29 
30 #define MAX_DBG_MSGS 256
31 
32 #define ATH6KL_FWLOG_PAYLOAD_SIZE              1500
33 
34 #define DBGLOG_PRINT_PREFIX "FWLOG: "
35 
36 /* Handy Macros to read data length and type from FW */
37 #define WLAN_DIAG_0_TYPE_S          0
38 #define WLAN_DIAG_0_TYPE            0x000000ff
39 #define WLAN_DIAG_0_TYPE_GET(x)     WMI_F_MS(x, WLAN_DIAG_0_TYPE)
40 #define WLAN_DIAG_0_TYPE_SET(x, y)  WMI_F_RMW(x, y, WLAN_DIAG_0_TYPE)
41 /* bits 8-15 reserved */
42 
43 /* length includes the size of wlan_diag_data */
44 #define WLAN_DIAG_0_LEN_S           16
45 #define WLAN_DIAG_0_LEN             0xffff0000
46 #define WLAN_DIAG_0_LEN_GET(x)      WMI_F_MS(x, WLAN_DIAG_0_LEN)
47 #define WLAN_DIAG_0_LEN_SET(x, y)   WMI_F_RMW(x, y, WLAN_DIAG_0_LEN)
48 
49 #define CNSS_DIAG_SLEEP_INTERVAL    5   /* In secs */
50 
51 #define ATH6KL_FWLOG_MAX_ENTRIES   20
52 #define ATH6KL_FWLOG_PAYLOAD_SIZE  1500
53 
54 #define DIAG_WLAN_DRIVER_UNLOADED 6
55 #define DIAG_WLAN_DRIVER_LOADED   7
56 #define DIAG_TYPE_LOGS   1
57 #define DIAG_TYPE_EVENTS 2
58 
59 typedef enum {
60 	DBGLOG_PROCESS_DEFAULT = 0,
61 	DBGLOG_PROCESS_PRINT_RAW,       /* print them in debug view */
62 	DBGLOG_PROCESS_POOL_RAW,        /* user buffer pool to save them */
63 	DBGLOG_PROCESS_NET_RAW,         /* user buffer pool to save them */
64 	DBGLOG_PROCESS_MAX,
65 } dbglog_process_t;
66 
67 enum cnss_diag_type {
68 	DIAG_TYPE_FW_EVENT,           /* send fw event- to diag */
69 	DIAG_TYPE_FW_LOG,             /* send log event- to diag */
70 	DIAG_TYPE_FW_DEBUG_MSG,       /* send dbg message- to diag */
71 	DIAG_TYPE_INIT_REQ,           /* cnss_diag initialization- from diag */
72 	DIAG_TYPE_FW_MSG,             /* fw msg command-to diag */
73 	DIAG_TYPE_HOST_MSG,           /* host command-to diag */
74 	DIAG_TYPE_CRASH_INJECT,       /*crash inject-from diag */
75 	DIAG_TYPE_DBG_LEVEL,          /* DBG LEVEL-from diag */
76 };
77 
78 enum wlan_diag_config_type {
79 	DIAG_VERSION_INFO,
80 };
81 
82 enum wlan_diag_frame_type {
83 	WLAN_DIAG_TYPE_CONFIG,
84 	WLAN_DIAG_TYPE_EVENT,
85 	WLAN_DIAG_TYPE_LOG,
86 	WLAN_DIAG_TYPE_MSG,
87 	WLAN_DIAG_TYPE_LEGACY_MSG,
88 };
89 
90 /* log/event are always 32-bit aligned. Padding is inserted after
91  * optional payload to satisfy this requirement
92  */
93 struct wlan_diag_data {
94 	unsigned int word0;             /* type, length */
95 	unsigned int target_time;
96 	unsigned int code;              /* Diag log or event Code */
97 	uint8_t payload[];
98 };
99 
100 struct dbglog_slot {
101 	unsigned int diag_type;
102 	unsigned int timestamp;
103 	unsigned int length;
104 	unsigned int dropped;
105 	/* max ATH6KL_FWLOG_PAYLOAD_SIZE bytes */
106 	uint8_t payload[];
107 } __packed;
108 
109 typedef struct event_report_s {
110 	unsigned int diag_type;
111 	unsigned short event_id;
112 	unsigned short length;
113 } event_report_t;
114 
115 /*
116  * Custom debug_print handlers
117  * Args:
118  * module Id
119  * vap id
120  * debug msg id
121  * Time stamp
122  * no of arguments
123  * pointer to the buffer holding the args
124  */
125 typedef A_BOOL (*module_dbg_print)(A_UINT32, A_UINT16, A_UINT32,
126 				   A_UINT32, A_UINT16, A_UINT32 *);
127 
128 /** Register module specific dbg print*/
129 void dbglog_reg_modprint(A_UINT32 mod_id, module_dbg_print printfn);
130 
131 #ifdef __cplusplus
132 }
133 #endif
134 
135 #endif /* _DBGLOG_COMMON_H_ */
136