2 * Copyright (c) 2020-2021 The FreeBSD Foundation
3 * Copyright (c) 2021-2022 Bjoern A. Zeeb
5 * This software was developed by Björn Zeeb under sponsorship from
6 * the FreeBSD Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
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.
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
32 #ifndef _LINUXKPI_NET_CFG80211_H
33 #define _LINUXKPI_NET_CFG80211_H
35 #include <linux/types.h>
36 #include <linux/nl80211.h>
37 #include <linux/ieee80211.h>
38 #include <linux/if_ether.h>
39 #include <linux/ethtool.h>
40 #include <linux/device.h>
41 #include <linux/netdevice.h>
42 #include <linux/random.h>
43 #include <linux/skbuff.h>
44 #include <net/regulatory.h>
47 extern int linuxkpi_debug_80211;
49 #define D80211_TODO 0x1
51 #ifndef D80211_IMPROVE
52 #define D80211_IMPROVE 0x2
54 #define TODO() if (linuxkpi_debug_80211 & D80211_TODO) \
55 printf("%s:%d: XXX LKPI80211 TODO\n", __func__, __LINE__)
56 #define IMPROVE(...) if (linuxkpi_debug_80211 & D80211_IMPROVE) \
57 printf("%s:%d: XXX LKPI80211 IMPROVE\n", __func__, __LINE__)
59 enum rfkill_hard_block_reasons {
60 RFKILL_HARD_BLOCK_NOT_OWNER = BIT(0),
63 #define WIPHY_PARAM_FRAG_THRESHOLD __LINE__ /* TODO FIXME brcmfmac */
64 #define WIPHY_PARAM_RETRY_LONG __LINE__ /* TODO FIXME brcmfmac */
65 #define WIPHY_PARAM_RETRY_SHORT __LINE__ /* TODO FIXME brcmfmac */
66 #define WIPHY_PARAM_RTS_THRESHOLD __LINE__ /* TODO FIXME brcmfmac */
68 #define CFG80211_SIGNAL_TYPE_MBM __LINE__ /* TODO FIXME brcmfmac */
70 #define UPDATE_ASSOC_IES 1
72 #define IEEE80211_MAX_CHAINS 4 /* net80211: IEEE80211_MAX_CHAINS copied */
74 enum cfg80211_rate_info_flags {
75 RATE_INFO_FLAGS_SHORT_GI = BIT(0),
76 RATE_INFO_FLAGS_MCS = BIT(1),
77 RATE_INFO_FLAGS_VHT_MCS = BIT(2),
78 RATE_INFO_FLAGS_HE_MCS = BIT(3),
81 extern const uint8_t rfc1042_header[6];
82 extern const uint8_t bridge_tunnel_header[6];
84 enum ieee80211_privacy {
85 IEEE80211_PRIVACY_ANY,
88 enum ieee80211_bss_type {
89 IEEE80211_BSS_TYPE_ANY,
92 enum cfg80211_bss_frame_type {
93 CFG80211_BSS_FTYPE_UNKNOWN,
94 CFG80211_BSS_FTYPE_BEACON,
95 CFG80211_BSS_FTYPE_PRESP,
98 enum ieee80211_channel_flags {
99 IEEE80211_CHAN_DISABLED = BIT(0),
100 IEEE80211_CHAN_INDOOR_ONLY = BIT(1),
101 IEEE80211_CHAN_IR_CONCURRENT = BIT(2),
102 IEEE80211_CHAN_RADAR = BIT(3),
103 IEEE80211_CHAN_NO_IR = BIT(4),
104 IEEE80211_CHAN_NO_HT40MINUS = BIT(5),
105 IEEE80211_CHAN_NO_HT40PLUS = BIT(6),
106 IEEE80211_CHAN_NO_80MHZ = BIT(7),
107 IEEE80211_CHAN_NO_160MHZ = BIT(8),
108 IEEE80211_CHAN_NO_OFDM = BIT(9),
110 #define IEEE80211_CHAN_NO_HT40 (IEEE80211_CHAN_NO_HT40MINUS|IEEE80211_CHAN_NO_HT40PLUS)
112 struct ieee80211_txrx_stypes {
117 /* XXX net80211 has an ieee80211_channel as well. */
118 struct linuxkpi_ieee80211_channel {
120 uint32_t hw_value; /* ic_ieee */
121 uint32_t center_freq; /* ic_freq */
122 enum ieee80211_channel_flags flags; /* ic_flags */
123 enum nl80211_band band;
124 int8_t max_power; /* ic_maxpower */
126 int max_antenna_gain, max_reg_power;
128 int dfs_cac_ms, dfs_state;
132 struct cfg80211_bitrate_mask {
134 /* This is so weird but nothing else works out...*/
136 uint64_t legacy; /* XXX? */
137 uint8_t ht_mcs[IEEE80211_HT_MCS_MASK_LEN];
138 uint16_t vht_mcs[16]; /* XXX? */
139 uint16_t he_mcs[16]; /* XXX? */
140 enum nl80211_txrate_gi gi;
141 enum nl80211_he_gi he_gi;
143 } control[NUM_NL80211_BANDS];
158 int bw, flags, he_dcm, he_gi, he_ru_alloc, legacy, mcs, nss;
161 struct ieee80211_rate {
165 uint32_t hw_value_short;
169 struct ieee80211_sta_ht_cap {
171 int ampdu_density, ampdu_factor;
174 struct ieee80211_mcs_info mcs;
177 /* XXX net80211 calls these IEEE80211_VHTCAP_* */
178 #define IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895 0x00000000 /* IEEE80211_VHTCAP_MAX_MPDU_LENGTH_3895 */
179 #define IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991 0x00000001 /* IEEE80211_VHTCAP_MAX_MPDU_LENGTH_7991 */
180 #define IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454 0x00000002 /* IEEE80211_VHTCAP_MAX_MPDU_LENGTH_11454 */
181 #define IEEE80211_VHT_CAP_MAX_MPDU_MASK 0x00000003 /* IEEE80211_VHTCAP_MAX_MPDU_MASK */
183 #define IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ (IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_160MHZ << IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_MASK_S)
184 #define IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ (IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_160_80P80MHZ << IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_MASK_S)
185 #define IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK 0x0000000c /* IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_MASK */
187 #define IEEE80211_VHT_CAP_RXLDPC 0x00000010 /* IEEE80211_VHTCAP_RXLDPC */
189 #define IEEE80211_VHT_CAP_SHORT_GI_80 0x00000020 /* IEEE80211_VHTCAP_SHORT_GI_80 */
190 #define IEEE80211_VHT_CAP_SHORT_GI_160 0x00000040 /* IEEE80211_VHTCAP_SHORT_GI_160 */
192 #define IEEE80211_VHT_CAP_TXSTBC 0x00000080 /* IEEE80211_VHTCAP_TXSTBC */
194 #define IEEE80211_VHT_CAP_RXSTBC_1 0x00000100 /* IEEE80211_VHTCAP_RXSTBC_1 */
195 #define IEEE80211_VHT_CAP_RXSTBC_MASK 0x00000700 /* IEEE80211_VHTCAP_RXSTBC_MASK */
197 #define IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE 0x00000800 /* IEEE80211_VHTCAP_SU_BEAMFORMER_CAPABLE */
199 #define IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE 0x00001000 /* IEEE80211_VHTCAP_SU_BEAMFORMEE_CAPABLE */
201 #define IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE 0x00080000 /* IEEE80211_VHTCAP_MU_BEAMFORMER_CAPABLE */
203 #define IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE 0x00100000 /* IEEE80211_VHTCAP_MU_BEAMFORMEE_CAPABLE */
205 #define IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT 13 /* IEEE80211_VHTCAP_BEAMFORMEE_STS_SHIFT */
206 #define IEEE80211_VHT_CAP_BEAMFORMEE_STS_MASK (7 << IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT) /* IEEE80211_VHTCAP_BEAMFORMEE_STS_MASK */
208 #define IEEE80211_VHT_CAP_HTC_VHT 0x00400000 /* IEEE80211_VHTCAP_HTC_VHT */
210 #define IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN 0x10000000 /* IEEE80211_VHTCAP_RX_ANTENNA_PATTERN */
211 #define IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN 0x20000000 /* IEEE80211_VHTCAP_TX_ANTENNA_PATTERN */
213 #define IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB 0x0c000000 /* IEEE80211_VHTCAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB */
215 #define IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT 16 /* IEEE80211_VHTCAP_SOUNDING_DIMENSIONS_SHIFT */
216 #define IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_MASK \
217 (7 << IEEE80211_VHTCAP_SOUNDING_DIMENSIONS_SHIFT) /* IEEE80211_VHTCAP_SOUNDING_DIMENSIONS_MASK */
219 #define IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT 23 /* IEEE80211_VHTCAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT */
220 #define IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK \
221 (7 << IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT) /* IEEE80211_VHTCAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK */
224 struct ieee80211_sta_vht_cap {
228 struct vht_mcs vht_mcs;
231 enum ieee80211_vht_opmode {
232 IEEE80211_OPMODE_NOTIF_RX_NSS_SHIFT = 4,
235 struct cfg80211_connect_resp_params {
238 const uint8_t *req_ie;
239 const uint8_t *resp_ie;
241 uint32_t resp_ie_len;
245 struct cfg80211_inform_bss {
247 int boottime_ns, scan_width, signal;
248 struct linuxkpi_ieee80211_channel *chan;
251 struct cfg80211_roam_info {
254 const uint8_t *req_ie;
255 const uint8_t *resp_ie;
257 uint32_t resp_ie_len;
258 struct linuxkpi_ieee80211_channel *channel;
261 struct cfg80211_bss_ies {
262 /* XXX TODO, type is best guess. Fix if more info. */
267 struct cfg80211_bss {
269 struct cfg80211_bss_ies *ies;
272 struct cfg80211_chan_def {
274 struct linuxkpi_ieee80211_channel *chan;
275 enum nl80211_chan_width width;
276 uint32_t center_freq1;
277 uint32_t center_freq2;
280 struct cfg80211_ftm_responder_stats {
282 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;
285 struct cfg80211_pmsr_capabilities {
287 int max_peers, randomize_mac_addr, report_ap_tsf;
289 int asap, bandwidths, max_bursts_exponent, max_ftms_per_burst, non_asap, non_trigger_based, preambles, request_civicloc, request_lci, supported, trigger_based;
293 struct cfg80211_pmsr_ftm_request {
295 int asap, burst_period, ftmr_retries, ftms_per_burst, non_trigger_based, num_bursts_exp, request_civicloc, request_lci, trigger_based;
300 struct cfg80211_pmsr_request_peer {
302 struct cfg80211_chan_def chandef;
303 struct cfg80211_pmsr_ftm_request ftm;
304 uint8_t addr[ETH_ALEN];
308 struct cfg80211_pmsr_request {
310 int cookie, n_peers, timeout;
311 uint8_t mac_addr[ETH_ALEN], mac_addr_mask[ETH_ALEN];
312 struct cfg80211_pmsr_request_peer peers[];
315 struct cfg80211_pmsr_ftm_result {
317 int burst_index, busy_retry_time, failure_reason;
318 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;
325 struct cfg80211_pmsr_result {
327 int ap_tsf, ap_tsf_valid, final, host_time, status, type;
328 uint8_t addr[ETH_ALEN];
329 struct cfg80211_pmsr_ftm_result ftm;
332 struct cfg80211_sar_freq_ranges {
337 struct cfg80211_sar_sub_specs {
338 uint32_t freq_range_index;
342 struct cfg80211_sar_specs {
343 enum nl80211_sar_type type;
344 uint32_t num_sub_specs;
345 struct cfg80211_sar_sub_specs sub_specs[];
348 struct cfg80211_sar_capa {
349 enum nl80211_sar_type type;
350 uint32_t num_freq_ranges;
351 const struct cfg80211_sar_freq_ranges *freq_ranges;
354 struct cfg80211_ssid {
356 uint8_t ssid[IEEE80211_MAX_SSID_LEN];
359 struct cfg80211_scan_6ghz_params {
362 int channel_idx, psc_no_listen, short_ssid, short_ssid_valid, unsolicited_probe;
365 struct cfg80211_match_set {
366 uint8_t bssid[ETH_ALEN];
367 struct cfg80211_ssid ssid;
371 struct cfg80211_scan_request {
373 int duration, duration_mandatory, flags;
376 struct wireless_dev *wdev;
380 uint8_t mac_addr[ETH_ALEN], mac_addr_mask[ETH_ALEN];
381 uint8_t bssid[ETH_ALEN];
385 struct cfg80211_ssid *ssids;
386 struct cfg80211_scan_6ghz_params *scan_6ghz_params;
387 struct linuxkpi_ieee80211_channel *channels[0];
390 struct cfg80211_sched_scan_plan {
392 int interval, iterations;
395 struct cfg80211_sched_scan_request {
398 uint8_t mac_addr[ETH_ALEN], mac_addr_mask[ETH_ALEN];
406 struct cfg80211_match_set *match_sets;
407 struct cfg80211_sched_scan_plan *scan_plans;
408 struct cfg80211_ssid *ssids;
409 struct linuxkpi_ieee80211_channel *channels[0];
412 struct cfg80211_scan_info {
413 uint64_t scan_start_tsf;
414 uint8_t tsf_bssid[ETH_ALEN];
418 struct cfg80211_beacon_data {
424 const uint8_t *proberesp_ies;
425 const uint8_t *assocresp_ies;
426 uint32_t proberesp_ies_len;
427 uint32_t assocresp_ies_len;
430 struct cfg80211_ap_settings {
432 int auth_type, beacon_interval, dtim_period, hidden_ssid, inactivity_timeout;
435 struct cfg80211_beacon_data beacon;
436 struct cfg80211_chan_def chandef;
439 struct cfg80211_bss_selection {
441 enum nl80211_bss_select_attr behaviour;
443 enum nl80211_band band_pref;
445 enum nl80211_band band;
451 struct cfg80211_crypto { /* XXX made up name */
453 enum nl80211_wpa_versions wpa_versions;
454 uint32_t cipher_group; /* WLAN_CIPHER_SUITE_* */
455 uint32_t *akm_suites;
456 uint32_t *ciphers_pairwise;
457 const uint8_t *sae_pwd;
460 int n_ciphers_pairwise;
464 struct cfg80211_connect_params {
466 struct linuxkpi_ieee80211_channel *channel;
474 int auth_type, key_idx, privacy, want_1x;
475 struct cfg80211_bss_selection bss_select;
476 struct cfg80211_crypto crypto;
479 enum bss_param_flags { /* Used as bitflags. XXX FIXME values? */
480 BSS_PARAM_FLAGS_CTS_PROT = 0x01,
481 BSS_PARAM_FLAGS_SHORT_PREAMBLE = 0x02,
482 BSS_PARAM_FLAGS_SHORT_SLOT_TIME = 0x04,
485 struct cfg80211_ibss_params {
487 int basic_rates, beacon_interval;
488 int channel_fixed, ie, ie_len, privacy;
493 struct cfg80211_chan_def chandef;
494 enum bss_param_flags flags;
497 struct cfg80211_mgmt_tx_params {
499 struct linuxkpi_ieee80211_channel *chan;
505 struct cfg80211_pmk_conf {
511 struct cfg80211_pmksa {
513 const uint8_t *bssid;
514 const uint8_t *pmkid;
517 struct cfg80211_wowlan_nd_match {
519 struct cfg80211_ssid ssid;
521 uint32_t channels[0]; /* freq! = ieee80211_channel_to_frequency() */
524 struct cfg80211_wowlan_nd_info {
527 struct cfg80211_wowlan_nd_match *matches[0];
530 enum wiphy_wowlan_support_flags {
531 WIPHY_WOWLAN_DISCONNECT,
532 WIPHY_WOWLAN_GTK_REKEY_FAILURE,
533 WIPHY_WOWLAN_MAGIC_PKT,
534 WIPHY_WOWLAN_SUPPORTS_GTK_REKEY,
535 WIPHY_WOWLAN_NET_DETECT,
538 struct wiphy_wowlan_support {
540 enum wiphy_wowlan_support_flags flags;
541 int max_nd_match_sets, max_pkt_offset, n_patterns, pattern_max_len, pattern_min_len;
544 struct station_del_parameters {
547 uint32_t reason_code; /* elsewhere uint16_t? */
550 struct station_info {
552 int assoc_req_ies_len, connected_time;
553 int generation, inactive_time, rx_bytes, rx_dropped_misc, rx_packets, signal, tx_bytes, tx_packets;
554 int filled, rx_beacon, rx_beacon_signal_avg, signal_avg;
555 int rx_duration, tx_failed, tx_retries;
558 uint8_t chain_signal[IEEE80211_MAX_CHAINS];
559 uint8_t chain_signal_avg[IEEE80211_MAX_CHAINS];
561 uint8_t *assoc_req_ies;
562 struct rate_info rxrate;
563 struct rate_info txrate;
564 struct cfg80211_ibss_params bss_param;
565 struct nl80211_sta_flag_update sta_flags;
568 struct station_parameters {
570 int sta_flags_mask, sta_flags_set;
579 uint32_t cipher; /* WLAN_CIPHER_SUITE_* */
582 struct mgmt_frame_regs {
584 int interface_stypes;
589 uint8_t macaddr[ETH_ALEN];
592 /* That the world needs so many different structs for this is amazing. */
594 uint8_t addr[ETH_ALEN];
597 struct ieee80211_reg_rule {
603 int max_bandwidth_khz;
606 int max_antenna_gain;
611 struct linuxkpi_ieee80211_regdomain {
616 struct ieee80211_reg_rule reg_rules[];
619 /* XXX-BZ this are insensible values probably ... */
620 #define IEEE80211_HE_MAC_CAP0_HTC_HE 0x1
621 #define IEEE80211_HE_MAC_CAP0_TWT_REQ 0x2
622 #define IEEE80211_HE_MAC_CAP0_TWT_RES 0x4
624 #define IEEE80211_HE_MAC_CAP1_LINK_ADAPTATION 0x1
625 #define IEEE80211_HE_MAC_CAP1_MULTI_TID_AGG_RX_QOS_8 0x2
626 #define IEEE80211_HE_MAC_CAP1_TF_MAC_PAD_DUR_16US 0x4
627 #define IEEE80211_HE_MAC_CAP1_TF_MAC_PAD_DUR_MASK 0x8
629 #define IEEE80211_HE_MAC_CAP2_32BIT_BA_BITMAP 0x1
630 #define IEEE80211_HE_MAC_CAP2_ACK_EN 0x2
631 #define IEEE80211_HE_MAC_CAP2_BSR 0x4
632 #define IEEE80211_HE_MAC_CAP2_LINK_ADAPTATION 0x8
633 #define IEEE80211_HE_MAC_CAP2_BCAST_TWT 0x10
634 #define IEEE80211_HE_MAC_CAP2_ALL_ACK 0x20
635 #define IEEE80211_HE_MAC_CAP2_MU_CASCADING 0x40
636 #define IEEE80211_HE_MAC_CAP2_TRS 0x80
638 #define IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_VHT_2 0x1
639 #define IEEE80211_HE_MAC_CAP3_OMI_CONTROL 0x2
640 #define IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_EXT_1 0x10
641 #define IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_EXT_2 0x20
642 #define IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_EXT_3 0x40
643 #define IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_MASK 0x70
644 #define IEEE80211_HE_MAC_CAP3_RX_CTRL_FRAME_TO_MULTIBSS 0x80
645 #define IEEE80211_HE_MAC_CAP3_FLEX_TWT_SCHED 0x80
646 #define IEEE80211_HE_MAC_CAP3_OFDMA_RA 0x80
648 #define IEEE80211_HE_MAC_CAP4_AMDSU_IN_AMPDU 0x1
649 #define IEEE80211_HE_MAC_CAP4_BQR 0x2
650 #define IEEE80211_HE_MAC_CAP4_MULTI_TID_AGG_TX_QOS_B39 0x4
651 #define IEEE80211_HE_MAC_CAP4_AMSDU_IN_AMPDU 0x8
652 #define IEEE80211_HE_MAC_CAP4_OPS 0x10
653 #define IEEE80211_HE_MAC_CAP4_BSRP_BQRP_A_MPDU_AGG 0x20
655 #define IEEE80211_HE_MAC_CAP5_HE_DYNAMIC_SM_PS 0x1
656 #define IEEE80211_HE_MAC_CAP5_HT_VHT_TRIG_FRAME_RX 0x2
657 #define IEEE80211_HE_MAC_CAP5_MULTI_TID_AGG_TX_QOS_B40 0x4
658 #define IEEE80211_HE_MAC_CAP5_MULTI_TID_AGG_TX_QOS_B41 0x8
659 #define IEEE80211_HE_MAC_CAP5_UL_2x996_TONE_RU 0x10
660 #define IEEE80211_HE_MAC_CAP5_OM_CTRL_UL_MU_DATA_DIS_RX 0x20
661 #define IEEE80211_HE_MAC_CAP5_PUNCTURED_SOUNDING 0x40
662 #define IEEE80211_HE_MAC_CAP5_SUBCHAN_SELECTIVE_TRANSMISSION 0x80
664 #define IEEE80211_HE_MCS_NOT_SUPPORTED 0x0
665 #define IEEE80211_HE_MCS_SUPPORT_0_7 0x1
666 #define IEEE80211_HE_MCS_SUPPORT_0_9 0x2
667 #define IEEE80211_HE_MCS_SUPPORT_0_11 0x4
669 #define IEEE80211_HE_6GHZ_CAP_TX_ANTPAT_CONS 0x01
670 #define IEEE80211_HE_6GHZ_CAP_RX_ANTPAT_CONS 0x02
671 #define IEEE80211_HE_6GHZ_CAP_MIN_MPDU_START 0x04
672 #define IEEE80211_HE_6GHZ_CAP_MAX_MPDU_LEN 0x08
673 #define IEEE80211_HE_6GHZ_CAP_MAX_AMPDU_LEN_EXP 0x10
674 #define IEEE80211_HE_6GHZ_CAP_SM_PS 0x20
675 #define IEEE80211_HE_6GHZ_MAX_AMPDU_FACTOR 0x40
677 #define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_160MHZ_IN_5G 0x1
678 #define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_80MHZ_IN_5G 0x2
679 #define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_IN_2G 0x4
680 #define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_80PLUS80_MHZ_IN_5G 0x8
681 #define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_RU_MAPPING_IN_2G 0x10
682 #define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_RU_MAPPING_IN_5G 0x20
683 #define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_MASK 0x40
685 #define IEEE80211_HE_PHY_CAP1_DEVICE_CLASS_A 0x1
686 #define IEEE80211_HE_PHY_CAP1_LDPC_CODING_IN_PAYLOAD 0x2
687 #define IEEE80211_HE_PHY_CAP1_MIDAMBLE_RX_TX_MAX_NSTS 0x4
688 #define IEEE80211_HE_PHY_CAP1_PREAMBLE_PUNC_RX_MASK 0x8
689 #define IEEE80211_HE_PHY_CAP1_HE_LTF_AND_GI_FOR_HE_PPDUS_0_8US 0x10
691 #define IEEE80211_HE_PHY_CAP2_MIDAMBLE_RX_TX_MAX_NSTS 0x1
692 #define IEEE80211_HE_PHY_CAP2_NDP_4x_LTF_AND_3_2US 0x2
693 #define IEEE80211_HE_PHY_CAP2_STBC_TX_UNDER_80MHZ 0x4
694 #define IEEE80211_HE_PHY_CAP2_STBC_RX_UNDER_80MHZ 0x8
695 #define IEEE80211_HE_PHY_CAP2_DOPPLER_TX 0x10
696 #define IEEE80211_HE_PHY_CAP2_UL_MU_PARTIAL_MU_MIMO 0x20
697 #define IEEE80211_HE_PHY_CAP2_UL_MU_FULL_MU_MIMO 0x40
699 #define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_MASK 0x1
700 #define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_NO_DCM 0x2
701 #define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_NO_DCM 0x4
702 #define IEEE80211_HE_PHY_CAP3_DCM_MAX_RX_NSS_1 0x8
703 #define IEEE80211_HE_PHY_CAP3_DCM_MAX_TX_NSS_1 0x10
704 #define IEEE80211_HE_PHY_CAP3_SU_BEAMFORMER 0x20
705 #define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_16_QAM 0x40
706 #define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_16_QAM 0x80
707 #define IEEE80211_HE_PHY_CAP3_DCM_MAX_TX_NSS_2 0x10
708 #define IEEE80211_HE_PHY_CAP3_RX_PARTIAL_BW_SU_IN_20MHZ_MU 0x20
709 #define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_BPSK 0x40
710 #define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_BPSK 0x80
711 #define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_MASK 0x80
712 #define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_QPSK 0x80
713 #define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_QPSK 0x80
714 #define IEEE80211_HE_PHY_CAP3_DCM_MAX_RX_NSS_2 0x80
716 #define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_8 0x1
717 #define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_8 0x2
718 #define IEEE80211_HE_PHY_CAP4_SU_BEAMFORMEE 0x4
719 #define IEEE80211_HE_PHY_CAP4_MU_BEAMFORMER 0x8
720 #define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_4 0x10
721 #define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_4 0x20
722 #define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_MASK 0x40
723 #define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_MASK 0x80
725 #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_2 0x1
726 #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_2 0x2
727 #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_MASK 0x4
728 #define IEEE80211_HE_PHY_CAP5_NG16_MU_FEEDBACK 0x8
729 #define IEEE80211_HE_PHY_CAP5_NG16_SU_FEEDBACK 0x10
730 #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_MASK 0x20
732 #define IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT 0x1
733 #define IEEE80211_HE_PHY_CAP6_TRIG_MU_BEAMFORMER_FB 0x2
734 #define IEEE80211_HE_PHY_CAP6_TRIG_SU_BEAMFORMER_FB 0x4
735 #define IEEE80211_HE_PHY_CAP6_TRIG_SU_BEAMFORMING_FB 0x8
736 #define IEEE80211_HE_PHY_CAP6_TRIG_MU_BEAMFORMING_PARTIAL_BW_FB 0x20
737 #define IEEE80211_HE_PHY_CAP6_CODEBOOK_SIZE_42_SU 0x40
738 #define IEEE80211_HE_PHY_CAP6_CODEBOOK_SIZE_75_MU 0x80
739 #define IEEE80211_HE_PHY_CAP6_PARTIAL_BW_EXT_RANGE 0x80
740 #define IEEE80211_HE_PHY_CAP6_TRIG_CQI_FB 0x80
741 #define IEEE80211_HE_PHY_CAP6_PARTIAL_BANDWIDTH_DL_MUMIMO 0x80
743 #define IEEE80211_HE_PHY_CAP7_HE_SU_MU_PPDU_4XLTF_AND_08_US_GI 0x1
744 #define IEEE80211_HE_PHY_CAP7_MAX_NC_1 0x2
745 #define IEEE80211_HE_PHY_CAP7_MAX_NC_2 0x4
746 #define IEEE80211_HE_PHY_CAP7_MAX_NC_MASK 0x6
747 #define IEEE80211_HE_PHY_CAP7_POWER_BOOST_FACTOR_AR 0x8
748 #define IEEE80211_HE_PHY_CAP7_POWER_BOOST_FACTOR_SUPP 0x10
749 #define IEEE80211_HE_PHY_CAP7_STBC_RX_ABOVE_80MHZ 0x20
750 #define IEEE80211_HE_PHY_CAP7_STBC_TX_ABOVE_80MHZ 0x40
751 #define IEEE80211_HE_PHY_CAP7_PSR_BASED_SR 0x80
753 #define IEEE80211_HE_PHY_CAP8_20MHZ_IN_160MHZ_HE_PPDU 0x1
754 #define IEEE80211_HE_PHY_CAP8_20MHZ_IN_40MHZ_HE_PPDU_IN_2G 0x2
755 #define IEEE80211_HE_PHY_CAP8_80MHZ_IN_160MHZ_HE_PPDU 0x4
756 #define IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_242 0x8
757 #define IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_484 0x10
758 #define IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_996 0x18
759 #define IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_2x996 0x20
760 #define IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_MASK 0x28
761 #define IEEE80211_HE_PHY_CAP8_HE_ER_SU_PPDU_4XLTF_AND_08_US_GI 0x40
762 #define IEEE80211_HE_PHY_CAP8_HE_ER_SU_1XLTF_AND_08_US_GI 0x80
764 #define IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_0US 0x1
765 #define IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_16US 0x2
766 #define IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_8US 0x4
767 #define IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_MASK 0x8
768 #define IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_RESERVED 0x10
769 #define IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_POS 0x0
770 #define IEEE80211_HE_PHY_CAP9_NON_TRIGGERED_CQI_FEEDBACK 0x20
771 #define IEEE80211_HE_PHY_CAP9_RX_FULL_BW_SU_USING_MU_WITH_COMP_SIGB 0x4
772 #define IEEE80211_HE_PHY_CAP9_RX_FULL_BW_SU_USING_MU_WITH_NON_COMP_SIGB 0x8
773 #define IEEE80211_HE_PHY_CAP9_RX_1024_QAM_LESS_THAN_242_TONE_RU 0x10
774 #define IEEE80211_HE_PHY_CAP9_TX_1024_QAM_LESS_THAN_242_TONE_RU 0x20
775 #define IEEE80211_HE_PHY_CAP9_LONGER_THAN_16_SIGB_OFDM_SYM 0x40
777 #define IEEE80211_HE_PHY_CAP10_HE_MU_M1RU_MAX_LTF 0x1
779 #define VENDOR_CMD_RAW_DATA (void *)(uintptr_t)(-ENOENT)
781 struct ieee80211_he_cap_elem {
786 struct ieee80211_he_mcs_nss_supp {
792 uint32_t rx_mcs_80p80;
793 uint32_t tx_mcs_80p80;
796 #define IEEE80211_STA_HE_CAP_PPE_THRES_MAX 32
797 struct ieee80211_sta_he_cap {
800 struct ieee80211_he_cap_elem he_cap_elem;
801 struct ieee80211_he_mcs_nss_supp he_mcs_nss_supp;
802 uint8_t ppe_thres[IEEE80211_STA_HE_CAP_PPE_THRES_MAX];
805 struct cfg80211_he_bss_color {
809 struct ieee80211_he_obss_pd {
813 struct ieee80211_sta_he_6ghz_capa {
818 struct ieee80211_sband_iftype_data {
820 enum nl80211_iftype types_mask;
821 struct ieee80211_sta_he_cap he_cap;
822 struct ieee80211_sta_he_6ghz_capa he_6ghz_capa;
829 struct ieee80211_supported_band {
831 struct linuxkpi_ieee80211_channel *channels;
832 struct ieee80211_rate *bitrates;
833 struct ieee80211_sband_iftype_data *iftype_data;
837 enum nl80211_band band;
838 struct ieee80211_sta_ht_cap ht_cap;
839 struct ieee80211_sta_vht_cap vht_cap;
842 struct cfg80211_pkt_pattern {
850 struct cfg80211_wowlan {
852 int disconnect, gtk_rekey_failure, magic_pkt;
854 struct cfg80211_sched_scan_request *nd_config;
855 struct cfg80211_pkt_pattern *patterns;
858 struct cfg80211_gtk_rekey_data {
860 int kck, kek, replay_ctr;
863 struct cfg80211_tid_cfg {
865 int mask, noack, retry_long, rtscts, tids;
866 enum nl80211_tx_rate_setting txrate_type;
867 struct cfg80211_bitrate_mask txrate_mask;
870 struct cfg80211_tid_config {
873 struct cfg80211_tid_cfg tid_conf[0];
876 struct ieee80211_iface_limit {
881 struct ieee80211_iface_combination {
883 const struct ieee80211_iface_limit *limits;
885 int max_interfaces, num_different_channels;
886 int beacon_int_infra_match, beacon_int_min_gcd;
887 int radar_detect_widths;
890 struct iface_combination_params {
891 int num_different_channels;
892 int iftype_num[NUM_NL80211_IFTYPES];
895 struct regulatory_request {
898 int initiator, dfs_region;
901 enum wiphy_vendor_cmd_need_flags {
902 WIPHY_VENDOR_CMD_NEED_NETDEV = 0x01,
903 WIPHY_VENDOR_CMD_NEED_RUNNING = 0x02,
904 WIPHY_VENDOR_CMD_NEED_WDEV = 0x04,
907 struct wiphy_vendor_command {
914 int (*doit)(struct wiphy *, struct wireless_dev *, const void *, int);
917 struct wiphy_iftype_ext_capab {
919 enum nl80211_iftype iftype;
920 const uint8_t *extended_capabilities;
921 const uint8_t *extended_capabilities_mask;
922 uint8_t extended_capabilities_len;
926 struct tid_config_support {
928 uint64_t vif; /* enum nl80211_tid_cfg_attr */
929 uint64_t peer; /* enum nl80211_tid_cfg_attr */
932 enum cfg80211_regulatory {
933 REGULATORY_CUSTOM_REG = BIT(0),
934 REGULATORY_STRICT_REG = BIT(1),
935 REGULATORY_DISABLE_BEACON_HINTS = BIT(2),
936 REGULATORY_ENABLE_RELAX_NO_IR = BIT(3),
937 REGULATORY_WIPHY_SELF_MANAGED = BIT(4),
938 REGULATORY_COUNTRY_IE_IGNORE = BIT(5),
939 REGULATORY_COUNTRY_IE_FOLLOW_POWER = BIT(6),
943 WIPHY_FLAG_AP_UAPSD = BIT(0),
944 WIPHY_FLAG_HAS_CHANNEL_SWITCH = BIT(1),
945 WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL = BIT(2),
946 WIPHY_FLAG_HAVE_AP_SME = BIT(3),
947 WIPHY_FLAG_IBSS_RSN = BIT(4),
948 WIPHY_FLAG_NETNS_OK = BIT(5),
949 WIPHY_FLAG_OFFCHAN_TX = BIT(6),
950 WIPHY_FLAG_PS_ON_BY_DEFAULT = BIT(7),
951 WIPHY_FLAG_SPLIT_SCAN_6GHZ = BIT(8),
952 WIPHY_FLAG_SUPPORTS_EXT_KEK_KCK = BIT(9),
953 WIPHY_FLAG_SUPPORTS_FW_ROAM = BIT(10),
954 WIPHY_FLAG_SUPPORTS_TDLS = BIT(11),
955 WIPHY_FLAG_TDLS_EXTERNAL_SETUP = BIT(12),
956 WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD = BIT(13),
957 WIPHY_FLAG_4ADDR_AP = BIT(14),
958 WIPHY_FLAG_4ADDR_STATION = BIT(15),
964 struct mac_address *addresses;
967 struct ieee80211_supported_band *bands[NUM_NL80211_BANDS];
968 uint8_t perm_addr[ETH_ALEN];
971 const struct cfg80211_pmsr_capabilities *pmsr_capa;
972 const struct cfg80211_sar_capa *sar_capa;
973 const struct wiphy_iftype_ext_capab *iftype_ext_capab;
974 const struct linuxkpi_ieee80211_regdomain *regd;
975 char fw_version[ETHTOOL_FWVERS_LEN];
976 const struct ieee80211_iface_combination *iface_combinations;
977 const uint32_t *cipher_suites;
978 int n_iface_combinations;
980 void(*reg_notifier)(struct wiphy *, struct regulatory_request *);
981 enum cfg80211_regulatory regulatory_flags;
982 int n_vendor_commands;
983 const struct wiphy_vendor_command *vendor_commands;
984 const struct ieee80211_txrx_stypes *mgmt_stypes;
985 uint32_t rts_threshold;
986 uint32_t frag_threshold;
987 struct tid_config_support tid_config_support;
989 int available_antennas_rx, available_antennas_tx;
990 int features, hw_version;
991 int interface_modes, max_match_sets, max_remain_on_channel_duration, max_scan_ie_len, 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;
992 int num_iftype_ext_capab;
993 int max_ap_assoc_sta, probe_resp_offload, software_iftypes;
994 int bss_select_support, max_num_pmkids, retry_long, retry_short, signal_type;
995 int max_data_retry_count;
996 int tx_queue_len, rfkill;
997 int mbssid_max_interfaces;
999 unsigned long ext_features[BITS_TO_LONGS(NUM_NL80211_EXT_FEATURES)];
1000 struct dentry *debugfsdir;
1001 struct cfg80211_wowlan_support *wowlan;
1002 /* Lower layer (driver/mac80211) specific data. */
1003 /* Must stay last. */
1004 uint8_t priv[0] __aligned(CACHE_LINE_SIZE);
1007 struct wireless_dev {
1008 /* XXX TODO, like ic? */
1011 struct net_device *netdev;
1012 struct wiphy *wiphy;
1015 struct cfg80211_ops {
1017 struct wireless_dev *(*add_virtual_intf)(struct wiphy *, const char *, unsigned char, enum nl80211_iftype, struct vif_params *);
1018 int (*del_virtual_intf)(struct wiphy *, struct wireless_dev *);
1019 s32 (*change_virtual_intf)(struct wiphy *, struct net_device *, enum nl80211_iftype, struct vif_params *);
1020 s32 (*scan)(struct wiphy *, struct cfg80211_scan_request *);
1021 s32 (*set_wiphy_params)(struct wiphy *, u32);
1022 s32 (*join_ibss)(struct wiphy *, struct net_device *, struct cfg80211_ibss_params *);
1023 s32 (*leave_ibss)(struct wiphy *, struct net_device *);
1024 s32 (*get_station)(struct wiphy *, struct net_device *, const u8 *, struct station_info *);
1025 int (*dump_station)(struct wiphy *, struct net_device *, int, u8 *, struct station_info *);
1026 s32 (*set_tx_power)(struct wiphy *, struct wireless_dev *, enum nl80211_tx_power_setting, s32);
1027 s32 (*get_tx_power)(struct wiphy *, struct wireless_dev *, s32 *);
1028 s32 (*add_key)(struct wiphy *, struct net_device *, u8, bool, const u8 *, struct key_params *);
1029 s32 (*del_key)(struct wiphy *, struct net_device *, u8, bool, const u8 *);
1030 s32 (*get_key)(struct wiphy *, struct net_device *, u8, bool, const u8 *, void *, void(*)(void *, struct key_params *));
1031 s32 (*set_default_key)(struct wiphy *, struct net_device *, u8, bool, bool);
1032 s32 (*set_default_mgmt_key)(struct wiphy *, struct net_device *, u8);
1033 s32 (*set_power_mgmt)(struct wiphy *, struct net_device *, bool, s32);
1034 s32 (*connect)(struct wiphy *, struct net_device *, struct cfg80211_connect_params *);
1035 s32 (*disconnect)(struct wiphy *, struct net_device *, u16);
1036 s32 (*suspend)(struct wiphy *, struct cfg80211_wowlan *);
1037 s32 (*resume)(struct wiphy *);
1038 s32 (*set_pmksa)(struct wiphy *, struct net_device *, struct cfg80211_pmksa *);
1039 s32 (*del_pmksa)(struct wiphy *, struct net_device *, struct cfg80211_pmksa *);
1040 s32 (*flush_pmksa)(struct wiphy *, struct net_device *);
1041 s32 (*start_ap)(struct wiphy *, struct net_device *, struct cfg80211_ap_settings *);
1042 int (*stop_ap)(struct wiphy *, struct net_device *);
1043 s32 (*change_beacon)(struct wiphy *, struct net_device *, struct cfg80211_beacon_data *);
1044 int (*del_station)(struct wiphy *, struct net_device *, struct station_del_parameters *);
1045 int (*change_station)(struct wiphy *, struct net_device *, const u8 *, struct station_parameters *);
1046 int (*sched_scan_start)(struct wiphy *, struct net_device *, struct cfg80211_sched_scan_request *);
1047 int (*sched_scan_stop)(struct wiphy *, struct net_device *, u64);
1048 void (*update_mgmt_frame_registrations)(struct wiphy *, struct wireless_dev *, struct mgmt_frame_regs *);
1049 int (*mgmt_tx)(struct wiphy *, struct wireless_dev *, struct cfg80211_mgmt_tx_params *, u64 *);
1050 int (*cancel_remain_on_channel)(struct wiphy *, struct wireless_dev *, u64);
1051 int (*get_channel)(struct wiphy *, struct wireless_dev *, struct cfg80211_chan_def *);
1052 int (*crit_proto_start)(struct wiphy *, struct wireless_dev *, enum nl80211_crit_proto_id, u16);
1053 void (*crit_proto_stop)(struct wiphy *, struct wireless_dev *);
1054 int (*tdls_oper)(struct wiphy *, struct net_device *, const u8 *, enum nl80211_tdls_operation);
1055 int (*update_connect_params)(struct wiphy *, struct net_device *, struct cfg80211_connect_params *, u32);
1056 int (*set_pmk)(struct wiphy *, struct net_device *, const struct cfg80211_pmk_conf *);
1057 int (*del_pmk)(struct wiphy *, struct net_device *, const u8 *);
1058 int (*remain_on_channel)(struct wiphy *, struct wireless_dev *, struct linuxkpi_ieee80211_channel *, unsigned int, u64 *);
1059 int (*start_p2p_device)(struct wiphy *, struct wireless_dev *);
1060 void (*stop_p2p_device)(struct wiphy *, struct wireless_dev *);
1064 /* -------------------------------------------------------------------------- */
1068 struct wiphy *linuxkpi_wiphy_new(const struct cfg80211_ops *, size_t);
1069 void linuxkpi_wiphy_free(struct wiphy *wiphy);
1071 int linuxkpi_regulatory_set_wiphy_regd_sync(struct wiphy *wiphy,
1072 struct linuxkpi_ieee80211_regdomain *regd);
1073 uint32_t linuxkpi_ieee80211_channel_to_frequency(uint32_t, enum nl80211_band);
1074 uint32_t linuxkpi_ieee80211_frequency_to_channel(uint32_t, uint32_t);
1075 struct linuxkpi_ieee80211_channel *
1076 linuxkpi_ieee80211_get_channel(struct wiphy *, uint32_t);
1077 void linuxkpi_cfg80211_bss_flush(struct wiphy *);
1079 /* -------------------------------------------------------------------------- */
1081 static __inline struct wiphy *
1082 wiphy_new(const struct cfg80211_ops *ops, size_t priv_len)
1085 return (linuxkpi_wiphy_new(ops, priv_len));
1088 static __inline void
1089 wiphy_free(struct wiphy *wiphy)
1092 linuxkpi_wiphy_free(wiphy);
1095 static __inline void *
1096 wiphy_priv(struct wiphy *wiphy)
1099 return (wiphy->priv);
1102 static __inline void
1103 set_wiphy_dev(struct wiphy *wiphy, struct device *dev)
1109 static __inline struct device *
1110 wiphy_dev(struct wiphy *wiphy)
1113 return (wiphy->dev);
1116 #define wiphy_err(_wiphy, _fmt, ...) \
1117 dev_err((_wiphy)->dev, _fmt, __VA_ARGS__)
1119 static __inline const struct linuxkpi_ieee80211_regdomain *
1120 wiphy_dereference(struct wiphy *wiphy,
1121 const struct linuxkpi_ieee80211_regdomain *regd)
1127 static __inline void
1128 wiphy_lock(struct wiphy *wiphy)
1133 static __inline void
1134 wiphy_unlock(struct wiphy *wiphy)
1139 static __inline void
1140 wiphy_rfkill_set_hw_state_reason(struct wiphy *wiphy, bool blocked,
1141 enum rfkill_hard_block_reasons reason)
1146 /* -------------------------------------------------------------------------- */
1148 static __inline bool
1149 rfkill_blocked(int rfkill) /* argument type? */
1155 static __inline bool
1156 rfkill_soft_blocked(int rfkill)
1163 reg_query_regdb_wmm(uint8_t *alpha2, uint32_t center_freq,
1164 struct ieee80211_reg_rule *rule)
1167 /* ETSI has special rules. FreeBSD regdb needs to learn about them. */
1173 static __inline const u8 *
1174 cfg80211_find_ie_match(uint32_t f, const u8 *ies, size_t ies_len,
1175 const u8 *match, int x, int y)
1181 static __inline const u8 *
1182 cfg80211_find_ie(uint8_t eid, const uint8_t *ie, uint32_t ielen)
1188 static __inline void
1189 cfg80211_pmsr_complete(struct wireless_dev *wdev,
1190 struct cfg80211_pmsr_request *req, gfp_t gfp)
1195 static __inline void
1196 cfg80211_pmsr_report(struct wireless_dev *wdev,
1197 struct cfg80211_pmsr_request *req,
1198 struct cfg80211_pmsr_result *result, gfp_t gfp)
1203 static __inline void
1204 cfg80211_chandef_create(struct cfg80211_chan_def *chandef,
1205 struct linuxkpi_ieee80211_channel *chan, enum nl80211_chan_flags chan_flag)
1208 KASSERT(chandef != NULL, ("%s: chandef is NULL\n", __func__));
1209 KASSERT(chan != NULL, ("%s: chan is NULL\n", __func__));
1211 memset(chandef, 0, sizeof(*chandef));
1212 chandef->chan = chan;
1213 chandef->center_freq2 = 0; /* Set here and only overwrite if needed. */
1215 switch (chan_flag) {
1216 case NL80211_CHAN_NO_HT:
1217 chandef->width = NL80211_CHAN_WIDTH_20_NOHT;
1218 chandef->center_freq1 = chan->center_freq;
1221 if (chan->flags & IEEE80211_CHAN_NO_HT40)
1222 chandef->width = NL80211_CHAN_WIDTH_20;
1223 else if (chan->flags & IEEE80211_CHAN_NO_80MHZ)
1224 chandef->width = NL80211_CHAN_WIDTH_40;
1225 else if (chan->flags & IEEE80211_CHAN_NO_160MHZ)
1226 chandef->width = NL80211_CHAN_WIDTH_80;
1228 chandef->width = NL80211_CHAN_WIDTH_160;
1229 IMPROVE("80P80 and 320 ...");
1231 chandef->center_freq1 = chan->center_freq;
1236 static __inline void
1237 cfg80211_bss_iter(struct wiphy *wiphy, struct cfg80211_chan_def *chandef,
1238 void (*iterfunc)(struct wiphy *, struct cfg80211_bss *, void *), void *data)
1249 static __inline const struct element *
1250 cfg80211_find_elem(enum ieee80211_eid eid, uint8_t *data, size_t len)
1256 static __inline uint32_t
1257 cfg80211_calculate_bitrate(struct rate_info *rate)
1263 static __inline uint32_t
1264 ieee80211_channel_to_frequency(uint32_t channel, enum nl80211_band band)
1267 return (linuxkpi_ieee80211_channel_to_frequency(channel, band));
1270 static __inline uint32_t
1271 ieee80211_frequency_to_channel(uint32_t freq)
1274 return (linuxkpi_ieee80211_frequency_to_channel(freq, 0));
1278 regulatory_set_wiphy_regd_sync(struct wiphy *wiphy,
1279 struct linuxkpi_ieee80211_regdomain *regd)
1282 return (linuxkpi_regulatory_set_wiphy_regd_sync(wiphy, regd));
1286 regulatory_set_wiphy_regd_sync_rtnl(struct wiphy *wiphy,
1287 struct linuxkpi_ieee80211_regdomain *regd)
1291 return (linuxkpi_regulatory_set_wiphy_regd_sync(wiphy, regd));
1295 regulatory_set_wiphy_regd(struct wiphy *wiphy,
1296 struct linuxkpi_ieee80211_regdomain *regd)
1303 /* XXX-BZ wild guessing here based on brcmfmac. */
1304 if (wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED)
1309 /* XXX FIXME, do we have to do anything with reg_notifier? */
1314 regulatory_hint(struct wiphy *wiphy, const uint8_t *alpha2)
1320 static __inline const char *
1321 reg_initiator_name(enum nl80211_reg_initiator initiator)
1327 static __inline struct linuxkpi_ieee80211_regdomain *
1328 rtnl_dereference(const struct linuxkpi_ieee80211_regdomain *regd)
1334 static __inline struct ieee80211_reg_rule *
1335 freq_reg_info(struct wiphy *wiphy, uint32_t center_freq)
1341 static __inline struct cfg80211_bss *
1342 cfg80211_get_bss(struct wiphy *wiphy, struct linuxkpi_ieee80211_channel *chan,
1343 uint8_t *bssid, void *p, int x, uint32_t f1, uint32_t f2)
1349 static __inline void
1350 cfg80211_put_bss(struct wiphy *wiphy, struct cfg80211_bss *bss)
1355 static __inline void
1356 wiphy_apply_custom_regulatory(struct wiphy *wiphy,
1357 const struct linuxkpi_ieee80211_regdomain *regd)
1362 static __inline char *
1363 wiphy_name(struct wiphy *wiphy)
1365 if (wiphy != NULL && wiphy->dev != NULL)
1366 return dev_name(wiphy->dev);
1373 static __inline void
1374 wiphy_read_of_freq_limits(struct wiphy *wiphy)
1381 static __inline uint8_t *
1382 cfg80211_find_vendor_ie(unsigned int oui, u8 oui_type,
1383 uint8_t *data, size_t len)
1389 static __inline void
1390 wiphy_ext_feature_set(struct wiphy *wiphy, enum nl80211_ext_feature ef)
1393 set_bit(ef, wiphy->ext_features);
1396 static __inline void *
1397 wiphy_net(struct wiphy *wiphy)
1400 return (NULL); /* XXX passed to dev_net_set() */
1404 wiphy_register(struct wiphy *wiphy)
1410 static __inline void
1411 wiphy_unregister(struct wiphy *wiphy)
1416 static __inline void
1417 wiphy_warn(struct wiphy *wiphy, const char *fmt, ...)
1423 cfg80211_check_combinations(struct wiphy *wiphy,
1424 struct iface_combination_params *params)
1430 static __inline uint8_t
1431 cfg80211_classify8021d(struct sk_buff *skb, void *p)
1437 static __inline void
1438 cfg80211_connect_done(struct net_device *ndev,
1439 struct cfg80211_connect_resp_params *conn_params, gfp_t gfp)
1444 static __inline void
1445 cfg80211_crit_proto_stopped(struct wireless_dev *wdev, gfp_t gfp)
1450 static __inline void
1451 cfg80211_disconnected(struct net_device *ndev, uint16_t reason,
1452 void *p, int x, bool locally_generated, gfp_t gfp)
1458 cfg80211_get_p2p_attr(const u8 *ie, u32 ie_len,
1459 enum ieee80211_p2p_attr_ids attr, u8 *p, size_t p_len)
1465 static __inline void
1466 cfg80211_ibss_joined(struct net_device *ndev, const uint8_t *addr,
1467 struct linuxkpi_ieee80211_channel *chan, gfp_t gfp)
1472 static __inline struct cfg80211_bss *
1473 cfg80211_inform_bss(struct wiphy *wiphy,
1474 struct linuxkpi_ieee80211_channel *channel,
1475 enum cfg80211_bss_frame_type bss_ftype, const uint8_t *bss, int _x,
1476 uint16_t cap, uint16_t intvl, const uint8_t *ie, size_t ie_len,
1477 int signal, gfp_t gfp)
1483 static __inline struct cfg80211_bss *
1484 cfg80211_inform_bss_data(struct wiphy *wiphy,
1485 struct cfg80211_inform_bss *bss_data,
1486 enum cfg80211_bss_frame_type bss_ftype, const uint8_t *bss, int _x,
1487 uint16_t cap, uint16_t intvl, const uint8_t *ie, size_t ie_len, gfp_t gfp)
1493 static __inline void
1494 cfg80211_mgmt_tx_status(struct wireless_dev *wdev, uint64_t cookie,
1495 const u8 *buf, size_t len, bool ack, gfp_t gfp)
1500 static __inline void
1501 cfg80211_michael_mic_failure(struct net_device *ndev, const uint8_t *addr,
1502 enum nl80211_key_type key_type, int _x, void *p, gfp_t gfp)
1507 static __inline void
1508 cfg80211_new_sta(struct net_device *ndev, const uint8_t *addr,
1509 struct station_info *sinfo, gfp_t gfp)
1514 static __inline void
1515 cfg80211_del_sta(struct net_device *ndev, const uint8_t *addr, gfp_t gfp)
1520 static __inline void
1521 cfg80211_port_authorized(struct net_device *ndev, const uint8_t *bssid,
1527 static __inline void
1528 cfg80211_ready_on_channel(struct wireless_dev *wdev, uint64_t cookie,
1529 struct linuxkpi_ieee80211_channel *channel, unsigned int duration,
1535 static __inline void
1536 cfg80211_remain_on_channel_expired(struct wireless_dev *wdev,
1537 uint64_t cookie, struct linuxkpi_ieee80211_channel *channel, gfp_t gfp)
1542 static __inline void
1543 cfg80211_report_wowlan_wakeup(void)
1548 static __inline void
1549 cfg80211_roamed(struct net_device *ndev, struct cfg80211_roam_info *roam_info,
1555 static __inline void
1556 cfg80211_rx_mgmt(struct wireless_dev *wdev, int freq, int _x,
1557 uint8_t *p, size_t p_len, int _x2)
1562 static __inline void
1563 cfg80211_scan_done(struct cfg80211_scan_request *scan_request,
1564 struct cfg80211_scan_info *info)
1569 static __inline void
1570 cfg80211_sched_scan_results(struct wiphy *wiphy, uint64_t reqid)
1575 static __inline void
1576 cfg80211_sched_scan_stopped(struct wiphy *wiphy, int _x)
1581 static __inline void
1582 cfg80211_unregister_wdev(struct wireless_dev *wdev)
1587 static __inline struct sk_buff *
1588 cfg80211_vendor_cmd_alloc_reply_skb(struct wiphy *wiphy, unsigned int len)
1595 cfg80211_vendor_cmd_reply(struct sk_buff *skb)
1601 static __inline struct linuxkpi_ieee80211_channel *
1602 ieee80211_get_channel(struct wiphy *wiphy, uint32_t freq)
1605 return (linuxkpi_ieee80211_get_channel(wiphy, freq));
1608 static __inline size_t
1609 ieee80211_get_hdrlen_from_skb(struct sk_buff *skb)
1616 static __inline void
1617 cfg80211_bss_flush(struct wiphy *wiphy)
1620 linuxkpi_cfg80211_bss_flush(wiphy);
1623 static __inline bool
1624 cfg80211_channel_is_psc(struct linuxkpi_ieee80211_channel *channel)
1628 if (channel->band != NL80211_BAND_6GHZ)
1636 cfg80211_get_ies_channel_number(const uint8_t *ie, size_t len,
1637 enum nl80211_band band, enum cfg80211_bss_frame_type ftype)
1644 /* Used for scanning at least. */
1645 static __inline void
1646 get_random_mask_addr(uint8_t *dst, const uint8_t *addr, const uint8_t *mask)
1650 /* Get a completely random address and then overlay what we want. */
1651 get_random_bytes(dst, ETH_ALEN);
1652 for (i = 0; i < ETH_ALEN; i++)
1653 dst[i] = (dst[i] & ~(mask[i])) | (addr[i] & mask[i]);
1656 static __inline void
1657 cfg80211_shutdown_all_interfaces(struct wiphy *wiphy)
1662 static __inline bool
1663 cfg80211_reg_can_beacon(struct wiphy *wiphy, struct cfg80211_chan_def *chandef,
1664 enum nl80211_iftype iftype)
1670 static __inline void
1671 cfg80211_background_radar_event(struct wiphy *wiphy,
1672 struct cfg80211_chan_def *chandef, gfp_t gfp)
1677 static __inline const u8 *
1678 cfg80211_find_ext_ie(uint8_t eid, uint8_t *p, size_t len)
1684 static __inline bool
1685 cfg80211_chandef_valid(const struct cfg80211_chan_def *chandef)
1691 #define wiphy_info(wiphy, fmt, ...) \
1692 printf("%s:%d XXX TODO " fmt, __func__, __LINE__, __VA_ARGS__)
1694 #ifndef LINUXKPI_NET80211
1695 #define ieee80211_channel linuxkpi_ieee80211_channel
1696 #define ieee80211_regdomain linuxkpi_ieee80211_regdomain
1699 #endif /* _LINUXKPI_NET_CFG80211_H */