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_OMI_CONTROL		0x02
618 #define	IEEE80211_HE_MAC_CAP3_OFDMA_RA			0x04
619 #define	IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_EXT_1	0x08
620 #define	IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_EXT_2	0x10
621 #define	IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_EXT_3	0x18
622 #define	IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_MASK	0x18
623 #define	IEEE80211_HE_MAC_CAP3_FLEX_TWT_SCHED		0x40
624 #define	IEEE80211_HE_MAC_CAP3_RX_CTRL_FRAME_TO_MULTIBSS	0x80
625 
626 #define	IEEE80211_HE_MAC_CAP4_AMDSU_IN_AMPDU		0x1
627 #define	IEEE80211_HE_MAC_CAP4_BQR			0x2
628 #define	IEEE80211_HE_MAC_CAP4_MULTI_TID_AGG_TX_QOS_B39	0x4
629 #define	IEEE80211_HE_MAC_CAP4_AMSDU_IN_AMPDU		0x8
630 #define	IEEE80211_HE_MAC_CAP4_OPS			0x10
631 #define	IEEE80211_HE_MAC_CAP4_BSRP_BQRP_A_MPDU_AGG	0x20
632 
633 #define	IEEE80211_HE_MAC_CAP5_HE_DYNAMIC_SM_PS		0x1
634 #define	IEEE80211_HE_MAC_CAP5_HT_VHT_TRIG_FRAME_RX	0x2
635 #define	IEEE80211_HE_MAC_CAP5_MULTI_TID_AGG_TX_QOS_B40	0x4
636 #define	IEEE80211_HE_MAC_CAP5_MULTI_TID_AGG_TX_QOS_B41	0x8
637 #define	IEEE80211_HE_MAC_CAP5_UL_2x996_TONE_RU		0x10
638 #define	IEEE80211_HE_MAC_CAP5_OM_CTRL_UL_MU_DATA_DIS_RX	0x20
639 #define	IEEE80211_HE_MAC_CAP5_PUNCTURED_SOUNDING	0x40
640 #define	IEEE80211_HE_MAC_CAP5_SUBCHAN_SELECTIVE_TRANSMISSION	0x80
641 
642 #define	IEEE80211_HE_MCS_NOT_SUPPORTED			0x0
643 #define	IEEE80211_HE_MCS_SUPPORT_0_7			0x1
644 #define	IEEE80211_HE_MCS_SUPPORT_0_9			0x2
645 #define	IEEE80211_HE_MCS_SUPPORT_0_11			0x4
646 
647 #define	IEEE80211_HE_6GHZ_CAP_TX_ANTPAT_CONS		0x01
648 #define	IEEE80211_HE_6GHZ_CAP_RX_ANTPAT_CONS		0x02
649 #define	IEEE80211_HE_6GHZ_CAP_MIN_MPDU_START		0x04
650 #define	IEEE80211_HE_6GHZ_CAP_MAX_MPDU_LEN		0x08
651 #define	IEEE80211_HE_6GHZ_CAP_MAX_AMPDU_LEN_EXP		0x10
652 #define	IEEE80211_HE_6GHZ_CAP_SM_PS			0x20
653 
654 #define	IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_160MHZ_IN_5G		0x1
655 #define	IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_80MHZ_IN_5G	0x2
656 #define	IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_IN_2G		0x4
657 #define	IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_80PLUS80_MHZ_IN_5G	0x8
658 #define	IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_RU_MAPPING_IN_2G	0x10
659 #define	IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_RU_MAPPING_IN_5G	0x20
660 #define	IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_MASK			0x40
661 
662 #define	IEEE80211_HE_PHY_CAP1_DEVICE_CLASS_A		0x1
663 #define	IEEE80211_HE_PHY_CAP1_LDPC_CODING_IN_PAYLOAD	0x2
664 #define	IEEE80211_HE_PHY_CAP1_MIDAMBLE_RX_TX_MAX_NSTS	0x4
665 #define	IEEE80211_HE_PHY_CAP1_PREAMBLE_PUNC_RX_MASK	0x8
666 #define	IEEE80211_HE_PHY_CAP1_HE_LTF_AND_GI_FOR_HE_PPDUS_0_8US	0x10
667 
668 #define	IEEE80211_HE_PHY_CAP2_MIDAMBLE_RX_TX_MAX_NSTS	0x1
669 #define	IEEE80211_HE_PHY_CAP2_NDP_4x_LTF_AND_3_2US	0x2
670 #define	IEEE80211_HE_PHY_CAP2_STBC_TX_UNDER_80MHZ	0x4
671 #define	IEEE80211_HE_PHY_CAP2_STBC_RX_UNDER_80MHZ	0x8
672 #define	IEEE80211_HE_PHY_CAP2_DOPPLER_TX		0x10
673 #define	IEEE80211_HE_PHY_CAP2_UL_MU_PARTIAL_MU_MIMO	0x20
674 #define	IEEE80211_HE_PHY_CAP2_UL_MU_FULL_MU_MIMO	0x40
675 
676 #define	IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_MASK	0x1
677 #define	IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_NO_DCM	0x2
678 #define	IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_NO_DCM	0x4
679 #define	IEEE80211_HE_PHY_CAP3_DCM_MAX_RX_NSS_1		0x8
680 #define	IEEE80211_HE_PHY_CAP3_DCM_MAX_TX_NSS_1		0x10
681 #define	IEEE80211_HE_PHY_CAP3_SU_BEAMFORMER		0x20
682 #define	IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_16_QAM	0x40
683 #define	IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_16_QAM	0x80
684 #define	IEEE80211_HE_PHY_CAP3_DCM_MAX_TX_NSS_2		0x10
685 #define	IEEE80211_HE_PHY_CAP3_RX_PARTIAL_BW_SU_IN_20MHZ_MU	0x20
686 #define	IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_BPSK	0x40
687 #define	IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_BPSK	0x80
688 #define	IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_MASK	0x80
689 #define	IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_QPSK	0x80
690 #define	IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_QPSK	0x80
691 #define	IEEE80211_HE_PHY_CAP3_DCM_MAX_RX_NSS_2		0x80
692 
693 #define	IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_8	0x1
694 #define	IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_8	0x2
695 #define	IEEE80211_HE_PHY_CAP4_SU_BEAMFORMEE			0x4
696 #define	IEEE80211_HE_PHY_CAP4_MU_BEAMFORMER			0x8
697 #define	IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_4	0x10
698 #define	IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_4	0x20
699 #define	IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_MASK	0x40
700 #define	IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_MASK	0x80
701 
702 #define	IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_2	0x1
703 #define	IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_2	0x2
704 #define	IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_MASK	0x4
705 #define	IEEE80211_HE_PHY_CAP5_NG16_MU_FEEDBACK				0x8
706 #define	IEEE80211_HE_PHY_CAP5_NG16_SU_FEEDBACK				0x10
707 #define	IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_MASK	0x20
708 
709 #define	IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT	0x1
710 #define	IEEE80211_HE_PHY_CAP6_TRIG_MU_BEAMFORMER_FB	0x2
711 #define	IEEE80211_HE_PHY_CAP6_TRIG_SU_BEAMFORMER_FB	0x4
712 #define	IEEE80211_HE_PHY_CAP6_TRIG_SU_BEAMFORMING_FB	0x8
713 #define	IEEE80211_HE_PHY_CAP6_TRIG_MU_BEAMFORMING_PARTIAL_BW_FB	0x20
714 #define	IEEE80211_HE_PHY_CAP6_CODEBOOK_SIZE_42_SU	0x40
715 #define	IEEE80211_HE_PHY_CAP6_CODEBOOK_SIZE_75_MU	0x80
716 #define	IEEE80211_HE_PHY_CAP6_PARTIAL_BW_EXT_RANGE	0x80
717 #define	IEEE80211_HE_PHY_CAP6_TRIG_CQI_FB		0x80
718 #define	IEEE80211_HE_PHY_CAP6_PARTIAL_BANDWIDTH_DL_MUMIMO	0x80
719 
720 #define	IEEE80211_HE_PHY_CAP7_HE_SU_MU_PPDU_4XLTF_AND_08_US_GI	0x1
721 #define	IEEE80211_HE_PHY_CAP7_MAX_NC_1				0x2
722 #define	IEEE80211_HE_PHY_CAP7_MAX_NC_2				0x4
723 #define	IEEE80211_HE_PHY_CAP7_MAX_NC_MASK			0x6
724 #define	IEEE80211_HE_PHY_CAP7_POWER_BOOST_FACTOR_AR		0x8
725 #define	IEEE80211_HE_PHY_CAP7_POWER_BOOST_FACTOR_SUPP		0x10
726 #define	IEEE80211_HE_PHY_CAP7_STBC_RX_ABOVE_80MHZ		0x20
727 #define	IEEE80211_HE_PHY_CAP7_STBC_TX_ABOVE_80MHZ		0x40
728 #define	IEEE80211_HE_PHY_CAP7_PSR_BASED_SR			0x80
729 
730 #define	IEEE80211_HE_PHY_CAP8_20MHZ_IN_160MHZ_HE_PPDU		0x1
731 #define	IEEE80211_HE_PHY_CAP8_20MHZ_IN_40MHZ_HE_PPDU_IN_2G	0x2
732 #define	IEEE80211_HE_PHY_CAP8_80MHZ_IN_160MHZ_HE_PPDU		0x4
733 #define	IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_242			0x8
734 #define	IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_484			0x10
735 #define	IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_996			0x18
736 #define	IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_2x996			0x20
737 #define	IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_MASK			0x28
738 #define	IEEE80211_HE_PHY_CAP8_HE_ER_SU_PPDU_4XLTF_AND_08_US_GI	0x40
739 #define	IEEE80211_HE_PHY_CAP8_HE_ER_SU_1XLTF_AND_08_US_GI	0x80
740 
741 #define	IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_0US		0x1
742 #define	IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_16US		0x2
743 #define	IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_8US		0x4
744 #define	IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_MASK		0x8
745 #define	IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_RESERVED	0x10
746 #define	IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_POS		0x0
747 #define	IEEE80211_HE_PHY_CAP9_NON_TRIGGERED_CQI_FEEDBACK	0x20
748 #define	IEEE80211_HE_PHY_CAP9_RX_FULL_BW_SU_USING_MU_WITH_COMP_SIGB	0x4
749 #define	IEEE80211_HE_PHY_CAP9_RX_FULL_BW_SU_USING_MU_WITH_NON_COMP_SIGB	0x8
750 #define	IEEE80211_HE_PHY_CAP9_RX_1024_QAM_LESS_THAN_242_TONE_RU	0x10
751 #define	IEEE80211_HE_PHY_CAP9_TX_1024_QAM_LESS_THAN_242_TONE_RU	0x20
752 #define	IEEE80211_HE_PHY_CAP9_LONGER_THAN_16_SIGB_OFDM_SYM	0x40
753 
754 #define	IEEE80211_HE_PHY_CAP10_HE_MU_M1RU_MAX_LTF		0x1
755 
756 #define	IEEE80211_HE_OPERATION_BSS_COLOR_DISABLED		0x1
757 #define	IEEE80211_HE_OPERATION_BSS_COLOR_OFFSET			0x2
758 
759 #define	IEEE80211_HE_SPR_HESIGA_SR_VAL15_ALLOWED		0x01
760 #define	IEEE80211_HE_SPR_NON_SRG_OBSS_PD_SR_DISALLOWED		0x02
761 #define	IEEE80211_HE_SPR_NON_SRG_OFFSET_PRESENT			0x04
762 #define	IEEE80211_HE_SPR_SRG_INFORMATION_PRESENT		0x08
763 
764 #define	VENDOR_CMD_RAW_DATA	(void *)(uintptr_t)(-ENOENT)
765 
766 struct ieee80211_he_cap_elem {
767 	u8 mac_cap_info[6];
768 	u8 phy_cap_info[11];
769 } __packed;
770 
771 struct ieee80211_he_mcs_nss_supp {
772 	/* TODO FIXME */
773 	uint32_t	rx_mcs_80;
774 	uint32_t	tx_mcs_80;
775 	uint32_t	rx_mcs_160;
776 	uint32_t	tx_mcs_160;
777 	uint32_t	rx_mcs_80p80;
778 	uint32_t	tx_mcs_80p80;
779 };
780 
781 #define	IEEE80211_STA_HE_CAP_PPE_THRES_MAX	32
782 struct ieee80211_sta_he_cap {
783 	/* TODO FIXME */
784 	int					has_he;
785 	struct ieee80211_he_cap_elem		he_cap_elem;
786 	struct ieee80211_he_mcs_nss_supp	he_mcs_nss_supp;
787 	uint8_t					ppe_thres[IEEE80211_STA_HE_CAP_PPE_THRES_MAX];
788 };
789 
790 struct cfg80211_he_bss_color {
791 	int	color, enabled;
792 };
793 
794 struct ieee80211_he_obss_pd {
795 	bool					enable;
796 	uint8_t					min_offset;
797 	uint8_t					max_offset;
798 	uint8_t					non_srg_max_offset;
799 	uint8_t					sr_ctrl;
800 	uint8_t					bss_color_bitmap[8];
801 	uint8_t					partial_bssid_bitmap[8];
802 };
803 
804 struct ieee80211_sta_he_6ghz_capa {
805 	/* TODO FIXME */
806 	int	capa;
807 };
808 
809 struct ieee80211_sband_iftype_data {
810 	/* TODO FIXME */
811 	enum nl80211_iftype			types_mask;
812 	struct ieee80211_sta_he_cap		he_cap;
813 	struct ieee80211_sta_he_6ghz_capa	he_6ghz_capa;
814 	struct {
815 		const uint8_t			*data;
816 		size_t				len;
817 	} vendor_elems;
818 };
819 
820 struct ieee80211_supported_band {
821 	/* TODO FIXME */
822 	struct linuxkpi_ieee80211_channel	*channels;
823 	struct ieee80211_rate			*bitrates;
824 	struct ieee80211_sband_iftype_data	*iftype_data;
825 	int					n_channels;
826 	int					n_bitrates;
827 	int					n_iftype_data;
828 	enum nl80211_band			band;
829 	struct ieee80211_sta_ht_cap		ht_cap;
830 	struct ieee80211_sta_vht_cap		vht_cap;
831 };
832 
833 struct cfg80211_pkt_pattern {
834 	/* XXX TODO */
835 	uint8_t					*mask;
836 	uint8_t					*pattern;
837 	int					pattern_len;
838 	int					pkt_offset;
839 };
840 
841 struct cfg80211_wowlan_nd_match {
842 	/* XXX TODO */
843 	struct cfg80211_ssid		ssid;
844 	int				n_channels;
845 	uint32_t			channels[0];	/* freq! = ieee80211_channel_to_frequency() */
846 };
847 
848 struct cfg80211_wowlan_nd_info {
849 	/* XXX TODO */
850 	int				n_matches;
851 	struct cfg80211_wowlan_nd_match	*matches[0];
852 };
853 
854 enum wiphy_wowlan_support_flags {
855 	WIPHY_WOWLAN_DISCONNECT,
856 	WIPHY_WOWLAN_GTK_REKEY_FAILURE,
857 	WIPHY_WOWLAN_MAGIC_PKT,
858 	WIPHY_WOWLAN_SUPPORTS_GTK_REKEY,
859 	WIPHY_WOWLAN_NET_DETECT,
860 };
861 
862 struct wiphy_wowlan_support {
863 	/* XXX TODO */
864 	enum wiphy_wowlan_support_flags		flags;
865 	int	max_nd_match_sets, max_pkt_offset, n_patterns, pattern_max_len, pattern_min_len;
866 };
867 
868 struct cfg80211_wowlan_wakeup {
869 	/* XXX TODO */
870 	uint16_t				pattern_idx;
871 	bool					disconnect;
872 	bool					eap_identity_req;
873 	bool					four_way_handshake;
874 	bool					gtk_rekey_failure;
875 	bool					magic_pkt;
876 	bool					rfkill_release;
877 	bool					tcp_connlost;
878 	bool					tcp_nomoretokens;
879 	bool					tcp_match;
880 	bool					packet_80211;
881 	struct cfg80211_wowlan_nd_info		*net_detect;
882 	uint8_t					*packet;
883 	uint16_t				packet_len;
884 	uint16_t				packet_present_len;
885 };
886 
887 struct cfg80211_wowlan {
888 	/* XXX TODO */
889 	int	disconnect, gtk_rekey_failure, magic_pkt;
890 	int	eap_identity_req, four_way_handshake, rfkill_release, tcp, any;
891 	int					n_patterns;
892 	struct cfg80211_sched_scan_request	*nd_config;
893 	struct cfg80211_pkt_pattern		*patterns;
894 };
895 
896 struct cfg80211_gtk_rekey_data {
897 	/* XXX TODO */
898 	const uint8_t				*kck, *kek, *replay_ctr;
899 	uint32_t				akm;
900 	uint8_t					kck_len, kek_len;
901 };
902 
903 struct cfg80211_tid_cfg {
904 	/* XXX TODO */
905 	int	mask, noack, retry_long, rtscts, tids;
906 	enum nl80211_tx_rate_setting		txrate_type;
907 	struct cfg80211_bitrate_mask		txrate_mask;
908 };
909 
910 struct cfg80211_tid_config {
911 	/* XXX TODO */
912 	int	n_tid_conf;
913 	struct cfg80211_tid_cfg			tid_conf[0];
914 };
915 
916 struct ieee80211_iface_limit {
917 	/* TODO FIXME */
918 	int		max, types;
919 };
920 
921 struct ieee80211_iface_combination {
922 	/* TODO FIXME */
923 	const struct ieee80211_iface_limit	*limits;
924 	int					n_limits;
925 	int		max_interfaces, num_different_channels;
926 	int		beacon_int_infra_match, beacon_int_min_gcd;
927 	int		radar_detect_widths;
928 };
929 
930 struct iface_combination_params {
931 	int num_different_channels;
932 	int iftype_num[NUM_NL80211_IFTYPES];
933 };
934 
935 struct regulatory_request {
936 		/* XXX TODO */
937 	uint8_t					alpha2[2];
938 	enum environment_cap			country_ie_env;
939 	int	initiator, dfs_region;
940 	int	user_reg_hint_type;
941 };
942 
943 enum wiphy_vendor_cmd_need_flags {
944 	WIPHY_VENDOR_CMD_NEED_NETDEV		= 0x01,
945 	WIPHY_VENDOR_CMD_NEED_RUNNING		= 0x02,
946 	WIPHY_VENDOR_CMD_NEED_WDEV		= 0x04,
947 };
948 
949 struct wiphy_vendor_command {
950 	struct {
951 		uint32_t	vendor_id;
952 		uint32_t	subcmd;
953 	};
954 	uint32_t		flags;
955 	void			*policy;
956 	int (*doit)(struct wiphy *, struct wireless_dev *, const void *, int);
957 };
958 
959 struct wiphy_iftype_ext_capab {
960 	/* TODO FIXME */
961 	enum nl80211_iftype			iftype;
962 	const uint8_t				*extended_capabilities;
963 	const uint8_t				*extended_capabilities_mask;
964 	uint8_t					extended_capabilities_len;
965 
966 };
967 
968 struct tid_config_support {
969 	/* TODO FIXME */
970 	uint64_t				vif;	/* enum nl80211_tid_cfg_attr */
971 	uint64_t		 		peer;	/* enum nl80211_tid_cfg_attr */
972 };
973 
974 enum cfg80211_regulatory {
975 	REGULATORY_CUSTOM_REG			= BIT(0),
976 	REGULATORY_STRICT_REG			= BIT(1),
977 	REGULATORY_DISABLE_BEACON_HINTS		= BIT(2),
978 	REGULATORY_ENABLE_RELAX_NO_IR		= BIT(3),
979 	REGULATORY_WIPHY_SELF_MANAGED		= BIT(4),
980 	REGULATORY_COUNTRY_IE_IGNORE		= BIT(5),
981 	REGULATORY_COUNTRY_IE_FOLLOW_POWER	= BIT(6),
982 };
983 
984 enum wiphy_flags {
985 	WIPHY_FLAG_AP_UAPSD			= BIT(0),
986 	WIPHY_FLAG_HAS_CHANNEL_SWITCH		= BIT(1),
987 	WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL	= BIT(2),
988 	WIPHY_FLAG_HAVE_AP_SME			= BIT(3),
989 	WIPHY_FLAG_IBSS_RSN			= BIT(4),
990 	WIPHY_FLAG_NETNS_OK			= BIT(5),
991 	WIPHY_FLAG_OFFCHAN_TX			= BIT(6),
992 	WIPHY_FLAG_PS_ON_BY_DEFAULT		= BIT(7),
993 	WIPHY_FLAG_SPLIT_SCAN_6GHZ		= BIT(8),
994 	WIPHY_FLAG_SUPPORTS_EXT_KEK_KCK		= BIT(9),
995 	WIPHY_FLAG_SUPPORTS_FW_ROAM		= BIT(10),
996 	WIPHY_FLAG_SUPPORTS_TDLS		= BIT(11),
997 	WIPHY_FLAG_TDLS_EXTERNAL_SETUP		= BIT(12),
998 	WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD	= BIT(13),
999 	WIPHY_FLAG_4ADDR_AP			= BIT(14),
1000 	WIPHY_FLAG_4ADDR_STATION		= BIT(15),
1001 };
1002 
1003 struct wiphy {
1004 
1005 	struct device				*dev;
1006 	struct mac_address			*addresses;
1007 	int					n_addresses;
1008 	uint32_t				flags;
1009 	struct ieee80211_supported_band		*bands[NUM_NL80211_BANDS];
1010 	uint8_t					perm_addr[ETH_ALEN];
1011 	uint16_t				max_scan_ie_len;
1012 
1013 	/* XXX TODO */
1014 	const struct cfg80211_pmsr_capabilities	*pmsr_capa;
1015 	const struct cfg80211_sar_capa		*sar_capa;
1016 	const struct wiphy_iftype_ext_capab	*iftype_ext_capab;
1017 	const struct linuxkpi_ieee80211_regdomain *regd;
1018 	char					fw_version[ETHTOOL_FWVERS_LEN];
1019 	const struct ieee80211_iface_combination *iface_combinations;
1020 	const uint32_t				*cipher_suites;
1021 	int					n_iface_combinations;
1022 	int					n_cipher_suites;
1023 	void(*reg_notifier)(struct wiphy *, struct regulatory_request *);
1024 	enum cfg80211_regulatory		regulatory_flags;
1025 	int					n_vendor_commands;
1026 	const struct wiphy_vendor_command	*vendor_commands;
1027 	const struct ieee80211_txrx_stypes	*mgmt_stypes;
1028 	uint32_t				rts_threshold;
1029 	uint32_t				frag_threshold;
1030 	struct tid_config_support		tid_config_support;
1031 	uint8_t					available_antennas_rx;
1032 	uint8_t					available_antennas_tx;
1033 
1034 	int	features, hw_version;
1035 	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;
1036 	int	num_iftype_ext_capab;
1037 	int	max_ap_assoc_sta, probe_resp_offload, software_iftypes;
1038 	int     bss_select_support, max_num_pmkids, retry_long, retry_short, signal_type;
1039 	int	max_data_retry_count;
1040 	int     tx_queue_len, rfkill;
1041 	int	mbssid_max_interfaces;
1042 
1043 	unsigned long				ext_features[BITS_TO_LONGS(NUM_NL80211_EXT_FEATURES)];
1044 	struct dentry				*debugfsdir;
1045 	struct cfg80211_wowlan_support		*wowlan;
1046 	/* Lower layer (driver/mac80211) specific data. */
1047 	/* Must stay last. */
1048 	uint8_t					priv[0] __aligned(CACHE_LINE_SIZE);
1049 };
1050 
1051 struct wireless_dev {
1052 		/* XXX TODO, like ic? */
1053 	int		iftype;
1054 	int     address;
1055 	struct net_device			*netdev;
1056 	struct wiphy				*wiphy;
1057 };
1058 
1059 struct cfg80211_ops {
1060 	/* XXX TODO */
1061 	struct wireless_dev *(*add_virtual_intf)(struct wiphy *, const char *, unsigned char, enum nl80211_iftype, struct vif_params *);
1062 	int (*del_virtual_intf)(struct wiphy *,  struct wireless_dev *);
1063 	s32 (*change_virtual_intf)(struct wiphy *,  struct net_device *, enum nl80211_iftype, struct vif_params *);
1064 	s32 (*scan)(struct wiphy *,  struct cfg80211_scan_request *);
1065 	s32 (*set_wiphy_params)(struct wiphy *,  u32);
1066 	s32 (*join_ibss)(struct wiphy *,  struct net_device *, struct cfg80211_ibss_params *);
1067 	s32 (*leave_ibss)(struct wiphy *,  struct net_device *);
1068 	s32 (*get_station)(struct wiphy *, struct net_device *, const u8 *, struct station_info *);
1069 	int (*dump_station)(struct wiphy *,  struct net_device *, int,  u8 *,  struct station_info *);
1070 	s32 (*set_tx_power)(struct wiphy *,  struct wireless_dev *, enum nl80211_tx_power_setting,  s32);
1071 	s32 (*get_tx_power)(struct wiphy *,  struct wireless_dev *, s32 *);
1072 	s32 (*add_key)(struct wiphy *,  struct net_device *, u8,  bool,  const u8 *, struct key_params *);
1073 	s32 (*del_key)(struct wiphy *,  struct net_device *, u8,  bool,  const u8 *);
1074 	s32 (*get_key)(struct wiphy *,  struct net_device *,  u8, bool,  const u8 *,  void *, void(*)(void *, struct key_params *));
1075 	s32 (*set_default_key)(struct wiphy *,  struct net_device *, u8,  bool,  bool);
1076 	s32 (*set_default_mgmt_key)(struct wiphy *, struct net_device *,  u8);
1077 	s32 (*set_power_mgmt)(struct wiphy *,  struct net_device *, bool,  s32);
1078 	s32 (*connect)(struct wiphy *,  struct net_device *, struct cfg80211_connect_params *);
1079 	s32 (*disconnect)(struct wiphy *,  struct net_device *, u16);
1080 	s32 (*suspend)(struct wiphy *, struct cfg80211_wowlan *);
1081 	s32 (*resume)(struct wiphy *);
1082 	s32 (*set_pmksa)(struct wiphy *, struct net_device *, struct cfg80211_pmksa *);
1083 	s32 (*del_pmksa)(struct wiphy *, struct net_device *, struct cfg80211_pmksa *);
1084 	s32 (*flush_pmksa)(struct wiphy *,  struct net_device *);
1085 	s32 (*start_ap)(struct wiphy *,  struct net_device *, struct cfg80211_ap_settings *);
1086 	int (*stop_ap)(struct wiphy *,  struct net_device *);
1087 	s32 (*change_beacon)(struct wiphy *,  struct net_device *, struct cfg80211_beacon_data *);
1088 	int (*del_station)(struct wiphy *,  struct net_device *, struct station_del_parameters *);
1089 	int (*change_station)(struct wiphy *,  struct net_device *, const u8 *,  struct station_parameters *);
1090 	int (*sched_scan_start)(struct wiphy *, struct net_device *, struct cfg80211_sched_scan_request *);
1091 	int (*sched_scan_stop)(struct wiphy *, struct net_device *,  u64);
1092 	void (*update_mgmt_frame_registrations)(struct wiphy *, struct wireless_dev *, struct mgmt_frame_regs *);
1093 	int (*mgmt_tx)(struct wiphy *,  struct wireless_dev *, struct cfg80211_mgmt_tx_params *,  u64 *);
1094 	int (*cancel_remain_on_channel)(struct wiphy *, struct wireless_dev *, u64);
1095 	int (*get_channel)(struct wiphy *, struct wireless_dev *, struct cfg80211_chan_def *);
1096 	int (*crit_proto_start)(struct wiphy *, struct wireless_dev *, enum nl80211_crit_proto_id, u16);
1097 	void (*crit_proto_stop)(struct wiphy *, struct wireless_dev *);
1098 	int (*tdls_oper)(struct wiphy *, struct net_device *,  const u8 *, enum nl80211_tdls_operation);
1099 	int (*update_connect_params)(struct wiphy *, struct net_device *, struct cfg80211_connect_params *, u32);
1100 	int (*set_pmk)(struct wiphy *,  struct net_device *, const struct cfg80211_pmk_conf *);
1101 	int (*del_pmk)(struct wiphy *,  struct net_device *, const u8 *);
1102 	int (*remain_on_channel)(struct wiphy *,  struct wireless_dev *, struct linuxkpi_ieee80211_channel *, unsigned int,  u64 *);
1103 	int (*start_p2p_device)(struct wiphy *,  struct wireless_dev *);
1104 	void (*stop_p2p_device)(struct wiphy *,  struct wireless_dev *);
1105 };
1106 
1107 
1108 /* -------------------------------------------------------------------------- */
1109 
1110 /* linux_80211.c */
1111 
1112 struct wiphy *linuxkpi_wiphy_new(const struct cfg80211_ops *, size_t);
1113 void linuxkpi_wiphy_free(struct wiphy *wiphy);
1114 
1115 int linuxkpi_regulatory_set_wiphy_regd_sync(struct wiphy *wiphy,
1116     struct linuxkpi_ieee80211_regdomain *regd);
1117 uint32_t linuxkpi_ieee80211_channel_to_frequency(uint32_t, enum nl80211_band);
1118 uint32_t linuxkpi_ieee80211_frequency_to_channel(uint32_t, uint32_t);
1119 struct linuxkpi_ieee80211_channel *
1120     linuxkpi_ieee80211_get_channel(struct wiphy *, uint32_t);
1121 struct cfg80211_bss *linuxkpi_cfg80211_get_bss(struct wiphy *,
1122     struct linuxkpi_ieee80211_channel *, const uint8_t *,
1123     const uint8_t *, size_t, enum ieee80211_bss_type, enum ieee80211_privacy);
1124 void linuxkpi_cfg80211_put_bss(struct wiphy *, struct cfg80211_bss *);
1125 void linuxkpi_cfg80211_bss_flush(struct wiphy *);
1126 
1127 /* -------------------------------------------------------------------------- */
1128 
1129 static __inline struct wiphy *
1130 wiphy_new(const struct cfg80211_ops *ops, size_t priv_len)
1131 {
1132 
1133 	return (linuxkpi_wiphy_new(ops, priv_len));
1134 }
1135 
1136 static __inline void
1137 wiphy_free(struct wiphy *wiphy)
1138 {
1139 
1140 	linuxkpi_wiphy_free(wiphy);
1141 }
1142 
1143 static __inline void *
1144 wiphy_priv(struct wiphy *wiphy)
1145 {
1146 
1147 	return (wiphy->priv);
1148 }
1149 
1150 static __inline void
1151 set_wiphy_dev(struct wiphy *wiphy, struct device *dev)
1152 {
1153 
1154 	wiphy->dev = dev;
1155 }
1156 
1157 static __inline struct device *
1158 wiphy_dev(struct wiphy *wiphy)
1159 {
1160 
1161 	return (wiphy->dev);
1162 }
1163 
1164 #define	wiphy_err(_wiphy, _fmt, ...)					\
1165     dev_err((_wiphy)->dev, _fmt, __VA_ARGS__)
1166 
1167 static __inline const struct linuxkpi_ieee80211_regdomain *
1168 wiphy_dereference(struct wiphy *wiphy,
1169     const struct linuxkpi_ieee80211_regdomain *regd)
1170 {
1171 	TODO();
1172         return (NULL);
1173 }
1174 
1175 static __inline void
1176 wiphy_lock(struct wiphy *wiphy)
1177 {
1178 	TODO();
1179 }
1180 
1181 static __inline void
1182 wiphy_unlock(struct wiphy *wiphy)
1183 {
1184 	TODO();
1185 }
1186 
1187 static __inline void
1188 wiphy_rfkill_set_hw_state_reason(struct wiphy *wiphy, bool blocked,
1189     enum rfkill_hard_block_reasons reason)
1190 {
1191 	TODO();
1192 }
1193 
1194 /* -------------------------------------------------------------------------- */
1195 
1196 static inline struct cfg80211_bss *
1197 cfg80211_get_bss(struct wiphy *wiphy, struct linuxkpi_ieee80211_channel *chan,
1198     const uint8_t *bssid, const uint8_t *ssid, size_t ssid_len,
1199     enum ieee80211_bss_type bss_type, enum ieee80211_privacy privacy)
1200 {
1201 
1202 	return (linuxkpi_cfg80211_get_bss(wiphy, chan, bssid, ssid, ssid_len,
1203 	    bss_type, privacy));
1204 }
1205 
1206 static inline void
1207 cfg80211_put_bss(struct wiphy *wiphy, struct cfg80211_bss *bss)
1208 {
1209 
1210 	linuxkpi_cfg80211_put_bss(wiphy, bss);
1211 }
1212 
1213 static inline void
1214 cfg80211_bss_flush(struct wiphy *wiphy)
1215 {
1216 
1217 	linuxkpi_cfg80211_bss_flush(wiphy);
1218 }
1219 
1220 /* -------------------------------------------------------------------------- */
1221 
1222 static __inline bool
1223 rfkill_blocked(int rfkill)		/* argument type? */
1224 {
1225 	TODO();
1226 	return (false);
1227 }
1228 
1229 static __inline bool
1230 rfkill_soft_blocked(int rfkill)
1231 {
1232 	TODO();
1233 	return (false);
1234 }
1235 
1236 static __inline int
1237 reg_query_regdb_wmm(uint8_t *alpha2, uint32_t center_freq,
1238     struct ieee80211_reg_rule *rule)
1239 {
1240 
1241 	/* ETSI has special rules. FreeBSD regdb needs to learn about them. */
1242 	TODO();
1243 
1244 	return (-ENXIO);
1245 }
1246 
1247 static __inline const u8 *
1248 cfg80211_find_ie_match(uint32_t f, const u8 *ies, size_t ies_len,
1249     const u8 *match, int x, int y)
1250 {
1251 	TODO();
1252 	return (NULL);
1253 }
1254 
1255 static __inline const u8 *
1256 cfg80211_find_ie(uint8_t eid, const uint8_t *ie, uint32_t ielen)
1257 {
1258 	TODO();
1259 	return (NULL);
1260 }
1261 
1262 static __inline void
1263 cfg80211_pmsr_complete(struct wireless_dev *wdev,
1264     struct cfg80211_pmsr_request *req, gfp_t gfp)
1265 {
1266 	TODO();
1267 }
1268 
1269 static __inline void
1270 cfg80211_pmsr_report(struct wireless_dev *wdev,
1271     struct cfg80211_pmsr_request *req,
1272     struct cfg80211_pmsr_result *result, gfp_t gfp)
1273 {
1274 	TODO();
1275 }
1276 
1277 static __inline void
1278 cfg80211_chandef_create(struct cfg80211_chan_def *chandef,
1279     struct linuxkpi_ieee80211_channel *chan, enum nl80211_chan_flags chan_flag)
1280 {
1281 
1282 	KASSERT(chandef != NULL, ("%s: chandef is NULL\n", __func__));
1283 	KASSERT(chan != NULL, ("%s: chan is NULL\n", __func__));
1284 
1285 	memset(chandef, 0, sizeof(*chandef));
1286 	chandef->chan = chan;
1287 	chandef->center_freq2 = 0;	/* Set here and only overwrite if needed. */
1288 
1289 	switch (chan_flag) {
1290 	case NL80211_CHAN_NO_HT:
1291 		chandef->width = NL80211_CHAN_WIDTH_20_NOHT;
1292 		chandef->center_freq1 = chan->center_freq;
1293 		break;
1294 	default:
1295 		IMPROVE("Also depends on our manual settings");
1296 		if (chan->flags & IEEE80211_CHAN_NO_HT40)
1297 			chandef->width = NL80211_CHAN_WIDTH_20;
1298 		else if (chan->flags & IEEE80211_CHAN_NO_80MHZ)
1299 			chandef->width = NL80211_CHAN_WIDTH_40;
1300 		else if (chan->flags & IEEE80211_CHAN_NO_160MHZ)
1301 			chandef->width = NL80211_CHAN_WIDTH_80;
1302 		else {
1303 			chandef->width = NL80211_CHAN_WIDTH_160;
1304 			IMPROVE("80P80 and 320 ...");
1305 		}
1306 		chandef->center_freq1 = chan->center_freq;
1307 		break;
1308 	};
1309 }
1310 
1311 static __inline void
1312 cfg80211_bss_iter(struct wiphy *wiphy, struct cfg80211_chan_def *chandef,
1313     void (*iterfunc)(struct wiphy *, struct cfg80211_bss *, void *), void *data)
1314 {
1315 	TODO();
1316 }
1317 
1318 struct element {
1319 	uint8_t					id;
1320 	uint8_t					datalen;
1321 	uint8_t					data[0];
1322 } __packed;
1323 
1324 static inline const struct element *
1325 lkpi_cfg80211_find_elem_pattern(enum ieee80211_eid eid,
1326     const uint8_t *data, size_t len, uint8_t *pattern, size_t plen)
1327 {
1328 	const struct element *elem;
1329 	const uint8_t *p;
1330 	size_t ielen;
1331 
1332 	p = data;
1333 	elem = (const struct element *)p;
1334 	ielen = len;
1335 	while (elem != NULL && ielen > 1) {
1336 		if ((2 + elem->datalen) > ielen)
1337 			/* Element overruns our memory. */
1338 			return (NULL);
1339 		if (elem->id == eid) {
1340 			if (pattern == NULL)
1341 				return (elem);
1342 			if (elem->datalen >= plen &&
1343 			    memcmp(elem->data, pattern, plen) == 0)
1344 				return (elem);
1345 		}
1346 		ielen -= 2 + elem->datalen;
1347 		p += 2 + elem->datalen;
1348 		elem = (const struct element *)p;
1349 	}
1350 
1351 	return (NULL);
1352 }
1353 
1354 static inline const struct element *
1355 cfg80211_find_elem(enum ieee80211_eid eid, const uint8_t *data, size_t len)
1356 {
1357 
1358 	return (lkpi_cfg80211_find_elem_pattern(eid, data, len, NULL, 0));
1359 }
1360 
1361 static inline const struct element *
1362 ieee80211_bss_get_elem(struct cfg80211_bss *bss, uint32_t eid)
1363 {
1364 
1365 	if (bss->ies == NULL)
1366 		return (NULL);
1367 	return (cfg80211_find_elem(eid, bss->ies->data, bss->ies->len));
1368 }
1369 
1370 static inline const uint8_t *
1371 ieee80211_bss_get_ie(struct cfg80211_bss *bss, uint32_t eid)
1372 {
1373 
1374 	return ((const uint8_t *)ieee80211_bss_get_elem(bss, eid));
1375 }
1376 
1377 static inline uint8_t *
1378 cfg80211_find_vendor_ie(unsigned int oui, int oui_type,
1379     uint8_t *data, size_t len)
1380 {
1381 	const struct element *elem;
1382 	uint8_t pattern[4] = { oui << 16, oui << 8, oui, oui_type };
1383 	uint8_t plen = 4;		/* >= 3? oui_type always part of this? */
1384 	IMPROVE("plen currently always incl. oui_type");
1385 
1386 	elem = lkpi_cfg80211_find_elem_pattern(IEEE80211_ELEMID_VENDOR,
1387 	    data, len, pattern, plen);
1388 	if (elem == NULL)
1389 		return (NULL);
1390 	return (__DECONST(uint8_t *, elem));
1391 }
1392 
1393 static __inline uint32_t
1394 cfg80211_calculate_bitrate(struct rate_info *rate)
1395 {
1396 	TODO();
1397 	return (-1);
1398 }
1399 
1400 static __inline uint32_t
1401 ieee80211_channel_to_frequency(uint32_t channel, enum nl80211_band band)
1402 {
1403 
1404 	return (linuxkpi_ieee80211_channel_to_frequency(channel, band));
1405 }
1406 
1407 static __inline uint32_t
1408 ieee80211_frequency_to_channel(uint32_t freq)
1409 {
1410 
1411 	return (linuxkpi_ieee80211_frequency_to_channel(freq, 0));
1412 }
1413 
1414 static __inline int
1415 regulatory_set_wiphy_regd_sync(struct wiphy *wiphy,
1416     struct linuxkpi_ieee80211_regdomain *regd)
1417 {
1418 	IMPROVE();
1419 	return (linuxkpi_regulatory_set_wiphy_regd_sync(wiphy, regd));
1420 }
1421 
1422 static __inline int
1423 regulatory_set_wiphy_regd_sync_rtnl(struct wiphy *wiphy,
1424     struct linuxkpi_ieee80211_regdomain *regd)
1425 {
1426 
1427 	IMPROVE();
1428 	return (linuxkpi_regulatory_set_wiphy_regd_sync(wiphy, regd));
1429 }
1430 
1431 static __inline int
1432 regulatory_set_wiphy_regd(struct wiphy *wiphy,
1433     struct linuxkpi_ieee80211_regdomain *regd)
1434 {
1435 
1436 	IMPROVE();
1437 	if (regd == NULL)
1438 		return (EINVAL);
1439 
1440 	/* XXX-BZ wild guessing here based on brcmfmac. */
1441 	if (wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED)
1442 		wiphy->regd = regd;
1443 	else
1444 		return (EPERM);
1445 
1446 	/* XXX FIXME, do we have to do anything with reg_notifier? */
1447 	return (0);
1448 }
1449 
1450 static __inline int
1451 regulatory_hint(struct wiphy *wiphy, const uint8_t *alpha2)
1452 {
1453 	TODO();
1454 	return (-ENXIO);
1455 }
1456 
1457 static __inline const char *
1458 reg_initiator_name(enum nl80211_reg_initiator initiator)
1459 {
1460 	TODO();
1461 	return (NULL);
1462 }
1463 
1464 static __inline struct linuxkpi_ieee80211_regdomain *
1465 rtnl_dereference(const struct linuxkpi_ieee80211_regdomain *regd)
1466 {
1467 	TODO();
1468 	return (NULL);
1469 }
1470 
1471 static __inline struct ieee80211_reg_rule *
1472 freq_reg_info(struct wiphy *wiphy, uint32_t center_freq)
1473 {
1474 	TODO();
1475 	return (NULL);
1476 }
1477 
1478 static __inline void
1479 wiphy_apply_custom_regulatory(struct wiphy *wiphy,
1480     const struct linuxkpi_ieee80211_regdomain *regd)
1481 {
1482 	TODO();
1483 }
1484 
1485 static __inline char *
1486 wiphy_name(struct wiphy *wiphy)
1487 {
1488 	if (wiphy != NULL && wiphy->dev != NULL)
1489 		return dev_name(wiphy->dev);
1490 	else {
1491 		IMPROVE("wlanNA");
1492 		return ("wlanNA");
1493 	}
1494 }
1495 
1496 static __inline void
1497 wiphy_read_of_freq_limits(struct wiphy *wiphy)
1498 {
1499 #ifdef FDT
1500 	TODO();
1501 #endif
1502 }
1503 
1504 static __inline void
1505 wiphy_ext_feature_set(struct wiphy *wiphy, enum nl80211_ext_feature ef)
1506 {
1507 
1508 	set_bit(ef, wiphy->ext_features);
1509 }
1510 
1511 static __inline void *
1512 wiphy_net(struct wiphy *wiphy)
1513 {
1514 	TODO();
1515 	return (NULL);	/* XXX passed to dev_net_set() */
1516 }
1517 
1518 static __inline int
1519 wiphy_register(struct wiphy *wiphy)
1520 {
1521 	TODO();
1522 	return (0);
1523 }
1524 
1525 static __inline void
1526 wiphy_unregister(struct wiphy *wiphy)
1527 {
1528 	TODO();
1529 }
1530 
1531 static __inline void
1532 wiphy_warn(struct wiphy *wiphy, const char *fmt, ...)
1533 {
1534 	TODO();
1535 }
1536 
1537 static __inline int
1538 cfg80211_check_combinations(struct wiphy *wiphy,
1539     struct iface_combination_params *params)
1540 {
1541 	TODO();
1542 	return (-ENOENT);
1543 }
1544 
1545 static __inline uint8_t
1546 cfg80211_classify8021d(struct sk_buff *skb, void *p)
1547 {
1548 	TODO();
1549 	return (0);
1550 }
1551 
1552 static __inline void
1553 cfg80211_connect_done(struct net_device *ndev,
1554     struct cfg80211_connect_resp_params *conn_params, gfp_t gfp)
1555 {
1556 	TODO();
1557 }
1558 
1559 static __inline void
1560 cfg80211_crit_proto_stopped(struct wireless_dev *wdev, gfp_t gfp)
1561 {
1562 	TODO();
1563 }
1564 
1565 static __inline void
1566 cfg80211_disconnected(struct net_device *ndev, uint16_t reason,
1567     void *p, int x, bool locally_generated, gfp_t gfp)
1568 {
1569 	TODO();
1570 }
1571 
1572 static __inline int
1573 cfg80211_get_p2p_attr(const u8 *ie, u32 ie_len,
1574     enum ieee80211_p2p_attr_ids attr, u8 *p, size_t p_len)
1575 {
1576 	TODO();
1577 	return (-1);
1578 }
1579 
1580 static __inline void
1581 cfg80211_ibss_joined(struct net_device *ndev, const uint8_t *addr,
1582     struct linuxkpi_ieee80211_channel *chan, gfp_t gfp)
1583 {
1584 	TODO();
1585 }
1586 
1587 static __inline struct cfg80211_bss *
1588 cfg80211_inform_bss(struct wiphy *wiphy,
1589     struct linuxkpi_ieee80211_channel *channel,
1590     enum cfg80211_bss_frame_type bss_ftype, const uint8_t *bss, int _x,
1591     uint16_t cap, uint16_t intvl, const uint8_t *ie, size_t ie_len,
1592     int signal, gfp_t gfp)
1593 {
1594 	TODO();
1595 	return (NULL);
1596 }
1597 
1598 static __inline struct cfg80211_bss *
1599 cfg80211_inform_bss_data(struct wiphy *wiphy,
1600     struct cfg80211_inform_bss *bss_data,
1601     enum cfg80211_bss_frame_type bss_ftype, const uint8_t *bss, int _x,
1602     uint16_t cap, uint16_t intvl, const uint8_t *ie, size_t ie_len, gfp_t gfp)
1603 {
1604 	TODO();
1605 	return (NULL);
1606 }
1607 
1608 static __inline void
1609 cfg80211_mgmt_tx_status(struct wireless_dev *wdev, uint64_t cookie,
1610     const u8 *buf, size_t len, bool ack, gfp_t gfp)
1611 {
1612 	TODO();
1613 }
1614 
1615 static __inline void
1616 cfg80211_michael_mic_failure(struct net_device *ndev, const uint8_t *addr,
1617     enum nl80211_key_type key_type, int _x, void *p, gfp_t gfp)
1618 {
1619 	TODO();
1620 }
1621 
1622 static __inline void
1623 cfg80211_new_sta(struct net_device *ndev, const uint8_t *addr,
1624     struct station_info *sinfo, gfp_t gfp)
1625 {
1626 	TODO();
1627 }
1628 
1629 static __inline void
1630 cfg80211_del_sta(struct net_device *ndev, const uint8_t *addr, gfp_t gfp)
1631 {
1632 	TODO();
1633 }
1634 
1635 static __inline void
1636 cfg80211_port_authorized(struct net_device *ndev, const uint8_t *bssid,
1637     gfp_t gfp)
1638 {
1639 	TODO();
1640 }
1641 
1642 static __inline void
1643 cfg80211_ready_on_channel(struct wireless_dev *wdev, uint64_t cookie,
1644     struct linuxkpi_ieee80211_channel *channel, unsigned int duration,
1645     gfp_t gfp)
1646 {
1647 	TODO();
1648 }
1649 
1650 static __inline void
1651 cfg80211_remain_on_channel_expired(struct wireless_dev *wdev,
1652     uint64_t cookie, struct linuxkpi_ieee80211_channel *channel, gfp_t gfp)
1653 {
1654 	TODO();
1655 }
1656 
1657 static __inline void
1658 cfg80211_report_wowlan_wakeup(void)
1659 {
1660 	TODO();
1661 }
1662 
1663 static __inline void
1664 cfg80211_roamed(struct net_device *ndev, struct cfg80211_roam_info *roam_info,
1665     gfp_t gfp)
1666 {
1667 	TODO();
1668 }
1669 
1670 static __inline void
1671 cfg80211_rx_mgmt(struct wireless_dev *wdev, int freq, int _x,
1672     uint8_t *p, size_t p_len, int _x2)
1673 {
1674 	TODO();
1675 }
1676 
1677 static __inline void
1678 cfg80211_scan_done(struct cfg80211_scan_request *scan_request,
1679     struct cfg80211_scan_info *info)
1680 {
1681 	TODO();
1682 }
1683 
1684 static __inline void
1685 cfg80211_sched_scan_results(struct wiphy *wiphy, uint64_t reqid)
1686 {
1687 	TODO();
1688 }
1689 
1690 static __inline void
1691 cfg80211_sched_scan_stopped(struct wiphy *wiphy, int _x)
1692 {
1693 	TODO();
1694 }
1695 
1696 static __inline void
1697 cfg80211_unregister_wdev(struct wireless_dev *wdev)
1698 {
1699 	TODO();
1700 }
1701 
1702 static __inline struct sk_buff *
1703 cfg80211_vendor_cmd_alloc_reply_skb(struct wiphy *wiphy, unsigned int len)
1704 {
1705 	TODO();
1706 	return (NULL);
1707 }
1708 
1709 static __inline int
1710 cfg80211_vendor_cmd_reply(struct sk_buff *skb)
1711 {
1712 	TODO();
1713 	return (-ENXIO);
1714 }
1715 
1716 static __inline struct linuxkpi_ieee80211_channel *
1717 ieee80211_get_channel(struct wiphy *wiphy, uint32_t freq)
1718 {
1719 
1720 	return (linuxkpi_ieee80211_get_channel(wiphy, freq));
1721 }
1722 
1723 static inline size_t
1724 ieee80211_get_hdrlen_from_skb(struct sk_buff *skb)
1725 {
1726 	const struct ieee80211_hdr *hdr;
1727 	size_t len;
1728 
1729 	if (skb->len < 10)	/* sizeof(ieee80211_frame_[ack,cts]) */
1730 		return (0);
1731 
1732 	hdr = (const struct ieee80211_hdr *)skb->data;
1733 	len = ieee80211_hdrlen(hdr->frame_control);
1734 
1735 	/* If larger than what is in the skb return. */
1736 	if (len > skb->len)
1737 		return (0);
1738 
1739 	return (len);
1740 }
1741 
1742 static __inline bool
1743 cfg80211_channel_is_psc(struct linuxkpi_ieee80211_channel *channel)
1744 {
1745 
1746 	/* Only 6Ghz. */
1747 	if (channel->band != NL80211_BAND_6GHZ)
1748 		return (false);
1749 
1750 	TODO();
1751 	return (false);
1752 }
1753 
1754 static inline int
1755 cfg80211_get_ies_channel_number(const uint8_t *ie, size_t len,
1756     enum nl80211_band band, enum cfg80211_bss_frame_type ftype)
1757 {
1758 	const struct element *elem;
1759 
1760 	switch (band) {
1761 	case NL80211_BAND_6GHZ:
1762 		TODO();
1763 		break;
1764 	case NL80211_BAND_5GHZ:
1765 	case NL80211_BAND_2GHZ:
1766 		/* DSPARAMS has the channel number. */
1767 		elem = cfg80211_find_elem(IEEE80211_ELEMID_DSPARMS, ie, len);
1768 		if (elem != NULL && elem->datalen == 1)
1769 			return (elem->data[0]);
1770 		/* HTINFO has the primary center channel. */
1771 		elem = cfg80211_find_elem(IEEE80211_ELEMID_HTINFO, ie, len);
1772 		if (elem != NULL &&
1773 		    elem->datalen >= (sizeof(struct ieee80211_ie_htinfo) - 2)) {
1774 			const struct ieee80211_ie_htinfo *htinfo;
1775 			htinfo = (const struct ieee80211_ie_htinfo *)elem;
1776 			return (htinfo->hi_ctrlchannel);
1777 		}
1778 		/* What else? */
1779 		break;
1780 	default:
1781 		IMPROVE("Unsupported");
1782 		break;
1783 	}
1784 	return (-1);
1785 }
1786 
1787 /* Used for scanning at least. */
1788 static __inline void
1789 get_random_mask_addr(uint8_t *dst, const uint8_t *addr, const uint8_t *mask)
1790 {
1791 	int i;
1792 
1793 	/* Get a completely random address and then overlay what we want. */
1794 	get_random_bytes(dst, ETH_ALEN);
1795 	for (i = 0; i < ETH_ALEN; i++)
1796 		dst[i] = (dst[i] & ~(mask[i])) | (addr[i] & mask[i]);
1797 }
1798 
1799 static __inline void
1800 cfg80211_shutdown_all_interfaces(struct wiphy *wiphy)
1801 {
1802 	TODO();
1803 }
1804 
1805 static __inline bool
1806 cfg80211_reg_can_beacon(struct wiphy *wiphy, struct cfg80211_chan_def *chandef,
1807     enum nl80211_iftype iftype)
1808 {
1809 	TODO();
1810 	return (false);
1811 }
1812 
1813 static __inline void
1814 cfg80211_background_radar_event(struct wiphy *wiphy,
1815     struct cfg80211_chan_def *chandef, gfp_t gfp)
1816 {
1817 	TODO();
1818 }
1819 
1820 static __inline const u8 *
1821 cfg80211_find_ext_ie(uint8_t eid, uint8_t *p, size_t len)
1822 {
1823 	TODO();
1824 	return (NULL);
1825 }
1826 
1827 static __inline bool
1828 cfg80211_chandef_valid(const struct cfg80211_chan_def *chandef)
1829 {
1830 	TODO();
1831 	return (false);
1832 }
1833 
1834 #define	wiphy_info(wiphy, fmt, ...)					\
1835 	printf("%s:%d XXX TODO " fmt, __func__, __LINE__, __VA_ARGS__)
1836 
1837 #ifndef LINUXKPI_NET80211
1838 #define	ieee80211_channel		linuxkpi_ieee80211_channel
1839 #define	ieee80211_regdomain		linuxkpi_ieee80211_regdomain
1840 #endif
1841 
1842 #include <net/mac80211.h>
1843 
1844 #endif	/* _LINUXKPI_NET_CFG80211_H */
1845