ieee80211_i.h 26 KB

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