ieee80211_i.h 25 KB

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