ieee80211.h 75 KB

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