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