ieee80211_i.h 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018
  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 18
  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. #define NUM_DEFAULT_MGMT_KEYS 2
  348. struct ieee80211_key *keys[NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS];
  349. struct ieee80211_key *default_key;
  350. struct ieee80211_key *default_mgmt_key;
  351. u16 sequence_number;
  352. /*
  353. * AP this belongs to: self in AP mode and
  354. * corresponding AP in VLAN mode, NULL for
  355. * all others (might be needed later in IBSS)
  356. */
  357. struct ieee80211_if_ap *bss;
  358. int force_unicast_rateidx; /* forced TX rateidx for unicast frames */
  359. int max_ratectrl_rateidx; /* max TX rateidx for rate control */
  360. union {
  361. struct ieee80211_if_ap ap;
  362. struct ieee80211_if_wds wds;
  363. struct ieee80211_if_vlan vlan;
  364. struct ieee80211_if_sta sta;
  365. #ifdef CONFIG_MAC80211_MESH
  366. struct ieee80211_if_mesh mesh;
  367. #endif
  368. u32 mntr_flags;
  369. } u;
  370. #ifdef CONFIG_MAC80211_DEBUGFS
  371. struct dentry *debugfsdir;
  372. union {
  373. struct {
  374. struct dentry *drop_unencrypted;
  375. struct dentry *state;
  376. struct dentry *bssid;
  377. struct dentry *prev_bssid;
  378. struct dentry *ssid_len;
  379. struct dentry *aid;
  380. struct dentry *ap_capab;
  381. struct dentry *capab;
  382. struct dentry *extra_ie_len;
  383. struct dentry *auth_tries;
  384. struct dentry *assoc_tries;
  385. struct dentry *auth_algs;
  386. struct dentry *auth_alg;
  387. struct dentry *auth_transaction;
  388. struct dentry *flags;
  389. struct dentry *force_unicast_rateidx;
  390. struct dentry *max_ratectrl_rateidx;
  391. } sta;
  392. struct {
  393. struct dentry *drop_unencrypted;
  394. struct dentry *num_sta_ps;
  395. struct dentry *dtim_count;
  396. struct dentry *force_unicast_rateidx;
  397. struct dentry *max_ratectrl_rateidx;
  398. struct dentry *num_buffered_multicast;
  399. } ap;
  400. struct {
  401. struct dentry *drop_unencrypted;
  402. struct dentry *peer;
  403. struct dentry *force_unicast_rateidx;
  404. struct dentry *max_ratectrl_rateidx;
  405. } wds;
  406. struct {
  407. struct dentry *drop_unencrypted;
  408. struct dentry *force_unicast_rateidx;
  409. struct dentry *max_ratectrl_rateidx;
  410. } vlan;
  411. struct {
  412. struct dentry *mode;
  413. } monitor;
  414. } debugfs;
  415. struct {
  416. struct dentry *default_key;
  417. struct dentry *default_mgmt_key;
  418. } common_debugfs;
  419. #ifdef CONFIG_MAC80211_MESH
  420. struct dentry *mesh_stats_dir;
  421. struct {
  422. struct dentry *fwded_frames;
  423. struct dentry *dropped_frames_ttl;
  424. struct dentry *dropped_frames_no_route;
  425. struct dentry *estab_plinks;
  426. struct timer_list mesh_path_timer;
  427. } mesh_stats;
  428. struct dentry *mesh_config_dir;
  429. struct {
  430. struct dentry *dot11MeshRetryTimeout;
  431. struct dentry *dot11MeshConfirmTimeout;
  432. struct dentry *dot11MeshHoldingTimeout;
  433. struct dentry *dot11MeshMaxRetries;
  434. struct dentry *dot11MeshTTL;
  435. struct dentry *auto_open_plinks;
  436. struct dentry *dot11MeshMaxPeerLinks;
  437. struct dentry *dot11MeshHWMPactivePathTimeout;
  438. struct dentry *dot11MeshHWMPpreqMinInterval;
  439. struct dentry *dot11MeshHWMPnetDiameterTraversalTime;
  440. struct dentry *dot11MeshHWMPmaxPREQretries;
  441. struct dentry *path_refresh_time;
  442. struct dentry *min_discovery_timeout;
  443. } mesh_config;
  444. #endif
  445. #endif
  446. /* must be last, dynamically sized area in this! */
  447. struct ieee80211_vif vif;
  448. };
  449. static inline
  450. struct ieee80211_sub_if_data *vif_to_sdata(struct ieee80211_vif *p)
  451. {
  452. return container_of(p, struct ieee80211_sub_if_data, vif);
  453. }
  454. static inline void
  455. ieee80211_sdata_set_mesh_id(struct ieee80211_sub_if_data *sdata,
  456. u8 mesh_id_len, u8 *mesh_id)
  457. {
  458. #ifdef CONFIG_MAC80211_MESH
  459. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  460. ifmsh->mesh_id_len = mesh_id_len;
  461. memcpy(ifmsh->mesh_id, mesh_id, mesh_id_len);
  462. #else
  463. WARN_ON(1);
  464. #endif
  465. }
  466. enum {
  467. IEEE80211_RX_MSG = 1,
  468. IEEE80211_TX_STATUS_MSG = 2,
  469. IEEE80211_DELBA_MSG = 3,
  470. IEEE80211_ADDBA_MSG = 4,
  471. };
  472. enum queue_stop_reason {
  473. IEEE80211_QUEUE_STOP_REASON_DRIVER,
  474. IEEE80211_QUEUE_STOP_REASON_PS,
  475. IEEE80211_QUEUE_STOP_REASON_CSA
  476. };
  477. /* maximum number of hardware queues we support. */
  478. #define QD_MAX_QUEUES (IEEE80211_MAX_AMPDU_QUEUES + IEEE80211_MAX_QUEUES)
  479. struct ieee80211_master_priv {
  480. struct ieee80211_local *local;
  481. };
  482. struct ieee80211_local {
  483. /* embed the driver visible part.
  484. * don't cast (use the static inlines below), but we keep
  485. * it first anyway so they become a no-op */
  486. struct ieee80211_hw hw;
  487. const struct ieee80211_ops *ops;
  488. unsigned long queue_pool[BITS_TO_LONGS(QD_MAX_QUEUES)];
  489. unsigned long queue_stop_reasons[IEEE80211_MAX_QUEUES];
  490. spinlock_t queue_stop_reason_lock;
  491. struct net_device *mdev; /* wmaster# - "master" 802.11 device */
  492. int open_count;
  493. int monitors, cooked_mntrs;
  494. /* number of interfaces with corresponding FIF_ flags */
  495. int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss;
  496. unsigned int filter_flags; /* FIF_* */
  497. struct iw_statistics wstats;
  498. u8 wstats_flags;
  499. bool tim_in_locked_section; /* see ieee80211_beacon_get() */
  500. int tx_headroom; /* required headroom for hardware/radiotap */
  501. /* Tasklet and skb queue to process calls from IRQ mode. All frames
  502. * added to skb_queue will be processed, but frames in
  503. * skb_queue_unreliable may be dropped if the total length of these
  504. * queues increases over the limit. */
  505. #define IEEE80211_IRQSAFE_QUEUE_LIMIT 128
  506. struct tasklet_struct tasklet;
  507. struct sk_buff_head skb_queue;
  508. struct sk_buff_head skb_queue_unreliable;
  509. /* Station data */
  510. /*
  511. * The lock only protects the list, hash, timer and counter
  512. * against manipulation, reads are done in RCU. Additionally,
  513. * the lock protects each BSS's TIM bitmap.
  514. */
  515. spinlock_t sta_lock;
  516. unsigned long num_sta;
  517. struct list_head sta_list;
  518. struct list_head sta_flush_list;
  519. struct work_struct sta_flush_work;
  520. struct sta_info *sta_hash[STA_HASH_SIZE];
  521. struct timer_list sta_cleanup;
  522. unsigned long queues_pending[BITS_TO_LONGS(IEEE80211_MAX_QUEUES)];
  523. unsigned long queues_pending_run[BITS_TO_LONGS(IEEE80211_MAX_QUEUES)];
  524. struct ieee80211_tx_stored_packet pending_packet[IEEE80211_MAX_QUEUES];
  525. struct tasklet_struct tx_pending_tasklet;
  526. /* number of interfaces with corresponding IFF_ flags */
  527. atomic_t iff_allmultis, iff_promiscs;
  528. struct rate_control_ref *rate_ctrl;
  529. int rts_threshold;
  530. int fragmentation_threshold;
  531. struct crypto_blkcipher *wep_tx_tfm;
  532. struct crypto_blkcipher *wep_rx_tfm;
  533. u32 wep_iv;
  534. struct list_head interfaces;
  535. /*
  536. * Key lock, protects sdata's key_list and sta_info's
  537. * key pointers (write access, they're RCU.)
  538. */
  539. spinlock_t key_lock;
  540. /* Scanning and BSS list */
  541. bool sw_scanning, hw_scanning;
  542. int scan_channel_idx;
  543. enum ieee80211_band scan_band;
  544. enum { SCAN_SET_CHANNEL, SCAN_SEND_PROBE } scan_state;
  545. unsigned long last_scan_completed;
  546. struct delayed_work scan_work;
  547. struct ieee80211_sub_if_data *scan_sdata;
  548. struct ieee80211_channel *oper_channel, *scan_channel, *csa_channel;
  549. enum nl80211_channel_type oper_channel_type;
  550. u8 scan_ssid[IEEE80211_MAX_SSID_LEN];
  551. size_t scan_ssid_len;
  552. struct list_head bss_list;
  553. struct ieee80211_bss *bss_hash[STA_HASH_SIZE];
  554. spinlock_t bss_lock;
  555. /* SNMP counters */
  556. /* dot11CountersTable */
  557. u32 dot11TransmittedFragmentCount;
  558. u32 dot11MulticastTransmittedFrameCount;
  559. u32 dot11FailedCount;
  560. u32 dot11RetryCount;
  561. u32 dot11MultipleRetryCount;
  562. u32 dot11FrameDuplicateCount;
  563. u32 dot11ReceivedFragmentCount;
  564. u32 dot11MulticastReceivedFrameCount;
  565. u32 dot11TransmittedFrameCount;
  566. #ifdef CONFIG_MAC80211_LEDS
  567. int tx_led_counter, rx_led_counter;
  568. struct led_trigger *tx_led, *rx_led, *assoc_led, *radio_led;
  569. char tx_led_name[32], rx_led_name[32],
  570. assoc_led_name[32], radio_led_name[32];
  571. #endif
  572. #ifdef CONFIG_MAC80211_DEBUGFS
  573. struct work_struct sta_debugfs_add;
  574. #endif
  575. #ifdef CONFIG_MAC80211_DEBUG_COUNTERS
  576. /* TX/RX handler statistics */
  577. unsigned int tx_handlers_drop;
  578. unsigned int tx_handlers_queued;
  579. unsigned int tx_handlers_drop_unencrypted;
  580. unsigned int tx_handlers_drop_fragment;
  581. unsigned int tx_handlers_drop_wep;
  582. unsigned int tx_handlers_drop_not_assoc;
  583. unsigned int tx_handlers_drop_unauth_port;
  584. unsigned int rx_handlers_drop;
  585. unsigned int rx_handlers_queued;
  586. unsigned int rx_handlers_drop_nullfunc;
  587. unsigned int rx_handlers_drop_defrag;
  588. unsigned int rx_handlers_drop_short;
  589. unsigned int rx_handlers_drop_passive_scan;
  590. unsigned int tx_expand_skb_head;
  591. unsigned int tx_expand_skb_head_cloned;
  592. unsigned int rx_expand_skb_head;
  593. unsigned int rx_expand_skb_head2;
  594. unsigned int rx_handlers_fragments;
  595. unsigned int tx_status_drop;
  596. #define I802_DEBUG_INC(c) (c)++
  597. #else /* CONFIG_MAC80211_DEBUG_COUNTERS */
  598. #define I802_DEBUG_INC(c) do { } while (0)
  599. #endif /* CONFIG_MAC80211_DEBUG_COUNTERS */
  600. int total_ps_buffered; /* total number of all buffered unicast and
  601. * multicast packets for power saving stations
  602. */
  603. int wifi_wme_noack_test;
  604. unsigned int wmm_acm; /* bit field of ACM bits (BIT(802.1D tag)) */
  605. bool powersave;
  606. struct work_struct dynamic_ps_enable_work;
  607. struct work_struct dynamic_ps_disable_work;
  608. struct timer_list dynamic_ps_timer;
  609. int user_power_level; /* in dBm */
  610. #ifdef CONFIG_MAC80211_DEBUGFS
  611. struct local_debugfsdentries {
  612. struct dentry *rcdir;
  613. struct dentry *rcname;
  614. struct dentry *frequency;
  615. struct dentry *rts_threshold;
  616. struct dentry *fragmentation_threshold;
  617. struct dentry *short_retry_limit;
  618. struct dentry *long_retry_limit;
  619. struct dentry *total_ps_buffered;
  620. struct dentry *wep_iv;
  621. struct dentry *statistics;
  622. struct local_debugfsdentries_statsdentries {
  623. struct dentry *transmitted_fragment_count;
  624. struct dentry *multicast_transmitted_frame_count;
  625. struct dentry *failed_count;
  626. struct dentry *retry_count;
  627. struct dentry *multiple_retry_count;
  628. struct dentry *frame_duplicate_count;
  629. struct dentry *received_fragment_count;
  630. struct dentry *multicast_received_frame_count;
  631. struct dentry *transmitted_frame_count;
  632. struct dentry *wep_undecryptable_count;
  633. struct dentry *num_scans;
  634. #ifdef CONFIG_MAC80211_DEBUG_COUNTERS
  635. struct dentry *tx_handlers_drop;
  636. struct dentry *tx_handlers_queued;
  637. struct dentry *tx_handlers_drop_unencrypted;
  638. struct dentry *tx_handlers_drop_fragment;
  639. struct dentry *tx_handlers_drop_wep;
  640. struct dentry *tx_handlers_drop_not_assoc;
  641. struct dentry *tx_handlers_drop_unauth_port;
  642. struct dentry *rx_handlers_drop;
  643. struct dentry *rx_handlers_queued;
  644. struct dentry *rx_handlers_drop_nullfunc;
  645. struct dentry *rx_handlers_drop_defrag;
  646. struct dentry *rx_handlers_drop_short;
  647. struct dentry *rx_handlers_drop_passive_scan;
  648. struct dentry *tx_expand_skb_head;
  649. struct dentry *tx_expand_skb_head_cloned;
  650. struct dentry *rx_expand_skb_head;
  651. struct dentry *rx_expand_skb_head2;
  652. struct dentry *rx_handlers_fragments;
  653. struct dentry *tx_status_drop;
  654. #endif
  655. struct dentry *dot11ACKFailureCount;
  656. struct dentry *dot11RTSFailureCount;
  657. struct dentry *dot11FCSErrorCount;
  658. struct dentry *dot11RTSSuccessCount;
  659. } stats;
  660. struct dentry *stations;
  661. struct dentry *keys;
  662. } debugfs;
  663. #endif
  664. };
  665. static inline struct ieee80211_sub_if_data *
  666. IEEE80211_DEV_TO_SUB_IF(struct net_device *dev)
  667. {
  668. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  669. BUG_ON(!local || local->mdev == dev);
  670. return netdev_priv(dev);
  671. }
  672. /* this struct represents 802.11n's RA/TID combination */
  673. struct ieee80211_ra_tid {
  674. u8 ra[ETH_ALEN];
  675. u16 tid;
  676. };
  677. /* Parsed Information Elements */
  678. struct ieee802_11_elems {
  679. u8 *ie_start;
  680. size_t total_len;
  681. /* pointers to IEs */
  682. u8 *ssid;
  683. u8 *supp_rates;
  684. u8 *fh_params;
  685. u8 *ds_params;
  686. u8 *cf_params;
  687. u8 *tim;
  688. u8 *ibss_params;
  689. u8 *challenge;
  690. u8 *wpa;
  691. u8 *rsn;
  692. u8 *erp_info;
  693. u8 *ext_supp_rates;
  694. u8 *wmm_info;
  695. u8 *wmm_param;
  696. struct ieee80211_ht_cap *ht_cap_elem;
  697. struct ieee80211_ht_info *ht_info_elem;
  698. u8 *mesh_config;
  699. u8 *mesh_id;
  700. u8 *peer_link;
  701. u8 *preq;
  702. u8 *prep;
  703. u8 *perr;
  704. u8 *ch_switch_elem;
  705. u8 *country_elem;
  706. u8 *pwr_constr_elem;
  707. u8 *quiet_elem; /* first quite element */
  708. /* length of them, respectively */
  709. u8 ssid_len;
  710. u8 supp_rates_len;
  711. u8 fh_params_len;
  712. u8 ds_params_len;
  713. u8 cf_params_len;
  714. u8 tim_len;
  715. u8 ibss_params_len;
  716. u8 challenge_len;
  717. u8 wpa_len;
  718. u8 rsn_len;
  719. u8 erp_info_len;
  720. u8 ext_supp_rates_len;
  721. u8 wmm_info_len;
  722. u8 wmm_param_len;
  723. u8 mesh_config_len;
  724. u8 mesh_id_len;
  725. u8 peer_link_len;
  726. u8 preq_len;
  727. u8 prep_len;
  728. u8 perr_len;
  729. u8 ch_switch_elem_len;
  730. u8 country_elem_len;
  731. u8 pwr_constr_elem_len;
  732. u8 quiet_elem_len;
  733. u8 num_of_quiet_elem; /* can be more the one */
  734. };
  735. static inline struct ieee80211_local *hw_to_local(
  736. struct ieee80211_hw *hw)
  737. {
  738. return container_of(hw, struct ieee80211_local, hw);
  739. }
  740. static inline struct ieee80211_hw *local_to_hw(
  741. struct ieee80211_local *local)
  742. {
  743. return &local->hw;
  744. }
  745. static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr)
  746. {
  747. return compare_ether_addr(raddr, addr) == 0 ||
  748. is_broadcast_ether_addr(raddr);
  749. }
  750. int ieee80211_hw_config(struct ieee80211_local *local, u32 changed);
  751. int ieee80211_if_config(struct ieee80211_sub_if_data *sdata, u32 changed);
  752. void ieee80211_tx_set_protected(struct ieee80211_tx_data *tx);
  753. void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
  754. u32 changed);
  755. void ieee80211_configure_filter(struct ieee80211_local *local);
  756. /* wireless extensions */
  757. extern const struct iw_handler_def ieee80211_iw_handler_def;
  758. /* STA/IBSS code */
  759. void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata);
  760. void ieee80211_scan_work(struct work_struct *work);
  761. void ieee80211_sta_rx_mgmt(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb,
  762. struct ieee80211_rx_status *rx_status);
  763. int ieee80211_sta_set_ssid(struct ieee80211_sub_if_data *sdata, char *ssid, size_t len);
  764. int ieee80211_sta_get_ssid(struct ieee80211_sub_if_data *sdata, char *ssid, size_t *len);
  765. int ieee80211_sta_set_bssid(struct ieee80211_sub_if_data *sdata, u8 *bssid);
  766. void ieee80211_sta_req_auth(struct ieee80211_sub_if_data *sdata,
  767. struct ieee80211_if_sta *ifsta);
  768. struct sta_info *ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata,
  769. u8 *bssid, u8 *addr, u64 supp_rates);
  770. int ieee80211_sta_deauthenticate(struct ieee80211_sub_if_data *sdata, u16 reason);
  771. int ieee80211_sta_disassociate(struct ieee80211_sub_if_data *sdata, u16 reason);
  772. u32 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata);
  773. u64 ieee80211_sta_get_rates(struct ieee80211_local *local,
  774. struct ieee802_11_elems *elems,
  775. enum ieee80211_band band);
  776. void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst,
  777. u8 *ssid, size_t ssid_len);
  778. /* scan/BSS handling */
  779. int ieee80211_request_scan(struct ieee80211_sub_if_data *sdata,
  780. u8 *ssid, size_t ssid_len);
  781. int ieee80211_scan_results(struct ieee80211_local *local,
  782. struct iw_request_info *info,
  783. char *buf, size_t len);
  784. ieee80211_rx_result
  785. ieee80211_scan_rx(struct ieee80211_sub_if_data *sdata,
  786. struct sk_buff *skb,
  787. struct ieee80211_rx_status *rx_status);
  788. void ieee80211_rx_bss_list_init(struct ieee80211_local *local);
  789. void ieee80211_rx_bss_list_deinit(struct ieee80211_local *local);
  790. int ieee80211_sta_set_extra_ie(struct ieee80211_sub_if_data *sdata,
  791. char *ie, size_t len);
  792. void ieee80211_mlme_notify_scan_completed(struct ieee80211_local *local);
  793. int ieee80211_start_scan(struct ieee80211_sub_if_data *scan_sdata,
  794. u8 *ssid, size_t ssid_len);
  795. struct ieee80211_bss *
  796. ieee80211_bss_info_update(struct ieee80211_local *local,
  797. struct ieee80211_rx_status *rx_status,
  798. struct ieee80211_mgmt *mgmt,
  799. size_t len,
  800. struct ieee802_11_elems *elems,
  801. int freq, bool beacon);
  802. struct ieee80211_bss *
  803. ieee80211_rx_bss_add(struct ieee80211_local *local, u8 *bssid, int freq,
  804. u8 *ssid, u8 ssid_len);
  805. struct ieee80211_bss *
  806. ieee80211_rx_bss_get(struct ieee80211_local *local, u8 *bssid, int freq,
  807. u8 *ssid, u8 ssid_len);
  808. void ieee80211_rx_bss_put(struct ieee80211_local *local,
  809. struct ieee80211_bss *bss);
  810. /* interface handling */
  811. int ieee80211_if_add(struct ieee80211_local *local, const char *name,
  812. struct net_device **new_dev, enum nl80211_iftype type,
  813. struct vif_params *params);
  814. int ieee80211_if_change_type(struct ieee80211_sub_if_data *sdata,
  815. enum nl80211_iftype type);
  816. void ieee80211_if_remove(struct ieee80211_sub_if_data *sdata);
  817. void ieee80211_remove_interfaces(struct ieee80211_local *local);
  818. /* tx handling */
  819. void ieee80211_clear_tx_pending(struct ieee80211_local *local);
  820. void ieee80211_tx_pending(unsigned long data);
  821. int ieee80211_master_start_xmit(struct sk_buff *skb, struct net_device *dev);
  822. int ieee80211_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev);
  823. int ieee80211_subif_start_xmit(struct sk_buff *skb, struct net_device *dev);
  824. /* HT */
  825. void ieee80211_ht_cap_ie_to_sta_ht_cap(struct ieee80211_supported_band *sband,
  826. struct ieee80211_ht_cap *ht_cap_ie,
  827. struct ieee80211_sta_ht_cap *ht_cap);
  828. u32 ieee80211_enable_ht(struct ieee80211_sub_if_data *sdata,
  829. struct ieee80211_ht_info *hti,
  830. u16 ap_ht_cap_flags);
  831. void ieee80211_send_bar(struct ieee80211_sub_if_data *sdata, u8 *ra, u16 tid, u16 ssn);
  832. void ieee80211_sta_stop_rx_ba_session(struct ieee80211_sub_if_data *sdata, u8 *da,
  833. u16 tid, u16 initiator, u16 reason);
  834. void ieee80211_sta_tear_down_BA_sessions(struct ieee80211_sub_if_data *sdata, u8 *addr);
  835. void ieee80211_process_delba(struct ieee80211_sub_if_data *sdata,
  836. struct sta_info *sta,
  837. struct ieee80211_mgmt *mgmt, size_t len);
  838. void ieee80211_process_addba_resp(struct ieee80211_local *local,
  839. struct sta_info *sta,
  840. struct ieee80211_mgmt *mgmt,
  841. size_t len);
  842. void ieee80211_process_addba_request(struct ieee80211_local *local,
  843. struct sta_info *sta,
  844. struct ieee80211_mgmt *mgmt,
  845. size_t len);
  846. /* Spectrum management */
  847. void ieee80211_process_measurement_req(struct ieee80211_sub_if_data *sdata,
  848. struct ieee80211_mgmt *mgmt,
  849. size_t len);
  850. void ieee80211_chswitch_timer(unsigned long data);
  851. void ieee80211_chswitch_work(struct work_struct *work);
  852. void ieee80211_process_chanswitch(struct ieee80211_sub_if_data *sdata,
  853. struct ieee80211_channel_sw_ie *sw_elem,
  854. struct ieee80211_bss *bss);
  855. /* utility functions/constants */
  856. extern void *mac80211_wiphy_privid; /* for wiphy privid */
  857. extern const unsigned char rfc1042_header[6];
  858. extern const unsigned char bridge_tunnel_header[6];
  859. u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len,
  860. enum nl80211_iftype type);
  861. int ieee80211_frame_duration(struct ieee80211_local *local, size_t len,
  862. int rate, int erp, int short_preamble);
  863. void mac80211_ev_michael_mic_failure(struct ieee80211_sub_if_data *sdata, int keyidx,
  864. struct ieee80211_hdr *hdr);
  865. void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata);
  866. void ieee80211_tx_skb(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb,
  867. int encrypt);
  868. void ieee802_11_parse_elems(u8 *start, size_t len,
  869. struct ieee802_11_elems *elems);
  870. int ieee80211_set_freq(struct ieee80211_sub_if_data *sdata, int freq);
  871. u64 ieee80211_mandatory_rates(struct ieee80211_local *local,
  872. enum ieee80211_band band);
  873. void ieee80211_dynamic_ps_enable_work(struct work_struct *work);
  874. void ieee80211_dynamic_ps_disable_work(struct work_struct *work);
  875. void ieee80211_dynamic_ps_timer(unsigned long data);
  876. void ieee80211_send_nullfunc(struct ieee80211_local *local,
  877. struct ieee80211_sub_if_data *sdata,
  878. int powersave);
  879. void ieee80211_wake_queues_by_reason(struct ieee80211_hw *hw,
  880. enum queue_stop_reason reason);
  881. void ieee80211_stop_queues_by_reason(struct ieee80211_hw *hw,
  882. enum queue_stop_reason reason);
  883. #ifdef CONFIG_MAC80211_NOINLINE
  884. #define debug_noinline noinline
  885. #else
  886. #define debug_noinline
  887. #endif
  888. #endif /* IEEE80211_I_H */