]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/compat/linuxkpi/common/include/net/mac80211.h
LinuxKPI: 802.11: bring in some HT code
[FreeBSD/FreeBSD.git] / sys / compat / linuxkpi / common / include / net / mac80211.h
1 /*-
2  * Copyright (c) 2020-2023 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
30 #ifndef _LINUXKPI_NET_MAC80211_H
31 #define _LINUXKPI_NET_MAC80211_H
32
33 #include <sys/types.h>
34
35 #include <asm/atomic64.h>
36 #include <linux/bitops.h>
37 #include <linux/etherdevice.h>
38 #include <linux/ethtool.h>
39 #include <linux/netdevice.h>
40 #include <linux/skbuff.h>
41 #include <linux/workqueue.h>
42 #include <linux/dcache.h>
43 #include <net/cfg80211.h>
44
45 #define ARPHRD_IEEE80211_RADIOTAP               __LINE__ /* XXX TODO brcmfmac */
46
47 #define WLAN_OUI_MICROSOFT                      (0x0050F2)
48 #define WLAN_OUI_TYPE_MICROSOFT_WPA             (1)
49 #define WLAN_OUI_TYPE_MICROSOFT_TPC             (8)
50 #define WLAN_OUI_TYPE_WFA_P2P                   (9)
51 #define WLAN_OUI_WFA                            (0x506F9A)
52
53 #define IEEE80211_LINK_UNSPECIFIED              0x0f
54
55 /* hw->conf.flags */
56 enum ieee80211_hw_conf_flags {
57         IEEE80211_CONF_IDLE                     = BIT(0),
58         IEEE80211_CONF_PS                       = BIT(1),
59         IEEE80211_CONF_MONITOR                  = BIT(2),
60         IEEE80211_CONF_OFFCHANNEL               = BIT(3),
61 };
62
63 /* (*ops->config()) */
64 enum ieee80211_hw_conf_changed_flags {
65         IEEE80211_CONF_CHANGE_CHANNEL           = BIT(0),
66         IEEE80211_CONF_CHANGE_IDLE              = BIT(1),
67         IEEE80211_CONF_CHANGE_PS                = BIT(2),
68         IEEE80211_CONF_CHANGE_MONITOR           = BIT(3),
69         IEEE80211_CONF_CHANGE_POWER             = BIT(4),
70 };
71
72 #define CFG80211_TESTMODE_CMD(_x)       /* XXX TODO */
73 #define CFG80211_TESTMODE_DUMP(_x)      /* XXX TODO */
74
75 #define FCS_LEN                         4
76
77 /* ops.configure_filter() */
78 enum mcast_filter_flags {
79         FIF_ALLMULTI                    = BIT(0),
80         FIF_PROBE_REQ                   = BIT(1),
81         FIF_BCN_PRBRESP_PROMISC         = BIT(2),
82         FIF_FCSFAIL                     = BIT(3),
83         FIF_OTHER_BSS                   = BIT(4),
84         FIF_PSPOLL                      = BIT(5),
85         FIF_CONTROL                     = BIT(6),
86 };
87
88 enum ieee80211_bss_changed {
89         BSS_CHANGED_ARP_FILTER          = BIT(0),
90         BSS_CHANGED_ASSOC               = BIT(1),
91         BSS_CHANGED_BANDWIDTH           = BIT(2),
92         BSS_CHANGED_BEACON              = BIT(3),
93         BSS_CHANGED_BEACON_ENABLED      = BIT(4),
94         BSS_CHANGED_BEACON_INFO         = BIT(5),
95         BSS_CHANGED_BEACON_INT          = BIT(6),
96         BSS_CHANGED_BSSID               = BIT(7),
97         BSS_CHANGED_CQM                 = BIT(8),
98         BSS_CHANGED_ERP_CTS_PROT        = BIT(9),
99         BSS_CHANGED_ERP_SLOT            = BIT(10),
100         BSS_CHANGED_FTM_RESPONDER       = BIT(11),
101         BSS_CHANGED_HT                  = BIT(12),
102         BSS_CHANGED_IDLE                = BIT(13),
103         BSS_CHANGED_MU_GROUPS           = BIT(14),
104         BSS_CHANGED_P2P_PS              = BIT(15),
105         BSS_CHANGED_PS                  = BIT(16),
106         BSS_CHANGED_QOS                 = BIT(17),
107         BSS_CHANGED_TXPOWER             = BIT(18),
108         BSS_CHANGED_HE_BSS_COLOR        = BIT(19),
109         BSS_CHANGED_AP_PROBE_RESP       = BIT(20),
110         BSS_CHANGED_BASIC_RATES         = BIT(21),
111         BSS_CHANGED_ERP_PREAMBLE        = BIT(22),
112         BSS_CHANGED_IBSS                = BIT(23),
113         BSS_CHANGED_MCAST_RATE          = BIT(24),
114         BSS_CHANGED_SSID                = BIT(25),
115         BSS_CHANGED_FILS_DISCOVERY      = BIT(26),
116         BSS_CHANGED_HE_OBSS_PD          = BIT(27),
117         BSS_CHANGED_TWT                 = BIT(28),
118         BSS_CHANGED_UNSOL_BCAST_PROBE_RESP = BIT(30),
119         BSS_CHANGED_EHT_PUNCTURING      = BIT(31),
120 };
121
122 /* 802.11 Figure 9-256 Suite selector format. [OUI(3), SUITE TYPE(1)] */
123 #define WLAN_CIPHER_SUITE_OUI(_oui, _x) (((_oui) << 8) | ((_x) & 0xff))
124
125 /* 802.11 Table 9-131 Cipher suite selectors. */
126 /* 802.1x suite B                       11 */
127 #define WLAN_CIPHER_SUITE(_x)           WLAN_CIPHER_SUITE_OUI(0x000fac, _x)
128 /* Use group                            0 */
129 #define WLAN_CIPHER_SUITE_WEP40         WLAN_CIPHER_SUITE(1)
130 #define WLAN_CIPHER_SUITE_TKIP          WLAN_CIPHER_SUITE(2)
131 /* Reserved                             3 */
132 #define WLAN_CIPHER_SUITE_CCMP          WLAN_CIPHER_SUITE(4)    /* CCMP-128 */
133 #define WLAN_CIPHER_SUITE_WEP104        WLAN_CIPHER_SUITE(5)
134 #define WLAN_CIPHER_SUITE_AES_CMAC      WLAN_CIPHER_SUITE(6)    /* BIP-CMAC-128 */
135 /* Group addressed traffic not allowed  7 */
136 #define WLAN_CIPHER_SUITE_GCMP          WLAN_CIPHER_SUITE(8)
137 #define WLAN_CIPHER_SUITE_GCMP_256      WLAN_CIPHER_SUITE(9)
138 #define WLAN_CIPHER_SUITE_CCMP_256      WLAN_CIPHER_SUITE(10)
139 #define WLAN_CIPHER_SUITE_BIP_GMAC_128  WLAN_CIPHER_SUITE(11)
140 #define WLAN_CIPHER_SUITE_BIP_GMAC_256  WLAN_CIPHER_SUITE(12)
141 #define WLAN_CIPHER_SUITE_BIP_CMAC_256  WLAN_CIPHER_SUITE(13)
142 /* Reserved                             14-255 */
143
144 /* See ISO/IEC JTC 1 N 9880 Table 11 */
145 #define WLAN_CIPHER_SUITE_SMS4          WLAN_CIPHER_SUITE_OUI(0x001472, 1)
146
147
148 /* 802.11 Table 9-133 AKM suite selectors. */
149 #define WLAN_AKM_SUITE(_x)              WLAN_CIPHER_SUITE_OUI(0x000fac, _x)
150 /* Reserved                             0 */
151 #define WLAN_AKM_SUITE_8021X            WLAN_AKM_SUITE(1)
152 #define WLAN_AKM_SUITE_PSK              WLAN_AKM_SUITE(2)
153 #define WLAN_AKM_SUITE_FT_8021X         WLAN_AKM_SUITE(3)
154 #define WLAN_AKM_SUITE_FT_PSK           WLAN_AKM_SUITE(4)
155 #define WLAN_AKM_SUITE_8021X_SHA256     WLAN_AKM_SUITE(5)
156 #define WLAN_AKM_SUITE_PSK_SHA256       WLAN_AKM_SUITE(6)
157 /* TDLS                                 7 */
158 #define WLAN_AKM_SUITE_SAE              WLAN_AKM_SUITE(8)
159 /* FToSAE                               9 */
160 /* AP peer key                          10 */
161 /* 802.1x suite B                       11 */
162 /* 802.1x suite B 384                   12 */
163 /* FTo802.1x 384                        13 */
164 /* Reserved                             14-255 */
165 /* Apparently 11ax defines more. Seen (19,20) mentioned. */
166
167 #define TKIP_PN_TO_IV16(_x)             ((uint16_t)(_x & 0xffff))
168 #define TKIP_PN_TO_IV32(_x)             ((uint32_t)((_x >> 16) & 0xffffffff))
169
170 struct ieee80211_sta;
171
172 /* 802.11-2020 9.4.2.55.3 A-MPDU Parameters field */
173 #define IEEE80211_HT_AMPDU_PARM_FACTOR          0x3
174 #define IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT   2
175 #define IEEE80211_HT_AMPDU_PARM_DENSITY         (0x7 << IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT)
176
177 struct ieee80211_ampdu_params {
178         struct ieee80211_sta                    *sta;
179         enum ieee80211_ampdu_mlme_action        action;
180         uint16_t                                buf_size;
181         uint16_t                                timeout;
182         uint16_t                                ssn;
183         uint8_t                                 tid;
184         bool                                    amsdu;
185 };
186
187 struct ieee80211_bar {
188         /* TODO FIXME */
189         int             control, start_seq_num;
190         uint8_t         *ra;
191         uint16_t        frame_control;
192 };
193
194 struct ieee80211_p2p_noa_desc {
195         uint32_t                                count;          /* uint8_t ? */
196         uint32_t                                duration;
197         uint32_t                                interval;
198         uint32_t                                start_time;
199 };
200
201 struct ieee80211_p2p_noa_attr {
202         uint8_t                                 index;
203         uint8_t                                 oppps_ctwindow;
204         struct ieee80211_p2p_noa_desc           desc[4];
205 };
206
207 struct ieee80211_mutable_offsets {
208         /* TODO FIXME */
209         uint16_t                                tim_offset;
210         uint16_t                                cntdwn_counter_offs[2];
211
212         int     mbssid_off;
213 };
214
215 struct mac80211_fils_discovery {
216         uint32_t                                max_interval;
217 };
218
219 struct ieee80211_chanctx_conf {
220         /* TODO FIXME */
221         int             rx_chains_dynamic, rx_chains_static;
222         bool                                    radar_enabled;
223         struct cfg80211_chan_def                def;
224         struct cfg80211_chan_def                min_def;
225
226         /* Must stay last. */
227         uint8_t                                 drv_priv[0] __aligned(CACHE_LINE_SIZE);
228 };
229
230 struct ieee80211_rate_status {
231         struct rate_info                        rate_idx;
232         uint8_t                                 try_count;
233 };
234
235 struct ieee80211_ema_beacons {
236         uint8_t                                 cnt;
237         struct {
238                 struct sk_buff                  *skb;
239                 struct ieee80211_mutable_offsets offs;
240         } bcn[0];
241 };
242
243 #define WLAN_MEMBERSHIP_LEN                     (8)
244 #define WLAN_USER_POSITION_LEN                  (16)
245
246 struct ieee80211_bss_conf {
247         /* TODO FIXME */
248         struct ieee80211_vif                    *vif;
249         const uint8_t                           *bssid;
250         uint8_t                                 addr[ETH_ALEN];
251         uint8_t                                 link_id;
252         uint8_t                                 _pad0;
253         uint8_t                                 transmitter_bssid[ETH_ALEN];
254         struct ieee80211_ftm_responder_params   *ftmr_params;
255         struct ieee80211_p2p_noa_attr           p2p_noa_attr;
256         struct cfg80211_chan_def                chandef;
257         __be32                                  arp_addr_list[1];       /* XXX TODO */
258         struct ieee80211_rate                   *beacon_rate;
259         struct {
260                 uint8_t membership[WLAN_MEMBERSHIP_LEN];
261                 uint8_t position[WLAN_USER_POSITION_LEN];
262         }  mu_group;
263         struct {
264                 uint32_t                        params;
265                 /* single field struct? */
266         } he_oper;
267         struct cfg80211_he_bss_color            he_bss_color;
268         struct ieee80211_he_obss_pd             he_obss_pd;
269
270         bool                                    ht_ldpc;
271         bool                                    vht_ldpc;
272         bool                                    he_ldpc;
273         bool                                    vht_mu_beamformee;
274         bool                                    vht_mu_beamformer;
275         bool                                    vht_su_beamformee;
276         bool                                    vht_su_beamformer;
277         bool                                    he_mu_beamformer;
278         bool                                    he_su_beamformee;
279         bool                                    he_su_beamformer;
280         bool                                    he_full_ul_mumimo;
281         bool                                    eht_su_beamformee;
282         bool                                    eht_su_beamformer;
283         bool                                    eht_mu_beamformer;
284
285         uint16_t                                ht_operation_mode;
286         int                                     arp_addr_cnt;
287         uint16_t                                eht_puncturing;
288
289         uint8_t                                 dtim_period;
290         uint8_t                                 sync_dtim_count;
291         bool                                    qos;
292         bool                                    twt_broadcast;
293         bool                                    use_cts_prot;
294         bool                                    use_short_preamble;
295         bool                                    use_short_slot;
296         bool                                    he_support;
297         bool                                    eht_support;
298         bool                                    csa_active;
299         bool                                    mu_mimo_owner;
300         uint32_t                                sync_device_ts;
301         uint64_t                                sync_tsf;
302         uint16_t                                beacon_int;
303         int16_t                                 txpower;
304         uint32_t                                basic_rates;
305         int                                     mcast_rate[NUM_NL80211_BANDS];
306         enum ieee80211_reg_ap_power             power_type;
307         struct cfg80211_bitrate_mask            beacon_tx_rate;
308         struct mac80211_fils_discovery          fils_discovery;
309         struct ieee80211_chanctx_conf           *chanctx_conf;
310         struct ieee80211_vif                    *mbssid_tx_vif;
311
312         int             ack_enabled, bssid_index, bssid_indicator, cqm_rssi_hyst, cqm_rssi_thold, ema_ap, frame_time_rts_th, ftm_responder;
313         int             htc_trig_based_pkt_ext;
314         int             multi_sta_back_32bit, nontransmitted;
315         int             profile_periodicity;
316         int             twt_requester, uora_exists, uora_ocw_range;
317         int             assoc_capability, enable_beacon, hidden_ssid, ibss_joined, twt_protected;
318         int             twt_responder, unsol_bcast_probe_resp_interval;
319         int             color_change_active;
320 };
321
322 struct ieee80211_channel_switch {
323         /* TODO FIXME */
324         int             block_tx, count, delay, device_timestamp, timestamp;
325         struct cfg80211_chan_def                chandef;
326 };
327
328 struct ieee80211_cipher_scheme {
329         uint32_t        cipher;
330         uint8_t         iftype;         /* We do not know the size of this. */
331         uint8_t         hdr_len;
332         uint8_t         pn_len;
333         uint8_t         pn_off;
334         uint8_t         key_idx_off;
335         uint8_t         key_idx_mask;
336         uint8_t         key_idx_shift;
337         uint8_t         mic_len;
338 };
339
340 enum ieee80211_event_type {
341         BA_FRAME_TIMEOUT,
342         BAR_RX_EVENT,
343         MLME_EVENT,
344         RSSI_EVENT,
345 };
346
347 enum ieee80211_rssi_event_data {
348         RSSI_EVENT_LOW,
349         RSSI_EVENT_HIGH,
350 };
351
352 enum ieee80211_mlme_event_data {
353         ASSOC_EVENT,
354         AUTH_EVENT,
355         DEAUTH_RX_EVENT,
356         DEAUTH_TX_EVENT,
357 };
358
359 enum ieee80211_mlme_event_status {
360         MLME_DENIED,
361         MLME_TIMEOUT,
362 };
363
364 struct ieee80211_mlme_event {
365         enum ieee80211_mlme_event_data          data;
366         enum ieee80211_mlme_event_status        status;
367         int                                     reason;
368 };
369
370 struct ieee80211_event {
371         /* TODO FIXME */
372         enum ieee80211_event_type               type;
373         union {
374                 struct {
375                         int     ssn;
376                         struct ieee80211_sta    *sta;
377                         uint8_t                 tid;
378                 } ba;
379                 struct ieee80211_mlme_event     mlme;
380         } u;
381 };
382
383 struct ieee80211_ftm_responder_params {
384         /* TODO FIXME */
385         uint8_t                                 *lci;
386         uint8_t                                 *civicloc;
387         int                                     lci_len;
388         int                                     civicloc_len;
389 };
390
391 struct ieee80211_he_mu_edca_param_ac_rec {
392         /* TODO FIXME */
393         int             aifsn, ecw_min_max, mu_edca_timer;
394 };
395
396 struct ieee80211_conf {
397         int                                     dynamic_ps_timeout;
398         int                                     power_level;
399         uint32_t                                listen_interval;
400         bool                                    radar_enabled;
401         enum ieee80211_hw_conf_flags            flags;
402         struct cfg80211_chan_def                chandef;
403 };
404
405 enum ieee80211_hw_flags {
406         IEEE80211_HW_AMPDU_AGGREGATION,
407         IEEE80211_HW_AP_LINK_PS,
408         IEEE80211_HW_BUFF_MMPDU_TXQ,
409         IEEE80211_HW_CHANCTX_STA_CSA,
410         IEEE80211_HW_CONNECTION_MONITOR,
411         IEEE80211_HW_DEAUTH_NEED_MGD_TX_PREP,
412         IEEE80211_HW_HAS_RATE_CONTROL,
413         IEEE80211_HW_MFP_CAPABLE,
414         IEEE80211_HW_NEEDS_UNIQUE_STA_ADDR,
415         IEEE80211_HW_REPORTS_TX_ACK_STATUS,
416         IEEE80211_HW_RX_INCLUDES_FCS,
417         IEEE80211_HW_SIGNAL_DBM,
418         IEEE80211_HW_SINGLE_SCAN_ON_ALL_BANDS,
419         IEEE80211_HW_SPECTRUM_MGMT,
420         IEEE80211_HW_STA_MMPDU_TXQ,
421         IEEE80211_HW_SUPPORTS_AMSDU_IN_AMPDU,
422         IEEE80211_HW_SUPPORTS_CLONED_SKBS,
423         IEEE80211_HW_SUPPORTS_DYNAMIC_PS,
424         IEEE80211_HW_SUPPORTS_MULTI_BSSID,
425         IEEE80211_HW_SUPPORTS_ONLY_HE_MULTI_BSSID,
426         IEEE80211_HW_SUPPORTS_PS,
427         IEEE80211_HW_SUPPORTS_REORDERING_BUFFER,
428         IEEE80211_HW_SUPPORTS_VHT_EXT_NSS_BW,
429         IEEE80211_HW_SUPPORT_FAST_XMIT,
430         IEEE80211_HW_TDLS_WIDER_BW,
431         IEEE80211_HW_TIMING_BEACON_ONLY,
432         IEEE80211_HW_TX_AMPDU_SETUP_IN_HW,
433         IEEE80211_HW_TX_AMSDU,
434         IEEE80211_HW_TX_FRAG_LIST,
435         IEEE80211_HW_USES_RSS,
436         IEEE80211_HW_WANT_MONITOR_VIF,
437         IEEE80211_HW_SW_CRYPTO_CONTROL,
438         IEEE80211_HW_SUPPORTS_TX_FRAG,
439         IEEE80211_HW_SUPPORTS_TDLS_BUFFER_STA,
440         IEEE80211_HW_SUPPORTS_PER_STA_GTK,
441         IEEE80211_HW_REPORTS_LOW_ACK,
442         IEEE80211_HW_QUEUE_CONTROL,
443         IEEE80211_HW_SUPPORTS_RX_DECAP_OFFLOAD,
444         IEEE80211_HW_SUPPORTS_TX_ENCAP_OFFLOAD,
445         IEEE80211_HW_SUPPORTS_RC_TABLE,
446         IEEE80211_HW_DETECTS_COLOR_COLLISION,
447
448         /* Keep last. */
449         NUM_IEEE80211_HW_FLAGS
450 };
451
452 struct ieee80211_hw {
453
454         struct wiphy                    *wiphy;
455
456         /* TODO FIXME */
457         int             extra_tx_headroom, weight_multiplier;
458         int             max_rate_tries, max_rates, max_report_rates;
459         struct ieee80211_cipher_scheme  *cipher_schemes;
460         int                             n_cipher_schemes;
461         const char                      *rate_control_algorithm;
462         struct {
463                 uint16_t units_pos;     /* radiotap "spec" is .. inconsistent. */
464                 uint16_t accuracy;
465         } radiotap_timestamp;
466         size_t                          sta_data_size;
467         size_t                          vif_data_size;
468         size_t                          chanctx_data_size;
469         size_t                          txq_data_size;
470         uint16_t                        radiotap_mcs_details;
471         uint16_t                        radiotap_vht_details;
472         uint16_t                        queues;
473         uint16_t                        offchannel_tx_hw_queue;
474         uint16_t                        uapsd_max_sp_len;
475         uint16_t                        uapsd_queues;
476         uint16_t                        max_rx_aggregation_subframes;
477         uint16_t                        max_tx_aggregation_subframes;
478         uint16_t                        max_tx_fragments;
479         uint16_t                        max_listen_interval;
480         uint32_t                        extra_beacon_tailroom;
481         netdev_features_t               netdev_features;
482         unsigned long                   flags[BITS_TO_LONGS(NUM_IEEE80211_HW_FLAGS)];
483         struct ieee80211_conf           conf;
484
485 #if 0   /* leave here for documentation purposes.  This does NOT work. */
486         /* Must stay last. */
487         uint8_t                         priv[0] __aligned(CACHE_LINE_SIZE);
488 #else
489         void                            *priv;
490 #endif
491 };
492
493 enum ieee802111_key_flag {
494         IEEE80211_KEY_FLAG_GENERATE_IV          = BIT(0),
495         IEEE80211_KEY_FLAG_GENERATE_MMIC        = BIT(1),
496         IEEE80211_KEY_FLAG_PAIRWISE             = BIT(2),
497         IEEE80211_KEY_FLAG_PUT_IV_SPACE         = BIT(3),
498         IEEE80211_KEY_FLAG_PUT_MIC_SPACE        = BIT(4),
499         IEEE80211_KEY_FLAG_SW_MGMT_TX           = BIT(5),
500         IEEE80211_KEY_FLAG_GENERATE_IV_MGMT     = BIT(6),
501         IEEE80211_KEY_FLAG_GENERATE_MMIE        = BIT(7),
502         IEEE80211_KEY_FLAG_RESERVE_TAILROOM     = BIT(8),
503 };
504
505 struct ieee80211_key_conf {
506         atomic64_t                      tx_pn;
507         uint32_t                        cipher;
508         uint8_t                         icv_len;        /* __unused nowadays? */
509         uint8_t                         iv_len;
510         uint8_t                         hw_key_idx;     /* Set by drv. */
511         uint8_t                         keyidx;
512         uint16_t                        flags;
513         uint8_t                         keylen;
514         uint8_t                         key[0];
515         int8_t                          link_id;        /* signed! */
516 };
517
518 struct ieee80211_key_seq {
519         /* TODO FIXME */
520         union {
521                 struct {
522                         uint8_t         seq[IEEE80211_MAX_PN_LEN];
523                         uint8_t         seq_len;
524                 } hw;
525                 struct {
526                         uint8_t         pn[IEEE80211_CCMP_PN_LEN];
527                 } ccmp;
528                 struct {
529                         uint8_t         pn[IEEE80211_CCMP_PN_LEN];
530                 } aes_cmac;
531                 struct {
532                         uint32_t        iv32;
533                         uint16_t        iv16;
534                 } tkip;
535         };
536 };
537
538
539 enum ieee80211_rx_status_flags {
540         RX_FLAG_ALLOW_SAME_PN           = BIT(0),
541         RX_FLAG_AMPDU_DETAILS           = BIT(1),
542         RX_FLAG_AMPDU_EOF_BIT           = BIT(2),
543         RX_FLAG_AMPDU_EOF_BIT_KNOWN     = BIT(3),
544         RX_FLAG_DECRYPTED               = BIT(4),
545         RX_FLAG_DUP_VALIDATED           = BIT(5),
546         RX_FLAG_FAILED_FCS_CRC          = BIT(6),
547         RX_FLAG_ICV_STRIPPED            = BIT(7),
548         RX_FLAG_MACTIME_PLCP_START      = BIT(8),
549         RX_FLAG_MACTIME_START           = BIT(9),
550         RX_FLAG_MIC_STRIPPED            = BIT(10),
551         RX_FLAG_MMIC_ERROR              = BIT(11),
552         RX_FLAG_MMIC_STRIPPED           = BIT(12),
553         RX_FLAG_NO_PSDU                 = BIT(13),
554         RX_FLAG_PN_VALIDATED            = BIT(14),
555         RX_FLAG_RADIOTAP_HE             = BIT(15),
556         RX_FLAG_RADIOTAP_HE_MU          = BIT(16),
557         RX_FLAG_RADIOTAP_LSIG           = BIT(17),
558         RX_FLAG_RADIOTAP_VENDOR_DATA    = BIT(18),
559         RX_FLAG_NO_SIGNAL_VAL           = BIT(19),
560         RX_FLAG_IV_STRIPPED             = BIT(20),
561         RX_FLAG_AMPDU_IS_LAST           = BIT(21),
562         RX_FLAG_AMPDU_LAST_KNOWN        = BIT(22),
563         RX_FLAG_AMSDU_MORE              = BIT(23),
564         RX_FLAG_MACTIME_END             = BIT(24),
565         RX_FLAG_ONLY_MONITOR            = BIT(25),
566         RX_FLAG_SKIP_MONITOR            = BIT(26),
567         RX_FLAG_8023                    = BIT(27),
568         RX_FLAG_RADIOTAP_TLV_AT_END     = BIT(28),
569 };
570
571 enum mac80211_rx_encoding {
572         RX_ENC_LEGACY           = 0,
573         RX_ENC_HT,
574         RX_ENC_VHT,
575         RX_ENC_HE,
576         RX_ENC_EHT,
577 };
578
579 struct ieee80211_rx_status {
580         /* TODO FIXME, this is too large. Over-reduce types to u8 where possible. */
581         union {
582                 uint64_t                        boottime_ns;
583                 int64_t                         ack_tx_hwtstamp;
584         };
585         uint64_t                        mactime;
586         uint32_t                        device_timestamp;
587         enum ieee80211_rx_status_flags  flag;
588         uint16_t                        freq;
589         uint8_t                         encoding:3, bw:4;       /* enum mac80211_rx_encoding, rate_info_bw */   /* See mt76.h */
590         uint8_t                         ampdu_reference;
591         uint8_t                         band;
592         uint8_t                         chains;
593         int8_t                          chain_signal[IEEE80211_MAX_CHAINS];
594         int8_t                          signal;
595         uint8_t                         enc_flags;
596         union {
597                 struct {
598                         uint8_t         he_ru:3;        /* nl80211::enum nl80211_he_ru_alloc */
599                         uint8_t         he_gi:2;        /* nl80211::enum nl80211_he_gi */
600                         uint8_t         he_dcm:1;
601                 };
602                 struct {
603                         uint8_t         ru:4;           /* nl80211::enum nl80211_eht_ru_alloc */
604                         uint8_t         gi:2;           /* nl80211::enum nl80211_eht_gi */
605                 } eht;
606         };
607         bool                            link_valid;
608         uint8_t                         link_id;        /* very incosistent sizes? */
609         uint8_t                         zero_length_psdu_type;
610         uint8_t                         nss;
611         uint8_t                         rate_idx;
612 };
613
614 struct ieee80211_tx_status {
615         struct ieee80211_sta            *sta;
616         struct ieee80211_tx_info        *info;
617         int64_t                         ack_hwtstamp;
618
619         u8                              n_rates;
620         struct ieee80211_rate_status    *rates;
621
622         struct sk_buff                  *skb;
623         struct list_head                *free_list;
624 };
625
626 struct ieee80211_scan_ies {
627         /* TODO FIXME */
628         int             common_ie_len;
629         int             len[NUM_NL80211_BANDS];
630         uint8_t         *common_ies;
631         uint8_t         *ies[NUM_NL80211_BANDS];
632 };
633
634 struct ieee80211_scan_request {
635         struct ieee80211_scan_ies       ies;
636         struct cfg80211_scan_request    req;
637 };
638
639 struct ieee80211_txq {
640         struct ieee80211_sta            *sta;
641         struct ieee80211_vif            *vif;
642         int                             ac;
643         uint8_t                         tid;
644
645         /* Must stay last. */
646         uint8_t                         drv_priv[0] __aligned(CACHE_LINE_SIZE);
647 };
648
649 struct ieee80211_sta_rates {
650         /* XXX TODO */
651         /* XXX some _rcu thing */
652         struct {
653                 int     idx;
654                 int     flags;
655         } rate[1];              /* XXX what is the real number? */
656 };
657
658 struct ieee80211_sta_txpwr {
659         /* XXX TODO */
660         enum nl80211_tx_power_setting   type;
661         short                           power;
662 };
663
664 #define IEEE80211_NUM_TIDS                      16      /* net80211::WME_NUM_TID */
665 struct ieee80211_sta_agg {
666         uint16_t                                max_amsdu_len;
667         uint16_t                                max_rc_amsdu_len;
668         uint16_t                                max_tid_amsdu_len[IEEE80211_NUM_TIDS];
669 };
670
671 struct ieee80211_link_sta {
672         uint8_t                                 addr[ETH_ALEN];
673         uint8_t                                 link_id;
674         uint32_t                                supp_rates[NUM_NL80211_BANDS];
675         struct ieee80211_sta_ht_cap             ht_cap;
676         struct ieee80211_sta_vht_cap            vht_cap;
677         struct ieee80211_sta_he_cap             he_cap;
678         struct ieee80211_sta_he_6ghz_capa       he_6ghz_capa;
679         struct ieee80211_sta_eht_cap            eht_cap;
680         uint8_t                                 rx_nss;
681         enum ieee80211_sta_rx_bw                bandwidth;
682         enum ieee80211_smps_mode                smps_mode;
683         struct ieee80211_sta_agg                agg;
684         struct ieee80211_sta_txpwr              txpwr;
685 };
686
687 struct ieee80211_sta {
688         /* TODO FIXME */
689         int             max_amsdu_subframes;
690         int             mfp, smps_mode, tdls, tdls_initiator;
691         struct ieee80211_txq                    *txq[IEEE80211_NUM_TIDS + 1];   /* iwlwifi: 8 and adds +1 to tid_data, net80211::IEEE80211_TID_SIZE */
692         struct ieee80211_sta_rates              *rates; /* some rcu thing? */
693         uint8_t                                 addr[ETH_ALEN];
694         uint16_t                                aid;
695         bool                                    wme;
696         uint8_t                                 max_sp;
697         uint8_t                                 uapsd_queues;
698         uint16_t                                valid_links;
699
700         struct ieee80211_link_sta               deflink;
701         struct ieee80211_link_sta               *link[IEEE80211_MLD_MAX_NUM_LINKS];     /* rcu? */
702
703         /* Must stay last. */
704         uint8_t                                 drv_priv[0] __aligned(CACHE_LINE_SIZE);
705 };
706
707 struct ieee80211_tdls_ch_sw_params {
708         /* TODO FIXME */
709         int             action_code, ch_sw_tm_ie, status, switch_time, switch_timeout, timestamp;
710         struct ieee80211_sta                    *sta;
711         struct cfg80211_chan_def                *chandef;
712         struct sk_buff                          *tmpl_skb;
713 };
714
715 struct ieee80211_tx_control {
716         /* TODO FIXME */
717         struct ieee80211_sta                    *sta;
718 };
719
720 struct ieee80211_tx_queue_params {
721         /* These types are based on iwlwifi FW structs. */
722         uint16_t        cw_min;
723         uint16_t        cw_max;
724         uint16_t        txop;
725         uint8_t         aifs;
726
727         /* TODO FIXME */
728         int             acm, mu_edca, uapsd;
729         struct ieee80211_he_mu_edca_param_ac_rec        mu_edca_param_rec;
730 };
731
732 struct ieee80211_tx_rate {
733         uint8_t         idx;
734         uint16_t        count:5,
735                         flags:11;
736 };
737
738 enum ieee80211_vif_driver_flags {
739         IEEE80211_VIF_BEACON_FILTER             = BIT(0),
740         IEEE80211_VIF_SUPPORTS_CQM_RSSI         = BIT(1),
741         IEEE80211_VIF_SUPPORTS_UAPSD            = BIT(2),
742         IEEE80211_VIF_DISABLE_SMPS_OVERRIDE     = BIT(3),
743 };
744
745 #define IEEE80211_BSS_ARP_ADDR_LIST_LEN         4
746
747 struct ieee80211_vif_cfg {
748         uint16_t                                aid;
749         uint16_t                                eml_cap;
750         uint16_t                                eml_med_sync_delay;
751         bool                                    assoc;
752         bool                                    ps;
753         bool                                    idle;
754         bool                                    ibss_joined;
755         int                                     arp_addr_cnt;
756         size_t                                  ssid_len;
757         uint32_t                                arp_addr_list[IEEE80211_BSS_ARP_ADDR_LIST_LEN];         /* big endian */
758         uint8_t                                 ssid[IEEE80211_NWID_LEN];
759         uint8_t                                 ap_addr[ETH_ALEN];
760 };
761
762 struct ieee80211_vif {
763         /* TODO FIXME */
764         enum nl80211_iftype             type;
765         int             csa_active, mu_mimo_owner;
766         int             cab_queue;
767         int     color_change_active, offload_flags;
768         enum ieee80211_vif_driver_flags driver_flags;
769         bool                            p2p;
770         bool                            probe_req_reg;
771         uint8_t                         addr[ETH_ALEN];
772         struct ieee80211_vif_cfg        cfg;
773         struct ieee80211_chanctx_conf   *chanctx_conf;
774         struct ieee80211_txq            *txq;
775         struct ieee80211_bss_conf       bss_conf;
776         struct ieee80211_bss_conf       *link_conf[IEEE80211_MLD_MAX_NUM_LINKS];        /* rcu? */
777         uint8_t                         hw_queue[IEEE80211_NUM_ACS];
778         uint16_t                        active_links;
779         uint16_t                        valid_links;
780         struct ieee80211_vif            *mbssid_tx_vif;
781
782 /* #ifdef CONFIG_MAC80211_DEBUGFS */    /* Do not change structure depending on compile-time option. */
783         struct dentry                   *debugfs_dir;
784 /* #endif */
785
786         /* Must stay last. */
787         uint8_t                         drv_priv[0] __aligned(CACHE_LINE_SIZE);
788 };
789
790 struct ieee80211_vif_chanctx_switch {
791         struct ieee80211_chanctx_conf   *old_ctx, *new_ctx;
792         struct ieee80211_vif            *vif;
793         struct ieee80211_bss_conf       *link_conf;
794 };
795
796 struct ieee80211_prep_tx_info {
797         u16                             duration;
798         bool                            success;
799 };
800
801 /* XXX-BZ too big, over-reduce size to u8, and array sizes to minuimum to fit in skb->cb. */
802 /* Also warning: some sizes change by pointer size!  This is 64bit only. */
803 struct ieee80211_tx_info {
804         enum ieee80211_tx_info_flags            flags;
805         /* TODO FIXME */
806         u8              band;
807         u8              hw_queue;
808         bool            tx_time_est;
809         union {
810                 struct {
811                         struct ieee80211_tx_rate        rates[4];
812                         bool                            use_rts;
813                         struct ieee80211_vif            *vif;
814                         struct ieee80211_key_conf       *hw_key;
815                         enum ieee80211_tx_control_flags flags;
816                 } control;
817                 struct {
818                         struct ieee80211_tx_rate        rates[4];
819                         uint32_t                        ack_signal;
820                         uint8_t                         ampdu_ack_len;
821                         uint8_t                         ampdu_len;
822                         uint8_t                         antenna;
823                         uint16_t                        tx_time;
824                         uint8_t                         flags;
825                         void                            *status_driver_data[16 / sizeof(void *)];               /* XXX TODO */
826                 } status;
827 #define IEEE80211_TX_INFO_DRIVER_DATA_SIZE      40
828                 void                                    *driver_data[IEEE80211_TX_INFO_DRIVER_DATA_SIZE / sizeof(void *)];
829         };
830 };
831
832 /* net80211 conflict */
833 struct linuxkpi_ieee80211_tim_ie {
834         uint8_t                         dtim_count;
835         uint8_t                         dtim_period;
836         uint8_t                         bitmap_ctrl;
837         uint8_t                         *virtual_map;
838 };
839 #define ieee80211_tim_ie        linuxkpi_ieee80211_tim_ie
840
841 struct survey_info {            /* net80211::struct ieee80211_channel_survey */
842         /* TODO FIXME */
843         uint32_t                        filled;
844 #define SURVEY_INFO_TIME                0x0001
845 #define SURVEY_INFO_TIME_RX             0x0002
846 #define SURVEY_INFO_TIME_SCAN           0x0004
847 #define SURVEY_INFO_TIME_TX             0x0008
848 #define SURVEY_INFO_TIME_BSS_RX         0x0010
849 #define SURVEY_INFO_TIME_BUSY           0x0020
850 #define SURVEY_INFO_IN_USE              0x0040
851 #define SURVEY_INFO_NOISE_DBM           0x0080
852         uint32_t                        noise;
853         uint64_t                        time;
854         uint64_t                        time_bss_rx;
855         uint64_t                        time_busy;
856         uint64_t                        time_rx;
857         uint64_t                        time_scan;
858         uint64_t                        time_tx;
859         struct ieee80211_channel        *channel;
860 };
861
862 enum ieee80211_iface_iter {
863         IEEE80211_IFACE_ITER_NORMAL     = BIT(0),
864         IEEE80211_IFACE_ITER_RESUME_ALL = BIT(1),
865         IEEE80211_IFACE_SKIP_SDATA_NOT_IN_DRIVER = BIT(2),      /* seems to be an iter flag */
866         IEEE80211_IFACE_ITER_ACTIVE     = BIT(3),
867
868         /* Internal flags only. */
869         IEEE80211_IFACE_ITER__ATOMIC    = BIT(6),
870         IEEE80211_IFACE_ITER__MTX       = BIT(8),
871 };
872
873 enum set_key_cmd {
874         SET_KEY,
875         DISABLE_KEY,
876 };
877
878 /* 802.11-2020, 9.4.2.55.2 HT Capability Information field. */
879 enum rx_enc_flags {
880         RX_ENC_FLAG_SHORTPRE    =       BIT(0),
881         RX_ENC_FLAG_SHORT_GI    =       BIT(2),
882         RX_ENC_FLAG_HT_GF       =       BIT(3),
883         RX_ENC_FLAG_STBC_MASK   =       BIT(4) | BIT(5),
884 #define RX_ENC_FLAG_STBC_SHIFT          4
885         RX_ENC_FLAG_LDPC        =       BIT(6),
886         RX_ENC_FLAG_BF          =       BIT(7),
887 };
888
889 enum sta_notify_cmd {
890         STA_NOTIFY_AWAKE,
891         STA_NOTIFY_SLEEP,
892 };
893
894 struct ieee80211_low_level_stats {
895         /* Can we make them uint64_t? */
896         uint32_t dot11ACKFailureCount;
897         uint32_t dot11FCSErrorCount;
898         uint32_t dot11RTSFailureCount;
899         uint32_t dot11RTSSuccessCount;
900 };
901
902 enum ieee80211_offload_flags {
903         IEEE80211_OFFLOAD_ENCAP_4ADDR,
904         IEEE80211_OFFLOAD_ENCAP_ENABLED,
905         IEEE80211_OFFLOAD_DECAP_ENABLED,
906 };
907
908 struct ieee80211_ops {
909         /* TODO FIXME */
910         int  (*start)(struct ieee80211_hw *);
911         void (*stop)(struct ieee80211_hw *);
912
913         int  (*config)(struct ieee80211_hw *, u32);
914         void (*reconfig_complete)(struct ieee80211_hw *, enum ieee80211_reconfig_type);
915
916         int  (*add_interface)(struct ieee80211_hw *, struct ieee80211_vif *);
917         void (*remove_interface)(struct ieee80211_hw *, struct ieee80211_vif *);
918         int  (*change_interface)(struct ieee80211_hw *, struct ieee80211_vif *, enum nl80211_iftype, bool);
919
920         void (*sw_scan_start)(struct ieee80211_hw *, struct ieee80211_vif *, const u8 *);
921         void (*sw_scan_complete)(struct ieee80211_hw *, struct ieee80211_vif *);
922         int  (*sched_scan_start)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_sched_scan_request *, struct ieee80211_scan_ies *);
923         int  (*sched_scan_stop)(struct ieee80211_hw *, struct ieee80211_vif *);
924         int  (*hw_scan)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_scan_request *);
925         void (*cancel_hw_scan)(struct ieee80211_hw *, struct ieee80211_vif *);
926
927         int  (*conf_tx)(struct ieee80211_hw *, struct ieee80211_vif *, u32, u16, const struct ieee80211_tx_queue_params *);
928         void (*tx)(struct ieee80211_hw *, struct ieee80211_tx_control *, struct sk_buff *);
929         int  (*tx_last_beacon)(struct ieee80211_hw *);
930         void (*wake_tx_queue)(struct ieee80211_hw *, struct ieee80211_txq *);
931
932         void (*mgd_prepare_tx)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_prep_tx_info *);
933         void (*mgd_complete_tx)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_prep_tx_info *);
934         void (*mgd_protect_tdls_discover)(struct ieee80211_hw *, struct ieee80211_vif *);
935
936         void (*flush)(struct ieee80211_hw *, struct ieee80211_vif *, u32, bool);
937         void (*flush_sta)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *);
938
939         int  (*set_frag_threshold)(struct ieee80211_hw *, u32);
940
941         void (*sync_rx_queues)(struct ieee80211_hw *);
942
943         void (*allow_buffered_frames)(struct ieee80211_hw *, struct ieee80211_sta *, u16, int, enum ieee80211_frame_release_type, bool);
944         void (*release_buffered_frames)(struct ieee80211_hw *, struct ieee80211_sta *, u16, int, enum ieee80211_frame_release_type, bool);
945
946         int  (*sta_add)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *);
947         int  (*sta_remove)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *);
948         int  (*sta_set_txpwr)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *);
949         void (*sta_statistics)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, struct station_info *);
950         void (*sta_pre_rcu_remove)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *);
951         int  (*sta_state)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, enum ieee80211_sta_state, enum ieee80211_sta_state);
952         void (*sta_notify)(struct ieee80211_hw *, struct ieee80211_vif *, enum sta_notify_cmd, struct ieee80211_sta *);
953         void (*sta_rc_update)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, u32);
954         void (*sta_rate_tbl_update)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *);
955         void (*sta_set_4addr)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, bool);
956         void (*sta_set_decap_offload)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, bool);
957
958         u64  (*prepare_multicast)(struct ieee80211_hw *, struct netdev_hw_addr_list *);
959
960         int  (*ampdu_action)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_ampdu_params *);
961
962         bool (*can_aggregate_in_amsdu)(struct ieee80211_hw *, struct sk_buff *, struct sk_buff *);
963
964         int  (*pre_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_channel_switch *);
965         int  (*post_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *);
966         void (*channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_channel_switch *);
967         void (*channel_switch_beacon)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_chan_def *);
968         void (*abort_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *);
969         void (*channel_switch_rx_beacon)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_channel_switch *);
970         int  (*tdls_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, u8, struct cfg80211_chan_def *, struct sk_buff *, u32);
971         void (*tdls_cancel_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *);
972         void (*tdls_recv_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_tdls_ch_sw_params *);
973
974         int  (*add_chanctx)(struct ieee80211_hw *, struct ieee80211_chanctx_conf *);
975         void (*remove_chanctx)(struct ieee80211_hw *, struct ieee80211_chanctx_conf *);
976         void (*change_chanctx)(struct ieee80211_hw *, struct ieee80211_chanctx_conf *, u32);
977         int  (*assign_vif_chanctx)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_bss_conf *, struct ieee80211_chanctx_conf *);
978         void (*unassign_vif_chanctx)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_bss_conf *, struct ieee80211_chanctx_conf *);
979         int  (*switch_vif_chanctx)(struct ieee80211_hw *, struct ieee80211_vif_chanctx_switch *, int, enum ieee80211_chanctx_switch_mode);
980
981         int  (*get_antenna)(struct ieee80211_hw *, u32 *, u32 *);
982         int  (*set_antenna)(struct ieee80211_hw *, u32, u32);
983
984         int  (*remain_on_channel)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_channel *, int, enum ieee80211_roc_type);
985         int  (*cancel_remain_on_channel)(struct ieee80211_hw *, struct ieee80211_vif *);
986
987         void (*configure_filter)(struct ieee80211_hw *, unsigned int, unsigned int *, u64);
988         void (*config_iface_filter)(struct ieee80211_hw *, struct ieee80211_vif *, unsigned int, unsigned int);
989
990         void (*bss_info_changed)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_bss_conf *, u64);
991         void (*link_info_changed)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_bss_conf *, u64);
992
993         int  (*set_rts_threshold)(struct ieee80211_hw *, u32);
994         void (*event_callback)(struct ieee80211_hw *, struct ieee80211_vif *, const struct ieee80211_event *);
995         int  (*get_survey)(struct ieee80211_hw *, int, struct survey_info *);
996         int  (*get_ftm_responder_stats)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_ftm_responder_stats *);
997
998         uint64_t (*get_tsf)(struct ieee80211_hw *, struct ieee80211_vif *);
999         void (*set_tsf)(struct ieee80211_hw *, struct ieee80211_vif *, uint64_t);
1000         void (*offset_tsf)(struct ieee80211_hw *, struct ieee80211_vif *, s64);
1001
1002         int  (*set_bitrate_mask)(struct ieee80211_hw *, struct ieee80211_vif *, const struct cfg80211_bitrate_mask *);
1003         void (*set_coverage_class)(struct ieee80211_hw *, s16);
1004         int  (*set_tim)(struct ieee80211_hw *, struct ieee80211_sta *, bool);
1005
1006         int  (*set_key)(struct ieee80211_hw *, enum set_key_cmd, struct ieee80211_vif *, struct ieee80211_sta *, struct ieee80211_key_conf *);
1007         void (*set_default_unicast_key)(struct ieee80211_hw *, struct ieee80211_vif *, int);
1008         void (*update_tkip_key)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_key_conf *, struct ieee80211_sta *, u32, u16 *);
1009         void (*set_rekey_data)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_gtk_rekey_data *);
1010
1011         int  (*start_pmsr)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_pmsr_request *);
1012         void (*abort_pmsr)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_pmsr_request *);
1013
1014         int  (*start_ap)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_bss_conf *link_conf);
1015         void (*stop_ap)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_bss_conf *link_conf);
1016         int  (*join_ibss)(struct ieee80211_hw *, struct ieee80211_vif *);
1017         void (*leave_ibss)(struct ieee80211_hw *, struct ieee80211_vif *);
1018
1019         int  (*set_sar_specs)(struct ieee80211_hw *, const struct cfg80211_sar_specs *);
1020
1021         int  (*set_tid_config)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, struct cfg80211_tid_config *);
1022         int  (*reset_tid_config)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, u8);
1023
1024         int  (*get_et_sset_count)(struct ieee80211_hw *, struct ieee80211_vif *, int);
1025         void (*get_et_stats)(struct ieee80211_hw *, struct ieee80211_vif *, struct ethtool_stats *, u64 *);
1026         void (*get_et_strings)(struct ieee80211_hw *, struct ieee80211_vif *, u32, u8 *);
1027
1028         void (*update_vif_offload)(struct ieee80211_hw *, struct ieee80211_vif *);
1029
1030         int  (*get_txpower)(struct ieee80211_hw *, struct ieee80211_vif *, int *);
1031         int  (*get_stats)(struct ieee80211_hw *, struct ieee80211_low_level_stats *);
1032
1033         int  (*set_radar_background)(struct ieee80211_hw *, struct cfg80211_chan_def *);
1034
1035         void (*add_twt_setup)(struct ieee80211_hw *, struct ieee80211_sta *, struct ieee80211_twt_setup *);
1036         void (*twt_teardown_request)(struct ieee80211_hw *, struct ieee80211_sta *, u8);
1037
1038         int (*set_hw_timestamp)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_set_hw_timestamp *);
1039
1040         void (*vif_cfg_changed)(struct ieee80211_hw *, struct ieee80211_vif *, u64);
1041
1042         int (*change_vif_links)(struct ieee80211_hw *, struct ieee80211_vif *, u16, u16, struct ieee80211_bss_conf *[IEEE80211_MLD_MAX_NUM_LINKS]);
1043         int (*change_sta_links)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, u16, u16);
1044
1045 /* #ifdef CONFIG_MAC80211_DEBUGFS */    /* Do not change depending on compile-time option. */
1046         void (*sta_add_debugfs)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, struct dentry *);
1047 /* #endif */
1048 };
1049
1050
1051 /* -------------------------------------------------------------------------- */
1052
1053 /* linux_80211.c */
1054 extern const struct cfg80211_ops linuxkpi_mac80211cfgops;
1055
1056 struct ieee80211_hw *linuxkpi_ieee80211_alloc_hw(size_t,
1057     const struct ieee80211_ops *);
1058 void linuxkpi_ieee80211_iffree(struct ieee80211_hw *);
1059 void linuxkpi_set_ieee80211_dev(struct ieee80211_hw *, char *);
1060 int linuxkpi_ieee80211_ifattach(struct ieee80211_hw *);
1061 void linuxkpi_ieee80211_ifdetach(struct ieee80211_hw *);
1062 void linuxkpi_ieee80211_unregister_hw(struct ieee80211_hw *);
1063 struct ieee80211_hw * linuxkpi_wiphy_to_ieee80211_hw(struct wiphy *);
1064 void linuxkpi_ieee80211_restart_hw(struct ieee80211_hw *);
1065 void linuxkpi_ieee80211_iterate_interfaces(
1066     struct ieee80211_hw *hw, enum ieee80211_iface_iter flags,
1067     void(*iterfunc)(void *, uint8_t *, struct ieee80211_vif *),
1068     void *);
1069 void linuxkpi_ieee80211_iterate_keys(struct ieee80211_hw *,
1070     struct ieee80211_vif *,
1071     void(*iterfunc)(struct ieee80211_hw *, struct ieee80211_vif *,
1072         struct ieee80211_sta *, struct ieee80211_key_conf *, void *),
1073     void *);
1074 void linuxkpi_ieee80211_iterate_chan_contexts(struct ieee80211_hw *,
1075     void(*iterfunc)(struct ieee80211_hw *,
1076         struct ieee80211_chanctx_conf *, void *),
1077     void *);
1078 void linuxkpi_ieee80211_iterate_stations_atomic(struct ieee80211_hw *,
1079    void (*iterfunc)(void *, struct ieee80211_sta *), void *);
1080 void linuxkpi_ieee80211_scan_completed(struct ieee80211_hw *,
1081     struct cfg80211_scan_info *);
1082 void linuxkpi_ieee80211_rx(struct ieee80211_hw *, struct sk_buff *,
1083     struct ieee80211_sta *, struct napi_struct *, struct list_head *);
1084 uint8_t linuxkpi_ieee80211_get_tid(struct ieee80211_hdr *, bool);
1085 struct ieee80211_sta *linuxkpi_ieee80211_find_sta(struct ieee80211_vif *,
1086     const u8 *);
1087 struct ieee80211_sta *linuxkpi_ieee80211_find_sta_by_ifaddr(
1088     struct ieee80211_hw *, const uint8_t *, const uint8_t *);
1089 struct sk_buff *linuxkpi_ieee80211_tx_dequeue(struct ieee80211_hw *,
1090     struct ieee80211_txq *);
1091 bool linuxkpi_ieee80211_is_ie_id_in_ie_buf(const u8, const u8 *, size_t);
1092 bool linuxkpi_ieee80211_ie_advance(size_t *, const u8 *, size_t);
1093 void linuxkpi_ieee80211_free_txskb(struct ieee80211_hw *, struct sk_buff *,
1094     int);
1095 void linuxkpi_ieee80211_queue_delayed_work(struct ieee80211_hw *,
1096     struct delayed_work *, int);
1097 void linuxkpi_ieee80211_queue_work(struct ieee80211_hw *, struct work_struct *);
1098 struct sk_buff *linuxkpi_ieee80211_pspoll_get(struct ieee80211_hw *,
1099     struct ieee80211_vif *);
1100 struct sk_buff *linuxkpi_ieee80211_nullfunc_get(struct ieee80211_hw *,
1101     struct ieee80211_vif *, int, bool);
1102 void linuxkpi_ieee80211_txq_get_depth(struct ieee80211_txq *, unsigned long *,
1103     unsigned long *);
1104 struct wireless_dev *linuxkpi_ieee80211_vif_to_wdev(struct ieee80211_vif *);
1105 void linuxkpi_ieee80211_connection_loss(struct ieee80211_vif *);
1106 void linuxkpi_ieee80211_beacon_loss(struct ieee80211_vif *);
1107 struct sk_buff *linuxkpi_ieee80211_probereq_get(struct ieee80211_hw *,
1108     uint8_t *, uint8_t *, size_t, size_t);
1109 void linuxkpi_ieee80211_tx_status(struct ieee80211_hw *, struct sk_buff *);
1110 void linuxkpi_ieee80211_tx_status_ext(struct ieee80211_hw *,
1111     struct ieee80211_tx_status *);
1112 void linuxkpi_ieee80211_stop_queues(struct ieee80211_hw *);
1113 void linuxkpi_ieee80211_wake_queues(struct ieee80211_hw *);
1114 void linuxkpi_ieee80211_stop_queue(struct ieee80211_hw *, int);
1115 void linuxkpi_ieee80211_wake_queue(struct ieee80211_hw *, int);
1116 void linuxkpi_ieee80211_txq_schedule_start(struct ieee80211_hw *, uint8_t);
1117 struct ieee80211_txq *linuxkpi_ieee80211_next_txq(struct ieee80211_hw *, uint8_t);
1118 void linuxkpi_ieee80211_schedule_txq(struct ieee80211_hw *,
1119     struct ieee80211_txq *, bool);
1120
1121 /* -------------------------------------------------------------------------- */
1122
1123 static __inline void
1124 _ieee80211_hw_set(struct ieee80211_hw *hw, enum ieee80211_hw_flags flag)
1125 {
1126
1127         set_bit(flag, hw->flags);
1128 }
1129
1130 static __inline bool
1131 __ieee80211_hw_check(struct ieee80211_hw *hw, enum ieee80211_hw_flags flag)
1132 {
1133
1134         return (test_bit(flag, hw->flags));
1135 }
1136
1137 /* They pass in shortened flag names; how confusingly inconsistent. */
1138 #define ieee80211_hw_set(_hw, _flag)                                    \
1139         _ieee80211_hw_set(_hw, IEEE80211_HW_ ## _flag)
1140 #define ieee80211_hw_check(_hw, _flag)                                  \
1141         __ieee80211_hw_check(_hw, IEEE80211_HW_ ## _flag)
1142
1143 /* XXX-BZ add CTASSERTS that size of struct is <= sizeof skb->cb. */
1144 CTASSERT(sizeof(struct ieee80211_tx_info) <= sizeof(((struct sk_buff *)0)->cb));
1145 #define IEEE80211_SKB_CB(_skb)                                          \
1146         ((struct ieee80211_tx_info *)((_skb)->cb))
1147
1148 CTASSERT(sizeof(struct ieee80211_rx_status) <= sizeof(((struct sk_buff *)0)->cb));
1149 #define IEEE80211_SKB_RXCB(_skb)                                        \
1150         ((struct ieee80211_rx_status *)((_skb)->cb))
1151
1152 static __inline void
1153 ieee80211_free_hw(struct ieee80211_hw *hw)
1154 {
1155
1156         linuxkpi_ieee80211_iffree(hw);
1157
1158         if (hw->wiphy != NULL)
1159                 wiphy_free(hw->wiphy);
1160         /* Note that *hw is not valid any longer after this. */
1161
1162         IMPROVE();
1163 }
1164
1165 static __inline struct ieee80211_hw *
1166 ieee80211_alloc_hw(size_t priv_len, const struct ieee80211_ops *ops)
1167 {
1168
1169         return (linuxkpi_ieee80211_alloc_hw(priv_len, ops));
1170 }
1171
1172 static __inline void
1173 SET_IEEE80211_DEV(struct ieee80211_hw *hw, struct device *dev)
1174 {
1175
1176         set_wiphy_dev(hw->wiphy, dev);
1177         linuxkpi_set_ieee80211_dev(hw, dev_name(dev));
1178
1179         IMPROVE();
1180 }
1181
1182 static __inline int
1183 ieee80211_register_hw(struct ieee80211_hw *hw)
1184 {
1185         int error;
1186
1187         error = wiphy_register(hw->wiphy);
1188         if (error != 0)
1189                 return (error);
1190
1191         /*
1192          * At this point the driver has set all the options, flags, bands,
1193          * ciphers, hw address(es), ... basically mac80211/cfg80211 hw/wiphy
1194          * setup is done.
1195          * We need to replicate a lot of information from here into net80211.
1196          */
1197         error = linuxkpi_ieee80211_ifattach(hw);
1198
1199         IMPROVE();
1200
1201         return (error);
1202 }
1203
1204 static inline void
1205 ieee80211_unregister_hw(struct ieee80211_hw *hw)
1206 {
1207
1208         linuxkpi_ieee80211_unregister_hw(hw);
1209 }
1210
1211 static __inline struct ieee80211_hw *
1212 wiphy_to_ieee80211_hw(struct wiphy *wiphy)
1213 {
1214
1215         return (linuxkpi_wiphy_to_ieee80211_hw(wiphy));
1216 }
1217
1218 static inline void
1219 ieee80211_restart_hw(struct ieee80211_hw *hw)
1220 {
1221         linuxkpi_ieee80211_restart_hw(hw);
1222 }
1223
1224 static inline void
1225 ieee80211_hw_restart_disconnect(struct ieee80211_vif *vif)
1226 {
1227         TODO();
1228 }
1229
1230 /* -------------------------------------------------------------------------- */
1231
1232 #define link_conf_dereference_check(_vif, _linkid)                      \
1233     rcu_dereference_check((_vif)->link_conf[_linkid], true)
1234
1235 #define link_conf_dereference_protected(_vif, _linkid)                  \
1236     rcu_dereference_protected((_vif)->link_conf[_linkid], true)
1237
1238 #define link_sta_dereference_check(_sta, _linkid)                       \
1239     rcu_dereference_check((_sta)->link[_linkid], true)
1240
1241 #define link_sta_dereference_protected(_sta, _linkid)                   \
1242     rcu_dereference_protected((_sta)->link[_linkid], true)
1243
1244 #define for_each_vif_active_link(_vif, _link, _linkid)                  \
1245     for (_linkid = 0; _linkid < nitems((_vif)->link_conf); _linkid++)   \
1246         if ( ((_vif)->active_links == 0 /* no MLO */ ||                 \
1247             ((_vif)->active_links & BIT(_linkid)) != 0) &&              \
1248             (_link = rcu_dereference((_vif)->link_conf[_linkid])) )
1249
1250 #define for_each_sta_active_link(_vif, _sta, _linksta, _linkid)         \
1251     for (_linkid = 0; _linkid < nitems((_vif)->link_conf); _linkid++)   \
1252         if ( ((_vif)->active_links == 0 /* no MLO */ ||                 \
1253             ((_vif)->active_links & BIT(_linkid)) != 0) &&              \
1254             (_linksta = link_sta_dereference_protected((_sta), (_linkid))) )
1255
1256 /* -------------------------------------------------------------------------- */
1257
1258 static __inline bool
1259 ieee80211_is_action(__le16 fc)
1260 {
1261         __le16 v;
1262
1263         fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1264         v = htole16(IEEE80211_FC0_SUBTYPE_ACTION | IEEE80211_FC0_TYPE_MGT);
1265
1266         return (fc == v);
1267 }
1268
1269 static __inline bool
1270 ieee80211_is_probe_resp(__le16 fc)
1271 {
1272         __le16 v;
1273
1274         fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1275         v = htole16(IEEE80211_FC0_SUBTYPE_PROBE_RESP | IEEE80211_FC0_TYPE_MGT);
1276
1277         return (fc == v);
1278 }
1279
1280 static __inline bool
1281 ieee80211_is_auth(__le16 fc)
1282 {
1283         __le16 v;
1284
1285         fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1286         v = htole16(IEEE80211_FC0_SUBTYPE_AUTH | IEEE80211_FC0_TYPE_MGT);
1287
1288         return (fc == v);
1289 }
1290
1291 static __inline bool
1292 ieee80211_is_assoc_req(__le16 fc)
1293 {
1294         __le16 v;
1295
1296         fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1297         v = htole16(IEEE80211_FC0_SUBTYPE_ASSOC_REQ | IEEE80211_FC0_TYPE_MGT);
1298
1299         return (fc == v);
1300 }
1301
1302 static __inline bool
1303 ieee80211_is_assoc_resp(__le16 fc)
1304 {
1305         __le16 v;
1306
1307         fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1308         v = htole16(IEEE80211_FC0_SUBTYPE_ASSOC_RESP | IEEE80211_FC0_TYPE_MGT);
1309
1310         return (fc == v);
1311 }
1312
1313 static __inline bool
1314 ieee80211_is_reassoc_req(__le16 fc)
1315 {
1316         __le16 v;
1317
1318         fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1319         v = htole16(IEEE80211_FC0_SUBTYPE_REASSOC_REQ | IEEE80211_FC0_TYPE_MGT);
1320
1321         return (fc == v);
1322 }
1323
1324 static __inline bool
1325 ieee80211_is_reassoc_resp(__le16 fc)
1326 {
1327         __le16 v;
1328
1329         fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1330         v = htole16(IEEE80211_FC0_SUBTYPE_REASSOC_RESP | IEEE80211_FC0_TYPE_MGT);
1331
1332         return (fc == v);
1333 }
1334
1335 static __inline bool
1336 ieee80211_is_disassoc(__le16 fc)
1337 {
1338         __le16 v;
1339
1340         fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1341         v = htole16(IEEE80211_FC0_SUBTYPE_DISASSOC | IEEE80211_FC0_TYPE_MGT);
1342
1343         return (fc == v);
1344 }
1345
1346 static __inline bool
1347 ieee80211_is_data_present(__le16 fc)
1348 {
1349         __le16 v;
1350
1351         /* If it is a data frame and NODATA is not present. */
1352         fc &= htole16(IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_NODATA);
1353         v = htole16(IEEE80211_FC0_TYPE_DATA);
1354
1355         return (fc == v);
1356 }
1357
1358 static __inline bool
1359 ieee80211_is_deauth(__le16 fc)
1360 {
1361         __le16 v;
1362
1363         fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1364         v = htole16(IEEE80211_FC0_SUBTYPE_DEAUTH | IEEE80211_FC0_TYPE_MGT);
1365
1366         return (fc == v);
1367 }
1368
1369 static __inline bool
1370 ieee80211_is_beacon(__le16 fc)
1371 {
1372         __le16 v;
1373
1374         /*
1375          * For as much as I get it this comes in LE and unlike FreeBSD
1376          * where we get the entire frame header and u8[], here we get the
1377          * 9.2.4.1 Frame Control field only. Mask and compare.
1378          */
1379         fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1380         v = htole16(IEEE80211_FC0_SUBTYPE_BEACON | IEEE80211_FC0_TYPE_MGT);
1381
1382         return (fc == v);
1383 }
1384
1385
1386 static __inline bool
1387 ieee80211_is_probe_req(__le16 fc)
1388 {
1389         __le16 v;
1390
1391         fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1392         v = htole16(IEEE80211_FC0_SUBTYPE_PROBE_REQ | IEEE80211_FC0_TYPE_MGT);
1393
1394         return (fc == v);
1395 }
1396
1397 static __inline bool
1398 ieee80211_has_protected(__le16 fc)
1399 {
1400
1401         return (fc & htole16(IEEE80211_FC1_PROTECTED << 8));
1402 }
1403
1404 static __inline bool
1405 ieee80211_is_back_req(__le16 fc)
1406 {
1407         __le16 v;
1408
1409         fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1410         v = htole16(IEEE80211_FC0_SUBTYPE_BAR | IEEE80211_FC0_TYPE_CTL);
1411
1412         return (fc == v);
1413 }
1414
1415 static __inline bool
1416 ieee80211_is_bufferable_mmpdu(struct sk_buff *skb)
1417 {
1418         struct ieee80211_mgmt *mgmt;
1419         __le16 fc;
1420
1421         mgmt = (struct ieee80211_mgmt *)skb->data;
1422         fc = mgmt->frame_control;
1423
1424         /* 11.2.2 Bufferable MMPDUs, 80211-2020. */
1425         /* XXX we do not care about IBSS yet. */
1426
1427         if (!ieee80211_is_mgmt(fc))
1428                 return (false);
1429         if (ieee80211_is_action(fc))            /* XXX FTM? */
1430                 return (true);                  /* XXX false? */
1431         if (ieee80211_is_disassoc(fc))
1432                 return (true);
1433         if (ieee80211_is_deauth(fc))
1434                 return (true);
1435
1436         TODO();
1437
1438         return (false);
1439 }
1440
1441 static __inline bool
1442 ieee80211_is_nullfunc(__le16 fc)
1443 {
1444         __le16 v;
1445
1446         fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1447         v = htole16(IEEE80211_FC0_SUBTYPE_NODATA | IEEE80211_FC0_TYPE_DATA);
1448
1449         return (fc == v);
1450 }
1451
1452 static __inline bool
1453 ieee80211_is_qos_nullfunc(__le16 fc)
1454 {
1455         __le16 v;
1456
1457         fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1458         v = htole16(IEEE80211_FC0_SUBTYPE_QOS_NULL | IEEE80211_FC0_TYPE_DATA);
1459
1460         return (fc == v);
1461 }
1462
1463 static __inline bool
1464 ieee80211_is_any_nullfunc(__le16 fc)
1465 {
1466
1467         return (ieee80211_is_nullfunc(fc) || ieee80211_is_qos_nullfunc(fc));
1468 }
1469
1470 static inline bool
1471 ieee80211_is_pspoll(__le16 fc)
1472 {
1473         __le16 v;
1474
1475         fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1476         v = htole16(IEEE80211_FC0_SUBTYPE_PS_POLL | IEEE80211_FC0_TYPE_CTL);
1477
1478         return (fc == v);
1479 }
1480
1481 static __inline bool
1482 ieee80211_vif_is_mesh(struct ieee80211_vif *vif)
1483 {
1484         TODO();
1485         return (false);
1486 }
1487
1488 static __inline bool
1489 ieee80211_is_frag(struct ieee80211_hdr *hdr)
1490 {
1491         TODO();
1492         return (false);
1493 }
1494
1495 static __inline bool
1496 ieee80211_is_first_frag(__le16 fc)
1497 {
1498         TODO();
1499         return (false);
1500 }
1501
1502 static __inline bool
1503 ieee80211_is_robust_mgmt_frame(struct sk_buff *skb)
1504 {
1505         TODO();
1506         return (false);
1507 }
1508
1509 static __inline bool
1510 ieee80211_is_ftm(struct sk_buff *skb)
1511 {
1512         TODO();
1513         return (false);
1514 }
1515
1516 static __inline bool
1517 ieee80211_is_timing_measurement(struct sk_buff *skb)
1518 {
1519         TODO();
1520         return (false);
1521 }
1522
1523 static __inline bool
1524 ieee80211_has_pm(__le16 fc)
1525 {
1526         TODO();
1527         return (false);
1528 }
1529
1530 static __inline bool
1531 ieee80211_has_a4(__le16 fc)
1532 {
1533         __le16 v;
1534
1535         fc &= htole16((IEEE80211_FC1_DIR_TODS | IEEE80211_FC1_DIR_FROMDS) << 8);
1536         v = htole16((IEEE80211_FC1_DIR_TODS | IEEE80211_FC1_DIR_FROMDS) << 8);
1537
1538         return (fc == v);
1539 }
1540
1541 static __inline bool
1542 ieee80211_has_order(__le16 fc)
1543 {
1544
1545         return (fc & htole16(IEEE80211_FC1_ORDER << 8));
1546 }
1547
1548 static __inline bool
1549 ieee80211_has_retry(__le16 fc)
1550 {
1551
1552         return (fc & htole16(IEEE80211_FC1_RETRY << 8));
1553 }
1554
1555
1556 static __inline bool
1557 ieee80211_has_fromds(__le16 fc)
1558 {
1559
1560         return (fc & htole16(IEEE80211_FC1_DIR_FROMDS << 8));
1561 }
1562
1563 static __inline bool
1564 ieee80211_has_tods(__le16 fc)
1565 {
1566
1567         return (fc & htole16(IEEE80211_FC1_DIR_TODS << 8));
1568 }
1569
1570 static __inline uint8_t *
1571 ieee80211_get_SA(struct ieee80211_hdr *hdr)
1572 {
1573
1574         if (ieee80211_has_a4(hdr->frame_control))
1575                 return (hdr->addr4);
1576         if (ieee80211_has_fromds(hdr->frame_control))
1577                 return (hdr->addr3);
1578         return (hdr->addr2);
1579 }
1580
1581 static __inline uint8_t *
1582 ieee80211_get_DA(struct ieee80211_hdr *hdr)
1583 {
1584
1585         if (ieee80211_has_tods(hdr->frame_control))
1586                 return (hdr->addr3);
1587         return (hdr->addr1);
1588 }
1589
1590 static __inline bool
1591 ieee80211_has_morefrags(__le16 fc)
1592 {
1593
1594         fc &= htole16(IEEE80211_FC1_MORE_FRAG << 8);
1595         return (fc != 0);
1596 }
1597
1598 static __inline u8 *
1599 ieee80211_get_qos_ctl(struct ieee80211_hdr *hdr)
1600 {
1601         if (ieee80211_has_a4(hdr->frame_control))
1602                 return (u8 *)hdr + 30;
1603         else
1604                 return (u8 *)hdr + 24;
1605 }
1606
1607 /* -------------------------------------------------------------------------- */
1608 /* Receive functions (air/driver to mac80211/net80211). */
1609
1610
1611 static __inline void
1612 ieee80211_rx_napi(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
1613     struct sk_buff *skb, struct napi_struct *napi)
1614 {
1615
1616         linuxkpi_ieee80211_rx(hw, skb, sta, napi, NULL);
1617 }
1618
1619 static __inline void
1620 ieee80211_rx_list(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
1621     struct sk_buff *skb, struct list_head *list)
1622 {
1623
1624         linuxkpi_ieee80211_rx(hw, skb, sta, NULL, list);
1625 }
1626
1627 static __inline void
1628 ieee80211_rx_ni(struct ieee80211_hw *hw, struct sk_buff *skb)
1629 {
1630
1631         linuxkpi_ieee80211_rx(hw, skb, NULL, NULL, NULL);
1632 }
1633
1634 static __inline void
1635 ieee80211_rx_irqsafe(struct ieee80211_hw *hw, struct sk_buff *skb)
1636 {
1637
1638         linuxkpi_ieee80211_rx(hw, skb, NULL, NULL, NULL);
1639 }
1640
1641 static __inline void
1642 ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb)
1643 {
1644
1645         linuxkpi_ieee80211_rx(hw, skb, NULL, NULL, NULL);
1646 }
1647
1648 /* -------------------------------------------------------------------------- */
1649
1650 static inline void
1651 ieee80211_stop_queues(struct ieee80211_hw *hw)
1652 {
1653         linuxkpi_ieee80211_stop_queues(hw);
1654 }
1655
1656 static inline void
1657 ieee80211_wake_queues(struct ieee80211_hw *hw)
1658 {
1659         linuxkpi_ieee80211_wake_queues(hw);
1660 }
1661
1662 static inline void
1663 ieee80211_stop_queue(struct ieee80211_hw *hw, int qnum)
1664 {
1665         linuxkpi_ieee80211_stop_queue(hw, qnum);
1666 }
1667
1668 static inline void
1669 ieee80211_wake_queue(struct ieee80211_hw *hw, int qnum)
1670 {
1671         linuxkpi_ieee80211_wake_queue(hw, qnum);
1672 }
1673
1674 static inline void
1675 ieee80211_schedule_txq(struct ieee80211_hw *hw, struct ieee80211_txq *txq)
1676 {
1677         linuxkpi_ieee80211_schedule_txq(hw, txq, true);
1678 }
1679
1680 static inline void
1681 ieee80211_return_txq(struct ieee80211_hw *hw, struct ieee80211_txq *txq,
1682     bool withoutpkts)
1683 {
1684         linuxkpi_ieee80211_schedule_txq(hw, txq, true);
1685 }
1686
1687 static inline void
1688 ieee80211_txq_schedule_start(struct ieee80211_hw *hw, uint8_t ac)
1689 {
1690         linuxkpi_ieee80211_txq_schedule_start(hw, ac);
1691 }
1692
1693 static inline void
1694 ieee80211_txq_schedule_end(struct ieee80211_hw *hw, uint8_t ac)
1695 {
1696         /* DO_NADA; */
1697 }
1698
1699 static inline struct ieee80211_txq *
1700 ieee80211_next_txq(struct ieee80211_hw *hw, uint8_t ac)
1701 {
1702         return (linuxkpi_ieee80211_next_txq(hw, ac));
1703 }
1704
1705 static inline void
1706 ieee80211_handle_wake_tx_queue(struct ieee80211_hw *hw,
1707     struct ieee80211_txq *txq)
1708 {
1709         TODO();
1710 }
1711
1712 /* -------------------------------------------------------------------------- */
1713
1714 static __inline uint8_t
1715 ieee80211_get_tid(struct ieee80211_hdr *hdr)
1716 {
1717
1718         return (linuxkpi_ieee80211_get_tid(hdr, false));
1719 }
1720
1721 static __inline struct sk_buff *
1722 ieee80211_beacon_get_tim(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1723     uint16_t *tim_offset, uint16_t *tim_len, uint32_t link_id)
1724 {
1725
1726         if (tim_offset != NULL)
1727                 *tim_offset = 0;
1728         if (tim_len != NULL)
1729                 *tim_len = 0;
1730         TODO();
1731         return (NULL);
1732 }
1733
1734 static __inline void
1735 ieee80211_iterate_active_interfaces_atomic(struct ieee80211_hw *hw,
1736     enum ieee80211_iface_iter flags,
1737     void(*iterfunc)(void *, uint8_t *, struct ieee80211_vif *),
1738     void *arg)
1739 {
1740
1741         flags |= IEEE80211_IFACE_ITER__ATOMIC;
1742         flags |= IEEE80211_IFACE_ITER_ACTIVE;
1743         linuxkpi_ieee80211_iterate_interfaces(hw, flags, iterfunc, arg);
1744 }
1745
1746 static __inline void
1747 ieee80211_iterate_active_interfaces(struct ieee80211_hw *hw,
1748     enum ieee80211_iface_iter flags,
1749     void(*iterfunc)(void *, uint8_t *, struct ieee80211_vif *),
1750     void *arg)
1751 {
1752
1753         flags |= IEEE80211_IFACE_ITER_ACTIVE;
1754         linuxkpi_ieee80211_iterate_interfaces(hw, flags, iterfunc, arg);
1755 }
1756
1757 static __inline void
1758 ieee80211_iterate_active_interfaces_mtx(struct ieee80211_hw *hw,
1759     enum ieee80211_iface_iter flags,
1760     void(*iterfunc)(void *, uint8_t *, struct ieee80211_vif *),
1761     void *arg)
1762 {
1763         flags |= IEEE80211_IFACE_ITER_ACTIVE;
1764         flags |= IEEE80211_IFACE_ITER__MTX;
1765         linuxkpi_ieee80211_iterate_interfaces(hw, flags, iterfunc, arg);
1766 }
1767
1768 static __inline void
1769 ieee80211_iterate_interfaces(struct ieee80211_hw *hw,
1770    enum ieee80211_iface_iter flags,
1771    void (*iterfunc)(void *, uint8_t *, struct ieee80211_vif *),
1772    void *arg)
1773 {
1774
1775         linuxkpi_ieee80211_iterate_interfaces(hw, flags, iterfunc, arg);
1776 }
1777
1778 static __inline void
1779 ieee80211_iter_keys(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1780     void(*iterfunc)(struct ieee80211_hw *, struct ieee80211_vif *,
1781         struct ieee80211_sta *, struct ieee80211_key_conf *, void *),
1782     void *arg)
1783 {
1784
1785         linuxkpi_ieee80211_iterate_keys(hw, vif, iterfunc, arg);
1786 }
1787
1788 static __inline void
1789 ieee80211_iter_keys_rcu(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1790     void(*iterfunc)(struct ieee80211_hw *, struct ieee80211_vif *,
1791         struct ieee80211_sta *, struct ieee80211_key_conf *, void *),
1792     void *arg)
1793 {
1794
1795         IMPROVE();      /* "rcu" */
1796         linuxkpi_ieee80211_iterate_keys(hw, vif, iterfunc, arg);
1797 }
1798
1799 static __inline void
1800 ieee80211_iter_chan_contexts_atomic(struct ieee80211_hw *hw,
1801     void(*iterfunc)(struct ieee80211_hw *, struct ieee80211_chanctx_conf *, void *),
1802     void *arg)
1803 {
1804
1805         linuxkpi_ieee80211_iterate_chan_contexts(hw, iterfunc, arg);
1806 }
1807
1808 static __inline void
1809 ieee80211_iterate_stations_atomic(struct ieee80211_hw *hw,
1810    void (*iterfunc)(void *, struct ieee80211_sta *), void *arg)
1811 {
1812
1813         linuxkpi_ieee80211_iterate_stations_atomic(hw, iterfunc, arg);
1814 }
1815
1816 static __inline struct wireless_dev *
1817 ieee80211_vif_to_wdev(struct ieee80211_vif *vif)
1818 {
1819
1820         return (linuxkpi_ieee80211_vif_to_wdev(vif));
1821 }
1822
1823 static __inline struct sk_buff *
1824 ieee80211_beacon_get_template(struct ieee80211_hw *hw,
1825     struct ieee80211_vif *vif, struct ieee80211_mutable_offsets *offs,
1826     uint32_t link_id)
1827 {
1828         TODO();
1829         return (NULL);
1830 }
1831
1832 static __inline void
1833 ieee80211_beacon_loss(struct ieee80211_vif *vif)
1834 {
1835         linuxkpi_ieee80211_beacon_loss(vif);
1836 }
1837
1838 static __inline void
1839 ieee80211_chswitch_done(struct ieee80211_vif *vif, bool t)
1840 {
1841         TODO();
1842 }
1843
1844 static __inline bool
1845 ieee80211_csa_is_complete(struct ieee80211_vif *vif)
1846 {
1847         TODO();
1848         return (false);
1849 }
1850
1851 static __inline void
1852 ieee80211_csa_set_counter(struct ieee80211_vif *vif, uint8_t counter)
1853 {
1854         TODO();
1855 }
1856
1857 static __inline int
1858 ieee80211_csa_update_counter(struct ieee80211_vif *vif)
1859 {
1860         TODO();
1861         return (-1);
1862 }
1863
1864 static __inline void
1865 ieee80211_csa_finish(struct ieee80211_vif *vif)
1866 {
1867         TODO();
1868 }
1869
1870 static __inline enum nl80211_iftype
1871 ieee80211_vif_type_p2p(struct ieee80211_vif *vif)
1872 {
1873
1874         /* If we are not p2p enabled, just return the type. */
1875         if (!vif->p2p)
1876                 return (vif->type);
1877
1878         /* If we are p2p, depending on side, return type. */
1879         switch (vif->type) {
1880         case NL80211_IFTYPE_AP:
1881                 return (NL80211_IFTYPE_P2P_GO);
1882         case NL80211_IFTYPE_STATION:
1883                 return (NL80211_IFTYPE_P2P_CLIENT);
1884         default:
1885                 fallthrough;
1886         }
1887         return (vif->type);
1888 }
1889
1890 static __inline unsigned long
1891 ieee80211_tu_to_usec(unsigned long tu)
1892 {
1893
1894         return (tu * IEEE80211_DUR_TU);
1895 }
1896
1897 /*
1898  * Below we assume that the two values from different emums are the same.
1899  * Make sure this does not accidentally change.
1900  */
1901 CTASSERT((int)IEEE80211_ACTION_SM_TPCREP == (int)IEEE80211_ACTION_RADIO_MEASUREMENT_LMREP);
1902
1903 static __inline bool
1904 ieee80211_action_contains_tpc(struct sk_buff *skb)
1905 {
1906         struct ieee80211_mgmt *mgmt;
1907
1908         mgmt = (struct ieee80211_mgmt *)skb->data;
1909
1910         /* Check that this is a mgmt/action frame? */
1911         if (!ieee80211_is_action(mgmt->frame_control))
1912                 return (false);
1913
1914         /*
1915          * This is a bit convoluted but according to docs both actions
1916          * are checked for this.  Kind-of makes sense for the only consumer
1917          * (iwlwifi) I am aware off given the txpower fields are at the
1918          * same location so firmware can update the value.
1919          */
1920         /* 80211-2020 9.6.2 Spectrum Management Action frames */
1921         /* 80211-2020 9.6.2.5 TPC Report frame format */
1922         /* 80211-2020 9.6.6 Radio Measurement action details */
1923         /* 80211-2020 9.6.6.4 Link Measurement Report frame format */
1924         /* Check that it is Spectrum Management or Radio Measurement? */
1925         if (mgmt->u.action.category != IEEE80211_ACTION_CAT_SM &&
1926             mgmt->u.action.category != IEEE80211_ACTION_CAT_RADIO_MEASUREMENT)
1927                 return (false);
1928
1929         /*
1930          * Check that it is TPC Report or Link Measurement Report?
1931          * The values of each are the same (see CTASSERT above function).
1932          */
1933         if (mgmt->u.action.u.tpc_report.spec_mgmt != IEEE80211_ACTION_SM_TPCREP)
1934                 return (false);
1935
1936         /* 80211-2020 9.4.2.16 TPC Report element */
1937         /* Check that the ELEMID and length are correct? */
1938         if (mgmt->u.action.u.tpc_report.tpc_elem_id != IEEE80211_ELEMID_TPCREP ||
1939             mgmt->u.action.u.tpc_report.tpc_elem_length != 4)
1940                 return (false);
1941
1942         /* All the right fields in the right place. */
1943         return (true);
1944 }
1945
1946 static __inline void
1947 ieee80211_connection_loss(struct ieee80211_vif *vif)
1948 {
1949
1950         linuxkpi_ieee80211_connection_loss(vif);
1951 }
1952
1953 static __inline struct ieee80211_sta *
1954 ieee80211_find_sta(struct ieee80211_vif *vif, const u8 *peer)
1955 {
1956
1957         return (linuxkpi_ieee80211_find_sta(vif, peer));
1958 }
1959
1960 static __inline struct ieee80211_sta *
1961 ieee80211_find_sta_by_ifaddr(struct ieee80211_hw *hw, const uint8_t *addr,
1962     const uint8_t *ourvifaddr)
1963 {
1964
1965         return (linuxkpi_ieee80211_find_sta_by_ifaddr(hw, addr, ourvifaddr));
1966 }
1967
1968
1969 static __inline void
1970 ieee80211_get_tkip_p2k(struct ieee80211_key_conf *keyconf,
1971     struct sk_buff *skb_frag, u8 *key)
1972 {
1973         TODO();
1974 }
1975
1976 static __inline void
1977 ieee80211_get_tkip_rx_p1k(struct ieee80211_key_conf *keyconf,
1978     const u8 *addr, uint32_t iv32, u16 *p1k)
1979 {
1980
1981         KASSERT(keyconf != NULL && addr != NULL && p1k != NULL,
1982             ("%s: keyconf %p addr %p p1k %p\n", __func__, keyconf, addr, p1k));
1983
1984         TODO();
1985         memset(p1k, 0xfa, 5 * sizeof(*p1k));    /* Just initializing. */
1986 }
1987
1988 static __inline size_t
1989 ieee80211_ie_split(const u8 *ies, size_t ies_len,
1990     const u8 *ie_ids, size_t ie_ids_len, size_t start)
1991 {
1992         size_t x;
1993
1994         x = start;
1995
1996         /* XXX FIXME, we need to deal with "Element ID Extension" */
1997         while (x < ies_len) {
1998
1999                 /* Is this IE[s] one of the ie_ids? */
2000                 if (!linuxkpi_ieee80211_is_ie_id_in_ie_buf(ies[x],
2001                     ie_ids, ie_ids_len))
2002                         break;
2003
2004                 if (!linuxkpi_ieee80211_ie_advance(&x, ies, ies_len))
2005                         break;
2006         }
2007
2008         return (x);
2009 }
2010
2011 static __inline void
2012 ieee80211_request_smps(struct ieee80211_vif *vif, u_int link_id,
2013     enum ieee80211_smps_mode smps)
2014 {
2015         static const char *smps_mode_name[] = {
2016                 "SMPS_OFF",
2017                 "SMPS_STATIC",
2018                 "SMPS_DYNAMIC",
2019                 "SMPS_AUTOMATIC",
2020                 "SMPS_NUM_MODES"
2021         };
2022
2023         if (linuxkpi_debug_80211 & D80211_TODO)
2024                 printf("%s:%d: XXX LKPI80211 TODO smps %d %s\n",
2025                     __func__, __LINE__, smps, smps_mode_name[smps]);
2026 }
2027
2028 static __inline void
2029 ieee80211_tdls_oper_request(struct ieee80211_vif *vif, uint8_t *addr,
2030     enum nl80211_tdls_operation oper, enum ieee80211_reason_code code,
2031     gfp_t gfp)
2032 {
2033         TODO();
2034 }
2035
2036 static __inline void
2037 wiphy_rfkill_set_hw_state(struct wiphy *wiphy, bool state)
2038 {
2039         TODO();
2040 }
2041
2042 static __inline void
2043 ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb)
2044 {
2045         IMPROVE();
2046
2047         /*
2048          * This is called on transmit failure.
2049          * Use a not-so-random random high status error so we can distinguish
2050          * it from normal low values flying around in net80211 ("ETX").
2051          */
2052         linuxkpi_ieee80211_free_txskb(hw, skb, 0x455458);
2053 }
2054
2055 static __inline void
2056 ieee80211_ready_on_channel(struct ieee80211_hw *hw)
2057 {
2058         TODO();
2059 /* XXX-BZ We need to see that. */
2060 }
2061
2062 static __inline void
2063 ieee80211_remain_on_channel_expired(struct ieee80211_hw *hw)
2064 {
2065         TODO();
2066 }
2067
2068 static __inline void
2069 ieee80211_cqm_rssi_notify(struct ieee80211_vif *vif,
2070     enum nl80211_cqm_rssi_threshold_event crte, int sig, gfp_t gfp)
2071 {
2072         TODO();
2073 }
2074
2075 static __inline void
2076 ieee80211_mark_rx_ba_filtered_frames(struct ieee80211_sta *sta, uint8_t tid,
2077     uint32_t ssn, uint64_t bitmap, uint16_t received_mpdu)
2078 {
2079         TODO();
2080 }
2081
2082 static __inline bool
2083 ieee80211_sn_less(uint16_t sn1, uint16_t sn2)
2084 {
2085         TODO();
2086         return (false);
2087 }
2088
2089 static __inline uint16_t
2090 ieee80211_sn_inc(uint16_t sn)
2091 {
2092         TODO();
2093         return (sn + 1);
2094 }
2095
2096 static __inline uint16_t
2097 ieee80211_sn_add(uint16_t sn, uint16_t a)
2098 {
2099         TODO();
2100         return (sn + a);
2101 }
2102
2103 static __inline void
2104 ieee80211_stop_rx_ba_session(struct ieee80211_vif *vif, uint32_t x, uint8_t *addr)
2105 {
2106         TODO();
2107 }
2108
2109 static __inline void
2110 ieee80211_rate_set_vht(struct ieee80211_tx_rate *r, uint32_t f1, uint32_t f2)
2111 {
2112         TODO();
2113 }
2114
2115 static __inline uint8_t
2116 ieee80211_rate_get_vht_nss(struct ieee80211_tx_rate *r)
2117 {
2118         TODO();
2119         return (0);
2120 }
2121
2122 static __inline uint8_t
2123 ieee80211_rate_get_vht_mcs(struct ieee80211_tx_rate *r)
2124 {
2125         TODO();
2126         return (0);
2127 }
2128
2129 static __inline void
2130 ieee80211_reserve_tid(struct ieee80211_sta *sta, uint8_t tid)
2131 {
2132         TODO();
2133 }
2134
2135 static __inline void
2136 ieee80211_unreserve_tid(struct ieee80211_sta *sta, uint8_t tid)
2137 {
2138         TODO();
2139 }
2140
2141 static __inline void
2142 ieee80211_rx_ba_timer_expired(struct ieee80211_vif *vif, uint8_t *addr,
2143     uint8_t tid)
2144 {
2145         TODO();
2146 }
2147
2148 static __inline void
2149 ieee80211_send_eosp_nullfunc(struct ieee80211_sta *sta, uint8_t tid)
2150 {
2151         TODO();
2152 }
2153
2154 static __inline uint16_t
2155 ieee80211_sn_sub(uint16_t sa, uint16_t sb)
2156 {
2157
2158         return ((sa - sb) &
2159             (IEEE80211_SEQ_SEQ_MASK >> IEEE80211_SEQ_SEQ_SHIFT));
2160 }
2161
2162 static __inline void
2163 ieee80211_sta_block_awake(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
2164     bool disable)
2165 {
2166         TODO();
2167 }
2168
2169 static __inline void
2170 ieee80211_sta_ps_transition(struct ieee80211_sta *sta, bool sleeping)
2171 {
2172         TODO();
2173 }
2174
2175 static __inline void
2176 ieee80211_sta_pspoll(struct ieee80211_sta *sta)
2177 {
2178         TODO();
2179 }
2180
2181 static __inline void
2182 ieee80211_sta_recalc_aggregates(struct ieee80211_sta *sta)
2183 {
2184         TODO();
2185 }
2186
2187 static __inline void
2188 ieee80211_sta_uapsd_trigger(struct ieee80211_sta *sta, int ntids)
2189 {
2190         TODO();
2191 }
2192
2193 static __inline void
2194 ieee80211_tkip_add_iv(u8 *crypto_hdr, struct ieee80211_key_conf *keyconf,
2195     uint64_t pn)
2196 {
2197         TODO();
2198 }
2199
2200 static __inline struct sk_buff *
2201 ieee80211_tx_dequeue(struct ieee80211_hw *hw, struct ieee80211_txq *txq)
2202 {
2203
2204         return (linuxkpi_ieee80211_tx_dequeue(hw, txq));
2205 }
2206
2207 static __inline void
2208 ieee80211_update_mu_groups(struct ieee80211_vif *vif,
2209     u_int _i, uint8_t *ms, uint8_t *up)
2210 {
2211         TODO();
2212 }
2213
2214 static __inline void
2215 ieee80211_sta_set_buffered(struct ieee80211_sta *sta, uint8_t tid, bool t)
2216 {
2217         TODO();
2218 }
2219
2220 static __inline void
2221 ieee80211_get_key_rx_seq(struct ieee80211_key_conf *keyconf, uint8_t tid,
2222     struct ieee80211_key_seq *seq)
2223 {
2224
2225         KASSERT(keyconf != NULL && seq != NULL, ("%s: keyconf %p seq %p\n",
2226             __func__, keyconf, seq));
2227
2228         TODO();
2229         switch (keyconf->cipher) {
2230         case WLAN_CIPHER_SUITE_CCMP:
2231         case WLAN_CIPHER_SUITE_CCMP_256:
2232                 memset(seq->ccmp.pn, 0xfa, sizeof(seq->ccmp.pn));       /* XXX TODO */
2233                 break;
2234         case WLAN_CIPHER_SUITE_AES_CMAC:
2235                 memset(seq->aes_cmac.pn, 0xfa, sizeof(seq->aes_cmac.pn));       /* XXX TODO */
2236                 break;
2237         case WLAN_CIPHER_SUITE_TKIP:
2238                 seq->tkip.iv32 = 0xfa;          /* XXX TODO */
2239                 seq->tkip.iv16 = 0xfa;          /* XXX TODO */
2240                 break;
2241         default:
2242                 pr_debug("%s: unsupported cipher suite %d\n", __func__, keyconf->cipher);
2243                 break;
2244         }
2245 }
2246
2247 static __inline void
2248 ieee80211_sched_scan_results(struct ieee80211_hw *hw)
2249 {
2250         TODO();
2251 }
2252
2253 static __inline void
2254 ieee80211_sta_eosp(struct ieee80211_sta *sta)
2255 {
2256         TODO();
2257 }
2258
2259 static __inline int
2260 ieee80211_start_tx_ba_session(struct ieee80211_sta *sta, uint8_t tid, int x)
2261 {
2262         TODO("rtw8x");
2263         return (-EINVAL);
2264 }
2265
2266 static __inline int
2267 ieee80211_stop_tx_ba_session(struct ieee80211_sta *sta, uint8_t tid)
2268 {
2269         TODO("rtw89");
2270         return (-EINVAL);
2271 }
2272
2273 static __inline void
2274 ieee80211_start_tx_ba_cb_irqsafe(struct ieee80211_vif *vif, uint8_t *addr,
2275     uint8_t tid)
2276 {
2277         TODO("iwlwifi");
2278 }
2279
2280 static __inline void
2281 ieee80211_stop_tx_ba_cb_irqsafe(struct ieee80211_vif *vif, uint8_t *addr,
2282     uint8_t tid)
2283 {
2284         TODO("iwlwifi/rtw8x/...");
2285 }
2286
2287 static __inline void
2288 ieee80211_sched_scan_stopped(struct ieee80211_hw *hw)
2289 {
2290         TODO();
2291 }
2292
2293 static __inline void
2294 ieee80211_scan_completed(struct ieee80211_hw *hw,
2295     struct cfg80211_scan_info *info)
2296 {
2297
2298         linuxkpi_ieee80211_scan_completed(hw, info);
2299 }
2300
2301 static __inline struct sk_buff *
2302 ieee80211_beacon_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
2303     uint32_t link_id)
2304 {
2305         TODO();
2306         return (NULL);
2307 }
2308
2309 static __inline struct sk_buff *
2310 ieee80211_pspoll_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
2311 {
2312
2313         /* Only STA needs this.  Otherwise return NULL and panic bad drivers. */
2314         if (vif->type != NL80211_IFTYPE_STATION)
2315                 return (NULL);
2316
2317         return (linuxkpi_ieee80211_pspoll_get(hw, vif));
2318 }
2319
2320 static __inline struct sk_buff *
2321 ieee80211_proberesp_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
2322 {
2323         TODO();
2324         return (NULL);
2325 }
2326
2327 static __inline struct sk_buff *
2328 ieee80211_nullfunc_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
2329     int linkid, bool qos)
2330 {
2331
2332         /* Only STA needs this.  Otherwise return NULL and panic bad drivers. */
2333         if (vif->type != NL80211_IFTYPE_STATION)
2334                 return (NULL);
2335
2336         return (linuxkpi_ieee80211_nullfunc_get(hw, vif, linkid, qos));
2337 }
2338
2339 static __inline struct sk_buff *
2340 ieee80211_probereq_get(struct ieee80211_hw *hw, uint8_t *addr,
2341     uint8_t *ssid, size_t ssid_len, size_t tailroom)
2342 {
2343
2344         return (linuxkpi_ieee80211_probereq_get(hw, addr, ssid, ssid_len,
2345             tailroom));
2346 }
2347
2348 static __inline void
2349 ieee80211_queue_delayed_work(struct ieee80211_hw *hw, struct delayed_work *w,
2350     int delay)
2351 {
2352
2353         linuxkpi_ieee80211_queue_delayed_work(hw, w, delay);
2354 }
2355
2356 static __inline void
2357 ieee80211_queue_work(struct ieee80211_hw *hw, struct work_struct *w)
2358 {
2359
2360         linuxkpi_ieee80211_queue_work(hw, w);
2361 }
2362
2363 static __inline void
2364 ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)
2365 {
2366
2367         linuxkpi_ieee80211_tx_status(hw, skb);
2368 }
2369
2370 static __inline void
2371 ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw, struct sk_buff *skb)
2372 {
2373         IMPROVE();
2374         ieee80211_tx_status(hw, skb);
2375 }
2376
2377 static __inline void
2378 ieee80211_tx_status_ni(struct ieee80211_hw *hw, struct sk_buff *skb)
2379 {
2380         IMPROVE();
2381         ieee80211_tx_status(hw, skb);
2382 }
2383
2384 static __inline void
2385 ieee80211_tx_status_ext(struct ieee80211_hw *hw,
2386     struct ieee80211_tx_status *txstat)
2387 {
2388
2389         linuxkpi_ieee80211_tx_status_ext(hw, txstat);
2390 }
2391
2392 static __inline void
2393 ieee80211_tx_info_clear_status(struct ieee80211_tx_info *info)
2394 {
2395         int i;
2396
2397         /*
2398          * Apparently clearing flags and some other fields is not right.
2399          * Given the function is called "status" we work on that part of
2400          * the union.
2401          */
2402         for (i = 0; i < nitems(info->status.rates); i++)
2403                 info->status.rates[i].count = 0;
2404         /*
2405          * Unclear if ack_signal should be included or not but we clear the
2406          * "valid" bool so this field is no longer valid.
2407          */
2408         memset(&info->status.ack_signal, 0, sizeof(*info) -
2409             offsetof(struct ieee80211_tx_info, status.ack_signal));
2410 }
2411
2412 static __inline void
2413 ieee80211_txq_get_depth(struct ieee80211_txq *txq, unsigned long *frame_cnt,
2414     unsigned long *byte_cnt)
2415 {
2416
2417         if (frame_cnt == NULL && byte_cnt == NULL)
2418                 return;
2419
2420         linuxkpi_ieee80211_txq_get_depth(txq, frame_cnt, byte_cnt);
2421 }
2422
2423 static __inline int
2424 rate_lowest_index(struct ieee80211_supported_band *band,
2425     struct ieee80211_sta *sta)
2426 {
2427         IMPROVE();
2428         return (0);
2429 }
2430
2431
2432 static __inline void
2433 SET_IEEE80211_PERM_ADDR (struct ieee80211_hw *hw, uint8_t *addr)
2434 {
2435
2436         ether_addr_copy(hw->wiphy->perm_addr, addr);
2437 }
2438
2439 static __inline void
2440 ieee80211_report_low_ack(struct ieee80211_sta *sta, int x)
2441 {
2442         TODO();
2443 }
2444
2445 static __inline void
2446 ieee80211_start_rx_ba_session_offl(struct ieee80211_vif *vif, uint8_t *addr,
2447     uint8_t tid)
2448 {
2449         TODO();
2450 }
2451
2452 static __inline void
2453 ieee80211_stop_rx_ba_session_offl(struct ieee80211_vif *vif, uint8_t *addr,
2454     uint8_t tid)
2455 {
2456         TODO();
2457 }
2458
2459 static __inline struct sk_buff *
2460 ieee80211_tx_dequeue_ni(struct ieee80211_hw *hw, struct ieee80211_txq *txq)
2461 {
2462         TODO();
2463         return (NULL);
2464 }
2465
2466 static __inline void
2467 ieee80211_tx_rate_update(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
2468     struct ieee80211_tx_info *info)
2469 {
2470         TODO();
2471 }
2472
2473 static __inline bool
2474 ieee80211_txq_may_transmit(struct ieee80211_hw *hw, struct ieee80211_txq *txq)
2475 {
2476         TODO();
2477         return (false);
2478 }
2479
2480 static __inline void
2481 ieee80211_radar_detected(struct ieee80211_hw *hw)
2482 {
2483         TODO();
2484 }
2485
2486 static __inline void
2487 ieee80211_sta_register_airtime(struct ieee80211_sta *sta,
2488     uint8_t tid, uint32_t duration, int x)
2489 {
2490         TODO();
2491 }
2492
2493 static __inline void
2494 ieee80211_beacon_set_cntdwn(struct ieee80211_vif *vif, u8 counter)
2495 {
2496         TODO();
2497 }
2498
2499 static __inline int
2500 ieee80211_beacon_update_cntdwn(struct ieee80211_vif *vif)
2501 {
2502         TODO();
2503         return (-1);
2504 }
2505
2506 static __inline int
2507 ieee80211_get_vht_max_nss(struct ieee80211_vht_cap *vht_cap, uint32_t chanwidth,
2508     int x, bool t, int nss)
2509 {
2510         TODO();
2511         return (-1);
2512 }
2513
2514 static __inline bool
2515 ieee80211_beacon_cntdwn_is_complete(struct ieee80211_vif *vif)
2516 {
2517         TODO();
2518         return (true);
2519 }
2520
2521 static __inline void
2522 ieee80211_disconnect(struct ieee80211_vif *vif, bool _x)
2523 {
2524         TODO();
2525 }
2526
2527 static __inline void
2528 ieee80211_channel_switch_disconnect(struct ieee80211_vif *vif, bool _x)
2529 {
2530         TODO();
2531 }
2532
2533 static __inline const struct ieee80211_sta_he_cap *
2534 ieee80211_get_he_iftype_cap(const struct ieee80211_supported_band *band,
2535     enum nl80211_iftype type)
2536 {
2537         TODO();
2538         return (NULL);
2539 }
2540
2541 static __inline void
2542 ieee80211_key_mic_failure(struct ieee80211_key_conf *key)
2543 {
2544         TODO();
2545 }
2546
2547 static __inline void
2548 ieee80211_key_replay(struct ieee80211_key_conf *key)
2549 {
2550         TODO();
2551 }
2552
2553 static __inline uint32_t
2554 ieee80211_calc_rx_airtime(struct ieee80211_hw *hw,
2555     struct ieee80211_rx_status *rxstat, int len)
2556 {
2557         TODO();
2558         return (0);
2559 }
2560
2561 static __inline void
2562 ieee80211_get_tx_rates(struct ieee80211_vif *vif, struct ieee80211_sta *sta,
2563     struct sk_buff *skb, struct ieee80211_tx_rate *txrate, int nrates)
2564 {
2565         TODO();
2566 }
2567
2568 static __inline void
2569 ieee80211_color_change_finish(struct ieee80211_vif *vif)
2570 {
2571         TODO();
2572 }
2573
2574 static __inline struct sk_buff *
2575 ieee80211_get_fils_discovery_tmpl(struct ieee80211_hw *hw,
2576     struct ieee80211_vif *vif)
2577 {
2578         TODO();
2579         return (NULL);
2580 }
2581
2582 static __inline struct sk_buff *
2583 ieee80211_get_unsol_bcast_probe_resp_tmpl(struct ieee80211_hw *hw,
2584     struct ieee80211_vif *vif)
2585 {
2586         TODO();
2587         return (NULL);
2588 }
2589
2590 static __inline void
2591 linuxkpi_ieee80211_send_bar(struct ieee80211_vif *vif, uint8_t *ra, uint16_t tid,
2592     uint16_t ssn)
2593 {
2594         TODO();
2595 }
2596
2597 static __inline void
2598 ieee80211_resume_disconnect(struct ieee80211_vif *vif)
2599 {
2600         TODO();
2601 }
2602
2603 static __inline int
2604 ieee80211_data_to_8023(struct sk_buff *skb, const uint8_t *addr,
2605      enum nl80211_iftype iftype)
2606 {
2607         TODO();
2608         return (-1);
2609 }
2610
2611 static __inline void
2612 ieee80211_get_tkip_p1k_iv(struct ieee80211_key_conf *key,
2613     uint32_t iv32, uint16_t *p1k)
2614 {
2615         TODO();
2616 }
2617
2618 static __inline struct ieee80211_key_conf *
2619 ieee80211_gtk_rekey_add(struct ieee80211_vif *vif,
2620     struct ieee80211_key_conf *key)
2621 {
2622         TODO();
2623         return (NULL);
2624 }
2625
2626 static __inline void
2627 ieee80211_gtk_rekey_notify(struct ieee80211_vif *vif, const uint8_t *bssid,
2628     const uint8_t *replay_ctr, gfp_t gfp)
2629 {
2630         TODO();
2631 }
2632
2633 static __inline void
2634 ieee80211_remove_key(struct ieee80211_key_conf *key)
2635 {
2636         TODO();
2637 }
2638
2639 static __inline void
2640 ieee80211_set_key_rx_seq(struct ieee80211_key_conf *key, int tid,
2641     struct ieee80211_key_seq *seq)
2642 {
2643         TODO();
2644 }
2645
2646 static __inline void
2647 ieee80211_report_wowlan_wakeup(struct ieee80211_vif *vif,
2648     struct cfg80211_wowlan_wakeup *wakeup, gfp_t gfp)
2649 {
2650         TODO();
2651 }
2652
2653 static __inline void
2654 ieee80211_obss_color_collision_notify(struct ieee80211_vif *vif,
2655     uint64_t obss_color_bitmap, gfp_t gfp)
2656 {
2657         TODO();
2658 }
2659
2660 static __inline void
2661 ieee80211_refresh_tx_agg_session_timer(struct ieee80211_sta *sta,
2662     uint8_t tid)
2663 {
2664         TODO();
2665 }
2666
2667 static __inline struct ieee80211_ema_beacons *
2668 ieee80211_beacon_get_template_ema_list(struct ieee80211_hw *hw,
2669     struct ieee80211_vif *vif, uint32_t link_id)
2670 {
2671         TODO();
2672         return (NULL);
2673 }
2674
2675 static __inline void
2676 ieee80211_beacon_free_ema_list(struct ieee80211_ema_beacons *bcns)
2677 {
2678         TODO();
2679 }
2680
2681 static inline bool
2682 ieee80211_vif_is_mld(const struct ieee80211_vif *vif)
2683 {
2684
2685         /* If valid_links is non-zero, the vif is an MLD. */
2686         return (vif->valid_links != 0);
2687 }
2688
2689 static __inline const struct ieee80211_sta_he_cap *
2690 ieee80211_get_he_iftype_cap_vif(const struct ieee80211_supported_band *band,
2691     struct ieee80211_vif *vif)
2692 {
2693         TODO();
2694         return (NULL);
2695 }
2696
2697 static __inline const struct ieee80211_sta_eht_cap *
2698 ieee80211_get_eht_iftype_cap_vif(const struct ieee80211_supported_band *band,
2699     struct ieee80211_vif *vif)
2700 {
2701         TODO();
2702         return (NULL);
2703 }
2704
2705 #define ieee80211_send_bar(_v, _r, _t, _s)                              \
2706     linuxkpi_ieee80211_send_bar(_v, _r, _t, _s)
2707
2708 #endif  /* _LINUXKPI_NET_MAC80211_H */