xref: /dflybsd-src/sys/netproto/802_11/ieee80211_dragonfly.h (revision c332e0e8d3bc067a075fa42c1e3896f875c99b82)
132176cfdSRui Paulo /*-
232176cfdSRui Paulo  * Copyright (c) 2003-2008 Sam Leffler, Errno Consulting
3841ab66cSSepherosa Ziehau  * All rights reserved.
4841ab66cSSepherosa Ziehau  *
5841ab66cSSepherosa Ziehau  * Redistribution and use in source and binary forms, with or without
6841ab66cSSepherosa Ziehau  * modification, are permitted provided that the following conditions
7841ab66cSSepherosa Ziehau  * are met:
8841ab66cSSepherosa Ziehau  * 1. Redistributions of source code must retain the above copyright
9841ab66cSSepherosa Ziehau  *    notice, this list of conditions and the following disclaimer.
10841ab66cSSepherosa Ziehau  * 2. Redistributions in binary form must reproduce the above copyright
11841ab66cSSepherosa Ziehau  *    notice, this list of conditions and the following disclaimer in the
12841ab66cSSepherosa Ziehau  *    documentation and/or other materials provided with the distribution.
13841ab66cSSepherosa Ziehau  *
14841ab66cSSepherosa Ziehau  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15841ab66cSSepherosa Ziehau  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16841ab66cSSepherosa Ziehau  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17841ab66cSSepherosa Ziehau  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18841ab66cSSepherosa Ziehau  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19841ab66cSSepherosa Ziehau  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20841ab66cSSepherosa Ziehau  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21841ab66cSSepherosa Ziehau  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22841ab66cSSepherosa Ziehau  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23841ab66cSSepherosa Ziehau  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24841ab66cSSepherosa Ziehau  *
2532176cfdSRui Paulo  * $FreeBSD: head/sys/net80211/ieee80211_freebsd.h 195618 2009-07-11 15:02:45Z rpaulo $
26841ab66cSSepherosa Ziehau  */
27841ab66cSSepherosa Ziehau #ifndef _NET80211_IEEE80211_DRAGONFLY_H_
28841ab66cSSepherosa Ziehau #define _NET80211_IEEE80211_DRAGONFLY_H_
29841ab66cSSepherosa Ziehau 
3032176cfdSRui Paulo #ifdef _KERNEL
3126c6f223SMatthew Dillon 
3232176cfdSRui Paulo #include <sys/param.h>
3332176cfdSRui Paulo #include <sys/types.h>
3426c6f223SMatthew Dillon #include <sys/serialize.h>
3532176cfdSRui Paulo #include <sys/sysctl.h>
3626c6f223SMatthew Dillon #include <sys/condvar.h>
3732176cfdSRui Paulo #include <sys/taskqueue.h>
3832176cfdSRui Paulo 
3926c6f223SMatthew Dillon #include <sys/mutex2.h>
4026c6f223SMatthew Dillon #include <sys/serialize2.h>
4132176cfdSRui Paulo 
4232176cfdSRui Paulo #ifndef IF_PREPEND_LIST
4326c6f223SMatthew Dillon 
4432176cfdSRui Paulo #define _IF_PREPEND_LIST(ifq, mhead, mtail, mcount) do {	\
4532176cfdSRui Paulo 	(mtail)->m_nextpkt = (ifq)->ifq_head;			\
4632176cfdSRui Paulo 	if ((ifq)->ifq_tail == NULL)				\
4732176cfdSRui Paulo 		(ifq)->ifq_tail = (mtail);			\
4832176cfdSRui Paulo 	(ifq)->ifq_head = (mhead);				\
4932176cfdSRui Paulo 	(ifq)->ifq_len += (mcount);				\
50841ab66cSSepherosa Ziehau } while (0)
5126c6f223SMatthew Dillon 
5232176cfdSRui Paulo #define IF_PREPEND_LIST(ifq, mhead, mtail, mcount) do {		\
5326c6f223SMatthew Dillon 	wlan_assert_serialized();				\
5432176cfdSRui Paulo 	_IF_PREPEND_LIST(ifq, mhead, mtail, mcount);		\
55841ab66cSSepherosa Ziehau } while (0)
5626c6f223SMatthew Dillon 
5732176cfdSRui Paulo #endif /* IF_PREPEND_LIST */
5832176cfdSRui Paulo 
5932176cfdSRui Paulo /*
6026c6f223SMatthew Dillon  * Global serializer (operates like a non-reentrant lockmgr lock)
6132176cfdSRui Paulo  */
6226c6f223SMatthew Dillon extern struct lwkt_serialize wlan_global_serializer;
631b196a0cSMatthew Dillon extern int ieee80211_force_swcrypto;
6426c6f223SMatthew Dillon 
6551237956SMatthew Dillon #define wlan_serialize_enter()	_wlan_serialize_enter(__FUNCTION__)
6651237956SMatthew Dillon #define wlan_serialize_exit()	_wlan_serialize_exit(__FUNCTION__)
6751237956SMatthew Dillon void _wlan_serialize_enter(const char *funcname);
6851237956SMatthew Dillon void _wlan_serialize_exit(const char *funcname);
6926c6f223SMatthew Dillon int wlan_serialize_sleep(void *ident, int flags, const char *wmesg, int timo);
7026c6f223SMatthew Dillon 
7126c6f223SMatthew Dillon static __inline void
7226c6f223SMatthew Dillon wlan_assert_serialized(void)
7326c6f223SMatthew Dillon {
7426c6f223SMatthew Dillon 	ASSERT_SERIALIZED(&wlan_global_serializer);
7526c6f223SMatthew Dillon }
7632176cfdSRui Paulo 
7732176cfdSRui Paulo /*
7826c6f223SMatthew Dillon  * wlan condition variables.  Assume the global serializer is held.
7932176cfdSRui Paulo  */
8026c6f223SMatthew Dillon void wlan_cv_init(struct cv *cv, const char *desc);
8126c6f223SMatthew Dillon int wlan_cv_timedwait(struct cv *cv, int ticks);
8226c6f223SMatthew Dillon void wlan_cv_wait(struct cv *cv);
8326c6f223SMatthew Dillon void wlan_cv_signal(struct cv *cv, int broadcast);
84841ab66cSSepherosa Ziehau 
85841ab66cSSepherosa Ziehau /*
86841ab66cSSepherosa Ziehau  * Node reference counting definitions.
87841ab66cSSepherosa Ziehau  *
88841ab66cSSepherosa Ziehau  * ieee80211_node_initref	initialize the reference count to 1
89841ab66cSSepherosa Ziehau  * ieee80211_node_incref	add a reference
90841ab66cSSepherosa Ziehau  * ieee80211_node_decref	remove a reference
91841ab66cSSepherosa Ziehau  * ieee80211_node_dectestref	remove a reference and return 1 if this
92841ab66cSSepherosa Ziehau  *				is the last reference, otherwise 0
93841ab66cSSepherosa Ziehau  * ieee80211_node_refcnt	reference count for printing (only)
94841ab66cSSepherosa Ziehau  */
95841ab66cSSepherosa Ziehau #include <machine/atomic.h>
96841ab66cSSepherosa Ziehau 
97841ab66cSSepherosa Ziehau #define ieee80211_node_initref(_ni) \
98841ab66cSSepherosa Ziehau 	do { ((_ni)->ni_refcnt = 1); } while (0)
99841ab66cSSepherosa Ziehau #define ieee80211_node_incref(_ni) \
100841ab66cSSepherosa Ziehau 	atomic_add_int(&(_ni)->ni_refcnt, 1)
101841ab66cSSepherosa Ziehau #define	ieee80211_node_decref(_ni) \
102841ab66cSSepherosa Ziehau 	atomic_subtract_int(&(_ni)->ni_refcnt, 1)
103841ab66cSSepherosa Ziehau struct ieee80211_node;
104841ab66cSSepherosa Ziehau int	ieee80211_node_dectestref(struct ieee80211_node *ni);
105841ab66cSSepherosa Ziehau #define	ieee80211_node_refcnt(_ni)	(_ni)->ni_refcnt
106841ab66cSSepherosa Ziehau 
10732176cfdSRui Paulo struct ifqueue;
10832176cfdSRui Paulo struct ieee80211vap;
109*c332e0e8SSepherosa Ziehau void	ieee80211_flush_ifq(struct ifaltq *, struct ieee80211vap *);
1104b582d92SSepherosa Ziehau 
11132176cfdSRui Paulo void	ieee80211_vap_destroy(struct ieee80211vap *);
1123088f8e9SRui Paulo int	ieee80211_handoff(struct ifnet *, struct mbuf *);
113a13825b3SRui Paulo uint16_t ieee80211_txtime(struct ieee80211_node *, u_int, uint8_t, uint32_t);
11432176cfdSRui Paulo 
11532176cfdSRui Paulo #define	IFNET_IS_UP_RUNNING(_ifp) \
11632176cfdSRui Paulo 	(((_ifp)->if_flags & IFF_UP) && \
11734a60cf6SRui Paulo 	 ((_ifp)->if_flags & IFF_RUNNING))
11832176cfdSRui Paulo 
11932176cfdSRui Paulo #define	msecs_to_ticks(ms)	(((ms)*hz)/1000)
12032176cfdSRui Paulo #define	ticks_to_msecs(t)	(1000*(t) / hz)
12132176cfdSRui Paulo #define	ticks_to_secs(t)	((t) / hz)
12232176cfdSRui Paulo #define time_after(a,b) 	((long)(b) - (long)(a) < 0)
12332176cfdSRui Paulo #define time_before(a,b)	time_after(b,a)
12432176cfdSRui Paulo #define time_after_eq(a,b)	((long)(a) - (long)(b) >= 0)
12532176cfdSRui Paulo #define time_before_eq(a,b)	time_after_eq(b,a)
12632176cfdSRui Paulo 
12732176cfdSRui Paulo struct mbuf *ieee80211_getmgtframe(uint8_t **frm, int headroom, int pktlen);
12832176cfdSRui Paulo 
12932176cfdSRui Paulo /* tx path usage */
13032176cfdSRui Paulo #define	M_ENCAP		M_PROTO1		/* 802.11 encap done */
13132176cfdSRui Paulo #define	M_EAPOL		M_PROTO3		/* PAE/EAPOL frame */
132841ab66cSSepherosa Ziehau #define	M_PWR_SAV	M_PROTO4		/* bypass PS handling */
133841ab66cSSepherosa Ziehau #define	M_MORE_DATA	M_PROTO5		/* more data frames to follow */
13432176cfdSRui Paulo #define	M_FF		M_PROTO6		/* fast frame */
13532176cfdSRui Paulo #define	M_TXCB		M_PROTO7		/* do tx complete callback */
13632176cfdSRui Paulo #define	M_AMPDU_MPDU	M_PROTO8		/* ok for A-MPDU aggregation */
13732176cfdSRui Paulo #define	M_80211_TX \
13832176cfdSRui Paulo 	(M_FRAG|M_FIRSTFRAG|M_LASTFRAG|M_ENCAP|M_EAPOL|M_PWR_SAV|\
13932176cfdSRui Paulo 	 M_MORE_DATA|M_FF|M_TXCB|M_AMPDU_MPDU)
14032176cfdSRui Paulo 
14132176cfdSRui Paulo /* rx path usage */
14232176cfdSRui Paulo #define	M_AMPDU		M_PROTO1		/* A-MPDU subframe */
14332176cfdSRui Paulo #define	M_WEP		M_PROTO2		/* WEP done by hardware */
14432176cfdSRui Paulo #if 0
14532176cfdSRui Paulo #define	M_AMPDU_MPDU	M_PROTO8		/* A-MPDU re-order done */
14632176cfdSRui Paulo #endif
14732176cfdSRui Paulo #define	M_80211_RX	(M_AMPDU|M_WEP|M_AMPDU_MPDU)
14832176cfdSRui Paulo 
14932176cfdSRui Paulo #define	IEEE80211_MBUF_TX_FLAG_BITS \
15032176cfdSRui Paulo 	"\20\1M_EXT\2M_PKTHDR\3M_EOR\4M_RDONLY\5M_ENCAP\6M_WEP\7M_EAPOL" \
15132176cfdSRui Paulo 	"\10M_PWR_SAV\11M_MORE_DATA\12M_BCAST\13M_MCAST\14M_FRAG\15M_FIRSTFRAG" \
15232176cfdSRui Paulo 	"\16M_LASTFRAG\17M_SKIP_FIREWALL\20M_FREELIST\21M_VLANTAG\22M_PROMISC" \
15332176cfdSRui Paulo 	"\23M_NOFREE\24M_FF\25M_TXCB\26M_AMPDU_MPDU\27M_FLOWID"
15432176cfdSRui Paulo 
15532176cfdSRui Paulo #define	IEEE80211_MBUF_RX_FLAG_BITS \
15632176cfdSRui Paulo 	"\20\1M_EXT\2M_PKTHDR\3M_EOR\4M_RDONLY\5M_AMPDU\6M_WEP\7M_PROTO3" \
15732176cfdSRui Paulo 	"\10M_PROTO4\11M_PROTO5\12M_BCAST\13M_MCAST\14M_FRAG\15M_FIRSTFRAG" \
15832176cfdSRui Paulo 	"\16M_LASTFRAG\17M_SKIP_FIREWALL\20M_FREELIST\21M_VLANTAG\22M_PROMISC" \
15932176cfdSRui Paulo 	"\23M_NOFREE\24M_PROTO6\25M_PROTO7\26M_AMPDU_MPDU\27M_FLOWID"
16032176cfdSRui Paulo 
161841ab66cSSepherosa Ziehau /*
16232176cfdSRui Paulo  * Store WME access control bits in the vlan tag.
16332176cfdSRui Paulo  * This is safe since it's done after the packet is classified
16432176cfdSRui Paulo  * (where we use any previous tag) and because it's passed
16532176cfdSRui Paulo  * directly in to the driver and there's no chance someone
16632176cfdSRui Paulo  * else will clobber them on us.
167841ab66cSSepherosa Ziehau  */
168841ab66cSSepherosa Ziehau #define	M_WME_SETAC(m, ac) \
16932176cfdSRui Paulo 	((m)->m_pkthdr.ether_vlantag = (ac))
17032176cfdSRui Paulo #define	M_WME_GETAC(m)	((m)->m_pkthdr.ether_vlantag)
171841ab66cSSepherosa Ziehau 
172841ab66cSSepherosa Ziehau /*
173841ab66cSSepherosa Ziehau  * Mbufs on the power save queue are tagged with an age and
174841ab66cSSepherosa Ziehau  * timed out.  We reuse the hardware checksum field in the
175841ab66cSSepherosa Ziehau  * mbuf packet header to store this data.
176841ab66cSSepherosa Ziehau  */
177841ab66cSSepherosa Ziehau #define	M_AGE_SET(m,v)		(m->m_pkthdr.csum_data = v)
178841ab66cSSepherosa Ziehau #define	M_AGE_GET(m)		(m->m_pkthdr.csum_data)
179841ab66cSSepherosa Ziehau #define	M_AGE_SUB(m,adj)	(m->m_pkthdr.csum_data -= adj)
180841ab66cSSepherosa Ziehau 
18132176cfdSRui Paulo /*
18232176cfdSRui Paulo  * Store the sequence number.
18332176cfdSRui Paulo  */
18432176cfdSRui Paulo #define	M_SEQNO_SET(m, seqno) \
18534a60cf6SRui Paulo 	((m)->m_pkthdr.wlan_seqno = (seqno))
18634a60cf6SRui Paulo #define	M_SEQNO_GET(m)	((m)->m_pkthdr.wlan_seqno)
18732176cfdSRui Paulo 
18832176cfdSRui Paulo #define	MTAG_ABI_NET80211	1132948340	/* net80211 ABI */
18932176cfdSRui Paulo 
19032176cfdSRui Paulo struct ieee80211_cb {
19132176cfdSRui Paulo 	void	(*func)(struct ieee80211_node *, void *, int status);
19232176cfdSRui Paulo 	void	*arg;
19332176cfdSRui Paulo };
19432176cfdSRui Paulo #define	NET80211_TAG_CALLBACK	0	/* xmit complete callback */
19532176cfdSRui Paulo int	ieee80211_add_callback(struct mbuf *m,
19632176cfdSRui Paulo 		void (*func)(struct ieee80211_node *, void *, int), void *arg);
19732176cfdSRui Paulo void	ieee80211_process_callback(struct ieee80211_node *, struct mbuf *, int);
19832176cfdSRui Paulo 
199841ab66cSSepherosa Ziehau void	get_random_bytes(void *, size_t);
200841ab66cSSepherosa Ziehau 
201841ab66cSSepherosa Ziehau struct ieee80211com;
202841ab66cSSepherosa Ziehau 
203841ab66cSSepherosa Ziehau void	ieee80211_sysctl_attach(struct ieee80211com *);
204841ab66cSSepherosa Ziehau void	ieee80211_sysctl_detach(struct ieee80211com *);
20532176cfdSRui Paulo void	ieee80211_sysctl_vattach(struct ieee80211vap *);
20632176cfdSRui Paulo void	ieee80211_sysctl_vdetach(struct ieee80211vap *);
20732176cfdSRui Paulo 
20832176cfdSRui Paulo SYSCTL_DECL(_net_wlan);
20932176cfdSRui Paulo int	ieee80211_sysctl_msecs_ticks(SYSCTL_HANDLER_ARGS);
210841ab66cSSepherosa Ziehau 
211841ab66cSSepherosa Ziehau void	ieee80211_load_module(const char *);
21232176cfdSRui Paulo 
21332176cfdSRui Paulo /*
21432176cfdSRui Paulo  * A "policy module" is an adjunct module to net80211 that provides
21532176cfdSRui Paulo  * functionality that typically includes policy decisions.  This
21632176cfdSRui Paulo  * modularity enables extensibility and vendor-supplied functionality.
21732176cfdSRui Paulo  */
21832176cfdSRui Paulo #define	_IEEE80211_POLICY_MODULE(policy, name, version)			\
21932176cfdSRui Paulo typedef void (*policy##_setup)(int);					\
22032176cfdSRui Paulo SET_DECLARE(policy##_set, policy##_setup);				\
22132176cfdSRui Paulo static int								\
22232176cfdSRui Paulo wlan_##name##_modevent(module_t mod, int type, void *unused)		\
22332176cfdSRui Paulo {									\
22432176cfdSRui Paulo 	policy##_setup * const *iter, f;				\
22547156d48SMatthew Dillon 	int error;							\
22647156d48SMatthew Dillon 									\
22747156d48SMatthew Dillon 	wlan_serialize_enter();						\
22847156d48SMatthew Dillon 									\
22932176cfdSRui Paulo 	switch (type) {							\
23032176cfdSRui Paulo 	case MOD_LOAD:							\
23132176cfdSRui Paulo 		SET_FOREACH(iter, policy##_set) {			\
23232176cfdSRui Paulo 			f = (void*) *iter;				\
23332176cfdSRui Paulo 			f(type);					\
23432176cfdSRui Paulo 		}							\
23547156d48SMatthew Dillon 		error = 0;						\
23647156d48SMatthew Dillon 		break;							\
23732176cfdSRui Paulo 	case MOD_UNLOAD:						\
23851237956SMatthew Dillon 		error = 0;						\
23932176cfdSRui Paulo 		if (nrefs) {						\
24047156d48SMatthew Dillon 			kprintf("wlan_##name: still in use (%u "	\
24147156d48SMatthew Dillon 				"dynamic refs)\n",			\
24232176cfdSRui Paulo 				nrefs);					\
24351237956SMatthew Dillon 			error = EBUSY;					\
24451237956SMatthew Dillon 		} else if (type == MOD_UNLOAD) {			\
24532176cfdSRui Paulo 			SET_FOREACH(iter, policy##_set) {		\
24632176cfdSRui Paulo 				f = (void*) *iter;			\
24732176cfdSRui Paulo 				f(type);				\
24832176cfdSRui Paulo 			}						\
24932176cfdSRui Paulo 		}							\
25047156d48SMatthew Dillon 		break;							\
25147156d48SMatthew Dillon 	default:							\
25247156d48SMatthew Dillon 		error = EINVAL;						\
25347156d48SMatthew Dillon 		break;							\
25432176cfdSRui Paulo 	}								\
25547156d48SMatthew Dillon 									\
25647156d48SMatthew Dillon 	wlan_serialize_exit();						\
25747156d48SMatthew Dillon 									\
25847156d48SMatthew Dillon 	return error;							\
25932176cfdSRui Paulo }									\
26032176cfdSRui Paulo static moduledata_t name##_mod = {					\
26132176cfdSRui Paulo 	"wlan_" #name,							\
26232176cfdSRui Paulo 	wlan_##name##_modevent,						\
26332176cfdSRui Paulo 	0								\
26432176cfdSRui Paulo };									\
26532176cfdSRui Paulo DECLARE_MODULE(wlan_##name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST);\
26632176cfdSRui Paulo MODULE_VERSION(wlan_##name, version);					\
26732176cfdSRui Paulo MODULE_DEPEND(wlan_##name, wlan, 1, 1, 1)
26832176cfdSRui Paulo 
26932176cfdSRui Paulo /*
27032176cfdSRui Paulo  * Crypto modules implement cipher support.
27132176cfdSRui Paulo  */
27232176cfdSRui Paulo #define	IEEE80211_CRYPTO_MODULE(name, version)				\
27332176cfdSRui Paulo _IEEE80211_POLICY_MODULE(crypto, name, version);			\
27432176cfdSRui Paulo static void								\
27532176cfdSRui Paulo name##_modevent(int type)						\
27632176cfdSRui Paulo {									\
27751237956SMatthew Dillon 	/* wlan already serialized! */					\
27832176cfdSRui Paulo 	if (type == MOD_LOAD)						\
27932176cfdSRui Paulo 		ieee80211_crypto_register(&name);			\
28032176cfdSRui Paulo 	else								\
28132176cfdSRui Paulo 		ieee80211_crypto_unregister(&name);			\
28232176cfdSRui Paulo }									\
28332176cfdSRui Paulo TEXT_SET(crypto##_set, name##_modevent)
28432176cfdSRui Paulo 
28532176cfdSRui Paulo /*
28632176cfdSRui Paulo  * Scanner modules provide scanning policy.
28732176cfdSRui Paulo  */
28832176cfdSRui Paulo #define	IEEE80211_SCANNER_MODULE(name, version)				\
28932176cfdSRui Paulo 	_IEEE80211_POLICY_MODULE(scanner, name, version)
29032176cfdSRui Paulo 
29132176cfdSRui Paulo #define	IEEE80211_SCANNER_ALG(name, alg, v)				\
29232176cfdSRui Paulo static void								\
29332176cfdSRui Paulo name##_modevent(int type)						\
29432176cfdSRui Paulo {									\
29551237956SMatthew Dillon 	/* wlan already serialized! */					\
29632176cfdSRui Paulo 	if (type == MOD_LOAD)						\
29732176cfdSRui Paulo 		ieee80211_scanner_register(alg, &v);			\
29832176cfdSRui Paulo 	else								\
29932176cfdSRui Paulo 		ieee80211_scanner_unregister(alg, &v);			\
30032176cfdSRui Paulo }									\
30132176cfdSRui Paulo TEXT_SET(scanner_set, name##_modevent);					\
30232176cfdSRui Paulo 
30332176cfdSRui Paulo /*
30432176cfdSRui Paulo  * ACL modules implement acl policy.
30532176cfdSRui Paulo  */
30632176cfdSRui Paulo #define	IEEE80211_ACL_MODULE(name, alg, version)			\
30732176cfdSRui Paulo _IEEE80211_POLICY_MODULE(acl, name, version);				\
30832176cfdSRui Paulo static void								\
30932176cfdSRui Paulo alg##_modevent(int type)						\
31032176cfdSRui Paulo {									\
31151237956SMatthew Dillon 	/* wlan already serialized! */					\
31232176cfdSRui Paulo 	if (type == MOD_LOAD)						\
31332176cfdSRui Paulo 		ieee80211_aclator_register(&alg);			\
31432176cfdSRui Paulo 	else								\
31532176cfdSRui Paulo 		ieee80211_aclator_unregister(&alg);			\
31632176cfdSRui Paulo }									\
31732176cfdSRui Paulo TEXT_SET(acl_set, alg##_modevent);					\
31832176cfdSRui Paulo 
31932176cfdSRui Paulo /*
32032176cfdSRui Paulo  * Authenticator modules handle 802.1x/WPA authentication.
32132176cfdSRui Paulo  */
32232176cfdSRui Paulo #define	IEEE80211_AUTH_MODULE(name, version)				\
32332176cfdSRui Paulo 	_IEEE80211_POLICY_MODULE(auth, name, version)
32432176cfdSRui Paulo 
32532176cfdSRui Paulo #define	IEEE80211_AUTH_ALG(name, alg, v)				\
32632176cfdSRui Paulo static void								\
32732176cfdSRui Paulo name##_modevent(int type)						\
32832176cfdSRui Paulo {									\
32951237956SMatthew Dillon 	/* wlan already serialized! */					\
33032176cfdSRui Paulo 	if (type == MOD_LOAD)						\
33132176cfdSRui Paulo 		ieee80211_authenticator_register(alg, &v);		\
33232176cfdSRui Paulo 	else								\
33332176cfdSRui Paulo 		ieee80211_authenticator_unregister(alg);		\
33432176cfdSRui Paulo }									\
33532176cfdSRui Paulo TEXT_SET(auth_set, name##_modevent)
33632176cfdSRui Paulo 
33732176cfdSRui Paulo /*
33832176cfdSRui Paulo  * Rate control modules provide tx rate control support.
33932176cfdSRui Paulo  */
3404028af95SRui Paulo #define	IEEE80211_RATECTL_MODULE(alg, version)				\
3414028af95SRui Paulo 	_IEEE80211_POLICY_MODULE(ratectl, alg, version);		\
3424028af95SRui Paulo 
3434028af95SRui Paulo #define	IEEE80211_RATECTL_ALG(name, alg, v)				\
34432176cfdSRui Paulo static void								\
34532176cfdSRui Paulo alg##_modevent(int type)						\
34632176cfdSRui Paulo {									\
34751237956SMatthew Dillon 	/* wlan already serialized! */					\
3484028af95SRui Paulo 	if (type == MOD_LOAD)						\
3494028af95SRui Paulo 		ieee80211_ratectl_register(alg, &v);			\
3504028af95SRui Paulo 	else								\
3514028af95SRui Paulo 		ieee80211_ratectl_unregister(alg);			\
35232176cfdSRui Paulo }									\
3534028af95SRui Paulo TEXT_SET(ratectl##_set, alg##_modevent)
35432176cfdSRui Paulo 
35532176cfdSRui Paulo struct ieee80211req;
35632176cfdSRui Paulo typedef int ieee80211_ioctl_getfunc(struct ieee80211vap *,
35732176cfdSRui Paulo     struct ieee80211req *);
35832176cfdSRui Paulo SET_DECLARE(ieee80211_ioctl_getset, ieee80211_ioctl_getfunc);
35932176cfdSRui Paulo #define	IEEE80211_IOCTL_GET(_name, _get) TEXT_SET(ieee80211_ioctl_getset, _get)
36032176cfdSRui Paulo 
36132176cfdSRui Paulo typedef int ieee80211_ioctl_setfunc(struct ieee80211vap *,
36232176cfdSRui Paulo     struct ieee80211req *);
36332176cfdSRui Paulo SET_DECLARE(ieee80211_ioctl_setset, ieee80211_ioctl_setfunc);
36432176cfdSRui Paulo #define	IEEE80211_IOCTL_SET(_name, _set) TEXT_SET(ieee80211_ioctl_setset, _set)
36532176cfdSRui Paulo #endif /* _KERNEL */
366841ab66cSSepherosa Ziehau 
367841ab66cSSepherosa Ziehau /* XXX this stuff belongs elsewhere */
368841ab66cSSepherosa Ziehau /*
369841ab66cSSepherosa Ziehau  * Message formats for messages from the net80211 layer to user
370841ab66cSSepherosa Ziehau  * applications via the routing socket.  These messages are appended
371841ab66cSSepherosa Ziehau  * to an if_announcemsghdr structure.
372841ab66cSSepherosa Ziehau  */
373841ab66cSSepherosa Ziehau struct ieee80211_join_event {
374841ab66cSSepherosa Ziehau 	uint8_t		iev_addr[6];
375841ab66cSSepherosa Ziehau };
376841ab66cSSepherosa Ziehau 
377841ab66cSSepherosa Ziehau struct ieee80211_leave_event {
378841ab66cSSepherosa Ziehau 	uint8_t		iev_addr[6];
379841ab66cSSepherosa Ziehau };
380841ab66cSSepherosa Ziehau 
381841ab66cSSepherosa Ziehau struct ieee80211_replay_event {
382841ab66cSSepherosa Ziehau 	uint8_t		iev_src[6];	/* src MAC */
383841ab66cSSepherosa Ziehau 	uint8_t		iev_dst[6];	/* dst MAC */
384841ab66cSSepherosa Ziehau 	uint8_t		iev_cipher;	/* cipher type */
385841ab66cSSepherosa Ziehau 	uint8_t		iev_keyix;	/* key id/index */
386841ab66cSSepherosa Ziehau 	uint64_t	iev_keyrsc;	/* RSC from key */
387841ab66cSSepherosa Ziehau 	uint64_t	iev_rsc;	/* RSC from frame */
388841ab66cSSepherosa Ziehau };
389841ab66cSSepherosa Ziehau 
390841ab66cSSepherosa Ziehau struct ieee80211_michael_event {
391841ab66cSSepherosa Ziehau 	uint8_t		iev_src[6];	/* src MAC */
392841ab66cSSepherosa Ziehau 	uint8_t		iev_dst[6];	/* dst MAC */
393841ab66cSSepherosa Ziehau 	uint8_t		iev_cipher;	/* cipher type */
394841ab66cSSepherosa Ziehau 	uint8_t		iev_keyix;	/* key id/index */
395841ab66cSSepherosa Ziehau };
396841ab66cSSepherosa Ziehau 
39732176cfdSRui Paulo struct ieee80211_wds_event {
39832176cfdSRui Paulo 	uint8_t		iev_addr[6];
39932176cfdSRui Paulo };
40032176cfdSRui Paulo 
40132176cfdSRui Paulo struct ieee80211_csa_event {
40232176cfdSRui Paulo 	uint32_t	iev_flags;	/* channel flags */
40332176cfdSRui Paulo 	uint16_t	iev_freq;	/* setting in Mhz */
40432176cfdSRui Paulo 	uint8_t		iev_ieee;	/* IEEE channel number */
40532176cfdSRui Paulo 	uint8_t		iev_mode;	/* CSA mode */
40632176cfdSRui Paulo 	uint8_t		iev_count;	/* CSA count */
40732176cfdSRui Paulo };
40832176cfdSRui Paulo 
40932176cfdSRui Paulo struct ieee80211_cac_event {
41032176cfdSRui Paulo 	uint32_t	iev_flags;	/* channel flags */
41132176cfdSRui Paulo 	uint16_t	iev_freq;	/* setting in Mhz */
41232176cfdSRui Paulo 	uint8_t		iev_ieee;	/* IEEE channel number */
41332176cfdSRui Paulo 	/* XXX timestamp? */
41432176cfdSRui Paulo 	uint8_t		iev_type;	/* IEEE80211_NOTIFY_CAC_* */
41532176cfdSRui Paulo };
41632176cfdSRui Paulo 
41732176cfdSRui Paulo struct ieee80211_radar_event {
41832176cfdSRui Paulo 	uint32_t	iev_flags;	/* channel flags */
41932176cfdSRui Paulo 	uint16_t	iev_freq;	/* setting in Mhz */
42032176cfdSRui Paulo 	uint8_t		iev_ieee;	/* IEEE channel number */
42132176cfdSRui Paulo 	/* XXX timestamp? */
42232176cfdSRui Paulo };
42332176cfdSRui Paulo 
42432176cfdSRui Paulo struct ieee80211_auth_event {
42532176cfdSRui Paulo 	uint8_t		iev_addr[6];
42632176cfdSRui Paulo };
42732176cfdSRui Paulo 
42832176cfdSRui Paulo struct ieee80211_deauth_event {
42932176cfdSRui Paulo 	uint8_t		iev_addr[6];
43032176cfdSRui Paulo };
43132176cfdSRui Paulo 
43232176cfdSRui Paulo struct ieee80211_country_event {
43332176cfdSRui Paulo 	uint8_t		iev_addr[6];
43432176cfdSRui Paulo 	uint8_t		iev_cc[2];	/* ISO country code */
43532176cfdSRui Paulo };
43632176cfdSRui Paulo 
43732176cfdSRui Paulo struct ieee80211_radio_event {
43832176cfdSRui Paulo 	uint8_t		iev_state;	/* 1 on, 0 off */
43932176cfdSRui Paulo };
44032176cfdSRui Paulo 
441841ab66cSSepherosa Ziehau #define	RTM_IEEE80211_ASSOC	100	/* station associate (bss mode) */
442841ab66cSSepherosa Ziehau #define	RTM_IEEE80211_REASSOC	101	/* station re-associate (bss mode) */
443841ab66cSSepherosa Ziehau #define	RTM_IEEE80211_DISASSOC	102	/* station disassociate (bss mode) */
444841ab66cSSepherosa Ziehau #define	RTM_IEEE80211_JOIN	103	/* station join (ap mode) */
445841ab66cSSepherosa Ziehau #define	RTM_IEEE80211_LEAVE	104	/* station leave (ap mode) */
446841ab66cSSepherosa Ziehau #define	RTM_IEEE80211_SCAN	105	/* scan complete, results available */
447841ab66cSSepherosa Ziehau #define	RTM_IEEE80211_REPLAY	106	/* sequence counter replay detected */
448841ab66cSSepherosa Ziehau #define	RTM_IEEE80211_MICHAEL	107	/* Michael MIC failure detected */
449841ab66cSSepherosa Ziehau #define	RTM_IEEE80211_REJOIN	108	/* station re-associate (ap mode) */
45032176cfdSRui Paulo #define	RTM_IEEE80211_WDS	109	/* WDS discovery (ap mode) */
45132176cfdSRui Paulo #define	RTM_IEEE80211_CSA	110	/* Channel Switch Announcement event */
45232176cfdSRui Paulo #define	RTM_IEEE80211_RADAR	111	/* radar event */
45332176cfdSRui Paulo #define	RTM_IEEE80211_CAC	112	/* Channel Availability Check event */
45432176cfdSRui Paulo #define	RTM_IEEE80211_DEAUTH	113	/* station deauthenticate */
45532176cfdSRui Paulo #define	RTM_IEEE80211_AUTH	114	/* station authenticate (ap mode) */
45632176cfdSRui Paulo #define	RTM_IEEE80211_COUNTRY	115	/* discovered country code (sta mode) */
45732176cfdSRui Paulo #define	RTM_IEEE80211_RADIO	116	/* RF kill switch state change */
458841ab66cSSepherosa Ziehau 
45932176cfdSRui Paulo /*
46032176cfdSRui Paulo  * Structure prepended to raw packets sent through the bpf
46132176cfdSRui Paulo  * interface when set to DLT_IEEE802_11_RADIO.  This allows
46232176cfdSRui Paulo  * user applications to specify pretty much everything in
46332176cfdSRui Paulo  * an Atheros tx descriptor.  XXX need to generalize.
46432176cfdSRui Paulo  *
46532176cfdSRui Paulo  * XXX cannot be more than 14 bytes as it is copied to a sockaddr's
46632176cfdSRui Paulo  * XXX sa_data area.
46732176cfdSRui Paulo  */
46832176cfdSRui Paulo struct ieee80211_bpf_params {
46932176cfdSRui Paulo 	uint8_t		ibp_vers;	/* version */
47032176cfdSRui Paulo #define	IEEE80211_BPF_VERSION	0
47132176cfdSRui Paulo 	uint8_t		ibp_len;	/* header length in bytes */
47232176cfdSRui Paulo 	uint8_t		ibp_flags;
47332176cfdSRui Paulo #define	IEEE80211_BPF_SHORTPRE	0x01	/* tx with short preamble */
47432176cfdSRui Paulo #define	IEEE80211_BPF_NOACK	0x02	/* tx with no ack */
47532176cfdSRui Paulo #define	IEEE80211_BPF_CRYPTO	0x04	/* tx with h/w encryption */
47632176cfdSRui Paulo #define	IEEE80211_BPF_FCS	0x10	/* frame incldues FCS */
47732176cfdSRui Paulo #define	IEEE80211_BPF_DATAPAD	0x20	/* frame includes data padding */
47832176cfdSRui Paulo #define	IEEE80211_BPF_RTS	0x40	/* tx with RTS/CTS */
47932176cfdSRui Paulo #define	IEEE80211_BPF_CTS	0x80	/* tx with CTS only */
48032176cfdSRui Paulo 	uint8_t		ibp_pri;	/* WME/WMM AC+tx antenna */
48132176cfdSRui Paulo 	uint8_t		ibp_try0;	/* series 1 try count */
48232176cfdSRui Paulo 	uint8_t		ibp_rate0;	/* series 1 IEEE tx rate */
48332176cfdSRui Paulo 	uint8_t		ibp_power;	/* tx power (device units) */
48432176cfdSRui Paulo 	uint8_t		ibp_ctsrate;	/* IEEE tx rate for CTS */
48532176cfdSRui Paulo 	uint8_t		ibp_try1;	/* series 2 try count */
48632176cfdSRui Paulo 	uint8_t		ibp_rate1;	/* series 2 IEEE tx rate */
48732176cfdSRui Paulo 	uint8_t		ibp_try2;	/* series 3 try count */
48832176cfdSRui Paulo 	uint8_t		ibp_rate2;	/* series 3 IEEE tx rate */
48932176cfdSRui Paulo 	uint8_t		ibp_try3;	/* series 4 try count */
49032176cfdSRui Paulo 	uint8_t		ibp_rate3;	/* series 4 IEEE tx rate */
49132176cfdSRui Paulo };
492841ab66cSSepherosa Ziehau #endif /* _NET80211_IEEE80211_DRAGONFLY_H_ */
493