1 /*- 2 * Copyright (c) 2020-2021 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 * $FreeBSD$ 30 */ 31 32 #ifndef _LINUXKPI_NET_MAC80211_H 33 #define _LINUXKPI_NET_MAC80211_H 34 35 #include <sys/types.h> 36 37 #include <asm/atomic64.h> 38 #include <linux/bitops.h> 39 #include <linux/etherdevice.h> 40 #include <linux/ethtool.h> 41 #include <linux/netdevice.h> 42 #include <linux/skbuff.h> 43 #include <linux/workqueue.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 /* hw->conf.flags */ 55 enum ieee80211_hw_conf_flags { 56 IEEE80211_CONF_IDLE = BIT(0), 57 IEEE80211_CONF_PS = BIT(1), 58 IEEE80211_CONF_MONITOR = BIT(2), 59 IEEE80211_CONF_OFFCHANNEL = BIT(3), 60 }; 61 62 /* (*ops->config()) */ 63 enum ieee80211_hw_conf_changed_flags { 64 IEEE80211_CONF_CHANGE_CHANNEL = BIT(0), 65 IEEE80211_CONF_CHANGE_IDLE = BIT(1), 66 IEEE80211_CONF_CHANGE_PS = BIT(2), 67 IEEE80211_CONF_CHANGE_MONITOR = BIT(3), 68 IEEE80211_CONF_CHANGE_POWER = BIT(4), 69 }; 70 71 #define CFG80211_TESTMODE_CMD(_x) /* XXX TODO */ 72 #define CFG80211_TESTMODE_DUMP(_x) /* XXX TODO */ 73 74 #define FCS_LEN 4 75 76 /* ops.configure_filter() */ 77 enum mcast_filter_flags { 78 FIF_ALLMULTI = BIT(0), 79 FIF_PROBE_REQ = BIT(1), 80 FIF_BCN_PRBRESP_PROMISC = BIT(2), 81 FIF_FCSFAIL = BIT(3), 82 FIF_OTHER_BSS = BIT(4), 83 FIF_PSPOLL = BIT(5), 84 FIF_CONTROL = BIT(6), 85 }; 86 87 enum ieee80211_bss_changed { 88 BSS_CHANGED_ARP_FILTER = BIT(0), 89 BSS_CHANGED_ASSOC = BIT(1), 90 BSS_CHANGED_BANDWIDTH = BIT(2), 91 BSS_CHANGED_BEACON = BIT(3), 92 BSS_CHANGED_BEACON_ENABLED = BIT(4), 93 BSS_CHANGED_BEACON_INFO = BIT(5), 94 BSS_CHANGED_BEACON_INT = BIT(6), 95 BSS_CHANGED_BSSID = BIT(7), 96 BSS_CHANGED_CQM = BIT(8), 97 BSS_CHANGED_ERP_CTS_PROT = BIT(9), 98 BSS_CHANGED_ERP_SLOT = BIT(10), 99 BSS_CHANGED_FTM_RESPONDER = BIT(11), 100 BSS_CHANGED_HT = BIT(12), 101 BSS_CHANGED_IDLE = BIT(13), 102 BSS_CHANGED_MU_GROUPS = BIT(14), 103 BSS_CHANGED_P2P_PS = BIT(15), 104 BSS_CHANGED_PS = BIT(16), 105 BSS_CHANGED_QOS = BIT(17), 106 BSS_CHANGED_TXPOWER = BIT(18), 107 BSS_CHANGED_HE_BSS_COLOR = BIT(19), 108 BSS_CHANGED_AP_PROBE_RESP = BIT(20), 109 BSS_CHANGED_BASIC_RATES = BIT(21), 110 BSS_CHANGED_ERP_PREAMBLE = BIT(22), 111 BSS_CHANGED_IBSS = BIT(23), 112 BSS_CHANGED_MCAST_RATE = BIT(24), 113 BSS_CHANGED_SSID = BIT(25), 114 BSS_CHANGED_FILS_DISCOVERY = BIT(26), 115 BSS_CHANGED_HE_OBSS_PD = BIT(27), 116 BSS_CHANGED_TWT = BIT(28), 117 BSS_CHANGED_UNSOL_BCAST_PROBE_RESP = BIT(30), 118 }; 119 120 /* 802.11 Figure 9-256 Suite selector format. [OUI(3), SUITE TYPE(1)] */ 121 #define WLAN_CIPHER_SUITE_OUI(_oui, _x) (((_oui) << 8) | ((_x) & 0xff)) 122 123 /* 802.11 Table 9-131 Cipher suite selectors. */ 124 /* 802.1x suite B 11 */ 125 #define WLAN_CIPHER_SUITE(_x) WLAN_CIPHER_SUITE_OUI(0x000fac, _x) 126 /* Use group 0 */ 127 #define WLAN_CIPHER_SUITE_WEP40 WLAN_CIPHER_SUITE(1) 128 #define WLAN_CIPHER_SUITE_TKIP WLAN_CIPHER_SUITE(2) 129 /* Reserved 3 */ 130 #define WLAN_CIPHER_SUITE_CCMP WLAN_CIPHER_SUITE(4) /* CCMP-128 */ 131 #define WLAN_CIPHER_SUITE_WEP104 WLAN_CIPHER_SUITE(5) 132 #define WLAN_CIPHER_SUITE_AES_CMAC WLAN_CIPHER_SUITE(6) /* BIP-CMAC-128 */ 133 /* Group addressed traffic not allowed 7 */ 134 #define WLAN_CIPHER_SUITE_GCMP WLAN_CIPHER_SUITE(8) 135 #define WLAN_CIPHER_SUITE_GCMP_256 WLAN_CIPHER_SUITE(9) 136 #define WLAN_CIPHER_SUITE_CCMP_256 WLAN_CIPHER_SUITE(10) 137 #define WLAN_CIPHER_SUITE_BIP_GMAC_128 WLAN_CIPHER_SUITE(11) 138 #define WLAN_CIPHER_SUITE_BIP_GMAC_256 WLAN_CIPHER_SUITE(12) 139 #define WLAN_CIPHER_SUITE_BIP_CMAC_256 WLAN_CIPHER_SUITE(13) 140 /* Reserved 14-255 */ 141 142 /* See ISO/IEC JTC 1 N 9880 Table 11 */ 143 #define WLAN_CIPHER_SUITE_SMS4 WLAN_CIPHER_SUITE_OUI(0x001472, 1) 144 145 146 /* 802.11 Table 9-133 AKM suite selectors. */ 147 #define WLAN_AKM_SUITE(_x) WLAN_CIPHER_SUITE_OUI(0x000fac, _x) 148 /* Reserved 0 */ 149 #define WLAN_AKM_SUITE_8021X WLAN_AKM_SUITE(1) 150 #define WLAN_AKM_SUITE_PSK WLAN_AKM_SUITE(2) 151 #define WLAN_AKM_SUITE_FT_8021X WLAN_AKM_SUITE(3) 152 #define WLAN_AKM_SUITE_FT_PSK WLAN_AKM_SUITE(4) 153 #define WLAN_AKM_SUITE_8021X_SHA256 WLAN_AKM_SUITE(5) 154 #define WLAN_AKM_SUITE_PSK_SHA256 WLAN_AKM_SUITE(6) 155 /* TDLS 7 */ 156 #define WLAN_AKM_SUITE_SAE WLAN_AKM_SUITE(8) 157 /* FToSAE 9 */ 158 /* AP peer key 10 */ 159 /* 802.1x suite B 11 */ 160 /* 802.1x suite B 384 12 */ 161 /* FTo802.1x 384 13 */ 162 /* Reserved 14-255 */ 163 /* Apparently 11ax defines more. Seen (19,20) mentioned. */ 164 165 166 struct ieee80211_sta; 167 168 /* 802.11-2020 9.4.2.55.3 A-MPDU Parameters field */ 169 #define IEEE80211_HT_AMPDU_PARM_FACTOR 0x3 170 #define IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT 2 171 #define IEEE80211_HT_AMPDU_PARM_DENSITY (0x7 << IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT) 172 173 struct ieee80211_ampdu_params { 174 /* TODO FIXME */ 175 struct ieee80211_sta *sta; 176 uint8_t tid; 177 uint16_t ssn; 178 int action, amsdu, buf_size, timeout; 179 }; 180 181 struct ieee80211_bar { 182 /* TODO FIXME */ 183 int control, start_seq_num; 184 uint8_t *ra; 185 uint16_t frame_control; 186 }; 187 188 struct ieee80211_p2p_noa_desc { 189 uint32_t count; /* uint8_t ? */ 190 uint32_t duration; 191 uint32_t interval; 192 uint32_t start_time; 193 }; 194 195 struct ieee80211_p2p_noa_attr { 196 uint8_t index; 197 uint8_t oppps_ctwindow; 198 struct ieee80211_p2p_noa_desc desc[4]; 199 }; 200 201 struct ieee80211_mutable_offsets { 202 /* TODO FIXME */ 203 uint16_t tim_offset; 204 uint16_t cntdwn_counter_offs[2]; 205 206 int mbssid_off; 207 }; 208 209 struct mac80211_fils_discovery { 210 uint32_t max_interval; 211 }; 212 213 #define WLAN_MEMBERSHIP_LEN (8) 214 #define WLAN_USER_POSITION_LEN (16) 215 216 struct ieee80211_bss_conf { 217 /* TODO FIXME */ 218 uint8_t bssid[ETH_ALEN]; 219 uint8_t transmitter_bssid[ETH_ALEN]; 220 struct ieee80211_ftm_responder_params *ftmr_params; 221 struct ieee80211_p2p_noa_attr p2p_noa_attr; 222 struct cfg80211_chan_def chandef; 223 __be32 arp_addr_list[1]; /* XXX TODO */ 224 struct ieee80211_rate *beacon_rate; 225 struct { 226 uint8_t membership[WLAN_MEMBERSHIP_LEN]; 227 uint8_t position[WLAN_USER_POSITION_LEN]; 228 } mu_group; 229 struct cfg80211_he_bss_color he_bss_color; 230 struct ieee80211_he_obss_pd he_obss_pd; 231 size_t ssid_len; 232 uint8_t ssid[IEEE80211_NWID_LEN]; 233 uint16_t aid; 234 uint16_t ht_operation_mode; 235 int arp_addr_cnt; 236 237 uint8_t dtim_period; 238 uint8_t sync_dtim_count; 239 bool assoc; 240 bool idle; 241 bool qos; 242 bool ps; 243 bool twt_broadcast; 244 bool use_cts_prot; 245 bool use_short_preamble; 246 bool use_short_slot; 247 bool he_support; 248 bool csa_active; 249 uint32_t sync_device_ts; 250 uint64_t sync_tsf; 251 uint16_t beacon_int; 252 int16_t txpower; 253 uint32_t basic_rates; 254 int mcast_rate[NUM_NL80211_BANDS]; 255 struct cfg80211_bitrate_mask beacon_tx_rate; 256 struct mac80211_fils_discovery fils_discovery; 257 258 int ack_enabled, bssid_index, bssid_indicator, cqm_rssi_hyst, cqm_rssi_thold, ema_ap, frame_time_rts_th, ftm_responder; 259 int htc_trig_based_pkt_ext; 260 int multi_sta_back_32bit, nontransmitted; 261 int profile_periodicity; 262 int twt_requester, uora_exists, uora_ocw_range; 263 int assoc_capability, enable_beacon, hidden_ssid, ibss_joined, twt_protected; 264 int he_oper, twt_responder, unsol_bcast_probe_resp_interval; 265 int color_change_active; 266 }; 267 268 struct ieee80211_chanctx_conf { 269 /* TODO FIXME */ 270 int rx_chains_dynamic, rx_chains_static; 271 bool radar_enabled; 272 struct cfg80211_chan_def def; 273 struct cfg80211_chan_def min_def; 274 275 /* Must stay last. */ 276 uint8_t drv_priv[0] __aligned(CACHE_LINE_SIZE); 277 }; 278 279 struct ieee80211_channel_switch { 280 /* TODO FIXME */ 281 int block_tx, count, delay, device_timestamp, timestamp; 282 struct cfg80211_chan_def chandef; 283 }; 284 285 struct ieee80211_cipher_scheme { 286 uint32_t cipher; 287 uint8_t iftype; /* We do not know the size of this. */ 288 uint8_t hdr_len; 289 uint8_t pn_len; 290 uint8_t pn_off; 291 uint8_t key_idx_off; 292 uint8_t key_idx_mask; 293 uint8_t key_idx_shift; 294 uint8_t mic_len; 295 }; 296 297 enum ieee80211_event_type { 298 BA_FRAME_TIMEOUT, 299 BAR_RX_EVENT, 300 MLME_EVENT, 301 RSSI_EVENT, 302 }; 303 304 enum ieee80211_rssi_event_data { 305 RSSI_EVENT_LOW, 306 RSSI_EVENT_HIGH, 307 }; 308 309 enum ieee80211_mlme_event_data { 310 ASSOC_EVENT, 311 AUTH_EVENT, 312 DEAUTH_RX_EVENT, 313 DEAUTH_TX_EVENT, 314 }; 315 316 enum ieee80211_mlme_event_status { 317 MLME_DENIED, 318 MLME_TIMEOUT, 319 }; 320 321 struct ieee80211_mlme_event { 322 enum ieee80211_mlme_event_data data; 323 enum ieee80211_mlme_event_status status; 324 int reason; 325 }; 326 327 struct ieee80211_event { 328 /* TODO FIXME */ 329 enum ieee80211_event_type type; 330 union { 331 struct { 332 int ssn; 333 struct ieee80211_sta *sta; 334 uint8_t tid; 335 } ba; 336 struct ieee80211_mlme_event mlme; 337 } u; 338 }; 339 340 struct ieee80211_ftm_responder_params { 341 /* TODO FIXME */ 342 uint8_t *lci; 343 uint8_t *civicloc; 344 int lci_len; 345 int civicloc_len; 346 }; 347 348 struct ieee80211_he_mu_edca_param_ac_rec { 349 /* TODO FIXME */ 350 int aifsn, ecw_min_max, mu_edca_timer; 351 }; 352 353 struct ieee80211_conf { 354 int dynamic_ps_timeout; 355 int power_level; 356 uint32_t listen_interval; 357 bool radar_enabled; 358 enum ieee80211_hw_conf_flags flags; 359 struct cfg80211_chan_def chandef; 360 }; 361 362 enum ieee80211_hw_flags { 363 IEEE80211_HW_AMPDU_AGGREGATION, 364 IEEE80211_HW_AP_LINK_PS, 365 IEEE80211_HW_BUFF_MMPDU_TXQ, 366 IEEE80211_HW_CHANCTX_STA_CSA, 367 IEEE80211_HW_CONNECTION_MONITOR, 368 IEEE80211_HW_DEAUTH_NEED_MGD_TX_PREP, 369 IEEE80211_HW_HAS_RATE_CONTROL, 370 IEEE80211_HW_MFP_CAPABLE, 371 IEEE80211_HW_NEEDS_UNIQUE_STA_ADDR, 372 IEEE80211_HW_REPORTS_TX_ACK_STATUS, 373 IEEE80211_HW_RX_INCLUDES_FCS, 374 IEEE80211_HW_SIGNAL_DBM, 375 IEEE80211_HW_SINGLE_SCAN_ON_ALL_BANDS, 376 IEEE80211_HW_SPECTRUM_MGMT, 377 IEEE80211_HW_STA_MMPDU_TXQ, 378 IEEE80211_HW_SUPPORTS_AMSDU_IN_AMPDU, 379 IEEE80211_HW_SUPPORTS_CLONED_SKBS, 380 IEEE80211_HW_SUPPORTS_DYNAMIC_PS, 381 IEEE80211_HW_SUPPORTS_MULTI_BSSID, 382 IEEE80211_HW_SUPPORTS_ONLY_HE_MULTI_BSSID, 383 IEEE80211_HW_SUPPORTS_PS, 384 IEEE80211_HW_SUPPORTS_REORDERING_BUFFER, 385 IEEE80211_HW_SUPPORTS_VHT_EXT_NSS_BW, 386 IEEE80211_HW_SUPPORT_FAST_XMIT, 387 IEEE80211_HW_TDLS_WIDER_BW, 388 IEEE80211_HW_TIMING_BEACON_ONLY, 389 IEEE80211_HW_TX_AMPDU_SETUP_IN_HW, 390 IEEE80211_HW_TX_AMSDU, 391 IEEE80211_HW_TX_FRAG_LIST, 392 IEEE80211_HW_USES_RSS, 393 IEEE80211_HW_WANT_MONITOR_VIF, 394 IEEE80211_HW_SW_CRYPTO_CONTROL, 395 IEEE80211_HW_SUPPORTS_TX_FRAG, 396 IEEE80211_HW_SUPPORTS_TDLS_BUFFER_STA, 397 IEEE80211_HW_SUPPORTS_PER_STA_GTK, 398 IEEE80211_HW_REPORTS_LOW_ACK, 399 IEEE80211_HW_QUEUE_CONTROL, 400 IEEE80211_HW_SUPPORTS_RX_DECAP_OFFLOAD, 401 IEEE80211_HW_SUPPORTS_TX_ENCAP_OFFLOAD, 402 IEEE80211_HW_SUPPORTS_RC_TABLE, 403 404 /* Keep last. */ 405 NUM_IEEE80211_HW_FLAGS 406 }; 407 408 struct ieee80211_hw { 409 410 struct wiphy *wiphy; 411 412 /* TODO FIXME */ 413 int max_rx_aggregation_subframes, max_tx_aggregation_subframes; 414 int extra_tx_headroom, weight_multiplier; 415 int max_rate_tries, max_rates, max_report_rates; 416 struct ieee80211_cipher_scheme *cipher_schemes; 417 int n_cipher_schemes; 418 const char *rate_control_algorithm; 419 struct { 420 uint16_t units_pos; /* radiotap "spec" is .. inconsistent. */ 421 uint16_t accuracy; 422 } radiotap_timestamp; 423 size_t sta_data_size; 424 size_t vif_data_size; 425 size_t chanctx_data_size; 426 size_t txq_data_size; 427 uint16_t radiotap_mcs_details; 428 uint16_t radiotap_vht_details; 429 uint16_t queues; 430 uint16_t offchannel_tx_hw_queue; 431 uint16_t uapsd_max_sp_len; 432 uint16_t uapsd_queues; 433 uint16_t max_tx_fragments; 434 uint16_t max_listen_interval; 435 netdev_features_t netdev_features; 436 unsigned long flags[BITS_TO_LONGS(NUM_IEEE80211_HW_FLAGS)]; 437 struct ieee80211_conf conf; 438 439 #if 0 /* leave here for documentation purposes. This does NOT work. */ 440 /* Must stay last. */ 441 uint8_t priv[0] __aligned(CACHE_LINE_SIZE); 442 #else 443 void *priv; 444 #endif 445 }; 446 447 enum ieee802111_key_flag { 448 IEEE80211_KEY_FLAG_GENERATE_IV = BIT(0), 449 IEEE80211_KEY_FLAG_GENERATE_MMIC = BIT(1), 450 IEEE80211_KEY_FLAG_PAIRWISE = BIT(2), 451 IEEE80211_KEY_FLAG_PUT_IV_SPACE = BIT(3), 452 IEEE80211_KEY_FLAG_PUT_MIC_SPACE = BIT(4), 453 IEEE80211_KEY_FLAG_SW_MGMT_TX = BIT(5), 454 IEEE80211_KEY_FLAG_GENERATE_IV_MGMT = BIT(6), 455 IEEE80211_KEY_FLAG_GENERATE_MMIE = BIT(7), 456 }; 457 458 struct ieee80211_key_conf { 459 atomic64_t tx_pn; 460 uint32_t cipher; 461 uint8_t icv_len; /* __unused nowadays? */ 462 uint8_t iv_len; 463 uint8_t hw_key_idx; /* Set by drv. */ 464 uint8_t keyidx; 465 uint16_t flags; 466 uint8_t keylen; 467 uint8_t key[0]; 468 }; 469 470 struct ieee80211_key_seq { 471 /* TODO FIXME */ 472 union { 473 struct { 474 uint8_t seq[IEEE80211_MAX_PN_LEN]; 475 uint8_t seq_len; 476 } hw; 477 struct { 478 uint8_t pn[IEEE80211_CCMP_PN_LEN]; 479 } ccmp; 480 struct { 481 uint8_t pn[IEEE80211_CCMP_PN_LEN]; 482 } aes_cmac; 483 struct { 484 uint32_t iv32; 485 uint16_t iv16; 486 } tkip; 487 }; 488 }; 489 490 491 enum ieee80211_rx_status_flags { 492 RX_FLAG_ALLOW_SAME_PN = BIT(0), 493 RX_FLAG_AMPDU_DETAILS = BIT(1), 494 RX_FLAG_AMPDU_EOF_BIT = BIT(2), 495 RX_FLAG_AMPDU_EOF_BIT_KNOWN = BIT(3), 496 RX_FLAG_DECRYPTED = BIT(4), 497 RX_FLAG_DUP_VALIDATED = BIT(5), 498 RX_FLAG_FAILED_FCS_CRC = BIT(6), 499 RX_FLAG_ICV_STRIPPED = BIT(7), 500 RX_FLAG_MACTIME_PLCP_START = BIT(8), 501 RX_FLAG_MACTIME_START = BIT(9), 502 RX_FLAG_MIC_STRIPPED = BIT(10), 503 RX_FLAG_MMIC_ERROR = BIT(11), 504 RX_FLAG_MMIC_STRIPPED = BIT(12), 505 RX_FLAG_NO_PSDU = BIT(13), 506 RX_FLAG_PN_VALIDATED = BIT(14), 507 RX_FLAG_RADIOTAP_HE = BIT(15), 508 RX_FLAG_RADIOTAP_HE_MU = BIT(16), 509 RX_FLAG_RADIOTAP_LSIG = BIT(17), 510 RX_FLAG_RADIOTAP_VENDOR_DATA = BIT(18), 511 RX_FLAG_NO_SIGNAL_VAL = BIT(19), 512 RX_FLAG_IV_STRIPPED = BIT(20), 513 RX_FLAG_AMPDU_IS_LAST = BIT(21), 514 RX_FLAG_AMPDU_LAST_KNOWN = BIT(22), 515 RX_FLAG_AMSDU_MORE = BIT(23), 516 RX_FLAG_MACTIME_END = BIT(24), 517 RX_FLAG_ONLY_MONITOR = BIT(25), 518 RX_FLAG_SKIP_MONITOR = BIT(26), 519 RX_FLAG_8023 = BIT(27), 520 }; 521 522 enum mac80211_rx_encoding { 523 RX_ENC_LEGACY = 0, 524 RX_ENC_HT, 525 RX_ENC_VHT, 526 RX_ENC_HE 527 }; 528 529 struct ieee80211_rx_status { 530 /* TODO FIXME, this is too large. Over-reduce types to u8 where possible. */ 531 uint64_t boottime_ns; 532 uint64_t mactime; 533 uint32_t device_timestamp; 534 enum ieee80211_rx_status_flags flag; 535 uint16_t freq; 536 uint8_t encoding:2, bw:3, he_ru:3; /* enum mac80211_rx_encoding, rate_info_bw */ /* See mt76.h */ 537 uint8_t ampdu_reference; 538 uint8_t band; 539 uint8_t chains; 540 int8_t chain_signal[IEEE80211_MAX_CHAINS]; 541 int8_t signal; 542 uint8_t enc_flags; 543 uint8_t he_dcm; 544 uint8_t he_gi; 545 uint8_t zero_length_psdu_type; 546 uint8_t nss; 547 uint8_t rate_idx; 548 }; 549 550 struct ieee80211_tx_rate_status { 551 }; 552 553 struct ieee80211_tx_status { 554 struct ieee80211_sta *sta; 555 struct ieee80211_tx_info *info; 556 557 u8 n_rates; 558 struct ieee80211_tx_rate_status *rates; 559 560 struct sk_buff *skb; 561 struct list_head *free_list; 562 }; 563 564 struct ieee80211_scan_ies { 565 /* TODO FIXME */ 566 int common_ie_len; 567 int len[NUM_NL80211_BANDS]; 568 uint8_t *common_ies; 569 uint8_t *ies[NUM_NL80211_BANDS]; 570 }; 571 572 struct ieee80211_scan_request { 573 struct ieee80211_scan_ies ies; 574 struct cfg80211_scan_request req; 575 }; 576 577 struct ieee80211_txq { 578 struct ieee80211_sta *sta; 579 struct ieee80211_vif *vif; 580 int ac; 581 uint8_t tid; 582 583 /* Must stay last. */ 584 uint8_t drv_priv[0] __aligned(CACHE_LINE_SIZE); 585 }; 586 587 struct ieee80211_sta_rates { 588 /* XXX TODO */ 589 /* XXX some _rcu thing */ 590 struct { 591 int idx; 592 int flags; 593 } rate[1]; /* XXX what is the real number? */ 594 }; 595 596 struct ieee80211_sta_txpwr { 597 /* XXX TODO */ 598 enum nl80211_tx_power_setting type; 599 short power; 600 }; 601 602 struct ieee80211_link_sta { 603 uint32_t supp_rates[NUM_NL80211_BANDS]; 604 struct ieee80211_sta_ht_cap ht_cap; 605 struct ieee80211_sta_vht_cap vht_cap; 606 struct ieee80211_sta_he_cap he_cap; 607 struct ieee80211_sta_he_6ghz_capa he_6ghz_capa; 608 uint8_t rx_nss; 609 enum ieee80211_sta_rx_bw bandwidth; 610 struct ieee80211_sta_txpwr txpwr; 611 }; 612 613 #define IEEE80211_NUM_TIDS 16 /* net80211::WME_NUM_TID */ 614 struct ieee80211_sta { 615 /* TODO FIXME */ 616 int max_amsdu_len, max_amsdu_subframes, max_rc_amsdu_len, max_sp; 617 int mfp, smps_mode, tdls, tdls_initiator, uapsd_queues, wme; 618 struct ieee80211_txq *txq[IEEE80211_NUM_TIDS + 1]; /* iwlwifi: 8 and adds +1 to tid_data, net80211::IEEE80211_TID_SIZE */ 619 struct ieee80211_sta_rates *rates; /* some rcu thing? */ 620 uint32_t max_tid_amsdu_len[IEEE80211_NUM_TIDS]; 621 uint8_t addr[ETH_ALEN]; 622 uint16_t aid; 623 624 struct ieee80211_link_sta deflink; 625 626 /* Must stay last. */ 627 uint8_t drv_priv[0] __aligned(CACHE_LINE_SIZE); 628 }; 629 630 struct ieee80211_tdls_ch_sw_params { 631 /* TODO FIXME */ 632 int action_code, ch_sw_tm_ie, status, switch_time, switch_timeout, timestamp; 633 struct ieee80211_sta *sta; 634 struct cfg80211_chan_def *chandef; 635 struct sk_buff *tmpl_skb; 636 }; 637 638 struct ieee80211_tx_control { 639 /* TODO FIXME */ 640 struct ieee80211_sta *sta; 641 }; 642 643 struct ieee80211_tx_queue_params { 644 /* These types are based on iwlwifi FW structs. */ 645 uint16_t cw_min; 646 uint16_t cw_max; 647 uint16_t txop; 648 uint8_t aifs; 649 650 /* TODO FIXME */ 651 int acm, mu_edca, uapsd; 652 struct ieee80211_he_mu_edca_param_ac_rec mu_edca_param_rec; 653 }; 654 655 struct ieee80211_tx_rate { 656 uint8_t idx; 657 uint16_t count:5, 658 flags:11; 659 }; 660 661 enum ieee80211_vif_driver_flags { 662 IEEE80211_VIF_BEACON_FILTER = BIT(0), 663 IEEE80211_VIF_SUPPORTS_CQM_RSSI = BIT(1), 664 IEEE80211_VIF_SUPPORTS_UAPSD = BIT(2), 665 }; 666 667 #define IEEE80211_BSS_ARP_ADDR_LIST_LEN 4 668 669 struct ieee80211_vif_cfg { 670 uint16_t aid; 671 bool assoc; 672 int arp_addr_cnt; 673 uint32_t arp_addr_list[IEEE80211_BSS_ARP_ADDR_LIST_LEN]; /* big endian */ 674 }; 675 676 struct ieee80211_vif { 677 /* TODO FIXME */ 678 enum nl80211_iftype type; 679 int csa_active, mu_mimo_owner; 680 int cab_queue; 681 int color_change_active, offload_flags; 682 enum ieee80211_vif_driver_flags driver_flags; 683 bool p2p; 684 bool probe_req_reg; 685 uint8_t addr[ETH_ALEN]; 686 struct ieee80211_vif_cfg cfg; 687 struct ieee80211_chanctx_conf *chanctx_conf; 688 struct ieee80211_txq *txq; 689 struct ieee80211_bss_conf bss_conf; 690 uint8_t hw_queue[IEEE80211_NUM_ACS]; 691 692 /* Must stay last. */ 693 uint8_t drv_priv[0] __aligned(CACHE_LINE_SIZE); 694 }; 695 696 struct ieee80211_vif_chanctx_switch { 697 struct ieee80211_chanctx_conf *old_ctx, *new_ctx; 698 struct ieee80211_vif *vif; 699 }; 700 701 struct ieee80211_prep_tx_info { 702 u16 duration; 703 bool success; 704 }; 705 706 /* XXX-BZ too big, over-reduce size to u8, and array sizes to minuimum to fit in skb->cb. */ 707 /* Also warning: some sizes change by pointer size! This is 64bit only. */ 708 struct ieee80211_tx_info { 709 enum ieee80211_tx_info_flags flags; 710 /* TODO FIXME */ 711 u8 band; 712 u8 hw_queue; 713 bool tx_time_est; 714 union { 715 struct { 716 struct ieee80211_tx_rate rates[4]; 717 bool use_rts; 718 struct ieee80211_vif *vif; 719 struct ieee80211_key_conf *hw_key; 720 enum ieee80211_tx_control_flags flags; 721 } control; 722 struct { 723 struct ieee80211_tx_rate rates[4]; 724 uint32_t ack_signal; 725 uint8_t ampdu_ack_len; 726 uint8_t ampdu_len; 727 uint8_t antenna; 728 uint16_t tx_time; 729 bool is_valid_ack_signal; 730 void *status_driver_data[16 / sizeof(void *)]; /* XXX TODO */ 731 } status; 732 #define IEEE80211_TX_INFO_DRIVER_DATA_SIZE (5 * sizeof(void *)) /* XXX TODO 5? */ 733 void *driver_data[IEEE80211_TX_INFO_DRIVER_DATA_SIZE / sizeof(void *)]; 734 }; 735 }; 736 737 /* net80211 conflict */ 738 struct linuxkpi_ieee80211_tim_ie { 739 uint8_t dtim_count; 740 uint8_t dtim_period; 741 uint8_t bitmap_ctrl; 742 uint8_t *virtual_map; 743 }; 744 #define ieee80211_tim_ie linuxkpi_ieee80211_tim_ie 745 746 struct survey_info { /* net80211::struct ieee80211_channel_survey */ 747 /* TODO FIXME */ 748 uint32_t filled; 749 #define SURVEY_INFO_TIME 0x0001 750 #define SURVEY_INFO_TIME_RX 0x0002 751 #define SURVEY_INFO_TIME_SCAN 0x0004 752 #define SURVEY_INFO_TIME_TX 0x0008 753 #define SURVEY_INFO_TIME_BSS_RX 0x0010 754 #define SURVEY_INFO_TIME_BUSY 0x0020 755 #define SURVEY_INFO_IN_USE 0x0040 756 #define SURVEY_INFO_NOISE_DBM 0x0080 757 uint32_t noise; 758 uint64_t time; 759 uint64_t time_bss_rx; 760 uint64_t time_busy; 761 uint64_t time_rx; 762 uint64_t time_scan; 763 uint64_t time_tx; 764 struct ieee80211_channel *channel; 765 }; 766 767 enum ieee80211_iface_iter { 768 IEEE80211_IFACE_ITER_NORMAL = BIT(0), 769 IEEE80211_IFACE_ITER_RESUME_ALL = BIT(1), 770 IEEE80211_IFACE_SKIP_SDATA_NOT_IN_DRIVER = BIT(2), /* seems to be an iter flag */ 771 772 /* Internal flags only. */ 773 /* ieee80211_iterate_active_interfaces*(). */ 774 IEEE80211_IFACE_ITER__ATOMIC = BIT(6), 775 IEEE80211_IFACE_ITER__ACTIVE = BIT(7), 776 }; 777 778 enum set_key_cmd { 779 SET_KEY, 780 DISABLE_KEY, 781 }; 782 783 /* 802.11-2020, 9.4.2.55.2 HT Capability Information field. */ 784 enum rx_enc_flags { 785 RX_ENC_FLAG_SHORTPRE = BIT(0), 786 RX_ENC_FLAG_SHORT_GI = BIT(2), 787 RX_ENC_FLAG_HT_GF = BIT(3), 788 RX_ENC_FLAG_STBC_MASK = BIT(4) | BIT(5), 789 #define RX_ENC_FLAG_STBC_SHIFT 4 790 RX_ENC_FLAG_LDPC = BIT(6), 791 RX_ENC_FLAG_BF = BIT(7), 792 }; 793 794 enum sta_notify_cmd { 795 STA_NOTIFY_AWAKE, 796 STA_NOTIFY_SLEEP, 797 }; 798 799 struct ieee80211_low_level_stats { 800 /* Can we make them uint64_t? */ 801 uint32_t dot11ACKFailureCount; 802 uint32_t dot11FCSErrorCount; 803 uint32_t dot11RTSFailureCount; 804 uint32_t dot11RTSSuccessCount; 805 }; 806 807 enum ieee80211_offload_flags { 808 IEEE80211_OFFLOAD_ENCAP_4ADDR, 809 }; 810 811 struct ieee80211_ops { 812 /* TODO FIXME */ 813 int (*start)(struct ieee80211_hw *); 814 void (*stop)(struct ieee80211_hw *); 815 816 int (*config)(struct ieee80211_hw *, u32); 817 void (*reconfig_complete)(struct ieee80211_hw *, enum ieee80211_reconfig_type); 818 819 int (*add_interface)(struct ieee80211_hw *, struct ieee80211_vif *); 820 void (*remove_interface)(struct ieee80211_hw *, struct ieee80211_vif *); 821 int (*change_interface)(struct ieee80211_hw *, struct ieee80211_vif *, enum nl80211_iftype, bool); 822 823 void (*sw_scan_start)(struct ieee80211_hw *, struct ieee80211_vif *, const u8 *); 824 void (*sw_scan_complete)(struct ieee80211_hw *, struct ieee80211_vif *); 825 int (*sched_scan_start)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_sched_scan_request *, struct ieee80211_scan_ies *); 826 int (*sched_scan_stop)(struct ieee80211_hw *, struct ieee80211_vif *); 827 int (*hw_scan)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_scan_request *); 828 void (*cancel_hw_scan)(struct ieee80211_hw *, struct ieee80211_vif *); 829 830 int (*conf_tx)(struct ieee80211_hw *, struct ieee80211_vif *, u16, const struct ieee80211_tx_queue_params *); 831 void (*tx)(struct ieee80211_hw *, struct ieee80211_tx_control *, struct sk_buff *); 832 int (*tx_last_beacon)(struct ieee80211_hw *); 833 void (*wake_tx_queue)(struct ieee80211_hw *, struct ieee80211_txq *); 834 835 void (*mgd_prepare_tx)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_prep_tx_info *); 836 void (*mgd_complete_tx)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_prep_tx_info *); 837 void (*mgd_protect_tdls_discover)(struct ieee80211_hw *, struct ieee80211_vif *); 838 839 void (*flush)(struct ieee80211_hw *, struct ieee80211_vif *, u32, bool); 840 841 int (*set_frag_threshold)(struct ieee80211_hw *, u32); 842 843 void (*sync_rx_queues)(struct ieee80211_hw *); 844 845 void (*allow_buffered_frames)(struct ieee80211_hw *, struct ieee80211_sta *, u16, int, enum ieee80211_frame_release_type, bool); 846 void (*release_buffered_frames)(struct ieee80211_hw *, struct ieee80211_sta *, u16, int, enum ieee80211_frame_release_type, bool); 847 848 int (*sta_add)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *); 849 int (*sta_remove)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *); 850 int (*sta_set_txpwr)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *); 851 void (*sta_statistics)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, struct station_info *); 852 void (*sta_pre_rcu_remove)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *); 853 int (*sta_state)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, enum ieee80211_sta_state, enum ieee80211_sta_state); 854 void (*sta_notify)(struct ieee80211_hw *, struct ieee80211_vif *, enum sta_notify_cmd, struct ieee80211_sta *); 855 void (*sta_rc_update)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, u32); 856 void (*sta_rate_tbl_update)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *); 857 void (*sta_set_4addr)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, bool); 858 void (*sta_set_decap_offload)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, bool); 859 860 u64 (*prepare_multicast)(struct ieee80211_hw *, struct netdev_hw_addr_list *); 861 862 int (*ampdu_action)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_ampdu_params *); 863 864 bool (*can_aggregate_in_amsdu)(struct ieee80211_hw *, struct sk_buff *, struct sk_buff *); 865 866 int (*pre_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_channel_switch *); 867 int (*post_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *); 868 void (*channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_channel_switch *); 869 void (*channel_switch_beacon)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_chan_def *); 870 void (*abort_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *); 871 void (*channel_switch_rx_beacon)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_channel_switch *); 872 int (*tdls_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, u8, struct cfg80211_chan_def *, struct sk_buff *, u32); 873 void (*tdls_cancel_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *); 874 void (*tdls_recv_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_tdls_ch_sw_params *); 875 876 int (*add_chanctx)(struct ieee80211_hw *, struct ieee80211_chanctx_conf *); 877 void (*remove_chanctx)(struct ieee80211_hw *, struct ieee80211_chanctx_conf *); 878 void (*change_chanctx)(struct ieee80211_hw *, struct ieee80211_chanctx_conf *, u32); 879 int (*assign_vif_chanctx)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_chanctx_conf *); 880 void (*unassign_vif_chanctx)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_chanctx_conf *); 881 int (*switch_vif_chanctx)(struct ieee80211_hw *, struct ieee80211_vif_chanctx_switch *, int, enum ieee80211_chanctx_switch_mode); 882 883 int (*get_antenna)(struct ieee80211_hw *, u32 *, u32 *); 884 int (*set_antenna)(struct ieee80211_hw *, u32, u32); 885 886 int (*remain_on_channel)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_channel *, int, enum ieee80211_roc_type); 887 int (*cancel_remain_on_channel)(struct ieee80211_hw *, struct ieee80211_vif *); 888 889 void (*configure_filter)(struct ieee80211_hw *, unsigned int, unsigned int *, u64); 890 void (*config_iface_filter)(struct ieee80211_hw *, struct ieee80211_vif *, unsigned int, unsigned int); 891 892 void (*bss_info_changed)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_bss_conf *, u64); 893 int (*set_rts_threshold)(struct ieee80211_hw *, u32); 894 void (*event_callback)(struct ieee80211_hw *, struct ieee80211_vif *, const struct ieee80211_event *); 895 int (*get_survey)(struct ieee80211_hw *, int, struct survey_info *); 896 int (*get_ftm_responder_stats)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_ftm_responder_stats *); 897 898 uint64_t (*get_tsf)(struct ieee80211_hw *, struct ieee80211_vif *); 899 void (*set_tsf)(struct ieee80211_hw *, struct ieee80211_vif *, uint64_t); 900 void (*offset_tsf)(struct ieee80211_hw *, struct ieee80211_vif *, s64); 901 902 int (*set_bitrate_mask)(struct ieee80211_hw *, struct ieee80211_vif *, const struct cfg80211_bitrate_mask *); 903 void (*set_coverage_class)(struct ieee80211_hw *, s16); 904 int (*set_tim)(struct ieee80211_hw *, struct ieee80211_sta *, bool); 905 906 int (*set_key)(struct ieee80211_hw *, enum set_key_cmd, struct ieee80211_vif *, struct ieee80211_sta *, struct ieee80211_key_conf *); 907 void (*set_default_unicast_key)(struct ieee80211_hw *, struct ieee80211_vif *, int); 908 void (*update_tkip_key)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_key_conf *, struct ieee80211_sta *, u32, u16 *); 909 910 int (*start_pmsr)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_pmsr_request *); 911 void (*abort_pmsr)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_pmsr_request *); 912 913 int (*start_ap)(struct ieee80211_hw *, struct ieee80211_vif *); 914 void (*stop_ap)(struct ieee80211_hw *, struct ieee80211_vif *); 915 int (*join_ibss)(struct ieee80211_hw *, struct ieee80211_vif *); 916 void (*leave_ibss)(struct ieee80211_hw *, struct ieee80211_vif *); 917 918 int (*set_sar_specs)(struct ieee80211_hw *, const struct cfg80211_sar_specs *); 919 920 int (*set_tid_config)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, struct cfg80211_tid_config *); 921 int (*reset_tid_config)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, u8); 922 923 int (*get_et_sset_count)(struct ieee80211_hw *, struct ieee80211_vif *, int); 924 void (*get_et_stats)(struct ieee80211_hw *, struct ieee80211_vif *, struct ethtool_stats *, u64 *); 925 void (*get_et_strings)(struct ieee80211_hw *, struct ieee80211_vif *, u32, u8 *); 926 927 void (*update_vif_offload)(struct ieee80211_hw *, struct ieee80211_vif *); 928 929 int (*get_txpower)(struct ieee80211_hw *, struct ieee80211_vif *, int *); 930 int (*get_stats)(struct ieee80211_hw *, struct ieee80211_low_level_stats *); 931 932 int (*set_radar_background)(struct ieee80211_hw *, struct cfg80211_chan_def *); 933 934 void (*add_twt_setup)(struct ieee80211_hw *, struct ieee80211_sta *, struct ieee80211_twt_setup *); 935 void (*twt_teardown_request)(struct ieee80211_hw *, struct ieee80211_sta *, u8); 936 }; 937 938 939 /* -------------------------------------------------------------------------- */ 940 941 /* linux_80211.c */ 942 extern const struct cfg80211_ops linuxkpi_mac80211cfgops; 943 944 struct ieee80211_hw *linuxkpi_ieee80211_alloc_hw(size_t, 945 const struct ieee80211_ops *); 946 void linuxkpi_ieee80211_iffree(struct ieee80211_hw *); 947 void linuxkpi_set_ieee80211_dev(struct ieee80211_hw *, char *); 948 int linuxkpi_ieee80211_ifattach(struct ieee80211_hw *); 949 void linuxkpi_ieee80211_ifdetach(struct ieee80211_hw *); 950 struct ieee80211_hw * linuxkpi_wiphy_to_ieee80211_hw(struct wiphy *); 951 void linuxkpi_ieee80211_iterate_interfaces( 952 struct ieee80211_hw *hw, enum ieee80211_iface_iter flags, 953 void(*iterfunc)(void *, uint8_t *, struct ieee80211_vif *), 954 void *); 955 void linuxkpi_ieee80211_iterate_keys(struct ieee80211_hw *, 956 struct ieee80211_vif *, 957 void(*iterfunc)(struct ieee80211_hw *, struct ieee80211_vif *, 958 struct ieee80211_sta *, struct ieee80211_key_conf *, void *), 959 void *); 960 void linuxkpi_ieee80211_iterate_chan_contexts(struct ieee80211_hw *, 961 void(*iterfunc)(struct ieee80211_hw *, 962 struct ieee80211_chanctx_conf *, void *), 963 void *); 964 void linuxkpi_ieee80211_iterate_stations_atomic(struct ieee80211_hw *, 965 void (*iterfunc)(void *, struct ieee80211_sta *), void *); 966 void linuxkpi_ieee80211_scan_completed(struct ieee80211_hw *, 967 struct cfg80211_scan_info *); 968 void linuxkpi_ieee80211_rx(struct ieee80211_hw *, struct sk_buff *, 969 struct ieee80211_sta *, struct napi_struct *); 970 uint8_t linuxkpi_ieee80211_get_tid(struct ieee80211_hdr *); 971 struct ieee80211_sta *linuxkpi_ieee80211_find_sta(struct ieee80211_vif *, 972 const u8 *); 973 struct ieee80211_sta *linuxkpi_ieee80211_find_sta_by_ifaddr( 974 struct ieee80211_hw *, const uint8_t *, const uint8_t *); 975 struct sk_buff *linuxkpi_ieee80211_tx_dequeue(struct ieee80211_hw *, 976 struct ieee80211_txq *); 977 bool linuxkpi_ieee80211_is_ie_id_in_ie_buf(const u8, const u8 *, size_t); 978 bool linuxkpi_ieee80211_ie_advance(size_t *, const u8 *, size_t); 979 void linuxkpi_ieee80211_free_txskb(struct ieee80211_hw *, struct sk_buff *, 980 int); 981 void linuxkpi_ieee80211_queue_delayed_work(struct ieee80211_hw *, 982 struct delayed_work *, int); 983 void linuxkpi_ieee80211_queue_work(struct ieee80211_hw *, struct work_struct *); 984 struct sk_buff *linuxkpi_ieee80211_pspoll_get(struct ieee80211_hw *, 985 struct ieee80211_vif *); 986 struct sk_buff *linuxkpi_ieee80211_nullfunc_get(struct ieee80211_hw *, 987 struct ieee80211_vif *, bool); 988 void linuxkpi_ieee80211_txq_get_depth(struct ieee80211_txq *, unsigned long *, 989 unsigned long *); 990 struct wireless_dev *linuxkpi_ieee80211_vif_to_wdev(struct ieee80211_vif *); 991 void linuxkpi_ieee80211_connection_loss(struct ieee80211_vif *); 992 void linuxkpi_ieee80211_beacon_loss(struct ieee80211_vif *); 993 struct sk_buff *linuxkpi_ieee80211_probereq_get(struct ieee80211_hw *, 994 uint8_t *, uint8_t *, size_t, size_t); 995 void linuxkpi_ieee80211_tx_status(struct ieee80211_hw *, struct sk_buff *); 996 997 /* -------------------------------------------------------------------------- */ 998 999 static __inline void 1000 _ieee80211_hw_set(struct ieee80211_hw *hw, enum ieee80211_hw_flags flag) 1001 { 1002 1003 set_bit(flag, hw->flags); 1004 } 1005 1006 static __inline bool 1007 __ieee80211_hw_check(struct ieee80211_hw *hw, enum ieee80211_hw_flags flag) 1008 { 1009 1010 return (test_bit(flag, hw->flags)); 1011 } 1012 1013 /* They pass in shortened flag names; how confusingly inconsistent. */ 1014 #define ieee80211_hw_set(_hw, _flag) \ 1015 _ieee80211_hw_set(_hw, IEEE80211_HW_ ## _flag) 1016 #define ieee80211_hw_check(_hw, _flag) \ 1017 __ieee80211_hw_check(_hw, IEEE80211_HW_ ## _flag) 1018 1019 /* XXX-BZ add CTASSERTS that size of struct is <= sizeof skb->cb. */ 1020 CTASSERT(sizeof(struct ieee80211_tx_info) <= sizeof(((struct sk_buff *)0)->cb)); 1021 #define IEEE80211_SKB_CB(_skb) \ 1022 ((struct ieee80211_tx_info *)((_skb)->cb)) 1023 1024 CTASSERT(sizeof(struct ieee80211_rx_status) <= sizeof(((struct sk_buff *)0)->cb)); 1025 #define IEEE80211_SKB_RXCB(_skb) \ 1026 ((struct ieee80211_rx_status *)((_skb)->cb)) 1027 1028 static __inline void 1029 ieee80211_free_hw(struct ieee80211_hw *hw) 1030 { 1031 1032 linuxkpi_ieee80211_iffree(hw); 1033 1034 if (hw->wiphy != NULL) 1035 wiphy_free(hw->wiphy); 1036 /* Note that *hw is not valid any longer after this. */ 1037 1038 IMPROVE(); 1039 } 1040 1041 static __inline struct ieee80211_hw * 1042 ieee80211_alloc_hw(size_t priv_len, const struct ieee80211_ops *ops) 1043 { 1044 1045 return (linuxkpi_ieee80211_alloc_hw(priv_len, ops)); 1046 } 1047 1048 static __inline void 1049 SET_IEEE80211_DEV(struct ieee80211_hw *hw, struct device *dev) 1050 { 1051 1052 set_wiphy_dev(hw->wiphy, dev); 1053 linuxkpi_set_ieee80211_dev(hw, dev_name(dev)); 1054 1055 IMPROVE(); 1056 } 1057 1058 static __inline int 1059 ieee80211_register_hw(struct ieee80211_hw *hw) 1060 { 1061 int error; 1062 1063 error = wiphy_register(hw->wiphy); 1064 if (error != 0) 1065 return (error); 1066 1067 /* 1068 * At this point the driver has set all the options, flags, bands, 1069 * ciphers, hw address(es), ... basically mac80211/cfg80211 hw/wiphy 1070 * setup is done. 1071 * We need to replicate a lot of information from here into net80211. 1072 */ 1073 error = linuxkpi_ieee80211_ifattach(hw); 1074 1075 IMPROVE(); 1076 1077 return (error); 1078 } 1079 1080 static __inline void 1081 ieee80211_unregister_hw(struct ieee80211_hw *hw) 1082 { 1083 1084 wiphy_unregister(hw->wiphy); 1085 linuxkpi_ieee80211_ifdetach(hw); 1086 1087 IMPROVE(); 1088 } 1089 1090 static __inline struct ieee80211_hw * 1091 wiphy_to_ieee80211_hw(struct wiphy *wiphy) 1092 { 1093 1094 return (linuxkpi_wiphy_to_ieee80211_hw(wiphy)); 1095 } 1096 1097 /* -------------------------------------------------------------------------- */ 1098 1099 static __inline bool 1100 ieee80211_is_action(__le16 fc) 1101 { 1102 __le16 v; 1103 1104 fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); 1105 v = htole16(IEEE80211_FC0_SUBTYPE_ACTION | IEEE80211_FC0_TYPE_MGT); 1106 1107 return (fc == v); 1108 } 1109 1110 static __inline bool 1111 ieee80211_is_probe_resp(__le16 fc) 1112 { 1113 __le16 v; 1114 1115 fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); 1116 v = htole16(IEEE80211_FC0_SUBTYPE_PROBE_RESP | IEEE80211_FC0_TYPE_MGT); 1117 1118 return (fc == v); 1119 } 1120 1121 static __inline bool 1122 ieee80211_is_auth(__le16 fc) 1123 { 1124 __le16 v; 1125 1126 fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); 1127 v = htole16(IEEE80211_FC0_SUBTYPE_AUTH | IEEE80211_FC0_TYPE_MGT); 1128 1129 return (fc == v); 1130 } 1131 1132 static __inline bool 1133 ieee80211_is_assoc_req(__le16 fc) 1134 { 1135 __le16 v; 1136 1137 fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); 1138 v = htole16(IEEE80211_FC0_SUBTYPE_ASSOC_REQ | IEEE80211_FC0_TYPE_MGT); 1139 1140 return (fc == v); 1141 } 1142 1143 static __inline bool 1144 ieee80211_is_assoc_resp(__le16 fc) 1145 { 1146 __le16 v; 1147 1148 fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); 1149 v = htole16(IEEE80211_FC0_SUBTYPE_ASSOC_RESP | IEEE80211_FC0_TYPE_MGT); 1150 1151 return (fc == v); 1152 } 1153 1154 static __inline bool 1155 ieee80211_is_reassoc_req(__le16 fc) 1156 { 1157 __le16 v; 1158 1159 fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); 1160 v = htole16(IEEE80211_FC0_SUBTYPE_REASSOC_REQ | IEEE80211_FC0_TYPE_MGT); 1161 1162 return (fc == v); 1163 } 1164 1165 static __inline bool 1166 ieee80211_is_reassoc_resp(__le16 fc) 1167 { 1168 __le16 v; 1169 1170 fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); 1171 v = htole16(IEEE80211_FC0_SUBTYPE_REASSOC_RESP | IEEE80211_FC0_TYPE_MGT); 1172 1173 return (fc == v); 1174 } 1175 1176 static __inline bool 1177 ieee80211_is_disassoc(__le16 fc) 1178 { 1179 __le16 v; 1180 1181 fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); 1182 v = htole16(IEEE80211_FC0_SUBTYPE_DISASSOC | IEEE80211_FC0_TYPE_MGT); 1183 1184 return (fc == v); 1185 } 1186 1187 static __inline bool 1188 ieee80211_is_data_present(__le16 fc) 1189 { 1190 __le16 v; 1191 1192 /* If it is a data frame and NODATA is not present. */ 1193 fc &= htole16(IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_NODATA); 1194 v = htole16(IEEE80211_FC0_TYPE_DATA); 1195 1196 return (fc == v); 1197 } 1198 1199 static __inline bool 1200 ieee80211_is_deauth(__le16 fc) 1201 { 1202 __le16 v; 1203 1204 fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); 1205 v = htole16(IEEE80211_FC0_SUBTYPE_DEAUTH | IEEE80211_FC0_TYPE_MGT); 1206 1207 return (fc == v); 1208 } 1209 1210 static __inline bool 1211 ieee80211_is_beacon(__le16 fc) 1212 { 1213 __le16 v; 1214 1215 /* 1216 * For as much as I get it this comes in LE and unlike FreeBSD 1217 * where we get the entire frame header and u8[], here we get the 1218 * 9.2.4.1 Frame Control field only. Mask and compare. 1219 */ 1220 fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); 1221 v = htole16(IEEE80211_FC0_SUBTYPE_BEACON | IEEE80211_FC0_TYPE_MGT); 1222 1223 return (fc == v); 1224 } 1225 1226 1227 static __inline bool 1228 ieee80211_is_probe_req(__le16 fc) 1229 { 1230 __le16 v; 1231 1232 fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); 1233 v = htole16(IEEE80211_FC0_SUBTYPE_PROBE_REQ | IEEE80211_FC0_TYPE_MGT); 1234 1235 return (fc == v); 1236 } 1237 1238 static __inline bool 1239 ieee80211_has_protected(__le16 fc) 1240 { 1241 1242 return (fc & htole16(IEEE80211_FC1_PROTECTED << 8)); 1243 } 1244 1245 static __inline bool 1246 ieee80211_is_back_req(__le16 fc) 1247 { 1248 __le16 v; 1249 1250 fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); 1251 v = htole16(IEEE80211_FC0_SUBTYPE_BAR | IEEE80211_FC0_TYPE_CTL); 1252 1253 return (fc == v); 1254 } 1255 1256 static __inline bool 1257 ieee80211_is_bufferable_mmpdu(__le16 fc) 1258 { 1259 1260 /* 11.2.2 Bufferable MMPDUs, 80211-2020. */ 1261 /* XXX we do not care about IBSS yet. */ 1262 1263 if (!ieee80211_is_mgmt(fc)) 1264 return (false); 1265 if (ieee80211_is_action(fc)) /* XXX FTM? */ 1266 return (true); 1267 if (ieee80211_is_disassoc(fc)) 1268 return (true); 1269 if (ieee80211_is_deauth(fc)) 1270 return (true); 1271 1272 return (false); 1273 } 1274 1275 static __inline bool 1276 ieee80211_is_nullfunc(__le16 fc) 1277 { 1278 __le16 v; 1279 1280 fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); 1281 v = htole16(IEEE80211_FC0_SUBTYPE_NODATA | IEEE80211_FC0_TYPE_DATA); 1282 1283 return (fc == v); 1284 } 1285 1286 static __inline bool 1287 ieee80211_is_qos_nullfunc(__le16 fc) 1288 { 1289 __le16 v; 1290 1291 fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK); 1292 v = htole16(IEEE80211_FC0_SUBTYPE_QOS_NULL | IEEE80211_FC0_TYPE_DATA); 1293 1294 return (fc == v); 1295 } 1296 1297 static __inline bool 1298 ieee80211_is_any_nullfunc(__le16 fc) 1299 { 1300 1301 return (ieee80211_is_nullfunc(fc) || ieee80211_is_qos_nullfunc(fc)); 1302 } 1303 1304 static __inline bool 1305 ieee80211_vif_is_mesh(struct ieee80211_vif *vif) 1306 { 1307 TODO(); 1308 return (false); 1309 } 1310 1311 static __inline bool 1312 ieee80211_is_frag(struct ieee80211_hdr *hdr) 1313 { 1314 TODO(); 1315 return (false); 1316 } 1317 1318 static __inline bool 1319 ieee80211_is_first_frag(__le16 fc) 1320 { 1321 TODO(); 1322 return (false); 1323 } 1324 1325 static __inline bool 1326 ieee80211_is_pspoll(__le16 fc) 1327 { 1328 TODO(); 1329 return (false); 1330 } 1331 1332 static __inline bool 1333 ieee80211_is_robust_mgmt_frame(struct sk_buff *skb) 1334 { 1335 TODO(); 1336 return (false); 1337 } 1338 1339 static __inline bool 1340 ieee80211_has_pm(__le16 fc) 1341 { 1342 TODO(); 1343 return (false); 1344 } 1345 1346 static __inline bool 1347 ieee80211_has_a4(__le16 fc) 1348 { 1349 __le16 v; 1350 1351 fc &= htole16((IEEE80211_FC1_DIR_TODS | IEEE80211_FC1_DIR_FROMDS) << 8); 1352 v = htole16((IEEE80211_FC1_DIR_TODS | IEEE80211_FC1_DIR_FROMDS) << 8); 1353 1354 return (fc == v); 1355 } 1356 1357 static __inline bool 1358 ieee80211_has_order(__le16 fc) 1359 { 1360 1361 return (fc & htole16(IEEE80211_FC1_ORDER << 8)); 1362 } 1363 1364 static __inline bool 1365 ieee80211_has_retry(__le16 fc) 1366 { 1367 1368 return (fc & htole16(IEEE80211_FC1_RETRY << 8)); 1369 } 1370 1371 1372 static __inline bool 1373 ieee80211_has_fromds(__le16 fc) 1374 { 1375 1376 return (fc & htole16(IEEE80211_FC1_DIR_FROMDS << 8)); 1377 } 1378 1379 static __inline bool 1380 ieee80211_has_tods(__le16 fc) 1381 { 1382 1383 return (fc & htole16(IEEE80211_FC1_DIR_TODS << 8)); 1384 } 1385 1386 static __inline uint8_t * 1387 ieee80211_get_SA(struct ieee80211_hdr *hdr) 1388 { 1389 1390 if (ieee80211_has_a4(hdr->frame_control)) 1391 return (hdr->addr4); 1392 if (ieee80211_has_fromds(hdr->frame_control)) 1393 return (hdr->addr3); 1394 return (hdr->addr2); 1395 } 1396 1397 static __inline uint8_t * 1398 ieee80211_get_DA(struct ieee80211_hdr *hdr) 1399 { 1400 1401 if (ieee80211_has_tods(hdr->frame_control)) 1402 return (hdr->addr3); 1403 return (hdr->addr1); 1404 } 1405 1406 static __inline bool 1407 ieee80211_has_morefrags(__le16 fc) 1408 { 1409 1410 fc &= htole16(IEEE80211_FC1_MORE_FRAG << 8); 1411 return (fc != 0); 1412 } 1413 1414 static __inline u8 * 1415 ieee80211_get_qos_ctl(struct ieee80211_hdr *hdr) 1416 { 1417 if (ieee80211_has_a4(hdr->frame_control)) 1418 return (u8 *)hdr + 30; 1419 else 1420 return (u8 *)hdr + 24; 1421 } 1422 1423 /* -------------------------------------------------------------------------- */ 1424 /* Receive functions (air/driver to mac80211/net80211). */ 1425 1426 1427 static __inline void 1428 ieee80211_rx_napi(struct ieee80211_hw *hw, struct ieee80211_sta *sta, 1429 struct sk_buff *skb, struct napi_struct *napi) 1430 { 1431 1432 linuxkpi_ieee80211_rx(hw, skb, sta, napi); 1433 } 1434 1435 static __inline void 1436 ieee80211_rx_ni(struct ieee80211_hw *hw, struct sk_buff *skb) 1437 { 1438 1439 linuxkpi_ieee80211_rx(hw, skb, NULL, NULL); 1440 } 1441 1442 static __inline void 1443 ieee80211_rx_irqsafe(struct ieee80211_hw *hw, struct sk_buff *skb) 1444 { 1445 1446 linuxkpi_ieee80211_rx(hw, skb, NULL, NULL); 1447 } 1448 1449 /* -------------------------------------------------------------------------- */ 1450 1451 static __inline uint8_t 1452 ieee80211_get_tid(struct ieee80211_hdr *hdr) 1453 { 1454 1455 return (linuxkpi_ieee80211_get_tid(hdr)); 1456 } 1457 1458 static __inline struct sk_buff * 1459 ieee80211_beacon_get_tim(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 1460 uint16_t *tim_offset, uint16_t *tim_len) 1461 { 1462 1463 if (tim_offset != NULL) 1464 *tim_offset = 0; 1465 if (tim_len != NULL) 1466 *tim_len = 0; 1467 TODO(); 1468 return (NULL); 1469 } 1470 1471 static __inline void 1472 ieee80211_iterate_active_interfaces_atomic(struct ieee80211_hw *hw, 1473 enum ieee80211_iface_iter flags, 1474 void(*iterfunc)(void *, uint8_t *, struct ieee80211_vif *), 1475 void *arg) 1476 { 1477 1478 flags |= IEEE80211_IFACE_ITER__ATOMIC; 1479 flags |= IEEE80211_IFACE_ITER__ACTIVE; 1480 linuxkpi_ieee80211_iterate_interfaces(hw, flags, iterfunc, arg); 1481 } 1482 1483 static __inline void 1484 ieee80211_iterate_active_interfaces(struct ieee80211_hw *hw, 1485 enum ieee80211_iface_iter flags, 1486 void(*iterfunc)(void *, uint8_t *, struct ieee80211_vif *), 1487 void *arg) 1488 { 1489 1490 flags |= IEEE80211_IFACE_ITER__ACTIVE; 1491 linuxkpi_ieee80211_iterate_interfaces(hw, flags, iterfunc, arg); 1492 } 1493 1494 static __inline void 1495 ieee80211_iterate_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 linuxkpi_ieee80211_iterate_interfaces(hw, flags, iterfunc, arg); 1502 } 1503 1504 static __inline void 1505 ieee80211_iter_keys(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 1506 void(*iterfunc)(struct ieee80211_hw *, struct ieee80211_vif *, 1507 struct ieee80211_sta *, struct ieee80211_key_conf *, void *), 1508 void *arg) 1509 { 1510 1511 linuxkpi_ieee80211_iterate_keys(hw, vif, iterfunc, arg); 1512 } 1513 1514 static __inline void 1515 ieee80211_iter_keys_rcu(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 1516 void(*iterfunc)(struct ieee80211_hw *, struct ieee80211_vif *, 1517 struct ieee80211_sta *, struct ieee80211_key_conf *, void *), 1518 void *arg) 1519 { 1520 1521 IMPROVE(); /* "rcu" */ 1522 linuxkpi_ieee80211_iterate_keys(hw, vif, iterfunc, arg); 1523 } 1524 1525 static __inline void 1526 ieee80211_iter_chan_contexts_atomic(struct ieee80211_hw *hw, 1527 void(*iterfunc)(struct ieee80211_hw *, struct ieee80211_chanctx_conf *, void *), 1528 void *arg) 1529 { 1530 1531 linuxkpi_ieee80211_iterate_chan_contexts(hw, iterfunc, arg); 1532 } 1533 1534 static __inline void 1535 ieee80211_iterate_stations_atomic(struct ieee80211_hw *hw, 1536 void (*iterfunc)(void *, struct ieee80211_sta *), void *arg) 1537 { 1538 1539 linuxkpi_ieee80211_iterate_stations_atomic(hw, iterfunc, arg); 1540 } 1541 1542 static __inline struct wireless_dev * 1543 ieee80211_vif_to_wdev(struct ieee80211_vif *vif) 1544 { 1545 1546 return (linuxkpi_ieee80211_vif_to_wdev(vif)); 1547 } 1548 1549 static __inline struct sk_buff * 1550 ieee80211_beacon_get_template(struct ieee80211_hw *hw, 1551 struct ieee80211_vif *vif, struct ieee80211_mutable_offsets *offs, 1552 int x) 1553 { 1554 TODO(); 1555 return (NULL); 1556 } 1557 1558 static __inline void 1559 ieee80211_beacon_loss(struct ieee80211_vif *vif) 1560 { 1561 linuxkpi_ieee80211_beacon_loss(vif); 1562 } 1563 1564 static __inline void 1565 ieee80211_chswitch_done(struct ieee80211_vif *vif, bool t) 1566 { 1567 TODO(); 1568 } 1569 1570 static __inline bool 1571 ieee80211_csa_is_complete(struct ieee80211_vif *vif) 1572 { 1573 TODO(); 1574 return (false); 1575 } 1576 1577 static __inline void 1578 ieee80211_csa_set_counter(struct ieee80211_vif *vif, uint8_t counter) 1579 { 1580 TODO(); 1581 } 1582 1583 static __inline int 1584 ieee80211_csa_update_counter(struct ieee80211_vif *vif) 1585 { 1586 TODO(); 1587 return (-1); 1588 } 1589 1590 static __inline void 1591 ieee80211_csa_finish(struct ieee80211_vif *vif) 1592 { 1593 TODO(); 1594 } 1595 1596 static __inline enum nl80211_iftype 1597 ieee80211_vif_type_p2p(struct ieee80211_vif *vif) 1598 { 1599 1600 /* If we are not p2p enabled, just return the type. */ 1601 if (!vif->p2p) 1602 return (vif->type); 1603 1604 /* If we are p2p, depending on side, return type. */ 1605 switch (vif->type) { 1606 case NL80211_IFTYPE_AP: 1607 return (NL80211_IFTYPE_P2P_GO); 1608 case NL80211_IFTYPE_STATION: 1609 return (NL80211_IFTYPE_P2P_CLIENT); 1610 default: 1611 fallthrough; 1612 } 1613 return (vif->type); 1614 } 1615 1616 static __inline unsigned long 1617 ieee80211_tu_to_usec(unsigned long tu) 1618 { 1619 1620 return (tu * IEEE80211_DUR_TU); 1621 } 1622 1623 1624 static __inline int 1625 ieee80211_action_contains_tpc(struct sk_buff *skb) 1626 { 1627 TODO(); 1628 return (0); 1629 } 1630 1631 static __inline void 1632 ieee80211_connection_loss(struct ieee80211_vif *vif) 1633 { 1634 1635 linuxkpi_ieee80211_connection_loss(vif); 1636 } 1637 1638 static __inline struct ieee80211_sta * 1639 ieee80211_find_sta(struct ieee80211_vif *vif, const u8 *peer) 1640 { 1641 1642 return (linuxkpi_ieee80211_find_sta(vif, peer)); 1643 } 1644 1645 static __inline struct ieee80211_sta * 1646 ieee80211_find_sta_by_ifaddr(struct ieee80211_hw *hw, const uint8_t *addr, 1647 const uint8_t *ourvifaddr) 1648 { 1649 1650 return (linuxkpi_ieee80211_find_sta_by_ifaddr(hw, addr, ourvifaddr)); 1651 } 1652 1653 1654 static __inline void 1655 ieee80211_get_tkip_p2k(struct ieee80211_key_conf *keyconf, 1656 struct sk_buff *skb_frag, u8 *key) 1657 { 1658 TODO(); 1659 } 1660 1661 static __inline void 1662 ieee80211_get_tkip_rx_p1k(struct ieee80211_key_conf *keyconf, 1663 const u8 *addr, uint32_t iv32, u16 *p1k) 1664 { 1665 TODO(); 1666 } 1667 1668 static __inline size_t 1669 ieee80211_ie_split(const u8 *ies, size_t ies_len, 1670 const u8 *ie_ids, size_t ie_ids_len, size_t start) 1671 { 1672 size_t x; 1673 1674 x = start; 1675 1676 /* XXX FIXME, we need to deal with "Element ID Extension" */ 1677 while (x < ies_len) { 1678 1679 /* Is this IE[s] one of the ie_ids? */ 1680 if (!linuxkpi_ieee80211_is_ie_id_in_ie_buf(ies[x], 1681 ie_ids, ie_ids_len)) 1682 break; 1683 1684 if (!linuxkpi_ieee80211_ie_advance(&x, ies, ies_len)) 1685 break; 1686 } 1687 1688 return (x); 1689 } 1690 1691 static __inline void 1692 ieee80211_request_smps(struct ieee80211_vif *vif, enum ieee80211_smps_mode smps) 1693 { 1694 static const char *smps_mode_name[] = { 1695 "SMPS_OFF", 1696 "SMPS_STATIC", 1697 "SMPS_DYNAMIC", 1698 "SMPS_AUTOMATIC", 1699 "SMPS_NUM_MODES" 1700 }; 1701 1702 if (linuxkpi_debug_80211 & D80211_TODO) 1703 printf("%s:%d: XXX LKPI80211 TODO smps %d %s\n", 1704 __func__, __LINE__, smps, smps_mode_name[smps]); 1705 } 1706 1707 static __inline void 1708 ieee80211_tdls_oper_request(struct ieee80211_vif *vif, uint8_t *addr, 1709 enum nl80211_tdls_operation oper, enum ieee80211_reason_code code, 1710 gfp_t gfp) 1711 { 1712 TODO(); 1713 } 1714 1715 static __inline void 1716 ieee80211_stop_queues(struct ieee80211_hw *hw) 1717 { 1718 TODO(); 1719 } 1720 1721 static __inline void 1722 ieee80211_wake_queues(struct ieee80211_hw *hw) 1723 { 1724 TODO(); 1725 } 1726 1727 static __inline void 1728 wiphy_rfkill_set_hw_state(struct wiphy *wiphy, bool state) 1729 { 1730 TODO(); 1731 } 1732 1733 static __inline void 1734 ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb) 1735 { 1736 IMPROVE(); 1737 1738 /* 1739 * This is called on transmit failure. 1740 * Use a not-so-random random high status error so we can distinguish 1741 * it from normal low values flying around in net80211 ("ETX"). 1742 */ 1743 linuxkpi_ieee80211_free_txskb(hw, skb, 0x455458); 1744 } 1745 1746 static __inline void 1747 ieee80211_restart_hw(struct ieee80211_hw *hw) 1748 { 1749 TODO(); 1750 } 1751 1752 static __inline void 1753 ieee80211_ready_on_channel(struct ieee80211_hw *hw) 1754 { 1755 TODO(); 1756 /* XXX-BZ We need to see that. */ 1757 } 1758 1759 static __inline void 1760 ieee80211_remain_on_channel_expired(struct ieee80211_hw *hw) 1761 { 1762 TODO(); 1763 } 1764 1765 static __inline void 1766 ieee80211_cqm_rssi_notify(struct ieee80211_vif *vif, 1767 enum nl80211_cqm_rssi_threshold_event crte, int sig, gfp_t gfp) 1768 { 1769 TODO(); 1770 } 1771 1772 static __inline void 1773 ieee80211_mark_rx_ba_filtered_frames(struct ieee80211_sta *sta, uint8_t tid, 1774 uint32_t ssn, uint64_t bitmap, uint16_t received_mpdu) 1775 { 1776 TODO(); 1777 } 1778 1779 static __inline bool 1780 ieee80211_sn_less(uint16_t sn1, uint16_t sn2) 1781 { 1782 TODO(); 1783 return (false); 1784 } 1785 1786 static __inline uint16_t 1787 ieee80211_sn_inc(uint16_t sn) 1788 { 1789 TODO(); 1790 return (sn + 1); 1791 } 1792 1793 static __inline uint16_t 1794 ieee80211_sn_add(uint16_t sn, uint16_t a) 1795 { 1796 TODO(); 1797 return (sn + a); 1798 } 1799 1800 static __inline void 1801 ieee80211_stop_rx_ba_session(struct ieee80211_vif *vif, uint32_t x, uint8_t *addr) 1802 { 1803 TODO(); 1804 } 1805 1806 static __inline void 1807 ieee80211_rate_set_vht(struct ieee80211_tx_rate *r, uint32_t f1, uint32_t f2) 1808 { 1809 TODO(); 1810 } 1811 1812 static __inline void 1813 ieee80211_reserve_tid(struct ieee80211_sta *sta, uint8_t tid) 1814 { 1815 TODO(); 1816 } 1817 1818 static __inline void 1819 ieee80211_unreserve_tid(struct ieee80211_sta *sta, uint8_t tid) 1820 { 1821 TODO(); 1822 } 1823 1824 static __inline void 1825 ieee80211_rx_ba_timer_expired(struct ieee80211_vif *vif, uint8_t *addr, 1826 uint8_t tid) 1827 { 1828 TODO(); 1829 } 1830 1831 static __inline void 1832 ieee80211_send_eosp_nullfunc(struct ieee80211_sta *sta, uint8_t tid) 1833 { 1834 TODO(); 1835 } 1836 1837 static __inline uint16_t 1838 ieee80211_sn_sub(uint16_t sa, uint16_t sb) 1839 { 1840 1841 return ((sa - sb) & 1842 (IEEE80211_SEQ_SEQ_MASK >> IEEE80211_SEQ_SEQ_SHIFT)); 1843 } 1844 1845 static __inline void 1846 ieee80211_sta_block_awake(struct ieee80211_hw *hw, struct ieee80211_sta *sta, 1847 bool disable) 1848 { 1849 TODO(); 1850 } 1851 1852 static __inline void 1853 ieee80211_sta_ps_transition(struct ieee80211_sta *sta, bool sleeping) 1854 { 1855 TODO(); 1856 } 1857 1858 static __inline void 1859 ieee80211_sta_pspoll(struct ieee80211_sta *sta) 1860 { 1861 TODO(); 1862 } 1863 1864 static __inline void 1865 ieee80211_sta_uapsd_trigger(struct ieee80211_sta *sta, int ntids) 1866 { 1867 TODO(); 1868 } 1869 1870 static __inline void 1871 ieee80211_start_tx_ba_cb_irqsafe(struct ieee80211_vif *vif, uint8_t *addr, 1872 uint8_t tid) 1873 { 1874 TODO(); 1875 } 1876 1877 static __inline void 1878 ieee80211_tkip_add_iv(u8 *crypto_hdr, struct ieee80211_key_conf *keyconf, 1879 uint64_t pn) 1880 { 1881 TODO(); 1882 } 1883 1884 static __inline struct sk_buff * 1885 ieee80211_tx_dequeue(struct ieee80211_hw *hw, struct ieee80211_txq *txq) 1886 { 1887 1888 return (linuxkpi_ieee80211_tx_dequeue(hw, txq)); 1889 } 1890 1891 static __inline void 1892 ieee80211_update_mu_groups(struct ieee80211_vif *vif, uint8_t *ms, uint8_t *up) 1893 { 1894 TODO(); 1895 } 1896 1897 static __inline void 1898 ieee80211_sta_set_buffered(struct ieee80211_sta *sta, uint8_t tid, bool t) 1899 { 1900 TODO(); 1901 } 1902 1903 static __inline void 1904 ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb) 1905 { 1906 1907 linuxkpi_ieee80211_tx_status(hw, skb); 1908 } 1909 1910 static __inline void 1911 ieee80211_get_key_rx_seq(struct ieee80211_key_conf *keyconf, uint8_t tid, 1912 struct ieee80211_key_seq *seq) 1913 { 1914 TODO(); 1915 } 1916 1917 static __inline void 1918 ieee80211_sched_scan_results(struct ieee80211_hw *hw) 1919 { 1920 TODO(); 1921 } 1922 1923 static __inline void 1924 ieee80211_sta_eosp(struct ieee80211_sta *sta) 1925 { 1926 TODO(); 1927 } 1928 1929 static __inline void 1930 ieee80211_stop_tx_ba_cb_irqsafe(struct ieee80211_vif *vif, uint8_t *addr, 1931 uint8_t tid) 1932 { 1933 TODO(); 1934 } 1935 1936 static __inline void 1937 ieee80211_sched_scan_stopped(struct ieee80211_hw *hw) 1938 { 1939 TODO(); 1940 } 1941 1942 static __inline void 1943 ieee80211_scan_completed(struct ieee80211_hw *hw, 1944 struct cfg80211_scan_info *info) 1945 { 1946 1947 linuxkpi_ieee80211_scan_completed(hw, info); 1948 } 1949 1950 static __inline struct sk_buff * 1951 ieee80211_beacon_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif) 1952 { 1953 TODO(); 1954 return (NULL); 1955 } 1956 1957 static __inline struct sk_buff * 1958 ieee80211_pspoll_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif) 1959 { 1960 1961 /* Only STA needs this. Otherwise return NULL and panic bad drivers. */ 1962 if (vif->type != NL80211_IFTYPE_STATION) 1963 return (NULL); 1964 1965 return (linuxkpi_ieee80211_pspoll_get(hw, vif)); 1966 } 1967 1968 static __inline struct sk_buff * 1969 ieee80211_proberesp_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif) 1970 { 1971 TODO(); 1972 return (NULL); 1973 } 1974 1975 static __inline struct sk_buff * 1976 ieee80211_nullfunc_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 1977 bool qos) 1978 { 1979 1980 /* Only STA needs this. Otherwise return NULL and panic bad drivers. */ 1981 if (vif->type != NL80211_IFTYPE_STATION) 1982 return (NULL); 1983 1984 return (linuxkpi_ieee80211_nullfunc_get(hw, vif, qos)); 1985 } 1986 1987 static __inline struct sk_buff * 1988 ieee80211_probereq_get(struct ieee80211_hw *hw, uint8_t *addr, 1989 uint8_t *ssid, size_t ssid_len, size_t tailroom) 1990 { 1991 1992 return (linuxkpi_ieee80211_probereq_get(hw, addr, ssid, ssid_len, 1993 tailroom)); 1994 } 1995 1996 static __inline void 1997 ieee80211_queue_delayed_work(struct ieee80211_hw *hw, struct delayed_work *w, 1998 int delay) 1999 { 2000 2001 linuxkpi_ieee80211_queue_delayed_work(hw, w, delay); 2002 } 2003 2004 static __inline void 2005 ieee80211_queue_work(struct ieee80211_hw *hw, struct work_struct *w) 2006 { 2007 2008 linuxkpi_ieee80211_queue_work(hw, w); 2009 } 2010 2011 static __inline void 2012 ieee80211_stop_queue(struct ieee80211_hw *hw, uint16_t q) 2013 { 2014 TODO(); 2015 } 2016 2017 static __inline void 2018 ieee80211_wake_queue(struct ieee80211_hw *hw, uint16_t q) 2019 { 2020 TODO(); 2021 } 2022 2023 static __inline void 2024 ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw, struct sk_buff *skb) 2025 { 2026 IMPROVE(); 2027 ieee80211_tx_status(hw, skb); 2028 } 2029 2030 static __inline void 2031 ieee80211_tx_status_ni(struct ieee80211_hw *hw, struct sk_buff *skb) 2032 { 2033 IMPROVE(); 2034 ieee80211_tx_status(hw, skb); 2035 } 2036 2037 static __inline int 2038 ieee80211_start_tx_ba_session(struct ieee80211_sta *sta, uint8_t tid, int x) 2039 { 2040 TODO(); 2041 return (-EINVAL); 2042 } 2043 2044 static __inline void 2045 ieee80211_tx_info_clear_status(struct ieee80211_tx_info *info) 2046 { 2047 int i; 2048 2049 /* 2050 * Apparently clearing flags and some other fields is not right. 2051 * Given the function is called "status" we work on that part of 2052 * the union. 2053 */ 2054 for (i = 0; i < nitems(info->status.rates); i++) 2055 info->status.rates[i].count = 0; 2056 /* 2057 * Unclear if ack_signal should be included or not but we clear the 2058 * "valid" bool so this field is no longer valid. 2059 */ 2060 memset(&info->status.ack_signal, 0, sizeof(*info) - 2061 offsetof(struct ieee80211_tx_info, status.ack_signal)); 2062 } 2063 2064 static __inline void 2065 ieee80211_txq_get_depth(struct ieee80211_txq *txq, unsigned long *frame_cnt, 2066 unsigned long *byte_cnt) 2067 { 2068 2069 if (frame_cnt == NULL && byte_cnt == NULL) 2070 return; 2071 2072 linuxkpi_ieee80211_txq_get_depth(txq, frame_cnt, byte_cnt); 2073 } 2074 2075 static __inline int 2076 rate_lowest_index(struct ieee80211_supported_band *band, 2077 struct ieee80211_sta *sta) 2078 { 2079 IMPROVE(); 2080 return (0); 2081 } 2082 2083 2084 static __inline void 2085 SET_IEEE80211_PERM_ADDR (struct ieee80211_hw *hw, uint8_t *addr) 2086 { 2087 2088 ether_addr_copy(hw->wiphy->perm_addr, addr); 2089 } 2090 2091 static __inline uint8_t * 2092 ieee80211_bss_get_ie(struct cfg80211_bss *bss, uint32_t eid) 2093 { 2094 TODO(); 2095 return (NULL); 2096 } 2097 2098 static __inline void 2099 ieee80211_report_low_ack(struct ieee80211_sta *sta, int x) 2100 { 2101 TODO(); 2102 } 2103 2104 static __inline void 2105 ieee80211_start_rx_ba_session_offl(struct ieee80211_vif *vif, uint8_t *addr, 2106 uint8_t tid) 2107 { 2108 TODO(); 2109 } 2110 2111 static __inline void 2112 ieee80211_stop_rx_ba_session_offl(struct ieee80211_vif *vif, uint8_t *addr, 2113 uint8_t tid) 2114 { 2115 TODO(); 2116 } 2117 2118 static __inline struct sk_buff * 2119 ieee80211_tx_dequeue_ni(struct ieee80211_hw *hw, struct ieee80211_txq *txq) 2120 { 2121 TODO(); 2122 return (NULL); 2123 } 2124 2125 static __inline void 2126 ieee80211_tx_rate_update(struct ieee80211_hw *hw, struct ieee80211_sta *sta, 2127 struct ieee80211_tx_info *info) 2128 { 2129 TODO(); 2130 } 2131 2132 static __inline bool 2133 ieee80211_txq_may_transmit(struct ieee80211_hw *hw, struct ieee80211_txq *txq) 2134 { 2135 TODO(); 2136 return (false); 2137 } 2138 2139 static __inline struct ieee80211_txq * 2140 ieee80211_next_txq(struct ieee80211_hw *hw, uint32_t ac) 2141 { 2142 TODO(); 2143 return (NULL); 2144 } 2145 2146 static __inline void 2147 ieee80211_radar_detected(struct ieee80211_hw *hw) 2148 { 2149 TODO(); 2150 } 2151 2152 static __inline void 2153 ieee80211_sta_register_airtime(struct ieee80211_sta *sta, 2154 uint8_t tid, uint32_t duration, int x) 2155 { 2156 TODO(); 2157 } 2158 2159 2160 static __inline void 2161 ieee80211_return_txq(struct ieee80211_hw *hw, 2162 struct ieee80211_txq *txq, bool _t) 2163 { 2164 TODO(); 2165 } 2166 2167 static __inline void 2168 ieee80211_txq_schedule_end(struct ieee80211_hw *hw, uint32_t ac) 2169 { 2170 TODO(); 2171 } 2172 2173 static __inline void 2174 ieee80211_txq_schedule_start(struct ieee80211_hw *hw, uint32_t ac) 2175 { 2176 TODO(); 2177 } 2178 2179 static __inline void 2180 ieee80211_schedule_txq(struct ieee80211_hw *hw, struct ieee80211_txq *txq) 2181 { 2182 TODO(); 2183 } 2184 2185 static __inline void 2186 ieee80211_beacon_set_cntdwn(struct ieee80211_vif *vif, u8 counter) 2187 { 2188 TODO(); 2189 } 2190 2191 static __inline int 2192 ieee80211_beacon_update_cntdwn(struct ieee80211_vif *vif) 2193 { 2194 TODO(); 2195 return (-1); 2196 } 2197 2198 static __inline int 2199 ieee80211_get_vht_max_nss(struct ieee80211_vht_cap *vht_cap, uint32_t chanwidth, 2200 int x, bool t, int nss) 2201 { 2202 TODO(); 2203 return (-1); 2204 } 2205 2206 static __inline bool 2207 ieee80211_beacon_cntdwn_is_complete(struct ieee80211_vif *vif) 2208 { 2209 TODO(); 2210 return (true); 2211 } 2212 2213 static __inline void 2214 ieee80211_disconnect(struct ieee80211_vif *vif, bool _x) 2215 { 2216 TODO(); 2217 } 2218 2219 static __inline void 2220 ieee80211_channel_switch_disconnect(struct ieee80211_vif *vif, bool _x) 2221 { 2222 TODO(); 2223 } 2224 2225 static __inline const struct ieee80211_sta_he_cap * 2226 ieee80211_get_he_iftype_cap(const struct ieee80211_supported_band *band, 2227 enum nl80211_iftype type) 2228 { 2229 TODO(); 2230 return (NULL); 2231 } 2232 2233 static __inline void 2234 ieee80211_key_mic_failure(struct ieee80211_key_conf *key) 2235 { 2236 TODO(); 2237 } 2238 2239 static __inline void 2240 ieee80211_key_replay(struct ieee80211_key_conf *key) 2241 { 2242 TODO(); 2243 } 2244 2245 static __inline uint32_t 2246 ieee80211_calc_rx_airtime(struct ieee80211_hw *hw, 2247 struct ieee80211_rx_status *rxstat, int len) 2248 { 2249 TODO(); 2250 return (0); 2251 } 2252 2253 static __inline void 2254 ieee80211_get_tx_rates(struct ieee80211_vif *vif, struct ieee80211_sta *sta, 2255 struct sk_buff *skb, struct ieee80211_tx_rate *txrate, int nrates) 2256 { 2257 TODO(); 2258 } 2259 2260 static __inline void 2261 ieee80211_rx_list(struct ieee80211_hw *hw, struct ieee80211_sta *sta, 2262 struct sk_buff *skb, struct list_head *list) 2263 { 2264 TODO(); 2265 } 2266 2267 static __inline void 2268 ieee80211_tx_status_ext(struct ieee80211_hw *hw, 2269 struct ieee80211_tx_status *txstat) 2270 { 2271 TODO(); 2272 } 2273 2274 static __inline const struct element * 2275 ieee80211_bss_get_elem(struct cfg80211_bss *bss, uint32_t eid) 2276 { 2277 TODO(); 2278 return (NULL); 2279 } 2280 2281 static __inline void 2282 ieee80211_color_change_finish(struct ieee80211_vif *vif) 2283 { 2284 TODO(); 2285 } 2286 2287 static __inline struct sk_buff * 2288 ieee80211_get_fils_discovery_tmpl(struct ieee80211_hw *hw, 2289 struct ieee80211_vif *vif) 2290 { 2291 TODO(); 2292 return (NULL); 2293 } 2294 2295 static __inline struct sk_buff * 2296 ieee80211_get_unsol_bcast_probe_resp_tmpl(struct ieee80211_hw *hw, 2297 struct ieee80211_vif *vif) 2298 { 2299 TODO(); 2300 return (NULL); 2301 } 2302 2303 static __inline void 2304 linuxkpi_ieee80211_send_bar(struct ieee80211_vif *vif, uint8_t *ra, uint16_t tid, 2305 uint16_t ssn) 2306 { 2307 TODO(); 2308 } 2309 2310 #define ieee80211_send_bar(_v, _r, _t, _s) \ 2311 linuxkpi_ieee80211_send_bar(_v, _r, _t, _s) 2312 2313 #endif /* _LINUXKPI_NET_MAC80211_H */ 2314