ieee80211_i.h 24 KB

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