ieee80211.h 71 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452
  1. /*
  2. * IEEE 802.11 defines
  3. *
  4. * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
  5. * <jkmaline@cc.hut.fi>
  6. * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
  7. * Copyright (c) 2005, Devicescape Software, Inc.
  8. * Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net>
  9. * Copyright (c) 2013 - 2014 Intel Mobile Communications GmbH
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License version 2 as
  13. * published by the Free Software Foundation.
  14. */
  15. #ifndef LINUX_IEEE80211_H
  16. #define LINUX_IEEE80211_H
  17. #include <linux/types.h>
  18. #include <linux/if_ether.h>
  19. #include <asm/byteorder.h>
  20. /*
  21. * DS bit usage
  22. *
  23. * TA = transmitter address
  24. * RA = receiver address
  25. * DA = destination address
  26. * SA = source address
  27. *
  28. * ToDS FromDS A1(RA) A2(TA) A3 A4 Use
  29. * -----------------------------------------------------------------
  30. * 0 0 DA SA BSSID - IBSS/DLS
  31. * 0 1 DA BSSID SA - AP -> STA
  32. * 1 0 BSSID SA DA - AP <- STA
  33. * 1 1 RA TA DA SA unspecified (WDS)
  34. */
  35. #define FCS_LEN 4
  36. #define IEEE80211_FCTL_VERS 0x0003
  37. #define IEEE80211_FCTL_FTYPE 0x000c
  38. #define IEEE80211_FCTL_STYPE 0x00f0
  39. #define IEEE80211_FCTL_TODS 0x0100
  40. #define IEEE80211_FCTL_FROMDS 0x0200
  41. #define IEEE80211_FCTL_MOREFRAGS 0x0400
  42. #define IEEE80211_FCTL_RETRY 0x0800
  43. #define IEEE80211_FCTL_PM 0x1000
  44. #define IEEE80211_FCTL_MOREDATA 0x2000
  45. #define IEEE80211_FCTL_PROTECTED 0x4000
  46. #define IEEE80211_FCTL_ORDER 0x8000
  47. #define IEEE80211_FCTL_CTL_EXT 0x0f00
  48. #define IEEE80211_SCTL_FRAG 0x000F
  49. #define IEEE80211_SCTL_SEQ 0xFFF0
  50. #define IEEE80211_FTYPE_MGMT 0x0000
  51. #define IEEE80211_FTYPE_CTL 0x0004
  52. #define IEEE80211_FTYPE_DATA 0x0008
  53. #define IEEE80211_FTYPE_EXT 0x000c
  54. /* management */
  55. #define IEEE80211_STYPE_ASSOC_REQ 0x0000
  56. #define IEEE80211_STYPE_ASSOC_RESP 0x0010
  57. #define IEEE80211_STYPE_REASSOC_REQ 0x0020
  58. #define IEEE80211_STYPE_REASSOC_RESP 0x0030
  59. #define IEEE80211_STYPE_PROBE_REQ 0x0040
  60. #define IEEE80211_STYPE_PROBE_RESP 0x0050
  61. #define IEEE80211_STYPE_BEACON 0x0080
  62. #define IEEE80211_STYPE_ATIM 0x0090
  63. #define IEEE80211_STYPE_DISASSOC 0x00A0
  64. #define IEEE80211_STYPE_AUTH 0x00B0
  65. #define IEEE80211_STYPE_DEAUTH 0x00C0
  66. #define IEEE80211_STYPE_ACTION 0x00D0
  67. /* control */
  68. #define IEEE80211_STYPE_CTL_EXT 0x0060
  69. #define IEEE80211_STYPE_BACK_REQ 0x0080
  70. #define IEEE80211_STYPE_BACK 0x0090
  71. #define IEEE80211_STYPE_PSPOLL 0x00A0
  72. #define IEEE80211_STYPE_RTS 0x00B0
  73. #define IEEE80211_STYPE_CTS 0x00C0
  74. #define IEEE80211_STYPE_ACK 0x00D0
  75. #define IEEE80211_STYPE_CFEND 0x00E0
  76. #define IEEE80211_STYPE_CFENDACK 0x00F0
  77. /* data */
  78. #define IEEE80211_STYPE_DATA 0x0000
  79. #define IEEE80211_STYPE_DATA_CFACK 0x0010
  80. #define IEEE80211_STYPE_DATA_CFPOLL 0x0020
  81. #define IEEE80211_STYPE_DATA_CFACKPOLL 0x0030
  82. #define IEEE80211_STYPE_NULLFUNC 0x0040
  83. #define IEEE80211_STYPE_CFACK 0x0050
  84. #define IEEE80211_STYPE_CFPOLL 0x0060
  85. #define IEEE80211_STYPE_CFACKPOLL 0x0070
  86. #define IEEE80211_STYPE_QOS_DATA 0x0080
  87. #define IEEE80211_STYPE_QOS_DATA_CFACK 0x0090
  88. #define IEEE80211_STYPE_QOS_DATA_CFPOLL 0x00A0
  89. #define IEEE80211_STYPE_QOS_DATA_CFACKPOLL 0x00B0
  90. #define IEEE80211_STYPE_QOS_NULLFUNC 0x00C0
  91. #define IEEE80211_STYPE_QOS_CFACK 0x00D0
  92. #define IEEE80211_STYPE_QOS_CFPOLL 0x00E0
  93. #define IEEE80211_STYPE_QOS_CFACKPOLL 0x00F0
  94. /* extension, added by 802.11ad */
  95. #define IEEE80211_STYPE_DMG_BEACON 0x0000
  96. /* control extension - for IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTL_EXT */
  97. #define IEEE80211_CTL_EXT_POLL 0x2000
  98. #define IEEE80211_CTL_EXT_SPR 0x3000
  99. #define IEEE80211_CTL_EXT_GRANT 0x4000
  100. #define IEEE80211_CTL_EXT_DMG_CTS 0x5000
  101. #define IEEE80211_CTL_EXT_DMG_DTS 0x6000
  102. #define IEEE80211_CTL_EXT_SSW 0x8000
  103. #define IEEE80211_CTL_EXT_SSW_FBACK 0x9000
  104. #define IEEE80211_CTL_EXT_SSW_ACK 0xa000
  105. #define IEEE80211_SN_MASK ((IEEE80211_SCTL_SEQ) >> 4)
  106. #define IEEE80211_MAX_SN IEEE80211_SN_MASK
  107. #define IEEE80211_SN_MODULO (IEEE80211_MAX_SN + 1)
  108. static inline int ieee80211_sn_less(u16 sn1, u16 sn2)
  109. {
  110. return ((sn1 - sn2) & IEEE80211_SN_MASK) > (IEEE80211_SN_MODULO >> 1);
  111. }
  112. static inline u16 ieee80211_sn_add(u16 sn1, u16 sn2)
  113. {
  114. return (sn1 + sn2) & IEEE80211_SN_MASK;
  115. }
  116. static inline u16 ieee80211_sn_inc(u16 sn)
  117. {
  118. return ieee80211_sn_add(sn, 1);
  119. }
  120. static inline u16 ieee80211_sn_sub(u16 sn1, u16 sn2)
  121. {
  122. return (sn1 - sn2) & IEEE80211_SN_MASK;
  123. }
  124. #define IEEE80211_SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
  125. #define IEEE80211_SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ)
  126. /* miscellaneous IEEE 802.11 constants */
  127. #define IEEE80211_MAX_FRAG_THRESHOLD 2352
  128. #define IEEE80211_MAX_RTS_THRESHOLD 2353
  129. #define IEEE80211_MAX_AID 2007
  130. #define IEEE80211_MAX_TIM_LEN 251
  131. #define IEEE80211_MAX_MESH_PEERINGS 63
  132. /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
  133. 6.2.1.1.2.
  134. 802.11e clarifies the figure in section 7.1.2. The frame body is
  135. up to 2304 octets long (maximum MSDU size) plus any crypt overhead. */
  136. #define IEEE80211_MAX_DATA_LEN 2304
  137. /* 802.11ad extends maximum MSDU size for DMG (freq > 40Ghz) networks
  138. * to 7920 bytes, see 8.2.3 General frame format
  139. */
  140. #define IEEE80211_MAX_DATA_LEN_DMG 7920
  141. /* 30 byte 4 addr hdr, 2 byte QoS, 2304 byte MSDU, 12 byte crypt, 4 byte FCS */
  142. #define IEEE80211_MAX_FRAME_LEN 2352
  143. #define IEEE80211_MAX_SSID_LEN 32
  144. #define IEEE80211_MAX_MESH_ID_LEN 32
  145. #define IEEE80211_FIRST_TSPEC_TSID 8
  146. #define IEEE80211_NUM_TIDS 16
  147. /* number of user priorities 802.11 uses */
  148. #define IEEE80211_NUM_UPS 8
  149. #define IEEE80211_QOS_CTL_LEN 2
  150. /* 1d tag mask */
  151. #define IEEE80211_QOS_CTL_TAG1D_MASK 0x0007
  152. /* TID mask */
  153. #define IEEE80211_QOS_CTL_TID_MASK 0x000f
  154. /* EOSP */
  155. #define IEEE80211_QOS_CTL_EOSP 0x0010
  156. /* ACK policy */
  157. #define IEEE80211_QOS_CTL_ACK_POLICY_NORMAL 0x0000
  158. #define IEEE80211_QOS_CTL_ACK_POLICY_NOACK 0x0020
  159. #define IEEE80211_QOS_CTL_ACK_POLICY_NO_EXPL 0x0040
  160. #define IEEE80211_QOS_CTL_ACK_POLICY_BLOCKACK 0x0060
  161. #define IEEE80211_QOS_CTL_ACK_POLICY_MASK 0x0060
  162. /* A-MSDU 802.11n */
  163. #define IEEE80211_QOS_CTL_A_MSDU_PRESENT 0x0080
  164. /* Mesh Control 802.11s */
  165. #define IEEE80211_QOS_CTL_MESH_CONTROL_PRESENT 0x0100
  166. /* Mesh Power Save Level */
  167. #define IEEE80211_QOS_CTL_MESH_PS_LEVEL 0x0200
  168. /* Mesh Receiver Service Period Initiated */
  169. #define IEEE80211_QOS_CTL_RSPI 0x0400
  170. /* U-APSD queue for WMM IEs sent by AP */
  171. #define IEEE80211_WMM_IE_AP_QOSINFO_UAPSD (1<<7)
  172. #define IEEE80211_WMM_IE_AP_QOSINFO_PARAM_SET_CNT_MASK 0x0f
  173. /* U-APSD queues for WMM IEs sent by STA */
  174. #define IEEE80211_WMM_IE_STA_QOSINFO_AC_VO (1<<0)
  175. #define IEEE80211_WMM_IE_STA_QOSINFO_AC_VI (1<<1)
  176. #define IEEE80211_WMM_IE_STA_QOSINFO_AC_BK (1<<2)
  177. #define IEEE80211_WMM_IE_STA_QOSINFO_AC_BE (1<<3)
  178. #define IEEE80211_WMM_IE_STA_QOSINFO_AC_MASK 0x0f
  179. /* U-APSD max SP length for WMM IEs sent by STA */
  180. #define IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL 0x00
  181. #define IEEE80211_WMM_IE_STA_QOSINFO_SP_2 0x01
  182. #define IEEE80211_WMM_IE_STA_QOSINFO_SP_4 0x02
  183. #define IEEE80211_WMM_IE_STA_QOSINFO_SP_6 0x03
  184. #define IEEE80211_WMM_IE_STA_QOSINFO_SP_MASK 0x03
  185. #define IEEE80211_WMM_IE_STA_QOSINFO_SP_SHIFT 5
  186. #define IEEE80211_HT_CTL_LEN 4
  187. struct ieee80211_hdr {
  188. __le16 frame_control;
  189. __le16 duration_id;
  190. u8 addr1[ETH_ALEN];
  191. u8 addr2[ETH_ALEN];
  192. u8 addr3[ETH_ALEN];
  193. __le16 seq_ctrl;
  194. u8 addr4[ETH_ALEN];
  195. } __packed __aligned(2);
  196. struct ieee80211_hdr_3addr {
  197. __le16 frame_control;
  198. __le16 duration_id;
  199. u8 addr1[ETH_ALEN];
  200. u8 addr2[ETH_ALEN];
  201. u8 addr3[ETH_ALEN];
  202. __le16 seq_ctrl;
  203. } __packed __aligned(2);
  204. struct ieee80211_qos_hdr {
  205. __le16 frame_control;
  206. __le16 duration_id;
  207. u8 addr1[ETH_ALEN];
  208. u8 addr2[ETH_ALEN];
  209. u8 addr3[ETH_ALEN];
  210. __le16 seq_ctrl;
  211. __le16 qos_ctrl;
  212. } __packed __aligned(2);
  213. /**
  214. * ieee80211_has_tods - check if IEEE80211_FCTL_TODS is set
  215. * @fc: frame control bytes in little-endian byteorder
  216. */
  217. static inline int ieee80211_has_tods(__le16 fc)
  218. {
  219. return (fc & cpu_to_le16(IEEE80211_FCTL_TODS)) != 0;
  220. }
  221. /**
  222. * ieee80211_has_fromds - check if IEEE80211_FCTL_FROMDS is set
  223. * @fc: frame control bytes in little-endian byteorder
  224. */
  225. static inline int ieee80211_has_fromds(__le16 fc)
  226. {
  227. return (fc & cpu_to_le16(IEEE80211_FCTL_FROMDS)) != 0;
  228. }
  229. /**
  230. * ieee80211_has_a4 - check if IEEE80211_FCTL_TODS and IEEE80211_FCTL_FROMDS are set
  231. * @fc: frame control bytes in little-endian byteorder
  232. */
  233. static inline int ieee80211_has_a4(__le16 fc)
  234. {
  235. __le16 tmp = cpu_to_le16(IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS);
  236. return (fc & tmp) == tmp;
  237. }
  238. /**
  239. * ieee80211_has_morefrags - check if IEEE80211_FCTL_MOREFRAGS is set
  240. * @fc: frame control bytes in little-endian byteorder
  241. */
  242. static inline int ieee80211_has_morefrags(__le16 fc)
  243. {
  244. return (fc & cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)) != 0;
  245. }
  246. /**
  247. * ieee80211_has_retry - check if IEEE80211_FCTL_RETRY is set
  248. * @fc: frame control bytes in little-endian byteorder
  249. */
  250. static inline int ieee80211_has_retry(__le16 fc)
  251. {
  252. return (fc & cpu_to_le16(IEEE80211_FCTL_RETRY)) != 0;
  253. }
  254. /**
  255. * ieee80211_has_pm - check if IEEE80211_FCTL_PM is set
  256. * @fc: frame control bytes in little-endian byteorder
  257. */
  258. static inline int ieee80211_has_pm(__le16 fc)
  259. {
  260. return (fc & cpu_to_le16(IEEE80211_FCTL_PM)) != 0;
  261. }
  262. /**
  263. * ieee80211_has_moredata - check if IEEE80211_FCTL_MOREDATA is set
  264. * @fc: frame control bytes in little-endian byteorder
  265. */
  266. static inline int ieee80211_has_moredata(__le16 fc)
  267. {
  268. return (fc & cpu_to_le16(IEEE80211_FCTL_MOREDATA)) != 0;
  269. }
  270. /**
  271. * ieee80211_has_protected - check if IEEE80211_FCTL_PROTECTED is set
  272. * @fc: frame control bytes in little-endian byteorder
  273. */
  274. static inline int ieee80211_has_protected(__le16 fc)
  275. {
  276. return (fc & cpu_to_le16(IEEE80211_FCTL_PROTECTED)) != 0;
  277. }
  278. /**
  279. * ieee80211_has_order - check if IEEE80211_FCTL_ORDER is set
  280. * @fc: frame control bytes in little-endian byteorder
  281. */
  282. static inline int ieee80211_has_order(__le16 fc)
  283. {
  284. return (fc & cpu_to_le16(IEEE80211_FCTL_ORDER)) != 0;
  285. }
  286. /**
  287. * ieee80211_is_mgmt - check if type is IEEE80211_FTYPE_MGMT
  288. * @fc: frame control bytes in little-endian byteorder
  289. */
  290. static inline int ieee80211_is_mgmt(__le16 fc)
  291. {
  292. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
  293. cpu_to_le16(IEEE80211_FTYPE_MGMT);
  294. }
  295. /**
  296. * ieee80211_is_ctl - check if type is IEEE80211_FTYPE_CTL
  297. * @fc: frame control bytes in little-endian byteorder
  298. */
  299. static inline int ieee80211_is_ctl(__le16 fc)
  300. {
  301. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
  302. cpu_to_le16(IEEE80211_FTYPE_CTL);
  303. }
  304. /**
  305. * ieee80211_is_data - check if type is IEEE80211_FTYPE_DATA
  306. * @fc: frame control bytes in little-endian byteorder
  307. */
  308. static inline int ieee80211_is_data(__le16 fc)
  309. {
  310. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
  311. cpu_to_le16(IEEE80211_FTYPE_DATA);
  312. }
  313. /**
  314. * ieee80211_is_data_qos - check if type is IEEE80211_FTYPE_DATA and IEEE80211_STYPE_QOS_DATA is set
  315. * @fc: frame control bytes in little-endian byteorder
  316. */
  317. static inline int ieee80211_is_data_qos(__le16 fc)
  318. {
  319. /*
  320. * mask with QOS_DATA rather than IEEE80211_FCTL_STYPE as we just need
  321. * to check the one bit
  322. */
  323. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_STYPE_QOS_DATA)) ==
  324. cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_DATA);
  325. }
  326. /**
  327. * ieee80211_is_data_present - check if type is IEEE80211_FTYPE_DATA and has data
  328. * @fc: frame control bytes in little-endian byteorder
  329. */
  330. static inline int ieee80211_is_data_present(__le16 fc)
  331. {
  332. /*
  333. * mask with 0x40 and test that that bit is clear to only return true
  334. * for the data-containing substypes.
  335. */
  336. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | 0x40)) ==
  337. cpu_to_le16(IEEE80211_FTYPE_DATA);
  338. }
  339. /**
  340. * ieee80211_is_assoc_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ASSOC_REQ
  341. * @fc: frame control bytes in little-endian byteorder
  342. */
  343. static inline int ieee80211_is_assoc_req(__le16 fc)
  344. {
  345. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  346. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ASSOC_REQ);
  347. }
  348. /**
  349. * ieee80211_is_assoc_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ASSOC_RESP
  350. * @fc: frame control bytes in little-endian byteorder
  351. */
  352. static inline int ieee80211_is_assoc_resp(__le16 fc)
  353. {
  354. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  355. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ASSOC_RESP);
  356. }
  357. /**
  358. * ieee80211_is_reassoc_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_REASSOC_REQ
  359. * @fc: frame control bytes in little-endian byteorder
  360. */
  361. static inline int ieee80211_is_reassoc_req(__le16 fc)
  362. {
  363. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  364. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_REASSOC_REQ);
  365. }
  366. /**
  367. * ieee80211_is_reassoc_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_REASSOC_RESP
  368. * @fc: frame control bytes in little-endian byteorder
  369. */
  370. static inline int ieee80211_is_reassoc_resp(__le16 fc)
  371. {
  372. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  373. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_REASSOC_RESP);
  374. }
  375. /**
  376. * ieee80211_is_probe_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_PROBE_REQ
  377. * @fc: frame control bytes in little-endian byteorder
  378. */
  379. static inline int ieee80211_is_probe_req(__le16 fc)
  380. {
  381. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  382. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ);
  383. }
  384. /**
  385. * ieee80211_is_probe_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_PROBE_RESP
  386. * @fc: frame control bytes in little-endian byteorder
  387. */
  388. static inline int ieee80211_is_probe_resp(__le16 fc)
  389. {
  390. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  391. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
  392. }
  393. /**
  394. * ieee80211_is_beacon - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_BEACON
  395. * @fc: frame control bytes in little-endian byteorder
  396. */
  397. static inline int ieee80211_is_beacon(__le16 fc)
  398. {
  399. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  400. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
  401. }
  402. /**
  403. * ieee80211_is_atim - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ATIM
  404. * @fc: frame control bytes in little-endian byteorder
  405. */
  406. static inline int ieee80211_is_atim(__le16 fc)
  407. {
  408. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  409. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ATIM);
  410. }
  411. /**
  412. * ieee80211_is_disassoc - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_DISASSOC
  413. * @fc: frame control bytes in little-endian byteorder
  414. */
  415. static inline int ieee80211_is_disassoc(__le16 fc)
  416. {
  417. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  418. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DISASSOC);
  419. }
  420. /**
  421. * ieee80211_is_auth - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_AUTH
  422. * @fc: frame control bytes in little-endian byteorder
  423. */
  424. static inline int ieee80211_is_auth(__le16 fc)
  425. {
  426. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  427. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH);
  428. }
  429. /**
  430. * ieee80211_is_deauth - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_DEAUTH
  431. * @fc: frame control bytes in little-endian byteorder
  432. */
  433. static inline int ieee80211_is_deauth(__le16 fc)
  434. {
  435. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  436. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DEAUTH);
  437. }
  438. /**
  439. * ieee80211_is_action - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ACTION
  440. * @fc: frame control bytes in little-endian byteorder
  441. */
  442. static inline int ieee80211_is_action(__le16 fc)
  443. {
  444. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  445. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ACTION);
  446. }
  447. /**
  448. * ieee80211_is_back_req - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_BACK_REQ
  449. * @fc: frame control bytes in little-endian byteorder
  450. */
  451. static inline int ieee80211_is_back_req(__le16 fc)
  452. {
  453. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  454. cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_BACK_REQ);
  455. }
  456. /**
  457. * ieee80211_is_back - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_BACK
  458. * @fc: frame control bytes in little-endian byteorder
  459. */
  460. static inline int ieee80211_is_back(__le16 fc)
  461. {
  462. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  463. cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_BACK);
  464. }
  465. /**
  466. * ieee80211_is_pspoll - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_PSPOLL
  467. * @fc: frame control bytes in little-endian byteorder
  468. */
  469. static inline int ieee80211_is_pspoll(__le16 fc)
  470. {
  471. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  472. cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL);
  473. }
  474. /**
  475. * ieee80211_is_rts - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_RTS
  476. * @fc: frame control bytes in little-endian byteorder
  477. */
  478. static inline int ieee80211_is_rts(__le16 fc)
  479. {
  480. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  481. cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS);
  482. }
  483. /**
  484. * ieee80211_is_cts - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CTS
  485. * @fc: frame control bytes in little-endian byteorder
  486. */
  487. static inline int ieee80211_is_cts(__le16 fc)
  488. {
  489. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  490. cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS);
  491. }
  492. /**
  493. * ieee80211_is_ack - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_ACK
  494. * @fc: frame control bytes in little-endian byteorder
  495. */
  496. static inline int ieee80211_is_ack(__le16 fc)
  497. {
  498. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  499. cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_ACK);
  500. }
  501. /**
  502. * ieee80211_is_cfend - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CFEND
  503. * @fc: frame control bytes in little-endian byteorder
  504. */
  505. static inline int ieee80211_is_cfend(__le16 fc)
  506. {
  507. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  508. cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CFEND);
  509. }
  510. /**
  511. * ieee80211_is_cfendack - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CFENDACK
  512. * @fc: frame control bytes in little-endian byteorder
  513. */
  514. static inline int ieee80211_is_cfendack(__le16 fc)
  515. {
  516. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  517. cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CFENDACK);
  518. }
  519. /**
  520. * ieee80211_is_nullfunc - check if frame is a regular (non-QoS) nullfunc frame
  521. * @fc: frame control bytes in little-endian byteorder
  522. */
  523. static inline int ieee80211_is_nullfunc(__le16 fc)
  524. {
  525. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  526. cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC);
  527. }
  528. /**
  529. * ieee80211_is_qos_nullfunc - check if frame is a QoS nullfunc frame
  530. * @fc: frame control bytes in little-endian byteorder
  531. */
  532. static inline int ieee80211_is_qos_nullfunc(__le16 fc)
  533. {
  534. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  535. cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_NULLFUNC);
  536. }
  537. /**
  538. * ieee80211_is_bufferable_mmpdu - check if frame is bufferable MMPDU
  539. * @fc: frame control field in little-endian byteorder
  540. */
  541. static inline bool ieee80211_is_bufferable_mmpdu(__le16 fc)
  542. {
  543. /* IEEE 802.11-2012, definition of "bufferable management frame";
  544. * note that this ignores the IBSS special case. */
  545. return ieee80211_is_mgmt(fc) &&
  546. (ieee80211_is_action(fc) ||
  547. ieee80211_is_disassoc(fc) ||
  548. ieee80211_is_deauth(fc));
  549. }
  550. /**
  551. * ieee80211_is_first_frag - check if IEEE80211_SCTL_FRAG is not set
  552. * @seq_ctrl: frame sequence control bytes in little-endian byteorder
  553. */
  554. static inline int ieee80211_is_first_frag(__le16 seq_ctrl)
  555. {
  556. return (seq_ctrl & cpu_to_le16(IEEE80211_SCTL_FRAG)) == 0;
  557. }
  558. struct ieee80211s_hdr {
  559. u8 flags;
  560. u8 ttl;
  561. __le32 seqnum;
  562. u8 eaddr1[ETH_ALEN];
  563. u8 eaddr2[ETH_ALEN];
  564. } __packed __aligned(2);
  565. /* Mesh flags */
  566. #define MESH_FLAGS_AE_A4 0x1
  567. #define MESH_FLAGS_AE_A5_A6 0x2
  568. #define MESH_FLAGS_AE 0x3
  569. #define MESH_FLAGS_PS_DEEP 0x4
  570. /**
  571. * enum ieee80211_preq_flags - mesh PREQ element flags
  572. *
  573. * @IEEE80211_PREQ_PROACTIVE_PREP_FLAG: proactive PREP subfield
  574. */
  575. enum ieee80211_preq_flags {
  576. IEEE80211_PREQ_PROACTIVE_PREP_FLAG = 1<<2,
  577. };
  578. /**
  579. * enum ieee80211_preq_target_flags - mesh PREQ element per target flags
  580. *
  581. * @IEEE80211_PREQ_TO_FLAG: target only subfield
  582. * @IEEE80211_PREQ_USN_FLAG: unknown target HWMP sequence number subfield
  583. */
  584. enum ieee80211_preq_target_flags {
  585. IEEE80211_PREQ_TO_FLAG = 1<<0,
  586. IEEE80211_PREQ_USN_FLAG = 1<<2,
  587. };
  588. /**
  589. * struct ieee80211_quiet_ie
  590. *
  591. * This structure refers to "Quiet information element"
  592. */
  593. struct ieee80211_quiet_ie {
  594. u8 count;
  595. u8 period;
  596. __le16 duration;
  597. __le16 offset;
  598. } __packed;
  599. /**
  600. * struct ieee80211_msrment_ie
  601. *
  602. * This structure refers to "Measurement Request/Report information element"
  603. */
  604. struct ieee80211_msrment_ie {
  605. u8 token;
  606. u8 mode;
  607. u8 type;
  608. u8 request[0];
  609. } __packed;
  610. /**
  611. * struct ieee80211_channel_sw_ie
  612. *
  613. * This structure refers to "Channel Switch Announcement information element"
  614. */
  615. struct ieee80211_channel_sw_ie {
  616. u8 mode;
  617. u8 new_ch_num;
  618. u8 count;
  619. } __packed;
  620. /**
  621. * struct ieee80211_ext_chansw_ie
  622. *
  623. * This structure represents the "Extended Channel Switch Announcement element"
  624. */
  625. struct ieee80211_ext_chansw_ie {
  626. u8 mode;
  627. u8 new_operating_class;
  628. u8 new_ch_num;
  629. u8 count;
  630. } __packed;
  631. /**
  632. * struct ieee80211_sec_chan_offs_ie - secondary channel offset IE
  633. * @sec_chan_offs: secondary channel offset, uses IEEE80211_HT_PARAM_CHA_SEC_*
  634. * values here
  635. * This structure represents the "Secondary Channel Offset element"
  636. */
  637. struct ieee80211_sec_chan_offs_ie {
  638. u8 sec_chan_offs;
  639. } __packed;
  640. /**
  641. * struct ieee80211_mesh_chansw_params_ie - mesh channel switch parameters IE
  642. *
  643. * This structure represents the "Mesh Channel Switch Paramters element"
  644. */
  645. struct ieee80211_mesh_chansw_params_ie {
  646. u8 mesh_ttl;
  647. u8 mesh_flags;
  648. __le16 mesh_reason;
  649. __le16 mesh_pre_value;
  650. } __packed;
  651. /**
  652. * struct ieee80211_wide_bw_chansw_ie - wide bandwidth channel switch IE
  653. */
  654. struct ieee80211_wide_bw_chansw_ie {
  655. u8 new_channel_width;
  656. u8 new_center_freq_seg0, new_center_freq_seg1;
  657. } __packed;
  658. /**
  659. * struct ieee80211_tim
  660. *
  661. * This structure refers to "Traffic Indication Map information element"
  662. */
  663. struct ieee80211_tim_ie {
  664. u8 dtim_count;
  665. u8 dtim_period;
  666. u8 bitmap_ctrl;
  667. /* variable size: 1 - 251 bytes */
  668. u8 virtual_map[1];
  669. } __packed;
  670. /**
  671. * struct ieee80211_meshconf_ie
  672. *
  673. * This structure refers to "Mesh Configuration information element"
  674. */
  675. struct ieee80211_meshconf_ie {
  676. u8 meshconf_psel;
  677. u8 meshconf_pmetric;
  678. u8 meshconf_congest;
  679. u8 meshconf_synch;
  680. u8 meshconf_auth;
  681. u8 meshconf_form;
  682. u8 meshconf_cap;
  683. } __packed;
  684. /**
  685. * enum mesh_config_capab_flags - Mesh Configuration IE capability field flags
  686. *
  687. * @IEEE80211_MESHCONF_CAPAB_ACCEPT_PLINKS: STA is willing to establish
  688. * additional mesh peerings with other mesh STAs
  689. * @IEEE80211_MESHCONF_CAPAB_FORWARDING: the STA forwards MSDUs
  690. * @IEEE80211_MESHCONF_CAPAB_TBTT_ADJUSTING: TBTT adjustment procedure
  691. * is ongoing
  692. * @IEEE80211_MESHCONF_CAPAB_POWER_SAVE_LEVEL: STA is in deep sleep mode or has
  693. * neighbors in deep sleep mode
  694. */
  695. enum mesh_config_capab_flags {
  696. IEEE80211_MESHCONF_CAPAB_ACCEPT_PLINKS = 0x01,
  697. IEEE80211_MESHCONF_CAPAB_FORWARDING = 0x08,
  698. IEEE80211_MESHCONF_CAPAB_TBTT_ADJUSTING = 0x20,
  699. IEEE80211_MESHCONF_CAPAB_POWER_SAVE_LEVEL = 0x40,
  700. };
  701. /**
  702. * mesh channel switch parameters element's flag indicator
  703. *
  704. */
  705. #define WLAN_EID_CHAN_SWITCH_PARAM_TX_RESTRICT BIT(0)
  706. #define WLAN_EID_CHAN_SWITCH_PARAM_INITIATOR BIT(1)
  707. #define WLAN_EID_CHAN_SWITCH_PARAM_REASON BIT(2)
  708. /**
  709. * struct ieee80211_rann_ie
  710. *
  711. * This structure refers to "Root Announcement information element"
  712. */
  713. struct ieee80211_rann_ie {
  714. u8 rann_flags;
  715. u8 rann_hopcount;
  716. u8 rann_ttl;
  717. u8 rann_addr[ETH_ALEN];
  718. __le32 rann_seq;
  719. __le32 rann_interval;
  720. __le32 rann_metric;
  721. } __packed;
  722. enum ieee80211_rann_flags {
  723. RANN_FLAG_IS_GATE = 1 << 0,
  724. };
  725. enum ieee80211_ht_chanwidth_values {
  726. IEEE80211_HT_CHANWIDTH_20MHZ = 0,
  727. IEEE80211_HT_CHANWIDTH_ANY = 1,
  728. };
  729. /**
  730. * enum ieee80211_opmode_bits - VHT operating mode field bits
  731. * @IEEE80211_OPMODE_NOTIF_CHANWIDTH_MASK: channel width mask
  732. * @IEEE80211_OPMODE_NOTIF_CHANWIDTH_20MHZ: 20 MHz channel width
  733. * @IEEE80211_OPMODE_NOTIF_CHANWIDTH_40MHZ: 40 MHz channel width
  734. * @IEEE80211_OPMODE_NOTIF_CHANWIDTH_80MHZ: 80 MHz channel width
  735. * @IEEE80211_OPMODE_NOTIF_CHANWIDTH_160MHZ: 160 MHz or 80+80 MHz channel width
  736. * @IEEE80211_OPMODE_NOTIF_RX_NSS_MASK: number of spatial streams mask
  737. * (the NSS value is the value of this field + 1)
  738. * @IEEE80211_OPMODE_NOTIF_RX_NSS_SHIFT: number of spatial streams shift
  739. * @IEEE80211_OPMODE_NOTIF_RX_NSS_TYPE_BF: indicates streams in SU-MIMO PPDU
  740. * using a beamforming steering matrix
  741. */
  742. enum ieee80211_vht_opmode_bits {
  743. IEEE80211_OPMODE_NOTIF_CHANWIDTH_MASK = 3,
  744. IEEE80211_OPMODE_NOTIF_CHANWIDTH_20MHZ = 0,
  745. IEEE80211_OPMODE_NOTIF_CHANWIDTH_40MHZ = 1,
  746. IEEE80211_OPMODE_NOTIF_CHANWIDTH_80MHZ = 2,
  747. IEEE80211_OPMODE_NOTIF_CHANWIDTH_160MHZ = 3,
  748. IEEE80211_OPMODE_NOTIF_RX_NSS_MASK = 0x70,
  749. IEEE80211_OPMODE_NOTIF_RX_NSS_SHIFT = 4,
  750. IEEE80211_OPMODE_NOTIF_RX_NSS_TYPE_BF = 0x80,
  751. };
  752. #define WLAN_SA_QUERY_TR_ID_LEN 2
  753. /**
  754. * struct ieee80211_tpc_report_ie
  755. *
  756. * This structure refers to "TPC Report element"
  757. */
  758. struct ieee80211_tpc_report_ie {
  759. u8 tx_power;
  760. u8 link_margin;
  761. } __packed;
  762. struct ieee80211_mgmt {
  763. __le16 frame_control;
  764. __le16 duration;
  765. u8 da[ETH_ALEN];
  766. u8 sa[ETH_ALEN];
  767. u8 bssid[ETH_ALEN];
  768. __le16 seq_ctrl;
  769. union {
  770. struct {
  771. __le16 auth_alg;
  772. __le16 auth_transaction;
  773. __le16 status_code;
  774. /* possibly followed by Challenge text */
  775. u8 variable[0];
  776. } __packed auth;
  777. struct {
  778. __le16 reason_code;
  779. } __packed deauth;
  780. struct {
  781. __le16 capab_info;
  782. __le16 listen_interval;
  783. /* followed by SSID and Supported rates */
  784. u8 variable[0];
  785. } __packed assoc_req;
  786. struct {
  787. __le16 capab_info;
  788. __le16 status_code;
  789. __le16 aid;
  790. /* followed by Supported rates */
  791. u8 variable[0];
  792. } __packed assoc_resp, reassoc_resp;
  793. struct {
  794. __le16 capab_info;
  795. __le16 listen_interval;
  796. u8 current_ap[ETH_ALEN];
  797. /* followed by SSID and Supported rates */
  798. u8 variable[0];
  799. } __packed reassoc_req;
  800. struct {
  801. __le16 reason_code;
  802. } __packed disassoc;
  803. struct {
  804. __le64 timestamp;
  805. __le16 beacon_int;
  806. __le16 capab_info;
  807. /* followed by some of SSID, Supported rates,
  808. * FH Params, DS Params, CF Params, IBSS Params, TIM */
  809. u8 variable[0];
  810. } __packed beacon;
  811. struct {
  812. /* only variable items: SSID, Supported rates */
  813. u8 variable[0];
  814. } __packed probe_req;
  815. struct {
  816. __le64 timestamp;
  817. __le16 beacon_int;
  818. __le16 capab_info;
  819. /* followed by some of SSID, Supported rates,
  820. * FH Params, DS Params, CF Params, IBSS Params */
  821. u8 variable[0];
  822. } __packed probe_resp;
  823. struct {
  824. u8 category;
  825. union {
  826. struct {
  827. u8 action_code;
  828. u8 dialog_token;
  829. u8 status_code;
  830. u8 variable[0];
  831. } __packed wme_action;
  832. struct{
  833. u8 action_code;
  834. u8 variable[0];
  835. } __packed chan_switch;
  836. struct{
  837. u8 action_code;
  838. struct ieee80211_ext_chansw_ie data;
  839. u8 variable[0];
  840. } __packed ext_chan_switch;
  841. struct{
  842. u8 action_code;
  843. u8 dialog_token;
  844. u8 element_id;
  845. u8 length;
  846. struct ieee80211_msrment_ie msr_elem;
  847. } __packed measurement;
  848. struct{
  849. u8 action_code;
  850. u8 dialog_token;
  851. __le16 capab;
  852. __le16 timeout;
  853. __le16 start_seq_num;
  854. } __packed addba_req;
  855. struct{
  856. u8 action_code;
  857. u8 dialog_token;
  858. __le16 status;
  859. __le16 capab;
  860. __le16 timeout;
  861. } __packed addba_resp;
  862. struct{
  863. u8 action_code;
  864. __le16 params;
  865. __le16 reason_code;
  866. } __packed delba;
  867. struct {
  868. u8 action_code;
  869. u8 variable[0];
  870. } __packed self_prot;
  871. struct{
  872. u8 action_code;
  873. u8 variable[0];
  874. } __packed mesh_action;
  875. struct {
  876. u8 action;
  877. u8 trans_id[WLAN_SA_QUERY_TR_ID_LEN];
  878. } __packed sa_query;
  879. struct {
  880. u8 action;
  881. u8 smps_control;
  882. } __packed ht_smps;
  883. struct {
  884. u8 action_code;
  885. u8 chanwidth;
  886. } __packed ht_notify_cw;
  887. struct {
  888. u8 action_code;
  889. u8 dialog_token;
  890. __le16 capability;
  891. u8 variable[0];
  892. } __packed tdls_discover_resp;
  893. struct {
  894. u8 action_code;
  895. u8 operating_mode;
  896. } __packed vht_opmode_notif;
  897. struct {
  898. u8 action_code;
  899. u8 dialog_token;
  900. u8 tpc_elem_id;
  901. u8 tpc_elem_length;
  902. struct ieee80211_tpc_report_ie tpc;
  903. } __packed tpc_report;
  904. } u;
  905. } __packed action;
  906. } u;
  907. } __packed __aligned(2);
  908. /* Supported Rates value encodings in 802.11n-2009 7.3.2.2 */
  909. #define BSS_MEMBERSHIP_SELECTOR_HT_PHY 127
  910. /* mgmt header + 1 byte category code */
  911. #define IEEE80211_MIN_ACTION_SIZE offsetof(struct ieee80211_mgmt, u.action.u)
  912. /* Management MIC information element (IEEE 802.11w) */
  913. struct ieee80211_mmie {
  914. u8 element_id;
  915. u8 length;
  916. __le16 key_id;
  917. u8 sequence_number[6];
  918. u8 mic[8];
  919. } __packed;
  920. struct ieee80211_vendor_ie {
  921. u8 element_id;
  922. u8 len;
  923. u8 oui[3];
  924. u8 oui_type;
  925. } __packed;
  926. struct ieee80211_wmm_ac_param {
  927. u8 aci_aifsn; /* AIFSN, ACM, ACI */
  928. u8 cw; /* ECWmin, ECWmax (CW = 2^ECW - 1) */
  929. __le16 txop_limit;
  930. } __packed;
  931. struct ieee80211_wmm_param_ie {
  932. u8 element_id; /* Element ID: 221 (0xdd); */
  933. u8 len; /* Length: 24 */
  934. /* required fields for WMM version 1 */
  935. u8 oui[3]; /* 00:50:f2 */
  936. u8 oui_type; /* 2 */
  937. u8 oui_subtype; /* 1 */
  938. u8 version; /* 1 for WMM version 1.0 */
  939. u8 qos_info; /* AP/STA specific QoS info */
  940. u8 reserved; /* 0 */
  941. /* AC_BE, AC_BK, AC_VI, AC_VO */
  942. struct ieee80211_wmm_ac_param ac[4];
  943. } __packed;
  944. /* Control frames */
  945. struct ieee80211_rts {
  946. __le16 frame_control;
  947. __le16 duration;
  948. u8 ra[ETH_ALEN];
  949. u8 ta[ETH_ALEN];
  950. } __packed __aligned(2);
  951. struct ieee80211_cts {
  952. __le16 frame_control;
  953. __le16 duration;
  954. u8 ra[ETH_ALEN];
  955. } __packed __aligned(2);
  956. struct ieee80211_pspoll {
  957. __le16 frame_control;
  958. __le16 aid;
  959. u8 bssid[ETH_ALEN];
  960. u8 ta[ETH_ALEN];
  961. } __packed __aligned(2);
  962. /* TDLS */
  963. /* Link-id information element */
  964. struct ieee80211_tdls_lnkie {
  965. u8 ie_type; /* Link Identifier IE */
  966. u8 ie_len;
  967. u8 bssid[ETH_ALEN];
  968. u8 init_sta[ETH_ALEN];
  969. u8 resp_sta[ETH_ALEN];
  970. } __packed;
  971. struct ieee80211_tdls_data {
  972. u8 da[ETH_ALEN];
  973. u8 sa[ETH_ALEN];
  974. __be16 ether_type;
  975. u8 payload_type;
  976. u8 category;
  977. u8 action_code;
  978. union {
  979. struct {
  980. u8 dialog_token;
  981. __le16 capability;
  982. u8 variable[0];
  983. } __packed setup_req;
  984. struct {
  985. __le16 status_code;
  986. u8 dialog_token;
  987. __le16 capability;
  988. u8 variable[0];
  989. } __packed setup_resp;
  990. struct {
  991. __le16 status_code;
  992. u8 dialog_token;
  993. u8 variable[0];
  994. } __packed setup_cfm;
  995. struct {
  996. __le16 reason_code;
  997. u8 variable[0];
  998. } __packed teardown;
  999. struct {
  1000. u8 dialog_token;
  1001. u8 variable[0];
  1002. } __packed discover_req;
  1003. } u;
  1004. } __packed;
  1005. /*
  1006. * Peer-to-Peer IE attribute related definitions.
  1007. */
  1008. /**
  1009. * enum ieee80211_p2p_attr_id - identifies type of peer-to-peer attribute.
  1010. */
  1011. enum ieee80211_p2p_attr_id {
  1012. IEEE80211_P2P_ATTR_STATUS = 0,
  1013. IEEE80211_P2P_ATTR_MINOR_REASON,
  1014. IEEE80211_P2P_ATTR_CAPABILITY,
  1015. IEEE80211_P2P_ATTR_DEVICE_ID,
  1016. IEEE80211_P2P_ATTR_GO_INTENT,
  1017. IEEE80211_P2P_ATTR_GO_CONFIG_TIMEOUT,
  1018. IEEE80211_P2P_ATTR_LISTEN_CHANNEL,
  1019. IEEE80211_P2P_ATTR_GROUP_BSSID,
  1020. IEEE80211_P2P_ATTR_EXT_LISTEN_TIMING,
  1021. IEEE80211_P2P_ATTR_INTENDED_IFACE_ADDR,
  1022. IEEE80211_P2P_ATTR_MANAGABILITY,
  1023. IEEE80211_P2P_ATTR_CHANNEL_LIST,
  1024. IEEE80211_P2P_ATTR_ABSENCE_NOTICE,
  1025. IEEE80211_P2P_ATTR_DEVICE_INFO,
  1026. IEEE80211_P2P_ATTR_GROUP_INFO,
  1027. IEEE80211_P2P_ATTR_GROUP_ID,
  1028. IEEE80211_P2P_ATTR_INTERFACE,
  1029. IEEE80211_P2P_ATTR_OPER_CHANNEL,
  1030. IEEE80211_P2P_ATTR_INVITE_FLAGS,
  1031. /* 19 - 220: Reserved */
  1032. IEEE80211_P2P_ATTR_VENDOR_SPECIFIC = 221,
  1033. IEEE80211_P2P_ATTR_MAX
  1034. };
  1035. /* Notice of Absence attribute - described in P2P spec 4.1.14 */
  1036. /* Typical max value used here */
  1037. #define IEEE80211_P2P_NOA_DESC_MAX 4
  1038. struct ieee80211_p2p_noa_desc {
  1039. u8 count;
  1040. __le32 duration;
  1041. __le32 interval;
  1042. __le32 start_time;
  1043. } __packed;
  1044. struct ieee80211_p2p_noa_attr {
  1045. u8 index;
  1046. u8 oppps_ctwindow;
  1047. struct ieee80211_p2p_noa_desc desc[IEEE80211_P2P_NOA_DESC_MAX];
  1048. } __packed;
  1049. #define IEEE80211_P2P_OPPPS_ENABLE_BIT BIT(7)
  1050. #define IEEE80211_P2P_OPPPS_CTWINDOW_MASK 0x7F
  1051. /**
  1052. * struct ieee80211_bar - HT Block Ack Request
  1053. *
  1054. * This structure refers to "HT BlockAckReq" as
  1055. * described in 802.11n draft section 7.2.1.7.1
  1056. */
  1057. struct ieee80211_bar {
  1058. __le16 frame_control;
  1059. __le16 duration;
  1060. __u8 ra[ETH_ALEN];
  1061. __u8 ta[ETH_ALEN];
  1062. __le16 control;
  1063. __le16 start_seq_num;
  1064. } __packed;
  1065. /* 802.11 BAR control masks */
  1066. #define IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL 0x0000
  1067. #define IEEE80211_BAR_CTRL_MULTI_TID 0x0002
  1068. #define IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA 0x0004
  1069. #define IEEE80211_BAR_CTRL_TID_INFO_MASK 0xf000
  1070. #define IEEE80211_BAR_CTRL_TID_INFO_SHIFT 12
  1071. #define IEEE80211_HT_MCS_MASK_LEN 10
  1072. /**
  1073. * struct ieee80211_mcs_info - MCS information
  1074. * @rx_mask: RX mask
  1075. * @rx_highest: highest supported RX rate. If set represents
  1076. * the highest supported RX data rate in units of 1 Mbps.
  1077. * If this field is 0 this value should not be used to
  1078. * consider the highest RX data rate supported.
  1079. * @tx_params: TX parameters
  1080. */
  1081. struct ieee80211_mcs_info {
  1082. u8 rx_mask[IEEE80211_HT_MCS_MASK_LEN];
  1083. __le16 rx_highest;
  1084. u8 tx_params;
  1085. u8 reserved[3];
  1086. } __packed;
  1087. /* 802.11n HT capability MSC set */
  1088. #define IEEE80211_HT_MCS_RX_HIGHEST_MASK 0x3ff
  1089. #define IEEE80211_HT_MCS_TX_DEFINED 0x01
  1090. #define IEEE80211_HT_MCS_TX_RX_DIFF 0x02
  1091. /* value 0 == 1 stream etc */
  1092. #define IEEE80211_HT_MCS_TX_MAX_STREAMS_MASK 0x0C
  1093. #define IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT 2
  1094. #define IEEE80211_HT_MCS_TX_MAX_STREAMS 4
  1095. #define IEEE80211_HT_MCS_TX_UNEQUAL_MODULATION 0x10
  1096. /*
  1097. * 802.11n D5.0 20.3.5 / 20.6 says:
  1098. * - indices 0 to 7 and 32 are single spatial stream
  1099. * - 8 to 31 are multiple spatial streams using equal modulation
  1100. * [8..15 for two streams, 16..23 for three and 24..31 for four]
  1101. * - remainder are multiple spatial streams using unequal modulation
  1102. */
  1103. #define IEEE80211_HT_MCS_UNEQUAL_MODULATION_START 33
  1104. #define IEEE80211_HT_MCS_UNEQUAL_MODULATION_START_BYTE \
  1105. (IEEE80211_HT_MCS_UNEQUAL_MODULATION_START / 8)
  1106. /**
  1107. * struct ieee80211_ht_cap - HT capabilities
  1108. *
  1109. * This structure is the "HT capabilities element" as
  1110. * described in 802.11n D5.0 7.3.2.57
  1111. */
  1112. struct ieee80211_ht_cap {
  1113. __le16 cap_info;
  1114. u8 ampdu_params_info;
  1115. /* 16 bytes MCS information */
  1116. struct ieee80211_mcs_info mcs;
  1117. __le16 extended_ht_cap_info;
  1118. __le32 tx_BF_cap_info;
  1119. u8 antenna_selection_info;
  1120. } __packed;
  1121. /* 802.11n HT capabilities masks (for cap_info) */
  1122. #define IEEE80211_HT_CAP_LDPC_CODING 0x0001
  1123. #define IEEE80211_HT_CAP_SUP_WIDTH_20_40 0x0002
  1124. #define IEEE80211_HT_CAP_SM_PS 0x000C
  1125. #define IEEE80211_HT_CAP_SM_PS_SHIFT 2
  1126. #define IEEE80211_HT_CAP_GRN_FLD 0x0010
  1127. #define IEEE80211_HT_CAP_SGI_20 0x0020
  1128. #define IEEE80211_HT_CAP_SGI_40 0x0040
  1129. #define IEEE80211_HT_CAP_TX_STBC 0x0080
  1130. #define IEEE80211_HT_CAP_RX_STBC 0x0300
  1131. #define IEEE80211_HT_CAP_RX_STBC_SHIFT 8
  1132. #define IEEE80211_HT_CAP_DELAY_BA 0x0400
  1133. #define IEEE80211_HT_CAP_MAX_AMSDU 0x0800
  1134. #define IEEE80211_HT_CAP_DSSSCCK40 0x1000
  1135. #define IEEE80211_HT_CAP_RESERVED 0x2000
  1136. #define IEEE80211_HT_CAP_40MHZ_INTOLERANT 0x4000
  1137. #define IEEE80211_HT_CAP_LSIG_TXOP_PROT 0x8000
  1138. /* 802.11n HT extended capabilities masks (for extended_ht_cap_info) */
  1139. #define IEEE80211_HT_EXT_CAP_PCO 0x0001
  1140. #define IEEE80211_HT_EXT_CAP_PCO_TIME 0x0006
  1141. #define IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT 1
  1142. #define IEEE80211_HT_EXT_CAP_MCS_FB 0x0300
  1143. #define IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT 8
  1144. #define IEEE80211_HT_EXT_CAP_HTC_SUP 0x0400
  1145. #define IEEE80211_HT_EXT_CAP_RD_RESPONDER 0x0800
  1146. /* 802.11n HT capability AMPDU settings (for ampdu_params_info) */
  1147. #define IEEE80211_HT_AMPDU_PARM_FACTOR 0x03
  1148. #define IEEE80211_HT_AMPDU_PARM_DENSITY 0x1C
  1149. #define IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT 2
  1150. /*
  1151. * Maximum length of AMPDU that the STA can receive.
  1152. * Length = 2 ^ (13 + max_ampdu_length_exp) - 1 (octets)
  1153. */
  1154. enum ieee80211_max_ampdu_length_exp {
  1155. IEEE80211_HT_MAX_AMPDU_8K = 0,
  1156. IEEE80211_HT_MAX_AMPDU_16K = 1,
  1157. IEEE80211_HT_MAX_AMPDU_32K = 2,
  1158. IEEE80211_HT_MAX_AMPDU_64K = 3
  1159. };
  1160. #define IEEE80211_HT_MAX_AMPDU_FACTOR 13
  1161. /* Minimum MPDU start spacing */
  1162. enum ieee80211_min_mpdu_spacing {
  1163. IEEE80211_HT_MPDU_DENSITY_NONE = 0, /* No restriction */
  1164. IEEE80211_HT_MPDU_DENSITY_0_25 = 1, /* 1/4 usec */
  1165. IEEE80211_HT_MPDU_DENSITY_0_5 = 2, /* 1/2 usec */
  1166. IEEE80211_HT_MPDU_DENSITY_1 = 3, /* 1 usec */
  1167. IEEE80211_HT_MPDU_DENSITY_2 = 4, /* 2 usec */
  1168. IEEE80211_HT_MPDU_DENSITY_4 = 5, /* 4 usec */
  1169. IEEE80211_HT_MPDU_DENSITY_8 = 6, /* 8 usec */
  1170. IEEE80211_HT_MPDU_DENSITY_16 = 7 /* 16 usec */
  1171. };
  1172. /**
  1173. * struct ieee80211_ht_operation - HT operation IE
  1174. *
  1175. * This structure is the "HT operation element" as
  1176. * described in 802.11n-2009 7.3.2.57
  1177. */
  1178. struct ieee80211_ht_operation {
  1179. u8 primary_chan;
  1180. u8 ht_param;
  1181. __le16 operation_mode;
  1182. __le16 stbc_param;
  1183. u8 basic_set[16];
  1184. } __packed;
  1185. /* for ht_param */
  1186. #define IEEE80211_HT_PARAM_CHA_SEC_OFFSET 0x03
  1187. #define IEEE80211_HT_PARAM_CHA_SEC_NONE 0x00
  1188. #define IEEE80211_HT_PARAM_CHA_SEC_ABOVE 0x01
  1189. #define IEEE80211_HT_PARAM_CHA_SEC_BELOW 0x03
  1190. #define IEEE80211_HT_PARAM_CHAN_WIDTH_ANY 0x04
  1191. #define IEEE80211_HT_PARAM_RIFS_MODE 0x08
  1192. /* for operation_mode */
  1193. #define IEEE80211_HT_OP_MODE_PROTECTION 0x0003
  1194. #define IEEE80211_HT_OP_MODE_PROTECTION_NONE 0
  1195. #define IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER 1
  1196. #define IEEE80211_HT_OP_MODE_PROTECTION_20MHZ 2
  1197. #define IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED 3
  1198. #define IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT 0x0004
  1199. #define IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT 0x0010
  1200. /* for stbc_param */
  1201. #define IEEE80211_HT_STBC_PARAM_DUAL_BEACON 0x0040
  1202. #define IEEE80211_HT_STBC_PARAM_DUAL_CTS_PROT 0x0080
  1203. #define IEEE80211_HT_STBC_PARAM_STBC_BEACON 0x0100
  1204. #define IEEE80211_HT_STBC_PARAM_LSIG_TXOP_FULLPROT 0x0200
  1205. #define IEEE80211_HT_STBC_PARAM_PCO_ACTIVE 0x0400
  1206. #define IEEE80211_HT_STBC_PARAM_PCO_PHASE 0x0800
  1207. /* block-ack parameters */
  1208. #define IEEE80211_ADDBA_PARAM_POLICY_MASK 0x0002
  1209. #define IEEE80211_ADDBA_PARAM_TID_MASK 0x003C
  1210. #define IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK 0xFFC0
  1211. #define IEEE80211_DELBA_PARAM_TID_MASK 0xF000
  1212. #define IEEE80211_DELBA_PARAM_INITIATOR_MASK 0x0800
  1213. /*
  1214. * A-PMDU buffer sizes
  1215. * According to IEEE802.11n spec size varies from 8K to 64K (in powers of 2)
  1216. */
  1217. #define IEEE80211_MIN_AMPDU_BUF 0x8
  1218. #define IEEE80211_MAX_AMPDU_BUF 0x40
  1219. /* Spatial Multiplexing Power Save Modes (for capability) */
  1220. #define WLAN_HT_CAP_SM_PS_STATIC 0
  1221. #define WLAN_HT_CAP_SM_PS_DYNAMIC 1
  1222. #define WLAN_HT_CAP_SM_PS_INVALID 2
  1223. #define WLAN_HT_CAP_SM_PS_DISABLED 3
  1224. /* for SM power control field lower two bits */
  1225. #define WLAN_HT_SMPS_CONTROL_DISABLED 0
  1226. #define WLAN_HT_SMPS_CONTROL_STATIC 1
  1227. #define WLAN_HT_SMPS_CONTROL_DYNAMIC 3
  1228. /**
  1229. * struct ieee80211_vht_mcs_info - VHT MCS information
  1230. * @rx_mcs_map: RX MCS map 2 bits for each stream, total 8 streams
  1231. * @rx_highest: Indicates highest long GI VHT PPDU data rate
  1232. * STA can receive. Rate expressed in units of 1 Mbps.
  1233. * If this field is 0 this value should not be used to
  1234. * consider the highest RX data rate supported.
  1235. * The top 3 bits of this field are reserved.
  1236. * @tx_mcs_map: TX MCS map 2 bits for each stream, total 8 streams
  1237. * @tx_highest: Indicates highest long GI VHT PPDU data rate
  1238. * STA can transmit. Rate expressed in units of 1 Mbps.
  1239. * If this field is 0 this value should not be used to
  1240. * consider the highest TX data rate supported.
  1241. * The top 3 bits of this field are reserved.
  1242. */
  1243. struct ieee80211_vht_mcs_info {
  1244. __le16 rx_mcs_map;
  1245. __le16 rx_highest;
  1246. __le16 tx_mcs_map;
  1247. __le16 tx_highest;
  1248. } __packed;
  1249. /**
  1250. * enum ieee80211_vht_mcs_support - VHT MCS support definitions
  1251. * @IEEE80211_VHT_MCS_SUPPORT_0_7: MCSes 0-7 are supported for the
  1252. * number of streams
  1253. * @IEEE80211_VHT_MCS_SUPPORT_0_8: MCSes 0-8 are supported
  1254. * @IEEE80211_VHT_MCS_SUPPORT_0_9: MCSes 0-9 are supported
  1255. * @IEEE80211_VHT_MCS_NOT_SUPPORTED: This number of streams isn't supported
  1256. *
  1257. * These definitions are used in each 2-bit subfield of the @rx_mcs_map
  1258. * and @tx_mcs_map fields of &struct ieee80211_vht_mcs_info, which are
  1259. * both split into 8 subfields by number of streams. These values indicate
  1260. * which MCSes are supported for the number of streams the value appears
  1261. * for.
  1262. */
  1263. enum ieee80211_vht_mcs_support {
  1264. IEEE80211_VHT_MCS_SUPPORT_0_7 = 0,
  1265. IEEE80211_VHT_MCS_SUPPORT_0_8 = 1,
  1266. IEEE80211_VHT_MCS_SUPPORT_0_9 = 2,
  1267. IEEE80211_VHT_MCS_NOT_SUPPORTED = 3,
  1268. };
  1269. /**
  1270. * struct ieee80211_vht_cap - VHT capabilities
  1271. *
  1272. * This structure is the "VHT capabilities element" as
  1273. * described in 802.11ac D3.0 8.4.2.160
  1274. * @vht_cap_info: VHT capability info
  1275. * @supp_mcs: VHT MCS supported rates
  1276. */
  1277. struct ieee80211_vht_cap {
  1278. __le32 vht_cap_info;
  1279. struct ieee80211_vht_mcs_info supp_mcs;
  1280. } __packed;
  1281. /**
  1282. * enum ieee80211_vht_chanwidth - VHT channel width
  1283. * @IEEE80211_VHT_CHANWIDTH_USE_HT: use the HT operation IE to
  1284. * determine the channel width (20 or 40 MHz)
  1285. * @IEEE80211_VHT_CHANWIDTH_80MHZ: 80 MHz bandwidth
  1286. * @IEEE80211_VHT_CHANWIDTH_160MHZ: 160 MHz bandwidth
  1287. * @IEEE80211_VHT_CHANWIDTH_80P80MHZ: 80+80 MHz bandwidth
  1288. */
  1289. enum ieee80211_vht_chanwidth {
  1290. IEEE80211_VHT_CHANWIDTH_USE_HT = 0,
  1291. IEEE80211_VHT_CHANWIDTH_80MHZ = 1,
  1292. IEEE80211_VHT_CHANWIDTH_160MHZ = 2,
  1293. IEEE80211_VHT_CHANWIDTH_80P80MHZ = 3,
  1294. };
  1295. /**
  1296. * struct ieee80211_vht_operation - VHT operation IE
  1297. *
  1298. * This structure is the "VHT operation element" as
  1299. * described in 802.11ac D3.0 8.4.2.161
  1300. * @chan_width: Operating channel width
  1301. * @center_freq_seg1_idx: center freq segment 1 index
  1302. * @center_freq_seg2_idx: center freq segment 2 index
  1303. * @basic_mcs_set: VHT Basic MCS rate set
  1304. */
  1305. struct ieee80211_vht_operation {
  1306. u8 chan_width;
  1307. u8 center_freq_seg1_idx;
  1308. u8 center_freq_seg2_idx;
  1309. __le16 basic_mcs_set;
  1310. } __packed;
  1311. /* 802.11ac VHT Capabilities */
  1312. #define IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895 0x00000000
  1313. #define IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991 0x00000001
  1314. #define IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454 0x00000002
  1315. #define IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ 0x00000004
  1316. #define IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ 0x00000008
  1317. #define IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK 0x0000000C
  1318. #define IEEE80211_VHT_CAP_RXLDPC 0x00000010
  1319. #define IEEE80211_VHT_CAP_SHORT_GI_80 0x00000020
  1320. #define IEEE80211_VHT_CAP_SHORT_GI_160 0x00000040
  1321. #define IEEE80211_VHT_CAP_TXSTBC 0x00000080
  1322. #define IEEE80211_VHT_CAP_RXSTBC_1 0x00000100
  1323. #define IEEE80211_VHT_CAP_RXSTBC_2 0x00000200
  1324. #define IEEE80211_VHT_CAP_RXSTBC_3 0x00000300
  1325. #define IEEE80211_VHT_CAP_RXSTBC_4 0x00000400
  1326. #define IEEE80211_VHT_CAP_RXSTBC_MASK 0x00000700
  1327. #define IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE 0x00000800
  1328. #define IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE 0x00001000
  1329. #define IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT 13
  1330. #define IEEE80211_VHT_CAP_BEAMFORMEE_STS_MASK \
  1331. (7 << IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT)
  1332. #define IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT 16
  1333. #define IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_MASK \
  1334. (7 << IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT)
  1335. #define IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE 0x00080000
  1336. #define IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE 0x00100000
  1337. #define IEEE80211_VHT_CAP_VHT_TXOP_PS 0x00200000
  1338. #define IEEE80211_VHT_CAP_HTC_VHT 0x00400000
  1339. #define IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT 23
  1340. #define IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK \
  1341. (7 << IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT)
  1342. #define IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_UNSOL_MFB 0x08000000
  1343. #define IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB 0x0c000000
  1344. #define IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN 0x10000000
  1345. #define IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN 0x20000000
  1346. /* Authentication algorithms */
  1347. #define WLAN_AUTH_OPEN 0
  1348. #define WLAN_AUTH_SHARED_KEY 1
  1349. #define WLAN_AUTH_FT 2
  1350. #define WLAN_AUTH_SAE 3
  1351. #define WLAN_AUTH_LEAP 128
  1352. #define WLAN_AUTH_CHALLENGE_LEN 128
  1353. #define WLAN_CAPABILITY_ESS (1<<0)
  1354. #define WLAN_CAPABILITY_IBSS (1<<1)
  1355. /*
  1356. * A mesh STA sets the ESS and IBSS capability bits to zero.
  1357. * however, this holds true for p2p probe responses (in the p2p_find
  1358. * phase) as well.
  1359. */
  1360. #define WLAN_CAPABILITY_IS_STA_BSS(cap) \
  1361. (!((cap) & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS)))
  1362. #define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
  1363. #define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
  1364. #define WLAN_CAPABILITY_PRIVACY (1<<4)
  1365. #define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
  1366. #define WLAN_CAPABILITY_PBCC (1<<6)
  1367. #define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
  1368. /* 802.11h */
  1369. #define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8)
  1370. #define WLAN_CAPABILITY_QOS (1<<9)
  1371. #define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10)
  1372. #define WLAN_CAPABILITY_APSD (1<<11)
  1373. #define WLAN_CAPABILITY_RADIO_MEASURE (1<<12)
  1374. #define WLAN_CAPABILITY_DSSS_OFDM (1<<13)
  1375. #define WLAN_CAPABILITY_DEL_BACK (1<<14)
  1376. #define WLAN_CAPABILITY_IMM_BACK (1<<15)
  1377. /* DMG (60gHz) 802.11ad */
  1378. /* type - bits 0..1 */
  1379. #define WLAN_CAPABILITY_DMG_TYPE_MASK (3<<0)
  1380. #define WLAN_CAPABILITY_DMG_TYPE_IBSS (1<<0) /* Tx by: STA */
  1381. #define WLAN_CAPABILITY_DMG_TYPE_PBSS (2<<0) /* Tx by: PCP */
  1382. #define WLAN_CAPABILITY_DMG_TYPE_AP (3<<0) /* Tx by: AP */
  1383. #define WLAN_CAPABILITY_DMG_CBAP_ONLY (1<<2)
  1384. #define WLAN_CAPABILITY_DMG_CBAP_SOURCE (1<<3)
  1385. #define WLAN_CAPABILITY_DMG_PRIVACY (1<<4)
  1386. #define WLAN_CAPABILITY_DMG_ECPAC (1<<5)
  1387. #define WLAN_CAPABILITY_DMG_SPECTRUM_MGMT (1<<8)
  1388. #define WLAN_CAPABILITY_DMG_RADIO_MEASURE (1<<12)
  1389. /* measurement */
  1390. #define IEEE80211_SPCT_MSR_RPRT_MODE_LATE (1<<0)
  1391. #define IEEE80211_SPCT_MSR_RPRT_MODE_INCAPABLE (1<<1)
  1392. #define IEEE80211_SPCT_MSR_RPRT_MODE_REFUSED (1<<2)
  1393. #define IEEE80211_SPCT_MSR_RPRT_TYPE_BASIC 0
  1394. #define IEEE80211_SPCT_MSR_RPRT_TYPE_CCA 1
  1395. #define IEEE80211_SPCT_MSR_RPRT_TYPE_RPI 2
  1396. /* 802.11g ERP information element */
  1397. #define WLAN_ERP_NON_ERP_PRESENT (1<<0)
  1398. #define WLAN_ERP_USE_PROTECTION (1<<1)
  1399. #define WLAN_ERP_BARKER_PREAMBLE (1<<2)
  1400. /* WLAN_ERP_BARKER_PREAMBLE values */
  1401. enum {
  1402. WLAN_ERP_PREAMBLE_SHORT = 0,
  1403. WLAN_ERP_PREAMBLE_LONG = 1,
  1404. };
  1405. /* Band ID, 802.11ad #8.4.1.45 */
  1406. enum {
  1407. IEEE80211_BANDID_TV_WS = 0, /* TV white spaces */
  1408. IEEE80211_BANDID_SUB1 = 1, /* Sub-1 GHz (excluding TV white spaces) */
  1409. IEEE80211_BANDID_2G = 2, /* 2.4 GHz */
  1410. IEEE80211_BANDID_3G = 3, /* 3.6 GHz */
  1411. IEEE80211_BANDID_5G = 4, /* 4.9 and 5 GHz */
  1412. IEEE80211_BANDID_60G = 5, /* 60 GHz */
  1413. };
  1414. /* Status codes */
  1415. enum ieee80211_statuscode {
  1416. WLAN_STATUS_SUCCESS = 0,
  1417. WLAN_STATUS_UNSPECIFIED_FAILURE = 1,
  1418. WLAN_STATUS_CAPS_UNSUPPORTED = 10,
  1419. WLAN_STATUS_REASSOC_NO_ASSOC = 11,
  1420. WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12,
  1421. WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13,
  1422. WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14,
  1423. WLAN_STATUS_CHALLENGE_FAIL = 15,
  1424. WLAN_STATUS_AUTH_TIMEOUT = 16,
  1425. WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17,
  1426. WLAN_STATUS_ASSOC_DENIED_RATES = 18,
  1427. /* 802.11b */
  1428. WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19,
  1429. WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20,
  1430. WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21,
  1431. /* 802.11h */
  1432. WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22,
  1433. WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23,
  1434. WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24,
  1435. /* 802.11g */
  1436. WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25,
  1437. WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26,
  1438. /* 802.11w */
  1439. WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY = 30,
  1440. WLAN_STATUS_ROBUST_MGMT_FRAME_POLICY_VIOLATION = 31,
  1441. /* 802.11i */
  1442. WLAN_STATUS_INVALID_IE = 40,
  1443. WLAN_STATUS_INVALID_GROUP_CIPHER = 41,
  1444. WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42,
  1445. WLAN_STATUS_INVALID_AKMP = 43,
  1446. WLAN_STATUS_UNSUPP_RSN_VERSION = 44,
  1447. WLAN_STATUS_INVALID_RSN_IE_CAP = 45,
  1448. WLAN_STATUS_CIPHER_SUITE_REJECTED = 46,
  1449. /* 802.11e */
  1450. WLAN_STATUS_UNSPECIFIED_QOS = 32,
  1451. WLAN_STATUS_ASSOC_DENIED_NOBANDWIDTH = 33,
  1452. WLAN_STATUS_ASSOC_DENIED_LOWACK = 34,
  1453. WLAN_STATUS_ASSOC_DENIED_UNSUPP_QOS = 35,
  1454. WLAN_STATUS_REQUEST_DECLINED = 37,
  1455. WLAN_STATUS_INVALID_QOS_PARAM = 38,
  1456. WLAN_STATUS_CHANGE_TSPEC = 39,
  1457. WLAN_STATUS_WAIT_TS_DELAY = 47,
  1458. WLAN_STATUS_NO_DIRECT_LINK = 48,
  1459. WLAN_STATUS_STA_NOT_PRESENT = 49,
  1460. WLAN_STATUS_STA_NOT_QSTA = 50,
  1461. /* 802.11s */
  1462. WLAN_STATUS_ANTI_CLOG_REQUIRED = 76,
  1463. WLAN_STATUS_FCG_NOT_SUPP = 78,
  1464. WLAN_STATUS_STA_NO_TBTT = 78,
  1465. /* 802.11ad */
  1466. WLAN_STATUS_REJECTED_WITH_SUGGESTED_CHANGES = 39,
  1467. WLAN_STATUS_REJECTED_FOR_DELAY_PERIOD = 47,
  1468. WLAN_STATUS_REJECT_WITH_SCHEDULE = 83,
  1469. WLAN_STATUS_PENDING_ADMITTING_FST_SESSION = 86,
  1470. WLAN_STATUS_PERFORMING_FST_NOW = 87,
  1471. WLAN_STATUS_PENDING_GAP_IN_BA_WINDOW = 88,
  1472. WLAN_STATUS_REJECT_U_PID_SETTING = 89,
  1473. WLAN_STATUS_REJECT_DSE_BAND = 96,
  1474. WLAN_STATUS_DENIED_WITH_SUGGESTED_BAND_AND_CHANNEL = 99,
  1475. WLAN_STATUS_DENIED_DUE_TO_SPECTRUM_MANAGEMENT = 103,
  1476. };
  1477. /* Reason codes */
  1478. enum ieee80211_reasoncode {
  1479. WLAN_REASON_UNSPECIFIED = 1,
  1480. WLAN_REASON_PREV_AUTH_NOT_VALID = 2,
  1481. WLAN_REASON_DEAUTH_LEAVING = 3,
  1482. WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4,
  1483. WLAN_REASON_DISASSOC_AP_BUSY = 5,
  1484. WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6,
  1485. WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7,
  1486. WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8,
  1487. WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9,
  1488. /* 802.11h */
  1489. WLAN_REASON_DISASSOC_BAD_POWER = 10,
  1490. WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11,
  1491. /* 802.11i */
  1492. WLAN_REASON_INVALID_IE = 13,
  1493. WLAN_REASON_MIC_FAILURE = 14,
  1494. WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15,
  1495. WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16,
  1496. WLAN_REASON_IE_DIFFERENT = 17,
  1497. WLAN_REASON_INVALID_GROUP_CIPHER = 18,
  1498. WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19,
  1499. WLAN_REASON_INVALID_AKMP = 20,
  1500. WLAN_REASON_UNSUPP_RSN_VERSION = 21,
  1501. WLAN_REASON_INVALID_RSN_IE_CAP = 22,
  1502. WLAN_REASON_IEEE8021X_FAILED = 23,
  1503. WLAN_REASON_CIPHER_SUITE_REJECTED = 24,
  1504. /* TDLS (802.11z) */
  1505. WLAN_REASON_TDLS_TEARDOWN_UNREACHABLE = 25,
  1506. WLAN_REASON_TDLS_TEARDOWN_UNSPECIFIED = 26,
  1507. /* 802.11e */
  1508. WLAN_REASON_DISASSOC_UNSPECIFIED_QOS = 32,
  1509. WLAN_REASON_DISASSOC_QAP_NO_BANDWIDTH = 33,
  1510. WLAN_REASON_DISASSOC_LOW_ACK = 34,
  1511. WLAN_REASON_DISASSOC_QAP_EXCEED_TXOP = 35,
  1512. WLAN_REASON_QSTA_LEAVE_QBSS = 36,
  1513. WLAN_REASON_QSTA_NOT_USE = 37,
  1514. WLAN_REASON_QSTA_REQUIRE_SETUP = 38,
  1515. WLAN_REASON_QSTA_TIMEOUT = 39,
  1516. WLAN_REASON_QSTA_CIPHER_NOT_SUPP = 45,
  1517. /* 802.11s */
  1518. WLAN_REASON_MESH_PEER_CANCELED = 52,
  1519. WLAN_REASON_MESH_MAX_PEERS = 53,
  1520. WLAN_REASON_MESH_CONFIG = 54,
  1521. WLAN_REASON_MESH_CLOSE = 55,
  1522. WLAN_REASON_MESH_MAX_RETRIES = 56,
  1523. WLAN_REASON_MESH_CONFIRM_TIMEOUT = 57,
  1524. WLAN_REASON_MESH_INVALID_GTK = 58,
  1525. WLAN_REASON_MESH_INCONSISTENT_PARAM = 59,
  1526. WLAN_REASON_MESH_INVALID_SECURITY = 60,
  1527. WLAN_REASON_MESH_PATH_ERROR = 61,
  1528. WLAN_REASON_MESH_PATH_NOFORWARD = 62,
  1529. WLAN_REASON_MESH_PATH_DEST_UNREACHABLE = 63,
  1530. WLAN_REASON_MAC_EXISTS_IN_MBSS = 64,
  1531. WLAN_REASON_MESH_CHAN_REGULATORY = 65,
  1532. WLAN_REASON_MESH_CHAN = 66,
  1533. };
  1534. /* Information Element IDs */
  1535. enum ieee80211_eid {
  1536. WLAN_EID_SSID = 0,
  1537. WLAN_EID_SUPP_RATES = 1,
  1538. WLAN_EID_FH_PARAMS = 2, /* reserved now */
  1539. WLAN_EID_DS_PARAMS = 3,
  1540. WLAN_EID_CF_PARAMS = 4,
  1541. WLAN_EID_TIM = 5,
  1542. WLAN_EID_IBSS_PARAMS = 6,
  1543. WLAN_EID_COUNTRY = 7,
  1544. WLAN_EID_HP_PARAMS = 8,
  1545. WLAN_EID_HP_TABLE = 9,
  1546. WLAN_EID_REQUEST = 10,
  1547. WLAN_EID_QBSS_LOAD = 11,
  1548. WLAN_EID_EDCA_PARAM_SET = 12,
  1549. WLAN_EID_TSPEC = 13,
  1550. WLAN_EID_TCLAS = 14,
  1551. WLAN_EID_SCHEDULE = 15,
  1552. WLAN_EID_CHALLENGE = 16,
  1553. /* 17-31 reserved for challenge text extension */
  1554. WLAN_EID_PWR_CONSTRAINT = 32,
  1555. WLAN_EID_PWR_CAPABILITY = 33,
  1556. WLAN_EID_TPC_REQUEST = 34,
  1557. WLAN_EID_TPC_REPORT = 35,
  1558. WLAN_EID_SUPPORTED_CHANNELS = 36,
  1559. WLAN_EID_CHANNEL_SWITCH = 37,
  1560. WLAN_EID_MEASURE_REQUEST = 38,
  1561. WLAN_EID_MEASURE_REPORT = 39,
  1562. WLAN_EID_QUIET = 40,
  1563. WLAN_EID_IBSS_DFS = 41,
  1564. WLAN_EID_ERP_INFO = 42,
  1565. WLAN_EID_TS_DELAY = 43,
  1566. WLAN_EID_TCLAS_PROCESSING = 44,
  1567. WLAN_EID_HT_CAPABILITY = 45,
  1568. WLAN_EID_QOS_CAPA = 46,
  1569. /* 47 reserved for Broadcom */
  1570. WLAN_EID_RSN = 48,
  1571. WLAN_EID_802_15_COEX = 49,
  1572. WLAN_EID_EXT_SUPP_RATES = 50,
  1573. WLAN_EID_AP_CHAN_REPORT = 51,
  1574. WLAN_EID_NEIGHBOR_REPORT = 52,
  1575. WLAN_EID_RCPI = 53,
  1576. WLAN_EID_MOBILITY_DOMAIN = 54,
  1577. WLAN_EID_FAST_BSS_TRANSITION = 55,
  1578. WLAN_EID_TIMEOUT_INTERVAL = 56,
  1579. WLAN_EID_RIC_DATA = 57,
  1580. WLAN_EID_DSE_REGISTERED_LOCATION = 58,
  1581. WLAN_EID_SUPPORTED_REGULATORY_CLASSES = 59,
  1582. WLAN_EID_EXT_CHANSWITCH_ANN = 60,
  1583. WLAN_EID_HT_OPERATION = 61,
  1584. WLAN_EID_SECONDARY_CHANNEL_OFFSET = 62,
  1585. WLAN_EID_BSS_AVG_ACCESS_DELAY = 63,
  1586. WLAN_EID_ANTENNA_INFO = 64,
  1587. WLAN_EID_RSNI = 65,
  1588. WLAN_EID_MEASUREMENT_PILOT_TX_INFO = 66,
  1589. WLAN_EID_BSS_AVAILABLE_CAPACITY = 67,
  1590. WLAN_EID_BSS_AC_ACCESS_DELAY = 68,
  1591. WLAN_EID_TIME_ADVERTISEMENT = 69,
  1592. WLAN_EID_RRM_ENABLED_CAPABILITIES = 70,
  1593. WLAN_EID_MULTIPLE_BSSID = 71,
  1594. WLAN_EID_BSS_COEX_2040 = 72,
  1595. WLAN_EID_BSS_INTOLERANT_CHL_REPORT = 73,
  1596. WLAN_EID_OVERLAP_BSS_SCAN_PARAM = 74,
  1597. WLAN_EID_RIC_DESCRIPTOR = 75,
  1598. WLAN_EID_MMIE = 76,
  1599. WLAN_EID_ASSOC_COMEBACK_TIME = 77,
  1600. WLAN_EID_EVENT_REQUEST = 78,
  1601. WLAN_EID_EVENT_REPORT = 79,
  1602. WLAN_EID_DIAGNOSTIC_REQUEST = 80,
  1603. WLAN_EID_DIAGNOSTIC_REPORT = 81,
  1604. WLAN_EID_LOCATION_PARAMS = 82,
  1605. WLAN_EID_NON_TX_BSSID_CAP = 83,
  1606. WLAN_EID_SSID_LIST = 84,
  1607. WLAN_EID_MULTI_BSSID_IDX = 85,
  1608. WLAN_EID_FMS_DESCRIPTOR = 86,
  1609. WLAN_EID_FMS_REQUEST = 87,
  1610. WLAN_EID_FMS_RESPONSE = 88,
  1611. WLAN_EID_QOS_TRAFFIC_CAPA = 89,
  1612. WLAN_EID_BSS_MAX_IDLE_PERIOD = 90,
  1613. WLAN_EID_TSF_REQUEST = 91,
  1614. WLAN_EID_TSF_RESPOSNE = 92,
  1615. WLAN_EID_WNM_SLEEP_MODE = 93,
  1616. WLAN_EID_TIM_BCAST_REQ = 94,
  1617. WLAN_EID_TIM_BCAST_RESP = 95,
  1618. WLAN_EID_COLL_IF_REPORT = 96,
  1619. WLAN_EID_CHANNEL_USAGE = 97,
  1620. WLAN_EID_TIME_ZONE = 98,
  1621. WLAN_EID_DMS_REQUEST = 99,
  1622. WLAN_EID_DMS_RESPONSE = 100,
  1623. WLAN_EID_LINK_ID = 101,
  1624. WLAN_EID_WAKEUP_SCHEDUL = 102,
  1625. /* 103 reserved */
  1626. WLAN_EID_CHAN_SWITCH_TIMING = 104,
  1627. WLAN_EID_PTI_CONTROL = 105,
  1628. WLAN_EID_PU_BUFFER_STATUS = 106,
  1629. WLAN_EID_INTERWORKING = 107,
  1630. WLAN_EID_ADVERTISEMENT_PROTOCOL = 108,
  1631. WLAN_EID_EXPEDITED_BW_REQ = 109,
  1632. WLAN_EID_QOS_MAP_SET = 110,
  1633. WLAN_EID_ROAMING_CONSORTIUM = 111,
  1634. WLAN_EID_EMERGENCY_ALERT = 112,
  1635. WLAN_EID_MESH_CONFIG = 113,
  1636. WLAN_EID_MESH_ID = 114,
  1637. WLAN_EID_LINK_METRIC_REPORT = 115,
  1638. WLAN_EID_CONGESTION_NOTIFICATION = 116,
  1639. WLAN_EID_PEER_MGMT = 117,
  1640. WLAN_EID_CHAN_SWITCH_PARAM = 118,
  1641. WLAN_EID_MESH_AWAKE_WINDOW = 119,
  1642. WLAN_EID_BEACON_TIMING = 120,
  1643. WLAN_EID_MCCAOP_SETUP_REQ = 121,
  1644. WLAN_EID_MCCAOP_SETUP_RESP = 122,
  1645. WLAN_EID_MCCAOP_ADVERT = 123,
  1646. WLAN_EID_MCCAOP_TEARDOWN = 124,
  1647. WLAN_EID_GANN = 125,
  1648. WLAN_EID_RANN = 126,
  1649. WLAN_EID_EXT_CAPABILITY = 127,
  1650. /* 128, 129 reserved for Agere */
  1651. WLAN_EID_PREQ = 130,
  1652. WLAN_EID_PREP = 131,
  1653. WLAN_EID_PERR = 132,
  1654. /* 133-136 reserved for Cisco */
  1655. WLAN_EID_PXU = 137,
  1656. WLAN_EID_PXUC = 138,
  1657. WLAN_EID_AUTH_MESH_PEER_EXCH = 139,
  1658. WLAN_EID_MIC = 140,
  1659. WLAN_EID_DESTINATION_URI = 141,
  1660. WLAN_EID_UAPSD_COEX = 142,
  1661. WLAN_EID_WAKEUP_SCHEDULE = 143,
  1662. WLAN_EID_EXT_SCHEDULE = 144,
  1663. WLAN_EID_STA_AVAILABILITY = 145,
  1664. WLAN_EID_DMG_TSPEC = 146,
  1665. WLAN_EID_DMG_AT = 147,
  1666. WLAN_EID_DMG_CAP = 148,
  1667. /* 149 reserved for Cisco */
  1668. WLAN_EID_CISCO_VENDOR_SPECIFIC = 150,
  1669. WLAN_EID_DMG_OPERATION = 151,
  1670. WLAN_EID_DMG_BSS_PARAM_CHANGE = 152,
  1671. WLAN_EID_DMG_BEAM_REFINEMENT = 153,
  1672. WLAN_EID_CHANNEL_MEASURE_FEEDBACK = 154,
  1673. /* 155-156 reserved for Cisco */
  1674. WLAN_EID_AWAKE_WINDOW = 157,
  1675. WLAN_EID_MULTI_BAND = 158,
  1676. WLAN_EID_ADDBA_EXT = 159,
  1677. WLAN_EID_NEXT_PCP_LIST = 160,
  1678. WLAN_EID_PCP_HANDOVER = 161,
  1679. WLAN_EID_DMG_LINK_MARGIN = 162,
  1680. WLAN_EID_SWITCHING_STREAM = 163,
  1681. WLAN_EID_SESSION_TRANSITION = 164,
  1682. WLAN_EID_DYN_TONE_PAIRING_REPORT = 165,
  1683. WLAN_EID_CLUSTER_REPORT = 166,
  1684. WLAN_EID_RELAY_CAP = 167,
  1685. WLAN_EID_RELAY_XFER_PARAM_SET = 168,
  1686. WLAN_EID_BEAM_LINK_MAINT = 169,
  1687. WLAN_EID_MULTIPLE_MAC_ADDR = 170,
  1688. WLAN_EID_U_PID = 171,
  1689. WLAN_EID_DMG_LINK_ADAPT_ACK = 172,
  1690. /* 173 reserved for Symbol */
  1691. WLAN_EID_MCCAOP_ADV_OVERVIEW = 174,
  1692. WLAN_EID_QUIET_PERIOD_REQ = 175,
  1693. /* 176 reserved for Symbol */
  1694. WLAN_EID_QUIET_PERIOD_RESP = 177,
  1695. /* 178-179 reserved for Symbol */
  1696. /* 180 reserved for ISO/IEC 20011 */
  1697. WLAN_EID_EPAC_POLICY = 182,
  1698. WLAN_EID_CLISTER_TIME_OFF = 183,
  1699. WLAN_EID_INTER_AC_PRIO = 184,
  1700. WLAN_EID_SCS_DESCRIPTOR = 185,
  1701. WLAN_EID_QLOAD_REPORT = 186,
  1702. WLAN_EID_HCCA_TXOP_UPDATE_COUNT = 187,
  1703. WLAN_EID_HL_STREAM_ID = 188,
  1704. WLAN_EID_GCR_GROUP_ADDR = 189,
  1705. WLAN_EID_ANTENNA_SECTOR_ID_PATTERN = 190,
  1706. WLAN_EID_VHT_CAPABILITY = 191,
  1707. WLAN_EID_VHT_OPERATION = 192,
  1708. WLAN_EID_EXTENDED_BSS_LOAD = 193,
  1709. WLAN_EID_WIDE_BW_CHANNEL_SWITCH = 194,
  1710. WLAN_EID_VHT_TX_POWER_ENVELOPE = 195,
  1711. WLAN_EID_CHANNEL_SWITCH_WRAPPER = 196,
  1712. WLAN_EID_AID = 197,
  1713. WLAN_EID_QUIET_CHANNEL = 198,
  1714. WLAN_EID_OPMODE_NOTIF = 199,
  1715. WLAN_EID_VENDOR_SPECIFIC = 221,
  1716. WLAN_EID_QOS_PARAMETER = 222,
  1717. };
  1718. /* Action category code */
  1719. enum ieee80211_category {
  1720. WLAN_CATEGORY_SPECTRUM_MGMT = 0,
  1721. WLAN_CATEGORY_QOS = 1,
  1722. WLAN_CATEGORY_DLS = 2,
  1723. WLAN_CATEGORY_BACK = 3,
  1724. WLAN_CATEGORY_PUBLIC = 4,
  1725. WLAN_CATEGORY_RADIO_MEASUREMENT = 5,
  1726. WLAN_CATEGORY_HT = 7,
  1727. WLAN_CATEGORY_SA_QUERY = 8,
  1728. WLAN_CATEGORY_PROTECTED_DUAL_OF_ACTION = 9,
  1729. WLAN_CATEGORY_TDLS = 12,
  1730. WLAN_CATEGORY_MESH_ACTION = 13,
  1731. WLAN_CATEGORY_MULTIHOP_ACTION = 14,
  1732. WLAN_CATEGORY_SELF_PROTECTED = 15,
  1733. WLAN_CATEGORY_DMG = 16,
  1734. WLAN_CATEGORY_WMM = 17,
  1735. WLAN_CATEGORY_FST = 18,
  1736. WLAN_CATEGORY_UNPROT_DMG = 20,
  1737. WLAN_CATEGORY_VHT = 21,
  1738. WLAN_CATEGORY_VENDOR_SPECIFIC_PROTECTED = 126,
  1739. WLAN_CATEGORY_VENDOR_SPECIFIC = 127,
  1740. };
  1741. /* SPECTRUM_MGMT action code */
  1742. enum ieee80211_spectrum_mgmt_actioncode {
  1743. WLAN_ACTION_SPCT_MSR_REQ = 0,
  1744. WLAN_ACTION_SPCT_MSR_RPRT = 1,
  1745. WLAN_ACTION_SPCT_TPC_REQ = 2,
  1746. WLAN_ACTION_SPCT_TPC_RPRT = 3,
  1747. WLAN_ACTION_SPCT_CHL_SWITCH = 4,
  1748. };
  1749. /* HT action codes */
  1750. enum ieee80211_ht_actioncode {
  1751. WLAN_HT_ACTION_NOTIFY_CHANWIDTH = 0,
  1752. WLAN_HT_ACTION_SMPS = 1,
  1753. WLAN_HT_ACTION_PSMP = 2,
  1754. WLAN_HT_ACTION_PCO_PHASE = 3,
  1755. WLAN_HT_ACTION_CSI = 4,
  1756. WLAN_HT_ACTION_NONCOMPRESSED_BF = 5,
  1757. WLAN_HT_ACTION_COMPRESSED_BF = 6,
  1758. WLAN_HT_ACTION_ASEL_IDX_FEEDBACK = 7,
  1759. };
  1760. /* VHT action codes */
  1761. enum ieee80211_vht_actioncode {
  1762. WLAN_VHT_ACTION_COMPRESSED_BF = 0,
  1763. WLAN_VHT_ACTION_GROUPID_MGMT = 1,
  1764. WLAN_VHT_ACTION_OPMODE_NOTIF = 2,
  1765. };
  1766. /* Self Protected Action codes */
  1767. enum ieee80211_self_protected_actioncode {
  1768. WLAN_SP_RESERVED = 0,
  1769. WLAN_SP_MESH_PEERING_OPEN = 1,
  1770. WLAN_SP_MESH_PEERING_CONFIRM = 2,
  1771. WLAN_SP_MESH_PEERING_CLOSE = 3,
  1772. WLAN_SP_MGK_INFORM = 4,
  1773. WLAN_SP_MGK_ACK = 5,
  1774. };
  1775. /* Mesh action codes */
  1776. enum ieee80211_mesh_actioncode {
  1777. WLAN_MESH_ACTION_LINK_METRIC_REPORT,
  1778. WLAN_MESH_ACTION_HWMP_PATH_SELECTION,
  1779. WLAN_MESH_ACTION_GATE_ANNOUNCEMENT,
  1780. WLAN_MESH_ACTION_CONGESTION_CONTROL_NOTIFICATION,
  1781. WLAN_MESH_ACTION_MCCA_SETUP_REQUEST,
  1782. WLAN_MESH_ACTION_MCCA_SETUP_REPLY,
  1783. WLAN_MESH_ACTION_MCCA_ADVERTISEMENT_REQUEST,
  1784. WLAN_MESH_ACTION_MCCA_ADVERTISEMENT,
  1785. WLAN_MESH_ACTION_MCCA_TEARDOWN,
  1786. WLAN_MESH_ACTION_TBTT_ADJUSTMENT_REQUEST,
  1787. WLAN_MESH_ACTION_TBTT_ADJUSTMENT_RESPONSE,
  1788. };
  1789. /* Security key length */
  1790. enum ieee80211_key_len {
  1791. WLAN_KEY_LEN_WEP40 = 5,
  1792. WLAN_KEY_LEN_WEP104 = 13,
  1793. WLAN_KEY_LEN_CCMP = 16,
  1794. WLAN_KEY_LEN_TKIP = 32,
  1795. WLAN_KEY_LEN_AES_CMAC = 16,
  1796. WLAN_KEY_LEN_SMS4 = 32,
  1797. };
  1798. #define IEEE80211_WEP_IV_LEN 4
  1799. #define IEEE80211_WEP_ICV_LEN 4
  1800. #define IEEE80211_CCMP_HDR_LEN 8
  1801. #define IEEE80211_CCMP_MIC_LEN 8
  1802. #define IEEE80211_CCMP_PN_LEN 6
  1803. #define IEEE80211_TKIP_IV_LEN 8
  1804. #define IEEE80211_TKIP_ICV_LEN 4
  1805. #define IEEE80211_CMAC_PN_LEN 6
  1806. /* Public action codes */
  1807. enum ieee80211_pub_actioncode {
  1808. WLAN_PUB_ACTION_EXT_CHANSW_ANN = 4,
  1809. WLAN_PUB_ACTION_TDLS_DISCOVER_RES = 14,
  1810. };
  1811. /* TDLS action codes */
  1812. enum ieee80211_tdls_actioncode {
  1813. WLAN_TDLS_SETUP_REQUEST = 0,
  1814. WLAN_TDLS_SETUP_RESPONSE = 1,
  1815. WLAN_TDLS_SETUP_CONFIRM = 2,
  1816. WLAN_TDLS_TEARDOWN = 3,
  1817. WLAN_TDLS_PEER_TRAFFIC_INDICATION = 4,
  1818. WLAN_TDLS_CHANNEL_SWITCH_REQUEST = 5,
  1819. WLAN_TDLS_CHANNEL_SWITCH_RESPONSE = 6,
  1820. WLAN_TDLS_PEER_PSM_REQUEST = 7,
  1821. WLAN_TDLS_PEER_PSM_RESPONSE = 8,
  1822. WLAN_TDLS_PEER_TRAFFIC_RESPONSE = 9,
  1823. WLAN_TDLS_DISCOVERY_REQUEST = 10,
  1824. };
  1825. /* Interworking capabilities are set in 7th bit of 4th byte of the
  1826. * @WLAN_EID_EXT_CAPABILITY information element
  1827. */
  1828. #define WLAN_EXT_CAPA4_INTERWORKING_ENABLED BIT(7)
  1829. /*
  1830. * TDLS capabililites to be enabled in the 5th byte of the
  1831. * @WLAN_EID_EXT_CAPABILITY information element
  1832. */
  1833. #define WLAN_EXT_CAPA5_TDLS_ENABLED BIT(5)
  1834. #define WLAN_EXT_CAPA5_TDLS_PROHIBITED BIT(6)
  1835. #define WLAN_EXT_CAPA8_OPMODE_NOTIF BIT(6)
  1836. #define WLAN_EXT_CAPA8_TDLS_WIDE_BW_ENABLED BIT(7)
  1837. /* TDLS specific payload type in the LLC/SNAP header */
  1838. #define WLAN_TDLS_SNAP_RFTYPE 0x2
  1839. /**
  1840. * enum - mesh synchronization method identifier
  1841. *
  1842. * @IEEE80211_SYNC_METHOD_NEIGHBOR_OFFSET: the default synchronization method
  1843. * @IEEE80211_SYNC_METHOD_VENDOR: a vendor specific synchronization method
  1844. * that will be specified in a vendor specific information element
  1845. */
  1846. enum {
  1847. IEEE80211_SYNC_METHOD_NEIGHBOR_OFFSET = 1,
  1848. IEEE80211_SYNC_METHOD_VENDOR = 255,
  1849. };
  1850. /**
  1851. * enum - mesh path selection protocol identifier
  1852. *
  1853. * @IEEE80211_PATH_PROTOCOL_HWMP: the default path selection protocol
  1854. * @IEEE80211_PATH_PROTOCOL_VENDOR: a vendor specific protocol that will
  1855. * be specified in a vendor specific information element
  1856. */
  1857. enum {
  1858. IEEE80211_PATH_PROTOCOL_HWMP = 1,
  1859. IEEE80211_PATH_PROTOCOL_VENDOR = 255,
  1860. };
  1861. /**
  1862. * enum - mesh path selection metric identifier
  1863. *
  1864. * @IEEE80211_PATH_METRIC_AIRTIME: the default path selection metric
  1865. * @IEEE80211_PATH_METRIC_VENDOR: a vendor specific metric that will be
  1866. * specified in a vendor specific information element
  1867. */
  1868. enum {
  1869. IEEE80211_PATH_METRIC_AIRTIME = 1,
  1870. IEEE80211_PATH_METRIC_VENDOR = 255,
  1871. };
  1872. /**
  1873. * enum ieee80211_root_mode_identifier - root mesh STA mode identifier
  1874. *
  1875. * These attribute are used by dot11MeshHWMPRootMode to set root mesh STA mode
  1876. *
  1877. * @IEEE80211_ROOTMODE_NO_ROOT: the mesh STA is not a root mesh STA (default)
  1878. * @IEEE80211_ROOTMODE_ROOT: the mesh STA is a root mesh STA if greater than
  1879. * this value
  1880. * @IEEE80211_PROACTIVE_PREQ_NO_PREP: the mesh STA is a root mesh STA supports
  1881. * the proactive PREQ with proactive PREP subfield set to 0
  1882. * @IEEE80211_PROACTIVE_PREQ_WITH_PREP: the mesh STA is a root mesh STA
  1883. * supports the proactive PREQ with proactive PREP subfield set to 1
  1884. * @IEEE80211_PROACTIVE_RANN: the mesh STA is a root mesh STA supports
  1885. * the proactive RANN
  1886. */
  1887. enum ieee80211_root_mode_identifier {
  1888. IEEE80211_ROOTMODE_NO_ROOT = 0,
  1889. IEEE80211_ROOTMODE_ROOT = 1,
  1890. IEEE80211_PROACTIVE_PREQ_NO_PREP = 2,
  1891. IEEE80211_PROACTIVE_PREQ_WITH_PREP = 3,
  1892. IEEE80211_PROACTIVE_RANN = 4,
  1893. };
  1894. /*
  1895. * IEEE 802.11-2007 7.3.2.9 Country information element
  1896. *
  1897. * Minimum length is 8 octets, ie len must be evenly
  1898. * divisible by 2
  1899. */
  1900. /* Although the spec says 8 I'm seeing 6 in practice */
  1901. #define IEEE80211_COUNTRY_IE_MIN_LEN 6
  1902. /* The Country String field of the element shall be 3 octets in length */
  1903. #define IEEE80211_COUNTRY_STRING_LEN 3
  1904. /*
  1905. * For regulatory extension stuff see IEEE 802.11-2007
  1906. * Annex I (page 1141) and Annex J (page 1147). Also
  1907. * review 7.3.2.9.
  1908. *
  1909. * When dot11RegulatoryClassesRequired is true and the
  1910. * first_channel/reg_extension_id is >= 201 then the IE
  1911. * compromises of the 'ext' struct represented below:
  1912. *
  1913. * - Regulatory extension ID - when generating IE this just needs
  1914. * to be monotonically increasing for each triplet passed in
  1915. * the IE
  1916. * - Regulatory class - index into set of rules
  1917. * - Coverage class - index into air propagation time (Table 7-27),
  1918. * in microseconds, you can compute the air propagation time from
  1919. * the index by multiplying by 3, so index 10 yields a propagation
  1920. * of 10 us. Valid values are 0-31, values 32-255 are not defined
  1921. * yet. A value of 0 inicates air propagation of <= 1 us.
  1922. *
  1923. * See also Table I.2 for Emission limit sets and table
  1924. * I.3 for Behavior limit sets. Table J.1 indicates how to map
  1925. * a reg_class to an emission limit set and behavior limit set.
  1926. */
  1927. #define IEEE80211_COUNTRY_EXTENSION_ID 201
  1928. /*
  1929. * Channels numbers in the IE must be monotonically increasing
  1930. * if dot11RegulatoryClassesRequired is not true.
  1931. *
  1932. * If dot11RegulatoryClassesRequired is true consecutive
  1933. * subband triplets following a regulatory triplet shall
  1934. * have monotonically increasing first_channel number fields.
  1935. *
  1936. * Channel numbers shall not overlap.
  1937. *
  1938. * Note that max_power is signed.
  1939. */
  1940. struct ieee80211_country_ie_triplet {
  1941. union {
  1942. struct {
  1943. u8 first_channel;
  1944. u8 num_channels;
  1945. s8 max_power;
  1946. } __packed chans;
  1947. struct {
  1948. u8 reg_extension_id;
  1949. u8 reg_class;
  1950. u8 coverage_class;
  1951. } __packed ext;
  1952. };
  1953. } __packed;
  1954. enum ieee80211_timeout_interval_type {
  1955. WLAN_TIMEOUT_REASSOC_DEADLINE = 1 /* 802.11r */,
  1956. WLAN_TIMEOUT_KEY_LIFETIME = 2 /* 802.11r */,
  1957. WLAN_TIMEOUT_ASSOC_COMEBACK = 3 /* 802.11w */,
  1958. };
  1959. /**
  1960. * struct ieee80211_timeout_interval_ie - Timeout Interval element
  1961. * @type: type, see &enum ieee80211_timeout_interval_type
  1962. * @value: timeout interval value
  1963. */
  1964. struct ieee80211_timeout_interval_ie {
  1965. u8 type;
  1966. __le32 value;
  1967. } __packed;
  1968. /* BACK action code */
  1969. enum ieee80211_back_actioncode {
  1970. WLAN_ACTION_ADDBA_REQ = 0,
  1971. WLAN_ACTION_ADDBA_RESP = 1,
  1972. WLAN_ACTION_DELBA = 2,
  1973. };
  1974. /* BACK (block-ack) parties */
  1975. enum ieee80211_back_parties {
  1976. WLAN_BACK_RECIPIENT = 0,
  1977. WLAN_BACK_INITIATOR = 1,
  1978. };
  1979. /* SA Query action */
  1980. enum ieee80211_sa_query_action {
  1981. WLAN_ACTION_SA_QUERY_REQUEST = 0,
  1982. WLAN_ACTION_SA_QUERY_RESPONSE = 1,
  1983. };
  1984. /* cipher suite selectors */
  1985. #define WLAN_CIPHER_SUITE_USE_GROUP 0x000FAC00
  1986. #define WLAN_CIPHER_SUITE_WEP40 0x000FAC01
  1987. #define WLAN_CIPHER_SUITE_TKIP 0x000FAC02
  1988. /* reserved: 0x000FAC03 */
  1989. #define WLAN_CIPHER_SUITE_CCMP 0x000FAC04
  1990. #define WLAN_CIPHER_SUITE_WEP104 0x000FAC05
  1991. #define WLAN_CIPHER_SUITE_AES_CMAC 0x000FAC06
  1992. #define WLAN_CIPHER_SUITE_GCMP 0x000FAC08
  1993. #define WLAN_CIPHER_SUITE_SMS4 0x00147201
  1994. /* AKM suite selectors */
  1995. #define WLAN_AKM_SUITE_8021X 0x000FAC01
  1996. #define WLAN_AKM_SUITE_PSK 0x000FAC02
  1997. #define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05
  1998. #define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06
  1999. #define WLAN_AKM_SUITE_TDLS 0x000FAC07
  2000. #define WLAN_AKM_SUITE_SAE 0x000FAC08
  2001. #define WLAN_AKM_SUITE_FT_OVER_SAE 0x000FAC09
  2002. #define WLAN_MAX_KEY_LEN 32
  2003. #define WLAN_PMKID_LEN 16
  2004. #define WLAN_OUI_WFA 0x506f9a
  2005. #define WLAN_OUI_TYPE_WFA_P2P 9
  2006. #define WLAN_OUI_MICROSOFT 0x0050f2
  2007. #define WLAN_OUI_TYPE_MICROSOFT_WPA 1
  2008. #define WLAN_OUI_TYPE_MICROSOFT_WMM 2
  2009. #define WLAN_OUI_TYPE_MICROSOFT_WPS 4
  2010. /*
  2011. * WMM/802.11e Tspec Element
  2012. */
  2013. #define IEEE80211_WMM_IE_TSPEC_TID_MASK 0x0F
  2014. #define IEEE80211_WMM_IE_TSPEC_TID_SHIFT 1
  2015. enum ieee80211_tspec_status_code {
  2016. IEEE80211_TSPEC_STATUS_ADMISS_ACCEPTED = 0,
  2017. IEEE80211_TSPEC_STATUS_ADDTS_INVAL_PARAMS = 0x1,
  2018. };
  2019. struct ieee80211_tspec_ie {
  2020. u8 element_id;
  2021. u8 len;
  2022. u8 oui[3];
  2023. u8 oui_type;
  2024. u8 oui_subtype;
  2025. u8 version;
  2026. __le16 tsinfo;
  2027. u8 tsinfo_resvd;
  2028. __le16 nominal_msdu;
  2029. __le16 max_msdu;
  2030. __le32 min_service_int;
  2031. __le32 max_service_int;
  2032. __le32 inactivity_int;
  2033. __le32 suspension_int;
  2034. __le32 service_start_time;
  2035. __le32 min_data_rate;
  2036. __le32 mean_data_rate;
  2037. __le32 peak_data_rate;
  2038. __le32 max_burst_size;
  2039. __le32 delay_bound;
  2040. __le32 min_phy_rate;
  2041. __le16 sba;
  2042. __le16 medium_time;
  2043. } __packed;
  2044. /**
  2045. * ieee80211_get_qos_ctl - get pointer to qos control bytes
  2046. * @hdr: the frame
  2047. *
  2048. * The qos ctrl bytes come after the frame_control, duration, seq_num
  2049. * and 3 or 4 addresses of length ETH_ALEN.
  2050. * 3 addr: 2 + 2 + 2 + 3*6 = 24
  2051. * 4 addr: 2 + 2 + 2 + 4*6 = 30
  2052. */
  2053. static inline u8 *ieee80211_get_qos_ctl(struct ieee80211_hdr *hdr)
  2054. {
  2055. if (ieee80211_has_a4(hdr->frame_control))
  2056. return (u8 *)hdr + 30;
  2057. else
  2058. return (u8 *)hdr + 24;
  2059. }
  2060. /**
  2061. * ieee80211_get_SA - get pointer to SA
  2062. * @hdr: the frame
  2063. *
  2064. * Given an 802.11 frame, this function returns the offset
  2065. * to the source address (SA). It does not verify that the
  2066. * header is long enough to contain the address, and the
  2067. * header must be long enough to contain the frame control
  2068. * field.
  2069. */
  2070. static inline u8 *ieee80211_get_SA(struct ieee80211_hdr *hdr)
  2071. {
  2072. if (ieee80211_has_a4(hdr->frame_control))
  2073. return hdr->addr4;
  2074. if (ieee80211_has_fromds(hdr->frame_control))
  2075. return hdr->addr3;
  2076. return hdr->addr2;
  2077. }
  2078. /**
  2079. * ieee80211_get_DA - get pointer to DA
  2080. * @hdr: the frame
  2081. *
  2082. * Given an 802.11 frame, this function returns the offset
  2083. * to the destination address (DA). It does not verify that
  2084. * the header is long enough to contain the address, and the
  2085. * header must be long enough to contain the frame control
  2086. * field.
  2087. */
  2088. static inline u8 *ieee80211_get_DA(struct ieee80211_hdr *hdr)
  2089. {
  2090. if (ieee80211_has_tods(hdr->frame_control))
  2091. return hdr->addr3;
  2092. else
  2093. return hdr->addr1;
  2094. }
  2095. /**
  2096. * _ieee80211_is_robust_mgmt_frame - check if frame is a robust management frame
  2097. * @hdr: the frame (buffer must include at least the first octet of payload)
  2098. */
  2099. static inline bool _ieee80211_is_robust_mgmt_frame(struct ieee80211_hdr *hdr)
  2100. {
  2101. if (ieee80211_is_disassoc(hdr->frame_control) ||
  2102. ieee80211_is_deauth(hdr->frame_control))
  2103. return true;
  2104. if (ieee80211_is_action(hdr->frame_control)) {
  2105. u8 *category;
  2106. /*
  2107. * Action frames, excluding Public Action frames, are Robust
  2108. * Management Frames. However, if we are looking at a Protected
  2109. * frame, skip the check since the data may be encrypted and
  2110. * the frame has already been found to be a Robust Management
  2111. * Frame (by the other end).
  2112. */
  2113. if (ieee80211_has_protected(hdr->frame_control))
  2114. return true;
  2115. category = ((u8 *) hdr) + 24;
  2116. return *category != WLAN_CATEGORY_PUBLIC &&
  2117. *category != WLAN_CATEGORY_HT &&
  2118. *category != WLAN_CATEGORY_SELF_PROTECTED &&
  2119. *category != WLAN_CATEGORY_VENDOR_SPECIFIC;
  2120. }
  2121. return false;
  2122. }
  2123. /**
  2124. * ieee80211_is_robust_mgmt_frame - check if skb contains a robust mgmt frame
  2125. * @skb: the skb containing the frame, length will be checked
  2126. */
  2127. static inline bool ieee80211_is_robust_mgmt_frame(struct sk_buff *skb)
  2128. {
  2129. if (skb->len < 25)
  2130. return false;
  2131. return _ieee80211_is_robust_mgmt_frame((void *)skb->data);
  2132. }
  2133. /**
  2134. * ieee80211_is_public_action - check if frame is a public action frame
  2135. * @hdr: the frame
  2136. * @len: length of the frame
  2137. */
  2138. static inline bool ieee80211_is_public_action(struct ieee80211_hdr *hdr,
  2139. size_t len)
  2140. {
  2141. struct ieee80211_mgmt *mgmt = (void *)hdr;
  2142. if (len < IEEE80211_MIN_ACTION_SIZE)
  2143. return false;
  2144. if (!ieee80211_is_action(hdr->frame_control))
  2145. return false;
  2146. return mgmt->u.action.category == WLAN_CATEGORY_PUBLIC;
  2147. }
  2148. /**
  2149. * ieee80211_tu_to_usec - convert time units (TU) to microseconds
  2150. * @tu: the TUs
  2151. */
  2152. static inline unsigned long ieee80211_tu_to_usec(unsigned long tu)
  2153. {
  2154. return 1024 * tu;
  2155. }
  2156. /**
  2157. * ieee80211_check_tim - check if AID bit is set in TIM
  2158. * @tim: the TIM IE
  2159. * @tim_len: length of the TIM IE
  2160. * @aid: the AID to look for
  2161. */
  2162. static inline bool ieee80211_check_tim(const struct ieee80211_tim_ie *tim,
  2163. u8 tim_len, u16 aid)
  2164. {
  2165. u8 mask;
  2166. u8 index, indexn1, indexn2;
  2167. if (unlikely(!tim || tim_len < sizeof(*tim)))
  2168. return false;
  2169. aid &= 0x3fff;
  2170. index = aid / 8;
  2171. mask = 1 << (aid & 7);
  2172. indexn1 = tim->bitmap_ctrl & 0xfe;
  2173. indexn2 = tim_len + indexn1 - 4;
  2174. if (index < indexn1 || index > indexn2)
  2175. return false;
  2176. index -= indexn1;
  2177. return !!(tim->virtual_map[index] & mask);
  2178. }
  2179. /* convert time units */
  2180. #define TU_TO_JIFFIES(x) (usecs_to_jiffies((x) * 1024))
  2181. #define TU_TO_EXP_TIME(x) (jiffies + TU_TO_JIFFIES(x))
  2182. /**
  2183. * ieee80211_action_contains_tpc - checks if the frame contains TPC element
  2184. * @skb: the skb containing the frame, length will be checked
  2185. *
  2186. * This function checks if it's either TPC report action frame or Link
  2187. * Measurement report action frame as defined in IEEE Std. 802.11-2012 8.5.2.5
  2188. * and 8.5.7.5 accordingly.
  2189. */
  2190. static inline bool ieee80211_action_contains_tpc(struct sk_buff *skb)
  2191. {
  2192. struct ieee80211_mgmt *mgmt = (void *)skb->data;
  2193. if (!ieee80211_is_action(mgmt->frame_control))
  2194. return false;
  2195. if (skb->len < IEEE80211_MIN_ACTION_SIZE +
  2196. sizeof(mgmt->u.action.u.tpc_report))
  2197. return false;
  2198. /*
  2199. * TPC report - check that:
  2200. * category = 0 (Spectrum Management) or 5 (Radio Measurement)
  2201. * spectrum management action = 3 (TPC/Link Measurement report)
  2202. * TPC report EID = 35
  2203. * TPC report element length = 2
  2204. *
  2205. * The spectrum management's tpc_report struct is used here both for
  2206. * parsing tpc_report and radio measurement's link measurement report
  2207. * frame, since the relevant part is identical in both frames.
  2208. */
  2209. if (mgmt->u.action.category != WLAN_CATEGORY_SPECTRUM_MGMT &&
  2210. mgmt->u.action.category != WLAN_CATEGORY_RADIO_MEASUREMENT)
  2211. return false;
  2212. /* both spectrum mgmt and link measurement have same action code */
  2213. if (mgmt->u.action.u.tpc_report.action_code !=
  2214. WLAN_ACTION_SPCT_TPC_RPRT)
  2215. return false;
  2216. if (mgmt->u.action.u.tpc_report.tpc_elem_id != WLAN_EID_TPC_REPORT ||
  2217. mgmt->u.action.u.tpc_report.tpc_elem_length !=
  2218. sizeof(struct ieee80211_tpc_report_ie))
  2219. return false;
  2220. return true;
  2221. }
  2222. #endif /* LINUX_IEEE80211_H */