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