xref: /openbsd/sys/dev/ic/bwfmreg.h (revision 9b183917)
1 /* $OpenBSD: bwfmreg.h,v 1.26 2022/03/04 22:34:41 kettenis Exp $ */
2 /*
3  * Copyright (c) 2010-2016 Broadcom Corporation
4  * Copyright (c) 2016,2017 Patrick Wildt <patrick@blueri.se>
5  *
6  * Permission to use, copy, modify, and/or distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 /* Chip registers */
20 #define BWFM_CHIP_BASE				0x18000000
21 #define BWFM_CHIP_REG_CHIPID			0x00000000
22 #define  BWFM_CHIP_CHIPID_ID(x)				(((x) >> 0) & 0xffff)
23 #define  BWFM_CHIP_CHIPID_REV(x)			(((x) >> 16) & 0xf)
24 #define  BWFM_CHIP_CHIPID_PKG(x)			(((x) >> 20) & 0xf)
25 #define  BWFM_CHIP_CHIPID_CC(x)				(((x) >> 24) & 0xf)
26 #define  BWFM_CHIP_CHIPID_TYPE(x)			(((x) >> 28) & 0xf)
27 #define  BWFM_CHIP_CHIPID_TYPE_SOCI_SB			0
28 #define  BWFM_CHIP_CHIPID_TYPE_SOCI_AI			1
29 #define BWFM_CHIP_REG_CAPABILITIES		0x00000004
30 #define  BWFM_CHIP_REG_CAPABILITIES_PMU			0x10000000
31 #define BWFM_CHIP_REG_CAPABILITIES_EXT		0x000000AC
32 #define  BWFM_CHIP_REG_CAPABILITIES_EXT_AOB_PRESENT	0x00000040
33 #define BWFM_CHIP_REG_WATCHDOG			0x00000080
34 #define BWFM_CHIP_REG_EROMPTR			0x000000FC
35 #define BWFM_CHIP_REG_SROMCONTROL		0x00000190
36 #define  BWFM_CHIP_REG_SROMCONTROL_OTPSEL		(1 << 4)
37 #define  BWFM_CHIP_REG_SROMCONTROL_OTP_PRESENT		(1 << 5)
38 #define BWFM_CHIP_REG_SR_CAPABILITY		0x00000500
39 #define BWFM_CHIP_REG_SR_CONTROL0		0x00000504
40 #define  BWFM_CHIP_REG_SR_CONTROL0_ENABLE		(1 << 0)
41 #define BWFM_CHIP_REG_SR_CONTROL1		0x00000508
42 #define BWFM_CHIP_REG_PMUCONTROL		0x00000600
43 #define  BWFM_CHIP_REG_PMUCONTROL_RES_MASK		0x00006000
44 #define  BWFM_CHIP_REG_PMUCONTROL_RES_SHIFT		13
45 #define  BWFM_CHIP_REG_PMUCONTROL_RES_RELOAD		0x2
46 #define BWFM_CHIP_REG_PMUCAPABILITIES		0x00000604
47 #define  BWFM_CHIP_REG_PMUCAPABILITIES_REV_MASK		0x000000ff
48 #define BWFM_CHIP_REG_PMUCAPABILITIES_EXT	0x0000064C
49 #define  BWFM_CHIP_REG_PMUCAPABILITIES_SR_SUPP		(1 << 1)
50 #define BWFM_CHIP_REG_CHIPCONTROL_ADDR		0x00000650
51 #define BWFM_CHIP_REG_CHIPCONTROL_DATA		0x00000654
52 #define BWFM_CHIP_REG_RETENTION_CTL		0x00000670
53 #define  BWFM_CHIP_REG_RETENTION_CTL_MACPHY_DIS		(1 << 26)
54 #define  BWFM_CHIP_REG_RETENTION_CTL_LOGIC_DIS		(1 << 27)
55 
56 /* Agent registers */
57 #define BWFM_AGENT_IOCTL			0x0408
58 #define  BWFM_AGENT_IOCTL_CLK				0x0001
59 #define  BWFM_AGENT_IOCTL_FGC				0x0002
60 #define  BWFM_AGENT_IOCTL_CORE_BITS			0x3FFC
61 #define  BWFM_AGENT_IOCTL_PME_EN			0x4000
62 #define  BWFM_AGENT_IOCTL_BIST_EN			0x8000
63 #define  BWFM_AGENT_IOCTL_ARMCR4_CPUHALT		0x0020
64 #define BWFM_AGENT_RESET_CTL			0x0800
65 #define  BWFM_AGENT_RESET_CTL_RESET			0x0001
66 
67 /* Agent Core-IDs */
68 #define BWFM_AGENT_CORE_CHIPCOMMON		0x800
69 #define BWFM_AGENT_INTERNAL_MEM			0x80E
70 #define BWFM_AGENT_CORE_80211			0x812
71 #define BWFM_AGENT_CORE_PMU			0x827
72 #define BWFM_AGENT_CORE_SDIO_DEV		0x829
73 #define BWFM_AGENT_CORE_ARM_CM3			0x82A
74 #define BWFM_AGENT_CORE_PCIE2			0x83C
75 #define BWFM_AGENT_CORE_ARM_CR4			0x83E
76 #define BWFM_AGENT_CORE_GCI			0x840
77 #define BWFM_AGENT_CORE_ARM_CA7			0x847
78 #define BWFM_AGENT_SYS_MEM			0x849
79 
80 /* Specific Core Bits */
81 #define BWFM_AGENT_ARMCR4_IOCTL_CPUHALT		0x0020
82 #define BWFM_AGENT_D11_IOCTL_PHYCLOCKEN		0x0004
83 #define BWFM_AGENT_D11_IOCTL_PHYRESET		0x0008
84 
85 /* CR4 registers */
86 #define BWFM_ARMCR4_CAP				0x0004
87 #define  BWFM_ARMCR4_CAP_TCBANB_MASK			0xf
88 #define  BWFM_ARMCR4_CAP_TCBANB_SHIFT			0
89 #define  BWFM_ARMCR4_CAP_TCBBNB_MASK			0xf0
90 #define  BWFM_ARMCR4_CAP_TCBBNB_SHIFT			4
91 #define BWFM_ARMCR4_BANKIDX			0x0040
92 #define BWFM_ARMCR4_BANKINFO			0x0044
93 #define  BWFM_ARMCR4_BANKINFO_BSZ_MASK			0x7f
94 #define  BWFM_ARMCR4_BANKINFO_BLK_1K_MASK		0x200
95 #define BWFM_ARMCR4_BANKPDA			0x004C
96 
97 /* SOCRAM registers */
98 #define BWFM_SOCRAM_COREINFO			0x0000
99 #define  BWFM_SOCRAM_COREINFO_SRBSZ_BASE		14
100 #define  BWFM_SOCRAM_COREINFO_SRBSZ_MASK		0xf
101 #define  BWFM_SOCRAM_COREINFO_SRBSZ_SHIFT		0
102 #define  BWFM_SOCRAM_COREINFO_SRNB_MASK			0xf0
103 #define  BWFM_SOCRAM_COREINFO_SRNB_SHIFT		4
104 #define  BWFM_SOCRAM_COREINFO_LSS_MASK			0xf00000
105 #define  BWFM_SOCRAM_COREINFO_LSS_SHIFT			20
106 #define BWFM_SOCRAM_BANKIDX			0x0010
107 #define  BWFM_SOCRAM_BANKIDX_MEMTYPE_RAM		0
108 #define  BWFM_SOCRAM_BANKIDX_MEMTYPE_ROM		1
109 #define  BWFM_SOCRAM_BANKIDX_MEMTYPE_DEVRAM		2
110 #define  BWFM_SOCRAM_BANKIDX_MEMTYPE_SHIFT		8
111 #define BWFM_SOCRAM_BANKINFO			0x0040
112 #define  BWFM_SOCRAM_BANKINFO_SZBASE			8192
113 #define  BWFM_SOCRAM_BANKINFO_SZMASK			0x7f
114 #define  BWFM_SOCRAM_BANKINFO_RETNTRAM_MASK		0x10000
115 #define BWFM_SOCRAM_BANKPDA			0x0044
116 
117 /* SDPCMD registers */
118 #define BWFM_SDPCMD_INTSTATUS			0x0020
119 
120 /* DMP descriptor */
121 #define BWFM_DMP_DESC_MASK			0x0000000F
122 #define BWFM_DMP_DESC_EMPTY			0x00000000
123 #define BWFM_DMP_DESC_VALID			0x00000001
124 #define BWFM_DMP_DESC_COMPONENT			0x00000001
125 #define BWFM_DMP_DESC_MASTER_PORT		0x00000003
126 #define BWFM_DMP_DESC_ADDRESS			0x00000005
127 #define BWFM_DMP_DESC_ADDRSIZE_GT32		0x00000008
128 #define BWFM_DMP_DESC_EOT			0x0000000F
129 #define BWFM_DMP_COMP_DESIGNER			0xFFF00000
130 #define BWFM_DMP_COMP_DESIGNER_S		20
131 #define BWFM_DMP_COMP_PARTNUM			0x000FFF00
132 #define BWFM_DMP_COMP_PARTNUM_S			8
133 #define BWFM_DMP_COMP_CLASS			0x000000F0
134 #define BWFM_DMP_COMP_CLASS_S			4
135 #define BWFM_DMP_COMP_REVISION			0xFF000000
136 #define BWFM_DMP_COMP_REVISION_S		24
137 #define BWFM_DMP_COMP_NUM_SWRAP			0x00F80000
138 #define BWFM_DMP_COMP_NUM_SWRAP_S		19
139 #define BWFM_DMP_COMP_NUM_MWRAP			0x0007C000
140 #define BWFM_DMP_COMP_NUM_MWRAP_S		14
141 #define BWFM_DMP_COMP_NUM_SPORT			0x00003E00
142 #define BWFM_DMP_COMP_NUM_SPORT_S		9
143 #define BWFM_DMP_COMP_NUM_MPORT			0x000001F0
144 #define BWFM_DMP_COMP_NUM_MPORT_S		4
145 #define BWFM_DMP_MASTER_PORT_UID		0x0000FF00
146 #define BWFM_DMP_MASTER_PORT_UID_S		8
147 #define BWFM_DMP_MASTER_PORT_NUM		0x000000F0
148 #define BWFM_DMP_MASTER_PORT_NUM_S		4
149 #define BWFM_DMP_SLAVE_ADDR_BASE		0xFFFFF000
150 #define BWFM_DMP_SLAVE_ADDR_BASE_S		12
151 #define BWFM_DMP_SLAVE_PORT_NUM			0x00000F00
152 #define BWFM_DMP_SLAVE_PORT_NUM_S		8
153 #define BWFM_DMP_SLAVE_TYPE			0x000000C0
154 #define BWFM_DMP_SLAVE_TYPE_S			6
155 #define  BWFM_DMP_SLAVE_TYPE_SLAVE		0
156 #define  BWFM_DMP_SLAVE_TYPE_BRIDGE		1
157 #define  BWFM_DMP_SLAVE_TYPE_SWRAP		2
158 #define  BWFM_DMP_SLAVE_TYPE_MWRAP		3
159 #define BWFM_DMP_SLAVE_SIZE_TYPE		0x00000030
160 #define BWFM_DMP_SLAVE_SIZE_TYPE_S		4
161 #define  BWFM_DMP_SLAVE_SIZE_4K			0
162 #define  BWFM_DMP_SLAVE_SIZE_8K			1
163 #define  BWFM_DMP_SLAVE_SIZE_16K		2
164 #define  BWFM_DMP_SLAVE_SIZE_DESC		3
165 
166 /* Security Parameters */
167 #define BWFM_AUTH_OPEN				0
168 #define BWFM_AUTH_SHARED_KEY			1
169 #define BWFM_AUTH_AUTO				2
170 #define BWFM_CRYPTO_ALGO_OFF			0
171 #define BWFM_CRYPTO_ALGO_WEP1			1
172 #define BWFM_CRYPTO_ALGO_TKIP			2
173 #define BWFM_CRYPTO_ALGO_WEP128			3
174 #define BWFM_CRYPTO_ALGO_AES_CCM		4
175 #define BWFM_CRYPTO_ALGO_AES_RESERVED1		5
176 #define BWFM_CRYPTO_ALGO_AES_RESERVED2		6
177 #define BWFM_MFP_NONE				0
178 #define BWFM_MFP_CAPABLE			1
179 #define BWFM_MFP_REQUIRED			2
180 #define BWFM_WPA_AUTH_DISABLED			(0 << 0)
181 #define BWFM_WPA_AUTH_NONE			(1 << 0)
182 #define BWFM_WPA_AUTH_WPA_UNSPECIFIED		(1 << 1)
183 #define BWFM_WPA_AUTH_WPA_PSK			(1 << 2)
184 #define BWFM_WPA_AUTH_WPA2_UNSPECIFIED		(1 << 6)
185 #define BWFM_WPA_AUTH_WPA2_PSK			(1 << 7)
186 #define BWFM_WPA_AUTH_WPA2_1X_SHA256		(1 << 12)
187 #define BWFM_WPA_AUTH_WPA2_PSK_SHA256		(1 << 15)
188 #define BWFM_WSEC_NONE				(0 << 0)
189 #define BWFM_WSEC_WEP				(1 << 0)
190 #define BWFM_WSEC_TKIP				(1 << 1)
191 #define BWFM_WSEC_AES				(1 << 2)
192 
193 /* Channel Parameters */
194 #define BWFM_CHANSPEC_CHAN_MASK			0xff
195 #define BWFM_CHANSPEC_CHAN_SHIFT		0
196 #define BWFM_CHANSPEC_D11N_SB_L			(0x1 << 8) /* control lower */
197 #define BWFM_CHANSPEC_D11N_SB_U			(0x2 << 8) /* control lower */
198 #define BWFM_CHANSPEC_D11N_SB_N			(0x3 << 8) /* none */
199 #define BWFM_CHANSPEC_D11N_SB_MASK		(0x3 << 8)
200 #define BWFM_CHANSPEC_D11N_SB_SHIFT		8
201 #define BWFM_CHANSPEC_D11N_BW_10		(0x1 << 10)
202 #define BWFM_CHANSPEC_D11N_BW_20		(0x2 << 10)
203 #define BWFM_CHANSPEC_D11N_BW_40		(0x3 << 10)
204 #define BWFM_CHANSPEC_D11N_BW_MASK		(0x3 << 10)
205 #define BWFM_CHANSPEC_D11N_BW_SHIFT		10
206 #define BWFM_CHANSPEC_D11N_BND_5G		(0x1 << 12)
207 #define BWFM_CHANSPEC_D11N_BND_2G		(0x2 << 12)
208 #define BWFM_CHANSPEC_D11N_BND_MASK		(0x3 << 12)
209 #define BWFM_CHANSPEC_D11N_BND_SHIFT		12
210 #define BWFM_CHANSPEC_D11AC_SB_LLL		(0x0 << 8)
211 #define BWFM_CHANSPEC_D11AC_SB_LLU		(0x1 << 8)
212 #define BWFM_CHANSPEC_D11AC_SB_LUL		(0x2 << 8)
213 #define BWFM_CHANSPEC_D11AC_SB_LUU		(0x3 << 8)
214 #define BWFM_CHANSPEC_D11AC_SB_ULL		(0x4 << 8)
215 #define BWFM_CHANSPEC_D11AC_SB_ULU		(0x5 << 8)
216 #define BWFM_CHANSPEC_D11AC_SB_UUL		(0x6 << 8)
217 #define BWFM_CHANSPEC_D11AC_SB_UUU		(0x7 << 8)
218 #define BWFM_CHANSPEC_D11AC_SB_MASK		(0x7 << 8)
219 #define BWFM_CHANSPEC_D11AC_SB_SHIFT		8
220 #define BWFM_CHANSPEC_D11AC_BW_5		(0x0 << 11)
221 #define BWFM_CHANSPEC_D11AC_BW_10		(0x1 << 11)
222 #define BWFM_CHANSPEC_D11AC_BW_20		(0x2 << 11)
223 #define BWFM_CHANSPEC_D11AC_BW_40		(0x3 << 11)
224 #define BWFM_CHANSPEC_D11AC_BW_80		(0x4 << 11)
225 #define BWFM_CHANSPEC_D11AC_BW_160		(0x5 << 11)
226 #define BWFM_CHANSPEC_D11AC_BW_8080		(0x6 << 11)
227 #define BWFM_CHANSPEC_D11AC_BW_MASK		(0x7 << 11)
228 #define BWFM_CHANSPEC_D11AC_BW_SHIFT		11
229 #define BWFM_CHANSPEC_D11AC_BND_2G		(0x0 << 14)
230 #define BWFM_CHANSPEC_D11AC_BND_3G		(0x1 << 14)
231 #define BWFM_CHANSPEC_D11AC_BND_4G		(0x2 << 14)
232 #define BWFM_CHANSPEC_D11AC_BND_5G		(0x3 << 14)
233 #define BWFM_CHANSPEC_D11AC_BND_MASK		(0x3 << 14)
234 #define BWFM_CHANSPEC_D11AC_BND_SHIFT		14
235 
236 #define BWFM_BAND_AUTO				0
237 #define BWFM_BAND_5G				1
238 #define BWFM_BAND_2G				2
239 #define BWFM_BAND_ALL				3
240 
241 /* Power Modes */
242 #define BWFM_PM_CAM				0
243 #define BWFM_PM_PS				1
244 #define BWFM_PM_FAST_PS				2
245 
246 /* DCMD commands */
247 #define BWFM_C_GET_VERSION			1
248 #define BWFM_C_UP				2
249 #define BWFM_C_DOWN				3
250 #define BWFM_C_SET_PROMISC			10
251 #define BWFM_C_GET_RATE				12
252 #define BWFM_C_GET_INFRA			19
253 #define BWFM_C_SET_INFRA			20
254 #define BWFM_C_GET_AUTH				21
255 #define BWFM_C_SET_AUTH				22
256 #define BWFM_C_GET_BSSID			23
257 #define BWFM_C_GET_SSID				25
258 #define BWFM_C_SET_SSID				26
259 #define BWFM_C_TERMINATED			28
260 #define BWFM_C_GET_CHANNEL			29
261 #define BWFM_C_SET_CHANNEL			30
262 #define BWFM_C_GET_SRL				31
263 #define BWFM_C_SET_SRL				32
264 #define BWFM_C_GET_LRL				33
265 #define BWFM_C_SET_LRL				34
266 #define BWFM_C_GET_RADIO			37
267 #define BWFM_C_SET_RADIO			38
268 #define BWFM_C_GET_PHYTYPE			39
269 #define BWFM_C_SET_KEY				45
270 #define BWFM_C_GET_REGULATORY			46
271 #define BWFM_C_SET_REGULATORY			47
272 #define BWFM_C_SET_PASSIVE_SCAN			49
273 #define BWFM_C_SCAN				50
274 #define BWFM_C_SCAN_RESULTS			51
275 #define BWFM_C_DISASSOC				52
276 #define BWFM_C_REASSOC				53
277 #define BWFM_C_SET_ROAM_TRIGGER			55
278 #define BWFM_C_SET_ROAM_DELTA			57
279 #define BWFM_C_GET_BCNPRD			75
280 #define BWFM_C_SET_BCNPRD			76
281 #define BWFM_C_GET_DTIMPRD			77
282 #define BWFM_C_SET_DTIMPRD			78
283 #define BWFM_C_SET_COUNTRY			84
284 #define BWFM_C_GET_PM				85
285 #define BWFM_C_SET_PM				86
286 #define BWFM_C_GET_REVINFO			98
287 #define BWFM_C_GET_CURR_RATESET			114
288 #define BWFM_C_GET_AP				117
289 #define BWFM_C_SET_AP				118
290 #define BWFM_C_SET_SCB_AUTHORIZE		121
291 #define BWFM_C_SET_SCB_DEAUTHORIZE		122
292 #define BWFM_C_GET_RSSI				127
293 #define BWFM_C_GET_WSEC				133
294 #define BWFM_C_SET_WSEC				134
295 #define BWFM_C_GET_PHY_NOISE			135
296 #define BWFM_C_GET_BSS_INFO			136
297 #define BWFM_C_GET_GET_PKTCNTS			137
298 #define BWFM_C_GET_BANDLIST			140
299 #define BWFM_C_SET_SCB_TIMEOUT			158
300 #define BWFM_C_GET_ASSOCLIST			159
301 #define BWFM_C_GET_PHYLIST			180
302 #define BWFM_C_SET_SCAN_CHANNEL_TIME		185
303 #define BWFM_C_SET_SCAN_UNASSOC_TIME		187
304 #define BWFM_C_SCB_DEAUTHENTICATE_FOR_REASON	201
305 #define BWFM_C_SET_ASSOC_PREFER			205
306 #define BWFM_C_GET_VALID_CHANNELS		217
307 #define BWFM_C_GET_KEY_PRIMARY			235
308 #define BWFM_C_SET_KEY_PRIMARY			236
309 #define BWFM_C_SET_SCAN_PASSIVE_TIME		258
310 #define BWFM_C_GET_VAR				262
311 #define BWFM_C_SET_VAR				263
312 #define BWFM_C_SET_WSEC_PMK			268
313 
314 struct bwfm_proto_bcdc_dcmd {
315 	struct {
316 		uint32_t cmd;
317 		uint32_t len;
318 		uint32_t flags;
319 #define BWFM_BCDC_DCMD_ERROR		(1 << 0)
320 #define BWFM_BCDC_DCMD_GET		(0 << 1)
321 #define BWFM_BCDC_DCMD_SET		(1 << 1)
322 #define BWFM_BCDC_DCMD_IF_GET(x)	(((x) >> 12) & 0xf)
323 #define BWFM_BCDC_DCMD_IF_SET(x)	(((x) & 0xf) << 12)
324 #define BWFM_BCDC_DCMD_ID_GET(x)	(((x) >> 16) & 0xffff)
325 #define BWFM_BCDC_DCMD_ID_SET(x)	(((x) & 0xffff) << 16)
326 		uint32_t status;
327 	} hdr;
328 	char buf[8192];
329 };
330 
331 struct bwfm_proto_bcdc_hdr {
332 	uint8_t flags;
333 #define BWFM_BCDC_FLAG_PROTO_VER	2
334 #define BWFM_BCDC_FLAG_VER(x)		(((x) & 0xf) << 4)
335 #define BWFM_BCDC_FLAG_SUM_GOOD		(1 << 2) /* rx */
336 #define BWFM_BCDC_FLAG_SUM_NEEDED	(1 << 3) /* tx */
337 	uint8_t priority;
338 #define BWFM_BCDC_PRIORITY_MASK		0x7
339 	uint8_t flags2;
340 #define BWFM_BCDC_FLAG2_IF_MASK		0xf
341 	uint8_t data_offset;
342 };
343 
344 #define BWFM_MCSSET_LEN				16
345 #define BWFM_MAX_SSID_LEN			32
346 struct bwfm_bss_info {
347 	uint32_t version;
348 	uint32_t length;
349 	uint8_t bssid[ETHER_ADDR_LEN];
350 	uint16_t beacon_period;
351 	uint16_t capability;
352 	uint8_t ssid_len;
353 	uint8_t ssid[BWFM_MAX_SSID_LEN];
354 	uint8_t pad0;
355 	uint32_t nrates;
356 	uint8_t rates[16];
357 	uint16_t chanspec;
358 	uint16_t atim_window;
359 	uint8_t dtim_period;
360 	uint8_t pad1;
361 	uint16_t rssi;
362 	uint8_t phy_noise;
363 	uint8_t n_cap;
364 	uint16_t pad2;
365 	uint32_t nbss_cap;
366 	uint8_t ctl_ch;
367 	uint8_t pad3[3];
368 	uint32_t reserved32[1];
369 	uint8_t flags;
370 	uint8_t reserved[3];
371 	uint8_t basic_mcs[BWFM_MCSSET_LEN];
372 	uint16_t ie_offset;
373 	uint16_t pad4;
374 	uint32_t ie_length;
375 	uint16_t snr;
376 };
377 
378 #define BWFM_MAXRATES_IN_SET		BWFM_MCSSET_LEN
379 #define BWFM_ANT_MAX			4
380 #define BWFM_VHT_CAP_MCS_MAP_NSS_MAX	8
381 #define BWFM_HE_CAP_MCS_MAP_NSS_MAX	BWFM_VHT_CAP_MCS_MAP_NSS_MAX
382 
383 struct bwfm_sta_rateset_v5 {
384 	uint32_t count;
385 	/* rates in 500kbps units w/hi bit set if basic */
386 	uint8_t rates[BWFM_MAXRATES_IN_SET];
387 	uint8_t mcs[BWFM_MCSSET_LEN];
388 	uint16_t vht_mcs[BWFM_VHT_CAP_MCS_MAP_NSS_MAX];
389 };
390 
391 struct bwfm_sta_rateset_v7 {
392 	uint16_t version;
393 	uint16_t len;
394 	uint32_t count;
395 	/* rates in 500kbps units w/hi bit set if basic */
396 	uint8_t rates[BWFM_MAXRATES_IN_SET];
397 	uint8_t mcs[BWFM_MCSSET_LEN];
398 	uint16_t vht_mcs[BWFM_VHT_CAP_MCS_MAP_NSS_MAX];
399 	uint16_t he_mcs[BWFM_HE_CAP_MCS_MAP_NSS_MAX];
400 };
401 
402 struct bwfm_sta_info {
403 	uint16_t ver;
404 	uint16_t len;
405 	uint16_t cap;		/* sta's advertised capabilities */
406 
407 	uint32_t flags;
408 #define BWFM_STA_BRCM		0x00000001 /* Running a Broadcom driver */
409 #define BWFM_STA_WME		0x00000002 /* WMM association */
410 #define BWFM_STA_NONERP		0x00000004 /* No ERP */
411 #define BWFM_STA_AUTHE		0x00000008 /* Authenticated */
412 #define BWFM_STA_ASSOC		0x00000010 /* Associated */
413 #define BWFM_STA_AUTHO		0x00000020 /* Authorized */
414 #define BWFM_STA_WDS		0x00000040 /* Wireless Distribution System */
415 #define BWFM_STA_WDS_LINKUP	0x00000080 /* WDS traffic/probes flowing */
416 #define BWFM_STA_PS		0x00000100 /* STA in power save mode, says AP */
417 #define BWFM_STA_APSD_BE	0x00000200 /* APSD for AC_BE default enabled */
418 #define BWFM_STA_APSD_BK	0x00000400 /* APSD for AC_BK default enabled */
419 #define BWFM_STA_APSD_VI	0x00000800 /* APSD for AC_VI default enabled */
420 #define BWFM_STA_APSD_VO	0x00001000 /* APSD for AC_VO default enabled */
421 #define BWFM_STA_N_CAP		0x00002000 /* STA 802.11n capable */
422 #define BWFM_STA_SCBSTATS	0x00004000 /* Per STA debug stats */
423 #define BWFM_STA_AMPDU_CAP	0x00008000 /* STA AMPDU capable */
424 #define BWFM_STA_AMSDU_CAP	0x00010000 /* STA AMSDU capable */
425 #define BWFM_STA_MIMO_PS	0x00020000 /* mimo ps mode is enabled */
426 #define BWFM_STA_MIMO_RTS	0x00040000 /* send rts in mimo ps mode */
427 #define BWFM_STA_RIFS_CAP	0x00080000 /* rifs enabled */
428 #define BWFM_STA_VHT_CAP	0x00100000 /* STA VHT(11ac) capable */
429 #define BWFM_STA_WPS		0x00200000 /* WPS state */
430 #define BWFM_STA_DWDS_CAP	0x01000000 /* DWDS CAP */
431 #define BWFM_STA_DWDS		0x02000000 /* DWDS active */
432 
433 	uint32_t idle;		/* time since data pkt rx'd from sta */
434 	uint8_t ea[ETHER_ADDR_LEN];
435 	uint32_t count;			/* # rates in this set */
436 	uint8_t rates[BWFM_MAXRATES_IN_SET];	/* rates in 500kbps units */
437 						/* w/hi bit set if basic */
438 	uint32_t in;		/* seconds elapsed since associated */
439 	uint32_t listen_interval_inms; /* Min Listen interval in ms for STA */
440 
441 	/* Fields valid for ver >= 3 */
442 	uint32_t tx_pkts;	/* # of packets transmitted */
443 	uint32_t tx_failures;	/* # of packets failed */
444 	uint32_t rx_ucast_pkts;	/* # of unicast packets received */
445 	uint32_t rx_mcast_pkts;	/* # of multicast packets received */
446 	uint32_t tx_rate;	/* Rate of last successful tx frame, in bps */
447 	uint32_t rx_rate;	/* Rate of last successful rx frame, in bps */
448 	uint32_t rx_decrypt_succeeds;	/* # of packet decrypted successfully */
449 	uint32_t rx_decrypt_failures;	/* # of packet decrypted failed */
450 
451 	/* Fields valid for ver >= 4 */
452 	uint32_t tx_tot_pkts;    /* # of tx pkts (ucast + mcast) */
453 	uint32_t rx_tot_pkts;    /* # of data packets recvd (uni + mcast) */
454 	uint32_t tx_mcast_pkts;  /* # of mcast pkts txed */
455 	uint64_t tx_tot_bytes;   /* data bytes txed (ucast + mcast) */
456 	uint64_t rx_tot_bytes;   /* data bytes recvd (ucast + mcast) */
457 	uint64_t tx_ucast_bytes; /* data bytes txed (ucast) */
458 	uint64_t tx_mcast_bytes; /* # data bytes txed (mcast) */
459 	uint64_t rx_ucast_bytes; /* data bytes recvd (ucast) */
460 	uint64_t rx_mcast_bytes; /* data bytes recvd (mcast) */
461 	int8_t rssi[BWFM_ANT_MAX];   /* per antenna rssi */
462 	int8_t nf[BWFM_ANT_MAX];     /* per antenna noise floor */
463 	uint16_t aid;                    /* association ID */
464 	uint16_t ht_capabilities;        /* advertised ht caps */
465 	uint16_t vht_flags;              /* converted vht flags */
466 	uint32_t tx_pkts_retry_cnt;      /* # of frames where a retry was
467 					 * exhausted.
468 					 */
469 	uint32_t tx_pkts_retry_exhausted; /* # of user frames where a retry
470 					 * was exhausted
471 					 */
472 	int8_t rx_lastpkt_rssi[BWFM_ANT_MAX]; /* Per antenna RSSI of last
473 					    * received data frame.
474 					    */
475 	/* TX WLAN retry/failure statistics:
476 	 * Separated for host requested frames and locally generated frames.
477 	 * Include unicast frame only where the retries/failures can be counted.
478 	 */
479 	uint32_t tx_pkts_total;          /* # user frames sent successfully */
480 	uint32_t tx_pkts_retries;        /* # user frames retries */
481 	uint32_t tx_pkts_fw_total;       /* # FW generated sent successfully */
482 	uint32_t tx_pkts_fw_retries;     /* # retries for FW generated frames */
483 	uint32_t tx_pkts_fw_retry_exhausted;	/* # FW generated where a retry
484 						* was exhausted
485 						*/
486 	uint32_t rx_pkts_retried;        /* # rx with retry bit set */
487 	uint32_t tx_rate_fallback;       /* lowest fallback TX rate */
488 
489 	union {
490 		struct {
491 			struct bwfm_sta_rateset_v5 rateset_adv;
492 		} v5;
493 
494 		struct {
495 			uint32_t rx_dur_total; /* user RX duration (estimate) */
496 			uint16_t chanspec;
497 			uint16_t pad_1;
498 			struct bwfm_sta_rateset_v7 rateset_adv;
499 			uint16_t wpauth;	/* authentication type */
500 			uint8_t algo;		/* crypto algorithm */
501 			uint8_t pad_2;
502 			uint32_t tx_rspec;/* Rate of last successful tx frame */
503 			uint32_t rx_rspec;/* Rate of last successful rx frame */
504 			uint32_t wnm_cap;
505 		} v7;
506 	};
507 };
508 
509 struct bwfm_ssid {
510 	uint32_t len;
511 	uint8_t ssid[BWFM_MAX_SSID_LEN];
512 };
513 
514 struct bwfm_scan_params_v0 {
515 	struct bwfm_ssid ssid;
516 	uint8_t bssid[ETHER_ADDR_LEN];
517 	uint8_t bss_type;
518 #define DOT11_BSSTYPE_ANY		2
519 	uint8_t scan_type;
520 #define BWFM_SCANTYPE_ACTIVE		0
521 #define BWFM_SCANTYPE_PASSIVE		1
522 #define BWFM_SCANTYPE_DEFAULT		0xff
523 	uint32_t nprobes;
524 	uint32_t active_time;
525 	uint32_t passive_time;
526 	uint32_t home_time;
527 	uint32_t channel_num;
528 #define BWFM_CHANNUM_NSSID_SHIFT	16
529 #define BWFM_CHANNUM_NSSID_MASK		0xffff
530 #define BWFM_CHANNUM_NCHAN_SHIFT	0
531 #define BWFM_CHANNUM_NCHAN_MASK		0xffff
532 	uint16_t channel_list[];
533 };
534 
535 struct bwfm_scan_params_v2 {
536 	uint16_t version;
537 	uint16_t length;
538 	struct bwfm_ssid ssid;
539 	uint8_t bssid[ETHER_ADDR_LEN];
540 	uint8_t bss_type;
541 	uint8_t pad;
542 	uint32_t scan_type;
543 	uint32_t nprobes;
544 	uint32_t active_time;
545 	uint32_t passive_time;
546 	uint32_t home_time;
547 	uint32_t channel_num;
548 	uint16_t channel_list[];
549 };
550 
551 struct bwfm_scan_results {
552 	uint32_t buflen;
553 	uint32_t version;
554 	uint32_t count;
555 	struct bwfm_bss_info bss_info[];
556 };
557 
558 struct bwfm_escan_params_v0 {
559 	uint32_t version;
560 #define BWFM_ESCAN_REQ_VERSION		1
561 	uint16_t action;
562 #define WL_ESCAN_ACTION_START		1
563 #define WL_ESCAN_ACTION_CONTINUE	2
564 #define WL_ESCAN_ACTION_ABORT		3
565 	uint16_t sync_id;
566 	struct bwfm_scan_params_v0 scan_params;
567 };
568 
569 struct bwfm_escan_params_v2 {
570 	uint32_t version;
571 #define BWFM_ESCAN_REQ_VERSION_V2	2
572 	uint16_t action;
573 	uint16_t sync_id;
574 	struct bwfm_scan_params_v2 scan_params;
575 };
576 
577 struct bwfm_escan_results {
578 	uint32_t buflen;
579 	uint32_t version;
580 	uint16_t sync_id;
581 	uint16_t bss_count;
582 	struct bwfm_bss_info bss_info[];
583 };
584 
585 struct bwfm_assoc_params {
586 	uint8_t bssid[ETHER_ADDR_LEN];
587 	uint16_t pad;
588 	uint32_t chanspec_num;
589 	uint16_t chanspec_list[];
590 };
591 
592 struct bwfm_join_pref_params {
593 	uint8_t type;
594 #define BWFM_JOIN_PREF_RSSI		1
595 #define BWFM_JOIN_PREF_WPA		2
596 #define BWFM_JOIN_PREF_BAND		3
597 #define BWFM_JOIN_PREF_RSSI_DELTA	4
598 	uint8_t len;
599 	uint8_t rssi_gain;
600 #define BWFM_JOIN_PREF_RSSI_BOOST	8
601 	uint8_t band;
602 #define BWFM_JOIN_PREF_BAND_AUTO	0
603 #define BWFM_JOIN_PREF_BAND_5G		1
604 #define BWFM_JOIN_PREF_BAND_2G		2
605 #define BWFM_JOIN_PREF_BAND_ALL		3
606 };
607 
608 struct bwfm_join_params {
609 	struct bwfm_ssid ssid;
610 	struct bwfm_assoc_params assoc;
611 };
612 
613 struct bwfm_join_scan_params {
614 	uint8_t scan_type;
615 	uint8_t pad[3];
616 	uint32_t nprobes;
617 	uint32_t active_time;
618 	uint32_t passive_time;
619 	uint32_t home_time;
620 };
621 
622 struct bwfm_ext_join_params {
623 	struct bwfm_ssid ssid;
624 	struct bwfm_join_scan_params scan;
625 	struct bwfm_assoc_params assoc;
626 };
627 
628 struct bwfm_wsec_key {
629 	uint32_t index;
630 	uint32_t len;
631 	uint8_t data[32];
632 	uint32_t pad_1[18];
633 	uint32_t algo;
634 	uint32_t flags;
635 #define BWFM_WSEC_PRIMARY_KEY		(1 << 1)
636 	uint32_t pad_2[3];
637 	uint32_t iv_initialized;
638 	uint32_t pad_3;
639 	/* Rx IV */
640 	struct {
641 		uint32_t hi;
642 		uint16_t lo;
643 		uint16_t pad_4;
644 	} rxiv;
645 	uint32_t pad_5[2];
646 	uint8_t ea[ETHER_ADDR_LEN];
647 };
648 
649 struct bwfm_wsec_pmk {
650 	uint16_t key_len;
651 #define BWFM_WSEC_MAX_PSK_LEN		32
652 	uint16_t flags;
653 #define BWFM_WSEC_PASSPHRASE		(1 << 0)
654 	uint8_t key[2 * BWFM_WSEC_MAX_PSK_LEN + 1];
655 };
656 
657 /* Event handling */
658 enum bwfm_fweh_event_code {
659 	BWFM_E_SET_SSID = 0,
660 	BWFM_E_JOIN = 1,
661 	BWFM_E_START = 2,
662 	BWFM_E_AUTH = 3,
663 	BWFM_E_AUTH_IND = 4,
664 	BWFM_E_DEAUTH = 5,
665 	BWFM_E_DEAUTH_IND = 6,
666 	BWFM_E_ASSOC = 7,
667 	BWFM_E_ASSOC_IND = 8,
668 	BWFM_E_REASSOC = 9,
669 	BWFM_E_REASSOC_IND = 10,
670 	BWFM_E_DISASSOC = 11,
671 	BWFM_E_DISASSOC_IND = 12,
672 	BWFM_E_QUIET_START = 13,
673 	BWFM_E_QUIET_END = 14,
674 	BWFM_E_BEACON_RX = 15,
675 	BWFM_E_LINK = 16,
676 	BWFM_E_MIC_ERROR = 17,
677 	BWFM_E_NDIS_LINK = 18,
678 	BWFM_E_ROAM = 19,
679 	BWFM_E_TXFAIL = 20,
680 	BWFM_E_PMKID_CACHE = 21,
681 	BWFM_E_RETROGRADE_TSF = 22,
682 	BWFM_E_PRUNE = 23,
683 	BWFM_E_AUTOAUTH = 24,
684 	BWFM_E_EAPOL_MSG = 25,
685 	BWFM_E_SCAN_COMPLETE = 26,
686 	BWFM_E_ADDTS_IND = 27,
687 	BWFM_E_DELTS_IND = 28,
688 	BWFM_E_BCNSENT_IND = 29,
689 	BWFM_E_BCNRX_MSG = 30,
690 	BWFM_E_BCNLOST_MSG = 31,
691 	BWFM_E_ROAM_PREP = 32,
692 	BWFM_E_PFN_NET_FOUND = 33,
693 	BWFM_E_PFN_NET_LOST = 34,
694 	BWFM_E_RESET_COMPLETE = 35,
695 	BWFM_E_JOIN_START = 36,
696 	BWFM_E_ROAM_START = 37,
697 	BWFM_E_ASSOC_START = 38,
698 	BWFM_E_IBSS_ASSOC = 39,
699 	BWFM_E_RADIO = 40,
700 	BWFM_E_PSM_WATCHDOG = 41,
701 	BWFM_E_PROBREQ_MSG = 44,
702 	BWFM_E_SCAN_CONFIRM_IND = 45,
703 	BWFM_E_PSK_SUP = 46,
704 	BWFM_E_COUNTRY_CODE_CHANGED = 47,
705 	BWFM_E_EXCEEDED_MEDIUM_TIME = 48,
706 	BWFM_E_ICV_ERROR = 49,
707 	BWFM_E_UNICAST_DECODE_ERROR = 50,
708 	BWFM_E_MULTICAST_DECODE_ERROR = 51,
709 	BWFM_E_TRACE = 52,
710 	BWFM_E_IF = 54,
711 	BWFM_E_P2P_DISC_LISTEN_COMPLETE = 55,
712 	BWFM_E_RSSI = 56,
713 	BWFM_E_EXTLOG_MSG = 58,
714 	BWFM_E_ACTION_FRAME = 59,
715 	BWFM_E_ACTION_FRAME_COMPLETE = 60,
716 	BWFM_E_PRE_ASSOC_IND = 61,
717 	BWFM_E_PRE_REASSOC_IND = 62,
718 	BWFM_E_CHANNEL_ADOPTED = 63,
719 	BWFM_E_AP_STARTED = 64,
720 	BWFM_E_DFS_AP_STOP = 65,
721 	BWFM_E_DFS_AP_RESUME = 66,
722 	BWFM_E_ESCAN_RESULT = 69,
723 	BWFM_E_ACTION_FRAME_OFF_CHAN_COMPLETE = 70,
724 	BWFM_E_PROBERESP_MSG = 71,
725 	BWFM_E_P2P_PROBEREQ_MSG = 72,
726 	BWFM_E_DCS_REQUEST = 73,
727 	BWFM_E_FIFO_CREDIT_MAP = 74,
728 	BWFM_E_ACTION_FRAME_RX = 75,
729 	BWFM_E_TDLS_PEER_EVENT = 92,
730 	BWFM_E_BCMC_CREDIT_SUPPORT = 127,
731 	BWFM_E_LAST = 139
732 };
733 #define BWFM_EVENT_MASK_LEN		(roundup(BWFM_E_LAST, 8) / 8)
734 
735 enum bwfm_fweh_event_status {
736 	BWFM_E_STATUS_SUCCESS = 0,
737 	BWFM_E_STATUS_FAIL = 1,
738 	BWFM_E_STATUS_TIMEOUT = 2,
739 	BWFM_E_STATUS_NO_NETWORKS = 3,
740 	BWFM_E_STATUS_ABORT = 4,
741 	BWFM_E_STATUS_NO_ACK = 5,
742 	BWFM_E_STATUS_UNSOLICITED = 6,
743 	BWFM_E_STATUS_ATTEMPT = 7,
744 	BWFM_E_STATUS_PARTIAL = 8,
745 	BWFM_E_STATUS_NEWSCAN = 9,
746 	BWFM_E_STATUS_NEWASSOC = 10,
747 	BWFM_E_STATUS_11HQUIET = 11,
748 	BWFM_E_STATUS_SUPPRESS = 12,
749 	BWFM_E_STATUS_NOCHANS = 13,
750 	BWFM_E_STATUS_CS_ABORT = 15,
751 	BWFM_E_STATUS_ERROR = 16,
752 };
753 
754 struct bwfm_ethhdr {
755 	uint16_t subtype;
756 	uint16_t length;
757 	uint8_t version;
758 	uint8_t oui[3];
759 #define	BWFM_BRCM_OUI			"\x00\x10\x18"
760 	uint16_t usr_subtype;
761 #define	BWFM_BRCM_SUBTYPE_EVENT		1
762 } __packed;
763 
764 struct bwfm_event_msg {
765 	uint16_t version;
766 	uint16_t flags;
767 	uint32_t event_type;
768 	uint32_t status;
769 	uint32_t reason;
770 	uint32_t auth_type;
771 	uint32_t datalen;
772 	struct ether_addr addr;
773 	char ifname[IFNAMSIZ];
774 	uint8_t ifidx;
775 	uint8_t bsscfgidx;
776 } __packed;
777 
778 struct bwfm_event {
779 	struct ether_header ehdr;
780 #define BWFM_ETHERTYPE_LINK_CTL			0x886c
781 	struct bwfm_ethhdr hdr;
782 	struct bwfm_event_msg msg;
783 } __packed;
784 
785 struct bwfm_dload_data {
786 	uint16_t flag;
787 #define BWFM_DLOAD_FLAG_BEGIN			(1 << 1)
788 #define BWFM_DLOAD_FLAG_END			(1 << 2)
789 #define BWFM_DLOAD_FLAG_HANDLER_VER_1		(1 << 12)
790 #define BWFM_DLOAD_FLAG_HANDLER_VER_MASK	(0xf << 12)
791 	uint16_t type;
792 #define BWFM_DLOAD_TYPE_CLM			2
793 	uint32_t len;
794 #define BWFM_DLOAD_MAX_LEN			1400
795 	uint32_t crc;
796 	uint8_t data[];
797 } __packed;
798