1 /*- 2 * Copyright (c) 2020-2021 The FreeBSD Foundation 3 * Copyright (c) 2021 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 * $FreeBSD$ 30 */ 31 32 #ifndef _LINUXKPI_NET_CFG80211_H 33 #define _LINUXKPI_NET_CFG80211_H 34 35 #include <linux/types.h> 36 #include <linux/nl80211.h> 37 #include <linux/ieee80211.h> 38 #include <linux/if_ether.h> 39 #include <linux/device.h> 40 #include <linux/netdevice.h> 41 #include <linux/random.h> 42 #include <linux/skbuff.h> 43 44 /* linux_80211.c */ 45 extern int debug_80211; 46 #ifndef D80211_TODO 47 #define D80211_TODO 0x1 48 #endif 49 #ifndef D80211_IMPROVE 50 #define D80211_IMPROVE 0x2 51 #endif 52 #define TODO() if (debug_80211 & D80211_TODO) \ 53 printf("%s:%d: XXX LKPI80211 TODO\n", __func__, __LINE__) 54 #define IMPROVE(...) if (debug_80211 & D80211_IMPROVE) \ 55 printf("%s:%d: XXX LKPI80211 IMPROVE\n", __func__, __LINE__) 56 57 #define WIPHY_PARAM_FRAG_THRESHOLD __LINE__ /* TODO FIXME brcmfmac */ 58 #define WIPHY_PARAM_RETRY_LONG __LINE__ /* TODO FIXME brcmfmac */ 59 #define WIPHY_PARAM_RETRY_SHORT __LINE__ /* TODO FIXME brcmfmac */ 60 #define WIPHY_PARAM_RTS_THRESHOLD __LINE__ /* TODO FIXME brcmfmac */ 61 62 #define CFG80211_SIGNAL_TYPE_MBM __LINE__ /* TODO FIXME brcmfmac */ 63 64 #define UPDATE_ASSOC_IES 1 65 66 #define IEEE80211_MAX_CHAINS 4 /* net80211: IEEE80211_MAX_CHAINS copied */ 67 68 enum cfg80211_rate_info_flags { 69 RATE_INFO_FLAGS_SHORT_GI = BIT(0), 70 RATE_INFO_FLAGS_MCS = BIT(1), 71 RATE_INFO_FLAGS_VHT_MCS = BIT(2), 72 RATE_INFO_FLAGS_HE_MCS = BIT(3), 73 }; 74 75 extern const uint8_t rfc1042_header[6]; 76 77 enum cfg80211_bss_ftypes { 78 CFG80211_BSS_FTYPE_UNKNOWN, 79 }; 80 81 enum ieee80211_channel_flags { 82 IEEE80211_CHAN_DISABLED = 1, 83 IEEE80211_CHAN_INDOOR_ONLY, 84 IEEE80211_CHAN_IR_CONCURRENT, 85 IEEE80211_CHAN_RADAR, 86 IEEE80211_CHAN_NO_IR, 87 IEEE80211_CHAN_NO_HT40MINUS, 88 IEEE80211_CHAN_NO_HT40PLUS, 89 IEEE80211_CHAN_NO_80MHZ, 90 IEEE80211_CHAN_NO_160MHZ, 91 }; 92 #define IEEE80211_CHAN_NO_HT40 (IEEE80211_CHAN_NO_HT40MINUS|IEEE80211_CHAN_NO_HT40PLUS) 93 94 struct ieee80211_txrx_stypes { 95 uint16_t tx; 96 uint16_t rx; 97 }; 98 99 /* XXX net80211 has an ieee80211_channel as well. */ 100 struct linuxkpi_ieee80211_channel { 101 /* TODO FIXME */ 102 uint32_t hw_value; /* ic_ieee */ 103 uint32_t center_freq; /* ic_freq */ 104 enum ieee80211_channel_flags flags; /* ic_flags */ 105 enum nl80211_band band; 106 int8_t max_power; /* ic_maxpower */ 107 bool beacon_found; 108 int max_antenna_gain, max_reg_power; 109 int orig_flags; 110 }; 111 112 enum ieee80211_vht_mcs_support { 113 LKPI_IEEE80211_VHT_MCS_SUPPORT_0_7, 114 LKPI_IEEE80211_VHT_MCS_SUPPORT_0_8, 115 LKPI_IEEE80211_VHT_MCS_SUPPORT_0_9, 116 }; 117 118 struct cfg80211_bitrate_mask { 119 /* TODO FIXME */ 120 /* This is so weird but nothing else works out...*/ 121 struct { 122 uint64_t legacy; /* XXX? */ 123 uint8_t ht_mcs[16]; /* XXX? */ 124 uint16_t vht_mcs[16]; /* XXX? */ 125 uint8_t gi; /* NL80211_TXRATE_FORCE_LGI enum? */ 126 } control[NUM_NL80211_BANDS]; 127 }; 128 129 struct rate_info { 130 /* TODO FIXME */ 131 int bw, flags, he_dcm, he_gi, he_ru_alloc, legacy, mcs, nss; 132 }; 133 134 struct ieee80211_rate { 135 /* TODO FIXME */ 136 uint32_t bitrate; 137 uint32_t hw_value; 138 uint32_t hw_value_short; 139 uint32_t flags; 140 }; 141 142 /* XXX net80211 calls these IEEE80211_HTCAP_* */ 143 #define IEEE80211_HT_CAP_LDPC_CODING 0x0001 /* IEEE80211_HTCAP_LDPC */ 144 #define IEEE80211_HT_CAP_SUP_WIDTH_20_40 0x0002 /* IEEE80211_HTCAP_CHWIDTH40 */ 145 #define IEEE80211_HT_CAP_GRN_FLD 0x0010 /* IEEE80211_HTCAP_GREENFIELD */ 146 #define IEEE80211_HT_CAP_SGI_20 0x0020 /* IEEE80211_HTCAP_SHORTGI20 */ 147 #define IEEE80211_HT_CAP_SGI_40 0x0040 /* IEEE80211_HTCAP_SHORTGI40 */ 148 #define IEEE80211_HT_CAP_TX_STBC 0x0080 /* IEEE80211_HTCAP_TXSTBC */ 149 #define IEEE80211_HT_CAP_RX_STBC 0x0100 /* IEEE80211_HTCAP_RXSTBC */ 150 #define IEEE80211_HT_CAP_RX_STBC_SHIFT 8 /* IEEE80211_HTCAP_RXSTBC_S */ 151 #define IEEE80211_HT_CAP_MAX_AMSDU 0x0800 /* IEEE80211_HTCAP_MAXAMSDU */ 152 #define IEEE80211_HT_CAP_DSSSCCK40 0x1000 /* IEEE80211_HTCAP_DSSSCCK40 */ 153 154 #define IEEE80211_HT_MCS_TX_DEFINED 0x0001 155 #define IEEE80211_HT_MCS_TX_RX_DIFF 0x0002 156 #define IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT 2 157 #define IEEE80211_HT_MCS_RX_HIGHEST_MASK 0x3FF 158 159 struct ieee80211_sta_ht_cap { 160 /* TODO FIXME */ 161 int ampdu_density, ampdu_factor; 162 bool ht_supported; 163 uint16_t cap; 164 struct mcs { 165 uint16_t rx_mask[16]; /* XXX ? > 4 (rtw88) */ 166 int rx_highest; 167 uint32_t tx_params; 168 } mcs; 169 }; 170 171 /* XXX net80211 calls these IEEE80211_VHTCAP_* */ 172 #define IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895 0x00000000 /* IEEE80211_VHTCAP_MAX_MPDU_LENGTH_3895 */ 173 #define IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991 0x00000001 /* IEEE80211_VHTCAP_MAX_MPDU_LENGTH_7991 */ 174 #define IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454 0x00000002 /* IEEE80211_VHTCAP_MAX_MPDU_LENGTH_11454 */ 175 #define IEEE80211_VHT_CAP_MAX_MPDU_MASK 0x00000003 /* IEEE80211_VHTCAP_MAX_MPDU_MASK */ 176 177 #define IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ (IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_160MHZ << IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_MASK_S) 178 179 #define IEEE80211_VHT_CAP_RXLDPC 0x00000010 /* IEEE80211_VHTCAP_RXLDPC */ 180 181 #define IEEE80211_VHT_CAP_SHORT_GI_80 0x00000020 /* IEEE80211_VHTCAP_SHORT_GI_80 */ 182 #define IEEE80211_VHT_CAP_SHORT_GI_160 0x00000040 /* IEEE80211_VHTCAP_SHORT_GI_160 */ 183 184 #define IEEE80211_VHT_CAP_TXSTBC 0x00000080 /* IEEE80211_VHTCAP_TXSTBC */ 185 186 #define IEEE80211_VHT_CAP_RXSTBC_1 0x00000100 /* IEEE80211_VHTCAP_RXSTBC_1 */ 187 #define IEEE80211_VHT_CAP_RXSTBC_MASK 0x00000700 /* IEEE80211_VHTCAP_RXSTBC_MASK */ 188 189 #define IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE 0x00000800 /* IEEE80211_VHTCAP_SU_BEAMFORMER_CAPABLE */ 190 191 #define IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE 0x00001000 /* IEEE80211_VHTCAP_SU_BEAMFORMEE_CAPABLE */ 192 193 #define IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE 0x00080000 /* IEEE80211_VHTCAP_MU_BEAMFORMER_CAPABLE */ 194 195 #define IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE 0x00100000 /* IEEE80211_VHTCAP_MU_BEAMFORMEE_CAPABLE */ 196 197 #define IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT 13 /* IEEE80211_VHTCAP_BEAMFORMEE_STS_SHIFT */ 198 199 #define IEEE80211_VHT_CAP_HTC_VHT 0x00400000 /* IEEE80211_VHTCAP_HTC_VHT */ 200 201 #define IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN 0x10000000 /* IEEE80211_VHTCAP_RX_ANTENNA_PATTERN */ 202 #define IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN 0x20000000 /* IEEE80211_VHTCAP_TX_ANTENNA_PATTERN */ 203 204 #define IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB 0x0c000000 /* IEEE80211_VHTCAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB */ 205 206 #define IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT 16 /* IEEE80211_VHTCAP_SOUNDING_DIMENSIONS_SHIFT */ 207 #define IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_MASK \ 208 (7 << IEEE80211_VHTCAP_SOUNDING_DIMENSIONS_SHIFT) /* IEEE80211_VHTCAP_SOUNDING_DIMENSIONS_MASK */ 209 210 #define IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT 23 /* IEEE80211_VHTCAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT */ 211 #define IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK \ 212 (7 << IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT) /* IEEE80211_VHTCAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK */ 213 214 struct ieee80211_sta_vht_cap { 215 /* TODO FIXME */ 216 bool vht_supported; 217 uint32_t cap; 218 struct vht_mcs vht_mcs; 219 }; 220 221 struct cfg80211_connect_resp_params { 222 /* XXX TODO */ 223 uint8_t *bssid; 224 const uint8_t *req_ie; 225 const uint8_t *resp_ie; 226 uint32_t req_ie_len; 227 uint32_t resp_ie_len; 228 int status; 229 }; 230 231 struct cfg80211_inform_bss { 232 /* XXX TODO */ 233 int boottime_ns, scan_width, signal; 234 struct linuxkpi_ieee80211_channel *chan; 235 }; 236 237 struct cfg80211_roam_info { 238 /* XXX TODO */ 239 uint8_t *bssid; 240 const uint8_t *req_ie; 241 const uint8_t *resp_ie; 242 uint32_t req_ie_len; 243 uint32_t resp_ie_len; 244 struct linuxkpi_ieee80211_channel *channel; 245 }; 246 247 struct cfg80211_bss_ies { 248 /* XXX TODO, type is best guess. Fix if more info. */ 249 uint8_t *data; 250 int len; 251 }; 252 253 struct cfg80211_bss { 254 /* XXX TODO */ 255 struct cfg80211_bss_ies *ies; 256 }; 257 258 struct cfg80211_chan_def { 259 /* XXX TODO */ 260 struct linuxkpi_ieee80211_channel *chan; 261 enum nl80211_chan_width width; 262 uint32_t center_freq1; 263 uint32_t center_freq2; 264 }; 265 266 struct cfg80211_ftm_responder_stats { 267 /* XXX TODO */ 268 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; 269 }; 270 271 struct cfg80211_pmsr_capabilities { 272 /* XXX TODO */ 273 int max_peers, randomize_mac_addr, report_ap_tsf; 274 struct { 275 int asap, bandwidths, max_bursts_exponent, max_ftms_per_burst, non_asap, non_trigger_based, preambles, request_civicloc, request_lci, supported, trigger_based; 276 } ftm; 277 }; 278 279 struct cfg80211_pmsr_ftm_request { 280 /* XXX TODO */ 281 int asap, burst_period, ftmr_retries, ftms_per_burst, non_trigger_based, num_bursts_exp, request_civicloc, request_lci, trigger_based; 282 uint8_t bss_color; 283 bool lmr_feedback; 284 }; 285 286 struct cfg80211_pmsr_request_peer { 287 /* XXX TODO */ 288 struct cfg80211_chan_def chandef; 289 struct cfg80211_pmsr_ftm_request ftm; 290 uint8_t addr[ETH_ALEN]; 291 int report_ap_tsf; 292 }; 293 294 struct cfg80211_pmsr_request { 295 /* XXX TODO */ 296 int cookie, n_peers, timeout; 297 uint8_t mac_addr[ETH_ALEN], mac_addr_mask[ETH_ALEN]; 298 struct cfg80211_pmsr_request_peer peers[]; 299 }; 300 301 struct cfg80211_pmsr_ftm_result { 302 /* XXX TODO */ 303 int burst_index, busy_retry_time, failure_reason; 304 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; 305 uint8_t *lci; 306 uint8_t *civicloc; 307 int lci_len; 308 int civicloc_len; 309 }; 310 311 struct cfg80211_pmsr_result { 312 /* XXX TODO */ 313 int ap_tsf, ap_tsf_valid, final, host_time, status, type; 314 uint8_t addr[ETH_ALEN]; 315 struct cfg80211_pmsr_ftm_result ftm; 316 }; 317 318 struct cfg80211_ssid { 319 int ssid_len; 320 uint8_t ssid[IEEE80211_MAX_SSID_LEN]; 321 }; 322 323 struct cfg80211_scan_6ghz_params { 324 /* XXX TODO */ 325 uint8_t *bssid; 326 int channel_idx, psc_no_listen, short_ssid, short_ssid_valid, unsolicited_probe; 327 }; 328 329 struct cfg80211_match_set { 330 uint8_t bssid[ETH_ALEN]; 331 struct cfg80211_ssid ssid; 332 int rssi_thold; 333 }; 334 335 struct cfg80211_scan_request { 336 /* XXX TODO */ 337 int duration, duration_mandatory, flags; 338 bool no_cck; 339 bool scan_6ghz; 340 struct wireless_dev *wdev; 341 struct wiphy *wiphy; 342 int ie_len; 343 uint8_t *ie; 344 uint8_t mac_addr[ETH_ALEN], mac_addr_mask[ETH_ALEN]; 345 int n_ssids; 346 int n_6ghz_params; 347 int n_channels; 348 struct cfg80211_ssid *ssids; 349 struct cfg80211_scan_6ghz_params *scan_6ghz_params; 350 struct linuxkpi_ieee80211_channel *channels[0]; 351 }; 352 353 struct cfg80211_sched_scan_plan { 354 /* XXX TODO */ 355 int interval, iterations; 356 }; 357 358 struct cfg80211_sched_scan_request { 359 /* XXX TODO */ 360 int delay, flags; 361 uint8_t mac_addr[ETH_ALEN], mac_addr_mask[ETH_ALEN]; 362 uint64_t reqid; 363 int n_match_sets; 364 int n_scan_plans; 365 int n_ssids; 366 int n_channels; 367 struct cfg80211_match_set *match_sets; 368 struct cfg80211_sched_scan_plan *scan_plans; 369 struct cfg80211_ssid *ssids; 370 struct linuxkpi_ieee80211_channel *channels[0]; 371 }; 372 373 struct cfg80211_scan_info { 374 uint64_t scan_start_tsf; 375 uint8_t tsf_bssid[ETH_ALEN]; 376 bool aborted; 377 }; 378 379 struct cfg80211_beacon_data { 380 /* XXX TODO */ 381 const uint8_t *head; 382 const uint8_t *tail; 383 uint32_t head_len; 384 uint32_t tail_len; 385 const uint8_t *proberesp_ies; 386 const uint8_t *assocresp_ies; 387 uint32_t proberesp_ies_len; 388 uint32_t assocresp_ies_len; 389 }; 390 391 struct cfg80211_ap_settings { 392 /* XXX TODO */ 393 int auth_type, beacon_interval, dtim_period, hidden_ssid, inactivity_timeout; 394 const uint8_t *ssid; 395 size_t ssid_len; 396 struct cfg80211_beacon_data beacon; 397 struct cfg80211_chan_def chandef; 398 }; 399 400 struct cfg80211_bss_selection { 401 /* XXX TODO */ 402 enum nl80211_bss_select_attr behaviour; 403 union { 404 enum nl80211_band band_pref; 405 struct { 406 enum nl80211_band band; 407 uint8_t delta; 408 } adjust; 409 } param; 410 }; 411 412 struct cfg80211_crypto { /* XXX made up name */ 413 /* XXX TODO */ 414 enum nl80211_wpa_versions wpa_versions; 415 uint32_t cipher_group; /* WLAN_CIPHER_SUITE_* */ 416 uint32_t *akm_suites; 417 uint32_t *ciphers_pairwise; 418 const uint8_t *sae_pwd; 419 const uint8_t *psk; 420 int n_akm_suites; 421 int n_ciphers_pairwise; 422 int sae_pwd_len; 423 }; 424 425 struct cfg80211_connect_params { 426 /* XXX TODO */ 427 struct linuxkpi_ieee80211_channel *channel; 428 uint8_t *bssid; 429 const uint8_t *ie; 430 const uint8_t *ssid; 431 uint32_t ie_len; 432 uint32_t ssid_len; 433 const void *key; 434 uint32_t key_len; 435 int auth_type, key_idx, privacy, want_1x; 436 struct cfg80211_bss_selection bss_select; 437 struct cfg80211_crypto crypto; 438 }; 439 440 enum bss_param_flags { /* Used as bitflags. XXX FIXME values? */ 441 BSS_PARAM_FLAGS_CTS_PROT = 0x01, 442 BSS_PARAM_FLAGS_SHORT_PREAMBLE = 0x02, 443 BSS_PARAM_FLAGS_SHORT_SLOT_TIME = 0x04, 444 }; 445 446 struct cfg80211_ibss_params { 447 /* XXX TODO */ 448 int basic_rates, beacon_interval; 449 int channel_fixed, ie, ie_len, privacy; 450 int dtim_period; 451 uint8_t *ssid; 452 uint8_t *bssid; 453 int ssid_len; 454 struct cfg80211_chan_def chandef; 455 enum bss_param_flags flags; 456 }; 457 458 struct cfg80211_mgmt_tx_params { 459 /* XXX TODO */ 460 struct linuxkpi_ieee80211_channel *chan; 461 const uint8_t *buf; 462 size_t len; 463 int wait; 464 }; 465 466 struct cfg80211_pmk_conf { 467 /* XXX TODO */ 468 const uint8_t *pmk; 469 uint8_t pmk_len; 470 }; 471 472 struct cfg80211_pmksa { 473 /* XXX TODO */ 474 const uint8_t *bssid; 475 const uint8_t *pmkid; 476 }; 477 478 struct cfg80211_wowlan_nd_match { 479 /* XXX TODO */ 480 struct cfg80211_ssid ssid; 481 int n_channels; 482 uint32_t channels[0]; /* freq! = ieee80211_channel_to_frequency() */ 483 }; 484 485 struct cfg80211_wowlan_nd_info { 486 /* XXX TODO */ 487 int n_matches; 488 struct cfg80211_wowlan_nd_match *matches[0]; 489 }; 490 491 enum wiphy_wowlan_support_flags { 492 WIPHY_WOWLAN_DISCONNECT, 493 WIPHY_WOWLAN_GTK_REKEY_FAILURE, 494 WIPHY_WOWLAN_MAGIC_PKT, 495 WIPHY_WOWLAN_SUPPORTS_GTK_REKEY, 496 WIPHY_WOWLAN_NET_DETECT, 497 }; 498 499 struct wiphy_wowlan_support { 500 /* XXX TODO */ 501 enum wiphy_wowlan_support_flags flags; 502 int max_nd_match_sets, max_pkt_offset, n_patterns, pattern_max_len, pattern_min_len; 503 }; 504 505 struct station_del_parameters { 506 /* XXX TODO */ 507 const uint8_t *mac; 508 uint32_t reason_code; /* elsewhere uint16_t? */ 509 }; 510 511 struct station_info { 512 /* TODO FIXME */ 513 int assoc_req_ies_len, connected_time; 514 int generation, inactive_time, rx_bytes, rx_dropped_misc, rx_packets, signal, tx_bytes, tx_packets; 515 int filled, rx_beacon, rx_beacon_signal_avg, signal_avg; 516 int rx_duration, tx_failed, tx_retries; 517 518 int chains; 519 uint8_t chain_signal[IEEE80211_MAX_CHAINS]; 520 uint8_t chain_signal_avg[IEEE80211_MAX_CHAINS]; 521 522 uint8_t *assoc_req_ies; 523 struct rate_info rxrate; 524 struct rate_info txrate; 525 struct cfg80211_ibss_params bss_param; 526 struct nl80211_sta_flag_update sta_flags; 527 }; 528 529 struct station_parameters { 530 /* XXX TODO */ 531 int sta_flags_mask, sta_flags_set; 532 }; 533 534 struct key_params { 535 /* XXX TODO */ 536 const uint8_t *key; 537 const uint8_t *seq; 538 int key_len; 539 int seq_len; 540 uint32_t cipher; /* WLAN_CIPHER_SUITE_* */ 541 }; 542 543 struct mgmt_frame_regs { 544 /* XXX TODO */ 545 int interface_stypes; 546 }; 547 548 struct vif_params { 549 /* XXX TODO */ 550 uint8_t macaddr[ETH_ALEN]; 551 }; 552 553 /* That the world needs so many different structs for this is amazing. */ 554 struct mac_address { 555 uint8_t addr[ETH_ALEN]; 556 }; 557 558 #define REG_RULE(_begin, _end, _bw, _gain, _eirp, _x) \ 559 { \ 560 .freq_range.start_freq_khz = (_begin) * 1000, \ 561 .freq_range.end_freq_khz = (_end) * 1000, \ 562 .freq_range.max_bandwidth_khz = (_bw) * 1000, \ 563 .power_rule.max_antenna_gain = DBI_TO_MBI(_gain), \ 564 .power_rule.max_eirp = DBM_TO_MBM(_eirp), \ 565 .flags = (_x), /* ? */ \ 566 /* XXX TODO FIXME */ \ 567 } 568 569 struct ieee80211_reg_rule { 570 /* TODO FIXME */ 571 uint32_t flags; 572 struct freq_range { 573 int start_freq_khz; 574 int end_freq_khz; 575 int max_bandwidth_khz; 576 } freq_range; 577 struct power_rule { 578 int max_antenna_gain; 579 int max_eirp; 580 } power_rule; 581 }; 582 583 struct linuxkpi_ieee80211_regdomain { 584 /* TODO FIXME */ 585 uint8_t alpha2[2]; 586 int n_reg_rules; 587 struct ieee80211_reg_rule reg_rules[]; 588 }; 589 590 /* XXX-BZ this are insensible values probably ... */ 591 #define IEEE80211_HE_MAC_CAP0_HTC_HE 0x1 592 #define IEEE80211_HE_MAC_CAP0_TWT_REQ 0x2 593 594 #define IEEE80211_HE_MAC_CAP1_LINK_ADAPTATION 0x1 595 #define IEEE80211_HE_MAC_CAP1_MULTI_TID_AGG_RX_QOS_8 0x2 596 #define IEEE80211_HE_MAC_CAP1_TF_MAC_PAD_DUR_16US 0x4 597 598 #define IEEE80211_HE_MAC_CAP2_32BIT_BA_BITMAP 0x1 599 #define IEEE80211_HE_MAC_CAP2_ACK_EN 0x2 600 #define IEEE80211_HE_MAC_CAP2_BSR 0x4 601 #define IEEE80211_HE_MAC_CAP2_LINK_ADAPTATION 0x8 602 #define IEEE80211_HE_MAC_CAP2_BCAST_TWT 0x10 603 604 #define IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_VHT_2 0x1 605 #define IEEE80211_HE_MAC_CAP3_OMI_CONTROL 0x2 606 #define IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_EXT_1 0x10 607 #define IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_EXT_3 0x20 608 #define IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_MASK 0x30 609 #define IEEE80211_HE_MAC_CAP3_RX_CTRL_FRAME_TO_MULTIBSS 0x80 610 611 #define IEEE80211_HE_MAC_CAP4_AMDSU_IN_AMPDU 0x1 612 #define IEEE80211_HE_MAC_CAP4_BQR 0x2 613 #define IEEE80211_HE_MAC_CAP4_MULTI_TID_AGG_TX_QOS_B39 0x4 614 #define IEEE80211_HE_MAC_CAP4_AMSDU_IN_AMPDU 0x8 615 616 #define IEEE80211_HE_MAC_CAP5_HE_DYNAMIC_SM_PS 0x1 617 #define IEEE80211_HE_MAC_CAP5_HT_VHT_TRIG_FRAME_RX 0x2 618 #define IEEE80211_HE_MAC_CAP5_MULTI_TID_AGG_TX_QOS_B40 0x4 619 #define IEEE80211_HE_MAC_CAP5_MULTI_TID_AGG_TX_QOS_B41 0x8 620 #define IEEE80211_HE_MAC_CAP5_UL_2x996_TONE_RU 0x10 621 622 #define IEEE80211_HE_MCS_NOT_SUPPORTED 0x0 623 #define IEEE80211_HE_MCS_SUPPORT_0_7 0x1 624 #define IEEE80211_HE_MCS_SUPPORT_0_9 0x2 625 #define IEEE80211_HE_MCS_SUPPORT_0_11 0x4 626 627 #define IEEE80211_HE_6GHZ_CAP_TX_ANTPAT_CONS 0x01 628 #define IEEE80211_HE_6GHZ_CAP_RX_ANTPAT_CONS 0x02 629 #define IEEE80211_HE_6GHZ_CAP_MIN_MPDU_START 0x04 630 #define IEEE80211_HE_6GHZ_CAP_MAX_MPDU_LEN 0x08 631 #define IEEE80211_HE_6GHZ_CAP_MAX_AMPDU_LEN_EXP 0x10 632 633 #define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_160MHZ_IN_5G 0x1 634 #define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_80MHZ_IN_5G 0x2 635 #define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_IN_2G 0x4 636 637 #define IEEE80211_HE_PHY_CAP1_DEVICE_CLASS_A 0x1 638 #define IEEE80211_HE_PHY_CAP1_LDPC_CODING_IN_PAYLOAD 0x2 639 #define IEEE80211_HE_PHY_CAP1_MIDAMBLE_RX_TX_MAX_NSTS 0x4 640 #define IEEE80211_HE_PHY_CAP1_PREAMBLE_PUNC_RX_MASK 0x8 641 642 #define IEEE80211_HE_PHY_CAP2_MIDAMBLE_RX_TX_MAX_NSTS 0x1 643 #define IEEE80211_HE_PHY_CAP2_NDP_4x_LTF_AND_3_2US 0x2 644 #define IEEE80211_HE_PHY_CAP2_STBC_TX_UNDER_80MHZ 0x4 645 #define IEEE80211_HE_PHY_CAP2_STBC_RX_UNDER_80MHZ 0x8 646 647 #define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_MASK 0x1 648 #define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_NO_DCM 0x2 649 #define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_NO_DCM 0x4 650 #define IEEE80211_HE_PHY_CAP3_DCM_MAX_RX_NSS_1 0x8 651 #define IEEE80211_HE_PHY_CAP3_DCM_MAX_TX_NSS_1 0x10 652 653 #define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_8 0x1 654 #define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_8 0x2 655 #define IEEE80211_HE_PHY_CAP4_SU_BEAMFORMEE 0x4 656 657 #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_2 0x1 658 #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_2 0x2 659 660 #define IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT 0x1 661 #define IEEE80211_HE_PHY_CAP6_TRIG_MU_BEAMFORMER_FB 0x2 662 #define IEEE80211_HE_PHY_CAP6_TRIG_SU_BEAMFORMER_FB 0x4 663 #define IEEE80211_HE_PHY_CAP6_TRIG_SU_BEAMFORMING_FB 0x10 664 #define IEEE80211_HE_PHY_CAP6_TRIG_MU_BEAMFORMING_PARTIAL_BW_FB 0x20 665 666 #define IEEE80211_HE_PHY_CAP7_HE_SU_MU_PPDU_4XLTF_AND_08_US_GI 0x1 667 #define IEEE80211_HE_PHY_CAP7_MAX_NC_1 0x2 668 #define IEEE80211_HE_PHY_CAP7_MAX_NC_2 0x4 669 #define IEEE80211_HE_PHY_CAP7_MAX_NC_MASK 0x6 670 #define IEEE80211_HE_PHY_CAP7_POWER_BOOST_FACTOR_AR 0x8 671 #define IEEE80211_HE_PHY_CAP7_POWER_BOOST_FACTOR_SUPP 0x10 672 #define IEEE80211_HE_PHY_CAP7_STBC_RX_ABOVE_80MHZ 0x20 673 674 #define IEEE80211_HE_PHY_CAP8_20MHZ_IN_160MHZ_HE_PPDU 0x1 675 #define IEEE80211_HE_PHY_CAP8_20MHZ_IN_40MHZ_HE_PPDU_IN_2G 0x2 676 #define IEEE80211_HE_PHY_CAP8_80MHZ_IN_160MHZ_HE_PPDU 0x4 677 #define IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_2x996 0x8 678 #define IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_242 0x10 679 #define IEEE80211_HE_PHY_CAP8_HE_ER_SU_PPDU_4XLTF_AND_08_US_GI 0x20 680 681 #define IEEE80211_HE_PHY_CAP9_NOMIMAL_PKT_PADDING_0US 0x1 682 #define IEEE80211_HE_PHY_CAP9_NOMIMAL_PKT_PADDING_16US 0x2 683 #define IEEE80211_HE_PHY_CAP9_NOMIMAL_PKT_PADDING_8US 0x4 684 #define IEEE80211_HE_PHY_CAP9_NOMIMAL_PKT_PADDING_MASK 0x8 685 #define IEEE80211_HE_PHY_CAP9_NOMIMAL_PKT_PADDING_RESERVED 0x10 686 #define IEEE80211_HE_PHY_CAP9_NON_TRIGGERED_CQI_FEEDBACK 0x20 687 #define IEEE80211_HE_PHY_CAP9_RX_FULL_BW_SU_USING_MU_WITH_COMP_SIGB 0x40 688 #define IEEE80211_HE_PHY_CAP9_RX_FULL_BW_SU_USING_MU_WITH_NON_COMP_SIGB 0x80 689 #define IEEE80211_HE_PHY_CAP9_RX_1024_QAM_LESS_THAN_242_TONE_RU 0x100 690 #define IEEE80211_HE_PHY_CAP9_TX_1024_QAM_LESS_THAN_242_TONE_RU 0x200 691 692 #define IEEE80211_HE_PHY_CAP10_HE_MU_M1RU_MAX_LTF 0x1 693 694 #define VENDOR_CMD_RAW_DATA (void *)(uintptr_t)(-ENOENT) 695 696 struct ieee80211_he_cap_elem { 697 u8 mac_cap_info[6]; 698 u8 phy_cap_info[11]; 699 } __packed; 700 701 struct ieee80211_he_mcs_nss_supp { 702 /* TODO FIXME */ 703 uint32_t rx_mcs_80; 704 uint32_t tx_mcs_80; 705 uint32_t rx_mcs_160; 706 uint32_t tx_mcs_160; 707 uint32_t rx_mcs_80p80; 708 uint32_t tx_mcs_80p80; 709 }; 710 711 #define IEEE80211_STA_HE_CAP_PPE_THRES_MAX 32 712 struct ieee80211_sta_he_cap { 713 /* TODO FIXME */ 714 int has_he; 715 struct ieee80211_he_cap_elem he_cap_elem; 716 struct ieee80211_he_mcs_nss_supp he_mcs_nss_supp; 717 uint8_t ppe_thres[IEEE80211_STA_HE_CAP_PPE_THRES_MAX]; 718 }; 719 720 struct ieee80211_sta_he_6ghz_capa { 721 /* TODO FIXME */ 722 int capa; 723 }; 724 725 struct ieee80211_sband_iftype_data { 726 /* TODO FIXME */ 727 enum nl80211_iftype types_mask; 728 struct ieee80211_sta_he_cap he_cap; 729 struct ieee80211_sta_he_6ghz_capa he_6ghz_capa; 730 struct { 731 const uint8_t *data; 732 size_t len; 733 } vendor_elems; 734 }; 735 736 struct ieee80211_supported_band { 737 /* TODO FIXME */ 738 struct linuxkpi_ieee80211_channel *channels; 739 struct ieee80211_rate *bitrates; 740 struct ieee80211_sband_iftype_data *iftype_data; 741 int n_channels; 742 int n_bitrates; 743 int n_iftype_data; 744 enum nl80211_band band; 745 struct ieee80211_sta_ht_cap ht_cap; 746 struct ieee80211_sta_vht_cap vht_cap; 747 }; 748 749 struct cfg80211_pkt_pattern { 750 /* XXX TODO */ 751 uint8_t *mask; 752 uint8_t *pattern; 753 int pattern_len; 754 int pkt_offset; 755 }; 756 757 struct cfg80211_wowlan { 758 /* XXX TODO */ 759 int disconnect, gtk_rekey_failure, magic_pkt; 760 int n_patterns; 761 struct cfg80211_sched_scan_request *nd_config; 762 struct cfg80211_pkt_pattern *patterns; 763 }; 764 765 struct cfg80211_gtk_rekey_data { 766 /* XXX TODO */ 767 int kck, kek, replay_ctr; 768 }; 769 770 struct ieee80211_iface_limit { 771 /* TODO FIXME */ 772 int max, types; 773 }; 774 775 struct ieee80211_iface_combination { 776 /* TODO FIXME */ 777 const struct ieee80211_iface_limit *limits; 778 int n_limits; 779 int max_interfaces, num_different_channels; 780 int beacon_int_infra_match, beacon_int_min_gcd; 781 }; 782 783 struct iface_combination_params { 784 int num_different_channels; 785 int iftype_num[NUM_NL80211_IFTYPES]; 786 }; 787 788 struct regulatory_request { 789 /* XXX TODO */ 790 uint8_t alpha2[2]; 791 int initiator, dfs_region; 792 }; 793 794 enum wiphy_vendor_cmd_need_flags { 795 WIPHY_VENDOR_CMD_NEED_NETDEV = 0x01, 796 WIPHY_VENDOR_CMD_NEED_RUNNING = 0x02, 797 WIPHY_VENDOR_CMD_NEED_WDEV = 0x04, 798 }; 799 800 struct wiphy_vendor_command { 801 struct { 802 uint32_t vendor_id; 803 uint32_t subcmd; 804 }; 805 uint32_t flags; 806 void *policy; 807 int (*doit)(struct wiphy *, struct wireless_dev *, const void *, int); 808 }; 809 810 struct wiphy_iftype_ext_capab { 811 /* TODO FIXME */ 812 enum nl80211_iftype iftype; 813 const uint8_t *extended_capabilities; 814 const uint8_t *extended_capabilities_mask; 815 uint8_t extended_capabilities_len; 816 817 }; 818 819 enum cfg80211_regulatory { 820 REGULATORY_CUSTOM_REG = BIT(0), 821 REGULATORY_STRICT_REG = BIT(1), 822 REGULATORY_DISABLE_BEACON_HINTS = BIT(2), 823 REGULATORY_ENABLE_RELAX_NO_IR = BIT(3), 824 REGULATORY_WIPHY_SELF_MANAGED = BIT(4), 825 REGULATORY_COUNTRY_IE_IGNORE = BIT(5), 826 }; 827 828 #define WIPHY_FLAG_AP_UAPSD 0x00000001 829 #define WIPHY_FLAG_HAS_CHANNEL_SWITCH 0x00000002 830 #define WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL 0x00000004 831 #define WIPHY_FLAG_HAVE_AP_SME 0x00000008 832 #define WIPHY_FLAG_IBSS_RSN 0x00000010 833 #define WIPHY_FLAG_NETNS_OK 0x00000020 834 #define WIPHY_FLAG_OFFCHAN_TX 0x00000040 835 #define WIPHY_FLAG_PS_ON_BY_DEFAULT 0x00000080 836 #define WIPHY_FLAG_SPLIT_SCAN_6GHZ 0x00000100 837 #define WIPHY_FLAG_SUPPORTS_EXT_KEK_KCK 0x00000200 838 #define WIPHY_FLAG_SUPPORTS_FW_ROAM 0x00000400 839 #define WIPHY_FLAG_SUPPORTS_TDLS 0x00000800 840 #define WIPHY_FLAG_TDLS_EXTERNAL_SETUP 0x00001000 841 842 struct wiphy { 843 844 struct device *dev; 845 struct mac_address *addresses; 846 int n_addresses; 847 uint32_t flags; 848 struct ieee80211_supported_band *bands[NUM_NL80211_BANDS]; 849 uint8_t perm_addr[ETH_ALEN]; 850 851 /* XXX TODO */ 852 const struct cfg80211_pmsr_capabilities *pmsr_capa; 853 const struct wiphy_iftype_ext_capab *iftype_ext_capab; 854 const struct linuxkpi_ieee80211_regdomain *regd; 855 char fw_version[64]; /* XXX TODO */ 856 const struct ieee80211_iface_combination *iface_combinations; 857 const uint32_t *cipher_suites; 858 int n_iface_combinations; 859 int n_cipher_suites; 860 void(*reg_notifier)(struct wiphy *, struct regulatory_request *); 861 enum cfg80211_regulatory regulatory_flags; 862 int n_vendor_commands; 863 const struct wiphy_vendor_command *vendor_commands; 864 const struct ieee80211_txrx_stypes *mgmt_stypes; 865 uint32_t rts_threshold; 866 uint32_t frag_threshold; 867 868 int available_antennas_rx, available_antennas_tx; 869 int features, hw_version; 870 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; 871 int num_iftype_ext_capab; 872 int max_ap_assoc_sta, probe_resp_offload, software_iftypes; 873 int bss_select_support, max_num_pmkids, retry_long, retry_short, signal_type; 874 875 unsigned long ext_features[BITS_TO_LONGS(NUM_NL80211_EXT_FEATURES)]; 876 struct dentry *debugfsdir; 877 struct cfg80211_wowlan_support *wowlan; 878 /* Lower layer (driver/mac80211) specific data. */ 879 /* Must stay last. */ 880 uint8_t priv[0] __aligned(CACHE_LINE_SIZE); 881 }; 882 883 struct wireless_dev { 884 /* XXX TODO, like ic? */ 885 int iftype; 886 int address; 887 struct net_device *netdev; 888 struct wiphy *wiphy; 889 }; 890 891 struct cfg80211_ops { 892 /* XXX TODO */ 893 struct wireless_dev *(*add_virtual_intf)(struct wiphy *, const char *, unsigned char, enum nl80211_iftype, struct vif_params *); 894 int (*del_virtual_intf)(struct wiphy *, struct wireless_dev *); 895 s32 (*change_virtual_intf)(struct wiphy *, struct net_device *, enum nl80211_iftype, struct vif_params *); 896 s32 (*scan)(struct wiphy *, struct cfg80211_scan_request *); 897 s32 (*set_wiphy_params)(struct wiphy *, u32); 898 s32 (*join_ibss)(struct wiphy *, struct net_device *, struct cfg80211_ibss_params *); 899 s32 (*leave_ibss)(struct wiphy *, struct net_device *); 900 s32 (*get_station)(struct wiphy *, struct net_device *, const u8 *, struct station_info *); 901 int (*dump_station)(struct wiphy *, struct net_device *, int, u8 *, struct station_info *); 902 s32 (*set_tx_power)(struct wiphy *, struct wireless_dev *, enum nl80211_tx_power_setting, s32); 903 s32 (*get_tx_power)(struct wiphy *, struct wireless_dev *, s32 *); 904 s32 (*add_key)(struct wiphy *, struct net_device *, u8, bool, const u8 *, struct key_params *); 905 s32 (*del_key)(struct wiphy *, struct net_device *, u8, bool, const u8 *); 906 s32 (*get_key)(struct wiphy *, struct net_device *, u8, bool, const u8 *, void *, void(*)(void *, struct key_params *)); 907 s32 (*set_default_key)(struct wiphy *, struct net_device *, u8, bool, bool); 908 s32 (*set_default_mgmt_key)(struct wiphy *, struct net_device *, u8); 909 s32 (*set_power_mgmt)(struct wiphy *, struct net_device *, bool, s32); 910 s32 (*connect)(struct wiphy *, struct net_device *, struct cfg80211_connect_params *); 911 s32 (*disconnect)(struct wiphy *, struct net_device *, u16); 912 s32 (*suspend)(struct wiphy *, struct cfg80211_wowlan *); 913 s32 (*resume)(struct wiphy *); 914 s32 (*set_pmksa)(struct wiphy *, struct net_device *, struct cfg80211_pmksa *); 915 s32 (*del_pmksa)(struct wiphy *, struct net_device *, struct cfg80211_pmksa *); 916 s32 (*flush_pmksa)(struct wiphy *, struct net_device *); 917 s32 (*start_ap)(struct wiphy *, struct net_device *, struct cfg80211_ap_settings *); 918 int (*stop_ap)(struct wiphy *, struct net_device *); 919 s32 (*change_beacon)(struct wiphy *, struct net_device *, struct cfg80211_beacon_data *); 920 int (*del_station)(struct wiphy *, struct net_device *, struct station_del_parameters *); 921 int (*change_station)(struct wiphy *, struct net_device *, const u8 *, struct station_parameters *); 922 int (*sched_scan_start)(struct wiphy *, struct net_device *, struct cfg80211_sched_scan_request *); 923 int (*sched_scan_stop)(struct wiphy *, struct net_device *, u64); 924 void (*update_mgmt_frame_registrations)(struct wiphy *, struct wireless_dev *, struct mgmt_frame_regs *); 925 int (*mgmt_tx)(struct wiphy *, struct wireless_dev *, struct cfg80211_mgmt_tx_params *, u64 *); 926 int (*cancel_remain_on_channel)(struct wiphy *, struct wireless_dev *, u64); 927 int (*get_channel)(struct wiphy *, struct wireless_dev *, struct cfg80211_chan_def *); 928 int (*crit_proto_start)(struct wiphy *, struct wireless_dev *, enum nl80211_crit_proto_id, u16); 929 void (*crit_proto_stop)(struct wiphy *, struct wireless_dev *); 930 int (*tdls_oper)(struct wiphy *, struct net_device *, const u8 *, enum nl80211_tdls_operation); 931 int (*update_connect_params)(struct wiphy *, struct net_device *, struct cfg80211_connect_params *, u32); 932 int (*set_pmk)(struct wiphy *, struct net_device *, const struct cfg80211_pmk_conf *); 933 int (*del_pmk)(struct wiphy *, struct net_device *, const u8 *); 934 int (*remain_on_channel)(struct wiphy *, struct wireless_dev *, struct linuxkpi_ieee80211_channel *, unsigned int, u64 *); 935 int (*start_p2p_device)(struct wiphy *, struct wireless_dev *); 936 void (*stop_p2p_device)(struct wiphy *, struct wireless_dev *); 937 }; 938 939 940 /* -------------------------------------------------------------------------- */ 941 942 /* linux_80211.c */ 943 944 struct wiphy *linuxkpi_wiphy_new(const struct cfg80211_ops *, size_t); 945 void linuxkpi_wiphy_free(struct wiphy *wiphy); 946 947 int linuxkpi_regulatory_set_wiphy_regd_sync(struct wiphy *wiphy, 948 struct linuxkpi_ieee80211_regdomain *regd); 949 uint32_t linuxkpi_ieee80211_channel_to_frequency(uint32_t, enum nl80211_band); 950 uint32_t linuxkpi_ieee80211_frequency_to_channel(uint32_t, uint32_t); 951 952 /* -------------------------------------------------------------------------- */ 953 954 static __inline struct wiphy * 955 wiphy_new(const struct cfg80211_ops *ops, size_t priv_len) 956 { 957 958 return (linuxkpi_wiphy_new(ops, priv_len)); 959 } 960 961 static __inline void 962 wiphy_free(struct wiphy *wiphy) 963 { 964 965 linuxkpi_wiphy_free(wiphy); 966 } 967 968 static __inline void * 969 wiphy_priv(struct wiphy *wiphy) 970 { 971 972 return (wiphy->priv); 973 } 974 975 static __inline void 976 set_wiphy_dev(struct wiphy *wiphy, struct device *dev) 977 { 978 979 wiphy->dev = dev; 980 } 981 982 static __inline struct device * 983 wiphy_dev(struct wiphy *wiphy) 984 { 985 986 return (wiphy->dev); 987 } 988 989 #define wiphy_err(_wiphy, _fmt, ...) \ 990 dev_err((_wiphy)->dev, _fmt, __VA_ARGS__) 991 992 static __inline const struct linuxkpi_ieee80211_regdomain * 993 wiphy_dereference(struct wiphy *wiphy, 994 const struct linuxkpi_ieee80211_regdomain *regd) 995 { 996 TODO(); 997 return (NULL); 998 } 999 1000 /* -------------------------------------------------------------------------- */ 1001 1002 static __inline int 1003 reg_query_regdb_wmm(uint8_t *alpha2, uint32_t center_freq, 1004 struct ieee80211_reg_rule *rule) 1005 { 1006 1007 /* ETSI has special rules. FreeBSD regdb needs to learn about them. */ 1008 TODO(); 1009 1010 return (-ENXIO); 1011 } 1012 1013 static __inline const u8 * 1014 cfg80211_find_ie_match(uint32_t f, const u8 *ies, size_t ies_len, 1015 const u8 *match, int x, int y) 1016 { 1017 TODO(); 1018 return (NULL); 1019 } 1020 1021 static __inline const u8 * 1022 cfg80211_find_ie(uint8_t eid, uint8_t *variable, uint32_t frame_size) 1023 { 1024 TODO(); 1025 return (NULL); 1026 } 1027 1028 static __inline void 1029 cfg80211_pmsr_complete(struct wireless_dev *wdev, 1030 struct cfg80211_pmsr_request *req, gfp_t gfp) 1031 { 1032 TODO(); 1033 } 1034 1035 static __inline void 1036 cfg80211_pmsr_report(struct wireless_dev *wdev, 1037 struct cfg80211_pmsr_request *req, 1038 struct cfg80211_pmsr_result *result, gfp_t gfp) 1039 { 1040 TODO(); 1041 } 1042 1043 static __inline void 1044 cfg80211_chandef_create(struct cfg80211_chan_def *chandef, 1045 struct linuxkpi_ieee80211_channel *chan, enum nl80211_chan_flags chan_flag) 1046 { 1047 1048 KASSERT(chandef != NULL, ("%s: chandef is NULL\n", __func__)); 1049 KASSERT(chan != NULL, ("%s: chan is NULL\n", __func__)); 1050 1051 chandef->chan = chan; 1052 chandef->center_freq2 = 0; /* Set here and only overwrite if needed. */ 1053 chandef->chan = chan; 1054 1055 switch (chan_flag) { 1056 case NL80211_CHAN_NO_HT: 1057 chandef->width = NL80211_CHAN_WIDTH_20_NOHT; 1058 chandef->center_freq1 = chan->center_freq; 1059 break; 1060 default: 1061 printf("%s: unsupported chan_flag %#0x\n", __func__, chan_flag); 1062 /* XXX-BZ should we panic instead? */ 1063 chandef->width = NL80211_CHAN_WIDTH_20; 1064 chandef->center_freq1 = chan->center_freq; 1065 break; 1066 }; 1067 } 1068 1069 static __inline void 1070 cfg80211_bss_iter(struct wiphy *wiphy, struct cfg80211_chan_def *chandef, 1071 void (*iterfunc)(struct wiphy *, struct cfg80211_bss *, void *), void *data) 1072 { 1073 TODO(); 1074 } 1075 1076 struct element { 1077 uint8_t id; 1078 uint8_t datalen; 1079 uint8_t data[0]; 1080 }; 1081 1082 static __inline const struct element * 1083 cfg80211_find_elem(enum ieee80211_eid eid, uint8_t *data, size_t len) 1084 { 1085 TODO(); 1086 return (NULL); 1087 } 1088 1089 static __inline uint32_t 1090 cfg80211_calculate_bitrate(struct rate_info *rate) 1091 { 1092 TODO(); 1093 return (-1); 1094 } 1095 1096 static __inline uint32_t 1097 ieee80211_channel_to_frequency(uint32_t channel, enum nl80211_band band) 1098 { 1099 1100 return (linuxkpi_ieee80211_channel_to_frequency(channel, band)); 1101 } 1102 1103 static __inline uint32_t 1104 ieee80211_frequency_to_channel(uint32_t freq) 1105 { 1106 1107 return (linuxkpi_ieee80211_frequency_to_channel(freq, 0)); 1108 } 1109 1110 static __inline int 1111 regulatory_set_wiphy_regd_sync(struct wiphy *wiphy, 1112 struct linuxkpi_ieee80211_regdomain *regd) 1113 { 1114 IMPROVE(); 1115 return (linuxkpi_regulatory_set_wiphy_regd_sync(wiphy, regd)); 1116 } 1117 1118 static __inline int 1119 regulatory_set_wiphy_regd_sync_rtnl(struct wiphy *wiphy, 1120 struct linuxkpi_ieee80211_regdomain *regd) 1121 { 1122 1123 IMPROVE(); 1124 return (linuxkpi_regulatory_set_wiphy_regd_sync(wiphy, regd)); 1125 } 1126 1127 static __inline int 1128 regulatory_set_wiphy_regd(struct wiphy *wiphy, 1129 struct linuxkpi_ieee80211_regdomain *regd) 1130 { 1131 1132 IMPROVE(); 1133 if (regd == NULL) 1134 return (EINVAL); 1135 1136 /* XXX-BZ wild guessing here based on brcmfmac. */ 1137 if (wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED) 1138 wiphy->regd = regd; 1139 else 1140 return (EPERM); 1141 1142 /* XXX FIXME, do we have to do anything with reg_notifier? */ 1143 return (0); 1144 } 1145 1146 static __inline int 1147 regulatory_hint(struct wiphy *wiphy, uint8_t *alpha2) 1148 { 1149 TODO(); 1150 return (-ENXIO); 1151 } 1152 1153 static __inline struct linuxkpi_ieee80211_regdomain * 1154 rtnl_dereference(const struct linuxkpi_ieee80211_regdomain *regd) 1155 { 1156 TODO(); 1157 return (NULL); 1158 } 1159 1160 static __inline struct ieee80211_reg_rule * 1161 freq_reg_info(struct wiphy *wiphy, uint32_t center_freq) 1162 { 1163 TODO(); 1164 return (NULL); 1165 } 1166 1167 static __inline struct cfg80211_bss * 1168 cfg80211_get_bss(struct wiphy *wiphy, struct linuxkpi_ieee80211_channel *chan, 1169 uint8_t *bssid, void *p, int x, uint32_t f1, uint32_t f2) 1170 { 1171 TODO(); 1172 return (NULL); 1173 } 1174 1175 static __inline void 1176 cfg80211_put_bss(struct wiphy *wiphy, struct cfg80211_bss *bss) 1177 { 1178 TODO(); 1179 } 1180 1181 static __inline void 1182 wiphy_apply_custom_regulatory(struct wiphy *wiphy, 1183 const struct linuxkpi_ieee80211_regdomain *regd) 1184 { 1185 TODO(); 1186 } 1187 1188 static __inline char * 1189 wiphy_name(struct wiphy *wiphy) 1190 { 1191 if (wiphy != NULL && wiphy->dev != NULL) 1192 return dev_name(wiphy->dev); 1193 else 1194 return ("wlanNA"); 1195 } 1196 1197 static __inline void 1198 wiphy_read_of_freq_limits(struct wiphy *wiphy) 1199 { 1200 #ifdef FDT 1201 TODO(); 1202 #endif 1203 } 1204 1205 static __inline uint8_t * 1206 cfg80211_find_vendor_ie(unsigned int oui, u8 oui_type, 1207 uint8_t *data, size_t len) 1208 { 1209 TODO(); 1210 return (NULL); 1211 } 1212 1213 static __inline void 1214 wiphy_ext_feature_set(struct wiphy *wiphy, enum nl80211_ext_feature ef) 1215 { 1216 1217 set_bit(ef, wiphy->ext_features); 1218 } 1219 1220 static __inline void * 1221 wiphy_net(struct wiphy *wiphy) 1222 { 1223 TODO(); 1224 return (NULL); /* XXX passed to dev_net_set() */ 1225 } 1226 1227 static __inline int 1228 wiphy_register(struct wiphy *wiphy) 1229 { 1230 TODO(); 1231 return (0); 1232 } 1233 1234 static __inline void 1235 wiphy_unregister(struct wiphy *wiphy) 1236 { 1237 TODO(); 1238 } 1239 1240 static __inline void 1241 wiphy_warn(struct wiphy *wiphy, const char *fmt, ...) 1242 { 1243 TODO(); 1244 } 1245 1246 static __inline int 1247 cfg80211_check_combinations(struct wiphy *wiphy, 1248 struct iface_combination_params *params) 1249 { 1250 TODO(); 1251 return (-ENOENT); 1252 } 1253 1254 static __inline uint8_t 1255 cfg80211_classify8021d(struct sk_buff *skb, void *p) 1256 { 1257 TODO(); 1258 return (0); 1259 } 1260 1261 static __inline void 1262 cfg80211_connect_done(struct net_device *ndev, 1263 struct cfg80211_connect_resp_params *conn_params, gfp_t gfp) 1264 { 1265 TODO(); 1266 } 1267 1268 static __inline void 1269 cfg80211_crit_proto_stopped(struct wireless_dev *wdev, gfp_t gfp) 1270 { 1271 TODO(); 1272 } 1273 1274 static __inline void 1275 cfg80211_disconnected(struct net_device *ndev, uint16_t reason, 1276 void *p, int x, bool locally_generated, gfp_t gfp) 1277 { 1278 TODO(); 1279 } 1280 1281 static __inline int 1282 cfg80211_get_p2p_attr(const u8 *ie, u32 ie_len, 1283 enum ieee80211_p2p_attr_ids attr, u8 *p, size_t p_len) 1284 { 1285 TODO(); 1286 return (-1); 1287 } 1288 1289 static __inline void 1290 cfg80211_ibss_joined(struct net_device *ndev, const uint8_t *addr, 1291 struct linuxkpi_ieee80211_channel *chan, gfp_t gfp) 1292 { 1293 TODO(); 1294 } 1295 1296 static __inline struct cfg80211_bss * 1297 cfg80211_inform_bss(struct wiphy *wiphy, 1298 struct linuxkpi_ieee80211_channel *channel, 1299 enum cfg80211_bss_ftypes bss_ftype, const uint8_t *bss, int _x, 1300 uint16_t cap, uint16_t intvl, const uint8_t *ie, size_t ie_len, 1301 int signal, gfp_t gfp) 1302 { 1303 TODO(); 1304 return (NULL); 1305 } 1306 1307 static __inline struct cfg80211_bss * 1308 cfg80211_inform_bss_data(struct wiphy *wiphy, 1309 struct cfg80211_inform_bss *bss_data, 1310 enum cfg80211_bss_ftypes bss_ftype, const uint8_t *bss, int _x, 1311 uint16_t cap, uint16_t intvl, const uint8_t *ie, size_t ie_len, gfp_t gfp) 1312 { 1313 TODO(); 1314 return (NULL); 1315 } 1316 1317 static __inline void 1318 cfg80211_mgmt_tx_status(struct wireless_dev *wdev, uint64_t cookie, 1319 const u8 *buf, size_t len, bool ack, gfp_t gfp) 1320 { 1321 TODO(); 1322 } 1323 1324 static __inline void 1325 cfg80211_michael_mic_failure(struct net_device *ndev, const uint8_t *addr, 1326 enum nl80211_key_type key_type, int _x, void *p, gfp_t gfp) 1327 { 1328 TODO(); 1329 } 1330 1331 static __inline void 1332 cfg80211_new_sta(struct net_device *ndev, const uint8_t *addr, 1333 struct station_info *sinfo, gfp_t gfp) 1334 { 1335 TODO(); 1336 } 1337 1338 static __inline void 1339 cfg80211_del_sta(struct net_device *ndev, const uint8_t *addr, gfp_t gfp) 1340 { 1341 TODO(); 1342 } 1343 1344 static __inline void 1345 cfg80211_port_authorized(struct net_device *ndev, const uint8_t *bssid, 1346 gfp_t gfp) 1347 { 1348 TODO(); 1349 } 1350 1351 static __inline void 1352 cfg80211_ready_on_channel(struct wireless_dev *wdev, uint64_t cookie, 1353 struct linuxkpi_ieee80211_channel *channel, unsigned int duration, 1354 gfp_t gfp) 1355 { 1356 TODO(); 1357 } 1358 1359 static __inline void 1360 cfg80211_remain_on_channel_expired(struct wireless_dev *wdev, 1361 uint64_t cookie, struct linuxkpi_ieee80211_channel *channel, gfp_t gfp) 1362 { 1363 TODO(); 1364 } 1365 1366 static __inline void 1367 cfg80211_report_wowlan_wakeup(void) 1368 { 1369 TODO(); 1370 } 1371 1372 static __inline void 1373 cfg80211_roamed(struct net_device *ndev, struct cfg80211_roam_info *roam_info, 1374 gfp_t gfp) 1375 { 1376 TODO(); 1377 } 1378 1379 static __inline void 1380 cfg80211_rx_mgmt(struct wireless_dev *wdev, int freq, int _x, 1381 uint8_t *p, size_t p_len, int _x2) 1382 { 1383 TODO(); 1384 } 1385 1386 static __inline void 1387 cfg80211_scan_done(struct cfg80211_scan_request *scan_request, 1388 struct cfg80211_scan_info *info) 1389 { 1390 TODO(); 1391 } 1392 1393 static __inline void 1394 cfg80211_sched_scan_results(struct wiphy *wiphy, uint64_t reqid) 1395 { 1396 TODO(); 1397 } 1398 1399 static __inline void 1400 cfg80211_sched_scan_stopped(struct wiphy *wiphy, int _x) 1401 { 1402 TODO(); 1403 } 1404 1405 static __inline void 1406 cfg80211_unregister_wdev(struct wireless_dev *wdev) 1407 { 1408 TODO(); 1409 } 1410 1411 static __inline struct sk_buff * 1412 cfg80211_vendor_cmd_alloc_reply_skb(struct wiphy *wiphy, unsigned int len) 1413 { 1414 TODO(); 1415 return (NULL); 1416 } 1417 1418 static __inline int 1419 cfg80211_vendor_cmd_reply(struct sk_buff *skb) 1420 { 1421 TODO(); 1422 return (-ENXIO); 1423 } 1424 1425 static __inline struct linuxkpi_ieee80211_channel * 1426 ieee80211_get_channel(struct wiphy *wiphy, uint32_t freq) 1427 { 1428 TODO(); 1429 return (NULL); 1430 } 1431 1432 static __inline size_t 1433 ieee80211_get_hdrlen_from_skb(struct sk_buff *skb) 1434 { 1435 1436 TODO(); 1437 return (-1); 1438 } 1439 1440 static __inline void 1441 cfg80211_bss_flush(struct wiphy *wiphy) 1442 { 1443 TODO(); 1444 } 1445 1446 static __inline bool 1447 cfg80211_channel_is_psc(struct linuxkpi_ieee80211_channel *channel) 1448 { 1449 1450 /* Only 6Ghz. */ 1451 if (channel->band != NL80211_BAND_6GHZ) 1452 return (false); 1453 1454 TODO(); 1455 return (false); 1456 } 1457 1458 1459 /* Used for scanning at least. */ 1460 static __inline void 1461 get_random_mask_addr(uint8_t *dst, const uint8_t *addr, const uint8_t *mask) 1462 { 1463 int i; 1464 1465 /* Get a completely random address and then overlay what we want. */ 1466 get_random_bytes(dst, ETH_ALEN); 1467 for (i = 0; i < ETH_ALEN; i++) 1468 dst[i] = (dst[i] & ~(mask[i])) | (addr[i] & mask[i]); 1469 } 1470 1471 #ifndef LINUXKPI_NET80211 1472 #define ieee80211_channel linuxkpi_ieee80211_channel 1473 #define ieee80211_regdomain linuxkpi_ieee80211_regdomain 1474 /* net80211::IEEE80211_VHT_MCS_SUPPORT_0_n() conflicts */ 1475 #if defined(IEEE80211_VHT_MCS_SUPPORT_0_7) 1476 #undef IEEE80211_VHT_MCS_SUPPORT_0_7 1477 #endif 1478 #if defined(IEEE80211_VHT_MCS_SUPPORT_0_8) 1479 #undef IEEE80211_VHT_MCS_SUPPORT_0_8 1480 #endif 1481 #if defined(IEEE80211_VHT_MCS_SUPPORT_0_9) 1482 #undef IEEE80211_VHT_MCS_SUPPORT_0_9 1483 #endif 1484 #define IEEE80211_VHT_MCS_SUPPORT_0_7 LKPI_IEEE80211_VHT_MCS_SUPPORT_0_7 1485 #define IEEE80211_VHT_MCS_SUPPORT_0_8 LKPI_IEEE80211_VHT_MCS_SUPPORT_0_8 1486 #define IEEE80211_VHT_MCS_SUPPORT_0_9 LKPI_IEEE80211_VHT_MCS_SUPPORT_0_9 1487 #endif 1488 1489 #endif /* _LINUXKPI_NET_CFG80211_H */ 1490