ieee80211_i.h 29 KB

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