ieee80211_i.h 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015
  1. /*
  2. * Copyright 2002-2005, Instant802 Networks, Inc.
  3. * Copyright 2005, Devicescape Software, Inc.
  4. * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
  5. * Copyright 2007-2008 Johannes Berg <johannes@sipsolutions.net>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #ifndef IEEE80211_I_H
  12. #define IEEE80211_I_H
  13. #include <linux/kernel.h>
  14. #include <linux/device.h>
  15. #include <linux/if_ether.h>
  16. #include <linux/interrupt.h>
  17. #include <linux/list.h>
  18. #include <linux/netdevice.h>
  19. #include <linux/skbuff.h>
  20. #include <linux/workqueue.h>
  21. #include <linux/types.h>
  22. #include <linux/spinlock.h>
  23. #include <linux/etherdevice.h>
  24. #include <net/cfg80211.h>
  25. #include <net/wireless.h>
  26. #include <net/iw_handler.h>
  27. #include <net/mac80211.h>
  28. #include "key.h"
  29. #include "sta_info.h"
  30. struct ieee80211_local;
  31. /* Maximum number of broadcast/multicast frames to buffer when some of the
  32. * associated stations are using power saving. */
  33. #define AP_MAX_BC_BUFFER 128
  34. /* Maximum number of frames buffered to all STAs, including multicast frames.
  35. * Note: increasing this limit increases the potential memory requirement. Each
  36. * frame can be up to about 2 kB long. */
  37. #define TOTAL_MAX_TX_BUFFER 512
  38. /* Required encryption head and tailroom */
  39. #define IEEE80211_ENCRYPT_HEADROOM 8
  40. #define IEEE80211_ENCRYPT_TAILROOM 12
  41. /* IEEE 802.11 (Ch. 9.5 Defragmentation) requires support for concurrent
  42. * reception of at least three fragmented frames. This limit can be increased
  43. * by changing this define, at the cost of slower frame reassembly and
  44. * increased memory use (about 2 kB of RAM per entry). */
  45. #define IEEE80211_FRAGMENT_MAX 4
  46. /*
  47. * Time after which we ignore scan results and no longer report/use
  48. * them in any way.
  49. */
  50. #define IEEE80211_SCAN_RESULT_EXPIRE (10 * HZ)
  51. struct ieee80211_fragment_entry {
  52. unsigned long first_frag_time;
  53. unsigned int seq;
  54. unsigned int rx_queue;
  55. unsigned int last_frag;
  56. unsigned int extra_len;
  57. struct sk_buff_head skb_list;
  58. int ccmp; /* Whether fragments were encrypted with CCMP */
  59. u8 last_pn[6]; /* PN of the last fragment if CCMP was used */
  60. };
  61. struct ieee80211_bss {
  62. struct list_head list;
  63. struct ieee80211_bss *hnext;
  64. size_t ssid_len;
  65. atomic_t users;
  66. u8 bssid[ETH_ALEN];
  67. u8 ssid[IEEE80211_MAX_SSID_LEN];
  68. u8 dtim_period;
  69. u16 capability; /* host byte order */
  70. enum ieee80211_band band;
  71. int freq;
  72. int signal, noise, qual;
  73. u8 *ies; /* all information elements from the last Beacon or Probe
  74. * Response frames; note Beacon frame is not allowed to
  75. * override values from Probe Response */
  76. size_t ies_len;
  77. bool wmm_used;
  78. #ifdef CONFIG_MAC80211_MESH
  79. u8 *mesh_id;
  80. size_t mesh_id_len;
  81. u8 *mesh_cfg;
  82. #endif
  83. #define IEEE80211_MAX_SUPP_RATES 32
  84. u8 supp_rates[IEEE80211_MAX_SUPP_RATES];
  85. size_t supp_rates_len;
  86. u64 timestamp;
  87. int beacon_int;
  88. unsigned long last_probe_resp;
  89. unsigned long last_update;
  90. /* during assocation, we save an ERP value from a probe response so
  91. * that we can feed ERP info to the driver when handling the
  92. * association completes. these fields probably won't be up-to-date
  93. * otherwise, you probably don't want to use them. */
  94. int has_erp_value;
  95. u8 erp_value;
  96. };
  97. static inline u8 *bss_mesh_cfg(struct ieee80211_bss *bss)
  98. {
  99. #ifdef CONFIG_MAC80211_MESH
  100. return bss->mesh_cfg;
  101. #endif
  102. return NULL;
  103. }
  104. static inline u8 *bss_mesh_id(struct ieee80211_bss *bss)
  105. {
  106. #ifdef CONFIG_MAC80211_MESH
  107. return bss->mesh_id;
  108. #endif
  109. return NULL;
  110. }
  111. static inline u8 bss_mesh_id_len(struct ieee80211_bss *bss)
  112. {
  113. #ifdef CONFIG_MAC80211_MESH
  114. return bss->mesh_id_len;
  115. #endif
  116. return 0;
  117. }
  118. typedef unsigned __bitwise__ ieee80211_tx_result;
  119. #define TX_CONTINUE ((__force ieee80211_tx_result) 0u)
  120. #define TX_DROP ((__force ieee80211_tx_result) 1u)
  121. #define TX_QUEUED ((__force ieee80211_tx_result) 2u)
  122. #define IEEE80211_TX_FRAGMENTED BIT(0)
  123. #define IEEE80211_TX_UNICAST BIT(1)
  124. #define IEEE80211_TX_PS_BUFFERED BIT(2)
  125. struct ieee80211_tx_data {
  126. struct sk_buff *skb;
  127. struct net_device *dev;
  128. struct ieee80211_local *local;
  129. struct ieee80211_sub_if_data *sdata;
  130. struct sta_info *sta;
  131. struct ieee80211_key *key;
  132. struct ieee80211_channel *channel;
  133. /* Extra fragments (in addition to the first fragment
  134. * in skb) */
  135. struct sk_buff **extra_frag;
  136. int num_extra_frag;
  137. u16 ethertype;
  138. unsigned int flags;
  139. };
  140. typedef unsigned __bitwise__ ieee80211_rx_result;
  141. #define RX_CONTINUE ((__force ieee80211_rx_result) 0u)
  142. #define RX_DROP_UNUSABLE ((__force ieee80211_rx_result) 1u)
  143. #define RX_DROP_MONITOR ((__force ieee80211_rx_result) 2u)
  144. #define RX_QUEUED ((__force ieee80211_rx_result) 3u)
  145. #define IEEE80211_RX_IN_SCAN BIT(0)
  146. /* frame is destined to interface currently processed (incl. multicast frames) */
  147. #define IEEE80211_RX_RA_MATCH BIT(1)
  148. #define IEEE80211_RX_AMSDU BIT(2)
  149. #define IEEE80211_RX_CMNTR_REPORTED BIT(3)
  150. #define IEEE80211_RX_FRAGMENTED BIT(4)
  151. struct ieee80211_rx_data {
  152. struct sk_buff *skb;
  153. struct net_device *dev;
  154. struct ieee80211_local *local;
  155. struct ieee80211_sub_if_data *sdata;
  156. struct sta_info *sta;
  157. struct ieee80211_key *key;
  158. struct ieee80211_rx_status *status;
  159. struct ieee80211_rate *rate;
  160. unsigned int flags;
  161. int sent_ps_buffered;
  162. int queue;
  163. u32 tkip_iv32;
  164. u16 tkip_iv16;
  165. };
  166. struct ieee80211_tx_stored_packet {
  167. struct sk_buff *skb;
  168. struct sk_buff **extra_frag;
  169. int num_extra_frag;
  170. };
  171. struct beacon_data {
  172. u8 *head, *tail;
  173. int head_len, tail_len;
  174. int dtim_period;
  175. };
  176. struct ieee80211_if_ap {
  177. struct beacon_data *beacon;
  178. struct list_head vlans;
  179. /* yes, this looks ugly, but guarantees that we can later use
  180. * bitmap_empty :)
  181. * NB: don't touch this bitmap, use sta_info_{set,clear}_tim_bit */
  182. u8 tim[sizeof(unsigned long) * BITS_TO_LONGS(IEEE80211_MAX_AID + 1)];
  183. struct sk_buff_head ps_bc_buf;
  184. atomic_t num_sta_ps; /* number of stations in PS mode */
  185. int dtim_count;
  186. };
  187. struct ieee80211_if_wds {
  188. struct sta_info *sta;
  189. u8 remote_addr[ETH_ALEN];
  190. };
  191. struct ieee80211_if_vlan {
  192. struct list_head list;
  193. };
  194. struct mesh_stats {
  195. __u32 fwded_frames; /* Mesh forwarded frames */
  196. __u32 dropped_frames_ttl; /* Not transmitted since mesh_ttl == 0*/
  197. __u32 dropped_frames_no_route; /* Not transmitted, no route found */
  198. atomic_t estab_plinks;
  199. };
  200. #define PREQ_Q_F_START 0x1
  201. #define PREQ_Q_F_REFRESH 0x2
  202. struct mesh_preq_queue {
  203. struct list_head list;
  204. u8 dst[ETH_ALEN];
  205. u8 flags;
  206. };
  207. /* flags used in struct ieee80211_if_sta.flags */
  208. #define IEEE80211_STA_SSID_SET BIT(0)
  209. #define IEEE80211_STA_BSSID_SET BIT(1)
  210. #define IEEE80211_STA_PREV_BSSID_SET BIT(2)
  211. #define IEEE80211_STA_AUTHENTICATED BIT(3)
  212. #define IEEE80211_STA_ASSOCIATED BIT(4)
  213. #define IEEE80211_STA_PROBEREQ_POLL BIT(5)
  214. #define IEEE80211_STA_CREATE_IBSS BIT(6)
  215. #define IEEE80211_STA_MIXED_CELL BIT(7)
  216. #define IEEE80211_STA_WMM_ENABLED BIT(8)
  217. #define IEEE80211_STA_AUTO_SSID_SEL BIT(10)
  218. #define IEEE80211_STA_AUTO_BSSID_SEL BIT(11)
  219. #define IEEE80211_STA_AUTO_CHANNEL_SEL BIT(12)
  220. #define IEEE80211_STA_PRIVACY_INVOKED BIT(13)
  221. #define IEEE80211_STA_TKIP_WEP_USED BIT(14)
  222. #define IEEE80211_STA_CSA_RECEIVED BIT(15)
  223. #define IEEE80211_STA_MFP_ENABLED BIT(16)
  224. /* flags for MLME request */
  225. #define IEEE80211_STA_REQ_SCAN 0
  226. #define IEEE80211_STA_REQ_DIRECT_PROBE 1
  227. #define IEEE80211_STA_REQ_AUTH 2
  228. #define IEEE80211_STA_REQ_RUN 3
  229. /* STA/IBSS MLME states */
  230. enum ieee80211_sta_mlme_state {
  231. IEEE80211_STA_MLME_DISABLED,
  232. IEEE80211_STA_MLME_DIRECT_PROBE,
  233. IEEE80211_STA_MLME_AUTHENTICATE,
  234. IEEE80211_STA_MLME_ASSOCIATE,
  235. IEEE80211_STA_MLME_ASSOCIATED,
  236. IEEE80211_STA_MLME_IBSS_SEARCH,
  237. IEEE80211_STA_MLME_IBSS_JOINED,
  238. };
  239. /* bitfield of allowed auth algs */
  240. #define IEEE80211_AUTH_ALG_OPEN BIT(0)
  241. #define IEEE80211_AUTH_ALG_SHARED_KEY BIT(1)
  242. #define IEEE80211_AUTH_ALG_LEAP BIT(2)
  243. struct ieee80211_if_sta {
  244. struct timer_list timer;
  245. struct timer_list chswitch_timer;
  246. struct work_struct work;
  247. struct work_struct chswitch_work;
  248. u8 bssid[ETH_ALEN], prev_bssid[ETH_ALEN];
  249. u8 ssid[IEEE80211_MAX_SSID_LEN];
  250. enum ieee80211_sta_mlme_state state;
  251. size_t ssid_len;
  252. u8 scan_ssid[IEEE80211_MAX_SSID_LEN];
  253. size_t scan_ssid_len;
  254. u16 aid;
  255. u16 ap_capab, capab;
  256. u8 *extra_ie; /* to be added to the end of AssocReq */
  257. size_t extra_ie_len;
  258. /* The last AssocReq/Resp IEs */
  259. u8 *assocreq_ies, *assocresp_ies;
  260. size_t assocreq_ies_len, assocresp_ies_len;
  261. struct sk_buff_head skb_queue;
  262. int assoc_scan_tries; /* number of scans done pre-association */
  263. int direct_probe_tries; /* retries for direct probes */
  264. int auth_tries; /* retries for auth req */
  265. int assoc_tries; /* retries for assoc req */
  266. unsigned long request;
  267. unsigned long last_probe;
  268. unsigned int flags;
  269. unsigned int auth_algs; /* bitfield of allowed auth algs */
  270. int auth_alg; /* currently used IEEE 802.11 authentication algorithm */
  271. int auth_transaction;
  272. unsigned long ibss_join_req;
  273. struct sk_buff *probe_resp; /* ProbeResp template for IBSS */
  274. u32 supp_rates_bits[IEEE80211_NUM_BANDS];
  275. int wmm_last_param_set;
  276. };
  277. struct ieee80211_if_mesh {
  278. struct work_struct work;
  279. struct timer_list housekeeping_timer;
  280. struct timer_list mesh_path_timer;
  281. struct sk_buff_head skb_queue;
  282. bool housekeeping;
  283. u8 mesh_id[IEEE80211_MAX_MESH_ID_LEN];
  284. size_t mesh_id_len;
  285. /* Active Path Selection Protocol Identifier */
  286. u8 mesh_pp_id[4];
  287. /* Active Path Selection Metric Identifier */
  288. u8 mesh_pm_id[4];
  289. /* Congestion Control Mode Identifier */
  290. u8 mesh_cc_id[4];
  291. /* Local mesh Destination Sequence Number */
  292. u32 dsn;
  293. /* Last used PREQ ID */
  294. u32 preq_id;
  295. atomic_t mpaths;
  296. /* Timestamp of last DSN update */
  297. unsigned long last_dsn_update;
  298. /* Timestamp of last DSN sent */
  299. unsigned long last_preq;
  300. struct mesh_rmc *rmc;
  301. spinlock_t mesh_preq_queue_lock;
  302. struct mesh_preq_queue preq_queue;
  303. int preq_queue_len;
  304. struct mesh_stats mshstats;
  305. struct mesh_config mshcfg;
  306. u32 mesh_seqnum;
  307. bool accepting_plinks;
  308. };
  309. #ifdef CONFIG_MAC80211_MESH
  310. #define IEEE80211_IFSTA_MESH_CTR_INC(msh, name) \
  311. do { (msh)->mshstats.name++; } while (0)
  312. #else
  313. #define IEEE80211_IFSTA_MESH_CTR_INC(msh, name) \
  314. do { } while (0)
  315. #endif
  316. /**
  317. * enum ieee80211_sub_if_data_flags - virtual interface flags
  318. *
  319. * @IEEE80211_SDATA_ALLMULTI: interface wants all multicast packets
  320. * @IEEE80211_SDATA_PROMISC: interface is promisc
  321. * @IEEE80211_SDATA_USERSPACE_MLME: userspace MLME is active
  322. * @IEEE80211_SDATA_OPERATING_GMODE: operating in G-only mode
  323. * @IEEE80211_SDATA_DONT_BRIDGE_PACKETS: bridge packets between
  324. * associated stations and deliver multicast frames both
  325. * back to wireless media and to the local net stack.
  326. */
  327. enum ieee80211_sub_if_data_flags {
  328. IEEE80211_SDATA_ALLMULTI = BIT(0),
  329. IEEE80211_SDATA_PROMISC = BIT(1),
  330. IEEE80211_SDATA_USERSPACE_MLME = BIT(2),
  331. IEEE80211_SDATA_OPERATING_GMODE = BIT(3),
  332. IEEE80211_SDATA_DONT_BRIDGE_PACKETS = BIT(4),
  333. };
  334. struct ieee80211_sub_if_data {
  335. struct list_head list;
  336. struct wireless_dev wdev;
  337. /* keys */
  338. struct list_head key_list;
  339. struct net_device *dev;
  340. struct ieee80211_local *local;
  341. unsigned int flags;
  342. int drop_unencrypted;
  343. /* Fragment table for host-based reassembly */
  344. struct ieee80211_fragment_entry fragments[IEEE80211_FRAGMENT_MAX];
  345. unsigned int fragment_next;
  346. #define NUM_DEFAULT_KEYS 4
  347. struct ieee80211_key *keys[NUM_DEFAULT_KEYS];
  348. struct ieee80211_key *default_key;
  349. u16 sequence_number;
  350. /*
  351. * AP this belongs to: self in AP mode and
  352. * corresponding AP in VLAN mode, NULL for
  353. * all others (might be needed later in IBSS)
  354. */
  355. struct ieee80211_if_ap *bss;
  356. int force_unicast_rateidx; /* forced TX rateidx for unicast frames */
  357. int max_ratectrl_rateidx; /* max TX rateidx for rate control */
  358. union {
  359. struct ieee80211_if_ap ap;
  360. struct ieee80211_if_wds wds;
  361. struct ieee80211_if_vlan vlan;
  362. struct ieee80211_if_sta sta;
  363. #ifdef CONFIG_MAC80211_MESH
  364. struct ieee80211_if_mesh mesh;
  365. #endif
  366. u32 mntr_flags;
  367. } u;
  368. #ifdef CONFIG_MAC80211_DEBUGFS
  369. struct dentry *debugfsdir;
  370. union {
  371. struct {
  372. struct dentry *drop_unencrypted;
  373. struct dentry *state;
  374. struct dentry *bssid;
  375. struct dentry *prev_bssid;
  376. struct dentry *ssid_len;
  377. struct dentry *aid;
  378. struct dentry *ap_capab;
  379. struct dentry *capab;
  380. struct dentry *extra_ie_len;
  381. struct dentry *auth_tries;
  382. struct dentry *assoc_tries;
  383. struct dentry *auth_algs;
  384. struct dentry *auth_alg;
  385. struct dentry *auth_transaction;
  386. struct dentry *flags;
  387. struct dentry *force_unicast_rateidx;
  388. struct dentry *max_ratectrl_rateidx;
  389. } sta;
  390. struct {
  391. struct dentry *drop_unencrypted;
  392. struct dentry *num_sta_ps;
  393. struct dentry *dtim_count;
  394. struct dentry *force_unicast_rateidx;
  395. struct dentry *max_ratectrl_rateidx;
  396. struct dentry *num_buffered_multicast;
  397. } ap;
  398. struct {
  399. struct dentry *drop_unencrypted;
  400. struct dentry *peer;
  401. struct dentry *force_unicast_rateidx;
  402. struct dentry *max_ratectrl_rateidx;
  403. } wds;
  404. struct {
  405. struct dentry *drop_unencrypted;
  406. struct dentry *force_unicast_rateidx;
  407. struct dentry *max_ratectrl_rateidx;
  408. } vlan;
  409. struct {
  410. struct dentry *mode;
  411. } monitor;
  412. } debugfs;
  413. struct {
  414. struct dentry *default_key;
  415. } common_debugfs;
  416. #ifdef CONFIG_MAC80211_MESH
  417. struct dentry *mesh_stats_dir;
  418. struct {
  419. struct dentry *fwded_frames;
  420. struct dentry *dropped_frames_ttl;
  421. struct dentry *dropped_frames_no_route;
  422. struct dentry *estab_plinks;
  423. struct timer_list mesh_path_timer;
  424. } mesh_stats;
  425. struct dentry *mesh_config_dir;
  426. struct {
  427. struct dentry *dot11MeshRetryTimeout;
  428. struct dentry *dot11MeshConfirmTimeout;
  429. struct dentry *dot11MeshHoldingTimeout;
  430. struct dentry *dot11MeshMaxRetries;
  431. struct dentry *dot11MeshTTL;
  432. struct dentry *auto_open_plinks;
  433. struct dentry *dot11MeshMaxPeerLinks;
  434. struct dentry *dot11MeshHWMPactivePathTimeout;
  435. struct dentry *dot11MeshHWMPpreqMinInterval;
  436. struct dentry *dot11MeshHWMPnetDiameterTraversalTime;
  437. struct dentry *dot11MeshHWMPmaxPREQretries;
  438. struct dentry *path_refresh_time;
  439. struct dentry *min_discovery_timeout;
  440. } mesh_config;
  441. #endif
  442. #endif
  443. /* must be last, dynamically sized area in this! */
  444. struct ieee80211_vif vif;
  445. };
  446. static inline
  447. struct ieee80211_sub_if_data *vif_to_sdata(struct ieee80211_vif *p)
  448. {
  449. return container_of(p, struct ieee80211_sub_if_data, vif);
  450. }
  451. static inline void
  452. ieee80211_sdata_set_mesh_id(struct ieee80211_sub_if_data *sdata,
  453. u8 mesh_id_len, u8 *mesh_id)
  454. {
  455. #ifdef CONFIG_MAC80211_MESH
  456. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  457. ifmsh->mesh_id_len = mesh_id_len;
  458. memcpy(ifmsh->mesh_id, mesh_id, mesh_id_len);
  459. #else
  460. WARN_ON(1);
  461. #endif
  462. }
  463. enum {
  464. IEEE80211_RX_MSG = 1,
  465. IEEE80211_TX_STATUS_MSG = 2,
  466. IEEE80211_DELBA_MSG = 3,
  467. IEEE80211_ADDBA_MSG = 4,
  468. };
  469. enum queue_stop_reason {
  470. IEEE80211_QUEUE_STOP_REASON_DRIVER,
  471. IEEE80211_QUEUE_STOP_REASON_PS,
  472. IEEE80211_QUEUE_STOP_REASON_CSA
  473. };
  474. /* maximum number of hardware queues we support. */
  475. #define QD_MAX_QUEUES (IEEE80211_MAX_AMPDU_QUEUES + IEEE80211_MAX_QUEUES)
  476. struct ieee80211_master_priv {
  477. struct ieee80211_local *local;
  478. };
  479. struct ieee80211_local {
  480. /* embed the driver visible part.
  481. * don't cast (use the static inlines below), but we keep
  482. * it first anyway so they become a no-op */
  483. struct ieee80211_hw hw;
  484. const struct ieee80211_ops *ops;
  485. unsigned long queue_pool[BITS_TO_LONGS(QD_MAX_QUEUES)];
  486. unsigned long queue_stop_reasons[IEEE80211_MAX_QUEUES];
  487. spinlock_t queue_stop_reason_lock;
  488. struct net_device *mdev; /* wmaster# - "master" 802.11 device */
  489. int open_count;
  490. int monitors, cooked_mntrs;
  491. /* number of interfaces with corresponding FIF_ flags */
  492. int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss;
  493. unsigned int filter_flags; /* FIF_* */
  494. struct iw_statistics wstats;
  495. u8 wstats_flags;
  496. bool tim_in_locked_section; /* see ieee80211_beacon_get() */
  497. int tx_headroom; /* required headroom for hardware/radiotap */
  498. /* Tasklet and skb queue to process calls from IRQ mode. All frames
  499. * added to skb_queue will be processed, but frames in
  500. * skb_queue_unreliable may be dropped if the total length of these
  501. * queues increases over the limit. */
  502. #define IEEE80211_IRQSAFE_QUEUE_LIMIT 128
  503. struct tasklet_struct tasklet;
  504. struct sk_buff_head skb_queue;
  505. struct sk_buff_head skb_queue_unreliable;
  506. /* Station data */
  507. /*
  508. * The lock only protects the list, hash, timer and counter
  509. * against manipulation, reads are done in RCU. Additionally,
  510. * the lock protects each BSS's TIM bitmap.
  511. */
  512. spinlock_t sta_lock;
  513. unsigned long num_sta;
  514. struct list_head sta_list;
  515. struct list_head sta_flush_list;
  516. struct work_struct sta_flush_work;
  517. struct sta_info *sta_hash[STA_HASH_SIZE];
  518. struct timer_list sta_cleanup;
  519. unsigned long queues_pending[BITS_TO_LONGS(IEEE80211_MAX_QUEUES)];
  520. unsigned long queues_pending_run[BITS_TO_LONGS(IEEE80211_MAX_QUEUES)];
  521. struct ieee80211_tx_stored_packet pending_packet[IEEE80211_MAX_QUEUES];
  522. struct tasklet_struct tx_pending_tasklet;
  523. /* number of interfaces with corresponding IFF_ flags */
  524. atomic_t iff_allmultis, iff_promiscs;
  525. struct rate_control_ref *rate_ctrl;
  526. int rts_threshold;
  527. int fragmentation_threshold;
  528. struct crypto_blkcipher *wep_tx_tfm;
  529. struct crypto_blkcipher *wep_rx_tfm;
  530. u32 wep_iv;
  531. struct list_head interfaces;
  532. /*
  533. * Key lock, protects sdata's key_list and sta_info's
  534. * key pointers (write access, they're RCU.)
  535. */
  536. spinlock_t key_lock;
  537. /* Scanning and BSS list */
  538. bool sw_scanning, hw_scanning;
  539. int scan_channel_idx;
  540. enum ieee80211_band scan_band;
  541. enum { SCAN_SET_CHANNEL, SCAN_SEND_PROBE } scan_state;
  542. unsigned long last_scan_completed;
  543. struct delayed_work scan_work;
  544. struct ieee80211_sub_if_data *scan_sdata;
  545. struct ieee80211_channel *oper_channel, *scan_channel, *csa_channel;
  546. enum nl80211_channel_type oper_channel_type;
  547. u8 scan_ssid[IEEE80211_MAX_SSID_LEN];
  548. size_t scan_ssid_len;
  549. struct list_head bss_list;
  550. struct ieee80211_bss *bss_hash[STA_HASH_SIZE];
  551. spinlock_t bss_lock;
  552. /* SNMP counters */
  553. /* dot11CountersTable */
  554. u32 dot11TransmittedFragmentCount;
  555. u32 dot11MulticastTransmittedFrameCount;
  556. u32 dot11FailedCount;
  557. u32 dot11RetryCount;
  558. u32 dot11MultipleRetryCount;
  559. u32 dot11FrameDuplicateCount;
  560. u32 dot11ReceivedFragmentCount;
  561. u32 dot11MulticastReceivedFrameCount;
  562. u32 dot11TransmittedFrameCount;
  563. #ifdef CONFIG_MAC80211_LEDS
  564. int tx_led_counter, rx_led_counter;
  565. struct led_trigger *tx_led, *rx_led, *assoc_led, *radio_led;
  566. char tx_led_name[32], rx_led_name[32],
  567. assoc_led_name[32], radio_led_name[32];
  568. #endif
  569. #ifdef CONFIG_MAC80211_DEBUGFS
  570. struct work_struct sta_debugfs_add;
  571. #endif
  572. #ifdef CONFIG_MAC80211_DEBUG_COUNTERS
  573. /* TX/RX handler statistics */
  574. unsigned int tx_handlers_drop;
  575. unsigned int tx_handlers_queued;
  576. unsigned int tx_handlers_drop_unencrypted;
  577. unsigned int tx_handlers_drop_fragment;
  578. unsigned int tx_handlers_drop_wep;
  579. unsigned int tx_handlers_drop_not_assoc;
  580. unsigned int tx_handlers_drop_unauth_port;
  581. unsigned int rx_handlers_drop;
  582. unsigned int rx_handlers_queued;
  583. unsigned int rx_handlers_drop_nullfunc;
  584. unsigned int rx_handlers_drop_defrag;
  585. unsigned int rx_handlers_drop_short;
  586. unsigned int rx_handlers_drop_passive_scan;
  587. unsigned int tx_expand_skb_head;
  588. unsigned int tx_expand_skb_head_cloned;
  589. unsigned int rx_expand_skb_head;
  590. unsigned int rx_expand_skb_head2;
  591. unsigned int rx_handlers_fragments;
  592. unsigned int tx_status_drop;
  593. #define I802_DEBUG_INC(c) (c)++
  594. #else /* CONFIG_MAC80211_DEBUG_COUNTERS */
  595. #define I802_DEBUG_INC(c) do { } while (0)
  596. #endif /* CONFIG_MAC80211_DEBUG_COUNTERS */
  597. int total_ps_buffered; /* total number of all buffered unicast and
  598. * multicast packets for power saving stations
  599. */
  600. int wifi_wme_noack_test;
  601. unsigned int wmm_acm; /* bit field of ACM bits (BIT(802.1D tag)) */
  602. bool powersave;
  603. struct work_struct dynamic_ps_enable_work;
  604. struct work_struct dynamic_ps_disable_work;
  605. struct timer_list dynamic_ps_timer;
  606. int user_power_level; /* in dBm */
  607. #ifdef CONFIG_MAC80211_DEBUGFS
  608. struct local_debugfsdentries {
  609. struct dentry *rcdir;
  610. struct dentry *rcname;
  611. struct dentry *frequency;
  612. struct dentry *rts_threshold;
  613. struct dentry *fragmentation_threshold;
  614. struct dentry *short_retry_limit;
  615. struct dentry *long_retry_limit;
  616. struct dentry *total_ps_buffered;
  617. struct dentry *wep_iv;
  618. struct dentry *statistics;
  619. struct local_debugfsdentries_statsdentries {
  620. struct dentry *transmitted_fragment_count;
  621. struct dentry *multicast_transmitted_frame_count;
  622. struct dentry *failed_count;
  623. struct dentry *retry_count;
  624. struct dentry *multiple_retry_count;
  625. struct dentry *frame_duplicate_count;
  626. struct dentry *received_fragment_count;
  627. struct dentry *multicast_received_frame_count;
  628. struct dentry *transmitted_frame_count;
  629. struct dentry *wep_undecryptable_count;
  630. struct dentry *num_scans;
  631. #ifdef CONFIG_MAC80211_DEBUG_COUNTERS
  632. struct dentry *tx_handlers_drop;
  633. struct dentry *tx_handlers_queued;
  634. struct dentry *tx_handlers_drop_unencrypted;
  635. struct dentry *tx_handlers_drop_fragment;
  636. struct dentry *tx_handlers_drop_wep;
  637. struct dentry *tx_handlers_drop_not_assoc;
  638. struct dentry *tx_handlers_drop_unauth_port;
  639. struct dentry *rx_handlers_drop;
  640. struct dentry *rx_handlers_queued;
  641. struct dentry *rx_handlers_drop_nullfunc;
  642. struct dentry *rx_handlers_drop_defrag;
  643. struct dentry *rx_handlers_drop_short;
  644. struct dentry *rx_handlers_drop_passive_scan;
  645. struct dentry *tx_expand_skb_head;
  646. struct dentry *tx_expand_skb_head_cloned;
  647. struct dentry *rx_expand_skb_head;
  648. struct dentry *rx_expand_skb_head2;
  649. struct dentry *rx_handlers_fragments;
  650. struct dentry *tx_status_drop;
  651. #endif
  652. struct dentry *dot11ACKFailureCount;
  653. struct dentry *dot11RTSFailureCount;
  654. struct dentry *dot11FCSErrorCount;
  655. struct dentry *dot11RTSSuccessCount;
  656. } stats;
  657. struct dentry *stations;
  658. struct dentry *keys;
  659. } debugfs;
  660. #endif
  661. };
  662. static inline struct ieee80211_sub_if_data *
  663. IEEE80211_DEV_TO_SUB_IF(struct net_device *dev)
  664. {
  665. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  666. BUG_ON(!local || local->mdev == dev);
  667. return netdev_priv(dev);
  668. }
  669. /* this struct represents 802.11n's RA/TID combination */
  670. struct ieee80211_ra_tid {
  671. u8 ra[ETH_ALEN];
  672. u16 tid;
  673. };
  674. /* Parsed Information Elements */
  675. struct ieee802_11_elems {
  676. u8 *ie_start;
  677. size_t total_len;
  678. /* pointers to IEs */
  679. u8 *ssid;
  680. u8 *supp_rates;
  681. u8 *fh_params;
  682. u8 *ds_params;
  683. u8 *cf_params;
  684. u8 *tim;
  685. u8 *ibss_params;
  686. u8 *challenge;
  687. u8 *wpa;
  688. u8 *rsn;
  689. u8 *erp_info;
  690. u8 *ext_supp_rates;
  691. u8 *wmm_info;
  692. u8 *wmm_param;
  693. struct ieee80211_ht_cap *ht_cap_elem;
  694. struct ieee80211_ht_info *ht_info_elem;
  695. u8 *mesh_config;
  696. u8 *mesh_id;
  697. u8 *peer_link;
  698. u8 *preq;
  699. u8 *prep;
  700. u8 *perr;
  701. u8 *ch_switch_elem;
  702. u8 *country_elem;
  703. u8 *pwr_constr_elem;
  704. u8 *quiet_elem; /* first quite element */
  705. /* length of them, respectively */
  706. u8 ssid_len;
  707. u8 supp_rates_len;
  708. u8 fh_params_len;
  709. u8 ds_params_len;
  710. u8 cf_params_len;
  711. u8 tim_len;
  712. u8 ibss_params_len;
  713. u8 challenge_len;
  714. u8 wpa_len;
  715. u8 rsn_len;
  716. u8 erp_info_len;
  717. u8 ext_supp_rates_len;
  718. u8 wmm_info_len;
  719. u8 wmm_param_len;
  720. u8 mesh_config_len;
  721. u8 mesh_id_len;
  722. u8 peer_link_len;
  723. u8 preq_len;
  724. u8 prep_len;
  725. u8 perr_len;
  726. u8 ch_switch_elem_len;
  727. u8 country_elem_len;
  728. u8 pwr_constr_elem_len;
  729. u8 quiet_elem_len;
  730. u8 num_of_quiet_elem; /* can be more the one */
  731. };
  732. static inline struct ieee80211_local *hw_to_local(
  733. struct ieee80211_hw *hw)
  734. {
  735. return container_of(hw, struct ieee80211_local, hw);
  736. }
  737. static inline struct ieee80211_hw *local_to_hw(
  738. struct ieee80211_local *local)
  739. {
  740. return &local->hw;
  741. }
  742. static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr)
  743. {
  744. return compare_ether_addr(raddr, addr) == 0 ||
  745. is_broadcast_ether_addr(raddr);
  746. }
  747. int ieee80211_hw_config(struct ieee80211_local *local, u32 changed);
  748. int ieee80211_if_config(struct ieee80211_sub_if_data *sdata, u32 changed);
  749. void ieee80211_tx_set_protected(struct ieee80211_tx_data *tx);
  750. void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
  751. u32 changed);
  752. void ieee80211_configure_filter(struct ieee80211_local *local);
  753. /* wireless extensions */
  754. extern const struct iw_handler_def ieee80211_iw_handler_def;
  755. /* STA/IBSS code */
  756. void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata);
  757. void ieee80211_scan_work(struct work_struct *work);
  758. void ieee80211_sta_rx_mgmt(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb,
  759. struct ieee80211_rx_status *rx_status);
  760. int ieee80211_sta_set_ssid(struct ieee80211_sub_if_data *sdata, char *ssid, size_t len);
  761. int ieee80211_sta_get_ssid(struct ieee80211_sub_if_data *sdata, char *ssid, size_t *len);
  762. int ieee80211_sta_set_bssid(struct ieee80211_sub_if_data *sdata, u8 *bssid);
  763. void ieee80211_sta_req_auth(struct ieee80211_sub_if_data *sdata,
  764. struct ieee80211_if_sta *ifsta);
  765. struct sta_info *ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata,
  766. u8 *bssid, u8 *addr, u64 supp_rates);
  767. int ieee80211_sta_deauthenticate(struct ieee80211_sub_if_data *sdata, u16 reason);
  768. int ieee80211_sta_disassociate(struct ieee80211_sub_if_data *sdata, u16 reason);
  769. u32 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata);
  770. u64 ieee80211_sta_get_rates(struct ieee80211_local *local,
  771. struct ieee802_11_elems *elems,
  772. enum ieee80211_band band);
  773. void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst,
  774. u8 *ssid, size_t ssid_len);
  775. /* scan/BSS handling */
  776. int ieee80211_request_scan(struct ieee80211_sub_if_data *sdata,
  777. u8 *ssid, size_t ssid_len);
  778. int ieee80211_scan_results(struct ieee80211_local *local,
  779. struct iw_request_info *info,
  780. char *buf, size_t len);
  781. ieee80211_rx_result
  782. ieee80211_scan_rx(struct ieee80211_sub_if_data *sdata,
  783. struct sk_buff *skb,
  784. struct ieee80211_rx_status *rx_status);
  785. void ieee80211_rx_bss_list_init(struct ieee80211_local *local);
  786. void ieee80211_rx_bss_list_deinit(struct ieee80211_local *local);
  787. int ieee80211_sta_set_extra_ie(struct ieee80211_sub_if_data *sdata,
  788. char *ie, size_t len);
  789. void ieee80211_mlme_notify_scan_completed(struct ieee80211_local *local);
  790. int ieee80211_start_scan(struct ieee80211_sub_if_data *scan_sdata,
  791. u8 *ssid, size_t ssid_len);
  792. struct ieee80211_bss *
  793. ieee80211_bss_info_update(struct ieee80211_local *local,
  794. struct ieee80211_rx_status *rx_status,
  795. struct ieee80211_mgmt *mgmt,
  796. size_t len,
  797. struct ieee802_11_elems *elems,
  798. int freq, bool beacon);
  799. struct ieee80211_bss *
  800. ieee80211_rx_bss_add(struct ieee80211_local *local, u8 *bssid, int freq,
  801. u8 *ssid, u8 ssid_len);
  802. struct ieee80211_bss *
  803. ieee80211_rx_bss_get(struct ieee80211_local *local, u8 *bssid, int freq,
  804. u8 *ssid, u8 ssid_len);
  805. void ieee80211_rx_bss_put(struct ieee80211_local *local,
  806. struct ieee80211_bss *bss);
  807. /* interface handling */
  808. int ieee80211_if_add(struct ieee80211_local *local, const char *name,
  809. struct net_device **new_dev, enum nl80211_iftype type,
  810. struct vif_params *params);
  811. int ieee80211_if_change_type(struct ieee80211_sub_if_data *sdata,
  812. enum nl80211_iftype type);
  813. void ieee80211_if_remove(struct ieee80211_sub_if_data *sdata);
  814. void ieee80211_remove_interfaces(struct ieee80211_local *local);
  815. /* tx handling */
  816. void ieee80211_clear_tx_pending(struct ieee80211_local *local);
  817. void ieee80211_tx_pending(unsigned long data);
  818. int ieee80211_master_start_xmit(struct sk_buff *skb, struct net_device *dev);
  819. int ieee80211_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev);
  820. int ieee80211_subif_start_xmit(struct sk_buff *skb, struct net_device *dev);
  821. /* HT */
  822. void ieee80211_ht_cap_ie_to_sta_ht_cap(struct ieee80211_supported_band *sband,
  823. struct ieee80211_ht_cap *ht_cap_ie,
  824. struct ieee80211_sta_ht_cap *ht_cap);
  825. u32 ieee80211_enable_ht(struct ieee80211_sub_if_data *sdata,
  826. struct ieee80211_ht_info *hti,
  827. u16 ap_ht_cap_flags);
  828. void ieee80211_send_bar(struct ieee80211_sub_if_data *sdata, u8 *ra, u16 tid, u16 ssn);
  829. void ieee80211_sta_stop_rx_ba_session(struct ieee80211_sub_if_data *sdata, u8 *da,
  830. u16 tid, u16 initiator, u16 reason);
  831. void ieee80211_sta_tear_down_BA_sessions(struct ieee80211_sub_if_data *sdata, u8 *addr);
  832. void ieee80211_process_delba(struct ieee80211_sub_if_data *sdata,
  833. struct sta_info *sta,
  834. struct ieee80211_mgmt *mgmt, size_t len);
  835. void ieee80211_process_addba_resp(struct ieee80211_local *local,
  836. struct sta_info *sta,
  837. struct ieee80211_mgmt *mgmt,
  838. size_t len);
  839. void ieee80211_process_addba_request(struct ieee80211_local *local,
  840. struct sta_info *sta,
  841. struct ieee80211_mgmt *mgmt,
  842. size_t len);
  843. /* Spectrum management */
  844. void ieee80211_process_measurement_req(struct ieee80211_sub_if_data *sdata,
  845. struct ieee80211_mgmt *mgmt,
  846. size_t len);
  847. void ieee80211_chswitch_timer(unsigned long data);
  848. void ieee80211_chswitch_work(struct work_struct *work);
  849. void ieee80211_process_chanswitch(struct ieee80211_sub_if_data *sdata,
  850. struct ieee80211_channel_sw_ie *sw_elem,
  851. struct ieee80211_bss *bss);
  852. /* utility functions/constants */
  853. extern void *mac80211_wiphy_privid; /* for wiphy privid */
  854. extern const unsigned char rfc1042_header[6];
  855. extern const unsigned char bridge_tunnel_header[6];
  856. u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len,
  857. enum nl80211_iftype type);
  858. int ieee80211_frame_duration(struct ieee80211_local *local, size_t len,
  859. int rate, int erp, int short_preamble);
  860. void mac80211_ev_michael_mic_failure(struct ieee80211_sub_if_data *sdata, int keyidx,
  861. struct ieee80211_hdr *hdr);
  862. void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata);
  863. void ieee80211_tx_skb(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb,
  864. int encrypt);
  865. void ieee802_11_parse_elems(u8 *start, size_t len,
  866. struct ieee802_11_elems *elems);
  867. int ieee80211_set_freq(struct ieee80211_sub_if_data *sdata, int freq);
  868. u64 ieee80211_mandatory_rates(struct ieee80211_local *local,
  869. enum ieee80211_band band);
  870. void ieee80211_dynamic_ps_enable_work(struct work_struct *work);
  871. void ieee80211_dynamic_ps_disable_work(struct work_struct *work);
  872. void ieee80211_dynamic_ps_timer(unsigned long data);
  873. void ieee80211_send_nullfunc(struct ieee80211_local *local,
  874. struct ieee80211_sub_if_data *sdata,
  875. int powersave);
  876. void ieee80211_wake_queues_by_reason(struct ieee80211_hw *hw,
  877. enum queue_stop_reason reason);
  878. void ieee80211_stop_queues_by_reason(struct ieee80211_hw *hw,
  879. enum queue_stop_reason reason);
  880. #ifdef CONFIG_MAC80211_NOINLINE
  881. #define debug_noinline noinline
  882. #else
  883. #define debug_noinline
  884. #endif
  885. #endif /* IEEE80211_I_H */