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