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