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