ieee80211.h 65 KB

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