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