ieee80211.h 66 KB

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