ieee80211_i.h 89 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright 2002-2005, Instant802 Networks, Inc.
  4. * Copyright 2005, Devicescape Software, Inc.
  5. * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
  6. * Copyright 2007-2010 Johannes Berg <johannes@sipsolutions.net>
  7. * Copyright 2013-2015 Intel Mobile Communications GmbH
  8. * Copyright (C) 2018-2024 Intel Corporation
  9. */
  10. #ifndef IEEE80211_I_H
  11. #define IEEE80211_I_H
  12. #include <linux/kernel.h>
  13. #include <linux/device.h>
  14. #include <linux/if_ether.h>
  15. #include <linux/interrupt.h>
  16. #include <linux/list.h>
  17. #include <linux/netdevice.h>
  18. #include <linux/skbuff.h>
  19. #include <linux/workqueue.h>
  20. #include <linux/types.h>
  21. #include <linux/spinlock.h>
  22. #include <linux/etherdevice.h>
  23. #include <linux/leds.h>
  24. #include <linux/idr.h>
  25. #include <linux/rhashtable.h>
  26. #include <linux/rbtree.h>
  27. #include <kunit/visibility.h>
  28. #include <net/ieee80211_radiotap.h>
  29. #include <net/cfg80211.h>
  30. #include <net/mac80211.h>
  31. #include <net/fq.h>
  32. #include "key.h"
  33. #include "sta_info.h"
  34. #include "debug.h"
  35. #include "drop.h"
  36. extern const struct cfg80211_ops mac80211_config_ops;
  37. struct ieee80211_local;
  38. struct ieee80211_mesh_fast_tx;
  39. /* Maximum number of broadcast/multicast frames to buffer when some of the
  40. * associated stations are using power saving. */
  41. #define AP_MAX_BC_BUFFER 128
  42. /* Maximum number of frames buffered to all STAs, including multicast frames.
  43. * Note: increasing this limit increases the potential memory requirement. Each
  44. * frame can be up to about 2 kB long. */
  45. #define TOTAL_MAX_TX_BUFFER 512
  46. /* Required encryption head and tailroom */
  47. #define IEEE80211_ENCRYPT_HEADROOM 8
  48. #define IEEE80211_ENCRYPT_TAILROOM 18
  49. /* power level hasn't been configured (or set to automatic) */
  50. #define IEEE80211_UNSET_POWER_LEVEL INT_MIN
  51. /*
  52. * Some APs experience problems when working with U-APSD. Decreasing the
  53. * probability of that happening by using legacy mode for all ACs but VO isn't
  54. * enough.
  55. *
  56. * Cisco 4410N originally forced us to enable VO by default only because it
  57. * treated non-VO ACs as legacy.
  58. *
  59. * However some APs (notably Netgear R7000) silently reclassify packets to
  60. * different ACs. Since u-APSD ACs require trigger frames for frame retrieval
  61. * clients would never see some frames (e.g. ARP responses) or would fetch them
  62. * accidentally after a long time.
  63. *
  64. * It makes little sense to enable u-APSD queues by default because it needs
  65. * userspace applications to be aware of it to actually take advantage of the
  66. * possible additional powersavings. Implicitly depending on driver autotrigger
  67. * frame support doesn't make much sense.
  68. */
  69. #define IEEE80211_DEFAULT_UAPSD_QUEUES 0
  70. #define IEEE80211_DEFAULT_MAX_SP_LEN \
  71. IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL
  72. extern const u8 ieee80211_ac_to_qos_mask[IEEE80211_NUM_ACS];
  73. #define IEEE80211_DEAUTH_FRAME_LEN (24 /* hdr */ + 2 /* reason */)
  74. #define IEEE80211_MAX_NAN_INSTANCE_ID 255
  75. enum ieee80211_status_data {
  76. IEEE80211_STATUS_TYPE_MASK = 0x00f,
  77. IEEE80211_STATUS_TYPE_INVALID = 0,
  78. IEEE80211_STATUS_TYPE_SMPS = 1,
  79. IEEE80211_STATUS_TYPE_NEG_TTLM = 2,
  80. IEEE80211_STATUS_SUBDATA_MASK = 0x1ff0,
  81. };
  82. static inline bool
  83. ieee80211_sta_keep_active(struct sta_info *sta, u8 ac)
  84. {
  85. /* Keep a station's queues on the active list for deficit accounting
  86. * purposes if it was active or queued during the last 100ms.
  87. */
  88. return time_before_eq(jiffies, sta->airtime[ac].last_active + HZ / 10);
  89. }
  90. struct ieee80211_bss {
  91. u32 device_ts_beacon, device_ts_presp;
  92. bool wmm_used;
  93. bool uapsd_supported;
  94. #define IEEE80211_MAX_SUPP_RATES 32
  95. u8 supp_rates[IEEE80211_MAX_SUPP_RATES];
  96. size_t supp_rates_len;
  97. struct ieee80211_rate *beacon_rate;
  98. u32 vht_cap_info;
  99. /*
  100. * During association, we save an ERP value from a probe response so
  101. * that we can feed ERP info to the driver when handling the
  102. * association completes. these fields probably won't be up-to-date
  103. * otherwise, you probably don't want to use them.
  104. */
  105. bool has_erp_value;
  106. u8 erp_value;
  107. /* Keep track of the corruption of the last beacon/probe response. */
  108. u8 corrupt_data;
  109. /* Keep track of what bits of information we have valid info for. */
  110. u8 valid_data;
  111. };
  112. /**
  113. * enum ieee80211_bss_corrupt_data_flags - BSS data corruption flags
  114. * @IEEE80211_BSS_CORRUPT_BEACON: last beacon frame received was corrupted
  115. * @IEEE80211_BSS_CORRUPT_PROBE_RESP: last probe response received was corrupted
  116. *
  117. * These are bss flags that are attached to a bss in the
  118. * @corrupt_data field of &struct ieee80211_bss.
  119. */
  120. enum ieee80211_bss_corrupt_data_flags {
  121. IEEE80211_BSS_CORRUPT_BEACON = BIT(0),
  122. IEEE80211_BSS_CORRUPT_PROBE_RESP = BIT(1)
  123. };
  124. /**
  125. * enum ieee80211_bss_valid_data_flags - BSS valid data flags
  126. * @IEEE80211_BSS_VALID_WMM: WMM/UAPSD data was gathered from non-corrupt IE
  127. * @IEEE80211_BSS_VALID_RATES: Supported rates were gathered from non-corrupt IE
  128. * @IEEE80211_BSS_VALID_ERP: ERP flag was gathered from non-corrupt IE
  129. *
  130. * These are bss flags that are attached to a bss in the
  131. * @valid_data field of &struct ieee80211_bss. They show which parts
  132. * of the data structure were received as a result of an un-corrupted
  133. * beacon/probe response.
  134. */
  135. enum ieee80211_bss_valid_data_flags {
  136. IEEE80211_BSS_VALID_WMM = BIT(1),
  137. IEEE80211_BSS_VALID_RATES = BIT(2),
  138. IEEE80211_BSS_VALID_ERP = BIT(3)
  139. };
  140. typedef unsigned __bitwise ieee80211_tx_result;
  141. #define TX_CONTINUE ((__force ieee80211_tx_result) 0u)
  142. #define TX_DROP ((__force ieee80211_tx_result) 1u)
  143. #define TX_QUEUED ((__force ieee80211_tx_result) 2u)
  144. #define IEEE80211_TX_UNICAST BIT(1)
  145. #define IEEE80211_TX_PS_BUFFERED BIT(2)
  146. struct ieee80211_tx_data {
  147. struct sk_buff *skb;
  148. struct sk_buff_head skbs;
  149. struct ieee80211_local *local;
  150. struct ieee80211_sub_if_data *sdata;
  151. struct sta_info *sta;
  152. struct ieee80211_key *key;
  153. struct ieee80211_tx_rate rate;
  154. unsigned int flags;
  155. };
  156. /**
  157. * enum ieee80211_packet_rx_flags - packet RX flags
  158. * @IEEE80211_RX_AMSDU: a-MSDU packet
  159. * @IEEE80211_RX_MALFORMED_ACTION_FRM: action frame is malformed
  160. * @IEEE80211_RX_DEFERRED_RELEASE: frame was subjected to receive reordering
  161. *
  162. * These are per-frame flags that are attached to a frame in the
  163. * @rx_flags field of &struct ieee80211_rx_status.
  164. */
  165. enum ieee80211_packet_rx_flags {
  166. IEEE80211_RX_AMSDU = BIT(3),
  167. IEEE80211_RX_MALFORMED_ACTION_FRM = BIT(4),
  168. IEEE80211_RX_DEFERRED_RELEASE = BIT(5),
  169. };
  170. /**
  171. * enum ieee80211_rx_flags - RX data flags
  172. *
  173. * @IEEE80211_RX_CMNTR: received on cooked monitor already
  174. * @IEEE80211_RX_BEACON_REPORTED: This frame was already reported
  175. * to cfg80211_report_obss_beacon().
  176. *
  177. * These flags are used across handling multiple interfaces
  178. * for a single frame.
  179. */
  180. enum ieee80211_rx_flags {
  181. IEEE80211_RX_CMNTR = BIT(0),
  182. IEEE80211_RX_BEACON_REPORTED = BIT(1),
  183. };
  184. struct ieee80211_rx_data {
  185. struct list_head *list;
  186. struct sk_buff *skb;
  187. struct ieee80211_local *local;
  188. struct ieee80211_sub_if_data *sdata;
  189. struct ieee80211_link_data *link;
  190. struct sta_info *sta;
  191. struct link_sta_info *link_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. int link_id;
  208. union {
  209. struct {
  210. u32 iv32;
  211. u16 iv16;
  212. } tkip;
  213. struct {
  214. u8 pn[IEEE80211_CCMP_PN_LEN];
  215. } ccm_gcm;
  216. };
  217. };
  218. struct ieee80211_csa_settings {
  219. const u16 *counter_offsets_beacon;
  220. const u16 *counter_offsets_presp;
  221. int n_counter_offsets_beacon;
  222. int n_counter_offsets_presp;
  223. u8 count;
  224. };
  225. struct ieee80211_color_change_settings {
  226. u16 counter_offset_beacon;
  227. u16 counter_offset_presp;
  228. u8 count;
  229. };
  230. struct beacon_data {
  231. u8 *head, *tail;
  232. int head_len, tail_len;
  233. struct ieee80211_meshconf_ie *meshconf;
  234. u16 cntdwn_counter_offsets[IEEE80211_MAX_CNTDWN_COUNTERS_NUM];
  235. u8 cntdwn_current_counter;
  236. struct cfg80211_mbssid_elems *mbssid_ies;
  237. struct cfg80211_rnr_elems *rnr_ies;
  238. struct rcu_head rcu_head;
  239. };
  240. struct probe_resp {
  241. struct rcu_head rcu_head;
  242. int len;
  243. u16 cntdwn_counter_offsets[IEEE80211_MAX_CNTDWN_COUNTERS_NUM];
  244. u8 data[];
  245. };
  246. struct fils_discovery_data {
  247. struct rcu_head rcu_head;
  248. int len;
  249. u8 data[];
  250. };
  251. struct unsol_bcast_probe_resp_data {
  252. struct rcu_head rcu_head;
  253. int len;
  254. u8 data[];
  255. };
  256. struct ps_data {
  257. /* yes, this looks ugly, but guarantees that we can later use
  258. * bitmap_empty :)
  259. * NB: don't touch this bitmap, use sta_info_{set,clear}_tim_bit */
  260. u8 tim[sizeof(unsigned long) * BITS_TO_LONGS(IEEE80211_MAX_AID + 1)]
  261. __aligned(__alignof__(unsigned long));
  262. struct sk_buff_head bc_buf;
  263. atomic_t num_sta_ps; /* number of stations in PS mode */
  264. int dtim_count;
  265. bool dtim_bc_mc;
  266. };
  267. struct ieee80211_if_ap {
  268. struct list_head vlans; /* write-protected with RTNL and local->mtx */
  269. struct ps_data ps;
  270. atomic_t num_mcast_sta; /* number of stations receiving multicast */
  271. bool multicast_to_unicast;
  272. bool active;
  273. };
  274. struct ieee80211_if_vlan {
  275. struct list_head list; /* write-protected with RTNL and local->mtx */
  276. /* used for all tx if the VLAN is configured to 4-addr mode */
  277. struct sta_info __rcu *sta;
  278. atomic_t num_mcast_sta; /* number of stations receiving multicast */
  279. };
  280. struct mesh_stats {
  281. __u32 fwded_mcast; /* Mesh forwarded multicast frames */
  282. __u32 fwded_unicast; /* Mesh forwarded unicast frames */
  283. __u32 fwded_frames; /* Mesh total forwarded frames */
  284. __u32 dropped_frames_ttl; /* Not transmitted since mesh_ttl == 0*/
  285. __u32 dropped_frames_no_route; /* Not transmitted, no route found */
  286. };
  287. #define PREQ_Q_F_START 0x1
  288. #define PREQ_Q_F_REFRESH 0x2
  289. struct mesh_preq_queue {
  290. struct list_head list;
  291. u8 dst[ETH_ALEN];
  292. u8 flags;
  293. };
  294. struct ieee80211_roc_work {
  295. struct list_head list;
  296. struct ieee80211_sub_if_data *sdata;
  297. struct ieee80211_channel *chan;
  298. bool started, abort, hw_begun, notified;
  299. bool on_channel;
  300. unsigned long start_time;
  301. u32 duration, req_duration;
  302. struct sk_buff *frame;
  303. u64 cookie, mgmt_tx_cookie;
  304. enum ieee80211_roc_type type;
  305. };
  306. /* flags used in struct ieee80211_if_managed.flags */
  307. enum ieee80211_sta_flags {
  308. IEEE80211_STA_CONNECTION_POLL = BIT(1),
  309. IEEE80211_STA_CONTROL_PORT = BIT(2),
  310. IEEE80211_STA_MFP_ENABLED = BIT(6),
  311. IEEE80211_STA_UAPSD_ENABLED = BIT(7),
  312. IEEE80211_STA_NULLFUNC_ACKED = BIT(8),
  313. IEEE80211_STA_ENABLE_RRM = BIT(15),
  314. };
  315. enum ieee80211_conn_mode {
  316. IEEE80211_CONN_MODE_S1G,
  317. IEEE80211_CONN_MODE_LEGACY,
  318. IEEE80211_CONN_MODE_HT,
  319. IEEE80211_CONN_MODE_VHT,
  320. IEEE80211_CONN_MODE_HE,
  321. IEEE80211_CONN_MODE_EHT,
  322. };
  323. #define IEEE80211_CONN_MODE_HIGHEST IEEE80211_CONN_MODE_EHT
  324. enum ieee80211_conn_bw_limit {
  325. IEEE80211_CONN_BW_LIMIT_20,
  326. IEEE80211_CONN_BW_LIMIT_40,
  327. IEEE80211_CONN_BW_LIMIT_80,
  328. IEEE80211_CONN_BW_LIMIT_160, /* also 80+80 */
  329. IEEE80211_CONN_BW_LIMIT_320,
  330. };
  331. struct ieee80211_conn_settings {
  332. enum ieee80211_conn_mode mode;
  333. enum ieee80211_conn_bw_limit bw_limit;
  334. };
  335. extern const struct ieee80211_conn_settings ieee80211_conn_settings_unlimited;
  336. struct ieee80211_mgd_auth_data {
  337. struct cfg80211_bss *bss;
  338. unsigned long timeout;
  339. int tries;
  340. u16 algorithm, expected_transaction;
  341. u8 key[WLAN_KEY_LEN_WEP104];
  342. u8 key_len, key_idx;
  343. bool done, waiting;
  344. bool peer_confirmed;
  345. bool timeout_started;
  346. int link_id;
  347. u8 ap_addr[ETH_ALEN] __aligned(2);
  348. u16 sae_trans, sae_status;
  349. size_t data_len;
  350. u8 data[];
  351. };
  352. struct ieee80211_mgd_assoc_data {
  353. struct {
  354. struct cfg80211_bss *bss;
  355. u8 addr[ETH_ALEN] __aligned(2);
  356. u8 ap_ht_param;
  357. struct ieee80211_vht_cap ap_vht_cap;
  358. size_t elems_len;
  359. u8 *elems; /* pointing to inside ie[] below */
  360. struct ieee80211_conn_settings conn;
  361. u16 status;
  362. bool disabled;
  363. } link[IEEE80211_MLD_MAX_NUM_LINKS];
  364. u8 ap_addr[ETH_ALEN] __aligned(2);
  365. /* this is for a workaround, so we use it only for non-MLO */
  366. const u8 *supp_rates;
  367. u8 supp_rates_len;
  368. unsigned long timeout;
  369. int tries;
  370. u8 prev_ap_addr[ETH_ALEN];
  371. u8 ssid[IEEE80211_MAX_SSID_LEN];
  372. u8 ssid_len;
  373. bool wmm, uapsd;
  374. bool need_beacon;
  375. bool synced;
  376. bool timeout_started;
  377. bool comeback; /* whether the AP has requested association comeback */
  378. bool s1g;
  379. bool spp_amsdu;
  380. unsigned int assoc_link_id;
  381. u8 fils_nonces[2 * FILS_NONCE_LEN];
  382. u8 fils_kek[FILS_MAX_KEK_LEN];
  383. size_t fils_kek_len;
  384. size_t ie_len;
  385. u8 *ie_pos; /* used to fill ie[] with link[].elems */
  386. u8 ie[];
  387. };
  388. struct ieee80211_sta_tx_tspec {
  389. /* timestamp of the first packet in the time slice */
  390. unsigned long time_slice_start;
  391. u32 admitted_time; /* in usecs, unlike over the air */
  392. u8 tsid;
  393. s8 up; /* signed to be able to invalidate with -1 during teardown */
  394. /* consumed TX time in microseconds in the time slice */
  395. u32 consumed_tx_time;
  396. enum {
  397. TX_TSPEC_ACTION_NONE = 0,
  398. TX_TSPEC_ACTION_DOWNGRADE,
  399. TX_TSPEC_ACTION_STOP_DOWNGRADE,
  400. } action;
  401. bool downgraded;
  402. };
  403. /* Advertised TID-to-link mapping info */
  404. struct ieee80211_adv_ttlm_info {
  405. /* time in TUs at which the new mapping is established, or 0 if there is
  406. * no planned advertised TID-to-link mapping
  407. */
  408. u16 switch_time;
  409. u32 duration; /* duration of the planned T2L map in TUs */
  410. u16 map; /* map of usable links for all TIDs */
  411. bool active; /* whether the advertised mapping is active or not */
  412. };
  413. DECLARE_EWMA(beacon_signal, 4, 4)
  414. struct ieee80211_if_managed {
  415. struct timer_list timer;
  416. struct timer_list conn_mon_timer;
  417. struct timer_list bcn_mon_timer;
  418. struct wiphy_work monitor_work;
  419. struct wiphy_work beacon_connection_loss_work;
  420. struct wiphy_work csa_connection_drop_work;
  421. unsigned long beacon_timeout;
  422. unsigned long probe_timeout;
  423. int probe_send_count;
  424. bool nullfunc_failed;
  425. u8 connection_loss:1,
  426. driver_disconnect:1,
  427. reconnect:1,
  428. associated:1;
  429. struct ieee80211_mgd_auth_data *auth_data;
  430. struct ieee80211_mgd_assoc_data *assoc_data;
  431. bool powersave; /* powersave requested for this iface */
  432. bool broken_ap; /* AP is broken -- turn off powersave */
  433. unsigned int flags;
  434. u16 mcast_seq_last;
  435. bool status_acked;
  436. bool status_received;
  437. __le16 status_fc;
  438. enum {
  439. IEEE80211_MFP_DISABLED,
  440. IEEE80211_MFP_OPTIONAL,
  441. IEEE80211_MFP_REQUIRED
  442. } mfp; /* management frame protection */
  443. /*
  444. * Bitmask of enabled u-apsd queues,
  445. * IEEE80211_WMM_IE_STA_QOSINFO_AC_BE & co. Needs a new association
  446. * to take effect.
  447. */
  448. unsigned int uapsd_queues;
  449. /*
  450. * Maximum number of buffered frames AP can deliver during a
  451. * service period, IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL or similar.
  452. * Needs a new association to take effect.
  453. */
  454. unsigned int uapsd_max_sp_len;
  455. u8 use_4addr;
  456. /*
  457. * State variables for keeping track of RSSI of the AP currently
  458. * connected to and informing driver when RSSI has gone
  459. * below/above a certain threshold.
  460. */
  461. int rssi_min_thold, rssi_max_thold;
  462. struct ieee80211_ht_cap ht_capa; /* configured ht-cap over-rides */
  463. struct ieee80211_ht_cap ht_capa_mask; /* Valid parts of ht_capa */
  464. struct ieee80211_vht_cap vht_capa; /* configured VHT overrides */
  465. struct ieee80211_vht_cap vht_capa_mask; /* Valid parts of vht_capa */
  466. struct ieee80211_s1g_cap s1g_capa; /* configured S1G overrides */
  467. struct ieee80211_s1g_cap s1g_capa_mask; /* valid s1g_capa bits */
  468. /* TDLS support */
  469. u8 tdls_peer[ETH_ALEN] __aligned(2);
  470. struct wiphy_delayed_work tdls_peer_del_work;
  471. struct sk_buff *orig_teardown_skb; /* The original teardown skb */
  472. struct sk_buff *teardown_skb; /* A copy to send through the AP */
  473. spinlock_t teardown_lock; /* To lock changing teardown_skb */
  474. bool tdls_wider_bw_prohibited;
  475. /* WMM-AC TSPEC support */
  476. struct ieee80211_sta_tx_tspec tx_tspec[IEEE80211_NUM_ACS];
  477. /* Use a separate work struct so that we can do something here
  478. * while the sdata->work is flushing the queues, for example.
  479. * otherwise, in scenarios where we hardly get any traffic out
  480. * on the BE queue, but there's a lot of VO traffic, we might
  481. * get stuck in a downgraded situation and flush takes forever.
  482. */
  483. struct wiphy_delayed_work tx_tspec_wk;
  484. /* Information elements from the last transmitted (Re)Association
  485. * Request frame.
  486. */
  487. u8 *assoc_req_ies;
  488. size_t assoc_req_ies_len;
  489. struct wiphy_delayed_work ml_reconf_work;
  490. u16 removed_links;
  491. /* TID-to-link mapping support */
  492. struct wiphy_delayed_work ttlm_work;
  493. struct ieee80211_adv_ttlm_info ttlm_info;
  494. struct wiphy_work teardown_ttlm_work;
  495. /* dialog token enumerator for neg TTLM request */
  496. u8 dialog_token_alloc;
  497. struct wiphy_delayed_work neg_ttlm_timeout_work;
  498. };
  499. struct ieee80211_if_ibss {
  500. struct timer_list timer;
  501. struct wiphy_work csa_connection_drop_work;
  502. unsigned long last_scan_completed;
  503. u32 basic_rates;
  504. bool fixed_bssid;
  505. bool fixed_channel;
  506. bool privacy;
  507. bool control_port;
  508. bool userspace_handles_dfs;
  509. u8 bssid[ETH_ALEN] __aligned(2);
  510. u8 ssid[IEEE80211_MAX_SSID_LEN];
  511. u8 ssid_len, ie_len;
  512. u8 *ie;
  513. struct cfg80211_chan_def chandef;
  514. unsigned long ibss_join_req;
  515. /* probe response/beacon for IBSS */
  516. struct beacon_data __rcu *presp;
  517. struct ieee80211_ht_cap ht_capa; /* configured ht-cap over-rides */
  518. struct ieee80211_ht_cap ht_capa_mask; /* Valid parts of ht_capa */
  519. spinlock_t incomplete_lock;
  520. struct list_head incomplete_stations;
  521. enum {
  522. IEEE80211_IBSS_MLME_SEARCH,
  523. IEEE80211_IBSS_MLME_JOINED,
  524. } state;
  525. };
  526. /**
  527. * struct ieee80211_if_ocb - OCB mode state
  528. *
  529. * @housekeeping_timer: timer for periodic invocation of a housekeeping task
  530. * @wrkq_flags: OCB deferred task action
  531. * @incomplete_lock: delayed STA insertion lock
  532. * @incomplete_stations: list of STAs waiting for delayed insertion
  533. * @joined: indication if the interface is connected to an OCB network
  534. */
  535. struct ieee80211_if_ocb {
  536. struct timer_list housekeeping_timer;
  537. unsigned long wrkq_flags;
  538. spinlock_t incomplete_lock;
  539. struct list_head incomplete_stations;
  540. bool joined;
  541. };
  542. /**
  543. * struct ieee80211_mesh_sync_ops - Extensible synchronization framework interface
  544. *
  545. * these declarations define the interface, which enables
  546. * vendor-specific mesh synchronization
  547. *
  548. * @rx_bcn_presp: beacon/probe response was received
  549. * @adjust_tsf: TSF adjustment method
  550. */
  551. struct ieee80211_mesh_sync_ops {
  552. void (*rx_bcn_presp)(struct ieee80211_sub_if_data *sdata, u16 stype,
  553. struct ieee80211_mgmt *mgmt, unsigned int len,
  554. const struct ieee80211_meshconf_ie *mesh_cfg,
  555. struct ieee80211_rx_status *rx_status);
  556. /* should be called with beacon_data under RCU read lock */
  557. void (*adjust_tsf)(struct ieee80211_sub_if_data *sdata,
  558. struct beacon_data *beacon);
  559. /* add other framework functions here */
  560. };
  561. struct mesh_csa_settings {
  562. struct rcu_head rcu_head;
  563. struct cfg80211_csa_settings settings;
  564. };
  565. /**
  566. * struct mesh_table - mesh hash table
  567. *
  568. * @known_gates: list of known mesh gates and their mpaths by the station. The
  569. * gate's mpath may or may not be resolved and active.
  570. * @gates_lock: protects updates to known_gates
  571. * @rhead: the rhashtable containing struct mesh_paths, keyed by dest addr
  572. * @walk_head: linked list containing all mesh_path objects
  573. * @walk_lock: lock protecting walk_head
  574. * @entries: number of entries in the table
  575. */
  576. struct mesh_table {
  577. struct hlist_head known_gates;
  578. spinlock_t gates_lock;
  579. struct rhashtable rhead;
  580. struct hlist_head walk_head;
  581. spinlock_t walk_lock;
  582. atomic_t entries; /* Up to MAX_MESH_NEIGHBOURS */
  583. };
  584. /**
  585. * struct mesh_tx_cache - mesh fast xmit header cache
  586. *
  587. * @rht: hash table containing struct ieee80211_mesh_fast_tx, using skb DA as key
  588. * @walk_head: linked list containing all ieee80211_mesh_fast_tx objects
  589. * @walk_lock: lock protecting walk_head and rht
  590. */
  591. struct mesh_tx_cache {
  592. struct rhashtable rht;
  593. struct hlist_head walk_head;
  594. spinlock_t walk_lock;
  595. };
  596. struct ieee80211_if_mesh {
  597. struct timer_list housekeeping_timer;
  598. struct timer_list mesh_path_timer;
  599. struct timer_list mesh_path_root_timer;
  600. unsigned long wrkq_flags;
  601. unsigned long mbss_changed[64 / BITS_PER_LONG];
  602. bool userspace_handles_dfs;
  603. u8 mesh_id[IEEE80211_MAX_MESH_ID_LEN];
  604. size_t mesh_id_len;
  605. /* Active Path Selection Protocol Identifier */
  606. u8 mesh_pp_id;
  607. /* Active Path Selection Metric Identifier */
  608. u8 mesh_pm_id;
  609. /* Congestion Control Mode Identifier */
  610. u8 mesh_cc_id;
  611. /* Synchronization Protocol Identifier */
  612. u8 mesh_sp_id;
  613. /* Authentication Protocol Identifier */
  614. u8 mesh_auth_id;
  615. /* Local mesh Sequence Number */
  616. u32 sn;
  617. /* Last used PREQ ID */
  618. u32 preq_id;
  619. atomic_t mpaths;
  620. /* Timestamp of last SN update */
  621. unsigned long last_sn_update;
  622. /* Time when it's ok to send next PERR */
  623. unsigned long next_perr;
  624. /* Timestamp of last PREQ sent */
  625. unsigned long last_preq;
  626. struct mesh_rmc *rmc;
  627. spinlock_t mesh_preq_queue_lock;
  628. struct mesh_preq_queue preq_queue;
  629. int preq_queue_len;
  630. struct mesh_stats mshstats;
  631. struct mesh_config mshcfg;
  632. atomic_t estab_plinks;
  633. atomic_t mesh_seqnum;
  634. bool accepting_plinks;
  635. int num_gates;
  636. struct beacon_data __rcu *beacon;
  637. const u8 *ie;
  638. u8 ie_len;
  639. enum {
  640. IEEE80211_MESH_SEC_NONE = 0x0,
  641. IEEE80211_MESH_SEC_AUTHED = 0x1,
  642. IEEE80211_MESH_SEC_SECURED = 0x2,
  643. } security;
  644. bool user_mpm;
  645. /* Extensible Synchronization Framework */
  646. const struct ieee80211_mesh_sync_ops *sync_ops;
  647. s64 sync_offset_clockdrift_max;
  648. spinlock_t sync_offset_lock;
  649. /* mesh power save */
  650. enum nl80211_mesh_power_mode nonpeer_pm;
  651. int ps_peers_light_sleep;
  652. int ps_peers_deep_sleep;
  653. struct ps_data ps;
  654. /* Channel Switching Support */
  655. struct mesh_csa_settings __rcu *csa;
  656. enum {
  657. IEEE80211_MESH_CSA_ROLE_NONE,
  658. IEEE80211_MESH_CSA_ROLE_INIT,
  659. IEEE80211_MESH_CSA_ROLE_REPEATER,
  660. } csa_role;
  661. u8 chsw_ttl;
  662. u16 pre_value;
  663. /* offset from skb->data while building IE */
  664. int meshconf_offset;
  665. struct mesh_table mesh_paths;
  666. struct mesh_table mpp_paths; /* Store paths for MPP&MAP */
  667. int mesh_paths_generation;
  668. int mpp_paths_generation;
  669. struct mesh_tx_cache tx_cache;
  670. };
  671. #ifdef CONFIG_MAC80211_MESH
  672. #define IEEE80211_IFSTA_MESH_CTR_INC(msh, name) \
  673. do { (msh)->mshstats.name++; } while (0)
  674. #else
  675. #define IEEE80211_IFSTA_MESH_CTR_INC(msh, name) \
  676. do { } while (0)
  677. #endif
  678. /**
  679. * enum ieee80211_sub_if_data_flags - virtual interface flags
  680. *
  681. * @IEEE80211_SDATA_ALLMULTI: interface wants all multicast packets
  682. * @IEEE80211_SDATA_DONT_BRIDGE_PACKETS: bridge packets between
  683. * associated stations and deliver multicast frames both
  684. * back to wireless media and to the local net stack.
  685. * @IEEE80211_SDATA_DISCONNECT_RESUME: Disconnect after resume.
  686. * @IEEE80211_SDATA_IN_DRIVER: indicates interface was added to driver
  687. * @IEEE80211_SDATA_DISCONNECT_HW_RESTART: Disconnect after hardware restart
  688. * recovery
  689. */
  690. enum ieee80211_sub_if_data_flags {
  691. IEEE80211_SDATA_ALLMULTI = BIT(0),
  692. IEEE80211_SDATA_DONT_BRIDGE_PACKETS = BIT(3),
  693. IEEE80211_SDATA_DISCONNECT_RESUME = BIT(4),
  694. IEEE80211_SDATA_IN_DRIVER = BIT(5),
  695. IEEE80211_SDATA_DISCONNECT_HW_RESTART = BIT(6),
  696. };
  697. /**
  698. * enum ieee80211_sdata_state_bits - virtual interface state bits
  699. * @SDATA_STATE_RUNNING: virtual interface is up & running; this
  700. * mirrors netif_running() but is separate for interface type
  701. * change handling while the interface is up
  702. * @SDATA_STATE_OFFCHANNEL: This interface is currently in offchannel
  703. * mode, so queues are stopped
  704. * @SDATA_STATE_OFFCHANNEL_BEACON_STOPPED: Beaconing was stopped due
  705. * to offchannel, reset when offchannel returns
  706. */
  707. enum ieee80211_sdata_state_bits {
  708. SDATA_STATE_RUNNING,
  709. SDATA_STATE_OFFCHANNEL,
  710. SDATA_STATE_OFFCHANNEL_BEACON_STOPPED,
  711. };
  712. /**
  713. * enum ieee80211_chanctx_mode - channel context configuration mode
  714. *
  715. * @IEEE80211_CHANCTX_SHARED: channel context may be used by
  716. * multiple interfaces
  717. * @IEEE80211_CHANCTX_EXCLUSIVE: channel context can be used
  718. * only by a single interface. This can be used for example for
  719. * non-fixed channel IBSS.
  720. */
  721. enum ieee80211_chanctx_mode {
  722. IEEE80211_CHANCTX_SHARED,
  723. IEEE80211_CHANCTX_EXCLUSIVE
  724. };
  725. /**
  726. * enum ieee80211_chanctx_replace_state - channel context replacement state
  727. *
  728. * This is used for channel context in-place reservations that require channel
  729. * context switch/swap.
  730. *
  731. * @IEEE80211_CHANCTX_REPLACE_NONE: no replacement is taking place
  732. * @IEEE80211_CHANCTX_WILL_BE_REPLACED: this channel context will be replaced
  733. * by a (not yet registered) channel context pointed by %replace_ctx.
  734. * @IEEE80211_CHANCTX_REPLACES_OTHER: this (not yet registered) channel context
  735. * replaces an existing channel context pointed to by %replace_ctx.
  736. */
  737. enum ieee80211_chanctx_replace_state {
  738. IEEE80211_CHANCTX_REPLACE_NONE,
  739. IEEE80211_CHANCTX_WILL_BE_REPLACED,
  740. IEEE80211_CHANCTX_REPLACES_OTHER,
  741. };
  742. struct ieee80211_chanctx {
  743. struct list_head list;
  744. struct rcu_head rcu_head;
  745. struct list_head assigned_links;
  746. struct list_head reserved_links;
  747. enum ieee80211_chanctx_replace_state replace_state;
  748. struct ieee80211_chanctx *replace_ctx;
  749. enum ieee80211_chanctx_mode mode;
  750. bool driver_present;
  751. /* temporary data for search algorithm etc. */
  752. struct ieee80211_chan_req req;
  753. bool radar_detected;
  754. /* MUST be last - ends in a flexible-array member. */
  755. struct ieee80211_chanctx_conf conf;
  756. };
  757. struct mac80211_qos_map {
  758. struct cfg80211_qos_map qos_map;
  759. struct rcu_head rcu_head;
  760. };
  761. enum txq_info_flags {
  762. IEEE80211_TXQ_STOP,
  763. IEEE80211_TXQ_AMPDU,
  764. IEEE80211_TXQ_NO_AMSDU,
  765. IEEE80211_TXQ_DIRTY,
  766. };
  767. /**
  768. * struct txq_info - per tid queue
  769. *
  770. * @tin: contains packets split into multiple flows
  771. * @def_cvars: codel vars for the @tin's default_flow
  772. * @cstats: code statistics for this queue
  773. * @frags: used to keep fragments created after dequeue
  774. * @schedule_order: used with ieee80211_local->active_txqs
  775. * @schedule_round: counter to prevent infinite loops on TXQ scheduling
  776. * @flags: TXQ flags from &enum txq_info_flags
  777. * @txq: the driver visible part
  778. */
  779. struct txq_info {
  780. struct fq_tin tin;
  781. struct codel_vars def_cvars;
  782. struct codel_stats cstats;
  783. u16 schedule_round;
  784. struct list_head schedule_order;
  785. struct sk_buff_head frags;
  786. unsigned long flags;
  787. /* keep last! */
  788. struct ieee80211_txq txq;
  789. };
  790. struct ieee80211_if_mntr {
  791. u32 flags;
  792. u8 mu_follow_addr[ETH_ALEN] __aligned(2);
  793. struct list_head list;
  794. };
  795. /**
  796. * struct ieee80211_if_nan - NAN state
  797. *
  798. * @conf: current NAN configuration
  799. * @func_lock: lock for @func_inst_ids
  800. * @function_inst_ids: a bitmap of available instance_id's
  801. */
  802. struct ieee80211_if_nan {
  803. struct cfg80211_nan_conf conf;
  804. /* protects function_inst_ids */
  805. spinlock_t func_lock;
  806. struct idr function_inst_ids;
  807. };
  808. struct ieee80211_link_data_managed {
  809. u8 bssid[ETH_ALEN] __aligned(2);
  810. u8 dtim_period;
  811. enum ieee80211_smps_mode req_smps, /* requested smps mode */
  812. driver_smps_mode; /* smps mode request */
  813. struct ieee80211_conn_settings conn;
  814. s16 p2p_noa_index;
  815. bool tdls_chan_switch_prohibited;
  816. bool have_beacon;
  817. bool tracking_signal_avg;
  818. bool disable_wmm_tracking;
  819. bool operating_11g_mode;
  820. struct {
  821. struct wiphy_delayed_work switch_work;
  822. struct cfg80211_chan_def ap_chandef;
  823. struct ieee80211_parsed_tpe tpe;
  824. unsigned long time;
  825. bool waiting_bcn;
  826. bool ignored_same_chan;
  827. bool blocked_tx;
  828. } csa;
  829. struct wiphy_work request_smps_work;
  830. /* used to reconfigure hardware SM PS */
  831. struct wiphy_work recalc_smps;
  832. bool beacon_crc_valid;
  833. u32 beacon_crc;
  834. struct ewma_beacon_signal ave_beacon_signal;
  835. int last_ave_beacon_signal;
  836. /*
  837. * Number of Beacon frames used in ave_beacon_signal. This can be used
  838. * to avoid generating less reliable cqm events that would be based
  839. * only on couple of received frames.
  840. */
  841. unsigned int count_beacon_signal;
  842. /* Number of times beacon loss was invoked. */
  843. unsigned int beacon_loss_count;
  844. /*
  845. * Last Beacon frame signal strength average (ave_beacon_signal / 16)
  846. * that triggered a cqm event. 0 indicates that no event has been
  847. * generated for the current association.
  848. */
  849. int last_cqm_event_signal;
  850. int wmm_last_param_set;
  851. int mu_edca_last_param_set;
  852. u8 bss_param_ch_cnt;
  853. };
  854. struct ieee80211_link_data_ap {
  855. struct beacon_data __rcu *beacon;
  856. struct probe_resp __rcu *probe_resp;
  857. struct fils_discovery_data __rcu *fils_discovery;
  858. struct unsol_bcast_probe_resp_data __rcu *unsol_bcast_probe_resp;
  859. /* to be used after channel switch. */
  860. struct cfg80211_beacon_data *next_beacon;
  861. };
  862. struct ieee80211_link_data {
  863. struct ieee80211_sub_if_data *sdata;
  864. unsigned int link_id;
  865. struct list_head assigned_chanctx_list; /* protected by wiphy mutex */
  866. struct list_head reserved_chanctx_list; /* protected by wiphy mutex */
  867. /* multicast keys only */
  868. struct ieee80211_key __rcu *gtk[NUM_DEFAULT_KEYS +
  869. NUM_DEFAULT_MGMT_KEYS +
  870. NUM_DEFAULT_BEACON_KEYS];
  871. struct ieee80211_key __rcu *default_multicast_key;
  872. struct ieee80211_key __rcu *default_mgmt_key;
  873. struct ieee80211_key __rcu *default_beacon_key;
  874. bool operating_11g_mode;
  875. struct {
  876. struct wiphy_work finalize_work;
  877. struct ieee80211_chan_req chanreq;
  878. } csa;
  879. struct wiphy_work color_change_finalize_work;
  880. struct wiphy_delayed_work color_collision_detect_work;
  881. u64 color_bitmap;
  882. /* context reservation -- protected with wiphy mutex */
  883. struct ieee80211_chanctx *reserved_chanctx;
  884. struct ieee80211_chan_req reserved;
  885. bool reserved_radar_required;
  886. bool reserved_ready;
  887. u8 needed_rx_chains;
  888. enum ieee80211_smps_mode smps_mode;
  889. int user_power_level; /* in dBm */
  890. int ap_power_level; /* in dBm */
  891. bool radar_required;
  892. struct wiphy_delayed_work dfs_cac_timer_work;
  893. union {
  894. struct ieee80211_link_data_managed mgd;
  895. struct ieee80211_link_data_ap ap;
  896. } u;
  897. struct ieee80211_tx_queue_params tx_conf[IEEE80211_NUM_ACS];
  898. struct ieee80211_bss_conf *conf;
  899. #ifdef CONFIG_MAC80211_DEBUGFS
  900. struct dentry *debugfs_dir;
  901. #endif
  902. };
  903. struct ieee80211_sub_if_data {
  904. struct list_head list;
  905. struct wireless_dev wdev;
  906. /* keys */
  907. struct list_head key_list;
  908. /* count for keys needing tailroom space allocation */
  909. int crypto_tx_tailroom_needed_cnt;
  910. int crypto_tx_tailroom_pending_dec;
  911. struct wiphy_delayed_work dec_tailroom_needed_wk;
  912. struct net_device *dev;
  913. struct ieee80211_local *local;
  914. unsigned int flags;
  915. unsigned long state;
  916. char name[IFNAMSIZ];
  917. struct ieee80211_fragment_cache frags;
  918. /* TID bitmap for NoAck policy */
  919. u16 noack_map;
  920. /* bit field of ACM bits (BIT(802.1D tag)) */
  921. u8 wmm_acm;
  922. struct ieee80211_key __rcu *keys[NUM_DEFAULT_KEYS];
  923. struct ieee80211_key __rcu *default_unicast_key;
  924. u16 sequence_number;
  925. u16 mld_mcast_seq;
  926. __be16 control_port_protocol;
  927. bool control_port_no_encrypt;
  928. bool control_port_no_preauth;
  929. bool control_port_over_nl80211;
  930. atomic_t num_tx_queued;
  931. struct mac80211_qos_map __rcu *qos_map;
  932. struct wiphy_work work;
  933. struct sk_buff_head skb_queue;
  934. struct sk_buff_head status_queue;
  935. /*
  936. * AP this belongs to: self in AP mode and
  937. * corresponding AP in VLAN mode, NULL for
  938. * all others (might be needed later in IBSS)
  939. */
  940. struct ieee80211_if_ap *bss;
  941. /* bitmap of allowed (non-MCS) rate indexes for rate control */
  942. u32 rc_rateidx_mask[NUM_NL80211_BANDS];
  943. bool rc_has_mcs_mask[NUM_NL80211_BANDS];
  944. u8 rc_rateidx_mcs_mask[NUM_NL80211_BANDS][IEEE80211_HT_MCS_MASK_LEN];
  945. bool rc_has_vht_mcs_mask[NUM_NL80211_BANDS];
  946. u16 rc_rateidx_vht_mcs_mask[NUM_NL80211_BANDS][NL80211_VHT_NSS_MAX];
  947. /* Beacon frame (non-MCS) rate (as a bitmap) */
  948. u32 beacon_rateidx_mask[NUM_NL80211_BANDS];
  949. bool beacon_rate_set;
  950. union {
  951. struct ieee80211_if_ap ap;
  952. struct ieee80211_if_vlan vlan;
  953. struct ieee80211_if_managed mgd;
  954. struct ieee80211_if_ibss ibss;
  955. struct ieee80211_if_mesh mesh;
  956. struct ieee80211_if_ocb ocb;
  957. struct ieee80211_if_mntr mntr;
  958. struct ieee80211_if_nan nan;
  959. } u;
  960. struct ieee80211_link_data deflink;
  961. struct ieee80211_link_data __rcu *link[IEEE80211_MLD_MAX_NUM_LINKS];
  962. /* for ieee80211_set_active_links_async() */
  963. struct wiphy_work activate_links_work;
  964. u16 desired_active_links;
  965. u16 restart_active_links;
  966. #ifdef CONFIG_MAC80211_DEBUGFS
  967. struct {
  968. struct dentry *subdir_stations;
  969. struct dentry *default_unicast_key;
  970. struct dentry *default_multicast_key;
  971. struct dentry *default_mgmt_key;
  972. struct dentry *default_beacon_key;
  973. } debugfs;
  974. #endif
  975. /* must be last, dynamically sized area in this! */
  976. struct ieee80211_vif vif;
  977. };
  978. static inline
  979. struct ieee80211_sub_if_data *vif_to_sdata(struct ieee80211_vif *p)
  980. {
  981. return container_of(p, struct ieee80211_sub_if_data, vif);
  982. }
  983. #define sdata_dereference(p, sdata) \
  984. wiphy_dereference(sdata->local->hw.wiphy, p)
  985. #define for_each_sdata_link(_local, _link) \
  986. /* outer loop just to define the variables ... */ \
  987. for (struct ieee80211_sub_if_data *___sdata = NULL; \
  988. !___sdata; \
  989. ___sdata = (void *)~0 /* always stop */) \
  990. list_for_each_entry(___sdata, &(_local)->interfaces, list) \
  991. if (ieee80211_sdata_running(___sdata)) \
  992. for (int ___link_id = 0; \
  993. ___link_id < ARRAY_SIZE(___sdata->link); \
  994. ___link_id++) \
  995. if ((_link = wiphy_dereference((local)->hw.wiphy, \
  996. ___sdata->link[___link_id])))
  997. #define for_each_link_data(sdata, __link) \
  998. struct ieee80211_sub_if_data *__sdata = sdata; \
  999. for (int __link_id = 0; \
  1000. __link_id < ARRAY_SIZE((__sdata)->link); __link_id++) \
  1001. if ((!(__sdata)->vif.valid_links || \
  1002. (__sdata)->vif.valid_links & BIT(__link_id)) && \
  1003. ((__link) = sdata_dereference((__sdata)->link[__link_id], \
  1004. (__sdata))))
  1005. static inline int
  1006. ieee80211_get_mbssid_beacon_len(struct cfg80211_mbssid_elems *elems,
  1007. struct cfg80211_rnr_elems *rnr_elems,
  1008. u8 i)
  1009. {
  1010. int len = 0;
  1011. if (!elems || !elems->cnt || i > elems->cnt)
  1012. return 0;
  1013. if (i < elems->cnt) {
  1014. len = elems->elem[i].len;
  1015. if (rnr_elems) {
  1016. len += rnr_elems->elem[i].len;
  1017. for (i = elems->cnt; i < rnr_elems->cnt; i++)
  1018. len += rnr_elems->elem[i].len;
  1019. }
  1020. return len;
  1021. }
  1022. /* i == elems->cnt, calculate total length of all MBSSID elements */
  1023. for (i = 0; i < elems->cnt; i++)
  1024. len += elems->elem[i].len;
  1025. if (rnr_elems) {
  1026. for (i = 0; i < rnr_elems->cnt; i++)
  1027. len += rnr_elems->elem[i].len;
  1028. }
  1029. return len;
  1030. }
  1031. enum {
  1032. IEEE80211_RX_MSG = 1,
  1033. IEEE80211_TX_STATUS_MSG = 2,
  1034. };
  1035. enum queue_stop_reason {
  1036. IEEE80211_QUEUE_STOP_REASON_DRIVER,
  1037. IEEE80211_QUEUE_STOP_REASON_PS,
  1038. IEEE80211_QUEUE_STOP_REASON_CSA,
  1039. IEEE80211_QUEUE_STOP_REASON_AGGREGATION,
  1040. IEEE80211_QUEUE_STOP_REASON_SUSPEND,
  1041. IEEE80211_QUEUE_STOP_REASON_SKB_ADD,
  1042. IEEE80211_QUEUE_STOP_REASON_OFFCHANNEL,
  1043. IEEE80211_QUEUE_STOP_REASON_FLUSH,
  1044. IEEE80211_QUEUE_STOP_REASON_TDLS_TEARDOWN,
  1045. IEEE80211_QUEUE_STOP_REASON_RESERVE_TID,
  1046. IEEE80211_QUEUE_STOP_REASON_IFTYPE_CHANGE,
  1047. IEEE80211_QUEUE_STOP_REASONS,
  1048. };
  1049. #ifdef CONFIG_MAC80211_LEDS
  1050. struct tpt_led_trigger {
  1051. char name[32];
  1052. const struct ieee80211_tpt_blink *blink_table;
  1053. unsigned int blink_table_len;
  1054. struct timer_list timer;
  1055. struct ieee80211_local *local;
  1056. unsigned long prev_traffic;
  1057. unsigned long tx_bytes, rx_bytes;
  1058. unsigned int active, want;
  1059. bool running;
  1060. };
  1061. #endif
  1062. /**
  1063. * enum mac80211_scan_flags - currently active scan mode
  1064. *
  1065. * @SCAN_SW_SCANNING: We're currently in the process of scanning but may as
  1066. * well be on the operating channel
  1067. * @SCAN_HW_SCANNING: The hardware is scanning for us, we have no way to
  1068. * determine if we are on the operating channel or not
  1069. * @SCAN_ONCHANNEL_SCANNING: Do a software scan on only the current operating
  1070. * channel. This should not interrupt normal traffic.
  1071. * @SCAN_COMPLETED: Set for our scan work function when the driver reported
  1072. * that the scan completed.
  1073. * @SCAN_ABORTED: Set for our scan work function when the driver reported
  1074. * a scan complete for an aborted scan.
  1075. * @SCAN_HW_CANCELLED: Set for our scan work function when the scan is being
  1076. * cancelled.
  1077. * @SCAN_BEACON_WAIT: Set whenever we're passive scanning because of radar/no-IR
  1078. * and could send a probe request after receiving a beacon.
  1079. * @SCAN_BEACON_DONE: Beacon received, we can now send a probe request
  1080. */
  1081. enum mac80211_scan_flags {
  1082. SCAN_SW_SCANNING,
  1083. SCAN_HW_SCANNING,
  1084. SCAN_ONCHANNEL_SCANNING,
  1085. SCAN_COMPLETED,
  1086. SCAN_ABORTED,
  1087. SCAN_HW_CANCELLED,
  1088. SCAN_BEACON_WAIT,
  1089. SCAN_BEACON_DONE,
  1090. };
  1091. /**
  1092. * enum mac80211_scan_state - scan state machine states
  1093. *
  1094. * @SCAN_DECISION: Main entry point to the scan state machine, this state
  1095. * determines if we should keep on scanning or switch back to the
  1096. * operating channel
  1097. * @SCAN_SET_CHANNEL: Set the next channel to be scanned
  1098. * @SCAN_SEND_PROBE: Send probe requests and wait for probe responses
  1099. * @SCAN_SUSPEND: Suspend the scan and go back to operating channel to
  1100. * send out data
  1101. * @SCAN_RESUME: Resume the scan and scan the next channel
  1102. * @SCAN_ABORT: Abort the scan and go back to operating channel
  1103. */
  1104. enum mac80211_scan_state {
  1105. SCAN_DECISION,
  1106. SCAN_SET_CHANNEL,
  1107. SCAN_SEND_PROBE,
  1108. SCAN_SUSPEND,
  1109. SCAN_RESUME,
  1110. SCAN_ABORT,
  1111. };
  1112. DECLARE_STATIC_KEY_FALSE(aql_disable);
  1113. struct ieee80211_local {
  1114. /* embed the driver visible part.
  1115. * don't cast (use the static inlines below), but we keep
  1116. * it first anyway so they become a no-op */
  1117. struct ieee80211_hw hw;
  1118. struct fq fq;
  1119. struct codel_vars *cvars;
  1120. struct codel_params cparams;
  1121. /* protects active_txqs and txqi->schedule_order */
  1122. spinlock_t active_txq_lock[IEEE80211_NUM_ACS];
  1123. struct list_head active_txqs[IEEE80211_NUM_ACS];
  1124. u16 schedule_round[IEEE80211_NUM_ACS];
  1125. /* serializes ieee80211_handle_wake_tx_queue */
  1126. spinlock_t handle_wake_tx_queue_lock;
  1127. u16 airtime_flags;
  1128. u32 aql_txq_limit_low[IEEE80211_NUM_ACS];
  1129. u32 aql_txq_limit_high[IEEE80211_NUM_ACS];
  1130. u32 aql_threshold;
  1131. atomic_t aql_total_pending_airtime;
  1132. atomic_t aql_ac_pending_airtime[IEEE80211_NUM_ACS];
  1133. const struct ieee80211_ops *ops;
  1134. /*
  1135. * private workqueue to mac80211. mac80211 makes this accessible
  1136. * via ieee80211_queue_work()
  1137. */
  1138. struct workqueue_struct *workqueue;
  1139. unsigned long queue_stop_reasons[IEEE80211_MAX_QUEUES];
  1140. int q_stop_reasons[IEEE80211_MAX_QUEUES][IEEE80211_QUEUE_STOP_REASONS];
  1141. /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
  1142. spinlock_t queue_stop_reason_lock;
  1143. int open_count;
  1144. int monitors, cooked_mntrs;
  1145. /* number of interfaces with corresponding FIF_ flags */
  1146. int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
  1147. fif_probe_req;
  1148. bool probe_req_reg;
  1149. bool rx_mcast_action_reg;
  1150. unsigned int filter_flags; /* FIF_* */
  1151. bool wiphy_ciphers_allocated;
  1152. struct cfg80211_chan_def dflt_chandef;
  1153. bool emulate_chanctx;
  1154. /* protects the aggregated multicast list and filter calls */
  1155. spinlock_t filter_lock;
  1156. /* used for uploading changed mc list */
  1157. struct wiphy_work reconfig_filter;
  1158. /* aggregated multicast list */
  1159. struct netdev_hw_addr_list mc_list;
  1160. bool tim_in_locked_section; /* see ieee80211_beacon_get() */
  1161. /*
  1162. * suspended is true if we finished all the suspend _and_ we have
  1163. * not yet come up from resume. This is to be used by mac80211
  1164. * to ensure driver sanity during suspend and mac80211's own
  1165. * sanity. It can eventually be used for WoW as well.
  1166. */
  1167. bool suspended;
  1168. /* suspending is true during the whole suspend process */
  1169. bool suspending;
  1170. /*
  1171. * Resuming is true while suspended, but when we're reprogramming the
  1172. * hardware -- at that time it's allowed to use ieee80211_queue_work()
  1173. * again even though some other parts of the stack are still suspended
  1174. * and we still drop received frames to avoid waking the stack.
  1175. */
  1176. bool resuming;
  1177. /*
  1178. * quiescing is true during the suspend process _only_ to
  1179. * ease timer cancelling etc.
  1180. */
  1181. bool quiescing;
  1182. /* device is started */
  1183. bool started;
  1184. /* device is during a HW reconfig */
  1185. bool in_reconfig;
  1186. /* reconfiguration failed ... suppress some warnings etc. */
  1187. bool reconfig_failure;
  1188. /* wowlan is enabled -- don't reconfig on resume */
  1189. bool wowlan;
  1190. struct wiphy_work radar_detected_work;
  1191. /* number of RX chains the hardware has */
  1192. u8 rx_chains;
  1193. /* bitmap of which sbands were copied */
  1194. u8 sband_allocated;
  1195. int tx_headroom; /* required headroom for hardware/radiotap */
  1196. /* Tasklet and skb queue to process calls from IRQ mode. All frames
  1197. * added to skb_queue will be processed, but frames in
  1198. * skb_queue_unreliable may be dropped if the total length of these
  1199. * queues increases over the limit. */
  1200. #define IEEE80211_IRQSAFE_QUEUE_LIMIT 128
  1201. struct tasklet_struct tasklet;
  1202. struct sk_buff_head skb_queue;
  1203. struct sk_buff_head skb_queue_unreliable;
  1204. spinlock_t rx_path_lock;
  1205. /* Station data */
  1206. /*
  1207. * The list, hash table and counter are protected
  1208. * by the wiphy mutex, reads are done with RCU.
  1209. */
  1210. spinlock_t tim_lock;
  1211. unsigned long num_sta;
  1212. struct list_head sta_list;
  1213. struct rhltable sta_hash;
  1214. struct rhltable link_sta_hash;
  1215. struct timer_list sta_cleanup;
  1216. int sta_generation;
  1217. struct sk_buff_head pending[IEEE80211_MAX_QUEUES];
  1218. struct tasklet_struct tx_pending_tasklet;
  1219. struct tasklet_struct wake_txqs_tasklet;
  1220. atomic_t agg_queue_stop[IEEE80211_MAX_QUEUES];
  1221. /* number of interfaces with allmulti RX */
  1222. atomic_t iff_allmultis;
  1223. struct rate_control_ref *rate_ctrl;
  1224. struct arc4_ctx wep_tx_ctx;
  1225. struct arc4_ctx wep_rx_ctx;
  1226. u32 wep_iv;
  1227. /* see iface.c */
  1228. struct list_head interfaces;
  1229. struct list_head mon_list; /* only that are IFF_UP && !cooked */
  1230. struct mutex iflist_mtx;
  1231. /* Scanning and BSS list */
  1232. unsigned long scanning;
  1233. struct cfg80211_ssid scan_ssid;
  1234. struct cfg80211_scan_request *int_scan_req;
  1235. struct cfg80211_scan_request __rcu *scan_req;
  1236. struct ieee80211_scan_request *hw_scan_req;
  1237. struct cfg80211_chan_def scan_chandef;
  1238. enum nl80211_band hw_scan_band;
  1239. int scan_channel_idx;
  1240. int scan_ies_len;
  1241. int hw_scan_ies_bufsize;
  1242. struct cfg80211_scan_info scan_info;
  1243. struct wiphy_work sched_scan_stopped_work;
  1244. struct ieee80211_sub_if_data __rcu *sched_scan_sdata;
  1245. struct cfg80211_sched_scan_request __rcu *sched_scan_req;
  1246. u8 scan_addr[ETH_ALEN];
  1247. unsigned long leave_oper_channel_time;
  1248. enum mac80211_scan_state next_scan_state;
  1249. struct wiphy_delayed_work scan_work;
  1250. struct ieee80211_sub_if_data __rcu *scan_sdata;
  1251. /* Temporary remain-on-channel for off-channel operations */
  1252. struct ieee80211_channel *tmp_channel;
  1253. /* channel contexts */
  1254. struct list_head chanctx_list;
  1255. #ifdef CONFIG_MAC80211_LEDS
  1256. struct led_trigger tx_led, rx_led, assoc_led, radio_led;
  1257. struct led_trigger tpt_led;
  1258. atomic_t tx_led_active, rx_led_active, assoc_led_active;
  1259. atomic_t radio_led_active, tpt_led_active;
  1260. struct tpt_led_trigger *tpt_led_trigger;
  1261. #endif
  1262. #ifdef CONFIG_MAC80211_DEBUG_COUNTERS
  1263. /* SNMP counters */
  1264. /* dot11CountersTable */
  1265. u32 dot11TransmittedFragmentCount;
  1266. u32 dot11MulticastTransmittedFrameCount;
  1267. u32 dot11FailedCount;
  1268. u32 dot11RetryCount;
  1269. u32 dot11MultipleRetryCount;
  1270. u32 dot11FrameDuplicateCount;
  1271. u32 dot11ReceivedFragmentCount;
  1272. u32 dot11MulticastReceivedFrameCount;
  1273. u32 dot11TransmittedFrameCount;
  1274. /* TX/RX handler statistics */
  1275. unsigned int tx_handlers_drop;
  1276. unsigned int tx_handlers_queued;
  1277. unsigned int tx_handlers_drop_wep;
  1278. unsigned int tx_handlers_drop_not_assoc;
  1279. unsigned int tx_handlers_drop_unauth_port;
  1280. unsigned int rx_handlers_drop;
  1281. unsigned int rx_handlers_queued;
  1282. unsigned int rx_handlers_drop_nullfunc;
  1283. unsigned int rx_handlers_drop_defrag;
  1284. unsigned int tx_expand_skb_head;
  1285. unsigned int tx_expand_skb_head_cloned;
  1286. unsigned int rx_expand_skb_head_defrag;
  1287. unsigned int rx_handlers_fragments;
  1288. unsigned int tx_status_drop;
  1289. #define I802_DEBUG_INC(c) (c)++
  1290. #else /* CONFIG_MAC80211_DEBUG_COUNTERS */
  1291. #define I802_DEBUG_INC(c) do { } while (0)
  1292. #endif /* CONFIG_MAC80211_DEBUG_COUNTERS */
  1293. int total_ps_buffered; /* total number of all buffered unicast and
  1294. * multicast packets for power saving stations
  1295. */
  1296. bool pspolling;
  1297. /*
  1298. * PS can only be enabled when we have exactly one managed
  1299. * interface (and monitors) in PS, this then points there.
  1300. */
  1301. struct ieee80211_sub_if_data *ps_sdata;
  1302. struct wiphy_work dynamic_ps_enable_work;
  1303. struct wiphy_work dynamic_ps_disable_work;
  1304. struct timer_list dynamic_ps_timer;
  1305. struct notifier_block ifa_notifier;
  1306. struct notifier_block ifa6_notifier;
  1307. /*
  1308. * The dynamic ps timeout configured from user space via WEXT -
  1309. * this will override whatever chosen by mac80211 internally.
  1310. */
  1311. int dynamic_ps_forced_timeout;
  1312. int user_power_level; /* in dBm, for all interfaces */
  1313. struct work_struct restart_work;
  1314. #ifdef CONFIG_MAC80211_DEBUGFS
  1315. struct local_debugfsdentries {
  1316. struct dentry *rcdir;
  1317. struct dentry *keys;
  1318. } debugfs;
  1319. bool force_tx_status;
  1320. #endif
  1321. /*
  1322. * Remain-on-channel support
  1323. */
  1324. struct wiphy_delayed_work roc_work;
  1325. struct list_head roc_list;
  1326. struct wiphy_work hw_roc_start, hw_roc_done;
  1327. unsigned long hw_roc_start_time;
  1328. u64 roc_cookie_counter;
  1329. struct idr ack_status_frames;
  1330. spinlock_t ack_status_lock;
  1331. struct ieee80211_sub_if_data __rcu *p2p_sdata;
  1332. /* virtual monitor interface */
  1333. struct ieee80211_sub_if_data __rcu *monitor_sdata;
  1334. struct ieee80211_chan_req monitor_chanreq;
  1335. /* extended capabilities provided by mac80211 */
  1336. u8 ext_capa[8];
  1337. bool wbrf_supported;
  1338. };
  1339. static inline struct ieee80211_sub_if_data *
  1340. IEEE80211_DEV_TO_SUB_IF(const struct net_device *dev)
  1341. {
  1342. return netdev_priv(dev);
  1343. }
  1344. static inline struct ieee80211_sub_if_data *
  1345. IEEE80211_WDEV_TO_SUB_IF(struct wireless_dev *wdev)
  1346. {
  1347. return container_of(wdev, struct ieee80211_sub_if_data, wdev);
  1348. }
  1349. static inline struct ieee80211_supported_band *
  1350. ieee80211_get_sband(struct ieee80211_sub_if_data *sdata)
  1351. {
  1352. struct ieee80211_local *local = sdata->local;
  1353. struct ieee80211_chanctx_conf *chanctx_conf;
  1354. enum nl80211_band band;
  1355. WARN_ON(ieee80211_vif_is_mld(&sdata->vif));
  1356. rcu_read_lock();
  1357. chanctx_conf = rcu_dereference(sdata->vif.bss_conf.chanctx_conf);
  1358. if (!chanctx_conf) {
  1359. rcu_read_unlock();
  1360. return NULL;
  1361. }
  1362. band = chanctx_conf->def.chan->band;
  1363. rcu_read_unlock();
  1364. return local->hw.wiphy->bands[band];
  1365. }
  1366. static inline struct ieee80211_supported_band *
  1367. ieee80211_get_link_sband(struct ieee80211_link_data *link)
  1368. {
  1369. struct ieee80211_local *local = link->sdata->local;
  1370. struct ieee80211_chanctx_conf *chanctx_conf;
  1371. enum nl80211_band band;
  1372. rcu_read_lock();
  1373. chanctx_conf = rcu_dereference(link->conf->chanctx_conf);
  1374. if (!chanctx_conf) {
  1375. rcu_read_unlock();
  1376. return NULL;
  1377. }
  1378. band = chanctx_conf->def.chan->band;
  1379. rcu_read_unlock();
  1380. return local->hw.wiphy->bands[band];
  1381. }
  1382. /* this struct holds the value parsing from channel switch IE */
  1383. struct ieee80211_csa_ie {
  1384. struct ieee80211_chan_req chanreq;
  1385. u8 mode;
  1386. u8 count;
  1387. u8 ttl;
  1388. u16 pre_value;
  1389. u16 reason_code;
  1390. u32 max_switch_time;
  1391. };
  1392. enum ieee80211_elems_parse_error {
  1393. IEEE80211_PARSE_ERR_INVALID_END = BIT(0),
  1394. IEEE80211_PARSE_ERR_DUP_ELEM = BIT(1),
  1395. IEEE80211_PARSE_ERR_BAD_ELEM_SIZE = BIT(2),
  1396. IEEE80211_PARSE_ERR_UNEXPECTED_ELEM = BIT(3),
  1397. IEEE80211_PARSE_ERR_DUP_NEST_ML_BASIC = BIT(4),
  1398. };
  1399. /* Parsed Information Elements */
  1400. struct ieee802_11_elems {
  1401. const u8 *ie_start;
  1402. size_t total_len;
  1403. u32 crc;
  1404. /* pointers to IEs */
  1405. const struct ieee80211_tdls_lnkie *lnk_id;
  1406. const struct ieee80211_ch_switch_timing *ch_sw_timing;
  1407. const u8 *ext_capab;
  1408. const u8 *ssid;
  1409. const u8 *supp_rates;
  1410. const u8 *ds_params;
  1411. const struct ieee80211_tim_ie *tim;
  1412. const u8 *rsn;
  1413. const u8 *rsnx;
  1414. const u8 *erp_info;
  1415. const u8 *ext_supp_rates;
  1416. const u8 *wmm_info;
  1417. const u8 *wmm_param;
  1418. const struct ieee80211_ht_cap *ht_cap_elem;
  1419. const struct ieee80211_ht_operation *ht_operation;
  1420. const struct ieee80211_vht_cap *vht_cap_elem;
  1421. const struct ieee80211_vht_operation *vht_operation;
  1422. const struct ieee80211_meshconf_ie *mesh_config;
  1423. const u8 *he_cap;
  1424. const struct ieee80211_he_operation *he_operation;
  1425. const struct ieee80211_he_spr *he_spr;
  1426. const struct ieee80211_mu_edca_param_set *mu_edca_param_set;
  1427. const struct ieee80211_he_6ghz_capa *he_6ghz_capa;
  1428. const u8 *uora_element;
  1429. const u8 *mesh_id;
  1430. const u8 *peering;
  1431. const __le16 *awake_window;
  1432. const u8 *preq;
  1433. const u8 *prep;
  1434. const u8 *perr;
  1435. const struct ieee80211_rann_ie *rann;
  1436. const struct ieee80211_channel_sw_ie *ch_switch_ie;
  1437. const struct ieee80211_ext_chansw_ie *ext_chansw_ie;
  1438. const struct ieee80211_wide_bw_chansw_ie *wide_bw_chansw_ie;
  1439. const u8 *max_channel_switch_time;
  1440. const u8 *country_elem;
  1441. const u8 *pwr_constr_elem;
  1442. const u8 *cisco_dtpc_elem;
  1443. const struct ieee80211_timeout_interval_ie *timeout_int;
  1444. const u8 *opmode_notif;
  1445. const struct ieee80211_sec_chan_offs_ie *sec_chan_offs;
  1446. struct ieee80211_mesh_chansw_params_ie *mesh_chansw_params_ie;
  1447. const struct ieee80211_bss_max_idle_period_ie *max_idle_period_ie;
  1448. const struct ieee80211_multiple_bssid_configuration *mbssid_config_ie;
  1449. const struct ieee80211_bssid_index *bssid_index;
  1450. u8 max_bssid_indicator;
  1451. u8 dtim_count;
  1452. u8 dtim_period;
  1453. const struct ieee80211_addba_ext_ie *addba_ext_ie;
  1454. const struct ieee80211_s1g_cap *s1g_capab;
  1455. const struct ieee80211_s1g_oper_ie *s1g_oper;
  1456. const struct ieee80211_s1g_bcn_compat_ie *s1g_bcn_compat;
  1457. const struct ieee80211_aid_response_ie *aid_resp;
  1458. const struct ieee80211_eht_cap_elem *eht_cap;
  1459. const struct ieee80211_eht_operation *eht_operation;
  1460. const struct ieee80211_multi_link_elem *ml_basic;
  1461. const struct ieee80211_multi_link_elem *ml_reconf;
  1462. const struct ieee80211_multi_link_elem *ml_epcs;
  1463. const struct ieee80211_bandwidth_indication *bandwidth_indication;
  1464. const struct ieee80211_ttlm_elem *ttlm[IEEE80211_TTLM_MAX_CNT];
  1465. /* not the order in the psd values is per element, not per chandef */
  1466. struct ieee80211_parsed_tpe tpe;
  1467. struct ieee80211_parsed_tpe csa_tpe;
  1468. /* length of them, respectively */
  1469. u8 ext_capab_len;
  1470. u8 ssid_len;
  1471. u8 supp_rates_len;
  1472. u8 tim_len;
  1473. u8 rsn_len;
  1474. u8 rsnx_len;
  1475. u8 ext_supp_rates_len;
  1476. u8 wmm_info_len;
  1477. u8 wmm_param_len;
  1478. u8 he_cap_len;
  1479. u8 mesh_id_len;
  1480. u8 peering_len;
  1481. u8 preq_len;
  1482. u8 prep_len;
  1483. u8 perr_len;
  1484. u8 country_elem_len;
  1485. u8 bssid_index_len;
  1486. u8 eht_cap_len;
  1487. /* mult-link element can be de-fragmented and thus u8 is not sufficient */
  1488. size_t ml_basic_len;
  1489. size_t ml_reconf_len;
  1490. size_t ml_epcs_len;
  1491. u8 ttlm_num;
  1492. /*
  1493. * store the per station profile pointer and length in case that the
  1494. * parsing also handled Multi-Link element parsing for a specific link
  1495. * ID.
  1496. */
  1497. struct ieee80211_mle_per_sta_profile *prof;
  1498. size_t sta_prof_len;
  1499. /* whether/which parse error occurred while retrieving these elements */
  1500. u8 parse_error;
  1501. };
  1502. static inline struct ieee80211_local *hw_to_local(
  1503. struct ieee80211_hw *hw)
  1504. {
  1505. return container_of(hw, struct ieee80211_local, hw);
  1506. }
  1507. static inline struct txq_info *to_txq_info(struct ieee80211_txq *txq)
  1508. {
  1509. return container_of(txq, struct txq_info, txq);
  1510. }
  1511. static inline bool txq_has_queue(struct ieee80211_txq *txq)
  1512. {
  1513. struct txq_info *txqi = to_txq_info(txq);
  1514. return !(skb_queue_empty(&txqi->frags) && !txqi->tin.backlog_packets);
  1515. }
  1516. static inline bool
  1517. ieee80211_have_rx_timestamp(struct ieee80211_rx_status *status)
  1518. {
  1519. return status->flag & RX_FLAG_MACTIME;
  1520. }
  1521. void ieee80211_vif_inc_num_mcast(struct ieee80211_sub_if_data *sdata);
  1522. void ieee80211_vif_dec_num_mcast(struct ieee80211_sub_if_data *sdata);
  1523. void ieee80211_vif_block_queues_csa(struct ieee80211_sub_if_data *sdata);
  1524. void ieee80211_vif_unblock_queues_csa(struct ieee80211_sub_if_data *sdata);
  1525. /* This function returns the number of multicast stations connected to this
  1526. * interface. It returns -1 if that number is not tracked, that is for netdevs
  1527. * not in AP or AP_VLAN mode or when using 4addr.
  1528. */
  1529. static inline int
  1530. ieee80211_vif_get_num_mcast_if(struct ieee80211_sub_if_data *sdata)
  1531. {
  1532. if (sdata->vif.type == NL80211_IFTYPE_AP)
  1533. return atomic_read(&sdata->u.ap.num_mcast_sta);
  1534. if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN && !sdata->u.vlan.sta)
  1535. return atomic_read(&sdata->u.vlan.num_mcast_sta);
  1536. return -1;
  1537. }
  1538. u64 ieee80211_calculate_rx_timestamp(struct ieee80211_local *local,
  1539. struct ieee80211_rx_status *status,
  1540. unsigned int mpdu_len,
  1541. unsigned int mpdu_offset);
  1542. int ieee80211_hw_config(struct ieee80211_local *local, u32 changed);
  1543. int ieee80211_hw_conf_chan(struct ieee80211_local *local);
  1544. void ieee80211_hw_conf_init(struct ieee80211_local *local);
  1545. void ieee80211_tx_set_protected(struct ieee80211_tx_data *tx);
  1546. void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
  1547. u64 changed);
  1548. void ieee80211_vif_cfg_change_notify(struct ieee80211_sub_if_data *sdata,
  1549. u64 changed);
  1550. void ieee80211_link_info_change_notify(struct ieee80211_sub_if_data *sdata,
  1551. struct ieee80211_link_data *link,
  1552. u64 changed);
  1553. void ieee80211_configure_filter(struct ieee80211_local *local);
  1554. u64 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata);
  1555. void ieee80211_handle_queued_frames(struct ieee80211_local *local);
  1556. u64 ieee80211_mgmt_tx_cookie(struct ieee80211_local *local);
  1557. int ieee80211_attach_ack_skb(struct ieee80211_local *local, struct sk_buff *skb,
  1558. u64 *cookie, gfp_t gfp);
  1559. void ieee80211_check_fast_rx(struct sta_info *sta);
  1560. void __ieee80211_check_fast_rx_iface(struct ieee80211_sub_if_data *sdata);
  1561. void ieee80211_check_fast_rx_iface(struct ieee80211_sub_if_data *sdata);
  1562. void ieee80211_clear_fast_rx(struct sta_info *sta);
  1563. bool ieee80211_is_our_addr(struct ieee80211_sub_if_data *sdata,
  1564. const u8 *addr, int *out_link_id);
  1565. /* STA code */
  1566. void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata);
  1567. int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata,
  1568. struct cfg80211_auth_request *req);
  1569. int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
  1570. struct cfg80211_assoc_request *req);
  1571. int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata,
  1572. struct cfg80211_deauth_request *req);
  1573. int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata,
  1574. struct cfg80211_disassoc_request *req);
  1575. void ieee80211_send_pspoll(struct ieee80211_local *local,
  1576. struct ieee80211_sub_if_data *sdata);
  1577. void ieee80211_recalc_ps(struct ieee80211_local *local);
  1578. void ieee80211_recalc_ps_vif(struct ieee80211_sub_if_data *sdata);
  1579. void ieee80211_sta_work(struct ieee80211_sub_if_data *sdata);
  1580. void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
  1581. struct sk_buff *skb);
  1582. void ieee80211_sta_rx_queued_ext(struct ieee80211_sub_if_data *sdata,
  1583. struct sk_buff *skb);
  1584. void ieee80211_sta_reset_beacon_monitor(struct ieee80211_sub_if_data *sdata);
  1585. void ieee80211_sta_reset_conn_monitor(struct ieee80211_sub_if_data *sdata);
  1586. void ieee80211_mgd_stop(struct ieee80211_sub_if_data *sdata);
  1587. void ieee80211_mgd_conn_tx_status(struct ieee80211_sub_if_data *sdata,
  1588. __le16 fc, bool acked);
  1589. void ieee80211_mgd_quiesce(struct ieee80211_sub_if_data *sdata);
  1590. void ieee80211_sta_restart(struct ieee80211_sub_if_data *sdata);
  1591. void ieee80211_sta_handle_tspec_ac_params(struct ieee80211_sub_if_data *sdata);
  1592. void ieee80211_sta_connection_lost(struct ieee80211_sub_if_data *sdata,
  1593. u8 reason, bool tx);
  1594. void ieee80211_mgd_setup_link(struct ieee80211_link_data *link);
  1595. void ieee80211_mgd_stop_link(struct ieee80211_link_data *link);
  1596. void ieee80211_mgd_set_link_qos_params(struct ieee80211_link_data *link);
  1597. /* IBSS code */
  1598. void ieee80211_ibss_notify_scan_completed(struct ieee80211_local *local);
  1599. void ieee80211_ibss_setup_sdata(struct ieee80211_sub_if_data *sdata);
  1600. void ieee80211_ibss_rx_no_sta(struct ieee80211_sub_if_data *sdata,
  1601. const u8 *bssid, const u8 *addr, u32 supp_rates);
  1602. int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata,
  1603. struct cfg80211_ibss_params *params);
  1604. int ieee80211_ibss_leave(struct ieee80211_sub_if_data *sdata);
  1605. void ieee80211_ibss_work(struct ieee80211_sub_if_data *sdata);
  1606. void ieee80211_ibss_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
  1607. struct sk_buff *skb);
  1608. int ieee80211_ibss_csa_beacon(struct ieee80211_sub_if_data *sdata,
  1609. struct cfg80211_csa_settings *csa_settings,
  1610. u64 *changed);
  1611. int ieee80211_ibss_finish_csa(struct ieee80211_sub_if_data *sdata,
  1612. u64 *changed);
  1613. void ieee80211_ibss_stop(struct ieee80211_sub_if_data *sdata);
  1614. /* OCB code */
  1615. void ieee80211_ocb_work(struct ieee80211_sub_if_data *sdata);
  1616. void ieee80211_ocb_rx_no_sta(struct ieee80211_sub_if_data *sdata,
  1617. const u8 *bssid, const u8 *addr, u32 supp_rates);
  1618. void ieee80211_ocb_setup_sdata(struct ieee80211_sub_if_data *sdata);
  1619. int ieee80211_ocb_join(struct ieee80211_sub_if_data *sdata,
  1620. struct ocb_setup *setup);
  1621. int ieee80211_ocb_leave(struct ieee80211_sub_if_data *sdata);
  1622. /* mesh code */
  1623. void ieee80211_mesh_work(struct ieee80211_sub_if_data *sdata);
  1624. void ieee80211_mesh_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
  1625. struct sk_buff *skb);
  1626. int ieee80211_mesh_csa_beacon(struct ieee80211_sub_if_data *sdata,
  1627. struct cfg80211_csa_settings *csa_settings,
  1628. u64 *changed);
  1629. int ieee80211_mesh_finish_csa(struct ieee80211_sub_if_data *sdata,
  1630. u64 *changed);
  1631. /* scan/BSS handling */
  1632. void ieee80211_scan_work(struct wiphy *wiphy, struct wiphy_work *work);
  1633. int ieee80211_request_ibss_scan(struct ieee80211_sub_if_data *sdata,
  1634. const u8 *ssid, u8 ssid_len,
  1635. struct ieee80211_channel **channels,
  1636. unsigned int n_channels);
  1637. int ieee80211_request_scan(struct ieee80211_sub_if_data *sdata,
  1638. struct cfg80211_scan_request *req);
  1639. void ieee80211_scan_cancel(struct ieee80211_local *local);
  1640. void ieee80211_run_deferred_scan(struct ieee80211_local *local);
  1641. void ieee80211_scan_rx(struct ieee80211_local *local, struct sk_buff *skb);
  1642. void ieee80211_inform_bss(struct wiphy *wiphy, struct cfg80211_bss *bss,
  1643. const struct cfg80211_bss_ies *ies, void *data);
  1644. void ieee80211_mlme_notify_scan_completed(struct ieee80211_local *local);
  1645. struct ieee80211_bss *
  1646. ieee80211_bss_info_update(struct ieee80211_local *local,
  1647. struct ieee80211_rx_status *rx_status,
  1648. struct ieee80211_mgmt *mgmt,
  1649. size_t len,
  1650. struct ieee80211_channel *channel);
  1651. void ieee80211_rx_bss_put(struct ieee80211_local *local,
  1652. struct ieee80211_bss *bss);
  1653. /* scheduled scan handling */
  1654. int
  1655. __ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata,
  1656. struct cfg80211_sched_scan_request *req);
  1657. int ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata,
  1658. struct cfg80211_sched_scan_request *req);
  1659. int ieee80211_request_sched_scan_stop(struct ieee80211_local *local);
  1660. void ieee80211_sched_scan_end(struct ieee80211_local *local);
  1661. void ieee80211_sched_scan_stopped_work(struct wiphy *wiphy,
  1662. struct wiphy_work *work);
  1663. /* off-channel/mgmt-tx */
  1664. void ieee80211_offchannel_stop_vifs(struct ieee80211_local *local);
  1665. void ieee80211_offchannel_return(struct ieee80211_local *local);
  1666. void ieee80211_roc_setup(struct ieee80211_local *local);
  1667. void ieee80211_start_next_roc(struct ieee80211_local *local);
  1668. void ieee80211_reconfig_roc(struct ieee80211_local *local);
  1669. void ieee80211_roc_purge(struct ieee80211_local *local,
  1670. struct ieee80211_sub_if_data *sdata);
  1671. int ieee80211_remain_on_channel(struct wiphy *wiphy, struct wireless_dev *wdev,
  1672. struct ieee80211_channel *chan,
  1673. unsigned int duration, u64 *cookie);
  1674. int ieee80211_cancel_remain_on_channel(struct wiphy *wiphy,
  1675. struct wireless_dev *wdev, u64 cookie);
  1676. int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
  1677. struct cfg80211_mgmt_tx_params *params, u64 *cookie);
  1678. int ieee80211_mgmt_tx_cancel_wait(struct wiphy *wiphy,
  1679. struct wireless_dev *wdev, u64 cookie);
  1680. /* channel switch handling */
  1681. void ieee80211_csa_finalize_work(struct wiphy *wiphy, struct wiphy_work *work);
  1682. int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
  1683. struct cfg80211_csa_settings *params);
  1684. /* color change handling */
  1685. void ieee80211_color_change_finalize_work(struct wiphy *wiphy,
  1686. struct wiphy_work *work);
  1687. void ieee80211_color_collision_detection_work(struct wiphy *wiphy,
  1688. struct wiphy_work *work);
  1689. /* interface handling */
  1690. #define MAC80211_SUPPORTED_FEATURES_TX (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | \
  1691. NETIF_F_HW_CSUM | NETIF_F_SG | \
  1692. NETIF_F_HIGHDMA | NETIF_F_GSO_SOFTWARE | \
  1693. NETIF_F_HW_TC)
  1694. #define MAC80211_SUPPORTED_FEATURES_RX (NETIF_F_RXCSUM)
  1695. #define MAC80211_SUPPORTED_FEATURES (MAC80211_SUPPORTED_FEATURES_TX | \
  1696. MAC80211_SUPPORTED_FEATURES_RX)
  1697. int ieee80211_iface_init(void);
  1698. void ieee80211_iface_exit(void);
  1699. int ieee80211_if_add(struct ieee80211_local *local, const char *name,
  1700. unsigned char name_assign_type,
  1701. struct wireless_dev **new_wdev, enum nl80211_iftype type,
  1702. struct vif_params *params);
  1703. int ieee80211_if_change_type(struct ieee80211_sub_if_data *sdata,
  1704. enum nl80211_iftype type);
  1705. void ieee80211_if_remove(struct ieee80211_sub_if_data *sdata);
  1706. void ieee80211_remove_interfaces(struct ieee80211_local *local);
  1707. u32 ieee80211_idle_off(struct ieee80211_local *local);
  1708. void ieee80211_recalc_idle(struct ieee80211_local *local);
  1709. void ieee80211_adjust_monitor_flags(struct ieee80211_sub_if_data *sdata,
  1710. const int offset);
  1711. int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up);
  1712. void ieee80211_sdata_stop(struct ieee80211_sub_if_data *sdata);
  1713. int ieee80211_add_virtual_monitor(struct ieee80211_local *local);
  1714. void ieee80211_del_virtual_monitor(struct ieee80211_local *local);
  1715. bool __ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata);
  1716. void ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata,
  1717. bool update_bss);
  1718. void ieee80211_recalc_offload(struct ieee80211_local *local);
  1719. static inline bool ieee80211_sdata_running(struct ieee80211_sub_if_data *sdata)
  1720. {
  1721. return test_bit(SDATA_STATE_RUNNING, &sdata->state);
  1722. }
  1723. /* link handling */
  1724. void ieee80211_link_setup(struct ieee80211_link_data *link);
  1725. void ieee80211_link_init(struct ieee80211_sub_if_data *sdata,
  1726. int link_id,
  1727. struct ieee80211_link_data *link,
  1728. struct ieee80211_bss_conf *link_conf);
  1729. void ieee80211_link_stop(struct ieee80211_link_data *link);
  1730. int ieee80211_vif_set_links(struct ieee80211_sub_if_data *sdata,
  1731. u16 new_links, u16 dormant_links);
  1732. static inline void ieee80211_vif_clear_links(struct ieee80211_sub_if_data *sdata)
  1733. {
  1734. ieee80211_vif_set_links(sdata, 0, 0);
  1735. }
  1736. void ieee80211_apvlan_link_setup(struct ieee80211_sub_if_data *sdata);
  1737. void ieee80211_apvlan_link_clear(struct ieee80211_sub_if_data *sdata);
  1738. /* tx handling */
  1739. void ieee80211_clear_tx_pending(struct ieee80211_local *local);
  1740. void ieee80211_tx_pending(struct tasklet_struct *t);
  1741. netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb,
  1742. struct net_device *dev);
  1743. netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
  1744. struct net_device *dev);
  1745. netdev_tx_t ieee80211_subif_start_xmit_8023(struct sk_buff *skb,
  1746. struct net_device *dev);
  1747. void __ieee80211_subif_start_xmit(struct sk_buff *skb,
  1748. struct net_device *dev,
  1749. u32 info_flags,
  1750. u32 ctrl_flags,
  1751. u64 *cookie);
  1752. struct sk_buff *
  1753. ieee80211_build_data_template(struct ieee80211_sub_if_data *sdata,
  1754. struct sk_buff *skb, u32 info_flags);
  1755. void ieee80211_tx_monitor(struct ieee80211_local *local, struct sk_buff *skb,
  1756. int retry_count, bool send_to_cooked,
  1757. struct ieee80211_tx_status *status);
  1758. void ieee80211_check_fast_xmit(struct sta_info *sta);
  1759. void ieee80211_check_fast_xmit_all(struct ieee80211_local *local);
  1760. void ieee80211_check_fast_xmit_iface(struct ieee80211_sub_if_data *sdata);
  1761. void ieee80211_clear_fast_xmit(struct sta_info *sta);
  1762. int ieee80211_tx_control_port(struct wiphy *wiphy, struct net_device *dev,
  1763. const u8 *buf, size_t len,
  1764. const u8 *dest, __be16 proto, bool unencrypted,
  1765. int link_id, u64 *cookie);
  1766. int ieee80211_probe_mesh_link(struct wiphy *wiphy, struct net_device *dev,
  1767. const u8 *buf, size_t len);
  1768. void __ieee80211_xmit_fast(struct ieee80211_sub_if_data *sdata,
  1769. struct sta_info *sta,
  1770. struct ieee80211_fast_tx *fast_tx,
  1771. struct sk_buff *skb, bool ampdu,
  1772. const u8 *da, const u8 *sa);
  1773. void ieee80211_aggr_check(struct ieee80211_sub_if_data *sdata,
  1774. struct sta_info *sta, struct sk_buff *skb);
  1775. /* HT */
  1776. void ieee80211_apply_htcap_overrides(struct ieee80211_sub_if_data *sdata,
  1777. struct ieee80211_sta_ht_cap *ht_cap);
  1778. bool ieee80211_ht_cap_ie_to_sta_ht_cap(struct ieee80211_sub_if_data *sdata,
  1779. struct ieee80211_supported_band *sband,
  1780. const struct ieee80211_ht_cap *ht_cap_ie,
  1781. struct link_sta_info *link_sta);
  1782. void ieee80211_send_delba(struct ieee80211_sub_if_data *sdata,
  1783. const u8 *da, u16 tid,
  1784. u16 initiator, u16 reason_code);
  1785. int ieee80211_send_smps_action(struct ieee80211_sub_if_data *sdata,
  1786. enum ieee80211_smps_mode smps, const u8 *da,
  1787. const u8 *bssid, int link_id);
  1788. bool ieee80211_smps_is_restrictive(enum ieee80211_smps_mode smps_mode_old,
  1789. enum ieee80211_smps_mode smps_mode_new);
  1790. void __ieee80211_stop_rx_ba_session(struct sta_info *sta, u16 tid,
  1791. u16 initiator, u16 reason, bool stop);
  1792. void __ieee80211_start_rx_ba_session(struct sta_info *sta,
  1793. u8 dialog_token, u16 timeout,
  1794. u16 start_seq_num, u16 ba_policy, u16 tid,
  1795. u16 buf_size, bool tx, bool auto_seq,
  1796. const struct ieee80211_addba_ext_ie *addbaext);
  1797. void ieee80211_sta_tear_down_BA_sessions(struct sta_info *sta,
  1798. enum ieee80211_agg_stop_reason reason);
  1799. void ieee80211_process_delba(struct ieee80211_sub_if_data *sdata,
  1800. struct sta_info *sta,
  1801. struct ieee80211_mgmt *mgmt, size_t len);
  1802. void ieee80211_process_addba_resp(struct ieee80211_local *local,
  1803. struct sta_info *sta,
  1804. struct ieee80211_mgmt *mgmt,
  1805. size_t len);
  1806. void ieee80211_process_addba_request(struct ieee80211_local *local,
  1807. struct sta_info *sta,
  1808. struct ieee80211_mgmt *mgmt,
  1809. size_t len);
  1810. static inline struct ieee80211_mgmt *
  1811. ieee80211_mgmt_ba(struct sk_buff *skb, const u8 *da,
  1812. struct ieee80211_sub_if_data *sdata)
  1813. {
  1814. struct ieee80211_mgmt *mgmt = skb_put_zero(skb, 24);
  1815. ether_addr_copy(mgmt->da, da);
  1816. ether_addr_copy(mgmt->sa, sdata->vif.addr);
  1817. if (sdata->vif.type == NL80211_IFTYPE_AP ||
  1818. sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
  1819. sdata->vif.type == NL80211_IFTYPE_MESH_POINT)
  1820. ether_addr_copy(mgmt->bssid, sdata->vif.addr);
  1821. else if (sdata->vif.type == NL80211_IFTYPE_STATION)
  1822. ether_addr_copy(mgmt->bssid, sdata->vif.cfg.ap_addr);
  1823. else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
  1824. ether_addr_copy(mgmt->bssid, sdata->u.ibss.bssid);
  1825. mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
  1826. IEEE80211_STYPE_ACTION);
  1827. return mgmt;
  1828. }
  1829. int __ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid,
  1830. enum ieee80211_agg_stop_reason reason);
  1831. void ieee80211_start_tx_ba_cb(struct sta_info *sta, int tid,
  1832. struct tid_ampdu_tx *tid_tx);
  1833. void ieee80211_stop_tx_ba_cb(struct sta_info *sta, int tid,
  1834. struct tid_ampdu_tx *tid_tx);
  1835. void ieee80211_ba_session_work(struct wiphy *wiphy, struct wiphy_work *work);
  1836. void ieee80211_tx_ba_session_handle_start(struct sta_info *sta, int tid);
  1837. void ieee80211_release_reorder_timeout(struct sta_info *sta, int tid);
  1838. u8 ieee80211_mcs_to_chains(const struct ieee80211_mcs_info *mcs);
  1839. enum nl80211_smps_mode
  1840. ieee80211_smps_mode_to_smps_mode(enum ieee80211_smps_mode smps);
  1841. /* VHT */
  1842. void
  1843. ieee80211_vht_cap_ie_to_sta_vht_cap(struct ieee80211_sub_if_data *sdata,
  1844. struct ieee80211_supported_band *sband,
  1845. const struct ieee80211_vht_cap *vht_cap_ie,
  1846. const struct ieee80211_vht_cap *vht_cap_ie2,
  1847. struct link_sta_info *link_sta);
  1848. enum ieee80211_sta_rx_bandwidth
  1849. _ieee80211_sta_cap_rx_bw(struct link_sta_info *link_sta,
  1850. struct cfg80211_chan_def *chandef);
  1851. static inline enum ieee80211_sta_rx_bandwidth
  1852. ieee80211_sta_cap_rx_bw(struct link_sta_info *link_sta)
  1853. {
  1854. return _ieee80211_sta_cap_rx_bw(link_sta, NULL);
  1855. }
  1856. enum ieee80211_sta_rx_bandwidth
  1857. _ieee80211_sta_cur_vht_bw(struct link_sta_info *link_sta,
  1858. struct cfg80211_chan_def *chandef);
  1859. static inline enum ieee80211_sta_rx_bandwidth
  1860. ieee80211_sta_cur_vht_bw(struct link_sta_info *link_sta)
  1861. {
  1862. return _ieee80211_sta_cur_vht_bw(link_sta, NULL);
  1863. }
  1864. void ieee80211_sta_init_nss(struct link_sta_info *link_sta);
  1865. enum ieee80211_sta_rx_bandwidth
  1866. ieee80211_chan_width_to_rx_bw(enum nl80211_chan_width width);
  1867. enum nl80211_chan_width
  1868. ieee80211_sta_cap_chan_bw(struct link_sta_info *link_sta);
  1869. void ieee80211_process_mu_groups(struct ieee80211_sub_if_data *sdata,
  1870. struct ieee80211_link_data *link,
  1871. struct ieee80211_mgmt *mgmt);
  1872. u32 __ieee80211_vht_handle_opmode(struct ieee80211_sub_if_data *sdata,
  1873. struct link_sta_info *sta,
  1874. u8 opmode, enum nl80211_band band);
  1875. void ieee80211_vht_handle_opmode(struct ieee80211_sub_if_data *sdata,
  1876. struct link_sta_info *sta,
  1877. u8 opmode, enum nl80211_band band);
  1878. void ieee80211_apply_vhtcap_overrides(struct ieee80211_sub_if_data *sdata,
  1879. struct ieee80211_sta_vht_cap *vht_cap);
  1880. void ieee80211_get_vht_mask_from_cap(__le16 vht_cap,
  1881. u16 vht_mask[NL80211_VHT_NSS_MAX]);
  1882. enum nl80211_chan_width
  1883. ieee80211_sta_rx_bw_to_chan_width(struct link_sta_info *sta);
  1884. /* HE */
  1885. void
  1886. ieee80211_he_cap_ie_to_sta_he_cap(struct ieee80211_sub_if_data *sdata,
  1887. struct ieee80211_supported_band *sband,
  1888. const u8 *he_cap_ie, u8 he_cap_len,
  1889. const struct ieee80211_he_6ghz_capa *he_6ghz_capa,
  1890. struct link_sta_info *link_sta);
  1891. void
  1892. ieee80211_he_spr_ie_to_bss_conf(struct ieee80211_vif *vif,
  1893. const struct ieee80211_he_spr *he_spr_ie_elem);
  1894. void
  1895. ieee80211_he_op_ie_to_bss_conf(struct ieee80211_vif *vif,
  1896. const struct ieee80211_he_operation *he_op_ie_elem);
  1897. /* S1G */
  1898. void ieee80211_s1g_sta_rate_init(struct sta_info *sta);
  1899. bool ieee80211_s1g_is_twt_setup(struct sk_buff *skb);
  1900. void ieee80211_s1g_rx_twt_action(struct ieee80211_sub_if_data *sdata,
  1901. struct sk_buff *skb);
  1902. void ieee80211_s1g_status_twt_action(struct ieee80211_sub_if_data *sdata,
  1903. struct sk_buff *skb);
  1904. /* Spectrum management */
  1905. void ieee80211_process_measurement_req(struct ieee80211_sub_if_data *sdata,
  1906. struct ieee80211_mgmt *mgmt,
  1907. size_t len);
  1908. /**
  1909. * ieee80211_parse_ch_switch_ie - parses channel switch IEs
  1910. * @sdata: the sdata of the interface which has received the frame
  1911. * @elems: parsed 802.11 elements received with the frame
  1912. * @current_band: indicates the current band
  1913. * @vht_cap_info: VHT capabilities of the transmitter
  1914. * @conn: contains information about own capabilities and restrictions
  1915. * to decide which channel switch announcements can be accepted
  1916. * @bssid: the currently connected bssid (for reporting)
  1917. * @unprot_action: whether the frame was an unprotected frame or not,
  1918. * used for reporting
  1919. * @csa_ie: parsed 802.11 csa elements on count, mode, chandef and mesh ttl.
  1920. * All of them will be filled with if success only.
  1921. * Return: 0 on success, <0 on error and >0 if there is nothing to parse.
  1922. */
  1923. int ieee80211_parse_ch_switch_ie(struct ieee80211_sub_if_data *sdata,
  1924. struct ieee802_11_elems *elems,
  1925. enum nl80211_band current_band,
  1926. u32 vht_cap_info,
  1927. struct ieee80211_conn_settings *conn,
  1928. u8 *bssid, bool unprot_action,
  1929. struct ieee80211_csa_ie *csa_ie);
  1930. /* Suspend/resume and hw reconfiguration */
  1931. int ieee80211_reconfig(struct ieee80211_local *local);
  1932. void ieee80211_stop_device(struct ieee80211_local *local, bool suspend);
  1933. int __ieee80211_suspend(struct ieee80211_hw *hw,
  1934. struct cfg80211_wowlan *wowlan);
  1935. static inline int __ieee80211_resume(struct ieee80211_hw *hw)
  1936. {
  1937. struct ieee80211_local *local = hw_to_local(hw);
  1938. WARN(test_bit(SCAN_HW_SCANNING, &local->scanning) &&
  1939. !test_bit(SCAN_COMPLETED, &local->scanning),
  1940. "%s: resume with hardware scan still in progress\n",
  1941. wiphy_name(hw->wiphy));
  1942. return ieee80211_reconfig(hw_to_local(hw));
  1943. }
  1944. /* utility functions/constants */
  1945. extern const void *const mac80211_wiphy_privid; /* for wiphy privid */
  1946. const char *ieee80211_conn_mode_str(enum ieee80211_conn_mode mode);
  1947. enum ieee80211_conn_bw_limit
  1948. ieee80211_min_bw_limit_from_chandef(struct cfg80211_chan_def *chandef);
  1949. int ieee80211_frame_duration(enum nl80211_band band, size_t len,
  1950. int rate, int erp, int short_preamble);
  1951. void ieee80211_regulatory_limit_wmm_params(struct ieee80211_sub_if_data *sdata,
  1952. struct ieee80211_tx_queue_params *qparam,
  1953. int ac);
  1954. void ieee80211_clear_tpe(struct ieee80211_parsed_tpe *tpe);
  1955. void ieee80211_set_wmm_default(struct ieee80211_link_data *link,
  1956. bool bss_notify, bool enable_qos);
  1957. void ieee80211_xmit(struct ieee80211_sub_if_data *sdata,
  1958. struct sta_info *sta, struct sk_buff *skb);
  1959. void __ieee80211_tx_skb_tid_band(struct ieee80211_sub_if_data *sdata,
  1960. struct sk_buff *skb, int tid, int link_id,
  1961. enum nl80211_band band);
  1962. /* sta_out needs to be checked for ERR_PTR() before using */
  1963. int ieee80211_lookup_ra_sta(struct ieee80211_sub_if_data *sdata,
  1964. struct sk_buff *skb,
  1965. struct sta_info **sta_out);
  1966. static inline void
  1967. ieee80211_tx_skb_tid_band(struct ieee80211_sub_if_data *sdata,
  1968. struct sk_buff *skb, int tid,
  1969. enum nl80211_band band)
  1970. {
  1971. rcu_read_lock();
  1972. __ieee80211_tx_skb_tid_band(sdata, skb, tid, -1, band);
  1973. rcu_read_unlock();
  1974. }
  1975. void ieee80211_tx_skb_tid(struct ieee80211_sub_if_data *sdata,
  1976. struct sk_buff *skb, int tid, int link_id);
  1977. static inline void ieee80211_tx_skb(struct ieee80211_sub_if_data *sdata,
  1978. struct sk_buff *skb)
  1979. {
  1980. /* Send all internal mgmt frames on VO. Accordingly set TID to 7. */
  1981. ieee80211_tx_skb_tid(sdata, skb, 7, -1);
  1982. }
  1983. /**
  1984. * struct ieee80211_elems_parse_params - element parsing parameters
  1985. * @mode: connection mode for parsing
  1986. * @start: pointer to the elements
  1987. * @len: length of the elements
  1988. * @action: %true if the elements came from an action frame
  1989. * @filter: bitmap of element IDs to filter out while calculating
  1990. * the element CRC
  1991. * @crc: CRC starting value
  1992. * @bss: the BSS to parse this as, for multi-BSSID cases this can
  1993. * represent a non-transmitting BSS in which case the data
  1994. * for that non-transmitting BSS is returned
  1995. * @link_id: the link ID to parse elements for, if a STA profile
  1996. * is present in the multi-link element, or -1 to ignore;
  1997. * note that the code currently assumes parsing an association
  1998. * (or re-association) response frame if this is given
  1999. * @from_ap: frame is received from an AP (currently used only
  2000. * for EHT capabilities parsing)
  2001. */
  2002. struct ieee80211_elems_parse_params {
  2003. enum ieee80211_conn_mode mode;
  2004. const u8 *start;
  2005. size_t len;
  2006. bool action;
  2007. u64 filter;
  2008. u32 crc;
  2009. struct cfg80211_bss *bss;
  2010. int link_id;
  2011. bool from_ap;
  2012. };
  2013. struct ieee802_11_elems *
  2014. ieee802_11_parse_elems_full(struct ieee80211_elems_parse_params *params);
  2015. static inline struct ieee802_11_elems *
  2016. ieee802_11_parse_elems_crc(const u8 *start, size_t len, bool action,
  2017. u64 filter, u32 crc,
  2018. struct cfg80211_bss *bss)
  2019. {
  2020. struct ieee80211_elems_parse_params params = {
  2021. .mode = IEEE80211_CONN_MODE_HIGHEST,
  2022. .start = start,
  2023. .len = len,
  2024. .action = action,
  2025. .filter = filter,
  2026. .crc = crc,
  2027. .bss = bss,
  2028. .link_id = -1,
  2029. };
  2030. return ieee802_11_parse_elems_full(&params);
  2031. }
  2032. static inline struct ieee802_11_elems *
  2033. ieee802_11_parse_elems(const u8 *start, size_t len, bool action,
  2034. struct cfg80211_bss *bss)
  2035. {
  2036. return ieee802_11_parse_elems_crc(start, len, action, 0, 0, bss);
  2037. }
  2038. extern const int ieee802_1d_to_ac[8];
  2039. static inline int ieee80211_ac_from_tid(int tid)
  2040. {
  2041. return ieee802_1d_to_ac[tid & 7];
  2042. }
  2043. void ieee80211_dynamic_ps_enable_work(struct wiphy *wiphy,
  2044. struct wiphy_work *work);
  2045. void ieee80211_dynamic_ps_disable_work(struct wiphy *wiphy,
  2046. struct wiphy_work *work);
  2047. void ieee80211_dynamic_ps_timer(struct timer_list *t);
  2048. void ieee80211_send_nullfunc(struct ieee80211_local *local,
  2049. struct ieee80211_sub_if_data *sdata,
  2050. bool powersave);
  2051. void ieee80211_send_4addr_nullfunc(struct ieee80211_local *local,
  2052. struct ieee80211_sub_if_data *sdata);
  2053. void ieee80211_sta_tx_notify(struct ieee80211_sub_if_data *sdata,
  2054. struct ieee80211_hdr *hdr, bool ack, u16 tx_time);
  2055. unsigned int
  2056. ieee80211_get_vif_queues(struct ieee80211_local *local,
  2057. struct ieee80211_sub_if_data *sdata);
  2058. void ieee80211_wake_queues_by_reason(struct ieee80211_hw *hw,
  2059. unsigned long queues,
  2060. enum queue_stop_reason reason,
  2061. bool refcounted);
  2062. void ieee80211_stop_queues_by_reason(struct ieee80211_hw *hw,
  2063. unsigned long queues,
  2064. enum queue_stop_reason reason,
  2065. bool refcounted);
  2066. void ieee80211_wake_queue_by_reason(struct ieee80211_hw *hw, int queue,
  2067. enum queue_stop_reason reason,
  2068. bool refcounted);
  2069. void ieee80211_stop_queue_by_reason(struct ieee80211_hw *hw, int queue,
  2070. enum queue_stop_reason reason,
  2071. bool refcounted);
  2072. static inline void
  2073. ieee80211_stop_vif_queues(struct ieee80211_local *local,
  2074. struct ieee80211_sub_if_data *sdata,
  2075. enum queue_stop_reason reason)
  2076. {
  2077. ieee80211_stop_queues_by_reason(&local->hw,
  2078. ieee80211_get_vif_queues(local, sdata),
  2079. reason, true);
  2080. }
  2081. static inline void
  2082. ieee80211_wake_vif_queues(struct ieee80211_local *local,
  2083. struct ieee80211_sub_if_data *sdata,
  2084. enum queue_stop_reason reason)
  2085. {
  2086. ieee80211_wake_queues_by_reason(&local->hw,
  2087. ieee80211_get_vif_queues(local, sdata),
  2088. reason, true);
  2089. }
  2090. static inline void
  2091. ieee80211_stop_vif_queues_norefcount(struct ieee80211_local *local,
  2092. struct ieee80211_sub_if_data *sdata,
  2093. enum queue_stop_reason reason)
  2094. {
  2095. ieee80211_stop_queues_by_reason(&local->hw,
  2096. ieee80211_get_vif_queues(local, sdata),
  2097. reason, false);
  2098. }
  2099. static inline void
  2100. ieee80211_wake_vif_queues_norefcount(struct ieee80211_local *local,
  2101. struct ieee80211_sub_if_data *sdata,
  2102. enum queue_stop_reason reason)
  2103. {
  2104. ieee80211_wake_queues_by_reason(&local->hw,
  2105. ieee80211_get_vif_queues(local, sdata),
  2106. reason, false);
  2107. }
  2108. void ieee80211_add_pending_skb(struct ieee80211_local *local,
  2109. struct sk_buff *skb);
  2110. void ieee80211_add_pending_skbs(struct ieee80211_local *local,
  2111. struct sk_buff_head *skbs);
  2112. void ieee80211_flush_queues(struct ieee80211_local *local,
  2113. struct ieee80211_sub_if_data *sdata, bool drop);
  2114. void __ieee80211_flush_queues(struct ieee80211_local *local,
  2115. struct ieee80211_sub_if_data *sdata,
  2116. unsigned int queues, bool drop);
  2117. static inline bool ieee80211_can_run_worker(struct ieee80211_local *local)
  2118. {
  2119. /*
  2120. * It's unsafe to try to do any work during reconfigure flow.
  2121. * When the flow ends the work will be requeued.
  2122. */
  2123. if (local->in_reconfig)
  2124. return false;
  2125. /*
  2126. * If quiescing is set, we are racing with __ieee80211_suspend.
  2127. * __ieee80211_suspend flushes the workers after setting quiescing,
  2128. * and we check quiescing / suspended before enqueing new workers.
  2129. * We should abort the worker to avoid the races below.
  2130. */
  2131. if (local->quiescing)
  2132. return false;
  2133. /*
  2134. * We might already be suspended if the following scenario occurs:
  2135. * __ieee80211_suspend Control path
  2136. *
  2137. * if (local->quiescing)
  2138. * return;
  2139. * local->quiescing = true;
  2140. * flush_workqueue();
  2141. * queue_work(...);
  2142. * local->suspended = true;
  2143. * local->quiescing = false;
  2144. * worker starts running...
  2145. */
  2146. if (local->suspended)
  2147. return false;
  2148. return true;
  2149. }
  2150. int ieee80211_txq_setup_flows(struct ieee80211_local *local);
  2151. void ieee80211_txq_set_params(struct ieee80211_local *local);
  2152. void ieee80211_txq_teardown_flows(struct ieee80211_local *local);
  2153. void ieee80211_txq_init(struct ieee80211_sub_if_data *sdata,
  2154. struct sta_info *sta,
  2155. struct txq_info *txq, int tid);
  2156. void ieee80211_txq_purge(struct ieee80211_local *local,
  2157. struct txq_info *txqi);
  2158. void ieee80211_purge_sta_txqs(struct sta_info *sta);
  2159. void ieee80211_txq_remove_vlan(struct ieee80211_local *local,
  2160. struct ieee80211_sub_if_data *sdata);
  2161. void ieee80211_fill_txq_stats(struct cfg80211_txq_stats *txqstats,
  2162. struct txq_info *txqi);
  2163. void ieee80211_wake_txqs(struct tasklet_struct *t);
  2164. void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata,
  2165. u16 transaction, u16 auth_alg, u16 status,
  2166. const u8 *extra, size_t extra_len, const u8 *bssid,
  2167. const u8 *da, const u8 *key, u8 key_len, u8 key_idx,
  2168. u32 tx_flags);
  2169. void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata,
  2170. const u8 *da, const u8 *bssid,
  2171. u16 stype, u16 reason,
  2172. bool send_frame, u8 *frame_buf);
  2173. enum {
  2174. IEEE80211_PROBE_FLAG_DIRECTED = BIT(0),
  2175. IEEE80211_PROBE_FLAG_MIN_CONTENT = BIT(1),
  2176. IEEE80211_PROBE_FLAG_RANDOM_SN = BIT(2),
  2177. };
  2178. int ieee80211_build_preq_ies(struct ieee80211_sub_if_data *sdata, u8 *buffer,
  2179. size_t buffer_len,
  2180. struct ieee80211_scan_ies *ie_desc,
  2181. const u8 *ie, size_t ie_len,
  2182. u8 bands_used, u32 *rate_masks,
  2183. struct cfg80211_chan_def *chandef,
  2184. u32 flags);
  2185. struct sk_buff *ieee80211_build_probe_req(struct ieee80211_sub_if_data *sdata,
  2186. const u8 *src, const u8 *dst,
  2187. u32 ratemask,
  2188. struct ieee80211_channel *chan,
  2189. const u8 *ssid, size_t ssid_len,
  2190. const u8 *ie, size_t ie_len,
  2191. u32 flags);
  2192. u32 ieee80211_sta_get_rates(struct ieee80211_sub_if_data *sdata,
  2193. struct ieee802_11_elems *elems,
  2194. enum nl80211_band band, u32 *basic_rates);
  2195. int __ieee80211_request_smps_mgd(struct ieee80211_sub_if_data *sdata,
  2196. struct ieee80211_link_data *link,
  2197. enum ieee80211_smps_mode smps_mode);
  2198. void ieee80211_recalc_smps(struct ieee80211_sub_if_data *sdata,
  2199. struct ieee80211_link_data *link);
  2200. void ieee80211_recalc_min_chandef(struct ieee80211_sub_if_data *sdata,
  2201. int link_id);
  2202. size_t ieee80211_ie_split_vendor(const u8 *ies, size_t ielen, size_t offset);
  2203. u8 *ieee80211_ie_build_ht_cap(u8 *pos, struct ieee80211_sta_ht_cap *ht_cap,
  2204. u16 cap);
  2205. u8 *ieee80211_ie_build_ht_oper(u8 *pos, struct ieee80211_sta_ht_cap *ht_cap,
  2206. const struct cfg80211_chan_def *chandef,
  2207. u16 prot_mode, bool rifs_mode);
  2208. void ieee80211_ie_build_wide_bw_cs(u8 *pos,
  2209. const struct cfg80211_chan_def *chandef);
  2210. u8 *ieee80211_ie_build_vht_cap(u8 *pos, struct ieee80211_sta_vht_cap *vht_cap,
  2211. u32 cap);
  2212. u8 *ieee80211_ie_build_vht_oper(u8 *pos, struct ieee80211_sta_vht_cap *vht_cap,
  2213. const struct cfg80211_chan_def *chandef);
  2214. u8 ieee80211_ie_len_he_cap(struct ieee80211_sub_if_data *sdata);
  2215. u8 *ieee80211_ie_build_he_oper(u8 *pos, struct cfg80211_chan_def *chandef);
  2216. u8 *ieee80211_ie_build_eht_oper(u8 *pos, struct cfg80211_chan_def *chandef,
  2217. const struct ieee80211_sta_eht_cap *eht_cap);
  2218. int ieee80211_parse_bitrates(enum nl80211_chan_width width,
  2219. const struct ieee80211_supported_band *sband,
  2220. const u8 *srates, int srates_len, u32 *rates);
  2221. u8 *ieee80211_add_wmm_info_ie(u8 *buf, u8 qosinfo);
  2222. void ieee80211_add_s1g_capab_ie(struct ieee80211_sub_if_data *sdata,
  2223. struct ieee80211_sta_s1g_cap *caps,
  2224. struct sk_buff *skb);
  2225. void ieee80211_add_aid_request_ie(struct ieee80211_sub_if_data *sdata,
  2226. struct sk_buff *skb);
  2227. /* element building in SKBs */
  2228. int ieee80211_put_srates_elem(struct sk_buff *skb,
  2229. const struct ieee80211_supported_band *sband,
  2230. u32 basic_rates, u32 rate_flags, u32 masked_rates,
  2231. u8 element_id);
  2232. int ieee80211_put_he_cap(struct sk_buff *skb,
  2233. struct ieee80211_sub_if_data *sdata,
  2234. const struct ieee80211_supported_band *sband,
  2235. const struct ieee80211_conn_settings *conn);
  2236. int ieee80211_put_he_6ghz_cap(struct sk_buff *skb,
  2237. struct ieee80211_sub_if_data *sdata,
  2238. enum ieee80211_smps_mode smps_mode);
  2239. int ieee80211_put_eht_cap(struct sk_buff *skb,
  2240. struct ieee80211_sub_if_data *sdata,
  2241. const struct ieee80211_supported_band *sband,
  2242. const struct ieee80211_conn_settings *conn);
  2243. /* channel management */
  2244. bool ieee80211_chandef_ht_oper(const struct ieee80211_ht_operation *ht_oper,
  2245. struct cfg80211_chan_def *chandef);
  2246. bool ieee80211_chandef_vht_oper(struct ieee80211_hw *hw, u32 vht_cap_info,
  2247. const struct ieee80211_vht_operation *oper,
  2248. const struct ieee80211_ht_operation *htop,
  2249. struct cfg80211_chan_def *chandef);
  2250. void ieee80211_chandef_eht_oper(const struct ieee80211_eht_operation_info *info,
  2251. struct cfg80211_chan_def *chandef);
  2252. bool ieee80211_chandef_he_6ghz_oper(struct ieee80211_local *local,
  2253. const struct ieee80211_he_operation *he_oper,
  2254. const struct ieee80211_eht_operation *eht_oper,
  2255. struct cfg80211_chan_def *chandef);
  2256. bool ieee80211_chandef_s1g_oper(const struct ieee80211_s1g_oper_ie *oper,
  2257. struct cfg80211_chan_def *chandef);
  2258. void ieee80211_chandef_downgrade(struct cfg80211_chan_def *chandef,
  2259. struct ieee80211_conn_settings *conn);
  2260. static inline void
  2261. ieee80211_chanreq_downgrade(struct ieee80211_chan_req *chanreq,
  2262. struct ieee80211_conn_settings *conn)
  2263. {
  2264. ieee80211_chandef_downgrade(&chanreq->oper, conn);
  2265. if (WARN_ON(!conn))
  2266. return;
  2267. if (conn->mode < IEEE80211_CONN_MODE_EHT)
  2268. chanreq->ap.chan = NULL;
  2269. }
  2270. bool ieee80211_chanreq_identical(const struct ieee80211_chan_req *a,
  2271. const struct ieee80211_chan_req *b);
  2272. int __must_check
  2273. _ieee80211_link_use_channel(struct ieee80211_link_data *link,
  2274. const struct ieee80211_chan_req *req,
  2275. enum ieee80211_chanctx_mode mode,
  2276. bool assign_on_failure);
  2277. static inline int __must_check
  2278. ieee80211_link_use_channel(struct ieee80211_link_data *link,
  2279. const struct ieee80211_chan_req *req,
  2280. enum ieee80211_chanctx_mode mode)
  2281. {
  2282. return _ieee80211_link_use_channel(link, req, mode, false);
  2283. }
  2284. int __must_check
  2285. ieee80211_link_reserve_chanctx(struct ieee80211_link_data *link,
  2286. const struct ieee80211_chan_req *req,
  2287. enum ieee80211_chanctx_mode mode,
  2288. bool radar_required);
  2289. int __must_check
  2290. ieee80211_link_use_reserved_context(struct ieee80211_link_data *link);
  2291. int ieee80211_link_unreserve_chanctx(struct ieee80211_link_data *link);
  2292. int __must_check
  2293. ieee80211_link_change_chanreq(struct ieee80211_link_data *link,
  2294. const struct ieee80211_chan_req *req,
  2295. u64 *changed);
  2296. void __ieee80211_link_release_channel(struct ieee80211_link_data *link,
  2297. bool skip_idle_recalc);
  2298. void ieee80211_link_release_channel(struct ieee80211_link_data *link);
  2299. void ieee80211_link_vlan_copy_chanctx(struct ieee80211_link_data *link);
  2300. void ieee80211_link_copy_chanctx_to_vlans(struct ieee80211_link_data *link,
  2301. bool clear);
  2302. int ieee80211_chanctx_refcount(struct ieee80211_local *local,
  2303. struct ieee80211_chanctx *ctx);
  2304. void ieee80211_recalc_smps_chanctx(struct ieee80211_local *local,
  2305. struct ieee80211_chanctx *chanctx);
  2306. void ieee80211_recalc_chanctx_min_def(struct ieee80211_local *local,
  2307. struct ieee80211_chanctx *ctx,
  2308. struct ieee80211_link_data *rsvd_for,
  2309. bool check_reserved);
  2310. bool ieee80211_is_radar_required(struct ieee80211_local *local);
  2311. void ieee80211_dfs_cac_timer_work(struct wiphy *wiphy, struct wiphy_work *work);
  2312. void ieee80211_dfs_cac_cancel(struct ieee80211_local *local,
  2313. struct ieee80211_chanctx *chanctx);
  2314. void ieee80211_dfs_radar_detected_work(struct wiphy *wiphy,
  2315. struct wiphy_work *work);
  2316. int ieee80211_send_action_csa(struct ieee80211_sub_if_data *sdata,
  2317. struct cfg80211_csa_settings *csa_settings);
  2318. void ieee80211_recalc_dtim(struct ieee80211_local *local,
  2319. struct ieee80211_sub_if_data *sdata);
  2320. int ieee80211_check_combinations(struct ieee80211_sub_if_data *sdata,
  2321. const struct cfg80211_chan_def *chandef,
  2322. enum ieee80211_chanctx_mode chanmode,
  2323. u8 radar_detect, int radio_idx);
  2324. int ieee80211_max_num_channels(struct ieee80211_local *local, int radio_idx);
  2325. u32 ieee80211_get_radio_mask(struct wiphy *wiphy, struct net_device *dev);
  2326. void ieee80211_recalc_chanctx_chantype(struct ieee80211_local *local,
  2327. struct ieee80211_chanctx *ctx);
  2328. /* TDLS */
  2329. int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
  2330. const u8 *peer, int link_id,
  2331. u8 action_code, u8 dialog_token, u16 status_code,
  2332. u32 peer_capability, bool initiator,
  2333. const u8 *extra_ies, size_t extra_ies_len);
  2334. int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
  2335. const u8 *peer, enum nl80211_tdls_operation oper);
  2336. void ieee80211_tdls_peer_del_work(struct wiphy *wiphy, struct wiphy_work *wk);
  2337. int ieee80211_tdls_channel_switch(struct wiphy *wiphy, struct net_device *dev,
  2338. const u8 *addr, u8 oper_class,
  2339. struct cfg80211_chan_def *chandef);
  2340. void ieee80211_tdls_cancel_channel_switch(struct wiphy *wiphy,
  2341. struct net_device *dev,
  2342. const u8 *addr);
  2343. void ieee80211_teardown_tdls_peers(struct ieee80211_link_data *link);
  2344. void ieee80211_tdls_handle_disconnect(struct ieee80211_sub_if_data *sdata,
  2345. const u8 *peer, u16 reason);
  2346. void
  2347. ieee80211_process_tdls_channel_switch(struct ieee80211_sub_if_data *sdata,
  2348. struct sk_buff *skb);
  2349. const char *ieee80211_get_reason_code_string(u16 reason_code);
  2350. u16 ieee80211_encode_usf(int val);
  2351. u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len,
  2352. enum nl80211_iftype type);
  2353. extern const struct ethtool_ops ieee80211_ethtool_ops;
  2354. u32 ieee80211_calc_expected_tx_airtime(struct ieee80211_hw *hw,
  2355. struct ieee80211_vif *vif,
  2356. struct ieee80211_sta *pubsta,
  2357. int len, bool ampdu);
  2358. #ifdef CONFIG_MAC80211_NOINLINE
  2359. #define debug_noinline noinline
  2360. #else
  2361. #define debug_noinline
  2362. #endif
  2363. void ieee80211_init_frag_cache(struct ieee80211_fragment_cache *cache);
  2364. void ieee80211_destroy_frag_cache(struct ieee80211_fragment_cache *cache);
  2365. u8 ieee80211_ie_len_eht_cap(struct ieee80211_sub_if_data *sdata);
  2366. void
  2367. ieee80211_eht_cap_ie_to_sta_eht_cap(struct ieee80211_sub_if_data *sdata,
  2368. struct ieee80211_supported_band *sband,
  2369. const u8 *he_cap_ie, u8 he_cap_len,
  2370. const struct ieee80211_eht_cap_elem *eht_cap_ie_elem,
  2371. u8 eht_cap_len,
  2372. struct link_sta_info *link_sta);
  2373. void ieee80211_process_neg_ttlm_req(struct ieee80211_sub_if_data *sdata,
  2374. struct ieee80211_mgmt *mgmt, size_t len);
  2375. void ieee80211_process_neg_ttlm_res(struct ieee80211_sub_if_data *sdata,
  2376. struct ieee80211_mgmt *mgmt, size_t len);
  2377. int ieee80211_req_neg_ttlm(struct ieee80211_sub_if_data *sdata,
  2378. struct cfg80211_ttlm_params *params);
  2379. void ieee80211_check_wbrf_support(struct ieee80211_local *local);
  2380. void ieee80211_add_wbrf(struct ieee80211_local *local, struct cfg80211_chan_def *chandef);
  2381. void ieee80211_remove_wbrf(struct ieee80211_local *local, struct cfg80211_chan_def *chandef);
  2382. #if IS_ENABLED(CONFIG_MAC80211_KUNIT_TEST)
  2383. #define EXPORT_SYMBOL_IF_MAC80211_KUNIT(sym) EXPORT_SYMBOL_IF_KUNIT(sym)
  2384. #define VISIBLE_IF_MAC80211_KUNIT
  2385. ieee80211_rx_result
  2386. ieee80211_drop_unencrypted_mgmt(struct ieee80211_rx_data *rx);
  2387. int ieee80211_calc_chandef_subchan_offset(const struct cfg80211_chan_def *ap,
  2388. u8 n_partial_subchans);
  2389. void ieee80211_rearrange_tpe_psd(struct ieee80211_parsed_tpe_psd *psd,
  2390. const struct cfg80211_chan_def *ap,
  2391. const struct cfg80211_chan_def *used);
  2392. #else
  2393. #define EXPORT_SYMBOL_IF_MAC80211_KUNIT(sym)
  2394. #define VISIBLE_IF_MAC80211_KUNIT static
  2395. #endif
  2396. #endif /* IEEE80211_I_H */