1 /*- 2 * Copyright (c) 2003-2008 Sam Leffler, Errno Consulting 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * 25 * $FreeBSD: head/sys/net80211/ieee80211_freebsd.h 195618 2009-07-11 15:02:45Z rpaulo $ 26 */ 27 #ifndef _NET80211_IEEE80211_DRAGONFLY_H_ 28 #define _NET80211_IEEE80211_DRAGONFLY_H_ 29 30 #ifdef _KERNEL 31 32 #include <sys/param.h> 33 #include <sys/types.h> 34 #include <sys/serialize.h> 35 #include <sys/sysctl.h> 36 #include <sys/condvar.h> 37 #include <sys/lock.h> 38 #include <sys/taskqueue.h> 39 40 #include <sys/mutex2.h> 41 #include <sys/serialize2.h> 42 43 #ifndef IF_PREPEND_LIST 44 45 /* XXX all are prepended to normal queue */ 46 #define _IF_PREPEND_LIST(ifq, mhead, mtail, mcount, bcnt) do { \ 47 (mtail)->m_nextpkt = (ifq)->ifsq_norm_head; \ 48 if ((ifq)->ifsq_norm_tail == NULL) \ 49 (ifq)->ifsq_norm_tail = (mtail); \ 50 (ifq)->ifsq_norm_head = (mhead); \ 51 (ifq)->ifsq_len += (mcount); \ 52 (ifq)->ifsq_bcnt += (bcnt); \ 53 } while (0) 54 55 #define IF_PREPEND_LIST(ifq, mhead, mtail, mcount, bcnt) do { \ 56 wlan_assert_serialized(); \ 57 _IF_PREPEND_LIST(ifq, mhead, mtail, mcount, bcnt); \ 58 } while (0) 59 60 #endif /* IF_PREPEND_LIST */ 61 62 /* 63 * Global serializer (operates like a non-reentrant lockmgr lock) 64 */ 65 extern struct lwkt_serialize wlan_global_serializer; 66 extern int ieee80211_force_swcrypto; 67 68 #define wlan_serialize_enter() _wlan_serialize_enter(__func__) 69 #define wlan_serialize_exit() _wlan_serialize_exit(__func__) 70 #define wlan_serialize_push() _wlan_serialize_push(__func__) 71 #define wlan_serialize_pop(wst) _wlan_serialize_pop(__func__, wst) 72 #define wlan_is_serialized() _wlan_is_serialized() 73 void _wlan_serialize_enter(const char *funcname); 74 void _wlan_serialize_exit(const char *funcname); 75 int _wlan_serialize_push(const char *funcname); 76 void _wlan_serialize_pop(const char *funcname, int wst); 77 int _wlan_is_serialized(void); 78 int wlan_serialize_sleep(void *ident, int flags, const char *wmesg, int timo); 79 80 static __inline void 81 wlan_assert_serialized(void) 82 { 83 ASSERT_SERIALIZED(&wlan_global_serializer); 84 } 85 86 static __inline void 87 wlan_assert_notserialized(void) 88 { 89 ASSERT_NOT_SERIALIZED(&wlan_global_serializer); 90 } 91 92 /* 93 * Node reference counting definitions. 94 * 95 * ieee80211_node_initref initialize the reference count to 1 96 * ieee80211_node_incref add a reference 97 * ieee80211_node_decref remove a reference 98 * ieee80211_node_dectestref remove a reference and return 1 if this 99 * is the last reference, otherwise 0 100 * ieee80211_node_refcnt reference count for printing (only) 101 */ 102 #include <machine/atomic.h> 103 104 #define ieee80211_node_initref(_ni) \ 105 do { ((_ni)->ni_refcnt = 1); } while (0) 106 #define ieee80211_node_incref(_ni) \ 107 atomic_add_int(&(_ni)->ni_refcnt, 1) 108 #define ieee80211_node_decref(_ni) \ 109 atomic_subtract_int(&(_ni)->ni_refcnt, 1) 110 struct ieee80211_node; 111 int ieee80211_node_dectestref(struct ieee80211_node *ni); 112 #define ieee80211_node_refcnt(_ni) (_ni)->ni_refcnt 113 114 struct ifqueue; 115 struct ieee80211vap; 116 struct ieee80211com; 117 void ieee80211_flush_ifq(struct ifaltq *, struct ieee80211vap *); 118 119 void ieee80211_vap_destroy(struct ieee80211vap *); 120 int ieee80211_vap_xmitpkt(struct ieee80211vap *vap, struct mbuf *m); 121 int ieee80211_parent_xmitpkt(struct ieee80211com *ic, struct mbuf *m); 122 int ieee80211_handoff(struct ifnet *, struct mbuf *); 123 uint16_t ieee80211_txtime(struct ieee80211_node *, u_int, uint8_t, uint32_t); 124 125 #define IFNET_IS_UP_RUNNING(_ifp) \ 126 (((_ifp)->if_flags & IFF_UP) && \ 127 ((_ifp)->if_flags & IFF_RUNNING)) 128 129 #define msecs_to_ticks(ms) (((ms)*hz)/1000) 130 #define ticks_to_msecs(t) (1000*(t) / hz) 131 #define ticks_to_secs(t) ((t) / hz) 132 #define time_after(a,b) ((long)(b) - (long)(a) < 0) 133 #define time_before(a,b) time_after(b,a) 134 #define time_after_eq(a,b) ((long)(a) - (long)(b) >= 0) 135 #define time_before_eq(a,b) time_after_eq(b,a) 136 137 struct mbuf *ieee80211_getmgtframe(uint8_t **frm, int headroom, int pktlen); 138 139 /* tx path usage */ 140 #define M_ENCAP M_PROTO1 /* 802.11 encap done */ 141 #define M_EAPOL M_PROTO3 /* PAE/EAPOL frame */ 142 #define M_PWR_SAV M_PROTO4 /* bypass PS handling */ 143 #define M_MORE_DATA M_PROTO5 /* more data frames to follow */ 144 #define M_FF M_PROTO6 /* fast frame */ 145 #define M_TXCB M_PROTO7 /* do tx complete callback */ 146 #define M_AMPDU_MPDU M_PROTO8 /* ok for A-MPDU aggregation */ 147 #define M_80211_TX \ 148 (M_FRAG|M_FIRSTFRAG|M_LASTFRAG|M_ENCAP|M_EAPOL|M_PWR_SAV|\ 149 M_MORE_DATA|M_FF|M_TXCB|M_AMPDU_MPDU) 150 151 /* rx path usage */ 152 #define M_AMPDU M_PROTO1 /* A-MPDU subframe */ 153 #define M_WEP M_PROTO2 /* WEP done by hardware */ 154 #if 0 155 #define M_AMPDU_MPDU M_PROTO8 /* A-MPDU re-order done */ 156 #endif 157 #define M_80211_RX (M_AMPDU|M_WEP|M_AMPDU_MPDU) 158 159 #define IEEE80211_MBUF_TX_FLAG_BITS \ 160 "\20\1M_EXT\2M_PKTHDR\3M_EOR\4M_RDONLY\5M_ENCAP\6M_WEP\7M_EAPOL" \ 161 "\10M_PWR_SAV\11M_MORE_DATA\12M_BCAST\13M_MCAST\14M_FRAG\15M_FIRSTFRAG" \ 162 "\16M_LASTFRAG\17M_SKIP_FIREWALL\20M_FREELIST\21M_VLANTAG\22M_PROMISC" \ 163 "\23M_NOFREE\24M_FF\25M_TXCB\26M_AMPDU_MPDU\27M_FLOWID" 164 165 #define IEEE80211_MBUF_RX_FLAG_BITS \ 166 "\20\1M_EXT\2M_PKTHDR\3M_EOR\4M_RDONLY\5M_AMPDU\6M_WEP\7M_PROTO3" \ 167 "\10M_PROTO4\11M_PROTO5\12M_BCAST\13M_MCAST\14M_FRAG\15M_FIRSTFRAG" \ 168 "\16M_LASTFRAG\17M_SKIP_FIREWALL\20M_FREELIST\21M_VLANTAG\22M_PROMISC" \ 169 "\23M_NOFREE\24M_PROTO6\25M_PROTO7\26M_AMPDU_MPDU\27M_FLOWID" 170 171 /* 172 * Store WME access control bits in the vlan tag. 173 * This is safe since it's done after the packet is classified 174 * (where we use any previous tag) and because it's passed 175 * directly in to the driver and there's no chance someone 176 * else will clobber them on us. 177 */ 178 #define M_WME_SETAC(m, ac) \ 179 ((m)->m_pkthdr.ether_vlantag = (ac)) 180 #define M_WME_GETAC(m) ((m)->m_pkthdr.ether_vlantag) 181 182 /* 183 * Mbufs on the power save queue are tagged with an age and 184 * timed out. We reuse the hardware checksum field in the 185 * mbuf packet header to store this data. 186 */ 187 #define M_AGE_SET(m,v) (m->m_pkthdr.csum_data = v) 188 #define M_AGE_GET(m) (m->m_pkthdr.csum_data) 189 #define M_AGE_SUB(m,adj) (m->m_pkthdr.csum_data -= adj) 190 191 /* 192 * Store the sequence number. 193 */ 194 #define M_SEQNO_SET(m, seqno) \ 195 ((m)->m_pkthdr.wlan_seqno = (seqno)) 196 #define M_SEQNO_GET(m) ((m)->m_pkthdr.wlan_seqno) 197 198 #define MTAG_ABI_NET80211 1132948340 /* net80211 ABI */ 199 200 struct ieee80211_cb { 201 void (*func)(struct ieee80211_node *, void *, int status); 202 void *arg; 203 }; 204 #define NET80211_TAG_CALLBACK 0 /* xmit complete callback */ 205 int ieee80211_add_callback(struct mbuf *m, 206 void (*func)(struct ieee80211_node *, void *, int), void *arg); 207 void ieee80211_process_callback(struct ieee80211_node *, struct mbuf *, int); 208 209 void get_random_bytes(void *, size_t); 210 211 struct ieee80211com; 212 213 void ieee80211_sysctl_attach(struct ieee80211com *); 214 void ieee80211_sysctl_detach(struct ieee80211com *); 215 void ieee80211_sysctl_vattach(struct ieee80211vap *); 216 void ieee80211_sysctl_vdetach(struct ieee80211vap *); 217 218 SYSCTL_DECL(_net_wlan); 219 int ieee80211_sysctl_msecs_ticks(SYSCTL_HANDLER_ARGS); 220 221 void ieee80211_load_module(const char *); 222 223 /* 224 * A "policy module" is an adjunct module to net80211 that provides 225 * functionality that typically includes policy decisions. This 226 * modularity enables extensibility and vendor-supplied functionality. 227 */ 228 #define _IEEE80211_POLICY_MODULE(policy, name, version) \ 229 typedef void (*policy##_setup)(int); \ 230 SET_DECLARE(policy##_set, policy##_setup); \ 231 static int \ 232 wlan_##name##_modevent(module_t mod, int type, void *unused) \ 233 { \ 234 policy##_setup * const *iter, f; \ 235 int error; \ 236 \ 237 switch (type) { \ 238 case MOD_LOAD: \ 239 SET_FOREACH(iter, policy##_set) { \ 240 f = (void*) *iter; \ 241 f(type); \ 242 } \ 243 error = 0; \ 244 break; \ 245 case MOD_UNLOAD: \ 246 error = 0; \ 247 if (nrefs) { \ 248 kprintf("wlan_##name: still in use (%u " \ 249 "dynamic refs)\n", \ 250 nrefs); \ 251 error = EBUSY; \ 252 } else if (type == MOD_UNLOAD) { \ 253 SET_FOREACH(iter, policy##_set) { \ 254 f = (void*) *iter; \ 255 f(type); \ 256 } \ 257 } \ 258 break; \ 259 default: \ 260 error = EINVAL; \ 261 break; \ 262 } \ 263 \ 264 return error; \ 265 } \ 266 static moduledata_t name##_mod = { \ 267 "wlan_" #name, \ 268 wlan_##name##_modevent, \ 269 0 \ 270 }; \ 271 DECLARE_MODULE(wlan_##name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST);\ 272 MODULE_VERSION(wlan_##name, version); \ 273 MODULE_DEPEND(wlan_##name, wlan, 1, 1, 1) 274 275 /* 276 * Crypto modules implement cipher support. 277 */ 278 #define IEEE80211_CRYPTO_MODULE(name, version) \ 279 _IEEE80211_POLICY_MODULE(crypto, name, version); \ 280 static void \ 281 name##_modevent(int type) \ 282 { \ 283 /* wlan already serialized! */ \ 284 if (type == MOD_LOAD) \ 285 ieee80211_crypto_register(&name); \ 286 else \ 287 ieee80211_crypto_unregister(&name); \ 288 } \ 289 TEXT_SET(crypto##_set, name##_modevent) 290 291 /* 292 * Scanner modules provide scanning policy. 293 */ 294 #define IEEE80211_SCANNER_MODULE(name, version) \ 295 _IEEE80211_POLICY_MODULE(scanner, name, version) 296 297 #define IEEE80211_SCANNER_ALG(name, alg, v) \ 298 static void \ 299 name##_modevent(int type) \ 300 { \ 301 /* wlan already serialized! */ \ 302 if (type == MOD_LOAD) \ 303 ieee80211_scanner_register(alg, &v); \ 304 else \ 305 ieee80211_scanner_unregister(alg, &v); \ 306 } \ 307 TEXT_SET(scanner_set, name##_modevent); \ 308 309 /* 310 * ACL modules implement acl policy. 311 */ 312 #define IEEE80211_ACL_MODULE(name, alg, version) \ 313 _IEEE80211_POLICY_MODULE(acl, name, version); \ 314 static void \ 315 alg##_modevent(int type) \ 316 { \ 317 /* wlan already serialized! */ \ 318 if (type == MOD_LOAD) \ 319 ieee80211_aclator_register(&alg); \ 320 else \ 321 ieee80211_aclator_unregister(&alg); \ 322 } \ 323 TEXT_SET(acl_set, alg##_modevent); \ 324 325 /* 326 * Authenticator modules handle 802.1x/WPA authentication. 327 */ 328 #define IEEE80211_AUTH_MODULE(name, version) \ 329 _IEEE80211_POLICY_MODULE(auth, name, version) 330 331 #define IEEE80211_AUTH_ALG(name, alg, v) \ 332 static void \ 333 name##_modevent(int type) \ 334 { \ 335 /* wlan already serialized! */ \ 336 if (type == MOD_LOAD) \ 337 ieee80211_authenticator_register(alg, &v); \ 338 else \ 339 ieee80211_authenticator_unregister(alg); \ 340 } \ 341 TEXT_SET(auth_set, name##_modevent) 342 343 /* 344 * Rate control modules provide tx rate control support. 345 */ 346 #define IEEE80211_RATECTL_MODULE(alg, version) \ 347 _IEEE80211_POLICY_MODULE(ratectl, alg, version); \ 348 349 #define IEEE80211_RATECTL_ALG(name, alg, v) \ 350 static void \ 351 alg##_modevent(int type) \ 352 { \ 353 /* wlan already serialized! */ \ 354 if (type == MOD_LOAD) \ 355 ieee80211_ratectl_register(alg, &v); \ 356 else \ 357 ieee80211_ratectl_unregister(alg); \ 358 } \ 359 TEXT_SET(ratectl##_set, alg##_modevent) 360 361 struct ieee80211req; 362 typedef int ieee80211_ioctl_getfunc(struct ieee80211vap *, 363 struct ieee80211req *); 364 SET_DECLARE(ieee80211_ioctl_getset, ieee80211_ioctl_getfunc); 365 #define IEEE80211_IOCTL_GET(_name, _get) TEXT_SET(ieee80211_ioctl_getset, _get) 366 367 typedef int ieee80211_ioctl_setfunc(struct ieee80211vap *, 368 struct ieee80211req *); 369 SET_DECLARE(ieee80211_ioctl_setset, ieee80211_ioctl_setfunc); 370 #define IEEE80211_IOCTL_SET(_name, _set) TEXT_SET(ieee80211_ioctl_setset, _set) 371 #endif /* _KERNEL */ 372 373 /* XXX this stuff belongs elsewhere */ 374 /* 375 * Message formats for messages from the net80211 layer to user 376 * applications via the routing socket. These messages are appended 377 * to an if_announcemsghdr structure. 378 */ 379 struct ieee80211_join_event { 380 uint8_t iev_addr[6]; 381 }; 382 383 struct ieee80211_leave_event { 384 uint8_t iev_addr[6]; 385 }; 386 387 struct ieee80211_replay_event { 388 uint8_t iev_src[6]; /* src MAC */ 389 uint8_t iev_dst[6]; /* dst MAC */ 390 uint8_t iev_cipher; /* cipher type */ 391 uint8_t iev_keyix; /* key id/index */ 392 uint64_t iev_keyrsc; /* RSC from key */ 393 uint64_t iev_rsc; /* RSC from frame */ 394 }; 395 396 struct ieee80211_michael_event { 397 uint8_t iev_src[6]; /* src MAC */ 398 uint8_t iev_dst[6]; /* dst MAC */ 399 uint8_t iev_cipher; /* cipher type */ 400 uint8_t iev_keyix; /* key id/index */ 401 }; 402 403 struct ieee80211_wds_event { 404 uint8_t iev_addr[6]; 405 }; 406 407 struct ieee80211_csa_event { 408 uint32_t iev_flags; /* channel flags */ 409 uint16_t iev_freq; /* setting in Mhz */ 410 uint8_t iev_ieee; /* IEEE channel number */ 411 uint8_t iev_mode; /* CSA mode */ 412 uint8_t iev_count; /* CSA count */ 413 }; 414 415 struct ieee80211_cac_event { 416 uint32_t iev_flags; /* channel flags */ 417 uint16_t iev_freq; /* setting in Mhz */ 418 uint8_t iev_ieee; /* IEEE channel number */ 419 /* XXX timestamp? */ 420 uint8_t iev_type; /* IEEE80211_NOTIFY_CAC_* */ 421 }; 422 423 struct ieee80211_radar_event { 424 uint32_t iev_flags; /* channel flags */ 425 uint16_t iev_freq; /* setting in Mhz */ 426 uint8_t iev_ieee; /* IEEE channel number */ 427 /* XXX timestamp? */ 428 }; 429 430 struct ieee80211_auth_event { 431 uint8_t iev_addr[6]; 432 }; 433 434 struct ieee80211_deauth_event { 435 uint8_t iev_addr[6]; 436 }; 437 438 struct ieee80211_country_event { 439 uint8_t iev_addr[6]; 440 uint8_t iev_cc[2]; /* ISO country code */ 441 }; 442 443 struct ieee80211_radio_event { 444 uint8_t iev_state; /* 1 on, 0 off */ 445 }; 446 447 #define RTM_IEEE80211_ASSOC 100 /* station associate (bss mode) */ 448 #define RTM_IEEE80211_REASSOC 101 /* station re-associate (bss mode) */ 449 #define RTM_IEEE80211_DISASSOC 102 /* station disassociate (bss mode) */ 450 #define RTM_IEEE80211_JOIN 103 /* station join (ap mode) */ 451 #define RTM_IEEE80211_LEAVE 104 /* station leave (ap mode) */ 452 #define RTM_IEEE80211_SCAN 105 /* scan complete, results available */ 453 #define RTM_IEEE80211_REPLAY 106 /* sequence counter replay detected */ 454 #define RTM_IEEE80211_MICHAEL 107 /* Michael MIC failure detected */ 455 #define RTM_IEEE80211_REJOIN 108 /* station re-associate (ap mode) */ 456 #define RTM_IEEE80211_WDS 109 /* WDS discovery (ap mode) */ 457 #define RTM_IEEE80211_CSA 110 /* Channel Switch Announcement event */ 458 #define RTM_IEEE80211_RADAR 111 /* radar event */ 459 #define RTM_IEEE80211_CAC 112 /* Channel Availability Check event */ 460 #define RTM_IEEE80211_DEAUTH 113 /* station deauthenticate */ 461 #define RTM_IEEE80211_AUTH 114 /* station authenticate (ap mode) */ 462 #define RTM_IEEE80211_COUNTRY 115 /* discovered country code (sta mode) */ 463 #define RTM_IEEE80211_RADIO 116 /* RF kill switch state change */ 464 465 /* 466 * Structure prepended to raw packets sent through the bpf 467 * interface when set to DLT_IEEE802_11_RADIO. This allows 468 * user applications to specify pretty much everything in 469 * an Atheros tx descriptor. XXX need to generalize. 470 * 471 * XXX cannot be more than 14 bytes as it is copied to a sockaddr's 472 * XXX sa_data area. 473 */ 474 struct ieee80211_bpf_params { 475 uint8_t ibp_vers; /* version */ 476 #define IEEE80211_BPF_VERSION 0 477 uint8_t ibp_len; /* header length in bytes */ 478 uint8_t ibp_flags; 479 #define IEEE80211_BPF_SHORTPRE 0x01 /* tx with short preamble */ 480 #define IEEE80211_BPF_NOACK 0x02 /* tx with no ack */ 481 #define IEEE80211_BPF_CRYPTO 0x04 /* tx with h/w encryption */ 482 #define IEEE80211_BPF_FCS 0x10 /* frame incldues FCS */ 483 #define IEEE80211_BPF_DATAPAD 0x20 /* frame includes data padding */ 484 #define IEEE80211_BPF_RTS 0x40 /* tx with RTS/CTS */ 485 #define IEEE80211_BPF_CTS 0x80 /* tx with CTS only */ 486 uint8_t ibp_pri; /* WME/WMM AC+tx antenna */ 487 uint8_t ibp_try0; /* series 1 try count */ 488 uint8_t ibp_rate0; /* series 1 IEEE tx rate */ 489 uint8_t ibp_power; /* tx power (device units) */ 490 uint8_t ibp_ctsrate; /* IEEE tx rate for CTS */ 491 uint8_t ibp_try1; /* series 2 try count */ 492 uint8_t ibp_rate1; /* series 2 IEEE tx rate */ 493 uint8_t ibp_try2; /* series 3 try count */ 494 uint8_t ibp_rate2; /* series 3 IEEE tx rate */ 495 uint8_t ibp_try3; /* series 4 try count */ 496 uint8_t ibp_rate3; /* series 4 IEEE tx rate */ 497 }; 498 499 /* 500 * FreeBSD overrides 501 */ 502 const char *ether_sprintf(const u_char *buf); 503 504 #define V_ifnet ifnet 505 #define IFF_DRV_RUNNING IFF_RUNNING 506 #define if_drv_flags if_flags 507 508 typedef struct lock ieee80211_psq_lock_t; 509 typedef struct lock ieee80211_ageq_lock_t; 510 typedef struct lock ieee80211_node_lock_t; 511 typedef struct lock ieee80211_scan_lock_t; 512 typedef struct lock ieee80211_com_lock_t; 513 typedef struct lock ieee80211_tx_lock_t; 514 typedef struct lock ieee80211_ageq_lock_t; 515 typedef struct lock ieee80211_scan_table_lock_t; 516 typedef struct lock acl_lock_t; 517 518 #define IEEE80211_LOCK_OBJ(ic) (&(ic)->ic_comlock) 519 520 #define IEEE80211_LOCK_INIT(ic, name) lockinit(&(ic)->ic_comlock, name, 0, LK_CANRECURSE) 521 #define IEEE80211_NODE_LOCK_INIT(ic, name) lockinit(&(nt)->nt_nodelock, name, 0, LK_CANRECURSE) 522 #define IEEE80211_NODE_ITERATE_LOCK_INIT(ic, name) lockinit(&(nt)->nt_scanlock, name, 0, LK_CANRECURSE) 523 #define IEEE80211_SCAN_TABLE_LOCK_INIT(st, name) lockinit(&(st)->st_lock, name, 0, LK_CANRECURSE) 524 #define IEEE80211_TX_LOCK_INIT(ic, name) lockinit(&(ic)->ic_txlock, name, 0, LK_CANRECURSE) 525 #define IEEE80211_AGEQ_LOCK_INIT(aq, name) lockinit(&(aq)->aq_lock, name, 0, LK_CANRECURSE) 526 #define IEEE80211_PSQ_INIT(psq, name) lockinit(&(psq)->psq_lock, name, 0, LK_CANRECURSE) 527 #define ACL_LOCK_INIT(as, name) lockinit(&(as)->as_lock, name, 0, LK_CANRECURSE) 528 529 #define IEEE80211_LOCK_DESTROY(ic) lockuninit(&(ic)->ic_comlock) 530 #define IEEE80211_NODE_LOCK_DESTROY(nt) lockuninit(&(nt)->nt_nodelock) 531 #define IEEE80211_NODE_ITERATE_LOCK_DESTROY(nt) lockuninit(&(nt)->nt_scanlock) 532 #define IEEE80211_SCAN_TABLE_LOCK_DESTROY(st) lockuninit(&(st)->st_lock) 533 #define IEEE80211_TX_LOCK_DESTROY(ic) lockuninit(&(ic)->ic_txlock) 534 #define IEEE80211_AGEQ_LOCK_DESTROY(aq) lockuninit(&(aq)->aq_lock) 535 #define IEEE80211_PSQ_DESTROY(psq) lockuninit(&(psq)->psq_lock) 536 #define ACL_LOCK_DESTROY(as) lockuninit(&(as)->as_lock) 537 538 #define IEEE80211_LOCK(ic) lockmgr(&(ic)->ic_comlock, LK_EXCLUSIVE) 539 #define IEEE80211_NODE_LOCK(nt) lockmgr(&(nt)->nt_nodelock, LK_EXCLUSIVE) 540 #define IEEE80211_NODE_ITERATE_LOCK(nt) lockmgr(&(nt)->nt_scanlock, LK_EXCLUSIVE) 541 #define IEEE80211_SCAN_TABLE_LOCK(st) lockmgr(&(st)->st_lock, LK_EXCLUSIVE) 542 #define IEEE80211_TX_LOCK(ic) lockmgr(&(ic)->ic_txlock, LK_EXCLUSIVE) 543 #define IEEE80211_AGEQ_LOCK(aq) lockmgr(&(aq)->aq_lock, LK_EXCLUSIVE) 544 #define IEEE80211_PSQ_LOCK(psq) lockmgr(&(psq)->psq_lock, LK_EXCLUSIVE) 545 #define ACL_LOCK(as) lockmgr(&(as)->as_lock, LK_EXCLUSIVE) 546 547 #define IEEE80211_UNLOCK(ic) lockmgr(&(ic)->ic_comlock, LK_RELEASE) 548 #define IEEE80211_NODE_UNLOCK(nt) lockmgr(&(nt)->nt_nodelock, LK_RELEASE) 549 #define IEEE80211_NODE_ITERATE_UNLOCK(nt) lockmgr(&(nt)->nt_scanlock, LK_RELEASE) 550 #define IEEE80211_SCAN_TABLE_UNLOCK(nt) lockmgr(&(st)->st_lock, LK_RELEASE) 551 #define IEEE80211_TX_UNLOCK(ic) lockmgr(&(ic)->ic_txlock, LK_RELEASE) 552 #define IEEE80211_AGEQ_UNLOCK(aq) lockmgr(&(aq)->aq_lock, LK_RELEASE) 553 #define IEEE80211_PSQ_UNLOCK(psq) lockmgr(&(psq)->psq_lock, LK_RELEASE) 554 #define ACL_UNLOCK(as) lockmgr(&(as)->as_lock, LK_RELEASE) 555 556 #define IEEE80211_LOCK_ASSERT(ic) \ 557 KKASSERT(lockstatus(&(ic)->ic_comlock, curthread) == LK_EXCLUSIVE) 558 #define IEEE80211_NODE_LOCK_ASSERT(nt) \ 559 KKASSERT(lockstatus(&(nt)->nt_nodelock, curthread) == LK_EXCLUSIVE) 560 #define IEEE80211_NODE_ITERATE_LOCK_ASSERT(nt) \ 561 KKASSERT(lockstatus(&(nt)->nt_scanlock, curthread) == LK_EXCLUSIVE) 562 #define IEEE80211_TX_LOCK_ASSERT(ic) \ 563 KKASSERT(lockstatus(&(ic)->ic_txlock, curthread) == LK_EXCLUSIVE) 564 #define IEEE80211_TX_UNLOCK_ASSERT(ic) \ 565 KKASSERT(lockstatus(&(ic)->ic_txlock, curthread) != LK_EXCLUSIVE) 566 #define IEEE80211_AGEQ_LOCK_ASSERT(aq) \ 567 KKASSERT(lockstatus(&(aq)->aq_lock, curthread) == LK_EXCLUSIVE) 568 #define ACL_LOCK_ASSERT(as) \ 569 KKASSERT(lockstatus(&(as)->as_lock, curthread) == LK_EXCLUSIVE) 570 571 #define IEEE80211_NODE_IS_LOCKED(nt) \ 572 (lockstatus(&(nt)->nt_nodelock, curthread) == LK_EXCLUSIVE) 573 574 #define arc4random karc4random 575 576 #define IEEE80211_AGEQ_INIT(aq, name) 577 #define IEEE80211_AGEQ_DESTROY(aq) 578 #define CURVNET_SET(x) 579 #define CURVNET_RESTORE() 580 #define ifa_free(ifa) 581 582 #define ALIGNED_POINTER(p, t) (((uintptr_t)(p) & (sizeof(t) - 1)) == 0) 583 584 #define osdep_va_list __va_list 585 #define osdep_va_start __va_start 586 #define osdep_va_end __va_end 587 588 /* 589 * DragonFly does not implement _SAFE macros because they are generally not 590 * actually safe in a MP environment, and so it is bad programming practice 591 * to use them. 592 */ 593 #define TAILQ_FOREACH_SAFE(scan, list, next, save) \ 594 for (scan = TAILQ_FIRST(list); (save = scan ? TAILQ_NEXT(scan, next) : NULL), scan; scan = save) \ 595 596 #define callout_init_mtx(callo, lk, flags) \ 597 callout_init_lk(callo, lk) 598 #define callout_schedule_dfly(callo, timo, func, args) \ 599 callout_reset(callo, timo, func, args) 600 601 #endif /* _NET80211_IEEE80211_DRAGONFLY_H_ */ 602