ieee80211.h 78 KB

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