cfg80211.h 220 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237
  1. #ifndef __NET_CFG80211_H
  2. #define __NET_CFG80211_H
  3. /*
  4. * 802.11 device and configuration interface
  5. *
  6. * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net>
  7. * Copyright 2013-2014 Intel Mobile Communications GmbH
  8. * Copyright 2015-2017 Intel Deutschland GmbH
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #include <linux/netdevice.h>
  15. #include <linux/debugfs.h>
  16. #include <linux/list.h>
  17. #include <linux/bug.h>
  18. #include <linux/netlink.h>
  19. #include <linux/skbuff.h>
  20. #include <linux/nl80211.h>
  21. #include <linux/if_ether.h>
  22. #include <linux/ieee80211.h>
  23. #include <linux/net.h>
  24. #include <net/regulatory.h>
  25. /**
  26. * DOC: Introduction
  27. *
  28. * cfg80211 is the configuration API for 802.11 devices in Linux. It bridges
  29. * userspace and drivers, and offers some utility functionality associated
  30. * with 802.11. cfg80211 must, directly or indirectly via mac80211, be used
  31. * by all modern wireless drivers in Linux, so that they offer a consistent
  32. * API through nl80211. For backward compatibility, cfg80211 also offers
  33. * wireless extensions to userspace, but hides them from drivers completely.
  34. *
  35. * Additionally, cfg80211 contains code to help enforce regulatory spectrum
  36. * use restrictions.
  37. */
  38. /**
  39. * DOC: Device registration
  40. *
  41. * In order for a driver to use cfg80211, it must register the hardware device
  42. * with cfg80211. This happens through a number of hardware capability structs
  43. * described below.
  44. *
  45. * The fundamental structure for each device is the 'wiphy', of which each
  46. * instance describes a physical wireless device connected to the system. Each
  47. * such wiphy can have zero, one, or many virtual interfaces associated with
  48. * it, which need to be identified as such by pointing the network interface's
  49. * @ieee80211_ptr pointer to a &struct wireless_dev which further describes
  50. * the wireless part of the interface, normally this struct is embedded in the
  51. * network interface's private data area. Drivers can optionally allow creating
  52. * or destroying virtual interfaces on the fly, but without at least one or the
  53. * ability to create some the wireless device isn't useful.
  54. *
  55. * Each wiphy structure contains device capability information, and also has
  56. * a pointer to the various operations the driver offers. The definitions and
  57. * structures here describe these capabilities in detail.
  58. */
  59. struct wiphy;
  60. /*
  61. * wireless hardware capability structures
  62. */
  63. /**
  64. * enum ieee80211_channel_flags - channel flags
  65. *
  66. * Channel flags set by the regulatory control code.
  67. *
  68. * @IEEE80211_CHAN_DISABLED: This channel is disabled.
  69. * @IEEE80211_CHAN_NO_IR: do not initiate radiation, this includes
  70. * sending probe requests or beaconing.
  71. * @IEEE80211_CHAN_RADAR: Radar detection is required on this channel.
  72. * @IEEE80211_CHAN_NO_HT40PLUS: extension channel above this channel
  73. * is not permitted.
  74. * @IEEE80211_CHAN_NO_HT40MINUS: extension channel below this channel
  75. * is not permitted.
  76. * @IEEE80211_CHAN_NO_OFDM: OFDM is not allowed on this channel.
  77. * @IEEE80211_CHAN_NO_80MHZ: If the driver supports 80 MHz on the band,
  78. * this flag indicates that an 80 MHz channel cannot use this
  79. * channel as the control or any of the secondary channels.
  80. * This may be due to the driver or due to regulatory bandwidth
  81. * restrictions.
  82. * @IEEE80211_CHAN_NO_160MHZ: If the driver supports 160 MHz on the band,
  83. * this flag indicates that an 160 MHz channel cannot use this
  84. * channel as the control or any of the secondary channels.
  85. * This may be due to the driver or due to regulatory bandwidth
  86. * restrictions.
  87. * @IEEE80211_CHAN_INDOOR_ONLY: see %NL80211_FREQUENCY_ATTR_INDOOR_ONLY
  88. * @IEEE80211_CHAN_IR_CONCURRENT: see %NL80211_FREQUENCY_ATTR_IR_CONCURRENT
  89. * @IEEE80211_CHAN_NO_20MHZ: 20 MHz bandwidth is not permitted
  90. * on this channel.
  91. * @IEEE80211_CHAN_NO_10MHZ: 10 MHz bandwidth is not permitted
  92. * on this channel.
  93. *
  94. */
  95. enum ieee80211_channel_flags {
  96. IEEE80211_CHAN_DISABLED = 1<<0,
  97. IEEE80211_CHAN_NO_IR = 1<<1,
  98. /* hole at 1<<2 */
  99. IEEE80211_CHAN_RADAR = 1<<3,
  100. IEEE80211_CHAN_NO_HT40PLUS = 1<<4,
  101. IEEE80211_CHAN_NO_HT40MINUS = 1<<5,
  102. IEEE80211_CHAN_NO_OFDM = 1<<6,
  103. IEEE80211_CHAN_NO_80MHZ = 1<<7,
  104. IEEE80211_CHAN_NO_160MHZ = 1<<8,
  105. IEEE80211_CHAN_INDOOR_ONLY = 1<<9,
  106. IEEE80211_CHAN_IR_CONCURRENT = 1<<10,
  107. IEEE80211_CHAN_NO_20MHZ = 1<<11,
  108. IEEE80211_CHAN_NO_10MHZ = 1<<12,
  109. };
  110. #define IEEE80211_CHAN_NO_HT40 \
  111. (IEEE80211_CHAN_NO_HT40PLUS | IEEE80211_CHAN_NO_HT40MINUS)
  112. #define IEEE80211_DFS_MIN_CAC_TIME_MS 60000
  113. #define IEEE80211_DFS_MIN_NOP_TIME_MS (30 * 60 * 1000)
  114. /**
  115. * struct ieee80211_channel - channel definition
  116. *
  117. * This structure describes a single channel for use
  118. * with cfg80211.
  119. *
  120. * @center_freq: center frequency in MHz
  121. * @hw_value: hardware-specific value for the channel
  122. * @flags: channel flags from &enum ieee80211_channel_flags.
  123. * @orig_flags: channel flags at registration time, used by regulatory
  124. * code to support devices with additional restrictions
  125. * @band: band this channel belongs to.
  126. * @max_antenna_gain: maximum antenna gain in dBi
  127. * @max_power: maximum transmission power (in dBm)
  128. * @max_reg_power: maximum regulatory transmission power (in dBm)
  129. * @beacon_found: helper to regulatory code to indicate when a beacon
  130. * has been found on this channel. Use regulatory_hint_found_beacon()
  131. * to enable this, this is useful only on 5 GHz band.
  132. * @orig_mag: internal use
  133. * @orig_mpwr: internal use
  134. * @dfs_state: current state of this channel. Only relevant if radar is required
  135. * on this channel.
  136. * @dfs_state_entered: timestamp (jiffies) when the dfs state was entered.
  137. * @dfs_cac_ms: DFS CAC time in milliseconds, this is valid for DFS channels.
  138. */
  139. struct ieee80211_channel {
  140. enum nl80211_band band;
  141. u16 center_freq;
  142. u16 hw_value;
  143. u32 flags;
  144. int max_antenna_gain;
  145. int max_power;
  146. int max_reg_power;
  147. bool beacon_found;
  148. u32 orig_flags;
  149. int orig_mag, orig_mpwr;
  150. enum nl80211_dfs_state dfs_state;
  151. unsigned long dfs_state_entered;
  152. unsigned int dfs_cac_ms;
  153. };
  154. /**
  155. * enum ieee80211_rate_flags - rate flags
  156. *
  157. * Hardware/specification flags for rates. These are structured
  158. * in a way that allows using the same bitrate structure for
  159. * different bands/PHY modes.
  160. *
  161. * @IEEE80211_RATE_SHORT_PREAMBLE: Hardware can send with short
  162. * preamble on this bitrate; only relevant in 2.4GHz band and
  163. * with CCK rates.
  164. * @IEEE80211_RATE_MANDATORY_A: This bitrate is a mandatory rate
  165. * when used with 802.11a (on the 5 GHz band); filled by the
  166. * core code when registering the wiphy.
  167. * @IEEE80211_RATE_MANDATORY_B: This bitrate is a mandatory rate
  168. * when used with 802.11b (on the 2.4 GHz band); filled by the
  169. * core code when registering the wiphy.
  170. * @IEEE80211_RATE_MANDATORY_G: This bitrate is a mandatory rate
  171. * when used with 802.11g (on the 2.4 GHz band); filled by the
  172. * core code when registering the wiphy.
  173. * @IEEE80211_RATE_ERP_G: This is an ERP rate in 802.11g mode.
  174. * @IEEE80211_RATE_SUPPORTS_5MHZ: Rate can be used in 5 MHz mode
  175. * @IEEE80211_RATE_SUPPORTS_10MHZ: Rate can be used in 10 MHz mode
  176. */
  177. enum ieee80211_rate_flags {
  178. IEEE80211_RATE_SHORT_PREAMBLE = 1<<0,
  179. IEEE80211_RATE_MANDATORY_A = 1<<1,
  180. IEEE80211_RATE_MANDATORY_B = 1<<2,
  181. IEEE80211_RATE_MANDATORY_G = 1<<3,
  182. IEEE80211_RATE_ERP_G = 1<<4,
  183. IEEE80211_RATE_SUPPORTS_5MHZ = 1<<5,
  184. IEEE80211_RATE_SUPPORTS_10MHZ = 1<<6,
  185. };
  186. /**
  187. * enum ieee80211_bss_type - BSS type filter
  188. *
  189. * @IEEE80211_BSS_TYPE_ESS: Infrastructure BSS
  190. * @IEEE80211_BSS_TYPE_PBSS: Personal BSS
  191. * @IEEE80211_BSS_TYPE_IBSS: Independent BSS
  192. * @IEEE80211_BSS_TYPE_MBSS: Mesh BSS
  193. * @IEEE80211_BSS_TYPE_ANY: Wildcard value for matching any BSS type
  194. */
  195. enum ieee80211_bss_type {
  196. IEEE80211_BSS_TYPE_ESS,
  197. IEEE80211_BSS_TYPE_PBSS,
  198. IEEE80211_BSS_TYPE_IBSS,
  199. IEEE80211_BSS_TYPE_MBSS,
  200. IEEE80211_BSS_TYPE_ANY
  201. };
  202. /**
  203. * enum ieee80211_privacy - BSS privacy filter
  204. *
  205. * @IEEE80211_PRIVACY_ON: privacy bit set
  206. * @IEEE80211_PRIVACY_OFF: privacy bit clear
  207. * @IEEE80211_PRIVACY_ANY: Wildcard value for matching any privacy setting
  208. */
  209. enum ieee80211_privacy {
  210. IEEE80211_PRIVACY_ON,
  211. IEEE80211_PRIVACY_OFF,
  212. IEEE80211_PRIVACY_ANY
  213. };
  214. #define IEEE80211_PRIVACY(x) \
  215. ((x) ? IEEE80211_PRIVACY_ON : IEEE80211_PRIVACY_OFF)
  216. /**
  217. * struct ieee80211_rate - bitrate definition
  218. *
  219. * This structure describes a bitrate that an 802.11 PHY can
  220. * operate with. The two values @hw_value and @hw_value_short
  221. * are only for driver use when pointers to this structure are
  222. * passed around.
  223. *
  224. * @flags: rate-specific flags
  225. * @bitrate: bitrate in units of 100 Kbps
  226. * @hw_value: driver/hardware value for this rate
  227. * @hw_value_short: driver/hardware value for this rate when
  228. * short preamble is used
  229. */
  230. struct ieee80211_rate {
  231. u32 flags;
  232. u16 bitrate;
  233. u16 hw_value, hw_value_short;
  234. };
  235. /**
  236. * struct ieee80211_sta_ht_cap - STA's HT capabilities
  237. *
  238. * This structure describes most essential parameters needed
  239. * to describe 802.11n HT capabilities for an STA.
  240. *
  241. * @ht_supported: is HT supported by the STA
  242. * @cap: HT capabilities map as described in 802.11n spec
  243. * @ampdu_factor: Maximum A-MPDU length factor
  244. * @ampdu_density: Minimum A-MPDU spacing
  245. * @mcs: Supported MCS rates
  246. */
  247. struct ieee80211_sta_ht_cap {
  248. u16 cap; /* use IEEE80211_HT_CAP_ */
  249. bool ht_supported;
  250. u8 ampdu_factor;
  251. u8 ampdu_density;
  252. struct ieee80211_mcs_info mcs;
  253. };
  254. /**
  255. * struct ieee80211_sta_vht_cap - STA's VHT capabilities
  256. *
  257. * This structure describes most essential parameters needed
  258. * to describe 802.11ac VHT capabilities for an STA.
  259. *
  260. * @vht_supported: is VHT supported by the STA
  261. * @cap: VHT capabilities map as described in 802.11ac spec
  262. * @vht_mcs: Supported VHT MCS rates
  263. */
  264. struct ieee80211_sta_vht_cap {
  265. bool vht_supported;
  266. u32 cap; /* use IEEE80211_VHT_CAP_ */
  267. struct ieee80211_vht_mcs_info vht_mcs;
  268. };
  269. /**
  270. * struct ieee80211_supported_band - frequency band definition
  271. *
  272. * This structure describes a frequency band a wiphy
  273. * is able to operate in.
  274. *
  275. * @channels: Array of channels the hardware can operate in
  276. * in this band.
  277. * @band: the band this structure represents
  278. * @n_channels: Number of channels in @channels
  279. * @bitrates: Array of bitrates the hardware can operate with
  280. * in this band. Must be sorted to give a valid "supported
  281. * rates" IE, i.e. CCK rates first, then OFDM.
  282. * @n_bitrates: Number of bitrates in @bitrates
  283. * @ht_cap: HT capabilities in this band
  284. * @vht_cap: VHT capabilities in this band
  285. */
  286. struct ieee80211_supported_band {
  287. struct ieee80211_channel *channels;
  288. struct ieee80211_rate *bitrates;
  289. enum nl80211_band band;
  290. int n_channels;
  291. int n_bitrates;
  292. struct ieee80211_sta_ht_cap ht_cap;
  293. struct ieee80211_sta_vht_cap vht_cap;
  294. };
  295. /**
  296. * wiphy_read_of_freq_limits - read frequency limits from device tree
  297. *
  298. * @wiphy: the wireless device to get extra limits for
  299. *
  300. * Some devices may have extra limitations specified in DT. This may be useful
  301. * for chipsets that normally support more bands but are limited due to board
  302. * design (e.g. by antennas or external power amplifier).
  303. *
  304. * This function reads info from DT and uses it to *modify* channels (disable
  305. * unavailable ones). It's usually a *bad* idea to use it in drivers with
  306. * shared channel data as DT limitations are device specific. You should make
  307. * sure to call it only if channels in wiphy are copied and can be modified
  308. * without affecting other devices.
  309. *
  310. * As this function access device node it has to be called after set_wiphy_dev.
  311. * It also modifies channels so they have to be set first.
  312. * If using this helper, call it before wiphy_register().
  313. */
  314. #ifdef CONFIG_OF
  315. void wiphy_read_of_freq_limits(struct wiphy *wiphy);
  316. #else /* CONFIG_OF */
  317. static inline void wiphy_read_of_freq_limits(struct wiphy *wiphy)
  318. {
  319. }
  320. #endif /* !CONFIG_OF */
  321. /*
  322. * Wireless hardware/device configuration structures and methods
  323. */
  324. /**
  325. * DOC: Actions and configuration
  326. *
  327. * Each wireless device and each virtual interface offer a set of configuration
  328. * operations and other actions that are invoked by userspace. Each of these
  329. * actions is described in the operations structure, and the parameters these
  330. * operations use are described separately.
  331. *
  332. * Additionally, some operations are asynchronous and expect to get status
  333. * information via some functions that drivers need to call.
  334. *
  335. * Scanning and BSS list handling with its associated functionality is described
  336. * in a separate chapter.
  337. */
  338. #define VHT_MUMIMO_GROUPS_DATA_LEN (WLAN_MEMBERSHIP_LEN +\
  339. WLAN_USER_POSITION_LEN)
  340. /**
  341. * struct vif_params - describes virtual interface parameters
  342. * @flags: monitor interface flags, unchanged if 0, otherwise
  343. * %MONITOR_FLAG_CHANGED will be set
  344. * @use_4addr: use 4-address frames
  345. * @macaddr: address to use for this virtual interface.
  346. * If this parameter is set to zero address the driver may
  347. * determine the address as needed.
  348. * This feature is only fully supported by drivers that enable the
  349. * %NL80211_FEATURE_MAC_ON_CREATE flag. Others may support creating
  350. ** only p2p devices with specified MAC.
  351. * @vht_mumimo_groups: MU-MIMO groupID, used for monitoring MU-MIMO packets
  352. * belonging to that MU-MIMO groupID; %NULL if not changed
  353. * @vht_mumimo_follow_addr: MU-MIMO follow address, used for monitoring
  354. * MU-MIMO packets going to the specified station; %NULL if not changed
  355. */
  356. struct vif_params {
  357. u32 flags;
  358. int use_4addr;
  359. u8 macaddr[ETH_ALEN];
  360. const u8 *vht_mumimo_groups;
  361. const u8 *vht_mumimo_follow_addr;
  362. };
  363. /**
  364. * struct key_params - key information
  365. *
  366. * Information about a key
  367. *
  368. * @key: key material
  369. * @key_len: length of key material
  370. * @cipher: cipher suite selector
  371. * @seq: sequence counter (IV/PN) for TKIP and CCMP keys, only used
  372. * with the get_key() callback, must be in little endian,
  373. * length given by @seq_len.
  374. * @seq_len: length of @seq.
  375. */
  376. struct key_params {
  377. const u8 *key;
  378. const u8 *seq;
  379. int key_len;
  380. int seq_len;
  381. u32 cipher;
  382. };
  383. /**
  384. * struct cfg80211_chan_def - channel definition
  385. * @chan: the (control) channel
  386. * @width: channel width
  387. * @center_freq1: center frequency of first segment
  388. * @center_freq2: center frequency of second segment
  389. * (only with 80+80 MHz)
  390. */
  391. struct cfg80211_chan_def {
  392. struct ieee80211_channel *chan;
  393. enum nl80211_chan_width width;
  394. u32 center_freq1;
  395. u32 center_freq2;
  396. };
  397. /**
  398. * cfg80211_get_chandef_type - return old channel type from chandef
  399. * @chandef: the channel definition
  400. *
  401. * Return: The old channel type (NOHT, HT20, HT40+/-) from a given
  402. * chandef, which must have a bandwidth allowing this conversion.
  403. */
  404. static inline enum nl80211_channel_type
  405. cfg80211_get_chandef_type(const struct cfg80211_chan_def *chandef)
  406. {
  407. switch (chandef->width) {
  408. case NL80211_CHAN_WIDTH_20_NOHT:
  409. return NL80211_CHAN_NO_HT;
  410. case NL80211_CHAN_WIDTH_20:
  411. return NL80211_CHAN_HT20;
  412. case NL80211_CHAN_WIDTH_40:
  413. if (chandef->center_freq1 > chandef->chan->center_freq)
  414. return NL80211_CHAN_HT40PLUS;
  415. return NL80211_CHAN_HT40MINUS;
  416. default:
  417. WARN_ON(1);
  418. return NL80211_CHAN_NO_HT;
  419. }
  420. }
  421. /**
  422. * cfg80211_chandef_create - create channel definition using channel type
  423. * @chandef: the channel definition struct to fill
  424. * @channel: the control channel
  425. * @chantype: the channel type
  426. *
  427. * Given a channel type, create a channel definition.
  428. */
  429. void cfg80211_chandef_create(struct cfg80211_chan_def *chandef,
  430. struct ieee80211_channel *channel,
  431. enum nl80211_channel_type chantype);
  432. /**
  433. * cfg80211_chandef_identical - check if two channel definitions are identical
  434. * @chandef1: first channel definition
  435. * @chandef2: second channel definition
  436. *
  437. * Return: %true if the channels defined by the channel definitions are
  438. * identical, %false otherwise.
  439. */
  440. static inline bool
  441. cfg80211_chandef_identical(const struct cfg80211_chan_def *chandef1,
  442. const struct cfg80211_chan_def *chandef2)
  443. {
  444. return (chandef1->chan == chandef2->chan &&
  445. chandef1->width == chandef2->width &&
  446. chandef1->center_freq1 == chandef2->center_freq1 &&
  447. chandef1->center_freq2 == chandef2->center_freq2);
  448. }
  449. /**
  450. * cfg80211_chandef_compatible - check if two channel definitions are compatible
  451. * @chandef1: first channel definition
  452. * @chandef2: second channel definition
  453. *
  454. * Return: %NULL if the given channel definitions are incompatible,
  455. * chandef1 or chandef2 otherwise.
  456. */
  457. const struct cfg80211_chan_def *
  458. cfg80211_chandef_compatible(const struct cfg80211_chan_def *chandef1,
  459. const struct cfg80211_chan_def *chandef2);
  460. /**
  461. * cfg80211_chandef_valid - check if a channel definition is valid
  462. * @chandef: the channel definition to check
  463. * Return: %true if the channel definition is valid. %false otherwise.
  464. */
  465. bool cfg80211_chandef_valid(const struct cfg80211_chan_def *chandef);
  466. /**
  467. * cfg80211_chandef_usable - check if secondary channels can be used
  468. * @wiphy: the wiphy to validate against
  469. * @chandef: the channel definition to check
  470. * @prohibited_flags: the regulatory channel flags that must not be set
  471. * Return: %true if secondary channels are usable. %false otherwise.
  472. */
  473. bool cfg80211_chandef_usable(struct wiphy *wiphy,
  474. const struct cfg80211_chan_def *chandef,
  475. u32 prohibited_flags);
  476. /**
  477. * cfg80211_chandef_dfs_required - checks if radar detection is required
  478. * @wiphy: the wiphy to validate against
  479. * @chandef: the channel definition to check
  480. * @iftype: the interface type as specified in &enum nl80211_iftype
  481. * Returns:
  482. * 1 if radar detection is required, 0 if it is not, < 0 on error
  483. */
  484. int cfg80211_chandef_dfs_required(struct wiphy *wiphy,
  485. const struct cfg80211_chan_def *chandef,
  486. enum nl80211_iftype iftype);
  487. /**
  488. * ieee80211_chandef_rate_flags - returns rate flags for a channel
  489. *
  490. * In some channel types, not all rates may be used - for example CCK
  491. * rates may not be used in 5/10 MHz channels.
  492. *
  493. * @chandef: channel definition for the channel
  494. *
  495. * Returns: rate flags which apply for this channel
  496. */
  497. static inline enum ieee80211_rate_flags
  498. ieee80211_chandef_rate_flags(struct cfg80211_chan_def *chandef)
  499. {
  500. switch (chandef->width) {
  501. case NL80211_CHAN_WIDTH_5:
  502. return IEEE80211_RATE_SUPPORTS_5MHZ;
  503. case NL80211_CHAN_WIDTH_10:
  504. return IEEE80211_RATE_SUPPORTS_10MHZ;
  505. default:
  506. break;
  507. }
  508. return 0;
  509. }
  510. /**
  511. * ieee80211_chandef_max_power - maximum transmission power for the chandef
  512. *
  513. * In some regulations, the transmit power may depend on the configured channel
  514. * bandwidth which may be defined as dBm/MHz. This function returns the actual
  515. * max_power for non-standard (20 MHz) channels.
  516. *
  517. * @chandef: channel definition for the channel
  518. *
  519. * Returns: maximum allowed transmission power in dBm for the chandef
  520. */
  521. static inline int
  522. ieee80211_chandef_max_power(struct cfg80211_chan_def *chandef)
  523. {
  524. switch (chandef->width) {
  525. case NL80211_CHAN_WIDTH_5:
  526. return min(chandef->chan->max_reg_power - 6,
  527. chandef->chan->max_power);
  528. case NL80211_CHAN_WIDTH_10:
  529. return min(chandef->chan->max_reg_power - 3,
  530. chandef->chan->max_power);
  531. default:
  532. break;
  533. }
  534. return chandef->chan->max_power;
  535. }
  536. /**
  537. * enum survey_info_flags - survey information flags
  538. *
  539. * @SURVEY_INFO_NOISE_DBM: noise (in dBm) was filled in
  540. * @SURVEY_INFO_IN_USE: channel is currently being used
  541. * @SURVEY_INFO_TIME: active time (in ms) was filled in
  542. * @SURVEY_INFO_TIME_BUSY: busy time was filled in
  543. * @SURVEY_INFO_TIME_EXT_BUSY: extension channel busy time was filled in
  544. * @SURVEY_INFO_TIME_RX: receive time was filled in
  545. * @SURVEY_INFO_TIME_TX: transmit time was filled in
  546. * @SURVEY_INFO_TIME_SCAN: scan time was filled in
  547. *
  548. * Used by the driver to indicate which info in &struct survey_info
  549. * it has filled in during the get_survey().
  550. */
  551. enum survey_info_flags {
  552. SURVEY_INFO_NOISE_DBM = BIT(0),
  553. SURVEY_INFO_IN_USE = BIT(1),
  554. SURVEY_INFO_TIME = BIT(2),
  555. SURVEY_INFO_TIME_BUSY = BIT(3),
  556. SURVEY_INFO_TIME_EXT_BUSY = BIT(4),
  557. SURVEY_INFO_TIME_RX = BIT(5),
  558. SURVEY_INFO_TIME_TX = BIT(6),
  559. SURVEY_INFO_TIME_SCAN = BIT(7),
  560. };
  561. /**
  562. * struct survey_info - channel survey response
  563. *
  564. * @channel: the channel this survey record reports, may be %NULL for a single
  565. * record to report global statistics
  566. * @filled: bitflag of flags from &enum survey_info_flags
  567. * @noise: channel noise in dBm. This and all following fields are
  568. * optional
  569. * @time: amount of time in ms the radio was turn on (on the channel)
  570. * @time_busy: amount of time the primary channel was sensed busy
  571. * @time_ext_busy: amount of time the extension channel was sensed busy
  572. * @time_rx: amount of time the radio spent receiving data
  573. * @time_tx: amount of time the radio spent transmitting data
  574. * @time_scan: amount of time the radio spent for scanning
  575. *
  576. * Used by dump_survey() to report back per-channel survey information.
  577. *
  578. * This structure can later be expanded with things like
  579. * channel duty cycle etc.
  580. */
  581. struct survey_info {
  582. struct ieee80211_channel *channel;
  583. u64 time;
  584. u64 time_busy;
  585. u64 time_ext_busy;
  586. u64 time_rx;
  587. u64 time_tx;
  588. u64 time_scan;
  589. u32 filled;
  590. s8 noise;
  591. };
  592. #define CFG80211_MAX_WEP_KEYS 4
  593. /**
  594. * struct cfg80211_crypto_settings - Crypto settings
  595. * @wpa_versions: indicates which, if any, WPA versions are enabled
  596. * (from enum nl80211_wpa_versions)
  597. * @cipher_group: group key cipher suite (or 0 if unset)
  598. * @n_ciphers_pairwise: number of AP supported unicast ciphers
  599. * @ciphers_pairwise: unicast key cipher suites
  600. * @n_akm_suites: number of AKM suites
  601. * @akm_suites: AKM suites
  602. * @control_port: Whether user space controls IEEE 802.1X port, i.e.,
  603. * sets/clears %NL80211_STA_FLAG_AUTHORIZED. If true, the driver is
  604. * required to assume that the port is unauthorized until authorized by
  605. * user space. Otherwise, port is marked authorized by default.
  606. * @control_port_ethertype: the control port protocol that should be
  607. * allowed through even on unauthorized ports
  608. * @control_port_no_encrypt: TRUE to prevent encryption of control port
  609. * protocol frames.
  610. * @wep_keys: static WEP keys, if not NULL points to an array of
  611. * CFG80211_MAX_WEP_KEYS WEP keys
  612. * @wep_tx_key: key index (0..3) of the default TX static WEP key
  613. * @psk: PSK (for devices supporting 4-way-handshake offload)
  614. */
  615. struct cfg80211_crypto_settings {
  616. u32 wpa_versions;
  617. u32 cipher_group;
  618. int n_ciphers_pairwise;
  619. u32 ciphers_pairwise[NL80211_MAX_NR_CIPHER_SUITES];
  620. int n_akm_suites;
  621. u32 akm_suites[NL80211_MAX_NR_AKM_SUITES];
  622. bool control_port;
  623. __be16 control_port_ethertype;
  624. bool control_port_no_encrypt;
  625. struct key_params *wep_keys;
  626. int wep_tx_key;
  627. const u8 *psk;
  628. };
  629. /**
  630. * struct cfg80211_beacon_data - beacon data
  631. * @head: head portion of beacon (before TIM IE)
  632. * or %NULL if not changed
  633. * @tail: tail portion of beacon (after TIM IE)
  634. * or %NULL if not changed
  635. * @head_len: length of @head
  636. * @tail_len: length of @tail
  637. * @beacon_ies: extra information element(s) to add into Beacon frames or %NULL
  638. * @beacon_ies_len: length of beacon_ies in octets
  639. * @proberesp_ies: extra information element(s) to add into Probe Response
  640. * frames or %NULL
  641. * @proberesp_ies_len: length of proberesp_ies in octets
  642. * @assocresp_ies: extra information element(s) to add into (Re)Association
  643. * Response frames or %NULL
  644. * @assocresp_ies_len: length of assocresp_ies in octets
  645. * @probe_resp_len: length of probe response template (@probe_resp)
  646. * @probe_resp: probe response template (AP mode only)
  647. */
  648. struct cfg80211_beacon_data {
  649. const u8 *head, *tail;
  650. const u8 *beacon_ies;
  651. const u8 *proberesp_ies;
  652. const u8 *assocresp_ies;
  653. const u8 *probe_resp;
  654. size_t head_len, tail_len;
  655. size_t beacon_ies_len;
  656. size_t proberesp_ies_len;
  657. size_t assocresp_ies_len;
  658. size_t probe_resp_len;
  659. };
  660. struct mac_address {
  661. u8 addr[ETH_ALEN];
  662. };
  663. /**
  664. * struct cfg80211_acl_data - Access control list data
  665. *
  666. * @acl_policy: ACL policy to be applied on the station's
  667. * entry specified by mac_addr
  668. * @n_acl_entries: Number of MAC address entries passed
  669. * @mac_addrs: List of MAC addresses of stations to be used for ACL
  670. */
  671. struct cfg80211_acl_data {
  672. enum nl80211_acl_policy acl_policy;
  673. int n_acl_entries;
  674. /* Keep it last */
  675. struct mac_address mac_addrs[];
  676. };
  677. /*
  678. * cfg80211_bitrate_mask - masks for bitrate control
  679. */
  680. struct cfg80211_bitrate_mask {
  681. struct {
  682. u32 legacy;
  683. u8 ht_mcs[IEEE80211_HT_MCS_MASK_LEN];
  684. u16 vht_mcs[NL80211_VHT_NSS_MAX];
  685. enum nl80211_txrate_gi gi;
  686. } control[NUM_NL80211_BANDS];
  687. };
  688. /**
  689. * struct cfg80211_ap_settings - AP configuration
  690. *
  691. * Used to configure an AP interface.
  692. *
  693. * @chandef: defines the channel to use
  694. * @beacon: beacon data
  695. * @beacon_interval: beacon interval
  696. * @dtim_period: DTIM period
  697. * @ssid: SSID to be used in the BSS (note: may be %NULL if not provided from
  698. * user space)
  699. * @ssid_len: length of @ssid
  700. * @hidden_ssid: whether to hide the SSID in Beacon/Probe Response frames
  701. * @crypto: crypto settings
  702. * @privacy: the BSS uses privacy
  703. * @auth_type: Authentication type (algorithm)
  704. * @smps_mode: SMPS mode
  705. * @inactivity_timeout: time in seconds to determine station's inactivity.
  706. * @p2p_ctwindow: P2P CT Window
  707. * @p2p_opp_ps: P2P opportunistic PS
  708. * @acl: ACL configuration used by the drivers which has support for
  709. * MAC address based access control
  710. * @pbss: If set, start as a PCP instead of AP. Relevant for DMG
  711. * networks.
  712. * @beacon_rate: bitrate to be used for beacons
  713. * @ht_cap: HT capabilities (or %NULL if HT isn't enabled)
  714. * @vht_cap: VHT capabilities (or %NULL if VHT isn't enabled)
  715. * @ht_required: stations must support HT
  716. * @vht_required: stations must support VHT
  717. */
  718. struct cfg80211_ap_settings {
  719. struct cfg80211_chan_def chandef;
  720. struct cfg80211_beacon_data beacon;
  721. int beacon_interval, dtim_period;
  722. const u8 *ssid;
  723. size_t ssid_len;
  724. enum nl80211_hidden_ssid hidden_ssid;
  725. struct cfg80211_crypto_settings crypto;
  726. bool privacy;
  727. enum nl80211_auth_type auth_type;
  728. enum nl80211_smps_mode smps_mode;
  729. int inactivity_timeout;
  730. u8 p2p_ctwindow;
  731. bool p2p_opp_ps;
  732. const struct cfg80211_acl_data *acl;
  733. bool pbss;
  734. struct cfg80211_bitrate_mask beacon_rate;
  735. const struct ieee80211_ht_cap *ht_cap;
  736. const struct ieee80211_vht_cap *vht_cap;
  737. bool ht_required, vht_required;
  738. };
  739. /**
  740. * struct cfg80211_csa_settings - channel switch settings
  741. *
  742. * Used for channel switch
  743. *
  744. * @chandef: defines the channel to use after the switch
  745. * @beacon_csa: beacon data while performing the switch
  746. * @counter_offsets_beacon: offsets of the counters within the beacon (tail)
  747. * @counter_offsets_presp: offsets of the counters within the probe response
  748. * @n_counter_offsets_beacon: number of csa counters the beacon (tail)
  749. * @n_counter_offsets_presp: number of csa counters in the probe response
  750. * @beacon_after: beacon data to be used on the new channel
  751. * @radar_required: whether radar detection is required on the new channel
  752. * @block_tx: whether transmissions should be blocked while changing
  753. * @count: number of beacons until switch
  754. */
  755. struct cfg80211_csa_settings {
  756. struct cfg80211_chan_def chandef;
  757. struct cfg80211_beacon_data beacon_csa;
  758. const u16 *counter_offsets_beacon;
  759. const u16 *counter_offsets_presp;
  760. unsigned int n_counter_offsets_beacon;
  761. unsigned int n_counter_offsets_presp;
  762. struct cfg80211_beacon_data beacon_after;
  763. bool radar_required;
  764. bool block_tx;
  765. u8 count;
  766. };
  767. /**
  768. * struct iface_combination_params - input parameters for interface combinations
  769. *
  770. * Used to pass interface combination parameters
  771. *
  772. * @num_different_channels: the number of different channels we want
  773. * to use for verification
  774. * @radar_detect: a bitmap where each bit corresponds to a channel
  775. * width where radar detection is needed, as in the definition of
  776. * &struct ieee80211_iface_combination.@radar_detect_widths
  777. * @iftype_num: array with the number of interfaces of each interface
  778. * type. The index is the interface type as specified in &enum
  779. * nl80211_iftype.
  780. * @new_beacon_int: set this to the beacon interval of a new interface
  781. * that's not operating yet, if such is to be checked as part of
  782. * the verification
  783. */
  784. struct iface_combination_params {
  785. int num_different_channels;
  786. u8 radar_detect;
  787. int iftype_num[NUM_NL80211_IFTYPES];
  788. u32 new_beacon_int;
  789. };
  790. /**
  791. * enum station_parameters_apply_mask - station parameter values to apply
  792. * @STATION_PARAM_APPLY_UAPSD: apply new uAPSD parameters (uapsd_queues, max_sp)
  793. * @STATION_PARAM_APPLY_CAPABILITY: apply new capability
  794. * @STATION_PARAM_APPLY_PLINK_STATE: apply new plink state
  795. *
  796. * Not all station parameters have in-band "no change" signalling,
  797. * for those that don't these flags will are used.
  798. */
  799. enum station_parameters_apply_mask {
  800. STATION_PARAM_APPLY_UAPSD = BIT(0),
  801. STATION_PARAM_APPLY_CAPABILITY = BIT(1),
  802. STATION_PARAM_APPLY_PLINK_STATE = BIT(2),
  803. };
  804. /**
  805. * struct station_parameters - station parameters
  806. *
  807. * Used to change and create a new station.
  808. *
  809. * @vlan: vlan interface station should belong to
  810. * @supported_rates: supported rates in IEEE 802.11 format
  811. * (or NULL for no change)
  812. * @supported_rates_len: number of supported rates
  813. * @sta_flags_mask: station flags that changed
  814. * (bitmask of BIT(%NL80211_STA_FLAG_...))
  815. * @sta_flags_set: station flags values
  816. * (bitmask of BIT(%NL80211_STA_FLAG_...))
  817. * @listen_interval: listen interval or -1 for no change
  818. * @aid: AID or zero for no change
  819. * @peer_aid: mesh peer AID or zero for no change
  820. * @plink_action: plink action to take
  821. * @plink_state: set the peer link state for a station
  822. * @ht_capa: HT capabilities of station
  823. * @vht_capa: VHT capabilities of station
  824. * @uapsd_queues: bitmap of queues configured for uapsd. same format
  825. * as the AC bitmap in the QoS info field
  826. * @max_sp: max Service Period. same format as the MAX_SP in the
  827. * QoS info field (but already shifted down)
  828. * @sta_modify_mask: bitmap indicating which parameters changed
  829. * (for those that don't have a natural "no change" value),
  830. * see &enum station_parameters_apply_mask
  831. * @local_pm: local link-specific mesh power save mode (no change when set
  832. * to unknown)
  833. * @capability: station capability
  834. * @ext_capab: extended capabilities of the station
  835. * @ext_capab_len: number of extended capabilities
  836. * @supported_channels: supported channels in IEEE 802.11 format
  837. * @supported_channels_len: number of supported channels
  838. * @supported_oper_classes: supported oper classes in IEEE 802.11 format
  839. * @supported_oper_classes_len: number of supported operating classes
  840. * @opmode_notif: operating mode field from Operating Mode Notification
  841. * @opmode_notif_used: information if operating mode field is used
  842. * @support_p2p_ps: information if station supports P2P PS mechanism
  843. */
  844. struct station_parameters {
  845. const u8 *supported_rates;
  846. struct net_device *vlan;
  847. u32 sta_flags_mask, sta_flags_set;
  848. u32 sta_modify_mask;
  849. int listen_interval;
  850. u16 aid;
  851. u16 peer_aid;
  852. u8 supported_rates_len;
  853. u8 plink_action;
  854. u8 plink_state;
  855. const struct ieee80211_ht_cap *ht_capa;
  856. const struct ieee80211_vht_cap *vht_capa;
  857. u8 uapsd_queues;
  858. u8 max_sp;
  859. enum nl80211_mesh_power_mode local_pm;
  860. u16 capability;
  861. const u8 *ext_capab;
  862. u8 ext_capab_len;
  863. const u8 *supported_channels;
  864. u8 supported_channels_len;
  865. const u8 *supported_oper_classes;
  866. u8 supported_oper_classes_len;
  867. u8 opmode_notif;
  868. bool opmode_notif_used;
  869. int support_p2p_ps;
  870. };
  871. /**
  872. * struct station_del_parameters - station deletion parameters
  873. *
  874. * Used to delete a station entry (or all stations).
  875. *
  876. * @mac: MAC address of the station to remove or NULL to remove all stations
  877. * @subtype: Management frame subtype to use for indicating removal
  878. * (10 = Disassociation, 12 = Deauthentication)
  879. * @reason_code: Reason code for the Disassociation/Deauthentication frame
  880. */
  881. struct station_del_parameters {
  882. const u8 *mac;
  883. u8 subtype;
  884. u16 reason_code;
  885. };
  886. /**
  887. * enum cfg80211_station_type - the type of station being modified
  888. * @CFG80211_STA_AP_CLIENT: client of an AP interface
  889. * @CFG80211_STA_AP_CLIENT_UNASSOC: client of an AP interface that is still
  890. * unassociated (update properties for this type of client is permitted)
  891. * @CFG80211_STA_AP_MLME_CLIENT: client of an AP interface that has
  892. * the AP MLME in the device
  893. * @CFG80211_STA_AP_STA: AP station on managed interface
  894. * @CFG80211_STA_IBSS: IBSS station
  895. * @CFG80211_STA_TDLS_PEER_SETUP: TDLS peer on managed interface (dummy entry
  896. * while TDLS setup is in progress, it moves out of this state when
  897. * being marked authorized; use this only if TDLS with external setup is
  898. * supported/used)
  899. * @CFG80211_STA_TDLS_PEER_ACTIVE: TDLS peer on managed interface (active
  900. * entry that is operating, has been marked authorized by userspace)
  901. * @CFG80211_STA_MESH_PEER_KERNEL: peer on mesh interface (kernel managed)
  902. * @CFG80211_STA_MESH_PEER_USER: peer on mesh interface (user managed)
  903. */
  904. enum cfg80211_station_type {
  905. CFG80211_STA_AP_CLIENT,
  906. CFG80211_STA_AP_CLIENT_UNASSOC,
  907. CFG80211_STA_AP_MLME_CLIENT,
  908. CFG80211_STA_AP_STA,
  909. CFG80211_STA_IBSS,
  910. CFG80211_STA_TDLS_PEER_SETUP,
  911. CFG80211_STA_TDLS_PEER_ACTIVE,
  912. CFG80211_STA_MESH_PEER_KERNEL,
  913. CFG80211_STA_MESH_PEER_USER,
  914. };
  915. /**
  916. * cfg80211_check_station_change - validate parameter changes
  917. * @wiphy: the wiphy this operates on
  918. * @params: the new parameters for a station
  919. * @statype: the type of station being modified
  920. *
  921. * Utility function for the @change_station driver method. Call this function
  922. * with the appropriate station type looking up the station (and checking that
  923. * it exists). It will verify whether the station change is acceptable, and if
  924. * not will return an error code. Note that it may modify the parameters for
  925. * backward compatibility reasons, so don't use them before calling this.
  926. */
  927. int cfg80211_check_station_change(struct wiphy *wiphy,
  928. struct station_parameters *params,
  929. enum cfg80211_station_type statype);
  930. /**
  931. * enum station_info_rate_flags - bitrate info flags
  932. *
  933. * Used by the driver to indicate the specific rate transmission
  934. * type for 802.11n transmissions.
  935. *
  936. * @RATE_INFO_FLAGS_MCS: mcs field filled with HT MCS
  937. * @RATE_INFO_FLAGS_VHT_MCS: mcs field filled with VHT MCS
  938. * @RATE_INFO_FLAGS_SHORT_GI: 400ns guard interval
  939. * @RATE_INFO_FLAGS_60G: 60GHz MCS
  940. */
  941. enum rate_info_flags {
  942. RATE_INFO_FLAGS_MCS = BIT(0),
  943. RATE_INFO_FLAGS_VHT_MCS = BIT(1),
  944. RATE_INFO_FLAGS_SHORT_GI = BIT(2),
  945. RATE_INFO_FLAGS_60G = BIT(3),
  946. };
  947. /**
  948. * enum rate_info_bw - rate bandwidth information
  949. *
  950. * Used by the driver to indicate the rate bandwidth.
  951. *
  952. * @RATE_INFO_BW_5: 5 MHz bandwidth
  953. * @RATE_INFO_BW_10: 10 MHz bandwidth
  954. * @RATE_INFO_BW_20: 20 MHz bandwidth
  955. * @RATE_INFO_BW_40: 40 MHz bandwidth
  956. * @RATE_INFO_BW_80: 80 MHz bandwidth
  957. * @RATE_INFO_BW_160: 160 MHz bandwidth
  958. */
  959. enum rate_info_bw {
  960. RATE_INFO_BW_20 = 0,
  961. RATE_INFO_BW_5,
  962. RATE_INFO_BW_10,
  963. RATE_INFO_BW_40,
  964. RATE_INFO_BW_80,
  965. RATE_INFO_BW_160,
  966. };
  967. /**
  968. * struct rate_info - bitrate information
  969. *
  970. * Information about a receiving or transmitting bitrate
  971. *
  972. * @flags: bitflag of flags from &enum rate_info_flags
  973. * @mcs: mcs index if struct describes a 802.11n bitrate
  974. * @legacy: bitrate in 100kbit/s for 802.11abg
  975. * @nss: number of streams (VHT only)
  976. * @bw: bandwidth (from &enum rate_info_bw)
  977. */
  978. struct rate_info {
  979. u8 flags;
  980. u8 mcs;
  981. u16 legacy;
  982. u8 nss;
  983. u8 bw;
  984. };
  985. /**
  986. * enum station_info_rate_flags - bitrate info flags
  987. *
  988. * Used by the driver to indicate the specific rate transmission
  989. * type for 802.11n transmissions.
  990. *
  991. * @BSS_PARAM_FLAGS_CTS_PROT: whether CTS protection is enabled
  992. * @BSS_PARAM_FLAGS_SHORT_PREAMBLE: whether short preamble is enabled
  993. * @BSS_PARAM_FLAGS_SHORT_SLOT_TIME: whether short slot time is enabled
  994. */
  995. enum bss_param_flags {
  996. BSS_PARAM_FLAGS_CTS_PROT = 1<<0,
  997. BSS_PARAM_FLAGS_SHORT_PREAMBLE = 1<<1,
  998. BSS_PARAM_FLAGS_SHORT_SLOT_TIME = 1<<2,
  999. };
  1000. /**
  1001. * struct sta_bss_parameters - BSS parameters for the attached station
  1002. *
  1003. * Information about the currently associated BSS
  1004. *
  1005. * @flags: bitflag of flags from &enum bss_param_flags
  1006. * @dtim_period: DTIM period for the BSS
  1007. * @beacon_interval: beacon interval
  1008. */
  1009. struct sta_bss_parameters {
  1010. u8 flags;
  1011. u8 dtim_period;
  1012. u16 beacon_interval;
  1013. };
  1014. /**
  1015. * struct cfg80211_tid_stats - per-TID statistics
  1016. * @filled: bitmap of flags using the bits of &enum nl80211_tid_stats to
  1017. * indicate the relevant values in this struct are filled
  1018. * @rx_msdu: number of received MSDUs
  1019. * @tx_msdu: number of (attempted) transmitted MSDUs
  1020. * @tx_msdu_retries: number of retries (not counting the first) for
  1021. * transmitted MSDUs
  1022. * @tx_msdu_failed: number of failed transmitted MSDUs
  1023. */
  1024. struct cfg80211_tid_stats {
  1025. u32 filled;
  1026. u64 rx_msdu;
  1027. u64 tx_msdu;
  1028. u64 tx_msdu_retries;
  1029. u64 tx_msdu_failed;
  1030. };
  1031. #define IEEE80211_MAX_CHAINS 4
  1032. /**
  1033. * struct station_info - station information
  1034. *
  1035. * Station information filled by driver for get_station() and dump_station.
  1036. *
  1037. * @filled: bitflag of flags using the bits of &enum nl80211_sta_info to
  1038. * indicate the relevant values in this struct for them
  1039. * @connected_time: time(in secs) since a station is last connected
  1040. * @inactive_time: time since last station activity (tx/rx) in milliseconds
  1041. * @rx_bytes: bytes (size of MPDUs) received from this station
  1042. * @tx_bytes: bytes (size of MPDUs) transmitted to this station
  1043. * @llid: mesh local link id
  1044. * @plid: mesh peer link id
  1045. * @plink_state: mesh peer link state
  1046. * @signal: The signal strength, type depends on the wiphy's signal_type.
  1047. * For CFG80211_SIGNAL_TYPE_MBM, value is expressed in _dBm_.
  1048. * @signal_avg: Average signal strength, type depends on the wiphy's signal_type.
  1049. * For CFG80211_SIGNAL_TYPE_MBM, value is expressed in _dBm_.
  1050. * @chains: bitmask for filled values in @chain_signal, @chain_signal_avg
  1051. * @chain_signal: per-chain signal strength of last received packet in dBm
  1052. * @chain_signal_avg: per-chain signal strength average in dBm
  1053. * @txrate: current unicast bitrate from this station
  1054. * @rxrate: current unicast bitrate to this station
  1055. * @rx_packets: packets (MSDUs & MMPDUs) received from this station
  1056. * @tx_packets: packets (MSDUs & MMPDUs) transmitted to this station
  1057. * @tx_retries: cumulative retry counts (MPDUs)
  1058. * @tx_failed: number of failed transmissions (MPDUs) (retries exceeded, no ACK)
  1059. * @rx_dropped_misc: Dropped for un-specified reason.
  1060. * @bss_param: current BSS parameters
  1061. * @generation: generation number for nl80211 dumps.
  1062. * This number should increase every time the list of stations
  1063. * changes, i.e. when a station is added or removed, so that
  1064. * userspace can tell whether it got a consistent snapshot.
  1065. * @assoc_req_ies: IEs from (Re)Association Request.
  1066. * This is used only when in AP mode with drivers that do not use
  1067. * user space MLME/SME implementation. The information is provided for
  1068. * the cfg80211_new_sta() calls to notify user space of the IEs.
  1069. * @assoc_req_ies_len: Length of assoc_req_ies buffer in octets.
  1070. * @sta_flags: station flags mask & values
  1071. * @beacon_loss_count: Number of times beacon loss event has triggered.
  1072. * @t_offset: Time offset of the station relative to this host.
  1073. * @local_pm: local mesh STA power save mode
  1074. * @peer_pm: peer mesh STA power save mode
  1075. * @nonpeer_pm: non-peer mesh STA power save mode
  1076. * @expected_throughput: expected throughput in kbps (including 802.11 headers)
  1077. * towards this station.
  1078. * @rx_beacon: number of beacons received from this peer
  1079. * @rx_beacon_signal_avg: signal strength average (in dBm) for beacons received
  1080. * from this peer
  1081. * @rx_duration: aggregate PPDU duration(usecs) for all the frames from a peer
  1082. * @pertid: per-TID statistics, see &struct cfg80211_tid_stats, using the last
  1083. * (IEEE80211_NUM_TIDS) index for MSDUs not encapsulated in QoS-MPDUs.
  1084. */
  1085. struct station_info {
  1086. u64 filled;
  1087. u32 connected_time;
  1088. u32 inactive_time;
  1089. u64 rx_bytes;
  1090. u64 tx_bytes;
  1091. u16 llid;
  1092. u16 plid;
  1093. u8 plink_state;
  1094. s8 signal;
  1095. s8 signal_avg;
  1096. u8 chains;
  1097. s8 chain_signal[IEEE80211_MAX_CHAINS];
  1098. s8 chain_signal_avg[IEEE80211_MAX_CHAINS];
  1099. struct rate_info txrate;
  1100. struct rate_info rxrate;
  1101. u32 rx_packets;
  1102. u32 tx_packets;
  1103. u32 tx_retries;
  1104. u32 tx_failed;
  1105. u32 rx_dropped_misc;
  1106. struct sta_bss_parameters bss_param;
  1107. struct nl80211_sta_flag_update sta_flags;
  1108. int generation;
  1109. const u8 *assoc_req_ies;
  1110. size_t assoc_req_ies_len;
  1111. u32 beacon_loss_count;
  1112. s64 t_offset;
  1113. enum nl80211_mesh_power_mode local_pm;
  1114. enum nl80211_mesh_power_mode peer_pm;
  1115. enum nl80211_mesh_power_mode nonpeer_pm;
  1116. u32 expected_throughput;
  1117. u64 rx_beacon;
  1118. u64 rx_duration;
  1119. u8 rx_beacon_signal_avg;
  1120. struct cfg80211_tid_stats pertid[IEEE80211_NUM_TIDS + 1];
  1121. };
  1122. #if IS_ENABLED(CONFIG_CFG80211)
  1123. /**
  1124. * cfg80211_get_station - retrieve information about a given station
  1125. * @dev: the device where the station is supposed to be connected to
  1126. * @mac_addr: the mac address of the station of interest
  1127. * @sinfo: pointer to the structure to fill with the information
  1128. *
  1129. * Returns 0 on success and sinfo is filled with the available information
  1130. * otherwise returns a negative error code and the content of sinfo has to be
  1131. * considered undefined.
  1132. */
  1133. int cfg80211_get_station(struct net_device *dev, const u8 *mac_addr,
  1134. struct station_info *sinfo);
  1135. #else
  1136. static inline int cfg80211_get_station(struct net_device *dev,
  1137. const u8 *mac_addr,
  1138. struct station_info *sinfo)
  1139. {
  1140. return -ENOENT;
  1141. }
  1142. #endif
  1143. /**
  1144. * enum monitor_flags - monitor flags
  1145. *
  1146. * Monitor interface configuration flags. Note that these must be the bits
  1147. * according to the nl80211 flags.
  1148. *
  1149. * @MONITOR_FLAG_CHANGED: set if the flags were changed
  1150. * @MONITOR_FLAG_FCSFAIL: pass frames with bad FCS
  1151. * @MONITOR_FLAG_PLCPFAIL: pass frames with bad PLCP
  1152. * @MONITOR_FLAG_CONTROL: pass control frames
  1153. * @MONITOR_FLAG_OTHER_BSS: disable BSSID filtering
  1154. * @MONITOR_FLAG_COOK_FRAMES: report frames after processing
  1155. * @MONITOR_FLAG_ACTIVE: active monitor, ACKs frames on its MAC address
  1156. */
  1157. enum monitor_flags {
  1158. MONITOR_FLAG_CHANGED = 1<<__NL80211_MNTR_FLAG_INVALID,
  1159. MONITOR_FLAG_FCSFAIL = 1<<NL80211_MNTR_FLAG_FCSFAIL,
  1160. MONITOR_FLAG_PLCPFAIL = 1<<NL80211_MNTR_FLAG_PLCPFAIL,
  1161. MONITOR_FLAG_CONTROL = 1<<NL80211_MNTR_FLAG_CONTROL,
  1162. MONITOR_FLAG_OTHER_BSS = 1<<NL80211_MNTR_FLAG_OTHER_BSS,
  1163. MONITOR_FLAG_COOK_FRAMES = 1<<NL80211_MNTR_FLAG_COOK_FRAMES,
  1164. MONITOR_FLAG_ACTIVE = 1<<NL80211_MNTR_FLAG_ACTIVE,
  1165. };
  1166. /**
  1167. * enum mpath_info_flags - mesh path information flags
  1168. *
  1169. * Used by the driver to indicate which info in &struct mpath_info it has filled
  1170. * in during get_station() or dump_station().
  1171. *
  1172. * @MPATH_INFO_FRAME_QLEN: @frame_qlen filled
  1173. * @MPATH_INFO_SN: @sn filled
  1174. * @MPATH_INFO_METRIC: @metric filled
  1175. * @MPATH_INFO_EXPTIME: @exptime filled
  1176. * @MPATH_INFO_DISCOVERY_TIMEOUT: @discovery_timeout filled
  1177. * @MPATH_INFO_DISCOVERY_RETRIES: @discovery_retries filled
  1178. * @MPATH_INFO_FLAGS: @flags filled
  1179. */
  1180. enum mpath_info_flags {
  1181. MPATH_INFO_FRAME_QLEN = BIT(0),
  1182. MPATH_INFO_SN = BIT(1),
  1183. MPATH_INFO_METRIC = BIT(2),
  1184. MPATH_INFO_EXPTIME = BIT(3),
  1185. MPATH_INFO_DISCOVERY_TIMEOUT = BIT(4),
  1186. MPATH_INFO_DISCOVERY_RETRIES = BIT(5),
  1187. MPATH_INFO_FLAGS = BIT(6),
  1188. };
  1189. /**
  1190. * struct mpath_info - mesh path information
  1191. *
  1192. * Mesh path information filled by driver for get_mpath() and dump_mpath().
  1193. *
  1194. * @filled: bitfield of flags from &enum mpath_info_flags
  1195. * @frame_qlen: number of queued frames for this destination
  1196. * @sn: target sequence number
  1197. * @metric: metric (cost) of this mesh path
  1198. * @exptime: expiration time for the mesh path from now, in msecs
  1199. * @flags: mesh path flags
  1200. * @discovery_timeout: total mesh path discovery timeout, in msecs
  1201. * @discovery_retries: mesh path discovery retries
  1202. * @generation: generation number for nl80211 dumps.
  1203. * This number should increase every time the list of mesh paths
  1204. * changes, i.e. when a station is added or removed, so that
  1205. * userspace can tell whether it got a consistent snapshot.
  1206. */
  1207. struct mpath_info {
  1208. u32 filled;
  1209. u32 frame_qlen;
  1210. u32 sn;
  1211. u32 metric;
  1212. u32 exptime;
  1213. u32 discovery_timeout;
  1214. u8 discovery_retries;
  1215. u8 flags;
  1216. int generation;
  1217. };
  1218. /**
  1219. * struct bss_parameters - BSS parameters
  1220. *
  1221. * Used to change BSS parameters (mainly for AP mode).
  1222. *
  1223. * @use_cts_prot: Whether to use CTS protection
  1224. * (0 = no, 1 = yes, -1 = do not change)
  1225. * @use_short_preamble: Whether the use of short preambles is allowed
  1226. * (0 = no, 1 = yes, -1 = do not change)
  1227. * @use_short_slot_time: Whether the use of short slot time is allowed
  1228. * (0 = no, 1 = yes, -1 = do not change)
  1229. * @basic_rates: basic rates in IEEE 802.11 format
  1230. * (or NULL for no change)
  1231. * @basic_rates_len: number of basic rates
  1232. * @ap_isolate: do not forward packets between connected stations
  1233. * @ht_opmode: HT Operation mode
  1234. * (u16 = opmode, -1 = do not change)
  1235. * @p2p_ctwindow: P2P CT Window (-1 = no change)
  1236. * @p2p_opp_ps: P2P opportunistic PS (-1 = no change)
  1237. */
  1238. struct bss_parameters {
  1239. int use_cts_prot;
  1240. int use_short_preamble;
  1241. int use_short_slot_time;
  1242. const u8 *basic_rates;
  1243. u8 basic_rates_len;
  1244. int ap_isolate;
  1245. int ht_opmode;
  1246. s8 p2p_ctwindow, p2p_opp_ps;
  1247. };
  1248. /**
  1249. * struct mesh_config - 802.11s mesh configuration
  1250. *
  1251. * These parameters can be changed while the mesh is active.
  1252. *
  1253. * @dot11MeshRetryTimeout: the initial retry timeout in millisecond units used
  1254. * by the Mesh Peering Open message
  1255. * @dot11MeshConfirmTimeout: the initial retry timeout in millisecond units
  1256. * used by the Mesh Peering Open message
  1257. * @dot11MeshHoldingTimeout: the confirm timeout in millisecond units used by
  1258. * the mesh peering management to close a mesh peering
  1259. * @dot11MeshMaxPeerLinks: the maximum number of peer links allowed on this
  1260. * mesh interface
  1261. * @dot11MeshMaxRetries: the maximum number of peer link open retries that can
  1262. * be sent to establish a new peer link instance in a mesh
  1263. * @dot11MeshTTL: the value of TTL field set at a source mesh STA
  1264. * @element_ttl: the value of TTL field set at a mesh STA for path selection
  1265. * elements
  1266. * @auto_open_plinks: whether we should automatically open peer links when we
  1267. * detect compatible mesh peers
  1268. * @dot11MeshNbrOffsetMaxNeighbor: the maximum number of neighbors to
  1269. * synchronize to for 11s default synchronization method
  1270. * @dot11MeshHWMPmaxPREQretries: the number of action frames containing a PREQ
  1271. * that an originator mesh STA can send to a particular path target
  1272. * @path_refresh_time: how frequently to refresh mesh paths in milliseconds
  1273. * @min_discovery_timeout: the minimum length of time to wait until giving up on
  1274. * a path discovery in milliseconds
  1275. * @dot11MeshHWMPactivePathTimeout: the time (in TUs) for which mesh STAs
  1276. * receiving a PREQ shall consider the forwarding information from the
  1277. * root to be valid. (TU = time unit)
  1278. * @dot11MeshHWMPpreqMinInterval: the minimum interval of time (in TUs) during
  1279. * which a mesh STA can send only one action frame containing a PREQ
  1280. * element
  1281. * @dot11MeshHWMPperrMinInterval: the minimum interval of time (in TUs) during
  1282. * which a mesh STA can send only one Action frame containing a PERR
  1283. * element
  1284. * @dot11MeshHWMPnetDiameterTraversalTime: the interval of time (in TUs) that
  1285. * it takes for an HWMP information element to propagate across the mesh
  1286. * @dot11MeshHWMPRootMode: the configuration of a mesh STA as root mesh STA
  1287. * @dot11MeshHWMPRannInterval: the interval of time (in TUs) between root
  1288. * announcements are transmitted
  1289. * @dot11MeshGateAnnouncementProtocol: whether to advertise that this mesh
  1290. * station has access to a broader network beyond the MBSS. (This is
  1291. * missnamed in draft 12.0: dot11MeshGateAnnouncementProtocol set to true
  1292. * only means that the station will announce others it's a mesh gate, but
  1293. * not necessarily using the gate announcement protocol. Still keeping the
  1294. * same nomenclature to be in sync with the spec)
  1295. * @dot11MeshForwarding: whether the Mesh STA is forwarding or non-forwarding
  1296. * entity (default is TRUE - forwarding entity)
  1297. * @rssi_threshold: the threshold for average signal strength of candidate
  1298. * station to establish a peer link
  1299. * @ht_opmode: mesh HT protection mode
  1300. *
  1301. * @dot11MeshHWMPactivePathToRootTimeout: The time (in TUs) for which mesh STAs
  1302. * receiving a proactive PREQ shall consider the forwarding information to
  1303. * the root mesh STA to be valid.
  1304. *
  1305. * @dot11MeshHWMProotInterval: The interval of time (in TUs) between proactive
  1306. * PREQs are transmitted.
  1307. * @dot11MeshHWMPconfirmationInterval: The minimum interval of time (in TUs)
  1308. * during which a mesh STA can send only one Action frame containing
  1309. * a PREQ element for root path confirmation.
  1310. * @power_mode: The default mesh power save mode which will be the initial
  1311. * setting for new peer links.
  1312. * @dot11MeshAwakeWindowDuration: The duration in TUs the STA will remain awake
  1313. * after transmitting its beacon.
  1314. * @plink_timeout: If no tx activity is seen from a STA we've established
  1315. * peering with for longer than this time (in seconds), then remove it
  1316. * from the STA's list of peers. Default is 30 minutes.
  1317. */
  1318. struct mesh_config {
  1319. u16 dot11MeshRetryTimeout;
  1320. u16 dot11MeshConfirmTimeout;
  1321. u16 dot11MeshHoldingTimeout;
  1322. u16 dot11MeshMaxPeerLinks;
  1323. u8 dot11MeshMaxRetries;
  1324. u8 dot11MeshTTL;
  1325. u8 element_ttl;
  1326. bool auto_open_plinks;
  1327. u32 dot11MeshNbrOffsetMaxNeighbor;
  1328. u8 dot11MeshHWMPmaxPREQretries;
  1329. u32 path_refresh_time;
  1330. u16 min_discovery_timeout;
  1331. u32 dot11MeshHWMPactivePathTimeout;
  1332. u16 dot11MeshHWMPpreqMinInterval;
  1333. u16 dot11MeshHWMPperrMinInterval;
  1334. u16 dot11MeshHWMPnetDiameterTraversalTime;
  1335. u8 dot11MeshHWMPRootMode;
  1336. u16 dot11MeshHWMPRannInterval;
  1337. bool dot11MeshGateAnnouncementProtocol;
  1338. bool dot11MeshForwarding;
  1339. s32 rssi_threshold;
  1340. u16 ht_opmode;
  1341. u32 dot11MeshHWMPactivePathToRootTimeout;
  1342. u16 dot11MeshHWMProotInterval;
  1343. u16 dot11MeshHWMPconfirmationInterval;
  1344. enum nl80211_mesh_power_mode power_mode;
  1345. u16 dot11MeshAwakeWindowDuration;
  1346. u32 plink_timeout;
  1347. };
  1348. /**
  1349. * struct mesh_setup - 802.11s mesh setup configuration
  1350. * @chandef: defines the channel to use
  1351. * @mesh_id: the mesh ID
  1352. * @mesh_id_len: length of the mesh ID, at least 1 and at most 32 bytes
  1353. * @sync_method: which synchronization method to use
  1354. * @path_sel_proto: which path selection protocol to use
  1355. * @path_metric: which metric to use
  1356. * @auth_id: which authentication method this mesh is using
  1357. * @ie: vendor information elements (optional)
  1358. * @ie_len: length of vendor information elements
  1359. * @is_authenticated: this mesh requires authentication
  1360. * @is_secure: this mesh uses security
  1361. * @user_mpm: userspace handles all MPM functions
  1362. * @dtim_period: DTIM period to use
  1363. * @beacon_interval: beacon interval to use
  1364. * @mcast_rate: multicat rate for Mesh Node [6Mbps is the default for 802.11a]
  1365. * @basic_rates: basic rates to use when creating the mesh
  1366. * @beacon_rate: bitrate to be used for beacons
  1367. * @userspace_handles_dfs: whether user space controls DFS operation, i.e.
  1368. * changes the channel when a radar is detected. This is required
  1369. * to operate on DFS channels.
  1370. *
  1371. * These parameters are fixed when the mesh is created.
  1372. */
  1373. struct mesh_setup {
  1374. struct cfg80211_chan_def chandef;
  1375. const u8 *mesh_id;
  1376. u8 mesh_id_len;
  1377. u8 sync_method;
  1378. u8 path_sel_proto;
  1379. u8 path_metric;
  1380. u8 auth_id;
  1381. const u8 *ie;
  1382. u8 ie_len;
  1383. bool is_authenticated;
  1384. bool is_secure;
  1385. bool user_mpm;
  1386. u8 dtim_period;
  1387. u16 beacon_interval;
  1388. int mcast_rate[NUM_NL80211_BANDS];
  1389. u32 basic_rates;
  1390. struct cfg80211_bitrate_mask beacon_rate;
  1391. bool userspace_handles_dfs;
  1392. };
  1393. /**
  1394. * struct ocb_setup - 802.11p OCB mode setup configuration
  1395. * @chandef: defines the channel to use
  1396. *
  1397. * These parameters are fixed when connecting to the network
  1398. */
  1399. struct ocb_setup {
  1400. struct cfg80211_chan_def chandef;
  1401. };
  1402. /**
  1403. * struct ieee80211_txq_params - TX queue parameters
  1404. * @ac: AC identifier
  1405. * @txop: Maximum burst time in units of 32 usecs, 0 meaning disabled
  1406. * @cwmin: Minimum contention window [a value of the form 2^n-1 in the range
  1407. * 1..32767]
  1408. * @cwmax: Maximum contention window [a value of the form 2^n-1 in the range
  1409. * 1..32767]
  1410. * @aifs: Arbitration interframe space [0..255]
  1411. */
  1412. struct ieee80211_txq_params {
  1413. enum nl80211_ac ac;
  1414. u16 txop;
  1415. u16 cwmin;
  1416. u16 cwmax;
  1417. u8 aifs;
  1418. };
  1419. /**
  1420. * DOC: Scanning and BSS list handling
  1421. *
  1422. * The scanning process itself is fairly simple, but cfg80211 offers quite
  1423. * a bit of helper functionality. To start a scan, the scan operation will
  1424. * be invoked with a scan definition. This scan definition contains the
  1425. * channels to scan, and the SSIDs to send probe requests for (including the
  1426. * wildcard, if desired). A passive scan is indicated by having no SSIDs to
  1427. * probe. Additionally, a scan request may contain extra information elements
  1428. * that should be added to the probe request. The IEs are guaranteed to be
  1429. * well-formed, and will not exceed the maximum length the driver advertised
  1430. * in the wiphy structure.
  1431. *
  1432. * When scanning finds a BSS, cfg80211 needs to be notified of that, because
  1433. * it is responsible for maintaining the BSS list; the driver should not
  1434. * maintain a list itself. For this notification, various functions exist.
  1435. *
  1436. * Since drivers do not maintain a BSS list, there are also a number of
  1437. * functions to search for a BSS and obtain information about it from the
  1438. * BSS structure cfg80211 maintains. The BSS list is also made available
  1439. * to userspace.
  1440. */
  1441. /**
  1442. * struct cfg80211_ssid - SSID description
  1443. * @ssid: the SSID
  1444. * @ssid_len: length of the ssid
  1445. */
  1446. struct cfg80211_ssid {
  1447. u8 ssid[IEEE80211_MAX_SSID_LEN];
  1448. u8 ssid_len;
  1449. };
  1450. /**
  1451. * struct cfg80211_scan_info - information about completed scan
  1452. * @scan_start_tsf: scan start time in terms of the TSF of the BSS that the
  1453. * wireless device that requested the scan is connected to. If this
  1454. * information is not available, this field is left zero.
  1455. * @tsf_bssid: the BSSID according to which %scan_start_tsf is set.
  1456. * @aborted: set to true if the scan was aborted for any reason,
  1457. * userspace will be notified of that
  1458. */
  1459. struct cfg80211_scan_info {
  1460. u64 scan_start_tsf;
  1461. u8 tsf_bssid[ETH_ALEN] __aligned(2);
  1462. bool aborted;
  1463. };
  1464. /**
  1465. * struct cfg80211_scan_request - scan request description
  1466. *
  1467. * @ssids: SSIDs to scan for (active scan only)
  1468. * @n_ssids: number of SSIDs
  1469. * @channels: channels to scan on.
  1470. * @n_channels: total number of channels to scan
  1471. * @scan_width: channel width for scanning
  1472. * @ie: optional information element(s) to add into Probe Request or %NULL
  1473. * @ie_len: length of ie in octets
  1474. * @duration: how long to listen on each channel, in TUs. If
  1475. * %duration_mandatory is not set, this is the maximum dwell time and
  1476. * the actual dwell time may be shorter.
  1477. * @duration_mandatory: if set, the scan duration must be as specified by the
  1478. * %duration field.
  1479. * @flags: bit field of flags controlling operation
  1480. * @rates: bitmap of rates to advertise for each band
  1481. * @wiphy: the wiphy this was for
  1482. * @scan_start: time (in jiffies) when the scan started
  1483. * @wdev: the wireless device to scan for
  1484. * @info: (internal) information about completed scan
  1485. * @notified: (internal) scan request was notified as done or aborted
  1486. * @no_cck: used to send probe requests at non CCK rate in 2GHz band
  1487. * @mac_addr: MAC address used with randomisation
  1488. * @mac_addr_mask: MAC address mask used with randomisation, bits that
  1489. * are 0 in the mask should be randomised, bits that are 1 should
  1490. * be taken from the @mac_addr
  1491. * @bssid: BSSID to scan for (most commonly, the wildcard BSSID)
  1492. */
  1493. struct cfg80211_scan_request {
  1494. struct cfg80211_ssid *ssids;
  1495. int n_ssids;
  1496. u32 n_channels;
  1497. enum nl80211_bss_scan_width scan_width;
  1498. const u8 *ie;
  1499. size_t ie_len;
  1500. u16 duration;
  1501. bool duration_mandatory;
  1502. u32 flags;
  1503. u32 rates[NUM_NL80211_BANDS];
  1504. struct wireless_dev *wdev;
  1505. u8 mac_addr[ETH_ALEN] __aligned(2);
  1506. u8 mac_addr_mask[ETH_ALEN] __aligned(2);
  1507. u8 bssid[ETH_ALEN] __aligned(2);
  1508. /* internal */
  1509. struct wiphy *wiphy;
  1510. unsigned long scan_start;
  1511. struct cfg80211_scan_info info;
  1512. bool notified;
  1513. bool no_cck;
  1514. /* keep last */
  1515. struct ieee80211_channel *channels[0];
  1516. };
  1517. static inline void get_random_mask_addr(u8 *buf, const u8 *addr, const u8 *mask)
  1518. {
  1519. int i;
  1520. get_random_bytes(buf, ETH_ALEN);
  1521. for (i = 0; i < ETH_ALEN; i++) {
  1522. buf[i] &= ~mask[i];
  1523. buf[i] |= addr[i] & mask[i];
  1524. }
  1525. }
  1526. /**
  1527. * struct cfg80211_match_set - sets of attributes to match
  1528. *
  1529. * @ssid: SSID to be matched; may be zero-length in case of BSSID match
  1530. * or no match (RSSI only)
  1531. * @bssid: BSSID to be matched; may be all-zero BSSID in case of SSID match
  1532. * or no match (RSSI only)
  1533. * @rssi_thold: don't report scan results below this threshold (in s32 dBm)
  1534. */
  1535. struct cfg80211_match_set {
  1536. struct cfg80211_ssid ssid;
  1537. u8 bssid[ETH_ALEN];
  1538. s32 rssi_thold;
  1539. };
  1540. /**
  1541. * struct cfg80211_sched_scan_plan - scan plan for scheduled scan
  1542. *
  1543. * @interval: interval between scheduled scan iterations. In seconds.
  1544. * @iterations: number of scan iterations in this scan plan. Zero means
  1545. * infinite loop.
  1546. * The last scan plan will always have this parameter set to zero,
  1547. * all other scan plans will have a finite number of iterations.
  1548. */
  1549. struct cfg80211_sched_scan_plan {
  1550. u32 interval;
  1551. u32 iterations;
  1552. };
  1553. /**
  1554. * struct cfg80211_bss_select_adjust - BSS selection with RSSI adjustment.
  1555. *
  1556. * @band: band of BSS which should match for RSSI level adjustment.
  1557. * @delta: value of RSSI level adjustment.
  1558. */
  1559. struct cfg80211_bss_select_adjust {
  1560. enum nl80211_band band;
  1561. s8 delta;
  1562. };
  1563. /**
  1564. * struct cfg80211_sched_scan_request - scheduled scan request description
  1565. *
  1566. * @reqid: identifies this request.
  1567. * @ssids: SSIDs to scan for (passed in the probe_reqs in active scans)
  1568. * @n_ssids: number of SSIDs
  1569. * @n_channels: total number of channels to scan
  1570. * @scan_width: channel width for scanning
  1571. * @ie: optional information element(s) to add into Probe Request or %NULL
  1572. * @ie_len: length of ie in octets
  1573. * @flags: bit field of flags controlling operation
  1574. * @match_sets: sets of parameters to be matched for a scan result
  1575. * entry to be considered valid and to be passed to the host
  1576. * (others are filtered out).
  1577. * If ommited, all results are passed.
  1578. * @n_match_sets: number of match sets
  1579. * @report_results: indicates that results were reported for this request
  1580. * @wiphy: the wiphy this was for
  1581. * @dev: the interface
  1582. * @scan_start: start time of the scheduled scan
  1583. * @channels: channels to scan
  1584. * @min_rssi_thold: for drivers only supporting a single threshold, this
  1585. * contains the minimum over all matchsets
  1586. * @mac_addr: MAC address used with randomisation
  1587. * @mac_addr_mask: MAC address mask used with randomisation, bits that
  1588. * are 0 in the mask should be randomised, bits that are 1 should
  1589. * be taken from the @mac_addr
  1590. * @scan_plans: scan plans to be executed in this scheduled scan. Lowest
  1591. * index must be executed first.
  1592. * @n_scan_plans: number of scan plans, at least 1.
  1593. * @rcu_head: RCU callback used to free the struct
  1594. * @owner_nlportid: netlink portid of owner (if this should is a request
  1595. * owned by a particular socket)
  1596. * @nl_owner_dead: netlink owner socket was closed - this request be freed
  1597. * @list: for keeping list of requests.
  1598. * @delay: delay in seconds to use before starting the first scan
  1599. * cycle. The driver may ignore this parameter and start
  1600. * immediately (or at any other time), if this feature is not
  1601. * supported.
  1602. * @relative_rssi_set: Indicates whether @relative_rssi is set or not.
  1603. * @relative_rssi: Relative RSSI threshold in dB to restrict scan result
  1604. * reporting in connected state to cases where a matching BSS is determined
  1605. * to have better or slightly worse RSSI than the current connected BSS.
  1606. * The relative RSSI threshold values are ignored in disconnected state.
  1607. * @rssi_adjust: delta dB of RSSI preference to be given to the BSSs that belong
  1608. * to the specified band while deciding whether a better BSS is reported
  1609. * using @relative_rssi. If delta is a negative number, the BSSs that
  1610. * belong to the specified band will be penalized by delta dB in relative
  1611. * comparisions.
  1612. */
  1613. struct cfg80211_sched_scan_request {
  1614. u64 reqid;
  1615. struct cfg80211_ssid *ssids;
  1616. int n_ssids;
  1617. u32 n_channels;
  1618. enum nl80211_bss_scan_width scan_width;
  1619. const u8 *ie;
  1620. size_t ie_len;
  1621. u32 flags;
  1622. struct cfg80211_match_set *match_sets;
  1623. int n_match_sets;
  1624. s32 min_rssi_thold;
  1625. u32 delay;
  1626. struct cfg80211_sched_scan_plan *scan_plans;
  1627. int n_scan_plans;
  1628. u8 mac_addr[ETH_ALEN] __aligned(2);
  1629. u8 mac_addr_mask[ETH_ALEN] __aligned(2);
  1630. bool relative_rssi_set;
  1631. s8 relative_rssi;
  1632. struct cfg80211_bss_select_adjust rssi_adjust;
  1633. /* internal */
  1634. struct wiphy *wiphy;
  1635. struct net_device *dev;
  1636. unsigned long scan_start;
  1637. bool report_results;
  1638. struct rcu_head rcu_head;
  1639. u32 owner_nlportid;
  1640. bool nl_owner_dead;
  1641. struct list_head list;
  1642. /* keep last */
  1643. struct ieee80211_channel *channels[0];
  1644. };
  1645. /**
  1646. * enum cfg80211_signal_type - signal type
  1647. *
  1648. * @CFG80211_SIGNAL_TYPE_NONE: no signal strength information available
  1649. * @CFG80211_SIGNAL_TYPE_MBM: signal strength in mBm (100*dBm)
  1650. * @CFG80211_SIGNAL_TYPE_UNSPEC: signal strength, increasing from 0 through 100
  1651. */
  1652. enum cfg80211_signal_type {
  1653. CFG80211_SIGNAL_TYPE_NONE,
  1654. CFG80211_SIGNAL_TYPE_MBM,
  1655. CFG80211_SIGNAL_TYPE_UNSPEC,
  1656. };
  1657. /**
  1658. * struct cfg80211_inform_bss - BSS inform data
  1659. * @chan: channel the frame was received on
  1660. * @scan_width: scan width that was used
  1661. * @signal: signal strength value, according to the wiphy's
  1662. * signal type
  1663. * @boottime_ns: timestamp (CLOCK_BOOTTIME) when the information was
  1664. * received; should match the time when the frame was actually
  1665. * received by the device (not just by the host, in case it was
  1666. * buffered on the device) and be accurate to about 10ms.
  1667. * If the frame isn't buffered, just passing the return value of
  1668. * ktime_get_boot_ns() is likely appropriate.
  1669. * @parent_tsf: the time at the start of reception of the first octet of the
  1670. * timestamp field of the frame. The time is the TSF of the BSS specified
  1671. * by %parent_bssid.
  1672. * @parent_bssid: the BSS according to which %parent_tsf is set. This is set to
  1673. * the BSS that requested the scan in which the beacon/probe was received.
  1674. */
  1675. struct cfg80211_inform_bss {
  1676. struct ieee80211_channel *chan;
  1677. enum nl80211_bss_scan_width scan_width;
  1678. s32 signal;
  1679. u64 boottime_ns;
  1680. u64 parent_tsf;
  1681. u8 parent_bssid[ETH_ALEN] __aligned(2);
  1682. };
  1683. /**
  1684. * struct cfg80211_bss_ies - BSS entry IE data
  1685. * @tsf: TSF contained in the frame that carried these IEs
  1686. * @rcu_head: internal use, for freeing
  1687. * @len: length of the IEs
  1688. * @from_beacon: these IEs are known to come from a beacon
  1689. * @data: IE data
  1690. */
  1691. struct cfg80211_bss_ies {
  1692. u64 tsf;
  1693. struct rcu_head rcu_head;
  1694. int len;
  1695. bool from_beacon;
  1696. u8 data[];
  1697. };
  1698. /**
  1699. * struct cfg80211_bss - BSS description
  1700. *
  1701. * This structure describes a BSS (which may also be a mesh network)
  1702. * for use in scan results and similar.
  1703. *
  1704. * @channel: channel this BSS is on
  1705. * @scan_width: width of the control channel
  1706. * @bssid: BSSID of the BSS
  1707. * @beacon_interval: the beacon interval as from the frame
  1708. * @capability: the capability field in host byte order
  1709. * @ies: the information elements (Note that there is no guarantee that these
  1710. * are well-formed!); this is a pointer to either the beacon_ies or
  1711. * proberesp_ies depending on whether Probe Response frame has been
  1712. * received. It is always non-%NULL.
  1713. * @beacon_ies: the information elements from the last Beacon frame
  1714. * (implementation note: if @hidden_beacon_bss is set this struct doesn't
  1715. * own the beacon_ies, but they're just pointers to the ones from the
  1716. * @hidden_beacon_bss struct)
  1717. * @proberesp_ies: the information elements from the last Probe Response frame
  1718. * @hidden_beacon_bss: in case this BSS struct represents a probe response from
  1719. * a BSS that hides the SSID in its beacon, this points to the BSS struct
  1720. * that holds the beacon data. @beacon_ies is still valid, of course, and
  1721. * points to the same data as hidden_beacon_bss->beacon_ies in that case.
  1722. * @signal: signal strength value (type depends on the wiphy's signal_type)
  1723. * @priv: private area for driver use, has at least wiphy->bss_priv_size bytes
  1724. */
  1725. struct cfg80211_bss {
  1726. struct ieee80211_channel *channel;
  1727. enum nl80211_bss_scan_width scan_width;
  1728. const struct cfg80211_bss_ies __rcu *ies;
  1729. const struct cfg80211_bss_ies __rcu *beacon_ies;
  1730. const struct cfg80211_bss_ies __rcu *proberesp_ies;
  1731. struct cfg80211_bss *hidden_beacon_bss;
  1732. s32 signal;
  1733. u16 beacon_interval;
  1734. u16 capability;
  1735. u8 bssid[ETH_ALEN];
  1736. u8 priv[0] __aligned(sizeof(void *));
  1737. };
  1738. /**
  1739. * ieee80211_bss_get_ie - find IE with given ID
  1740. * @bss: the bss to search
  1741. * @ie: the IE ID
  1742. *
  1743. * Note that the return value is an RCU-protected pointer, so
  1744. * rcu_read_lock() must be held when calling this function.
  1745. * Return: %NULL if not found.
  1746. */
  1747. const u8 *ieee80211_bss_get_ie(struct cfg80211_bss *bss, u8 ie);
  1748. /**
  1749. * struct cfg80211_auth_request - Authentication request data
  1750. *
  1751. * This structure provides information needed to complete IEEE 802.11
  1752. * authentication.
  1753. *
  1754. * @bss: The BSS to authenticate with, the callee must obtain a reference
  1755. * to it if it needs to keep it.
  1756. * @auth_type: Authentication type (algorithm)
  1757. * @ie: Extra IEs to add to Authentication frame or %NULL
  1758. * @ie_len: Length of ie buffer in octets
  1759. * @key_len: length of WEP key for shared key authentication
  1760. * @key_idx: index of WEP key for shared key authentication
  1761. * @key: WEP key for shared key authentication
  1762. * @auth_data: Fields and elements in Authentication frames. This contains
  1763. * the authentication frame body (non-IE and IE data), excluding the
  1764. * Authentication algorithm number, i.e., starting at the Authentication
  1765. * transaction sequence number field.
  1766. * @auth_data_len: Length of auth_data buffer in octets
  1767. */
  1768. struct cfg80211_auth_request {
  1769. struct cfg80211_bss *bss;
  1770. const u8 *ie;
  1771. size_t ie_len;
  1772. enum nl80211_auth_type auth_type;
  1773. const u8 *key;
  1774. u8 key_len, key_idx;
  1775. const u8 *auth_data;
  1776. size_t auth_data_len;
  1777. };
  1778. /**
  1779. * enum cfg80211_assoc_req_flags - Over-ride default behaviour in association.
  1780. *
  1781. * @ASSOC_REQ_DISABLE_HT: Disable HT (802.11n)
  1782. * @ASSOC_REQ_DISABLE_VHT: Disable VHT
  1783. * @ASSOC_REQ_USE_RRM: Declare RRM capability in this association
  1784. */
  1785. enum cfg80211_assoc_req_flags {
  1786. ASSOC_REQ_DISABLE_HT = BIT(0),
  1787. ASSOC_REQ_DISABLE_VHT = BIT(1),
  1788. ASSOC_REQ_USE_RRM = BIT(2),
  1789. };
  1790. /**
  1791. * struct cfg80211_assoc_request - (Re)Association request data
  1792. *
  1793. * This structure provides information needed to complete IEEE 802.11
  1794. * (re)association.
  1795. * @bss: The BSS to associate with. If the call is successful the driver is
  1796. * given a reference that it must give back to cfg80211_send_rx_assoc()
  1797. * or to cfg80211_assoc_timeout(). To ensure proper refcounting, new
  1798. * association requests while already associating must be rejected.
  1799. * @ie: Extra IEs to add to (Re)Association Request frame or %NULL
  1800. * @ie_len: Length of ie buffer in octets
  1801. * @use_mfp: Use management frame protection (IEEE 802.11w) in this association
  1802. * @crypto: crypto settings
  1803. * @prev_bssid: previous BSSID, if not %NULL use reassociate frame. This is used
  1804. * to indicate a request to reassociate within the ESS instead of a request
  1805. * do the initial association with the ESS. When included, this is set to
  1806. * the BSSID of the current association, i.e., to the value that is
  1807. * included in the Current AP address field of the Reassociation Request
  1808. * frame.
  1809. * @flags: See &enum cfg80211_assoc_req_flags
  1810. * @ht_capa: HT Capabilities over-rides. Values set in ht_capa_mask
  1811. * will be used in ht_capa. Un-supported values will be ignored.
  1812. * @ht_capa_mask: The bits of ht_capa which are to be used.
  1813. * @vht_capa: VHT capability override
  1814. * @vht_capa_mask: VHT capability mask indicating which fields to use
  1815. * @fils_kek: FILS KEK for protecting (Re)Association Request/Response frame or
  1816. * %NULL if FILS is not used.
  1817. * @fils_kek_len: Length of fils_kek in octets
  1818. * @fils_nonces: FILS nonces (part of AAD) for protecting (Re)Association
  1819. * Request/Response frame or %NULL if FILS is not used. This field starts
  1820. * with 16 octets of STA Nonce followed by 16 octets of AP Nonce.
  1821. */
  1822. struct cfg80211_assoc_request {
  1823. struct cfg80211_bss *bss;
  1824. const u8 *ie, *prev_bssid;
  1825. size_t ie_len;
  1826. struct cfg80211_crypto_settings crypto;
  1827. bool use_mfp;
  1828. u32 flags;
  1829. struct ieee80211_ht_cap ht_capa;
  1830. struct ieee80211_ht_cap ht_capa_mask;
  1831. struct ieee80211_vht_cap vht_capa, vht_capa_mask;
  1832. const u8 *fils_kek;
  1833. size_t fils_kek_len;
  1834. const u8 *fils_nonces;
  1835. };
  1836. /**
  1837. * struct cfg80211_deauth_request - Deauthentication request data
  1838. *
  1839. * This structure provides information needed to complete IEEE 802.11
  1840. * deauthentication.
  1841. *
  1842. * @bssid: the BSSID of the BSS to deauthenticate from
  1843. * @ie: Extra IEs to add to Deauthentication frame or %NULL
  1844. * @ie_len: Length of ie buffer in octets
  1845. * @reason_code: The reason code for the deauthentication
  1846. * @local_state_change: if set, change local state only and
  1847. * do not set a deauth frame
  1848. */
  1849. struct cfg80211_deauth_request {
  1850. const u8 *bssid;
  1851. const u8 *ie;
  1852. size_t ie_len;
  1853. u16 reason_code;
  1854. bool local_state_change;
  1855. };
  1856. /**
  1857. * struct cfg80211_disassoc_request - Disassociation request data
  1858. *
  1859. * This structure provides information needed to complete IEEE 802.11
  1860. * disassociation.
  1861. *
  1862. * @bss: the BSS to disassociate from
  1863. * @ie: Extra IEs to add to Disassociation frame or %NULL
  1864. * @ie_len: Length of ie buffer in octets
  1865. * @reason_code: The reason code for the disassociation
  1866. * @local_state_change: This is a request for a local state only, i.e., no
  1867. * Disassociation frame is to be transmitted.
  1868. */
  1869. struct cfg80211_disassoc_request {
  1870. struct cfg80211_bss *bss;
  1871. const u8 *ie;
  1872. size_t ie_len;
  1873. u16 reason_code;
  1874. bool local_state_change;
  1875. };
  1876. /**
  1877. * struct cfg80211_ibss_params - IBSS parameters
  1878. *
  1879. * This structure defines the IBSS parameters for the join_ibss()
  1880. * method.
  1881. *
  1882. * @ssid: The SSID, will always be non-null.
  1883. * @ssid_len: The length of the SSID, will always be non-zero.
  1884. * @bssid: Fixed BSSID requested, maybe be %NULL, if set do not
  1885. * search for IBSSs with a different BSSID.
  1886. * @chandef: defines the channel to use if no other IBSS to join can be found
  1887. * @channel_fixed: The channel should be fixed -- do not search for
  1888. * IBSSs to join on other channels.
  1889. * @ie: information element(s) to include in the beacon
  1890. * @ie_len: length of that
  1891. * @beacon_interval: beacon interval to use
  1892. * @privacy: this is a protected network, keys will be configured
  1893. * after joining
  1894. * @control_port: whether user space controls IEEE 802.1X port, i.e.,
  1895. * sets/clears %NL80211_STA_FLAG_AUTHORIZED. If true, the driver is
  1896. * required to assume that the port is unauthorized until authorized by
  1897. * user space. Otherwise, port is marked authorized by default.
  1898. * @userspace_handles_dfs: whether user space controls DFS operation, i.e.
  1899. * changes the channel when a radar is detected. This is required
  1900. * to operate on DFS channels.
  1901. * @basic_rates: bitmap of basic rates to use when creating the IBSS
  1902. * @mcast_rate: per-band multicast rate index + 1 (0: disabled)
  1903. * @ht_capa: HT Capabilities over-rides. Values set in ht_capa_mask
  1904. * will be used in ht_capa. Un-supported values will be ignored.
  1905. * @ht_capa_mask: The bits of ht_capa which are to be used.
  1906. */
  1907. struct cfg80211_ibss_params {
  1908. const u8 *ssid;
  1909. const u8 *bssid;
  1910. struct cfg80211_chan_def chandef;
  1911. const u8 *ie;
  1912. u8 ssid_len, ie_len;
  1913. u16 beacon_interval;
  1914. u32 basic_rates;
  1915. bool channel_fixed;
  1916. bool privacy;
  1917. bool control_port;
  1918. bool userspace_handles_dfs;
  1919. int mcast_rate[NUM_NL80211_BANDS];
  1920. struct ieee80211_ht_cap ht_capa;
  1921. struct ieee80211_ht_cap ht_capa_mask;
  1922. };
  1923. /**
  1924. * struct cfg80211_bss_selection - connection parameters for BSS selection.
  1925. *
  1926. * @behaviour: requested BSS selection behaviour.
  1927. * @param: parameters for requestion behaviour.
  1928. * @band_pref: preferred band for %NL80211_BSS_SELECT_ATTR_BAND_PREF.
  1929. * @adjust: parameters for %NL80211_BSS_SELECT_ATTR_RSSI_ADJUST.
  1930. */
  1931. struct cfg80211_bss_selection {
  1932. enum nl80211_bss_select_attr behaviour;
  1933. union {
  1934. enum nl80211_band band_pref;
  1935. struct cfg80211_bss_select_adjust adjust;
  1936. } param;
  1937. };
  1938. /**
  1939. * struct cfg80211_connect_params - Connection parameters
  1940. *
  1941. * This structure provides information needed to complete IEEE 802.11
  1942. * authentication and association.
  1943. *
  1944. * @channel: The channel to use or %NULL if not specified (auto-select based
  1945. * on scan results)
  1946. * @channel_hint: The channel of the recommended BSS for initial connection or
  1947. * %NULL if not specified
  1948. * @bssid: The AP BSSID or %NULL if not specified (auto-select based on scan
  1949. * results)
  1950. * @bssid_hint: The recommended AP BSSID for initial connection to the BSS or
  1951. * %NULL if not specified. Unlike the @bssid parameter, the driver is
  1952. * allowed to ignore this @bssid_hint if it has knowledge of a better BSS
  1953. * to use.
  1954. * @ssid: SSID
  1955. * @ssid_len: Length of ssid in octets
  1956. * @auth_type: Authentication type (algorithm)
  1957. * @ie: IEs for association request
  1958. * @ie_len: Length of assoc_ie in octets
  1959. * @privacy: indicates whether privacy-enabled APs should be used
  1960. * @mfp: indicate whether management frame protection is used
  1961. * @crypto: crypto settings
  1962. * @key_len: length of WEP key for shared key authentication
  1963. * @key_idx: index of WEP key for shared key authentication
  1964. * @key: WEP key for shared key authentication
  1965. * @flags: See &enum cfg80211_assoc_req_flags
  1966. * @bg_scan_period: Background scan period in seconds
  1967. * or -1 to indicate that default value is to be used.
  1968. * @ht_capa: HT Capabilities over-rides. Values set in ht_capa_mask
  1969. * will be used in ht_capa. Un-supported values will be ignored.
  1970. * @ht_capa_mask: The bits of ht_capa which are to be used.
  1971. * @vht_capa: VHT Capability overrides
  1972. * @vht_capa_mask: The bits of vht_capa which are to be used.
  1973. * @pbss: if set, connect to a PCP instead of AP. Valid for DMG
  1974. * networks.
  1975. * @bss_select: criteria to be used for BSS selection.
  1976. * @prev_bssid: previous BSSID, if not %NULL use reassociate frame. This is used
  1977. * to indicate a request to reassociate within the ESS instead of a request
  1978. * do the initial association with the ESS. When included, this is set to
  1979. * the BSSID of the current association, i.e., to the value that is
  1980. * included in the Current AP address field of the Reassociation Request
  1981. * frame.
  1982. * @fils_erp_username: EAP re-authentication protocol (ERP) username part of the
  1983. * NAI or %NULL if not specified. This is used to construct FILS wrapped
  1984. * data IE.
  1985. * @fils_erp_username_len: Length of @fils_erp_username in octets.
  1986. * @fils_erp_realm: EAP re-authentication protocol (ERP) realm part of NAI or
  1987. * %NULL if not specified. This specifies the domain name of ER server and
  1988. * is used to construct FILS wrapped data IE.
  1989. * @fils_erp_realm_len: Length of @fils_erp_realm in octets.
  1990. * @fils_erp_next_seq_num: The next sequence number to use in the FILS ERP
  1991. * messages. This is also used to construct FILS wrapped data IE.
  1992. * @fils_erp_rrk: ERP re-authentication Root Key (rRK) used to derive additional
  1993. * keys in FILS or %NULL if not specified.
  1994. * @fils_erp_rrk_len: Length of @fils_erp_rrk in octets.
  1995. * @want_1x: indicates user-space supports and wants to use 802.1X driver
  1996. * offload of 4-way handshake.
  1997. */
  1998. struct cfg80211_connect_params {
  1999. struct ieee80211_channel *channel;
  2000. struct ieee80211_channel *channel_hint;
  2001. const u8 *bssid;
  2002. const u8 *bssid_hint;
  2003. const u8 *ssid;
  2004. size_t ssid_len;
  2005. enum nl80211_auth_type auth_type;
  2006. const u8 *ie;
  2007. size_t ie_len;
  2008. bool privacy;
  2009. enum nl80211_mfp mfp;
  2010. struct cfg80211_crypto_settings crypto;
  2011. const u8 *key;
  2012. u8 key_len, key_idx;
  2013. u32 flags;
  2014. int bg_scan_period;
  2015. struct ieee80211_ht_cap ht_capa;
  2016. struct ieee80211_ht_cap ht_capa_mask;
  2017. struct ieee80211_vht_cap vht_capa;
  2018. struct ieee80211_vht_cap vht_capa_mask;
  2019. bool pbss;
  2020. struct cfg80211_bss_selection bss_select;
  2021. const u8 *prev_bssid;
  2022. const u8 *fils_erp_username;
  2023. size_t fils_erp_username_len;
  2024. const u8 *fils_erp_realm;
  2025. size_t fils_erp_realm_len;
  2026. u16 fils_erp_next_seq_num;
  2027. const u8 *fils_erp_rrk;
  2028. size_t fils_erp_rrk_len;
  2029. bool want_1x;
  2030. };
  2031. /**
  2032. * enum cfg80211_connect_params_changed - Connection parameters being updated
  2033. *
  2034. * This enum provides information of all connect parameters that
  2035. * have to be updated as part of update_connect_params() call.
  2036. *
  2037. * @UPDATE_ASSOC_IES: Indicates whether association request IEs are updated
  2038. */
  2039. enum cfg80211_connect_params_changed {
  2040. UPDATE_ASSOC_IES = BIT(0),
  2041. };
  2042. /**
  2043. * enum wiphy_params_flags - set_wiphy_params bitfield values
  2044. * @WIPHY_PARAM_RETRY_SHORT: wiphy->retry_short has changed
  2045. * @WIPHY_PARAM_RETRY_LONG: wiphy->retry_long has changed
  2046. * @WIPHY_PARAM_FRAG_THRESHOLD: wiphy->frag_threshold has changed
  2047. * @WIPHY_PARAM_RTS_THRESHOLD: wiphy->rts_threshold has changed
  2048. * @WIPHY_PARAM_COVERAGE_CLASS: coverage class changed
  2049. * @WIPHY_PARAM_DYN_ACK: dynack has been enabled
  2050. */
  2051. enum wiphy_params_flags {
  2052. WIPHY_PARAM_RETRY_SHORT = 1 << 0,
  2053. WIPHY_PARAM_RETRY_LONG = 1 << 1,
  2054. WIPHY_PARAM_FRAG_THRESHOLD = 1 << 2,
  2055. WIPHY_PARAM_RTS_THRESHOLD = 1 << 3,
  2056. WIPHY_PARAM_COVERAGE_CLASS = 1 << 4,
  2057. WIPHY_PARAM_DYN_ACK = 1 << 5,
  2058. };
  2059. /**
  2060. * struct cfg80211_pmksa - PMK Security Association
  2061. *
  2062. * This structure is passed to the set/del_pmksa() method for PMKSA
  2063. * caching.
  2064. *
  2065. * @bssid: The AP's BSSID (may be %NULL).
  2066. * @pmkid: The identifier to refer a PMKSA.
  2067. * @pmk: The PMK for the PMKSA identified by @pmkid. This is used for key
  2068. * derivation by a FILS STA. Otherwise, %NULL.
  2069. * @pmk_len: Length of the @pmk. The length of @pmk can differ depending on
  2070. * the hash algorithm used to generate this.
  2071. * @ssid: SSID to specify the ESS within which a PMKSA is valid when using FILS
  2072. * cache identifier (may be %NULL).
  2073. * @ssid_len: Length of the @ssid in octets.
  2074. * @cache_id: 2-octet cache identifier advertized by a FILS AP identifying the
  2075. * scope of PMKSA. This is valid only if @ssid_len is non-zero (may be
  2076. * %NULL).
  2077. */
  2078. struct cfg80211_pmksa {
  2079. const u8 *bssid;
  2080. const u8 *pmkid;
  2081. const u8 *pmk;
  2082. size_t pmk_len;
  2083. const u8 *ssid;
  2084. size_t ssid_len;
  2085. const u8 *cache_id;
  2086. };
  2087. /**
  2088. * struct cfg80211_pkt_pattern - packet pattern
  2089. * @mask: bitmask where to match pattern and where to ignore bytes,
  2090. * one bit per byte, in same format as nl80211
  2091. * @pattern: bytes to match where bitmask is 1
  2092. * @pattern_len: length of pattern (in bytes)
  2093. * @pkt_offset: packet offset (in bytes)
  2094. *
  2095. * Internal note: @mask and @pattern are allocated in one chunk of
  2096. * memory, free @mask only!
  2097. */
  2098. struct cfg80211_pkt_pattern {
  2099. const u8 *mask, *pattern;
  2100. int pattern_len;
  2101. int pkt_offset;
  2102. };
  2103. /**
  2104. * struct cfg80211_wowlan_tcp - TCP connection parameters
  2105. *
  2106. * @sock: (internal) socket for source port allocation
  2107. * @src: source IP address
  2108. * @dst: destination IP address
  2109. * @dst_mac: destination MAC address
  2110. * @src_port: source port
  2111. * @dst_port: destination port
  2112. * @payload_len: data payload length
  2113. * @payload: data payload buffer
  2114. * @payload_seq: payload sequence stamping configuration
  2115. * @data_interval: interval at which to send data packets
  2116. * @wake_len: wakeup payload match length
  2117. * @wake_data: wakeup payload match data
  2118. * @wake_mask: wakeup payload match mask
  2119. * @tokens_size: length of the tokens buffer
  2120. * @payload_tok: payload token usage configuration
  2121. */
  2122. struct cfg80211_wowlan_tcp {
  2123. struct socket *sock;
  2124. __be32 src, dst;
  2125. u16 src_port, dst_port;
  2126. u8 dst_mac[ETH_ALEN];
  2127. int payload_len;
  2128. const u8 *payload;
  2129. struct nl80211_wowlan_tcp_data_seq payload_seq;
  2130. u32 data_interval;
  2131. u32 wake_len;
  2132. const u8 *wake_data, *wake_mask;
  2133. u32 tokens_size;
  2134. /* must be last, variable member */
  2135. struct nl80211_wowlan_tcp_data_token payload_tok;
  2136. };
  2137. /**
  2138. * struct cfg80211_wowlan - Wake on Wireless-LAN support info
  2139. *
  2140. * This structure defines the enabled WoWLAN triggers for the device.
  2141. * @any: wake up on any activity -- special trigger if device continues
  2142. * operating as normal during suspend
  2143. * @disconnect: wake up if getting disconnected
  2144. * @magic_pkt: wake up on receiving magic packet
  2145. * @patterns: wake up on receiving packet matching a pattern
  2146. * @n_patterns: number of patterns
  2147. * @gtk_rekey_failure: wake up on GTK rekey failure
  2148. * @eap_identity_req: wake up on EAP identity request packet
  2149. * @four_way_handshake: wake up on 4-way handshake
  2150. * @rfkill_release: wake up when rfkill is released
  2151. * @tcp: TCP connection establishment/wakeup parameters, see nl80211.h.
  2152. * NULL if not configured.
  2153. * @nd_config: configuration for the scan to be used for net detect wake.
  2154. */
  2155. struct cfg80211_wowlan {
  2156. bool any, disconnect, magic_pkt, gtk_rekey_failure,
  2157. eap_identity_req, four_way_handshake,
  2158. rfkill_release;
  2159. struct cfg80211_pkt_pattern *patterns;
  2160. struct cfg80211_wowlan_tcp *tcp;
  2161. int n_patterns;
  2162. struct cfg80211_sched_scan_request *nd_config;
  2163. };
  2164. /**
  2165. * struct cfg80211_coalesce_rules - Coalesce rule parameters
  2166. *
  2167. * This structure defines coalesce rule for the device.
  2168. * @delay: maximum coalescing delay in msecs.
  2169. * @condition: condition for packet coalescence.
  2170. * see &enum nl80211_coalesce_condition.
  2171. * @patterns: array of packet patterns
  2172. * @n_patterns: number of patterns
  2173. */
  2174. struct cfg80211_coalesce_rules {
  2175. int delay;
  2176. enum nl80211_coalesce_condition condition;
  2177. struct cfg80211_pkt_pattern *patterns;
  2178. int n_patterns;
  2179. };
  2180. /**
  2181. * struct cfg80211_coalesce - Packet coalescing settings
  2182. *
  2183. * This structure defines coalescing settings.
  2184. * @rules: array of coalesce rules
  2185. * @n_rules: number of rules
  2186. */
  2187. struct cfg80211_coalesce {
  2188. struct cfg80211_coalesce_rules *rules;
  2189. int n_rules;
  2190. };
  2191. /**
  2192. * struct cfg80211_wowlan_nd_match - information about the match
  2193. *
  2194. * @ssid: SSID of the match that triggered the wake up
  2195. * @n_channels: Number of channels where the match occurred. This
  2196. * value may be zero if the driver can't report the channels.
  2197. * @channels: center frequencies of the channels where a match
  2198. * occurred (in MHz)
  2199. */
  2200. struct cfg80211_wowlan_nd_match {
  2201. struct cfg80211_ssid ssid;
  2202. int n_channels;
  2203. u32 channels[];
  2204. };
  2205. /**
  2206. * struct cfg80211_wowlan_nd_info - net detect wake up information
  2207. *
  2208. * @n_matches: Number of match information instances provided in
  2209. * @matches. This value may be zero if the driver can't provide
  2210. * match information.
  2211. * @matches: Array of pointers to matches containing information about
  2212. * the matches that triggered the wake up.
  2213. */
  2214. struct cfg80211_wowlan_nd_info {
  2215. int n_matches;
  2216. struct cfg80211_wowlan_nd_match *matches[];
  2217. };
  2218. /**
  2219. * struct cfg80211_wowlan_wakeup - wakeup report
  2220. * @disconnect: woke up by getting disconnected
  2221. * @magic_pkt: woke up by receiving magic packet
  2222. * @gtk_rekey_failure: woke up by GTK rekey failure
  2223. * @eap_identity_req: woke up by EAP identity request packet
  2224. * @four_way_handshake: woke up by 4-way handshake
  2225. * @rfkill_release: woke up by rfkill being released
  2226. * @pattern_idx: pattern that caused wakeup, -1 if not due to pattern
  2227. * @packet_present_len: copied wakeup packet data
  2228. * @packet_len: original wakeup packet length
  2229. * @packet: The packet causing the wakeup, if any.
  2230. * @packet_80211: For pattern match, magic packet and other data
  2231. * frame triggers an 802.3 frame should be reported, for
  2232. * disconnect due to deauth 802.11 frame. This indicates which
  2233. * it is.
  2234. * @tcp_match: TCP wakeup packet received
  2235. * @tcp_connlost: TCP connection lost or failed to establish
  2236. * @tcp_nomoretokens: TCP data ran out of tokens
  2237. * @net_detect: if not %NULL, woke up because of net detect
  2238. */
  2239. struct cfg80211_wowlan_wakeup {
  2240. bool disconnect, magic_pkt, gtk_rekey_failure,
  2241. eap_identity_req, four_way_handshake,
  2242. rfkill_release, packet_80211,
  2243. tcp_match, tcp_connlost, tcp_nomoretokens;
  2244. s32 pattern_idx;
  2245. u32 packet_present_len, packet_len;
  2246. const void *packet;
  2247. struct cfg80211_wowlan_nd_info *net_detect;
  2248. };
  2249. /**
  2250. * struct cfg80211_gtk_rekey_data - rekey data
  2251. * @kek: key encryption key (NL80211_KEK_LEN bytes)
  2252. * @kck: key confirmation key (NL80211_KCK_LEN bytes)
  2253. * @replay_ctr: replay counter (NL80211_REPLAY_CTR_LEN bytes)
  2254. */
  2255. struct cfg80211_gtk_rekey_data {
  2256. const u8 *kek, *kck, *replay_ctr;
  2257. };
  2258. /**
  2259. * struct cfg80211_update_ft_ies_params - FT IE Information
  2260. *
  2261. * This structure provides information needed to update the fast transition IE
  2262. *
  2263. * @md: The Mobility Domain ID, 2 Octet value
  2264. * @ie: Fast Transition IEs
  2265. * @ie_len: Length of ft_ie in octets
  2266. */
  2267. struct cfg80211_update_ft_ies_params {
  2268. u16 md;
  2269. const u8 *ie;
  2270. size_t ie_len;
  2271. };
  2272. /**
  2273. * struct cfg80211_mgmt_tx_params - mgmt tx parameters
  2274. *
  2275. * This structure provides information needed to transmit a mgmt frame
  2276. *
  2277. * @chan: channel to use
  2278. * @offchan: indicates wether off channel operation is required
  2279. * @wait: duration for ROC
  2280. * @buf: buffer to transmit
  2281. * @len: buffer length
  2282. * @no_cck: don't use cck rates for this frame
  2283. * @dont_wait_for_ack: tells the low level not to wait for an ack
  2284. * @n_csa_offsets: length of csa_offsets array
  2285. * @csa_offsets: array of all the csa offsets in the frame
  2286. */
  2287. struct cfg80211_mgmt_tx_params {
  2288. struct ieee80211_channel *chan;
  2289. bool offchan;
  2290. unsigned int wait;
  2291. const u8 *buf;
  2292. size_t len;
  2293. bool no_cck;
  2294. bool dont_wait_for_ack;
  2295. int n_csa_offsets;
  2296. const u16 *csa_offsets;
  2297. };
  2298. /**
  2299. * struct cfg80211_dscp_exception - DSCP exception
  2300. *
  2301. * @dscp: DSCP value that does not adhere to the user priority range definition
  2302. * @up: user priority value to which the corresponding DSCP value belongs
  2303. */
  2304. struct cfg80211_dscp_exception {
  2305. u8 dscp;
  2306. u8 up;
  2307. };
  2308. /**
  2309. * struct cfg80211_dscp_range - DSCP range definition for user priority
  2310. *
  2311. * @low: lowest DSCP value of this user priority range, inclusive
  2312. * @high: highest DSCP value of this user priority range, inclusive
  2313. */
  2314. struct cfg80211_dscp_range {
  2315. u8 low;
  2316. u8 high;
  2317. };
  2318. /* QoS Map Set element length defined in IEEE Std 802.11-2012, 8.4.2.97 */
  2319. #define IEEE80211_QOS_MAP_MAX_EX 21
  2320. #define IEEE80211_QOS_MAP_LEN_MIN 16
  2321. #define IEEE80211_QOS_MAP_LEN_MAX \
  2322. (IEEE80211_QOS_MAP_LEN_MIN + 2 * IEEE80211_QOS_MAP_MAX_EX)
  2323. /**
  2324. * struct cfg80211_qos_map - QoS Map Information
  2325. *
  2326. * This struct defines the Interworking QoS map setting for DSCP values
  2327. *
  2328. * @num_des: number of DSCP exceptions (0..21)
  2329. * @dscp_exception: optionally up to maximum of 21 DSCP exceptions from
  2330. * the user priority DSCP range definition
  2331. * @up: DSCP range definition for a particular user priority
  2332. */
  2333. struct cfg80211_qos_map {
  2334. u8 num_des;
  2335. struct cfg80211_dscp_exception dscp_exception[IEEE80211_QOS_MAP_MAX_EX];
  2336. struct cfg80211_dscp_range up[8];
  2337. };
  2338. /**
  2339. * struct cfg80211_nan_conf - NAN configuration
  2340. *
  2341. * This struct defines NAN configuration parameters
  2342. *
  2343. * @master_pref: master preference (1 - 255)
  2344. * @bands: operating bands, a bitmap of &enum nl80211_band values.
  2345. * For instance, for NL80211_BAND_2GHZ, bit 0 would be set
  2346. * (i.e. BIT(NL80211_BAND_2GHZ)).
  2347. */
  2348. struct cfg80211_nan_conf {
  2349. u8 master_pref;
  2350. u8 bands;
  2351. };
  2352. /**
  2353. * enum cfg80211_nan_conf_changes - indicates changed fields in NAN
  2354. * configuration
  2355. *
  2356. * @CFG80211_NAN_CONF_CHANGED_PREF: master preference
  2357. * @CFG80211_NAN_CONF_CHANGED_BANDS: operating bands
  2358. */
  2359. enum cfg80211_nan_conf_changes {
  2360. CFG80211_NAN_CONF_CHANGED_PREF = BIT(0),
  2361. CFG80211_NAN_CONF_CHANGED_BANDS = BIT(1),
  2362. };
  2363. /**
  2364. * struct cfg80211_nan_func_filter - a NAN function Rx / Tx filter
  2365. *
  2366. * @filter: the content of the filter
  2367. * @len: the length of the filter
  2368. */
  2369. struct cfg80211_nan_func_filter {
  2370. const u8 *filter;
  2371. u8 len;
  2372. };
  2373. /**
  2374. * struct cfg80211_nan_func - a NAN function
  2375. *
  2376. * @type: &enum nl80211_nan_function_type
  2377. * @service_id: the service ID of the function
  2378. * @publish_type: &nl80211_nan_publish_type
  2379. * @close_range: if true, the range should be limited. Threshold is
  2380. * implementation specific.
  2381. * @publish_bcast: if true, the solicited publish should be broadcasted
  2382. * @subscribe_active: if true, the subscribe is active
  2383. * @followup_id: the instance ID for follow up
  2384. * @followup_reqid: the requestor instance ID for follow up
  2385. * @followup_dest: MAC address of the recipient of the follow up
  2386. * @ttl: time to live counter in DW.
  2387. * @serv_spec_info: Service Specific Info
  2388. * @serv_spec_info_len: Service Specific Info length
  2389. * @srf_include: if true, SRF is inclusive
  2390. * @srf_bf: Bloom Filter
  2391. * @srf_bf_len: Bloom Filter length
  2392. * @srf_bf_idx: Bloom Filter index
  2393. * @srf_macs: SRF MAC addresses
  2394. * @srf_num_macs: number of MAC addresses in SRF
  2395. * @rx_filters: rx filters that are matched with corresponding peer's tx_filter
  2396. * @tx_filters: filters that should be transmitted in the SDF.
  2397. * @num_rx_filters: length of &rx_filters.
  2398. * @num_tx_filters: length of &tx_filters.
  2399. * @instance_id: driver allocated id of the function.
  2400. * @cookie: unique NAN function identifier.
  2401. */
  2402. struct cfg80211_nan_func {
  2403. enum nl80211_nan_function_type type;
  2404. u8 service_id[NL80211_NAN_FUNC_SERVICE_ID_LEN];
  2405. u8 publish_type;
  2406. bool close_range;
  2407. bool publish_bcast;
  2408. bool subscribe_active;
  2409. u8 followup_id;
  2410. u8 followup_reqid;
  2411. struct mac_address followup_dest;
  2412. u32 ttl;
  2413. const u8 *serv_spec_info;
  2414. u8 serv_spec_info_len;
  2415. bool srf_include;
  2416. const u8 *srf_bf;
  2417. u8 srf_bf_len;
  2418. u8 srf_bf_idx;
  2419. struct mac_address *srf_macs;
  2420. int srf_num_macs;
  2421. struct cfg80211_nan_func_filter *rx_filters;
  2422. struct cfg80211_nan_func_filter *tx_filters;
  2423. u8 num_tx_filters;
  2424. u8 num_rx_filters;
  2425. u8 instance_id;
  2426. u64 cookie;
  2427. };
  2428. /**
  2429. * struct cfg80211_pmk_conf - PMK configuration
  2430. *
  2431. * @aa: authenticator address
  2432. * @pmk_len: PMK length in bytes.
  2433. * @pmk: the PMK material
  2434. * @pmk_r0_name: PMK-R0 Name. NULL if not applicable (i.e., the PMK
  2435. * is not PMK-R0). When pmk_r0_name is not NULL, the pmk field
  2436. * holds PMK-R0.
  2437. */
  2438. struct cfg80211_pmk_conf {
  2439. const u8 *aa;
  2440. u8 pmk_len;
  2441. const u8 *pmk;
  2442. const u8 *pmk_r0_name;
  2443. };
  2444. /**
  2445. * struct cfg80211_ops - backend description for wireless configuration
  2446. *
  2447. * This struct is registered by fullmac card drivers and/or wireless stacks
  2448. * in order to handle configuration requests on their interfaces.
  2449. *
  2450. * All callbacks except where otherwise noted should return 0
  2451. * on success or a negative error code.
  2452. *
  2453. * All operations are currently invoked under rtnl for consistency with the
  2454. * wireless extensions but this is subject to reevaluation as soon as this
  2455. * code is used more widely and we have a first user without wext.
  2456. *
  2457. * @suspend: wiphy device needs to be suspended. The variable @wow will
  2458. * be %NULL or contain the enabled Wake-on-Wireless triggers that are
  2459. * configured for the device.
  2460. * @resume: wiphy device needs to be resumed
  2461. * @set_wakeup: Called when WoWLAN is enabled/disabled, use this callback
  2462. * to call device_set_wakeup_enable() to enable/disable wakeup from
  2463. * the device.
  2464. *
  2465. * @add_virtual_intf: create a new virtual interface with the given name,
  2466. * must set the struct wireless_dev's iftype. Beware: You must create
  2467. * the new netdev in the wiphy's network namespace! Returns the struct
  2468. * wireless_dev, or an ERR_PTR. For P2P device wdevs, the driver must
  2469. * also set the address member in the wdev.
  2470. *
  2471. * @del_virtual_intf: remove the virtual interface
  2472. *
  2473. * @change_virtual_intf: change type/configuration of virtual interface,
  2474. * keep the struct wireless_dev's iftype updated.
  2475. *
  2476. * @add_key: add a key with the given parameters. @mac_addr will be %NULL
  2477. * when adding a group key.
  2478. *
  2479. * @get_key: get information about the key with the given parameters.
  2480. * @mac_addr will be %NULL when requesting information for a group
  2481. * key. All pointers given to the @callback function need not be valid
  2482. * after it returns. This function should return an error if it is
  2483. * not possible to retrieve the key, -ENOENT if it doesn't exist.
  2484. *
  2485. * @del_key: remove a key given the @mac_addr (%NULL for a group key)
  2486. * and @key_index, return -ENOENT if the key doesn't exist.
  2487. *
  2488. * @set_default_key: set the default key on an interface
  2489. *
  2490. * @set_default_mgmt_key: set the default management frame key on an interface
  2491. *
  2492. * @set_rekey_data: give the data necessary for GTK rekeying to the driver
  2493. *
  2494. * @start_ap: Start acting in AP mode defined by the parameters.
  2495. * @change_beacon: Change the beacon parameters for an access point mode
  2496. * interface. This should reject the call when AP mode wasn't started.
  2497. * @stop_ap: Stop being an AP, including stopping beaconing.
  2498. *
  2499. * @add_station: Add a new station.
  2500. * @del_station: Remove a station
  2501. * @change_station: Modify a given station. Note that flags changes are not much
  2502. * validated in cfg80211, in particular the auth/assoc/authorized flags
  2503. * might come to the driver in invalid combinations -- make sure to check
  2504. * them, also against the existing state! Drivers must call
  2505. * cfg80211_check_station_change() to validate the information.
  2506. * @get_station: get station information for the station identified by @mac
  2507. * @dump_station: dump station callback -- resume dump at index @idx
  2508. *
  2509. * @add_mpath: add a fixed mesh path
  2510. * @del_mpath: delete a given mesh path
  2511. * @change_mpath: change a given mesh path
  2512. * @get_mpath: get a mesh path for the given parameters
  2513. * @dump_mpath: dump mesh path callback -- resume dump at index @idx
  2514. * @get_mpp: get a mesh proxy path for the given parameters
  2515. * @dump_mpp: dump mesh proxy path callback -- resume dump at index @idx
  2516. * @join_mesh: join the mesh network with the specified parameters
  2517. * (invoked with the wireless_dev mutex held)
  2518. * @leave_mesh: leave the current mesh network
  2519. * (invoked with the wireless_dev mutex held)
  2520. *
  2521. * @get_mesh_config: Get the current mesh configuration
  2522. *
  2523. * @update_mesh_config: Update mesh parameters on a running mesh.
  2524. * The mask is a bitfield which tells us which parameters to
  2525. * set, and which to leave alone.
  2526. *
  2527. * @change_bss: Modify parameters for a given BSS.
  2528. *
  2529. * @set_txq_params: Set TX queue parameters
  2530. *
  2531. * @libertas_set_mesh_channel: Only for backward compatibility for libertas,
  2532. * as it doesn't implement join_mesh and needs to set the channel to
  2533. * join the mesh instead.
  2534. *
  2535. * @set_monitor_channel: Set the monitor mode channel for the device. If other
  2536. * interfaces are active this callback should reject the configuration.
  2537. * If no interfaces are active or the device is down, the channel should
  2538. * be stored for when a monitor interface becomes active.
  2539. *
  2540. * @scan: Request to do a scan. If returning zero, the scan request is given
  2541. * the driver, and will be valid until passed to cfg80211_scan_done().
  2542. * For scan results, call cfg80211_inform_bss(); you can call this outside
  2543. * the scan/scan_done bracket too.
  2544. * @abort_scan: Tell the driver to abort an ongoing scan. The driver shall
  2545. * indicate the status of the scan through cfg80211_scan_done().
  2546. *
  2547. * @auth: Request to authenticate with the specified peer
  2548. * (invoked with the wireless_dev mutex held)
  2549. * @assoc: Request to (re)associate with the specified peer
  2550. * (invoked with the wireless_dev mutex held)
  2551. * @deauth: Request to deauthenticate from the specified peer
  2552. * (invoked with the wireless_dev mutex held)
  2553. * @disassoc: Request to disassociate from the specified peer
  2554. * (invoked with the wireless_dev mutex held)
  2555. *
  2556. * @connect: Connect to the ESS with the specified parameters. When connected,
  2557. * call cfg80211_connect_result()/cfg80211_connect_bss() with status code
  2558. * %WLAN_STATUS_SUCCESS. If the connection fails for some reason, call
  2559. * cfg80211_connect_result()/cfg80211_connect_bss() with the status code
  2560. * from the AP or cfg80211_connect_timeout() if no frame with status code
  2561. * was received.
  2562. * The driver is allowed to roam to other BSSes within the ESS when the
  2563. * other BSS matches the connect parameters. When such roaming is initiated
  2564. * by the driver, the driver is expected to verify that the target matches
  2565. * the configured security parameters and to use Reassociation Request
  2566. * frame instead of Association Request frame.
  2567. * The connect function can also be used to request the driver to perform a
  2568. * specific roam when connected to an ESS. In that case, the prev_bssid
  2569. * parameter is set to the BSSID of the currently associated BSS as an
  2570. * indication of requesting reassociation.
  2571. * In both the driver-initiated and new connect() call initiated roaming
  2572. * cases, the result of roaming is indicated with a call to
  2573. * cfg80211_roamed(). (invoked with the wireless_dev mutex held)
  2574. * @update_connect_params: Update the connect parameters while connected to a
  2575. * BSS. The updated parameters can be used by driver/firmware for
  2576. * subsequent BSS selection (roaming) decisions and to form the
  2577. * Authentication/(Re)Association Request frames. This call does not
  2578. * request an immediate disassociation or reassociation with the current
  2579. * BSS, i.e., this impacts only subsequent (re)associations. The bits in
  2580. * changed are defined in &enum cfg80211_connect_params_changed.
  2581. * (invoked with the wireless_dev mutex held)
  2582. * @disconnect: Disconnect from the BSS/ESS or stop connection attempts if
  2583. * connection is in progress. Once done, call cfg80211_disconnected() in
  2584. * case connection was already established (invoked with the
  2585. * wireless_dev mutex held), otherwise call cfg80211_connect_timeout().
  2586. *
  2587. * @join_ibss: Join the specified IBSS (or create if necessary). Once done, call
  2588. * cfg80211_ibss_joined(), also call that function when changing BSSID due
  2589. * to a merge.
  2590. * (invoked with the wireless_dev mutex held)
  2591. * @leave_ibss: Leave the IBSS.
  2592. * (invoked with the wireless_dev mutex held)
  2593. *
  2594. * @set_mcast_rate: Set the specified multicast rate (only if vif is in ADHOC or
  2595. * MESH mode)
  2596. *
  2597. * @set_wiphy_params: Notify that wiphy parameters have changed;
  2598. * @changed bitfield (see &enum wiphy_params_flags) describes which values
  2599. * have changed. The actual parameter values are available in
  2600. * struct wiphy. If returning an error, no value should be changed.
  2601. *
  2602. * @set_tx_power: set the transmit power according to the parameters,
  2603. * the power passed is in mBm, to get dBm use MBM_TO_DBM(). The
  2604. * wdev may be %NULL if power was set for the wiphy, and will
  2605. * always be %NULL unless the driver supports per-vif TX power
  2606. * (as advertised by the nl80211 feature flag.)
  2607. * @get_tx_power: store the current TX power into the dbm variable;
  2608. * return 0 if successful
  2609. *
  2610. * @set_wds_peer: set the WDS peer for a WDS interface
  2611. *
  2612. * @rfkill_poll: polls the hw rfkill line, use cfg80211 reporting
  2613. * functions to adjust rfkill hw state
  2614. *
  2615. * @dump_survey: get site survey information.
  2616. *
  2617. * @remain_on_channel: Request the driver to remain awake on the specified
  2618. * channel for the specified duration to complete an off-channel
  2619. * operation (e.g., public action frame exchange). When the driver is
  2620. * ready on the requested channel, it must indicate this with an event
  2621. * notification by calling cfg80211_ready_on_channel().
  2622. * @cancel_remain_on_channel: Cancel an on-going remain-on-channel operation.
  2623. * This allows the operation to be terminated prior to timeout based on
  2624. * the duration value.
  2625. * @mgmt_tx: Transmit a management frame.
  2626. * @mgmt_tx_cancel_wait: Cancel the wait time from transmitting a management
  2627. * frame on another channel
  2628. *
  2629. * @testmode_cmd: run a test mode command; @wdev may be %NULL
  2630. * @testmode_dump: Implement a test mode dump. The cb->args[2] and up may be
  2631. * used by the function, but 0 and 1 must not be touched. Additionally,
  2632. * return error codes other than -ENOBUFS and -ENOENT will terminate the
  2633. * dump and return to userspace with an error, so be careful. If any data
  2634. * was passed in from userspace then the data/len arguments will be present
  2635. * and point to the data contained in %NL80211_ATTR_TESTDATA.
  2636. *
  2637. * @set_bitrate_mask: set the bitrate mask configuration
  2638. *
  2639. * @set_pmksa: Cache a PMKID for a BSSID. This is mostly useful for fullmac
  2640. * devices running firmwares capable of generating the (re) association
  2641. * RSN IE. It allows for faster roaming between WPA2 BSSIDs.
  2642. * @del_pmksa: Delete a cached PMKID.
  2643. * @flush_pmksa: Flush all cached PMKIDs.
  2644. * @set_power_mgmt: Configure WLAN power management. A timeout value of -1
  2645. * allows the driver to adjust the dynamic ps timeout value.
  2646. * @set_cqm_rssi_config: Configure connection quality monitor RSSI threshold.
  2647. * After configuration, the driver should (soon) send an event indicating
  2648. * the current level is above/below the configured threshold; this may
  2649. * need some care when the configuration is changed (without first being
  2650. * disabled.)
  2651. * @set_cqm_rssi_range_config: Configure two RSSI thresholds in the
  2652. * connection quality monitor. An event is to be sent only when the
  2653. * signal level is found to be outside the two values. The driver should
  2654. * set %NL80211_EXT_FEATURE_CQM_RSSI_LIST if this method is implemented.
  2655. * If it is provided then there's no point providing @set_cqm_rssi_config.
  2656. * @set_cqm_txe_config: Configure connection quality monitor TX error
  2657. * thresholds.
  2658. * @sched_scan_start: Tell the driver to start a scheduled scan.
  2659. * @sched_scan_stop: Tell the driver to stop an ongoing scheduled scan with
  2660. * given request id. This call must stop the scheduled scan and be ready
  2661. * for starting a new one before it returns, i.e. @sched_scan_start may be
  2662. * called immediately after that again and should not fail in that case.
  2663. * The driver should not call cfg80211_sched_scan_stopped() for a requested
  2664. * stop (when this method returns 0).
  2665. *
  2666. * @mgmt_frame_register: Notify driver that a management frame type was
  2667. * registered. The callback is allowed to sleep.
  2668. *
  2669. * @set_antenna: Set antenna configuration (tx_ant, rx_ant) on the device.
  2670. * Parameters are bitmaps of allowed antennas to use for TX/RX. Drivers may
  2671. * reject TX/RX mask combinations they cannot support by returning -EINVAL
  2672. * (also see nl80211.h @NL80211_ATTR_WIPHY_ANTENNA_TX).
  2673. *
  2674. * @get_antenna: Get current antenna configuration from device (tx_ant, rx_ant).
  2675. *
  2676. * @tdls_mgmt: Transmit a TDLS management frame.
  2677. * @tdls_oper: Perform a high-level TDLS operation (e.g. TDLS link setup).
  2678. *
  2679. * @probe_client: probe an associated client, must return a cookie that it
  2680. * later passes to cfg80211_probe_status().
  2681. *
  2682. * @set_noack_map: Set the NoAck Map for the TIDs.
  2683. *
  2684. * @get_channel: Get the current operating channel for the virtual interface.
  2685. * For monitor interfaces, it should return %NULL unless there's a single
  2686. * current monitoring channel.
  2687. *
  2688. * @start_p2p_device: Start the given P2P device.
  2689. * @stop_p2p_device: Stop the given P2P device.
  2690. *
  2691. * @set_mac_acl: Sets MAC address control list in AP and P2P GO mode.
  2692. * Parameters include ACL policy, an array of MAC address of stations
  2693. * and the number of MAC addresses. If there is already a list in driver
  2694. * this new list replaces the existing one. Driver has to clear its ACL
  2695. * when number of MAC addresses entries is passed as 0. Drivers which
  2696. * advertise the support for MAC based ACL have to implement this callback.
  2697. *
  2698. * @start_radar_detection: Start radar detection in the driver.
  2699. *
  2700. * @update_ft_ies: Provide updated Fast BSS Transition information to the
  2701. * driver. If the SME is in the driver/firmware, this information can be
  2702. * used in building Authentication and Reassociation Request frames.
  2703. *
  2704. * @crit_proto_start: Indicates a critical protocol needs more link reliability
  2705. * for a given duration (milliseconds). The protocol is provided so the
  2706. * driver can take the most appropriate actions.
  2707. * @crit_proto_stop: Indicates critical protocol no longer needs increased link
  2708. * reliability. This operation can not fail.
  2709. * @set_coalesce: Set coalesce parameters.
  2710. *
  2711. * @channel_switch: initiate channel-switch procedure (with CSA). Driver is
  2712. * responsible for veryfing if the switch is possible. Since this is
  2713. * inherently tricky driver may decide to disconnect an interface later
  2714. * with cfg80211_stop_iface(). This doesn't mean driver can accept
  2715. * everything. It should do it's best to verify requests and reject them
  2716. * as soon as possible.
  2717. *
  2718. * @set_qos_map: Set QoS mapping information to the driver
  2719. *
  2720. * @set_ap_chanwidth: Set the AP (including P2P GO) mode channel width for the
  2721. * given interface This is used e.g. for dynamic HT 20/40 MHz channel width
  2722. * changes during the lifetime of the BSS.
  2723. *
  2724. * @add_tx_ts: validate (if admitted_time is 0) or add a TX TS to the device
  2725. * with the given parameters; action frame exchange has been handled by
  2726. * userspace so this just has to modify the TX path to take the TS into
  2727. * account.
  2728. * If the admitted time is 0 just validate the parameters to make sure
  2729. * the session can be created at all; it is valid to just always return
  2730. * success for that but that may result in inefficient behaviour (handshake
  2731. * with the peer followed by immediate teardown when the addition is later
  2732. * rejected)
  2733. * @del_tx_ts: remove an existing TX TS
  2734. *
  2735. * @join_ocb: join the OCB network with the specified parameters
  2736. * (invoked with the wireless_dev mutex held)
  2737. * @leave_ocb: leave the current OCB network
  2738. * (invoked with the wireless_dev mutex held)
  2739. *
  2740. * @tdls_channel_switch: Start channel-switching with a TDLS peer. The driver
  2741. * is responsible for continually initiating channel-switching operations
  2742. * and returning to the base channel for communication with the AP.
  2743. * @tdls_cancel_channel_switch: Stop channel-switching with a TDLS peer. Both
  2744. * peers must be on the base channel when the call completes.
  2745. * @start_nan: Start the NAN interface.
  2746. * @stop_nan: Stop the NAN interface.
  2747. * @add_nan_func: Add a NAN function. Returns negative value on failure.
  2748. * On success @nan_func ownership is transferred to the driver and
  2749. * it may access it outside of the scope of this function. The driver
  2750. * should free the @nan_func when no longer needed by calling
  2751. * cfg80211_free_nan_func().
  2752. * On success the driver should assign an instance_id in the
  2753. * provided @nan_func.
  2754. * @del_nan_func: Delete a NAN function.
  2755. * @nan_change_conf: changes NAN configuration. The changed parameters must
  2756. * be specified in @changes (using &enum cfg80211_nan_conf_changes);
  2757. * All other parameters must be ignored.
  2758. *
  2759. * @set_multicast_to_unicast: configure multicast to unicast conversion for BSS
  2760. *
  2761. * @set_pmk: configure the PMK to be used for offloaded 802.1X 4-Way handshake.
  2762. * If not deleted through @del_pmk the PMK remains valid until disconnect
  2763. * upon which the driver should clear it.
  2764. * (invoked with the wireless_dev mutex held)
  2765. * @del_pmk: delete the previously configured PMK for the given authenticator.
  2766. * (invoked with the wireless_dev mutex held)
  2767. */
  2768. struct cfg80211_ops {
  2769. int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow);
  2770. int (*resume)(struct wiphy *wiphy);
  2771. void (*set_wakeup)(struct wiphy *wiphy, bool enabled);
  2772. struct wireless_dev * (*add_virtual_intf)(struct wiphy *wiphy,
  2773. const char *name,
  2774. unsigned char name_assign_type,
  2775. enum nl80211_iftype type,
  2776. struct vif_params *params);
  2777. int (*del_virtual_intf)(struct wiphy *wiphy,
  2778. struct wireless_dev *wdev);
  2779. int (*change_virtual_intf)(struct wiphy *wiphy,
  2780. struct net_device *dev,
  2781. enum nl80211_iftype type,
  2782. struct vif_params *params);
  2783. int (*add_key)(struct wiphy *wiphy, struct net_device *netdev,
  2784. u8 key_index, bool pairwise, const u8 *mac_addr,
  2785. struct key_params *params);
  2786. int (*get_key)(struct wiphy *wiphy, struct net_device *netdev,
  2787. u8 key_index, bool pairwise, const u8 *mac_addr,
  2788. void *cookie,
  2789. void (*callback)(void *cookie, struct key_params*));
  2790. int (*del_key)(struct wiphy *wiphy, struct net_device *netdev,
  2791. u8 key_index, bool pairwise, const u8 *mac_addr);
  2792. int (*set_default_key)(struct wiphy *wiphy,
  2793. struct net_device *netdev,
  2794. u8 key_index, bool unicast, bool multicast);
  2795. int (*set_default_mgmt_key)(struct wiphy *wiphy,
  2796. struct net_device *netdev,
  2797. u8 key_index);
  2798. int (*start_ap)(struct wiphy *wiphy, struct net_device *dev,
  2799. struct cfg80211_ap_settings *settings);
  2800. int (*change_beacon)(struct wiphy *wiphy, struct net_device *dev,
  2801. struct cfg80211_beacon_data *info);
  2802. int (*stop_ap)(struct wiphy *wiphy, struct net_device *dev);
  2803. int (*add_station)(struct wiphy *wiphy, struct net_device *dev,
  2804. const u8 *mac,
  2805. struct station_parameters *params);
  2806. int (*del_station)(struct wiphy *wiphy, struct net_device *dev,
  2807. struct station_del_parameters *params);
  2808. int (*change_station)(struct wiphy *wiphy, struct net_device *dev,
  2809. const u8 *mac,
  2810. struct station_parameters *params);
  2811. int (*get_station)(struct wiphy *wiphy, struct net_device *dev,
  2812. const u8 *mac, struct station_info *sinfo);
  2813. int (*dump_station)(struct wiphy *wiphy, struct net_device *dev,
  2814. int idx, u8 *mac, struct station_info *sinfo);
  2815. int (*add_mpath)(struct wiphy *wiphy, struct net_device *dev,
  2816. const u8 *dst, const u8 *next_hop);
  2817. int (*del_mpath)(struct wiphy *wiphy, struct net_device *dev,
  2818. const u8 *dst);
  2819. int (*change_mpath)(struct wiphy *wiphy, struct net_device *dev,
  2820. const u8 *dst, const u8 *next_hop);
  2821. int (*get_mpath)(struct wiphy *wiphy, struct net_device *dev,
  2822. u8 *dst, u8 *next_hop, struct mpath_info *pinfo);
  2823. int (*dump_mpath)(struct wiphy *wiphy, struct net_device *dev,
  2824. int idx, u8 *dst, u8 *next_hop,
  2825. struct mpath_info *pinfo);
  2826. int (*get_mpp)(struct wiphy *wiphy, struct net_device *dev,
  2827. u8 *dst, u8 *mpp, struct mpath_info *pinfo);
  2828. int (*dump_mpp)(struct wiphy *wiphy, struct net_device *dev,
  2829. int idx, u8 *dst, u8 *mpp,
  2830. struct mpath_info *pinfo);
  2831. int (*get_mesh_config)(struct wiphy *wiphy,
  2832. struct net_device *dev,
  2833. struct mesh_config *conf);
  2834. int (*update_mesh_config)(struct wiphy *wiphy,
  2835. struct net_device *dev, u32 mask,
  2836. const struct mesh_config *nconf);
  2837. int (*join_mesh)(struct wiphy *wiphy, struct net_device *dev,
  2838. const struct mesh_config *conf,
  2839. const struct mesh_setup *setup);
  2840. int (*leave_mesh)(struct wiphy *wiphy, struct net_device *dev);
  2841. int (*join_ocb)(struct wiphy *wiphy, struct net_device *dev,
  2842. struct ocb_setup *setup);
  2843. int (*leave_ocb)(struct wiphy *wiphy, struct net_device *dev);
  2844. int (*change_bss)(struct wiphy *wiphy, struct net_device *dev,
  2845. struct bss_parameters *params);
  2846. int (*set_txq_params)(struct wiphy *wiphy, struct net_device *dev,
  2847. struct ieee80211_txq_params *params);
  2848. int (*libertas_set_mesh_channel)(struct wiphy *wiphy,
  2849. struct net_device *dev,
  2850. struct ieee80211_channel *chan);
  2851. int (*set_monitor_channel)(struct wiphy *wiphy,
  2852. struct cfg80211_chan_def *chandef);
  2853. int (*scan)(struct wiphy *wiphy,
  2854. struct cfg80211_scan_request *request);
  2855. void (*abort_scan)(struct wiphy *wiphy, struct wireless_dev *wdev);
  2856. int (*auth)(struct wiphy *wiphy, struct net_device *dev,
  2857. struct cfg80211_auth_request *req);
  2858. int (*assoc)(struct wiphy *wiphy, struct net_device *dev,
  2859. struct cfg80211_assoc_request *req);
  2860. int (*deauth)(struct wiphy *wiphy, struct net_device *dev,
  2861. struct cfg80211_deauth_request *req);
  2862. int (*disassoc)(struct wiphy *wiphy, struct net_device *dev,
  2863. struct cfg80211_disassoc_request *req);
  2864. int (*connect)(struct wiphy *wiphy, struct net_device *dev,
  2865. struct cfg80211_connect_params *sme);
  2866. int (*update_connect_params)(struct wiphy *wiphy,
  2867. struct net_device *dev,
  2868. struct cfg80211_connect_params *sme,
  2869. u32 changed);
  2870. int (*disconnect)(struct wiphy *wiphy, struct net_device *dev,
  2871. u16 reason_code);
  2872. int (*join_ibss)(struct wiphy *wiphy, struct net_device *dev,
  2873. struct cfg80211_ibss_params *params);
  2874. int (*leave_ibss)(struct wiphy *wiphy, struct net_device *dev);
  2875. int (*set_mcast_rate)(struct wiphy *wiphy, struct net_device *dev,
  2876. int rate[NUM_NL80211_BANDS]);
  2877. int (*set_wiphy_params)(struct wiphy *wiphy, u32 changed);
  2878. int (*set_tx_power)(struct wiphy *wiphy, struct wireless_dev *wdev,
  2879. enum nl80211_tx_power_setting type, int mbm);
  2880. int (*get_tx_power)(struct wiphy *wiphy, struct wireless_dev *wdev,
  2881. int *dbm);
  2882. int (*set_wds_peer)(struct wiphy *wiphy, struct net_device *dev,
  2883. const u8 *addr);
  2884. void (*rfkill_poll)(struct wiphy *wiphy);
  2885. #ifdef CONFIG_NL80211_TESTMODE
  2886. int (*testmode_cmd)(struct wiphy *wiphy, struct wireless_dev *wdev,
  2887. void *data, int len);
  2888. int (*testmode_dump)(struct wiphy *wiphy, struct sk_buff *skb,
  2889. struct netlink_callback *cb,
  2890. void *data, int len);
  2891. #endif
  2892. int (*set_bitrate_mask)(struct wiphy *wiphy,
  2893. struct net_device *dev,
  2894. const u8 *peer,
  2895. const struct cfg80211_bitrate_mask *mask);
  2896. int (*dump_survey)(struct wiphy *wiphy, struct net_device *netdev,
  2897. int idx, struct survey_info *info);
  2898. int (*set_pmksa)(struct wiphy *wiphy, struct net_device *netdev,
  2899. struct cfg80211_pmksa *pmksa);
  2900. int (*del_pmksa)(struct wiphy *wiphy, struct net_device *netdev,
  2901. struct cfg80211_pmksa *pmksa);
  2902. int (*flush_pmksa)(struct wiphy *wiphy, struct net_device *netdev);
  2903. int (*remain_on_channel)(struct wiphy *wiphy,
  2904. struct wireless_dev *wdev,
  2905. struct ieee80211_channel *chan,
  2906. unsigned int duration,
  2907. u64 *cookie);
  2908. int (*cancel_remain_on_channel)(struct wiphy *wiphy,
  2909. struct wireless_dev *wdev,
  2910. u64 cookie);
  2911. int (*mgmt_tx)(struct wiphy *wiphy, struct wireless_dev *wdev,
  2912. struct cfg80211_mgmt_tx_params *params,
  2913. u64 *cookie);
  2914. int (*mgmt_tx_cancel_wait)(struct wiphy *wiphy,
  2915. struct wireless_dev *wdev,
  2916. u64 cookie);
  2917. int (*set_power_mgmt)(struct wiphy *wiphy, struct net_device *dev,
  2918. bool enabled, int timeout);
  2919. int (*set_cqm_rssi_config)(struct wiphy *wiphy,
  2920. struct net_device *dev,
  2921. s32 rssi_thold, u32 rssi_hyst);
  2922. int (*set_cqm_rssi_range_config)(struct wiphy *wiphy,
  2923. struct net_device *dev,
  2924. s32 rssi_low, s32 rssi_high);
  2925. int (*set_cqm_txe_config)(struct wiphy *wiphy,
  2926. struct net_device *dev,
  2927. u32 rate, u32 pkts, u32 intvl);
  2928. void (*mgmt_frame_register)(struct wiphy *wiphy,
  2929. struct wireless_dev *wdev,
  2930. u16 frame_type, bool reg);
  2931. int (*set_antenna)(struct wiphy *wiphy, u32 tx_ant, u32 rx_ant);
  2932. int (*get_antenna)(struct wiphy *wiphy, u32 *tx_ant, u32 *rx_ant);
  2933. int (*sched_scan_start)(struct wiphy *wiphy,
  2934. struct net_device *dev,
  2935. struct cfg80211_sched_scan_request *request);
  2936. int (*sched_scan_stop)(struct wiphy *wiphy, struct net_device *dev,
  2937. u64 reqid);
  2938. int (*set_rekey_data)(struct wiphy *wiphy, struct net_device *dev,
  2939. struct cfg80211_gtk_rekey_data *data);
  2940. int (*tdls_mgmt)(struct wiphy *wiphy, struct net_device *dev,
  2941. const u8 *peer, u8 action_code, u8 dialog_token,
  2942. u16 status_code, u32 peer_capability,
  2943. bool initiator, const u8 *buf, size_t len);
  2944. int (*tdls_oper)(struct wiphy *wiphy, struct net_device *dev,
  2945. const u8 *peer, enum nl80211_tdls_operation oper);
  2946. int (*probe_client)(struct wiphy *wiphy, struct net_device *dev,
  2947. const u8 *peer, u64 *cookie);
  2948. int (*set_noack_map)(struct wiphy *wiphy,
  2949. struct net_device *dev,
  2950. u16 noack_map);
  2951. int (*get_channel)(struct wiphy *wiphy,
  2952. struct wireless_dev *wdev,
  2953. struct cfg80211_chan_def *chandef);
  2954. int (*start_p2p_device)(struct wiphy *wiphy,
  2955. struct wireless_dev *wdev);
  2956. void (*stop_p2p_device)(struct wiphy *wiphy,
  2957. struct wireless_dev *wdev);
  2958. int (*set_mac_acl)(struct wiphy *wiphy, struct net_device *dev,
  2959. const struct cfg80211_acl_data *params);
  2960. int (*start_radar_detection)(struct wiphy *wiphy,
  2961. struct net_device *dev,
  2962. struct cfg80211_chan_def *chandef,
  2963. u32 cac_time_ms);
  2964. int (*update_ft_ies)(struct wiphy *wiphy, struct net_device *dev,
  2965. struct cfg80211_update_ft_ies_params *ftie);
  2966. int (*crit_proto_start)(struct wiphy *wiphy,
  2967. struct wireless_dev *wdev,
  2968. enum nl80211_crit_proto_id protocol,
  2969. u16 duration);
  2970. void (*crit_proto_stop)(struct wiphy *wiphy,
  2971. struct wireless_dev *wdev);
  2972. int (*set_coalesce)(struct wiphy *wiphy,
  2973. struct cfg80211_coalesce *coalesce);
  2974. int (*channel_switch)(struct wiphy *wiphy,
  2975. struct net_device *dev,
  2976. struct cfg80211_csa_settings *params);
  2977. int (*set_qos_map)(struct wiphy *wiphy,
  2978. struct net_device *dev,
  2979. struct cfg80211_qos_map *qos_map);
  2980. int (*set_ap_chanwidth)(struct wiphy *wiphy, struct net_device *dev,
  2981. struct cfg80211_chan_def *chandef);
  2982. int (*add_tx_ts)(struct wiphy *wiphy, struct net_device *dev,
  2983. u8 tsid, const u8 *peer, u8 user_prio,
  2984. u16 admitted_time);
  2985. int (*del_tx_ts)(struct wiphy *wiphy, struct net_device *dev,
  2986. u8 tsid, const u8 *peer);
  2987. int (*tdls_channel_switch)(struct wiphy *wiphy,
  2988. struct net_device *dev,
  2989. const u8 *addr, u8 oper_class,
  2990. struct cfg80211_chan_def *chandef);
  2991. void (*tdls_cancel_channel_switch)(struct wiphy *wiphy,
  2992. struct net_device *dev,
  2993. const u8 *addr);
  2994. int (*start_nan)(struct wiphy *wiphy, struct wireless_dev *wdev,
  2995. struct cfg80211_nan_conf *conf);
  2996. void (*stop_nan)(struct wiphy *wiphy, struct wireless_dev *wdev);
  2997. int (*add_nan_func)(struct wiphy *wiphy, struct wireless_dev *wdev,
  2998. struct cfg80211_nan_func *nan_func);
  2999. void (*del_nan_func)(struct wiphy *wiphy, struct wireless_dev *wdev,
  3000. u64 cookie);
  3001. int (*nan_change_conf)(struct wiphy *wiphy,
  3002. struct wireless_dev *wdev,
  3003. struct cfg80211_nan_conf *conf,
  3004. u32 changes);
  3005. int (*set_multicast_to_unicast)(struct wiphy *wiphy,
  3006. struct net_device *dev,
  3007. const bool enabled);
  3008. int (*set_pmk)(struct wiphy *wiphy, struct net_device *dev,
  3009. const struct cfg80211_pmk_conf *conf);
  3010. int (*del_pmk)(struct wiphy *wiphy, struct net_device *dev,
  3011. const u8 *aa);
  3012. };
  3013. /*
  3014. * wireless hardware and networking interfaces structures
  3015. * and registration/helper functions
  3016. */
  3017. /**
  3018. * enum wiphy_flags - wiphy capability flags
  3019. *
  3020. * @WIPHY_FLAG_NETNS_OK: if not set, do not allow changing the netns of this
  3021. * wiphy at all
  3022. * @WIPHY_FLAG_PS_ON_BY_DEFAULT: if set to true, powersave will be enabled
  3023. * by default -- this flag will be set depending on the kernel's default
  3024. * on wiphy_new(), but can be changed by the driver if it has a good
  3025. * reason to override the default
  3026. * @WIPHY_FLAG_4ADDR_AP: supports 4addr mode even on AP (with a single station
  3027. * on a VLAN interface)
  3028. * @WIPHY_FLAG_4ADDR_STATION: supports 4addr mode even as a station
  3029. * @WIPHY_FLAG_CONTROL_PORT_PROTOCOL: This device supports setting the
  3030. * control port protocol ethertype. The device also honours the
  3031. * control_port_no_encrypt flag.
  3032. * @WIPHY_FLAG_IBSS_RSN: The device supports IBSS RSN.
  3033. * @WIPHY_FLAG_MESH_AUTH: The device supports mesh authentication by routing
  3034. * auth frames to userspace. See @NL80211_MESH_SETUP_USERSPACE_AUTH.
  3035. * @WIPHY_FLAG_SUPPORTS_SCHED_SCAN: The device supports scheduled scans.
  3036. * @WIPHY_FLAG_SUPPORTS_FW_ROAM: The device supports roaming feature in the
  3037. * firmware.
  3038. * @WIPHY_FLAG_AP_UAPSD: The device supports uapsd on AP.
  3039. * @WIPHY_FLAG_SUPPORTS_TDLS: The device supports TDLS (802.11z) operation.
  3040. * @WIPHY_FLAG_TDLS_EXTERNAL_SETUP: The device does not handle TDLS (802.11z)
  3041. * link setup/discovery operations internally. Setup, discovery and
  3042. * teardown packets should be sent through the @NL80211_CMD_TDLS_MGMT
  3043. * command. When this flag is not set, @NL80211_CMD_TDLS_OPER should be
  3044. * used for asking the driver/firmware to perform a TDLS operation.
  3045. * @WIPHY_FLAG_HAVE_AP_SME: device integrates AP SME
  3046. * @WIPHY_FLAG_REPORTS_OBSS: the device will report beacons from other BSSes
  3047. * when there are virtual interfaces in AP mode by calling
  3048. * cfg80211_report_obss_beacon().
  3049. * @WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD: When operating as an AP, the device
  3050. * responds to probe-requests in hardware.
  3051. * @WIPHY_FLAG_OFFCHAN_TX: Device supports direct off-channel TX.
  3052. * @WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL: Device supports remain-on-channel call.
  3053. * @WIPHY_FLAG_SUPPORTS_5_10_MHZ: Device supports 5 MHz and 10 MHz channels.
  3054. * @WIPHY_FLAG_HAS_CHANNEL_SWITCH: Device supports channel switch in
  3055. * beaconing mode (AP, IBSS, Mesh, ...).
  3056. * @WIPHY_FLAG_HAS_STATIC_WEP: The device supports static WEP key installation
  3057. * before connection.
  3058. */
  3059. enum wiphy_flags {
  3060. /* use hole at 0 */
  3061. /* use hole at 1 */
  3062. /* use hole at 2 */
  3063. WIPHY_FLAG_NETNS_OK = BIT(3),
  3064. WIPHY_FLAG_PS_ON_BY_DEFAULT = BIT(4),
  3065. WIPHY_FLAG_4ADDR_AP = BIT(5),
  3066. WIPHY_FLAG_4ADDR_STATION = BIT(6),
  3067. WIPHY_FLAG_CONTROL_PORT_PROTOCOL = BIT(7),
  3068. WIPHY_FLAG_IBSS_RSN = BIT(8),
  3069. WIPHY_FLAG_MESH_AUTH = BIT(10),
  3070. /* use hole at 11 */
  3071. /* use hole at 12 */
  3072. WIPHY_FLAG_SUPPORTS_FW_ROAM = BIT(13),
  3073. WIPHY_FLAG_AP_UAPSD = BIT(14),
  3074. WIPHY_FLAG_SUPPORTS_TDLS = BIT(15),
  3075. WIPHY_FLAG_TDLS_EXTERNAL_SETUP = BIT(16),
  3076. WIPHY_FLAG_HAVE_AP_SME = BIT(17),
  3077. WIPHY_FLAG_REPORTS_OBSS = BIT(18),
  3078. WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD = BIT(19),
  3079. WIPHY_FLAG_OFFCHAN_TX = BIT(20),
  3080. WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL = BIT(21),
  3081. WIPHY_FLAG_SUPPORTS_5_10_MHZ = BIT(22),
  3082. WIPHY_FLAG_HAS_CHANNEL_SWITCH = BIT(23),
  3083. WIPHY_FLAG_HAS_STATIC_WEP = BIT(24),
  3084. };
  3085. /**
  3086. * struct ieee80211_iface_limit - limit on certain interface types
  3087. * @max: maximum number of interfaces of these types
  3088. * @types: interface types (bits)
  3089. */
  3090. struct ieee80211_iface_limit {
  3091. u16 max;
  3092. u16 types;
  3093. };
  3094. /**
  3095. * struct ieee80211_iface_combination - possible interface combination
  3096. *
  3097. * With this structure the driver can describe which interface
  3098. * combinations it supports concurrently.
  3099. *
  3100. * Examples:
  3101. *
  3102. * 1. Allow #STA <= 1, #AP <= 1, matching BI, channels = 1, 2 total:
  3103. *
  3104. * .. code-block:: c
  3105. *
  3106. * struct ieee80211_iface_limit limits1[] = {
  3107. * { .max = 1, .types = BIT(NL80211_IFTYPE_STATION), },
  3108. * { .max = 1, .types = BIT(NL80211_IFTYPE_AP}, },
  3109. * };
  3110. * struct ieee80211_iface_combination combination1 = {
  3111. * .limits = limits1,
  3112. * .n_limits = ARRAY_SIZE(limits1),
  3113. * .max_interfaces = 2,
  3114. * .beacon_int_infra_match = true,
  3115. * };
  3116. *
  3117. *
  3118. * 2. Allow #{AP, P2P-GO} <= 8, channels = 1, 8 total:
  3119. *
  3120. * .. code-block:: c
  3121. *
  3122. * struct ieee80211_iface_limit limits2[] = {
  3123. * { .max = 8, .types = BIT(NL80211_IFTYPE_AP) |
  3124. * BIT(NL80211_IFTYPE_P2P_GO), },
  3125. * };
  3126. * struct ieee80211_iface_combination combination2 = {
  3127. * .limits = limits2,
  3128. * .n_limits = ARRAY_SIZE(limits2),
  3129. * .max_interfaces = 8,
  3130. * .num_different_channels = 1,
  3131. * };
  3132. *
  3133. *
  3134. * 3. Allow #STA <= 1, #{P2P-client,P2P-GO} <= 3 on two channels, 4 total.
  3135. *
  3136. * This allows for an infrastructure connection and three P2P connections.
  3137. *
  3138. * .. code-block:: c
  3139. *
  3140. * struct ieee80211_iface_limit limits3[] = {
  3141. * { .max = 1, .types = BIT(NL80211_IFTYPE_STATION), },
  3142. * { .max = 3, .types = BIT(NL80211_IFTYPE_P2P_GO) |
  3143. * BIT(NL80211_IFTYPE_P2P_CLIENT), },
  3144. * };
  3145. * struct ieee80211_iface_combination combination3 = {
  3146. * .limits = limits3,
  3147. * .n_limits = ARRAY_SIZE(limits3),
  3148. * .max_interfaces = 4,
  3149. * .num_different_channels = 2,
  3150. * };
  3151. *
  3152. */
  3153. struct ieee80211_iface_combination {
  3154. /**
  3155. * @limits:
  3156. * limits for the given interface types
  3157. */
  3158. const struct ieee80211_iface_limit *limits;
  3159. /**
  3160. * @num_different_channels:
  3161. * can use up to this many different channels
  3162. */
  3163. u32 num_different_channels;
  3164. /**
  3165. * @max_interfaces:
  3166. * maximum number of interfaces in total allowed in this group
  3167. */
  3168. u16 max_interfaces;
  3169. /**
  3170. * @n_limits:
  3171. * number of limitations
  3172. */
  3173. u8 n_limits;
  3174. /**
  3175. * @beacon_int_infra_match:
  3176. * In this combination, the beacon intervals between infrastructure
  3177. * and AP types must match. This is required only in special cases.
  3178. */
  3179. bool beacon_int_infra_match;
  3180. /**
  3181. * @radar_detect_widths:
  3182. * bitmap of channel widths supported for radar detection
  3183. */
  3184. u8 radar_detect_widths;
  3185. /**
  3186. * @radar_detect_regions:
  3187. * bitmap of regions supported for radar detection
  3188. */
  3189. u8 radar_detect_regions;
  3190. /**
  3191. * @beacon_int_min_gcd:
  3192. * This interface combination supports different beacon intervals.
  3193. *
  3194. * = 0
  3195. * all beacon intervals for different interface must be same.
  3196. * > 0
  3197. * any beacon interval for the interface part of this combination AND
  3198. * GCD of all beacon intervals from beaconing interfaces of this
  3199. * combination must be greater or equal to this value.
  3200. */
  3201. u32 beacon_int_min_gcd;
  3202. };
  3203. struct ieee80211_txrx_stypes {
  3204. u16 tx, rx;
  3205. };
  3206. /**
  3207. * enum wiphy_wowlan_support_flags - WoWLAN support flags
  3208. * @WIPHY_WOWLAN_ANY: supports wakeup for the special "any"
  3209. * trigger that keeps the device operating as-is and
  3210. * wakes up the host on any activity, for example a
  3211. * received packet that passed filtering; note that the
  3212. * packet should be preserved in that case
  3213. * @WIPHY_WOWLAN_MAGIC_PKT: supports wakeup on magic packet
  3214. * (see nl80211.h)
  3215. * @WIPHY_WOWLAN_DISCONNECT: supports wakeup on disconnect
  3216. * @WIPHY_WOWLAN_SUPPORTS_GTK_REKEY: supports GTK rekeying while asleep
  3217. * @WIPHY_WOWLAN_GTK_REKEY_FAILURE: supports wakeup on GTK rekey failure
  3218. * @WIPHY_WOWLAN_EAP_IDENTITY_REQ: supports wakeup on EAP identity request
  3219. * @WIPHY_WOWLAN_4WAY_HANDSHAKE: supports wakeup on 4-way handshake failure
  3220. * @WIPHY_WOWLAN_RFKILL_RELEASE: supports wakeup on RF-kill release
  3221. * @WIPHY_WOWLAN_NET_DETECT: supports wakeup on network detection
  3222. */
  3223. enum wiphy_wowlan_support_flags {
  3224. WIPHY_WOWLAN_ANY = BIT(0),
  3225. WIPHY_WOWLAN_MAGIC_PKT = BIT(1),
  3226. WIPHY_WOWLAN_DISCONNECT = BIT(2),
  3227. WIPHY_WOWLAN_SUPPORTS_GTK_REKEY = BIT(3),
  3228. WIPHY_WOWLAN_GTK_REKEY_FAILURE = BIT(4),
  3229. WIPHY_WOWLAN_EAP_IDENTITY_REQ = BIT(5),
  3230. WIPHY_WOWLAN_4WAY_HANDSHAKE = BIT(6),
  3231. WIPHY_WOWLAN_RFKILL_RELEASE = BIT(7),
  3232. WIPHY_WOWLAN_NET_DETECT = BIT(8),
  3233. };
  3234. struct wiphy_wowlan_tcp_support {
  3235. const struct nl80211_wowlan_tcp_data_token_feature *tok;
  3236. u32 data_payload_max;
  3237. u32 data_interval_max;
  3238. u32 wake_payload_max;
  3239. bool seq;
  3240. };
  3241. /**
  3242. * struct wiphy_wowlan_support - WoWLAN support data
  3243. * @flags: see &enum wiphy_wowlan_support_flags
  3244. * @n_patterns: number of supported wakeup patterns
  3245. * (see nl80211.h for the pattern definition)
  3246. * @pattern_max_len: maximum length of each pattern
  3247. * @pattern_min_len: minimum length of each pattern
  3248. * @max_pkt_offset: maximum Rx packet offset
  3249. * @max_nd_match_sets: maximum number of matchsets for net-detect,
  3250. * similar, but not necessarily identical, to max_match_sets for
  3251. * scheduled scans.
  3252. * See &struct cfg80211_sched_scan_request.@match_sets for more
  3253. * details.
  3254. * @tcp: TCP wakeup support information
  3255. */
  3256. struct wiphy_wowlan_support {
  3257. u32 flags;
  3258. int n_patterns;
  3259. int pattern_max_len;
  3260. int pattern_min_len;
  3261. int max_pkt_offset;
  3262. int max_nd_match_sets;
  3263. const struct wiphy_wowlan_tcp_support *tcp;
  3264. };
  3265. /**
  3266. * struct wiphy_coalesce_support - coalesce support data
  3267. * @n_rules: maximum number of coalesce rules
  3268. * @max_delay: maximum supported coalescing delay in msecs
  3269. * @n_patterns: number of supported patterns in a rule
  3270. * (see nl80211.h for the pattern definition)
  3271. * @pattern_max_len: maximum length of each pattern
  3272. * @pattern_min_len: minimum length of each pattern
  3273. * @max_pkt_offset: maximum Rx packet offset
  3274. */
  3275. struct wiphy_coalesce_support {
  3276. int n_rules;
  3277. int max_delay;
  3278. int n_patterns;
  3279. int pattern_max_len;
  3280. int pattern_min_len;
  3281. int max_pkt_offset;
  3282. };
  3283. /**
  3284. * enum wiphy_vendor_command_flags - validation flags for vendor commands
  3285. * @WIPHY_VENDOR_CMD_NEED_WDEV: vendor command requires wdev
  3286. * @WIPHY_VENDOR_CMD_NEED_NETDEV: vendor command requires netdev
  3287. * @WIPHY_VENDOR_CMD_NEED_RUNNING: interface/wdev must be up & running
  3288. * (must be combined with %_WDEV or %_NETDEV)
  3289. */
  3290. enum wiphy_vendor_command_flags {
  3291. WIPHY_VENDOR_CMD_NEED_WDEV = BIT(0),
  3292. WIPHY_VENDOR_CMD_NEED_NETDEV = BIT(1),
  3293. WIPHY_VENDOR_CMD_NEED_RUNNING = BIT(2),
  3294. };
  3295. /**
  3296. * struct wiphy_vendor_command - vendor command definition
  3297. * @info: vendor command identifying information, as used in nl80211
  3298. * @flags: flags, see &enum wiphy_vendor_command_flags
  3299. * @doit: callback for the operation, note that wdev is %NULL if the
  3300. * flags didn't ask for a wdev and non-%NULL otherwise; the data
  3301. * pointer may be %NULL if userspace provided no data at all
  3302. * @dumpit: dump callback, for transferring bigger/multiple items. The
  3303. * @storage points to cb->args[5], ie. is preserved over the multiple
  3304. * dumpit calls.
  3305. * It's recommended to not have the same sub command with both @doit and
  3306. * @dumpit, so that userspace can assume certain ones are get and others
  3307. * are used with dump requests.
  3308. */
  3309. struct wiphy_vendor_command {
  3310. struct nl80211_vendor_cmd_info info;
  3311. u32 flags;
  3312. int (*doit)(struct wiphy *wiphy, struct wireless_dev *wdev,
  3313. const void *data, int data_len);
  3314. int (*dumpit)(struct wiphy *wiphy, struct wireless_dev *wdev,
  3315. struct sk_buff *skb, const void *data, int data_len,
  3316. unsigned long *storage);
  3317. };
  3318. /**
  3319. * struct wiphy_iftype_ext_capab - extended capabilities per interface type
  3320. * @iftype: interface type
  3321. * @extended_capabilities: extended capabilities supported by the driver,
  3322. * additional capabilities might be supported by userspace; these are the
  3323. * 802.11 extended capabilities ("Extended Capabilities element") and are
  3324. * in the same format as in the information element. See IEEE Std
  3325. * 802.11-2012 8.4.2.29 for the defined fields.
  3326. * @extended_capabilities_mask: mask of the valid values
  3327. * @extended_capabilities_len: length of the extended capabilities
  3328. */
  3329. struct wiphy_iftype_ext_capab {
  3330. enum nl80211_iftype iftype;
  3331. const u8 *extended_capabilities;
  3332. const u8 *extended_capabilities_mask;
  3333. u8 extended_capabilities_len;
  3334. };
  3335. /**
  3336. * struct wiphy - wireless hardware description
  3337. * @reg_notifier: the driver's regulatory notification callback,
  3338. * note that if your driver uses wiphy_apply_custom_regulatory()
  3339. * the reg_notifier's request can be passed as NULL
  3340. * @regd: the driver's regulatory domain, if one was requested via
  3341. * the regulatory_hint() API. This can be used by the driver
  3342. * on the reg_notifier() if it chooses to ignore future
  3343. * regulatory domain changes caused by other drivers.
  3344. * @signal_type: signal type reported in &struct cfg80211_bss.
  3345. * @cipher_suites: supported cipher suites
  3346. * @n_cipher_suites: number of supported cipher suites
  3347. * @retry_short: Retry limit for short frames (dot11ShortRetryLimit)
  3348. * @retry_long: Retry limit for long frames (dot11LongRetryLimit)
  3349. * @frag_threshold: Fragmentation threshold (dot11FragmentationThreshold);
  3350. * -1 = fragmentation disabled, only odd values >= 256 used
  3351. * @rts_threshold: RTS threshold (dot11RTSThreshold); -1 = RTS/CTS disabled
  3352. * @_net: the network namespace this wiphy currently lives in
  3353. * @perm_addr: permanent MAC address of this device
  3354. * @addr_mask: If the device supports multiple MAC addresses by masking,
  3355. * set this to a mask with variable bits set to 1, e.g. if the last
  3356. * four bits are variable then set it to 00-00-00-00-00-0f. The actual
  3357. * variable bits shall be determined by the interfaces added, with
  3358. * interfaces not matching the mask being rejected to be brought up.
  3359. * @n_addresses: number of addresses in @addresses.
  3360. * @addresses: If the device has more than one address, set this pointer
  3361. * to a list of addresses (6 bytes each). The first one will be used
  3362. * by default for perm_addr. In this case, the mask should be set to
  3363. * all-zeroes. In this case it is assumed that the device can handle
  3364. * the same number of arbitrary MAC addresses.
  3365. * @registered: protects ->resume and ->suspend sysfs callbacks against
  3366. * unregister hardware
  3367. * @debugfsdir: debugfs directory used for this wiphy, will be renamed
  3368. * automatically on wiphy renames
  3369. * @dev: (virtual) struct device for this wiphy
  3370. * @registered: helps synchronize suspend/resume with wiphy unregister
  3371. * @wext: wireless extension handlers
  3372. * @priv: driver private data (sized according to wiphy_new() parameter)
  3373. * @interface_modes: bitmask of interfaces types valid for this wiphy,
  3374. * must be set by driver
  3375. * @iface_combinations: Valid interface combinations array, should not
  3376. * list single interface types.
  3377. * @n_iface_combinations: number of entries in @iface_combinations array.
  3378. * @software_iftypes: bitmask of software interface types, these are not
  3379. * subject to any restrictions since they are purely managed in SW.
  3380. * @flags: wiphy flags, see &enum wiphy_flags
  3381. * @regulatory_flags: wiphy regulatory flags, see
  3382. * &enum ieee80211_regulatory_flags
  3383. * @features: features advertised to nl80211, see &enum nl80211_feature_flags.
  3384. * @ext_features: extended features advertised to nl80211, see
  3385. * &enum nl80211_ext_feature_index.
  3386. * @bss_priv_size: each BSS struct has private data allocated with it,
  3387. * this variable determines its size
  3388. * @max_scan_ssids: maximum number of SSIDs the device can scan for in
  3389. * any given scan
  3390. * @max_sched_scan_reqs: maximum number of scheduled scan requests that
  3391. * the device can run concurrently.
  3392. * @max_sched_scan_ssids: maximum number of SSIDs the device can scan
  3393. * for in any given scheduled scan
  3394. * @max_match_sets: maximum number of match sets the device can handle
  3395. * when performing a scheduled scan, 0 if filtering is not
  3396. * supported.
  3397. * @max_scan_ie_len: maximum length of user-controlled IEs device can
  3398. * add to probe request frames transmitted during a scan, must not
  3399. * include fixed IEs like supported rates
  3400. * @max_sched_scan_ie_len: same as max_scan_ie_len, but for scheduled
  3401. * scans
  3402. * @max_sched_scan_plans: maximum number of scan plans (scan interval and number
  3403. * of iterations) for scheduled scan supported by the device.
  3404. * @max_sched_scan_plan_interval: maximum interval (in seconds) for a
  3405. * single scan plan supported by the device.
  3406. * @max_sched_scan_plan_iterations: maximum number of iterations for a single
  3407. * scan plan supported by the device.
  3408. * @coverage_class: current coverage class
  3409. * @fw_version: firmware version for ethtool reporting
  3410. * @hw_version: hardware version for ethtool reporting
  3411. * @max_num_pmkids: maximum number of PMKIDs supported by device
  3412. * @privid: a pointer that drivers can use to identify if an arbitrary
  3413. * wiphy is theirs, e.g. in global notifiers
  3414. * @bands: information about bands/channels supported by this device
  3415. *
  3416. * @mgmt_stypes: bitmasks of frame subtypes that can be subscribed to or
  3417. * transmitted through nl80211, points to an array indexed by interface
  3418. * type
  3419. *
  3420. * @available_antennas_tx: bitmap of antennas which are available to be
  3421. * configured as TX antennas. Antenna configuration commands will be
  3422. * rejected unless this or @available_antennas_rx is set.
  3423. *
  3424. * @available_antennas_rx: bitmap of antennas which are available to be
  3425. * configured as RX antennas. Antenna configuration commands will be
  3426. * rejected unless this or @available_antennas_tx is set.
  3427. *
  3428. * @probe_resp_offload:
  3429. * Bitmap of supported protocols for probe response offloading.
  3430. * See &enum nl80211_probe_resp_offload_support_attr. Only valid
  3431. * when the wiphy flag @WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD is set.
  3432. *
  3433. * @max_remain_on_channel_duration: Maximum time a remain-on-channel operation
  3434. * may request, if implemented.
  3435. *
  3436. * @wowlan: WoWLAN support information
  3437. * @wowlan_config: current WoWLAN configuration; this should usually not be
  3438. * used since access to it is necessarily racy, use the parameter passed
  3439. * to the suspend() operation instead.
  3440. *
  3441. * @ap_sme_capa: AP SME capabilities, flags from &enum nl80211_ap_sme_features.
  3442. * @ht_capa_mod_mask: Specify what ht_cap values can be over-ridden.
  3443. * If null, then none can be over-ridden.
  3444. * @vht_capa_mod_mask: Specify what VHT capabilities can be over-ridden.
  3445. * If null, then none can be over-ridden.
  3446. *
  3447. * @wdev_list: the list of associated (virtual) interfaces; this list must
  3448. * not be modified by the driver, but can be read with RTNL/RCU protection.
  3449. *
  3450. * @max_acl_mac_addrs: Maximum number of MAC addresses that the device
  3451. * supports for ACL.
  3452. *
  3453. * @extended_capabilities: extended capabilities supported by the driver,
  3454. * additional capabilities might be supported by userspace; these are
  3455. * the 802.11 extended capabilities ("Extended Capabilities element")
  3456. * and are in the same format as in the information element. See
  3457. * 802.11-2012 8.4.2.29 for the defined fields. These are the default
  3458. * extended capabilities to be used if the capabilities are not specified
  3459. * for a specific interface type in iftype_ext_capab.
  3460. * @extended_capabilities_mask: mask of the valid values
  3461. * @extended_capabilities_len: length of the extended capabilities
  3462. * @iftype_ext_capab: array of extended capabilities per interface type
  3463. * @num_iftype_ext_capab: number of interface types for which extended
  3464. * capabilities are specified separately.
  3465. * @coalesce: packet coalescing support information
  3466. *
  3467. * @vendor_commands: array of vendor commands supported by the hardware
  3468. * @n_vendor_commands: number of vendor commands
  3469. * @vendor_events: array of vendor events supported by the hardware
  3470. * @n_vendor_events: number of vendor events
  3471. *
  3472. * @max_ap_assoc_sta: maximum number of associated stations supported in AP mode
  3473. * (including P2P GO) or 0 to indicate no such limit is advertised. The
  3474. * driver is allowed to advertise a theoretical limit that it can reach in
  3475. * some cases, but may not always reach.
  3476. *
  3477. * @max_num_csa_counters: Number of supported csa_counters in beacons
  3478. * and probe responses. This value should be set if the driver
  3479. * wishes to limit the number of csa counters. Default (0) means
  3480. * infinite.
  3481. * @max_adj_channel_rssi_comp: max offset of between the channel on which the
  3482. * frame was sent and the channel on which the frame was heard for which
  3483. * the reported rssi is still valid. If a driver is able to compensate the
  3484. * low rssi when a frame is heard on different channel, then it should set
  3485. * this variable to the maximal offset for which it can compensate.
  3486. * This value should be set in MHz.
  3487. * @bss_select_support: bitmask indicating the BSS selection criteria supported
  3488. * by the driver in the .connect() callback. The bit position maps to the
  3489. * attribute indices defined in &enum nl80211_bss_select_attr.
  3490. *
  3491. * @cookie_counter: unique generic cookie counter, used to identify objects.
  3492. * @nan_supported_bands: bands supported by the device in NAN mode, a
  3493. * bitmap of &enum nl80211_band values. For instance, for
  3494. * NL80211_BAND_2GHZ, bit 0 would be set
  3495. * (i.e. BIT(NL80211_BAND_2GHZ)).
  3496. */
  3497. struct wiphy {
  3498. /* assign these fields before you register the wiphy */
  3499. /* permanent MAC address(es) */
  3500. u8 perm_addr[ETH_ALEN];
  3501. u8 addr_mask[ETH_ALEN];
  3502. struct mac_address *addresses;
  3503. const struct ieee80211_txrx_stypes *mgmt_stypes;
  3504. const struct ieee80211_iface_combination *iface_combinations;
  3505. int n_iface_combinations;
  3506. u16 software_iftypes;
  3507. u16 n_addresses;
  3508. /* Supported interface modes, OR together BIT(NL80211_IFTYPE_...) */
  3509. u16 interface_modes;
  3510. u16 max_acl_mac_addrs;
  3511. u32 flags, regulatory_flags, features;
  3512. u8 ext_features[DIV_ROUND_UP(NUM_NL80211_EXT_FEATURES, 8)];
  3513. u32 ap_sme_capa;
  3514. enum cfg80211_signal_type signal_type;
  3515. int bss_priv_size;
  3516. u8 max_scan_ssids;
  3517. u8 max_sched_scan_reqs;
  3518. u8 max_sched_scan_ssids;
  3519. u8 max_match_sets;
  3520. u16 max_scan_ie_len;
  3521. u16 max_sched_scan_ie_len;
  3522. u32 max_sched_scan_plans;
  3523. u32 max_sched_scan_plan_interval;
  3524. u32 max_sched_scan_plan_iterations;
  3525. int n_cipher_suites;
  3526. const u32 *cipher_suites;
  3527. u8 retry_short;
  3528. u8 retry_long;
  3529. u32 frag_threshold;
  3530. u32 rts_threshold;
  3531. u8 coverage_class;
  3532. char fw_version[ETHTOOL_FWVERS_LEN];
  3533. u32 hw_version;
  3534. #ifdef CONFIG_PM
  3535. const struct wiphy_wowlan_support *wowlan;
  3536. struct cfg80211_wowlan *wowlan_config;
  3537. #endif
  3538. u16 max_remain_on_channel_duration;
  3539. u8 max_num_pmkids;
  3540. u32 available_antennas_tx;
  3541. u32 available_antennas_rx;
  3542. /*
  3543. * Bitmap of supported protocols for probe response offloading
  3544. * see &enum nl80211_probe_resp_offload_support_attr. Only valid
  3545. * when the wiphy flag @WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD is set.
  3546. */
  3547. u32 probe_resp_offload;
  3548. const u8 *extended_capabilities, *extended_capabilities_mask;
  3549. u8 extended_capabilities_len;
  3550. const struct wiphy_iftype_ext_capab *iftype_ext_capab;
  3551. unsigned int num_iftype_ext_capab;
  3552. /* If multiple wiphys are registered and you're handed e.g.
  3553. * a regular netdev with assigned ieee80211_ptr, you won't
  3554. * know whether it points to a wiphy your driver has registered
  3555. * or not. Assign this to something global to your driver to
  3556. * help determine whether you own this wiphy or not. */
  3557. const void *privid;
  3558. struct ieee80211_supported_band *bands[NUM_NL80211_BANDS];
  3559. /* Lets us get back the wiphy on the callback */
  3560. void (*reg_notifier)(struct wiphy *wiphy,
  3561. struct regulatory_request *request);
  3562. /* fields below are read-only, assigned by cfg80211 */
  3563. const struct ieee80211_regdomain __rcu *regd;
  3564. /* the item in /sys/class/ieee80211/ points to this,
  3565. * you need use set_wiphy_dev() (see below) */
  3566. struct device dev;
  3567. /* protects ->resume, ->suspend sysfs callbacks against unregister hw */
  3568. bool registered;
  3569. /* dir in debugfs: ieee80211/<wiphyname> */
  3570. struct dentry *debugfsdir;
  3571. const struct ieee80211_ht_cap *ht_capa_mod_mask;
  3572. const struct ieee80211_vht_cap *vht_capa_mod_mask;
  3573. struct list_head wdev_list;
  3574. /* the network namespace this phy lives in currently */
  3575. possible_net_t _net;
  3576. #ifdef CONFIG_CFG80211_WEXT
  3577. const struct iw_handler_def *wext;
  3578. #endif
  3579. const struct wiphy_coalesce_support *coalesce;
  3580. const struct wiphy_vendor_command *vendor_commands;
  3581. const struct nl80211_vendor_cmd_info *vendor_events;
  3582. int n_vendor_commands, n_vendor_events;
  3583. u16 max_ap_assoc_sta;
  3584. u8 max_num_csa_counters;
  3585. u8 max_adj_channel_rssi_comp;
  3586. u32 bss_select_support;
  3587. u64 cookie_counter;
  3588. u8 nan_supported_bands;
  3589. char priv[0] __aligned(NETDEV_ALIGN);
  3590. };
  3591. static inline struct net *wiphy_net(struct wiphy *wiphy)
  3592. {
  3593. return read_pnet(&wiphy->_net);
  3594. }
  3595. static inline void wiphy_net_set(struct wiphy *wiphy, struct net *net)
  3596. {
  3597. write_pnet(&wiphy->_net, net);
  3598. }
  3599. /**
  3600. * wiphy_priv - return priv from wiphy
  3601. *
  3602. * @wiphy: the wiphy whose priv pointer to return
  3603. * Return: The priv of @wiphy.
  3604. */
  3605. static inline void *wiphy_priv(struct wiphy *wiphy)
  3606. {
  3607. BUG_ON(!wiphy);
  3608. return &wiphy->priv;
  3609. }
  3610. /**
  3611. * priv_to_wiphy - return the wiphy containing the priv
  3612. *
  3613. * @priv: a pointer previously returned by wiphy_priv
  3614. * Return: The wiphy of @priv.
  3615. */
  3616. static inline struct wiphy *priv_to_wiphy(void *priv)
  3617. {
  3618. BUG_ON(!priv);
  3619. return container_of(priv, struct wiphy, priv);
  3620. }
  3621. /**
  3622. * set_wiphy_dev - set device pointer for wiphy
  3623. *
  3624. * @wiphy: The wiphy whose device to bind
  3625. * @dev: The device to parent it to
  3626. */
  3627. static inline void set_wiphy_dev(struct wiphy *wiphy, struct device *dev)
  3628. {
  3629. wiphy->dev.parent = dev;
  3630. }
  3631. /**
  3632. * wiphy_dev - get wiphy dev pointer
  3633. *
  3634. * @wiphy: The wiphy whose device struct to look up
  3635. * Return: The dev of @wiphy.
  3636. */
  3637. static inline struct device *wiphy_dev(struct wiphy *wiphy)
  3638. {
  3639. return wiphy->dev.parent;
  3640. }
  3641. /**
  3642. * wiphy_name - get wiphy name
  3643. *
  3644. * @wiphy: The wiphy whose name to return
  3645. * Return: The name of @wiphy.
  3646. */
  3647. static inline const char *wiphy_name(const struct wiphy *wiphy)
  3648. {
  3649. return dev_name(&wiphy->dev);
  3650. }
  3651. /**
  3652. * wiphy_new_nm - create a new wiphy for use with cfg80211
  3653. *
  3654. * @ops: The configuration operations for this device
  3655. * @sizeof_priv: The size of the private area to allocate
  3656. * @requested_name: Request a particular name.
  3657. * NULL is valid value, and means use the default phy%d naming.
  3658. *
  3659. * Create a new wiphy and associate the given operations with it.
  3660. * @sizeof_priv bytes are allocated for private use.
  3661. *
  3662. * Return: A pointer to the new wiphy. This pointer must be
  3663. * assigned to each netdev's ieee80211_ptr for proper operation.
  3664. */
  3665. struct wiphy *wiphy_new_nm(const struct cfg80211_ops *ops, int sizeof_priv,
  3666. const char *requested_name);
  3667. /**
  3668. * wiphy_new - create a new wiphy for use with cfg80211
  3669. *
  3670. * @ops: The configuration operations for this device
  3671. * @sizeof_priv: The size of the private area to allocate
  3672. *
  3673. * Create a new wiphy and associate the given operations with it.
  3674. * @sizeof_priv bytes are allocated for private use.
  3675. *
  3676. * Return: A pointer to the new wiphy. This pointer must be
  3677. * assigned to each netdev's ieee80211_ptr for proper operation.
  3678. */
  3679. static inline struct wiphy *wiphy_new(const struct cfg80211_ops *ops,
  3680. int sizeof_priv)
  3681. {
  3682. return wiphy_new_nm(ops, sizeof_priv, NULL);
  3683. }
  3684. /**
  3685. * wiphy_register - register a wiphy with cfg80211
  3686. *
  3687. * @wiphy: The wiphy to register.
  3688. *
  3689. * Return: A non-negative wiphy index or a negative error code.
  3690. */
  3691. int wiphy_register(struct wiphy *wiphy);
  3692. /**
  3693. * wiphy_unregister - deregister a wiphy from cfg80211
  3694. *
  3695. * @wiphy: The wiphy to unregister.
  3696. *
  3697. * After this call, no more requests can be made with this priv
  3698. * pointer, but the call may sleep to wait for an outstanding
  3699. * request that is being handled.
  3700. */
  3701. void wiphy_unregister(struct wiphy *wiphy);
  3702. /**
  3703. * wiphy_free - free wiphy
  3704. *
  3705. * @wiphy: The wiphy to free
  3706. */
  3707. void wiphy_free(struct wiphy *wiphy);
  3708. /* internal structs */
  3709. struct cfg80211_conn;
  3710. struct cfg80211_internal_bss;
  3711. struct cfg80211_cached_keys;
  3712. struct cfg80211_cqm_config;
  3713. /**
  3714. * struct wireless_dev - wireless device state
  3715. *
  3716. * For netdevs, this structure must be allocated by the driver
  3717. * that uses the ieee80211_ptr field in struct net_device (this
  3718. * is intentional so it can be allocated along with the netdev.)
  3719. * It need not be registered then as netdev registration will
  3720. * be intercepted by cfg80211 to see the new wireless device.
  3721. *
  3722. * For non-netdev uses, it must also be allocated by the driver
  3723. * in response to the cfg80211 callbacks that require it, as
  3724. * there's no netdev registration in that case it may not be
  3725. * allocated outside of callback operations that return it.
  3726. *
  3727. * @wiphy: pointer to hardware description
  3728. * @iftype: interface type
  3729. * @list: (private) Used to collect the interfaces
  3730. * @netdev: (private) Used to reference back to the netdev, may be %NULL
  3731. * @identifier: (private) Identifier used in nl80211 to identify this
  3732. * wireless device if it has no netdev
  3733. * @current_bss: (private) Used by the internal configuration code
  3734. * @chandef: (private) Used by the internal configuration code to track
  3735. * the user-set channel definition.
  3736. * @preset_chandef: (private) Used by the internal configuration code to
  3737. * track the channel to be used for AP later
  3738. * @bssid: (private) Used by the internal configuration code
  3739. * @ssid: (private) Used by the internal configuration code
  3740. * @ssid_len: (private) Used by the internal configuration code
  3741. * @mesh_id_len: (private) Used by the internal configuration code
  3742. * @mesh_id_up_len: (private) Used by the internal configuration code
  3743. * @wext: (private) Used by the internal wireless extensions compat code
  3744. * @use_4addr: indicates 4addr mode is used on this interface, must be
  3745. * set by driver (if supported) on add_interface BEFORE registering the
  3746. * netdev and may otherwise be used by driver read-only, will be update
  3747. * by cfg80211 on change_interface
  3748. * @mgmt_registrations: list of registrations for management frames
  3749. * @mgmt_registrations_lock: lock for the list
  3750. * @mtx: mutex used to lock data in this struct, may be used by drivers
  3751. * and some API functions require it held
  3752. * @beacon_interval: beacon interval used on this device for transmitting
  3753. * beacons, 0 when not valid
  3754. * @address: The address for this device, valid only if @netdev is %NULL
  3755. * @is_running: true if this is a non-netdev device that has been started, e.g.
  3756. * the P2P Device.
  3757. * @cac_started: true if DFS channel availability check has been started
  3758. * @cac_start_time: timestamp (jiffies) when the dfs state was entered.
  3759. * @cac_time_ms: CAC time in ms
  3760. * @ps: powersave mode is enabled
  3761. * @ps_timeout: dynamic powersave timeout
  3762. * @ap_unexpected_nlportid: (private) netlink port ID of application
  3763. * registered for unexpected class 3 frames (AP mode)
  3764. * @conn: (private) cfg80211 software SME connection state machine data
  3765. * @connect_keys: (private) keys to set after connection is established
  3766. * @conn_bss_type: connecting/connected BSS type
  3767. * @conn_owner_nlportid: (private) connection owner socket port ID
  3768. * @disconnect_wk: (private) auto-disconnect work
  3769. * @disconnect_bssid: (private) the BSSID to use for auto-disconnect
  3770. * @ibss_fixed: (private) IBSS is using fixed BSSID
  3771. * @ibss_dfs_possible: (private) IBSS may change to a DFS channel
  3772. * @event_list: (private) list for internal event processing
  3773. * @event_lock: (private) lock for event list
  3774. * @owner_nlportid: (private) owner socket port ID
  3775. * @nl_owner_dead: (private) owner socket went away
  3776. * @cqm_config: (private) nl80211 RSSI monitor state
  3777. */
  3778. struct wireless_dev {
  3779. struct wiphy *wiphy;
  3780. enum nl80211_iftype iftype;
  3781. /* the remainder of this struct should be private to cfg80211 */
  3782. struct list_head list;
  3783. struct net_device *netdev;
  3784. u32 identifier;
  3785. struct list_head mgmt_registrations;
  3786. spinlock_t mgmt_registrations_lock;
  3787. struct mutex mtx;
  3788. bool use_4addr, is_running;
  3789. u8 address[ETH_ALEN] __aligned(sizeof(u16));
  3790. /* currently used for IBSS and SME - might be rearranged later */
  3791. u8 ssid[IEEE80211_MAX_SSID_LEN];
  3792. u8 ssid_len, mesh_id_len, mesh_id_up_len;
  3793. struct cfg80211_conn *conn;
  3794. struct cfg80211_cached_keys *connect_keys;
  3795. enum ieee80211_bss_type conn_bss_type;
  3796. u32 conn_owner_nlportid;
  3797. struct work_struct disconnect_wk;
  3798. u8 disconnect_bssid[ETH_ALEN];
  3799. struct list_head event_list;
  3800. spinlock_t event_lock;
  3801. struct cfg80211_internal_bss *current_bss; /* associated / joined */
  3802. struct cfg80211_chan_def preset_chandef;
  3803. struct cfg80211_chan_def chandef;
  3804. bool ibss_fixed;
  3805. bool ibss_dfs_possible;
  3806. bool ps;
  3807. int ps_timeout;
  3808. int beacon_interval;
  3809. u32 ap_unexpected_nlportid;
  3810. u32 owner_nlportid;
  3811. bool nl_owner_dead;
  3812. bool cac_started;
  3813. unsigned long cac_start_time;
  3814. unsigned int cac_time_ms;
  3815. #ifdef CONFIG_CFG80211_WEXT
  3816. /* wext data */
  3817. struct {
  3818. struct cfg80211_ibss_params ibss;
  3819. struct cfg80211_connect_params connect;
  3820. struct cfg80211_cached_keys *keys;
  3821. const u8 *ie;
  3822. size_t ie_len;
  3823. u8 bssid[ETH_ALEN], prev_bssid[ETH_ALEN];
  3824. u8 ssid[IEEE80211_MAX_SSID_LEN];
  3825. s8 default_key, default_mgmt_key;
  3826. bool prev_bssid_valid;
  3827. } wext;
  3828. #endif
  3829. struct cfg80211_cqm_config *cqm_config;
  3830. };
  3831. static inline u8 *wdev_address(struct wireless_dev *wdev)
  3832. {
  3833. if (wdev->netdev)
  3834. return wdev->netdev->dev_addr;
  3835. return wdev->address;
  3836. }
  3837. static inline bool wdev_running(struct wireless_dev *wdev)
  3838. {
  3839. if (wdev->netdev)
  3840. return netif_running(wdev->netdev);
  3841. return wdev->is_running;
  3842. }
  3843. /**
  3844. * wdev_priv - return wiphy priv from wireless_dev
  3845. *
  3846. * @wdev: The wireless device whose wiphy's priv pointer to return
  3847. * Return: The wiphy priv of @wdev.
  3848. */
  3849. static inline void *wdev_priv(struct wireless_dev *wdev)
  3850. {
  3851. BUG_ON(!wdev);
  3852. return wiphy_priv(wdev->wiphy);
  3853. }
  3854. /**
  3855. * DOC: Utility functions
  3856. *
  3857. * cfg80211 offers a number of utility functions that can be useful.
  3858. */
  3859. /**
  3860. * ieee80211_channel_to_frequency - convert channel number to frequency
  3861. * @chan: channel number
  3862. * @band: band, necessary due to channel number overlap
  3863. * Return: The corresponding frequency (in MHz), or 0 if the conversion failed.
  3864. */
  3865. int ieee80211_channel_to_frequency(int chan, enum nl80211_band band);
  3866. /**
  3867. * ieee80211_frequency_to_channel - convert frequency to channel number
  3868. * @freq: center frequency
  3869. * Return: The corresponding channel, or 0 if the conversion failed.
  3870. */
  3871. int ieee80211_frequency_to_channel(int freq);
  3872. /**
  3873. * ieee80211_get_channel - get channel struct from wiphy for specified frequency
  3874. *
  3875. * @wiphy: the struct wiphy to get the channel for
  3876. * @freq: the center frequency of the channel
  3877. *
  3878. * Return: The channel struct from @wiphy at @freq.
  3879. */
  3880. struct ieee80211_channel *ieee80211_get_channel(struct wiphy *wiphy, int freq);
  3881. /**
  3882. * ieee80211_get_response_rate - get basic rate for a given rate
  3883. *
  3884. * @sband: the band to look for rates in
  3885. * @basic_rates: bitmap of basic rates
  3886. * @bitrate: the bitrate for which to find the basic rate
  3887. *
  3888. * Return: The basic rate corresponding to a given bitrate, that
  3889. * is the next lower bitrate contained in the basic rate map,
  3890. * which is, for this function, given as a bitmap of indices of
  3891. * rates in the band's bitrate table.
  3892. */
  3893. struct ieee80211_rate *
  3894. ieee80211_get_response_rate(struct ieee80211_supported_band *sband,
  3895. u32 basic_rates, int bitrate);
  3896. /**
  3897. * ieee80211_mandatory_rates - get mandatory rates for a given band
  3898. * @sband: the band to look for rates in
  3899. * @scan_width: width of the control channel
  3900. *
  3901. * This function returns a bitmap of the mandatory rates for the given
  3902. * band, bits are set according to the rate position in the bitrates array.
  3903. */
  3904. u32 ieee80211_mandatory_rates(struct ieee80211_supported_band *sband,
  3905. enum nl80211_bss_scan_width scan_width);
  3906. /*
  3907. * Radiotap parsing functions -- for controlled injection support
  3908. *
  3909. * Implemented in net/wireless/radiotap.c
  3910. * Documentation in Documentation/networking/radiotap-headers.txt
  3911. */
  3912. struct radiotap_align_size {
  3913. uint8_t align:4, size:4;
  3914. };
  3915. struct ieee80211_radiotap_namespace {
  3916. const struct radiotap_align_size *align_size;
  3917. int n_bits;
  3918. uint32_t oui;
  3919. uint8_t subns;
  3920. };
  3921. struct ieee80211_radiotap_vendor_namespaces {
  3922. const struct ieee80211_radiotap_namespace *ns;
  3923. int n_ns;
  3924. };
  3925. /**
  3926. * struct ieee80211_radiotap_iterator - tracks walk thru present radiotap args
  3927. * @this_arg_index: index of current arg, valid after each successful call
  3928. * to ieee80211_radiotap_iterator_next()
  3929. * @this_arg: pointer to current radiotap arg; it is valid after each
  3930. * call to ieee80211_radiotap_iterator_next() but also after
  3931. * ieee80211_radiotap_iterator_init() where it will point to
  3932. * the beginning of the actual data portion
  3933. * @this_arg_size: length of the current arg, for convenience
  3934. * @current_namespace: pointer to the current namespace definition
  3935. * (or internally %NULL if the current namespace is unknown)
  3936. * @is_radiotap_ns: indicates whether the current namespace is the default
  3937. * radiotap namespace or not
  3938. *
  3939. * @_rtheader: pointer to the radiotap header we are walking through
  3940. * @_max_length: length of radiotap header in cpu byte ordering
  3941. * @_arg_index: next argument index
  3942. * @_arg: next argument pointer
  3943. * @_next_bitmap: internal pointer to next present u32
  3944. * @_bitmap_shifter: internal shifter for curr u32 bitmap, b0 set == arg present
  3945. * @_vns: vendor namespace definitions
  3946. * @_next_ns_data: beginning of the next namespace's data
  3947. * @_reset_on_ext: internal; reset the arg index to 0 when going to the
  3948. * next bitmap word
  3949. *
  3950. * Describes the radiotap parser state. Fields prefixed with an underscore
  3951. * must not be used by users of the parser, only by the parser internally.
  3952. */
  3953. struct ieee80211_radiotap_iterator {
  3954. struct ieee80211_radiotap_header *_rtheader;
  3955. const struct ieee80211_radiotap_vendor_namespaces *_vns;
  3956. const struct ieee80211_radiotap_namespace *current_namespace;
  3957. unsigned char *_arg, *_next_ns_data;
  3958. __le32 *_next_bitmap;
  3959. unsigned char *this_arg;
  3960. int this_arg_index;
  3961. int this_arg_size;
  3962. int is_radiotap_ns;
  3963. int _max_length;
  3964. int _arg_index;
  3965. uint32_t _bitmap_shifter;
  3966. int _reset_on_ext;
  3967. };
  3968. int
  3969. ieee80211_radiotap_iterator_init(struct ieee80211_radiotap_iterator *iterator,
  3970. struct ieee80211_radiotap_header *radiotap_header,
  3971. int max_length,
  3972. const struct ieee80211_radiotap_vendor_namespaces *vns);
  3973. int
  3974. ieee80211_radiotap_iterator_next(struct ieee80211_radiotap_iterator *iterator);
  3975. extern const unsigned char rfc1042_header[6];
  3976. extern const unsigned char bridge_tunnel_header[6];
  3977. /**
  3978. * ieee80211_get_hdrlen_from_skb - get header length from data
  3979. *
  3980. * @skb: the frame
  3981. *
  3982. * Given an skb with a raw 802.11 header at the data pointer this function
  3983. * returns the 802.11 header length.
  3984. *
  3985. * Return: The 802.11 header length in bytes (not including encryption
  3986. * headers). Or 0 if the data in the sk_buff is too short to contain a valid
  3987. * 802.11 header.
  3988. */
  3989. unsigned int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb);
  3990. /**
  3991. * ieee80211_hdrlen - get header length in bytes from frame control
  3992. * @fc: frame control field in little-endian format
  3993. * Return: The header length in bytes.
  3994. */
  3995. unsigned int __attribute_const__ ieee80211_hdrlen(__le16 fc);
  3996. /**
  3997. * ieee80211_get_mesh_hdrlen - get mesh extension header length
  3998. * @meshhdr: the mesh extension header, only the flags field
  3999. * (first byte) will be accessed
  4000. * Return: The length of the extension header, which is always at
  4001. * least 6 bytes and at most 18 if address 5 and 6 are present.
  4002. */
  4003. unsigned int ieee80211_get_mesh_hdrlen(struct ieee80211s_hdr *meshhdr);
  4004. /**
  4005. * DOC: Data path helpers
  4006. *
  4007. * In addition to generic utilities, cfg80211 also offers
  4008. * functions that help implement the data path for devices
  4009. * that do not do the 802.11/802.3 conversion on the device.
  4010. */
  4011. /**
  4012. * ieee80211_data_to_8023_exthdr - convert an 802.11 data frame to 802.3
  4013. * @skb: the 802.11 data frame
  4014. * @ehdr: pointer to a &struct ethhdr that will get the header, instead
  4015. * of it being pushed into the SKB
  4016. * @addr: the device MAC address
  4017. * @iftype: the virtual interface type
  4018. * Return: 0 on success. Non-zero on error.
  4019. */
  4020. int ieee80211_data_to_8023_exthdr(struct sk_buff *skb, struct ethhdr *ehdr,
  4021. const u8 *addr, enum nl80211_iftype iftype);
  4022. /**
  4023. * ieee80211_data_to_8023 - convert an 802.11 data frame to 802.3
  4024. * @skb: the 802.11 data frame
  4025. * @addr: the device MAC address
  4026. * @iftype: the virtual interface type
  4027. * Return: 0 on success. Non-zero on error.
  4028. */
  4029. static inline int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr,
  4030. enum nl80211_iftype iftype)
  4031. {
  4032. return ieee80211_data_to_8023_exthdr(skb, NULL, addr, iftype);
  4033. }
  4034. /**
  4035. * ieee80211_amsdu_to_8023s - decode an IEEE 802.11n A-MSDU frame
  4036. *
  4037. * Decode an IEEE 802.11 A-MSDU and convert it to a list of 802.3 frames.
  4038. * The @list will be empty if the decode fails. The @skb must be fully
  4039. * header-less before being passed in here; it is freed in this function.
  4040. *
  4041. * @skb: The input A-MSDU frame without any headers.
  4042. * @list: The output list of 802.3 frames. It must be allocated and
  4043. * initialized by by the caller.
  4044. * @addr: The device MAC address.
  4045. * @iftype: The device interface type.
  4046. * @extra_headroom: The hardware extra headroom for SKBs in the @list.
  4047. * @check_da: DA to check in the inner ethernet header, or NULL
  4048. * @check_sa: SA to check in the inner ethernet header, or NULL
  4049. */
  4050. void ieee80211_amsdu_to_8023s(struct sk_buff *skb, struct sk_buff_head *list,
  4051. const u8 *addr, enum nl80211_iftype iftype,
  4052. const unsigned int extra_headroom,
  4053. const u8 *check_da, const u8 *check_sa);
  4054. /**
  4055. * cfg80211_classify8021d - determine the 802.1p/1d tag for a data frame
  4056. * @skb: the data frame
  4057. * @qos_map: Interworking QoS mapping or %NULL if not in use
  4058. * Return: The 802.1p/1d tag.
  4059. */
  4060. unsigned int cfg80211_classify8021d(struct sk_buff *skb,
  4061. struct cfg80211_qos_map *qos_map);
  4062. /**
  4063. * cfg80211_find_ie_match - match information element and byte array in data
  4064. *
  4065. * @eid: element ID
  4066. * @ies: data consisting of IEs
  4067. * @len: length of data
  4068. * @match: byte array to match
  4069. * @match_len: number of bytes in the match array
  4070. * @match_offset: offset in the IE where the byte array should match.
  4071. * If match_len is zero, this must also be set to zero.
  4072. * Otherwise this must be set to 2 or more, because the first
  4073. * byte is the element id, which is already compared to eid, and
  4074. * the second byte is the IE length.
  4075. *
  4076. * Return: %NULL if the element ID could not be found or if
  4077. * the element is invalid (claims to be longer than the given
  4078. * data) or if the byte array doesn't match, or a pointer to the first
  4079. * byte of the requested element, that is the byte containing the
  4080. * element ID.
  4081. *
  4082. * Note: There are no checks on the element length other than
  4083. * having to fit into the given data and being large enough for the
  4084. * byte array to match.
  4085. */
  4086. const u8 *cfg80211_find_ie_match(u8 eid, const u8 *ies, int len,
  4087. const u8 *match, int match_len,
  4088. int match_offset);
  4089. /**
  4090. * cfg80211_find_ie - find information element in data
  4091. *
  4092. * @eid: element ID
  4093. * @ies: data consisting of IEs
  4094. * @len: length of data
  4095. *
  4096. * Return: %NULL if the element ID could not be found or if
  4097. * the element is invalid (claims to be longer than the given
  4098. * data), or a pointer to the first byte of the requested
  4099. * element, that is the byte containing the element ID.
  4100. *
  4101. * Note: There are no checks on the element length other than
  4102. * having to fit into the given data.
  4103. */
  4104. static inline const u8 *cfg80211_find_ie(u8 eid, const u8 *ies, int len)
  4105. {
  4106. return cfg80211_find_ie_match(eid, ies, len, NULL, 0, 0);
  4107. }
  4108. /**
  4109. * cfg80211_find_ext_ie - find information element with EID Extension in data
  4110. *
  4111. * @ext_eid: element ID Extension
  4112. * @ies: data consisting of IEs
  4113. * @len: length of data
  4114. *
  4115. * Return: %NULL if the extended element ID could not be found or if
  4116. * the element is invalid (claims to be longer than the given
  4117. * data), or a pointer to the first byte of the requested
  4118. * element, that is the byte containing the element ID.
  4119. *
  4120. * Note: There are no checks on the element length other than
  4121. * having to fit into the given data.
  4122. */
  4123. static inline const u8 *cfg80211_find_ext_ie(u8 ext_eid, const u8 *ies, int len)
  4124. {
  4125. return cfg80211_find_ie_match(WLAN_EID_EXTENSION, ies, len,
  4126. &ext_eid, 1, 2);
  4127. }
  4128. /**
  4129. * cfg80211_find_vendor_ie - find vendor specific information element in data
  4130. *
  4131. * @oui: vendor OUI
  4132. * @oui_type: vendor-specific OUI type (must be < 0xff), negative means any
  4133. * @ies: data consisting of IEs
  4134. * @len: length of data
  4135. *
  4136. * Return: %NULL if the vendor specific element ID could not be found or if the
  4137. * element is invalid (claims to be longer than the given data), or a pointer to
  4138. * the first byte of the requested element, that is the byte containing the
  4139. * element ID.
  4140. *
  4141. * Note: There are no checks on the element length other than having to fit into
  4142. * the given data.
  4143. */
  4144. const u8 *cfg80211_find_vendor_ie(unsigned int oui, int oui_type,
  4145. const u8 *ies, int len);
  4146. /**
  4147. * DOC: Regulatory enforcement infrastructure
  4148. *
  4149. * TODO
  4150. */
  4151. /**
  4152. * regulatory_hint - driver hint to the wireless core a regulatory domain
  4153. * @wiphy: the wireless device giving the hint (used only for reporting
  4154. * conflicts)
  4155. * @alpha2: the ISO/IEC 3166 alpha2 the driver claims its regulatory domain
  4156. * should be in. If @rd is set this should be NULL. Note that if you
  4157. * set this to NULL you should still set rd->alpha2 to some accepted
  4158. * alpha2.
  4159. *
  4160. * Wireless drivers can use this function to hint to the wireless core
  4161. * what it believes should be the current regulatory domain by
  4162. * giving it an ISO/IEC 3166 alpha2 country code it knows its regulatory
  4163. * domain should be in or by providing a completely build regulatory domain.
  4164. * If the driver provides an ISO/IEC 3166 alpha2 userspace will be queried
  4165. * for a regulatory domain structure for the respective country.
  4166. *
  4167. * The wiphy must have been registered to cfg80211 prior to this call.
  4168. * For cfg80211 drivers this means you must first use wiphy_register(),
  4169. * for mac80211 drivers you must first use ieee80211_register_hw().
  4170. *
  4171. * Drivers should check the return value, its possible you can get
  4172. * an -ENOMEM.
  4173. *
  4174. * Return: 0 on success. -ENOMEM.
  4175. */
  4176. int regulatory_hint(struct wiphy *wiphy, const char *alpha2);
  4177. /**
  4178. * regulatory_set_wiphy_regd - set regdom info for self managed drivers
  4179. * @wiphy: the wireless device we want to process the regulatory domain on
  4180. * @rd: the regulatory domain informatoin to use for this wiphy
  4181. *
  4182. * Set the regulatory domain information for self-managed wiphys, only they
  4183. * may use this function. See %REGULATORY_WIPHY_SELF_MANAGED for more
  4184. * information.
  4185. *
  4186. * Return: 0 on success. -EINVAL, -EPERM
  4187. */
  4188. int regulatory_set_wiphy_regd(struct wiphy *wiphy,
  4189. struct ieee80211_regdomain *rd);
  4190. /**
  4191. * regulatory_set_wiphy_regd_sync_rtnl - set regdom for self-managed drivers
  4192. * @wiphy: the wireless device we want to process the regulatory domain on
  4193. * @rd: the regulatory domain information to use for this wiphy
  4194. *
  4195. * This functions requires the RTNL to be held and applies the new regdomain
  4196. * synchronously to this wiphy. For more details see
  4197. * regulatory_set_wiphy_regd().
  4198. *
  4199. * Return: 0 on success. -EINVAL, -EPERM
  4200. */
  4201. int regulatory_set_wiphy_regd_sync_rtnl(struct wiphy *wiphy,
  4202. struct ieee80211_regdomain *rd);
  4203. /**
  4204. * wiphy_apply_custom_regulatory - apply a custom driver regulatory domain
  4205. * @wiphy: the wireless device we want to process the regulatory domain on
  4206. * @regd: the custom regulatory domain to use for this wiphy
  4207. *
  4208. * Drivers can sometimes have custom regulatory domains which do not apply
  4209. * to a specific country. Drivers can use this to apply such custom regulatory
  4210. * domains. This routine must be called prior to wiphy registration. The
  4211. * custom regulatory domain will be trusted completely and as such previous
  4212. * default channel settings will be disregarded. If no rule is found for a
  4213. * channel on the regulatory domain the channel will be disabled.
  4214. * Drivers using this for a wiphy should also set the wiphy flag
  4215. * REGULATORY_CUSTOM_REG or cfg80211 will set it for the wiphy
  4216. * that called this helper.
  4217. */
  4218. void wiphy_apply_custom_regulatory(struct wiphy *wiphy,
  4219. const struct ieee80211_regdomain *regd);
  4220. /**
  4221. * freq_reg_info - get regulatory information for the given frequency
  4222. * @wiphy: the wiphy for which we want to process this rule for
  4223. * @center_freq: Frequency in KHz for which we want regulatory information for
  4224. *
  4225. * Use this function to get the regulatory rule for a specific frequency on
  4226. * a given wireless device. If the device has a specific regulatory domain
  4227. * it wants to follow we respect that unless a country IE has been received
  4228. * and processed already.
  4229. *
  4230. * Return: A valid pointer, or, when an error occurs, for example if no rule
  4231. * can be found, the return value is encoded using ERR_PTR(). Use IS_ERR() to
  4232. * check and PTR_ERR() to obtain the numeric return value. The numeric return
  4233. * value will be -ERANGE if we determine the given center_freq does not even
  4234. * have a regulatory rule for a frequency range in the center_freq's band.
  4235. * See freq_in_rule_band() for our current definition of a band -- this is
  4236. * purely subjective and right now it's 802.11 specific.
  4237. */
  4238. const struct ieee80211_reg_rule *freq_reg_info(struct wiphy *wiphy,
  4239. u32 center_freq);
  4240. /**
  4241. * reg_initiator_name - map regulatory request initiator enum to name
  4242. * @initiator: the regulatory request initiator
  4243. *
  4244. * You can use this to map the regulatory request initiator enum to a
  4245. * proper string representation.
  4246. */
  4247. const char *reg_initiator_name(enum nl80211_reg_initiator initiator);
  4248. /*
  4249. * callbacks for asynchronous cfg80211 methods, notification
  4250. * functions and BSS handling helpers
  4251. */
  4252. /**
  4253. * cfg80211_scan_done - notify that scan finished
  4254. *
  4255. * @request: the corresponding scan request
  4256. * @info: information about the completed scan
  4257. */
  4258. void cfg80211_scan_done(struct cfg80211_scan_request *request,
  4259. struct cfg80211_scan_info *info);
  4260. /**
  4261. * cfg80211_sched_scan_results - notify that new scan results are available
  4262. *
  4263. * @wiphy: the wiphy which got scheduled scan results
  4264. * @reqid: identifier for the related scheduled scan request
  4265. */
  4266. void cfg80211_sched_scan_results(struct wiphy *wiphy, u64 reqid);
  4267. /**
  4268. * cfg80211_sched_scan_stopped - notify that the scheduled scan has stopped
  4269. *
  4270. * @wiphy: the wiphy on which the scheduled scan stopped
  4271. * @reqid: identifier for the related scheduled scan request
  4272. *
  4273. * The driver can call this function to inform cfg80211 that the
  4274. * scheduled scan had to be stopped, for whatever reason. The driver
  4275. * is then called back via the sched_scan_stop operation when done.
  4276. */
  4277. void cfg80211_sched_scan_stopped(struct wiphy *wiphy, u64 reqid);
  4278. /**
  4279. * cfg80211_sched_scan_stopped_rtnl - notify that the scheduled scan has stopped
  4280. *
  4281. * @wiphy: the wiphy on which the scheduled scan stopped
  4282. * @reqid: identifier for the related scheduled scan request
  4283. *
  4284. * The driver can call this function to inform cfg80211 that the
  4285. * scheduled scan had to be stopped, for whatever reason. The driver
  4286. * is then called back via the sched_scan_stop operation when done.
  4287. * This function should be called with rtnl locked.
  4288. */
  4289. void cfg80211_sched_scan_stopped_rtnl(struct wiphy *wiphy, u64 reqid);
  4290. /**
  4291. * cfg80211_inform_bss_frame_data - inform cfg80211 of a received BSS frame
  4292. * @wiphy: the wiphy reporting the BSS
  4293. * @data: the BSS metadata
  4294. * @mgmt: the management frame (probe response or beacon)
  4295. * @len: length of the management frame
  4296. * @gfp: context flags
  4297. *
  4298. * This informs cfg80211 that BSS information was found and
  4299. * the BSS should be updated/added.
  4300. *
  4301. * Return: A referenced struct, must be released with cfg80211_put_bss()!
  4302. * Or %NULL on error.
  4303. */
  4304. struct cfg80211_bss * __must_check
  4305. cfg80211_inform_bss_frame_data(struct wiphy *wiphy,
  4306. struct cfg80211_inform_bss *data,
  4307. struct ieee80211_mgmt *mgmt, size_t len,
  4308. gfp_t gfp);
  4309. static inline struct cfg80211_bss * __must_check
  4310. cfg80211_inform_bss_width_frame(struct wiphy *wiphy,
  4311. struct ieee80211_channel *rx_channel,
  4312. enum nl80211_bss_scan_width scan_width,
  4313. struct ieee80211_mgmt *mgmt, size_t len,
  4314. s32 signal, gfp_t gfp)
  4315. {
  4316. struct cfg80211_inform_bss data = {
  4317. .chan = rx_channel,
  4318. .scan_width = scan_width,
  4319. .signal = signal,
  4320. };
  4321. return cfg80211_inform_bss_frame_data(wiphy, &data, mgmt, len, gfp);
  4322. }
  4323. static inline struct cfg80211_bss * __must_check
  4324. cfg80211_inform_bss_frame(struct wiphy *wiphy,
  4325. struct ieee80211_channel *rx_channel,
  4326. struct ieee80211_mgmt *mgmt, size_t len,
  4327. s32 signal, gfp_t gfp)
  4328. {
  4329. struct cfg80211_inform_bss data = {
  4330. .chan = rx_channel,
  4331. .scan_width = NL80211_BSS_CHAN_WIDTH_20,
  4332. .signal = signal,
  4333. };
  4334. return cfg80211_inform_bss_frame_data(wiphy, &data, mgmt, len, gfp);
  4335. }
  4336. /**
  4337. * enum cfg80211_bss_frame_type - frame type that the BSS data came from
  4338. * @CFG80211_BSS_FTYPE_UNKNOWN: driver doesn't know whether the data is
  4339. * from a beacon or probe response
  4340. * @CFG80211_BSS_FTYPE_BEACON: data comes from a beacon
  4341. * @CFG80211_BSS_FTYPE_PRESP: data comes from a probe response
  4342. */
  4343. enum cfg80211_bss_frame_type {
  4344. CFG80211_BSS_FTYPE_UNKNOWN,
  4345. CFG80211_BSS_FTYPE_BEACON,
  4346. CFG80211_BSS_FTYPE_PRESP,
  4347. };
  4348. /**
  4349. * cfg80211_inform_bss_data - inform cfg80211 of a new BSS
  4350. *
  4351. * @wiphy: the wiphy reporting the BSS
  4352. * @data: the BSS metadata
  4353. * @ftype: frame type (if known)
  4354. * @bssid: the BSSID of the BSS
  4355. * @tsf: the TSF sent by the peer in the beacon/probe response (or 0)
  4356. * @capability: the capability field sent by the peer
  4357. * @beacon_interval: the beacon interval announced by the peer
  4358. * @ie: additional IEs sent by the peer
  4359. * @ielen: length of the additional IEs
  4360. * @gfp: context flags
  4361. *
  4362. * This informs cfg80211 that BSS information was found and
  4363. * the BSS should be updated/added.
  4364. *
  4365. * Return: A referenced struct, must be released with cfg80211_put_bss()!
  4366. * Or %NULL on error.
  4367. */
  4368. struct cfg80211_bss * __must_check
  4369. cfg80211_inform_bss_data(struct wiphy *wiphy,
  4370. struct cfg80211_inform_bss *data,
  4371. enum cfg80211_bss_frame_type ftype,
  4372. const u8 *bssid, u64 tsf, u16 capability,
  4373. u16 beacon_interval, const u8 *ie, size_t ielen,
  4374. gfp_t gfp);
  4375. static inline struct cfg80211_bss * __must_check
  4376. cfg80211_inform_bss_width(struct wiphy *wiphy,
  4377. struct ieee80211_channel *rx_channel,
  4378. enum nl80211_bss_scan_width scan_width,
  4379. enum cfg80211_bss_frame_type ftype,
  4380. const u8 *bssid, u64 tsf, u16 capability,
  4381. u16 beacon_interval, const u8 *ie, size_t ielen,
  4382. s32 signal, gfp_t gfp)
  4383. {
  4384. struct cfg80211_inform_bss data = {
  4385. .chan = rx_channel,
  4386. .scan_width = scan_width,
  4387. .signal = signal,
  4388. };
  4389. return cfg80211_inform_bss_data(wiphy, &data, ftype, bssid, tsf,
  4390. capability, beacon_interval, ie, ielen,
  4391. gfp);
  4392. }
  4393. static inline struct cfg80211_bss * __must_check
  4394. cfg80211_inform_bss(struct wiphy *wiphy,
  4395. struct ieee80211_channel *rx_channel,
  4396. enum cfg80211_bss_frame_type ftype,
  4397. const u8 *bssid, u64 tsf, u16 capability,
  4398. u16 beacon_interval, const u8 *ie, size_t ielen,
  4399. s32 signal, gfp_t gfp)
  4400. {
  4401. struct cfg80211_inform_bss data = {
  4402. .chan = rx_channel,
  4403. .scan_width = NL80211_BSS_CHAN_WIDTH_20,
  4404. .signal = signal,
  4405. };
  4406. return cfg80211_inform_bss_data(wiphy, &data, ftype, bssid, tsf,
  4407. capability, beacon_interval, ie, ielen,
  4408. gfp);
  4409. }
  4410. /**
  4411. * cfg80211_get_bss - get a BSS reference
  4412. * @wiphy: the wiphy this BSS struct belongs to
  4413. * @channel: the channel to search on (or %NULL)
  4414. * @bssid: the desired BSSID (or %NULL)
  4415. * @ssid: the desired SSID (or %NULL)
  4416. * @ssid_len: length of the SSID (or 0)
  4417. * @bss_type: type of BSS, see &enum ieee80211_bss_type
  4418. * @privacy: privacy filter, see &enum ieee80211_privacy
  4419. */
  4420. struct cfg80211_bss *cfg80211_get_bss(struct wiphy *wiphy,
  4421. struct ieee80211_channel *channel,
  4422. const u8 *bssid,
  4423. const u8 *ssid, size_t ssid_len,
  4424. enum ieee80211_bss_type bss_type,
  4425. enum ieee80211_privacy privacy);
  4426. static inline struct cfg80211_bss *
  4427. cfg80211_get_ibss(struct wiphy *wiphy,
  4428. struct ieee80211_channel *channel,
  4429. const u8 *ssid, size_t ssid_len)
  4430. {
  4431. return cfg80211_get_bss(wiphy, channel, NULL, ssid, ssid_len,
  4432. IEEE80211_BSS_TYPE_IBSS,
  4433. IEEE80211_PRIVACY_ANY);
  4434. }
  4435. /**
  4436. * cfg80211_ref_bss - reference BSS struct
  4437. * @wiphy: the wiphy this BSS struct belongs to
  4438. * @bss: the BSS struct to reference
  4439. *
  4440. * Increments the refcount of the given BSS struct.
  4441. */
  4442. void cfg80211_ref_bss(struct wiphy *wiphy, struct cfg80211_bss *bss);
  4443. /**
  4444. * cfg80211_put_bss - unref BSS struct
  4445. * @wiphy: the wiphy this BSS struct belongs to
  4446. * @bss: the BSS struct
  4447. *
  4448. * Decrements the refcount of the given BSS struct.
  4449. */
  4450. void cfg80211_put_bss(struct wiphy *wiphy, struct cfg80211_bss *bss);
  4451. /**
  4452. * cfg80211_unlink_bss - unlink BSS from internal data structures
  4453. * @wiphy: the wiphy
  4454. * @bss: the bss to remove
  4455. *
  4456. * This function removes the given BSS from the internal data structures
  4457. * thereby making it no longer show up in scan results etc. Use this
  4458. * function when you detect a BSS is gone. Normally BSSes will also time
  4459. * out, so it is not necessary to use this function at all.
  4460. */
  4461. void cfg80211_unlink_bss(struct wiphy *wiphy, struct cfg80211_bss *bss);
  4462. static inline enum nl80211_bss_scan_width
  4463. cfg80211_chandef_to_scan_width(const struct cfg80211_chan_def *chandef)
  4464. {
  4465. switch (chandef->width) {
  4466. case NL80211_CHAN_WIDTH_5:
  4467. return NL80211_BSS_CHAN_WIDTH_5;
  4468. case NL80211_CHAN_WIDTH_10:
  4469. return NL80211_BSS_CHAN_WIDTH_10;
  4470. default:
  4471. return NL80211_BSS_CHAN_WIDTH_20;
  4472. }
  4473. }
  4474. /**
  4475. * cfg80211_rx_mlme_mgmt - notification of processed MLME management frame
  4476. * @dev: network device
  4477. * @buf: authentication frame (header + body)
  4478. * @len: length of the frame data
  4479. *
  4480. * This function is called whenever an authentication, disassociation or
  4481. * deauthentication frame has been received and processed in station mode.
  4482. * After being asked to authenticate via cfg80211_ops::auth() the driver must
  4483. * call either this function or cfg80211_auth_timeout().
  4484. * After being asked to associate via cfg80211_ops::assoc() the driver must
  4485. * call either this function or cfg80211_auth_timeout().
  4486. * While connected, the driver must calls this for received and processed
  4487. * disassociation and deauthentication frames. If the frame couldn't be used
  4488. * because it was unprotected, the driver must call the function
  4489. * cfg80211_rx_unprot_mlme_mgmt() instead.
  4490. *
  4491. * This function may sleep. The caller must hold the corresponding wdev's mutex.
  4492. */
  4493. void cfg80211_rx_mlme_mgmt(struct net_device *dev, const u8 *buf, size_t len);
  4494. /**
  4495. * cfg80211_auth_timeout - notification of timed out authentication
  4496. * @dev: network device
  4497. * @addr: The MAC address of the device with which the authentication timed out
  4498. *
  4499. * This function may sleep. The caller must hold the corresponding wdev's
  4500. * mutex.
  4501. */
  4502. void cfg80211_auth_timeout(struct net_device *dev, const u8 *addr);
  4503. /**
  4504. * cfg80211_rx_assoc_resp - notification of processed association response
  4505. * @dev: network device
  4506. * @bss: the BSS that association was requested with, ownership of the pointer
  4507. * moves to cfg80211 in this call
  4508. * @buf: authentication frame (header + body)
  4509. * @len: length of the frame data
  4510. * @uapsd_queues: bitmap of queues configured for uapsd. Same format
  4511. * as the AC bitmap in the QoS info field
  4512. *
  4513. * After being asked to associate via cfg80211_ops::assoc() the driver must
  4514. * call either this function or cfg80211_auth_timeout().
  4515. *
  4516. * This function may sleep. The caller must hold the corresponding wdev's mutex.
  4517. */
  4518. void cfg80211_rx_assoc_resp(struct net_device *dev,
  4519. struct cfg80211_bss *bss,
  4520. const u8 *buf, size_t len,
  4521. int uapsd_queues);
  4522. /**
  4523. * cfg80211_assoc_timeout - notification of timed out association
  4524. * @dev: network device
  4525. * @bss: The BSS entry with which association timed out.
  4526. *
  4527. * This function may sleep. The caller must hold the corresponding wdev's mutex.
  4528. */
  4529. void cfg80211_assoc_timeout(struct net_device *dev, struct cfg80211_bss *bss);
  4530. /**
  4531. * cfg80211_abandon_assoc - notify cfg80211 of abandoned association attempt
  4532. * @dev: network device
  4533. * @bss: The BSS entry with which association was abandoned.
  4534. *
  4535. * Call this whenever - for reasons reported through other API, like deauth RX,
  4536. * an association attempt was abandoned.
  4537. * This function may sleep. The caller must hold the corresponding wdev's mutex.
  4538. */
  4539. void cfg80211_abandon_assoc(struct net_device *dev, struct cfg80211_bss *bss);
  4540. /**
  4541. * cfg80211_tx_mlme_mgmt - notification of transmitted deauth/disassoc frame
  4542. * @dev: network device
  4543. * @buf: 802.11 frame (header + body)
  4544. * @len: length of the frame data
  4545. *
  4546. * This function is called whenever deauthentication has been processed in
  4547. * station mode. This includes both received deauthentication frames and
  4548. * locally generated ones. This function may sleep. The caller must hold the
  4549. * corresponding wdev's mutex.
  4550. */
  4551. void cfg80211_tx_mlme_mgmt(struct net_device *dev, const u8 *buf, size_t len);
  4552. /**
  4553. * cfg80211_rx_unprot_mlme_mgmt - notification of unprotected mlme mgmt frame
  4554. * @dev: network device
  4555. * @buf: deauthentication frame (header + body)
  4556. * @len: length of the frame data
  4557. *
  4558. * This function is called whenever a received deauthentication or dissassoc
  4559. * frame has been dropped in station mode because of MFP being used but the
  4560. * frame was not protected. This function may sleep.
  4561. */
  4562. void cfg80211_rx_unprot_mlme_mgmt(struct net_device *dev,
  4563. const u8 *buf, size_t len);
  4564. /**
  4565. * cfg80211_michael_mic_failure - notification of Michael MIC failure (TKIP)
  4566. * @dev: network device
  4567. * @addr: The source MAC address of the frame
  4568. * @key_type: The key type that the received frame used
  4569. * @key_id: Key identifier (0..3). Can be -1 if missing.
  4570. * @tsc: The TSC value of the frame that generated the MIC failure (6 octets)
  4571. * @gfp: allocation flags
  4572. *
  4573. * This function is called whenever the local MAC detects a MIC failure in a
  4574. * received frame. This matches with MLME-MICHAELMICFAILURE.indication()
  4575. * primitive.
  4576. */
  4577. void cfg80211_michael_mic_failure(struct net_device *dev, const u8 *addr,
  4578. enum nl80211_key_type key_type, int key_id,
  4579. const u8 *tsc, gfp_t gfp);
  4580. /**
  4581. * cfg80211_ibss_joined - notify cfg80211 that device joined an IBSS
  4582. *
  4583. * @dev: network device
  4584. * @bssid: the BSSID of the IBSS joined
  4585. * @channel: the channel of the IBSS joined
  4586. * @gfp: allocation flags
  4587. *
  4588. * This function notifies cfg80211 that the device joined an IBSS or
  4589. * switched to a different BSSID. Before this function can be called,
  4590. * either a beacon has to have been received from the IBSS, or one of
  4591. * the cfg80211_inform_bss{,_frame} functions must have been called
  4592. * with the locally generated beacon -- this guarantees that there is
  4593. * always a scan result for this IBSS. cfg80211 will handle the rest.
  4594. */
  4595. void cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid,
  4596. struct ieee80211_channel *channel, gfp_t gfp);
  4597. /**
  4598. * cfg80211_notify_new_candidate - notify cfg80211 of a new mesh peer candidate
  4599. *
  4600. * @dev: network device
  4601. * @macaddr: the MAC address of the new candidate
  4602. * @ie: information elements advertised by the peer candidate
  4603. * @ie_len: lenght of the information elements buffer
  4604. * @gfp: allocation flags
  4605. *
  4606. * This function notifies cfg80211 that the mesh peer candidate has been
  4607. * detected, most likely via a beacon or, less likely, via a probe response.
  4608. * cfg80211 then sends a notification to userspace.
  4609. */
  4610. void cfg80211_notify_new_peer_candidate(struct net_device *dev,
  4611. const u8 *macaddr, const u8 *ie, u8 ie_len, gfp_t gfp);
  4612. /**
  4613. * DOC: RFkill integration
  4614. *
  4615. * RFkill integration in cfg80211 is almost invisible to drivers,
  4616. * as cfg80211 automatically registers an rfkill instance for each
  4617. * wireless device it knows about. Soft kill is also translated
  4618. * into disconnecting and turning all interfaces off, drivers are
  4619. * expected to turn off the device when all interfaces are down.
  4620. *
  4621. * However, devices may have a hard RFkill line, in which case they
  4622. * also need to interact with the rfkill subsystem, via cfg80211.
  4623. * They can do this with a few helper functions documented here.
  4624. */
  4625. /**
  4626. * wiphy_rfkill_set_hw_state - notify cfg80211 about hw block state
  4627. * @wiphy: the wiphy
  4628. * @blocked: block status
  4629. */
  4630. void wiphy_rfkill_set_hw_state(struct wiphy *wiphy, bool blocked);
  4631. /**
  4632. * wiphy_rfkill_start_polling - start polling rfkill
  4633. * @wiphy: the wiphy
  4634. */
  4635. void wiphy_rfkill_start_polling(struct wiphy *wiphy);
  4636. /**
  4637. * wiphy_rfkill_stop_polling - stop polling rfkill
  4638. * @wiphy: the wiphy
  4639. */
  4640. void wiphy_rfkill_stop_polling(struct wiphy *wiphy);
  4641. /**
  4642. * DOC: Vendor commands
  4643. *
  4644. * Occasionally, there are special protocol or firmware features that
  4645. * can't be implemented very openly. For this and similar cases, the
  4646. * vendor command functionality allows implementing the features with
  4647. * (typically closed-source) userspace and firmware, using nl80211 as
  4648. * the configuration mechanism.
  4649. *
  4650. * A driver supporting vendor commands must register them as an array
  4651. * in struct wiphy, with handlers for each one, each command has an
  4652. * OUI and sub command ID to identify it.
  4653. *
  4654. * Note that this feature should not be (ab)used to implement protocol
  4655. * features that could openly be shared across drivers. In particular,
  4656. * it must never be required to use vendor commands to implement any
  4657. * "normal" functionality that higher-level userspace like connection
  4658. * managers etc. need.
  4659. */
  4660. struct sk_buff *__cfg80211_alloc_reply_skb(struct wiphy *wiphy,
  4661. enum nl80211_commands cmd,
  4662. enum nl80211_attrs attr,
  4663. int approxlen);
  4664. struct sk_buff *__cfg80211_alloc_event_skb(struct wiphy *wiphy,
  4665. struct wireless_dev *wdev,
  4666. enum nl80211_commands cmd,
  4667. enum nl80211_attrs attr,
  4668. int vendor_event_idx,
  4669. int approxlen, gfp_t gfp);
  4670. void __cfg80211_send_event_skb(struct sk_buff *skb, gfp_t gfp);
  4671. /**
  4672. * cfg80211_vendor_cmd_alloc_reply_skb - allocate vendor command reply
  4673. * @wiphy: the wiphy
  4674. * @approxlen: an upper bound of the length of the data that will
  4675. * be put into the skb
  4676. *
  4677. * This function allocates and pre-fills an skb for a reply to
  4678. * a vendor command. Since it is intended for a reply, calling
  4679. * it outside of a vendor command's doit() operation is invalid.
  4680. *
  4681. * The returned skb is pre-filled with some identifying data in
  4682. * a way that any data that is put into the skb (with skb_put(),
  4683. * nla_put() or similar) will end up being within the
  4684. * %NL80211_ATTR_VENDOR_DATA attribute, so all that needs to be done
  4685. * with the skb is adding data for the corresponding userspace tool
  4686. * which can then read that data out of the vendor data attribute.
  4687. * You must not modify the skb in any other way.
  4688. *
  4689. * When done, call cfg80211_vendor_cmd_reply() with the skb and return
  4690. * its error code as the result of the doit() operation.
  4691. *
  4692. * Return: An allocated and pre-filled skb. %NULL if any errors happen.
  4693. */
  4694. static inline struct sk_buff *
  4695. cfg80211_vendor_cmd_alloc_reply_skb(struct wiphy *wiphy, int approxlen)
  4696. {
  4697. return __cfg80211_alloc_reply_skb(wiphy, NL80211_CMD_VENDOR,
  4698. NL80211_ATTR_VENDOR_DATA, approxlen);
  4699. }
  4700. /**
  4701. * cfg80211_vendor_cmd_reply - send the reply skb
  4702. * @skb: The skb, must have been allocated with
  4703. * cfg80211_vendor_cmd_alloc_reply_skb()
  4704. *
  4705. * Since calling this function will usually be the last thing
  4706. * before returning from the vendor command doit() you should
  4707. * return the error code. Note that this function consumes the
  4708. * skb regardless of the return value.
  4709. *
  4710. * Return: An error code or 0 on success.
  4711. */
  4712. int cfg80211_vendor_cmd_reply(struct sk_buff *skb);
  4713. /**
  4714. * cfg80211_vendor_event_alloc - allocate vendor-specific event skb
  4715. * @wiphy: the wiphy
  4716. * @wdev: the wireless device
  4717. * @event_idx: index of the vendor event in the wiphy's vendor_events
  4718. * @approxlen: an upper bound of the length of the data that will
  4719. * be put into the skb
  4720. * @gfp: allocation flags
  4721. *
  4722. * This function allocates and pre-fills an skb for an event on the
  4723. * vendor-specific multicast group.
  4724. *
  4725. * If wdev != NULL, both the ifindex and identifier of the specified
  4726. * wireless device are added to the event message before the vendor data
  4727. * attribute.
  4728. *
  4729. * When done filling the skb, call cfg80211_vendor_event() with the
  4730. * skb to send the event.
  4731. *
  4732. * Return: An allocated and pre-filled skb. %NULL if any errors happen.
  4733. */
  4734. static inline struct sk_buff *
  4735. cfg80211_vendor_event_alloc(struct wiphy *wiphy, struct wireless_dev *wdev,
  4736. int approxlen, int event_idx, gfp_t gfp)
  4737. {
  4738. return __cfg80211_alloc_event_skb(wiphy, wdev, NL80211_CMD_VENDOR,
  4739. NL80211_ATTR_VENDOR_DATA,
  4740. event_idx, approxlen, gfp);
  4741. }
  4742. /**
  4743. * cfg80211_vendor_event - send the event
  4744. * @skb: The skb, must have been allocated with cfg80211_vendor_event_alloc()
  4745. * @gfp: allocation flags
  4746. *
  4747. * This function sends the given @skb, which must have been allocated
  4748. * by cfg80211_vendor_event_alloc(), as an event. It always consumes it.
  4749. */
  4750. static inline void cfg80211_vendor_event(struct sk_buff *skb, gfp_t gfp)
  4751. {
  4752. __cfg80211_send_event_skb(skb, gfp);
  4753. }
  4754. #ifdef CONFIG_NL80211_TESTMODE
  4755. /**
  4756. * DOC: Test mode
  4757. *
  4758. * Test mode is a set of utility functions to allow drivers to
  4759. * interact with driver-specific tools to aid, for instance,
  4760. * factory programming.
  4761. *
  4762. * This chapter describes how drivers interact with it, for more
  4763. * information see the nl80211 book's chapter on it.
  4764. */
  4765. /**
  4766. * cfg80211_testmode_alloc_reply_skb - allocate testmode reply
  4767. * @wiphy: the wiphy
  4768. * @approxlen: an upper bound of the length of the data that will
  4769. * be put into the skb
  4770. *
  4771. * This function allocates and pre-fills an skb for a reply to
  4772. * the testmode command. Since it is intended for a reply, calling
  4773. * it outside of the @testmode_cmd operation is invalid.
  4774. *
  4775. * The returned skb is pre-filled with the wiphy index and set up in
  4776. * a way that any data that is put into the skb (with skb_put(),
  4777. * nla_put() or similar) will end up being within the
  4778. * %NL80211_ATTR_TESTDATA attribute, so all that needs to be done
  4779. * with the skb is adding data for the corresponding userspace tool
  4780. * which can then read that data out of the testdata attribute. You
  4781. * must not modify the skb in any other way.
  4782. *
  4783. * When done, call cfg80211_testmode_reply() with the skb and return
  4784. * its error code as the result of the @testmode_cmd operation.
  4785. *
  4786. * Return: An allocated and pre-filled skb. %NULL if any errors happen.
  4787. */
  4788. static inline struct sk_buff *
  4789. cfg80211_testmode_alloc_reply_skb(struct wiphy *wiphy, int approxlen)
  4790. {
  4791. return __cfg80211_alloc_reply_skb(wiphy, NL80211_CMD_TESTMODE,
  4792. NL80211_ATTR_TESTDATA, approxlen);
  4793. }
  4794. /**
  4795. * cfg80211_testmode_reply - send the reply skb
  4796. * @skb: The skb, must have been allocated with
  4797. * cfg80211_testmode_alloc_reply_skb()
  4798. *
  4799. * Since calling this function will usually be the last thing
  4800. * before returning from the @testmode_cmd you should return
  4801. * the error code. Note that this function consumes the skb
  4802. * regardless of the return value.
  4803. *
  4804. * Return: An error code or 0 on success.
  4805. */
  4806. static inline int cfg80211_testmode_reply(struct sk_buff *skb)
  4807. {
  4808. return cfg80211_vendor_cmd_reply(skb);
  4809. }
  4810. /**
  4811. * cfg80211_testmode_alloc_event_skb - allocate testmode event
  4812. * @wiphy: the wiphy
  4813. * @approxlen: an upper bound of the length of the data that will
  4814. * be put into the skb
  4815. * @gfp: allocation flags
  4816. *
  4817. * This function allocates and pre-fills an skb for an event on the
  4818. * testmode multicast group.
  4819. *
  4820. * The returned skb is set up in the same way as with
  4821. * cfg80211_testmode_alloc_reply_skb() but prepared for an event. As
  4822. * there, you should simply add data to it that will then end up in the
  4823. * %NL80211_ATTR_TESTDATA attribute. Again, you must not modify the skb
  4824. * in any other way.
  4825. *
  4826. * When done filling the skb, call cfg80211_testmode_event() with the
  4827. * skb to send the event.
  4828. *
  4829. * Return: An allocated and pre-filled skb. %NULL if any errors happen.
  4830. */
  4831. static inline struct sk_buff *
  4832. cfg80211_testmode_alloc_event_skb(struct wiphy *wiphy, int approxlen, gfp_t gfp)
  4833. {
  4834. return __cfg80211_alloc_event_skb(wiphy, NULL, NL80211_CMD_TESTMODE,
  4835. NL80211_ATTR_TESTDATA, -1,
  4836. approxlen, gfp);
  4837. }
  4838. /**
  4839. * cfg80211_testmode_event - send the event
  4840. * @skb: The skb, must have been allocated with
  4841. * cfg80211_testmode_alloc_event_skb()
  4842. * @gfp: allocation flags
  4843. *
  4844. * This function sends the given @skb, which must have been allocated
  4845. * by cfg80211_testmode_alloc_event_skb(), as an event. It always
  4846. * consumes it.
  4847. */
  4848. static inline void cfg80211_testmode_event(struct sk_buff *skb, gfp_t gfp)
  4849. {
  4850. __cfg80211_send_event_skb(skb, gfp);
  4851. }
  4852. #define CFG80211_TESTMODE_CMD(cmd) .testmode_cmd = (cmd),
  4853. #define CFG80211_TESTMODE_DUMP(cmd) .testmode_dump = (cmd),
  4854. #else
  4855. #define CFG80211_TESTMODE_CMD(cmd)
  4856. #define CFG80211_TESTMODE_DUMP(cmd)
  4857. #endif
  4858. /**
  4859. * struct cfg80211_connect_resp_params - Connection response params
  4860. * @status: Status code, %WLAN_STATUS_SUCCESS for successful connection, use
  4861. * %WLAN_STATUS_UNSPECIFIED_FAILURE if your device cannot give you
  4862. * the real status code for failures. If this call is used to report a
  4863. * failure due to a timeout (e.g., not receiving an Authentication frame
  4864. * from the AP) instead of an explicit rejection by the AP, -1 is used to
  4865. * indicate that this is a failure, but without a status code.
  4866. * @timeout_reason is used to report the reason for the timeout in that
  4867. * case.
  4868. * @bssid: The BSSID of the AP (may be %NULL)
  4869. * @bss: Entry of bss to which STA got connected to, can be obtained through
  4870. * cfg80211_get_bss() (may be %NULL). Only one parameter among @bssid and
  4871. * @bss needs to be specified.
  4872. * @req_ie: Association request IEs (may be %NULL)
  4873. * @req_ie_len: Association request IEs length
  4874. * @resp_ie: Association response IEs (may be %NULL)
  4875. * @resp_ie_len: Association response IEs length
  4876. * @fils_kek: KEK derived from a successful FILS connection (may be %NULL)
  4877. * @fils_kek_len: Length of @fils_kek in octets
  4878. * @update_erp_next_seq_num: Boolean value to specify whether the value in
  4879. * @fils_erp_next_seq_num is valid.
  4880. * @fils_erp_next_seq_num: The next sequence number to use in ERP message in
  4881. * FILS Authentication. This value should be specified irrespective of the
  4882. * status for a FILS connection.
  4883. * @pmk: A new PMK if derived from a successful FILS connection (may be %NULL).
  4884. * @pmk_len: Length of @pmk in octets
  4885. * @pmkid: A new PMKID if derived from a successful FILS connection or the PMKID
  4886. * used for this FILS connection (may be %NULL).
  4887. * @timeout_reason: Reason for connection timeout. This is used when the
  4888. * connection fails due to a timeout instead of an explicit rejection from
  4889. * the AP. %NL80211_TIMEOUT_UNSPECIFIED is used when the timeout reason is
  4890. * not known. This value is used only if @status < 0 to indicate that the
  4891. * failure is due to a timeout and not due to explicit rejection by the AP.
  4892. * This value is ignored in other cases (@status >= 0).
  4893. */
  4894. struct cfg80211_connect_resp_params {
  4895. int status;
  4896. const u8 *bssid;
  4897. struct cfg80211_bss *bss;
  4898. const u8 *req_ie;
  4899. size_t req_ie_len;
  4900. const u8 *resp_ie;
  4901. size_t resp_ie_len;
  4902. const u8 *fils_kek;
  4903. size_t fils_kek_len;
  4904. bool update_erp_next_seq_num;
  4905. u16 fils_erp_next_seq_num;
  4906. const u8 *pmk;
  4907. size_t pmk_len;
  4908. const u8 *pmkid;
  4909. enum nl80211_timeout_reason timeout_reason;
  4910. };
  4911. /**
  4912. * cfg80211_connect_done - notify cfg80211 of connection result
  4913. *
  4914. * @dev: network device
  4915. * @params: connection response parameters
  4916. * @gfp: allocation flags
  4917. *
  4918. * It should be called by the underlying driver once execution of the connection
  4919. * request from connect() has been completed. This is similar to
  4920. * cfg80211_connect_bss(), but takes a structure pointer for connection response
  4921. * parameters. Only one of the functions among cfg80211_connect_bss(),
  4922. * cfg80211_connect_result(), cfg80211_connect_timeout(),
  4923. * and cfg80211_connect_done() should be called.
  4924. */
  4925. void cfg80211_connect_done(struct net_device *dev,
  4926. struct cfg80211_connect_resp_params *params,
  4927. gfp_t gfp);
  4928. /**
  4929. * cfg80211_connect_bss - notify cfg80211 of connection result
  4930. *
  4931. * @dev: network device
  4932. * @bssid: the BSSID of the AP
  4933. * @bss: entry of bss to which STA got connected to, can be obtained
  4934. * through cfg80211_get_bss (may be %NULL)
  4935. * @req_ie: association request IEs (maybe be %NULL)
  4936. * @req_ie_len: association request IEs length
  4937. * @resp_ie: association response IEs (may be %NULL)
  4938. * @resp_ie_len: assoc response IEs length
  4939. * @status: status code, %WLAN_STATUS_SUCCESS for successful connection, use
  4940. * %WLAN_STATUS_UNSPECIFIED_FAILURE if your device cannot give you
  4941. * the real status code for failures. If this call is used to report a
  4942. * failure due to a timeout (e.g., not receiving an Authentication frame
  4943. * from the AP) instead of an explicit rejection by the AP, -1 is used to
  4944. * indicate that this is a failure, but without a status code.
  4945. * @timeout_reason is used to report the reason for the timeout in that
  4946. * case.
  4947. * @gfp: allocation flags
  4948. * @timeout_reason: reason for connection timeout. This is used when the
  4949. * connection fails due to a timeout instead of an explicit rejection from
  4950. * the AP. %NL80211_TIMEOUT_UNSPECIFIED is used when the timeout reason is
  4951. * not known. This value is used only if @status < 0 to indicate that the
  4952. * failure is due to a timeout and not due to explicit rejection by the AP.
  4953. * This value is ignored in other cases (@status >= 0).
  4954. *
  4955. * It should be called by the underlying driver once execution of the connection
  4956. * request from connect() has been completed. This is similar to
  4957. * cfg80211_connect_result(), but with the option of identifying the exact bss
  4958. * entry for the connection. Only one of the functions among
  4959. * cfg80211_connect_bss(), cfg80211_connect_result(),
  4960. * cfg80211_connect_timeout(), and cfg80211_connect_done() should be called.
  4961. */
  4962. static inline void
  4963. cfg80211_connect_bss(struct net_device *dev, const u8 *bssid,
  4964. struct cfg80211_bss *bss, const u8 *req_ie,
  4965. size_t req_ie_len, const u8 *resp_ie,
  4966. size_t resp_ie_len, int status, gfp_t gfp,
  4967. enum nl80211_timeout_reason timeout_reason)
  4968. {
  4969. struct cfg80211_connect_resp_params params;
  4970. memset(&params, 0, sizeof(params));
  4971. params.status = status;
  4972. params.bssid = bssid;
  4973. params.bss = bss;
  4974. params.req_ie = req_ie;
  4975. params.req_ie_len = req_ie_len;
  4976. params.resp_ie = resp_ie;
  4977. params.resp_ie_len = resp_ie_len;
  4978. params.timeout_reason = timeout_reason;
  4979. cfg80211_connect_done(dev, &params, gfp);
  4980. }
  4981. /**
  4982. * cfg80211_connect_result - notify cfg80211 of connection result
  4983. *
  4984. * @dev: network device
  4985. * @bssid: the BSSID of the AP
  4986. * @req_ie: association request IEs (maybe be %NULL)
  4987. * @req_ie_len: association request IEs length
  4988. * @resp_ie: association response IEs (may be %NULL)
  4989. * @resp_ie_len: assoc response IEs length
  4990. * @status: status code, %WLAN_STATUS_SUCCESS for successful connection, use
  4991. * %WLAN_STATUS_UNSPECIFIED_FAILURE if your device cannot give you
  4992. * the real status code for failures.
  4993. * @gfp: allocation flags
  4994. *
  4995. * It should be called by the underlying driver once execution of the connection
  4996. * request from connect() has been completed. This is similar to
  4997. * cfg80211_connect_bss() which allows the exact bss entry to be specified. Only
  4998. * one of the functions among cfg80211_connect_bss(), cfg80211_connect_result(),
  4999. * cfg80211_connect_timeout(), and cfg80211_connect_done() should be called.
  5000. */
  5001. static inline void
  5002. cfg80211_connect_result(struct net_device *dev, const u8 *bssid,
  5003. const u8 *req_ie, size_t req_ie_len,
  5004. const u8 *resp_ie, size_t resp_ie_len,
  5005. u16 status, gfp_t gfp)
  5006. {
  5007. cfg80211_connect_bss(dev, bssid, NULL, req_ie, req_ie_len, resp_ie,
  5008. resp_ie_len, status, gfp,
  5009. NL80211_TIMEOUT_UNSPECIFIED);
  5010. }
  5011. /**
  5012. * cfg80211_connect_timeout - notify cfg80211 of connection timeout
  5013. *
  5014. * @dev: network device
  5015. * @bssid: the BSSID of the AP
  5016. * @req_ie: association request IEs (maybe be %NULL)
  5017. * @req_ie_len: association request IEs length
  5018. * @gfp: allocation flags
  5019. * @timeout_reason: reason for connection timeout.
  5020. *
  5021. * It should be called by the underlying driver whenever connect() has failed
  5022. * in a sequence where no explicit authentication/association rejection was
  5023. * received from the AP. This could happen, e.g., due to not being able to send
  5024. * out the Authentication or Association Request frame or timing out while
  5025. * waiting for the response. Only one of the functions among
  5026. * cfg80211_connect_bss(), cfg80211_connect_result(),
  5027. * cfg80211_connect_timeout(), and cfg80211_connect_done() should be called.
  5028. */
  5029. static inline void
  5030. cfg80211_connect_timeout(struct net_device *dev, const u8 *bssid,
  5031. const u8 *req_ie, size_t req_ie_len, gfp_t gfp,
  5032. enum nl80211_timeout_reason timeout_reason)
  5033. {
  5034. cfg80211_connect_bss(dev, bssid, NULL, req_ie, req_ie_len, NULL, 0, -1,
  5035. gfp, timeout_reason);
  5036. }
  5037. /**
  5038. * struct cfg80211_roam_info - driver initiated roaming information
  5039. *
  5040. * @channel: the channel of the new AP
  5041. * @bss: entry of bss to which STA got roamed (may be %NULL if %bssid is set)
  5042. * @bssid: the BSSID of the new AP (may be %NULL if %bss is set)
  5043. * @req_ie: association request IEs (maybe be %NULL)
  5044. * @req_ie_len: association request IEs length
  5045. * @resp_ie: association response IEs (may be %NULL)
  5046. * @resp_ie_len: assoc response IEs length
  5047. */
  5048. struct cfg80211_roam_info {
  5049. struct ieee80211_channel *channel;
  5050. struct cfg80211_bss *bss;
  5051. const u8 *bssid;
  5052. const u8 *req_ie;
  5053. size_t req_ie_len;
  5054. const u8 *resp_ie;
  5055. size_t resp_ie_len;
  5056. };
  5057. /**
  5058. * cfg80211_roamed - notify cfg80211 of roaming
  5059. *
  5060. * @dev: network device
  5061. * @info: information about the new BSS. struct &cfg80211_roam_info.
  5062. * @gfp: allocation flags
  5063. *
  5064. * This function may be called with the driver passing either the BSSID of the
  5065. * new AP or passing the bss entry to avoid a race in timeout of the bss entry.
  5066. * It should be called by the underlying driver whenever it roamed from one AP
  5067. * to another while connected. Drivers which have roaming implemented in
  5068. * firmware should pass the bss entry to avoid a race in bss entry timeout where
  5069. * the bss entry of the new AP is seen in the driver, but gets timed out by the
  5070. * time it is accessed in __cfg80211_roamed() due to delay in scheduling
  5071. * rdev->event_work. In case of any failures, the reference is released
  5072. * either in cfg80211_roamed() or in __cfg80211_romed(), Otherwise, it will be
  5073. * released while diconneting from the current bss.
  5074. */
  5075. void cfg80211_roamed(struct net_device *dev, struct cfg80211_roam_info *info,
  5076. gfp_t gfp);
  5077. /**
  5078. * cfg80211_port_authorized - notify cfg80211 of successful security association
  5079. *
  5080. * @dev: network device
  5081. * @bssid: the BSSID of the AP
  5082. * @gfp: allocation flags
  5083. *
  5084. * This function should be called by a driver that supports 4 way handshake
  5085. * offload after a security association was successfully established (i.e.,
  5086. * the 4 way handshake was completed successfully). The call to this function
  5087. * should be preceded with a call to cfg80211_connect_result(),
  5088. * cfg80211_connect_done(), cfg80211_connect_bss() or cfg80211_roamed() to
  5089. * indicate the 802.11 association.
  5090. */
  5091. void cfg80211_port_authorized(struct net_device *dev, const u8 *bssid,
  5092. gfp_t gfp);
  5093. /**
  5094. * cfg80211_disconnected - notify cfg80211 that connection was dropped
  5095. *
  5096. * @dev: network device
  5097. * @ie: information elements of the deauth/disassoc frame (may be %NULL)
  5098. * @ie_len: length of IEs
  5099. * @reason: reason code for the disconnection, set it to 0 if unknown
  5100. * @locally_generated: disconnection was requested locally
  5101. * @gfp: allocation flags
  5102. *
  5103. * After it calls this function, the driver should enter an idle state
  5104. * and not try to connect to any AP any more.
  5105. */
  5106. void cfg80211_disconnected(struct net_device *dev, u16 reason,
  5107. const u8 *ie, size_t ie_len,
  5108. bool locally_generated, gfp_t gfp);
  5109. /**
  5110. * cfg80211_ready_on_channel - notification of remain_on_channel start
  5111. * @wdev: wireless device
  5112. * @cookie: the request cookie
  5113. * @chan: The current channel (from remain_on_channel request)
  5114. * @duration: Duration in milliseconds that the driver intents to remain on the
  5115. * channel
  5116. * @gfp: allocation flags
  5117. */
  5118. void cfg80211_ready_on_channel(struct wireless_dev *wdev, u64 cookie,
  5119. struct ieee80211_channel *chan,
  5120. unsigned int duration, gfp_t gfp);
  5121. /**
  5122. * cfg80211_remain_on_channel_expired - remain_on_channel duration expired
  5123. * @wdev: wireless device
  5124. * @cookie: the request cookie
  5125. * @chan: The current channel (from remain_on_channel request)
  5126. * @gfp: allocation flags
  5127. */
  5128. void cfg80211_remain_on_channel_expired(struct wireless_dev *wdev, u64 cookie,
  5129. struct ieee80211_channel *chan,
  5130. gfp_t gfp);
  5131. /**
  5132. * cfg80211_new_sta - notify userspace about station
  5133. *
  5134. * @dev: the netdev
  5135. * @mac_addr: the station's address
  5136. * @sinfo: the station information
  5137. * @gfp: allocation flags
  5138. */
  5139. void cfg80211_new_sta(struct net_device *dev, const u8 *mac_addr,
  5140. struct station_info *sinfo, gfp_t gfp);
  5141. /**
  5142. * cfg80211_del_sta_sinfo - notify userspace about deletion of a station
  5143. * @dev: the netdev
  5144. * @mac_addr: the station's address
  5145. * @sinfo: the station information/statistics
  5146. * @gfp: allocation flags
  5147. */
  5148. void cfg80211_del_sta_sinfo(struct net_device *dev, const u8 *mac_addr,
  5149. struct station_info *sinfo, gfp_t gfp);
  5150. /**
  5151. * cfg80211_del_sta - notify userspace about deletion of a station
  5152. *
  5153. * @dev: the netdev
  5154. * @mac_addr: the station's address
  5155. * @gfp: allocation flags
  5156. */
  5157. static inline void cfg80211_del_sta(struct net_device *dev,
  5158. const u8 *mac_addr, gfp_t gfp)
  5159. {
  5160. cfg80211_del_sta_sinfo(dev, mac_addr, NULL, gfp);
  5161. }
  5162. /**
  5163. * cfg80211_conn_failed - connection request failed notification
  5164. *
  5165. * @dev: the netdev
  5166. * @mac_addr: the station's address
  5167. * @reason: the reason for connection failure
  5168. * @gfp: allocation flags
  5169. *
  5170. * Whenever a station tries to connect to an AP and if the station
  5171. * could not connect to the AP as the AP has rejected the connection
  5172. * for some reasons, this function is called.
  5173. *
  5174. * The reason for connection failure can be any of the value from
  5175. * nl80211_connect_failed_reason enum
  5176. */
  5177. void cfg80211_conn_failed(struct net_device *dev, const u8 *mac_addr,
  5178. enum nl80211_connect_failed_reason reason,
  5179. gfp_t gfp);
  5180. /**
  5181. * cfg80211_rx_mgmt - notification of received, unprocessed management frame
  5182. * @wdev: wireless device receiving the frame
  5183. * @freq: Frequency on which the frame was received in MHz
  5184. * @sig_dbm: signal strength in mBm, or 0 if unknown
  5185. * @buf: Management frame (header + body)
  5186. * @len: length of the frame data
  5187. * @flags: flags, as defined in enum nl80211_rxmgmt_flags
  5188. *
  5189. * This function is called whenever an Action frame is received for a station
  5190. * mode interface, but is not processed in kernel.
  5191. *
  5192. * Return: %true if a user space application has registered for this frame.
  5193. * For action frames, that makes it responsible for rejecting unrecognized
  5194. * action frames; %false otherwise, in which case for action frames the
  5195. * driver is responsible for rejecting the frame.
  5196. */
  5197. bool cfg80211_rx_mgmt(struct wireless_dev *wdev, int freq, int sig_dbm,
  5198. const u8 *buf, size_t len, u32 flags);
  5199. /**
  5200. * cfg80211_mgmt_tx_status - notification of TX status for management frame
  5201. * @wdev: wireless device receiving the frame
  5202. * @cookie: Cookie returned by cfg80211_ops::mgmt_tx()
  5203. * @buf: Management frame (header + body)
  5204. * @len: length of the frame data
  5205. * @ack: Whether frame was acknowledged
  5206. * @gfp: context flags
  5207. *
  5208. * This function is called whenever a management frame was requested to be
  5209. * transmitted with cfg80211_ops::mgmt_tx() to report the TX status of the
  5210. * transmission attempt.
  5211. */
  5212. void cfg80211_mgmt_tx_status(struct wireless_dev *wdev, u64 cookie,
  5213. const u8 *buf, size_t len, bool ack, gfp_t gfp);
  5214. /**
  5215. * cfg80211_cqm_rssi_notify - connection quality monitoring rssi event
  5216. * @dev: network device
  5217. * @rssi_event: the triggered RSSI event
  5218. * @rssi_level: new RSSI level value or 0 if not available
  5219. * @gfp: context flags
  5220. *
  5221. * This function is called when a configured connection quality monitoring
  5222. * rssi threshold reached event occurs.
  5223. */
  5224. void cfg80211_cqm_rssi_notify(struct net_device *dev,
  5225. enum nl80211_cqm_rssi_threshold_event rssi_event,
  5226. s32 rssi_level, gfp_t gfp);
  5227. /**
  5228. * cfg80211_cqm_pktloss_notify - notify userspace about packetloss to peer
  5229. * @dev: network device
  5230. * @peer: peer's MAC address
  5231. * @num_packets: how many packets were lost -- should be a fixed threshold
  5232. * but probably no less than maybe 50, or maybe a throughput dependent
  5233. * threshold (to account for temporary interference)
  5234. * @gfp: context flags
  5235. */
  5236. void cfg80211_cqm_pktloss_notify(struct net_device *dev,
  5237. const u8 *peer, u32 num_packets, gfp_t gfp);
  5238. /**
  5239. * cfg80211_cqm_txe_notify - TX error rate event
  5240. * @dev: network device
  5241. * @peer: peer's MAC address
  5242. * @num_packets: how many packets were lost
  5243. * @rate: % of packets which failed transmission
  5244. * @intvl: interval (in s) over which the TX failure threshold was breached.
  5245. * @gfp: context flags
  5246. *
  5247. * Notify userspace when configured % TX failures over number of packets in a
  5248. * given interval is exceeded.
  5249. */
  5250. void cfg80211_cqm_txe_notify(struct net_device *dev, const u8 *peer,
  5251. u32 num_packets, u32 rate, u32 intvl, gfp_t gfp);
  5252. /**
  5253. * cfg80211_cqm_beacon_loss_notify - beacon loss event
  5254. * @dev: network device
  5255. * @gfp: context flags
  5256. *
  5257. * Notify userspace about beacon loss from the connected AP.
  5258. */
  5259. void cfg80211_cqm_beacon_loss_notify(struct net_device *dev, gfp_t gfp);
  5260. /**
  5261. * cfg80211_radar_event - radar detection event
  5262. * @wiphy: the wiphy
  5263. * @chandef: chandef for the current channel
  5264. * @gfp: context flags
  5265. *
  5266. * This function is called when a radar is detected on the current chanenl.
  5267. */
  5268. void cfg80211_radar_event(struct wiphy *wiphy,
  5269. struct cfg80211_chan_def *chandef, gfp_t gfp);
  5270. /**
  5271. * cfg80211_cac_event - Channel availability check (CAC) event
  5272. * @netdev: network device
  5273. * @chandef: chandef for the current channel
  5274. * @event: type of event
  5275. * @gfp: context flags
  5276. *
  5277. * This function is called when a Channel availability check (CAC) is finished
  5278. * or aborted. This must be called to notify the completion of a CAC process,
  5279. * also by full-MAC drivers.
  5280. */
  5281. void cfg80211_cac_event(struct net_device *netdev,
  5282. const struct cfg80211_chan_def *chandef,
  5283. enum nl80211_radar_event event, gfp_t gfp);
  5284. /**
  5285. * cfg80211_gtk_rekey_notify - notify userspace about driver rekeying
  5286. * @dev: network device
  5287. * @bssid: BSSID of AP (to avoid races)
  5288. * @replay_ctr: new replay counter
  5289. * @gfp: allocation flags
  5290. */
  5291. void cfg80211_gtk_rekey_notify(struct net_device *dev, const u8 *bssid,
  5292. const u8 *replay_ctr, gfp_t gfp);
  5293. /**
  5294. * cfg80211_pmksa_candidate_notify - notify about PMKSA caching candidate
  5295. * @dev: network device
  5296. * @index: candidate index (the smaller the index, the higher the priority)
  5297. * @bssid: BSSID of AP
  5298. * @preauth: Whether AP advertises support for RSN pre-authentication
  5299. * @gfp: allocation flags
  5300. */
  5301. void cfg80211_pmksa_candidate_notify(struct net_device *dev, int index,
  5302. const u8 *bssid, bool preauth, gfp_t gfp);
  5303. /**
  5304. * cfg80211_rx_spurious_frame - inform userspace about a spurious frame
  5305. * @dev: The device the frame matched to
  5306. * @addr: the transmitter address
  5307. * @gfp: context flags
  5308. *
  5309. * This function is used in AP mode (only!) to inform userspace that
  5310. * a spurious class 3 frame was received, to be able to deauth the
  5311. * sender.
  5312. * Return: %true if the frame was passed to userspace (or this failed
  5313. * for a reason other than not having a subscription.)
  5314. */
  5315. bool cfg80211_rx_spurious_frame(struct net_device *dev,
  5316. const u8 *addr, gfp_t gfp);
  5317. /**
  5318. * cfg80211_rx_unexpected_4addr_frame - inform about unexpected WDS frame
  5319. * @dev: The device the frame matched to
  5320. * @addr: the transmitter address
  5321. * @gfp: context flags
  5322. *
  5323. * This function is used in AP mode (only!) to inform userspace that
  5324. * an associated station sent a 4addr frame but that wasn't expected.
  5325. * It is allowed and desirable to send this event only once for each
  5326. * station to avoid event flooding.
  5327. * Return: %true if the frame was passed to userspace (or this failed
  5328. * for a reason other than not having a subscription.)
  5329. */
  5330. bool cfg80211_rx_unexpected_4addr_frame(struct net_device *dev,
  5331. const u8 *addr, gfp_t gfp);
  5332. /**
  5333. * cfg80211_probe_status - notify userspace about probe status
  5334. * @dev: the device the probe was sent on
  5335. * @addr: the address of the peer
  5336. * @cookie: the cookie filled in @probe_client previously
  5337. * @acked: indicates whether probe was acked or not
  5338. * @gfp: allocation flags
  5339. */
  5340. void cfg80211_probe_status(struct net_device *dev, const u8 *addr,
  5341. u64 cookie, bool acked, gfp_t gfp);
  5342. /**
  5343. * cfg80211_report_obss_beacon - report beacon from other APs
  5344. * @wiphy: The wiphy that received the beacon
  5345. * @frame: the frame
  5346. * @len: length of the frame
  5347. * @freq: frequency the frame was received on
  5348. * @sig_dbm: signal strength in mBm, or 0 if unknown
  5349. *
  5350. * Use this function to report to userspace when a beacon was
  5351. * received. It is not useful to call this when there is no
  5352. * netdev that is in AP/GO mode.
  5353. */
  5354. void cfg80211_report_obss_beacon(struct wiphy *wiphy,
  5355. const u8 *frame, size_t len,
  5356. int freq, int sig_dbm);
  5357. /**
  5358. * cfg80211_reg_can_beacon - check if beaconing is allowed
  5359. * @wiphy: the wiphy
  5360. * @chandef: the channel definition
  5361. * @iftype: interface type
  5362. *
  5363. * Return: %true if there is no secondary channel or the secondary channel(s)
  5364. * can be used for beaconing (i.e. is not a radar channel etc.)
  5365. */
  5366. bool cfg80211_reg_can_beacon(struct wiphy *wiphy,
  5367. struct cfg80211_chan_def *chandef,
  5368. enum nl80211_iftype iftype);
  5369. /**
  5370. * cfg80211_reg_can_beacon_relax - check if beaconing is allowed with relaxation
  5371. * @wiphy: the wiphy
  5372. * @chandef: the channel definition
  5373. * @iftype: interface type
  5374. *
  5375. * Return: %true if there is no secondary channel or the secondary channel(s)
  5376. * can be used for beaconing (i.e. is not a radar channel etc.). This version
  5377. * also checks if IR-relaxation conditions apply, to allow beaconing under
  5378. * more permissive conditions.
  5379. *
  5380. * Requires the RTNL to be held.
  5381. */
  5382. bool cfg80211_reg_can_beacon_relax(struct wiphy *wiphy,
  5383. struct cfg80211_chan_def *chandef,
  5384. enum nl80211_iftype iftype);
  5385. /*
  5386. * cfg80211_ch_switch_notify - update wdev channel and notify userspace
  5387. * @dev: the device which switched channels
  5388. * @chandef: the new channel definition
  5389. *
  5390. * Caller must acquire wdev_lock, therefore must only be called from sleepable
  5391. * driver context!
  5392. */
  5393. void cfg80211_ch_switch_notify(struct net_device *dev,
  5394. struct cfg80211_chan_def *chandef);
  5395. /*
  5396. * cfg80211_ch_switch_started_notify - notify channel switch start
  5397. * @dev: the device on which the channel switch started
  5398. * @chandef: the future channel definition
  5399. * @count: the number of TBTTs until the channel switch happens
  5400. *
  5401. * Inform the userspace about the channel switch that has just
  5402. * started, so that it can take appropriate actions (eg. starting
  5403. * channel switch on other vifs), if necessary.
  5404. */
  5405. void cfg80211_ch_switch_started_notify(struct net_device *dev,
  5406. struct cfg80211_chan_def *chandef,
  5407. u8 count);
  5408. /**
  5409. * ieee80211_operating_class_to_band - convert operating class to band
  5410. *
  5411. * @operating_class: the operating class to convert
  5412. * @band: band pointer to fill
  5413. *
  5414. * Returns %true if the conversion was successful, %false otherwise.
  5415. */
  5416. bool ieee80211_operating_class_to_band(u8 operating_class,
  5417. enum nl80211_band *band);
  5418. /**
  5419. * ieee80211_chandef_to_operating_class - convert chandef to operation class
  5420. *
  5421. * @chandef: the chandef to convert
  5422. * @op_class: a pointer to the resulting operating class
  5423. *
  5424. * Returns %true if the conversion was successful, %false otherwise.
  5425. */
  5426. bool ieee80211_chandef_to_operating_class(struct cfg80211_chan_def *chandef,
  5427. u8 *op_class);
  5428. /*
  5429. * cfg80211_tdls_oper_request - request userspace to perform TDLS operation
  5430. * @dev: the device on which the operation is requested
  5431. * @peer: the MAC address of the peer device
  5432. * @oper: the requested TDLS operation (NL80211_TDLS_SETUP or
  5433. * NL80211_TDLS_TEARDOWN)
  5434. * @reason_code: the reason code for teardown request
  5435. * @gfp: allocation flags
  5436. *
  5437. * This function is used to request userspace to perform TDLS operation that
  5438. * requires knowledge of keys, i.e., link setup or teardown when the AP
  5439. * connection uses encryption. This is optional mechanism for the driver to use
  5440. * if it can automatically determine when a TDLS link could be useful (e.g.,
  5441. * based on traffic and signal strength for a peer).
  5442. */
  5443. void cfg80211_tdls_oper_request(struct net_device *dev, const u8 *peer,
  5444. enum nl80211_tdls_operation oper,
  5445. u16 reason_code, gfp_t gfp);
  5446. /*
  5447. * cfg80211_calculate_bitrate - calculate actual bitrate (in 100Kbps units)
  5448. * @rate: given rate_info to calculate bitrate from
  5449. *
  5450. * return 0 if MCS index >= 32
  5451. */
  5452. u32 cfg80211_calculate_bitrate(struct rate_info *rate);
  5453. /**
  5454. * cfg80211_unregister_wdev - remove the given wdev
  5455. * @wdev: struct wireless_dev to remove
  5456. *
  5457. * Call this function only for wdevs that have no netdev assigned,
  5458. * e.g. P2P Devices. It removes the device from the list so that
  5459. * it can no longer be used. It is necessary to call this function
  5460. * even when cfg80211 requests the removal of the interface by
  5461. * calling the del_virtual_intf() callback. The function must also
  5462. * be called when the driver wishes to unregister the wdev, e.g.
  5463. * when the device is unbound from the driver.
  5464. *
  5465. * Requires the RTNL to be held.
  5466. */
  5467. void cfg80211_unregister_wdev(struct wireless_dev *wdev);
  5468. /**
  5469. * struct cfg80211_ft_event - FT Information Elements
  5470. * @ies: FT IEs
  5471. * @ies_len: length of the FT IE in bytes
  5472. * @target_ap: target AP's MAC address
  5473. * @ric_ies: RIC IE
  5474. * @ric_ies_len: length of the RIC IE in bytes
  5475. */
  5476. struct cfg80211_ft_event_params {
  5477. const u8 *ies;
  5478. size_t ies_len;
  5479. const u8 *target_ap;
  5480. const u8 *ric_ies;
  5481. size_t ric_ies_len;
  5482. };
  5483. /**
  5484. * cfg80211_ft_event - notify userspace about FT IE and RIC IE
  5485. * @netdev: network device
  5486. * @ft_event: IE information
  5487. */
  5488. void cfg80211_ft_event(struct net_device *netdev,
  5489. struct cfg80211_ft_event_params *ft_event);
  5490. /**
  5491. * cfg80211_get_p2p_attr - find and copy a P2P attribute from IE buffer
  5492. * @ies: the input IE buffer
  5493. * @len: the input length
  5494. * @attr: the attribute ID to find
  5495. * @buf: output buffer, can be %NULL if the data isn't needed, e.g.
  5496. * if the function is only called to get the needed buffer size
  5497. * @bufsize: size of the output buffer
  5498. *
  5499. * The function finds a given P2P attribute in the (vendor) IEs and
  5500. * copies its contents to the given buffer.
  5501. *
  5502. * Return: A negative error code (-%EILSEQ or -%ENOENT) if the data is
  5503. * malformed or the attribute can't be found (respectively), or the
  5504. * length of the found attribute (which can be zero).
  5505. */
  5506. int cfg80211_get_p2p_attr(const u8 *ies, unsigned int len,
  5507. enum ieee80211_p2p_attr_id attr,
  5508. u8 *buf, unsigned int bufsize);
  5509. /**
  5510. * ieee80211_ie_split_ric - split an IE buffer according to ordering (with RIC)
  5511. * @ies: the IE buffer
  5512. * @ielen: the length of the IE buffer
  5513. * @ids: an array with element IDs that are allowed before
  5514. * the split. A WLAN_EID_EXTENSION value means that the next
  5515. * EID in the list is a sub-element of the EXTENSION IE.
  5516. * @n_ids: the size of the element ID array
  5517. * @after_ric: array IE types that come after the RIC element
  5518. * @n_after_ric: size of the @after_ric array
  5519. * @offset: offset where to start splitting in the buffer
  5520. *
  5521. * This function splits an IE buffer by updating the @offset
  5522. * variable to point to the location where the buffer should be
  5523. * split.
  5524. *
  5525. * It assumes that the given IE buffer is well-formed, this
  5526. * has to be guaranteed by the caller!
  5527. *
  5528. * It also assumes that the IEs in the buffer are ordered
  5529. * correctly, if not the result of using this function will not
  5530. * be ordered correctly either, i.e. it does no reordering.
  5531. *
  5532. * The function returns the offset where the next part of the
  5533. * buffer starts, which may be @ielen if the entire (remainder)
  5534. * of the buffer should be used.
  5535. */
  5536. size_t ieee80211_ie_split_ric(const u8 *ies, size_t ielen,
  5537. const u8 *ids, int n_ids,
  5538. const u8 *after_ric, int n_after_ric,
  5539. size_t offset);
  5540. /**
  5541. * ieee80211_ie_split - split an IE buffer according to ordering
  5542. * @ies: the IE buffer
  5543. * @ielen: the length of the IE buffer
  5544. * @ids: an array with element IDs that are allowed before
  5545. * the split. A WLAN_EID_EXTENSION value means that the next
  5546. * EID in the list is a sub-element of the EXTENSION IE.
  5547. * @n_ids: the size of the element ID array
  5548. * @offset: offset where to start splitting in the buffer
  5549. *
  5550. * This function splits an IE buffer by updating the @offset
  5551. * variable to point to the location where the buffer should be
  5552. * split.
  5553. *
  5554. * It assumes that the given IE buffer is well-formed, this
  5555. * has to be guaranteed by the caller!
  5556. *
  5557. * It also assumes that the IEs in the buffer are ordered
  5558. * correctly, if not the result of using this function will not
  5559. * be ordered correctly either, i.e. it does no reordering.
  5560. *
  5561. * The function returns the offset where the next part of the
  5562. * buffer starts, which may be @ielen if the entire (remainder)
  5563. * of the buffer should be used.
  5564. */
  5565. static inline size_t ieee80211_ie_split(const u8 *ies, size_t ielen,
  5566. const u8 *ids, int n_ids, size_t offset)
  5567. {
  5568. return ieee80211_ie_split_ric(ies, ielen, ids, n_ids, NULL, 0, offset);
  5569. }
  5570. /**
  5571. * cfg80211_report_wowlan_wakeup - report wakeup from WoWLAN
  5572. * @wdev: the wireless device reporting the wakeup
  5573. * @wakeup: the wakeup report
  5574. * @gfp: allocation flags
  5575. *
  5576. * This function reports that the given device woke up. If it
  5577. * caused the wakeup, report the reason(s), otherwise you may
  5578. * pass %NULL as the @wakeup parameter to advertise that something
  5579. * else caused the wakeup.
  5580. */
  5581. void cfg80211_report_wowlan_wakeup(struct wireless_dev *wdev,
  5582. struct cfg80211_wowlan_wakeup *wakeup,
  5583. gfp_t gfp);
  5584. /**
  5585. * cfg80211_crit_proto_stopped() - indicate critical protocol stopped by driver.
  5586. *
  5587. * @wdev: the wireless device for which critical protocol is stopped.
  5588. * @gfp: allocation flags
  5589. *
  5590. * This function can be called by the driver to indicate it has reverted
  5591. * operation back to normal. One reason could be that the duration given
  5592. * by .crit_proto_start() has expired.
  5593. */
  5594. void cfg80211_crit_proto_stopped(struct wireless_dev *wdev, gfp_t gfp);
  5595. /**
  5596. * ieee80211_get_num_supported_channels - get number of channels device has
  5597. * @wiphy: the wiphy
  5598. *
  5599. * Return: the number of channels supported by the device.
  5600. */
  5601. unsigned int ieee80211_get_num_supported_channels(struct wiphy *wiphy);
  5602. /**
  5603. * cfg80211_check_combinations - check interface combinations
  5604. *
  5605. * @wiphy: the wiphy
  5606. * @params: the interface combinations parameter
  5607. *
  5608. * This function can be called by the driver to check whether a
  5609. * combination of interfaces and their types are allowed according to
  5610. * the interface combinations.
  5611. */
  5612. int cfg80211_check_combinations(struct wiphy *wiphy,
  5613. struct iface_combination_params *params);
  5614. /**
  5615. * cfg80211_iter_combinations - iterate over matching combinations
  5616. *
  5617. * @wiphy: the wiphy
  5618. * @params: the interface combinations parameter
  5619. * @iter: function to call for each matching combination
  5620. * @data: pointer to pass to iter function
  5621. *
  5622. * This function can be called by the driver to check what possible
  5623. * combinations it fits in at a given moment, e.g. for channel switching
  5624. * purposes.
  5625. */
  5626. int cfg80211_iter_combinations(struct wiphy *wiphy,
  5627. struct iface_combination_params *params,
  5628. void (*iter)(const struct ieee80211_iface_combination *c,
  5629. void *data),
  5630. void *data);
  5631. /*
  5632. * cfg80211_stop_iface - trigger interface disconnection
  5633. *
  5634. * @wiphy: the wiphy
  5635. * @wdev: wireless device
  5636. * @gfp: context flags
  5637. *
  5638. * Trigger interface to be stopped as if AP was stopped, IBSS/mesh left, STA
  5639. * disconnected.
  5640. *
  5641. * Note: This doesn't need any locks and is asynchronous.
  5642. */
  5643. void cfg80211_stop_iface(struct wiphy *wiphy, struct wireless_dev *wdev,
  5644. gfp_t gfp);
  5645. /**
  5646. * cfg80211_shutdown_all_interfaces - shut down all interfaces for a wiphy
  5647. * @wiphy: the wiphy to shut down
  5648. *
  5649. * This function shuts down all interfaces belonging to this wiphy by
  5650. * calling dev_close() (and treating non-netdev interfaces as needed).
  5651. * It shouldn't really be used unless there are some fatal device errors
  5652. * that really can't be recovered in any other way.
  5653. *
  5654. * Callers must hold the RTNL and be able to deal with callbacks into
  5655. * the driver while the function is running.
  5656. */
  5657. void cfg80211_shutdown_all_interfaces(struct wiphy *wiphy);
  5658. /**
  5659. * wiphy_ext_feature_set - set the extended feature flag
  5660. *
  5661. * @wiphy: the wiphy to modify.
  5662. * @ftidx: extended feature bit index.
  5663. *
  5664. * The extended features are flagged in multiple bytes (see
  5665. * &struct wiphy.@ext_features)
  5666. */
  5667. static inline void wiphy_ext_feature_set(struct wiphy *wiphy,
  5668. enum nl80211_ext_feature_index ftidx)
  5669. {
  5670. u8 *ft_byte;
  5671. ft_byte = &wiphy->ext_features[ftidx / 8];
  5672. *ft_byte |= BIT(ftidx % 8);
  5673. }
  5674. /**
  5675. * wiphy_ext_feature_isset - check the extended feature flag
  5676. *
  5677. * @wiphy: the wiphy to modify.
  5678. * @ftidx: extended feature bit index.
  5679. *
  5680. * The extended features are flagged in multiple bytes (see
  5681. * &struct wiphy.@ext_features)
  5682. */
  5683. static inline bool
  5684. wiphy_ext_feature_isset(struct wiphy *wiphy,
  5685. enum nl80211_ext_feature_index ftidx)
  5686. {
  5687. u8 ft_byte;
  5688. ft_byte = wiphy->ext_features[ftidx / 8];
  5689. return (ft_byte & BIT(ftidx % 8)) != 0;
  5690. }
  5691. /**
  5692. * cfg80211_free_nan_func - free NAN function
  5693. * @f: NAN function that should be freed
  5694. *
  5695. * Frees all the NAN function and all it's allocated members.
  5696. */
  5697. void cfg80211_free_nan_func(struct cfg80211_nan_func *f);
  5698. /**
  5699. * struct cfg80211_nan_match_params - NAN match parameters
  5700. * @type: the type of the function that triggered a match. If it is
  5701. * %NL80211_NAN_FUNC_SUBSCRIBE it means that we replied to a subscriber.
  5702. * If it is %NL80211_NAN_FUNC_PUBLISH, it means that we got a discovery
  5703. * result.
  5704. * If it is %NL80211_NAN_FUNC_FOLLOW_UP, we received a follow up.
  5705. * @inst_id: the local instance id
  5706. * @peer_inst_id: the instance id of the peer's function
  5707. * @addr: the MAC address of the peer
  5708. * @info_len: the length of the &info
  5709. * @info: the Service Specific Info from the peer (if any)
  5710. * @cookie: unique identifier of the corresponding function
  5711. */
  5712. struct cfg80211_nan_match_params {
  5713. enum nl80211_nan_function_type type;
  5714. u8 inst_id;
  5715. u8 peer_inst_id;
  5716. const u8 *addr;
  5717. u8 info_len;
  5718. const u8 *info;
  5719. u64 cookie;
  5720. };
  5721. /**
  5722. * cfg80211_nan_match - report a match for a NAN function.
  5723. * @wdev: the wireless device reporting the match
  5724. * @match: match notification parameters
  5725. * @gfp: allocation flags
  5726. *
  5727. * This function reports that the a NAN function had a match. This
  5728. * can be a subscribe that had a match or a solicited publish that
  5729. * was sent. It can also be a follow up that was received.
  5730. */
  5731. void cfg80211_nan_match(struct wireless_dev *wdev,
  5732. struct cfg80211_nan_match_params *match, gfp_t gfp);
  5733. /**
  5734. * cfg80211_nan_func_terminated - notify about NAN function termination.
  5735. *
  5736. * @wdev: the wireless device reporting the match
  5737. * @inst_id: the local instance id
  5738. * @reason: termination reason (one of the NL80211_NAN_FUNC_TERM_REASON_*)
  5739. * @cookie: unique NAN function identifier
  5740. * @gfp: allocation flags
  5741. *
  5742. * This function reports that the a NAN function is terminated.
  5743. */
  5744. void cfg80211_nan_func_terminated(struct wireless_dev *wdev,
  5745. u8 inst_id,
  5746. enum nl80211_nan_func_term_reason reason,
  5747. u64 cookie, gfp_t gfp);
  5748. /* ethtool helper */
  5749. void cfg80211_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info);
  5750. /* Logging, debugging and troubleshooting/diagnostic helpers. */
  5751. /* wiphy_printk helpers, similar to dev_printk */
  5752. #define wiphy_printk(level, wiphy, format, args...) \
  5753. dev_printk(level, &(wiphy)->dev, format, ##args)
  5754. #define wiphy_emerg(wiphy, format, args...) \
  5755. dev_emerg(&(wiphy)->dev, format, ##args)
  5756. #define wiphy_alert(wiphy, format, args...) \
  5757. dev_alert(&(wiphy)->dev, format, ##args)
  5758. #define wiphy_crit(wiphy, format, args...) \
  5759. dev_crit(&(wiphy)->dev, format, ##args)
  5760. #define wiphy_err(wiphy, format, args...) \
  5761. dev_err(&(wiphy)->dev, format, ##args)
  5762. #define wiphy_warn(wiphy, format, args...) \
  5763. dev_warn(&(wiphy)->dev, format, ##args)
  5764. #define wiphy_notice(wiphy, format, args...) \
  5765. dev_notice(&(wiphy)->dev, format, ##args)
  5766. #define wiphy_info(wiphy, format, args...) \
  5767. dev_info(&(wiphy)->dev, format, ##args)
  5768. #define wiphy_debug(wiphy, format, args...) \
  5769. wiphy_printk(KERN_DEBUG, wiphy, format, ##args)
  5770. #define wiphy_dbg(wiphy, format, args...) \
  5771. dev_dbg(&(wiphy)->dev, format, ##args)
  5772. #if defined(VERBOSE_DEBUG)
  5773. #define wiphy_vdbg wiphy_dbg
  5774. #else
  5775. #define wiphy_vdbg(wiphy, format, args...) \
  5776. ({ \
  5777. if (0) \
  5778. wiphy_printk(KERN_DEBUG, wiphy, format, ##args); \
  5779. 0; \
  5780. })
  5781. #endif
  5782. /*
  5783. * wiphy_WARN() acts like wiphy_printk(), but with the key difference
  5784. * of using a WARN/WARN_ON to get the message out, including the
  5785. * file/line information and a backtrace.
  5786. */
  5787. #define wiphy_WARN(wiphy, format, args...) \
  5788. WARN(1, "wiphy: %s\n" format, wiphy_name(wiphy), ##args);
  5789. #endif /* __NET_CFG80211_H */