ieee80211_i.h 25 KB

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