cfg80211.h 223 KB

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