ieee80211.h 66 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296
  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_wide_bw_chansw_ie - wide bandwidth channel switch IE
  621. */
  622. struct ieee80211_wide_bw_chansw_ie {
  623. u8 new_channel_width;
  624. u8 new_center_freq_seg0, new_center_freq_seg1;
  625. } __packed;
  626. /**
  627. * struct ieee80211_tim
  628. *
  629. * This structure refers to "Traffic Indication Map information element"
  630. */
  631. struct ieee80211_tim_ie {
  632. u8 dtim_count;
  633. u8 dtim_period;
  634. u8 bitmap_ctrl;
  635. /* variable size: 1 - 251 bytes */
  636. u8 virtual_map[1];
  637. } __packed;
  638. /**
  639. * struct ieee80211_meshconf_ie
  640. *
  641. * This structure refers to "Mesh Configuration information element"
  642. */
  643. struct ieee80211_meshconf_ie {
  644. u8 meshconf_psel;
  645. u8 meshconf_pmetric;
  646. u8 meshconf_congest;
  647. u8 meshconf_synch;
  648. u8 meshconf_auth;
  649. u8 meshconf_form;
  650. u8 meshconf_cap;
  651. } __packed;
  652. /**
  653. * enum mesh_config_capab_flags - Mesh Configuration IE capability field flags
  654. *
  655. * @IEEE80211_MESHCONF_CAPAB_ACCEPT_PLINKS: STA is willing to establish
  656. * additional mesh peerings with other mesh STAs
  657. * @IEEE80211_MESHCONF_CAPAB_FORWARDING: the STA forwards MSDUs
  658. * @IEEE80211_MESHCONF_CAPAB_TBTT_ADJUSTING: TBTT adjustment procedure
  659. * is ongoing
  660. * @IEEE80211_MESHCONF_CAPAB_POWER_SAVE_LEVEL: STA is in deep sleep mode or has
  661. * neighbors in deep sleep mode
  662. */
  663. enum mesh_config_capab_flags {
  664. IEEE80211_MESHCONF_CAPAB_ACCEPT_PLINKS = 0x01,
  665. IEEE80211_MESHCONF_CAPAB_FORWARDING = 0x08,
  666. IEEE80211_MESHCONF_CAPAB_TBTT_ADJUSTING = 0x20,
  667. IEEE80211_MESHCONF_CAPAB_POWER_SAVE_LEVEL = 0x40,
  668. };
  669. /**
  670. * struct ieee80211_rann_ie
  671. *
  672. * This structure refers to "Root Announcement information element"
  673. */
  674. struct ieee80211_rann_ie {
  675. u8 rann_flags;
  676. u8 rann_hopcount;
  677. u8 rann_ttl;
  678. u8 rann_addr[ETH_ALEN];
  679. __le32 rann_seq;
  680. __le32 rann_interval;
  681. __le32 rann_metric;
  682. } __packed;
  683. enum ieee80211_rann_flags {
  684. RANN_FLAG_IS_GATE = 1 << 0,
  685. };
  686. enum ieee80211_ht_chanwidth_values {
  687. IEEE80211_HT_CHANWIDTH_20MHZ = 0,
  688. IEEE80211_HT_CHANWIDTH_ANY = 1,
  689. };
  690. /**
  691. * enum ieee80211_opmode_bits - VHT operating mode field bits
  692. * @IEEE80211_OPMODE_NOTIF_CHANWIDTH_MASK: channel width mask
  693. * @IEEE80211_OPMODE_NOTIF_CHANWIDTH_20MHZ: 20 MHz channel width
  694. * @IEEE80211_OPMODE_NOTIF_CHANWIDTH_40MHZ: 40 MHz channel width
  695. * @IEEE80211_OPMODE_NOTIF_CHANWIDTH_80MHZ: 80 MHz channel width
  696. * @IEEE80211_OPMODE_NOTIF_CHANWIDTH_160MHZ: 160 MHz or 80+80 MHz channel width
  697. * @IEEE80211_OPMODE_NOTIF_RX_NSS_MASK: number of spatial streams mask
  698. * (the NSS value is the value of this field + 1)
  699. * @IEEE80211_OPMODE_NOTIF_RX_NSS_SHIFT: number of spatial streams shift
  700. * @IEEE80211_OPMODE_NOTIF_RX_NSS_TYPE_BF: indicates streams in SU-MIMO PPDU
  701. * using a beamforming steering matrix
  702. */
  703. enum ieee80211_vht_opmode_bits {
  704. IEEE80211_OPMODE_NOTIF_CHANWIDTH_MASK = 3,
  705. IEEE80211_OPMODE_NOTIF_CHANWIDTH_20MHZ = 0,
  706. IEEE80211_OPMODE_NOTIF_CHANWIDTH_40MHZ = 1,
  707. IEEE80211_OPMODE_NOTIF_CHANWIDTH_80MHZ = 2,
  708. IEEE80211_OPMODE_NOTIF_CHANWIDTH_160MHZ = 3,
  709. IEEE80211_OPMODE_NOTIF_RX_NSS_MASK = 0x70,
  710. IEEE80211_OPMODE_NOTIF_RX_NSS_SHIFT = 4,
  711. IEEE80211_OPMODE_NOTIF_RX_NSS_TYPE_BF = 0x80,
  712. };
  713. #define WLAN_SA_QUERY_TR_ID_LEN 2
  714. struct ieee80211_mgmt {
  715. __le16 frame_control;
  716. __le16 duration;
  717. u8 da[ETH_ALEN];
  718. u8 sa[ETH_ALEN];
  719. u8 bssid[ETH_ALEN];
  720. __le16 seq_ctrl;
  721. union {
  722. struct {
  723. __le16 auth_alg;
  724. __le16 auth_transaction;
  725. __le16 status_code;
  726. /* possibly followed by Challenge text */
  727. u8 variable[0];
  728. } __packed auth;
  729. struct {
  730. __le16 reason_code;
  731. } __packed deauth;
  732. struct {
  733. __le16 capab_info;
  734. __le16 listen_interval;
  735. /* followed by SSID and Supported rates */
  736. u8 variable[0];
  737. } __packed assoc_req;
  738. struct {
  739. __le16 capab_info;
  740. __le16 status_code;
  741. __le16 aid;
  742. /* followed by Supported rates */
  743. u8 variable[0];
  744. } __packed assoc_resp, reassoc_resp;
  745. struct {
  746. __le16 capab_info;
  747. __le16 listen_interval;
  748. u8 current_ap[ETH_ALEN];
  749. /* followed by SSID and Supported rates */
  750. u8 variable[0];
  751. } __packed reassoc_req;
  752. struct {
  753. __le16 reason_code;
  754. } __packed disassoc;
  755. struct {
  756. __le64 timestamp;
  757. __le16 beacon_int;
  758. __le16 capab_info;
  759. /* followed by some of SSID, Supported rates,
  760. * FH Params, DS Params, CF Params, IBSS Params, TIM */
  761. u8 variable[0];
  762. } __packed beacon;
  763. struct {
  764. /* only variable items: SSID, Supported rates */
  765. u8 variable[0];
  766. } __packed probe_req;
  767. struct {
  768. __le64 timestamp;
  769. __le16 beacon_int;
  770. __le16 capab_info;
  771. /* followed by some of SSID, Supported rates,
  772. * FH Params, DS Params, CF Params, IBSS Params */
  773. u8 variable[0];
  774. } __packed probe_resp;
  775. struct {
  776. u8 category;
  777. union {
  778. struct {
  779. u8 action_code;
  780. u8 dialog_token;
  781. u8 status_code;
  782. u8 variable[0];
  783. } __packed wme_action;
  784. struct{
  785. u8 action_code;
  786. u8 variable[0];
  787. } __packed chan_switch;
  788. struct{
  789. u8 action_code;
  790. struct ieee80211_ext_chansw_ie data;
  791. u8 variable[0];
  792. } __packed ext_chan_switch;
  793. struct{
  794. u8 action_code;
  795. u8 dialog_token;
  796. u8 element_id;
  797. u8 length;
  798. struct ieee80211_msrment_ie msr_elem;
  799. } __packed measurement;
  800. struct{
  801. u8 action_code;
  802. u8 dialog_token;
  803. __le16 capab;
  804. __le16 timeout;
  805. __le16 start_seq_num;
  806. } __packed addba_req;
  807. struct{
  808. u8 action_code;
  809. u8 dialog_token;
  810. __le16 status;
  811. __le16 capab;
  812. __le16 timeout;
  813. } __packed addba_resp;
  814. struct{
  815. u8 action_code;
  816. __le16 params;
  817. __le16 reason_code;
  818. } __packed delba;
  819. struct {
  820. u8 action_code;
  821. u8 variable[0];
  822. } __packed self_prot;
  823. struct{
  824. u8 action_code;
  825. u8 variable[0];
  826. } __packed mesh_action;
  827. struct {
  828. u8 action;
  829. u8 trans_id[WLAN_SA_QUERY_TR_ID_LEN];
  830. } __packed sa_query;
  831. struct {
  832. u8 action;
  833. u8 smps_control;
  834. } __packed ht_smps;
  835. struct {
  836. u8 action_code;
  837. u8 chanwidth;
  838. } __packed ht_notify_cw;
  839. struct {
  840. u8 action_code;
  841. u8 dialog_token;
  842. __le16 capability;
  843. u8 variable[0];
  844. } __packed tdls_discover_resp;
  845. struct {
  846. u8 action_code;
  847. u8 operating_mode;
  848. } __packed vht_opmode_notif;
  849. } u;
  850. } __packed action;
  851. } u;
  852. } __packed __aligned(2);
  853. /* Supported Rates value encodings in 802.11n-2009 7.3.2.2 */
  854. #define BSS_MEMBERSHIP_SELECTOR_HT_PHY 127
  855. /* mgmt header + 1 byte category code */
  856. #define IEEE80211_MIN_ACTION_SIZE offsetof(struct ieee80211_mgmt, u.action.u)
  857. /* Management MIC information element (IEEE 802.11w) */
  858. struct ieee80211_mmie {
  859. u8 element_id;
  860. u8 length;
  861. __le16 key_id;
  862. u8 sequence_number[6];
  863. u8 mic[8];
  864. } __packed;
  865. struct ieee80211_vendor_ie {
  866. u8 element_id;
  867. u8 len;
  868. u8 oui[3];
  869. u8 oui_type;
  870. } __packed;
  871. /* Control frames */
  872. struct ieee80211_rts {
  873. __le16 frame_control;
  874. __le16 duration;
  875. u8 ra[ETH_ALEN];
  876. u8 ta[ETH_ALEN];
  877. } __packed __aligned(2);
  878. struct ieee80211_cts {
  879. __le16 frame_control;
  880. __le16 duration;
  881. u8 ra[ETH_ALEN];
  882. } __packed __aligned(2);
  883. struct ieee80211_pspoll {
  884. __le16 frame_control;
  885. __le16 aid;
  886. u8 bssid[ETH_ALEN];
  887. u8 ta[ETH_ALEN];
  888. } __packed __aligned(2);
  889. /* TDLS */
  890. /* Link-id information element */
  891. struct ieee80211_tdls_lnkie {
  892. u8 ie_type; /* Link Identifier IE */
  893. u8 ie_len;
  894. u8 bssid[ETH_ALEN];
  895. u8 init_sta[ETH_ALEN];
  896. u8 resp_sta[ETH_ALEN];
  897. } __packed;
  898. struct ieee80211_tdls_data {
  899. u8 da[ETH_ALEN];
  900. u8 sa[ETH_ALEN];
  901. __be16 ether_type;
  902. u8 payload_type;
  903. u8 category;
  904. u8 action_code;
  905. union {
  906. struct {
  907. u8 dialog_token;
  908. __le16 capability;
  909. u8 variable[0];
  910. } __packed setup_req;
  911. struct {
  912. __le16 status_code;
  913. u8 dialog_token;
  914. __le16 capability;
  915. u8 variable[0];
  916. } __packed setup_resp;
  917. struct {
  918. __le16 status_code;
  919. u8 dialog_token;
  920. u8 variable[0];
  921. } __packed setup_cfm;
  922. struct {
  923. __le16 reason_code;
  924. u8 variable[0];
  925. } __packed teardown;
  926. struct {
  927. u8 dialog_token;
  928. u8 variable[0];
  929. } __packed discover_req;
  930. } u;
  931. } __packed;
  932. /*
  933. * Peer-to-Peer IE attribute related definitions.
  934. */
  935. /**
  936. * enum ieee80211_p2p_attr_id - identifies type of peer-to-peer attribute.
  937. */
  938. enum ieee80211_p2p_attr_id {
  939. IEEE80211_P2P_ATTR_STATUS = 0,
  940. IEEE80211_P2P_ATTR_MINOR_REASON,
  941. IEEE80211_P2P_ATTR_CAPABILITY,
  942. IEEE80211_P2P_ATTR_DEVICE_ID,
  943. IEEE80211_P2P_ATTR_GO_INTENT,
  944. IEEE80211_P2P_ATTR_GO_CONFIG_TIMEOUT,
  945. IEEE80211_P2P_ATTR_LISTEN_CHANNEL,
  946. IEEE80211_P2P_ATTR_GROUP_BSSID,
  947. IEEE80211_P2P_ATTR_EXT_LISTEN_TIMING,
  948. IEEE80211_P2P_ATTR_INTENDED_IFACE_ADDR,
  949. IEEE80211_P2P_ATTR_MANAGABILITY,
  950. IEEE80211_P2P_ATTR_CHANNEL_LIST,
  951. IEEE80211_P2P_ATTR_ABSENCE_NOTICE,
  952. IEEE80211_P2P_ATTR_DEVICE_INFO,
  953. IEEE80211_P2P_ATTR_GROUP_INFO,
  954. IEEE80211_P2P_ATTR_GROUP_ID,
  955. IEEE80211_P2P_ATTR_INTERFACE,
  956. IEEE80211_P2P_ATTR_OPER_CHANNEL,
  957. IEEE80211_P2P_ATTR_INVITE_FLAGS,
  958. /* 19 - 220: Reserved */
  959. IEEE80211_P2P_ATTR_VENDOR_SPECIFIC = 221,
  960. IEEE80211_P2P_ATTR_MAX
  961. };
  962. /* Notice of Absence attribute - described in P2P spec 4.1.14 */
  963. /* Typical max value used here */
  964. #define IEEE80211_P2P_NOA_DESC_MAX 4
  965. struct ieee80211_p2p_noa_desc {
  966. u8 count;
  967. __le32 duration;
  968. __le32 interval;
  969. __le32 start_time;
  970. } __packed;
  971. struct ieee80211_p2p_noa_attr {
  972. u8 index;
  973. u8 oppps_ctwindow;
  974. struct ieee80211_p2p_noa_desc desc[IEEE80211_P2P_NOA_DESC_MAX];
  975. } __packed;
  976. #define IEEE80211_P2P_OPPPS_ENABLE_BIT BIT(7)
  977. #define IEEE80211_P2P_OPPPS_CTWINDOW_MASK 0x7F
  978. /**
  979. * struct ieee80211_bar - HT Block Ack Request
  980. *
  981. * This structure refers to "HT BlockAckReq" as
  982. * described in 802.11n draft section 7.2.1.7.1
  983. */
  984. struct ieee80211_bar {
  985. __le16 frame_control;
  986. __le16 duration;
  987. __u8 ra[ETH_ALEN];
  988. __u8 ta[ETH_ALEN];
  989. __le16 control;
  990. __le16 start_seq_num;
  991. } __packed;
  992. /* 802.11 BAR control masks */
  993. #define IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL 0x0000
  994. #define IEEE80211_BAR_CTRL_MULTI_TID 0x0002
  995. #define IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA 0x0004
  996. #define IEEE80211_BAR_CTRL_TID_INFO_MASK 0xf000
  997. #define IEEE80211_BAR_CTRL_TID_INFO_SHIFT 12
  998. #define IEEE80211_HT_MCS_MASK_LEN 10
  999. /**
  1000. * struct ieee80211_mcs_info - MCS information
  1001. * @rx_mask: RX mask
  1002. * @rx_highest: highest supported RX rate. If set represents
  1003. * the highest supported RX data rate in units of 1 Mbps.
  1004. * If this field is 0 this value should not be used to
  1005. * consider the highest RX data rate supported.
  1006. * @tx_params: TX parameters
  1007. */
  1008. struct ieee80211_mcs_info {
  1009. u8 rx_mask[IEEE80211_HT_MCS_MASK_LEN];
  1010. __le16 rx_highest;
  1011. u8 tx_params;
  1012. u8 reserved[3];
  1013. } __packed;
  1014. /* 802.11n HT capability MSC set */
  1015. #define IEEE80211_HT_MCS_RX_HIGHEST_MASK 0x3ff
  1016. #define IEEE80211_HT_MCS_TX_DEFINED 0x01
  1017. #define IEEE80211_HT_MCS_TX_RX_DIFF 0x02
  1018. /* value 0 == 1 stream etc */
  1019. #define IEEE80211_HT_MCS_TX_MAX_STREAMS_MASK 0x0C
  1020. #define IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT 2
  1021. #define IEEE80211_HT_MCS_TX_MAX_STREAMS 4
  1022. #define IEEE80211_HT_MCS_TX_UNEQUAL_MODULATION 0x10
  1023. /*
  1024. * 802.11n D5.0 20.3.5 / 20.6 says:
  1025. * - indices 0 to 7 and 32 are single spatial stream
  1026. * - 8 to 31 are multiple spatial streams using equal modulation
  1027. * [8..15 for two streams, 16..23 for three and 24..31 for four]
  1028. * - remainder are multiple spatial streams using unequal modulation
  1029. */
  1030. #define IEEE80211_HT_MCS_UNEQUAL_MODULATION_START 33
  1031. #define IEEE80211_HT_MCS_UNEQUAL_MODULATION_START_BYTE \
  1032. (IEEE80211_HT_MCS_UNEQUAL_MODULATION_START / 8)
  1033. /**
  1034. * struct ieee80211_ht_cap - HT capabilities
  1035. *
  1036. * This structure is the "HT capabilities element" as
  1037. * described in 802.11n D5.0 7.3.2.57
  1038. */
  1039. struct ieee80211_ht_cap {
  1040. __le16 cap_info;
  1041. u8 ampdu_params_info;
  1042. /* 16 bytes MCS information */
  1043. struct ieee80211_mcs_info mcs;
  1044. __le16 extended_ht_cap_info;
  1045. __le32 tx_BF_cap_info;
  1046. u8 antenna_selection_info;
  1047. } __packed;
  1048. /* 802.11n HT capabilities masks (for cap_info) */
  1049. #define IEEE80211_HT_CAP_LDPC_CODING 0x0001
  1050. #define IEEE80211_HT_CAP_SUP_WIDTH_20_40 0x0002
  1051. #define IEEE80211_HT_CAP_SM_PS 0x000C
  1052. #define IEEE80211_HT_CAP_SM_PS_SHIFT 2
  1053. #define IEEE80211_HT_CAP_GRN_FLD 0x0010
  1054. #define IEEE80211_HT_CAP_SGI_20 0x0020
  1055. #define IEEE80211_HT_CAP_SGI_40 0x0040
  1056. #define IEEE80211_HT_CAP_TX_STBC 0x0080
  1057. #define IEEE80211_HT_CAP_RX_STBC 0x0300
  1058. #define IEEE80211_HT_CAP_RX_STBC_SHIFT 8
  1059. #define IEEE80211_HT_CAP_DELAY_BA 0x0400
  1060. #define IEEE80211_HT_CAP_MAX_AMSDU 0x0800
  1061. #define IEEE80211_HT_CAP_DSSSCCK40 0x1000
  1062. #define IEEE80211_HT_CAP_RESERVED 0x2000
  1063. #define IEEE80211_HT_CAP_40MHZ_INTOLERANT 0x4000
  1064. #define IEEE80211_HT_CAP_LSIG_TXOP_PROT 0x8000
  1065. /* 802.11n HT extended capabilities masks (for extended_ht_cap_info) */
  1066. #define IEEE80211_HT_EXT_CAP_PCO 0x0001
  1067. #define IEEE80211_HT_EXT_CAP_PCO_TIME 0x0006
  1068. #define IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT 1
  1069. #define IEEE80211_HT_EXT_CAP_MCS_FB 0x0300
  1070. #define IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT 8
  1071. #define IEEE80211_HT_EXT_CAP_HTC_SUP 0x0400
  1072. #define IEEE80211_HT_EXT_CAP_RD_RESPONDER 0x0800
  1073. /* 802.11n HT capability AMPDU settings (for ampdu_params_info) */
  1074. #define IEEE80211_HT_AMPDU_PARM_FACTOR 0x03
  1075. #define IEEE80211_HT_AMPDU_PARM_DENSITY 0x1C
  1076. #define IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT 2
  1077. /*
  1078. * Maximum length of AMPDU that the STA can receive.
  1079. * Length = 2 ^ (13 + max_ampdu_length_exp) - 1 (octets)
  1080. */
  1081. enum ieee80211_max_ampdu_length_exp {
  1082. IEEE80211_HT_MAX_AMPDU_8K = 0,
  1083. IEEE80211_HT_MAX_AMPDU_16K = 1,
  1084. IEEE80211_HT_MAX_AMPDU_32K = 2,
  1085. IEEE80211_HT_MAX_AMPDU_64K = 3
  1086. };
  1087. #define IEEE80211_HT_MAX_AMPDU_FACTOR 13
  1088. /* Minimum MPDU start spacing */
  1089. enum ieee80211_min_mpdu_spacing {
  1090. IEEE80211_HT_MPDU_DENSITY_NONE = 0, /* No restriction */
  1091. IEEE80211_HT_MPDU_DENSITY_0_25 = 1, /* 1/4 usec */
  1092. IEEE80211_HT_MPDU_DENSITY_0_5 = 2, /* 1/2 usec */
  1093. IEEE80211_HT_MPDU_DENSITY_1 = 3, /* 1 usec */
  1094. IEEE80211_HT_MPDU_DENSITY_2 = 4, /* 2 usec */
  1095. IEEE80211_HT_MPDU_DENSITY_4 = 5, /* 4 usec */
  1096. IEEE80211_HT_MPDU_DENSITY_8 = 6, /* 8 usec */
  1097. IEEE80211_HT_MPDU_DENSITY_16 = 7 /* 16 usec */
  1098. };
  1099. /**
  1100. * struct ieee80211_ht_operation - HT operation IE
  1101. *
  1102. * This structure is the "HT operation element" as
  1103. * described in 802.11n-2009 7.3.2.57
  1104. */
  1105. struct ieee80211_ht_operation {
  1106. u8 primary_chan;
  1107. u8 ht_param;
  1108. __le16 operation_mode;
  1109. __le16 stbc_param;
  1110. u8 basic_set[16];
  1111. } __packed;
  1112. /* for ht_param */
  1113. #define IEEE80211_HT_PARAM_CHA_SEC_OFFSET 0x03
  1114. #define IEEE80211_HT_PARAM_CHA_SEC_NONE 0x00
  1115. #define IEEE80211_HT_PARAM_CHA_SEC_ABOVE 0x01
  1116. #define IEEE80211_HT_PARAM_CHA_SEC_BELOW 0x03
  1117. #define IEEE80211_HT_PARAM_CHAN_WIDTH_ANY 0x04
  1118. #define IEEE80211_HT_PARAM_RIFS_MODE 0x08
  1119. /* for operation_mode */
  1120. #define IEEE80211_HT_OP_MODE_PROTECTION 0x0003
  1121. #define IEEE80211_HT_OP_MODE_PROTECTION_NONE 0
  1122. #define IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER 1
  1123. #define IEEE80211_HT_OP_MODE_PROTECTION_20MHZ 2
  1124. #define IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED 3
  1125. #define IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT 0x0004
  1126. #define IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT 0x0010
  1127. /* for stbc_param */
  1128. #define IEEE80211_HT_STBC_PARAM_DUAL_BEACON 0x0040
  1129. #define IEEE80211_HT_STBC_PARAM_DUAL_CTS_PROT 0x0080
  1130. #define IEEE80211_HT_STBC_PARAM_STBC_BEACON 0x0100
  1131. #define IEEE80211_HT_STBC_PARAM_LSIG_TXOP_FULLPROT 0x0200
  1132. #define IEEE80211_HT_STBC_PARAM_PCO_ACTIVE 0x0400
  1133. #define IEEE80211_HT_STBC_PARAM_PCO_PHASE 0x0800
  1134. /* block-ack parameters */
  1135. #define IEEE80211_ADDBA_PARAM_POLICY_MASK 0x0002
  1136. #define IEEE80211_ADDBA_PARAM_TID_MASK 0x003C
  1137. #define IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK 0xFFC0
  1138. #define IEEE80211_DELBA_PARAM_TID_MASK 0xF000
  1139. #define IEEE80211_DELBA_PARAM_INITIATOR_MASK 0x0800
  1140. /*
  1141. * A-PMDU buffer sizes
  1142. * According to IEEE802.11n spec size varies from 8K to 64K (in powers of 2)
  1143. */
  1144. #define IEEE80211_MIN_AMPDU_BUF 0x8
  1145. #define IEEE80211_MAX_AMPDU_BUF 0x40
  1146. /* Spatial Multiplexing Power Save Modes (for capability) */
  1147. #define WLAN_HT_CAP_SM_PS_STATIC 0
  1148. #define WLAN_HT_CAP_SM_PS_DYNAMIC 1
  1149. #define WLAN_HT_CAP_SM_PS_INVALID 2
  1150. #define WLAN_HT_CAP_SM_PS_DISABLED 3
  1151. /* for SM power control field lower two bits */
  1152. #define WLAN_HT_SMPS_CONTROL_DISABLED 0
  1153. #define WLAN_HT_SMPS_CONTROL_STATIC 1
  1154. #define WLAN_HT_SMPS_CONTROL_DYNAMIC 3
  1155. /**
  1156. * struct ieee80211_vht_mcs_info - VHT MCS information
  1157. * @rx_mcs_map: RX MCS map 2 bits for each stream, total 8 streams
  1158. * @rx_highest: Indicates highest long GI VHT PPDU data rate
  1159. * STA can receive. Rate expressed in units of 1 Mbps.
  1160. * If this field is 0 this value should not be used to
  1161. * consider the highest RX data rate supported.
  1162. * The top 3 bits of this field are reserved.
  1163. * @tx_mcs_map: TX MCS map 2 bits for each stream, total 8 streams
  1164. * @tx_highest: Indicates highest long GI VHT PPDU data rate
  1165. * STA can transmit. Rate expressed in units of 1 Mbps.
  1166. * If this field is 0 this value should not be used to
  1167. * consider the highest TX data rate supported.
  1168. * The top 3 bits of this field are reserved.
  1169. */
  1170. struct ieee80211_vht_mcs_info {
  1171. __le16 rx_mcs_map;
  1172. __le16 rx_highest;
  1173. __le16 tx_mcs_map;
  1174. __le16 tx_highest;
  1175. } __packed;
  1176. /**
  1177. * enum ieee80211_vht_mcs_support - VHT MCS support definitions
  1178. * @IEEE80211_VHT_MCS_SUPPORT_0_7: MCSes 0-7 are supported for the
  1179. * number of streams
  1180. * @IEEE80211_VHT_MCS_SUPPORT_0_8: MCSes 0-8 are supported
  1181. * @IEEE80211_VHT_MCS_SUPPORT_0_9: MCSes 0-9 are supported
  1182. * @IEEE80211_VHT_MCS_NOT_SUPPORTED: This number of streams isn't supported
  1183. *
  1184. * These definitions are used in each 2-bit subfield of the @rx_mcs_map
  1185. * and @tx_mcs_map fields of &struct ieee80211_vht_mcs_info, which are
  1186. * both split into 8 subfields by number of streams. These values indicate
  1187. * which MCSes are supported for the number of streams the value appears
  1188. * for.
  1189. */
  1190. enum ieee80211_vht_mcs_support {
  1191. IEEE80211_VHT_MCS_SUPPORT_0_7 = 0,
  1192. IEEE80211_VHT_MCS_SUPPORT_0_8 = 1,
  1193. IEEE80211_VHT_MCS_SUPPORT_0_9 = 2,
  1194. IEEE80211_VHT_MCS_NOT_SUPPORTED = 3,
  1195. };
  1196. /**
  1197. * struct ieee80211_vht_cap - VHT capabilities
  1198. *
  1199. * This structure is the "VHT capabilities element" as
  1200. * described in 802.11ac D3.0 8.4.2.160
  1201. * @vht_cap_info: VHT capability info
  1202. * @supp_mcs: VHT MCS supported rates
  1203. */
  1204. struct ieee80211_vht_cap {
  1205. __le32 vht_cap_info;
  1206. struct ieee80211_vht_mcs_info supp_mcs;
  1207. } __packed;
  1208. /**
  1209. * enum ieee80211_vht_chanwidth - VHT channel width
  1210. * @IEEE80211_VHT_CHANWIDTH_USE_HT: use the HT operation IE to
  1211. * determine the channel width (20 or 40 MHz)
  1212. * @IEEE80211_VHT_CHANWIDTH_80MHZ: 80 MHz bandwidth
  1213. * @IEEE80211_VHT_CHANWIDTH_160MHZ: 160 MHz bandwidth
  1214. * @IEEE80211_VHT_CHANWIDTH_80P80MHZ: 80+80 MHz bandwidth
  1215. */
  1216. enum ieee80211_vht_chanwidth {
  1217. IEEE80211_VHT_CHANWIDTH_USE_HT = 0,
  1218. IEEE80211_VHT_CHANWIDTH_80MHZ = 1,
  1219. IEEE80211_VHT_CHANWIDTH_160MHZ = 2,
  1220. IEEE80211_VHT_CHANWIDTH_80P80MHZ = 3,
  1221. };
  1222. /**
  1223. * struct ieee80211_vht_operation - VHT operation IE
  1224. *
  1225. * This structure is the "VHT operation element" as
  1226. * described in 802.11ac D3.0 8.4.2.161
  1227. * @chan_width: Operating channel width
  1228. * @center_freq_seg1_idx: center freq segment 1 index
  1229. * @center_freq_seg2_idx: center freq segment 2 index
  1230. * @basic_mcs_set: VHT Basic MCS rate set
  1231. */
  1232. struct ieee80211_vht_operation {
  1233. u8 chan_width;
  1234. u8 center_freq_seg1_idx;
  1235. u8 center_freq_seg2_idx;
  1236. __le16 basic_mcs_set;
  1237. } __packed;
  1238. /* 802.11ac VHT Capabilities */
  1239. #define IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895 0x00000000
  1240. #define IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991 0x00000001
  1241. #define IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454 0x00000002
  1242. #define IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ 0x00000004
  1243. #define IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ 0x00000008
  1244. #define IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK 0x0000000C
  1245. #define IEEE80211_VHT_CAP_RXLDPC 0x00000010
  1246. #define IEEE80211_VHT_CAP_SHORT_GI_80 0x00000020
  1247. #define IEEE80211_VHT_CAP_SHORT_GI_160 0x00000040
  1248. #define IEEE80211_VHT_CAP_TXSTBC 0x00000080
  1249. #define IEEE80211_VHT_CAP_RXSTBC_1 0x00000100
  1250. #define IEEE80211_VHT_CAP_RXSTBC_2 0x00000200
  1251. #define IEEE80211_VHT_CAP_RXSTBC_3 0x00000300
  1252. #define IEEE80211_VHT_CAP_RXSTBC_4 0x00000400
  1253. #define IEEE80211_VHT_CAP_RXSTBC_MASK 0x00000700
  1254. #define IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE 0x00000800
  1255. #define IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE 0x00001000
  1256. #define IEEE80211_VHT_CAP_BEAMFORMEE_STS_MAX 0x0000e000
  1257. #define IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_MAX 0x00070000
  1258. #define IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE 0x00080000
  1259. #define IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE 0x00100000
  1260. #define IEEE80211_VHT_CAP_VHT_TXOP_PS 0x00200000
  1261. #define IEEE80211_VHT_CAP_HTC_VHT 0x00400000
  1262. #define IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT 23
  1263. #define IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK \
  1264. (7 << IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT)
  1265. #define IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_UNSOL_MFB 0x08000000
  1266. #define IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB 0x0c000000
  1267. #define IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN 0x10000000
  1268. #define IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN 0x20000000
  1269. /* Authentication algorithms */
  1270. #define WLAN_AUTH_OPEN 0
  1271. #define WLAN_AUTH_SHARED_KEY 1
  1272. #define WLAN_AUTH_FT 2
  1273. #define WLAN_AUTH_SAE 3
  1274. #define WLAN_AUTH_LEAP 128
  1275. #define WLAN_AUTH_CHALLENGE_LEN 128
  1276. #define WLAN_CAPABILITY_ESS (1<<0)
  1277. #define WLAN_CAPABILITY_IBSS (1<<1)
  1278. /*
  1279. * A mesh STA sets the ESS and IBSS capability bits to zero.
  1280. * however, this holds true for p2p probe responses (in the p2p_find
  1281. * phase) as well.
  1282. */
  1283. #define WLAN_CAPABILITY_IS_STA_BSS(cap) \
  1284. (!((cap) & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS)))
  1285. #define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
  1286. #define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
  1287. #define WLAN_CAPABILITY_PRIVACY (1<<4)
  1288. #define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
  1289. #define WLAN_CAPABILITY_PBCC (1<<6)
  1290. #define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
  1291. /* 802.11h */
  1292. #define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8)
  1293. #define WLAN_CAPABILITY_QOS (1<<9)
  1294. #define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10)
  1295. #define WLAN_CAPABILITY_APSD (1<<11)
  1296. #define WLAN_CAPABILITY_RADIO_MEASURE (1<<12)
  1297. #define WLAN_CAPABILITY_DSSS_OFDM (1<<13)
  1298. #define WLAN_CAPABILITY_DEL_BACK (1<<14)
  1299. #define WLAN_CAPABILITY_IMM_BACK (1<<15)
  1300. /* DMG (60gHz) 802.11ad */
  1301. /* type - bits 0..1 */
  1302. #define WLAN_CAPABILITY_DMG_TYPE_MASK (3<<0)
  1303. #define WLAN_CAPABILITY_DMG_TYPE_IBSS (1<<0) /* Tx by: STA */
  1304. #define WLAN_CAPABILITY_DMG_TYPE_PBSS (2<<0) /* Tx by: PCP */
  1305. #define WLAN_CAPABILITY_DMG_TYPE_AP (3<<0) /* Tx by: AP */
  1306. #define WLAN_CAPABILITY_DMG_CBAP_ONLY (1<<2)
  1307. #define WLAN_CAPABILITY_DMG_CBAP_SOURCE (1<<3)
  1308. #define WLAN_CAPABILITY_DMG_PRIVACY (1<<4)
  1309. #define WLAN_CAPABILITY_DMG_ECPAC (1<<5)
  1310. #define WLAN_CAPABILITY_DMG_SPECTRUM_MGMT (1<<8)
  1311. #define WLAN_CAPABILITY_DMG_RADIO_MEASURE (1<<12)
  1312. /* measurement */
  1313. #define IEEE80211_SPCT_MSR_RPRT_MODE_LATE (1<<0)
  1314. #define IEEE80211_SPCT_MSR_RPRT_MODE_INCAPABLE (1<<1)
  1315. #define IEEE80211_SPCT_MSR_RPRT_MODE_REFUSED (1<<2)
  1316. #define IEEE80211_SPCT_MSR_RPRT_TYPE_BASIC 0
  1317. #define IEEE80211_SPCT_MSR_RPRT_TYPE_CCA 1
  1318. #define IEEE80211_SPCT_MSR_RPRT_TYPE_RPI 2
  1319. /* 802.11g ERP information element */
  1320. #define WLAN_ERP_NON_ERP_PRESENT (1<<0)
  1321. #define WLAN_ERP_USE_PROTECTION (1<<1)
  1322. #define WLAN_ERP_BARKER_PREAMBLE (1<<2)
  1323. /* WLAN_ERP_BARKER_PREAMBLE values */
  1324. enum {
  1325. WLAN_ERP_PREAMBLE_SHORT = 0,
  1326. WLAN_ERP_PREAMBLE_LONG = 1,
  1327. };
  1328. /* Band ID, 802.11ad #8.4.1.45 */
  1329. enum {
  1330. IEEE80211_BANDID_TV_WS = 0, /* TV white spaces */
  1331. IEEE80211_BANDID_SUB1 = 1, /* Sub-1 GHz (excluding TV white spaces) */
  1332. IEEE80211_BANDID_2G = 2, /* 2.4 GHz */
  1333. IEEE80211_BANDID_3G = 3, /* 3.6 GHz */
  1334. IEEE80211_BANDID_5G = 4, /* 4.9 and 5 GHz */
  1335. IEEE80211_BANDID_60G = 5, /* 60 GHz */
  1336. };
  1337. /* Status codes */
  1338. enum ieee80211_statuscode {
  1339. WLAN_STATUS_SUCCESS = 0,
  1340. WLAN_STATUS_UNSPECIFIED_FAILURE = 1,
  1341. WLAN_STATUS_CAPS_UNSUPPORTED = 10,
  1342. WLAN_STATUS_REASSOC_NO_ASSOC = 11,
  1343. WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12,
  1344. WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13,
  1345. WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14,
  1346. WLAN_STATUS_CHALLENGE_FAIL = 15,
  1347. WLAN_STATUS_AUTH_TIMEOUT = 16,
  1348. WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17,
  1349. WLAN_STATUS_ASSOC_DENIED_RATES = 18,
  1350. /* 802.11b */
  1351. WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19,
  1352. WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20,
  1353. WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21,
  1354. /* 802.11h */
  1355. WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22,
  1356. WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23,
  1357. WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24,
  1358. /* 802.11g */
  1359. WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25,
  1360. WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26,
  1361. /* 802.11w */
  1362. WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY = 30,
  1363. WLAN_STATUS_ROBUST_MGMT_FRAME_POLICY_VIOLATION = 31,
  1364. /* 802.11i */
  1365. WLAN_STATUS_INVALID_IE = 40,
  1366. WLAN_STATUS_INVALID_GROUP_CIPHER = 41,
  1367. WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42,
  1368. WLAN_STATUS_INVALID_AKMP = 43,
  1369. WLAN_STATUS_UNSUPP_RSN_VERSION = 44,
  1370. WLAN_STATUS_INVALID_RSN_IE_CAP = 45,
  1371. WLAN_STATUS_CIPHER_SUITE_REJECTED = 46,
  1372. /* 802.11e */
  1373. WLAN_STATUS_UNSPECIFIED_QOS = 32,
  1374. WLAN_STATUS_ASSOC_DENIED_NOBANDWIDTH = 33,
  1375. WLAN_STATUS_ASSOC_DENIED_LOWACK = 34,
  1376. WLAN_STATUS_ASSOC_DENIED_UNSUPP_QOS = 35,
  1377. WLAN_STATUS_REQUEST_DECLINED = 37,
  1378. WLAN_STATUS_INVALID_QOS_PARAM = 38,
  1379. WLAN_STATUS_CHANGE_TSPEC = 39,
  1380. WLAN_STATUS_WAIT_TS_DELAY = 47,
  1381. WLAN_STATUS_NO_DIRECT_LINK = 48,
  1382. WLAN_STATUS_STA_NOT_PRESENT = 49,
  1383. WLAN_STATUS_STA_NOT_QSTA = 50,
  1384. /* 802.11s */
  1385. WLAN_STATUS_ANTI_CLOG_REQUIRED = 76,
  1386. WLAN_STATUS_FCG_NOT_SUPP = 78,
  1387. WLAN_STATUS_STA_NO_TBTT = 78,
  1388. /* 802.11ad */
  1389. WLAN_STATUS_REJECTED_WITH_SUGGESTED_CHANGES = 39,
  1390. WLAN_STATUS_REJECTED_FOR_DELAY_PERIOD = 47,
  1391. WLAN_STATUS_REJECT_WITH_SCHEDULE = 83,
  1392. WLAN_STATUS_PENDING_ADMITTING_FST_SESSION = 86,
  1393. WLAN_STATUS_PERFORMING_FST_NOW = 87,
  1394. WLAN_STATUS_PENDING_GAP_IN_BA_WINDOW = 88,
  1395. WLAN_STATUS_REJECT_U_PID_SETTING = 89,
  1396. WLAN_STATUS_REJECT_DSE_BAND = 96,
  1397. WLAN_STATUS_DENIED_WITH_SUGGESTED_BAND_AND_CHANNEL = 99,
  1398. WLAN_STATUS_DENIED_DUE_TO_SPECTRUM_MANAGEMENT = 103,
  1399. };
  1400. /* Reason codes */
  1401. enum ieee80211_reasoncode {
  1402. WLAN_REASON_UNSPECIFIED = 1,
  1403. WLAN_REASON_PREV_AUTH_NOT_VALID = 2,
  1404. WLAN_REASON_DEAUTH_LEAVING = 3,
  1405. WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4,
  1406. WLAN_REASON_DISASSOC_AP_BUSY = 5,
  1407. WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6,
  1408. WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7,
  1409. WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8,
  1410. WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9,
  1411. /* 802.11h */
  1412. WLAN_REASON_DISASSOC_BAD_POWER = 10,
  1413. WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11,
  1414. /* 802.11i */
  1415. WLAN_REASON_INVALID_IE = 13,
  1416. WLAN_REASON_MIC_FAILURE = 14,
  1417. WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15,
  1418. WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16,
  1419. WLAN_REASON_IE_DIFFERENT = 17,
  1420. WLAN_REASON_INVALID_GROUP_CIPHER = 18,
  1421. WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19,
  1422. WLAN_REASON_INVALID_AKMP = 20,
  1423. WLAN_REASON_UNSUPP_RSN_VERSION = 21,
  1424. WLAN_REASON_INVALID_RSN_IE_CAP = 22,
  1425. WLAN_REASON_IEEE8021X_FAILED = 23,
  1426. WLAN_REASON_CIPHER_SUITE_REJECTED = 24,
  1427. /* 802.11e */
  1428. WLAN_REASON_DISASSOC_UNSPECIFIED_QOS = 32,
  1429. WLAN_REASON_DISASSOC_QAP_NO_BANDWIDTH = 33,
  1430. WLAN_REASON_DISASSOC_LOW_ACK = 34,
  1431. WLAN_REASON_DISASSOC_QAP_EXCEED_TXOP = 35,
  1432. WLAN_REASON_QSTA_LEAVE_QBSS = 36,
  1433. WLAN_REASON_QSTA_NOT_USE = 37,
  1434. WLAN_REASON_QSTA_REQUIRE_SETUP = 38,
  1435. WLAN_REASON_QSTA_TIMEOUT = 39,
  1436. WLAN_REASON_QSTA_CIPHER_NOT_SUPP = 45,
  1437. /* 802.11s */
  1438. WLAN_REASON_MESH_PEER_CANCELED = 52,
  1439. WLAN_REASON_MESH_MAX_PEERS = 53,
  1440. WLAN_REASON_MESH_CONFIG = 54,
  1441. WLAN_REASON_MESH_CLOSE = 55,
  1442. WLAN_REASON_MESH_MAX_RETRIES = 56,
  1443. WLAN_REASON_MESH_CONFIRM_TIMEOUT = 57,
  1444. WLAN_REASON_MESH_INVALID_GTK = 58,
  1445. WLAN_REASON_MESH_INCONSISTENT_PARAM = 59,
  1446. WLAN_REASON_MESH_INVALID_SECURITY = 60,
  1447. WLAN_REASON_MESH_PATH_ERROR = 61,
  1448. WLAN_REASON_MESH_PATH_NOFORWARD = 62,
  1449. WLAN_REASON_MESH_PATH_DEST_UNREACHABLE = 63,
  1450. WLAN_REASON_MAC_EXISTS_IN_MBSS = 64,
  1451. WLAN_REASON_MESH_CHAN_REGULATORY = 65,
  1452. WLAN_REASON_MESH_CHAN = 66,
  1453. };
  1454. /* Information Element IDs */
  1455. enum ieee80211_eid {
  1456. WLAN_EID_SSID = 0,
  1457. WLAN_EID_SUPP_RATES = 1,
  1458. WLAN_EID_FH_PARAMS = 2,
  1459. WLAN_EID_DS_PARAMS = 3,
  1460. WLAN_EID_CF_PARAMS = 4,
  1461. WLAN_EID_TIM = 5,
  1462. WLAN_EID_IBSS_PARAMS = 6,
  1463. WLAN_EID_CHALLENGE = 16,
  1464. WLAN_EID_COUNTRY = 7,
  1465. WLAN_EID_HP_PARAMS = 8,
  1466. WLAN_EID_HP_TABLE = 9,
  1467. WLAN_EID_REQUEST = 10,
  1468. WLAN_EID_QBSS_LOAD = 11,
  1469. WLAN_EID_EDCA_PARAM_SET = 12,
  1470. WLAN_EID_TSPEC = 13,
  1471. WLAN_EID_TCLAS = 14,
  1472. WLAN_EID_SCHEDULE = 15,
  1473. WLAN_EID_TS_DELAY = 43,
  1474. WLAN_EID_TCLAS_PROCESSING = 44,
  1475. WLAN_EID_QOS_CAPA = 46,
  1476. /* 802.11z */
  1477. WLAN_EID_LINK_ID = 101,
  1478. /* 802.11s */
  1479. WLAN_EID_MESH_CONFIG = 113,
  1480. WLAN_EID_MESH_ID = 114,
  1481. WLAN_EID_LINK_METRIC_REPORT = 115,
  1482. WLAN_EID_CONGESTION_NOTIFICATION = 116,
  1483. WLAN_EID_PEER_MGMT = 117,
  1484. WLAN_EID_CHAN_SWITCH_PARAM = 118,
  1485. WLAN_EID_MESH_AWAKE_WINDOW = 119,
  1486. WLAN_EID_BEACON_TIMING = 120,
  1487. WLAN_EID_MCCAOP_SETUP_REQ = 121,
  1488. WLAN_EID_MCCAOP_SETUP_RESP = 122,
  1489. WLAN_EID_MCCAOP_ADVERT = 123,
  1490. WLAN_EID_MCCAOP_TEARDOWN = 124,
  1491. WLAN_EID_GANN = 125,
  1492. WLAN_EID_RANN = 126,
  1493. WLAN_EID_PREQ = 130,
  1494. WLAN_EID_PREP = 131,
  1495. WLAN_EID_PERR = 132,
  1496. WLAN_EID_PXU = 137,
  1497. WLAN_EID_PXUC = 138,
  1498. WLAN_EID_AUTH_MESH_PEER_EXCH = 139,
  1499. WLAN_EID_MIC = 140,
  1500. WLAN_EID_PWR_CONSTRAINT = 32,
  1501. WLAN_EID_PWR_CAPABILITY = 33,
  1502. WLAN_EID_TPC_REQUEST = 34,
  1503. WLAN_EID_TPC_REPORT = 35,
  1504. WLAN_EID_SUPPORTED_CHANNELS = 36,
  1505. WLAN_EID_CHANNEL_SWITCH = 37,
  1506. WLAN_EID_MEASURE_REQUEST = 38,
  1507. WLAN_EID_MEASURE_REPORT = 39,
  1508. WLAN_EID_QUIET = 40,
  1509. WLAN_EID_IBSS_DFS = 41,
  1510. WLAN_EID_ERP_INFO = 42,
  1511. WLAN_EID_EXT_SUPP_RATES = 50,
  1512. WLAN_EID_HT_CAPABILITY = 45,
  1513. WLAN_EID_HT_OPERATION = 61,
  1514. WLAN_EID_SECONDARY_CHANNEL_OFFSET = 62,
  1515. WLAN_EID_RSN = 48,
  1516. WLAN_EID_MMIE = 76,
  1517. WLAN_EID_VENDOR_SPECIFIC = 221,
  1518. WLAN_EID_QOS_PARAMETER = 222,
  1519. WLAN_EID_AP_CHAN_REPORT = 51,
  1520. WLAN_EID_NEIGHBOR_REPORT = 52,
  1521. WLAN_EID_RCPI = 53,
  1522. WLAN_EID_BSS_AVG_ACCESS_DELAY = 63,
  1523. WLAN_EID_ANTENNA_INFO = 64,
  1524. WLAN_EID_RSNI = 65,
  1525. WLAN_EID_MEASUREMENT_PILOT_TX_INFO = 66,
  1526. WLAN_EID_BSS_AVAILABLE_CAPACITY = 67,
  1527. WLAN_EID_BSS_AC_ACCESS_DELAY = 68,
  1528. WLAN_EID_RRM_ENABLED_CAPABILITIES = 70,
  1529. WLAN_EID_MULTIPLE_BSSID = 71,
  1530. WLAN_EID_BSS_COEX_2040 = 72,
  1531. WLAN_EID_OVERLAP_BSS_SCAN_PARAM = 74,
  1532. WLAN_EID_EXT_CAPABILITY = 127,
  1533. WLAN_EID_MOBILITY_DOMAIN = 54,
  1534. WLAN_EID_FAST_BSS_TRANSITION = 55,
  1535. WLAN_EID_TIMEOUT_INTERVAL = 56,
  1536. WLAN_EID_RIC_DATA = 57,
  1537. WLAN_EID_RIC_DESCRIPTOR = 75,
  1538. WLAN_EID_DSE_REGISTERED_LOCATION = 58,
  1539. WLAN_EID_SUPPORTED_REGULATORY_CLASSES = 59,
  1540. WLAN_EID_EXT_CHANSWITCH_ANN = 60,
  1541. WLAN_EID_VHT_CAPABILITY = 191,
  1542. WLAN_EID_VHT_OPERATION = 192,
  1543. WLAN_EID_OPMODE_NOTIF = 199,
  1544. WLAN_EID_WIDE_BW_CHANNEL_SWITCH = 194,
  1545. WLAN_EID_CHANNEL_SWITCH_WRAPPER = 196,
  1546. WLAN_EID_EXTENDED_BSS_LOAD = 193,
  1547. WLAN_EID_VHT_TX_POWER_ENVELOPE = 195,
  1548. WLAN_EID_AID = 197,
  1549. WLAN_EID_QUIET_CHANNEL = 198,
  1550. /* 802.11ad */
  1551. WLAN_EID_NON_TX_BSSID_CAP = 83,
  1552. WLAN_EID_WAKEUP_SCHEDULE = 143,
  1553. WLAN_EID_EXT_SCHEDULE = 144,
  1554. WLAN_EID_STA_AVAILABILITY = 145,
  1555. WLAN_EID_DMG_TSPEC = 146,
  1556. WLAN_EID_DMG_AT = 147,
  1557. WLAN_EID_DMG_CAP = 148,
  1558. WLAN_EID_DMG_OPERATION = 151,
  1559. WLAN_EID_DMG_BSS_PARAM_CHANGE = 152,
  1560. WLAN_EID_DMG_BEAM_REFINEMENT = 153,
  1561. WLAN_EID_CHANNEL_MEASURE_FEEDBACK = 154,
  1562. WLAN_EID_AWAKE_WINDOW = 157,
  1563. WLAN_EID_MULTI_BAND = 158,
  1564. WLAN_EID_ADDBA_EXT = 159,
  1565. WLAN_EID_NEXT_PCP_LIST = 160,
  1566. WLAN_EID_PCP_HANDOVER = 161,
  1567. WLAN_EID_DMG_LINK_MARGIN = 162,
  1568. WLAN_EID_SWITCHING_STREAM = 163,
  1569. WLAN_EID_SESSION_TRANSITION = 164,
  1570. WLAN_EID_DYN_TONE_PAIRING_REPORT = 165,
  1571. WLAN_EID_CLUSTER_REPORT = 166,
  1572. WLAN_EID_RELAY_CAP = 167,
  1573. WLAN_EID_RELAY_XFER_PARAM_SET = 168,
  1574. WLAN_EID_BEAM_LINK_MAINT = 169,
  1575. WLAN_EID_MULTIPLE_MAC_ADDR = 170,
  1576. WLAN_EID_U_PID = 171,
  1577. WLAN_EID_DMG_LINK_ADAPT_ACK = 172,
  1578. WLAN_EID_QUIET_PERIOD_REQ = 175,
  1579. WLAN_EID_QUIET_PERIOD_RESP = 177,
  1580. WLAN_EID_EPAC_POLICY = 182,
  1581. WLAN_EID_CLISTER_TIME_OFF = 183,
  1582. WLAN_EID_ANTENNA_SECTOR_ID_PATTERN = 190,
  1583. };
  1584. /* Action category code */
  1585. enum ieee80211_category {
  1586. WLAN_CATEGORY_SPECTRUM_MGMT = 0,
  1587. WLAN_CATEGORY_QOS = 1,
  1588. WLAN_CATEGORY_DLS = 2,
  1589. WLAN_CATEGORY_BACK = 3,
  1590. WLAN_CATEGORY_PUBLIC = 4,
  1591. WLAN_CATEGORY_HT = 7,
  1592. WLAN_CATEGORY_SA_QUERY = 8,
  1593. WLAN_CATEGORY_PROTECTED_DUAL_OF_ACTION = 9,
  1594. WLAN_CATEGORY_TDLS = 12,
  1595. WLAN_CATEGORY_MESH_ACTION = 13,
  1596. WLAN_CATEGORY_MULTIHOP_ACTION = 14,
  1597. WLAN_CATEGORY_SELF_PROTECTED = 15,
  1598. WLAN_CATEGORY_DMG = 16,
  1599. WLAN_CATEGORY_WMM = 17,
  1600. WLAN_CATEGORY_FST = 18,
  1601. WLAN_CATEGORY_UNPROT_DMG = 20,
  1602. WLAN_CATEGORY_VHT = 21,
  1603. WLAN_CATEGORY_VENDOR_SPECIFIC_PROTECTED = 126,
  1604. WLAN_CATEGORY_VENDOR_SPECIFIC = 127,
  1605. };
  1606. /* SPECTRUM_MGMT action code */
  1607. enum ieee80211_spectrum_mgmt_actioncode {
  1608. WLAN_ACTION_SPCT_MSR_REQ = 0,
  1609. WLAN_ACTION_SPCT_MSR_RPRT = 1,
  1610. WLAN_ACTION_SPCT_TPC_REQ = 2,
  1611. WLAN_ACTION_SPCT_TPC_RPRT = 3,
  1612. WLAN_ACTION_SPCT_CHL_SWITCH = 4,
  1613. };
  1614. /* HT action codes */
  1615. enum ieee80211_ht_actioncode {
  1616. WLAN_HT_ACTION_NOTIFY_CHANWIDTH = 0,
  1617. WLAN_HT_ACTION_SMPS = 1,
  1618. WLAN_HT_ACTION_PSMP = 2,
  1619. WLAN_HT_ACTION_PCO_PHASE = 3,
  1620. WLAN_HT_ACTION_CSI = 4,
  1621. WLAN_HT_ACTION_NONCOMPRESSED_BF = 5,
  1622. WLAN_HT_ACTION_COMPRESSED_BF = 6,
  1623. WLAN_HT_ACTION_ASEL_IDX_FEEDBACK = 7,
  1624. };
  1625. /* VHT action codes */
  1626. enum ieee80211_vht_actioncode {
  1627. WLAN_VHT_ACTION_COMPRESSED_BF = 0,
  1628. WLAN_VHT_ACTION_GROUPID_MGMT = 1,
  1629. WLAN_VHT_ACTION_OPMODE_NOTIF = 2,
  1630. };
  1631. /* Self Protected Action codes */
  1632. enum ieee80211_self_protected_actioncode {
  1633. WLAN_SP_RESERVED = 0,
  1634. WLAN_SP_MESH_PEERING_OPEN = 1,
  1635. WLAN_SP_MESH_PEERING_CONFIRM = 2,
  1636. WLAN_SP_MESH_PEERING_CLOSE = 3,
  1637. WLAN_SP_MGK_INFORM = 4,
  1638. WLAN_SP_MGK_ACK = 5,
  1639. };
  1640. /* Mesh action codes */
  1641. enum ieee80211_mesh_actioncode {
  1642. WLAN_MESH_ACTION_LINK_METRIC_REPORT,
  1643. WLAN_MESH_ACTION_HWMP_PATH_SELECTION,
  1644. WLAN_MESH_ACTION_GATE_ANNOUNCEMENT,
  1645. WLAN_MESH_ACTION_CONGESTION_CONTROL_NOTIFICATION,
  1646. WLAN_MESH_ACTION_MCCA_SETUP_REQUEST,
  1647. WLAN_MESH_ACTION_MCCA_SETUP_REPLY,
  1648. WLAN_MESH_ACTION_MCCA_ADVERTISEMENT_REQUEST,
  1649. WLAN_MESH_ACTION_MCCA_ADVERTISEMENT,
  1650. WLAN_MESH_ACTION_MCCA_TEARDOWN,
  1651. WLAN_MESH_ACTION_TBTT_ADJUSTMENT_REQUEST,
  1652. WLAN_MESH_ACTION_TBTT_ADJUSTMENT_RESPONSE,
  1653. };
  1654. /* Security key length */
  1655. enum ieee80211_key_len {
  1656. WLAN_KEY_LEN_WEP40 = 5,
  1657. WLAN_KEY_LEN_WEP104 = 13,
  1658. WLAN_KEY_LEN_CCMP = 16,
  1659. WLAN_KEY_LEN_TKIP = 32,
  1660. WLAN_KEY_LEN_AES_CMAC = 16,
  1661. };
  1662. #define IEEE80211_WEP_IV_LEN 4
  1663. #define IEEE80211_WEP_ICV_LEN 4
  1664. #define IEEE80211_CCMP_HDR_LEN 8
  1665. #define IEEE80211_CCMP_MIC_LEN 8
  1666. #define IEEE80211_CCMP_PN_LEN 6
  1667. #define IEEE80211_TKIP_IV_LEN 8
  1668. #define IEEE80211_TKIP_ICV_LEN 4
  1669. #define IEEE80211_CMAC_PN_LEN 6
  1670. /* Public action codes */
  1671. enum ieee80211_pub_actioncode {
  1672. WLAN_PUB_ACTION_EXT_CHANSW_ANN = 4,
  1673. WLAN_PUB_ACTION_TDLS_DISCOVER_RES = 14,
  1674. };
  1675. /* TDLS action codes */
  1676. enum ieee80211_tdls_actioncode {
  1677. WLAN_TDLS_SETUP_REQUEST = 0,
  1678. WLAN_TDLS_SETUP_RESPONSE = 1,
  1679. WLAN_TDLS_SETUP_CONFIRM = 2,
  1680. WLAN_TDLS_TEARDOWN = 3,
  1681. WLAN_TDLS_PEER_TRAFFIC_INDICATION = 4,
  1682. WLAN_TDLS_CHANNEL_SWITCH_REQUEST = 5,
  1683. WLAN_TDLS_CHANNEL_SWITCH_RESPONSE = 6,
  1684. WLAN_TDLS_PEER_PSM_REQUEST = 7,
  1685. WLAN_TDLS_PEER_PSM_RESPONSE = 8,
  1686. WLAN_TDLS_PEER_TRAFFIC_RESPONSE = 9,
  1687. WLAN_TDLS_DISCOVERY_REQUEST = 10,
  1688. };
  1689. /* Interworking capabilities are set in 7th bit of 4th byte of the
  1690. * @WLAN_EID_EXT_CAPABILITY information element
  1691. */
  1692. #define WLAN_EXT_CAPA4_INTERWORKING_ENABLED BIT(7)
  1693. /*
  1694. * TDLS capabililites to be enabled in the 5th byte of the
  1695. * @WLAN_EID_EXT_CAPABILITY information element
  1696. */
  1697. #define WLAN_EXT_CAPA5_TDLS_ENABLED BIT(5)
  1698. #define WLAN_EXT_CAPA5_TDLS_PROHIBITED BIT(6)
  1699. #define WLAN_EXT_CAPA8_OPMODE_NOTIF BIT(6)
  1700. /* TDLS specific payload type in the LLC/SNAP header */
  1701. #define WLAN_TDLS_SNAP_RFTYPE 0x2
  1702. /**
  1703. * enum - mesh synchronization method identifier
  1704. *
  1705. * @IEEE80211_SYNC_METHOD_NEIGHBOR_OFFSET: the default synchronization method
  1706. * @IEEE80211_SYNC_METHOD_VENDOR: a vendor specific synchronization method
  1707. * that will be specified in a vendor specific information element
  1708. */
  1709. enum {
  1710. IEEE80211_SYNC_METHOD_NEIGHBOR_OFFSET = 1,
  1711. IEEE80211_SYNC_METHOD_VENDOR = 255,
  1712. };
  1713. /**
  1714. * enum - mesh path selection protocol identifier
  1715. *
  1716. * @IEEE80211_PATH_PROTOCOL_HWMP: the default path selection protocol
  1717. * @IEEE80211_PATH_PROTOCOL_VENDOR: a vendor specific protocol that will
  1718. * be specified in a vendor specific information element
  1719. */
  1720. enum {
  1721. IEEE80211_PATH_PROTOCOL_HWMP = 1,
  1722. IEEE80211_PATH_PROTOCOL_VENDOR = 255,
  1723. };
  1724. /**
  1725. * enum - mesh path selection metric identifier
  1726. *
  1727. * @IEEE80211_PATH_METRIC_AIRTIME: the default path selection metric
  1728. * @IEEE80211_PATH_METRIC_VENDOR: a vendor specific metric that will be
  1729. * specified in a vendor specific information element
  1730. */
  1731. enum {
  1732. IEEE80211_PATH_METRIC_AIRTIME = 1,
  1733. IEEE80211_PATH_METRIC_VENDOR = 255,
  1734. };
  1735. /**
  1736. * enum ieee80211_root_mode_identifier - root mesh STA mode identifier
  1737. *
  1738. * These attribute are used by dot11MeshHWMPRootMode to set root mesh STA mode
  1739. *
  1740. * @IEEE80211_ROOTMODE_NO_ROOT: the mesh STA is not a root mesh STA (default)
  1741. * @IEEE80211_ROOTMODE_ROOT: the mesh STA is a root mesh STA if greater than
  1742. * this value
  1743. * @IEEE80211_PROACTIVE_PREQ_NO_PREP: the mesh STA is a root mesh STA supports
  1744. * the proactive PREQ with proactive PREP subfield set to 0
  1745. * @IEEE80211_PROACTIVE_PREQ_WITH_PREP: the mesh STA is a root mesh STA
  1746. * supports the proactive PREQ with proactive PREP subfield set to 1
  1747. * @IEEE80211_PROACTIVE_RANN: the mesh STA is a root mesh STA supports
  1748. * the proactive RANN
  1749. */
  1750. enum ieee80211_root_mode_identifier {
  1751. IEEE80211_ROOTMODE_NO_ROOT = 0,
  1752. IEEE80211_ROOTMODE_ROOT = 1,
  1753. IEEE80211_PROACTIVE_PREQ_NO_PREP = 2,
  1754. IEEE80211_PROACTIVE_PREQ_WITH_PREP = 3,
  1755. IEEE80211_PROACTIVE_RANN = 4,
  1756. };
  1757. /*
  1758. * IEEE 802.11-2007 7.3.2.9 Country information element
  1759. *
  1760. * Minimum length is 8 octets, ie len must be evenly
  1761. * divisible by 2
  1762. */
  1763. /* Although the spec says 8 I'm seeing 6 in practice */
  1764. #define IEEE80211_COUNTRY_IE_MIN_LEN 6
  1765. /* The Country String field of the element shall be 3 octets in length */
  1766. #define IEEE80211_COUNTRY_STRING_LEN 3
  1767. /*
  1768. * For regulatory extension stuff see IEEE 802.11-2007
  1769. * Annex I (page 1141) and Annex J (page 1147). Also
  1770. * review 7.3.2.9.
  1771. *
  1772. * When dot11RegulatoryClassesRequired is true and the
  1773. * first_channel/reg_extension_id is >= 201 then the IE
  1774. * compromises of the 'ext' struct represented below:
  1775. *
  1776. * - Regulatory extension ID - when generating IE this just needs
  1777. * to be monotonically increasing for each triplet passed in
  1778. * the IE
  1779. * - Regulatory class - index into set of rules
  1780. * - Coverage class - index into air propagation time (Table 7-27),
  1781. * in microseconds, you can compute the air propagation time from
  1782. * the index by multiplying by 3, so index 10 yields a propagation
  1783. * of 10 us. Valid values are 0-31, values 32-255 are not defined
  1784. * yet. A value of 0 inicates air propagation of <= 1 us.
  1785. *
  1786. * See also Table I.2 for Emission limit sets and table
  1787. * I.3 for Behavior limit sets. Table J.1 indicates how to map
  1788. * a reg_class to an emission limit set and behavior limit set.
  1789. */
  1790. #define IEEE80211_COUNTRY_EXTENSION_ID 201
  1791. /*
  1792. * Channels numbers in the IE must be monotonically increasing
  1793. * if dot11RegulatoryClassesRequired is not true.
  1794. *
  1795. * If dot11RegulatoryClassesRequired is true consecutive
  1796. * subband triplets following a regulatory triplet shall
  1797. * have monotonically increasing first_channel number fields.
  1798. *
  1799. * Channel numbers shall not overlap.
  1800. *
  1801. * Note that max_power is signed.
  1802. */
  1803. struct ieee80211_country_ie_triplet {
  1804. union {
  1805. struct {
  1806. u8 first_channel;
  1807. u8 num_channels;
  1808. s8 max_power;
  1809. } __packed chans;
  1810. struct {
  1811. u8 reg_extension_id;
  1812. u8 reg_class;
  1813. u8 coverage_class;
  1814. } __packed ext;
  1815. };
  1816. } __packed;
  1817. enum ieee80211_timeout_interval_type {
  1818. WLAN_TIMEOUT_REASSOC_DEADLINE = 1 /* 802.11r */,
  1819. WLAN_TIMEOUT_KEY_LIFETIME = 2 /* 802.11r */,
  1820. WLAN_TIMEOUT_ASSOC_COMEBACK = 3 /* 802.11w */,
  1821. };
  1822. /**
  1823. * struct ieee80211_timeout_interval_ie - Timeout Interval element
  1824. * @type: type, see &enum ieee80211_timeout_interval_type
  1825. * @value: timeout interval value
  1826. */
  1827. struct ieee80211_timeout_interval_ie {
  1828. u8 type;
  1829. __le32 value;
  1830. } __packed;
  1831. /* BACK action code */
  1832. enum ieee80211_back_actioncode {
  1833. WLAN_ACTION_ADDBA_REQ = 0,
  1834. WLAN_ACTION_ADDBA_RESP = 1,
  1835. WLAN_ACTION_DELBA = 2,
  1836. };
  1837. /* BACK (block-ack) parties */
  1838. enum ieee80211_back_parties {
  1839. WLAN_BACK_RECIPIENT = 0,
  1840. WLAN_BACK_INITIATOR = 1,
  1841. };
  1842. /* SA Query action */
  1843. enum ieee80211_sa_query_action {
  1844. WLAN_ACTION_SA_QUERY_REQUEST = 0,
  1845. WLAN_ACTION_SA_QUERY_RESPONSE = 1,
  1846. };
  1847. /* cipher suite selectors */
  1848. #define WLAN_CIPHER_SUITE_USE_GROUP 0x000FAC00
  1849. #define WLAN_CIPHER_SUITE_WEP40 0x000FAC01
  1850. #define WLAN_CIPHER_SUITE_TKIP 0x000FAC02
  1851. /* reserved: 0x000FAC03 */
  1852. #define WLAN_CIPHER_SUITE_CCMP 0x000FAC04
  1853. #define WLAN_CIPHER_SUITE_WEP104 0x000FAC05
  1854. #define WLAN_CIPHER_SUITE_AES_CMAC 0x000FAC06
  1855. #define WLAN_CIPHER_SUITE_GCMP 0x000FAC08
  1856. #define WLAN_CIPHER_SUITE_SMS4 0x00147201
  1857. /* AKM suite selectors */
  1858. #define WLAN_AKM_SUITE_8021X 0x000FAC01
  1859. #define WLAN_AKM_SUITE_PSK 0x000FAC02
  1860. #define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05
  1861. #define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06
  1862. #define WLAN_AKM_SUITE_TDLS 0x000FAC07
  1863. #define WLAN_AKM_SUITE_SAE 0x000FAC08
  1864. #define WLAN_AKM_SUITE_FT_OVER_SAE 0x000FAC09
  1865. #define WLAN_MAX_KEY_LEN 32
  1866. #define WLAN_PMKID_LEN 16
  1867. #define WLAN_OUI_WFA 0x506f9a
  1868. #define WLAN_OUI_TYPE_WFA_P2P 9
  1869. #define WLAN_OUI_MICROSOFT 0x0050f2
  1870. #define WLAN_OUI_TYPE_MICROSOFT_WPA 1
  1871. #define WLAN_OUI_TYPE_MICROSOFT_WMM 2
  1872. #define WLAN_OUI_TYPE_MICROSOFT_WPS 4
  1873. /*
  1874. * WMM/802.11e Tspec Element
  1875. */
  1876. #define IEEE80211_WMM_IE_TSPEC_TID_MASK 0x0F
  1877. #define IEEE80211_WMM_IE_TSPEC_TID_SHIFT 1
  1878. enum ieee80211_tspec_status_code {
  1879. IEEE80211_TSPEC_STATUS_ADMISS_ACCEPTED = 0,
  1880. IEEE80211_TSPEC_STATUS_ADDTS_INVAL_PARAMS = 0x1,
  1881. };
  1882. struct ieee80211_tspec_ie {
  1883. u8 element_id;
  1884. u8 len;
  1885. u8 oui[3];
  1886. u8 oui_type;
  1887. u8 oui_subtype;
  1888. u8 version;
  1889. __le16 tsinfo;
  1890. u8 tsinfo_resvd;
  1891. __le16 nominal_msdu;
  1892. __le16 max_msdu;
  1893. __le32 min_service_int;
  1894. __le32 max_service_int;
  1895. __le32 inactivity_int;
  1896. __le32 suspension_int;
  1897. __le32 service_start_time;
  1898. __le32 min_data_rate;
  1899. __le32 mean_data_rate;
  1900. __le32 peak_data_rate;
  1901. __le32 max_burst_size;
  1902. __le32 delay_bound;
  1903. __le32 min_phy_rate;
  1904. __le16 sba;
  1905. __le16 medium_time;
  1906. } __packed;
  1907. /**
  1908. * ieee80211_get_qos_ctl - get pointer to qos control bytes
  1909. * @hdr: the frame
  1910. *
  1911. * The qos ctrl bytes come after the frame_control, duration, seq_num
  1912. * and 3 or 4 addresses of length ETH_ALEN.
  1913. * 3 addr: 2 + 2 + 2 + 3*6 = 24
  1914. * 4 addr: 2 + 2 + 2 + 4*6 = 30
  1915. */
  1916. static inline u8 *ieee80211_get_qos_ctl(struct ieee80211_hdr *hdr)
  1917. {
  1918. if (ieee80211_has_a4(hdr->frame_control))
  1919. return (u8 *)hdr + 30;
  1920. else
  1921. return (u8 *)hdr + 24;
  1922. }
  1923. /**
  1924. * ieee80211_get_SA - get pointer to SA
  1925. * @hdr: the frame
  1926. *
  1927. * Given an 802.11 frame, this function returns the offset
  1928. * to the source address (SA). It does not verify that the
  1929. * header is long enough to contain the address, and the
  1930. * header must be long enough to contain the frame control
  1931. * field.
  1932. */
  1933. static inline u8 *ieee80211_get_SA(struct ieee80211_hdr *hdr)
  1934. {
  1935. if (ieee80211_has_a4(hdr->frame_control))
  1936. return hdr->addr4;
  1937. if (ieee80211_has_fromds(hdr->frame_control))
  1938. return hdr->addr3;
  1939. return hdr->addr2;
  1940. }
  1941. /**
  1942. * ieee80211_get_DA - get pointer to DA
  1943. * @hdr: the frame
  1944. *
  1945. * Given an 802.11 frame, this function returns the offset
  1946. * to the destination address (DA). It does not verify that
  1947. * the 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_DA(struct ieee80211_hdr *hdr)
  1952. {
  1953. if (ieee80211_has_tods(hdr->frame_control))
  1954. return hdr->addr3;
  1955. else
  1956. return hdr->addr1;
  1957. }
  1958. /**
  1959. * ieee80211_is_robust_mgmt_frame - check if frame is a robust management frame
  1960. * @hdr: the frame (buffer must include at least the first octet of payload)
  1961. */
  1962. static inline bool ieee80211_is_robust_mgmt_frame(struct ieee80211_hdr *hdr)
  1963. {
  1964. if (ieee80211_is_disassoc(hdr->frame_control) ||
  1965. ieee80211_is_deauth(hdr->frame_control))
  1966. return true;
  1967. if (ieee80211_is_action(hdr->frame_control)) {
  1968. u8 *category;
  1969. /*
  1970. * Action frames, excluding Public Action frames, are Robust
  1971. * Management Frames. However, if we are looking at a Protected
  1972. * frame, skip the check since the data may be encrypted and
  1973. * the frame has already been found to be a Robust Management
  1974. * Frame (by the other end).
  1975. */
  1976. if (ieee80211_has_protected(hdr->frame_control))
  1977. return true;
  1978. category = ((u8 *) hdr) + 24;
  1979. return *category != WLAN_CATEGORY_PUBLIC &&
  1980. *category != WLAN_CATEGORY_HT &&
  1981. *category != WLAN_CATEGORY_SELF_PROTECTED &&
  1982. *category != WLAN_CATEGORY_VENDOR_SPECIFIC;
  1983. }
  1984. return false;
  1985. }
  1986. /**
  1987. * ieee80211_is_public_action - check if frame is a public action frame
  1988. * @hdr: the frame
  1989. * @len: length of the frame
  1990. */
  1991. static inline bool ieee80211_is_public_action(struct ieee80211_hdr *hdr,
  1992. size_t len)
  1993. {
  1994. struct ieee80211_mgmt *mgmt = (void *)hdr;
  1995. if (len < IEEE80211_MIN_ACTION_SIZE)
  1996. return false;
  1997. if (!ieee80211_is_action(hdr->frame_control))
  1998. return false;
  1999. return mgmt->u.action.category == WLAN_CATEGORY_PUBLIC;
  2000. }
  2001. /**
  2002. * ieee80211_dsss_chan_to_freq - get channel center frequency
  2003. * @channel: the DSSS channel
  2004. *
  2005. * Convert IEEE802.11 DSSS channel to the center frequency (MHz).
  2006. * Ref IEEE 802.11-2007 section 15.6
  2007. */
  2008. static inline int ieee80211_dsss_chan_to_freq(int channel)
  2009. {
  2010. if ((channel > 0) && (channel < 14))
  2011. return 2407 + (channel * 5);
  2012. else if (channel == 14)
  2013. return 2484;
  2014. else
  2015. return -1;
  2016. }
  2017. /**
  2018. * ieee80211_freq_to_dsss_chan - get channel
  2019. * @freq: the frequency
  2020. *
  2021. * Convert frequency (MHz) to IEEE802.11 DSSS channel
  2022. * Ref IEEE 802.11-2007 section 15.6
  2023. *
  2024. * This routine selects the channel with the closest center frequency.
  2025. */
  2026. static inline int ieee80211_freq_to_dsss_chan(int freq)
  2027. {
  2028. if ((freq >= 2410) && (freq < 2475))
  2029. return (freq - 2405) / 5;
  2030. else if ((freq >= 2482) && (freq < 2487))
  2031. return 14;
  2032. else
  2033. return -1;
  2034. }
  2035. /**
  2036. * ieee80211_tu_to_usec - convert time units (TU) to microseconds
  2037. * @tu: the TUs
  2038. */
  2039. static inline unsigned long ieee80211_tu_to_usec(unsigned long tu)
  2040. {
  2041. return 1024 * tu;
  2042. }
  2043. /**
  2044. * ieee80211_check_tim - check if AID bit is set in TIM
  2045. * @tim: the TIM IE
  2046. * @tim_len: length of the TIM IE
  2047. * @aid: the AID to look for
  2048. */
  2049. static inline bool ieee80211_check_tim(const struct ieee80211_tim_ie *tim,
  2050. u8 tim_len, u16 aid)
  2051. {
  2052. u8 mask;
  2053. u8 index, indexn1, indexn2;
  2054. if (unlikely(!tim || tim_len < sizeof(*tim)))
  2055. return false;
  2056. aid &= 0x3fff;
  2057. index = aid / 8;
  2058. mask = 1 << (aid & 7);
  2059. indexn1 = tim->bitmap_ctrl & 0xfe;
  2060. indexn2 = tim_len + indexn1 - 4;
  2061. if (index < indexn1 || index > indexn2)
  2062. return false;
  2063. index -= indexn1;
  2064. return !!(tim->virtual_map[index] & mask);
  2065. }
  2066. /* convert time units */
  2067. #define TU_TO_JIFFIES(x) (usecs_to_jiffies((x) * 1024))
  2068. #define TU_TO_EXP_TIME(x) (jiffies + TU_TO_JIFFIES(x))
  2069. #endif /* LINUX_IEEE80211_H */