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>
37085ff963SMatthew Dillon #include <sys/lock.h>
3832176cfdSRui Paulo #include <sys/taskqueue.h>
3932176cfdSRui Paulo
4026c6f223SMatthew Dillon #include <sys/mutex2.h>
4126c6f223SMatthew Dillon #include <sys/serialize2.h>
4232176cfdSRui Paulo
4332176cfdSRui Paulo #ifndef IF_PREPEND_LIST
4426c6f223SMatthew Dillon
454cc8caefSSepherosa Ziehau /* XXX all are prepended to normal queue */
4668dc1916SSepherosa Ziehau #define _IF_PREPEND_LIST(ifq, mhead, mtail, mcount, bcnt) do { \
474cc8caefSSepherosa Ziehau (mtail)->m_nextpkt = (ifq)->ifsq_norm_head; \
484cc8caefSSepherosa Ziehau if ((ifq)->ifsq_norm_tail == NULL) \
494cc8caefSSepherosa Ziehau (ifq)->ifsq_norm_tail = (mtail); \
504cc8caefSSepherosa Ziehau (ifq)->ifsq_norm_head = (mhead); \
51b21c2105SSepherosa Ziehau (ifq)->ifsq_len += (mcount); \
5268dc1916SSepherosa Ziehau (ifq)->ifsq_bcnt += (bcnt); \
53841ab66cSSepherosa Ziehau } while (0)
5426c6f223SMatthew Dillon
5568dc1916SSepherosa Ziehau #define IF_PREPEND_LIST(ifq, mhead, mtail, mcount, bcnt) do { \
5626c6f223SMatthew Dillon wlan_assert_serialized(); \
5768dc1916SSepherosa Ziehau _IF_PREPEND_LIST(ifq, mhead, mtail, mcount, bcnt); \
58841ab66cSSepherosa Ziehau } while (0)
5926c6f223SMatthew Dillon
6032176cfdSRui Paulo #endif /* IF_PREPEND_LIST */
6132176cfdSRui Paulo
6232176cfdSRui Paulo /*
6326c6f223SMatthew Dillon * Global serializer (operates like a non-reentrant lockmgr lock)
6432176cfdSRui Paulo */
6526c6f223SMatthew Dillon extern struct lwkt_serialize wlan_global_serializer;
661b196a0cSMatthew Dillon extern int ieee80211_force_swcrypto;
6726c6f223SMatthew Dillon
687fd4e1a1SSascha Wildner #define wlan_serialize_enter() _wlan_serialize_enter(__func__)
697fd4e1a1SSascha Wildner #define wlan_serialize_exit() _wlan_serialize_exit(__func__)
70085ff963SMatthew Dillon #define wlan_serialize_push() _wlan_serialize_push(__func__)
71085ff963SMatthew Dillon #define wlan_serialize_pop(wst) _wlan_serialize_pop(__func__, wst)
72085ff963SMatthew Dillon #define wlan_is_serialized() _wlan_is_serialized()
7351237956SMatthew Dillon void _wlan_serialize_enter(const char *funcname);
7451237956SMatthew Dillon void _wlan_serialize_exit(const char *funcname);
75085ff963SMatthew Dillon int _wlan_serialize_push(const char *funcname);
76085ff963SMatthew Dillon void _wlan_serialize_pop(const char *funcname, int wst);
77085ff963SMatthew Dillon int _wlan_is_serialized(void);
7826c6f223SMatthew Dillon int wlan_serialize_sleep(void *ident, int flags, const char *wmesg, int timo);
7926c6f223SMatthew Dillon
8026c6f223SMatthew Dillon static __inline void
wlan_assert_serialized(void)8126c6f223SMatthew Dillon wlan_assert_serialized(void)
8226c6f223SMatthew Dillon {
8326c6f223SMatthew Dillon ASSERT_SERIALIZED(&wlan_global_serializer);
8426c6f223SMatthew Dillon }
8532176cfdSRui Paulo
86a583ece6SSepherosa Ziehau static __inline void
wlan_assert_notserialized(void)87a583ece6SSepherosa Ziehau wlan_assert_notserialized(void)
88a583ece6SSepherosa Ziehau {
89a583ece6SSepherosa Ziehau ASSERT_NOT_SERIALIZED(&wlan_global_serializer);
90a583ece6SSepherosa Ziehau }
91a583ece6SSepherosa Ziehau
9232176cfdSRui Paulo /*
93841ab66cSSepherosa Ziehau * Node reference counting definitions.
94841ab66cSSepherosa Ziehau *
95841ab66cSSepherosa Ziehau * ieee80211_node_initref initialize the reference count to 1
96841ab66cSSepherosa Ziehau * ieee80211_node_incref add a reference
97841ab66cSSepherosa Ziehau * ieee80211_node_decref remove a reference
98841ab66cSSepherosa Ziehau * ieee80211_node_dectestref remove a reference and return 1 if this
99841ab66cSSepherosa Ziehau * is the last reference, otherwise 0
100841ab66cSSepherosa Ziehau * ieee80211_node_refcnt reference count for printing (only)
101841ab66cSSepherosa Ziehau */
102841ab66cSSepherosa Ziehau #include <machine/atomic.h>
103841ab66cSSepherosa Ziehau
104841ab66cSSepherosa Ziehau #define ieee80211_node_initref(_ni) \
105841ab66cSSepherosa Ziehau do { ((_ni)->ni_refcnt = 1); } while (0)
106841ab66cSSepherosa Ziehau #define ieee80211_node_incref(_ni) \
107841ab66cSSepherosa Ziehau atomic_add_int(&(_ni)->ni_refcnt, 1)
108841ab66cSSepherosa Ziehau #define ieee80211_node_decref(_ni) \
109841ab66cSSepherosa Ziehau atomic_subtract_int(&(_ni)->ni_refcnt, 1)
110841ab66cSSepherosa Ziehau struct ieee80211_node;
111841ab66cSSepherosa Ziehau int ieee80211_node_dectestref(struct ieee80211_node *ni);
112841ab66cSSepherosa Ziehau #define ieee80211_node_refcnt(_ni) (_ni)->ni_refcnt
113841ab66cSSepherosa Ziehau
11432176cfdSRui Paulo struct ifqueue;
11532176cfdSRui Paulo struct ieee80211vap;
116085ff963SMatthew Dillon struct ieee80211com;
117c332e0e8SSepherosa Ziehau void ieee80211_flush_ifq(struct ifaltq *, struct ieee80211vap *);
1184b582d92SSepherosa Ziehau
11932176cfdSRui Paulo void ieee80211_vap_destroy(struct ieee80211vap *);
120085ff963SMatthew Dillon int ieee80211_vap_xmitpkt(struct ieee80211vap *vap, struct mbuf *m);
121085ff963SMatthew Dillon int ieee80211_parent_xmitpkt(struct ieee80211com *ic, struct mbuf *m);
1223088f8e9SRui Paulo int ieee80211_handoff(struct ifnet *, struct mbuf *);
123a13825b3SRui Paulo uint16_t ieee80211_txtime(struct ieee80211_node *, u_int, uint8_t, uint32_t);
12432176cfdSRui Paulo
12532176cfdSRui Paulo #define IFNET_IS_UP_RUNNING(_ifp) \
12632176cfdSRui Paulo (((_ifp)->if_flags & IFF_UP) && \
12734a60cf6SRui Paulo ((_ifp)->if_flags & IFF_RUNNING))
12832176cfdSRui Paulo
1294f655ef5SMatthew Dillon /* XXX TODO: cap these at 1, as hz may not be 1000 */
13032176cfdSRui Paulo #define msecs_to_ticks(ms) (((ms)*hz)/1000)
13132176cfdSRui Paulo #define ticks_to_msecs(t) (1000*(t) / hz)
13232176cfdSRui Paulo #define ticks_to_secs(t) ((t) / hz)
1334f655ef5SMatthew Dillon
1344f655ef5SMatthew Dillon #define ieee80211_time_after(a,b) ((long)(b) - (long)(a) < 0)
1354f655ef5SMatthew Dillon #define ieee80211_time_before(a,b) ieee80211_time_after(b,a)
1364f655ef5SMatthew Dillon #define ieee80211_time_after_eq(a,b) ((long)(a) - (long)(b) >= 0)
1374f655ef5SMatthew Dillon #define ieee80211_time_before_eq(a,b) ieee80211_time_after_eq(b,a)
13832176cfdSRui Paulo
13932176cfdSRui Paulo struct mbuf *ieee80211_getmgtframe(uint8_t **frm, int headroom, int pktlen);
14032176cfdSRui Paulo
14132176cfdSRui Paulo /* tx path usage */
14232176cfdSRui Paulo #define M_ENCAP M_PROTO1 /* 802.11 encap done */
14332176cfdSRui Paulo #define M_EAPOL M_PROTO3 /* PAE/EAPOL frame */
144841ab66cSSepherosa Ziehau #define M_PWR_SAV M_PROTO4 /* bypass PS handling */
145841ab66cSSepherosa Ziehau #define M_MORE_DATA M_PROTO5 /* more data frames to follow */
1464f655ef5SMatthew Dillon #define M_FF M_PROTO6 /* fast frame / A-MSDU */
14732176cfdSRui Paulo #define M_TXCB M_PROTO7 /* do tx complete callback */
14832176cfdSRui Paulo #define M_AMPDU_MPDU M_PROTO8 /* ok for A-MPDU aggregation */
14932176cfdSRui Paulo #define M_80211_TX \
15032176cfdSRui Paulo (M_FRAG|M_FIRSTFRAG|M_LASTFRAG|M_ENCAP|M_EAPOL|M_PWR_SAV|\
15132176cfdSRui Paulo M_MORE_DATA|M_FF|M_TXCB|M_AMPDU_MPDU)
15232176cfdSRui Paulo
15332176cfdSRui Paulo /* rx path usage */
15432176cfdSRui Paulo #define M_AMPDU M_PROTO1 /* A-MPDU subframe */
15532176cfdSRui Paulo #define M_WEP M_PROTO2 /* WEP done by hardware */
15632176cfdSRui Paulo #if 0
15732176cfdSRui Paulo #define M_AMPDU_MPDU M_PROTO8 /* A-MPDU re-order done */
15832176cfdSRui Paulo #endif
15932176cfdSRui Paulo #define M_80211_RX (M_AMPDU|M_WEP|M_AMPDU_MPDU)
16032176cfdSRui Paulo
16132176cfdSRui Paulo #define IEEE80211_MBUF_TX_FLAG_BITS \
16232176cfdSRui Paulo "\20\1M_EXT\2M_PKTHDR\3M_EOR\4M_RDONLY\5M_ENCAP\6M_WEP\7M_EAPOL" \
16332176cfdSRui Paulo "\10M_PWR_SAV\11M_MORE_DATA\12M_BCAST\13M_MCAST\14M_FRAG\15M_FIRSTFRAG" \
16432176cfdSRui Paulo "\16M_LASTFRAG\17M_SKIP_FIREWALL\20M_FREELIST\21M_VLANTAG\22M_PROMISC" \
16532176cfdSRui Paulo "\23M_NOFREE\24M_FF\25M_TXCB\26M_AMPDU_MPDU\27M_FLOWID"
16632176cfdSRui Paulo
16732176cfdSRui Paulo #define IEEE80211_MBUF_RX_FLAG_BITS \
16832176cfdSRui Paulo "\20\1M_EXT\2M_PKTHDR\3M_EOR\4M_RDONLY\5M_AMPDU\6M_WEP\7M_PROTO3" \
16932176cfdSRui Paulo "\10M_PROTO4\11M_PROTO5\12M_BCAST\13M_MCAST\14M_FRAG\15M_FIRSTFRAG" \
17032176cfdSRui Paulo "\16M_LASTFRAG\17M_SKIP_FIREWALL\20M_FREELIST\21M_VLANTAG\22M_PROMISC" \
17132176cfdSRui Paulo "\23M_NOFREE\24M_PROTO6\25M_PROTO7\26M_AMPDU_MPDU\27M_FLOWID"
17232176cfdSRui Paulo
173841ab66cSSepherosa Ziehau /*
17432176cfdSRui Paulo * Store WME access control bits in the vlan tag.
17532176cfdSRui Paulo * This is safe since it's done after the packet is classified
17632176cfdSRui Paulo * (where we use any previous tag) and because it's passed
17732176cfdSRui Paulo * directly in to the driver and there's no chance someone
17832176cfdSRui Paulo * else will clobber them on us.
179841ab66cSSepherosa Ziehau */
180841ab66cSSepherosa Ziehau #define M_WME_SETAC(m, ac) \
18132176cfdSRui Paulo ((m)->m_pkthdr.ether_vlantag = (ac))
18232176cfdSRui Paulo #define M_WME_GETAC(m) ((m)->m_pkthdr.ether_vlantag)
183841ab66cSSepherosa Ziehau
184841ab66cSSepherosa Ziehau /*
185841ab66cSSepherosa Ziehau * Mbufs on the power save queue are tagged with an age and
186841ab66cSSepherosa Ziehau * timed out. We reuse the hardware checksum field in the
187841ab66cSSepherosa Ziehau * mbuf packet header to store this data.
188841ab66cSSepherosa Ziehau */
189841ab66cSSepherosa Ziehau #define M_AGE_SET(m,v) (m->m_pkthdr.csum_data = v)
190841ab66cSSepherosa Ziehau #define M_AGE_GET(m) (m->m_pkthdr.csum_data)
191841ab66cSSepherosa Ziehau #define M_AGE_SUB(m,adj) (m->m_pkthdr.csum_data -= adj)
192841ab66cSSepherosa Ziehau
19332176cfdSRui Paulo /*
19432176cfdSRui Paulo * Store the sequence number.
19532176cfdSRui Paulo */
19632176cfdSRui Paulo #define M_SEQNO_SET(m, seqno) \
19701d73edbSSepherosa Ziehau ((m)->m_pkthdr.wlan_seqno = (seqno))
19801d73edbSSepherosa Ziehau #define M_SEQNO_GET(m) ((m)->m_pkthdr.wlan_seqno)
19932176cfdSRui Paulo
20032176cfdSRui Paulo #define MTAG_ABI_NET80211 1132948340 /* net80211 ABI */
20132176cfdSRui Paulo
20232176cfdSRui Paulo struct ieee80211_cb {
20332176cfdSRui Paulo void (*func)(struct ieee80211_node *, void *, int status);
20432176cfdSRui Paulo void *arg;
20532176cfdSRui Paulo };
20632176cfdSRui Paulo #define NET80211_TAG_CALLBACK 0 /* xmit complete callback */
20732176cfdSRui Paulo int ieee80211_add_callback(struct mbuf *m,
20832176cfdSRui Paulo void (*func)(struct ieee80211_node *, void *, int), void *arg);
20932176cfdSRui Paulo void ieee80211_process_callback(struct ieee80211_node *, struct mbuf *, int);
21032176cfdSRui Paulo
2114f898719SImre Vadász #define NET80211_TAG_XMIT_PARAMS 1
2124f898719SImre Vadász /* See below; this is after the bpf_params definition */
2134f898719SImre Vadász
214841ab66cSSepherosa Ziehau void get_random_bytes(void *, size_t);
215841ab66cSSepherosa Ziehau
2164f655ef5SMatthew Dillon #define NET80211_TAG_RECV_PARAMS 2
2174f655ef5SMatthew Dillon
218841ab66cSSepherosa Ziehau void ieee80211_sysctl_attach(struct ieee80211com *);
219841ab66cSSepherosa Ziehau void ieee80211_sysctl_detach(struct ieee80211com *);
22032176cfdSRui Paulo void ieee80211_sysctl_vattach(struct ieee80211vap *);
22132176cfdSRui Paulo void ieee80211_sysctl_vdetach(struct ieee80211vap *);
22232176cfdSRui Paulo
22332176cfdSRui Paulo SYSCTL_DECL(_net_wlan);
22432176cfdSRui Paulo int ieee80211_sysctl_msecs_ticks(SYSCTL_HANDLER_ARGS);
225841ab66cSSepherosa Ziehau
226841ab66cSSepherosa Ziehau void ieee80211_load_module(const char *);
22732176cfdSRui Paulo
22832176cfdSRui Paulo /*
22932176cfdSRui Paulo * A "policy module" is an adjunct module to net80211 that provides
23032176cfdSRui Paulo * functionality that typically includes policy decisions. This
23132176cfdSRui Paulo * modularity enables extensibility and vendor-supplied functionality.
23232176cfdSRui Paulo */
23332176cfdSRui Paulo #define _IEEE80211_POLICY_MODULE(policy, name, version) \
23432176cfdSRui Paulo typedef void (*policy##_setup)(int); \
23532176cfdSRui Paulo SET_DECLARE(policy##_set, policy##_setup); \
23632176cfdSRui Paulo static int \
23732176cfdSRui Paulo wlan_##name##_modevent(module_t mod, int type, void *unused) \
23832176cfdSRui Paulo { \
23932176cfdSRui Paulo policy##_setup * const *iter, f; \
24047156d48SMatthew Dillon int error; \
24147156d48SMatthew Dillon \
24232176cfdSRui Paulo switch (type) { \
24332176cfdSRui Paulo case MOD_LOAD: \
24432176cfdSRui Paulo SET_FOREACH(iter, policy##_set) { \
24532176cfdSRui Paulo f = (void*) *iter; \
24632176cfdSRui Paulo f(type); \
24732176cfdSRui Paulo } \
24847156d48SMatthew Dillon error = 0; \
24947156d48SMatthew Dillon break; \
25032176cfdSRui Paulo case MOD_UNLOAD: \
25151237956SMatthew Dillon error = 0; \
25232176cfdSRui Paulo if (nrefs) { \
2534f898719SImre Vadász kprintf("wlan_" #name ": still in use (%u " \
25447156d48SMatthew Dillon "dynamic refs)\n", \
25532176cfdSRui Paulo nrefs); \
25651237956SMatthew Dillon error = EBUSY; \
25751237956SMatthew Dillon } else if (type == MOD_UNLOAD) { \
25832176cfdSRui Paulo SET_FOREACH(iter, policy##_set) { \
25932176cfdSRui Paulo f = (void*) *iter; \
26032176cfdSRui Paulo f(type); \
26132176cfdSRui Paulo } \
26232176cfdSRui Paulo } \
26347156d48SMatthew Dillon break; \
26447156d48SMatthew Dillon default: \
26547156d48SMatthew Dillon error = EINVAL; \
26647156d48SMatthew Dillon break; \
26732176cfdSRui Paulo } \
26847156d48SMatthew Dillon \
26947156d48SMatthew Dillon return error; \
27032176cfdSRui Paulo } \
27132176cfdSRui Paulo static moduledata_t name##_mod = { \
27232176cfdSRui Paulo "wlan_" #name, \
27332176cfdSRui Paulo wlan_##name##_modevent, \
27432176cfdSRui Paulo 0 \
27532176cfdSRui Paulo }; \
27632176cfdSRui Paulo DECLARE_MODULE(wlan_##name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST);\
27732176cfdSRui Paulo MODULE_VERSION(wlan_##name, version); \
27832176cfdSRui Paulo MODULE_DEPEND(wlan_##name, wlan, 1, 1, 1)
27932176cfdSRui Paulo
28032176cfdSRui Paulo /*
28132176cfdSRui Paulo * Crypto modules implement cipher support.
28232176cfdSRui Paulo */
28332176cfdSRui Paulo #define IEEE80211_CRYPTO_MODULE(name, version) \
28432176cfdSRui Paulo _IEEE80211_POLICY_MODULE(crypto, name, version); \
28532176cfdSRui Paulo static void \
28632176cfdSRui Paulo name##_modevent(int type) \
28732176cfdSRui Paulo { \
28851237956SMatthew Dillon /* wlan already serialized! */ \
28932176cfdSRui Paulo if (type == MOD_LOAD) \
29032176cfdSRui Paulo ieee80211_crypto_register(&name); \
29132176cfdSRui Paulo else \
29232176cfdSRui Paulo ieee80211_crypto_unregister(&name); \
29332176cfdSRui Paulo } \
29432176cfdSRui Paulo TEXT_SET(crypto##_set, name##_modevent)
29532176cfdSRui Paulo
29632176cfdSRui Paulo /*
29732176cfdSRui Paulo * Scanner modules provide scanning policy.
29832176cfdSRui Paulo */
29932176cfdSRui Paulo #define IEEE80211_SCANNER_MODULE(name, version) \
30032176cfdSRui Paulo _IEEE80211_POLICY_MODULE(scanner, name, version)
30132176cfdSRui Paulo
30232176cfdSRui Paulo #define IEEE80211_SCANNER_ALG(name, alg, v) \
30332176cfdSRui Paulo static void \
30432176cfdSRui Paulo name##_modevent(int type) \
30532176cfdSRui Paulo { \
30651237956SMatthew Dillon /* wlan already serialized! */ \
30732176cfdSRui Paulo if (type == MOD_LOAD) \
30832176cfdSRui Paulo ieee80211_scanner_register(alg, &v); \
30932176cfdSRui Paulo else \
31032176cfdSRui Paulo ieee80211_scanner_unregister(alg, &v); \
31132176cfdSRui Paulo } \
31232176cfdSRui Paulo TEXT_SET(scanner_set, name##_modevent); \
31332176cfdSRui Paulo
31432176cfdSRui Paulo /*
31532176cfdSRui Paulo * ACL modules implement acl policy.
31632176cfdSRui Paulo */
31732176cfdSRui Paulo #define IEEE80211_ACL_MODULE(name, alg, version) \
31832176cfdSRui Paulo _IEEE80211_POLICY_MODULE(acl, name, version); \
31932176cfdSRui Paulo static void \
32032176cfdSRui Paulo alg##_modevent(int type) \
32132176cfdSRui Paulo { \
32251237956SMatthew Dillon /* wlan already serialized! */ \
32332176cfdSRui Paulo if (type == MOD_LOAD) \
32432176cfdSRui Paulo ieee80211_aclator_register(&alg); \
32532176cfdSRui Paulo else \
32632176cfdSRui Paulo ieee80211_aclator_unregister(&alg); \
32732176cfdSRui Paulo } \
32832176cfdSRui Paulo TEXT_SET(acl_set, alg##_modevent); \
32932176cfdSRui Paulo
33032176cfdSRui Paulo /*
33132176cfdSRui Paulo * Authenticator modules handle 802.1x/WPA authentication.
33232176cfdSRui Paulo */
33332176cfdSRui Paulo #define IEEE80211_AUTH_MODULE(name, version) \
33432176cfdSRui Paulo _IEEE80211_POLICY_MODULE(auth, name, version)
33532176cfdSRui Paulo
33632176cfdSRui Paulo #define IEEE80211_AUTH_ALG(name, alg, v) \
33732176cfdSRui Paulo static void \
33832176cfdSRui Paulo name##_modevent(int type) \
33932176cfdSRui Paulo { \
34051237956SMatthew Dillon /* wlan already serialized! */ \
34132176cfdSRui Paulo if (type == MOD_LOAD) \
34232176cfdSRui Paulo ieee80211_authenticator_register(alg, &v); \
34332176cfdSRui Paulo else \
34432176cfdSRui Paulo ieee80211_authenticator_unregister(alg); \
34532176cfdSRui Paulo } \
34632176cfdSRui Paulo TEXT_SET(auth_set, name##_modevent)
34732176cfdSRui Paulo
34832176cfdSRui Paulo /*
34932176cfdSRui Paulo * Rate control modules provide tx rate control support.
35032176cfdSRui Paulo */
3514028af95SRui Paulo #define IEEE80211_RATECTL_MODULE(alg, version) \
3524028af95SRui Paulo _IEEE80211_POLICY_MODULE(ratectl, alg, version); \
3534028af95SRui Paulo
3544028af95SRui Paulo #define IEEE80211_RATECTL_ALG(name, alg, v) \
35532176cfdSRui Paulo static void \
35632176cfdSRui Paulo alg##_modevent(int type) \
35732176cfdSRui Paulo { \
35851237956SMatthew Dillon /* wlan already serialized! */ \
3594028af95SRui Paulo if (type == MOD_LOAD) \
3604028af95SRui Paulo ieee80211_ratectl_register(alg, &v); \
3614028af95SRui Paulo else \
3624028af95SRui Paulo ieee80211_ratectl_unregister(alg); \
36332176cfdSRui Paulo } \
3644028af95SRui Paulo TEXT_SET(ratectl##_set, alg##_modevent)
36532176cfdSRui Paulo
36632176cfdSRui Paulo struct ieee80211req;
36732176cfdSRui Paulo typedef int ieee80211_ioctl_getfunc(struct ieee80211vap *,
36832176cfdSRui Paulo struct ieee80211req *);
36932176cfdSRui Paulo SET_DECLARE(ieee80211_ioctl_getset, ieee80211_ioctl_getfunc);
37032176cfdSRui Paulo #define IEEE80211_IOCTL_GET(_name, _get) TEXT_SET(ieee80211_ioctl_getset, _get)
37132176cfdSRui Paulo
37232176cfdSRui Paulo typedef int ieee80211_ioctl_setfunc(struct ieee80211vap *,
37332176cfdSRui Paulo struct ieee80211req *);
37432176cfdSRui Paulo SET_DECLARE(ieee80211_ioctl_setset, ieee80211_ioctl_setfunc);
37532176cfdSRui Paulo #define IEEE80211_IOCTL_SET(_name, _set) TEXT_SET(ieee80211_ioctl_setset, _set)
37632176cfdSRui Paulo #endif /* _KERNEL */
377841ab66cSSepherosa Ziehau
378841ab66cSSepherosa Ziehau /* XXX this stuff belongs elsewhere */
379841ab66cSSepherosa Ziehau /*
380841ab66cSSepherosa Ziehau * Message formats for messages from the net80211 layer to user
381841ab66cSSepherosa Ziehau * applications via the routing socket. These messages are appended
382841ab66cSSepherosa Ziehau * to an if_announcemsghdr structure.
383841ab66cSSepherosa Ziehau */
384841ab66cSSepherosa Ziehau struct ieee80211_join_event {
385841ab66cSSepherosa Ziehau uint8_t iev_addr[6];
386841ab66cSSepherosa Ziehau };
387841ab66cSSepherosa Ziehau
388841ab66cSSepherosa Ziehau struct ieee80211_leave_event {
389841ab66cSSepherosa Ziehau uint8_t iev_addr[6];
390841ab66cSSepherosa Ziehau };
391841ab66cSSepherosa Ziehau
392841ab66cSSepherosa Ziehau struct ieee80211_replay_event {
393841ab66cSSepherosa Ziehau uint8_t iev_src[6]; /* src MAC */
394841ab66cSSepherosa Ziehau uint8_t iev_dst[6]; /* dst MAC */
395841ab66cSSepherosa Ziehau uint8_t iev_cipher; /* cipher type */
396841ab66cSSepherosa Ziehau uint8_t iev_keyix; /* key id/index */
397841ab66cSSepherosa Ziehau uint64_t iev_keyrsc; /* RSC from key */
398841ab66cSSepherosa Ziehau uint64_t iev_rsc; /* RSC from frame */
399841ab66cSSepherosa Ziehau };
400841ab66cSSepherosa Ziehau
401841ab66cSSepherosa Ziehau struct ieee80211_michael_event {
402841ab66cSSepherosa Ziehau uint8_t iev_src[6]; /* src MAC */
403841ab66cSSepherosa Ziehau uint8_t iev_dst[6]; /* dst MAC */
404841ab66cSSepherosa Ziehau uint8_t iev_cipher; /* cipher type */
405841ab66cSSepherosa Ziehau uint8_t iev_keyix; /* key id/index */
406841ab66cSSepherosa Ziehau };
407841ab66cSSepherosa Ziehau
40832176cfdSRui Paulo struct ieee80211_wds_event {
40932176cfdSRui Paulo uint8_t iev_addr[6];
41032176cfdSRui Paulo };
41132176cfdSRui Paulo
41232176cfdSRui Paulo struct ieee80211_csa_event {
41332176cfdSRui Paulo uint32_t iev_flags; /* channel flags */
41432176cfdSRui Paulo uint16_t iev_freq; /* setting in Mhz */
41532176cfdSRui Paulo uint8_t iev_ieee; /* IEEE channel number */
41632176cfdSRui Paulo uint8_t iev_mode; /* CSA mode */
41732176cfdSRui Paulo uint8_t iev_count; /* CSA count */
41832176cfdSRui Paulo };
41932176cfdSRui Paulo
42032176cfdSRui Paulo struct ieee80211_cac_event {
42132176cfdSRui Paulo uint32_t iev_flags; /* channel flags */
42232176cfdSRui Paulo uint16_t iev_freq; /* setting in Mhz */
42332176cfdSRui Paulo uint8_t iev_ieee; /* IEEE channel number */
42432176cfdSRui Paulo /* XXX timestamp? */
42532176cfdSRui Paulo uint8_t iev_type; /* IEEE80211_NOTIFY_CAC_* */
42632176cfdSRui Paulo };
42732176cfdSRui Paulo
42832176cfdSRui Paulo struct ieee80211_radar_event {
42932176cfdSRui Paulo uint32_t iev_flags; /* channel flags */
43032176cfdSRui Paulo uint16_t iev_freq; /* setting in Mhz */
43132176cfdSRui Paulo uint8_t iev_ieee; /* IEEE channel number */
43232176cfdSRui Paulo /* XXX timestamp? */
43332176cfdSRui Paulo };
43432176cfdSRui Paulo
43532176cfdSRui Paulo struct ieee80211_auth_event {
43632176cfdSRui Paulo uint8_t iev_addr[6];
43732176cfdSRui Paulo };
43832176cfdSRui Paulo
43932176cfdSRui Paulo struct ieee80211_deauth_event {
44032176cfdSRui Paulo uint8_t iev_addr[6];
44132176cfdSRui Paulo };
44232176cfdSRui Paulo
44332176cfdSRui Paulo struct ieee80211_country_event {
44432176cfdSRui Paulo uint8_t iev_addr[6];
44532176cfdSRui Paulo uint8_t iev_cc[2]; /* ISO country code */
44632176cfdSRui Paulo };
44732176cfdSRui Paulo
44832176cfdSRui Paulo struct ieee80211_radio_event {
44932176cfdSRui Paulo uint8_t iev_state; /* 1 on, 0 off */
45032176cfdSRui Paulo };
45132176cfdSRui Paulo
452841ab66cSSepherosa Ziehau #define RTM_IEEE80211_ASSOC 100 /* station associate (bss mode) */
453841ab66cSSepherosa Ziehau #define RTM_IEEE80211_REASSOC 101 /* station re-associate (bss mode) */
454841ab66cSSepherosa Ziehau #define RTM_IEEE80211_DISASSOC 102 /* station disassociate (bss mode) */
455841ab66cSSepherosa Ziehau #define RTM_IEEE80211_JOIN 103 /* station join (ap mode) */
456841ab66cSSepherosa Ziehau #define RTM_IEEE80211_LEAVE 104 /* station leave (ap mode) */
457841ab66cSSepherosa Ziehau #define RTM_IEEE80211_SCAN 105 /* scan complete, results available */
458841ab66cSSepherosa Ziehau #define RTM_IEEE80211_REPLAY 106 /* sequence counter replay detected */
459841ab66cSSepherosa Ziehau #define RTM_IEEE80211_MICHAEL 107 /* Michael MIC failure detected */
460841ab66cSSepherosa Ziehau #define RTM_IEEE80211_REJOIN 108 /* station re-associate (ap mode) */
46132176cfdSRui Paulo #define RTM_IEEE80211_WDS 109 /* WDS discovery (ap mode) */
46232176cfdSRui Paulo #define RTM_IEEE80211_CSA 110 /* Channel Switch Announcement event */
46332176cfdSRui Paulo #define RTM_IEEE80211_RADAR 111 /* radar event */
46432176cfdSRui Paulo #define RTM_IEEE80211_CAC 112 /* Channel Availability Check event */
46532176cfdSRui Paulo #define RTM_IEEE80211_DEAUTH 113 /* station deauthenticate */
46632176cfdSRui Paulo #define RTM_IEEE80211_AUTH 114 /* station authenticate (ap mode) */
46732176cfdSRui Paulo #define RTM_IEEE80211_COUNTRY 115 /* discovered country code (sta mode) */
46832176cfdSRui Paulo #define RTM_IEEE80211_RADIO 116 /* RF kill switch state change */
469841ab66cSSepherosa Ziehau
47032176cfdSRui Paulo /*
47132176cfdSRui Paulo * Structure prepended to raw packets sent through the bpf
47232176cfdSRui Paulo * interface when set to DLT_IEEE802_11_RADIO. This allows
47332176cfdSRui Paulo * user applications to specify pretty much everything in
47432176cfdSRui Paulo * an Atheros tx descriptor. XXX need to generalize.
47532176cfdSRui Paulo *
47632176cfdSRui Paulo * XXX cannot be more than 14 bytes as it is copied to a sockaddr's
47732176cfdSRui Paulo * XXX sa_data area.
47832176cfdSRui Paulo */
47932176cfdSRui Paulo struct ieee80211_bpf_params {
48032176cfdSRui Paulo uint8_t ibp_vers; /* version */
48132176cfdSRui Paulo #define IEEE80211_BPF_VERSION 0
48232176cfdSRui Paulo uint8_t ibp_len; /* header length in bytes */
48332176cfdSRui Paulo uint8_t ibp_flags;
48432176cfdSRui Paulo #define IEEE80211_BPF_SHORTPRE 0x01 /* tx with short preamble */
48532176cfdSRui Paulo #define IEEE80211_BPF_NOACK 0x02 /* tx with no ack */
48632176cfdSRui Paulo #define IEEE80211_BPF_CRYPTO 0x04 /* tx with h/w encryption */
48732176cfdSRui Paulo #define IEEE80211_BPF_FCS 0x10 /* frame incldues FCS */
48832176cfdSRui Paulo #define IEEE80211_BPF_DATAPAD 0x20 /* frame includes data padding */
48932176cfdSRui Paulo #define IEEE80211_BPF_RTS 0x40 /* tx with RTS/CTS */
49032176cfdSRui Paulo #define IEEE80211_BPF_CTS 0x80 /* tx with CTS only */
49132176cfdSRui Paulo uint8_t ibp_pri; /* WME/WMM AC+tx antenna */
49232176cfdSRui Paulo uint8_t ibp_try0; /* series 1 try count */
49332176cfdSRui Paulo uint8_t ibp_rate0; /* series 1 IEEE tx rate */
49432176cfdSRui Paulo uint8_t ibp_power; /* tx power (device units) */
49532176cfdSRui Paulo uint8_t ibp_ctsrate; /* IEEE tx rate for CTS */
49632176cfdSRui Paulo uint8_t ibp_try1; /* series 2 try count */
49732176cfdSRui Paulo uint8_t ibp_rate1; /* series 2 IEEE tx rate */
49832176cfdSRui Paulo uint8_t ibp_try2; /* series 3 try count */
49932176cfdSRui Paulo uint8_t ibp_rate2; /* series 3 IEEE tx rate */
50032176cfdSRui Paulo uint8_t ibp_try3; /* series 4 try count */
50132176cfdSRui Paulo uint8_t ibp_rate3; /* series 4 IEEE tx rate */
50232176cfdSRui Paulo };
503085ff963SMatthew Dillon
5044f898719SImre Vadász #ifdef _KERNEL
5054f898719SImre Vadász struct ieee80211_tx_params {
5064f898719SImre Vadász struct ieee80211_bpf_params params;
5074f898719SImre Vadász };
5084f898719SImre Vadász int ieee80211_add_xmit_params(struct mbuf *m,
5094f898719SImre Vadász const struct ieee80211_bpf_params *);
5104f898719SImre Vadász int ieee80211_get_xmit_params(struct mbuf *m,
5114f898719SImre Vadász struct ieee80211_bpf_params *);
5124f655ef5SMatthew Dillon
5134f655ef5SMatthew Dillon #define IEEE80211_MAX_CHAINS 3
5144f655ef5SMatthew Dillon #define IEEE80211_MAX_EVM_PILOTS 6
5154f655ef5SMatthew Dillon
5164f655ef5SMatthew Dillon #define IEEE80211_R_NF 0x0000001 /* global NF value valid */
5174f655ef5SMatthew Dillon #define IEEE80211_R_RSSI 0x0000002 /* global RSSI value valid */
5184f655ef5SMatthew Dillon #define IEEE80211_R_C_CHAIN 0x0000004 /* RX chain count valid */
5194f655ef5SMatthew Dillon #define IEEE80211_R_C_NF 0x0000008 /* per-chain NF value valid */
5204f655ef5SMatthew Dillon #define IEEE80211_R_C_RSSI 0x0000010 /* per-chain RSSI value valid */
5214f655ef5SMatthew Dillon #define IEEE80211_R_C_EVM 0x0000020 /* per-chain EVM valid */
5224f655ef5SMatthew Dillon #define IEEE80211_R_C_HT40 0x0000040 /* RX'ed packet is 40mhz, pilots 4,5 valid */
5234f655ef5SMatthew Dillon #define IEEE80211_R_FREQ 0x0000080 /* Freq value populated, MHz */
5244f655ef5SMatthew Dillon #define IEEE80211_R_IEEE 0x0000100 /* IEEE value populated */
5254f655ef5SMatthew Dillon #define IEEE80211_R_BAND 0x0000200 /* Frequency band populated */
5264f655ef5SMatthew Dillon
5274f655ef5SMatthew Dillon struct ieee80211_rx_stats {
5284f655ef5SMatthew Dillon uint32_t r_flags; /* IEEE80211_R_* flags */
5294f655ef5SMatthew Dillon uint8_t c_chain; /* number of RX chains involved */
5304f655ef5SMatthew Dillon int16_t c_nf_ctl[IEEE80211_MAX_CHAINS]; /* per-chain NF */
5314f655ef5SMatthew Dillon int16_t c_nf_ext[IEEE80211_MAX_CHAINS]; /* per-chain NF */
5324f655ef5SMatthew Dillon int16_t c_rssi_ctl[IEEE80211_MAX_CHAINS]; /* per-chain RSSI */
5334f655ef5SMatthew Dillon int16_t c_rssi_ext[IEEE80211_MAX_CHAINS]; /* per-chain RSSI */
534*796562b1SMichael Neumann uint8_t c_nf; /* global NF */
535*796562b1SMichael Neumann uint8_t c_rssi; /* global RSSI */
5364f655ef5SMatthew Dillon uint8_t evm[IEEE80211_MAX_CHAINS][IEEE80211_MAX_EVM_PILOTS];
5374f655ef5SMatthew Dillon /* per-chain, per-pilot EVM values */
5384f655ef5SMatthew Dillon uint16_t c_freq;
5394f655ef5SMatthew Dillon uint8_t c_ieee;
5404f655ef5SMatthew Dillon };
5414f655ef5SMatthew Dillon
5424f655ef5SMatthew Dillon struct ieee80211_rx_params {
5434f655ef5SMatthew Dillon struct ieee80211_rx_stats params;
5444f655ef5SMatthew Dillon };
5454f655ef5SMatthew Dillon int ieee80211_add_rx_params(struct mbuf *m,
5464f655ef5SMatthew Dillon const struct ieee80211_rx_stats *rxs);
5474f655ef5SMatthew Dillon int ieee80211_get_rx_params(struct mbuf *m,
5484f655ef5SMatthew Dillon struct ieee80211_rx_stats *rxs);
5494f898719SImre Vadász #endif /* _KERNEL */
5504f898719SImre Vadász
551085ff963SMatthew Dillon /*
552085ff963SMatthew Dillon * FreeBSD overrides
553085ff963SMatthew Dillon */
554085ff963SMatthew Dillon const char *ether_sprintf(const u_char *buf);
555085ff963SMatthew Dillon
556085ff963SMatthew Dillon #define V_ifnet ifnet
557085ff963SMatthew Dillon #define IFF_DRV_RUNNING IFF_RUNNING
558085ff963SMatthew Dillon #define if_drv_flags if_flags
559085ff963SMatthew Dillon
560085ff963SMatthew Dillon typedef struct lock ieee80211_psq_lock_t;
561085ff963SMatthew Dillon typedef struct lock ieee80211_ageq_lock_t;
562085ff963SMatthew Dillon typedef struct lock ieee80211_node_lock_t;
563085ff963SMatthew Dillon typedef struct lock ieee80211_scan_lock_t;
564085ff963SMatthew Dillon typedef struct lock ieee80211_com_lock_t;
565085ff963SMatthew Dillon typedef struct lock ieee80211_tx_lock_t;
566085ff963SMatthew Dillon typedef struct lock ieee80211_scan_table_lock_t;
567bc42d9bcSImre Vadász typedef struct lock ieee80211_scan_iter_lock_t;
568085ff963SMatthew Dillon typedef struct lock acl_lock_t;
569c3bc1bd4SImre Vadász typedef struct lock ieee80211_rte_lock_t;
570c3bc1bd4SImre Vadász typedef struct lock ieee80211_rt_lock_t;
571085ff963SMatthew Dillon
572085ff963SMatthew Dillon #define IEEE80211_LOCK_OBJ(ic) (&(ic)->ic_comlock)
573085ff963SMatthew Dillon
574085ff963SMatthew Dillon #define IEEE80211_LOCK_INIT(ic, name) lockinit(&(ic)->ic_comlock, name, 0, LK_CANRECURSE)
575085ff963SMatthew Dillon #define IEEE80211_NODE_LOCK_INIT(ic, name) lockinit(&(nt)->nt_nodelock, name, 0, LK_CANRECURSE)
576085ff963SMatthew Dillon #define IEEE80211_NODE_ITERATE_LOCK_INIT(ic, name) lockinit(&(nt)->nt_scanlock, name, 0, LK_CANRECURSE)
577085ff963SMatthew Dillon #define IEEE80211_SCAN_TABLE_LOCK_INIT(st, name) lockinit(&(st)->st_lock, name, 0, LK_CANRECURSE)
578bc42d9bcSImre Vadász #define IEEE80211_SCAN_ITER_LOCK_INIT(st, name) lockinit(&(st)->st_scanlock, name, 0, LK_CANRECURSE)
579085ff963SMatthew Dillon #define IEEE80211_TX_LOCK_INIT(ic, name) lockinit(&(ic)->ic_txlock, name, 0, LK_CANRECURSE)
580085ff963SMatthew Dillon #define IEEE80211_AGEQ_LOCK_INIT(aq, name) lockinit(&(aq)->aq_lock, name, 0, LK_CANRECURSE)
581085ff963SMatthew Dillon #define IEEE80211_PSQ_INIT(psq, name) lockinit(&(psq)->psq_lock, name, 0, LK_CANRECURSE)
582085ff963SMatthew Dillon #define ACL_LOCK_INIT(as, name) lockinit(&(as)->as_lock, name, 0, LK_CANRECURSE)
583c3bc1bd4SImre Vadász #define MESH_RT_ENTRY_LOCK_INIT(st, name) lockinit(&(st)->rt_lock, name, 0, LK_CANRECURSE)
584c3bc1bd4SImre Vadász #define MESH_RT_LOCK_INIT(ms, name) lockinit(&(ms)->ms_rt_lock, name, 0, LK_CANRECURSE)
585085ff963SMatthew Dillon
586085ff963SMatthew Dillon #define IEEE80211_LOCK_DESTROY(ic) lockuninit(&(ic)->ic_comlock)
587085ff963SMatthew Dillon #define IEEE80211_NODE_LOCK_DESTROY(nt) lockuninit(&(nt)->nt_nodelock)
588085ff963SMatthew Dillon #define IEEE80211_NODE_ITERATE_LOCK_DESTROY(nt) lockuninit(&(nt)->nt_scanlock)
589085ff963SMatthew Dillon #define IEEE80211_SCAN_TABLE_LOCK_DESTROY(st) lockuninit(&(st)->st_lock)
590bc42d9bcSImre Vadász #define IEEE80211_SCAN_ITER_LOCK_DESTROY(st) lockuninit(&(st)->st_scanlock)
591085ff963SMatthew Dillon #define IEEE80211_TX_LOCK_DESTROY(ic) lockuninit(&(ic)->ic_txlock)
592085ff963SMatthew Dillon #define IEEE80211_AGEQ_LOCK_DESTROY(aq) lockuninit(&(aq)->aq_lock)
593085ff963SMatthew Dillon #define IEEE80211_PSQ_DESTROY(psq) lockuninit(&(psq)->psq_lock)
594085ff963SMatthew Dillon #define ACL_LOCK_DESTROY(as) lockuninit(&(as)->as_lock)
595c3bc1bd4SImre Vadász #define MESH_RT_ENTRY_LOCK_DESTROY(rt) lockuninit(&(rt)->rt_lock)
596c3bc1bd4SImre Vadász #define MESH_RT_LOCK_DESTROY(ms) lockuninit(&(ms)->ms_rt_lock)
597085ff963SMatthew Dillon
598085ff963SMatthew Dillon #define IEEE80211_LOCK(ic) lockmgr(&(ic)->ic_comlock, LK_EXCLUSIVE)
599085ff963SMatthew Dillon #define IEEE80211_NODE_LOCK(nt) lockmgr(&(nt)->nt_nodelock, LK_EXCLUSIVE)
600085ff963SMatthew Dillon #define IEEE80211_NODE_ITERATE_LOCK(nt) lockmgr(&(nt)->nt_scanlock, LK_EXCLUSIVE)
601085ff963SMatthew Dillon #define IEEE80211_SCAN_TABLE_LOCK(st) lockmgr(&(st)->st_lock, LK_EXCLUSIVE)
602bc42d9bcSImre Vadász #define IEEE80211_SCAN_ITER_LOCK(st) lockmgr(&(st)->st_scanlock, LK_EXCLUSIVE)
603085ff963SMatthew Dillon #define IEEE80211_TX_LOCK(ic) lockmgr(&(ic)->ic_txlock, LK_EXCLUSIVE)
604085ff963SMatthew Dillon #define IEEE80211_AGEQ_LOCK(aq) lockmgr(&(aq)->aq_lock, LK_EXCLUSIVE)
605085ff963SMatthew Dillon #define IEEE80211_PSQ_LOCK(psq) lockmgr(&(psq)->psq_lock, LK_EXCLUSIVE)
606085ff963SMatthew Dillon #define ACL_LOCK(as) lockmgr(&(as)->as_lock, LK_EXCLUSIVE)
607c3bc1bd4SImre Vadász #define MESH_RT_ENTRY_LOCK(rt) lockmgr(&(rt)->rt_lock, LK_EXCLUSIVE)
608c3bc1bd4SImre Vadász #define MESH_RT_LOCK(ms) lockmgr(&(ms)->ms_rt_lock, LK_EXCLUSIVE)
609085ff963SMatthew Dillon
610085ff963SMatthew Dillon #define IEEE80211_UNLOCK(ic) lockmgr(&(ic)->ic_comlock, LK_RELEASE)
611085ff963SMatthew Dillon #define IEEE80211_NODE_UNLOCK(nt) lockmgr(&(nt)->nt_nodelock, LK_RELEASE)
612085ff963SMatthew Dillon #define IEEE80211_NODE_ITERATE_UNLOCK(nt) lockmgr(&(nt)->nt_scanlock, LK_RELEASE)
613085ff963SMatthew Dillon #define IEEE80211_SCAN_TABLE_UNLOCK(nt) lockmgr(&(st)->st_lock, LK_RELEASE)
614bc42d9bcSImre Vadász #define IEEE80211_SCAN_ITER_UNLOCK(nt) lockmgr(&(st)->st_scanlock, LK_RELEASE)
615085ff963SMatthew Dillon #define IEEE80211_TX_UNLOCK(ic) lockmgr(&(ic)->ic_txlock, LK_RELEASE)
616085ff963SMatthew Dillon #define IEEE80211_AGEQ_UNLOCK(aq) lockmgr(&(aq)->aq_lock, LK_RELEASE)
617085ff963SMatthew Dillon #define IEEE80211_PSQ_UNLOCK(psq) lockmgr(&(psq)->psq_lock, LK_RELEASE)
618085ff963SMatthew Dillon #define ACL_UNLOCK(as) lockmgr(&(as)->as_lock, LK_RELEASE)
619c3bc1bd4SImre Vadász #define MESH_RT_ENTRY_UNLOCK(rt) lockmgr(&(rt)->rt_lock, LK_RELEASE)
620c3bc1bd4SImre Vadász #define MESH_RT_UNLOCK(ms) lockmgr(&(ms)->ms_rt_lock, LK_RELEASE)
621085ff963SMatthew Dillon
622085ff963SMatthew Dillon #define IEEE80211_LOCK_ASSERT(ic) \
623085ff963SMatthew Dillon KKASSERT(lockstatus(&(ic)->ic_comlock, curthread) == LK_EXCLUSIVE)
6244f655ef5SMatthew Dillon #define IEEE80211_UNLOCK_ASSERT(ic) \
6254f655ef5SMatthew Dillon KKASSERT(lockstatus(&(ic)->ic_comlock, curthread) != LK_EXCLUSIVE)
626085ff963SMatthew Dillon #define IEEE80211_NODE_LOCK_ASSERT(nt) \
627085ff963SMatthew Dillon KKASSERT(lockstatus(&(nt)->nt_nodelock, curthread) == LK_EXCLUSIVE)
628085ff963SMatthew Dillon #define IEEE80211_NODE_ITERATE_LOCK_ASSERT(nt) \
629085ff963SMatthew Dillon KKASSERT(lockstatus(&(nt)->nt_scanlock, curthread) == LK_EXCLUSIVE)
630085ff963SMatthew Dillon #define IEEE80211_TX_LOCK_ASSERT(ic) \
631085ff963SMatthew Dillon KKASSERT(lockstatus(&(ic)->ic_txlock, curthread) == LK_EXCLUSIVE)
632085ff963SMatthew Dillon #define IEEE80211_TX_UNLOCK_ASSERT(ic) \
633085ff963SMatthew Dillon KKASSERT(lockstatus(&(ic)->ic_txlock, curthread) != LK_EXCLUSIVE)
634085ff963SMatthew Dillon #define IEEE80211_AGEQ_LOCK_ASSERT(aq) \
635085ff963SMatthew Dillon KKASSERT(lockstatus(&(aq)->aq_lock, curthread) == LK_EXCLUSIVE)
636085ff963SMatthew Dillon #define ACL_LOCK_ASSERT(as) \
637085ff963SMatthew Dillon KKASSERT(lockstatus(&(as)->as_lock, curthread) == LK_EXCLUSIVE)
638c3bc1bd4SImre Vadász #define MESH_RT_ENTRY_LOCK_ASSERT(rt) \
639c3bc1bd4SImre Vadász KKASSERT(lockstatus(&(rt)->rt_lock, curthread) == LK_EXCLUSIVE)
640c3bc1bd4SImre Vadász #define MESH_RT_LOCK_ASSERT(ms) \
641c3bc1bd4SImre Vadász KKASSERT(lockstatus(&(ms)->ms_rt_lock, curthread) == LK_EXCLUSIVE)
642085ff963SMatthew Dillon
643085ff963SMatthew Dillon #define IEEE80211_NODE_IS_LOCKED(nt) \
644085ff963SMatthew Dillon (lockstatus(&(nt)->nt_nodelock, curthread) == LK_EXCLUSIVE)
645085ff963SMatthew Dillon
646085ff963SMatthew Dillon #define arc4random karc4random
647085ff963SMatthew Dillon
648085ff963SMatthew Dillon #define IEEE80211_AGEQ_INIT(aq, name)
649085ff963SMatthew Dillon #define IEEE80211_AGEQ_DESTROY(aq)
650085ff963SMatthew Dillon #define CURVNET_SET(x)
651085ff963SMatthew Dillon #define CURVNET_RESTORE()
652085ff963SMatthew Dillon #define ifa_free(ifa)
653085ff963SMatthew Dillon
654085ff963SMatthew Dillon #define ALIGNED_POINTER(p, t) (((uintptr_t)(p) & (sizeof(t) - 1)) == 0)
655085ff963SMatthew Dillon
656085ff963SMatthew Dillon #define osdep_va_list __va_list
657085ff963SMatthew Dillon #define osdep_va_start __va_start
658085ff963SMatthew Dillon #define osdep_va_end __va_end
659085ff963SMatthew Dillon
660085ff963SMatthew Dillon /*
661085ff963SMatthew Dillon * DragonFly does not implement _SAFE macros because they are generally not
662085ff963SMatthew Dillon * actually safe in a MP environment, and so it is bad programming practice
663085ff963SMatthew Dillon * to use them.
664085ff963SMatthew Dillon */
665085ff963SMatthew Dillon #define TAILQ_FOREACH_SAFE(scan, list, next, save) \
666085ff963SMatthew Dillon for (scan = TAILQ_FIRST(list); (save = scan ? TAILQ_NEXT(scan, next) : NULL), scan; scan = save) \
667085ff963SMatthew Dillon
668085ff963SMatthew Dillon #define callout_init_mtx(callo, lk, flags) \
669085ff963SMatthew Dillon callout_init_lk(callo, lk)
670085ff963SMatthew Dillon #define callout_schedule_dfly(callo, timo, func, args) \
671085ff963SMatthew Dillon callout_reset(callo, timo, func, args)
672085ff963SMatthew Dillon
6734f655ef5SMatthew Dillon /*
6744f655ef5SMatthew Dillon * if_inc macros
6754f655ef5SMatthew Dillon */
6764f655ef5SMatthew Dillon #define ifd_IFCOUNTER_IERRORS ifd_ierrors
6774f655ef5SMatthew Dillon #define ifd_IFCOUNTER_IPACKETS ifd_ipackets
6784f655ef5SMatthew Dillon #define ifd_IFCOUNTER_IBYTES ifd_ibytes
6794f655ef5SMatthew Dillon #define ifd_IFCOUNTER_OERRORS ifd_oerrors
6804f655ef5SMatthew Dillon #define ifd_IFCOUNTER_OPACKETS ifd_opackets
6814f655ef5SMatthew Dillon #define ifd_IFCOUNTER_OMCASTS ifd_omcasts
6824f655ef5SMatthew Dillon #define ifd_IFCOUNTER_OBYTES ifd_obytes
6834f655ef5SMatthew Dillon
6844f655ef5SMatthew Dillon #define if_inc_counter IFNET_STAT_INC
6854f655ef5SMatthew Dillon
6864f655ef5SMatthew Dillon #define IEEE80211_FREE(ptr, type) kfree((ptr), (type))
6874f655ef5SMatthew Dillon
688841ab66cSSepherosa Ziehau #endif /* _NET80211_IEEE80211_DRAGONFLY_H_ */
689