ieee80211.h 147 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * IEEE 802.11 defines
  4. *
  5. * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
  6. * <[email protected]>
  7. * Copyright (c) 2002-2003, Jouni Malinen <[email protected]>
  8. * Copyright (c) 2005, Devicescape Software, Inc.
  9. * Copyright (c) 2006, Michael Wu <[email protected]>
  10. * Copyright (c) 2013 - 2014 Intel Mobile Communications GmbH
  11. * Copyright (c) 2016 - 2017 Intel Deutschland GmbH
  12. * Copyright (c) 2018 - 2022 Intel Corporation
  13. */
  14. #ifndef LINUX_IEEE80211_H
  15. #define LINUX_IEEE80211_H
  16. #include <linux/types.h>
  17. #include <linux/if_ether.h>
  18. #include <linux/etherdevice.h>
  19. #include <linux/bitfield.h>
  20. #include <asm/byteorder.h>
  21. #include <asm/unaligned.h>
  22. /*
  23. * DS bit usage
  24. *
  25. * TA = transmitter address
  26. * RA = receiver address
  27. * DA = destination address
  28. * SA = source address
  29. *
  30. * ToDS FromDS A1(RA) A2(TA) A3 A4 Use
  31. * -----------------------------------------------------------------
  32. * 0 0 DA SA BSSID - IBSS/DLS
  33. * 0 1 DA BSSID SA - AP -> STA
  34. * 1 0 BSSID SA DA - AP <- STA
  35. * 1 1 RA TA DA SA unspecified (WDS)
  36. */
  37. #define FCS_LEN 4
  38. #define IEEE80211_FCTL_VERS 0x0003
  39. #define IEEE80211_FCTL_FTYPE 0x000c
  40. #define IEEE80211_FCTL_STYPE 0x00f0
  41. #define IEEE80211_FCTL_TODS 0x0100
  42. #define IEEE80211_FCTL_FROMDS 0x0200
  43. #define IEEE80211_FCTL_MOREFRAGS 0x0400
  44. #define IEEE80211_FCTL_RETRY 0x0800
  45. #define IEEE80211_FCTL_PM 0x1000
  46. #define IEEE80211_FCTL_MOREDATA 0x2000
  47. #define IEEE80211_FCTL_PROTECTED 0x4000
  48. #define IEEE80211_FCTL_ORDER 0x8000
  49. #define IEEE80211_FCTL_CTL_EXT 0x0f00
  50. #define IEEE80211_SCTL_FRAG 0x000F
  51. #define IEEE80211_SCTL_SEQ 0xFFF0
  52. #define IEEE80211_FTYPE_MGMT 0x0000
  53. #define IEEE80211_FTYPE_CTL 0x0004
  54. #define IEEE80211_FTYPE_DATA 0x0008
  55. #define IEEE80211_FTYPE_EXT 0x000c
  56. /* management */
  57. #define IEEE80211_STYPE_ASSOC_REQ 0x0000
  58. #define IEEE80211_STYPE_ASSOC_RESP 0x0010
  59. #define IEEE80211_STYPE_REASSOC_REQ 0x0020
  60. #define IEEE80211_STYPE_REASSOC_RESP 0x0030
  61. #define IEEE80211_STYPE_PROBE_REQ 0x0040
  62. #define IEEE80211_STYPE_PROBE_RESP 0x0050
  63. #define IEEE80211_STYPE_BEACON 0x0080
  64. #define IEEE80211_STYPE_ATIM 0x0090
  65. #define IEEE80211_STYPE_DISASSOC 0x00A0
  66. #define IEEE80211_STYPE_AUTH 0x00B0
  67. #define IEEE80211_STYPE_DEAUTH 0x00C0
  68. #define IEEE80211_STYPE_ACTION 0x00D0
  69. /* control */
  70. #define IEEE80211_STYPE_TRIGGER 0x0020
  71. #define IEEE80211_STYPE_CTL_EXT 0x0060
  72. #define IEEE80211_STYPE_BACK_REQ 0x0080
  73. #define IEEE80211_STYPE_BACK 0x0090
  74. #define IEEE80211_STYPE_PSPOLL 0x00A0
  75. #define IEEE80211_STYPE_RTS 0x00B0
  76. #define IEEE80211_STYPE_CTS 0x00C0
  77. #define IEEE80211_STYPE_ACK 0x00D0
  78. #define IEEE80211_STYPE_CFEND 0x00E0
  79. #define IEEE80211_STYPE_CFENDACK 0x00F0
  80. /* data */
  81. #define IEEE80211_STYPE_DATA 0x0000
  82. #define IEEE80211_STYPE_DATA_CFACK 0x0010
  83. #define IEEE80211_STYPE_DATA_CFPOLL 0x0020
  84. #define IEEE80211_STYPE_DATA_CFACKPOLL 0x0030
  85. #define IEEE80211_STYPE_NULLFUNC 0x0040
  86. #define IEEE80211_STYPE_CFACK 0x0050
  87. #define IEEE80211_STYPE_CFPOLL 0x0060
  88. #define IEEE80211_STYPE_CFACKPOLL 0x0070
  89. #define IEEE80211_STYPE_QOS_DATA 0x0080
  90. #define IEEE80211_STYPE_QOS_DATA_CFACK 0x0090
  91. #define IEEE80211_STYPE_QOS_DATA_CFPOLL 0x00A0
  92. #define IEEE80211_STYPE_QOS_DATA_CFACKPOLL 0x00B0
  93. #define IEEE80211_STYPE_QOS_NULLFUNC 0x00C0
  94. #define IEEE80211_STYPE_QOS_CFACK 0x00D0
  95. #define IEEE80211_STYPE_QOS_CFPOLL 0x00E0
  96. #define IEEE80211_STYPE_QOS_CFACKPOLL 0x00F0
  97. /* extension, added by 802.11ad */
  98. #define IEEE80211_STYPE_DMG_BEACON 0x0000
  99. #define IEEE80211_STYPE_S1G_BEACON 0x0010
  100. /* bits unique to S1G beacon */
  101. #define IEEE80211_S1G_BCN_NEXT_TBTT 0x100
  102. /* see 802.11ah-2016 9.9 NDP CMAC frames */
  103. #define IEEE80211_S1G_1MHZ_NDP_BITS 25
  104. #define IEEE80211_S1G_1MHZ_NDP_BYTES 4
  105. #define IEEE80211_S1G_2MHZ_NDP_BITS 37
  106. #define IEEE80211_S1G_2MHZ_NDP_BYTES 5
  107. #define IEEE80211_NDP_FTYPE_CTS 0
  108. #define IEEE80211_NDP_FTYPE_CF_END 0
  109. #define IEEE80211_NDP_FTYPE_PS_POLL 1
  110. #define IEEE80211_NDP_FTYPE_ACK 2
  111. #define IEEE80211_NDP_FTYPE_PS_POLL_ACK 3
  112. #define IEEE80211_NDP_FTYPE_BA 4
  113. #define IEEE80211_NDP_FTYPE_BF_REPORT_POLL 5
  114. #define IEEE80211_NDP_FTYPE_PAGING 6
  115. #define IEEE80211_NDP_FTYPE_PREQ 7
  116. #define SM64(f, v) ((((u64)v) << f##_S) & f)
  117. /* NDP CMAC frame fields */
  118. #define IEEE80211_NDP_FTYPE 0x0000000000000007
  119. #define IEEE80211_NDP_FTYPE_S 0x0000000000000000
  120. /* 1M Probe Request 11ah 9.9.3.1.1 */
  121. #define IEEE80211_NDP_1M_PREQ_ANO 0x0000000000000008
  122. #define IEEE80211_NDP_1M_PREQ_ANO_S 3
  123. #define IEEE80211_NDP_1M_PREQ_CSSID 0x00000000000FFFF0
  124. #define IEEE80211_NDP_1M_PREQ_CSSID_S 4
  125. #define IEEE80211_NDP_1M_PREQ_RTYPE 0x0000000000100000
  126. #define IEEE80211_NDP_1M_PREQ_RTYPE_S 20
  127. #define IEEE80211_NDP_1M_PREQ_RSV 0x0000000001E00000
  128. #define IEEE80211_NDP_1M_PREQ_RSV 0x0000000001E00000
  129. /* 2M Probe Request 11ah 9.9.3.1.2 */
  130. #define IEEE80211_NDP_2M_PREQ_ANO 0x0000000000000008
  131. #define IEEE80211_NDP_2M_PREQ_ANO_S 3
  132. #define IEEE80211_NDP_2M_PREQ_CSSID 0x0000000FFFFFFFF0
  133. #define IEEE80211_NDP_2M_PREQ_CSSID_S 4
  134. #define IEEE80211_NDP_2M_PREQ_RTYPE 0x0000001000000000
  135. #define IEEE80211_NDP_2M_PREQ_RTYPE_S 36
  136. #define IEEE80211_ANO_NETTYPE_WILD 15
  137. /* bits unique to S1G beacon */
  138. #define IEEE80211_S1G_BCN_NEXT_TBTT 0x100
  139. /* control extension - for IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTL_EXT */
  140. #define IEEE80211_CTL_EXT_POLL 0x2000
  141. #define IEEE80211_CTL_EXT_SPR 0x3000
  142. #define IEEE80211_CTL_EXT_GRANT 0x4000
  143. #define IEEE80211_CTL_EXT_DMG_CTS 0x5000
  144. #define IEEE80211_CTL_EXT_DMG_DTS 0x6000
  145. #define IEEE80211_CTL_EXT_SSW 0x8000
  146. #define IEEE80211_CTL_EXT_SSW_FBACK 0x9000
  147. #define IEEE80211_CTL_EXT_SSW_ACK 0xa000
  148. #define IEEE80211_SN_MASK ((IEEE80211_SCTL_SEQ) >> 4)
  149. #define IEEE80211_MAX_SN IEEE80211_SN_MASK
  150. #define IEEE80211_SN_MODULO (IEEE80211_MAX_SN + 1)
  151. /* PV1 Layout 11ah 9.8.3.1 */
  152. #define IEEE80211_PV1_FCTL_VERS 0x0003
  153. #define IEEE80211_PV1_FCTL_FTYPE 0x001c
  154. #define IEEE80211_PV1_FCTL_STYPE 0x00e0
  155. #define IEEE80211_PV1_FCTL_TODS 0x0100
  156. #define IEEE80211_PV1_FCTL_MOREFRAGS 0x0200
  157. #define IEEE80211_PV1_FCTL_PM 0x0400
  158. #define IEEE80211_PV1_FCTL_MOREDATA 0x0800
  159. #define IEEE80211_PV1_FCTL_PROTECTED 0x1000
  160. #define IEEE80211_PV1_FCTL_END_SP 0x2000
  161. #define IEEE80211_PV1_FCTL_RELAYED 0x4000
  162. #define IEEE80211_PV1_FCTL_ACK_POLICY 0x8000
  163. #define IEEE80211_PV1_FCTL_CTL_EXT 0x0f00
  164. static inline bool ieee80211_sn_less(u16 sn1, u16 sn2)
  165. {
  166. return ((sn1 - sn2) & IEEE80211_SN_MASK) > (IEEE80211_SN_MODULO >> 1);
  167. }
  168. static inline u16 ieee80211_sn_add(u16 sn1, u16 sn2)
  169. {
  170. return (sn1 + sn2) & IEEE80211_SN_MASK;
  171. }
  172. static inline u16 ieee80211_sn_inc(u16 sn)
  173. {
  174. return ieee80211_sn_add(sn, 1);
  175. }
  176. static inline u16 ieee80211_sn_sub(u16 sn1, u16 sn2)
  177. {
  178. return (sn1 - sn2) & IEEE80211_SN_MASK;
  179. }
  180. #define IEEE80211_SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
  181. #define IEEE80211_SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ)
  182. /* miscellaneous IEEE 802.11 constants */
  183. #define IEEE80211_MAX_FRAG_THRESHOLD 2352
  184. #define IEEE80211_MAX_RTS_THRESHOLD 2353
  185. #define IEEE80211_MAX_AID 2007
  186. #define IEEE80211_MAX_AID_S1G 8191
  187. #define IEEE80211_MAX_TIM_LEN 251
  188. #define IEEE80211_MAX_MESH_PEERINGS 63
  189. /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
  190. 6.2.1.1.2.
  191. 802.11e clarifies the figure in section 7.1.2. The frame body is
  192. up to 2304 octets long (maximum MSDU size) plus any crypt overhead. */
  193. #define IEEE80211_MAX_DATA_LEN 2304
  194. /* 802.11ad extends maximum MSDU size for DMG (freq > 40Ghz) networks
  195. * to 7920 bytes, see 8.2.3 General frame format
  196. */
  197. #define IEEE80211_MAX_DATA_LEN_DMG 7920
  198. /* 30 byte 4 addr hdr, 2 byte QoS, 2304 byte MSDU, 12 byte crypt, 4 byte FCS */
  199. #define IEEE80211_MAX_FRAME_LEN 2352
  200. /* Maximal size of an A-MSDU that can be transported in a HT BA session */
  201. #define IEEE80211_MAX_MPDU_LEN_HT_BA 4095
  202. /* Maximal size of an A-MSDU */
  203. #define IEEE80211_MAX_MPDU_LEN_HT_3839 3839
  204. #define IEEE80211_MAX_MPDU_LEN_HT_7935 7935
  205. #define IEEE80211_MAX_MPDU_LEN_VHT_3895 3895
  206. #define IEEE80211_MAX_MPDU_LEN_VHT_7991 7991
  207. #define IEEE80211_MAX_MPDU_LEN_VHT_11454 11454
  208. #define IEEE80211_MAX_SSID_LEN 32
  209. #define IEEE80211_MAX_MESH_ID_LEN 32
  210. #define IEEE80211_FIRST_TSPEC_TSID 8
  211. #define IEEE80211_NUM_TIDS 16
  212. /* number of user priorities 802.11 uses */
  213. #define IEEE80211_NUM_UPS 8
  214. /* number of ACs */
  215. #define IEEE80211_NUM_ACS 4
  216. #define IEEE80211_QOS_CTL_LEN 2
  217. /* 1d tag mask */
  218. #define IEEE80211_QOS_CTL_TAG1D_MASK 0x0007
  219. /* TID mask */
  220. #define IEEE80211_QOS_CTL_TID_MASK 0x000f
  221. /* EOSP */
  222. #define IEEE80211_QOS_CTL_EOSP 0x0010
  223. /* ACK policy */
  224. #define IEEE80211_QOS_CTL_ACK_POLICY_NORMAL 0x0000
  225. #define IEEE80211_QOS_CTL_ACK_POLICY_NOACK 0x0020
  226. #define IEEE80211_QOS_CTL_ACK_POLICY_NO_EXPL 0x0040
  227. #define IEEE80211_QOS_CTL_ACK_POLICY_BLOCKACK 0x0060
  228. #define IEEE80211_QOS_CTL_ACK_POLICY_MASK 0x0060
  229. /* A-MSDU 802.11n */
  230. #define IEEE80211_QOS_CTL_A_MSDU_PRESENT 0x0080
  231. /* Mesh Control 802.11s */
  232. #define IEEE80211_QOS_CTL_MESH_CONTROL_PRESENT 0x0100
  233. /* Mesh Power Save Level */
  234. #define IEEE80211_QOS_CTL_MESH_PS_LEVEL 0x0200
  235. /* Mesh Receiver Service Period Initiated */
  236. #define IEEE80211_QOS_CTL_RSPI 0x0400
  237. /* U-APSD queue for WMM IEs sent by AP */
  238. #define IEEE80211_WMM_IE_AP_QOSINFO_UAPSD (1<<7)
  239. #define IEEE80211_WMM_IE_AP_QOSINFO_PARAM_SET_CNT_MASK 0x0f
  240. /* U-APSD queues for WMM IEs sent by STA */
  241. #define IEEE80211_WMM_IE_STA_QOSINFO_AC_VO (1<<0)
  242. #define IEEE80211_WMM_IE_STA_QOSINFO_AC_VI (1<<1)
  243. #define IEEE80211_WMM_IE_STA_QOSINFO_AC_BK (1<<2)
  244. #define IEEE80211_WMM_IE_STA_QOSINFO_AC_BE (1<<3)
  245. #define IEEE80211_WMM_IE_STA_QOSINFO_AC_MASK 0x0f
  246. /* U-APSD max SP length for WMM IEs sent by STA */
  247. #define IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL 0x00
  248. #define IEEE80211_WMM_IE_STA_QOSINFO_SP_2 0x01
  249. #define IEEE80211_WMM_IE_STA_QOSINFO_SP_4 0x02
  250. #define IEEE80211_WMM_IE_STA_QOSINFO_SP_6 0x03
  251. #define IEEE80211_WMM_IE_STA_QOSINFO_SP_MASK 0x03
  252. #define IEEE80211_WMM_IE_STA_QOSINFO_SP_SHIFT 5
  253. #define IEEE80211_HT_CTL_LEN 4
  254. /* trigger type within common_info of trigger frame */
  255. #define IEEE80211_TRIGGER_TYPE_MASK 0xf
  256. #define IEEE80211_TRIGGER_TYPE_BASIC 0x0
  257. #define IEEE80211_TRIGGER_TYPE_BFRP 0x1
  258. #define IEEE80211_TRIGGER_TYPE_MU_BAR 0x2
  259. #define IEEE80211_TRIGGER_TYPE_MU_RTS 0x3
  260. #define IEEE80211_TRIGGER_TYPE_BSRP 0x4
  261. #define IEEE80211_TRIGGER_TYPE_GCR_MU_BAR 0x5
  262. #define IEEE80211_TRIGGER_TYPE_BQRP 0x6
  263. #define IEEE80211_TRIGGER_TYPE_NFRP 0x7
  264. struct ieee80211_hdr {
  265. __le16 frame_control;
  266. __le16 duration_id;
  267. struct_group(addrs,
  268. u8 addr1[ETH_ALEN];
  269. u8 addr2[ETH_ALEN];
  270. u8 addr3[ETH_ALEN];
  271. );
  272. __le16 seq_ctrl;
  273. u8 addr4[ETH_ALEN];
  274. } __packed __aligned(2);
  275. struct ieee80211_hdr_3addr {
  276. __le16 frame_control;
  277. __le16 duration_id;
  278. u8 addr1[ETH_ALEN];
  279. u8 addr2[ETH_ALEN];
  280. u8 addr3[ETH_ALEN];
  281. __le16 seq_ctrl;
  282. } __packed __aligned(2);
  283. struct ieee80211_qos_hdr {
  284. __le16 frame_control;
  285. __le16 duration_id;
  286. u8 addr1[ETH_ALEN];
  287. u8 addr2[ETH_ALEN];
  288. u8 addr3[ETH_ALEN];
  289. __le16 seq_ctrl;
  290. __le16 qos_ctrl;
  291. } __packed __aligned(2);
  292. struct ieee80211_trigger {
  293. __le16 frame_control;
  294. __le16 duration;
  295. u8 ra[ETH_ALEN];
  296. u8 ta[ETH_ALEN];
  297. __le64 common_info;
  298. u8 variable[];
  299. } __packed __aligned(2);
  300. /**
  301. * ieee80211_has_tods - check if IEEE80211_FCTL_TODS is set
  302. * @fc: frame control bytes in little-endian byteorder
  303. */
  304. static inline bool ieee80211_has_tods(__le16 fc)
  305. {
  306. return (fc & cpu_to_le16(IEEE80211_FCTL_TODS)) != 0;
  307. }
  308. /**
  309. * ieee80211_has_fromds - check if IEEE80211_FCTL_FROMDS is set
  310. * @fc: frame control bytes in little-endian byteorder
  311. */
  312. static inline bool ieee80211_has_fromds(__le16 fc)
  313. {
  314. return (fc & cpu_to_le16(IEEE80211_FCTL_FROMDS)) != 0;
  315. }
  316. /**
  317. * ieee80211_has_a4 - check if IEEE80211_FCTL_TODS and IEEE80211_FCTL_FROMDS are set
  318. * @fc: frame control bytes in little-endian byteorder
  319. */
  320. static inline bool ieee80211_has_a4(__le16 fc)
  321. {
  322. __le16 tmp = cpu_to_le16(IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS);
  323. return (fc & tmp) == tmp;
  324. }
  325. /**
  326. * ieee80211_has_morefrags - check if IEEE80211_FCTL_MOREFRAGS is set
  327. * @fc: frame control bytes in little-endian byteorder
  328. */
  329. static inline bool ieee80211_has_morefrags(__le16 fc)
  330. {
  331. return (fc & cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)) != 0;
  332. }
  333. /**
  334. * ieee80211_has_retry - check if IEEE80211_FCTL_RETRY is set
  335. * @fc: frame control bytes in little-endian byteorder
  336. */
  337. static inline bool ieee80211_has_retry(__le16 fc)
  338. {
  339. return (fc & cpu_to_le16(IEEE80211_FCTL_RETRY)) != 0;
  340. }
  341. /**
  342. * ieee80211_has_pm - check if IEEE80211_FCTL_PM is set
  343. * @fc: frame control bytes in little-endian byteorder
  344. */
  345. static inline bool ieee80211_has_pm(__le16 fc)
  346. {
  347. return (fc & cpu_to_le16(IEEE80211_FCTL_PM)) != 0;
  348. }
  349. /**
  350. * ieee80211_has_moredata - check if IEEE80211_FCTL_MOREDATA is set
  351. * @fc: frame control bytes in little-endian byteorder
  352. */
  353. static inline bool ieee80211_has_moredata(__le16 fc)
  354. {
  355. return (fc & cpu_to_le16(IEEE80211_FCTL_MOREDATA)) != 0;
  356. }
  357. /**
  358. * ieee80211_has_protected - check if IEEE80211_FCTL_PROTECTED is set
  359. * @fc: frame control bytes in little-endian byteorder
  360. */
  361. static inline bool ieee80211_has_protected(__le16 fc)
  362. {
  363. return (fc & cpu_to_le16(IEEE80211_FCTL_PROTECTED)) != 0;
  364. }
  365. /**
  366. * ieee80211_has_order - check if IEEE80211_FCTL_ORDER is set
  367. * @fc: frame control bytes in little-endian byteorder
  368. */
  369. static inline bool ieee80211_has_order(__le16 fc)
  370. {
  371. return (fc & cpu_to_le16(IEEE80211_FCTL_ORDER)) != 0;
  372. }
  373. /**
  374. * ieee80211_is_mgmt - check if type is IEEE80211_FTYPE_MGMT
  375. * @fc: frame control bytes in little-endian byteorder
  376. */
  377. static inline bool ieee80211_is_mgmt(__le16 fc)
  378. {
  379. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
  380. cpu_to_le16(IEEE80211_FTYPE_MGMT);
  381. }
  382. /**
  383. * ieee80211_is_ctl - check if type is IEEE80211_FTYPE_CTL
  384. * @fc: frame control bytes in little-endian byteorder
  385. */
  386. static inline bool ieee80211_is_ctl(__le16 fc)
  387. {
  388. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
  389. cpu_to_le16(IEEE80211_FTYPE_CTL);
  390. }
  391. /**
  392. * ieee80211_is_data - check if type is IEEE80211_FTYPE_DATA
  393. * @fc: frame control bytes in little-endian byteorder
  394. */
  395. static inline bool ieee80211_is_data(__le16 fc)
  396. {
  397. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
  398. cpu_to_le16(IEEE80211_FTYPE_DATA);
  399. }
  400. /**
  401. * ieee80211_is_ext - check if type is IEEE80211_FTYPE_EXT
  402. * @fc: frame control bytes in little-endian byteorder
  403. */
  404. static inline bool ieee80211_is_ext(__le16 fc)
  405. {
  406. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
  407. cpu_to_le16(IEEE80211_FTYPE_EXT);
  408. }
  409. /**
  410. * ieee80211_is_data_qos - check if type is IEEE80211_FTYPE_DATA and IEEE80211_STYPE_QOS_DATA is set
  411. * @fc: frame control bytes in little-endian byteorder
  412. */
  413. static inline bool ieee80211_is_data_qos(__le16 fc)
  414. {
  415. /*
  416. * mask with QOS_DATA rather than IEEE80211_FCTL_STYPE as we just need
  417. * to check the one bit
  418. */
  419. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_STYPE_QOS_DATA)) ==
  420. cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_DATA);
  421. }
  422. /**
  423. * ieee80211_is_data_present - check if type is IEEE80211_FTYPE_DATA and has data
  424. * @fc: frame control bytes in little-endian byteorder
  425. */
  426. static inline bool ieee80211_is_data_present(__le16 fc)
  427. {
  428. /*
  429. * mask with 0x40 and test that that bit is clear to only return true
  430. * for the data-containing substypes.
  431. */
  432. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | 0x40)) ==
  433. cpu_to_le16(IEEE80211_FTYPE_DATA);
  434. }
  435. /**
  436. * ieee80211_is_assoc_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ASSOC_REQ
  437. * @fc: frame control bytes in little-endian byteorder
  438. */
  439. static inline bool ieee80211_is_assoc_req(__le16 fc)
  440. {
  441. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  442. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ASSOC_REQ);
  443. }
  444. /**
  445. * ieee80211_is_assoc_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ASSOC_RESP
  446. * @fc: frame control bytes in little-endian byteorder
  447. */
  448. static inline bool ieee80211_is_assoc_resp(__le16 fc)
  449. {
  450. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  451. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ASSOC_RESP);
  452. }
  453. /**
  454. * ieee80211_is_reassoc_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_REASSOC_REQ
  455. * @fc: frame control bytes in little-endian byteorder
  456. */
  457. static inline bool ieee80211_is_reassoc_req(__le16 fc)
  458. {
  459. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  460. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_REASSOC_REQ);
  461. }
  462. /**
  463. * ieee80211_is_reassoc_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_REASSOC_RESP
  464. * @fc: frame control bytes in little-endian byteorder
  465. */
  466. static inline bool ieee80211_is_reassoc_resp(__le16 fc)
  467. {
  468. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  469. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_REASSOC_RESP);
  470. }
  471. /**
  472. * ieee80211_is_probe_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_PROBE_REQ
  473. * @fc: frame control bytes in little-endian byteorder
  474. */
  475. static inline bool ieee80211_is_probe_req(__le16 fc)
  476. {
  477. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  478. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ);
  479. }
  480. /**
  481. * ieee80211_is_probe_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_PROBE_RESP
  482. * @fc: frame control bytes in little-endian byteorder
  483. */
  484. static inline bool ieee80211_is_probe_resp(__le16 fc)
  485. {
  486. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  487. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
  488. }
  489. /**
  490. * ieee80211_is_beacon - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_BEACON
  491. * @fc: frame control bytes in little-endian byteorder
  492. */
  493. static inline bool ieee80211_is_beacon(__le16 fc)
  494. {
  495. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  496. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
  497. }
  498. /**
  499. * ieee80211_is_s1g_beacon - check if IEEE80211_FTYPE_EXT &&
  500. * IEEE80211_STYPE_S1G_BEACON
  501. * @fc: frame control bytes in little-endian byteorder
  502. */
  503. static inline bool ieee80211_is_s1g_beacon(__le16 fc)
  504. {
  505. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE |
  506. IEEE80211_FCTL_STYPE)) ==
  507. cpu_to_le16(IEEE80211_FTYPE_EXT | IEEE80211_STYPE_S1G_BEACON);
  508. }
  509. /**
  510. * ieee80211_next_tbtt_present - check if IEEE80211_FTYPE_EXT &&
  511. * IEEE80211_STYPE_S1G_BEACON && IEEE80211_S1G_BCN_NEXT_TBTT
  512. * @fc: frame control bytes in little-endian byteorder
  513. */
  514. static inline bool ieee80211_next_tbtt_present(__le16 fc)
  515. {
  516. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  517. cpu_to_le16(IEEE80211_FTYPE_EXT | IEEE80211_STYPE_S1G_BEACON) &&
  518. fc & cpu_to_le16(IEEE80211_S1G_BCN_NEXT_TBTT);
  519. }
  520. /**
  521. * ieee80211_is_s1g_short_beacon - check if next tbtt present bit is set. Only
  522. * true for S1G beacons when they're short.
  523. * @fc: frame control bytes in little-endian byteorder
  524. */
  525. static inline bool ieee80211_is_s1g_short_beacon(__le16 fc)
  526. {
  527. return ieee80211_is_s1g_beacon(fc) && ieee80211_next_tbtt_present(fc);
  528. }
  529. /**
  530. * ieee80211_is_atim - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ATIM
  531. * @fc: frame control bytes in little-endian byteorder
  532. */
  533. static inline bool ieee80211_is_atim(__le16 fc)
  534. {
  535. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  536. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ATIM);
  537. }
  538. /**
  539. * ieee80211_is_disassoc - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_DISASSOC
  540. * @fc: frame control bytes in little-endian byteorder
  541. */
  542. static inline bool ieee80211_is_disassoc(__le16 fc)
  543. {
  544. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  545. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DISASSOC);
  546. }
  547. /**
  548. * ieee80211_is_auth - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_AUTH
  549. * @fc: frame control bytes in little-endian byteorder
  550. */
  551. static inline bool ieee80211_is_auth(__le16 fc)
  552. {
  553. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  554. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH);
  555. }
  556. /**
  557. * ieee80211_is_deauth - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_DEAUTH
  558. * @fc: frame control bytes in little-endian byteorder
  559. */
  560. static inline bool ieee80211_is_deauth(__le16 fc)
  561. {
  562. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  563. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DEAUTH);
  564. }
  565. /**
  566. * ieee80211_is_action - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ACTION
  567. * @fc: frame control bytes in little-endian byteorder
  568. */
  569. static inline bool ieee80211_is_action(__le16 fc)
  570. {
  571. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  572. cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ACTION);
  573. }
  574. /**
  575. * ieee80211_is_back_req - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_BACK_REQ
  576. * @fc: frame control bytes in little-endian byteorder
  577. */
  578. static inline bool ieee80211_is_back_req(__le16 fc)
  579. {
  580. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  581. cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_BACK_REQ);
  582. }
  583. /**
  584. * ieee80211_is_back - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_BACK
  585. * @fc: frame control bytes in little-endian byteorder
  586. */
  587. static inline bool ieee80211_is_back(__le16 fc)
  588. {
  589. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  590. cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_BACK);
  591. }
  592. /**
  593. * ieee80211_is_pspoll - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_PSPOLL
  594. * @fc: frame control bytes in little-endian byteorder
  595. */
  596. static inline bool ieee80211_is_pspoll(__le16 fc)
  597. {
  598. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  599. cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL);
  600. }
  601. /**
  602. * ieee80211_is_rts - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_RTS
  603. * @fc: frame control bytes in little-endian byteorder
  604. */
  605. static inline bool ieee80211_is_rts(__le16 fc)
  606. {
  607. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  608. cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS);
  609. }
  610. /**
  611. * ieee80211_is_cts - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CTS
  612. * @fc: frame control bytes in little-endian byteorder
  613. */
  614. static inline bool ieee80211_is_cts(__le16 fc)
  615. {
  616. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  617. cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS);
  618. }
  619. /**
  620. * ieee80211_is_ack - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_ACK
  621. * @fc: frame control bytes in little-endian byteorder
  622. */
  623. static inline bool ieee80211_is_ack(__le16 fc)
  624. {
  625. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  626. cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_ACK);
  627. }
  628. /**
  629. * ieee80211_is_cfend - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CFEND
  630. * @fc: frame control bytes in little-endian byteorder
  631. */
  632. static inline bool ieee80211_is_cfend(__le16 fc)
  633. {
  634. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  635. cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CFEND);
  636. }
  637. /**
  638. * ieee80211_is_cfendack - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CFENDACK
  639. * @fc: frame control bytes in little-endian byteorder
  640. */
  641. static inline bool ieee80211_is_cfendack(__le16 fc)
  642. {
  643. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  644. cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CFENDACK);
  645. }
  646. /**
  647. * ieee80211_is_nullfunc - check if frame is a regular (non-QoS) nullfunc frame
  648. * @fc: frame control bytes in little-endian byteorder
  649. */
  650. static inline bool ieee80211_is_nullfunc(__le16 fc)
  651. {
  652. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  653. cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC);
  654. }
  655. /**
  656. * ieee80211_is_qos_nullfunc - check if frame is a QoS nullfunc frame
  657. * @fc: frame control bytes in little-endian byteorder
  658. */
  659. static inline bool ieee80211_is_qos_nullfunc(__le16 fc)
  660. {
  661. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  662. cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_NULLFUNC);
  663. }
  664. /**
  665. * ieee80211_is_trigger - check if frame is trigger frame
  666. * @fc: frame control field in little-endian byteorder
  667. */
  668. static inline bool ieee80211_is_trigger(__le16 fc)
  669. {
  670. return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
  671. cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_TRIGGER);
  672. }
  673. /**
  674. * ieee80211_is_any_nullfunc - check if frame is regular or QoS nullfunc frame
  675. * @fc: frame control bytes in little-endian byteorder
  676. */
  677. static inline bool ieee80211_is_any_nullfunc(__le16 fc)
  678. {
  679. return (ieee80211_is_nullfunc(fc) || ieee80211_is_qos_nullfunc(fc));
  680. }
  681. /**
  682. * ieee80211_is_bufferable_mmpdu - check if frame is bufferable MMPDU
  683. * @fc: frame control field in little-endian byteorder
  684. */
  685. static inline bool ieee80211_is_bufferable_mmpdu(__le16 fc)
  686. {
  687. /* IEEE 802.11-2012, definition of "bufferable management frame";
  688. * note that this ignores the IBSS special case. */
  689. return ieee80211_is_mgmt(fc) &&
  690. (ieee80211_is_action(fc) ||
  691. ieee80211_is_disassoc(fc) ||
  692. ieee80211_is_deauth(fc));
  693. }
  694. /**
  695. * ieee80211_is_first_frag - check if IEEE80211_SCTL_FRAG is not set
  696. * @seq_ctrl: frame sequence control bytes in little-endian byteorder
  697. */
  698. static inline bool ieee80211_is_first_frag(__le16 seq_ctrl)
  699. {
  700. return (seq_ctrl & cpu_to_le16(IEEE80211_SCTL_FRAG)) == 0;
  701. }
  702. /**
  703. * ieee80211_is_frag - check if a frame is a fragment
  704. * @hdr: 802.11 header of the frame
  705. */
  706. static inline bool ieee80211_is_frag(struct ieee80211_hdr *hdr)
  707. {
  708. return ieee80211_has_morefrags(hdr->frame_control) ||
  709. hdr->seq_ctrl & cpu_to_le16(IEEE80211_SCTL_FRAG);
  710. }
  711. struct ieee80211s_hdr {
  712. u8 flags;
  713. u8 ttl;
  714. __le32 seqnum;
  715. u8 eaddr1[ETH_ALEN];
  716. u8 eaddr2[ETH_ALEN];
  717. } __packed __aligned(2);
  718. /* Mesh flags */
  719. #define MESH_FLAGS_AE_A4 0x1
  720. #define MESH_FLAGS_AE_A5_A6 0x2
  721. #define MESH_FLAGS_AE 0x3
  722. #define MESH_FLAGS_PS_DEEP 0x4
  723. /**
  724. * enum ieee80211_preq_flags - mesh PREQ element flags
  725. *
  726. * @IEEE80211_PREQ_PROACTIVE_PREP_FLAG: proactive PREP subfield
  727. */
  728. enum ieee80211_preq_flags {
  729. IEEE80211_PREQ_PROACTIVE_PREP_FLAG = 1<<2,
  730. };
  731. /**
  732. * enum ieee80211_preq_target_flags - mesh PREQ element per target flags
  733. *
  734. * @IEEE80211_PREQ_TO_FLAG: target only subfield
  735. * @IEEE80211_PREQ_USN_FLAG: unknown target HWMP sequence number subfield
  736. */
  737. enum ieee80211_preq_target_flags {
  738. IEEE80211_PREQ_TO_FLAG = 1<<0,
  739. IEEE80211_PREQ_USN_FLAG = 1<<2,
  740. };
  741. /**
  742. * struct ieee80211_quiet_ie
  743. *
  744. * This structure refers to "Quiet information element"
  745. */
  746. struct ieee80211_quiet_ie {
  747. u8 count;
  748. u8 period;
  749. __le16 duration;
  750. __le16 offset;
  751. } __packed;
  752. /**
  753. * struct ieee80211_msrment_ie
  754. *
  755. * This structure refers to "Measurement Request/Report information element"
  756. */
  757. struct ieee80211_msrment_ie {
  758. u8 token;
  759. u8 mode;
  760. u8 type;
  761. u8 request[];
  762. } __packed;
  763. /**
  764. * struct ieee80211_channel_sw_ie
  765. *
  766. * This structure refers to "Channel Switch Announcement information element"
  767. */
  768. struct ieee80211_channel_sw_ie {
  769. u8 mode;
  770. u8 new_ch_num;
  771. u8 count;
  772. } __packed;
  773. /**
  774. * struct ieee80211_ext_chansw_ie
  775. *
  776. * This structure represents the "Extended Channel Switch Announcement element"
  777. */
  778. struct ieee80211_ext_chansw_ie {
  779. u8 mode;
  780. u8 new_operating_class;
  781. u8 new_ch_num;
  782. u8 count;
  783. } __packed;
  784. /**
  785. * struct ieee80211_sec_chan_offs_ie - secondary channel offset IE
  786. * @sec_chan_offs: secondary channel offset, uses IEEE80211_HT_PARAM_CHA_SEC_*
  787. * values here
  788. * This structure represents the "Secondary Channel Offset element"
  789. */
  790. struct ieee80211_sec_chan_offs_ie {
  791. u8 sec_chan_offs;
  792. } __packed;
  793. /**
  794. * struct ieee80211_mesh_chansw_params_ie - mesh channel switch parameters IE
  795. *
  796. * This structure represents the "Mesh Channel Switch Paramters element"
  797. */
  798. struct ieee80211_mesh_chansw_params_ie {
  799. u8 mesh_ttl;
  800. u8 mesh_flags;
  801. __le16 mesh_reason;
  802. __le16 mesh_pre_value;
  803. } __packed;
  804. /**
  805. * struct ieee80211_wide_bw_chansw_ie - wide bandwidth channel switch IE
  806. */
  807. struct ieee80211_wide_bw_chansw_ie {
  808. u8 new_channel_width;
  809. u8 new_center_freq_seg0, new_center_freq_seg1;
  810. } __packed;
  811. /**
  812. * struct ieee80211_tim
  813. *
  814. * This structure refers to "Traffic Indication Map information element"
  815. */
  816. struct ieee80211_tim_ie {
  817. u8 dtim_count;
  818. u8 dtim_period;
  819. u8 bitmap_ctrl;
  820. /* variable size: 1 - 251 bytes */
  821. u8 virtual_map[1];
  822. } __packed;
  823. /**
  824. * struct ieee80211_meshconf_ie
  825. *
  826. * This structure refers to "Mesh Configuration information element"
  827. */
  828. struct ieee80211_meshconf_ie {
  829. u8 meshconf_psel;
  830. u8 meshconf_pmetric;
  831. u8 meshconf_congest;
  832. u8 meshconf_synch;
  833. u8 meshconf_auth;
  834. u8 meshconf_form;
  835. u8 meshconf_cap;
  836. } __packed;
  837. /**
  838. * enum mesh_config_capab_flags - Mesh Configuration IE capability field flags
  839. *
  840. * @IEEE80211_MESHCONF_CAPAB_ACCEPT_PLINKS: STA is willing to establish
  841. * additional mesh peerings with other mesh STAs
  842. * @IEEE80211_MESHCONF_CAPAB_FORWARDING: the STA forwards MSDUs
  843. * @IEEE80211_MESHCONF_CAPAB_TBTT_ADJUSTING: TBTT adjustment procedure
  844. * is ongoing
  845. * @IEEE80211_MESHCONF_CAPAB_POWER_SAVE_LEVEL: STA is in deep sleep mode or has
  846. * neighbors in deep sleep mode
  847. */
  848. enum mesh_config_capab_flags {
  849. IEEE80211_MESHCONF_CAPAB_ACCEPT_PLINKS = 0x01,
  850. IEEE80211_MESHCONF_CAPAB_FORWARDING = 0x08,
  851. IEEE80211_MESHCONF_CAPAB_TBTT_ADJUSTING = 0x20,
  852. IEEE80211_MESHCONF_CAPAB_POWER_SAVE_LEVEL = 0x40,
  853. };
  854. #define IEEE80211_MESHCONF_FORM_CONNECTED_TO_GATE 0x1
  855. /**
  856. * mesh channel switch parameters element's flag indicator
  857. *
  858. */
  859. #define WLAN_EID_CHAN_SWITCH_PARAM_TX_RESTRICT BIT(0)
  860. #define WLAN_EID_CHAN_SWITCH_PARAM_INITIATOR BIT(1)
  861. #define WLAN_EID_CHAN_SWITCH_PARAM_REASON BIT(2)
  862. /**
  863. * struct ieee80211_rann_ie
  864. *
  865. * This structure refers to "Root Announcement information element"
  866. */
  867. struct ieee80211_rann_ie {
  868. u8 rann_flags;
  869. u8 rann_hopcount;
  870. u8 rann_ttl;
  871. u8 rann_addr[ETH_ALEN];
  872. __le32 rann_seq;
  873. __le32 rann_interval;
  874. __le32 rann_metric;
  875. } __packed;
  876. enum ieee80211_rann_flags {
  877. RANN_FLAG_IS_GATE = 1 << 0,
  878. };
  879. enum ieee80211_ht_chanwidth_values {
  880. IEEE80211_HT_CHANWIDTH_20MHZ = 0,
  881. IEEE80211_HT_CHANWIDTH_ANY = 1,
  882. };
  883. /**
  884. * enum ieee80211_opmode_bits - VHT operating mode field bits
  885. * @IEEE80211_OPMODE_NOTIF_CHANWIDTH_MASK: channel width mask
  886. * @IEEE80211_OPMODE_NOTIF_CHANWIDTH_20MHZ: 20 MHz channel width
  887. * @IEEE80211_OPMODE_NOTIF_CHANWIDTH_40MHZ: 40 MHz channel width
  888. * @IEEE80211_OPMODE_NOTIF_CHANWIDTH_80MHZ: 80 MHz channel width
  889. * @IEEE80211_OPMODE_NOTIF_CHANWIDTH_160MHZ: 160 MHz or 80+80 MHz channel width
  890. * @IEEE80211_OPMODE_NOTIF_BW_160_80P80: 160 / 80+80 MHz indicator flag
  891. * @IEEE80211_OPMODE_NOTIF_RX_NSS_MASK: number of spatial streams mask
  892. * (the NSS value is the value of this field + 1)
  893. * @IEEE80211_OPMODE_NOTIF_RX_NSS_SHIFT: number of spatial streams shift
  894. * @IEEE80211_OPMODE_NOTIF_RX_NSS_TYPE_BF: indicates streams in SU-MIMO PPDU
  895. * using a beamforming steering matrix
  896. */
  897. enum ieee80211_vht_opmode_bits {
  898. IEEE80211_OPMODE_NOTIF_CHANWIDTH_MASK = 0x03,
  899. IEEE80211_OPMODE_NOTIF_CHANWIDTH_20MHZ = 0,
  900. IEEE80211_OPMODE_NOTIF_CHANWIDTH_40MHZ = 1,
  901. IEEE80211_OPMODE_NOTIF_CHANWIDTH_80MHZ = 2,
  902. IEEE80211_OPMODE_NOTIF_CHANWIDTH_160MHZ = 3,
  903. IEEE80211_OPMODE_NOTIF_BW_160_80P80 = 0x04,
  904. IEEE80211_OPMODE_NOTIF_RX_NSS_MASK = 0x70,
  905. IEEE80211_OPMODE_NOTIF_RX_NSS_SHIFT = 4,
  906. IEEE80211_OPMODE_NOTIF_RX_NSS_TYPE_BF = 0x80,
  907. };
  908. /**
  909. * enum ieee80211_s1g_chanwidth
  910. * These are defined in IEEE802.11-2016ah Table 10-20
  911. * as BSS Channel Width
  912. *
  913. * @IEEE80211_S1G_CHANWIDTH_1MHZ: 1MHz operating channel
  914. * @IEEE80211_S1G_CHANWIDTH_2MHZ: 2MHz operating channel
  915. * @IEEE80211_S1G_CHANWIDTH_4MHZ: 4MHz operating channel
  916. * @IEEE80211_S1G_CHANWIDTH_8MHZ: 8MHz operating channel
  917. * @IEEE80211_S1G_CHANWIDTH_16MHZ: 16MHz operating channel
  918. */
  919. enum ieee80211_s1g_chanwidth {
  920. IEEE80211_S1G_CHANWIDTH_1MHZ = 0,
  921. IEEE80211_S1G_CHANWIDTH_2MHZ = 1,
  922. IEEE80211_S1G_CHANWIDTH_4MHZ = 3,
  923. IEEE80211_S1G_CHANWIDTH_8MHZ = 7,
  924. IEEE80211_S1G_CHANWIDTH_16MHZ = 15,
  925. };
  926. #define WLAN_SA_QUERY_TR_ID_LEN 2
  927. #define WLAN_MEMBERSHIP_LEN 8
  928. #define WLAN_USER_POSITION_LEN 16
  929. /**
  930. * struct ieee80211_tpc_report_ie
  931. *
  932. * This structure refers to "TPC Report element"
  933. */
  934. struct ieee80211_tpc_report_ie {
  935. u8 tx_power;
  936. u8 link_margin;
  937. } __packed;
  938. #define IEEE80211_ADDBA_EXT_FRAG_LEVEL_MASK GENMASK(2, 1)
  939. #define IEEE80211_ADDBA_EXT_FRAG_LEVEL_SHIFT 1
  940. #define IEEE80211_ADDBA_EXT_NO_FRAG BIT(0)
  941. #define IEEE80211_ADDBA_EXT_BUF_SIZE_MASK GENMASK(7, 5)
  942. #define IEEE80211_ADDBA_EXT_BUF_SIZE_SHIFT 10
  943. struct ieee80211_addba_ext_ie {
  944. u8 data;
  945. } __packed;
  946. /**
  947. * struct ieee80211_s1g_bcn_compat_ie
  948. *
  949. * S1G Beacon Compatibility element
  950. */
  951. struct ieee80211_s1g_bcn_compat_ie {
  952. __le16 compat_info;
  953. __le16 beacon_int;
  954. __le32 tsf_completion;
  955. } __packed;
  956. /**
  957. * struct ieee80211_s1g_oper_ie
  958. *
  959. * S1G Operation element
  960. */
  961. struct ieee80211_s1g_oper_ie {
  962. u8 ch_width;
  963. u8 oper_class;
  964. u8 primary_ch;
  965. u8 oper_ch;
  966. __le16 basic_mcs_nss;
  967. } __packed;
  968. /**
  969. * struct ieee80211_aid_response_ie
  970. *
  971. * AID Response element
  972. */
  973. struct ieee80211_aid_response_ie {
  974. __le16 aid;
  975. u8 switch_count;
  976. __le16 response_int;
  977. } __packed;
  978. struct ieee80211_s1g_cap {
  979. u8 capab_info[10];
  980. u8 supp_mcs_nss[5];
  981. } __packed;
  982. struct ieee80211_ext {
  983. __le16 frame_control;
  984. __le16 duration;
  985. union {
  986. struct {
  987. u8 sa[ETH_ALEN];
  988. __le32 timestamp;
  989. u8 change_seq;
  990. u8 variable[0];
  991. } __packed s1g_beacon;
  992. struct {
  993. u8 sa[ETH_ALEN];
  994. __le32 timestamp;
  995. u8 change_seq;
  996. u8 next_tbtt[3];
  997. u8 variable[0];
  998. } __packed s1g_short_beacon;
  999. } u;
  1000. } __packed __aligned(2);
  1001. #define IEEE80211_TWT_CONTROL_NDP BIT(0)
  1002. #define IEEE80211_TWT_CONTROL_RESP_MODE BIT(1)
  1003. #define IEEE80211_TWT_CONTROL_NEG_TYPE_BROADCAST BIT(3)
  1004. #define IEEE80211_TWT_CONTROL_RX_DISABLED BIT(4)
  1005. #define IEEE80211_TWT_CONTROL_WAKE_DUR_UNIT BIT(5)
  1006. #define IEEE80211_TWT_REQTYPE_REQUEST BIT(0)
  1007. #define IEEE80211_TWT_REQTYPE_SETUP_CMD GENMASK(3, 1)
  1008. #define IEEE80211_TWT_REQTYPE_TRIGGER BIT(4)
  1009. #define IEEE80211_TWT_REQTYPE_IMPLICIT BIT(5)
  1010. #define IEEE80211_TWT_REQTYPE_FLOWTYPE BIT(6)
  1011. #define IEEE80211_TWT_REQTYPE_FLOWID GENMASK(9, 7)
  1012. #define IEEE80211_TWT_REQTYPE_WAKE_INT_EXP GENMASK(14, 10)
  1013. #define IEEE80211_TWT_REQTYPE_PROTECTION BIT(15)
  1014. enum ieee80211_twt_setup_cmd {
  1015. TWT_SETUP_CMD_REQUEST,
  1016. TWT_SETUP_CMD_SUGGEST,
  1017. TWT_SETUP_CMD_DEMAND,
  1018. TWT_SETUP_CMD_GROUPING,
  1019. TWT_SETUP_CMD_ACCEPT,
  1020. TWT_SETUP_CMD_ALTERNATE,
  1021. TWT_SETUP_CMD_DICTATE,
  1022. TWT_SETUP_CMD_REJECT,
  1023. };
  1024. struct ieee80211_twt_params {
  1025. __le16 req_type;
  1026. __le64 twt;
  1027. u8 min_twt_dur;
  1028. __le16 mantissa;
  1029. u8 channel;
  1030. } __packed;
  1031. struct ieee80211_twt_setup {
  1032. u8 dialog_token;
  1033. u8 element_id;
  1034. u8 length;
  1035. u8 control;
  1036. u8 params[];
  1037. } __packed;
  1038. struct ieee80211_mgmt {
  1039. __le16 frame_control;
  1040. __le16 duration;
  1041. u8 da[ETH_ALEN];
  1042. u8 sa[ETH_ALEN];
  1043. u8 bssid[ETH_ALEN];
  1044. __le16 seq_ctrl;
  1045. union {
  1046. struct {
  1047. __le16 auth_alg;
  1048. __le16 auth_transaction;
  1049. __le16 status_code;
  1050. /* possibly followed by Challenge text */
  1051. u8 variable[];
  1052. } __packed auth;
  1053. struct {
  1054. __le16 reason_code;
  1055. } __packed deauth;
  1056. struct {
  1057. __le16 capab_info;
  1058. __le16 listen_interval;
  1059. /* followed by SSID and Supported rates */
  1060. u8 variable[];
  1061. } __packed assoc_req;
  1062. struct {
  1063. __le16 capab_info;
  1064. __le16 status_code;
  1065. __le16 aid;
  1066. /* followed by Supported rates */
  1067. u8 variable[];
  1068. } __packed assoc_resp, reassoc_resp;
  1069. struct {
  1070. __le16 capab_info;
  1071. __le16 status_code;
  1072. u8 variable[];
  1073. } __packed s1g_assoc_resp, s1g_reassoc_resp;
  1074. struct {
  1075. __le16 capab_info;
  1076. __le16 listen_interval;
  1077. u8 current_ap[ETH_ALEN];
  1078. /* followed by SSID and Supported rates */
  1079. u8 variable[];
  1080. } __packed reassoc_req;
  1081. struct {
  1082. __le16 reason_code;
  1083. } __packed disassoc;
  1084. struct {
  1085. __le64 timestamp;
  1086. __le16 beacon_int;
  1087. __le16 capab_info;
  1088. /* followed by some of SSID, Supported rates,
  1089. * FH Params, DS Params, CF Params, IBSS Params, TIM */
  1090. u8 variable[];
  1091. } __packed beacon;
  1092. struct {
  1093. /* only variable items: SSID, Supported rates */
  1094. DECLARE_FLEX_ARRAY(u8, variable);
  1095. } __packed probe_req;
  1096. struct {
  1097. __le64 timestamp;
  1098. __le16 beacon_int;
  1099. __le16 capab_info;
  1100. /* followed by some of SSID, Supported rates,
  1101. * FH Params, DS Params, CF Params, IBSS Params */
  1102. u8 variable[];
  1103. } __packed probe_resp;
  1104. struct {
  1105. u8 category;
  1106. union {
  1107. struct {
  1108. u8 action_code;
  1109. u8 dialog_token;
  1110. u8 status_code;
  1111. u8 variable[];
  1112. } __packed wme_action;
  1113. struct{
  1114. u8 action_code;
  1115. u8 variable[];
  1116. } __packed chan_switch;
  1117. struct{
  1118. u8 action_code;
  1119. struct ieee80211_ext_chansw_ie data;
  1120. u8 variable[];
  1121. } __packed ext_chan_switch;
  1122. struct{
  1123. u8 action_code;
  1124. u8 dialog_token;
  1125. u8 element_id;
  1126. u8 length;
  1127. struct ieee80211_msrment_ie msr_elem;
  1128. } __packed measurement;
  1129. struct{
  1130. u8 action_code;
  1131. u8 dialog_token;
  1132. __le16 capab;
  1133. __le16 timeout;
  1134. __le16 start_seq_num;
  1135. /* followed by BA Extension */
  1136. u8 variable[];
  1137. } __packed addba_req;
  1138. struct{
  1139. u8 action_code;
  1140. u8 dialog_token;
  1141. __le16 status;
  1142. __le16 capab;
  1143. __le16 timeout;
  1144. } __packed addba_resp;
  1145. struct{
  1146. u8 action_code;
  1147. __le16 params;
  1148. __le16 reason_code;
  1149. } __packed delba;
  1150. struct {
  1151. u8 action_code;
  1152. u8 variable[];
  1153. } __packed self_prot;
  1154. struct{
  1155. u8 action_code;
  1156. u8 variable[];
  1157. } __packed mesh_action;
  1158. struct {
  1159. u8 action;
  1160. u8 trans_id[WLAN_SA_QUERY_TR_ID_LEN];
  1161. } __packed sa_query;
  1162. struct {
  1163. u8 action;
  1164. u8 smps_control;
  1165. } __packed ht_smps;
  1166. struct {
  1167. u8 action_code;
  1168. u8 chanwidth;
  1169. } __packed ht_notify_cw;
  1170. struct {
  1171. u8 action_code;
  1172. u8 dialog_token;
  1173. __le16 capability;
  1174. u8 variable[0];
  1175. } __packed tdls_discover_resp;
  1176. struct {
  1177. u8 action_code;
  1178. u8 operating_mode;
  1179. } __packed vht_opmode_notif;
  1180. struct {
  1181. u8 action_code;
  1182. u8 membership[WLAN_MEMBERSHIP_LEN];
  1183. u8 position[WLAN_USER_POSITION_LEN];
  1184. } __packed vht_group_notif;
  1185. struct {
  1186. u8 action_code;
  1187. u8 dialog_token;
  1188. u8 tpc_elem_id;
  1189. u8 tpc_elem_length;
  1190. struct ieee80211_tpc_report_ie tpc;
  1191. } __packed tpc_report;
  1192. struct {
  1193. u8 action_code;
  1194. u8 dialog_token;
  1195. u8 follow_up;
  1196. u8 tod[6];
  1197. u8 toa[6];
  1198. __le16 tod_error;
  1199. __le16 toa_error;
  1200. u8 variable[];
  1201. } __packed ftm;
  1202. struct {
  1203. u8 action_code;
  1204. u8 variable[];
  1205. } __packed s1g;
  1206. struct {
  1207. u8 action_code;
  1208. u8 dialog_token;
  1209. u8 follow_up;
  1210. u32 tod;
  1211. u32 toa;
  1212. u8 max_tod_error;
  1213. u8 max_toa_error;
  1214. } __packed wnm_timing_msr;
  1215. } u;
  1216. } __packed action;
  1217. } u;
  1218. } __packed __aligned(2);
  1219. /* Supported rates membership selectors */
  1220. #define BSS_MEMBERSHIP_SELECTOR_HT_PHY 127
  1221. #define BSS_MEMBERSHIP_SELECTOR_VHT_PHY 126
  1222. #define BSS_MEMBERSHIP_SELECTOR_HE_PHY 122
  1223. #define BSS_MEMBERSHIP_SELECTOR_SAE_H2E 123
  1224. /* mgmt header + 1 byte category code */
  1225. #define IEEE80211_MIN_ACTION_SIZE offsetof(struct ieee80211_mgmt, u.action.u)
  1226. /* Management MIC information element (IEEE 802.11w) */
  1227. struct ieee80211_mmie {
  1228. u8 element_id;
  1229. u8 length;
  1230. __le16 key_id;
  1231. u8 sequence_number[6];
  1232. u8 mic[8];
  1233. } __packed;
  1234. /* Management MIC information element (IEEE 802.11w) for GMAC and CMAC-256 */
  1235. struct ieee80211_mmie_16 {
  1236. u8 element_id;
  1237. u8 length;
  1238. __le16 key_id;
  1239. u8 sequence_number[6];
  1240. u8 mic[16];
  1241. } __packed;
  1242. struct ieee80211_vendor_ie {
  1243. u8 element_id;
  1244. u8 len;
  1245. u8 oui[3];
  1246. u8 oui_type;
  1247. } __packed;
  1248. struct ieee80211_wmm_ac_param {
  1249. u8 aci_aifsn; /* AIFSN, ACM, ACI */
  1250. u8 cw; /* ECWmin, ECWmax (CW = 2^ECW - 1) */
  1251. __le16 txop_limit;
  1252. } __packed;
  1253. struct ieee80211_wmm_param_ie {
  1254. u8 element_id; /* Element ID: 221 (0xdd); */
  1255. u8 len; /* Length: 24 */
  1256. /* required fields for WMM version 1 */
  1257. u8 oui[3]; /* 00:50:f2 */
  1258. u8 oui_type; /* 2 */
  1259. u8 oui_subtype; /* 1 */
  1260. u8 version; /* 1 for WMM version 1.0 */
  1261. u8 qos_info; /* AP/STA specific QoS info */
  1262. u8 reserved; /* 0 */
  1263. /* AC_BE, AC_BK, AC_VI, AC_VO */
  1264. struct ieee80211_wmm_ac_param ac[4];
  1265. } __packed;
  1266. /* Control frames */
  1267. struct ieee80211_rts {
  1268. __le16 frame_control;
  1269. __le16 duration;
  1270. u8 ra[ETH_ALEN];
  1271. u8 ta[ETH_ALEN];
  1272. } __packed __aligned(2);
  1273. struct ieee80211_cts {
  1274. __le16 frame_control;
  1275. __le16 duration;
  1276. u8 ra[ETH_ALEN];
  1277. } __packed __aligned(2);
  1278. struct ieee80211_pspoll {
  1279. __le16 frame_control;
  1280. __le16 aid;
  1281. u8 bssid[ETH_ALEN];
  1282. u8 ta[ETH_ALEN];
  1283. } __packed __aligned(2);
  1284. /* TDLS */
  1285. /* Channel switch timing */
  1286. struct ieee80211_ch_switch_timing {
  1287. __le16 switch_time;
  1288. __le16 switch_timeout;
  1289. } __packed;
  1290. /* Link-id information element */
  1291. struct ieee80211_tdls_lnkie {
  1292. u8 ie_type; /* Link Identifier IE */
  1293. u8 ie_len;
  1294. u8 bssid[ETH_ALEN];
  1295. u8 init_sta[ETH_ALEN];
  1296. u8 resp_sta[ETH_ALEN];
  1297. } __packed;
  1298. struct ieee80211_tdls_data {
  1299. u8 da[ETH_ALEN];
  1300. u8 sa[ETH_ALEN];
  1301. __be16 ether_type;
  1302. u8 payload_type;
  1303. u8 category;
  1304. u8 action_code;
  1305. union {
  1306. struct {
  1307. u8 dialog_token;
  1308. __le16 capability;
  1309. u8 variable[0];
  1310. } __packed setup_req;
  1311. struct {
  1312. __le16 status_code;
  1313. u8 dialog_token;
  1314. __le16 capability;
  1315. u8 variable[0];
  1316. } __packed setup_resp;
  1317. struct {
  1318. __le16 status_code;
  1319. u8 dialog_token;
  1320. u8 variable[0];
  1321. } __packed setup_cfm;
  1322. struct {
  1323. __le16 reason_code;
  1324. u8 variable[0];
  1325. } __packed teardown;
  1326. struct {
  1327. u8 dialog_token;
  1328. u8 variable[0];
  1329. } __packed discover_req;
  1330. struct {
  1331. u8 target_channel;
  1332. u8 oper_class;
  1333. u8 variable[0];
  1334. } __packed chan_switch_req;
  1335. struct {
  1336. __le16 status_code;
  1337. u8 variable[0];
  1338. } __packed chan_switch_resp;
  1339. } u;
  1340. } __packed;
  1341. /*
  1342. * Peer-to-Peer IE attribute related definitions.
  1343. */
  1344. /**
  1345. * enum ieee80211_p2p_attr_id - identifies type of peer-to-peer attribute.
  1346. */
  1347. enum ieee80211_p2p_attr_id {
  1348. IEEE80211_P2P_ATTR_STATUS = 0,
  1349. IEEE80211_P2P_ATTR_MINOR_REASON,
  1350. IEEE80211_P2P_ATTR_CAPABILITY,
  1351. IEEE80211_P2P_ATTR_DEVICE_ID,
  1352. IEEE80211_P2P_ATTR_GO_INTENT,
  1353. IEEE80211_P2P_ATTR_GO_CONFIG_TIMEOUT,
  1354. IEEE80211_P2P_ATTR_LISTEN_CHANNEL,
  1355. IEEE80211_P2P_ATTR_GROUP_BSSID,
  1356. IEEE80211_P2P_ATTR_EXT_LISTEN_TIMING,
  1357. IEEE80211_P2P_ATTR_INTENDED_IFACE_ADDR,
  1358. IEEE80211_P2P_ATTR_MANAGABILITY,
  1359. IEEE80211_P2P_ATTR_CHANNEL_LIST,
  1360. IEEE80211_P2P_ATTR_ABSENCE_NOTICE,
  1361. IEEE80211_P2P_ATTR_DEVICE_INFO,
  1362. IEEE80211_P2P_ATTR_GROUP_INFO,
  1363. IEEE80211_P2P_ATTR_GROUP_ID,
  1364. IEEE80211_P2P_ATTR_INTERFACE,
  1365. IEEE80211_P2P_ATTR_OPER_CHANNEL,
  1366. IEEE80211_P2P_ATTR_INVITE_FLAGS,
  1367. /* 19 - 220: Reserved */
  1368. IEEE80211_P2P_ATTR_VENDOR_SPECIFIC = 221,
  1369. IEEE80211_P2P_ATTR_MAX
  1370. };
  1371. /* Notice of Absence attribute - described in P2P spec 4.1.14 */
  1372. /* Typical max value used here */
  1373. #define IEEE80211_P2P_NOA_DESC_MAX 4
  1374. struct ieee80211_p2p_noa_desc {
  1375. u8 count;
  1376. __le32 duration;
  1377. __le32 interval;
  1378. __le32 start_time;
  1379. } __packed;
  1380. struct ieee80211_p2p_noa_attr {
  1381. u8 index;
  1382. u8 oppps_ctwindow;
  1383. struct ieee80211_p2p_noa_desc desc[IEEE80211_P2P_NOA_DESC_MAX];
  1384. } __packed;
  1385. #define IEEE80211_P2P_OPPPS_ENABLE_BIT BIT(7)
  1386. #define IEEE80211_P2P_OPPPS_CTWINDOW_MASK 0x7F
  1387. /**
  1388. * struct ieee80211_bar - HT Block Ack Request
  1389. *
  1390. * This structure refers to "HT BlockAckReq" as
  1391. * described in 802.11n draft section 7.2.1.7.1
  1392. */
  1393. struct ieee80211_bar {
  1394. __le16 frame_control;
  1395. __le16 duration;
  1396. __u8 ra[ETH_ALEN];
  1397. __u8 ta[ETH_ALEN];
  1398. __le16 control;
  1399. __le16 start_seq_num;
  1400. } __packed;
  1401. /* 802.11 BAR control masks */
  1402. #define IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL 0x0000
  1403. #define IEEE80211_BAR_CTRL_MULTI_TID 0x0002
  1404. #define IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA 0x0004
  1405. #define IEEE80211_BAR_CTRL_TID_INFO_MASK 0xf000
  1406. #define IEEE80211_BAR_CTRL_TID_INFO_SHIFT 12
  1407. #define IEEE80211_HT_MCS_MASK_LEN 10
  1408. /**
  1409. * struct ieee80211_mcs_info - MCS information
  1410. * @rx_mask: RX mask
  1411. * @rx_highest: highest supported RX rate. If set represents
  1412. * the highest supported RX data rate in units of 1 Mbps.
  1413. * If this field is 0 this value should not be used to
  1414. * consider the highest RX data rate supported.
  1415. * @tx_params: TX parameters
  1416. */
  1417. struct ieee80211_mcs_info {
  1418. u8 rx_mask[IEEE80211_HT_MCS_MASK_LEN];
  1419. __le16 rx_highest;
  1420. u8 tx_params;
  1421. u8 reserved[3];
  1422. } __packed;
  1423. /* 802.11n HT capability MSC set */
  1424. #define IEEE80211_HT_MCS_RX_HIGHEST_MASK 0x3ff
  1425. #define IEEE80211_HT_MCS_TX_DEFINED 0x01
  1426. #define IEEE80211_HT_MCS_TX_RX_DIFF 0x02
  1427. /* value 0 == 1 stream etc */
  1428. #define IEEE80211_HT_MCS_TX_MAX_STREAMS_MASK 0x0C
  1429. #define IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT 2
  1430. #define IEEE80211_HT_MCS_TX_MAX_STREAMS 4
  1431. #define IEEE80211_HT_MCS_TX_UNEQUAL_MODULATION 0x10
  1432. /*
  1433. * 802.11n D5.0 20.3.5 / 20.6 says:
  1434. * - indices 0 to 7 and 32 are single spatial stream
  1435. * - 8 to 31 are multiple spatial streams using equal modulation
  1436. * [8..15 for two streams, 16..23 for three and 24..31 for four]
  1437. * - remainder are multiple spatial streams using unequal modulation
  1438. */
  1439. #define IEEE80211_HT_MCS_UNEQUAL_MODULATION_START 33
  1440. #define IEEE80211_HT_MCS_UNEQUAL_MODULATION_START_BYTE \
  1441. (IEEE80211_HT_MCS_UNEQUAL_MODULATION_START / 8)
  1442. /**
  1443. * struct ieee80211_ht_cap - HT capabilities
  1444. *
  1445. * This structure is the "HT capabilities element" as
  1446. * described in 802.11n D5.0 7.3.2.57
  1447. */
  1448. struct ieee80211_ht_cap {
  1449. __le16 cap_info;
  1450. u8 ampdu_params_info;
  1451. /* 16 bytes MCS information */
  1452. struct ieee80211_mcs_info mcs;
  1453. __le16 extended_ht_cap_info;
  1454. __le32 tx_BF_cap_info;
  1455. u8 antenna_selection_info;
  1456. } __packed;
  1457. /* 802.11n HT capabilities masks (for cap_info) */
  1458. #define IEEE80211_HT_CAP_LDPC_CODING 0x0001
  1459. #define IEEE80211_HT_CAP_SUP_WIDTH_20_40 0x0002
  1460. #define IEEE80211_HT_CAP_SM_PS 0x000C
  1461. #define IEEE80211_HT_CAP_SM_PS_SHIFT 2
  1462. #define IEEE80211_HT_CAP_GRN_FLD 0x0010
  1463. #define IEEE80211_HT_CAP_SGI_20 0x0020
  1464. #define IEEE80211_HT_CAP_SGI_40 0x0040
  1465. #define IEEE80211_HT_CAP_TX_STBC 0x0080
  1466. #define IEEE80211_HT_CAP_RX_STBC 0x0300
  1467. #define IEEE80211_HT_CAP_RX_STBC_SHIFT 8
  1468. #define IEEE80211_HT_CAP_DELAY_BA 0x0400
  1469. #define IEEE80211_HT_CAP_MAX_AMSDU 0x0800
  1470. #define IEEE80211_HT_CAP_DSSSCCK40 0x1000
  1471. #define IEEE80211_HT_CAP_RESERVED 0x2000
  1472. #define IEEE80211_HT_CAP_40MHZ_INTOLERANT 0x4000
  1473. #define IEEE80211_HT_CAP_LSIG_TXOP_PROT 0x8000
  1474. /* 802.11n HT extended capabilities masks (for extended_ht_cap_info) */
  1475. #define IEEE80211_HT_EXT_CAP_PCO 0x0001
  1476. #define IEEE80211_HT_EXT_CAP_PCO_TIME 0x0006
  1477. #define IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT 1
  1478. #define IEEE80211_HT_EXT_CAP_MCS_FB 0x0300
  1479. #define IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT 8
  1480. #define IEEE80211_HT_EXT_CAP_HTC_SUP 0x0400
  1481. #define IEEE80211_HT_EXT_CAP_RD_RESPONDER 0x0800
  1482. /* 802.11n HT capability AMPDU settings (for ampdu_params_info) */
  1483. #define IEEE80211_HT_AMPDU_PARM_FACTOR 0x03
  1484. #define IEEE80211_HT_AMPDU_PARM_DENSITY 0x1C
  1485. #define IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT 2
  1486. /*
  1487. * Maximum length of AMPDU that the STA can receive in high-throughput (HT).
  1488. * Length = 2 ^ (13 + max_ampdu_length_exp) - 1 (octets)
  1489. */
  1490. enum ieee80211_max_ampdu_length_exp {
  1491. IEEE80211_HT_MAX_AMPDU_8K = 0,
  1492. IEEE80211_HT_MAX_AMPDU_16K = 1,
  1493. IEEE80211_HT_MAX_AMPDU_32K = 2,
  1494. IEEE80211_HT_MAX_AMPDU_64K = 3
  1495. };
  1496. /*
  1497. * Maximum length of AMPDU that the STA can receive in VHT.
  1498. * Length = 2 ^ (13 + max_ampdu_length_exp) - 1 (octets)
  1499. */
  1500. enum ieee80211_vht_max_ampdu_length_exp {
  1501. IEEE80211_VHT_MAX_AMPDU_8K = 0,
  1502. IEEE80211_VHT_MAX_AMPDU_16K = 1,
  1503. IEEE80211_VHT_MAX_AMPDU_32K = 2,
  1504. IEEE80211_VHT_MAX_AMPDU_64K = 3,
  1505. IEEE80211_VHT_MAX_AMPDU_128K = 4,
  1506. IEEE80211_VHT_MAX_AMPDU_256K = 5,
  1507. IEEE80211_VHT_MAX_AMPDU_512K = 6,
  1508. IEEE80211_VHT_MAX_AMPDU_1024K = 7
  1509. };
  1510. #define IEEE80211_HT_MAX_AMPDU_FACTOR 13
  1511. /* Minimum MPDU start spacing */
  1512. enum ieee80211_min_mpdu_spacing {
  1513. IEEE80211_HT_MPDU_DENSITY_NONE = 0, /* No restriction */
  1514. IEEE80211_HT_MPDU_DENSITY_0_25 = 1, /* 1/4 usec */
  1515. IEEE80211_HT_MPDU_DENSITY_0_5 = 2, /* 1/2 usec */
  1516. IEEE80211_HT_MPDU_DENSITY_1 = 3, /* 1 usec */
  1517. IEEE80211_HT_MPDU_DENSITY_2 = 4, /* 2 usec */
  1518. IEEE80211_HT_MPDU_DENSITY_4 = 5, /* 4 usec */
  1519. IEEE80211_HT_MPDU_DENSITY_8 = 6, /* 8 usec */
  1520. IEEE80211_HT_MPDU_DENSITY_16 = 7 /* 16 usec */
  1521. };
  1522. /**
  1523. * struct ieee80211_ht_operation - HT operation IE
  1524. *
  1525. * This structure is the "HT operation element" as
  1526. * described in 802.11n-2009 7.3.2.57
  1527. */
  1528. struct ieee80211_ht_operation {
  1529. u8 primary_chan;
  1530. u8 ht_param;
  1531. __le16 operation_mode;
  1532. __le16 stbc_param;
  1533. u8 basic_set[16];
  1534. } __packed;
  1535. /* for ht_param */
  1536. #define IEEE80211_HT_PARAM_CHA_SEC_OFFSET 0x03
  1537. #define IEEE80211_HT_PARAM_CHA_SEC_NONE 0x00
  1538. #define IEEE80211_HT_PARAM_CHA_SEC_ABOVE 0x01
  1539. #define IEEE80211_HT_PARAM_CHA_SEC_BELOW 0x03
  1540. #define IEEE80211_HT_PARAM_CHAN_WIDTH_ANY 0x04
  1541. #define IEEE80211_HT_PARAM_RIFS_MODE 0x08
  1542. /* for operation_mode */
  1543. #define IEEE80211_HT_OP_MODE_PROTECTION 0x0003
  1544. #define IEEE80211_HT_OP_MODE_PROTECTION_NONE 0
  1545. #define IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER 1
  1546. #define IEEE80211_HT_OP_MODE_PROTECTION_20MHZ 2
  1547. #define IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED 3
  1548. #define IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT 0x0004
  1549. #define IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT 0x0010
  1550. #define IEEE80211_HT_OP_MODE_CCFS2_SHIFT 5
  1551. #define IEEE80211_HT_OP_MODE_CCFS2_MASK 0x1fe0
  1552. /* for stbc_param */
  1553. #define IEEE80211_HT_STBC_PARAM_DUAL_BEACON 0x0040
  1554. #define IEEE80211_HT_STBC_PARAM_DUAL_CTS_PROT 0x0080
  1555. #define IEEE80211_HT_STBC_PARAM_STBC_BEACON 0x0100
  1556. #define IEEE80211_HT_STBC_PARAM_LSIG_TXOP_FULLPROT 0x0200
  1557. #define IEEE80211_HT_STBC_PARAM_PCO_ACTIVE 0x0400
  1558. #define IEEE80211_HT_STBC_PARAM_PCO_PHASE 0x0800
  1559. /* block-ack parameters */
  1560. #define IEEE80211_ADDBA_PARAM_AMSDU_MASK 0x0001
  1561. #define IEEE80211_ADDBA_PARAM_POLICY_MASK 0x0002
  1562. #define IEEE80211_ADDBA_PARAM_TID_MASK 0x003C
  1563. #define IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK 0xFFC0
  1564. #define IEEE80211_DELBA_PARAM_TID_MASK 0xF000
  1565. #define IEEE80211_DELBA_PARAM_INITIATOR_MASK 0x0800
  1566. /*
  1567. * A-MPDU buffer sizes
  1568. * According to HT size varies from 8 to 64 frames
  1569. * HE adds the ability to have up to 256 frames.
  1570. * EHT adds the ability to have up to 1K frames.
  1571. */
  1572. #define IEEE80211_MIN_AMPDU_BUF 0x8
  1573. #define IEEE80211_MAX_AMPDU_BUF_HT 0x40
  1574. #define IEEE80211_MAX_AMPDU_BUF_HE 0x100
  1575. #define IEEE80211_MAX_AMPDU_BUF_EHT 0x400
  1576. /* Spatial Multiplexing Power Save Modes (for capability) */
  1577. #define WLAN_HT_CAP_SM_PS_STATIC 0
  1578. #define WLAN_HT_CAP_SM_PS_DYNAMIC 1
  1579. #define WLAN_HT_CAP_SM_PS_INVALID 2
  1580. #define WLAN_HT_CAP_SM_PS_DISABLED 3
  1581. /* for SM power control field lower two bits */
  1582. #define WLAN_HT_SMPS_CONTROL_DISABLED 0
  1583. #define WLAN_HT_SMPS_CONTROL_STATIC 1
  1584. #define WLAN_HT_SMPS_CONTROL_DYNAMIC 3
  1585. /**
  1586. * struct ieee80211_vht_mcs_info - VHT MCS information
  1587. * @rx_mcs_map: RX MCS map 2 bits for each stream, total 8 streams
  1588. * @rx_highest: Indicates highest long GI VHT PPDU data rate
  1589. * STA can receive. Rate expressed in units of 1 Mbps.
  1590. * If this field is 0 this value should not be used to
  1591. * consider the highest RX data rate supported.
  1592. * The top 3 bits of this field indicate the Maximum NSTS,total
  1593. * (a beamformee capability.)
  1594. * @tx_mcs_map: TX MCS map 2 bits for each stream, total 8 streams
  1595. * @tx_highest: Indicates highest long GI VHT PPDU data rate
  1596. * STA can transmit. Rate expressed in units of 1 Mbps.
  1597. * If this field is 0 this value should not be used to
  1598. * consider the highest TX data rate supported.
  1599. * The top 2 bits of this field are reserved, the
  1600. * 3rd bit from the top indiciates VHT Extended NSS BW
  1601. * Capability.
  1602. */
  1603. struct ieee80211_vht_mcs_info {
  1604. __le16 rx_mcs_map;
  1605. __le16 rx_highest;
  1606. __le16 tx_mcs_map;
  1607. __le16 tx_highest;
  1608. } __packed;
  1609. /* for rx_highest */
  1610. #define IEEE80211_VHT_MAX_NSTS_TOTAL_SHIFT 13
  1611. #define IEEE80211_VHT_MAX_NSTS_TOTAL_MASK (7 << IEEE80211_VHT_MAX_NSTS_TOTAL_SHIFT)
  1612. /* for tx_highest */
  1613. #define IEEE80211_VHT_EXT_NSS_BW_CAPABLE (1 << 13)
  1614. /**
  1615. * enum ieee80211_vht_mcs_support - VHT MCS support definitions
  1616. * @IEEE80211_VHT_MCS_SUPPORT_0_7: MCSes 0-7 are supported for the
  1617. * number of streams
  1618. * @IEEE80211_VHT_MCS_SUPPORT_0_8: MCSes 0-8 are supported
  1619. * @IEEE80211_VHT_MCS_SUPPORT_0_9: MCSes 0-9 are supported
  1620. * @IEEE80211_VHT_MCS_NOT_SUPPORTED: This number of streams isn't supported
  1621. *
  1622. * These definitions are used in each 2-bit subfield of the @rx_mcs_map
  1623. * and @tx_mcs_map fields of &struct ieee80211_vht_mcs_info, which are
  1624. * both split into 8 subfields by number of streams. These values indicate
  1625. * which MCSes are supported for the number of streams the value appears
  1626. * for.
  1627. */
  1628. enum ieee80211_vht_mcs_support {
  1629. IEEE80211_VHT_MCS_SUPPORT_0_7 = 0,
  1630. IEEE80211_VHT_MCS_SUPPORT_0_8 = 1,
  1631. IEEE80211_VHT_MCS_SUPPORT_0_9 = 2,
  1632. IEEE80211_VHT_MCS_NOT_SUPPORTED = 3,
  1633. };
  1634. /**
  1635. * struct ieee80211_vht_cap - VHT capabilities
  1636. *
  1637. * This structure is the "VHT capabilities element" as
  1638. * described in 802.11ac D3.0 8.4.2.160
  1639. * @vht_cap_info: VHT capability info
  1640. * @supp_mcs: VHT MCS supported rates
  1641. */
  1642. struct ieee80211_vht_cap {
  1643. __le32 vht_cap_info;
  1644. struct ieee80211_vht_mcs_info supp_mcs;
  1645. } __packed;
  1646. /**
  1647. * enum ieee80211_vht_chanwidth - VHT channel width
  1648. * @IEEE80211_VHT_CHANWIDTH_USE_HT: use the HT operation IE to
  1649. * determine the channel width (20 or 40 MHz)
  1650. * @IEEE80211_VHT_CHANWIDTH_80MHZ: 80 MHz bandwidth
  1651. * @IEEE80211_VHT_CHANWIDTH_160MHZ: 160 MHz bandwidth
  1652. * @IEEE80211_VHT_CHANWIDTH_80P80MHZ: 80+80 MHz bandwidth
  1653. */
  1654. enum ieee80211_vht_chanwidth {
  1655. IEEE80211_VHT_CHANWIDTH_USE_HT = 0,
  1656. IEEE80211_VHT_CHANWIDTH_80MHZ = 1,
  1657. IEEE80211_VHT_CHANWIDTH_160MHZ = 2,
  1658. IEEE80211_VHT_CHANWIDTH_80P80MHZ = 3,
  1659. };
  1660. /**
  1661. * struct ieee80211_vht_operation - VHT operation IE
  1662. *
  1663. * This structure is the "VHT operation element" as
  1664. * described in 802.11ac D3.0 8.4.2.161
  1665. * @chan_width: Operating channel width
  1666. * @center_freq_seg0_idx: center freq segment 0 index
  1667. * @center_freq_seg1_idx: center freq segment 1 index
  1668. * @basic_mcs_set: VHT Basic MCS rate set
  1669. */
  1670. struct ieee80211_vht_operation {
  1671. u8 chan_width;
  1672. u8 center_freq_seg0_idx;
  1673. u8 center_freq_seg1_idx;
  1674. __le16 basic_mcs_set;
  1675. } __packed;
  1676. /**
  1677. * struct ieee80211_he_cap_elem - HE capabilities element
  1678. *
  1679. * This structure is the "HE capabilities element" fixed fields as
  1680. * described in P802.11ax_D4.0 section 9.4.2.242.2 and 9.4.2.242.3
  1681. */
  1682. struct ieee80211_he_cap_elem {
  1683. u8 mac_cap_info[6];
  1684. u8 phy_cap_info[11];
  1685. } __packed;
  1686. #define IEEE80211_TX_RX_MCS_NSS_DESC_MAX_LEN 5
  1687. /**
  1688. * enum ieee80211_he_mcs_support - HE MCS support definitions
  1689. * @IEEE80211_HE_MCS_SUPPORT_0_7: MCSes 0-7 are supported for the
  1690. * number of streams
  1691. * @IEEE80211_HE_MCS_SUPPORT_0_9: MCSes 0-9 are supported
  1692. * @IEEE80211_HE_MCS_SUPPORT_0_11: MCSes 0-11 are supported
  1693. * @IEEE80211_HE_MCS_NOT_SUPPORTED: This number of streams isn't supported
  1694. *
  1695. * These definitions are used in each 2-bit subfield of the rx_mcs_*
  1696. * and tx_mcs_* fields of &struct ieee80211_he_mcs_nss_supp, which are
  1697. * both split into 8 subfields by number of streams. These values indicate
  1698. * which MCSes are supported for the number of streams the value appears
  1699. * for.
  1700. */
  1701. enum ieee80211_he_mcs_support {
  1702. IEEE80211_HE_MCS_SUPPORT_0_7 = 0,
  1703. IEEE80211_HE_MCS_SUPPORT_0_9 = 1,
  1704. IEEE80211_HE_MCS_SUPPORT_0_11 = 2,
  1705. IEEE80211_HE_MCS_NOT_SUPPORTED = 3,
  1706. };
  1707. /**
  1708. * struct ieee80211_he_mcs_nss_supp - HE Tx/Rx HE MCS NSS Support Field
  1709. *
  1710. * This structure holds the data required for the Tx/Rx HE MCS NSS Support Field
  1711. * described in P802.11ax_D2.0 section 9.4.2.237.4
  1712. *
  1713. * @rx_mcs_80: Rx MCS map 2 bits for each stream, total 8 streams, for channel
  1714. * widths less than 80MHz.
  1715. * @tx_mcs_80: Tx MCS map 2 bits for each stream, total 8 streams, for channel
  1716. * widths less than 80MHz.
  1717. * @rx_mcs_160: Rx MCS map 2 bits for each stream, total 8 streams, for channel
  1718. * width 160MHz.
  1719. * @tx_mcs_160: Tx MCS map 2 bits for each stream, total 8 streams, for channel
  1720. * width 160MHz.
  1721. * @rx_mcs_80p80: Rx MCS map 2 bits for each stream, total 8 streams, for
  1722. * channel width 80p80MHz.
  1723. * @tx_mcs_80p80: Tx MCS map 2 bits for each stream, total 8 streams, for
  1724. * channel width 80p80MHz.
  1725. */
  1726. struct ieee80211_he_mcs_nss_supp {
  1727. __le16 rx_mcs_80;
  1728. __le16 tx_mcs_80;
  1729. __le16 rx_mcs_160;
  1730. __le16 tx_mcs_160;
  1731. __le16 rx_mcs_80p80;
  1732. __le16 tx_mcs_80p80;
  1733. } __packed;
  1734. /**
  1735. * struct ieee80211_he_operation - HE capabilities element
  1736. *
  1737. * This structure is the "HE operation element" fields as
  1738. * described in P802.11ax_D4.0 section 9.4.2.243
  1739. */
  1740. struct ieee80211_he_operation {
  1741. __le32 he_oper_params;
  1742. __le16 he_mcs_nss_set;
  1743. /* Optional 0,1,3,4,5,7 or 8 bytes: depends on @he_oper_params */
  1744. u8 optional[];
  1745. } __packed;
  1746. /**
  1747. * struct ieee80211_he_spr - HE spatial reuse element
  1748. *
  1749. * This structure is the "HE spatial reuse element" element as
  1750. * described in P802.11ax_D4.0 section 9.4.2.241
  1751. */
  1752. struct ieee80211_he_spr {
  1753. u8 he_sr_control;
  1754. /* Optional 0 to 19 bytes: depends on @he_sr_control */
  1755. u8 optional[];
  1756. } __packed;
  1757. /**
  1758. * struct ieee80211_he_mu_edca_param_ac_rec - MU AC Parameter Record field
  1759. *
  1760. * This structure is the "MU AC Parameter Record" fields as
  1761. * described in P802.11ax_D4.0 section 9.4.2.245
  1762. */
  1763. struct ieee80211_he_mu_edca_param_ac_rec {
  1764. u8 aifsn;
  1765. u8 ecw_min_max;
  1766. u8 mu_edca_timer;
  1767. } __packed;
  1768. /**
  1769. * struct ieee80211_mu_edca_param_set - MU EDCA Parameter Set element
  1770. *
  1771. * This structure is the "MU EDCA Parameter Set element" fields as
  1772. * described in P802.11ax_D4.0 section 9.4.2.245
  1773. */
  1774. struct ieee80211_mu_edca_param_set {
  1775. u8 mu_qos_info;
  1776. struct ieee80211_he_mu_edca_param_ac_rec ac_be;
  1777. struct ieee80211_he_mu_edca_param_ac_rec ac_bk;
  1778. struct ieee80211_he_mu_edca_param_ac_rec ac_vi;
  1779. struct ieee80211_he_mu_edca_param_ac_rec ac_vo;
  1780. } __packed;
  1781. #define IEEE80211_EHT_MCS_NSS_RX 0x0f
  1782. #define IEEE80211_EHT_MCS_NSS_TX 0xf0
  1783. /**
  1784. * struct ieee80211_eht_mcs_nss_supp_20mhz_only - EHT 20MHz only station max
  1785. * supported NSS for per MCS.
  1786. *
  1787. * For each field below, bits 0 - 3 indicate the maximal number of spatial
  1788. * streams for Rx, and bits 4 - 7 indicate the maximal number of spatial streams
  1789. * for Tx.
  1790. *
  1791. * @rx_tx_mcs7_max_nss: indicates the maximum number of spatial streams
  1792. * supported for reception and the maximum number of spatial streams
  1793. * supported for transmission for MCS 0 - 7.
  1794. * @rx_tx_mcs9_max_nss: indicates the maximum number of spatial streams
  1795. * supported for reception and the maximum number of spatial streams
  1796. * supported for transmission for MCS 8 - 9.
  1797. * @rx_tx_mcs11_max_nss: indicates the maximum number of spatial streams
  1798. * supported for reception and the maximum number of spatial streams
  1799. * supported for transmission for MCS 10 - 11.
  1800. * @rx_tx_mcs13_max_nss: indicates the maximum number of spatial streams
  1801. * supported for reception and the maximum number of spatial streams
  1802. * supported for transmission for MCS 12 - 13.
  1803. */
  1804. struct ieee80211_eht_mcs_nss_supp_20mhz_only {
  1805. u8 rx_tx_mcs7_max_nss;
  1806. u8 rx_tx_mcs9_max_nss;
  1807. u8 rx_tx_mcs11_max_nss;
  1808. u8 rx_tx_mcs13_max_nss;
  1809. };
  1810. /**
  1811. * struct ieee80211_eht_mcs_nss_supp_bw - EHT max supported NSS per MCS (except
  1812. * 20MHz only stations).
  1813. *
  1814. * For each field below, bits 0 - 3 indicate the maximal number of spatial
  1815. * streams for Rx, and bits 4 - 7 indicate the maximal number of spatial streams
  1816. * for Tx.
  1817. *
  1818. * @rx_tx_mcs9_max_nss: indicates the maximum number of spatial streams
  1819. * supported for reception and the maximum number of spatial streams
  1820. * supported for transmission for MCS 0 - 9.
  1821. * @rx_tx_mcs11_max_nss: indicates the maximum number of spatial streams
  1822. * supported for reception and the maximum number of spatial streams
  1823. * supported for transmission for MCS 10 - 11.
  1824. * @rx_tx_mcs13_max_nss: indicates the maximum number of spatial streams
  1825. * supported for reception and the maximum number of spatial streams
  1826. * supported for transmission for MCS 12 - 13.
  1827. */
  1828. struct ieee80211_eht_mcs_nss_supp_bw {
  1829. u8 rx_tx_mcs9_max_nss;
  1830. u8 rx_tx_mcs11_max_nss;
  1831. u8 rx_tx_mcs13_max_nss;
  1832. };
  1833. /**
  1834. * struct ieee80211_eht_cap_elem_fixed - EHT capabilities fixed data
  1835. *
  1836. * This structure is the "EHT Capabilities element" fixed fields as
  1837. * described in P802.11be_D2.0 section 9.4.2.313.
  1838. *
  1839. * @mac_cap_info: MAC capabilities, see IEEE80211_EHT_MAC_CAP*
  1840. * @phy_cap_info: PHY capabilities, see IEEE80211_EHT_PHY_CAP*
  1841. */
  1842. struct ieee80211_eht_cap_elem_fixed {
  1843. u8 mac_cap_info[2];
  1844. u8 phy_cap_info[9];
  1845. } __packed;
  1846. /**
  1847. * struct ieee80211_eht_cap_elem - EHT capabilities element
  1848. * @fixed: fixed parts, see &ieee80211_eht_cap_elem_fixed
  1849. * @optional: optional parts
  1850. */
  1851. struct ieee80211_eht_cap_elem {
  1852. struct ieee80211_eht_cap_elem_fixed fixed;
  1853. /*
  1854. * Followed by:
  1855. * Supported EHT-MCS And NSS Set field: 4, 3, 6 or 9 octets.
  1856. * EHT PPE Thresholds field: variable length.
  1857. */
  1858. u8 optional[];
  1859. } __packed;
  1860. #define IEEE80211_EHT_OPER_INFO_PRESENT 0x01
  1861. #define IEEE80211_EHT_OPER_DISABLED_SUBCHANNEL_BITMAP_PRESENT 0x02
  1862. #define IEEE80211_EHT_OPER_EHT_DEF_PE_DURATION 0x04
  1863. #define IEEE80211_EHT_OPER_GROUP_ADDRESSED_BU_IND_LIMIT 0x08
  1864. #define IEEE80211_EHT_OPER_GROUP_ADDRESSED_BU_IND_EXP_MASK 0x30
  1865. /**
  1866. * struct ieee80211_eht_operation - eht operation element
  1867. *
  1868. * This structure is the "EHT Operation Element" fields as
  1869. * described in P802.11be_D2.0 section 9.4.2.311
  1870. *
  1871. * @params: EHT operation element parameters. See &IEEE80211_EHT_OPER_*
  1872. * @basic_mcs_nss: indicates the EHT-MCSs for each number of spatial streams in
  1873. * EHT PPDUs that are supported by all EHT STAs in the BSS in transmit and
  1874. * receive.
  1875. * @optional: optional parts
  1876. */
  1877. struct ieee80211_eht_operation {
  1878. u8 params;
  1879. __le32 basic_mcs_nss;
  1880. u8 optional[];
  1881. } __packed;
  1882. /**
  1883. * struct ieee80211_eht_operation_info - eht operation information
  1884. *
  1885. * @control: EHT operation information control.
  1886. * @ccfs0: defines a channel center frequency for a 20, 40, 80, 160, or 320 MHz
  1887. * EHT BSS.
  1888. * @ccfs1: defines a channel center frequency for a 160 or 320 MHz EHT BSS.
  1889. * @optional: optional parts
  1890. */
  1891. struct ieee80211_eht_operation_info {
  1892. u8 control;
  1893. u8 ccfs0;
  1894. u8 ccfs1;
  1895. u8 optional[];
  1896. } __packed;
  1897. /* 802.11ac VHT Capabilities */
  1898. #define IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895 0x00000000
  1899. #define IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991 0x00000001
  1900. #define IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454 0x00000002
  1901. #define IEEE80211_VHT_CAP_MAX_MPDU_MASK 0x00000003
  1902. #define IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ 0x00000004
  1903. #define IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ 0x00000008
  1904. #define IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK 0x0000000C
  1905. #define IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_SHIFT 2
  1906. #define IEEE80211_VHT_CAP_RXLDPC 0x00000010
  1907. #define IEEE80211_VHT_CAP_SHORT_GI_80 0x00000020
  1908. #define IEEE80211_VHT_CAP_SHORT_GI_160 0x00000040
  1909. #define IEEE80211_VHT_CAP_TXSTBC 0x00000080
  1910. #define IEEE80211_VHT_CAP_RXSTBC_1 0x00000100
  1911. #define IEEE80211_VHT_CAP_RXSTBC_2 0x00000200
  1912. #define IEEE80211_VHT_CAP_RXSTBC_3 0x00000300
  1913. #define IEEE80211_VHT_CAP_RXSTBC_4 0x00000400
  1914. #define IEEE80211_VHT_CAP_RXSTBC_MASK 0x00000700
  1915. #define IEEE80211_VHT_CAP_RXSTBC_SHIFT 8
  1916. #define IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE 0x00000800
  1917. #define IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE 0x00001000
  1918. #define IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT 13
  1919. #define IEEE80211_VHT_CAP_BEAMFORMEE_STS_MASK \
  1920. (7 << IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT)
  1921. #define IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT 16
  1922. #define IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_MASK \
  1923. (7 << IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT)
  1924. #define IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE 0x00080000
  1925. #define IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE 0x00100000
  1926. #define IEEE80211_VHT_CAP_VHT_TXOP_PS 0x00200000
  1927. #define IEEE80211_VHT_CAP_HTC_VHT 0x00400000
  1928. #define IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT 23
  1929. #define IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK \
  1930. (7 << IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT)
  1931. #define IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_UNSOL_MFB 0x08000000
  1932. #define IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB 0x0c000000
  1933. #define IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN 0x10000000
  1934. #define IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN 0x20000000
  1935. #define IEEE80211_VHT_CAP_EXT_NSS_BW_SHIFT 30
  1936. #define IEEE80211_VHT_CAP_EXT_NSS_BW_MASK 0xc0000000
  1937. /**
  1938. * ieee80211_get_vht_max_nss - return max NSS for a given bandwidth/MCS
  1939. * @cap: VHT capabilities of the peer
  1940. * @bw: bandwidth to use
  1941. * @mcs: MCS index to use
  1942. * @ext_nss_bw_capable: indicates whether or not the local transmitter
  1943. * (rate scaling algorithm) can deal with the new logic
  1944. * (dot11VHTExtendedNSSBWCapable)
  1945. * @max_vht_nss: current maximum NSS as advertised by the STA in
  1946. * operating mode notification, can be 0 in which case the
  1947. * capability data will be used to derive this (from MCS support)
  1948. *
  1949. * Due to the VHT Extended NSS Bandwidth Support, the maximum NSS can
  1950. * vary for a given BW/MCS. This function parses the data.
  1951. *
  1952. * Note: This function is exported by cfg80211.
  1953. */
  1954. int ieee80211_get_vht_max_nss(struct ieee80211_vht_cap *cap,
  1955. enum ieee80211_vht_chanwidth bw,
  1956. int mcs, bool ext_nss_bw_capable,
  1957. unsigned int max_vht_nss);
  1958. /**
  1959. * enum ieee80211_ap_reg_power - regulatory power for a Access Point
  1960. *
  1961. * @IEEE80211_REG_UNSET_AP: Access Point has no regulatory power mode
  1962. * @IEEE80211_REG_LPI: Indoor Access Point
  1963. * @IEEE80211_REG_SP: Standard power Access Point
  1964. * @IEEE80211_REG_VLP: Very low power Access Point
  1965. * @IEEE80211_REG_AP_POWER_AFTER_LAST: internal
  1966. * @IEEE80211_REG_AP_POWER_MAX: maximum value
  1967. */
  1968. enum ieee80211_ap_reg_power {
  1969. IEEE80211_REG_UNSET_AP,
  1970. IEEE80211_REG_LPI_AP,
  1971. IEEE80211_REG_SP_AP,
  1972. IEEE80211_REG_VLP_AP,
  1973. IEEE80211_REG_AP_POWER_AFTER_LAST,
  1974. IEEE80211_REG_AP_POWER_MAX =
  1975. IEEE80211_REG_AP_POWER_AFTER_LAST - 1,
  1976. };
  1977. /**
  1978. * enum ieee80211_client_reg_power - regulatory power for a client
  1979. *
  1980. * @IEEE80211_REG_UNSET_CLIENT: Client has no regulatory power mode
  1981. * @IEEE80211_REG_DEFAULT_CLIENT: Default Client
  1982. * @IEEE80211_REG_SUBORDINATE_CLIENT: Subordinate Client
  1983. * @IEEE80211_REG_CLIENT_POWER_AFTER_LAST: internal
  1984. * @IEEE80211_REG_CLIENT_POWER_MAX: maximum value
  1985. */
  1986. enum ieee80211_client_reg_power {
  1987. IEEE80211_REG_UNSET_CLIENT,
  1988. IEEE80211_REG_DEFAULT_CLIENT,
  1989. IEEE80211_REG_SUBORDINATE_CLIENT,
  1990. IEEE80211_REG_CLIENT_POWER_AFTER_LAST,
  1991. IEEE80211_REG_CLIENT_POWER_MAX =
  1992. IEEE80211_REG_CLIENT_POWER_AFTER_LAST - 1,
  1993. };
  1994. /* 802.11ax HE MAC capabilities */
  1995. #define IEEE80211_HE_MAC_CAP0_HTC_HE 0x01
  1996. #define IEEE80211_HE_MAC_CAP0_TWT_REQ 0x02
  1997. #define IEEE80211_HE_MAC_CAP0_TWT_RES 0x04
  1998. #define IEEE80211_HE_MAC_CAP0_DYNAMIC_FRAG_NOT_SUPP 0x00
  1999. #define IEEE80211_HE_MAC_CAP0_DYNAMIC_FRAG_LEVEL_1 0x08
  2000. #define IEEE80211_HE_MAC_CAP0_DYNAMIC_FRAG_LEVEL_2 0x10
  2001. #define IEEE80211_HE_MAC_CAP0_DYNAMIC_FRAG_LEVEL_3 0x18
  2002. #define IEEE80211_HE_MAC_CAP0_DYNAMIC_FRAG_MASK 0x18
  2003. #define IEEE80211_HE_MAC_CAP0_MAX_NUM_FRAG_MSDU_1 0x00
  2004. #define IEEE80211_HE_MAC_CAP0_MAX_NUM_FRAG_MSDU_2 0x20
  2005. #define IEEE80211_HE_MAC_CAP0_MAX_NUM_FRAG_MSDU_4 0x40
  2006. #define IEEE80211_HE_MAC_CAP0_MAX_NUM_FRAG_MSDU_8 0x60
  2007. #define IEEE80211_HE_MAC_CAP0_MAX_NUM_FRAG_MSDU_16 0x80
  2008. #define IEEE80211_HE_MAC_CAP0_MAX_NUM_FRAG_MSDU_32 0xa0
  2009. #define IEEE80211_HE_MAC_CAP0_MAX_NUM_FRAG_MSDU_64 0xc0
  2010. #define IEEE80211_HE_MAC_CAP0_MAX_NUM_FRAG_MSDU_UNLIMITED 0xe0
  2011. #define IEEE80211_HE_MAC_CAP0_MAX_NUM_FRAG_MSDU_MASK 0xe0
  2012. #define IEEE80211_HE_MAC_CAP1_MIN_FRAG_SIZE_UNLIMITED 0x00
  2013. #define IEEE80211_HE_MAC_CAP1_MIN_FRAG_SIZE_128 0x01
  2014. #define IEEE80211_HE_MAC_CAP1_MIN_FRAG_SIZE_256 0x02
  2015. #define IEEE80211_HE_MAC_CAP1_MIN_FRAG_SIZE_512 0x03
  2016. #define IEEE80211_HE_MAC_CAP1_MIN_FRAG_SIZE_MASK 0x03
  2017. #define IEEE80211_HE_MAC_CAP1_TF_MAC_PAD_DUR_0US 0x00
  2018. #define IEEE80211_HE_MAC_CAP1_TF_MAC_PAD_DUR_8US 0x04
  2019. #define IEEE80211_HE_MAC_CAP1_TF_MAC_PAD_DUR_16US 0x08
  2020. #define IEEE80211_HE_MAC_CAP1_TF_MAC_PAD_DUR_MASK 0x0c
  2021. #define IEEE80211_HE_MAC_CAP1_MULTI_TID_AGG_RX_QOS_1 0x00
  2022. #define IEEE80211_HE_MAC_CAP1_MULTI_TID_AGG_RX_QOS_2 0x10
  2023. #define IEEE80211_HE_MAC_CAP1_MULTI_TID_AGG_RX_QOS_3 0x20
  2024. #define IEEE80211_HE_MAC_CAP1_MULTI_TID_AGG_RX_QOS_4 0x30
  2025. #define IEEE80211_HE_MAC_CAP1_MULTI_TID_AGG_RX_QOS_5 0x40
  2026. #define IEEE80211_HE_MAC_CAP1_MULTI_TID_AGG_RX_QOS_6 0x50
  2027. #define IEEE80211_HE_MAC_CAP1_MULTI_TID_AGG_RX_QOS_7 0x60
  2028. #define IEEE80211_HE_MAC_CAP1_MULTI_TID_AGG_RX_QOS_8 0x70
  2029. #define IEEE80211_HE_MAC_CAP1_MULTI_TID_AGG_RX_QOS_MASK 0x70
  2030. /* Link adaptation is split between byte HE_MAC_CAP1 and
  2031. * HE_MAC_CAP2. It should be set only if IEEE80211_HE_MAC_CAP0_HTC_HE
  2032. * in which case the following values apply:
  2033. * 0 = No feedback.
  2034. * 1 = reserved.
  2035. * 2 = Unsolicited feedback.
  2036. * 3 = both
  2037. */
  2038. #define IEEE80211_HE_MAC_CAP1_LINK_ADAPTATION 0x80
  2039. #define IEEE80211_HE_MAC_CAP2_LINK_ADAPTATION 0x01
  2040. #define IEEE80211_HE_MAC_CAP2_ALL_ACK 0x02
  2041. #define IEEE80211_HE_MAC_CAP2_TRS 0x04
  2042. #define IEEE80211_HE_MAC_CAP2_BSR 0x08
  2043. #define IEEE80211_HE_MAC_CAP2_BCAST_TWT 0x10
  2044. #define IEEE80211_HE_MAC_CAP2_32BIT_BA_BITMAP 0x20
  2045. #define IEEE80211_HE_MAC_CAP2_MU_CASCADING 0x40
  2046. #define IEEE80211_HE_MAC_CAP2_ACK_EN 0x80
  2047. #define IEEE80211_HE_MAC_CAP3_OMI_CONTROL 0x02
  2048. #define IEEE80211_HE_MAC_CAP3_OFDMA_RA 0x04
  2049. /* The maximum length of an A-MDPU is defined by the combination of the Maximum
  2050. * A-MDPU Length Exponent field in the HT capabilities, VHT capabilities and the
  2051. * same field in the HE capabilities.
  2052. */
  2053. #define IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_EXT_0 0x00
  2054. #define IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_EXT_1 0x08
  2055. #define IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_EXT_2 0x10
  2056. #define IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_EXT_3 0x18
  2057. #define IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_MASK 0x18
  2058. #define IEEE80211_HE_MAC_CAP3_AMSDU_FRAG 0x20
  2059. #define IEEE80211_HE_MAC_CAP3_FLEX_TWT_SCHED 0x40
  2060. #define IEEE80211_HE_MAC_CAP3_RX_CTRL_FRAME_TO_MULTIBSS 0x80
  2061. #define IEEE80211_HE_MAC_CAP4_BSRP_BQRP_A_MPDU_AGG 0x01
  2062. #define IEEE80211_HE_MAC_CAP4_QTP 0x02
  2063. #define IEEE80211_HE_MAC_CAP4_BQR 0x04
  2064. #define IEEE80211_HE_MAC_CAP4_PSR_RESP 0x08
  2065. #define IEEE80211_HE_MAC_CAP4_NDP_FB_REP 0x10
  2066. #define IEEE80211_HE_MAC_CAP4_OPS 0x20
  2067. #define IEEE80211_HE_MAC_CAP4_AMSDU_IN_AMPDU 0x40
  2068. /* Multi TID agg TX is split between byte #4 and #5
  2069. * The value is a combination of B39,B40,B41
  2070. */
  2071. #define IEEE80211_HE_MAC_CAP4_MULTI_TID_AGG_TX_QOS_B39 0x80
  2072. #define IEEE80211_HE_MAC_CAP5_MULTI_TID_AGG_TX_QOS_B40 0x01
  2073. #define IEEE80211_HE_MAC_CAP5_MULTI_TID_AGG_TX_QOS_B41 0x02
  2074. #define IEEE80211_HE_MAC_CAP5_SUBCHAN_SELECTIVE_TRANSMISSION 0x04
  2075. #define IEEE80211_HE_MAC_CAP5_UL_2x996_TONE_RU 0x08
  2076. #define IEEE80211_HE_MAC_CAP5_OM_CTRL_UL_MU_DATA_DIS_RX 0x10
  2077. #define IEEE80211_HE_MAC_CAP5_HE_DYNAMIC_SM_PS 0x20
  2078. #define IEEE80211_HE_MAC_CAP5_PUNCTURED_SOUNDING 0x40
  2079. #define IEEE80211_HE_MAC_CAP5_HT_VHT_TRIG_FRAME_RX 0x80
  2080. #define IEEE80211_HE_VHT_MAX_AMPDU_FACTOR 20
  2081. #define IEEE80211_HE_HT_MAX_AMPDU_FACTOR 16
  2082. #define IEEE80211_HE_6GHZ_MAX_AMPDU_FACTOR 13
  2083. /* 802.11ax HE PHY capabilities */
  2084. #define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_IN_2G 0x02
  2085. #define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_80MHZ_IN_5G 0x04
  2086. #define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_160MHZ_IN_5G 0x08
  2087. #define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_80PLUS80_MHZ_IN_5G 0x10
  2088. #define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_MASK_ALL 0x1e
  2089. #define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_RU_MAPPING_IN_2G 0x20
  2090. #define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_RU_MAPPING_IN_5G 0x40
  2091. #define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_MASK 0xfe
  2092. #define IEEE80211_HE_PHY_CAP1_PREAMBLE_PUNC_RX_80MHZ_ONLY_SECOND_20MHZ 0x01
  2093. #define IEEE80211_HE_PHY_CAP1_PREAMBLE_PUNC_RX_80MHZ_ONLY_SECOND_40MHZ 0x02
  2094. #define IEEE80211_HE_PHY_CAP1_PREAMBLE_PUNC_RX_160MHZ_ONLY_SECOND_20MHZ 0x04
  2095. #define IEEE80211_HE_PHY_CAP1_PREAMBLE_PUNC_RX_160MHZ_ONLY_SECOND_40MHZ 0x08
  2096. #define IEEE80211_HE_PHY_CAP1_PREAMBLE_PUNC_RX_MASK 0x0f
  2097. #define IEEE80211_HE_PHY_CAP1_DEVICE_CLASS_A 0x10
  2098. #define IEEE80211_HE_PHY_CAP1_LDPC_CODING_IN_PAYLOAD 0x20
  2099. #define IEEE80211_HE_PHY_CAP1_HE_LTF_AND_GI_FOR_HE_PPDUS_0_8US 0x40
  2100. /* Midamble RX/TX Max NSTS is split between byte #2 and byte #3 */
  2101. #define IEEE80211_HE_PHY_CAP1_MIDAMBLE_RX_TX_MAX_NSTS 0x80
  2102. #define IEEE80211_HE_PHY_CAP2_MIDAMBLE_RX_TX_MAX_NSTS 0x01
  2103. #define IEEE80211_HE_PHY_CAP2_NDP_4x_LTF_AND_3_2US 0x02
  2104. #define IEEE80211_HE_PHY_CAP2_STBC_TX_UNDER_80MHZ 0x04
  2105. #define IEEE80211_HE_PHY_CAP2_STBC_RX_UNDER_80MHZ 0x08
  2106. #define IEEE80211_HE_PHY_CAP2_DOPPLER_TX 0x10
  2107. #define IEEE80211_HE_PHY_CAP2_DOPPLER_RX 0x20
  2108. /* Note that the meaning of UL MU below is different between an AP and a non-AP
  2109. * sta, where in the AP case it indicates support for Rx and in the non-AP sta
  2110. * case it indicates support for Tx.
  2111. */
  2112. #define IEEE80211_HE_PHY_CAP2_UL_MU_FULL_MU_MIMO 0x40
  2113. #define IEEE80211_HE_PHY_CAP2_UL_MU_PARTIAL_MU_MIMO 0x80
  2114. #define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_NO_DCM 0x00
  2115. #define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_BPSK 0x01
  2116. #define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_QPSK 0x02
  2117. #define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_16_QAM 0x03
  2118. #define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_MASK 0x03
  2119. #define IEEE80211_HE_PHY_CAP3_DCM_MAX_TX_NSS_1 0x00
  2120. #define IEEE80211_HE_PHY_CAP3_DCM_MAX_TX_NSS_2 0x04
  2121. #define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_NO_DCM 0x00
  2122. #define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_BPSK 0x08
  2123. #define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_QPSK 0x10
  2124. #define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_16_QAM 0x18
  2125. #define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_MASK 0x18
  2126. #define IEEE80211_HE_PHY_CAP3_DCM_MAX_RX_NSS_1 0x00
  2127. #define IEEE80211_HE_PHY_CAP3_DCM_MAX_RX_NSS_2 0x20
  2128. #define IEEE80211_HE_PHY_CAP3_RX_PARTIAL_BW_SU_IN_20MHZ_MU 0x40
  2129. #define IEEE80211_HE_PHY_CAP3_SU_BEAMFORMER 0x80
  2130. #define IEEE80211_HE_PHY_CAP4_SU_BEAMFORMEE 0x01
  2131. #define IEEE80211_HE_PHY_CAP4_MU_BEAMFORMER 0x02
  2132. /* Minimal allowed value of Max STS under 80MHz is 3 */
  2133. #define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_4 0x0c
  2134. #define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_5 0x10
  2135. #define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_6 0x14
  2136. #define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_7 0x18
  2137. #define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_8 0x1c
  2138. #define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_MASK 0x1c
  2139. /* Minimal allowed value of Max STS above 80MHz is 3 */
  2140. #define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_4 0x60
  2141. #define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_5 0x80
  2142. #define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_6 0xa0
  2143. #define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_7 0xc0
  2144. #define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_8 0xe0
  2145. #define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_MASK 0xe0
  2146. #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_1 0x00
  2147. #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_2 0x01
  2148. #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_3 0x02
  2149. #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_4 0x03
  2150. #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_5 0x04
  2151. #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_6 0x05
  2152. #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_7 0x06
  2153. #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_8 0x07
  2154. #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_MASK 0x07
  2155. #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_1 0x00
  2156. #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_2 0x08
  2157. #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_3 0x10
  2158. #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_4 0x18
  2159. #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_5 0x20
  2160. #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_6 0x28
  2161. #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_7 0x30
  2162. #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_8 0x38
  2163. #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_MASK 0x38
  2164. #define IEEE80211_HE_PHY_CAP5_NG16_SU_FEEDBACK 0x40
  2165. #define IEEE80211_HE_PHY_CAP5_NG16_MU_FEEDBACK 0x80
  2166. #define IEEE80211_HE_PHY_CAP6_CODEBOOK_SIZE_42_SU 0x01
  2167. #define IEEE80211_HE_PHY_CAP6_CODEBOOK_SIZE_75_MU 0x02
  2168. #define IEEE80211_HE_PHY_CAP6_TRIG_SU_BEAMFORMING_FB 0x04
  2169. #define IEEE80211_HE_PHY_CAP6_TRIG_MU_BEAMFORMING_PARTIAL_BW_FB 0x08
  2170. #define IEEE80211_HE_PHY_CAP6_TRIG_CQI_FB 0x10
  2171. #define IEEE80211_HE_PHY_CAP6_PARTIAL_BW_EXT_RANGE 0x20
  2172. #define IEEE80211_HE_PHY_CAP6_PARTIAL_BANDWIDTH_DL_MUMIMO 0x40
  2173. #define IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT 0x80
  2174. #define IEEE80211_HE_PHY_CAP7_PSR_BASED_SR 0x01
  2175. #define IEEE80211_HE_PHY_CAP7_POWER_BOOST_FACTOR_SUPP 0x02
  2176. #define IEEE80211_HE_PHY_CAP7_HE_SU_MU_PPDU_4XLTF_AND_08_US_GI 0x04
  2177. #define IEEE80211_HE_PHY_CAP7_MAX_NC_1 0x08
  2178. #define IEEE80211_HE_PHY_CAP7_MAX_NC_2 0x10
  2179. #define IEEE80211_HE_PHY_CAP7_MAX_NC_3 0x18
  2180. #define IEEE80211_HE_PHY_CAP7_MAX_NC_4 0x20
  2181. #define IEEE80211_HE_PHY_CAP7_MAX_NC_5 0x28
  2182. #define IEEE80211_HE_PHY_CAP7_MAX_NC_6 0x30
  2183. #define IEEE80211_HE_PHY_CAP7_MAX_NC_7 0x38
  2184. #define IEEE80211_HE_PHY_CAP7_MAX_NC_MASK 0x38
  2185. #define IEEE80211_HE_PHY_CAP7_STBC_TX_ABOVE_80MHZ 0x40
  2186. #define IEEE80211_HE_PHY_CAP7_STBC_RX_ABOVE_80MHZ 0x80
  2187. #define IEEE80211_HE_PHY_CAP8_HE_ER_SU_PPDU_4XLTF_AND_08_US_GI 0x01
  2188. #define IEEE80211_HE_PHY_CAP8_20MHZ_IN_40MHZ_HE_PPDU_IN_2G 0x02
  2189. #define IEEE80211_HE_PHY_CAP8_20MHZ_IN_160MHZ_HE_PPDU 0x04
  2190. #define IEEE80211_HE_PHY_CAP8_80MHZ_IN_160MHZ_HE_PPDU 0x08
  2191. #define IEEE80211_HE_PHY_CAP8_HE_ER_SU_1XLTF_AND_08_US_GI 0x10
  2192. #define IEEE80211_HE_PHY_CAP8_MIDAMBLE_RX_TX_2X_AND_1XLTF 0x20
  2193. #define IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_242 0x00
  2194. #define IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_484 0x40
  2195. #define IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_996 0x80
  2196. #define IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_2x996 0xc0
  2197. #define IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_MASK 0xc0
  2198. #define IEEE80211_HE_PHY_CAP9_LONGER_THAN_16_SIGB_OFDM_SYM 0x01
  2199. #define IEEE80211_HE_PHY_CAP9_NON_TRIGGERED_CQI_FEEDBACK 0x02
  2200. #define IEEE80211_HE_PHY_CAP9_TX_1024_QAM_LESS_THAN_242_TONE_RU 0x04
  2201. #define IEEE80211_HE_PHY_CAP9_RX_1024_QAM_LESS_THAN_242_TONE_RU 0x08
  2202. #define IEEE80211_HE_PHY_CAP9_RX_FULL_BW_SU_USING_MU_WITH_COMP_SIGB 0x10
  2203. #define IEEE80211_HE_PHY_CAP9_RX_FULL_BW_SU_USING_MU_WITH_NON_COMP_SIGB 0x20
  2204. #define IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_0US 0x0
  2205. #define IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_8US 0x1
  2206. #define IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_16US 0x2
  2207. #define IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_RESERVED 0x3
  2208. #define IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_POS 6
  2209. #define IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_MASK 0xc0
  2210. #define IEEE80211_HE_PHY_CAP10_HE_MU_M1RU_MAX_LTF 0x01
  2211. /* 802.11ax HE TX/RX MCS NSS Support */
  2212. #define IEEE80211_TX_RX_MCS_NSS_SUPP_HIGHEST_MCS_POS (3)
  2213. #define IEEE80211_TX_RX_MCS_NSS_SUPP_TX_BITMAP_POS (6)
  2214. #define IEEE80211_TX_RX_MCS_NSS_SUPP_RX_BITMAP_POS (11)
  2215. #define IEEE80211_TX_RX_MCS_NSS_SUPP_TX_BITMAP_MASK 0x07c0
  2216. #define IEEE80211_TX_RX_MCS_NSS_SUPP_RX_BITMAP_MASK 0xf800
  2217. /* TX/RX HE MCS Support field Highest MCS subfield encoding */
  2218. enum ieee80211_he_highest_mcs_supported_subfield_enc {
  2219. HIGHEST_MCS_SUPPORTED_MCS7 = 0,
  2220. HIGHEST_MCS_SUPPORTED_MCS8,
  2221. HIGHEST_MCS_SUPPORTED_MCS9,
  2222. HIGHEST_MCS_SUPPORTED_MCS10,
  2223. HIGHEST_MCS_SUPPORTED_MCS11,
  2224. };
  2225. /* Calculate 802.11ax HE capabilities IE Tx/Rx HE MCS NSS Support Field size */
  2226. static inline u8
  2227. ieee80211_he_mcs_nss_size(const struct ieee80211_he_cap_elem *he_cap)
  2228. {
  2229. u8 count = 4;
  2230. if (he_cap->phy_cap_info[0] &
  2231. IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_160MHZ_IN_5G)
  2232. count += 4;
  2233. if (he_cap->phy_cap_info[0] &
  2234. IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_80PLUS80_MHZ_IN_5G)
  2235. count += 4;
  2236. return count;
  2237. }
  2238. /* 802.11ax HE PPE Thresholds */
  2239. #define IEEE80211_PPE_THRES_NSS_SUPPORT_2NSS (1)
  2240. #define IEEE80211_PPE_THRES_NSS_POS (0)
  2241. #define IEEE80211_PPE_THRES_NSS_MASK (7)
  2242. #define IEEE80211_PPE_THRES_RU_INDEX_BITMASK_2x966_AND_966_RU \
  2243. (BIT(5) | BIT(6))
  2244. #define IEEE80211_PPE_THRES_RU_INDEX_BITMASK_MASK 0x78
  2245. #define IEEE80211_PPE_THRES_RU_INDEX_BITMASK_POS (3)
  2246. #define IEEE80211_PPE_THRES_INFO_PPET_SIZE (3)
  2247. #define IEEE80211_HE_PPE_THRES_INFO_HEADER_SIZE (7)
  2248. /*
  2249. * Calculate 802.11ax HE capabilities IE PPE field size
  2250. * Input: Header byte of ppe_thres (first byte), and HE capa IE's PHY cap u8*
  2251. */
  2252. static inline u8
  2253. ieee80211_he_ppe_size(u8 ppe_thres_hdr, const u8 *phy_cap_info)
  2254. {
  2255. u8 n;
  2256. if ((phy_cap_info[6] &
  2257. IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT) == 0)
  2258. return 0;
  2259. n = hweight8(ppe_thres_hdr &
  2260. IEEE80211_PPE_THRES_RU_INDEX_BITMASK_MASK);
  2261. n *= (1 + ((ppe_thres_hdr & IEEE80211_PPE_THRES_NSS_MASK) >>
  2262. IEEE80211_PPE_THRES_NSS_POS));
  2263. /*
  2264. * Each pair is 6 bits, and we need to add the 7 "header" bits to the
  2265. * total size.
  2266. */
  2267. n = (n * IEEE80211_PPE_THRES_INFO_PPET_SIZE * 2) + 7;
  2268. n = DIV_ROUND_UP(n, 8);
  2269. return n;
  2270. }
  2271. static inline bool ieee80211_he_capa_size_ok(const u8 *data, u8 len)
  2272. {
  2273. const struct ieee80211_he_cap_elem *he_cap_ie_elem = (const void *)data;
  2274. u8 needed = sizeof(*he_cap_ie_elem);
  2275. if (len < needed)
  2276. return false;
  2277. needed += ieee80211_he_mcs_nss_size(he_cap_ie_elem);
  2278. if (len < needed)
  2279. return false;
  2280. if (he_cap_ie_elem->phy_cap_info[6] &
  2281. IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT) {
  2282. if (len < needed + 1)
  2283. return false;
  2284. needed += ieee80211_he_ppe_size(data[needed],
  2285. he_cap_ie_elem->phy_cap_info);
  2286. }
  2287. return len >= needed;
  2288. }
  2289. /* HE Operation defines */
  2290. #define IEEE80211_HE_OPERATION_DFLT_PE_DURATION_MASK 0x00000007
  2291. #define IEEE80211_HE_OPERATION_TWT_REQUIRED 0x00000008
  2292. #define IEEE80211_HE_OPERATION_RTS_THRESHOLD_MASK 0x00003ff0
  2293. #define IEEE80211_HE_OPERATION_RTS_THRESHOLD_OFFSET 4
  2294. #define IEEE80211_HE_OPERATION_VHT_OPER_INFO 0x00004000
  2295. #define IEEE80211_HE_OPERATION_CO_HOSTED_BSS 0x00008000
  2296. #define IEEE80211_HE_OPERATION_ER_SU_DISABLE 0x00010000
  2297. #define IEEE80211_HE_OPERATION_6GHZ_OP_INFO 0x00020000
  2298. #define IEEE80211_HE_OPERATION_BSS_COLOR_MASK 0x3f000000
  2299. #define IEEE80211_HE_OPERATION_BSS_COLOR_OFFSET 24
  2300. #define IEEE80211_HE_OPERATION_PARTIAL_BSS_COLOR 0x40000000
  2301. #define IEEE80211_HE_OPERATION_BSS_COLOR_DISABLED 0x80000000
  2302. #define IEEE80211_6GHZ_CTRL_REG_LPI_AP 0
  2303. #define IEEE80211_6GHZ_CTRL_REG_SP_AP 1
  2304. /**
  2305. * ieee80211_he_6ghz_oper - HE 6 GHz operation Information field
  2306. * @primary: primary channel
  2307. * @control: control flags
  2308. * @ccfs0: channel center frequency segment 0
  2309. * @ccfs1: channel center frequency segment 1
  2310. * @minrate: minimum rate (in 1 Mbps units)
  2311. */
  2312. struct ieee80211_he_6ghz_oper {
  2313. u8 primary;
  2314. #define IEEE80211_HE_6GHZ_OPER_CTRL_CHANWIDTH 0x3
  2315. #define IEEE80211_HE_6GHZ_OPER_CTRL_CHANWIDTH_20MHZ 0
  2316. #define IEEE80211_HE_6GHZ_OPER_CTRL_CHANWIDTH_40MHZ 1
  2317. #define IEEE80211_HE_6GHZ_OPER_CTRL_CHANWIDTH_80MHZ 2
  2318. #define IEEE80211_HE_6GHZ_OPER_CTRL_CHANWIDTH_160MHZ 3
  2319. #define IEEE80211_HE_6GHZ_OPER_CTRL_DUP_BEACON 0x4
  2320. #define IEEE80211_HE_6GHZ_OPER_CTRL_REG_INFO 0x38
  2321. u8 control;
  2322. u8 ccfs0;
  2323. u8 ccfs1;
  2324. u8 minrate;
  2325. } __packed;
  2326. /*
  2327. * In "9.4.2.161 Transmit Power Envelope element" of "IEEE Std 802.11ax-2021",
  2328. * it show four types in "Table 9-275a-Maximum Transmit Power Interpretation
  2329. * subfield encoding", and two category for each type in "Table E-12-Regulatory
  2330. * Info subfield encoding in the United States".
  2331. * So it it totally max 8 Transmit Power Envelope element.
  2332. */
  2333. #define IEEE80211_TPE_MAX_IE_COUNT 8
  2334. /*
  2335. * In "Table 9-277—Meaning of Maximum Transmit Power Count subfield"
  2336. * of "IEEE Std 802.11ax™‐2021", the max power level is 8.
  2337. */
  2338. #define IEEE80211_MAX_NUM_PWR_LEVEL 8
  2339. #define IEEE80211_TPE_MAX_POWER_COUNT 8
  2340. /* transmit power interpretation type of transmit power envelope element */
  2341. enum ieee80211_tx_power_intrpt_type {
  2342. IEEE80211_TPE_LOCAL_EIRP,
  2343. IEEE80211_TPE_LOCAL_EIRP_PSD,
  2344. IEEE80211_TPE_REG_CLIENT_EIRP,
  2345. IEEE80211_TPE_REG_CLIENT_EIRP_PSD,
  2346. };
  2347. /**
  2348. * struct ieee80211_tx_pwr_env
  2349. *
  2350. * This structure represents the "Transmit Power Envelope element"
  2351. */
  2352. struct ieee80211_tx_pwr_env {
  2353. u8 tx_power_info;
  2354. s8 tx_power[IEEE80211_TPE_MAX_POWER_COUNT];
  2355. } __packed;
  2356. #define IEEE80211_TX_PWR_ENV_INFO_COUNT 0x7
  2357. #define IEEE80211_TX_PWR_ENV_INFO_INTERPRET 0x38
  2358. #define IEEE80211_TX_PWR_ENV_INFO_CATEGORY 0xC0
  2359. /*
  2360. * ieee80211_he_oper_size - calculate 802.11ax HE Operations IE size
  2361. * @he_oper_ie: byte data of the He Operations IE, stating from the byte
  2362. * after the ext ID byte. It is assumed that he_oper_ie has at least
  2363. * sizeof(struct ieee80211_he_operation) bytes, the caller must have
  2364. * validated this.
  2365. * @return the actual size of the IE data (not including header), or 0 on error
  2366. */
  2367. static inline u8
  2368. ieee80211_he_oper_size(const u8 *he_oper_ie)
  2369. {
  2370. const struct ieee80211_he_operation *he_oper = (const void *)he_oper_ie;
  2371. u8 oper_len = sizeof(struct ieee80211_he_operation);
  2372. u32 he_oper_params;
  2373. /* Make sure the input is not NULL */
  2374. if (!he_oper_ie)
  2375. return 0;
  2376. /* Calc required length */
  2377. he_oper_params = le32_to_cpu(he_oper->he_oper_params);
  2378. if (he_oper_params & IEEE80211_HE_OPERATION_VHT_OPER_INFO)
  2379. oper_len += 3;
  2380. if (he_oper_params & IEEE80211_HE_OPERATION_CO_HOSTED_BSS)
  2381. oper_len++;
  2382. if (he_oper_params & IEEE80211_HE_OPERATION_6GHZ_OP_INFO)
  2383. oper_len += sizeof(struct ieee80211_he_6ghz_oper);
  2384. /* Add the first byte (extension ID) to the total length */
  2385. oper_len++;
  2386. return oper_len;
  2387. }
  2388. /**
  2389. * ieee80211_he_6ghz_oper - obtain 6 GHz operation field
  2390. * @he_oper: HE operation element (must be pre-validated for size)
  2391. * but may be %NULL
  2392. *
  2393. * Return: a pointer to the 6 GHz operation field, or %NULL
  2394. */
  2395. static inline const struct ieee80211_he_6ghz_oper *
  2396. ieee80211_he_6ghz_oper(const struct ieee80211_he_operation *he_oper)
  2397. {
  2398. const u8 *ret = (const void *)&he_oper->optional;
  2399. u32 he_oper_params;
  2400. if (!he_oper)
  2401. return NULL;
  2402. he_oper_params = le32_to_cpu(he_oper->he_oper_params);
  2403. if (!(he_oper_params & IEEE80211_HE_OPERATION_6GHZ_OP_INFO))
  2404. return NULL;
  2405. if (he_oper_params & IEEE80211_HE_OPERATION_VHT_OPER_INFO)
  2406. ret += 3;
  2407. if (he_oper_params & IEEE80211_HE_OPERATION_CO_HOSTED_BSS)
  2408. ret++;
  2409. return (const void *)ret;
  2410. }
  2411. /* HE Spatial Reuse defines */
  2412. #define IEEE80211_HE_SPR_PSR_DISALLOWED BIT(0)
  2413. #define IEEE80211_HE_SPR_NON_SRG_OBSS_PD_SR_DISALLOWED BIT(1)
  2414. #define IEEE80211_HE_SPR_NON_SRG_OFFSET_PRESENT BIT(2)
  2415. #define IEEE80211_HE_SPR_SRG_INFORMATION_PRESENT BIT(3)
  2416. #define IEEE80211_HE_SPR_HESIGA_SR_VAL15_ALLOWED BIT(4)
  2417. /*
  2418. * ieee80211_he_spr_size - calculate 802.11ax HE Spatial Reuse IE size
  2419. * @he_spr_ie: byte data of the He Spatial Reuse IE, stating from the byte
  2420. * after the ext ID byte. It is assumed that he_spr_ie has at least
  2421. * sizeof(struct ieee80211_he_spr) bytes, the caller must have validated
  2422. * this
  2423. * @return the actual size of the IE data (not including header), or 0 on error
  2424. */
  2425. static inline u8
  2426. ieee80211_he_spr_size(const u8 *he_spr_ie)
  2427. {
  2428. const struct ieee80211_he_spr *he_spr = (const void *)he_spr_ie;
  2429. u8 spr_len = sizeof(struct ieee80211_he_spr);
  2430. u8 he_spr_params;
  2431. /* Make sure the input is not NULL */
  2432. if (!he_spr_ie)
  2433. return 0;
  2434. /* Calc required length */
  2435. he_spr_params = he_spr->he_sr_control;
  2436. if (he_spr_params & IEEE80211_HE_SPR_NON_SRG_OFFSET_PRESENT)
  2437. spr_len++;
  2438. if (he_spr_params & IEEE80211_HE_SPR_SRG_INFORMATION_PRESENT)
  2439. spr_len += 18;
  2440. /* Add the first byte (extension ID) to the total length */
  2441. spr_len++;
  2442. return spr_len;
  2443. }
  2444. /* S1G Capabilities Information field */
  2445. #define IEEE80211_S1G_CAPABILITY_LEN 15
  2446. #define S1G_CAP0_S1G_LONG BIT(0)
  2447. #define S1G_CAP0_SGI_1MHZ BIT(1)
  2448. #define S1G_CAP0_SGI_2MHZ BIT(2)
  2449. #define S1G_CAP0_SGI_4MHZ BIT(3)
  2450. #define S1G_CAP0_SGI_8MHZ BIT(4)
  2451. #define S1G_CAP0_SGI_16MHZ BIT(5)
  2452. #define S1G_CAP0_SUPP_CH_WIDTH GENMASK(7, 6)
  2453. #define S1G_SUPP_CH_WIDTH_2 0
  2454. #define S1G_SUPP_CH_WIDTH_4 1
  2455. #define S1G_SUPP_CH_WIDTH_8 2
  2456. #define S1G_SUPP_CH_WIDTH_16 3
  2457. #define S1G_SUPP_CH_WIDTH_MAX(cap) ((1 << FIELD_GET(S1G_CAP0_SUPP_CH_WIDTH, \
  2458. cap[0])) << 1)
  2459. #define S1G_CAP1_RX_LDPC BIT(0)
  2460. #define S1G_CAP1_TX_STBC BIT(1)
  2461. #define S1G_CAP1_RX_STBC BIT(2)
  2462. #define S1G_CAP1_SU_BFER BIT(3)
  2463. #define S1G_CAP1_SU_BFEE BIT(4)
  2464. #define S1G_CAP1_BFEE_STS GENMASK(7, 5)
  2465. #define S1G_CAP2_SOUNDING_DIMENSIONS GENMASK(2, 0)
  2466. #define S1G_CAP2_MU_BFER BIT(3)
  2467. #define S1G_CAP2_MU_BFEE BIT(4)
  2468. #define S1G_CAP2_PLUS_HTC_VHT BIT(5)
  2469. #define S1G_CAP2_TRAVELING_PILOT GENMASK(7, 6)
  2470. #define S1G_CAP3_RD_RESPONDER BIT(0)
  2471. #define S1G_CAP3_HT_DELAYED_BA BIT(1)
  2472. #define S1G_CAP3_MAX_MPDU_LEN BIT(2)
  2473. #define S1G_CAP3_MAX_AMPDU_LEN_EXP GENMASK(4, 3)
  2474. #define S1G_CAP3_MIN_MPDU_START GENMASK(7, 5)
  2475. #define S1G_CAP4_UPLINK_SYNC BIT(0)
  2476. #define S1G_CAP4_DYNAMIC_AID BIT(1)
  2477. #define S1G_CAP4_BAT BIT(2)
  2478. #define S1G_CAP4_TIME_ADE BIT(3)
  2479. #define S1G_CAP4_NON_TIM BIT(4)
  2480. #define S1G_CAP4_GROUP_AID BIT(5)
  2481. #define S1G_CAP4_STA_TYPE GENMASK(7, 6)
  2482. #define S1G_CAP5_CENT_AUTH_CONTROL BIT(0)
  2483. #define S1G_CAP5_DIST_AUTH_CONTROL BIT(1)
  2484. #define S1G_CAP5_AMSDU BIT(2)
  2485. #define S1G_CAP5_AMPDU BIT(3)
  2486. #define S1G_CAP5_ASYMMETRIC_BA BIT(4)
  2487. #define S1G_CAP5_FLOW_CONTROL BIT(5)
  2488. #define S1G_CAP5_SECTORIZED_BEAM GENMASK(7, 6)
  2489. #define S1G_CAP6_OBSS_MITIGATION BIT(0)
  2490. #define S1G_CAP6_FRAGMENT_BA BIT(1)
  2491. #define S1G_CAP6_NDP_PS_POLL BIT(2)
  2492. #define S1G_CAP6_RAW_OPERATION BIT(3)
  2493. #define S1G_CAP6_PAGE_SLICING BIT(4)
  2494. #define S1G_CAP6_TXOP_SHARING_IMP_ACK BIT(5)
  2495. #define S1G_CAP6_VHT_LINK_ADAPT GENMASK(7, 6)
  2496. #define S1G_CAP7_TACK_AS_PS_POLL BIT(0)
  2497. #define S1G_CAP7_DUP_1MHZ BIT(1)
  2498. #define S1G_CAP7_MCS_NEGOTIATION BIT(2)
  2499. #define S1G_CAP7_1MHZ_CTL_RESPONSE_PREAMBLE BIT(3)
  2500. #define S1G_CAP7_NDP_BFING_REPORT_POLL BIT(4)
  2501. #define S1G_CAP7_UNSOLICITED_DYN_AID BIT(5)
  2502. #define S1G_CAP7_SECTOR_TRAINING_OPERATION BIT(6)
  2503. #define S1G_CAP7_TEMP_PS_MODE_SWITCH BIT(7)
  2504. #define S1G_CAP8_TWT_GROUPING BIT(0)
  2505. #define S1G_CAP8_BDT BIT(1)
  2506. #define S1G_CAP8_COLOR GENMASK(4, 2)
  2507. #define S1G_CAP8_TWT_REQUEST BIT(5)
  2508. #define S1G_CAP8_TWT_RESPOND BIT(6)
  2509. #define S1G_CAP8_PV1_FRAME BIT(7)
  2510. #define S1G_CAP9_LINK_ADAPT_PER_CONTROL_RESPONSE BIT(0)
  2511. #define S1G_OPER_CH_WIDTH_PRIMARY_1MHZ BIT(0)
  2512. #define S1G_OPER_CH_WIDTH_OPER GENMASK(4, 1)
  2513. /* EHT MAC capabilities as defined in P802.11be_D2.0 section 9.4.2.313.2 */
  2514. #define IEEE80211_EHT_MAC_CAP0_EPCS_PRIO_ACCESS 0x01
  2515. #define IEEE80211_EHT_MAC_CAP0_OM_CONTROL 0x02
  2516. #define IEEE80211_EHT_MAC_CAP0_TRIG_TXOP_SHARING_MODE1 0x04
  2517. #define IEEE80211_EHT_MAC_CAP0_TRIG_TXOP_SHARING_MODE2 0x08
  2518. #define IEEE80211_EHT_MAC_CAP0_RESTRICTED_TWT 0x10
  2519. #define IEEE80211_EHT_MAC_CAP0_SCS_TRAFFIC_DESC 0x20
  2520. #define IEEE80211_EHT_MAC_CAP0_MAX_MPDU_LEN_MASK 0xc0
  2521. #define IEEE80211_EHT_MAC_CAP0_MAX_MPDU_LEN_3895 0
  2522. #define IEEE80211_EHT_MAC_CAP0_MAX_MPDU_LEN_7991 1
  2523. #define IEEE80211_EHT_MAC_CAP0_MAX_MPDU_LEN_11454 2
  2524. #define IEEE80211_EHT_MAC_CAP1_MAX_AMPDU_LEN_MASK 0x01
  2525. /* EHT PHY capabilities as defined in P802.11be_D2.0 section 9.4.2.313.3 */
  2526. #define IEEE80211_EHT_PHY_CAP0_320MHZ_IN_6GHZ 0x02
  2527. #define IEEE80211_EHT_PHY_CAP0_242_TONE_RU_GT20MHZ 0x04
  2528. #define IEEE80211_EHT_PHY_CAP0_NDP_4_EHT_LFT_32_GI 0x08
  2529. #define IEEE80211_EHT_PHY_CAP0_PARTIAL_BW_UL_MU_MIMO 0x10
  2530. #define IEEE80211_EHT_PHY_CAP0_SU_BEAMFORMER 0x20
  2531. #define IEEE80211_EHT_PHY_CAP0_SU_BEAMFORMEE 0x40
  2532. /* EHT beamformee number of spatial streams <= 80MHz is split */
  2533. #define IEEE80211_EHT_PHY_CAP0_BEAMFORMEE_SS_80MHZ_MASK 0x80
  2534. #define IEEE80211_EHT_PHY_CAP1_BEAMFORMEE_SS_80MHZ_MASK 0x03
  2535. #define IEEE80211_EHT_PHY_CAP1_BEAMFORMEE_SS_160MHZ_MASK 0x1c
  2536. #define IEEE80211_EHT_PHY_CAP1_BEAMFORMEE_SS_320MHZ_MASK 0xe0
  2537. #define IEEE80211_EHT_PHY_CAP2_SOUNDING_DIM_80MHZ_MASK 0x07
  2538. #define IEEE80211_EHT_PHY_CAP2_SOUNDING_DIM_160MHZ_MASK 0x38
  2539. /* EHT number of sounding dimensions for 320MHz is split */
  2540. #define IEEE80211_EHT_PHY_CAP2_SOUNDING_DIM_320MHZ_MASK 0xc0
  2541. #define IEEE80211_EHT_PHY_CAP3_SOUNDING_DIM_320MHZ_MASK 0x01
  2542. #define IEEE80211_EHT_PHY_CAP3_NG_16_SU_FEEDBACK 0x02
  2543. #define IEEE80211_EHT_PHY_CAP3_NG_16_MU_FEEDBACK 0x04
  2544. #define IEEE80211_EHT_PHY_CAP3_CODEBOOK_4_2_SU_FDBK 0x08
  2545. #define IEEE80211_EHT_PHY_CAP3_CODEBOOK_7_5_MU_FDBK 0x10
  2546. #define IEEE80211_EHT_PHY_CAP3_TRIG_SU_BF_FDBK 0x20
  2547. #define IEEE80211_EHT_PHY_CAP3_TRIG_MU_BF_PART_BW_FDBK 0x40
  2548. #define IEEE80211_EHT_PHY_CAP3_TRIG_CQI_FDBK 0x80
  2549. #define IEEE80211_EHT_PHY_CAP4_PART_BW_DL_MU_MIMO 0x01
  2550. #define IEEE80211_EHT_PHY_CAP4_PSR_SR_SUPP 0x02
  2551. #define IEEE80211_EHT_PHY_CAP4_POWER_BOOST_FACT_SUPP 0x04
  2552. #define IEEE80211_EHT_PHY_CAP4_EHT_MU_PPDU_4_EHT_LTF_08_GI 0x08
  2553. #define IEEE80211_EHT_PHY_CAP4_MAX_NC_MASK 0xf0
  2554. #define IEEE80211_EHT_PHY_CAP5_NON_TRIG_CQI_FEEDBACK 0x01
  2555. #define IEEE80211_EHT_PHY_CAP5_TX_LESS_242_TONE_RU_SUPP 0x02
  2556. #define IEEE80211_EHT_PHY_CAP5_RX_LESS_242_TONE_RU_SUPP 0x04
  2557. #define IEEE80211_EHT_PHY_CAP5_PPE_THRESHOLD_PRESENT 0x08
  2558. #define IEEE80211_EHT_PHY_CAP5_COMMON_NOMINAL_PKT_PAD_MASK 0x30
  2559. #define IEEE80211_EHT_PHY_CAP5_COMMON_NOMINAL_PKT_PAD_0US 0
  2560. #define IEEE80211_EHT_PHY_CAP5_COMMON_NOMINAL_PKT_PAD_8US 1
  2561. #define IEEE80211_EHT_PHY_CAP5_COMMON_NOMINAL_PKT_PAD_16US 2
  2562. #define IEEE80211_EHT_PHY_CAP5_COMMON_NOMINAL_PKT_PAD_20US 3
  2563. /* Maximum number of supported EHT LTF is split */
  2564. #define IEEE80211_EHT_PHY_CAP5_MAX_NUM_SUPP_EHT_LTF_MASK 0xc0
  2565. #define IEEE80211_EHT_PHY_CAP6_MAX_NUM_SUPP_EHT_LTF_MASK 0x07
  2566. #define IEEE80211_EHT_PHY_CAP6_MCS15_SUPP_MASK 0x78
  2567. #define IEEE80211_EHT_PHY_CAP6_EHT_DUP_6GHZ_SUPP 0x80
  2568. #define IEEE80211_EHT_PHY_CAP7_20MHZ_STA_RX_NDP_WIDER_BW 0x01
  2569. #define IEEE80211_EHT_PHY_CAP7_NON_OFDMA_UL_MU_MIMO_80MHZ 0x02
  2570. #define IEEE80211_EHT_PHY_CAP7_NON_OFDMA_UL_MU_MIMO_160MHZ 0x04
  2571. #define IEEE80211_EHT_PHY_CAP7_NON_OFDMA_UL_MU_MIMO_320MHZ 0x08
  2572. #define IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_80MHZ 0x10
  2573. #define IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_160MHZ 0x20
  2574. #define IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_320MHZ 0x40
  2575. #define IEEE80211_EHT_PHY_CAP7_TB_SOUNDING_FDBK_RATE_LIMIT 0x80
  2576. #define IEEE80211_EHT_PHY_CAP8_RX_1024QAM_WIDER_BW_DL_OFDMA 0x01
  2577. #define IEEE80211_EHT_PHY_CAP8_RX_4096QAM_WIDER_BW_DL_OFDMA 0x02
  2578. /*
  2579. * EHT operation channel width as defined in P802.11be_D2.0 section 9.4.2.311
  2580. */
  2581. #define IEEE80211_EHT_OPER_CHAN_WIDTH 0x7
  2582. #define IEEE80211_EHT_OPER_CHAN_WIDTH_20MHZ 0
  2583. #define IEEE80211_EHT_OPER_CHAN_WIDTH_40MHZ 1
  2584. #define IEEE80211_EHT_OPER_CHAN_WIDTH_80MHZ 2
  2585. #define IEEE80211_EHT_OPER_CHAN_WIDTH_160MHZ 3
  2586. #define IEEE80211_EHT_OPER_CHAN_WIDTH_320MHZ 4
  2587. /* Calculate 802.11be EHT capabilities IE Tx/Rx EHT MCS NSS Support Field size */
  2588. static inline u8
  2589. ieee80211_eht_mcs_nss_size(const struct ieee80211_he_cap_elem *he_cap,
  2590. const struct ieee80211_eht_cap_elem_fixed *eht_cap,
  2591. bool from_ap)
  2592. {
  2593. u8 count = 0;
  2594. /* on 2.4 GHz, if it supports 40 MHz, the result is 3 */
  2595. if (he_cap->phy_cap_info[0] &
  2596. IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_IN_2G)
  2597. return 3;
  2598. /* on 2.4 GHz, these three bits are reserved, so should be 0 */
  2599. if (he_cap->phy_cap_info[0] &
  2600. IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_80MHZ_IN_5G)
  2601. count += 3;
  2602. if (he_cap->phy_cap_info[0] &
  2603. IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_160MHZ_IN_5G)
  2604. count += 3;
  2605. if (eht_cap->phy_cap_info[0] & IEEE80211_EHT_PHY_CAP0_320MHZ_IN_6GHZ)
  2606. count += 3;
  2607. if (count)
  2608. return count;
  2609. return from_ap ? 3 : 4;
  2610. }
  2611. /* 802.11be EHT PPE Thresholds */
  2612. #define IEEE80211_EHT_PPE_THRES_NSS_POS 0
  2613. #define IEEE80211_EHT_PPE_THRES_NSS_MASK 0xf
  2614. #define IEEE80211_EHT_PPE_THRES_RU_INDEX_BITMASK_MASK 0x1f0
  2615. #define IEEE80211_EHT_PPE_THRES_INFO_PPET_SIZE 3
  2616. #define IEEE80211_EHT_PPE_THRES_INFO_HEADER_SIZE 9
  2617. /*
  2618. * Calculate 802.11be EHT capabilities IE EHT field size
  2619. */
  2620. static inline u8
  2621. ieee80211_eht_ppe_size(u16 ppe_thres_hdr, const u8 *phy_cap_info)
  2622. {
  2623. u32 n;
  2624. if (!(phy_cap_info[5] &
  2625. IEEE80211_EHT_PHY_CAP5_PPE_THRESHOLD_PRESENT))
  2626. return 0;
  2627. n = hweight16(ppe_thres_hdr &
  2628. IEEE80211_EHT_PPE_THRES_RU_INDEX_BITMASK_MASK);
  2629. n *= 1 + u16_get_bits(ppe_thres_hdr, IEEE80211_EHT_PPE_THRES_NSS_MASK);
  2630. /*
  2631. * Each pair is 6 bits, and we need to add the 9 "header" bits to the
  2632. * total size.
  2633. */
  2634. n = n * IEEE80211_EHT_PPE_THRES_INFO_PPET_SIZE * 2 +
  2635. IEEE80211_EHT_PPE_THRES_INFO_HEADER_SIZE;
  2636. return DIV_ROUND_UP(n, 8);
  2637. }
  2638. static inline bool
  2639. ieee80211_eht_capa_size_ok(const u8 *he_capa, const u8 *data, u8 len,
  2640. bool from_ap)
  2641. {
  2642. const struct ieee80211_eht_cap_elem_fixed *elem = (const void *)data;
  2643. u8 needed = sizeof(struct ieee80211_eht_cap_elem_fixed);
  2644. if (len < needed || !he_capa)
  2645. return false;
  2646. needed += ieee80211_eht_mcs_nss_size((const void *)he_capa,
  2647. (const void *)data,
  2648. from_ap);
  2649. if (len < needed)
  2650. return false;
  2651. if (elem->phy_cap_info[5] &
  2652. IEEE80211_EHT_PHY_CAP5_PPE_THRESHOLD_PRESENT) {
  2653. u16 ppe_thres_hdr;
  2654. if (len < needed + sizeof(ppe_thres_hdr))
  2655. return false;
  2656. ppe_thres_hdr = get_unaligned_le16(data + needed);
  2657. needed += ieee80211_eht_ppe_size(ppe_thres_hdr,
  2658. elem->phy_cap_info);
  2659. }
  2660. return len >= needed;
  2661. }
  2662. static inline bool
  2663. ieee80211_eht_oper_size_ok(const u8 *data, u8 len)
  2664. {
  2665. const struct ieee80211_eht_operation *elem = (const void *)data;
  2666. u8 needed = sizeof(*elem);
  2667. if (len < needed)
  2668. return false;
  2669. if (elem->params & IEEE80211_EHT_OPER_INFO_PRESENT) {
  2670. needed += 3;
  2671. if (elem->params &
  2672. IEEE80211_EHT_OPER_DISABLED_SUBCHANNEL_BITMAP_PRESENT)
  2673. needed += 2;
  2674. }
  2675. return len >= needed;
  2676. }
  2677. #define LISTEN_INT_USF GENMASK(15, 14)
  2678. #define LISTEN_INT_UI GENMASK(13, 0)
  2679. #define IEEE80211_MAX_USF FIELD_MAX(LISTEN_INT_USF)
  2680. #define IEEE80211_MAX_UI FIELD_MAX(LISTEN_INT_UI)
  2681. /* Authentication algorithms */
  2682. #define WLAN_AUTH_OPEN 0
  2683. #define WLAN_AUTH_SHARED_KEY 1
  2684. #define WLAN_AUTH_FT 2
  2685. #define WLAN_AUTH_SAE 3
  2686. #define WLAN_AUTH_FILS_SK 4
  2687. #define WLAN_AUTH_FILS_SK_PFS 5
  2688. #define WLAN_AUTH_FILS_PK 6
  2689. #define WLAN_AUTH_LEAP 128
  2690. #define WLAN_AUTH_CHALLENGE_LEN 128
  2691. #define WLAN_CAPABILITY_ESS (1<<0)
  2692. #define WLAN_CAPABILITY_IBSS (1<<1)
  2693. /*
  2694. * A mesh STA sets the ESS and IBSS capability bits to zero.
  2695. * however, this holds true for p2p probe responses (in the p2p_find
  2696. * phase) as well.
  2697. */
  2698. #define WLAN_CAPABILITY_IS_STA_BSS(cap) \
  2699. (!((cap) & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS)))
  2700. #define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
  2701. #define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
  2702. #define WLAN_CAPABILITY_PRIVACY (1<<4)
  2703. #define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
  2704. #define WLAN_CAPABILITY_PBCC (1<<6)
  2705. #define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
  2706. /* 802.11h */
  2707. #define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8)
  2708. #define WLAN_CAPABILITY_QOS (1<<9)
  2709. #define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10)
  2710. #define WLAN_CAPABILITY_APSD (1<<11)
  2711. #define WLAN_CAPABILITY_RADIO_MEASURE (1<<12)
  2712. #define WLAN_CAPABILITY_DSSS_OFDM (1<<13)
  2713. #define WLAN_CAPABILITY_DEL_BACK (1<<14)
  2714. #define WLAN_CAPABILITY_IMM_BACK (1<<15)
  2715. /* DMG (60gHz) 802.11ad */
  2716. /* type - bits 0..1 */
  2717. #define WLAN_CAPABILITY_DMG_TYPE_MASK (3<<0)
  2718. #define WLAN_CAPABILITY_DMG_TYPE_IBSS (1<<0) /* Tx by: STA */
  2719. #define WLAN_CAPABILITY_DMG_TYPE_PBSS (2<<0) /* Tx by: PCP */
  2720. #define WLAN_CAPABILITY_DMG_TYPE_AP (3<<0) /* Tx by: AP */
  2721. #define WLAN_CAPABILITY_DMG_CBAP_ONLY (1<<2)
  2722. #define WLAN_CAPABILITY_DMG_CBAP_SOURCE (1<<3)
  2723. #define WLAN_CAPABILITY_DMG_PRIVACY (1<<4)
  2724. #define WLAN_CAPABILITY_DMG_ECPAC (1<<5)
  2725. #define WLAN_CAPABILITY_DMG_SPECTRUM_MGMT (1<<8)
  2726. #define WLAN_CAPABILITY_DMG_RADIO_MEASURE (1<<12)
  2727. /* measurement */
  2728. #define IEEE80211_SPCT_MSR_RPRT_MODE_LATE (1<<0)
  2729. #define IEEE80211_SPCT_MSR_RPRT_MODE_INCAPABLE (1<<1)
  2730. #define IEEE80211_SPCT_MSR_RPRT_MODE_REFUSED (1<<2)
  2731. #define IEEE80211_SPCT_MSR_RPRT_TYPE_BASIC 0
  2732. #define IEEE80211_SPCT_MSR_RPRT_TYPE_CCA 1
  2733. #define IEEE80211_SPCT_MSR_RPRT_TYPE_RPI 2
  2734. #define IEEE80211_SPCT_MSR_RPRT_TYPE_LCI 8
  2735. #define IEEE80211_SPCT_MSR_RPRT_TYPE_CIVIC 11
  2736. /* 802.11g ERP information element */
  2737. #define WLAN_ERP_NON_ERP_PRESENT (1<<0)
  2738. #define WLAN_ERP_USE_PROTECTION (1<<1)
  2739. #define WLAN_ERP_BARKER_PREAMBLE (1<<2)
  2740. /* WLAN_ERP_BARKER_PREAMBLE values */
  2741. enum {
  2742. WLAN_ERP_PREAMBLE_SHORT = 0,
  2743. WLAN_ERP_PREAMBLE_LONG = 1,
  2744. };
  2745. /* Band ID, 802.11ad #8.4.1.45 */
  2746. enum {
  2747. IEEE80211_BANDID_TV_WS = 0, /* TV white spaces */
  2748. IEEE80211_BANDID_SUB1 = 1, /* Sub-1 GHz (excluding TV white spaces) */
  2749. IEEE80211_BANDID_2G = 2, /* 2.4 GHz */
  2750. IEEE80211_BANDID_3G = 3, /* 3.6 GHz */
  2751. IEEE80211_BANDID_5G = 4, /* 4.9 and 5 GHz */
  2752. IEEE80211_BANDID_60G = 5, /* 60 GHz */
  2753. };
  2754. /* Status codes */
  2755. enum ieee80211_statuscode {
  2756. WLAN_STATUS_SUCCESS = 0,
  2757. WLAN_STATUS_UNSPECIFIED_FAILURE = 1,
  2758. WLAN_STATUS_CAPS_UNSUPPORTED = 10,
  2759. WLAN_STATUS_REASSOC_NO_ASSOC = 11,
  2760. WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12,
  2761. WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13,
  2762. WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14,
  2763. WLAN_STATUS_CHALLENGE_FAIL = 15,
  2764. WLAN_STATUS_AUTH_TIMEOUT = 16,
  2765. WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17,
  2766. WLAN_STATUS_ASSOC_DENIED_RATES = 18,
  2767. /* 802.11b */
  2768. WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19,
  2769. WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20,
  2770. WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21,
  2771. /* 802.11h */
  2772. WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22,
  2773. WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23,
  2774. WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24,
  2775. /* 802.11g */
  2776. WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25,
  2777. WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26,
  2778. /* 802.11w */
  2779. WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY = 30,
  2780. WLAN_STATUS_ROBUST_MGMT_FRAME_POLICY_VIOLATION = 31,
  2781. /* 802.11i */
  2782. WLAN_STATUS_INVALID_IE = 40,
  2783. WLAN_STATUS_INVALID_GROUP_CIPHER = 41,
  2784. WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42,
  2785. WLAN_STATUS_INVALID_AKMP = 43,
  2786. WLAN_STATUS_UNSUPP_RSN_VERSION = 44,
  2787. WLAN_STATUS_INVALID_RSN_IE_CAP = 45,
  2788. WLAN_STATUS_CIPHER_SUITE_REJECTED = 46,
  2789. /* 802.11e */
  2790. WLAN_STATUS_UNSPECIFIED_QOS = 32,
  2791. WLAN_STATUS_ASSOC_DENIED_NOBANDWIDTH = 33,
  2792. WLAN_STATUS_ASSOC_DENIED_LOWACK = 34,
  2793. WLAN_STATUS_ASSOC_DENIED_UNSUPP_QOS = 35,
  2794. WLAN_STATUS_REQUEST_DECLINED = 37,
  2795. WLAN_STATUS_INVALID_QOS_PARAM = 38,
  2796. WLAN_STATUS_CHANGE_TSPEC = 39,
  2797. WLAN_STATUS_WAIT_TS_DELAY = 47,
  2798. WLAN_STATUS_NO_DIRECT_LINK = 48,
  2799. WLAN_STATUS_STA_NOT_PRESENT = 49,
  2800. WLAN_STATUS_STA_NOT_QSTA = 50,
  2801. /* 802.11s */
  2802. WLAN_STATUS_ANTI_CLOG_REQUIRED = 76,
  2803. WLAN_STATUS_FCG_NOT_SUPP = 78,
  2804. WLAN_STATUS_STA_NO_TBTT = 78,
  2805. /* 802.11ad */
  2806. WLAN_STATUS_REJECTED_WITH_SUGGESTED_CHANGES = 39,
  2807. WLAN_STATUS_REJECTED_FOR_DELAY_PERIOD = 47,
  2808. WLAN_STATUS_REJECT_WITH_SCHEDULE = 83,
  2809. WLAN_STATUS_PENDING_ADMITTING_FST_SESSION = 86,
  2810. WLAN_STATUS_PERFORMING_FST_NOW = 87,
  2811. WLAN_STATUS_PENDING_GAP_IN_BA_WINDOW = 88,
  2812. WLAN_STATUS_REJECT_U_PID_SETTING = 89,
  2813. WLAN_STATUS_REJECT_DSE_BAND = 96,
  2814. WLAN_STATUS_DENIED_WITH_SUGGESTED_BAND_AND_CHANNEL = 99,
  2815. WLAN_STATUS_DENIED_DUE_TO_SPECTRUM_MANAGEMENT = 103,
  2816. /* 802.11ai */
  2817. WLAN_STATUS_FILS_AUTHENTICATION_FAILURE = 108,
  2818. WLAN_STATUS_UNKNOWN_AUTHENTICATION_SERVER = 109,
  2819. WLAN_STATUS_SAE_HASH_TO_ELEMENT = 126,
  2820. WLAN_STATUS_SAE_PK = 127,
  2821. };
  2822. /* Reason codes */
  2823. enum ieee80211_reasoncode {
  2824. WLAN_REASON_UNSPECIFIED = 1,
  2825. WLAN_REASON_PREV_AUTH_NOT_VALID = 2,
  2826. WLAN_REASON_DEAUTH_LEAVING = 3,
  2827. WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4,
  2828. WLAN_REASON_DISASSOC_AP_BUSY = 5,
  2829. WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6,
  2830. WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7,
  2831. WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8,
  2832. WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9,
  2833. /* 802.11h */
  2834. WLAN_REASON_DISASSOC_BAD_POWER = 10,
  2835. WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11,
  2836. /* 802.11i */
  2837. WLAN_REASON_INVALID_IE = 13,
  2838. WLAN_REASON_MIC_FAILURE = 14,
  2839. WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15,
  2840. WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16,
  2841. WLAN_REASON_IE_DIFFERENT = 17,
  2842. WLAN_REASON_INVALID_GROUP_CIPHER = 18,
  2843. WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19,
  2844. WLAN_REASON_INVALID_AKMP = 20,
  2845. WLAN_REASON_UNSUPP_RSN_VERSION = 21,
  2846. WLAN_REASON_INVALID_RSN_IE_CAP = 22,
  2847. WLAN_REASON_IEEE8021X_FAILED = 23,
  2848. WLAN_REASON_CIPHER_SUITE_REJECTED = 24,
  2849. /* TDLS (802.11z) */
  2850. WLAN_REASON_TDLS_TEARDOWN_UNREACHABLE = 25,
  2851. WLAN_REASON_TDLS_TEARDOWN_UNSPECIFIED = 26,
  2852. /* 802.11e */
  2853. WLAN_REASON_DISASSOC_UNSPECIFIED_QOS = 32,
  2854. WLAN_REASON_DISASSOC_QAP_NO_BANDWIDTH = 33,
  2855. WLAN_REASON_DISASSOC_LOW_ACK = 34,
  2856. WLAN_REASON_DISASSOC_QAP_EXCEED_TXOP = 35,
  2857. WLAN_REASON_QSTA_LEAVE_QBSS = 36,
  2858. WLAN_REASON_QSTA_NOT_USE = 37,
  2859. WLAN_REASON_QSTA_REQUIRE_SETUP = 38,
  2860. WLAN_REASON_QSTA_TIMEOUT = 39,
  2861. WLAN_REASON_QSTA_CIPHER_NOT_SUPP = 45,
  2862. /* 802.11s */
  2863. WLAN_REASON_MESH_PEER_CANCELED = 52,
  2864. WLAN_REASON_MESH_MAX_PEERS = 53,
  2865. WLAN_REASON_MESH_CONFIG = 54,
  2866. WLAN_REASON_MESH_CLOSE = 55,
  2867. WLAN_REASON_MESH_MAX_RETRIES = 56,
  2868. WLAN_REASON_MESH_CONFIRM_TIMEOUT = 57,
  2869. WLAN_REASON_MESH_INVALID_GTK = 58,
  2870. WLAN_REASON_MESH_INCONSISTENT_PARAM = 59,
  2871. WLAN_REASON_MESH_INVALID_SECURITY = 60,
  2872. WLAN_REASON_MESH_PATH_ERROR = 61,
  2873. WLAN_REASON_MESH_PATH_NOFORWARD = 62,
  2874. WLAN_REASON_MESH_PATH_DEST_UNREACHABLE = 63,
  2875. WLAN_REASON_MAC_EXISTS_IN_MBSS = 64,
  2876. WLAN_REASON_MESH_CHAN_REGULATORY = 65,
  2877. WLAN_REASON_MESH_CHAN = 66,
  2878. };
  2879. /* Information Element IDs */
  2880. enum ieee80211_eid {
  2881. WLAN_EID_SSID = 0,
  2882. WLAN_EID_SUPP_RATES = 1,
  2883. WLAN_EID_FH_PARAMS = 2, /* reserved now */
  2884. WLAN_EID_DS_PARAMS = 3,
  2885. WLAN_EID_CF_PARAMS = 4,
  2886. WLAN_EID_TIM = 5,
  2887. WLAN_EID_IBSS_PARAMS = 6,
  2888. WLAN_EID_COUNTRY = 7,
  2889. /* 8, 9 reserved */
  2890. WLAN_EID_REQUEST = 10,
  2891. WLAN_EID_QBSS_LOAD = 11,
  2892. WLAN_EID_EDCA_PARAM_SET = 12,
  2893. WLAN_EID_TSPEC = 13,
  2894. WLAN_EID_TCLAS = 14,
  2895. WLAN_EID_SCHEDULE = 15,
  2896. WLAN_EID_CHALLENGE = 16,
  2897. /* 17-31 reserved for challenge text extension */
  2898. WLAN_EID_PWR_CONSTRAINT = 32,
  2899. WLAN_EID_PWR_CAPABILITY = 33,
  2900. WLAN_EID_TPC_REQUEST = 34,
  2901. WLAN_EID_TPC_REPORT = 35,
  2902. WLAN_EID_SUPPORTED_CHANNELS = 36,
  2903. WLAN_EID_CHANNEL_SWITCH = 37,
  2904. WLAN_EID_MEASURE_REQUEST = 38,
  2905. WLAN_EID_MEASURE_REPORT = 39,
  2906. WLAN_EID_QUIET = 40,
  2907. WLAN_EID_IBSS_DFS = 41,
  2908. WLAN_EID_ERP_INFO = 42,
  2909. WLAN_EID_TS_DELAY = 43,
  2910. WLAN_EID_TCLAS_PROCESSING = 44,
  2911. WLAN_EID_HT_CAPABILITY = 45,
  2912. WLAN_EID_QOS_CAPA = 46,
  2913. /* 47 reserved for Broadcom */
  2914. WLAN_EID_RSN = 48,
  2915. WLAN_EID_802_15_COEX = 49,
  2916. WLAN_EID_EXT_SUPP_RATES = 50,
  2917. WLAN_EID_AP_CHAN_REPORT = 51,
  2918. WLAN_EID_NEIGHBOR_REPORT = 52,
  2919. WLAN_EID_RCPI = 53,
  2920. WLAN_EID_MOBILITY_DOMAIN = 54,
  2921. WLAN_EID_FAST_BSS_TRANSITION = 55,
  2922. WLAN_EID_TIMEOUT_INTERVAL = 56,
  2923. WLAN_EID_RIC_DATA = 57,
  2924. WLAN_EID_DSE_REGISTERED_LOCATION = 58,
  2925. WLAN_EID_SUPPORTED_REGULATORY_CLASSES = 59,
  2926. WLAN_EID_EXT_CHANSWITCH_ANN = 60,
  2927. WLAN_EID_HT_OPERATION = 61,
  2928. WLAN_EID_SECONDARY_CHANNEL_OFFSET = 62,
  2929. WLAN_EID_BSS_AVG_ACCESS_DELAY = 63,
  2930. WLAN_EID_ANTENNA_INFO = 64,
  2931. WLAN_EID_RSNI = 65,
  2932. WLAN_EID_MEASUREMENT_PILOT_TX_INFO = 66,
  2933. WLAN_EID_BSS_AVAILABLE_CAPACITY = 67,
  2934. WLAN_EID_BSS_AC_ACCESS_DELAY = 68,
  2935. WLAN_EID_TIME_ADVERTISEMENT = 69,
  2936. WLAN_EID_RRM_ENABLED_CAPABILITIES = 70,
  2937. WLAN_EID_MULTIPLE_BSSID = 71,
  2938. WLAN_EID_BSS_COEX_2040 = 72,
  2939. WLAN_EID_BSS_INTOLERANT_CHL_REPORT = 73,
  2940. WLAN_EID_OVERLAP_BSS_SCAN_PARAM = 74,
  2941. WLAN_EID_RIC_DESCRIPTOR = 75,
  2942. WLAN_EID_MMIE = 76,
  2943. WLAN_EID_ASSOC_COMEBACK_TIME = 77,
  2944. WLAN_EID_EVENT_REQUEST = 78,
  2945. WLAN_EID_EVENT_REPORT = 79,
  2946. WLAN_EID_DIAGNOSTIC_REQUEST = 80,
  2947. WLAN_EID_DIAGNOSTIC_REPORT = 81,
  2948. WLAN_EID_LOCATION_PARAMS = 82,
  2949. WLAN_EID_NON_TX_BSSID_CAP = 83,
  2950. WLAN_EID_SSID_LIST = 84,
  2951. WLAN_EID_MULTI_BSSID_IDX = 85,
  2952. WLAN_EID_FMS_DESCRIPTOR = 86,
  2953. WLAN_EID_FMS_REQUEST = 87,
  2954. WLAN_EID_FMS_RESPONSE = 88,
  2955. WLAN_EID_QOS_TRAFFIC_CAPA = 89,
  2956. WLAN_EID_BSS_MAX_IDLE_PERIOD = 90,
  2957. WLAN_EID_TSF_REQUEST = 91,
  2958. WLAN_EID_TSF_RESPOSNE = 92,
  2959. WLAN_EID_WNM_SLEEP_MODE = 93,
  2960. WLAN_EID_TIM_BCAST_REQ = 94,
  2961. WLAN_EID_TIM_BCAST_RESP = 95,
  2962. WLAN_EID_COLL_IF_REPORT = 96,
  2963. WLAN_EID_CHANNEL_USAGE = 97,
  2964. WLAN_EID_TIME_ZONE = 98,
  2965. WLAN_EID_DMS_REQUEST = 99,
  2966. WLAN_EID_DMS_RESPONSE = 100,
  2967. WLAN_EID_LINK_ID = 101,
  2968. WLAN_EID_WAKEUP_SCHEDUL = 102,
  2969. /* 103 reserved */
  2970. WLAN_EID_CHAN_SWITCH_TIMING = 104,
  2971. WLAN_EID_PTI_CONTROL = 105,
  2972. WLAN_EID_PU_BUFFER_STATUS = 106,
  2973. WLAN_EID_INTERWORKING = 107,
  2974. WLAN_EID_ADVERTISEMENT_PROTOCOL = 108,
  2975. WLAN_EID_EXPEDITED_BW_REQ = 109,
  2976. WLAN_EID_QOS_MAP_SET = 110,
  2977. WLAN_EID_ROAMING_CONSORTIUM = 111,
  2978. WLAN_EID_EMERGENCY_ALERT = 112,
  2979. WLAN_EID_MESH_CONFIG = 113,
  2980. WLAN_EID_MESH_ID = 114,
  2981. WLAN_EID_LINK_METRIC_REPORT = 115,
  2982. WLAN_EID_CONGESTION_NOTIFICATION = 116,
  2983. WLAN_EID_PEER_MGMT = 117,
  2984. WLAN_EID_CHAN_SWITCH_PARAM = 118,
  2985. WLAN_EID_MESH_AWAKE_WINDOW = 119,
  2986. WLAN_EID_BEACON_TIMING = 120,
  2987. WLAN_EID_MCCAOP_SETUP_REQ = 121,
  2988. WLAN_EID_MCCAOP_SETUP_RESP = 122,
  2989. WLAN_EID_MCCAOP_ADVERT = 123,
  2990. WLAN_EID_MCCAOP_TEARDOWN = 124,
  2991. WLAN_EID_GANN = 125,
  2992. WLAN_EID_RANN = 126,
  2993. WLAN_EID_EXT_CAPABILITY = 127,
  2994. /* 128, 129 reserved for Agere */
  2995. WLAN_EID_PREQ = 130,
  2996. WLAN_EID_PREP = 131,
  2997. WLAN_EID_PERR = 132,
  2998. /* 133-136 reserved for Cisco */
  2999. WLAN_EID_PXU = 137,
  3000. WLAN_EID_PXUC = 138,
  3001. WLAN_EID_AUTH_MESH_PEER_EXCH = 139,
  3002. WLAN_EID_MIC = 140,
  3003. WLAN_EID_DESTINATION_URI = 141,
  3004. WLAN_EID_UAPSD_COEX = 142,
  3005. WLAN_EID_WAKEUP_SCHEDULE = 143,
  3006. WLAN_EID_EXT_SCHEDULE = 144,
  3007. WLAN_EID_STA_AVAILABILITY = 145,
  3008. WLAN_EID_DMG_TSPEC = 146,
  3009. WLAN_EID_DMG_AT = 147,
  3010. WLAN_EID_DMG_CAP = 148,
  3011. /* 149 reserved for Cisco */
  3012. WLAN_EID_CISCO_VENDOR_SPECIFIC = 150,
  3013. WLAN_EID_DMG_OPERATION = 151,
  3014. WLAN_EID_DMG_BSS_PARAM_CHANGE = 152,
  3015. WLAN_EID_DMG_BEAM_REFINEMENT = 153,
  3016. WLAN_EID_CHANNEL_MEASURE_FEEDBACK = 154,
  3017. /* 155-156 reserved for Cisco */
  3018. WLAN_EID_AWAKE_WINDOW = 157,
  3019. WLAN_EID_MULTI_BAND = 158,
  3020. WLAN_EID_ADDBA_EXT = 159,
  3021. WLAN_EID_NEXT_PCP_LIST = 160,
  3022. WLAN_EID_PCP_HANDOVER = 161,
  3023. WLAN_EID_DMG_LINK_MARGIN = 162,
  3024. WLAN_EID_SWITCHING_STREAM = 163,
  3025. WLAN_EID_SESSION_TRANSITION = 164,
  3026. WLAN_EID_DYN_TONE_PAIRING_REPORT = 165,
  3027. WLAN_EID_CLUSTER_REPORT = 166,
  3028. WLAN_EID_RELAY_CAP = 167,
  3029. WLAN_EID_RELAY_XFER_PARAM_SET = 168,
  3030. WLAN_EID_BEAM_LINK_MAINT = 169,
  3031. WLAN_EID_MULTIPLE_MAC_ADDR = 170,
  3032. WLAN_EID_U_PID = 171,
  3033. WLAN_EID_DMG_LINK_ADAPT_ACK = 172,
  3034. /* 173 reserved for Symbol */
  3035. WLAN_EID_MCCAOP_ADV_OVERVIEW = 174,
  3036. WLAN_EID_QUIET_PERIOD_REQ = 175,
  3037. /* 176 reserved for Symbol */
  3038. WLAN_EID_QUIET_PERIOD_RESP = 177,
  3039. /* 178-179 reserved for Symbol */
  3040. /* 180 reserved for ISO/IEC 20011 */
  3041. WLAN_EID_EPAC_POLICY = 182,
  3042. WLAN_EID_CLISTER_TIME_OFF = 183,
  3043. WLAN_EID_INTER_AC_PRIO = 184,
  3044. WLAN_EID_SCS_DESCRIPTOR = 185,
  3045. WLAN_EID_QLOAD_REPORT = 186,
  3046. WLAN_EID_HCCA_TXOP_UPDATE_COUNT = 187,
  3047. WLAN_EID_HL_STREAM_ID = 188,
  3048. WLAN_EID_GCR_GROUP_ADDR = 189,
  3049. WLAN_EID_ANTENNA_SECTOR_ID_PATTERN = 190,
  3050. WLAN_EID_VHT_CAPABILITY = 191,
  3051. WLAN_EID_VHT_OPERATION = 192,
  3052. WLAN_EID_EXTENDED_BSS_LOAD = 193,
  3053. WLAN_EID_WIDE_BW_CHANNEL_SWITCH = 194,
  3054. WLAN_EID_TX_POWER_ENVELOPE = 195,
  3055. WLAN_EID_CHANNEL_SWITCH_WRAPPER = 196,
  3056. WLAN_EID_AID = 197,
  3057. WLAN_EID_QUIET_CHANNEL = 198,
  3058. WLAN_EID_OPMODE_NOTIF = 199,
  3059. WLAN_EID_REDUCED_NEIGHBOR_REPORT = 201,
  3060. WLAN_EID_AID_REQUEST = 210,
  3061. WLAN_EID_AID_RESPONSE = 211,
  3062. WLAN_EID_S1G_BCN_COMPAT = 213,
  3063. WLAN_EID_S1G_SHORT_BCN_INTERVAL = 214,
  3064. WLAN_EID_S1G_TWT = 216,
  3065. WLAN_EID_S1G_CAPABILITIES = 217,
  3066. WLAN_EID_VENDOR_SPECIFIC = 221,
  3067. WLAN_EID_QOS_PARAMETER = 222,
  3068. WLAN_EID_S1G_OPERATION = 232,
  3069. WLAN_EID_CAG_NUMBER = 237,
  3070. WLAN_EID_AP_CSN = 239,
  3071. WLAN_EID_FILS_INDICATION = 240,
  3072. WLAN_EID_DILS = 241,
  3073. WLAN_EID_FRAGMENT = 242,
  3074. WLAN_EID_RSNX = 244,
  3075. WLAN_EID_EXTENSION = 255
  3076. };
  3077. /* Element ID Extensions for Element ID 255 */
  3078. enum ieee80211_eid_ext {
  3079. WLAN_EID_EXT_ASSOC_DELAY_INFO = 1,
  3080. WLAN_EID_EXT_FILS_REQ_PARAMS = 2,
  3081. WLAN_EID_EXT_FILS_KEY_CONFIRM = 3,
  3082. WLAN_EID_EXT_FILS_SESSION = 4,
  3083. WLAN_EID_EXT_FILS_HLP_CONTAINER = 5,
  3084. WLAN_EID_EXT_FILS_IP_ADDR_ASSIGN = 6,
  3085. WLAN_EID_EXT_KEY_DELIVERY = 7,
  3086. WLAN_EID_EXT_FILS_WRAPPED_DATA = 8,
  3087. WLAN_EID_EXT_FILS_PUBLIC_KEY = 12,
  3088. WLAN_EID_EXT_FILS_NONCE = 13,
  3089. WLAN_EID_EXT_FUTURE_CHAN_GUIDANCE = 14,
  3090. WLAN_EID_EXT_HE_CAPABILITY = 35,
  3091. WLAN_EID_EXT_HE_OPERATION = 36,
  3092. WLAN_EID_EXT_UORA = 37,
  3093. WLAN_EID_EXT_HE_MU_EDCA = 38,
  3094. WLAN_EID_EXT_HE_SPR = 39,
  3095. WLAN_EID_EXT_NDP_FEEDBACK_REPORT_PARAMSET = 41,
  3096. WLAN_EID_EXT_BSS_COLOR_CHG_ANN = 42,
  3097. WLAN_EID_EXT_QUIET_TIME_PERIOD_SETUP = 43,
  3098. WLAN_EID_EXT_ESS_REPORT = 45,
  3099. WLAN_EID_EXT_OPS = 46,
  3100. WLAN_EID_EXT_HE_BSS_LOAD = 47,
  3101. WLAN_EID_EXT_MAX_CHANNEL_SWITCH_TIME = 52,
  3102. WLAN_EID_EXT_MULTIPLE_BSSID_CONFIGURATION = 55,
  3103. WLAN_EID_EXT_NON_INHERITANCE = 56,
  3104. WLAN_EID_EXT_KNOWN_BSSID = 57,
  3105. WLAN_EID_EXT_SHORT_SSID_LIST = 58,
  3106. WLAN_EID_EXT_HE_6GHZ_CAPA = 59,
  3107. WLAN_EID_EXT_UL_MU_POWER_CAPA = 60,
  3108. WLAN_EID_EXT_EHT_OPERATION = 106,
  3109. WLAN_EID_EXT_EHT_MULTI_LINK = 107,
  3110. WLAN_EID_EXT_EHT_CAPABILITY = 108,
  3111. };
  3112. /* Action category code */
  3113. enum ieee80211_category {
  3114. WLAN_CATEGORY_SPECTRUM_MGMT = 0,
  3115. WLAN_CATEGORY_QOS = 1,
  3116. WLAN_CATEGORY_DLS = 2,
  3117. WLAN_CATEGORY_BACK = 3,
  3118. WLAN_CATEGORY_PUBLIC = 4,
  3119. WLAN_CATEGORY_RADIO_MEASUREMENT = 5,
  3120. WLAN_CATEGORY_FAST_BBS_TRANSITION = 6,
  3121. WLAN_CATEGORY_HT = 7,
  3122. WLAN_CATEGORY_SA_QUERY = 8,
  3123. WLAN_CATEGORY_PROTECTED_DUAL_OF_ACTION = 9,
  3124. WLAN_CATEGORY_WNM = 10,
  3125. WLAN_CATEGORY_WNM_UNPROTECTED = 11,
  3126. WLAN_CATEGORY_TDLS = 12,
  3127. WLAN_CATEGORY_MESH_ACTION = 13,
  3128. WLAN_CATEGORY_MULTIHOP_ACTION = 14,
  3129. WLAN_CATEGORY_SELF_PROTECTED = 15,
  3130. WLAN_CATEGORY_DMG = 16,
  3131. WLAN_CATEGORY_WMM = 17,
  3132. WLAN_CATEGORY_FST = 18,
  3133. WLAN_CATEGORY_UNPROT_DMG = 20,
  3134. WLAN_CATEGORY_VHT = 21,
  3135. WLAN_CATEGORY_S1G = 22,
  3136. WLAN_CATEGORY_VENDOR_SPECIFIC_PROTECTED = 126,
  3137. WLAN_CATEGORY_VENDOR_SPECIFIC = 127,
  3138. };
  3139. /* SPECTRUM_MGMT action code */
  3140. enum ieee80211_spectrum_mgmt_actioncode {
  3141. WLAN_ACTION_SPCT_MSR_REQ = 0,
  3142. WLAN_ACTION_SPCT_MSR_RPRT = 1,
  3143. WLAN_ACTION_SPCT_TPC_REQ = 2,
  3144. WLAN_ACTION_SPCT_TPC_RPRT = 3,
  3145. WLAN_ACTION_SPCT_CHL_SWITCH = 4,
  3146. };
  3147. /* HT action codes */
  3148. enum ieee80211_ht_actioncode {
  3149. WLAN_HT_ACTION_NOTIFY_CHANWIDTH = 0,
  3150. WLAN_HT_ACTION_SMPS = 1,
  3151. WLAN_HT_ACTION_PSMP = 2,
  3152. WLAN_HT_ACTION_PCO_PHASE = 3,
  3153. WLAN_HT_ACTION_CSI = 4,
  3154. WLAN_HT_ACTION_NONCOMPRESSED_BF = 5,
  3155. WLAN_HT_ACTION_COMPRESSED_BF = 6,
  3156. WLAN_HT_ACTION_ASEL_IDX_FEEDBACK = 7,
  3157. };
  3158. /* VHT action codes */
  3159. enum ieee80211_vht_actioncode {
  3160. WLAN_VHT_ACTION_COMPRESSED_BF = 0,
  3161. WLAN_VHT_ACTION_GROUPID_MGMT = 1,
  3162. WLAN_VHT_ACTION_OPMODE_NOTIF = 2,
  3163. };
  3164. /* Self Protected Action codes */
  3165. enum ieee80211_self_protected_actioncode {
  3166. WLAN_SP_RESERVED = 0,
  3167. WLAN_SP_MESH_PEERING_OPEN = 1,
  3168. WLAN_SP_MESH_PEERING_CONFIRM = 2,
  3169. WLAN_SP_MESH_PEERING_CLOSE = 3,
  3170. WLAN_SP_MGK_INFORM = 4,
  3171. WLAN_SP_MGK_ACK = 5,
  3172. };
  3173. /* Mesh action codes */
  3174. enum ieee80211_mesh_actioncode {
  3175. WLAN_MESH_ACTION_LINK_METRIC_REPORT,
  3176. WLAN_MESH_ACTION_HWMP_PATH_SELECTION,
  3177. WLAN_MESH_ACTION_GATE_ANNOUNCEMENT,
  3178. WLAN_MESH_ACTION_CONGESTION_CONTROL_NOTIFICATION,
  3179. WLAN_MESH_ACTION_MCCA_SETUP_REQUEST,
  3180. WLAN_MESH_ACTION_MCCA_SETUP_REPLY,
  3181. WLAN_MESH_ACTION_MCCA_ADVERTISEMENT_REQUEST,
  3182. WLAN_MESH_ACTION_MCCA_ADVERTISEMENT,
  3183. WLAN_MESH_ACTION_MCCA_TEARDOWN,
  3184. WLAN_MESH_ACTION_TBTT_ADJUSTMENT_REQUEST,
  3185. WLAN_MESH_ACTION_TBTT_ADJUSTMENT_RESPONSE,
  3186. };
  3187. /* Unprotected WNM action codes */
  3188. enum ieee80211_unprotected_wnm_actioncode {
  3189. WLAN_UNPROTECTED_WNM_ACTION_TIM = 0,
  3190. WLAN_UNPROTECTED_WNM_ACTION_TIMING_MEASUREMENT_RESPONSE = 1,
  3191. };
  3192. /* Public action codes */
  3193. enum ieee80211_public_actioncode {
  3194. WLAN_PUBLIC_ACTION_FTM_RESPONSE = 33,
  3195. };
  3196. /* Security key length */
  3197. enum ieee80211_key_len {
  3198. WLAN_KEY_LEN_WEP40 = 5,
  3199. WLAN_KEY_LEN_WEP104 = 13,
  3200. WLAN_KEY_LEN_CCMP = 16,
  3201. WLAN_KEY_LEN_CCMP_256 = 32,
  3202. WLAN_KEY_LEN_TKIP = 32,
  3203. WLAN_KEY_LEN_AES_CMAC = 16,
  3204. WLAN_KEY_LEN_SMS4 = 32,
  3205. WLAN_KEY_LEN_GCMP = 16,
  3206. WLAN_KEY_LEN_GCMP_256 = 32,
  3207. WLAN_KEY_LEN_BIP_CMAC_256 = 32,
  3208. WLAN_KEY_LEN_BIP_GMAC_128 = 16,
  3209. WLAN_KEY_LEN_BIP_GMAC_256 = 32,
  3210. };
  3211. enum ieee80211_s1g_actioncode {
  3212. WLAN_S1G_AID_SWITCH_REQUEST,
  3213. WLAN_S1G_AID_SWITCH_RESPONSE,
  3214. WLAN_S1G_SYNC_CONTROL,
  3215. WLAN_S1G_STA_INFO_ANNOUNCE,
  3216. WLAN_S1G_EDCA_PARAM_SET,
  3217. WLAN_S1G_EL_OPERATION,
  3218. WLAN_S1G_TWT_SETUP,
  3219. WLAN_S1G_TWT_TEARDOWN,
  3220. WLAN_S1G_SECT_GROUP_ID_LIST,
  3221. WLAN_S1G_SECT_ID_FEEDBACK,
  3222. WLAN_S1G_TWT_INFORMATION = 11,
  3223. };
  3224. #define IEEE80211_WEP_IV_LEN 4
  3225. #define IEEE80211_WEP_ICV_LEN 4
  3226. #define IEEE80211_CCMP_HDR_LEN 8
  3227. #define IEEE80211_CCMP_MIC_LEN 8
  3228. #define IEEE80211_CCMP_PN_LEN 6
  3229. #define IEEE80211_CCMP_256_HDR_LEN 8
  3230. #define IEEE80211_CCMP_256_MIC_LEN 16
  3231. #define IEEE80211_CCMP_256_PN_LEN 6
  3232. #define IEEE80211_TKIP_IV_LEN 8
  3233. #define IEEE80211_TKIP_ICV_LEN 4
  3234. #define IEEE80211_CMAC_PN_LEN 6
  3235. #define IEEE80211_GMAC_PN_LEN 6
  3236. #define IEEE80211_GCMP_HDR_LEN 8
  3237. #define IEEE80211_GCMP_MIC_LEN 16
  3238. #define IEEE80211_GCMP_PN_LEN 6
  3239. #define FILS_NONCE_LEN 16
  3240. #define FILS_MAX_KEK_LEN 64
  3241. #define FILS_ERP_MAX_USERNAME_LEN 16
  3242. #define FILS_ERP_MAX_REALM_LEN 253
  3243. #define FILS_ERP_MAX_RRK_LEN 64
  3244. #define PMK_MAX_LEN 64
  3245. #define SAE_PASSWORD_MAX_LEN 128
  3246. /* Public action codes (IEEE Std 802.11-2016, 9.6.8.1, Table 9-307) */
  3247. enum ieee80211_pub_actioncode {
  3248. WLAN_PUB_ACTION_20_40_BSS_COEX = 0,
  3249. WLAN_PUB_ACTION_DSE_ENABLEMENT = 1,
  3250. WLAN_PUB_ACTION_DSE_DEENABLEMENT = 2,
  3251. WLAN_PUB_ACTION_DSE_REG_LOC_ANN = 3,
  3252. WLAN_PUB_ACTION_EXT_CHANSW_ANN = 4,
  3253. WLAN_PUB_ACTION_DSE_MSMT_REQ = 5,
  3254. WLAN_PUB_ACTION_DSE_MSMT_RESP = 6,
  3255. WLAN_PUB_ACTION_MSMT_PILOT = 7,
  3256. WLAN_PUB_ACTION_DSE_PC = 8,
  3257. WLAN_PUB_ACTION_VENDOR_SPECIFIC = 9,
  3258. WLAN_PUB_ACTION_GAS_INITIAL_REQ = 10,
  3259. WLAN_PUB_ACTION_GAS_INITIAL_RESP = 11,
  3260. WLAN_PUB_ACTION_GAS_COMEBACK_REQ = 12,
  3261. WLAN_PUB_ACTION_GAS_COMEBACK_RESP = 13,
  3262. WLAN_PUB_ACTION_TDLS_DISCOVER_RES = 14,
  3263. WLAN_PUB_ACTION_LOC_TRACK_NOTI = 15,
  3264. WLAN_PUB_ACTION_QAB_REQUEST_FRAME = 16,
  3265. WLAN_PUB_ACTION_QAB_RESPONSE_FRAME = 17,
  3266. WLAN_PUB_ACTION_QMF_POLICY = 18,
  3267. WLAN_PUB_ACTION_QMF_POLICY_CHANGE = 19,
  3268. WLAN_PUB_ACTION_QLOAD_REQUEST = 20,
  3269. WLAN_PUB_ACTION_QLOAD_REPORT = 21,
  3270. WLAN_PUB_ACTION_HCCA_TXOP_ADVERT = 22,
  3271. WLAN_PUB_ACTION_HCCA_TXOP_RESPONSE = 23,
  3272. WLAN_PUB_ACTION_PUBLIC_KEY = 24,
  3273. WLAN_PUB_ACTION_CHANNEL_AVAIL_QUERY = 25,
  3274. WLAN_PUB_ACTION_CHANNEL_SCHEDULE_MGMT = 26,
  3275. WLAN_PUB_ACTION_CONTACT_VERI_SIGNAL = 27,
  3276. WLAN_PUB_ACTION_GDD_ENABLEMENT_REQ = 28,
  3277. WLAN_PUB_ACTION_GDD_ENABLEMENT_RESP = 29,
  3278. WLAN_PUB_ACTION_NETWORK_CHANNEL_CONTROL = 30,
  3279. WLAN_PUB_ACTION_WHITE_SPACE_MAP_ANN = 31,
  3280. WLAN_PUB_ACTION_FTM_REQUEST = 32,
  3281. WLAN_PUB_ACTION_FTM = 33,
  3282. WLAN_PUB_ACTION_FILS_DISCOVERY = 34,
  3283. };
  3284. /* TDLS action codes */
  3285. enum ieee80211_tdls_actioncode {
  3286. WLAN_TDLS_SETUP_REQUEST = 0,
  3287. WLAN_TDLS_SETUP_RESPONSE = 1,
  3288. WLAN_TDLS_SETUP_CONFIRM = 2,
  3289. WLAN_TDLS_TEARDOWN = 3,
  3290. WLAN_TDLS_PEER_TRAFFIC_INDICATION = 4,
  3291. WLAN_TDLS_CHANNEL_SWITCH_REQUEST = 5,
  3292. WLAN_TDLS_CHANNEL_SWITCH_RESPONSE = 6,
  3293. WLAN_TDLS_PEER_PSM_REQUEST = 7,
  3294. WLAN_TDLS_PEER_PSM_RESPONSE = 8,
  3295. WLAN_TDLS_PEER_TRAFFIC_RESPONSE = 9,
  3296. WLAN_TDLS_DISCOVERY_REQUEST = 10,
  3297. };
  3298. /* Extended Channel Switching capability to be set in the 1st byte of
  3299. * the @WLAN_EID_EXT_CAPABILITY information element
  3300. */
  3301. #define WLAN_EXT_CAPA1_EXT_CHANNEL_SWITCHING BIT(2)
  3302. /* Multiple BSSID capability is set in the 6th bit of 3rd byte of the
  3303. * @WLAN_EID_EXT_CAPABILITY information element
  3304. */
  3305. #define WLAN_EXT_CAPA3_MULTI_BSSID_SUPPORT BIT(6)
  3306. /* Timing Measurement protocol for time sync is set in the 7th bit of 3rd byte
  3307. * of the @WLAN_EID_EXT_CAPABILITY information element
  3308. */
  3309. #define WLAN_EXT_CAPA3_TIMING_MEASUREMENT_SUPPORT BIT(7)
  3310. /* TDLS capabilities in the 4th byte of @WLAN_EID_EXT_CAPABILITY */
  3311. #define WLAN_EXT_CAPA4_TDLS_BUFFER_STA BIT(4)
  3312. #define WLAN_EXT_CAPA4_TDLS_PEER_PSM BIT(5)
  3313. #define WLAN_EXT_CAPA4_TDLS_CHAN_SWITCH BIT(6)
  3314. /* Interworking capabilities are set in 7th bit of 4th byte of the
  3315. * @WLAN_EID_EXT_CAPABILITY information element
  3316. */
  3317. #define WLAN_EXT_CAPA4_INTERWORKING_ENABLED BIT(7)
  3318. /*
  3319. * TDLS capabililites to be enabled in the 5th byte of the
  3320. * @WLAN_EID_EXT_CAPABILITY information element
  3321. */
  3322. #define WLAN_EXT_CAPA5_TDLS_ENABLED BIT(5)
  3323. #define WLAN_EXT_CAPA5_TDLS_PROHIBITED BIT(6)
  3324. #define WLAN_EXT_CAPA5_TDLS_CH_SW_PROHIBITED BIT(7)
  3325. #define WLAN_EXT_CAPA8_TDLS_WIDE_BW_ENABLED BIT(5)
  3326. #define WLAN_EXT_CAPA8_OPMODE_NOTIF BIT(6)
  3327. /* Defines the maximal number of MSDUs in an A-MSDU. */
  3328. #define WLAN_EXT_CAPA8_MAX_MSDU_IN_AMSDU_LSB BIT(7)
  3329. #define WLAN_EXT_CAPA9_MAX_MSDU_IN_AMSDU_MSB BIT(0)
  3330. /*
  3331. * Fine Timing Measurement Initiator - bit 71 of @WLAN_EID_EXT_CAPABILITY
  3332. * information element
  3333. */
  3334. #define WLAN_EXT_CAPA9_FTM_INITIATOR BIT(7)
  3335. /* Defines support for TWT Requester and TWT Responder */
  3336. #define WLAN_EXT_CAPA10_TWT_REQUESTER_SUPPORT BIT(5)
  3337. #define WLAN_EXT_CAPA10_TWT_RESPONDER_SUPPORT BIT(6)
  3338. /*
  3339. * When set, indicates that the AP is able to tolerate 26-tone RU UL
  3340. * OFDMA transmissions using HE TB PPDU from OBSS (not falsely classify the
  3341. * 26-tone RU UL OFDMA transmissions as radar pulses).
  3342. */
  3343. #define WLAN_EXT_CAPA10_OBSS_NARROW_BW_RU_TOLERANCE_SUPPORT BIT(7)
  3344. /* Defines support for enhanced multi-bssid advertisement*/
  3345. #define WLAN_EXT_CAPA11_EMA_SUPPORT BIT(3)
  3346. /* TDLS specific payload type in the LLC/SNAP header */
  3347. #define WLAN_TDLS_SNAP_RFTYPE 0x2
  3348. /* BSS Coex IE information field bits */
  3349. #define WLAN_BSS_COEX_INFORMATION_REQUEST BIT(0)
  3350. /**
  3351. * enum ieee80211_mesh_sync_method - mesh synchronization method identifier
  3352. *
  3353. * @IEEE80211_SYNC_METHOD_NEIGHBOR_OFFSET: the default synchronization method
  3354. * @IEEE80211_SYNC_METHOD_VENDOR: a vendor specific synchronization method
  3355. * that will be specified in a vendor specific information element
  3356. */
  3357. enum ieee80211_mesh_sync_method {
  3358. IEEE80211_SYNC_METHOD_NEIGHBOR_OFFSET = 1,
  3359. IEEE80211_SYNC_METHOD_VENDOR = 255,
  3360. };
  3361. /**
  3362. * enum ieee80211_mesh_path_protocol - mesh path selection protocol identifier
  3363. *
  3364. * @IEEE80211_PATH_PROTOCOL_HWMP: the default path selection protocol
  3365. * @IEEE80211_PATH_PROTOCOL_VENDOR: a vendor specific protocol that will
  3366. * be specified in a vendor specific information element
  3367. */
  3368. enum ieee80211_mesh_path_protocol {
  3369. IEEE80211_PATH_PROTOCOL_HWMP = 1,
  3370. IEEE80211_PATH_PROTOCOL_VENDOR = 255,
  3371. };
  3372. /**
  3373. * enum ieee80211_mesh_path_metric - mesh path selection metric identifier
  3374. *
  3375. * @IEEE80211_PATH_METRIC_AIRTIME: the default path selection metric
  3376. * @IEEE80211_PATH_METRIC_VENDOR: a vendor specific metric that will be
  3377. * specified in a vendor specific information element
  3378. */
  3379. enum ieee80211_mesh_path_metric {
  3380. IEEE80211_PATH_METRIC_AIRTIME = 1,
  3381. IEEE80211_PATH_METRIC_VENDOR = 255,
  3382. };
  3383. /**
  3384. * enum ieee80211_root_mode_identifier - root mesh STA mode identifier
  3385. *
  3386. * These attribute are used by dot11MeshHWMPRootMode to set root mesh STA mode
  3387. *
  3388. * @IEEE80211_ROOTMODE_NO_ROOT: the mesh STA is not a root mesh STA (default)
  3389. * @IEEE80211_ROOTMODE_ROOT: the mesh STA is a root mesh STA if greater than
  3390. * this value
  3391. * @IEEE80211_PROACTIVE_PREQ_NO_PREP: the mesh STA is a root mesh STA supports
  3392. * the proactive PREQ with proactive PREP subfield set to 0
  3393. * @IEEE80211_PROACTIVE_PREQ_WITH_PREP: the mesh STA is a root mesh STA
  3394. * supports the proactive PREQ with proactive PREP subfield set to 1
  3395. * @IEEE80211_PROACTIVE_RANN: the mesh STA is a root mesh STA supports
  3396. * the proactive RANN
  3397. */
  3398. enum ieee80211_root_mode_identifier {
  3399. IEEE80211_ROOTMODE_NO_ROOT = 0,
  3400. IEEE80211_ROOTMODE_ROOT = 1,
  3401. IEEE80211_PROACTIVE_PREQ_NO_PREP = 2,
  3402. IEEE80211_PROACTIVE_PREQ_WITH_PREP = 3,
  3403. IEEE80211_PROACTIVE_RANN = 4,
  3404. };
  3405. /*
  3406. * IEEE 802.11-2007 7.3.2.9 Country information element
  3407. *
  3408. * Minimum length is 8 octets, ie len must be evenly
  3409. * divisible by 2
  3410. */
  3411. /* Although the spec says 8 I'm seeing 6 in practice */
  3412. #define IEEE80211_COUNTRY_IE_MIN_LEN 6
  3413. /* The Country String field of the element shall be 3 octets in length */
  3414. #define IEEE80211_COUNTRY_STRING_LEN 3
  3415. /*
  3416. * For regulatory extension stuff see IEEE 802.11-2007
  3417. * Annex I (page 1141) and Annex J (page 1147). Also
  3418. * review 7.3.2.9.
  3419. *
  3420. * When dot11RegulatoryClassesRequired is true and the
  3421. * first_channel/reg_extension_id is >= 201 then the IE
  3422. * compromises of the 'ext' struct represented below:
  3423. *
  3424. * - Regulatory extension ID - when generating IE this just needs
  3425. * to be monotonically increasing for each triplet passed in
  3426. * the IE
  3427. * - Regulatory class - index into set of rules
  3428. * - Coverage class - index into air propagation time (Table 7-27),
  3429. * in microseconds, you can compute the air propagation time from
  3430. * the index by multiplying by 3, so index 10 yields a propagation
  3431. * of 10 us. Valid values are 0-31, values 32-255 are not defined
  3432. * yet. A value of 0 inicates air propagation of <= 1 us.
  3433. *
  3434. * See also Table I.2 for Emission limit sets and table
  3435. * I.3 for Behavior limit sets. Table J.1 indicates how to map
  3436. * a reg_class to an emission limit set and behavior limit set.
  3437. */
  3438. #define IEEE80211_COUNTRY_EXTENSION_ID 201
  3439. /*
  3440. * Channels numbers in the IE must be monotonically increasing
  3441. * if dot11RegulatoryClassesRequired is not true.
  3442. *
  3443. * If dot11RegulatoryClassesRequired is true consecutive
  3444. * subband triplets following a regulatory triplet shall
  3445. * have monotonically increasing first_channel number fields.
  3446. *
  3447. * Channel numbers shall not overlap.
  3448. *
  3449. * Note that max_power is signed.
  3450. */
  3451. struct ieee80211_country_ie_triplet {
  3452. union {
  3453. struct {
  3454. u8 first_channel;
  3455. u8 num_channels;
  3456. s8 max_power;
  3457. } __packed chans;
  3458. struct {
  3459. u8 reg_extension_id;
  3460. u8 reg_class;
  3461. u8 coverage_class;
  3462. } __packed ext;
  3463. };
  3464. } __packed;
  3465. enum ieee80211_timeout_interval_type {
  3466. WLAN_TIMEOUT_REASSOC_DEADLINE = 1 /* 802.11r */,
  3467. WLAN_TIMEOUT_KEY_LIFETIME = 2 /* 802.11r */,
  3468. WLAN_TIMEOUT_ASSOC_COMEBACK = 3 /* 802.11w */,
  3469. };
  3470. /**
  3471. * struct ieee80211_timeout_interval_ie - Timeout Interval element
  3472. * @type: type, see &enum ieee80211_timeout_interval_type
  3473. * @value: timeout interval value
  3474. */
  3475. struct ieee80211_timeout_interval_ie {
  3476. u8 type;
  3477. __le32 value;
  3478. } __packed;
  3479. /**
  3480. * enum ieee80211_idle_options - BSS idle options
  3481. * @WLAN_IDLE_OPTIONS_PROTECTED_KEEP_ALIVE: the station should send an RSN
  3482. * protected frame to the AP to reset the idle timer at the AP for
  3483. * the station.
  3484. */
  3485. enum ieee80211_idle_options {
  3486. WLAN_IDLE_OPTIONS_PROTECTED_KEEP_ALIVE = BIT(0),
  3487. };
  3488. /**
  3489. * struct ieee80211_bss_max_idle_period_ie
  3490. *
  3491. * This structure refers to "BSS Max idle period element"
  3492. *
  3493. * @max_idle_period: indicates the time period during which a station can
  3494. * refrain from transmitting frames to its associated AP without being
  3495. * disassociated. In units of 1000 TUs.
  3496. * @idle_options: indicates the options associated with the BSS idle capability
  3497. * as specified in &enum ieee80211_idle_options.
  3498. */
  3499. struct ieee80211_bss_max_idle_period_ie {
  3500. __le16 max_idle_period;
  3501. u8 idle_options;
  3502. } __packed;
  3503. /* BACK action code */
  3504. enum ieee80211_back_actioncode {
  3505. WLAN_ACTION_ADDBA_REQ = 0,
  3506. WLAN_ACTION_ADDBA_RESP = 1,
  3507. WLAN_ACTION_DELBA = 2,
  3508. };
  3509. /* BACK (block-ack) parties */
  3510. enum ieee80211_back_parties {
  3511. WLAN_BACK_RECIPIENT = 0,
  3512. WLAN_BACK_INITIATOR = 1,
  3513. };
  3514. /* SA Query action */
  3515. enum ieee80211_sa_query_action {
  3516. WLAN_ACTION_SA_QUERY_REQUEST = 0,
  3517. WLAN_ACTION_SA_QUERY_RESPONSE = 1,
  3518. };
  3519. /**
  3520. * struct ieee80211_bssid_index
  3521. *
  3522. * This structure refers to "Multiple BSSID-index element"
  3523. *
  3524. * @bssid_index: BSSID index
  3525. * @dtim_period: optional, overrides transmitted BSS dtim period
  3526. * @dtim_count: optional, overrides transmitted BSS dtim count
  3527. */
  3528. struct ieee80211_bssid_index {
  3529. u8 bssid_index;
  3530. u8 dtim_period;
  3531. u8 dtim_count;
  3532. };
  3533. /**
  3534. * struct ieee80211_multiple_bssid_configuration
  3535. *
  3536. * This structure refers to "Multiple BSSID Configuration element"
  3537. *
  3538. * @bssid_count: total number of active BSSIDs in the set
  3539. * @profile_periodicity: the least number of beacon frames need to be received
  3540. * in order to discover all the nontransmitted BSSIDs in the set.
  3541. */
  3542. struct ieee80211_multiple_bssid_configuration {
  3543. u8 bssid_count;
  3544. u8 profile_periodicity;
  3545. };
  3546. #define SUITE(oui, id) (((oui) << 8) | (id))
  3547. /* cipher suite selectors */
  3548. #define WLAN_CIPHER_SUITE_USE_GROUP SUITE(0x000FAC, 0)
  3549. #define WLAN_CIPHER_SUITE_WEP40 SUITE(0x000FAC, 1)
  3550. #define WLAN_CIPHER_SUITE_TKIP SUITE(0x000FAC, 2)
  3551. /* reserved: SUITE(0x000FAC, 3) */
  3552. #define WLAN_CIPHER_SUITE_CCMP SUITE(0x000FAC, 4)
  3553. #define WLAN_CIPHER_SUITE_WEP104 SUITE(0x000FAC, 5)
  3554. #define WLAN_CIPHER_SUITE_AES_CMAC SUITE(0x000FAC, 6)
  3555. #define WLAN_CIPHER_SUITE_GCMP SUITE(0x000FAC, 8)
  3556. #define WLAN_CIPHER_SUITE_GCMP_256 SUITE(0x000FAC, 9)
  3557. #define WLAN_CIPHER_SUITE_CCMP_256 SUITE(0x000FAC, 10)
  3558. #define WLAN_CIPHER_SUITE_BIP_GMAC_128 SUITE(0x000FAC, 11)
  3559. #define WLAN_CIPHER_SUITE_BIP_GMAC_256 SUITE(0x000FAC, 12)
  3560. #define WLAN_CIPHER_SUITE_BIP_CMAC_256 SUITE(0x000FAC, 13)
  3561. #define WLAN_CIPHER_SUITE_SMS4 SUITE(0x001472, 1)
  3562. /* AKM suite selectors */
  3563. #define WLAN_AKM_SUITE_8021X SUITE(0x000FAC, 1)
  3564. #define WLAN_AKM_SUITE_PSK SUITE(0x000FAC, 2)
  3565. #define WLAN_AKM_SUITE_FT_8021X SUITE(0x000FAC, 3)
  3566. #define WLAN_AKM_SUITE_FT_PSK SUITE(0x000FAC, 4)
  3567. #define WLAN_AKM_SUITE_8021X_SHA256 SUITE(0x000FAC, 5)
  3568. #define WLAN_AKM_SUITE_PSK_SHA256 SUITE(0x000FAC, 6)
  3569. #define WLAN_AKM_SUITE_TDLS SUITE(0x000FAC, 7)
  3570. #define WLAN_AKM_SUITE_SAE SUITE(0x000FAC, 8)
  3571. #define WLAN_AKM_SUITE_FT_OVER_SAE SUITE(0x000FAC, 9)
  3572. #define WLAN_AKM_SUITE_AP_PEER_KEY SUITE(0x000FAC, 10)
  3573. #define WLAN_AKM_SUITE_8021X_SUITE_B SUITE(0x000FAC, 11)
  3574. #define WLAN_AKM_SUITE_8021X_SUITE_B_192 SUITE(0x000FAC, 12)
  3575. #define WLAN_AKM_SUITE_FT_8021X_SHA384 SUITE(0x000FAC, 13)
  3576. #define WLAN_AKM_SUITE_FILS_SHA256 SUITE(0x000FAC, 14)
  3577. #define WLAN_AKM_SUITE_FILS_SHA384 SUITE(0x000FAC, 15)
  3578. #define WLAN_AKM_SUITE_FT_FILS_SHA256 SUITE(0x000FAC, 16)
  3579. #define WLAN_AKM_SUITE_FT_FILS_SHA384 SUITE(0x000FAC, 17)
  3580. #define WLAN_AKM_SUITE_OWE SUITE(0x000FAC, 18)
  3581. #define WLAN_AKM_SUITE_FT_PSK_SHA384 SUITE(0x000FAC, 19)
  3582. #define WLAN_AKM_SUITE_PSK_SHA384 SUITE(0x000FAC, 20)
  3583. #define WLAN_AKM_SUITE_WFA_DPP SUITE(WLAN_OUI_WFA, 2)
  3584. #define WLAN_MAX_KEY_LEN 32
  3585. #define WLAN_PMK_NAME_LEN 16
  3586. #define WLAN_PMKID_LEN 16
  3587. #define WLAN_PMK_LEN_EAP_LEAP 16
  3588. #define WLAN_PMK_LEN 32
  3589. #define WLAN_PMK_LEN_SUITE_B_192 48
  3590. #define WLAN_OUI_WFA 0x506f9a
  3591. #define WLAN_OUI_TYPE_WFA_P2P 9
  3592. #define WLAN_OUI_TYPE_WFA_DPP 0x1A
  3593. #define WLAN_OUI_MICROSOFT 0x0050f2
  3594. #define WLAN_OUI_TYPE_MICROSOFT_WPA 1
  3595. #define WLAN_OUI_TYPE_MICROSOFT_WMM 2
  3596. #define WLAN_OUI_TYPE_MICROSOFT_WPS 4
  3597. #define WLAN_OUI_TYPE_MICROSOFT_TPC 8
  3598. /*
  3599. * WMM/802.11e Tspec Element
  3600. */
  3601. #define IEEE80211_WMM_IE_TSPEC_TID_MASK 0x0F
  3602. #define IEEE80211_WMM_IE_TSPEC_TID_SHIFT 1
  3603. enum ieee80211_tspec_status_code {
  3604. IEEE80211_TSPEC_STATUS_ADMISS_ACCEPTED = 0,
  3605. IEEE80211_TSPEC_STATUS_ADDTS_INVAL_PARAMS = 0x1,
  3606. };
  3607. struct ieee80211_tspec_ie {
  3608. u8 element_id;
  3609. u8 len;
  3610. u8 oui[3];
  3611. u8 oui_type;
  3612. u8 oui_subtype;
  3613. u8 version;
  3614. __le16 tsinfo;
  3615. u8 tsinfo_resvd;
  3616. __le16 nominal_msdu;
  3617. __le16 max_msdu;
  3618. __le32 min_service_int;
  3619. __le32 max_service_int;
  3620. __le32 inactivity_int;
  3621. __le32 suspension_int;
  3622. __le32 service_start_time;
  3623. __le32 min_data_rate;
  3624. __le32 mean_data_rate;
  3625. __le32 peak_data_rate;
  3626. __le32 max_burst_size;
  3627. __le32 delay_bound;
  3628. __le32 min_phy_rate;
  3629. __le16 sba;
  3630. __le16 medium_time;
  3631. } __packed;
  3632. struct ieee80211_he_6ghz_capa {
  3633. /* uses IEEE80211_HE_6GHZ_CAP_* below */
  3634. __le16 capa;
  3635. } __packed;
  3636. /* HE 6 GHz band capabilities */
  3637. /* uses enum ieee80211_min_mpdu_spacing values */
  3638. #define IEEE80211_HE_6GHZ_CAP_MIN_MPDU_START 0x0007
  3639. /* uses enum ieee80211_vht_max_ampdu_length_exp values */
  3640. #define IEEE80211_HE_6GHZ_CAP_MAX_AMPDU_LEN_EXP 0x0038
  3641. /* uses IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_* values */
  3642. #define IEEE80211_HE_6GHZ_CAP_MAX_MPDU_LEN 0x00c0
  3643. /* WLAN_HT_CAP_SM_PS_* values */
  3644. #define IEEE80211_HE_6GHZ_CAP_SM_PS 0x0600
  3645. #define IEEE80211_HE_6GHZ_CAP_RD_RESPONDER 0x0800
  3646. #define IEEE80211_HE_6GHZ_CAP_RX_ANTPAT_CONS 0x1000
  3647. #define IEEE80211_HE_6GHZ_CAP_TX_ANTPAT_CONS 0x2000
  3648. /**
  3649. * ieee80211_get_qos_ctl - get pointer to qos control bytes
  3650. * @hdr: the frame
  3651. *
  3652. * The qos ctrl bytes come after the frame_control, duration, seq_num
  3653. * and 3 or 4 addresses of length ETH_ALEN.
  3654. * 3 addr: 2 + 2 + 2 + 3*6 = 24
  3655. * 4 addr: 2 + 2 + 2 + 4*6 = 30
  3656. */
  3657. static inline u8 *ieee80211_get_qos_ctl(struct ieee80211_hdr *hdr)
  3658. {
  3659. if (ieee80211_has_a4(hdr->frame_control))
  3660. return (u8 *)hdr + 30;
  3661. else
  3662. return (u8 *)hdr + 24;
  3663. }
  3664. /**
  3665. * ieee80211_get_tid - get qos TID
  3666. * @hdr: the frame
  3667. */
  3668. static inline u8 ieee80211_get_tid(struct ieee80211_hdr *hdr)
  3669. {
  3670. u8 *qc = ieee80211_get_qos_ctl(hdr);
  3671. return qc[0] & IEEE80211_QOS_CTL_TID_MASK;
  3672. }
  3673. /**
  3674. * ieee80211_get_SA - get pointer to SA
  3675. * @hdr: the frame
  3676. *
  3677. * Given an 802.11 frame, this function returns the offset
  3678. * to the source address (SA). It does not verify that the
  3679. * header is long enough to contain the address, and the
  3680. * header must be long enough to contain the frame control
  3681. * field.
  3682. */
  3683. static inline u8 *ieee80211_get_SA(struct ieee80211_hdr *hdr)
  3684. {
  3685. if (ieee80211_has_a4(hdr->frame_control))
  3686. return hdr->addr4;
  3687. if (ieee80211_has_fromds(hdr->frame_control))
  3688. return hdr->addr3;
  3689. return hdr->addr2;
  3690. }
  3691. /**
  3692. * ieee80211_get_DA - get pointer to DA
  3693. * @hdr: the frame
  3694. *
  3695. * Given an 802.11 frame, this function returns the offset
  3696. * to the destination address (DA). It does not verify that
  3697. * the header is long enough to contain the address, and the
  3698. * header must be long enough to contain the frame control
  3699. * field.
  3700. */
  3701. static inline u8 *ieee80211_get_DA(struct ieee80211_hdr *hdr)
  3702. {
  3703. if (ieee80211_has_tods(hdr->frame_control))
  3704. return hdr->addr3;
  3705. else
  3706. return hdr->addr1;
  3707. }
  3708. /**
  3709. * _ieee80211_is_robust_mgmt_frame - check if frame is a robust management frame
  3710. * @hdr: the frame (buffer must include at least the first octet of payload)
  3711. */
  3712. static inline bool _ieee80211_is_robust_mgmt_frame(struct ieee80211_hdr *hdr)
  3713. {
  3714. if (ieee80211_is_disassoc(hdr->frame_control) ||
  3715. ieee80211_is_deauth(hdr->frame_control))
  3716. return true;
  3717. if (ieee80211_is_action(hdr->frame_control)) {
  3718. u8 *category;
  3719. /*
  3720. * Action frames, excluding Public Action frames, are Robust
  3721. * Management Frames. However, if we are looking at a Protected
  3722. * frame, skip the check since the data may be encrypted and
  3723. * the frame has already been found to be a Robust Management
  3724. * Frame (by the other end).
  3725. */
  3726. if (ieee80211_has_protected(hdr->frame_control))
  3727. return true;
  3728. category = ((u8 *) hdr) + 24;
  3729. return *category != WLAN_CATEGORY_PUBLIC &&
  3730. *category != WLAN_CATEGORY_HT &&
  3731. *category != WLAN_CATEGORY_WNM_UNPROTECTED &&
  3732. *category != WLAN_CATEGORY_SELF_PROTECTED &&
  3733. *category != WLAN_CATEGORY_UNPROT_DMG &&
  3734. *category != WLAN_CATEGORY_VHT &&
  3735. *category != WLAN_CATEGORY_S1G &&
  3736. *category != WLAN_CATEGORY_VENDOR_SPECIFIC;
  3737. }
  3738. return false;
  3739. }
  3740. /**
  3741. * ieee80211_is_robust_mgmt_frame - check if skb contains a robust mgmt frame
  3742. * @skb: the skb containing the frame, length will be checked
  3743. */
  3744. static inline bool ieee80211_is_robust_mgmt_frame(struct sk_buff *skb)
  3745. {
  3746. if (skb->len < IEEE80211_MIN_ACTION_SIZE)
  3747. return false;
  3748. return _ieee80211_is_robust_mgmt_frame((void *)skb->data);
  3749. }
  3750. /**
  3751. * ieee80211_is_public_action - check if frame is a public action frame
  3752. * @hdr: the frame
  3753. * @len: length of the frame
  3754. */
  3755. static inline bool ieee80211_is_public_action(struct ieee80211_hdr *hdr,
  3756. size_t len)
  3757. {
  3758. struct ieee80211_mgmt *mgmt = (void *)hdr;
  3759. if (len < IEEE80211_MIN_ACTION_SIZE)
  3760. return false;
  3761. if (!ieee80211_is_action(hdr->frame_control))
  3762. return false;
  3763. return mgmt->u.action.category == WLAN_CATEGORY_PUBLIC;
  3764. }
  3765. /**
  3766. * _ieee80211_is_group_privacy_action - check if frame is a group addressed
  3767. * privacy action frame
  3768. * @hdr: the frame
  3769. */
  3770. static inline bool _ieee80211_is_group_privacy_action(struct ieee80211_hdr *hdr)
  3771. {
  3772. struct ieee80211_mgmt *mgmt = (void *)hdr;
  3773. if (!ieee80211_is_action(hdr->frame_control) ||
  3774. !is_multicast_ether_addr(hdr->addr1))
  3775. return false;
  3776. return mgmt->u.action.category == WLAN_CATEGORY_MESH_ACTION ||
  3777. mgmt->u.action.category == WLAN_CATEGORY_MULTIHOP_ACTION;
  3778. }
  3779. /**
  3780. * ieee80211_is_group_privacy_action - check if frame is a group addressed
  3781. * privacy action frame
  3782. * @skb: the skb containing the frame, length will be checked
  3783. */
  3784. static inline bool ieee80211_is_group_privacy_action(struct sk_buff *skb)
  3785. {
  3786. if (skb->len < IEEE80211_MIN_ACTION_SIZE)
  3787. return false;
  3788. return _ieee80211_is_group_privacy_action((void *)skb->data);
  3789. }
  3790. /**
  3791. * ieee80211_tu_to_usec - convert time units (TU) to microseconds
  3792. * @tu: the TUs
  3793. */
  3794. static inline unsigned long ieee80211_tu_to_usec(unsigned long tu)
  3795. {
  3796. return 1024 * tu;
  3797. }
  3798. /**
  3799. * ieee80211_check_tim - check if AID bit is set in TIM
  3800. * @tim: the TIM IE
  3801. * @tim_len: length of the TIM IE
  3802. * @aid: the AID to look for
  3803. */
  3804. static inline bool ieee80211_check_tim(const struct ieee80211_tim_ie *tim,
  3805. u8 tim_len, u16 aid)
  3806. {
  3807. u8 mask;
  3808. u8 index, indexn1, indexn2;
  3809. if (unlikely(!tim || tim_len < sizeof(*tim)))
  3810. return false;
  3811. aid &= 0x3fff;
  3812. index = aid / 8;
  3813. mask = 1 << (aid & 7);
  3814. indexn1 = tim->bitmap_ctrl & 0xfe;
  3815. indexn2 = tim_len + indexn1 - 4;
  3816. if (index < indexn1 || index > indexn2)
  3817. return false;
  3818. index -= indexn1;
  3819. return !!(tim->virtual_map[index] & mask);
  3820. }
  3821. /**
  3822. * ieee80211_get_tdls_action - get tdls packet action (or -1, if not tdls packet)
  3823. * @skb: the skb containing the frame, length will not be checked
  3824. * @hdr_size: the size of the ieee80211_hdr that starts at skb->data
  3825. *
  3826. * This function assumes the frame is a data frame, and that the network header
  3827. * is in the correct place.
  3828. */
  3829. static inline int ieee80211_get_tdls_action(struct sk_buff *skb, u32 hdr_size)
  3830. {
  3831. if (!skb_is_nonlinear(skb) &&
  3832. skb->len > (skb_network_offset(skb) + 2)) {
  3833. /* Point to where the indication of TDLS should start */
  3834. const u8 *tdls_data = skb_network_header(skb) - 2;
  3835. if (get_unaligned_be16(tdls_data) == ETH_P_TDLS &&
  3836. tdls_data[2] == WLAN_TDLS_SNAP_RFTYPE &&
  3837. tdls_data[3] == WLAN_CATEGORY_TDLS)
  3838. return tdls_data[4];
  3839. }
  3840. return -1;
  3841. }
  3842. /* convert time units */
  3843. #define TU_TO_JIFFIES(x) (usecs_to_jiffies((x) * 1024))
  3844. #define TU_TO_EXP_TIME(x) (jiffies + TU_TO_JIFFIES(x))
  3845. /* convert frequencies */
  3846. #define MHZ_TO_KHZ(freq) ((freq) * 1000)
  3847. #define KHZ_TO_MHZ(freq) ((freq) / 1000)
  3848. #define PR_KHZ(f) KHZ_TO_MHZ(f), f % 1000
  3849. #define KHZ_F "%d.%03d"
  3850. /* convert powers */
  3851. #define DBI_TO_MBI(gain) ((gain) * 100)
  3852. #define MBI_TO_DBI(gain) ((gain) / 100)
  3853. #define DBM_TO_MBM(gain) ((gain) * 100)
  3854. #define MBM_TO_DBM(gain) ((gain) / 100)
  3855. /**
  3856. * ieee80211_action_contains_tpc - checks if the frame contains TPC element
  3857. * @skb: the skb containing the frame, length will be checked
  3858. *
  3859. * This function checks if it's either TPC report action frame or Link
  3860. * Measurement report action frame as defined in IEEE Std. 802.11-2012 8.5.2.5
  3861. * and 8.5.7.5 accordingly.
  3862. */
  3863. static inline bool ieee80211_action_contains_tpc(struct sk_buff *skb)
  3864. {
  3865. struct ieee80211_mgmt *mgmt = (void *)skb->data;
  3866. if (!ieee80211_is_action(mgmt->frame_control))
  3867. return false;
  3868. if (skb->len < IEEE80211_MIN_ACTION_SIZE +
  3869. sizeof(mgmt->u.action.u.tpc_report))
  3870. return false;
  3871. /*
  3872. * TPC report - check that:
  3873. * category = 0 (Spectrum Management) or 5 (Radio Measurement)
  3874. * spectrum management action = 3 (TPC/Link Measurement report)
  3875. * TPC report EID = 35
  3876. * TPC report element length = 2
  3877. *
  3878. * The spectrum management's tpc_report struct is used here both for
  3879. * parsing tpc_report and radio measurement's link measurement report
  3880. * frame, since the relevant part is identical in both frames.
  3881. */
  3882. if (mgmt->u.action.category != WLAN_CATEGORY_SPECTRUM_MGMT &&
  3883. mgmt->u.action.category != WLAN_CATEGORY_RADIO_MEASUREMENT)
  3884. return false;
  3885. /* both spectrum mgmt and link measurement have same action code */
  3886. if (mgmt->u.action.u.tpc_report.action_code !=
  3887. WLAN_ACTION_SPCT_TPC_RPRT)
  3888. return false;
  3889. if (mgmt->u.action.u.tpc_report.tpc_elem_id != WLAN_EID_TPC_REPORT ||
  3890. mgmt->u.action.u.tpc_report.tpc_elem_length !=
  3891. sizeof(struct ieee80211_tpc_report_ie))
  3892. return false;
  3893. return true;
  3894. }
  3895. static inline bool ieee80211_is_timing_measurement(struct sk_buff *skb)
  3896. {
  3897. struct ieee80211_mgmt *mgmt = (void *)skb->data;
  3898. if (skb->len < IEEE80211_MIN_ACTION_SIZE)
  3899. return false;
  3900. if (!ieee80211_is_action(mgmt->frame_control))
  3901. return false;
  3902. if (mgmt->u.action.category == WLAN_CATEGORY_WNM_UNPROTECTED &&
  3903. mgmt->u.action.u.wnm_timing_msr.action_code ==
  3904. WLAN_UNPROTECTED_WNM_ACTION_TIMING_MEASUREMENT_RESPONSE &&
  3905. skb->len >= offsetofend(typeof(*mgmt), u.action.u.wnm_timing_msr))
  3906. return true;
  3907. return false;
  3908. }
  3909. static inline bool ieee80211_is_ftm(struct sk_buff *skb)
  3910. {
  3911. struct ieee80211_mgmt *mgmt = (void *)skb->data;
  3912. if (!ieee80211_is_public_action((void *)mgmt, skb->len))
  3913. return false;
  3914. if (mgmt->u.action.u.ftm.action_code ==
  3915. WLAN_PUBLIC_ACTION_FTM_RESPONSE &&
  3916. skb->len >= offsetofend(typeof(*mgmt), u.action.u.ftm))
  3917. return true;
  3918. return false;
  3919. }
  3920. struct element {
  3921. u8 id;
  3922. u8 datalen;
  3923. u8 data[];
  3924. } __packed;
  3925. /* element iteration helpers */
  3926. #define for_each_element(_elem, _data, _datalen) \
  3927. for (_elem = (const struct element *)(_data); \
  3928. (const u8 *)(_data) + (_datalen) - (const u8 *)_elem >= \
  3929. (int)sizeof(*_elem) && \
  3930. (const u8 *)(_data) + (_datalen) - (const u8 *)_elem >= \
  3931. (int)sizeof(*_elem) + _elem->datalen; \
  3932. _elem = (const struct element *)(_elem->data + _elem->datalen))
  3933. #define for_each_element_id(element, _id, data, datalen) \
  3934. for_each_element(element, data, datalen) \
  3935. if (element->id == (_id))
  3936. #define for_each_element_extid(element, extid, _data, _datalen) \
  3937. for_each_element(element, _data, _datalen) \
  3938. if (element->id == WLAN_EID_EXTENSION && \
  3939. element->datalen > 0 && \
  3940. element->data[0] == (extid))
  3941. #define for_each_subelement(sub, element) \
  3942. for_each_element(sub, (element)->data, (element)->datalen)
  3943. #define for_each_subelement_id(sub, id, element) \
  3944. for_each_element_id(sub, id, (element)->data, (element)->datalen)
  3945. #define for_each_subelement_extid(sub, extid, element) \
  3946. for_each_element_extid(sub, extid, (element)->data, (element)->datalen)
  3947. /**
  3948. * for_each_element_completed - determine if element parsing consumed all data
  3949. * @element: element pointer after for_each_element() or friends
  3950. * @data: same data pointer as passed to for_each_element() or friends
  3951. * @datalen: same data length as passed to for_each_element() or friends
  3952. *
  3953. * This function returns %true if all the data was parsed or considered
  3954. * while walking the elements. Only use this if your for_each_element()
  3955. * loop cannot be broken out of, otherwise it always returns %false.
  3956. *
  3957. * If some data was malformed, this returns %false since the last parsed
  3958. * element will not fill the whole remaining data.
  3959. */
  3960. static inline bool for_each_element_completed(const struct element *element,
  3961. const void *data, size_t datalen)
  3962. {
  3963. return (const u8 *)element == (const u8 *)data + datalen;
  3964. }
  3965. /**
  3966. * RSNX Capabilities:
  3967. * bits 0-3: Field length (n-1)
  3968. */
  3969. #define WLAN_RSNX_CAPA_PROTECTED_TWT BIT(4)
  3970. #define WLAN_RSNX_CAPA_SAE_H2E BIT(5)
  3971. /*
  3972. * reduced neighbor report, based on Draft P802.11ax_D6.1,
  3973. * section 9.4.2.170 and accepted contributions.
  3974. */
  3975. #define IEEE80211_AP_INFO_TBTT_HDR_TYPE 0x03
  3976. #define IEEE80211_AP_INFO_TBTT_HDR_FILTERED 0x04
  3977. #define IEEE80211_AP_INFO_TBTT_HDR_COLOC 0x08
  3978. #define IEEE80211_AP_INFO_TBTT_HDR_COUNT 0xF0
  3979. #define IEEE80211_TBTT_INFO_OFFSET_BSSID_BSS_PARAM 9
  3980. #define IEEE80211_TBTT_INFO_OFFSET_BSSID_SSSID_BSS_PARAM 13
  3981. #define IEEE80211_RNR_TBTT_PARAMS_OCT_RECOMMENDED 0x01
  3982. #define IEEE80211_RNR_TBTT_PARAMS_SAME_SSID 0x02
  3983. #define IEEE80211_RNR_TBTT_PARAMS_MULTI_BSSID 0x04
  3984. #define IEEE80211_RNR_TBTT_PARAMS_TRANSMITTED_BSSID 0x08
  3985. #define IEEE80211_RNR_TBTT_PARAMS_COLOC_ESS 0x10
  3986. #define IEEE80211_RNR_TBTT_PARAMS_PROBE_ACTIVE 0x20
  3987. #define IEEE80211_RNR_TBTT_PARAMS_COLOC_AP 0x40
  3988. struct ieee80211_neighbor_ap_info {
  3989. u8 tbtt_info_hdr;
  3990. u8 tbtt_info_len;
  3991. u8 op_class;
  3992. u8 channel;
  3993. } __packed;
  3994. enum ieee80211_range_params_max_total_ltf {
  3995. IEEE80211_RANGE_PARAMS_MAX_TOTAL_LTF_4 = 0,
  3996. IEEE80211_RANGE_PARAMS_MAX_TOTAL_LTF_8,
  3997. IEEE80211_RANGE_PARAMS_MAX_TOTAL_LTF_16,
  3998. IEEE80211_RANGE_PARAMS_MAX_TOTAL_LTF_UNSPECIFIED,
  3999. };
  4000. /* multi-link device */
  4001. #define IEEE80211_MLD_MAX_NUM_LINKS 15
  4002. #define IEEE80211_ML_CONTROL_TYPE 0x0007
  4003. #define IEEE80211_ML_CONTROL_TYPE_BASIC 0
  4004. #define IEEE80211_ML_CONTROL_TYPE_PREQ 1
  4005. #define IEEE80211_ML_CONTROL_TYPE_RECONF 2
  4006. #define IEEE80211_ML_CONTROL_TYPE_TDLS 3
  4007. #define IEEE80211_ML_CONTROL_TYPE_PRIO_ACCESS 4
  4008. #define IEEE80211_ML_CONTROL_PRESENCE_MASK 0xfff0
  4009. struct ieee80211_multi_link_elem {
  4010. __le16 control;
  4011. u8 variable[];
  4012. } __packed;
  4013. #define IEEE80211_MLC_BASIC_PRES_LINK_ID 0x0010
  4014. #define IEEE80211_MLC_BASIC_PRES_BSS_PARAM_CH_CNT 0x0020
  4015. #define IEEE80211_MLC_BASIC_PRES_MED_SYNC_DELAY 0x0040
  4016. #define IEEE80211_MLC_BASIC_PRES_EML_CAPA 0x0080
  4017. #define IEEE80211_MLC_BASIC_PRES_MLD_CAPA_OP 0x0100
  4018. #define IEEE80211_MLC_BASIC_PRES_MLD_ID 0x0200
  4019. #define IEEE80211_MED_SYNC_DELAY_DURATION 0x00ff
  4020. #define IEEE80211_MED_SYNC_DELAY_SYNC_OFDM_ED_THRESH 0x0f00
  4021. #define IEEE80211_MED_SYNC_DELAY_SYNC_MAX_NUM_TXOPS 0xf000
  4022. #define IEEE80211_EML_CAP_EMLSR_SUPP 0x0001
  4023. #define IEEE80211_EML_CAP_EMLSR_PADDING_DELAY 0x000e
  4024. #define IEEE80211_EML_CAP_EMLSR_PADDING_DELAY_0US 0
  4025. #define IEEE80211_EML_CAP_EMLSR_PADDING_DELAY_32US 1
  4026. #define IEEE80211_EML_CAP_EMLSR_PADDING_DELAY_64US 2
  4027. #define IEEE80211_EML_CAP_EMLSR_PADDING_DELAY_128US 3
  4028. #define IEEE80211_EML_CAP_EMLSR_PADDING_DELAY_256US 4
  4029. #define IEEE80211_EML_CAP_EMLSR_TRANSITION_DELAY 0x0070
  4030. #define IEEE80211_EML_CAP_EMLSR_TRANSITION_DELAY_0US 0
  4031. #define IEEE80211_EML_CAP_EMLSR_TRANSITION_DELAY_16US 1
  4032. #define IEEE80211_EML_CAP_EMLSR_TRANSITION_DELAY_32US 2
  4033. #define IEEE80211_EML_CAP_EMLSR_TRANSITION_DELAY_64US 3
  4034. #define IEEE80211_EML_CAP_EMLSR_TRANSITION_DELAY_128US 4
  4035. #define IEEE80211_EML_CAP_EMLSR_TRANSITION_DELAY_256US 5
  4036. #define IEEE80211_EML_CAP_EMLMR_SUPPORT 0x0080
  4037. #define IEEE80211_EML_CAP_EMLMR_DELAY 0x0700
  4038. #define IEEE80211_EML_CAP_EMLMR_DELAY_0US 0
  4039. #define IEEE80211_EML_CAP_EMLMR_DELAY_32US 1
  4040. #define IEEE80211_EML_CAP_EMLMR_DELAY_64US 2
  4041. #define IEEE80211_EML_CAP_EMLMR_DELAY_128US 3
  4042. #define IEEE80211_EML_CAP_EMLMR_DELAY_256US 4
  4043. #define IEEE80211_EML_CAP_TRANSITION_TIMEOUT 0x7800
  4044. #define IEEE80211_EML_CAP_TRANSITION_TIMEOUT_0 0
  4045. #define IEEE80211_EML_CAP_TRANSITION_TIMEOUT_128US 1
  4046. #define IEEE80211_EML_CAP_TRANSITION_TIMEOUT_256US 2
  4047. #define IEEE80211_EML_CAP_TRANSITION_TIMEOUT_512US 3
  4048. #define IEEE80211_EML_CAP_TRANSITION_TIMEOUT_1TU 4
  4049. #define IEEE80211_EML_CAP_TRANSITION_TIMEOUT_2TU 5
  4050. #define IEEE80211_EML_CAP_TRANSITION_TIMEOUT_4TU 6
  4051. #define IEEE80211_EML_CAP_TRANSITION_TIMEOUT_8TU 7
  4052. #define IEEE80211_EML_CAP_TRANSITION_TIMEOUT_16TU 8
  4053. #define IEEE80211_EML_CAP_TRANSITION_TIMEOUT_32TU 9
  4054. #define IEEE80211_EML_CAP_TRANSITION_TIMEOUT_64TU 10
  4055. #define IEEE80211_EML_CAP_TRANSITION_TIMEOUT_128TU 11
  4056. #define IEEE80211_MLD_CAP_OP_MAX_SIMUL_LINKS 0x000f
  4057. #define IEEE80211_MLD_CAP_OP_SRS_SUPPORT 0x0010
  4058. #define IEEE80211_MLD_CAP_OP_TID_TO_LINK_MAP_NEG_SUPP 0x0060
  4059. #define IEEE80211_MLD_CAP_OP_FREQ_SEP_TYPE_IND 0x0f80
  4060. #define IEEE80211_MLD_CAP_OP_AAR_SUPPORT 0x1000
  4061. struct ieee80211_mle_basic_common_info {
  4062. u8 len;
  4063. u8 mld_mac_addr[ETH_ALEN];
  4064. u8 variable[];
  4065. } __packed;
  4066. #define IEEE80211_MLC_PREQ_PRES_MLD_ID 0x0010
  4067. struct ieee80211_mle_preq_common_info {
  4068. u8 len;
  4069. u8 variable[];
  4070. } __packed;
  4071. #define IEEE80211_MLC_RECONF_PRES_MLD_MAC_ADDR 0x0010
  4072. /* no fixed fields in RECONF */
  4073. struct ieee80211_mle_tdls_common_info {
  4074. u8 len;
  4075. u8 ap_mld_mac_addr[ETH_ALEN];
  4076. } __packed;
  4077. #define IEEE80211_MLC_PRIO_ACCESS_PRES_AP_MLD_MAC_ADDR 0x0010
  4078. /* no fixed fields in PRIO_ACCESS */
  4079. /**
  4080. * ieee80211_mle_common_size - check multi-link element common size
  4081. * @data: multi-link element, must already be checked for size using
  4082. * ieee80211_mle_size_ok()
  4083. */
  4084. static inline u8 ieee80211_mle_common_size(const u8 *data)
  4085. {
  4086. const struct ieee80211_multi_link_elem *mle = (const void *)data;
  4087. u16 control = le16_to_cpu(mle->control);
  4088. u8 common = 0;
  4089. switch (u16_get_bits(control, IEEE80211_ML_CONTROL_TYPE)) {
  4090. case IEEE80211_ML_CONTROL_TYPE_BASIC:
  4091. case IEEE80211_ML_CONTROL_TYPE_PREQ:
  4092. case IEEE80211_ML_CONTROL_TYPE_TDLS:
  4093. case IEEE80211_ML_CONTROL_TYPE_RECONF:
  4094. /*
  4095. * The length is the first octet pointed by mle->variable so no
  4096. * need to add anything
  4097. */
  4098. break;
  4099. case IEEE80211_ML_CONTROL_TYPE_PRIO_ACCESS:
  4100. if (control & IEEE80211_MLC_PRIO_ACCESS_PRES_AP_MLD_MAC_ADDR)
  4101. common += ETH_ALEN;
  4102. return common;
  4103. default:
  4104. WARN_ON(1);
  4105. return 0;
  4106. }
  4107. return sizeof(*mle) + common + mle->variable[0];
  4108. }
  4109. /**
  4110. * ieee80211_mle_size_ok - validate multi-link element size
  4111. * @data: pointer to the element data
  4112. * @len: length of the containing element
  4113. */
  4114. static inline bool ieee80211_mle_size_ok(const u8 *data, u8 len)
  4115. {
  4116. const struct ieee80211_multi_link_elem *mle = (const void *)data;
  4117. u8 fixed = sizeof(*mle);
  4118. u8 common = 0;
  4119. bool check_common_len = false;
  4120. u16 control;
  4121. if (len < fixed)
  4122. return false;
  4123. control = le16_to_cpu(mle->control);
  4124. switch (u16_get_bits(control, IEEE80211_ML_CONTROL_TYPE)) {
  4125. case IEEE80211_ML_CONTROL_TYPE_BASIC:
  4126. common += sizeof(struct ieee80211_mle_basic_common_info);
  4127. check_common_len = true;
  4128. if (control & IEEE80211_MLC_BASIC_PRES_LINK_ID)
  4129. common += 1;
  4130. if (control & IEEE80211_MLC_BASIC_PRES_BSS_PARAM_CH_CNT)
  4131. common += 1;
  4132. if (control & IEEE80211_MLC_BASIC_PRES_MED_SYNC_DELAY)
  4133. common += 2;
  4134. if (control & IEEE80211_MLC_BASIC_PRES_EML_CAPA)
  4135. common += 2;
  4136. if (control & IEEE80211_MLC_BASIC_PRES_MLD_CAPA_OP)
  4137. common += 2;
  4138. if (control & IEEE80211_MLC_BASIC_PRES_MLD_ID)
  4139. common += 1;
  4140. break;
  4141. case IEEE80211_ML_CONTROL_TYPE_PREQ:
  4142. common += sizeof(struct ieee80211_mle_preq_common_info);
  4143. if (control & IEEE80211_MLC_PREQ_PRES_MLD_ID)
  4144. common += 1;
  4145. check_common_len = true;
  4146. break;
  4147. case IEEE80211_ML_CONTROL_TYPE_RECONF:
  4148. if (control & IEEE80211_MLC_RECONF_PRES_MLD_MAC_ADDR)
  4149. common += ETH_ALEN;
  4150. break;
  4151. case IEEE80211_ML_CONTROL_TYPE_TDLS:
  4152. common += sizeof(struct ieee80211_mle_tdls_common_info);
  4153. check_common_len = true;
  4154. break;
  4155. case IEEE80211_ML_CONTROL_TYPE_PRIO_ACCESS:
  4156. if (control & IEEE80211_MLC_PRIO_ACCESS_PRES_AP_MLD_MAC_ADDR)
  4157. common += ETH_ALEN;
  4158. break;
  4159. default:
  4160. /* we don't know this type */
  4161. return true;
  4162. }
  4163. if (len < fixed + common)
  4164. return false;
  4165. if (!check_common_len)
  4166. return true;
  4167. /* if present, common length is the first octet there */
  4168. return mle->variable[0] >= common;
  4169. }
  4170. enum ieee80211_mle_subelems {
  4171. IEEE80211_MLE_SUBELEM_PER_STA_PROFILE = 0,
  4172. };
  4173. #define IEEE80211_MLE_STA_CONTROL_LINK_ID 0x000f
  4174. #define IEEE80211_MLE_STA_CONTROL_COMPLETE_PROFILE 0x0010
  4175. #define IEEE80211_MLE_STA_CONTROL_STA_MAC_ADDR_PRESENT 0x0020
  4176. #define IEEE80211_MLE_STA_CONTROL_BEACON_INT_PRESENT 0x0040
  4177. #define IEEE80211_MLE_STA_CONTROL_TSF_OFFS_PRESENT 0x0080
  4178. #define IEEE80211_MLE_STA_CONTROL_DTIM_INFO_PRESENT 0x0100
  4179. #define IEEE80211_MLE_STA_CONTROL_NSTR_LINK_PAIR_PRESENT 0x0200
  4180. #define IEEE80211_MLE_STA_CONTROL_NSTR_BITMAP_SIZE 0x0400
  4181. #define IEEE80211_MLE_STA_CONTROL_BSS_PARAM_CHANGE_CNT_PRESENT 0x0800
  4182. struct ieee80211_mle_per_sta_profile {
  4183. __le16 control;
  4184. u8 sta_info_len;
  4185. u8 variable[];
  4186. } __packed;
  4187. #define for_each_mle_subelement(_elem, _data, _len) \
  4188. if (ieee80211_mle_size_ok(_data, _len)) \
  4189. for_each_element(_elem, \
  4190. _data + ieee80211_mle_common_size(_data),\
  4191. _len - ieee80211_mle_common_size(_data))
  4192. #endif /* LINUX_IEEE80211_H */