1 /* 2 * Copyright 2009, Colin Günther, coling@gmx.de. All rights reserved. 3 * Copyright 2018, Haiku, Inc. All rights reserved. 4 * Distributed under the terms of the MIT License. 5 */ 6 /*- 7 * Copyright (c) 2003-2008 Sam Leffler, Errno Consulting 8 * All rights reserved. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 #ifndef _FBSD_COMPAT_NET80211_IEEE80211_HAIKU_H_ 31 #define _FBSD_COMPAT_NET80211_IEEE80211_HAIKU_H_ 32 33 34 #include <stdint.h> 35 36 37 #ifdef _KERNEL 38 39 # ifdef __cplusplus 40 // Those includes are needed to avoid C/C++ function export clashes 41 # include <new> 42 # include <thread.h> 43 extern "C" { 44 # endif 45 46 #include <sys/kernel.h> 47 #include <sys/mutex.h> 48 #include <sys/sysctl.h> 49 #include <sys/taskqueue.h> 50 #include <sys/time.h> 51 52 53 #ifdef DEBUGNET 54 #include <net/debugnet.h> 55 #endif 56 57 /* 58 * priv(9) NET80211 checks. 59 */ 60 struct ieee80211vap; 61 int ieee80211_priv_check_vap_getkey(u_long, struct ieee80211vap *, 62 struct ifnet *); 63 int ieee80211_priv_check_vap_manage(u_long, struct ieee80211vap *, 64 struct ifnet *); 65 int ieee80211_priv_check_vap_setmac(u_long, struct ieee80211vap *, 66 struct ifnet *); 67 int ieee80211_priv_check_create_vap(u_long, struct ieee80211vap *, 68 struct ifnet *); 69 70 /* 71 * Common state locking definitions. 72 */ 73 typedef struct { 74 char name[16]; /* e.g. "ath0_com_lock" */ 75 struct mtx mtx; 76 } ieee80211_com_lock_t; 77 #define IEEE80211_LOCK_INIT(_ic, _name) do { \ 78 ieee80211_com_lock_t *cl = &(_ic)->ic_comlock; \ 79 snprintf(cl->name, sizeof(cl->name), "%s_com_lock", _name); \ 80 mtx_init(&cl->mtx, cl->name, NULL, MTX_DEF | MTX_RECURSE); \ 81 } while (0) 82 #define IEEE80211_LOCK_OBJ(_ic) (&(_ic)->ic_comlock.mtx) 83 #define IEEE80211_LOCK_DESTROY(_ic) mtx_destroy(IEEE80211_LOCK_OBJ(_ic)) 84 #define IEEE80211_LOCK(_ic) mtx_lock(IEEE80211_LOCK_OBJ(_ic)) 85 #define IEEE80211_UNLOCK(_ic) mtx_unlock(IEEE80211_LOCK_OBJ(_ic)) 86 #define IEEE80211_LOCK_ASSERT(_ic) \ 87 mtx_assert(IEEE80211_LOCK_OBJ(_ic), MA_OWNED) 88 #define IEEE80211_UNLOCK_ASSERT(_ic) \ 89 mtx_assert(IEEE80211_LOCK_OBJ(_ic), MA_NOTOWNED) 90 91 /* 92 * Transmit lock. 93 * 94 * This is a (mostly) temporary lock designed to serialise all of the 95 * transmission operations throughout the stack. 96 */ 97 typedef struct { 98 char name[16]; /* e.g. "ath0_tx_lock" */ 99 struct mtx mtx; 100 } ieee80211_tx_lock_t; 101 #define IEEE80211_TX_LOCK_INIT(_ic, _name) do { \ 102 ieee80211_tx_lock_t *cl = &(_ic)->ic_txlock; \ 103 snprintf(cl->name, sizeof(cl->name), "%s_tx_lock", _name); \ 104 mtx_init(&cl->mtx, cl->name, NULL, MTX_DEF); \ 105 } while (0) 106 #define IEEE80211_TX_LOCK_OBJ(_ic) (&(_ic)->ic_txlock.mtx) 107 #define IEEE80211_TX_LOCK_DESTROY(_ic) mtx_destroy(IEEE80211_TX_LOCK_OBJ(_ic)) 108 #define IEEE80211_TX_LOCK(_ic) mtx_lock(IEEE80211_TX_LOCK_OBJ(_ic)) 109 #define IEEE80211_TX_UNLOCK(_ic) mtx_unlock(IEEE80211_TX_LOCK_OBJ(_ic)) 110 #define IEEE80211_TX_LOCK_ASSERT(_ic) \ 111 mtx_assert(IEEE80211_TX_LOCK_OBJ(_ic), MA_OWNED) 112 #define IEEE80211_TX_UNLOCK_ASSERT(_ic) \ 113 mtx_assert(IEEE80211_TX_LOCK_OBJ(_ic), MA_NOTOWNED) 114 115 /* 116 * Stageq / ni_tx_superg lock 117 */ 118 typedef struct { 119 char name[16]; /* e.g. "ath0_ff_lock" */ 120 struct mtx mtx; 121 } ieee80211_ff_lock_t; 122 #define IEEE80211_FF_LOCK_INIT(_ic, _name) do { \ 123 ieee80211_ff_lock_t *fl = &(_ic)->ic_fflock; \ 124 snprintf(fl->name, sizeof(fl->name), "%s_ff_lock", _name); \ 125 mtx_init(&fl->mtx, fl->name, NULL, MTX_DEF); \ 126 } while (0) 127 #define IEEE80211_FF_LOCK_OBJ(_ic) (&(_ic)->ic_fflock.mtx) 128 #define IEEE80211_FF_LOCK_DESTROY(_ic) mtx_destroy(IEEE80211_FF_LOCK_OBJ(_ic)) 129 #define IEEE80211_FF_LOCK(_ic) mtx_lock(IEEE80211_FF_LOCK_OBJ(_ic)) 130 #define IEEE80211_FF_UNLOCK(_ic) mtx_unlock(IEEE80211_FF_LOCK_OBJ(_ic)) 131 #define IEEE80211_FF_LOCK_ASSERT(_ic) \ 132 mtx_assert(IEEE80211_FF_LOCK_OBJ(_ic), MA_OWNED) 133 134 /* 135 * Node locking definitions. 136 */ 137 typedef struct { 138 char name[16]; /* e.g. "ath0_node_lock" */ 139 struct mtx mtx; 140 } ieee80211_node_lock_t; 141 #define IEEE80211_NODE_LOCK_INIT(_nt, _name) do { \ 142 ieee80211_node_lock_t *nl = &(_nt)->nt_nodelock; \ 143 snprintf(nl->name, sizeof(nl->name), "%s_node_lock", _name); \ 144 mtx_init(&nl->mtx, nl->name, NULL, MTX_DEF | MTX_RECURSE); \ 145 } while (0) 146 #define IEEE80211_NODE_LOCK_OBJ(_nt) (&(_nt)->nt_nodelock.mtx) 147 #define IEEE80211_NODE_LOCK_DESTROY(_nt) \ 148 mtx_destroy(IEEE80211_NODE_LOCK_OBJ(_nt)) 149 #define IEEE80211_NODE_LOCK(_nt) \ 150 mtx_lock(IEEE80211_NODE_LOCK_OBJ(_nt)) 151 #define IEEE80211_NODE_IS_LOCKED(_nt) \ 152 mtx_owned(IEEE80211_NODE_LOCK_OBJ(_nt)) 153 #define IEEE80211_NODE_UNLOCK(_nt) \ 154 mtx_unlock(IEEE80211_NODE_LOCK_OBJ(_nt)) 155 #define IEEE80211_NODE_LOCK_ASSERT(_nt) \ 156 mtx_assert(IEEE80211_NODE_LOCK_OBJ(_nt), MA_OWNED) 157 158 /* 159 * Node table iteration locking definitions; this protects the 160 * scan generation # used to iterate over the station table 161 * while grabbing+releasing the node lock. 162 */ 163 typedef struct { 164 char name[16]; /* e.g. "ath0_scan_lock" */ 165 struct mtx mtx; 166 } ieee80211_scan_lock_t; 167 #define IEEE80211_NODE_ITERATE_LOCK_INIT(_nt, _name) do { \ 168 ieee80211_scan_lock_t *sl = &(_nt)->nt_scanlock; \ 169 snprintf(sl->name, sizeof(sl->name), "%s_scan_lock", _name); \ 170 mtx_init(&sl->mtx, sl->name, NULL, MTX_DEF); \ 171 } while (0) 172 #define IEEE80211_NODE_ITERATE_LOCK_OBJ(_nt) (&(_nt)->nt_scanlock.mtx) 173 #define IEEE80211_NODE_ITERATE_LOCK_DESTROY(_nt) \ 174 mtx_destroy(IEEE80211_NODE_ITERATE_LOCK_OBJ(_nt)) 175 #define IEEE80211_NODE_ITERATE_LOCK(_nt) \ 176 mtx_lock(IEEE80211_NODE_ITERATE_LOCK_OBJ(_nt)) 177 #define IEEE80211_NODE_ITERATE_UNLOCK(_nt) \ 178 mtx_unlock(IEEE80211_NODE_ITERATE_LOCK_OBJ(_nt)) 179 180 /* 181 * Power-save queue definitions. 182 */ 183 typedef struct mtx ieee80211_psq_lock_t; 184 #define IEEE80211_PSQ_INIT(_psq, _name) \ 185 mtx_init(&(_psq)->psq_lock, _name, "802.11 ps q", MTX_DEF) 186 #define IEEE80211_PSQ_DESTROY(_psq) mtx_destroy(&(_psq)->psq_lock) 187 #define IEEE80211_PSQ_LOCK(_psq) mtx_lock(&(_psq)->psq_lock) 188 #define IEEE80211_PSQ_UNLOCK(_psq) mtx_unlock(&(_psq)->psq_lock) 189 190 #ifndef IF_PREPEND_LIST 191 #define _IF_PREPEND_LIST(ifq, mhead, mtail, mcount) do { \ 192 (mtail)->m_nextpkt = (ifq)->ifq_head; \ 193 if ((ifq)->ifq_tail == NULL) \ 194 (ifq)->ifq_tail = (mtail); \ 195 (ifq)->ifq_head = (mhead); \ 196 (ifq)->ifq_len += (mcount); \ 197 } while (0) 198 #define IF_PREPEND_LIST(ifq, mhead, mtail, mcount) do { \ 199 IF_LOCK(ifq); \ 200 _IF_PREPEND_LIST(ifq, mhead, mtail, mcount); \ 201 IF_UNLOCK(ifq); \ 202 } while (0) 203 #endif /* IF_PREPEND_LIST */ 204 205 /* 206 * Age queue definitions. 207 */ 208 typedef struct mtx ieee80211_ageq_lock_t; 209 #define IEEE80211_AGEQ_INIT(_aq, _name) \ 210 mtx_init(&(_aq)->aq_lock, _name, "802.11 age q", MTX_DEF) 211 #define IEEE80211_AGEQ_DESTROY(_aq) mtx_destroy(&(_aq)->aq_lock) 212 #define IEEE80211_AGEQ_LOCK(_aq) mtx_lock(&(_aq)->aq_lock) 213 #define IEEE80211_AGEQ_UNLOCK(_aq) mtx_unlock(&(_aq)->aq_lock) 214 215 /* 216 * Scan table definitions. 217 */ 218 typedef struct mtx ieee80211_scan_table_lock_t; 219 #define IEEE80211_SCAN_TABLE_LOCK_INIT(_st, _name) \ 220 mtx_init(&(_st)->st_lock, _name, "802.11 scan table", MTX_DEF) 221 #define IEEE80211_SCAN_TABLE_LOCK_DESTROY(_st) mtx_destroy(&(_st)->st_lock) 222 #define IEEE80211_SCAN_TABLE_LOCK(_st) mtx_lock(&(_st)->st_lock) 223 #define IEEE80211_SCAN_TABLE_UNLOCK(_st) mtx_unlock(&(_st)->st_lock) 224 225 typedef struct mtx ieee80211_scan_iter_lock_t; 226 #define IEEE80211_SCAN_ITER_LOCK_INIT(_st, _name) \ 227 mtx_init(&(_st)->st_scanlock, _name, "802.11 scangen", MTX_DEF) 228 #define IEEE80211_SCAN_ITER_LOCK_DESTROY(_st) mtx_destroy(&(_st)->st_scanlock) 229 #define IEEE80211_SCAN_ITER_LOCK(_st) mtx_lock(&(_st)->st_scanlock) 230 #define IEEE80211_SCAN_ITER_UNLOCK(_st) mtx_unlock(&(_st)->st_scanlock) 231 232 /* 233 * Mesh node/routing definitions. 234 */ 235 typedef struct mtx ieee80211_rte_lock_t; 236 #define MESH_RT_ENTRY_LOCK_INIT(_rt, _name) \ 237 mtx_init(&(rt)->rt_lock, _name, "802.11s route entry", MTX_DEF) 238 #define MESH_RT_ENTRY_LOCK_DESTROY(_rt) \ 239 mtx_destroy(&(_rt)->rt_lock) 240 #define MESH_RT_ENTRY_LOCK(rt) mtx_lock(&(rt)->rt_lock) 241 #define MESH_RT_ENTRY_LOCK_ASSERT(rt) mtx_assert(&(rt)->rt_lock, MA_OWNED) 242 #define MESH_RT_ENTRY_UNLOCK(rt) mtx_unlock(&(rt)->rt_lock) 243 244 typedef struct mtx ieee80211_rt_lock_t; 245 #define MESH_RT_LOCK(ms) mtx_lock(&(ms)->ms_rt_lock) 246 #define MESH_RT_LOCK_ASSERT(ms) mtx_assert(&(ms)->ms_rt_lock, MA_OWNED) 247 #define MESH_RT_UNLOCK(ms) mtx_unlock(&(ms)->ms_rt_lock) 248 #define MESH_RT_LOCK_INIT(ms, name) \ 249 mtx_init(&(ms)->ms_rt_lock, name, "802.11s routing table", MTX_DEF) 250 #define MESH_RT_LOCK_DESTROY(ms) \ 251 mtx_destroy(&(ms)->ms_rt_lock) 252 253 /* 254 * Node reference counting definitions. 255 * 256 * ieee80211_node_initref initialize the reference count to 1 257 * ieee80211_node_incref add a reference 258 * ieee80211_node_decref remove a reference 259 * ieee80211_node_dectestref remove a reference and return 1 if this 260 * is the last reference, otherwise 0 261 * ieee80211_node_refcnt reference count for printing (only) 262 */ 263 #include <machine/atomic.h> 264 265 struct ieee80211vap; 266 int ieee80211_com_vincref(struct ieee80211vap *); 267 void ieee80211_com_vdecref(struct ieee80211vap *); 268 void ieee80211_com_vdetach(struct ieee80211vap *); 269 270 #define ieee80211_node_initref(_ni) \ 271 do { ((_ni)->ni_refcnt = 1); } while (0) 272 #define ieee80211_node_incref(_ni) \ 273 atomic_add_int(&(_ni)->ni_refcnt, 1) 274 #define ieee80211_node_decref(_ni) \ 275 atomic_subtract_int(&(_ni)->ni_refcnt, 1) 276 struct ieee80211_node; 277 int ieee80211_node_dectestref(struct ieee80211_node *ni); 278 #define ieee80211_node_refcnt(_ni) (_ni)->ni_refcnt 279 280 struct ifqueue; 281 void ieee80211_drain_ifq(struct ifqueue *); 282 void ieee80211_flush_ifq(struct ifqueue *, struct ieee80211vap *); 283 284 void ieee80211_vap_destroy(struct ieee80211vap *); 285 const char * ieee80211_get_vap_ifname(struct ieee80211vap *); 286 287 #define IFNET_IS_UP_RUNNING(_ifp) \ 288 (((_ifp)->if_flags & IFF_UP) && \ 289 ((_ifp)->if_drv_flags & IFF_DRV_RUNNING)) 290 291 #define msecs_to_ticks(ms) MSEC_2_TICKS(ms) 292 #define ticks_to_msecs(t) TICKS_2_MSEC(t) 293 #define ticks_to_secs(t) ((t) / hz) 294 295 #define ieee80211_time_after(a,b) ((int)(b) - (int)(a) < 0) 296 #define ieee80211_time_before(a,b) ieee80211_time_after(b,a) 297 #define ieee80211_time_after_eq(a,b) ((int)(a) - (int)(b) >= 0) 298 #define ieee80211_time_before_eq(a,b) ieee80211_time_after_eq(b,a) 299 300 struct mbuf *ieee80211_getmgtframe(uint8_t **frm, int headroom, int pktlen); 301 302 /* tx path usage */ 303 #define M_ENCAP M_PROTO1 /* 802.11 encap done */ 304 #define M_EAPOL M_PROTO3 /* PAE/EAPOL frame */ 305 #define M_PWR_SAV M_PROTO4 /* bypass PS handling */ 306 #define M_MORE_DATA M_PROTO5 /* more data frames to follow */ 307 #define M_FF M_PROTO6 /* fast frame / A-MSDU */ 308 #define M_TXCB M_PROTO7 /* do tx complete callback */ 309 #define M_AMPDU_MPDU M_PROTO8 /* ok for A-MPDU aggregation */ 310 #define M_FRAG M_PROTO9 /* frame fragmentation */ 311 #define M_FIRSTFRAG M_PROTO10 /* first frame fragment */ 312 #define M_LASTFRAG M_PROTO11 /* last frame fragment */ 313 314 #define M_80211_TX \ 315 (M_ENCAP|M_EAPOL|M_PWR_SAV|M_MORE_DATA|M_FF|M_TXCB| \ 316 M_AMPDU_MPDU|M_FRAG|M_FIRSTFRAG|M_LASTFRAG) 317 318 /* rx path usage */ 319 #define M_AMPDU M_PROTO1 /* A-MPDU subframe */ 320 #define M_WEP M_PROTO2 /* WEP done by hardware */ 321 #if 0 322 #define M_AMPDU_MPDU M_PROTO8 /* A-MPDU re-order done */ 323 #endif 324 #define M_80211_RX (M_AMPDU|M_WEP|M_AMPDU_MPDU) 325 326 #define IEEE80211_MBUF_TX_FLAG_BITS \ 327 M_FLAG_BITS \ 328 "\15M_ENCAP\17M_EAPOL\20M_PWR_SAV\21M_MORE_DATA\22M_FF\23M_TXCB" \ 329 "\24M_AMPDU_MPDU\25M_FRAG\26M_FIRSTFRAG\27M_LASTFRAG" 330 331 #define IEEE80211_MBUF_RX_FLAG_BITS \ 332 M_FLAG_BITS \ 333 "\15M_AMPDU\16M_WEP\24M_AMPDU_MPDU" 334 335 /* 336 * Store WME access control bits in the vlan tag. 337 * This is safe since it's done after the packet is classified 338 * (where we use any previous tag) and because it's passed 339 * directly in to the driver and there's no chance someone 340 * else will clobber them on us. 341 */ 342 #define M_WME_SETAC(m, ac) \ 343 ((m)->m_pkthdr.ether_vtag = (ac)) 344 #define M_WME_GETAC(m) ((m)->m_pkthdr.ether_vtag) 345 346 /* 347 * Mbufs on the power save queue are tagged with an age and 348 * timed out. We reuse the hardware checksum field in the 349 * mbuf packet header to store this data. 350 */ 351 #define M_AGE_SET(m,v) (m->m_pkthdr.csum_data = v) 352 #define M_AGE_GET(m) (m->m_pkthdr.csum_data) 353 #define M_AGE_SUB(m,adj) (m->m_pkthdr.csum_data -= adj) 354 355 /* 356 * Store the sequence number. 357 */ 358 #define M_SEQNO_SET(m, seqno) \ 359 ((m)->m_pkthdr.tso_segsz = (seqno)) 360 #define M_SEQNO_GET(m) ((m)->m_pkthdr.tso_segsz) 361 362 #define MTAG_ABI_NET80211 1132948340 /* net80211 ABI */ 363 364 struct ieee80211_cb { 365 void (*func)(struct ieee80211_node *, void *, int status); 366 void *arg; 367 }; 368 #define NET80211_TAG_CALLBACK 0 /* xmit complete callback */ 369 #define NET80211_TAG_XMIT_PARAMS 1 370 /* See below; this is after the bpf_params definition */ 371 #define NET80211_TAG_RECV_PARAMS 2 372 #define NET80211_TAG_TOA_PARAMS 3 373 374 int ieee80211_add_callback(struct mbuf *m, 375 void (*func)(struct ieee80211_node *, void *, int), void *arg); 376 void ieee80211_process_callback(struct ieee80211_node *, struct mbuf *, int); 377 378 void get_random_bytes(void *, size_t); 379 380 struct ieee80211com; 381 382 int ieee80211_parent_xmitpkt(struct ieee80211com *ic, struct mbuf *m); 383 int ieee80211_vap_xmitpkt(struct ieee80211vap *vap, struct mbuf *m); 384 385 void ieee80211_sysctl_attach(struct ieee80211com *); 386 void ieee80211_sysctl_detach(struct ieee80211com *); 387 void ieee80211_sysctl_vattach(struct ieee80211vap *); 388 void ieee80211_sysctl_vdetach(struct ieee80211vap *); 389 390 void ieee80211_load_module(const char *); 391 392 /* 393 * A "policy module" is an adjunct module to net80211 that provides 394 * functionality that typically includes policy decisions. This 395 * modularity enables extensibility and vendor-supplied functionality. 396 */ 397 #define _IEEE80211_POLICY_MODULE(policy, name, version, load, unload) \ 398 static void ieee80211_##policy##_##name##_load() { load; } \ 399 static void ieee80211_##policy##_##name##_unload() { unload; } \ 400 SYSINIT(ieee80211_##policy##_##name, SI_SUB_DRIVERS, SI_ORDER_ANY, \ 401 ieee80211_##policy##_##name##_load, NULL); \ 402 SYSUNINIT(ieee80211_##policy##_##name, SI_SUB_DRIVERS, SI_ORDER_ANY, \ 403 ieee80211_##policy##_##name##_unload, NULL) 404 405 /* 406 * Authenticator modules handle 802.1x/WPA authentication. 407 */ 408 #define IEEE80211_AUTH_MODULE(name, version) 409 #define IEEE80211_AUTH_ALG(name, alg, v) \ 410 _IEEE80211_POLICY_MODULE(auth, alg, v, \ 411 ieee80211_authenticator_register(alg, &v), \ 412 ieee80211_authenticator_unregister(alg)) 413 414 /* 415 * Crypto modules implement cipher support. 416 */ 417 #define IEEE80211_CRYPTO_MODULE(name, version) \ 418 _IEEE80211_POLICY_MODULE(crypto, name, version, \ 419 ieee80211_crypto_register(&name), \ 420 ieee80211_crypto_unregister(&name)) 421 422 /* 423 * Scanner modules provide scanning policy. 424 */ 425 #define IEEE80211_SCANNER_MODULE(name, version) 426 #define IEEE80211_SCANNER_ALG(name, alg, v) \ 427 _IEEE80211_POLICY_MODULE(scan, alg, v, \ 428 ieee80211_scanner_register(alg, &v), \ 429 ieee80211_scanner_unregister(alg, &v)) 430 431 /* 432 * Rate control modules provide tx rate control support. 433 */ 434 #define IEEE80211_RATECTL_MODULE(alg, version) 435 #define IEEE80211_RATECTL_ALG(name, alg, v) \ 436 _IEEE80211_POLICY_MODULE(ratectl, alg, v, \ 437 ieee80211_ratectl_register(alg, &v), \ 438 ieee80211_ratectl_unregister(alg)) 439 440 441 struct ieee80211req; 442 typedef int ieee80211_ioctl_getfunc(struct ieee80211vap *, 443 struct ieee80211req *); 444 SET_DECLARE(ieee80211_ioctl_getset, ieee80211_ioctl_getfunc); 445 #define IEEE80211_IOCTL_GET(_name, _get) TEXT_SET(ieee80211_ioctl_getset, _get) 446 447 typedef int ieee80211_ioctl_setfunc(struct ieee80211vap *, 448 struct ieee80211req *); 449 SET_DECLARE(ieee80211_ioctl_setset, ieee80211_ioctl_setfunc); 450 #define IEEE80211_IOCTL_SET(_name, _set) TEXT_SET(ieee80211_ioctl_setset, _set) 451 452 #ifdef DEBUGNET 453 typedef void debugnet80211_init_t(struct ieee80211com *, int *nrxr, int *ncl, 454 int *clsize); 455 typedef void debugnet80211_event_t(struct ieee80211com *, enum debugnet_ev); 456 typedef int debugnet80211_poll_t(struct ieee80211com *, int); 457 458 struct debugnet80211_methods { 459 debugnet80211_init_t *dn8_init; 460 debugnet80211_event_t *dn8_event; 461 debugnet80211_poll_t *dn8_poll; 462 }; 463 464 #define DEBUGNET80211_DEFINE(driver) \ 465 static debugnet80211_init_t driver##_debugnet80211_init; \ 466 static debugnet80211_event_t driver##_debugnet80211_event; \ 467 static debugnet80211_poll_t driver##_debugnet80211_poll; \ 468 \ 469 static struct debugnet80211_methods driver##_debugnet80211_methods = { \ 470 .dn8_init = driver##_debugnet80211_init, \ 471 .dn8_event = driver##_debugnet80211_event, \ 472 .dn8_poll = driver##_debugnet80211_poll, \ 473 } 474 #define DEBUGNET80211_SET(ic, driver) \ 475 (ic)->ic_debugnet_meth = &driver##_debugnet80211_methods 476 #else 477 #define DEBUGNET80211_DEFINE(driver) 478 #define DEBUGNET80211_SET(ic, driver) 479 #endif /* DEBUGNET */ 480 481 /* 482 * Structure prepended to raw packets sent through the bpf 483 * interface when set to DLT_IEEE802_11_RADIO. This allows 484 * user applications to specify pretty much everything in 485 * an Atheros tx descriptor. XXX need to generalize. 486 * 487 * XXX cannot be more than 14 bytes as it is copied to a sockaddr's 488 * XXX sa_data area. 489 */ 490 struct ieee80211_bpf_params { 491 uint8_t ibp_vers; /* version */ 492 #define IEEE80211_BPF_VERSION 0 493 uint8_t ibp_len; /* header length in bytes */ 494 uint8_t ibp_flags; 495 #define IEEE80211_BPF_SHORTPRE 0x01 /* tx with short preamble */ 496 #define IEEE80211_BPF_NOACK 0x02 /* tx with no ack */ 497 #define IEEE80211_BPF_CRYPTO 0x04 /* tx with h/w encryption */ 498 #define IEEE80211_BPF_FCS 0x10 /* frame incldues FCS */ 499 #define IEEE80211_BPF_DATAPAD 0x20 /* frame includes data padding */ 500 #define IEEE80211_BPF_RTS 0x40 /* tx with RTS/CTS */ 501 #define IEEE80211_BPF_CTS 0x80 /* tx with CTS only */ 502 uint8_t ibp_pri; /* WME/WMM AC+tx antenna */ 503 uint8_t ibp_try0; /* series 1 try count */ 504 uint8_t ibp_rate0; /* series 1 IEEE tx rate */ 505 uint8_t ibp_power; /* tx power (device units) */ 506 uint8_t ibp_ctsrate; /* IEEE tx rate for CTS */ 507 uint8_t ibp_try1; /* series 2 try count */ 508 uint8_t ibp_rate1; /* series 2 IEEE tx rate */ 509 uint8_t ibp_try2; /* series 3 try count */ 510 uint8_t ibp_rate2; /* series 3 IEEE tx rate */ 511 uint8_t ibp_try3; /* series 4 try count */ 512 uint8_t ibp_rate3; /* series 4 IEEE tx rate */ 513 }; 514 515 int ieee80211_add_xmit_params(struct mbuf *m, const struct ieee80211_bpf_params *params); 516 int ieee80211_get_xmit_params(struct mbuf *m, struct ieee80211_bpf_params *params); 517 518 struct ieee80211_tx_params { 519 struct ieee80211_bpf_params params; 520 }; 521 522 struct ieee80211_rx_params; 523 struct ieee80211_rx_stats; 524 525 int ieee80211_add_rx_params(struct mbuf *m, const struct ieee80211_rx_stats *rxs); 526 int ieee80211_get_rx_params(struct mbuf *m, struct ieee80211_rx_stats *rxs); 527 const struct ieee80211_rx_stats * ieee80211_get_rx_params_ptr(struct mbuf *m); 528 529 struct ieee80211_toa_params { 530 int request_id; 531 }; 532 int ieee80211_add_toa_params(struct mbuf *m, const struct ieee80211_toa_params *p); 533 int ieee80211_get_toa_params(struct mbuf *m, struct ieee80211_toa_params *p); 534 535 #ifdef __cplusplus 536 } 537 #endif 538 #endif /* _KERNEL */ 539 540 #define IEEE80211_MALLOC malloc 541 #define IEEE80211_FREE free 542 543 /* XXX TODO: get rid of WAITOK, fix all the users of it? */ 544 #define IEEE80211_M_NOWAIT M_NOWAIT 545 #define IEEE80211_M_WAITOK M_WAITOK 546 #define IEEE80211_M_ZERO M_ZERO 547 548 #endif /* _FBSD_COMPAT_NET80211_IEEE80211_HAIKU_H_ */ 549