xref: /dflybsd-src/sys/netproto/802_11/ieee80211_dragonfly.h (revision 26c6f2232fbf5e8d1c724e0b6eab7831184f292d)
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 $
2632176cfdSRui Paulo  * $DragonFly$
27841ab66cSSepherosa Ziehau  */
28841ab66cSSepherosa Ziehau #ifndef _NET80211_IEEE80211_DRAGONFLY_H_
29841ab66cSSepherosa Ziehau #define _NET80211_IEEE80211_DRAGONFLY_H_
30841ab66cSSepherosa Ziehau 
3132176cfdSRui Paulo #ifdef _KERNEL
32*26c6f223SMatthew Dillon 
3332176cfdSRui Paulo #include <sys/param.h>
3432176cfdSRui Paulo #include <sys/types.h>
35*26c6f223SMatthew Dillon #include <sys/serialize.h>
3632176cfdSRui Paulo #include <sys/sysctl.h>
37*26c6f223SMatthew Dillon #include <sys/condvar.h>
3832176cfdSRui Paulo #include <sys/taskqueue.h>
3932176cfdSRui Paulo 
40*26c6f223SMatthew Dillon #include <sys/mutex2.h>
41*26c6f223SMatthew Dillon #include <sys/serialize2.h>
4232176cfdSRui Paulo 
4332176cfdSRui Paulo #ifndef IF_PREPEND_LIST
44*26c6f223SMatthew Dillon 
4532176cfdSRui Paulo #define _IF_PREPEND_LIST(ifq, mhead, mtail, mcount) do {	\
4632176cfdSRui Paulo 	(mtail)->m_nextpkt = (ifq)->ifq_head;			\
4732176cfdSRui Paulo 	if ((ifq)->ifq_tail == NULL)				\
4832176cfdSRui Paulo 		(ifq)->ifq_tail = (mtail);			\
4932176cfdSRui Paulo 	(ifq)->ifq_head = (mhead);				\
5032176cfdSRui Paulo 	(ifq)->ifq_len += (mcount);				\
51841ab66cSSepherosa Ziehau } while (0)
52*26c6f223SMatthew Dillon 
5332176cfdSRui Paulo #define IF_PREPEND_LIST(ifq, mhead, mtail, mcount) do {		\
54*26c6f223SMatthew Dillon 	wlan_assert_serialized();				\
5532176cfdSRui Paulo 	_IF_PREPEND_LIST(ifq, mhead, mtail, mcount);		\
56841ab66cSSepherosa Ziehau } while (0)
57*26c6f223SMatthew Dillon 
5832176cfdSRui Paulo #endif /* IF_PREPEND_LIST */
5932176cfdSRui Paulo 
6032176cfdSRui Paulo /*
61*26c6f223SMatthew Dillon  * Global serializer (operates like a non-reentrant lockmgr lock)
6232176cfdSRui Paulo  */
63*26c6f223SMatthew Dillon extern struct lwkt_serialize wlan_global_serializer;
64*26c6f223SMatthew Dillon 
65*26c6f223SMatthew Dillon void wlan_serialize_enter(void);
66*26c6f223SMatthew Dillon void wlan_serialize_exit(void);
67*26c6f223SMatthew Dillon int wlan_serialize_sleep(void *ident, int flags, const char *wmesg, int timo);
68*26c6f223SMatthew Dillon 
69*26c6f223SMatthew Dillon static __inline void
70*26c6f223SMatthew Dillon wlan_assert_serialized(void)
71*26c6f223SMatthew Dillon {
72*26c6f223SMatthew Dillon 	ASSERT_SERIALIZED(&wlan_global_serializer);
73*26c6f223SMatthew Dillon }
7432176cfdSRui Paulo 
7532176cfdSRui Paulo /*
76*26c6f223SMatthew Dillon  * wlan condition variables.  Assume the global serializer is held.
7732176cfdSRui Paulo  */
78*26c6f223SMatthew Dillon void wlan_cv_init(struct cv *cv, const char *desc);
79*26c6f223SMatthew Dillon int wlan_cv_timedwait(struct cv *cv, int ticks);
80*26c6f223SMatthew Dillon void wlan_cv_wait(struct cv *cv);
81*26c6f223SMatthew Dillon void wlan_cv_signal(struct cv *cv, int broadcast);
82841ab66cSSepherosa Ziehau 
83841ab66cSSepherosa Ziehau /*
84841ab66cSSepherosa Ziehau  * Node reference counting definitions.
85841ab66cSSepherosa Ziehau  *
86841ab66cSSepherosa Ziehau  * ieee80211_node_initref	initialize the reference count to 1
87841ab66cSSepherosa Ziehau  * ieee80211_node_incref	add a reference
88841ab66cSSepherosa Ziehau  * ieee80211_node_decref	remove a reference
89841ab66cSSepherosa Ziehau  * ieee80211_node_dectestref	remove a reference and return 1 if this
90841ab66cSSepherosa Ziehau  *				is the last reference, otherwise 0
91841ab66cSSepherosa Ziehau  * ieee80211_node_refcnt	reference count for printing (only)
92841ab66cSSepherosa Ziehau  */
93841ab66cSSepherosa Ziehau #include <machine/atomic.h>
94841ab66cSSepherosa Ziehau 
95841ab66cSSepherosa Ziehau #define ieee80211_node_initref(_ni) \
96841ab66cSSepherosa Ziehau 	do { ((_ni)->ni_refcnt = 1); } while (0)
97841ab66cSSepherosa Ziehau #define ieee80211_node_incref(_ni) \
98841ab66cSSepherosa Ziehau 	atomic_add_int(&(_ni)->ni_refcnt, 1)
99841ab66cSSepherosa Ziehau #define	ieee80211_node_decref(_ni) \
100841ab66cSSepherosa Ziehau 	atomic_subtract_int(&(_ni)->ni_refcnt, 1)
101841ab66cSSepherosa Ziehau struct ieee80211_node;
102841ab66cSSepherosa Ziehau int	ieee80211_node_dectestref(struct ieee80211_node *ni);
103841ab66cSSepherosa Ziehau #define	ieee80211_node_refcnt(_ni)	(_ni)->ni_refcnt
104841ab66cSSepherosa Ziehau 
10532176cfdSRui Paulo struct ifqueue;
10632176cfdSRui Paulo struct ieee80211vap;
10732176cfdSRui Paulo void	ieee80211_drain_ifq(struct ifqueue *);
10832176cfdSRui Paulo void	ieee80211_flush_ifq(struct ifqueue *, struct ieee80211vap *);
1094b582d92SSepherosa Ziehau 
11032176cfdSRui Paulo void	ieee80211_vap_destroy(struct ieee80211vap *);
1113088f8e9SRui Paulo int	ieee80211_handoff(struct ifnet *, struct mbuf *);
112a13825b3SRui Paulo uint16_t ieee80211_txtime(struct ieee80211_node *, u_int, uint8_t, uint32_t);
11332176cfdSRui Paulo 
11432176cfdSRui Paulo #define	IFNET_IS_UP_RUNNING(_ifp) \
11532176cfdSRui Paulo 	(((_ifp)->if_flags & IFF_UP) && \
11634a60cf6SRui Paulo 	 ((_ifp)->if_flags & IFF_RUNNING))
11732176cfdSRui Paulo 
11832176cfdSRui Paulo #define	msecs_to_ticks(ms)	(((ms)*hz)/1000)
11932176cfdSRui Paulo #define	ticks_to_msecs(t)	(1000*(t) / hz)
12032176cfdSRui Paulo #define	ticks_to_secs(t)	((t) / hz)
12132176cfdSRui Paulo #define time_after(a,b) 	((long)(b) - (long)(a) < 0)
12232176cfdSRui Paulo #define time_before(a,b)	time_after(b,a)
12332176cfdSRui Paulo #define time_after_eq(a,b)	((long)(a) - (long)(b) >= 0)
12432176cfdSRui Paulo #define time_before_eq(a,b)	time_after_eq(b,a)
12532176cfdSRui Paulo 
12632176cfdSRui Paulo struct mbuf *ieee80211_getmgtframe(uint8_t **frm, int headroom, int pktlen);
12732176cfdSRui Paulo 
12832176cfdSRui Paulo /* tx path usage */
12932176cfdSRui Paulo #define	M_ENCAP		M_PROTO1		/* 802.11 encap done */
13032176cfdSRui Paulo #define	M_EAPOL		M_PROTO3		/* PAE/EAPOL frame */
131841ab66cSSepherosa Ziehau #define	M_PWR_SAV	M_PROTO4		/* bypass PS handling */
132841ab66cSSepherosa Ziehau #define	M_MORE_DATA	M_PROTO5		/* more data frames to follow */
13332176cfdSRui Paulo #define	M_FF		M_PROTO6		/* fast frame */
13432176cfdSRui Paulo #define	M_TXCB		M_PROTO7		/* do tx complete callback */
13532176cfdSRui Paulo #define	M_AMPDU_MPDU	M_PROTO8		/* ok for A-MPDU aggregation */
13632176cfdSRui Paulo #define	M_80211_TX \
13732176cfdSRui Paulo 	(M_FRAG|M_FIRSTFRAG|M_LASTFRAG|M_ENCAP|M_EAPOL|M_PWR_SAV|\
13832176cfdSRui Paulo 	 M_MORE_DATA|M_FF|M_TXCB|M_AMPDU_MPDU)
13932176cfdSRui Paulo 
14032176cfdSRui Paulo /* rx path usage */
14132176cfdSRui Paulo #define	M_AMPDU		M_PROTO1		/* A-MPDU subframe */
14232176cfdSRui Paulo #define	M_WEP		M_PROTO2		/* WEP done by hardware */
14332176cfdSRui Paulo #if 0
14432176cfdSRui Paulo #define	M_AMPDU_MPDU	M_PROTO8		/* A-MPDU re-order done */
14532176cfdSRui Paulo #endif
14632176cfdSRui Paulo #define	M_80211_RX	(M_AMPDU|M_WEP|M_AMPDU_MPDU)
14732176cfdSRui Paulo 
14832176cfdSRui Paulo #define	IEEE80211_MBUF_TX_FLAG_BITS \
14932176cfdSRui Paulo 	"\20\1M_EXT\2M_PKTHDR\3M_EOR\4M_RDONLY\5M_ENCAP\6M_WEP\7M_EAPOL" \
15032176cfdSRui Paulo 	"\10M_PWR_SAV\11M_MORE_DATA\12M_BCAST\13M_MCAST\14M_FRAG\15M_FIRSTFRAG" \
15132176cfdSRui Paulo 	"\16M_LASTFRAG\17M_SKIP_FIREWALL\20M_FREELIST\21M_VLANTAG\22M_PROMISC" \
15232176cfdSRui Paulo 	"\23M_NOFREE\24M_FF\25M_TXCB\26M_AMPDU_MPDU\27M_FLOWID"
15332176cfdSRui Paulo 
15432176cfdSRui Paulo #define	IEEE80211_MBUF_RX_FLAG_BITS \
15532176cfdSRui Paulo 	"\20\1M_EXT\2M_PKTHDR\3M_EOR\4M_RDONLY\5M_AMPDU\6M_WEP\7M_PROTO3" \
15632176cfdSRui Paulo 	"\10M_PROTO4\11M_PROTO5\12M_BCAST\13M_MCAST\14M_FRAG\15M_FIRSTFRAG" \
15732176cfdSRui Paulo 	"\16M_LASTFRAG\17M_SKIP_FIREWALL\20M_FREELIST\21M_VLANTAG\22M_PROMISC" \
15832176cfdSRui Paulo 	"\23M_NOFREE\24M_PROTO6\25M_PROTO7\26M_AMPDU_MPDU\27M_FLOWID"
15932176cfdSRui Paulo 
160841ab66cSSepherosa Ziehau /*
16132176cfdSRui Paulo  * Store WME access control bits in the vlan tag.
16232176cfdSRui Paulo  * This is safe since it's done after the packet is classified
16332176cfdSRui Paulo  * (where we use any previous tag) and because it's passed
16432176cfdSRui Paulo  * directly in to the driver and there's no chance someone
16532176cfdSRui Paulo  * else will clobber them on us.
166841ab66cSSepherosa Ziehau  */
167841ab66cSSepherosa Ziehau #define	M_WME_SETAC(m, ac) \
16832176cfdSRui Paulo 	((m)->m_pkthdr.ether_vlantag = (ac))
16932176cfdSRui Paulo #define	M_WME_GETAC(m)	((m)->m_pkthdr.ether_vlantag)
170841ab66cSSepherosa Ziehau 
171841ab66cSSepherosa Ziehau /*
172841ab66cSSepherosa Ziehau  * Mbufs on the power save queue are tagged with an age and
173841ab66cSSepherosa Ziehau  * timed out.  We reuse the hardware checksum field in the
174841ab66cSSepherosa Ziehau  * mbuf packet header to store this data.
175841ab66cSSepherosa Ziehau  */
176841ab66cSSepherosa Ziehau #define	M_AGE_SET(m,v)		(m->m_pkthdr.csum_data = v)
177841ab66cSSepherosa Ziehau #define	M_AGE_GET(m)		(m->m_pkthdr.csum_data)
178841ab66cSSepherosa Ziehau #define	M_AGE_SUB(m,adj)	(m->m_pkthdr.csum_data -= adj)
179841ab66cSSepherosa Ziehau 
18032176cfdSRui Paulo /*
18132176cfdSRui Paulo  * Store the sequence number.
18232176cfdSRui Paulo  */
18332176cfdSRui Paulo #define	M_SEQNO_SET(m, seqno) \
18434a60cf6SRui Paulo 	((m)->m_pkthdr.wlan_seqno = (seqno))
18534a60cf6SRui Paulo #define	M_SEQNO_GET(m)	((m)->m_pkthdr.wlan_seqno)
18632176cfdSRui Paulo 
18732176cfdSRui Paulo #define	MTAG_ABI_NET80211	1132948340	/* net80211 ABI */
18832176cfdSRui Paulo 
18932176cfdSRui Paulo struct ieee80211_cb {
19032176cfdSRui Paulo 	void	(*func)(struct ieee80211_node *, void *, int status);
19132176cfdSRui Paulo 	void	*arg;
19232176cfdSRui Paulo };
19332176cfdSRui Paulo #define	NET80211_TAG_CALLBACK	0	/* xmit complete callback */
19432176cfdSRui Paulo int	ieee80211_add_callback(struct mbuf *m,
19532176cfdSRui Paulo 		void (*func)(struct ieee80211_node *, void *, int), void *arg);
19632176cfdSRui Paulo void	ieee80211_process_callback(struct ieee80211_node *, struct mbuf *, int);
19732176cfdSRui Paulo 
198841ab66cSSepherosa Ziehau void	get_random_bytes(void *, size_t);
199841ab66cSSepherosa Ziehau 
200841ab66cSSepherosa Ziehau struct ieee80211com;
201841ab66cSSepherosa Ziehau 
202841ab66cSSepherosa Ziehau void	ieee80211_sysctl_attach(struct ieee80211com *);
203841ab66cSSepherosa Ziehau void	ieee80211_sysctl_detach(struct ieee80211com *);
20432176cfdSRui Paulo void	ieee80211_sysctl_vattach(struct ieee80211vap *);
20532176cfdSRui Paulo void	ieee80211_sysctl_vdetach(struct ieee80211vap *);
20632176cfdSRui Paulo 
20732176cfdSRui Paulo SYSCTL_DECL(_net_wlan);
20832176cfdSRui Paulo int	ieee80211_sysctl_msecs_ticks(SYSCTL_HANDLER_ARGS);
209841ab66cSSepherosa Ziehau 
210841ab66cSSepherosa Ziehau void	ieee80211_load_module(const char *);
21132176cfdSRui Paulo 
21232176cfdSRui Paulo /*
21332176cfdSRui Paulo  * A "policy module" is an adjunct module to net80211 that provides
21432176cfdSRui Paulo  * functionality that typically includes policy decisions.  This
21532176cfdSRui Paulo  * modularity enables extensibility and vendor-supplied functionality.
21632176cfdSRui Paulo  */
21732176cfdSRui Paulo #define	_IEEE80211_POLICY_MODULE(policy, name, version)			\
21832176cfdSRui Paulo typedef void (*policy##_setup)(int);					\
21932176cfdSRui Paulo SET_DECLARE(policy##_set, policy##_setup);				\
22032176cfdSRui Paulo static int								\
22132176cfdSRui Paulo wlan_##name##_modevent(module_t mod, int type, void *unused)		\
22232176cfdSRui Paulo {									\
22332176cfdSRui Paulo 	policy##_setup * const *iter, f;				\
22432176cfdSRui Paulo 	switch (type) {							\
22532176cfdSRui Paulo 	case MOD_LOAD:							\
22632176cfdSRui Paulo 		SET_FOREACH(iter, policy##_set) {			\
22732176cfdSRui Paulo 			f = (void*) *iter;				\
22832176cfdSRui Paulo 			f(type);					\
22932176cfdSRui Paulo 		}							\
23032176cfdSRui Paulo 		return 0;						\
23132176cfdSRui Paulo 	case MOD_UNLOAD:						\
23232176cfdSRui Paulo 		if (nrefs) {						\
23332176cfdSRui Paulo 			kprintf("wlan_##name: still in use (%u dynamic refs)\n",\
23432176cfdSRui Paulo 				nrefs);					\
23532176cfdSRui Paulo 			return EBUSY;					\
23632176cfdSRui Paulo 		}							\
23732176cfdSRui Paulo 		if (type == MOD_UNLOAD) {				\
23832176cfdSRui Paulo 			SET_FOREACH(iter, policy##_set) {		\
23932176cfdSRui Paulo 				f = (void*) *iter;			\
24032176cfdSRui Paulo 				f(type);				\
24132176cfdSRui Paulo 			}						\
24232176cfdSRui Paulo 		}							\
24332176cfdSRui Paulo 		return 0;						\
24432176cfdSRui Paulo 	}								\
24532176cfdSRui Paulo 	return EINVAL;							\
24632176cfdSRui Paulo }									\
24732176cfdSRui Paulo static moduledata_t name##_mod = {					\
24832176cfdSRui Paulo 	"wlan_" #name,							\
24932176cfdSRui Paulo 	wlan_##name##_modevent,						\
25032176cfdSRui Paulo 	0								\
25132176cfdSRui Paulo };									\
25232176cfdSRui Paulo DECLARE_MODULE(wlan_##name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST);\
25332176cfdSRui Paulo MODULE_VERSION(wlan_##name, version);					\
25432176cfdSRui Paulo MODULE_DEPEND(wlan_##name, wlan, 1, 1, 1)
25532176cfdSRui Paulo 
25632176cfdSRui Paulo /*
25732176cfdSRui Paulo  * Crypto modules implement cipher support.
25832176cfdSRui Paulo  */
25932176cfdSRui Paulo #define	IEEE80211_CRYPTO_MODULE(name, version)				\
26032176cfdSRui Paulo _IEEE80211_POLICY_MODULE(crypto, name, version);			\
26132176cfdSRui Paulo static void								\
26232176cfdSRui Paulo name##_modevent(int type)						\
26332176cfdSRui Paulo {									\
26432176cfdSRui Paulo 	if (type == MOD_LOAD)						\
26532176cfdSRui Paulo 		ieee80211_crypto_register(&name);			\
26632176cfdSRui Paulo 	else								\
26732176cfdSRui Paulo 		ieee80211_crypto_unregister(&name);			\
26832176cfdSRui Paulo }									\
26932176cfdSRui Paulo TEXT_SET(crypto##_set, name##_modevent)
27032176cfdSRui Paulo 
27132176cfdSRui Paulo /*
27232176cfdSRui Paulo  * Scanner modules provide scanning policy.
27332176cfdSRui Paulo  */
27432176cfdSRui Paulo #define	IEEE80211_SCANNER_MODULE(name, version)				\
27532176cfdSRui Paulo 	_IEEE80211_POLICY_MODULE(scanner, name, version)
27632176cfdSRui Paulo 
27732176cfdSRui Paulo #define	IEEE80211_SCANNER_ALG(name, alg, v)				\
27832176cfdSRui Paulo static void								\
27932176cfdSRui Paulo name##_modevent(int type)						\
28032176cfdSRui Paulo {									\
28132176cfdSRui Paulo 	if (type == MOD_LOAD)						\
28232176cfdSRui Paulo 		ieee80211_scanner_register(alg, &v);			\
28332176cfdSRui Paulo 	else								\
28432176cfdSRui Paulo 		ieee80211_scanner_unregister(alg, &v);			\
28532176cfdSRui Paulo }									\
28632176cfdSRui Paulo TEXT_SET(scanner_set, name##_modevent);					\
28732176cfdSRui Paulo 
28832176cfdSRui Paulo /*
28932176cfdSRui Paulo  * ACL modules implement acl policy.
29032176cfdSRui Paulo  */
29132176cfdSRui Paulo #define	IEEE80211_ACL_MODULE(name, alg, version)			\
29232176cfdSRui Paulo _IEEE80211_POLICY_MODULE(acl, name, version);				\
29332176cfdSRui Paulo static void								\
29432176cfdSRui Paulo alg##_modevent(int type)						\
29532176cfdSRui Paulo {									\
29632176cfdSRui Paulo 	if (type == MOD_LOAD)						\
29732176cfdSRui Paulo 		ieee80211_aclator_register(&alg);			\
29832176cfdSRui Paulo 	else								\
29932176cfdSRui Paulo 		ieee80211_aclator_unregister(&alg);			\
30032176cfdSRui Paulo }									\
30132176cfdSRui Paulo TEXT_SET(acl_set, alg##_modevent);					\
30232176cfdSRui Paulo 
30332176cfdSRui Paulo /*
30432176cfdSRui Paulo  * Authenticator modules handle 802.1x/WPA authentication.
30532176cfdSRui Paulo  */
30632176cfdSRui Paulo #define	IEEE80211_AUTH_MODULE(name, version)				\
30732176cfdSRui Paulo 	_IEEE80211_POLICY_MODULE(auth, name, version)
30832176cfdSRui Paulo 
30932176cfdSRui Paulo #define	IEEE80211_AUTH_ALG(name, alg, v)				\
31032176cfdSRui Paulo static void								\
31132176cfdSRui Paulo name##_modevent(int type)						\
31232176cfdSRui Paulo {									\
31332176cfdSRui Paulo 	if (type == MOD_LOAD)						\
31432176cfdSRui Paulo 		ieee80211_authenticator_register(alg, &v);		\
31532176cfdSRui Paulo 	else								\
31632176cfdSRui Paulo 		ieee80211_authenticator_unregister(alg);		\
31732176cfdSRui Paulo }									\
31832176cfdSRui Paulo TEXT_SET(auth_set, name##_modevent)
31932176cfdSRui Paulo 
32032176cfdSRui Paulo /*
32132176cfdSRui Paulo  * Rate control modules provide tx rate control support.
32232176cfdSRui Paulo  */
3234028af95SRui Paulo #define	IEEE80211_RATECTL_MODULE(alg, version)				\
3244028af95SRui Paulo 	_IEEE80211_POLICY_MODULE(ratectl, alg, version);		\
3254028af95SRui Paulo 
3264028af95SRui Paulo #define	IEEE80211_RATECTL_ALG(name, alg, v)				\
32732176cfdSRui Paulo static void								\
32832176cfdSRui Paulo alg##_modevent(int type)						\
32932176cfdSRui Paulo {									\
3304028af95SRui Paulo 	if (type == MOD_LOAD)						\
3314028af95SRui Paulo 		ieee80211_ratectl_register(alg, &v);			\
3324028af95SRui Paulo 	else								\
3334028af95SRui Paulo 		ieee80211_ratectl_unregister(alg);			\
33432176cfdSRui Paulo }									\
3354028af95SRui Paulo TEXT_SET(ratectl##_set, alg##_modevent)
33632176cfdSRui Paulo 
33732176cfdSRui Paulo struct ieee80211req;
33832176cfdSRui Paulo typedef int ieee80211_ioctl_getfunc(struct ieee80211vap *,
33932176cfdSRui Paulo     struct ieee80211req *);
34032176cfdSRui Paulo SET_DECLARE(ieee80211_ioctl_getset, ieee80211_ioctl_getfunc);
34132176cfdSRui Paulo #define	IEEE80211_IOCTL_GET(_name, _get) TEXT_SET(ieee80211_ioctl_getset, _get)
34232176cfdSRui Paulo 
34332176cfdSRui Paulo typedef int ieee80211_ioctl_setfunc(struct ieee80211vap *,
34432176cfdSRui Paulo     struct ieee80211req *);
34532176cfdSRui Paulo SET_DECLARE(ieee80211_ioctl_setset, ieee80211_ioctl_setfunc);
34632176cfdSRui Paulo #define	IEEE80211_IOCTL_SET(_name, _set) TEXT_SET(ieee80211_ioctl_setset, _set)
34732176cfdSRui Paulo #endif /* _KERNEL */
348841ab66cSSepherosa Ziehau 
349841ab66cSSepherosa Ziehau /* XXX this stuff belongs elsewhere */
350841ab66cSSepherosa Ziehau /*
351841ab66cSSepherosa Ziehau  * Message formats for messages from the net80211 layer to user
352841ab66cSSepherosa Ziehau  * applications via the routing socket.  These messages are appended
353841ab66cSSepherosa Ziehau  * to an if_announcemsghdr structure.
354841ab66cSSepherosa Ziehau  */
355841ab66cSSepherosa Ziehau struct ieee80211_join_event {
356841ab66cSSepherosa Ziehau 	uint8_t		iev_addr[6];
357841ab66cSSepherosa Ziehau };
358841ab66cSSepherosa Ziehau 
359841ab66cSSepherosa Ziehau struct ieee80211_leave_event {
360841ab66cSSepherosa Ziehau 	uint8_t		iev_addr[6];
361841ab66cSSepherosa Ziehau };
362841ab66cSSepherosa Ziehau 
363841ab66cSSepherosa Ziehau struct ieee80211_replay_event {
364841ab66cSSepherosa Ziehau 	uint8_t		iev_src[6];	/* src MAC */
365841ab66cSSepherosa Ziehau 	uint8_t		iev_dst[6];	/* dst MAC */
366841ab66cSSepherosa Ziehau 	uint8_t		iev_cipher;	/* cipher type */
367841ab66cSSepherosa Ziehau 	uint8_t		iev_keyix;	/* key id/index */
368841ab66cSSepherosa Ziehau 	uint64_t	iev_keyrsc;	/* RSC from key */
369841ab66cSSepherosa Ziehau 	uint64_t	iev_rsc;	/* RSC from frame */
370841ab66cSSepherosa Ziehau };
371841ab66cSSepherosa Ziehau 
372841ab66cSSepherosa Ziehau struct ieee80211_michael_event {
373841ab66cSSepherosa Ziehau 	uint8_t		iev_src[6];	/* src MAC */
374841ab66cSSepherosa Ziehau 	uint8_t		iev_dst[6];	/* dst MAC */
375841ab66cSSepherosa Ziehau 	uint8_t		iev_cipher;	/* cipher type */
376841ab66cSSepherosa Ziehau 	uint8_t		iev_keyix;	/* key id/index */
377841ab66cSSepherosa Ziehau };
378841ab66cSSepherosa Ziehau 
37932176cfdSRui Paulo struct ieee80211_wds_event {
38032176cfdSRui Paulo 	uint8_t		iev_addr[6];
38132176cfdSRui Paulo };
38232176cfdSRui Paulo 
38332176cfdSRui Paulo struct ieee80211_csa_event {
38432176cfdSRui Paulo 	uint32_t	iev_flags;	/* channel flags */
38532176cfdSRui Paulo 	uint16_t	iev_freq;	/* setting in Mhz */
38632176cfdSRui Paulo 	uint8_t		iev_ieee;	/* IEEE channel number */
38732176cfdSRui Paulo 	uint8_t		iev_mode;	/* CSA mode */
38832176cfdSRui Paulo 	uint8_t		iev_count;	/* CSA count */
38932176cfdSRui Paulo };
39032176cfdSRui Paulo 
39132176cfdSRui Paulo struct ieee80211_cac_event {
39232176cfdSRui Paulo 	uint32_t	iev_flags;	/* channel flags */
39332176cfdSRui Paulo 	uint16_t	iev_freq;	/* setting in Mhz */
39432176cfdSRui Paulo 	uint8_t		iev_ieee;	/* IEEE channel number */
39532176cfdSRui Paulo 	/* XXX timestamp? */
39632176cfdSRui Paulo 	uint8_t		iev_type;	/* IEEE80211_NOTIFY_CAC_* */
39732176cfdSRui Paulo };
39832176cfdSRui Paulo 
39932176cfdSRui Paulo struct ieee80211_radar_event {
40032176cfdSRui Paulo 	uint32_t	iev_flags;	/* channel flags */
40132176cfdSRui Paulo 	uint16_t	iev_freq;	/* setting in Mhz */
40232176cfdSRui Paulo 	uint8_t		iev_ieee;	/* IEEE channel number */
40332176cfdSRui Paulo 	/* XXX timestamp? */
40432176cfdSRui Paulo };
40532176cfdSRui Paulo 
40632176cfdSRui Paulo struct ieee80211_auth_event {
40732176cfdSRui Paulo 	uint8_t		iev_addr[6];
40832176cfdSRui Paulo };
40932176cfdSRui Paulo 
41032176cfdSRui Paulo struct ieee80211_deauth_event {
41132176cfdSRui Paulo 	uint8_t		iev_addr[6];
41232176cfdSRui Paulo };
41332176cfdSRui Paulo 
41432176cfdSRui Paulo struct ieee80211_country_event {
41532176cfdSRui Paulo 	uint8_t		iev_addr[6];
41632176cfdSRui Paulo 	uint8_t		iev_cc[2];	/* ISO country code */
41732176cfdSRui Paulo };
41832176cfdSRui Paulo 
41932176cfdSRui Paulo struct ieee80211_radio_event {
42032176cfdSRui Paulo 	uint8_t		iev_state;	/* 1 on, 0 off */
42132176cfdSRui Paulo };
42232176cfdSRui Paulo 
423841ab66cSSepherosa Ziehau #define	RTM_IEEE80211_ASSOC	100	/* station associate (bss mode) */
424841ab66cSSepherosa Ziehau #define	RTM_IEEE80211_REASSOC	101	/* station re-associate (bss mode) */
425841ab66cSSepherosa Ziehau #define	RTM_IEEE80211_DISASSOC	102	/* station disassociate (bss mode) */
426841ab66cSSepherosa Ziehau #define	RTM_IEEE80211_JOIN	103	/* station join (ap mode) */
427841ab66cSSepherosa Ziehau #define	RTM_IEEE80211_LEAVE	104	/* station leave (ap mode) */
428841ab66cSSepherosa Ziehau #define	RTM_IEEE80211_SCAN	105	/* scan complete, results available */
429841ab66cSSepherosa Ziehau #define	RTM_IEEE80211_REPLAY	106	/* sequence counter replay detected */
430841ab66cSSepherosa Ziehau #define	RTM_IEEE80211_MICHAEL	107	/* Michael MIC failure detected */
431841ab66cSSepherosa Ziehau #define	RTM_IEEE80211_REJOIN	108	/* station re-associate (ap mode) */
43232176cfdSRui Paulo #define	RTM_IEEE80211_WDS	109	/* WDS discovery (ap mode) */
43332176cfdSRui Paulo #define	RTM_IEEE80211_CSA	110	/* Channel Switch Announcement event */
43432176cfdSRui Paulo #define	RTM_IEEE80211_RADAR	111	/* radar event */
43532176cfdSRui Paulo #define	RTM_IEEE80211_CAC	112	/* Channel Availability Check event */
43632176cfdSRui Paulo #define	RTM_IEEE80211_DEAUTH	113	/* station deauthenticate */
43732176cfdSRui Paulo #define	RTM_IEEE80211_AUTH	114	/* station authenticate (ap mode) */
43832176cfdSRui Paulo #define	RTM_IEEE80211_COUNTRY	115	/* discovered country code (sta mode) */
43932176cfdSRui Paulo #define	RTM_IEEE80211_RADIO	116	/* RF kill switch state change */
440841ab66cSSepherosa Ziehau 
44132176cfdSRui Paulo /*
44232176cfdSRui Paulo  * Structure prepended to raw packets sent through the bpf
44332176cfdSRui Paulo  * interface when set to DLT_IEEE802_11_RADIO.  This allows
44432176cfdSRui Paulo  * user applications to specify pretty much everything in
44532176cfdSRui Paulo  * an Atheros tx descriptor.  XXX need to generalize.
44632176cfdSRui Paulo  *
44732176cfdSRui Paulo  * XXX cannot be more than 14 bytes as it is copied to a sockaddr's
44832176cfdSRui Paulo  * XXX sa_data area.
44932176cfdSRui Paulo  */
45032176cfdSRui Paulo struct ieee80211_bpf_params {
45132176cfdSRui Paulo 	uint8_t		ibp_vers;	/* version */
45232176cfdSRui Paulo #define	IEEE80211_BPF_VERSION	0
45332176cfdSRui Paulo 	uint8_t		ibp_len;	/* header length in bytes */
45432176cfdSRui Paulo 	uint8_t		ibp_flags;
45532176cfdSRui Paulo #define	IEEE80211_BPF_SHORTPRE	0x01	/* tx with short preamble */
45632176cfdSRui Paulo #define	IEEE80211_BPF_NOACK	0x02	/* tx with no ack */
45732176cfdSRui Paulo #define	IEEE80211_BPF_CRYPTO	0x04	/* tx with h/w encryption */
45832176cfdSRui Paulo #define	IEEE80211_BPF_FCS	0x10	/* frame incldues FCS */
45932176cfdSRui Paulo #define	IEEE80211_BPF_DATAPAD	0x20	/* frame includes data padding */
46032176cfdSRui Paulo #define	IEEE80211_BPF_RTS	0x40	/* tx with RTS/CTS */
46132176cfdSRui Paulo #define	IEEE80211_BPF_CTS	0x80	/* tx with CTS only */
46232176cfdSRui Paulo 	uint8_t		ibp_pri;	/* WME/WMM AC+tx antenna */
46332176cfdSRui Paulo 	uint8_t		ibp_try0;	/* series 1 try count */
46432176cfdSRui Paulo 	uint8_t		ibp_rate0;	/* series 1 IEEE tx rate */
46532176cfdSRui Paulo 	uint8_t		ibp_power;	/* tx power (device units) */
46632176cfdSRui Paulo 	uint8_t		ibp_ctsrate;	/* IEEE tx rate for CTS */
46732176cfdSRui Paulo 	uint8_t		ibp_try1;	/* series 2 try count */
46832176cfdSRui Paulo 	uint8_t		ibp_rate1;	/* series 2 IEEE tx rate */
46932176cfdSRui Paulo 	uint8_t		ibp_try2;	/* series 3 try count */
47032176cfdSRui Paulo 	uint8_t		ibp_rate2;	/* series 3 IEEE tx rate */
47132176cfdSRui Paulo 	uint8_t		ibp_try3;	/* series 4 try count */
47232176cfdSRui Paulo 	uint8_t		ibp_rate3;	/* series 4 IEEE tx rate */
47332176cfdSRui Paulo };
474841ab66cSSepherosa Ziehau #endif /* _NET80211_IEEE80211_DRAGONFLY_H_ */
475