ieee80211_i.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829
  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. #ifndef IEEE80211_I_H
  11. #define IEEE80211_I_H
  12. #include <linux/kernel.h>
  13. #include <linux/device.h>
  14. #include <linux/if_ether.h>
  15. #include <linux/interrupt.h>
  16. #include <linux/list.h>
  17. #include <linux/netdevice.h>
  18. #include <linux/skbuff.h>
  19. #include <linux/workqueue.h>
  20. #include <linux/types.h>
  21. #include <linux/spinlock.h>
  22. #include <linux/etherdevice.h>
  23. #include <net/wireless.h>
  24. #include "ieee80211_key.h"
  25. #include "sta_info.h"
  26. /* ieee80211.o internal definitions, etc. These are not included into
  27. * low-level drivers. */
  28. #ifndef ETH_P_PAE
  29. #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
  30. #endif /* ETH_P_PAE */
  31. #define WLAN_FC_DATA_PRESENT(fc) (((fc) & 0x4c) == 0x08)
  32. struct ieee80211_local;
  33. #define BIT(x) (1 << (x))
  34. #define IEEE80211_ALIGN32_PAD(a) ((4 - ((a) & 3)) & 3)
  35. /* Maximum number of broadcast/multicast frames to buffer when some of the
  36. * associated stations are using power saving. */
  37. #define AP_MAX_BC_BUFFER 128
  38. /* Maximum number of frames buffered to all STAs, including multicast frames.
  39. * Note: increasing this limit increases the potential memory requirement. Each
  40. * frame can be up to about 2 kB long. */
  41. #define TOTAL_MAX_TX_BUFFER 512
  42. /* Required encryption head and tailroom */
  43. #define IEEE80211_ENCRYPT_HEADROOM 8
  44. #define IEEE80211_ENCRYPT_TAILROOM 12
  45. /* IEEE 802.11 (Ch. 9.5 Defragmentation) requires support for concurrent
  46. * reception of at least three fragmented frames. This limit can be increased
  47. * by changing this define, at the cost of slower frame reassembly and
  48. * increased memory use (about 2 kB of RAM per entry). */
  49. #define IEEE80211_FRAGMENT_MAX 4
  50. struct ieee80211_fragment_entry {
  51. unsigned long first_frag_time;
  52. unsigned int seq;
  53. unsigned int rx_queue;
  54. unsigned int last_frag;
  55. unsigned int extra_len;
  56. struct sk_buff_head skb_list;
  57. int ccmp; /* Whether fragments were encrypted with CCMP */
  58. u8 last_pn[6]; /* PN of the last fragment if CCMP was used */
  59. };
  60. struct ieee80211_sta_bss {
  61. struct list_head list;
  62. struct ieee80211_sta_bss *hnext;
  63. atomic_t users;
  64. u8 bssid[ETH_ALEN];
  65. u8 ssid[IEEE80211_MAX_SSID_LEN];
  66. size_t ssid_len;
  67. u16 capability; /* host byte order */
  68. int hw_mode;
  69. int channel;
  70. int freq;
  71. int rssi, signal, noise;
  72. u8 *wpa_ie;
  73. size_t wpa_ie_len;
  74. u8 *rsn_ie;
  75. size_t rsn_ie_len;
  76. u8 *wmm_ie;
  77. size_t wmm_ie_len;
  78. #define IEEE80211_MAX_SUPP_RATES 32
  79. u8 supp_rates[IEEE80211_MAX_SUPP_RATES];
  80. size_t supp_rates_len;
  81. int beacon_int;
  82. u64 timestamp;
  83. int probe_resp;
  84. unsigned long last_update;
  85. /* during assocation, we save an ERP value from a probe response so
  86. * that we can feed ERP info to the driver when handling the
  87. * association completes. these fields probably won't be up-to-date
  88. * otherwise, you probably don't want to use them. */
  89. int has_erp_value;
  90. u8 erp_value;
  91. };
  92. typedef enum {
  93. TXRX_CONTINUE, TXRX_DROP, TXRX_QUEUED
  94. } ieee80211_txrx_result;
  95. struct ieee80211_txrx_data {
  96. struct sk_buff *skb;
  97. struct net_device *dev;
  98. struct ieee80211_local *local;
  99. struct ieee80211_sub_if_data *sdata;
  100. struct sta_info *sta;
  101. u16 fc, ethertype;
  102. struct ieee80211_key *key;
  103. unsigned int fragmented:1; /* whether the MSDU was fragmented */
  104. union {
  105. struct {
  106. struct ieee80211_tx_control *control;
  107. unsigned int unicast:1;
  108. unsigned int ps_buffered:1;
  109. unsigned int short_preamble:1;
  110. unsigned int probe_last_frag:1;
  111. struct ieee80211_hw_mode *mode;
  112. struct ieee80211_rate *rate;
  113. /* use this rate (if set) for last fragment; rate can
  114. * be set to lower rate for the first fragments, e.g.,
  115. * when using CTS protection with IEEE 802.11g. */
  116. struct ieee80211_rate *last_frag_rate;
  117. int last_frag_hwrate;
  118. int mgmt_interface;
  119. /* Extra fragments (in addition to the first fragment
  120. * in skb) */
  121. int num_extra_frag;
  122. struct sk_buff **extra_frag;
  123. } tx;
  124. struct {
  125. struct ieee80211_rx_status *status;
  126. int sent_ps_buffered;
  127. int queue;
  128. int load;
  129. unsigned int in_scan:1;
  130. /* frame is destined to interface currently processed
  131. * (including multicast frames) */
  132. unsigned int ra_match:1;
  133. } rx;
  134. } u;
  135. };
  136. /* Stored in sk_buff->cb */
  137. struct ieee80211_tx_packet_data {
  138. int ifindex;
  139. unsigned long jiffies;
  140. unsigned int req_tx_status:1;
  141. unsigned int do_not_encrypt:1;
  142. unsigned int requeue:1;
  143. unsigned int mgmt_iface:1;
  144. unsigned int queue:4;
  145. };
  146. struct ieee80211_tx_stored_packet {
  147. struct ieee80211_tx_control control;
  148. struct sk_buff *skb;
  149. int num_extra_frag;
  150. struct sk_buff **extra_frag;
  151. int last_frag_rateidx;
  152. int last_frag_hwrate;
  153. struct ieee80211_rate *last_frag_rate;
  154. unsigned int last_frag_rate_ctrl_probe:1;
  155. };
  156. typedef ieee80211_txrx_result (*ieee80211_tx_handler)
  157. (struct ieee80211_txrx_data *tx);
  158. typedef ieee80211_txrx_result (*ieee80211_rx_handler)
  159. (struct ieee80211_txrx_data *rx);
  160. struct ieee80211_if_ap {
  161. u8 *beacon_head, *beacon_tail;
  162. int beacon_head_len, beacon_tail_len;
  163. u8 ssid[IEEE80211_MAX_SSID_LEN];
  164. size_t ssid_len;
  165. u8 *generic_elem;
  166. size_t generic_elem_len;
  167. /* yes, this looks ugly, but guarantees that we can later use
  168. * bitmap_empty :)
  169. * NB: don't ever use set_bit, use bss_tim_set/bss_tim_clear! */
  170. u8 tim[sizeof(unsigned long) * BITS_TO_LONGS(IEEE80211_MAX_AID + 1)];
  171. atomic_t num_sta_ps; /* number of stations in PS mode */
  172. struct sk_buff_head ps_bc_buf;
  173. int dtim_period, dtim_count;
  174. int force_unicast_rateidx; /* forced TX rateidx for unicast frames */
  175. int max_ratectrl_rateidx; /* max TX rateidx for rate control */
  176. int num_beacons; /* number of TXed beacon frames for this BSS */
  177. };
  178. struct ieee80211_if_wds {
  179. u8 remote_addr[ETH_ALEN];
  180. struct sta_info *sta;
  181. };
  182. struct ieee80211_if_vlan {
  183. u8 id;
  184. };
  185. struct ieee80211_if_sta {
  186. enum {
  187. IEEE80211_DISABLED, IEEE80211_AUTHENTICATE,
  188. IEEE80211_ASSOCIATE, IEEE80211_ASSOCIATED,
  189. IEEE80211_IBSS_SEARCH, IEEE80211_IBSS_JOINED
  190. } state;
  191. struct timer_list timer;
  192. struct work_struct work;
  193. u8 bssid[ETH_ALEN], prev_bssid[ETH_ALEN];
  194. u8 ssid[IEEE80211_MAX_SSID_LEN];
  195. size_t ssid_len;
  196. u16 aid;
  197. u16 ap_capab, capab;
  198. u8 *extra_ie; /* to be added to the end of AssocReq */
  199. size_t extra_ie_len;
  200. /* The last AssocReq/Resp IEs */
  201. u8 *assocreq_ies, *assocresp_ies;
  202. size_t assocreq_ies_len, assocresp_ies_len;
  203. int auth_tries, assoc_tries;
  204. unsigned int ssid_set:1;
  205. unsigned int bssid_set:1;
  206. unsigned int prev_bssid_set:1;
  207. unsigned int authenticated:1;
  208. unsigned int associated:1;
  209. unsigned int probereq_poll:1;
  210. unsigned int create_ibss:1;
  211. unsigned int mixed_cell:1;
  212. unsigned int wmm_enabled:1;
  213. unsigned int auto_ssid_sel:1;
  214. unsigned int auto_bssid_sel:1;
  215. unsigned int auto_channel_sel:1;
  216. #define IEEE80211_STA_REQ_SCAN 0
  217. #define IEEE80211_STA_REQ_AUTH 1
  218. #define IEEE80211_STA_REQ_RUN 2
  219. unsigned long request;
  220. struct sk_buff_head skb_queue;
  221. int key_mgmt;
  222. unsigned long last_probe;
  223. #define IEEE80211_AUTH_ALG_OPEN BIT(0)
  224. #define IEEE80211_AUTH_ALG_SHARED_KEY BIT(1)
  225. #define IEEE80211_AUTH_ALG_LEAP BIT(2)
  226. unsigned int auth_algs; /* bitfield of allowed auth algs */
  227. int auth_alg; /* currently used IEEE 802.11 authentication algorithm */
  228. int auth_transaction;
  229. unsigned long ibss_join_req;
  230. struct sk_buff *probe_resp; /* ProbeResp template for IBSS */
  231. u32 supp_rates_bits;
  232. int wmm_last_param_set;
  233. };
  234. struct ieee80211_sub_if_data {
  235. struct list_head list;
  236. unsigned int type;
  237. struct wireless_dev wdev;
  238. struct net_device *dev;
  239. struct ieee80211_local *local;
  240. int mc_count;
  241. unsigned int allmulti:1;
  242. unsigned int promisc:1;
  243. unsigned int use_protection:1; /* CTS protect ERP frames */
  244. struct net_device_stats stats;
  245. int drop_unencrypted;
  246. int eapol; /* 0 = process EAPOL frames as normal data frames,
  247. * 1 = send EAPOL frames through wlan#ap to hostapd
  248. * (default) */
  249. int ieee802_1x; /* IEEE 802.1X PAE - drop packet to/from unauthorized
  250. * port */
  251. u16 sequence;
  252. /* Fragment table for host-based reassembly */
  253. struct ieee80211_fragment_entry fragments[IEEE80211_FRAGMENT_MAX];
  254. unsigned int fragment_next;
  255. #define NUM_DEFAULT_KEYS 4
  256. struct ieee80211_key *keys[NUM_DEFAULT_KEYS];
  257. struct ieee80211_key *default_key;
  258. struct ieee80211_if_ap *bss; /* BSS that this device belongs to */
  259. union {
  260. struct ieee80211_if_ap ap;
  261. struct ieee80211_if_wds wds;
  262. struct ieee80211_if_vlan vlan;
  263. struct ieee80211_if_sta sta;
  264. } u;
  265. int channel_use;
  266. int channel_use_raw;
  267. #ifdef CONFIG_MAC80211_DEBUGFS
  268. struct dentry *debugfsdir;
  269. union {
  270. struct {
  271. struct dentry *channel_use;
  272. struct dentry *drop_unencrypted;
  273. struct dentry *eapol;
  274. struct dentry *ieee8021_x;
  275. struct dentry *state;
  276. struct dentry *bssid;
  277. struct dentry *prev_bssid;
  278. struct dentry *ssid_len;
  279. struct dentry *aid;
  280. struct dentry *ap_capab;
  281. struct dentry *capab;
  282. struct dentry *extra_ie_len;
  283. struct dentry *auth_tries;
  284. struct dentry *assoc_tries;
  285. struct dentry *auth_algs;
  286. struct dentry *auth_alg;
  287. struct dentry *auth_transaction;
  288. struct dentry *flags;
  289. } sta;
  290. struct {
  291. struct dentry *channel_use;
  292. struct dentry *drop_unencrypted;
  293. struct dentry *eapol;
  294. struct dentry *ieee8021_x;
  295. struct dentry *num_sta_ps;
  296. struct dentry *dtim_period;
  297. struct dentry *dtim_count;
  298. struct dentry *num_beacons;
  299. struct dentry *force_unicast_rateidx;
  300. struct dentry *max_ratectrl_rateidx;
  301. struct dentry *num_buffered_multicast;
  302. struct dentry *beacon_head_len;
  303. struct dentry *beacon_tail_len;
  304. } ap;
  305. struct {
  306. struct dentry *channel_use;
  307. struct dentry *drop_unencrypted;
  308. struct dentry *eapol;
  309. struct dentry *ieee8021_x;
  310. struct dentry *peer;
  311. } wds;
  312. struct {
  313. struct dentry *channel_use;
  314. struct dentry *drop_unencrypted;
  315. struct dentry *eapol;
  316. struct dentry *ieee8021_x;
  317. struct dentry *vlan_id;
  318. } vlan;
  319. struct {
  320. struct dentry *mode;
  321. } monitor;
  322. struct dentry *default_key;
  323. } debugfs;
  324. #endif
  325. };
  326. #define IEEE80211_DEV_TO_SUB_IF(dev) netdev_priv(dev)
  327. enum {
  328. IEEE80211_RX_MSG = 1,
  329. IEEE80211_TX_STATUS_MSG = 2,
  330. };
  331. struct ieee80211_local {
  332. /* embed the driver visible part.
  333. * don't cast (use the static inlines below), but we keep
  334. * it first anyway so they become a no-op */
  335. struct ieee80211_hw hw;
  336. const struct ieee80211_ops *ops;
  337. /* List of registered struct ieee80211_hw_mode */
  338. struct list_head modes_list;
  339. struct net_device *mdev; /* wmaster# - "master" 802.11 device */
  340. struct net_device *apdev; /* wlan#ap - management frames (hostapd) */
  341. int open_count;
  342. int monitors;
  343. struct iw_statistics wstats;
  344. u8 wstats_flags;
  345. int tx_headroom; /* required headroom for hardware/radiotap */
  346. enum {
  347. IEEE80211_DEV_UNINITIALIZED = 0,
  348. IEEE80211_DEV_REGISTERED,
  349. IEEE80211_DEV_UNREGISTERED,
  350. } reg_state;
  351. /* Tasklet and skb queue to process calls from IRQ mode. All frames
  352. * added to skb_queue will be processed, but frames in
  353. * skb_queue_unreliable may be dropped if the total length of these
  354. * queues increases over the limit. */
  355. #define IEEE80211_IRQSAFE_QUEUE_LIMIT 128
  356. struct tasklet_struct tasklet;
  357. struct sk_buff_head skb_queue;
  358. struct sk_buff_head skb_queue_unreliable;
  359. /* Station data structures */
  360. spinlock_t sta_lock; /* mutex for STA data structures */
  361. int num_sta; /* number of stations in sta_list */
  362. struct list_head sta_list;
  363. struct list_head deleted_sta_list;
  364. struct sta_info *sta_hash[STA_HASH_SIZE];
  365. struct timer_list sta_cleanup;
  366. unsigned long state[NUM_TX_DATA_QUEUES];
  367. struct ieee80211_tx_stored_packet pending_packet[NUM_TX_DATA_QUEUES];
  368. struct tasklet_struct tx_pending_tasklet;
  369. int mc_count; /* total count of multicast entries in all interfaces */
  370. int iff_allmultis, iff_promiscs;
  371. /* number of interfaces with corresponding IFF_ flags */
  372. struct rate_control_ref *rate_ctrl;
  373. int next_mode; /* MODE_IEEE80211*
  374. * The mode preference for next channel change. This is
  375. * used to select .11g vs. .11b channels (or 4.9 GHz vs.
  376. * .11a) when the channel number is not unique. */
  377. /* Supported and basic rate filters for different modes. These are
  378. * pointers to -1 terminated lists and rates in 100 kbps units. */
  379. int *supp_rates[NUM_IEEE80211_MODES];
  380. int *basic_rates[NUM_IEEE80211_MODES];
  381. int rts_threshold;
  382. int fragmentation_threshold;
  383. int short_retry_limit; /* dot11ShortRetryLimit */
  384. int long_retry_limit; /* dot11LongRetryLimit */
  385. int short_preamble; /* use short preamble with IEEE 802.11b */
  386. struct crypto_blkcipher *wep_tx_tfm;
  387. struct crypto_blkcipher *wep_rx_tfm;
  388. u32 wep_iv;
  389. int key_tx_rx_threshold; /* number of times any key can be used in TX
  390. * or RX before generating a rekey
  391. * notification; 0 = notification disabled. */
  392. int bridge_packets; /* bridge packets between associated stations and
  393. * deliver multicast frames both back to wireless
  394. * media and to the local net stack */
  395. ieee80211_rx_handler *rx_pre_handlers;
  396. ieee80211_rx_handler *rx_handlers;
  397. ieee80211_tx_handler *tx_handlers;
  398. rwlock_t sub_if_lock; /* Protects sub_if_list. Cannot be taken under
  399. * sta_bss_lock or sta_lock. */
  400. struct list_head sub_if_list;
  401. int sta_scanning;
  402. int scan_channel_idx;
  403. enum { SCAN_SET_CHANNEL, SCAN_SEND_PROBE } scan_state;
  404. unsigned long last_scan_completed;
  405. struct delayed_work scan_work;
  406. struct net_device *scan_dev;
  407. struct ieee80211_channel *oper_channel, *scan_channel;
  408. struct ieee80211_hw_mode *oper_hw_mode, *scan_hw_mode;
  409. u8 scan_ssid[IEEE80211_MAX_SSID_LEN];
  410. size_t scan_ssid_len;
  411. struct list_head sta_bss_list;
  412. struct ieee80211_sta_bss *sta_bss_hash[STA_HASH_SIZE];
  413. spinlock_t sta_bss_lock;
  414. #define IEEE80211_SCAN_MATCH_SSID BIT(0)
  415. #define IEEE80211_SCAN_WPA_ONLY BIT(1)
  416. #define IEEE80211_SCAN_EXTRA_INFO BIT(2)
  417. int scan_flags;
  418. /* SNMP counters */
  419. /* dot11CountersTable */
  420. u32 dot11TransmittedFragmentCount;
  421. u32 dot11MulticastTransmittedFrameCount;
  422. u32 dot11FailedCount;
  423. u32 dot11RetryCount;
  424. u32 dot11MultipleRetryCount;
  425. u32 dot11FrameDuplicateCount;
  426. u32 dot11ReceivedFragmentCount;
  427. u32 dot11MulticastReceivedFrameCount;
  428. u32 dot11TransmittedFrameCount;
  429. u32 dot11WEPUndecryptableCount;
  430. #ifdef CONFIG_MAC80211_LEDS
  431. int tx_led_counter, rx_led_counter;
  432. struct led_trigger *tx_led, *rx_led;
  433. char tx_led_name[32], rx_led_name[32];
  434. #endif
  435. u32 channel_use;
  436. u32 channel_use_raw;
  437. u32 stat_time;
  438. struct timer_list stat_timer;
  439. #ifdef CONFIG_MAC80211_DEBUGFS
  440. struct work_struct sta_debugfs_add;
  441. #endif
  442. enum {
  443. STA_ANTENNA_SEL_AUTO = 0,
  444. STA_ANTENNA_SEL_SW_CTRL = 1,
  445. STA_ANTENNA_SEL_SW_CTRL_DEBUG = 2
  446. } sta_antenna_sel;
  447. #ifdef CONFIG_MAC80211_DEBUG_COUNTERS
  448. /* TX/RX handler statistics */
  449. unsigned int tx_handlers_drop;
  450. unsigned int tx_handlers_queued;
  451. unsigned int tx_handlers_drop_unencrypted;
  452. unsigned int tx_handlers_drop_fragment;
  453. unsigned int tx_handlers_drop_wep;
  454. unsigned int tx_handlers_drop_not_assoc;
  455. unsigned int tx_handlers_drop_unauth_port;
  456. unsigned int rx_handlers_drop;
  457. unsigned int rx_handlers_queued;
  458. unsigned int rx_handlers_drop_nullfunc;
  459. unsigned int rx_handlers_drop_defrag;
  460. unsigned int rx_handlers_drop_short;
  461. unsigned int rx_handlers_drop_passive_scan;
  462. unsigned int tx_expand_skb_head;
  463. unsigned int tx_expand_skb_head_cloned;
  464. unsigned int rx_expand_skb_head;
  465. unsigned int rx_expand_skb_head2;
  466. unsigned int rx_handlers_fragments;
  467. unsigned int tx_status_drop;
  468. unsigned int wme_rx_queue[NUM_RX_DATA_QUEUES];
  469. unsigned int wme_tx_queue[NUM_RX_DATA_QUEUES];
  470. #define I802_DEBUG_INC(c) (c)++
  471. #else /* CONFIG_MAC80211_DEBUG_COUNTERS */
  472. #define I802_DEBUG_INC(c) do { } while (0)
  473. #endif /* CONFIG_MAC80211_DEBUG_COUNTERS */
  474. int default_wep_only; /* only default WEP keys are used with this
  475. * interface; this is used to decide when hwaccel
  476. * can be used with default keys */
  477. int total_ps_buffered; /* total number of all buffered unicast and
  478. * multicast packets for power saving stations
  479. */
  480. int allow_broadcast_always; /* whether to allow TX of broadcast frames
  481. * even when there are no associated STAs
  482. */
  483. int wifi_wme_noack_test;
  484. unsigned int wmm_acm; /* bit field of ACM bits (BIT(802.1D tag)) */
  485. unsigned int enabled_modes; /* bitfield of allowed modes;
  486. * (1 << MODE_*) */
  487. unsigned int hw_modes; /* bitfield of supported hardware modes;
  488. * (1 << MODE_*) */
  489. int user_space_mlme;
  490. #ifdef CONFIG_MAC80211_DEBUGFS
  491. struct local_debugfsdentries {
  492. struct dentry *channel;
  493. struct dentry *frequency;
  494. struct dentry *radar_detect;
  495. struct dentry *antenna_sel_tx;
  496. struct dentry *antenna_sel_rx;
  497. struct dentry *bridge_packets;
  498. struct dentry *key_tx_rx_threshold;
  499. struct dentry *rts_threshold;
  500. struct dentry *fragmentation_threshold;
  501. struct dentry *short_retry_limit;
  502. struct dentry *long_retry_limit;
  503. struct dentry *total_ps_buffered;
  504. struct dentry *mode;
  505. struct dentry *wep_iv;
  506. struct dentry *tx_power_reduction;
  507. struct dentry *modes;
  508. struct dentry *statistics;
  509. struct local_debugfsdentries_statsdentries {
  510. struct dentry *transmitted_fragment_count;
  511. struct dentry *multicast_transmitted_frame_count;
  512. struct dentry *failed_count;
  513. struct dentry *retry_count;
  514. struct dentry *multiple_retry_count;
  515. struct dentry *frame_duplicate_count;
  516. struct dentry *received_fragment_count;
  517. struct dentry *multicast_received_frame_count;
  518. struct dentry *transmitted_frame_count;
  519. struct dentry *wep_undecryptable_count;
  520. struct dentry *num_scans;
  521. #ifdef CONFIG_MAC80211_DEBUG_COUNTERS
  522. struct dentry *tx_handlers_drop;
  523. struct dentry *tx_handlers_queued;
  524. struct dentry *tx_handlers_drop_unencrypted;
  525. struct dentry *tx_handlers_drop_fragment;
  526. struct dentry *tx_handlers_drop_wep;
  527. struct dentry *tx_handlers_drop_not_assoc;
  528. struct dentry *tx_handlers_drop_unauth_port;
  529. struct dentry *rx_handlers_drop;
  530. struct dentry *rx_handlers_queued;
  531. struct dentry *rx_handlers_drop_nullfunc;
  532. struct dentry *rx_handlers_drop_defrag;
  533. struct dentry *rx_handlers_drop_short;
  534. struct dentry *rx_handlers_drop_passive_scan;
  535. struct dentry *tx_expand_skb_head;
  536. struct dentry *tx_expand_skb_head_cloned;
  537. struct dentry *rx_expand_skb_head;
  538. struct dentry *rx_expand_skb_head2;
  539. struct dentry *rx_handlers_fragments;
  540. struct dentry *tx_status_drop;
  541. struct dentry *wme_tx_queue;
  542. struct dentry *wme_rx_queue;
  543. #endif
  544. struct dentry *dot11ACKFailureCount;
  545. struct dentry *dot11RTSFailureCount;
  546. struct dentry *dot11FCSErrorCount;
  547. struct dentry *dot11RTSSuccessCount;
  548. } stats;
  549. struct dentry *stations;
  550. struct dentry *keys;
  551. } debugfs;
  552. #endif
  553. };
  554. static inline struct ieee80211_local *hw_to_local(
  555. struct ieee80211_hw *hw)
  556. {
  557. return container_of(hw, struct ieee80211_local, hw);
  558. }
  559. static inline struct ieee80211_hw *local_to_hw(
  560. struct ieee80211_local *local)
  561. {
  562. return &local->hw;
  563. }
  564. enum ieee80211_link_state_t {
  565. IEEE80211_LINK_STATE_XOFF = 0,
  566. IEEE80211_LINK_STATE_PENDING,
  567. };
  568. struct sta_attribute {
  569. struct attribute attr;
  570. ssize_t (*show)(const struct sta_info *, char *buf);
  571. ssize_t (*store)(struct sta_info *, const char *buf, size_t count);
  572. };
  573. static inline void __bss_tim_set(struct ieee80211_if_ap *bss, int aid)
  574. {
  575. /*
  576. * This format has ben mandated by the IEEE specifications,
  577. * so this line may not be changed to use the __set_bit() format.
  578. */
  579. bss->tim[(aid)/8] |= 1<<((aid) % 8);
  580. }
  581. static inline void bss_tim_set(struct ieee80211_local *local,
  582. struct ieee80211_if_ap *bss, int aid)
  583. {
  584. spin_lock_bh(&local->sta_lock);
  585. __bss_tim_set(bss, aid);
  586. spin_unlock_bh(&local->sta_lock);
  587. }
  588. static inline void __bss_tim_clear(struct ieee80211_if_ap *bss, int aid)
  589. {
  590. /*
  591. * This format has ben mandated by the IEEE specifications,
  592. * so this line may not be changed to use the __clear_bit() format.
  593. */
  594. bss->tim[(aid)/8] &= !(1<<((aid) % 8));
  595. }
  596. static inline void bss_tim_clear(struct ieee80211_local *local,
  597. struct ieee80211_if_ap *bss, int aid)
  598. {
  599. spin_lock_bh(&local->sta_lock);
  600. __bss_tim_clear(bss, aid);
  601. spin_unlock_bh(&local->sta_lock);
  602. }
  603. /**
  604. * ieee80211_is_erp_rate - Check if a rate is an ERP rate
  605. * @phymode: The PHY-mode for this rate (MODE_IEEE80211...)
  606. * @rate: Transmission rate to check, in 100 kbps
  607. *
  608. * Check if a given rate is an Extended Rate PHY (ERP) rate.
  609. */
  610. static inline int ieee80211_is_erp_rate(int phymode, int rate)
  611. {
  612. if (phymode == MODE_IEEE80211G) {
  613. if (rate != 10 && rate != 20 &&
  614. rate != 55 && rate != 110)
  615. return 1;
  616. }
  617. return 0;
  618. }
  619. static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr)
  620. {
  621. return compare_ether_addr(raddr, addr) == 0 ||
  622. is_broadcast_ether_addr(raddr);
  623. }
  624. /* ieee80211.c */
  625. int ieee80211_hw_config(struct ieee80211_local *local);
  626. int ieee80211_if_config(struct net_device *dev);
  627. int ieee80211_if_config_beacon(struct net_device *dev);
  628. struct ieee80211_key_conf *
  629. ieee80211_key_data2conf(struct ieee80211_local *local,
  630. const struct ieee80211_key *data);
  631. struct ieee80211_key *ieee80211_key_alloc(struct ieee80211_sub_if_data *sdata,
  632. int idx, size_t key_len, gfp_t flags);
  633. void ieee80211_key_free(struct ieee80211_key *key);
  634. void ieee80211_rx_mgmt(struct ieee80211_local *local, struct sk_buff *skb,
  635. struct ieee80211_rx_status *status, u32 msg_type);
  636. void ieee80211_prepare_rates(struct ieee80211_local *local,
  637. struct ieee80211_hw_mode *mode);
  638. void ieee80211_tx_set_iswep(struct ieee80211_txrx_data *tx);
  639. int ieee80211_if_update_wds(struct net_device *dev, u8 *remote_addr);
  640. int ieee80211_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev);
  641. int ieee80211_subif_start_xmit(struct sk_buff *skb, struct net_device *dev);
  642. void ieee80211_if_setup(struct net_device *dev);
  643. void ieee80211_if_mgmt_setup(struct net_device *dev);
  644. int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
  645. const char *name);
  646. struct net_device_stats *ieee80211_dev_stats(struct net_device *dev);
  647. struct ieee80211_rate *ieee80211_get_rate(struct ieee80211_local *local,
  648. int phymode, int hwrate);
  649. void ieee80211_key_threshold_notify(struct net_device *dev,
  650. struct ieee80211_key *key,
  651. struct sta_info *sta);
  652. u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len);
  653. int ieee80211_is_eapol(const struct sk_buff *skb);
  654. extern const unsigned char rfc1042_header[];
  655. extern const unsigned char bridge_tunnel_header[];
  656. /* ieee80211_ioctl.c */
  657. extern const struct iw_handler_def ieee80211_iw_handler_def;
  658. void ieee80211_update_default_wep_only(struct ieee80211_local *local);
  659. /* Least common multiple of the used rates (in 100 kbps). This is used to
  660. * calculate rate_inv values for each rate so that only integers are needed. */
  661. #define CHAN_UTIL_RATE_LCM 95040
  662. /* 1 usec is 1/8 * (95040/10) = 1188 */
  663. #define CHAN_UTIL_PER_USEC 1188
  664. /* Amount of bits to shift the result right to scale the total utilization
  665. * to values that will not wrap around 32-bit integers. */
  666. #define CHAN_UTIL_SHIFT 9
  667. /* Theoretical maximum of channel utilization counter in 10 ms (stat_time=1):
  668. * (CHAN_UTIL_PER_USEC * 10000) >> CHAN_UTIL_SHIFT = 23203. So dividing the
  669. * raw value with about 23 should give utilization in 10th of a percentage
  670. * (1/1000). However, utilization is only estimated and not all intervals
  671. * between frames etc. are calculated. 18 seems to give numbers that are closer
  672. * to the real maximum. */
  673. #define CHAN_UTIL_PER_10MS 18
  674. #define CHAN_UTIL_HDR_LONG (202 * CHAN_UTIL_PER_USEC)
  675. #define CHAN_UTIL_HDR_SHORT (40 * CHAN_UTIL_PER_USEC)
  676. /* ieee80211_ioctl.c */
  677. int ieee80211_set_compression(struct ieee80211_local *local,
  678. struct net_device *dev, struct sta_info *sta);
  679. int ieee80211_set_channel(struct ieee80211_local *local, int channel, int freq);
  680. /* ieee80211_sta.c */
  681. void ieee80211_sta_timer(unsigned long data);
  682. void ieee80211_sta_work(struct work_struct *work);
  683. void ieee80211_sta_scan_work(struct work_struct *work);
  684. void ieee80211_sta_rx_mgmt(struct net_device *dev, struct sk_buff *skb,
  685. struct ieee80211_rx_status *rx_status);
  686. int ieee80211_sta_set_ssid(struct net_device *dev, char *ssid, size_t len);
  687. int ieee80211_sta_get_ssid(struct net_device *dev, char *ssid, size_t *len);
  688. int ieee80211_sta_set_bssid(struct net_device *dev, u8 *bssid);
  689. int ieee80211_sta_req_scan(struct net_device *dev, u8 *ssid, size_t ssid_len);
  690. void ieee80211_sta_req_auth(struct net_device *dev,
  691. struct ieee80211_if_sta *ifsta);
  692. int ieee80211_sta_scan_results(struct net_device *dev, char *buf, size_t len);
  693. void ieee80211_sta_rx_scan(struct net_device *dev, struct sk_buff *skb,
  694. struct ieee80211_rx_status *rx_status);
  695. void ieee80211_rx_bss_list_init(struct net_device *dev);
  696. void ieee80211_rx_bss_list_deinit(struct net_device *dev);
  697. int ieee80211_sta_set_extra_ie(struct net_device *dev, char *ie, size_t len);
  698. struct sta_info * ieee80211_ibss_add_sta(struct net_device *dev,
  699. struct sk_buff *skb, u8 *bssid,
  700. u8 *addr);
  701. int ieee80211_sta_deauthenticate(struct net_device *dev, u16 reason);
  702. int ieee80211_sta_disassociate(struct net_device *dev, u16 reason);
  703. /* ieee80211_iface.c */
  704. int ieee80211_if_add(struct net_device *dev, const char *name,
  705. struct net_device **new_dev, int type);
  706. void ieee80211_if_set_type(struct net_device *dev, int type);
  707. void ieee80211_if_reinit(struct net_device *dev);
  708. void __ieee80211_if_del(struct ieee80211_local *local,
  709. struct ieee80211_sub_if_data *sdata);
  710. int ieee80211_if_remove(struct net_device *dev, const char *name, int id);
  711. void ieee80211_if_free(struct net_device *dev);
  712. void ieee80211_if_sdata_init(struct ieee80211_sub_if_data *sdata);
  713. int ieee80211_if_add_mgmt(struct ieee80211_local *local);
  714. void ieee80211_if_del_mgmt(struct ieee80211_local *local);
  715. /* regdomain.c */
  716. void ieee80211_regdomain_init(void);
  717. void ieee80211_set_default_regdomain(struct ieee80211_hw_mode *mode);
  718. /* rx handling */
  719. extern ieee80211_rx_handler ieee80211_rx_pre_handlers[];
  720. extern ieee80211_rx_handler ieee80211_rx_handlers[];
  721. /* for wiphy privid */
  722. extern void *mac80211_wiphy_privid;
  723. #endif /* IEEE80211_I_H */