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