]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - net/mac80211/ieee80211_i.h
mac80211: fix key vs. sta locking problems
[mirror_ubuntu-jammy-kernel.git] / net / mac80211 / ieee80211_i.h
1 /*
2 * Copyright 2002-2005, Instant802 Networks, Inc.
3 * Copyright 2005, Devicescape Software, Inc.
4 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
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 <net/wireless.h>
26 #include "ieee80211_key.h"
27 #include "sta_info.h"
28
29 /* ieee80211.o internal definitions, etc. These are not included into
30 * low-level drivers. */
31
32 #ifndef ETH_P_PAE
33 #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
34 #endif /* ETH_P_PAE */
35
36 #define WLAN_FC_DATA_PRESENT(fc) (((fc) & 0x4c) == 0x08)
37
38 #define IEEE80211_FC(type, subtype) cpu_to_le16(type | subtype)
39
40 struct ieee80211_local;
41
42 /* Maximum number of broadcast/multicast frames to buffer when some of the
43 * associated stations are using power saving. */
44 #define AP_MAX_BC_BUFFER 128
45
46 /* Maximum number of frames buffered to all STAs, including multicast frames.
47 * Note: increasing this limit increases the potential memory requirement. Each
48 * frame can be up to about 2 kB long. */
49 #define TOTAL_MAX_TX_BUFFER 512
50
51 /* Required encryption head and tailroom */
52 #define IEEE80211_ENCRYPT_HEADROOM 8
53 #define IEEE80211_ENCRYPT_TAILROOM 12
54
55 /* IEEE 802.11 (Ch. 9.5 Defragmentation) requires support for concurrent
56 * reception of at least three fragmented frames. This limit can be increased
57 * by changing this define, at the cost of slower frame reassembly and
58 * increased memory use (about 2 kB of RAM per entry). */
59 #define IEEE80211_FRAGMENT_MAX 4
60
61 struct ieee80211_fragment_entry {
62 unsigned long first_frag_time;
63 unsigned int seq;
64 unsigned int rx_queue;
65 unsigned int last_frag;
66 unsigned int extra_len;
67 struct sk_buff_head skb_list;
68 int ccmp; /* Whether fragments were encrypted with CCMP */
69 u8 last_pn[6]; /* PN of the last fragment if CCMP was used */
70 };
71
72
73 struct ieee80211_sta_bss {
74 struct list_head list;
75 struct ieee80211_sta_bss *hnext;
76 size_t ssid_len;
77
78 atomic_t users;
79
80 u8 bssid[ETH_ALEN];
81 u8 ssid[IEEE80211_MAX_SSID_LEN];
82 u16 capability; /* host byte order */
83 enum ieee80211_band band;
84 int freq;
85 int rssi, signal, noise;
86 u8 *wpa_ie;
87 size_t wpa_ie_len;
88 u8 *rsn_ie;
89 size_t rsn_ie_len;
90 u8 *wmm_ie;
91 size_t wmm_ie_len;
92 u8 *ht_ie;
93 size_t ht_ie_len;
94 #ifdef CONFIG_MAC80211_MESH
95 u8 *mesh_id;
96 size_t mesh_id_len;
97 u8 *mesh_cfg;
98 #endif
99 #define IEEE80211_MAX_SUPP_RATES 32
100 u8 supp_rates[IEEE80211_MAX_SUPP_RATES];
101 size_t supp_rates_len;
102 u64 timestamp;
103 int beacon_int;
104
105 int probe_resp;
106 unsigned long last_update;
107
108 /* during assocation, we save an ERP value from a probe response so
109 * that we can feed ERP info to the driver when handling the
110 * association completes. these fields probably won't be up-to-date
111 * otherwise, you probably don't want to use them. */
112 int has_erp_value;
113 u8 erp_value;
114 };
115
116 static inline u8 *bss_mesh_cfg(struct ieee80211_sta_bss *bss)
117 {
118 #ifdef CONFIG_MAC80211_MESH
119 return bss->mesh_cfg;
120 #endif
121 return NULL;
122 }
123
124 static inline u8 *bss_mesh_id(struct ieee80211_sta_bss *bss)
125 {
126 #ifdef CONFIG_MAC80211_MESH
127 return bss->mesh_id;
128 #endif
129 return NULL;
130 }
131
132 static inline u8 bss_mesh_id_len(struct ieee80211_sta_bss *bss)
133 {
134 #ifdef CONFIG_MAC80211_MESH
135 return bss->mesh_id_len;
136 #endif
137 return 0;
138 }
139
140
141 typedef unsigned __bitwise__ ieee80211_tx_result;
142 #define TX_CONTINUE ((__force ieee80211_tx_result) 0u)
143 #define TX_DROP ((__force ieee80211_tx_result) 1u)
144 #define TX_QUEUED ((__force ieee80211_tx_result) 2u)
145
146 #define IEEE80211_TX_FRAGMENTED BIT(0)
147 #define IEEE80211_TX_UNICAST BIT(1)
148 #define IEEE80211_TX_PS_BUFFERED BIT(2)
149 #define IEEE80211_TX_PROBE_LAST_FRAG BIT(3)
150 #define IEEE80211_TX_INJECTED BIT(4)
151
152 struct ieee80211_tx_data {
153 struct sk_buff *skb;
154 struct net_device *dev;
155 struct ieee80211_local *local;
156 struct ieee80211_sub_if_data *sdata;
157 struct sta_info *sta;
158 struct ieee80211_key *key;
159
160 struct ieee80211_tx_control *control;
161 struct ieee80211_channel *channel;
162 struct ieee80211_rate *rate;
163 /* use this rate (if set) for last fragment; rate can
164 * be set to lower rate for the first fragments, e.g.,
165 * when using CTS protection with IEEE 802.11g. */
166 struct ieee80211_rate *last_frag_rate;
167
168 /* Extra fragments (in addition to the first fragment
169 * in skb) */
170 struct sk_buff **extra_frag;
171 int num_extra_frag;
172
173 u16 fc, ethertype;
174 unsigned int flags;
175 };
176
177
178 typedef unsigned __bitwise__ ieee80211_rx_result;
179 #define RX_CONTINUE ((__force ieee80211_rx_result) 0u)
180 #define RX_DROP_UNUSABLE ((__force ieee80211_rx_result) 1u)
181 #define RX_DROP_MONITOR ((__force ieee80211_rx_result) 2u)
182 #define RX_QUEUED ((__force ieee80211_rx_result) 3u)
183
184 #define IEEE80211_RX_IN_SCAN BIT(0)
185 /* frame is destined to interface currently processed (incl. multicast frames) */
186 #define IEEE80211_RX_RA_MATCH BIT(1)
187 #define IEEE80211_RX_AMSDU BIT(2)
188 #define IEEE80211_RX_CMNTR_REPORTED BIT(3)
189 #define IEEE80211_RX_FRAGMENTED BIT(4)
190
191 struct ieee80211_rx_data {
192 struct sk_buff *skb;
193 struct net_device *dev;
194 struct ieee80211_local *local;
195 struct ieee80211_sub_if_data *sdata;
196 struct sta_info *sta;
197 struct ieee80211_key *key;
198 struct ieee80211_rx_status *status;
199 struct ieee80211_rate *rate;
200
201 u16 fc, ethertype;
202 unsigned int flags;
203 int sent_ps_buffered;
204 int queue;
205 int load;
206 u32 tkip_iv32;
207 u16 tkip_iv16;
208 };
209
210 /* flags used in struct ieee80211_tx_packet_data.flags */
211 #define IEEE80211_TXPD_REQ_TX_STATUS BIT(0)
212 #define IEEE80211_TXPD_DO_NOT_ENCRYPT BIT(1)
213 #define IEEE80211_TXPD_REQUEUE BIT(2)
214 #define IEEE80211_TXPD_EAPOL_FRAME BIT(3)
215 #define IEEE80211_TXPD_AMPDU BIT(4)
216 /* Stored in sk_buff->cb */
217 struct ieee80211_tx_packet_data {
218 int ifindex;
219 unsigned long jiffies;
220 unsigned int flags;
221 u8 queue;
222 };
223
224 struct ieee80211_tx_stored_packet {
225 struct ieee80211_tx_control control;
226 struct sk_buff *skb;
227 struct sk_buff **extra_frag;
228 struct ieee80211_rate *last_frag_rate;
229 int num_extra_frag;
230 unsigned int last_frag_rate_ctrl_probe;
231 };
232
233 struct beacon_data {
234 u8 *head, *tail;
235 int head_len, tail_len;
236 int dtim_period;
237 };
238
239 struct ieee80211_if_ap {
240 struct beacon_data *beacon;
241
242 struct list_head vlans;
243
244 u8 ssid[IEEE80211_MAX_SSID_LEN];
245 size_t ssid_len;
246
247 /* yes, this looks ugly, but guarantees that we can later use
248 * bitmap_empty :)
249 * NB: don't touch this bitmap, use sta_info_{set,clear}_tim_bit */
250 u8 tim[sizeof(unsigned long) * BITS_TO_LONGS(IEEE80211_MAX_AID + 1)];
251 struct sk_buff_head ps_bc_buf;
252 atomic_t num_sta_ps; /* number of stations in PS mode */
253 int dtim_count;
254 int force_unicast_rateidx; /* forced TX rateidx for unicast frames */
255 int max_ratectrl_rateidx; /* max TX rateidx for rate control */
256 int num_beacons; /* number of TXed beacon frames for this BSS */
257 };
258
259 struct ieee80211_if_wds {
260 struct sta_info *sta;
261 u8 remote_addr[ETH_ALEN];
262 };
263
264 struct ieee80211_if_vlan {
265 struct ieee80211_sub_if_data *ap;
266 struct list_head list;
267 };
268
269 struct mesh_stats {
270 __u32 fwded_frames; /* Mesh forwarded frames */
271 __u32 dropped_frames_ttl; /* Not transmitted since mesh_ttl == 0*/
272 __u32 dropped_frames_no_route; /* Not transmitted, no route found */
273 atomic_t estab_plinks;
274 };
275
276 #define PREQ_Q_F_START 0x1
277 #define PREQ_Q_F_REFRESH 0x2
278 struct mesh_preq_queue {
279 struct list_head list;
280 u8 dst[ETH_ALEN];
281 u8 flags;
282 };
283
284 struct mesh_config {
285 /* Timeouts in ms */
286 /* Mesh plink management parameters */
287 u16 dot11MeshRetryTimeout;
288 u16 dot11MeshConfirmTimeout;
289 u16 dot11MeshHoldingTimeout;
290 u16 dot11MeshMaxPeerLinks;
291 u8 dot11MeshMaxRetries;
292 u8 dot11MeshTTL;
293 bool auto_open_plinks;
294 /* HWMP parameters */
295 u8 dot11MeshHWMPmaxPREQretries;
296 u32 path_refresh_time;
297 u16 min_discovery_timeout;
298 u32 dot11MeshHWMPactivePathTimeout;
299 u16 dot11MeshHWMPpreqMinInterval;
300 u16 dot11MeshHWMPnetDiameterTraversalTime;
301 };
302
303
304 /* flags used in struct ieee80211_if_sta.flags */
305 #define IEEE80211_STA_SSID_SET BIT(0)
306 #define IEEE80211_STA_BSSID_SET BIT(1)
307 #define IEEE80211_STA_PREV_BSSID_SET BIT(2)
308 #define IEEE80211_STA_AUTHENTICATED BIT(3)
309 #define IEEE80211_STA_ASSOCIATED BIT(4)
310 #define IEEE80211_STA_PROBEREQ_POLL BIT(5)
311 #define IEEE80211_STA_CREATE_IBSS BIT(6)
312 #define IEEE80211_STA_MIXED_CELL BIT(7)
313 #define IEEE80211_STA_WMM_ENABLED BIT(8)
314 #define IEEE80211_STA_AUTO_SSID_SEL BIT(10)
315 #define IEEE80211_STA_AUTO_BSSID_SEL BIT(11)
316 #define IEEE80211_STA_AUTO_CHANNEL_SEL BIT(12)
317 #define IEEE80211_STA_PRIVACY_INVOKED BIT(13)
318 struct ieee80211_if_sta {
319 struct timer_list timer;
320 struct work_struct work;
321 u8 bssid[ETH_ALEN], prev_bssid[ETH_ALEN];
322 u8 ssid[IEEE80211_MAX_SSID_LEN];
323 enum {
324 IEEE80211_DISABLED, IEEE80211_AUTHENTICATE,
325 IEEE80211_ASSOCIATE, IEEE80211_ASSOCIATED,
326 IEEE80211_IBSS_SEARCH, IEEE80211_IBSS_JOINED,
327 IEEE80211_MESH_UP
328 } state;
329 size_t ssid_len;
330 u8 scan_ssid[IEEE80211_MAX_SSID_LEN];
331 size_t scan_ssid_len;
332 #ifdef CONFIG_MAC80211_MESH
333 struct timer_list mesh_path_timer;
334 u8 mesh_id[IEEE80211_MAX_MESH_ID_LEN];
335 size_t mesh_id_len;
336 /* Active Path Selection Protocol Identifier */
337 u8 mesh_pp_id[4];
338 /* Active Path Selection Metric Identifier */
339 u8 mesh_pm_id[4];
340 /* Congestion Control Mode Identifier */
341 u8 mesh_cc_id[4];
342 /* Local mesh Destination Sequence Number */
343 u32 dsn;
344 /* Last used PREQ ID */
345 u32 preq_id;
346 atomic_t mpaths;
347 /* Timestamp of last DSN update */
348 unsigned long last_dsn_update;
349 /* Timestamp of last DSN sent */
350 unsigned long last_preq;
351 struct mesh_rmc *rmc;
352 spinlock_t mesh_preq_queue_lock;
353 struct mesh_preq_queue preq_queue;
354 int preq_queue_len;
355 struct mesh_stats mshstats;
356 struct mesh_config mshcfg;
357 u8 mesh_seqnum[3];
358 bool accepting_plinks;
359 #endif
360 u16 aid;
361 u16 ap_capab, capab;
362 u8 *extra_ie; /* to be added to the end of AssocReq */
363 size_t extra_ie_len;
364
365 /* The last AssocReq/Resp IEs */
366 u8 *assocreq_ies, *assocresp_ies;
367 size_t assocreq_ies_len, assocresp_ies_len;
368
369 struct sk_buff_head skb_queue;
370
371 int auth_tries, assoc_tries;
372
373 unsigned long request;
374
375 unsigned long last_probe;
376
377 unsigned int flags;
378 #define IEEE80211_STA_REQ_SCAN 0
379 #define IEEE80211_STA_REQ_AUTH 1
380 #define IEEE80211_STA_REQ_RUN 2
381
382 #define IEEE80211_AUTH_ALG_OPEN BIT(0)
383 #define IEEE80211_AUTH_ALG_SHARED_KEY BIT(1)
384 #define IEEE80211_AUTH_ALG_LEAP BIT(2)
385 unsigned int auth_algs; /* bitfield of allowed auth algs */
386 int auth_alg; /* currently used IEEE 802.11 authentication algorithm */
387 int auth_transaction;
388
389 unsigned long ibss_join_req;
390 struct sk_buff *probe_resp; /* ProbeResp template for IBSS */
391 u32 supp_rates_bits[IEEE80211_NUM_BANDS];
392
393 int wmm_last_param_set;
394 int num_beacons; /* number of TXed beacon frames by this STA */
395 };
396
397 static inline void ieee80211_if_sta_set_mesh_id(struct ieee80211_if_sta *ifsta,
398 u8 mesh_id_len, u8 *mesh_id)
399 {
400 #ifdef CONFIG_MAC80211_MESH
401 ifsta->mesh_id_len = mesh_id_len;
402 memcpy(ifsta->mesh_id, mesh_id, mesh_id_len);
403 #endif
404 }
405
406 #ifdef CONFIG_MAC80211_MESH
407 #define IEEE80211_IFSTA_MESH_CTR_INC(sta, name) \
408 do { (sta)->mshstats.name++; } while (0)
409 #else
410 #define IEEE80211_IFSTA_MESH_CTR_INC(sta, name) \
411 do { } while (0)
412 #endif
413
414 /* flags used in struct ieee80211_sub_if_data.flags */
415 #define IEEE80211_SDATA_ALLMULTI BIT(0)
416 #define IEEE80211_SDATA_PROMISC BIT(1)
417 #define IEEE80211_SDATA_USERSPACE_MLME BIT(2)
418 #define IEEE80211_SDATA_OPERATING_GMODE BIT(3)
419 struct ieee80211_sub_if_data {
420 struct list_head list;
421
422 struct wireless_dev wdev;
423
424 /* keys */
425 struct list_head key_list;
426
427 struct net_device *dev;
428 struct ieee80211_local *local;
429
430 unsigned int flags;
431
432 int drop_unencrypted;
433
434 /*
435 * basic rates of this AP or the AP we're associated to
436 */
437 u64 basic_rates;
438
439 u16 sequence;
440
441 /* Fragment table for host-based reassembly */
442 struct ieee80211_fragment_entry fragments[IEEE80211_FRAGMENT_MAX];
443 unsigned int fragment_next;
444
445 #define NUM_DEFAULT_KEYS 4
446 struct ieee80211_key *keys[NUM_DEFAULT_KEYS];
447 struct ieee80211_key *default_key;
448
449 /*
450 * BSS configuration for this interface.
451 *
452 * FIXME: I feel bad putting this here when we already have a
453 * bss pointer, but the bss pointer is just wrong when
454 * you have multiple virtual STA mode interfaces...
455 * This needs to be fixed.
456 */
457 struct ieee80211_bss_conf bss_conf;
458 struct ieee80211_if_ap *bss; /* BSS that this device belongs to */
459
460 union {
461 struct ieee80211_if_ap ap;
462 struct ieee80211_if_wds wds;
463 struct ieee80211_if_vlan vlan;
464 struct ieee80211_if_sta sta;
465 u32 mntr_flags;
466 } u;
467 int channel_use;
468 int channel_use_raw;
469
470 #ifdef CONFIG_MAC80211_DEBUGFS
471 struct dentry *debugfsdir;
472 union {
473 struct {
474 struct dentry *channel_use;
475 struct dentry *drop_unencrypted;
476 struct dentry *state;
477 struct dentry *bssid;
478 struct dentry *prev_bssid;
479 struct dentry *ssid_len;
480 struct dentry *aid;
481 struct dentry *ap_capab;
482 struct dentry *capab;
483 struct dentry *extra_ie_len;
484 struct dentry *auth_tries;
485 struct dentry *assoc_tries;
486 struct dentry *auth_algs;
487 struct dentry *auth_alg;
488 struct dentry *auth_transaction;
489 struct dentry *flags;
490 struct dentry *num_beacons_sta;
491 } sta;
492 struct {
493 struct dentry *channel_use;
494 struct dentry *drop_unencrypted;
495 struct dentry *num_sta_ps;
496 struct dentry *dtim_count;
497 struct dentry *num_beacons;
498 struct dentry *force_unicast_rateidx;
499 struct dentry *max_ratectrl_rateidx;
500 struct dentry *num_buffered_multicast;
501 } ap;
502 struct {
503 struct dentry *channel_use;
504 struct dentry *drop_unencrypted;
505 struct dentry *peer;
506 } wds;
507 struct {
508 struct dentry *channel_use;
509 struct dentry *drop_unencrypted;
510 } vlan;
511 struct {
512 struct dentry *mode;
513 } monitor;
514 struct dentry *default_key;
515 } debugfs;
516
517 #ifdef CONFIG_MAC80211_MESH
518 struct dentry *mesh_stats_dir;
519 struct {
520 struct dentry *fwded_frames;
521 struct dentry *dropped_frames_ttl;
522 struct dentry *dropped_frames_no_route;
523 struct dentry *estab_plinks;
524 struct timer_list mesh_path_timer;
525 } mesh_stats;
526
527 struct dentry *mesh_config_dir;
528 struct {
529 struct dentry *dot11MeshRetryTimeout;
530 struct dentry *dot11MeshConfirmTimeout;
531 struct dentry *dot11MeshHoldingTimeout;
532 struct dentry *dot11MeshMaxRetries;
533 struct dentry *dot11MeshTTL;
534 struct dentry *auto_open_plinks;
535 struct dentry *dot11MeshMaxPeerLinks;
536 struct dentry *dot11MeshHWMPactivePathTimeout;
537 struct dentry *dot11MeshHWMPpreqMinInterval;
538 struct dentry *dot11MeshHWMPnetDiameterTraversalTime;
539 struct dentry *dot11MeshHWMPmaxPREQretries;
540 struct dentry *path_refresh_time;
541 struct dentry *min_discovery_timeout;
542 } mesh_config;
543 #endif
544
545 #endif
546 /* must be last, dynamically sized area in this! */
547 struct ieee80211_vif vif;
548 };
549
550 static inline
551 struct ieee80211_sub_if_data *vif_to_sdata(struct ieee80211_vif *p)
552 {
553 return container_of(p, struct ieee80211_sub_if_data, vif);
554 }
555
556 #define IEEE80211_DEV_TO_SUB_IF(dev) netdev_priv(dev)
557
558 enum {
559 IEEE80211_RX_MSG = 1,
560 IEEE80211_TX_STATUS_MSG = 2,
561 IEEE80211_DELBA_MSG = 3,
562 IEEE80211_ADDBA_MSG = 4,
563 };
564
565 struct ieee80211_local {
566 /* embed the driver visible part.
567 * don't cast (use the static inlines below), but we keep
568 * it first anyway so they become a no-op */
569 struct ieee80211_hw hw;
570
571 const struct ieee80211_ops *ops;
572
573 struct net_device *mdev; /* wmaster# - "master" 802.11 device */
574 int open_count;
575 int monitors, cooked_mntrs;
576 /* number of interfaces with corresponding FIF_ flags */
577 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss;
578 unsigned int filter_flags; /* FIF_* */
579 struct iw_statistics wstats;
580 u8 wstats_flags;
581 bool tim_in_locked_section; /* see ieee80211_beacon_get() */
582 int tx_headroom; /* required headroom for hardware/radiotap */
583
584 enum {
585 IEEE80211_DEV_UNINITIALIZED = 0,
586 IEEE80211_DEV_REGISTERED,
587 IEEE80211_DEV_UNREGISTERED,
588 } reg_state;
589
590 /* Tasklet and skb queue to process calls from IRQ mode. All frames
591 * added to skb_queue will be processed, but frames in
592 * skb_queue_unreliable may be dropped if the total length of these
593 * queues increases over the limit. */
594 #define IEEE80211_IRQSAFE_QUEUE_LIMIT 128
595 struct tasklet_struct tasklet;
596 struct sk_buff_head skb_queue;
597 struct sk_buff_head skb_queue_unreliable;
598
599 /* Station data */
600 /*
601 * The lock only protects the list, hash, timer and counter
602 * against manipulation, reads are done in RCU. Additionally,
603 * the lock protects each BSS's TIM bitmap, a few items in
604 * STA info structures and various key pointers.
605 */
606 spinlock_t sta_lock;
607 unsigned long num_sta;
608 struct list_head sta_list;
609 struct list_head sta_flush_list;
610 struct work_struct sta_flush_work;
611 struct sta_info *sta_hash[STA_HASH_SIZE];
612 struct timer_list sta_cleanup;
613
614 unsigned long state[NUM_TX_DATA_QUEUES_AMPDU];
615 struct ieee80211_tx_stored_packet pending_packet[NUM_TX_DATA_QUEUES_AMPDU];
616 struct tasklet_struct tx_pending_tasklet;
617
618 /* number of interfaces with corresponding IFF_ flags */
619 atomic_t iff_allmultis, iff_promiscs;
620
621 struct rate_control_ref *rate_ctrl;
622
623 int rts_threshold;
624 int fragmentation_threshold;
625 int short_retry_limit; /* dot11ShortRetryLimit */
626 int long_retry_limit; /* dot11LongRetryLimit */
627
628 struct crypto_blkcipher *wep_tx_tfm;
629 struct crypto_blkcipher *wep_rx_tfm;
630 u32 wep_iv;
631
632 int bridge_packets; /* bridge packets between associated stations and
633 * deliver multicast frames both back to wireless
634 * media and to the local net stack */
635
636 struct list_head interfaces;
637
638 bool sta_sw_scanning;
639 bool sta_hw_scanning;
640 int scan_channel_idx;
641 enum ieee80211_band scan_band;
642
643 enum { SCAN_SET_CHANNEL, SCAN_SEND_PROBE } scan_state;
644 unsigned long last_scan_completed;
645 struct delayed_work scan_work;
646 struct net_device *scan_dev;
647 struct ieee80211_channel *oper_channel, *scan_channel;
648 u8 scan_ssid[IEEE80211_MAX_SSID_LEN];
649 size_t scan_ssid_len;
650 struct list_head sta_bss_list;
651 struct ieee80211_sta_bss *sta_bss_hash[STA_HASH_SIZE];
652 spinlock_t sta_bss_lock;
653
654 /* SNMP counters */
655 /* dot11CountersTable */
656 u32 dot11TransmittedFragmentCount;
657 u32 dot11MulticastTransmittedFrameCount;
658 u32 dot11FailedCount;
659 u32 dot11RetryCount;
660 u32 dot11MultipleRetryCount;
661 u32 dot11FrameDuplicateCount;
662 u32 dot11ReceivedFragmentCount;
663 u32 dot11MulticastReceivedFrameCount;
664 u32 dot11TransmittedFrameCount;
665 u32 dot11WEPUndecryptableCount;
666
667 #ifdef CONFIG_MAC80211_LEDS
668 int tx_led_counter, rx_led_counter;
669 struct led_trigger *tx_led, *rx_led, *assoc_led, *radio_led;
670 char tx_led_name[32], rx_led_name[32],
671 assoc_led_name[32], radio_led_name[32];
672 #endif
673
674 u32 channel_use;
675 u32 channel_use_raw;
676
677 #ifdef CONFIG_MAC80211_DEBUGFS
678 struct work_struct sta_debugfs_add;
679 #endif
680
681 #ifdef CONFIG_MAC80211_DEBUG_COUNTERS
682 /* TX/RX handler statistics */
683 unsigned int tx_handlers_drop;
684 unsigned int tx_handlers_queued;
685 unsigned int tx_handlers_drop_unencrypted;
686 unsigned int tx_handlers_drop_fragment;
687 unsigned int tx_handlers_drop_wep;
688 unsigned int tx_handlers_drop_not_assoc;
689 unsigned int tx_handlers_drop_unauth_port;
690 unsigned int rx_handlers_drop;
691 unsigned int rx_handlers_queued;
692 unsigned int rx_handlers_drop_nullfunc;
693 unsigned int rx_handlers_drop_defrag;
694 unsigned int rx_handlers_drop_short;
695 unsigned int rx_handlers_drop_passive_scan;
696 unsigned int tx_expand_skb_head;
697 unsigned int tx_expand_skb_head_cloned;
698 unsigned int rx_expand_skb_head;
699 unsigned int rx_expand_skb_head2;
700 unsigned int rx_handlers_fragments;
701 unsigned int tx_status_drop;
702 unsigned int wme_rx_queue[NUM_RX_DATA_QUEUES];
703 unsigned int wme_tx_queue[NUM_RX_DATA_QUEUES];
704 #define I802_DEBUG_INC(c) (c)++
705 #else /* CONFIG_MAC80211_DEBUG_COUNTERS */
706 #define I802_DEBUG_INC(c) do { } while (0)
707 #endif /* CONFIG_MAC80211_DEBUG_COUNTERS */
708
709
710 int total_ps_buffered; /* total number of all buffered unicast and
711 * multicast packets for power saving stations
712 */
713 int wifi_wme_noack_test;
714 unsigned int wmm_acm; /* bit field of ACM bits (BIT(802.1D tag)) */
715
716 #ifdef CONFIG_MAC80211_DEBUGFS
717 struct local_debugfsdentries {
718 struct dentry *frequency;
719 struct dentry *antenna_sel_tx;
720 struct dentry *antenna_sel_rx;
721 struct dentry *bridge_packets;
722 struct dentry *rts_threshold;
723 struct dentry *fragmentation_threshold;
724 struct dentry *short_retry_limit;
725 struct dentry *long_retry_limit;
726 struct dentry *total_ps_buffered;
727 struct dentry *wep_iv;
728 struct dentry *statistics;
729 struct local_debugfsdentries_statsdentries {
730 struct dentry *transmitted_fragment_count;
731 struct dentry *multicast_transmitted_frame_count;
732 struct dentry *failed_count;
733 struct dentry *retry_count;
734 struct dentry *multiple_retry_count;
735 struct dentry *frame_duplicate_count;
736 struct dentry *received_fragment_count;
737 struct dentry *multicast_received_frame_count;
738 struct dentry *transmitted_frame_count;
739 struct dentry *wep_undecryptable_count;
740 struct dentry *num_scans;
741 #ifdef CONFIG_MAC80211_DEBUG_COUNTERS
742 struct dentry *tx_handlers_drop;
743 struct dentry *tx_handlers_queued;
744 struct dentry *tx_handlers_drop_unencrypted;
745 struct dentry *tx_handlers_drop_fragment;
746 struct dentry *tx_handlers_drop_wep;
747 struct dentry *tx_handlers_drop_not_assoc;
748 struct dentry *tx_handlers_drop_unauth_port;
749 struct dentry *rx_handlers_drop;
750 struct dentry *rx_handlers_queued;
751 struct dentry *rx_handlers_drop_nullfunc;
752 struct dentry *rx_handlers_drop_defrag;
753 struct dentry *rx_handlers_drop_short;
754 struct dentry *rx_handlers_drop_passive_scan;
755 struct dentry *tx_expand_skb_head;
756 struct dentry *tx_expand_skb_head_cloned;
757 struct dentry *rx_expand_skb_head;
758 struct dentry *rx_expand_skb_head2;
759 struct dentry *rx_handlers_fragments;
760 struct dentry *tx_status_drop;
761 struct dentry *wme_tx_queue;
762 struct dentry *wme_rx_queue;
763 #endif
764 struct dentry *dot11ACKFailureCount;
765 struct dentry *dot11RTSFailureCount;
766 struct dentry *dot11FCSErrorCount;
767 struct dentry *dot11RTSSuccessCount;
768 } stats;
769 struct dentry *stations;
770 struct dentry *keys;
771 } debugfs;
772 #endif
773 };
774
775 /* this struct represents 802.11n's RA/TID combination */
776 struct ieee80211_ra_tid {
777 u8 ra[ETH_ALEN];
778 u16 tid;
779 };
780
781 /* Parsed Information Elements */
782 struct ieee802_11_elems {
783 /* pointers to IEs */
784 u8 *ssid;
785 u8 *supp_rates;
786 u8 *fh_params;
787 u8 *ds_params;
788 u8 *cf_params;
789 u8 *tim;
790 u8 *ibss_params;
791 u8 *challenge;
792 u8 *wpa;
793 u8 *rsn;
794 u8 *erp_info;
795 u8 *ext_supp_rates;
796 u8 *wmm_info;
797 u8 *wmm_param;
798 u8 *ht_cap_elem;
799 u8 *ht_info_elem;
800 u8 *mesh_config;
801 u8 *mesh_id;
802 u8 *peer_link;
803 u8 *preq;
804 u8 *prep;
805 u8 *perr;
806
807 /* length of them, respectively */
808 u8 ssid_len;
809 u8 supp_rates_len;
810 u8 fh_params_len;
811 u8 ds_params_len;
812 u8 cf_params_len;
813 u8 tim_len;
814 u8 ibss_params_len;
815 u8 challenge_len;
816 u8 wpa_len;
817 u8 rsn_len;
818 u8 erp_info_len;
819 u8 ext_supp_rates_len;
820 u8 wmm_info_len;
821 u8 wmm_param_len;
822 u8 ht_cap_elem_len;
823 u8 ht_info_elem_len;
824 u8 mesh_config_len;
825 u8 mesh_id_len;
826 u8 peer_link_len;
827 u8 preq_len;
828 u8 prep_len;
829 u8 perr_len;
830 };
831
832 static inline struct ieee80211_local *hw_to_local(
833 struct ieee80211_hw *hw)
834 {
835 return container_of(hw, struct ieee80211_local, hw);
836 }
837
838 static inline struct ieee80211_hw *local_to_hw(
839 struct ieee80211_local *local)
840 {
841 return &local->hw;
842 }
843
844 enum ieee80211_link_state_t {
845 IEEE80211_LINK_STATE_XOFF = 0,
846 IEEE80211_LINK_STATE_PENDING,
847 };
848
849 struct sta_attribute {
850 struct attribute attr;
851 ssize_t (*show)(const struct sta_info *, char *buf);
852 ssize_t (*store)(struct sta_info *, const char *buf, size_t count);
853 };
854
855 static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr)
856 {
857 return compare_ether_addr(raddr, addr) == 0 ||
858 is_broadcast_ether_addr(raddr);
859 }
860
861
862 /* ieee80211.c */
863 int ieee80211_hw_config(struct ieee80211_local *local);
864 int ieee80211_if_config(struct net_device *dev);
865 int ieee80211_if_config_beacon(struct net_device *dev);
866 void ieee80211_tx_set_protected(struct ieee80211_tx_data *tx);
867 void ieee80211_if_setup(struct net_device *dev);
868 u32 ieee80211_handle_ht(struct ieee80211_local *local, int enable_ht,
869 struct ieee80211_ht_info *req_ht_cap,
870 struct ieee80211_ht_bss_info *req_bss_cap);
871
872 /* ieee80211_ioctl.c */
873 extern const struct iw_handler_def ieee80211_iw_handler_def;
874
875
876 /* Least common multiple of the used rates (in 100 kbps). This is used to
877 * calculate rate_inv values for each rate so that only integers are needed. */
878 #define CHAN_UTIL_RATE_LCM 95040
879 /* 1 usec is 1/8 * (95040/10) = 1188 */
880 #define CHAN_UTIL_PER_USEC 1188
881 /* Amount of bits to shift the result right to scale the total utilization
882 * to values that will not wrap around 32-bit integers. */
883 #define CHAN_UTIL_SHIFT 9
884 /* Theoretical maximum of channel utilization counter in 10 ms (stat_time=1):
885 * (CHAN_UTIL_PER_USEC * 10000) >> CHAN_UTIL_SHIFT = 23203. So dividing the
886 * raw value with about 23 should give utilization in 10th of a percentage
887 * (1/1000). However, utilization is only estimated and not all intervals
888 * between frames etc. are calculated. 18 seems to give numbers that are closer
889 * to the real maximum. */
890 #define CHAN_UTIL_PER_10MS 18
891 #define CHAN_UTIL_HDR_LONG (202 * CHAN_UTIL_PER_USEC)
892 #define CHAN_UTIL_HDR_SHORT (40 * CHAN_UTIL_PER_USEC)
893
894
895 /* ieee80211_ioctl.c */
896 int ieee80211_set_freq(struct ieee80211_local *local, int freq);
897 /* ieee80211_sta.c */
898 void ieee80211_sta_timer(unsigned long data);
899 void ieee80211_sta_work(struct work_struct *work);
900 void ieee80211_sta_scan_work(struct work_struct *work);
901 void ieee80211_sta_rx_mgmt(struct net_device *dev, struct sk_buff *skb,
902 struct ieee80211_rx_status *rx_status);
903 int ieee80211_sta_set_ssid(struct net_device *dev, char *ssid, size_t len);
904 int ieee80211_sta_get_ssid(struct net_device *dev, char *ssid, size_t *len);
905 int ieee80211_sta_set_bssid(struct net_device *dev, u8 *bssid);
906 int ieee80211_sta_req_scan(struct net_device *dev, u8 *ssid, size_t ssid_len);
907 void ieee80211_sta_req_auth(struct net_device *dev,
908 struct ieee80211_if_sta *ifsta);
909 int ieee80211_sta_scan_results(struct net_device *dev, char *buf, size_t len);
910 ieee80211_rx_result ieee80211_sta_rx_scan(
911 struct net_device *dev, struct sk_buff *skb,
912 struct ieee80211_rx_status *rx_status);
913 void ieee80211_rx_bss_list_init(struct net_device *dev);
914 void ieee80211_rx_bss_list_deinit(struct net_device *dev);
915 int ieee80211_sta_set_extra_ie(struct net_device *dev, char *ie, size_t len);
916 struct sta_info * ieee80211_ibss_add_sta(struct net_device *dev,
917 struct sk_buff *skb, u8 *bssid,
918 u8 *addr);
919 int ieee80211_sta_deauthenticate(struct net_device *dev, u16 reason);
920 int ieee80211_sta_disassociate(struct net_device *dev, u16 reason);
921 void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
922 u32 changed);
923 void ieee80211_reset_erp_info(struct net_device *dev);
924 int ieee80211_ht_cap_ie_to_ht_info(struct ieee80211_ht_cap *ht_cap_ie,
925 struct ieee80211_ht_info *ht_info);
926 int ieee80211_ht_addt_info_ie_to_ht_bss_info(
927 struct ieee80211_ht_addt_info *ht_add_info_ie,
928 struct ieee80211_ht_bss_info *bss_info);
929 void ieee80211_send_addba_request(struct net_device *dev, const u8 *da,
930 u16 tid, u8 dialog_token, u16 start_seq_num,
931 u16 agg_size, u16 timeout);
932 void ieee80211_send_delba(struct net_device *dev, const u8 *da, u16 tid,
933 u16 initiator, u16 reason_code);
934
935 void ieee80211_sta_stop_rx_ba_session(struct net_device *dev, u8 *da,
936 u16 tid, u16 initiator, u16 reason);
937 void sta_rx_agg_session_timer_expired(unsigned long data);
938 void sta_addba_resp_timer_expired(unsigned long data);
939 void ieee80211_sta_tear_down_BA_sessions(struct net_device *dev, u8 *addr);
940 u64 ieee80211_sta_get_rates(struct ieee80211_local *local,
941 struct ieee802_11_elems *elems,
942 enum ieee80211_band band);
943 void ieee80211_sta_tx(struct net_device *dev, struct sk_buff *skb,
944 int encrypt);
945 void ieee802_11_parse_elems(u8 *start, size_t len,
946 struct ieee802_11_elems *elems);
947
948 #ifdef CONFIG_MAC80211_MESH
949 void ieee80211_start_mesh(struct net_device *dev);
950 #else
951 static inline void ieee80211_start_mesh(struct net_device *dev)
952 {}
953 #endif
954
955 /* ieee80211_iface.c */
956 int ieee80211_if_add(struct net_device *dev, const char *name,
957 struct net_device **new_dev, int type,
958 struct vif_params *params);
959 void ieee80211_if_set_type(struct net_device *dev, int type);
960 void ieee80211_if_reinit(struct net_device *dev);
961 void __ieee80211_if_del(struct ieee80211_local *local,
962 struct ieee80211_sub_if_data *sdata);
963 int ieee80211_if_remove(struct net_device *dev, const char *name, int id);
964 void ieee80211_if_free(struct net_device *dev);
965 void ieee80211_if_sdata_init(struct ieee80211_sub_if_data *sdata);
966
967 /* tx handling */
968 void ieee80211_clear_tx_pending(struct ieee80211_local *local);
969 void ieee80211_tx_pending(unsigned long data);
970 int ieee80211_master_start_xmit(struct sk_buff *skb, struct net_device *dev);
971 int ieee80211_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev);
972 int ieee80211_subif_start_xmit(struct sk_buff *skb, struct net_device *dev);
973
974 /* utility functions/constants */
975 extern void *mac80211_wiphy_privid; /* for wiphy privid */
976 extern const unsigned char rfc1042_header[6];
977 extern const unsigned char bridge_tunnel_header[6];
978 u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len,
979 enum ieee80211_if_types type);
980 int ieee80211_frame_duration(struct ieee80211_local *local, size_t len,
981 int rate, int erp, int short_preamble);
982 void mac80211_ev_michael_mic_failure(struct net_device *dev, int keyidx,
983 struct ieee80211_hdr *hdr);
984
985 #endif /* IEEE80211_I_H */