ieee80211_i.h 81 KB

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