1 /*- 2 * Copyright (c) 2020-2025 The FreeBSD Foundation 3 * Copyright (c) 2020-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_MAC80211_H 31 #define _LINUXKPI_NET_MAC80211_H 32 33 #include <sys/types.h> 34 35 #include <asm/atomic64.h> 36 #include <linux/bitops.h> 37 #include <linux/bitfield.h> 38 #include <linux/etherdevice.h> 39 #include <linux/ethtool.h> 40 #include <linux/netdevice.h> 41 #include <linux/skbuff.h> 42 #include <linux/workqueue.h> 43 #include <linux/dcache.h> 44 #include <net/cfg80211.h> 45 #include <net/if_inet6.h> 46 47 #define ARPHRD_IEEE80211_RADIOTAP __LINE__ /* XXX TODO brcmfmac */ 48 49 #define WLAN_OUI_MICROSOFT (0x0050F2) 50 #define WLAN_OUI_TYPE_MICROSOFT_WPA (1) 51 #define WLAN_OUI_TYPE_MICROSOFT_TPC (8) 52 #define WLAN_OUI_TYPE_WFA_P2P (9) 53 #define WLAN_OUI_WFA (0x506F9A) 54 55 #define IEEE80211_LINK_UNSPECIFIED 0x0f 56 57 /* hw->conf.flags */ 58 enum ieee80211_hw_conf_flags { 59 IEEE80211_CONF_IDLE = BIT(0), 60 IEEE80211_CONF_PS = BIT(1), 61 IEEE80211_CONF_MONITOR = BIT(2), 62 IEEE80211_CONF_OFFCHANNEL = BIT(3), 63 }; 64 65 /* (*ops->config()) */ 66 enum ieee80211_hw_conf_changed_flags { 67 IEEE80211_CONF_CHANGE_CHANNEL = BIT(0), 68 IEEE80211_CONF_CHANGE_IDLE = BIT(1), 69 IEEE80211_CONF_CHANGE_PS = BIT(2), 70 IEEE80211_CONF_CHANGE_MONITOR = BIT(3), 71 IEEE80211_CONF_CHANGE_POWER = BIT(4), 72 }; 73 74 #define CFG80211_TESTMODE_CMD(_x) /* XXX TODO */ 75 #define CFG80211_TESTMODE_DUMP(_x) /* XXX TODO */ 76 77 #define FCS_LEN 4 78 79 /* ops.configure_filter() */ 80 enum mcast_filter_flags { 81 FIF_ALLMULTI = BIT(0), 82 FIF_PROBE_REQ = BIT(1), 83 FIF_BCN_PRBRESP_PROMISC = BIT(2), 84 FIF_FCSFAIL = BIT(3), 85 FIF_OTHER_BSS = BIT(4), 86 FIF_PSPOLL = BIT(5), 87 FIF_CONTROL = BIT(6), 88 FIF_MCAST_ACTION = BIT(7), 89 }; 90 91 enum ieee80211_bss_changed { 92 BSS_CHANGED_ARP_FILTER = BIT(0), 93 BSS_CHANGED_ASSOC = BIT(1), 94 BSS_CHANGED_BANDWIDTH = BIT(2), 95 BSS_CHANGED_BEACON = BIT(3), 96 BSS_CHANGED_BEACON_ENABLED = BIT(4), 97 BSS_CHANGED_BEACON_INFO = BIT(5), 98 BSS_CHANGED_BEACON_INT = BIT(6), 99 BSS_CHANGED_BSSID = BIT(7), 100 BSS_CHANGED_CQM = BIT(8), 101 BSS_CHANGED_ERP_CTS_PROT = BIT(9), 102 BSS_CHANGED_ERP_SLOT = BIT(10), 103 BSS_CHANGED_FTM_RESPONDER = BIT(11), 104 BSS_CHANGED_HT = BIT(12), 105 BSS_CHANGED_IDLE = BIT(13), 106 BSS_CHANGED_MU_GROUPS = BIT(14), 107 BSS_CHANGED_P2P_PS = BIT(15), 108 BSS_CHANGED_PS = BIT(16), 109 BSS_CHANGED_QOS = BIT(17), 110 BSS_CHANGED_TXPOWER = BIT(18), 111 BSS_CHANGED_HE_BSS_COLOR = BIT(19), 112 BSS_CHANGED_AP_PROBE_RESP = BIT(20), 113 BSS_CHANGED_BASIC_RATES = BIT(21), 114 BSS_CHANGED_ERP_PREAMBLE = BIT(22), 115 BSS_CHANGED_IBSS = BIT(23), 116 BSS_CHANGED_MCAST_RATE = BIT(24), 117 BSS_CHANGED_SSID = BIT(25), 118 BSS_CHANGED_FILS_DISCOVERY = BIT(26), 119 BSS_CHANGED_HE_OBSS_PD = BIT(27), 120 BSS_CHANGED_TWT = BIT(28), 121 BSS_CHANGED_UNSOL_BCAST_PROBE_RESP = BIT(30), 122 BSS_CHANGED_EHT_PUNCTURING = BIT(31), 123 BSS_CHANGED_MLD_VALID_LINKS = BIT_ULL(32), 124 BSS_CHANGED_MLD_TTLM = BIT_ULL(33), 125 BSS_CHANGED_TPE = BIT_ULL(34), 126 }; 127 128 /* 802.11 Figure 9-256 Suite selector format. [OUI(3), SUITE TYPE(1)] */ 129 #define WLAN_CIPHER_SUITE_OUI(_oui, _x) (((_oui) << 8) | ((_x) & 0xff)) 130 131 /* 802.11 Table 9-131 Cipher suite selectors. */ 132 /* 802.1x suite B 11 */ 133 #define WLAN_CIPHER_SUITE(_x) WLAN_CIPHER_SUITE_OUI(0x000fac, _x) 134 /* Use group 0 */ 135 #define WLAN_CIPHER_SUITE_WEP40 WLAN_CIPHER_SUITE(1) 136 #define WLAN_CIPHER_SUITE_TKIP WLAN_CIPHER_SUITE(2) 137 /* Reserved 3 */ 138 #define WLAN_CIPHER_SUITE_CCMP WLAN_CIPHER_SUITE(4) /* CCMP-128 */ 139 #define WLAN_CIPHER_SUITE_WEP104 WLAN_CIPHER_SUITE(5) 140 #define WLAN_CIPHER_SUITE_AES_CMAC WLAN_CIPHER_SUITE(6) /* BIP-CMAC-128 */ 141 /* Group addressed traffic not allowed 7 */ 142 #define WLAN_CIPHER_SUITE_GCMP WLAN_CIPHER_SUITE(8) 143 #define WLAN_CIPHER_SUITE_GCMP_256 WLAN_CIPHER_SUITE(9) 144 #define WLAN_CIPHER_SUITE_CCMP_256 WLAN_CIPHER_SUITE(10) 145 #define WLAN_CIPHER_SUITE_BIP_GMAC_128 WLAN_CIPHER_SUITE(11) 146 #define WLAN_CIPHER_SUITE_BIP_GMAC_256 WLAN_CIPHER_SUITE(12) 147 #define WLAN_CIPHER_SUITE_BIP_CMAC_256 WLAN_CIPHER_SUITE(13) 148 /* Reserved 14-255 */ 149 150 /* See ISO/IEC JTC 1 N 9880 Table 11 */ 151 #define WLAN_CIPHER_SUITE_SMS4 WLAN_CIPHER_SUITE_OUI(0x001472, 1) 152 153 154 /* 802.11 Table 9-133 AKM suite selectors. */ 155 #define WLAN_AKM_SUITE(_x) WLAN_CIPHER_SUITE_OUI(0x000fac, _x) 156 /* Reserved 0 */ 157 #define WLAN_AKM_SUITE_8021X WLAN_AKM_SUITE(1) 158 #define WLAN_AKM_SUITE_PSK WLAN_AKM_SUITE(2) 159 #define WLAN_AKM_SUITE_FT_8021X WLAN_AKM_SUITE(3) 160 #define WLAN_AKM_SUITE_FT_PSK WLAN_AKM_SUITE(4) 161 #define WLAN_AKM_SUITE_8021X_SHA256 WLAN_AKM_SUITE(5) 162 #define WLAN_AKM_SUITE_PSK_SHA256 WLAN_AKM_SUITE(6) 163 /* TDLS 7 */ 164 #define WLAN_AKM_SUITE_SAE WLAN_AKM_SUITE(8) 165 /* FToSAE 9 */ 166 /* AP peer key 10 */ 167 /* 802.1x suite B 11 */ 168 /* 802.1x suite B 384 12 */ 169 /* FTo802.1x 384 13 */ 170 /* Reserved 14-255 */ 171 /* Apparently 11ax defines more. Seen (19,20) mentioned. */ 172 173 #define TKIP_PN_TO_IV16(_x) ((uint16_t)(_x & 0xffff)) 174 #define TKIP_PN_TO_IV32(_x) ((uint32_t)((_x >> 16) & 0xffffffff)) 175 176 enum ieee80211_neg_ttlm_res { 177 NEG_TTLM_RES_ACCEPT, 178 NEG_TTLM_RES_REJECT, 179 }; 180 181 #define IEEE80211_TTLM_NUM_TIDS 8 182 struct ieee80211_neg_ttlm { 183 uint16_t downlink[IEEE80211_TTLM_NUM_TIDS]; 184 uint16_t uplink[IEEE80211_TTLM_NUM_TIDS]; 185 }; 186 187 /* 802.11-2020 9.4.2.55.3 A-MPDU Parameters field */ 188 #define IEEE80211_HT_AMPDU_PARM_FACTOR 0x3 189 #define IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT 2 190 #define IEEE80211_HT_AMPDU_PARM_DENSITY (0x7 << IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT) 191 192 struct ieee80211_sta; 193 194 struct ieee80211_ampdu_params { 195 struct ieee80211_sta *sta; 196 enum ieee80211_ampdu_mlme_action action; 197 uint16_t buf_size; 198 uint16_t timeout; 199 uint16_t ssn; 200 uint8_t tid; 201 bool amsdu; 202 }; 203 204 struct ieee80211_bar { 205 /* TODO FIXME */ 206 int control, start_seq_num; 207 uint8_t *ra; 208 uint16_t frame_control; 209 }; 210 211 struct ieee80211_p2p_noa_desc { 212 uint32_t count; /* uint8_t ? */ 213 uint32_t duration; 214 uint32_t interval; 215 uint32_t start_time; 216 }; 217 218 struct ieee80211_p2p_noa_attr { 219 uint8_t index; 220 uint8_t oppps_ctwindow; 221 struct ieee80211_p2p_noa_desc desc[4]; 222 }; 223 224 struct ieee80211_mutable_offsets { 225 /* TODO FIXME */ 226 uint16_t tim_offset; 227 uint16_t cntdwn_counter_offs[2]; 228 229 int mbssid_off; 230 }; 231 232 struct mac80211_fils_discovery { 233 uint32_t max_interval; 234 }; 235 236 struct ieee80211_chanctx_conf { 237 struct cfg80211_chan_def def; 238 struct cfg80211_chan_def min_def; 239 struct cfg80211_chan_def ap; 240 241 uint8_t rx_chains_dynamic; 242 uint8_t rx_chains_static; 243 bool radar_enabled; 244 245 /* Must stay last. */ 246 uint8_t drv_priv[0] __aligned(CACHE_LINE_SIZE); 247 }; 248 249 struct ieee80211_rate_status { 250 struct rate_info rate_idx; 251 uint8_t try_count; 252 }; 253 254 struct ieee80211_ema_beacons { 255 uint8_t cnt; 256 struct { 257 struct sk_buff *skb; 258 struct ieee80211_mutable_offsets offs; 259 } bcn[0]; 260 }; 261 262 struct ieee80211_chanreq { 263 struct cfg80211_chan_def oper; 264 }; 265 266 #define WLAN_MEMBERSHIP_LEN (8) 267 #define WLAN_USER_POSITION_LEN (16) 268 269 /* 270 * 802.11ac-2013, 8.4.2.164 VHT Transmit Power Envelope element 271 * 802.11-???? ? 272 */ 273 struct ieee80211_parsed_tpe_eirp { 274 int8_t power[5]; 275 uint8_t count; 276 bool valid; 277 }; 278 struct ieee80211_parsed_tpe_psd { 279 int8_t power[16]; 280 uint8_t count; 281 bool valid; 282 }; 283 struct ieee80211_parsed_tpe { 284 /* We see access to [0] so assume at least 2. */ 285 struct ieee80211_parsed_tpe_eirp max_local[2]; 286 struct ieee80211_parsed_tpe_eirp max_reg_client[2]; 287 struct ieee80211_parsed_tpe_psd psd_local[2]; 288 struct ieee80211_parsed_tpe_psd psd_reg_client[2]; 289 }; 290 291 struct ieee80211_bss_conf { 292 /* TODO FIXME */ 293 struct ieee80211_vif *vif; 294 struct cfg80211_bss *bss; 295 const uint8_t *bssid; 296 uint8_t addr[ETH_ALEN]; 297 uint8_t link_id; 298 uint8_t _pad0; 299 uint8_t transmitter_bssid[ETH_ALEN]; 300 struct ieee80211_ftm_responder_params *ftmr_params; 301 struct ieee80211_p2p_noa_attr p2p_noa_attr; 302 struct ieee80211_chanreq chanreq; 303 __be32 arp_addr_list[1]; /* XXX TODO */ 304 struct ieee80211_rate *beacon_rate; 305 struct { 306 uint8_t membership[WLAN_MEMBERSHIP_LEN]; 307 uint8_t position[WLAN_USER_POSITION_LEN]; 308 } mu_group; 309 struct { 310 uint32_t params; 311 /* single field struct? */ 312 } he_oper; 313 struct cfg80211_he_bss_color he_bss_color; 314 struct ieee80211_he_obss_pd he_obss_pd; 315 316 bool ht_ldpc; 317 bool vht_ldpc; 318 bool he_ldpc; 319 bool vht_mu_beamformee; 320 bool vht_mu_beamformer; 321 bool vht_su_beamformee; 322 bool vht_su_beamformer; 323 bool he_mu_beamformer; 324 bool he_su_beamformee; 325 bool he_su_beamformer; 326 bool he_full_ul_mumimo; 327 bool eht_su_beamformee; 328 bool eht_su_beamformer; 329 bool eht_mu_beamformer; 330 331 uint16_t ht_operation_mode; 332 int arp_addr_cnt; 333 uint16_t eht_puncturing; 334 335 uint8_t dtim_period; 336 uint8_t sync_dtim_count; 337 bool qos; 338 bool twt_broadcast; 339 bool use_cts_prot; 340 bool use_short_preamble; 341 bool use_short_slot; 342 bool he_support; 343 bool eht_support; 344 bool csa_active; 345 bool mu_mimo_owner; 346 uint32_t sync_device_ts; 347 uint64_t sync_tsf; 348 uint16_t beacon_int; 349 int16_t txpower; 350 uint32_t basic_rates; 351 int mcast_rate[NUM_NL80211_BANDS]; 352 enum ieee80211_ap_reg_power power_type; 353 struct cfg80211_bitrate_mask beacon_tx_rate; 354 struct mac80211_fils_discovery fils_discovery; 355 struct ieee80211_chanctx_conf *chanctx_conf; 356 struct ieee80211_vif *mbssid_tx_vif; 357 struct ieee80211_parsed_tpe tpe; 358 359 int ack_enabled, bssid_index, bssid_indicator, cqm_rssi_hyst, cqm_rssi_thold, ema_ap, frame_time_rts_th, ftm_responder; 360 int htc_trig_based_pkt_ext; 361 int multi_sta_back_32bit, nontransmitted; 362 int profile_periodicity; 363 int twt_requester, uora_exists, uora_ocw_range; 364 int assoc_capability, enable_beacon, hidden_ssid, ibss_joined, twt_protected; 365 int twt_responder, unsol_bcast_probe_resp_interval; 366 int color_change_active; 367 }; 368 369 struct ieee80211_channel_switch { 370 /* TODO FIXME */ 371 int block_tx, count, delay, device_timestamp, timestamp; 372 uint8_t link_id; 373 struct cfg80211_chan_def chandef; 374 }; 375 376 struct ieee80211_cipher_scheme { 377 uint32_t cipher; 378 uint8_t iftype; /* We do not know the size of this. */ 379 uint8_t hdr_len; 380 uint8_t pn_len; 381 uint8_t pn_off; 382 uint8_t key_idx_off; 383 uint8_t key_idx_mask; 384 uint8_t key_idx_shift; 385 uint8_t mic_len; 386 }; 387 388 enum ieee80211_event_type { 389 BA_FRAME_TIMEOUT, 390 BAR_RX_EVENT, 391 MLME_EVENT, 392 RSSI_EVENT, 393 }; 394 395 enum ieee80211_rssi_event_data { 396 RSSI_EVENT_LOW, 397 RSSI_EVENT_HIGH, 398 }; 399 400 enum ieee80211_mlme_event_data { 401 ASSOC_EVENT, 402 AUTH_EVENT, 403 DEAUTH_RX_EVENT, 404 DEAUTH_TX_EVENT, 405 }; 406 407 enum ieee80211_mlme_event_status { 408 MLME_DENIED, 409 MLME_TIMEOUT, 410 }; 411 412 struct ieee80211_mlme_event { 413 enum ieee80211_mlme_event_data data; 414 enum ieee80211_mlme_event_status status; 415 int reason; 416 }; 417 418 struct ieee80211_event { 419 /* TODO FIXME */ 420 enum ieee80211_event_type type; 421 union { 422 struct { 423 int ssn; 424 struct ieee80211_sta *sta; 425 uint8_t tid; 426 } ba; 427 struct ieee80211_mlme_event mlme; 428 } u; 429 }; 430 431 struct ieee80211_ftm_responder_params { 432 /* TODO FIXME */ 433 uint8_t *lci; 434 uint8_t *civicloc; 435 int lci_len; 436 int civicloc_len; 437 }; 438 439 struct ieee80211_he_mu_edca_param_ac_rec { 440 /* TODO FIXME */ 441 int aifsn, ecw_min_max, mu_edca_timer; 442 }; 443 444 struct ieee80211_conf { 445 int dynamic_ps_timeout; 446 int power_level; 447 uint32_t listen_interval; 448 bool radar_enabled; 449 enum ieee80211_hw_conf_flags flags; 450 struct cfg80211_chan_def chandef; 451 }; 452 453 enum ieee80211_hw_flags { 454 IEEE80211_HW_AMPDU_AGGREGATION, 455 IEEE80211_HW_AP_LINK_PS, 456 IEEE80211_HW_BUFF_MMPDU_TXQ, 457 IEEE80211_HW_CHANCTX_STA_CSA, 458 IEEE80211_HW_CONNECTION_MONITOR, 459 IEEE80211_HW_DEAUTH_NEED_MGD_TX_PREP, 460 IEEE80211_HW_HAS_RATE_CONTROL, 461 IEEE80211_HW_MFP_CAPABLE, 462 IEEE80211_HW_NEEDS_UNIQUE_STA_ADDR, 463 IEEE80211_HW_REPORTS_TX_ACK_STATUS, 464 IEEE80211_HW_RX_INCLUDES_FCS, 465 IEEE80211_HW_SIGNAL_DBM, 466 IEEE80211_HW_SINGLE_SCAN_ON_ALL_BANDS, 467 IEEE80211_HW_SPECTRUM_MGMT, 468 IEEE80211_HW_STA_MMPDU_TXQ, 469 IEEE80211_HW_SUPPORTS_AMSDU_IN_AMPDU, 470 IEEE80211_HW_SUPPORTS_CLONED_SKBS, 471 IEEE80211_HW_SUPPORTS_DYNAMIC_PS, 472 IEEE80211_HW_SUPPORTS_MULTI_BSSID, 473 IEEE80211_HW_SUPPORTS_ONLY_HE_MULTI_BSSID, 474 IEEE80211_HW_SUPPORTS_PS, 475 IEEE80211_HW_SUPPORTS_REORDERING_BUFFER, 476 IEEE80211_HW_SUPPORTS_VHT_EXT_NSS_BW, 477 IEEE80211_HW_SUPPORT_FAST_XMIT, 478 IEEE80211_HW_TDLS_WIDER_BW, 479 IEEE80211_HW_TIMING_BEACON_ONLY, 480 IEEE80211_HW_TX_AMPDU_SETUP_IN_HW, 481 IEEE80211_HW_TX_AMSDU, 482 IEEE80211_HW_TX_FRAG_LIST, 483 IEEE80211_HW_USES_RSS, 484 IEEE80211_HW_WANT_MONITOR_VIF, 485 IEEE80211_HW_SW_CRYPTO_CONTROL, 486 IEEE80211_HW_SUPPORTS_TX_FRAG, 487 IEEE80211_HW_SUPPORTS_TDLS_BUFFER_STA, 488 IEEE80211_HW_SUPPORTS_PER_STA_GTK, 489 IEEE80211_HW_REPORTS_LOW_ACK, 490 IEEE80211_HW_QUEUE_CONTROL, 491 IEEE80211_HW_SUPPORTS_RX_DECAP_OFFLOAD, 492 IEEE80211_HW_SUPPORTS_TX_ENCAP_OFFLOAD, 493 IEEE80211_HW_SUPPORTS_RC_TABLE, 494 IEEE80211_HW_DETECTS_COLOR_COLLISION, 495 IEEE80211_HW_DISALLOW_PUNCTURING, 496 IEEE80211_HW_DISALLOW_PUNCTURING_5GHZ, 497 IEEE80211_HW_TX_STATUS_NO_AMPDU_LEN, 498 IEEE80211_HW_HANDLES_QUIET_CSA, 499 500 /* Keep last. */ 501 NUM_IEEE80211_HW_FLAGS 502 }; 503 504 struct ieee80211_hw { 505 506 struct wiphy *wiphy; 507 508 /* TODO FIXME */ 509 int extra_tx_headroom, weight_multiplier; 510 int max_rate_tries, max_rates, max_report_rates; 511 struct ieee80211_cipher_scheme *cipher_schemes; 512 int n_cipher_schemes; 513 const char *rate_control_algorithm; 514 struct { 515 uint16_t units_pos; /* radiotap "spec" is .. inconsistent. */ 516 uint16_t accuracy; 517 } radiotap_timestamp; 518 size_t sta_data_size; 519 size_t vif_data_size; 520 size_t chanctx_data_size; 521 size_t txq_data_size; 522 uint16_t radiotap_mcs_details; 523 uint16_t radiotap_vht_details; 524 uint16_t queues; 525 uint16_t offchannel_tx_hw_queue; 526 uint16_t uapsd_max_sp_len; 527 uint16_t uapsd_queues; 528 uint16_t max_rx_aggregation_subframes; 529 uint16_t max_tx_aggregation_subframes; 530 uint16_t max_tx_fragments; 531 uint16_t max_listen_interval; 532 uint32_t extra_beacon_tailroom; 533 netdev_features_t netdev_features; 534 unsigned long flags[BITS_TO_LONGS(NUM_IEEE80211_HW_FLAGS)]; 535 struct ieee80211_conf conf; 536 537 #if 0 /* leave here for documentation purposes. This does NOT work. */ 538 /* Must stay last. */ 539 uint8_t priv[0] __aligned(CACHE_LINE_SIZE); 540 #else 541 void *priv; 542 #endif 543 }; 544 545 enum ieee802111_key_flag { 546 IEEE80211_KEY_FLAG_GENERATE_IV = BIT(0), 547 IEEE80211_KEY_FLAG_GENERATE_MMIC = BIT(1), 548 IEEE80211_KEY_FLAG_PAIRWISE = BIT(2), 549 IEEE80211_KEY_FLAG_PUT_IV_SPACE = BIT(3), 550 IEEE80211_KEY_FLAG_PUT_MIC_SPACE = BIT(4), 551 IEEE80211_KEY_FLAG_SW_MGMT_TX = BIT(5), 552 IEEE80211_KEY_FLAG_GENERATE_IV_MGMT = BIT(6), 553 IEEE80211_KEY_FLAG_GENERATE_MMIE = BIT(7), 554 IEEE80211_KEY_FLAG_RESERVE_TAILROOM = BIT(8), 555 IEEE80211_KEY_FLAG_SPP_AMSDU = BIT(9), 556 }; 557 558 struct ieee80211_key_conf { 559 #if defined(__FreeBSD__) 560 const struct ieee80211_key *_k; /* backpointer to net80211 */ 561 #endif 562 atomic64_t tx_pn; 563 uint32_t cipher; 564 uint8_t icv_len; /* __unused nowadays? */ 565 uint8_t iv_len; 566 uint8_t hw_key_idx; /* Set by drv. */ 567 uint8_t keyidx; 568 uint16_t flags; 569 int8_t link_id; /* signed! */ 570 uint8_t keylen; 571 uint8_t key[0]; /* Must stay last! */ 572 }; 573 574 struct ieee80211_key_seq { 575 /* TODO FIXME */ 576 union { 577 struct { 578 uint8_t seq[IEEE80211_MAX_PN_LEN]; 579 uint8_t seq_len; 580 } hw; 581 struct { 582 uint8_t pn[IEEE80211_CCMP_PN_LEN]; 583 } ccmp; 584 struct { 585 uint8_t pn[IEEE80211_GCMP_PN_LEN]; 586 } gcmp; 587 struct { 588 uint8_t pn[IEEE80211_CMAC_PN_LEN]; 589 } aes_cmac; 590 struct { 591 uint8_t pn[IEEE80211_GMAC_PN_LEN]; 592 } aes_gmac; 593 struct { 594 uint32_t iv32; 595 uint16_t iv16; 596 } tkip; 597 }; 598 }; 599 600 601 enum ieee80211_rx_status_flags { 602 RX_FLAG_ALLOW_SAME_PN = BIT(0), 603 RX_FLAG_AMPDU_DETAILS = BIT(1), 604 RX_FLAG_AMPDU_EOF_BIT = BIT(2), 605 RX_FLAG_AMPDU_EOF_BIT_KNOWN = BIT(3), 606 RX_FLAG_DECRYPTED = BIT(4), 607 RX_FLAG_DUP_VALIDATED = BIT(5), 608 RX_FLAG_FAILED_FCS_CRC = BIT(6), 609 RX_FLAG_ICV_STRIPPED = BIT(7), 610 RX_FLAG_MACTIME = BIT(8) | BIT(9), 611 RX_FLAG_MACTIME_PLCP_START = 1 << 8, 612 RX_FLAG_MACTIME_START = 2 << 8, 613 RX_FLAG_MACTIME_END = 3 << 8, 614 RX_FLAG_MIC_STRIPPED = BIT(10), 615 RX_FLAG_MMIC_ERROR = BIT(11), 616 RX_FLAG_MMIC_STRIPPED = BIT(12), 617 RX_FLAG_NO_PSDU = BIT(13), 618 RX_FLAG_PN_VALIDATED = BIT(14), 619 RX_FLAG_RADIOTAP_HE = BIT(15), 620 RX_FLAG_RADIOTAP_HE_MU = BIT(16), 621 RX_FLAG_RADIOTAP_LSIG = BIT(17), 622 RX_FLAG_RADIOTAP_VENDOR_DATA = BIT(18), 623 RX_FLAG_NO_SIGNAL_VAL = BIT(19), 624 RX_FLAG_IV_STRIPPED = BIT(20), 625 RX_FLAG_AMPDU_IS_LAST = BIT(21), 626 RX_FLAG_AMPDU_LAST_KNOWN = BIT(22), 627 RX_FLAG_AMSDU_MORE = BIT(23), 628 /* = BIT(24), */ 629 RX_FLAG_ONLY_MONITOR = BIT(25), 630 RX_FLAG_SKIP_MONITOR = BIT(26), 631 RX_FLAG_8023 = BIT(27), 632 RX_FLAG_RADIOTAP_TLV_AT_END = BIT(28), 633 /* = BIT(29), */ 634 RX_FLAG_MACTIME_IS_RTAP_TS64 = BIT(30), 635 RX_FLAG_FAILED_PLCP_CRC = BIT(31), 636 }; 637 638 #define IEEE80211_RX_STATUS_FLAGS_BITS \ 639 "\20\1ALLOW_SAME_PN\2AMPDU_DETAILS\3AMPDU_EOF_BIT\4AMPDU_EOF_BIT_KNOWN" \ 640 "\5DECRYPTED\6DUP_VALIDATED\7FAILED_FCS_CRC\10ICV_STRIPPED" \ 641 "\11MACTIME_PLCP_START\12MACTIME_START\13MIC_STRIPPED" \ 642 "\14MMIC_ERROR\15MMIC_STRIPPED\16NO_PSDU\17PN_VALIDATED" \ 643 "\20RADIOTAP_HE\21RADIOTAP_HE_MU\22RADIOTAP_LSIG\23RADIOTAP_VENDOR_DATA" \ 644 "\24NO_SIGNAL_VAL\25IV_STRIPPED\26AMPDU_IS_LAST\27AMPDU_LAST_KNOWN" \ 645 "\30AMSDU_MORE\31MACTIME_END\32ONLY_MONITOR\33SKIP_MONITOR" \ 646 "\348023\35RADIOTAP_TLV_AT_END\36MACTIME\37MACTIME_IS_RTAP_TS64" \ 647 "\40FAILED_PLCP_CRC" 648 649 enum mac80211_rx_encoding { 650 RX_ENC_LEGACY = 0, 651 RX_ENC_HT, 652 RX_ENC_VHT, 653 RX_ENC_HE, 654 RX_ENC_EHT, 655 }; 656 657 struct ieee80211_rx_status { 658 /* TODO FIXME, this is too large. Over-reduce types to u8 where possible. */ 659 union { 660 uint64_t boottime_ns; 661 int64_t ack_tx_hwtstamp; 662 }; 663 uint64_t mactime; 664 uint32_t device_timestamp; 665 enum ieee80211_rx_status_flags flag; 666 uint16_t freq; 667 uint8_t encoding:3, bw:4; /* enum mac80211_rx_encoding, rate_info_bw */ /* See mt76.h */ 668 uint8_t ampdu_reference; 669 uint8_t band; 670 uint8_t chains; 671 int8_t chain_signal[IEEE80211_MAX_CHAINS]; 672 int8_t signal; 673 uint8_t enc_flags; 674 union { 675 struct { 676 uint8_t he_ru:3; /* nl80211::enum nl80211_he_ru_alloc */ 677 uint8_t he_gi:2; /* nl80211::enum nl80211_he_gi */ 678 uint8_t he_dcm:1; 679 }; 680 struct { 681 uint8_t ru:4; /* nl80211::enum nl80211_eht_ru_alloc */ 682 uint8_t gi:2; /* nl80211::enum nl80211_eht_gi */ 683 } eht; 684 }; 685 bool link_valid; 686 uint8_t link_id; /* very incosistent sizes? */ 687 uint8_t zero_length_psdu_type; 688 uint8_t nss; 689 uint8_t rate_idx; 690 }; 691 692 struct ieee80211_tx_status { 693 struct ieee80211_sta *sta; 694 struct ieee80211_tx_info *info; 695 int64_t ack_hwtstamp; 696 697 u8 n_rates; 698 struct ieee80211_rate_status *rates; 699 700 struct sk_buff *skb; 701 struct list_head *free_list; 702 }; 703 704 struct ieee80211_scan_ies { 705 /* TODO FIXME */ 706 int common_ie_len; 707 int len[NUM_NL80211_BANDS]; 708 uint8_t *common_ies; 709 uint8_t *ies[NUM_NL80211_BANDS]; 710 }; 711 712 struct ieee80211_scan_request { 713 struct ieee80211_scan_ies ies; 714 struct cfg80211_scan_request req; 715 }; 716 717 struct ieee80211_txq { 718 struct ieee80211_sta *sta; 719 struct ieee80211_vif *vif; 720 int ac; 721 uint8_t tid; 722 723 /* Must stay last. */ 724 uint8_t drv_priv[0] __aligned(CACHE_LINE_SIZE); 725 }; 726 727 struct ieee80211_sta_rates { 728 /* XXX TODO */ 729 /* XXX some _rcu thing */ 730 struct { 731 int idx; 732 int flags; 733 } rate[1]; /* XXX what is the real number? */ 734 }; 735 736 struct ieee80211_sta_txpwr { 737 /* XXX TODO */ 738 enum nl80211_tx_power_setting type; 739 short power; 740 }; 741 742 #define IEEE80211_NUM_TIDS 16 /* net80211::WME_NUM_TID */ 743 struct ieee80211_sta_agg { 744 uint16_t max_amsdu_len; 745 uint16_t max_rc_amsdu_len; 746 uint16_t max_tid_amsdu_len[IEEE80211_NUM_TIDS]; 747 }; 748 749 struct ieee80211_link_sta { 750 struct ieee80211_sta *sta; 751 uint8_t addr[ETH_ALEN]; 752 uint8_t link_id; 753 uint32_t supp_rates[NUM_NL80211_BANDS]; 754 struct ieee80211_sta_ht_cap ht_cap; 755 struct ieee80211_sta_vht_cap vht_cap; 756 struct ieee80211_sta_he_cap he_cap; 757 struct ieee80211_sta_he_6ghz_capa he_6ghz_capa; 758 struct ieee80211_sta_eht_cap eht_cap; 759 uint8_t rx_nss; 760 enum ieee80211_sta_rx_bw bandwidth; 761 enum ieee80211_smps_mode smps_mode; 762 struct ieee80211_sta_agg agg; 763 struct ieee80211_sta_txpwr txpwr; 764 }; 765 766 struct ieee80211_sta { 767 /* TODO FIXME */ 768 int max_amsdu_subframes; 769 int mfp, smps_mode, tdls, tdls_initiator; 770 struct ieee80211_txq *txq[IEEE80211_NUM_TIDS + 1]; /* iwlwifi: 8 and adds +1 to tid_data, net80211::IEEE80211_TID_SIZE */ 771 struct ieee80211_sta_rates *rates; /* some rcu thing? */ 772 uint8_t addr[ETH_ALEN]; 773 uint16_t aid; 774 bool wme; 775 uint8_t max_sp; 776 uint8_t uapsd_queues; 777 uint16_t valid_links; 778 779 struct ieee80211_link_sta deflink; 780 struct ieee80211_link_sta *link[IEEE80211_MLD_MAX_NUM_LINKS]; /* rcu? */ 781 782 /* Must stay last. */ 783 uint8_t drv_priv[0] __aligned(CACHE_LINE_SIZE); 784 }; 785 786 struct ieee80211_tdls_ch_sw_params { 787 /* TODO FIXME */ 788 int action_code, ch_sw_tm_ie, status, switch_time, switch_timeout, timestamp; 789 struct ieee80211_sta *sta; 790 struct cfg80211_chan_def *chandef; 791 struct sk_buff *tmpl_skb; 792 }; 793 794 struct ieee80211_tx_control { 795 /* TODO FIXME */ 796 struct ieee80211_sta *sta; 797 }; 798 799 struct ieee80211_tx_queue_params { 800 /* These types are based on iwlwifi FW structs. */ 801 uint16_t cw_min; 802 uint16_t cw_max; 803 uint16_t txop; 804 uint8_t aifs; 805 806 /* TODO FIXME */ 807 int acm, mu_edca, uapsd; 808 struct ieee80211_he_mu_edca_param_ac_rec mu_edca_param_rec; 809 }; 810 811 struct ieee80211_tx_rate { 812 uint8_t idx; 813 uint16_t count:5, 814 flags:11; 815 }; 816 817 enum ieee80211_vif_driver_flags { 818 IEEE80211_VIF_BEACON_FILTER = BIT(0), 819 IEEE80211_VIF_SUPPORTS_CQM_RSSI = BIT(1), 820 IEEE80211_VIF_SUPPORTS_UAPSD = BIT(2), 821 #if defined(LINUXKPI_VERSION) && (LINUXKPI_VERSION < 60600) /* v6.6 */ 822 IEEE80211_VIF_DISABLE_SMPS_OVERRIDE = BIT(3), /* Renamed to IEEE80211_VIF_EML_ACTIVE. */ 823 #endif 824 IEEE80211_VIF_EML_ACTIVE = BIT(4), 825 IEEE80211_VIF_IGNORE_OFDMA_WIDER_BW = BIT(5), 826 }; 827 828 #define IEEE80211_BSS_ARP_ADDR_LIST_LEN 4 829 830 struct ieee80211_vif_cfg { 831 uint16_t aid; 832 uint16_t eml_cap; 833 uint16_t eml_med_sync_delay; 834 bool assoc; 835 bool ps; 836 bool idle; 837 bool ibss_joined; 838 int arp_addr_cnt; 839 size_t ssid_len; 840 uint32_t arp_addr_list[IEEE80211_BSS_ARP_ADDR_LIST_LEN]; /* big endian */ 841 uint8_t ssid[IEEE80211_NWID_LEN]; 842 uint8_t ap_addr[ETH_ALEN]; 843 }; 844 845 struct ieee80211_vif { 846 /* TODO FIXME */ 847 enum nl80211_iftype type; 848 int csa_active, mu_mimo_owner; 849 int cab_queue; 850 int color_change_active, offload_flags; 851 enum ieee80211_vif_driver_flags driver_flags; 852 bool p2p; 853 bool probe_req_reg; 854 uint8_t addr[ETH_ALEN]; 855 struct ieee80211_vif_cfg cfg; 856 struct ieee80211_chanctx_conf *chanctx_conf; 857 struct ieee80211_txq *txq; 858 struct ieee80211_bss_conf bss_conf; 859 struct ieee80211_bss_conf *link_conf[IEEE80211_MLD_MAX_NUM_LINKS]; /* rcu? */ 860 uint8_t hw_queue[IEEE80211_NUM_ACS]; 861 uint16_t active_links; 862 uint16_t valid_links; 863 struct ieee80211_vif *mbssid_tx_vif; 864 865 /* #ifdef CONFIG_MAC80211_DEBUGFS */ /* Do not change structure depending on compile-time option. */ 866 struct dentry *debugfs_dir; 867 /* #endif */ 868 869 /* Must stay last. */ 870 uint8_t drv_priv[0] __aligned(CACHE_LINE_SIZE); 871 }; 872 873 struct ieee80211_vif_chanctx_switch { 874 struct ieee80211_chanctx_conf *old_ctx, *new_ctx; 875 struct ieee80211_vif *vif; 876 struct ieee80211_bss_conf *link_conf; 877 }; 878 879 struct ieee80211_prep_tx_info { 880 u16 duration; 881 bool success; 882 bool was_assoc; 883 int link_id; 884 }; 885 886 /* XXX-BZ too big, over-reduce size to u8, and array sizes to minuimum to fit in skb->cb. */ 887 /* Also warning: some sizes change by pointer size! This is 64bit only. */ 888 struct ieee80211_tx_info { 889 enum ieee80211_tx_info_flags flags; /* 32 bits */ 890 /* TODO FIXME */ 891 enum nl80211_band band; /* 3 bits */ 892 uint16_t hw_queue:4, /* 4 bits */ 893 tx_time_est:10; /* 10 bits */ 894 union { 895 struct { 896 struct ieee80211_tx_rate rates[4]; 897 bool use_rts; 898 uint8_t antennas:2; 899 struct ieee80211_vif *vif; 900 struct ieee80211_key_conf *hw_key; 901 enum ieee80211_tx_control_flags flags; 902 } control; 903 struct { 904 struct ieee80211_tx_rate rates[4]; 905 uint32_t ack_signal; 906 uint8_t ampdu_ack_len; 907 uint8_t ampdu_len; 908 uint8_t antenna; 909 uint16_t tx_time; 910 uint8_t flags; 911 void *status_driver_data[16 / sizeof(void *)]; /* XXX TODO */ 912 } status; 913 #define IEEE80211_TX_INFO_DRIVER_DATA_SIZE 40 914 void *driver_data[IEEE80211_TX_INFO_DRIVER_DATA_SIZE / sizeof(void *)]; 915 }; 916 }; 917 918 /* net80211 conflict */ 919 struct linuxkpi_ieee80211_tim_ie { 920 uint8_t dtim_count; 921 uint8_t dtim_period; 922 uint8_t bitmap_ctrl; 923 uint8_t *virtual_map; 924 }; 925 #define ieee80211_tim_ie linuxkpi_ieee80211_tim_ie 926 927 struct survey_info { /* net80211::struct ieee80211_channel_survey */ 928 /* TODO FIXME */ 929 uint32_t filled; 930 #define SURVEY_INFO_TIME 0x0001 931 #define SURVEY_INFO_TIME_RX 0x0002 932 #define SURVEY_INFO_TIME_SCAN 0x0004 933 #define SURVEY_INFO_TIME_TX 0x0008 934 #define SURVEY_INFO_TIME_BSS_RX 0x0010 935 #define SURVEY_INFO_TIME_BUSY 0x0020 936 #define SURVEY_INFO_IN_USE 0x0040 937 #define SURVEY_INFO_NOISE_DBM 0x0080 938 uint32_t noise; 939 uint64_t time; 940 uint64_t time_bss_rx; 941 uint64_t time_busy; 942 uint64_t time_rx; 943 uint64_t time_scan; 944 uint64_t time_tx; 945 struct ieee80211_channel *channel; 946 }; 947 948 enum ieee80211_iface_iter { 949 IEEE80211_IFACE_ITER_NORMAL = BIT(0), 950 IEEE80211_IFACE_ITER_RESUME_ALL = BIT(1), 951 IEEE80211_IFACE_SKIP_SDATA_NOT_IN_DRIVER = BIT(2), /* seems to be an iter flag */ 952 IEEE80211_IFACE_ITER_ACTIVE = BIT(3), 953 954 /* Internal flags only. */ 955 IEEE80211_IFACE_ITER__ATOMIC = BIT(6), 956 IEEE80211_IFACE_ITER__MTX = BIT(8), 957 }; 958 959 enum set_key_cmd { 960 SET_KEY, 961 DISABLE_KEY, 962 }; 963 964 /* 802.11-2020, 9.4.2.55.2 HT Capability Information field. */ 965 enum rx_enc_flags { 966 RX_ENC_FLAG_SHORTPRE = BIT(0), 967 RX_ENC_FLAG_SHORT_GI = BIT(2), 968 RX_ENC_FLAG_HT_GF = BIT(3), 969 RX_ENC_FLAG_STBC_MASK = BIT(4) | BIT(5), 970 #define RX_ENC_FLAG_STBC_SHIFT 4 971 RX_ENC_FLAG_LDPC = BIT(6), 972 RX_ENC_FLAG_BF = BIT(7), 973 }; 974 975 enum sta_notify_cmd { 976 STA_NOTIFY_AWAKE, 977 STA_NOTIFY_SLEEP, 978 }; 979 980 struct ieee80211_low_level_stats { 981 /* Can we make them uint64_t? */ 982 uint32_t dot11ACKFailureCount; 983 uint32_t dot11FCSErrorCount; 984 uint32_t dot11RTSFailureCount; 985 uint32_t dot11RTSSuccessCount; 986 }; 987 988 enum ieee80211_offload_flags { 989 IEEE80211_OFFLOAD_ENCAP_4ADDR, 990 IEEE80211_OFFLOAD_ENCAP_ENABLED, 991 IEEE80211_OFFLOAD_DECAP_ENABLED, 992 }; 993 994 struct ieee80211_ops { 995 /* TODO FIXME */ 996 int (*start)(struct ieee80211_hw *); 997 void (*stop)(struct ieee80211_hw *, bool); 998 999 int (*config)(struct ieee80211_hw *, u32); 1000 void (*reconfig_complete)(struct ieee80211_hw *, enum ieee80211_reconfig_type); 1001 1002 int (*add_interface)(struct ieee80211_hw *, struct ieee80211_vif *); 1003 void (*remove_interface)(struct ieee80211_hw *, struct ieee80211_vif *); 1004 int (*change_interface)(struct ieee80211_hw *, struct ieee80211_vif *, enum nl80211_iftype, bool); 1005 1006 void (*sw_scan_start)(struct ieee80211_hw *, struct ieee80211_vif *, const u8 *); 1007 void (*sw_scan_complete)(struct ieee80211_hw *, struct ieee80211_vif *); 1008 int (*sched_scan_start)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_sched_scan_request *, struct ieee80211_scan_ies *); 1009 int (*sched_scan_stop)(struct ieee80211_hw *, struct ieee80211_vif *); 1010 int (*hw_scan)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_scan_request *); 1011 void (*cancel_hw_scan)(struct ieee80211_hw *, struct ieee80211_vif *); 1012 1013 int (*conf_tx)(struct ieee80211_hw *, struct ieee80211_vif *, u32, u16, const struct ieee80211_tx_queue_params *); 1014 void (*tx)(struct ieee80211_hw *, struct ieee80211_tx_control *, struct sk_buff *); 1015 int (*tx_last_beacon)(struct ieee80211_hw *); 1016 void (*wake_tx_queue)(struct ieee80211_hw *, struct ieee80211_txq *); 1017 1018 void (*mgd_prepare_tx)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_prep_tx_info *); 1019 void (*mgd_complete_tx)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_prep_tx_info *); 1020 void (*mgd_protect_tdls_discover)(struct ieee80211_hw *, struct ieee80211_vif *, unsigned int); 1021 1022 void (*flush)(struct ieee80211_hw *, struct ieee80211_vif *, u32, bool); 1023 void (*flush_sta)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *); 1024 1025 int (*set_frag_threshold)(struct ieee80211_hw *, u32); 1026 1027 void (*sync_rx_queues)(struct ieee80211_hw *); 1028 1029 void (*allow_buffered_frames)(struct ieee80211_hw *, struct ieee80211_sta *, u16, int, enum ieee80211_frame_release_type, bool); 1030 void (*release_buffered_frames)(struct ieee80211_hw *, struct ieee80211_sta *, u16, int, enum ieee80211_frame_release_type, bool); 1031 1032 int (*sta_add)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *); 1033 int (*sta_remove)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *); 1034 int (*sta_set_txpwr)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *); 1035 void (*sta_statistics)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, struct station_info *); 1036 void (*sta_pre_rcu_remove)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *); 1037 int (*sta_state)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, enum ieee80211_sta_state, enum ieee80211_sta_state); 1038 void (*sta_notify)(struct ieee80211_hw *, struct ieee80211_vif *, enum sta_notify_cmd, struct ieee80211_sta *); 1039 void (*sta_rc_update)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, u32); 1040 void (*sta_rate_tbl_update)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *); 1041 void (*sta_set_4addr)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, bool); 1042 void (*sta_set_decap_offload)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, bool); 1043 1044 u64 (*prepare_multicast)(struct ieee80211_hw *, struct netdev_hw_addr_list *); 1045 1046 int (*ampdu_action)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_ampdu_params *); 1047 1048 bool (*can_aggregate_in_amsdu)(struct ieee80211_hw *, struct sk_buff *, struct sk_buff *); 1049 1050 int (*pre_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_channel_switch *); 1051 int (*post_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_bss_conf *); 1052 void (*channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_channel_switch *); 1053 void (*channel_switch_beacon)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_chan_def *); 1054 void (*abort_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_bss_conf *); 1055 void (*channel_switch_rx_beacon)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_channel_switch *); 1056 int (*tdls_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, u8, struct cfg80211_chan_def *, struct sk_buff *, u32); 1057 void (*tdls_cancel_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *); 1058 void (*tdls_recv_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_tdls_ch_sw_params *); 1059 1060 int (*add_chanctx)(struct ieee80211_hw *, struct ieee80211_chanctx_conf *); 1061 void (*remove_chanctx)(struct ieee80211_hw *, struct ieee80211_chanctx_conf *); 1062 void (*change_chanctx)(struct ieee80211_hw *, struct ieee80211_chanctx_conf *, u32); 1063 int (*assign_vif_chanctx)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_bss_conf *, struct ieee80211_chanctx_conf *); 1064 void (*unassign_vif_chanctx)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_bss_conf *, struct ieee80211_chanctx_conf *); 1065 int (*switch_vif_chanctx)(struct ieee80211_hw *, struct ieee80211_vif_chanctx_switch *, int, enum ieee80211_chanctx_switch_mode); 1066 1067 int (*get_antenna)(struct ieee80211_hw *, u32 *, u32 *); 1068 int (*set_antenna)(struct ieee80211_hw *, u32, u32); 1069 1070 int (*remain_on_channel)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_channel *, int, enum ieee80211_roc_type); 1071 int (*cancel_remain_on_channel)(struct ieee80211_hw *, struct ieee80211_vif *); 1072 1073 void (*configure_filter)(struct ieee80211_hw *, unsigned int, unsigned int *, u64); 1074 void (*config_iface_filter)(struct ieee80211_hw *, struct ieee80211_vif *, unsigned int, unsigned int); 1075 1076 void (*bss_info_changed)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_bss_conf *, u64); 1077 void (*link_info_changed)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_bss_conf *, u64); 1078 1079 int (*set_rts_threshold)(struct ieee80211_hw *, u32); 1080 void (*event_callback)(struct ieee80211_hw *, struct ieee80211_vif *, const struct ieee80211_event *); 1081 int (*get_survey)(struct ieee80211_hw *, int, struct survey_info *); 1082 int (*get_ftm_responder_stats)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_ftm_responder_stats *); 1083 1084 uint64_t (*get_tsf)(struct ieee80211_hw *, struct ieee80211_vif *); 1085 void (*set_tsf)(struct ieee80211_hw *, struct ieee80211_vif *, uint64_t); 1086 void (*offset_tsf)(struct ieee80211_hw *, struct ieee80211_vif *, s64); 1087 1088 int (*set_bitrate_mask)(struct ieee80211_hw *, struct ieee80211_vif *, const struct cfg80211_bitrate_mask *); 1089 void (*set_coverage_class)(struct ieee80211_hw *, s16); 1090 int (*set_tim)(struct ieee80211_hw *, struct ieee80211_sta *, bool); 1091 1092 int (*set_key)(struct ieee80211_hw *, enum set_key_cmd, struct ieee80211_vif *, struct ieee80211_sta *, struct ieee80211_key_conf *); 1093 void (*update_tkip_key)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_key_conf *, struct ieee80211_sta *, u32, u16 *); 1094 1095 int (*start_pmsr)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_pmsr_request *); 1096 void (*abort_pmsr)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_pmsr_request *); 1097 1098 int (*start_ap)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_bss_conf *link_conf); 1099 void (*stop_ap)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_bss_conf *link_conf); 1100 int (*join_ibss)(struct ieee80211_hw *, struct ieee80211_vif *); 1101 void (*leave_ibss)(struct ieee80211_hw *, struct ieee80211_vif *); 1102 1103 int (*set_sar_specs)(struct ieee80211_hw *, const struct cfg80211_sar_specs *); 1104 1105 int (*set_tid_config)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, struct cfg80211_tid_config *); 1106 int (*reset_tid_config)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, u8); 1107 1108 int (*get_et_sset_count)(struct ieee80211_hw *, struct ieee80211_vif *, int); 1109 void (*get_et_stats)(struct ieee80211_hw *, struct ieee80211_vif *, struct ethtool_stats *, u64 *); 1110 void (*get_et_strings)(struct ieee80211_hw *, struct ieee80211_vif *, u32, u8 *); 1111 1112 void (*update_vif_offload)(struct ieee80211_hw *, struct ieee80211_vif *); 1113 1114 int (*get_txpower)(struct ieee80211_hw *, struct ieee80211_vif *, int *); 1115 int (*get_stats)(struct ieee80211_hw *, struct ieee80211_low_level_stats *); 1116 1117 int (*set_radar_background)(struct ieee80211_hw *, struct cfg80211_chan_def *); 1118 1119 void (*add_twt_setup)(struct ieee80211_hw *, struct ieee80211_sta *, struct ieee80211_twt_setup *); 1120 void (*twt_teardown_request)(struct ieee80211_hw *, struct ieee80211_sta *, u8); 1121 1122 int (*set_hw_timestamp)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_set_hw_timestamp *); 1123 1124 void (*vif_cfg_changed)(struct ieee80211_hw *, struct ieee80211_vif *, u64); 1125 1126 int (*change_vif_links)(struct ieee80211_hw *, struct ieee80211_vif *, u16, u16, struct ieee80211_bss_conf *[IEEE80211_MLD_MAX_NUM_LINKS]); 1127 int (*change_sta_links)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, u16, u16); 1128 bool (*can_activate_links)(struct ieee80211_hw *, struct ieee80211_vif *, u16); 1129 enum ieee80211_neg_ttlm_res (*can_neg_ttlm)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_neg_ttlm *); 1130 1131 /* #ifdef CONFIG_MAC80211_DEBUGFS */ /* Do not change depending on compile-time option. */ 1132 void (*sta_add_debugfs)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, struct dentry *); 1133 void (*vif_add_debugfs)(struct ieee80211_hw *, struct ieee80211_vif *); 1134 void (*link_sta_add_debugfs)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_link_sta *, struct dentry *); 1135 void (*link_add_debugfs)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_bss_conf *, struct dentry *); 1136 /* #endif */ 1137 /* #ifdef CONFIG_PM_SLEEP */ /* Do not change depending on compile-time option. */ 1138 int (*suspend)(struct ieee80211_hw *, struct cfg80211_wowlan *); 1139 int (*resume)(struct ieee80211_hw *); 1140 void (*set_wakeup)(struct ieee80211_hw *, bool); 1141 void (*set_rekey_data)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_gtk_rekey_data *); 1142 void (*set_default_unicast_key)(struct ieee80211_hw *, struct ieee80211_vif *, int); 1143 /* #if IS_ENABLED(CONFIG_IPV6) */ 1144 void (*ipv6_addr_change)(struct ieee80211_hw *, struct ieee80211_vif *, struct inet6_dev *); 1145 /* #endif */ 1146 /* #endif CONFIG_PM_SLEEP */ 1147 }; 1148 1149 /* -------------------------------------------------------------------------- */ 1150 1151 /* linux_80211.c */ 1152 extern const struct cfg80211_ops linuxkpi_mac80211cfgops; 1153 1154 struct ieee80211_hw *linuxkpi_ieee80211_alloc_hw(size_t, 1155 const struct ieee80211_ops *); 1156 void linuxkpi_ieee80211_iffree(struct ieee80211_hw *); 1157 void linuxkpi_set_ieee80211_dev(struct ieee80211_hw *, char *); 1158 int linuxkpi_ieee80211_ifattach(struct ieee80211_hw *); 1159 void linuxkpi_ieee80211_ifdetach(struct ieee80211_hw *); 1160 void linuxkpi_ieee80211_unregister_hw(struct ieee80211_hw *); 1161 struct ieee80211_hw * linuxkpi_wiphy_to_ieee80211_hw(struct wiphy *); 1162 void linuxkpi_ieee80211_restart_hw(struct ieee80211_hw *); 1163 void linuxkpi_ieee80211_iterate_interfaces( 1164 struct ieee80211_hw *hw, enum ieee80211_iface_iter flags, 1165 void(*iterfunc)(void *, uint8_t *, struct ieee80211_vif *), 1166 void *); 1167 void linuxkpi_ieee80211_iterate_keys(struct ieee80211_hw *, 1168 struct ieee80211_vif *, 1169 void(*iterfunc)(struct ieee80211_hw *, struct ieee80211_vif *, 1170 struct ieee80211_sta *, struct ieee80211_key_conf *, void *), 1171 void *, bool); 1172 void linuxkpi_ieee80211_iterate_chan_contexts(struct ieee80211_hw *, 1173 void(*iterfunc)(struct ieee80211_hw *, 1174 struct ieee80211_chanctx_conf *, void *), 1175 void *); 1176 void linuxkpi_ieee80211_iterate_stations_atomic(struct ieee80211_hw *, 1177 void (*iterfunc)(void *, struct ieee80211_sta *), void *); 1178 void linuxkpi_ieee80211_scan_completed(struct ieee80211_hw *, 1179 struct cfg80211_scan_info *); 1180 void linuxkpi_ieee80211_rx(struct ieee80211_hw *, struct sk_buff *, 1181 struct ieee80211_sta *, struct napi_struct *, struct list_head *); 1182 uint8_t linuxkpi_ieee80211_get_tid(struct ieee80211_hdr *, bool); 1183 struct ieee80211_sta *linuxkpi_ieee80211_find_sta(struct ieee80211_vif *, 1184 const u8 *); 1185 struct ieee80211_sta *linuxkpi_ieee80211_find_sta_by_ifaddr( 1186 struct ieee80211_hw *, const uint8_t *, const uint8_t *); 1187 struct sk_buff *linuxkpi_ieee80211_tx_dequeue(struct ieee80211_hw *, 1188 struct ieee80211_txq *); 1189 bool linuxkpi_ieee80211_is_ie_id_in_ie_buf(const u8, const u8 *, size_t); 1190 bool linuxkpi_ieee80211_ie_advance(size_t *, const u8 *, size_t); 1191 void linuxkpi_ieee80211_free_txskb(struct ieee80211_hw *, struct sk_buff *, 1192 int); 1193 void linuxkpi_ieee80211_queue_delayed_work(struct ieee80211_hw *, 1194 struct delayed_work *, int); 1195 void linuxkpi_ieee80211_queue_work(struct ieee80211_hw *, struct work_struct *); 1196 struct sk_buff *linuxkpi_ieee80211_pspoll_get(struct ieee80211_hw *, 1197 struct ieee80211_vif *); 1198 struct sk_buff *linuxkpi_ieee80211_nullfunc_get(struct ieee80211_hw *, 1199 struct ieee80211_vif *, int, bool); 1200 void linuxkpi_ieee80211_txq_get_depth(struct ieee80211_txq *, unsigned long *, 1201 unsigned long *); 1202 struct wireless_dev *linuxkpi_ieee80211_vif_to_wdev(struct ieee80211_vif *); 1203 void linuxkpi_ieee80211_connection_loss(struct ieee80211_vif *); 1204 void linuxkpi_ieee80211_beacon_loss(struct ieee80211_vif *); 1205 struct sk_buff *linuxkpi_ieee80211_probereq_get(struct ieee80211_hw *, 1206 uint8_t *, uint8_t *, size_t, size_t); 1207 void linuxkpi_ieee80211_tx_status(struct ieee80211_hw *, struct sk_buff *); 1208 void linuxkpi_ieee80211_tx_status_ext(struct ieee80211_hw *, 1209 struct ieee80211_tx_status *); 1210 void linuxkpi_ieee80211_stop_queues(struct ieee80211_hw *); 1211 void linuxkpi_ieee80211_wake_queues(struct ieee80211_hw *); 1212 void linuxkpi_ieee80211_stop_queue(struct ieee80211_hw *, int); 1213 void linuxkpi_ieee80211_wake_queue(struct ieee80211_hw *, int); 1214 void linuxkpi_ieee80211_txq_schedule_start(struct ieee80211_hw *, uint8_t); 1215 struct ieee80211_txq *linuxkpi_ieee80211_next_txq(struct ieee80211_hw *, uint8_t); 1216 void linuxkpi_ieee80211_schedule_txq(struct ieee80211_hw *, 1217 struct ieee80211_txq *, bool); 1218 void linuxkpi_ieee80211_handle_wake_tx_queue(struct ieee80211_hw *, 1219 struct ieee80211_txq *); 1220 1221 /* -------------------------------------------------------------------------- */ 1222 1223 static __inline void 1224 _ieee80211_hw_set(struct ieee80211_hw *hw, enum ieee80211_hw_flags flag) 1225 { 1226 1227 set_bit(flag, hw->flags); 1228 } 1229 1230 static __inline bool 1231 __ieee80211_hw_check(struct ieee80211_hw *hw, enum ieee80211_hw_flags flag) 1232 { 1233 1234 return (test_bit(flag, hw->flags)); 1235 } 1236 1237 /* They pass in shortened flag names; how confusingly inconsistent. */ 1238 #define ieee80211_hw_set(_hw, _flag) \ 1239 _ieee80211_hw_set(_hw, IEEE80211_HW_ ## _flag) 1240 #define ieee80211_hw_check(_hw, _flag) \ 1241 __ieee80211_hw_check(_hw, IEEE80211_HW_ ## _flag) 1242 1243 /* XXX-BZ add CTASSERTS that size of struct is <= sizeof skb->cb. */ 1244 CTASSERT(sizeof(struct ieee80211_tx_info) <= sizeof(((struct sk_buff *)0)->cb)); 1245 #define IEEE80211_SKB_CB(_skb) \ 1246 ((struct ieee80211_tx_info *)((_skb)->cb)) 1247 1248 CTASSERT(sizeof(struct ieee80211_rx_status) <= sizeof(((struct sk_buff *)0)->cb)); 1249 #define IEEE80211_SKB_RXCB(_skb) \ 1250 ((struct ieee80211_rx_status *)((_skb)->cb)) 1251 1252 static __inline void 1253 ieee80211_free_hw(struct ieee80211_hw *hw) 1254 { 1255 1256 linuxkpi_ieee80211_iffree(hw); 1257 1258 if (hw->wiphy != NULL) 1259 wiphy_free(hw->wiphy); 1260 /* Note that *hw is not valid any longer after this. */ 1261 1262 IMPROVE(); 1263 } 1264 1265 static __inline struct ieee80211_hw * 1266 ieee80211_alloc_hw(size_t priv_len, const struct ieee80211_ops *ops) 1267 { 1268 1269 return (linuxkpi_ieee80211_alloc_hw(priv_len, ops)); 1270 } 1271 1272 static __inline void 1273 SET_IEEE80211_DEV(struct ieee80211_hw *hw, struct device *dev) 1274 { 1275 1276 set_wiphy_dev(hw->wiphy, dev); 1277 linuxkpi_set_ieee80211_dev(hw, dev_name(dev)); 1278 1279 IMPROVE(); 1280 } 1281 1282 static __inline int 1283 ieee80211_register_hw(struct ieee80211_hw *hw) 1284 { 1285 int error; 1286 1287 error = wiphy_register(hw->wiphy); 1288 if (error != 0) 1289 return (error); 1290 1291 /* 1292 * At this point the driver has set all the options, flags, bands, 1293 * ciphers, hw address(es), ... basically mac80211/cfg80211 hw/wiphy 1294 * setup is done. 1295 * We need to replicate a lot of information from here into net80211. 1296 */ 1297 error = linuxkpi_ieee80211_ifattach(hw); 1298 1299 IMPROVE(); 1300 1301 return (error); 1302 } 1303 1304 static inline void 1305 ieee80211_unregister_hw(struct ieee80211_hw *hw) 1306 { 1307 1308 linuxkpi_ieee80211_unregister_hw(hw); 1309 } 1310 1311 static __inline struct ieee80211_hw * 1312 wiphy_to_ieee80211_hw(struct wiphy *wiphy) 1313 { 1314 1315 return (linuxkpi_wiphy_to_ieee80211_hw(wiphy)); 1316 } 1317 1318 static inline void 1319 ieee80211_restart_hw(struct ieee80211_hw *hw) 1320 { 1321 linuxkpi_ieee80211_restart_hw(hw); 1322 } 1323 1324 static inline void 1325 ieee80211_hw_restart_disconnect(struct ieee80211_vif *vif) 1326 { 1327 TODO(); 1328 } 1329 1330 /* -------------------------------------------------------------------------- */ 1331 1332 #define link_conf_dereference_check(_vif, _linkid) \ 1333 rcu_dereference_check((_vif)->link_conf[_linkid], true) 1334 1335 #define link_conf_dereference_protected(_vif, _linkid) \ 1336 rcu_dereference_protected((_vif)->link_conf[_linkid], true) 1337 1338 #define link_sta_dereference_check(_sta, _linkid) \ 1339 rcu_dereference_check((_sta)->link[_linkid], true) 1340 1341 #define link_sta_dereference_protected(_sta, _linkid) \ 1342 rcu_dereference_protected((_sta)->link[_linkid], true) 1343 1344 #define for_each_vif_active_link(_vif, _link, _linkid) \ 1345 for (_linkid = 0; _linkid < nitems((_vif)->link_conf); _linkid++) \ 1346 if ( ((_vif)->active_links == 0 /* no MLO */ || \ 1347 ((_vif)->active_links & BIT(_linkid)) != 0) && \ 1348 (_link = rcu_dereference((_vif)->link_conf[_linkid])) ) 1349 1350 #define for_each_sta_active_link(_vif, _sta, _linksta, _linkid) \ 1351 for (_linkid = 0; _linkid < nitems((_sta)->link); _linkid++) \ 1352 if ( ((_vif)->active_links == 0 /* no MLO */ || \ 1353 ((_vif)->active_links & BIT(_linkid)) != 0) && \ 1354 (_linksta = link_sta_dereference_protected((_sta), (_linkid))) ) 1355 1356 /* -------------------------------------------------------------------------- */ 1357 1358 static __inline bool 1359 ieee80211_vif_is_mesh(struct ieee80211_vif *vif) 1360 { 1361 TODO(); 1362 return (false); 1363 } 1364 1365 1366 /* -------------------------------------------------------------------------- */ 1367 /* Receive functions (air/driver to mac80211/net80211). */ 1368 1369 1370 static __inline void 1371 ieee80211_rx_napi(struct ieee80211_hw *hw, struct ieee80211_sta *sta, 1372 struct sk_buff *skb, struct napi_struct *napi) 1373 { 1374 1375 linuxkpi_ieee80211_rx(hw, skb, sta, napi, NULL); 1376 } 1377 1378 static __inline void 1379 ieee80211_rx_list(struct ieee80211_hw *hw, struct ieee80211_sta *sta, 1380 struct sk_buff *skb, struct list_head *list) 1381 { 1382 1383 linuxkpi_ieee80211_rx(hw, skb, sta, NULL, list); 1384 } 1385 1386 static __inline void 1387 ieee80211_rx_ni(struct ieee80211_hw *hw, struct sk_buff *skb) 1388 { 1389 1390 linuxkpi_ieee80211_rx(hw, skb, NULL, NULL, NULL); 1391 } 1392 1393 static __inline void 1394 ieee80211_rx_irqsafe(struct ieee80211_hw *hw, struct sk_buff *skb) 1395 { 1396 1397 linuxkpi_ieee80211_rx(hw, skb, NULL, NULL, NULL); 1398 } 1399 1400 static __inline void 1401 ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb) 1402 { 1403 1404 linuxkpi_ieee80211_rx(hw, skb, NULL, NULL, NULL); 1405 } 1406 1407 /* -------------------------------------------------------------------------- */ 1408 1409 static inline void 1410 ieee80211_stop_queues(struct ieee80211_hw *hw) 1411 { 1412 linuxkpi_ieee80211_stop_queues(hw); 1413 } 1414 1415 static inline void 1416 ieee80211_wake_queues(struct ieee80211_hw *hw) 1417 { 1418 linuxkpi_ieee80211_wake_queues(hw); 1419 } 1420 1421 static inline void 1422 ieee80211_stop_queue(struct ieee80211_hw *hw, int qnum) 1423 { 1424 linuxkpi_ieee80211_stop_queue(hw, qnum); 1425 } 1426 1427 static inline void 1428 ieee80211_wake_queue(struct ieee80211_hw *hw, int qnum) 1429 { 1430 linuxkpi_ieee80211_wake_queue(hw, qnum); 1431 } 1432 1433 static inline void 1434 ieee80211_schedule_txq(struct ieee80211_hw *hw, struct ieee80211_txq *txq) 1435 { 1436 linuxkpi_ieee80211_schedule_txq(hw, txq, true); 1437 } 1438 1439 static inline void 1440 ieee80211_return_txq(struct ieee80211_hw *hw, struct ieee80211_txq *txq, 1441 bool withoutpkts) 1442 { 1443 linuxkpi_ieee80211_schedule_txq(hw, txq, withoutpkts); 1444 } 1445 1446 static inline void 1447 ieee80211_txq_schedule_start(struct ieee80211_hw *hw, uint8_t ac) 1448 { 1449 linuxkpi_ieee80211_txq_schedule_start(hw, ac); 1450 } 1451 1452 static inline void 1453 ieee80211_txq_schedule_end(struct ieee80211_hw *hw, uint8_t ac) 1454 { 1455 /* DO_NADA; */ 1456 } 1457 1458 static inline struct ieee80211_txq * 1459 ieee80211_next_txq(struct ieee80211_hw *hw, uint8_t ac) 1460 { 1461 return (linuxkpi_ieee80211_next_txq(hw, ac)); 1462 } 1463 1464 static inline void 1465 ieee80211_handle_wake_tx_queue(struct ieee80211_hw *hw, 1466 struct ieee80211_txq *txq) 1467 { 1468 linuxkpi_ieee80211_handle_wake_tx_queue(hw, txq); 1469 } 1470 1471 /* -------------------------------------------------------------------------- */ 1472 1473 static __inline uint8_t 1474 ieee80211_get_tid(struct ieee80211_hdr *hdr) 1475 { 1476 1477 return (linuxkpi_ieee80211_get_tid(hdr, false)); 1478 } 1479 1480 static __inline struct sk_buff * 1481 ieee80211_beacon_get_tim(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 1482 uint16_t *tim_offset, uint16_t *tim_len, uint32_t link_id) 1483 { 1484 1485 if (tim_offset != NULL) 1486 *tim_offset = 0; 1487 if (tim_len != NULL) 1488 *tim_len = 0; 1489 TODO(); 1490 return (NULL); 1491 } 1492 1493 static __inline void 1494 ieee80211_iterate_active_interfaces_atomic(struct ieee80211_hw *hw, 1495 enum ieee80211_iface_iter flags, 1496 void(*iterfunc)(void *, uint8_t *, struct ieee80211_vif *), 1497 void *arg) 1498 { 1499 1500 flags |= IEEE80211_IFACE_ITER__ATOMIC; 1501 flags |= IEEE80211_IFACE_ITER_ACTIVE; 1502 linuxkpi_ieee80211_iterate_interfaces(hw, flags, iterfunc, arg); 1503 } 1504 1505 static __inline void 1506 ieee80211_iterate_active_interfaces(struct ieee80211_hw *hw, 1507 enum ieee80211_iface_iter flags, 1508 void(*iterfunc)(void *, uint8_t *, struct ieee80211_vif *), 1509 void *arg) 1510 { 1511 1512 flags |= IEEE80211_IFACE_ITER_ACTIVE; 1513 linuxkpi_ieee80211_iterate_interfaces(hw, flags, iterfunc, arg); 1514 } 1515 1516 static __inline void 1517 ieee80211_iterate_active_interfaces_mtx(struct ieee80211_hw *hw, 1518 enum ieee80211_iface_iter flags, 1519 void(*iterfunc)(void *, uint8_t *, struct ieee80211_vif *), 1520 void *arg) 1521 { 1522 flags |= IEEE80211_IFACE_ITER_ACTIVE; 1523 flags |= IEEE80211_IFACE_ITER__MTX; 1524 linuxkpi_ieee80211_iterate_interfaces(hw, flags, iterfunc, arg); 1525 } 1526 1527 static __inline void 1528 ieee80211_iterate_interfaces(struct ieee80211_hw *hw, 1529 enum ieee80211_iface_iter flags, 1530 void (*iterfunc)(void *, uint8_t *, struct ieee80211_vif *), 1531 void *arg) 1532 { 1533 1534 linuxkpi_ieee80211_iterate_interfaces(hw, flags, iterfunc, arg); 1535 } 1536 1537 static inline void 1538 ieee80211_iter_keys(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 1539 void(*iterfunc)(struct ieee80211_hw *, struct ieee80211_vif *, 1540 struct ieee80211_sta *, struct ieee80211_key_conf *, void *), 1541 void *arg) 1542 { 1543 linuxkpi_ieee80211_iterate_keys(hw, vif, iterfunc, arg, false); 1544 } 1545 1546 static inline void 1547 ieee80211_iter_keys_rcu(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 1548 void(*iterfunc)(struct ieee80211_hw *, struct ieee80211_vif *, 1549 struct ieee80211_sta *, struct ieee80211_key_conf *, void *), 1550 void *arg) 1551 { 1552 linuxkpi_ieee80211_iterate_keys(hw, vif, iterfunc, arg, true); 1553 } 1554 1555 static __inline void 1556 ieee80211_iter_chan_contexts_atomic(struct ieee80211_hw *hw, 1557 void(*iterfunc)(struct ieee80211_hw *, struct ieee80211_chanctx_conf *, void *), 1558 void *arg) 1559 { 1560 1561 linuxkpi_ieee80211_iterate_chan_contexts(hw, iterfunc, arg); 1562 } 1563 1564 static __inline void 1565 ieee80211_iterate_stations_atomic(struct ieee80211_hw *hw, 1566 void (*iterfunc)(void *, struct ieee80211_sta *), void *arg) 1567 { 1568 1569 linuxkpi_ieee80211_iterate_stations_atomic(hw, iterfunc, arg); 1570 } 1571 1572 static __inline struct wireless_dev * 1573 ieee80211_vif_to_wdev(struct ieee80211_vif *vif) 1574 { 1575 1576 return (linuxkpi_ieee80211_vif_to_wdev(vif)); 1577 } 1578 1579 static __inline struct sk_buff * 1580 ieee80211_beacon_get_template(struct ieee80211_hw *hw, 1581 struct ieee80211_vif *vif, struct ieee80211_mutable_offsets *offs, 1582 uint32_t link_id) 1583 { 1584 TODO(); 1585 return (NULL); 1586 } 1587 1588 static __inline void 1589 ieee80211_beacon_loss(struct ieee80211_vif *vif) 1590 { 1591 linuxkpi_ieee80211_beacon_loss(vif); 1592 } 1593 1594 static __inline void 1595 ieee80211_chswitch_done(struct ieee80211_vif *vif, bool t, uint32_t link_id) 1596 { 1597 TODO(); 1598 } 1599 1600 static __inline bool 1601 ieee80211_csa_is_complete(struct ieee80211_vif *vif) 1602 { 1603 TODO(); 1604 return (false); 1605 } 1606 1607 static __inline void 1608 ieee80211_csa_set_counter(struct ieee80211_vif *vif, uint8_t counter) 1609 { 1610 TODO(); 1611 } 1612 1613 static __inline int 1614 ieee80211_csa_update_counter(struct ieee80211_vif *vif) 1615 { 1616 TODO(); 1617 return (-1); 1618 } 1619 1620 static __inline void 1621 ieee80211_csa_finish(struct ieee80211_vif *vif, uint32_t link_id) 1622 { 1623 TODO(); 1624 } 1625 1626 static inline enum nl80211_iftype 1627 ieee80211_vif_type_p2p(struct ieee80211_vif *vif) 1628 { 1629 1630 /* If we are not p2p enabled, just return the type. */ 1631 if (!vif->p2p) 1632 return (vif->type); 1633 1634 /* If we are p2p, depending on side, return type. */ 1635 switch (vif->type) { 1636 case NL80211_IFTYPE_AP: 1637 return (NL80211_IFTYPE_P2P_GO); 1638 case NL80211_IFTYPE_STATION: 1639 return (NL80211_IFTYPE_P2P_CLIENT); 1640 default: 1641 fallthrough; 1642 } 1643 return (vif->type); 1644 } 1645 1646 static __inline unsigned long 1647 ieee80211_tu_to_usec(unsigned long tu) 1648 { 1649 1650 return (tu * IEEE80211_DUR_TU); 1651 } 1652 1653 /* 1654 * Below we assume that the two values from different emums are the same. 1655 * Make sure this does not accidentally change. 1656 */ 1657 CTASSERT((int)IEEE80211_ACTION_SM_TPCREP == (int)IEEE80211_ACTION_RADIO_MEASUREMENT_LMREP); 1658 1659 static __inline bool 1660 ieee80211_action_contains_tpc(struct sk_buff *skb) 1661 { 1662 struct ieee80211_mgmt *mgmt; 1663 1664 mgmt = (struct ieee80211_mgmt *)skb->data; 1665 1666 /* Check that this is a mgmt/action frame? */ 1667 if (!ieee80211_is_action(mgmt->frame_control)) 1668 return (false); 1669 1670 /* 1671 * This is a bit convoluted but according to docs both actions 1672 * are checked for this. Kind-of makes sense for the only consumer 1673 * (iwlwifi) I am aware off given the txpower fields are at the 1674 * same location so firmware can update the value. 1675 */ 1676 /* 80211-2020 9.6.2 Spectrum Management Action frames */ 1677 /* 80211-2020 9.6.2.5 TPC Report frame format */ 1678 /* 80211-2020 9.6.6 Radio Measurement action details */ 1679 /* 80211-2020 9.6.6.4 Link Measurement Report frame format */ 1680 /* Check that it is Spectrum Management or Radio Measurement? */ 1681 if (mgmt->u.action.category != IEEE80211_ACTION_CAT_SM && 1682 mgmt->u.action.category != IEEE80211_ACTION_CAT_RADIO_MEASUREMENT) 1683 return (false); 1684 1685 /* 1686 * Check that it is TPC Report or Link Measurement Report? 1687 * The values of each are the same (see CTASSERT above function). 1688 */ 1689 if (mgmt->u.action.u.tpc_report.spec_mgmt != IEEE80211_ACTION_SM_TPCREP) 1690 return (false); 1691 1692 /* 80211-2020 9.4.2.16 TPC Report element */ 1693 /* Check that the ELEMID and length are correct? */ 1694 if (mgmt->u.action.u.tpc_report.tpc_elem_id != IEEE80211_ELEMID_TPCREP || 1695 mgmt->u.action.u.tpc_report.tpc_elem_length != 4) 1696 return (false); 1697 1698 /* All the right fields in the right place. */ 1699 return (true); 1700 } 1701 1702 static __inline void 1703 ieee80211_connection_loss(struct ieee80211_vif *vif) 1704 { 1705 1706 linuxkpi_ieee80211_connection_loss(vif); 1707 } 1708 1709 static __inline struct ieee80211_sta * 1710 ieee80211_find_sta(struct ieee80211_vif *vif, const u8 *peer) 1711 { 1712 1713 return (linuxkpi_ieee80211_find_sta(vif, peer)); 1714 } 1715 1716 static __inline struct ieee80211_sta * 1717 ieee80211_find_sta_by_ifaddr(struct ieee80211_hw *hw, const uint8_t *addr, 1718 const uint8_t *ourvifaddr) 1719 { 1720 1721 return (linuxkpi_ieee80211_find_sta_by_ifaddr(hw, addr, ourvifaddr)); 1722 } 1723 1724 1725 static __inline void 1726 ieee80211_get_tkip_p2k(struct ieee80211_key_conf *keyconf, 1727 struct sk_buff *skb_frag, u8 *key) 1728 { 1729 TODO(); 1730 } 1731 1732 static __inline void 1733 ieee80211_get_tkip_rx_p1k(struct ieee80211_key_conf *keyconf, 1734 const u8 *addr, uint32_t iv32, u16 *p1k) 1735 { 1736 1737 KASSERT(keyconf != NULL && addr != NULL && p1k != NULL, 1738 ("%s: keyconf %p addr %p p1k %p\n", __func__, keyconf, addr, p1k)); 1739 1740 TODO(); 1741 memset(p1k, 0xfa, 5 * sizeof(*p1k)); /* Just initializing. */ 1742 } 1743 1744 static __inline size_t 1745 ieee80211_ie_split(const u8 *ies, size_t ies_len, 1746 const u8 *ie_ids, size_t ie_ids_len, size_t start) 1747 { 1748 size_t x; 1749 1750 x = start; 1751 1752 /* XXX FIXME, we need to deal with "Element ID Extension" */ 1753 while (x < ies_len) { 1754 1755 /* Is this IE[s] one of the ie_ids? */ 1756 if (!linuxkpi_ieee80211_is_ie_id_in_ie_buf(ies[x], 1757 ie_ids, ie_ids_len)) 1758 break; 1759 1760 if (!linuxkpi_ieee80211_ie_advance(&x, ies, ies_len)) 1761 break; 1762 } 1763 1764 return (x); 1765 } 1766 1767 static __inline void 1768 ieee80211_request_smps(struct ieee80211_vif *vif, u_int link_id, 1769 enum ieee80211_smps_mode smps) 1770 { 1771 static const char *smps_mode_name[] = { 1772 "SMPS_OFF", 1773 "SMPS_STATIC", 1774 "SMPS_DYNAMIC", 1775 "SMPS_AUTOMATIC", 1776 "SMPS_NUM_MODES" 1777 }; 1778 1779 if (linuxkpi_debug_80211 & D80211_TODO) 1780 printf("%s:%d: XXX LKPI80211 TODO smps %d %s\n", 1781 __func__, __LINE__, smps, smps_mode_name[smps]); 1782 } 1783 1784 static __inline void 1785 ieee80211_tdls_oper_request(struct ieee80211_vif *vif, uint8_t *addr, 1786 enum nl80211_tdls_operation oper, enum ieee80211_reason_code code, 1787 gfp_t gfp) 1788 { 1789 TODO(); 1790 } 1791 1792 static __inline void 1793 wiphy_rfkill_set_hw_state(struct wiphy *wiphy, bool state) 1794 { 1795 TODO(); 1796 } 1797 1798 static __inline void 1799 ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb) 1800 { 1801 IMPROVE(); 1802 1803 /* 1804 * This is called on transmit failure. 1805 * Use a not-so-random random high status error so we can distinguish 1806 * it from normal low values flying around in net80211 ("ETX"). 1807 */ 1808 linuxkpi_ieee80211_free_txskb(hw, skb, 0x455458); 1809 } 1810 1811 static __inline void 1812 ieee80211_ready_on_channel(struct ieee80211_hw *hw) 1813 { 1814 TODO(); 1815 /* XXX-BZ We need to see that. */ 1816 } 1817 1818 static __inline void 1819 ieee80211_remain_on_channel_expired(struct ieee80211_hw *hw) 1820 { 1821 TODO(); 1822 } 1823 1824 static __inline void 1825 ieee80211_cqm_rssi_notify(struct ieee80211_vif *vif, 1826 enum nl80211_cqm_rssi_threshold_event crte, int sig, gfp_t gfp) 1827 { 1828 TODO(); 1829 } 1830 1831 /* -------------------------------------------------------------------------- */ 1832 1833 static inline bool 1834 ieee80211_sn_less(uint16_t sn1, uint16_t sn2) 1835 { 1836 return (IEEE80211_SEQ_BA_BEFORE(sn1, sn2)); 1837 } 1838 1839 static inline uint16_t 1840 ieee80211_sn_inc(uint16_t sn) 1841 { 1842 return (IEEE80211_SEQ_INC(sn)); 1843 } 1844 1845 static inline uint16_t 1846 ieee80211_sn_add(uint16_t sn, uint16_t a) 1847 { 1848 return (IEEE80211_SEQ_ADD(sn, a)); 1849 } 1850 1851 static inline uint16_t 1852 ieee80211_sn_sub(uint16_t sa, uint16_t sb) 1853 { 1854 return (IEEE80211_SEQ_SUB(sa, sb)); 1855 } 1856 1857 static __inline void 1858 ieee80211_mark_rx_ba_filtered_frames(struct ieee80211_sta *sta, uint8_t tid, 1859 uint32_t ssn, uint64_t bitmap, uint16_t received_mpdu) 1860 { 1861 TODO(); 1862 } 1863 1864 static __inline void 1865 ieee80211_stop_rx_ba_session(struct ieee80211_vif *vif, uint32_t x, uint8_t *addr) 1866 { 1867 TODO(); 1868 } 1869 1870 static __inline void 1871 ieee80211_rx_ba_timer_expired(struct ieee80211_vif *vif, uint8_t *addr, 1872 uint8_t tid) 1873 { 1874 TODO(); 1875 } 1876 1877 static __inline void 1878 ieee80211_start_rx_ba_session_offl(struct ieee80211_vif *vif, uint8_t *addr, 1879 uint8_t tid) 1880 { 1881 TODO(); 1882 } 1883 1884 static __inline void 1885 ieee80211_stop_rx_ba_session_offl(struct ieee80211_vif *vif, uint8_t *addr, 1886 uint8_t tid) 1887 { 1888 TODO(); 1889 } 1890 1891 /* -------------------------------------------------------------------------- */ 1892 1893 static inline void 1894 ieee80211_rate_set_vht(struct ieee80211_tx_rate *r, uint8_t mcs, uint8_t nss) 1895 { 1896 1897 /* XXX-BZ make it KASSERTS? */ 1898 if (((mcs & 0xF0) != 0) || (((nss - 1) & 0xf8) != 0)) { 1899 printf("%s:%d: mcs %#04x nss %#04x invalid\n", 1900 __func__, __LINE__, mcs, nss); 1901 return; 1902 } 1903 1904 r->idx = mcs; 1905 r->idx |= ((nss - 1) << 4); 1906 } 1907 1908 static inline uint8_t 1909 ieee80211_rate_get_vht_nss(struct ieee80211_tx_rate *r) 1910 { 1911 return (((r->idx >> 4) & 0x07) + 1); 1912 } 1913 1914 static inline uint8_t 1915 ieee80211_rate_get_vht_mcs(struct ieee80211_tx_rate *r) 1916 { 1917 return (r->idx & 0x0f); 1918 } 1919 1920 static inline int 1921 ieee80211_get_vht_max_nss(struct ieee80211_vht_cap *vht_cap, 1922 enum ieee80211_vht_chanwidth chanwidth, /* defined in net80211. */ 1923 int mcs /* always 0 */, bool ext_nss_bw_cap /* always true */, int max_nss) 1924 { 1925 enum ieee80211_vht_mcs_support mcs_s; 1926 uint32_t supp_cw, ext_nss_bw; 1927 1928 switch (mcs) { 1929 case 0 ... 7: 1930 mcs_s = IEEE80211_VHT_MCS_SUPPORT_0_7; 1931 break; 1932 case 8: 1933 mcs_s = IEEE80211_VHT_MCS_SUPPORT_0_8; 1934 break; 1935 case 9: 1936 mcs_s = IEEE80211_VHT_MCS_SUPPORT_0_9; 1937 break; 1938 default: 1939 printf("%s: unsupported mcs value %d\n", __func__, mcs); 1940 return (0); 1941 } 1942 1943 if (max_nss == 0) { 1944 uint16_t map; 1945 1946 map = le16toh(vht_cap->supp_mcs.rx_mcs_map); 1947 for (int i = 7; i >= 0; i--) { 1948 uint8_t val; 1949 1950 val = (map >> (2 * i)) & 0x03; 1951 if (val == IEEE80211_VHT_MCS_NOT_SUPPORTED) 1952 continue; 1953 if (val >= mcs_s) { 1954 max_nss = i + 1; 1955 break; 1956 } 1957 } 1958 } 1959 1960 if (max_nss == 0) 1961 return (0); 1962 1963 if ((le16toh(vht_cap->supp_mcs.tx_mcs_map) & 1964 IEEE80211_VHT_EXT_NSS_BW_CAPABLE) == 0) 1965 return (max_nss); 1966 1967 supp_cw = le32_get_bits(vht_cap->vht_cap_info, 1968 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK); 1969 ext_nss_bw = le32_get_bits(vht_cap->vht_cap_info, 1970 IEEE80211_VHT_CAP_EXT_NSS_BW_MASK); 1971 1972 /* If requested as ext nss not supported assume ext_nss_bw 0. */ 1973 if (!ext_nss_bw_cap) 1974 ext_nss_bw = 0; 1975 1976 /* 1977 * Cover 802.11-2016, Table 9-250. 1978 */ 1979 1980 /* Unsupported settings. */ 1981 if (supp_cw == 3) 1982 return (0); 1983 if (supp_cw == 2 && (ext_nss_bw == 1 || ext_nss_bw == 2)) 1984 return (0); 1985 1986 /* Settings with factor != 1 or unsupported. */ 1987 switch (chanwidth) { 1988 case IEEE80211_VHT_CHANWIDTH_80P80MHZ: 1989 if (supp_cw == 0 && (ext_nss_bw == 0 || ext_nss_bw == 1)) 1990 return (0); 1991 if (supp_cw == 1 && ext_nss_bw == 0) 1992 return (0); 1993 if ((supp_cw == 0 || supp_cw == 1) && ext_nss_bw == 2) 1994 return (max_nss / 2); 1995 if ((supp_cw == 0 || supp_cw == 1) && ext_nss_bw == 3) 1996 return (3 * max_nss / 4); 1997 break; 1998 case IEEE80211_VHT_CHANWIDTH_160MHZ: 1999 if (supp_cw == 0 && ext_nss_bw == 0) 2000 return (0); 2001 if (supp_cw == 0 && (ext_nss_bw == 1 || ext_nss_bw == 2)) 2002 return (max_nss / 2); 2003 if (supp_cw == 0 && ext_nss_bw == 3) 2004 return (3 * max_nss / 4); 2005 if (supp_cw == 1 && ext_nss_bw == 3) 2006 return (2 * max_nss); 2007 break; 2008 case IEEE80211_VHT_CHANWIDTH_80MHZ: 2009 case IEEE80211_VHT_CHANWIDTH_USE_HT: 2010 if ((supp_cw == 1 || supp_cw == 2) && ext_nss_bw == 3) 2011 return (2 * max_nss); 2012 break; 2013 } 2014 2015 /* Everything else has a factor of 1. */ 2016 return (max_nss); 2017 } 2018 2019 2020 static __inline void 2021 ieee80211_reserve_tid(struct ieee80211_sta *sta, uint8_t tid) 2022 { 2023 TODO(); 2024 } 2025 2026 static __inline void 2027 ieee80211_unreserve_tid(struct ieee80211_sta *sta, uint8_t tid) 2028 { 2029 TODO(); 2030 } 2031 2032 static __inline void 2033 ieee80211_send_eosp_nullfunc(struct ieee80211_sta *sta, uint8_t tid) 2034 { 2035 TODO(); 2036 } 2037 2038 static __inline void 2039 ieee80211_sta_block_awake(struct ieee80211_hw *hw, struct ieee80211_sta *sta, 2040 bool disable) 2041 { 2042 TODO(); 2043 } 2044 2045 static __inline void 2046 ieee80211_sta_ps_transition(struct ieee80211_sta *sta, bool sleeping) 2047 { 2048 TODO(); 2049 } 2050 2051 static __inline void 2052 ieee80211_sta_pspoll(struct ieee80211_sta *sta) 2053 { 2054 TODO(); 2055 } 2056 2057 static inline void 2058 ieee80211_sta_recalc_aggregates(struct ieee80211_sta *sta) 2059 { 2060 if (sta->valid_links) { 2061 TODO(); 2062 } 2063 } 2064 2065 static __inline void 2066 ieee80211_sta_uapsd_trigger(struct ieee80211_sta *sta, int ntids) 2067 { 2068 TODO(); 2069 } 2070 2071 static __inline void 2072 ieee80211_tkip_add_iv(u8 *crypto_hdr, struct ieee80211_key_conf *keyconf, 2073 uint64_t pn) 2074 { 2075 TODO(); 2076 } 2077 2078 static inline struct sk_buff * 2079 ieee80211_tx_dequeue(struct ieee80211_hw *hw, struct ieee80211_txq *txq) 2080 { 2081 2082 return (linuxkpi_ieee80211_tx_dequeue(hw, txq)); 2083 } 2084 2085 static inline struct sk_buff * 2086 ieee80211_tx_dequeue_ni(struct ieee80211_hw *hw, struct ieee80211_txq *txq) 2087 { 2088 struct sk_buff *skb; 2089 2090 local_bh_disable(); 2091 skb = linuxkpi_ieee80211_tx_dequeue(hw, txq); 2092 local_bh_enable(); 2093 2094 return (skb); 2095 } 2096 2097 static __inline void 2098 ieee80211_update_mu_groups(struct ieee80211_vif *vif, 2099 u_int _i, uint8_t *ms, uint8_t *up) 2100 { 2101 TODO(); 2102 } 2103 2104 static __inline void 2105 ieee80211_sta_set_buffered(struct ieee80211_sta *sta, uint8_t tid, bool t) 2106 { 2107 TODO(); 2108 } 2109 2110 static __inline void 2111 ieee80211_sched_scan_results(struct ieee80211_hw *hw) 2112 { 2113 TODO(); 2114 } 2115 2116 static __inline void 2117 ieee80211_sta_eosp(struct ieee80211_sta *sta) 2118 { 2119 TODO(); 2120 } 2121 2122 static __inline int 2123 ieee80211_start_tx_ba_session(struct ieee80211_sta *sta, uint8_t tid, int x) 2124 { 2125 TODO("rtw8x"); 2126 return (-EINVAL); 2127 } 2128 2129 static __inline int 2130 ieee80211_stop_tx_ba_session(struct ieee80211_sta *sta, uint8_t tid) 2131 { 2132 TODO("rtw89"); 2133 return (-EINVAL); 2134 } 2135 2136 static __inline void 2137 ieee80211_start_tx_ba_cb_irqsafe(struct ieee80211_vif *vif, uint8_t *addr, 2138 uint8_t tid) 2139 { 2140 TODO("iwlwifi"); 2141 } 2142 2143 static __inline void 2144 ieee80211_stop_tx_ba_cb_irqsafe(struct ieee80211_vif *vif, uint8_t *addr, 2145 uint8_t tid) 2146 { 2147 TODO("iwlwifi/rtw8x/..."); 2148 } 2149 2150 static __inline void 2151 ieee80211_sched_scan_stopped(struct ieee80211_hw *hw) 2152 { 2153 TODO(); 2154 } 2155 2156 static __inline void 2157 ieee80211_scan_completed(struct ieee80211_hw *hw, 2158 struct cfg80211_scan_info *info) 2159 { 2160 2161 linuxkpi_ieee80211_scan_completed(hw, info); 2162 } 2163 2164 static __inline struct sk_buff * 2165 ieee80211_beacon_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 2166 uint32_t link_id) 2167 { 2168 TODO(); 2169 return (NULL); 2170 } 2171 2172 static __inline struct sk_buff * 2173 ieee80211_pspoll_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif) 2174 { 2175 2176 /* Only STA needs this. Otherwise return NULL and panic bad drivers. */ 2177 if (vif->type != NL80211_IFTYPE_STATION) 2178 return (NULL); 2179 2180 return (linuxkpi_ieee80211_pspoll_get(hw, vif)); 2181 } 2182 2183 static __inline struct sk_buff * 2184 ieee80211_proberesp_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif) 2185 { 2186 TODO(); 2187 return (NULL); 2188 } 2189 2190 static __inline struct sk_buff * 2191 ieee80211_nullfunc_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 2192 int linkid, bool qos) 2193 { 2194 2195 /* Only STA needs this. Otherwise return NULL and panic bad drivers. */ 2196 if (vif->type != NL80211_IFTYPE_STATION) 2197 return (NULL); 2198 2199 return (linuxkpi_ieee80211_nullfunc_get(hw, vif, linkid, qos)); 2200 } 2201 2202 static __inline struct sk_buff * 2203 ieee80211_probereq_get(struct ieee80211_hw *hw, uint8_t *addr, 2204 uint8_t *ssid, size_t ssid_len, size_t tailroom) 2205 { 2206 2207 return (linuxkpi_ieee80211_probereq_get(hw, addr, ssid, ssid_len, 2208 tailroom)); 2209 } 2210 2211 static __inline void 2212 ieee80211_queue_delayed_work(struct ieee80211_hw *hw, struct delayed_work *w, 2213 int delay) 2214 { 2215 2216 linuxkpi_ieee80211_queue_delayed_work(hw, w, delay); 2217 } 2218 2219 static __inline void 2220 ieee80211_queue_work(struct ieee80211_hw *hw, struct work_struct *w) 2221 { 2222 2223 linuxkpi_ieee80211_queue_work(hw, w); 2224 } 2225 2226 static __inline void 2227 ieee80211_tx_status_skb(struct ieee80211_hw *hw, struct sk_buff *skb) 2228 { 2229 linuxkpi_ieee80211_tx_status(hw, skb); 2230 } 2231 2232 static __inline void 2233 ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw, struct sk_buff *skb) 2234 { 2235 IMPROVE(); 2236 linuxkpi_ieee80211_tx_status(hw, skb); 2237 } 2238 2239 static __inline void 2240 ieee80211_tx_status_ni(struct ieee80211_hw *hw, struct sk_buff *skb) 2241 { 2242 IMPROVE(); 2243 linuxkpi_ieee80211_tx_status(hw, skb); 2244 } 2245 2246 static __inline void 2247 ieee80211_tx_status_ext(struct ieee80211_hw *hw, 2248 struct ieee80211_tx_status *txstat) 2249 { 2250 2251 linuxkpi_ieee80211_tx_status_ext(hw, txstat); 2252 } 2253 2254 static __inline void 2255 ieee80211_tx_info_clear_status(struct ieee80211_tx_info *info) 2256 { 2257 int i; 2258 2259 /* 2260 * Apparently clearing flags and some other fields is not right. 2261 * Given the function is called "status" we work on that part of 2262 * the union. 2263 */ 2264 for (i = 0; i < nitems(info->status.rates); i++) 2265 info->status.rates[i].count = 0; 2266 /* 2267 * Unclear if ack_signal should be included or not but we clear the 2268 * "valid" bool so this field is no longer valid. 2269 */ 2270 memset(&info->status.ack_signal, 0, sizeof(*info) - 2271 offsetof(struct ieee80211_tx_info, status.ack_signal)); 2272 } 2273 2274 static __inline void 2275 ieee80211_txq_get_depth(struct ieee80211_txq *txq, unsigned long *frame_cnt, 2276 unsigned long *byte_cnt) 2277 { 2278 2279 if (frame_cnt == NULL && byte_cnt == NULL) 2280 return; 2281 2282 linuxkpi_ieee80211_txq_get_depth(txq, frame_cnt, byte_cnt); 2283 } 2284 2285 static __inline void 2286 SET_IEEE80211_PERM_ADDR (struct ieee80211_hw *hw, uint8_t *addr) 2287 { 2288 2289 ether_addr_copy(hw->wiphy->perm_addr, addr); 2290 } 2291 2292 static __inline void 2293 ieee80211_report_low_ack(struct ieee80211_sta *sta, int x) 2294 { 2295 TODO(); 2296 } 2297 2298 static __inline void 2299 ieee80211_tx_rate_update(struct ieee80211_hw *hw, struct ieee80211_sta *sta, 2300 struct ieee80211_tx_info *info) 2301 { 2302 TODO(); 2303 } 2304 2305 static __inline bool 2306 ieee80211_txq_may_transmit(struct ieee80211_hw *hw, struct ieee80211_txq *txq) 2307 { 2308 TODO(); 2309 return (false); 2310 } 2311 2312 static __inline void 2313 ieee80211_radar_detected(struct ieee80211_hw *hw) 2314 { 2315 TODO(); 2316 } 2317 2318 static __inline void 2319 ieee80211_sta_register_airtime(struct ieee80211_sta *sta, 2320 uint8_t tid, uint32_t duration, int x) 2321 { 2322 TODO(); 2323 } 2324 2325 static __inline void 2326 ieee80211_beacon_set_cntdwn(struct ieee80211_vif *vif, u8 counter) 2327 { 2328 TODO(); 2329 } 2330 2331 static __inline int 2332 ieee80211_beacon_update_cntdwn(struct ieee80211_vif *vif, uint32_t link_id) 2333 { 2334 TODO(); 2335 return (-1); 2336 } 2337 2338 static __inline bool 2339 ieee80211_beacon_cntdwn_is_complete(struct ieee80211_vif *vif, uint32_t link_id) 2340 { 2341 TODO(); 2342 return (true); 2343 } 2344 2345 static __inline void 2346 ieee80211_disconnect(struct ieee80211_vif *vif, bool _x) 2347 { 2348 TODO(); 2349 } 2350 2351 static __inline void 2352 ieee80211_channel_switch_disconnect(struct ieee80211_vif *vif, bool _x) 2353 { 2354 TODO(); 2355 } 2356 2357 static __inline void 2358 ieee80211_key_mic_failure(struct ieee80211_key_conf *key) 2359 { 2360 TODO(); 2361 } 2362 2363 static __inline void 2364 ieee80211_key_replay(struct ieee80211_key_conf *key) 2365 { 2366 TODO(); 2367 } 2368 2369 static __inline uint32_t 2370 ieee80211_calc_rx_airtime(struct ieee80211_hw *hw, 2371 struct ieee80211_rx_status *rxstat, int len) 2372 { 2373 TODO(); 2374 return (0); 2375 } 2376 2377 static __inline void 2378 ieee80211_get_tx_rates(struct ieee80211_vif *vif, struct ieee80211_sta *sta, 2379 struct sk_buff *skb, struct ieee80211_tx_rate *txrate, int nrates) 2380 { 2381 TODO(); 2382 } 2383 2384 static __inline void 2385 ieee80211_color_change_finish(struct ieee80211_vif *vif) 2386 { 2387 TODO(); 2388 } 2389 2390 static __inline struct sk_buff * 2391 ieee80211_get_fils_discovery_tmpl(struct ieee80211_hw *hw, 2392 struct ieee80211_vif *vif) 2393 { 2394 TODO(); 2395 return (NULL); 2396 } 2397 2398 static __inline struct sk_buff * 2399 ieee80211_get_unsol_bcast_probe_resp_tmpl(struct ieee80211_hw *hw, 2400 struct ieee80211_vif *vif) 2401 { 2402 TODO(); 2403 return (NULL); 2404 } 2405 2406 static __inline void 2407 linuxkpi_ieee80211_send_bar(struct ieee80211_vif *vif, uint8_t *ra, uint16_t tid, 2408 uint16_t ssn) 2409 { 2410 TODO(); 2411 } 2412 2413 static __inline void 2414 ieee80211_resume_disconnect(struct ieee80211_vif *vif) 2415 { 2416 TODO(); 2417 } 2418 2419 static __inline int 2420 ieee80211_data_to_8023(struct sk_buff *skb, const uint8_t *addr, 2421 enum nl80211_iftype iftype) 2422 { 2423 TODO(); 2424 return (-1); 2425 } 2426 2427 static __inline void 2428 ieee80211_get_tkip_p1k_iv(struct ieee80211_key_conf *key, 2429 uint32_t iv32, uint16_t *p1k) 2430 { 2431 TODO(); 2432 } 2433 2434 static __inline struct ieee80211_key_conf * 2435 ieee80211_gtk_rekey_add(struct ieee80211_vif *vif, 2436 struct ieee80211_key_conf *key, int link_id) 2437 { 2438 TODO(); 2439 return (NULL); 2440 } 2441 2442 static __inline void 2443 ieee80211_gtk_rekey_notify(struct ieee80211_vif *vif, const uint8_t *bssid, 2444 const uint8_t *replay_ctr, gfp_t gfp) 2445 { 2446 TODO(); 2447 } 2448 2449 static __inline void 2450 ieee80211_remove_key(struct ieee80211_key_conf *key) 2451 { 2452 TODO(); 2453 } 2454 2455 static inline void 2456 ieee80211_get_key_rx_seq(struct ieee80211_key_conf *keyconf, int8_t tid, 2457 struct ieee80211_key_seq *seq) 2458 { 2459 const struct ieee80211_key *k; 2460 const uint8_t *p; 2461 2462 KASSERT(keyconf != NULL && seq != NULL, ("%s: keyconf %p seq %p\n", 2463 __func__, keyconf, seq)); 2464 KASSERT(tid <= IEEE80211_NUM_TIDS, ("%s: tid out of bounds %d\n", 2465 __func__, tid)); 2466 k = keyconf->_k; 2467 KASSERT(k != NULL, ("%s: keyconf %p ieee80211_key is NULL\n", __func__, keyconf)); 2468 2469 switch (keyconf->cipher) { 2470 case WLAN_CIPHER_SUITE_CCMP: 2471 case WLAN_CIPHER_SUITE_CCMP_256: 2472 if (tid < 0) 2473 p = (const uint8_t *)&k->wk_keyrsc[IEEE80211_NUM_TIDS]; /* IEEE80211_NONQOS_TID */ 2474 else 2475 p = (const uint8_t *)&k->wk_keyrsc[tid]; 2476 memcpy(seq->ccmp.pn, p, sizeof(seq->ccmp.pn)); 2477 break; 2478 case WLAN_CIPHER_SUITE_AES_CMAC: 2479 TODO(); 2480 memset(seq->aes_cmac.pn, 0xfa, sizeof(seq->aes_cmac.pn)); /* XXX TODO */ 2481 break; 2482 case WLAN_CIPHER_SUITE_TKIP: 2483 TODO(); 2484 seq->tkip.iv32 = 0xfa; /* XXX TODO */ 2485 seq->tkip.iv16 = 0xfa; /* XXX TODO */ 2486 break; 2487 default: 2488 pr_debug("%s: unsupported cipher suite %d\n", __func__, keyconf->cipher); 2489 break; 2490 } 2491 } 2492 2493 static __inline void 2494 ieee80211_set_key_rx_seq(struct ieee80211_key_conf *key, int tid, 2495 struct ieee80211_key_seq *seq) 2496 { 2497 TODO(); 2498 } 2499 2500 static __inline void 2501 ieee80211_report_wowlan_wakeup(struct ieee80211_vif *vif, 2502 struct cfg80211_wowlan_wakeup *wakeup, gfp_t gfp) 2503 { 2504 TODO(); 2505 } 2506 2507 static __inline void 2508 ieee80211_obss_color_collision_notify(struct ieee80211_vif *vif, 2509 uint64_t obss_color_bitmap, gfp_t gfp) 2510 { 2511 TODO(); 2512 } 2513 2514 static __inline void 2515 ieee80211_refresh_tx_agg_session_timer(struct ieee80211_sta *sta, 2516 uint8_t tid) 2517 { 2518 TODO(); 2519 } 2520 2521 static __inline struct ieee80211_ema_beacons * 2522 ieee80211_beacon_get_template_ema_list(struct ieee80211_hw *hw, 2523 struct ieee80211_vif *vif, uint32_t link_id) 2524 { 2525 TODO(); 2526 return (NULL); 2527 } 2528 2529 static __inline void 2530 ieee80211_beacon_free_ema_list(struct ieee80211_ema_beacons *bcns) 2531 { 2532 TODO(); 2533 } 2534 2535 static inline bool 2536 ieee80211_vif_is_mld(const struct ieee80211_vif *vif) 2537 { 2538 2539 /* If valid_links is non-zero, the vif is an MLD. */ 2540 return (vif->valid_links != 0); 2541 } 2542 2543 static inline const struct ieee80211_sta_he_cap * 2544 ieee80211_get_he_iftype_cap_vif(const struct ieee80211_supported_band *band, 2545 struct ieee80211_vif *vif) 2546 { 2547 enum nl80211_iftype iftype; 2548 2549 iftype = ieee80211_vif_type_p2p(vif); 2550 return (ieee80211_get_he_iftype_cap(band, iftype)); 2551 } 2552 2553 static inline const struct ieee80211_sta_eht_cap * 2554 ieee80211_get_eht_iftype_cap_vif(const struct ieee80211_supported_band *band, 2555 struct ieee80211_vif *vif) 2556 { 2557 enum nl80211_iftype iftype; 2558 2559 iftype = ieee80211_vif_type_p2p(vif); 2560 return (ieee80211_get_eht_iftype_cap(band, iftype)); 2561 } 2562 2563 static inline uint32_t 2564 ieee80211_vif_usable_links(const struct ieee80211_vif *vif) 2565 { 2566 IMPROVE("MLO usable links likely are not just valid"); 2567 return (vif->valid_links); 2568 } 2569 2570 static inline bool 2571 ieee80211_vif_link_active(const struct ieee80211_vif *vif, uint8_t link_id) 2572 { 2573 if (ieee80211_vif_is_mld(vif)) 2574 return (vif->active_links & BIT(link_id)); 2575 return (link_id == 0); 2576 } 2577 2578 static inline void 2579 ieee80211_set_active_links_async(struct ieee80211_vif *vif, 2580 uint32_t new_active_links) 2581 { 2582 TODO(); 2583 } 2584 2585 static inline int 2586 ieee80211_set_active_links(struct ieee80211_vif *vif, 2587 uint32_t active_links) 2588 { 2589 TODO(); 2590 return (-ENXIO); 2591 } 2592 2593 static inline void 2594 ieee80211_cqm_beacon_loss_notify(struct ieee80211_vif *vif, gfp_t gfp __unused) 2595 { 2596 IMPROVE("we notify user space by a vap state change eventually"); 2597 linuxkpi_ieee80211_beacon_loss(vif); 2598 } 2599 2600 #define ieee80211_send_bar(_v, _r, _t, _s) \ 2601 linuxkpi_ieee80211_send_bar(_v, _r, _t, _s) 2602 2603 /* -------------------------------------------------------------------------- */ 2604 2605 int lkpi_80211_update_chandef(struct ieee80211_hw *, 2606 struct ieee80211_chanctx_conf *); 2607 2608 static inline int 2609 ieee80211_emulate_add_chanctx(struct ieee80211_hw *hw, 2610 struct ieee80211_chanctx_conf *chanctx_conf) 2611 { 2612 int error; 2613 2614 hw->conf.radar_enabled = chanctx_conf->radar_enabled; 2615 error = lkpi_80211_update_chandef(hw, chanctx_conf); 2616 return (error); 2617 } 2618 2619 static inline void 2620 ieee80211_emulate_remove_chanctx(struct ieee80211_hw *hw, 2621 struct ieee80211_chanctx_conf *chanctx_conf __unused) 2622 { 2623 hw->conf.radar_enabled = false; 2624 lkpi_80211_update_chandef(hw, NULL); 2625 } 2626 2627 static inline void 2628 ieee80211_emulate_change_chanctx(struct ieee80211_hw *hw, 2629 struct ieee80211_chanctx_conf *chanctx_conf, uint32_t changed __unused) 2630 { 2631 hw->conf.radar_enabled = chanctx_conf->radar_enabled; 2632 lkpi_80211_update_chandef(hw, chanctx_conf); 2633 } 2634 2635 static inline int 2636 ieee80211_emulate_switch_vif_chanctx(struct ieee80211_hw *hw, 2637 struct ieee80211_vif_chanctx_switch *vifs, int n_vifs, 2638 enum ieee80211_chanctx_switch_mode mode __unused) 2639 { 2640 struct ieee80211_chanctx_conf *chanctx_conf; 2641 int error; 2642 2643 /* Sanity check. */ 2644 if (n_vifs <= 0) 2645 return (-EINVAL); 2646 if (vifs == NULL || vifs[0].new_ctx == NULL) 2647 return (-EINVAL); 2648 2649 /* 2650 * What to do if n_vifs > 1? 2651 * Does that make sense for drivers not supporting chanctx? 2652 */ 2653 hw->conf.radar_enabled = vifs[0].new_ctx->radar_enabled; 2654 chanctx_conf = vifs[0].new_ctx; 2655 error = lkpi_80211_update_chandef(hw, chanctx_conf); 2656 return (error); 2657 } 2658 2659 /* -------------------------------------------------------------------------- */ 2660 2661 #endif /* _LINUXKPI_NET_MAC80211_H */ 2662