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