2 * Copyright (c) 2020-2021 The FreeBSD Foundation
3 * Copyright (c) 2020-2022 Bjoern A. Zeeb
5 * This software was developed by Björn Zeeb under sponsorship from
6 * the FreeBSD Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
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.
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
32 #ifndef _LINUXKPI_NET_MAC80211_H
33 #define _LINUXKPI_NET_MAC80211_H
35 #include <sys/types.h>
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>
46 #define ARPHRD_IEEE80211_RADIOTAP __LINE__ /* XXX TODO brcmfmac */
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)
55 enum ieee80211_hw_conf_flags {
56 IEEE80211_CONF_IDLE = BIT(0),
57 IEEE80211_CONF_PS = BIT(1),
58 IEEE80211_CONF_MONITOR = BIT(2),
61 /* (*ops->config()) */
62 enum ieee80211_hw_conf_changed_flags {
63 IEEE80211_CONF_CHANGE_CHANNEL = BIT(0),
64 IEEE80211_CONF_CHANGE_IDLE = BIT(1),
65 IEEE80211_CONF_CHANGE_PS = BIT(2),
66 IEEE80211_CONF_CHANGE_MONITOR = BIT(3),
69 #define CFG80211_TESTMODE_CMD(_x) /* XXX TODO */
73 /* ops.configure_filter() */
74 enum mcast_filter_flags {
75 FIF_ALLMULTI = BIT(0),
76 FIF_PROBE_REQ = BIT(1),
77 FIF_BCN_PRBRESP_PROMISC = BIT(2),
79 FIF_OTHER_BSS = BIT(4),
84 enum ieee80211_bss_changed {
85 BSS_CHANGED_ARP_FILTER = BIT(0),
86 BSS_CHANGED_ASSOC = BIT(1),
87 BSS_CHANGED_BANDWIDTH = BIT(2),
88 BSS_CHANGED_BEACON = BIT(3),
89 BSS_CHANGED_BEACON_ENABLED = BIT(4),
90 BSS_CHANGED_BEACON_INFO = BIT(5),
91 BSS_CHANGED_BEACON_INT = BIT(6),
92 BSS_CHANGED_BSSID = BIT(7),
93 BSS_CHANGED_CQM = BIT(8),
94 BSS_CHANGED_ERP_CTS_PROT = BIT(9),
95 BSS_CHANGED_ERP_SLOT = BIT(10),
96 BSS_CHANGED_FTM_RESPONDER = BIT(11),
97 BSS_CHANGED_HT = BIT(12),
98 BSS_CHANGED_IDLE = BIT(13),
99 BSS_CHANGED_MU_GROUPS = BIT(14),
100 BSS_CHANGED_P2P_PS = BIT(15),
101 BSS_CHANGED_PS = BIT(16),
102 BSS_CHANGED_QOS = BIT(17),
103 BSS_CHANGED_TXPOWER = BIT(18),
104 BSS_CHANGED_HE_BSS_COLOR = BIT(19),
105 BSS_CHANGED_AP_PROBE_RESP = BIT(20),
106 BSS_CHANGED_BASIC_RATES = BIT(21),
107 BSS_CHANGED_ERP_PREAMBLE = BIT(22),
108 BSS_CHANGED_IBSS = BIT(23),
109 BSS_CHANGED_MCAST_RATE = BIT(24),
110 BSS_CHANGED_SSID = BIT(25),
113 /* 802.11 Figure 9-256 Suite selector format. [OUI(3), SUITE TYPE(1)] */
114 #define WLAN_CIPHER_SUITE_OUI(_oui, _x) (((_oui) << 8) | ((_x) & 0xff))
116 /* 802.11 Table 9-131 Cipher suite selectors. */
117 /* 802.1x suite B 11 */
118 #define WLAN_CIPHER_SUITE(_x) WLAN_CIPHER_SUITE_OUI(0x000fac, _x)
120 #define WLAN_CIPHER_SUITE_WEP40 WLAN_CIPHER_SUITE(1)
121 #define WLAN_CIPHER_SUITE_TKIP WLAN_CIPHER_SUITE(2)
123 #define WLAN_CIPHER_SUITE_CCMP WLAN_CIPHER_SUITE(4) /* CCMP-128 */
124 #define WLAN_CIPHER_SUITE_WEP104 WLAN_CIPHER_SUITE(5)
125 #define WLAN_CIPHER_SUITE_AES_CMAC WLAN_CIPHER_SUITE(6) /* BIP-CMAC-128 */
126 /* Group addressed traffic not allowed 7 */
127 #define WLAN_CIPHER_SUITE_GCMP WLAN_CIPHER_SUITE(8)
128 #define WLAN_CIPHER_SUITE_GCMP_256 WLAN_CIPHER_SUITE(9)
129 #define WLAN_CIPHER_SUITE_CCMP_256 WLAN_CIPHER_SUITE(10)
130 #define WLAN_CIPHER_SUITE_BIP_GMAC_128 WLAN_CIPHER_SUITE(11)
131 #define WLAN_CIPHER_SUITE_BIP_GMAC_256 WLAN_CIPHER_SUITE(12)
132 #define WLAN_CIPHER_SUITE_BIP_CMAC_256 WLAN_CIPHER_SUITE(13)
133 /* Reserved 14-255 */
136 /* 802.11 Table 9-133 AKM suite selectors. */
137 #define WLAN_AKM_SUITE(_x) WLAN_CIPHER_SUITE_OUI(0x000fac, _x)
139 #define WLAN_AKM_SUITE_8021X WLAN_AKM_SUITE(1)
140 #define WLAN_AKM_SUITE_PSK WLAN_AKM_SUITE(2)
141 #define WLAN_AKM_SUITE_FT_8021X WLAN_AKM_SUITE(3)
142 #define WLAN_AKM_SUITE_FT_PSK WLAN_AKM_SUITE(4)
143 #define WLAN_AKM_SUITE_8021X_SHA256 WLAN_AKM_SUITE(5)
144 #define WLAN_AKM_SUITE_PSK_SHA256 WLAN_AKM_SUITE(6)
146 #define WLAN_AKM_SUITE_SAE WLAN_AKM_SUITE(8)
149 /* 802.1x suite B 11 */
150 /* 802.1x suite B 384 12 */
151 /* FTo802.1x 384 13 */
152 /* Reserved 14-255 */
153 /* Apparently 11ax defines more. Seen (19,20) mentioned. */
156 struct ieee80211_sta;
158 struct ieee80211_ampdu_params {
160 struct ieee80211_sta *sta;
163 int action, amsdu, buf_size, timeout;
166 struct ieee80211_bar {
168 int control, start_seq_num;
170 uint16_t frame_control;
173 struct ieee80211_p2p_noa_desc {
174 uint32_t count; /* uint8_t ? */
180 struct ieee80211_p2p_noa_attr {
182 uint8_t oppps_ctwindow;
183 struct ieee80211_p2p_noa_desc desc[4];
186 struct ieee80211_mutable_offsets {
189 int cntdwn_counter_offs;
192 #define WLAN_MEMBERSHIP_LEN (8)
193 #define WLAN_USER_POSITION_LEN (16)
195 struct ieee80211_bss_conf {
197 uint8_t bssid[ETH_ALEN];
198 uint8_t transmitter_bssid[ETH_ALEN];
199 struct ieee80211_ftm_responder_params *ftmr_params;
200 struct ieee80211_p2p_noa_attr p2p_noa_attr;
201 struct cfg80211_chan_def chandef;
202 __be32 arp_addr_list[1]; /* XXX TODO */
203 struct ieee80211_rate *beacon_rate;
205 uint8_t membership[WLAN_MEMBERSHIP_LEN];
206 uint8_t position[WLAN_USER_POSITION_LEN];
212 uint8_t ssid[IEEE80211_NWID_LEN];
214 uint16_t ht_operation_mode;
224 bool use_short_preamble;
227 uint32_t sync_device_ts;
229 uint8_t sync_dtim_count;
231 int mcast_rate[NUM_NL80211_BANDS];
233 int ack_enabled, bssid_index, bssid_indicator, cqm_rssi_hyst, cqm_rssi_thold, ema_ap, frame_time_rts_th, ftm_responder;
234 int htc_trig_based_pkt_ext;
235 int multi_sta_back_32bit, nontransmitted;
236 int profile_periodicity;
237 int twt_requester, uora_exists, uora_ocw_range;
238 int assoc_capability, enable_beacon, hidden_ssid, ibss_joined, twt_protected;
239 int fils_discovery, he_obss_pd, he_oper, twt_responder, unsol_bcast_probe_resp_interval;
240 unsigned long basic_rates;
244 struct ieee80211_chanctx_conf {
246 int rx_chains_dynamic, rx_chains_static;
248 struct cfg80211_chan_def def;
249 struct cfg80211_chan_def min_def;
251 /* Must stay last. */
252 uint8_t drv_priv[0] __aligned(CACHE_LINE_SIZE);
255 struct ieee80211_channel_switch {
257 int block_tx, count, delay, device_timestamp, timestamp;
258 struct cfg80211_chan_def chandef;
261 struct ieee80211_cipher_scheme {
263 uint8_t iftype; /* We do not know the size of this. */
268 uint8_t key_idx_mask;
269 uint8_t key_idx_shift;
273 enum ieee80211_event_type {
280 enum ieee80211_rssi_event_data {
285 enum ieee80211_mlme_event_data {
292 enum ieee80211_mlme_event_status {
297 struct ieee80211_mlme_event {
298 enum ieee80211_mlme_event_data data;
299 enum ieee80211_mlme_event_status status;
303 struct ieee80211_event {
305 enum ieee80211_event_type type;
309 struct ieee80211_sta *sta;
312 struct ieee80211_mlme_event mlme;
316 struct ieee80211_ftm_responder_params {
324 struct ieee80211_he_mu_edca_param_ac_rec {
326 int aifsn, ecw_min_max, mu_edca_timer;
329 struct ieee80211_conf {
330 int dynamic_ps_timeout;
331 uint32_t listen_interval;
332 enum ieee80211_hw_conf_flags flags;
333 struct cfg80211_chan_def chandef;
336 enum ieee80211_hw_flags {
337 IEEE80211_HW_AMPDU_AGGREGATION,
338 IEEE80211_HW_AP_LINK_PS,
339 IEEE80211_HW_BUFF_MMPDU_TXQ,
340 IEEE80211_HW_CHANCTX_STA_CSA,
341 IEEE80211_HW_CONNECTION_MONITOR,
342 IEEE80211_HW_DEAUTH_NEED_MGD_TX_PREP,
343 IEEE80211_HW_HAS_RATE_CONTROL,
344 IEEE80211_HW_MFP_CAPABLE,
345 IEEE80211_HW_NEEDS_UNIQUE_STA_ADDR,
346 IEEE80211_HW_REPORTS_TX_ACK_STATUS,
347 IEEE80211_HW_RX_INCLUDES_FCS,
348 IEEE80211_HW_SIGNAL_DBM,
349 IEEE80211_HW_SINGLE_SCAN_ON_ALL_BANDS,
350 IEEE80211_HW_SPECTRUM_MGMT,
351 IEEE80211_HW_STA_MMPDU_TXQ,
352 IEEE80211_HW_SUPPORTS_AMSDU_IN_AMPDU,
353 IEEE80211_HW_SUPPORTS_CLONED_SKBS,
354 IEEE80211_HW_SUPPORTS_DYNAMIC_PS,
355 IEEE80211_HW_SUPPORTS_MULTI_BSSID,
356 IEEE80211_HW_SUPPORTS_ONLY_HE_MULTI_BSSID,
357 IEEE80211_HW_SUPPORTS_PS,
358 IEEE80211_HW_SUPPORTS_REORDERING_BUFFER,
359 IEEE80211_HW_SUPPORTS_VHT_EXT_NSS_BW,
360 IEEE80211_HW_SUPPORT_FAST_XMIT,
361 IEEE80211_HW_TDLS_WIDER_BW,
362 IEEE80211_HW_TIMING_BEACON_ONLY,
363 IEEE80211_HW_TX_AMPDU_SETUP_IN_HW,
364 IEEE80211_HW_TX_AMSDU,
365 IEEE80211_HW_TX_FRAG_LIST,
366 IEEE80211_HW_USES_RSS,
367 IEEE80211_HW_WANT_MONITOR_VIF,
368 IEEE80211_HW_SW_CRYPTO_CONTROL,
369 IEEE80211_HW_SUPPORTS_TX_FRAG,
370 IEEE80211_HW_SUPPORTS_TDLS_BUFFER_STA,
371 IEEE80211_HW_SUPPORTS_PER_STA_GTK,
372 IEEE80211_HW_REPORTS_LOW_ACK,
373 IEEE80211_HW_QUEUE_CONTROL,
376 NUM_IEEE80211_HW_FLAGS
379 struct ieee80211_hw {
384 int max_rx_aggregation_subframes, max_tx_aggregation_subframes;
385 int extra_tx_headroom, weight_multiplier;
386 int max_rate_tries, max_rates, max_report_rates;
387 struct ieee80211_cipher_scheme *cipher_schemes;
388 int n_cipher_schemes;
389 const char *rate_control_algorithm;
391 uint16_t units_pos; /* radiotap "spec" is .. inconsistent. */
393 } radiotap_timestamp;
394 size_t sta_data_size;
395 size_t vif_data_size;
396 size_t chanctx_data_size;
397 size_t txq_data_size;
398 uint16_t radiotap_mcs_details;
399 uint16_t radiotap_vht_details;
401 uint16_t offchannel_tx_hw_queue;
402 uint16_t uapsd_max_sp_len;
403 uint16_t uapsd_queues;
404 uint16_t max_tx_fragments;
405 uint16_t max_listen_interval;
406 netdev_features_t netdev_features;
407 unsigned long flags[BITS_TO_LONGS(NUM_IEEE80211_HW_FLAGS)];
408 struct ieee80211_conf conf;
410 #if 0 /* leave here for documentation purposes. This does NOT work. */
411 /* Must stay last. */
412 uint8_t priv[0] __aligned(CACHE_LINE_SIZE);
418 enum ieee802111_key_flag {
419 IEEE80211_KEY_FLAG_GENERATE_IV = BIT(0),
420 IEEE80211_KEY_FLAG_GENERATE_MMIC = BIT(1),
421 IEEE80211_KEY_FLAG_PAIRWISE = BIT(2),
422 IEEE80211_KEY_FLAG_PUT_IV_SPACE = BIT(3),
423 IEEE80211_KEY_FLAG_PUT_MIC_SPACE = BIT(4),
424 IEEE80211_KEY_FLAG_SW_MGMT_TX = BIT(5),
425 IEEE80211_KEY_FLAG_GENERATE_IV_MGMT = BIT(6),
428 struct ieee80211_key_conf {
431 uint8_t icv_len; /* __unused nowadays? */
433 uint8_t hw_key_idx; /* Set by drv. */
440 struct ieee80211_key_seq {
444 uint8_t seq[IEEE80211_MAX_PN_LEN];
448 uint8_t pn[IEEE80211_CCMP_PN_LEN];
451 uint8_t pn[IEEE80211_CCMP_PN_LEN];
461 enum ieee80211_rx_status_flags {
462 RX_FLAG_ALLOW_SAME_PN = BIT(0),
463 RX_FLAG_AMPDU_DETAILS = BIT(1),
464 RX_FLAG_AMPDU_EOF_BIT = BIT(2),
465 RX_FLAG_AMPDU_EOF_BIT_KNOWN = BIT(3),
466 RX_FLAG_DECRYPTED = BIT(4),
467 RX_FLAG_DUP_VALIDATED = BIT(5),
468 RX_FLAG_FAILED_FCS_CRC = BIT(6),
469 RX_FLAG_ICV_STRIPPED = BIT(7),
470 RX_FLAG_MACTIME_PLCP_START = BIT(8),
471 RX_FLAG_MACTIME_START = BIT(9),
472 RX_FLAG_MIC_STRIPPED = BIT(10),
473 RX_FLAG_MMIC_ERROR = BIT(11),
474 RX_FLAG_MMIC_STRIPPED = BIT(12),
475 RX_FLAG_NO_PSDU = BIT(13),
476 RX_FLAG_PN_VALIDATED = BIT(14),
477 RX_FLAG_RADIOTAP_HE = BIT(15),
478 RX_FLAG_RADIOTAP_HE_MU = BIT(16),
479 RX_FLAG_RADIOTAP_LSIG = BIT(17),
480 RX_FLAG_RADIOTAP_VENDOR_DATA = BIT(18),
481 RX_FLAG_NO_SIGNAL_VAL = BIT(19),
482 RX_FLAG_IV_STRIPPED = BIT(20),
483 RX_FLAG_AMPDU_IS_LAST = BIT(21),
484 RX_FLAG_AMPDU_LAST_KNOWN = BIT(22),
485 RX_FLAG_AMSDU_MORE = BIT(23),
486 RX_FLAG_MACTIME_END = BIT(24),
487 RX_FLAG_ONLY_MONITOR = BIT(25),
488 RX_FLAG_SKIP_MONITOR = BIT(26),
491 struct ieee80211_rx_status {
492 /* TODO FIXME, this is too large. Over-reduce types to u8 where possible. */
493 uint64_t boottime_ns;
495 uint32_t device_timestamp;
496 enum ieee80211_rx_status_flags flag;
499 #define RATE_INFO_BW_20 0x01
500 #define RATE_INFO_BW_40 0x02
501 #define RATE_INFO_BW_80 0x04
502 #define RATE_INFO_BW_160 0x08
503 #define RATE_INFO_BW_HE_RU 0x10
505 #define RX_ENC_LEGACY 0x00
506 #define RX_ENC_HE 0x01
507 #define RX_ENC_HT 0x02
508 #define RX_ENC_VHT 0x04
509 uint8_t ampdu_reference;
512 int8_t chain_signal[IEEE80211_MAX_CHAINS];
518 uint8_t zero_length_psdu_type;
523 struct ieee80211_scan_ies {
526 int len[NUM_NL80211_BANDS];
528 uint8_t *ies[NUM_NL80211_BANDS];
531 struct ieee80211_scan_request {
532 struct ieee80211_scan_ies ies;
533 struct cfg80211_scan_request req;
536 struct ieee80211_txq {
537 struct ieee80211_sta *sta;
538 struct ieee80211_vif *vif;
542 /* Must stay last. */
543 uint8_t drv_priv[0] __aligned(CACHE_LINE_SIZE);
546 struct ieee80211_sta_rates {
548 /* XXX some _rcu thing */
552 } rate[1]; /* XXX what is the real number? */
555 struct ieee80211_sta_txpwr {
557 enum nl80211_tx_power_setting type;
561 struct ieee80211_link_sta {
562 uint32_t supp_rates[NUM_NL80211_BANDS];
563 struct ieee80211_sta_ht_cap ht_cap;
564 struct ieee80211_sta_vht_cap vht_cap;
565 struct ieee80211_sta_he_cap he_cap;
566 struct ieee80211_sta_he_6ghz_capa he_6ghz_capa;
568 enum ieee80211_sta_rx_bw bandwidth;
569 struct ieee80211_sta_txpwr txpwr;
572 #define IEEE80211_NUM_TIDS 16 /* net80211::WME_NUM_TID */
573 struct ieee80211_sta {
575 int max_amsdu_len, max_amsdu_subframes, max_rc_amsdu_len, max_sp;
576 int mfp, smps_mode, tdls, tdls_initiator, uapsd_queues, wme;
577 struct ieee80211_txq *txq[IEEE80211_NUM_TIDS + 1]; /* iwlwifi: 8 and adds +1 to tid_data, net80211::IEEE80211_TID_SIZE */
578 struct ieee80211_sta_rates *rates; /* some rcu thing? */
579 uint32_t max_tid_amsdu_len[IEEE80211_NUM_TIDS];
580 uint8_t addr[ETH_ALEN];
583 struct ieee80211_link_sta deflink;
585 /* Must stay last. */
586 uint8_t drv_priv[0] __aligned(CACHE_LINE_SIZE);
589 struct ieee80211_tdls_ch_sw_params {
591 int action_code, ch_sw_tm_ie, status, switch_time, switch_timeout, timestamp;
592 struct ieee80211_sta *sta;
593 struct cfg80211_chan_def *chandef;
594 struct sk_buff *tmpl_skb;
597 struct ieee80211_tx_control {
599 struct ieee80211_sta *sta;
602 struct ieee80211_tx_queue_params {
603 /* These types are based on iwlwifi FW structs. */
610 int acm, mu_edca, uapsd;
611 struct ieee80211_he_mu_edca_param_ac_rec mu_edca_param_rec;
614 struct ieee80211_tx_rate {
620 enum ieee80211_vif_driver_flags {
621 IEEE80211_VIF_BEACON_FILTER = BIT(0),
622 IEEE80211_VIF_SUPPORTS_CQM_RSSI = BIT(1),
623 IEEE80211_VIF_SUPPORTS_UAPSD = BIT(2),
626 struct ieee80211_vif {
628 enum nl80211_iftype type;
629 int csa_active, mu_mimo_owner;
631 int color_change_active, offload_flags;
632 enum ieee80211_vif_driver_flags driver_flags;
635 uint8_t addr[ETH_ALEN];
636 struct ieee80211_chanctx_conf *chanctx_conf;
637 struct ieee80211_txq *txq;
638 struct ieee80211_bss_conf bss_conf;
639 uint8_t hw_queue[IEEE80211_NUM_ACS];
641 /* Must stay last. */
642 uint8_t drv_priv[0] __aligned(CACHE_LINE_SIZE);
645 struct ieee80211_vif_chanctx_switch {
646 struct ieee80211_chanctx_conf *old_ctx, *new_ctx;
647 struct ieee80211_vif *vif;
650 struct ieee80211_prep_tx_info {
655 /* XXX-BZ too big, over-reduce size to u8, and array sizes to minuimum to fit in skb->cb. */
656 /* Also warning: some sizes change by pointer size! This is 64bit only. */
657 struct ieee80211_tx_info {
658 enum ieee80211_tx_info_flags flags;
665 struct ieee80211_tx_rate rates[4];
667 struct ieee80211_vif *vif;
668 struct ieee80211_key_conf *hw_key;
669 enum ieee80211_tx_control_flags flags;
672 struct ieee80211_tx_rate rates[4];
674 uint8_t ampdu_ack_len;
678 bool is_valid_ack_signal;
679 void *status_driver_data[16 / sizeof(void *)]; /* XXX TODO */
681 #define IEEE80211_TX_INFO_DRIVER_DATA_SIZE (5 * sizeof(void *)) /* XXX TODO 5? */
682 void *driver_data[IEEE80211_TX_INFO_DRIVER_DATA_SIZE / sizeof(void *)];
686 /* net80211 conflict */
687 struct linuxkpi_ieee80211_tim_ie {
691 uint8_t *virtual_map;
693 #define ieee80211_tim_ie linuxkpi_ieee80211_tim_ie
695 struct survey_info { /* net80211::struct ieee80211_channel_survey */
698 #define SURVEY_INFO_TIME 0x0001
699 #define SURVEY_INFO_TIME_RX 0x0002
700 #define SURVEY_INFO_TIME_SCAN 0x0004
701 #define SURVEY_INFO_TIME_TX 0x0008
702 #define SURVEY_INFO_TIME_BSS_RX 0x0010
703 #define SURVEY_INFO_TIME_BUSY 0x0020
704 #define SURVEY_INFO_IN_USE 0x0040
705 #define SURVEY_INFO_NOISE_DBM 0x0080
708 uint64_t time_bss_rx;
713 struct ieee80211_channel *channel;
716 enum ieee80211_iface_iter {
717 IEEE80211_IFACE_ITER_NORMAL = BIT(0),
718 IEEE80211_IFACE_ITER_RESUME_ALL = BIT(1),
719 IEEE80211_IFACE_SKIP_SDATA_NOT_IN_DRIVER = BIT(2), /* seems to be an iter flag */
721 /* Internal flags only. */
722 /* ieee80211_iterate_active_interfaces*(). */
723 IEEE80211_IFACE_ITER__ATOMIC = BIT(6),
724 IEEE80211_IFACE_ITER__ACTIVE = BIT(7),
733 RX_ENC_FLAG_SHORTPRE = BIT(0),
734 RX_ENC_FLAG_SHORT_GI = BIT(1),
735 RX_ENC_FLAG_HT_GF = BIT(2),
736 RX_ENC_FLAG_LDPC = BIT(3),
737 RX_ENC_FLAG_BF = BIT(4),
738 #define RX_ENC_FLAG_STBC_SHIFT 6
741 enum sta_notify_cmd {
746 struct ieee80211_ops {
748 int (*start)(struct ieee80211_hw *);
749 void (*stop)(struct ieee80211_hw *);
751 int (*config)(struct ieee80211_hw *, u32);
752 void (*reconfig_complete)(struct ieee80211_hw *, enum ieee80211_reconfig_type);
754 int (*add_interface)(struct ieee80211_hw *, struct ieee80211_vif *);
755 void (*remove_interface)(struct ieee80211_hw *, struct ieee80211_vif *);
756 int (*change_interface)(struct ieee80211_hw *, struct ieee80211_vif *, enum nl80211_iftype, bool);
758 void (*sw_scan_start)(struct ieee80211_hw *, struct ieee80211_vif *, const u8 *);
759 void (*sw_scan_complete)(struct ieee80211_hw *, struct ieee80211_vif *);
760 int (*sched_scan_start)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_sched_scan_request *, struct ieee80211_scan_ies *);
761 int (*sched_scan_stop)(struct ieee80211_hw *, struct ieee80211_vif *);
762 int (*hw_scan)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_scan_request *);
763 void (*cancel_hw_scan)(struct ieee80211_hw *, struct ieee80211_vif *);
765 int (*conf_tx)(struct ieee80211_hw *, struct ieee80211_vif *, u16, const struct ieee80211_tx_queue_params *);
766 void (*tx)(struct ieee80211_hw *, struct ieee80211_tx_control *, struct sk_buff *);
767 int (*tx_last_beacon)(struct ieee80211_hw *);
768 void (*wake_tx_queue)(struct ieee80211_hw *, struct ieee80211_txq *);
770 void (*mgd_prepare_tx)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_prep_tx_info *);
771 void (*mgd_complete_tx)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_prep_tx_info *);
772 void (*mgd_protect_tdls_discover)(struct ieee80211_hw *, struct ieee80211_vif *);
774 void (*flush)(struct ieee80211_hw *, struct ieee80211_vif *, u32, bool);
776 int (*set_frag_threshold)(struct ieee80211_hw *, u32);
778 void (*sync_rx_queues)(struct ieee80211_hw *);
780 void (*allow_buffered_frames)(struct ieee80211_hw *, struct ieee80211_sta *, u16, int, enum ieee80211_frame_release_type, bool);
781 void (*release_buffered_frames)(struct ieee80211_hw *, struct ieee80211_sta *, u16, int, enum ieee80211_frame_release_type, bool);
783 int (*sta_add)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *);
784 int (*sta_remove)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *);
785 int (*sta_set_txpwr)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *);
786 void (*sta_statistics)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, struct station_info *);
787 void (*sta_pre_rcu_remove)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *);
788 int (*sta_state)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, enum ieee80211_sta_state, enum ieee80211_sta_state);
789 void (*sta_notify)(struct ieee80211_hw *, struct ieee80211_vif *, enum sta_notify_cmd, struct ieee80211_sta *);
790 void (*sta_rc_update)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, u32);
791 void (*sta_rate_tbl_update)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *);
792 void (*sta_set_4addr)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, bool);
794 u64 (*prepare_multicast)(struct ieee80211_hw *, struct netdev_hw_addr_list *);
796 int (*ampdu_action)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_ampdu_params *);
798 bool (*can_aggregate_in_amsdu)(struct ieee80211_hw *, struct sk_buff *, struct sk_buff *);
800 int (*pre_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_channel_switch *);
801 int (*post_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *);
802 void (*channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_channel_switch *);
803 void (*abort_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *);
804 void (*channel_switch_rx_beacon)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_channel_switch *);
805 int (*tdls_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, u8, struct cfg80211_chan_def *, struct sk_buff *, u32);
806 void (*tdls_cancel_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *);
807 void (*tdls_recv_channel_switch)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_tdls_ch_sw_params *);
809 int (*add_chanctx)(struct ieee80211_hw *, struct ieee80211_chanctx_conf *);
810 void (*remove_chanctx)(struct ieee80211_hw *, struct ieee80211_chanctx_conf *);
811 void (*change_chanctx)(struct ieee80211_hw *, struct ieee80211_chanctx_conf *, u32);
812 int (*assign_vif_chanctx)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_chanctx_conf *);
813 void (*unassign_vif_chanctx)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_chanctx_conf *);
814 int (*switch_vif_chanctx)(struct ieee80211_hw *, struct ieee80211_vif_chanctx_switch *, int, enum ieee80211_chanctx_switch_mode);
816 int (*get_antenna)(struct ieee80211_hw *, u32 *, u32 *);
817 int (*set_antenna)(struct ieee80211_hw *, u32, u32);
819 int (*remain_on_channel)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_channel *, int, enum ieee80211_roc_type);
820 int (*cancel_remain_on_channel)(struct ieee80211_hw *, struct ieee80211_vif *);
822 void (*configure_filter)(struct ieee80211_hw *, unsigned int, unsigned int *, u64);
823 void (*config_iface_filter)(struct ieee80211_hw *, struct ieee80211_vif *, unsigned int, unsigned int);
825 void (*bss_info_changed)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_bss_conf *, u32);
826 int (*set_rts_threshold)(struct ieee80211_hw *, u32);
827 void (*event_callback)(struct ieee80211_hw *, struct ieee80211_vif *, const struct ieee80211_event *);
828 int (*get_survey)(struct ieee80211_hw *, int, struct survey_info *);
829 int (*get_ftm_responder_stats)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_ftm_responder_stats *);
830 void (*offset_tsf)(struct ieee80211_hw *, struct ieee80211_vif *, s64);
831 int (*set_bitrate_mask)(struct ieee80211_hw *, struct ieee80211_vif *, const struct cfg80211_bitrate_mask *);
832 void (*set_coverage_class)(struct ieee80211_hw *, s16);
833 int (*set_tim)(struct ieee80211_hw *, struct ieee80211_sta *, bool);
835 int (*set_key)(struct ieee80211_hw *, enum set_key_cmd, struct ieee80211_vif *, struct ieee80211_sta *, struct ieee80211_key_conf *);
836 void (*set_default_unicast_key)(struct ieee80211_hw *, struct ieee80211_vif *, int);
837 void (*update_tkip_key)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_key_conf *, struct ieee80211_sta *, u32, u16 *);
839 int (*start_pmsr)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_pmsr_request *);
840 void (*abort_pmsr)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_pmsr_request *);
842 int (*start_ap)(struct ieee80211_hw *, struct ieee80211_vif *);
843 void (*stop_ap)(struct ieee80211_hw *, struct ieee80211_vif *);
844 int (*join_ibss)(struct ieee80211_hw *, struct ieee80211_vif *);
845 void (*leave_ibss)(struct ieee80211_hw *, struct ieee80211_vif *);
847 int (*set_sar_specs)(struct ieee80211_hw *, const struct cfg80211_sar_specs *);
849 int (*set_tid_config)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, struct cfg80211_tid_config *);
850 int (*reset_tid_config)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_sta *, u8);
852 int (*get_et_sset_count)(struct ieee80211_hw *, struct ieee80211_vif *, int);
853 void (*get_et_stats)(struct ieee80211_hw *, struct ieee80211_vif *, struct ethtool_stats *, u64 *);
854 void (*get_et_strings)(struct ieee80211_hw *, struct ieee80211_vif *, u32, u8 *);
856 void (*update_vif_offload)(struct ieee80211_hw *, struct ieee80211_vif *);
860 /* -------------------------------------------------------------------------- */
863 extern const struct cfg80211_ops linuxkpi_mac80211cfgops;
865 struct ieee80211_hw *linuxkpi_ieee80211_alloc_hw(size_t,
866 const struct ieee80211_ops *);
867 void linuxkpi_ieee80211_iffree(struct ieee80211_hw *);
868 void linuxkpi_set_ieee80211_dev(struct ieee80211_hw *, char *);
869 int linuxkpi_ieee80211_ifattach(struct ieee80211_hw *);
870 void linuxkpi_ieee80211_ifdetach(struct ieee80211_hw *);
871 struct ieee80211_hw * linuxkpi_wiphy_to_ieee80211_hw(struct wiphy *);
872 void linuxkpi_ieee80211_iterate_interfaces(
873 struct ieee80211_hw *hw, enum ieee80211_iface_iter flags,
874 void(*iterfunc)(void *, uint8_t *, struct ieee80211_vif *),
876 void linuxkpi_ieee80211_iterate_keys(struct ieee80211_hw *,
877 struct ieee80211_vif *,
878 void(*iterfunc)(struct ieee80211_hw *, struct ieee80211_vif *,
879 struct ieee80211_sta *, struct ieee80211_key_conf *, void *),
881 void linuxkpi_ieee80211_iterate_chan_contexts(struct ieee80211_hw *,
882 void(*iterfunc)(struct ieee80211_hw *,
883 struct ieee80211_chanctx_conf *, void *),
885 void linuxkpi_ieee80211_iterate_stations_atomic(struct ieee80211_hw *,
886 void (*iterfunc)(void *, struct ieee80211_sta *), void *);
887 void linuxkpi_ieee80211_scan_completed(struct ieee80211_hw *,
888 struct cfg80211_scan_info *);
889 void linuxkpi_ieee80211_rx(struct ieee80211_hw *, struct sk_buff *,
890 struct ieee80211_sta *, struct napi_struct *);
891 uint8_t linuxkpi_ieee80211_get_tid(struct ieee80211_hdr *);
892 struct ieee80211_sta *linuxkpi_ieee80211_find_sta(struct ieee80211_vif *,
894 struct ieee80211_sta *linuxkpi_ieee80211_find_sta_by_ifaddr(
895 struct ieee80211_hw *, const uint8_t *, const uint8_t *);
896 struct sk_buff *linuxkpi_ieee80211_tx_dequeue(struct ieee80211_hw *,
897 struct ieee80211_txq *);
898 bool linuxkpi_ieee80211_is_ie_id_in_ie_buf(const u8, const u8 *, size_t);
899 bool linuxkpi_ieee80211_ie_advance(size_t *, const u8 *, size_t);
900 void linuxkpi_ieee80211_free_txskb(struct ieee80211_hw *, struct sk_buff *,
902 void linuxkpi_ieee80211_queue_delayed_work(struct ieee80211_hw *,
903 struct delayed_work *, int);
904 void linuxkpi_ieee80211_queue_work(struct ieee80211_hw *, struct work_struct *);
905 struct sk_buff *linuxkpi_ieee80211_pspoll_get(struct ieee80211_hw *,
906 struct ieee80211_vif *);
907 struct sk_buff *linuxkpi_ieee80211_nullfunc_get(struct ieee80211_hw *,
908 struct ieee80211_vif *, bool);
909 void linuxkpi_ieee80211_txq_get_depth(struct ieee80211_txq *, unsigned long *,
911 struct wireless_dev *linuxkpi_ieee80211_vif_to_wdev(struct ieee80211_vif *);
912 void linuxkpi_ieee80211_connection_loss(struct ieee80211_vif *);
913 void linuxkpi_ieee80211_beacon_loss(struct ieee80211_vif *);
914 struct sk_buff *linuxkpi_ieee80211_probereq_get(struct ieee80211_hw *,
915 uint8_t *, uint8_t *, size_t, size_t);
916 void linuxkpi_ieee80211_tx_status(struct ieee80211_hw *, struct sk_buff *);
918 /* -------------------------------------------------------------------------- */
921 _ieee80211_hw_set(struct ieee80211_hw *hw, enum ieee80211_hw_flags flag)
924 set_bit(flag, hw->flags);
928 __ieee80211_hw_check(struct ieee80211_hw *hw, enum ieee80211_hw_flags flag)
931 return (test_bit(flag, hw->flags));
934 /* They pass in shortened flag names; how confusingly inconsistent. */
935 #define ieee80211_hw_set(_hw, _flag) \
936 _ieee80211_hw_set(_hw, IEEE80211_HW_ ## _flag)
937 #define ieee80211_hw_check(_hw, _flag) \
938 __ieee80211_hw_check(_hw, IEEE80211_HW_ ## _flag)
940 /* XXX-BZ add CTASSERTS that size of struct is <= sizeof skb->cb. */
941 CTASSERT(sizeof(struct ieee80211_tx_info) <= sizeof(((struct sk_buff *)0)->cb));
942 #define IEEE80211_SKB_CB(_skb) \
943 ((struct ieee80211_tx_info *)((_skb)->cb))
945 CTASSERT(sizeof(struct ieee80211_rx_status) <= sizeof(((struct sk_buff *)0)->cb));
946 #define IEEE80211_SKB_RXCB(_skb) \
947 ((struct ieee80211_rx_status *)((_skb)->cb))
950 ieee80211_free_hw(struct ieee80211_hw *hw)
953 linuxkpi_ieee80211_iffree(hw);
955 if (hw->wiphy != NULL)
956 wiphy_free(hw->wiphy);
957 /* Note that *hw is not valid any longer after this. */
962 static __inline struct ieee80211_hw *
963 ieee80211_alloc_hw(size_t priv_len, const struct ieee80211_ops *ops)
966 return (linuxkpi_ieee80211_alloc_hw(priv_len, ops));
970 SET_IEEE80211_DEV(struct ieee80211_hw *hw, struct device *dev)
973 set_wiphy_dev(hw->wiphy, dev);
974 linuxkpi_set_ieee80211_dev(hw, dev_name(dev));
980 ieee80211_register_hw(struct ieee80211_hw *hw)
984 error = wiphy_register(hw->wiphy);
989 * At this point the driver has set all the options, flags, bands,
990 * ciphers, hw address(es), ... basically mac80211/cfg80211 hw/wiphy
992 * We need to replicate a lot of information from here into net80211.
994 error = linuxkpi_ieee80211_ifattach(hw);
1001 static __inline void
1002 ieee80211_unregister_hw(struct ieee80211_hw *hw)
1005 wiphy_unregister(hw->wiphy);
1006 linuxkpi_ieee80211_ifdetach(hw);
1011 static __inline struct ieee80211_hw *
1012 wiphy_to_ieee80211_hw(struct wiphy *wiphy)
1015 return (linuxkpi_wiphy_to_ieee80211_hw(wiphy));
1018 /* -------------------------------------------------------------------------- */
1020 static __inline bool
1021 ieee80211_is_action(__le16 fc)
1025 fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1026 v = htole16(IEEE80211_FC0_SUBTYPE_ACTION | IEEE80211_FC0_TYPE_MGT);
1031 static __inline bool
1032 ieee80211_is_probe_resp(__le16 fc)
1036 fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1037 v = htole16(IEEE80211_FC0_SUBTYPE_PROBE_RESP | IEEE80211_FC0_TYPE_MGT);
1042 static __inline bool
1043 ieee80211_is_auth(__le16 fc)
1047 fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1048 v = htole16(IEEE80211_FC0_SUBTYPE_AUTH | IEEE80211_FC0_TYPE_MGT);
1053 static __inline bool
1054 ieee80211_is_assoc_req(__le16 fc)
1058 fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1059 v = htole16(IEEE80211_FC0_SUBTYPE_ASSOC_REQ | IEEE80211_FC0_TYPE_MGT);
1064 static __inline bool
1065 ieee80211_is_assoc_resp(__le16 fc)
1069 fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1070 v = htole16(IEEE80211_FC0_SUBTYPE_ASSOC_RESP | IEEE80211_FC0_TYPE_MGT);
1075 static __inline bool
1076 ieee80211_is_reassoc_req(__le16 fc)
1080 fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1081 v = htole16(IEEE80211_FC0_SUBTYPE_REASSOC_REQ | IEEE80211_FC0_TYPE_MGT);
1086 static __inline bool
1087 ieee80211_is_reassoc_resp(__le16 fc)
1091 fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1092 v = htole16(IEEE80211_FC0_SUBTYPE_REASSOC_RESP | IEEE80211_FC0_TYPE_MGT);
1097 static __inline bool
1098 ieee80211_is_disassoc(__le16 fc)
1102 fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1103 v = htole16(IEEE80211_FC0_SUBTYPE_DISASSOC | IEEE80211_FC0_TYPE_MGT);
1108 static __inline bool
1109 ieee80211_is_data_present(__le16 fc)
1113 /* If it is a data frame and NODATA is not present. */
1114 fc &= htole16(IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_NODATA);
1115 v = htole16(IEEE80211_FC0_TYPE_DATA);
1120 static __inline bool
1121 ieee80211_is_deauth(__le16 fc)
1125 fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1126 v = htole16(IEEE80211_FC0_SUBTYPE_DEAUTH | IEEE80211_FC0_TYPE_MGT);
1131 static __inline bool
1132 ieee80211_is_beacon(__le16 fc)
1137 * For as much as I get it this comes in LE and unlike FreeBSD
1138 * where we get the entire frame header and u8[], here we get the
1139 * 9.2.4.1 Frame Control field only. Mask and compare.
1141 fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1142 v = htole16(IEEE80211_FC0_SUBTYPE_BEACON | IEEE80211_FC0_TYPE_MGT);
1148 static __inline bool
1149 ieee80211_is_probe_req(__le16 fc)
1153 fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1154 v = htole16(IEEE80211_FC0_SUBTYPE_PROBE_REQ | IEEE80211_FC0_TYPE_MGT);
1159 static __inline bool
1160 ieee80211_has_protected(__le16 fc)
1163 return (fc & htole16(IEEE80211_FC1_PROTECTED << 8));
1166 static __inline bool
1167 ieee80211_is_back_req(__le16 fc)
1171 fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1172 v = htole16(IEEE80211_FC0_SUBTYPE_BAR | IEEE80211_FC0_TYPE_CTL);
1177 static __inline bool
1178 ieee80211_is_bufferable_mmpdu(__le16 fc)
1181 /* 11.2.2 Bufferable MMPDUs, 80211-2020. */
1182 /* XXX we do not care about IBSS yet. */
1184 if (!ieee80211_is_mgmt(fc))
1186 if (ieee80211_is_action(fc)) /* XXX FTM? */
1188 if (ieee80211_is_disassoc(fc))
1190 if (ieee80211_is_deauth(fc))
1196 static __inline bool
1197 ieee80211_is_nullfunc(__le16 fc)
1201 fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1202 v = htole16(IEEE80211_FC0_SUBTYPE_NODATA | IEEE80211_FC0_TYPE_DATA);
1207 static __inline bool
1208 ieee80211_is_qos_nullfunc(__le16 fc)
1212 fc &= htole16(IEEE80211_FC0_SUBTYPE_MASK | IEEE80211_FC0_TYPE_MASK);
1213 v = htole16(IEEE80211_FC0_SUBTYPE_QOS_NULL | IEEE80211_FC0_TYPE_DATA);
1218 static __inline bool
1219 ieee80211_is_any_nullfunc(__le16 fc)
1222 return (ieee80211_is_nullfunc(fc) || ieee80211_is_qos_nullfunc(fc));
1225 static __inline bool
1226 ieee80211_vif_is_mesh(struct ieee80211_vif *vif)
1232 static __inline bool
1233 ieee80211_has_a4(__le16 fc)
1237 fc &= htole16((IEEE80211_FC1_DIR_TODS | IEEE80211_FC1_DIR_FROMDS) << 8);
1238 v = htole16((IEEE80211_FC1_DIR_TODS | IEEE80211_FC1_DIR_FROMDS) << 8);
1243 static __inline bool
1244 ieee80211_has_order(__le16 fc)
1247 return (fc & htole16(IEEE80211_FC1_ORDER << 8));
1250 static __inline bool
1251 ieee80211_has_retry(__le16 fc)
1254 return (fc & htole16(IEEE80211_FC1_RETRY << 8));
1258 static __inline bool
1259 ieee80211_has_fromds(__le16 fc)
1262 return (fc & htole16(IEEE80211_FC1_DIR_FROMDS << 8));
1265 static __inline bool
1266 ieee80211_has_tods(__le16 fc)
1269 return (fc & htole16(IEEE80211_FC1_DIR_TODS << 8));
1272 static __inline uint8_t *
1273 ieee80211_get_SA(struct ieee80211_hdr *hdr)
1276 if (ieee80211_has_a4(hdr->frame_control))
1277 return (hdr->addr4);
1278 if (ieee80211_has_fromds(hdr->frame_control))
1279 return (hdr->addr3);
1280 return (hdr->addr2);
1283 static __inline uint8_t *
1284 ieee80211_get_DA(struct ieee80211_hdr *hdr)
1287 if (ieee80211_has_tods(hdr->frame_control))
1288 return (hdr->addr3);
1289 return (hdr->addr1);
1292 static __inline bool
1293 ieee80211_has_morefrags(__le16 fc)
1296 fc &= htole16(IEEE80211_FC1_MORE_FRAG << 8);
1300 static __inline u8 *
1301 ieee80211_get_qos_ctl(struct ieee80211_hdr *hdr)
1303 if (ieee80211_has_a4(hdr->frame_control))
1304 return (u8 *)hdr + 30;
1306 return (u8 *)hdr + 24;
1309 /* -------------------------------------------------------------------------- */
1310 /* Receive functions (air/driver to mac80211/net80211). */
1313 static __inline void
1314 ieee80211_rx_napi(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
1315 struct sk_buff *skb, struct napi_struct *napi)
1318 linuxkpi_ieee80211_rx(hw, skb, sta, napi);
1321 static __inline void
1322 ieee80211_rx_ni(struct ieee80211_hw *hw, struct sk_buff *skb)
1325 linuxkpi_ieee80211_rx(hw, skb, NULL, NULL);
1328 static __inline void
1329 ieee80211_rx_irqsafe(struct ieee80211_hw *hw, struct sk_buff *skb)
1332 linuxkpi_ieee80211_rx(hw, skb, NULL, NULL);
1335 /* -------------------------------------------------------------------------- */
1337 static __inline uint8_t
1338 ieee80211_get_tid(struct ieee80211_hdr *hdr)
1341 return (linuxkpi_ieee80211_get_tid(hdr));
1344 static __inline struct sk_buff *
1345 ieee80211_beacon_get_tim(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1346 uint16_t *tim_offset, uint16_t *tim_len)
1349 if (tim_offset != NULL)
1351 if (tim_len != NULL)
1357 static __inline void
1358 ieee80211_iterate_active_interfaces_atomic(struct ieee80211_hw *hw,
1359 enum ieee80211_iface_iter flags,
1360 void(*iterfunc)(void *, uint8_t *, struct ieee80211_vif *),
1364 flags |= IEEE80211_IFACE_ITER__ATOMIC;
1365 flags |= IEEE80211_IFACE_ITER__ACTIVE;
1366 linuxkpi_ieee80211_iterate_interfaces(hw, flags, iterfunc, arg);
1369 static __inline void
1370 ieee80211_iterate_active_interfaces(struct ieee80211_hw *hw,
1371 enum ieee80211_iface_iter flags,
1372 void(*iterfunc)(void *, uint8_t *, struct ieee80211_vif *),
1376 flags |= IEEE80211_IFACE_ITER__ACTIVE;
1377 linuxkpi_ieee80211_iterate_interfaces(hw, flags, iterfunc, arg);
1380 static __inline void
1381 ieee80211_iterate_interfaces(struct ieee80211_hw *hw,
1382 enum ieee80211_iface_iter flags,
1383 void (*iterfunc)(void *, uint8_t *, struct ieee80211_vif *),
1387 linuxkpi_ieee80211_iterate_interfaces(hw, flags, iterfunc, arg);
1390 static __inline void
1391 ieee80211_iter_keys(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1392 void(*iterfunc)(struct ieee80211_hw *, struct ieee80211_vif *,
1393 struct ieee80211_sta *, struct ieee80211_key_conf *, void *),
1397 linuxkpi_ieee80211_iterate_keys(hw, vif, iterfunc, arg);
1400 static __inline void
1401 ieee80211_iter_keys_rcu(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1402 void(*iterfunc)(struct ieee80211_hw *, struct ieee80211_vif *,
1403 struct ieee80211_sta *, struct ieee80211_key_conf *, void *),
1407 IMPROVE(); /* "rcu" */
1408 linuxkpi_ieee80211_iterate_keys(hw, vif, iterfunc, arg);
1411 static __inline void
1412 ieee80211_iter_chan_contexts_atomic(struct ieee80211_hw *hw,
1413 void(*iterfunc)(struct ieee80211_hw *, struct ieee80211_chanctx_conf *, void *),
1417 linuxkpi_ieee80211_iterate_chan_contexts(hw, iterfunc, arg);
1420 static __inline void
1421 ieee80211_iterate_stations_atomic(struct ieee80211_hw *hw,
1422 void (*iterfunc)(void *, struct ieee80211_sta *), void *arg)
1425 linuxkpi_ieee80211_iterate_stations_atomic(hw, iterfunc, arg);
1428 static __inline struct wireless_dev *
1429 ieee80211_vif_to_wdev(struct ieee80211_vif *vif)
1432 return (linuxkpi_ieee80211_vif_to_wdev(vif));
1435 static __inline struct sk_buff *
1436 ieee80211_beacon_get_template(struct ieee80211_hw *hw,
1437 struct ieee80211_vif *vif, struct ieee80211_mutable_offsets *offs)
1443 static __inline void
1444 ieee80211_beacon_loss(struct ieee80211_vif *vif)
1446 linuxkpi_ieee80211_beacon_loss(vif);
1449 static __inline void
1450 ieee80211_chswitch_done(struct ieee80211_vif *vif, bool t)
1455 static __inline bool
1456 ieee80211_csa_is_complete(struct ieee80211_vif *vif)
1462 static __inline void
1463 ieee80211_csa_set_counter(struct ieee80211_vif *vif, uint8_t counter)
1469 ieee80211_csa_update_counter(struct ieee80211_vif *vif)
1475 static __inline void
1476 ieee80211_csa_finish(struct ieee80211_vif *vif)
1481 static __inline enum nl80211_iftype
1482 ieee80211_vif_type_p2p(struct ieee80211_vif *vif)
1485 /* If we are not p2p enabled, just return the type. */
1489 /* If we are p2p, depending on side, return type. */
1490 switch (vif->type) {
1491 case NL80211_IFTYPE_AP:
1492 return (NL80211_IFTYPE_P2P_GO);
1493 case NL80211_IFTYPE_STATION:
1494 return (NL80211_IFTYPE_P2P_CLIENT);
1501 static __inline unsigned long
1502 ieee80211_tu_to_usec(unsigned long tu)
1505 return (tu * IEEE80211_DUR_TU);
1510 ieee80211_action_contains_tpc(struct sk_buff *skb)
1516 static __inline void
1517 ieee80211_connection_loss(struct ieee80211_vif *vif)
1520 linuxkpi_ieee80211_connection_loss(vif);
1523 static __inline struct ieee80211_sta *
1524 ieee80211_find_sta(struct ieee80211_vif *vif, const u8 *peer)
1527 return (linuxkpi_ieee80211_find_sta(vif, peer));
1530 static __inline struct ieee80211_sta *
1531 ieee80211_find_sta_by_ifaddr(struct ieee80211_hw *hw, const uint8_t *addr,
1532 const uint8_t *ourvifaddr)
1535 return (linuxkpi_ieee80211_find_sta_by_ifaddr(hw, addr, ourvifaddr));
1539 static __inline void
1540 ieee80211_get_tkip_p2k(struct ieee80211_key_conf *keyconf,
1541 struct sk_buff *skb_frag, u8 *key)
1546 static __inline void
1547 ieee80211_get_tkip_rx_p1k(struct ieee80211_key_conf *keyconf,
1548 const u8 *addr, uint32_t iv32, u16 *p1k)
1553 static __inline size_t
1554 ieee80211_ie_split(const u8 *ies, size_t ies_len,
1555 const u8 *ie_ids, size_t ie_ids_len, size_t start)
1561 /* XXX FIXME, we need to deal with "Element ID Extension" */
1562 while (x < ies_len) {
1564 /* Is this IE[s] one of the ie_ids? */
1565 if (!linuxkpi_ieee80211_is_ie_id_in_ie_buf(ies[x],
1566 ie_ids, ie_ids_len))
1569 if (!linuxkpi_ieee80211_ie_advance(&x, ies, ies_len))
1576 static __inline void
1577 ieee80211_request_smps(struct ieee80211_vif *vif, enum ieee80211_smps_mode smps)
1583 static __inline void
1584 ieee80211_tdls_oper_request(struct ieee80211_vif *vif, uint8_t *addr,
1585 enum nl80211_tdls_operation oper, enum ieee80211_reason_code code,
1591 static __inline void
1592 ieee80211_stop_queues(struct ieee80211_hw *hw)
1597 static __inline void
1598 ieee80211_wake_queues(struct ieee80211_hw *hw)
1603 static __inline void
1604 wiphy_rfkill_set_hw_state(struct wiphy *wiphy, bool state)
1609 static __inline void
1610 ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb)
1615 * This is called on transmit failure.
1616 * Use a not-so-random random high status error so we can distinguish
1617 * it from normal low values flying around in net80211 ("ETX").
1619 linuxkpi_ieee80211_free_txskb(hw, skb, 0x455458);
1622 static __inline void
1623 ieee80211_restart_hw(struct ieee80211_hw *hw)
1628 static __inline void
1629 ieee80211_ready_on_channel(struct ieee80211_hw *hw)
1632 /* XXX-BZ We need to see that. */
1635 static __inline void
1636 ieee80211_remain_on_channel_expired(struct ieee80211_hw *hw)
1641 static __inline void
1642 ieee80211_cqm_rssi_notify(struct ieee80211_vif *vif,
1643 enum nl80211_cqm_rssi_threshold_event crte, int sig, gfp_t gfp)
1648 static __inline void
1649 ieee80211_mark_rx_ba_filtered_frames(struct ieee80211_sta *sta, uint8_t tid,
1650 uint32_t ssn, uint64_t bitmap, uint16_t received_mpdu)
1655 static __inline bool
1656 ieee80211_sn_less(uint16_t sn1, uint16_t sn2)
1662 static __inline uint16_t
1663 ieee80211_sn_inc(uint16_t sn)
1669 static __inline uint16_t
1670 ieee80211_sn_add(uint16_t sn, uint16_t a)
1676 static __inline void
1677 ieee80211_stop_rx_ba_session(struct ieee80211_vif *vif, uint32_t x, uint8_t *addr)
1682 static __inline void
1683 ieee80211_rate_set_vht(struct ieee80211_tx_rate *r, uint32_t f1, uint32_t f2)
1688 static __inline void
1689 ieee80211_reserve_tid(struct ieee80211_sta *sta, uint8_t tid)
1694 static __inline void
1695 ieee80211_unreserve_tid(struct ieee80211_sta *sta, uint8_t tid)
1700 static __inline void
1701 ieee80211_rx_ba_timer_expired(struct ieee80211_vif *vif, uint8_t *addr,
1707 static __inline void
1708 ieee80211_send_eosp_nullfunc(struct ieee80211_sta *sta, uint8_t tid)
1713 static __inline uint16_t
1714 ieee80211_sn_sub(uint16_t sa, uint16_t sb)
1718 (IEEE80211_SEQ_SEQ_MASK >> IEEE80211_SEQ_SEQ_SHIFT));
1721 static __inline void
1722 ieee80211_sta_block_awake(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
1728 static __inline void
1729 ieee80211_sta_ps_transition(struct ieee80211_sta *sta, bool sleeping)
1734 static __inline void
1735 ieee80211_sta_pspoll(struct ieee80211_sta *sta)
1740 static __inline void
1741 ieee80211_sta_uapsd_trigger(struct ieee80211_sta *sta, int ntids)
1746 static __inline void
1747 ieee80211_start_tx_ba_cb_irqsafe(struct ieee80211_vif *vif, uint8_t *addr,
1753 static __inline void
1754 ieee80211_tkip_add_iv(u8 *crypto_hdr, struct ieee80211_key_conf *keyconf,
1760 static __inline struct sk_buff *
1761 ieee80211_tx_dequeue(struct ieee80211_hw *hw, struct ieee80211_txq *txq)
1764 return (linuxkpi_ieee80211_tx_dequeue(hw, txq));
1767 static __inline void
1768 ieee80211_update_mu_groups(struct ieee80211_vif *vif, uint8_t *ms, uint8_t *up)
1773 static __inline void
1774 ieee80211_sta_set_buffered(struct ieee80211_sta *sta, uint8_t tid, bool t)
1779 static __inline void
1780 ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)
1783 linuxkpi_ieee80211_tx_status(hw, skb);
1786 static __inline void
1787 ieee80211_get_key_rx_seq(struct ieee80211_key_conf *keyconf, uint8_t tid,
1788 struct ieee80211_key_seq *seq)
1793 static __inline void
1794 ieee80211_sched_scan_results(struct ieee80211_hw *hw)
1799 static __inline void
1800 ieee80211_sta_eosp(struct ieee80211_sta *sta)
1805 static __inline void
1806 ieee80211_stop_tx_ba_cb_irqsafe(struct ieee80211_vif *vif, uint8_t *addr,
1812 static __inline void
1813 ieee80211_sched_scan_stopped(struct ieee80211_hw *hw)
1818 static __inline void
1819 ieee80211_scan_completed(struct ieee80211_hw *hw,
1820 struct cfg80211_scan_info *info)
1823 linuxkpi_ieee80211_scan_completed(hw, info);
1826 static __inline struct sk_buff *
1827 ieee80211_beacon_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
1833 static __inline struct sk_buff *
1834 ieee80211_pspoll_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
1837 /* Only STA needs this. Otherwise return NULL and panic bad drivers. */
1838 if (vif->type != NL80211_IFTYPE_STATION)
1841 return (linuxkpi_ieee80211_pspoll_get(hw, vif));
1844 static __inline struct sk_buff *
1845 ieee80211_proberesp_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
1851 static __inline struct sk_buff *
1852 ieee80211_nullfunc_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1856 /* Only STA needs this. Otherwise return NULL and panic bad drivers. */
1857 if (vif->type != NL80211_IFTYPE_STATION)
1860 return (linuxkpi_ieee80211_nullfunc_get(hw, vif, qos));
1863 static __inline struct sk_buff *
1864 ieee80211_probereq_get(struct ieee80211_hw *hw, uint8_t *addr,
1865 uint8_t *ssid, size_t ssid_len, size_t tailroom)
1868 return (linuxkpi_ieee80211_probereq_get(hw, addr, ssid, ssid_len,
1872 static __inline void
1873 ieee80211_queue_delayed_work(struct ieee80211_hw *hw, struct delayed_work *w,
1877 linuxkpi_ieee80211_queue_delayed_work(hw, w, delay);
1880 static __inline void
1881 ieee80211_queue_work(struct ieee80211_hw *hw, struct work_struct *w)
1884 linuxkpi_ieee80211_queue_work(hw, w);
1887 static __inline void
1888 ieee80211_stop_queue(struct ieee80211_hw *hw, uint16_t q)
1893 static __inline void
1894 ieee80211_wake_queue(struct ieee80211_hw *hw, uint16_t q)
1899 static __inline void
1900 ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw, struct sk_buff *skb)
1903 ieee80211_tx_status(hw, skb);
1906 static __inline void
1907 ieee80211_tx_status_ni(struct ieee80211_hw *hw, struct sk_buff *skb)
1910 ieee80211_tx_status(hw, skb);
1914 ieee80211_start_tx_ba_session(struct ieee80211_sta *sta, uint8_t tid, int x)
1920 static __inline void
1921 ieee80211_tx_info_clear_status(struct ieee80211_tx_info *info)
1926 * Apparently clearing flags and some other fields is not right.
1927 * Given the function is called "status" we work on that part of
1930 for (i = 0; i < nitems(info->status.rates); i++)
1931 info->status.rates[i].count = 0;
1933 * Unclear if ack_signal should be included or not but we clear the
1934 * "valid" bool so this field is no longer valid.
1936 memset(&info->status.ack_signal, 0, sizeof(*info) -
1937 offsetof(struct ieee80211_tx_info, status.ack_signal));
1940 static __inline void
1941 ieee80211_txq_get_depth(struct ieee80211_txq *txq, unsigned long *frame_cnt,
1942 unsigned long *byte_cnt)
1945 if (frame_cnt == NULL && byte_cnt == NULL)
1948 linuxkpi_ieee80211_txq_get_depth(txq, frame_cnt, byte_cnt);
1952 rate_lowest_index(struct ieee80211_supported_band *band,
1953 struct ieee80211_sta *sta)
1960 static __inline void
1961 SET_IEEE80211_PERM_ADDR (struct ieee80211_hw *hw, uint8_t *addr)
1964 ether_addr_copy(hw->wiphy->perm_addr, addr);
1967 static __inline uint8_t *
1968 ieee80211_bss_get_ie(struct cfg80211_bss *bss, uint32_t x)
1974 static __inline void
1975 ieee80211_report_low_ack(struct ieee80211_sta *sta, int x)
1980 static __inline void
1981 ieee80211_start_rx_ba_session_offl(struct ieee80211_vif *vif, uint8_t *addr,
1987 static __inline void
1988 ieee80211_stop_rx_ba_session_offl(struct ieee80211_vif *vif, uint8_t *addr,
1994 static __inline struct sk_buff *
1995 ieee80211_tx_dequeue_ni(struct ieee80211_hw *hw, struct ieee80211_txq *txq)
2001 static __inline void
2002 ieee80211_tx_rate_update(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
2003 struct ieee80211_tx_info *info)
2008 static __inline bool
2009 ieee80211_txq_may_transmit(struct ieee80211_hw *hw, struct ieee80211_txq *txq)
2015 static __inline struct ieee80211_txq *
2016 ieee80211_next_txq(struct ieee80211_hw *hw, uint32_t ac)
2022 static __inline void
2023 ieee80211_radar_detected(struct ieee80211_hw *hw)
2028 static __inline void
2029 ieee80211_sta_register_airtime(struct ieee80211_sta *sta,
2030 uint8_t tid, uint32_t duration, int x)
2036 static __inline void
2037 ieee80211_return_txq(struct ieee80211_hw *hw,
2038 struct ieee80211_txq *txq, bool _t)
2043 static __inline void
2044 ieee80211_txq_schedule_end(struct ieee80211_hw *hw, uint32_t ac)
2049 static __inline void
2050 ieee80211_txq_schedule_start(struct ieee80211_hw *hw, uint32_t ac)
2055 static __inline void
2056 ieee80211_schedule_txq(struct ieee80211_hw *hw, struct ieee80211_txq *txq)
2061 static __inline void
2062 ieee80211_beacon_set_cntdwn(struct ieee80211_vif *vif, u8 counter)
2068 ieee80211_beacon_update_cntdwn(struct ieee80211_vif *vif)
2075 ieee80211_get_vht_max_nss(struct ieee80211_vht_cap *vht_cap, uint32_t chanwidth,
2076 int x, bool t, int nss)
2082 static __inline bool
2083 ieee80211_beacon_cntdwn_is_complete(struct ieee80211_vif *vif)
2089 static __inline void
2090 ieee80211_disconnect(struct ieee80211_vif *vif, bool _x)
2095 static __inline void
2096 ieee80211_channel_switch_disconnect(struct ieee80211_vif *vif, bool _x)
2101 static __inline const struct ieee80211_sta_he_cap *
2102 ieee80211_get_he_iftype_cap(const struct ieee80211_supported_band *band,
2103 enum nl80211_iftype type)
2109 static __inline void
2110 ieee80211_key_mic_failure(struct ieee80211_key_conf *key)
2115 static __inline void
2116 ieee80211_key_replay(struct ieee80211_key_conf *key)
2121 #endif /* _LINUXKPI_NET_MAC80211_H */