1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Copyright 2002-2005, Instant802 Networks, Inc.
4 * Copyright 2005, Devicescape Software, Inc.
5 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
6 * Copyright 2007-2010 Johannes Berg <johannes@sipsolutions.net>
7 * Copyright 2013-2015 Intel Mobile Communications GmbH
8 * Copyright (C) 2018-2020 Intel Corporation
9 */
10
11 #ifndef IEEE80211_I_H
12 #define IEEE80211_I_H
13
14 #include <linux/kernel.h>
15 #include <linux/device.h>
16 #include <linux/if_ether.h>
17 #include <linux/interrupt.h>
18 #include <linux/list.h>
19 #include <linux/netdevice.h>
20 #include <linux/skbuff.h>
21 #include <linux/workqueue.h>
22 #include <linux/types.h>
23 #include <linux/spinlock.h>
24 #include <linux/etherdevice.h>
25 #include <linux/leds.h>
26 #include <linux/idr.h>
27 #include <linux/rhashtable.h>
28 #include <net/ieee80211_radiotap.h>
29 #include <net/cfg80211.h>
30 #include <net/mac80211.h>
31 #include <net/fq.h>
32 #include "key.h"
33 #include "sta_info.h"
34 #include "debug.h"
35
36 extern const struct cfg80211_ops mac80211_config_ops;
37
38 struct ieee80211_local;
39
40 /* Maximum number of broadcast/multicast frames to buffer when some of the
41 * associated stations are using power saving. */
42 #define AP_MAX_BC_BUFFER 128
43
44 /* Maximum number of frames buffered to all STAs, including multicast frames.
45 * Note: increasing this limit increases the potential memory requirement. Each
46 * frame can be up to about 2 kB long. */
47 #define TOTAL_MAX_TX_BUFFER 512
48
49 /* Required encryption head and tailroom */
50 #define IEEE80211_ENCRYPT_HEADROOM 8
51 #define IEEE80211_ENCRYPT_TAILROOM 18
52
53 /* power level hasn't been configured (or set to automatic) */
54 #define IEEE80211_UNSET_POWER_LEVEL INT_MIN
55
56 /*
57 * Some APs experience problems when working with U-APSD. Decreasing the
58 * probability of that happening by using legacy mode for all ACs but VO isn't
59 * enough.
60 *
61 * Cisco 4410N originally forced us to enable VO by default only because it
62 * treated non-VO ACs as legacy.
63 *
64 * However some APs (notably Netgear R7000) silently reclassify packets to
65 * different ACs. Since u-APSD ACs require trigger frames for frame retrieval
66 * clients would never see some frames (e.g. ARP responses) or would fetch them
67 * accidentally after a long time.
68 *
69 * It makes little sense to enable u-APSD queues by default because it needs
70 * userspace applications to be aware of it to actually take advantage of the
71 * possible additional powersavings. Implicitly depending on driver autotrigger
72 * frame support doesn't make much sense.
73 */
74 #define IEEE80211_DEFAULT_UAPSD_QUEUES 0
75
76 #define IEEE80211_DEFAULT_MAX_SP_LEN \
77 IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL
78
79 extern const u8 ieee80211_ac_to_qos_mask[IEEE80211_NUM_ACS];
80
81 #define IEEE80211_DEAUTH_FRAME_LEN (24 /* hdr */ + 2 /* reason */)
82
83 #define IEEE80211_MAX_NAN_INSTANCE_ID 255
84
85 struct ieee80211_bss {
86 u32 device_ts_beacon, device_ts_presp;
87
88 bool wmm_used;
89 bool uapsd_supported;
90
91 #define IEEE80211_MAX_SUPP_RATES 32
92 u8 supp_rates[IEEE80211_MAX_SUPP_RATES];
93 size_t supp_rates_len;
94 struct ieee80211_rate *beacon_rate;
95
96 u32 vht_cap_info;
97
98 /*
99 * During association, we save an ERP value from a probe response so
100 * that we can feed ERP info to the driver when handling the
101 * association completes. these fields probably won't be up-to-date
102 * otherwise, you probably don't want to use them.
103 */
104 bool has_erp_value;
105 u8 erp_value;
106
107 /* Keep track of the corruption of the last beacon/probe response. */
108 u8 corrupt_data;
109
110 /* Keep track of what bits of information we have valid info for. */
111 u8 valid_data;
112 };
113
114 /**
115 * enum ieee80211_corrupt_data_flags - BSS data corruption flags
116 * @IEEE80211_BSS_CORRUPT_BEACON: last beacon frame received was corrupted
117 * @IEEE80211_BSS_CORRUPT_PROBE_RESP: last probe response received was corrupted
118 *
119 * These are bss flags that are attached to a bss in the
120 * @corrupt_data field of &struct ieee80211_bss.
121 */
122 enum ieee80211_bss_corrupt_data_flags {
123 IEEE80211_BSS_CORRUPT_BEACON = BIT(0),
124 IEEE80211_BSS_CORRUPT_PROBE_RESP = BIT(1)
125 };
126
127 /**
128 * enum ieee80211_valid_data_flags - BSS valid data flags
129 * @IEEE80211_BSS_VALID_WMM: WMM/UAPSD data was gathered from non-corrupt IE
130 * @IEEE80211_BSS_VALID_RATES: Supported rates were gathered from non-corrupt IE
131 * @IEEE80211_BSS_VALID_ERP: ERP flag was gathered from non-corrupt IE
132 *
133 * These are bss flags that are attached to a bss in the
134 * @valid_data field of &struct ieee80211_bss. They show which parts
135 * of the data structure were received as a result of an un-corrupted
136 * beacon/probe response.
137 */
138 enum ieee80211_bss_valid_data_flags {
139 IEEE80211_BSS_VALID_WMM = BIT(1),
140 IEEE80211_BSS_VALID_RATES = BIT(2),
141 IEEE80211_BSS_VALID_ERP = BIT(3)
142 };
143
144 typedef unsigned __bitwise ieee80211_tx_result;
145 #define TX_CONTINUE ((__force ieee80211_tx_result) 0u)
146 #define TX_DROP ((__force ieee80211_tx_result) 1u)
147 #define TX_QUEUED ((__force ieee80211_tx_result) 2u)
148
149 #define IEEE80211_TX_UNICAST BIT(1)
150 #define IEEE80211_TX_PS_BUFFERED BIT(2)
151
152 struct ieee80211_tx_data {
153 struct sk_buff *skb;
154 struct sk_buff_head skbs;
155 struct ieee80211_local *local;
156 struct ieee80211_sub_if_data *sdata;
157 struct sta_info *sta;
158 struct ieee80211_key *key;
159 struct ieee80211_tx_rate rate;
160
161 unsigned int flags;
162 };
163
164
165 typedef unsigned __bitwise ieee80211_rx_result;
166 #define RX_CONTINUE ((__force ieee80211_rx_result) 0u)
167 #define RX_DROP_UNUSABLE ((__force ieee80211_rx_result) 1u)
168 #define RX_DROP_MONITOR ((__force ieee80211_rx_result) 2u)
169 #define RX_QUEUED ((__force ieee80211_rx_result) 3u)
170
171 /**
172 * enum ieee80211_packet_rx_flags - packet RX flags
173 * @IEEE80211_RX_AMSDU: a-MSDU packet
174 * @IEEE80211_RX_MALFORMED_ACTION_FRM: action frame is malformed
175 * @IEEE80211_RX_DEFERRED_RELEASE: frame was subjected to receive reordering
176 *
177 * These are per-frame flags that are attached to a frame in the
178 * @rx_flags field of &struct ieee80211_rx_status.
179 */
180 enum ieee80211_packet_rx_flags {
181 IEEE80211_RX_AMSDU = BIT(3),
182 IEEE80211_RX_MALFORMED_ACTION_FRM = BIT(4),
183 IEEE80211_RX_DEFERRED_RELEASE = BIT(5),
184 };
185
186 /**
187 * enum ieee80211_rx_flags - RX data flags
188 *
189 * @IEEE80211_RX_CMNTR: received on cooked monitor already
190 * @IEEE80211_RX_BEACON_REPORTED: This frame was already reported
191 * to cfg80211_report_obss_beacon().
192 *
193 * These flags are used across handling multiple interfaces
194 * for a single frame.
195 */
196 enum ieee80211_rx_flags {
197 IEEE80211_RX_CMNTR = BIT(0),
198 IEEE80211_RX_BEACON_REPORTED = BIT(1),
199 };
200
201 struct ieee80211_rx_data {
202 struct list_head *list;
203 struct sk_buff *skb;
204 struct ieee80211_local *local;
205 struct ieee80211_sub_if_data *sdata;
206 struct sta_info *sta;
207 struct ieee80211_key *key;
208
209 unsigned int flags;
210
211 /*
212 * Index into sequence numbers array, 0..16
213 * since the last (16) is used for non-QoS,
214 * will be 16 on non-QoS frames.
215 */
216 int seqno_idx;
217
218 /*
219 * Index into the security IV/PN arrays, 0..16
220 * since the last (16) is used for CCMP-encrypted
221 * management frames, will be set to 16 on mgmt
222 * frames and 0 on non-QoS frames.
223 */
224 int security_idx;
225
226 union {
227 struct {
228 u32 iv32;
229 u16 iv16;
230 } tkip;
231 struct {
232 u8 pn[IEEE80211_CCMP_PN_LEN];
233 } ccm_gcm;
234 };
235 };
236
237 struct ieee80211_csa_settings {
238 const u16 *counter_offsets_beacon;
239 const u16 *counter_offsets_presp;
240
241 int n_counter_offsets_beacon;
242 int n_counter_offsets_presp;
243
244 u8 count;
245 };
246
247 struct beacon_data {
248 u8 *head, *tail;
249 int head_len, tail_len;
250 struct ieee80211_meshconf_ie *meshconf;
251 u16 cntdwn_counter_offsets[IEEE80211_MAX_CNTDWN_COUNTERS_NUM];
252 u8 cntdwn_current_counter;
253 struct rcu_head rcu_head;
254 };
255
256 struct probe_resp {
257 struct rcu_head rcu_head;
258 int len;
259 u16 cntdwn_counter_offsets[IEEE80211_MAX_CNTDWN_COUNTERS_NUM];
260 u8 data[];
261 };
262
263 struct fils_discovery_data {
264 struct rcu_head rcu_head;
265 int len;
266 u8 data[];
267 };
268
269 struct unsol_bcast_probe_resp_data {
270 struct rcu_head rcu_head;
271 int len;
272 u8 data[];
273 };
274
275 struct ps_data {
276 /* yes, this looks ugly, but guarantees that we can later use
277 * bitmap_empty :)
278 * NB: don't touch this bitmap, use sta_info_{set,clear}_tim_bit */
279 u8 tim[sizeof(unsigned long) * BITS_TO_LONGS(IEEE80211_MAX_AID + 1)]
280 __aligned(__alignof__(unsigned long));
281 struct sk_buff_head bc_buf;
282 atomic_t num_sta_ps; /* number of stations in PS mode */
283 int dtim_count;
284 bool dtim_bc_mc;
285 };
286
287 struct ieee80211_if_ap {
288 struct beacon_data __rcu *beacon;
289 struct probe_resp __rcu *probe_resp;
290 struct fils_discovery_data __rcu *fils_discovery;
291 struct unsol_bcast_probe_resp_data __rcu *unsol_bcast_probe_resp;
292
293 /* to be used after channel switch. */
294 struct cfg80211_beacon_data *next_beacon;
295 struct list_head vlans; /* write-protected with RTNL and local->mtx */
296
297 struct ps_data ps;
298 atomic_t num_mcast_sta; /* number of stations receiving multicast */
299
300 bool multicast_to_unicast;
301 };
302
303 struct ieee80211_if_wds {
304 struct sta_info *sta;
305 u8 remote_addr[ETH_ALEN];
306 };
307
308 struct ieee80211_if_vlan {
309 struct list_head list; /* write-protected with RTNL and local->mtx */
310
311 /* used for all tx if the VLAN is configured to 4-addr mode */
312 struct sta_info __rcu *sta;
313 atomic_t num_mcast_sta; /* number of stations receiving multicast */
314 };
315
316 struct mesh_stats {
317 __u32 fwded_mcast; /* Mesh forwarded multicast frames */
318 __u32 fwded_unicast; /* Mesh forwarded unicast frames */
319 __u32 fwded_frames; /* Mesh total forwarded frames */
320 __u32 dropped_frames_ttl; /* Not transmitted since mesh_ttl == 0*/
321 __u32 dropped_frames_no_route; /* Not transmitted, no route found */
322 __u32 dropped_frames_congestion;/* Not forwarded due to congestion */
323 };
324
325 #define PREQ_Q_F_START 0x1
326 #define PREQ_Q_F_REFRESH 0x2
327 struct mesh_preq_queue {
328 struct list_head list;
329 u8 dst[ETH_ALEN];
330 u8 flags;
331 };
332
333 struct ieee80211_roc_work {
334 struct list_head list;
335
336 struct ieee80211_sub_if_data *sdata;
337
338 struct ieee80211_channel *chan;
339
340 bool started, abort, hw_begun, notified;
341 bool on_channel;
342
343 unsigned long start_time;
344
345 u32 duration, req_duration;
346 struct sk_buff *frame;
347 u64 cookie, mgmt_tx_cookie;
348 enum ieee80211_roc_type type;
349 };
350
351 /* flags used in struct ieee80211_if_managed.flags */
352 enum ieee80211_sta_flags {
353 IEEE80211_STA_CONNECTION_POLL = BIT(1),
354 IEEE80211_STA_CONTROL_PORT = BIT(2),
355 IEEE80211_STA_DISABLE_HT = BIT(4),
356 IEEE80211_STA_MFP_ENABLED = BIT(6),
357 IEEE80211_STA_UAPSD_ENABLED = BIT(7),
358 IEEE80211_STA_NULLFUNC_ACKED = BIT(8),
359 IEEE80211_STA_RESET_SIGNAL_AVE = BIT(9),
360 IEEE80211_STA_DISABLE_40MHZ = BIT(10),
361 IEEE80211_STA_DISABLE_VHT = BIT(11),
362 IEEE80211_STA_DISABLE_80P80MHZ = BIT(12),
363 IEEE80211_STA_DISABLE_160MHZ = BIT(13),
364 IEEE80211_STA_DISABLE_WMM = BIT(14),
365 IEEE80211_STA_ENABLE_RRM = BIT(15),
366 IEEE80211_STA_DISABLE_HE = BIT(16),
367 };
368
369 struct ieee80211_mgd_auth_data {
370 struct cfg80211_bss *bss;
371 unsigned long timeout;
372 int tries;
373 u16 algorithm, expected_transaction;
374
375 u8 key[WLAN_KEY_LEN_WEP104];
376 u8 key_len, key_idx;
377 bool done;
378 bool peer_confirmed;
379 bool timeout_started;
380
381 u16 sae_trans, sae_status;
382 size_t data_len;
383 u8 data[];
384 };
385
386 struct ieee80211_mgd_assoc_data {
387 struct cfg80211_bss *bss;
388 const u8 *supp_rates;
389
390 unsigned long timeout;
391 int tries;
392
393 u16 capability;
394 u8 prev_bssid[ETH_ALEN];
395 u8 ssid[IEEE80211_MAX_SSID_LEN];
396 u8 ssid_len;
397 u8 supp_rates_len;
398 bool wmm, uapsd;
399 bool need_beacon;
400 bool synced;
401 bool timeout_started;
402
403 u8 ap_ht_param;
404
405 struct ieee80211_vht_cap ap_vht_cap;
406
407 u8 fils_nonces[2 * FILS_NONCE_LEN];
408 u8 fils_kek[FILS_MAX_KEK_LEN];
409 size_t fils_kek_len;
410
411 size_t ie_len;
412 u8 ie[];
413 };
414
415 struct ieee80211_sta_tx_tspec {
416 /* timestamp of the first packet in the time slice */
417 unsigned long time_slice_start;
418
419 u32 admitted_time; /* in usecs, unlike over the air */
420 u8 tsid;
421 s8 up; /* signed to be able to invalidate with -1 during teardown */
422
423 /* consumed TX time in microseconds in the time slice */
424 u32 consumed_tx_time;
425 enum {
426 TX_TSPEC_ACTION_NONE = 0,
427 TX_TSPEC_ACTION_DOWNGRADE,
428 TX_TSPEC_ACTION_STOP_DOWNGRADE,
429 } action;
430 bool downgraded;
431 };
432
433 DECLARE_EWMA(beacon_signal, 4, 4)
434
435 struct ieee80211_if_managed {
436 struct timer_list timer;
437 struct timer_list conn_mon_timer;
438 struct timer_list bcn_mon_timer;
439 struct timer_list chswitch_timer;
440 struct work_struct monitor_work;
441 struct work_struct chswitch_work;
442 struct work_struct beacon_connection_loss_work;
443 struct work_struct csa_connection_drop_work;
444
445 unsigned long beacon_timeout;
446 unsigned long probe_timeout;
447 int probe_send_count;
448 bool nullfunc_failed;
449 bool connection_loss;
450
451 struct cfg80211_bss *associated;
452 struct ieee80211_mgd_auth_data *auth_data;
453 struct ieee80211_mgd_assoc_data *assoc_data;
454
455 u8 bssid[ETH_ALEN] __aligned(2);
456
457 bool powersave; /* powersave requested for this iface */
458 bool broken_ap; /* AP is broken -- turn off powersave */
459 bool have_beacon;
460 u8 dtim_period;
461 enum ieee80211_smps_mode req_smps, /* requested smps mode */
462 driver_smps_mode; /* smps mode request */
463
464 struct work_struct request_smps_work;
465
466 unsigned int flags;
467
468 bool csa_waiting_bcn;
469 bool csa_ignored_same_chan;
470
471 bool beacon_crc_valid;
472 u32 beacon_crc;
473
474 bool status_acked;
475 bool status_received;
476 __le16 status_fc;
477
478 enum {
479 IEEE80211_MFP_DISABLED,
480 IEEE80211_MFP_OPTIONAL,
481 IEEE80211_MFP_REQUIRED
482 } mfp; /* management frame protection */
483
484 /*
485 * Bitmask of enabled u-apsd queues,
486 * IEEE80211_WMM_IE_STA_QOSINFO_AC_BE & co. Needs a new association
487 * to take effect.
488 */
489 unsigned int uapsd_queues;
490
491 /*
492 * Maximum number of buffered frames AP can deliver during a
493 * service period, IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL or similar.
494 * Needs a new association to take effect.
495 */
496 unsigned int uapsd_max_sp_len;
497
498 int wmm_last_param_set;
499 int mu_edca_last_param_set;
500
501 u8 use_4addr;
502
503 s16 p2p_noa_index;
504
505 struct ewma_beacon_signal ave_beacon_signal;
506
507 /*
508 * Number of Beacon frames used in ave_beacon_signal. This can be used
509 * to avoid generating less reliable cqm events that would be based
510 * only on couple of received frames.
511 */
512 unsigned int count_beacon_signal;
513
514 /* Number of times beacon loss was invoked. */
515 unsigned int beacon_loss_count;
516
517 /*
518 * Last Beacon frame signal strength average (ave_beacon_signal / 16)
519 * that triggered a cqm event. 0 indicates that no event has been
520 * generated for the current association.
521 */
522 int last_cqm_event_signal;
523
524 /*
525 * State variables for keeping track of RSSI of the AP currently
526 * connected to and informing driver when RSSI has gone
527 * below/above a certain threshold.
528 */
529 int rssi_min_thold, rssi_max_thold;
530 int last_ave_beacon_signal;
531
532 struct ieee80211_ht_cap ht_capa; /* configured ht-cap over-rides */
533 struct ieee80211_ht_cap ht_capa_mask; /* Valid parts of ht_capa */
534 struct ieee80211_vht_cap vht_capa; /* configured VHT overrides */
535 struct ieee80211_vht_cap vht_capa_mask; /* Valid parts of vht_capa */
536 struct ieee80211_s1g_cap s1g_capa; /* configured S1G overrides */
537 struct ieee80211_s1g_cap s1g_capa_mask; /* valid s1g_capa bits */
538
539 /* TDLS support */
540 u8 tdls_peer[ETH_ALEN] __aligned(2);
541 struct delayed_work tdls_peer_del_work;
542 struct sk_buff *orig_teardown_skb; /* The original teardown skb */
543 struct sk_buff *teardown_skb; /* A copy to send through the AP */
544 spinlock_t teardown_lock; /* To lock changing teardown_skb */
545 bool tdls_chan_switch_prohibited;
546 bool tdls_wider_bw_prohibited;
547
548 /* WMM-AC TSPEC support */
549 struct ieee80211_sta_tx_tspec tx_tspec[IEEE80211_NUM_ACS];
550 /* Use a separate work struct so that we can do something here
551 * while the sdata->work is flushing the queues, for example.
552 * otherwise, in scenarios where we hardly get any traffic out
553 * on the BE queue, but there's a lot of VO traffic, we might
554 * get stuck in a downgraded situation and flush takes forever.
555 */
556 struct delayed_work tx_tspec_wk;
557
558 /* Information elements from the last transmitted (Re)Association
559 * Request frame.
560 */
561 u8 *assoc_req_ies;
562 size_t assoc_req_ies_len;
563 };
564
565 struct ieee80211_if_ibss {
566 struct timer_list timer;
567 struct work_struct csa_connection_drop_work;
568
569 unsigned long last_scan_completed;
570
571 u32 basic_rates;
572
573 bool fixed_bssid;
574 bool fixed_channel;
575 bool privacy;
576
577 bool control_port;
578 bool userspace_handles_dfs;
579
580 u8 bssid[ETH_ALEN] __aligned(2);
581 u8 ssid[IEEE80211_MAX_SSID_LEN];
582 u8 ssid_len, ie_len;
583 u8 *ie;
584 struct cfg80211_chan_def chandef;
585
586 unsigned long ibss_join_req;
587 /* probe response/beacon for IBSS */
588 struct beacon_data __rcu *presp;
589
590 struct ieee80211_ht_cap ht_capa; /* configured ht-cap over-rides */
591 struct ieee80211_ht_cap ht_capa_mask; /* Valid parts of ht_capa */
592
593 spinlock_t incomplete_lock;
594 struct list_head incomplete_stations;
595
596 enum {
597 IEEE80211_IBSS_MLME_SEARCH,
598 IEEE80211_IBSS_MLME_JOINED,
599 } state;
600 };
601
602 /**
603 * struct ieee80211_if_ocb - OCB mode state
604 *
605 * @housekeeping_timer: timer for periodic invocation of a housekeeping task
606 * @wrkq_flags: OCB deferred task action
607 * @incomplete_lock: delayed STA insertion lock
608 * @incomplete_stations: list of STAs waiting for delayed insertion
609 * @joined: indication if the interface is connected to an OCB network
610 */
611 struct ieee80211_if_ocb {
612 struct timer_list housekeeping_timer;
613 unsigned long wrkq_flags;
614
615 spinlock_t incomplete_lock;
616 struct list_head incomplete_stations;
617
618 bool joined;
619 };
620
621 /**
622 * struct ieee80211_mesh_sync_ops - Extensible synchronization framework interface
623 *
624 * these declarations define the interface, which enables
625 * vendor-specific mesh synchronization
626 *
627 */
628 struct ieee802_11_elems;
629 struct ieee80211_mesh_sync_ops {
630 void (*rx_bcn_presp)(struct ieee80211_sub_if_data *sdata,
631 u16 stype,
632 struct ieee80211_mgmt *mgmt,
633 struct ieee802_11_elems *elems,
634 struct ieee80211_rx_status *rx_status);
635
636 /* should be called with beacon_data under RCU read lock */
637 void (*adjust_tsf)(struct ieee80211_sub_if_data *sdata,
638 struct beacon_data *beacon);
639 /* add other framework functions here */
640 };
641
642 struct mesh_csa_settings {
643 struct rcu_head rcu_head;
644 struct cfg80211_csa_settings settings;
645 };
646
647 struct ieee80211_if_mesh {
648 struct timer_list housekeeping_timer;
649 struct timer_list mesh_path_timer;
650 struct timer_list mesh_path_root_timer;
651
652 unsigned long wrkq_flags;
653 unsigned long mbss_changed;
654
655 bool userspace_handles_dfs;
656
657 u8 mesh_id[IEEE80211_MAX_MESH_ID_LEN];
658 size_t mesh_id_len;
659 /* Active Path Selection Protocol Identifier */
660 u8 mesh_pp_id;
661 /* Active Path Selection Metric Identifier */
662 u8 mesh_pm_id;
663 /* Congestion Control Mode Identifier */
664 u8 mesh_cc_id;
665 /* Synchronization Protocol Identifier */
666 u8 mesh_sp_id;
667 /* Authentication Protocol Identifier */
668 u8 mesh_auth_id;
669 /* Local mesh Sequence Number */
670 u32 sn;
671 /* Last used PREQ ID */
672 u32 preq_id;
673 atomic_t mpaths;
674 /* Timestamp of last SN update */
675 unsigned long last_sn_update;
676 /* Time when it's ok to send next PERR */
677 unsigned long next_perr;
678 /* Timestamp of last PREQ sent */
679 unsigned long last_preq;
680 struct mesh_rmc *rmc;
681 spinlock_t mesh_preq_queue_lock;
682 struct mesh_preq_queue preq_queue;
683 int preq_queue_len;
684 struct mesh_stats mshstats;
685 struct mesh_config mshcfg;
686 atomic_t estab_plinks;
687 u32 mesh_seqnum;
688 bool accepting_plinks;
689 int num_gates;
690 struct beacon_data __rcu *beacon;
691 const u8 *ie;
692 u8 ie_len;
693 enum {
694 IEEE80211_MESH_SEC_NONE = 0x0,
695 IEEE80211_MESH_SEC_AUTHED = 0x1,
696 IEEE80211_MESH_SEC_SECURED = 0x2,
697 } security;
698 bool user_mpm;
699 /* Extensible Synchronization Framework */
700 const struct ieee80211_mesh_sync_ops *sync_ops;
701 s64 sync_offset_clockdrift_max;
702 spinlock_t sync_offset_lock;
703 /* mesh power save */
704 enum nl80211_mesh_power_mode nonpeer_pm;
705 int ps_peers_light_sleep;
706 int ps_peers_deep_sleep;
707 struct ps_data ps;
708 /* Channel Switching Support */
709 struct mesh_csa_settings __rcu *csa;
710 enum {
711 IEEE80211_MESH_CSA_ROLE_NONE,
712 IEEE80211_MESH_CSA_ROLE_INIT,
713 IEEE80211_MESH_CSA_ROLE_REPEATER,
714 } csa_role;
715 u8 chsw_ttl;
716 u16 pre_value;
717
718 /* offset from skb->data while building IE */
719 int meshconf_offset;
720
721 struct mesh_table *mesh_paths;
722 struct mesh_table *mpp_paths; /* Store paths for MPP&MAP */
723 int mesh_paths_generation;
724 int mpp_paths_generation;
725 };
726
727 #ifdef CONFIG_MAC80211_MESH
728 #define IEEE80211_IFSTA_MESH_CTR_INC(msh, name) \
729 do { (msh)->mshstats.name++; } while (0)
730 #else
731 #define IEEE80211_IFSTA_MESH_CTR_INC(msh, name) \
732 do { } while (0)
733 #endif
734
735 /**
736 * enum ieee80211_sub_if_data_flags - virtual interface flags
737 *
738 * @IEEE80211_SDATA_ALLMULTI: interface wants all multicast packets
739 * @IEEE80211_SDATA_OPERATING_GMODE: operating in G-only mode
740 * @IEEE80211_SDATA_DONT_BRIDGE_PACKETS: bridge packets between
741 * associated stations and deliver multicast frames both
742 * back to wireless media and to the local net stack.
743 * @IEEE80211_SDATA_DISCONNECT_RESUME: Disconnect after resume.
744 * @IEEE80211_SDATA_IN_DRIVER: indicates interface was added to driver
745 */
746 enum ieee80211_sub_if_data_flags {
747 IEEE80211_SDATA_ALLMULTI = BIT(0),
748 IEEE80211_SDATA_OPERATING_GMODE = BIT(2),
749 IEEE80211_SDATA_DONT_BRIDGE_PACKETS = BIT(3),
750 IEEE80211_SDATA_DISCONNECT_RESUME = BIT(4),
751 IEEE80211_SDATA_IN_DRIVER = BIT(5),
752 };
753
754 /**
755 * enum ieee80211_sdata_state_bits - virtual interface state bits
756 * @SDATA_STATE_RUNNING: virtual interface is up & running; this
757 * mirrors netif_running() but is separate for interface type
758 * change handling while the interface is up
759 * @SDATA_STATE_OFFCHANNEL: This interface is currently in offchannel
760 * mode, so queues are stopped
761 * @SDATA_STATE_OFFCHANNEL_BEACON_STOPPED: Beaconing was stopped due
762 * to offchannel, reset when offchannel returns
763 */
764 enum ieee80211_sdata_state_bits {
765 SDATA_STATE_RUNNING,
766 SDATA_STATE_OFFCHANNEL,
767 SDATA_STATE_OFFCHANNEL_BEACON_STOPPED,
768 };
769
770 /**
771 * enum ieee80211_chanctx_mode - channel context configuration mode
772 *
773 * @IEEE80211_CHANCTX_SHARED: channel context may be used by
774 * multiple interfaces
775 * @IEEE80211_CHANCTX_EXCLUSIVE: channel context can be used
776 * only by a single interface. This can be used for example for
777 * non-fixed channel IBSS.
778 */
779 enum ieee80211_chanctx_mode {
780 IEEE80211_CHANCTX_SHARED,
781 IEEE80211_CHANCTX_EXCLUSIVE
782 };
783
784 /**
785 * enum ieee80211_chanctx_replace_state - channel context replacement state
786 *
787 * This is used for channel context in-place reservations that require channel
788 * context switch/swap.
789 *
790 * @IEEE80211_CHANCTX_REPLACE_NONE: no replacement is taking place
791 * @IEEE80211_CHANCTX_WILL_BE_REPLACED: this channel context will be replaced
792 * by a (not yet registered) channel context pointed by %replace_ctx.
793 * @IEEE80211_CHANCTX_REPLACES_OTHER: this (not yet registered) channel context
794 * replaces an existing channel context pointed to by %replace_ctx.
795 */
796 enum ieee80211_chanctx_replace_state {
797 IEEE80211_CHANCTX_REPLACE_NONE,
798 IEEE80211_CHANCTX_WILL_BE_REPLACED,
799 IEEE80211_CHANCTX_REPLACES_OTHER,
800 };
801
802 struct ieee80211_chanctx {
803 struct list_head list;
804 struct rcu_head rcu_head;
805
806 struct list_head assigned_vifs;
807 struct list_head reserved_vifs;
808
809 enum ieee80211_chanctx_replace_state replace_state;
810 struct ieee80211_chanctx *replace_ctx;
811
812 enum ieee80211_chanctx_mode mode;
813 bool driver_present;
814
815 struct ieee80211_chanctx_conf conf;
816 };
817
818 struct mac80211_qos_map {
819 struct cfg80211_qos_map qos_map;
820 struct rcu_head rcu_head;
821 };
822
823 enum txq_info_flags {
824 IEEE80211_TXQ_STOP,
825 IEEE80211_TXQ_AMPDU,
826 IEEE80211_TXQ_NO_AMSDU,
827 IEEE80211_TXQ_STOP_NETIF_TX,
828 };
829
830 /**
831 * struct txq_info - per tid queue
832 *
833 * @tin: contains packets split into multiple flows
834 * @def_flow: used as a fallback flow when a packet destined to @tin hashes to
835 * a fq_flow which is already owned by a different tin
836 * @def_cvars: codel vars for @def_flow
837 * @frags: used to keep fragments created after dequeue
838 * @schedule_order: used with ieee80211_local->active_txqs
839 * @schedule_round: counter to prevent infinite loops on TXQ scheduling
840 */
841 struct txq_info {
842 struct fq_tin tin;
843 struct fq_flow def_flow;
844 struct codel_vars def_cvars;
845 struct codel_stats cstats;
846 struct sk_buff_head frags;
847 struct list_head schedule_order;
848 u16 schedule_round;
849 unsigned long flags;
850
851 /* keep last! */
852 struct ieee80211_txq txq;
853 };
854
855 struct ieee80211_if_mntr {
856 u32 flags;
857 u8 mu_follow_addr[ETH_ALEN] __aligned(2);
858
859 struct list_head list;
860 };
861
862 /**
863 * struct ieee80211_if_nan - NAN state
864 *
865 * @conf: current NAN configuration
866 * @func_ids: a bitmap of available instance_id's
867 */
868 struct ieee80211_if_nan {
869 struct cfg80211_nan_conf conf;
870
871 /* protects function_inst_ids */
872 spinlock_t func_lock;
873 struct idr function_inst_ids;
874 };
875
876 struct ieee80211_sub_if_data {
877 struct list_head list;
878
879 struct wireless_dev wdev;
880
881 /* keys */
882 struct list_head key_list;
883
884 /* count for keys needing tailroom space allocation */
885 int crypto_tx_tailroom_needed_cnt;
886 int crypto_tx_tailroom_pending_dec;
887 struct delayed_work dec_tailroom_needed_wk;
888
889 struct net_device *dev;
890 struct ieee80211_local *local;
891
892 unsigned int flags;
893
894 unsigned long state;
895
896 char name[IFNAMSIZ];
897
898 struct ieee80211_fragment_cache frags;
899
900 /* TID bitmap for NoAck policy */
901 u16 noack_map;
902
903 /* bit field of ACM bits (BIT(802.1D tag)) */
904 u8 wmm_acm;
905
906 struct ieee80211_key __rcu *keys[NUM_DEFAULT_KEYS +
907 NUM_DEFAULT_MGMT_KEYS +
908 NUM_DEFAULT_BEACON_KEYS];
909 struct ieee80211_key __rcu *default_unicast_key;
910 struct ieee80211_key __rcu *default_multicast_key;
911 struct ieee80211_key __rcu *default_mgmt_key;
912 struct ieee80211_key __rcu *default_beacon_key;
913
914 u16 sequence_number;
915 __be16 control_port_protocol;
916 bool control_port_no_encrypt;
917 bool control_port_no_preauth;
918 bool control_port_over_nl80211;
919 int encrypt_headroom;
920
921 atomic_t num_tx_queued;
922 struct ieee80211_tx_queue_params tx_conf[IEEE80211_NUM_ACS];
923 struct mac80211_qos_map __rcu *qos_map;
924
925 struct work_struct csa_finalize_work;
926 bool csa_block_tx; /* write-protected by sdata_lock and local->mtx */
927 struct cfg80211_chan_def csa_chandef;
928
929 struct list_head assigned_chanctx_list; /* protected by chanctx_mtx */
930 struct list_head reserved_chanctx_list; /* protected by chanctx_mtx */
931
932 /* context reservation -- protected with chanctx_mtx */
933 struct ieee80211_chanctx *reserved_chanctx;
934 struct cfg80211_chan_def reserved_chandef;
935 bool reserved_radar_required;
936 bool reserved_ready;
937
938 /* used to reconfigure hardware SM PS */
939 struct work_struct recalc_smps;
940
941 struct work_struct work;
942 struct sk_buff_head skb_queue;
943
944 u8 needed_rx_chains;
945 enum ieee80211_smps_mode smps_mode;
946
947 int user_power_level; /* in dBm */
948 int ap_power_level; /* in dBm */
949
950 bool radar_required;
951 struct delayed_work dfs_cac_timer_work;
952
953 /*
954 * AP this belongs to: self in AP mode and
955 * corresponding AP in VLAN mode, NULL for
956 * all others (might be needed later in IBSS)
957 */
958 struct ieee80211_if_ap *bss;
959
960 /* bitmap of allowed (non-MCS) rate indexes for rate control */
961 u32 rc_rateidx_mask[NUM_NL80211_BANDS];
962
963 bool rc_has_mcs_mask[NUM_NL80211_BANDS];
964 u8 rc_rateidx_mcs_mask[NUM_NL80211_BANDS][IEEE80211_HT_MCS_MASK_LEN];
965
966 bool rc_has_vht_mcs_mask[NUM_NL80211_BANDS];
967 u16 rc_rateidx_vht_mcs_mask[NUM_NL80211_BANDS][NL80211_VHT_NSS_MAX];
968
969 /* Beacon frame (non-MCS) rate (as a bitmap) */
970 u32 beacon_rateidx_mask[NUM_NL80211_BANDS];
971 bool beacon_rate_set;
972
973 union {
974 struct ieee80211_if_ap ap;
975 struct ieee80211_if_wds wds;
976 struct ieee80211_if_vlan vlan;
977 struct ieee80211_if_managed mgd;
978 struct ieee80211_if_ibss ibss;
979 struct ieee80211_if_mesh mesh;
980 struct ieee80211_if_ocb ocb;
981 struct ieee80211_if_mntr mntr;
982 struct ieee80211_if_nan nan;
983 } u;
984
985 #ifdef CONFIG_MAC80211_DEBUGFS
986 struct {
987 struct dentry *subdir_stations;
988 struct dentry *default_unicast_key;
989 struct dentry *default_multicast_key;
990 struct dentry *default_mgmt_key;
991 struct dentry *default_beacon_key;
992 } debugfs;
993 #endif
994
995 /* must be last, dynamically sized area in this! */
996 struct ieee80211_vif vif;
997 };
998
999 static inline
vif_to_sdata(struct ieee80211_vif * p)1000 struct ieee80211_sub_if_data *vif_to_sdata(struct ieee80211_vif *p)
1001 {
1002 return container_of(p, struct ieee80211_sub_if_data, vif);
1003 }
1004
sdata_lock(struct ieee80211_sub_if_data * sdata)1005 static inline void sdata_lock(struct ieee80211_sub_if_data *sdata)
1006 __acquires(&sdata->wdev.mtx)
1007 {
1008 mutex_lock(&sdata->wdev.mtx);
1009 __acquire(&sdata->wdev.mtx);
1010 }
1011
sdata_unlock(struct ieee80211_sub_if_data * sdata)1012 static inline void sdata_unlock(struct ieee80211_sub_if_data *sdata)
1013 __releases(&sdata->wdev.mtx)
1014 {
1015 mutex_unlock(&sdata->wdev.mtx);
1016 __release(&sdata->wdev.mtx);
1017 }
1018
1019 #define sdata_dereference(p, sdata) \
1020 rcu_dereference_protected(p, lockdep_is_held(&sdata->wdev.mtx))
1021
1022 static inline void
sdata_assert_lock(struct ieee80211_sub_if_data * sdata)1023 sdata_assert_lock(struct ieee80211_sub_if_data *sdata)
1024 {
1025 lockdep_assert_held(&sdata->wdev.mtx);
1026 }
1027
1028 static inline int
ieee80211_chandef_get_shift(struct cfg80211_chan_def * chandef)1029 ieee80211_chandef_get_shift(struct cfg80211_chan_def *chandef)
1030 {
1031 switch (chandef->width) {
1032 case NL80211_CHAN_WIDTH_5:
1033 return 2;
1034 case NL80211_CHAN_WIDTH_10:
1035 return 1;
1036 default:
1037 return 0;
1038 }
1039 }
1040
1041 static inline int
ieee80211_vif_get_shift(struct ieee80211_vif * vif)1042 ieee80211_vif_get_shift(struct ieee80211_vif *vif)
1043 {
1044 struct ieee80211_chanctx_conf *chanctx_conf;
1045 int shift = 0;
1046
1047 rcu_read_lock();
1048 chanctx_conf = rcu_dereference(vif->chanctx_conf);
1049 if (chanctx_conf)
1050 shift = ieee80211_chandef_get_shift(&chanctx_conf->def);
1051 rcu_read_unlock();
1052
1053 return shift;
1054 }
1055
1056 enum {
1057 IEEE80211_RX_MSG = 1,
1058 IEEE80211_TX_STATUS_MSG = 2,
1059 };
1060
1061 enum queue_stop_reason {
1062 IEEE80211_QUEUE_STOP_REASON_DRIVER,
1063 IEEE80211_QUEUE_STOP_REASON_PS,
1064 IEEE80211_QUEUE_STOP_REASON_CSA,
1065 IEEE80211_QUEUE_STOP_REASON_AGGREGATION,
1066 IEEE80211_QUEUE_STOP_REASON_SUSPEND,
1067 IEEE80211_QUEUE_STOP_REASON_SKB_ADD,
1068 IEEE80211_QUEUE_STOP_REASON_OFFCHANNEL,
1069 IEEE80211_QUEUE_STOP_REASON_FLUSH,
1070 IEEE80211_QUEUE_STOP_REASON_TDLS_TEARDOWN,
1071 IEEE80211_QUEUE_STOP_REASON_RESERVE_TID,
1072 IEEE80211_QUEUE_STOP_REASON_IFTYPE_CHANGE,
1073
1074 IEEE80211_QUEUE_STOP_REASONS,
1075 };
1076
1077 #ifdef CONFIG_MAC80211_LEDS
1078 struct tpt_led_trigger {
1079 char name[32];
1080 const struct ieee80211_tpt_blink *blink_table;
1081 unsigned int blink_table_len;
1082 struct timer_list timer;
1083 struct ieee80211_local *local;
1084 unsigned long prev_traffic;
1085 unsigned long tx_bytes, rx_bytes;
1086 unsigned int active, want;
1087 bool running;
1088 };
1089 #endif
1090
1091 /**
1092 * mac80211 scan flags - currently active scan mode
1093 *
1094 * @SCAN_SW_SCANNING: We're currently in the process of scanning but may as
1095 * well be on the operating channel
1096 * @SCAN_HW_SCANNING: The hardware is scanning for us, we have no way to
1097 * determine if we are on the operating channel or not
1098 * @SCAN_ONCHANNEL_SCANNING: Do a software scan on only the current operating
1099 * channel. This should not interrupt normal traffic.
1100 * @SCAN_COMPLETED: Set for our scan work function when the driver reported
1101 * that the scan completed.
1102 * @SCAN_ABORTED: Set for our scan work function when the driver reported
1103 * a scan complete for an aborted scan.
1104 * @SCAN_HW_CANCELLED: Set for our scan work function when the scan is being
1105 * cancelled.
1106 */
1107 enum {
1108 SCAN_SW_SCANNING,
1109 SCAN_HW_SCANNING,
1110 SCAN_ONCHANNEL_SCANNING,
1111 SCAN_COMPLETED,
1112 SCAN_ABORTED,
1113 SCAN_HW_CANCELLED,
1114 };
1115
1116 /**
1117 * enum mac80211_scan_state - scan state machine states
1118 *
1119 * @SCAN_DECISION: Main entry point to the scan state machine, this state
1120 * determines if we should keep on scanning or switch back to the
1121 * operating channel
1122 * @SCAN_SET_CHANNEL: Set the next channel to be scanned
1123 * @SCAN_SEND_PROBE: Send probe requests and wait for probe responses
1124 * @SCAN_SUSPEND: Suspend the scan and go back to operating channel to
1125 * send out data
1126 * @SCAN_RESUME: Resume the scan and scan the next channel
1127 * @SCAN_ABORT: Abort the scan and go back to operating channel
1128 */
1129 enum mac80211_scan_state {
1130 SCAN_DECISION,
1131 SCAN_SET_CHANNEL,
1132 SCAN_SEND_PROBE,
1133 SCAN_SUSPEND,
1134 SCAN_RESUME,
1135 SCAN_ABORT,
1136 };
1137
1138 struct ieee80211_local {
1139 /* embed the driver visible part.
1140 * don't cast (use the static inlines below), but we keep
1141 * it first anyway so they become a no-op */
1142 struct ieee80211_hw hw;
1143
1144 struct fq fq;
1145 struct codel_vars *cvars;
1146 struct codel_params cparams;
1147
1148 /* protects active_txqs and txqi->schedule_order */
1149 spinlock_t active_txq_lock[IEEE80211_NUM_ACS];
1150 struct list_head active_txqs[IEEE80211_NUM_ACS];
1151 u16 schedule_round[IEEE80211_NUM_ACS];
1152
1153 u16 airtime_flags;
1154 u32 aql_txq_limit_low[IEEE80211_NUM_ACS];
1155 u32 aql_txq_limit_high[IEEE80211_NUM_ACS];
1156 u32 aql_threshold;
1157 atomic_t aql_total_pending_airtime;
1158
1159 const struct ieee80211_ops *ops;
1160
1161 /*
1162 * private workqueue to mac80211. mac80211 makes this accessible
1163 * via ieee80211_queue_work()
1164 */
1165 struct workqueue_struct *workqueue;
1166
1167 unsigned long queue_stop_reasons[IEEE80211_MAX_QUEUES];
1168 int q_stop_reasons[IEEE80211_MAX_QUEUES][IEEE80211_QUEUE_STOP_REASONS];
1169 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
1170 spinlock_t queue_stop_reason_lock;
1171
1172 int open_count;
1173 int monitors, cooked_mntrs;
1174 /* number of interfaces with corresponding FIF_ flags */
1175 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
1176 fif_probe_req;
1177 bool probe_req_reg;
1178 bool rx_mcast_action_reg;
1179 unsigned int filter_flags; /* FIF_* */
1180
1181 bool wiphy_ciphers_allocated;
1182
1183 bool use_chanctx;
1184
1185 /* protects the aggregated multicast list and filter calls */
1186 spinlock_t filter_lock;
1187
1188 /* used for uploading changed mc list */
1189 struct work_struct reconfig_filter;
1190
1191 /* aggregated multicast list */
1192 struct netdev_hw_addr_list mc_list;
1193
1194 bool tim_in_locked_section; /* see ieee80211_beacon_get() */
1195
1196 /*
1197 * suspended is true if we finished all the suspend _and_ we have
1198 * not yet come up from resume. This is to be used by mac80211
1199 * to ensure driver sanity during suspend and mac80211's own
1200 * sanity. It can eventually be used for WoW as well.
1201 */
1202 bool suspended;
1203
1204 /*
1205 * Resuming is true while suspended, but when we're reprogramming the
1206 * hardware -- at that time it's allowed to use ieee80211_queue_work()
1207 * again even though some other parts of the stack are still suspended
1208 * and we still drop received frames to avoid waking the stack.
1209 */
1210 bool resuming;
1211
1212 /*
1213 * quiescing is true during the suspend process _only_ to
1214 * ease timer cancelling etc.
1215 */
1216 bool quiescing;
1217
1218 /* device is started */
1219 bool started;
1220
1221 /* device is during a HW reconfig */
1222 bool in_reconfig;
1223
1224 /* wowlan is enabled -- don't reconfig on resume */
1225 bool wowlan;
1226
1227 struct work_struct radar_detected_work;
1228
1229 /* number of RX chains the hardware has */
1230 u8 rx_chains;
1231
1232 /* bitmap of which sbands were copied */
1233 u8 sband_allocated;
1234
1235 int tx_headroom; /* required headroom for hardware/radiotap */
1236
1237 /* Tasklet and skb queue to process calls from IRQ mode. All frames
1238 * added to skb_queue will be processed, but frames in
1239 * skb_queue_unreliable may be dropped if the total length of these
1240 * queues increases over the limit. */
1241 #define IEEE80211_IRQSAFE_QUEUE_LIMIT 128
1242 struct tasklet_struct tasklet;
1243 struct sk_buff_head skb_queue;
1244 struct sk_buff_head skb_queue_unreliable;
1245
1246 spinlock_t rx_path_lock;
1247
1248 /* Station data */
1249 /*
1250 * The mutex only protects the list, hash table and
1251 * counter, reads are done with RCU.
1252 */
1253 struct mutex sta_mtx;
1254 spinlock_t tim_lock;
1255 unsigned long num_sta;
1256 struct list_head sta_list;
1257 struct rhltable sta_hash;
1258 struct timer_list sta_cleanup;
1259 int sta_generation;
1260
1261 struct sk_buff_head pending[IEEE80211_MAX_QUEUES];
1262 struct tasklet_struct tx_pending_tasklet;
1263 struct tasklet_struct wake_txqs_tasklet;
1264
1265 atomic_t agg_queue_stop[IEEE80211_MAX_QUEUES];
1266
1267 /* number of interfaces with allmulti RX */
1268 atomic_t iff_allmultis;
1269
1270 struct rate_control_ref *rate_ctrl;
1271
1272 struct arc4_ctx wep_tx_ctx;
1273 struct arc4_ctx wep_rx_ctx;
1274 u32 wep_iv;
1275
1276 /* see iface.c */
1277 struct list_head interfaces;
1278 struct list_head mon_list; /* only that are IFF_UP && !cooked */
1279 struct mutex iflist_mtx;
1280
1281 /*
1282 * Key mutex, protects sdata's key_list and sta_info's
1283 * key pointers and ptk_idx (write access, they're RCU.)
1284 */
1285 struct mutex key_mtx;
1286
1287 /* mutex for scan and work locking */
1288 struct mutex mtx;
1289
1290 /* Scanning and BSS list */
1291 unsigned long scanning;
1292 struct cfg80211_ssid scan_ssid;
1293 struct cfg80211_scan_request *int_scan_req;
1294 struct cfg80211_scan_request __rcu *scan_req;
1295 struct ieee80211_scan_request *hw_scan_req;
1296 struct cfg80211_chan_def scan_chandef;
1297 enum nl80211_band hw_scan_band;
1298 int scan_channel_idx;
1299 int scan_ies_len;
1300 int hw_scan_ies_bufsize;
1301 struct cfg80211_scan_info scan_info;
1302
1303 struct work_struct sched_scan_stopped_work;
1304 struct ieee80211_sub_if_data __rcu *sched_scan_sdata;
1305 struct cfg80211_sched_scan_request __rcu *sched_scan_req;
1306 u8 scan_addr[ETH_ALEN];
1307
1308 unsigned long leave_oper_channel_time;
1309 enum mac80211_scan_state next_scan_state;
1310 struct delayed_work scan_work;
1311 struct ieee80211_sub_if_data __rcu *scan_sdata;
1312 /* For backward compatibility only -- do not use */
1313 struct cfg80211_chan_def _oper_chandef;
1314
1315 /* Temporary remain-on-channel for off-channel operations */
1316 struct ieee80211_channel *tmp_channel;
1317
1318 /* channel contexts */
1319 struct list_head chanctx_list;
1320 struct mutex chanctx_mtx;
1321
1322 #ifdef CONFIG_MAC80211_LEDS
1323 struct led_trigger tx_led, rx_led, assoc_led, radio_led;
1324 struct led_trigger tpt_led;
1325 atomic_t tx_led_active, rx_led_active, assoc_led_active;
1326 atomic_t radio_led_active, tpt_led_active;
1327 struct tpt_led_trigger *tpt_led_trigger;
1328 #endif
1329
1330 #ifdef CONFIG_MAC80211_DEBUG_COUNTERS
1331 /* SNMP counters */
1332 /* dot11CountersTable */
1333 u32 dot11TransmittedFragmentCount;
1334 u32 dot11MulticastTransmittedFrameCount;
1335 u32 dot11FailedCount;
1336 u32 dot11RetryCount;
1337 u32 dot11MultipleRetryCount;
1338 u32 dot11FrameDuplicateCount;
1339 u32 dot11ReceivedFragmentCount;
1340 u32 dot11MulticastReceivedFrameCount;
1341 u32 dot11TransmittedFrameCount;
1342
1343 /* TX/RX handler statistics */
1344 unsigned int tx_handlers_drop;
1345 unsigned int tx_handlers_queued;
1346 unsigned int tx_handlers_drop_wep;
1347 unsigned int tx_handlers_drop_not_assoc;
1348 unsigned int tx_handlers_drop_unauth_port;
1349 unsigned int rx_handlers_drop;
1350 unsigned int rx_handlers_queued;
1351 unsigned int rx_handlers_drop_nullfunc;
1352 unsigned int rx_handlers_drop_defrag;
1353 unsigned int tx_expand_skb_head;
1354 unsigned int tx_expand_skb_head_cloned;
1355 unsigned int rx_expand_skb_head_defrag;
1356 unsigned int rx_handlers_fragments;
1357 unsigned int tx_status_drop;
1358 #define I802_DEBUG_INC(c) (c)++
1359 #else /* CONFIG_MAC80211_DEBUG_COUNTERS */
1360 #define I802_DEBUG_INC(c) do { } while (0)
1361 #endif /* CONFIG_MAC80211_DEBUG_COUNTERS */
1362
1363
1364 int total_ps_buffered; /* total number of all buffered unicast and
1365 * multicast packets for power saving stations
1366 */
1367
1368 bool pspolling;
1369 /*
1370 * PS can only be enabled when we have exactly one managed
1371 * interface (and monitors) in PS, this then points there.
1372 */
1373 struct ieee80211_sub_if_data *ps_sdata;
1374 struct work_struct dynamic_ps_enable_work;
1375 struct work_struct dynamic_ps_disable_work;
1376 struct timer_list dynamic_ps_timer;
1377 struct notifier_block ifa_notifier;
1378 struct notifier_block ifa6_notifier;
1379
1380 /*
1381 * The dynamic ps timeout configured from user space via WEXT -
1382 * this will override whatever chosen by mac80211 internally.
1383 */
1384 int dynamic_ps_forced_timeout;
1385
1386 int user_power_level; /* in dBm, for all interfaces */
1387
1388 enum ieee80211_smps_mode smps_mode;
1389
1390 struct work_struct restart_work;
1391
1392 #ifdef CONFIG_MAC80211_DEBUGFS
1393 struct local_debugfsdentries {
1394 struct dentry *rcdir;
1395 struct dentry *keys;
1396 } debugfs;
1397 bool force_tx_status;
1398 #endif
1399
1400 /*
1401 * Remain-on-channel support
1402 */
1403 struct delayed_work roc_work;
1404 struct list_head roc_list;
1405 struct work_struct hw_roc_start, hw_roc_done;
1406 unsigned long hw_roc_start_time;
1407 u64 roc_cookie_counter;
1408
1409 struct idr ack_status_frames;
1410 spinlock_t ack_status_lock;
1411
1412 struct ieee80211_sub_if_data __rcu *p2p_sdata;
1413
1414 /* virtual monitor interface */
1415 struct ieee80211_sub_if_data __rcu *monitor_sdata;
1416 struct cfg80211_chan_def monitor_chandef;
1417
1418 /* extended capabilities provided by mac80211 */
1419 u8 ext_capa[8];
1420
1421 /* TDLS channel switch */
1422 struct work_struct tdls_chsw_work;
1423 struct sk_buff_head skb_queue_tdls_chsw;
1424 };
1425
1426 static inline struct ieee80211_sub_if_data *
IEEE80211_DEV_TO_SUB_IF(struct net_device * dev)1427 IEEE80211_DEV_TO_SUB_IF(struct net_device *dev)
1428 {
1429 return netdev_priv(dev);
1430 }
1431
1432 static inline struct ieee80211_sub_if_data *
IEEE80211_WDEV_TO_SUB_IF(struct wireless_dev * wdev)1433 IEEE80211_WDEV_TO_SUB_IF(struct wireless_dev *wdev)
1434 {
1435 return container_of(wdev, struct ieee80211_sub_if_data, wdev);
1436 }
1437
1438 static inline struct ieee80211_supported_band *
ieee80211_get_sband(struct ieee80211_sub_if_data * sdata)1439 ieee80211_get_sband(struct ieee80211_sub_if_data *sdata)
1440 {
1441 struct ieee80211_local *local = sdata->local;
1442 struct ieee80211_chanctx_conf *chanctx_conf;
1443 enum nl80211_band band;
1444
1445 rcu_read_lock();
1446 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
1447
1448 if (!chanctx_conf) {
1449 rcu_read_unlock();
1450 return NULL;
1451 }
1452
1453 band = chanctx_conf->def.chan->band;
1454 rcu_read_unlock();
1455
1456 return local->hw.wiphy->bands[band];
1457 }
1458
1459 /* this struct holds the value parsing from channel switch IE */
1460 struct ieee80211_csa_ie {
1461 struct cfg80211_chan_def chandef;
1462 u8 mode;
1463 u8 count;
1464 u8 ttl;
1465 u16 pre_value;
1466 u16 reason_code;
1467 u32 max_switch_time;
1468 };
1469
1470 /* Parsed Information Elements */
1471 struct ieee802_11_elems {
1472 const u8 *ie_start;
1473 size_t total_len;
1474
1475 /* pointers to IEs */
1476 const struct ieee80211_tdls_lnkie *lnk_id;
1477 const struct ieee80211_ch_switch_timing *ch_sw_timing;
1478 const u8 *ext_capab;
1479 const u8 *ssid;
1480 const u8 *supp_rates;
1481 const u8 *ds_params;
1482 const struct ieee80211_tim_ie *tim;
1483 const u8 *challenge;
1484 const u8 *rsn;
1485 const u8 *rsnx;
1486 const u8 *erp_info;
1487 const u8 *ext_supp_rates;
1488 const u8 *wmm_info;
1489 const u8 *wmm_param;
1490 const struct ieee80211_ht_cap *ht_cap_elem;
1491 const struct ieee80211_ht_operation *ht_operation;
1492 const struct ieee80211_vht_cap *vht_cap_elem;
1493 const struct ieee80211_vht_operation *vht_operation;
1494 const struct ieee80211_meshconf_ie *mesh_config;
1495 const u8 *he_cap;
1496 const struct ieee80211_he_operation *he_operation;
1497 const struct ieee80211_he_spr *he_spr;
1498 const struct ieee80211_mu_edca_param_set *mu_edca_param_set;
1499 const struct ieee80211_he_6ghz_capa *he_6ghz_capa;
1500 const u8 *uora_element;
1501 const u8 *mesh_id;
1502 const u8 *peering;
1503 const __le16 *awake_window;
1504 const u8 *preq;
1505 const u8 *prep;
1506 const u8 *perr;
1507 const struct ieee80211_rann_ie *rann;
1508 const struct ieee80211_channel_sw_ie *ch_switch_ie;
1509 const struct ieee80211_ext_chansw_ie *ext_chansw_ie;
1510 const struct ieee80211_wide_bw_chansw_ie *wide_bw_chansw_ie;
1511 const u8 *max_channel_switch_time;
1512 const u8 *country_elem;
1513 const u8 *pwr_constr_elem;
1514 const u8 *cisco_dtpc_elem;
1515 const struct ieee80211_timeout_interval_ie *timeout_int;
1516 const u8 *opmode_notif;
1517 const struct ieee80211_sec_chan_offs_ie *sec_chan_offs;
1518 struct ieee80211_mesh_chansw_params_ie *mesh_chansw_params_ie;
1519 const struct ieee80211_bss_max_idle_period_ie *max_idle_period_ie;
1520 const struct ieee80211_multiple_bssid_configuration *mbssid_config_ie;
1521 const struct ieee80211_bssid_index *bssid_index;
1522 u8 max_bssid_indicator;
1523 u8 dtim_count;
1524 u8 dtim_period;
1525 const struct ieee80211_addba_ext_ie *addba_ext_ie;
1526 const struct ieee80211_s1g_cap *s1g_capab;
1527 const struct ieee80211_s1g_oper_ie *s1g_oper;
1528 const struct ieee80211_s1g_bcn_compat_ie *s1g_bcn_compat;
1529 const struct ieee80211_aid_response_ie *aid_resp;
1530
1531 /* length of them, respectively */
1532 u8 ext_capab_len;
1533 u8 ssid_len;
1534 u8 supp_rates_len;
1535 u8 tim_len;
1536 u8 challenge_len;
1537 u8 rsn_len;
1538 u8 rsnx_len;
1539 u8 ext_supp_rates_len;
1540 u8 wmm_info_len;
1541 u8 wmm_param_len;
1542 u8 he_cap_len;
1543 u8 mesh_id_len;
1544 u8 peering_len;
1545 u8 preq_len;
1546 u8 prep_len;
1547 u8 perr_len;
1548 u8 country_elem_len;
1549 u8 bssid_index_len;
1550
1551 void *nontx_profile;
1552
1553 /* whether a parse error occurred while retrieving these elements */
1554 bool parse_error;
1555 };
1556
hw_to_local(struct ieee80211_hw * hw)1557 static inline struct ieee80211_local *hw_to_local(
1558 struct ieee80211_hw *hw)
1559 {
1560 return container_of(hw, struct ieee80211_local, hw);
1561 }
1562
to_txq_info(struct ieee80211_txq * txq)1563 static inline struct txq_info *to_txq_info(struct ieee80211_txq *txq)
1564 {
1565 return container_of(txq, struct txq_info, txq);
1566 }
1567
txq_has_queue(struct ieee80211_txq * txq)1568 static inline bool txq_has_queue(struct ieee80211_txq *txq)
1569 {
1570 struct txq_info *txqi = to_txq_info(txq);
1571
1572 return !(skb_queue_empty(&txqi->frags) && !txqi->tin.backlog_packets);
1573 }
1574
ieee80211_bssid_match(const u8 * raddr,const u8 * addr)1575 static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr)
1576 {
1577 return ether_addr_equal(raddr, addr) ||
1578 is_broadcast_ether_addr(raddr);
1579 }
1580
1581 static inline bool
ieee80211_have_rx_timestamp(struct ieee80211_rx_status * status)1582 ieee80211_have_rx_timestamp(struct ieee80211_rx_status *status)
1583 {
1584 WARN_ON_ONCE(status->flag & RX_FLAG_MACTIME_START &&
1585 status->flag & RX_FLAG_MACTIME_END);
1586 if (status->flag & (RX_FLAG_MACTIME_START | RX_FLAG_MACTIME_END))
1587 return true;
1588 /* can't handle non-legacy preamble yet */
1589 if (status->flag & RX_FLAG_MACTIME_PLCP_START &&
1590 status->encoding == RX_ENC_LEGACY)
1591 return true;
1592 return false;
1593 }
1594
1595 void ieee80211_vif_inc_num_mcast(struct ieee80211_sub_if_data *sdata);
1596 void ieee80211_vif_dec_num_mcast(struct ieee80211_sub_if_data *sdata);
1597
1598 /* This function returns the number of multicast stations connected to this
1599 * interface. It returns -1 if that number is not tracked, that is for netdevs
1600 * not in AP or AP_VLAN mode or when using 4addr.
1601 */
1602 static inline int
ieee80211_vif_get_num_mcast_if(struct ieee80211_sub_if_data * sdata)1603 ieee80211_vif_get_num_mcast_if(struct ieee80211_sub_if_data *sdata)
1604 {
1605 if (sdata->vif.type == NL80211_IFTYPE_AP)
1606 return atomic_read(&sdata->u.ap.num_mcast_sta);
1607 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN && !sdata->u.vlan.sta)
1608 return atomic_read(&sdata->u.vlan.num_mcast_sta);
1609 return -1;
1610 }
1611
1612 u64 ieee80211_calculate_rx_timestamp(struct ieee80211_local *local,
1613 struct ieee80211_rx_status *status,
1614 unsigned int mpdu_len,
1615 unsigned int mpdu_offset);
1616 int ieee80211_hw_config(struct ieee80211_local *local, u32 changed);
1617 void ieee80211_tx_set_protected(struct ieee80211_tx_data *tx);
1618 void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
1619 u32 changed);
1620 void ieee80211_configure_filter(struct ieee80211_local *local);
1621 u32 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata);
1622
1623 u64 ieee80211_mgmt_tx_cookie(struct ieee80211_local *local);
1624 int ieee80211_attach_ack_skb(struct ieee80211_local *local, struct sk_buff *skb,
1625 u64 *cookie, gfp_t gfp);
1626
1627 void ieee80211_check_fast_rx(struct sta_info *sta);
1628 void __ieee80211_check_fast_rx_iface(struct ieee80211_sub_if_data *sdata);
1629 void ieee80211_check_fast_rx_iface(struct ieee80211_sub_if_data *sdata);
1630 void ieee80211_clear_fast_rx(struct sta_info *sta);
1631
1632 /* STA code */
1633 void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata);
1634 int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata,
1635 struct cfg80211_auth_request *req);
1636 int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
1637 struct cfg80211_assoc_request *req);
1638 int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata,
1639 struct cfg80211_deauth_request *req);
1640 int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata,
1641 struct cfg80211_disassoc_request *req);
1642 void ieee80211_send_pspoll(struct ieee80211_local *local,
1643 struct ieee80211_sub_if_data *sdata);
1644 void ieee80211_recalc_ps(struct ieee80211_local *local);
1645 void ieee80211_recalc_ps_vif(struct ieee80211_sub_if_data *sdata);
1646 int ieee80211_set_arp_filter(struct ieee80211_sub_if_data *sdata);
1647 void ieee80211_sta_work(struct ieee80211_sub_if_data *sdata);
1648 void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
1649 struct sk_buff *skb);
1650 void ieee80211_sta_rx_queued_ext(struct ieee80211_sub_if_data *sdata,
1651 struct sk_buff *skb);
1652 void ieee80211_sta_reset_beacon_monitor(struct ieee80211_sub_if_data *sdata);
1653 void ieee80211_sta_reset_conn_monitor(struct ieee80211_sub_if_data *sdata);
1654 void ieee80211_mgd_stop(struct ieee80211_sub_if_data *sdata);
1655 void ieee80211_mgd_conn_tx_status(struct ieee80211_sub_if_data *sdata,
1656 __le16 fc, bool acked);
1657 void ieee80211_mgd_quiesce(struct ieee80211_sub_if_data *sdata);
1658 void ieee80211_sta_restart(struct ieee80211_sub_if_data *sdata);
1659 void ieee80211_sta_handle_tspec_ac_params(struct ieee80211_sub_if_data *sdata);
1660
1661 /* IBSS code */
1662 void ieee80211_ibss_notify_scan_completed(struct ieee80211_local *local);
1663 void ieee80211_ibss_setup_sdata(struct ieee80211_sub_if_data *sdata);
1664 void ieee80211_ibss_rx_no_sta(struct ieee80211_sub_if_data *sdata,
1665 const u8 *bssid, const u8 *addr, u32 supp_rates);
1666 int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata,
1667 struct cfg80211_ibss_params *params);
1668 int ieee80211_ibss_leave(struct ieee80211_sub_if_data *sdata);
1669 void ieee80211_ibss_work(struct ieee80211_sub_if_data *sdata);
1670 void ieee80211_ibss_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
1671 struct sk_buff *skb);
1672 int ieee80211_ibss_csa_beacon(struct ieee80211_sub_if_data *sdata,
1673 struct cfg80211_csa_settings *csa_settings);
1674 int ieee80211_ibss_finish_csa(struct ieee80211_sub_if_data *sdata);
1675 void ieee80211_ibss_stop(struct ieee80211_sub_if_data *sdata);
1676
1677 /* OCB code */
1678 void ieee80211_ocb_work(struct ieee80211_sub_if_data *sdata);
1679 void ieee80211_ocb_rx_no_sta(struct ieee80211_sub_if_data *sdata,
1680 const u8 *bssid, const u8 *addr, u32 supp_rates);
1681 void ieee80211_ocb_setup_sdata(struct ieee80211_sub_if_data *sdata);
1682 int ieee80211_ocb_join(struct ieee80211_sub_if_data *sdata,
1683 struct ocb_setup *setup);
1684 int ieee80211_ocb_leave(struct ieee80211_sub_if_data *sdata);
1685
1686 /* mesh code */
1687 void ieee80211_mesh_work(struct ieee80211_sub_if_data *sdata);
1688 void ieee80211_mesh_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
1689 struct sk_buff *skb);
1690 int ieee80211_mesh_csa_beacon(struct ieee80211_sub_if_data *sdata,
1691 struct cfg80211_csa_settings *csa_settings);
1692 int ieee80211_mesh_finish_csa(struct ieee80211_sub_if_data *sdata);
1693
1694 /* scan/BSS handling */
1695 void ieee80211_scan_work(struct work_struct *work);
1696 int ieee80211_request_ibss_scan(struct ieee80211_sub_if_data *sdata,
1697 const u8 *ssid, u8 ssid_len,
1698 struct ieee80211_channel **channels,
1699 unsigned int n_channels,
1700 enum nl80211_bss_scan_width scan_width);
1701 int ieee80211_request_scan(struct ieee80211_sub_if_data *sdata,
1702 struct cfg80211_scan_request *req);
1703 void ieee80211_scan_cancel(struct ieee80211_local *local);
1704 void ieee80211_run_deferred_scan(struct ieee80211_local *local);
1705 void ieee80211_scan_rx(struct ieee80211_local *local, struct sk_buff *skb);
1706
1707 void ieee80211_mlme_notify_scan_completed(struct ieee80211_local *local);
1708 struct ieee80211_bss *
1709 ieee80211_bss_info_update(struct ieee80211_local *local,
1710 struct ieee80211_rx_status *rx_status,
1711 struct ieee80211_mgmt *mgmt,
1712 size_t len,
1713 struct ieee80211_channel *channel);
1714 void ieee80211_rx_bss_put(struct ieee80211_local *local,
1715 struct ieee80211_bss *bss);
1716
1717 /* scheduled scan handling */
1718 int
1719 __ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata,
1720 struct cfg80211_sched_scan_request *req);
1721 int ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata,
1722 struct cfg80211_sched_scan_request *req);
1723 int ieee80211_request_sched_scan_stop(struct ieee80211_local *local);
1724 void ieee80211_sched_scan_end(struct ieee80211_local *local);
1725 void ieee80211_sched_scan_stopped_work(struct work_struct *work);
1726
1727 /* off-channel/mgmt-tx */
1728 void ieee80211_offchannel_stop_vifs(struct ieee80211_local *local);
1729 void ieee80211_offchannel_return(struct ieee80211_local *local);
1730 void ieee80211_roc_setup(struct ieee80211_local *local);
1731 void ieee80211_start_next_roc(struct ieee80211_local *local);
1732 void ieee80211_roc_purge(struct ieee80211_local *local,
1733 struct ieee80211_sub_if_data *sdata);
1734 int ieee80211_remain_on_channel(struct wiphy *wiphy, struct wireless_dev *wdev,
1735 struct ieee80211_channel *chan,
1736 unsigned int duration, u64 *cookie);
1737 int ieee80211_cancel_remain_on_channel(struct wiphy *wiphy,
1738 struct wireless_dev *wdev, u64 cookie);
1739 int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
1740 struct cfg80211_mgmt_tx_params *params, u64 *cookie);
1741 int ieee80211_mgmt_tx_cancel_wait(struct wiphy *wiphy,
1742 struct wireless_dev *wdev, u64 cookie);
1743
1744 /* channel switch handling */
1745 void ieee80211_csa_finalize_work(struct work_struct *work);
1746 int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
1747 struct cfg80211_csa_settings *params);
1748
1749 /* interface handling */
1750 #define MAC80211_SUPPORTED_FEATURES_TX (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | \
1751 NETIF_F_HW_CSUM | NETIF_F_SG | \
1752 NETIF_F_HIGHDMA | NETIF_F_GSO_SOFTWARE)
1753 #define MAC80211_SUPPORTED_FEATURES_RX (NETIF_F_RXCSUM)
1754 #define MAC80211_SUPPORTED_FEATURES (MAC80211_SUPPORTED_FEATURES_TX | \
1755 MAC80211_SUPPORTED_FEATURES_RX)
1756
1757 int ieee80211_iface_init(void);
1758 void ieee80211_iface_exit(void);
1759 int ieee80211_if_add(struct ieee80211_local *local, const char *name,
1760 unsigned char name_assign_type,
1761 struct wireless_dev **new_wdev, enum nl80211_iftype type,
1762 struct vif_params *params);
1763 int ieee80211_if_change_type(struct ieee80211_sub_if_data *sdata,
1764 enum nl80211_iftype type);
1765 void ieee80211_if_remove(struct ieee80211_sub_if_data *sdata);
1766 void ieee80211_remove_interfaces(struct ieee80211_local *local);
1767 u32 ieee80211_idle_off(struct ieee80211_local *local);
1768 void ieee80211_recalc_idle(struct ieee80211_local *local);
1769 void ieee80211_adjust_monitor_flags(struct ieee80211_sub_if_data *sdata,
1770 const int offset);
1771 int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up);
1772 void ieee80211_sdata_stop(struct ieee80211_sub_if_data *sdata);
1773 int ieee80211_add_virtual_monitor(struct ieee80211_local *local);
1774 void ieee80211_del_virtual_monitor(struct ieee80211_local *local);
1775
1776 bool __ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata);
1777 void ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata,
1778 bool update_bss);
1779 void ieee80211_recalc_offload(struct ieee80211_local *local);
1780
ieee80211_sdata_running(struct ieee80211_sub_if_data * sdata)1781 static inline bool ieee80211_sdata_running(struct ieee80211_sub_if_data *sdata)
1782 {
1783 return test_bit(SDATA_STATE_RUNNING, &sdata->state);
1784 }
1785
1786 /* tx handling */
1787 void ieee80211_clear_tx_pending(struct ieee80211_local *local);
1788 void ieee80211_tx_pending(unsigned long data);
1789 netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb,
1790 struct net_device *dev);
1791 netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1792 struct net_device *dev);
1793 netdev_tx_t ieee80211_subif_start_xmit_8023(struct sk_buff *skb,
1794 struct net_device *dev);
1795 void __ieee80211_subif_start_xmit(struct sk_buff *skb,
1796 struct net_device *dev,
1797 u32 info_flags,
1798 u32 ctrl_flags,
1799 u64 *cookie);
1800 void ieee80211_purge_tx_queue(struct ieee80211_hw *hw,
1801 struct sk_buff_head *skbs);
1802 struct sk_buff *
1803 ieee80211_build_data_template(struct ieee80211_sub_if_data *sdata,
1804 struct sk_buff *skb, u32 info_flags);
1805 void ieee80211_tx_monitor(struct ieee80211_local *local, struct sk_buff *skb,
1806 struct ieee80211_supported_band *sband,
1807 int retry_count, int shift, bool send_to_cooked,
1808 struct ieee80211_tx_status *status);
1809
1810 void ieee80211_check_fast_xmit(struct sta_info *sta);
1811 void ieee80211_check_fast_xmit_all(struct ieee80211_local *local);
1812 void ieee80211_check_fast_xmit_iface(struct ieee80211_sub_if_data *sdata);
1813 void ieee80211_clear_fast_xmit(struct sta_info *sta);
1814 int ieee80211_tx_control_port(struct wiphy *wiphy, struct net_device *dev,
1815 const u8 *buf, size_t len,
1816 const u8 *dest, __be16 proto, bool unencrypted,
1817 u64 *cookie);
1818 int ieee80211_probe_mesh_link(struct wiphy *wiphy, struct net_device *dev,
1819 const u8 *buf, size_t len);
1820
1821 /* HT */
1822 void ieee80211_apply_htcap_overrides(struct ieee80211_sub_if_data *sdata,
1823 struct ieee80211_sta_ht_cap *ht_cap);
1824 bool ieee80211_ht_cap_ie_to_sta_ht_cap(struct ieee80211_sub_if_data *sdata,
1825 struct ieee80211_supported_band *sband,
1826 const struct ieee80211_ht_cap *ht_cap_ie,
1827 struct sta_info *sta);
1828 void ieee80211_send_delba(struct ieee80211_sub_if_data *sdata,
1829 const u8 *da, u16 tid,
1830 u16 initiator, u16 reason_code);
1831 int ieee80211_send_smps_action(struct ieee80211_sub_if_data *sdata,
1832 enum ieee80211_smps_mode smps, const u8 *da,
1833 const u8 *bssid);
1834 void ieee80211_request_smps_ap_work(struct work_struct *work);
1835 void ieee80211_request_smps_mgd_work(struct work_struct *work);
1836 bool ieee80211_smps_is_restrictive(enum ieee80211_smps_mode smps_mode_old,
1837 enum ieee80211_smps_mode smps_mode_new);
1838
1839 void ___ieee80211_stop_rx_ba_session(struct sta_info *sta, u16 tid,
1840 u16 initiator, u16 reason, bool stop);
1841 void __ieee80211_stop_rx_ba_session(struct sta_info *sta, u16 tid,
1842 u16 initiator, u16 reason, bool stop);
1843 void ___ieee80211_start_rx_ba_session(struct sta_info *sta,
1844 u8 dialog_token, u16 timeout,
1845 u16 start_seq_num, u16 ba_policy, u16 tid,
1846 u16 buf_size, bool tx, bool auto_seq,
1847 const struct ieee80211_addba_ext_ie *addbaext);
1848 void ieee80211_sta_tear_down_BA_sessions(struct sta_info *sta,
1849 enum ieee80211_agg_stop_reason reason);
1850 void ieee80211_process_delba(struct ieee80211_sub_if_data *sdata,
1851 struct sta_info *sta,
1852 struct ieee80211_mgmt *mgmt, size_t len);
1853 void ieee80211_process_addba_resp(struct ieee80211_local *local,
1854 struct sta_info *sta,
1855 struct ieee80211_mgmt *mgmt,
1856 size_t len);
1857 void ieee80211_process_addba_request(struct ieee80211_local *local,
1858 struct sta_info *sta,
1859 struct ieee80211_mgmt *mgmt,
1860 size_t len);
1861
1862 int __ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid,
1863 enum ieee80211_agg_stop_reason reason);
1864 int ___ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid,
1865 enum ieee80211_agg_stop_reason reason);
1866 void ieee80211_start_tx_ba_cb(struct sta_info *sta, int tid,
1867 struct tid_ampdu_tx *tid_tx);
1868 void ieee80211_stop_tx_ba_cb(struct sta_info *sta, int tid,
1869 struct tid_ampdu_tx *tid_tx);
1870 void ieee80211_ba_session_work(struct work_struct *work);
1871 void ieee80211_tx_ba_session_handle_start(struct sta_info *sta, int tid);
1872 void ieee80211_release_reorder_timeout(struct sta_info *sta, int tid);
1873
1874 u8 ieee80211_mcs_to_chains(const struct ieee80211_mcs_info *mcs);
1875 enum nl80211_smps_mode
1876 ieee80211_smps_mode_to_smps_mode(enum ieee80211_smps_mode smps);
1877
1878 /* VHT */
1879 void
1880 ieee80211_vht_cap_ie_to_sta_vht_cap(struct ieee80211_sub_if_data *sdata,
1881 struct ieee80211_supported_band *sband,
1882 const struct ieee80211_vht_cap *vht_cap_ie,
1883 struct sta_info *sta);
1884 enum ieee80211_sta_rx_bandwidth ieee80211_sta_cap_rx_bw(struct sta_info *sta);
1885 enum ieee80211_sta_rx_bandwidth ieee80211_sta_cur_vht_bw(struct sta_info *sta);
1886 void ieee80211_sta_set_rx_nss(struct sta_info *sta);
1887 enum ieee80211_sta_rx_bandwidth
1888 ieee80211_chan_width_to_rx_bw(enum nl80211_chan_width width);
1889 enum nl80211_chan_width ieee80211_sta_cap_chan_bw(struct sta_info *sta);
1890 void ieee80211_sta_set_rx_nss(struct sta_info *sta);
1891 void ieee80211_process_mu_groups(struct ieee80211_sub_if_data *sdata,
1892 struct ieee80211_mgmt *mgmt);
1893 u32 __ieee80211_vht_handle_opmode(struct ieee80211_sub_if_data *sdata,
1894 struct sta_info *sta, u8 opmode,
1895 enum nl80211_band band);
1896 void ieee80211_vht_handle_opmode(struct ieee80211_sub_if_data *sdata,
1897 struct sta_info *sta, u8 opmode,
1898 enum nl80211_band band);
1899 void ieee80211_apply_vhtcap_overrides(struct ieee80211_sub_if_data *sdata,
1900 struct ieee80211_sta_vht_cap *vht_cap);
1901 void ieee80211_get_vht_mask_from_cap(__le16 vht_cap,
1902 u16 vht_mask[NL80211_VHT_NSS_MAX]);
1903 enum nl80211_chan_width
1904 ieee80211_sta_rx_bw_to_chan_width(struct sta_info *sta);
1905
1906 /* HE */
1907 void
1908 ieee80211_he_cap_ie_to_sta_he_cap(struct ieee80211_sub_if_data *sdata,
1909 struct ieee80211_supported_band *sband,
1910 const u8 *he_cap_ie, u8 he_cap_len,
1911 const struct ieee80211_he_6ghz_capa *he_6ghz_capa,
1912 struct sta_info *sta);
1913 void
1914 ieee80211_he_spr_ie_to_bss_conf(struct ieee80211_vif *vif,
1915 const struct ieee80211_he_spr *he_spr_ie_elem);
1916
1917 void
1918 ieee80211_he_op_ie_to_bss_conf(struct ieee80211_vif *vif,
1919 const struct ieee80211_he_operation *he_op_ie_elem);
1920
1921 /* S1G */
1922 void ieee80211_s1g_sta_rate_init(struct sta_info *sta);
1923
1924 /* Spectrum management */
1925 void ieee80211_process_measurement_req(struct ieee80211_sub_if_data *sdata,
1926 struct ieee80211_mgmt *mgmt,
1927 size_t len);
1928 /**
1929 * ieee80211_parse_ch_switch_ie - parses channel switch IEs
1930 * @sdata: the sdata of the interface which has received the frame
1931 * @elems: parsed 802.11 elements received with the frame
1932 * @current_band: indicates the current band
1933 * @vht_cap_info: VHT capabilities of the transmitter
1934 * @sta_flags: contains information about own capabilities and restrictions
1935 * to decide which channel switch announcements can be accepted. Only the
1936 * following subset of &enum ieee80211_sta_flags are evaluated:
1937 * %IEEE80211_STA_DISABLE_HT, %IEEE80211_STA_DISABLE_VHT,
1938 * %IEEE80211_STA_DISABLE_40MHZ, %IEEE80211_STA_DISABLE_80P80MHZ,
1939 * %IEEE80211_STA_DISABLE_160MHZ.
1940 * @bssid: the currently connected bssid (for reporting)
1941 * @csa_ie: parsed 802.11 csa elements on count, mode, chandef and mesh ttl.
1942 All of them will be filled with if success only.
1943 * Return: 0 on success, <0 on error and >0 if there is nothing to parse.
1944 */
1945 int ieee80211_parse_ch_switch_ie(struct ieee80211_sub_if_data *sdata,
1946 struct ieee802_11_elems *elems,
1947 enum nl80211_band current_band,
1948 u32 vht_cap_info,
1949 u32 sta_flags, u8 *bssid,
1950 struct ieee80211_csa_ie *csa_ie);
1951
1952 /* Suspend/resume and hw reconfiguration */
1953 int ieee80211_reconfig(struct ieee80211_local *local);
1954 void ieee80211_stop_device(struct ieee80211_local *local);
1955
1956 int __ieee80211_suspend(struct ieee80211_hw *hw,
1957 struct cfg80211_wowlan *wowlan);
1958
__ieee80211_resume(struct ieee80211_hw * hw)1959 static inline int __ieee80211_resume(struct ieee80211_hw *hw)
1960 {
1961 struct ieee80211_local *local = hw_to_local(hw);
1962
1963 WARN(test_bit(SCAN_HW_SCANNING, &local->scanning) &&
1964 !test_bit(SCAN_COMPLETED, &local->scanning),
1965 "%s: resume with hardware scan still in progress\n",
1966 wiphy_name(hw->wiphy));
1967
1968 return ieee80211_reconfig(hw_to_local(hw));
1969 }
1970
1971 /* utility functions/constants */
1972 extern const void *const mac80211_wiphy_privid; /* for wiphy privid */
1973 int ieee80211_frame_duration(enum nl80211_band band, size_t len,
1974 int rate, int erp, int short_preamble,
1975 int shift);
1976 void ieee80211_regulatory_limit_wmm_params(struct ieee80211_sub_if_data *sdata,
1977 struct ieee80211_tx_queue_params *qparam,
1978 int ac);
1979 void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata,
1980 bool bss_notify, bool enable_qos);
1981 void ieee80211_xmit(struct ieee80211_sub_if_data *sdata,
1982 struct sta_info *sta, struct sk_buff *skb);
1983
1984 void __ieee80211_tx_skb_tid_band(struct ieee80211_sub_if_data *sdata,
1985 struct sk_buff *skb, int tid,
1986 enum nl80211_band band);
1987
1988 /* sta_out needs to be checked for ERR_PTR() before using */
1989 int ieee80211_lookup_ra_sta(struct ieee80211_sub_if_data *sdata,
1990 struct sk_buff *skb,
1991 struct sta_info **sta_out);
1992
1993 static inline void
ieee80211_tx_skb_tid_band(struct ieee80211_sub_if_data * sdata,struct sk_buff * skb,int tid,enum nl80211_band band)1994 ieee80211_tx_skb_tid_band(struct ieee80211_sub_if_data *sdata,
1995 struct sk_buff *skb, int tid,
1996 enum nl80211_band band)
1997 {
1998 rcu_read_lock();
1999 __ieee80211_tx_skb_tid_band(sdata, skb, tid, band);
2000 rcu_read_unlock();
2001 }
2002
ieee80211_tx_skb_tid(struct ieee80211_sub_if_data * sdata,struct sk_buff * skb,int tid)2003 static inline void ieee80211_tx_skb_tid(struct ieee80211_sub_if_data *sdata,
2004 struct sk_buff *skb, int tid)
2005 {
2006 struct ieee80211_chanctx_conf *chanctx_conf;
2007
2008 rcu_read_lock();
2009 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
2010 if (WARN_ON(!chanctx_conf)) {
2011 rcu_read_unlock();
2012 kfree_skb(skb);
2013 return;
2014 }
2015
2016 __ieee80211_tx_skb_tid_band(sdata, skb, tid,
2017 chanctx_conf->def.chan->band);
2018 rcu_read_unlock();
2019 }
2020
ieee80211_tx_skb(struct ieee80211_sub_if_data * sdata,struct sk_buff * skb)2021 static inline void ieee80211_tx_skb(struct ieee80211_sub_if_data *sdata,
2022 struct sk_buff *skb)
2023 {
2024 /* Send all internal mgmt frames on VO. Accordingly set TID to 7. */
2025 ieee80211_tx_skb_tid(sdata, skb, 7);
2026 }
2027
2028 u32 ieee802_11_parse_elems_crc(const u8 *start, size_t len, bool action,
2029 struct ieee802_11_elems *elems,
2030 u64 filter, u32 crc, u8 *transmitter_bssid,
2031 u8 *bss_bssid);
ieee802_11_parse_elems(const u8 * start,size_t len,bool action,struct ieee802_11_elems * elems,u8 * transmitter_bssid,u8 * bss_bssid)2032 static inline void ieee802_11_parse_elems(const u8 *start, size_t len,
2033 bool action,
2034 struct ieee802_11_elems *elems,
2035 u8 *transmitter_bssid,
2036 u8 *bss_bssid)
2037 {
2038 ieee802_11_parse_elems_crc(start, len, action, elems, 0, 0,
2039 transmitter_bssid, bss_bssid);
2040 }
2041
2042
2043 extern const int ieee802_1d_to_ac[8];
2044
ieee80211_ac_from_tid(int tid)2045 static inline int ieee80211_ac_from_tid(int tid)
2046 {
2047 return ieee802_1d_to_ac[tid & 7];
2048 }
2049
2050 void ieee80211_dynamic_ps_enable_work(struct work_struct *work);
2051 void ieee80211_dynamic_ps_disable_work(struct work_struct *work);
2052 void ieee80211_dynamic_ps_timer(struct timer_list *t);
2053 void ieee80211_send_nullfunc(struct ieee80211_local *local,
2054 struct ieee80211_sub_if_data *sdata,
2055 bool powersave);
2056 void ieee80211_send_4addr_nullfunc(struct ieee80211_local *local,
2057 struct ieee80211_sub_if_data *sdata);
2058 void ieee80211_sta_tx_notify(struct ieee80211_sub_if_data *sdata,
2059 struct ieee80211_hdr *hdr, bool ack, u16 tx_time);
2060
2061 void ieee80211_wake_queues_by_reason(struct ieee80211_hw *hw,
2062 unsigned long queues,
2063 enum queue_stop_reason reason,
2064 bool refcounted);
2065 void ieee80211_stop_vif_queues(struct ieee80211_local *local,
2066 struct ieee80211_sub_if_data *sdata,
2067 enum queue_stop_reason reason);
2068 void ieee80211_wake_vif_queues(struct ieee80211_local *local,
2069 struct ieee80211_sub_if_data *sdata,
2070 enum queue_stop_reason reason);
2071 void ieee80211_stop_queues_by_reason(struct ieee80211_hw *hw,
2072 unsigned long queues,
2073 enum queue_stop_reason reason,
2074 bool refcounted);
2075 void ieee80211_wake_queue_by_reason(struct ieee80211_hw *hw, int queue,
2076 enum queue_stop_reason reason,
2077 bool refcounted);
2078 void ieee80211_stop_queue_by_reason(struct ieee80211_hw *hw, int queue,
2079 enum queue_stop_reason reason,
2080 bool refcounted);
2081 void ieee80211_propagate_queue_wake(struct ieee80211_local *local, int queue);
2082 void ieee80211_add_pending_skb(struct ieee80211_local *local,
2083 struct sk_buff *skb);
2084 void ieee80211_add_pending_skbs(struct ieee80211_local *local,
2085 struct sk_buff_head *skbs);
2086 void ieee80211_flush_queues(struct ieee80211_local *local,
2087 struct ieee80211_sub_if_data *sdata, bool drop);
2088 void __ieee80211_flush_queues(struct ieee80211_local *local,
2089 struct ieee80211_sub_if_data *sdata,
2090 unsigned int queues, bool drop);
2091
ieee80211_can_run_worker(struct ieee80211_local * local)2092 static inline bool ieee80211_can_run_worker(struct ieee80211_local *local)
2093 {
2094 /*
2095 * It's unsafe to try to do any work during reconfigure flow.
2096 * When the flow ends the work will be requeued.
2097 */
2098 if (local->in_reconfig)
2099 return false;
2100
2101 /*
2102 * If quiescing is set, we are racing with __ieee80211_suspend.
2103 * __ieee80211_suspend flushes the workers after setting quiescing,
2104 * and we check quiescing / suspended before enqueing new workers.
2105 * We should abort the worker to avoid the races below.
2106 */
2107 if (local->quiescing)
2108 return false;
2109
2110 /*
2111 * We might already be suspended if the following scenario occurs:
2112 * __ieee80211_suspend Control path
2113 *
2114 * if (local->quiescing)
2115 * return;
2116 * local->quiescing = true;
2117 * flush_workqueue();
2118 * queue_work(...);
2119 * local->suspended = true;
2120 * local->quiescing = false;
2121 * worker starts running...
2122 */
2123 if (local->suspended)
2124 return false;
2125
2126 return true;
2127 }
2128
2129 int ieee80211_txq_setup_flows(struct ieee80211_local *local);
2130 void ieee80211_txq_set_params(struct ieee80211_local *local);
2131 void ieee80211_txq_teardown_flows(struct ieee80211_local *local);
2132 void ieee80211_txq_init(struct ieee80211_sub_if_data *sdata,
2133 struct sta_info *sta,
2134 struct txq_info *txq, int tid);
2135 void ieee80211_txq_purge(struct ieee80211_local *local,
2136 struct txq_info *txqi);
2137 void ieee80211_txq_remove_vlan(struct ieee80211_local *local,
2138 struct ieee80211_sub_if_data *sdata);
2139 void ieee80211_fill_txq_stats(struct cfg80211_txq_stats *txqstats,
2140 struct txq_info *txqi);
2141 void ieee80211_wake_txqs(unsigned long data);
2142 void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata,
2143 u16 transaction, u16 auth_alg, u16 status,
2144 const u8 *extra, size_t extra_len, const u8 *bssid,
2145 const u8 *da, const u8 *key, u8 key_len, u8 key_idx,
2146 u32 tx_flags);
2147 void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata,
2148 const u8 *da, const u8 *bssid,
2149 u16 stype, u16 reason,
2150 bool send_frame, u8 *frame_buf);
2151
2152 enum {
2153 IEEE80211_PROBE_FLAG_DIRECTED = BIT(0),
2154 IEEE80211_PROBE_FLAG_MIN_CONTENT = BIT(1),
2155 IEEE80211_PROBE_FLAG_RANDOM_SN = BIT(2),
2156 };
2157
2158 int ieee80211_build_preq_ies(struct ieee80211_sub_if_data *sdata, u8 *buffer,
2159 size_t buffer_len,
2160 struct ieee80211_scan_ies *ie_desc,
2161 const u8 *ie, size_t ie_len,
2162 u8 bands_used, u32 *rate_masks,
2163 struct cfg80211_chan_def *chandef,
2164 u32 flags);
2165 struct sk_buff *ieee80211_build_probe_req(struct ieee80211_sub_if_data *sdata,
2166 const u8 *src, const u8 *dst,
2167 u32 ratemask,
2168 struct ieee80211_channel *chan,
2169 const u8 *ssid, size_t ssid_len,
2170 const u8 *ie, size_t ie_len,
2171 u32 flags);
2172 u32 ieee80211_sta_get_rates(struct ieee80211_sub_if_data *sdata,
2173 struct ieee802_11_elems *elems,
2174 enum nl80211_band band, u32 *basic_rates);
2175 int __ieee80211_request_smps_mgd(struct ieee80211_sub_if_data *sdata,
2176 enum ieee80211_smps_mode smps_mode);
2177 void ieee80211_recalc_smps(struct ieee80211_sub_if_data *sdata);
2178 void ieee80211_recalc_min_chandef(struct ieee80211_sub_if_data *sdata);
2179
2180 size_t ieee80211_ie_split_vendor(const u8 *ies, size_t ielen, size_t offset);
2181 u8 *ieee80211_ie_build_ht_cap(u8 *pos, struct ieee80211_sta_ht_cap *ht_cap,
2182 u16 cap);
2183 u8 *ieee80211_ie_build_ht_oper(u8 *pos, struct ieee80211_sta_ht_cap *ht_cap,
2184 const struct cfg80211_chan_def *chandef,
2185 u16 prot_mode, bool rifs_mode);
2186 void ieee80211_ie_build_wide_bw_cs(u8 *pos,
2187 const struct cfg80211_chan_def *chandef);
2188 u8 *ieee80211_ie_build_vht_cap(u8 *pos, struct ieee80211_sta_vht_cap *vht_cap,
2189 u32 cap);
2190 u8 *ieee80211_ie_build_vht_oper(u8 *pos, struct ieee80211_sta_vht_cap *vht_cap,
2191 const struct cfg80211_chan_def *chandef);
2192 u8 ieee80211_ie_len_he_cap(struct ieee80211_sub_if_data *sdata, u8 iftype);
2193 u8 *ieee80211_ie_build_he_cap(u8 *pos,
2194 const struct ieee80211_sta_he_cap *he_cap,
2195 u8 *end);
2196 void ieee80211_ie_build_he_6ghz_cap(struct ieee80211_sub_if_data *sdata,
2197 struct sk_buff *skb);
2198 u8 *ieee80211_ie_build_he_oper(u8 *pos, struct cfg80211_chan_def *chandef);
2199 int ieee80211_parse_bitrates(struct cfg80211_chan_def *chandef,
2200 const struct ieee80211_supported_band *sband,
2201 const u8 *srates, int srates_len, u32 *rates);
2202 int ieee80211_add_srates_ie(struct ieee80211_sub_if_data *sdata,
2203 struct sk_buff *skb, bool need_basic,
2204 enum nl80211_band band);
2205 int ieee80211_add_ext_srates_ie(struct ieee80211_sub_if_data *sdata,
2206 struct sk_buff *skb, bool need_basic,
2207 enum nl80211_band band);
2208 u8 *ieee80211_add_wmm_info_ie(u8 *buf, u8 qosinfo);
2209 void ieee80211_add_s1g_capab_ie(struct ieee80211_sub_if_data *sdata,
2210 struct ieee80211_sta_s1g_cap *caps,
2211 struct sk_buff *skb);
2212 void ieee80211_add_aid_request_ie(struct ieee80211_sub_if_data *sdata,
2213 struct sk_buff *skb);
2214
2215 /* channel management */
2216 bool ieee80211_chandef_ht_oper(const struct ieee80211_ht_operation *ht_oper,
2217 struct cfg80211_chan_def *chandef);
2218 bool ieee80211_chandef_vht_oper(struct ieee80211_hw *hw, u32 vht_cap_info,
2219 const struct ieee80211_vht_operation *oper,
2220 const struct ieee80211_ht_operation *htop,
2221 struct cfg80211_chan_def *chandef);
2222 bool ieee80211_chandef_he_6ghz_oper(struct ieee80211_sub_if_data *sdata,
2223 const struct ieee80211_he_operation *he_oper,
2224 struct cfg80211_chan_def *chandef);
2225 bool ieee80211_chandef_s1g_oper(const struct ieee80211_s1g_oper_ie *oper,
2226 struct cfg80211_chan_def *chandef);
2227 u32 ieee80211_chandef_downgrade(struct cfg80211_chan_def *c);
2228
2229 int __must_check
2230 ieee80211_vif_use_channel(struct ieee80211_sub_if_data *sdata,
2231 const struct cfg80211_chan_def *chandef,
2232 enum ieee80211_chanctx_mode mode);
2233 int __must_check
2234 ieee80211_vif_reserve_chanctx(struct ieee80211_sub_if_data *sdata,
2235 const struct cfg80211_chan_def *chandef,
2236 enum ieee80211_chanctx_mode mode,
2237 bool radar_required);
2238 int __must_check
2239 ieee80211_vif_use_reserved_context(struct ieee80211_sub_if_data *sdata);
2240 int ieee80211_vif_unreserve_chanctx(struct ieee80211_sub_if_data *sdata);
2241
2242 int __must_check
2243 ieee80211_vif_change_bandwidth(struct ieee80211_sub_if_data *sdata,
2244 const struct cfg80211_chan_def *chandef,
2245 u32 *changed);
2246 void ieee80211_vif_release_channel(struct ieee80211_sub_if_data *sdata);
2247 void ieee80211_vif_vlan_copy_chanctx(struct ieee80211_sub_if_data *sdata);
2248 void ieee80211_vif_copy_chanctx_to_vlans(struct ieee80211_sub_if_data *sdata,
2249 bool clear);
2250 int ieee80211_chanctx_refcount(struct ieee80211_local *local,
2251 struct ieee80211_chanctx *ctx);
2252
2253 void ieee80211_recalc_smps_chanctx(struct ieee80211_local *local,
2254 struct ieee80211_chanctx *chanctx);
2255 void ieee80211_recalc_chanctx_min_def(struct ieee80211_local *local,
2256 struct ieee80211_chanctx *ctx);
2257 bool ieee80211_is_radar_required(struct ieee80211_local *local);
2258
2259 void ieee80211_dfs_cac_timer(unsigned long data);
2260 void ieee80211_dfs_cac_timer_work(struct work_struct *work);
2261 void ieee80211_dfs_cac_cancel(struct ieee80211_local *local);
2262 void ieee80211_dfs_radar_detected_work(struct work_struct *work);
2263 int ieee80211_send_action_csa(struct ieee80211_sub_if_data *sdata,
2264 struct cfg80211_csa_settings *csa_settings);
2265
2266 bool ieee80211_cs_valid(const struct ieee80211_cipher_scheme *cs);
2267 bool ieee80211_cs_list_valid(const struct ieee80211_cipher_scheme *cs, int n);
2268 const struct ieee80211_cipher_scheme *
2269 ieee80211_cs_get(struct ieee80211_local *local, u32 cipher,
2270 enum nl80211_iftype iftype);
2271 int ieee80211_cs_headroom(struct ieee80211_local *local,
2272 struct cfg80211_crypto_settings *crypto,
2273 enum nl80211_iftype iftype);
2274 void ieee80211_recalc_dtim(struct ieee80211_local *local,
2275 struct ieee80211_sub_if_data *sdata);
2276 int ieee80211_check_combinations(struct ieee80211_sub_if_data *sdata,
2277 const struct cfg80211_chan_def *chandef,
2278 enum ieee80211_chanctx_mode chanmode,
2279 u8 radar_detect);
2280 int ieee80211_max_num_channels(struct ieee80211_local *local);
2281 enum nl80211_chan_width ieee80211_get_sta_bw(struct ieee80211_sta *sta);
2282 void ieee80211_recalc_chanctx_chantype(struct ieee80211_local *local,
2283 struct ieee80211_chanctx *ctx);
2284
2285 /* TDLS */
2286 int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
2287 const u8 *peer, u8 action_code, u8 dialog_token,
2288 u16 status_code, u32 peer_capability,
2289 bool initiator, const u8 *extra_ies,
2290 size_t extra_ies_len);
2291 int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
2292 const u8 *peer, enum nl80211_tdls_operation oper);
2293 void ieee80211_tdls_peer_del_work(struct work_struct *wk);
2294 int ieee80211_tdls_channel_switch(struct wiphy *wiphy, struct net_device *dev,
2295 const u8 *addr, u8 oper_class,
2296 struct cfg80211_chan_def *chandef);
2297 void ieee80211_tdls_cancel_channel_switch(struct wiphy *wiphy,
2298 struct net_device *dev,
2299 const u8 *addr);
2300 void ieee80211_teardown_tdls_peers(struct ieee80211_sub_if_data *sdata);
2301 void ieee80211_tdls_chsw_work(struct work_struct *wk);
2302 void ieee80211_tdls_handle_disconnect(struct ieee80211_sub_if_data *sdata,
2303 const u8 *peer, u16 reason);
2304 const char *ieee80211_get_reason_code_string(u16 reason_code);
2305 u16 ieee80211_encode_usf(int val);
2306 u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len,
2307 enum nl80211_iftype type);
2308
2309 extern const struct ethtool_ops ieee80211_ethtool_ops;
2310
2311 u32 ieee80211_calc_expected_tx_airtime(struct ieee80211_hw *hw,
2312 struct ieee80211_vif *vif,
2313 struct ieee80211_sta *pubsta,
2314 int len, bool ampdu);
2315 #ifdef CONFIG_MAC80211_NOINLINE
2316 #define debug_noinline noinline
2317 #else
2318 #define debug_noinline
2319 #endif
2320
2321 void ieee80211_init_frag_cache(struct ieee80211_fragment_cache *cache);
2322 void ieee80211_destroy_frag_cache(struct ieee80211_fragment_cache *cache);
2323
2324 #endif /* IEEE80211_I_H */
2325