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