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