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