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