blob: ca07c5e76bfea61c3a1c8bb9e2f3770f82f6ef25 [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001/*
2 * Copyright 2002-2005, Instant802 Networks, Inc.
3 * Copyright 2005, Devicescape Software, Inc.
4 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
5 * Copyright 2007-2010 Johannes Berg <johannes@sipsolutions.net>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#ifndef IEEE80211_I_H
13#define IEEE80211_I_H
14
15#include <linux/kernel.h>
16#include <linux/device.h>
17#include <linux/if_ether.h>
18#include <linux/interrupt.h>
19#include <linux/list.h>
20#include <linux/netdevice.h>
21#include <linux/skbuff.h>
22#include <linux/workqueue.h>
23#include <linux/types.h>
24#include <linux/spinlock.h>
25#include <linux/etherdevice.h>
26#include <linux/leds.h>
27#include <linux/idr.h>
28#include <net/ieee80211_radiotap.h>
29#include <net/cfg80211.h>
30#include <net/mac80211.h>
31#include "key.h"
32#include "sta_info.h"
33
34struct ieee80211_local;
35
36/* Maximum number of broadcast/multicast frames to buffer when some of the
37 * associated stations are using power saving. */
38#define AP_MAX_BC_BUFFER 128
39
40/* Maximum number of frames buffered to all STAs, including multicast frames.
41 * Note: increasing this limit increases the potential memory requirement. Each
42 * frame can be up to about 2 kB long. */
43#define TOTAL_MAX_TX_BUFFER 512
44
45/* Required encryption head and tailroom */
46#define IEEE80211_ENCRYPT_HEADROOM 8
47#define IEEE80211_ENCRYPT_TAILROOM 18
48
49/* IEEE 802.11 (Ch. 9.5 Defragmentation) requires support for concurrent
50 * reception of at least three fragmented frames. This limit can be increased
51 * by changing this define, at the cost of slower frame reassembly and
52 * increased memory use (about 2 kB of RAM per entry). */
53#define IEEE80211_FRAGMENT_MAX 4
54
55#define TU_TO_EXP_TIME(x) (jiffies + usecs_to_jiffies((x) * 1024))
56
57/*
58 * Some APs experience problems when working with U-APSD. Decreasing the
59 * probability of that happening by using legacy mode for all ACs but VO isn't
60 * enough.
61 *
62 * Cisco 4410N originally forced us to enable VO by default only because it
63 * treated non-VO ACs as legacy.
64 *
65 * However some APs (notably Netgear R7000) silently reclassify packets to
66 * different ACs. Since u-APSD ACs require trigger frames for frame retrieval
67 * clients would never see some frames (e.g. ARP responses) or would fetch them
68 * accidentally after a long time.
69 *
70 * It makes little sense to enable u-APSD queues by default because it needs
71 * userspace applications to be aware of it to actually take advantage of the
72 * possible additional powersavings. Implicitly depending on driver autotrigger
73 * frame support doesn't make much sense.
74 */
75#define IEEE80211_DEFAULT_UAPSD_QUEUES 0
76
77#define IEEE80211_DEFAULT_MAX_SP_LEN \
78 IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL
79
80struct ieee80211_fragment_entry {
81 unsigned long first_frag_time;
82 unsigned int seq;
83 unsigned int rx_queue;
84 unsigned int last_frag;
85 unsigned int extra_len;
86 struct sk_buff_head skb_list;
87 int ccmp; /* Whether fragments were encrypted with CCMP */
88 u8 last_pn[6]; /* PN of the last fragment if CCMP was used */
89};
90
91
92struct ieee80211_bss {
93 /* don't want to look up all the time */
94 size_t ssid_len;
95 u8 ssid[IEEE80211_MAX_SSID_LEN];
96
97 u8 dtim_period;
98
99 bool wmm_used;
100 bool uapsd_supported;
101
102 unsigned long last_probe_resp;
103
104#ifdef CONFIG_MAC80211_MESH
105 u8 *mesh_id;
106 size_t mesh_id_len;
107 u8 *mesh_cfg;
108#endif
109
110#define IEEE80211_MAX_SUPP_RATES 32
111 u8 supp_rates[IEEE80211_MAX_SUPP_RATES];
112 size_t supp_rates_len;
113
114 /*
115 * During association, we save an ERP value from a probe response so
116 * that we can feed ERP info to the driver when handling the
117 * association completes. these fields probably won't be up-to-date
118 * otherwise, you probably don't want to use them.
119 */
120 bool has_erp_value;
121 u8 erp_value;
122
123 /* Keep track of the corruption of the last beacon/probe response. */
124 u8 corrupt_data;
125
126 /* Keep track of what bits of information we have valid info for. */
127 u8 valid_data;
128};
129
130/**
131 * enum ieee80211_corrupt_data_flags - BSS data corruption flags
132 * @IEEE80211_BSS_CORRUPT_BEACON: last beacon frame received was corrupted
133 * @IEEE80211_BSS_CORRUPT_PROBE_RESP: last probe response received was corrupted
134 *
135 * These are bss flags that are attached to a bss in the
136 * @corrupt_data field of &struct ieee80211_bss.
137 */
138enum ieee80211_bss_corrupt_data_flags {
139 IEEE80211_BSS_CORRUPT_BEACON = BIT(0),
140 IEEE80211_BSS_CORRUPT_PROBE_RESP = BIT(1)
141};
142
143/**
144 * enum ieee80211_valid_data_flags - BSS valid data flags
145 * @IEEE80211_BSS_VALID_DTIM: DTIM data was gathered from non-corrupt IE
146 * @IEEE80211_BSS_VALID_WMM: WMM/UAPSD data was gathered from non-corrupt IE
147 * @IEEE80211_BSS_VALID_RATES: Supported rates were gathered from non-corrupt IE
148 * @IEEE80211_BSS_VALID_ERP: ERP flag was gathered from non-corrupt IE
149 *
150 * These are bss flags that are attached to a bss in the
151 * @valid_data field of &struct ieee80211_bss. They show which parts
152 * of the data structure were recieved as a result of an un-corrupted
153 * beacon/probe response.
154 */
155enum ieee80211_bss_valid_data_flags {
156 IEEE80211_BSS_VALID_DTIM = BIT(0),
157 IEEE80211_BSS_VALID_WMM = BIT(1),
158 IEEE80211_BSS_VALID_RATES = BIT(2),
159 IEEE80211_BSS_VALID_ERP = BIT(3)
160};
161
162static inline u8 *bss_mesh_cfg(struct ieee80211_bss *bss)
163{
164#ifdef CONFIG_MAC80211_MESH
165 return bss->mesh_cfg;
166#endif
167 return NULL;
168}
169
170static inline u8 *bss_mesh_id(struct ieee80211_bss *bss)
171{
172#ifdef CONFIG_MAC80211_MESH
173 return bss->mesh_id;
174#endif
175 return NULL;
176}
177
178static inline u8 bss_mesh_id_len(struct ieee80211_bss *bss)
179{
180#ifdef CONFIG_MAC80211_MESH
181 return bss->mesh_id_len;
182#endif
183 return 0;
184}
185
186
187typedef unsigned __bitwise__ ieee80211_tx_result;
188#define TX_CONTINUE ((__force ieee80211_tx_result) 0u)
189#define TX_DROP ((__force ieee80211_tx_result) 1u)
190#define TX_QUEUED ((__force ieee80211_tx_result) 2u)
191
192#define IEEE80211_TX_UNICAST BIT(1)
193#define IEEE80211_TX_PS_BUFFERED BIT(2)
194
195struct ieee80211_tx_data {
196 struct sk_buff *skb;
197 struct sk_buff_head skbs;
198 struct ieee80211_local *local;
199 struct ieee80211_sub_if_data *sdata;
200 struct sta_info *sta;
201 struct ieee80211_key *key;
202
203 struct ieee80211_channel *channel;
204
205 unsigned int flags;
206};
207
208
209typedef unsigned __bitwise__ ieee80211_rx_result;
210#define RX_CONTINUE ((__force ieee80211_rx_result) 0u)
211#define RX_DROP_UNUSABLE ((__force ieee80211_rx_result) 1u)
212#define RX_DROP_MONITOR ((__force ieee80211_rx_result) 2u)
213#define RX_QUEUED ((__force ieee80211_rx_result) 3u)
214
215/**
216 * enum ieee80211_packet_rx_flags - packet RX flags
217 * @IEEE80211_RX_RA_MATCH: frame is destined to interface currently processed
218 * (incl. multicast frames)
219 * @IEEE80211_RX_IN_SCAN: received while scanning
220 * @IEEE80211_RX_FRAGMENTED: fragmented frame
221 * @IEEE80211_RX_AMSDU: a-MSDU packet
222 * @IEEE80211_RX_MALFORMED_ACTION_FRM: action frame is malformed
223 * @IEEE80211_RX_DEFERRED_RELEASE: frame was subjected to receive reordering
224 *
225 * These are per-frame flags that are attached to a frame in the
226 * @rx_flags field of &struct ieee80211_rx_status.
227 */
228enum ieee80211_packet_rx_flags {
229 IEEE80211_RX_IN_SCAN = BIT(0),
230 IEEE80211_RX_RA_MATCH = BIT(1),
231 IEEE80211_RX_FRAGMENTED = BIT(2),
232 IEEE80211_RX_AMSDU = BIT(3),
233 IEEE80211_RX_MALFORMED_ACTION_FRM = BIT(4),
234 IEEE80211_RX_DEFERRED_RELEASE = BIT(5),
235};
236
237/**
238 * enum ieee80211_rx_flags - RX data flags
239 *
240 * @IEEE80211_RX_CMNTR: received on cooked monitor already
241 * @IEEE80211_RX_BEACON_REPORTED: This frame was already reported
242 * to cfg80211_report_obss_beacon().
243 *
244 * These flags are used across handling multiple interfaces
245 * for a single frame.
246 */
247enum ieee80211_rx_flags {
248 IEEE80211_RX_CMNTR = BIT(0),
249 IEEE80211_RX_BEACON_REPORTED = BIT(1),
250};
251
252struct ieee80211_rx_data {
253 struct sk_buff *skb;
254 struct ieee80211_local *local;
255 struct ieee80211_sub_if_data *sdata;
256 struct sta_info *sta;
257 struct ieee80211_key *key;
258
259 unsigned int flags;
260
261 /*
262 * Index into sequence numbers array, 0..16
263 * since the last (16) is used for non-QoS,
264 * will be 16 on non-QoS frames.
265 */
266 int seqno_idx;
267
268 /*
269 * Index into the security IV/PN arrays, 0..16
270 * since the last (16) is used for CCMP-encrypted
271 * management frames, will be set to 16 on mgmt
272 * frames and 0 on non-QoS frames.
273 */
274 int security_idx;
275
276 u32 tkip_iv32;
277 u16 tkip_iv16;
278};
279
280struct beacon_data {
281 u8 *head, *tail;
282 int head_len, tail_len;
283 struct rcu_head rcu_head;
284};
285
286struct ieee80211_if_ap {
287 struct beacon_data __rcu *beacon;
288 struct sk_buff __rcu *probe_resp;
289
290 struct list_head vlans;
291
292 /* yes, this looks ugly, but guarantees that we can later use
293 * bitmap_empty :)
294 * NB: don't touch this bitmap, use sta_info_{set,clear}_tim_bit */
295 u8 tim[sizeof(unsigned long) * BITS_TO_LONGS(IEEE80211_MAX_AID + 1)];
296 struct sk_buff_head ps_bc_buf;
297 atomic_t num_sta_ps; /* number of stations in PS mode */
298 atomic_t num_sta_authorized; /* number of authorized stations */
299 int dtim_count;
300 bool dtim_bc_mc;
301};
302
303struct ieee80211_if_wds {
304 struct sta_info *sta;
305 u8 remote_addr[ETH_ALEN];
306};
307
308struct ieee80211_if_vlan {
309 struct list_head list;
310
311 /* used for all tx if the VLAN is configured to 4-addr mode */
312 struct sta_info __rcu *sta;
313};
314
315struct mesh_stats {
316 __u32 fwded_mcast; /* Mesh forwarded multicast frames */
317 __u32 fwded_unicast; /* Mesh forwarded unicast frames */
318 __u32 fwded_frames; /* Mesh total forwarded frames */
319 __u32 dropped_frames_ttl; /* Not transmitted since mesh_ttl == 0*/
320 __u32 dropped_frames_no_route; /* Not transmitted, no route found */
321 __u32 dropped_frames_congestion;/* Not forwarded due to congestion */
322 atomic_t estab_plinks;
323};
324
325#define PREQ_Q_F_START 0x1
326#define PREQ_Q_F_REFRESH 0x2
327struct mesh_preq_queue {
328 struct list_head list;
329 u8 dst[ETH_ALEN];
330 u8 flags;
331};
332
333enum ieee80211_work_type {
334 IEEE80211_WORK_ABORT,
335 IEEE80211_WORK_REMAIN_ON_CHANNEL,
336 IEEE80211_WORK_OFFCHANNEL_TX,
337};
338
339/**
340 * enum work_done_result - indicates what to do after work was done
341 *
342 * @WORK_DONE_DESTROY: This work item is no longer needed, destroy.
343 * @WORK_DONE_REQUEUE: This work item was reset to be reused, and
344 * should be requeued.
345 */
346enum work_done_result {
347 WORK_DONE_DESTROY,
348 WORK_DONE_REQUEUE,
349};
350
351struct ieee80211_work {
352 struct list_head list;
353
354 struct rcu_head rcu_head;
355
356 struct ieee80211_sub_if_data *sdata;
357
358 enum work_done_result (*done)(struct ieee80211_work *wk,
359 struct sk_buff *skb);
360
361 struct ieee80211_channel *chan;
362 enum nl80211_channel_type chan_type;
363
364 unsigned long timeout;
365 enum ieee80211_work_type type;
366
367 bool started;
368
369 union {
370 struct {
371 u32 duration;
372 } remain;
373 struct {
374 struct sk_buff *frame;
375 u32 wait;
376 bool status;
377 } offchan_tx;
378 };
379
380 size_t data_len;
381 u8 data[];
382};
383
384/* flags used in struct ieee80211_if_managed.flags */
385enum ieee80211_sta_flags {
386 IEEE80211_STA_BEACON_POLL = BIT(0),
387 IEEE80211_STA_CONNECTION_POLL = BIT(1),
388 IEEE80211_STA_CONTROL_PORT = BIT(2),
389 IEEE80211_STA_DISABLE_11N = BIT(4),
390 IEEE80211_STA_CSA_RECEIVED = BIT(5),
391 IEEE80211_STA_MFP_ENABLED = BIT(6),
392 IEEE80211_STA_UAPSD_ENABLED = BIT(7),
393 IEEE80211_STA_NULLFUNC_ACKED = BIT(8),
394 IEEE80211_STA_RESET_SIGNAL_AVE = BIT(9),
395};
396
397struct ieee80211_mgd_auth_data {
398 struct cfg80211_bss *bss;
399 unsigned long timeout;
400 int tries;
401 u16 algorithm, expected_transaction;
402
403 u8 key[WLAN_KEY_LEN_WEP104];
404 u8 key_len, key_idx;
405 bool done;
406
407 size_t ie_len;
408 u8 ie[];
409};
410
411struct ieee80211_mgd_assoc_data {
412 struct cfg80211_bss *bss;
413 const u8 *supp_rates;
414 const u8 *ht_information_ie;
415
416 unsigned long timeout;
417 int tries;
418
419 u16 capability;
420 u8 prev_bssid[ETH_ALEN];
421 u8 ssid[IEEE80211_MAX_SSID_LEN];
422 u8 ssid_len;
423 u8 supp_rates_len;
424 bool wmm, uapsd;
425 bool have_beacon;
426 bool sent_assoc;
427 bool synced;
428
429 size_t ie_len;
430 u8 ie[];
431};
432
433struct ieee80211_if_managed {
434 struct timer_list timer;
435 struct timer_list conn_mon_timer;
436 struct timer_list bcn_mon_timer;
437 struct timer_list chswitch_timer;
438 struct work_struct monitor_work;
439 struct work_struct chswitch_work;
440 struct work_struct beacon_connection_loss_work;
441
442 unsigned long beacon_timeout;
443 unsigned long probe_timeout;
444 int probe_send_count;
445 bool nullfunc_failed;
446
447 struct mutex mtx;
448 struct cfg80211_bss *associated;
449 struct ieee80211_mgd_auth_data *auth_data;
450 struct ieee80211_mgd_assoc_data *assoc_data;
451
452 u8 bssid[ETH_ALEN];
453
454 u16 aid;
455
456 unsigned long timers_running; /* used for quiesce/restart */
457 bool powersave; /* powersave requested for this iface */
458 bool broken_ap; /* AP is broken -- turn off powersave */
459 enum ieee80211_smps_mode req_smps, /* requested smps mode */
460 ap_smps, /* smps mode AP thinks we're in */
461 driver_smps_mode; /* smps mode request */
462
463 struct work_struct request_smps_work;
464
465 unsigned int flags;
466
467 bool beacon_crc_valid;
468 u32 beacon_crc;
469
470 enum {
471 IEEE80211_MFP_DISABLED,
472 IEEE80211_MFP_OPTIONAL,
473 IEEE80211_MFP_REQUIRED
474 } mfp; /* management frame protection */
475
476 /*
477 * Bitmask of enabled u-apsd queues,
478 * IEEE80211_WMM_IE_STA_QOSINFO_AC_BE & co. Needs a new association
479 * to take effect.
480 */
481 unsigned int uapsd_queues;
482
483 /*
484 * Maximum number of buffered frames AP can deliver during a
485 * service period, IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL or similar.
486 * Needs a new association to take effect.
487 */
488 unsigned int uapsd_max_sp_len;
489
490 int wmm_last_param_set;
491
492 u8 use_4addr;
493
494 /* Signal strength from the last Beacon frame in the current BSS. */
495 int last_beacon_signal;
496
497 /*
498 * Weighted average of the signal strength from Beacon frames in the
499 * current BSS. This is in units of 1/16 of the signal unit to maintain
500 * accuracy and to speed up calculations, i.e., the value need to be
501 * divided by 16 to get the actual value.
502 */
503 int ave_beacon_signal;
504
505 /*
506 * Number of Beacon frames used in ave_beacon_signal. This can be used
507 * to avoid generating less reliable cqm events that would be based
508 * only on couple of received frames.
509 */
510 unsigned int count_beacon_signal;
511
512 /*
513 * Last Beacon frame signal strength average (ave_beacon_signal / 16)
514 * that triggered a cqm event. 0 indicates that no event has been
515 * generated for the current association.
516 */
517 int last_cqm_event_signal;
518
519 /*
520 * State variables for keeping track of RSSI of the AP currently
521 * connected to and informing driver when RSSI has gone
522 * below/above a certain threshold.
523 */
524 int rssi_min_thold, rssi_max_thold;
525 int last_ave_beacon_signal;
526
527 struct ieee80211_ht_cap ht_capa; /* configured ht-cap over-rides */
528 struct ieee80211_ht_cap ht_capa_mask; /* Valid parts of ht_capa */
529};
530
531struct ieee80211_if_ibss {
532 struct timer_list timer;
533
534 struct mutex mtx;
535
536 unsigned long last_scan_completed;
537
538 u32 basic_rates;
539
540 bool timer_running;
541
542 bool fixed_bssid;
543 bool fixed_channel;
544 bool privacy;
545
546 bool control_port;
547
548 u8 bssid[ETH_ALEN] __aligned(2);
549 u8 ssid[IEEE80211_MAX_SSID_LEN];
550 u8 ssid_len, ie_len;
551 u8 *ie;
552 struct ieee80211_channel *channel;
553 enum nl80211_channel_type channel_type;
554
555 unsigned long ibss_join_req;
556 /* probe response/beacon for IBSS */
557 struct sk_buff __rcu *presp;
558 struct sk_buff *skb;
559
560 spinlock_t incomplete_lock;
561 struct list_head incomplete_stations;
562
563 enum {
564 IEEE80211_IBSS_MLME_SEARCH,
565 IEEE80211_IBSS_MLME_JOINED,
566 } state;
567};
568
569struct ieee80211_if_mesh {
570 struct timer_list housekeeping_timer;
571 struct timer_list mesh_path_timer;
572 struct timer_list mesh_path_root_timer;
573
574 unsigned long timers_running;
575
576 unsigned long wrkq_flags;
577
578 u8 mesh_id[IEEE80211_MAX_MESH_ID_LEN];
579 size_t mesh_id_len;
580 /* Active Path Selection Protocol Identifier */
581 u8 mesh_pp_id;
582 /* Active Path Selection Metric Identifier */
583 u8 mesh_pm_id;
584 /* Congestion Control Mode Identifier */
585 u8 mesh_cc_id;
586 /* Synchronization Protocol Identifier */
587 u8 mesh_sp_id;
588 /* Authentication Protocol Identifier */
589 u8 mesh_auth_id;
590 /* Local mesh Sequence Number */
591 u32 sn;
592 /* Last used PREQ ID */
593 u32 preq_id;
594 atomic_t mpaths;
595 /* Timestamp of last SN update */
596 unsigned long last_sn_update;
597 /* Time when it's ok to send next PERR */
598 unsigned long next_perr;
599 /* Timestamp of last PREQ sent */
600 unsigned long last_preq;
601 struct mesh_rmc *rmc;
602 spinlock_t mesh_preq_queue_lock;
603 struct mesh_preq_queue preq_queue;
604 int preq_queue_len;
605 struct mesh_stats mshstats;
606 struct mesh_config mshcfg;
607 u32 mesh_seqnum;
608 bool accepting_plinks;
609 int num_gates;
610 const u8 *ie;
611 u8 ie_len;
612 enum {
613 IEEE80211_MESH_SEC_NONE = 0x0,
614 IEEE80211_MESH_SEC_AUTHED = 0x1,
615 IEEE80211_MESH_SEC_SECURED = 0x2,
616 } security;
617};
618
619#ifdef CONFIG_MAC80211_MESH
620#define IEEE80211_IFSTA_MESH_CTR_INC(msh, name) \
621 do { (msh)->mshstats.name++; } while (0)
622#else
623#define IEEE80211_IFSTA_MESH_CTR_INC(msh, name) \
624 do { } while (0)
625#endif
626
627/**
628 * enum ieee80211_sub_if_data_flags - virtual interface flags
629 *
630 * @IEEE80211_SDATA_ALLMULTI: interface wants all multicast packets
631 * @IEEE80211_SDATA_PROMISC: interface is promisc
632 * @IEEE80211_SDATA_OPERATING_GMODE: operating in G-only mode
633 * @IEEE80211_SDATA_DONT_BRIDGE_PACKETS: bridge packets between
634 * associated stations and deliver multicast frames both
635 * back to wireless media and to the local net stack.
636 * @IEEE80211_SDATA_DISCONNECT_RESUME: Disconnect after resume.
637 * @IEEE80211_SDATA_IN_DRIVER: indicates interface was added to driver
638 */
639enum ieee80211_sub_if_data_flags {
640 IEEE80211_SDATA_ALLMULTI = BIT(0),
641 IEEE80211_SDATA_PROMISC = BIT(1),
642 IEEE80211_SDATA_OPERATING_GMODE = BIT(2),
643 IEEE80211_SDATA_DONT_BRIDGE_PACKETS = BIT(3),
644 IEEE80211_SDATA_DISCONNECT_RESUME = BIT(4),
645 IEEE80211_SDATA_IN_DRIVER = BIT(5),
646};
647
648/**
649 * enum ieee80211_sdata_state_bits - virtual interface state bits
650 * @SDATA_STATE_RUNNING: virtual interface is up & running; this
651 * mirrors netif_running() but is separate for interface type
652 * change handling while the interface is up
653 * @SDATA_STATE_OFFCHANNEL: This interface is currently in offchannel
654 * mode, so queues are stopped
655 */
656enum ieee80211_sdata_state_bits {
657 SDATA_STATE_RUNNING,
658 SDATA_STATE_OFFCHANNEL,
659};
660
661struct ieee80211_sub_if_data {
662 struct list_head list;
663
664 struct wireless_dev wdev;
665
666 /* keys */
667 struct list_head key_list;
668
669 /* count for keys needing tailroom space allocation */
670 int crypto_tx_tailroom_needed_cnt;
671
672 struct net_device *dev;
673 struct ieee80211_local *local;
674
675 unsigned int flags;
676
677 unsigned long state;
678
679 int drop_unencrypted;
680
681 char name[IFNAMSIZ];
682
683 /*
684 * keep track of whether the HT opmode (stored in
685 * vif.bss_info.ht_operation_mode) is valid.
686 */
687 bool ht_opmode_valid;
688
689 /* to detect idle changes */
690 bool old_idle;
691
692 /* Fragment table for host-based reassembly */
693 struct ieee80211_fragment_entry fragments[IEEE80211_FRAGMENT_MAX];
694 unsigned int fragment_next;
695
696 /* TID bitmap for NoAck policy */
697 u16 noack_map;
698
699 struct ieee80211_key __rcu *keys[NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS];
700 struct ieee80211_key __rcu *default_unicast_key;
701 struct ieee80211_key __rcu *default_multicast_key;
702 struct ieee80211_key __rcu *default_mgmt_key;
703
704 u16 sequence_number;
705 __be16 control_port_protocol;
706 bool control_port_no_encrypt;
707
708 struct ieee80211_tx_queue_params tx_conf[IEEE80211_MAX_QUEUES];
709
710 struct work_struct work;
711 struct sk_buff_head skb_queue;
712
713 bool arp_filter_state;
714
715 /*
716 * AP this belongs to: self in AP mode and
717 * corresponding AP in VLAN mode, NULL for
718 * all others (might be needed later in IBSS)
719 */
720 struct ieee80211_if_ap *bss;
721
722 /* bitmap of allowed (non-MCS) rate indexes for rate control */
723 u32 rc_rateidx_mask[IEEE80211_NUM_BANDS];
724 u8 rc_rateidx_mcs_mask[IEEE80211_NUM_BANDS][IEEE80211_HT_MCS_MASK_LEN];
725
726 union {
727 struct ieee80211_if_ap ap;
728 struct ieee80211_if_wds wds;
729 struct ieee80211_if_vlan vlan;
730 struct ieee80211_if_managed mgd;
731 struct ieee80211_if_ibss ibss;
732 struct ieee80211_if_mesh mesh;
733 u32 mntr_flags;
734 } u;
735
736#ifdef CONFIG_MAC80211_DEBUGFS
737 struct {
738 struct dentry *dir;
739 struct dentry *subdir_stations;
740 struct dentry *default_unicast_key;
741 struct dentry *default_multicast_key;
742 struct dentry *default_mgmt_key;
743 } debugfs;
744#endif
745 /* must be last, dynamically sized area in this! */
746 struct ieee80211_vif vif;
747};
748
749static inline
750struct ieee80211_sub_if_data *vif_to_sdata(struct ieee80211_vif *p)
751{
752 return container_of(p, struct ieee80211_sub_if_data, vif);
753}
754
755enum sdata_queue_type {
756 IEEE80211_SDATA_QUEUE_TYPE_FRAME = 0,
757 IEEE80211_SDATA_QUEUE_AGG_START = 1,
758 IEEE80211_SDATA_QUEUE_AGG_STOP = 2,
759};
760
761enum {
762 IEEE80211_RX_MSG = 1,
763 IEEE80211_TX_STATUS_MSG = 2,
764 IEEE80211_EOSP_MSG = 3,
765};
766
767struct skb_eosp_msg_data {
768 u8 sta[ETH_ALEN], iface[ETH_ALEN];
769};
770
771enum queue_stop_reason {
772 IEEE80211_QUEUE_STOP_REASON_DRIVER,
773 IEEE80211_QUEUE_STOP_REASON_PS,
774 IEEE80211_QUEUE_STOP_REASON_CSA,
775 IEEE80211_QUEUE_STOP_REASON_AGGREGATION,
776 IEEE80211_QUEUE_STOP_REASON_SUSPEND,
777 IEEE80211_QUEUE_STOP_REASON_SKB_ADD,
778 IEEE80211_QUEUE_STOP_REASON_CHTYPE_CHANGE,
779};
780
781#ifdef CONFIG_MAC80211_LEDS
782struct tpt_led_trigger {
783 struct led_trigger trig;
784 char name[32];
785 const struct ieee80211_tpt_blink *blink_table;
786 unsigned int blink_table_len;
787 struct timer_list timer;
788 unsigned long prev_traffic;
789 unsigned long tx_bytes, rx_bytes;
790 unsigned int active, want;
791 bool running;
792};
793#endif
794
795/**
796 * mac80211 scan flags - currently active scan mode
797 *
798 * @SCAN_SW_SCANNING: We're currently in the process of scanning but may as
799 * well be on the operating channel
800 * @SCAN_HW_SCANNING: The hardware is scanning for us, we have no way to
801 * determine if we are on the operating channel or not
802 * @SCAN_COMPLETED: Set for our scan work function when the driver reported
803 * that the scan completed.
804 * @SCAN_ABORTED: Set for our scan work function when the driver reported
805 * a scan complete for an aborted scan.
806 * @SCAN_HW_CANCELLED: Set for our scan work function when the scan is being
807 * cancelled.
808 */
809enum {
810 SCAN_SW_SCANNING,
811 SCAN_HW_SCANNING,
812 SCAN_COMPLETED,
813 SCAN_ABORTED,
814 SCAN_HW_CANCELLED,
815};
816
817/**
818 * enum mac80211_scan_state - scan state machine states
819 *
820 * @SCAN_DECISION: Main entry point to the scan state machine, this state
821 * determines if we should keep on scanning or switch back to the
822 * operating channel
823 * @SCAN_SET_CHANNEL: Set the next channel to be scanned
824 * @SCAN_SEND_PROBE: Send probe requests and wait for probe responses
825 * @SCAN_SUSPEND: Suspend the scan and go back to operating channel to
826 * send out data
827 * @SCAN_RESUME: Resume the scan and scan the next channel
828 */
829enum mac80211_scan_state {
830 SCAN_DECISION,
831 SCAN_SET_CHANNEL,
832 SCAN_SEND_PROBE,
833 SCAN_SUSPEND,
834 SCAN_RESUME,
835};
836
837struct ieee80211_local {
838 /* embed the driver visible part.
839 * don't cast (use the static inlines below), but we keep
840 * it first anyway so they become a no-op */
841 struct ieee80211_hw hw;
842
843 const struct ieee80211_ops *ops;
844
845 /*
846 * work stuff, potentially off-channel (in the future)
847 */
848 struct list_head work_list;
849 struct timer_list work_timer;
850 struct work_struct work_work;
851
852 /*
853 * private workqueue to mac80211. mac80211 makes this accessible
854 * via ieee80211_queue_work()
855 */
856 struct workqueue_struct *workqueue;
857
858 unsigned long queue_stop_reasons[IEEE80211_MAX_QUEUES];
859 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
860 spinlock_t queue_stop_reason_lock;
861
862 int open_count;
863 int monitors, cooked_mntrs;
864 /* number of interfaces with corresponding FIF_ flags */
865 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
866 fif_probe_req;
867 int probe_req_reg;
868 unsigned int filter_flags; /* FIF_* */
869
870 bool wiphy_ciphers_allocated;
871
872 /* protects the aggregated multicast list and filter calls */
873 spinlock_t filter_lock;
874
875 /* used for uploading changed mc list */
876 struct work_struct reconfig_filter;
877
878 /* used to reconfigure hardware SM PS */
879 struct work_struct recalc_smps;
880
881 /* aggregated multicast list */
882 struct netdev_hw_addr_list mc_list;
883
884 bool tim_in_locked_section; /* see ieee80211_beacon_get() */
885
886 /*
887 * suspended is true if we finished all the suspend _and_ we have
888 * not yet come up from resume. This is to be used by mac80211
889 * to ensure driver sanity during suspend and mac80211's own
890 * sanity. It can eventually be used for WoW as well.
891 */
892 bool suspended;
893
894 /*
895 * Resuming is true while suspended, but when we're reprogramming the
896 * hardware -- at that time it's allowed to use ieee80211_queue_work()
897 * again even though some other parts of the stack are still suspended
898 * and we still drop received frames to avoid waking the stack.
899 */
900 bool resuming;
901
902 /*
903 * quiescing is true during the suspend process _only_ to
904 * ease timer cancelling etc.
905 */
906 bool quiescing;
907
908 /* device is started */
909 bool started;
910
911 /* wowlan is enabled -- don't reconfig on resume */
912 bool wowlan;
913
914 int tx_headroom; /* required headroom for hardware/radiotap */
915
916 /* Tasklet and skb queue to process calls from IRQ mode. All frames
917 * added to skb_queue will be processed, but frames in
918 * skb_queue_unreliable may be dropped if the total length of these
919 * queues increases over the limit. */
920#define IEEE80211_IRQSAFE_QUEUE_LIMIT 128
921 struct tasklet_struct tasklet;
922 struct sk_buff_head skb_queue;
923 struct sk_buff_head skb_queue_unreliable;
924
925 /*
926 * Internal FIFO queue which is shared between multiple rx path
927 * stages. Its main task is to provide a serialization mechanism,
928 * so all rx handlers can enjoy having exclusive access to their
929 * private data structures.
930 */
931 struct sk_buff_head rx_skb_queue;
932 bool running_rx_handler; /* protected by rx_skb_queue.lock */
933
934 /* Station data */
935 /*
936 * The mutex only protects the list, hash table and
937 * counter, reads are done with RCU.
938 */
939 struct mutex sta_mtx;
940 spinlock_t tim_lock;
941 unsigned long num_sta;
942 struct list_head sta_list;
943 struct sta_info __rcu *sta_hash[STA_HASH_SIZE];
944 struct timer_list sta_cleanup;
945 int sta_generation;
946
947 struct sk_buff_head pending[IEEE80211_MAX_QUEUES];
948 struct tasklet_struct tx_pending_tasklet;
949
950 atomic_t agg_queue_stop[IEEE80211_MAX_QUEUES];
951
952 /* number of interfaces with corresponding IFF_ flags */
953 atomic_t iff_allmultis, iff_promiscs;
954
955 struct rate_control_ref *rate_ctrl;
956
957 struct crypto_cipher *wep_tx_tfm;
958 struct crypto_cipher *wep_rx_tfm;
959 u32 wep_iv;
960
961 /* see iface.c */
962 struct list_head interfaces;
963 struct mutex iflist_mtx;
964
965 /*
966 * Key mutex, protects sdata's key_list and sta_info's
967 * key pointers (write access, they're RCU.)
968 */
969 struct mutex key_mtx;
970
971 /* mutex for scan and work locking */
972 struct mutex mtx;
973
974 /* Scanning and BSS list */
975 unsigned long scanning;
976 struct cfg80211_ssid scan_ssid;
977 struct cfg80211_scan_request *int_scan_req;
978 struct cfg80211_scan_request *scan_req, *hw_scan_req;
979 struct ieee80211_channel *scan_channel;
980 enum ieee80211_band hw_scan_band;
981 int scan_channel_idx;
982 int scan_ies_len;
983
984 bool sched_scanning;
985 struct ieee80211_sched_scan_ies sched_scan_ies;
986 struct work_struct sched_scan_stopped_work;
987
988 unsigned long leave_oper_channel_time;
989 enum mac80211_scan_state next_scan_state;
990 struct delayed_work scan_work;
991 struct ieee80211_sub_if_data *scan_sdata;
992 enum nl80211_channel_type _oper_channel_type;
993 struct ieee80211_channel *oper_channel, *csa_channel;
994
995 /* Temporary remain-on-channel for off-channel operations */
996 struct ieee80211_channel *tmp_channel;
997 enum nl80211_channel_type tmp_channel_type;
998
999 /* SNMP counters */
1000 /* dot11CountersTable */
1001 u32 dot11TransmittedFragmentCount;
1002 u32 dot11MulticastTransmittedFrameCount;
1003 u32 dot11FailedCount;
1004 u32 dot11RetryCount;
1005 u32 dot11MultipleRetryCount;
1006 u32 dot11FrameDuplicateCount;
1007 u32 dot11ReceivedFragmentCount;
1008 u32 dot11MulticastReceivedFrameCount;
1009 u32 dot11TransmittedFrameCount;
1010
1011#ifdef CONFIG_MAC80211_LEDS
1012 int tx_led_counter, rx_led_counter;
1013 struct led_trigger *tx_led, *rx_led, *assoc_led, *radio_led;
1014 struct tpt_led_trigger *tpt_led_trigger;
1015 char tx_led_name[32], rx_led_name[32],
1016 assoc_led_name[32], radio_led_name[32];
1017#endif
1018
1019#ifdef CONFIG_MAC80211_DEBUG_COUNTERS
1020 /* TX/RX handler statistics */
1021 unsigned int tx_handlers_drop;
1022 unsigned int tx_handlers_queued;
1023 unsigned int tx_handlers_drop_unencrypted;
1024 unsigned int tx_handlers_drop_fragment;
1025 unsigned int tx_handlers_drop_wep;
1026 unsigned int tx_handlers_drop_not_assoc;
1027 unsigned int tx_handlers_drop_unauth_port;
1028 unsigned int rx_handlers_drop;
1029 unsigned int rx_handlers_queued;
1030 unsigned int rx_handlers_drop_nullfunc;
1031 unsigned int rx_handlers_drop_defrag;
1032 unsigned int rx_handlers_drop_short;
1033 unsigned int rx_handlers_drop_passive_scan;
1034 unsigned int tx_expand_skb_head;
1035 unsigned int tx_expand_skb_head_cloned;
1036 unsigned int rx_expand_skb_head;
1037 unsigned int rx_expand_skb_head2;
1038 unsigned int rx_handlers_fragments;
1039 unsigned int tx_status_drop;
1040#define I802_DEBUG_INC(c) (c)++
1041#else /* CONFIG_MAC80211_DEBUG_COUNTERS */
1042#define I802_DEBUG_INC(c) do { } while (0)
1043#endif /* CONFIG_MAC80211_DEBUG_COUNTERS */
1044
1045
1046 int total_ps_buffered; /* total number of all buffered unicast and
1047 * multicast packets for power saving stations
1048 */
1049 unsigned int wmm_acm; /* bit field of ACM bits (BIT(802.1D tag)) */
1050
1051 bool pspolling;
1052 bool offchannel_ps_enabled;
1053 /*
1054 * PS can only be enabled when we have exactly one managed
1055 * interface (and monitors) in PS, this then points there.
1056 */
1057 struct ieee80211_sub_if_data *ps_sdata;
1058 struct work_struct dynamic_ps_enable_work;
1059 struct work_struct dynamic_ps_disable_work;
1060 struct timer_list dynamic_ps_timer;
1061 struct notifier_block network_latency_notifier;
1062 struct notifier_block ifa_notifier;
1063
1064 /*
1065 * The dynamic ps timeout configured from user space via WEXT -
1066 * this will override whatever chosen by mac80211 internally.
1067 */
1068 int dynamic_ps_forced_timeout;
1069 int dynamic_ps_user_timeout;
1070 bool disable_dynamic_ps;
1071
1072 int user_power_level; /* in dBm */
1073 int power_constr_level; /* in dBm */
1074
1075 enum ieee80211_smps_mode smps_mode;
1076
1077 struct work_struct restart_work;
1078
1079#ifdef CONFIG_MAC80211_DEBUGFS
1080 struct local_debugfsdentries {
1081 struct dentry *rcdir;
1082 struct dentry *keys;
1083 } debugfs;
1084#endif
1085
1086 struct ieee80211_channel *hw_roc_channel;
1087 struct net_device *hw_roc_dev;
1088 struct sk_buff *hw_roc_skb, *hw_roc_skb_for_status;
1089 struct work_struct hw_roc_start, hw_roc_done;
1090 enum nl80211_channel_type hw_roc_channel_type;
1091 unsigned int hw_roc_duration;
1092 u32 hw_roc_cookie;
1093 bool hw_roc_for_tx;
1094
1095 struct idr ack_status_frames;
1096 spinlock_t ack_status_lock;
1097
1098 /* dummy netdev for use w/ NAPI */
1099 struct net_device napi_dev;
1100
1101 struct napi_struct napi;
1102};
1103
1104static inline struct ieee80211_sub_if_data *
1105IEEE80211_DEV_TO_SUB_IF(struct net_device *dev)
1106{
1107 return netdev_priv(dev);
1108}
1109
1110/* this struct represents 802.11n's RA/TID combination */
1111struct ieee80211_ra_tid {
1112 u8 ra[ETH_ALEN];
1113 u16 tid;
1114};
1115
1116/* Parsed Information Elements */
1117struct ieee802_11_elems {
1118 u8 *ie_start;
1119 size_t total_len;
1120
1121 /* pointers to IEs */
1122 u8 *ssid;
1123 u8 *supp_rates;
1124 u8 *fh_params;
1125 u8 *ds_params;
1126 u8 *cf_params;
1127 struct ieee80211_tim_ie *tim;
1128 u8 *ibss_params;
1129 u8 *challenge;
1130 u8 *wpa;
1131 u8 *rsn;
1132 u8 *erp_info;
1133 u8 *ext_supp_rates;
1134 u8 *wmm_info;
1135 u8 *wmm_param;
1136 struct ieee80211_ht_cap *ht_cap_elem;
1137 struct ieee80211_ht_info *ht_info_elem;
1138 struct ieee80211_meshconf_ie *mesh_config;
1139 u8 *mesh_id;
1140 u8 *peering;
1141 u8 *preq;
1142 u8 *prep;
1143 u8 *perr;
1144 struct ieee80211_rann_ie *rann;
1145 u8 *ch_switch_elem;
1146 u8 *country_elem;
1147 u8 *pwr_constr_elem;
1148 u8 *quiet_elem; /* first quite element */
1149 u8 *timeout_int;
1150
1151 /* length of them, respectively */
1152 u8 ssid_len;
1153 u8 supp_rates_len;
1154 u8 fh_params_len;
1155 u8 ds_params_len;
1156 u8 cf_params_len;
1157 u8 tim_len;
1158 u8 ibss_params_len;
1159 u8 challenge_len;
1160 u8 wpa_len;
1161 u8 rsn_len;
1162 u8 erp_info_len;
1163 u8 ext_supp_rates_len;
1164 u8 wmm_info_len;
1165 u8 wmm_param_len;
1166 u8 mesh_id_len;
1167 u8 peering_len;
1168 u8 preq_len;
1169 u8 prep_len;
1170 u8 perr_len;
1171 u8 ch_switch_elem_len;
1172 u8 country_elem_len;
1173 u8 pwr_constr_elem_len;
1174 u8 quiet_elem_len;
1175 u8 num_of_quiet_elem; /* can be more the one */
1176 u8 timeout_int_len;
1177
1178 /* whether a parse error occurred while retrieving these elements */
1179 bool parse_error;
1180};
1181
1182static inline struct ieee80211_local *hw_to_local(
1183 struct ieee80211_hw *hw)
1184{
1185 return container_of(hw, struct ieee80211_local, hw);
1186}
1187
1188
1189static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr)
1190{
1191 return compare_ether_addr(raddr, addr) == 0 ||
1192 is_broadcast_ether_addr(raddr);
1193}
1194
1195
1196int ieee80211_hw_config(struct ieee80211_local *local, u32 changed);
1197void ieee80211_tx_set_protected(struct ieee80211_tx_data *tx);
1198void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
1199 u32 changed);
1200void ieee80211_configure_filter(struct ieee80211_local *local);
1201u32 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata);
1202
1203/* STA code */
1204void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata);
1205int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata,
1206 struct cfg80211_auth_request *req);
1207int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
1208 struct cfg80211_assoc_request *req);
1209int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata,
1210 struct cfg80211_deauth_request *req);
1211int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata,
1212 struct cfg80211_disassoc_request *req);
1213void ieee80211_send_pspoll(struct ieee80211_local *local,
1214 struct ieee80211_sub_if_data *sdata);
1215void ieee80211_recalc_ps(struct ieee80211_local *local, s32 latency);
1216int ieee80211_max_network_latency(struct notifier_block *nb,
1217 unsigned long data, void *dummy);
1218int ieee80211_set_arp_filter(struct ieee80211_sub_if_data *sdata);
1219void ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata,
1220 struct ieee80211_channel_sw_ie *sw_elem,
1221 struct ieee80211_bss *bss,
1222 u64 timestamp);
1223void ieee80211_sta_quiesce(struct ieee80211_sub_if_data *sdata);
1224void ieee80211_sta_restart(struct ieee80211_sub_if_data *sdata);
1225void ieee80211_sta_work(struct ieee80211_sub_if_data *sdata);
1226void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
1227 struct sk_buff *skb);
1228void ieee80211_sta_reset_beacon_monitor(struct ieee80211_sub_if_data *sdata);
1229void ieee80211_sta_reset_conn_monitor(struct ieee80211_sub_if_data *sdata);
1230void ieee80211_mgd_stop(struct ieee80211_sub_if_data *sdata);
1231
1232/* IBSS code */
1233void ieee80211_ibss_notify_scan_completed(struct ieee80211_local *local);
1234void ieee80211_ibss_setup_sdata(struct ieee80211_sub_if_data *sdata);
1235void ieee80211_ibss_rx_no_sta(struct ieee80211_sub_if_data *sdata,
1236 const u8 *bssid, const u8 *addr, u32 supp_rates);
1237int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata,
1238 struct cfg80211_ibss_params *params);
1239int ieee80211_ibss_leave(struct ieee80211_sub_if_data *sdata);
1240void ieee80211_ibss_quiesce(struct ieee80211_sub_if_data *sdata);
1241void ieee80211_ibss_restart(struct ieee80211_sub_if_data *sdata);
1242void ieee80211_ibss_work(struct ieee80211_sub_if_data *sdata);
1243void ieee80211_ibss_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
1244 struct sk_buff *skb);
1245
1246/* mesh code */
1247void ieee80211_mesh_work(struct ieee80211_sub_if_data *sdata);
1248void ieee80211_mesh_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
1249 struct sk_buff *skb);
1250
1251/* scan/BSS handling */
1252void ieee80211_scan_work(struct work_struct *work);
1253int ieee80211_request_ibss_scan(struct ieee80211_sub_if_data *sdata,
1254 const u8 *ssid, u8 ssid_len,
1255 struct ieee80211_channel *chan);
1256int ieee80211_request_scan(struct ieee80211_sub_if_data *sdata,
1257 struct cfg80211_scan_request *req);
1258void ieee80211_scan_cancel(struct ieee80211_local *local);
1259ieee80211_rx_result
1260ieee80211_scan_rx(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb);
1261
1262void ieee80211_mlme_notify_scan_completed(struct ieee80211_local *local);
1263struct ieee80211_bss *
1264ieee80211_bss_info_update(struct ieee80211_local *local,
1265 struct ieee80211_rx_status *rx_status,
1266 struct ieee80211_mgmt *mgmt,
1267 size_t len,
1268 struct ieee802_11_elems *elems,
1269 struct ieee80211_channel *channel,
1270 bool beacon);
1271struct ieee80211_bss *
1272ieee80211_rx_bss_get(struct ieee80211_local *local, u8 *bssid, int freq,
1273 u8 *ssid, u8 ssid_len);
1274void ieee80211_rx_bss_put(struct ieee80211_local *local,
1275 struct ieee80211_bss *bss);
1276
1277/* scheduled scan handling */
1278int ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata,
1279 struct cfg80211_sched_scan_request *req);
1280int ieee80211_request_sched_scan_stop(struct ieee80211_sub_if_data *sdata);
1281void ieee80211_sched_scan_stopped_work(struct work_struct *work);
1282
1283/* off-channel helpers */
1284void ieee80211_offchannel_stop_vifs(struct ieee80211_local *local);
1285void ieee80211_offchannel_return(struct ieee80211_local *local);
1286void ieee80211_hw_roc_setup(struct ieee80211_local *local);
1287
1288/* interface handling */
1289int ieee80211_iface_init(void);
1290void ieee80211_iface_exit(void);
1291int ieee80211_if_add(struct ieee80211_local *local, const char *name,
1292 struct net_device **new_dev, enum nl80211_iftype type,
1293 struct vif_params *params);
1294int ieee80211_if_change_type(struct ieee80211_sub_if_data *sdata,
1295 enum nl80211_iftype type);
1296void ieee80211_if_remove(struct ieee80211_sub_if_data *sdata);
1297void ieee80211_remove_interfaces(struct ieee80211_local *local);
1298u32 __ieee80211_recalc_idle(struct ieee80211_local *local);
1299void ieee80211_recalc_idle(struct ieee80211_local *local);
1300void ieee80211_adjust_monitor_flags(struct ieee80211_sub_if_data *sdata,
1301 const int offset);
1302
1303static inline bool ieee80211_sdata_running(struct ieee80211_sub_if_data *sdata)
1304{
1305 return test_bit(SDATA_STATE_RUNNING, &sdata->state);
1306}
1307
1308/* tx handling */
1309void ieee80211_clear_tx_pending(struct ieee80211_local *local);
1310void ieee80211_tx_pending(unsigned long data);
1311netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb,
1312 struct net_device *dev);
1313netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1314 struct net_device *dev);
1315void ieee80211_purge_tx_queue(struct ieee80211_hw *hw,
1316 struct sk_buff_head *skbs);
1317
1318/* HT */
1319bool ieee80111_cfg_override_disables_ht40(struct ieee80211_sub_if_data *sdata);
1320void ieee80211_apply_htcap_overrides(struct ieee80211_sub_if_data *sdata,
1321 struct ieee80211_sta_ht_cap *ht_cap);
1322void ieee80211_ht_cap_ie_to_sta_ht_cap(struct ieee80211_sub_if_data *sdata,
1323 struct ieee80211_supported_band *sband,
1324 struct ieee80211_ht_cap *ht_cap_ie,
1325 struct ieee80211_sta_ht_cap *ht_cap);
1326void ieee80211_send_delba(struct ieee80211_sub_if_data *sdata,
1327 const u8 *da, u16 tid,
1328 u16 initiator, u16 reason_code);
1329int ieee80211_send_smps_action(struct ieee80211_sub_if_data *sdata,
1330 enum ieee80211_smps_mode smps, const u8 *da,
1331 const u8 *bssid);
1332void ieee80211_request_smps_work(struct work_struct *work);
1333
1334void ___ieee80211_stop_rx_ba_session(struct sta_info *sta, u16 tid,
1335 u16 initiator, u16 reason, bool stop);
1336void __ieee80211_stop_rx_ba_session(struct sta_info *sta, u16 tid,
1337 u16 initiator, u16 reason, bool stop);
1338void ieee80211_sta_tear_down_BA_sessions(struct sta_info *sta, bool tx);
1339void ieee80211_process_delba(struct ieee80211_sub_if_data *sdata,
1340 struct sta_info *sta,
1341 struct ieee80211_mgmt *mgmt, size_t len);
1342void ieee80211_process_addba_resp(struct ieee80211_local *local,
1343 struct sta_info *sta,
1344 struct ieee80211_mgmt *mgmt,
1345 size_t len);
1346void ieee80211_process_addba_request(struct ieee80211_local *local,
1347 struct sta_info *sta,
1348 struct ieee80211_mgmt *mgmt,
1349 size_t len);
1350
1351int __ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid,
1352 enum ieee80211_back_parties initiator,
1353 bool tx);
1354int ___ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid,
1355 enum ieee80211_back_parties initiator,
1356 bool tx);
1357void ieee80211_start_tx_ba_cb(struct ieee80211_vif *vif, u8 *ra, u16 tid);
1358void ieee80211_stop_tx_ba_cb(struct ieee80211_vif *vif, u8 *ra, u8 tid);
1359void ieee80211_ba_session_work(struct work_struct *work);
1360void ieee80211_tx_ba_session_handle_start(struct sta_info *sta, int tid);
1361void ieee80211_release_reorder_timeout(struct sta_info *sta, int tid);
1362
1363/* Spectrum management */
1364void ieee80211_process_measurement_req(struct ieee80211_sub_if_data *sdata,
1365 struct ieee80211_mgmt *mgmt,
1366 size_t len);
1367
1368/* Suspend/resume and hw reconfiguration */
1369int ieee80211_reconfig(struct ieee80211_local *local);
1370void ieee80211_stop_device(struct ieee80211_local *local);
1371
1372#ifdef CONFIG_PM
1373int __ieee80211_suspend(struct ieee80211_hw *hw,
1374 struct cfg80211_wowlan *wowlan);
1375
1376static inline int __ieee80211_resume(struct ieee80211_hw *hw)
1377{
1378 struct ieee80211_local *local = hw_to_local(hw);
1379
1380 WARN(test_bit(SCAN_HW_SCANNING, &local->scanning),
1381 "%s: resume with hardware scan still in progress\n",
1382 wiphy_name(hw->wiphy));
1383
1384 return ieee80211_reconfig(hw_to_local(hw));
1385}
1386#else
1387static inline int __ieee80211_suspend(struct ieee80211_hw *hw,
1388 struct cfg80211_wowlan *wowlan)
1389{
1390 return 0;
1391}
1392
1393static inline int __ieee80211_resume(struct ieee80211_hw *hw)
1394{
1395 return 0;
1396}
1397#endif
1398
1399/* utility functions/constants */
1400extern void *mac80211_wiphy_privid; /* for wiphy privid */
1401u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len,
1402 enum nl80211_iftype type);
1403int ieee80211_frame_duration(struct ieee80211_local *local, size_t len,
1404 int rate, int erp, int short_preamble);
1405void mac80211_ev_michael_mic_failure(struct ieee80211_sub_if_data *sdata, int keyidx,
1406 struct ieee80211_hdr *hdr, const u8 *tsc,
1407 gfp_t gfp);
1408void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata,
1409 bool bss_notify);
1410void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb);
1411
1412void ieee80211_tx_skb_tid(struct ieee80211_sub_if_data *sdata,
1413 struct sk_buff *skb, int tid);
1414static void inline ieee80211_tx_skb(struct ieee80211_sub_if_data *sdata,
1415 struct sk_buff *skb)
1416{
1417 /* Send all internal mgmt frames on VO. Accordingly set TID to 7. */
1418 ieee80211_tx_skb_tid(sdata, skb, 7);
1419}
1420
1421void ieee802_11_parse_elems(u8 *start, size_t len,
1422 struct ieee802_11_elems *elems);
1423u32 ieee802_11_parse_elems_crc(u8 *start, size_t len,
1424 struct ieee802_11_elems *elems,
1425 u64 filter, u32 crc);
1426u32 ieee80211_mandatory_rates(struct ieee80211_local *local,
1427 enum ieee80211_band band);
1428
1429void ieee80211_dynamic_ps_enable_work(struct work_struct *work);
1430void ieee80211_dynamic_ps_disable_work(struct work_struct *work);
1431void ieee80211_dynamic_ps_timer(unsigned long data);
1432void ieee80211_send_nullfunc(struct ieee80211_local *local,
1433 struct ieee80211_sub_if_data *sdata,
1434 int powersave);
1435void ieee80211_sta_rx_notify(struct ieee80211_sub_if_data *sdata,
1436 struct ieee80211_hdr *hdr);
1437void ieee80211_sta_tx_notify(struct ieee80211_sub_if_data *sdata,
1438 struct ieee80211_hdr *hdr, bool ack);
1439void ieee80211_beacon_connection_loss_work(struct work_struct *work);
1440
1441void ieee80211_wake_queues_by_reason(struct ieee80211_hw *hw,
1442 enum queue_stop_reason reason);
1443void ieee80211_stop_queues_by_reason(struct ieee80211_hw *hw,
1444 enum queue_stop_reason reason);
1445void ieee80211_wake_queue_by_reason(struct ieee80211_hw *hw, int queue,
1446 enum queue_stop_reason reason);
1447void ieee80211_stop_queue_by_reason(struct ieee80211_hw *hw, int queue,
1448 enum queue_stop_reason reason);
1449void ieee80211_add_pending_skb(struct ieee80211_local *local,
1450 struct sk_buff *skb);
1451void ieee80211_add_pending_skbs(struct ieee80211_local *local,
1452 struct sk_buff_head *skbs);
1453void ieee80211_add_pending_skbs_fn(struct ieee80211_local *local,
1454 struct sk_buff_head *skbs,
1455 void (*fn)(void *data), void *data);
1456
1457void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata,
1458 u16 transaction, u16 auth_alg,
1459 u8 *extra, size_t extra_len, const u8 *bssid,
1460 const u8 *da, const u8 *key, u8 key_len, u8 key_idx);
1461int ieee80211_build_preq_ies(struct ieee80211_local *local, u8 *buffer,
1462 const u8 *ie, size_t ie_len,
1463 enum ieee80211_band band, u32 rate_mask,
1464 u8 channel);
1465struct sk_buff *ieee80211_build_probe_req(struct ieee80211_sub_if_data *sdata,
1466 u8 *dst, u32 ratemask,
1467 const u8 *ssid, size_t ssid_len,
1468 const u8 *ie, size_t ie_len,
1469 bool directed);
1470void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst,
1471 const u8 *ssid, size_t ssid_len,
1472 const u8 *ie, size_t ie_len,
1473 u32 ratemask, bool directed, bool no_cck);
1474
1475void ieee80211_sta_def_wmm_params(struct ieee80211_sub_if_data *sdata,
1476 const size_t supp_rates_len,
1477 const u8 *supp_rates);
1478u32 ieee80211_sta_get_rates(struct ieee80211_local *local,
1479 struct ieee802_11_elems *elems,
1480 enum ieee80211_band band);
1481int __ieee80211_request_smps(struct ieee80211_sub_if_data *sdata,
1482 enum ieee80211_smps_mode smps_mode);
1483void ieee80211_recalc_smps(struct ieee80211_local *local);
1484
1485size_t ieee80211_ie_split(const u8 *ies, size_t ielen,
1486 const u8 *ids, int n_ids, size_t offset);
1487size_t ieee80211_ie_split_vendor(const u8 *ies, size_t ielen, size_t offset);
1488u8 *ieee80211_ie_build_ht_cap(u8 *pos, struct ieee80211_sta_ht_cap *ht_cap,
1489 u16 cap);
1490u8 *ieee80211_ie_build_ht_info(u8 *pos,
1491 struct ieee80211_sta_ht_cap *ht_cap,
1492 struct ieee80211_channel *channel,
1493 enum nl80211_channel_type channel_type);
1494
1495/* internal work items */
1496void ieee80211_work_init(struct ieee80211_local *local);
1497void ieee80211_add_work(struct ieee80211_work *wk);
1498void free_work(struct ieee80211_work *wk);
1499void ieee80211_work_purge(struct ieee80211_sub_if_data *sdata);
1500int ieee80211_wk_remain_on_channel(struct ieee80211_sub_if_data *sdata,
1501 struct ieee80211_channel *chan,
1502 enum nl80211_channel_type channel_type,
1503 unsigned int duration, u64 *cookie);
1504int ieee80211_wk_cancel_remain_on_channel(
1505 struct ieee80211_sub_if_data *sdata, u64 cookie);
1506
1507/* channel management */
1508enum ieee80211_chan_mode {
1509 CHAN_MODE_UNDEFINED,
1510 CHAN_MODE_HOPPING,
1511 CHAN_MODE_FIXED,
1512};
1513
1514enum ieee80211_chan_mode
1515ieee80211_get_channel_mode(struct ieee80211_local *local,
1516 struct ieee80211_sub_if_data *ignore);
1517bool ieee80211_set_channel_type(struct ieee80211_local *local,
1518 struct ieee80211_sub_if_data *sdata,
1519 enum nl80211_channel_type chantype);
1520enum nl80211_channel_type
1521ieee80211_ht_info_to_channel_type(struct ieee80211_ht_info *ht_info);
1522enum nl80211_channel_type ieee80211_get_tx_channel_type(
1523 struct ieee80211_local *local,
1524 enum nl80211_channel_type channel_type);
1525
1526#ifdef CONFIG_MAC80211_NOINLINE
1527#define debug_noinline noinline
1528#else
1529#define debug_noinline
1530#endif
1531
1532#endif /* IEEE80211_I_H */