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