xref: /freebsd/sys/compat/linuxkpi/common/include/net/cfg80211.h (revision b5daf675efc746611c7cfcd1fa474b8905064c4b)
1 /*-
2  * Copyright (c) 2020-2025 The FreeBSD Foundation
3  * Copyright (c) 2021-2022 Bjoern A. Zeeb
4  *
5  * This software was developed by Björn Zeeb under sponsorship from
6  * the FreeBSD Foundation.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  */
29 
30 #ifndef	_LINUXKPI_NET_CFG80211_H
31 #define	_LINUXKPI_NET_CFG80211_H
32 
33 #include <linux/types.h>
34 #include <linux/nl80211.h>
35 #include <linux/ieee80211.h>
36 #include <linux/mutex.h>
37 #include <linux/if_ether.h>
38 #include <linux/ethtool.h>
39 #include <linux/debugfs.h>
40 #include <linux/device.h>
41 #include <linux/netdevice.h>
42 #include <linux/random.h>
43 #include <linux/skbuff.h>
44 #include <linux/timer.h>
45 #include <linux/workqueue.h>
46 #include <net/regulatory.h>
47 
48 #include <net80211/ieee80211.h>
49 
50 /* linux_80211.c */
51 extern int linuxkpi_debug_80211;
52 #ifndef	D80211_TODO
53 #define	D80211_TODO		0x1
54 #endif
55 #ifndef	D80211_IMPROVE
56 #define	D80211_IMPROVE		0x2
57 #endif
58 #define	TODO(fmt, ...)		if (linuxkpi_debug_80211 & D80211_TODO)	\
59     printf("%s:%d: XXX LKPI80211 TODO " fmt "\n",  __func__, __LINE__, ##__VA_ARGS__)
60 #define	IMPROVE(...)	if (linuxkpi_debug_80211 & D80211_IMPROVE)	\
61     printf("%s:%d: XXX LKPI80211 IMPROVE\n", __func__, __LINE__)
62 
63 enum rfkill_hard_block_reasons {
64 	RFKILL_HARD_BLOCK_NOT_OWNER		= BIT(0),
65 };
66 
67 #define	WIPHY_PARAM_FRAG_THRESHOLD			__LINE__ /* TODO FIXME brcmfmac */
68 #define	WIPHY_PARAM_RETRY_LONG				__LINE__ /* TODO FIXME brcmfmac */
69 #define	WIPHY_PARAM_RETRY_SHORT				__LINE__ /* TODO FIXME brcmfmac */
70 #define	WIPHY_PARAM_RTS_THRESHOLD			__LINE__ /* TODO FIXME brcmfmac */
71 
72 #define	CFG80211_SIGNAL_TYPE_MBM			__LINE__ /* TODO FIXME brcmfmac */
73 
74 #define	UPDATE_ASSOC_IES	1
75 
76 #define	IEEE80211_MAX_CHAINS	4		/* net80211: IEEE80211_MAX_CHAINS copied */
77 
78 enum cfg80211_rate_info_flags {
79 	RATE_INFO_FLAGS_MCS		= BIT(0),
80 	RATE_INFO_FLAGS_VHT_MCS		= BIT(1),
81 	RATE_INFO_FLAGS_SHORT_GI	= BIT(2),
82 	RATE_INFO_FLAGS_HE_MCS		= BIT(4),
83 	RATE_INFO_FLAGS_EHT_MCS		= BIT(7),
84 	/* Max 8 bits as used in struct rate_info. */
85 };
86 
87 #define	CFG80211_RATE_INFO_FLAGS_BITS					\
88     "\20\1MCS\2VHT_MCS\3SGI\5HE_MCS\10EHT_MCS"
89 
90 extern const uint8_t rfc1042_header[6];
91 extern const uint8_t bridge_tunnel_header[6];
92 
93 enum ieee80211_privacy {
94 	IEEE80211_PRIVACY_ANY,
95 };
96 
97 enum ieee80211_bss_type {
98 	IEEE80211_BSS_TYPE_ANY,
99 };
100 
101 enum cfg80211_bss_frame_type {
102 	CFG80211_BSS_FTYPE_UNKNOWN,
103 	CFG80211_BSS_FTYPE_BEACON,
104 	CFG80211_BSS_FTYPE_PRESP,
105 };
106 
107 enum ieee80211_channel_flags {
108 	IEEE80211_CHAN_DISABLED			= BIT(0),
109 	IEEE80211_CHAN_INDOOR_ONLY		= BIT(1),
110 	IEEE80211_CHAN_IR_CONCURRENT		= BIT(2),
111 	IEEE80211_CHAN_RADAR			= BIT(3),
112 	IEEE80211_CHAN_NO_IR			= BIT(4),
113 	IEEE80211_CHAN_NO_HT40MINUS		= BIT(5),
114 	IEEE80211_CHAN_NO_HT40PLUS		= BIT(6),
115 	IEEE80211_CHAN_NO_80MHZ			= BIT(7),
116 	IEEE80211_CHAN_NO_160MHZ		= BIT(8),
117 	IEEE80211_CHAN_NO_OFDM			= BIT(9),
118 	IEEE80211_CHAN_NO_6GHZ_VLP_CLIENT	= BIT(10),
119 	IEEE80211_CHAN_NO_6GHZ_AFC_CLIENT	= BIT(11),
120 	IEEE80211_CHAN_PSD			= BIT(12),
121 	IEEE80211_CHAN_ALLOW_6GHZ_VLP_AP	= BIT(13),
122 	IEEE80211_CHAN_CAN_MONITOR		= BIT(14),
123 };
124 #define	IEEE80211_CHAN_NO_HT40	(IEEE80211_CHAN_NO_HT40MINUS|IEEE80211_CHAN_NO_HT40PLUS)
125 
126 struct ieee80211_txrx_stypes {
127 	uint16_t	tx;
128 	uint16_t	rx;
129 };
130 
131 /* XXX net80211 has an ieee80211_channel as well. */
132 struct linuxkpi_ieee80211_channel {
133 	/* TODO FIXME */
134 	uint32_t				hw_value;	/* ic_ieee */
135 	uint32_t				center_freq;	/* ic_freq */
136 	enum ieee80211_channel_flags		flags;		/* ic_flags */
137 	enum nl80211_band			band;
138 	int8_t					max_power;	/* ic_maxpower */
139 	bool					beacon_found;
140 	int     max_antenna_gain, max_reg_power;
141 	int     orig_flags;
142 	int	dfs_cac_ms, dfs_state;
143 	int	orig_mpwr;
144 };
145 
146 struct cfg80211_bitrate_mask {
147 	/* TODO FIXME */
148 	struct {
149 		uint32_t			legacy;
150 		uint8_t				ht_mcs[IEEE80211_HT_MCS_MASK_LEN];
151 		uint16_t			vht_mcs[8];
152 		uint16_t			he_mcs[8];
153 		enum nl80211_txrate_gi		gi;
154 		enum nl80211_he_gi		he_gi;
155 		uint8_t				he_ltf;		/* XXX enum? */
156 	} control[NUM_NL80211_BANDS];
157 };
158 
159 enum rate_info_bw {
160 	RATE_INFO_BW_20		= 0,
161 	RATE_INFO_BW_5,
162 	RATE_INFO_BW_10,
163 	RATE_INFO_BW_40,
164 	RATE_INFO_BW_80,
165 	RATE_INFO_BW_160,
166 	RATE_INFO_BW_HE_RU,
167 	RATE_INFO_BW_320,
168 	RATE_INFO_BW_EHT_RU,
169 };
170 
171 struct rate_info {
172 	uint8_t					flags;			/* enum cfg80211_rate_info_flags */
173 	uint8_t					bw;			/* enum rate_info_bw */
174 	uint16_t				legacy;
175 	uint8_t					mcs;
176 	uint8_t					nss;
177 	uint8_t					he_dcm;
178 	uint8_t					he_gi;
179 	uint8_t					he_ru_alloc;
180 	uint8_t					eht_gi;
181 };
182 
183 struct ieee80211_rate {
184 	uint32_t		flags;					/* enum ieee80211_rate_flags */
185 	uint16_t		bitrate;
186 	uint16_t		hw_value;
187 	uint16_t		hw_value_short;
188 };
189 
190 struct ieee80211_sta_ht_cap {
191 	bool					ht_supported;
192 	uint8_t					ampdu_density;
193 	uint8_t					ampdu_factor;
194 	uint16_t				cap;
195 	struct ieee80211_mcs_info		mcs;
196 };
197 
198 /* XXX net80211 calls these IEEE80211_VHTCAP_* */
199 #define	IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895	0x00000000	/* IEEE80211_VHTCAP_MAX_MPDU_LENGTH_3895 */
200 #define	IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991	0x00000001	/* IEEE80211_VHTCAP_MAX_MPDU_LENGTH_7991 */
201 #define	IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454	0x00000002	/* IEEE80211_VHTCAP_MAX_MPDU_LENGTH_11454 */
202 #define	IEEE80211_VHT_CAP_MAX_MPDU_MASK		0x00000003	/* IEEE80211_VHTCAP_MAX_MPDU_MASK */
203 
204 #define	IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ		(IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_160MHZ << IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_MASK_S)
205 #define	IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ	(IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_160_80P80MHZ << IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_MASK_S)
206 #define	IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK			IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_MASK
207 
208 #define	IEEE80211_VHT_CAP_RXLDPC		0x00000010	/* IEEE80211_VHTCAP_RXLDPC */
209 
210 #define	IEEE80211_VHT_CAP_SHORT_GI_80		0x00000020	/* IEEE80211_VHTCAP_SHORT_GI_80 */
211 #define	IEEE80211_VHT_CAP_SHORT_GI_160		0x00000040	/* IEEE80211_VHTCAP_SHORT_GI_160 */
212 
213 #define	IEEE80211_VHT_CAP_TXSTBC		0x00000080	/* IEEE80211_VHTCAP_TXSTBC */
214 
215 #define	IEEE80211_VHT_CAP_RXSTBC_1		0x00000100	/* IEEE80211_VHTCAP_RXSTBC_1 */
216 #define	IEEE80211_VHT_CAP_RXSTBC_MASK		0x00000700	/* IEEE80211_VHTCAP_RXSTBC_MASK */
217 
218 #define	IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE	0x00000800	/* IEEE80211_VHTCAP_SU_BEAMFORMER_CAPABLE */
219 
220 #define	IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE	0x00001000	/* IEEE80211_VHTCAP_SU_BEAMFORMEE_CAPABLE */
221 
222 #define	IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE	0x00080000	/* IEEE80211_VHTCAP_MU_BEAMFORMER_CAPABLE */
223 
224 #define	IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE	0x00100000	/* IEEE80211_VHTCAP_MU_BEAMFORMEE_CAPABLE */
225 
226 #define	IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT		13	/* IEEE80211_VHTCAP_BEAMFORMEE_STS_SHIFT */
227 #define	IEEE80211_VHT_CAP_BEAMFORMEE_STS_MASK		(7 << IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT)	/* IEEE80211_VHTCAP_BEAMFORMEE_STS_MASK */
228 
229 #define	IEEE80211_VHT_CAP_HTC_VHT		0x00400000	/* IEEE80211_VHTCAP_HTC_VHT */
230 
231 #define	IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN	0x10000000	/* IEEE80211_VHTCAP_RX_ANTENNA_PATTERN */
232 #define	IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN	0x20000000	/* IEEE80211_VHTCAP_TX_ANTENNA_PATTERN */
233 
234 #define	IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB	0x0c000000	/* IEEE80211_VHTCAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB */
235 
236 #define	IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT	16	/* IEEE80211_VHTCAP_SOUNDING_DIMENSIONS_SHIFT */
237 #define	IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_MASK		\
238 	(7 << IEEE80211_VHTCAP_SOUNDING_DIMENSIONS_SHIFT)	/* IEEE80211_VHTCAP_SOUNDING_DIMENSIONS_MASK */
239 
240 #define	IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT	23	/* IEEE80211_VHTCAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT */
241 #define	IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK	\
242 	(7 << IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT)	/* IEEE80211_VHTCAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK */
243 
244 #define	IEEE80211_VHT_CAP_EXT_NSS_BW_MASK	IEEE80211_VHTCAP_EXT_NSS_BW
245 #define	IEEE80211_VHT_CAP_EXT_NSS_BW_SHIFT	IEEE80211_VHTCAP_EXT_NSS_BW_S
246 
247 struct ieee80211_sta_vht_cap {
248 		/* TODO FIXME */
249 	bool				vht_supported;
250 	uint32_t			cap;
251 	struct ieee80211_vht_mcs_info	vht_mcs;
252 };
253 
254 enum ieee80211_vht_opmode {
255 	IEEE80211_OPMODE_NOTIF_RX_NSS_SHIFT	= 4,
256 };
257 
258 struct cfg80211_connect_resp_params {
259 		/* XXX TODO */
260 	uint8_t				*bssid;
261 	const uint8_t			*req_ie;
262 	const uint8_t			*resp_ie;
263 	uint32_t			req_ie_len;
264 	uint32_t			resp_ie_len;
265 	int	status;
266 };
267 
268 struct cfg80211_inform_bss {
269 		/* XXX TODO */
270 	int     boottime_ns, scan_width, signal;
271 	struct linuxkpi_ieee80211_channel	*chan;
272 };
273 
274 struct cfg80211_roam_info {
275 		/* XXX TODO */
276 	uint8_t				*bssid;
277 	const uint8_t			*req_ie;
278 	const uint8_t			*resp_ie;
279 	uint32_t			req_ie_len;
280 	uint32_t			resp_ie_len;
281 	struct linuxkpi_ieee80211_channel	*channel;
282 };
283 
284 struct cfg80211_bss_ies {
285 	uint8_t				*data;
286 	size_t				len;
287 };
288 
289 struct cfg80211_bss {
290 		/* XXX TODO */
291 	struct cfg80211_bss_ies		*ies;
292 	struct cfg80211_bss_ies		*beacon_ies;
293 
294 	int32_t				signal;
295 };
296 
297 struct cfg80211_chan_def {
298 		/* XXX TODO */
299 	struct linuxkpi_ieee80211_channel	*chan;
300 	enum nl80211_chan_width		width;
301 	uint32_t			center_freq1;
302 	uint32_t			center_freq2;
303 	uint16_t			punctured;
304 };
305 
306 struct cfg80211_ftm_responder_stats {
307 		/* XXX TODO */
308 	int	asap_num, failed_num, filled, non_asap_num, out_of_window_triggers_num, partial_num, reschedule_requests_num, success_num, total_duration_ms, unknown_triggers_num;
309 };
310 
311 struct cfg80211_pmsr_capabilities {
312 		/* XXX TODO */
313 	int	max_peers, randomize_mac_addr, report_ap_tsf;
314 	struct {
315 		int	 asap, bandwidths, max_bursts_exponent, max_ftms_per_burst, non_asap, non_trigger_based, preambles, request_civicloc, request_lci, supported, trigger_based;
316 	} ftm;
317 };
318 
319 struct cfg80211_pmsr_ftm_request {
320 		/* XXX TODO */
321 	int     asap, burst_period, ftmr_retries, ftms_per_burst, non_trigger_based, num_bursts_exp, request_civicloc, request_lci, trigger_based;
322 	uint8_t					bss_color;
323 	bool					lmr_feedback;
324 };
325 
326 struct cfg80211_pmsr_request_peer {
327 		/* XXX TODO */
328 	struct cfg80211_chan_def		chandef;
329 	struct cfg80211_pmsr_ftm_request	ftm;
330 	uint8_t					addr[ETH_ALEN];
331 	int	report_ap_tsf;
332 };
333 
334 struct cfg80211_pmsr_request {
335 		/* XXX TODO */
336 	int	cookie, n_peers, timeout;
337 	uint8_t					mac_addr[ETH_ALEN], mac_addr_mask[ETH_ALEN];
338 	struct cfg80211_pmsr_request_peer	peers[];
339 };
340 
341 struct cfg80211_pmsr_ftm_result {
342 		/* XXX TODO */
343 	int	burst_index, busy_retry_time, failure_reason;
344 	int	num_ftmr_successes, rssi_avg, rssi_avg_valid, rssi_spread, rssi_spread_valid, rtt_avg, rtt_avg_valid, rtt_spread, rtt_spread_valid, rtt_variance, rtt_variance_valid;
345 	uint8_t					*lci;
346 	uint8_t					*civicloc;
347 	int					lci_len;
348 	int					civicloc_len;
349 };
350 
351 struct cfg80211_pmsr_result {
352 		/* XXX TODO */
353 	int	ap_tsf, ap_tsf_valid, final, host_time, status, type;
354 	uint8_t					addr[ETH_ALEN];
355 	struct cfg80211_pmsr_ftm_result		ftm;
356 };
357 
358 struct cfg80211_sar_freq_ranges {
359 	uint32_t				start_freq;
360 	uint32_t				end_freq;
361 };
362 
363 struct cfg80211_sar_sub_specs {
364 	uint32_t				freq_range_index;
365 	int					power;
366 };
367 
368 struct cfg80211_sar_specs {
369 	enum nl80211_sar_type			type;
370 	uint32_t				num_sub_specs;
371 	struct cfg80211_sar_sub_specs		sub_specs[];
372 };
373 
374 struct cfg80211_sar_capa {
375 	enum nl80211_sar_type			type;
376 	uint32_t				num_freq_ranges;
377 	const struct cfg80211_sar_freq_ranges	*freq_ranges;
378 };
379 
380 struct cfg80211_ssid {
381 	int	ssid_len;
382 	uint8_t	ssid[IEEE80211_MAX_SSID_LEN];
383 };
384 
385 struct cfg80211_scan_6ghz_params {
386 	/* XXX TODO */
387 	uint8_t				*bssid;
388 	int	channel_idx, psc_no_listen, short_ssid, short_ssid_valid, unsolicited_probe, psd_20;
389 };
390 
391 struct cfg80211_match_set {
392 	uint8_t					bssid[ETH_ALEN];
393 	struct cfg80211_ssid	ssid;
394 	int			rssi_thold;
395 };
396 
397 struct cfg80211_scan_request {
398 		/* XXX TODO */
399 	bool					no_cck;
400 	bool					scan_6ghz;
401 	bool					duration_mandatory;
402 	int8_t					tsf_report_link_id;
403 	uint16_t				duration;
404 	uint32_t				flags;
405 	struct wireless_dev			*wdev;
406 	struct wiphy				*wiphy;
407 	uint64_t				scan_start;
408 	uint32_t				rates[NUM_NL80211_BANDS];
409 	int					ie_len;
410 	uint8_t					*ie;
411 	uint8_t					mac_addr[ETH_ALEN], mac_addr_mask[ETH_ALEN];
412 	uint8_t					bssid[ETH_ALEN];
413 	int					n_ssids;
414 	int					n_6ghz_params;
415 	int					n_channels;
416 	struct cfg80211_ssid			*ssids;
417 	struct cfg80211_scan_6ghz_params 	*scan_6ghz_params;
418 	struct linuxkpi_ieee80211_channel	*channels[0];
419 };
420 
421 struct cfg80211_sched_scan_plan {
422 		/* XXX TODO */
423 	int	interval, iterations;
424 };
425 
426 struct cfg80211_sched_scan_request {
427 		/* XXX TODO */
428 	int	delay, flags;
429 	uint8_t					mac_addr[ETH_ALEN], mac_addr_mask[ETH_ALEN];
430 	uint64_t				reqid;
431 	int					n_match_sets;
432 	int					n_scan_plans;
433 	int					n_ssids;
434 	int					n_channels;
435 	int					ie_len;
436 	uint8_t					*ie;
437 	struct cfg80211_match_set		*match_sets;
438 	struct cfg80211_sched_scan_plan		*scan_plans;
439 	struct cfg80211_ssid			*ssids;
440 	struct linuxkpi_ieee80211_channel	*channels[0];
441 };
442 
443 struct cfg80211_scan_info {
444 	uint64_t				scan_start_tsf;
445 	uint8_t					tsf_bssid[ETH_ALEN];
446 	bool					aborted;
447 };
448 
449 struct cfg80211_beacon_data {
450 	/* XXX TODO */
451 	const uint8_t				*head;
452 	const uint8_t				*tail;
453 	uint32_t				head_len;
454 	uint32_t				tail_len;
455 	const uint8_t				*proberesp_ies;
456 	const uint8_t				*assocresp_ies;
457 	uint32_t				proberesp_ies_len;
458 	uint32_t				assocresp_ies_len;
459 };
460 
461 struct cfg80211_ap_settings {
462 	/* XXX TODO */
463 	int     auth_type, beacon_interval, dtim_period, hidden_ssid, inactivity_timeout;
464 	const uint8_t				*ssid;
465 	size_t					ssid_len;
466 	struct cfg80211_beacon_data		beacon;
467 	struct cfg80211_chan_def		chandef;
468 };
469 
470 struct cfg80211_bss_selection {
471 	/* XXX TODO */
472 	enum nl80211_bss_select_attr		behaviour;
473 	union {
474 		enum nl80211_band		band_pref;
475 		struct {
476 			enum nl80211_band	band;
477 			uint8_t			delta;
478 		} adjust;
479 	} param;
480 };
481 
482 struct cfg80211_crypto {		/* XXX made up name */
483 	/* XXX TODO */
484 	enum nl80211_wpa_versions		wpa_versions;
485 	uint32_t				cipher_group;	/* WLAN_CIPHER_SUITE_* */
486 	uint32_t				*akm_suites;
487 	uint32_t				*ciphers_pairwise;
488 	const uint8_t				*sae_pwd;
489 	const uint8_t				*psk;
490 	int					n_akm_suites;
491 	int					n_ciphers_pairwise;
492 	int					sae_pwd_len;
493 };
494 
495 struct cfg80211_connect_params {
496 	/* XXX TODO */
497 	struct linuxkpi_ieee80211_channel	*channel;
498 	uint8_t					*bssid;
499 	const uint8_t				*ie;
500 	const uint8_t				*ssid;
501 	uint32_t				ie_len;
502 	uint32_t				ssid_len;
503 	const void				*key;
504 	uint32_t				key_len;
505 	int     auth_type, key_idx, privacy, want_1x;
506 	struct cfg80211_bss_selection		bss_select;
507 	struct cfg80211_crypto			crypto;
508 };
509 
510 enum bss_param_flags {		/* Used as bitflags. XXX FIXME values? */
511 	BSS_PARAM_FLAGS_CTS_PROT	= 0x01,
512 	BSS_PARAM_FLAGS_SHORT_PREAMBLE	= 0x02,
513 	BSS_PARAM_FLAGS_SHORT_SLOT_TIME = 0x04,
514 };
515 
516 struct cfg80211_ibss_params {
517 	/* XXX TODO */
518 	int     basic_rates, beacon_interval;
519 	int	channel_fixed, ie, ie_len, privacy;
520 	int	dtim_period;
521 	uint8_t					*ssid;
522 	uint8_t					*bssid;
523 	int					ssid_len;
524 	struct cfg80211_chan_def		chandef;
525 	enum bss_param_flags			flags;
526 };
527 
528 struct cfg80211_mgmt_tx_params {
529 	/* XXX TODO */
530 	struct linuxkpi_ieee80211_channel	*chan;
531 	const uint8_t				*buf;
532 	size_t					len;
533 	int	wait;
534 };
535 
536 struct cfg80211_pmk_conf {
537 	/* XXX TODO */
538 	const uint8_t			*pmk;
539 	uint8_t				pmk_len;
540 };
541 
542 struct cfg80211_pmksa {
543 	/* XXX TODO */
544 	const uint8_t			*bssid;
545 	const uint8_t			*pmkid;
546 };
547 
548 struct station_del_parameters {
549 	/* XXX TODO */
550 	const uint8_t				*mac;
551 	uint32_t				reason_code;	/* elsewhere uint16_t? */
552 };
553 
554 struct station_info {
555 	uint64_t				filled;		/* enum nl80211_sta_info */
556 	uint32_t				connected_time;
557 	uint32_t				inactive_time;
558 
559 	uint64_t				rx_bytes;
560 	uint32_t				rx_packets;
561 	uint32_t				rx_dropped_misc;
562 
563 	uint64_t				rx_duration;
564 	uint32_t				rx_beacon;
565 	uint8_t					rx_beacon_signal_avg;
566 
567 	int8_t					signal;
568 	int8_t					signal_avg;
569 	int8_t					ack_signal;
570 	int8_t					avg_ack_signal;
571 
572 	/* gap */
573 	int					generation;
574 
575 	uint64_t				tx_bytes;
576 	uint32_t				tx_packets;
577 	uint32_t				tx_failed;
578 	uint64_t				tx_duration;
579 	uint32_t				tx_retries;
580 
581 	int					chains;
582 	uint8_t					chain_signal[IEEE80211_MAX_CHAINS];
583 	uint8_t					chain_signal_avg[IEEE80211_MAX_CHAINS];
584 
585 	uint8_t					*assoc_req_ies;
586 	size_t					assoc_req_ies_len;
587 
588 	struct rate_info			rxrate;
589 	struct rate_info			txrate;
590 	struct cfg80211_ibss_params		bss_param;
591 	struct nl80211_sta_flag_update		sta_flags;
592 };
593 
594 struct station_parameters {
595 	/* XXX TODO */
596 	int     sta_flags_mask, sta_flags_set;
597 };
598 
599 struct key_params {
600 	/* XXX TODO */
601 	const uint8_t	*key;
602 	const uint8_t	*seq;
603 	int		key_len;
604 	int		seq_len;
605 	uint32_t	cipher;			/* WLAN_CIPHER_SUITE_* */
606 };
607 
608 struct mgmt_frame_regs {
609 	/* XXX TODO */
610 	int	interface_stypes;
611 };
612 
613 struct vif_params {
614 	/* XXX TODO */
615 	uint8_t			macaddr[ETH_ALEN];
616 };
617 
618 /* That the world needs so many different structs for this is amazing. */
619 struct mac_address {
620 	uint8_t	addr[ETH_ALEN];
621 };
622 
623 struct ieee80211_reg_rule {
624 	/* TODO FIXME */
625 	uint32_t	flags;
626 	int	dfs_cac_ms;
627 	struct freq_range {
628 		int	start_freq_khz;
629 		int	end_freq_khz;
630 		int	max_bandwidth_khz;
631 	} freq_range;
632 	struct power_rule {
633 		int	max_antenna_gain;
634 		int	max_eirp;
635 	} power_rule;
636 };
637 
638 struct linuxkpi_ieee80211_regdomain {
639 	/* TODO FIXME */
640 	uint8_t					alpha2[2];
641 	int	dfs_region;
642 	int					n_reg_rules;
643 	struct ieee80211_reg_rule		reg_rules[];
644 };
645 
646 #define	IEEE80211_EHT_MAC_CAP0_EPCS_PRIO_ACCESS			0x01
647 #define	IEEE80211_EHT_MAC_CAP0_MAX_MPDU_LEN_11454		0x02
648 #define	IEEE80211_EHT_MAC_CAP0_MAX_MPDU_LEN_MASK		0x03
649 #define	IEEE80211_EHT_MAC_CAP0_OM_CONTROL			0x04
650 #define	IEEE80211_EHT_MAC_CAP0_TRIG_TXOP_SHARING_MODE1		0x05
651 #define	IEEE80211_EHT_MAC_CAP0_TRIG_TXOP_SHARING_MODE2		0x06
652 #define	IEEE80211_EHT_MAC_CAP0_MAX_MPDU_LEN_7991		0x07
653 #define	IEEE80211_EHT_MAC_CAP0_SCS_TRAFFIC_DESC			0x08
654 
655 #define	IEEE80211_EHT_MAC_CAP1_MAX_AMPDU_LEN_MASK		0x01
656 
657 #define	IEEE80211_EHT_MCS_NSS_RX				0x01
658 #define	IEEE80211_EHT_MCS_NSS_TX				0x02
659 
660 #define	IEEE80211_EHT_PHY_CAP0_242_TONE_RU_GT20MHZ		0x01
661 #define	IEEE80211_EHT_PHY_CAP0_320MHZ_IN_6GHZ			0x02
662 #define	IEEE80211_EHT_PHY_CAP0_BEAMFORMEE_SS_80MHZ_MASK		0x03
663 #define	IEEE80211_EHT_PHY_CAP0_NDP_4_EHT_LFT_32_GI		0x04
664 #define	IEEE80211_EHT_PHY_CAP0_PARTIAL_BW_UL_MU_MIMO		0x05
665 #define	IEEE80211_EHT_PHY_CAP0_SU_BEAMFORMEE			0x06
666 #define	IEEE80211_EHT_PHY_CAP0_SU_BEAMFORMER			0x07
667 
668 #define	IEEE80211_EHT_PHY_CAP1_BEAMFORMEE_SS_160MHZ_MASK	0x01
669 #define	IEEE80211_EHT_PHY_CAP1_BEAMFORMEE_SS_320MHZ_MASK	0x02
670 #define	IEEE80211_EHT_PHY_CAP1_BEAMFORMEE_SS_80MHZ_MASK		0x03
671 
672 #define	IEEE80211_EHT_PHY_CAP2_SOUNDING_DIM_80MHZ_MASK		0x01
673 #define	IEEE80211_EHT_PHY_CAP2_SOUNDING_DIM_160MHZ_MASK		0x02
674 #define	IEEE80211_EHT_PHY_CAP2_SOUNDING_DIM_320MHZ_MASK		0x03
675 
676 #define	IEEE80211_EHT_PHY_CAP3_CODEBOOK_4_2_SU_FDBK		0x01
677 #define	IEEE80211_EHT_PHY_CAP3_CODEBOOK_7_5_MU_FDBK		0x02
678 #define	IEEE80211_EHT_PHY_CAP3_NG_16_MU_FEEDBACK		0x03
679 #define	IEEE80211_EHT_PHY_CAP3_NG_16_SU_FEEDBACK		0x04
680 #define	IEEE80211_EHT_PHY_CAP3_TRIG_CQI_FDBK			0x05
681 #define	IEEE80211_EHT_PHY_CAP3_TRIG_MU_BF_PART_BW_FDBK		0x06
682 #define	IEEE80211_EHT_PHY_CAP3_TRIG_SU_BF_FDBK			0x07
683 #define	IEEE80211_EHT_PHY_CAP3_SOUNDING_DIM_320MHZ_MASK		0x08
684 
685 #define	IEEE80211_EHT_PHY_CAP4_EHT_MU_PPDU_4_EHT_LTF_08_GI	0x01
686 #define	IEEE80211_EHT_PHY_CAP4_PART_BW_DL_MU_MIMO		0x02
687 #define	IEEE80211_EHT_PHY_CAP4_POWER_BOOST_FACT_SUPP		0x03
688 #define	IEEE80211_EHT_PHY_CAP4_MAX_NC_MASK			0x04
689 
690 #define	IEEE80211_EHT_PHY_CAP5_COMMON_NOMINAL_PKT_PAD_0US	0x01
691 #define	IEEE80211_EHT_PHY_CAP5_COMMON_NOMINAL_PKT_PAD_16US	0x02
692 #define	IEEE80211_EHT_PHY_CAP5_COMMON_NOMINAL_PKT_PAD_20US	0x03
693 #define	IEEE80211_EHT_PHY_CAP5_COMMON_NOMINAL_PKT_PAD_8US	0x04
694 #define	IEEE80211_EHT_PHY_CAP5_COMMON_NOMINAL_PKT_PAD_MASK	0x05
695 #define	IEEE80211_EHT_PHY_CAP5_NON_TRIG_CQI_FEEDBACK		0x06
696 #define	IEEE80211_EHT_PHY_CAP5_PPE_THRESHOLD_PRESENT		0x07
697 #define	IEEE80211_EHT_PHY_CAP5_RX_LESS_242_TONE_RU_SUPP		0x08
698 #define	IEEE80211_EHT_PHY_CAP5_TX_LESS_242_TONE_RU_SUPP		0x09
699 #define	IEEE80211_EHT_PHY_CAP5_MAX_NUM_SUPP_EHT_LTF_MASK	0x0a
700 #define	IEEE80211_EHT_PHY_CAP5_SUPP_EXTRA_EHT_LTF		0x0b
701 
702 #define	IEEE80211_EHT_PHY_CAP6_EHT_DUP_6GHZ_SUPP		0x01
703 #define	IEEE80211_EHT_PHY_CAP6_MCS15_SUPP_MASK			0x02
704 #define	IEEE80211_EHT_PHY_CAP6_MAX_NUM_SUPP_EHT_LTF_MASK	0x03
705 
706 #define	IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_80MHZ		0x01
707 #define	IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_160MHZ		0x02
708 #define	IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_320MHZ		0x03
709 #define	IEEE80211_EHT_PHY_CAP7_NON_OFDMA_UL_MU_MIMO_80MHZ	0x04
710 #define	IEEE80211_EHT_PHY_CAP7_NON_OFDMA_UL_MU_MIMO_160MHZ	0x05
711 #define	IEEE80211_EHT_PHY_CAP7_NON_OFDMA_UL_MU_MIMO_320MHZ	0x06
712 
713 #define	IEEE80211_EHT_PHY_CAP8_RX_1024QAM_WIDER_BW_DL_OFDMA	0x01
714 #define	IEEE80211_EHT_PHY_CAP8_RX_4096QAM_WIDER_BW_DL_OFDMA	0x02
715 
716 #define	IEEE80211_EHT_PPE_THRES_INFO_HEADER_SIZE		0x01
717 #define	IEEE80211_EHT_PPE_THRES_NSS_MASK			0x02
718 #define	IEEE80211_EHT_PPE_THRES_RU_INDEX_BITMASK_MASK		0x03
719 #define	IEEE80211_EHT_PPE_THRES_INFO_PPET_SIZE			0x04
720 
721 #define	IEEE80211_EML_CAP_EMLSR_SUPP				0x01
722 #define	IEEE80211_EML_CAP_TRANSITION_TIMEOUT			0x02
723 #define	IEEE80211_EML_CAP_TRANSITION_TIMEOUT_128TU		0x04
724 #define	IEEE80211_EML_CAP_EMLSR_PADDING_DELAY			0x08
725 #define	IEEE80211_EML_CAP_EMLSR_PADDING_DELAY_32US		0x10
726 #define	IEEE80211_EML_CAP_EMLSR_PADDING_DELAY_256US		0x10
727 #define	IEEE80211_EML_CAP_EMLSR_TRANSITION_DELAY		0x20
728 #define	IEEE80211_EML_CAP_EMLSR_TRANSITION_DELAY_64US		0x40
729 #define	IEEE80211_EML_CAP_EMLSR_TRANSITION_DELAY_256US		0x40
730 
731 #define	VENDOR_CMD_RAW_DATA	(void *)(uintptr_t)(-ENOENT)
732 
733 /* net80211::net80211_he_cap */
734 struct ieee80211_sta_he_cap {
735 	bool					has_he;
736 	struct ieee80211_he_cap_elem		he_cap_elem;
737 	struct ieee80211_he_mcs_nss_supp	he_mcs_nss_supp;
738 	uint8_t					ppe_thres[IEEE80211_HE_CAP_PPE_THRES_MAX];
739 };
740 
741 struct cfg80211_he_bss_color {
742 	int	color, enabled;
743 };
744 
745 struct ieee80211_he_obss_pd {
746 	bool					enable;
747 	uint8_t					min_offset;
748 	uint8_t					max_offset;
749 	uint8_t					non_srg_max_offset;
750 	uint8_t					sr_ctrl;
751 	uint8_t					bss_color_bitmap[8];
752 	uint8_t					partial_bssid_bitmap[8];
753 };
754 
755 struct ieee80211_eht_mcs_nss_supp_20mhz_only {
756 	union {
757 		struct {
758 			uint8_t				rx_tx_mcs7_max_nss;
759 			uint8_t				rx_tx_mcs9_max_nss;
760 			uint8_t				rx_tx_mcs11_max_nss;
761 			uint8_t				rx_tx_mcs13_max_nss;
762 		};
763 		uint8_t					rx_tx_max_nss[4];
764 	};
765 };
766 
767 struct ieee80211_eht_mcs_nss_supp_bw {
768 	union {
769 		struct {
770 			uint8_t				rx_tx_mcs9_max_nss;
771 			uint8_t				rx_tx_mcs11_max_nss;
772 			uint8_t				rx_tx_mcs13_max_nss;
773 		};
774 		uint8_t					rx_tx_max_nss[3];
775 	};
776 };
777 
778 struct ieee80211_eht_cap_elem_fixed {
779 	uint8_t					mac_cap_info[2];
780 	uint8_t					phy_cap_info[9];
781 };
782 
783 struct ieee80211_eht_mcs_nss_supp {
784 	/* TODO FIXME */
785 	/* Can only have either or... */
786 	union {
787 		struct ieee80211_eht_mcs_nss_supp_20mhz_only		only_20mhz;
788 		struct {
789 			struct ieee80211_eht_mcs_nss_supp_bw		_80;
790 			struct ieee80211_eht_mcs_nss_supp_bw		_160;
791 			struct ieee80211_eht_mcs_nss_supp_bw		_320;
792 		} bw;
793 	};
794 };
795 
796 #define	IEEE80211_STA_EHT_PPE_THRES_MAX		32
797 struct ieee80211_sta_eht_cap {
798 	bool					has_eht;
799 	struct ieee80211_eht_cap_elem_fixed	eht_cap_elem;
800 	struct ieee80211_eht_mcs_nss_supp	eht_mcs_nss_supp;
801 	uint8_t					eht_ppe_thres[IEEE80211_STA_EHT_PPE_THRES_MAX];
802 };
803 
804 struct ieee80211_sband_iftype_data {
805 	/* TODO FIXME */
806 	enum nl80211_iftype			types_mask;
807 	struct ieee80211_sta_he_cap		he_cap;
808 	struct ieee80211_he_6ghz_capa		he_6ghz_capa;
809 	struct ieee80211_sta_eht_cap		eht_cap;
810 	struct {
811 		const uint8_t			*data;
812 		size_t				len;
813 	} vendor_elems;
814 };
815 
816 struct ieee80211_supported_band {
817 	/* TODO FIXME */
818 	struct linuxkpi_ieee80211_channel	*channels;
819 	struct ieee80211_rate			*bitrates;
820 	struct ieee80211_sband_iftype_data	*iftype_data;
821 	int					n_channels;
822 	int					n_bitrates;
823 	int					n_iftype_data;
824 	enum nl80211_band			band;
825 	struct ieee80211_sta_ht_cap		ht_cap;
826 	struct ieee80211_sta_vht_cap		vht_cap;
827 };
828 
829 struct cfg80211_pkt_pattern {
830 	/* XXX TODO */
831 	uint8_t					*mask;
832 	uint8_t					*pattern;
833 	int					pattern_len;
834 	int					pkt_offset;
835 };
836 
837 struct cfg80211_wowlan_nd_match {
838 	/* XXX TODO */
839 	struct cfg80211_ssid		ssid;
840 	int				n_channels;
841 	uint32_t			channels[0];	/* freq! = ieee80211_channel_to_frequency() */
842 };
843 
844 struct cfg80211_wowlan_nd_info {
845 	/* XXX TODO */
846 	int				n_matches;
847 	struct cfg80211_wowlan_nd_match	*matches[0];
848 };
849 
850 enum wiphy_wowlan_support_flags {
851 	WIPHY_WOWLAN_DISCONNECT,
852 	WIPHY_WOWLAN_MAGIC_PKT,
853 	WIPHY_WOWLAN_SUPPORTS_GTK_REKEY,
854 	WIPHY_WOWLAN_GTK_REKEY_FAILURE,
855 	WIPHY_WOWLAN_EAP_IDENTITY_REQ,
856 	WIPHY_WOWLAN_4WAY_HANDSHAKE,
857 	WIPHY_WOWLAN_RFKILL_RELEASE,
858 	WIPHY_WOWLAN_NET_DETECT,
859 };
860 
861 struct wiphy_wowlan_support {
862 	/* XXX TODO */
863 	enum wiphy_wowlan_support_flags		flags;
864 	int	max_nd_match_sets, max_pkt_offset, n_patterns, pattern_max_len, pattern_min_len;
865 };
866 
867 struct cfg80211_wowlan_wakeup {
868 	/* XXX TODO */
869 	uint16_t				pattern_idx;
870 	bool					disconnect;
871 	bool					unprot_deauth_disassoc;
872 	bool					eap_identity_req;
873 	bool					four_way_handshake;
874 	bool					gtk_rekey_failure;
875 	bool					magic_pkt;
876 	bool					rfkill_release;
877 	bool					tcp_connlost;
878 	bool					tcp_nomoretokens;
879 	bool					tcp_match;
880 	bool					packet_80211;
881 	struct cfg80211_wowlan_nd_info		*net_detect;
882 	uint8_t					*packet;
883 	uint16_t				packet_len;
884 	uint16_t				packet_present_len;
885 };
886 
887 struct cfg80211_wowlan {
888 	/* XXX TODO */
889 	bool					any;
890 	bool					disconnect;
891 	bool					magic_pkt;
892 	bool					gtk_rekey_failure;
893 	bool					eap_identity_req;
894 	bool					four_way_handshake;
895 	bool					rfkill_release;
896 
897 	/* Magic packet patterns. */
898 	int					n_patterns;
899 	struct cfg80211_pkt_pattern		*patterns;
900 
901 	/* netdetect? if not assoc? */
902 	struct cfg80211_sched_scan_request	*nd_config;
903 
904 	void					*tcp;		/* XXX ? */
905 };
906 
907 struct cfg80211_gtk_rekey_data {
908 	/* XXX TODO */
909 	const uint8_t				*kck, *kek, *replay_ctr;
910 	uint32_t				akm;
911 	uint8_t					kck_len, kek_len;
912 };
913 
914 struct cfg80211_tid_cfg {
915 	/* XXX TODO */
916 	int	mask, noack, retry_long, rtscts, tids, amsdu, ampdu;
917 	enum nl80211_tx_rate_setting		txrate_type;
918 	struct cfg80211_bitrate_mask		txrate_mask;
919 };
920 
921 struct cfg80211_tid_config {
922 	/* XXX TODO */
923 	int	n_tid_conf;
924 	struct cfg80211_tid_cfg			tid_conf[0];
925 };
926 
927 struct ieee80211_iface_limit {
928 	/* TODO FIXME */
929 	int		max, types;
930 };
931 
932 struct ieee80211_iface_combination {
933 	/* TODO FIXME */
934 	const struct ieee80211_iface_limit	*limits;
935 	int					n_limits;
936 	int		max_interfaces, num_different_channels;
937 	int		beacon_int_infra_match, beacon_int_min_gcd;
938 	int		radar_detect_widths;
939 };
940 
941 struct iface_combination_params {
942 	int num_different_channels;
943 	int iftype_num[NUM_NL80211_IFTYPES];
944 };
945 
946 struct regulatory_request {
947 		/* XXX TODO */
948 	uint8_t					alpha2[2];
949 	enum environment_cap			country_ie_env;
950 	int	initiator, dfs_region;
951 	int	user_reg_hint_type;
952 };
953 
954 struct cfg80211_set_hw_timestamp {
955 	const uint8_t				*macaddr;
956 	bool					enable;
957 };
958 
959 enum wiphy_vendor_cmd_need_flags {
960 	WIPHY_VENDOR_CMD_NEED_NETDEV		= 0x01,
961 	WIPHY_VENDOR_CMD_NEED_RUNNING		= 0x02,
962 	WIPHY_VENDOR_CMD_NEED_WDEV		= 0x04,
963 };
964 
965 struct wiphy_vendor_command {
966 	struct {
967 		uint32_t	vendor_id;
968 		uint32_t	subcmd;
969 	};
970 	uint32_t		flags;
971 	void			*policy;
972 	int (*doit)(struct wiphy *, struct wireless_dev *, const void *, int);
973 };
974 
975 struct wiphy_iftype_ext_capab {
976 	/* TODO FIXME */
977 	enum nl80211_iftype			iftype;
978 	const uint8_t				*extended_capabilities;
979 	const uint8_t				*extended_capabilities_mask;
980 	uint8_t					extended_capabilities_len;
981 	uint16_t				eml_capabilities;
982 	uint16_t				mld_capa_and_ops;
983 };
984 
985 struct tid_config_support {
986 	/* TODO FIXME */
987 	uint64_t				vif;	/* enum nl80211_tid_cfg_attr */
988 	uint64_t		 		peer;	/* enum nl80211_tid_cfg_attr */
989 };
990 
991 enum cfg80211_regulatory {
992 	REGULATORY_CUSTOM_REG			= BIT(0),
993 	REGULATORY_STRICT_REG			= BIT(1),
994 	REGULATORY_DISABLE_BEACON_HINTS		= BIT(2),
995 	REGULATORY_ENABLE_RELAX_NO_IR		= BIT(3),
996 	REGULATORY_WIPHY_SELF_MANAGED		= BIT(4),
997 	REGULATORY_COUNTRY_IE_IGNORE		= BIT(5),
998 	REGULATORY_COUNTRY_IE_FOLLOW_POWER	= BIT(6),
999 };
1000 
1001 struct wiphy_radio_freq_range {
1002 	uint32_t				start_freq;
1003 	uint32_t				end_freq;
1004 };
1005 
1006 struct wiphy_radio {
1007 	int					n_freq_range;
1008 	int					n_iface_combinations;
1009 	const struct wiphy_radio_freq_range	*freq_range;
1010 	const struct ieee80211_iface_combination *iface_combinations;
1011 };
1012 
1013 enum wiphy_flags {
1014 	WIPHY_FLAG_AP_UAPSD			= BIT(0),
1015 	WIPHY_FLAG_HAS_CHANNEL_SWITCH		= BIT(1),
1016 	WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL	= BIT(2),
1017 	WIPHY_FLAG_HAVE_AP_SME			= BIT(3),
1018 	WIPHY_FLAG_IBSS_RSN			= BIT(4),
1019 	WIPHY_FLAG_NETNS_OK			= BIT(5),
1020 	WIPHY_FLAG_OFFCHAN_TX			= BIT(6),
1021 	WIPHY_FLAG_PS_ON_BY_DEFAULT		= BIT(7),
1022 	WIPHY_FLAG_SPLIT_SCAN_6GHZ		= BIT(8),
1023 	WIPHY_FLAG_SUPPORTS_EXT_KEK_KCK		= BIT(9),
1024 	WIPHY_FLAG_SUPPORTS_FW_ROAM		= BIT(10),
1025 	WIPHY_FLAG_SUPPORTS_TDLS		= BIT(11),
1026 	WIPHY_FLAG_TDLS_EXTERNAL_SETUP		= BIT(12),
1027 	WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD	= BIT(13),
1028 	WIPHY_FLAG_4ADDR_AP			= BIT(14),
1029 	WIPHY_FLAG_4ADDR_STATION		= BIT(15),
1030 	WIPHY_FLAG_SUPPORTS_MLO			= BIT(16),
1031 	WIPHY_FLAG_DISABLE_WEXT			= BIT(17),
1032 };
1033 
1034 struct wiphy_work;
1035 typedef void (*wiphy_work_fn)(struct wiphy *, struct wiphy_work *);
1036 struct wiphy_work {
1037 	struct list_head			entry;
1038 	wiphy_work_fn				fn;
1039 };
1040 struct wiphy_delayed_work {
1041 	struct wiphy_work			work;
1042 	struct wiphy				*wiphy;
1043 	struct timer_list			timer;
1044 };
1045 
1046 struct wiphy {
1047 	struct mutex				mtx;
1048 	struct device				*dev;
1049 	struct mac_address			*addresses;
1050 	int					n_addresses;
1051 	uint32_t				flags;
1052 	struct ieee80211_supported_band		*bands[NUM_NL80211_BANDS];
1053 	uint8_t					perm_addr[ETH_ALEN];
1054 	uint16_t				max_scan_ie_len;
1055 
1056 	/* XXX TODO */
1057 	const struct cfg80211_pmsr_capabilities	*pmsr_capa;
1058 	const struct cfg80211_sar_capa		*sar_capa;
1059 	const struct wiphy_iftype_ext_capab	*iftype_ext_capab;
1060 	const struct linuxkpi_ieee80211_regdomain *regd;
1061 	char					fw_version[ETHTOOL_FWVERS_LEN];
1062 	const struct ieee80211_iface_combination *iface_combinations;
1063 	const uint32_t				*cipher_suites;
1064 	int					n_iface_combinations;
1065 	int					n_cipher_suites;
1066 	void(*reg_notifier)(struct wiphy *, struct regulatory_request *);
1067 	enum cfg80211_regulatory		regulatory_flags;
1068 	int					n_vendor_commands;
1069 	const struct wiphy_vendor_command	*vendor_commands;
1070 	const struct ieee80211_txrx_stypes	*mgmt_stypes;
1071 	uint32_t				rts_threshold;
1072 	uint32_t				frag_threshold;
1073 	struct tid_config_support		tid_config_support;
1074 	uint8_t					available_antennas_rx;
1075 	uint8_t					available_antennas_tx;
1076 
1077 	int					n_radio;
1078 	const struct wiphy_radio		*radio;
1079 
1080 	int	features, hw_version;
1081 	int	interface_modes, max_match_sets, max_remain_on_channel_duration, max_scan_ssids, max_sched_scan_ie_len, max_sched_scan_plan_interval, max_sched_scan_plan_iterations, max_sched_scan_plans, max_sched_scan_reqs, max_sched_scan_ssids;
1082 	int	num_iftype_ext_capab;
1083 	int	max_ap_assoc_sta, probe_resp_offload, software_iftypes;
1084 	int     bss_select_support, max_num_pmkids, retry_long, retry_short, signal_type;
1085 	int	max_data_retry_count;
1086 	int     tx_queue_len, rfkill;
1087 	int	mbssid_max_interfaces;
1088 	int	hw_timestamp_max_peers;
1089 	int	ema_max_profile_periodicity;
1090 
1091 	unsigned long				ext_features[BITS_TO_LONGS(NUM_NL80211_EXT_FEATURES)];
1092 	struct dentry				*debugfsdir;
1093 
1094 	const struct wiphy_wowlan_support	*wowlan;
1095 	struct cfg80211_wowlan			*wowlan_config;
1096 	/* Lower layer (driver/mac80211) specific data. */
1097 	/* Must stay last. */
1098 	uint8_t					priv[0] __aligned(CACHE_LINE_SIZE);
1099 };
1100 
1101 #define	lockdep_assert_wiphy(wiphy)					\
1102     lockdep_assert_held(&(wiphy)->mtx)
1103 
1104 struct wireless_dev {
1105 		/* XXX TODO, like ic? */
1106 	enum nl80211_iftype			iftype;
1107 	uint32_t				radio_mask;
1108 	uint8_t					address[ETH_ALEN];
1109 	struct net_device			*netdev;
1110 	struct wiphy				*wiphy;
1111 };
1112 
1113 struct cfg80211_ops {
1114 	/* XXX TODO */
1115 	struct wireless_dev *(*add_virtual_intf)(struct wiphy *, const char *, unsigned char, enum nl80211_iftype, struct vif_params *);
1116 	int (*del_virtual_intf)(struct wiphy *,  struct wireless_dev *);
1117 	s32 (*change_virtual_intf)(struct wiphy *,  struct net_device *, enum nl80211_iftype, struct vif_params *);
1118 	s32 (*scan)(struct wiphy *,  struct cfg80211_scan_request *);
1119 	s32 (*set_wiphy_params)(struct wiphy *,  u32);
1120 	s32 (*join_ibss)(struct wiphy *,  struct net_device *, struct cfg80211_ibss_params *);
1121 	s32 (*leave_ibss)(struct wiphy *,  struct net_device *);
1122 	s32 (*get_station)(struct wiphy *, struct net_device *, const u8 *, struct station_info *);
1123 	int (*dump_station)(struct wiphy *,  struct net_device *, int,  u8 *,  struct station_info *);
1124 	s32 (*set_tx_power)(struct wiphy *,  struct wireless_dev *, enum nl80211_tx_power_setting,  s32);
1125 	s32 (*get_tx_power)(struct wiphy *,  struct wireless_dev *, s32 *);
1126 	s32 (*add_key)(struct wiphy *,  struct net_device *, u8,  bool,  const u8 *, struct key_params *);
1127 	s32 (*del_key)(struct wiphy *,  struct net_device *, u8,  bool,  const u8 *);
1128 	s32 (*get_key)(struct wiphy *,  struct net_device *,  u8, bool,  const u8 *,  void *, void(*)(void *, struct key_params *));
1129 	s32 (*set_default_key)(struct wiphy *,  struct net_device *, u8,  bool,  bool);
1130 	s32 (*set_default_mgmt_key)(struct wiphy *, struct net_device *,  u8);
1131 	s32 (*set_power_mgmt)(struct wiphy *,  struct net_device *, bool,  s32);
1132 	s32 (*connect)(struct wiphy *,  struct net_device *, struct cfg80211_connect_params *);
1133 	s32 (*disconnect)(struct wiphy *,  struct net_device *, u16);
1134 	s32 (*suspend)(struct wiphy *, struct cfg80211_wowlan *);
1135 	s32 (*resume)(struct wiphy *);
1136 	s32 (*set_pmksa)(struct wiphy *, struct net_device *, struct cfg80211_pmksa *);
1137 	s32 (*del_pmksa)(struct wiphy *, struct net_device *, struct cfg80211_pmksa *);
1138 	s32 (*flush_pmksa)(struct wiphy *,  struct net_device *);
1139 	s32 (*start_ap)(struct wiphy *,  struct net_device *, struct cfg80211_ap_settings *);
1140 	int (*stop_ap)(struct wiphy *,  struct net_device *);
1141 	s32 (*change_beacon)(struct wiphy *,  struct net_device *, struct cfg80211_beacon_data *);
1142 	int (*del_station)(struct wiphy *,  struct net_device *, struct station_del_parameters *);
1143 	int (*change_station)(struct wiphy *,  struct net_device *, const u8 *,  struct station_parameters *);
1144 	int (*sched_scan_start)(struct wiphy *, struct net_device *, struct cfg80211_sched_scan_request *);
1145 	int (*sched_scan_stop)(struct wiphy *, struct net_device *,  u64);
1146 	void (*update_mgmt_frame_registrations)(struct wiphy *, struct wireless_dev *, struct mgmt_frame_regs *);
1147 	int (*mgmt_tx)(struct wiphy *,  struct wireless_dev *, struct cfg80211_mgmt_tx_params *,  u64 *);
1148 	int (*cancel_remain_on_channel)(struct wiphy *, struct wireless_dev *, u64);
1149 	int (*get_channel)(struct wiphy *, struct wireless_dev *, struct cfg80211_chan_def *);
1150 	int (*crit_proto_start)(struct wiphy *, struct wireless_dev *, enum nl80211_crit_proto_id, u16);
1151 	void (*crit_proto_stop)(struct wiphy *, struct wireless_dev *);
1152 	int (*tdls_oper)(struct wiphy *, struct net_device *,  const u8 *, enum nl80211_tdls_operation);
1153 	int (*update_connect_params)(struct wiphy *, struct net_device *, struct cfg80211_connect_params *, u32);
1154 	int (*set_pmk)(struct wiphy *,  struct net_device *, const struct cfg80211_pmk_conf *);
1155 	int (*del_pmk)(struct wiphy *,  struct net_device *, const u8 *);
1156 	int (*remain_on_channel)(struct wiphy *,  struct wireless_dev *, struct linuxkpi_ieee80211_channel *, unsigned int,  u64 *);
1157 	int (*start_p2p_device)(struct wiphy *,  struct wireless_dev *);
1158 	void (*stop_p2p_device)(struct wiphy *,  struct wireless_dev *);
1159 };
1160 
1161 
1162 /* -------------------------------------------------------------------------- */
1163 
1164 /* linux_80211.c */
1165 
1166 struct wiphy *linuxkpi_wiphy_new(const struct cfg80211_ops *, size_t);
1167 void linuxkpi_wiphy_free(struct wiphy *wiphy);
1168 
1169 void linuxkpi_wiphy_work_queue(struct wiphy *, struct wiphy_work *);
1170 void linuxkpi_wiphy_work_cancel(struct wiphy *, struct wiphy_work *);
1171 void linuxkpi_wiphy_work_flush(struct wiphy *, struct wiphy_work *);
1172 void lkpi_wiphy_delayed_work_timer(struct timer_list *);
1173 void linuxkpi_wiphy_delayed_work_queue(struct wiphy *,
1174     struct wiphy_delayed_work *, unsigned long);
1175 void linuxkpi_wiphy_delayed_work_cancel(struct wiphy *,
1176     struct wiphy_delayed_work *);
1177 
1178 int linuxkpi_regulatory_set_wiphy_regd_sync(struct wiphy *wiphy,
1179     struct linuxkpi_ieee80211_regdomain *regd);
1180 uint32_t linuxkpi_cfg80211_calculate_bitrate(struct rate_info *);
1181 uint32_t linuxkpi_ieee80211_channel_to_frequency(uint32_t, enum nl80211_band);
1182 uint32_t linuxkpi_ieee80211_frequency_to_channel(uint32_t, uint32_t);
1183 struct linuxkpi_ieee80211_channel *
1184     linuxkpi_ieee80211_get_channel(struct wiphy *, uint32_t);
1185 struct cfg80211_bss *linuxkpi_cfg80211_get_bss(struct wiphy *,
1186     struct linuxkpi_ieee80211_channel *, const uint8_t *,
1187     const uint8_t *, size_t, enum ieee80211_bss_type, enum ieee80211_privacy);
1188 void linuxkpi_cfg80211_put_bss(struct wiphy *, struct cfg80211_bss *);
1189 void linuxkpi_cfg80211_bss_flush(struct wiphy *);
1190 struct linuxkpi_ieee80211_regdomain *
1191     lkpi_get_linuxkpi_ieee80211_regdomain(size_t);
1192 
1193 /* -------------------------------------------------------------------------- */
1194 
1195 static __inline struct wiphy *
1196 wiphy_new(const struct cfg80211_ops *ops, size_t priv_len)
1197 {
1198 
1199 	return (linuxkpi_wiphy_new(ops, priv_len));
1200 }
1201 
1202 static __inline void
1203 wiphy_free(struct wiphy *wiphy)
1204 {
1205 
1206 	linuxkpi_wiphy_free(wiphy);
1207 }
1208 
1209 static __inline void *
1210 wiphy_priv(struct wiphy *wiphy)
1211 {
1212 
1213 	return (wiphy->priv);
1214 }
1215 
1216 static __inline void
1217 set_wiphy_dev(struct wiphy *wiphy, struct device *dev)
1218 {
1219 
1220 	wiphy->dev = dev;
1221 }
1222 
1223 static __inline struct device *
1224 wiphy_dev(struct wiphy *wiphy)
1225 {
1226 
1227 	return (wiphy->dev);
1228 }
1229 
1230 #define	wiphy_dereference(_w, p)					\
1231     rcu_dereference_check(p, lockdep_is_held(&(_w)->mtx))
1232 
1233 #define	wiphy_lock(_w)		mutex_lock(&(_w)->mtx)
1234 #define	wiphy_unlock(_w)	mutex_unlock(&(_w)->mtx)
1235 
1236 static __inline void
1237 wiphy_rfkill_set_hw_state_reason(struct wiphy *wiphy, bool blocked,
1238     enum rfkill_hard_block_reasons reason)
1239 {
1240 	TODO();
1241 }
1242 
1243 /* -------------------------------------------------------------------------- */
1244 
1245 static inline struct cfg80211_bss *
1246 cfg80211_get_bss(struct wiphy *wiphy, struct linuxkpi_ieee80211_channel *chan,
1247     const uint8_t *bssid, const uint8_t *ssid, size_t ssid_len,
1248     enum ieee80211_bss_type bss_type, enum ieee80211_privacy privacy)
1249 {
1250 
1251 	return (linuxkpi_cfg80211_get_bss(wiphy, chan, bssid, ssid, ssid_len,
1252 	    bss_type, privacy));
1253 }
1254 
1255 static inline void
1256 cfg80211_put_bss(struct wiphy *wiphy, struct cfg80211_bss *bss)
1257 {
1258 
1259 	linuxkpi_cfg80211_put_bss(wiphy, bss);
1260 }
1261 
1262 static inline void
1263 cfg80211_bss_flush(struct wiphy *wiphy)
1264 {
1265 
1266 	linuxkpi_cfg80211_bss_flush(wiphy);
1267 }
1268 
1269 /* -------------------------------------------------------------------------- */
1270 
1271 static __inline bool
1272 rfkill_blocked(int rfkill)		/* argument type? */
1273 {
1274 	TODO();
1275 	return (false);
1276 }
1277 
1278 static __inline bool
1279 rfkill_soft_blocked(int rfkill)
1280 {
1281 	TODO();
1282 	return (false);
1283 }
1284 
1285 static __inline void
1286 wiphy_rfkill_start_polling(struct wiphy *wiphy)
1287 {
1288 	TODO();
1289 }
1290 
1291 static __inline void
1292 wiphy_rfkill_stop_polling(struct wiphy *wiphy)
1293 {
1294 	TODO();
1295 }
1296 
1297 static __inline int
1298 reg_query_regdb_wmm(uint8_t *alpha2, uint32_t center_freq,
1299     struct ieee80211_reg_rule *rule)
1300 {
1301 
1302 	/* ETSI has special rules. FreeBSD regdb needs to learn about them. */
1303 	TODO();
1304 
1305 	return (-ENXIO);
1306 }
1307 
1308 static __inline const u8 *
1309 cfg80211_find_ie_match(uint32_t f, const u8 *ies, size_t ies_len,
1310     const u8 *match, int x, int y)
1311 {
1312 	TODO();
1313 	return (NULL);
1314 }
1315 
1316 static __inline const u8 *
1317 cfg80211_find_ie(uint8_t eid, const uint8_t *ie, uint32_t ielen)
1318 {
1319 	TODO();
1320 	return (NULL);
1321 }
1322 
1323 static __inline void
1324 cfg80211_pmsr_complete(struct wireless_dev *wdev,
1325     struct cfg80211_pmsr_request *req, gfp_t gfp)
1326 {
1327 	TODO();
1328 }
1329 
1330 static __inline void
1331 cfg80211_pmsr_report(struct wireless_dev *wdev,
1332     struct cfg80211_pmsr_request *req,
1333     struct cfg80211_pmsr_result *result, gfp_t gfp)
1334 {
1335 	TODO();
1336 }
1337 
1338 static inline void
1339 cfg80211_chandef_create(struct cfg80211_chan_def *chandef,
1340     struct linuxkpi_ieee80211_channel *chan, enum nl80211_channel_type chan_type)
1341 {
1342 
1343 	KASSERT(chandef != NULL, ("%s: chandef is NULL\n", __func__));
1344 	KASSERT(chan != NULL, ("%s: chan is NULL\n", __func__));
1345 
1346 	/* memset(chandef, 0, sizeof(*chandef)); */
1347 	chandef->chan = chan;
1348 	chandef->center_freq1 = chan->center_freq;
1349 	/* chandef->width, center_freq2, punctured */
1350 
1351 	switch (chan_type) {
1352 	case NL80211_CHAN_NO_HT:
1353 		chandef->width = NL80211_CHAN_WIDTH_20_NOHT;
1354 		break;
1355 	case NL80211_CHAN_HT20:
1356 		chandef->width = NL80211_CHAN_WIDTH_20;
1357 		break;
1358 	case NL80211_CHAN_HT40MINUS:
1359 		chandef->width = NL80211_CHAN_WIDTH_40;
1360 		chandef->center_freq1 -= 10;
1361 		break;
1362 	case NL80211_CHAN_HT40PLUS:
1363 		chandef->width = NL80211_CHAN_WIDTH_40;
1364 		chandef->center_freq1 += 10;
1365 		break;
1366 	};
1367 }
1368 
1369 static __inline bool
1370 cfg80211_chandef_valid(const struct cfg80211_chan_def *chandef)
1371 {
1372 	TODO();
1373 	return (false);
1374 }
1375 
1376 static __inline bool
1377 cfg80211_chandef_dfs_usable(struct wiphy *wiphy, const struct cfg80211_chan_def *chandef)
1378 {
1379 	TODO();
1380 	return (false);
1381 }
1382 
1383 static __inline unsigned int
1384 cfg80211_chandef_dfs_cac_time(struct wiphy *wiphy, const struct cfg80211_chan_def *chandef)
1385 {
1386 	TODO();
1387 	return (0);
1388 }
1389 
1390 static __inline bool
1391 cfg80211_chandef_identical(const struct cfg80211_chan_def *chandef_1,
1392     const struct cfg80211_chan_def *chandef_2)
1393 {
1394 	TODO();
1395 	return (false);
1396 }
1397 
1398 static __inline bool
1399 cfg80211_chandef_usable(struct wiphy *wiphy,
1400     const struct cfg80211_chan_def *chandef, uint32_t flags)
1401 {
1402 	TODO();
1403 	return (false);
1404 }
1405 
1406 static __inline void
1407 cfg80211_bss_iter(struct wiphy *wiphy, struct cfg80211_chan_def *chandef,
1408     void (*iterfunc)(struct wiphy *, struct cfg80211_bss *, void *), void *data)
1409 {
1410 	TODO();
1411 }
1412 
1413 struct element {
1414 	uint8_t					id;
1415 	uint8_t					datalen;
1416 	uint8_t					data[0];
1417 } __packed;
1418 
1419 static inline const struct element *
1420 lkpi_cfg80211_find_elem_pattern(enum ieee80211_eid eid,
1421     const uint8_t *data, size_t len, uint8_t *pattern, size_t plen)
1422 {
1423 	const struct element *elem;
1424 	const uint8_t *p;
1425 	size_t ielen;
1426 
1427 	p = data;
1428 	elem = (const struct element *)p;
1429 	ielen = len;
1430 	while (elem != NULL && ielen > 1) {
1431 		if ((2 + elem->datalen) > ielen)
1432 			/* Element overruns our memory. */
1433 			return (NULL);
1434 		if (elem->id == eid) {
1435 			if (pattern == NULL)
1436 				return (elem);
1437 			if (elem->datalen >= plen &&
1438 			    memcmp(elem->data, pattern, plen) == 0)
1439 				return (elem);
1440 		}
1441 		ielen -= 2 + elem->datalen;
1442 		p += 2 + elem->datalen;
1443 		elem = (const struct element *)p;
1444 	}
1445 
1446 	return (NULL);
1447 }
1448 
1449 static inline const struct element *
1450 cfg80211_find_elem(enum ieee80211_eid eid, const uint8_t *data, size_t len)
1451 {
1452 
1453 	return (lkpi_cfg80211_find_elem_pattern(eid, data, len, NULL, 0));
1454 }
1455 
1456 static inline const struct element *
1457 ieee80211_bss_get_elem(struct cfg80211_bss *bss, uint32_t eid)
1458 {
1459 
1460 	if (bss->ies == NULL)
1461 		return (NULL);
1462 	return (cfg80211_find_elem(eid, bss->ies->data, bss->ies->len));
1463 }
1464 
1465 static inline const uint8_t *
1466 ieee80211_bss_get_ie(struct cfg80211_bss *bss, uint32_t eid)
1467 {
1468 
1469 	return ((const uint8_t *)ieee80211_bss_get_elem(bss, eid));
1470 }
1471 
1472 static inline uint8_t *
1473 cfg80211_find_vendor_ie(unsigned int oui, int oui_type,
1474     uint8_t *data, size_t len)
1475 {
1476 	const struct element *elem;
1477 	uint8_t pattern[4] = { oui << 16, oui << 8, oui, oui_type };
1478 	uint8_t plen = 4;		/* >= 3? oui_type always part of this? */
1479 	IMPROVE("plen currently always incl. oui_type");
1480 
1481 	elem = lkpi_cfg80211_find_elem_pattern(IEEE80211_ELEMID_VENDOR,
1482 	    data, len, pattern, plen);
1483 	if (elem == NULL)
1484 		return (NULL);
1485 	return (__DECONST(uint8_t *, elem));
1486 }
1487 
1488 static inline uint32_t
1489 cfg80211_calculate_bitrate(struct rate_info *rate)
1490 {
1491 	return (linuxkpi_cfg80211_calculate_bitrate(rate));
1492 }
1493 
1494 static __inline uint32_t
1495 ieee80211_channel_to_frequency(uint32_t channel, enum nl80211_band band)
1496 {
1497 
1498 	return (linuxkpi_ieee80211_channel_to_frequency(channel, band));
1499 }
1500 
1501 static __inline uint32_t
1502 ieee80211_frequency_to_channel(uint32_t freq)
1503 {
1504 
1505 	return (linuxkpi_ieee80211_frequency_to_channel(freq, 0));
1506 }
1507 
1508 static __inline int
1509 regulatory_set_wiphy_regd_sync(struct wiphy *wiphy,
1510     struct linuxkpi_ieee80211_regdomain *regd)
1511 {
1512 	IMPROVE();
1513 	return (linuxkpi_regulatory_set_wiphy_regd_sync(wiphy, regd));
1514 }
1515 
1516 static __inline int
1517 regulatory_set_wiphy_regd_sync_rtnl(struct wiphy *wiphy,
1518     struct linuxkpi_ieee80211_regdomain *regd)
1519 {
1520 
1521 	IMPROVE();
1522 	return (linuxkpi_regulatory_set_wiphy_regd_sync(wiphy, regd));
1523 }
1524 
1525 static __inline int
1526 regulatory_set_wiphy_regd(struct wiphy *wiphy,
1527     struct linuxkpi_ieee80211_regdomain *regd)
1528 {
1529 
1530 	IMPROVE();
1531 	if (regd == NULL)
1532 		return (EINVAL);
1533 
1534 	/* XXX-BZ wild guessing here based on brcmfmac. */
1535 	if (wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED)
1536 		wiphy->regd = regd;
1537 	else
1538 		return (EPERM);
1539 
1540 	/* XXX FIXME, do we have to do anything with reg_notifier? */
1541 	return (0);
1542 }
1543 
1544 static __inline int
1545 regulatory_hint(struct wiphy *wiphy, const uint8_t *alpha2)
1546 {
1547 	struct linuxkpi_ieee80211_regdomain *regd;
1548 
1549 	if (wiphy->regd != NULL)
1550 		return (-EBUSY);
1551 
1552 	regd = lkpi_get_linuxkpi_ieee80211_regdomain(0);
1553 	if (regd == NULL)
1554 		return (-ENOMEM);
1555 
1556 	regd->alpha2[0] = alpha2[0];
1557 	regd->alpha2[1] = alpha2[1];
1558 	wiphy->regd = regd;
1559 
1560 	IMPROVE("are there flags who is managing? update net8011?");
1561 
1562 	return (0);
1563 }
1564 
1565 static __inline const char *
1566 reg_initiator_name(enum nl80211_reg_initiator initiator)
1567 {
1568 	TODO();
1569 	return (NULL);
1570 }
1571 
1572 static __inline struct linuxkpi_ieee80211_regdomain *
1573 rtnl_dereference(const struct linuxkpi_ieee80211_regdomain *regd)
1574 {
1575 	TODO();
1576 	return (NULL);
1577 }
1578 
1579 static __inline struct ieee80211_reg_rule *
1580 freq_reg_info(struct wiphy *wiphy, uint32_t center_freq)
1581 {
1582 	TODO();
1583 	return (NULL);
1584 }
1585 
1586 static __inline void
1587 wiphy_apply_custom_regulatory(struct wiphy *wiphy,
1588     const struct linuxkpi_ieee80211_regdomain *regd)
1589 {
1590 	TODO();
1591 }
1592 
1593 static __inline char *
1594 wiphy_name(struct wiphy *wiphy)
1595 {
1596 	if (wiphy != NULL && wiphy->dev != NULL)
1597 		return dev_name(wiphy->dev);
1598 	else {
1599 		IMPROVE("wlanNA");
1600 		return ("wlanNA");
1601 	}
1602 }
1603 
1604 static __inline void
1605 wiphy_read_of_freq_limits(struct wiphy *wiphy)
1606 {
1607 #ifdef FDT
1608 	TODO();
1609 #endif
1610 }
1611 
1612 static __inline void
1613 wiphy_ext_feature_set(struct wiphy *wiphy, enum nl80211_ext_feature ef)
1614 {
1615 
1616 	set_bit(ef, wiphy->ext_features);
1617 }
1618 
1619 static inline bool
1620 wiphy_ext_feature_isset(struct wiphy *wiphy, enum nl80211_ext_feature ef)
1621 {
1622 	return (test_bit(ef, wiphy->ext_features));
1623 }
1624 
1625 static __inline void *
1626 wiphy_net(struct wiphy *wiphy)
1627 {
1628 	TODO();
1629 	return (NULL);	/* XXX passed to dev_net_set() */
1630 }
1631 
1632 static __inline int
1633 wiphy_register(struct wiphy *wiphy)
1634 {
1635 	TODO();
1636 	return (0);
1637 }
1638 
1639 static __inline void
1640 wiphy_unregister(struct wiphy *wiphy)
1641 {
1642 	TODO();
1643 }
1644 
1645 static __inline void
1646 wiphy_warn(struct wiphy *wiphy, const char *fmt, ...)
1647 {
1648 	TODO();
1649 }
1650 
1651 static __inline int
1652 cfg80211_check_combinations(struct wiphy *wiphy,
1653     struct iface_combination_params *params)
1654 {
1655 	TODO();
1656 	return (-ENOENT);
1657 }
1658 
1659 static __inline uint8_t
1660 cfg80211_classify8021d(struct sk_buff *skb, void *p)
1661 {
1662 	TODO();
1663 	return (0);
1664 }
1665 
1666 static __inline void
1667 cfg80211_connect_done(struct net_device *ndev,
1668     struct cfg80211_connect_resp_params *conn_params, gfp_t gfp)
1669 {
1670 	TODO();
1671 }
1672 
1673 static __inline void
1674 cfg80211_crit_proto_stopped(struct wireless_dev *wdev, gfp_t gfp)
1675 {
1676 	TODO();
1677 }
1678 
1679 static __inline void
1680 cfg80211_disconnected(struct net_device *ndev, uint16_t reason,
1681     void *p, int x, bool locally_generated, gfp_t gfp)
1682 {
1683 	TODO();
1684 }
1685 
1686 static __inline int
1687 cfg80211_get_p2p_attr(const u8 *ie, u32 ie_len,
1688     enum ieee80211_p2p_attr_ids attr, u8 *p, size_t p_len)
1689 {
1690 	TODO();
1691 	return (-1);
1692 }
1693 
1694 static __inline void
1695 cfg80211_ibss_joined(struct net_device *ndev, const uint8_t *addr,
1696     struct linuxkpi_ieee80211_channel *chan, gfp_t gfp)
1697 {
1698 	TODO();
1699 }
1700 
1701 static __inline struct cfg80211_bss *
1702 cfg80211_inform_bss(struct wiphy *wiphy,
1703     struct linuxkpi_ieee80211_channel *channel,
1704     enum cfg80211_bss_frame_type bss_ftype, const uint8_t *bss, int _x,
1705     uint16_t cap, uint16_t intvl, const uint8_t *ie, size_t ie_len,
1706     int signal, gfp_t gfp)
1707 {
1708 	TODO();
1709 	return (NULL);
1710 }
1711 
1712 static __inline struct cfg80211_bss *
1713 cfg80211_inform_bss_data(struct wiphy *wiphy,
1714     struct cfg80211_inform_bss *bss_data,
1715     enum cfg80211_bss_frame_type bss_ftype, const uint8_t *bss, int _x,
1716     uint16_t cap, uint16_t intvl, const uint8_t *ie, size_t ie_len, gfp_t gfp)
1717 {
1718 	TODO();
1719 	return (NULL);
1720 }
1721 
1722 static __inline void
1723 cfg80211_mgmt_tx_status(struct wireless_dev *wdev, uint64_t cookie,
1724     const u8 *buf, size_t len, bool ack, gfp_t gfp)
1725 {
1726 	TODO();
1727 }
1728 
1729 static __inline void
1730 cfg80211_michael_mic_failure(struct net_device *ndev, const uint8_t *addr,
1731     enum nl80211_key_type key_type, int _x, void *p, gfp_t gfp)
1732 {
1733 	TODO();
1734 }
1735 
1736 static __inline void
1737 cfg80211_new_sta(struct net_device *ndev, const uint8_t *addr,
1738     struct station_info *sinfo, gfp_t gfp)
1739 {
1740 	TODO();
1741 }
1742 
1743 static __inline void
1744 cfg80211_del_sta(struct net_device *ndev, const uint8_t *addr, gfp_t gfp)
1745 {
1746 	TODO();
1747 }
1748 
1749 static __inline void
1750 cfg80211_port_authorized(struct net_device *ndev, const uint8_t *bssid,
1751     gfp_t gfp)
1752 {
1753 	TODO();
1754 }
1755 
1756 static __inline void
1757 cfg80211_ready_on_channel(struct wireless_dev *wdev, uint64_t cookie,
1758     struct linuxkpi_ieee80211_channel *channel, unsigned int duration,
1759     gfp_t gfp)
1760 {
1761 	TODO();
1762 }
1763 
1764 static __inline void
1765 cfg80211_remain_on_channel_expired(struct wireless_dev *wdev,
1766     uint64_t cookie, struct linuxkpi_ieee80211_channel *channel, gfp_t gfp)
1767 {
1768 	TODO();
1769 }
1770 
1771 static __inline void
1772 cfg80211_report_wowlan_wakeup(void)
1773 {
1774 	TODO();
1775 }
1776 
1777 static __inline void
1778 cfg80211_roamed(struct net_device *ndev, struct cfg80211_roam_info *roam_info,
1779     gfp_t gfp)
1780 {
1781 	TODO();
1782 }
1783 
1784 static __inline void
1785 cfg80211_rx_mgmt(struct wireless_dev *wdev, int freq, int _x,
1786     uint8_t *p, size_t p_len, int _x2)
1787 {
1788 	TODO();
1789 }
1790 
1791 static __inline void
1792 cfg80211_scan_done(struct cfg80211_scan_request *scan_request,
1793     struct cfg80211_scan_info *info)
1794 {
1795 	TODO();
1796 }
1797 
1798 static __inline void
1799 cfg80211_sched_scan_results(struct wiphy *wiphy, uint64_t reqid)
1800 {
1801 	TODO();
1802 }
1803 
1804 static __inline void
1805 cfg80211_sched_scan_stopped(struct wiphy *wiphy, int _x)
1806 {
1807 	TODO();
1808 }
1809 
1810 static __inline void
1811 cfg80211_unregister_wdev(struct wireless_dev *wdev)
1812 {
1813 	TODO();
1814 }
1815 
1816 static __inline struct sk_buff *
1817 cfg80211_vendor_cmd_alloc_reply_skb(struct wiphy *wiphy, unsigned int len)
1818 {
1819 	TODO();
1820 	return (NULL);
1821 }
1822 
1823 static __inline int
1824 cfg80211_vendor_cmd_reply(struct sk_buff *skb)
1825 {
1826 	TODO();
1827 	return (-ENXIO);
1828 }
1829 
1830 static __inline struct linuxkpi_ieee80211_channel *
1831 ieee80211_get_channel(struct wiphy *wiphy, uint32_t freq)
1832 {
1833 
1834 	return (linuxkpi_ieee80211_get_channel(wiphy, freq));
1835 }
1836 
1837 static inline size_t
1838 ieee80211_get_hdrlen_from_skb(struct sk_buff *skb)
1839 {
1840 	const struct ieee80211_hdr *hdr;
1841 	size_t len;
1842 
1843 	if (skb->len < 10)	/* sizeof(ieee80211_frame_[ack,cts]) */
1844 		return (0);
1845 
1846 	hdr = (const struct ieee80211_hdr *)skb->data;
1847 	len = ieee80211_hdrlen(hdr->frame_control);
1848 
1849 	/* If larger than what is in the skb return. */
1850 	if (len > skb->len)
1851 		return (0);
1852 
1853 	return (len);
1854 }
1855 
1856 static __inline bool
1857 cfg80211_channel_is_psc(struct linuxkpi_ieee80211_channel *channel)
1858 {
1859 
1860 	/* Only 6Ghz. */
1861 	if (channel->band != NL80211_BAND_6GHZ)
1862 		return (false);
1863 
1864 	TODO();
1865 	return (false);
1866 }
1867 
1868 static inline int
1869 cfg80211_get_ies_channel_number(const uint8_t *ie, size_t len,
1870     enum nl80211_band band)
1871 {
1872 	const struct element *elem;
1873 
1874 	switch (band) {
1875 	case NL80211_BAND_6GHZ:
1876 		TODO();
1877 		break;
1878 	case NL80211_BAND_5GHZ:
1879 	case NL80211_BAND_2GHZ:
1880 		/* DSPARAMS has the channel number. */
1881 		elem = cfg80211_find_elem(IEEE80211_ELEMID_DSPARMS, ie, len);
1882 		if (elem != NULL && elem->datalen == 1)
1883 			return (elem->data[0]);
1884 		/* HTINFO has the primary center channel. */
1885 		elem = cfg80211_find_elem(IEEE80211_ELEMID_HTINFO, ie, len);
1886 		if (elem != NULL &&
1887 		    elem->datalen >= (sizeof(struct ieee80211_ie_htinfo) - 2)) {
1888 			const struct ieee80211_ie_htinfo *htinfo;
1889 			htinfo = (const struct ieee80211_ie_htinfo *)elem;
1890 			return (htinfo->hi_ctrlchannel);
1891 		}
1892 		/* What else? */
1893 		break;
1894 	default:
1895 		IMPROVE("Unsupported");
1896 		break;
1897 	}
1898 	return (-1);
1899 }
1900 
1901 /* Used for scanning at least. */
1902 static __inline void
1903 get_random_mask_addr(uint8_t *dst, const uint8_t *addr, const uint8_t *mask)
1904 {
1905 	int i;
1906 
1907 	/* Get a completely random address and then overlay what we want. */
1908 	get_random_bytes(dst, ETH_ALEN);
1909 	for (i = 0; i < ETH_ALEN; i++)
1910 		dst[i] = (dst[i] & ~(mask[i])) | (addr[i] & mask[i]);
1911 }
1912 
1913 static __inline void
1914 cfg80211_shutdown_all_interfaces(struct wiphy *wiphy)
1915 {
1916 	TODO();
1917 }
1918 
1919 static __inline bool
1920 cfg80211_reg_can_beacon(struct wiphy *wiphy, struct cfg80211_chan_def *chandef,
1921     enum nl80211_iftype iftype)
1922 {
1923 	TODO();
1924 	return (false);
1925 }
1926 
1927 static __inline void
1928 cfg80211_background_radar_event(struct wiphy *wiphy,
1929     struct cfg80211_chan_def *chandef, gfp_t gfp)
1930 {
1931 	TODO();
1932 }
1933 
1934 static __inline const u8 *
1935 cfg80211_find_ext_ie(uint8_t eid, const uint8_t *p, size_t len)
1936 {
1937 	TODO();
1938 	return (NULL);
1939 }
1940 
1941 static inline void
1942 _ieee80211_set_sband_iftype_data(struct ieee80211_supported_band *band,
1943     struct ieee80211_sband_iftype_data *iftype_data, size_t nitems)
1944 {
1945 	band->iftype_data = iftype_data;
1946 	band->n_iftype_data = nitems;
1947 }
1948 
1949 static inline const struct ieee80211_sband_iftype_data *
1950 ieee80211_get_sband_iftype_data(const struct ieee80211_supported_band *band,
1951     enum nl80211_iftype iftype)
1952 {
1953 	const struct ieee80211_sband_iftype_data *iftype_data;
1954 	int i;
1955 
1956 	for (i = 0; i < band->n_iftype_data; i++) {
1957 		iftype_data = (const void *)&band->iftype_data[i];
1958 		if (iftype_data->types_mask & BIT(iftype))
1959 			return (iftype_data);
1960 	}
1961 
1962 	return (NULL);
1963 }
1964 
1965 static inline const struct ieee80211_sta_he_cap *
1966 ieee80211_get_he_iftype_cap(const struct ieee80211_supported_band *band,
1967     enum nl80211_iftype iftype)
1968 {
1969 	const struct ieee80211_sband_iftype_data *iftype_data;
1970 	const struct ieee80211_sta_he_cap *he_cap;
1971 
1972 	iftype_data = ieee80211_get_sband_iftype_data(band, iftype);
1973 	if (iftype_data == NULL)
1974 		return (NULL);
1975 
1976 	he_cap = NULL;
1977 	if (iftype_data->he_cap.has_he)
1978 		he_cap = &iftype_data->he_cap;
1979 
1980 	return (he_cap);
1981 }
1982 
1983 static inline const struct ieee80211_sta_eht_cap *
1984 ieee80211_get_eht_iftype_cap(const struct ieee80211_supported_band *band,
1985     enum nl80211_iftype iftype)
1986 {
1987 	const struct ieee80211_sband_iftype_data *iftype_data;
1988 	const struct ieee80211_sta_eht_cap *eht_cap;
1989 
1990 	iftype_data = ieee80211_get_sband_iftype_data(band, iftype);
1991 	if (iftype_data == NULL)
1992 		return (NULL);
1993 
1994 	eht_cap = NULL;
1995 	if (iftype_data->eht_cap.has_eht)
1996 		eht_cap = &iftype_data->eht_cap;
1997 
1998 	return (eht_cap);
1999 }
2000 
2001 static inline bool
2002 cfg80211_ssid_eq(struct cfg80211_ssid *ssid1, struct cfg80211_ssid *ssid2)
2003 {
2004 	int error;
2005 
2006 	if (ssid1 == NULL || ssid2 == NULL)	/* Can we KASSERT this? */
2007 		return (false);
2008 
2009 	if (ssid1->ssid_len != ssid2->ssid_len)
2010 		return (false);
2011 	error = memcmp(ssid1->ssid, ssid2->ssid, ssid2->ssid_len);
2012 	if (error != 0)
2013 		return (false);
2014 	return (true);
2015 }
2016 
2017 static inline void
2018 cfg80211_rx_unprot_mlme_mgmt(struct net_device *ndev, const uint8_t *hdr,
2019     uint32_t len)
2020 {
2021 	TODO();
2022 }
2023 
2024 static inline const struct wiphy_iftype_ext_capab *
2025 cfg80211_get_iftype_ext_capa(struct wiphy *wiphy, enum nl80211_iftype iftype)
2026 {
2027 
2028 	TODO();
2029 	return (NULL);
2030 }
2031 
2032 static inline uint16_t
2033 ieee80211_get_he_6ghz_capa(const struct ieee80211_supported_band *sband,
2034     enum nl80211_iftype iftype)
2035 {
2036 	TODO();
2037 	return (0);
2038 }
2039 
2040 static inline int
2041 nl80211_chan_width_to_mhz(enum nl80211_chan_width width)
2042 {
2043 	switch (width) {
2044 	case NL80211_CHAN_WIDTH_5:
2045 		return (5);
2046 		break;
2047 	case NL80211_CHAN_WIDTH_10:
2048 		return (10);
2049 		break;
2050 	case NL80211_CHAN_WIDTH_20_NOHT:
2051 	case NL80211_CHAN_WIDTH_20:
2052 		return (20);
2053 		break;
2054 	case NL80211_CHAN_WIDTH_40:
2055 		return (40);
2056 		break;
2057 	case NL80211_CHAN_WIDTH_80:
2058 	case NL80211_CHAN_WIDTH_80P80:
2059 		return (80);
2060 		break;
2061 	case NL80211_CHAN_WIDTH_160:
2062 		return (160);
2063 		break;
2064 	case NL80211_CHAN_WIDTH_320:
2065 		return (320);
2066 		break;
2067 	}
2068 }
2069 
2070 static __inline ssize_t
2071 wiphy_locked_debugfs_read(struct wiphy *wiphy, struct file *file,
2072     char *buf, size_t bufsize, const char __user *userbuf, size_t count,
2073     loff_t *ppos,
2074     ssize_t (*handler)(struct wiphy *, struct file *, char *, size_t, void *),
2075     void *data)
2076 {
2077 	TODO();
2078 	return (-ENXIO);
2079 }
2080 
2081 
2082 static __inline ssize_t
2083 wiphy_locked_debugfs_write(struct wiphy *wiphy, struct file *file,
2084     char *buf, size_t bufsize, const char __user *userbuf, size_t count,
2085     ssize_t (*handler)(struct wiphy *, struct file *, char *, size_t, void *),
2086     void *data)
2087 {
2088 	TODO();
2089 	return (-ENXIO);
2090 }
2091 
2092 /* -------------------------------------------------------------------------- */
2093 
2094 static inline void
2095 wiphy_work_init(struct wiphy_work *wwk, wiphy_work_fn fn)
2096 {
2097 	INIT_LIST_HEAD(&wwk->entry);
2098 	wwk->fn = fn;
2099 }
2100 
2101 static inline void
2102 wiphy_work_queue(struct wiphy *wiphy, struct wiphy_work *wwk)
2103 {
2104 	linuxkpi_wiphy_work_queue(wiphy, wwk);
2105 }
2106 
2107 static inline void
2108 wiphy_work_cancel(struct wiphy *wiphy, struct wiphy_work *wwk)
2109 {
2110 	linuxkpi_wiphy_work_cancel(wiphy, wwk);
2111 }
2112 
2113 static inline void
2114 wiphy_work_flush(struct wiphy *wiphy, struct wiphy_work *wwk)
2115 {
2116 	linuxkpi_wiphy_work_flush(wiphy, wwk);
2117 }
2118 
2119 static inline void
2120 wiphy_delayed_work_init(struct wiphy_delayed_work *wdwk, wiphy_work_fn fn)
2121 {
2122 	wiphy_work_init(&wdwk->work, fn);
2123 	timer_setup(&wdwk->timer, lkpi_wiphy_delayed_work_timer, 0);
2124 }
2125 
2126 static inline void
2127 wiphy_delayed_work_queue(struct wiphy *wiphy, struct wiphy_delayed_work *wdwk,
2128     unsigned long delay)
2129 {
2130 	linuxkpi_wiphy_delayed_work_queue(wiphy, wdwk, delay);
2131 }
2132 
2133 static inline void
2134 wiphy_delayed_work_cancel(struct wiphy *wiphy, struct wiphy_delayed_work *wdwk)
2135 {
2136 	linuxkpi_wiphy_delayed_work_cancel(wiphy, wdwk);
2137 }
2138 
2139 /* -------------------------------------------------------------------------- */
2140 
2141 #define	wiphy_err(_wiphy, _fmt, ...)					\
2142     dev_err((_wiphy)->dev, _fmt, __VA_ARGS__)
2143 #define	wiphy_info(wiphy, fmt, ...)					\
2144     dev_info((wiphy)->dev, fmt, ##__VA_ARGS__)
2145 #define	wiphy_info_once(wiphy, fmt, ...)				\
2146     dev_info_once((wiphy)->dev, fmt, ##__VA_ARGS__)
2147 
2148 #ifndef LINUXKPI_NET80211
2149 #define	ieee80211_channel		linuxkpi_ieee80211_channel
2150 #define	ieee80211_regdomain		linuxkpi_ieee80211_regdomain
2151 #endif
2152 
2153 #include <net/mac80211.h>
2154 
2155 #endif	/* _LINUXKPI_NET_CFG80211_H */
2156