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