ieee80211_i.h 25 KB

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