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