1 /*-
2  * Copyright (c) 2020-2023 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  * $FreeBSD$
30  */
31 
32 #ifndef	_LINUXKPI_NET_CFG80211_H
33 #define	_LINUXKPI_NET_CFG80211_H
34 
35 #include <linux/types.h>
36 #include <linux/nl80211.h>
37 #include <linux/ieee80211.h>
38 #include <linux/if_ether.h>
39 #include <linux/ethtool.h>
40 #include <linux/device.h>
41 #include <linux/netdevice.h>
42 #include <linux/random.h>
43 #include <linux/skbuff.h>
44 #include <net/regulatory.h>
45 
46 /* linux_80211.c */
47 extern int linuxkpi_debug_80211;
48 #ifndef	D80211_TODO
49 #define	D80211_TODO		0x1
50 #endif
51 #ifndef	D80211_IMPROVE
52 #define	D80211_IMPROVE		0x2
53 #endif
54 #define	TODO(...)		if (linuxkpi_debug_80211 & D80211_TODO)	\
55     printf("%s:%d: XXX LKPI80211 TODO\n", __func__, __LINE__)
56 #define	IMPROVE(...)	if (linuxkpi_debug_80211 & D80211_IMPROVE)	\
57     printf("%s:%d: XXX LKPI80211 IMPROVE\n", __func__, __LINE__)
58 
59 enum rfkill_hard_block_reasons {
60 	RFKILL_HARD_BLOCK_NOT_OWNER		= BIT(0),
61 };
62 
63 #define	WIPHY_PARAM_FRAG_THRESHOLD			__LINE__ /* TODO FIXME brcmfmac */
64 #define	WIPHY_PARAM_RETRY_LONG				__LINE__ /* TODO FIXME brcmfmac */
65 #define	WIPHY_PARAM_RETRY_SHORT				__LINE__ /* TODO FIXME brcmfmac */
66 #define	WIPHY_PARAM_RTS_THRESHOLD			__LINE__ /* TODO FIXME brcmfmac */
67 
68 #define	CFG80211_SIGNAL_TYPE_MBM			__LINE__ /* TODO FIXME brcmfmac */
69 
70 #define	UPDATE_ASSOC_IES	1
71 
72 #define	IEEE80211_MAX_CHAINS	4		/* net80211: IEEE80211_MAX_CHAINS copied */
73 
74 enum cfg80211_rate_info_flags {
75 	RATE_INFO_FLAGS_SHORT_GI	= BIT(0),
76 	RATE_INFO_FLAGS_MCS		= BIT(1),
77 	RATE_INFO_FLAGS_VHT_MCS		= BIT(2),
78 	RATE_INFO_FLAGS_HE_MCS		= BIT(3),
79 	/* Max 8 bits as used in struct rate_info. */
80 };
81 
82 extern const uint8_t rfc1042_header[6];
83 extern const uint8_t bridge_tunnel_header[6];
84 
85 enum ieee80211_privacy {
86 	IEEE80211_PRIVACY_ANY,
87 };
88 
89 enum ieee80211_bss_type {
90 	IEEE80211_BSS_TYPE_ANY,
91 };
92 
93 enum cfg80211_bss_frame_type {
94 	CFG80211_BSS_FTYPE_UNKNOWN,
95 	CFG80211_BSS_FTYPE_BEACON,
96 	CFG80211_BSS_FTYPE_PRESP,
97 };
98 
99 enum ieee80211_channel_flags {
100 	IEEE80211_CHAN_DISABLED			= BIT(0),
101 	IEEE80211_CHAN_INDOOR_ONLY		= BIT(1),
102 	IEEE80211_CHAN_IR_CONCURRENT		= BIT(2),
103 	IEEE80211_CHAN_RADAR			= BIT(3),
104 	IEEE80211_CHAN_NO_IR			= BIT(4),
105 	IEEE80211_CHAN_NO_HT40MINUS		= BIT(5),
106 	IEEE80211_CHAN_NO_HT40PLUS		= BIT(6),
107 	IEEE80211_CHAN_NO_80MHZ			= BIT(7),
108 	IEEE80211_CHAN_NO_160MHZ		= BIT(8),
109 	IEEE80211_CHAN_NO_OFDM			= BIT(9),
110 };
111 #define	IEEE80211_CHAN_NO_HT40	(IEEE80211_CHAN_NO_HT40MINUS|IEEE80211_CHAN_NO_HT40PLUS)
112 
113 struct ieee80211_txrx_stypes {
114 	uint16_t	tx;
115 	uint16_t	rx;
116 };
117 
118 /* XXX net80211 has an ieee80211_channel as well. */
119 struct linuxkpi_ieee80211_channel {
120 	/* TODO FIXME */
121 	uint32_t				hw_value;	/* ic_ieee */
122 	uint32_t				center_freq;	/* ic_freq */
123 	enum ieee80211_channel_flags		flags;		/* ic_flags */
124 	enum nl80211_band			band;
125 	int8_t					max_power;	/* ic_maxpower */
126 	bool					beacon_found;
127 	int     max_antenna_gain, max_reg_power;
128 	int     orig_flags;
129 	int	dfs_cac_ms, dfs_state;
130 	int	orig_mpwr;
131 };
132 
133 struct cfg80211_bitrate_mask {
134 	/* TODO FIXME */
135 	struct {
136 		uint32_t			legacy;
137 		uint8_t				ht_mcs[IEEE80211_HT_MCS_MASK_LEN];
138 		uint16_t			vht_mcs[8];
139 		uint16_t			he_mcs[8];
140 		enum nl80211_txrate_gi		gi;
141 		enum nl80211_he_gi		he_gi;
142 		uint8_t				he_ltf;		/* XXX enum? */
143 	} control[NUM_NL80211_BANDS];
144 };
145 
146 enum rate_info_bw {
147 	RATE_INFO_BW_20		= 0,
148 	RATE_INFO_BW_5,
149 	RATE_INFO_BW_10,
150 	RATE_INFO_BW_40,
151 	RATE_INFO_BW_80,
152 	RATE_INFO_BW_160,
153 	RATE_INFO_BW_HE_RU,
154 };
155 
156 struct rate_info {
157 	uint8_t					flags;			/* enum cfg80211_rate_info_flags */
158 	uint8_t					bw;
159 	uint16_t				legacy;
160 	uint8_t					mcs;
161 	uint8_t					nss;
162 	uint8_t					he_dcm;
163 	uint8_t					he_gi;
164 	uint8_t					he_ru_alloc;
165 };
166 
167 struct ieee80211_rate {
168 	/* TODO FIXME */
169 	uint32_t		bitrate;
170 	uint32_t		hw_value;
171 	uint32_t		hw_value_short;
172 	uint32_t		flags;
173 };
174 
175 struct ieee80211_sta_ht_cap {
176 	bool					ht_supported;
177 	uint8_t					ampdu_density;
178 	uint8_t					ampdu_factor;
179 	uint16_t				cap;
180 	struct ieee80211_mcs_info		mcs;
181 };
182 
183 /* XXX net80211 calls these IEEE80211_VHTCAP_* */
184 #define	IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895	0x00000000	/* IEEE80211_VHTCAP_MAX_MPDU_LENGTH_3895 */
185 #define	IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991	0x00000001	/* IEEE80211_VHTCAP_MAX_MPDU_LENGTH_7991 */
186 #define	IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454	0x00000002	/* IEEE80211_VHTCAP_MAX_MPDU_LENGTH_11454 */
187 #define	IEEE80211_VHT_CAP_MAX_MPDU_MASK		0x00000003	/* IEEE80211_VHTCAP_MAX_MPDU_MASK */
188 
189 #define	IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ		(IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_160MHZ << IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_MASK_S)
190 #define	IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ	(IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_160_80P80MHZ << IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_MASK_S)
191 #define	IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK	0x0000000c	/* IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_MASK */
192 
193 #define	IEEE80211_VHT_CAP_RXLDPC		0x00000010	/* IEEE80211_VHTCAP_RXLDPC */
194 
195 #define	IEEE80211_VHT_CAP_SHORT_GI_80		0x00000020	/* IEEE80211_VHTCAP_SHORT_GI_80 */
196 #define	IEEE80211_VHT_CAP_SHORT_GI_160		0x00000040	/* IEEE80211_VHTCAP_SHORT_GI_160 */
197 
198 #define	IEEE80211_VHT_CAP_TXSTBC		0x00000080	/* IEEE80211_VHTCAP_TXSTBC */
199 
200 #define	IEEE80211_VHT_CAP_RXSTBC_1		0x00000100	/* IEEE80211_VHTCAP_RXSTBC_1 */
201 #define	IEEE80211_VHT_CAP_RXSTBC_MASK		0x00000700	/* IEEE80211_VHTCAP_RXSTBC_MASK */
202 
203 #define	IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE	0x00000800	/* IEEE80211_VHTCAP_SU_BEAMFORMER_CAPABLE */
204 
205 #define	IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE	0x00001000	/* IEEE80211_VHTCAP_SU_BEAMFORMEE_CAPABLE */
206 
207 #define	IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE	0x00080000	/* IEEE80211_VHTCAP_MU_BEAMFORMER_CAPABLE */
208 
209 #define	IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE	0x00100000	/* IEEE80211_VHTCAP_MU_BEAMFORMEE_CAPABLE */
210 
211 #define	IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT		13	/* IEEE80211_VHTCAP_BEAMFORMEE_STS_SHIFT */
212 #define	IEEE80211_VHT_CAP_BEAMFORMEE_STS_MASK		(7 << IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT)	/* IEEE80211_VHTCAP_BEAMFORMEE_STS_MASK */
213 
214 #define	IEEE80211_VHT_CAP_HTC_VHT		0x00400000	/* IEEE80211_VHTCAP_HTC_VHT */
215 
216 #define	IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN	0x10000000	/* IEEE80211_VHTCAP_RX_ANTENNA_PATTERN */
217 #define	IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN	0x20000000	/* IEEE80211_VHTCAP_TX_ANTENNA_PATTERN */
218 
219 #define	IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB	0x0c000000	/* IEEE80211_VHTCAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB */
220 
221 #define	IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT	16	/* IEEE80211_VHTCAP_SOUNDING_DIMENSIONS_SHIFT */
222 #define	IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_MASK		\
223 	(7 << IEEE80211_VHTCAP_SOUNDING_DIMENSIONS_SHIFT)	/* IEEE80211_VHTCAP_SOUNDING_DIMENSIONS_MASK */
224 
225 #define	IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT	23	/* IEEE80211_VHTCAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT */
226 #define	IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK	\
227 	(7 << IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT)	/* IEEE80211_VHTCAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK */
228 
229 
230 struct ieee80211_sta_vht_cap {
231 		/* TODO FIXME */
232 	bool				vht_supported;
233 	uint32_t			cap;
234 	struct ieee80211_vht_mcs_info	vht_mcs;
235 };
236 
237 enum ieee80211_vht_opmode {
238 	IEEE80211_OPMODE_NOTIF_RX_NSS_SHIFT	= 4,
239 };
240 
241 struct cfg80211_connect_resp_params {
242 		/* XXX TODO */
243 	uint8_t				*bssid;
244 	const uint8_t			*req_ie;
245 	const uint8_t			*resp_ie;
246 	uint32_t			req_ie_len;
247 	uint32_t			resp_ie_len;
248 	int	status;
249 };
250 
251 struct cfg80211_inform_bss {
252 		/* XXX TODO */
253 	int     boottime_ns, scan_width, signal;
254 	struct linuxkpi_ieee80211_channel	*chan;
255 };
256 
257 struct cfg80211_roam_info {
258 		/* XXX TODO */
259 	uint8_t				*bssid;
260 	const uint8_t			*req_ie;
261 	const uint8_t			*resp_ie;
262 	uint32_t			req_ie_len;
263 	uint32_t			resp_ie_len;
264 	struct linuxkpi_ieee80211_channel	*channel;
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 };
276 
277 struct cfg80211_chan_def {
278 		/* XXX TODO */
279 	struct linuxkpi_ieee80211_channel	*chan;
280 	enum nl80211_chan_width		width;
281 	uint32_t			center_freq1;
282 	uint32_t			center_freq2;
283 };
284 
285 struct cfg80211_ftm_responder_stats {
286 		/* XXX TODO */
287 	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;
288 };
289 
290 struct cfg80211_pmsr_capabilities {
291 		/* XXX TODO */
292 	int	max_peers, randomize_mac_addr, report_ap_tsf;
293 	struct {
294 		int	 asap, bandwidths, max_bursts_exponent, max_ftms_per_burst, non_asap, non_trigger_based, preambles, request_civicloc, request_lci, supported, trigger_based;
295 	} ftm;
296 };
297 
298 struct cfg80211_pmsr_ftm_request {
299 		/* XXX TODO */
300 	int     asap, burst_period, ftmr_retries, ftms_per_burst, non_trigger_based, num_bursts_exp, request_civicloc, request_lci, trigger_based;
301 	uint8_t					bss_color;
302 	bool					lmr_feedback;
303 };
304 
305 struct cfg80211_pmsr_request_peer {
306 		/* XXX TODO */
307 	struct cfg80211_chan_def		chandef;
308 	struct cfg80211_pmsr_ftm_request	ftm;
309 	uint8_t					addr[ETH_ALEN];
310 	int	report_ap_tsf;
311 };
312 
313 struct cfg80211_pmsr_request {
314 		/* XXX TODO */
315 	int	cookie, n_peers, timeout;
316 	uint8_t					mac_addr[ETH_ALEN], mac_addr_mask[ETH_ALEN];
317 	struct cfg80211_pmsr_request_peer	peers[];
318 };
319 
320 struct cfg80211_pmsr_ftm_result {
321 		/* XXX TODO */
322 	int	burst_index, busy_retry_time, failure_reason;
323 	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;
324 	uint8_t					*lci;
325 	uint8_t					*civicloc;
326 	int					lci_len;
327 	int					civicloc_len;
328 };
329 
330 struct cfg80211_pmsr_result {
331 		/* XXX TODO */
332 	int	ap_tsf, ap_tsf_valid, final, host_time, status, type;
333 	uint8_t					addr[ETH_ALEN];
334 	struct cfg80211_pmsr_ftm_result		ftm;
335 };
336 
337 struct cfg80211_sar_freq_ranges {
338 	uint32_t				start_freq;
339 	uint32_t				end_freq;
340 };
341 
342 struct cfg80211_sar_sub_specs {
343 	uint32_t				freq_range_index;
344 	int					power;
345 };
346 
347 struct cfg80211_sar_specs {
348 	enum nl80211_sar_type			type;
349 	uint32_t				num_sub_specs;
350 	struct cfg80211_sar_sub_specs		sub_specs[];
351 };
352 
353 struct cfg80211_sar_capa {
354 	enum nl80211_sar_type			type;
355 	uint32_t				num_freq_ranges;
356 	const struct cfg80211_sar_freq_ranges	*freq_ranges;
357 };
358 
359 struct cfg80211_ssid {
360 	int	ssid_len;
361 	uint8_t	ssid[IEEE80211_MAX_SSID_LEN];
362 };
363 
364 struct cfg80211_scan_6ghz_params {
365 	/* XXX TODO */
366 	uint8_t				*bssid;
367 	int	channel_idx, psc_no_listen, short_ssid, short_ssid_valid, unsolicited_probe;
368 };
369 
370 struct cfg80211_match_set {
371 	uint8_t					bssid[ETH_ALEN];
372 	struct cfg80211_ssid	ssid;
373 	int			rssi_thold;
374 };
375 
376 struct cfg80211_scan_request {
377 		/* XXX TODO */
378 	int	duration, duration_mandatory, flags;
379 	bool					no_cck;
380 	bool					scan_6ghz;
381 	struct wireless_dev			*wdev;
382 	struct wiphy				*wiphy;
383 	int					ie_len;
384 	uint8_t					*ie;
385 	uint8_t					mac_addr[ETH_ALEN], mac_addr_mask[ETH_ALEN];
386 	uint8_t					bssid[ETH_ALEN];
387 	int					n_ssids;
388 	int					n_6ghz_params;
389 	int					n_channels;
390 	struct cfg80211_ssid			*ssids;
391 	struct cfg80211_scan_6ghz_params 	*scan_6ghz_params;
392 	struct linuxkpi_ieee80211_channel	*channels[0];
393 };
394 
395 struct cfg80211_sched_scan_plan {
396 		/* XXX TODO */
397 	int	interval, iterations;
398 };
399 
400 struct cfg80211_sched_scan_request {
401 		/* XXX TODO */
402 	int	delay, flags;
403 	uint8_t					mac_addr[ETH_ALEN], mac_addr_mask[ETH_ALEN];
404 	uint64_t				reqid;
405 	int					n_match_sets;
406 	int					n_scan_plans;
407 	int					n_ssids;
408 	int					n_channels;
409 	int					ie_len;
410 	uint8_t					*ie;
411 	struct cfg80211_match_set		*match_sets;
412 	struct cfg80211_sched_scan_plan		*scan_plans;
413 	struct cfg80211_ssid			*ssids;
414 	struct linuxkpi_ieee80211_channel	*channels[0];
415 };
416 
417 struct cfg80211_scan_info {
418 	uint64_t				scan_start_tsf;
419 	uint8_t					tsf_bssid[ETH_ALEN];
420 	bool					aborted;
421 };
422 
423 struct cfg80211_beacon_data {
424 	/* XXX TODO */
425 	const uint8_t				*head;
426 	const uint8_t				*tail;
427 	uint32_t				head_len;
428 	uint32_t				tail_len;
429 	const uint8_t				*proberesp_ies;
430 	const uint8_t				*assocresp_ies;
431 	uint32_t				proberesp_ies_len;
432 	uint32_t				assocresp_ies_len;
433 };
434 
435 struct cfg80211_ap_settings {
436 	/* XXX TODO */
437 	int     auth_type, beacon_interval, dtim_period, hidden_ssid, inactivity_timeout;
438 	const uint8_t				*ssid;
439 	size_t					ssid_len;
440 	struct cfg80211_beacon_data		beacon;
441 	struct cfg80211_chan_def		chandef;
442 };
443 
444 struct cfg80211_bss_selection {
445 	/* XXX TODO */
446 	enum nl80211_bss_select_attr		behaviour;
447 	union {
448 		enum nl80211_band		band_pref;
449 		struct {
450 			enum nl80211_band	band;
451 			uint8_t			delta;
452 		} adjust;
453 	} param;
454 };
455 
456 struct cfg80211_crypto {		/* XXX made up name */
457 	/* XXX TODO */
458 	enum nl80211_wpa_versions		wpa_versions;
459 	uint32_t				cipher_group;	/* WLAN_CIPHER_SUITE_* */
460 	uint32_t				*akm_suites;
461 	uint32_t				*ciphers_pairwise;
462 	const uint8_t				*sae_pwd;
463 	const uint8_t				*psk;
464 	int					n_akm_suites;
465 	int					n_ciphers_pairwise;
466 	int					sae_pwd_len;
467 };
468 
469 struct cfg80211_connect_params {
470 	/* XXX TODO */
471 	struct linuxkpi_ieee80211_channel	*channel;
472 	uint8_t					*bssid;
473 	const uint8_t				*ie;
474 	const uint8_t				*ssid;
475 	uint32_t				ie_len;
476 	uint32_t				ssid_len;
477 	const void				*key;
478 	uint32_t				key_len;
479 	int     auth_type, key_idx, privacy, want_1x;
480 	struct cfg80211_bss_selection		bss_select;
481 	struct cfg80211_crypto			crypto;
482 };
483 
484 enum bss_param_flags {		/* Used as bitflags. XXX FIXME values? */
485 	BSS_PARAM_FLAGS_CTS_PROT	= 0x01,
486 	BSS_PARAM_FLAGS_SHORT_PREAMBLE	= 0x02,
487 	BSS_PARAM_FLAGS_SHORT_SLOT_TIME = 0x04,
488 };
489 
490 struct cfg80211_ibss_params {
491 	/* XXX TODO */
492 	int     basic_rates, beacon_interval;
493 	int	channel_fixed, ie, ie_len, privacy;
494 	int	dtim_period;
495 	uint8_t					*ssid;
496 	uint8_t					*bssid;
497 	int					ssid_len;
498 	struct cfg80211_chan_def		chandef;
499 	enum bss_param_flags			flags;
500 };
501 
502 struct cfg80211_mgmt_tx_params {
503 	/* XXX TODO */
504 	struct linuxkpi_ieee80211_channel	*chan;
505 	const uint8_t				*buf;
506 	size_t					len;
507 	int	wait;
508 };
509 
510 struct cfg80211_pmk_conf {
511 	/* XXX TODO */
512 	const uint8_t			*pmk;
513 	uint8_t				pmk_len;
514 };
515 
516 struct cfg80211_pmksa {
517 	/* XXX TODO */
518 	const uint8_t			*bssid;
519 	const uint8_t			*pmkid;
520 };
521 
522 struct station_del_parameters {
523 	/* XXX TODO */
524 	const uint8_t				*mac;
525 	uint32_t				reason_code;	/* elsewhere uint16_t? */
526 };
527 
528 struct station_info {
529 	/* TODO FIXME */
530 	int     assoc_req_ies_len, connected_time;
531 	int	generation, inactive_time, rx_bytes, rx_dropped_misc, rx_packets, signal, tx_bytes, tx_packets;
532 	int     filled, rx_beacon, rx_beacon_signal_avg, signal_avg;
533 	int	rx_duration, tx_duration, tx_failed, tx_retries;
534 
535 	int					chains;
536 	uint8_t					chain_signal[IEEE80211_MAX_CHAINS];
537 	uint8_t					chain_signal_avg[IEEE80211_MAX_CHAINS];
538 
539 	uint8_t					*assoc_req_ies;
540 	struct rate_info			rxrate;
541 	struct rate_info			txrate;
542 	struct cfg80211_ibss_params		bss_param;
543 	struct nl80211_sta_flag_update		sta_flags;
544 };
545 
546 struct station_parameters {
547 	/* XXX TODO */
548 	int     sta_flags_mask, sta_flags_set;
549 };
550 
551 struct key_params {
552 	/* XXX TODO */
553 	const uint8_t	*key;
554 	const uint8_t	*seq;
555 	int		key_len;
556 	int		seq_len;
557 	uint32_t	cipher;			/* WLAN_CIPHER_SUITE_* */
558 };
559 
560 struct mgmt_frame_regs {
561 	/* XXX TODO */
562 	int	interface_stypes;
563 };
564 
565 struct vif_params {
566 	/* XXX TODO */
567 	uint8_t			macaddr[ETH_ALEN];
568 };
569 
570 /* That the world needs so many different structs for this is amazing. */
571 struct mac_address {
572 	uint8_t	addr[ETH_ALEN];
573 };
574 
575 struct ieee80211_reg_rule {
576 	/* TODO FIXME */
577 	uint32_t	flags;
578 	int	dfs_cac_ms;
579 	struct freq_range {
580 		int	start_freq_khz;
581 		int	end_freq_khz;
582 		int	max_bandwidth_khz;
583 	} freq_range;
584 	struct power_rule {
585 		int	max_antenna_gain;
586 		int	max_eirp;
587 	} power_rule;
588 };
589 
590 struct linuxkpi_ieee80211_regdomain {
591 	/* TODO FIXME */
592 	uint8_t					alpha2[2];
593 	int	dfs_region;
594 	int					n_reg_rules;
595 	struct ieee80211_reg_rule		reg_rules[];
596 };
597 
598 /* XXX-BZ this are insensible values probably ... */
599 #define	IEEE80211_HE_MAC_CAP0_HTC_HE			0x1
600 #define	IEEE80211_HE_MAC_CAP0_TWT_REQ			0x2
601 #define	IEEE80211_HE_MAC_CAP0_TWT_RES			0x4
602 
603 #define	IEEE80211_HE_MAC_CAP1_LINK_ADAPTATION		0x1
604 #define	IEEE80211_HE_MAC_CAP1_MULTI_TID_AGG_RX_QOS_8	0x2
605 #define	IEEE80211_HE_MAC_CAP1_TF_MAC_PAD_DUR_16US	0x4
606 #define	IEEE80211_HE_MAC_CAP1_TF_MAC_PAD_DUR_MASK	0x8
607 
608 #define	IEEE80211_HE_MAC_CAP2_32BIT_BA_BITMAP		0x1
609 #define	IEEE80211_HE_MAC_CAP2_ACK_EN			0x2
610 #define	IEEE80211_HE_MAC_CAP2_BSR			0x4
611 #define	IEEE80211_HE_MAC_CAP2_LINK_ADAPTATION		0x8
612 #define	IEEE80211_HE_MAC_CAP2_BCAST_TWT			0x10
613 #define	IEEE80211_HE_MAC_CAP2_ALL_ACK			0x20
614 #define	IEEE80211_HE_MAC_CAP2_MU_CASCADING		0x40
615 #define	IEEE80211_HE_MAC_CAP2_TRS			0x80
616 
617 #define	IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_VHT_2	0x1
618 #define	IEEE80211_HE_MAC_CAP3_OMI_CONTROL		0x2
619 #define	IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_EXT_1	0x10
620 #define	IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_EXT_2	0x20
621 #define	IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_EXT_3	0x40
622 #define	IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_MASK	0x70
623 #define	IEEE80211_HE_MAC_CAP3_RX_CTRL_FRAME_TO_MULTIBSS	0x80
624 #define	IEEE80211_HE_MAC_CAP3_FLEX_TWT_SCHED		0x80
625 #define	IEEE80211_HE_MAC_CAP3_OFDMA_RA			0x80
626 
627 #define	IEEE80211_HE_MAC_CAP4_AMDSU_IN_AMPDU		0x1
628 #define	IEEE80211_HE_MAC_CAP4_BQR			0x2
629 #define	IEEE80211_HE_MAC_CAP4_MULTI_TID_AGG_TX_QOS_B39	0x4
630 #define	IEEE80211_HE_MAC_CAP4_AMSDU_IN_AMPDU		0x8
631 #define	IEEE80211_HE_MAC_CAP4_OPS			0x10
632 #define	IEEE80211_HE_MAC_CAP4_BSRP_BQRP_A_MPDU_AGG	0x20
633 
634 #define	IEEE80211_HE_MAC_CAP5_HE_DYNAMIC_SM_PS		0x1
635 #define	IEEE80211_HE_MAC_CAP5_HT_VHT_TRIG_FRAME_RX	0x2
636 #define	IEEE80211_HE_MAC_CAP5_MULTI_TID_AGG_TX_QOS_B40	0x4
637 #define	IEEE80211_HE_MAC_CAP5_MULTI_TID_AGG_TX_QOS_B41	0x8
638 #define	IEEE80211_HE_MAC_CAP5_UL_2x996_TONE_RU		0x10
639 #define	IEEE80211_HE_MAC_CAP5_OM_CTRL_UL_MU_DATA_DIS_RX	0x20
640 #define	IEEE80211_HE_MAC_CAP5_PUNCTURED_SOUNDING	0x40
641 #define	IEEE80211_HE_MAC_CAP5_SUBCHAN_SELECTIVE_TRANSMISSION	0x80
642 
643 #define	IEEE80211_HE_MCS_NOT_SUPPORTED			0x0
644 #define	IEEE80211_HE_MCS_SUPPORT_0_7			0x1
645 #define	IEEE80211_HE_MCS_SUPPORT_0_9			0x2
646 #define	IEEE80211_HE_MCS_SUPPORT_0_11			0x4
647 
648 #define	IEEE80211_HE_6GHZ_CAP_TX_ANTPAT_CONS		0x01
649 #define	IEEE80211_HE_6GHZ_CAP_RX_ANTPAT_CONS		0x02
650 #define	IEEE80211_HE_6GHZ_CAP_MIN_MPDU_START		0x04
651 #define	IEEE80211_HE_6GHZ_CAP_MAX_MPDU_LEN		0x08
652 #define	IEEE80211_HE_6GHZ_CAP_MAX_AMPDU_LEN_EXP		0x10
653 #define	IEEE80211_HE_6GHZ_CAP_SM_PS			0x20
654 
655 #define	IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_160MHZ_IN_5G		0x1
656 #define	IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_80MHZ_IN_5G	0x2
657 #define	IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_IN_2G		0x4
658 #define	IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_80PLUS80_MHZ_IN_5G	0x8
659 #define	IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_RU_MAPPING_IN_2G	0x10
660 #define	IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_RU_MAPPING_IN_5G	0x20
661 #define	IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_MASK			0x40
662 
663 #define	IEEE80211_HE_PHY_CAP1_DEVICE_CLASS_A		0x1
664 #define	IEEE80211_HE_PHY_CAP1_LDPC_CODING_IN_PAYLOAD	0x2
665 #define	IEEE80211_HE_PHY_CAP1_MIDAMBLE_RX_TX_MAX_NSTS	0x4
666 #define	IEEE80211_HE_PHY_CAP1_PREAMBLE_PUNC_RX_MASK	0x8
667 #define	IEEE80211_HE_PHY_CAP1_HE_LTF_AND_GI_FOR_HE_PPDUS_0_8US	0x10
668 
669 #define	IEEE80211_HE_PHY_CAP2_MIDAMBLE_RX_TX_MAX_NSTS	0x1
670 #define	IEEE80211_HE_PHY_CAP2_NDP_4x_LTF_AND_3_2US	0x2
671 #define	IEEE80211_HE_PHY_CAP2_STBC_TX_UNDER_80MHZ	0x4
672 #define	IEEE80211_HE_PHY_CAP2_STBC_RX_UNDER_80MHZ	0x8
673 #define	IEEE80211_HE_PHY_CAP2_DOPPLER_TX		0x10
674 #define	IEEE80211_HE_PHY_CAP2_UL_MU_PARTIAL_MU_MIMO	0x20
675 #define	IEEE80211_HE_PHY_CAP2_UL_MU_FULL_MU_MIMO	0x40
676 
677 #define	IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_MASK	0x1
678 #define	IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_NO_DCM	0x2
679 #define	IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_NO_DCM	0x4
680 #define	IEEE80211_HE_PHY_CAP3_DCM_MAX_RX_NSS_1		0x8
681 #define	IEEE80211_HE_PHY_CAP3_DCM_MAX_TX_NSS_1		0x10
682 #define	IEEE80211_HE_PHY_CAP3_SU_BEAMFORMER		0x20
683 #define	IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_16_QAM	0x40
684 #define	IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_16_QAM	0x80
685 #define	IEEE80211_HE_PHY_CAP3_DCM_MAX_TX_NSS_2		0x10
686 #define	IEEE80211_HE_PHY_CAP3_RX_PARTIAL_BW_SU_IN_20MHZ_MU	0x20
687 #define	IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_BPSK	0x40
688 #define	IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_BPSK	0x80
689 #define	IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_MASK	0x80
690 #define	IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_QPSK	0x80
691 #define	IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_QPSK	0x80
692 #define	IEEE80211_HE_PHY_CAP3_DCM_MAX_RX_NSS_2		0x80
693 
694 #define	IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_8	0x1
695 #define	IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_8	0x2
696 #define	IEEE80211_HE_PHY_CAP4_SU_BEAMFORMEE			0x4
697 #define	IEEE80211_HE_PHY_CAP4_MU_BEAMFORMER			0x8
698 #define	IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_4	0x10
699 #define	IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_4	0x20
700 #define	IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_MASK	0x40
701 #define	IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_MASK	0x80
702 
703 #define	IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_2	0x1
704 #define	IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_2	0x2
705 #define	IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_MASK	0x4
706 #define	IEEE80211_HE_PHY_CAP5_NG16_MU_FEEDBACK				0x8
707 #define	IEEE80211_HE_PHY_CAP5_NG16_SU_FEEDBACK				0x10
708 #define	IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_MASK	0x20
709 
710 #define	IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT	0x1
711 #define	IEEE80211_HE_PHY_CAP6_TRIG_MU_BEAMFORMER_FB	0x2
712 #define	IEEE80211_HE_PHY_CAP6_TRIG_SU_BEAMFORMER_FB	0x4
713 #define	IEEE80211_HE_PHY_CAP6_TRIG_SU_BEAMFORMING_FB	0x8
714 #define	IEEE80211_HE_PHY_CAP6_TRIG_MU_BEAMFORMING_PARTIAL_BW_FB	0x20
715 #define	IEEE80211_HE_PHY_CAP6_CODEBOOK_SIZE_42_SU	0x40
716 #define	IEEE80211_HE_PHY_CAP6_CODEBOOK_SIZE_75_MU	0x80
717 #define	IEEE80211_HE_PHY_CAP6_PARTIAL_BW_EXT_RANGE	0x80
718 #define	IEEE80211_HE_PHY_CAP6_TRIG_CQI_FB		0x80
719 #define	IEEE80211_HE_PHY_CAP6_PARTIAL_BANDWIDTH_DL_MUMIMO	0x80
720 
721 #define	IEEE80211_HE_PHY_CAP7_HE_SU_MU_PPDU_4XLTF_AND_08_US_GI	0x1
722 #define	IEEE80211_HE_PHY_CAP7_MAX_NC_1				0x2
723 #define	IEEE80211_HE_PHY_CAP7_MAX_NC_2				0x4
724 #define	IEEE80211_HE_PHY_CAP7_MAX_NC_MASK			0x6
725 #define	IEEE80211_HE_PHY_CAP7_POWER_BOOST_FACTOR_AR		0x8
726 #define	IEEE80211_HE_PHY_CAP7_POWER_BOOST_FACTOR_SUPP		0x10
727 #define	IEEE80211_HE_PHY_CAP7_STBC_RX_ABOVE_80MHZ		0x20
728 #define	IEEE80211_HE_PHY_CAP7_STBC_TX_ABOVE_80MHZ		0x40
729 #define	IEEE80211_HE_PHY_CAP7_PSR_BASED_SR			0x80
730 
731 #define	IEEE80211_HE_PHY_CAP8_20MHZ_IN_160MHZ_HE_PPDU		0x1
732 #define	IEEE80211_HE_PHY_CAP8_20MHZ_IN_40MHZ_HE_PPDU_IN_2G	0x2
733 #define	IEEE80211_HE_PHY_CAP8_80MHZ_IN_160MHZ_HE_PPDU		0x4
734 #define	IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_242			0x8
735 #define	IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_484			0x10
736 #define	IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_996			0x18
737 #define	IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_2x996			0x20
738 #define	IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_MASK			0x28
739 #define	IEEE80211_HE_PHY_CAP8_HE_ER_SU_PPDU_4XLTF_AND_08_US_GI	0x40
740 #define	IEEE80211_HE_PHY_CAP8_HE_ER_SU_1XLTF_AND_08_US_GI	0x80
741 
742 #define	IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_0US		0x1
743 #define	IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_16US		0x2
744 #define	IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_8US		0x4
745 #define	IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_MASK		0x8
746 #define	IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_RESERVED	0x10
747 #define	IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_POS		0x0
748 #define	IEEE80211_HE_PHY_CAP9_NON_TRIGGERED_CQI_FEEDBACK	0x20
749 #define	IEEE80211_HE_PHY_CAP9_RX_FULL_BW_SU_USING_MU_WITH_COMP_SIGB	0x4
750 #define	IEEE80211_HE_PHY_CAP9_RX_FULL_BW_SU_USING_MU_WITH_NON_COMP_SIGB	0x8
751 #define	IEEE80211_HE_PHY_CAP9_RX_1024_QAM_LESS_THAN_242_TONE_RU	0x10
752 #define	IEEE80211_HE_PHY_CAP9_TX_1024_QAM_LESS_THAN_242_TONE_RU	0x20
753 #define	IEEE80211_HE_PHY_CAP9_LONGER_THAN_16_SIGB_OFDM_SYM	0x40
754 
755 #define	IEEE80211_HE_PHY_CAP10_HE_MU_M1RU_MAX_LTF		0x1
756 
757 #define	IEEE80211_HE_OPERATION_BSS_COLOR_DISABLED		0x1
758 #define	IEEE80211_HE_OPERATION_BSS_COLOR_OFFSET			0x2
759 
760 #define	IEEE80211_HE_SPR_HESIGA_SR_VAL15_ALLOWED		0x01
761 #define	IEEE80211_HE_SPR_NON_SRG_OBSS_PD_SR_DISALLOWED		0x02
762 #define	IEEE80211_HE_SPR_NON_SRG_OFFSET_PRESENT			0x04
763 #define	IEEE80211_HE_SPR_SRG_INFORMATION_PRESENT		0x08
764 
765 #define	VENDOR_CMD_RAW_DATA	(void *)(uintptr_t)(-ENOENT)
766 
767 struct ieee80211_he_cap_elem {
768 	u8 mac_cap_info[6];
769 	u8 phy_cap_info[11];
770 } __packed;
771 
772 struct ieee80211_he_mcs_nss_supp {
773 	/* TODO FIXME */
774 	uint32_t	rx_mcs_80;
775 	uint32_t	tx_mcs_80;
776 	uint32_t	rx_mcs_160;
777 	uint32_t	tx_mcs_160;
778 	uint32_t	rx_mcs_80p80;
779 	uint32_t	tx_mcs_80p80;
780 };
781 
782 #define	IEEE80211_STA_HE_CAP_PPE_THRES_MAX	32
783 struct ieee80211_sta_he_cap {
784 	/* TODO FIXME */
785 	int					has_he;
786 	struct ieee80211_he_cap_elem		he_cap_elem;
787 	struct ieee80211_he_mcs_nss_supp	he_mcs_nss_supp;
788 	uint8_t					ppe_thres[IEEE80211_STA_HE_CAP_PPE_THRES_MAX];
789 };
790 
791 struct cfg80211_he_bss_color {
792 	int	color, enabled;
793 };
794 
795 struct ieee80211_he_obss_pd {
796 	bool					enable;
797 	uint8_t					min_offset;
798 	uint8_t					max_offset;
799 	uint8_t					non_srg_max_offset;
800 	uint8_t					sr_ctrl;
801 	uint8_t					bss_color_bitmap[8];
802 	uint8_t					partial_bssid_bitmap[8];
803 };
804 
805 struct ieee80211_sta_he_6ghz_capa {
806 	/* TODO FIXME */
807 	int	capa;
808 };
809 
810 struct ieee80211_sband_iftype_data {
811 	/* TODO FIXME */
812 	enum nl80211_iftype			types_mask;
813 	struct ieee80211_sta_he_cap		he_cap;
814 	struct ieee80211_sta_he_6ghz_capa	he_6ghz_capa;
815 	struct {
816 		const uint8_t			*data;
817 		size_t				len;
818 	} vendor_elems;
819 };
820 
821 struct ieee80211_supported_band {
822 	/* TODO FIXME */
823 	struct linuxkpi_ieee80211_channel	*channels;
824 	struct ieee80211_rate			*bitrates;
825 	struct ieee80211_sband_iftype_data	*iftype_data;
826 	int					n_channels;
827 	int					n_bitrates;
828 	int					n_iftype_data;
829 	enum nl80211_band			band;
830 	struct ieee80211_sta_ht_cap		ht_cap;
831 	struct ieee80211_sta_vht_cap		vht_cap;
832 };
833 
834 struct cfg80211_pkt_pattern {
835 	/* XXX TODO */
836 	uint8_t					*mask;
837 	uint8_t					*pattern;
838 	int					pattern_len;
839 	int					pkt_offset;
840 };
841 
842 struct cfg80211_wowlan_nd_match {
843 	/* XXX TODO */
844 	struct cfg80211_ssid		ssid;
845 	int				n_channels;
846 	uint32_t			channels[0];	/* freq! = ieee80211_channel_to_frequency() */
847 };
848 
849 struct cfg80211_wowlan_nd_info {
850 	/* XXX TODO */
851 	int				n_matches;
852 	struct cfg80211_wowlan_nd_match	*matches[0];
853 };
854 
855 enum wiphy_wowlan_support_flags {
856 	WIPHY_WOWLAN_DISCONNECT,
857 	WIPHY_WOWLAN_GTK_REKEY_FAILURE,
858 	WIPHY_WOWLAN_MAGIC_PKT,
859 	WIPHY_WOWLAN_SUPPORTS_GTK_REKEY,
860 	WIPHY_WOWLAN_NET_DETECT,
861 };
862 
863 struct wiphy_wowlan_support {
864 	/* XXX TODO */
865 	enum wiphy_wowlan_support_flags		flags;
866 	int	max_nd_match_sets, max_pkt_offset, n_patterns, pattern_max_len, pattern_min_len;
867 };
868 
869 struct cfg80211_wowlan_wakeup {
870 	/* XXX TODO */
871 	uint16_t				pattern_idx;
872 	bool					disconnect;
873 	bool					eap_identity_req;
874 	bool					four_way_handshake;
875 	bool					gtk_rekey_failure;
876 	bool					magic_pkt;
877 	bool					rfkill_release;
878 	bool					tcp_connlost;
879 	bool					tcp_nomoretokens;
880 	bool					tcp_match;
881 	bool					packet_80211;
882 	struct cfg80211_wowlan_nd_info		*net_detect;
883 	uint8_t					*packet;
884 	uint16_t				packet_len;
885 	uint16_t				packet_present_len;
886 };
887 
888 struct cfg80211_wowlan {
889 	/* XXX TODO */
890 	int	disconnect, gtk_rekey_failure, magic_pkt;
891 	int	eap_identity_req, four_way_handshake, rfkill_release, tcp, any;
892 	int					n_patterns;
893 	struct cfg80211_sched_scan_request	*nd_config;
894 	struct cfg80211_pkt_pattern		*patterns;
895 };
896 
897 struct cfg80211_gtk_rekey_data {
898 	/* XXX TODO */
899 	const uint8_t				*kck, *kek, *replay_ctr;
900 	uint32_t				akm;
901 	uint8_t					kck_len, kek_len;
902 };
903 
904 struct cfg80211_tid_cfg {
905 	/* XXX TODO */
906 	int	mask, noack, retry_long, rtscts, tids;
907 	enum nl80211_tx_rate_setting		txrate_type;
908 	struct cfg80211_bitrate_mask		txrate_mask;
909 };
910 
911 struct cfg80211_tid_config {
912 	/* XXX TODO */
913 	int	n_tid_conf;
914 	struct cfg80211_tid_cfg			tid_conf[0];
915 };
916 
917 struct ieee80211_iface_limit {
918 	/* TODO FIXME */
919 	int		max, types;
920 };
921 
922 struct ieee80211_iface_combination {
923 	/* TODO FIXME */
924 	const struct ieee80211_iface_limit	*limits;
925 	int					n_limits;
926 	int		max_interfaces, num_different_channels;
927 	int		beacon_int_infra_match, beacon_int_min_gcd;
928 	int		radar_detect_widths;
929 };
930 
931 struct iface_combination_params {
932 	int num_different_channels;
933 	int iftype_num[NUM_NL80211_IFTYPES];
934 };
935 
936 struct regulatory_request {
937 		/* XXX TODO */
938 	uint8_t					alpha2[2];
939 	enum environment_cap			country_ie_env;
940 	int	initiator, dfs_region;
941 	int	user_reg_hint_type;
942 };
943 
944 enum wiphy_vendor_cmd_need_flags {
945 	WIPHY_VENDOR_CMD_NEED_NETDEV		= 0x01,
946 	WIPHY_VENDOR_CMD_NEED_RUNNING		= 0x02,
947 	WIPHY_VENDOR_CMD_NEED_WDEV		= 0x04,
948 };
949 
950 struct wiphy_vendor_command {
951 	struct {
952 		uint32_t	vendor_id;
953 		uint32_t	subcmd;
954 	};
955 	uint32_t		flags;
956 	void			*policy;
957 	int (*doit)(struct wiphy *, struct wireless_dev *, const void *, int);
958 };
959 
960 struct wiphy_iftype_ext_capab {
961 	/* TODO FIXME */
962 	enum nl80211_iftype			iftype;
963 	const uint8_t				*extended_capabilities;
964 	const uint8_t				*extended_capabilities_mask;
965 	uint8_t					extended_capabilities_len;
966 
967 };
968 
969 struct tid_config_support {
970 	/* TODO FIXME */
971 	uint64_t				vif;	/* enum nl80211_tid_cfg_attr */
972 	uint64_t		 		peer;	/* enum nl80211_tid_cfg_attr */
973 };
974 
975 enum cfg80211_regulatory {
976 	REGULATORY_CUSTOM_REG			= BIT(0),
977 	REGULATORY_STRICT_REG			= BIT(1),
978 	REGULATORY_DISABLE_BEACON_HINTS		= BIT(2),
979 	REGULATORY_ENABLE_RELAX_NO_IR		= BIT(3),
980 	REGULATORY_WIPHY_SELF_MANAGED		= BIT(4),
981 	REGULATORY_COUNTRY_IE_IGNORE		= BIT(5),
982 	REGULATORY_COUNTRY_IE_FOLLOW_POWER	= BIT(6),
983 };
984 
985 enum wiphy_flags {
986 	WIPHY_FLAG_AP_UAPSD			= BIT(0),
987 	WIPHY_FLAG_HAS_CHANNEL_SWITCH		= BIT(1),
988 	WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL	= BIT(2),
989 	WIPHY_FLAG_HAVE_AP_SME			= BIT(3),
990 	WIPHY_FLAG_IBSS_RSN			= BIT(4),
991 	WIPHY_FLAG_NETNS_OK			= BIT(5),
992 	WIPHY_FLAG_OFFCHAN_TX			= BIT(6),
993 	WIPHY_FLAG_PS_ON_BY_DEFAULT		= BIT(7),
994 	WIPHY_FLAG_SPLIT_SCAN_6GHZ		= BIT(8),
995 	WIPHY_FLAG_SUPPORTS_EXT_KEK_KCK		= BIT(9),
996 	WIPHY_FLAG_SUPPORTS_FW_ROAM		= BIT(10),
997 	WIPHY_FLAG_SUPPORTS_TDLS		= BIT(11),
998 	WIPHY_FLAG_TDLS_EXTERNAL_SETUP		= BIT(12),
999 	WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD	= BIT(13),
1000 	WIPHY_FLAG_4ADDR_AP			= BIT(14),
1001 	WIPHY_FLAG_4ADDR_STATION		= BIT(15),
1002 };
1003 
1004 struct wiphy {
1005 
1006 	struct device				*dev;
1007 	struct mac_address			*addresses;
1008 	int					n_addresses;
1009 	uint32_t				flags;
1010 	struct ieee80211_supported_band		*bands[NUM_NL80211_BANDS];
1011 	uint8_t					perm_addr[ETH_ALEN];
1012 	uint16_t				max_scan_ie_len;
1013 
1014 	/* XXX TODO */
1015 	const struct cfg80211_pmsr_capabilities	*pmsr_capa;
1016 	const struct cfg80211_sar_capa		*sar_capa;
1017 	const struct wiphy_iftype_ext_capab	*iftype_ext_capab;
1018 	const struct linuxkpi_ieee80211_regdomain *regd;
1019 	char					fw_version[ETHTOOL_FWVERS_LEN];
1020 	const struct ieee80211_iface_combination *iface_combinations;
1021 	const uint32_t				*cipher_suites;
1022 	int					n_iface_combinations;
1023 	int					n_cipher_suites;
1024 	void(*reg_notifier)(struct wiphy *, struct regulatory_request *);
1025 	enum cfg80211_regulatory		regulatory_flags;
1026 	int					n_vendor_commands;
1027 	const struct wiphy_vendor_command	*vendor_commands;
1028 	const struct ieee80211_txrx_stypes	*mgmt_stypes;
1029 	uint32_t				rts_threshold;
1030 	uint32_t				frag_threshold;
1031 	struct tid_config_support		tid_config_support;
1032 	uint8_t					available_antennas_rx;
1033 	uint8_t					available_antennas_tx;
1034 
1035 	int	features, hw_version;
1036 	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;
1037 	int	num_iftype_ext_capab;
1038 	int	max_ap_assoc_sta, probe_resp_offload, software_iftypes;
1039 	int     bss_select_support, max_num_pmkids, retry_long, retry_short, signal_type;
1040 	int	max_data_retry_count;
1041 	int     tx_queue_len, rfkill;
1042 	int	mbssid_max_interfaces;
1043 
1044 	unsigned long				ext_features[BITS_TO_LONGS(NUM_NL80211_EXT_FEATURES)];
1045 	struct dentry				*debugfsdir;
1046 	struct cfg80211_wowlan_support		*wowlan;
1047 	/* Lower layer (driver/mac80211) specific data. */
1048 	/* Must stay last. */
1049 	uint8_t					priv[0] __aligned(CACHE_LINE_SIZE);
1050 };
1051 
1052 struct wireless_dev {
1053 		/* XXX TODO, like ic? */
1054 	int		iftype;
1055 	int     address;
1056 	struct net_device			*netdev;
1057 	struct wiphy				*wiphy;
1058 };
1059 
1060 struct cfg80211_ops {
1061 	/* XXX TODO */
1062 	struct wireless_dev *(*add_virtual_intf)(struct wiphy *, const char *, unsigned char, enum nl80211_iftype, struct vif_params *);
1063 	int (*del_virtual_intf)(struct wiphy *,  struct wireless_dev *);
1064 	s32 (*change_virtual_intf)(struct wiphy *,  struct net_device *, enum nl80211_iftype, struct vif_params *);
1065 	s32 (*scan)(struct wiphy *,  struct cfg80211_scan_request *);
1066 	s32 (*set_wiphy_params)(struct wiphy *,  u32);
1067 	s32 (*join_ibss)(struct wiphy *,  struct net_device *, struct cfg80211_ibss_params *);
1068 	s32 (*leave_ibss)(struct wiphy *,  struct net_device *);
1069 	s32 (*get_station)(struct wiphy *, struct net_device *, const u8 *, struct station_info *);
1070 	int (*dump_station)(struct wiphy *,  struct net_device *, int,  u8 *,  struct station_info *);
1071 	s32 (*set_tx_power)(struct wiphy *,  struct wireless_dev *, enum nl80211_tx_power_setting,  s32);
1072 	s32 (*get_tx_power)(struct wiphy *,  struct wireless_dev *, s32 *);
1073 	s32 (*add_key)(struct wiphy *,  struct net_device *, u8,  bool,  const u8 *, struct key_params *);
1074 	s32 (*del_key)(struct wiphy *,  struct net_device *, u8,  bool,  const u8 *);
1075 	s32 (*get_key)(struct wiphy *,  struct net_device *,  u8, bool,  const u8 *,  void *, void(*)(void *, struct key_params *));
1076 	s32 (*set_default_key)(struct wiphy *,  struct net_device *, u8,  bool,  bool);
1077 	s32 (*set_default_mgmt_key)(struct wiphy *, struct net_device *,  u8);
1078 	s32 (*set_power_mgmt)(struct wiphy *,  struct net_device *, bool,  s32);
1079 	s32 (*connect)(struct wiphy *,  struct net_device *, struct cfg80211_connect_params *);
1080 	s32 (*disconnect)(struct wiphy *,  struct net_device *, u16);
1081 	s32 (*suspend)(struct wiphy *, struct cfg80211_wowlan *);
1082 	s32 (*resume)(struct wiphy *);
1083 	s32 (*set_pmksa)(struct wiphy *, struct net_device *, struct cfg80211_pmksa *);
1084 	s32 (*del_pmksa)(struct wiphy *, struct net_device *, struct cfg80211_pmksa *);
1085 	s32 (*flush_pmksa)(struct wiphy *,  struct net_device *);
1086 	s32 (*start_ap)(struct wiphy *,  struct net_device *, struct cfg80211_ap_settings *);
1087 	int (*stop_ap)(struct wiphy *,  struct net_device *);
1088 	s32 (*change_beacon)(struct wiphy *,  struct net_device *, struct cfg80211_beacon_data *);
1089 	int (*del_station)(struct wiphy *,  struct net_device *, struct station_del_parameters *);
1090 	int (*change_station)(struct wiphy *,  struct net_device *, const u8 *,  struct station_parameters *);
1091 	int (*sched_scan_start)(struct wiphy *, struct net_device *, struct cfg80211_sched_scan_request *);
1092 	int (*sched_scan_stop)(struct wiphy *, struct net_device *,  u64);
1093 	void (*update_mgmt_frame_registrations)(struct wiphy *, struct wireless_dev *, struct mgmt_frame_regs *);
1094 	int (*mgmt_tx)(struct wiphy *,  struct wireless_dev *, struct cfg80211_mgmt_tx_params *,  u64 *);
1095 	int (*cancel_remain_on_channel)(struct wiphy *, struct wireless_dev *, u64);
1096 	int (*get_channel)(struct wiphy *, struct wireless_dev *, struct cfg80211_chan_def *);
1097 	int (*crit_proto_start)(struct wiphy *, struct wireless_dev *, enum nl80211_crit_proto_id, u16);
1098 	void (*crit_proto_stop)(struct wiphy *, struct wireless_dev *);
1099 	int (*tdls_oper)(struct wiphy *, struct net_device *,  const u8 *, enum nl80211_tdls_operation);
1100 	int (*update_connect_params)(struct wiphy *, struct net_device *, struct cfg80211_connect_params *, u32);
1101 	int (*set_pmk)(struct wiphy *,  struct net_device *, const struct cfg80211_pmk_conf *);
1102 	int (*del_pmk)(struct wiphy *,  struct net_device *, const u8 *);
1103 	int (*remain_on_channel)(struct wiphy *,  struct wireless_dev *, struct linuxkpi_ieee80211_channel *, unsigned int,  u64 *);
1104 	int (*start_p2p_device)(struct wiphy *,  struct wireless_dev *);
1105 	void (*stop_p2p_device)(struct wiphy *,  struct wireless_dev *);
1106 };
1107 
1108 
1109 /* -------------------------------------------------------------------------- */
1110 
1111 /* linux_80211.c */
1112 
1113 struct wiphy *linuxkpi_wiphy_new(const struct cfg80211_ops *, size_t);
1114 void linuxkpi_wiphy_free(struct wiphy *wiphy);
1115 
1116 int linuxkpi_regulatory_set_wiphy_regd_sync(struct wiphy *wiphy,
1117     struct linuxkpi_ieee80211_regdomain *regd);
1118 uint32_t linuxkpi_ieee80211_channel_to_frequency(uint32_t, enum nl80211_band);
1119 uint32_t linuxkpi_ieee80211_frequency_to_channel(uint32_t, uint32_t);
1120 struct linuxkpi_ieee80211_channel *
1121     linuxkpi_ieee80211_get_channel(struct wiphy *, uint32_t);
1122 struct cfg80211_bss *linuxkpi_cfg80211_get_bss(struct wiphy *,
1123     struct linuxkpi_ieee80211_channel *, const uint8_t *,
1124     const uint8_t *, size_t, enum ieee80211_bss_type, enum ieee80211_privacy);
1125 void linuxkpi_cfg80211_put_bss(struct wiphy *, struct cfg80211_bss *);
1126 void linuxkpi_cfg80211_bss_flush(struct wiphy *);
1127 
1128 /* -------------------------------------------------------------------------- */
1129 
1130 static __inline struct wiphy *
1131 wiphy_new(const struct cfg80211_ops *ops, size_t priv_len)
1132 {
1133 
1134 	return (linuxkpi_wiphy_new(ops, priv_len));
1135 }
1136 
1137 static __inline void
1138 wiphy_free(struct wiphy *wiphy)
1139 {
1140 
1141 	linuxkpi_wiphy_free(wiphy);
1142 }
1143 
1144 static __inline void *
1145 wiphy_priv(struct wiphy *wiphy)
1146 {
1147 
1148 	return (wiphy->priv);
1149 }
1150 
1151 static __inline void
1152 set_wiphy_dev(struct wiphy *wiphy, struct device *dev)
1153 {
1154 
1155 	wiphy->dev = dev;
1156 }
1157 
1158 static __inline struct device *
1159 wiphy_dev(struct wiphy *wiphy)
1160 {
1161 
1162 	return (wiphy->dev);
1163 }
1164 
1165 #define	wiphy_err(_wiphy, _fmt, ...)					\
1166     dev_err((_wiphy)->dev, _fmt, __VA_ARGS__)
1167 
1168 static __inline const struct linuxkpi_ieee80211_regdomain *
1169 wiphy_dereference(struct wiphy *wiphy,
1170     const struct linuxkpi_ieee80211_regdomain *regd)
1171 {
1172 	TODO();
1173         return (NULL);
1174 }
1175 
1176 static __inline void
1177 wiphy_lock(struct wiphy *wiphy)
1178 {
1179 	TODO();
1180 }
1181 
1182 static __inline void
1183 wiphy_unlock(struct wiphy *wiphy)
1184 {
1185 	TODO();
1186 }
1187 
1188 static __inline void
1189 wiphy_rfkill_set_hw_state_reason(struct wiphy *wiphy, bool blocked,
1190     enum rfkill_hard_block_reasons reason)
1191 {
1192 	TODO();
1193 }
1194 
1195 /* -------------------------------------------------------------------------- */
1196 
1197 static inline struct cfg80211_bss *
1198 cfg80211_get_bss(struct wiphy *wiphy, struct linuxkpi_ieee80211_channel *chan,
1199     const uint8_t *bssid, const uint8_t *ssid, size_t ssid_len,
1200     enum ieee80211_bss_type bss_type, enum ieee80211_privacy privacy)
1201 {
1202 
1203 	return (linuxkpi_cfg80211_get_bss(wiphy, chan, bssid, ssid, ssid_len,
1204 	    bss_type, privacy));
1205 }
1206 
1207 static inline void
1208 cfg80211_put_bss(struct wiphy *wiphy, struct cfg80211_bss *bss)
1209 {
1210 
1211 	linuxkpi_cfg80211_put_bss(wiphy, bss);
1212 }
1213 
1214 static inline void
1215 cfg80211_bss_flush(struct wiphy *wiphy)
1216 {
1217 
1218 	linuxkpi_cfg80211_bss_flush(wiphy);
1219 }
1220 
1221 /* -------------------------------------------------------------------------- */
1222 
1223 static __inline bool
1224 rfkill_blocked(int rfkill)		/* argument type? */
1225 {
1226 	TODO();
1227 	return (false);
1228 }
1229 
1230 static __inline bool
1231 rfkill_soft_blocked(int rfkill)
1232 {
1233 	TODO();
1234 	return (false);
1235 }
1236 
1237 static __inline int
1238 reg_query_regdb_wmm(uint8_t *alpha2, uint32_t center_freq,
1239     struct ieee80211_reg_rule *rule)
1240 {
1241 
1242 	/* ETSI has special rules. FreeBSD regdb needs to learn about them. */
1243 	TODO();
1244 
1245 	return (-ENXIO);
1246 }
1247 
1248 static __inline const u8 *
1249 cfg80211_find_ie_match(uint32_t f, const u8 *ies, size_t ies_len,
1250     const u8 *match, int x, int y)
1251 {
1252 	TODO();
1253 	return (NULL);
1254 }
1255 
1256 static __inline const u8 *
1257 cfg80211_find_ie(uint8_t eid, const uint8_t *ie, uint32_t ielen)
1258 {
1259 	TODO();
1260 	return (NULL);
1261 }
1262 
1263 static __inline void
1264 cfg80211_pmsr_complete(struct wireless_dev *wdev,
1265     struct cfg80211_pmsr_request *req, gfp_t gfp)
1266 {
1267 	TODO();
1268 }
1269 
1270 static __inline void
1271 cfg80211_pmsr_report(struct wireless_dev *wdev,
1272     struct cfg80211_pmsr_request *req,
1273     struct cfg80211_pmsr_result *result, gfp_t gfp)
1274 {
1275 	TODO();
1276 }
1277 
1278 static __inline void
1279 cfg80211_chandef_create(struct cfg80211_chan_def *chandef,
1280     struct linuxkpi_ieee80211_channel *chan, enum nl80211_chan_flags chan_flag)
1281 {
1282 
1283 	KASSERT(chandef != NULL, ("%s: chandef is NULL\n", __func__));
1284 	KASSERT(chan != NULL, ("%s: chan is NULL\n", __func__));
1285 
1286 	memset(chandef, 0, sizeof(*chandef));
1287 	chandef->chan = chan;
1288 	chandef->center_freq2 = 0;	/* Set here and only overwrite if needed. */
1289 
1290 	switch (chan_flag) {
1291 	case NL80211_CHAN_NO_HT:
1292 		chandef->width = NL80211_CHAN_WIDTH_20_NOHT;
1293 		chandef->center_freq1 = chan->center_freq;
1294 		break;
1295 	default:
1296 		IMPROVE("Also depends on our manual settings");
1297 		if (chan->flags & IEEE80211_CHAN_NO_HT40)
1298 			chandef->width = NL80211_CHAN_WIDTH_20;
1299 		else if (chan->flags & IEEE80211_CHAN_NO_80MHZ)
1300 			chandef->width = NL80211_CHAN_WIDTH_40;
1301 		else if (chan->flags & IEEE80211_CHAN_NO_160MHZ)
1302 			chandef->width = NL80211_CHAN_WIDTH_80;
1303 		else {
1304 			chandef->width = NL80211_CHAN_WIDTH_160;
1305 			IMPROVE("80P80 and 320 ...");
1306 		}
1307 		chandef->center_freq1 = chan->center_freq;
1308 		break;
1309 	};
1310 }
1311 
1312 static __inline void
1313 cfg80211_bss_iter(struct wiphy *wiphy, struct cfg80211_chan_def *chandef,
1314     void (*iterfunc)(struct wiphy *, struct cfg80211_bss *, void *), void *data)
1315 {
1316 	TODO();
1317 }
1318 
1319 struct element {
1320 	uint8_t					id;
1321 	uint8_t					datalen;
1322 	uint8_t					data[0];
1323 } __packed;
1324 
1325 static inline const struct element *
1326 lkpi_cfg80211_find_elem_pattern(enum ieee80211_eid eid,
1327     const uint8_t *data, size_t len, uint8_t *pattern, size_t plen)
1328 {
1329 	const struct element *elem;
1330 	const uint8_t *p;
1331 	size_t ielen;
1332 
1333 	p = data;
1334 	elem = (const struct element *)p;
1335 	ielen = len;
1336 	while (elem != NULL && ielen > 1) {
1337 		if ((2 + elem->datalen) > ielen)
1338 			/* Element overruns our memory. */
1339 			return (NULL);
1340 		if (elem->id == eid) {
1341 			if (pattern == NULL)
1342 				return (elem);
1343 			if (elem->datalen >= plen &&
1344 			    memcmp(elem->data, pattern, plen) == 0)
1345 				return (elem);
1346 		}
1347 		ielen -= 2 + elem->datalen;
1348 		p += 2 + elem->datalen;
1349 		elem = (const struct element *)p;
1350 	}
1351 
1352 	return (NULL);
1353 }
1354 
1355 static inline const struct element *
1356 cfg80211_find_elem(enum ieee80211_eid eid, const uint8_t *data, size_t len)
1357 {
1358 
1359 	return (lkpi_cfg80211_find_elem_pattern(eid, data, len, NULL, 0));
1360 }
1361 
1362 static inline const struct element *
1363 ieee80211_bss_get_elem(struct cfg80211_bss *bss, uint32_t eid)
1364 {
1365 
1366 	if (bss->ies == NULL)
1367 		return (NULL);
1368 	return (cfg80211_find_elem(eid, bss->ies->data, bss->ies->len));
1369 }
1370 
1371 static inline const uint8_t *
1372 ieee80211_bss_get_ie(struct cfg80211_bss *bss, uint32_t eid)
1373 {
1374 
1375 	return ((const uint8_t *)ieee80211_bss_get_elem(bss, eid));
1376 }
1377 
1378 static inline uint8_t *
1379 cfg80211_find_vendor_ie(unsigned int oui, int oui_type,
1380     uint8_t *data, size_t len)
1381 {
1382 	const struct element *elem;
1383 	uint8_t pattern[4] = { oui << 16, oui << 8, oui, oui_type };
1384 	uint8_t plen = 4;		/* >= 3? oui_type always part of this? */
1385 	IMPROVE("plen currently always incl. oui_type");
1386 
1387 	elem = lkpi_cfg80211_find_elem_pattern(IEEE80211_ELEMID_VENDOR,
1388 	    data, len, pattern, plen);
1389 	if (elem == NULL)
1390 		return (NULL);
1391 	return (__DECONST(uint8_t *, elem));
1392 }
1393 
1394 static __inline uint32_t
1395 cfg80211_calculate_bitrate(struct rate_info *rate)
1396 {
1397 	TODO();
1398 	return (-1);
1399 }
1400 
1401 static __inline uint32_t
1402 ieee80211_channel_to_frequency(uint32_t channel, enum nl80211_band band)
1403 {
1404 
1405 	return (linuxkpi_ieee80211_channel_to_frequency(channel, band));
1406 }
1407 
1408 static __inline uint32_t
1409 ieee80211_frequency_to_channel(uint32_t freq)
1410 {
1411 
1412 	return (linuxkpi_ieee80211_frequency_to_channel(freq, 0));
1413 }
1414 
1415 static __inline int
1416 regulatory_set_wiphy_regd_sync(struct wiphy *wiphy,
1417     struct linuxkpi_ieee80211_regdomain *regd)
1418 {
1419 	IMPROVE();
1420 	return (linuxkpi_regulatory_set_wiphy_regd_sync(wiphy, regd));
1421 }
1422 
1423 static __inline int
1424 regulatory_set_wiphy_regd_sync_rtnl(struct wiphy *wiphy,
1425     struct linuxkpi_ieee80211_regdomain *regd)
1426 {
1427 
1428 	IMPROVE();
1429 	return (linuxkpi_regulatory_set_wiphy_regd_sync(wiphy, regd));
1430 }
1431 
1432 static __inline int
1433 regulatory_set_wiphy_regd(struct wiphy *wiphy,
1434     struct linuxkpi_ieee80211_regdomain *regd)
1435 {
1436 
1437 	IMPROVE();
1438 	if (regd == NULL)
1439 		return (EINVAL);
1440 
1441 	/* XXX-BZ wild guessing here based on brcmfmac. */
1442 	if (wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED)
1443 		wiphy->regd = regd;
1444 	else
1445 		return (EPERM);
1446 
1447 	/* XXX FIXME, do we have to do anything with reg_notifier? */
1448 	return (0);
1449 }
1450 
1451 static __inline int
1452 regulatory_hint(struct wiphy *wiphy, const uint8_t *alpha2)
1453 {
1454 	TODO();
1455 	return (-ENXIO);
1456 }
1457 
1458 static __inline const char *
1459 reg_initiator_name(enum nl80211_reg_initiator initiator)
1460 {
1461 	TODO();
1462 	return (NULL);
1463 }
1464 
1465 static __inline struct linuxkpi_ieee80211_regdomain *
1466 rtnl_dereference(const struct linuxkpi_ieee80211_regdomain *regd)
1467 {
1468 	TODO();
1469 	return (NULL);
1470 }
1471 
1472 static __inline struct ieee80211_reg_rule *
1473 freq_reg_info(struct wiphy *wiphy, uint32_t center_freq)
1474 {
1475 	TODO();
1476 	return (NULL);
1477 }
1478 
1479 static __inline void
1480 wiphy_apply_custom_regulatory(struct wiphy *wiphy,
1481     const struct linuxkpi_ieee80211_regdomain *regd)
1482 {
1483 	TODO();
1484 }
1485 
1486 static __inline char *
1487 wiphy_name(struct wiphy *wiphy)
1488 {
1489 	if (wiphy != NULL && wiphy->dev != NULL)
1490 		return dev_name(wiphy->dev);
1491 	else {
1492 		IMPROVE("wlanNA");
1493 		return ("wlanNA");
1494 	}
1495 }
1496 
1497 static __inline void
1498 wiphy_read_of_freq_limits(struct wiphy *wiphy)
1499 {
1500 #ifdef FDT
1501 	TODO();
1502 #endif
1503 }
1504 
1505 static __inline void
1506 wiphy_ext_feature_set(struct wiphy *wiphy, enum nl80211_ext_feature ef)
1507 {
1508 
1509 	set_bit(ef, wiphy->ext_features);
1510 }
1511 
1512 static __inline void *
1513 wiphy_net(struct wiphy *wiphy)
1514 {
1515 	TODO();
1516 	return (NULL);	/* XXX passed to dev_net_set() */
1517 }
1518 
1519 static __inline int
1520 wiphy_register(struct wiphy *wiphy)
1521 {
1522 	TODO();
1523 	return (0);
1524 }
1525 
1526 static __inline void
1527 wiphy_unregister(struct wiphy *wiphy)
1528 {
1529 	TODO();
1530 }
1531 
1532 static __inline void
1533 wiphy_warn(struct wiphy *wiphy, const char *fmt, ...)
1534 {
1535 	TODO();
1536 }
1537 
1538 static __inline int
1539 cfg80211_check_combinations(struct wiphy *wiphy,
1540     struct iface_combination_params *params)
1541 {
1542 	TODO();
1543 	return (-ENOENT);
1544 }
1545 
1546 static __inline uint8_t
1547 cfg80211_classify8021d(struct sk_buff *skb, void *p)
1548 {
1549 	TODO();
1550 	return (0);
1551 }
1552 
1553 static __inline void
1554 cfg80211_connect_done(struct net_device *ndev,
1555     struct cfg80211_connect_resp_params *conn_params, gfp_t gfp)
1556 {
1557 	TODO();
1558 }
1559 
1560 static __inline void
1561 cfg80211_crit_proto_stopped(struct wireless_dev *wdev, gfp_t gfp)
1562 {
1563 	TODO();
1564 }
1565 
1566 static __inline void
1567 cfg80211_disconnected(struct net_device *ndev, uint16_t reason,
1568     void *p, int x, bool locally_generated, gfp_t gfp)
1569 {
1570 	TODO();
1571 }
1572 
1573 static __inline int
1574 cfg80211_get_p2p_attr(const u8 *ie, u32 ie_len,
1575     enum ieee80211_p2p_attr_ids attr, u8 *p, size_t p_len)
1576 {
1577 	TODO();
1578 	return (-1);
1579 }
1580 
1581 static __inline void
1582 cfg80211_ibss_joined(struct net_device *ndev, const uint8_t *addr,
1583     struct linuxkpi_ieee80211_channel *chan, gfp_t gfp)
1584 {
1585 	TODO();
1586 }
1587 
1588 static __inline struct cfg80211_bss *
1589 cfg80211_inform_bss(struct wiphy *wiphy,
1590     struct linuxkpi_ieee80211_channel *channel,
1591     enum cfg80211_bss_frame_type bss_ftype, const uint8_t *bss, int _x,
1592     uint16_t cap, uint16_t intvl, const uint8_t *ie, size_t ie_len,
1593     int signal, gfp_t gfp)
1594 {
1595 	TODO();
1596 	return (NULL);
1597 }
1598 
1599 static __inline struct cfg80211_bss *
1600 cfg80211_inform_bss_data(struct wiphy *wiphy,
1601     struct cfg80211_inform_bss *bss_data,
1602     enum cfg80211_bss_frame_type bss_ftype, const uint8_t *bss, int _x,
1603     uint16_t cap, uint16_t intvl, const uint8_t *ie, size_t ie_len, gfp_t gfp)
1604 {
1605 	TODO();
1606 	return (NULL);
1607 }
1608 
1609 static __inline void
1610 cfg80211_mgmt_tx_status(struct wireless_dev *wdev, uint64_t cookie,
1611     const u8 *buf, size_t len, bool ack, gfp_t gfp)
1612 {
1613 	TODO();
1614 }
1615 
1616 static __inline void
1617 cfg80211_michael_mic_failure(struct net_device *ndev, const uint8_t *addr,
1618     enum nl80211_key_type key_type, int _x, void *p, gfp_t gfp)
1619 {
1620 	TODO();
1621 }
1622 
1623 static __inline void
1624 cfg80211_new_sta(struct net_device *ndev, const uint8_t *addr,
1625     struct station_info *sinfo, gfp_t gfp)
1626 {
1627 	TODO();
1628 }
1629 
1630 static __inline void
1631 cfg80211_del_sta(struct net_device *ndev, const uint8_t *addr, gfp_t gfp)
1632 {
1633 	TODO();
1634 }
1635 
1636 static __inline void
1637 cfg80211_port_authorized(struct net_device *ndev, const uint8_t *bssid,
1638     gfp_t gfp)
1639 {
1640 	TODO();
1641 }
1642 
1643 static __inline void
1644 cfg80211_ready_on_channel(struct wireless_dev *wdev, uint64_t cookie,
1645     struct linuxkpi_ieee80211_channel *channel, unsigned int duration,
1646     gfp_t gfp)
1647 {
1648 	TODO();
1649 }
1650 
1651 static __inline void
1652 cfg80211_remain_on_channel_expired(struct wireless_dev *wdev,
1653     uint64_t cookie, struct linuxkpi_ieee80211_channel *channel, gfp_t gfp)
1654 {
1655 	TODO();
1656 }
1657 
1658 static __inline void
1659 cfg80211_report_wowlan_wakeup(void)
1660 {
1661 	TODO();
1662 }
1663 
1664 static __inline void
1665 cfg80211_roamed(struct net_device *ndev, struct cfg80211_roam_info *roam_info,
1666     gfp_t gfp)
1667 {
1668 	TODO();
1669 }
1670 
1671 static __inline void
1672 cfg80211_rx_mgmt(struct wireless_dev *wdev, int freq, int _x,
1673     uint8_t *p, size_t p_len, int _x2)
1674 {
1675 	TODO();
1676 }
1677 
1678 static __inline void
1679 cfg80211_scan_done(struct cfg80211_scan_request *scan_request,
1680     struct cfg80211_scan_info *info)
1681 {
1682 	TODO();
1683 }
1684 
1685 static __inline void
1686 cfg80211_sched_scan_results(struct wiphy *wiphy, uint64_t reqid)
1687 {
1688 	TODO();
1689 }
1690 
1691 static __inline void
1692 cfg80211_sched_scan_stopped(struct wiphy *wiphy, int _x)
1693 {
1694 	TODO();
1695 }
1696 
1697 static __inline void
1698 cfg80211_unregister_wdev(struct wireless_dev *wdev)
1699 {
1700 	TODO();
1701 }
1702 
1703 static __inline struct sk_buff *
1704 cfg80211_vendor_cmd_alloc_reply_skb(struct wiphy *wiphy, unsigned int len)
1705 {
1706 	TODO();
1707 	return (NULL);
1708 }
1709 
1710 static __inline int
1711 cfg80211_vendor_cmd_reply(struct sk_buff *skb)
1712 {
1713 	TODO();
1714 	return (-ENXIO);
1715 }
1716 
1717 static __inline struct linuxkpi_ieee80211_channel *
1718 ieee80211_get_channel(struct wiphy *wiphy, uint32_t freq)
1719 {
1720 
1721 	return (linuxkpi_ieee80211_get_channel(wiphy, freq));
1722 }
1723 
1724 static inline size_t
1725 ieee80211_get_hdrlen_from_skb(struct sk_buff *skb)
1726 {
1727 	const struct ieee80211_hdr *hdr;
1728 	size_t len;
1729 
1730 	if (skb->len < 10)	/* sizeof(ieee80211_frame_[ack,cts]) */
1731 		return (0);
1732 
1733 	hdr = (const struct ieee80211_hdr *)skb->data;
1734 	len = ieee80211_hdrlen(hdr->frame_control);
1735 
1736 	/* If larger than what is in the skb return. */
1737 	if (len > skb->len)
1738 		return (0);
1739 
1740 	return (len);
1741 }
1742 
1743 static __inline bool
1744 cfg80211_channel_is_psc(struct linuxkpi_ieee80211_channel *channel)
1745 {
1746 
1747 	/* Only 6Ghz. */
1748 	if (channel->band != NL80211_BAND_6GHZ)
1749 		return (false);
1750 
1751 	TODO();
1752 	return (false);
1753 }
1754 
1755 static inline int
1756 cfg80211_get_ies_channel_number(const uint8_t *ie, size_t len,
1757     enum nl80211_band band, enum cfg80211_bss_frame_type ftype)
1758 {
1759 	const struct element *elem;
1760 
1761 	switch (band) {
1762 	case NL80211_BAND_6GHZ:
1763 		TODO();
1764 		break;
1765 	case NL80211_BAND_5GHZ:
1766 	case NL80211_BAND_2GHZ:
1767 		/* DSPARAMS has the channel number. */
1768 		elem = cfg80211_find_elem(IEEE80211_ELEMID_DSPARMS, ie, len);
1769 		if (elem != NULL && elem->datalen == 1)
1770 			return (elem->data[0]);
1771 		/* HTINFO has the primary center channel. */
1772 		elem = cfg80211_find_elem(IEEE80211_ELEMID_HTINFO, ie, len);
1773 		if (elem != NULL &&
1774 		    elem->datalen >= (sizeof(struct ieee80211_ie_htinfo) - 2)) {
1775 			const struct ieee80211_ie_htinfo *htinfo;
1776 			htinfo = (const struct ieee80211_ie_htinfo *)elem;
1777 			return (htinfo->hi_ctrlchannel);
1778 		}
1779 		/* What else? */
1780 		break;
1781 	default:
1782 		IMPROVE("Unsupported");
1783 		break;
1784 	}
1785 	return (-1);
1786 }
1787 
1788 /* Used for scanning at least. */
1789 static __inline void
1790 get_random_mask_addr(uint8_t *dst, const uint8_t *addr, const uint8_t *mask)
1791 {
1792 	int i;
1793 
1794 	/* Get a completely random address and then overlay what we want. */
1795 	get_random_bytes(dst, ETH_ALEN);
1796 	for (i = 0; i < ETH_ALEN; i++)
1797 		dst[i] = (dst[i] & ~(mask[i])) | (addr[i] & mask[i]);
1798 }
1799 
1800 static __inline void
1801 cfg80211_shutdown_all_interfaces(struct wiphy *wiphy)
1802 {
1803 	TODO();
1804 }
1805 
1806 static __inline bool
1807 cfg80211_reg_can_beacon(struct wiphy *wiphy, struct cfg80211_chan_def *chandef,
1808     enum nl80211_iftype iftype)
1809 {
1810 	TODO();
1811 	return (false);
1812 }
1813 
1814 static __inline void
1815 cfg80211_background_radar_event(struct wiphy *wiphy,
1816     struct cfg80211_chan_def *chandef, gfp_t gfp)
1817 {
1818 	TODO();
1819 }
1820 
1821 static __inline const u8 *
1822 cfg80211_find_ext_ie(uint8_t eid, uint8_t *p, size_t len)
1823 {
1824 	TODO();
1825 	return (NULL);
1826 }
1827 
1828 static __inline bool
1829 cfg80211_chandef_valid(const struct cfg80211_chan_def *chandef)
1830 {
1831 	TODO();
1832 	return (false);
1833 }
1834 
1835 #define	wiphy_info(wiphy, fmt, ...)					\
1836 	printf("%s:%d XXX TODO " fmt, __func__, __LINE__, __VA_ARGS__)
1837 
1838 #ifndef LINUXKPI_NET80211
1839 #define	ieee80211_channel		linuxkpi_ieee80211_channel
1840 #define	ieee80211_regdomain		linuxkpi_ieee80211_regdomain
1841 #endif
1842 
1843 #include <net/mac80211.h>
1844 
1845 #endif	/* _LINUXKPI_NET_CFG80211_H */
1846