ieee80211_i.h 65 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077
  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-2010 Johannes Berg <johannes@sipsolutions.net>
  6. * Copyright 2013-2014 Intel Mobile Communications GmbH
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #ifndef IEEE80211_I_H
  13. #define IEEE80211_I_H
  14. #include <linux/kernel.h>
  15. #include <linux/device.h>
  16. #include <linux/if_ether.h>
  17. #include <linux/interrupt.h>
  18. #include <linux/list.h>
  19. #include <linux/netdevice.h>
  20. #include <linux/skbuff.h>
  21. #include <linux/workqueue.h>
  22. #include <linux/types.h>
  23. #include <linux/spinlock.h>
  24. #include <linux/etherdevice.h>
  25. #include <linux/leds.h>
  26. #include <linux/idr.h>
  27. #include <linux/rhashtable.h>
  28. #include <net/ieee80211_radiotap.h>
  29. #include <net/cfg80211.h>
  30. #include <net/mac80211.h>
  31. #include "key.h"
  32. #include "sta_info.h"
  33. #include "debug.h"
  34. struct ieee80211_local;
  35. /* Maximum number of broadcast/multicast frames to buffer when some of the
  36. * associated stations are using power saving. */
  37. #define AP_MAX_BC_BUFFER 128
  38. /* Maximum number of frames buffered to all STAs, including multicast frames.
  39. * Note: increasing this limit increases the potential memory requirement. Each
  40. * frame can be up to about 2 kB long. */
  41. #define TOTAL_MAX_TX_BUFFER 512
  42. /* Required encryption head and tailroom */
  43. #define IEEE80211_ENCRYPT_HEADROOM 8
  44. #define IEEE80211_ENCRYPT_TAILROOM 18
  45. /* IEEE 802.11 (Ch. 9.5 Defragmentation) requires support for concurrent
  46. * reception of at least three fragmented frames. This limit can be increased
  47. * by changing this define, at the cost of slower frame reassembly and
  48. * increased memory use (about 2 kB of RAM per entry). */
  49. #define IEEE80211_FRAGMENT_MAX 4
  50. /* power level hasn't been configured (or set to automatic) */
  51. #define IEEE80211_UNSET_POWER_LEVEL INT_MIN
  52. /*
  53. * Some APs experience problems when working with U-APSD. Decreasing the
  54. * probability of that happening by using legacy mode for all ACs but VO isn't
  55. * enough.
  56. *
  57. * Cisco 4410N originally forced us to enable VO by default only because it
  58. * treated non-VO ACs as legacy.
  59. *
  60. * However some APs (notably Netgear R7000) silently reclassify packets to
  61. * different ACs. Since u-APSD ACs require trigger frames for frame retrieval
  62. * clients would never see some frames (e.g. ARP responses) or would fetch them
  63. * accidentally after a long time.
  64. *
  65. * It makes little sense to enable u-APSD queues by default because it needs
  66. * userspace applications to be aware of it to actually take advantage of the
  67. * possible additional powersavings. Implicitly depending on driver autotrigger
  68. * frame support doesn't make much sense.
  69. */
  70. #define IEEE80211_DEFAULT_UAPSD_QUEUES 0
  71. #define IEEE80211_DEFAULT_MAX_SP_LEN \
  72. IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL
  73. #define IEEE80211_DEAUTH_FRAME_LEN (24 /* hdr */ + 2 /* reason */)
  74. struct ieee80211_fragment_entry {
  75. unsigned long first_frag_time;
  76. unsigned int seq;
  77. unsigned int rx_queue;
  78. unsigned int last_frag;
  79. unsigned int extra_len;
  80. struct sk_buff_head skb_list;
  81. int ccmp; /* Whether fragments were encrypted with CCMP */
  82. u8 last_pn[6]; /* PN of the last fragment if CCMP was used */
  83. };
  84. struct ieee80211_bss {
  85. u32 device_ts_beacon, device_ts_presp;
  86. bool wmm_used;
  87. bool uapsd_supported;
  88. #define IEEE80211_MAX_SUPP_RATES 32
  89. u8 supp_rates[IEEE80211_MAX_SUPP_RATES];
  90. size_t supp_rates_len;
  91. struct ieee80211_rate *beacon_rate;
  92. /*
  93. * During association, we save an ERP value from a probe response so
  94. * that we can feed ERP info to the driver when handling the
  95. * association completes. these fields probably won't be up-to-date
  96. * otherwise, you probably don't want to use them.
  97. */
  98. bool has_erp_value;
  99. u8 erp_value;
  100. /* Keep track of the corruption of the last beacon/probe response. */
  101. u8 corrupt_data;
  102. /* Keep track of what bits of information we have valid info for. */
  103. u8 valid_data;
  104. };
  105. /**
  106. * enum ieee80211_corrupt_data_flags - BSS data corruption flags
  107. * @IEEE80211_BSS_CORRUPT_BEACON: last beacon frame received was corrupted
  108. * @IEEE80211_BSS_CORRUPT_PROBE_RESP: last probe response received was corrupted
  109. *
  110. * These are bss flags that are attached to a bss in the
  111. * @corrupt_data field of &struct ieee80211_bss.
  112. */
  113. enum ieee80211_bss_corrupt_data_flags {
  114. IEEE80211_BSS_CORRUPT_BEACON = BIT(0),
  115. IEEE80211_BSS_CORRUPT_PROBE_RESP = BIT(1)
  116. };
  117. /**
  118. * enum ieee80211_valid_data_flags - BSS valid data flags
  119. * @IEEE80211_BSS_VALID_WMM: WMM/UAPSD data was gathered from non-corrupt IE
  120. * @IEEE80211_BSS_VALID_RATES: Supported rates were gathered from non-corrupt IE
  121. * @IEEE80211_BSS_VALID_ERP: ERP flag was gathered from non-corrupt IE
  122. *
  123. * These are bss flags that are attached to a bss in the
  124. * @valid_data field of &struct ieee80211_bss. They show which parts
  125. * of the data structure were received as a result of an un-corrupted
  126. * beacon/probe response.
  127. */
  128. enum ieee80211_bss_valid_data_flags {
  129. IEEE80211_BSS_VALID_WMM = BIT(1),
  130. IEEE80211_BSS_VALID_RATES = BIT(2),
  131. IEEE80211_BSS_VALID_ERP = BIT(3)
  132. };
  133. typedef unsigned __bitwise__ ieee80211_tx_result;
  134. #define TX_CONTINUE ((__force ieee80211_tx_result) 0u)
  135. #define TX_DROP ((__force ieee80211_tx_result) 1u)
  136. #define TX_QUEUED ((__force ieee80211_tx_result) 2u)
  137. #define IEEE80211_TX_UNICAST BIT(1)
  138. #define IEEE80211_TX_PS_BUFFERED BIT(2)
  139. struct ieee80211_tx_data {
  140. struct sk_buff *skb;
  141. struct sk_buff_head skbs;
  142. struct ieee80211_local *local;
  143. struct ieee80211_sub_if_data *sdata;
  144. struct sta_info *sta;
  145. struct ieee80211_key *key;
  146. struct ieee80211_tx_rate rate;
  147. unsigned int flags;
  148. };
  149. typedef unsigned __bitwise__ ieee80211_rx_result;
  150. #define RX_CONTINUE ((__force ieee80211_rx_result) 0u)
  151. #define RX_DROP_UNUSABLE ((__force ieee80211_rx_result) 1u)
  152. #define RX_DROP_MONITOR ((__force ieee80211_rx_result) 2u)
  153. #define RX_QUEUED ((__force ieee80211_rx_result) 3u)
  154. /**
  155. * enum ieee80211_packet_rx_flags - packet RX flags
  156. * @IEEE80211_RX_RA_MATCH: frame is destined to interface currently processed
  157. * (incl. multicast frames)
  158. * @IEEE80211_RX_FRAGMENTED: fragmented frame
  159. * @IEEE80211_RX_AMSDU: a-MSDU packet
  160. * @IEEE80211_RX_MALFORMED_ACTION_FRM: action frame is malformed
  161. * @IEEE80211_RX_DEFERRED_RELEASE: frame was subjected to receive reordering
  162. *
  163. * These are per-frame flags that are attached to a frame in the
  164. * @rx_flags field of &struct ieee80211_rx_status.
  165. */
  166. enum ieee80211_packet_rx_flags {
  167. IEEE80211_RX_RA_MATCH = BIT(1),
  168. IEEE80211_RX_FRAGMENTED = BIT(2),
  169. IEEE80211_RX_AMSDU = BIT(3),
  170. IEEE80211_RX_MALFORMED_ACTION_FRM = BIT(4),
  171. IEEE80211_RX_DEFERRED_RELEASE = BIT(5),
  172. };
  173. /**
  174. * enum ieee80211_rx_flags - RX data flags
  175. *
  176. * @IEEE80211_RX_CMNTR: received on cooked monitor already
  177. * @IEEE80211_RX_BEACON_REPORTED: This frame was already reported
  178. * to cfg80211_report_obss_beacon().
  179. *
  180. * These flags are used across handling multiple interfaces
  181. * for a single frame.
  182. */
  183. enum ieee80211_rx_flags {
  184. IEEE80211_RX_CMNTR = BIT(0),
  185. IEEE80211_RX_BEACON_REPORTED = BIT(1),
  186. };
  187. struct ieee80211_rx_data {
  188. struct sk_buff *skb;
  189. struct ieee80211_local *local;
  190. struct ieee80211_sub_if_data *sdata;
  191. struct sta_info *sta;
  192. struct ieee80211_key *key;
  193. unsigned int flags;
  194. /*
  195. * Index into sequence numbers array, 0..16
  196. * since the last (16) is used for non-QoS,
  197. * will be 16 on non-QoS frames.
  198. */
  199. int seqno_idx;
  200. /*
  201. * Index into the security IV/PN arrays, 0..16
  202. * since the last (16) is used for CCMP-encrypted
  203. * management frames, will be set to 16 on mgmt
  204. * frames and 0 on non-QoS frames.
  205. */
  206. int security_idx;
  207. u32 tkip_iv32;
  208. u16 tkip_iv16;
  209. };
  210. struct ieee80211_csa_settings {
  211. const u16 *counter_offsets_beacon;
  212. const u16 *counter_offsets_presp;
  213. int n_counter_offsets_beacon;
  214. int n_counter_offsets_presp;
  215. u8 count;
  216. };
  217. struct beacon_data {
  218. u8 *head, *tail;
  219. int head_len, tail_len;
  220. struct ieee80211_meshconf_ie *meshconf;
  221. u16 csa_counter_offsets[IEEE80211_MAX_CSA_COUNTERS_NUM];
  222. u8 csa_current_counter;
  223. struct rcu_head rcu_head;
  224. };
  225. struct probe_resp {
  226. struct rcu_head rcu_head;
  227. int len;
  228. u16 csa_counter_offsets[IEEE80211_MAX_CSA_COUNTERS_NUM];
  229. u8 data[0];
  230. };
  231. struct ps_data {
  232. /* yes, this looks ugly, but guarantees that we can later use
  233. * bitmap_empty :)
  234. * NB: don't touch this bitmap, use sta_info_{set,clear}_tim_bit */
  235. u8 tim[sizeof(unsigned long) * BITS_TO_LONGS(IEEE80211_MAX_AID + 1)]
  236. __aligned(__alignof__(unsigned long));
  237. struct sk_buff_head bc_buf;
  238. atomic_t num_sta_ps; /* number of stations in PS mode */
  239. int dtim_count;
  240. bool dtim_bc_mc;
  241. };
  242. struct ieee80211_if_ap {
  243. struct beacon_data __rcu *beacon;
  244. struct probe_resp __rcu *probe_resp;
  245. /* to be used after channel switch. */
  246. struct cfg80211_beacon_data *next_beacon;
  247. struct list_head vlans; /* write-protected with RTNL and local->mtx */
  248. struct ps_data ps;
  249. atomic_t num_mcast_sta; /* number of stations receiving multicast */
  250. enum ieee80211_smps_mode req_smps, /* requested smps mode */
  251. driver_smps_mode; /* smps mode request */
  252. struct work_struct request_smps_work;
  253. };
  254. struct ieee80211_if_wds {
  255. struct sta_info *sta;
  256. u8 remote_addr[ETH_ALEN];
  257. };
  258. struct ieee80211_if_vlan {
  259. struct list_head list; /* write-protected with RTNL and local->mtx */
  260. /* used for all tx if the VLAN is configured to 4-addr mode */
  261. struct sta_info __rcu *sta;
  262. };
  263. struct mesh_stats {
  264. __u32 fwded_mcast; /* Mesh forwarded multicast frames */
  265. __u32 fwded_unicast; /* Mesh forwarded unicast frames */
  266. __u32 fwded_frames; /* Mesh total forwarded frames */
  267. __u32 dropped_frames_ttl; /* Not transmitted since mesh_ttl == 0*/
  268. __u32 dropped_frames_no_route; /* Not transmitted, no route found */
  269. __u32 dropped_frames_congestion;/* Not forwarded due to congestion */
  270. };
  271. #define PREQ_Q_F_START 0x1
  272. #define PREQ_Q_F_REFRESH 0x2
  273. struct mesh_preq_queue {
  274. struct list_head list;
  275. u8 dst[ETH_ALEN];
  276. u8 flags;
  277. };
  278. #if HZ/100 == 0
  279. #define IEEE80211_ROC_MIN_LEFT 1
  280. #else
  281. #define IEEE80211_ROC_MIN_LEFT (HZ/100)
  282. #endif
  283. struct ieee80211_roc_work {
  284. struct list_head list;
  285. struct list_head dependents;
  286. struct delayed_work work;
  287. struct ieee80211_sub_if_data *sdata;
  288. struct ieee80211_channel *chan;
  289. bool started, abort, hw_begun, notified;
  290. bool to_be_freed;
  291. bool on_channel;
  292. unsigned long hw_start_time;
  293. u32 duration, req_duration;
  294. struct sk_buff *frame;
  295. u64 cookie, mgmt_tx_cookie;
  296. enum ieee80211_roc_type type;
  297. };
  298. /* flags used in struct ieee80211_if_managed.flags */
  299. enum ieee80211_sta_flags {
  300. IEEE80211_STA_CONNECTION_POLL = BIT(1),
  301. IEEE80211_STA_CONTROL_PORT = BIT(2),
  302. IEEE80211_STA_DISABLE_HT = BIT(4),
  303. IEEE80211_STA_MFP_ENABLED = BIT(6),
  304. IEEE80211_STA_UAPSD_ENABLED = BIT(7),
  305. IEEE80211_STA_NULLFUNC_ACKED = BIT(8),
  306. IEEE80211_STA_RESET_SIGNAL_AVE = BIT(9),
  307. IEEE80211_STA_DISABLE_40MHZ = BIT(10),
  308. IEEE80211_STA_DISABLE_VHT = BIT(11),
  309. IEEE80211_STA_DISABLE_80P80MHZ = BIT(12),
  310. IEEE80211_STA_DISABLE_160MHZ = BIT(13),
  311. IEEE80211_STA_DISABLE_WMM = BIT(14),
  312. IEEE80211_STA_ENABLE_RRM = BIT(15),
  313. };
  314. struct ieee80211_mgd_auth_data {
  315. struct cfg80211_bss *bss;
  316. unsigned long timeout;
  317. int tries;
  318. u16 algorithm, expected_transaction;
  319. u8 key[WLAN_KEY_LEN_WEP104];
  320. u8 key_len, key_idx;
  321. bool done;
  322. bool timeout_started;
  323. u16 sae_trans, sae_status;
  324. size_t data_len;
  325. u8 data[];
  326. };
  327. struct ieee80211_mgd_assoc_data {
  328. struct cfg80211_bss *bss;
  329. const u8 *supp_rates;
  330. unsigned long timeout;
  331. int tries;
  332. u16 capability;
  333. u8 prev_bssid[ETH_ALEN];
  334. u8 ssid[IEEE80211_MAX_SSID_LEN];
  335. u8 ssid_len;
  336. u8 supp_rates_len;
  337. bool wmm, uapsd;
  338. bool need_beacon;
  339. bool synced;
  340. bool timeout_started;
  341. u8 ap_ht_param;
  342. struct ieee80211_vht_cap ap_vht_cap;
  343. size_t ie_len;
  344. u8 ie[];
  345. };
  346. struct ieee80211_sta_tx_tspec {
  347. /* timestamp of the first packet in the time slice */
  348. unsigned long time_slice_start;
  349. u32 admitted_time; /* in usecs, unlike over the air */
  350. u8 tsid;
  351. s8 up; /* signed to be able to invalidate with -1 during teardown */
  352. /* consumed TX time in microseconds in the time slice */
  353. u32 consumed_tx_time;
  354. enum {
  355. TX_TSPEC_ACTION_NONE = 0,
  356. TX_TSPEC_ACTION_DOWNGRADE,
  357. TX_TSPEC_ACTION_STOP_DOWNGRADE,
  358. } action;
  359. bool downgraded;
  360. };
  361. struct ieee80211_if_managed {
  362. struct timer_list timer;
  363. struct timer_list conn_mon_timer;
  364. struct timer_list bcn_mon_timer;
  365. struct timer_list chswitch_timer;
  366. struct work_struct monitor_work;
  367. struct work_struct chswitch_work;
  368. struct work_struct beacon_connection_loss_work;
  369. struct work_struct csa_connection_drop_work;
  370. unsigned long beacon_timeout;
  371. unsigned long probe_timeout;
  372. int probe_send_count;
  373. bool nullfunc_failed;
  374. bool connection_loss;
  375. struct cfg80211_bss *associated;
  376. struct ieee80211_mgd_auth_data *auth_data;
  377. struct ieee80211_mgd_assoc_data *assoc_data;
  378. u8 bssid[ETH_ALEN];
  379. u16 aid;
  380. bool powersave; /* powersave requested for this iface */
  381. bool broken_ap; /* AP is broken -- turn off powersave */
  382. bool have_beacon;
  383. u8 dtim_period;
  384. enum ieee80211_smps_mode req_smps, /* requested smps mode */
  385. driver_smps_mode; /* smps mode request */
  386. struct work_struct request_smps_work;
  387. unsigned int flags;
  388. bool csa_waiting_bcn;
  389. bool csa_ignored_same_chan;
  390. bool beacon_crc_valid;
  391. u32 beacon_crc;
  392. bool status_acked;
  393. bool status_received;
  394. __le16 status_fc;
  395. enum {
  396. IEEE80211_MFP_DISABLED,
  397. IEEE80211_MFP_OPTIONAL,
  398. IEEE80211_MFP_REQUIRED
  399. } mfp; /* management frame protection */
  400. /*
  401. * Bitmask of enabled u-apsd queues,
  402. * IEEE80211_WMM_IE_STA_QOSINFO_AC_BE & co. Needs a new association
  403. * to take effect.
  404. */
  405. unsigned int uapsd_queues;
  406. /*
  407. * Maximum number of buffered frames AP can deliver during a
  408. * service period, IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL or similar.
  409. * Needs a new association to take effect.
  410. */
  411. unsigned int uapsd_max_sp_len;
  412. int wmm_last_param_set;
  413. u8 use_4addr;
  414. s16 p2p_noa_index;
  415. /* Signal strength from the last Beacon frame in the current BSS. */
  416. int last_beacon_signal;
  417. /*
  418. * Weighted average of the signal strength from Beacon frames in the
  419. * current BSS. This is in units of 1/16 of the signal unit to maintain
  420. * accuracy and to speed up calculations, i.e., the value need to be
  421. * divided by 16 to get the actual value.
  422. */
  423. int ave_beacon_signal;
  424. /*
  425. * Number of Beacon frames used in ave_beacon_signal. This can be used
  426. * to avoid generating less reliable cqm events that would be based
  427. * only on couple of received frames.
  428. */
  429. unsigned int count_beacon_signal;
  430. /*
  431. * Last Beacon frame signal strength average (ave_beacon_signal / 16)
  432. * that triggered a cqm event. 0 indicates that no event has been
  433. * generated for the current association.
  434. */
  435. int last_cqm_event_signal;
  436. /*
  437. * State variables for keeping track of RSSI of the AP currently
  438. * connected to and informing driver when RSSI has gone
  439. * below/above a certain threshold.
  440. */
  441. int rssi_min_thold, rssi_max_thold;
  442. int last_ave_beacon_signal;
  443. struct ieee80211_ht_cap ht_capa; /* configured ht-cap over-rides */
  444. struct ieee80211_ht_cap ht_capa_mask; /* Valid parts of ht_capa */
  445. struct ieee80211_vht_cap vht_capa; /* configured VHT overrides */
  446. struct ieee80211_vht_cap vht_capa_mask; /* Valid parts of vht_capa */
  447. /* TDLS support */
  448. u8 tdls_peer[ETH_ALEN] __aligned(2);
  449. struct delayed_work tdls_peer_del_work;
  450. struct sk_buff *orig_teardown_skb; /* The original teardown skb */
  451. struct sk_buff *teardown_skb; /* A copy to send through the AP */
  452. spinlock_t teardown_lock; /* To lock changing teardown_skb */
  453. bool tdls_chan_switch_prohibited;
  454. /* WMM-AC TSPEC support */
  455. struct ieee80211_sta_tx_tspec tx_tspec[IEEE80211_NUM_ACS];
  456. /* Use a separate work struct so that we can do something here
  457. * while the sdata->work is flushing the queues, for example.
  458. * otherwise, in scenarios where we hardly get any traffic out
  459. * on the BE queue, but there's a lot of VO traffic, we might
  460. * get stuck in a downgraded situation and flush takes forever.
  461. */
  462. struct delayed_work tx_tspec_wk;
  463. };
  464. struct ieee80211_if_ibss {
  465. struct timer_list timer;
  466. struct work_struct csa_connection_drop_work;
  467. unsigned long last_scan_completed;
  468. u32 basic_rates;
  469. bool fixed_bssid;
  470. bool fixed_channel;
  471. bool privacy;
  472. bool control_port;
  473. bool userspace_handles_dfs;
  474. u8 bssid[ETH_ALEN] __aligned(2);
  475. u8 ssid[IEEE80211_MAX_SSID_LEN];
  476. u8 ssid_len, ie_len;
  477. u8 *ie;
  478. struct cfg80211_chan_def chandef;
  479. unsigned long ibss_join_req;
  480. /* probe response/beacon for IBSS */
  481. struct beacon_data __rcu *presp;
  482. struct ieee80211_ht_cap ht_capa; /* configured ht-cap over-rides */
  483. struct ieee80211_ht_cap ht_capa_mask; /* Valid parts of ht_capa */
  484. spinlock_t incomplete_lock;
  485. struct list_head incomplete_stations;
  486. enum {
  487. IEEE80211_IBSS_MLME_SEARCH,
  488. IEEE80211_IBSS_MLME_JOINED,
  489. } state;
  490. };
  491. /**
  492. * struct ieee80211_if_ocb - OCB mode state
  493. *
  494. * @housekeeping_timer: timer for periodic invocation of a housekeeping task
  495. * @wrkq_flags: OCB deferred task action
  496. * @incomplete_lock: delayed STA insertion lock
  497. * @incomplete_stations: list of STAs waiting for delayed insertion
  498. * @joined: indication if the interface is connected to an OCB network
  499. */
  500. struct ieee80211_if_ocb {
  501. struct timer_list housekeeping_timer;
  502. unsigned long wrkq_flags;
  503. spinlock_t incomplete_lock;
  504. struct list_head incomplete_stations;
  505. bool joined;
  506. };
  507. /**
  508. * struct ieee80211_mesh_sync_ops - Extensible synchronization framework interface
  509. *
  510. * these declarations define the interface, which enables
  511. * vendor-specific mesh synchronization
  512. *
  513. */
  514. struct ieee802_11_elems;
  515. struct ieee80211_mesh_sync_ops {
  516. void (*rx_bcn_presp)(struct ieee80211_sub_if_data *sdata,
  517. u16 stype,
  518. struct ieee80211_mgmt *mgmt,
  519. struct ieee802_11_elems *elems,
  520. struct ieee80211_rx_status *rx_status);
  521. /* should be called with beacon_data under RCU read lock */
  522. void (*adjust_tbtt)(struct ieee80211_sub_if_data *sdata,
  523. struct beacon_data *beacon);
  524. /* add other framework functions here */
  525. };
  526. struct mesh_csa_settings {
  527. struct rcu_head rcu_head;
  528. struct cfg80211_csa_settings settings;
  529. };
  530. struct ieee80211_if_mesh {
  531. struct timer_list housekeeping_timer;
  532. struct timer_list mesh_path_timer;
  533. struct timer_list mesh_path_root_timer;
  534. unsigned long wrkq_flags;
  535. unsigned long mbss_changed;
  536. u8 mesh_id[IEEE80211_MAX_MESH_ID_LEN];
  537. size_t mesh_id_len;
  538. /* Active Path Selection Protocol Identifier */
  539. u8 mesh_pp_id;
  540. /* Active Path Selection Metric Identifier */
  541. u8 mesh_pm_id;
  542. /* Congestion Control Mode Identifier */
  543. u8 mesh_cc_id;
  544. /* Synchronization Protocol Identifier */
  545. u8 mesh_sp_id;
  546. /* Authentication Protocol Identifier */
  547. u8 mesh_auth_id;
  548. /* Local mesh Sequence Number */
  549. u32 sn;
  550. /* Last used PREQ ID */
  551. u32 preq_id;
  552. atomic_t mpaths;
  553. /* Timestamp of last SN update */
  554. unsigned long last_sn_update;
  555. /* Time when it's ok to send next PERR */
  556. unsigned long next_perr;
  557. /* Timestamp of last PREQ sent */
  558. unsigned long last_preq;
  559. struct mesh_rmc *rmc;
  560. spinlock_t mesh_preq_queue_lock;
  561. struct mesh_preq_queue preq_queue;
  562. int preq_queue_len;
  563. struct mesh_stats mshstats;
  564. struct mesh_config mshcfg;
  565. atomic_t estab_plinks;
  566. u32 mesh_seqnum;
  567. bool accepting_plinks;
  568. int num_gates;
  569. struct beacon_data __rcu *beacon;
  570. const u8 *ie;
  571. u8 ie_len;
  572. enum {
  573. IEEE80211_MESH_SEC_NONE = 0x0,
  574. IEEE80211_MESH_SEC_AUTHED = 0x1,
  575. IEEE80211_MESH_SEC_SECURED = 0x2,
  576. } security;
  577. bool user_mpm;
  578. /* Extensible Synchronization Framework */
  579. const struct ieee80211_mesh_sync_ops *sync_ops;
  580. s64 sync_offset_clockdrift_max;
  581. spinlock_t sync_offset_lock;
  582. bool adjusting_tbtt;
  583. /* mesh power save */
  584. enum nl80211_mesh_power_mode nonpeer_pm;
  585. int ps_peers_light_sleep;
  586. int ps_peers_deep_sleep;
  587. struct ps_data ps;
  588. /* Channel Switching Support */
  589. struct mesh_csa_settings __rcu *csa;
  590. enum {
  591. IEEE80211_MESH_CSA_ROLE_NONE,
  592. IEEE80211_MESH_CSA_ROLE_INIT,
  593. IEEE80211_MESH_CSA_ROLE_REPEATER,
  594. } csa_role;
  595. u8 chsw_ttl;
  596. u16 pre_value;
  597. /* offset from skb->data while building IE */
  598. int meshconf_offset;
  599. };
  600. #ifdef CONFIG_MAC80211_MESH
  601. #define IEEE80211_IFSTA_MESH_CTR_INC(msh, name) \
  602. do { (msh)->mshstats.name++; } while (0)
  603. #else
  604. #define IEEE80211_IFSTA_MESH_CTR_INC(msh, name) \
  605. do { } while (0)
  606. #endif
  607. /**
  608. * enum ieee80211_sub_if_data_flags - virtual interface flags
  609. *
  610. * @IEEE80211_SDATA_ALLMULTI: interface wants all multicast packets
  611. * @IEEE80211_SDATA_PROMISC: interface is promisc
  612. * @IEEE80211_SDATA_OPERATING_GMODE: operating in G-only mode
  613. * @IEEE80211_SDATA_DONT_BRIDGE_PACKETS: bridge packets between
  614. * associated stations and deliver multicast frames both
  615. * back to wireless media and to the local net stack.
  616. * @IEEE80211_SDATA_DISCONNECT_RESUME: Disconnect after resume.
  617. * @IEEE80211_SDATA_IN_DRIVER: indicates interface was added to driver
  618. */
  619. enum ieee80211_sub_if_data_flags {
  620. IEEE80211_SDATA_ALLMULTI = BIT(0),
  621. IEEE80211_SDATA_PROMISC = BIT(1),
  622. IEEE80211_SDATA_OPERATING_GMODE = BIT(2),
  623. IEEE80211_SDATA_DONT_BRIDGE_PACKETS = BIT(3),
  624. IEEE80211_SDATA_DISCONNECT_RESUME = BIT(4),
  625. IEEE80211_SDATA_IN_DRIVER = BIT(5),
  626. };
  627. /**
  628. * enum ieee80211_sdata_state_bits - virtual interface state bits
  629. * @SDATA_STATE_RUNNING: virtual interface is up & running; this
  630. * mirrors netif_running() but is separate for interface type
  631. * change handling while the interface is up
  632. * @SDATA_STATE_OFFCHANNEL: This interface is currently in offchannel
  633. * mode, so queues are stopped
  634. * @SDATA_STATE_OFFCHANNEL_BEACON_STOPPED: Beaconing was stopped due
  635. * to offchannel, reset when offchannel returns
  636. */
  637. enum ieee80211_sdata_state_bits {
  638. SDATA_STATE_RUNNING,
  639. SDATA_STATE_OFFCHANNEL,
  640. SDATA_STATE_OFFCHANNEL_BEACON_STOPPED,
  641. };
  642. /**
  643. * enum ieee80211_chanctx_mode - channel context configuration mode
  644. *
  645. * @IEEE80211_CHANCTX_SHARED: channel context may be used by
  646. * multiple interfaces
  647. * @IEEE80211_CHANCTX_EXCLUSIVE: channel context can be used
  648. * only by a single interface. This can be used for example for
  649. * non-fixed channel IBSS.
  650. */
  651. enum ieee80211_chanctx_mode {
  652. IEEE80211_CHANCTX_SHARED,
  653. IEEE80211_CHANCTX_EXCLUSIVE
  654. };
  655. /**
  656. * enum ieee80211_chanctx_replace_state - channel context replacement state
  657. *
  658. * This is used for channel context in-place reservations that require channel
  659. * context switch/swap.
  660. *
  661. * @IEEE80211_CHANCTX_REPLACE_NONE: no replacement is taking place
  662. * @IEEE80211_CHANCTX_WILL_BE_REPLACED: this channel context will be replaced
  663. * by a (not yet registered) channel context pointed by %replace_ctx.
  664. * @IEEE80211_CHANCTX_REPLACES_OTHER: this (not yet registered) channel context
  665. * replaces an existing channel context pointed to by %replace_ctx.
  666. */
  667. enum ieee80211_chanctx_replace_state {
  668. IEEE80211_CHANCTX_REPLACE_NONE,
  669. IEEE80211_CHANCTX_WILL_BE_REPLACED,
  670. IEEE80211_CHANCTX_REPLACES_OTHER,
  671. };
  672. struct ieee80211_chanctx {
  673. struct list_head list;
  674. struct rcu_head rcu_head;
  675. struct list_head assigned_vifs;
  676. struct list_head reserved_vifs;
  677. enum ieee80211_chanctx_replace_state replace_state;
  678. struct ieee80211_chanctx *replace_ctx;
  679. enum ieee80211_chanctx_mode mode;
  680. bool driver_present;
  681. struct ieee80211_chanctx_conf conf;
  682. };
  683. struct mac80211_qos_map {
  684. struct cfg80211_qos_map qos_map;
  685. struct rcu_head rcu_head;
  686. };
  687. enum txq_info_flags {
  688. IEEE80211_TXQ_STOP,
  689. IEEE80211_TXQ_AMPDU,
  690. };
  691. struct txq_info {
  692. struct sk_buff_head queue;
  693. unsigned long flags;
  694. /* keep last! */
  695. struct ieee80211_txq txq;
  696. };
  697. struct ieee80211_sub_if_data {
  698. struct list_head list;
  699. struct wireless_dev wdev;
  700. /* keys */
  701. struct list_head key_list;
  702. /* count for keys needing tailroom space allocation */
  703. int crypto_tx_tailroom_needed_cnt;
  704. int crypto_tx_tailroom_pending_dec;
  705. struct delayed_work dec_tailroom_needed_wk;
  706. struct net_device *dev;
  707. struct ieee80211_local *local;
  708. unsigned int flags;
  709. unsigned long state;
  710. char name[IFNAMSIZ];
  711. /* Fragment table for host-based reassembly */
  712. struct ieee80211_fragment_entry fragments[IEEE80211_FRAGMENT_MAX];
  713. unsigned int fragment_next;
  714. /* TID bitmap for NoAck policy */
  715. u16 noack_map;
  716. /* bit field of ACM bits (BIT(802.1D tag)) */
  717. u8 wmm_acm;
  718. struct ieee80211_key __rcu *keys[NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS];
  719. struct ieee80211_key __rcu *default_unicast_key;
  720. struct ieee80211_key __rcu *default_multicast_key;
  721. struct ieee80211_key __rcu *default_mgmt_key;
  722. u16 sequence_number;
  723. __be16 control_port_protocol;
  724. bool control_port_no_encrypt;
  725. int encrypt_headroom;
  726. atomic_t txqs_len[IEEE80211_NUM_ACS];
  727. struct ieee80211_tx_queue_params tx_conf[IEEE80211_NUM_ACS];
  728. struct mac80211_qos_map __rcu *qos_map;
  729. struct work_struct csa_finalize_work;
  730. bool csa_block_tx; /* write-protected by sdata_lock and local->mtx */
  731. struct cfg80211_chan_def csa_chandef;
  732. struct list_head assigned_chanctx_list; /* protected by chanctx_mtx */
  733. struct list_head reserved_chanctx_list; /* protected by chanctx_mtx */
  734. /* context reservation -- protected with chanctx_mtx */
  735. struct ieee80211_chanctx *reserved_chanctx;
  736. struct cfg80211_chan_def reserved_chandef;
  737. bool reserved_radar_required;
  738. bool reserved_ready;
  739. /* used to reconfigure hardware SM PS */
  740. struct work_struct recalc_smps;
  741. struct work_struct work;
  742. struct sk_buff_head skb_queue;
  743. u8 needed_rx_chains;
  744. enum ieee80211_smps_mode smps_mode;
  745. int user_power_level; /* in dBm */
  746. int ap_power_level; /* in dBm */
  747. bool radar_required;
  748. struct delayed_work dfs_cac_timer_work;
  749. /*
  750. * AP this belongs to: self in AP mode and
  751. * corresponding AP in VLAN mode, NULL for
  752. * all others (might be needed later in IBSS)
  753. */
  754. struct ieee80211_if_ap *bss;
  755. /* bitmap of allowed (non-MCS) rate indexes for rate control */
  756. u32 rc_rateidx_mask[IEEE80211_NUM_BANDS];
  757. bool rc_has_mcs_mask[IEEE80211_NUM_BANDS];
  758. u8 rc_rateidx_mcs_mask[IEEE80211_NUM_BANDS][IEEE80211_HT_MCS_MASK_LEN];
  759. union {
  760. struct ieee80211_if_ap ap;
  761. struct ieee80211_if_wds wds;
  762. struct ieee80211_if_vlan vlan;
  763. struct ieee80211_if_managed mgd;
  764. struct ieee80211_if_ibss ibss;
  765. struct ieee80211_if_mesh mesh;
  766. struct ieee80211_if_ocb ocb;
  767. u32 mntr_flags;
  768. } u;
  769. #ifdef CONFIG_MAC80211_DEBUGFS
  770. struct {
  771. struct dentry *subdir_stations;
  772. struct dentry *default_unicast_key;
  773. struct dentry *default_multicast_key;
  774. struct dentry *default_mgmt_key;
  775. } debugfs;
  776. #endif
  777. /* must be last, dynamically sized area in this! */
  778. struct ieee80211_vif vif;
  779. };
  780. static inline
  781. struct ieee80211_sub_if_data *vif_to_sdata(struct ieee80211_vif *p)
  782. {
  783. return container_of(p, struct ieee80211_sub_if_data, vif);
  784. }
  785. static inline void sdata_lock(struct ieee80211_sub_if_data *sdata)
  786. __acquires(&sdata->wdev.mtx)
  787. {
  788. mutex_lock(&sdata->wdev.mtx);
  789. __acquire(&sdata->wdev.mtx);
  790. }
  791. static inline void sdata_unlock(struct ieee80211_sub_if_data *sdata)
  792. __releases(&sdata->wdev.mtx)
  793. {
  794. mutex_unlock(&sdata->wdev.mtx);
  795. __release(&sdata->wdev.mtx);
  796. }
  797. #define sdata_dereference(p, sdata) \
  798. rcu_dereference_protected(p, lockdep_is_held(&sdata->wdev.mtx))
  799. static inline void
  800. sdata_assert_lock(struct ieee80211_sub_if_data *sdata)
  801. {
  802. lockdep_assert_held(&sdata->wdev.mtx);
  803. }
  804. static inline enum ieee80211_band
  805. ieee80211_get_sdata_band(struct ieee80211_sub_if_data *sdata)
  806. {
  807. enum ieee80211_band band = IEEE80211_BAND_2GHZ;
  808. struct ieee80211_chanctx_conf *chanctx_conf;
  809. rcu_read_lock();
  810. chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
  811. if (!WARN_ON(!chanctx_conf))
  812. band = chanctx_conf->def.chan->band;
  813. rcu_read_unlock();
  814. return band;
  815. }
  816. static inline int
  817. ieee80211_chandef_get_shift(struct cfg80211_chan_def *chandef)
  818. {
  819. switch (chandef->width) {
  820. case NL80211_CHAN_WIDTH_5:
  821. return 2;
  822. case NL80211_CHAN_WIDTH_10:
  823. return 1;
  824. default:
  825. return 0;
  826. }
  827. }
  828. static inline int
  829. ieee80211_vif_get_shift(struct ieee80211_vif *vif)
  830. {
  831. struct ieee80211_chanctx_conf *chanctx_conf;
  832. int shift = 0;
  833. rcu_read_lock();
  834. chanctx_conf = rcu_dereference(vif->chanctx_conf);
  835. if (chanctx_conf)
  836. shift = ieee80211_chandef_get_shift(&chanctx_conf->def);
  837. rcu_read_unlock();
  838. return shift;
  839. }
  840. struct ieee80211_rx_agg {
  841. u8 addr[ETH_ALEN];
  842. u16 tid;
  843. };
  844. enum sdata_queue_type {
  845. IEEE80211_SDATA_QUEUE_TYPE_FRAME = 0,
  846. IEEE80211_SDATA_QUEUE_AGG_START = 1,
  847. IEEE80211_SDATA_QUEUE_AGG_STOP = 2,
  848. IEEE80211_SDATA_QUEUE_RX_AGG_START = 3,
  849. IEEE80211_SDATA_QUEUE_RX_AGG_STOP = 4,
  850. IEEE80211_SDATA_QUEUE_TDLS_CHSW = 5,
  851. };
  852. enum {
  853. IEEE80211_RX_MSG = 1,
  854. IEEE80211_TX_STATUS_MSG = 2,
  855. };
  856. enum queue_stop_reason {
  857. IEEE80211_QUEUE_STOP_REASON_DRIVER,
  858. IEEE80211_QUEUE_STOP_REASON_PS,
  859. IEEE80211_QUEUE_STOP_REASON_CSA,
  860. IEEE80211_QUEUE_STOP_REASON_AGGREGATION,
  861. IEEE80211_QUEUE_STOP_REASON_SUSPEND,
  862. IEEE80211_QUEUE_STOP_REASON_SKB_ADD,
  863. IEEE80211_QUEUE_STOP_REASON_OFFCHANNEL,
  864. IEEE80211_QUEUE_STOP_REASON_FLUSH,
  865. IEEE80211_QUEUE_STOP_REASON_TDLS_TEARDOWN,
  866. IEEE80211_QUEUE_STOP_REASON_RESERVE_TID,
  867. IEEE80211_QUEUE_STOP_REASONS,
  868. };
  869. #ifdef CONFIG_MAC80211_LEDS
  870. struct tpt_led_trigger {
  871. struct led_trigger trig;
  872. char name[32];
  873. const struct ieee80211_tpt_blink *blink_table;
  874. unsigned int blink_table_len;
  875. struct timer_list timer;
  876. unsigned long prev_traffic;
  877. unsigned long tx_bytes, rx_bytes;
  878. unsigned int active, want;
  879. bool running;
  880. };
  881. #endif
  882. /**
  883. * mac80211 scan flags - currently active scan mode
  884. *
  885. * @SCAN_SW_SCANNING: We're currently in the process of scanning but may as
  886. * well be on the operating channel
  887. * @SCAN_HW_SCANNING: The hardware is scanning for us, we have no way to
  888. * determine if we are on the operating channel or not
  889. * @SCAN_ONCHANNEL_SCANNING: Do a software scan on only the current operating
  890. * channel. This should not interrupt normal traffic.
  891. * @SCAN_COMPLETED: Set for our scan work function when the driver reported
  892. * that the scan completed.
  893. * @SCAN_ABORTED: Set for our scan work function when the driver reported
  894. * a scan complete for an aborted scan.
  895. * @SCAN_HW_CANCELLED: Set for our scan work function when the scan is being
  896. * cancelled.
  897. */
  898. enum {
  899. SCAN_SW_SCANNING,
  900. SCAN_HW_SCANNING,
  901. SCAN_ONCHANNEL_SCANNING,
  902. SCAN_COMPLETED,
  903. SCAN_ABORTED,
  904. SCAN_HW_CANCELLED,
  905. };
  906. /**
  907. * enum mac80211_scan_state - scan state machine states
  908. *
  909. * @SCAN_DECISION: Main entry point to the scan state machine, this state
  910. * determines if we should keep on scanning or switch back to the
  911. * operating channel
  912. * @SCAN_SET_CHANNEL: Set the next channel to be scanned
  913. * @SCAN_SEND_PROBE: Send probe requests and wait for probe responses
  914. * @SCAN_SUSPEND: Suspend the scan and go back to operating channel to
  915. * send out data
  916. * @SCAN_RESUME: Resume the scan and scan the next channel
  917. * @SCAN_ABORT: Abort the scan and go back to operating channel
  918. */
  919. enum mac80211_scan_state {
  920. SCAN_DECISION,
  921. SCAN_SET_CHANNEL,
  922. SCAN_SEND_PROBE,
  923. SCAN_SUSPEND,
  924. SCAN_RESUME,
  925. SCAN_ABORT,
  926. };
  927. struct ieee80211_local {
  928. /* embed the driver visible part.
  929. * don't cast (use the static inlines below), but we keep
  930. * it first anyway so they become a no-op */
  931. struct ieee80211_hw hw;
  932. const struct ieee80211_ops *ops;
  933. /*
  934. * private workqueue to mac80211. mac80211 makes this accessible
  935. * via ieee80211_queue_work()
  936. */
  937. struct workqueue_struct *workqueue;
  938. unsigned long queue_stop_reasons[IEEE80211_MAX_QUEUES];
  939. int q_stop_reasons[IEEE80211_MAX_QUEUES][IEEE80211_QUEUE_STOP_REASONS];
  940. /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
  941. spinlock_t queue_stop_reason_lock;
  942. int open_count;
  943. int monitors, cooked_mntrs;
  944. /* number of interfaces with corresponding FIF_ flags */
  945. int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
  946. fif_probe_req;
  947. int probe_req_reg;
  948. unsigned int filter_flags; /* FIF_* */
  949. bool wiphy_ciphers_allocated;
  950. bool use_chanctx;
  951. /* protects the aggregated multicast list and filter calls */
  952. spinlock_t filter_lock;
  953. /* used for uploading changed mc list */
  954. struct work_struct reconfig_filter;
  955. /* aggregated multicast list */
  956. struct netdev_hw_addr_list mc_list;
  957. bool tim_in_locked_section; /* see ieee80211_beacon_get() */
  958. /*
  959. * suspended is true if we finished all the suspend _and_ we have
  960. * not yet come up from resume. This is to be used by mac80211
  961. * to ensure driver sanity during suspend and mac80211's own
  962. * sanity. It can eventually be used for WoW as well.
  963. */
  964. bool suspended;
  965. /*
  966. * Resuming is true while suspended, but when we're reprogramming the
  967. * hardware -- at that time it's allowed to use ieee80211_queue_work()
  968. * again even though some other parts of the stack are still suspended
  969. * and we still drop received frames to avoid waking the stack.
  970. */
  971. bool resuming;
  972. /*
  973. * quiescing is true during the suspend process _only_ to
  974. * ease timer cancelling etc.
  975. */
  976. bool quiescing;
  977. /* device is started */
  978. bool started;
  979. /* device is during a HW reconfig */
  980. bool in_reconfig;
  981. /* wowlan is enabled -- don't reconfig on resume */
  982. bool wowlan;
  983. struct work_struct radar_detected_work;
  984. /* number of RX chains the hardware has */
  985. u8 rx_chains;
  986. int tx_headroom; /* required headroom for hardware/radiotap */
  987. /* Tasklet and skb queue to process calls from IRQ mode. All frames
  988. * added to skb_queue will be processed, but frames in
  989. * skb_queue_unreliable may be dropped if the total length of these
  990. * queues increases over the limit. */
  991. #define IEEE80211_IRQSAFE_QUEUE_LIMIT 128
  992. struct tasklet_struct tasklet;
  993. struct sk_buff_head skb_queue;
  994. struct sk_buff_head skb_queue_unreliable;
  995. spinlock_t rx_path_lock;
  996. /* Station data */
  997. /*
  998. * The mutex only protects the list, hash table and
  999. * counter, reads are done with RCU.
  1000. */
  1001. struct mutex sta_mtx;
  1002. spinlock_t tim_lock;
  1003. unsigned long num_sta;
  1004. struct list_head sta_list;
  1005. struct rhashtable sta_hash;
  1006. struct timer_list sta_cleanup;
  1007. int sta_generation;
  1008. struct sk_buff_head pending[IEEE80211_MAX_QUEUES];
  1009. struct tasklet_struct tx_pending_tasklet;
  1010. atomic_t agg_queue_stop[IEEE80211_MAX_QUEUES];
  1011. /* number of interfaces with corresponding IFF_ flags */
  1012. atomic_t iff_allmultis, iff_promiscs;
  1013. struct rate_control_ref *rate_ctrl;
  1014. struct crypto_cipher *wep_tx_tfm;
  1015. struct crypto_cipher *wep_rx_tfm;
  1016. u32 wep_iv;
  1017. /* see iface.c */
  1018. struct list_head interfaces;
  1019. struct mutex iflist_mtx;
  1020. /*
  1021. * Key mutex, protects sdata's key_list and sta_info's
  1022. * key pointers (write access, they're RCU.)
  1023. */
  1024. struct mutex key_mtx;
  1025. /* mutex for scan and work locking */
  1026. struct mutex mtx;
  1027. /* Scanning and BSS list */
  1028. unsigned long scanning;
  1029. struct cfg80211_ssid scan_ssid;
  1030. struct cfg80211_scan_request *int_scan_req;
  1031. struct cfg80211_scan_request __rcu *scan_req;
  1032. struct ieee80211_scan_request *hw_scan_req;
  1033. struct cfg80211_chan_def scan_chandef;
  1034. enum ieee80211_band hw_scan_band;
  1035. int scan_channel_idx;
  1036. int scan_ies_len;
  1037. int hw_scan_ies_bufsize;
  1038. struct work_struct sched_scan_stopped_work;
  1039. struct ieee80211_sub_if_data __rcu *sched_scan_sdata;
  1040. struct cfg80211_sched_scan_request __rcu *sched_scan_req;
  1041. u8 scan_addr[ETH_ALEN];
  1042. unsigned long leave_oper_channel_time;
  1043. enum mac80211_scan_state next_scan_state;
  1044. struct delayed_work scan_work;
  1045. struct ieee80211_sub_if_data __rcu *scan_sdata;
  1046. /* For backward compatibility only -- do not use */
  1047. struct cfg80211_chan_def _oper_chandef;
  1048. /* Temporary remain-on-channel for off-channel operations */
  1049. struct ieee80211_channel *tmp_channel;
  1050. /* channel contexts */
  1051. struct list_head chanctx_list;
  1052. struct mutex chanctx_mtx;
  1053. /* SNMP counters */
  1054. /* dot11CountersTable */
  1055. u32 dot11TransmittedFragmentCount;
  1056. u32 dot11MulticastTransmittedFrameCount;
  1057. u32 dot11FailedCount;
  1058. u32 dot11RetryCount;
  1059. u32 dot11MultipleRetryCount;
  1060. u32 dot11FrameDuplicateCount;
  1061. u32 dot11ReceivedFragmentCount;
  1062. u32 dot11MulticastReceivedFrameCount;
  1063. u32 dot11TransmittedFrameCount;
  1064. #ifdef CONFIG_MAC80211_LEDS
  1065. struct led_trigger *tx_led, *rx_led, *assoc_led, *radio_led;
  1066. struct tpt_led_trigger *tpt_led_trigger;
  1067. char tx_led_name[32], rx_led_name[32],
  1068. assoc_led_name[32], radio_led_name[32];
  1069. #endif
  1070. #ifdef CONFIG_MAC80211_DEBUG_COUNTERS
  1071. /* TX/RX handler statistics */
  1072. unsigned int tx_handlers_drop;
  1073. unsigned int tx_handlers_queued;
  1074. unsigned int tx_handlers_drop_fragment;
  1075. unsigned int tx_handlers_drop_wep;
  1076. unsigned int tx_handlers_drop_not_assoc;
  1077. unsigned int tx_handlers_drop_unauth_port;
  1078. unsigned int rx_handlers_drop;
  1079. unsigned int rx_handlers_queued;
  1080. unsigned int rx_handlers_drop_nullfunc;
  1081. unsigned int rx_handlers_drop_defrag;
  1082. unsigned int rx_handlers_drop_short;
  1083. unsigned int tx_expand_skb_head;
  1084. unsigned int tx_expand_skb_head_cloned;
  1085. unsigned int rx_expand_skb_head;
  1086. unsigned int rx_expand_skb_head2;
  1087. unsigned int rx_handlers_fragments;
  1088. unsigned int tx_status_drop;
  1089. #define I802_DEBUG_INC(c) (c)++
  1090. #else /* CONFIG_MAC80211_DEBUG_COUNTERS */
  1091. #define I802_DEBUG_INC(c) do { } while (0)
  1092. #endif /* CONFIG_MAC80211_DEBUG_COUNTERS */
  1093. int total_ps_buffered; /* total number of all buffered unicast and
  1094. * multicast packets for power saving stations
  1095. */
  1096. bool pspolling;
  1097. bool offchannel_ps_enabled;
  1098. /*
  1099. * PS can only be enabled when we have exactly one managed
  1100. * interface (and monitors) in PS, this then points there.
  1101. */
  1102. struct ieee80211_sub_if_data *ps_sdata;
  1103. struct work_struct dynamic_ps_enable_work;
  1104. struct work_struct dynamic_ps_disable_work;
  1105. struct timer_list dynamic_ps_timer;
  1106. struct notifier_block network_latency_notifier;
  1107. struct notifier_block ifa_notifier;
  1108. struct notifier_block ifa6_notifier;
  1109. /*
  1110. * The dynamic ps timeout configured from user space via WEXT -
  1111. * this will override whatever chosen by mac80211 internally.
  1112. */
  1113. int dynamic_ps_forced_timeout;
  1114. int user_power_level; /* in dBm, for all interfaces */
  1115. enum ieee80211_smps_mode smps_mode;
  1116. struct work_struct restart_work;
  1117. #ifdef CONFIG_MAC80211_DEBUGFS
  1118. struct local_debugfsdentries {
  1119. struct dentry *rcdir;
  1120. struct dentry *keys;
  1121. } debugfs;
  1122. #endif
  1123. /*
  1124. * Remain-on-channel support
  1125. */
  1126. struct list_head roc_list;
  1127. struct work_struct hw_roc_start, hw_roc_done;
  1128. unsigned long hw_roc_start_time;
  1129. u64 roc_cookie_counter;
  1130. struct idr ack_status_frames;
  1131. spinlock_t ack_status_lock;
  1132. struct ieee80211_sub_if_data __rcu *p2p_sdata;
  1133. struct napi_struct *napi;
  1134. /* virtual monitor interface */
  1135. struct ieee80211_sub_if_data __rcu *monitor_sdata;
  1136. struct cfg80211_chan_def monitor_chandef;
  1137. /* extended capabilities provided by mac80211 */
  1138. u8 ext_capa[8];
  1139. };
  1140. static inline struct ieee80211_sub_if_data *
  1141. IEEE80211_DEV_TO_SUB_IF(struct net_device *dev)
  1142. {
  1143. return netdev_priv(dev);
  1144. }
  1145. static inline struct ieee80211_sub_if_data *
  1146. IEEE80211_WDEV_TO_SUB_IF(struct wireless_dev *wdev)
  1147. {
  1148. return container_of(wdev, struct ieee80211_sub_if_data, wdev);
  1149. }
  1150. /* this struct represents 802.11n's RA/TID combination */
  1151. struct ieee80211_ra_tid {
  1152. u8 ra[ETH_ALEN];
  1153. u16 tid;
  1154. };
  1155. /* this struct holds the value parsing from channel switch IE */
  1156. struct ieee80211_csa_ie {
  1157. struct cfg80211_chan_def chandef;
  1158. u8 mode;
  1159. u8 count;
  1160. u8 ttl;
  1161. u16 pre_value;
  1162. };
  1163. /* Parsed Information Elements */
  1164. struct ieee802_11_elems {
  1165. const u8 *ie_start;
  1166. size_t total_len;
  1167. /* pointers to IEs */
  1168. const struct ieee80211_tdls_lnkie *lnk_id;
  1169. const struct ieee80211_ch_switch_timing *ch_sw_timing;
  1170. const u8 *ext_capab;
  1171. const u8 *ssid;
  1172. const u8 *supp_rates;
  1173. const u8 *ds_params;
  1174. const struct ieee80211_tim_ie *tim;
  1175. const u8 *challenge;
  1176. const u8 *rsn;
  1177. const u8 *erp_info;
  1178. const u8 *ext_supp_rates;
  1179. const u8 *wmm_info;
  1180. const u8 *wmm_param;
  1181. const struct ieee80211_ht_cap *ht_cap_elem;
  1182. const struct ieee80211_ht_operation *ht_operation;
  1183. const struct ieee80211_vht_cap *vht_cap_elem;
  1184. const struct ieee80211_vht_operation *vht_operation;
  1185. const struct ieee80211_meshconf_ie *mesh_config;
  1186. const u8 *mesh_id;
  1187. const u8 *peering;
  1188. const __le16 *awake_window;
  1189. const u8 *preq;
  1190. const u8 *prep;
  1191. const u8 *perr;
  1192. const struct ieee80211_rann_ie *rann;
  1193. const struct ieee80211_channel_sw_ie *ch_switch_ie;
  1194. const struct ieee80211_ext_chansw_ie *ext_chansw_ie;
  1195. const struct ieee80211_wide_bw_chansw_ie *wide_bw_chansw_ie;
  1196. const u8 *country_elem;
  1197. const u8 *pwr_constr_elem;
  1198. const u8 *cisco_dtpc_elem;
  1199. const struct ieee80211_timeout_interval_ie *timeout_int;
  1200. const u8 *opmode_notif;
  1201. const struct ieee80211_sec_chan_offs_ie *sec_chan_offs;
  1202. const struct ieee80211_mesh_chansw_params_ie *mesh_chansw_params_ie;
  1203. /* length of them, respectively */
  1204. u8 ext_capab_len;
  1205. u8 ssid_len;
  1206. u8 supp_rates_len;
  1207. u8 tim_len;
  1208. u8 challenge_len;
  1209. u8 rsn_len;
  1210. u8 ext_supp_rates_len;
  1211. u8 wmm_info_len;
  1212. u8 wmm_param_len;
  1213. u8 mesh_id_len;
  1214. u8 peering_len;
  1215. u8 preq_len;
  1216. u8 prep_len;
  1217. u8 perr_len;
  1218. u8 country_elem_len;
  1219. /* whether a parse error occurred while retrieving these elements */
  1220. bool parse_error;
  1221. };
  1222. static inline struct ieee80211_local *hw_to_local(
  1223. struct ieee80211_hw *hw)
  1224. {
  1225. return container_of(hw, struct ieee80211_local, hw);
  1226. }
  1227. static inline struct txq_info *to_txq_info(struct ieee80211_txq *txq)
  1228. {
  1229. return container_of(txq, struct txq_info, txq);
  1230. }
  1231. static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr)
  1232. {
  1233. return ether_addr_equal(raddr, addr) ||
  1234. is_broadcast_ether_addr(raddr);
  1235. }
  1236. static inline bool
  1237. ieee80211_have_rx_timestamp(struct ieee80211_rx_status *status)
  1238. {
  1239. WARN_ON_ONCE(status->flag & RX_FLAG_MACTIME_START &&
  1240. status->flag & RX_FLAG_MACTIME_END);
  1241. return status->flag & (RX_FLAG_MACTIME_START | RX_FLAG_MACTIME_END);
  1242. }
  1243. u64 ieee80211_calculate_rx_timestamp(struct ieee80211_local *local,
  1244. struct ieee80211_rx_status *status,
  1245. unsigned int mpdu_len,
  1246. unsigned int mpdu_offset);
  1247. int ieee80211_hw_config(struct ieee80211_local *local, u32 changed);
  1248. void ieee80211_tx_set_protected(struct ieee80211_tx_data *tx);
  1249. void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
  1250. u32 changed);
  1251. void ieee80211_configure_filter(struct ieee80211_local *local);
  1252. u32 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata);
  1253. /* STA code */
  1254. void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata);
  1255. int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata,
  1256. struct cfg80211_auth_request *req);
  1257. int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
  1258. struct cfg80211_assoc_request *req);
  1259. int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata,
  1260. struct cfg80211_deauth_request *req);
  1261. int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata,
  1262. struct cfg80211_disassoc_request *req);
  1263. void ieee80211_send_pspoll(struct ieee80211_local *local,
  1264. struct ieee80211_sub_if_data *sdata);
  1265. void ieee80211_recalc_ps(struct ieee80211_local *local, s32 latency);
  1266. void ieee80211_recalc_ps_vif(struct ieee80211_sub_if_data *sdata);
  1267. int ieee80211_max_network_latency(struct notifier_block *nb,
  1268. unsigned long data, void *dummy);
  1269. int ieee80211_set_arp_filter(struct ieee80211_sub_if_data *sdata);
  1270. void ieee80211_sta_work(struct ieee80211_sub_if_data *sdata);
  1271. void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
  1272. struct sk_buff *skb);
  1273. void ieee80211_sta_reset_beacon_monitor(struct ieee80211_sub_if_data *sdata);
  1274. void ieee80211_sta_reset_conn_monitor(struct ieee80211_sub_if_data *sdata);
  1275. void ieee80211_mgd_stop(struct ieee80211_sub_if_data *sdata);
  1276. void ieee80211_mgd_conn_tx_status(struct ieee80211_sub_if_data *sdata,
  1277. __le16 fc, bool acked);
  1278. void ieee80211_mgd_quiesce(struct ieee80211_sub_if_data *sdata);
  1279. void ieee80211_sta_restart(struct ieee80211_sub_if_data *sdata);
  1280. void ieee80211_sta_handle_tspec_ac_params(struct ieee80211_sub_if_data *sdata);
  1281. /* IBSS code */
  1282. void ieee80211_ibss_notify_scan_completed(struct ieee80211_local *local);
  1283. void ieee80211_ibss_setup_sdata(struct ieee80211_sub_if_data *sdata);
  1284. void ieee80211_ibss_rx_no_sta(struct ieee80211_sub_if_data *sdata,
  1285. const u8 *bssid, const u8 *addr, u32 supp_rates);
  1286. int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata,
  1287. struct cfg80211_ibss_params *params);
  1288. int ieee80211_ibss_leave(struct ieee80211_sub_if_data *sdata);
  1289. void ieee80211_ibss_work(struct ieee80211_sub_if_data *sdata);
  1290. void ieee80211_ibss_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
  1291. struct sk_buff *skb);
  1292. int ieee80211_ibss_csa_beacon(struct ieee80211_sub_if_data *sdata,
  1293. struct cfg80211_csa_settings *csa_settings);
  1294. int ieee80211_ibss_finish_csa(struct ieee80211_sub_if_data *sdata);
  1295. void ieee80211_ibss_stop(struct ieee80211_sub_if_data *sdata);
  1296. /* OCB code */
  1297. void ieee80211_ocb_work(struct ieee80211_sub_if_data *sdata);
  1298. void ieee80211_ocb_rx_no_sta(struct ieee80211_sub_if_data *sdata,
  1299. const u8 *bssid, const u8 *addr, u32 supp_rates);
  1300. void ieee80211_ocb_setup_sdata(struct ieee80211_sub_if_data *sdata);
  1301. int ieee80211_ocb_join(struct ieee80211_sub_if_data *sdata,
  1302. struct ocb_setup *setup);
  1303. int ieee80211_ocb_leave(struct ieee80211_sub_if_data *sdata);
  1304. /* mesh code */
  1305. void ieee80211_mesh_work(struct ieee80211_sub_if_data *sdata);
  1306. void ieee80211_mesh_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
  1307. struct sk_buff *skb);
  1308. int ieee80211_mesh_csa_beacon(struct ieee80211_sub_if_data *sdata,
  1309. struct cfg80211_csa_settings *csa_settings);
  1310. int ieee80211_mesh_finish_csa(struct ieee80211_sub_if_data *sdata);
  1311. /* scan/BSS handling */
  1312. void ieee80211_scan_work(struct work_struct *work);
  1313. int ieee80211_request_ibss_scan(struct ieee80211_sub_if_data *sdata,
  1314. const u8 *ssid, u8 ssid_len,
  1315. struct ieee80211_channel **channels,
  1316. unsigned int n_channels,
  1317. enum nl80211_bss_scan_width scan_width);
  1318. int ieee80211_request_scan(struct ieee80211_sub_if_data *sdata,
  1319. struct cfg80211_scan_request *req);
  1320. void ieee80211_scan_cancel(struct ieee80211_local *local);
  1321. void ieee80211_run_deferred_scan(struct ieee80211_local *local);
  1322. void ieee80211_scan_rx(struct ieee80211_local *local, struct sk_buff *skb);
  1323. void ieee80211_mlme_notify_scan_completed(struct ieee80211_local *local);
  1324. struct ieee80211_bss *
  1325. ieee80211_bss_info_update(struct ieee80211_local *local,
  1326. struct ieee80211_rx_status *rx_status,
  1327. struct ieee80211_mgmt *mgmt,
  1328. size_t len,
  1329. struct ieee802_11_elems *elems,
  1330. struct ieee80211_channel *channel);
  1331. void ieee80211_rx_bss_put(struct ieee80211_local *local,
  1332. struct ieee80211_bss *bss);
  1333. /* scheduled scan handling */
  1334. int
  1335. __ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata,
  1336. struct cfg80211_sched_scan_request *req);
  1337. int ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata,
  1338. struct cfg80211_sched_scan_request *req);
  1339. int ieee80211_request_sched_scan_stop(struct ieee80211_sub_if_data *sdata);
  1340. void ieee80211_sched_scan_end(struct ieee80211_local *local);
  1341. void ieee80211_sched_scan_stopped_work(struct work_struct *work);
  1342. /* off-channel helpers */
  1343. void ieee80211_offchannel_stop_vifs(struct ieee80211_local *local);
  1344. void ieee80211_offchannel_return(struct ieee80211_local *local);
  1345. void ieee80211_roc_setup(struct ieee80211_local *local);
  1346. void ieee80211_start_next_roc(struct ieee80211_local *local);
  1347. void ieee80211_roc_purge(struct ieee80211_local *local,
  1348. struct ieee80211_sub_if_data *sdata);
  1349. void ieee80211_roc_notify_destroy(struct ieee80211_roc_work *roc, bool free);
  1350. void ieee80211_sw_roc_work(struct work_struct *work);
  1351. void ieee80211_handle_roc_started(struct ieee80211_roc_work *roc);
  1352. /* channel switch handling */
  1353. void ieee80211_csa_finalize_work(struct work_struct *work);
  1354. int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
  1355. struct cfg80211_csa_settings *params);
  1356. /* interface handling */
  1357. int ieee80211_iface_init(void);
  1358. void ieee80211_iface_exit(void);
  1359. int ieee80211_if_add(struct ieee80211_local *local, const char *name,
  1360. unsigned char name_assign_type,
  1361. struct wireless_dev **new_wdev, enum nl80211_iftype type,
  1362. struct vif_params *params);
  1363. int ieee80211_if_change_type(struct ieee80211_sub_if_data *sdata,
  1364. enum nl80211_iftype type);
  1365. void ieee80211_if_remove(struct ieee80211_sub_if_data *sdata);
  1366. void ieee80211_remove_interfaces(struct ieee80211_local *local);
  1367. u32 ieee80211_idle_off(struct ieee80211_local *local);
  1368. void ieee80211_recalc_idle(struct ieee80211_local *local);
  1369. void ieee80211_adjust_monitor_flags(struct ieee80211_sub_if_data *sdata,
  1370. const int offset);
  1371. int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up);
  1372. void ieee80211_sdata_stop(struct ieee80211_sub_if_data *sdata);
  1373. int ieee80211_add_virtual_monitor(struct ieee80211_local *local);
  1374. void ieee80211_del_virtual_monitor(struct ieee80211_local *local);
  1375. bool __ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata);
  1376. void ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata,
  1377. bool update_bss);
  1378. static inline bool ieee80211_sdata_running(struct ieee80211_sub_if_data *sdata)
  1379. {
  1380. return test_bit(SDATA_STATE_RUNNING, &sdata->state);
  1381. }
  1382. /* tx handling */
  1383. void ieee80211_clear_tx_pending(struct ieee80211_local *local);
  1384. void ieee80211_tx_pending(unsigned long data);
  1385. netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb,
  1386. struct net_device *dev);
  1387. netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
  1388. struct net_device *dev);
  1389. void __ieee80211_subif_start_xmit(struct sk_buff *skb,
  1390. struct net_device *dev,
  1391. u32 info_flags);
  1392. void ieee80211_purge_tx_queue(struct ieee80211_hw *hw,
  1393. struct sk_buff_head *skbs);
  1394. struct sk_buff *
  1395. ieee80211_build_data_template(struct ieee80211_sub_if_data *sdata,
  1396. struct sk_buff *skb, u32 info_flags);
  1397. /* HT */
  1398. void ieee80211_apply_htcap_overrides(struct ieee80211_sub_if_data *sdata,
  1399. struct ieee80211_sta_ht_cap *ht_cap);
  1400. bool ieee80211_ht_cap_ie_to_sta_ht_cap(struct ieee80211_sub_if_data *sdata,
  1401. struct ieee80211_supported_band *sband,
  1402. const struct ieee80211_ht_cap *ht_cap_ie,
  1403. struct sta_info *sta);
  1404. void ieee80211_send_delba(struct ieee80211_sub_if_data *sdata,
  1405. const u8 *da, u16 tid,
  1406. u16 initiator, u16 reason_code);
  1407. int ieee80211_send_smps_action(struct ieee80211_sub_if_data *sdata,
  1408. enum ieee80211_smps_mode smps, const u8 *da,
  1409. const u8 *bssid);
  1410. void ieee80211_request_smps_ap_work(struct work_struct *work);
  1411. void ieee80211_request_smps_mgd_work(struct work_struct *work);
  1412. bool ieee80211_smps_is_restrictive(enum ieee80211_smps_mode smps_mode_old,
  1413. enum ieee80211_smps_mode smps_mode_new);
  1414. void ___ieee80211_stop_rx_ba_session(struct sta_info *sta, u16 tid,
  1415. u16 initiator, u16 reason, bool stop);
  1416. void __ieee80211_stop_rx_ba_session(struct sta_info *sta, u16 tid,
  1417. u16 initiator, u16 reason, bool stop);
  1418. void __ieee80211_start_rx_ba_session(struct sta_info *sta,
  1419. u8 dialog_token, u16 timeout,
  1420. u16 start_seq_num, u16 ba_policy, u16 tid,
  1421. u16 buf_size, bool tx, bool auto_seq);
  1422. void ieee80211_sta_tear_down_BA_sessions(struct sta_info *sta,
  1423. enum ieee80211_agg_stop_reason reason);
  1424. void ieee80211_process_delba(struct ieee80211_sub_if_data *sdata,
  1425. struct sta_info *sta,
  1426. struct ieee80211_mgmt *mgmt, size_t len);
  1427. void ieee80211_process_addba_resp(struct ieee80211_local *local,
  1428. struct sta_info *sta,
  1429. struct ieee80211_mgmt *mgmt,
  1430. size_t len);
  1431. void ieee80211_process_addba_request(struct ieee80211_local *local,
  1432. struct sta_info *sta,
  1433. struct ieee80211_mgmt *mgmt,
  1434. size_t len);
  1435. int __ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid,
  1436. enum ieee80211_agg_stop_reason reason);
  1437. int ___ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid,
  1438. enum ieee80211_agg_stop_reason reason);
  1439. void ieee80211_start_tx_ba_cb(struct ieee80211_vif *vif, u8 *ra, u16 tid);
  1440. void ieee80211_stop_tx_ba_cb(struct ieee80211_vif *vif, u8 *ra, u8 tid);
  1441. void ieee80211_ba_session_work(struct work_struct *work);
  1442. void ieee80211_tx_ba_session_handle_start(struct sta_info *sta, int tid);
  1443. void ieee80211_release_reorder_timeout(struct sta_info *sta, int tid);
  1444. u8 ieee80211_mcs_to_chains(const struct ieee80211_mcs_info *mcs);
  1445. /* VHT */
  1446. void
  1447. ieee80211_vht_cap_ie_to_sta_vht_cap(struct ieee80211_sub_if_data *sdata,
  1448. struct ieee80211_supported_band *sband,
  1449. const struct ieee80211_vht_cap *vht_cap_ie,
  1450. struct sta_info *sta);
  1451. enum ieee80211_sta_rx_bandwidth ieee80211_sta_cap_rx_bw(struct sta_info *sta);
  1452. enum ieee80211_sta_rx_bandwidth ieee80211_sta_cur_vht_bw(struct sta_info *sta);
  1453. void ieee80211_sta_set_rx_nss(struct sta_info *sta);
  1454. u32 __ieee80211_vht_handle_opmode(struct ieee80211_sub_if_data *sdata,
  1455. struct sta_info *sta, u8 opmode,
  1456. enum ieee80211_band band, bool nss_only);
  1457. void ieee80211_vht_handle_opmode(struct ieee80211_sub_if_data *sdata,
  1458. struct sta_info *sta, u8 opmode,
  1459. enum ieee80211_band band, bool nss_only);
  1460. void ieee80211_apply_vhtcap_overrides(struct ieee80211_sub_if_data *sdata,
  1461. struct ieee80211_sta_vht_cap *vht_cap);
  1462. /* Spectrum management */
  1463. void ieee80211_process_measurement_req(struct ieee80211_sub_if_data *sdata,
  1464. struct ieee80211_mgmt *mgmt,
  1465. size_t len);
  1466. /**
  1467. * ieee80211_parse_ch_switch_ie - parses channel switch IEs
  1468. * @sdata: the sdata of the interface which has received the frame
  1469. * @elems: parsed 802.11 elements received with the frame
  1470. * @current_band: indicates the current band
  1471. * @sta_flags: contains information about own capabilities and restrictions
  1472. * to decide which channel switch announcements can be accepted. Only the
  1473. * following subset of &enum ieee80211_sta_flags are evaluated:
  1474. * %IEEE80211_STA_DISABLE_HT, %IEEE80211_STA_DISABLE_VHT,
  1475. * %IEEE80211_STA_DISABLE_40MHZ, %IEEE80211_STA_DISABLE_80P80MHZ,
  1476. * %IEEE80211_STA_DISABLE_160MHZ.
  1477. * @bssid: the currently connected bssid (for reporting)
  1478. * @csa_ie: parsed 802.11 csa elements on count, mode, chandef and mesh ttl.
  1479. All of them will be filled with if success only.
  1480. * Return: 0 on success, <0 on error and >0 if there is nothing to parse.
  1481. */
  1482. int ieee80211_parse_ch_switch_ie(struct ieee80211_sub_if_data *sdata,
  1483. struct ieee802_11_elems *elems,
  1484. enum ieee80211_band current_band,
  1485. u32 sta_flags, u8 *bssid,
  1486. struct ieee80211_csa_ie *csa_ie);
  1487. /* Suspend/resume and hw reconfiguration */
  1488. int ieee80211_reconfig(struct ieee80211_local *local);
  1489. void ieee80211_stop_device(struct ieee80211_local *local);
  1490. int __ieee80211_suspend(struct ieee80211_hw *hw,
  1491. struct cfg80211_wowlan *wowlan);
  1492. static inline int __ieee80211_resume(struct ieee80211_hw *hw)
  1493. {
  1494. struct ieee80211_local *local = hw_to_local(hw);
  1495. WARN(test_bit(SCAN_HW_SCANNING, &local->scanning) &&
  1496. !test_bit(SCAN_COMPLETED, &local->scanning),
  1497. "%s: resume with hardware scan still in progress\n",
  1498. wiphy_name(hw->wiphy));
  1499. return ieee80211_reconfig(hw_to_local(hw));
  1500. }
  1501. /* utility functions/constants */
  1502. extern const void *const mac80211_wiphy_privid; /* for wiphy privid */
  1503. u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len,
  1504. enum nl80211_iftype type);
  1505. int ieee80211_frame_duration(enum ieee80211_band band, size_t len,
  1506. int rate, int erp, int short_preamble,
  1507. int shift);
  1508. void mac80211_ev_michael_mic_failure(struct ieee80211_sub_if_data *sdata, int keyidx,
  1509. struct ieee80211_hdr *hdr, const u8 *tsc,
  1510. gfp_t gfp);
  1511. void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata,
  1512. bool bss_notify);
  1513. void ieee80211_xmit(struct ieee80211_sub_if_data *sdata,
  1514. struct sta_info *sta, struct sk_buff *skb);
  1515. void __ieee80211_tx_skb_tid_band(struct ieee80211_sub_if_data *sdata,
  1516. struct sk_buff *skb, int tid,
  1517. enum ieee80211_band band);
  1518. static inline void
  1519. ieee80211_tx_skb_tid_band(struct ieee80211_sub_if_data *sdata,
  1520. struct sk_buff *skb, int tid,
  1521. enum ieee80211_band band)
  1522. {
  1523. rcu_read_lock();
  1524. __ieee80211_tx_skb_tid_band(sdata, skb, tid, band);
  1525. rcu_read_unlock();
  1526. }
  1527. static inline void ieee80211_tx_skb_tid(struct ieee80211_sub_if_data *sdata,
  1528. struct sk_buff *skb, int tid)
  1529. {
  1530. struct ieee80211_chanctx_conf *chanctx_conf;
  1531. rcu_read_lock();
  1532. chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
  1533. if (WARN_ON(!chanctx_conf)) {
  1534. rcu_read_unlock();
  1535. kfree_skb(skb);
  1536. return;
  1537. }
  1538. __ieee80211_tx_skb_tid_band(sdata, skb, tid,
  1539. chanctx_conf->def.chan->band);
  1540. rcu_read_unlock();
  1541. }
  1542. static inline void ieee80211_tx_skb(struct ieee80211_sub_if_data *sdata,
  1543. struct sk_buff *skb)
  1544. {
  1545. /* Send all internal mgmt frames on VO. Accordingly set TID to 7. */
  1546. ieee80211_tx_skb_tid(sdata, skb, 7);
  1547. }
  1548. u32 ieee802_11_parse_elems_crc(const u8 *start, size_t len, bool action,
  1549. struct ieee802_11_elems *elems,
  1550. u64 filter, u32 crc);
  1551. static inline void ieee802_11_parse_elems(const u8 *start, size_t len,
  1552. bool action,
  1553. struct ieee802_11_elems *elems)
  1554. {
  1555. ieee802_11_parse_elems_crc(start, len, action, elems, 0, 0);
  1556. }
  1557. static inline bool ieee80211_rx_reorder_ready(struct sk_buff_head *frames)
  1558. {
  1559. struct sk_buff *tail = skb_peek_tail(frames);
  1560. struct ieee80211_rx_status *status;
  1561. if (!tail)
  1562. return false;
  1563. status = IEEE80211_SKB_RXCB(tail);
  1564. if (status->flag & RX_FLAG_AMSDU_MORE)
  1565. return false;
  1566. return true;
  1567. }
  1568. extern const int ieee802_1d_to_ac[8];
  1569. static inline int ieee80211_ac_from_tid(int tid)
  1570. {
  1571. return ieee802_1d_to_ac[tid & 7];
  1572. }
  1573. void ieee80211_dynamic_ps_enable_work(struct work_struct *work);
  1574. void ieee80211_dynamic_ps_disable_work(struct work_struct *work);
  1575. void ieee80211_dynamic_ps_timer(unsigned long data);
  1576. void ieee80211_send_nullfunc(struct ieee80211_local *local,
  1577. struct ieee80211_sub_if_data *sdata,
  1578. int powersave);
  1579. void ieee80211_sta_rx_notify(struct ieee80211_sub_if_data *sdata,
  1580. struct ieee80211_hdr *hdr);
  1581. void ieee80211_sta_tx_notify(struct ieee80211_sub_if_data *sdata,
  1582. struct ieee80211_hdr *hdr, bool ack, u16 tx_time);
  1583. void ieee80211_wake_queues_by_reason(struct ieee80211_hw *hw,
  1584. unsigned long queues,
  1585. enum queue_stop_reason reason,
  1586. bool refcounted);
  1587. void ieee80211_stop_vif_queues(struct ieee80211_local *local,
  1588. struct ieee80211_sub_if_data *sdata,
  1589. enum queue_stop_reason reason);
  1590. void ieee80211_wake_vif_queues(struct ieee80211_local *local,
  1591. struct ieee80211_sub_if_data *sdata,
  1592. enum queue_stop_reason reason);
  1593. void ieee80211_stop_queues_by_reason(struct ieee80211_hw *hw,
  1594. unsigned long queues,
  1595. enum queue_stop_reason reason,
  1596. bool refcounted);
  1597. void ieee80211_wake_queue_by_reason(struct ieee80211_hw *hw, int queue,
  1598. enum queue_stop_reason reason,
  1599. bool refcounted);
  1600. void ieee80211_stop_queue_by_reason(struct ieee80211_hw *hw, int queue,
  1601. enum queue_stop_reason reason,
  1602. bool refcounted);
  1603. void ieee80211_propagate_queue_wake(struct ieee80211_local *local, int queue);
  1604. void ieee80211_add_pending_skb(struct ieee80211_local *local,
  1605. struct sk_buff *skb);
  1606. void ieee80211_add_pending_skbs(struct ieee80211_local *local,
  1607. struct sk_buff_head *skbs);
  1608. void ieee80211_flush_queues(struct ieee80211_local *local,
  1609. struct ieee80211_sub_if_data *sdata, bool drop);
  1610. void __ieee80211_flush_queues(struct ieee80211_local *local,
  1611. struct ieee80211_sub_if_data *sdata,
  1612. unsigned int queues, bool drop);
  1613. static inline bool ieee80211_can_run_worker(struct ieee80211_local *local)
  1614. {
  1615. /*
  1616. * If quiescing is set, we are racing with __ieee80211_suspend.
  1617. * __ieee80211_suspend flushes the workers after setting quiescing,
  1618. * and we check quiescing / suspended before enqueing new workers.
  1619. * We should abort the worker to avoid the races below.
  1620. */
  1621. if (local->quiescing)
  1622. return false;
  1623. /*
  1624. * We might already be suspended if the following scenario occurs:
  1625. * __ieee80211_suspend Control path
  1626. *
  1627. * if (local->quiescing)
  1628. * return;
  1629. * local->quiescing = true;
  1630. * flush_workqueue();
  1631. * queue_work(...);
  1632. * local->suspended = true;
  1633. * local->quiescing = false;
  1634. * worker starts running...
  1635. */
  1636. if (local->suspended)
  1637. return false;
  1638. return true;
  1639. }
  1640. void ieee80211_init_tx_queue(struct ieee80211_sub_if_data *sdata,
  1641. struct sta_info *sta,
  1642. struct txq_info *txq, int tid);
  1643. void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata,
  1644. u16 transaction, u16 auth_alg, u16 status,
  1645. const u8 *extra, size_t extra_len, const u8 *bssid,
  1646. const u8 *da, const u8 *key, u8 key_len, u8 key_idx,
  1647. u32 tx_flags);
  1648. void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata,
  1649. const u8 *bssid, u16 stype, u16 reason,
  1650. bool send_frame, u8 *frame_buf);
  1651. int ieee80211_build_preq_ies(struct ieee80211_local *local, u8 *buffer,
  1652. size_t buffer_len,
  1653. struct ieee80211_scan_ies *ie_desc,
  1654. const u8 *ie, size_t ie_len,
  1655. u8 bands_used, u32 *rate_masks,
  1656. struct cfg80211_chan_def *chandef);
  1657. struct sk_buff *ieee80211_build_probe_req(struct ieee80211_sub_if_data *sdata,
  1658. const u8 *src, const u8 *dst,
  1659. u32 ratemask,
  1660. struct ieee80211_channel *chan,
  1661. const u8 *ssid, size_t ssid_len,
  1662. const u8 *ie, size_t ie_len,
  1663. bool directed);
  1664. void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata,
  1665. const u8 *src, const u8 *dst,
  1666. const u8 *ssid, size_t ssid_len,
  1667. const u8 *ie, size_t ie_len,
  1668. u32 ratemask, bool directed, u32 tx_flags,
  1669. struct ieee80211_channel *channel, bool scan);
  1670. u32 ieee80211_sta_get_rates(struct ieee80211_sub_if_data *sdata,
  1671. struct ieee802_11_elems *elems,
  1672. enum ieee80211_band band, u32 *basic_rates);
  1673. int __ieee80211_request_smps_mgd(struct ieee80211_sub_if_data *sdata,
  1674. enum ieee80211_smps_mode smps_mode);
  1675. int __ieee80211_request_smps_ap(struct ieee80211_sub_if_data *sdata,
  1676. enum ieee80211_smps_mode smps_mode);
  1677. void ieee80211_recalc_smps(struct ieee80211_sub_if_data *sdata);
  1678. void ieee80211_recalc_min_chandef(struct ieee80211_sub_if_data *sdata);
  1679. size_t ieee80211_ie_split_vendor(const u8 *ies, size_t ielen, size_t offset);
  1680. u8 *ieee80211_ie_build_ht_cap(u8 *pos, struct ieee80211_sta_ht_cap *ht_cap,
  1681. u16 cap);
  1682. u8 *ieee80211_ie_build_ht_oper(u8 *pos, struct ieee80211_sta_ht_cap *ht_cap,
  1683. const struct cfg80211_chan_def *chandef,
  1684. u16 prot_mode);
  1685. u8 *ieee80211_ie_build_vht_cap(u8 *pos, struct ieee80211_sta_vht_cap *vht_cap,
  1686. u32 cap);
  1687. u8 *ieee80211_ie_build_vht_oper(u8 *pos, struct ieee80211_sta_vht_cap *vht_cap,
  1688. const struct cfg80211_chan_def *chandef);
  1689. int ieee80211_parse_bitrates(struct cfg80211_chan_def *chandef,
  1690. const struct ieee80211_supported_band *sband,
  1691. const u8 *srates, int srates_len, u32 *rates);
  1692. int ieee80211_add_srates_ie(struct ieee80211_sub_if_data *sdata,
  1693. struct sk_buff *skb, bool need_basic,
  1694. enum ieee80211_band band);
  1695. int ieee80211_add_ext_srates_ie(struct ieee80211_sub_if_data *sdata,
  1696. struct sk_buff *skb, bool need_basic,
  1697. enum ieee80211_band band);
  1698. u8 *ieee80211_add_wmm_info_ie(u8 *buf, u8 qosinfo);
  1699. /* channel management */
  1700. void ieee80211_ht_oper_to_chandef(struct ieee80211_channel *control_chan,
  1701. const struct ieee80211_ht_operation *ht_oper,
  1702. struct cfg80211_chan_def *chandef);
  1703. void ieee80211_vht_oper_to_chandef(struct ieee80211_channel *control_chan,
  1704. const struct ieee80211_vht_operation *oper,
  1705. struct cfg80211_chan_def *chandef);
  1706. u32 ieee80211_chandef_downgrade(struct cfg80211_chan_def *c);
  1707. int __must_check
  1708. ieee80211_vif_use_channel(struct ieee80211_sub_if_data *sdata,
  1709. const struct cfg80211_chan_def *chandef,
  1710. enum ieee80211_chanctx_mode mode);
  1711. int __must_check
  1712. ieee80211_vif_reserve_chanctx(struct ieee80211_sub_if_data *sdata,
  1713. const struct cfg80211_chan_def *chandef,
  1714. enum ieee80211_chanctx_mode mode,
  1715. bool radar_required);
  1716. int __must_check
  1717. ieee80211_vif_use_reserved_context(struct ieee80211_sub_if_data *sdata);
  1718. int ieee80211_vif_unreserve_chanctx(struct ieee80211_sub_if_data *sdata);
  1719. int __must_check
  1720. ieee80211_vif_change_bandwidth(struct ieee80211_sub_if_data *sdata,
  1721. const struct cfg80211_chan_def *chandef,
  1722. u32 *changed);
  1723. void ieee80211_vif_release_channel(struct ieee80211_sub_if_data *sdata);
  1724. void ieee80211_vif_vlan_copy_chanctx(struct ieee80211_sub_if_data *sdata);
  1725. void ieee80211_vif_copy_chanctx_to_vlans(struct ieee80211_sub_if_data *sdata,
  1726. bool clear);
  1727. int ieee80211_chanctx_refcount(struct ieee80211_local *local,
  1728. struct ieee80211_chanctx *ctx);
  1729. void ieee80211_recalc_smps_chanctx(struct ieee80211_local *local,
  1730. struct ieee80211_chanctx *chanctx);
  1731. void ieee80211_recalc_chanctx_min_def(struct ieee80211_local *local,
  1732. struct ieee80211_chanctx *ctx);
  1733. bool ieee80211_is_radar_required(struct ieee80211_local *local);
  1734. void ieee80211_dfs_cac_timer(unsigned long data);
  1735. void ieee80211_dfs_cac_timer_work(struct work_struct *work);
  1736. void ieee80211_dfs_cac_cancel(struct ieee80211_local *local);
  1737. void ieee80211_dfs_radar_detected_work(struct work_struct *work);
  1738. int ieee80211_send_action_csa(struct ieee80211_sub_if_data *sdata,
  1739. struct cfg80211_csa_settings *csa_settings);
  1740. bool ieee80211_cs_valid(const struct ieee80211_cipher_scheme *cs);
  1741. bool ieee80211_cs_list_valid(const struct ieee80211_cipher_scheme *cs, int n);
  1742. const struct ieee80211_cipher_scheme *
  1743. ieee80211_cs_get(struct ieee80211_local *local, u32 cipher,
  1744. enum nl80211_iftype iftype);
  1745. int ieee80211_cs_headroom(struct ieee80211_local *local,
  1746. struct cfg80211_crypto_settings *crypto,
  1747. enum nl80211_iftype iftype);
  1748. void ieee80211_recalc_dtim(struct ieee80211_local *local,
  1749. struct ieee80211_sub_if_data *sdata);
  1750. int ieee80211_check_combinations(struct ieee80211_sub_if_data *sdata,
  1751. const struct cfg80211_chan_def *chandef,
  1752. enum ieee80211_chanctx_mode chanmode,
  1753. u8 radar_detect);
  1754. int ieee80211_max_num_channels(struct ieee80211_local *local);
  1755. /* TDLS */
  1756. int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
  1757. const u8 *peer, u8 action_code, u8 dialog_token,
  1758. u16 status_code, u32 peer_capability,
  1759. bool initiator, const u8 *extra_ies,
  1760. size_t extra_ies_len);
  1761. int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
  1762. const u8 *peer, enum nl80211_tdls_operation oper);
  1763. void ieee80211_tdls_peer_del_work(struct work_struct *wk);
  1764. int ieee80211_tdls_channel_switch(struct wiphy *wiphy, struct net_device *dev,
  1765. const u8 *addr, u8 oper_class,
  1766. struct cfg80211_chan_def *chandef);
  1767. void ieee80211_tdls_cancel_channel_switch(struct wiphy *wiphy,
  1768. struct net_device *dev,
  1769. const u8 *addr);
  1770. void ieee80211_process_tdls_channel_switch(struct ieee80211_sub_if_data *sdata,
  1771. struct sk_buff *skb);
  1772. extern const struct ethtool_ops ieee80211_ethtool_ops;
  1773. #ifdef CONFIG_MAC80211_NOINLINE
  1774. #define debug_noinline noinline
  1775. #else
  1776. #define debug_noinline
  1777. #endif
  1778. #endif /* IEEE80211_I_H */