xref: /freebsd/sys/compat/linuxkpi/common/include/net/mac80211.h (revision b4ce0ff19a1f0faa92bdb03019badfaa2876f73e)
1 /*-
2  * Copyright (c) 2020-2021 The FreeBSD Foundation
3  * Copyright (c) 2020-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_MAC80211_H
33 #define	_LINUXKPI_NET_MAC80211_H
34 
35 #include <sys/types.h>
36 
37 #include <asm/atomic64.h>
38 #include <linux/bitops.h>
39 #include <linux/etherdevice.h>
40 #include <linux/ethtool.h>
41 #include <linux/netdevice.h>
42 #include <linux/skbuff.h>
43 #include <linux/workqueue.h>
44 #include <net/cfg80211.h>
45 
46 #define	ARPHRD_IEEE80211_RADIOTAP		__LINE__ /* XXX TODO brcmfmac */
47 
48 #define	WLAN_OUI_MICROSOFT			(0x0050F2)
49 #define	WLAN_OUI_TYPE_MICROSOFT_WPA		(1)
50 #define	WLAN_OUI_TYPE_MICROSOFT_TPC		(8)
51 #define	WLAN_OUI_TYPE_WFA_P2P			(9)
52 #define	WLAN_OUI_WFA				(0x506F9A)
53 
54 /* hw->conf.flags */
55 enum ieee80211_hw_conf_flags {
56 	IEEE80211_CONF_IDLE			= BIT(0),
57 	IEEE80211_CONF_PS			= BIT(1),
58 	IEEE80211_CONF_MONITOR			= BIT(2),
59 };
60 
61 /* (*ops->config()) */
62 enum ieee80211_hw_conf_changed_flags {
63 	IEEE80211_CONF_CHANGE_CHANNEL		= BIT(0),
64 	IEEE80211_CONF_CHANGE_IDLE		= BIT(1),
65 	IEEE80211_CONF_CHANGE_PS		= BIT(2),
66 	IEEE80211_CONF_CHANGE_MONITOR		= BIT(3),
67 };
68 
69 #define	CFG80211_TESTMODE_CMD(_x)	/* XXX TODO */
70 
71 #define	FCS_LEN				4
72 
73 /* ops.configure_filter() */
74 enum mcast_filter_flags {
75 	FIF_ALLMULTI			= BIT(0),
76 	FIF_PROBE_REQ			= BIT(1),
77 	FIF_BCN_PRBRESP_PROMISC		= BIT(2),
78 	FIF_FCSFAIL			= BIT(3),
79 	FIF_OTHER_BSS			= BIT(4),
80 	FIF_PSPOLL			= BIT(5),
81 	FIF_CONTROL			= BIT(6),
82 };
83 
84 enum ieee80211_bss_changed {
85 	BSS_CHANGED_ARP_FILTER		= BIT(0),
86 	BSS_CHANGED_ASSOC		= BIT(1),
87 	BSS_CHANGED_BANDWIDTH		= BIT(2),
88 	BSS_CHANGED_BEACON		= BIT(3),
89 	BSS_CHANGED_BEACON_ENABLED	= BIT(4),
90 	BSS_CHANGED_BEACON_INFO		= BIT(5),
91 	BSS_CHANGED_BEACON_INT		= BIT(6),
92 	BSS_CHANGED_BSSID		= BIT(7),
93 	BSS_CHANGED_CQM			= BIT(8),
94 	BSS_CHANGED_ERP_CTS_PROT	= BIT(9),
95 	BSS_CHANGED_ERP_SLOT		= BIT(10),
96 	BSS_CHANGED_FTM_RESPONDER	= BIT(11),
97 	BSS_CHANGED_HT			= BIT(12),
98 	BSS_CHANGED_IDLE		= BIT(13),
99 	BSS_CHANGED_MU_GROUPS		= BIT(14),
100 	BSS_CHANGED_P2P_PS		= BIT(15),
101 	BSS_CHANGED_PS			= BIT(16),
102 	BSS_CHANGED_QOS			= BIT(17),
103 	BSS_CHANGED_TXPOWER		= BIT(18),
104 	BSS_CHANGED_HE_BSS_COLOR	= BIT(19),
105 	BSS_CHANGED_AP_PROBE_RESP	= BIT(20),
106 	BSS_CHANGED_BASIC_RATES		= BIT(21),
107 	BSS_CHANGED_ERP_PREAMBLE	= BIT(22),
108 	BSS_CHANGED_IBSS		= BIT(23),
109 	BSS_CHANGED_MCAST_RATE		= BIT(24),
110 	BSS_CHANGED_SSID		= BIT(25),
111 };
112 
113 /* 802.11 Figure 9-256 Suite selector format. [OUI(3), SUITE TYPE(1)] */
114 #define	WLAN_CIPHER_SUITE_OUI(_oui, _x)	(((_oui) << 8) | ((_x) & 0xff))
115 
116 /* 802.11 Table 9-131 Cipher suite selectors. */
117 /* 802.1x suite B			11 */
118 #define	WLAN_CIPHER_SUITE(_x)		WLAN_CIPHER_SUITE_OUI(0x000fac, _x)
119 /* Use group				0 */
120 #define	WLAN_CIPHER_SUITE_WEP40		WLAN_CIPHER_SUITE(1)
121 #define	WLAN_CIPHER_SUITE_TKIP		WLAN_CIPHER_SUITE(2)
122 /* Reserved				3 */
123 #define	WLAN_CIPHER_SUITE_CCMP		WLAN_CIPHER_SUITE(4)	/* CCMP-128 */
124 #define	WLAN_CIPHER_SUITE_WEP104	WLAN_CIPHER_SUITE(5)
125 #define	WLAN_CIPHER_SUITE_AES_CMAC	WLAN_CIPHER_SUITE(6)	/* BIP-CMAC-128 */
126 /* Group addressed traffic not allowed	7 */
127 #define	WLAN_CIPHER_SUITE_GCMP		WLAN_CIPHER_SUITE(8)
128 #define	WLAN_CIPHER_SUITE_GCMP_256	WLAN_CIPHER_SUITE(9)
129 #define	WLAN_CIPHER_SUITE_CCMP_256	WLAN_CIPHER_SUITE(10)
130 #define	WLAN_CIPHER_SUITE_BIP_GMAC_128	WLAN_CIPHER_SUITE(11)
131 #define	WLAN_CIPHER_SUITE_BIP_GMAC_256	WLAN_CIPHER_SUITE(12)
132 #define	WLAN_CIPHER_SUITE_BIP_CMAC_256	WLAN_CIPHER_SUITE(13)
133 /* Reserved				14-255 */
134 
135 
136 /* 802.11 Table 9-133 AKM suite selectors. */
137 #define	WLAN_AKM_SUITE(_x)		WLAN_CIPHER_SUITE_OUI(0x000fac, _x)
138 /* Reserved				0 */
139 #define	WLAN_AKM_SUITE_8021X		WLAN_AKM_SUITE(1)
140 #define	WLAN_AKM_SUITE_PSK		WLAN_AKM_SUITE(2)
141 #define	WLAN_AKM_SUITE_FT_8021X		WLAN_AKM_SUITE(3)
142 #define	WLAN_AKM_SUITE_FT_PSK		WLAN_AKM_SUITE(4)
143 #define	WLAN_AKM_SUITE_8021X_SHA256	WLAN_AKM_SUITE(5)
144 #define	WLAN_AKM_SUITE_PSK_SHA256	WLAN_AKM_SUITE(6)
145 /* TDLS					7 */
146 #define	WLAN_AKM_SUITE_SAE		WLAN_AKM_SUITE(8)
147 /* FToSAE				9 */
148 /* AP peer key				10 */
149 /* 802.1x suite B			11 */
150 /* 802.1x suite B 384			12 */
151 /* FTo802.1x 384			13 */
152 /* Reserved				14-255 */
153 /* Apparently 11ax defines more. Seen (19,20) mentioned. */
154 
155 
156 struct ieee80211_sta;
157 
158 struct ieee80211_ampdu_params {
159 	/* TODO FIXME */
160 	struct ieee80211_sta			*sta;
161 	uint8_t					tid;
162 	uint16_t				ssn;
163 	int		action, amsdu, buf_size, timeout;
164 };
165 
166 struct ieee80211_bar {
167 	/* TODO FIXME */
168 	int		control, start_seq_num;
169 	uint8_t		*ra;
170 	uint16_t	frame_control;
171 };
172 
173 struct ieee80211_p2p_noa_desc {
174 	uint32_t				count;		/* uint8_t ? */
175 	uint32_t				duration;
176 	uint32_t				interval;
177 	uint32_t				start_time;
178 };
179 
180 struct ieee80211_p2p_noa_attr {
181 	uint8_t					index;
182 	uint8_t					oppps_ctwindow;
183 	struct ieee80211_p2p_noa_desc		desc[4];
184 };
185 
186 struct ieee80211_mutable_offsets {
187 	/* TODO FIXME */
188 	uint16_t				tim_offset;
189 	int     cntdwn_counter_offs;
190 };
191 
192 #define	WLAN_MEMBERSHIP_LEN			(8)
193 #define	WLAN_USER_POSITION_LEN			(16)
194 
195 struct ieee80211_bss_conf {
196 	/* TODO FIXME */
197 	uint8_t					bssid[ETH_ALEN];
198 	uint8_t					transmitter_bssid[ETH_ALEN];
199 	struct ieee80211_ftm_responder_params	*ftmr_params;
200 	struct ieee80211_p2p_noa_attr		p2p_noa_attr;
201 	struct cfg80211_chan_def		chandef;
202 	__be32					arp_addr_list[1];	/* XXX TODO */
203 	struct ieee80211_rate			*beacon_rate;
204 	struct {
205 		uint8_t membership[WLAN_MEMBERSHIP_LEN];
206 		uint8_t position[WLAN_USER_POSITION_LEN];
207 	}  mu_group;
208 	struct {
209 		int color;
210 	} he_bss_color;
211 	size_t					ssid_len;
212 	uint8_t					ssid[IEEE80211_NWID_LEN];
213 	uint16_t				aid;
214 	uint16_t				ht_operation_mode;
215 	int					arp_addr_cnt;
216 
217 	uint8_t					dtim_period;
218 	bool					assoc;
219 	bool					idle;
220 	bool					qos;
221 	bool					ps;
222 	bool					twt_broadcast;
223 	bool					use_cts_prot;
224 	bool					use_short_preamble;
225 	bool					use_short_slot;
226 	uint16_t				beacon_int;
227 	uint32_t				sync_device_ts;
228 	uint64_t				sync_tsf;
229 	uint8_t					sync_dtim_count;
230 	int16_t					txpower;
231 	int					mcast_rate[NUM_NL80211_BANDS];
232 
233 	int		ack_enabled, bssid_index, bssid_indicator, cqm_rssi_hyst, cqm_rssi_thold, ema_ap, frame_time_rts_th, ftm_responder;
234 	int		htc_trig_based_pkt_ext;
235 	int		multi_sta_back_32bit, nontransmitted;
236 	int		profile_periodicity;
237 	int		twt_requester, uora_exists, uora_ocw_range;
238 	int		assoc_capability, enable_beacon, hidden_ssid, ibss_joined, twt_protected;
239 	int		fils_discovery, he_obss_pd, he_oper, twt_responder, unsol_bcast_probe_resp_interval;
240 	unsigned long	basic_rates;
241 	bool		he_support;
242 };
243 
244 struct ieee80211_chanctx_conf {
245 	/* TODO FIXME */
246 	int		rx_chains_dynamic, rx_chains_static;
247 	bool					radar_enabled;
248 	struct cfg80211_chan_def		def;
249 	struct cfg80211_chan_def		min_def;
250 
251 	/* Must stay last. */
252 	uint8_t					drv_priv[0] __aligned(CACHE_LINE_SIZE);
253 };
254 
255 struct ieee80211_channel_switch {
256 	/* TODO FIXME */
257 	int		block_tx, count, delay, device_timestamp, timestamp;
258 	struct cfg80211_chan_def		chandef;
259 };
260 
261 struct ieee80211_cipher_scheme {
262 	uint32_t	cipher;
263 	uint8_t		iftype;		/* We do not know the size of this. */
264 	uint8_t		hdr_len;
265 	uint8_t		pn_len;
266 	uint8_t		pn_off;
267 	uint8_t		key_idx_off;
268 	uint8_t		key_idx_mask;
269 	uint8_t		key_idx_shift;
270 	uint8_t		mic_len;
271 };
272 
273 enum ieee80211_event_type {
274 	BA_FRAME_TIMEOUT,
275 	BAR_RX_EVENT,
276 	MLME_EVENT,
277 	RSSI_EVENT,
278 };
279 
280 enum ieee80211_rssi_event_data {
281 	RSSI_EVENT_LOW,
282 	RSSI_EVENT_HIGH,
283 };
284 
285 enum ieee80211_mlme_event_data {
286 	ASSOC_EVENT,
287 	AUTH_EVENT,
288 	DEAUTH_RX_EVENT,
289 	DEAUTH_TX_EVENT,
290 };
291 
292 enum ieee80211_mlme_event_status {
293 	MLME_DENIED,
294 	MLME_TIMEOUT,
295 };
296 
297 struct ieee80211_mlme_event {
298 	enum ieee80211_mlme_event_data		data;
299 	enum ieee80211_mlme_event_status	status;
300 	int					reason;
301 };
302 
303 struct ieee80211_event {
304 	/* TODO FIXME */
305 	enum ieee80211_event_type		type;
306 	union {
307 		struct {
308 			int     ssn;
309 			struct ieee80211_sta	*sta;
310 			uint8_t		 	tid;
311 		} ba;
312 		struct ieee80211_mlme_event	mlme;
313 	} u;
314 };
315 
316 struct ieee80211_ftm_responder_params {
317 	/* TODO FIXME */
318 	uint8_t					*lci;
319 	uint8_t					*civicloc;
320 	int					lci_len;
321 	int					civicloc_len;
322 };
323 
324 struct ieee80211_he_mu_edca_param_ac_rec {
325 	/* TODO FIXME */
326 	int		aifsn, ecw_min_max, mu_edca_timer;
327 };
328 
329 struct ieee80211_conf {
330 	int					dynamic_ps_timeout;
331 	uint32_t				listen_interval;
332 	enum ieee80211_hw_conf_flags		flags;
333 	struct cfg80211_chan_def		chandef;
334 };
335 
336 enum ieee80211_hw_flags {
337 	IEEE80211_HW_AMPDU_AGGREGATION,
338 	IEEE80211_HW_AP_LINK_PS,
339 	IEEE80211_HW_BUFF_MMPDU_TXQ,
340 	IEEE80211_HW_CHANCTX_STA_CSA,
341 	IEEE80211_HW_CONNECTION_MONITOR,
342 	IEEE80211_HW_DEAUTH_NEED_MGD_TX_PREP,
343 	IEEE80211_HW_HAS_RATE_CONTROL,
344 	IEEE80211_HW_MFP_CAPABLE,
345 	IEEE80211_HW_NEEDS_UNIQUE_STA_ADDR,
346 	IEEE80211_HW_REPORTS_TX_ACK_STATUS,
347 	IEEE80211_HW_RX_INCLUDES_FCS,
348 	IEEE80211_HW_SIGNAL_DBM,
349 	IEEE80211_HW_SINGLE_SCAN_ON_ALL_BANDS,
350 	IEEE80211_HW_SPECTRUM_MGMT,
351 	IEEE80211_HW_STA_MMPDU_TXQ,
352 	IEEE80211_HW_SUPPORTS_AMSDU_IN_AMPDU,
353 	IEEE80211_HW_SUPPORTS_CLONED_SKBS,
354 	IEEE80211_HW_SUPPORTS_DYNAMIC_PS,
355 	IEEE80211_HW_SUPPORTS_MULTI_BSSID,
356 	IEEE80211_HW_SUPPORTS_ONLY_HE_MULTI_BSSID,
357 	IEEE80211_HW_SUPPORTS_PS,
358 	IEEE80211_HW_SUPPORTS_REORDERING_BUFFER,
359 	IEEE80211_HW_SUPPORTS_VHT_EXT_NSS_BW,
360 	IEEE80211_HW_SUPPORT_FAST_XMIT,
361 	IEEE80211_HW_TDLS_WIDER_BW,
362 	IEEE80211_HW_TIMING_BEACON_ONLY,
363 	IEEE80211_HW_TX_AMPDU_SETUP_IN_HW,
364 	IEEE80211_HW_TX_AMSDU,
365 	IEEE80211_HW_TX_FRAG_LIST,
366 	IEEE80211_HW_USES_RSS,
367 	IEEE80211_HW_WANT_MONITOR_VIF,
368 	IEEE80211_HW_SW_CRYPTO_CONTROL,
369 	IEEE80211_HW_SUPPORTS_TX_FRAG,
370 	IEEE80211_HW_SUPPORTS_TDLS_BUFFER_STA,
371 	IEEE80211_HW_SUPPORTS_PER_STA_GTK,
372 	IEEE80211_HW_REPORTS_LOW_ACK,
373 	IEEE80211_HW_QUEUE_CONTROL,
374 
375 	/* Keep last. */
376 	NUM_IEEE80211_HW_FLAGS
377 };
378 
379 struct ieee80211_hw {
380 
381 	struct wiphy			*wiphy;
382 
383 	/* TODO FIXME */
384 	int		max_rx_aggregation_subframes, max_tx_aggregation_subframes;
385 	int		extra_tx_headroom, weight_multiplier;
386 	int		max_rate_tries, max_rates, max_report_rates;
387 	struct ieee80211_cipher_scheme	*cipher_schemes;
388 	int				n_cipher_schemes;
389 	const char			*rate_control_algorithm;
390 	struct {
391 		uint16_t units_pos;	/* radiotap "spec" is .. inconsistent. */
392 		uint16_t accuracy;
393 	} radiotap_timestamp;
394 	size_t				sta_data_size;
395 	size_t				vif_data_size;
396 	size_t				chanctx_data_size;
397 	size_t				txq_data_size;
398 	uint16_t			radiotap_mcs_details;
399 	uint16_t			radiotap_vht_details;
400 	uint16_t			queues;
401 	uint16_t			offchannel_tx_hw_queue;
402 	uint16_t			uapsd_max_sp_len;
403 	uint16_t			uapsd_queues;
404 	uint16_t			max_tx_fragments;
405 	uint16_t			max_listen_interval;
406 	netdev_features_t		netdev_features;
407 	unsigned long			flags[BITS_TO_LONGS(NUM_IEEE80211_HW_FLAGS)];
408 	struct ieee80211_conf		conf;
409 
410 #if 0	/* leave here for documentation purposes.  This does NOT work. */
411 	/* Must stay last. */
412 	uint8_t				priv[0] __aligned(CACHE_LINE_SIZE);
413 #else
414 	void				*priv;
415 #endif
416 };
417 
418 enum ieee802111_key_flag {
419 	IEEE80211_KEY_FLAG_GENERATE_IV		= BIT(0),
420 	IEEE80211_KEY_FLAG_GENERATE_MMIC	= BIT(1),
421 	IEEE80211_KEY_FLAG_PAIRWISE		= BIT(2),
422 	IEEE80211_KEY_FLAG_PUT_IV_SPACE		= BIT(3),
423 	IEEE80211_KEY_FLAG_PUT_MIC_SPACE	= BIT(4),
424 	IEEE80211_KEY_FLAG_SW_MGMT_TX		= BIT(5),
425 	IEEE80211_KEY_FLAG_GENERATE_IV_MGMT	= BIT(6),
426 };
427 
428 struct ieee80211_key_conf {
429 	atomic64_t			tx_pn;
430 	uint32_t			cipher;
431 	uint8_t				icv_len;	/* __unused nowadays? */
432 	uint8_t				iv_len;
433 	uint8_t				hw_key_idx;	/* Set by drv. */
434 	uint8_t				keyidx;
435 	uint16_t			flags;
436 	uint8_t				keylen;
437 	uint8_t				key[0];
438 };
439 
440 struct ieee80211_key_seq {
441 	/* TODO FIXME */
442 	union {
443 		struct {
444 			uint8_t		seq[IEEE80211_MAX_PN_LEN];
445 			uint8_t		seq_len;
446 		} hw;
447 		struct {
448 			uint8_t		pn[IEEE80211_CCMP_PN_LEN];
449 		} ccmp;
450 		struct {
451 			uint8_t		pn[IEEE80211_CCMP_PN_LEN];
452 		} aes_cmac;
453 		struct {
454 			uint32_t	iv32;
455 			uint16_t	iv16;
456 		} tkip;
457 	};
458 };
459 
460 
461 enum ieee80211_rx_status_flags {
462 	RX_FLAG_ALLOW_SAME_PN		= BIT(0),
463 	RX_FLAG_AMPDU_DETAILS		= BIT(1),
464 	RX_FLAG_AMPDU_EOF_BIT		= BIT(2),
465 	RX_FLAG_AMPDU_EOF_BIT_KNOWN	= BIT(3),
466 	RX_FLAG_DECRYPTED		= BIT(4),
467 	RX_FLAG_DUP_VALIDATED		= BIT(5),
468 	RX_FLAG_FAILED_FCS_CRC		= BIT(6),
469 	RX_FLAG_ICV_STRIPPED		= BIT(7),
470 	RX_FLAG_MACTIME_PLCP_START	= BIT(8),
471 	RX_FLAG_MACTIME_START		= BIT(9),
472 	RX_FLAG_MIC_STRIPPED		= BIT(10),
473 	RX_FLAG_MMIC_ERROR		= BIT(11),
474 	RX_FLAG_MMIC_STRIPPED		= BIT(12),
475 	RX_FLAG_NO_PSDU			= BIT(13),
476 	RX_FLAG_PN_VALIDATED		= BIT(14),
477 	RX_FLAG_RADIOTAP_HE		= BIT(15),
478 	RX_FLAG_RADIOTAP_HE_MU		= BIT(16),
479 	RX_FLAG_RADIOTAP_LSIG		= BIT(17),
480 	RX_FLAG_RADIOTAP_VENDOR_DATA	= BIT(18),
481 	RX_FLAG_NO_SIGNAL_VAL		= BIT(19),
482 	RX_FLAG_IV_STRIPPED		= BIT(20),
483 	RX_FLAG_AMPDU_IS_LAST		= BIT(21),
484 	RX_FLAG_AMPDU_LAST_KNOWN	= BIT(22),
485 	RX_FLAG_AMSDU_MORE		= BIT(23),
486 	RX_FLAG_MACTIME_END		= BIT(24),
487 	RX_FLAG_ONLY_MONITOR		= BIT(25),
488 	RX_FLAG_SKIP_MONITOR		= BIT(26),
489 };
490 
491 struct ieee80211_rx_status {
492 	/* TODO FIXME, this is too large. Over-reduce types to u8 where possible. */
493 	uint64_t			boottime_ns;
494 	uint64_t			mactime;
495 	uint32_t			device_timestamp;
496 	enum ieee80211_rx_status_flags	flag;
497 	uint16_t			freq;
498 	uint8_t				bw;
499 #define	RATE_INFO_BW_20		0x01
500 #define	RATE_INFO_BW_40		0x02
501 #define	RATE_INFO_BW_80		0x04
502 #define	RATE_INFO_BW_160	0x08
503 #define	RATE_INFO_BW_HE_RU	0x10
504 	uint8_t				encoding;
505 #define	RX_ENC_LEGACY		0x00
506 #define	RX_ENC_HE		0x01
507 #define	RX_ENC_HT		0x02
508 #define	RX_ENC_VHT		0x04
509 	uint8_t				ampdu_reference;
510 	uint8_t				band;
511 	uint8_t				chains;
512 	int8_t				chain_signal[IEEE80211_MAX_CHAINS];
513 	int8_t				signal;
514 	uint8_t				enc_flags;
515 	uint8_t				he_dcm;
516 	uint8_t				he_gi;
517 	uint8_t				he_ru;
518 	uint8_t				zero_length_psdu_type;
519 	uint8_t				nss;
520 	uint8_t				rate_idx;
521 };
522 
523 struct ieee80211_scan_ies {
524 	/* TODO FIXME */
525 	int		common_ie_len;
526 	int		len[NUM_NL80211_BANDS];
527 	uint8_t		*common_ies;
528 	uint8_t		*ies[NUM_NL80211_BANDS];
529 };
530 
531 struct ieee80211_scan_request {
532 	struct ieee80211_scan_ies	ies;
533 	struct cfg80211_scan_request	req;
534 };
535 
536 struct ieee80211_txq {
537 	struct ieee80211_sta		*sta;
538 	struct ieee80211_vif		*vif;
539 	int				ac;
540 	uint8_t				tid;
541 
542 	/* Must stay last. */
543 	uint8_t				drv_priv[0] __aligned(CACHE_LINE_SIZE);
544 };
545 
546 struct ieee80211_sta_rates {
547 	/* XXX TODO */
548 	/* XXX some _rcu thing */
549 	struct {
550 		int	idx;
551 		int	flags;
552 	} rate[1];		/* XXX what is the real number? */
553 };
554 
555 struct ieee80211_sta_txpwr {
556 	/* XXX TODO */
557 	enum nl80211_tx_power_setting	type;
558 	short				power;
559 };
560 
561 #define	IEEE80211_NUM_TIDS			16	/* net80211::WME_NUM_TID */
562 struct ieee80211_sta {
563 	/* TODO FIXME */
564 	int		max_amsdu_len, max_amsdu_subframes, max_rc_amsdu_len, max_sp;
565 	int		mfp, rx_nss, smps_mode, tdls, tdls_initiator, uapsd_queues, wme;
566 	enum ieee80211_sta_rx_bw		bandwidth;
567 	struct ieee80211_sta_ht_cap		ht_cap;
568 	struct ieee80211_sta_vht_cap		vht_cap;
569 	struct ieee80211_sta_he_cap		he_cap;
570 	struct ieee80211_sta_he_6ghz_capa	he_6ghz_capa;
571 	struct ieee80211_txq			*txq[IEEE80211_NUM_TIDS + 1];	/* iwlwifi: 8 and adds +1 to tid_data, net80211::IEEE80211_TID_SIZE */
572 	struct ieee80211_sta_rates		*rates;	/* some rcu thing? */
573 	struct ieee80211_sta_txpwr		txpwr;
574 	uint32_t				max_tid_amsdu_len[IEEE80211_NUM_TIDS];
575 	uint32_t				supp_rates[NUM_NL80211_BANDS];
576 	uint8_t					addr[ETH_ALEN];
577 	uint16_t				aid;
578 
579 	/* Must stay last. */
580 	uint8_t					drv_priv[0] __aligned(CACHE_LINE_SIZE);
581 };
582 
583 struct ieee80211_tdls_ch_sw_params {
584 	/* TODO FIXME */
585 	int		action_code, ch_sw_tm_ie, status, switch_time, switch_timeout, timestamp;
586 	struct ieee80211_sta			*sta;
587 	struct cfg80211_chan_def		*chandef;
588 	struct sk_buff				*tmpl_skb;
589 };
590 
591 struct ieee80211_tx_control {
592 	/* TODO FIXME */
593 	struct ieee80211_sta			*sta;
594 };
595 
596 struct ieee80211_tx_queue_params {
597 	/* These types are based on iwlwifi FW structs. */
598 	uint16_t	cw_min;
599 	uint16_t	cw_max;
600 	uint16_t	txop;
601 	uint8_t		aifs;
602 
603 	/* TODO FIXME */
604 	int		acm, mu_edca, uapsd;
605 	struct ieee80211_he_mu_edca_param_ac_rec	mu_edca_param_rec;
606 };
607 
608 struct ieee80211_tx_rate {
609 	uint8_t		idx;
610 	uint16_t	count:5,
611 			flags:11;
612 };
613 
614 enum ieee80211_vif_driver_flags {
615 	IEEE80211_VIF_BEACON_FILTER		= BIT(0),
616 	IEEE80211_VIF_SUPPORTS_CQM_RSSI		= BIT(1),
617 	IEEE80211_VIF_SUPPORTS_UAPSD		= BIT(2),
618 };
619 
620 struct ieee80211_vif {
621 	/* TODO FIXME */
622 	enum nl80211_iftype		type;
623 	int		csa_active, mu_mimo_owner;
624 	int		cab_queue;
625 	int     color_change_active, offload_flags;
626 	enum ieee80211_vif_driver_flags	driver_flags;
627 	bool				p2p;
628 	bool				probe_req_reg;
629 	uint8_t				addr[ETH_ALEN];
630 	struct ieee80211_chanctx_conf	*chanctx_conf;
631 	struct ieee80211_txq		*txq;
632 	struct ieee80211_bss_conf	bss_conf;
633 	uint8_t				hw_queue[IEEE80211_NUM_ACS];
634 
635 	/* Must stay last. */
636 	uint8_t				drv_priv[0] __aligned(CACHE_LINE_SIZE);
637 };
638 
639 struct ieee80211_vif_chanctx_switch {
640 	struct ieee80211_chanctx_conf	*old_ctx, *new_ctx;
641 	struct ieee80211_vif		*vif;
642 };
643 
644 struct ieee80211_prep_tx_info {
645 	u16				duration;
646 	bool				success;
647 };
648 
649 /* XXX-BZ too big, over-reduce size to u8, and array sizes to minuimum to fit in skb->cb. */
650 /* Also warning: some sizes change by pointer size!  This is 64bit only. */
651 struct ieee80211_tx_info {
652 	enum ieee80211_tx_info_flags		flags;
653 	/* TODO FIXME */
654 	u8		band;
655 	u8		hw_queue;
656 	bool		tx_time_est;
657 	union {
658 		struct {
659 			struct ieee80211_tx_rate	rates[4];
660 			bool				use_rts;
661 			struct ieee80211_vif		*vif;
662 			struct ieee80211_key_conf	*hw_key;
663 			enum ieee80211_tx_control_flags	flags;
664 		} control;
665 		struct {
666 			struct ieee80211_tx_rate	rates[4];
667 			uint32_t			ack_signal;
668 			uint8_t				ampdu_ack_len;
669 			uint8_t				ampdu_len;
670 			uint8_t				antenna;
671 			uint16_t			tx_time;
672 			bool				is_valid_ack_signal;
673 			void				*status_driver_data[16 / sizeof(void *)];		/* XXX TODO */
674 		} status;
675 #define	IEEE80211_TX_INFO_DRIVER_DATA_SIZE	(5 * sizeof(void *))			/* XXX TODO 5? */
676 		void					*driver_data[IEEE80211_TX_INFO_DRIVER_DATA_SIZE / sizeof(void *)];
677 	};
678 };
679 
680 /* net80211 conflict */
681 struct linuxkpi_ieee80211_tim_ie {
682 	uint8_t				dtim_count;
683 	uint8_t				dtim_period;
684 	uint8_t				bitmap_ctrl;
685 	uint8_t				*virtual_map;
686 };
687 #define	ieee80211_tim_ie	linuxkpi_ieee80211_tim_ie
688 
689 struct survey_info {		/* net80211::struct ieee80211_channel_survey */
690 	/* TODO FIXME */
691 	uint32_t			filled;
692 #define	SURVEY_INFO_TIME		0x0001
693 #define	SURVEY_INFO_TIME_RX		0x0002
694 #define	SURVEY_INFO_TIME_SCAN		0x0004
695 #define	SURVEY_INFO_TIME_TX		0x0008
696 #define	SURVEY_INFO_TIME_BSS_RX		0x0010
697 #define	SURVEY_INFO_TIME_BUSY		0x0020
698 #define	SURVEY_INFO_IN_USE		0x0040
699 #define	SURVEY_INFO_NOISE_DBM		0x0080
700 	uint32_t			noise;
701 	uint64_t			time;
702 	uint64_t			time_bss_rx;
703 	uint64_t			time_busy;
704 	uint64_t			time_rx;
705 	uint64_t			time_scan;
706 	uint64_t			time_tx;
707 	struct ieee80211_channel	*channel;
708 };
709 
710 enum ieee80211_iface_iter {
711 	IEEE80211_IFACE_ITER_NORMAL	= BIT(0),
712 	IEEE80211_IFACE_ITER_RESUME_ALL	= BIT(1),
713 	IEEE80211_IFACE_SKIP_SDATA_NOT_IN_DRIVER = BIT(2),	/* seems to be an iter flag */
714 
715 	/* Internal flags only. */
716 	/* ieee80211_iterate_active_interfaces*(). */
717 	IEEE80211_IFACE_ITER__ATOMIC	= BIT(6),
718 	IEEE80211_IFACE_ITER__ACTIVE	= BIT(7),
719 };
720 
721 enum set_key_cmd {
722 	SET_KEY,
723 	DISABLE_KEY,
724 };
725 
726 enum rx_enc_flags {
727 	RX_ENC_FLAG_SHORTPRE	=	BIT(0),
728 	RX_ENC_FLAG_SHORT_GI	=	BIT(1),
729 	RX_ENC_FLAG_HT_GF	=	BIT(2),
730 	RX_ENC_FLAG_LDPC	=	BIT(3),
731 	RX_ENC_FLAG_BF		=	BIT(4),
732 #define	RX_ENC_FLAG_STBC_SHIFT		6
733 };
734 
735 enum sta_notify_cmd {
736 	STA_NOTIFY_AWAKE,
737 	STA_NOTIFY_SLEEP,
738 };
739 
740 struct ieee80211_ops {
741 	/* TODO FIXME */
742 	int  (*start)(struct ieee80211_hw *);
743 	void (*stop)(struct ieee80211_hw *);
744 
745 	int  (*config)(struct ieee80211_hw *, u32);
746 	void (*reconfig_complete)(struct ieee80211_hw *, enum ieee80211_reconfig_type);
747 
748 	int  (*add_interface)(struct ieee80211_hw *, struct ieee80211_vif *);
749 	void (*remove_interface)(struct ieee80211_hw *, struct ieee80211_vif *);
750 	int  (*change_interface)(struct ieee80211_hw *, struct ieee80211_vif *, enum nl80211_iftype, bool);
751 
752 	void (*sw_scan_start)(struct ieee80211_hw *, struct ieee80211_vif *, const u8 *);
753 	void (*sw_scan_complete)(struct ieee80211_hw *, struct ieee80211_vif *);
754 	int  (*sched_scan_start)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_sched_scan_request *, struct ieee80211_scan_ies *);
755 	int  (*sched_scan_stop)(struct ieee80211_hw *, struct ieee80211_vif *);
756 	int  (*hw_scan)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_scan_request *);
757 	void (*cancel_hw_scan)(struct ieee80211_hw *, struct ieee80211_vif *);
758 
759 	int  (*conf_tx)(struct ieee80211_hw *, struct ieee80211_vif *, u16, const struct ieee80211_tx_queue_params *);
760 	void (*tx)(struct ieee80211_hw *, struct ieee80211_tx_control *, struct sk_buff *);
761 	int  (*tx_last_beacon)(struct ieee80211_hw *);
762 	void (*wake_tx_queue)(struct ieee80211_hw *, struct ieee80211_txq *);
763 
764 	void (*mgd_prepare_tx)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_prep_tx_info *);
765 	void (*mgd_complete_tx)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_prep_tx_info *);
766 	void (*mgd_protect_tdls_discover)(struct ieee80211_hw *, struct ieee80211_vif *);
767 
768 	void (*flush)(struct ieee80211_hw *, struct ieee80211_vif *, u32, bool);
769 
770 	int  (*set_frag_threshold)(struct ieee80211_hw *, u32);
771 
772 	void (*sync_rx_queues)(struct ieee80211_hw *);
773 
774 	void (*allow_buffered_frames)(struct ieee80211_hw *, struct ieee80211_sta *, u16, int, enum ieee80211_frame_release_type, bool);
775 	void (*release_buffered_frames)(struct ieee80211_hw *, struct ieee80211_sta *, u16, int, enum ieee80211_frame_release_type, bool);
776 
777 	int  (*sta_add)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *);
778 	int  (*sta_remove)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *);
779 	int  (*sta_set_txpwr)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *);
780 	void (*sta_statistics)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, struct station_info *);
781 	void (*sta_pre_rcu_remove)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *);
782 	int  (*sta_state)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, enum ieee80211_sta_state, enum ieee80211_sta_state);
783 	void (*sta_notify)(struct ieee80211_hw *, struct ieee80211_vif *, enum sta_notify_cmd, struct ieee80211_sta *);
784 	void (*sta_rc_update)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, u32);
785 	void (*sta_rate_tbl_update)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *);
786 	void (*sta_set_4addr)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, bool);
787 
788 	u64  (*prepare_multicast)(struct ieee80211_hw *, struct netdev_hw_addr_list *);
789 
790 	int  (*ampdu_action)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_ampdu_params *);
791 
792 	bool (*can_aggregate_in_amsdu)(struct ieee80211_hw *, struct sk_buff *, struct sk_buff *);
793 
794 	int  (*pre_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_channel_switch *);
795 	int  (*post_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *);
796 	void (*channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_channel_switch *);
797 	void (*abort_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *);
798 	void (*channel_switch_rx_beacon)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_channel_switch *);
799 	int  (*tdls_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, u8, struct cfg80211_chan_def *, struct sk_buff *, u32);
800 	void (*tdls_cancel_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *);
801 	void (*tdls_recv_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_tdls_ch_sw_params *);
802 
803 	int  (*add_chanctx)(struct ieee80211_hw *, struct ieee80211_chanctx_conf *);
804 	void (*remove_chanctx)(struct ieee80211_hw *, struct ieee80211_chanctx_conf *);
805 	void (*change_chanctx)(struct ieee80211_hw *, struct ieee80211_chanctx_conf *, u32);
806 	int  (*assign_vif_chanctx)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_chanctx_conf *);
807 	void (*unassign_vif_chanctx)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_chanctx_conf *);
808 	int  (*switch_vif_chanctx)(struct ieee80211_hw *, struct ieee80211_vif_chanctx_switch *, int, enum ieee80211_chanctx_switch_mode);
809 
810 	int  (*get_antenna)(struct ieee80211_hw *, u32 *, u32 *);
811 	int  (*set_antenna)(struct ieee80211_hw *, u32, u32);
812 
813 	int  (*remain_on_channel)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_channel *, int, enum ieee80211_roc_type);
814 	int  (*cancel_remain_on_channel)(struct ieee80211_hw *, struct ieee80211_vif *);
815 
816 	void (*configure_filter)(struct ieee80211_hw *, unsigned int, unsigned int *, u64);
817 	void (*config_iface_filter)(struct ieee80211_hw *, struct ieee80211_vif *, unsigned int, unsigned int);
818 
819 	void (*bss_info_changed)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_bss_conf *, u32);
820 	int  (*set_rts_threshold)(struct ieee80211_hw *, u32);
821 	void (*event_callback)(struct ieee80211_hw *, struct ieee80211_vif *, const struct ieee80211_event *);
822 	int  (*get_survey)(struct ieee80211_hw *, int, struct survey_info *);
823 	int  (*get_ftm_responder_stats)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_ftm_responder_stats *);
824 	void (*offset_tsf)(struct ieee80211_hw *, struct ieee80211_vif *, s64);
825 	int  (*set_bitrate_mask)(struct ieee80211_hw *, struct ieee80211_vif *, const struct cfg80211_bitrate_mask *);
826 	void (*set_coverage_class)(struct ieee80211_hw *, s16);
827 	int  (*set_tim)(struct ieee80211_hw *, struct ieee80211_sta *, bool);
828 
829 	int  (*set_key)(struct ieee80211_hw *, enum set_key_cmd, struct ieee80211_vif *, struct ieee80211_sta *, struct ieee80211_key_conf *);
830 	void (*set_default_unicast_key)(struct ieee80211_hw *, struct ieee80211_vif *, int);
831 	void (*update_tkip_key)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_key_conf *, struct ieee80211_sta *, u32, u16 *);
832 
833 	int  (*start_pmsr)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_pmsr_request *);
834 	void (*abort_pmsr)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_pmsr_request *);
835 
836 	int  (*start_ap)(struct ieee80211_hw *, struct ieee80211_vif *);
837 	void (*stop_ap)(struct ieee80211_hw *, struct ieee80211_vif *);
838 	int  (*join_ibss)(struct ieee80211_hw *, struct ieee80211_vif *);
839 	void (*leave_ibss)(struct ieee80211_hw *, struct ieee80211_vif *);
840 
841 	int (*set_sar_specs)(struct ieee80211_hw *, const struct cfg80211_sar_specs *);
842 
843 	int (*set_tid_config)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, struct cfg80211_tid_config *);
844 	int (*reset_tid_config)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, u8);
845 
846 	int (*get_et_sset_count)(struct ieee80211_hw *, struct ieee80211_vif *, int);
847 	void (*get_et_stats)(struct ieee80211_hw *, struct ieee80211_vif *, struct ethtool_stats *, u64 *);
848 	void (*get_et_strings)(struct ieee80211_hw *, struct ieee80211_vif *, u32, u8 *);
849 
850 	void (*update_vif_offload)(struct ieee80211_hw *, struct ieee80211_vif *);
851 };
852 
853 
854 /* -------------------------------------------------------------------------- */
855 
856 /* linux_80211.c */
857 extern const struct cfg80211_ops linuxkpi_mac80211cfgops;
858 
859 struct ieee80211_hw *linuxkpi_ieee80211_alloc_hw(size_t,
860     const struct ieee80211_ops *);
861 void linuxkpi_ieee80211_iffree(struct ieee80211_hw *);
862 void linuxkpi_set_ieee80211_dev(struct ieee80211_hw *, char *);
863 int linuxkpi_ieee80211_ifattach(struct ieee80211_hw *);
864 void linuxkpi_ieee80211_ifdetach(struct ieee80211_hw *);
865 struct ieee80211_hw * linuxkpi_wiphy_to_ieee80211_hw(struct wiphy *);
866 void linuxkpi_ieee80211_iterate_interfaces(
867     struct ieee80211_hw *hw, enum ieee80211_iface_iter flags,
868     void(*iterfunc)(void *, uint8_t *, struct ieee80211_vif *),
869     void *);
870 void linuxkpi_ieee80211_iterate_keys(struct ieee80211_hw *,
871     struct ieee80211_vif *,
872     void(*iterfunc)(struct ieee80211_hw *, struct ieee80211_vif *,
873         struct ieee80211_sta *, struct ieee80211_key_conf *, void *),
874     void *);
875 void linuxkpi_ieee80211_iterate_chan_contexts(struct ieee80211_hw *,
876     void(*iterfunc)(struct ieee80211_hw *,
877 	struct ieee80211_chanctx_conf *, void *),
878     void *);
879 void linuxkpi_ieee80211_iterate_stations_atomic(struct ieee80211_hw *,
880    void (*iterfunc)(void *, struct ieee80211_sta *), void *);
881 void linuxkpi_ieee80211_scan_completed(struct ieee80211_hw *,
882     struct cfg80211_scan_info *);
883 void linuxkpi_ieee80211_rx(struct ieee80211_hw *, struct sk_buff *,
884     struct ieee80211_sta *, struct napi_struct *);
885 uint8_t linuxkpi_ieee80211_get_tid(struct ieee80211_hdr *);
886 struct ieee80211_sta *linuxkpi_ieee80211_find_sta(struct ieee80211_vif *,
887     const u8 *);
888 struct ieee80211_sta *linuxkpi_ieee80211_find_sta_by_ifaddr(
889     struct ieee80211_hw *, const uint8_t *, const uint8_t *);
890 struct sk_buff *linuxkpi_ieee80211_tx_dequeue(struct ieee80211_hw *,
891     struct ieee80211_txq *);
892 bool linuxkpi_ieee80211_is_ie_id_in_ie_buf(const u8, const u8 *, size_t);
893 bool linuxkpi_ieee80211_ie_advance(size_t *, const u8 *, size_t);
894 void linuxkpi_ieee80211_free_txskb(struct ieee80211_hw *, struct sk_buff *,
895     int);
896 void linuxkpi_ieee80211_queue_delayed_work(struct ieee80211_hw *,
897     struct delayed_work *, int);
898 void linuxkpi_ieee80211_queue_work(struct ieee80211_hw *, struct work_struct *);
899 struct sk_buff *linuxkpi_ieee80211_pspoll_get(struct ieee80211_hw *,
900     struct ieee80211_vif *);
901 struct sk_buff *linuxkpi_ieee80211_nullfunc_get(struct ieee80211_hw *,
902     struct ieee80211_vif *, bool);
903 void linuxkpi_ieee80211_txq_get_depth(struct ieee80211_txq *, unsigned long *,
904     unsigned long *);
905 struct wireless_dev *linuxkpi_ieee80211_vif_to_wdev(struct ieee80211_vif *);
906 void linuxkpi_ieee80211_connection_loss(struct ieee80211_vif *);
907 void linuxkpi_ieee80211_beacon_loss(struct ieee80211_vif *);
908 
909 /* -------------------------------------------------------------------------- */
910 
911 static __inline void
912 _ieee80211_hw_set(struct ieee80211_hw *hw, enum ieee80211_hw_flags flag)
913 {
914 
915 	set_bit(flag, hw->flags);
916 }
917 
918 static __inline bool
919 __ieee80211_hw_check(struct ieee80211_hw *hw, enum ieee80211_hw_flags flag)
920 {
921 
922 	return (test_bit(flag, hw->flags));
923 }
924 
925 /* They pass in shortened flag names; how confusingly inconsistent. */
926 #define	ieee80211_hw_set(_hw, _flag)					\
927 	_ieee80211_hw_set(_hw, IEEE80211_HW_ ## _flag)
928 #define	ieee80211_hw_check(_hw, _flag)					\
929 	__ieee80211_hw_check(_hw, IEEE80211_HW_ ## _flag)
930 
931 /* XXX-BZ add CTASSERTS that size of struct is <= sizeof skb->cb. */
932 CTASSERT(sizeof(struct ieee80211_tx_info) <= sizeof(((struct sk_buff *)0)->cb));
933 #define	IEEE80211_SKB_CB(_skb)						\
934 	((struct ieee80211_tx_info *)((_skb)->cb))
935 
936 CTASSERT(sizeof(struct ieee80211_rx_status) <= sizeof(((struct sk_buff *)0)->cb));
937 #define	IEEE80211_SKB_RXCB(_skb)					\
938 	((struct ieee80211_rx_status *)((_skb)->cb))
939 
940 static __inline void
941 ieee80211_free_hw(struct ieee80211_hw *hw)
942 {
943 
944 	linuxkpi_ieee80211_iffree(hw);
945 
946 	if (hw->wiphy != NULL)
947 		wiphy_free(hw->wiphy);
948 	/* Note that *hw is not valid any longer after this. */
949 
950 	IMPROVE();
951 }
952 
953 static __inline struct ieee80211_hw *
954 ieee80211_alloc_hw(size_t priv_len, const struct ieee80211_ops *ops)
955 {
956 
957 	return (linuxkpi_ieee80211_alloc_hw(priv_len, ops));
958 }
959 
960 static __inline void
961 SET_IEEE80211_DEV(struct ieee80211_hw *hw, struct device *dev)
962 {
963 
964 	set_wiphy_dev(hw->wiphy, dev);
965 	linuxkpi_set_ieee80211_dev(hw, dev_name(dev));
966 
967 	IMPROVE();
968 }
969 
970 static __inline int
971 ieee80211_register_hw(struct ieee80211_hw *hw)
972 {
973 	int error;
974 
975 	error = wiphy_register(hw->wiphy);
976 	if (error != 0)
977 		return (error);
978 
979 	/*
980 	 * At this point the driver has set all the options, flags, bands,
981 	 * ciphers, hw address(es), ... basically mac80211/cfg80211 hw/wiphy
982 	 * setup is done.
983 	 * We need to replicate a lot of information from here into net80211.
984 	 */
985 	error = linuxkpi_ieee80211_ifattach(hw);
986 
987 	IMPROVE();
988 
989 	return (error);
990 }
991 
992 static __inline void
993 ieee80211_unregister_hw(struct ieee80211_hw *hw)
994 {
995 
996 	wiphy_unregister(hw->wiphy);
997 	linuxkpi_ieee80211_ifdetach(hw);
998 
999 	IMPROVE();
1000 }
1001 
1002 static __inline struct ieee80211_hw *
1003 wiphy_to_ieee80211_hw(struct wiphy *wiphy)
1004 {
1005 
1006 	return (linuxkpi_wiphy_to_ieee80211_hw(wiphy));
1007 }
1008 
1009 /* -------------------------------------------------------------------------- */
1010 
1011 static __inline bool
1012 ieee80211_is_action(__le16 fc)
1013 {
1014 	__le16 v;
1015 
1016 	fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1017 	v = htole16(IEEE80211_FC0_SUBTYPE_ACTION | IEEE80211_FC0_TYPE_MGT);
1018 
1019 	return (fc == v);
1020 }
1021 
1022 static __inline bool
1023 ieee80211_is_probe_resp(__le16 fc)
1024 {
1025 	__le16 v;
1026 
1027 	fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1028 	v = htole16(IEEE80211_FC0_SUBTYPE_PROBE_RESP | IEEE80211_FC0_TYPE_MGT);
1029 
1030 	return (fc == v);
1031 }
1032 
1033 static __inline bool
1034 ieee80211_is_auth(__le16 fc)
1035 {
1036 	__le16 v;
1037 
1038 	fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1039 	v = htole16(IEEE80211_FC0_SUBTYPE_AUTH | IEEE80211_FC0_TYPE_MGT);
1040 
1041 	return (fc == v);
1042 }
1043 
1044 static __inline bool
1045 ieee80211_is_assoc_req(__le16 fc)
1046 {
1047 	__le16 v;
1048 
1049 	fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1050 	v = htole16(IEEE80211_FC0_SUBTYPE_ASSOC_REQ | IEEE80211_FC0_TYPE_MGT);
1051 
1052 	return (fc == v);
1053 }
1054 
1055 static __inline bool
1056 ieee80211_is_assoc_resp(__le16 fc)
1057 {
1058 	__le16 v;
1059 
1060 	fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1061 	v = htole16(IEEE80211_FC0_SUBTYPE_ASSOC_RESP | IEEE80211_FC0_TYPE_MGT);
1062 
1063 	return (fc == v);
1064 }
1065 
1066 static __inline bool
1067 ieee80211_is_reassoc_req(__le16 fc)
1068 {
1069 	__le16 v;
1070 
1071 	fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1072 	v = htole16(IEEE80211_FC0_SUBTYPE_REASSOC_REQ | IEEE80211_FC0_TYPE_MGT);
1073 
1074 	return (fc == v);
1075 }
1076 
1077 static __inline bool
1078 ieee80211_is_reassoc_resp(__le16 fc)
1079 {
1080 	__le16 v;
1081 
1082 	fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1083 	v = htole16(IEEE80211_FC0_SUBTYPE_REASSOC_RESP | IEEE80211_FC0_TYPE_MGT);
1084 
1085 	return (fc == v);
1086 }
1087 
1088 static __inline bool
1089 ieee80211_is_disassoc(__le16 fc)
1090 {
1091 	__le16 v;
1092 
1093 	fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1094 	v = htole16(IEEE80211_FC0_SUBTYPE_DISASSOC | IEEE80211_FC0_TYPE_MGT);
1095 
1096 	return (fc == v);
1097 }
1098 
1099 static __inline bool
1100 ieee80211_is_data_present(__le16 fc)
1101 {
1102 	TODO();
1103 	return (false);
1104 }
1105 
1106 static __inline bool
1107 ieee80211_is_deauth(__le16 fc)
1108 {
1109 	__le16 v;
1110 
1111 	fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1112 	v = htole16(IEEE80211_FC0_SUBTYPE_DEAUTH | IEEE80211_FC0_TYPE_MGT);
1113 
1114 	return (fc == v);
1115 }
1116 
1117 static __inline bool
1118 ieee80211_is_beacon(__le16 fc)
1119 {
1120 	__le16 v;
1121 
1122 	/*
1123 	 * For as much as I get it this comes in LE and unlike FreeBSD
1124 	 * where we get the entire frame header and u8[], here we get the
1125 	 * 9.2.4.1 Frame Control field only. Mask and compare.
1126 	 */
1127 	fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1128 	v = htole16(IEEE80211_FC0_SUBTYPE_BEACON | IEEE80211_FC0_TYPE_MGT);
1129 
1130 	return (fc == v);
1131 }
1132 
1133 
1134 static __inline bool
1135 ieee80211_is_probe_req(__le16 fc)
1136 {
1137 	__le16 v;
1138 
1139 	fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1140 	v = htole16(IEEE80211_FC0_SUBTYPE_PROBE_REQ | IEEE80211_FC0_TYPE_MGT);
1141 
1142 	return (fc == v);
1143 }
1144 
1145 static __inline bool
1146 ieee80211_has_protected(__le16 fc)
1147 {
1148 
1149 	return (fc & htole16(IEEE80211_FC1_PROTECTED << 8));
1150 }
1151 
1152 static __inline bool
1153 ieee80211_is_back_req(__le16 fc)
1154 {
1155 	__le16 v;
1156 
1157 	fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1158 	v = htole16(IEEE80211_FC0_SUBTYPE_BAR | IEEE80211_FC0_TYPE_CTL);
1159 
1160 	return (fc == v);
1161 }
1162 
1163 static __inline bool
1164 ieee80211_is_bufferable_mmpdu(__le16 fc)
1165 {
1166 	TODO();
1167 	return (false);
1168 }
1169 
1170 static __inline bool
1171 ieee80211_is_nullfunc(__le16 fc)
1172 {
1173 	__le16 v;
1174 
1175 	fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1176 	v = htole16(IEEE80211_FC0_SUBTYPE_NODATA | IEEE80211_FC0_TYPE_DATA);
1177 
1178 	return (fc == v);
1179 }
1180 
1181 static __inline bool
1182 ieee80211_is_qos_nullfunc(__le16 fc)
1183 {
1184 	__le16 v;
1185 
1186 	fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1187 	v = htole16(IEEE80211_FC0_SUBTYPE_QOS_NULL | IEEE80211_FC0_TYPE_DATA);
1188 
1189 	return (fc == v);
1190 }
1191 
1192 static __inline bool
1193 ieee80211_is_any_nullfunc(__le16 fc)
1194 {
1195 
1196 	return (ieee80211_is_nullfunc(fc) || ieee80211_is_qos_nullfunc(fc));
1197 }
1198 
1199 static __inline bool
1200 ieee80211_vif_is_mesh(struct ieee80211_vif *vif)
1201 {
1202 	TODO();
1203 	return (false);
1204 }
1205 
1206 static __inline bool
1207 ieee80211_has_a4(__le16 fc)
1208 {
1209 	__le16 v;
1210 
1211 	fc &= htole16((IEEE80211_FC1_DIR_TODS | IEEE80211_FC1_DIR_FROMDS) << 8);
1212 	v = htole16((IEEE80211_FC1_DIR_TODS | IEEE80211_FC1_DIR_FROMDS) << 8);
1213 
1214 	return (fc == v);
1215 }
1216 
1217 static __inline bool
1218 ieee80211_has_order(__le16 fc)
1219 {
1220 
1221 	return (fc & htole16(IEEE80211_FC1_ORDER << 8));
1222 }
1223 
1224 static __inline bool
1225 ieee80211_has_retry(__le16 fc)
1226 {
1227 
1228 	return (fc & htole16(IEEE80211_FC1_RETRY << 8));
1229 }
1230 
1231 
1232 static __inline bool
1233 ieee80211_has_fromds(__le16 fc)
1234 {
1235 
1236 	return (fc & htole16(IEEE80211_FC1_DIR_FROMDS << 8));
1237 }
1238 
1239 static __inline bool
1240 ieee80211_has_tods(__le16 fc)
1241 {
1242 
1243 	return (fc & htole16(IEEE80211_FC1_DIR_TODS << 8));
1244 }
1245 
1246 static __inline uint8_t *
1247 ieee80211_get_SA(struct ieee80211_hdr *hdr)
1248 {
1249 
1250 	if (ieee80211_has_a4(hdr->frame_control))
1251 		return (hdr->addr4);
1252 	if (ieee80211_has_fromds(hdr->frame_control))
1253 		return (hdr->addr3);
1254 	return (hdr->addr2);
1255 }
1256 
1257 static __inline uint8_t *
1258 ieee80211_get_DA(struct ieee80211_hdr *hdr)
1259 {
1260 
1261 	if (ieee80211_has_tods(hdr->frame_control))
1262 		return (hdr->addr3);
1263 	return (hdr->addr1);
1264 }
1265 
1266 static __inline bool
1267 ieee80211_has_morefrags(__le16 fc)
1268 {
1269 
1270 	fc &= htole16(IEEE80211_FC1_MORE_FRAG << 8);
1271 	return (fc != 0);
1272 }
1273 
1274 static __inline u8 *
1275 ieee80211_get_qos_ctl(struct ieee80211_hdr *hdr)
1276 {
1277         if (ieee80211_has_a4(hdr->frame_control))
1278                 return (u8 *)hdr + 30;
1279         else
1280                 return (u8 *)hdr + 24;
1281 }
1282 
1283 /* -------------------------------------------------------------------------- */
1284 /* Receive functions (air/driver to mac80211/net80211). */
1285 
1286 
1287 static __inline void
1288 ieee80211_rx_napi(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
1289     struct sk_buff *skb, struct napi_struct *napi)
1290 {
1291 
1292 	linuxkpi_ieee80211_rx(hw, skb, sta, napi);
1293 }
1294 
1295 static __inline void
1296 ieee80211_rx_ni(struct ieee80211_hw *hw, struct sk_buff *skb)
1297 {
1298 
1299 	linuxkpi_ieee80211_rx(hw, skb, NULL, NULL);
1300 }
1301 
1302 static __inline void
1303 ieee80211_rx_irqsafe(struct ieee80211_hw *hw, struct sk_buff *skb)
1304 {
1305 
1306 	linuxkpi_ieee80211_rx(hw, skb, NULL, NULL);
1307 }
1308 
1309 /* -------------------------------------------------------------------------- */
1310 
1311 static __inline uint8_t
1312 ieee80211_get_tid(struct ieee80211_hdr *hdr)
1313 {
1314 
1315 	return (linuxkpi_ieee80211_get_tid(hdr));
1316 }
1317 
1318 static __inline struct sk_buff *
1319 ieee80211_beacon_get_tim(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1320     uint16_t *tim_offset, uint16_t *tim_len)
1321 {
1322 
1323 	if (tim_offset != NULL)
1324 		*tim_offset = 0;
1325 	if (tim_len != NULL)
1326 		*tim_len = 0;
1327 	TODO();
1328 	return (NULL);
1329 }
1330 
1331 static __inline void
1332 ieee80211_iterate_active_interfaces_atomic(struct ieee80211_hw *hw,
1333     enum ieee80211_iface_iter flags,
1334     void(*iterfunc)(void *, uint8_t *, struct ieee80211_vif *),
1335     void *arg)
1336 {
1337 
1338 	flags |= IEEE80211_IFACE_ITER__ATOMIC;
1339 	flags |= IEEE80211_IFACE_ITER__ACTIVE;
1340 	linuxkpi_ieee80211_iterate_interfaces(hw, flags, iterfunc, arg);
1341 }
1342 
1343 static __inline void
1344 ieee80211_iterate_active_interfaces(struct ieee80211_hw *hw,
1345     enum ieee80211_iface_iter flags,
1346     void(*iterfunc)(void *, uint8_t *, struct ieee80211_vif *),
1347     void *arg)
1348 {
1349 
1350 	flags |= IEEE80211_IFACE_ITER__ACTIVE;
1351 	linuxkpi_ieee80211_iterate_interfaces(hw, flags, iterfunc, arg);
1352 }
1353 
1354 static __inline void
1355 ieee80211_iterate_interfaces(struct ieee80211_hw *hw,
1356    enum ieee80211_iface_iter flags,
1357    void (*iterfunc)(void *, uint8_t *, struct ieee80211_vif *),
1358    void *arg)
1359 {
1360 
1361 	linuxkpi_ieee80211_iterate_interfaces(hw, flags, iterfunc, arg);
1362 }
1363 
1364 static __inline void
1365 ieee80211_iter_keys(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1366     void(*iterfunc)(struct ieee80211_hw *, struct ieee80211_vif *,
1367         struct ieee80211_sta *, struct ieee80211_key_conf *, void *),
1368     void *arg)
1369 {
1370 
1371 	linuxkpi_ieee80211_iterate_keys(hw, vif, iterfunc, arg);
1372 }
1373 
1374 static __inline void
1375 ieee80211_iter_keys_rcu(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1376     void(*iterfunc)(struct ieee80211_hw *, struct ieee80211_vif *,
1377         struct ieee80211_sta *, struct ieee80211_key_conf *, void *),
1378     void *arg)
1379 {
1380 
1381 	IMPROVE();	/* "rcu" */
1382 	linuxkpi_ieee80211_iterate_keys(hw, vif, iterfunc, arg);
1383 }
1384 
1385 static __inline void
1386 ieee80211_iter_chan_contexts_atomic(struct ieee80211_hw *hw,
1387     void(*iterfunc)(struct ieee80211_hw *, struct ieee80211_chanctx_conf *, void *),
1388     void *arg)
1389 {
1390 
1391 	linuxkpi_ieee80211_iterate_chan_contexts(hw, iterfunc, arg);
1392 }
1393 
1394 static __inline void
1395 ieee80211_iterate_stations_atomic(struct ieee80211_hw *hw,
1396    void (*iterfunc)(void *, struct ieee80211_sta *), void *arg)
1397 {
1398 
1399 	linuxkpi_ieee80211_iterate_stations_atomic(hw, iterfunc, arg);
1400 }
1401 
1402 static __inline struct wireless_dev *
1403 ieee80211_vif_to_wdev(struct ieee80211_vif *vif)
1404 {
1405 
1406 	return (linuxkpi_ieee80211_vif_to_wdev(vif));
1407 }
1408 
1409 static __inline struct sk_buff *
1410 ieee80211_beacon_get_template(struct ieee80211_hw *hw,
1411     struct ieee80211_vif *vif, struct ieee80211_mutable_offsets *offs)
1412 {
1413 	TODO();
1414 	return (NULL);
1415 }
1416 
1417 static __inline void
1418 ieee80211_beacon_loss(struct ieee80211_vif *vif)
1419 {
1420 	linuxkpi_ieee80211_beacon_loss(vif);
1421 }
1422 
1423 static __inline void
1424 ieee80211_chswitch_done(struct ieee80211_vif *vif, bool t)
1425 {
1426 	TODO();
1427 }
1428 
1429 static __inline bool
1430 ieee80211_csa_is_complete(struct ieee80211_vif *vif)
1431 {
1432 	TODO();
1433 	return (false);
1434 }
1435 
1436 static __inline void
1437 ieee80211_csa_set_counter(struct ieee80211_vif *vif, uint8_t counter)
1438 {
1439 	TODO();
1440 }
1441 
1442 static __inline int
1443 ieee80211_csa_update_counter(struct ieee80211_vif *vif)
1444 {
1445 	TODO();
1446 	return (-1);
1447 }
1448 
1449 static __inline void
1450 ieee80211_csa_finish(struct ieee80211_vif *vif)
1451 {
1452 	TODO();
1453 }
1454 
1455 static __inline enum nl80211_iftype
1456 ieee80211_vif_type_p2p(struct ieee80211_vif *vif)
1457 {
1458 
1459 	/* If we are not p2p enabled, just return the type. */
1460 	if (!vif->p2p)
1461 		return (vif->type);
1462 
1463 	/* If we are p2p, depending on side, return type. */
1464 	switch (vif->type) {
1465 	case NL80211_IFTYPE_AP:
1466 		return (NL80211_IFTYPE_P2P_GO);
1467 	case NL80211_IFTYPE_STATION:
1468 		return (NL80211_IFTYPE_P2P_CLIENT);
1469 	default:
1470 		fallthrough;
1471 	}
1472 	return (vif->type);
1473 }
1474 
1475 static __inline unsigned long
1476 ieee80211_tu_to_usec(unsigned long tu)
1477 {
1478 
1479 	return (tu * IEEE80211_DUR_TU);
1480 }
1481 
1482 
1483 static __inline int
1484 ieee80211_action_contains_tpc(struct sk_buff *skb)
1485 {
1486 	TODO();
1487 	return (0);
1488 }
1489 
1490 static __inline void
1491 ieee80211_connection_loss(struct ieee80211_vif *vif)
1492 {
1493 
1494 	linuxkpi_ieee80211_connection_loss(vif);
1495 }
1496 
1497 static __inline struct ieee80211_sta *
1498 ieee80211_find_sta(struct ieee80211_vif *vif, const u8 *peer)
1499 {
1500 
1501 	return (linuxkpi_ieee80211_find_sta(vif, peer));
1502 }
1503 
1504 static __inline struct ieee80211_sta *
1505 ieee80211_find_sta_by_ifaddr(struct ieee80211_hw *hw, const uint8_t *addr,
1506     const uint8_t *ourvifaddr)
1507 {
1508 
1509 	return (linuxkpi_ieee80211_find_sta_by_ifaddr(hw, addr, ourvifaddr));
1510 }
1511 
1512 
1513 static __inline void
1514 ieee80211_get_tkip_p2k(struct ieee80211_key_conf *keyconf,
1515     struct sk_buff *skb_frag, u8 *key)
1516 {
1517 	TODO();
1518 }
1519 
1520 static __inline void
1521 ieee80211_get_tkip_rx_p1k(struct ieee80211_key_conf *keyconf,
1522     const u8 *addr, uint32_t iv32, u16 *p1k)
1523 {
1524 	TODO();
1525 }
1526 
1527 static __inline size_t
1528 ieee80211_ie_split(const u8 *ies, size_t ies_len,
1529     const u8 *ie_ids, size_t ie_ids_len, size_t start)
1530 {
1531 	size_t x;
1532 
1533 	x = start;
1534 
1535 	/* XXX FIXME, we need to deal with "Element ID Extension" */
1536 	while (x < ies_len) {
1537 
1538 		/* Is this IE[s] one of the ie_ids? */
1539 		if (!linuxkpi_ieee80211_is_ie_id_in_ie_buf(ies[x],
1540 		    ie_ids, ie_ids_len))
1541 			break;
1542 
1543 		if (!linuxkpi_ieee80211_ie_advance(&x, ies, ies_len))
1544 			break;
1545 	}
1546 
1547 	return (x);
1548 }
1549 
1550 static __inline void
1551 ieee80211_request_smps(struct ieee80211_vif *vif, enum ieee80211_smps_mode smps)
1552 {
1553 
1554 	TODO();
1555 }
1556 
1557 static __inline void
1558 ieee80211_tdls_oper_request(struct ieee80211_vif *vif, uint8_t *addr,
1559     enum nl80211_tdls_operation oper, enum ieee80211_reason_code code,
1560     gfp_t gfp)
1561 {
1562 	TODO();
1563 }
1564 
1565 static __inline void
1566 ieee80211_stop_queues(struct ieee80211_hw *hw)
1567 {
1568 	TODO();
1569 }
1570 
1571 static __inline void
1572 ieee80211_wake_queues(struct ieee80211_hw *hw)
1573 {
1574 	TODO();
1575 }
1576 
1577 static __inline void
1578 wiphy_rfkill_set_hw_state(struct wiphy *wiphy, bool state)
1579 {
1580 	TODO();
1581 }
1582 
1583 static __inline void
1584 ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb)
1585 {
1586 	IMPROVE();
1587 
1588 	/*
1589 	 * This is called on transmit failure.
1590 	 * Use a not-so-random random high status error so we can distinguish
1591 	 * it from normal low values flying around in net80211 ("ETX").
1592 	 */
1593 	linuxkpi_ieee80211_free_txskb(hw, skb, 0x455458);
1594 }
1595 
1596 static __inline void
1597 ieee80211_restart_hw(struct ieee80211_hw *hw)
1598 {
1599 	TODO();
1600 }
1601 
1602 static __inline void
1603 ieee80211_ready_on_channel(struct ieee80211_hw *hw)
1604 {
1605 	TODO();
1606 /* XXX-BZ We need to see that. */
1607 }
1608 
1609 static __inline void
1610 ieee80211_remain_on_channel_expired(struct ieee80211_hw *hw)
1611 {
1612 	TODO();
1613 }
1614 
1615 static __inline void
1616 ieee80211_cqm_rssi_notify(struct ieee80211_vif *vif,
1617     enum nl80211_cqm_rssi_threshold_event crte, int sig, gfp_t gfp)
1618 {
1619 	TODO();
1620 }
1621 
1622 static __inline void
1623 ieee80211_mark_rx_ba_filtered_frames(struct ieee80211_sta *sta, uint8_t tid,
1624     uint32_t ssn, uint64_t bitmap, uint16_t received_mpdu)
1625 {
1626 	TODO();
1627 }
1628 
1629 static __inline bool
1630 ieee80211_sn_less(uint16_t sn1, uint16_t sn2)
1631 {
1632 	TODO();
1633 	return (false);
1634 }
1635 
1636 static __inline uint16_t
1637 ieee80211_sn_inc(uint16_t sn)
1638 {
1639 	TODO();
1640 	return (sn + 1);
1641 }
1642 
1643 static __inline uint16_t
1644 ieee80211_sn_add(uint16_t sn, uint16_t a)
1645 {
1646 	TODO();
1647 	return (sn + a);
1648 }
1649 
1650 static __inline void
1651 ieee80211_stop_rx_ba_session(struct ieee80211_vif *vif, uint32_t x, uint8_t *addr)
1652 {
1653 	TODO();
1654 }
1655 
1656 static __inline void
1657 ieee80211_rate_set_vht(struct ieee80211_tx_rate *r, uint32_t f1, uint32_t f2)
1658 {
1659 	TODO();
1660 }
1661 
1662 static __inline void
1663 ieee80211_reserve_tid(struct ieee80211_sta *sta, uint8_t tid)
1664 {
1665 	TODO();
1666 }
1667 
1668 static __inline void
1669 ieee80211_unreserve_tid(struct ieee80211_sta *sta, uint8_t tid)
1670 {
1671 	TODO();
1672 }
1673 
1674 static __inline void
1675 ieee80211_rx_ba_timer_expired(struct ieee80211_vif *vif, uint8_t *addr,
1676     uint8_t tid)
1677 {
1678 	TODO();
1679 }
1680 
1681 static __inline void
1682 ieee80211_send_eosp_nullfunc(struct ieee80211_sta *sta, uint8_t tid)
1683 {
1684 	TODO();
1685 }
1686 
1687 static __inline uint16_t
1688 ieee80211_sn_sub(uint16_t sa, uint16_t sb)
1689 {
1690 
1691 	return ((sa - sb) & IEEE80211_SEQ_SEQ_MASK);
1692 }
1693 
1694 static __inline void
1695 ieee80211_sta_block_awake(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
1696     bool disable)
1697 {
1698 	TODO();
1699 }
1700 
1701 static __inline void
1702 ieee80211_sta_ps_transition(struct ieee80211_sta *sta, bool sleeping)
1703 {
1704 	TODO();
1705 }
1706 
1707 static __inline void
1708 ieee80211_sta_pspoll(struct ieee80211_sta *sta)
1709 {
1710 	TODO();
1711 }
1712 
1713 static __inline void
1714 ieee80211_sta_uapsd_trigger(struct ieee80211_sta *sta, int ntids)
1715 {
1716 	TODO();
1717 }
1718 
1719 static __inline void
1720 ieee80211_start_tx_ba_cb_irqsafe(struct ieee80211_vif *vif, uint8_t *addr,
1721     uint8_t tid)
1722 {
1723 	TODO();
1724 }
1725 
1726 static __inline void
1727 ieee80211_tkip_add_iv(u8 *crypto_hdr, struct ieee80211_key_conf *keyconf,
1728     uint64_t pn)
1729 {
1730 	TODO();
1731 }
1732 
1733 static __inline struct sk_buff *
1734 ieee80211_tx_dequeue(struct ieee80211_hw *hw, struct ieee80211_txq *txq)
1735 {
1736 
1737 	return (linuxkpi_ieee80211_tx_dequeue(hw, txq));
1738 }
1739 
1740 static __inline void
1741 ieee80211_update_mu_groups(struct ieee80211_vif *vif, uint8_t *ms, uint8_t *up)
1742 {
1743 	TODO();
1744 }
1745 
1746 static __inline void
1747 ieee80211_sta_set_buffered(struct ieee80211_sta *sta, uint8_t tid, bool t)
1748 {
1749 	TODO();
1750 }
1751 
1752 static __inline void
1753 ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)
1754 {
1755 	struct ieee80211_tx_info *info;
1756 	int status;
1757 
1758 	info = IEEE80211_SKB_CB(skb);
1759 
1760 	/* XXX-BZ this check is probably over-simplified? */
1761 	/* XXX-BZ but then we have no full feedback in net80211 yet. */
1762 	if (info->flags & IEEE80211_TX_STAT_ACK)
1763 		status = 0;	/* No error. */
1764 	else
1765 		status = 1;
1766 #if 0
1767 	printf("XXX-BZ: %s: hw %p skb %p status %d : flags %#x "
1768 	    "band %u hw_queue %u tx_time_est %d : "
1769 	    "rates [ %u %u %#x, %u %u %#x, %u %u %#x, %u %u %#x ] "
1770 	    "ack_signal %u ampdu_ack_len %u ampdu_len %u antenna %u tx_time %u "
1771 	    "is_valid_ack_signal %u status_driver_data [ %p %p ]\n",
1772 	    __func__, hw, skb, status, info->flags,
1773 	    info->band, info->hw_queue, info->tx_time_est,
1774 	    info->status.rates[0].idx, info->status.rates[0].count,
1775 	    info->status.rates[0].flags,
1776 	    info->status.rates[1].idx, info->status.rates[1].count,
1777 	    info->status.rates[1].flags,
1778 	    info->status.rates[2].idx, info->status.rates[2].count,
1779 	    info->status.rates[2].flags,
1780 	    info->status.rates[3].idx, info->status.rates[3].count,
1781 	    info->status.rates[3].flags,
1782 	    info->status.ack_signal, info->status.ampdu_ack_len,
1783 	    info->status.ampdu_len, info->status.antenna,
1784 	    info->status.tx_time, info->status.is_valid_ack_signal,
1785 	    info->status.status_driver_data[0],
1786 	    info->status.status_driver_data[1]);
1787 #endif
1788 	IMPROVE();
1789 	linuxkpi_ieee80211_free_txskb(hw, skb, status);
1790 }
1791 
1792 static __inline void
1793 ieee80211_get_key_rx_seq(struct ieee80211_key_conf *keyconf, uint8_t tid,
1794     struct ieee80211_key_seq *seq)
1795 {
1796 	TODO();
1797 }
1798 
1799 static __inline void
1800 ieee80211_sched_scan_results(struct ieee80211_hw *hw)
1801 {
1802 	TODO();
1803 }
1804 
1805 static __inline void
1806 ieee80211_sta_eosp(struct ieee80211_sta *sta)
1807 {
1808 	TODO();
1809 }
1810 
1811 static __inline void
1812 ieee80211_stop_tx_ba_cb_irqsafe(struct ieee80211_vif *vif, uint8_t *addr,
1813     uint8_t tid)
1814 {
1815 	TODO();
1816 }
1817 
1818 static __inline void
1819 ieee80211_sched_scan_stopped(struct ieee80211_hw *hw)
1820 {
1821 	TODO();
1822 }
1823 
1824 static __inline void
1825 ieee80211_scan_completed(struct ieee80211_hw *hw,
1826     struct cfg80211_scan_info *info)
1827 {
1828 
1829 	linuxkpi_ieee80211_scan_completed(hw, info);
1830 }
1831 
1832 static __inline struct sk_buff *
1833 ieee80211_beacon_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
1834 {
1835 	TODO();
1836 	return (NULL);
1837 }
1838 
1839 static __inline struct sk_buff *
1840 ieee80211_pspoll_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
1841 {
1842 
1843 	/* Only STA needs this.  Otherwise return NULL and panic bad drivers. */
1844 	if (vif->type != NL80211_IFTYPE_STATION)
1845 		return (NULL);
1846 
1847 	return (linuxkpi_ieee80211_pspoll_get(hw, vif));
1848 }
1849 
1850 static __inline struct sk_buff *
1851 ieee80211_proberesp_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
1852 {
1853 	TODO();
1854 	return (NULL);
1855 }
1856 
1857 static __inline struct sk_buff *
1858 ieee80211_nullfunc_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1859     bool qos)
1860 {
1861 
1862 	/* Only STA needs this.  Otherwise return NULL and panic bad drivers. */
1863 	if (vif->type != NL80211_IFTYPE_STATION)
1864 		return (NULL);
1865 
1866 	return (linuxkpi_ieee80211_nullfunc_get(hw, vif, qos));
1867 }
1868 
1869 static __inline struct sk_buff *
1870 ieee80211_probereq_get(struct ieee80211_hw *hw, uint8_t *addr,
1871     uint8_t *ssid, size_t ssid_len, int _x)
1872 {
1873 	TODO();
1874 	return (NULL);
1875 }
1876 
1877 static __inline void
1878 ieee80211_queue_delayed_work(struct ieee80211_hw *hw, struct delayed_work *w,
1879     int delay)
1880 {
1881 
1882 	linuxkpi_ieee80211_queue_delayed_work(hw, w, delay);
1883 }
1884 
1885 static __inline void
1886 ieee80211_queue_work(struct ieee80211_hw *hw, struct work_struct *w)
1887 {
1888 
1889 	linuxkpi_ieee80211_queue_work(hw, w);
1890 }
1891 
1892 static __inline void
1893 ieee80211_stop_queue(struct ieee80211_hw *hw, uint16_t q)
1894 {
1895 	TODO();
1896 }
1897 
1898 static __inline void
1899 ieee80211_wake_queue(struct ieee80211_hw *hw, uint16_t q)
1900 {
1901 	TODO();
1902 }
1903 
1904 static __inline void
1905 ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw, struct sk_buff *skb)
1906 {
1907 	IMPROVE();
1908 	ieee80211_tx_status(hw, skb);
1909 }
1910 
1911 static __inline void
1912 ieee80211_tx_status_ni(struct ieee80211_hw *hw, struct sk_buff *skb)
1913 {
1914 	IMPROVE();
1915 	ieee80211_tx_status(hw, skb);
1916 }
1917 
1918 static __inline int
1919 ieee80211_start_tx_ba_session(struct ieee80211_sta *sta, uint8_t tid, int x)
1920 {
1921 	TODO();
1922 	return (ENXIO);
1923 }
1924 
1925 static __inline void
1926 ieee80211_tx_info_clear_status(struct ieee80211_tx_info *info)
1927 {
1928 	int i;
1929 
1930 	/*
1931 	 * Apparently clearing flags and some other fields is not right.
1932 	 * Given the function is called "status" we work on that part of
1933 	 * the union.
1934 	 */
1935 	for (i = 0; i < nitems(info->status.rates); i++)
1936 		info->status.rates[i].count = 0;
1937 	/*
1938 	 * Unclear if ack_signal should be included or not but we clear the
1939 	 * "valid" bool so this field is no longer valid.
1940 	 */
1941 	memset(&info->status.ack_signal, 0, sizeof(*info) -
1942 	    offsetof(struct ieee80211_tx_info, status.ack_signal));
1943 }
1944 
1945 static __inline void
1946 ieee80211_txq_get_depth(struct ieee80211_txq *txq, unsigned long *frame_cnt,
1947     unsigned long *byte_cnt)
1948 {
1949 
1950 	if (frame_cnt == NULL && byte_cnt == NULL)
1951 		return;
1952 
1953 	linuxkpi_ieee80211_txq_get_depth(txq, frame_cnt, byte_cnt);
1954 }
1955 
1956 static __inline int
1957 rate_lowest_index(struct ieee80211_supported_band *band,
1958     struct ieee80211_sta *sta)
1959 {
1960 	IMPROVE();
1961 	return (0);
1962 }
1963 
1964 
1965 static __inline void
1966 SET_IEEE80211_PERM_ADDR	(struct ieee80211_hw *hw, uint8_t *addr)
1967 {
1968 
1969 	ether_addr_copy(hw->wiphy->perm_addr, addr);
1970 }
1971 
1972 static __inline uint8_t *
1973 ieee80211_bss_get_ie(struct cfg80211_bss *bss, uint32_t x)
1974 {
1975 	TODO();
1976 	return (NULL);
1977 }
1978 
1979 static __inline void
1980 ieee80211_report_low_ack(struct ieee80211_sta *sta, int x)
1981 {
1982 	TODO();
1983 }
1984 
1985 static __inline void
1986 ieee80211_start_rx_ba_session_offl(struct ieee80211_vif *vif, uint8_t *addr,
1987     uint8_t tid)
1988 {
1989 	TODO();
1990 }
1991 
1992 static __inline void
1993 ieee80211_stop_rx_ba_session_offl(struct ieee80211_vif *vif, uint8_t *addr,
1994     uint8_t tid)
1995 {
1996 	TODO();
1997 }
1998 
1999 static __inline struct sk_buff *
2000 ieee80211_tx_dequeue_ni(struct ieee80211_hw *hw, struct ieee80211_txq *txq)
2001 {
2002 	TODO();
2003 	return (NULL);
2004 }
2005 
2006 static __inline void
2007 ieee80211_tx_rate_update(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
2008     struct ieee80211_tx_info *info)
2009 {
2010 	TODO();
2011 }
2012 
2013 static __inline bool
2014 ieee80211_txq_may_transmit(struct ieee80211_hw *hw, struct ieee80211_txq *txq)
2015 {
2016 	TODO();
2017 	return (false);
2018 }
2019 
2020 static __inline struct ieee80211_txq *
2021 ieee80211_next_txq(struct ieee80211_hw *hw, uint32_t ac)
2022 {
2023 	TODO();
2024 	return (NULL);
2025 }
2026 
2027 static __inline void
2028 ieee80211_radar_detected(struct ieee80211_hw *hw)
2029 {
2030 	TODO();
2031 }
2032 
2033 static __inline void
2034 ieee80211_sta_register_airtime(struct ieee80211_sta *sta,
2035     uint8_t tid, uint32_t duration, int x)
2036 {
2037 	TODO();
2038 }
2039 
2040 
2041 static __inline void
2042 ieee80211_return_txq(struct ieee80211_hw *hw,
2043     struct ieee80211_txq *txq, bool _t)
2044 {
2045 	TODO();
2046 }
2047 
2048 static __inline void
2049 ieee80211_txq_schedule_end(struct ieee80211_hw *hw, uint32_t ac)
2050 {
2051 	TODO();
2052 }
2053 
2054 static __inline void
2055 ieee80211_txq_schedule_start(struct ieee80211_hw *hw, uint32_t ac)
2056 {
2057 	TODO();
2058 }
2059 
2060 static __inline void
2061 ieee80211_schedule_txq(struct ieee80211_hw *hw, struct ieee80211_txq *txq)
2062 {
2063 	TODO();
2064 }
2065 
2066 static __inline void
2067 ieee80211_beacon_set_cntdwn(struct ieee80211_vif *vif, u8 counter)
2068 {
2069 	TODO();
2070 }
2071 
2072 static __inline int
2073 ieee80211_beacon_update_cntdwn(struct ieee80211_vif *vif)
2074 {
2075 	TODO();
2076 	return (-1);
2077 }
2078 
2079 static __inline int
2080 ieee80211_get_vht_max_nss(struct ieee80211_vht_cap *vht_cap, uint32_t chanwidth,
2081     int x, bool t, int nss)
2082 {
2083 	TODO();
2084 	return (-1);
2085 }
2086 
2087 static __inline bool
2088 ieee80211_beacon_cntdwn_is_complete(struct ieee80211_vif *vif)
2089 {
2090 	TODO();
2091 	return (true);
2092 }
2093 
2094 static __inline void
2095 ieee80211_disconnect(struct ieee80211_vif *vif, bool _x)
2096 {
2097 	TODO();
2098 }
2099 
2100 static __inline void
2101 ieee80211_channel_switch_disconnect(struct ieee80211_vif *vif, bool _x)
2102 {
2103 	TODO();
2104 }
2105 
2106 static __inline const struct ieee80211_sta_he_cap *
2107 ieee80211_get_he_iftype_cap(const struct ieee80211_supported_band *band,
2108     enum nl80211_iftype type)
2109 {
2110 	TODO();
2111         return (NULL);
2112 }
2113 
2114 static __inline void
2115 ieee80211_key_mic_failure(struct ieee80211_key_conf *key)
2116 {
2117 	TODO();
2118 }
2119 
2120 static __inline void
2121 ieee80211_key_replay(struct ieee80211_key_conf *key)
2122 {
2123 	TODO();
2124 }
2125 
2126 #endif	/* _LINUXKPI_NET_MAC80211_H */
2127