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