]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blame - net/mac80211/ieee80211_i.h
mac80211: split ieee80211_txrx_result
[mirror_ubuntu-hirsute-kernel.git] / net / mac80211 / ieee80211_i.h
CommitLineData
f0706e82
JB
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>
571ecf67 24#include <linux/etherdevice.h>
f0706e82
JB
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
38struct ieee80211_local;
39
f0706e82
JB
40#define IEEE80211_ALIGN32_PAD(a) ((4 - ((a) & 3)) & 3)
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
61struct 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
73struct ieee80211_sta_bss {
74 struct list_head list;
75 struct ieee80211_sta_bss *hnext;
76 atomic_t users;
77
78 u8 bssid[ETH_ALEN];
79 u8 ssid[IEEE80211_MAX_SSID_LEN];
80 size_t ssid_len;
81 u16 capability; /* host byte order */
8318d78a 82 enum ieee80211_band band;
f0706e82
JB
83 int freq;
84 int rssi, signal, noise;
85 u8 *wpa_ie;
86 size_t wpa_ie_len;
87 u8 *rsn_ie;
88 size_t rsn_ie_len;
89 u8 *wmm_ie;
90 size_t wmm_ie_len;
c7153508
RR
91 u8 *ht_ie;
92 size_t ht_ie_len;
f0706e82
JB
93#define IEEE80211_MAX_SUPP_RATES 32
94 u8 supp_rates[IEEE80211_MAX_SUPP_RATES];
95 size_t supp_rates_len;
96 int beacon_int;
97 u64 timestamp;
98
99 int probe_resp;
100 unsigned long last_update;
101
5628221c
DD
102 /* during assocation, we save an ERP value from a probe response so
103 * that we can feed ERP info to the driver when handling the
104 * association completes. these fields probably won't be up-to-date
105 * otherwise, you probably don't want to use them. */
106 int has_erp_value;
107 u8 erp_value;
f0706e82
JB
108};
109
110
9ae54c84
JB
111typedef unsigned __bitwise__ ieee80211_tx_result;
112#define TX_CONTINUE ((__force ieee80211_tx_result) 0u)
113#define TX_DROP ((__force ieee80211_tx_result) 1u)
114#define TX_QUEUED ((__force ieee80211_tx_result) 2u)
115
116typedef unsigned __bitwise__ ieee80211_rx_result;
117#define RX_CONTINUE ((__force ieee80211_rx_result) 0u)
118#define RX_DROP ((__force ieee80211_rx_result) 1u)
119#define RX_QUEUED ((__force ieee80211_rx_result) 2u)
120
f0706e82 121
badffb72
JS
122/* flags used in struct ieee80211_txrx_data.flags */
123/* whether the MSDU was fragmented */
124#define IEEE80211_TXRXD_FRAGMENTED BIT(0)
125#define IEEE80211_TXRXD_TXUNICAST BIT(1)
126#define IEEE80211_TXRXD_TXPS_BUFFERED BIT(2)
127#define IEEE80211_TXRXD_TXPROBE_LAST_FRAG BIT(3)
128#define IEEE80211_TXRXD_RXIN_SCAN BIT(4)
129/* frame is destined to interface currently processed (incl. multicast frames) */
130#define IEEE80211_TXRXD_RXRA_MATCH BIT(5)
58d4185e 131#define IEEE80211_TXRXD_TX_INJECTED BIT(6)
64bd4b69 132#define IEEE80211_TXRXD_RX_AMSDU BIT(7)
f0706e82
JB
133struct ieee80211_txrx_data {
134 struct sk_buff *skb;
135 struct net_device *dev;
136 struct ieee80211_local *local;
137 struct ieee80211_sub_if_data *sdata;
138 struct sta_info *sta;
139 u16 fc, ethertype;
140 struct ieee80211_key *key;
badffb72 141 unsigned int flags;
f0706e82
JB
142 union {
143 struct {
144 struct ieee80211_tx_control *control;
8318d78a 145 struct ieee80211_channel *channel;
f0706e82
JB
146 struct ieee80211_rate *rate;
147 /* use this rate (if set) for last fragment; rate can
148 * be set to lower rate for the first fragments, e.g.,
149 * when using CTS protection with IEEE 802.11g. */
150 struct ieee80211_rate *last_frag_rate;
f0706e82
JB
151
152 /* Extra fragments (in addition to the first fragment
153 * in skb) */
154 int num_extra_frag;
155 struct sk_buff **extra_frag;
156 } tx;
157 struct {
158 struct ieee80211_rx_status *status;
8318d78a 159 struct ieee80211_rate *rate;
f0706e82
JB
160 int sent_ps_buffered;
161 int queue;
162 int load;
50741ae0
JB
163 u32 tkip_iv32;
164 u16 tkip_iv16;
f0706e82
JB
165 } rx;
166 } u;
167};
168
e8bf9649
JS
169/* flags used in struct ieee80211_tx_packet_data.flags */
170#define IEEE80211_TXPD_REQ_TX_STATUS BIT(0)
171#define IEEE80211_TXPD_DO_NOT_ENCRYPT BIT(1)
172#define IEEE80211_TXPD_REQUEUE BIT(2)
678f5f71 173#define IEEE80211_TXPD_EAPOL_FRAME BIT(3)
9e723492 174#define IEEE80211_TXPD_AMPDU BIT(4)
f0706e82
JB
175/* Stored in sk_buff->cb */
176struct ieee80211_tx_packet_data {
177 int ifindex;
178 unsigned long jiffies;
e8bf9649
JS
179 unsigned int flags;
180 u8 queue;
f0706e82
JB
181};
182
183struct ieee80211_tx_stored_packet {
184 struct ieee80211_tx_control control;
185 struct sk_buff *skb;
186 int num_extra_frag;
187 struct sk_buff **extra_frag;
f0706e82 188 struct ieee80211_rate *last_frag_rate;
badffb72 189 unsigned int last_frag_rate_ctrl_probe;
f0706e82
JB
190};
191
9ae54c84 192typedef ieee80211_tx_result (*ieee80211_tx_handler)
f0706e82
JB
193(struct ieee80211_txrx_data *tx);
194
9ae54c84 195typedef ieee80211_rx_result (*ieee80211_rx_handler)
f0706e82
JB
196(struct ieee80211_txrx_data *rx);
197
5dfdaf58
JB
198struct beacon_data {
199 u8 *head, *tail;
200 int head_len, tail_len;
201 int dtim_period;
202};
203
f0706e82 204struct ieee80211_if_ap {
5dfdaf58 205 struct beacon_data *beacon;
f0706e82 206
0ec3ca44
JB
207 struct list_head vlans;
208
f0706e82
JB
209 u8 ssid[IEEE80211_MAX_SSID_LEN];
210 size_t ssid_len;
f0706e82
JB
211
212 /* yes, this looks ugly, but guarantees that we can later use
213 * bitmap_empty :)
214 * NB: don't ever use set_bit, use bss_tim_set/bss_tim_clear! */
215 u8 tim[sizeof(unsigned long) * BITS_TO_LONGS(IEEE80211_MAX_AID + 1)];
216 atomic_t num_sta_ps; /* number of stations in PS mode */
217 struct sk_buff_head ps_bc_buf;
5dfdaf58 218 int dtim_count;
f0706e82
JB
219 int force_unicast_rateidx; /* forced TX rateidx for unicast frames */
220 int max_ratectrl_rateidx; /* max TX rateidx for rate control */
221 int num_beacons; /* number of TXed beacon frames for this BSS */
222};
223
224struct ieee80211_if_wds {
225 u8 remote_addr[ETH_ALEN];
226 struct sta_info *sta;
227};
228
229struct ieee80211_if_vlan {
0ec3ca44
JB
230 struct ieee80211_sub_if_data *ap;
231 struct list_head list;
f0706e82
JB
232};
233
d6f2da5b
JS
234/* flags used in struct ieee80211_if_sta.flags */
235#define IEEE80211_STA_SSID_SET BIT(0)
236#define IEEE80211_STA_BSSID_SET BIT(1)
237#define IEEE80211_STA_PREV_BSSID_SET BIT(2)
238#define IEEE80211_STA_AUTHENTICATED BIT(3)
239#define IEEE80211_STA_ASSOCIATED BIT(4)
240#define IEEE80211_STA_PROBEREQ_POLL BIT(5)
241#define IEEE80211_STA_CREATE_IBSS BIT(6)
242#define IEEE80211_STA_MIXED_CELL BIT(7)
243#define IEEE80211_STA_WMM_ENABLED BIT(8)
244#define IEEE80211_STA_AUTO_SSID_SEL BIT(10)
245#define IEEE80211_STA_AUTO_BSSID_SEL BIT(11)
246#define IEEE80211_STA_AUTO_CHANNEL_SEL BIT(12)
5b98b1f7 247#define IEEE80211_STA_PRIVACY_INVOKED BIT(13)
f0706e82
JB
248struct ieee80211_if_sta {
249 enum {
250 IEEE80211_DISABLED, IEEE80211_AUTHENTICATE,
251 IEEE80211_ASSOCIATE, IEEE80211_ASSOCIATED,
252 IEEE80211_IBSS_SEARCH, IEEE80211_IBSS_JOINED
253 } state;
254 struct timer_list timer;
255 struct work_struct work;
256 u8 bssid[ETH_ALEN], prev_bssid[ETH_ALEN];
257 u8 ssid[IEEE80211_MAX_SSID_LEN];
258 size_t ssid_len;
a0af5f14
HS
259 u8 scan_ssid[IEEE80211_MAX_SSID_LEN];
260 size_t scan_ssid_len;
f0706e82
JB
261 u16 aid;
262 u16 ap_capab, capab;
263 u8 *extra_ie; /* to be added to the end of AssocReq */
264 size_t extra_ie_len;
265
266 /* The last AssocReq/Resp IEs */
267 u8 *assocreq_ies, *assocresp_ies;
268 size_t assocreq_ies_len, assocresp_ies_len;
269
270 int auth_tries, assoc_tries;
271
d6f2da5b 272 unsigned int flags;
f0706e82
JB
273#define IEEE80211_STA_REQ_SCAN 0
274#define IEEE80211_STA_REQ_AUTH 1
275#define IEEE80211_STA_REQ_RUN 2
276 unsigned long request;
277 struct sk_buff_head skb_queue;
278
f0706e82
JB
279 unsigned long last_probe;
280
281#define IEEE80211_AUTH_ALG_OPEN BIT(0)
282#define IEEE80211_AUTH_ALG_SHARED_KEY BIT(1)
283#define IEEE80211_AUTH_ALG_LEAP BIT(2)
284 unsigned int auth_algs; /* bitfield of allowed auth algs */
285 int auth_alg; /* currently used IEEE 802.11 authentication algorithm */
286 int auth_transaction;
287
288 unsigned long ibss_join_req;
289 struct sk_buff *probe_resp; /* ProbeResp template for IBSS */
8318d78a 290 u32 supp_rates_bits[IEEE80211_NUM_BANDS];
f0706e82
JB
291
292 int wmm_last_param_set;
293};
294
295
13262ffd
JS
296/* flags used in struct ieee80211_sub_if_data.flags */
297#define IEEE80211_SDATA_ALLMULTI BIT(0)
298#define IEEE80211_SDATA_PROMISC BIT(1)
471b3efd 299#define IEEE80211_SDATA_USERSPACE_MLME BIT(2)
8318d78a 300#define IEEE80211_SDATA_OPERATING_GMODE BIT(3)
f0706e82
JB
301struct ieee80211_sub_if_data {
302 struct list_head list;
f0706e82
JB
303
304 struct wireless_dev wdev;
305
11a843b7
JB
306 /* keys */
307 struct list_head key_list;
308
f0706e82
JB
309 struct net_device *dev;
310 struct ieee80211_local *local;
311
13262ffd 312 unsigned int flags;
7e9ed188 313
f0706e82 314 int drop_unencrypted;
f0706e82 315
8318d78a
JB
316 /*
317 * basic rates of this AP or the AP we're associated to
318 */
319 u64 basic_rates;
320
f0706e82
JB
321 u16 sequence;
322
323 /* Fragment table for host-based reassembly */
324 struct ieee80211_fragment_entry fragments[IEEE80211_FRAGMENT_MAX];
325 unsigned int fragment_next;
326
327#define NUM_DEFAULT_KEYS 4
328 struct ieee80211_key *keys[NUM_DEFAULT_KEYS];
329 struct ieee80211_key *default_key;
330
471b3efd
JB
331 /*
332 * BSS configuration for this interface.
333 *
334 * FIXME: I feel bad putting this here when we already have a
335 * bss pointer, but the bss pointer is just wrong when
336 * you have multiple virtual STA mode interfaces...
337 * This needs to be fixed.
338 */
339 struct ieee80211_bss_conf bss_conf;
f0706e82
JB
340 struct ieee80211_if_ap *bss; /* BSS that this device belongs to */
341
342 union {
343 struct ieee80211_if_ap ap;
344 struct ieee80211_if_wds wds;
345 struct ieee80211_if_vlan vlan;
346 struct ieee80211_if_sta sta;
347 } u;
348 int channel_use;
349 int channel_use_raw;
e9f207f0
JB
350
351#ifdef CONFIG_MAC80211_DEBUGFS
352 struct dentry *debugfsdir;
353 union {
354 struct {
355 struct dentry *channel_use;
356 struct dentry *drop_unencrypted;
e9f207f0
JB
357 struct dentry *state;
358 struct dentry *bssid;
359 struct dentry *prev_bssid;
360 struct dentry *ssid_len;
361 struct dentry *aid;
362 struct dentry *ap_capab;
363 struct dentry *capab;
364 struct dentry *extra_ie_len;
365 struct dentry *auth_tries;
366 struct dentry *assoc_tries;
367 struct dentry *auth_algs;
368 struct dentry *auth_alg;
369 struct dentry *auth_transaction;
370 struct dentry *flags;
371 } sta;
372 struct {
373 struct dentry *channel_use;
374 struct dentry *drop_unencrypted;
e9f207f0 375 struct dentry *num_sta_ps;
e9f207f0
JB
376 struct dentry *dtim_count;
377 struct dentry *num_beacons;
378 struct dentry *force_unicast_rateidx;
379 struct dentry *max_ratectrl_rateidx;
380 struct dentry *num_buffered_multicast;
e9f207f0
JB
381 } ap;
382 struct {
383 struct dentry *channel_use;
384 struct dentry *drop_unencrypted;
e9f207f0
JB
385 struct dentry *peer;
386 } wds;
387 struct {
388 struct dentry *channel_use;
389 struct dentry *drop_unencrypted;
e9f207f0
JB
390 } vlan;
391 struct {
392 struct dentry *mode;
393 } monitor;
394 struct dentry *default_key;
395 } debugfs;
396#endif
32bfd35d
JB
397 /* must be last, dynamically sized area in this! */
398 struct ieee80211_vif vif;
f0706e82
JB
399};
400
32bfd35d
JB
401static inline
402struct ieee80211_sub_if_data *vif_to_sdata(struct ieee80211_vif *p)
403{
404 return container_of(p, struct ieee80211_sub_if_data, vif);
405}
406
f0706e82
JB
407#define IEEE80211_DEV_TO_SUB_IF(dev) netdev_priv(dev)
408
409enum {
410 IEEE80211_RX_MSG = 1,
411 IEEE80211_TX_STATUS_MSG = 2,
eadc8d9e
RR
412 IEEE80211_DELBA_MSG = 3,
413 IEEE80211_ADDBA_MSG = 4,
f0706e82
JB
414};
415
416struct ieee80211_local {
417 /* embed the driver visible part.
418 * don't cast (use the static inlines below), but we keep
419 * it first anyway so they become a no-op */
420 struct ieee80211_hw hw;
421
422 const struct ieee80211_ops *ops;
423
f0706e82 424 struct net_device *mdev; /* wmaster# - "master" 802.11 device */
f0706e82
JB
425 int open_count;
426 int monitors;
4150c572 427 unsigned int filter_flags; /* FIF_* */
f0706e82
JB
428 struct iw_statistics wstats;
429 u8 wstats_flags;
b306f453 430 int tx_headroom; /* required headroom for hardware/radiotap */
f0706e82
JB
431
432 enum {
433 IEEE80211_DEV_UNINITIALIZED = 0,
434 IEEE80211_DEV_REGISTERED,
435 IEEE80211_DEV_UNREGISTERED,
436 } reg_state;
437
438 /* Tasklet and skb queue to process calls from IRQ mode. All frames
439 * added to skb_queue will be processed, but frames in
440 * skb_queue_unreliable may be dropped if the total length of these
441 * queues increases over the limit. */
442#define IEEE80211_IRQSAFE_QUEUE_LIMIT 128
443 struct tasklet_struct tasklet;
444 struct sk_buff_head skb_queue;
445 struct sk_buff_head skb_queue_unreliable;
446
447 /* Station data structures */
be8755e1 448 rwlock_t sta_lock; /* protects STA data structures */
f0706e82
JB
449 int num_sta; /* number of stations in sta_list */
450 struct list_head sta_list;
f0706e82
JB
451 struct sta_info *sta_hash[STA_HASH_SIZE];
452 struct timer_list sta_cleanup;
453
9e723492
RR
454 unsigned long state[NUM_TX_DATA_QUEUES_AMPDU];
455 struct ieee80211_tx_stored_packet pending_packet[NUM_TX_DATA_QUEUES_AMPDU];
f0706e82
JB
456 struct tasklet_struct tx_pending_tasklet;
457
53918994
JB
458 /* number of interfaces with corresponding IFF_ flags */
459 atomic_t iff_allmultis, iff_promiscs;
f0706e82
JB
460
461 struct rate_control_ref *rate_ctrl;
462
f0706e82 463 int rts_threshold;
f0706e82
JB
464 int fragmentation_threshold;
465 int short_retry_limit; /* dot11ShortRetryLimit */
466 int long_retry_limit; /* dot11LongRetryLimit */
f0706e82
JB
467
468 struct crypto_blkcipher *wep_tx_tfm;
469 struct crypto_blkcipher *wep_rx_tfm;
470 u32 wep_iv;
f0706e82
JB
471
472 int bridge_packets; /* bridge packets between associated stations and
473 * deliver multicast frames both back to wireless
474 * media and to the local net stack */
475
f0706e82
JB
476 ieee80211_rx_handler *rx_handlers;
477 ieee80211_tx_handler *tx_handlers;
478
79010420
JB
479 struct list_head interfaces;
480
ece8eddd
ZY
481 bool sta_sw_scanning;
482 bool sta_hw_scanning;
f0706e82 483 int scan_channel_idx;
8318d78a
JB
484 enum ieee80211_band scan_band;
485
f0706e82
JB
486 enum { SCAN_SET_CHANNEL, SCAN_SEND_PROBE } scan_state;
487 unsigned long last_scan_completed;
488 struct delayed_work scan_work;
489 struct net_device *scan_dev;
490 struct ieee80211_channel *oper_channel, *scan_channel;
f0706e82
JB
491 u8 scan_ssid[IEEE80211_MAX_SSID_LEN];
492 size_t scan_ssid_len;
493 struct list_head sta_bss_list;
494 struct ieee80211_sta_bss *sta_bss_hash[STA_HASH_SIZE];
495 spinlock_t sta_bss_lock;
f0706e82
JB
496
497 /* SNMP counters */
498 /* dot11CountersTable */
499 u32 dot11TransmittedFragmentCount;
500 u32 dot11MulticastTransmittedFrameCount;
501 u32 dot11FailedCount;
502 u32 dot11RetryCount;
503 u32 dot11MultipleRetryCount;
504 u32 dot11FrameDuplicateCount;
505 u32 dot11ReceivedFragmentCount;
506 u32 dot11MulticastReceivedFrameCount;
507 u32 dot11TransmittedFrameCount;
508 u32 dot11WEPUndecryptableCount;
509
510#ifdef CONFIG_MAC80211_LEDS
511 int tx_led_counter, rx_led_counter;
cdcb006f
ID
512 struct led_trigger *tx_led, *rx_led, *assoc_led, *radio_led;
513 char tx_led_name[32], rx_led_name[32],
514 assoc_led_name[32], radio_led_name[32];
f0706e82
JB
515#endif
516
517 u32 channel_use;
518 u32 channel_use_raw;
f0706e82 519
e9f207f0
JB
520#ifdef CONFIG_MAC80211_DEBUGFS
521 struct work_struct sta_debugfs_add;
522#endif
523
f0706e82
JB
524#ifdef CONFIG_MAC80211_DEBUG_COUNTERS
525 /* TX/RX handler statistics */
526 unsigned int tx_handlers_drop;
527 unsigned int tx_handlers_queued;
528 unsigned int tx_handlers_drop_unencrypted;
529 unsigned int tx_handlers_drop_fragment;
530 unsigned int tx_handlers_drop_wep;
531 unsigned int tx_handlers_drop_not_assoc;
532 unsigned int tx_handlers_drop_unauth_port;
533 unsigned int rx_handlers_drop;
534 unsigned int rx_handlers_queued;
535 unsigned int rx_handlers_drop_nullfunc;
536 unsigned int rx_handlers_drop_defrag;
537 unsigned int rx_handlers_drop_short;
538 unsigned int rx_handlers_drop_passive_scan;
539 unsigned int tx_expand_skb_head;
540 unsigned int tx_expand_skb_head_cloned;
541 unsigned int rx_expand_skb_head;
542 unsigned int rx_expand_skb_head2;
543 unsigned int rx_handlers_fragments;
544 unsigned int tx_status_drop;
545 unsigned int wme_rx_queue[NUM_RX_DATA_QUEUES];
546 unsigned int wme_tx_queue[NUM_RX_DATA_QUEUES];
547#define I802_DEBUG_INC(c) (c)++
548#else /* CONFIG_MAC80211_DEBUG_COUNTERS */
549#define I802_DEBUG_INC(c) do { } while (0)
550#endif /* CONFIG_MAC80211_DEBUG_COUNTERS */
551
552
f0706e82
JB
553 int total_ps_buffered; /* total number of all buffered unicast and
554 * multicast packets for power saving stations
555 */
f0706e82
JB
556 int wifi_wme_noack_test;
557 unsigned int wmm_acm; /* bit field of ACM bits (BIT(802.1D tag)) */
558
e9f207f0
JB
559#ifdef CONFIG_MAC80211_DEBUGFS
560 struct local_debugfsdentries {
e9f207f0 561 struct dentry *frequency;
e9f207f0
JB
562 struct dentry *antenna_sel_tx;
563 struct dentry *antenna_sel_rx;
564 struct dentry *bridge_packets;
e9f207f0
JB
565 struct dentry *rts_threshold;
566 struct dentry *fragmentation_threshold;
567 struct dentry *short_retry_limit;
568 struct dentry *long_retry_limit;
569 struct dentry *total_ps_buffered;
e9f207f0 570 struct dentry *wep_iv;
e9f207f0
JB
571 struct dentry *statistics;
572 struct local_debugfsdentries_statsdentries {
573 struct dentry *transmitted_fragment_count;
574 struct dentry *multicast_transmitted_frame_count;
575 struct dentry *failed_count;
576 struct dentry *retry_count;
577 struct dentry *multiple_retry_count;
578 struct dentry *frame_duplicate_count;
579 struct dentry *received_fragment_count;
580 struct dentry *multicast_received_frame_count;
581 struct dentry *transmitted_frame_count;
582 struct dentry *wep_undecryptable_count;
583 struct dentry *num_scans;
584#ifdef CONFIG_MAC80211_DEBUG_COUNTERS
585 struct dentry *tx_handlers_drop;
586 struct dentry *tx_handlers_queued;
587 struct dentry *tx_handlers_drop_unencrypted;
588 struct dentry *tx_handlers_drop_fragment;
589 struct dentry *tx_handlers_drop_wep;
590 struct dentry *tx_handlers_drop_not_assoc;
591 struct dentry *tx_handlers_drop_unauth_port;
592 struct dentry *rx_handlers_drop;
593 struct dentry *rx_handlers_queued;
594 struct dentry *rx_handlers_drop_nullfunc;
595 struct dentry *rx_handlers_drop_defrag;
596 struct dentry *rx_handlers_drop_short;
597 struct dentry *rx_handlers_drop_passive_scan;
598 struct dentry *tx_expand_skb_head;
599 struct dentry *tx_expand_skb_head_cloned;
600 struct dentry *rx_expand_skb_head;
601 struct dentry *rx_expand_skb_head2;
602 struct dentry *rx_handlers_fragments;
603 struct dentry *tx_status_drop;
604 struct dentry *wme_tx_queue;
605 struct dentry *wme_rx_queue;
606#endif
607 struct dentry *dot11ACKFailureCount;
608 struct dentry *dot11RTSFailureCount;
609 struct dentry *dot11FCSErrorCount;
610 struct dentry *dot11RTSSuccessCount;
611 } stats;
612 struct dentry *stations;
613 struct dentry *keys;
614 } debugfs;
615#endif
f0706e82
JB
616};
617
eadc8d9e
RR
618/* this struct represents 802.11n's RA/TID combination */
619struct ieee80211_ra_tid {
620 u8 ra[ETH_ALEN];
621 u16 tid;
622};
623
f0706e82
JB
624static inline struct ieee80211_local *hw_to_local(
625 struct ieee80211_hw *hw)
626{
627 return container_of(hw, struct ieee80211_local, hw);
628}
629
630static inline struct ieee80211_hw *local_to_hw(
631 struct ieee80211_local *local)
632{
633 return &local->hw;
634}
635
636enum ieee80211_link_state_t {
637 IEEE80211_LINK_STATE_XOFF = 0,
638 IEEE80211_LINK_STATE_PENDING,
639};
640
641struct sta_attribute {
642 struct attribute attr;
643 ssize_t (*show)(const struct sta_info *, char *buf);
644 ssize_t (*store)(struct sta_info *, const char *buf, size_t count);
645};
646
30ccb088 647static inline void __bss_tim_set(struct ieee80211_if_ap *bss, u16 aid)
f0706e82
JB
648{
649 /*
30ccb088 650 * This format has been mandated by the IEEE specifications,
f0706e82
JB
651 * so this line may not be changed to use the __set_bit() format.
652 */
30ccb088 653 bss->tim[aid / 8] |= (1 << (aid % 8));
f0706e82
JB
654}
655
656static inline void bss_tim_set(struct ieee80211_local *local,
30ccb088 657 struct ieee80211_if_ap *bss, u16 aid)
f0706e82 658{
be8755e1 659 read_lock_bh(&local->sta_lock);
f0706e82 660 __bss_tim_set(bss, aid);
be8755e1 661 read_unlock_bh(&local->sta_lock);
f0706e82
JB
662}
663
30ccb088 664static inline void __bss_tim_clear(struct ieee80211_if_ap *bss, u16 aid)
f0706e82
JB
665{
666 /*
30ccb088 667 * This format has been mandated by the IEEE specifications,
f0706e82
JB
668 * so this line may not be changed to use the __clear_bit() format.
669 */
30ccb088 670 bss->tim[aid / 8] &= ~(1 << (aid % 8));
f0706e82
JB
671}
672
673static inline void bss_tim_clear(struct ieee80211_local *local,
30ccb088 674 struct ieee80211_if_ap *bss, u16 aid)
f0706e82 675{
be8755e1 676 read_lock_bh(&local->sta_lock);
f0706e82 677 __bss_tim_clear(bss, aid);
be8755e1 678 read_unlock_bh(&local->sta_lock);
f0706e82
JB
679}
680
571ecf67
JB
681static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr)
682{
683 return compare_ether_addr(raddr, addr) == 0 ||
684 is_broadcast_ether_addr(raddr);
685}
686
687
f0706e82
JB
688/* ieee80211.c */
689int ieee80211_hw_config(struct ieee80211_local *local);
690int ieee80211_if_config(struct net_device *dev);
691int ieee80211_if_config_beacon(struct net_device *dev);
f0706e82
JB
692void ieee80211_tx_set_iswep(struct ieee80211_txrx_data *tx);
693int ieee80211_if_update_wds(struct net_device *dev, u8 *remote_addr);
694void ieee80211_if_setup(struct net_device *dev);
d3c990fb
RR
695int ieee80211_hw_config_ht(struct ieee80211_local *local, int enable_ht,
696 struct ieee80211_ht_info *req_ht_cap,
697 struct ieee80211_ht_bss_info *req_bss_cap);
f0706e82
JB
698
699/* ieee80211_ioctl.c */
700extern const struct iw_handler_def ieee80211_iw_handler_def;
701
f0706e82
JB
702
703/* Least common multiple of the used rates (in 100 kbps). This is used to
704 * calculate rate_inv values for each rate so that only integers are needed. */
705#define CHAN_UTIL_RATE_LCM 95040
706/* 1 usec is 1/8 * (95040/10) = 1188 */
707#define CHAN_UTIL_PER_USEC 1188
708/* Amount of bits to shift the result right to scale the total utilization
709 * to values that will not wrap around 32-bit integers. */
710#define CHAN_UTIL_SHIFT 9
711/* Theoretical maximum of channel utilization counter in 10 ms (stat_time=1):
712 * (CHAN_UTIL_PER_USEC * 10000) >> CHAN_UTIL_SHIFT = 23203. So dividing the
713 * raw value with about 23 should give utilization in 10th of a percentage
714 * (1/1000). However, utilization is only estimated and not all intervals
715 * between frames etc. are calculated. 18 seems to give numbers that are closer
716 * to the real maximum. */
717#define CHAN_UTIL_PER_10MS 18
718#define CHAN_UTIL_HDR_LONG (202 * CHAN_UTIL_PER_USEC)
719#define CHAN_UTIL_HDR_SHORT (40 * CHAN_UTIL_PER_USEC)
720
721
722/* ieee80211_ioctl.c */
723int ieee80211_set_compression(struct ieee80211_local *local,
724 struct net_device *dev, struct sta_info *sta);
8318d78a 725int ieee80211_set_freq(struct ieee80211_local *local, int freq);
f0706e82
JB
726/* ieee80211_sta.c */
727void ieee80211_sta_timer(unsigned long data);
728void ieee80211_sta_work(struct work_struct *work);
729void ieee80211_sta_scan_work(struct work_struct *work);
730void ieee80211_sta_rx_mgmt(struct net_device *dev, struct sk_buff *skb,
731 struct ieee80211_rx_status *rx_status);
732int ieee80211_sta_set_ssid(struct net_device *dev, char *ssid, size_t len);
733int ieee80211_sta_get_ssid(struct net_device *dev, char *ssid, size_t *len);
734int ieee80211_sta_set_bssid(struct net_device *dev, u8 *bssid);
735int ieee80211_sta_req_scan(struct net_device *dev, u8 *ssid, size_t ssid_len);
736void ieee80211_sta_req_auth(struct net_device *dev,
737 struct ieee80211_if_sta *ifsta);
738int ieee80211_sta_scan_results(struct net_device *dev, char *buf, size_t len);
9ae54c84
JB
739ieee80211_rx_result ieee80211_sta_rx_scan(
740 struct net_device *dev, struct sk_buff *skb,
741 struct ieee80211_rx_status *rx_status);
f0706e82
JB
742void ieee80211_rx_bss_list_init(struct net_device *dev);
743void ieee80211_rx_bss_list_deinit(struct net_device *dev);
744int ieee80211_sta_set_extra_ie(struct net_device *dev, char *ie, size_t len);
745struct sta_info * ieee80211_ibss_add_sta(struct net_device *dev,
746 struct sk_buff *skb, u8 *bssid,
747 u8 *addr);
748int ieee80211_sta_deauthenticate(struct net_device *dev, u16 reason);
749int ieee80211_sta_disassociate(struct net_device *dev, u16 reason);
471b3efd
JB
750void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
751 u32 changed);
d9430a32 752void ieee80211_reset_erp_info(struct net_device *dev);
c7153508
RR
753int ieee80211_ht_cap_ie_to_ht_info(struct ieee80211_ht_cap *ht_cap_ie,
754 struct ieee80211_ht_info *ht_info);
755int ieee80211_ht_addt_info_ie_to_ht_bss_info(
756 struct ieee80211_ht_addt_info *ht_add_info_ie,
757 struct ieee80211_ht_bss_info *bss_info);
eadc8d9e
RR
758void ieee80211_send_addba_request(struct net_device *dev, const u8 *da,
759 u16 tid, u8 dialog_token, u16 start_seq_num,
760 u16 agg_size, u16 timeout);
761void ieee80211_send_delba(struct net_device *dev, const u8 *da, u16 tid,
762 u16 initiator, u16 reason_code);
07db2183
RR
763void ieee80211_sta_stop_rx_ba_session(struct net_device *dev, u8 *da,
764 u16 tid, u16 initiator, u16 reason);
765void sta_rx_agg_session_timer_expired(unsigned long data);
eadc8d9e 766void sta_addba_resp_timer_expired(unsigned long data);
f0706e82
JB
767/* ieee80211_iface.c */
768int ieee80211_if_add(struct net_device *dev, const char *name,
769 struct net_device **new_dev, int type);
770void ieee80211_if_set_type(struct net_device *dev, int type);
771void ieee80211_if_reinit(struct net_device *dev);
772void __ieee80211_if_del(struct ieee80211_local *local,
773 struct ieee80211_sub_if_data *sdata);
774int ieee80211_if_remove(struct net_device *dev, const char *name, int id);
775void ieee80211_if_free(struct net_device *dev);
776void ieee80211_if_sdata_init(struct ieee80211_sub_if_data *sdata);
f0706e82 777
571ecf67 778/* rx handling */
571ecf67
JB
779extern ieee80211_rx_handler ieee80211_rx_handlers[];
780
e2ebc74d
JB
781/* tx handling */
782extern ieee80211_tx_handler ieee80211_tx_handlers[];
783void ieee80211_clear_tx_pending(struct ieee80211_local *local);
784void ieee80211_tx_pending(unsigned long data);
785int ieee80211_master_start_xmit(struct sk_buff *skb, struct net_device *dev);
786int ieee80211_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev);
787int ieee80211_subif_start_xmit(struct sk_buff *skb, struct net_device *dev);
e2ebc74d 788
c2d1560a
JB
789/* utility functions/constants */
790extern void *mac80211_wiphy_privid; /* for wiphy privid */
791extern const unsigned char rfc1042_header[6];
792extern const unsigned char bridge_tunnel_header[6];
71364716
RR
793u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len,
794 enum ieee80211_if_types type);
c2d1560a
JB
795int ieee80211_frame_duration(struct ieee80211_local *local, size_t len,
796 int rate, int erp, int short_preamble);
eb063c17
JB
797void mac80211_ev_michael_mic_failure(struct net_device *dev, int keyidx,
798 struct ieee80211_hdr *hdr);
f0706e82
JB
799
800#endif /* IEEE80211_I_H */