xref: /OK3568_Linux_fs/kernel/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/include/dnglevent.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Broadcom Event protocol definitions
3  *
4  * Dependencies: bcmeth.h
5  *
6  * Copyright (C) 2020, Broadcom.
7  *
8  *      Unless you and Broadcom execute a separate written software license
9  * agreement governing use of this software, this software is licensed to you
10  * under the terms of the GNU General Public License version 2 (the "GPL"),
11  * available at http://www.broadcom.com/licenses/GPLv2.php, with the
12  * following added to such license:
13  *
14  *      As a special exception, the copyright holders of this software give you
15  * permission to link this software with independent modules, and to copy and
16  * distribute the resulting executable under terms of your choice, provided that
17  * you also meet, for each linked independent module, the terms and conditions of
18  * the license of that module.  An independent module is a module which is not
19  * derived from this software.  The special exception does not apply to any
20  * modifications of the software.
21  *
22  *
23  * <<Broadcom-WL-IPTag/Dual:>>
24  *
25  * -----------------------------------------------------------------------------
26  *
27  */
28 
29 /*
30  * Broadcom dngl Ethernet Events protocol defines
31  *
32  */
33 
34 #ifndef _DNGLEVENT_H_
35 #define _DNGLEVENT_H_
36 
37 #ifndef _TYPEDEFS_H_
38 #include <typedefs.h>
39 #endif
40 #include <bcmeth.h>
41 #include <ethernet.h>
42 #ifdef HEALTH_CHECK
43 #include <dngl_defs.h>
44 #endif /* HEALTH_CHECK */
45 
46 /* This marks the start of a packed structure section. */
47 #include <packed_section_start.h>
48 #define BCM_DNGL_EVENT_MSG_VERSION		1
49 #define DNGL_E_RSRVD_1				0x0
50 #define DNGL_E_RSRVD_2				0x1
51 #define DNGL_E_SOCRAM_IND			0x2
52 #define DNGL_E_PROFILE_DATA_IND			0x3
53 typedef BWL_PRE_PACKED_STRUCT struct
54 {
55 	uint16  version; /* Current version is 1 */
56 	uint16  reserved; /* reserved for any future extension */
57 	uint16  event_type; /* DNGL_E_SOCRAM_IND */
58 	uint16  datalen; /* Length of the event payload */
59 } BWL_POST_PACKED_STRUCT bcm_dngl_event_msg_t;
60 
61 typedef BWL_PRE_PACKED_STRUCT struct bcm_dngl_event {
62 	struct ether_header eth;
63 	bcmeth_hdr_t        bcm_hdr;
64 	bcm_dngl_event_msg_t      dngl_event;
65 	/* data portion follows */
66 } BWL_POST_PACKED_STRUCT bcm_dngl_event_t;
67 
68 typedef BWL_PRE_PACKED_STRUCT struct bcm_dngl_socramind {
69 	uint16			tag;	/* data tag */
70 	uint16			length; /* data length */
71 	uint8			value[1]; /* data value with variable length specified by length */
72 } BWL_POST_PACKED_STRUCT bcm_dngl_socramind_t;
73 
74 typedef BWL_PRE_PACKED_STRUCT struct bcm_dngl_profile_data_ind_t {
75 	uint16 tag;
76 	uint16 length;
77 	uint8 value[];
78 } BWL_POST_PACKED_STRUCT bcm_dngl_profile_data_ind_t;
79 
80 typedef BWL_PRE_PACKED_STRUCT struct bcm_dngl_arm_event {
81 	uint32 type;
82 	uint32 value;
83 } BWL_POST_PACKED_STRUCT bcm_dngl_arm_event_t;
84 
85 #define PROFILE_DATA_IND_INFO 0x1
86 
87 #define PROFILE_SUB_TYPE_ARM_STATS_INFO 0x1
88 
89 typedef BWL_PRE_PACKED_STRUCT struct bcm_dngl_arm_stats_ind {
90 	uint16	tag;
91 	uint16	length;
92 	uint8	value[];
93 } BWL_POST_PACKED_STRUCT bcm_dngl_arm_stats_ind_t;
94 
95 typedef BWL_PRE_PACKED_STRUCT struct bcm_dngl_arm_stats {
96 	uint32	cycles;
97 	uint32	timestamp;
98 	uint16	freq;
99 	uint16	roh;
100 	uint16	num_events;
101 	uint16  seq_no;
102 	uint8	value[];
103 } BWL_POST_PACKED_STRUCT bcm_dngl_arm_stats_t;
104 
105 /* SOCRAM_IND type tags */
106 typedef enum socram_ind_tag {
107 	SOCRAM_IND_ASSERT_TAG = 1,
108 	SOCRAM_IND_TAG_HEALTH_CHECK = 2
109 } socram_ind_tag_t;
110 
111 /* Health check top level module tags */
112 typedef BWL_PRE_PACKED_STRUCT struct bcm_dngl_healthcheck {
113 	uint16			top_module_tag;	/* top level module tag */
114 	uint16			top_module_len; /* Type of PCIE issue indication */
115 	uint8			value[1]; /* data value with variable length specified by length */
116 } BWL_POST_PACKED_STRUCT bcm_dngl_healthcheck_t;
117 
118 /* Health check top level module tags */
119 #define HEALTH_CHECK_TOP_LEVEL_MODULE_PCIEDEV_RTE 1
120 #define HEALTH_CHECK_PCIEDEV_VERSION_1	1
121 #define HEALTH_CHECK_PCIEDEV_FLAG_IN_D3_SHIFT	0
122 #define HEALTH_CHECK_PCIEDEV_FLAG_AER_SHIFT		1
123 #define HEALTH_CHECK_PCIEDEV_FLAG_LINKDOWN_SHIFT		2
124 #define HEALTH_CHECK_PCIEDEV_FLAG_MSI_INT_SHIFT			3
125 #define HEALTH_CHECK_PCIEDEV_FLAG_NODS_SHIFT			4
126 #define HEALTH_CHECK_PCIEDEV_FLAG_NO_HOST_WAKE_SHIFT		5
127 #define HEALTH_CHECK_PCIEDEV_FLAG_IN_D3	1 << HEALTH_CHECK_PCIEDEV_FLAG_IN_D3_SHIFT
128 #define HEALTH_CHECK_PCIEDEV_FLAG_AER	1 << HEALTH_CHECK_PCIEDEV_FLAG_AER_SHIFT
129 #define HEALTH_CHECK_PCIEDEV_FLAG_LINKDOWN	1 << HEALTH_CHECK_PCIEDEV_FLAG_LINKDOWN_SHIFT
130 #define HEALTH_CHECK_PCIEDEV_FLAG_MSI_INT	1 << HEALTH_CHECK_PCIEDEV_FLAG_MSI_INT_SHIFT
131 #define HEALTH_CHECK_PCIEDEV_FLAG_NODS	1 << HEALTH_CHECK_PCIEDEV_FLAG_NODS_SHIFT
132 #define HEALTH_CHECK_PCIEDEV_FLAG_NO_HOST_WAKE	1 << HEALTH_CHECK_PCIEDEV_FLAG_NO_HOST_WAKE_SHIFT
133 /* PCIE Module TAGs */
134 #define HEALTH_CHECK_PCIEDEV_INDUCED_IND	0x1
135 #define HEALTH_CHECK_PCIEDEV_H2D_DMA_IND	0x2
136 #define HEALTH_CHECK_PCIEDEV_D2H_DMA_IND	0x3
137 #define HEALTH_CHECK_PCIEDEV_IOCTL_STALL_IND	0x4
138 #define HEALTH_CHECK_PCIEDEV_D3ACK_STALL_IND	0x5
139 #define HEALTH_CHECK_PCIEDEV_NODS_IND	0x6
140 #define HEALTH_CHECK_PCIEDEV_LINKSPEED_FALLBACK_IND	0x7
141 #define HEALTH_CHECK_PCIEDEV_DSACK_STALL_IND	0x8
142 #define HEALTH_CHECK_PCIEDEV_FLOWRING_IND	0x9
143 #define HEALTH_CHECK_PCIEDEV_HW_ASSERT_LONG_IND 0xA
144 #define HEALTH_CHECK_PCIEDEV_RXPOST_LONG_IND	0xB
145 
146 #define HC_PCIEDEV_CONFIG_REGLIST_MAX	25
147 typedef BWL_PRE_PACKED_STRUCT struct bcm_dngl_pcie_hc {
148 	uint16			version; /* HEALTH_CHECK_PCIEDEV_VERSION_1 */
149 	uint16			reserved;
150 	uint16			pcie_err_ind_type; /* PCIE Module TAGs */
151 	uint16			pcie_flag;
152 	uint32			pcie_control_reg;
153 	uint32			pcie_config_regs[HC_PCIEDEV_CONFIG_REGLIST_MAX];
154 } BWL_POST_PACKED_STRUCT bcm_dngl_pcie_hc_t;
155 
156 /* define to avoid compile issues in older branches which define hchk_sw_entity_t */
157 #ifdef HCHK_COMMON_SW_EVENT
158 /* Enumerating top level SW entities for use by health check */
159 typedef enum {
160 	HCHK_SW_ENTITY_UNDEFINED = 0,
161 	HCHK_SW_ENTITY_PCIE = 1,
162 	HCHK_SW_ENTITY_SDIO = 2,
163 	HCHK_SW_ENTITY_USB = 3,
164 	HCHK_SW_ENTITY_RTE = 4,
165 	HCHK_SW_ENTITY_WL_PRIMARY = 5, /* WL instance 0 */
166 	HCHK_SW_ENTITY_WL_SECONDARY = 6, /* WL instance 1 */
167 	HCHK_SW_ENTITY_MAX
168 } hchk_sw_entity_t;
169 #endif /* HCHK_COMMON_SW_EVENT */
170 
171 /* This marks the end of a packed structure section. */
172 #include <packed_section_end.h>
173 
174 #endif /* _DNGLEVENT_H_ */
175