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