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