ieee80211.h 66 KB

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