xref: /freebsd/sys/compat/linuxkpi/common/include/net/mac80211.h (revision edf8578117e8844e02c0121147f45e4609b30680)
1 /*-
2  * Copyright (c) 2020-2023 The FreeBSD Foundation
3  * Copyright (c) 2020-2022 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 #ifndef	_LINUXKPI_NET_MAC80211_H
31 #define	_LINUXKPI_NET_MAC80211_H
32 
33 #include <sys/types.h>
34 
35 #include <asm/atomic64.h>
36 #include <linux/bitops.h>
37 #include <linux/etherdevice.h>
38 #include <linux/ethtool.h>
39 #include <linux/netdevice.h>
40 #include <linux/skbuff.h>
41 #include <linux/workqueue.h>
42 #include <linux/dcache.h>
43 #include <net/cfg80211.h>
44 
45 #define	ARPHRD_IEEE80211_RADIOTAP		__LINE__ /* XXX TODO brcmfmac */
46 
47 #define	WLAN_OUI_MICROSOFT			(0x0050F2)
48 #define	WLAN_OUI_TYPE_MICROSOFT_WPA		(1)
49 #define	WLAN_OUI_TYPE_MICROSOFT_TPC		(8)
50 #define	WLAN_OUI_TYPE_WFA_P2P			(9)
51 #define	WLAN_OUI_WFA				(0x506F9A)
52 
53 #define	IEEE80211_LINK_UNSPECIFIED		0x0f
54 
55 /* hw->conf.flags */
56 enum ieee80211_hw_conf_flags {
57 	IEEE80211_CONF_IDLE			= BIT(0),
58 	IEEE80211_CONF_PS			= BIT(1),
59 	IEEE80211_CONF_MONITOR			= BIT(2),
60 	IEEE80211_CONF_OFFCHANNEL		= BIT(3),
61 };
62 
63 /* (*ops->config()) */
64 enum ieee80211_hw_conf_changed_flags {
65 	IEEE80211_CONF_CHANGE_CHANNEL		= BIT(0),
66 	IEEE80211_CONF_CHANGE_IDLE		= BIT(1),
67 	IEEE80211_CONF_CHANGE_PS		= BIT(2),
68 	IEEE80211_CONF_CHANGE_MONITOR		= BIT(3),
69 	IEEE80211_CONF_CHANGE_POWER		= BIT(4),
70 };
71 
72 #define	CFG80211_TESTMODE_CMD(_x)	/* XXX TODO */
73 #define	CFG80211_TESTMODE_DUMP(_x)	/* XXX TODO */
74 
75 #define	FCS_LEN				4
76 
77 /* ops.configure_filter() */
78 enum mcast_filter_flags {
79 	FIF_ALLMULTI			= BIT(0),
80 	FIF_PROBE_REQ			= BIT(1),
81 	FIF_BCN_PRBRESP_PROMISC		= BIT(2),
82 	FIF_FCSFAIL			= BIT(3),
83 	FIF_OTHER_BSS			= BIT(4),
84 	FIF_PSPOLL			= BIT(5),
85 	FIF_CONTROL			= BIT(6),
86 };
87 
88 enum ieee80211_bss_changed {
89 	BSS_CHANGED_ARP_FILTER		= BIT(0),
90 	BSS_CHANGED_ASSOC		= BIT(1),
91 	BSS_CHANGED_BANDWIDTH		= BIT(2),
92 	BSS_CHANGED_BEACON		= BIT(3),
93 	BSS_CHANGED_BEACON_ENABLED	= BIT(4),
94 	BSS_CHANGED_BEACON_INFO		= BIT(5),
95 	BSS_CHANGED_BEACON_INT		= BIT(6),
96 	BSS_CHANGED_BSSID		= BIT(7),
97 	BSS_CHANGED_CQM			= BIT(8),
98 	BSS_CHANGED_ERP_CTS_PROT	= BIT(9),
99 	BSS_CHANGED_ERP_SLOT		= BIT(10),
100 	BSS_CHANGED_FTM_RESPONDER	= BIT(11),
101 	BSS_CHANGED_HT			= BIT(12),
102 	BSS_CHANGED_IDLE		= BIT(13),
103 	BSS_CHANGED_MU_GROUPS		= BIT(14),
104 	BSS_CHANGED_P2P_PS		= BIT(15),
105 	BSS_CHANGED_PS			= BIT(16),
106 	BSS_CHANGED_QOS			= BIT(17),
107 	BSS_CHANGED_TXPOWER		= BIT(18),
108 	BSS_CHANGED_HE_BSS_COLOR	= BIT(19),
109 	BSS_CHANGED_AP_PROBE_RESP	= BIT(20),
110 	BSS_CHANGED_BASIC_RATES		= BIT(21),
111 	BSS_CHANGED_ERP_PREAMBLE	= BIT(22),
112 	BSS_CHANGED_IBSS		= BIT(23),
113 	BSS_CHANGED_MCAST_RATE		= BIT(24),
114 	BSS_CHANGED_SSID		= BIT(25),
115 	BSS_CHANGED_FILS_DISCOVERY	= BIT(26),
116 	BSS_CHANGED_HE_OBSS_PD		= BIT(27),
117 	BSS_CHANGED_TWT			= BIT(28),
118 	BSS_CHANGED_UNSOL_BCAST_PROBE_RESP = BIT(30),
119 	BSS_CHANGED_EHT_PUNCTURING	= BIT(31),
120 };
121 
122 /* 802.11 Figure 9-256 Suite selector format. [OUI(3), SUITE TYPE(1)] */
123 #define	WLAN_CIPHER_SUITE_OUI(_oui, _x)	(((_oui) << 8) | ((_x) & 0xff))
124 
125 /* 802.11 Table 9-131 Cipher suite selectors. */
126 /* 802.1x suite B			11 */
127 #define	WLAN_CIPHER_SUITE(_x)		WLAN_CIPHER_SUITE_OUI(0x000fac, _x)
128 /* Use group				0 */
129 #define	WLAN_CIPHER_SUITE_WEP40		WLAN_CIPHER_SUITE(1)
130 #define	WLAN_CIPHER_SUITE_TKIP		WLAN_CIPHER_SUITE(2)
131 /* Reserved				3 */
132 #define	WLAN_CIPHER_SUITE_CCMP		WLAN_CIPHER_SUITE(4)	/* CCMP-128 */
133 #define	WLAN_CIPHER_SUITE_WEP104	WLAN_CIPHER_SUITE(5)
134 #define	WLAN_CIPHER_SUITE_AES_CMAC	WLAN_CIPHER_SUITE(6)	/* BIP-CMAC-128 */
135 /* Group addressed traffic not allowed	7 */
136 #define	WLAN_CIPHER_SUITE_GCMP		WLAN_CIPHER_SUITE(8)
137 #define	WLAN_CIPHER_SUITE_GCMP_256	WLAN_CIPHER_SUITE(9)
138 #define	WLAN_CIPHER_SUITE_CCMP_256	WLAN_CIPHER_SUITE(10)
139 #define	WLAN_CIPHER_SUITE_BIP_GMAC_128	WLAN_CIPHER_SUITE(11)
140 #define	WLAN_CIPHER_SUITE_BIP_GMAC_256	WLAN_CIPHER_SUITE(12)
141 #define	WLAN_CIPHER_SUITE_BIP_CMAC_256	WLAN_CIPHER_SUITE(13)
142 /* Reserved				14-255 */
143 
144 /* See ISO/IEC JTC 1 N 9880 Table 11 */
145 #define	WLAN_CIPHER_SUITE_SMS4		WLAN_CIPHER_SUITE_OUI(0x001472, 1)
146 
147 
148 /* 802.11 Table 9-133 AKM suite selectors. */
149 #define	WLAN_AKM_SUITE(_x)		WLAN_CIPHER_SUITE_OUI(0x000fac, _x)
150 /* Reserved				0 */
151 #define	WLAN_AKM_SUITE_8021X		WLAN_AKM_SUITE(1)
152 #define	WLAN_AKM_SUITE_PSK		WLAN_AKM_SUITE(2)
153 #define	WLAN_AKM_SUITE_FT_8021X		WLAN_AKM_SUITE(3)
154 #define	WLAN_AKM_SUITE_FT_PSK		WLAN_AKM_SUITE(4)
155 #define	WLAN_AKM_SUITE_8021X_SHA256	WLAN_AKM_SUITE(5)
156 #define	WLAN_AKM_SUITE_PSK_SHA256	WLAN_AKM_SUITE(6)
157 /* TDLS					7 */
158 #define	WLAN_AKM_SUITE_SAE		WLAN_AKM_SUITE(8)
159 /* FToSAE				9 */
160 /* AP peer key				10 */
161 /* 802.1x suite B			11 */
162 /* 802.1x suite B 384			12 */
163 /* FTo802.1x 384			13 */
164 /* Reserved				14-255 */
165 /* Apparently 11ax defines more. Seen (19,20) mentioned. */
166 
167 #define	TKIP_PN_TO_IV16(_x)		((uint16_t)(_x & 0xffff))
168 #define	TKIP_PN_TO_IV32(_x)		((uint32_t)((_x >> 16) & 0xffffffff))
169 
170 struct ieee80211_sta;
171 
172 /* 802.11-2020 9.4.2.55.3 A-MPDU Parameters field */
173 #define	IEEE80211_HT_AMPDU_PARM_FACTOR		0x3
174 #define	IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT	2
175 #define	IEEE80211_HT_AMPDU_PARM_DENSITY		(0x7 << IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT)
176 
177 struct ieee80211_ampdu_params {
178 	/* TODO FIXME */
179 	struct ieee80211_sta			*sta;
180 	uint8_t					tid;
181 	uint16_t				ssn;
182 	int		action, amsdu, buf_size, timeout;
183 };
184 
185 struct ieee80211_bar {
186 	/* TODO FIXME */
187 	int		control, start_seq_num;
188 	uint8_t		*ra;
189 	uint16_t	frame_control;
190 };
191 
192 struct ieee80211_p2p_noa_desc {
193 	uint32_t				count;		/* uint8_t ? */
194 	uint32_t				duration;
195 	uint32_t				interval;
196 	uint32_t				start_time;
197 };
198 
199 struct ieee80211_p2p_noa_attr {
200 	uint8_t					index;
201 	uint8_t					oppps_ctwindow;
202 	struct ieee80211_p2p_noa_desc		desc[4];
203 };
204 
205 struct ieee80211_mutable_offsets {
206 	/* TODO FIXME */
207 	uint16_t				tim_offset;
208 	uint16_t				cntdwn_counter_offs[2];
209 
210 	int	mbssid_off;
211 };
212 
213 struct mac80211_fils_discovery {
214 	uint32_t				max_interval;
215 };
216 
217 struct ieee80211_chanctx_conf {
218 	/* TODO FIXME */
219 	int		rx_chains_dynamic, rx_chains_static;
220 	bool					radar_enabled;
221 	struct cfg80211_chan_def		def;
222 	struct cfg80211_chan_def		min_def;
223 
224 	/* Must stay last. */
225 	uint8_t					drv_priv[0] __aligned(CACHE_LINE_SIZE);
226 };
227 
228 struct ieee80211_rate_status {
229 	struct rate_info			rate_idx;
230 	uint8_t					try_count;
231 };
232 
233 struct ieee80211_ema_beacons {
234 	uint8_t					cnt;
235 	struct {
236 		struct sk_buff			*skb;
237 		struct ieee80211_mutable_offsets offs;
238 	} bcn[0];
239 };
240 
241 #define	WLAN_MEMBERSHIP_LEN			(8)
242 #define	WLAN_USER_POSITION_LEN			(16)
243 
244 struct ieee80211_bss_conf {
245 	/* TODO FIXME */
246 	struct ieee80211_vif			*vif;
247 	const uint8_t				*bssid;
248 	uint8_t					addr[ETH_ALEN];
249 	uint8_t					link_id;
250 	uint8_t					_pad0;
251 	uint8_t					transmitter_bssid[ETH_ALEN];
252 	struct ieee80211_ftm_responder_params	*ftmr_params;
253 	struct ieee80211_p2p_noa_attr		p2p_noa_attr;
254 	struct cfg80211_chan_def		chandef;
255 	__be32					arp_addr_list[1];	/* XXX TODO */
256 	struct ieee80211_rate			*beacon_rate;
257 	struct {
258 		uint8_t membership[WLAN_MEMBERSHIP_LEN];
259 		uint8_t position[WLAN_USER_POSITION_LEN];
260 	}  mu_group;
261 	struct {
262 		uint32_t			params;
263 		/* single field struct? */
264 	} he_oper;
265 	struct cfg80211_he_bss_color		he_bss_color;
266 	struct ieee80211_he_obss_pd		he_obss_pd;
267 
268 	bool					ht_ldpc;
269 	bool					vht_ldpc;
270 	bool					he_ldpc;
271 	bool					vht_mu_beamformee;
272 	bool					vht_mu_beamformer;
273 	bool					vht_su_beamformee;
274 	bool					vht_su_beamformer;
275 	bool					he_mu_beamformer;
276 	bool					he_su_beamformee;
277 	bool					he_su_beamformer;
278 	bool					he_full_ul_mumimo;
279 	bool					eht_su_beamformee;
280 	bool					eht_su_beamformer;
281 	bool					eht_mu_beamformer;
282 
283 	uint16_t				ht_operation_mode;
284 	int					arp_addr_cnt;
285 	uint16_t				eht_puncturing;
286 
287 	uint8_t					dtim_period;
288 	uint8_t					sync_dtim_count;
289 	bool					qos;
290 	bool					twt_broadcast;
291 	bool					use_cts_prot;
292 	bool					use_short_preamble;
293 	bool					use_short_slot;
294 	bool					he_support;
295 	bool					eht_support;
296 	bool					csa_active;
297 	bool					mu_mimo_owner;
298 	uint32_t				sync_device_ts;
299 	uint64_t				sync_tsf;
300 	uint16_t				beacon_int;
301 	int16_t					txpower;
302 	uint32_t				basic_rates;
303 	int					mcast_rate[NUM_NL80211_BANDS];
304 	enum ieee80211_reg_ap_power 		power_type;
305 	struct cfg80211_bitrate_mask		beacon_tx_rate;
306 	struct mac80211_fils_discovery		fils_discovery;
307 	struct ieee80211_chanctx_conf		*chanctx_conf;
308 	struct ieee80211_vif			*mbssid_tx_vif;
309 
310 	int		ack_enabled, bssid_index, bssid_indicator, cqm_rssi_hyst, cqm_rssi_thold, ema_ap, frame_time_rts_th, ftm_responder;
311 	int		htc_trig_based_pkt_ext;
312 	int		multi_sta_back_32bit, nontransmitted;
313 	int		profile_periodicity;
314 	int		twt_requester, uora_exists, uora_ocw_range;
315 	int		assoc_capability, enable_beacon, hidden_ssid, ibss_joined, twt_protected;
316 	int		twt_responder, unsol_bcast_probe_resp_interval;
317 	int		color_change_active;
318 };
319 
320 struct ieee80211_channel_switch {
321 	/* TODO FIXME */
322 	int		block_tx, count, delay, device_timestamp, timestamp;
323 	struct cfg80211_chan_def		chandef;
324 };
325 
326 struct ieee80211_cipher_scheme {
327 	uint32_t	cipher;
328 	uint8_t		iftype;		/* We do not know the size of this. */
329 	uint8_t		hdr_len;
330 	uint8_t		pn_len;
331 	uint8_t		pn_off;
332 	uint8_t		key_idx_off;
333 	uint8_t		key_idx_mask;
334 	uint8_t		key_idx_shift;
335 	uint8_t		mic_len;
336 };
337 
338 enum ieee80211_event_type {
339 	BA_FRAME_TIMEOUT,
340 	BAR_RX_EVENT,
341 	MLME_EVENT,
342 	RSSI_EVENT,
343 };
344 
345 enum ieee80211_rssi_event_data {
346 	RSSI_EVENT_LOW,
347 	RSSI_EVENT_HIGH,
348 };
349 
350 enum ieee80211_mlme_event_data {
351 	ASSOC_EVENT,
352 	AUTH_EVENT,
353 	DEAUTH_RX_EVENT,
354 	DEAUTH_TX_EVENT,
355 };
356 
357 enum ieee80211_mlme_event_status {
358 	MLME_DENIED,
359 	MLME_TIMEOUT,
360 };
361 
362 struct ieee80211_mlme_event {
363 	enum ieee80211_mlme_event_data		data;
364 	enum ieee80211_mlme_event_status	status;
365 	int					reason;
366 };
367 
368 struct ieee80211_event {
369 	/* TODO FIXME */
370 	enum ieee80211_event_type		type;
371 	union {
372 		struct {
373 			int     ssn;
374 			struct ieee80211_sta	*sta;
375 			uint8_t		 	tid;
376 		} ba;
377 		struct ieee80211_mlme_event	mlme;
378 	} u;
379 };
380 
381 struct ieee80211_ftm_responder_params {
382 	/* TODO FIXME */
383 	uint8_t					*lci;
384 	uint8_t					*civicloc;
385 	int					lci_len;
386 	int					civicloc_len;
387 };
388 
389 struct ieee80211_he_mu_edca_param_ac_rec {
390 	/* TODO FIXME */
391 	int		aifsn, ecw_min_max, mu_edca_timer;
392 };
393 
394 struct ieee80211_conf {
395 	int					dynamic_ps_timeout;
396 	int					power_level;
397 	uint32_t				listen_interval;
398 	bool					radar_enabled;
399 	enum ieee80211_hw_conf_flags		flags;
400 	struct cfg80211_chan_def		chandef;
401 };
402 
403 enum ieee80211_hw_flags {
404 	IEEE80211_HW_AMPDU_AGGREGATION,
405 	IEEE80211_HW_AP_LINK_PS,
406 	IEEE80211_HW_BUFF_MMPDU_TXQ,
407 	IEEE80211_HW_CHANCTX_STA_CSA,
408 	IEEE80211_HW_CONNECTION_MONITOR,
409 	IEEE80211_HW_DEAUTH_NEED_MGD_TX_PREP,
410 	IEEE80211_HW_HAS_RATE_CONTROL,
411 	IEEE80211_HW_MFP_CAPABLE,
412 	IEEE80211_HW_NEEDS_UNIQUE_STA_ADDR,
413 	IEEE80211_HW_REPORTS_TX_ACK_STATUS,
414 	IEEE80211_HW_RX_INCLUDES_FCS,
415 	IEEE80211_HW_SIGNAL_DBM,
416 	IEEE80211_HW_SINGLE_SCAN_ON_ALL_BANDS,
417 	IEEE80211_HW_SPECTRUM_MGMT,
418 	IEEE80211_HW_STA_MMPDU_TXQ,
419 	IEEE80211_HW_SUPPORTS_AMSDU_IN_AMPDU,
420 	IEEE80211_HW_SUPPORTS_CLONED_SKBS,
421 	IEEE80211_HW_SUPPORTS_DYNAMIC_PS,
422 	IEEE80211_HW_SUPPORTS_MULTI_BSSID,
423 	IEEE80211_HW_SUPPORTS_ONLY_HE_MULTI_BSSID,
424 	IEEE80211_HW_SUPPORTS_PS,
425 	IEEE80211_HW_SUPPORTS_REORDERING_BUFFER,
426 	IEEE80211_HW_SUPPORTS_VHT_EXT_NSS_BW,
427 	IEEE80211_HW_SUPPORT_FAST_XMIT,
428 	IEEE80211_HW_TDLS_WIDER_BW,
429 	IEEE80211_HW_TIMING_BEACON_ONLY,
430 	IEEE80211_HW_TX_AMPDU_SETUP_IN_HW,
431 	IEEE80211_HW_TX_AMSDU,
432 	IEEE80211_HW_TX_FRAG_LIST,
433 	IEEE80211_HW_USES_RSS,
434 	IEEE80211_HW_WANT_MONITOR_VIF,
435 	IEEE80211_HW_SW_CRYPTO_CONTROL,
436 	IEEE80211_HW_SUPPORTS_TX_FRAG,
437 	IEEE80211_HW_SUPPORTS_TDLS_BUFFER_STA,
438 	IEEE80211_HW_SUPPORTS_PER_STA_GTK,
439 	IEEE80211_HW_REPORTS_LOW_ACK,
440 	IEEE80211_HW_QUEUE_CONTROL,
441 	IEEE80211_HW_SUPPORTS_RX_DECAP_OFFLOAD,
442 	IEEE80211_HW_SUPPORTS_TX_ENCAP_OFFLOAD,
443 	IEEE80211_HW_SUPPORTS_RC_TABLE,
444 	IEEE80211_HW_DETECTS_COLOR_COLLISION,
445 
446 	/* Keep last. */
447 	NUM_IEEE80211_HW_FLAGS
448 };
449 
450 struct ieee80211_hw {
451 
452 	struct wiphy			*wiphy;
453 
454 	/* TODO FIXME */
455 	int		max_rx_aggregation_subframes, max_tx_aggregation_subframes;
456 	int		extra_tx_headroom, weight_multiplier;
457 	int		max_rate_tries, max_rates, max_report_rates;
458 	struct ieee80211_cipher_scheme	*cipher_schemes;
459 	int				n_cipher_schemes;
460 	const char			*rate_control_algorithm;
461 	struct {
462 		uint16_t units_pos;	/* radiotap "spec" is .. inconsistent. */
463 		uint16_t accuracy;
464 	} radiotap_timestamp;
465 	size_t				sta_data_size;
466 	size_t				vif_data_size;
467 	size_t				chanctx_data_size;
468 	size_t				txq_data_size;
469 	uint16_t			radiotap_mcs_details;
470 	uint16_t			radiotap_vht_details;
471 	uint16_t			queues;
472 	uint16_t			offchannel_tx_hw_queue;
473 	uint16_t			uapsd_max_sp_len;
474 	uint16_t			uapsd_queues;
475 	uint16_t			max_tx_fragments;
476 	uint16_t			max_listen_interval;
477 	uint32_t			extra_beacon_tailroom;
478 	netdev_features_t		netdev_features;
479 	unsigned long			flags[BITS_TO_LONGS(NUM_IEEE80211_HW_FLAGS)];
480 	struct ieee80211_conf		conf;
481 
482 #if 0	/* leave here for documentation purposes.  This does NOT work. */
483 	/* Must stay last. */
484 	uint8_t				priv[0] __aligned(CACHE_LINE_SIZE);
485 #else
486 	void				*priv;
487 #endif
488 };
489 
490 enum ieee802111_key_flag {
491 	IEEE80211_KEY_FLAG_GENERATE_IV		= BIT(0),
492 	IEEE80211_KEY_FLAG_GENERATE_MMIC	= BIT(1),
493 	IEEE80211_KEY_FLAG_PAIRWISE		= BIT(2),
494 	IEEE80211_KEY_FLAG_PUT_IV_SPACE		= BIT(3),
495 	IEEE80211_KEY_FLAG_PUT_MIC_SPACE	= BIT(4),
496 	IEEE80211_KEY_FLAG_SW_MGMT_TX		= BIT(5),
497 	IEEE80211_KEY_FLAG_GENERATE_IV_MGMT	= BIT(6),
498 	IEEE80211_KEY_FLAG_GENERATE_MMIE	= BIT(7),
499 	IEEE80211_KEY_FLAG_RESERVE_TAILROOM	= BIT(8),
500 };
501 
502 struct ieee80211_key_conf {
503 	atomic64_t			tx_pn;
504 	uint32_t			cipher;
505 	uint8_t				icv_len;	/* __unused nowadays? */
506 	uint8_t				iv_len;
507 	uint8_t				hw_key_idx;	/* Set by drv. */
508 	uint8_t				keyidx;
509 	uint16_t			flags;
510 	uint8_t				keylen;
511 	uint8_t				key[0];
512 	int8_t				link_id;	/* signed! */
513 };
514 
515 struct ieee80211_key_seq {
516 	/* TODO FIXME */
517 	union {
518 		struct {
519 			uint8_t		seq[IEEE80211_MAX_PN_LEN];
520 			uint8_t		seq_len;
521 		} hw;
522 		struct {
523 			uint8_t		pn[IEEE80211_CCMP_PN_LEN];
524 		} ccmp;
525 		struct {
526 			uint8_t		pn[IEEE80211_CCMP_PN_LEN];
527 		} aes_cmac;
528 		struct {
529 			uint32_t	iv32;
530 			uint16_t	iv16;
531 		} tkip;
532 	};
533 };
534 
535 
536 enum ieee80211_rx_status_flags {
537 	RX_FLAG_ALLOW_SAME_PN		= BIT(0),
538 	RX_FLAG_AMPDU_DETAILS		= BIT(1),
539 	RX_FLAG_AMPDU_EOF_BIT		= BIT(2),
540 	RX_FLAG_AMPDU_EOF_BIT_KNOWN	= BIT(3),
541 	RX_FLAG_DECRYPTED		= BIT(4),
542 	RX_FLAG_DUP_VALIDATED		= BIT(5),
543 	RX_FLAG_FAILED_FCS_CRC		= BIT(6),
544 	RX_FLAG_ICV_STRIPPED		= BIT(7),
545 	RX_FLAG_MACTIME_PLCP_START	= BIT(8),
546 	RX_FLAG_MACTIME_START		= BIT(9),
547 	RX_FLAG_MIC_STRIPPED		= BIT(10),
548 	RX_FLAG_MMIC_ERROR		= BIT(11),
549 	RX_FLAG_MMIC_STRIPPED		= BIT(12),
550 	RX_FLAG_NO_PSDU			= BIT(13),
551 	RX_FLAG_PN_VALIDATED		= BIT(14),
552 	RX_FLAG_RADIOTAP_HE		= BIT(15),
553 	RX_FLAG_RADIOTAP_HE_MU		= BIT(16),
554 	RX_FLAG_RADIOTAP_LSIG		= BIT(17),
555 	RX_FLAG_RADIOTAP_VENDOR_DATA	= BIT(18),
556 	RX_FLAG_NO_SIGNAL_VAL		= BIT(19),
557 	RX_FLAG_IV_STRIPPED		= BIT(20),
558 	RX_FLAG_AMPDU_IS_LAST		= BIT(21),
559 	RX_FLAG_AMPDU_LAST_KNOWN	= BIT(22),
560 	RX_FLAG_AMSDU_MORE		= BIT(23),
561 	RX_FLAG_MACTIME_END		= BIT(24),
562 	RX_FLAG_ONLY_MONITOR		= BIT(25),
563 	RX_FLAG_SKIP_MONITOR		= BIT(26),
564 	RX_FLAG_8023			= BIT(27),
565 	RX_FLAG_RADIOTAP_TLV_AT_END	= BIT(28),
566 };
567 
568 enum mac80211_rx_encoding {
569 	RX_ENC_LEGACY		= 0,
570 	RX_ENC_HT,
571 	RX_ENC_VHT,
572 	RX_ENC_HE,
573 	RX_ENC_EHT,
574 };
575 
576 struct ieee80211_rx_status {
577 	/* TODO FIXME, this is too large. Over-reduce types to u8 where possible. */
578 	union {
579 		uint64_t			boottime_ns;
580 		int64_t				ack_tx_hwtstamp;
581 	};
582 	uint64_t			mactime;
583 	uint32_t			device_timestamp;
584 	enum ieee80211_rx_status_flags	flag;
585 	uint16_t			freq;
586 	uint8_t				encoding:3, bw:4;	/* enum mac80211_rx_encoding, rate_info_bw */	/* See mt76.h */
587 	uint8_t				ampdu_reference;
588 	uint8_t				band;
589 	uint8_t				chains;
590 	int8_t				chain_signal[IEEE80211_MAX_CHAINS];
591 	int8_t				signal;
592 	uint8_t				enc_flags;
593 	union {
594 		struct {
595 			uint8_t		he_ru:3;	/* nl80211::enum nl80211_he_ru_alloc */
596 			uint8_t		he_gi:2;	/* nl80211::enum nl80211_he_gi */
597 			uint8_t		he_dcm:1;
598 		};
599 		struct {
600 			uint8_t		ru:4;		/* nl80211::enum nl80211_eht_ru_alloc */
601 			uint8_t		gi:2;		/* nl80211::enum nl80211_eht_gi */
602 		} eht;
603 	};
604 	bool				link_valid;
605 	uint8_t				link_id;	/* very incosistent sizes? */
606 	uint8_t				zero_length_psdu_type;
607 	uint8_t				nss;
608 	uint8_t				rate_idx;
609 };
610 
611 struct ieee80211_tx_status {
612 	struct ieee80211_sta		*sta;
613 	struct ieee80211_tx_info	*info;
614 	int64_t				ack_hwtstamp;
615 
616 	u8				n_rates;
617 	struct ieee80211_rate_status	*rates;
618 
619 	struct sk_buff			*skb;
620 	struct list_head		*free_list;
621 };
622 
623 struct ieee80211_scan_ies {
624 	/* TODO FIXME */
625 	int		common_ie_len;
626 	int		len[NUM_NL80211_BANDS];
627 	uint8_t		*common_ies;
628 	uint8_t		*ies[NUM_NL80211_BANDS];
629 };
630 
631 struct ieee80211_scan_request {
632 	struct ieee80211_scan_ies	ies;
633 	struct cfg80211_scan_request	req;
634 };
635 
636 struct ieee80211_txq {
637 	struct ieee80211_sta		*sta;
638 	struct ieee80211_vif		*vif;
639 	int				ac;
640 	uint8_t				tid;
641 
642 	/* Must stay last. */
643 	uint8_t				drv_priv[0] __aligned(CACHE_LINE_SIZE);
644 };
645 
646 struct ieee80211_sta_rates {
647 	/* XXX TODO */
648 	/* XXX some _rcu thing */
649 	struct {
650 		int	idx;
651 		int	flags;
652 	} rate[1];		/* XXX what is the real number? */
653 };
654 
655 struct ieee80211_sta_txpwr {
656 	/* XXX TODO */
657 	enum nl80211_tx_power_setting	type;
658 	short				power;
659 };
660 
661 #define	IEEE80211_NUM_TIDS			16	/* net80211::WME_NUM_TID */
662 struct ieee80211_sta_agg {
663 	uint16_t				max_amsdu_len;
664 	uint16_t				max_rc_amsdu_len;
665 	uint16_t				max_tid_amsdu_len[IEEE80211_NUM_TIDS];
666 };
667 
668 struct ieee80211_link_sta {
669 	uint8_t					addr[ETH_ALEN];
670 	uint8_t					link_id;
671 	uint32_t				supp_rates[NUM_NL80211_BANDS];
672 	struct ieee80211_sta_ht_cap		ht_cap;
673 	struct ieee80211_sta_vht_cap		vht_cap;
674 	struct ieee80211_sta_he_cap		he_cap;
675 	struct ieee80211_sta_he_6ghz_capa	he_6ghz_capa;
676 	struct ieee80211_sta_eht_cap		eht_cap;
677 	uint8_t					rx_nss;
678 	enum ieee80211_sta_rx_bw		bandwidth;
679 	enum ieee80211_smps_mode		smps_mode;
680 	struct ieee80211_sta_agg		agg;
681 	struct ieee80211_sta_txpwr		txpwr;
682 };
683 
684 struct ieee80211_sta {
685 	/* TODO FIXME */
686 	int		max_amsdu_subframes;
687 	int		mfp, smps_mode, tdls, tdls_initiator;
688 	struct ieee80211_txq			*txq[IEEE80211_NUM_TIDS + 1];	/* iwlwifi: 8 and adds +1 to tid_data, net80211::IEEE80211_TID_SIZE */
689 	struct ieee80211_sta_rates		*rates;	/* some rcu thing? */
690 	uint8_t					addr[ETH_ALEN];
691 	uint16_t				aid;
692 	bool					wme;
693 	uint8_t					max_sp;
694 	uint8_t					uapsd_queues;
695 	uint16_t				valid_links;
696 
697 	struct ieee80211_link_sta		deflink;
698 	struct ieee80211_link_sta		*link[IEEE80211_MLD_MAX_NUM_LINKS];	/* rcu? */
699 
700 	/* Must stay last. */
701 	uint8_t					drv_priv[0] __aligned(CACHE_LINE_SIZE);
702 };
703 
704 struct ieee80211_tdls_ch_sw_params {
705 	/* TODO FIXME */
706 	int		action_code, ch_sw_tm_ie, status, switch_time, switch_timeout, timestamp;
707 	struct ieee80211_sta			*sta;
708 	struct cfg80211_chan_def		*chandef;
709 	struct sk_buff				*tmpl_skb;
710 };
711 
712 struct ieee80211_tx_control {
713 	/* TODO FIXME */
714 	struct ieee80211_sta			*sta;
715 };
716 
717 struct ieee80211_tx_queue_params {
718 	/* These types are based on iwlwifi FW structs. */
719 	uint16_t	cw_min;
720 	uint16_t	cw_max;
721 	uint16_t	txop;
722 	uint8_t		aifs;
723 
724 	/* TODO FIXME */
725 	int		acm, mu_edca, uapsd;
726 	struct ieee80211_he_mu_edca_param_ac_rec	mu_edca_param_rec;
727 };
728 
729 struct ieee80211_tx_rate {
730 	uint8_t		idx;
731 	uint16_t	count:5,
732 			flags:11;
733 };
734 
735 enum ieee80211_vif_driver_flags {
736 	IEEE80211_VIF_BEACON_FILTER		= BIT(0),
737 	IEEE80211_VIF_SUPPORTS_CQM_RSSI		= BIT(1),
738 	IEEE80211_VIF_SUPPORTS_UAPSD		= BIT(2),
739 	IEEE80211_VIF_DISABLE_SMPS_OVERRIDE	= BIT(3),
740 };
741 
742 #define	IEEE80211_BSS_ARP_ADDR_LIST_LEN		4
743 
744 struct ieee80211_vif_cfg {
745 	uint16_t				aid;
746 	uint16_t				eml_cap;
747 	uint16_t				eml_med_sync_delay;
748 	bool					assoc;
749 	bool					ps;
750 	bool					idle;
751 	bool					ibss_joined;
752 	int					arp_addr_cnt;
753 	size_t					ssid_len;
754 	uint32_t				arp_addr_list[IEEE80211_BSS_ARP_ADDR_LIST_LEN];		/* big endian */
755 	uint8_t					ssid[IEEE80211_NWID_LEN];
756 	uint8_t					ap_addr[ETH_ALEN];
757 };
758 
759 struct ieee80211_vif {
760 	/* TODO FIXME */
761 	enum nl80211_iftype		type;
762 	int		csa_active, mu_mimo_owner;
763 	int		cab_queue;
764 	int     color_change_active, offload_flags;
765 	enum ieee80211_vif_driver_flags	driver_flags;
766 	bool				p2p;
767 	bool				probe_req_reg;
768 	uint8_t				addr[ETH_ALEN];
769 	struct ieee80211_vif_cfg	cfg;
770 	struct ieee80211_chanctx_conf	*chanctx_conf;
771 	struct ieee80211_txq		*txq;
772 	struct ieee80211_bss_conf	bss_conf;
773 	struct ieee80211_bss_conf	*link_conf[IEEE80211_MLD_MAX_NUM_LINKS];	/* rcu? */
774 	uint8_t				hw_queue[IEEE80211_NUM_ACS];
775 	uint16_t			active_links;
776 	uint16_t			valid_links;
777 	struct ieee80211_vif		*mbssid_tx_vif;
778 
779 /* #ifdef CONFIG_MAC80211_DEBUGFS */	/* Do not change structure depending on compile-time option. */
780 	struct dentry			*debugfs_dir;
781 /* #endif */
782 
783 	/* Must stay last. */
784 	uint8_t				drv_priv[0] __aligned(CACHE_LINE_SIZE);
785 };
786 
787 struct ieee80211_vif_chanctx_switch {
788 	struct ieee80211_chanctx_conf	*old_ctx, *new_ctx;
789 	struct ieee80211_vif		*vif;
790 	struct ieee80211_bss_conf	*link_conf;
791 };
792 
793 struct ieee80211_prep_tx_info {
794 	u16				duration;
795 	bool				success;
796 };
797 
798 /* XXX-BZ too big, over-reduce size to u8, and array sizes to minuimum to fit in skb->cb. */
799 /* Also warning: some sizes change by pointer size!  This is 64bit only. */
800 struct ieee80211_tx_info {
801 	enum ieee80211_tx_info_flags		flags;
802 	/* TODO FIXME */
803 	u8		band;
804 	u8		hw_queue;
805 	bool		tx_time_est;
806 	union {
807 		struct {
808 			struct ieee80211_tx_rate	rates[4];
809 			bool				use_rts;
810 			struct ieee80211_vif		*vif;
811 			struct ieee80211_key_conf	*hw_key;
812 			enum ieee80211_tx_control_flags	flags;
813 		} control;
814 		struct {
815 			struct ieee80211_tx_rate	rates[4];
816 			uint32_t			ack_signal;
817 			uint8_t				ampdu_ack_len;
818 			uint8_t				ampdu_len;
819 			uint8_t				antenna;
820 			uint16_t			tx_time;
821 			uint8_t				flags;
822 			void				*status_driver_data[16 / sizeof(void *)];		/* XXX TODO */
823 		} status;
824 #define	IEEE80211_TX_INFO_DRIVER_DATA_SIZE	40
825 		void					*driver_data[IEEE80211_TX_INFO_DRIVER_DATA_SIZE / sizeof(void *)];
826 	};
827 };
828 
829 /* net80211 conflict */
830 struct linuxkpi_ieee80211_tim_ie {
831 	uint8_t				dtim_count;
832 	uint8_t				dtim_period;
833 	uint8_t				bitmap_ctrl;
834 	uint8_t				*virtual_map;
835 };
836 #define	ieee80211_tim_ie	linuxkpi_ieee80211_tim_ie
837 
838 struct survey_info {		/* net80211::struct ieee80211_channel_survey */
839 	/* TODO FIXME */
840 	uint32_t			filled;
841 #define	SURVEY_INFO_TIME		0x0001
842 #define	SURVEY_INFO_TIME_RX		0x0002
843 #define	SURVEY_INFO_TIME_SCAN		0x0004
844 #define	SURVEY_INFO_TIME_TX		0x0008
845 #define	SURVEY_INFO_TIME_BSS_RX		0x0010
846 #define	SURVEY_INFO_TIME_BUSY		0x0020
847 #define	SURVEY_INFO_IN_USE		0x0040
848 #define	SURVEY_INFO_NOISE_DBM		0x0080
849 	uint32_t			noise;
850 	uint64_t			time;
851 	uint64_t			time_bss_rx;
852 	uint64_t			time_busy;
853 	uint64_t			time_rx;
854 	uint64_t			time_scan;
855 	uint64_t			time_tx;
856 	struct ieee80211_channel	*channel;
857 };
858 
859 enum ieee80211_iface_iter {
860 	IEEE80211_IFACE_ITER_NORMAL	= BIT(0),
861 	IEEE80211_IFACE_ITER_RESUME_ALL	= BIT(1),
862 	IEEE80211_IFACE_SKIP_SDATA_NOT_IN_DRIVER = BIT(2),	/* seems to be an iter flag */
863 	IEEE80211_IFACE_ITER_ACTIVE	= BIT(3),
864 
865 	/* Internal flags only. */
866 	IEEE80211_IFACE_ITER__ATOMIC	= BIT(6),
867 	IEEE80211_IFACE_ITER__MTX	= BIT(8),
868 };
869 
870 enum set_key_cmd {
871 	SET_KEY,
872 	DISABLE_KEY,
873 };
874 
875 /* 802.11-2020, 9.4.2.55.2 HT Capability Information field. */
876 enum rx_enc_flags {
877 	RX_ENC_FLAG_SHORTPRE	=	BIT(0),
878 	RX_ENC_FLAG_SHORT_GI	=	BIT(2),
879 	RX_ENC_FLAG_HT_GF	=	BIT(3),
880 	RX_ENC_FLAG_STBC_MASK	=	BIT(4) | BIT(5),
881 #define	RX_ENC_FLAG_STBC_SHIFT		4
882 	RX_ENC_FLAG_LDPC	=	BIT(6),
883 	RX_ENC_FLAG_BF		=	BIT(7),
884 };
885 
886 enum sta_notify_cmd {
887 	STA_NOTIFY_AWAKE,
888 	STA_NOTIFY_SLEEP,
889 };
890 
891 struct ieee80211_low_level_stats {
892 	/* Can we make them uint64_t? */
893 	uint32_t dot11ACKFailureCount;
894 	uint32_t dot11FCSErrorCount;
895 	uint32_t dot11RTSFailureCount;
896 	uint32_t dot11RTSSuccessCount;
897 };
898 
899 enum ieee80211_offload_flags {
900 	IEEE80211_OFFLOAD_ENCAP_4ADDR,
901 	IEEE80211_OFFLOAD_ENCAP_ENABLED,
902 	IEEE80211_OFFLOAD_DECAP_ENABLED,
903 };
904 
905 struct ieee80211_ops {
906 	/* TODO FIXME */
907 	int  (*start)(struct ieee80211_hw *);
908 	void (*stop)(struct ieee80211_hw *);
909 
910 	int  (*config)(struct ieee80211_hw *, u32);
911 	void (*reconfig_complete)(struct ieee80211_hw *, enum ieee80211_reconfig_type);
912 
913 	int  (*add_interface)(struct ieee80211_hw *, struct ieee80211_vif *);
914 	void (*remove_interface)(struct ieee80211_hw *, struct ieee80211_vif *);
915 	int  (*change_interface)(struct ieee80211_hw *, struct ieee80211_vif *, enum nl80211_iftype, bool);
916 
917 	void (*sw_scan_start)(struct ieee80211_hw *, struct ieee80211_vif *, const u8 *);
918 	void (*sw_scan_complete)(struct ieee80211_hw *, struct ieee80211_vif *);
919 	int  (*sched_scan_start)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_sched_scan_request *, struct ieee80211_scan_ies *);
920 	int  (*sched_scan_stop)(struct ieee80211_hw *, struct ieee80211_vif *);
921 	int  (*hw_scan)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_scan_request *);
922 	void (*cancel_hw_scan)(struct ieee80211_hw *, struct ieee80211_vif *);
923 
924 	int  (*conf_tx)(struct ieee80211_hw *, struct ieee80211_vif *, u32, u16, const struct ieee80211_tx_queue_params *);
925 	void (*tx)(struct ieee80211_hw *, struct ieee80211_tx_control *, struct sk_buff *);
926 	int  (*tx_last_beacon)(struct ieee80211_hw *);
927 	void (*wake_tx_queue)(struct ieee80211_hw *, struct ieee80211_txq *);
928 
929 	void (*mgd_prepare_tx)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_prep_tx_info *);
930 	void (*mgd_complete_tx)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_prep_tx_info *);
931 	void (*mgd_protect_tdls_discover)(struct ieee80211_hw *, struct ieee80211_vif *);
932 
933 	void (*flush)(struct ieee80211_hw *, struct ieee80211_vif *, u32, bool);
934 	void (*flush_sta)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *);
935 
936 	int  (*set_frag_threshold)(struct ieee80211_hw *, u32);
937 
938 	void (*sync_rx_queues)(struct ieee80211_hw *);
939 
940 	void (*allow_buffered_frames)(struct ieee80211_hw *, struct ieee80211_sta *, u16, int, enum ieee80211_frame_release_type, bool);
941 	void (*release_buffered_frames)(struct ieee80211_hw *, struct ieee80211_sta *, u16, int, enum ieee80211_frame_release_type, bool);
942 
943 	int  (*sta_add)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *);
944 	int  (*sta_remove)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *);
945 	int  (*sta_set_txpwr)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *);
946 	void (*sta_statistics)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, struct station_info *);
947 	void (*sta_pre_rcu_remove)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *);
948 	int  (*sta_state)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, enum ieee80211_sta_state, enum ieee80211_sta_state);
949 	void (*sta_notify)(struct ieee80211_hw *, struct ieee80211_vif *, enum sta_notify_cmd, struct ieee80211_sta *);
950 	void (*sta_rc_update)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, u32);
951 	void (*sta_rate_tbl_update)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *);
952 	void (*sta_set_4addr)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, bool);
953 	void (*sta_set_decap_offload)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, bool);
954 
955 	u64  (*prepare_multicast)(struct ieee80211_hw *, struct netdev_hw_addr_list *);
956 
957 	int  (*ampdu_action)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_ampdu_params *);
958 
959 	bool (*can_aggregate_in_amsdu)(struct ieee80211_hw *, struct sk_buff *, struct sk_buff *);
960 
961 	int  (*pre_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_channel_switch *);
962 	int  (*post_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *);
963 	void (*channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_channel_switch *);
964 	void (*channel_switch_beacon)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_chan_def *);
965 	void (*abort_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *);
966 	void (*channel_switch_rx_beacon)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_channel_switch *);
967 	int  (*tdls_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, u8, struct cfg80211_chan_def *, struct sk_buff *, u32);
968 	void (*tdls_cancel_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *);
969 	void (*tdls_recv_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_tdls_ch_sw_params *);
970 
971 	int  (*add_chanctx)(struct ieee80211_hw *, struct ieee80211_chanctx_conf *);
972 	void (*remove_chanctx)(struct ieee80211_hw *, struct ieee80211_chanctx_conf *);
973 	void (*change_chanctx)(struct ieee80211_hw *, struct ieee80211_chanctx_conf *, u32);
974 	int  (*assign_vif_chanctx)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_bss_conf *, struct ieee80211_chanctx_conf *);
975 	void (*unassign_vif_chanctx)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_bss_conf *, struct ieee80211_chanctx_conf *);
976 	int  (*switch_vif_chanctx)(struct ieee80211_hw *, struct ieee80211_vif_chanctx_switch *, int, enum ieee80211_chanctx_switch_mode);
977 
978 	int  (*get_antenna)(struct ieee80211_hw *, u32 *, u32 *);
979 	int  (*set_antenna)(struct ieee80211_hw *, u32, u32);
980 
981 	int  (*remain_on_channel)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_channel *, int, enum ieee80211_roc_type);
982 	int  (*cancel_remain_on_channel)(struct ieee80211_hw *, struct ieee80211_vif *);
983 
984 	void (*configure_filter)(struct ieee80211_hw *, unsigned int, unsigned int *, u64);
985 	void (*config_iface_filter)(struct ieee80211_hw *, struct ieee80211_vif *, unsigned int, unsigned int);
986 
987 	void (*bss_info_changed)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_bss_conf *, u64);
988         void (*link_info_changed)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_bss_conf *, u64);
989 
990 	int  (*set_rts_threshold)(struct ieee80211_hw *, u32);
991 	void (*event_callback)(struct ieee80211_hw *, struct ieee80211_vif *, const struct ieee80211_event *);
992 	int  (*get_survey)(struct ieee80211_hw *, int, struct survey_info *);
993 	int  (*get_ftm_responder_stats)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_ftm_responder_stats *);
994 
995         uint64_t (*get_tsf)(struct ieee80211_hw *, struct ieee80211_vif *);
996         void (*set_tsf)(struct ieee80211_hw *, struct ieee80211_vif *, uint64_t);
997 	void (*offset_tsf)(struct ieee80211_hw *, struct ieee80211_vif *, s64);
998 
999 	int  (*set_bitrate_mask)(struct ieee80211_hw *, struct ieee80211_vif *, const struct cfg80211_bitrate_mask *);
1000 	void (*set_coverage_class)(struct ieee80211_hw *, s16);
1001 	int  (*set_tim)(struct ieee80211_hw *, struct ieee80211_sta *, bool);
1002 
1003 	int  (*set_key)(struct ieee80211_hw *, enum set_key_cmd, struct ieee80211_vif *, struct ieee80211_sta *, struct ieee80211_key_conf *);
1004 	void (*set_default_unicast_key)(struct ieee80211_hw *, struct ieee80211_vif *, int);
1005 	void (*update_tkip_key)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_key_conf *, struct ieee80211_sta *, u32, u16 *);
1006 	void (*set_rekey_data)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_gtk_rekey_data *);
1007 
1008 	int  (*start_pmsr)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_pmsr_request *);
1009 	void (*abort_pmsr)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_pmsr_request *);
1010 
1011 	int  (*start_ap)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_bss_conf *link_conf);
1012 	void (*stop_ap)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_bss_conf *link_conf);
1013 	int  (*join_ibss)(struct ieee80211_hw *, struct ieee80211_vif *);
1014 	void (*leave_ibss)(struct ieee80211_hw *, struct ieee80211_vif *);
1015 
1016 	int  (*set_sar_specs)(struct ieee80211_hw *, const struct cfg80211_sar_specs *);
1017 
1018 	int  (*set_tid_config)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, struct cfg80211_tid_config *);
1019 	int  (*reset_tid_config)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, u8);
1020 
1021 	int  (*get_et_sset_count)(struct ieee80211_hw *, struct ieee80211_vif *, int);
1022 	void (*get_et_stats)(struct ieee80211_hw *, struct ieee80211_vif *, struct ethtool_stats *, u64 *);
1023 	void (*get_et_strings)(struct ieee80211_hw *, struct ieee80211_vif *, u32, u8 *);
1024 
1025 	void (*update_vif_offload)(struct ieee80211_hw *, struct ieee80211_vif *);
1026 
1027 	int  (*get_txpower)(struct ieee80211_hw *, struct ieee80211_vif *, int *);
1028 	int  (*get_stats)(struct ieee80211_hw *, struct ieee80211_low_level_stats *);
1029 
1030 	int  (*set_radar_background)(struct ieee80211_hw *, struct cfg80211_chan_def *);
1031 
1032 	void (*add_twt_setup)(struct ieee80211_hw *, struct ieee80211_sta *, struct ieee80211_twt_setup *);
1033 	void (*twt_teardown_request)(struct ieee80211_hw *, struct ieee80211_sta *, u8);
1034 
1035 	int (*set_hw_timestamp)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_set_hw_timestamp *);
1036 
1037         void (*vif_cfg_changed)(struct ieee80211_hw *, struct ieee80211_vif *, u64);
1038 
1039 	int (*change_vif_links)(struct ieee80211_hw *, struct ieee80211_vif *, u16, u16, struct ieee80211_bss_conf *[IEEE80211_MLD_MAX_NUM_LINKS]);
1040 	int (*change_sta_links)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, u16, u16);
1041 
1042 /* #ifdef CONFIG_MAC80211_DEBUGFS */	/* Do not change depending on compile-time option. */
1043 	void (*sta_add_debugfs)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, struct dentry *);
1044 /* #endif */
1045 };
1046 
1047 
1048 /* -------------------------------------------------------------------------- */
1049 
1050 /* linux_80211.c */
1051 extern const struct cfg80211_ops linuxkpi_mac80211cfgops;
1052 
1053 struct ieee80211_hw *linuxkpi_ieee80211_alloc_hw(size_t,
1054     const struct ieee80211_ops *);
1055 void linuxkpi_ieee80211_iffree(struct ieee80211_hw *);
1056 void linuxkpi_set_ieee80211_dev(struct ieee80211_hw *, char *);
1057 int linuxkpi_ieee80211_ifattach(struct ieee80211_hw *);
1058 void linuxkpi_ieee80211_ifdetach(struct ieee80211_hw *);
1059 void linuxkpi_ieee80211_unregister_hw(struct ieee80211_hw *);
1060 struct ieee80211_hw * linuxkpi_wiphy_to_ieee80211_hw(struct wiphy *);
1061 void linuxkpi_ieee80211_restart_hw(struct ieee80211_hw *);
1062 void linuxkpi_ieee80211_iterate_interfaces(
1063     struct ieee80211_hw *hw, enum ieee80211_iface_iter flags,
1064     void(*iterfunc)(void *, uint8_t *, struct ieee80211_vif *),
1065     void *);
1066 void linuxkpi_ieee80211_iterate_keys(struct ieee80211_hw *,
1067     struct ieee80211_vif *,
1068     void(*iterfunc)(struct ieee80211_hw *, struct ieee80211_vif *,
1069         struct ieee80211_sta *, struct ieee80211_key_conf *, void *),
1070     void *);
1071 void linuxkpi_ieee80211_iterate_chan_contexts(struct ieee80211_hw *,
1072     void(*iterfunc)(struct ieee80211_hw *,
1073 	struct ieee80211_chanctx_conf *, void *),
1074     void *);
1075 void linuxkpi_ieee80211_iterate_stations_atomic(struct ieee80211_hw *,
1076    void (*iterfunc)(void *, struct ieee80211_sta *), void *);
1077 void linuxkpi_ieee80211_scan_completed(struct ieee80211_hw *,
1078     struct cfg80211_scan_info *);
1079 void linuxkpi_ieee80211_rx(struct ieee80211_hw *, struct sk_buff *,
1080     struct ieee80211_sta *, struct napi_struct *, struct list_head *);
1081 uint8_t linuxkpi_ieee80211_get_tid(struct ieee80211_hdr *, bool);
1082 struct ieee80211_sta *linuxkpi_ieee80211_find_sta(struct ieee80211_vif *,
1083     const u8 *);
1084 struct ieee80211_sta *linuxkpi_ieee80211_find_sta_by_ifaddr(
1085     struct ieee80211_hw *, const uint8_t *, const uint8_t *);
1086 struct sk_buff *linuxkpi_ieee80211_tx_dequeue(struct ieee80211_hw *,
1087     struct ieee80211_txq *);
1088 bool linuxkpi_ieee80211_is_ie_id_in_ie_buf(const u8, const u8 *, size_t);
1089 bool linuxkpi_ieee80211_ie_advance(size_t *, const u8 *, size_t);
1090 void linuxkpi_ieee80211_free_txskb(struct ieee80211_hw *, struct sk_buff *,
1091     int);
1092 void linuxkpi_ieee80211_queue_delayed_work(struct ieee80211_hw *,
1093     struct delayed_work *, int);
1094 void linuxkpi_ieee80211_queue_work(struct ieee80211_hw *, struct work_struct *);
1095 struct sk_buff *linuxkpi_ieee80211_pspoll_get(struct ieee80211_hw *,
1096     struct ieee80211_vif *);
1097 struct sk_buff *linuxkpi_ieee80211_nullfunc_get(struct ieee80211_hw *,
1098     struct ieee80211_vif *, int, bool);
1099 void linuxkpi_ieee80211_txq_get_depth(struct ieee80211_txq *, unsigned long *,
1100     unsigned long *);
1101 struct wireless_dev *linuxkpi_ieee80211_vif_to_wdev(struct ieee80211_vif *);
1102 void linuxkpi_ieee80211_connection_loss(struct ieee80211_vif *);
1103 void linuxkpi_ieee80211_beacon_loss(struct ieee80211_vif *);
1104 struct sk_buff *linuxkpi_ieee80211_probereq_get(struct ieee80211_hw *,
1105     uint8_t *, uint8_t *, size_t, size_t);
1106 void linuxkpi_ieee80211_tx_status(struct ieee80211_hw *, struct sk_buff *);
1107 void linuxkpi_ieee80211_tx_status_ext(struct ieee80211_hw *,
1108     struct ieee80211_tx_status *);
1109 void linuxkpi_ieee80211_stop_queues(struct ieee80211_hw *);
1110 void linuxkpi_ieee80211_wake_queues(struct ieee80211_hw *);
1111 void linuxkpi_ieee80211_stop_queue(struct ieee80211_hw *, int);
1112 void linuxkpi_ieee80211_wake_queue(struct ieee80211_hw *, int);
1113 void linuxkpi_ieee80211_txq_schedule_start(struct ieee80211_hw *, uint8_t);
1114 struct ieee80211_txq *linuxkpi_ieee80211_next_txq(struct ieee80211_hw *, uint8_t);
1115 void linuxkpi_ieee80211_schedule_txq(struct ieee80211_hw *,
1116     struct ieee80211_txq *, bool);
1117 
1118 /* -------------------------------------------------------------------------- */
1119 
1120 static __inline void
1121 _ieee80211_hw_set(struct ieee80211_hw *hw, enum ieee80211_hw_flags flag)
1122 {
1123 
1124 	set_bit(flag, hw->flags);
1125 }
1126 
1127 static __inline bool
1128 __ieee80211_hw_check(struct ieee80211_hw *hw, enum ieee80211_hw_flags flag)
1129 {
1130 
1131 	return (test_bit(flag, hw->flags));
1132 }
1133 
1134 /* They pass in shortened flag names; how confusingly inconsistent. */
1135 #define	ieee80211_hw_set(_hw, _flag)					\
1136 	_ieee80211_hw_set(_hw, IEEE80211_HW_ ## _flag)
1137 #define	ieee80211_hw_check(_hw, _flag)					\
1138 	__ieee80211_hw_check(_hw, IEEE80211_HW_ ## _flag)
1139 
1140 /* XXX-BZ add CTASSERTS that size of struct is <= sizeof skb->cb. */
1141 CTASSERT(sizeof(struct ieee80211_tx_info) <= sizeof(((struct sk_buff *)0)->cb));
1142 #define	IEEE80211_SKB_CB(_skb)						\
1143 	((struct ieee80211_tx_info *)((_skb)->cb))
1144 
1145 CTASSERT(sizeof(struct ieee80211_rx_status) <= sizeof(((struct sk_buff *)0)->cb));
1146 #define	IEEE80211_SKB_RXCB(_skb)					\
1147 	((struct ieee80211_rx_status *)((_skb)->cb))
1148 
1149 static __inline void
1150 ieee80211_free_hw(struct ieee80211_hw *hw)
1151 {
1152 
1153 	linuxkpi_ieee80211_iffree(hw);
1154 
1155 	if (hw->wiphy != NULL)
1156 		wiphy_free(hw->wiphy);
1157 	/* Note that *hw is not valid any longer after this. */
1158 
1159 	IMPROVE();
1160 }
1161 
1162 static __inline struct ieee80211_hw *
1163 ieee80211_alloc_hw(size_t priv_len, const struct ieee80211_ops *ops)
1164 {
1165 
1166 	return (linuxkpi_ieee80211_alloc_hw(priv_len, ops));
1167 }
1168 
1169 static __inline void
1170 SET_IEEE80211_DEV(struct ieee80211_hw *hw, struct device *dev)
1171 {
1172 
1173 	set_wiphy_dev(hw->wiphy, dev);
1174 	linuxkpi_set_ieee80211_dev(hw, dev_name(dev));
1175 
1176 	IMPROVE();
1177 }
1178 
1179 static __inline int
1180 ieee80211_register_hw(struct ieee80211_hw *hw)
1181 {
1182 	int error;
1183 
1184 	error = wiphy_register(hw->wiphy);
1185 	if (error != 0)
1186 		return (error);
1187 
1188 	/*
1189 	 * At this point the driver has set all the options, flags, bands,
1190 	 * ciphers, hw address(es), ... basically mac80211/cfg80211 hw/wiphy
1191 	 * setup is done.
1192 	 * We need to replicate a lot of information from here into net80211.
1193 	 */
1194 	error = linuxkpi_ieee80211_ifattach(hw);
1195 
1196 	IMPROVE();
1197 
1198 	return (error);
1199 }
1200 
1201 static inline void
1202 ieee80211_unregister_hw(struct ieee80211_hw *hw)
1203 {
1204 
1205 	linuxkpi_ieee80211_unregister_hw(hw);
1206 }
1207 
1208 static __inline struct ieee80211_hw *
1209 wiphy_to_ieee80211_hw(struct wiphy *wiphy)
1210 {
1211 
1212 	return (linuxkpi_wiphy_to_ieee80211_hw(wiphy));
1213 }
1214 
1215 static inline void
1216 ieee80211_restart_hw(struct ieee80211_hw *hw)
1217 {
1218 	linuxkpi_ieee80211_restart_hw(hw);
1219 }
1220 
1221 static inline void
1222 ieee80211_hw_restart_disconnect(struct ieee80211_vif *vif)
1223 {
1224 	TODO();
1225 }
1226 
1227 /* -------------------------------------------------------------------------- */
1228 
1229 #define	link_conf_dereference_check(_vif, _linkid)			\
1230     rcu_dereference_check((_vif)->link_conf[_linkid], true)
1231 
1232 #define	link_conf_dereference_protected(_vif, _linkid)			\
1233     rcu_dereference_protected((_vif)->link_conf[_linkid], true)
1234 
1235 #define	link_sta_dereference_check(_sta, _linkid)			\
1236     rcu_dereference_check((_sta)->link[_linkid], true)
1237 
1238 #define	link_sta_dereference_protected(_sta, _linkid)			\
1239     rcu_dereference_protected((_sta)->link[_linkid], true)
1240 
1241 #define	for_each_vif_active_link(_vif, _link, _linkid)			\
1242     for (_linkid = 0; _linkid < nitems((_vif)->link_conf); _linkid++)	\
1243 	if ( ((_vif)->active_links == 0 /* no MLO */ ||			\
1244 	    ((_vif)->active_links & BIT(_linkid)) != 0) &&		\
1245 	    (_link = rcu_dereference((_vif)->link_conf[_linkid])) )
1246 
1247 #define	for_each_sta_active_link(_vif, _sta, _linksta, _linkid)		\
1248     for (_linkid = 0; _linkid < nitems((_vif)->link_conf); _linkid++)	\
1249 	if ( ((_vif)->active_links == 0 /* no MLO */ ||			\
1250 	    ((_vif)->active_links & BIT(_linkid)) != 0) &&		\
1251 	    (_linksta = link_sta_dereference_protected((_sta), (_linkid))) )
1252 
1253 /* -------------------------------------------------------------------------- */
1254 
1255 static __inline bool
1256 ieee80211_is_action(__le16 fc)
1257 {
1258 	__le16 v;
1259 
1260 	fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1261 	v = htole16(IEEE80211_FC0_SUBTYPE_ACTION | IEEE80211_FC0_TYPE_MGT);
1262 
1263 	return (fc == v);
1264 }
1265 
1266 static __inline bool
1267 ieee80211_is_probe_resp(__le16 fc)
1268 {
1269 	__le16 v;
1270 
1271 	fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1272 	v = htole16(IEEE80211_FC0_SUBTYPE_PROBE_RESP | IEEE80211_FC0_TYPE_MGT);
1273 
1274 	return (fc == v);
1275 }
1276 
1277 static __inline bool
1278 ieee80211_is_auth(__le16 fc)
1279 {
1280 	__le16 v;
1281 
1282 	fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1283 	v = htole16(IEEE80211_FC0_SUBTYPE_AUTH | IEEE80211_FC0_TYPE_MGT);
1284 
1285 	return (fc == v);
1286 }
1287 
1288 static __inline bool
1289 ieee80211_is_assoc_req(__le16 fc)
1290 {
1291 	__le16 v;
1292 
1293 	fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1294 	v = htole16(IEEE80211_FC0_SUBTYPE_ASSOC_REQ | IEEE80211_FC0_TYPE_MGT);
1295 
1296 	return (fc == v);
1297 }
1298 
1299 static __inline bool
1300 ieee80211_is_assoc_resp(__le16 fc)
1301 {
1302 	__le16 v;
1303 
1304 	fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1305 	v = htole16(IEEE80211_FC0_SUBTYPE_ASSOC_RESP | IEEE80211_FC0_TYPE_MGT);
1306 
1307 	return (fc == v);
1308 }
1309 
1310 static __inline bool
1311 ieee80211_is_reassoc_req(__le16 fc)
1312 {
1313 	__le16 v;
1314 
1315 	fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1316 	v = htole16(IEEE80211_FC0_SUBTYPE_REASSOC_REQ | IEEE80211_FC0_TYPE_MGT);
1317 
1318 	return (fc == v);
1319 }
1320 
1321 static __inline bool
1322 ieee80211_is_reassoc_resp(__le16 fc)
1323 {
1324 	__le16 v;
1325 
1326 	fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1327 	v = htole16(IEEE80211_FC0_SUBTYPE_REASSOC_RESP | IEEE80211_FC0_TYPE_MGT);
1328 
1329 	return (fc == v);
1330 }
1331 
1332 static __inline bool
1333 ieee80211_is_disassoc(__le16 fc)
1334 {
1335 	__le16 v;
1336 
1337 	fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1338 	v = htole16(IEEE80211_FC0_SUBTYPE_DISASSOC | IEEE80211_FC0_TYPE_MGT);
1339 
1340 	return (fc == v);
1341 }
1342 
1343 static __inline bool
1344 ieee80211_is_data_present(__le16 fc)
1345 {
1346 	__le16 v;
1347 
1348 	/* If it is a data frame and NODATA is not present. */
1349 	fc &= htole16(IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_NODATA);
1350 	v = htole16(IEEE80211_FC0_TYPE_DATA);
1351 
1352 	return (fc == v);
1353 }
1354 
1355 static __inline bool
1356 ieee80211_is_deauth(__le16 fc)
1357 {
1358 	__le16 v;
1359 
1360 	fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1361 	v = htole16(IEEE80211_FC0_SUBTYPE_DEAUTH | IEEE80211_FC0_TYPE_MGT);
1362 
1363 	return (fc == v);
1364 }
1365 
1366 static __inline bool
1367 ieee80211_is_beacon(__le16 fc)
1368 {
1369 	__le16 v;
1370 
1371 	/*
1372 	 * For as much as I get it this comes in LE and unlike FreeBSD
1373 	 * where we get the entire frame header and u8[], here we get the
1374 	 * 9.2.4.1 Frame Control field only. Mask and compare.
1375 	 */
1376 	fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1377 	v = htole16(IEEE80211_FC0_SUBTYPE_BEACON | IEEE80211_FC0_TYPE_MGT);
1378 
1379 	return (fc == v);
1380 }
1381 
1382 
1383 static __inline bool
1384 ieee80211_is_probe_req(__le16 fc)
1385 {
1386 	__le16 v;
1387 
1388 	fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1389 	v = htole16(IEEE80211_FC0_SUBTYPE_PROBE_REQ | IEEE80211_FC0_TYPE_MGT);
1390 
1391 	return (fc == v);
1392 }
1393 
1394 static __inline bool
1395 ieee80211_has_protected(__le16 fc)
1396 {
1397 
1398 	return (fc & htole16(IEEE80211_FC1_PROTECTED << 8));
1399 }
1400 
1401 static __inline bool
1402 ieee80211_is_back_req(__le16 fc)
1403 {
1404 	__le16 v;
1405 
1406 	fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1407 	v = htole16(IEEE80211_FC0_SUBTYPE_BAR | IEEE80211_FC0_TYPE_CTL);
1408 
1409 	return (fc == v);
1410 }
1411 
1412 static __inline bool
1413 ieee80211_is_bufferable_mmpdu(struct sk_buff *skb)
1414 {
1415 	struct ieee80211_mgmt *mgmt;
1416 	__le16 fc;
1417 
1418 	mgmt = (struct ieee80211_mgmt *)skb->data;
1419 	fc = mgmt->frame_control;
1420 
1421 	/* 11.2.2 Bufferable MMPDUs, 80211-2020. */
1422 	/* XXX we do not care about IBSS yet. */
1423 
1424 	if (!ieee80211_is_mgmt(fc))
1425 		return (false);
1426 	if (ieee80211_is_action(fc))		/* XXX FTM? */
1427 		return (true);			/* XXX false? */
1428 	if (ieee80211_is_disassoc(fc))
1429 		return (true);
1430 	if (ieee80211_is_deauth(fc))
1431 		return (true);
1432 
1433 	TODO();
1434 
1435 	return (false);
1436 }
1437 
1438 static __inline bool
1439 ieee80211_is_nullfunc(__le16 fc)
1440 {
1441 	__le16 v;
1442 
1443 	fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1444 	v = htole16(IEEE80211_FC0_SUBTYPE_NODATA | IEEE80211_FC0_TYPE_DATA);
1445 
1446 	return (fc == v);
1447 }
1448 
1449 static __inline bool
1450 ieee80211_is_qos_nullfunc(__le16 fc)
1451 {
1452 	__le16 v;
1453 
1454 	fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1455 	v = htole16(IEEE80211_FC0_SUBTYPE_QOS_NULL | IEEE80211_FC0_TYPE_DATA);
1456 
1457 	return (fc == v);
1458 }
1459 
1460 static __inline bool
1461 ieee80211_is_any_nullfunc(__le16 fc)
1462 {
1463 
1464 	return (ieee80211_is_nullfunc(fc) || ieee80211_is_qos_nullfunc(fc));
1465 }
1466 
1467 static inline bool
1468 ieee80211_is_pspoll(__le16 fc)
1469 {
1470 	__le16 v;
1471 
1472 	fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1473 	v = htole16(IEEE80211_FC0_SUBTYPE_PS_POLL | IEEE80211_FC0_TYPE_CTL);
1474 
1475 	return (fc == v);
1476 }
1477 
1478 static __inline bool
1479 ieee80211_vif_is_mesh(struct ieee80211_vif *vif)
1480 {
1481 	TODO();
1482 	return (false);
1483 }
1484 
1485 static __inline bool
1486 ieee80211_is_frag(struct ieee80211_hdr *hdr)
1487 {
1488 	TODO();
1489 	return (false);
1490 }
1491 
1492 static __inline bool
1493 ieee80211_is_first_frag(__le16 fc)
1494 {
1495 	TODO();
1496 	return (false);
1497 }
1498 
1499 static __inline bool
1500 ieee80211_is_robust_mgmt_frame(struct sk_buff *skb)
1501 {
1502 	TODO();
1503 	return (false);
1504 }
1505 
1506 static __inline bool
1507 ieee80211_is_ftm(struct sk_buff *skb)
1508 {
1509 	TODO();
1510 	return (false);
1511 }
1512 
1513 static __inline bool
1514 ieee80211_is_timing_measurement(struct sk_buff *skb)
1515 {
1516 	TODO();
1517 	return (false);
1518 }
1519 
1520 static __inline bool
1521 ieee80211_has_pm(__le16 fc)
1522 {
1523 	TODO();
1524 	return (false);
1525 }
1526 
1527 static __inline bool
1528 ieee80211_has_a4(__le16 fc)
1529 {
1530 	__le16 v;
1531 
1532 	fc &= htole16((IEEE80211_FC1_DIR_TODS | IEEE80211_FC1_DIR_FROMDS) << 8);
1533 	v = htole16((IEEE80211_FC1_DIR_TODS | IEEE80211_FC1_DIR_FROMDS) << 8);
1534 
1535 	return (fc == v);
1536 }
1537 
1538 static __inline bool
1539 ieee80211_has_order(__le16 fc)
1540 {
1541 
1542 	return (fc & htole16(IEEE80211_FC1_ORDER << 8));
1543 }
1544 
1545 static __inline bool
1546 ieee80211_has_retry(__le16 fc)
1547 {
1548 
1549 	return (fc & htole16(IEEE80211_FC1_RETRY << 8));
1550 }
1551 
1552 
1553 static __inline bool
1554 ieee80211_has_fromds(__le16 fc)
1555 {
1556 
1557 	return (fc & htole16(IEEE80211_FC1_DIR_FROMDS << 8));
1558 }
1559 
1560 static __inline bool
1561 ieee80211_has_tods(__le16 fc)
1562 {
1563 
1564 	return (fc & htole16(IEEE80211_FC1_DIR_TODS << 8));
1565 }
1566 
1567 static __inline uint8_t *
1568 ieee80211_get_SA(struct ieee80211_hdr *hdr)
1569 {
1570 
1571 	if (ieee80211_has_a4(hdr->frame_control))
1572 		return (hdr->addr4);
1573 	if (ieee80211_has_fromds(hdr->frame_control))
1574 		return (hdr->addr3);
1575 	return (hdr->addr2);
1576 }
1577 
1578 static __inline uint8_t *
1579 ieee80211_get_DA(struct ieee80211_hdr *hdr)
1580 {
1581 
1582 	if (ieee80211_has_tods(hdr->frame_control))
1583 		return (hdr->addr3);
1584 	return (hdr->addr1);
1585 }
1586 
1587 static __inline bool
1588 ieee80211_has_morefrags(__le16 fc)
1589 {
1590 
1591 	fc &= htole16(IEEE80211_FC1_MORE_FRAG << 8);
1592 	return (fc != 0);
1593 }
1594 
1595 static __inline u8 *
1596 ieee80211_get_qos_ctl(struct ieee80211_hdr *hdr)
1597 {
1598         if (ieee80211_has_a4(hdr->frame_control))
1599                 return (u8 *)hdr + 30;
1600         else
1601                 return (u8 *)hdr + 24;
1602 }
1603 
1604 /* -------------------------------------------------------------------------- */
1605 /* Receive functions (air/driver to mac80211/net80211). */
1606 
1607 
1608 static __inline void
1609 ieee80211_rx_napi(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
1610     struct sk_buff *skb, struct napi_struct *napi)
1611 {
1612 
1613 	linuxkpi_ieee80211_rx(hw, skb, sta, napi, NULL);
1614 }
1615 
1616 static __inline void
1617 ieee80211_rx_list(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
1618     struct sk_buff *skb, struct list_head *list)
1619 {
1620 
1621 	linuxkpi_ieee80211_rx(hw, skb, sta, NULL, list);
1622 }
1623 
1624 static __inline void
1625 ieee80211_rx_ni(struct ieee80211_hw *hw, struct sk_buff *skb)
1626 {
1627 
1628 	linuxkpi_ieee80211_rx(hw, skb, NULL, NULL, NULL);
1629 }
1630 
1631 static __inline void
1632 ieee80211_rx_irqsafe(struct ieee80211_hw *hw, struct sk_buff *skb)
1633 {
1634 
1635 	linuxkpi_ieee80211_rx(hw, skb, NULL, NULL, NULL);
1636 }
1637 
1638 static __inline void
1639 ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb)
1640 {
1641 
1642 	linuxkpi_ieee80211_rx(hw, skb, NULL, NULL, NULL);
1643 }
1644 
1645 /* -------------------------------------------------------------------------- */
1646 
1647 static inline void
1648 ieee80211_stop_queues(struct ieee80211_hw *hw)
1649 {
1650 	linuxkpi_ieee80211_stop_queues(hw);
1651 }
1652 
1653 static inline void
1654 ieee80211_wake_queues(struct ieee80211_hw *hw)
1655 {
1656 	linuxkpi_ieee80211_wake_queues(hw);
1657 }
1658 
1659 static inline void
1660 ieee80211_stop_queue(struct ieee80211_hw *hw, int qnum)
1661 {
1662 	linuxkpi_ieee80211_stop_queue(hw, qnum);
1663 }
1664 
1665 static inline void
1666 ieee80211_wake_queue(struct ieee80211_hw *hw, int qnum)
1667 {
1668 	linuxkpi_ieee80211_wake_queue(hw, qnum);
1669 }
1670 
1671 static inline void
1672 ieee80211_schedule_txq(struct ieee80211_hw *hw, struct ieee80211_txq *txq)
1673 {
1674 	linuxkpi_ieee80211_schedule_txq(hw, txq, true);
1675 }
1676 
1677 static inline void
1678 ieee80211_return_txq(struct ieee80211_hw *hw, struct ieee80211_txq *txq,
1679     bool withoutpkts)
1680 {
1681 	linuxkpi_ieee80211_schedule_txq(hw, txq, true);
1682 }
1683 
1684 static inline void
1685 ieee80211_txq_schedule_start(struct ieee80211_hw *hw, uint8_t ac)
1686 {
1687 	linuxkpi_ieee80211_txq_schedule_start(hw, ac);
1688 }
1689 
1690 static inline void
1691 ieee80211_txq_schedule_end(struct ieee80211_hw *hw, uint8_t ac)
1692 {
1693 	/* DO_NADA; */
1694 }
1695 
1696 static inline struct ieee80211_txq *
1697 ieee80211_next_txq(struct ieee80211_hw *hw, uint8_t ac)
1698 {
1699 	return (linuxkpi_ieee80211_next_txq(hw, ac));
1700 }
1701 
1702 static inline void
1703 ieee80211_handle_wake_tx_queue(struct ieee80211_hw *hw,
1704     struct ieee80211_txq *txq)
1705 {
1706 	TODO();
1707 }
1708 
1709 /* -------------------------------------------------------------------------- */
1710 
1711 static __inline uint8_t
1712 ieee80211_get_tid(struct ieee80211_hdr *hdr)
1713 {
1714 
1715 	return (linuxkpi_ieee80211_get_tid(hdr, false));
1716 }
1717 
1718 static __inline struct sk_buff *
1719 ieee80211_beacon_get_tim(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1720     uint16_t *tim_offset, uint16_t *tim_len, uint32_t link_id)
1721 {
1722 
1723 	if (tim_offset != NULL)
1724 		*tim_offset = 0;
1725 	if (tim_len != NULL)
1726 		*tim_len = 0;
1727 	TODO();
1728 	return (NULL);
1729 }
1730 
1731 static __inline void
1732 ieee80211_iterate_active_interfaces_atomic(struct ieee80211_hw *hw,
1733     enum ieee80211_iface_iter flags,
1734     void(*iterfunc)(void *, uint8_t *, struct ieee80211_vif *),
1735     void *arg)
1736 {
1737 
1738 	flags |= IEEE80211_IFACE_ITER__ATOMIC;
1739 	flags |= IEEE80211_IFACE_ITER_ACTIVE;
1740 	linuxkpi_ieee80211_iterate_interfaces(hw, flags, iterfunc, arg);
1741 }
1742 
1743 static __inline void
1744 ieee80211_iterate_active_interfaces(struct ieee80211_hw *hw,
1745     enum ieee80211_iface_iter flags,
1746     void(*iterfunc)(void *, uint8_t *, struct ieee80211_vif *),
1747     void *arg)
1748 {
1749 
1750 	flags |= IEEE80211_IFACE_ITER_ACTIVE;
1751 	linuxkpi_ieee80211_iterate_interfaces(hw, flags, iterfunc, arg);
1752 }
1753 
1754 static __inline void
1755 ieee80211_iterate_active_interfaces_mtx(struct ieee80211_hw *hw,
1756     enum ieee80211_iface_iter flags,
1757     void(*iterfunc)(void *, uint8_t *, struct ieee80211_vif *),
1758     void *arg)
1759 {
1760 	flags |= IEEE80211_IFACE_ITER_ACTIVE;
1761 	flags |= IEEE80211_IFACE_ITER__MTX;
1762 	linuxkpi_ieee80211_iterate_interfaces(hw, flags, iterfunc, arg);
1763 }
1764 
1765 static __inline void
1766 ieee80211_iterate_interfaces(struct ieee80211_hw *hw,
1767    enum ieee80211_iface_iter flags,
1768    void (*iterfunc)(void *, uint8_t *, struct ieee80211_vif *),
1769    void *arg)
1770 {
1771 
1772 	linuxkpi_ieee80211_iterate_interfaces(hw, flags, iterfunc, arg);
1773 }
1774 
1775 static __inline void
1776 ieee80211_iter_keys(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1777     void(*iterfunc)(struct ieee80211_hw *, struct ieee80211_vif *,
1778         struct ieee80211_sta *, struct ieee80211_key_conf *, void *),
1779     void *arg)
1780 {
1781 
1782 	linuxkpi_ieee80211_iterate_keys(hw, vif, iterfunc, arg);
1783 }
1784 
1785 static __inline void
1786 ieee80211_iter_keys_rcu(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1787     void(*iterfunc)(struct ieee80211_hw *, struct ieee80211_vif *,
1788         struct ieee80211_sta *, struct ieee80211_key_conf *, void *),
1789     void *arg)
1790 {
1791 
1792 	IMPROVE();	/* "rcu" */
1793 	linuxkpi_ieee80211_iterate_keys(hw, vif, iterfunc, arg);
1794 }
1795 
1796 static __inline void
1797 ieee80211_iter_chan_contexts_atomic(struct ieee80211_hw *hw,
1798     void(*iterfunc)(struct ieee80211_hw *, struct ieee80211_chanctx_conf *, void *),
1799     void *arg)
1800 {
1801 
1802 	linuxkpi_ieee80211_iterate_chan_contexts(hw, iterfunc, arg);
1803 }
1804 
1805 static __inline void
1806 ieee80211_iterate_stations_atomic(struct ieee80211_hw *hw,
1807    void (*iterfunc)(void *, struct ieee80211_sta *), void *arg)
1808 {
1809 
1810 	linuxkpi_ieee80211_iterate_stations_atomic(hw, iterfunc, arg);
1811 }
1812 
1813 static __inline struct wireless_dev *
1814 ieee80211_vif_to_wdev(struct ieee80211_vif *vif)
1815 {
1816 
1817 	return (linuxkpi_ieee80211_vif_to_wdev(vif));
1818 }
1819 
1820 static __inline struct sk_buff *
1821 ieee80211_beacon_get_template(struct ieee80211_hw *hw,
1822     struct ieee80211_vif *vif, struct ieee80211_mutable_offsets *offs,
1823     uint32_t link_id)
1824 {
1825 	TODO();
1826 	return (NULL);
1827 }
1828 
1829 static __inline void
1830 ieee80211_beacon_loss(struct ieee80211_vif *vif)
1831 {
1832 	linuxkpi_ieee80211_beacon_loss(vif);
1833 }
1834 
1835 static __inline void
1836 ieee80211_chswitch_done(struct ieee80211_vif *vif, bool t)
1837 {
1838 	TODO();
1839 }
1840 
1841 static __inline bool
1842 ieee80211_csa_is_complete(struct ieee80211_vif *vif)
1843 {
1844 	TODO();
1845 	return (false);
1846 }
1847 
1848 static __inline void
1849 ieee80211_csa_set_counter(struct ieee80211_vif *vif, uint8_t counter)
1850 {
1851 	TODO();
1852 }
1853 
1854 static __inline int
1855 ieee80211_csa_update_counter(struct ieee80211_vif *vif)
1856 {
1857 	TODO();
1858 	return (-1);
1859 }
1860 
1861 static __inline void
1862 ieee80211_csa_finish(struct ieee80211_vif *vif)
1863 {
1864 	TODO();
1865 }
1866 
1867 static __inline enum nl80211_iftype
1868 ieee80211_vif_type_p2p(struct ieee80211_vif *vif)
1869 {
1870 
1871 	/* If we are not p2p enabled, just return the type. */
1872 	if (!vif->p2p)
1873 		return (vif->type);
1874 
1875 	/* If we are p2p, depending on side, return type. */
1876 	switch (vif->type) {
1877 	case NL80211_IFTYPE_AP:
1878 		return (NL80211_IFTYPE_P2P_GO);
1879 	case NL80211_IFTYPE_STATION:
1880 		return (NL80211_IFTYPE_P2P_CLIENT);
1881 	default:
1882 		fallthrough;
1883 	}
1884 	return (vif->type);
1885 }
1886 
1887 static __inline unsigned long
1888 ieee80211_tu_to_usec(unsigned long tu)
1889 {
1890 
1891 	return (tu * IEEE80211_DUR_TU);
1892 }
1893 
1894 /*
1895  * Below we assume that the two values from different emums are the same.
1896  * Make sure this does not accidentally change.
1897  */
1898 CTASSERT((int)IEEE80211_ACTION_SM_TPCREP == (int)IEEE80211_ACTION_RADIO_MEASUREMENT_LMREP);
1899 
1900 static __inline bool
1901 ieee80211_action_contains_tpc(struct sk_buff *skb)
1902 {
1903 	struct ieee80211_mgmt *mgmt;
1904 
1905 	mgmt = (struct ieee80211_mgmt *)skb->data;
1906 
1907 	/* Check that this is a mgmt/action frame? */
1908 	if (!ieee80211_is_action(mgmt->frame_control))
1909 		return (false);
1910 
1911 	/*
1912 	 * This is a bit convoluted but according to docs both actions
1913 	 * are checked for this.  Kind-of makes sense for the only consumer
1914 	 * (iwlwifi) I am aware off given the txpower fields are at the
1915 	 * same location so firmware can update the value.
1916 	 */
1917 	/* 80211-2020 9.6.2 Spectrum Management Action frames */
1918 	/* 80211-2020 9.6.2.5 TPC Report frame format */
1919 	/* 80211-2020 9.6.6 Radio Measurement action details */
1920 	/* 80211-2020 9.6.6.4 Link Measurement Report frame format */
1921 	/* Check that it is Spectrum Management or Radio Measurement? */
1922 	if (mgmt->u.action.category != IEEE80211_ACTION_CAT_SM &&
1923 	    mgmt->u.action.category != IEEE80211_ACTION_CAT_RADIO_MEASUREMENT)
1924 		return (false);
1925 
1926 	/*
1927 	 * Check that it is TPC Report or Link Measurement Report?
1928 	 * The values of each are the same (see CTASSERT above function).
1929 	 */
1930 	if (mgmt->u.action.u.tpc_report.spec_mgmt != IEEE80211_ACTION_SM_TPCREP)
1931 		return (false);
1932 
1933 	/* 80211-2020 9.4.2.16 TPC Report element */
1934 	/* Check that the ELEMID and length are correct? */
1935 	if (mgmt->u.action.u.tpc_report.tpc_elem_id != IEEE80211_ELEMID_TPCREP ||
1936 	    mgmt->u.action.u.tpc_report.tpc_elem_length != 4)
1937 		return (false);
1938 
1939 	/* All the right fields in the right place. */
1940 	return (true);
1941 }
1942 
1943 static __inline void
1944 ieee80211_connection_loss(struct ieee80211_vif *vif)
1945 {
1946 
1947 	linuxkpi_ieee80211_connection_loss(vif);
1948 }
1949 
1950 static __inline struct ieee80211_sta *
1951 ieee80211_find_sta(struct ieee80211_vif *vif, const u8 *peer)
1952 {
1953 
1954 	return (linuxkpi_ieee80211_find_sta(vif, peer));
1955 }
1956 
1957 static __inline struct ieee80211_sta *
1958 ieee80211_find_sta_by_ifaddr(struct ieee80211_hw *hw, const uint8_t *addr,
1959     const uint8_t *ourvifaddr)
1960 {
1961 
1962 	return (linuxkpi_ieee80211_find_sta_by_ifaddr(hw, addr, ourvifaddr));
1963 }
1964 
1965 
1966 static __inline void
1967 ieee80211_get_tkip_p2k(struct ieee80211_key_conf *keyconf,
1968     struct sk_buff *skb_frag, u8 *key)
1969 {
1970 	TODO();
1971 }
1972 
1973 static __inline void
1974 ieee80211_get_tkip_rx_p1k(struct ieee80211_key_conf *keyconf,
1975     const u8 *addr, uint32_t iv32, u16 *p1k)
1976 {
1977 
1978 	KASSERT(keyconf != NULL && addr != NULL && p1k != NULL,
1979 	    ("%s: keyconf %p addr %p p1k %p\n", __func__, keyconf, addr, p1k));
1980 
1981 	TODO();
1982 	memset(p1k, 0xfa, 5 * sizeof(*p1k));	/* Just initializing. */
1983 }
1984 
1985 static __inline size_t
1986 ieee80211_ie_split(const u8 *ies, size_t ies_len,
1987     const u8 *ie_ids, size_t ie_ids_len, size_t start)
1988 {
1989 	size_t x;
1990 
1991 	x = start;
1992 
1993 	/* XXX FIXME, we need to deal with "Element ID Extension" */
1994 	while (x < ies_len) {
1995 
1996 		/* Is this IE[s] one of the ie_ids? */
1997 		if (!linuxkpi_ieee80211_is_ie_id_in_ie_buf(ies[x],
1998 		    ie_ids, ie_ids_len))
1999 			break;
2000 
2001 		if (!linuxkpi_ieee80211_ie_advance(&x, ies, ies_len))
2002 			break;
2003 	}
2004 
2005 	return (x);
2006 }
2007 
2008 static __inline void
2009 ieee80211_request_smps(struct ieee80211_vif *vif, u_int link_id,
2010     enum ieee80211_smps_mode smps)
2011 {
2012 	static const char *smps_mode_name[] = {
2013 		"SMPS_OFF",
2014 		"SMPS_STATIC",
2015 		"SMPS_DYNAMIC",
2016 		"SMPS_AUTOMATIC",
2017 		"SMPS_NUM_MODES"
2018 	};
2019 
2020 	if (linuxkpi_debug_80211 & D80211_TODO)
2021 		printf("%s:%d: XXX LKPI80211 TODO smps %d %s\n",
2022 		    __func__, __LINE__, smps, smps_mode_name[smps]);
2023 }
2024 
2025 static __inline void
2026 ieee80211_tdls_oper_request(struct ieee80211_vif *vif, uint8_t *addr,
2027     enum nl80211_tdls_operation oper, enum ieee80211_reason_code code,
2028     gfp_t gfp)
2029 {
2030 	TODO();
2031 }
2032 
2033 static __inline void
2034 wiphy_rfkill_set_hw_state(struct wiphy *wiphy, bool state)
2035 {
2036 	TODO();
2037 }
2038 
2039 static __inline void
2040 ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb)
2041 {
2042 	IMPROVE();
2043 
2044 	/*
2045 	 * This is called on transmit failure.
2046 	 * Use a not-so-random random high status error so we can distinguish
2047 	 * it from normal low values flying around in net80211 ("ETX").
2048 	 */
2049 	linuxkpi_ieee80211_free_txskb(hw, skb, 0x455458);
2050 }
2051 
2052 static __inline void
2053 ieee80211_ready_on_channel(struct ieee80211_hw *hw)
2054 {
2055 	TODO();
2056 /* XXX-BZ We need to see that. */
2057 }
2058 
2059 static __inline void
2060 ieee80211_remain_on_channel_expired(struct ieee80211_hw *hw)
2061 {
2062 	TODO();
2063 }
2064 
2065 static __inline void
2066 ieee80211_cqm_rssi_notify(struct ieee80211_vif *vif,
2067     enum nl80211_cqm_rssi_threshold_event crte, int sig, gfp_t gfp)
2068 {
2069 	TODO();
2070 }
2071 
2072 static __inline void
2073 ieee80211_mark_rx_ba_filtered_frames(struct ieee80211_sta *sta, uint8_t tid,
2074     uint32_t ssn, uint64_t bitmap, uint16_t received_mpdu)
2075 {
2076 	TODO();
2077 }
2078 
2079 static __inline bool
2080 ieee80211_sn_less(uint16_t sn1, uint16_t sn2)
2081 {
2082 	TODO();
2083 	return (false);
2084 }
2085 
2086 static __inline uint16_t
2087 ieee80211_sn_inc(uint16_t sn)
2088 {
2089 	TODO();
2090 	return (sn + 1);
2091 }
2092 
2093 static __inline uint16_t
2094 ieee80211_sn_add(uint16_t sn, uint16_t a)
2095 {
2096 	TODO();
2097 	return (sn + a);
2098 }
2099 
2100 static __inline void
2101 ieee80211_stop_rx_ba_session(struct ieee80211_vif *vif, uint32_t x, uint8_t *addr)
2102 {
2103 	TODO();
2104 }
2105 
2106 static __inline void
2107 ieee80211_rate_set_vht(struct ieee80211_tx_rate *r, uint32_t f1, uint32_t f2)
2108 {
2109 	TODO();
2110 }
2111 
2112 static __inline uint8_t
2113 ieee80211_rate_get_vht_nss(struct ieee80211_tx_rate *r)
2114 {
2115 	TODO();
2116 	return (0);
2117 }
2118 
2119 static __inline uint8_t
2120 ieee80211_rate_get_vht_mcs(struct ieee80211_tx_rate *r)
2121 {
2122 	TODO();
2123 	return (0);
2124 }
2125 
2126 static __inline void
2127 ieee80211_reserve_tid(struct ieee80211_sta *sta, uint8_t tid)
2128 {
2129 	TODO();
2130 }
2131 
2132 static __inline void
2133 ieee80211_unreserve_tid(struct ieee80211_sta *sta, uint8_t tid)
2134 {
2135 	TODO();
2136 }
2137 
2138 static __inline void
2139 ieee80211_rx_ba_timer_expired(struct ieee80211_vif *vif, uint8_t *addr,
2140     uint8_t tid)
2141 {
2142 	TODO();
2143 }
2144 
2145 static __inline void
2146 ieee80211_send_eosp_nullfunc(struct ieee80211_sta *sta, uint8_t tid)
2147 {
2148 	TODO();
2149 }
2150 
2151 static __inline uint16_t
2152 ieee80211_sn_sub(uint16_t sa, uint16_t sb)
2153 {
2154 
2155 	return ((sa - sb) &
2156 	    (IEEE80211_SEQ_SEQ_MASK >> IEEE80211_SEQ_SEQ_SHIFT));
2157 }
2158 
2159 static __inline void
2160 ieee80211_sta_block_awake(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
2161     bool disable)
2162 {
2163 	TODO();
2164 }
2165 
2166 static __inline void
2167 ieee80211_sta_ps_transition(struct ieee80211_sta *sta, bool sleeping)
2168 {
2169 	TODO();
2170 }
2171 
2172 static __inline void
2173 ieee80211_sta_pspoll(struct ieee80211_sta *sta)
2174 {
2175 	TODO();
2176 }
2177 
2178 static __inline void
2179 ieee80211_sta_recalc_aggregates(struct ieee80211_sta *sta)
2180 {
2181 	TODO();
2182 }
2183 
2184 static __inline void
2185 ieee80211_sta_uapsd_trigger(struct ieee80211_sta *sta, int ntids)
2186 {
2187 	TODO();
2188 }
2189 
2190 static __inline void
2191 ieee80211_tkip_add_iv(u8 *crypto_hdr, struct ieee80211_key_conf *keyconf,
2192     uint64_t pn)
2193 {
2194 	TODO();
2195 }
2196 
2197 static __inline struct sk_buff *
2198 ieee80211_tx_dequeue(struct ieee80211_hw *hw, struct ieee80211_txq *txq)
2199 {
2200 
2201 	return (linuxkpi_ieee80211_tx_dequeue(hw, txq));
2202 }
2203 
2204 static __inline void
2205 ieee80211_update_mu_groups(struct ieee80211_vif *vif,
2206     u_int _i, uint8_t *ms, uint8_t *up)
2207 {
2208 	TODO();
2209 }
2210 
2211 static __inline void
2212 ieee80211_sta_set_buffered(struct ieee80211_sta *sta, uint8_t tid, bool t)
2213 {
2214 	TODO();
2215 }
2216 
2217 static __inline void
2218 ieee80211_get_key_rx_seq(struct ieee80211_key_conf *keyconf, uint8_t tid,
2219     struct ieee80211_key_seq *seq)
2220 {
2221 
2222 	KASSERT(keyconf != NULL && seq != NULL, ("%s: keyconf %p seq %p\n",
2223 	    __func__, keyconf, seq));
2224 
2225 	TODO();
2226 	switch (keyconf->cipher) {
2227 	case WLAN_CIPHER_SUITE_CCMP:
2228 	case WLAN_CIPHER_SUITE_CCMP_256:
2229 		memset(seq->ccmp.pn, 0xfa, sizeof(seq->ccmp.pn));	/* XXX TODO */
2230 		break;
2231 	case WLAN_CIPHER_SUITE_AES_CMAC:
2232 		memset(seq->aes_cmac.pn, 0xfa, sizeof(seq->aes_cmac.pn));	/* XXX TODO */
2233 		break;
2234 	case WLAN_CIPHER_SUITE_TKIP:
2235 		seq->tkip.iv32 = 0xfa;		/* XXX TODO */
2236 		seq->tkip.iv16 = 0xfa;		/* XXX TODO */
2237 		break;
2238 	default:
2239 		pr_debug("%s: unsupported cipher suite %d\n", __func__, keyconf->cipher);
2240 		break;
2241 	}
2242 }
2243 
2244 static __inline void
2245 ieee80211_sched_scan_results(struct ieee80211_hw *hw)
2246 {
2247 	TODO();
2248 }
2249 
2250 static __inline void
2251 ieee80211_sta_eosp(struct ieee80211_sta *sta)
2252 {
2253 	TODO();
2254 }
2255 
2256 static __inline int
2257 ieee80211_start_tx_ba_session(struct ieee80211_sta *sta, uint8_t tid, int x)
2258 {
2259 	TODO("rtw8x");
2260 	return (-EINVAL);
2261 }
2262 
2263 static __inline int
2264 ieee80211_stop_tx_ba_session(struct ieee80211_sta *sta, uint8_t tid)
2265 {
2266 	TODO("rtw89");
2267 	return (-EINVAL);
2268 }
2269 
2270 static __inline void
2271 ieee80211_start_tx_ba_cb_irqsafe(struct ieee80211_vif *vif, uint8_t *addr,
2272     uint8_t tid)
2273 {
2274 	TODO("iwlwifi");
2275 }
2276 
2277 static __inline void
2278 ieee80211_stop_tx_ba_cb_irqsafe(struct ieee80211_vif *vif, uint8_t *addr,
2279     uint8_t tid)
2280 {
2281 	TODO("iwlwifi/rtw8x/...");
2282 }
2283 
2284 static __inline void
2285 ieee80211_sched_scan_stopped(struct ieee80211_hw *hw)
2286 {
2287 	TODO();
2288 }
2289 
2290 static __inline void
2291 ieee80211_scan_completed(struct ieee80211_hw *hw,
2292     struct cfg80211_scan_info *info)
2293 {
2294 
2295 	linuxkpi_ieee80211_scan_completed(hw, info);
2296 }
2297 
2298 static __inline struct sk_buff *
2299 ieee80211_beacon_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
2300     uint32_t link_id)
2301 {
2302 	TODO();
2303 	return (NULL);
2304 }
2305 
2306 static __inline struct sk_buff *
2307 ieee80211_pspoll_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
2308 {
2309 
2310 	/* Only STA needs this.  Otherwise return NULL and panic bad drivers. */
2311 	if (vif->type != NL80211_IFTYPE_STATION)
2312 		return (NULL);
2313 
2314 	return (linuxkpi_ieee80211_pspoll_get(hw, vif));
2315 }
2316 
2317 static __inline struct sk_buff *
2318 ieee80211_proberesp_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
2319 {
2320 	TODO();
2321 	return (NULL);
2322 }
2323 
2324 static __inline struct sk_buff *
2325 ieee80211_nullfunc_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
2326     int linkid, bool qos)
2327 {
2328 
2329 	/* Only STA needs this.  Otherwise return NULL and panic bad drivers. */
2330 	if (vif->type != NL80211_IFTYPE_STATION)
2331 		return (NULL);
2332 
2333 	return (linuxkpi_ieee80211_nullfunc_get(hw, vif, linkid, qos));
2334 }
2335 
2336 static __inline struct sk_buff *
2337 ieee80211_probereq_get(struct ieee80211_hw *hw, uint8_t *addr,
2338     uint8_t *ssid, size_t ssid_len, size_t tailroom)
2339 {
2340 
2341 	return (linuxkpi_ieee80211_probereq_get(hw, addr, ssid, ssid_len,
2342 	    tailroom));
2343 }
2344 
2345 static __inline void
2346 ieee80211_queue_delayed_work(struct ieee80211_hw *hw, struct delayed_work *w,
2347     int delay)
2348 {
2349 
2350 	linuxkpi_ieee80211_queue_delayed_work(hw, w, delay);
2351 }
2352 
2353 static __inline void
2354 ieee80211_queue_work(struct ieee80211_hw *hw, struct work_struct *w)
2355 {
2356 
2357 	linuxkpi_ieee80211_queue_work(hw, w);
2358 }
2359 
2360 static __inline void
2361 ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)
2362 {
2363 
2364 	linuxkpi_ieee80211_tx_status(hw, skb);
2365 }
2366 
2367 static __inline void
2368 ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw, struct sk_buff *skb)
2369 {
2370 	IMPROVE();
2371 	ieee80211_tx_status(hw, skb);
2372 }
2373 
2374 static __inline void
2375 ieee80211_tx_status_ni(struct ieee80211_hw *hw, struct sk_buff *skb)
2376 {
2377 	IMPROVE();
2378 	ieee80211_tx_status(hw, skb);
2379 }
2380 
2381 static __inline void
2382 ieee80211_tx_status_ext(struct ieee80211_hw *hw,
2383     struct ieee80211_tx_status *txstat)
2384 {
2385 
2386 	linuxkpi_ieee80211_tx_status_ext(hw, txstat);
2387 }
2388 
2389 static __inline void
2390 ieee80211_tx_info_clear_status(struct ieee80211_tx_info *info)
2391 {
2392 	int i;
2393 
2394 	/*
2395 	 * Apparently clearing flags and some other fields is not right.
2396 	 * Given the function is called "status" we work on that part of
2397 	 * the union.
2398 	 */
2399 	for (i = 0; i < nitems(info->status.rates); i++)
2400 		info->status.rates[i].count = 0;
2401 	/*
2402 	 * Unclear if ack_signal should be included or not but we clear the
2403 	 * "valid" bool so this field is no longer valid.
2404 	 */
2405 	memset(&info->status.ack_signal, 0, sizeof(*info) -
2406 	    offsetof(struct ieee80211_tx_info, status.ack_signal));
2407 }
2408 
2409 static __inline void
2410 ieee80211_txq_get_depth(struct ieee80211_txq *txq, unsigned long *frame_cnt,
2411     unsigned long *byte_cnt)
2412 {
2413 
2414 	if (frame_cnt == NULL && byte_cnt == NULL)
2415 		return;
2416 
2417 	linuxkpi_ieee80211_txq_get_depth(txq, frame_cnt, byte_cnt);
2418 }
2419 
2420 static __inline int
2421 rate_lowest_index(struct ieee80211_supported_band *band,
2422     struct ieee80211_sta *sta)
2423 {
2424 	IMPROVE();
2425 	return (0);
2426 }
2427 
2428 
2429 static __inline void
2430 SET_IEEE80211_PERM_ADDR	(struct ieee80211_hw *hw, uint8_t *addr)
2431 {
2432 
2433 	ether_addr_copy(hw->wiphy->perm_addr, addr);
2434 }
2435 
2436 static __inline void
2437 ieee80211_report_low_ack(struct ieee80211_sta *sta, int x)
2438 {
2439 	TODO();
2440 }
2441 
2442 static __inline void
2443 ieee80211_start_rx_ba_session_offl(struct ieee80211_vif *vif, uint8_t *addr,
2444     uint8_t tid)
2445 {
2446 	TODO();
2447 }
2448 
2449 static __inline void
2450 ieee80211_stop_rx_ba_session_offl(struct ieee80211_vif *vif, uint8_t *addr,
2451     uint8_t tid)
2452 {
2453 	TODO();
2454 }
2455 
2456 static __inline struct sk_buff *
2457 ieee80211_tx_dequeue_ni(struct ieee80211_hw *hw, struct ieee80211_txq *txq)
2458 {
2459 	TODO();
2460 	return (NULL);
2461 }
2462 
2463 static __inline void
2464 ieee80211_tx_rate_update(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
2465     struct ieee80211_tx_info *info)
2466 {
2467 	TODO();
2468 }
2469 
2470 static __inline bool
2471 ieee80211_txq_may_transmit(struct ieee80211_hw *hw, struct ieee80211_txq *txq)
2472 {
2473 	TODO();
2474 	return (false);
2475 }
2476 
2477 static __inline void
2478 ieee80211_radar_detected(struct ieee80211_hw *hw)
2479 {
2480 	TODO();
2481 }
2482 
2483 static __inline void
2484 ieee80211_sta_register_airtime(struct ieee80211_sta *sta,
2485     uint8_t tid, uint32_t duration, int x)
2486 {
2487 	TODO();
2488 }
2489 
2490 static __inline void
2491 ieee80211_beacon_set_cntdwn(struct ieee80211_vif *vif, u8 counter)
2492 {
2493 	TODO();
2494 }
2495 
2496 static __inline int
2497 ieee80211_beacon_update_cntdwn(struct ieee80211_vif *vif)
2498 {
2499 	TODO();
2500 	return (-1);
2501 }
2502 
2503 static __inline int
2504 ieee80211_get_vht_max_nss(struct ieee80211_vht_cap *vht_cap, uint32_t chanwidth,
2505     int x, bool t, int nss)
2506 {
2507 	TODO();
2508 	return (-1);
2509 }
2510 
2511 static __inline bool
2512 ieee80211_beacon_cntdwn_is_complete(struct ieee80211_vif *vif)
2513 {
2514 	TODO();
2515 	return (true);
2516 }
2517 
2518 static __inline void
2519 ieee80211_disconnect(struct ieee80211_vif *vif, bool _x)
2520 {
2521 	TODO();
2522 }
2523 
2524 static __inline void
2525 ieee80211_channel_switch_disconnect(struct ieee80211_vif *vif, bool _x)
2526 {
2527 	TODO();
2528 }
2529 
2530 static __inline const struct ieee80211_sta_he_cap *
2531 ieee80211_get_he_iftype_cap(const struct ieee80211_supported_band *band,
2532     enum nl80211_iftype type)
2533 {
2534 	TODO();
2535         return (NULL);
2536 }
2537 
2538 static __inline void
2539 ieee80211_key_mic_failure(struct ieee80211_key_conf *key)
2540 {
2541 	TODO();
2542 }
2543 
2544 static __inline void
2545 ieee80211_key_replay(struct ieee80211_key_conf *key)
2546 {
2547 	TODO();
2548 }
2549 
2550 static __inline uint32_t
2551 ieee80211_calc_rx_airtime(struct ieee80211_hw *hw,
2552     struct ieee80211_rx_status *rxstat, int len)
2553 {
2554 	TODO();
2555 	return (0);
2556 }
2557 
2558 static __inline void
2559 ieee80211_get_tx_rates(struct ieee80211_vif *vif, struct ieee80211_sta *sta,
2560     struct sk_buff *skb, struct ieee80211_tx_rate *txrate, int nrates)
2561 {
2562 	TODO();
2563 }
2564 
2565 static __inline void
2566 ieee80211_color_change_finish(struct ieee80211_vif *vif)
2567 {
2568 	TODO();
2569 }
2570 
2571 static __inline struct sk_buff *
2572 ieee80211_get_fils_discovery_tmpl(struct ieee80211_hw *hw,
2573     struct ieee80211_vif *vif)
2574 {
2575 	TODO();
2576 	return (NULL);
2577 }
2578 
2579 static __inline struct sk_buff *
2580 ieee80211_get_unsol_bcast_probe_resp_tmpl(struct ieee80211_hw *hw,
2581     struct ieee80211_vif *vif)
2582 {
2583 	TODO();
2584 	return (NULL);
2585 }
2586 
2587 static __inline void
2588 linuxkpi_ieee80211_send_bar(struct ieee80211_vif *vif, uint8_t *ra, uint16_t tid,
2589     uint16_t ssn)
2590 {
2591 	TODO();
2592 }
2593 
2594 static __inline void
2595 ieee80211_resume_disconnect(struct ieee80211_vif *vif)
2596 {
2597         TODO();
2598 }
2599 
2600 static __inline int
2601 ieee80211_data_to_8023(struct sk_buff *skb, const uint8_t *addr,
2602      enum nl80211_iftype iftype)
2603 {
2604         TODO();
2605         return (-1);
2606 }
2607 
2608 static __inline void
2609 ieee80211_get_tkip_p1k_iv(struct ieee80211_key_conf *key,
2610     uint32_t iv32, uint16_t *p1k)
2611 {
2612         TODO();
2613 }
2614 
2615 static __inline struct ieee80211_key_conf *
2616 ieee80211_gtk_rekey_add(struct ieee80211_vif *vif,
2617     struct ieee80211_key_conf *key)
2618 {
2619         TODO();
2620         return (NULL);
2621 }
2622 
2623 static __inline void
2624 ieee80211_gtk_rekey_notify(struct ieee80211_vif *vif, const uint8_t *bssid,
2625     const uint8_t *replay_ctr, gfp_t gfp)
2626 {
2627         TODO();
2628 }
2629 
2630 static __inline void
2631 ieee80211_remove_key(struct ieee80211_key_conf *key)
2632 {
2633         TODO();
2634 }
2635 
2636 static __inline void
2637 ieee80211_set_key_rx_seq(struct ieee80211_key_conf *key, int tid,
2638     struct ieee80211_key_seq *seq)
2639 {
2640         TODO();
2641 }
2642 
2643 static __inline void
2644 ieee80211_report_wowlan_wakeup(struct ieee80211_vif *vif,
2645     struct cfg80211_wowlan_wakeup *wakeup, gfp_t gfp)
2646 {
2647         TODO();
2648 }
2649 
2650 static __inline void
2651 ieee80211_obss_color_collision_notify(struct ieee80211_vif *vif,
2652     uint64_t obss_color_bitmap, gfp_t gfp)
2653 {
2654 	TODO();
2655 }
2656 
2657 static __inline void
2658 ieee80211_refresh_tx_agg_session_timer(struct ieee80211_sta *sta,
2659     uint8_t tid)
2660 {
2661 	TODO();
2662 }
2663 
2664 static __inline struct ieee80211_ema_beacons *
2665 ieee80211_beacon_get_template_ema_list(struct ieee80211_hw *hw,
2666     struct ieee80211_vif *vif, uint32_t link_id)
2667 {
2668 	TODO();
2669 	return (NULL);
2670 }
2671 
2672 static __inline void
2673 ieee80211_beacon_free_ema_list(struct ieee80211_ema_beacons *bcns)
2674 {
2675 	TODO();
2676 }
2677 
2678 static inline bool
2679 ieee80211_vif_is_mld(const struct ieee80211_vif *vif)
2680 {
2681 
2682 	/* If valid_links is non-zero, the vif is an MLD. */
2683 	return (vif->valid_links != 0);
2684 }
2685 
2686 static __inline const struct ieee80211_sta_he_cap *
2687 ieee80211_get_he_iftype_cap_vif(const struct ieee80211_supported_band *band,
2688     struct ieee80211_vif *vif)
2689 {
2690 	TODO();
2691 	return (NULL);
2692 }
2693 
2694 static __inline const struct ieee80211_sta_eht_cap *
2695 ieee80211_get_eht_iftype_cap_vif(const struct ieee80211_supported_band *band,
2696     struct ieee80211_vif *vif)
2697 {
2698 	TODO();
2699 	return (NULL);
2700 }
2701 
2702 #define	ieee80211_send_bar(_v, _r, _t, _s)				\
2703     linuxkpi_ieee80211_send_bar(_v, _r, _t, _s)
2704 
2705 #endif	/* _LINUXKPI_NET_MAC80211_H */
2706