xref: /freebsd/sys/net80211/_ieee80211.h (revision e0c4386e7e71d93b0edc0c8fa156263fc4a8b0b6)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2001 Atsushi Onoe
5  * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 #ifndef _NET80211__IEEE80211_H_
29 #define _NET80211__IEEE80211_H_
30 
31 /*
32  * 802.11 implementation definitions.
33  *
34  * NB: this file is used by applications.
35  */
36 
37 /*
38  * PHY type; mostly used to identify FH phys.
39  */
40 enum ieee80211_phytype {
41 	IEEE80211_T_DS,			/* direct sequence spread spectrum */
42 	IEEE80211_T_FH,			/* frequency hopping */
43 	IEEE80211_T_OFDM,		/* frequency division multiplexing */
44 	IEEE80211_T_TURBO,		/* high rate OFDM, aka turbo mode */
45 	IEEE80211_T_HT,			/* high throughput */
46 	IEEE80211_T_OFDM_HALF,		/* 1/2 rate OFDM */
47 	IEEE80211_T_OFDM_QUARTER,	/* 1/4 rate OFDM */
48 	IEEE80211_T_VHT,		/* VHT PHY */
49 };
50 #define	IEEE80211_T_CCK	IEEE80211_T_DS	/* more common nomenclature */
51 
52 /*
53  * PHY mode; this is not really a mode as multi-mode devices
54  * have multiple PHY's.  Mode is mostly used as a shorthand
55  * for constraining which channels to consider in setting up
56  * operation.  Modes used to be used more extensively when
57  * channels were identified as IEEE channel numbers.
58  */
59 enum ieee80211_phymode {
60 	IEEE80211_MODE_AUTO	= 0,	/* autoselect */
61 	IEEE80211_MODE_11A	= 1,	/* 5GHz, OFDM */
62 	IEEE80211_MODE_11B	= 2,	/* 2GHz, CCK */
63 	IEEE80211_MODE_11G	= 3,	/* 2GHz, OFDM */
64 	IEEE80211_MODE_FH	= 4,	/* 2GHz, GFSK */
65 	IEEE80211_MODE_TURBO_A	= 5,	/* 5GHz, OFDM, 2x clock */
66 	IEEE80211_MODE_TURBO_G	= 6,	/* 2GHz, OFDM, 2x clock */
67 	IEEE80211_MODE_STURBO_A	= 7,	/* 5GHz, OFDM, 2x clock, static */
68 	IEEE80211_MODE_11NA	= 8,	/* 5GHz, w/ HT */
69 	IEEE80211_MODE_11NG	= 9,	/* 2GHz, w/ HT */
70 	IEEE80211_MODE_HALF	= 10,	/* OFDM, 1/2x clock */
71 	IEEE80211_MODE_QUARTER	= 11,	/* OFDM, 1/4x clock */
72 	IEEE80211_MODE_VHT_2GHZ	= 12,	/* 2GHz, VHT */
73 	IEEE80211_MODE_VHT_5GHZ	= 13,	/* 5GHz, VHT */
74 };
75 #define	IEEE80211_MODE_MAX	(IEEE80211_MODE_VHT_5GHZ+1)
76 #define	IEEE80211_MODE_BYTES	howmany(IEEE80211_MODE_MAX, NBBY)
77 
78 /*
79  * Operating mode.  Devices do not necessarily support
80  * all modes; they indicate which are supported in their
81  * capabilities.
82  */
83 enum ieee80211_opmode {
84 	IEEE80211_M_IBSS 	= 0,	/* IBSS (adhoc) station */
85 	IEEE80211_M_STA		= 1,	/* infrastructure station */
86 	IEEE80211_M_WDS		= 2,	/* WDS link */
87 	IEEE80211_M_AHDEMO	= 3,	/* Old lucent compatible adhoc demo */
88 	IEEE80211_M_HOSTAP	= 4,	/* Software Access Point */
89 	IEEE80211_M_MONITOR	= 5,	/* Monitor mode */
90 	IEEE80211_M_MBSS	= 6,	/* MBSS (Mesh Point) link */
91 };
92 #define	IEEE80211_OPMODE_MAX	(IEEE80211_M_MBSS+1)
93 
94 /*
95  * 802.11g/802.11n protection mode.
96  */
97 enum ieee80211_protmode {
98 	IEEE80211_PROT_NONE	= 0,	/* no protection */
99 	IEEE80211_PROT_CTSONLY	= 1,	/* CTS to self */
100 	IEEE80211_PROT_RTSCTS	= 2,	/* RTS-CTS */
101 };
102 
103 /*
104  * Authentication mode.  The open and shared key authentication
105  * modes are implemented within the 802.11 layer.  802.1x and
106  * WPA/802.11i are implemented in user mode by setting the
107  * 802.11 layer into IEEE80211_AUTH_8021X and deferring
108  * authentication to user space programs.
109  */
110 enum ieee80211_authmode {
111 	IEEE80211_AUTH_NONE	= 0,
112 	IEEE80211_AUTH_OPEN	= 1,		/* open */
113 	IEEE80211_AUTH_SHARED	= 2,		/* shared-key */
114 	IEEE80211_AUTH_8021X	= 3,		/* 802.1x */
115 	IEEE80211_AUTH_AUTO	= 4,		/* auto-select/accept */
116 	/* NB: these are used only for ioctls */
117 	IEEE80211_AUTH_WPA	= 5,		/* WPA/RSN w/ 802.1x/PSK */
118 };
119 
120 /*
121  * Roaming mode is effectively who controls the operation
122  * of the 802.11 state machine when operating as a station.
123  * State transitions are controlled either by the driver
124  * (typically when management frames are processed by the
125  * hardware/firmware), the host (auto/normal operation of
126  * the 802.11 layer), or explicitly through ioctl requests
127  * when applications like wpa_supplicant want control.
128  */
129 enum ieee80211_roamingmode {
130 	IEEE80211_ROAMING_DEVICE= 0,	/* driver/hardware control */
131 	IEEE80211_ROAMING_AUTO	= 1,	/* 802.11 layer control */
132 	IEEE80211_ROAMING_MANUAL= 2,	/* application control */
133 };
134 
135 /*
136  * Channels are specified by frequency and attributes.
137  */
138 struct ieee80211_channel {
139 	uint32_t	ic_flags;	/* see below */
140 	uint16_t	ic_freq;	/* primary centre frequency in MHz */
141 	uint8_t		ic_ieee;	/* IEEE channel number */
142 	int8_t		ic_maxregpower;	/* maximum regulatory tx power in dBm */
143 	int8_t		ic_maxpower;	/* maximum tx power in .5 dBm */
144 	int8_t		ic_minpower;	/* minimum tx power in .5 dBm */
145 	uint8_t		ic_state;	/* dynamic state */
146 	uint8_t		ic_extieee;	/* HT40 extension channel number */
147 	int8_t		ic_maxantgain;	/* maximum antenna gain in .5 dBm */
148 	uint8_t		ic_pad;
149 	uint16_t	ic_devdata;	/* opaque device/driver data */
150 	uint8_t		ic_vht_ch_freq1; /* VHT primary freq1 IEEE value */
151 	uint8_t		ic_vht_ch_freq2; /* VHT secondary 80MHz freq2 IEEE value */
152 	uint16_t	ic_freq2;	/* VHT secondary 80MHz freq2 MHz */
153 };
154 
155 /*
156  * Note: for VHT operation we will need significantly more than
157  * IEEE80211_CHAN_MAX channels because of the combinations of
158  * VHT20, VHT40, VHT80, VHT160, and VHT80+80.
159  */
160 #define	IEEE80211_CHAN_MAX	1024
161 #define	IEEE80211_CHAN_BYTES	howmany(IEEE80211_CHAN_MAX, NBBY)
162 #define	IEEE80211_CHAN_ANY	0xffff	/* token for ``any channel'' */
163 #define	IEEE80211_CHAN_ANYC \
164 	((struct ieee80211_channel *) IEEE80211_CHAN_ANY)
165 
166 /* channel attributes */
167 #define	IEEE80211_CHAN_PRIV0	0x00000001 /* driver private bit 0 */
168 #define	IEEE80211_CHAN_PRIV1	0x00000002 /* driver private bit 1 */
169 #define	IEEE80211_CHAN_PRIV2	0x00000004 /* driver private bit 2 */
170 #define	IEEE80211_CHAN_PRIV3	0x00000008 /* driver private bit 3 */
171 #define	IEEE80211_CHAN_TURBO	0x00000010 /* Turbo channel */
172 #define	IEEE80211_CHAN_CCK	0x00000020 /* CCK channel */
173 #define	IEEE80211_CHAN_OFDM	0x00000040 /* OFDM channel */
174 #define	IEEE80211_CHAN_2GHZ	0x00000080 /* 2 GHz spectrum channel. */
175 #define	IEEE80211_CHAN_5GHZ	0x00000100 /* 5 GHz spectrum channel */
176 #define	IEEE80211_CHAN_PASSIVE	0x00000200 /* Only passive scan allowed */
177 #define	IEEE80211_CHAN_DYN	0x00000400 /* Dynamic CCK-OFDM channel */
178 #define	IEEE80211_CHAN_GFSK	0x00000800 /* GFSK channel (FHSS PHY) */
179 #define	IEEE80211_CHAN_GSM	0x00001000 /* 900 MHz spectrum channel */
180 #define	IEEE80211_CHAN_STURBO	0x00002000 /* 11a static turbo channel only */
181 #define	IEEE80211_CHAN_HALF	0x00004000 /* Half rate channel */
182 #define	IEEE80211_CHAN_QUARTER	0x00008000 /* Quarter rate channel */
183 #define	IEEE80211_CHAN_HT20	0x00010000 /* HT 20 channel */
184 #define	IEEE80211_CHAN_HT40U	0x00020000 /* HT 40 channel w/ ext above */
185 #define	IEEE80211_CHAN_HT40D	0x00040000 /* HT 40 channel w/ ext below */
186 #define	IEEE80211_CHAN_DFS	0x00080000 /* DFS required */
187 #define	IEEE80211_CHAN_4MSXMIT	0x00100000 /* 4ms limit on frame length */
188 #define	IEEE80211_CHAN_NOADHOC	0x00200000 /* adhoc mode not allowed */
189 #define	IEEE80211_CHAN_NOHOSTAP	0x00400000 /* hostap mode not allowed */
190 #define	IEEE80211_CHAN_11D	0x00800000 /* 802.11d required */
191 #define	IEEE80211_CHAN_VHT20	0x01000000 /* VHT20 channel */
192 #define	IEEE80211_CHAN_VHT40U	0x02000000 /* VHT40 channel, ext above */
193 #define	IEEE80211_CHAN_VHT40D	0x04000000 /* VHT40 channel, ext below */
194 #define	IEEE80211_CHAN_VHT80	0x08000000 /* VHT80 channel */
195 #define	IEEE80211_CHAN_VHT160	0x10000000 /* VHT160 channel */
196 #define	IEEE80211_CHAN_VHT80P80	0x20000000 /* VHT80+80 channel */
197 /* XXX note: 0x80000000 is used in src/sbin/ifconfig/ifieee80211.c :( */
198 
199 #define	IEEE80211_CHAN_HT40	(IEEE80211_CHAN_HT40U | IEEE80211_CHAN_HT40D)
200 #define	IEEE80211_CHAN_HT	(IEEE80211_CHAN_HT20 | IEEE80211_CHAN_HT40)
201 
202 #define	IEEE80211_CHAN_VHT40	(IEEE80211_CHAN_VHT40U | IEEE80211_CHAN_VHT40D)
203 #define	IEEE80211_CHAN_VHT	(IEEE80211_CHAN_VHT20 | IEEE80211_CHAN_VHT40 \
204 				| IEEE80211_CHAN_VHT80 | IEEE80211_CHAN_VHT160 \
205 				| IEEE80211_CHAN_VHT80P80)
206 
207 #define	IEEE80211_CHAN_BITS \
208 	"\20\1PRIV0\2PRIV2\3PRIV3\4PRIV4\5TURBO\6CCK\7OFDM\0102GHZ\0115GHZ" \
209 	"\12PASSIVE\13DYN\14GFSK\15GSM\16STURBO\17HALF\20QUARTER\21HT20" \
210 	"\22HT40U\23HT40D\24DFS\0254MSXMIT\26NOADHOC\27NOHOSTAP\03011D" \
211 	"\031VHT20\032VHT40U\033VHT40D\034VHT80\035VHT160\036VHT80P80"
212 
213 /*
214  * Useful combinations of channel characteristics.
215  */
216 #define	IEEE80211_CHAN_FHSS \
217 	(IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_GFSK)
218 #define	IEEE80211_CHAN_A \
219 	(IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM)
220 #define	IEEE80211_CHAN_B \
221 	(IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_CCK)
222 #define	IEEE80211_CHAN_PUREG \
223 	(IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_OFDM)
224 #define	IEEE80211_CHAN_G \
225 	(IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN)
226 #define IEEE80211_CHAN_108A \
227 	(IEEE80211_CHAN_A | IEEE80211_CHAN_TURBO)
228 #define	IEEE80211_CHAN_108G \
229 	(IEEE80211_CHAN_PUREG | IEEE80211_CHAN_TURBO)
230 #define	IEEE80211_CHAN_ST \
231 	(IEEE80211_CHAN_108A | IEEE80211_CHAN_STURBO)
232 
233 #define	IEEE80211_CHAN_ALL \
234 	(IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_GFSK | \
235 	 IEEE80211_CHAN_CCK | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_DYN | \
236 	 IEEE80211_CHAN_HALF | IEEE80211_CHAN_QUARTER | \
237 	 IEEE80211_CHAN_HT | IEEE80211_CHAN_VHT)
238 #define	IEEE80211_CHAN_ALLTURBO \
239 	(IEEE80211_CHAN_ALL | IEEE80211_CHAN_TURBO | IEEE80211_CHAN_STURBO)
240 
241 #define	IEEE80211_IS_CHAN_FHSS(_c) \
242 	(((_c)->ic_flags & IEEE80211_CHAN_FHSS) == IEEE80211_CHAN_FHSS)
243 #define	IEEE80211_IS_CHAN_A(_c) \
244 	(((_c)->ic_flags & IEEE80211_CHAN_A) == IEEE80211_CHAN_A)
245 #define	IEEE80211_IS_CHAN_B(_c) \
246 	(((_c)->ic_flags & IEEE80211_CHAN_B) == IEEE80211_CHAN_B)
247 #define	IEEE80211_IS_CHAN_PUREG(_c) \
248 	(((_c)->ic_flags & IEEE80211_CHAN_PUREG) == IEEE80211_CHAN_PUREG)
249 #define	IEEE80211_IS_CHAN_G(_c) \
250 	(((_c)->ic_flags & IEEE80211_CHAN_G) == IEEE80211_CHAN_G)
251 #define	IEEE80211_IS_CHAN_ANYG(_c) \
252 	(IEEE80211_IS_CHAN_PUREG(_c) || IEEE80211_IS_CHAN_G(_c))
253 #define	IEEE80211_IS_CHAN_ST(_c) \
254 	(((_c)->ic_flags & IEEE80211_CHAN_ST) == IEEE80211_CHAN_ST)
255 #define	IEEE80211_IS_CHAN_108A(_c) \
256 	(((_c)->ic_flags & IEEE80211_CHAN_108A) == IEEE80211_CHAN_108A)
257 #define	IEEE80211_IS_CHAN_108G(_c) \
258 	(((_c)->ic_flags & IEEE80211_CHAN_108G) == IEEE80211_CHAN_108G)
259 
260 #define	IEEE80211_IS_CHAN_2GHZ(_c) \
261 	(((_c)->ic_flags & IEEE80211_CHAN_2GHZ) != 0)
262 #define	IEEE80211_IS_CHAN_5GHZ(_c) \
263 	(((_c)->ic_flags & IEEE80211_CHAN_5GHZ) != 0)
264 #define	IEEE80211_IS_CHAN_PASSIVE(_c) \
265 	(((_c)->ic_flags & IEEE80211_CHAN_PASSIVE) != 0)
266 #define	IEEE80211_IS_CHAN_OFDM(_c) \
267 	(((_c)->ic_flags & (IEEE80211_CHAN_OFDM | IEEE80211_CHAN_DYN)) != 0)
268 #define	IEEE80211_IS_CHAN_CCK(_c) \
269 	(((_c)->ic_flags & (IEEE80211_CHAN_CCK | IEEE80211_CHAN_DYN)) != 0)
270 #define	IEEE80211_IS_CHAN_DYN(_c) \
271 	(((_c)->ic_flags & IEEE80211_CHAN_DYN) == IEEE80211_CHAN_DYN)
272 #define	IEEE80211_IS_CHAN_GFSK(_c) \
273 	(((_c)->ic_flags & IEEE80211_CHAN_GFSK) != 0)
274 #define	IEEE80211_IS_CHAN_TURBO(_c) \
275 	(((_c)->ic_flags & IEEE80211_CHAN_TURBO) != 0)
276 #define	IEEE80211_IS_CHAN_STURBO(_c) \
277 	(((_c)->ic_flags & IEEE80211_CHAN_STURBO) != 0)
278 #define	IEEE80211_IS_CHAN_DTURBO(_c) \
279 	(((_c)->ic_flags & \
280 	(IEEE80211_CHAN_TURBO | IEEE80211_CHAN_STURBO)) == IEEE80211_CHAN_TURBO)
281 #define	IEEE80211_IS_CHAN_HALF(_c) \
282 	(((_c)->ic_flags & IEEE80211_CHAN_HALF) != 0)
283 #define	IEEE80211_IS_CHAN_QUARTER(_c) \
284 	(((_c)->ic_flags & IEEE80211_CHAN_QUARTER) != 0)
285 #define	IEEE80211_IS_CHAN_FULL(_c) \
286 	(((_c)->ic_flags & (IEEE80211_CHAN_QUARTER | IEEE80211_CHAN_HALF)) == 0)
287 #define	IEEE80211_IS_CHAN_GSM(_c) \
288 	(((_c)->ic_flags & IEEE80211_CHAN_GSM) != 0)
289 #define	IEEE80211_IS_CHAN_HT(_c) \
290 	(((_c)->ic_flags & IEEE80211_CHAN_HT) != 0)
291 #define	IEEE80211_IS_CHAN_HT20(_c) \
292 	(((_c)->ic_flags & IEEE80211_CHAN_HT20) != 0)
293 #define	IEEE80211_IS_CHAN_HT40(_c) \
294 	(((_c)->ic_flags & IEEE80211_CHAN_HT40) != 0)
295 #define	IEEE80211_IS_CHAN_HT40U(_c) \
296 	(((_c)->ic_flags & IEEE80211_CHAN_HT40U) != 0)
297 #define	IEEE80211_IS_CHAN_HT40D(_c) \
298 	(((_c)->ic_flags & IEEE80211_CHAN_HT40D) != 0)
299 #define	IEEE80211_IS_CHAN_HTA(_c) \
300 	(IEEE80211_IS_CHAN_5GHZ(_c) && \
301 	 ((_c)->ic_flags & IEEE80211_CHAN_HT) != 0)
302 #define	IEEE80211_IS_CHAN_HTG(_c) \
303 	(IEEE80211_IS_CHAN_2GHZ(_c) && \
304 	 ((_c)->ic_flags & IEEE80211_CHAN_HT) != 0)
305 #define	IEEE80211_IS_CHAN_DFS(_c) \
306 	(((_c)->ic_flags & IEEE80211_CHAN_DFS) != 0)
307 #define	IEEE80211_IS_CHAN_NOADHOC(_c) \
308 	(((_c)->ic_flags & IEEE80211_CHAN_NOADHOC) != 0)
309 #define	IEEE80211_IS_CHAN_NOHOSTAP(_c) \
310 	(((_c)->ic_flags & IEEE80211_CHAN_NOHOSTAP) != 0)
311 #define	IEEE80211_IS_CHAN_11D(_c) \
312 	(((_c)->ic_flags & IEEE80211_CHAN_11D) != 0)
313 
314 #define	IEEE80211_IS_CHAN_VHT(_c) \
315 	(((_c)->ic_flags & IEEE80211_CHAN_VHT) != 0)
316 #define	IEEE80211_IS_CHAN_VHT_2GHZ(_c) \
317 	(IEEE80211_IS_CHAN_2GHZ(_c) && \
318 	 ((_c)->ic_flags & IEEE80211_CHAN_VHT) != 0)
319 #define	IEEE80211_IS_CHAN_VHT_5GHZ(_c) \
320 	(IEEE80211_IS_CHAN_5GHZ(_c) && \
321 	 ((_c)->ic_flags & IEEE80211_CHAN_VHT) != 0)
322 #define	IEEE80211_IS_CHAN_VHT20(_c) \
323 	(((_c)->ic_flags & IEEE80211_CHAN_VHT20) != 0)
324 #define	IEEE80211_IS_CHAN_VHT40(_c) \
325 	(((_c)->ic_flags & IEEE80211_CHAN_VHT40) != 0)
326 #define	IEEE80211_IS_CHAN_VHT40U(_c) \
327 	(((_c)->ic_flags & IEEE80211_CHAN_VHT40U) != 0)
328 #define	IEEE80211_IS_CHAN_VHT40D(_c) \
329 	(((_c)->ic_flags & IEEE80211_CHAN_VHT40D) != 0)
330 #define	IEEE80211_IS_CHAN_VHTA(_c) \
331 	(IEEE80211_IS_CHAN_5GHZ(_c) && \
332 	 ((_c)->ic_flags & IEEE80211_CHAN_VHT) != 0)
333 #define	IEEE80211_IS_CHAN_VHTG(_c) \
334 	(IEEE80211_IS_CHAN_2GHZ(_c) && \
335 	 ((_c)->ic_flags & IEEE80211_CHAN_VHT) != 0)
336 #define	IEEE80211_IS_CHAN_VHT80(_c) \
337 	(((_c)->ic_flags & IEEE80211_CHAN_VHT80) != 0)
338 #define	IEEE80211_IS_CHAN_VHT160(_c) \
339 	(((_c)->ic_flags & IEEE80211_CHAN_VHT160) != 0)
340 #define	IEEE80211_IS_CHAN_VHT80P80(_c) \
341 	(((_c)->ic_flags & IEEE80211_CHAN_VHT80P80) != 0)
342 
343 #define	IEEE80211_CHAN2IEEE(_c)		(_c)->ic_ieee
344 
345 /* dynamic state */
346 #define	IEEE80211_CHANSTATE_RADAR	0x01	/* radar detected */
347 #define	IEEE80211_CHANSTATE_CACDONE	0x02	/* CAC completed */
348 #define	IEEE80211_CHANSTATE_CWINT	0x04	/* interference detected */
349 #define	IEEE80211_CHANSTATE_NORADAR	0x10	/* post notify on radar clear */
350 
351 #define	IEEE80211_IS_CHAN_RADAR(_c) \
352 	(((_c)->ic_state & IEEE80211_CHANSTATE_RADAR) != 0)
353 #define	IEEE80211_IS_CHAN_CACDONE(_c) \
354 	(((_c)->ic_state & IEEE80211_CHANSTATE_CACDONE) != 0)
355 #define	IEEE80211_IS_CHAN_CWINT(_c) \
356 	(((_c)->ic_state & IEEE80211_CHANSTATE_CWINT) != 0)
357 
358 /* ni_chan encoding for FH phy */
359 #define	IEEE80211_FH_CHANMOD	80
360 #define	IEEE80211_FH_CHAN(set,pat)	(((set)-1)*IEEE80211_FH_CHANMOD+(pat))
361 #define	IEEE80211_FH_CHANSET(chan)	((chan)/IEEE80211_FH_CHANMOD+1)
362 #define	IEEE80211_FH_CHANPAT(chan)	((chan)%IEEE80211_FH_CHANMOD)
363 
364 #define	IEEE80211_TID_SIZE	(WME_NUM_TID+1)	/* WME TID's +1 for non-QoS */
365 #define	IEEE80211_NONQOS_TID	WME_NUM_TID	/* index for non-QoS sta */
366 
367 /*
368  * The 802.11 spec says at most 2007 stations may be
369  * associated at once.  For most AP's this is way more
370  * than is feasible so we use a default of 128.  This
371  * number may be overridden by the driver and/or by
372  * user configuration but may not be less than IEEE80211_AID_MIN.
373  */
374 #define	IEEE80211_AID_DEF		128
375 #define	IEEE80211_AID_MIN		16
376 
377 /*
378  * 802.11 rate set.
379  */
380 #define	IEEE80211_RATE_SIZE	8		/* 802.11 standard */
381 #define	IEEE80211_RATE_MAXSIZE	15		/* max rates we'll handle */
382 
383 struct ieee80211_rateset {
384 	uint8_t		rs_nrates;
385 	uint8_t		rs_rates[IEEE80211_RATE_MAXSIZE];
386 };
387 
388 /*
389  * 802.11n variant of ieee80211_rateset.  Instead of
390  * legacy rates the entries are MCS rates.  We define
391  * the structure such that it can be used interchangeably
392  * with an ieee80211_rateset (modulo structure size).
393  */
394 #define	IEEE80211_HTRATE_MAXSIZE	77
395 
396 struct ieee80211_htrateset {
397 	uint8_t		rs_nrates;
398 	uint8_t		rs_rates[IEEE80211_HTRATE_MAXSIZE];
399 };
400 
401 #define	IEEE80211_RATE_MCS	0x80
402 
403 /*
404  * Per-mode transmit parameters/controls visible to user space.
405  * These can be used to set fixed transmit rate for all operating
406  * modes or on a per-client basis according to the capabilities
407  * of the client (e.g. an 11b client associated to an 11g ap).
408  *
409  * MCS are distinguished from legacy rates by or'ing in 0x80.
410  */
411 struct ieee80211_txparam {
412 	uint8_t		ucastrate;	/* ucast data rate (legacy/MCS|0x80) */
413 	uint8_t		mgmtrate;	/* mgmt frame rate (legacy/MCS|0x80) */
414 	uint8_t		mcastrate;	/* multicast rate (legacy/MCS|0x80) */
415 	uint8_t		maxretry;	/* max unicast data retry count */
416 };
417 
418 /*
419  * Per-mode roaming state visible to user space.  There are two
420  * thresholds that control whether roaming is considered; when
421  * either is exceeded the 802.11 layer will check the scan cache
422  * for another AP.  If the cache is stale then a scan may be
423  * triggered.
424  */
425 struct ieee80211_roamparam {
426 	int8_t		rssi;		/* rssi thresh (.5 dBm) */
427 	uint8_t		rate;		/* tx rate thresh (.5 Mb/s or MCS) */
428 	uint16_t	pad;		/* reserve */
429 };
430 
431 /*
432  * Regulatory Information.
433  */
434 struct ieee80211_regdomain {
435 	uint16_t	regdomain;	/* SKU */
436 	uint16_t	country;	/* ISO country code */
437 	uint8_t		location;	/* I (indoor), O (outdoor), other */
438 	uint8_t		ecm;		/* Extended Channel Mode */
439 	char		isocc[2];	/* country code string */
440 	short		pad[2];
441 };
442 
443 /*
444  * MIMO antenna/radio state.
445  */
446 #define	IEEE80211_MAX_CHAINS		4
447 /*
448  * This is the number of sub-channels for a channel.
449  * 0 - pri20
450  * 1 - sec20 (HT40, VHT40)
451  * 2 - sec40 (VHT80)
452  * 3 - sec80 (VHT80+80, VHT160)
453  */
454 #define	IEEE80211_MAX_CHAIN_PRISEC	4
455 #define	IEEE80211_MAX_EVM_DWORDS	16	/* 16 pilots, 4 chains */
456 #define	IEEE80211_MAX_EVM_PILOTS	16	/* 468 subcarriers, 16 pilots */
457 
458 struct ieee80211_mimo_chan_info {
459 	int8_t	rssi[IEEE80211_MAX_CHAIN_PRISEC];
460 	int8_t	noise[IEEE80211_MAX_CHAIN_PRISEC];
461 };
462 
463 struct ieee80211_mimo_info {
464 	struct ieee80211_mimo_chan_info ch[IEEE80211_MAX_CHAINS];
465 	uint32_t	evm[IEEE80211_MAX_EVM_DWORDS];
466 };
467 
468 /*
469  * ic_caps/iv_caps: device driver capabilities
470  */
471 /* 0x2e available */
472 #define	IEEE80211_C_STA		0x00000001	/* CAPABILITY: STA available */
473 #define	IEEE80211_C_8023ENCAP	0x00000002	/* CAPABILITY: 802.3 encap */
474 #define	IEEE80211_C_FF		0x00000040	/* CAPABILITY: ATH FF avail */
475 #define	IEEE80211_C_TURBOP	0x00000080	/* CAPABILITY: ATH Turbo avail*/
476 #define	IEEE80211_C_IBSS	0x00000100	/* CAPABILITY: IBSS available */
477 #define	IEEE80211_C_PMGT	0x00000200	/* CAPABILITY: Power mgmt */
478 #define	IEEE80211_C_HOSTAP	0x00000400	/* CAPABILITY: HOSTAP avail */
479 #define	IEEE80211_C_AHDEMO	0x00000800	/* CAPABILITY: Old Adhoc Demo */
480 #define	IEEE80211_C_SWRETRY	0x00001000	/* CAPABILITY: sw tx retry */
481 #define	IEEE80211_C_TXPMGT	0x00002000	/* CAPABILITY: tx power mgmt */
482 #define	IEEE80211_C_SHSLOT	0x00004000	/* CAPABILITY: short slottime */
483 #define	IEEE80211_C_SHPREAMBLE	0x00008000	/* CAPABILITY: short preamble */
484 #define	IEEE80211_C_MONITOR	0x00010000	/* CAPABILITY: monitor mode */
485 #define	IEEE80211_C_DFS		0x00020000	/* CAPABILITY: DFS/radar avail*/
486 #define	IEEE80211_C_MBSS	0x00040000	/* CAPABILITY: MBSS available */
487 #define	IEEE80211_C_SWSLEEP	0x00080000	/* CAPABILITY: do sleep here */
488 #define	IEEE80211_C_SWAMSDUTX	0x00100000	/* CAPABILITY: software A-MSDU TX */
489 #define	IEEE80211_C_UAPSD	0x00200000	/* CAPABILITY: U-APSD */
490 /* 0x7c0000 available */
491 #define	IEEE80211_C_WPA1	0x00800000	/* CAPABILITY: WPA1 avail */
492 #define	IEEE80211_C_WPA2	0x01000000	/* CAPABILITY: WPA2 avail */
493 #define	IEEE80211_C_WPA		0x01800000	/* CAPABILITY: WPA1+WPA2 avail*/
494 #define	IEEE80211_C_BURST	0x02000000	/* CAPABILITY: frame bursting */
495 #define	IEEE80211_C_WME		0x04000000	/* CAPABILITY: WME avail */
496 #define	IEEE80211_C_WDS		0x08000000	/* CAPABILITY: 4-addr support */
497 /* 0x10000000 reserved */
498 #define	IEEE80211_C_BGSCAN	0x20000000	/* CAPABILITY: bg scanning */
499 #define	IEEE80211_C_TXFRAG	0x40000000	/* CAPABILITY: tx fragments */
500 #define	IEEE80211_C_TDMA	0x80000000	/* CAPABILITY: TDMA avail */
501 /* XXX protection/barker? */
502 
503 #define	IEEE80211_C_OPMODE \
504 	(IEEE80211_C_STA | IEEE80211_C_IBSS | IEEE80211_C_HOSTAP | \
505 	 IEEE80211_C_AHDEMO | IEEE80211_C_MONITOR | IEEE80211_C_WDS | \
506 	 IEEE80211_C_TDMA | IEEE80211_C_MBSS)
507 
508 #define	IEEE80211_C_BITS \
509 	"\20\1STA\002803ENCAP\7FF\10TURBOP\11IBSS\12PMGT" \
510 	"\13HOSTAP\14AHDEMO\15SWRETRY\16TXPMGT\17SHSLOT\20SHPREAMBLE" \
511 	"\21MONITOR\22DFS\23MBSS\30WPA1\31WPA2\32BURST\33WME\34WDS\36BGSCAN" \
512 	"\37TXFRAG\40TDMA"
513 
514 /*
515  * ic_htcaps/iv_htcaps: HT-specific device/driver capabilities
516  *
517  * NB: the low 16-bits are the 802.11 definitions, the upper
518  *     16-bits are used to define s/w/driver capabilities.
519  */
520 #define	IEEE80211_HTC_AMPDU	0x00010000	/* CAPABILITY: A-MPDU tx */
521 #define	IEEE80211_HTC_AMSDU	0x00020000	/* CAPABILITY: A-MSDU tx */
522 /* NB: HT40 is implied by IEEE80211_HTCAP_CHWIDTH40 */
523 #define	IEEE80211_HTC_HT	0x00040000	/* CAPABILITY: HT operation */
524 #define	IEEE80211_HTC_SMPS	0x00080000	/* CAPABILITY: MIMO power save*/
525 #define	IEEE80211_HTC_RIFS	0x00100000	/* CAPABILITY: RIFS support */
526 #define	IEEE80211_HTC_RXUNEQUAL	0x00200000	/* CAPABILITY: RX unequal MCS */
527 #define	IEEE80211_HTC_RXMCS32	0x00400000	/* CAPABILITY: MCS32 support */
528 #define	IEEE80211_HTC_TXUNEQUAL	0x00800000	/* CAPABILITY: TX unequal MCS */
529 #define	IEEE80211_HTC_TXMCS32	0x01000000	/* CAPABILITY: MCS32 support */
530 #define	IEEE80211_HTC_TXLDPC	0x02000000	/* CAPABILITY: TX using LDPC */
531 #define	IEEE80211_HTC_RX_AMSDU_AMPDU	0x04000000	/* CAPABILITY: RX A-MSDU in A-MPDU */
532 #define	IEEE80211_HTC_TX_AMSDU_AMPDU	0x08000000	/* CAPABILITY: TX A-MSDU in A-MPDU */
533 
534 #define	IEEE80211_C_HTCAP_BITS \
535 	"\20\1LDPC\2CHWIDTH40\5GREENFIELD\6SHORTGI20\7SHORTGI40\10TXSTBC" \
536 	"\21AMPDU\22AMSDU\23HT\24SMPS\25RIFS\32TXLDPC\33RXAMSDUAMPDU" \
537 	"\34TXAMSDUAMPDU"
538 
539 /*
540  * RX status notification - which fields are valid.
541  */
542 #define	IEEE80211_R_NF		0x00000001	/* global NF value valid */
543 #define	IEEE80211_R_RSSI	0x00000002	/* global RSSI value valid */
544 #define	IEEE80211_R_C_CHAIN	0x00000004	/* RX chain count valid */
545 #define	IEEE80211_R_C_NF	0x00000008	/* per-chain NF value valid */
546 #define	IEEE80211_R_C_RSSI	0x00000010	/* per-chain RSSI value valid */
547 #define	IEEE80211_R_C_EVM	0x00000020	/* per-chain EVM valid */
548 #define	IEEE80211_R_C_HT40	0x00000040	/* RX'ed packet is 40mhz, pilots 4,5 valid */
549 #define	IEEE80211_R_FREQ	0x00000080	/* Freq value populated, MHz */
550 #define	IEEE80211_R_IEEE	0x00000100	/* IEEE value populated */
551 #define	IEEE80211_R_BAND	0x00000200	/* Frequency band populated */
552 #define	IEEE80211_R_TSF32	0x00004000	/* 32 bit TSF */
553 #define	IEEE80211_R_TSF64	0x00008000	/* 64 bit TSF */
554 #define	IEEE80211_R_TSF_START	0x00010000	/* TSF is sampled at start of frame */
555 #define	IEEE80211_R_TSF_END	0x00020000	/* TSF is sampled at end of frame */
556 
557 /*
558  * RX status notification - describe the packet.
559  */
560 #define	IEEE80211_RX_F_STBC		0x00000001
561 #define	IEEE80211_RX_F_LDPC		0x00000002
562 #define	IEEE80211_RX_F_AMSDU		0x00000004 /* This is the start of an decap AMSDU list */
563 #define	IEEE80211_RX_F_AMSDU_MORE	0x00000008 /* This is another decap AMSDU frame in the batch */
564 #define	IEEE80211_RX_F_AMPDU		0x00000010 /* This is the start of an decap AMPDU list */
565 #define	IEEE80211_RX_F_AMPDU_MORE	0x00000020 /* This is another decap AMPDU frame in the batch */
566 #define	IEEE80211_RX_F_FAIL_FCSCRC	0x00000040 /* Failed CRC/FCS */
567 #define	IEEE80211_RX_F_FAIL_MIC		0x00000080 /* Failed MIC check */
568 #define	IEEE80211_RX_F_DECRYPTED	0x00000100 /* Hardware decrypted */
569 #define	IEEE80211_RX_F_IV_STRIP		0x00000200 /* Decrypted; IV stripped */
570 #define	IEEE80211_RX_F_MMIC_STRIP	0x00000400 /* Decrypted; MMIC stripped */
571 #define	IEEE80211_RX_F_SHORTGI		0x00000800 /* This is a short-GI frame */
572 #define	IEEE80211_RX_F_CCK		0x00001000
573 #define	IEEE80211_RX_F_OFDM		0x00002000
574 #define	IEEE80211_RX_F_HT		0x00004000
575 #define	IEEE80211_RX_F_VHT		0x00008000
576 
577 /* Channel width */
578 #define	IEEE80211_RX_FW_20MHZ		1
579 #define	IEEE80211_RX_FW_40MHZ		2
580 #define	IEEE80211_RX_FW_80MHZ		3
581 #define	IEEE80211_RX_FW_160MHZ		4
582 
583 /* PHY type */
584 #define	IEEE80211_RX_FP_11B		1
585 #define	IEEE80211_RX_FP_11G		2
586 #define	IEEE80211_RX_FP_11A		3
587 #define	IEEE80211_RX_FP_11NA		4
588 #define	IEEE80211_RX_FP_11NG		5
589 
590 struct ieee80211_rx_stats {
591 	uint32_t r_flags;		/* IEEE80211_R_* flags */
592 	uint32_t c_pktflags;		/* IEEE80211_RX_F_* flags */
593 
594 	uint64_t c_rx_tsf;		/* 32 or 64 bit TSF */
595 
596 	/* All DWORD aligned */
597 	int16_t c_nf_ctl[IEEE80211_MAX_CHAINS];	/* per-chain NF */
598 	int16_t c_nf_ext[IEEE80211_MAX_CHAINS];	/* per-chain NF */
599 	int16_t c_rssi_ctl[IEEE80211_MAX_CHAINS];	/* per-chain RSSI */
600 	int16_t c_rssi_ext[IEEE80211_MAX_CHAINS];	/* per-chain RSSI */
601 
602 	/* 32 bits */
603 	int8_t c_nf;			/* global NF */
604 	int8_t c_rssi;			/* global RSSI */
605 	uint8_t c_chain;		/* number of RX chains involved */
606 	uint8_t c_rate;			/* legacy; 11n rate code; VHT MCS */
607 
608 	/* 32 bits */
609 	uint16_t c_freq;		/* Frequency, MHz */
610 	uint8_t c_ieee;			/* Channel */
611 	uint8_t c_width;		/* channel width, FW flags above */
612 
613 	/* 32 bits */
614 	uint32_t c_band;		/* Band; XXX we do not have a real band. */
615 
616 	/* Force alignment to DWORD */
617 	union {
618 		uint8_t evm[IEEE80211_MAX_CHAINS][IEEE80211_MAX_EVM_PILOTS];
619 		    /* per-chain, per-pilot EVM values */
620 		uint32_t __aln[8];
621 	} evm;
622 
623 	/* 32 bits */
624 	uint8_t c_phytype;		/* PHY type, FW flags above */
625 	uint8_t c_vhtnss;		/* VHT - number of spatial streams */
626 	uint8_t c_pad2[2];
627 };
628 
629 struct ieee80211_rx_params {
630 	struct ieee80211_rx_stats params;
631 };
632 
633 #endif /* _NET80211__IEEE80211_H_ */
634