xref: /freebsd/sys/compat/linuxkpi/common/src/linux_80211.h (revision cc145f5d8425f19fbe07110fed89ecde8d70ce78)
1 /*-
2  * Copyright (c) 2020-2026 The FreeBSD Foundation
3  * Copyright (c) 2020-2025 Bjoern A. Zeeb
4  *
5  * This software was developed by Björn Zeeb under sponsorship from
6  * the FreeBSD Foundation.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  */
29 
30 /*
31  * Public functions are called linuxkpi_*().
32  * Internal (static) functions are called lkpi_*().
33  *
34  * The internal structures holding metadata over public structures are also
35  * called lkpi_xxx (usually with a member at the end called xxx).
36  * Note: we do not replicate the structure names but the general variable names
37  * for these (e.g., struct hw -> struct lkpi_hw, struct sta -> struct lkpi_sta).
38  * There are macros to access one from the other.
39  * We call the internal versions lxxx (e.g., hw -> lhw, sta -> lsta).
40  */
41 
42 #ifndef _LKPI_SRC_LINUX_80211_H
43 #define _LKPI_SRC_LINUX_80211_H
44 
45 #include "opt_wlan.h"
46 
47 #include <linux/skbuff.h>
48 #include <net/mac80211.h>
49 
50 #if defined(IEEE80211_DEBUG) && !defined(LINUXKPI_DEBUG_80211)
51 #define	LINUXKPI_DEBUG_80211
52 #endif
53 
54 /* #define	LINUXKPI_DEBUG_80211 */
55 
56 #ifndef	D80211_TODO
57 #define	D80211_TODO		0x00000001
58 #endif
59 #ifndef D80211_IMPROVE
60 #define	D80211_IMPROVE		0x00000002
61 #endif
62 #define	D80211_IMPROVE_TXQ	0x00000004
63 #define	D80211_CHANDEF		0x00000008
64 #define	D80211_TRACE		0x00000010
65 #define	D80211_TRACEOK		0x00000020
66 #define	D80211_SCAN		0x00000040
67 #define	D80211_SCAN_BEACON	0x00000080
68 #define	D80211_TRACE_TX		0x00000100
69 #define	D80211_TRACE_TX_DUMP	0x00000200
70 #define	D80211_TRACE_RX		0x00001000
71 #define	D80211_TRACE_RX_DUMP	0x00002000
72 #define	D80211_TRACE_RX_BEACONS	0x00004000
73 #define	D80211_TRACEX		(D80211_TRACE_TX|D80211_TRACE_RX)
74 #define	D80211_TRACEX_DUMP	(D80211_TRACE_TX_DUMP|D80211_TRACE_RX_DUMP)
75 #define	D80211_TRACE_STA	0x00010000
76 #define	D80211_TRACE_HW_CRYPTO	0x00020000
77 #define	D80211_TRACE_MO		0x00100000
78 #define	D80211_TRACE_MODE	0x0f000000
79 #define	D80211_TRACE_MODE_HT	0x01000000
80 #define	D80211_TRACE_MODE_VHT	0x02000000
81 #define	D80211_TRACE_MODE_HE	0x04000000
82 #define	D80211_TRACE_MODE_EHT	0x08000000
83 
84 #ifdef	LINUXKPI_DEBUG_80211
85 #define	TRACE_SCAN(ic, fmt, ...)					\
86     if (linuxkpi_debug_80211 & D80211_SCAN)				\
87 	printf("%s:%d: %s SCAN " fmt "\n",				\
88 	    __func__, __LINE__, ic->ic_name, ##__VA_ARGS__)
89 #define	TRACE_SCAN_BEACON(ic, fmt, ...)					\
90     if (linuxkpi_debug_80211 & D80211_SCAN_BEACON)			\
91 	printf("%s:%d: %s SCAN " fmt "\n",				\
92 	    __func__, __LINE__, ic->ic_name, ##__VA_ARGS__)
93 #else
94 #define	TRACE_SCAN(...)		do {} while (0)
95 #define	TRACE_SCAN_BEACON(...)	do {} while (0)
96 #endif
97 
98 #define	IMPROVE_TXQ(...)						\
99     if (linuxkpi_debug_80211 & D80211_IMPROVE_TXQ)			\
100 	printf("%s:%d: XXX LKPI80211 IMPROVE_TXQ\n", __func__, __LINE__)
101 
102 #define	IMPROVE_HT(fmt, ...)						\
103     if (linuxkpi_debug_80211 & D80211_TRACE_MODE_HT)			\
104 	printf("%s:%d: XXX LKPI80211 IMPROVE_HT " fmt "\n",		\
105 	    __func__, __LINE__, ##__VA_ARGS__);
106 
107 #define	MTAG_ABI_LKPI80211	1707696513	/* LinuxKPI 802.11 KBI */
108 
109 #ifdef LKPI_80211_USE_MTAG
110 /*
111  * Deferred RX path.
112  * We need to pass *ni along (and possibly more in the future so
113  * we use a struct right from the start.
114  */
115 #define	LKPI80211_TAG_RXNI	0		/* deferred RX path */
116 struct lkpi_80211_tag_rxni {
117 	struct ieee80211_node	*ni;		/* MUST hold a reference to it. */
118 };
119 #endif
120 
121 struct lkpi_radiotap_tx_hdr {
122 	struct ieee80211_radiotap_header wt_ihdr;
123 	uint8_t		wt_flags;
124 	uint8_t		wt_rate;
125 	uint16_t	wt_chan_freq;
126 	uint16_t	wt_chan_flags;
127 } __packed;
128 #define	LKPI_RTAP_TX_FLAGS_PRESENT					\
129 	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
130 	 (1 << IEEE80211_RADIOTAP_RATE) |				\
131 	 (1 << IEEE80211_RADIOTAP_CHANNEL))
132 
133 struct lkpi_radiotap_rx_hdr {
134 	struct ieee80211_radiotap_header wr_ihdr;
135 	uint64_t	wr_tsft;
136 	uint8_t		wr_flags;
137 	uint8_t		wr_rate;
138 	uint16_t	wr_chan_freq;
139 	uint16_t	wr_chan_flags;
140 	int8_t		wr_dbm_antsignal;
141 	int8_t		wr_dbm_antnoise;
142 } __packed __aligned(8);
143 #define	LKPI_RTAP_RX_FLAGS_PRESENT					\
144 	((1 << IEEE80211_RADIOTAP_TSFT) |				\
145 	 (1 << IEEE80211_RADIOTAP_FLAGS) |				\
146 	 (1 << IEEE80211_RADIOTAP_RATE) |				\
147 	 (1 << IEEE80211_RADIOTAP_CHANNEL) |				\
148 	 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) |			\
149 	 (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE))
150 
151 struct lkpi_hw;
152 
153 struct lkpi_txq {
154 	TAILQ_ENTRY(lkpi_txq)	txq_entry;
155 
156 	struct mtx		ltxq_mtx;
157 	bool			seen_dequeue;
158 	bool			stopped;
159 	uint32_t		txq_generation;
160 	struct sk_buff_head	skbq;
161 	uint64_t		frms_enqueued;
162 	uint64_t		frms_dequeued;
163 	uint64_t		frms_tx;
164 
165 	/* Must be last! */
166 	struct ieee80211_txq	txq __aligned(CACHE_LINE_SIZE);
167 };
168 #define	TXQ_TO_LTXQ(_txq)	container_of(_txq, struct lkpi_txq, txq)
169 
170 
171 struct lkpi_sta {
172 	struct list_head	lsta_list;
173 	struct ieee80211_node	*ni;
174 	struct ieee80211_hw	*hw;		/* back pointer f. locking. */
175 
176 	/* Deferred TX path. */
177 	/* Eventually we might want to migrate this into net80211 entirely. */
178 	/* XXX-BZ can we use sta->txq[] instead directly? */
179 	struct task		txq_task;
180 	struct mbufq		txq;
181 	struct mtx		txq_mtx;
182 
183 	struct ieee80211_key_conf *kc[IEEE80211_WEP_NKID];
184 	enum ieee80211_sta_state state;
185 	bool			txq_ready;			/* Can we run the taskq? */
186 	bool			added_to_drv;			/* Driver knows; i.e. we called ...(). */
187 	bool			in_mgd;				/* XXX-BZ should this be per-vif? */
188 
189 	struct station_info	sinfo;				/* statistics */
190 	uint64_t		frms_tx;			/* (*tx) */
191 
192 	/* Must be last! */
193 	struct ieee80211_sta	sta __aligned(CACHE_LINE_SIZE);
194 };
195 #define	STA_TO_LSTA(_sta)	container_of(_sta, struct lkpi_sta, sta)
196 #define	LSTA_TO_STA(_lsta)	(&(_lsta)->sta)
197 
198 /* Either protected by wiphy lock or rcu for the list. */
199 struct lkpi_vif {
200         TAILQ_ENTRY(lkpi_vif)	lvif_entry;
201 	struct ieee80211vap	iv_vap;
202 	eventhandler_tag	lvif_ifllevent;
203 
204 	struct sysctl_ctx_list	sysctl_ctx;
205 
206 	struct mtx		mtx;
207 	struct wireless_dev	wdev;
208 
209 	/* Other local stuff. */
210 	int			(*iv_newstate)(struct ieee80211vap *,
211 				    enum ieee80211_state, int);
212 	struct ieee80211_node *	(*iv_update_bss)(struct ieee80211vap *,
213 				    struct ieee80211_node *);
214 	void			(*iv_recv_mgmt)(struct ieee80211_node *,
215 				    struct mbuf *, int,
216 				    const struct ieee80211_rx_stats *,
217 				    int, int);
218 	struct task		sw_scan_task;
219 
220 	struct list_head	lsta_list;
221 
222 	struct lkpi_sta		*lvif_bss;
223 
224 	struct ieee80211_node	*key_update_iv_bss;
225 	int			ic_unlocked;			/* Count of ic unlocks pending (*mo_set_key) */
226 	int			nt_unlocked;			/* Count of nt unlocks pending (*mo_set_key) */
227 	int			beacons;			/* # of beacons since assoc */
228 	bool			lvif_bss_synched;
229 	bool			added_to_drv;			/* Driver knows; i.e. we called add_interface(). */
230 
231 	bool			hw_queue_stopped[IEEE80211_NUM_ACS];
232 
233 	/* Must be last! */
234 	struct ieee80211_vif	vif __aligned(CACHE_LINE_SIZE);
235 };
236 #define	VAP_TO_LVIF(_vap)	container_of(_vap, struct lkpi_vif, iv_vap)
237 #define	LVIF_TO_VAP(_lvif)	(&(_lvif)->iv_vap)
238 #define	VIF_TO_LVIF(_vif)	container_of(_vif, struct lkpi_vif, vif)
239 #define	LVIF_TO_VIF(_lvif)	(&(_lvif)->vif)
240 
241 
242 struct lkpi_hw {	/* name it mac80211_sc? */
243 	const struct ieee80211_ops	*ops;
244 	struct ieee80211_scan_request	*hw_req;
245 	struct workqueue_struct		*workq;
246 
247 	/* FreeBSD specific compat. */
248 	/* Linux device is in hw.wiphy->dev after SET_IEEE80211_DEV(). */
249 	struct ieee80211com		*ic;
250 	struct lkpi_radiotap_tx_hdr	rtap_tx;
251 	struct lkpi_radiotap_rx_hdr	rtap_rx;
252 
253 	TAILQ_HEAD(, lkpi_vif)		lvif_head;
254 	struct sx			lvif_sx;
255 
256 	struct list_head		lchanctx_list;
257 	struct list_head		lchanctx_list_reserved;
258 	struct netdev_hw_addr_list	mc_list;
259 	unsigned int			mc_flags;
260 	struct sx			mc_sx;
261 
262 	struct cfg80211_chan_def	dflt_chandef;
263 	struct cfg80211_chan_def	scan_chandef;
264 
265 	struct mtx			txq_mtx;
266 	uint32_t			txq_generation[IEEE80211_NUM_ACS];
267 	spinlock_t			txq_scheduled_lock[IEEE80211_NUM_ACS];
268 	TAILQ_HEAD(, lkpi_txq)		txq_scheduled[IEEE80211_NUM_ACS];
269 	spinlock_t			txq_lock;
270 
271 	/* Deferred RX path. */
272 	struct task		rxq_task;
273 	struct mbufq		rxq;
274 	struct mtx		rxq_mtx;
275 
276 	/* Scan functions we overload to handle depending on scan mode. */
277 	void                    (*ic_scan_curchan)(struct ieee80211_scan_state *,
278 				    unsigned long);
279 	void                    (*ic_scan_mindwell)(struct ieee80211_scan_state *);
280 
281 	/* Node functions we overload to sync state. */
282 	struct ieee80211_node *	(*ic_node_alloc)(struct ieee80211vap *,
283 				    const uint8_t [IEEE80211_ADDR_LEN]);
284 	int			(*ic_node_init)(struct ieee80211_node *);
285 	void			(*ic_node_cleanup)(struct ieee80211_node *);
286 	void			(*ic_node_free)(struct ieee80211_node *);
287 
288 	/* HT and later functions. */
289 	int			(*ic_recv_action)(struct ieee80211_node *,
290 				    const struct ieee80211_frame *,
291 				    const uint8_t *, const uint8_t *);
292 	int			(*ic_send_action)(struct ieee80211_node *,
293 				    int, int, void *);
294 	int			(*ic_ampdu_enable)(struct ieee80211_node *,
295 				    struct ieee80211_tx_ampdu *);
296 	int			(*ic_addba_request)(struct ieee80211_node *,
297 				    struct ieee80211_tx_ampdu *, int, int, int);
298 	int			(*ic_addba_response)(struct ieee80211_node *,
299 				    struct ieee80211_tx_ampdu *, int, int, int);
300 	void			(*ic_addba_stop)(struct ieee80211_node *,
301 				    struct ieee80211_tx_ampdu *);
302 	void			(*ic_addba_response_timeout)(struct ieee80211_node *,
303 				    struct ieee80211_tx_ampdu *);
304 	void			(*ic_bar_response)(struct ieee80211_node *,
305 				    struct ieee80211_tx_ampdu *, int);
306 	int			(*ic_ampdu_rx_start)(struct ieee80211_node *,
307 				    struct ieee80211_rx_ampdu *, int, int, int);
308 	void			(*ic_ampdu_rx_stop)(struct ieee80211_node *,
309 				    struct ieee80211_rx_ampdu *);
310 
311 #define	LKPI_MAC80211_DRV_STARTED	0x00000001
312 	uint32_t			sc_flags;
313 #define	LKPI_LHW_SCAN_RUNNING		0x00000001
314 #define	LKPI_LHW_SCAN_HW		0x00000002
315 	uint32_t			scan_flags;
316 	struct mtx			scan_mtx;
317 
318 	int				supbands;	/* Number of supported bands. */
319 	int				max_rates;	/* Maximum number of bitrates supported in any channel. */
320 	int				scan_ie_len;	/* Length of common per-band scan IEs. */
321 
322 	bool				mc_all_multi;
323 	bool				update_wme;
324 	bool				rxq_stopped;
325 	bool				emulate_chanctx;
326 
327 	/* Must be last! */
328 	struct ieee80211_hw		hw __aligned(CACHE_LINE_SIZE);
329 };
330 #define	LHW_TO_HW(_lhw)		(&(_lhw)->hw)
331 #define	HW_TO_LHW(_hw)		container_of(_hw, struct lkpi_hw, hw)
332 
333 #define	LKPI_LHW_SCAN_BITS				\
334     "\010\1RUNING\2HW"
335 
336 struct lkpi_chanctx {
337 	struct list_head		entry;
338 
339 	bool				added_to_drv;	/* Managed by MO */
340 	struct lkpi_vif			*lvif;		/* Backpointer. */
341 
342 	struct ieee80211_chanctx_conf	chanctx_conf __aligned(CACHE_LINE_SIZE);
343 };
344 #define	LCHANCTX_TO_CHANCTX_CONF(_lchanctx)		\
345     (&(_lchanctx)->chanctx_conf)
346 #define	CHANCTX_CONF_TO_LCHANCTX(_conf)			\
347     container_of(_conf, struct lkpi_chanctx, chanctx_conf)
348 
349 struct lkpi_wiphy {
350 	const struct cfg80211_ops	*ops;
351 
352 	struct work_struct		wwk;
353 	struct list_head		wwk_list;
354 	struct mtx			wwk_mtx;
355 
356 	/* Must be last! */
357 	struct wiphy			wiphy __aligned(CACHE_LINE_SIZE);
358 };
359 #define	WIPHY_TO_LWIPHY(_wiphy)	container_of(_wiphy, struct lkpi_wiphy, wiphy)
360 #define	LWIPHY_TO_WIPHY(_lwiphy)	(&(_lwiphy)->wiphy)
361 
362 #define	LKPI_80211_LWIPHY_WORK_LOCK_INIT(_lwiphy)	\
363     mtx_init(&(_lwiphy)->wwk_mtx, "lwiphy-work", NULL, MTX_DEF);
364 #define	LKPI_80211_LWIPHY_WORK_LOCK_DESTROY(_lwiphy)	\
365     mtx_destroy(&(_lwiphy)->wwk_mtx)
366 #define	LKPI_80211_LWIPHY_WORK_LOCK(_lwiphy)		\
367     mtx_lock(&(_lwiphy)->wwk_mtx)
368 #define	LKPI_80211_LWIPHY_WORK_UNLOCK(_lwiphy)		\
369     mtx_unlock(&(_lwiphy)->wwk_mtx)
370 #define	LKPI_80211_LWIPHY_WORK_LOCK_ASSERT(_lwiphy)	\
371     mtx_assert(&(_lwiphy)->wwk_mtx, MA_OWNED)
372 #define	LKPI_80211_LWIPHY_WORK_UNLOCK_ASSERT(_lwiphy)	\
373     mtx_assert(&(_lwiphy)->wwk_mtx, MA_NOTOWNED)
374 
375 #define	LKPI_80211_LHW_SCAN_LOCK_INIT(_lhw)		\
376     mtx_init(&(_lhw)->scan_mtx, "lhw-scan", NULL, MTX_DEF | MTX_RECURSE);
377 #define	LKPI_80211_LHW_SCAN_LOCK_DESTROY(_lhw)		\
378     mtx_destroy(&(_lhw)->scan_mtx);
379 #define	LKPI_80211_LHW_SCAN_LOCK(_lhw)			\
380     mtx_lock(&(_lhw)->scan_mtx)
381 #define	LKPI_80211_LHW_SCAN_UNLOCK(_lhw)		\
382     mtx_unlock(&(_lhw)->scan_mtx)
383 #define	LKPI_80211_LHW_SCAN_LOCK_ASSERT(_lhw)		\
384     mtx_assert(&(_lhw)->scan_mtx, MA_OWNED)
385 #define	LKPI_80211_LHW_SCAN_UNLOCK_ASSERT(_lhw)		\
386     mtx_assert(&(_lhw)->scan_mtx, MA_NOTOWNED)
387 
388 #define	LKPI_80211_LHW_TXQ_LOCK_INIT(_lhw)		\
389     mtx_init(&(_lhw)->txq_mtx, "lhw-txq", NULL, MTX_DEF | MTX_RECURSE);
390 #define	LKPI_80211_LHW_TXQ_LOCK_DESTROY(_lhw)		\
391     mtx_destroy(&(_lhw)->txq_mtx);
392 #define	LKPI_80211_LHW_TXQ_LOCK(_lhw)			\
393     mtx_lock(&(_lhw)->txq_mtx)
394 #define	LKPI_80211_LHW_TXQ_UNLOCK(_lhw)			\
395     mtx_unlock(&(_lhw)->txq_mtx)
396 #define	LKPI_80211_LHW_TXQ_LOCK_ASSERT(_lhw)		\
397     mtx_assert(&(_lhw)->txq_mtx, MA_OWNED)
398 #define	LKPI_80211_LHW_TXQ_UNLOCK_ASSERT(_lhw)		\
399     mtx_assert(&(_lhw)->txq_mtx, MA_NOTOWNED)
400 
401 #define	LKPI_80211_LHW_RXQ_LOCK_INIT(_lhw)		\
402     mtx_init(&(_lhw)->rxq_mtx, "lhw-rxq", NULL, MTX_DEF | MTX_RECURSE);
403 #define	LKPI_80211_LHW_RXQ_LOCK_DESTROY(_lhw)		\
404     mtx_destroy(&(_lhw)->rxq_mtx);
405 #define	LKPI_80211_LHW_RXQ_LOCK(_lhw)			\
406     mtx_lock(&(_lhw)->rxq_mtx)
407 #define	LKPI_80211_LHW_RXQ_UNLOCK(_lhw)			\
408     mtx_unlock(&(_lhw)->rxq_mtx)
409 #define	LKPI_80211_LHW_RXQ_LOCK_ASSERT(_lhw)		\
410     mtx_assert(&(_lhw)->rxq_mtx, MA_OWNED)
411 #define	LKPI_80211_LHW_RXQ_UNLOCK_ASSERT(_lhw)		\
412     mtx_assert(&(_lhw)->rxq_mtx, MA_NOTOWNED)
413 
414 #define	LKPI_80211_LHW_LVIF_LOCK(_lhw)	sx_xlock(&(_lhw)->lvif_sx)
415 #define	LKPI_80211_LHW_LVIF_UNLOCK(_lhw) sx_xunlock(&(_lhw)->lvif_sx)
416 
417 #define	LKPI_80211_LHW_MC_LOCK_INIT(_lhw)		\
418     sx_init_flags(&lhw->mc_sx, "lhw-mc", 0);
419 #define	LKPI_80211_LHW_MC_LOCK_DESTROY(_lhw)		\
420     sx_destroy(&lhw->mc_sx);
421 #define	LKPI_80211_LHW_MC_LOCK(_lhw)	sx_xlock(&(_lhw)->mc_sx)
422 #define	LKPI_80211_LHW_MC_UNLOCK(_lhw)	sx_xunlock(&(_lhw)->mc_sx)
423 
424 #define	LKPI_80211_LVIF_LOCK(_lvif)	mtx_lock(&(_lvif)->mtx)
425 #define	LKPI_80211_LVIF_UNLOCK(_lvif)	mtx_unlock(&(_lvif)->mtx)
426 
427 #define	LKPI_80211_LSTA_TXQ_LOCK_INIT(_lsta)		\
428     mtx_init(&(_lsta)->txq_mtx, "lsta-txq", NULL, MTX_DEF);
429 #define	LKPI_80211_LSTA_TXQ_LOCK_DESTROY(_lsta)		\
430     mtx_destroy(&(_lsta)->txq_mtx);
431 #define	LKPI_80211_LSTA_TXQ_LOCK(_lsta)			\
432     mtx_lock(&(_lsta)->txq_mtx)
433 #define	LKPI_80211_LSTA_TXQ_UNLOCK(_lsta)		\
434     mtx_unlock(&(_lsta)->txq_mtx)
435 #define	LKPI_80211_LSTA_TXQ_LOCK_ASSERT(_lsta)		\
436     mtx_assert(&(_lsta)->txq_mtx, MA_OWNED)
437 #define	LKPI_80211_LSTA_TXQ_UNLOCK_ASSERT(_lsta)	\
438     mtx_assert(&(_lsta)->txq_mtx, MA_NOTOWNED)
439 
440 #define	LKPI_80211_LTXQ_LOCK_INIT(_ltxq)		\
441     mtx_init(&(_ltxq)->ltxq_mtx, "ltxq", NULL, MTX_DEF);
442 #define	LKPI_80211_LTXQ_LOCK_DESTROY(_ltxq)		\
443     mtx_destroy(&(_ltxq)->ltxq_mtx);
444 #define	LKPI_80211_LTXQ_LOCK(_ltxq)			\
445     mtx_lock(&(_ltxq)->ltxq_mtx)
446 #define	LKPI_80211_LTXQ_UNLOCK(_ltxq)			\
447     mtx_unlock(&(_ltxq)->ltxq_mtx)
448 #define	LKPI_80211_LTXQ_LOCK_ASSERT(_ltxq)		\
449     mtx_assert(&(_ltxq)->ltxq_mtx, MA_OWNED)
450 #define	LKPI_80211_LTXQ_UNLOCK_ASSERT(_ltxq)		\
451     mtx_assert(&(_ltxq)->ltxq_mtx, MA_NOTOWNED)
452 
453 int lkpi_80211_mo_start(struct ieee80211_hw *);
454 void lkpi_80211_mo_stop(struct ieee80211_hw *, bool);
455 int lkpi_80211_mo_get_antenna(struct ieee80211_hw *, u32 *, u32 *);
456 int lkpi_80211_mo_set_frag_threshold(struct ieee80211_hw *, uint32_t);
457 int lkpi_80211_mo_set_rts_threshold(struct ieee80211_hw *, uint32_t);
458 int lkpi_80211_mo_add_interface(struct ieee80211_hw *, struct ieee80211_vif *);
459 void lkpi_80211_mo_remove_interface(struct ieee80211_hw *, struct ieee80211_vif *);
460 int lkpi_80211_mo_hw_scan(struct ieee80211_hw *, struct ieee80211_vif *,
461     struct ieee80211_scan_request *);
462 void lkpi_80211_mo_cancel_hw_scan(struct ieee80211_hw *, struct ieee80211_vif *);
463 void lkpi_80211_mo_sw_scan_complete(struct ieee80211_hw *, struct ieee80211_vif *);
464 void lkpi_80211_mo_sw_scan_start(struct ieee80211_hw *, struct ieee80211_vif *,
465     const u8 *);
466 u64 lkpi_80211_mo_prepare_multicast(struct ieee80211_hw *,
467     struct netdev_hw_addr_list *);
468 void lkpi_80211_mo_configure_filter(struct ieee80211_hw *, unsigned int,
469     unsigned int *, u64);
470 int lkpi_80211_mo_sta_state(struct ieee80211_hw *, struct ieee80211_vif *,
471     struct lkpi_sta *, enum ieee80211_sta_state);
472 int lkpi_80211_mo_config(struct ieee80211_hw *, uint32_t);
473 int lkpi_80211_mo_assign_vif_chanctx(struct ieee80211_hw *, struct ieee80211_vif *,
474     struct ieee80211_bss_conf *, struct ieee80211_chanctx_conf *);
475 void lkpi_80211_mo_unassign_vif_chanctx(struct ieee80211_hw *, struct ieee80211_vif *,
476     struct ieee80211_bss_conf *, struct ieee80211_chanctx_conf *);
477 int lkpi_80211_mo_add_chanctx(struct ieee80211_hw *, struct ieee80211_chanctx_conf *);
478 void lkpi_80211_mo_change_chanctx(struct ieee80211_hw *,
479     struct ieee80211_chanctx_conf *, uint32_t);
480 void lkpi_80211_mo_remove_chanctx(struct ieee80211_hw *,
481     struct ieee80211_chanctx_conf *);
482 void lkpi_80211_mo_vif_cfg_changed(struct ieee80211_hw *, struct ieee80211_vif *,
483     uint64_t, bool);
484 void lkpi_80211_mo_link_info_changed(struct ieee80211_hw *, struct ieee80211_vif *,
485     struct ieee80211_bss_conf *, uint64_t, uint8_t, bool);
486 void lkpi_80211_mo_bss_info_changed(struct ieee80211_hw *, struct ieee80211_vif *,
487     struct ieee80211_bss_conf *, uint64_t);
488 int lkpi_80211_mo_conf_tx(struct ieee80211_hw *, struct ieee80211_vif *,
489     uint32_t, uint16_t, const struct ieee80211_tx_queue_params *);
490 void lkpi_80211_mo_flush(struct ieee80211_hw *, struct ieee80211_vif *,
491     uint32_t, bool);
492 void lkpi_80211_mo_mgd_prepare_tx(struct ieee80211_hw *, struct ieee80211_vif *,
493     struct ieee80211_prep_tx_info *);
494 void lkpi_80211_mo_mgd_complete_tx(struct ieee80211_hw *, struct ieee80211_vif *,
495     struct ieee80211_prep_tx_info *);
496 void lkpi_80211_mo_tx(struct ieee80211_hw *, struct ieee80211_tx_control *,
497     struct sk_buff *);
498 void lkpi_80211_mo_wake_tx_queue(struct ieee80211_hw *, struct ieee80211_txq *,
499     bool);
500 void lkpi_80211_mo_sync_rx_queues(struct ieee80211_hw *);
501 void lkpi_80211_mo_sta_pre_rcu_remove(struct ieee80211_hw *,
502     struct ieee80211_vif *, struct ieee80211_sta *);
503 int lkpi_80211_mo_set_key(struct ieee80211_hw *, enum set_key_cmd,
504     struct ieee80211_vif *, struct ieee80211_sta *,
505     struct ieee80211_key_conf *);
506 int lkpi_80211_mo_ampdu_action(struct ieee80211_hw *, struct ieee80211_vif *,
507     struct ieee80211_ampdu_params *);
508 int lkpi_80211_mo_sta_statistics(struct ieee80211_hw *, struct ieee80211_vif *,
509     struct ieee80211_sta *, struct station_info *);
510 int lkpi_80211_mo_suspend(struct ieee80211_hw *, struct cfg80211_wowlan *);
511 int lkpi_80211_mo_resume(struct ieee80211_hw *);
512 int lkpi_80211_mo_set_wakeup(struct ieee80211_hw *, bool);
513 int lkpi_80211_mo_set_rekey_data(struct ieee80211_hw *,
514     struct ieee80211_vif *, struct cfg80211_gtk_rekey_data *);
515 int lkpi_80211_mo_set_default_unicast_key(struct ieee80211_hw *,
516     struct ieee80211_vif *, int);
517 
518 /* LinuxKPI 802.11 PM. */
519 int lkpi_80211_suspend(struct ieee80211com *, pm_message_t);
520 int lkpi_80211_resume(struct ieee80211com *);
521 
522 #endif	/* _LKPI_SRC_LINUX_80211_H */
523