xref: /illumos-gate/usr/src/uts/common/sys/net80211.h (revision 69a119caa6570c7077699161b7c28b6ee9f8b0f4)
1 /*
2  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 /*
7  * Copyright (c) 2001 Atsushi Onoe
8  * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  * 3. The name of the author may not be used to endorse or promote products
20  *    derived from this software without specific prior written permission.
21  *
22  * Alternatively, this software may be distributed under the terms of the
23  * GNU General Public License ("GPL") version 2 as published by the Free
24  * Software Foundation.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
27  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
28  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
29  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
30  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
31  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
38 #ifndef _SYS_NET80211_H
39 #define	_SYS_NET80211_H
40 
41 #include <sys/mac.h>
42 #include <sys/mac_provider.h>
43 #include <sys/ethernet.h>
44 #include <sys/net80211_proto.h>
45 #include <sys/net80211_crypto.h>
46 #include <sys/net80211_ht.h>
47 #include <net/wpa.h>
48 
49 /*
50  * IEEE802.11 kernel support module
51  */
52 
53 #ifdef	__cplusplus
54 extern "C" {
55 #endif
56 
57 /* ic_caps */
58 #define	IEEE80211_C_WEP		0x00000001	/* CAPABILITY: WEP available */
59 #define	IEEE80211_C_TKIP	0x00000002	/* CAPABILITY: TKIP available */
60 #define	IEEE80211_C_AES		0x00000004	/* CAPABILITY: AES OCB avail */
61 #define	IEEE80211_C_AES_CCM	0x00000008	/* CAPABILITY: AES CCM avail */
62 #define	IEEE80211_C_CKIP	0x00000010	/* CAPABILITY: CKIP available */
63 #define	IEEE80211_C_FF		0x00000040	/* CAPABILITY: ATH FF avail */
64 #define	IEEE80211_C_TURBOP	0x00000080
65 				/* CAPABILITY: ATH Turbo available */
66 #define	IEEE80211_C_IBSS	0x00000100	/* CAPABILITY: IBSS available */
67 #define	IEEE80211_C_PMGT	0x00000200	/* CAPABILITY: Power mgmt */
68 #define	IEEE80211_C_HOSTAP	0x00000400	/* CAPABILITY: HOSTAP avail */
69 #define	IEEE80211_C_AHDEMO	0x00000800	/* CAPABILITY: Old Adhoc Demo */
70 #define	IEEE80211_C_SWRETRY	0x00001000	/* CAPABILITY: sw tx retry */
71 #define	IEEE80211_C_TXPMGT	0x00002000	/* CAPABILITY: tx power mgmt */
72 #define	IEEE80211_C_SHSLOT	0x00004000	/* CAPABILITY: short slottime */
73 #define	IEEE80211_C_SHPREAMBLE	0x00008000	/* CAPABILITY: short preamble */
74 #define	IEEE80211_C_MONITOR	0x00010000	/* CAPABILITY: monitor mode */
75 #define	IEEE80211_C_TKIPMIC	0x00020000	/* CAPABILITY: TKIP MIC avail */
76 #define	IEEE80211_C_WPA1	0x00800000	/* CAPABILITY: WPA1 avail */
77 #define	IEEE80211_C_WPA2	0x01000000	/* CAPABILITY: WPA2 avail */
78 #define	IEEE80211_C_WPA		0x01800000
79 				/* CAPABILITY: WPA1+WPA2 avail */
80 #define	IEEE80211_C_BURST	0x02000000	/* CAPABILITY: frame bursting */
81 #define	IEEE80211_C_WME		0x04000000	/* CAPABILITY: WME avail */
82 #define	IEEE80211_C_WDS		0x08000000	/* CAPABILITY: 4-addr support */
83 /* 0x10000000 reserved */
84 #define	IEEE80211_C_BGSCAN	0x20000000	/* CAPABILITY: bg scanning */
85 #define	IEEE80211_C_TXFRAG	0x40000000	/* CAPABILITY: tx fragments */
86 /* XXX protection/barker? */
87 
88 #define	IEEE80211_C_CRYPTO	0x0000001f	/* CAPABILITY: crypto alg's */
89 
90 /*
91  * ic_htcaps: HT-specific device/driver capabilities
92  *
93  * NB: the low 16-bits are the 802.11 definitions, the upper
94  *     16-bits are used to define s/w/driver capabilities.
95  */
96 #define	IEEE80211_HTC_AMPDU	0x00010000	/* CAPABILITY: A-MPDU tx */
97 #define	IEEE80211_HTC_AMSDU	0x00020000	/* CAPABILITY: A-MSDU tx */
98 /* NB: HT40 is implied by IEEE80211_HTCAP_CHWIDTH40 */
99 #define	IEEE80211_HTC_HT	0x00040000	/* CAPABILITY: HT operation */
100 
101 /* ic_flags */
102 /* NB: bits 0x4c available */
103 #define	IEEE80211_F_FF		0x00000001	/* CONF: ATH FF enabled */
104 #define	IEEE80211_F_TURBOP	0x00000002	/* CONF: ATH Turbo enabled */
105 #define	IEEE80211_F_BURST	0x00000004	/* CONF: bursting enabled */
106 /* NB: this is intentionally setup to be IEEE80211_CAPINFO_PRIVACY */
107 #define	IEEE80211_F_PRIVACY	0x00000010	/* CONF: privacy enabled */
108 #define	IEEE80211_F_PUREG	0x00000020	/* CONF: 11g w/o 11b sta's */
109 #define	IEEE80211_F_SCANONLY	0x00000040	/* CONF: scan only */
110 #define	IEEE80211_F_SCAN	0x00000080	/* STATUS: scanning */
111 #define	IEEE80211_F_ASCAN	0x00000100	/* STATUS: active scan */
112 #define	IEEE80211_F_SIBSS	0x00000200	/* STATUS: start IBSS */
113 /* NB: this is intentionally setup to be IEEE80211_CAPINFO_SHORT_SLOTTIME */
114 #define	IEEE80211_F_SHSLOT	0x00000400
115 				/* STATUS: use short slot time */
116 #define	IEEE80211_F_PMGTON	0x00000800	/* CONF: Power mgmt enable */
117 #define	IEEE80211_F_DESBSSID	0x00001000	/* CONF: des_bssid is set */
118 #define	IEEE80211_F_WME		0x00002000	/* CONF: enable WME use */
119 #define	IEEE80211_F_BGSCAN	0x00004000
120 				/* CONF: bg scan enabled (???) */
121 #define	IEEE80211_F_SWRETRY	0x00008000	/* CONF: sw tx retry enabled */
122 #define	IEEE80211_F_TXPOW_FIXED	0x00010000	/* TX Power: fixed rate */
123 #define	IEEE80211_F_IBSSON	0x00020000	/* CONF: IBSS creation enable */
124 #define	IEEE80211_F_SHPREAMBLE	0x00040000	/* STATUS: use short preamble */
125 #define	IEEE80211_F_DATAPAD	0x00080000	/* CONF: do alignment pad */
126 #define	IEEE80211_F_USEPROT	0x00100000	/* STATUS: protection enabled */
127 #define	IEEE80211_F_USEBARKER	0x00200000
128 				/* STATUS: use barker preamble */
129 #define	IEEE80211_F_TIMUPDATE	0x00400000	/* STATUS: update beacon tim */
130 #define	IEEE80211_F_WPA1	0x00800000	/* CONF: WPA enabled */
131 #define	IEEE80211_F_WPA2	0x01000000	/* CONF: WPA2 enabled */
132 #define	IEEE80211_F_WPA		0x01800000	/* CONF: WPA/WPA2 enabled */
133 #define	IEEE80211_F_DROPUNENC	0x02000000	/* CONF: drop unencrypted */
134 #define	IEEE80211_F_COUNTERM	0x04000000	/* CONF: TKIP countermeasures */
135 #define	IEEE80211_F_HIDESSID	0x08000000	/* CONF: hide SSID in beacon */
136 #define	IEEE80211_F_NOBRIDGE	0x10000000	/* CONF: dis. internal bridge */
137 #define	IEEE80211_F_WMEUPDATE	0x20000000	/* STATUS: update beacon wme */
138 
139 /* ic_flags_ext */
140 #define	IEEE80211_FEXT_NONHT_PR	0x00000001	/* STATUS: non-HT sta present */
141 #define	IEEE80211_FEXT_INACT	0x00000002	/* CONF: sta inact handling */
142 /* 0x00000006 reserved */
143 #define	IEEE80211_FEXT_BGSCAN	0x00000008
144 				/* STATUS: enable full bgscan completion */
145 #define	IEEE80211_FEXT_ERPUPDATE 0x00000200	/* STATUS: update ERP element */
146 #define	IEEE80211_FEXT_SWBMISS	0x00000400	/* CONF: do bmiss in s/w */
147 #define	IEEE80211_FEXT_PROBECHAN 0x00020000	/* CONF: probe passive chan */
148 #define	IEEE80211_FEXT_HT	0x00080000	/* CONF: HT supported */
149 #define	IEEE80211_FEXT_AMPDU_TX	0x00100000	/* CONF: A-MPDU tx supported */
150 #define	IEEE80211_FEXT_AMPDU_RX	0x00200000	/* CONF: A-MPDU tx supported */
151 #define	IEEE80211_FEXT_AMSDU_TX	0x00400000	/* CONF: A-MSDU tx supported */
152 #define	IEEE80211_FEXT_AMSDU_RX	0x00800000	/* CONF: A-MSDU tx supported */
153 #define	IEEE80211_FEXT_USEHT40	0x01000000	/* CONF: 20/40 use enabled */
154 #define	IEEE80211_FEXT_PUREN	0x02000000	/* CONF: 11n w/o legacy sta's */
155 #define	IEEE80211_FEXT_SHORTGI20 0x04000000	/* CONF: short GI in HT20 */
156 #define	IEEE80211_FEXT_SHORTGI40 0x08000000	/* CONF: short GI in HT40 */
157 #define	IEEE80211_FEXT_HTCOMPAT 0x10000000	/* CONF: HT vendor OUI's */
158 
159 /*
160  * Channel attributes (ich_flags)
161  * bits 0-3 are for private use by drivers
162  */
163 #define	IEEE80211_CHAN_TURBO	0x00000010 /* Turbo channel */
164 #define	IEEE80211_CHAN_CCK	0x00000020 /* CCK channel */
165 #define	IEEE80211_CHAN_OFDM	0x00000040 /* OFDM channel */
166 #define	IEEE80211_CHAN_2GHZ	0x00000080 /* 2 GHz spectrum channel. */
167 #define	IEEE80211_CHAN_5GHZ	0x00000100 /* 5 GHz spectrum channel */
168 #define	IEEE80211_CHAN_PASSIVE	0x00000200 /* Only passive scan allowed */
169 #define	IEEE80211_CHAN_DYN	0x00000400 /* Dynamic CCK-OFDM channel */
170 #define	IEEE80211_CHAN_GFSK	0x00000800 /* GFSK channel (FHSS PHY) */
171 #define	IEEE80211_CHAN_GSM	0x00001000 /* 900 MHz spectrum channel */
172 #define	IEEE80211_CHAN_STURBO	0x00002000 /* 11a static turbo channel only */
173 #define	IEEE80211_CHAN_HALF	0x00004000 /* Half rate channel */
174 #define	IEEE80211_CHAN_QUARTER	0x00008000 /* Quarter rate channel */
175 #define	IEEE80211_CHAN_HT20	0x00010000 /* HT 20 channel */
176 #define	IEEE80211_CHAN_HT40U	0x00020000 /* HT 40 channel w/ ext above */
177 #define	IEEE80211_CHAN_HT40D	0x00040000 /* HT 40 channel w/ ext below */
178 #define	IEEE80211_CHAN_DFS	0x00080000 /* DFS required */
179 #define	IEEE80211_CHAN_4MSXMIT	0x00100000 /* 4ms limit on frame length */
180 #define	IEEE80211_CHAN_NOADHOC	0x00200000 /* adhoc mode not allowed */
181 #define	IEEE80211_CHAN_NOHOSTAP	0x00400000 /* hostap mode not allowed */
182 #define	IEEE80211_CHAN_11D	0x00800000 /* 802.11d required */
183 
184 #define	IEEE80211_CHAN_HT40	(IEEE80211_CHAN_HT40U | IEEE80211_CHAN_HT40D)
185 #define	IEEE80211_CHAN_HT	(IEEE80211_CHAN_HT20 | IEEE80211_CHAN_HT40)
186 
187 #define	IEEE80211_CHAN_MAX	255
188 #define	IEEE80211_CHAN_BYTES	32	/* howmany(IEEE80211_CHAN_MAX, NBBY) */
189 #define	IEEE80211_CHAN_ANY	0xffff	/* token for ``any channel'' */
190 #define	IEEE80211_CHAN_ANYC	\
191 	((struct ieee80211_channel *)IEEE80211_CHAN_ANY)
192 
193 #define	IEEE80211_IS_CHAN_2GHZ(_c)	\
194 	(((_c)->ich_flags & IEEE80211_CHAN_2GHZ) != 0)
195 #define	IEEE80211_IS_CHAN_5GHZ(_c)	\
196 	(((_c)->ich_flags & IEEE80211_CHAN_5GHZ) != 0)
197 
198 #define	IEEE80211_NODE_CHWUPDATE 0x0400		/* 11n channel width change */
199 #define	IEEE80211_NODE_HASHSIZE	32
200 
201 #define	IEEE80211_NODE_AUTH	0x0001		/* authorized for data */
202 #define	IEEE80211_NODE_QOS	0x0002		/* QoS enabled */
203 #define	IEEE80211_NODE_ERP	0x0004		/* ERP enabled */
204 /* NB: this must have the same value as IEEE80211_FC1_PWR_MGT */
205 #define	IEEE80211_NODE_PWR_MGT	0x0010		/* power save mode enabled */
206 #define	IEEE80211_NODE_AREF	0x0020		/* authentication ref held */
207 #define	IEEE80211_NODE_HT	0x0040		/* HT enabled */
208 #define	IEEE80211_NODE_HTCOMPAT	0x0080		/* HT setup w/ vendor OUI's */
209 #define	IEEE80211_NODE_AMPDU_RX	0x0400		/* AMPDU rx enabled */
210 #define	IEEE80211_NODE_AMPDU_TX	0x0800		/* AMPDU tx enabled */
211 
212 #define	IEEE80211_NODE_AMPDU \
213 	(IEEE80211_NODE_AMPDU_RX | IEEE80211_NODE_AMPDU_TX)
214 
215 #define	IEEE80211_FIXED_RATE_NONE	0
216 
217 #define	WME_OUI			0xf25000
218 #define	WME_OUI_TYPE		0x02
219 #define	WME_INFO_OUI_SUBTYPE	0x00
220 #define	WME_PARAM_OUI_SUBTYPE	0x01
221 #define	WME_VERSION		1
222 
223 /* WME stream classes */
224 #define	WME_AC_BE		0	/* best effort */
225 #define	WME_AC_BK		1	/* background */
226 #define	WME_AC_VI		2	/* video */
227 #define	WME_AC_VO		3	/* voice */
228 
229 #define	MAX_EVENT		16
230 #define	MAX_IEEE80211STR	256
231 
232 /* For IEEE80211_RADIOTAP_FLAGS */
233 #define	IEEE80211_RADIOTAP_F_CFP	0x01
234 					/* sent/received during CFP */
235 #define	IEEE80211_RADIOTAP_F_SHORTPRE	0x02
236 					/* sent/received with short preamble */
237 #define	IEEE80211_RADIOTAP_F_WEP	0x04
238 					/* sent/received with WEP encryption */
239 #define	IEEE80211_RADIOTAP_F_FRAG	0x08
240 					/* sent/received with fragmentation */
241 #define	IEEE80211_RADIOTAP_F_DATAPAD	0x20
242 					/*
243 					 * frame has padding between 802.11
244 					 * header and payload (to 32-bit
245 					 * boundary
246 					 */
247 #define	IEEE80211_RADIOTAP_F_FCS	0x10	/* frame includes FCS */
248 #define	IEEE80211_RADIOTAP_F_BADFCS	0x40	/* does not pass FCS check */
249 #define	IEEE80211_RADIOTAP_F_SHORTGI	0x80	/* HT short GI */
250 
251 /*
252  * Authentication mode.
253  */
254 enum ieee80211_authmode {
255 	IEEE80211_AUTH_NONE	= 0,
256 	IEEE80211_AUTH_OPEN	= 1,	/* open */
257 	IEEE80211_AUTH_SHARED	= 2,	/* shared-key */
258 	IEEE80211_AUTH_8021X	= 3,	/* 802.1x */
259 	IEEE80211_AUTH_AUTO	= 4,	/* auto-select/accept */
260 	/* NB: these are used only for ioctls */
261 	IEEE80211_AUTH_WPA	= 5	/* WPA/RSN w/ 802.1x/PSK */
262 };
263 
264 enum ieee80211_state {
265 	IEEE80211_S_INIT	= 0,	/* default state */
266 	IEEE80211_S_SCAN	= 1,	/* scanning */
267 	IEEE80211_S_AUTH	= 2,	/* try to authenticate */
268 	IEEE80211_S_ASSOC	= 3,	/* try to assoc */
269 	IEEE80211_S_RUN		= 4	/* associated */
270 };
271 #define	IEEE80211_S_MAX	(IEEE80211_S_RUN+1)
272 
273 /*
274  * 802.11 rate set.
275  */
276 #define	IEEE80211_RATE_MAXSIZE	15	/* max rates we'll handle */
277 #define	IEEE80211_RATE_SIZE	8	/* 802.11 standard */
278 #define	IEEE80211_XRATE_SIZE	(IEEE80211_RATE_MAXSIZE - IEEE80211_RATE_SIZE)
279 					/* size of extended supported rates */
280 struct ieee80211_rateset {
281 	uint8_t			ir_nrates;
282 	uint8_t			ir_rates[IEEE80211_RATE_MAXSIZE];
283 };
284 
285 /*
286  * 802.11n variant of ieee80211_rateset.  Instead
287  * legacy rates the entries are MCS rates.  We define
288  * the structure such that it can be used interchangeably
289  * with an ieee80211_rateset (modulo structure size).
290  */
291 #define	IEEE80211_HTRATE_MAXSIZE 127
292 
293 struct ieee80211_htrateset {
294 	uint8_t			rs_nrates;
295 	uint8_t			rs_rates[IEEE80211_HTRATE_MAXSIZE];
296 };
297 
298 #define	IEEE80211_RATE_MCS	0x80
299 
300 /*
301  * Channels are specified by frequency and attributes.
302  */
303 struct ieee80211_channel {
304 	uint16_t		ich_freq;	/* setting in Mhz */
305 	uint32_t		ich_flags;	/* see below */
306 };
307 
308 struct ieee80211_device_stats {
309 	uint32_t		is_tx_frags;
310 	uint32_t		is_tx_bytes;
311 	uint32_t		is_tx_mcast;
312 	uint32_t		is_tx_failed;
313 	uint32_t		is_tx_retries;
314 	uint32_t		is_rts_success;
315 	uint32_t		is_rts_failure;
316 	uint32_t		is_ack_failure;
317 	uint32_t		is_rx_frags;
318 	uint32_t		is_rx_bytes;
319 	uint32_t		is_rx_mcast;
320 	uint32_t		is_rx_dups;
321 	uint32_t		is_fcs_errors;
322 	uint32_t		is_wep_errors;
323 	uint32_t		is_tx_nobuf;
324 	uint32_t		is_tx_unknownmgt;
325 };
326 
327 struct ieee80211_crypto_state;
328 typedef struct ieee80211_node_table ieee80211_node_table_t;
329 typedef struct ieee80211_node ieee80211_node_t;
330 typedef struct ieee80211com ieee80211com_t;
331 
332 struct ieee80211_node_table {
333 	struct ieee80211com	*nt_ic;		/* back reference */
334 
335 	const char		*nt_name;	/* for debugging */
336 	/* For node inactivity processing */
337 	int			nt_inact_timer;	/* inactivity timer */
338 	int			nt_inact_init;	/* initial node inact setting */
339 	void			(*nt_timeout)(struct ieee80211_node_table *);
340 	uint32_t		nt_scangen;	/* gen# for timeout scan */
341 	kmutex_t		nt_scanlock;    /* on nt_scangen */
342 	kmutex_t		nt_nodelock;	/* on node table */
343 
344 	int			nt_keyixmax;	/* keyixmap size */
345 	struct ieee80211_node	**nt_keyixmap;	/* key ix -> node map */
346 
347 	list_t			nt_node;	/* information of all nodes */
348 	list_t			nt_hash[IEEE80211_NODE_HASHSIZE];
349 };
350 
351 #define	IEEE80211_TID_SIZE	(WME_NUM_TID+1)	/* WME TID's +1 for non-QoS */
352 #define	IEEE80211_NONQOS_TID	WME_NUM_TID	/* index for non-QoS sta */
353 
354 /*
355  * Node specific information.  Note that drivers are expected
356  * to derive from this structure to add device-specific per-node
357  * state.  This is done by overriding the ic_node_* methods in
358  * the ieee80211com structure.
359  */
360 struct ieee80211_node {
361 	struct ieee80211com		*in_ic;
362 	struct ieee80211_node_table	*in_table;
363 
364 	uint8_t			in_authmode;	/* authentication algorithm */
365 	uint16_t		in_flags;	/* special purpose state */
366 	uint16_t		in_associd;	/* assoc response */
367 	uint16_t		in_txpower;	/* current transmit power */
368 	uint16_t		in_vlan;	/* vlan tag */
369 	/*
370 	 * Tx/Rx sequence number.
371 	 * index 0 is used when QoS is not enabled. index 1-16 is used
372 	 * when QoS is enabled. 1-16 corresponds to TID 0-15.
373 	 */
374 	uint16_t		in_txseqs[IEEE80211_TID_SIZE];
375 	uint16_t		in_rxseqs[IEEE80211_TID_SIZE];
376 	clock_t			in_rxfragstamp;	/* time stamp of last rx frag */
377 	mblk_t			*in_rxfrag;	/* rx frag reassembly */
378 	uint32_t		in_scangen;	/* gen# for timeout scan */
379 	uint32_t		in_refcnt;
380 
381 	/* hardware */
382 	uint32_t		in_rstamp;	/* recv timestamp */
383 	uint8_t			in_rssi;	/* recv ssi */
384 
385 	/* header */
386 	uint8_t			in_macaddr[IEEE80211_ADDR_LEN];
387 	uint8_t			in_bssid[IEEE80211_ADDR_LEN];
388 
389 	/* beacon, probe response */
390 	union {
391 		uint8_t		data[8];
392 		uint64_t	tsf;
393 	} in_tstamp;				/* from last rcv'd beacon */
394 	uint16_t		in_intval;	/* beacon interval */
395 	uint16_t		in_capinfo;	/* capabilities */
396 	uint8_t			in_esslen;
397 	uint8_t			in_essid[IEEE80211_NWID_LEN];
398 	struct ieee80211_rateset in_rates;	/* negotiated rate set */
399 	struct ieee80211_channel *in_chan;	/* XXX multiple uses */
400 	enum ieee80211_phytype	in_phytype;
401 	uint16_t		in_fhdwell;	/* FH only */
402 	uint8_t			in_fhindex;	/* FH only */
403 	uint8_t			in_erp;		/* ERP from beacon/probe resp */
404 	uint16_t		in_tim_off;	/* byte offset to TIM ie */
405 	uint8_t			in_dtim_period;	/* DTIM period */
406 	uint8_t			in_dtim_count;	/* DTIM count for last bcn */
407 
408 	uint32_t		*in_challenge;	/* shared-key challenge */
409 	struct ieee80211_key	in_ucastkey;	/* unicast key */
410 	uint8_t			*in_wpa_ie;	/* captured WPA/RSN ie */
411 	uint8_t			*in_wme_ie;	/* captured WME ie */
412 
413 	/* 11n state */
414 	uint8_t			*in_htcap_ie;	/* captured HTCAP ie */
415 	uint16_t		in_htcap;	/* HT capabilities */
416 	uint8_t			in_htparam;	/* HT params */
417 	uint8_t			in_htctlchan;	/* HT control channel */
418 	uint8_t			in_ht2ndchan;	/* HT 2nd channel */
419 	uint8_t			in_htopmode;	/* HT operating mode */
420 	uint8_t			in_htstbc;	/* HT */
421 	uint8_t			in_reqcw;	/* requested tx channel width */
422 	uint8_t			in_chw;		/* negotiated channel width */
423 	struct ieee80211_htrateset in_htrates;	/* negotiated ht rate set */
424 	struct ieee80211_tx_ampdu in_tx_ampdu[WME_NUM_AC];
425 	struct ieee80211_rx_ampdu in_rx_ampdu[WME_NUM_TID];
426 
427 	/* others */
428 	int32_t			in_fails;	/* failure count to associate */
429 	int16_t			in_inact;	/* inactivity mark count */
430 	int16_t			in_inact_reload; /* inactivity reload value */
431 	int32_t			in_txrate;	/* index to in_rates[] */
432 
433 	list_node_t		in_node;	/* element of nt->nt_node */
434 	list_node_t		in_hash;	/* element of nt->nt_hash */
435 };
436 
437 /*
438  * WME/WMM support.
439  */
440 struct wmeParams {
441 	uint8_t		wmep_acm;
442 	uint8_t		wmep_aifsn;
443 	uint8_t		wmep_logcwmin;		/* log2(cwmin) */
444 	uint8_t		wmep_logcwmax;		/* log2(cwmax) */
445 	uint8_t		wmep_txopLimit;
446 	uint8_t		wmep_noackPolicy;	/* 0 (ack), 1 (no ack) */
447 };
448 #define	IEEE80211_TXOP_TO_US(_txop)	((_txop)<<5)
449 #define	IEEE80211_US_TO_TXOP(_us)	((_us)>>5)
450 
451 struct chanAccParams {
452 	uint8_t		cap_info;		/* version of the current set */
453 	struct wmeParams cap_wmeParams[WME_NUM_AC];
454 };
455 
456 struct ieee80211_wme_state {
457 	uint_t	wme_flags;
458 #define	WME_F_AGGRMODE	0x00000001	/* STATUS: WME agressive mode */
459 	uint_t	wme_hipri_traffic; /* VI/VO frames in beacon interval */
460 	uint_t	wme_hipri_switch_thresh; /* agressive mode switch thresh */
461 	uint_t	wme_hipri_switch_hysteresis;
462 					/* agressive mode switch hysteresis */
463 	struct wmeParams wme_params[4]; /* from assoc resp for each AC */
464 	struct chanAccParams wme_wmeChanParams; /* WME params applied to self */
465 	struct chanAccParams wme_wmeBssChanParams;
466 					/* WME params bcast to stations */
467 	struct chanAccParams wme_chanParams; /* params applied to self */
468 	struct chanAccParams wme_bssChanParams; /* params bcast to stations */
469 	int (*wme_update)(struct ieee80211com *);
470 };
471 
472 struct ieee80211com {
473 	mac_handle_t		ic_mach;
474 
475 	/* Initialized by driver */
476 	uint8_t			ic_macaddr[IEEE80211_ADDR_LEN];
477 	uint32_t		ic_caps;	/* capabilities */
478 	uint32_t		ic_htcaps;	/* HT capabilities */
479 	enum ieee80211_phytype	ic_phytype;	/* XXX wrong for multi-mode */
480 	enum ieee80211_opmode	ic_opmode;	/* current operation mode */
481 	enum ieee80211_state	ic_state;	/* current 802.11 state */
482 	struct ieee80211_channel	ic_sup_channels[IEEE80211_CHAN_MAX+1];
483 	struct ieee80211_rateset	ic_sup_rates[IEEE80211_MODE_MAX];
484 	enum ieee80211_phymode		ic_curmode;  /* OPT current mode */
485 	struct ieee80211_channel	*ic_curchan; /* OPT current channel */
486 	struct ieee80211_channel	*ic_ibss_chan;	/* OPT bss channel */
487 	uint8_t				ic_maxrssi;  /* maximum hardware RSSI */
488 
489 	/* INITIALIZED by IEEE80211, used/overridden by driver */
490 	uint16_t		ic_modecaps;	/* set of mode capabilities */
491 	uint8_t			ic_chan_active[IEEE80211_CHAN_BYTES];
492 	enum ieee80211_protmode	ic_protmode;	/* 802.11g protection mode */
493 	uint16_t		ic_bintval;	/* beacon interval */
494 	uint16_t		ic_lintval;	/* listen interval */
495 	uint16_t		ic_txpowlimit;	/* global tx power limit */
496 	uint8_t			ic_bmissthreshold;
497 	uint16_t		ic_rtsthreshold;
498 	uint16_t		ic_fragthreshold;
499 	uint8_t			ic_fixed_rate;	/* value of fixed rate */
500 	int32_t			ic_des_esslen;	/* length of desired essid */
501 	uint8_t			ic_des_essid[IEEE80211_NWID_LEN];
502 	uint8_t			ic_des_bssid[IEEE80211_ADDR_LEN];
503 	struct ieee80211_channel	*ic_des_chan;	/* desired channel */
504 	void			*ic_opt_ie;	/* user-specified IE's */
505 	uint16_t		ic_opt_ie_len;	/* length of ic_opt_ie */
506 	uint8_t			ic_nickname[IEEE80211_NWID_LEN];
507 	uint16_t		ic_tim_len;	/* ic_tim_bitmap size (bytes) */
508 	uint8_t			*ic_tim_bitmap;	/* powersave stations w/ data */
509 	timeout_id_t		ic_watchdog_timer;	/* watchdog timer */
510 	/* Cipher state/configuration. */
511 	struct ieee80211_crypto_state	ic_crypto;
512 	const struct ieee80211_cipher *ic_ciphers[IEEE80211_CIPHER_MAX];
513 
514 	kmutex_t		ic_doorlock;
515 	char			ic_wpadoor[MAX_IEEE80211STR];
516 
517 	wpa_event_type		ic_eventq[MAX_EVENT];
518 	uint32_t		ic_evq_head, ic_evq_tail;
519 
520 	/* Runtime states */
521 	uint32_t		ic_flags;	/* state/conf flags */
522 	uint32_t		ic_flags_ext;	/* extended state flags */
523 	struct ieee80211_node	*ic_bss;	/* information for this node */
524 	struct ieee80211_device_stats	ic_stats;
525 	struct ieee80211_node_table	ic_scan; /* STA: scan candidates */
526 	struct ieee80211_node_table	ic_sta; /* AP:stations/IBSS:neighbors */
527 
528 	struct ieee80211_wme_state ic_wme;	/* WME/WMM state */
529 
530 	int			ic_ampdu_rxmax;	/* A-MPDU rx limit (bytes) */
531 	int			ic_ampdu_density; /* A-MPDU density */
532 	int			ic_ampdu_limit;	/* A-MPDU tx limit (bytes) */
533 	int			ic_amsdu_limit;	/* A-MSDU tx limit (bytes) */
534 
535 	uint16_t		ic_sta_assoc;	/* stations associated */
536 	uint16_t		ic_ht_sta_assoc; /* HT stations associated */
537 	uint16_t		ic_ht40_sta_assoc; /* HT40 station associated */
538 	uint8_t			ic_curhtprotmode; /* HTINFO bss state */
539 	enum ieee80211_protmode	ic_htprotmode;	/* HT protection mode */
540 	int			ic_lastnonerp;	/* last time nonERP sta noted */
541 	int			ic_lastnonht;	/* last time non-HT sta noted */
542 	int			ic_beaconmiss;	/* beacon miss counter */
543 
544 
545 	/* callback functions */
546 	/*
547 	 * Functions initialized by driver before calling ieee80211_attach()
548 	 * Those must be initialized are marked with M(andatory)
549 	 *
550 	 *  ic_xmit		- [M] transmit a management or null data frame
551 	 *			return 0 on success, non-zero on error
552 	 *  ic_watchdog		- [O] periodic run function, enabled by
553 	 *			ieee80211_start_watchdog()
554 	 *  ic_set_tim		- [O] set/clear traffic indication map
555 	 *  ic_set_shortslot	- [O] enable/disable short slot timing
556 	 *  ic_node_newassoc	- [O] driver specific operation on a newly
557 	 *			associated or re-assoced node
558 	 */
559 	int			(*ic_xmit)(ieee80211com_t *, mblk_t *, uint8_t);
560 	void			(*ic_watchdog)(void *);
561 	void			(*ic_set_tim)(ieee80211com_t *,
562 					ieee80211_node_t *, int);
563 	void			(*ic_set_shortslot)(ieee80211com_t *, int);
564 	void			(*ic_node_newassoc)(ieee80211_node_t *, int);
565 	/*
566 	 * Functions initialized by ieee80211_attach(), driver could
567 	 * override these functions after calling ieee80211_attach()
568 	 *
569 	 *  ic_reset		- reset
570 	 *  ic_recv_mgmt	- handle received management frames
571 	 *  ic_send_mgmt	- construct and transmit management frames
572 	 *  ic_newstate		- handle state transition
573 	 *  ic_node_alloc	- allocate a new BSS info node
574 	 *  ic_node_cleanup	- cleanup or free memory spaces of a node
575 	 *  ic_node_free	- free a node
576 	 *  ic_node_getrssi	- get node's rssi
577 	 */
578 	int			(*ic_reset)(ieee80211com_t *);
579 	void			(*ic_recv_mgmt)(ieee80211com_t *,
580 					mblk_t *, ieee80211_node_t *,
581 					int, int, uint32_t);
582 	int			(*ic_send_mgmt)(ieee80211com_t *,
583 					ieee80211_node_t *, int, int);
584 	int			(*ic_newstate)(ieee80211com_t *,
585 					enum ieee80211_state, int);
586 	struct ieee80211_node	*(*ic_node_alloc)(ieee80211com_t *);
587 	void			(*ic_node_cleanup)(ieee80211_node_t *);
588 	void			(*ic_node_free)(ieee80211_node_t *);
589 	uint8_t			(*ic_node_getrssi)(const ieee80211_node_t *);
590 	void			(*ic_set_channel)(ieee80211com_t *);
591 
592 	/*
593 	 * 802.11n ADDBA support.  A simple/generic implementation
594 	 * of A-MPDU tx aggregation is provided; the driver may
595 	 * override these methods to provide their own support.
596 	 * A-MPDU rx re-ordering happens automatically if the
597 	 * driver passes out-of-order frames to ieee80211_input
598 	 * from an assocated HT station.
599 	 */
600 	void			(*ic_recv_action)(ieee80211_node_t *,
601 				    const uint8_t *, const uint8_t *);
602 	int			(*ic_send_action)(ieee80211_node_t *,
603 				    int, int, uint16_t[4]);
604 	/* start/stop doing A-MPDU tx aggregation for a station */
605 	int			(*ic_addba_request)(ieee80211_node_t *,
606 				    struct ieee80211_tx_ampdu *,
607 				    int, int, int);
608 	int			(*ic_addba_response)(ieee80211_node_t *,
609 				    struct ieee80211_tx_ampdu *,
610 				    int, int, int);
611 	void			(*ic_addba_stop)(ieee80211_node_t *,
612 				    struct ieee80211_tx_ampdu *);
613 
614 	kmutex_t		ic_genlock;
615 	void			*ic_private;	/* ieee80211 private data */
616 };
617 #define	ic_nw_keys		ic_crypto.cs_nw_keys
618 #define	ic_def_txkey		ic_crypto.cs_def_txkey
619 
620 extern	const char *ieee80211_state_name[IEEE80211_S_MAX];
621 extern	const char *ieee80211_wme_acnames[];
622 
623 #define	IEEE80211_RATE(_ix)			\
624 	(in->in_rates.ir_rates[(_ix)] & IEEE80211_RATE_VAL)
625 
626 #define	ieee80211_new_state(_ic, _nstate, _arg)	\
627 	(((_ic)->ic_newstate)((_ic), (_nstate), (_arg)))
628 
629 #define	ieee80211_macaddr_sprintf(_addr)	\
630 	ether_sprintf((struct ether_addr *)(_addr))
631 
632 /*
633  * Node reference counting definitions.
634  *
635  * ieee80211_node_initref	initialize the reference count to 1
636  * ieee80211_node_incref	add a reference
637  * ieee80211_node_decref	remove a reference
638  * ieee80211_node_decref_nv	remove a reference and return new value
639  * ieee80211_node_refcnt	reference count for printing (only)
640  */
641 #include <sys/atomic.h>
642 #define	ieee80211_node_initref(_in)		\
643 	((_in)->in_refcnt = 1)
644 #define	ieee80211_node_incref(_in)		\
645 	atomic_inc_uint(&(_in)->in_refcnt)
646 #define	ieee80211_node_decref(_in)		\
647 	atomic_dec_uint(&(_in)->in_refcnt)
648 #define	ieee80211_node_decref_nv(_in)		\
649 	atomic_dec_uint_nv(&(_in)->in_refcnt)
650 #define	ieee80211_node_refcnt(_in)		\
651 	(_in)->in_refcnt
652 
653 typedef void ieee80211_iter_func(void *, ieee80211_node_t *);
654 
655 /* Initialization */
656 void ieee80211_attach(ieee80211com_t *);
657 void ieee80211_detach(ieee80211com_t *);
658 void ieee80211_media_init(ieee80211com_t *);
659 int ieee80211_ioctl(ieee80211com_t *, queue_t *, mblk_t *);
660 void ieee80211_register_door(ieee80211com_t *, const char *, int);
661 
662 /* Protocol Processing */
663 int ieee80211_input(ieee80211com_t *, mblk_t *, ieee80211_node_t *,
664 	int32_t, uint32_t);
665 mblk_t *ieee80211_encap(ieee80211com_t *, mblk_t *, ieee80211_node_t *);
666 
667 mblk_t *ieee80211_beacon_alloc(ieee80211com_t *, ieee80211_node_t *,
668 	struct ieee80211_beacon_offsets *);
669 int ieee80211_beacon_update(ieee80211com_t *, ieee80211_node_t *,
670 	struct ieee80211_beacon_offsets *, mblk_t *, int);
671 void ieee80211_beacon_miss(ieee80211com_t *);
672 
673 void ieee80211_begin_scan(ieee80211com_t *, boolean_t);
674 void ieee80211_next_scan(ieee80211com_t *);
675 void ieee80211_end_scan(ieee80211com_t *);
676 void ieee80211_cancel_scan(ieee80211com_t *);
677 
678 void ieee80211_sta_join(ieee80211com_t *, ieee80211_node_t *);
679 void ieee80211_sta_leave(ieee80211com_t *, ieee80211_node_t *);
680 boolean_t ieee80211_ibss_merge(ieee80211_node_t *);
681 
682 /* Node Operation */
683 ieee80211_node_t *ieee80211_ref_node(ieee80211_node_t *);
684 void ieee80211_unref_node(ieee80211_node_t **);
685 void ieee80211_node_authorize(ieee80211_node_t *);
686 void ieee80211_node_unauthorize(ieee80211_node_t *);
687 ieee80211_node_t *ieee80211_alloc_node(ieee80211com_t *,
688 	ieee80211_node_table_t *, const uint8_t *);
689 void ieee80211_free_node(ieee80211_node_t *);
690 void ieee80211_node_table_reset(ieee80211_node_table_t *);
691 void ieee80211_iterate_nodes(ieee80211_node_table_t *, ieee80211_iter_func *,
692 	void *);
693 ieee80211_node_t *ieee80211_find_node(ieee80211_node_table_t *,
694 	const uint8_t *);
695 ieee80211_node_t *ieee80211_find_node_with_ssid(ieee80211_node_table_t *,
696 	const uint8_t *, uint32_t, const uint8_t *);
697 ieee80211_node_t *ieee80211_find_txnode(ieee80211com_t *,
698 	const uint8_t daddr[IEEE80211_ADDR_LEN]);
699 ieee80211_node_t *ieee80211_find_rxnode(ieee80211com_t *,
700 	const struct ieee80211_frame *);
701 
702 
703 /* Crypto */
704 extern struct ieee80211_key *ieee80211_crypto_encap(ieee80211com_t *, mblk_t *);
705 extern struct ieee80211_key *ieee80211_crypto_decap(ieee80211com_t *, mblk_t *,
706 	int);
707 extern int ieee80211_crypto_newkey(ieee80211com_t *, int, int,
708 	struct ieee80211_key *);
709 extern int ieee80211_crypto_delkey(ieee80211com_t *, struct ieee80211_key *);
710 extern int ieee80211_crypto_setkey(ieee80211com_t *, struct ieee80211_key *,
711 	const uint8_t macaddr[IEEE80211_ADDR_LEN]);
712 
713 /* Helper Functions */
714 int ieee80211_stat(ieee80211com_t *ic, uint_t stat, uint64_t *val);
715 uint32_t ieee80211_chan2ieee(ieee80211com_t *, struct ieee80211_channel *);
716 enum ieee80211_phymode ieee80211_chan2mode(ieee80211com_t *,
717 	struct ieee80211_channel *);
718 uint32_t ieee80211_ieee2mhz(uint32_t, uint32_t);
719 void ieee80211_reset_chan(ieee80211com_t *);
720 void ieee80211_dump_pkt(const uint8_t *, int32_t, int32_t, int32_t);
721 void ieee80211_watchdog(void *);
722 void ieee80211_start_watchdog(ieee80211com_t *, uint32_t);
723 void ieee80211_stop_watchdog(ieee80211com_t *);
724 int ieee80211_classify(struct ieee80211com *, mblk_t *,
725     struct ieee80211_node *);
726 int ieee80211_hdrsize(const void *);
727 int ieee80211_hdrspace(ieee80211com_t *, const void *);
728 int ieee80211_anyhdrsize(const void *);
729 int ieee80211_anyhdrspace(ieee80211com_t *, const void *);
730 
731 void *ieee80211_malloc(size_t);
732 void ieee80211_free(void *);
733 int ieee80211_setprop(void *, const char *, mac_prop_id_t, uint_t,
734     const void *);
735 int ieee80211_getprop(void *, const char *, mac_prop_id_t, uint_t, void *);
736 void ieee80211_propinfo(void *, const char *, mac_prop_id_t,
737     mac_prop_info_handle_t);
738 
739 
740 struct ieee80211_channel *ieee80211_find_channel(ieee80211com_t *, int, int);
741 const struct ieee80211_rateset *ieee80211_get_suprates(ieee80211com_t *,
742     struct ieee80211_channel *);
743 
744 /* HT */
745 
746 #ifdef	__cplusplus
747 }
748 #endif
749 
750 #endif	/* _SYS_NET80211_H */
751