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