xref: /onnv-gate/usr/src/uts/common/sys/net80211.h (revision 10266:bbc5945eddd7)
13147Sxc151355 /*
2*10266SQuaker.Fang@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
33147Sxc151355  * Use is subject to license terms.
43147Sxc151355  */
53147Sxc151355 
63147Sxc151355 /*
73147Sxc151355  * Copyright (c) 2001 Atsushi Onoe
83147Sxc151355  * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
93147Sxc151355  * All rights reserved.
103147Sxc151355  *
113147Sxc151355  * Redistribution and use in source and binary forms, with or without
123147Sxc151355  * modification, are permitted provided that the following conditions
133147Sxc151355  * are met:
143147Sxc151355  * 1. Redistributions of source code must retain the above copyright
153147Sxc151355  *    notice, this list of conditions and the following disclaimer.
163147Sxc151355  * 2. Redistributions in binary form must reproduce the above copyright
173147Sxc151355  *    notice, this list of conditions and the following disclaimer in the
183147Sxc151355  *    documentation and/or other materials provided with the distribution.
193147Sxc151355  * 3. The name of the author may not be used to endorse or promote products
203147Sxc151355  *    derived from this software without specific prior written permission.
213147Sxc151355  *
223147Sxc151355  * Alternatively, this software may be distributed under the terms of the
233147Sxc151355  * GNU General Public License ("GPL") version 2 as published by the Free
243147Sxc151355  * Software Foundation.
253147Sxc151355  *
263147Sxc151355  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
273147Sxc151355  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
283147Sxc151355  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
293147Sxc151355  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
303147Sxc151355  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
313147Sxc151355  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
323147Sxc151355  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
333147Sxc151355  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
343147Sxc151355  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
353147Sxc151355  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
363147Sxc151355  */
373147Sxc151355 
383147Sxc151355 #ifndef _SYS_NET80211_H
393147Sxc151355 #define	_SYS_NET80211_H
403147Sxc151355 
413147Sxc151355 #include <sys/mac.h>
423147Sxc151355 #include <sys/ethernet.h>
433147Sxc151355 #include <sys/net80211_proto.h>
443147Sxc151355 #include <sys/net80211_crypto.h>
45*10266SQuaker.Fang@Sun.COM #include <sys/net80211_ht.h>
464126Szf162725 #include <net/wpa.h>
473147Sxc151355 
483147Sxc151355 /*
493147Sxc151355  * IEEE802.11 kernel support module
503147Sxc151355  */
513147Sxc151355 
523147Sxc151355 #ifdef	__cplusplus
533147Sxc151355 extern "C" {
543147Sxc151355 #endif
553147Sxc151355 
563147Sxc151355 /* ic_caps */
573147Sxc151355 #define	IEEE80211_C_WEP		0x00000001	/* CAPABILITY: WEP available */
583147Sxc151355 #define	IEEE80211_C_TKIP	0x00000002	/* CAPABILITY: TKIP available */
593147Sxc151355 #define	IEEE80211_C_AES		0x00000004	/* CAPABILITY: AES OCB avail */
603147Sxc151355 #define	IEEE80211_C_AES_CCM	0x00000008	/* CAPABILITY: AES CCM avail */
613147Sxc151355 #define	IEEE80211_C_CKIP	0x00000010	/* CAPABILITY: CKIP available */
623147Sxc151355 #define	IEEE80211_C_FF		0x00000040	/* CAPABILITY: ATH FF avail */
633147Sxc151355 #define	IEEE80211_C_TURBOP	0x00000080
643147Sxc151355 				/* CAPABILITY: ATH Turbo available */
653147Sxc151355 #define	IEEE80211_C_IBSS	0x00000100	/* CAPABILITY: IBSS available */
663147Sxc151355 #define	IEEE80211_C_PMGT	0x00000200	/* CAPABILITY: Power mgmt */
673147Sxc151355 #define	IEEE80211_C_HOSTAP	0x00000400	/* CAPABILITY: HOSTAP avail */
683147Sxc151355 #define	IEEE80211_C_AHDEMO	0x00000800	/* CAPABILITY: Old Adhoc Demo */
693147Sxc151355 #define	IEEE80211_C_SWRETRY	0x00001000	/* CAPABILITY: sw tx retry */
703147Sxc151355 #define	IEEE80211_C_TXPMGT	0x00002000	/* CAPABILITY: tx power mgmt */
713147Sxc151355 #define	IEEE80211_C_SHSLOT	0x00004000	/* CAPABILITY: short slottime */
723147Sxc151355 #define	IEEE80211_C_SHPREAMBLE	0x00008000	/* CAPABILITY: short preamble */
733147Sxc151355 #define	IEEE80211_C_MONITOR	0x00010000	/* CAPABILITY: monitor mode */
743147Sxc151355 #define	IEEE80211_C_TKIPMIC	0x00020000	/* CAPABILITY: TKIP MIC avail */
753147Sxc151355 #define	IEEE80211_C_WPA1	0x00800000	/* CAPABILITY: WPA1 avail */
763147Sxc151355 #define	IEEE80211_C_WPA2	0x01000000	/* CAPABILITY: WPA2 avail */
773147Sxc151355 #define	IEEE80211_C_WPA		0x01800000
783147Sxc151355 				/* CAPABILITY: WPA1+WPA2 avail */
793147Sxc151355 #define	IEEE80211_C_BURST	0x02000000	/* CAPABILITY: frame bursting */
803147Sxc151355 #define	IEEE80211_C_WME		0x04000000	/* CAPABILITY: WME avail */
813147Sxc151355 #define	IEEE80211_C_WDS		0x08000000	/* CAPABILITY: 4-addr support */
823147Sxc151355 /* 0x10000000 reserved */
833147Sxc151355 #define	IEEE80211_C_BGSCAN	0x20000000	/* CAPABILITY: bg scanning */
843147Sxc151355 #define	IEEE80211_C_TXFRAG	0x40000000	/* CAPABILITY: tx fragments */
853147Sxc151355 /* XXX protection/barker? */
863147Sxc151355 
873147Sxc151355 #define	IEEE80211_C_CRYPTO	0x0000001f	/* CAPABILITY: crypto alg's */
883147Sxc151355 
89*10266SQuaker.Fang@Sun.COM /*
90*10266SQuaker.Fang@Sun.COM  * ic_htcaps: HT-specific device/driver capabilities
91*10266SQuaker.Fang@Sun.COM  *
92*10266SQuaker.Fang@Sun.COM  * NB: the low 16-bits are the 802.11 definitions, the upper
93*10266SQuaker.Fang@Sun.COM  *     16-bits are used to define s/w/driver capabilities.
94*10266SQuaker.Fang@Sun.COM  */
95*10266SQuaker.Fang@Sun.COM #define	IEEE80211_HTC_AMPDU	0x00010000	/* CAPABILITY: A-MPDU tx */
96*10266SQuaker.Fang@Sun.COM #define	IEEE80211_HTC_AMSDU	0x00020000	/* CAPABILITY: A-MSDU tx */
97*10266SQuaker.Fang@Sun.COM /* NB: HT40 is implied by IEEE80211_HTCAP_CHWIDTH40 */
98*10266SQuaker.Fang@Sun.COM #define	IEEE80211_HTC_HT	0x00040000	/* CAPABILITY: HT operation */
99*10266SQuaker.Fang@Sun.COM 
1003147Sxc151355 /* ic_flags */
1013147Sxc151355 /* NB: bits 0x4c available */
1023147Sxc151355 #define	IEEE80211_F_FF		0x00000001	/* CONF: ATH FF enabled */
1033147Sxc151355 #define	IEEE80211_F_TURBOP	0x00000002	/* CONF: ATH Turbo enabled */
1043147Sxc151355 #define	IEEE80211_F_BURST	0x00000004	/* CONF: bursting enabled */
1053147Sxc151355 /* NB: this is intentionally setup to be IEEE80211_CAPINFO_PRIVACY */
1063147Sxc151355 #define	IEEE80211_F_PRIVACY	0x00000010	/* CONF: privacy enabled */
1073147Sxc151355 #define	IEEE80211_F_PUREG	0x00000020	/* CONF: 11g w/o 11b sta's */
1083147Sxc151355 #define	IEEE80211_F_SCANONLY	0x00000040	/* CONF: scan only */
1093147Sxc151355 #define	IEEE80211_F_SCAN	0x00000080	/* STATUS: scanning */
1103147Sxc151355 #define	IEEE80211_F_ASCAN	0x00000100	/* STATUS: active scan */
1113147Sxc151355 #define	IEEE80211_F_SIBSS	0x00000200	/* STATUS: start IBSS */
1123147Sxc151355 /* NB: this is intentionally setup to be IEEE80211_CAPINFO_SHORT_SLOTTIME */
1133147Sxc151355 #define	IEEE80211_F_SHSLOT	0x00000400
1143147Sxc151355 				/* STATUS: use short slot time */
1153147Sxc151355 #define	IEEE80211_F_PMGTON	0x00000800	/* CONF: Power mgmt enable */
1163147Sxc151355 #define	IEEE80211_F_DESBSSID	0x00001000	/* CONF: des_bssid is set */
1173147Sxc151355 #define	IEEE80211_F_WME		0x00002000	/* CONF: enable WME use */
1183147Sxc151355 #define	IEEE80211_F_BGSCAN	0x00004000
1193147Sxc151355 				/* CONF: bg scan enabled (???) */
1203147Sxc151355 #define	IEEE80211_F_SWRETRY	0x00008000	/* CONF: sw tx retry enabled */
1213147Sxc151355 #define	IEEE80211_F_TXPOW_FIXED	0x00010000	/* TX Power: fixed rate */
1223147Sxc151355 #define	IEEE80211_F_IBSSON	0x00020000	/* CONF: IBSS creation enable */
1233147Sxc151355 #define	IEEE80211_F_SHPREAMBLE	0x00040000	/* STATUS: use short preamble */
1243147Sxc151355 #define	IEEE80211_F_DATAPAD	0x00080000	/* CONF: do alignment pad */
1253147Sxc151355 #define	IEEE80211_F_USEPROT	0x00100000	/* STATUS: protection enabled */
1263147Sxc151355 #define	IEEE80211_F_USEBARKER	0x00200000
1273147Sxc151355 				/* STATUS: use barker preamble */
1283147Sxc151355 #define	IEEE80211_F_TIMUPDATE	0x00400000	/* STATUS: update beacon tim */
1293147Sxc151355 #define	IEEE80211_F_WPA1	0x00800000	/* CONF: WPA enabled */
1303147Sxc151355 #define	IEEE80211_F_WPA2	0x01000000	/* CONF: WPA2 enabled */
1313147Sxc151355 #define	IEEE80211_F_WPA		0x01800000	/* CONF: WPA/WPA2 enabled */
1323147Sxc151355 #define	IEEE80211_F_DROPUNENC	0x02000000	/* CONF: drop unencrypted */
1333147Sxc151355 #define	IEEE80211_F_COUNTERM	0x04000000	/* CONF: TKIP countermeasures */
1343147Sxc151355 #define	IEEE80211_F_HIDESSID	0x08000000	/* CONF: hide SSID in beacon */
1353147Sxc151355 #define	IEEE80211_F_NOBRIDGE	0x10000000	/* CONF: dis. internal bridge */
1363147Sxc151355 #define	IEEE80211_F_WMEUPDATE	0x20000000	/* STATUS: update beacon wme */
1373147Sxc151355 
1383147Sxc151355 /* ic_flags_ext */
139*10266SQuaker.Fang@Sun.COM #define	IEEE80211_FEXT_NONHT_PR	0x00000001	/* STATUS: non-HT sta present */
140*10266SQuaker.Fang@Sun.COM #define	IEEE80211_FEXT_INACT	0x00000002	/* CONF: sta inact handling */
1413147Sxc151355 /* 0x00000006 reserved */
1423147Sxc151355 #define	IEEE80211_FEXT_BGSCAN	0x00000008
1433147Sxc151355 				/* STATUS: enable full bgscan completion */
1443147Sxc151355 #define	IEEE80211_FEXT_ERPUPDATE 0x00000200	/* STATUS: update ERP element */
1453147Sxc151355 #define	IEEE80211_FEXT_SWBMISS	0x00000400	/* CONF: do bmiss in s/w */
146*10266SQuaker.Fang@Sun.COM #define	IEEE80211_FEXT_PROBECHAN 0x00020000	/* CONF: probe passive chan */
147*10266SQuaker.Fang@Sun.COM #define	IEEE80211_FEXT_HT	0x00080000	/* CONF: HT supported */
148*10266SQuaker.Fang@Sun.COM #define	IEEE80211_FEXT_AMPDU_TX	0x00100000	/* CONF: A-MPDU tx supported */
149*10266SQuaker.Fang@Sun.COM #define	IEEE80211_FEXT_AMPDU_RX	0x00200000	/* CONF: A-MPDU tx supported */
150*10266SQuaker.Fang@Sun.COM #define	IEEE80211_FEXT_AMSDU_TX	0x00400000	/* CONF: A-MSDU tx supported */
151*10266SQuaker.Fang@Sun.COM #define	IEEE80211_FEXT_AMSDU_RX	0x00800000	/* CONF: A-MSDU tx supported */
152*10266SQuaker.Fang@Sun.COM #define	IEEE80211_FEXT_USEHT40	0x01000000	/* CONF: 20/40 use enabled */
153*10266SQuaker.Fang@Sun.COM #define	IEEE80211_FEXT_PUREN	0x02000000	/* CONF: 11n w/o legacy sta's */
154*10266SQuaker.Fang@Sun.COM #define	IEEE80211_FEXT_SHORTGI20 0x04000000	/* CONF: short GI in HT20 */
155*10266SQuaker.Fang@Sun.COM #define	IEEE80211_FEXT_SHORTGI40 0x08000000	/* CONF: short GI in HT40 */
156*10266SQuaker.Fang@Sun.COM #define	IEEE80211_FEXT_HTCOMPAT 0x10000000	/* CONF: HT vendor OUI's */
1573147Sxc151355 
1583147Sxc151355 /*
1593147Sxc151355  * Channel attributes (ich_flags)
1603147Sxc151355  * bits 0-3 are for private use by drivers
1613147Sxc151355  */
162*10266SQuaker.Fang@Sun.COM #define	IEEE80211_CHAN_TURBO	0x00000010 /* Turbo channel */
163*10266SQuaker.Fang@Sun.COM #define	IEEE80211_CHAN_CCK	0x00000020 /* CCK channel */
164*10266SQuaker.Fang@Sun.COM #define	IEEE80211_CHAN_OFDM	0x00000040 /* OFDM channel */
165*10266SQuaker.Fang@Sun.COM #define	IEEE80211_CHAN_2GHZ	0x00000080 /* 2 GHz spectrum channel. */
166*10266SQuaker.Fang@Sun.COM #define	IEEE80211_CHAN_5GHZ	0x00000100 /* 5 GHz spectrum channel */
167*10266SQuaker.Fang@Sun.COM #define	IEEE80211_CHAN_PASSIVE	0x00000200 /* Only passive scan allowed */
168*10266SQuaker.Fang@Sun.COM #define	IEEE80211_CHAN_DYN	0x00000400 /* Dynamic CCK-OFDM channel */
169*10266SQuaker.Fang@Sun.COM #define	IEEE80211_CHAN_GFSK	0x00000800 /* GFSK channel (FHSS PHY) */
170*10266SQuaker.Fang@Sun.COM #define	IEEE80211_CHAN_GSM	0x00001000 /* 900 MHz spectrum channel */
171*10266SQuaker.Fang@Sun.COM #define	IEEE80211_CHAN_STURBO	0x00002000 /* 11a static turbo channel only */
172*10266SQuaker.Fang@Sun.COM #define	IEEE80211_CHAN_HALF	0x00004000 /* Half rate channel */
173*10266SQuaker.Fang@Sun.COM #define	IEEE80211_CHAN_QUARTER	0x00008000 /* Quarter rate channel */
174*10266SQuaker.Fang@Sun.COM #define	IEEE80211_CHAN_HT20	0x00010000 /* HT 20 channel */
175*10266SQuaker.Fang@Sun.COM #define	IEEE80211_CHAN_HT40U	0x00020000 /* HT 40 channel w/ ext above */
176*10266SQuaker.Fang@Sun.COM #define	IEEE80211_CHAN_HT40D	0x00040000 /* HT 40 channel w/ ext below */
177*10266SQuaker.Fang@Sun.COM #define	IEEE80211_CHAN_DFS	0x00080000 /* DFS required */
178*10266SQuaker.Fang@Sun.COM #define	IEEE80211_CHAN_4MSXMIT	0x00100000 /* 4ms limit on frame length */
179*10266SQuaker.Fang@Sun.COM #define	IEEE80211_CHAN_NOADHOC	0x00200000 /* adhoc mode not allowed */
180*10266SQuaker.Fang@Sun.COM #define	IEEE80211_CHAN_NOHOSTAP	0x00400000 /* hostap mode not allowed */
181*10266SQuaker.Fang@Sun.COM #define	IEEE80211_CHAN_11D	0x00800000 /* 802.11d required */
182*10266SQuaker.Fang@Sun.COM 
183*10266SQuaker.Fang@Sun.COM #define	IEEE80211_CHAN_HT40	(IEEE80211_CHAN_HT40U | IEEE80211_CHAN_HT40D)
184*10266SQuaker.Fang@Sun.COM #define	IEEE80211_CHAN_HT	(IEEE80211_CHAN_HT20 | IEEE80211_CHAN_HT40)
1853147Sxc151355 
1863147Sxc151355 #define	IEEE80211_CHAN_MAX	255
1873147Sxc151355 #define	IEEE80211_CHAN_BYTES	32	/* howmany(IEEE80211_CHAN_MAX, NBBY) */
1883147Sxc151355 #define	IEEE80211_CHAN_ANY	0xffff	/* token for ``any channel'' */
1893147Sxc151355 #define	IEEE80211_CHAN_ANYC	\
1903147Sxc151355 	((struct ieee80211_channel *)IEEE80211_CHAN_ANY)
1913147Sxc151355 
1923147Sxc151355 #define	IEEE80211_IS_CHAN_2GHZ(_c)	\
1933147Sxc151355 	(((_c)->ich_flags & IEEE80211_CHAN_2GHZ) != 0)
1943147Sxc151355 #define	IEEE80211_IS_CHAN_5GHZ(_c)	\
1953147Sxc151355 	(((_c)->ich_flags & IEEE80211_CHAN_5GHZ) != 0)
1963147Sxc151355 
197*10266SQuaker.Fang@Sun.COM #define	IEEE80211_NODE_CHWUPDATE 0x0400		/* 11n channel width change */
1983147Sxc151355 #define	IEEE80211_NODE_HASHSIZE	32
1993147Sxc151355 
200*10266SQuaker.Fang@Sun.COM #define	IEEE80211_NODE_AUTH	0x0001		/* authorized for data */
201*10266SQuaker.Fang@Sun.COM #define	IEEE80211_NODE_QOS	0x0002		/* QoS enabled */
202*10266SQuaker.Fang@Sun.COM #define	IEEE80211_NODE_ERP	0x0004		/* ERP enabled */
203*10266SQuaker.Fang@Sun.COM /* NB: this must have the same value as IEEE80211_FC1_PWR_MGT */
204*10266SQuaker.Fang@Sun.COM #define	IEEE80211_NODE_PWR_MGT	0x0010		/* power save mode enabled */
205*10266SQuaker.Fang@Sun.COM #define	IEEE80211_NODE_AREF	0x0020		/* authentication ref held */
206*10266SQuaker.Fang@Sun.COM #define	IEEE80211_NODE_HT	0x0040		/* HT enabled */
207*10266SQuaker.Fang@Sun.COM #define	IEEE80211_NODE_HTCOMPAT	0x0080		/* HT setup w/ vendor OUI's */
208*10266SQuaker.Fang@Sun.COM #define	IEEE80211_NODE_AMPDU_RX	0x0400		/* AMPDU rx enabled */
209*10266SQuaker.Fang@Sun.COM #define	IEEE80211_NODE_AMPDU_TX	0x0800		/* AMPDU tx enabled */
210*10266SQuaker.Fang@Sun.COM 
211*10266SQuaker.Fang@Sun.COM #define	IEEE80211_NODE_AMPDU \
212*10266SQuaker.Fang@Sun.COM 	(IEEE80211_NODE_AMPDU_RX | IEEE80211_NODE_AMPDU_TX)
213*10266SQuaker.Fang@Sun.COM 
2143147Sxc151355 #define	IEEE80211_FIXED_RATE_NONE	0
215*10266SQuaker.Fang@Sun.COM 
216*10266SQuaker.Fang@Sun.COM #define	WME_OUI			0xf25000
217*10266SQuaker.Fang@Sun.COM #define	WME_OUI_TYPE		0x02
218*10266SQuaker.Fang@Sun.COM #define	WME_INFO_OUI_SUBTYPE	0x00
219*10266SQuaker.Fang@Sun.COM #define	WME_PARAM_OUI_SUBTYPE	0x01
220*10266SQuaker.Fang@Sun.COM #define	WME_VERSION		1
2213147Sxc151355 
2223147Sxc151355 /* WME stream classes */
2233147Sxc151355 #define	WME_AC_BE		0	/* best effort */
2243147Sxc151355 #define	WME_AC_BK		1	/* background */
2253147Sxc151355 #define	WME_AC_VI		2	/* video */
2263147Sxc151355 #define	WME_AC_VO		3	/* voice */
2273147Sxc151355 
2284126Szf162725 #define	MAX_EVENT		16
2294126Szf162725 #define	MAX_IEEE80211STR	256
2304126Szf162725 
231*10266SQuaker.Fang@Sun.COM /* For IEEE80211_RADIOTAP_FLAGS */
232*10266SQuaker.Fang@Sun.COM #define	IEEE80211_RADIOTAP_F_CFP	0x01
233*10266SQuaker.Fang@Sun.COM 					/* sent/received during CFP */
234*10266SQuaker.Fang@Sun.COM #define	IEEE80211_RADIOTAP_F_SHORTPRE	0x02
235*10266SQuaker.Fang@Sun.COM 					/* sent/received with short preamble */
236*10266SQuaker.Fang@Sun.COM #define	IEEE80211_RADIOTAP_F_WEP	0x04
237*10266SQuaker.Fang@Sun.COM 					/* sent/received with WEP encryption */
238*10266SQuaker.Fang@Sun.COM #define	IEEE80211_RADIOTAP_F_FRAG	0x08
239*10266SQuaker.Fang@Sun.COM 					/* sent/received with fragmentation */
240*10266SQuaker.Fang@Sun.COM #define	IEEE80211_RADIOTAP_F_DATAPAD	0x20
241*10266SQuaker.Fang@Sun.COM 					/*
242*10266SQuaker.Fang@Sun.COM 					 * frame has padding between 802.11
243*10266SQuaker.Fang@Sun.COM 					 * header and payload (to 32-bit
244*10266SQuaker.Fang@Sun.COM 					 * boundary
245*10266SQuaker.Fang@Sun.COM 					 */
246*10266SQuaker.Fang@Sun.COM #define	IEEE80211_RADIOTAP_F_FCS	0x10	/* frame includes FCS */
247*10266SQuaker.Fang@Sun.COM #define	IEEE80211_RADIOTAP_F_BADFCS	0x40	/* does not pass FCS check */
248*10266SQuaker.Fang@Sun.COM #define	IEEE80211_RADIOTAP_F_SHORTGI	0x80	/* HT short GI */
249*10266SQuaker.Fang@Sun.COM 
2503147Sxc151355 /*
2513147Sxc151355  * Authentication mode.
2523147Sxc151355  */
2533147Sxc151355 enum ieee80211_authmode {
2543147Sxc151355 	IEEE80211_AUTH_NONE	= 0,
2553147Sxc151355 	IEEE80211_AUTH_OPEN	= 1,	/* open */
2563147Sxc151355 	IEEE80211_AUTH_SHARED	= 2,	/* shared-key */
2573147Sxc151355 	IEEE80211_AUTH_8021X	= 3,	/* 802.1x */
2583147Sxc151355 	IEEE80211_AUTH_AUTO	= 4,	/* auto-select/accept */
2593147Sxc151355 	/* NB: these are used only for ioctls */
2603147Sxc151355 	IEEE80211_AUTH_WPA	= 5	/* WPA/RSN w/ 802.1x/PSK */
2613147Sxc151355 };
2623147Sxc151355 
2633147Sxc151355 enum ieee80211_state {
2643147Sxc151355 	IEEE80211_S_INIT	= 0,	/* default state */
2653147Sxc151355 	IEEE80211_S_SCAN	= 1,	/* scanning */
2663147Sxc151355 	IEEE80211_S_AUTH	= 2,	/* try to authenticate */
2673147Sxc151355 	IEEE80211_S_ASSOC	= 3,	/* try to assoc */
2683147Sxc151355 	IEEE80211_S_RUN		= 4	/* associated */
2693147Sxc151355 };
2703147Sxc151355 #define	IEEE80211_S_MAX	(IEEE80211_S_RUN+1)
2713147Sxc151355 
2723147Sxc151355 /*
2733147Sxc151355  * 802.11 rate set.
2743147Sxc151355  */
2753147Sxc151355 #define	IEEE80211_RATE_MAXSIZE	15	/* max rates we'll handle */
2763147Sxc151355 #define	IEEE80211_RATE_SIZE	8	/* 802.11 standard */
2773147Sxc151355 #define	IEEE80211_XRATE_SIZE	(IEEE80211_RATE_MAXSIZE - IEEE80211_RATE_SIZE)
2783147Sxc151355 					/* size of extended supported rates */
2793147Sxc151355 struct ieee80211_rateset {
2803147Sxc151355 	uint8_t			ir_nrates;
2813147Sxc151355 	uint8_t			ir_rates[IEEE80211_RATE_MAXSIZE];
2823147Sxc151355 };
2833147Sxc151355 
2843147Sxc151355 /*
285*10266SQuaker.Fang@Sun.COM  * 802.11n variant of ieee80211_rateset.  Instead
286*10266SQuaker.Fang@Sun.COM  * legacy rates the entries are MCS rates.  We define
287*10266SQuaker.Fang@Sun.COM  * the structure such that it can be used interchangeably
288*10266SQuaker.Fang@Sun.COM  * with an ieee80211_rateset (modulo structure size).
289*10266SQuaker.Fang@Sun.COM  */
290*10266SQuaker.Fang@Sun.COM #define	IEEE80211_HTRATE_MAXSIZE 127
291*10266SQuaker.Fang@Sun.COM 
292*10266SQuaker.Fang@Sun.COM struct ieee80211_htrateset {
293*10266SQuaker.Fang@Sun.COM 	uint8_t			rs_nrates;
294*10266SQuaker.Fang@Sun.COM 	uint8_t			rs_rates[IEEE80211_HTRATE_MAXSIZE];
295*10266SQuaker.Fang@Sun.COM };
296*10266SQuaker.Fang@Sun.COM 
297*10266SQuaker.Fang@Sun.COM #define	IEEE80211_RATE_MCS	0x80
298*10266SQuaker.Fang@Sun.COM 
299*10266SQuaker.Fang@Sun.COM /*
3003147Sxc151355  * Channels are specified by frequency and attributes.
3013147Sxc151355  */
3023147Sxc151355 struct ieee80211_channel {
3033147Sxc151355 	uint16_t		ich_freq;	/* setting in Mhz */
304*10266SQuaker.Fang@Sun.COM 	uint32_t		ich_flags;	/* see below */
3053147Sxc151355 };
3063147Sxc151355 
3073147Sxc151355 struct ieee80211_device_stats {
3083147Sxc151355 	uint32_t		is_tx_frags;
3093147Sxc151355 	uint32_t		is_tx_bytes;
3103147Sxc151355 	uint32_t		is_tx_mcast;
3113147Sxc151355 	uint32_t		is_tx_failed;
3123147Sxc151355 	uint32_t		is_tx_retries;
3133147Sxc151355 	uint32_t		is_rts_success;
3143147Sxc151355 	uint32_t		is_rts_failure;
3153147Sxc151355 	uint32_t		is_ack_failure;
3163147Sxc151355 	uint32_t		is_rx_frags;
3173147Sxc151355 	uint32_t		is_rx_bytes;
3183147Sxc151355 	uint32_t		is_rx_mcast;
3193147Sxc151355 	uint32_t		is_rx_dups;
3203147Sxc151355 	uint32_t		is_fcs_errors;
3213147Sxc151355 	uint32_t		is_wep_errors;
3223147Sxc151355 	uint32_t		is_tx_nobuf;
3233147Sxc151355 	uint32_t		is_tx_unknownmgt;
3243147Sxc151355 };
3253147Sxc151355 
3263147Sxc151355 struct ieee80211_crypto_state;
3273147Sxc151355 typedef struct ieee80211_node_table ieee80211_node_table_t;
3283147Sxc151355 typedef struct ieee80211_node ieee80211_node_t;
3293147Sxc151355 typedef struct ieee80211com ieee80211com_t;
3303147Sxc151355 
3313147Sxc151355 struct ieee80211_node_table {
3323147Sxc151355 	struct ieee80211com	*nt_ic;		/* back reference */
3333147Sxc151355 
3343147Sxc151355 	const char		*nt_name;	/* for debugging */
3353147Sxc151355 	/* For node inactivity processing */
3363147Sxc151355 	int			nt_inact_timer;	/* inactivity timer */
3373147Sxc151355 	int			nt_inact_init;	/* initial node inact setting */
3383147Sxc151355 	void			(*nt_timeout)(struct ieee80211_node_table *);
3393147Sxc151355 	uint32_t		nt_scangen;	/* gen# for timeout scan */
3403147Sxc151355 	kmutex_t		nt_scanlock;    /* on nt_scangen */
3413147Sxc151355 	kmutex_t		nt_nodelock;	/* on node table */
3423147Sxc151355 
3433147Sxc151355 	int			nt_keyixmax;	/* keyixmap size */
3443147Sxc151355 	struct ieee80211_node	**nt_keyixmap;	/* key ix -> node map */
3453147Sxc151355 
3463147Sxc151355 	list_t			nt_node;	/* information of all nodes */
3473147Sxc151355 	list_t			nt_hash[IEEE80211_NODE_HASHSIZE];
3483147Sxc151355 };
3493147Sxc151355 
350*10266SQuaker.Fang@Sun.COM #define	IEEE80211_TID_SIZE	(WME_NUM_TID+1)	/* WME TID's +1 for non-QoS */
351*10266SQuaker.Fang@Sun.COM #define	IEEE80211_NONQOS_TID	WME_NUM_TID	/* index for non-QoS sta */
352*10266SQuaker.Fang@Sun.COM 
3533147Sxc151355 /*
3543147Sxc151355  * Node specific information.  Note that drivers are expected
3553147Sxc151355  * to derive from this structure to add device-specific per-node
3563147Sxc151355  * state.  This is done by overriding the ic_node_* methods in
3573147Sxc151355  * the ieee80211com structure.
3583147Sxc151355  */
3593147Sxc151355 struct ieee80211_node {
3603147Sxc151355 	struct ieee80211com		*in_ic;
3613147Sxc151355 	struct ieee80211_node_table	*in_table;
3623147Sxc151355 
3633147Sxc151355 	uint8_t			in_authmode;	/* authentication algorithm */
3643147Sxc151355 	uint16_t		in_flags;	/* special purpose state */
3653147Sxc151355 	uint16_t		in_associd;	/* assoc response */
3663147Sxc151355 	uint16_t		in_txpower;	/* current transmit power */
3673147Sxc151355 	uint16_t		in_vlan;	/* vlan tag */
3683147Sxc151355 	/*
3693147Sxc151355 	 * Tx/Rx sequence number.
3703147Sxc151355 	 * index 0 is used when QoS is not enabled. index 1-16 is used
3713147Sxc151355 	 * when QoS is enabled. 1-16 corresponds to TID 0-15.
3723147Sxc151355 	 */
373*10266SQuaker.Fang@Sun.COM 	uint16_t		in_txseqs[IEEE80211_TID_SIZE];
374*10266SQuaker.Fang@Sun.COM 	uint16_t		in_rxseqs[IEEE80211_TID_SIZE];
3753147Sxc151355 	clock_t			in_rxfragstamp;	/* time stamp of last rx frag */
3763147Sxc151355 	mblk_t			*in_rxfrag;	/* rx frag reassembly */
3773147Sxc151355 	uint32_t		in_scangen;	/* gen# for timeout scan */
3783147Sxc151355 	uint32_t		in_refcnt;
3793147Sxc151355 
3803147Sxc151355 	/* hardware */
3813147Sxc151355 	uint32_t		in_rstamp;	/* recv timestamp */
3823147Sxc151355 	uint8_t			in_rssi;	/* recv ssi */
3833147Sxc151355 
3843147Sxc151355 	/* header */
3853147Sxc151355 	uint8_t			in_macaddr[IEEE80211_ADDR_LEN];
3863147Sxc151355 	uint8_t			in_bssid[IEEE80211_ADDR_LEN];
3873147Sxc151355 
3883147Sxc151355 	/* beacon, probe response */
3893147Sxc151355 	union {
3903147Sxc151355 		uint8_t		data[8];
3913147Sxc151355 		uint64_t	tsf;
3923147Sxc151355 	} in_tstamp;				/* from last rcv'd beacon */
3933147Sxc151355 	uint16_t		in_intval;	/* beacon interval */
3943147Sxc151355 	uint16_t		in_capinfo;	/* capabilities */
3953147Sxc151355 	uint8_t			in_esslen;
3963147Sxc151355 	uint8_t			in_essid[IEEE80211_NWID_LEN];
3973147Sxc151355 	struct ieee80211_rateset in_rates;	/* negotiated rate set */
3983147Sxc151355 	struct ieee80211_channel *in_chan;	/* XXX multiple uses */
3993147Sxc151355 	enum ieee80211_phytype	in_phytype;
4003147Sxc151355 	uint16_t		in_fhdwell;	/* FH only */
4013147Sxc151355 	uint8_t			in_fhindex;	/* FH only */
4023147Sxc151355 	uint8_t			in_erp;		/* ERP from beacon/probe resp */
4033147Sxc151355 	uint16_t		in_tim_off;	/* byte offset to TIM ie */
4043147Sxc151355 	uint8_t			in_dtim_period;	/* DTIM period */
4053147Sxc151355 	uint8_t			in_dtim_count;	/* DTIM count for last bcn */
4063147Sxc151355 
4073147Sxc151355 	uint32_t		*in_challenge;	/* shared-key challenge */
4083147Sxc151355 	struct ieee80211_key	in_ucastkey;	/* unicast key */
4094126Szf162725 	uint8_t			*in_wpa_ie;	/* captured WPA/RSN ie */
410*10266SQuaker.Fang@Sun.COM 	uint8_t			*in_wme_ie;	/* captured WME ie */
411*10266SQuaker.Fang@Sun.COM 
412*10266SQuaker.Fang@Sun.COM 	/* 11n state */
413*10266SQuaker.Fang@Sun.COM 	uint8_t			*in_htcap_ie;	/* captured HTCAP ie */
414*10266SQuaker.Fang@Sun.COM 	uint16_t		in_htcap;	/* HT capabilities */
415*10266SQuaker.Fang@Sun.COM 	uint8_t			in_htparam;	/* HT params */
416*10266SQuaker.Fang@Sun.COM 	uint8_t			in_htctlchan;	/* HT control channel */
417*10266SQuaker.Fang@Sun.COM 	uint8_t			in_ht2ndchan;	/* HT 2nd channel */
418*10266SQuaker.Fang@Sun.COM 	uint8_t			in_htopmode;	/* HT operating mode */
419*10266SQuaker.Fang@Sun.COM 	uint8_t			in_htstbc;	/* HT */
420*10266SQuaker.Fang@Sun.COM 	uint8_t			in_reqcw;	/* requested tx channel width */
421*10266SQuaker.Fang@Sun.COM 	uint8_t			in_chw;		/* negotiated channel width */
422*10266SQuaker.Fang@Sun.COM 	struct ieee80211_htrateset in_htrates;	/* negotiated ht rate set */
423*10266SQuaker.Fang@Sun.COM 	struct ieee80211_tx_ampdu in_tx_ampdu[WME_NUM_AC];
424*10266SQuaker.Fang@Sun.COM 	struct ieee80211_rx_ampdu in_rx_ampdu[WME_NUM_TID];
4253147Sxc151355 
4263147Sxc151355 	/* others */
4273147Sxc151355 	int32_t			in_fails;	/* failure count to associate */
4283147Sxc151355 	int16_t			in_inact;	/* inactivity mark count */
4293147Sxc151355 	int16_t			in_inact_reload; /* inactivity reload value */
430*10266SQuaker.Fang@Sun.COM 	int32_t			in_txrate;	/* index to in_rates[] */
4313147Sxc151355 
4323147Sxc151355 	list_node_t		in_node;	/* element of nt->nt_node */
4333147Sxc151355 	list_node_t		in_hash;	/* element of nt->nt_hash */
4343147Sxc151355 };
4353147Sxc151355 
436*10266SQuaker.Fang@Sun.COM /*
437*10266SQuaker.Fang@Sun.COM  * WME/WMM support.
438*10266SQuaker.Fang@Sun.COM  */
439*10266SQuaker.Fang@Sun.COM struct wmeParams {
440*10266SQuaker.Fang@Sun.COM 	uint8_t		wmep_acm;
441*10266SQuaker.Fang@Sun.COM 	uint8_t		wmep_aifsn;
442*10266SQuaker.Fang@Sun.COM 	uint8_t		wmep_logcwmin;		/* log2(cwmin) */
443*10266SQuaker.Fang@Sun.COM 	uint8_t		wmep_logcwmax;		/* log2(cwmax) */
444*10266SQuaker.Fang@Sun.COM 	uint8_t		wmep_txopLimit;
445*10266SQuaker.Fang@Sun.COM 	uint8_t		wmep_noackPolicy;	/* 0 (ack), 1 (no ack) */
446*10266SQuaker.Fang@Sun.COM };
447*10266SQuaker.Fang@Sun.COM #define	IEEE80211_TXOP_TO_US(_txop)	((_txop)<<5)
448*10266SQuaker.Fang@Sun.COM #define	IEEE80211_US_TO_TXOP(_us)	((_us)>>5)
449*10266SQuaker.Fang@Sun.COM 
450*10266SQuaker.Fang@Sun.COM struct chanAccParams {
451*10266SQuaker.Fang@Sun.COM 	uint8_t		cap_info;		/* version of the current set */
452*10266SQuaker.Fang@Sun.COM 	struct wmeParams cap_wmeParams[WME_NUM_AC];
453*10266SQuaker.Fang@Sun.COM };
454*10266SQuaker.Fang@Sun.COM 
455*10266SQuaker.Fang@Sun.COM struct ieee80211_wme_state {
456*10266SQuaker.Fang@Sun.COM 	uint_t	wme_flags;
457*10266SQuaker.Fang@Sun.COM #define	WME_F_AGGRMODE	0x00000001	/* STATUS: WME agressive mode */
458*10266SQuaker.Fang@Sun.COM 	uint_t	wme_hipri_traffic; /* VI/VO frames in beacon interval */
459*10266SQuaker.Fang@Sun.COM 	uint_t	wme_hipri_switch_thresh; /* agressive mode switch thresh */
460*10266SQuaker.Fang@Sun.COM 	uint_t	wme_hipri_switch_hysteresis;
461*10266SQuaker.Fang@Sun.COM 					/* agressive mode switch hysteresis */
462*10266SQuaker.Fang@Sun.COM 	struct wmeParams wme_params[4]; /* from assoc resp for each AC */
463*10266SQuaker.Fang@Sun.COM 	struct chanAccParams wme_wmeChanParams; /* WME params applied to self */
464*10266SQuaker.Fang@Sun.COM 	struct chanAccParams wme_wmeBssChanParams;
465*10266SQuaker.Fang@Sun.COM 					/* WME params bcast to stations */
466*10266SQuaker.Fang@Sun.COM 	struct chanAccParams wme_chanParams; /* params applied to self */
467*10266SQuaker.Fang@Sun.COM 	struct chanAccParams wme_bssChanParams; /* params bcast to stations */
468*10266SQuaker.Fang@Sun.COM 	int (*wme_update)(struct ieee80211com *);
469*10266SQuaker.Fang@Sun.COM };
470*10266SQuaker.Fang@Sun.COM 
4713147Sxc151355 struct ieee80211com {
4723147Sxc151355 	mac_handle_t		ic_mach;
4733147Sxc151355 
4743147Sxc151355 	/* Initialized by driver */
4753147Sxc151355 	uint8_t			ic_macaddr[IEEE80211_ADDR_LEN];
4763147Sxc151355 	uint32_t		ic_caps;	/* capabilities */
477*10266SQuaker.Fang@Sun.COM 	uint32_t		ic_htcaps;	/* HT capabilities */
4783147Sxc151355 	enum ieee80211_phytype	ic_phytype;	/* XXX wrong for multi-mode */
4793147Sxc151355 	enum ieee80211_opmode	ic_opmode;	/* current operation mode */
4803147Sxc151355 	enum ieee80211_state	ic_state;	/* current 802.11 state */
4813147Sxc151355 	struct ieee80211_channel	ic_sup_channels[IEEE80211_CHAN_MAX+1];
4823147Sxc151355 	struct ieee80211_rateset	ic_sup_rates[IEEE80211_MODE_MAX];
4833147Sxc151355 	enum ieee80211_phymode		ic_curmode;  /* OPT current mode */
4843147Sxc151355 	struct ieee80211_channel	*ic_curchan; /* OPT current channel */
4853147Sxc151355 	struct ieee80211_channel	*ic_ibss_chan;	/* OPT bss channel */
4863147Sxc151355 	uint8_t				ic_maxrssi;  /* maximum hardware RSSI */
4873147Sxc151355 
4883147Sxc151355 	/* INITIALIZED by IEEE80211, used/overridden by driver */
4893147Sxc151355 	uint16_t		ic_modecaps;	/* set of mode capabilities */
4903147Sxc151355 	uint8_t			ic_chan_active[IEEE80211_CHAN_BYTES];
4913147Sxc151355 	enum ieee80211_protmode	ic_protmode;	/* 802.11g protection mode */
4923147Sxc151355 	uint16_t		ic_bintval;	/* beacon interval */
4933147Sxc151355 	uint16_t		ic_lintval;	/* listen interval */
4943147Sxc151355 	uint16_t		ic_txpowlimit;	/* global tx power limit */
4953147Sxc151355 	uint8_t			ic_bmissthreshold;
4963147Sxc151355 	uint16_t		ic_rtsthreshold;
4973147Sxc151355 	uint16_t		ic_fragthreshold;
4983147Sxc151355 	uint8_t			ic_fixed_rate;	/* value of fixed rate */
4993147Sxc151355 	int32_t			ic_des_esslen;	/* length of desired essid */
5003147Sxc151355 	uint8_t			ic_des_essid[IEEE80211_NWID_LEN];
5013147Sxc151355 	uint8_t			ic_des_bssid[IEEE80211_ADDR_LEN];
5023147Sxc151355 	struct ieee80211_channel	*ic_des_chan;	/* desired channel */
5033147Sxc151355 	void			*ic_opt_ie;	/* user-specified IE's */
5043147Sxc151355 	uint16_t		ic_opt_ie_len;	/* length of ic_opt_ie */
5053147Sxc151355 	uint8_t			ic_nickname[IEEE80211_NWID_LEN];
5063147Sxc151355 	uint16_t		ic_tim_len;	/* ic_tim_bitmap size (bytes) */
5073147Sxc151355 	uint8_t			*ic_tim_bitmap;	/* powersave stations w/ data */
5083147Sxc151355 	timeout_id_t		ic_watchdog_timer;	/* watchdog timer */
5093147Sxc151355 	/* Cipher state/configuration. */
5103147Sxc151355 	struct ieee80211_crypto_state	ic_crypto;
5114499Shx147065 	const struct ieee80211_cipher *ic_ciphers[IEEE80211_CIPHER_MAX];
5123147Sxc151355 
5134126Szf162725 	kmutex_t		ic_doorlock;
5144126Szf162725 	char			ic_wpadoor[MAX_IEEE80211STR];
5154126Szf162725 
5164126Szf162725 	wpa_event_type		ic_eventq[MAX_EVENT];
5174126Szf162725 	uint32_t		ic_evq_head, ic_evq_tail;
5184126Szf162725 
5193147Sxc151355 	/* Runtime states */
5203147Sxc151355 	uint32_t		ic_flags;	/* state/conf flags */
5213147Sxc151355 	uint32_t		ic_flags_ext;	/* extended state flags */
5223147Sxc151355 	struct ieee80211_node	*ic_bss;	/* information for this node */
5233147Sxc151355 	struct ieee80211_device_stats	ic_stats;
5243147Sxc151355 	struct ieee80211_node_table	ic_scan; /* STA: scan candidates */
5253147Sxc151355 	struct ieee80211_node_table	ic_sta; /* AP:stations/IBSS:neighbors */
5263147Sxc151355 
527*10266SQuaker.Fang@Sun.COM 	struct ieee80211_wme_state ic_wme;	/* WME/WMM state */
528*10266SQuaker.Fang@Sun.COM 
529*10266SQuaker.Fang@Sun.COM 	int			ic_ampdu_rxmax;	/* A-MPDU rx limit (bytes) */
530*10266SQuaker.Fang@Sun.COM 	int			ic_ampdu_density; /* A-MPDU density */
531*10266SQuaker.Fang@Sun.COM 	int			ic_ampdu_limit;	/* A-MPDU tx limit (bytes) */
532*10266SQuaker.Fang@Sun.COM 	int			ic_amsdu_limit;	/* A-MSDU tx limit (bytes) */
533*10266SQuaker.Fang@Sun.COM 
534*10266SQuaker.Fang@Sun.COM 	uint16_t		ic_sta_assoc;	/* stations associated */
535*10266SQuaker.Fang@Sun.COM 	uint16_t		ic_ht_sta_assoc; /* HT stations associated */
536*10266SQuaker.Fang@Sun.COM 	uint16_t		ic_ht40_sta_assoc; /* HT40 station associated */
537*10266SQuaker.Fang@Sun.COM 	uint8_t			ic_curhtprotmode; /* HTINFO bss state */
538*10266SQuaker.Fang@Sun.COM 	enum ieee80211_protmode	ic_htprotmode;	/* HT protection mode */
539*10266SQuaker.Fang@Sun.COM 	int			ic_lastnonerp;	/* last time nonERP sta noted */
540*10266SQuaker.Fang@Sun.COM 	int			ic_lastnonht;	/* last time non-HT sta noted */
541*10266SQuaker.Fang@Sun.COM 
542*10266SQuaker.Fang@Sun.COM 
5433147Sxc151355 	/* callback functions */
5443147Sxc151355 	/*
5453147Sxc151355 	 * Functions initialized by driver before calling ieee80211_attach()
5463147Sxc151355 	 * Those must be initialized are marked with M(andatory)
5473147Sxc151355 	 *
5483147Sxc151355 	 *  ic_xmit		- [M] transmit a management or null data frame
5493147Sxc151355 	 *			return 0 on success, non-zero on error
5503147Sxc151355 	 *  ic_watchdog		- [O] periodic run function, enabled by
5513147Sxc151355 	 *			ieee80211_start_watchdog()
5523147Sxc151355 	 *  ic_set_tim		- [O] set/clear traffic indication map
5533147Sxc151355 	 *  ic_set_shortslot	- [O] enable/disable short slot timing
5543147Sxc151355 	 *  ic_node_newassoc	- [O] driver specific operation on a newly
5553147Sxc151355 	 *			associated or re-assoced node
5563147Sxc151355 	 */
5573147Sxc151355 	int			(*ic_xmit)(ieee80211com_t *, mblk_t *, uint8_t);
5583147Sxc151355 	void			(*ic_watchdog)(void *);
5593147Sxc151355 	void			(*ic_set_tim)(ieee80211com_t *,
5603147Sxc151355 					ieee80211_node_t *, int);
5613147Sxc151355 	void			(*ic_set_shortslot)(ieee80211com_t *, int);
5623147Sxc151355 	void			(*ic_node_newassoc)(ieee80211_node_t *, int);
5633147Sxc151355 	/*
5643147Sxc151355 	 * Functions initialized by ieee80211_attach(), driver could
5653147Sxc151355 	 * override these functions after calling ieee80211_attach()
5663147Sxc151355 	 *
5673147Sxc151355 	 *  ic_reset		- reset
5683147Sxc151355 	 *  ic_recv_mgmt	- handle received management frames
5693147Sxc151355 	 *  ic_send_mgmt	- construct and transmit management frames
5703147Sxc151355 	 *  ic_newstate		- handle state transition
5713147Sxc151355 	 *  ic_node_alloc	- allocate a new BSS info node
5723147Sxc151355 	 *  ic_node_cleanup	- cleanup or free memory spaces of a node
5733147Sxc151355 	 *  ic_node_free	- free a node
5743147Sxc151355 	 *  ic_node_getrssi	- get node's rssi
5753147Sxc151355 	 */
5763147Sxc151355 	int			(*ic_reset)(ieee80211com_t *);
5773147Sxc151355 	void			(*ic_recv_mgmt)(ieee80211com_t *,
5783147Sxc151355 					mblk_t *, ieee80211_node_t *,
5793147Sxc151355 					int, int, uint32_t);
5803147Sxc151355 	int			(*ic_send_mgmt)(ieee80211com_t *,
5813147Sxc151355 					ieee80211_node_t *, int, int);
5823147Sxc151355 	int			(*ic_newstate)(ieee80211com_t *,
5833147Sxc151355 					enum ieee80211_state, int);
5843147Sxc151355 	struct ieee80211_node	*(*ic_node_alloc)(ieee80211com_t *);
5853147Sxc151355 	void			(*ic_node_cleanup)(ieee80211_node_t *);
5863147Sxc151355 	void			(*ic_node_free)(ieee80211_node_t *);
5873147Sxc151355 	uint8_t			(*ic_node_getrssi)(const ieee80211_node_t *);
588*10266SQuaker.Fang@Sun.COM 	void			(*ic_set_channel)(ieee80211com_t *);
589*10266SQuaker.Fang@Sun.COM 
590*10266SQuaker.Fang@Sun.COM 	/*
591*10266SQuaker.Fang@Sun.COM 	 * 802.11n ADDBA support.  A simple/generic implementation
592*10266SQuaker.Fang@Sun.COM 	 * of A-MPDU tx aggregation is provided; the driver may
593*10266SQuaker.Fang@Sun.COM 	 * override these methods to provide their own support.
594*10266SQuaker.Fang@Sun.COM 	 * A-MPDU rx re-ordering happens automatically if the
595*10266SQuaker.Fang@Sun.COM 	 * driver passes out-of-order frames to ieee80211_input
596*10266SQuaker.Fang@Sun.COM 	 * from an assocated HT station.
597*10266SQuaker.Fang@Sun.COM 	 */
598*10266SQuaker.Fang@Sun.COM 	void			(*ic_recv_action)(ieee80211_node_t *,
599*10266SQuaker.Fang@Sun.COM 				    const uint8_t *, const uint8_t *);
600*10266SQuaker.Fang@Sun.COM 	int			(*ic_send_action)(ieee80211_node_t *,
601*10266SQuaker.Fang@Sun.COM 				    int, int, uint16_t[4]);
602*10266SQuaker.Fang@Sun.COM 	/* start/stop doing A-MPDU tx aggregation for a station */
603*10266SQuaker.Fang@Sun.COM 	int			(*ic_addba_request)(ieee80211_node_t *,
604*10266SQuaker.Fang@Sun.COM 				    struct ieee80211_tx_ampdu *,
605*10266SQuaker.Fang@Sun.COM 				    int, int, int);
606*10266SQuaker.Fang@Sun.COM 	int			(*ic_addba_response)(ieee80211_node_t *,
607*10266SQuaker.Fang@Sun.COM 				    struct ieee80211_tx_ampdu *,
608*10266SQuaker.Fang@Sun.COM 				    int, int, int);
609*10266SQuaker.Fang@Sun.COM 	void			(*ic_addba_stop)(ieee80211_node_t *,
610*10266SQuaker.Fang@Sun.COM 				    struct ieee80211_tx_ampdu *);
6113147Sxc151355 
6123147Sxc151355 	kmutex_t		ic_genlock;
6133147Sxc151355 	void			*ic_private;	/* ieee80211 private data */
6143147Sxc151355 };
6153147Sxc151355 #define	ic_nw_keys		ic_crypto.cs_nw_keys
6163147Sxc151355 #define	ic_def_txkey		ic_crypto.cs_def_txkey
6173147Sxc151355 
6183147Sxc151355 extern	const char *ieee80211_state_name[IEEE80211_S_MAX];
619*10266SQuaker.Fang@Sun.COM extern	const char *ieee80211_wme_acnames[];
6203147Sxc151355 
6213147Sxc151355 #define	IEEE80211_RATE(_ix)			\
6223147Sxc151355 	(in->in_rates.ir_rates[(_ix)] & IEEE80211_RATE_VAL)
6233147Sxc151355 
6243147Sxc151355 #define	ieee80211_new_state(_ic, _nstate, _arg)	\
6253147Sxc151355 	(((_ic)->ic_newstate)((_ic), (_nstate), (_arg)))
6263147Sxc151355 
6273147Sxc151355 #define	ieee80211_macaddr_sprintf(_addr)	\
6283147Sxc151355 	ether_sprintf((struct ether_addr *)(_addr))
6293147Sxc151355 
6303147Sxc151355 /*
6313147Sxc151355  * Node reference counting definitions.
6323147Sxc151355  *
6333147Sxc151355  * ieee80211_node_initref	initialize the reference count to 1
6343147Sxc151355  * ieee80211_node_incref	add a reference
6353147Sxc151355  * ieee80211_node_decref	remove a reference
6363147Sxc151355  * ieee80211_node_decref_nv	remove a reference and return new value
6373147Sxc151355  * ieee80211_node_refcnt	reference count for printing (only)
6383147Sxc151355  */
6393147Sxc151355 #include <sys/atomic.h>
6403147Sxc151355 #define	ieee80211_node_initref(_in)		\
6413147Sxc151355 	((_in)->in_refcnt = 1)
6423147Sxc151355 #define	ieee80211_node_incref(_in)		\
6433147Sxc151355 	atomic_inc_uint(&(_in)->in_refcnt)
6443147Sxc151355 #define	ieee80211_node_decref(_in)		\
6453147Sxc151355 	atomic_dec_uint(&(_in)->in_refcnt)
6463147Sxc151355 #define	ieee80211_node_decref_nv(_in)		\
6473147Sxc151355 	atomic_dec_uint_nv(&(_in)->in_refcnt)
6483147Sxc151355 #define	ieee80211_node_refcnt(_in)		\
6493147Sxc151355 	(_in)->in_refcnt
6503147Sxc151355 
6513147Sxc151355 typedef void ieee80211_iter_func(void *, ieee80211_node_t *);
6523147Sxc151355 
6533147Sxc151355 /* Initialization */
6543147Sxc151355 void ieee80211_attach(ieee80211com_t *);
6553147Sxc151355 void ieee80211_detach(ieee80211com_t *);
6563147Sxc151355 void ieee80211_media_init(ieee80211com_t *);
6573147Sxc151355 int ieee80211_ioctl(ieee80211com_t *, queue_t *, mblk_t *);
6585296Szf162725 void ieee80211_register_door(ieee80211com_t *, const char *, int);
6593147Sxc151355 
6603147Sxc151355 /* Protocol Processing */
6613147Sxc151355 int ieee80211_input(ieee80211com_t *, mblk_t *, ieee80211_node_t *,
6623147Sxc151355 	int32_t, uint32_t);
6633147Sxc151355 mblk_t *ieee80211_encap(ieee80211com_t *, mblk_t *, ieee80211_node_t *);
6643147Sxc151355 
6653147Sxc151355 mblk_t *ieee80211_beacon_alloc(ieee80211com_t *, ieee80211_node_t *,
6663147Sxc151355 	struct ieee80211_beacon_offsets *);
6673147Sxc151355 int ieee80211_beacon_update(ieee80211com_t *, ieee80211_node_t *,
6683147Sxc151355 	struct ieee80211_beacon_offsets *, mblk_t *, int);
6693147Sxc151355 void ieee80211_beacon_miss(ieee80211com_t *);
6703147Sxc151355 
6713147Sxc151355 void ieee80211_begin_scan(ieee80211com_t *, boolean_t);
6723147Sxc151355 void ieee80211_next_scan(ieee80211com_t *);
6733147Sxc151355 void ieee80211_end_scan(ieee80211com_t *);
6743147Sxc151355 void ieee80211_cancel_scan(ieee80211com_t *);
6753147Sxc151355 
6763147Sxc151355 void ieee80211_sta_join(ieee80211com_t *, ieee80211_node_t *);
6773147Sxc151355 void ieee80211_sta_leave(ieee80211com_t *, ieee80211_node_t *);
6783147Sxc151355 boolean_t ieee80211_ibss_merge(ieee80211_node_t *);
6793147Sxc151355 
6803147Sxc151355 /* Node Operation */
6813147Sxc151355 ieee80211_node_t *ieee80211_ref_node(ieee80211_node_t *);
6823147Sxc151355 void ieee80211_unref_node(ieee80211_node_t **);
6833147Sxc151355 void ieee80211_node_authorize(ieee80211_node_t *);
6843147Sxc151355 void ieee80211_node_unauthorize(ieee80211_node_t *);
6853147Sxc151355 ieee80211_node_t *ieee80211_alloc_node(ieee80211com_t *,
6863147Sxc151355 	ieee80211_node_table_t *, const uint8_t *);
6873147Sxc151355 void ieee80211_free_node(ieee80211_node_t *);
6883147Sxc151355 void ieee80211_node_table_reset(ieee80211_node_table_t *);
6893147Sxc151355 void ieee80211_iterate_nodes(ieee80211_node_table_t *, ieee80211_iter_func *,
6903147Sxc151355 	void *);
6913147Sxc151355 ieee80211_node_t *ieee80211_find_node(ieee80211_node_table_t *,
6923147Sxc151355 	const uint8_t *);
6934126Szf162725 ieee80211_node_t *ieee80211_find_node_with_ssid(ieee80211_node_table_t *,
6944126Szf162725 	const uint8_t *, uint32_t, const uint8_t *);
6953147Sxc151355 ieee80211_node_t *ieee80211_find_txnode(ieee80211com_t *,
6963147Sxc151355 	const uint8_t daddr[IEEE80211_ADDR_LEN]);
6973147Sxc151355 ieee80211_node_t *ieee80211_find_rxnode(ieee80211com_t *,
6983147Sxc151355 	const struct ieee80211_frame *);
6993147Sxc151355 
7003147Sxc151355 
7013147Sxc151355 /* Crypto */
7023147Sxc151355 extern struct ieee80211_key *ieee80211_crypto_encap(ieee80211com_t *, mblk_t *);
7033147Sxc151355 extern struct ieee80211_key *ieee80211_crypto_decap(ieee80211com_t *, mblk_t *,
7043147Sxc151355 	int);
7053147Sxc151355 extern int ieee80211_crypto_newkey(ieee80211com_t *, int, int,
7063147Sxc151355 	struct ieee80211_key *);
7073147Sxc151355 extern int ieee80211_crypto_delkey(ieee80211com_t *, struct ieee80211_key *);
7083147Sxc151355 extern int ieee80211_crypto_setkey(ieee80211com_t *, struct ieee80211_key *,
7093147Sxc151355 	const uint8_t macaddr[IEEE80211_ADDR_LEN]);
7103147Sxc151355 
7113147Sxc151355 /* Helper Functions */
7123147Sxc151355 int ieee80211_stat(ieee80211com_t *ic, uint_t stat, uint64_t *val);
7133147Sxc151355 uint32_t ieee80211_chan2ieee(ieee80211com_t *, struct ieee80211_channel *);
7143147Sxc151355 enum ieee80211_phymode ieee80211_chan2mode(ieee80211com_t *,
7153147Sxc151355 	struct ieee80211_channel *);
7163147Sxc151355 uint32_t ieee80211_ieee2mhz(uint32_t, uint32_t);
7173147Sxc151355 void ieee80211_reset_chan(ieee80211com_t *);
7183147Sxc151355 void ieee80211_dump_pkt(const uint8_t *, int32_t, int32_t, int32_t);
7193147Sxc151355 void ieee80211_watchdog(void *);
7203147Sxc151355 void ieee80211_start_watchdog(ieee80211com_t *, uint32_t);
7213147Sxc151355 void ieee80211_stop_watchdog(ieee80211com_t *);
722*10266SQuaker.Fang@Sun.COM int ieee80211_classify(struct ieee80211com *, mblk_t *,
723*10266SQuaker.Fang@Sun.COM     struct ieee80211_node *);
724*10266SQuaker.Fang@Sun.COM int ieee80211_hdrsize(const void *);
725*10266SQuaker.Fang@Sun.COM int ieee80211_hdrspace(ieee80211com_t *, const void *);
726*10266SQuaker.Fang@Sun.COM int ieee80211_anyhdrsize(const void *);
727*10266SQuaker.Fang@Sun.COM int ieee80211_anyhdrspace(ieee80211com_t *, const void *);
7283147Sxc151355 
7294126Szf162725 void *ieee80211_malloc(size_t);
7304126Szf162725 void ieee80211_free(void *);
7317663SSowmini.Varadhan@Sun.COM int ieee80211_setprop(void *, const char *, mac_prop_id_t, uint_t,
7327663SSowmini.Varadhan@Sun.COM     const void *);
7337663SSowmini.Varadhan@Sun.COM int ieee80211_getprop(void *, const char *, mac_prop_id_t, uint_t, uint_t,
7348118SVasumathi.Sundaram@Sun.COM     void *, uint_t *);
7354126Szf162725 
736*10266SQuaker.Fang@Sun.COM struct ieee80211_channel *ieee80211_find_channel(ieee80211com_t *, int, int);
737*10266SQuaker.Fang@Sun.COM const struct ieee80211_rateset *ieee80211_get_suprates(ieee80211com_t *,
738*10266SQuaker.Fang@Sun.COM     struct ieee80211_channel *);
739*10266SQuaker.Fang@Sun.COM 
740*10266SQuaker.Fang@Sun.COM /* HT */
741*10266SQuaker.Fang@Sun.COM 
7423147Sxc151355 #ifdef	__cplusplus
7433147Sxc151355 }
7443147Sxc151355 #endif
7453147Sxc151355 
7463147Sxc151355 #endif	/* _SYS_NET80211_H */
747