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>
43extern "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 */
55typedef 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 */
79typedef 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 */
100typedef 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 */
119typedef 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 */
145typedef 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 */
165typedef 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 */
190typedef 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 */
200typedef 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
207typedef 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 */
217typedef 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
226typedef 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)
253struct ieee80211_node;
254int	ieee80211_node_dectestref(struct ieee80211_node *ni);
255#define	ieee80211_node_refcnt(_ni)	(_ni)->ni_refcnt
256
257struct ifqueue;
258struct ieee80211vap;
259void	ieee80211_drain_ifq(struct ifqueue *);
260void	ieee80211_flush_ifq(struct ifqueue *, struct ieee80211vap *);
261
262void	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/* XXX TODO: cap these at 1, as hz may not be 1000 */
269#define	msecs_to_ticks(ms)	(((ms)*hz)/1000)
270#define	ticks_to_msecs(t)	(1000*(t) / hz)
271#define	ticks_to_secs(t)	((t) / hz)
272
273#define ieee80211_time_after(a,b) 	((long)(b) - (long)(a) < 0)
274#define ieee80211_time_before(a,b)	ieee80211_time_after(b,a)
275#define ieee80211_time_after_eq(a,b)	((long)(a) - (long)(b) >= 0)
276#define ieee80211_time_before_eq(a,b)	ieee80211_time_after_eq(b,a)
277
278struct mbuf *ieee80211_getmgtframe(uint8_t **frm, int headroom, int pktlen);
279
280/* tx path usage */
281#define	M_ENCAP		M_PROTO1		/* 802.11 encap done */
282#define	M_EAPOL		M_PROTO3		/* PAE/EAPOL frame */
283#define	M_PWR_SAV	M_PROTO4		/* bypass PS handling */
284#define	M_MORE_DATA	M_PROTO5		/* more data frames to follow */
285#define	M_FF		M_PROTO6		/* fast frame / A-MSDU */
286#define	M_TXCB		M_PROTO7		/* do tx complete callback */
287#define	M_AMPDU_MPDU	M_PROTO8		/* ok for A-MPDU aggregation */
288#define	M_FRAG		M_PROTO9		/* frame fragmentation */
289#define	M_FIRSTFRAG	M_PROTO10		/* first frame fragment */
290#define	M_LASTFRAG	M_PROTO11		/* last frame fragment */
291
292#define	M_80211_TX \
293	(M_ENCAP|M_EAPOL|M_PWR_SAV|M_MORE_DATA|M_FF|M_TXCB| \
294	 M_AMPDU_MPDU|M_FRAG|M_FIRSTFRAG|M_LASTFRAG)
295
296/* rx path usage */
297#define	M_AMPDU		M_PROTO1		/* A-MPDU subframe */
298#define	M_WEP		M_PROTO2		/* WEP done by hardware */
299#if 0
300#define	M_AMPDU_MPDU	M_PROTO8		/* A-MPDU re-order done */
301#endif
302#define	M_80211_RX	(M_AMPDU|M_WEP|M_AMPDU_MPDU)
303
304#define	IEEE80211_MBUF_TX_FLAG_BITS \
305	M_FLAG_BITS \
306	"\15M_ENCAP\17M_EAPOL\20M_PWR_SAV\21M_MORE_DATA\22M_FF\23M_TXCB" \
307	"\24M_AMPDU_MPDU\25M_FRAG\26M_FIRSTFRAG\27M_LASTFRAG"
308
309#define	IEEE80211_MBUF_RX_FLAG_BITS \
310	M_FLAG_BITS \
311	"\15M_AMPDU\16M_WEP\24M_AMPDU_MPDU"
312
313/*
314 * Store WME access control bits in the vlan tag.
315 * This is safe since it's done after the packet is classified
316 * (where we use any previous tag) and because it's passed
317 * directly in to the driver and there's no chance someone
318 * else will clobber them on us.
319 */
320#define	M_WME_SETAC(m, ac) \
321	((m)->m_pkthdr.ether_vtag = (ac))
322#define	M_WME_GETAC(m)	((m)->m_pkthdr.ether_vtag)
323
324/*
325 * Mbufs on the power save queue are tagged with an age and
326 * timed out.  We reuse the hardware checksum field in the
327 * mbuf packet header to store this data.
328 */
329#define	M_AGE_SET(m,v)		(m->m_pkthdr.csum_data = v)
330#define	M_AGE_GET(m)		(m->m_pkthdr.csum_data)
331#define	M_AGE_SUB(m,adj)	(m->m_pkthdr.csum_data -= adj)
332
333/*
334 * Store the sequence number.
335 */
336#define	M_SEQNO_SET(m, seqno) \
337	((m)->m_pkthdr.tso_segsz = (seqno))
338#define	M_SEQNO_GET(m)	((m)->m_pkthdr.tso_segsz)
339
340#define	MTAG_ABI_NET80211	1132948340	/* net80211 ABI */
341
342struct ieee80211_cb {
343	void	(*func)(struct ieee80211_node *, void *, int status);
344	void	*arg;
345};
346#define	NET80211_TAG_CALLBACK		0 /* xmit complete callback */
347#define	NET80211_TAG_XMIT_PARAMS	1
348	/* See below; this is after the bpf_params definition */
349#define	NET80211_TAG_RECV_PARAMS	2
350#define	NET80211_TAG_TOA_PARAMS		3
351
352int	ieee80211_add_callback(struct mbuf *m,
353		void (*func)(struct ieee80211_node *, void *, int), void *arg);
354void	ieee80211_process_callback(struct ieee80211_node *, struct mbuf *, int);
355
356void	get_random_bytes(void *, size_t);
357
358struct ieee80211com;
359
360int ieee80211_parent_xmitpkt(struct ieee80211com *ic, struct mbuf *m);
361int ieee80211_vap_xmitpkt(struct ieee80211vap *vap, struct mbuf *m);
362
363void	ieee80211_sysctl_attach(struct ieee80211com *);
364void	ieee80211_sysctl_detach(struct ieee80211com *);
365void	ieee80211_sysctl_vattach(struct ieee80211vap *);
366void	ieee80211_sysctl_vdetach(struct ieee80211vap *);
367
368void	ieee80211_load_module(const char *);
369
370/*
371 * A "policy module" is an adjunct module to net80211 that provides
372 * functionality that typically includes policy decisions.  This
373 * modularity enables extensibility and vendor-supplied functionality.
374 */
375#define	_IEEE80211_POLICY_MODULE(policy, name, version, load, unload) \
376	static void ieee80211_##policy##_##name##_load() { load; } \
377	static void ieee80211_##policy##_##name##_unload() { unload; } \
378	SYSINIT(ieee80211_##policy##_##name, SI_SUB_DRIVERS, SI_ORDER_ANY, \
379		ieee80211_##policy##_##name##_load, NULL); \
380	SYSUNINIT(ieee80211_##policy##_##name, SI_SUB_DRIVERS, SI_ORDER_ANY, \
381		ieee80211_##policy##_##name##_unload, NULL)
382
383/*
384 * Authenticator modules handle 802.1x/WPA authentication.
385 */
386#define	IEEE80211_AUTH_MODULE(name, version)
387#define	IEEE80211_AUTH_ALG(name, alg, v) \
388	_IEEE80211_POLICY_MODULE(auth, alg, v, \
389		ieee80211_authenticator_register(alg, &v), \
390		ieee80211_authenticator_unregister(alg))
391
392/*
393 * Crypto modules implement cipher support.
394 */
395#define IEEE80211_CRYPTO_MODULE(name, version) \
396	_IEEE80211_POLICY_MODULE(crypto, name, version, \
397		ieee80211_crypto_register(&name), \
398		ieee80211_crypto_unregister(&name))
399
400/*
401 * Scanner modules provide scanning policy.
402 */
403#define	IEEE80211_SCANNER_MODULE(name, version)
404#define	IEEE80211_SCANNER_ALG(name, alg, v) \
405	_IEEE80211_POLICY_MODULE(scan, alg, v, \
406		ieee80211_scanner_register(alg, &v), \
407		ieee80211_scanner_unregister(alg, &v))
408
409/*
410 * Rate control modules provide tx rate control support.
411 */
412#define	IEEE80211_RATECTL_MODULE(alg, version)
413#define IEEE80211_RATECTL_ALG(name, alg, v) \
414	_IEEE80211_POLICY_MODULE(ratectl, alg, v, \
415		ieee80211_ratectl_register(alg, &v), \
416		ieee80211_ratectl_unregister(alg))
417
418
419struct ieee80211req;
420typedef int ieee80211_ioctl_getfunc(struct ieee80211vap *,
421    struct ieee80211req *);
422SET_DECLARE(ieee80211_ioctl_getset, ieee80211_ioctl_getfunc);
423#define	IEEE80211_IOCTL_GET(_name, _get) TEXT_SET(ieee80211_ioctl_getset, _get)
424
425typedef int ieee80211_ioctl_setfunc(struct ieee80211vap *,
426    struct ieee80211req *);
427SET_DECLARE(ieee80211_ioctl_setset, ieee80211_ioctl_setfunc);
428#define	IEEE80211_IOCTL_SET(_name, _set) TEXT_SET(ieee80211_ioctl_setset, _set)
429
430/*
431 * Structure prepended to raw packets sent through the bpf
432 * interface when set to DLT_IEEE802_11_RADIO.  This allows
433 * user applications to specify pretty much everything in
434 * an Atheros tx descriptor.  XXX need to generalize.
435 *
436 * XXX cannot be more than 14 bytes as it is copied to a sockaddr's
437 * XXX sa_data area.
438 */
439struct ieee80211_bpf_params {
440	uint8_t		ibp_vers;	/* version */
441#define	IEEE80211_BPF_VERSION	0
442	uint8_t		ibp_len;	/* header length in bytes */
443	uint8_t		ibp_flags;
444#define	IEEE80211_BPF_SHORTPRE	0x01	/* tx with short preamble */
445#define	IEEE80211_BPF_NOACK	0x02	/* tx with no ack */
446#define	IEEE80211_BPF_CRYPTO	0x04	/* tx with h/w encryption */
447#define	IEEE80211_BPF_FCS	0x10	/* frame incldues FCS */
448#define	IEEE80211_BPF_DATAPAD	0x20	/* frame includes data padding */
449#define	IEEE80211_BPF_RTS	0x40	/* tx with RTS/CTS */
450#define	IEEE80211_BPF_CTS	0x80	/* tx with CTS only */
451	uint8_t		ibp_pri;	/* WME/WMM AC+tx antenna */
452	uint8_t		ibp_try0;	/* series 1 try count */
453	uint8_t		ibp_rate0;	/* series 1 IEEE tx rate */
454	uint8_t		ibp_power;	/* tx power (device units) */
455	uint8_t		ibp_ctsrate;	/* IEEE tx rate for CTS */
456	uint8_t		ibp_try1;	/* series 2 try count */
457	uint8_t		ibp_rate1;	/* series 2 IEEE tx rate */
458	uint8_t		ibp_try2;	/* series 3 try count */
459	uint8_t		ibp_rate2;	/* series 3 IEEE tx rate */
460	uint8_t		ibp_try3;	/* series 4 try count */
461	uint8_t		ibp_rate3;	/* series 4 IEEE tx rate */
462};
463
464int ieee80211_add_xmit_params(struct mbuf *m, const struct ieee80211_bpf_params *params);
465int ieee80211_get_xmit_params(struct mbuf *m, struct ieee80211_bpf_params *params);
466
467struct ieee80211_tx_params {
468	struct ieee80211_bpf_params params;
469};
470
471struct ieee80211_rx_params;
472struct ieee80211_rx_stats;
473
474int ieee80211_add_rx_params(struct mbuf *m, const struct ieee80211_rx_stats *rxs);
475int ieee80211_get_rx_params(struct mbuf *m, struct ieee80211_rx_stats *rxs);
476const struct ieee80211_rx_stats * ieee80211_get_rx_params_ptr(struct mbuf *m);
477
478struct ieee80211_toa_params {
479	int request_id;
480};
481int	ieee80211_add_toa_params(struct mbuf *m, const struct ieee80211_toa_params *p);
482int	ieee80211_get_toa_params(struct mbuf *m, struct ieee80211_toa_params *p);
483
484#ifdef __cplusplus
485}
486#endif
487#endif /* _KERNEL */
488
489#define	IEEE80211_MALLOC	malloc
490#define	IEEE80211_FREE		free
491
492/* XXX TODO: get rid of WAITOK, fix all the users of it? */
493#define	IEEE80211_M_NOWAIT	M_NOWAIT
494#define	IEEE80211_M_WAITOK	M_WAITOK
495#define	IEEE80211_M_ZERO	M_ZERO
496
497#endif /* _FBSD_COMPAT_NET80211_IEEE80211_HAIKU_H_ */
498