ieee80211_i.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924
  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. #ifdef CONFIG_MAC80211_MESH
  79. u8 *mesh_id;
  80. size_t mesh_id_len;
  81. #endif
  82. /* mesh_cfg left out the ifdef to reduce clutter on bss handling */
  83. u8 *mesh_cfg;
  84. #define IEEE80211_MAX_SUPP_RATES 32
  85. u8 supp_rates[IEEE80211_MAX_SUPP_RATES];
  86. size_t supp_rates_len;
  87. int beacon_int;
  88. u64 timestamp;
  89. int probe_resp;
  90. unsigned long last_update;
  91. /* during assocation, we save an ERP value from a probe response so
  92. * that we can feed ERP info to the driver when handling the
  93. * association completes. these fields probably won't be up-to-date
  94. * otherwise, you probably don't want to use them. */
  95. int has_erp_value;
  96. u8 erp_value;
  97. };
  98. typedef unsigned __bitwise__ ieee80211_tx_result;
  99. #define TX_CONTINUE ((__force ieee80211_tx_result) 0u)
  100. #define TX_DROP ((__force ieee80211_tx_result) 1u)
  101. #define TX_QUEUED ((__force ieee80211_tx_result) 2u)
  102. typedef unsigned __bitwise__ ieee80211_rx_result;
  103. #define RX_CONTINUE ((__force ieee80211_rx_result) 0u)
  104. #define RX_DROP_UNUSABLE ((__force ieee80211_rx_result) 1u)
  105. #define RX_DROP_MONITOR ((__force ieee80211_rx_result) 2u)
  106. #define RX_QUEUED ((__force ieee80211_rx_result) 3u)
  107. /* flags used in struct ieee80211_txrx_data.flags */
  108. /* whether the MSDU was fragmented */
  109. #define IEEE80211_TXRXD_FRAGMENTED BIT(0)
  110. #define IEEE80211_TXRXD_TXUNICAST BIT(1)
  111. #define IEEE80211_TXRXD_TXPS_BUFFERED BIT(2)
  112. #define IEEE80211_TXRXD_TXPROBE_LAST_FRAG BIT(3)
  113. #define IEEE80211_TXRXD_RXIN_SCAN BIT(4)
  114. /* frame is destined to interface currently processed (incl. multicast frames) */
  115. #define IEEE80211_TXRXD_RXRA_MATCH BIT(5)
  116. #define IEEE80211_TXRXD_TX_INJECTED BIT(6)
  117. #define IEEE80211_TXRXD_RX_AMSDU BIT(7)
  118. #define IEEE80211_TXRXD_RX_CMNTR_REPORTED BIT(8)
  119. struct ieee80211_txrx_data {
  120. struct sk_buff *skb;
  121. struct net_device *dev;
  122. struct ieee80211_local *local;
  123. struct ieee80211_sub_if_data *sdata;
  124. struct sta_info *sta;
  125. u16 fc, ethertype;
  126. struct ieee80211_key *key;
  127. unsigned int flags;
  128. union {
  129. struct {
  130. struct ieee80211_tx_control *control;
  131. struct ieee80211_channel *channel;
  132. struct ieee80211_rate *rate;
  133. /* use this rate (if set) for last fragment; rate can
  134. * be set to lower rate for the first fragments, e.g.,
  135. * when using CTS protection with IEEE 802.11g. */
  136. struct ieee80211_rate *last_frag_rate;
  137. /* Extra fragments (in addition to the first fragment
  138. * in skb) */
  139. int num_extra_frag;
  140. struct sk_buff **extra_frag;
  141. } tx;
  142. struct {
  143. struct ieee80211_rx_status *status;
  144. struct ieee80211_rate *rate;
  145. int sent_ps_buffered;
  146. int queue;
  147. int load;
  148. u32 tkip_iv32;
  149. u16 tkip_iv16;
  150. } rx;
  151. } u;
  152. };
  153. /* flags used in struct ieee80211_tx_packet_data.flags */
  154. #define IEEE80211_TXPD_REQ_TX_STATUS BIT(0)
  155. #define IEEE80211_TXPD_DO_NOT_ENCRYPT BIT(1)
  156. #define IEEE80211_TXPD_REQUEUE BIT(2)
  157. #define IEEE80211_TXPD_EAPOL_FRAME BIT(3)
  158. #define IEEE80211_TXPD_AMPDU BIT(4)
  159. /* Stored in sk_buff->cb */
  160. struct ieee80211_tx_packet_data {
  161. int ifindex;
  162. unsigned long jiffies;
  163. unsigned int flags;
  164. u8 queue;
  165. };
  166. struct ieee80211_tx_stored_packet {
  167. struct ieee80211_tx_control control;
  168. struct sk_buff *skb;
  169. int num_extra_frag;
  170. struct sk_buff **extra_frag;
  171. struct ieee80211_rate *last_frag_rate;
  172. unsigned int last_frag_rate_ctrl_probe;
  173. };
  174. struct beacon_data {
  175. u8 *head, *tail;
  176. int head_len, tail_len;
  177. int dtim_period;
  178. };
  179. struct ieee80211_if_ap {
  180. struct beacon_data *beacon;
  181. struct list_head vlans;
  182. u8 ssid[IEEE80211_MAX_SSID_LEN];
  183. size_t ssid_len;
  184. /* yes, this looks ugly, but guarantees that we can later use
  185. * bitmap_empty :)
  186. * NB: don't touch this bitmap, use sta_info_{set,clear}_tim_bit */
  187. u8 tim[sizeof(unsigned long) * BITS_TO_LONGS(IEEE80211_MAX_AID + 1)];
  188. atomic_t num_sta_ps; /* number of stations in PS mode */
  189. struct sk_buff_head ps_bc_buf;
  190. int dtim_count;
  191. int force_unicast_rateidx; /* forced TX rateidx for unicast frames */
  192. int max_ratectrl_rateidx; /* max TX rateidx for rate control */
  193. int num_beacons; /* number of TXed beacon frames for this BSS */
  194. };
  195. struct ieee80211_if_wds {
  196. u8 remote_addr[ETH_ALEN];
  197. struct sta_info *sta;
  198. };
  199. struct ieee80211_if_vlan {
  200. struct ieee80211_sub_if_data *ap;
  201. struct list_head list;
  202. };
  203. #ifdef CONFIG_MAC80211_MESH
  204. struct mesh_stats {
  205. __u32 fwded_frames; /* Mesh forwarded frames */
  206. __u32 dropped_frames_ttl; /* Not transmitted since mesh_ttl == 0*/
  207. __u32 dropped_frames_no_route; /* Not transmitted, no route found */
  208. atomic_t estab_plinks;
  209. };
  210. #define PREQ_Q_F_START 0x1
  211. #define PREQ_Q_F_REFRESH 0x2
  212. struct mesh_preq_queue {
  213. struct list_head list;
  214. u8 dst[ETH_ALEN];
  215. u8 flags;
  216. };
  217. struct mesh_config {
  218. /* Timeouts in ms */
  219. /* Mesh plink management parameters */
  220. u16 dot11MeshRetryTimeout;
  221. u16 dot11MeshConfirmTimeout;
  222. u16 dot11MeshHoldingTimeout;
  223. u16 dot11MeshMaxPeerLinks;
  224. u8 dot11MeshMaxRetries;
  225. u8 dot11MeshTTL;
  226. bool auto_open_plinks;
  227. /* HWMP parameters */
  228. u32 dot11MeshHWMPactivePathTimeout;
  229. u16 dot11MeshHWMPpreqMinInterval;
  230. u16 dot11MeshHWMPnetDiameterTraversalTime;
  231. u8 dot11MeshHWMPmaxPREQretries;
  232. u32 path_refresh_time;
  233. u16 min_discovery_timeout;
  234. };
  235. #endif
  236. /* flags used in struct ieee80211_if_sta.flags */
  237. #define IEEE80211_STA_SSID_SET BIT(0)
  238. #define IEEE80211_STA_BSSID_SET BIT(1)
  239. #define IEEE80211_STA_PREV_BSSID_SET BIT(2)
  240. #define IEEE80211_STA_AUTHENTICATED BIT(3)
  241. #define IEEE80211_STA_ASSOCIATED BIT(4)
  242. #define IEEE80211_STA_PROBEREQ_POLL BIT(5)
  243. #define IEEE80211_STA_CREATE_IBSS BIT(6)
  244. #define IEEE80211_STA_MIXED_CELL BIT(7)
  245. #define IEEE80211_STA_WMM_ENABLED BIT(8)
  246. #define IEEE80211_STA_AUTO_SSID_SEL BIT(10)
  247. #define IEEE80211_STA_AUTO_BSSID_SEL BIT(11)
  248. #define IEEE80211_STA_AUTO_CHANNEL_SEL BIT(12)
  249. #define IEEE80211_STA_PRIVACY_INVOKED BIT(13)
  250. struct ieee80211_if_sta {
  251. enum {
  252. IEEE80211_DISABLED, IEEE80211_AUTHENTICATE,
  253. IEEE80211_ASSOCIATE, IEEE80211_ASSOCIATED,
  254. IEEE80211_IBSS_SEARCH, IEEE80211_IBSS_JOINED,
  255. IEEE80211_MESH_UP
  256. } state;
  257. struct timer_list timer;
  258. struct work_struct work;
  259. u8 bssid[ETH_ALEN], prev_bssid[ETH_ALEN];
  260. u8 ssid[IEEE80211_MAX_SSID_LEN];
  261. size_t ssid_len;
  262. u8 scan_ssid[IEEE80211_MAX_SSID_LEN];
  263. size_t scan_ssid_len;
  264. #ifdef CONFIG_MAC80211_MESH
  265. struct timer_list mesh_path_timer;
  266. u8 mesh_id[IEEE80211_MAX_MESH_ID_LEN];
  267. bool accepting_plinks;
  268. size_t mesh_id_len;
  269. /* Active Path Selection Protocol Identifier */
  270. u8 mesh_pp_id[4];
  271. /* Active Path Selection Metric Identifier */
  272. u8 mesh_pm_id[4];
  273. /* Congestion Control Mode Identifier */
  274. u8 mesh_cc_id[4];
  275. /* Local mesh Destination Sequence Number */
  276. u32 dsn;
  277. /* Last used PREQ ID */
  278. u32 preq_id;
  279. atomic_t mpaths;
  280. /* Timestamp of last DSN update */
  281. unsigned long last_dsn_update;
  282. /* Timestamp of last DSN sent */
  283. unsigned long last_preq;
  284. struct mesh_rmc *rmc;
  285. spinlock_t mesh_preq_queue_lock;
  286. struct mesh_preq_queue preq_queue;
  287. int preq_queue_len;
  288. struct mesh_stats mshstats;
  289. struct mesh_config mshcfg;
  290. u8 mesh_seqnum[3];
  291. #endif
  292. u16 aid;
  293. u16 ap_capab, capab;
  294. u8 *extra_ie; /* to be added to the end of AssocReq */
  295. size_t extra_ie_len;
  296. /* The last AssocReq/Resp IEs */
  297. u8 *assocreq_ies, *assocresp_ies;
  298. size_t assocreq_ies_len, assocresp_ies_len;
  299. int auth_tries, assoc_tries;
  300. unsigned int flags;
  301. #define IEEE80211_STA_REQ_SCAN 0
  302. #define IEEE80211_STA_REQ_AUTH 1
  303. #define IEEE80211_STA_REQ_RUN 2
  304. unsigned long request;
  305. struct sk_buff_head skb_queue;
  306. unsigned long last_probe;
  307. #define IEEE80211_AUTH_ALG_OPEN BIT(0)
  308. #define IEEE80211_AUTH_ALG_SHARED_KEY BIT(1)
  309. #define IEEE80211_AUTH_ALG_LEAP BIT(2)
  310. unsigned int auth_algs; /* bitfield of allowed auth algs */
  311. int auth_alg; /* currently used IEEE 802.11 authentication algorithm */
  312. int auth_transaction;
  313. unsigned long ibss_join_req;
  314. struct sk_buff *probe_resp; /* ProbeResp template for IBSS */
  315. u32 supp_rates_bits[IEEE80211_NUM_BANDS];
  316. int wmm_last_param_set;
  317. int num_beacons; /* number of TXed beacon frames by this STA */
  318. };
  319. /* flags used in struct ieee80211_sub_if_data.flags */
  320. #define IEEE80211_SDATA_ALLMULTI BIT(0)
  321. #define IEEE80211_SDATA_PROMISC BIT(1)
  322. #define IEEE80211_SDATA_USERSPACE_MLME BIT(2)
  323. #define IEEE80211_SDATA_OPERATING_GMODE BIT(3)
  324. struct ieee80211_sub_if_data {
  325. struct list_head list;
  326. struct wireless_dev wdev;
  327. /* keys */
  328. struct list_head key_list;
  329. struct net_device *dev;
  330. struct ieee80211_local *local;
  331. unsigned int flags;
  332. int drop_unencrypted;
  333. /*
  334. * basic rates of this AP or the AP we're associated to
  335. */
  336. u64 basic_rates;
  337. u16 sequence;
  338. /* Fragment table for host-based reassembly */
  339. struct ieee80211_fragment_entry fragments[IEEE80211_FRAGMENT_MAX];
  340. unsigned int fragment_next;
  341. #define NUM_DEFAULT_KEYS 4
  342. struct ieee80211_key *keys[NUM_DEFAULT_KEYS];
  343. struct ieee80211_key *default_key;
  344. /*
  345. * BSS configuration for this interface.
  346. *
  347. * FIXME: I feel bad putting this here when we already have a
  348. * bss pointer, but the bss pointer is just wrong when
  349. * you have multiple virtual STA mode interfaces...
  350. * This needs to be fixed.
  351. */
  352. struct ieee80211_bss_conf bss_conf;
  353. struct ieee80211_if_ap *bss; /* BSS that this device belongs to */
  354. union {
  355. struct ieee80211_if_ap ap;
  356. struct ieee80211_if_wds wds;
  357. struct ieee80211_if_vlan vlan;
  358. struct ieee80211_if_sta sta;
  359. u32 mntr_flags;
  360. } u;
  361. int channel_use;
  362. int channel_use_raw;
  363. #ifdef CONFIG_MAC80211_DEBUGFS
  364. struct dentry *debugfsdir;
  365. union {
  366. struct {
  367. struct dentry *channel_use;
  368. struct dentry *drop_unencrypted;
  369. struct dentry *state;
  370. struct dentry *bssid;
  371. struct dentry *prev_bssid;
  372. struct dentry *ssid_len;
  373. struct dentry *aid;
  374. struct dentry *ap_capab;
  375. struct dentry *capab;
  376. struct dentry *extra_ie_len;
  377. struct dentry *auth_tries;
  378. struct dentry *assoc_tries;
  379. struct dentry *auth_algs;
  380. struct dentry *auth_alg;
  381. struct dentry *auth_transaction;
  382. struct dentry *flags;
  383. struct dentry *num_beacons_sta;
  384. } sta;
  385. struct {
  386. struct dentry *channel_use;
  387. struct dentry *drop_unencrypted;
  388. struct dentry *num_sta_ps;
  389. struct dentry *dtim_count;
  390. struct dentry *num_beacons;
  391. struct dentry *force_unicast_rateidx;
  392. struct dentry *max_ratectrl_rateidx;
  393. struct dentry *num_buffered_multicast;
  394. } ap;
  395. struct {
  396. struct dentry *channel_use;
  397. struct dentry *drop_unencrypted;
  398. struct dentry *peer;
  399. } wds;
  400. struct {
  401. struct dentry *channel_use;
  402. struct dentry *drop_unencrypted;
  403. } vlan;
  404. struct {
  405. struct dentry *mode;
  406. } monitor;
  407. struct dentry *default_key;
  408. } debugfs;
  409. #ifdef CONFIG_MAC80211_MESH
  410. struct dentry *mesh_stats_dir;
  411. struct {
  412. struct dentry *fwded_frames;
  413. struct dentry *dropped_frames_ttl;
  414. struct dentry *dropped_frames_no_route;
  415. struct dentry *estab_plinks;
  416. struct timer_list mesh_path_timer;
  417. } mesh_stats;
  418. struct dentry *mesh_config_dir;
  419. struct {
  420. struct dentry *dot11MeshRetryTimeout;
  421. struct dentry *dot11MeshConfirmTimeout;
  422. struct dentry *dot11MeshHoldingTimeout;
  423. struct dentry *dot11MeshMaxRetries;
  424. struct dentry *dot11MeshTTL;
  425. struct dentry *auto_open_plinks;
  426. struct dentry *dot11MeshMaxPeerLinks;
  427. struct dentry *dot11MeshHWMPactivePathTimeout;
  428. struct dentry *dot11MeshHWMPpreqMinInterval;
  429. struct dentry *dot11MeshHWMPnetDiameterTraversalTime;
  430. struct dentry *dot11MeshHWMPmaxPREQretries;
  431. struct dentry *path_refresh_time;
  432. struct dentry *min_discovery_timeout;
  433. } mesh_config;
  434. #endif
  435. #endif
  436. /* must be last, dynamically sized area in this! */
  437. struct ieee80211_vif vif;
  438. };
  439. static inline
  440. struct ieee80211_sub_if_data *vif_to_sdata(struct ieee80211_vif *p)
  441. {
  442. return container_of(p, struct ieee80211_sub_if_data, vif);
  443. }
  444. #define IEEE80211_DEV_TO_SUB_IF(dev) netdev_priv(dev)
  445. enum {
  446. IEEE80211_RX_MSG = 1,
  447. IEEE80211_TX_STATUS_MSG = 2,
  448. IEEE80211_DELBA_MSG = 3,
  449. IEEE80211_ADDBA_MSG = 4,
  450. };
  451. struct ieee80211_local {
  452. /* embed the driver visible part.
  453. * don't cast (use the static inlines below), but we keep
  454. * it first anyway so they become a no-op */
  455. struct ieee80211_hw hw;
  456. const struct ieee80211_ops *ops;
  457. struct net_device *mdev; /* wmaster# - "master" 802.11 device */
  458. int open_count;
  459. int monitors, cooked_mntrs;
  460. /* number of interfaces with corresponding FIF_ flags */
  461. int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss;
  462. unsigned int filter_flags; /* FIF_* */
  463. struct iw_statistics wstats;
  464. u8 wstats_flags;
  465. int tx_headroom; /* required headroom for hardware/radiotap */
  466. enum {
  467. IEEE80211_DEV_UNINITIALIZED = 0,
  468. IEEE80211_DEV_REGISTERED,
  469. IEEE80211_DEV_UNREGISTERED,
  470. } reg_state;
  471. /* Tasklet and skb queue to process calls from IRQ mode. All frames
  472. * added to skb_queue will be processed, but frames in
  473. * skb_queue_unreliable may be dropped if the total length of these
  474. * queues increases over the limit. */
  475. #define IEEE80211_IRQSAFE_QUEUE_LIMIT 128
  476. struct tasklet_struct tasklet;
  477. struct sk_buff_head skb_queue;
  478. struct sk_buff_head skb_queue_unreliable;
  479. /* Station data structures */
  480. rwlock_t sta_lock; /* protects STA data structures */
  481. int num_sta; /* number of stations in sta_list */
  482. struct list_head sta_list;
  483. struct sta_info *sta_hash[STA_HASH_SIZE];
  484. struct timer_list sta_cleanup;
  485. unsigned long state[NUM_TX_DATA_QUEUES_AMPDU];
  486. struct ieee80211_tx_stored_packet pending_packet[NUM_TX_DATA_QUEUES_AMPDU];
  487. struct tasklet_struct tx_pending_tasklet;
  488. /* number of interfaces with corresponding IFF_ flags */
  489. atomic_t iff_allmultis, iff_promiscs;
  490. struct rate_control_ref *rate_ctrl;
  491. int rts_threshold;
  492. int fragmentation_threshold;
  493. int short_retry_limit; /* dot11ShortRetryLimit */
  494. int long_retry_limit; /* dot11LongRetryLimit */
  495. struct crypto_blkcipher *wep_tx_tfm;
  496. struct crypto_blkcipher *wep_rx_tfm;
  497. u32 wep_iv;
  498. int bridge_packets; /* bridge packets between associated stations and
  499. * deliver multicast frames both back to wireless
  500. * media and to the local net stack */
  501. struct list_head interfaces;
  502. bool sta_sw_scanning;
  503. bool sta_hw_scanning;
  504. int scan_channel_idx;
  505. enum ieee80211_band scan_band;
  506. enum { SCAN_SET_CHANNEL, SCAN_SEND_PROBE } scan_state;
  507. unsigned long last_scan_completed;
  508. struct delayed_work scan_work;
  509. struct net_device *scan_dev;
  510. struct ieee80211_channel *oper_channel, *scan_channel;
  511. u8 scan_ssid[IEEE80211_MAX_SSID_LEN];
  512. size_t scan_ssid_len;
  513. struct list_head sta_bss_list;
  514. struct ieee80211_sta_bss *sta_bss_hash[STA_HASH_SIZE];
  515. spinlock_t sta_bss_lock;
  516. /* SNMP counters */
  517. /* dot11CountersTable */
  518. u32 dot11TransmittedFragmentCount;
  519. u32 dot11MulticastTransmittedFrameCount;
  520. u32 dot11FailedCount;
  521. u32 dot11RetryCount;
  522. u32 dot11MultipleRetryCount;
  523. u32 dot11FrameDuplicateCount;
  524. u32 dot11ReceivedFragmentCount;
  525. u32 dot11MulticastReceivedFrameCount;
  526. u32 dot11TransmittedFrameCount;
  527. u32 dot11WEPUndecryptableCount;
  528. #ifdef CONFIG_MAC80211_LEDS
  529. int tx_led_counter, rx_led_counter;
  530. struct led_trigger *tx_led, *rx_led, *assoc_led, *radio_led;
  531. char tx_led_name[32], rx_led_name[32],
  532. assoc_led_name[32], radio_led_name[32];
  533. #endif
  534. u32 channel_use;
  535. u32 channel_use_raw;
  536. #ifdef CONFIG_MAC80211_DEBUGFS
  537. struct work_struct sta_debugfs_add;
  538. #endif
  539. #ifdef CONFIG_MAC80211_DEBUG_COUNTERS
  540. /* TX/RX handler statistics */
  541. unsigned int tx_handlers_drop;
  542. unsigned int tx_handlers_queued;
  543. unsigned int tx_handlers_drop_unencrypted;
  544. unsigned int tx_handlers_drop_fragment;
  545. unsigned int tx_handlers_drop_wep;
  546. unsigned int tx_handlers_drop_not_assoc;
  547. unsigned int tx_handlers_drop_unauth_port;
  548. unsigned int rx_handlers_drop;
  549. unsigned int rx_handlers_queued;
  550. unsigned int rx_handlers_drop_nullfunc;
  551. unsigned int rx_handlers_drop_defrag;
  552. unsigned int rx_handlers_drop_short;
  553. unsigned int rx_handlers_drop_passive_scan;
  554. unsigned int tx_expand_skb_head;
  555. unsigned int tx_expand_skb_head_cloned;
  556. unsigned int rx_expand_skb_head;
  557. unsigned int rx_expand_skb_head2;
  558. unsigned int rx_handlers_fragments;
  559. unsigned int tx_status_drop;
  560. unsigned int wme_rx_queue[NUM_RX_DATA_QUEUES];
  561. unsigned int wme_tx_queue[NUM_RX_DATA_QUEUES];
  562. #define I802_DEBUG_INC(c) (c)++
  563. #else /* CONFIG_MAC80211_DEBUG_COUNTERS */
  564. #define I802_DEBUG_INC(c) do { } while (0)
  565. #endif /* CONFIG_MAC80211_DEBUG_COUNTERS */
  566. int total_ps_buffered; /* total number of all buffered unicast and
  567. * multicast packets for power saving stations
  568. */
  569. int wifi_wme_noack_test;
  570. unsigned int wmm_acm; /* bit field of ACM bits (BIT(802.1D tag)) */
  571. #ifdef CONFIG_MAC80211_DEBUGFS
  572. struct local_debugfsdentries {
  573. struct dentry *frequency;
  574. struct dentry *antenna_sel_tx;
  575. struct dentry *antenna_sel_rx;
  576. struct dentry *bridge_packets;
  577. struct dentry *rts_threshold;
  578. struct dentry *fragmentation_threshold;
  579. struct dentry *short_retry_limit;
  580. struct dentry *long_retry_limit;
  581. struct dentry *total_ps_buffered;
  582. struct dentry *wep_iv;
  583. struct dentry *statistics;
  584. struct local_debugfsdentries_statsdentries {
  585. struct dentry *transmitted_fragment_count;
  586. struct dentry *multicast_transmitted_frame_count;
  587. struct dentry *failed_count;
  588. struct dentry *retry_count;
  589. struct dentry *multiple_retry_count;
  590. struct dentry *frame_duplicate_count;
  591. struct dentry *received_fragment_count;
  592. struct dentry *multicast_received_frame_count;
  593. struct dentry *transmitted_frame_count;
  594. struct dentry *wep_undecryptable_count;
  595. struct dentry *num_scans;
  596. #ifdef CONFIG_MAC80211_DEBUG_COUNTERS
  597. struct dentry *tx_handlers_drop;
  598. struct dentry *tx_handlers_queued;
  599. struct dentry *tx_handlers_drop_unencrypted;
  600. struct dentry *tx_handlers_drop_fragment;
  601. struct dentry *tx_handlers_drop_wep;
  602. struct dentry *tx_handlers_drop_not_assoc;
  603. struct dentry *tx_handlers_drop_unauth_port;
  604. struct dentry *rx_handlers_drop;
  605. struct dentry *rx_handlers_queued;
  606. struct dentry *rx_handlers_drop_nullfunc;
  607. struct dentry *rx_handlers_drop_defrag;
  608. struct dentry *rx_handlers_drop_short;
  609. struct dentry *rx_handlers_drop_passive_scan;
  610. struct dentry *tx_expand_skb_head;
  611. struct dentry *tx_expand_skb_head_cloned;
  612. struct dentry *rx_expand_skb_head;
  613. struct dentry *rx_expand_skb_head2;
  614. struct dentry *rx_handlers_fragments;
  615. struct dentry *tx_status_drop;
  616. struct dentry *wme_tx_queue;
  617. struct dentry *wme_rx_queue;
  618. #endif
  619. struct dentry *dot11ACKFailureCount;
  620. struct dentry *dot11RTSFailureCount;
  621. struct dentry *dot11FCSErrorCount;
  622. struct dentry *dot11RTSSuccessCount;
  623. } stats;
  624. struct dentry *stations;
  625. struct dentry *keys;
  626. } debugfs;
  627. #endif
  628. };
  629. /* this struct represents 802.11n's RA/TID combination */
  630. struct ieee80211_ra_tid {
  631. u8 ra[ETH_ALEN];
  632. u16 tid;
  633. };
  634. /* Parsed Information Elements */
  635. struct ieee802_11_elems {
  636. /* pointers to IEs */
  637. u8 *ssid;
  638. u8 *supp_rates;
  639. u8 *fh_params;
  640. u8 *ds_params;
  641. u8 *cf_params;
  642. u8 *tim;
  643. u8 *ibss_params;
  644. u8 *challenge;
  645. u8 *wpa;
  646. u8 *rsn;
  647. u8 *erp_info;
  648. u8 *ext_supp_rates;
  649. u8 *wmm_info;
  650. u8 *wmm_param;
  651. u8 *ht_cap_elem;
  652. u8 *ht_info_elem;
  653. u8 *mesh_config;
  654. u8 *mesh_id;
  655. u8 *peer_link;
  656. u8 *preq;
  657. u8 *prep;
  658. u8 *perr;
  659. /* length of them, respectively */
  660. u8 ssid_len;
  661. u8 supp_rates_len;
  662. u8 fh_params_len;
  663. u8 ds_params_len;
  664. u8 cf_params_len;
  665. u8 tim_len;
  666. u8 ibss_params_len;
  667. u8 challenge_len;
  668. u8 wpa_len;
  669. u8 rsn_len;
  670. u8 erp_info_len;
  671. u8 ext_supp_rates_len;
  672. u8 wmm_info_len;
  673. u8 wmm_param_len;
  674. u8 ht_cap_elem_len;
  675. u8 ht_info_elem_len;
  676. u8 mesh_config_len;
  677. u8 mesh_id_len;
  678. u8 peer_link_len;
  679. u8 preq_len;
  680. u8 prep_len;
  681. u8 perr_len;
  682. };
  683. static inline struct ieee80211_local *hw_to_local(
  684. struct ieee80211_hw *hw)
  685. {
  686. return container_of(hw, struct ieee80211_local, hw);
  687. }
  688. static inline struct ieee80211_hw *local_to_hw(
  689. struct ieee80211_local *local)
  690. {
  691. return &local->hw;
  692. }
  693. enum ieee80211_link_state_t {
  694. IEEE80211_LINK_STATE_XOFF = 0,
  695. IEEE80211_LINK_STATE_PENDING,
  696. };
  697. struct sta_attribute {
  698. struct attribute attr;
  699. ssize_t (*show)(const struct sta_info *, char *buf);
  700. ssize_t (*store)(struct sta_info *, const char *buf, size_t count);
  701. };
  702. static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr)
  703. {
  704. return compare_ether_addr(raddr, addr) == 0 ||
  705. is_broadcast_ether_addr(raddr);
  706. }
  707. /* ieee80211.c */
  708. int ieee80211_hw_config(struct ieee80211_local *local);
  709. int ieee80211_if_config(struct net_device *dev);
  710. int ieee80211_if_config_beacon(struct net_device *dev);
  711. void ieee80211_tx_set_iswep(struct ieee80211_txrx_data *tx);
  712. int ieee80211_if_update_wds(struct net_device *dev, u8 *remote_addr);
  713. void ieee80211_if_setup(struct net_device *dev);
  714. int ieee80211_hw_config_ht(struct ieee80211_local *local, int enable_ht,
  715. struct ieee80211_ht_info *req_ht_cap,
  716. struct ieee80211_ht_bss_info *req_bss_cap);
  717. /* ieee80211_ioctl.c */
  718. extern const struct iw_handler_def ieee80211_iw_handler_def;
  719. /* Least common multiple of the used rates (in 100 kbps). This is used to
  720. * calculate rate_inv values for each rate so that only integers are needed. */
  721. #define CHAN_UTIL_RATE_LCM 95040
  722. /* 1 usec is 1/8 * (95040/10) = 1188 */
  723. #define CHAN_UTIL_PER_USEC 1188
  724. /* Amount of bits to shift the result right to scale the total utilization
  725. * to values that will not wrap around 32-bit integers. */
  726. #define CHAN_UTIL_SHIFT 9
  727. /* Theoretical maximum of channel utilization counter in 10 ms (stat_time=1):
  728. * (CHAN_UTIL_PER_USEC * 10000) >> CHAN_UTIL_SHIFT = 23203. So dividing the
  729. * raw value with about 23 should give utilization in 10th of a percentage
  730. * (1/1000). However, utilization is only estimated and not all intervals
  731. * between frames etc. are calculated. 18 seems to give numbers that are closer
  732. * to the real maximum. */
  733. #define CHAN_UTIL_PER_10MS 18
  734. #define CHAN_UTIL_HDR_LONG (202 * CHAN_UTIL_PER_USEC)
  735. #define CHAN_UTIL_HDR_SHORT (40 * CHAN_UTIL_PER_USEC)
  736. /* ieee80211_ioctl.c */
  737. int ieee80211_set_compression(struct ieee80211_local *local,
  738. struct net_device *dev, struct sta_info *sta);
  739. int ieee80211_set_freq(struct ieee80211_local *local, int freq);
  740. /* ieee80211_sta.c */
  741. #define IEEE80211_FC(type, stype) cpu_to_le16(type | stype)
  742. void ieee80211_sta_timer(unsigned long data);
  743. void ieee80211_sta_work(struct work_struct *work);
  744. void ieee80211_sta_scan_work(struct work_struct *work);
  745. void ieee80211_sta_rx_mgmt(struct net_device *dev, struct sk_buff *skb,
  746. struct ieee80211_rx_status *rx_status);
  747. int ieee80211_sta_set_ssid(struct net_device *dev, char *ssid, size_t len);
  748. int ieee80211_sta_get_ssid(struct net_device *dev, char *ssid, size_t *len);
  749. int ieee80211_sta_set_bssid(struct net_device *dev, u8 *bssid);
  750. int ieee80211_sta_req_scan(struct net_device *dev, u8 *ssid, size_t ssid_len);
  751. void ieee80211_sta_req_auth(struct net_device *dev,
  752. struct ieee80211_if_sta *ifsta);
  753. int ieee80211_sta_scan_results(struct net_device *dev, char *buf, size_t len);
  754. ieee80211_rx_result ieee80211_sta_rx_scan(
  755. struct net_device *dev, struct sk_buff *skb,
  756. struct ieee80211_rx_status *rx_status);
  757. void ieee80211_rx_bss_list_init(struct net_device *dev);
  758. void ieee80211_rx_bss_list_deinit(struct net_device *dev);
  759. int ieee80211_sta_set_extra_ie(struct net_device *dev, char *ie, size_t len);
  760. struct sta_info * ieee80211_ibss_add_sta(struct net_device *dev,
  761. struct sk_buff *skb, u8 *bssid,
  762. u8 *addr);
  763. int ieee80211_sta_deauthenticate(struct net_device *dev, u16 reason);
  764. int ieee80211_sta_disassociate(struct net_device *dev, u16 reason);
  765. void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
  766. u32 changed);
  767. void ieee80211_reset_erp_info(struct net_device *dev);
  768. int ieee80211_ht_cap_ie_to_ht_info(struct ieee80211_ht_cap *ht_cap_ie,
  769. struct ieee80211_ht_info *ht_info);
  770. int ieee80211_ht_addt_info_ie_to_ht_bss_info(
  771. struct ieee80211_ht_addt_info *ht_add_info_ie,
  772. struct ieee80211_ht_bss_info *bss_info);
  773. void ieee80211_send_addba_request(struct net_device *dev, const u8 *da,
  774. u16 tid, u8 dialog_token, u16 start_seq_num,
  775. u16 agg_size, u16 timeout);
  776. void ieee80211_send_delba(struct net_device *dev, const u8 *da, u16 tid,
  777. u16 initiator, u16 reason_code);
  778. void ieee80211_sta_stop_rx_ba_session(struct net_device *dev, u8 *da,
  779. u16 tid, u16 initiator, u16 reason);
  780. void sta_rx_agg_session_timer_expired(unsigned long data);
  781. void sta_addba_resp_timer_expired(unsigned long data);
  782. u64 ieee80211_sta_get_rates(struct ieee80211_local *local,
  783. struct ieee802_11_elems *elems,
  784. enum ieee80211_band band);
  785. void ieee80211_start_mesh(struct net_device *dev);
  786. void ieee80211_sta_tx(struct net_device *dev, struct sk_buff *skb,
  787. int encrypt);
  788. void ieee802_11_parse_elems(u8 *start, size_t len,
  789. struct ieee802_11_elems *elems);
  790. /* ieee80211_iface.c */
  791. int ieee80211_if_add(struct net_device *dev, const char *name,
  792. struct net_device **new_dev, int type,
  793. struct vif_params *params);
  794. void ieee80211_if_set_type(struct net_device *dev, int type);
  795. void ieee80211_if_reinit(struct net_device *dev);
  796. void __ieee80211_if_del(struct ieee80211_local *local,
  797. struct ieee80211_sub_if_data *sdata);
  798. int ieee80211_if_remove(struct net_device *dev, const char *name, int id);
  799. void ieee80211_if_free(struct net_device *dev);
  800. void ieee80211_if_sdata_init(struct ieee80211_sub_if_data *sdata);
  801. /* tx handling */
  802. void ieee80211_clear_tx_pending(struct ieee80211_local *local);
  803. void ieee80211_tx_pending(unsigned long data);
  804. int ieee80211_master_start_xmit(struct sk_buff *skb, struct net_device *dev);
  805. int ieee80211_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev);
  806. int ieee80211_subif_start_xmit(struct sk_buff *skb, struct net_device *dev);
  807. /* utility functions/constants */
  808. extern void *mac80211_wiphy_privid; /* for wiphy privid */
  809. extern const unsigned char rfc1042_header[6];
  810. extern const unsigned char bridge_tunnel_header[6];
  811. u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len,
  812. enum ieee80211_if_types type);
  813. int ieee80211_frame_duration(struct ieee80211_local *local, size_t len,
  814. int rate, int erp, int short_preamble);
  815. void mac80211_ev_michael_mic_failure(struct net_device *dev, int keyidx,
  816. struct ieee80211_hdr *hdr);
  817. #endif /* IEEE80211_I_H */