ieee80211_i.h 31 KB

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