cfg80211.h 230 KB

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