cfg80211.h 342 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. #ifndef __NET_CFG80211_H
  3. #define __NET_CFG80211_H
  4. /*
  5. * 802.11 device and configuration interface
  6. *
  7. * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net>
  8. * Copyright 2013-2014 Intel Mobile Communications GmbH
  9. * Copyright 2015-2017 Intel Deutschland GmbH
  10. * Copyright (C) 2018-2024 Intel Corporation
  11. */
  12. #include <linux/ethtool.h>
  13. #include <uapi/linux/rfkill.h>
  14. #include <linux/netdevice.h>
  15. #include <linux/debugfs.h>
  16. #include <linux/list.h>
  17. #include <linux/bug.h>
  18. #include <linux/netlink.h>
  19. #include <linux/skbuff.h>
  20. #include <linux/nl80211.h>
  21. #include <linux/if_ether.h>
  22. #include <linux/ieee80211.h>
  23. #include <linux/net.h>
  24. #include <linux/rfkill.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_PSD: Power spectral density (in dBm) is set for this
  73. * channel.
  74. * @IEEE80211_CHAN_RADAR: Radar detection is required on this channel.
  75. * @IEEE80211_CHAN_NO_HT40PLUS: extension channel above this channel
  76. * is not permitted.
  77. * @IEEE80211_CHAN_NO_HT40MINUS: extension channel below this channel
  78. * is not permitted.
  79. * @IEEE80211_CHAN_NO_OFDM: OFDM is not allowed on this channel.
  80. * @IEEE80211_CHAN_NO_80MHZ: If the driver supports 80 MHz on the band,
  81. * this flag indicates that an 80 MHz channel cannot use this
  82. * channel as the control or any of the secondary channels.
  83. * This may be due to the driver or due to regulatory bandwidth
  84. * restrictions.
  85. * @IEEE80211_CHAN_NO_160MHZ: If the driver supports 160 MHz on the band,
  86. * this flag indicates that an 160 MHz channel cannot use this
  87. * channel as the control or any of the secondary channels.
  88. * This may be due to the driver or due to regulatory bandwidth
  89. * restrictions.
  90. * @IEEE80211_CHAN_INDOOR_ONLY: see %NL80211_FREQUENCY_ATTR_INDOOR_ONLY
  91. * @IEEE80211_CHAN_IR_CONCURRENT: see %NL80211_FREQUENCY_ATTR_IR_CONCURRENT
  92. * @IEEE80211_CHAN_NO_20MHZ: 20 MHz bandwidth is not permitted
  93. * on this channel.
  94. * @IEEE80211_CHAN_NO_10MHZ: 10 MHz bandwidth is not permitted
  95. * on this channel.
  96. * @IEEE80211_CHAN_NO_HE: HE operation is not permitted on this channel.
  97. * @IEEE80211_CHAN_1MHZ: 1 MHz bandwidth is permitted
  98. * on this channel.
  99. * @IEEE80211_CHAN_2MHZ: 2 MHz bandwidth is permitted
  100. * on this channel.
  101. * @IEEE80211_CHAN_4MHZ: 4 MHz bandwidth is permitted
  102. * on this channel.
  103. * @IEEE80211_CHAN_8MHZ: 8 MHz bandwidth is permitted
  104. * on this channel.
  105. * @IEEE80211_CHAN_16MHZ: 16 MHz bandwidth is permitted
  106. * on this channel.
  107. * @IEEE80211_CHAN_NO_320MHZ: If the driver supports 320 MHz on the band,
  108. * this flag indicates that a 320 MHz channel cannot use this
  109. * channel as the control or any of the secondary channels.
  110. * This may be due to the driver or due to regulatory bandwidth
  111. * restrictions.
  112. * @IEEE80211_CHAN_NO_EHT: EHT operation is not permitted on this channel.
  113. * @IEEE80211_CHAN_DFS_CONCURRENT: See %NL80211_RRF_DFS_CONCURRENT
  114. * @IEEE80211_CHAN_NO_6GHZ_VLP_CLIENT: Client connection with VLP AP
  115. * not permitted using this channel
  116. * @IEEE80211_CHAN_NO_6GHZ_AFC_CLIENT: Client connection with AFC AP
  117. * not permitted using this channel
  118. * @IEEE80211_CHAN_CAN_MONITOR: This channel can be used for monitor
  119. * mode even in the presence of other (regulatory) restrictions,
  120. * even if it is otherwise disabled.
  121. * @IEEE80211_CHAN_ALLOW_6GHZ_VLP_AP: Allow using this channel for AP operation
  122. * with very low power (VLP), even if otherwise set to NO_IR.
  123. * @IEEE80211_CHAN_ALLOW_20MHZ_ACTIVITY: Allow activity on a 20 MHz channel,
  124. * even if otherwise set to NO_IR.
  125. */
  126. enum ieee80211_channel_flags {
  127. IEEE80211_CHAN_DISABLED = BIT(0),
  128. IEEE80211_CHAN_NO_IR = BIT(1),
  129. IEEE80211_CHAN_PSD = BIT(2),
  130. IEEE80211_CHAN_RADAR = BIT(3),
  131. IEEE80211_CHAN_NO_HT40PLUS = BIT(4),
  132. IEEE80211_CHAN_NO_HT40MINUS = BIT(5),
  133. IEEE80211_CHAN_NO_OFDM = BIT(6),
  134. IEEE80211_CHAN_NO_80MHZ = BIT(7),
  135. IEEE80211_CHAN_NO_160MHZ = BIT(8),
  136. IEEE80211_CHAN_INDOOR_ONLY = BIT(9),
  137. IEEE80211_CHAN_IR_CONCURRENT = BIT(10),
  138. IEEE80211_CHAN_NO_20MHZ = BIT(11),
  139. IEEE80211_CHAN_NO_10MHZ = BIT(12),
  140. IEEE80211_CHAN_NO_HE = BIT(13),
  141. IEEE80211_CHAN_1MHZ = BIT(14),
  142. IEEE80211_CHAN_2MHZ = BIT(15),
  143. IEEE80211_CHAN_4MHZ = BIT(16),
  144. IEEE80211_CHAN_8MHZ = BIT(17),
  145. IEEE80211_CHAN_16MHZ = BIT(18),
  146. IEEE80211_CHAN_NO_320MHZ = BIT(19),
  147. IEEE80211_CHAN_NO_EHT = BIT(20),
  148. IEEE80211_CHAN_DFS_CONCURRENT = BIT(21),
  149. IEEE80211_CHAN_NO_6GHZ_VLP_CLIENT = BIT(22),
  150. IEEE80211_CHAN_NO_6GHZ_AFC_CLIENT = BIT(23),
  151. IEEE80211_CHAN_CAN_MONITOR = BIT(24),
  152. IEEE80211_CHAN_ALLOW_6GHZ_VLP_AP = BIT(25),
  153. IEEE80211_CHAN_ALLOW_20MHZ_ACTIVITY = BIT(26),
  154. };
  155. #define IEEE80211_CHAN_NO_HT40 \
  156. (IEEE80211_CHAN_NO_HT40PLUS | IEEE80211_CHAN_NO_HT40MINUS)
  157. #define IEEE80211_DFS_MIN_CAC_TIME_MS 60000
  158. #define IEEE80211_DFS_MIN_NOP_TIME_MS (30 * 60 * 1000)
  159. /**
  160. * struct ieee80211_channel - channel definition
  161. *
  162. * This structure describes a single channel for use
  163. * with cfg80211.
  164. *
  165. * @center_freq: center frequency in MHz
  166. * @freq_offset: offset from @center_freq, in KHz
  167. * @hw_value: hardware-specific value for the channel
  168. * @flags: channel flags from &enum ieee80211_channel_flags.
  169. * @orig_flags: channel flags at registration time, used by regulatory
  170. * code to support devices with additional restrictions
  171. * @band: band this channel belongs to.
  172. * @max_antenna_gain: maximum antenna gain in dBi
  173. * @max_power: maximum transmission power (in dBm)
  174. * @max_reg_power: maximum regulatory transmission power (in dBm)
  175. * @beacon_found: helper to regulatory code to indicate when a beacon
  176. * has been found on this channel. Use regulatory_hint_found_beacon()
  177. * to enable this, this is useful only on 5 GHz band.
  178. * @orig_mag: internal use
  179. * @orig_mpwr: internal use
  180. * @dfs_state: current state of this channel. Only relevant if radar is required
  181. * on this channel.
  182. * @dfs_state_entered: timestamp (jiffies) when the dfs state was entered.
  183. * @dfs_cac_ms: DFS CAC time in milliseconds, this is valid for DFS channels.
  184. * @psd: power spectral density (in dBm)
  185. */
  186. struct ieee80211_channel {
  187. enum nl80211_band band;
  188. u32 center_freq;
  189. u16 freq_offset;
  190. u16 hw_value;
  191. u32 flags;
  192. int max_antenna_gain;
  193. int max_power;
  194. int max_reg_power;
  195. bool beacon_found;
  196. u32 orig_flags;
  197. int orig_mag, orig_mpwr;
  198. enum nl80211_dfs_state dfs_state;
  199. unsigned long dfs_state_entered;
  200. unsigned int dfs_cac_ms;
  201. s8 psd;
  202. };
  203. /**
  204. * enum ieee80211_rate_flags - rate flags
  205. *
  206. * Hardware/specification flags for rates. These are structured
  207. * in a way that allows using the same bitrate structure for
  208. * different bands/PHY modes.
  209. *
  210. * @IEEE80211_RATE_SHORT_PREAMBLE: Hardware can send with short
  211. * preamble on this bitrate; only relevant in 2.4GHz band and
  212. * with CCK rates.
  213. * @IEEE80211_RATE_MANDATORY_A: This bitrate is a mandatory rate
  214. * when used with 802.11a (on the 5 GHz band); filled by the
  215. * core code when registering the wiphy.
  216. * @IEEE80211_RATE_MANDATORY_B: This bitrate is a mandatory rate
  217. * when used with 802.11b (on the 2.4 GHz band); filled by the
  218. * core code when registering the wiphy.
  219. * @IEEE80211_RATE_MANDATORY_G: This bitrate is a mandatory rate
  220. * when used with 802.11g (on the 2.4 GHz band); filled by the
  221. * core code when registering the wiphy.
  222. * @IEEE80211_RATE_ERP_G: This is an ERP rate in 802.11g mode.
  223. * @IEEE80211_RATE_SUPPORTS_5MHZ: Rate can be used in 5 MHz mode
  224. * @IEEE80211_RATE_SUPPORTS_10MHZ: Rate can be used in 10 MHz mode
  225. */
  226. enum ieee80211_rate_flags {
  227. IEEE80211_RATE_SHORT_PREAMBLE = BIT(0),
  228. IEEE80211_RATE_MANDATORY_A = BIT(1),
  229. IEEE80211_RATE_MANDATORY_B = BIT(2),
  230. IEEE80211_RATE_MANDATORY_G = BIT(3),
  231. IEEE80211_RATE_ERP_G = BIT(4),
  232. IEEE80211_RATE_SUPPORTS_5MHZ = BIT(5),
  233. IEEE80211_RATE_SUPPORTS_10MHZ = BIT(6),
  234. };
  235. /**
  236. * enum ieee80211_bss_type - BSS type filter
  237. *
  238. * @IEEE80211_BSS_TYPE_ESS: Infrastructure BSS
  239. * @IEEE80211_BSS_TYPE_PBSS: Personal BSS
  240. * @IEEE80211_BSS_TYPE_IBSS: Independent BSS
  241. * @IEEE80211_BSS_TYPE_MBSS: Mesh BSS
  242. * @IEEE80211_BSS_TYPE_ANY: Wildcard value for matching any BSS type
  243. */
  244. enum ieee80211_bss_type {
  245. IEEE80211_BSS_TYPE_ESS,
  246. IEEE80211_BSS_TYPE_PBSS,
  247. IEEE80211_BSS_TYPE_IBSS,
  248. IEEE80211_BSS_TYPE_MBSS,
  249. IEEE80211_BSS_TYPE_ANY
  250. };
  251. /**
  252. * enum ieee80211_privacy - BSS privacy filter
  253. *
  254. * @IEEE80211_PRIVACY_ON: privacy bit set
  255. * @IEEE80211_PRIVACY_OFF: privacy bit clear
  256. * @IEEE80211_PRIVACY_ANY: Wildcard value for matching any privacy setting
  257. */
  258. enum ieee80211_privacy {
  259. IEEE80211_PRIVACY_ON,
  260. IEEE80211_PRIVACY_OFF,
  261. IEEE80211_PRIVACY_ANY
  262. };
  263. #define IEEE80211_PRIVACY(x) \
  264. ((x) ? IEEE80211_PRIVACY_ON : IEEE80211_PRIVACY_OFF)
  265. /**
  266. * struct ieee80211_rate - bitrate definition
  267. *
  268. * This structure describes a bitrate that an 802.11 PHY can
  269. * operate with. The two values @hw_value and @hw_value_short
  270. * are only for driver use when pointers to this structure are
  271. * passed around.
  272. *
  273. * @flags: rate-specific flags from &enum ieee80211_rate_flags
  274. * @bitrate: bitrate in units of 100 Kbps
  275. * @hw_value: driver/hardware value for this rate
  276. * @hw_value_short: driver/hardware value for this rate when
  277. * short preamble is used
  278. */
  279. struct ieee80211_rate {
  280. u32 flags;
  281. u16 bitrate;
  282. u16 hw_value, hw_value_short;
  283. };
  284. /**
  285. * struct ieee80211_he_obss_pd - AP settings for spatial reuse
  286. *
  287. * @enable: is the feature enabled.
  288. * @sr_ctrl: The SR Control field of SRP element.
  289. * @non_srg_max_offset: non-SRG maximum tx power offset
  290. * @min_offset: minimal tx power offset an associated station shall use
  291. * @max_offset: maximum tx power offset an associated station shall use
  292. * @bss_color_bitmap: bitmap that indicates the BSS color values used by
  293. * members of the SRG
  294. * @partial_bssid_bitmap: bitmap that indicates the partial BSSID values
  295. * used by members of the SRG
  296. */
  297. struct ieee80211_he_obss_pd {
  298. bool enable;
  299. u8 sr_ctrl;
  300. u8 non_srg_max_offset;
  301. u8 min_offset;
  302. u8 max_offset;
  303. u8 bss_color_bitmap[8];
  304. u8 partial_bssid_bitmap[8];
  305. };
  306. /**
  307. * struct cfg80211_he_bss_color - AP settings for BSS coloring
  308. *
  309. * @color: the current color.
  310. * @enabled: HE BSS color is used
  311. * @partial: define the AID equation.
  312. */
  313. struct cfg80211_he_bss_color {
  314. u8 color;
  315. bool enabled;
  316. bool partial;
  317. };
  318. /**
  319. * struct ieee80211_sta_ht_cap - STA's HT capabilities
  320. *
  321. * This structure describes most essential parameters needed
  322. * to describe 802.11n HT capabilities for an STA.
  323. *
  324. * @ht_supported: is HT supported by the STA
  325. * @cap: HT capabilities map as described in 802.11n spec
  326. * @ampdu_factor: Maximum A-MPDU length factor
  327. * @ampdu_density: Minimum A-MPDU spacing
  328. * @mcs: Supported MCS rates
  329. */
  330. struct ieee80211_sta_ht_cap {
  331. u16 cap; /* use IEEE80211_HT_CAP_ */
  332. bool ht_supported;
  333. u8 ampdu_factor;
  334. u8 ampdu_density;
  335. struct ieee80211_mcs_info mcs;
  336. };
  337. /**
  338. * struct ieee80211_sta_vht_cap - STA's VHT capabilities
  339. *
  340. * This structure describes most essential parameters needed
  341. * to describe 802.11ac VHT capabilities for an STA.
  342. *
  343. * @vht_supported: is VHT supported by the STA
  344. * @cap: VHT capabilities map as described in 802.11ac spec
  345. * @vht_mcs: Supported VHT MCS rates
  346. */
  347. struct ieee80211_sta_vht_cap {
  348. bool vht_supported;
  349. u32 cap; /* use IEEE80211_VHT_CAP_ */
  350. struct ieee80211_vht_mcs_info vht_mcs;
  351. };
  352. #define IEEE80211_HE_PPE_THRES_MAX_LEN 25
  353. /**
  354. * struct ieee80211_sta_he_cap - STA's HE capabilities
  355. *
  356. * This structure describes most essential parameters needed
  357. * to describe 802.11ax HE capabilities for a STA.
  358. *
  359. * @has_he: true iff HE data is valid.
  360. * @he_cap_elem: Fixed portion of the HE capabilities element.
  361. * @he_mcs_nss_supp: The supported NSS/MCS combinations.
  362. * @ppe_thres: Holds the PPE Thresholds data.
  363. */
  364. struct ieee80211_sta_he_cap {
  365. bool has_he;
  366. struct ieee80211_he_cap_elem he_cap_elem;
  367. struct ieee80211_he_mcs_nss_supp he_mcs_nss_supp;
  368. u8 ppe_thres[IEEE80211_HE_PPE_THRES_MAX_LEN];
  369. };
  370. /**
  371. * struct ieee80211_eht_mcs_nss_supp - EHT max supported NSS per MCS
  372. *
  373. * See P802.11be_D1.3 Table 9-401k - "Subfields of the Supported EHT-MCS
  374. * and NSS Set field"
  375. *
  376. * @only_20mhz: MCS/NSS support for 20 MHz-only STA.
  377. * @bw: MCS/NSS support for 80, 160 and 320 MHz
  378. * @bw._80: MCS/NSS support for BW <= 80 MHz
  379. * @bw._160: MCS/NSS support for BW = 160 MHz
  380. * @bw._320: MCS/NSS support for BW = 320 MHz
  381. */
  382. struct ieee80211_eht_mcs_nss_supp {
  383. union {
  384. struct ieee80211_eht_mcs_nss_supp_20mhz_only only_20mhz;
  385. struct {
  386. struct ieee80211_eht_mcs_nss_supp_bw _80;
  387. struct ieee80211_eht_mcs_nss_supp_bw _160;
  388. struct ieee80211_eht_mcs_nss_supp_bw _320;
  389. } __packed bw;
  390. } __packed;
  391. } __packed;
  392. #define IEEE80211_EHT_PPE_THRES_MAX_LEN 32
  393. /**
  394. * struct ieee80211_sta_eht_cap - STA's EHT capabilities
  395. *
  396. * This structure describes most essential parameters needed
  397. * to describe 802.11be EHT capabilities for a STA.
  398. *
  399. * @has_eht: true iff EHT data is valid.
  400. * @eht_cap_elem: Fixed portion of the eht capabilities element.
  401. * @eht_mcs_nss_supp: The supported NSS/MCS combinations.
  402. * @eht_ppe_thres: Holds the PPE Thresholds data.
  403. */
  404. struct ieee80211_sta_eht_cap {
  405. bool has_eht;
  406. struct ieee80211_eht_cap_elem_fixed eht_cap_elem;
  407. struct ieee80211_eht_mcs_nss_supp eht_mcs_nss_supp;
  408. u8 eht_ppe_thres[IEEE80211_EHT_PPE_THRES_MAX_LEN];
  409. };
  410. /* sparse defines __CHECKER__; see Documentation/dev-tools/sparse.rst */
  411. #ifdef __CHECKER__
  412. /*
  413. * This is used to mark the sband->iftype_data pointer which is supposed
  414. * to be an array with special access semantics (per iftype), but a lot
  415. * of code got it wrong in the past, so with this marking sparse will be
  416. * noisy when the pointer is used directly.
  417. */
  418. # define __iftd __attribute__((noderef, address_space(__iftype_data)))
  419. #else
  420. # define __iftd
  421. #endif /* __CHECKER__ */
  422. /**
  423. * struct ieee80211_sband_iftype_data - sband data per interface type
  424. *
  425. * This structure encapsulates sband data that is relevant for the
  426. * interface types defined in @types_mask. Each type in the
  427. * @types_mask must be unique across all instances of iftype_data.
  428. *
  429. * @types_mask: interface types mask
  430. * @he_cap: holds the HE capabilities
  431. * @he_6ghz_capa: HE 6 GHz capabilities, must be filled in for a
  432. * 6 GHz band channel (and 0 may be valid value).
  433. * @eht_cap: STA's EHT capabilities
  434. * @vendor_elems: vendor element(s) to advertise
  435. * @vendor_elems.data: vendor element(s) data
  436. * @vendor_elems.len: vendor element(s) length
  437. */
  438. struct ieee80211_sband_iftype_data {
  439. u16 types_mask;
  440. struct ieee80211_sta_he_cap he_cap;
  441. struct ieee80211_he_6ghz_capa he_6ghz_capa;
  442. struct ieee80211_sta_eht_cap eht_cap;
  443. struct {
  444. const u8 *data;
  445. unsigned int len;
  446. } vendor_elems;
  447. };
  448. /**
  449. * enum ieee80211_edmg_bw_config - allowed channel bandwidth configurations
  450. *
  451. * @IEEE80211_EDMG_BW_CONFIG_4: 2.16GHz
  452. * @IEEE80211_EDMG_BW_CONFIG_5: 2.16GHz and 4.32GHz
  453. * @IEEE80211_EDMG_BW_CONFIG_6: 2.16GHz, 4.32GHz and 6.48GHz
  454. * @IEEE80211_EDMG_BW_CONFIG_7: 2.16GHz, 4.32GHz, 6.48GHz and 8.64GHz
  455. * @IEEE80211_EDMG_BW_CONFIG_8: 2.16GHz and 2.16GHz + 2.16GHz
  456. * @IEEE80211_EDMG_BW_CONFIG_9: 2.16GHz, 4.32GHz and 2.16GHz + 2.16GHz
  457. * @IEEE80211_EDMG_BW_CONFIG_10: 2.16GHz, 4.32GHz, 6.48GHz and 2.16GHz+2.16GHz
  458. * @IEEE80211_EDMG_BW_CONFIG_11: 2.16GHz, 4.32GHz, 6.48GHz, 8.64GHz and
  459. * 2.16GHz+2.16GHz
  460. * @IEEE80211_EDMG_BW_CONFIG_12: 2.16GHz, 2.16GHz + 2.16GHz and
  461. * 4.32GHz + 4.32GHz
  462. * @IEEE80211_EDMG_BW_CONFIG_13: 2.16GHz, 4.32GHz, 2.16GHz + 2.16GHz and
  463. * 4.32GHz + 4.32GHz
  464. * @IEEE80211_EDMG_BW_CONFIG_14: 2.16GHz, 4.32GHz, 6.48GHz, 2.16GHz + 2.16GHz
  465. * and 4.32GHz + 4.32GHz
  466. * @IEEE80211_EDMG_BW_CONFIG_15: 2.16GHz, 4.32GHz, 6.48GHz, 8.64GHz,
  467. * 2.16GHz + 2.16GHz and 4.32GHz + 4.32GHz
  468. */
  469. enum ieee80211_edmg_bw_config {
  470. IEEE80211_EDMG_BW_CONFIG_4 = 4,
  471. IEEE80211_EDMG_BW_CONFIG_5 = 5,
  472. IEEE80211_EDMG_BW_CONFIG_6 = 6,
  473. IEEE80211_EDMG_BW_CONFIG_7 = 7,
  474. IEEE80211_EDMG_BW_CONFIG_8 = 8,
  475. IEEE80211_EDMG_BW_CONFIG_9 = 9,
  476. IEEE80211_EDMG_BW_CONFIG_10 = 10,
  477. IEEE80211_EDMG_BW_CONFIG_11 = 11,
  478. IEEE80211_EDMG_BW_CONFIG_12 = 12,
  479. IEEE80211_EDMG_BW_CONFIG_13 = 13,
  480. IEEE80211_EDMG_BW_CONFIG_14 = 14,
  481. IEEE80211_EDMG_BW_CONFIG_15 = 15,
  482. };
  483. /**
  484. * struct ieee80211_edmg - EDMG configuration
  485. *
  486. * This structure describes most essential parameters needed
  487. * to describe 802.11ay EDMG configuration
  488. *
  489. * @channels: bitmap that indicates the 2.16 GHz channel(s)
  490. * that are allowed to be used for transmissions.
  491. * Bit 0 indicates channel 1, bit 1 indicates channel 2, etc.
  492. * Set to 0 indicate EDMG not supported.
  493. * @bw_config: Channel BW Configuration subfield encodes
  494. * the allowed channel bandwidth configurations
  495. */
  496. struct ieee80211_edmg {
  497. u8 channels;
  498. enum ieee80211_edmg_bw_config bw_config;
  499. };
  500. /**
  501. * struct ieee80211_sta_s1g_cap - STA's S1G capabilities
  502. *
  503. * This structure describes most essential parameters needed
  504. * to describe 802.11ah S1G capabilities for a STA.
  505. *
  506. * @s1g: is STA an S1G STA
  507. * @cap: S1G capabilities information
  508. * @nss_mcs: Supported NSS MCS set
  509. */
  510. struct ieee80211_sta_s1g_cap {
  511. bool s1g;
  512. u8 cap[10]; /* use S1G_CAPAB_ */
  513. u8 nss_mcs[5];
  514. };
  515. /**
  516. * struct ieee80211_supported_band - frequency band definition
  517. *
  518. * This structure describes a frequency band a wiphy
  519. * is able to operate in.
  520. *
  521. * @channels: Array of channels the hardware can operate with
  522. * in this band.
  523. * @band: the band this structure represents
  524. * @n_channels: Number of channels in @channels
  525. * @bitrates: Array of bitrates the hardware can operate with
  526. * in this band. Must be sorted to give a valid "supported
  527. * rates" IE, i.e. CCK rates first, then OFDM.
  528. * @n_bitrates: Number of bitrates in @bitrates
  529. * @ht_cap: HT capabilities in this band
  530. * @vht_cap: VHT capabilities in this band
  531. * @s1g_cap: S1G capabilities in this band
  532. * @edmg_cap: EDMG capabilities in this band
  533. * @s1g_cap: S1G capabilities in this band (S1B band only, of course)
  534. * @n_iftype_data: number of iftype data entries
  535. * @iftype_data: interface type data entries. Note that the bits in
  536. * @types_mask inside this structure cannot overlap (i.e. only
  537. * one occurrence of each type is allowed across all instances of
  538. * iftype_data).
  539. */
  540. struct ieee80211_supported_band {
  541. struct ieee80211_channel *channels;
  542. struct ieee80211_rate *bitrates;
  543. enum nl80211_band band;
  544. int n_channels;
  545. int n_bitrates;
  546. struct ieee80211_sta_ht_cap ht_cap;
  547. struct ieee80211_sta_vht_cap vht_cap;
  548. struct ieee80211_sta_s1g_cap s1g_cap;
  549. struct ieee80211_edmg edmg_cap;
  550. u16 n_iftype_data;
  551. const struct ieee80211_sband_iftype_data __iftd *iftype_data;
  552. };
  553. /**
  554. * _ieee80211_set_sband_iftype_data - set sband iftype data array
  555. * @sband: the sband to initialize
  556. * @iftd: the iftype data array pointer
  557. * @n_iftd: the length of the iftype data array
  558. *
  559. * Set the sband iftype data array; use this where the length cannot
  560. * be derived from the ARRAY_SIZE() of the argument, but prefer
  561. * ieee80211_set_sband_iftype_data() where it can be used.
  562. */
  563. static inline void
  564. _ieee80211_set_sband_iftype_data(struct ieee80211_supported_band *sband,
  565. const struct ieee80211_sband_iftype_data *iftd,
  566. u16 n_iftd)
  567. {
  568. sband->iftype_data = (const void __iftd __force *)iftd;
  569. sband->n_iftype_data = n_iftd;
  570. }
  571. /**
  572. * ieee80211_set_sband_iftype_data - set sband iftype data array
  573. * @sband: the sband to initialize
  574. * @iftd: the iftype data array
  575. */
  576. #define ieee80211_set_sband_iftype_data(sband, iftd) \
  577. _ieee80211_set_sband_iftype_data(sband, iftd, ARRAY_SIZE(iftd))
  578. /**
  579. * for_each_sband_iftype_data - iterate sband iftype data entries
  580. * @sband: the sband whose iftype_data array to iterate
  581. * @i: iterator counter
  582. * @iftd: iftype data pointer to set
  583. */
  584. #define for_each_sband_iftype_data(sband, i, iftd) \
  585. for (i = 0, iftd = (const void __force *)&(sband)->iftype_data[i]; \
  586. i < (sband)->n_iftype_data; \
  587. i++, iftd = (const void __force *)&(sband)->iftype_data[i])
  588. /**
  589. * ieee80211_get_sband_iftype_data - return sband data for a given iftype
  590. * @sband: the sband to search for the STA on
  591. * @iftype: enum nl80211_iftype
  592. *
  593. * Return: pointer to struct ieee80211_sband_iftype_data, or NULL is none found
  594. */
  595. static inline const struct ieee80211_sband_iftype_data *
  596. ieee80211_get_sband_iftype_data(const struct ieee80211_supported_band *sband,
  597. u8 iftype)
  598. {
  599. const struct ieee80211_sband_iftype_data *data;
  600. int i;
  601. if (WARN_ON(iftype >= NUM_NL80211_IFTYPES))
  602. return NULL;
  603. if (iftype == NL80211_IFTYPE_AP_VLAN)
  604. iftype = NL80211_IFTYPE_AP;
  605. for_each_sband_iftype_data(sband, i, data) {
  606. if (data->types_mask & BIT(iftype))
  607. return data;
  608. }
  609. return NULL;
  610. }
  611. /**
  612. * ieee80211_get_he_iftype_cap - return HE capabilities for an sband's iftype
  613. * @sband: the sband to search for the iftype on
  614. * @iftype: enum nl80211_iftype
  615. *
  616. * Return: pointer to the struct ieee80211_sta_he_cap, or NULL is none found
  617. */
  618. static inline const struct ieee80211_sta_he_cap *
  619. ieee80211_get_he_iftype_cap(const struct ieee80211_supported_band *sband,
  620. u8 iftype)
  621. {
  622. const struct ieee80211_sband_iftype_data *data =
  623. ieee80211_get_sband_iftype_data(sband, iftype);
  624. if (data && data->he_cap.has_he)
  625. return &data->he_cap;
  626. return NULL;
  627. }
  628. /**
  629. * ieee80211_get_he_6ghz_capa - return HE 6 GHz capabilities
  630. * @sband: the sband to search for the STA on
  631. * @iftype: the iftype to search for
  632. *
  633. * Return: the 6GHz capabilities
  634. */
  635. static inline __le16
  636. ieee80211_get_he_6ghz_capa(const struct ieee80211_supported_band *sband,
  637. enum nl80211_iftype iftype)
  638. {
  639. const struct ieee80211_sband_iftype_data *data =
  640. ieee80211_get_sband_iftype_data(sband, iftype);
  641. if (WARN_ON(!data || !data->he_cap.has_he))
  642. return 0;
  643. return data->he_6ghz_capa.capa;
  644. }
  645. /**
  646. * ieee80211_get_eht_iftype_cap - return ETH capabilities for an sband's iftype
  647. * @sband: the sband to search for the iftype on
  648. * @iftype: enum nl80211_iftype
  649. *
  650. * Return: pointer to the struct ieee80211_sta_eht_cap, or NULL is none found
  651. */
  652. static inline const struct ieee80211_sta_eht_cap *
  653. ieee80211_get_eht_iftype_cap(const struct ieee80211_supported_band *sband,
  654. enum nl80211_iftype iftype)
  655. {
  656. const struct ieee80211_sband_iftype_data *data =
  657. ieee80211_get_sband_iftype_data(sband, iftype);
  658. if (data && data->eht_cap.has_eht)
  659. return &data->eht_cap;
  660. return NULL;
  661. }
  662. /**
  663. * wiphy_read_of_freq_limits - read frequency limits from device tree
  664. *
  665. * @wiphy: the wireless device to get extra limits for
  666. *
  667. * Some devices may have extra limitations specified in DT. This may be useful
  668. * for chipsets that normally support more bands but are limited due to board
  669. * design (e.g. by antennas or external power amplifier).
  670. *
  671. * This function reads info from DT and uses it to *modify* channels (disable
  672. * unavailable ones). It's usually a *bad* idea to use it in drivers with
  673. * shared channel data as DT limitations are device specific. You should make
  674. * sure to call it only if channels in wiphy are copied and can be modified
  675. * without affecting other devices.
  676. *
  677. * As this function access device node it has to be called after set_wiphy_dev.
  678. * It also modifies channels so they have to be set first.
  679. * If using this helper, call it before wiphy_register().
  680. */
  681. #ifdef CONFIG_OF
  682. void wiphy_read_of_freq_limits(struct wiphy *wiphy);
  683. #else /* CONFIG_OF */
  684. static inline void wiphy_read_of_freq_limits(struct wiphy *wiphy)
  685. {
  686. }
  687. #endif /* !CONFIG_OF */
  688. /*
  689. * Wireless hardware/device configuration structures and methods
  690. */
  691. /**
  692. * DOC: Actions and configuration
  693. *
  694. * Each wireless device and each virtual interface offer a set of configuration
  695. * operations and other actions that are invoked by userspace. Each of these
  696. * actions is described in the operations structure, and the parameters these
  697. * operations use are described separately.
  698. *
  699. * Additionally, some operations are asynchronous and expect to get status
  700. * information via some functions that drivers need to call.
  701. *
  702. * Scanning and BSS list handling with its associated functionality is described
  703. * in a separate chapter.
  704. */
  705. #define VHT_MUMIMO_GROUPS_DATA_LEN (WLAN_MEMBERSHIP_LEN +\
  706. WLAN_USER_POSITION_LEN)
  707. /**
  708. * struct vif_params - describes virtual interface parameters
  709. * @flags: monitor interface flags, unchanged if 0, otherwise
  710. * %MONITOR_FLAG_CHANGED will be set
  711. * @use_4addr: use 4-address frames
  712. * @macaddr: address to use for this virtual interface.
  713. * If this parameter is set to zero address the driver may
  714. * determine the address as needed.
  715. * This feature is only fully supported by drivers that enable the
  716. * %NL80211_FEATURE_MAC_ON_CREATE flag. Others may support creating
  717. ** only p2p devices with specified MAC.
  718. * @vht_mumimo_groups: MU-MIMO groupID, used for monitoring MU-MIMO packets
  719. * belonging to that MU-MIMO groupID; %NULL if not changed
  720. * @vht_mumimo_follow_addr: MU-MIMO follow address, used for monitoring
  721. * MU-MIMO packets going to the specified station; %NULL if not changed
  722. */
  723. struct vif_params {
  724. u32 flags;
  725. int use_4addr;
  726. u8 macaddr[ETH_ALEN];
  727. const u8 *vht_mumimo_groups;
  728. const u8 *vht_mumimo_follow_addr;
  729. };
  730. /**
  731. * struct key_params - key information
  732. *
  733. * Information about a key
  734. *
  735. * @key: key material
  736. * @key_len: length of key material
  737. * @cipher: cipher suite selector
  738. * @seq: sequence counter (IV/PN) for TKIP and CCMP keys, only used
  739. * with the get_key() callback, must be in little endian,
  740. * length given by @seq_len.
  741. * @seq_len: length of @seq.
  742. * @vlan_id: vlan_id for VLAN group key (if nonzero)
  743. * @mode: key install mode (RX_TX, NO_TX or SET_TX)
  744. */
  745. struct key_params {
  746. const u8 *key;
  747. const u8 *seq;
  748. int key_len;
  749. int seq_len;
  750. u16 vlan_id;
  751. u32 cipher;
  752. enum nl80211_key_mode mode;
  753. };
  754. /**
  755. * struct cfg80211_chan_def - channel definition
  756. * @chan: the (control) channel
  757. * @width: channel width
  758. * @center_freq1: center frequency of first segment
  759. * @center_freq2: center frequency of second segment
  760. * (only with 80+80 MHz)
  761. * @edmg: define the EDMG channels configuration.
  762. * If edmg is requested (i.e. the .channels member is non-zero),
  763. * chan will define the primary channel and all other
  764. * parameters are ignored.
  765. * @freq1_offset: offset from @center_freq1, in KHz
  766. * @punctured: mask of the punctured 20 MHz subchannels, with
  767. * bits turned on being disabled (punctured); numbered
  768. * from lower to higher frequency (like in the spec)
  769. */
  770. struct cfg80211_chan_def {
  771. struct ieee80211_channel *chan;
  772. enum nl80211_chan_width width;
  773. u32 center_freq1;
  774. u32 center_freq2;
  775. struct ieee80211_edmg edmg;
  776. u16 freq1_offset;
  777. u16 punctured;
  778. };
  779. /*
  780. * cfg80211_bitrate_mask - masks for bitrate control
  781. */
  782. struct cfg80211_bitrate_mask {
  783. struct {
  784. u32 legacy;
  785. u8 ht_mcs[IEEE80211_HT_MCS_MASK_LEN];
  786. u16 vht_mcs[NL80211_VHT_NSS_MAX];
  787. u16 he_mcs[NL80211_HE_NSS_MAX];
  788. enum nl80211_txrate_gi gi;
  789. enum nl80211_he_gi he_gi;
  790. enum nl80211_he_ltf he_ltf;
  791. } control[NUM_NL80211_BANDS];
  792. };
  793. /**
  794. * struct cfg80211_tid_cfg - TID specific configuration
  795. * @config_override: Flag to notify driver to reset TID configuration
  796. * of the peer.
  797. * @tids: bitmap of TIDs to modify
  798. * @mask: bitmap of attributes indicating which parameter changed,
  799. * similar to &nl80211_tid_config_supp.
  800. * @noack: noack configuration value for the TID
  801. * @retry_long: retry count value
  802. * @retry_short: retry count value
  803. * @ampdu: Enable/Disable MPDU aggregation
  804. * @rtscts: Enable/Disable RTS/CTS
  805. * @amsdu: Enable/Disable MSDU aggregation
  806. * @txrate_type: Tx bitrate mask type
  807. * @txrate_mask: Tx bitrate to be applied for the TID
  808. */
  809. struct cfg80211_tid_cfg {
  810. bool config_override;
  811. u8 tids;
  812. u64 mask;
  813. enum nl80211_tid_config noack;
  814. u8 retry_long, retry_short;
  815. enum nl80211_tid_config ampdu;
  816. enum nl80211_tid_config rtscts;
  817. enum nl80211_tid_config amsdu;
  818. enum nl80211_tx_rate_setting txrate_type;
  819. struct cfg80211_bitrate_mask txrate_mask;
  820. };
  821. /**
  822. * struct cfg80211_tid_config - TID configuration
  823. * @peer: Station's MAC address
  824. * @n_tid_conf: Number of TID specific configurations to be applied
  825. * @tid_conf: Configuration change info
  826. */
  827. struct cfg80211_tid_config {
  828. const u8 *peer;
  829. u32 n_tid_conf;
  830. struct cfg80211_tid_cfg tid_conf[] __counted_by(n_tid_conf);
  831. };
  832. /**
  833. * struct cfg80211_fils_aad - FILS AAD data
  834. * @macaddr: STA MAC address
  835. * @kek: FILS KEK
  836. * @kek_len: FILS KEK length
  837. * @snonce: STA Nonce
  838. * @anonce: AP Nonce
  839. */
  840. struct cfg80211_fils_aad {
  841. const u8 *macaddr;
  842. const u8 *kek;
  843. u8 kek_len;
  844. const u8 *snonce;
  845. const u8 *anonce;
  846. };
  847. /**
  848. * struct cfg80211_set_hw_timestamp - enable/disable HW timestamping
  849. * @macaddr: peer MAC address. NULL to enable/disable HW timestamping for all
  850. * addresses.
  851. * @enable: if set, enable HW timestamping for the specified MAC address.
  852. * Otherwise disable HW timestamping for the specified MAC address.
  853. */
  854. struct cfg80211_set_hw_timestamp {
  855. const u8 *macaddr;
  856. bool enable;
  857. };
  858. /**
  859. * cfg80211_get_chandef_type - return old channel type from chandef
  860. * @chandef: the channel definition
  861. *
  862. * Return: The old channel type (NOHT, HT20, HT40+/-) from a given
  863. * chandef, which must have a bandwidth allowing this conversion.
  864. */
  865. static inline enum nl80211_channel_type
  866. cfg80211_get_chandef_type(const struct cfg80211_chan_def *chandef)
  867. {
  868. switch (chandef->width) {
  869. case NL80211_CHAN_WIDTH_20_NOHT:
  870. return NL80211_CHAN_NO_HT;
  871. case NL80211_CHAN_WIDTH_20:
  872. return NL80211_CHAN_HT20;
  873. case NL80211_CHAN_WIDTH_40:
  874. if (chandef->center_freq1 > chandef->chan->center_freq)
  875. return NL80211_CHAN_HT40PLUS;
  876. return NL80211_CHAN_HT40MINUS;
  877. default:
  878. WARN_ON(1);
  879. return NL80211_CHAN_NO_HT;
  880. }
  881. }
  882. /**
  883. * cfg80211_chandef_create - create channel definition using channel type
  884. * @chandef: the channel definition struct to fill
  885. * @channel: the control channel
  886. * @chantype: the channel type
  887. *
  888. * Given a channel type, create a channel definition.
  889. */
  890. void cfg80211_chandef_create(struct cfg80211_chan_def *chandef,
  891. struct ieee80211_channel *channel,
  892. enum nl80211_channel_type chantype);
  893. /**
  894. * cfg80211_chandef_identical - check if two channel definitions are identical
  895. * @chandef1: first channel definition
  896. * @chandef2: second channel definition
  897. *
  898. * Return: %true if the channels defined by the channel definitions are
  899. * identical, %false otherwise.
  900. */
  901. static inline bool
  902. cfg80211_chandef_identical(const struct cfg80211_chan_def *chandef1,
  903. const struct cfg80211_chan_def *chandef2)
  904. {
  905. return (chandef1->chan == chandef2->chan &&
  906. chandef1->width == chandef2->width &&
  907. chandef1->center_freq1 == chandef2->center_freq1 &&
  908. chandef1->freq1_offset == chandef2->freq1_offset &&
  909. chandef1->center_freq2 == chandef2->center_freq2 &&
  910. chandef1->punctured == chandef2->punctured);
  911. }
  912. /**
  913. * cfg80211_chandef_is_edmg - check if chandef represents an EDMG channel
  914. *
  915. * @chandef: the channel definition
  916. *
  917. * Return: %true if EDMG defined, %false otherwise.
  918. */
  919. static inline bool
  920. cfg80211_chandef_is_edmg(const struct cfg80211_chan_def *chandef)
  921. {
  922. return chandef->edmg.channels || chandef->edmg.bw_config;
  923. }
  924. /**
  925. * cfg80211_chandef_compatible - check if two channel definitions are compatible
  926. * @chandef1: first channel definition
  927. * @chandef2: second channel definition
  928. *
  929. * Return: %NULL if the given channel definitions are incompatible,
  930. * chandef1 or chandef2 otherwise.
  931. */
  932. const struct cfg80211_chan_def *
  933. cfg80211_chandef_compatible(const struct cfg80211_chan_def *chandef1,
  934. const struct cfg80211_chan_def *chandef2);
  935. /**
  936. * nl80211_chan_width_to_mhz - get the channel width in MHz
  937. * @chan_width: the channel width from &enum nl80211_chan_width
  938. *
  939. * Return: channel width in MHz if the chan_width from &enum nl80211_chan_width
  940. * is valid. -1 otherwise.
  941. */
  942. int nl80211_chan_width_to_mhz(enum nl80211_chan_width chan_width);
  943. /**
  944. * cfg80211_chandef_valid - check if a channel definition is valid
  945. * @chandef: the channel definition to check
  946. * Return: %true if the channel definition is valid. %false otherwise.
  947. */
  948. bool cfg80211_chandef_valid(const struct cfg80211_chan_def *chandef);
  949. /**
  950. * cfg80211_chandef_usable - check if secondary channels can be used
  951. * @wiphy: the wiphy to validate against
  952. * @chandef: the channel definition to check
  953. * @prohibited_flags: the regulatory channel flags that must not be set
  954. * Return: %true if secondary channels are usable. %false otherwise.
  955. */
  956. bool cfg80211_chandef_usable(struct wiphy *wiphy,
  957. const struct cfg80211_chan_def *chandef,
  958. u32 prohibited_flags);
  959. /**
  960. * cfg80211_chandef_dfs_required - checks if radar detection is required
  961. * @wiphy: the wiphy to validate against
  962. * @chandef: the channel definition to check
  963. * @iftype: the interface type as specified in &enum nl80211_iftype
  964. * Returns:
  965. * 1 if radar detection is required, 0 if it is not, < 0 on error
  966. */
  967. int cfg80211_chandef_dfs_required(struct wiphy *wiphy,
  968. const struct cfg80211_chan_def *chandef,
  969. enum nl80211_iftype iftype);
  970. /**
  971. * cfg80211_chandef_dfs_usable - checks if chandef is DFS usable and we
  972. * can/need start CAC on such channel
  973. * @wiphy: the wiphy to validate against
  974. * @chandef: the channel definition to check
  975. *
  976. * Return: true if all channels available and at least
  977. * one channel requires CAC (NL80211_DFS_USABLE)
  978. */
  979. bool cfg80211_chandef_dfs_usable(struct wiphy *wiphy,
  980. const struct cfg80211_chan_def *chandef);
  981. /**
  982. * cfg80211_chandef_dfs_cac_time - get the DFS CAC time (in ms) for given
  983. * channel definition
  984. * @wiphy: the wiphy to validate against
  985. * @chandef: the channel definition to check
  986. *
  987. * Returns: DFS CAC time (in ms) which applies for this channel definition
  988. */
  989. unsigned int
  990. cfg80211_chandef_dfs_cac_time(struct wiphy *wiphy,
  991. const struct cfg80211_chan_def *chandef);
  992. /**
  993. * cfg80211_chandef_primary - calculate primary 40/80/160 MHz freq
  994. * @chandef: chandef to calculate for
  995. * @primary_chan_width: primary channel width to calculate center for
  996. * @punctured: punctured sub-channel bitmap, will be recalculated
  997. * according to the new bandwidth, can be %NULL
  998. *
  999. * Returns: the primary 40/80/160 MHz channel center frequency, or -1
  1000. * for errors, updating the punctured bitmap
  1001. */
  1002. int cfg80211_chandef_primary(const struct cfg80211_chan_def *chandef,
  1003. enum nl80211_chan_width primary_chan_width,
  1004. u16 *punctured);
  1005. /**
  1006. * nl80211_send_chandef - sends the channel definition.
  1007. * @msg: the msg to send channel definition
  1008. * @chandef: the channel definition to check
  1009. *
  1010. * Returns: 0 if sent the channel definition to msg, < 0 on error
  1011. **/
  1012. int nl80211_send_chandef(struct sk_buff *msg, const struct cfg80211_chan_def *chandef);
  1013. /**
  1014. * ieee80211_chanwidth_rate_flags - return rate flags for channel width
  1015. * @width: the channel width of the channel
  1016. *
  1017. * In some channel types, not all rates may be used - for example CCK
  1018. * rates may not be used in 5/10 MHz channels.
  1019. *
  1020. * Returns: rate flags which apply for this channel width
  1021. */
  1022. static inline enum ieee80211_rate_flags
  1023. ieee80211_chanwidth_rate_flags(enum nl80211_chan_width width)
  1024. {
  1025. switch (width) {
  1026. case NL80211_CHAN_WIDTH_5:
  1027. return IEEE80211_RATE_SUPPORTS_5MHZ;
  1028. case NL80211_CHAN_WIDTH_10:
  1029. return IEEE80211_RATE_SUPPORTS_10MHZ;
  1030. default:
  1031. break;
  1032. }
  1033. return 0;
  1034. }
  1035. /**
  1036. * ieee80211_chandef_rate_flags - returns rate flags for a channel
  1037. * @chandef: channel definition for the channel
  1038. *
  1039. * See ieee80211_chanwidth_rate_flags().
  1040. *
  1041. * Returns: rate flags which apply for this channel
  1042. */
  1043. static inline enum ieee80211_rate_flags
  1044. ieee80211_chandef_rate_flags(struct cfg80211_chan_def *chandef)
  1045. {
  1046. return ieee80211_chanwidth_rate_flags(chandef->width);
  1047. }
  1048. /**
  1049. * ieee80211_chandef_max_power - maximum transmission power for the chandef
  1050. *
  1051. * In some regulations, the transmit power may depend on the configured channel
  1052. * bandwidth which may be defined as dBm/MHz. This function returns the actual
  1053. * max_power for non-standard (20 MHz) channels.
  1054. *
  1055. * @chandef: channel definition for the channel
  1056. *
  1057. * Returns: maximum allowed transmission power in dBm for the chandef
  1058. */
  1059. static inline int
  1060. ieee80211_chandef_max_power(struct cfg80211_chan_def *chandef)
  1061. {
  1062. switch (chandef->width) {
  1063. case NL80211_CHAN_WIDTH_5:
  1064. return min(chandef->chan->max_reg_power - 6,
  1065. chandef->chan->max_power);
  1066. case NL80211_CHAN_WIDTH_10:
  1067. return min(chandef->chan->max_reg_power - 3,
  1068. chandef->chan->max_power);
  1069. default:
  1070. break;
  1071. }
  1072. return chandef->chan->max_power;
  1073. }
  1074. /**
  1075. * cfg80211_any_usable_channels - check for usable channels
  1076. * @wiphy: the wiphy to check for
  1077. * @band_mask: which bands to check on
  1078. * @prohibited_flags: which channels to not consider usable,
  1079. * %IEEE80211_CHAN_DISABLED is always taken into account
  1080. *
  1081. * Return: %true if usable channels found, %false otherwise
  1082. */
  1083. bool cfg80211_any_usable_channels(struct wiphy *wiphy,
  1084. unsigned long band_mask,
  1085. u32 prohibited_flags);
  1086. /**
  1087. * enum survey_info_flags - survey information flags
  1088. *
  1089. * @SURVEY_INFO_NOISE_DBM: noise (in dBm) was filled in
  1090. * @SURVEY_INFO_IN_USE: channel is currently being used
  1091. * @SURVEY_INFO_TIME: active time (in ms) was filled in
  1092. * @SURVEY_INFO_TIME_BUSY: busy time was filled in
  1093. * @SURVEY_INFO_TIME_EXT_BUSY: extension channel busy time was filled in
  1094. * @SURVEY_INFO_TIME_RX: receive time was filled in
  1095. * @SURVEY_INFO_TIME_TX: transmit time was filled in
  1096. * @SURVEY_INFO_TIME_SCAN: scan time was filled in
  1097. * @SURVEY_INFO_TIME_BSS_RX: local BSS receive time was filled in
  1098. *
  1099. * Used by the driver to indicate which info in &struct survey_info
  1100. * it has filled in during the get_survey().
  1101. */
  1102. enum survey_info_flags {
  1103. SURVEY_INFO_NOISE_DBM = BIT(0),
  1104. SURVEY_INFO_IN_USE = BIT(1),
  1105. SURVEY_INFO_TIME = BIT(2),
  1106. SURVEY_INFO_TIME_BUSY = BIT(3),
  1107. SURVEY_INFO_TIME_EXT_BUSY = BIT(4),
  1108. SURVEY_INFO_TIME_RX = BIT(5),
  1109. SURVEY_INFO_TIME_TX = BIT(6),
  1110. SURVEY_INFO_TIME_SCAN = BIT(7),
  1111. SURVEY_INFO_TIME_BSS_RX = BIT(8),
  1112. };
  1113. /**
  1114. * struct survey_info - channel survey response
  1115. *
  1116. * @channel: the channel this survey record reports, may be %NULL for a single
  1117. * record to report global statistics
  1118. * @filled: bitflag of flags from &enum survey_info_flags
  1119. * @noise: channel noise in dBm. This and all following fields are
  1120. * optional
  1121. * @time: amount of time in ms the radio was turn on (on the channel)
  1122. * @time_busy: amount of time the primary channel was sensed busy
  1123. * @time_ext_busy: amount of time the extension channel was sensed busy
  1124. * @time_rx: amount of time the radio spent receiving data
  1125. * @time_tx: amount of time the radio spent transmitting data
  1126. * @time_scan: amount of time the radio spent for scanning
  1127. * @time_bss_rx: amount of time the radio spent receiving data on a local BSS
  1128. *
  1129. * Used by dump_survey() to report back per-channel survey information.
  1130. *
  1131. * This structure can later be expanded with things like
  1132. * channel duty cycle etc.
  1133. */
  1134. struct survey_info {
  1135. struct ieee80211_channel *channel;
  1136. u64 time;
  1137. u64 time_busy;
  1138. u64 time_ext_busy;
  1139. u64 time_rx;
  1140. u64 time_tx;
  1141. u64 time_scan;
  1142. u64 time_bss_rx;
  1143. u32 filled;
  1144. s8 noise;
  1145. };
  1146. #define CFG80211_MAX_NUM_AKM_SUITES 10
  1147. /**
  1148. * struct cfg80211_crypto_settings - Crypto settings
  1149. * @wpa_versions: indicates which, if any, WPA versions are enabled
  1150. * (from enum nl80211_wpa_versions)
  1151. * @cipher_group: group key cipher suite (or 0 if unset)
  1152. * @n_ciphers_pairwise: number of AP supported unicast ciphers
  1153. * @ciphers_pairwise: unicast key cipher suites
  1154. * @n_akm_suites: number of AKM suites
  1155. * @akm_suites: AKM suites
  1156. * @control_port: Whether user space controls IEEE 802.1X port, i.e.,
  1157. * sets/clears %NL80211_STA_FLAG_AUTHORIZED. If true, the driver is
  1158. * required to assume that the port is unauthorized until authorized by
  1159. * user space. Otherwise, port is marked authorized by default.
  1160. * @control_port_ethertype: the control port protocol that should be
  1161. * allowed through even on unauthorized ports
  1162. * @control_port_no_encrypt: TRUE to prevent encryption of control port
  1163. * protocol frames.
  1164. * @control_port_over_nl80211: TRUE if userspace expects to exchange control
  1165. * port frames over NL80211 instead of the network interface.
  1166. * @control_port_no_preauth: disables pre-auth rx over the nl80211 control
  1167. * port for mac80211
  1168. * @psk: PSK (for devices supporting 4-way-handshake offload)
  1169. * @sae_pwd: password for SAE authentication (for devices supporting SAE
  1170. * offload)
  1171. * @sae_pwd_len: length of SAE password (for devices supporting SAE offload)
  1172. * @sae_pwe: The mechanisms allowed for SAE PWE derivation:
  1173. *
  1174. * NL80211_SAE_PWE_UNSPECIFIED
  1175. * Not-specified, used to indicate userspace did not specify any
  1176. * preference. The driver should follow its internal policy in
  1177. * such a scenario.
  1178. *
  1179. * NL80211_SAE_PWE_HUNT_AND_PECK
  1180. * Allow hunting-and-pecking loop only
  1181. *
  1182. * NL80211_SAE_PWE_HASH_TO_ELEMENT
  1183. * Allow hash-to-element only
  1184. *
  1185. * NL80211_SAE_PWE_BOTH
  1186. * Allow either hunting-and-pecking loop or hash-to-element
  1187. */
  1188. struct cfg80211_crypto_settings {
  1189. u32 wpa_versions;
  1190. u32 cipher_group;
  1191. int n_ciphers_pairwise;
  1192. u32 ciphers_pairwise[NL80211_MAX_NR_CIPHER_SUITES];
  1193. int n_akm_suites;
  1194. u32 akm_suites[CFG80211_MAX_NUM_AKM_SUITES];
  1195. bool control_port;
  1196. __be16 control_port_ethertype;
  1197. bool control_port_no_encrypt;
  1198. bool control_port_over_nl80211;
  1199. bool control_port_no_preauth;
  1200. const u8 *psk;
  1201. const u8 *sae_pwd;
  1202. u8 sae_pwd_len;
  1203. enum nl80211_sae_pwe_mechanism sae_pwe;
  1204. };
  1205. /**
  1206. * struct cfg80211_mbssid_config - AP settings for multi bssid
  1207. *
  1208. * @tx_wdev: pointer to the transmitted interface in the MBSSID set
  1209. * @index: index of this AP in the multi bssid group.
  1210. * @ema: set to true if the beacons should be sent out in EMA mode.
  1211. */
  1212. struct cfg80211_mbssid_config {
  1213. struct wireless_dev *tx_wdev;
  1214. u8 index;
  1215. bool ema;
  1216. };
  1217. /**
  1218. * struct cfg80211_mbssid_elems - Multiple BSSID elements
  1219. *
  1220. * @cnt: Number of elements in array %elems.
  1221. *
  1222. * @elem: Array of multiple BSSID element(s) to be added into Beacon frames.
  1223. * @elem.data: Data for multiple BSSID elements.
  1224. * @elem.len: Length of data.
  1225. */
  1226. struct cfg80211_mbssid_elems {
  1227. u8 cnt;
  1228. struct {
  1229. const u8 *data;
  1230. size_t len;
  1231. } elem[] __counted_by(cnt);
  1232. };
  1233. /**
  1234. * struct cfg80211_rnr_elems - Reduced neighbor report (RNR) elements
  1235. *
  1236. * @cnt: Number of elements in array %elems.
  1237. *
  1238. * @elem: Array of RNR element(s) to be added into Beacon frames.
  1239. * @elem.data: Data for RNR elements.
  1240. * @elem.len: Length of data.
  1241. */
  1242. struct cfg80211_rnr_elems {
  1243. u8 cnt;
  1244. struct {
  1245. const u8 *data;
  1246. size_t len;
  1247. } elem[] __counted_by(cnt);
  1248. };
  1249. /**
  1250. * struct cfg80211_beacon_data - beacon data
  1251. * @link_id: the link ID for the AP MLD link sending this beacon
  1252. * @head: head portion of beacon (before TIM IE)
  1253. * or %NULL if not changed
  1254. * @tail: tail portion of beacon (after TIM IE)
  1255. * or %NULL if not changed
  1256. * @head_len: length of @head
  1257. * @tail_len: length of @tail
  1258. * @beacon_ies: extra information element(s) to add into Beacon frames or %NULL
  1259. * @beacon_ies_len: length of beacon_ies in octets
  1260. * @proberesp_ies: extra information element(s) to add into Probe Response
  1261. * frames or %NULL
  1262. * @proberesp_ies_len: length of proberesp_ies in octets
  1263. * @assocresp_ies: extra information element(s) to add into (Re)Association
  1264. * Response frames or %NULL
  1265. * @assocresp_ies_len: length of assocresp_ies in octets
  1266. * @probe_resp_len: length of probe response template (@probe_resp)
  1267. * @probe_resp: probe response template (AP mode only)
  1268. * @mbssid_ies: multiple BSSID elements
  1269. * @rnr_ies: reduced neighbor report elements
  1270. * @ftm_responder: enable FTM responder functionality; -1 for no change
  1271. * (which also implies no change in LCI/civic location data)
  1272. * @lci: Measurement Report element content, starting with Measurement Token
  1273. * (measurement type 8)
  1274. * @civicloc: Measurement Report element content, starting with Measurement
  1275. * Token (measurement type 11)
  1276. * @lci_len: LCI data length
  1277. * @civicloc_len: Civic location data length
  1278. * @he_bss_color: BSS Color settings
  1279. * @he_bss_color_valid: indicates whether bss color
  1280. * attribute is present in beacon data or not.
  1281. */
  1282. struct cfg80211_beacon_data {
  1283. unsigned int link_id;
  1284. const u8 *head, *tail;
  1285. const u8 *beacon_ies;
  1286. const u8 *proberesp_ies;
  1287. const u8 *assocresp_ies;
  1288. const u8 *probe_resp;
  1289. const u8 *lci;
  1290. const u8 *civicloc;
  1291. struct cfg80211_mbssid_elems *mbssid_ies;
  1292. struct cfg80211_rnr_elems *rnr_ies;
  1293. s8 ftm_responder;
  1294. size_t head_len, tail_len;
  1295. size_t beacon_ies_len;
  1296. size_t proberesp_ies_len;
  1297. size_t assocresp_ies_len;
  1298. size_t probe_resp_len;
  1299. size_t lci_len;
  1300. size_t civicloc_len;
  1301. struct cfg80211_he_bss_color he_bss_color;
  1302. bool he_bss_color_valid;
  1303. };
  1304. struct mac_address {
  1305. u8 addr[ETH_ALEN];
  1306. };
  1307. /**
  1308. * struct cfg80211_acl_data - Access control list data
  1309. *
  1310. * @acl_policy: ACL policy to be applied on the station's
  1311. * entry specified by mac_addr
  1312. * @n_acl_entries: Number of MAC address entries passed
  1313. * @mac_addrs: List of MAC addresses of stations to be used for ACL
  1314. */
  1315. struct cfg80211_acl_data {
  1316. enum nl80211_acl_policy acl_policy;
  1317. int n_acl_entries;
  1318. /* Keep it last */
  1319. struct mac_address mac_addrs[] __counted_by(n_acl_entries);
  1320. };
  1321. /**
  1322. * struct cfg80211_fils_discovery - FILS discovery parameters from
  1323. * IEEE Std 802.11ai-2016, Annex C.3 MIB detail.
  1324. *
  1325. * @update: Set to true if the feature configuration should be updated.
  1326. * @min_interval: Minimum packet interval in TUs (0 - 10000)
  1327. * @max_interval: Maximum packet interval in TUs (0 - 10000)
  1328. * @tmpl_len: Template length
  1329. * @tmpl: Template data for FILS discovery frame including the action
  1330. * frame headers.
  1331. */
  1332. struct cfg80211_fils_discovery {
  1333. bool update;
  1334. u32 min_interval;
  1335. u32 max_interval;
  1336. size_t tmpl_len;
  1337. const u8 *tmpl;
  1338. };
  1339. /**
  1340. * struct cfg80211_unsol_bcast_probe_resp - Unsolicited broadcast probe
  1341. * response parameters in 6GHz.
  1342. *
  1343. * @update: Set to true if the feature configuration should be updated.
  1344. * @interval: Packet interval in TUs. Maximum allowed is 20 TU, as mentioned
  1345. * in IEEE P802.11ax/D6.0 26.17.2.3.2 - AP behavior for fast passive
  1346. * scanning
  1347. * @tmpl_len: Template length
  1348. * @tmpl: Template data for probe response
  1349. */
  1350. struct cfg80211_unsol_bcast_probe_resp {
  1351. bool update;
  1352. u32 interval;
  1353. size_t tmpl_len;
  1354. const u8 *tmpl;
  1355. };
  1356. /**
  1357. * struct cfg80211_ap_settings - AP configuration
  1358. *
  1359. * Used to configure an AP interface.
  1360. *
  1361. * @chandef: defines the channel to use
  1362. * @beacon: beacon data
  1363. * @beacon_interval: beacon interval
  1364. * @dtim_period: DTIM period
  1365. * @ssid: SSID to be used in the BSS (note: may be %NULL if not provided from
  1366. * user space)
  1367. * @ssid_len: length of @ssid
  1368. * @hidden_ssid: whether to hide the SSID in Beacon/Probe Response frames
  1369. * @crypto: crypto settings
  1370. * @privacy: the BSS uses privacy
  1371. * @auth_type: Authentication type (algorithm)
  1372. * @smps_mode: SMPS mode
  1373. * @inactivity_timeout: time in seconds to determine station's inactivity.
  1374. * @p2p_ctwindow: P2P CT Window
  1375. * @p2p_opp_ps: P2P opportunistic PS
  1376. * @acl: ACL configuration used by the drivers which has support for
  1377. * MAC address based access control
  1378. * @pbss: If set, start as a PCP instead of AP. Relevant for DMG
  1379. * networks.
  1380. * @beacon_rate: bitrate to be used for beacons
  1381. * @ht_cap: HT capabilities (or %NULL if HT isn't enabled)
  1382. * @vht_cap: VHT capabilities (or %NULL if VHT isn't enabled)
  1383. * @he_cap: HE capabilities (or %NULL if HE isn't enabled)
  1384. * @eht_cap: EHT capabilities (or %NULL if EHT isn't enabled)
  1385. * @eht_oper: EHT operation IE (or %NULL if EHT isn't enabled)
  1386. * @ht_required: stations must support HT
  1387. * @vht_required: stations must support VHT
  1388. * @twt_responder: Enable Target Wait Time
  1389. * @he_required: stations must support HE
  1390. * @sae_h2e_required: stations must support direct H2E technique in SAE
  1391. * @flags: flags, as defined in &enum nl80211_ap_settings_flags
  1392. * @he_obss_pd: OBSS Packet Detection settings
  1393. * @he_oper: HE operation IE (or %NULL if HE isn't enabled)
  1394. * @fils_discovery: FILS discovery transmission parameters
  1395. * @unsol_bcast_probe_resp: Unsolicited broadcast probe response parameters
  1396. * @mbssid_config: AP settings for multiple bssid
  1397. */
  1398. struct cfg80211_ap_settings {
  1399. struct cfg80211_chan_def chandef;
  1400. struct cfg80211_beacon_data beacon;
  1401. int beacon_interval, dtim_period;
  1402. const u8 *ssid;
  1403. size_t ssid_len;
  1404. enum nl80211_hidden_ssid hidden_ssid;
  1405. struct cfg80211_crypto_settings crypto;
  1406. bool privacy;
  1407. enum nl80211_auth_type auth_type;
  1408. enum nl80211_smps_mode smps_mode;
  1409. int inactivity_timeout;
  1410. u8 p2p_ctwindow;
  1411. bool p2p_opp_ps;
  1412. const struct cfg80211_acl_data *acl;
  1413. bool pbss;
  1414. struct cfg80211_bitrate_mask beacon_rate;
  1415. const struct ieee80211_ht_cap *ht_cap;
  1416. const struct ieee80211_vht_cap *vht_cap;
  1417. const struct ieee80211_he_cap_elem *he_cap;
  1418. const struct ieee80211_he_operation *he_oper;
  1419. const struct ieee80211_eht_cap_elem *eht_cap;
  1420. const struct ieee80211_eht_operation *eht_oper;
  1421. bool ht_required, vht_required, he_required, sae_h2e_required;
  1422. bool twt_responder;
  1423. u32 flags;
  1424. struct ieee80211_he_obss_pd he_obss_pd;
  1425. struct cfg80211_fils_discovery fils_discovery;
  1426. struct cfg80211_unsol_bcast_probe_resp unsol_bcast_probe_resp;
  1427. struct cfg80211_mbssid_config mbssid_config;
  1428. };
  1429. /**
  1430. * struct cfg80211_ap_update - AP configuration update
  1431. *
  1432. * Subset of &struct cfg80211_ap_settings, for updating a running AP.
  1433. *
  1434. * @beacon: beacon data
  1435. * @fils_discovery: FILS discovery transmission parameters
  1436. * @unsol_bcast_probe_resp: Unsolicited broadcast probe response parameters
  1437. */
  1438. struct cfg80211_ap_update {
  1439. struct cfg80211_beacon_data beacon;
  1440. struct cfg80211_fils_discovery fils_discovery;
  1441. struct cfg80211_unsol_bcast_probe_resp unsol_bcast_probe_resp;
  1442. };
  1443. /**
  1444. * struct cfg80211_csa_settings - channel switch settings
  1445. *
  1446. * Used for channel switch
  1447. *
  1448. * @chandef: defines the channel to use after the switch
  1449. * @beacon_csa: beacon data while performing the switch
  1450. * @counter_offsets_beacon: offsets of the counters within the beacon (tail)
  1451. * @counter_offsets_presp: offsets of the counters within the probe response
  1452. * @n_counter_offsets_beacon: number of csa counters the beacon (tail)
  1453. * @n_counter_offsets_presp: number of csa counters in the probe response
  1454. * @beacon_after: beacon data to be used on the new channel
  1455. * @radar_required: whether radar detection is required on the new channel
  1456. * @block_tx: whether transmissions should be blocked while changing
  1457. * @count: number of beacons until switch
  1458. * @link_id: defines the link on which channel switch is expected during
  1459. * MLO. 0 in case of non-MLO.
  1460. */
  1461. struct cfg80211_csa_settings {
  1462. struct cfg80211_chan_def chandef;
  1463. struct cfg80211_beacon_data beacon_csa;
  1464. const u16 *counter_offsets_beacon;
  1465. const u16 *counter_offsets_presp;
  1466. unsigned int n_counter_offsets_beacon;
  1467. unsigned int n_counter_offsets_presp;
  1468. struct cfg80211_beacon_data beacon_after;
  1469. bool radar_required;
  1470. bool block_tx;
  1471. u8 count;
  1472. u8 link_id;
  1473. };
  1474. /**
  1475. * struct cfg80211_color_change_settings - color change settings
  1476. *
  1477. * Used for bss color change
  1478. *
  1479. * @beacon_color_change: beacon data while performing the color countdown
  1480. * @counter_offset_beacon: offsets of the counters within the beacon (tail)
  1481. * @counter_offset_presp: offsets of the counters within the probe response
  1482. * @beacon_next: beacon data to be used after the color change
  1483. * @count: number of beacons until the color change
  1484. * @color: the color used after the change
  1485. * @link_id: defines the link on which color change is expected during MLO.
  1486. * 0 in case of non-MLO.
  1487. */
  1488. struct cfg80211_color_change_settings {
  1489. struct cfg80211_beacon_data beacon_color_change;
  1490. u16 counter_offset_beacon;
  1491. u16 counter_offset_presp;
  1492. struct cfg80211_beacon_data beacon_next;
  1493. u8 count;
  1494. u8 color;
  1495. u8 link_id;
  1496. };
  1497. /**
  1498. * struct iface_combination_params - input parameters for interface combinations
  1499. *
  1500. * Used to pass interface combination parameters
  1501. *
  1502. * @radio_idx: wiphy radio index or -1 for global
  1503. * @num_different_channels: the number of different channels we want
  1504. * to use for verification
  1505. * @radar_detect: a bitmap where each bit corresponds to a channel
  1506. * width where radar detection is needed, as in the definition of
  1507. * &struct ieee80211_iface_combination.@radar_detect_widths
  1508. * @iftype_num: array with the number of interfaces of each interface
  1509. * type. The index is the interface type as specified in &enum
  1510. * nl80211_iftype.
  1511. * @new_beacon_int: set this to the beacon interval of a new interface
  1512. * that's not operating yet, if such is to be checked as part of
  1513. * the verification
  1514. */
  1515. struct iface_combination_params {
  1516. int radio_idx;
  1517. int num_different_channels;
  1518. u8 radar_detect;
  1519. int iftype_num[NUM_NL80211_IFTYPES];
  1520. u32 new_beacon_int;
  1521. };
  1522. /**
  1523. * enum station_parameters_apply_mask - station parameter values to apply
  1524. * @STATION_PARAM_APPLY_UAPSD: apply new uAPSD parameters (uapsd_queues, max_sp)
  1525. * @STATION_PARAM_APPLY_CAPABILITY: apply new capability
  1526. * @STATION_PARAM_APPLY_PLINK_STATE: apply new plink state
  1527. *
  1528. * Not all station parameters have in-band "no change" signalling,
  1529. * for those that don't these flags will are used.
  1530. */
  1531. enum station_parameters_apply_mask {
  1532. STATION_PARAM_APPLY_UAPSD = BIT(0),
  1533. STATION_PARAM_APPLY_CAPABILITY = BIT(1),
  1534. STATION_PARAM_APPLY_PLINK_STATE = BIT(2),
  1535. };
  1536. /**
  1537. * struct sta_txpwr - station txpower configuration
  1538. *
  1539. * Used to configure txpower for station.
  1540. *
  1541. * @power: tx power (in dBm) to be used for sending data traffic. If tx power
  1542. * is not provided, the default per-interface tx power setting will be
  1543. * overriding. Driver should be picking up the lowest tx power, either tx
  1544. * power per-interface or per-station.
  1545. * @type: In particular if TPC %type is NL80211_TX_POWER_LIMITED then tx power
  1546. * will be less than or equal to specified from userspace, whereas if TPC
  1547. * %type is NL80211_TX_POWER_AUTOMATIC then it indicates default tx power.
  1548. * NL80211_TX_POWER_FIXED is not a valid configuration option for
  1549. * per peer TPC.
  1550. */
  1551. struct sta_txpwr {
  1552. s16 power;
  1553. enum nl80211_tx_power_setting type;
  1554. };
  1555. /**
  1556. * struct link_station_parameters - link station parameters
  1557. *
  1558. * Used to change and create a new link station.
  1559. *
  1560. * @mld_mac: MAC address of the station
  1561. * @link_id: the link id (-1 for non-MLD station)
  1562. * @link_mac: MAC address of the link
  1563. * @supported_rates: supported rates in IEEE 802.11 format
  1564. * (or NULL for no change)
  1565. * @supported_rates_len: number of supported rates
  1566. * @ht_capa: HT capabilities of station
  1567. * @vht_capa: VHT capabilities of station
  1568. * @opmode_notif: operating mode field from Operating Mode Notification
  1569. * @opmode_notif_used: information if operating mode field is used
  1570. * @he_capa: HE capabilities of station
  1571. * @he_capa_len: the length of the HE capabilities
  1572. * @txpwr: transmit power for an associated station
  1573. * @txpwr_set: txpwr field is set
  1574. * @he_6ghz_capa: HE 6 GHz Band capabilities of station
  1575. * @eht_capa: EHT capabilities of station
  1576. * @eht_capa_len: the length of the EHT capabilities
  1577. */
  1578. struct link_station_parameters {
  1579. const u8 *mld_mac;
  1580. int link_id;
  1581. const u8 *link_mac;
  1582. const u8 *supported_rates;
  1583. u8 supported_rates_len;
  1584. const struct ieee80211_ht_cap *ht_capa;
  1585. const struct ieee80211_vht_cap *vht_capa;
  1586. u8 opmode_notif;
  1587. bool opmode_notif_used;
  1588. const struct ieee80211_he_cap_elem *he_capa;
  1589. u8 he_capa_len;
  1590. struct sta_txpwr txpwr;
  1591. bool txpwr_set;
  1592. const struct ieee80211_he_6ghz_capa *he_6ghz_capa;
  1593. const struct ieee80211_eht_cap_elem *eht_capa;
  1594. u8 eht_capa_len;
  1595. };
  1596. /**
  1597. * struct link_station_del_parameters - link station deletion parameters
  1598. *
  1599. * Used to delete a link station entry (or all stations).
  1600. *
  1601. * @mld_mac: MAC address of the station
  1602. * @link_id: the link id
  1603. */
  1604. struct link_station_del_parameters {
  1605. const u8 *mld_mac;
  1606. u32 link_id;
  1607. };
  1608. /**
  1609. * struct cfg80211_ttlm_params: TID to link mapping parameters
  1610. *
  1611. * Used for setting a TID to link mapping.
  1612. *
  1613. * @dlink: Downlink TID to link mapping, as defined in section 9.4.2.314
  1614. * (TID-To-Link Mapping element) in Draft P802.11be_D4.0.
  1615. * @ulink: Uplink TID to link mapping, as defined in section 9.4.2.314
  1616. * (TID-To-Link Mapping element) in Draft P802.11be_D4.0.
  1617. */
  1618. struct cfg80211_ttlm_params {
  1619. u16 dlink[8];
  1620. u16 ulink[8];
  1621. };
  1622. /**
  1623. * struct station_parameters - station parameters
  1624. *
  1625. * Used to change and create a new station.
  1626. *
  1627. * @vlan: vlan interface station should belong to
  1628. * @sta_flags_mask: station flags that changed
  1629. * (bitmask of BIT(%NL80211_STA_FLAG_...))
  1630. * @sta_flags_set: station flags values
  1631. * (bitmask of BIT(%NL80211_STA_FLAG_...))
  1632. * @listen_interval: listen interval or -1 for no change
  1633. * @aid: AID or zero for no change
  1634. * @vlan_id: VLAN ID for station (if nonzero)
  1635. * @peer_aid: mesh peer AID or zero for no change
  1636. * @plink_action: plink action to take
  1637. * @plink_state: set the peer link state for a station
  1638. * @uapsd_queues: bitmap of queues configured for uapsd. same format
  1639. * as the AC bitmap in the QoS info field
  1640. * @max_sp: max Service Period. same format as the MAX_SP in the
  1641. * QoS info field (but already shifted down)
  1642. * @sta_modify_mask: bitmap indicating which parameters changed
  1643. * (for those that don't have a natural "no change" value),
  1644. * see &enum station_parameters_apply_mask
  1645. * @local_pm: local link-specific mesh power save mode (no change when set
  1646. * to unknown)
  1647. * @capability: station capability
  1648. * @ext_capab: extended capabilities of the station
  1649. * @ext_capab_len: number of extended capabilities
  1650. * @supported_channels: supported channels in IEEE 802.11 format
  1651. * @supported_channels_len: number of supported channels
  1652. * @supported_oper_classes: supported oper classes in IEEE 802.11 format
  1653. * @supported_oper_classes_len: number of supported operating classes
  1654. * @support_p2p_ps: information if station supports P2P PS mechanism
  1655. * @airtime_weight: airtime scheduler weight for this station
  1656. * @link_sta_params: link related params.
  1657. */
  1658. struct station_parameters {
  1659. struct net_device *vlan;
  1660. u32 sta_flags_mask, sta_flags_set;
  1661. u32 sta_modify_mask;
  1662. int listen_interval;
  1663. u16 aid;
  1664. u16 vlan_id;
  1665. u16 peer_aid;
  1666. u8 plink_action;
  1667. u8 plink_state;
  1668. u8 uapsd_queues;
  1669. u8 max_sp;
  1670. enum nl80211_mesh_power_mode local_pm;
  1671. u16 capability;
  1672. const u8 *ext_capab;
  1673. u8 ext_capab_len;
  1674. const u8 *supported_channels;
  1675. u8 supported_channels_len;
  1676. const u8 *supported_oper_classes;
  1677. u8 supported_oper_classes_len;
  1678. int support_p2p_ps;
  1679. u16 airtime_weight;
  1680. struct link_station_parameters link_sta_params;
  1681. };
  1682. /**
  1683. * struct station_del_parameters - station deletion parameters
  1684. *
  1685. * Used to delete a station entry (or all stations).
  1686. *
  1687. * @mac: MAC address of the station to remove or NULL to remove all stations
  1688. * @subtype: Management frame subtype to use for indicating removal
  1689. * (10 = Disassociation, 12 = Deauthentication)
  1690. * @reason_code: Reason code for the Disassociation/Deauthentication frame
  1691. * @link_id: Link ID indicating a link that stations to be flushed must be
  1692. * using; valid only for MLO, but can also be -1 for MLO to really
  1693. * remove all stations.
  1694. */
  1695. struct station_del_parameters {
  1696. const u8 *mac;
  1697. u8 subtype;
  1698. u16 reason_code;
  1699. int link_id;
  1700. };
  1701. /**
  1702. * enum cfg80211_station_type - the type of station being modified
  1703. * @CFG80211_STA_AP_CLIENT: client of an AP interface
  1704. * @CFG80211_STA_AP_CLIENT_UNASSOC: client of an AP interface that is still
  1705. * unassociated (update properties for this type of client is permitted)
  1706. * @CFG80211_STA_AP_MLME_CLIENT: client of an AP interface that has
  1707. * the AP MLME in the device
  1708. * @CFG80211_STA_AP_STA: AP station on managed interface
  1709. * @CFG80211_STA_IBSS: IBSS station
  1710. * @CFG80211_STA_TDLS_PEER_SETUP: TDLS peer on managed interface (dummy entry
  1711. * while TDLS setup is in progress, it moves out of this state when
  1712. * being marked authorized; use this only if TDLS with external setup is
  1713. * supported/used)
  1714. * @CFG80211_STA_TDLS_PEER_ACTIVE: TDLS peer on managed interface (active
  1715. * entry that is operating, has been marked authorized by userspace)
  1716. * @CFG80211_STA_MESH_PEER_KERNEL: peer on mesh interface (kernel managed)
  1717. * @CFG80211_STA_MESH_PEER_USER: peer on mesh interface (user managed)
  1718. */
  1719. enum cfg80211_station_type {
  1720. CFG80211_STA_AP_CLIENT,
  1721. CFG80211_STA_AP_CLIENT_UNASSOC,
  1722. CFG80211_STA_AP_MLME_CLIENT,
  1723. CFG80211_STA_AP_STA,
  1724. CFG80211_STA_IBSS,
  1725. CFG80211_STA_TDLS_PEER_SETUP,
  1726. CFG80211_STA_TDLS_PEER_ACTIVE,
  1727. CFG80211_STA_MESH_PEER_KERNEL,
  1728. CFG80211_STA_MESH_PEER_USER,
  1729. };
  1730. /**
  1731. * cfg80211_check_station_change - validate parameter changes
  1732. * @wiphy: the wiphy this operates on
  1733. * @params: the new parameters for a station
  1734. * @statype: the type of station being modified
  1735. *
  1736. * Utility function for the @change_station driver method. Call this function
  1737. * with the appropriate station type looking up the station (and checking that
  1738. * it exists). It will verify whether the station change is acceptable.
  1739. *
  1740. * Return: 0 if the change is acceptable, otherwise an error code. Note that
  1741. * it may modify the parameters for backward compatibility reasons, so don't
  1742. * use them before calling this.
  1743. */
  1744. int cfg80211_check_station_change(struct wiphy *wiphy,
  1745. struct station_parameters *params,
  1746. enum cfg80211_station_type statype);
  1747. /**
  1748. * enum rate_info_flags - bitrate info flags
  1749. *
  1750. * Used by the driver to indicate the specific rate transmission
  1751. * type for 802.11n transmissions.
  1752. *
  1753. * @RATE_INFO_FLAGS_MCS: mcs field filled with HT MCS
  1754. * @RATE_INFO_FLAGS_VHT_MCS: mcs field filled with VHT MCS
  1755. * @RATE_INFO_FLAGS_SHORT_GI: 400ns guard interval
  1756. * @RATE_INFO_FLAGS_DMG: 60GHz MCS
  1757. * @RATE_INFO_FLAGS_HE_MCS: HE MCS information
  1758. * @RATE_INFO_FLAGS_EDMG: 60GHz MCS in EDMG mode
  1759. * @RATE_INFO_FLAGS_EXTENDED_SC_DMG: 60GHz extended SC MCS
  1760. * @RATE_INFO_FLAGS_EHT_MCS: EHT MCS information
  1761. * @RATE_INFO_FLAGS_S1G_MCS: MCS field filled with S1G MCS
  1762. */
  1763. enum rate_info_flags {
  1764. RATE_INFO_FLAGS_MCS = BIT(0),
  1765. RATE_INFO_FLAGS_VHT_MCS = BIT(1),
  1766. RATE_INFO_FLAGS_SHORT_GI = BIT(2),
  1767. RATE_INFO_FLAGS_DMG = BIT(3),
  1768. RATE_INFO_FLAGS_HE_MCS = BIT(4),
  1769. RATE_INFO_FLAGS_EDMG = BIT(5),
  1770. RATE_INFO_FLAGS_EXTENDED_SC_DMG = BIT(6),
  1771. RATE_INFO_FLAGS_EHT_MCS = BIT(7),
  1772. RATE_INFO_FLAGS_S1G_MCS = BIT(8),
  1773. };
  1774. /**
  1775. * enum rate_info_bw - rate bandwidth information
  1776. *
  1777. * Used by the driver to indicate the rate bandwidth.
  1778. *
  1779. * @RATE_INFO_BW_5: 5 MHz bandwidth
  1780. * @RATE_INFO_BW_10: 10 MHz bandwidth
  1781. * @RATE_INFO_BW_20: 20 MHz bandwidth
  1782. * @RATE_INFO_BW_40: 40 MHz bandwidth
  1783. * @RATE_INFO_BW_80: 80 MHz bandwidth
  1784. * @RATE_INFO_BW_160: 160 MHz bandwidth
  1785. * @RATE_INFO_BW_HE_RU: bandwidth determined by HE RU allocation
  1786. * @RATE_INFO_BW_320: 320 MHz bandwidth
  1787. * @RATE_INFO_BW_EHT_RU: bandwidth determined by EHT RU allocation
  1788. * @RATE_INFO_BW_1: 1 MHz bandwidth
  1789. * @RATE_INFO_BW_2: 2 MHz bandwidth
  1790. * @RATE_INFO_BW_4: 4 MHz bandwidth
  1791. * @RATE_INFO_BW_8: 8 MHz bandwidth
  1792. * @RATE_INFO_BW_16: 16 MHz bandwidth
  1793. */
  1794. enum rate_info_bw {
  1795. RATE_INFO_BW_20 = 0,
  1796. RATE_INFO_BW_5,
  1797. RATE_INFO_BW_10,
  1798. RATE_INFO_BW_40,
  1799. RATE_INFO_BW_80,
  1800. RATE_INFO_BW_160,
  1801. RATE_INFO_BW_HE_RU,
  1802. RATE_INFO_BW_320,
  1803. RATE_INFO_BW_EHT_RU,
  1804. RATE_INFO_BW_1,
  1805. RATE_INFO_BW_2,
  1806. RATE_INFO_BW_4,
  1807. RATE_INFO_BW_8,
  1808. RATE_INFO_BW_16,
  1809. };
  1810. /**
  1811. * struct rate_info - bitrate information
  1812. *
  1813. * Information about a receiving or transmitting bitrate
  1814. *
  1815. * @flags: bitflag of flags from &enum rate_info_flags
  1816. * @legacy: bitrate in 100kbit/s for 802.11abg
  1817. * @mcs: mcs index if struct describes an HT/VHT/HE/EHT/S1G rate
  1818. * @nss: number of streams (VHT & HE only)
  1819. * @bw: bandwidth (from &enum rate_info_bw)
  1820. * @he_gi: HE guard interval (from &enum nl80211_he_gi)
  1821. * @he_dcm: HE DCM value
  1822. * @he_ru_alloc: HE RU allocation (from &enum nl80211_he_ru_alloc,
  1823. * only valid if bw is %RATE_INFO_BW_HE_RU)
  1824. * @n_bonded_ch: In case of EDMG the number of bonded channels (1-4)
  1825. * @eht_gi: EHT guard interval (from &enum nl80211_eht_gi)
  1826. * @eht_ru_alloc: EHT RU allocation (from &enum nl80211_eht_ru_alloc,
  1827. * only valid if bw is %RATE_INFO_BW_EHT_RU)
  1828. */
  1829. struct rate_info {
  1830. u16 flags;
  1831. u16 legacy;
  1832. u8 mcs;
  1833. u8 nss;
  1834. u8 bw;
  1835. u8 he_gi;
  1836. u8 he_dcm;
  1837. u8 he_ru_alloc;
  1838. u8 n_bonded_ch;
  1839. u8 eht_gi;
  1840. u8 eht_ru_alloc;
  1841. };
  1842. /**
  1843. * enum bss_param_flags - bitrate info flags
  1844. *
  1845. * Used by the driver to indicate the specific rate transmission
  1846. * type for 802.11n transmissions.
  1847. *
  1848. * @BSS_PARAM_FLAGS_CTS_PROT: whether CTS protection is enabled
  1849. * @BSS_PARAM_FLAGS_SHORT_PREAMBLE: whether short preamble is enabled
  1850. * @BSS_PARAM_FLAGS_SHORT_SLOT_TIME: whether short slot time is enabled
  1851. */
  1852. enum bss_param_flags {
  1853. BSS_PARAM_FLAGS_CTS_PROT = BIT(0),
  1854. BSS_PARAM_FLAGS_SHORT_PREAMBLE = BIT(1),
  1855. BSS_PARAM_FLAGS_SHORT_SLOT_TIME = BIT(2),
  1856. };
  1857. /**
  1858. * struct sta_bss_parameters - BSS parameters for the attached station
  1859. *
  1860. * Information about the currently associated BSS
  1861. *
  1862. * @flags: bitflag of flags from &enum bss_param_flags
  1863. * @dtim_period: DTIM period for the BSS
  1864. * @beacon_interval: beacon interval
  1865. */
  1866. struct sta_bss_parameters {
  1867. u8 flags;
  1868. u8 dtim_period;
  1869. u16 beacon_interval;
  1870. };
  1871. /**
  1872. * struct cfg80211_txq_stats - TXQ statistics for this TID
  1873. * @filled: bitmap of flags using the bits of &enum nl80211_txq_stats to
  1874. * indicate the relevant values in this struct are filled
  1875. * @backlog_bytes: total number of bytes currently backlogged
  1876. * @backlog_packets: total number of packets currently backlogged
  1877. * @flows: number of new flows seen
  1878. * @drops: total number of packets dropped
  1879. * @ecn_marks: total number of packets marked with ECN CE
  1880. * @overlimit: number of drops due to queue space overflow
  1881. * @overmemory: number of drops due to memory limit overflow
  1882. * @collisions: number of hash collisions
  1883. * @tx_bytes: total number of bytes dequeued
  1884. * @tx_packets: total number of packets dequeued
  1885. * @max_flows: maximum number of flows supported
  1886. */
  1887. struct cfg80211_txq_stats {
  1888. u32 filled;
  1889. u32 backlog_bytes;
  1890. u32 backlog_packets;
  1891. u32 flows;
  1892. u32 drops;
  1893. u32 ecn_marks;
  1894. u32 overlimit;
  1895. u32 overmemory;
  1896. u32 collisions;
  1897. u32 tx_bytes;
  1898. u32 tx_packets;
  1899. u32 max_flows;
  1900. };
  1901. /**
  1902. * struct cfg80211_tid_stats - per-TID statistics
  1903. * @filled: bitmap of flags using the bits of &enum nl80211_tid_stats to
  1904. * indicate the relevant values in this struct are filled
  1905. * @rx_msdu: number of received MSDUs
  1906. * @tx_msdu: number of (attempted) transmitted MSDUs
  1907. * @tx_msdu_retries: number of retries (not counting the first) for
  1908. * transmitted MSDUs
  1909. * @tx_msdu_failed: number of failed transmitted MSDUs
  1910. * @txq_stats: TXQ statistics
  1911. */
  1912. struct cfg80211_tid_stats {
  1913. u32 filled;
  1914. u64 rx_msdu;
  1915. u64 tx_msdu;
  1916. u64 tx_msdu_retries;
  1917. u64 tx_msdu_failed;
  1918. struct cfg80211_txq_stats txq_stats;
  1919. };
  1920. #define IEEE80211_MAX_CHAINS 4
  1921. /**
  1922. * struct station_info - station information
  1923. *
  1924. * Station information filled by driver for get_station() and dump_station.
  1925. *
  1926. * @filled: bitflag of flags using the bits of &enum nl80211_sta_info to
  1927. * indicate the relevant values in this struct for them
  1928. * @connected_time: time(in secs) since a station is last connected
  1929. * @inactive_time: time since last station activity (tx/rx) in milliseconds
  1930. * @assoc_at: bootime (ns) of the last association
  1931. * @rx_bytes: bytes (size of MPDUs) received from this station
  1932. * @tx_bytes: bytes (size of MPDUs) transmitted to this station
  1933. * @llid: mesh local link id
  1934. * @plid: mesh peer link id
  1935. * @plink_state: mesh peer link state
  1936. * @signal: The signal strength, type depends on the wiphy's signal_type.
  1937. * For CFG80211_SIGNAL_TYPE_MBM, value is expressed in _dBm_.
  1938. * @signal_avg: Average signal strength, type depends on the wiphy's signal_type.
  1939. * For CFG80211_SIGNAL_TYPE_MBM, value is expressed in _dBm_.
  1940. * @chains: bitmask for filled values in @chain_signal, @chain_signal_avg
  1941. * @chain_signal: per-chain signal strength of last received packet in dBm
  1942. * @chain_signal_avg: per-chain signal strength average in dBm
  1943. * @txrate: current unicast bitrate from this station
  1944. * @rxrate: current unicast bitrate to this station
  1945. * @rx_packets: packets (MSDUs & MMPDUs) received from this station
  1946. * @tx_packets: packets (MSDUs & MMPDUs) transmitted to this station
  1947. * @tx_retries: cumulative retry counts (MPDUs)
  1948. * @tx_failed: number of failed transmissions (MPDUs) (retries exceeded, no ACK)
  1949. * @rx_dropped_misc: Dropped for un-specified reason.
  1950. * @bss_param: current BSS parameters
  1951. * @generation: generation number for nl80211 dumps.
  1952. * This number should increase every time the list of stations
  1953. * changes, i.e. when a station is added or removed, so that
  1954. * userspace can tell whether it got a consistent snapshot.
  1955. * @assoc_req_ies: IEs from (Re)Association Request.
  1956. * This is used only when in AP mode with drivers that do not use
  1957. * user space MLME/SME implementation. The information is provided for
  1958. * the cfg80211_new_sta() calls to notify user space of the IEs.
  1959. * @assoc_req_ies_len: Length of assoc_req_ies buffer in octets.
  1960. * @sta_flags: station flags mask & values
  1961. * @beacon_loss_count: Number of times beacon loss event has triggered.
  1962. * @t_offset: Time offset of the station relative to this host.
  1963. * @local_pm: local mesh STA power save mode
  1964. * @peer_pm: peer mesh STA power save mode
  1965. * @nonpeer_pm: non-peer mesh STA power save mode
  1966. * @expected_throughput: expected throughput in kbps (including 802.11 headers)
  1967. * towards this station.
  1968. * @rx_beacon: number of beacons received from this peer
  1969. * @rx_beacon_signal_avg: signal strength average (in dBm) for beacons received
  1970. * from this peer
  1971. * @connected_to_gate: true if mesh STA has a path to mesh gate
  1972. * @rx_duration: aggregate PPDU duration(usecs) for all the frames from a peer
  1973. * @tx_duration: aggregate PPDU duration(usecs) for all the frames to a peer
  1974. * @airtime_weight: current airtime scheduling weight
  1975. * @pertid: per-TID statistics, see &struct cfg80211_tid_stats, using the last
  1976. * (IEEE80211_NUM_TIDS) index for MSDUs not encapsulated in QoS-MPDUs.
  1977. * Note that this doesn't use the @filled bit, but is used if non-NULL.
  1978. * @ack_signal: signal strength (in dBm) of the last ACK frame.
  1979. * @avg_ack_signal: average rssi value of ack packet for the no of msdu's has
  1980. * been sent.
  1981. * @rx_mpdu_count: number of MPDUs received from this station
  1982. * @fcs_err_count: number of packets (MPDUs) received from this station with
  1983. * an FCS error. This counter should be incremented only when TA of the
  1984. * received packet with an FCS error matches the peer MAC address.
  1985. * @airtime_link_metric: mesh airtime link metric.
  1986. * @connected_to_as: true if mesh STA has a path to authentication server
  1987. * @mlo_params_valid: Indicates @assoc_link_id and @mld_addr fields are filled
  1988. * by driver. Drivers use this only in cfg80211_new_sta() calls when AP
  1989. * MLD's MLME/SME is offload to driver. Drivers won't fill this
  1990. * information in cfg80211_del_sta_sinfo(), get_station() and
  1991. * dump_station() callbacks.
  1992. * @assoc_link_id: Indicates MLO link ID of the AP, with which the station
  1993. * completed (re)association. This information filled for both MLO
  1994. * and non-MLO STA connections when the AP affiliated with an MLD.
  1995. * @mld_addr: For MLO STA connection, filled with MLD address of the station.
  1996. * For non-MLO STA connection, filled with all zeros.
  1997. * @assoc_resp_ies: IEs from (Re)Association Response.
  1998. * This is used only when in AP mode with drivers that do not use user
  1999. * space MLME/SME implementation. The information is provided only for the
  2000. * cfg80211_new_sta() calls to notify user space of the IEs. Drivers won't
  2001. * fill this information in cfg80211_del_sta_sinfo(), get_station() and
  2002. * dump_station() callbacks. User space needs this information to determine
  2003. * the accepted and rejected affiliated links of the connected station.
  2004. * @assoc_resp_ies_len: Length of @assoc_resp_ies buffer in octets.
  2005. */
  2006. struct station_info {
  2007. u64 filled;
  2008. u32 connected_time;
  2009. u32 inactive_time;
  2010. u64 assoc_at;
  2011. u64 rx_bytes;
  2012. u64 tx_bytes;
  2013. u16 llid;
  2014. u16 plid;
  2015. u8 plink_state;
  2016. s8 signal;
  2017. s8 signal_avg;
  2018. u8 chains;
  2019. s8 chain_signal[IEEE80211_MAX_CHAINS];
  2020. s8 chain_signal_avg[IEEE80211_MAX_CHAINS];
  2021. struct rate_info txrate;
  2022. struct rate_info rxrate;
  2023. u32 rx_packets;
  2024. u32 tx_packets;
  2025. u32 tx_retries;
  2026. u32 tx_failed;
  2027. u32 rx_dropped_misc;
  2028. struct sta_bss_parameters bss_param;
  2029. struct nl80211_sta_flag_update sta_flags;
  2030. int generation;
  2031. const u8 *assoc_req_ies;
  2032. size_t assoc_req_ies_len;
  2033. u32 beacon_loss_count;
  2034. s64 t_offset;
  2035. enum nl80211_mesh_power_mode local_pm;
  2036. enum nl80211_mesh_power_mode peer_pm;
  2037. enum nl80211_mesh_power_mode nonpeer_pm;
  2038. u32 expected_throughput;
  2039. u64 tx_duration;
  2040. u64 rx_duration;
  2041. u64 rx_beacon;
  2042. u8 rx_beacon_signal_avg;
  2043. u8 connected_to_gate;
  2044. struct cfg80211_tid_stats *pertid;
  2045. s8 ack_signal;
  2046. s8 avg_ack_signal;
  2047. u16 airtime_weight;
  2048. u32 rx_mpdu_count;
  2049. u32 fcs_err_count;
  2050. u32 airtime_link_metric;
  2051. u8 connected_to_as;
  2052. bool mlo_params_valid;
  2053. u8 assoc_link_id;
  2054. u8 mld_addr[ETH_ALEN] __aligned(2);
  2055. const u8 *assoc_resp_ies;
  2056. size_t assoc_resp_ies_len;
  2057. };
  2058. /**
  2059. * struct cfg80211_sar_sub_specs - sub specs limit
  2060. * @power: power limitation in 0.25dbm
  2061. * @freq_range_index: index the power limitation applies to
  2062. */
  2063. struct cfg80211_sar_sub_specs {
  2064. s32 power;
  2065. u32 freq_range_index;
  2066. };
  2067. /**
  2068. * struct cfg80211_sar_specs - sar limit specs
  2069. * @type: it's set with power in 0.25dbm or other types
  2070. * @num_sub_specs: number of sar sub specs
  2071. * @sub_specs: memory to hold the sar sub specs
  2072. */
  2073. struct cfg80211_sar_specs {
  2074. enum nl80211_sar_type type;
  2075. u32 num_sub_specs;
  2076. struct cfg80211_sar_sub_specs sub_specs[] __counted_by(num_sub_specs);
  2077. };
  2078. /**
  2079. * struct cfg80211_sar_freq_ranges - sar frequency ranges
  2080. * @start_freq: start range edge frequency
  2081. * @end_freq: end range edge frequency
  2082. */
  2083. struct cfg80211_sar_freq_ranges {
  2084. u32 start_freq;
  2085. u32 end_freq;
  2086. };
  2087. /**
  2088. * struct cfg80211_sar_capa - sar limit capability
  2089. * @type: it's set via power in 0.25dbm or other types
  2090. * @num_freq_ranges: number of frequency ranges
  2091. * @freq_ranges: memory to hold the freq ranges.
  2092. *
  2093. * Note: WLAN driver may append new ranges or split an existing
  2094. * range to small ones and then append them.
  2095. */
  2096. struct cfg80211_sar_capa {
  2097. enum nl80211_sar_type type;
  2098. u32 num_freq_ranges;
  2099. const struct cfg80211_sar_freq_ranges *freq_ranges;
  2100. };
  2101. #if IS_ENABLED(CONFIG_CFG80211)
  2102. /**
  2103. * cfg80211_get_station - retrieve information about a given station
  2104. * @dev: the device where the station is supposed to be connected to
  2105. * @mac_addr: the mac address of the station of interest
  2106. * @sinfo: pointer to the structure to fill with the information
  2107. *
  2108. * Return: 0 on success and sinfo is filled with the available information
  2109. * otherwise returns a negative error code and the content of sinfo has to be
  2110. * considered undefined.
  2111. */
  2112. int cfg80211_get_station(struct net_device *dev, const u8 *mac_addr,
  2113. struct station_info *sinfo);
  2114. #else
  2115. static inline int cfg80211_get_station(struct net_device *dev,
  2116. const u8 *mac_addr,
  2117. struct station_info *sinfo)
  2118. {
  2119. return -ENOENT;
  2120. }
  2121. #endif
  2122. /**
  2123. * enum monitor_flags - monitor flags
  2124. *
  2125. * Monitor interface configuration flags. Note that these must be the bits
  2126. * according to the nl80211 flags.
  2127. *
  2128. * @MONITOR_FLAG_CHANGED: set if the flags were changed
  2129. * @MONITOR_FLAG_FCSFAIL: pass frames with bad FCS
  2130. * @MONITOR_FLAG_PLCPFAIL: pass frames with bad PLCP
  2131. * @MONITOR_FLAG_CONTROL: pass control frames
  2132. * @MONITOR_FLAG_OTHER_BSS: disable BSSID filtering
  2133. * @MONITOR_FLAG_COOK_FRAMES: report frames after processing
  2134. * @MONITOR_FLAG_ACTIVE: active monitor, ACKs frames on its MAC address
  2135. */
  2136. enum monitor_flags {
  2137. MONITOR_FLAG_CHANGED = BIT(__NL80211_MNTR_FLAG_INVALID),
  2138. MONITOR_FLAG_FCSFAIL = BIT(NL80211_MNTR_FLAG_FCSFAIL),
  2139. MONITOR_FLAG_PLCPFAIL = BIT(NL80211_MNTR_FLAG_PLCPFAIL),
  2140. MONITOR_FLAG_CONTROL = BIT(NL80211_MNTR_FLAG_CONTROL),
  2141. MONITOR_FLAG_OTHER_BSS = BIT(NL80211_MNTR_FLAG_OTHER_BSS),
  2142. MONITOR_FLAG_COOK_FRAMES = BIT(NL80211_MNTR_FLAG_COOK_FRAMES),
  2143. MONITOR_FLAG_ACTIVE = BIT(NL80211_MNTR_FLAG_ACTIVE),
  2144. };
  2145. /**
  2146. * enum mpath_info_flags - mesh path information flags
  2147. *
  2148. * Used by the driver to indicate which info in &struct mpath_info it has filled
  2149. * in during get_station() or dump_station().
  2150. *
  2151. * @MPATH_INFO_FRAME_QLEN: @frame_qlen filled
  2152. * @MPATH_INFO_SN: @sn filled
  2153. * @MPATH_INFO_METRIC: @metric filled
  2154. * @MPATH_INFO_EXPTIME: @exptime filled
  2155. * @MPATH_INFO_DISCOVERY_TIMEOUT: @discovery_timeout filled
  2156. * @MPATH_INFO_DISCOVERY_RETRIES: @discovery_retries filled
  2157. * @MPATH_INFO_FLAGS: @flags filled
  2158. * @MPATH_INFO_HOP_COUNT: @hop_count filled
  2159. * @MPATH_INFO_PATH_CHANGE: @path_change_count filled
  2160. */
  2161. enum mpath_info_flags {
  2162. MPATH_INFO_FRAME_QLEN = BIT(0),
  2163. MPATH_INFO_SN = BIT(1),
  2164. MPATH_INFO_METRIC = BIT(2),
  2165. MPATH_INFO_EXPTIME = BIT(3),
  2166. MPATH_INFO_DISCOVERY_TIMEOUT = BIT(4),
  2167. MPATH_INFO_DISCOVERY_RETRIES = BIT(5),
  2168. MPATH_INFO_FLAGS = BIT(6),
  2169. MPATH_INFO_HOP_COUNT = BIT(7),
  2170. MPATH_INFO_PATH_CHANGE = BIT(8),
  2171. };
  2172. /**
  2173. * struct mpath_info - mesh path information
  2174. *
  2175. * Mesh path information filled by driver for get_mpath() and dump_mpath().
  2176. *
  2177. * @filled: bitfield of flags from &enum mpath_info_flags
  2178. * @frame_qlen: number of queued frames for this destination
  2179. * @sn: target sequence number
  2180. * @metric: metric (cost) of this mesh path
  2181. * @exptime: expiration time for the mesh path from now, in msecs
  2182. * @flags: mesh path flags from &enum mesh_path_flags
  2183. * @discovery_timeout: total mesh path discovery timeout, in msecs
  2184. * @discovery_retries: mesh path discovery retries
  2185. * @generation: generation number for nl80211 dumps.
  2186. * This number should increase every time the list of mesh paths
  2187. * changes, i.e. when a station is added or removed, so that
  2188. * userspace can tell whether it got a consistent snapshot.
  2189. * @hop_count: hops to destination
  2190. * @path_change_count: total number of path changes to destination
  2191. */
  2192. struct mpath_info {
  2193. u32 filled;
  2194. u32 frame_qlen;
  2195. u32 sn;
  2196. u32 metric;
  2197. u32 exptime;
  2198. u32 discovery_timeout;
  2199. u8 discovery_retries;
  2200. u8 flags;
  2201. u8 hop_count;
  2202. u32 path_change_count;
  2203. int generation;
  2204. };
  2205. /**
  2206. * struct bss_parameters - BSS parameters
  2207. *
  2208. * Used to change BSS parameters (mainly for AP mode).
  2209. *
  2210. * @link_id: link_id or -1 for non-MLD
  2211. * @use_cts_prot: Whether to use CTS protection
  2212. * (0 = no, 1 = yes, -1 = do not change)
  2213. * @use_short_preamble: Whether the use of short preambles is allowed
  2214. * (0 = no, 1 = yes, -1 = do not change)
  2215. * @use_short_slot_time: Whether the use of short slot time is allowed
  2216. * (0 = no, 1 = yes, -1 = do not change)
  2217. * @basic_rates: basic rates in IEEE 802.11 format
  2218. * (or NULL for no change)
  2219. * @basic_rates_len: number of basic rates
  2220. * @ap_isolate: do not forward packets between connected stations
  2221. * (0 = no, 1 = yes, -1 = do not change)
  2222. * @ht_opmode: HT Operation mode
  2223. * (u16 = opmode, -1 = do not change)
  2224. * @p2p_ctwindow: P2P CT Window (-1 = no change)
  2225. * @p2p_opp_ps: P2P opportunistic PS (-1 = no change)
  2226. */
  2227. struct bss_parameters {
  2228. int link_id;
  2229. int use_cts_prot;
  2230. int use_short_preamble;
  2231. int use_short_slot_time;
  2232. const u8 *basic_rates;
  2233. u8 basic_rates_len;
  2234. int ap_isolate;
  2235. int ht_opmode;
  2236. s8 p2p_ctwindow, p2p_opp_ps;
  2237. };
  2238. /**
  2239. * struct mesh_config - 802.11s mesh configuration
  2240. *
  2241. * These parameters can be changed while the mesh is active.
  2242. *
  2243. * @dot11MeshRetryTimeout: the initial retry timeout in millisecond units used
  2244. * by the Mesh Peering Open message
  2245. * @dot11MeshConfirmTimeout: the initial retry timeout in millisecond units
  2246. * used by the Mesh Peering Open message
  2247. * @dot11MeshHoldingTimeout: the confirm timeout in millisecond units used by
  2248. * the mesh peering management to close a mesh peering
  2249. * @dot11MeshMaxPeerLinks: the maximum number of peer links allowed on this
  2250. * mesh interface
  2251. * @dot11MeshMaxRetries: the maximum number of peer link open retries that can
  2252. * be sent to establish a new peer link instance in a mesh
  2253. * @dot11MeshTTL: the value of TTL field set at a source mesh STA
  2254. * @element_ttl: the value of TTL field set at a mesh STA for path selection
  2255. * elements
  2256. * @auto_open_plinks: whether we should automatically open peer links when we
  2257. * detect compatible mesh peers
  2258. * @dot11MeshNbrOffsetMaxNeighbor: the maximum number of neighbors to
  2259. * synchronize to for 11s default synchronization method
  2260. * @dot11MeshHWMPmaxPREQretries: the number of action frames containing a PREQ
  2261. * that an originator mesh STA can send to a particular path target
  2262. * @path_refresh_time: how frequently to refresh mesh paths in milliseconds
  2263. * @min_discovery_timeout: the minimum length of time to wait until giving up on
  2264. * a path discovery in milliseconds
  2265. * @dot11MeshHWMPactivePathTimeout: the time (in TUs) for which mesh STAs
  2266. * receiving a PREQ shall consider the forwarding information from the
  2267. * root to be valid. (TU = time unit)
  2268. * @dot11MeshHWMPpreqMinInterval: the minimum interval of time (in TUs) during
  2269. * which a mesh STA can send only one action frame containing a PREQ
  2270. * element
  2271. * @dot11MeshHWMPperrMinInterval: the minimum interval of time (in TUs) during
  2272. * which a mesh STA can send only one Action frame containing a PERR
  2273. * element
  2274. * @dot11MeshHWMPnetDiameterTraversalTime: the interval of time (in TUs) that
  2275. * it takes for an HWMP information element to propagate across the mesh
  2276. * @dot11MeshHWMPRootMode: the configuration of a mesh STA as root mesh STA
  2277. * @dot11MeshHWMPRannInterval: the interval of time (in TUs) between root
  2278. * announcements are transmitted
  2279. * @dot11MeshGateAnnouncementProtocol: whether to advertise that this mesh
  2280. * station has access to a broader network beyond the MBSS. (This is
  2281. * missnamed in draft 12.0: dot11MeshGateAnnouncementProtocol set to true
  2282. * only means that the station will announce others it's a mesh gate, but
  2283. * not necessarily using the gate announcement protocol. Still keeping the
  2284. * same nomenclature to be in sync with the spec)
  2285. * @dot11MeshForwarding: whether the Mesh STA is forwarding or non-forwarding
  2286. * entity (default is TRUE - forwarding entity)
  2287. * @rssi_threshold: the threshold for average signal strength of candidate
  2288. * station to establish a peer link
  2289. * @ht_opmode: mesh HT protection mode
  2290. *
  2291. * @dot11MeshHWMPactivePathToRootTimeout: The time (in TUs) for which mesh STAs
  2292. * receiving a proactive PREQ shall consider the forwarding information to
  2293. * the root mesh STA to be valid.
  2294. *
  2295. * @dot11MeshHWMProotInterval: The interval of time (in TUs) between proactive
  2296. * PREQs are transmitted.
  2297. * @dot11MeshHWMPconfirmationInterval: The minimum interval of time (in TUs)
  2298. * during which a mesh STA can send only one Action frame containing
  2299. * a PREQ element for root path confirmation.
  2300. * @power_mode: The default mesh power save mode which will be the initial
  2301. * setting for new peer links.
  2302. * @dot11MeshAwakeWindowDuration: The duration in TUs the STA will remain awake
  2303. * after transmitting its beacon.
  2304. * @plink_timeout: If no tx activity is seen from a STA we've established
  2305. * peering with for longer than this time (in seconds), then remove it
  2306. * from the STA's list of peers. Default is 30 minutes.
  2307. * @dot11MeshConnectedToAuthServer: if set to true then this mesh STA
  2308. * will advertise that it is connected to a authentication server
  2309. * in the mesh formation field.
  2310. * @dot11MeshConnectedToMeshGate: if set to true, advertise that this STA is
  2311. * connected to a mesh gate in mesh formation info. If false, the
  2312. * value in mesh formation is determined by the presence of root paths
  2313. * in the mesh path table
  2314. * @dot11MeshNolearn: Try to avoid multi-hop path discovery (e.g. PREQ/PREP
  2315. * for HWMP) if the destination is a direct neighbor. Note that this might
  2316. * not be the optimal decision as a multi-hop route might be better. So
  2317. * if using this setting you will likely also want to disable
  2318. * dot11MeshForwarding and use another mesh routing protocol on top.
  2319. */
  2320. struct mesh_config {
  2321. u16 dot11MeshRetryTimeout;
  2322. u16 dot11MeshConfirmTimeout;
  2323. u16 dot11MeshHoldingTimeout;
  2324. u16 dot11MeshMaxPeerLinks;
  2325. u8 dot11MeshMaxRetries;
  2326. u8 dot11MeshTTL;
  2327. u8 element_ttl;
  2328. bool auto_open_plinks;
  2329. u32 dot11MeshNbrOffsetMaxNeighbor;
  2330. u8 dot11MeshHWMPmaxPREQretries;
  2331. u32 path_refresh_time;
  2332. u16 min_discovery_timeout;
  2333. u32 dot11MeshHWMPactivePathTimeout;
  2334. u16 dot11MeshHWMPpreqMinInterval;
  2335. u16 dot11MeshHWMPperrMinInterval;
  2336. u16 dot11MeshHWMPnetDiameterTraversalTime;
  2337. u8 dot11MeshHWMPRootMode;
  2338. bool dot11MeshConnectedToMeshGate;
  2339. bool dot11MeshConnectedToAuthServer;
  2340. u16 dot11MeshHWMPRannInterval;
  2341. bool dot11MeshGateAnnouncementProtocol;
  2342. bool dot11MeshForwarding;
  2343. s32 rssi_threshold;
  2344. u16 ht_opmode;
  2345. u32 dot11MeshHWMPactivePathToRootTimeout;
  2346. u16 dot11MeshHWMProotInterval;
  2347. u16 dot11MeshHWMPconfirmationInterval;
  2348. enum nl80211_mesh_power_mode power_mode;
  2349. u16 dot11MeshAwakeWindowDuration;
  2350. u32 plink_timeout;
  2351. bool dot11MeshNolearn;
  2352. };
  2353. /**
  2354. * struct mesh_setup - 802.11s mesh setup configuration
  2355. * @chandef: defines the channel to use
  2356. * @mesh_id: the mesh ID
  2357. * @mesh_id_len: length of the mesh ID, at least 1 and at most 32 bytes
  2358. * @sync_method: which synchronization method to use
  2359. * @path_sel_proto: which path selection protocol to use
  2360. * @path_metric: which metric to use
  2361. * @auth_id: which authentication method this mesh is using
  2362. * @ie: vendor information elements (optional)
  2363. * @ie_len: length of vendor information elements
  2364. * @is_authenticated: this mesh requires authentication
  2365. * @is_secure: this mesh uses security
  2366. * @user_mpm: userspace handles all MPM functions
  2367. * @dtim_period: DTIM period to use
  2368. * @beacon_interval: beacon interval to use
  2369. * @mcast_rate: multicast rate for Mesh Node [6Mbps is the default for 802.11a]
  2370. * @basic_rates: basic rates to use when creating the mesh
  2371. * @beacon_rate: bitrate to be used for beacons
  2372. * @userspace_handles_dfs: whether user space controls DFS operation, i.e.
  2373. * changes the channel when a radar is detected. This is required
  2374. * to operate on DFS channels.
  2375. * @control_port_over_nl80211: TRUE if userspace expects to exchange control
  2376. * port frames over NL80211 instead of the network interface.
  2377. *
  2378. * These parameters are fixed when the mesh is created.
  2379. */
  2380. struct mesh_setup {
  2381. struct cfg80211_chan_def chandef;
  2382. const u8 *mesh_id;
  2383. u8 mesh_id_len;
  2384. u8 sync_method;
  2385. u8 path_sel_proto;
  2386. u8 path_metric;
  2387. u8 auth_id;
  2388. const u8 *ie;
  2389. u8 ie_len;
  2390. bool is_authenticated;
  2391. bool is_secure;
  2392. bool user_mpm;
  2393. u8 dtim_period;
  2394. u16 beacon_interval;
  2395. int mcast_rate[NUM_NL80211_BANDS];
  2396. u32 basic_rates;
  2397. struct cfg80211_bitrate_mask beacon_rate;
  2398. bool userspace_handles_dfs;
  2399. bool control_port_over_nl80211;
  2400. };
  2401. /**
  2402. * struct ocb_setup - 802.11p OCB mode setup configuration
  2403. * @chandef: defines the channel to use
  2404. *
  2405. * These parameters are fixed when connecting to the network
  2406. */
  2407. struct ocb_setup {
  2408. struct cfg80211_chan_def chandef;
  2409. };
  2410. /**
  2411. * struct ieee80211_txq_params - TX queue parameters
  2412. * @ac: AC identifier
  2413. * @txop: Maximum burst time in units of 32 usecs, 0 meaning disabled
  2414. * @cwmin: Minimum contention window [a value of the form 2^n-1 in the range
  2415. * 1..32767]
  2416. * @cwmax: Maximum contention window [a value of the form 2^n-1 in the range
  2417. * 1..32767]
  2418. * @aifs: Arbitration interframe space [0..255]
  2419. * @link_id: link_id or -1 for non-MLD
  2420. */
  2421. struct ieee80211_txq_params {
  2422. enum nl80211_ac ac;
  2423. u16 txop;
  2424. u16 cwmin;
  2425. u16 cwmax;
  2426. u8 aifs;
  2427. int link_id;
  2428. };
  2429. /**
  2430. * DOC: Scanning and BSS list handling
  2431. *
  2432. * The scanning process itself is fairly simple, but cfg80211 offers quite
  2433. * a bit of helper functionality. To start a scan, the scan operation will
  2434. * be invoked with a scan definition. This scan definition contains the
  2435. * channels to scan, and the SSIDs to send probe requests for (including the
  2436. * wildcard, if desired). A passive scan is indicated by having no SSIDs to
  2437. * probe. Additionally, a scan request may contain extra information elements
  2438. * that should be added to the probe request. The IEs are guaranteed to be
  2439. * well-formed, and will not exceed the maximum length the driver advertised
  2440. * in the wiphy structure.
  2441. *
  2442. * When scanning finds a BSS, cfg80211 needs to be notified of that, because
  2443. * it is responsible for maintaining the BSS list; the driver should not
  2444. * maintain a list itself. For this notification, various functions exist.
  2445. *
  2446. * Since drivers do not maintain a BSS list, there are also a number of
  2447. * functions to search for a BSS and obtain information about it from the
  2448. * BSS structure cfg80211 maintains. The BSS list is also made available
  2449. * to userspace.
  2450. */
  2451. /**
  2452. * struct cfg80211_ssid - SSID description
  2453. * @ssid: the SSID
  2454. * @ssid_len: length of the ssid
  2455. */
  2456. struct cfg80211_ssid {
  2457. u8 ssid[IEEE80211_MAX_SSID_LEN];
  2458. u8 ssid_len;
  2459. };
  2460. /**
  2461. * struct cfg80211_scan_info - information about completed scan
  2462. * @scan_start_tsf: scan start time in terms of the TSF of the BSS that the
  2463. * wireless device that requested the scan is connected to. If this
  2464. * information is not available, this field is left zero.
  2465. * @tsf_bssid: the BSSID according to which %scan_start_tsf is set.
  2466. * @aborted: set to true if the scan was aborted for any reason,
  2467. * userspace will be notified of that
  2468. */
  2469. struct cfg80211_scan_info {
  2470. u64 scan_start_tsf;
  2471. u8 tsf_bssid[ETH_ALEN] __aligned(2);
  2472. bool aborted;
  2473. };
  2474. /**
  2475. * struct cfg80211_scan_6ghz_params - relevant for 6 GHz only
  2476. *
  2477. * @short_ssid: short ssid to scan for
  2478. * @bssid: bssid to scan for
  2479. * @channel_idx: idx of the channel in the channel array in the scan request
  2480. * which the above info is relevant to
  2481. * @unsolicited_probe: the AP transmits unsolicited probe response every 20 TU
  2482. * @short_ssid_valid: @short_ssid is valid and can be used
  2483. * @psc_no_listen: when set, and the channel is a PSC channel, no need to wait
  2484. * 20 TUs before starting to send probe requests.
  2485. * @psd_20: The AP's 20 MHz PSD value.
  2486. */
  2487. struct cfg80211_scan_6ghz_params {
  2488. u32 short_ssid;
  2489. u32 channel_idx;
  2490. u8 bssid[ETH_ALEN];
  2491. bool unsolicited_probe;
  2492. bool short_ssid_valid;
  2493. bool psc_no_listen;
  2494. s8 psd_20;
  2495. };
  2496. /**
  2497. * struct cfg80211_scan_request - scan request description
  2498. *
  2499. * @ssids: SSIDs to scan for (active scan only)
  2500. * @n_ssids: number of SSIDs
  2501. * @channels: channels to scan on.
  2502. * @n_channels: total number of channels to scan
  2503. * @ie: optional information element(s) to add into Probe Request or %NULL
  2504. * @ie_len: length of ie in octets
  2505. * @duration: how long to listen on each channel, in TUs. If
  2506. * %duration_mandatory is not set, this is the maximum dwell time and
  2507. * the actual dwell time may be shorter.
  2508. * @duration_mandatory: if set, the scan duration must be as specified by the
  2509. * %duration field.
  2510. * @flags: control flags from &enum nl80211_scan_flags
  2511. * @rates: bitmap of rates to advertise for each band
  2512. * @wiphy: the wiphy this was for
  2513. * @scan_start: time (in jiffies) when the scan started
  2514. * @wdev: the wireless device to scan for
  2515. * @info: (internal) information about completed scan
  2516. * @notified: (internal) scan request was notified as done or aborted
  2517. * @no_cck: used to send probe requests at non CCK rate in 2GHz band
  2518. * @mac_addr: MAC address used with randomisation
  2519. * @mac_addr_mask: MAC address mask used with randomisation, bits that
  2520. * are 0 in the mask should be randomised, bits that are 1 should
  2521. * be taken from the @mac_addr
  2522. * @scan_6ghz: relevant for split scan request only,
  2523. * true if this is the second scan request
  2524. * @n_6ghz_params: number of 6 GHz params
  2525. * @scan_6ghz_params: 6 GHz params
  2526. * @bssid: BSSID to scan for (most commonly, the wildcard BSSID)
  2527. * @tsf_report_link_id: for MLO, indicates the link ID of the BSS that should be
  2528. * used for TSF reporting. Can be set to -1 to indicate no preference.
  2529. */
  2530. struct cfg80211_scan_request {
  2531. struct cfg80211_ssid *ssids;
  2532. int n_ssids;
  2533. u32 n_channels;
  2534. const u8 *ie;
  2535. size_t ie_len;
  2536. u16 duration;
  2537. bool duration_mandatory;
  2538. u32 flags;
  2539. u32 rates[NUM_NL80211_BANDS];
  2540. struct wireless_dev *wdev;
  2541. u8 mac_addr[ETH_ALEN] __aligned(2);
  2542. u8 mac_addr_mask[ETH_ALEN] __aligned(2);
  2543. u8 bssid[ETH_ALEN] __aligned(2);
  2544. /* internal */
  2545. struct wiphy *wiphy;
  2546. unsigned long scan_start;
  2547. struct cfg80211_scan_info info;
  2548. bool notified;
  2549. bool no_cck;
  2550. bool scan_6ghz;
  2551. u32 n_6ghz_params;
  2552. struct cfg80211_scan_6ghz_params *scan_6ghz_params;
  2553. s8 tsf_report_link_id;
  2554. /* keep last */
  2555. struct ieee80211_channel *channels[];
  2556. };
  2557. static inline void get_random_mask_addr(u8 *buf, const u8 *addr, const u8 *mask)
  2558. {
  2559. int i;
  2560. get_random_bytes(buf, ETH_ALEN);
  2561. for (i = 0; i < ETH_ALEN; i++) {
  2562. buf[i] &= ~mask[i];
  2563. buf[i] |= addr[i] & mask[i];
  2564. }
  2565. }
  2566. /**
  2567. * struct cfg80211_match_set - sets of attributes to match
  2568. *
  2569. * @ssid: SSID to be matched; may be zero-length in case of BSSID match
  2570. * or no match (RSSI only)
  2571. * @bssid: BSSID to be matched; may be all-zero BSSID in case of SSID match
  2572. * or no match (RSSI only)
  2573. * @rssi_thold: don't report scan results below this threshold (in s32 dBm)
  2574. */
  2575. struct cfg80211_match_set {
  2576. struct cfg80211_ssid ssid;
  2577. u8 bssid[ETH_ALEN];
  2578. s32 rssi_thold;
  2579. };
  2580. /**
  2581. * struct cfg80211_sched_scan_plan - scan plan for scheduled scan
  2582. *
  2583. * @interval: interval between scheduled scan iterations. In seconds.
  2584. * @iterations: number of scan iterations in this scan plan. Zero means
  2585. * infinite loop.
  2586. * The last scan plan will always have this parameter set to zero,
  2587. * all other scan plans will have a finite number of iterations.
  2588. */
  2589. struct cfg80211_sched_scan_plan {
  2590. u32 interval;
  2591. u32 iterations;
  2592. };
  2593. /**
  2594. * struct cfg80211_bss_select_adjust - BSS selection with RSSI adjustment.
  2595. *
  2596. * @band: band of BSS which should match for RSSI level adjustment.
  2597. * @delta: value of RSSI level adjustment.
  2598. */
  2599. struct cfg80211_bss_select_adjust {
  2600. enum nl80211_band band;
  2601. s8 delta;
  2602. };
  2603. /**
  2604. * struct cfg80211_sched_scan_request - scheduled scan request description
  2605. *
  2606. * @reqid: identifies this request.
  2607. * @ssids: SSIDs to scan for (passed in the probe_reqs in active scans)
  2608. * @n_ssids: number of SSIDs
  2609. * @n_channels: total number of channels to scan
  2610. * @ie: optional information element(s) to add into Probe Request or %NULL
  2611. * @ie_len: length of ie in octets
  2612. * @flags: control flags from &enum nl80211_scan_flags
  2613. * @match_sets: sets of parameters to be matched for a scan result
  2614. * entry to be considered valid and to be passed to the host
  2615. * (others are filtered out).
  2616. * If omitted, all results are passed.
  2617. * @n_match_sets: number of match sets
  2618. * @report_results: indicates that results were reported for this request
  2619. * @wiphy: the wiphy this was for
  2620. * @dev: the interface
  2621. * @scan_start: start time of the scheduled scan
  2622. * @channels: channels to scan
  2623. * @min_rssi_thold: for drivers only supporting a single threshold, this
  2624. * contains the minimum over all matchsets
  2625. * @mac_addr: MAC address used with randomisation
  2626. * @mac_addr_mask: MAC address mask used with randomisation, bits that
  2627. * are 0 in the mask should be randomised, bits that are 1 should
  2628. * be taken from the @mac_addr
  2629. * @scan_plans: scan plans to be executed in this scheduled scan. Lowest
  2630. * index must be executed first.
  2631. * @n_scan_plans: number of scan plans, at least 1.
  2632. * @rcu_head: RCU callback used to free the struct
  2633. * @owner_nlportid: netlink portid of owner (if this should is a request
  2634. * owned by a particular socket)
  2635. * @nl_owner_dead: netlink owner socket was closed - this request be freed
  2636. * @list: for keeping list of requests.
  2637. * @delay: delay in seconds to use before starting the first scan
  2638. * cycle. The driver may ignore this parameter and start
  2639. * immediately (or at any other time), if this feature is not
  2640. * supported.
  2641. * @relative_rssi_set: Indicates whether @relative_rssi is set or not.
  2642. * @relative_rssi: Relative RSSI threshold in dB to restrict scan result
  2643. * reporting in connected state to cases where a matching BSS is determined
  2644. * to have better or slightly worse RSSI than the current connected BSS.
  2645. * The relative RSSI threshold values are ignored in disconnected state.
  2646. * @rssi_adjust: delta dB of RSSI preference to be given to the BSSs that belong
  2647. * to the specified band while deciding whether a better BSS is reported
  2648. * using @relative_rssi. If delta is a negative number, the BSSs that
  2649. * belong to the specified band will be penalized by delta dB in relative
  2650. * comparisons.
  2651. */
  2652. struct cfg80211_sched_scan_request {
  2653. u64 reqid;
  2654. struct cfg80211_ssid *ssids;
  2655. int n_ssids;
  2656. u32 n_channels;
  2657. const u8 *ie;
  2658. size_t ie_len;
  2659. u32 flags;
  2660. struct cfg80211_match_set *match_sets;
  2661. int n_match_sets;
  2662. s32 min_rssi_thold;
  2663. u32 delay;
  2664. struct cfg80211_sched_scan_plan *scan_plans;
  2665. int n_scan_plans;
  2666. u8 mac_addr[ETH_ALEN] __aligned(2);
  2667. u8 mac_addr_mask[ETH_ALEN] __aligned(2);
  2668. bool relative_rssi_set;
  2669. s8 relative_rssi;
  2670. struct cfg80211_bss_select_adjust rssi_adjust;
  2671. /* internal */
  2672. struct wiphy *wiphy;
  2673. struct net_device *dev;
  2674. unsigned long scan_start;
  2675. bool report_results;
  2676. struct rcu_head rcu_head;
  2677. u32 owner_nlportid;
  2678. bool nl_owner_dead;
  2679. struct list_head list;
  2680. /* keep last */
  2681. struct ieee80211_channel *channels[] __counted_by(n_channels);
  2682. };
  2683. /**
  2684. * enum cfg80211_signal_type - signal type
  2685. *
  2686. * @CFG80211_SIGNAL_TYPE_NONE: no signal strength information available
  2687. * @CFG80211_SIGNAL_TYPE_MBM: signal strength in mBm (100*dBm)
  2688. * @CFG80211_SIGNAL_TYPE_UNSPEC: signal strength, increasing from 0 through 100
  2689. */
  2690. enum cfg80211_signal_type {
  2691. CFG80211_SIGNAL_TYPE_NONE,
  2692. CFG80211_SIGNAL_TYPE_MBM,
  2693. CFG80211_SIGNAL_TYPE_UNSPEC,
  2694. };
  2695. /**
  2696. * struct cfg80211_inform_bss - BSS inform data
  2697. * @chan: channel the frame was received on
  2698. * @signal: signal strength value, according to the wiphy's
  2699. * signal type
  2700. * @boottime_ns: timestamp (CLOCK_BOOTTIME) when the information was
  2701. * received; should match the time when the frame was actually
  2702. * received by the device (not just by the host, in case it was
  2703. * buffered on the device) and be accurate to about 10ms.
  2704. * If the frame isn't buffered, just passing the return value of
  2705. * ktime_get_boottime_ns() is likely appropriate.
  2706. * @parent_tsf: the time at the start of reception of the first octet of the
  2707. * timestamp field of the frame. The time is the TSF of the BSS specified
  2708. * by %parent_bssid.
  2709. * @parent_bssid: the BSS according to which %parent_tsf is set. This is set to
  2710. * the BSS that requested the scan in which the beacon/probe was received.
  2711. * @chains: bitmask for filled values in @chain_signal.
  2712. * @chain_signal: per-chain signal strength of last received BSS in dBm.
  2713. * @restrict_use: restrict usage, if not set, assume @use_for is
  2714. * %NL80211_BSS_USE_FOR_NORMAL.
  2715. * @use_for: bitmap of possible usage for this BSS, see
  2716. * &enum nl80211_bss_use_for
  2717. * @cannot_use_reasons: the reasons (bitmap) for not being able to connect,
  2718. * if @restrict_use is set and @use_for is zero (empty); may be 0 for
  2719. * unspecified reasons; see &enum nl80211_bss_cannot_use_reasons
  2720. * @drv_data: Data to be passed through to @inform_bss
  2721. */
  2722. struct cfg80211_inform_bss {
  2723. struct ieee80211_channel *chan;
  2724. s32 signal;
  2725. u64 boottime_ns;
  2726. u64 parent_tsf;
  2727. u8 parent_bssid[ETH_ALEN] __aligned(2);
  2728. u8 chains;
  2729. s8 chain_signal[IEEE80211_MAX_CHAINS];
  2730. u8 restrict_use:1, use_for:7;
  2731. u8 cannot_use_reasons;
  2732. void *drv_data;
  2733. };
  2734. /**
  2735. * struct cfg80211_bss_ies - BSS entry IE data
  2736. * @tsf: TSF contained in the frame that carried these IEs
  2737. * @rcu_head: internal use, for freeing
  2738. * @len: length of the IEs
  2739. * @from_beacon: these IEs are known to come from a beacon
  2740. * @data: IE data
  2741. */
  2742. struct cfg80211_bss_ies {
  2743. u64 tsf;
  2744. struct rcu_head rcu_head;
  2745. int len;
  2746. bool from_beacon;
  2747. u8 data[];
  2748. };
  2749. /**
  2750. * struct cfg80211_bss - BSS description
  2751. *
  2752. * This structure describes a BSS (which may also be a mesh network)
  2753. * for use in scan results and similar.
  2754. *
  2755. * @channel: channel this BSS is on
  2756. * @bssid: BSSID of the BSS
  2757. * @beacon_interval: the beacon interval as from the frame
  2758. * @capability: the capability field in host byte order
  2759. * @ies: the information elements (Note that there is no guarantee that these
  2760. * are well-formed!); this is a pointer to either the beacon_ies or
  2761. * proberesp_ies depending on whether Probe Response frame has been
  2762. * received. It is always non-%NULL.
  2763. * @beacon_ies: the information elements from the last Beacon frame
  2764. * (implementation note: if @hidden_beacon_bss is set this struct doesn't
  2765. * own the beacon_ies, but they're just pointers to the ones from the
  2766. * @hidden_beacon_bss struct)
  2767. * @proberesp_ies: the information elements from the last Probe Response frame
  2768. * @proberesp_ecsa_stuck: ECSA element is stuck in the Probe Response frame,
  2769. * cannot rely on it having valid data
  2770. * @hidden_beacon_bss: in case this BSS struct represents a probe response from
  2771. * a BSS that hides the SSID in its beacon, this points to the BSS struct
  2772. * that holds the beacon data. @beacon_ies is still valid, of course, and
  2773. * points to the same data as hidden_beacon_bss->beacon_ies in that case.
  2774. * @transmitted_bss: pointer to the transmitted BSS, if this is a
  2775. * non-transmitted one (multi-BSSID support)
  2776. * @nontrans_list: list of non-transmitted BSS, if this is a transmitted one
  2777. * (multi-BSSID support)
  2778. * @signal: signal strength value (type depends on the wiphy's signal_type)
  2779. * @chains: bitmask for filled values in @chain_signal.
  2780. * @chain_signal: per-chain signal strength of last received BSS in dBm.
  2781. * @bssid_index: index in the multiple BSS set
  2782. * @max_bssid_indicator: max number of members in the BSS set
  2783. * @use_for: bitmap of possible usage for this BSS, see
  2784. * &enum nl80211_bss_use_for
  2785. * @cannot_use_reasons: the reasons (bitmap) for not being able to connect,
  2786. * if @restrict_use is set and @use_for is zero (empty); may be 0 for
  2787. * unspecified reasons; see &enum nl80211_bss_cannot_use_reasons
  2788. * @priv: private area for driver use, has at least wiphy->bss_priv_size bytes
  2789. */
  2790. struct cfg80211_bss {
  2791. struct ieee80211_channel *channel;
  2792. const struct cfg80211_bss_ies __rcu *ies;
  2793. const struct cfg80211_bss_ies __rcu *beacon_ies;
  2794. const struct cfg80211_bss_ies __rcu *proberesp_ies;
  2795. struct cfg80211_bss *hidden_beacon_bss;
  2796. struct cfg80211_bss *transmitted_bss;
  2797. struct list_head nontrans_list;
  2798. s32 signal;
  2799. u16 beacon_interval;
  2800. u16 capability;
  2801. u8 bssid[ETH_ALEN];
  2802. u8 chains;
  2803. s8 chain_signal[IEEE80211_MAX_CHAINS];
  2804. u8 proberesp_ecsa_stuck:1;
  2805. u8 bssid_index;
  2806. u8 max_bssid_indicator;
  2807. u8 use_for;
  2808. u8 cannot_use_reasons;
  2809. u8 priv[] __aligned(sizeof(void *));
  2810. };
  2811. /**
  2812. * ieee80211_bss_get_elem - find element with given ID
  2813. * @bss: the bss to search
  2814. * @id: the element ID
  2815. *
  2816. * Note that the return value is an RCU-protected pointer, so
  2817. * rcu_read_lock() must be held when calling this function.
  2818. * Return: %NULL if not found.
  2819. */
  2820. const struct element *ieee80211_bss_get_elem(struct cfg80211_bss *bss, u8 id);
  2821. /**
  2822. * ieee80211_bss_get_ie - find IE with given ID
  2823. * @bss: the bss to search
  2824. * @id: the element ID
  2825. *
  2826. * Note that the return value is an RCU-protected pointer, so
  2827. * rcu_read_lock() must be held when calling this function.
  2828. * Return: %NULL if not found.
  2829. */
  2830. static inline const u8 *ieee80211_bss_get_ie(struct cfg80211_bss *bss, u8 id)
  2831. {
  2832. return (const void *)ieee80211_bss_get_elem(bss, id);
  2833. }
  2834. /**
  2835. * struct cfg80211_auth_request - Authentication request data
  2836. *
  2837. * This structure provides information needed to complete IEEE 802.11
  2838. * authentication.
  2839. *
  2840. * @bss: The BSS to authenticate with, the callee must obtain a reference
  2841. * to it if it needs to keep it.
  2842. * @auth_type: Authentication type (algorithm)
  2843. * @ie: Extra IEs to add to Authentication frame or %NULL
  2844. * @ie_len: Length of ie buffer in octets
  2845. * @key_len: length of WEP key for shared key authentication
  2846. * @key_idx: index of WEP key for shared key authentication
  2847. * @key: WEP key for shared key authentication
  2848. * @auth_data: Fields and elements in Authentication frames. This contains
  2849. * the authentication frame body (non-IE and IE data), excluding the
  2850. * Authentication algorithm number, i.e., starting at the Authentication
  2851. * transaction sequence number field.
  2852. * @auth_data_len: Length of auth_data buffer in octets
  2853. * @link_id: if >= 0, indicates authentication should be done as an MLD,
  2854. * the interface address is included as the MLD address and the
  2855. * necessary link (with the given link_id) will be created (and
  2856. * given an MLD address) by the driver
  2857. * @ap_mld_addr: AP MLD address in case of authentication request with
  2858. * an AP MLD, valid iff @link_id >= 0
  2859. */
  2860. struct cfg80211_auth_request {
  2861. struct cfg80211_bss *bss;
  2862. const u8 *ie;
  2863. size_t ie_len;
  2864. enum nl80211_auth_type auth_type;
  2865. const u8 *key;
  2866. u8 key_len;
  2867. s8 key_idx;
  2868. const u8 *auth_data;
  2869. size_t auth_data_len;
  2870. s8 link_id;
  2871. const u8 *ap_mld_addr;
  2872. };
  2873. /**
  2874. * struct cfg80211_assoc_link - per-link information for MLO association
  2875. * @bss: the BSS pointer, see also &struct cfg80211_assoc_request::bss;
  2876. * if this is %NULL for a link, that link is not requested
  2877. * @elems: extra elements for the per-STA profile for this link
  2878. * @elems_len: length of the elements
  2879. * @disabled: If set this link should be included during association etc. but it
  2880. * should not be used until enabled by the AP MLD.
  2881. * @error: per-link error code, must be <= 0. If there is an error, then the
  2882. * operation as a whole must fail.
  2883. */
  2884. struct cfg80211_assoc_link {
  2885. struct cfg80211_bss *bss;
  2886. const u8 *elems;
  2887. size_t elems_len;
  2888. bool disabled;
  2889. int error;
  2890. };
  2891. /**
  2892. * enum cfg80211_assoc_req_flags - Over-ride default behaviour in association.
  2893. *
  2894. * @ASSOC_REQ_DISABLE_HT: Disable HT (802.11n)
  2895. * @ASSOC_REQ_DISABLE_VHT: Disable VHT
  2896. * @ASSOC_REQ_USE_RRM: Declare RRM capability in this association
  2897. * @CONNECT_REQ_EXTERNAL_AUTH_SUPPORT: User space indicates external
  2898. * authentication capability. Drivers can offload authentication to
  2899. * userspace if this flag is set. Only applicable for cfg80211_connect()
  2900. * request (connect callback).
  2901. * @ASSOC_REQ_DISABLE_HE: Disable HE
  2902. * @ASSOC_REQ_DISABLE_EHT: Disable EHT
  2903. * @CONNECT_REQ_MLO_SUPPORT: Userspace indicates support for handling MLD links.
  2904. * Drivers shall disable MLO features for the current association if this
  2905. * flag is not set.
  2906. * @ASSOC_REQ_SPP_AMSDU: SPP A-MSDUs will be used on this connection (if any)
  2907. */
  2908. enum cfg80211_assoc_req_flags {
  2909. ASSOC_REQ_DISABLE_HT = BIT(0),
  2910. ASSOC_REQ_DISABLE_VHT = BIT(1),
  2911. ASSOC_REQ_USE_RRM = BIT(2),
  2912. CONNECT_REQ_EXTERNAL_AUTH_SUPPORT = BIT(3),
  2913. ASSOC_REQ_DISABLE_HE = BIT(4),
  2914. ASSOC_REQ_DISABLE_EHT = BIT(5),
  2915. CONNECT_REQ_MLO_SUPPORT = BIT(6),
  2916. ASSOC_REQ_SPP_AMSDU = BIT(7),
  2917. };
  2918. /**
  2919. * struct cfg80211_assoc_request - (Re)Association request data
  2920. *
  2921. * This structure provides information needed to complete IEEE 802.11
  2922. * (re)association.
  2923. * @bss: The BSS to associate with. If the call is successful the driver is
  2924. * given a reference that it must give back to cfg80211_send_rx_assoc()
  2925. * or to cfg80211_assoc_timeout(). To ensure proper refcounting, new
  2926. * association requests while already associating must be rejected.
  2927. * This also applies to the @links.bss parameter, which is used instead
  2928. * of this one (it is %NULL) for MLO associations.
  2929. * @ie: Extra IEs to add to (Re)Association Request frame or %NULL
  2930. * @ie_len: Length of ie buffer in octets
  2931. * @use_mfp: Use management frame protection (IEEE 802.11w) in this association
  2932. * @crypto: crypto settings
  2933. * @prev_bssid: previous BSSID, if not %NULL use reassociate frame. This is used
  2934. * to indicate a request to reassociate within the ESS instead of a request
  2935. * do the initial association with the ESS. When included, this is set to
  2936. * the BSSID of the current association, i.e., to the value that is
  2937. * included in the Current AP address field of the Reassociation Request
  2938. * frame.
  2939. * @flags: See &enum cfg80211_assoc_req_flags
  2940. * @ht_capa: HT Capabilities over-rides. Values set in ht_capa_mask
  2941. * will be used in ht_capa. Un-supported values will be ignored.
  2942. * @ht_capa_mask: The bits of ht_capa which are to be used.
  2943. * @vht_capa: VHT capability override
  2944. * @vht_capa_mask: VHT capability mask indicating which fields to use
  2945. * @fils_kek: FILS KEK for protecting (Re)Association Request/Response frame or
  2946. * %NULL if FILS is not used.
  2947. * @fils_kek_len: Length of fils_kek in octets
  2948. * @fils_nonces: FILS nonces (part of AAD) for protecting (Re)Association
  2949. * Request/Response frame or %NULL if FILS is not used. This field starts
  2950. * with 16 octets of STA Nonce followed by 16 octets of AP Nonce.
  2951. * @s1g_capa: S1G capability override
  2952. * @s1g_capa_mask: S1G capability override mask
  2953. * @links: per-link information for MLO connections
  2954. * @link_id: >= 0 for MLO connections, where links are given, and indicates
  2955. * the link on which the association request should be sent
  2956. * @ap_mld_addr: AP MLD address in case of MLO association request,
  2957. * valid iff @link_id >= 0
  2958. */
  2959. struct cfg80211_assoc_request {
  2960. struct cfg80211_bss *bss;
  2961. const u8 *ie, *prev_bssid;
  2962. size_t ie_len;
  2963. struct cfg80211_crypto_settings crypto;
  2964. bool use_mfp;
  2965. u32 flags;
  2966. struct ieee80211_ht_cap ht_capa;
  2967. struct ieee80211_ht_cap ht_capa_mask;
  2968. struct ieee80211_vht_cap vht_capa, vht_capa_mask;
  2969. const u8 *fils_kek;
  2970. size_t fils_kek_len;
  2971. const u8 *fils_nonces;
  2972. struct ieee80211_s1g_cap s1g_capa, s1g_capa_mask;
  2973. struct cfg80211_assoc_link links[IEEE80211_MLD_MAX_NUM_LINKS];
  2974. const u8 *ap_mld_addr;
  2975. s8 link_id;
  2976. };
  2977. /**
  2978. * struct cfg80211_deauth_request - Deauthentication request data
  2979. *
  2980. * This structure provides information needed to complete IEEE 802.11
  2981. * deauthentication.
  2982. *
  2983. * @bssid: the BSSID or AP MLD address to deauthenticate from
  2984. * @ie: Extra IEs to add to Deauthentication frame or %NULL
  2985. * @ie_len: Length of ie buffer in octets
  2986. * @reason_code: The reason code for the deauthentication
  2987. * @local_state_change: if set, change local state only and
  2988. * do not set a deauth frame
  2989. */
  2990. struct cfg80211_deauth_request {
  2991. const u8 *bssid;
  2992. const u8 *ie;
  2993. size_t ie_len;
  2994. u16 reason_code;
  2995. bool local_state_change;
  2996. };
  2997. /**
  2998. * struct cfg80211_disassoc_request - Disassociation request data
  2999. *
  3000. * This structure provides information needed to complete IEEE 802.11
  3001. * disassociation.
  3002. *
  3003. * @ap_addr: the BSSID or AP MLD address to disassociate from
  3004. * @ie: Extra IEs to add to Disassociation frame or %NULL
  3005. * @ie_len: Length of ie buffer in octets
  3006. * @reason_code: The reason code for the disassociation
  3007. * @local_state_change: This is a request for a local state only, i.e., no
  3008. * Disassociation frame is to be transmitted.
  3009. */
  3010. struct cfg80211_disassoc_request {
  3011. const u8 *ap_addr;
  3012. const u8 *ie;
  3013. size_t ie_len;
  3014. u16 reason_code;
  3015. bool local_state_change;
  3016. };
  3017. /**
  3018. * struct cfg80211_ibss_params - IBSS parameters
  3019. *
  3020. * This structure defines the IBSS parameters for the join_ibss()
  3021. * method.
  3022. *
  3023. * @ssid: The SSID, will always be non-null.
  3024. * @ssid_len: The length of the SSID, will always be non-zero.
  3025. * @bssid: Fixed BSSID requested, maybe be %NULL, if set do not
  3026. * search for IBSSs with a different BSSID.
  3027. * @chandef: defines the channel to use if no other IBSS to join can be found
  3028. * @channel_fixed: The channel should be fixed -- do not search for
  3029. * IBSSs to join on other channels.
  3030. * @ie: information element(s) to include in the beacon
  3031. * @ie_len: length of that
  3032. * @beacon_interval: beacon interval to use
  3033. * @privacy: this is a protected network, keys will be configured
  3034. * after joining
  3035. * @control_port: whether user space controls IEEE 802.1X port, i.e.,
  3036. * sets/clears %NL80211_STA_FLAG_AUTHORIZED. If true, the driver is
  3037. * required to assume that the port is unauthorized until authorized by
  3038. * user space. Otherwise, port is marked authorized by default.
  3039. * @control_port_over_nl80211: TRUE if userspace expects to exchange control
  3040. * port frames over NL80211 instead of the network interface.
  3041. * @userspace_handles_dfs: whether user space controls DFS operation, i.e.
  3042. * changes the channel when a radar is detected. This is required
  3043. * to operate on DFS channels.
  3044. * @basic_rates: bitmap of basic rates to use when creating the IBSS
  3045. * @mcast_rate: per-band multicast rate index + 1 (0: disabled)
  3046. * @ht_capa: HT Capabilities over-rides. Values set in ht_capa_mask
  3047. * will be used in ht_capa. Un-supported values will be ignored.
  3048. * @ht_capa_mask: The bits of ht_capa which are to be used.
  3049. * @wep_keys: static WEP keys, if not NULL points to an array of
  3050. * CFG80211_MAX_WEP_KEYS WEP keys
  3051. * @wep_tx_key: key index (0..3) of the default TX static WEP key
  3052. */
  3053. struct cfg80211_ibss_params {
  3054. const u8 *ssid;
  3055. const u8 *bssid;
  3056. struct cfg80211_chan_def chandef;
  3057. const u8 *ie;
  3058. u8 ssid_len, ie_len;
  3059. u16 beacon_interval;
  3060. u32 basic_rates;
  3061. bool channel_fixed;
  3062. bool privacy;
  3063. bool control_port;
  3064. bool control_port_over_nl80211;
  3065. bool userspace_handles_dfs;
  3066. int mcast_rate[NUM_NL80211_BANDS];
  3067. struct ieee80211_ht_cap ht_capa;
  3068. struct ieee80211_ht_cap ht_capa_mask;
  3069. struct key_params *wep_keys;
  3070. int wep_tx_key;
  3071. };
  3072. /**
  3073. * struct cfg80211_bss_selection - connection parameters for BSS selection.
  3074. *
  3075. * @behaviour: requested BSS selection behaviour.
  3076. * @param: parameters for requestion behaviour.
  3077. * @param.band_pref: preferred band for %NL80211_BSS_SELECT_ATTR_BAND_PREF.
  3078. * @param.adjust: parameters for %NL80211_BSS_SELECT_ATTR_RSSI_ADJUST.
  3079. */
  3080. struct cfg80211_bss_selection {
  3081. enum nl80211_bss_select_attr behaviour;
  3082. union {
  3083. enum nl80211_band band_pref;
  3084. struct cfg80211_bss_select_adjust adjust;
  3085. } param;
  3086. };
  3087. /**
  3088. * struct cfg80211_connect_params - Connection parameters
  3089. *
  3090. * This structure provides information needed to complete IEEE 802.11
  3091. * authentication and association.
  3092. *
  3093. * @channel: The channel to use or %NULL if not specified (auto-select based
  3094. * on scan results)
  3095. * @channel_hint: The channel of the recommended BSS for initial connection or
  3096. * %NULL if not specified
  3097. * @bssid: The AP BSSID or %NULL if not specified (auto-select based on scan
  3098. * results)
  3099. * @bssid_hint: The recommended AP BSSID for initial connection to the BSS or
  3100. * %NULL if not specified. Unlike the @bssid parameter, the driver is
  3101. * allowed to ignore this @bssid_hint if it has knowledge of a better BSS
  3102. * to use.
  3103. * @ssid: SSID
  3104. * @ssid_len: Length of ssid in octets
  3105. * @auth_type: Authentication type (algorithm)
  3106. * @ie: IEs for association request
  3107. * @ie_len: Length of assoc_ie in octets
  3108. * @privacy: indicates whether privacy-enabled APs should be used
  3109. * @mfp: indicate whether management frame protection is used
  3110. * @crypto: crypto settings
  3111. * @key_len: length of WEP key for shared key authentication
  3112. * @key_idx: index of WEP key for shared key authentication
  3113. * @key: WEP key for shared key authentication
  3114. * @flags: See &enum cfg80211_assoc_req_flags
  3115. * @bg_scan_period: Background scan period in seconds
  3116. * or -1 to indicate that default value is to be used.
  3117. * @ht_capa: HT Capabilities over-rides. Values set in ht_capa_mask
  3118. * will be used in ht_capa. Un-supported values will be ignored.
  3119. * @ht_capa_mask: The bits of ht_capa which are to be used.
  3120. * @vht_capa: VHT Capability overrides
  3121. * @vht_capa_mask: The bits of vht_capa which are to be used.
  3122. * @pbss: if set, connect to a PCP instead of AP. Valid for DMG
  3123. * networks.
  3124. * @bss_select: criteria to be used for BSS selection.
  3125. * @prev_bssid: previous BSSID, if not %NULL use reassociate frame. This is used
  3126. * to indicate a request to reassociate within the ESS instead of a request
  3127. * do the initial association with the ESS. When included, this is set to
  3128. * the BSSID of the current association, i.e., to the value that is
  3129. * included in the Current AP address field of the Reassociation Request
  3130. * frame.
  3131. * @fils_erp_username: EAP re-authentication protocol (ERP) username part of the
  3132. * NAI or %NULL if not specified. This is used to construct FILS wrapped
  3133. * data IE.
  3134. * @fils_erp_username_len: Length of @fils_erp_username in octets.
  3135. * @fils_erp_realm: EAP re-authentication protocol (ERP) realm part of NAI or
  3136. * %NULL if not specified. This specifies the domain name of ER server and
  3137. * is used to construct FILS wrapped data IE.
  3138. * @fils_erp_realm_len: Length of @fils_erp_realm in octets.
  3139. * @fils_erp_next_seq_num: The next sequence number to use in the FILS ERP
  3140. * messages. This is also used to construct FILS wrapped data IE.
  3141. * @fils_erp_rrk: ERP re-authentication Root Key (rRK) used to derive additional
  3142. * keys in FILS or %NULL if not specified.
  3143. * @fils_erp_rrk_len: Length of @fils_erp_rrk in octets.
  3144. * @want_1x: indicates user-space supports and wants to use 802.1X driver
  3145. * offload of 4-way handshake.
  3146. * @edmg: define the EDMG channels.
  3147. * This may specify multiple channels and bonding options for the driver
  3148. * to choose from, based on BSS configuration.
  3149. */
  3150. struct cfg80211_connect_params {
  3151. struct ieee80211_channel *channel;
  3152. struct ieee80211_channel *channel_hint;
  3153. const u8 *bssid;
  3154. const u8 *bssid_hint;
  3155. const u8 *ssid;
  3156. size_t ssid_len;
  3157. enum nl80211_auth_type auth_type;
  3158. const u8 *ie;
  3159. size_t ie_len;
  3160. bool privacy;
  3161. enum nl80211_mfp mfp;
  3162. struct cfg80211_crypto_settings crypto;
  3163. const u8 *key;
  3164. u8 key_len, key_idx;
  3165. u32 flags;
  3166. int bg_scan_period;
  3167. struct ieee80211_ht_cap ht_capa;
  3168. struct ieee80211_ht_cap ht_capa_mask;
  3169. struct ieee80211_vht_cap vht_capa;
  3170. struct ieee80211_vht_cap vht_capa_mask;
  3171. bool pbss;
  3172. struct cfg80211_bss_selection bss_select;
  3173. const u8 *prev_bssid;
  3174. const u8 *fils_erp_username;
  3175. size_t fils_erp_username_len;
  3176. const u8 *fils_erp_realm;
  3177. size_t fils_erp_realm_len;
  3178. u16 fils_erp_next_seq_num;
  3179. const u8 *fils_erp_rrk;
  3180. size_t fils_erp_rrk_len;
  3181. bool want_1x;
  3182. struct ieee80211_edmg edmg;
  3183. };
  3184. /**
  3185. * enum cfg80211_connect_params_changed - Connection parameters being updated
  3186. *
  3187. * This enum provides information of all connect parameters that
  3188. * have to be updated as part of update_connect_params() call.
  3189. *
  3190. * @UPDATE_ASSOC_IES: Indicates whether association request IEs are updated
  3191. * @UPDATE_FILS_ERP_INFO: Indicates that FILS connection parameters (realm,
  3192. * username, erp sequence number and rrk) are updated
  3193. * @UPDATE_AUTH_TYPE: Indicates that authentication type is updated
  3194. */
  3195. enum cfg80211_connect_params_changed {
  3196. UPDATE_ASSOC_IES = BIT(0),
  3197. UPDATE_FILS_ERP_INFO = BIT(1),
  3198. UPDATE_AUTH_TYPE = BIT(2),
  3199. };
  3200. /**
  3201. * enum wiphy_params_flags - set_wiphy_params bitfield values
  3202. * @WIPHY_PARAM_RETRY_SHORT: wiphy->retry_short has changed
  3203. * @WIPHY_PARAM_RETRY_LONG: wiphy->retry_long has changed
  3204. * @WIPHY_PARAM_FRAG_THRESHOLD: wiphy->frag_threshold has changed
  3205. * @WIPHY_PARAM_RTS_THRESHOLD: wiphy->rts_threshold has changed
  3206. * @WIPHY_PARAM_COVERAGE_CLASS: coverage class changed
  3207. * @WIPHY_PARAM_DYN_ACK: dynack has been enabled
  3208. * @WIPHY_PARAM_TXQ_LIMIT: TXQ packet limit has been changed
  3209. * @WIPHY_PARAM_TXQ_MEMORY_LIMIT: TXQ memory limit has been changed
  3210. * @WIPHY_PARAM_TXQ_QUANTUM: TXQ scheduler quantum
  3211. */
  3212. enum wiphy_params_flags {
  3213. WIPHY_PARAM_RETRY_SHORT = BIT(0),
  3214. WIPHY_PARAM_RETRY_LONG = BIT(1),
  3215. WIPHY_PARAM_FRAG_THRESHOLD = BIT(2),
  3216. WIPHY_PARAM_RTS_THRESHOLD = BIT(3),
  3217. WIPHY_PARAM_COVERAGE_CLASS = BIT(4),
  3218. WIPHY_PARAM_DYN_ACK = BIT(5),
  3219. WIPHY_PARAM_TXQ_LIMIT = BIT(6),
  3220. WIPHY_PARAM_TXQ_MEMORY_LIMIT = BIT(7),
  3221. WIPHY_PARAM_TXQ_QUANTUM = BIT(8),
  3222. };
  3223. #define IEEE80211_DEFAULT_AIRTIME_WEIGHT 256
  3224. /* The per TXQ device queue limit in airtime */
  3225. #define IEEE80211_DEFAULT_AQL_TXQ_LIMIT_L 5000
  3226. #define IEEE80211_DEFAULT_AQL_TXQ_LIMIT_H 12000
  3227. /* The per interface airtime threshold to switch to lower queue limit */
  3228. #define IEEE80211_AQL_THRESHOLD 24000
  3229. /**
  3230. * struct cfg80211_pmksa - PMK Security Association
  3231. *
  3232. * This structure is passed to the set/del_pmksa() method for PMKSA
  3233. * caching.
  3234. *
  3235. * @bssid: The AP's BSSID (may be %NULL).
  3236. * @pmkid: The identifier to refer a PMKSA.
  3237. * @pmk: The PMK for the PMKSA identified by @pmkid. This is used for key
  3238. * derivation by a FILS STA. Otherwise, %NULL.
  3239. * @pmk_len: Length of the @pmk. The length of @pmk can differ depending on
  3240. * the hash algorithm used to generate this.
  3241. * @ssid: SSID to specify the ESS within which a PMKSA is valid when using FILS
  3242. * cache identifier (may be %NULL).
  3243. * @ssid_len: Length of the @ssid in octets.
  3244. * @cache_id: 2-octet cache identifier advertized by a FILS AP identifying the
  3245. * scope of PMKSA. This is valid only if @ssid_len is non-zero (may be
  3246. * %NULL).
  3247. * @pmk_lifetime: Maximum lifetime for PMKSA in seconds
  3248. * (dot11RSNAConfigPMKLifetime) or 0 if not specified.
  3249. * The configured PMKSA must not be used for PMKSA caching after
  3250. * expiration and any keys derived from this PMK become invalid on
  3251. * expiration, i.e., the current association must be dropped if the PMK
  3252. * used for it expires.
  3253. * @pmk_reauth_threshold: Threshold time for reauthentication (percentage of
  3254. * PMK lifetime, dot11RSNAConfigPMKReauthThreshold) or 0 if not specified.
  3255. * Drivers are expected to trigger a full authentication instead of using
  3256. * this PMKSA for caching when reassociating to a new BSS after this
  3257. * threshold to generate a new PMK before the current one expires.
  3258. */
  3259. struct cfg80211_pmksa {
  3260. const u8 *bssid;
  3261. const u8 *pmkid;
  3262. const u8 *pmk;
  3263. size_t pmk_len;
  3264. const u8 *ssid;
  3265. size_t ssid_len;
  3266. const u8 *cache_id;
  3267. u32 pmk_lifetime;
  3268. u8 pmk_reauth_threshold;
  3269. };
  3270. /**
  3271. * struct cfg80211_pkt_pattern - packet pattern
  3272. * @mask: bitmask where to match pattern and where to ignore bytes,
  3273. * one bit per byte, in same format as nl80211
  3274. * @pattern: bytes to match where bitmask is 1
  3275. * @pattern_len: length of pattern (in bytes)
  3276. * @pkt_offset: packet offset (in bytes)
  3277. *
  3278. * Internal note: @mask and @pattern are allocated in one chunk of
  3279. * memory, free @mask only!
  3280. */
  3281. struct cfg80211_pkt_pattern {
  3282. const u8 *mask, *pattern;
  3283. int pattern_len;
  3284. int pkt_offset;
  3285. };
  3286. /**
  3287. * struct cfg80211_wowlan_tcp - TCP connection parameters
  3288. *
  3289. * @sock: (internal) socket for source port allocation
  3290. * @src: source IP address
  3291. * @dst: destination IP address
  3292. * @dst_mac: destination MAC address
  3293. * @src_port: source port
  3294. * @dst_port: destination port
  3295. * @payload_len: data payload length
  3296. * @payload: data payload buffer
  3297. * @payload_seq: payload sequence stamping configuration
  3298. * @data_interval: interval at which to send data packets
  3299. * @wake_len: wakeup payload match length
  3300. * @wake_data: wakeup payload match data
  3301. * @wake_mask: wakeup payload match mask
  3302. * @tokens_size: length of the tokens buffer
  3303. * @payload_tok: payload token usage configuration
  3304. */
  3305. struct cfg80211_wowlan_tcp {
  3306. struct socket *sock;
  3307. __be32 src, dst;
  3308. u16 src_port, dst_port;
  3309. u8 dst_mac[ETH_ALEN];
  3310. int payload_len;
  3311. const u8 *payload;
  3312. struct nl80211_wowlan_tcp_data_seq payload_seq;
  3313. u32 data_interval;
  3314. u32 wake_len;
  3315. const u8 *wake_data, *wake_mask;
  3316. u32 tokens_size;
  3317. /* must be last, variable member */
  3318. struct nl80211_wowlan_tcp_data_token payload_tok;
  3319. };
  3320. /**
  3321. * struct cfg80211_wowlan - Wake on Wireless-LAN support info
  3322. *
  3323. * This structure defines the enabled WoWLAN triggers for the device.
  3324. * @any: wake up on any activity -- special trigger if device continues
  3325. * operating as normal during suspend
  3326. * @disconnect: wake up if getting disconnected
  3327. * @magic_pkt: wake up on receiving magic packet
  3328. * @patterns: wake up on receiving packet matching a pattern
  3329. * @n_patterns: number of patterns
  3330. * @gtk_rekey_failure: wake up on GTK rekey failure
  3331. * @eap_identity_req: wake up on EAP identity request packet
  3332. * @four_way_handshake: wake up on 4-way handshake
  3333. * @rfkill_release: wake up when rfkill is released
  3334. * @tcp: TCP connection establishment/wakeup parameters, see nl80211.h.
  3335. * NULL if not configured.
  3336. * @nd_config: configuration for the scan to be used for net detect wake.
  3337. */
  3338. struct cfg80211_wowlan {
  3339. bool any, disconnect, magic_pkt, gtk_rekey_failure,
  3340. eap_identity_req, four_way_handshake,
  3341. rfkill_release;
  3342. struct cfg80211_pkt_pattern *patterns;
  3343. struct cfg80211_wowlan_tcp *tcp;
  3344. int n_patterns;
  3345. struct cfg80211_sched_scan_request *nd_config;
  3346. };
  3347. /**
  3348. * struct cfg80211_coalesce_rules - Coalesce rule parameters
  3349. *
  3350. * This structure defines coalesce rule for the device.
  3351. * @delay: maximum coalescing delay in msecs.
  3352. * @condition: condition for packet coalescence.
  3353. * see &enum nl80211_coalesce_condition.
  3354. * @patterns: array of packet patterns
  3355. * @n_patterns: number of patterns
  3356. */
  3357. struct cfg80211_coalesce_rules {
  3358. int delay;
  3359. enum nl80211_coalesce_condition condition;
  3360. struct cfg80211_pkt_pattern *patterns;
  3361. int n_patterns;
  3362. };
  3363. /**
  3364. * struct cfg80211_coalesce - Packet coalescing settings
  3365. *
  3366. * This structure defines coalescing settings.
  3367. * @rules: array of coalesce rules
  3368. * @n_rules: number of rules
  3369. */
  3370. struct cfg80211_coalesce {
  3371. int n_rules;
  3372. struct cfg80211_coalesce_rules rules[] __counted_by(n_rules);
  3373. };
  3374. /**
  3375. * struct cfg80211_wowlan_nd_match - information about the match
  3376. *
  3377. * @ssid: SSID of the match that triggered the wake up
  3378. * @n_channels: Number of channels where the match occurred. This
  3379. * value may be zero if the driver can't report the channels.
  3380. * @channels: center frequencies of the channels where a match
  3381. * occurred (in MHz)
  3382. */
  3383. struct cfg80211_wowlan_nd_match {
  3384. struct cfg80211_ssid ssid;
  3385. int n_channels;
  3386. u32 channels[] __counted_by(n_channels);
  3387. };
  3388. /**
  3389. * struct cfg80211_wowlan_nd_info - net detect wake up information
  3390. *
  3391. * @n_matches: Number of match information instances provided in
  3392. * @matches. This value may be zero if the driver can't provide
  3393. * match information.
  3394. * @matches: Array of pointers to matches containing information about
  3395. * the matches that triggered the wake up.
  3396. */
  3397. struct cfg80211_wowlan_nd_info {
  3398. int n_matches;
  3399. struct cfg80211_wowlan_nd_match *matches[] __counted_by(n_matches);
  3400. };
  3401. /**
  3402. * struct cfg80211_wowlan_wakeup - wakeup report
  3403. * @disconnect: woke up by getting disconnected
  3404. * @magic_pkt: woke up by receiving magic packet
  3405. * @gtk_rekey_failure: woke up by GTK rekey failure
  3406. * @eap_identity_req: woke up by EAP identity request packet
  3407. * @four_way_handshake: woke up by 4-way handshake
  3408. * @rfkill_release: woke up by rfkill being released
  3409. * @pattern_idx: pattern that caused wakeup, -1 if not due to pattern
  3410. * @packet_present_len: copied wakeup packet data
  3411. * @packet_len: original wakeup packet length
  3412. * @packet: The packet causing the wakeup, if any.
  3413. * @packet_80211: For pattern match, magic packet and other data
  3414. * frame triggers an 802.3 frame should be reported, for
  3415. * disconnect due to deauth 802.11 frame. This indicates which
  3416. * it is.
  3417. * @tcp_match: TCP wakeup packet received
  3418. * @tcp_connlost: TCP connection lost or failed to establish
  3419. * @tcp_nomoretokens: TCP data ran out of tokens
  3420. * @net_detect: if not %NULL, woke up because of net detect
  3421. * @unprot_deauth_disassoc: woke up due to unprotected deauth or
  3422. * disassoc frame (in MFP).
  3423. */
  3424. struct cfg80211_wowlan_wakeup {
  3425. bool disconnect, magic_pkt, gtk_rekey_failure,
  3426. eap_identity_req, four_way_handshake,
  3427. rfkill_release, packet_80211,
  3428. tcp_match, tcp_connlost, tcp_nomoretokens,
  3429. unprot_deauth_disassoc;
  3430. s32 pattern_idx;
  3431. u32 packet_present_len, packet_len;
  3432. const void *packet;
  3433. struct cfg80211_wowlan_nd_info *net_detect;
  3434. };
  3435. /**
  3436. * struct cfg80211_gtk_rekey_data - rekey data
  3437. * @kek: key encryption key (@kek_len bytes)
  3438. * @kck: key confirmation key (@kck_len bytes)
  3439. * @replay_ctr: replay counter (NL80211_REPLAY_CTR_LEN bytes)
  3440. * @kek_len: length of kek
  3441. * @kck_len: length of kck
  3442. * @akm: akm (oui, id)
  3443. */
  3444. struct cfg80211_gtk_rekey_data {
  3445. const u8 *kek, *kck, *replay_ctr;
  3446. u32 akm;
  3447. u8 kek_len, kck_len;
  3448. };
  3449. /**
  3450. * struct cfg80211_update_ft_ies_params - FT IE Information
  3451. *
  3452. * This structure provides information needed to update the fast transition IE
  3453. *
  3454. * @md: The Mobility Domain ID, 2 Octet value
  3455. * @ie: Fast Transition IEs
  3456. * @ie_len: Length of ft_ie in octets
  3457. */
  3458. struct cfg80211_update_ft_ies_params {
  3459. u16 md;
  3460. const u8 *ie;
  3461. size_t ie_len;
  3462. };
  3463. /**
  3464. * struct cfg80211_mgmt_tx_params - mgmt tx parameters
  3465. *
  3466. * This structure provides information needed to transmit a mgmt frame
  3467. *
  3468. * @chan: channel to use
  3469. * @offchan: indicates whether off channel operation is required
  3470. * @wait: duration for ROC
  3471. * @buf: buffer to transmit
  3472. * @len: buffer length
  3473. * @no_cck: don't use cck rates for this frame
  3474. * @dont_wait_for_ack: tells the low level not to wait for an ack
  3475. * @n_csa_offsets: length of csa_offsets array
  3476. * @csa_offsets: array of all the csa offsets in the frame
  3477. * @link_id: for MLO, the link ID to transmit on, -1 if not given; note
  3478. * that the link ID isn't validated (much), it's in range but the
  3479. * link might not exist (or be used by the receiver STA)
  3480. */
  3481. struct cfg80211_mgmt_tx_params {
  3482. struct ieee80211_channel *chan;
  3483. bool offchan;
  3484. unsigned int wait;
  3485. const u8 *buf;
  3486. size_t len;
  3487. bool no_cck;
  3488. bool dont_wait_for_ack;
  3489. int n_csa_offsets;
  3490. const u16 *csa_offsets;
  3491. int link_id;
  3492. };
  3493. /**
  3494. * struct cfg80211_dscp_exception - DSCP exception
  3495. *
  3496. * @dscp: DSCP value that does not adhere to the user priority range definition
  3497. * @up: user priority value to which the corresponding DSCP value belongs
  3498. */
  3499. struct cfg80211_dscp_exception {
  3500. u8 dscp;
  3501. u8 up;
  3502. };
  3503. /**
  3504. * struct cfg80211_dscp_range - DSCP range definition for user priority
  3505. *
  3506. * @low: lowest DSCP value of this user priority range, inclusive
  3507. * @high: highest DSCP value of this user priority range, inclusive
  3508. */
  3509. struct cfg80211_dscp_range {
  3510. u8 low;
  3511. u8 high;
  3512. };
  3513. /* QoS Map Set element length defined in IEEE Std 802.11-2012, 8.4.2.97 */
  3514. #define IEEE80211_QOS_MAP_MAX_EX 21
  3515. #define IEEE80211_QOS_MAP_LEN_MIN 16
  3516. #define IEEE80211_QOS_MAP_LEN_MAX \
  3517. (IEEE80211_QOS_MAP_LEN_MIN + 2 * IEEE80211_QOS_MAP_MAX_EX)
  3518. /**
  3519. * struct cfg80211_qos_map - QoS Map Information
  3520. *
  3521. * This struct defines the Interworking QoS map setting for DSCP values
  3522. *
  3523. * @num_des: number of DSCP exceptions (0..21)
  3524. * @dscp_exception: optionally up to maximum of 21 DSCP exceptions from
  3525. * the user priority DSCP range definition
  3526. * @up: DSCP range definition for a particular user priority
  3527. */
  3528. struct cfg80211_qos_map {
  3529. u8 num_des;
  3530. struct cfg80211_dscp_exception dscp_exception[IEEE80211_QOS_MAP_MAX_EX];
  3531. struct cfg80211_dscp_range up[8];
  3532. };
  3533. /**
  3534. * struct cfg80211_nan_conf - NAN configuration
  3535. *
  3536. * This struct defines NAN configuration parameters
  3537. *
  3538. * @master_pref: master preference (1 - 255)
  3539. * @bands: operating bands, a bitmap of &enum nl80211_band values.
  3540. * For instance, for NL80211_BAND_2GHZ, bit 0 would be set
  3541. * (i.e. BIT(NL80211_BAND_2GHZ)).
  3542. */
  3543. struct cfg80211_nan_conf {
  3544. u8 master_pref;
  3545. u8 bands;
  3546. };
  3547. /**
  3548. * enum cfg80211_nan_conf_changes - indicates changed fields in NAN
  3549. * configuration
  3550. *
  3551. * @CFG80211_NAN_CONF_CHANGED_PREF: master preference
  3552. * @CFG80211_NAN_CONF_CHANGED_BANDS: operating bands
  3553. */
  3554. enum cfg80211_nan_conf_changes {
  3555. CFG80211_NAN_CONF_CHANGED_PREF = BIT(0),
  3556. CFG80211_NAN_CONF_CHANGED_BANDS = BIT(1),
  3557. };
  3558. /**
  3559. * struct cfg80211_nan_func_filter - a NAN function Rx / Tx filter
  3560. *
  3561. * @filter: the content of the filter
  3562. * @len: the length of the filter
  3563. */
  3564. struct cfg80211_nan_func_filter {
  3565. const u8 *filter;
  3566. u8 len;
  3567. };
  3568. /**
  3569. * struct cfg80211_nan_func - a NAN function
  3570. *
  3571. * @type: &enum nl80211_nan_function_type
  3572. * @service_id: the service ID of the function
  3573. * @publish_type: &nl80211_nan_publish_type
  3574. * @close_range: if true, the range should be limited. Threshold is
  3575. * implementation specific.
  3576. * @publish_bcast: if true, the solicited publish should be broadcasted
  3577. * @subscribe_active: if true, the subscribe is active
  3578. * @followup_id: the instance ID for follow up
  3579. * @followup_reqid: the requester instance ID for follow up
  3580. * @followup_dest: MAC address of the recipient of the follow up
  3581. * @ttl: time to live counter in DW.
  3582. * @serv_spec_info: Service Specific Info
  3583. * @serv_spec_info_len: Service Specific Info length
  3584. * @srf_include: if true, SRF is inclusive
  3585. * @srf_bf: Bloom Filter
  3586. * @srf_bf_len: Bloom Filter length
  3587. * @srf_bf_idx: Bloom Filter index
  3588. * @srf_macs: SRF MAC addresses
  3589. * @srf_num_macs: number of MAC addresses in SRF
  3590. * @rx_filters: rx filters that are matched with corresponding peer's tx_filter
  3591. * @tx_filters: filters that should be transmitted in the SDF.
  3592. * @num_rx_filters: length of &rx_filters.
  3593. * @num_tx_filters: length of &tx_filters.
  3594. * @instance_id: driver allocated id of the function.
  3595. * @cookie: unique NAN function identifier.
  3596. */
  3597. struct cfg80211_nan_func {
  3598. enum nl80211_nan_function_type type;
  3599. u8 service_id[NL80211_NAN_FUNC_SERVICE_ID_LEN];
  3600. u8 publish_type;
  3601. bool close_range;
  3602. bool publish_bcast;
  3603. bool subscribe_active;
  3604. u8 followup_id;
  3605. u8 followup_reqid;
  3606. struct mac_address followup_dest;
  3607. u32 ttl;
  3608. const u8 *serv_spec_info;
  3609. u8 serv_spec_info_len;
  3610. bool srf_include;
  3611. const u8 *srf_bf;
  3612. u8 srf_bf_len;
  3613. u8 srf_bf_idx;
  3614. struct mac_address *srf_macs;
  3615. int srf_num_macs;
  3616. struct cfg80211_nan_func_filter *rx_filters;
  3617. struct cfg80211_nan_func_filter *tx_filters;
  3618. u8 num_tx_filters;
  3619. u8 num_rx_filters;
  3620. u8 instance_id;
  3621. u64 cookie;
  3622. };
  3623. /**
  3624. * struct cfg80211_pmk_conf - PMK configuration
  3625. *
  3626. * @aa: authenticator address
  3627. * @pmk_len: PMK length in bytes.
  3628. * @pmk: the PMK material
  3629. * @pmk_r0_name: PMK-R0 Name. NULL if not applicable (i.e., the PMK
  3630. * is not PMK-R0). When pmk_r0_name is not NULL, the pmk field
  3631. * holds PMK-R0.
  3632. */
  3633. struct cfg80211_pmk_conf {
  3634. const u8 *aa;
  3635. u8 pmk_len;
  3636. const u8 *pmk;
  3637. const u8 *pmk_r0_name;
  3638. };
  3639. /**
  3640. * struct cfg80211_external_auth_params - Trigger External authentication.
  3641. *
  3642. * Commonly used across the external auth request and event interfaces.
  3643. *
  3644. * @action: action type / trigger for external authentication. Only significant
  3645. * for the authentication request event interface (driver to user space).
  3646. * @bssid: BSSID of the peer with which the authentication has
  3647. * to happen. Used by both the authentication request event and
  3648. * authentication response command interface.
  3649. * @ssid: SSID of the AP. Used by both the authentication request event and
  3650. * authentication response command interface.
  3651. * @key_mgmt_suite: AKM suite of the respective authentication. Used by the
  3652. * authentication request event interface.
  3653. * @status: status code, %WLAN_STATUS_SUCCESS for successful authentication,
  3654. * use %WLAN_STATUS_UNSPECIFIED_FAILURE if user space cannot give you
  3655. * the real status code for failures. Used only for the authentication
  3656. * response command interface (user space to driver).
  3657. * @pmkid: The identifier to refer a PMKSA.
  3658. * @mld_addr: MLD address of the peer. Used by the authentication request event
  3659. * interface. Driver indicates this to enable MLO during the authentication
  3660. * offload to user space. Driver shall look at %NL80211_ATTR_MLO_SUPPORT
  3661. * flag capability in NL80211_CMD_CONNECT to know whether the user space
  3662. * supports enabling MLO during the authentication offload.
  3663. * User space should use the address of the interface (on which the
  3664. * authentication request event reported) as self MLD address. User space
  3665. * and driver should use MLD addresses in RA, TA and BSSID fields of
  3666. * authentication frames sent or received via cfg80211. The driver
  3667. * translates the MLD addresses to/from link addresses based on the link
  3668. * chosen for the authentication.
  3669. */
  3670. struct cfg80211_external_auth_params {
  3671. enum nl80211_external_auth_action action;
  3672. u8 bssid[ETH_ALEN] __aligned(2);
  3673. struct cfg80211_ssid ssid;
  3674. unsigned int key_mgmt_suite;
  3675. u16 status;
  3676. const u8 *pmkid;
  3677. u8 mld_addr[ETH_ALEN] __aligned(2);
  3678. };
  3679. /**
  3680. * struct cfg80211_ftm_responder_stats - FTM responder statistics
  3681. *
  3682. * @filled: bitflag of flags using the bits of &enum nl80211_ftm_stats to
  3683. * indicate the relevant values in this struct for them
  3684. * @success_num: number of FTM sessions in which all frames were successfully
  3685. * answered
  3686. * @partial_num: number of FTM sessions in which part of frames were
  3687. * successfully answered
  3688. * @failed_num: number of failed FTM sessions
  3689. * @asap_num: number of ASAP FTM sessions
  3690. * @non_asap_num: number of non-ASAP FTM sessions
  3691. * @total_duration_ms: total sessions durations - gives an indication
  3692. * of how much time the responder was busy
  3693. * @unknown_triggers_num: number of unknown FTM triggers - triggers from
  3694. * initiators that didn't finish successfully the negotiation phase with
  3695. * the responder
  3696. * @reschedule_requests_num: number of FTM reschedule requests - initiator asks
  3697. * for a new scheduling although it already has scheduled FTM slot
  3698. * @out_of_window_triggers_num: total FTM triggers out of scheduled window
  3699. */
  3700. struct cfg80211_ftm_responder_stats {
  3701. u32 filled;
  3702. u32 success_num;
  3703. u32 partial_num;
  3704. u32 failed_num;
  3705. u32 asap_num;
  3706. u32 non_asap_num;
  3707. u64 total_duration_ms;
  3708. u32 unknown_triggers_num;
  3709. u32 reschedule_requests_num;
  3710. u32 out_of_window_triggers_num;
  3711. };
  3712. /**
  3713. * struct cfg80211_pmsr_ftm_result - FTM result
  3714. * @failure_reason: if this measurement failed (PMSR status is
  3715. * %NL80211_PMSR_STATUS_FAILURE), this gives a more precise
  3716. * reason than just "failure"
  3717. * @burst_index: if reporting partial results, this is the index
  3718. * in [0 .. num_bursts-1] of the burst that's being reported
  3719. * @num_ftmr_attempts: number of FTM request frames transmitted
  3720. * @num_ftmr_successes: number of FTM request frames acked
  3721. * @busy_retry_time: if failure_reason is %NL80211_PMSR_FTM_FAILURE_PEER_BUSY,
  3722. * fill this to indicate in how many seconds a retry is deemed possible
  3723. * by the responder
  3724. * @num_bursts_exp: actual number of bursts exponent negotiated
  3725. * @burst_duration: actual burst duration negotiated
  3726. * @ftms_per_burst: actual FTMs per burst negotiated
  3727. * @lci_len: length of LCI information (if present)
  3728. * @civicloc_len: length of civic location information (if present)
  3729. * @lci: LCI data (may be %NULL)
  3730. * @civicloc: civic location data (may be %NULL)
  3731. * @rssi_avg: average RSSI over FTM action frames reported
  3732. * @rssi_spread: spread of the RSSI over FTM action frames reported
  3733. * @tx_rate: bitrate for transmitted FTM action frame response
  3734. * @rx_rate: bitrate of received FTM action frame
  3735. * @rtt_avg: average of RTTs measured (must have either this or @dist_avg)
  3736. * @rtt_variance: variance of RTTs measured (note that standard deviation is
  3737. * the square root of the variance)
  3738. * @rtt_spread: spread of the RTTs measured
  3739. * @dist_avg: average of distances (mm) measured
  3740. * (must have either this or @rtt_avg)
  3741. * @dist_variance: variance of distances measured (see also @rtt_variance)
  3742. * @dist_spread: spread of distances measured (see also @rtt_spread)
  3743. * @num_ftmr_attempts_valid: @num_ftmr_attempts is valid
  3744. * @num_ftmr_successes_valid: @num_ftmr_successes is valid
  3745. * @rssi_avg_valid: @rssi_avg is valid
  3746. * @rssi_spread_valid: @rssi_spread is valid
  3747. * @tx_rate_valid: @tx_rate is valid
  3748. * @rx_rate_valid: @rx_rate is valid
  3749. * @rtt_avg_valid: @rtt_avg is valid
  3750. * @rtt_variance_valid: @rtt_variance is valid
  3751. * @rtt_spread_valid: @rtt_spread is valid
  3752. * @dist_avg_valid: @dist_avg is valid
  3753. * @dist_variance_valid: @dist_variance is valid
  3754. * @dist_spread_valid: @dist_spread is valid
  3755. */
  3756. struct cfg80211_pmsr_ftm_result {
  3757. const u8 *lci;
  3758. const u8 *civicloc;
  3759. unsigned int lci_len;
  3760. unsigned int civicloc_len;
  3761. enum nl80211_peer_measurement_ftm_failure_reasons failure_reason;
  3762. u32 num_ftmr_attempts, num_ftmr_successes;
  3763. s16 burst_index;
  3764. u8 busy_retry_time;
  3765. u8 num_bursts_exp;
  3766. u8 burst_duration;
  3767. u8 ftms_per_burst;
  3768. s32 rssi_avg;
  3769. s32 rssi_spread;
  3770. struct rate_info tx_rate, rx_rate;
  3771. s64 rtt_avg;
  3772. s64 rtt_variance;
  3773. s64 rtt_spread;
  3774. s64 dist_avg;
  3775. s64 dist_variance;
  3776. s64 dist_spread;
  3777. u16 num_ftmr_attempts_valid:1,
  3778. num_ftmr_successes_valid:1,
  3779. rssi_avg_valid:1,
  3780. rssi_spread_valid:1,
  3781. tx_rate_valid:1,
  3782. rx_rate_valid:1,
  3783. rtt_avg_valid:1,
  3784. rtt_variance_valid:1,
  3785. rtt_spread_valid:1,
  3786. dist_avg_valid:1,
  3787. dist_variance_valid:1,
  3788. dist_spread_valid:1;
  3789. };
  3790. /**
  3791. * struct cfg80211_pmsr_result - peer measurement result
  3792. * @addr: address of the peer
  3793. * @host_time: host time (use ktime_get_boottime() adjust to the time when the
  3794. * measurement was made)
  3795. * @ap_tsf: AP's TSF at measurement time
  3796. * @status: status of the measurement
  3797. * @final: if reporting partial results, mark this as the last one; if not
  3798. * reporting partial results always set this flag
  3799. * @ap_tsf_valid: indicates the @ap_tsf value is valid
  3800. * @type: type of the measurement reported, note that we only support reporting
  3801. * one type at a time, but you can report multiple results separately and
  3802. * they're all aggregated for userspace.
  3803. * @ftm: FTM result
  3804. */
  3805. struct cfg80211_pmsr_result {
  3806. u64 host_time, ap_tsf;
  3807. enum nl80211_peer_measurement_status status;
  3808. u8 addr[ETH_ALEN];
  3809. u8 final:1,
  3810. ap_tsf_valid:1;
  3811. enum nl80211_peer_measurement_type type;
  3812. union {
  3813. struct cfg80211_pmsr_ftm_result ftm;
  3814. };
  3815. };
  3816. /**
  3817. * struct cfg80211_pmsr_ftm_request_peer - FTM request data
  3818. * @requested: indicates FTM is requested
  3819. * @preamble: frame preamble to use
  3820. * @burst_period: burst period to use
  3821. * @asap: indicates to use ASAP mode
  3822. * @num_bursts_exp: number of bursts exponent
  3823. * @burst_duration: burst duration
  3824. * @ftms_per_burst: number of FTMs per burst
  3825. * @ftmr_retries: number of retries for FTM request
  3826. * @request_lci: request LCI information
  3827. * @request_civicloc: request civic location information
  3828. * @trigger_based: use trigger based ranging for the measurement
  3829. * If neither @trigger_based nor @non_trigger_based is set,
  3830. * EDCA based ranging will be used.
  3831. * @non_trigger_based: use non trigger based ranging for the measurement
  3832. * If neither @trigger_based nor @non_trigger_based is set,
  3833. * EDCA based ranging will be used.
  3834. * @lmr_feedback: negotiate for I2R LMR feedback. Only valid if either
  3835. * @trigger_based or @non_trigger_based is set.
  3836. * @bss_color: the bss color of the responder. Optional. Set to zero to
  3837. * indicate the driver should set the BSS color. Only valid if
  3838. * @non_trigger_based or @trigger_based is set.
  3839. *
  3840. * See also nl80211 for the respective attribute documentation.
  3841. */
  3842. struct cfg80211_pmsr_ftm_request_peer {
  3843. enum nl80211_preamble preamble;
  3844. u16 burst_period;
  3845. u8 requested:1,
  3846. asap:1,
  3847. request_lci:1,
  3848. request_civicloc:1,
  3849. trigger_based:1,
  3850. non_trigger_based:1,
  3851. lmr_feedback:1;
  3852. u8 num_bursts_exp;
  3853. u8 burst_duration;
  3854. u8 ftms_per_burst;
  3855. u8 ftmr_retries;
  3856. u8 bss_color;
  3857. };
  3858. /**
  3859. * struct cfg80211_pmsr_request_peer - peer data for a peer measurement request
  3860. * @addr: MAC address
  3861. * @chandef: channel to use
  3862. * @report_ap_tsf: report the associated AP's TSF
  3863. * @ftm: FTM data, see &struct cfg80211_pmsr_ftm_request_peer
  3864. */
  3865. struct cfg80211_pmsr_request_peer {
  3866. u8 addr[ETH_ALEN];
  3867. struct cfg80211_chan_def chandef;
  3868. u8 report_ap_tsf:1;
  3869. struct cfg80211_pmsr_ftm_request_peer ftm;
  3870. };
  3871. /**
  3872. * struct cfg80211_pmsr_request - peer measurement request
  3873. * @cookie: cookie, set by cfg80211
  3874. * @nl_portid: netlink portid - used by cfg80211
  3875. * @drv_data: driver data for this request, if required for aborting,
  3876. * not otherwise freed or anything by cfg80211
  3877. * @mac_addr: MAC address used for (randomised) request
  3878. * @mac_addr_mask: MAC address mask used for randomisation, bits that
  3879. * are 0 in the mask should be randomised, bits that are 1 should
  3880. * be taken from the @mac_addr
  3881. * @list: used by cfg80211 to hold on to the request
  3882. * @timeout: timeout (in milliseconds) for the whole operation, if
  3883. * zero it means there's no timeout
  3884. * @n_peers: number of peers to do measurements with
  3885. * @peers: per-peer measurement request data
  3886. */
  3887. struct cfg80211_pmsr_request {
  3888. u64 cookie;
  3889. void *drv_data;
  3890. u32 n_peers;
  3891. u32 nl_portid;
  3892. u32 timeout;
  3893. u8 mac_addr[ETH_ALEN] __aligned(2);
  3894. u8 mac_addr_mask[ETH_ALEN] __aligned(2);
  3895. struct list_head list;
  3896. struct cfg80211_pmsr_request_peer peers[] __counted_by(n_peers);
  3897. };
  3898. /**
  3899. * struct cfg80211_update_owe_info - OWE Information
  3900. *
  3901. * This structure provides information needed for the drivers to offload OWE
  3902. * (Opportunistic Wireless Encryption) processing to the user space.
  3903. *
  3904. * Commonly used across update_owe_info request and event interfaces.
  3905. *
  3906. * @peer: MAC address of the peer device for which the OWE processing
  3907. * has to be done.
  3908. * @status: status code, %WLAN_STATUS_SUCCESS for successful OWE info
  3909. * processing, use %WLAN_STATUS_UNSPECIFIED_FAILURE if user space
  3910. * cannot give you the real status code for failures. Used only for
  3911. * OWE update request command interface (user space to driver).
  3912. * @ie: IEs obtained from the peer or constructed by the user space. These are
  3913. * the IEs of the remote peer in the event from the host driver and
  3914. * the constructed IEs by the user space in the request interface.
  3915. * @ie_len: Length of IEs in octets.
  3916. * @assoc_link_id: MLO link ID of the AP, with which (re)association requested
  3917. * by peer. This will be filled by driver for both MLO and non-MLO station
  3918. * connections when the AP affiliated with an MLD. For non-MLD AP mode, it
  3919. * will be -1. Used only with OWE update event (driver to user space).
  3920. * @peer_mld_addr: For MLO connection, MLD address of the peer. For non-MLO
  3921. * connection, it will be all zeros. This is applicable only when
  3922. * @assoc_link_id is not -1, i.e., the AP affiliated with an MLD. Used only
  3923. * with OWE update event (driver to user space).
  3924. */
  3925. struct cfg80211_update_owe_info {
  3926. u8 peer[ETH_ALEN] __aligned(2);
  3927. u16 status;
  3928. const u8 *ie;
  3929. size_t ie_len;
  3930. int assoc_link_id;
  3931. u8 peer_mld_addr[ETH_ALEN] __aligned(2);
  3932. };
  3933. /**
  3934. * struct mgmt_frame_regs - management frame registrations data
  3935. * @global_stypes: bitmap of management frame subtypes registered
  3936. * for the entire device
  3937. * @interface_stypes: bitmap of management frame subtypes registered
  3938. * for the given interface
  3939. * @global_mcast_stypes: mcast RX is needed globally for these subtypes
  3940. * @interface_mcast_stypes: mcast RX is needed on this interface
  3941. * for these subtypes
  3942. */
  3943. struct mgmt_frame_regs {
  3944. u32 global_stypes, interface_stypes;
  3945. u32 global_mcast_stypes, interface_mcast_stypes;
  3946. };
  3947. /**
  3948. * struct cfg80211_ops - backend description for wireless configuration
  3949. *
  3950. * This struct is registered by fullmac card drivers and/or wireless stacks
  3951. * in order to handle configuration requests on their interfaces.
  3952. *
  3953. * All callbacks except where otherwise noted should return 0
  3954. * on success or a negative error code.
  3955. *
  3956. * All operations are invoked with the wiphy mutex held. The RTNL may be
  3957. * held in addition (due to wireless extensions) but this cannot be relied
  3958. * upon except in cases where documented below. Note that due to ordering,
  3959. * the RTNL also cannot be acquired in any handlers.
  3960. *
  3961. * @suspend: wiphy device needs to be suspended. The variable @wow will
  3962. * be %NULL or contain the enabled Wake-on-Wireless triggers that are
  3963. * configured for the device.
  3964. * @resume: wiphy device needs to be resumed
  3965. * @set_wakeup: Called when WoWLAN is enabled/disabled, use this callback
  3966. * to call device_set_wakeup_enable() to enable/disable wakeup from
  3967. * the device.
  3968. *
  3969. * @add_virtual_intf: create a new virtual interface with the given name,
  3970. * must set the struct wireless_dev's iftype. Beware: You must create
  3971. * the new netdev in the wiphy's network namespace! Returns the struct
  3972. * wireless_dev, or an ERR_PTR. For P2P device wdevs, the driver must
  3973. * also set the address member in the wdev.
  3974. * This additionally holds the RTNL to be able to do netdev changes.
  3975. *
  3976. * @del_virtual_intf: remove the virtual interface
  3977. * This additionally holds the RTNL to be able to do netdev changes.
  3978. *
  3979. * @change_virtual_intf: change type/configuration of virtual interface,
  3980. * keep the struct wireless_dev's iftype updated.
  3981. * This additionally holds the RTNL to be able to do netdev changes.
  3982. *
  3983. * @add_intf_link: Add a new MLO link to the given interface. Note that
  3984. * the wdev->link[] data structure has been updated, so the new link
  3985. * address is available.
  3986. * @del_intf_link: Remove an MLO link from the given interface.
  3987. *
  3988. * @add_key: add a key with the given parameters. @mac_addr will be %NULL
  3989. * when adding a group key. @link_id will be -1 for non-MLO connection.
  3990. * For MLO connection, @link_id will be >= 0 for group key and -1 for
  3991. * pairwise key, @mac_addr will be peer's MLD address for MLO pairwise key.
  3992. *
  3993. * @get_key: get information about the key with the given parameters.
  3994. * @mac_addr will be %NULL when requesting information for a group
  3995. * key. All pointers given to the @callback function need not be valid
  3996. * after it returns. This function should return an error if it is
  3997. * not possible to retrieve the key, -ENOENT if it doesn't exist.
  3998. * @link_id will be -1 for non-MLO connection. For MLO connection,
  3999. * @link_id will be >= 0 for group key and -1 for pairwise key, @mac_addr
  4000. * will be peer's MLD address for MLO pairwise key.
  4001. *
  4002. * @del_key: remove a key given the @mac_addr (%NULL for a group key)
  4003. * and @key_index, return -ENOENT if the key doesn't exist. @link_id will
  4004. * be -1 for non-MLO connection. For MLO connection, @link_id will be >= 0
  4005. * for group key and -1 for pairwise key, @mac_addr will be peer's MLD
  4006. * address for MLO pairwise key.
  4007. *
  4008. * @set_default_key: set the default key on an interface. @link_id will be >= 0
  4009. * for MLO connection and -1 for non-MLO connection.
  4010. *
  4011. * @set_default_mgmt_key: set the default management frame key on an interface.
  4012. * @link_id will be >= 0 for MLO connection and -1 for non-MLO connection.
  4013. *
  4014. * @set_default_beacon_key: set the default Beacon frame key on an interface.
  4015. * @link_id will be >= 0 for MLO connection and -1 for non-MLO connection.
  4016. *
  4017. * @set_rekey_data: give the data necessary for GTK rekeying to the driver
  4018. *
  4019. * @start_ap: Start acting in AP mode defined by the parameters.
  4020. * @change_beacon: Change the beacon parameters for an access point mode
  4021. * interface. This should reject the call when AP mode wasn't started.
  4022. * @stop_ap: Stop being an AP, including stopping beaconing.
  4023. *
  4024. * @add_station: Add a new station.
  4025. * @del_station: Remove a station
  4026. * @change_station: Modify a given station. Note that flags changes are not much
  4027. * validated in cfg80211, in particular the auth/assoc/authorized flags
  4028. * might come to the driver in invalid combinations -- make sure to check
  4029. * them, also against the existing state! Drivers must call
  4030. * cfg80211_check_station_change() to validate the information.
  4031. * @get_station: get station information for the station identified by @mac
  4032. * @dump_station: dump station callback -- resume dump at index @idx
  4033. *
  4034. * @add_mpath: add a fixed mesh path
  4035. * @del_mpath: delete a given mesh path
  4036. * @change_mpath: change a given mesh path
  4037. * @get_mpath: get a mesh path for the given parameters
  4038. * @dump_mpath: dump mesh path callback -- resume dump at index @idx
  4039. * @get_mpp: get a mesh proxy path for the given parameters
  4040. * @dump_mpp: dump mesh proxy path callback -- resume dump at index @idx
  4041. * @join_mesh: join the mesh network with the specified parameters
  4042. * (invoked with the wireless_dev mutex held)
  4043. * @leave_mesh: leave the current mesh network
  4044. * (invoked with the wireless_dev mutex held)
  4045. *
  4046. * @get_mesh_config: Get the current mesh configuration
  4047. *
  4048. * @update_mesh_config: Update mesh parameters on a running mesh.
  4049. * The mask is a bitfield which tells us which parameters to
  4050. * set, and which to leave alone.
  4051. *
  4052. * @change_bss: Modify parameters for a given BSS.
  4053. *
  4054. * @inform_bss: Called by cfg80211 while being informed about new BSS data
  4055. * for every BSS found within the reported data or frame. This is called
  4056. * from within the cfg8011 inform_bss handlers while holding the bss_lock.
  4057. * The data parameter is passed through from drv_data inside
  4058. * struct cfg80211_inform_bss.
  4059. * The new IE data for the BSS is explicitly passed.
  4060. *
  4061. * @set_txq_params: Set TX queue parameters
  4062. *
  4063. * @libertas_set_mesh_channel: Only for backward compatibility for libertas,
  4064. * as it doesn't implement join_mesh and needs to set the channel to
  4065. * join the mesh instead.
  4066. *
  4067. * @set_monitor_channel: Set the monitor mode channel for the device. If other
  4068. * interfaces are active this callback should reject the configuration.
  4069. * If no interfaces are active or the device is down, the channel should
  4070. * be stored for when a monitor interface becomes active.
  4071. *
  4072. * @scan: Request to do a scan. If returning zero, the scan request is given
  4073. * the driver, and will be valid until passed to cfg80211_scan_done().
  4074. * For scan results, call cfg80211_inform_bss(); you can call this outside
  4075. * the scan/scan_done bracket too.
  4076. * @abort_scan: Tell the driver to abort an ongoing scan. The driver shall
  4077. * indicate the status of the scan through cfg80211_scan_done().
  4078. *
  4079. * @auth: Request to authenticate with the specified peer
  4080. * (invoked with the wireless_dev mutex held)
  4081. * @assoc: Request to (re)associate with the specified peer
  4082. * (invoked with the wireless_dev mutex held)
  4083. * @deauth: Request to deauthenticate from the specified peer
  4084. * (invoked with the wireless_dev mutex held)
  4085. * @disassoc: Request to disassociate from the specified peer
  4086. * (invoked with the wireless_dev mutex held)
  4087. *
  4088. * @connect: Connect to the ESS with the specified parameters. When connected,
  4089. * call cfg80211_connect_result()/cfg80211_connect_bss() with status code
  4090. * %WLAN_STATUS_SUCCESS. If the connection fails for some reason, call
  4091. * cfg80211_connect_result()/cfg80211_connect_bss() with the status code
  4092. * from the AP or cfg80211_connect_timeout() if no frame with status code
  4093. * was received.
  4094. * The driver is allowed to roam to other BSSes within the ESS when the
  4095. * other BSS matches the connect parameters. When such roaming is initiated
  4096. * by the driver, the driver is expected to verify that the target matches
  4097. * the configured security parameters and to use Reassociation Request
  4098. * frame instead of Association Request frame.
  4099. * The connect function can also be used to request the driver to perform a
  4100. * specific roam when connected to an ESS. In that case, the prev_bssid
  4101. * parameter is set to the BSSID of the currently associated BSS as an
  4102. * indication of requesting reassociation.
  4103. * In both the driver-initiated and new connect() call initiated roaming
  4104. * cases, the result of roaming is indicated with a call to
  4105. * cfg80211_roamed(). (invoked with the wireless_dev mutex held)
  4106. * @update_connect_params: Update the connect parameters while connected to a
  4107. * BSS. The updated parameters can be used by driver/firmware for
  4108. * subsequent BSS selection (roaming) decisions and to form the
  4109. * Authentication/(Re)Association Request frames. This call does not
  4110. * request an immediate disassociation or reassociation with the current
  4111. * BSS, i.e., this impacts only subsequent (re)associations. The bits in
  4112. * changed are defined in &enum cfg80211_connect_params_changed.
  4113. * (invoked with the wireless_dev mutex held)
  4114. * @disconnect: Disconnect from the BSS/ESS or stop connection attempts if
  4115. * connection is in progress. Once done, call cfg80211_disconnected() in
  4116. * case connection was already established (invoked with the
  4117. * wireless_dev mutex held), otherwise call cfg80211_connect_timeout().
  4118. *
  4119. * @join_ibss: Join the specified IBSS (or create if necessary). Once done, call
  4120. * cfg80211_ibss_joined(), also call that function when changing BSSID due
  4121. * to a merge.
  4122. * (invoked with the wireless_dev mutex held)
  4123. * @leave_ibss: Leave the IBSS.
  4124. * (invoked with the wireless_dev mutex held)
  4125. *
  4126. * @set_mcast_rate: Set the specified multicast rate (only if vif is in ADHOC or
  4127. * MESH mode)
  4128. *
  4129. * @set_wiphy_params: Notify that wiphy parameters have changed;
  4130. * @changed bitfield (see &enum wiphy_params_flags) describes which values
  4131. * have changed. The actual parameter values are available in
  4132. * struct wiphy. If returning an error, no value should be changed.
  4133. *
  4134. * @set_tx_power: set the transmit power according to the parameters,
  4135. * the power passed is in mBm, to get dBm use MBM_TO_DBM(). The
  4136. * wdev may be %NULL if power was set for the wiphy, and will
  4137. * always be %NULL unless the driver supports per-vif TX power
  4138. * (as advertised by the nl80211 feature flag.)
  4139. * @get_tx_power: store the current TX power into the dbm variable;
  4140. * return 0 if successful
  4141. *
  4142. * @rfkill_poll: polls the hw rfkill line, use cfg80211 reporting
  4143. * functions to adjust rfkill hw state
  4144. *
  4145. * @dump_survey: get site survey information.
  4146. *
  4147. * @remain_on_channel: Request the driver to remain awake on the specified
  4148. * channel for the specified duration to complete an off-channel
  4149. * operation (e.g., public action frame exchange). When the driver is
  4150. * ready on the requested channel, it must indicate this with an event
  4151. * notification by calling cfg80211_ready_on_channel().
  4152. * @cancel_remain_on_channel: Cancel an on-going remain-on-channel operation.
  4153. * This allows the operation to be terminated prior to timeout based on
  4154. * the duration value.
  4155. * @mgmt_tx: Transmit a management frame.
  4156. * @mgmt_tx_cancel_wait: Cancel the wait time from transmitting a management
  4157. * frame on another channel
  4158. *
  4159. * @testmode_cmd: run a test mode command; @wdev may be %NULL
  4160. * @testmode_dump: Implement a test mode dump. The cb->args[2] and up may be
  4161. * used by the function, but 0 and 1 must not be touched. Additionally,
  4162. * return error codes other than -ENOBUFS and -ENOENT will terminate the
  4163. * dump and return to userspace with an error, so be careful. If any data
  4164. * was passed in from userspace then the data/len arguments will be present
  4165. * and point to the data contained in %NL80211_ATTR_TESTDATA.
  4166. *
  4167. * @set_bitrate_mask: set the bitrate mask configuration
  4168. *
  4169. * @set_pmksa: Cache a PMKID for a BSSID. This is mostly useful for fullmac
  4170. * devices running firmwares capable of generating the (re) association
  4171. * RSN IE. It allows for faster roaming between WPA2 BSSIDs.
  4172. * @del_pmksa: Delete a cached PMKID.
  4173. * @flush_pmksa: Flush all cached PMKIDs.
  4174. * @set_power_mgmt: Configure WLAN power management. A timeout value of -1
  4175. * allows the driver to adjust the dynamic ps timeout value.
  4176. * @set_cqm_rssi_config: Configure connection quality monitor RSSI threshold.
  4177. * After configuration, the driver should (soon) send an event indicating
  4178. * the current level is above/below the configured threshold; this may
  4179. * need some care when the configuration is changed (without first being
  4180. * disabled.)
  4181. * @set_cqm_rssi_range_config: Configure two RSSI thresholds in the
  4182. * connection quality monitor. An event is to be sent only when the
  4183. * signal level is found to be outside the two values. The driver should
  4184. * set %NL80211_EXT_FEATURE_CQM_RSSI_LIST if this method is implemented.
  4185. * If it is provided then there's no point providing @set_cqm_rssi_config.
  4186. * @set_cqm_txe_config: Configure connection quality monitor TX error
  4187. * thresholds.
  4188. * @sched_scan_start: Tell the driver to start a scheduled scan.
  4189. * @sched_scan_stop: Tell the driver to stop an ongoing scheduled scan with
  4190. * given request id. This call must stop the scheduled scan and be ready
  4191. * for starting a new one before it returns, i.e. @sched_scan_start may be
  4192. * called immediately after that again and should not fail in that case.
  4193. * The driver should not call cfg80211_sched_scan_stopped() for a requested
  4194. * stop (when this method returns 0).
  4195. *
  4196. * @update_mgmt_frame_registrations: Notify the driver that management frame
  4197. * registrations were updated. The callback is allowed to sleep.
  4198. *
  4199. * @set_antenna: Set antenna configuration (tx_ant, rx_ant) on the device.
  4200. * Parameters are bitmaps of allowed antennas to use for TX/RX. Drivers may
  4201. * reject TX/RX mask combinations they cannot support by returning -EINVAL
  4202. * (also see nl80211.h @NL80211_ATTR_WIPHY_ANTENNA_TX).
  4203. *
  4204. * @get_antenna: Get current antenna configuration from device (tx_ant, rx_ant).
  4205. *
  4206. * @tdls_mgmt: Transmit a TDLS management frame.
  4207. * @tdls_oper: Perform a high-level TDLS operation (e.g. TDLS link setup).
  4208. *
  4209. * @probe_client: probe an associated client, must return a cookie that it
  4210. * later passes to cfg80211_probe_status().
  4211. *
  4212. * @set_noack_map: Set the NoAck Map for the TIDs.
  4213. *
  4214. * @get_channel: Get the current operating channel for the virtual interface.
  4215. * For monitor interfaces, it should return %NULL unless there's a single
  4216. * current monitoring channel.
  4217. *
  4218. * @start_p2p_device: Start the given P2P device.
  4219. * @stop_p2p_device: Stop the given P2P device.
  4220. *
  4221. * @set_mac_acl: Sets MAC address control list in AP and P2P GO mode.
  4222. * Parameters include ACL policy, an array of MAC address of stations
  4223. * and the number of MAC addresses. If there is already a list in driver
  4224. * this new list replaces the existing one. Driver has to clear its ACL
  4225. * when number of MAC addresses entries is passed as 0. Drivers which
  4226. * advertise the support for MAC based ACL have to implement this callback.
  4227. *
  4228. * @start_radar_detection: Start radar detection in the driver.
  4229. *
  4230. * @end_cac: End running CAC, probably because a related CAC
  4231. * was finished on another phy.
  4232. *
  4233. * @update_ft_ies: Provide updated Fast BSS Transition information to the
  4234. * driver. If the SME is in the driver/firmware, this information can be
  4235. * used in building Authentication and Reassociation Request frames.
  4236. *
  4237. * @crit_proto_start: Indicates a critical protocol needs more link reliability
  4238. * for a given duration (milliseconds). The protocol is provided so the
  4239. * driver can take the most appropriate actions.
  4240. * @crit_proto_stop: Indicates critical protocol no longer needs increased link
  4241. * reliability. This operation can not fail.
  4242. * @set_coalesce: Set coalesce parameters.
  4243. *
  4244. * @channel_switch: initiate channel-switch procedure (with CSA). Driver is
  4245. * responsible for veryfing if the switch is possible. Since this is
  4246. * inherently tricky driver may decide to disconnect an interface later
  4247. * with cfg80211_stop_iface(). This doesn't mean driver can accept
  4248. * everything. It should do it's best to verify requests and reject them
  4249. * as soon as possible.
  4250. *
  4251. * @set_qos_map: Set QoS mapping information to the driver
  4252. *
  4253. * @set_ap_chanwidth: Set the AP (including P2P GO) mode channel width for the
  4254. * given interface This is used e.g. for dynamic HT 20/40 MHz channel width
  4255. * changes during the lifetime of the BSS.
  4256. *
  4257. * @add_tx_ts: validate (if admitted_time is 0) or add a TX TS to the device
  4258. * with the given parameters; action frame exchange has been handled by
  4259. * userspace so this just has to modify the TX path to take the TS into
  4260. * account.
  4261. * If the admitted time is 0 just validate the parameters to make sure
  4262. * the session can be created at all; it is valid to just always return
  4263. * success for that but that may result in inefficient behaviour (handshake
  4264. * with the peer followed by immediate teardown when the addition is later
  4265. * rejected)
  4266. * @del_tx_ts: remove an existing TX TS
  4267. *
  4268. * @join_ocb: join the OCB network with the specified parameters
  4269. * (invoked with the wireless_dev mutex held)
  4270. * @leave_ocb: leave the current OCB network
  4271. * (invoked with the wireless_dev mutex held)
  4272. *
  4273. * @tdls_channel_switch: Start channel-switching with a TDLS peer. The driver
  4274. * is responsible for continually initiating channel-switching operations
  4275. * and returning to the base channel for communication with the AP.
  4276. * @tdls_cancel_channel_switch: Stop channel-switching with a TDLS peer. Both
  4277. * peers must be on the base channel when the call completes.
  4278. * @start_nan: Start the NAN interface.
  4279. * @stop_nan: Stop the NAN interface.
  4280. * @add_nan_func: Add a NAN function. Returns negative value on failure.
  4281. * On success @nan_func ownership is transferred to the driver and
  4282. * it may access it outside of the scope of this function. The driver
  4283. * should free the @nan_func when no longer needed by calling
  4284. * cfg80211_free_nan_func().
  4285. * On success the driver should assign an instance_id in the
  4286. * provided @nan_func.
  4287. * @del_nan_func: Delete a NAN function.
  4288. * @nan_change_conf: changes NAN configuration. The changed parameters must
  4289. * be specified in @changes (using &enum cfg80211_nan_conf_changes);
  4290. * All other parameters must be ignored.
  4291. *
  4292. * @set_multicast_to_unicast: configure multicast to unicast conversion for BSS
  4293. *
  4294. * @get_txq_stats: Get TXQ stats for interface or phy. If wdev is %NULL, this
  4295. * function should return phy stats, and interface stats otherwise.
  4296. *
  4297. * @set_pmk: configure the PMK to be used for offloaded 802.1X 4-Way handshake.
  4298. * If not deleted through @del_pmk the PMK remains valid until disconnect
  4299. * upon which the driver should clear it.
  4300. * (invoked with the wireless_dev mutex held)
  4301. * @del_pmk: delete the previously configured PMK for the given authenticator.
  4302. * (invoked with the wireless_dev mutex held)
  4303. *
  4304. * @external_auth: indicates result of offloaded authentication processing from
  4305. * user space
  4306. *
  4307. * @tx_control_port: TX a control port frame (EAPoL). The noencrypt parameter
  4308. * tells the driver that the frame should not be encrypted.
  4309. *
  4310. * @get_ftm_responder_stats: Retrieve FTM responder statistics, if available.
  4311. * Statistics should be cumulative, currently no way to reset is provided.
  4312. * @start_pmsr: start peer measurement (e.g. FTM)
  4313. * @abort_pmsr: abort peer measurement
  4314. *
  4315. * @update_owe_info: Provide updated OWE info to driver. Driver implementing SME
  4316. * but offloading OWE processing to the user space will get the updated
  4317. * DH IE through this interface.
  4318. *
  4319. * @probe_mesh_link: Probe direct Mesh peer's link quality by sending data frame
  4320. * and overrule HWMP path selection algorithm.
  4321. * @set_tid_config: TID specific configuration, this can be peer or BSS specific
  4322. * This callback may sleep.
  4323. * @reset_tid_config: Reset TID specific configuration for the peer, for the
  4324. * given TIDs. This callback may sleep.
  4325. *
  4326. * @set_sar_specs: Update the SAR (TX power) settings.
  4327. *
  4328. * @color_change: Initiate a color change.
  4329. *
  4330. * @set_fils_aad: Set FILS AAD data to the AP driver so that the driver can use
  4331. * those to decrypt (Re)Association Request and encrypt (Re)Association
  4332. * Response frame.
  4333. *
  4334. * @set_radar_background: Configure dedicated offchannel chain available for
  4335. * radar/CAC detection on some hw. This chain can't be used to transmit
  4336. * or receive frames and it is bounded to a running wdev.
  4337. * Background radar/CAC detection allows to avoid the CAC downtime
  4338. * switching to a different channel during CAC detection on the selected
  4339. * radar channel.
  4340. * The caller is expected to set chandef pointer to NULL in order to
  4341. * disable background CAC/radar detection.
  4342. * @add_link_station: Add a link to a station.
  4343. * @mod_link_station: Modify a link of a station.
  4344. * @del_link_station: Remove a link of a station.
  4345. *
  4346. * @set_hw_timestamp: Enable/disable HW timestamping of TM/FTM frames.
  4347. * @set_ttlm: set the TID to link mapping.
  4348. * @get_radio_mask: get bitmask of radios in use.
  4349. * (invoked with the wiphy mutex held)
  4350. */
  4351. struct cfg80211_ops {
  4352. int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow);
  4353. int (*resume)(struct wiphy *wiphy);
  4354. void (*set_wakeup)(struct wiphy *wiphy, bool enabled);
  4355. struct wireless_dev * (*add_virtual_intf)(struct wiphy *wiphy,
  4356. const char *name,
  4357. unsigned char name_assign_type,
  4358. enum nl80211_iftype type,
  4359. struct vif_params *params);
  4360. int (*del_virtual_intf)(struct wiphy *wiphy,
  4361. struct wireless_dev *wdev);
  4362. int (*change_virtual_intf)(struct wiphy *wiphy,
  4363. struct net_device *dev,
  4364. enum nl80211_iftype type,
  4365. struct vif_params *params);
  4366. int (*add_intf_link)(struct wiphy *wiphy,
  4367. struct wireless_dev *wdev,
  4368. unsigned int link_id);
  4369. void (*del_intf_link)(struct wiphy *wiphy,
  4370. struct wireless_dev *wdev,
  4371. unsigned int link_id);
  4372. int (*add_key)(struct wiphy *wiphy, struct net_device *netdev,
  4373. int link_id, u8 key_index, bool pairwise,
  4374. const u8 *mac_addr, struct key_params *params);
  4375. int (*get_key)(struct wiphy *wiphy, struct net_device *netdev,
  4376. int link_id, u8 key_index, bool pairwise,
  4377. const u8 *mac_addr, void *cookie,
  4378. void (*callback)(void *cookie, struct key_params*));
  4379. int (*del_key)(struct wiphy *wiphy, struct net_device *netdev,
  4380. int link_id, u8 key_index, bool pairwise,
  4381. const u8 *mac_addr);
  4382. int (*set_default_key)(struct wiphy *wiphy,
  4383. struct net_device *netdev, int link_id,
  4384. u8 key_index, bool unicast, bool multicast);
  4385. int (*set_default_mgmt_key)(struct wiphy *wiphy,
  4386. struct net_device *netdev, int link_id,
  4387. u8 key_index);
  4388. int (*set_default_beacon_key)(struct wiphy *wiphy,
  4389. struct net_device *netdev,
  4390. int link_id,
  4391. u8 key_index);
  4392. int (*start_ap)(struct wiphy *wiphy, struct net_device *dev,
  4393. struct cfg80211_ap_settings *settings);
  4394. int (*change_beacon)(struct wiphy *wiphy, struct net_device *dev,
  4395. struct cfg80211_ap_update *info);
  4396. int (*stop_ap)(struct wiphy *wiphy, struct net_device *dev,
  4397. unsigned int link_id);
  4398. int (*add_station)(struct wiphy *wiphy, struct net_device *dev,
  4399. const u8 *mac,
  4400. struct station_parameters *params);
  4401. int (*del_station)(struct wiphy *wiphy, struct net_device *dev,
  4402. struct station_del_parameters *params);
  4403. int (*change_station)(struct wiphy *wiphy, struct net_device *dev,
  4404. const u8 *mac,
  4405. struct station_parameters *params);
  4406. int (*get_station)(struct wiphy *wiphy, struct net_device *dev,
  4407. const u8 *mac, struct station_info *sinfo);
  4408. int (*dump_station)(struct wiphy *wiphy, struct net_device *dev,
  4409. int idx, u8 *mac, struct station_info *sinfo);
  4410. int (*add_mpath)(struct wiphy *wiphy, struct net_device *dev,
  4411. const u8 *dst, const u8 *next_hop);
  4412. int (*del_mpath)(struct wiphy *wiphy, struct net_device *dev,
  4413. const u8 *dst);
  4414. int (*change_mpath)(struct wiphy *wiphy, struct net_device *dev,
  4415. const u8 *dst, const u8 *next_hop);
  4416. int (*get_mpath)(struct wiphy *wiphy, struct net_device *dev,
  4417. u8 *dst, u8 *next_hop, struct mpath_info *pinfo);
  4418. int (*dump_mpath)(struct wiphy *wiphy, struct net_device *dev,
  4419. int idx, u8 *dst, u8 *next_hop,
  4420. struct mpath_info *pinfo);
  4421. int (*get_mpp)(struct wiphy *wiphy, struct net_device *dev,
  4422. u8 *dst, u8 *mpp, struct mpath_info *pinfo);
  4423. int (*dump_mpp)(struct wiphy *wiphy, struct net_device *dev,
  4424. int idx, u8 *dst, u8 *mpp,
  4425. struct mpath_info *pinfo);
  4426. int (*get_mesh_config)(struct wiphy *wiphy,
  4427. struct net_device *dev,
  4428. struct mesh_config *conf);
  4429. int (*update_mesh_config)(struct wiphy *wiphy,
  4430. struct net_device *dev, u32 mask,
  4431. const struct mesh_config *nconf);
  4432. int (*join_mesh)(struct wiphy *wiphy, struct net_device *dev,
  4433. const struct mesh_config *conf,
  4434. const struct mesh_setup *setup);
  4435. int (*leave_mesh)(struct wiphy *wiphy, struct net_device *dev);
  4436. int (*join_ocb)(struct wiphy *wiphy, struct net_device *dev,
  4437. struct ocb_setup *setup);
  4438. int (*leave_ocb)(struct wiphy *wiphy, struct net_device *dev);
  4439. int (*change_bss)(struct wiphy *wiphy, struct net_device *dev,
  4440. struct bss_parameters *params);
  4441. void (*inform_bss)(struct wiphy *wiphy, struct cfg80211_bss *bss,
  4442. const struct cfg80211_bss_ies *ies, void *data);
  4443. int (*set_txq_params)(struct wiphy *wiphy, struct net_device *dev,
  4444. struct ieee80211_txq_params *params);
  4445. int (*libertas_set_mesh_channel)(struct wiphy *wiphy,
  4446. struct net_device *dev,
  4447. struct ieee80211_channel *chan);
  4448. int (*set_monitor_channel)(struct wiphy *wiphy,
  4449. struct cfg80211_chan_def *chandef);
  4450. int (*scan)(struct wiphy *wiphy,
  4451. struct cfg80211_scan_request *request);
  4452. void (*abort_scan)(struct wiphy *wiphy, struct wireless_dev *wdev);
  4453. int (*auth)(struct wiphy *wiphy, struct net_device *dev,
  4454. struct cfg80211_auth_request *req);
  4455. int (*assoc)(struct wiphy *wiphy, struct net_device *dev,
  4456. struct cfg80211_assoc_request *req);
  4457. int (*deauth)(struct wiphy *wiphy, struct net_device *dev,
  4458. struct cfg80211_deauth_request *req);
  4459. int (*disassoc)(struct wiphy *wiphy, struct net_device *dev,
  4460. struct cfg80211_disassoc_request *req);
  4461. int (*connect)(struct wiphy *wiphy, struct net_device *dev,
  4462. struct cfg80211_connect_params *sme);
  4463. int (*update_connect_params)(struct wiphy *wiphy,
  4464. struct net_device *dev,
  4465. struct cfg80211_connect_params *sme,
  4466. u32 changed);
  4467. int (*disconnect)(struct wiphy *wiphy, struct net_device *dev,
  4468. u16 reason_code);
  4469. int (*join_ibss)(struct wiphy *wiphy, struct net_device *dev,
  4470. struct cfg80211_ibss_params *params);
  4471. int (*leave_ibss)(struct wiphy *wiphy, struct net_device *dev);
  4472. int (*set_mcast_rate)(struct wiphy *wiphy, struct net_device *dev,
  4473. int rate[NUM_NL80211_BANDS]);
  4474. int (*set_wiphy_params)(struct wiphy *wiphy, u32 changed);
  4475. int (*set_tx_power)(struct wiphy *wiphy, struct wireless_dev *wdev,
  4476. enum nl80211_tx_power_setting type, int mbm);
  4477. int (*get_tx_power)(struct wiphy *wiphy, struct wireless_dev *wdev,
  4478. int *dbm);
  4479. void (*rfkill_poll)(struct wiphy *wiphy);
  4480. #ifdef CONFIG_NL80211_TESTMODE
  4481. int (*testmode_cmd)(struct wiphy *wiphy, struct wireless_dev *wdev,
  4482. void *data, int len);
  4483. int (*testmode_dump)(struct wiphy *wiphy, struct sk_buff *skb,
  4484. struct netlink_callback *cb,
  4485. void *data, int len);
  4486. #endif
  4487. int (*set_bitrate_mask)(struct wiphy *wiphy,
  4488. struct net_device *dev,
  4489. unsigned int link_id,
  4490. const u8 *peer,
  4491. const struct cfg80211_bitrate_mask *mask);
  4492. int (*dump_survey)(struct wiphy *wiphy, struct net_device *netdev,
  4493. int idx, struct survey_info *info);
  4494. int (*set_pmksa)(struct wiphy *wiphy, struct net_device *netdev,
  4495. struct cfg80211_pmksa *pmksa);
  4496. int (*del_pmksa)(struct wiphy *wiphy, struct net_device *netdev,
  4497. struct cfg80211_pmksa *pmksa);
  4498. int (*flush_pmksa)(struct wiphy *wiphy, struct net_device *netdev);
  4499. int (*remain_on_channel)(struct wiphy *wiphy,
  4500. struct wireless_dev *wdev,
  4501. struct ieee80211_channel *chan,
  4502. unsigned int duration,
  4503. u64 *cookie);
  4504. int (*cancel_remain_on_channel)(struct wiphy *wiphy,
  4505. struct wireless_dev *wdev,
  4506. u64 cookie);
  4507. int (*mgmt_tx)(struct wiphy *wiphy, struct wireless_dev *wdev,
  4508. struct cfg80211_mgmt_tx_params *params,
  4509. u64 *cookie);
  4510. int (*mgmt_tx_cancel_wait)(struct wiphy *wiphy,
  4511. struct wireless_dev *wdev,
  4512. u64 cookie);
  4513. int (*set_power_mgmt)(struct wiphy *wiphy, struct net_device *dev,
  4514. bool enabled, int timeout);
  4515. int (*set_cqm_rssi_config)(struct wiphy *wiphy,
  4516. struct net_device *dev,
  4517. s32 rssi_thold, u32 rssi_hyst);
  4518. int (*set_cqm_rssi_range_config)(struct wiphy *wiphy,
  4519. struct net_device *dev,
  4520. s32 rssi_low, s32 rssi_high);
  4521. int (*set_cqm_txe_config)(struct wiphy *wiphy,
  4522. struct net_device *dev,
  4523. u32 rate, u32 pkts, u32 intvl);
  4524. void (*update_mgmt_frame_registrations)(struct wiphy *wiphy,
  4525. struct wireless_dev *wdev,
  4526. struct mgmt_frame_regs *upd);
  4527. int (*set_antenna)(struct wiphy *wiphy, u32 tx_ant, u32 rx_ant);
  4528. int (*get_antenna)(struct wiphy *wiphy, u32 *tx_ant, u32 *rx_ant);
  4529. int (*sched_scan_start)(struct wiphy *wiphy,
  4530. struct net_device *dev,
  4531. struct cfg80211_sched_scan_request *request);
  4532. int (*sched_scan_stop)(struct wiphy *wiphy, struct net_device *dev,
  4533. u64 reqid);
  4534. int (*set_rekey_data)(struct wiphy *wiphy, struct net_device *dev,
  4535. struct cfg80211_gtk_rekey_data *data);
  4536. int (*tdls_mgmt)(struct wiphy *wiphy, struct net_device *dev,
  4537. const u8 *peer, int link_id,
  4538. u8 action_code, u8 dialog_token, u16 status_code,
  4539. u32 peer_capability, bool initiator,
  4540. const u8 *buf, size_t len);
  4541. int (*tdls_oper)(struct wiphy *wiphy, struct net_device *dev,
  4542. const u8 *peer, enum nl80211_tdls_operation oper);
  4543. int (*probe_client)(struct wiphy *wiphy, struct net_device *dev,
  4544. const u8 *peer, u64 *cookie);
  4545. int (*set_noack_map)(struct wiphy *wiphy,
  4546. struct net_device *dev,
  4547. u16 noack_map);
  4548. int (*get_channel)(struct wiphy *wiphy,
  4549. struct wireless_dev *wdev,
  4550. unsigned int link_id,
  4551. struct cfg80211_chan_def *chandef);
  4552. int (*start_p2p_device)(struct wiphy *wiphy,
  4553. struct wireless_dev *wdev);
  4554. void (*stop_p2p_device)(struct wiphy *wiphy,
  4555. struct wireless_dev *wdev);
  4556. int (*set_mac_acl)(struct wiphy *wiphy, struct net_device *dev,
  4557. const struct cfg80211_acl_data *params);
  4558. int (*start_radar_detection)(struct wiphy *wiphy,
  4559. struct net_device *dev,
  4560. struct cfg80211_chan_def *chandef,
  4561. u32 cac_time_ms, int link_id);
  4562. void (*end_cac)(struct wiphy *wiphy,
  4563. struct net_device *dev, unsigned int link_id);
  4564. int (*update_ft_ies)(struct wiphy *wiphy, struct net_device *dev,
  4565. struct cfg80211_update_ft_ies_params *ftie);
  4566. int (*crit_proto_start)(struct wiphy *wiphy,
  4567. struct wireless_dev *wdev,
  4568. enum nl80211_crit_proto_id protocol,
  4569. u16 duration);
  4570. void (*crit_proto_stop)(struct wiphy *wiphy,
  4571. struct wireless_dev *wdev);
  4572. int (*set_coalesce)(struct wiphy *wiphy,
  4573. struct cfg80211_coalesce *coalesce);
  4574. int (*channel_switch)(struct wiphy *wiphy,
  4575. struct net_device *dev,
  4576. struct cfg80211_csa_settings *params);
  4577. int (*set_qos_map)(struct wiphy *wiphy,
  4578. struct net_device *dev,
  4579. struct cfg80211_qos_map *qos_map);
  4580. int (*set_ap_chanwidth)(struct wiphy *wiphy, struct net_device *dev,
  4581. unsigned int link_id,
  4582. struct cfg80211_chan_def *chandef);
  4583. int (*add_tx_ts)(struct wiphy *wiphy, struct net_device *dev,
  4584. u8 tsid, const u8 *peer, u8 user_prio,
  4585. u16 admitted_time);
  4586. int (*del_tx_ts)(struct wiphy *wiphy, struct net_device *dev,
  4587. u8 tsid, const u8 *peer);
  4588. int (*tdls_channel_switch)(struct wiphy *wiphy,
  4589. struct net_device *dev,
  4590. const u8 *addr, u8 oper_class,
  4591. struct cfg80211_chan_def *chandef);
  4592. void (*tdls_cancel_channel_switch)(struct wiphy *wiphy,
  4593. struct net_device *dev,
  4594. const u8 *addr);
  4595. int (*start_nan)(struct wiphy *wiphy, struct wireless_dev *wdev,
  4596. struct cfg80211_nan_conf *conf);
  4597. void (*stop_nan)(struct wiphy *wiphy, struct wireless_dev *wdev);
  4598. int (*add_nan_func)(struct wiphy *wiphy, struct wireless_dev *wdev,
  4599. struct cfg80211_nan_func *nan_func);
  4600. void (*del_nan_func)(struct wiphy *wiphy, struct wireless_dev *wdev,
  4601. u64 cookie);
  4602. int (*nan_change_conf)(struct wiphy *wiphy,
  4603. struct wireless_dev *wdev,
  4604. struct cfg80211_nan_conf *conf,
  4605. u32 changes);
  4606. int (*set_multicast_to_unicast)(struct wiphy *wiphy,
  4607. struct net_device *dev,
  4608. const bool enabled);
  4609. int (*get_txq_stats)(struct wiphy *wiphy,
  4610. struct wireless_dev *wdev,
  4611. struct cfg80211_txq_stats *txqstats);
  4612. int (*set_pmk)(struct wiphy *wiphy, struct net_device *dev,
  4613. const struct cfg80211_pmk_conf *conf);
  4614. int (*del_pmk)(struct wiphy *wiphy, struct net_device *dev,
  4615. const u8 *aa);
  4616. int (*external_auth)(struct wiphy *wiphy, struct net_device *dev,
  4617. struct cfg80211_external_auth_params *params);
  4618. int (*tx_control_port)(struct wiphy *wiphy,
  4619. struct net_device *dev,
  4620. const u8 *buf, size_t len,
  4621. const u8 *dest, const __be16 proto,
  4622. const bool noencrypt, int link_id,
  4623. u64 *cookie);
  4624. int (*get_ftm_responder_stats)(struct wiphy *wiphy,
  4625. struct net_device *dev,
  4626. struct cfg80211_ftm_responder_stats *ftm_stats);
  4627. int (*start_pmsr)(struct wiphy *wiphy, struct wireless_dev *wdev,
  4628. struct cfg80211_pmsr_request *request);
  4629. void (*abort_pmsr)(struct wiphy *wiphy, struct wireless_dev *wdev,
  4630. struct cfg80211_pmsr_request *request);
  4631. int (*update_owe_info)(struct wiphy *wiphy, struct net_device *dev,
  4632. struct cfg80211_update_owe_info *owe_info);
  4633. int (*probe_mesh_link)(struct wiphy *wiphy, struct net_device *dev,
  4634. const u8 *buf, size_t len);
  4635. int (*set_tid_config)(struct wiphy *wiphy, struct net_device *dev,
  4636. struct cfg80211_tid_config *tid_conf);
  4637. int (*reset_tid_config)(struct wiphy *wiphy, struct net_device *dev,
  4638. const u8 *peer, u8 tids);
  4639. int (*set_sar_specs)(struct wiphy *wiphy,
  4640. struct cfg80211_sar_specs *sar);
  4641. int (*color_change)(struct wiphy *wiphy,
  4642. struct net_device *dev,
  4643. struct cfg80211_color_change_settings *params);
  4644. int (*set_fils_aad)(struct wiphy *wiphy, struct net_device *dev,
  4645. struct cfg80211_fils_aad *fils_aad);
  4646. int (*set_radar_background)(struct wiphy *wiphy,
  4647. struct cfg80211_chan_def *chandef);
  4648. int (*add_link_station)(struct wiphy *wiphy, struct net_device *dev,
  4649. struct link_station_parameters *params);
  4650. int (*mod_link_station)(struct wiphy *wiphy, struct net_device *dev,
  4651. struct link_station_parameters *params);
  4652. int (*del_link_station)(struct wiphy *wiphy, struct net_device *dev,
  4653. struct link_station_del_parameters *params);
  4654. int (*set_hw_timestamp)(struct wiphy *wiphy, struct net_device *dev,
  4655. struct cfg80211_set_hw_timestamp *hwts);
  4656. int (*set_ttlm)(struct wiphy *wiphy, struct net_device *dev,
  4657. struct cfg80211_ttlm_params *params);
  4658. u32 (*get_radio_mask)(struct wiphy *wiphy, struct net_device *dev);
  4659. };
  4660. /*
  4661. * wireless hardware and networking interfaces structures
  4662. * and registration/helper functions
  4663. */
  4664. /**
  4665. * enum wiphy_flags - wiphy capability flags
  4666. *
  4667. * @WIPHY_FLAG_SPLIT_SCAN_6GHZ: if set to true, the scan request will be split
  4668. * into two, first for legacy bands and second for 6 GHz.
  4669. * @WIPHY_FLAG_NETNS_OK: if not set, do not allow changing the netns of this
  4670. * wiphy at all
  4671. * @WIPHY_FLAG_PS_ON_BY_DEFAULT: if set to true, powersave will be enabled
  4672. * by default -- this flag will be set depending on the kernel's default
  4673. * on wiphy_new(), but can be changed by the driver if it has a good
  4674. * reason to override the default
  4675. * @WIPHY_FLAG_4ADDR_AP: supports 4addr mode even on AP (with a single station
  4676. * on a VLAN interface). This flag also serves an extra purpose of
  4677. * supporting 4ADDR AP mode on devices which do not support AP/VLAN iftype.
  4678. * @WIPHY_FLAG_4ADDR_STATION: supports 4addr mode even as a station
  4679. * @WIPHY_FLAG_CONTROL_PORT_PROTOCOL: This device supports setting the
  4680. * control port protocol ethertype. The device also honours the
  4681. * control_port_no_encrypt flag.
  4682. * @WIPHY_FLAG_IBSS_RSN: The device supports IBSS RSN.
  4683. * @WIPHY_FLAG_MESH_AUTH: The device supports mesh authentication by routing
  4684. * auth frames to userspace. See @NL80211_MESH_SETUP_USERSPACE_AUTH.
  4685. * @WIPHY_FLAG_SUPPORTS_FW_ROAM: The device supports roaming feature in the
  4686. * firmware.
  4687. * @WIPHY_FLAG_AP_UAPSD: The device supports uapsd on AP.
  4688. * @WIPHY_FLAG_SUPPORTS_TDLS: The device supports TDLS (802.11z) operation.
  4689. * @WIPHY_FLAG_TDLS_EXTERNAL_SETUP: The device does not handle TDLS (802.11z)
  4690. * link setup/discovery operations internally. Setup, discovery and
  4691. * teardown packets should be sent through the @NL80211_CMD_TDLS_MGMT
  4692. * command. When this flag is not set, @NL80211_CMD_TDLS_OPER should be
  4693. * used for asking the driver/firmware to perform a TDLS operation.
  4694. * @WIPHY_FLAG_HAVE_AP_SME: device integrates AP SME
  4695. * @WIPHY_FLAG_REPORTS_OBSS: the device will report beacons from other BSSes
  4696. * when there are virtual interfaces in AP mode by calling
  4697. * cfg80211_report_obss_beacon().
  4698. * @WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD: When operating as an AP, the device
  4699. * responds to probe-requests in hardware.
  4700. * @WIPHY_FLAG_OFFCHAN_TX: Device supports direct off-channel TX.
  4701. * @WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL: Device supports remain-on-channel call.
  4702. * @WIPHY_FLAG_SUPPORTS_5_10_MHZ: Device supports 5 MHz and 10 MHz channels.
  4703. * @WIPHY_FLAG_HAS_CHANNEL_SWITCH: Device supports channel switch in
  4704. * beaconing mode (AP, IBSS, Mesh, ...).
  4705. * @WIPHY_FLAG_SUPPORTS_EXT_KEK_KCK: The device supports bigger kek and kck keys
  4706. * @WIPHY_FLAG_SUPPORTS_MLO: This is a temporary flag gating the MLO APIs,
  4707. * in order to not have them reachable in normal drivers, until we have
  4708. * complete feature/interface combinations/etc. advertisement. No driver
  4709. * should set this flag for now.
  4710. * @WIPHY_FLAG_SUPPORTS_EXT_KCK_32: The device supports 32-byte KCK keys.
  4711. * @WIPHY_FLAG_NOTIFY_REGDOM_BY_DRIVER: The device could handle reg notify for
  4712. * NL80211_REGDOM_SET_BY_DRIVER.
  4713. * @WIPHY_FLAG_CHANNEL_CHANGE_ON_BEACON: reg_call_notifier() is called if driver
  4714. * set this flag to update channels on beacon hints.
  4715. * @WIPHY_FLAG_SUPPORTS_NSTR_NONPRIMARY: support connection to non-primary link
  4716. * of an NSTR mobile AP MLD.
  4717. * @WIPHY_FLAG_DISABLE_WEXT: disable wireless extensions for this device
  4718. */
  4719. enum wiphy_flags {
  4720. WIPHY_FLAG_SUPPORTS_EXT_KEK_KCK = BIT(0),
  4721. WIPHY_FLAG_SUPPORTS_MLO = BIT(1),
  4722. WIPHY_FLAG_SPLIT_SCAN_6GHZ = BIT(2),
  4723. WIPHY_FLAG_NETNS_OK = BIT(3),
  4724. WIPHY_FLAG_PS_ON_BY_DEFAULT = BIT(4),
  4725. WIPHY_FLAG_4ADDR_AP = BIT(5),
  4726. WIPHY_FLAG_4ADDR_STATION = BIT(6),
  4727. WIPHY_FLAG_CONTROL_PORT_PROTOCOL = BIT(7),
  4728. WIPHY_FLAG_IBSS_RSN = BIT(8),
  4729. WIPHY_FLAG_DISABLE_WEXT = BIT(9),
  4730. WIPHY_FLAG_MESH_AUTH = BIT(10),
  4731. WIPHY_FLAG_SUPPORTS_EXT_KCK_32 = BIT(11),
  4732. WIPHY_FLAG_SUPPORTS_NSTR_NONPRIMARY = BIT(12),
  4733. WIPHY_FLAG_SUPPORTS_FW_ROAM = BIT(13),
  4734. WIPHY_FLAG_AP_UAPSD = BIT(14),
  4735. WIPHY_FLAG_SUPPORTS_TDLS = BIT(15),
  4736. WIPHY_FLAG_TDLS_EXTERNAL_SETUP = BIT(16),
  4737. WIPHY_FLAG_HAVE_AP_SME = BIT(17),
  4738. WIPHY_FLAG_REPORTS_OBSS = BIT(18),
  4739. WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD = BIT(19),
  4740. WIPHY_FLAG_OFFCHAN_TX = BIT(20),
  4741. WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL = BIT(21),
  4742. WIPHY_FLAG_SUPPORTS_5_10_MHZ = BIT(22),
  4743. WIPHY_FLAG_HAS_CHANNEL_SWITCH = BIT(23),
  4744. WIPHY_FLAG_NOTIFY_REGDOM_BY_DRIVER = BIT(24),
  4745. WIPHY_FLAG_CHANNEL_CHANGE_ON_BEACON = BIT(25),
  4746. };
  4747. /**
  4748. * struct ieee80211_iface_limit - limit on certain interface types
  4749. * @max: maximum number of interfaces of these types
  4750. * @types: interface types (bits)
  4751. */
  4752. struct ieee80211_iface_limit {
  4753. u16 max;
  4754. u16 types;
  4755. };
  4756. /**
  4757. * struct ieee80211_iface_combination - possible interface combination
  4758. *
  4759. * With this structure the driver can describe which interface
  4760. * combinations it supports concurrently. When set in a struct wiphy_radio,
  4761. * the combinations refer to combinations of interfaces currently active on
  4762. * that radio.
  4763. *
  4764. * Examples:
  4765. *
  4766. * 1. Allow #STA <= 1, #AP <= 1, matching BI, channels = 1, 2 total:
  4767. *
  4768. * .. code-block:: c
  4769. *
  4770. * struct ieee80211_iface_limit limits1[] = {
  4771. * { .max = 1, .types = BIT(NL80211_IFTYPE_STATION), },
  4772. * { .max = 1, .types = BIT(NL80211_IFTYPE_AP), },
  4773. * };
  4774. * struct ieee80211_iface_combination combination1 = {
  4775. * .limits = limits1,
  4776. * .n_limits = ARRAY_SIZE(limits1),
  4777. * .max_interfaces = 2,
  4778. * .beacon_int_infra_match = true,
  4779. * };
  4780. *
  4781. *
  4782. * 2. Allow #{AP, P2P-GO} <= 8, channels = 1, 8 total:
  4783. *
  4784. * .. code-block:: c
  4785. *
  4786. * struct ieee80211_iface_limit limits2[] = {
  4787. * { .max = 8, .types = BIT(NL80211_IFTYPE_AP) |
  4788. * BIT(NL80211_IFTYPE_P2P_GO), },
  4789. * };
  4790. * struct ieee80211_iface_combination combination2 = {
  4791. * .limits = limits2,
  4792. * .n_limits = ARRAY_SIZE(limits2),
  4793. * .max_interfaces = 8,
  4794. * .num_different_channels = 1,
  4795. * };
  4796. *
  4797. *
  4798. * 3. Allow #STA <= 1, #{P2P-client,P2P-GO} <= 3 on two channels, 4 total.
  4799. *
  4800. * This allows for an infrastructure connection and three P2P connections.
  4801. *
  4802. * .. code-block:: c
  4803. *
  4804. * struct ieee80211_iface_limit limits3[] = {
  4805. * { .max = 1, .types = BIT(NL80211_IFTYPE_STATION), },
  4806. * { .max = 3, .types = BIT(NL80211_IFTYPE_P2P_GO) |
  4807. * BIT(NL80211_IFTYPE_P2P_CLIENT), },
  4808. * };
  4809. * struct ieee80211_iface_combination combination3 = {
  4810. * .limits = limits3,
  4811. * .n_limits = ARRAY_SIZE(limits3),
  4812. * .max_interfaces = 4,
  4813. * .num_different_channels = 2,
  4814. * };
  4815. *
  4816. */
  4817. struct ieee80211_iface_combination {
  4818. /**
  4819. * @limits:
  4820. * limits for the given interface types
  4821. */
  4822. const struct ieee80211_iface_limit *limits;
  4823. /**
  4824. * @num_different_channels:
  4825. * can use up to this many different channels
  4826. */
  4827. u32 num_different_channels;
  4828. /**
  4829. * @max_interfaces:
  4830. * maximum number of interfaces in total allowed in this group
  4831. */
  4832. u16 max_interfaces;
  4833. /**
  4834. * @n_limits:
  4835. * number of limitations
  4836. */
  4837. u8 n_limits;
  4838. /**
  4839. * @beacon_int_infra_match:
  4840. * In this combination, the beacon intervals between infrastructure
  4841. * and AP types must match. This is required only in special cases.
  4842. */
  4843. bool beacon_int_infra_match;
  4844. /**
  4845. * @radar_detect_widths:
  4846. * bitmap of channel widths supported for radar detection
  4847. */
  4848. u8 radar_detect_widths;
  4849. /**
  4850. * @radar_detect_regions:
  4851. * bitmap of regions supported for radar detection
  4852. */
  4853. u8 radar_detect_regions;
  4854. /**
  4855. * @beacon_int_min_gcd:
  4856. * This interface combination supports different beacon intervals.
  4857. *
  4858. * = 0
  4859. * all beacon intervals for different interface must be same.
  4860. * > 0
  4861. * any beacon interval for the interface part of this combination AND
  4862. * GCD of all beacon intervals from beaconing interfaces of this
  4863. * combination must be greater or equal to this value.
  4864. */
  4865. u32 beacon_int_min_gcd;
  4866. };
  4867. struct ieee80211_txrx_stypes {
  4868. u16 tx, rx;
  4869. };
  4870. /**
  4871. * enum wiphy_wowlan_support_flags - WoWLAN support flags
  4872. * @WIPHY_WOWLAN_ANY: supports wakeup for the special "any"
  4873. * trigger that keeps the device operating as-is and
  4874. * wakes up the host on any activity, for example a
  4875. * received packet that passed filtering; note that the
  4876. * packet should be preserved in that case
  4877. * @WIPHY_WOWLAN_MAGIC_PKT: supports wakeup on magic packet
  4878. * (see nl80211.h)
  4879. * @WIPHY_WOWLAN_DISCONNECT: supports wakeup on disconnect
  4880. * @WIPHY_WOWLAN_SUPPORTS_GTK_REKEY: supports GTK rekeying while asleep
  4881. * @WIPHY_WOWLAN_GTK_REKEY_FAILURE: supports wakeup on GTK rekey failure
  4882. * @WIPHY_WOWLAN_EAP_IDENTITY_REQ: supports wakeup on EAP identity request
  4883. * @WIPHY_WOWLAN_4WAY_HANDSHAKE: supports wakeup on 4-way handshake failure
  4884. * @WIPHY_WOWLAN_RFKILL_RELEASE: supports wakeup on RF-kill release
  4885. * @WIPHY_WOWLAN_NET_DETECT: supports wakeup on network detection
  4886. */
  4887. enum wiphy_wowlan_support_flags {
  4888. WIPHY_WOWLAN_ANY = BIT(0),
  4889. WIPHY_WOWLAN_MAGIC_PKT = BIT(1),
  4890. WIPHY_WOWLAN_DISCONNECT = BIT(2),
  4891. WIPHY_WOWLAN_SUPPORTS_GTK_REKEY = BIT(3),
  4892. WIPHY_WOWLAN_GTK_REKEY_FAILURE = BIT(4),
  4893. WIPHY_WOWLAN_EAP_IDENTITY_REQ = BIT(5),
  4894. WIPHY_WOWLAN_4WAY_HANDSHAKE = BIT(6),
  4895. WIPHY_WOWLAN_RFKILL_RELEASE = BIT(7),
  4896. WIPHY_WOWLAN_NET_DETECT = BIT(8),
  4897. };
  4898. struct wiphy_wowlan_tcp_support {
  4899. const struct nl80211_wowlan_tcp_data_token_feature *tok;
  4900. u32 data_payload_max;
  4901. u32 data_interval_max;
  4902. u32 wake_payload_max;
  4903. bool seq;
  4904. };
  4905. /**
  4906. * struct wiphy_wowlan_support - WoWLAN support data
  4907. * @flags: see &enum wiphy_wowlan_support_flags
  4908. * @n_patterns: number of supported wakeup patterns
  4909. * (see nl80211.h for the pattern definition)
  4910. * @pattern_max_len: maximum length of each pattern
  4911. * @pattern_min_len: minimum length of each pattern
  4912. * @max_pkt_offset: maximum Rx packet offset
  4913. * @max_nd_match_sets: maximum number of matchsets for net-detect,
  4914. * similar, but not necessarily identical, to max_match_sets for
  4915. * scheduled scans.
  4916. * See &struct cfg80211_sched_scan_request.@match_sets for more
  4917. * details.
  4918. * @tcp: TCP wakeup support information
  4919. */
  4920. struct wiphy_wowlan_support {
  4921. u32 flags;
  4922. int n_patterns;
  4923. int pattern_max_len;
  4924. int pattern_min_len;
  4925. int max_pkt_offset;
  4926. int max_nd_match_sets;
  4927. const struct wiphy_wowlan_tcp_support *tcp;
  4928. };
  4929. /**
  4930. * struct wiphy_coalesce_support - coalesce support data
  4931. * @n_rules: maximum number of coalesce rules
  4932. * @max_delay: maximum supported coalescing delay in msecs
  4933. * @n_patterns: number of supported patterns in a rule
  4934. * (see nl80211.h for the pattern definition)
  4935. * @pattern_max_len: maximum length of each pattern
  4936. * @pattern_min_len: minimum length of each pattern
  4937. * @max_pkt_offset: maximum Rx packet offset
  4938. */
  4939. struct wiphy_coalesce_support {
  4940. int n_rules;
  4941. int max_delay;
  4942. int n_patterns;
  4943. int pattern_max_len;
  4944. int pattern_min_len;
  4945. int max_pkt_offset;
  4946. };
  4947. /**
  4948. * enum wiphy_vendor_command_flags - validation flags for vendor commands
  4949. * @WIPHY_VENDOR_CMD_NEED_WDEV: vendor command requires wdev
  4950. * @WIPHY_VENDOR_CMD_NEED_NETDEV: vendor command requires netdev
  4951. * @WIPHY_VENDOR_CMD_NEED_RUNNING: interface/wdev must be up & running
  4952. * (must be combined with %_WDEV or %_NETDEV)
  4953. */
  4954. enum wiphy_vendor_command_flags {
  4955. WIPHY_VENDOR_CMD_NEED_WDEV = BIT(0),
  4956. WIPHY_VENDOR_CMD_NEED_NETDEV = BIT(1),
  4957. WIPHY_VENDOR_CMD_NEED_RUNNING = BIT(2),
  4958. };
  4959. /**
  4960. * enum wiphy_opmode_flag - Station's ht/vht operation mode information flags
  4961. *
  4962. * @STA_OPMODE_MAX_BW_CHANGED: Max Bandwidth changed
  4963. * @STA_OPMODE_SMPS_MODE_CHANGED: SMPS mode changed
  4964. * @STA_OPMODE_N_SS_CHANGED: max N_SS (number of spatial streams) changed
  4965. *
  4966. */
  4967. enum wiphy_opmode_flag {
  4968. STA_OPMODE_MAX_BW_CHANGED = BIT(0),
  4969. STA_OPMODE_SMPS_MODE_CHANGED = BIT(1),
  4970. STA_OPMODE_N_SS_CHANGED = BIT(2),
  4971. };
  4972. /**
  4973. * struct sta_opmode_info - Station's ht/vht operation mode information
  4974. * @changed: contains value from &enum wiphy_opmode_flag
  4975. * @smps_mode: New SMPS mode value from &enum nl80211_smps_mode of a station
  4976. * @bw: new max bandwidth value from &enum nl80211_chan_width of a station
  4977. * @rx_nss: new rx_nss value of a station
  4978. */
  4979. struct sta_opmode_info {
  4980. u32 changed;
  4981. enum nl80211_smps_mode smps_mode;
  4982. enum nl80211_chan_width bw;
  4983. u8 rx_nss;
  4984. };
  4985. #define VENDOR_CMD_RAW_DATA ((const struct nla_policy *)(long)(-ENODATA))
  4986. /**
  4987. * struct wiphy_vendor_command - vendor command definition
  4988. * @info: vendor command identifying information, as used in nl80211
  4989. * @flags: flags, see &enum wiphy_vendor_command_flags
  4990. * @doit: callback for the operation, note that wdev is %NULL if the
  4991. * flags didn't ask for a wdev and non-%NULL otherwise; the data
  4992. * pointer may be %NULL if userspace provided no data at all
  4993. * @dumpit: dump callback, for transferring bigger/multiple items. The
  4994. * @storage points to cb->args[5], ie. is preserved over the multiple
  4995. * dumpit calls.
  4996. * @policy: policy pointer for attributes within %NL80211_ATTR_VENDOR_DATA.
  4997. * Set this to %VENDOR_CMD_RAW_DATA if no policy can be given and the
  4998. * attribute is just raw data (e.g. a firmware command).
  4999. * @maxattr: highest attribute number in policy
  5000. * It's recommended to not have the same sub command with both @doit and
  5001. * @dumpit, so that userspace can assume certain ones are get and others
  5002. * are used with dump requests.
  5003. */
  5004. struct wiphy_vendor_command {
  5005. struct nl80211_vendor_cmd_info info;
  5006. u32 flags;
  5007. int (*doit)(struct wiphy *wiphy, struct wireless_dev *wdev,
  5008. const void *data, int data_len);
  5009. int (*dumpit)(struct wiphy *wiphy, struct wireless_dev *wdev,
  5010. struct sk_buff *skb, const void *data, int data_len,
  5011. unsigned long *storage);
  5012. const struct nla_policy *policy;
  5013. unsigned int maxattr;
  5014. };
  5015. /**
  5016. * struct wiphy_iftype_ext_capab - extended capabilities per interface type
  5017. * @iftype: interface type
  5018. * @extended_capabilities: extended capabilities supported by the driver,
  5019. * additional capabilities might be supported by userspace; these are the
  5020. * 802.11 extended capabilities ("Extended Capabilities element") and are
  5021. * in the same format as in the information element. See IEEE Std
  5022. * 802.11-2012 8.4.2.29 for the defined fields.
  5023. * @extended_capabilities_mask: mask of the valid values
  5024. * @extended_capabilities_len: length of the extended capabilities
  5025. * @eml_capabilities: EML capabilities (for MLO)
  5026. * @mld_capa_and_ops: MLD capabilities and operations (for MLO)
  5027. */
  5028. struct wiphy_iftype_ext_capab {
  5029. enum nl80211_iftype iftype;
  5030. const u8 *extended_capabilities;
  5031. const u8 *extended_capabilities_mask;
  5032. u8 extended_capabilities_len;
  5033. u16 eml_capabilities;
  5034. u16 mld_capa_and_ops;
  5035. };
  5036. /**
  5037. * cfg80211_get_iftype_ext_capa - lookup interface type extended capability
  5038. * @wiphy: the wiphy to look up from
  5039. * @type: the interface type to look up
  5040. *
  5041. * Return: The extended capability for the given interface @type, may be %NULL
  5042. */
  5043. const struct wiphy_iftype_ext_capab *
  5044. cfg80211_get_iftype_ext_capa(struct wiphy *wiphy, enum nl80211_iftype type);
  5045. /**
  5046. * struct cfg80211_pmsr_capabilities - cfg80211 peer measurement capabilities
  5047. * @max_peers: maximum number of peers in a single measurement
  5048. * @report_ap_tsf: can report assoc AP's TSF for radio resource measurement
  5049. * @randomize_mac_addr: can randomize MAC address for measurement
  5050. * @ftm: FTM measurement data
  5051. * @ftm.supported: FTM measurement is supported
  5052. * @ftm.asap: ASAP-mode is supported
  5053. * @ftm.non_asap: non-ASAP-mode is supported
  5054. * @ftm.request_lci: can request LCI data
  5055. * @ftm.request_civicloc: can request civic location data
  5056. * @ftm.preambles: bitmap of preambles supported (&enum nl80211_preamble)
  5057. * @ftm.bandwidths: bitmap of bandwidths supported (&enum nl80211_chan_width)
  5058. * @ftm.max_bursts_exponent: maximum burst exponent supported
  5059. * (set to -1 if not limited; note that setting this will necessarily
  5060. * forbid using the value 15 to let the responder pick)
  5061. * @ftm.max_ftms_per_burst: maximum FTMs per burst supported (set to 0 if
  5062. * not limited)
  5063. * @ftm.trigger_based: trigger based ranging measurement is supported
  5064. * @ftm.non_trigger_based: non trigger based ranging measurement is supported
  5065. */
  5066. struct cfg80211_pmsr_capabilities {
  5067. unsigned int max_peers;
  5068. u8 report_ap_tsf:1,
  5069. randomize_mac_addr:1;
  5070. struct {
  5071. u32 preambles;
  5072. u32 bandwidths;
  5073. s8 max_bursts_exponent;
  5074. u8 max_ftms_per_burst;
  5075. u8 supported:1,
  5076. asap:1,
  5077. non_asap:1,
  5078. request_lci:1,
  5079. request_civicloc:1,
  5080. trigger_based:1,
  5081. non_trigger_based:1;
  5082. } ftm;
  5083. };
  5084. /**
  5085. * struct wiphy_iftype_akm_suites - This structure encapsulates supported akm
  5086. * suites for interface types defined in @iftypes_mask. Each type in the
  5087. * @iftypes_mask must be unique across all instances of iftype_akm_suites.
  5088. *
  5089. * @iftypes_mask: bitmask of interfaces types
  5090. * @akm_suites: points to an array of supported akm suites
  5091. * @n_akm_suites: number of supported AKM suites
  5092. */
  5093. struct wiphy_iftype_akm_suites {
  5094. u16 iftypes_mask;
  5095. const u32 *akm_suites;
  5096. int n_akm_suites;
  5097. };
  5098. /**
  5099. * struct wiphy_radio_freq_range - wiphy frequency range
  5100. * @start_freq: start range edge frequency (kHz)
  5101. * @end_freq: end range edge frequency (kHz)
  5102. */
  5103. struct wiphy_radio_freq_range {
  5104. u32 start_freq;
  5105. u32 end_freq;
  5106. };
  5107. /**
  5108. * struct wiphy_radio - physical radio of a wiphy
  5109. * This structure describes a physical radio belonging to a wiphy.
  5110. * It is used to describe concurrent-channel capabilities. Only one channel
  5111. * can be active on the radio described by struct wiphy_radio.
  5112. *
  5113. * @freq_range: frequency range that the radio can operate on.
  5114. * @n_freq_range: number of elements in @freq_range
  5115. *
  5116. * @iface_combinations: Valid interface combinations array, should not
  5117. * list single interface types.
  5118. * @n_iface_combinations: number of entries in @iface_combinations array.
  5119. */
  5120. struct wiphy_radio {
  5121. const struct wiphy_radio_freq_range *freq_range;
  5122. int n_freq_range;
  5123. const struct ieee80211_iface_combination *iface_combinations;
  5124. int n_iface_combinations;
  5125. };
  5126. #define CFG80211_HW_TIMESTAMP_ALL_PEERS 0xffff
  5127. /**
  5128. * struct wiphy - wireless hardware description
  5129. * @mtx: mutex for the data (structures) of this device
  5130. * @reg_notifier: the driver's regulatory notification callback,
  5131. * note that if your driver uses wiphy_apply_custom_regulatory()
  5132. * the reg_notifier's request can be passed as NULL
  5133. * @regd: the driver's regulatory domain, if one was requested via
  5134. * the regulatory_hint() API. This can be used by the driver
  5135. * on the reg_notifier() if it chooses to ignore future
  5136. * regulatory domain changes caused by other drivers.
  5137. * @signal_type: signal type reported in &struct cfg80211_bss.
  5138. * @cipher_suites: supported cipher suites
  5139. * @n_cipher_suites: number of supported cipher suites
  5140. * @akm_suites: supported AKM suites. These are the default AKMs supported if
  5141. * the supported AKMs not advertized for a specific interface type in
  5142. * iftype_akm_suites.
  5143. * @n_akm_suites: number of supported AKM suites
  5144. * @iftype_akm_suites: array of supported akm suites info per interface type.
  5145. * Note that the bits in @iftypes_mask inside this structure cannot
  5146. * overlap (i.e. only one occurrence of each type is allowed across all
  5147. * instances of iftype_akm_suites).
  5148. * @num_iftype_akm_suites: number of interface types for which supported akm
  5149. * suites are specified separately.
  5150. * @retry_short: Retry limit for short frames (dot11ShortRetryLimit)
  5151. * @retry_long: Retry limit for long frames (dot11LongRetryLimit)
  5152. * @frag_threshold: Fragmentation threshold (dot11FragmentationThreshold);
  5153. * -1 = fragmentation disabled, only odd values >= 256 used
  5154. * @rts_threshold: RTS threshold (dot11RTSThreshold); -1 = RTS/CTS disabled
  5155. * @_net: the network namespace this wiphy currently lives in
  5156. * @perm_addr: permanent MAC address of this device
  5157. * @addr_mask: If the device supports multiple MAC addresses by masking,
  5158. * set this to a mask with variable bits set to 1, e.g. if the last
  5159. * four bits are variable then set it to 00-00-00-00-00-0f. The actual
  5160. * variable bits shall be determined by the interfaces added, with
  5161. * interfaces not matching the mask being rejected to be brought up.
  5162. * @n_addresses: number of addresses in @addresses.
  5163. * @addresses: If the device has more than one address, set this pointer
  5164. * to a list of addresses (6 bytes each). The first one will be used
  5165. * by default for perm_addr. In this case, the mask should be set to
  5166. * all-zeroes. In this case it is assumed that the device can handle
  5167. * the same number of arbitrary MAC addresses.
  5168. * @registered: protects ->resume and ->suspend sysfs callbacks against
  5169. * unregister hardware
  5170. * @debugfsdir: debugfs directory used for this wiphy (ieee80211/<wiphyname>).
  5171. * It will be renamed automatically on wiphy renames
  5172. * @dev: (virtual) struct device for this wiphy. The item in
  5173. * /sys/class/ieee80211/ points to this. You need use set_wiphy_dev()
  5174. * (see below).
  5175. * @wext: wireless extension handlers
  5176. * @priv: driver private data (sized according to wiphy_new() parameter)
  5177. * @interface_modes: bitmask of interfaces types valid for this wiphy,
  5178. * must be set by driver
  5179. * @iface_combinations: Valid interface combinations array, should not
  5180. * list single interface types.
  5181. * @n_iface_combinations: number of entries in @iface_combinations array.
  5182. * @software_iftypes: bitmask of software interface types, these are not
  5183. * subject to any restrictions since they are purely managed in SW.
  5184. * @flags: wiphy flags, see &enum wiphy_flags
  5185. * @regulatory_flags: wiphy regulatory flags, see
  5186. * &enum ieee80211_regulatory_flags
  5187. * @features: features advertised to nl80211, see &enum nl80211_feature_flags.
  5188. * @ext_features: extended features advertised to nl80211, see
  5189. * &enum nl80211_ext_feature_index.
  5190. * @bss_priv_size: each BSS struct has private data allocated with it,
  5191. * this variable determines its size
  5192. * @max_scan_ssids: maximum number of SSIDs the device can scan for in
  5193. * any given scan
  5194. * @max_sched_scan_reqs: maximum number of scheduled scan requests that
  5195. * the device can run concurrently.
  5196. * @max_sched_scan_ssids: maximum number of SSIDs the device can scan
  5197. * for in any given scheduled scan
  5198. * @max_match_sets: maximum number of match sets the device can handle
  5199. * when performing a scheduled scan, 0 if filtering is not
  5200. * supported.
  5201. * @max_scan_ie_len: maximum length of user-controlled IEs device can
  5202. * add to probe request frames transmitted during a scan, must not
  5203. * include fixed IEs like supported rates
  5204. * @max_sched_scan_ie_len: same as max_scan_ie_len, but for scheduled
  5205. * scans
  5206. * @max_sched_scan_plans: maximum number of scan plans (scan interval and number
  5207. * of iterations) for scheduled scan supported by the device.
  5208. * @max_sched_scan_plan_interval: maximum interval (in seconds) for a
  5209. * single scan plan supported by the device.
  5210. * @max_sched_scan_plan_iterations: maximum number of iterations for a single
  5211. * scan plan supported by the device.
  5212. * @coverage_class: current coverage class
  5213. * @fw_version: firmware version for ethtool reporting
  5214. * @hw_version: hardware version for ethtool reporting
  5215. * @max_num_pmkids: maximum number of PMKIDs supported by device
  5216. * @privid: a pointer that drivers can use to identify if an arbitrary
  5217. * wiphy is theirs, e.g. in global notifiers
  5218. * @bands: information about bands/channels supported by this device
  5219. *
  5220. * @mgmt_stypes: bitmasks of frame subtypes that can be subscribed to or
  5221. * transmitted through nl80211, points to an array indexed by interface
  5222. * type
  5223. *
  5224. * @available_antennas_tx: bitmap of antennas which are available to be
  5225. * configured as TX antennas. Antenna configuration commands will be
  5226. * rejected unless this or @available_antennas_rx is set.
  5227. *
  5228. * @available_antennas_rx: bitmap of antennas which are available to be
  5229. * configured as RX antennas. Antenna configuration commands will be
  5230. * rejected unless this or @available_antennas_tx is set.
  5231. *
  5232. * @probe_resp_offload:
  5233. * Bitmap of supported protocols for probe response offloading.
  5234. * See &enum nl80211_probe_resp_offload_support_attr. Only valid
  5235. * when the wiphy flag @WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD is set.
  5236. *
  5237. * @max_remain_on_channel_duration: Maximum time a remain-on-channel operation
  5238. * may request, if implemented.
  5239. *
  5240. * @wowlan: WoWLAN support information
  5241. * @wowlan_config: current WoWLAN configuration; this should usually not be
  5242. * used since access to it is necessarily racy, use the parameter passed
  5243. * to the suspend() operation instead.
  5244. *
  5245. * @ap_sme_capa: AP SME capabilities, flags from &enum nl80211_ap_sme_features.
  5246. * @ht_capa_mod_mask: Specify what ht_cap values can be over-ridden.
  5247. * If null, then none can be over-ridden.
  5248. * @vht_capa_mod_mask: Specify what VHT capabilities can be over-ridden.
  5249. * If null, then none can be over-ridden.
  5250. *
  5251. * @wdev_list: the list of associated (virtual) interfaces; this list must
  5252. * not be modified by the driver, but can be read with RTNL/RCU protection.
  5253. *
  5254. * @max_acl_mac_addrs: Maximum number of MAC addresses that the device
  5255. * supports for ACL.
  5256. *
  5257. * @extended_capabilities: extended capabilities supported by the driver,
  5258. * additional capabilities might be supported by userspace; these are
  5259. * the 802.11 extended capabilities ("Extended Capabilities element")
  5260. * and are in the same format as in the information element. See
  5261. * 802.11-2012 8.4.2.29 for the defined fields. These are the default
  5262. * extended capabilities to be used if the capabilities are not specified
  5263. * for a specific interface type in iftype_ext_capab.
  5264. * @extended_capabilities_mask: mask of the valid values
  5265. * @extended_capabilities_len: length of the extended capabilities
  5266. * @iftype_ext_capab: array of extended capabilities per interface type
  5267. * @num_iftype_ext_capab: number of interface types for which extended
  5268. * capabilities are specified separately.
  5269. * @coalesce: packet coalescing support information
  5270. *
  5271. * @vendor_commands: array of vendor commands supported by the hardware
  5272. * @n_vendor_commands: number of vendor commands
  5273. * @vendor_events: array of vendor events supported by the hardware
  5274. * @n_vendor_events: number of vendor events
  5275. *
  5276. * @max_ap_assoc_sta: maximum number of associated stations supported in AP mode
  5277. * (including P2P GO) or 0 to indicate no such limit is advertised. The
  5278. * driver is allowed to advertise a theoretical limit that it can reach in
  5279. * some cases, but may not always reach.
  5280. *
  5281. * @max_num_csa_counters: Number of supported csa_counters in beacons
  5282. * and probe responses. This value should be set if the driver
  5283. * wishes to limit the number of csa counters. Default (0) means
  5284. * infinite.
  5285. * @bss_select_support: bitmask indicating the BSS selection criteria supported
  5286. * by the driver in the .connect() callback. The bit position maps to the
  5287. * attribute indices defined in &enum nl80211_bss_select_attr.
  5288. *
  5289. * @nan_supported_bands: bands supported by the device in NAN mode, a
  5290. * bitmap of &enum nl80211_band values. For instance, for
  5291. * NL80211_BAND_2GHZ, bit 0 would be set
  5292. * (i.e. BIT(NL80211_BAND_2GHZ)).
  5293. *
  5294. * @txq_limit: configuration of internal TX queue frame limit
  5295. * @txq_memory_limit: configuration internal TX queue memory limit
  5296. * @txq_quantum: configuration of internal TX queue scheduler quantum
  5297. *
  5298. * @tx_queue_len: allow setting transmit queue len for drivers not using
  5299. * wake_tx_queue
  5300. *
  5301. * @support_mbssid: can HW support association with nontransmitted AP
  5302. * @support_only_he_mbssid: don't parse MBSSID elements if it is not
  5303. * HE AP, in order to avoid compatibility issues.
  5304. * @support_mbssid must be set for this to have any effect.
  5305. *
  5306. * @pmsr_capa: peer measurement capabilities
  5307. *
  5308. * @tid_config_support: describes the per-TID config support that the
  5309. * device has
  5310. * @tid_config_support.vif: bitmap of attributes (configurations)
  5311. * supported by the driver for each vif
  5312. * @tid_config_support.peer: bitmap of attributes (configurations)
  5313. * supported by the driver for each peer
  5314. * @tid_config_support.max_retry: maximum supported retry count for
  5315. * long/short retry configuration
  5316. *
  5317. * @max_data_retry_count: maximum supported per TID retry count for
  5318. * configuration through the %NL80211_TID_CONFIG_ATTR_RETRY_SHORT and
  5319. * %NL80211_TID_CONFIG_ATTR_RETRY_LONG attributes
  5320. * @sar_capa: SAR control capabilities
  5321. * @rfkill: a pointer to the rfkill structure
  5322. *
  5323. * @mbssid_max_interfaces: maximum number of interfaces supported by the driver
  5324. * in a multiple BSSID set. This field must be set to a non-zero value
  5325. * by the driver to advertise MBSSID support.
  5326. * @ema_max_profile_periodicity: maximum profile periodicity supported by
  5327. * the driver. Setting this field to a non-zero value indicates that the
  5328. * driver supports enhanced multi-BSSID advertisements (EMA AP).
  5329. * @max_num_akm_suites: maximum number of AKM suites allowed for
  5330. * configuration through %NL80211_CMD_CONNECT, %NL80211_CMD_ASSOCIATE and
  5331. * %NL80211_CMD_START_AP. Set to NL80211_MAX_NR_AKM_SUITES if not set by
  5332. * driver. If set by driver minimum allowed value is
  5333. * NL80211_MAX_NR_AKM_SUITES in order to avoid compatibility issues with
  5334. * legacy userspace and maximum allowed value is
  5335. * CFG80211_MAX_NUM_AKM_SUITES.
  5336. *
  5337. * @hw_timestamp_max_peers: maximum number of peers that the driver supports
  5338. * enabling HW timestamping for concurrently. Setting this field to a
  5339. * non-zero value indicates that the driver supports HW timestamping.
  5340. * A value of %CFG80211_HW_TIMESTAMP_ALL_PEERS indicates the driver
  5341. * supports enabling HW timestamping for all peers (i.e. no need to
  5342. * specify a mac address).
  5343. *
  5344. * @radio: radios belonging to this wiphy
  5345. * @n_radio: number of radios
  5346. */
  5347. struct wiphy {
  5348. struct mutex mtx;
  5349. /* assign these fields before you register the wiphy */
  5350. u8 perm_addr[ETH_ALEN];
  5351. u8 addr_mask[ETH_ALEN];
  5352. struct mac_address *addresses;
  5353. const struct ieee80211_txrx_stypes *mgmt_stypes;
  5354. const struct ieee80211_iface_combination *iface_combinations;
  5355. int n_iface_combinations;
  5356. u16 software_iftypes;
  5357. u16 n_addresses;
  5358. /* Supported interface modes, OR together BIT(NL80211_IFTYPE_...) */
  5359. u16 interface_modes;
  5360. u16 max_acl_mac_addrs;
  5361. u32 flags, regulatory_flags, features;
  5362. u8 ext_features[DIV_ROUND_UP(NUM_NL80211_EXT_FEATURES, 8)];
  5363. u32 ap_sme_capa;
  5364. enum cfg80211_signal_type signal_type;
  5365. int bss_priv_size;
  5366. u8 max_scan_ssids;
  5367. u8 max_sched_scan_reqs;
  5368. u8 max_sched_scan_ssids;
  5369. u8 max_match_sets;
  5370. u16 max_scan_ie_len;
  5371. u16 max_sched_scan_ie_len;
  5372. u32 max_sched_scan_plans;
  5373. u32 max_sched_scan_plan_interval;
  5374. u32 max_sched_scan_plan_iterations;
  5375. int n_cipher_suites;
  5376. const u32 *cipher_suites;
  5377. int n_akm_suites;
  5378. const u32 *akm_suites;
  5379. const struct wiphy_iftype_akm_suites *iftype_akm_suites;
  5380. unsigned int num_iftype_akm_suites;
  5381. u8 retry_short;
  5382. u8 retry_long;
  5383. u32 frag_threshold;
  5384. u32 rts_threshold;
  5385. u8 coverage_class;
  5386. char fw_version[ETHTOOL_FWVERS_LEN];
  5387. u32 hw_version;
  5388. #ifdef CONFIG_PM
  5389. const struct wiphy_wowlan_support *wowlan;
  5390. struct cfg80211_wowlan *wowlan_config;
  5391. #endif
  5392. u16 max_remain_on_channel_duration;
  5393. u8 max_num_pmkids;
  5394. u32 available_antennas_tx;
  5395. u32 available_antennas_rx;
  5396. u32 probe_resp_offload;
  5397. const u8 *extended_capabilities, *extended_capabilities_mask;
  5398. u8 extended_capabilities_len;
  5399. const struct wiphy_iftype_ext_capab *iftype_ext_capab;
  5400. unsigned int num_iftype_ext_capab;
  5401. const void *privid;
  5402. struct ieee80211_supported_band *bands[NUM_NL80211_BANDS];
  5403. void (*reg_notifier)(struct wiphy *wiphy,
  5404. struct regulatory_request *request);
  5405. /* fields below are read-only, assigned by cfg80211 */
  5406. const struct ieee80211_regdomain __rcu *regd;
  5407. struct device dev;
  5408. bool registered;
  5409. struct dentry *debugfsdir;
  5410. const struct ieee80211_ht_cap *ht_capa_mod_mask;
  5411. const struct ieee80211_vht_cap *vht_capa_mod_mask;
  5412. struct list_head wdev_list;
  5413. possible_net_t _net;
  5414. #ifdef CONFIG_CFG80211_WEXT
  5415. const struct iw_handler_def *wext;
  5416. #endif
  5417. const struct wiphy_coalesce_support *coalesce;
  5418. const struct wiphy_vendor_command *vendor_commands;
  5419. const struct nl80211_vendor_cmd_info *vendor_events;
  5420. int n_vendor_commands, n_vendor_events;
  5421. u16 max_ap_assoc_sta;
  5422. u8 max_num_csa_counters;
  5423. u32 bss_select_support;
  5424. u8 nan_supported_bands;
  5425. u32 txq_limit;
  5426. u32 txq_memory_limit;
  5427. u32 txq_quantum;
  5428. unsigned long tx_queue_len;
  5429. u8 support_mbssid:1,
  5430. support_only_he_mbssid:1;
  5431. const struct cfg80211_pmsr_capabilities *pmsr_capa;
  5432. struct {
  5433. u64 peer, vif;
  5434. u8 max_retry;
  5435. } tid_config_support;
  5436. u8 max_data_retry_count;
  5437. const struct cfg80211_sar_capa *sar_capa;
  5438. struct rfkill *rfkill;
  5439. u8 mbssid_max_interfaces;
  5440. u8 ema_max_profile_periodicity;
  5441. u16 max_num_akm_suites;
  5442. u16 hw_timestamp_max_peers;
  5443. int n_radio;
  5444. const struct wiphy_radio *radio;
  5445. char priv[] __aligned(NETDEV_ALIGN);
  5446. };
  5447. static inline struct net *wiphy_net(struct wiphy *wiphy)
  5448. {
  5449. return read_pnet(&wiphy->_net);
  5450. }
  5451. static inline void wiphy_net_set(struct wiphy *wiphy, struct net *net)
  5452. {
  5453. write_pnet(&wiphy->_net, net);
  5454. }
  5455. /**
  5456. * wiphy_priv - return priv from wiphy
  5457. *
  5458. * @wiphy: the wiphy whose priv pointer to return
  5459. * Return: The priv of @wiphy.
  5460. */
  5461. static inline void *wiphy_priv(struct wiphy *wiphy)
  5462. {
  5463. BUG_ON(!wiphy);
  5464. return &wiphy->priv;
  5465. }
  5466. /**
  5467. * priv_to_wiphy - return the wiphy containing the priv
  5468. *
  5469. * @priv: a pointer previously returned by wiphy_priv
  5470. * Return: The wiphy of @priv.
  5471. */
  5472. static inline struct wiphy *priv_to_wiphy(void *priv)
  5473. {
  5474. BUG_ON(!priv);
  5475. return container_of(priv, struct wiphy, priv);
  5476. }
  5477. /**
  5478. * set_wiphy_dev - set device pointer for wiphy
  5479. *
  5480. * @wiphy: The wiphy whose device to bind
  5481. * @dev: The device to parent it to
  5482. */
  5483. static inline void set_wiphy_dev(struct wiphy *wiphy, struct device *dev)
  5484. {
  5485. wiphy->dev.parent = dev;
  5486. }
  5487. /**
  5488. * wiphy_dev - get wiphy dev pointer
  5489. *
  5490. * @wiphy: The wiphy whose device struct to look up
  5491. * Return: The dev of @wiphy.
  5492. */
  5493. static inline struct device *wiphy_dev(struct wiphy *wiphy)
  5494. {
  5495. return wiphy->dev.parent;
  5496. }
  5497. /**
  5498. * wiphy_name - get wiphy name
  5499. *
  5500. * @wiphy: The wiphy whose name to return
  5501. * Return: The name of @wiphy.
  5502. */
  5503. static inline const char *wiphy_name(const struct wiphy *wiphy)
  5504. {
  5505. return dev_name(&wiphy->dev);
  5506. }
  5507. /**
  5508. * wiphy_new_nm - create a new wiphy for use with cfg80211
  5509. *
  5510. * @ops: The configuration operations for this device
  5511. * @sizeof_priv: The size of the private area to allocate
  5512. * @requested_name: Request a particular name.
  5513. * NULL is valid value, and means use the default phy%d naming.
  5514. *
  5515. * Create a new wiphy and associate the given operations with it.
  5516. * @sizeof_priv bytes are allocated for private use.
  5517. *
  5518. * Return: A pointer to the new wiphy. This pointer must be
  5519. * assigned to each netdev's ieee80211_ptr for proper operation.
  5520. */
  5521. struct wiphy *wiphy_new_nm(const struct cfg80211_ops *ops, int sizeof_priv,
  5522. const char *requested_name);
  5523. /**
  5524. * wiphy_new - create a new wiphy for use with cfg80211
  5525. *
  5526. * @ops: The configuration operations for this device
  5527. * @sizeof_priv: The size of the private area to allocate
  5528. *
  5529. * Create a new wiphy and associate the given operations with it.
  5530. * @sizeof_priv bytes are allocated for private use.
  5531. *
  5532. * Return: A pointer to the new wiphy. This pointer must be
  5533. * assigned to each netdev's ieee80211_ptr for proper operation.
  5534. */
  5535. static inline struct wiphy *wiphy_new(const struct cfg80211_ops *ops,
  5536. int sizeof_priv)
  5537. {
  5538. return wiphy_new_nm(ops, sizeof_priv, NULL);
  5539. }
  5540. /**
  5541. * wiphy_register - register a wiphy with cfg80211
  5542. *
  5543. * @wiphy: The wiphy to register.
  5544. *
  5545. * Return: A non-negative wiphy index or a negative error code.
  5546. */
  5547. int wiphy_register(struct wiphy *wiphy);
  5548. /* this is a define for better error reporting (file/line) */
  5549. #define lockdep_assert_wiphy(wiphy) lockdep_assert_held(&(wiphy)->mtx)
  5550. /**
  5551. * rcu_dereference_wiphy - rcu_dereference with debug checking
  5552. * @wiphy: the wiphy to check the locking on
  5553. * @p: The pointer to read, prior to dereferencing
  5554. *
  5555. * Do an rcu_dereference(p), but check caller either holds rcu_read_lock()
  5556. * or RTNL. Note: Please prefer wiphy_dereference() or rcu_dereference().
  5557. */
  5558. #define rcu_dereference_wiphy(wiphy, p) \
  5559. rcu_dereference_check(p, lockdep_is_held(&wiphy->mtx))
  5560. /**
  5561. * wiphy_dereference - fetch RCU pointer when updates are prevented by wiphy mtx
  5562. * @wiphy: the wiphy to check the locking on
  5563. * @p: The pointer to read, prior to dereferencing
  5564. *
  5565. * Return the value of the specified RCU-protected pointer, but omit the
  5566. * READ_ONCE(), because caller holds the wiphy mutex used for updates.
  5567. */
  5568. #define wiphy_dereference(wiphy, p) \
  5569. rcu_dereference_protected(p, lockdep_is_held(&wiphy->mtx))
  5570. /**
  5571. * get_wiphy_regdom - get custom regdomain for the given wiphy
  5572. * @wiphy: the wiphy to get the regdomain from
  5573. *
  5574. * Context: Requires any of RTNL, wiphy mutex or RCU protection.
  5575. *
  5576. * Return: pointer to the regulatory domain associated with the wiphy
  5577. */
  5578. const struct ieee80211_regdomain *get_wiphy_regdom(struct wiphy *wiphy);
  5579. /**
  5580. * wiphy_unregister - deregister a wiphy from cfg80211
  5581. *
  5582. * @wiphy: The wiphy to unregister.
  5583. *
  5584. * After this call, no more requests can be made with this priv
  5585. * pointer, but the call may sleep to wait for an outstanding
  5586. * request that is being handled.
  5587. */
  5588. void wiphy_unregister(struct wiphy *wiphy);
  5589. /**
  5590. * wiphy_free - free wiphy
  5591. *
  5592. * @wiphy: The wiphy to free
  5593. */
  5594. void wiphy_free(struct wiphy *wiphy);
  5595. /* internal structs */
  5596. struct cfg80211_conn;
  5597. struct cfg80211_internal_bss;
  5598. struct cfg80211_cached_keys;
  5599. struct cfg80211_cqm_config;
  5600. /**
  5601. * wiphy_lock - lock the wiphy
  5602. * @wiphy: the wiphy to lock
  5603. *
  5604. * This is needed around registering and unregistering netdevs that
  5605. * aren't created through cfg80211 calls, since that requires locking
  5606. * in cfg80211 when the notifiers is called, but that cannot
  5607. * differentiate which way it's called.
  5608. *
  5609. * It can also be used by drivers for their own purposes.
  5610. *
  5611. * When cfg80211 ops are called, the wiphy is already locked.
  5612. *
  5613. * Note that this makes sure that no workers that have been queued
  5614. * with wiphy_queue_work() are running.
  5615. */
  5616. static inline void wiphy_lock(struct wiphy *wiphy)
  5617. __acquires(&wiphy->mtx)
  5618. {
  5619. mutex_lock(&wiphy->mtx);
  5620. __acquire(&wiphy->mtx);
  5621. }
  5622. /**
  5623. * wiphy_unlock - unlock the wiphy again
  5624. * @wiphy: the wiphy to unlock
  5625. */
  5626. static inline void wiphy_unlock(struct wiphy *wiphy)
  5627. __releases(&wiphy->mtx)
  5628. {
  5629. __release(&wiphy->mtx);
  5630. mutex_unlock(&wiphy->mtx);
  5631. }
  5632. struct wiphy_work;
  5633. typedef void (*wiphy_work_func_t)(struct wiphy *, struct wiphy_work *);
  5634. struct wiphy_work {
  5635. struct list_head entry;
  5636. wiphy_work_func_t func;
  5637. };
  5638. static inline void wiphy_work_init(struct wiphy_work *work,
  5639. wiphy_work_func_t func)
  5640. {
  5641. INIT_LIST_HEAD(&work->entry);
  5642. work->func = func;
  5643. }
  5644. /**
  5645. * wiphy_work_queue - queue work for the wiphy
  5646. * @wiphy: the wiphy to queue for
  5647. * @work: the work item
  5648. *
  5649. * This is useful for work that must be done asynchronously, and work
  5650. * queued here has the special property that the wiphy mutex will be
  5651. * held as if wiphy_lock() was called, and that it cannot be running
  5652. * after wiphy_lock() was called. Therefore, wiphy_cancel_work() can
  5653. * use just cancel_work() instead of cancel_work_sync(), it requires
  5654. * being in a section protected by wiphy_lock().
  5655. */
  5656. void wiphy_work_queue(struct wiphy *wiphy, struct wiphy_work *work);
  5657. /**
  5658. * wiphy_work_cancel - cancel previously queued work
  5659. * @wiphy: the wiphy, for debug purposes
  5660. * @work: the work to cancel
  5661. *
  5662. * Cancel the work *without* waiting for it, this assumes being
  5663. * called under the wiphy mutex acquired by wiphy_lock().
  5664. */
  5665. void wiphy_work_cancel(struct wiphy *wiphy, struct wiphy_work *work);
  5666. /**
  5667. * wiphy_work_flush - flush previously queued work
  5668. * @wiphy: the wiphy, for debug purposes
  5669. * @work: the work to flush, this can be %NULL to flush all work
  5670. *
  5671. * Flush the work (i.e. run it if pending). This must be called
  5672. * under the wiphy mutex acquired by wiphy_lock().
  5673. */
  5674. void wiphy_work_flush(struct wiphy *wiphy, struct wiphy_work *work);
  5675. struct wiphy_delayed_work {
  5676. struct wiphy_work work;
  5677. struct wiphy *wiphy;
  5678. struct timer_list timer;
  5679. };
  5680. void wiphy_delayed_work_timer(struct timer_list *t);
  5681. static inline void wiphy_delayed_work_init(struct wiphy_delayed_work *dwork,
  5682. wiphy_work_func_t func)
  5683. {
  5684. timer_setup(&dwork->timer, wiphy_delayed_work_timer, 0);
  5685. wiphy_work_init(&dwork->work, func);
  5686. }
  5687. /**
  5688. * wiphy_delayed_work_queue - queue delayed work for the wiphy
  5689. * @wiphy: the wiphy to queue for
  5690. * @dwork: the delayable worker
  5691. * @delay: number of jiffies to wait before queueing
  5692. *
  5693. * This is useful for work that must be done asynchronously, and work
  5694. * queued here has the special property that the wiphy mutex will be
  5695. * held as if wiphy_lock() was called, and that it cannot be running
  5696. * after wiphy_lock() was called. Therefore, wiphy_cancel_work() can
  5697. * use just cancel_work() instead of cancel_work_sync(), it requires
  5698. * being in a section protected by wiphy_lock().
  5699. */
  5700. void wiphy_delayed_work_queue(struct wiphy *wiphy,
  5701. struct wiphy_delayed_work *dwork,
  5702. unsigned long delay);
  5703. /**
  5704. * wiphy_delayed_work_cancel - cancel previously queued delayed work
  5705. * @wiphy: the wiphy, for debug purposes
  5706. * @dwork: the delayed work to cancel
  5707. *
  5708. * Cancel the work *without* waiting for it, this assumes being
  5709. * called under the wiphy mutex acquired by wiphy_lock().
  5710. */
  5711. void wiphy_delayed_work_cancel(struct wiphy *wiphy,
  5712. struct wiphy_delayed_work *dwork);
  5713. /**
  5714. * wiphy_delayed_work_flush - flush previously queued delayed work
  5715. * @wiphy: the wiphy, for debug purposes
  5716. * @dwork: the delayed work to flush
  5717. *
  5718. * Flush the work (i.e. run it if pending). This must be called
  5719. * under the wiphy mutex acquired by wiphy_lock().
  5720. */
  5721. void wiphy_delayed_work_flush(struct wiphy *wiphy,
  5722. struct wiphy_delayed_work *dwork);
  5723. /**
  5724. * wiphy_delayed_work_pending - Find out whether a wiphy delayable
  5725. * work item is currently pending.
  5726. *
  5727. * @wiphy: the wiphy, for debug purposes
  5728. * @dwork: the delayed work in question
  5729. *
  5730. * Return: true if timer is pending, false otherwise
  5731. *
  5732. * How wiphy_delayed_work_queue() works is by setting a timer which
  5733. * when it expires calls wiphy_work_queue() to queue the wiphy work.
  5734. * Because wiphy_delayed_work_queue() uses mod_timer(), if it is
  5735. * called twice and the second call happens before the first call
  5736. * deadline, the work will rescheduled for the second deadline and
  5737. * won't run before that.
  5738. *
  5739. * wiphy_delayed_work_pending() can be used to detect if calling
  5740. * wiphy_work_delayed_work_queue() would start a new work schedule
  5741. * or delayed a previous one. As seen below it cannot be used to
  5742. * detect precisely if the work has finished to execute nor if it
  5743. * is currently executing.
  5744. *
  5745. * CPU0 CPU1
  5746. * wiphy_delayed_work_queue(wk)
  5747. * mod_timer(wk->timer)
  5748. * wiphy_delayed_work_pending(wk) -> true
  5749. *
  5750. * [...]
  5751. * expire_timers(wk->timer)
  5752. * detach_timer(wk->timer)
  5753. * wiphy_delayed_work_pending(wk) -> false
  5754. * wk->timer->function() |
  5755. * wiphy_work_queue(wk) | delayed work pending
  5756. * list_add_tail() | returns false but
  5757. * queue_work(cfg80211_wiphy_work) | wk->func() has not
  5758. * | been run yet
  5759. * [...] |
  5760. * cfg80211_wiphy_work() |
  5761. * wk->func() V
  5762. *
  5763. */
  5764. bool wiphy_delayed_work_pending(struct wiphy *wiphy,
  5765. struct wiphy_delayed_work *dwork);
  5766. /**
  5767. * enum ieee80211_ap_reg_power - regulatory power for an Access Point
  5768. *
  5769. * @IEEE80211_REG_UNSET_AP: Access Point has no regulatory power mode
  5770. * @IEEE80211_REG_LPI_AP: Indoor Access Point
  5771. * @IEEE80211_REG_SP_AP: Standard power Access Point
  5772. * @IEEE80211_REG_VLP_AP: Very low power Access Point
  5773. */
  5774. enum ieee80211_ap_reg_power {
  5775. IEEE80211_REG_UNSET_AP,
  5776. IEEE80211_REG_LPI_AP,
  5777. IEEE80211_REG_SP_AP,
  5778. IEEE80211_REG_VLP_AP,
  5779. };
  5780. /**
  5781. * struct wireless_dev - wireless device state
  5782. *
  5783. * For netdevs, this structure must be allocated by the driver
  5784. * that uses the ieee80211_ptr field in struct net_device (this
  5785. * is intentional so it can be allocated along with the netdev.)
  5786. * It need not be registered then as netdev registration will
  5787. * be intercepted by cfg80211 to see the new wireless device,
  5788. * however, drivers must lock the wiphy before registering or
  5789. * unregistering netdevs if they pre-create any netdevs (in ops
  5790. * called from cfg80211, the wiphy is already locked.)
  5791. *
  5792. * For non-netdev uses, it must also be allocated by the driver
  5793. * in response to the cfg80211 callbacks that require it, as
  5794. * there's no netdev registration in that case it may not be
  5795. * allocated outside of callback operations that return it.
  5796. *
  5797. * @wiphy: pointer to hardware description
  5798. * @iftype: interface type
  5799. * @registered: is this wdev already registered with cfg80211
  5800. * @registering: indicates we're doing registration under wiphy lock
  5801. * for the notifier
  5802. * @list: (private) Used to collect the interfaces
  5803. * @netdev: (private) Used to reference back to the netdev, may be %NULL
  5804. * @identifier: (private) Identifier used in nl80211 to identify this
  5805. * wireless device if it has no netdev
  5806. * @u: union containing data specific to @iftype
  5807. * @connected: indicates if connected or not (STA mode)
  5808. * @wext: (private) Used by the internal wireless extensions compat code
  5809. * @wext.ibss: (private) IBSS data part of wext handling
  5810. * @wext.connect: (private) connection handling data
  5811. * @wext.keys: (private) (WEP) key data
  5812. * @wext.ie: (private) extra elements for association
  5813. * @wext.ie_len: (private) length of extra elements
  5814. * @wext.bssid: (private) selected network BSSID
  5815. * @wext.ssid: (private) selected network SSID
  5816. * @wext.default_key: (private) selected default key index
  5817. * @wext.default_mgmt_key: (private) selected default management key index
  5818. * @wext.prev_bssid: (private) previous BSSID for reassociation
  5819. * @wext.prev_bssid_valid: (private) previous BSSID validity
  5820. * @use_4addr: indicates 4addr mode is used on this interface, must be
  5821. * set by driver (if supported) on add_interface BEFORE registering the
  5822. * netdev and may otherwise be used by driver read-only, will be update
  5823. * by cfg80211 on change_interface
  5824. * @mgmt_registrations: list of registrations for management frames
  5825. * @mgmt_registrations_need_update: mgmt registrations were updated,
  5826. * need to propagate the update to the driver
  5827. * @address: The address for this device, valid only if @netdev is %NULL
  5828. * @is_running: true if this is a non-netdev device that has been started, e.g.
  5829. * the P2P Device.
  5830. * @ps: powersave mode is enabled
  5831. * @ps_timeout: dynamic powersave timeout
  5832. * @ap_unexpected_nlportid: (private) netlink port ID of application
  5833. * registered for unexpected class 3 frames (AP mode)
  5834. * @conn: (private) cfg80211 software SME connection state machine data
  5835. * @connect_keys: (private) keys to set after connection is established
  5836. * @conn_bss_type: connecting/connected BSS type
  5837. * @conn_owner_nlportid: (private) connection owner socket port ID
  5838. * @disconnect_wk: (private) auto-disconnect work
  5839. * @disconnect_bssid: (private) the BSSID to use for auto-disconnect
  5840. * @event_list: (private) list for internal event processing
  5841. * @event_lock: (private) lock for event list
  5842. * @owner_nlportid: (private) owner socket port ID
  5843. * @nl_owner_dead: (private) owner socket went away
  5844. * @cqm_rssi_work: (private) CQM RSSI reporting work
  5845. * @cqm_config: (private) nl80211 RSSI monitor state
  5846. * @pmsr_list: (private) peer measurement requests
  5847. * @pmsr_lock: (private) peer measurements requests/results lock
  5848. * @pmsr_free_wk: (private) peer measurements cleanup work
  5849. * @unprot_beacon_reported: (private) timestamp of last
  5850. * unprotected beacon report
  5851. * @links: array of %IEEE80211_MLD_MAX_NUM_LINKS elements containing @addr
  5852. * @ap and @client for each link
  5853. * @links.cac_started: true if DFS channel availability check has been
  5854. * started
  5855. * @links.cac_start_time: timestamp (jiffies) when the dfs state was
  5856. * entered.
  5857. * @links.cac_time_ms: CAC time in ms
  5858. * @valid_links: bitmap describing what elements of @links are valid
  5859. */
  5860. struct wireless_dev {
  5861. struct wiphy *wiphy;
  5862. enum nl80211_iftype iftype;
  5863. /* the remainder of this struct should be private to cfg80211 */
  5864. struct list_head list;
  5865. struct net_device *netdev;
  5866. u32 identifier;
  5867. struct list_head mgmt_registrations;
  5868. u8 mgmt_registrations_need_update:1;
  5869. bool use_4addr, is_running, registered, registering;
  5870. u8 address[ETH_ALEN] __aligned(sizeof(u16));
  5871. /* currently used for IBSS and SME - might be rearranged later */
  5872. struct cfg80211_conn *conn;
  5873. struct cfg80211_cached_keys *connect_keys;
  5874. enum ieee80211_bss_type conn_bss_type;
  5875. u32 conn_owner_nlportid;
  5876. struct work_struct disconnect_wk;
  5877. u8 disconnect_bssid[ETH_ALEN];
  5878. struct list_head event_list;
  5879. spinlock_t event_lock;
  5880. u8 connected:1;
  5881. bool ps;
  5882. int ps_timeout;
  5883. u32 ap_unexpected_nlportid;
  5884. u32 owner_nlportid;
  5885. bool nl_owner_dead;
  5886. #ifdef CONFIG_CFG80211_WEXT
  5887. /* wext data */
  5888. struct {
  5889. struct cfg80211_ibss_params ibss;
  5890. struct cfg80211_connect_params connect;
  5891. struct cfg80211_cached_keys *keys;
  5892. const u8 *ie;
  5893. size_t ie_len;
  5894. u8 bssid[ETH_ALEN];
  5895. u8 prev_bssid[ETH_ALEN];
  5896. u8 ssid[IEEE80211_MAX_SSID_LEN];
  5897. s8 default_key, default_mgmt_key;
  5898. bool prev_bssid_valid;
  5899. } wext;
  5900. #endif
  5901. struct wiphy_work cqm_rssi_work;
  5902. struct cfg80211_cqm_config __rcu *cqm_config;
  5903. struct list_head pmsr_list;
  5904. spinlock_t pmsr_lock;
  5905. struct work_struct pmsr_free_wk;
  5906. unsigned long unprot_beacon_reported;
  5907. union {
  5908. struct {
  5909. u8 connected_addr[ETH_ALEN] __aligned(2);
  5910. u8 ssid[IEEE80211_MAX_SSID_LEN];
  5911. u8 ssid_len;
  5912. } client;
  5913. struct {
  5914. int beacon_interval;
  5915. struct cfg80211_chan_def preset_chandef;
  5916. struct cfg80211_chan_def chandef;
  5917. u8 id[IEEE80211_MAX_MESH_ID_LEN];
  5918. u8 id_len, id_up_len;
  5919. } mesh;
  5920. struct {
  5921. struct cfg80211_chan_def preset_chandef;
  5922. u8 ssid[IEEE80211_MAX_SSID_LEN];
  5923. u8 ssid_len;
  5924. } ap;
  5925. struct {
  5926. struct cfg80211_internal_bss *current_bss;
  5927. struct cfg80211_chan_def chandef;
  5928. int beacon_interval;
  5929. u8 ssid[IEEE80211_MAX_SSID_LEN];
  5930. u8 ssid_len;
  5931. } ibss;
  5932. struct {
  5933. struct cfg80211_chan_def chandef;
  5934. } ocb;
  5935. } u;
  5936. struct {
  5937. u8 addr[ETH_ALEN] __aligned(2);
  5938. union {
  5939. struct {
  5940. unsigned int beacon_interval;
  5941. struct cfg80211_chan_def chandef;
  5942. } ap;
  5943. struct {
  5944. struct cfg80211_internal_bss *current_bss;
  5945. } client;
  5946. };
  5947. bool cac_started;
  5948. unsigned long cac_start_time;
  5949. unsigned int cac_time_ms;
  5950. } links[IEEE80211_MLD_MAX_NUM_LINKS];
  5951. u16 valid_links;
  5952. };
  5953. static inline const u8 *wdev_address(struct wireless_dev *wdev)
  5954. {
  5955. if (wdev->netdev)
  5956. return wdev->netdev->dev_addr;
  5957. return wdev->address;
  5958. }
  5959. static inline bool wdev_running(struct wireless_dev *wdev)
  5960. {
  5961. if (wdev->netdev)
  5962. return netif_running(wdev->netdev);
  5963. return wdev->is_running;
  5964. }
  5965. /**
  5966. * wdev_priv - return wiphy priv from wireless_dev
  5967. *
  5968. * @wdev: The wireless device whose wiphy's priv pointer to return
  5969. * Return: The wiphy priv of @wdev.
  5970. */
  5971. static inline void *wdev_priv(struct wireless_dev *wdev)
  5972. {
  5973. BUG_ON(!wdev);
  5974. return wiphy_priv(wdev->wiphy);
  5975. }
  5976. /**
  5977. * wdev_chandef - return chandef pointer from wireless_dev
  5978. * @wdev: the wdev
  5979. * @link_id: the link ID for MLO
  5980. *
  5981. * Return: The chandef depending on the mode, or %NULL.
  5982. */
  5983. struct cfg80211_chan_def *wdev_chandef(struct wireless_dev *wdev,
  5984. unsigned int link_id);
  5985. static inline void WARN_INVALID_LINK_ID(struct wireless_dev *wdev,
  5986. unsigned int link_id)
  5987. {
  5988. WARN_ON(link_id && !wdev->valid_links);
  5989. WARN_ON(wdev->valid_links &&
  5990. !(wdev->valid_links & BIT(link_id)));
  5991. }
  5992. #define for_each_valid_link(link_info, link_id) \
  5993. for (link_id = 0; \
  5994. link_id < ((link_info)->valid_links ? \
  5995. ARRAY_SIZE((link_info)->links) : 1); \
  5996. link_id++) \
  5997. if (!(link_info)->valid_links || \
  5998. ((link_info)->valid_links & BIT(link_id)))
  5999. /**
  6000. * DOC: Utility functions
  6001. *
  6002. * cfg80211 offers a number of utility functions that can be useful.
  6003. */
  6004. /**
  6005. * ieee80211_channel_equal - compare two struct ieee80211_channel
  6006. *
  6007. * @a: 1st struct ieee80211_channel
  6008. * @b: 2nd struct ieee80211_channel
  6009. * Return: true if center frequency of @a == @b
  6010. */
  6011. static inline bool
  6012. ieee80211_channel_equal(struct ieee80211_channel *a,
  6013. struct ieee80211_channel *b)
  6014. {
  6015. return (a->center_freq == b->center_freq &&
  6016. a->freq_offset == b->freq_offset);
  6017. }
  6018. /**
  6019. * ieee80211_channel_to_khz - convert ieee80211_channel to frequency in KHz
  6020. * @chan: struct ieee80211_channel to convert
  6021. * Return: The corresponding frequency (in KHz)
  6022. */
  6023. static inline u32
  6024. ieee80211_channel_to_khz(const struct ieee80211_channel *chan)
  6025. {
  6026. return MHZ_TO_KHZ(chan->center_freq) + chan->freq_offset;
  6027. }
  6028. /**
  6029. * ieee80211_s1g_channel_width - get allowed channel width from @chan
  6030. *
  6031. * Only allowed for band NL80211_BAND_S1GHZ
  6032. * @chan: channel
  6033. * Return: The allowed channel width for this center_freq
  6034. */
  6035. enum nl80211_chan_width
  6036. ieee80211_s1g_channel_width(const struct ieee80211_channel *chan);
  6037. /**
  6038. * ieee80211_channel_to_freq_khz - convert channel number to frequency
  6039. * @chan: channel number
  6040. * @band: band, necessary due to channel number overlap
  6041. * Return: The corresponding frequency (in KHz), or 0 if the conversion failed.
  6042. */
  6043. u32 ieee80211_channel_to_freq_khz(int chan, enum nl80211_band band);
  6044. /**
  6045. * ieee80211_channel_to_frequency - convert channel number to frequency
  6046. * @chan: channel number
  6047. * @band: band, necessary due to channel number overlap
  6048. * Return: The corresponding frequency (in MHz), or 0 if the conversion failed.
  6049. */
  6050. static inline int
  6051. ieee80211_channel_to_frequency(int chan, enum nl80211_band band)
  6052. {
  6053. return KHZ_TO_MHZ(ieee80211_channel_to_freq_khz(chan, band));
  6054. }
  6055. /**
  6056. * ieee80211_freq_khz_to_channel - convert frequency to channel number
  6057. * @freq: center frequency in KHz
  6058. * Return: The corresponding channel, or 0 if the conversion failed.
  6059. */
  6060. int ieee80211_freq_khz_to_channel(u32 freq);
  6061. /**
  6062. * ieee80211_frequency_to_channel - convert frequency to channel number
  6063. * @freq: center frequency in MHz
  6064. * Return: The corresponding channel, or 0 if the conversion failed.
  6065. */
  6066. static inline int
  6067. ieee80211_frequency_to_channel(int freq)
  6068. {
  6069. return ieee80211_freq_khz_to_channel(MHZ_TO_KHZ(freq));
  6070. }
  6071. /**
  6072. * ieee80211_get_channel_khz - get channel struct from wiphy for specified
  6073. * frequency
  6074. * @wiphy: the struct wiphy to get the channel for
  6075. * @freq: the center frequency (in KHz) of the channel
  6076. * Return: The channel struct from @wiphy at @freq.
  6077. */
  6078. struct ieee80211_channel *
  6079. ieee80211_get_channel_khz(struct wiphy *wiphy, u32 freq);
  6080. /**
  6081. * ieee80211_get_channel - get channel struct from wiphy for specified frequency
  6082. *
  6083. * @wiphy: the struct wiphy to get the channel for
  6084. * @freq: the center frequency (in MHz) of the channel
  6085. * Return: The channel struct from @wiphy at @freq.
  6086. */
  6087. static inline struct ieee80211_channel *
  6088. ieee80211_get_channel(struct wiphy *wiphy, int freq)
  6089. {
  6090. return ieee80211_get_channel_khz(wiphy, MHZ_TO_KHZ(freq));
  6091. }
  6092. /**
  6093. * cfg80211_channel_is_psc - Check if the channel is a 6 GHz PSC
  6094. * @chan: control channel to check
  6095. *
  6096. * The Preferred Scanning Channels (PSC) are defined in
  6097. * Draft IEEE P802.11ax/D5.0, 26.17.2.3.3
  6098. *
  6099. * Return: %true if channel is a PSC, %false otherwise
  6100. */
  6101. static inline bool cfg80211_channel_is_psc(struct ieee80211_channel *chan)
  6102. {
  6103. if (chan->band != NL80211_BAND_6GHZ)
  6104. return false;
  6105. return ieee80211_frequency_to_channel(chan->center_freq) % 16 == 5;
  6106. }
  6107. /**
  6108. * cfg80211_radio_chandef_valid - Check if the radio supports the chandef
  6109. *
  6110. * @radio: wiphy radio
  6111. * @chandef: chandef for current channel
  6112. *
  6113. * Return: whether or not the given chandef is valid for the given radio
  6114. */
  6115. bool cfg80211_radio_chandef_valid(const struct wiphy_radio *radio,
  6116. const struct cfg80211_chan_def *chandef);
  6117. /**
  6118. * ieee80211_get_response_rate - get basic rate for a given rate
  6119. *
  6120. * @sband: the band to look for rates in
  6121. * @basic_rates: bitmap of basic rates
  6122. * @bitrate: the bitrate for which to find the basic rate
  6123. *
  6124. * Return: The basic rate corresponding to a given bitrate, that
  6125. * is the next lower bitrate contained in the basic rate map,
  6126. * which is, for this function, given as a bitmap of indices of
  6127. * rates in the band's bitrate table.
  6128. */
  6129. const struct ieee80211_rate *
  6130. ieee80211_get_response_rate(struct ieee80211_supported_band *sband,
  6131. u32 basic_rates, int bitrate);
  6132. /**
  6133. * ieee80211_mandatory_rates - get mandatory rates for a given band
  6134. * @sband: the band to look for rates in
  6135. *
  6136. * Return: a bitmap of the mandatory rates for the given band, bits
  6137. * are set according to the rate position in the bitrates array.
  6138. */
  6139. u32 ieee80211_mandatory_rates(struct ieee80211_supported_band *sband);
  6140. /*
  6141. * Radiotap parsing functions -- for controlled injection support
  6142. *
  6143. * Implemented in net/wireless/radiotap.c
  6144. * Documentation in Documentation/networking/radiotap-headers.rst
  6145. */
  6146. struct radiotap_align_size {
  6147. uint8_t align:4, size:4;
  6148. };
  6149. struct ieee80211_radiotap_namespace {
  6150. const struct radiotap_align_size *align_size;
  6151. int n_bits;
  6152. uint32_t oui;
  6153. uint8_t subns;
  6154. };
  6155. struct ieee80211_radiotap_vendor_namespaces {
  6156. const struct ieee80211_radiotap_namespace *ns;
  6157. int n_ns;
  6158. };
  6159. /**
  6160. * struct ieee80211_radiotap_iterator - tracks walk thru present radiotap args
  6161. * @this_arg_index: index of current arg, valid after each successful call
  6162. * to ieee80211_radiotap_iterator_next()
  6163. * @this_arg: pointer to current radiotap arg; it is valid after each
  6164. * call to ieee80211_radiotap_iterator_next() but also after
  6165. * ieee80211_radiotap_iterator_init() where it will point to
  6166. * the beginning of the actual data portion
  6167. * @this_arg_size: length of the current arg, for convenience
  6168. * @current_namespace: pointer to the current namespace definition
  6169. * (or internally %NULL if the current namespace is unknown)
  6170. * @is_radiotap_ns: indicates whether the current namespace is the default
  6171. * radiotap namespace or not
  6172. *
  6173. * @_rtheader: pointer to the radiotap header we are walking through
  6174. * @_max_length: length of radiotap header in cpu byte ordering
  6175. * @_arg_index: next argument index
  6176. * @_arg: next argument pointer
  6177. * @_next_bitmap: internal pointer to next present u32
  6178. * @_bitmap_shifter: internal shifter for curr u32 bitmap, b0 set == arg present
  6179. * @_vns: vendor namespace definitions
  6180. * @_next_ns_data: beginning of the next namespace's data
  6181. * @_reset_on_ext: internal; reset the arg index to 0 when going to the
  6182. * next bitmap word
  6183. *
  6184. * Describes the radiotap parser state. Fields prefixed with an underscore
  6185. * must not be used by users of the parser, only by the parser internally.
  6186. */
  6187. struct ieee80211_radiotap_iterator {
  6188. struct ieee80211_radiotap_header *_rtheader;
  6189. const struct ieee80211_radiotap_vendor_namespaces *_vns;
  6190. const struct ieee80211_radiotap_namespace *current_namespace;
  6191. unsigned char *_arg, *_next_ns_data;
  6192. __le32 *_next_bitmap;
  6193. unsigned char *this_arg;
  6194. int this_arg_index;
  6195. int this_arg_size;
  6196. int is_radiotap_ns;
  6197. int _max_length;
  6198. int _arg_index;
  6199. uint32_t _bitmap_shifter;
  6200. int _reset_on_ext;
  6201. };
  6202. int
  6203. ieee80211_radiotap_iterator_init(struct ieee80211_radiotap_iterator *iterator,
  6204. struct ieee80211_radiotap_header *radiotap_header,
  6205. int max_length,
  6206. const struct ieee80211_radiotap_vendor_namespaces *vns);
  6207. int
  6208. ieee80211_radiotap_iterator_next(struct ieee80211_radiotap_iterator *iterator);
  6209. extern const unsigned char rfc1042_header[6];
  6210. extern const unsigned char bridge_tunnel_header[6];
  6211. /**
  6212. * ieee80211_get_hdrlen_from_skb - get header length from data
  6213. *
  6214. * @skb: the frame
  6215. *
  6216. * Given an skb with a raw 802.11 header at the data pointer this function
  6217. * returns the 802.11 header length.
  6218. *
  6219. * Return: The 802.11 header length in bytes (not including encryption
  6220. * headers). Or 0 if the data in the sk_buff is too short to contain a valid
  6221. * 802.11 header.
  6222. */
  6223. unsigned int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb);
  6224. /**
  6225. * ieee80211_hdrlen - get header length in bytes from frame control
  6226. * @fc: frame control field in little-endian format
  6227. * Return: The header length in bytes.
  6228. */
  6229. unsigned int __attribute_const__ ieee80211_hdrlen(__le16 fc);
  6230. /**
  6231. * ieee80211_get_mesh_hdrlen - get mesh extension header length
  6232. * @meshhdr: the mesh extension header, only the flags field
  6233. * (first byte) will be accessed
  6234. * Return: The length of the extension header, which is always at
  6235. * least 6 bytes and at most 18 if address 5 and 6 are present.
  6236. */
  6237. unsigned int ieee80211_get_mesh_hdrlen(struct ieee80211s_hdr *meshhdr);
  6238. /**
  6239. * DOC: Data path helpers
  6240. *
  6241. * In addition to generic utilities, cfg80211 also offers
  6242. * functions that help implement the data path for devices
  6243. * that do not do the 802.11/802.3 conversion on the device.
  6244. */
  6245. /**
  6246. * ieee80211_data_to_8023_exthdr - convert an 802.11 data frame to 802.3
  6247. * @skb: the 802.11 data frame
  6248. * @ehdr: pointer to a &struct ethhdr that will get the header, instead
  6249. * of it being pushed into the SKB
  6250. * @addr: the device MAC address
  6251. * @iftype: the virtual interface type
  6252. * @data_offset: offset of payload after the 802.11 header
  6253. * @is_amsdu: true if the 802.11 header is A-MSDU
  6254. * Return: 0 on success. Non-zero on error.
  6255. */
  6256. int ieee80211_data_to_8023_exthdr(struct sk_buff *skb, struct ethhdr *ehdr,
  6257. const u8 *addr, enum nl80211_iftype iftype,
  6258. u8 data_offset, bool is_amsdu);
  6259. /**
  6260. * ieee80211_data_to_8023 - convert an 802.11 data frame to 802.3
  6261. * @skb: the 802.11 data frame
  6262. * @addr: the device MAC address
  6263. * @iftype: the virtual interface type
  6264. * Return: 0 on success. Non-zero on error.
  6265. */
  6266. static inline int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr,
  6267. enum nl80211_iftype iftype)
  6268. {
  6269. return ieee80211_data_to_8023_exthdr(skb, NULL, addr, iftype, 0, false);
  6270. }
  6271. /**
  6272. * ieee80211_is_valid_amsdu - check if subframe lengths of an A-MSDU are valid
  6273. *
  6274. * This is used to detect non-standard A-MSDU frames, e.g. the ones generated
  6275. * by ath10k and ath11k, where the subframe length includes the length of the
  6276. * mesh control field.
  6277. *
  6278. * @skb: The input A-MSDU frame without any headers.
  6279. * @mesh_hdr: the type of mesh header to test
  6280. * 0: non-mesh A-MSDU length field
  6281. * 1: big-endian mesh A-MSDU length field
  6282. * 2: little-endian mesh A-MSDU length field
  6283. * Returns: true if subframe header lengths are valid for the @mesh_hdr mode
  6284. */
  6285. bool ieee80211_is_valid_amsdu(struct sk_buff *skb, u8 mesh_hdr);
  6286. /**
  6287. * ieee80211_amsdu_to_8023s - decode an IEEE 802.11n A-MSDU frame
  6288. *
  6289. * Decode an IEEE 802.11 A-MSDU and convert it to a list of 802.3 frames.
  6290. * The @list will be empty if the decode fails. The @skb must be fully
  6291. * header-less before being passed in here; it is freed in this function.
  6292. *
  6293. * @skb: The input A-MSDU frame without any headers.
  6294. * @list: The output list of 802.3 frames. It must be allocated and
  6295. * initialized by the caller.
  6296. * @addr: The device MAC address.
  6297. * @iftype: The device interface type.
  6298. * @extra_headroom: The hardware extra headroom for SKBs in the @list.
  6299. * @check_da: DA to check in the inner ethernet header, or NULL
  6300. * @check_sa: SA to check in the inner ethernet header, or NULL
  6301. * @mesh_control: see mesh_hdr in ieee80211_is_valid_amsdu
  6302. */
  6303. void ieee80211_amsdu_to_8023s(struct sk_buff *skb, struct sk_buff_head *list,
  6304. const u8 *addr, enum nl80211_iftype iftype,
  6305. const unsigned int extra_headroom,
  6306. const u8 *check_da, const u8 *check_sa,
  6307. u8 mesh_control);
  6308. /**
  6309. * ieee80211_get_8023_tunnel_proto - get RFC1042 or bridge tunnel encap protocol
  6310. *
  6311. * Check for RFC1042 or bridge tunnel header and fetch the encapsulated
  6312. * protocol.
  6313. *
  6314. * @hdr: pointer to the MSDU payload
  6315. * @proto: destination pointer to store the protocol
  6316. * Return: true if encapsulation was found
  6317. */
  6318. bool ieee80211_get_8023_tunnel_proto(const void *hdr, __be16 *proto);
  6319. /**
  6320. * ieee80211_strip_8023_mesh_hdr - strip mesh header from converted 802.3 frames
  6321. *
  6322. * Strip the mesh header, which was left in by ieee80211_data_to_8023 as part
  6323. * of the MSDU data. Also move any source/destination addresses from the mesh
  6324. * header to the ethernet header (if present).
  6325. *
  6326. * @skb: The 802.3 frame with embedded mesh header
  6327. *
  6328. * Return: 0 on success. Non-zero on error.
  6329. */
  6330. int ieee80211_strip_8023_mesh_hdr(struct sk_buff *skb);
  6331. /**
  6332. * cfg80211_classify8021d - determine the 802.1p/1d tag for a data frame
  6333. * @skb: the data frame
  6334. * @qos_map: Interworking QoS mapping or %NULL if not in use
  6335. * Return: The 802.1p/1d tag.
  6336. */
  6337. unsigned int cfg80211_classify8021d(struct sk_buff *skb,
  6338. struct cfg80211_qos_map *qos_map);
  6339. /**
  6340. * cfg80211_find_elem_match - match information element and byte array in data
  6341. *
  6342. * @eid: element ID
  6343. * @ies: data consisting of IEs
  6344. * @len: length of data
  6345. * @match: byte array to match
  6346. * @match_len: number of bytes in the match array
  6347. * @match_offset: offset in the IE data where the byte array should match.
  6348. * Note the difference to cfg80211_find_ie_match() which considers
  6349. * the offset to start from the element ID byte, but here we take
  6350. * the data portion instead.
  6351. *
  6352. * Return: %NULL if the element ID could not be found or if
  6353. * the element is invalid (claims to be longer than the given
  6354. * data) or if the byte array doesn't match; otherwise return the
  6355. * requested element struct.
  6356. *
  6357. * Note: There are no checks on the element length other than
  6358. * having to fit into the given data and being large enough for the
  6359. * byte array to match.
  6360. */
  6361. const struct element *
  6362. cfg80211_find_elem_match(u8 eid, const u8 *ies, unsigned int len,
  6363. const u8 *match, unsigned int match_len,
  6364. unsigned int match_offset);
  6365. /**
  6366. * cfg80211_find_ie_match - match information element and byte array in data
  6367. *
  6368. * @eid: element ID
  6369. * @ies: data consisting of IEs
  6370. * @len: length of data
  6371. * @match: byte array to match
  6372. * @match_len: number of bytes in the match array
  6373. * @match_offset: offset in the IE where the byte array should match.
  6374. * If match_len is zero, this must also be set to zero.
  6375. * Otherwise this must be set to 2 or more, because the first
  6376. * byte is the element id, which is already compared to eid, and
  6377. * the second byte is the IE length.
  6378. *
  6379. * Return: %NULL if the element ID could not be found or if
  6380. * the element is invalid (claims to be longer than the given
  6381. * data) or if the byte array doesn't match, or a pointer to the first
  6382. * byte of the requested element, that is the byte containing the
  6383. * element ID.
  6384. *
  6385. * Note: There are no checks on the element length other than
  6386. * having to fit into the given data and being large enough for the
  6387. * byte array to match.
  6388. */
  6389. static inline const u8 *
  6390. cfg80211_find_ie_match(u8 eid, const u8 *ies, unsigned int len,
  6391. const u8 *match, unsigned int match_len,
  6392. unsigned int match_offset)
  6393. {
  6394. /* match_offset can't be smaller than 2, unless match_len is
  6395. * zero, in which case match_offset must be zero as well.
  6396. */
  6397. if (WARN_ON((match_len && match_offset < 2) ||
  6398. (!match_len && match_offset)))
  6399. return NULL;
  6400. return (const void *)cfg80211_find_elem_match(eid, ies, len,
  6401. match, match_len,
  6402. match_offset ?
  6403. match_offset - 2 : 0);
  6404. }
  6405. /**
  6406. * cfg80211_find_elem - find information element in data
  6407. *
  6408. * @eid: element ID
  6409. * @ies: data consisting of IEs
  6410. * @len: length of data
  6411. *
  6412. * Return: %NULL if the element ID could not be found or if
  6413. * the element is invalid (claims to be longer than the given
  6414. * data) or if the byte array doesn't match; otherwise return the
  6415. * requested element struct.
  6416. *
  6417. * Note: There are no checks on the element length other than
  6418. * having to fit into the given data.
  6419. */
  6420. static inline const struct element *
  6421. cfg80211_find_elem(u8 eid, const u8 *ies, int len)
  6422. {
  6423. return cfg80211_find_elem_match(eid, ies, len, NULL, 0, 0);
  6424. }
  6425. /**
  6426. * cfg80211_find_ie - find information element in data
  6427. *
  6428. * @eid: element ID
  6429. * @ies: data consisting of IEs
  6430. * @len: length of data
  6431. *
  6432. * Return: %NULL if the element ID could not be found or if
  6433. * the element is invalid (claims to be longer than the given
  6434. * data), or a pointer to the first byte of the requested
  6435. * element, that is the byte containing the element ID.
  6436. *
  6437. * Note: There are no checks on the element length other than
  6438. * having to fit into the given data.
  6439. */
  6440. static inline const u8 *cfg80211_find_ie(u8 eid, const u8 *ies, int len)
  6441. {
  6442. return cfg80211_find_ie_match(eid, ies, len, NULL, 0, 0);
  6443. }
  6444. /**
  6445. * cfg80211_find_ext_elem - find information element with EID Extension in data
  6446. *
  6447. * @ext_eid: element ID Extension
  6448. * @ies: data consisting of IEs
  6449. * @len: length of data
  6450. *
  6451. * Return: %NULL if the extended element could not be found or if
  6452. * the element is invalid (claims to be longer than the given
  6453. * data) or if the byte array doesn't match; otherwise return the
  6454. * requested element struct.
  6455. *
  6456. * Note: There are no checks on the element length other than
  6457. * having to fit into the given data.
  6458. */
  6459. static inline const struct element *
  6460. cfg80211_find_ext_elem(u8 ext_eid, const u8 *ies, int len)
  6461. {
  6462. return cfg80211_find_elem_match(WLAN_EID_EXTENSION, ies, len,
  6463. &ext_eid, 1, 0);
  6464. }
  6465. /**
  6466. * cfg80211_find_ext_ie - find information element with EID Extension in data
  6467. *
  6468. * @ext_eid: element ID Extension
  6469. * @ies: data consisting of IEs
  6470. * @len: length of data
  6471. *
  6472. * Return: %NULL if the extended element ID could not be found or if
  6473. * the element is invalid (claims to be longer than the given
  6474. * data), or a pointer to the first byte of the requested
  6475. * element, that is the byte containing the element ID.
  6476. *
  6477. * Note: There are no checks on the element length other than
  6478. * having to fit into the given data.
  6479. */
  6480. static inline const u8 *cfg80211_find_ext_ie(u8 ext_eid, const u8 *ies, int len)
  6481. {
  6482. return cfg80211_find_ie_match(WLAN_EID_EXTENSION, ies, len,
  6483. &ext_eid, 1, 2);
  6484. }
  6485. /**
  6486. * cfg80211_find_vendor_elem - find vendor specific information element in data
  6487. *
  6488. * @oui: vendor OUI
  6489. * @oui_type: vendor-specific OUI type (must be < 0xff), negative means any
  6490. * @ies: data consisting of IEs
  6491. * @len: length of data
  6492. *
  6493. * Return: %NULL if the vendor specific element ID could not be found or if the
  6494. * element is invalid (claims to be longer than the given data); otherwise
  6495. * return the element structure for the requested element.
  6496. *
  6497. * Note: There are no checks on the element length other than having to fit into
  6498. * the given data.
  6499. */
  6500. const struct element *cfg80211_find_vendor_elem(unsigned int oui, int oui_type,
  6501. const u8 *ies,
  6502. unsigned int len);
  6503. /**
  6504. * cfg80211_find_vendor_ie - find vendor specific information element in data
  6505. *
  6506. * @oui: vendor OUI
  6507. * @oui_type: vendor-specific OUI type (must be < 0xff), negative means any
  6508. * @ies: data consisting of IEs
  6509. * @len: length of data
  6510. *
  6511. * Return: %NULL if the vendor specific element ID could not be found or if the
  6512. * element is invalid (claims to be longer than the given data), or a pointer to
  6513. * the first byte of the requested element, that is the byte containing the
  6514. * element ID.
  6515. *
  6516. * Note: There are no checks on the element length other than having to fit into
  6517. * the given data.
  6518. */
  6519. static inline const u8 *
  6520. cfg80211_find_vendor_ie(unsigned int oui, int oui_type,
  6521. const u8 *ies, unsigned int len)
  6522. {
  6523. return (const void *)cfg80211_find_vendor_elem(oui, oui_type, ies, len);
  6524. }
  6525. /**
  6526. * enum cfg80211_rnr_iter_ret - reduced neighbor report iteration state
  6527. * @RNR_ITER_CONTINUE: continue iterating with the next entry
  6528. * @RNR_ITER_BREAK: break iteration and return success
  6529. * @RNR_ITER_ERROR: break iteration and return error
  6530. */
  6531. enum cfg80211_rnr_iter_ret {
  6532. RNR_ITER_CONTINUE,
  6533. RNR_ITER_BREAK,
  6534. RNR_ITER_ERROR,
  6535. };
  6536. /**
  6537. * cfg80211_iter_rnr - iterate reduced neighbor report entries
  6538. * @elems: the frame elements to iterate RNR elements and then
  6539. * their entries in
  6540. * @elems_len: length of the elements
  6541. * @iter: iteration function, see also &enum cfg80211_rnr_iter_ret
  6542. * for the return value
  6543. * @iter_data: additional data passed to the iteration function
  6544. * Return: %true on success (after successfully iterating all entries
  6545. * or if the iteration function returned %RNR_ITER_BREAK),
  6546. * %false on error (iteration function returned %RNR_ITER_ERROR
  6547. * or elements were malformed.)
  6548. */
  6549. bool cfg80211_iter_rnr(const u8 *elems, size_t elems_len,
  6550. enum cfg80211_rnr_iter_ret
  6551. (*iter)(void *data, u8 type,
  6552. const struct ieee80211_neighbor_ap_info *info,
  6553. const u8 *tbtt_info, u8 tbtt_info_len),
  6554. void *iter_data);
  6555. /**
  6556. * cfg80211_defragment_element - Defrag the given element data into a buffer
  6557. *
  6558. * @elem: the element to defragment
  6559. * @ies: elements where @elem is contained
  6560. * @ieslen: length of @ies
  6561. * @data: buffer to store element data, or %NULL to just determine size
  6562. * @data_len: length of @data, or 0
  6563. * @frag_id: the element ID of fragments
  6564. *
  6565. * Return: length of @data, or -EINVAL on error
  6566. *
  6567. * Copy out all data from an element that may be fragmented into @data, while
  6568. * skipping all headers.
  6569. *
  6570. * The function uses memmove() internally. It is acceptable to defragment an
  6571. * element in-place.
  6572. */
  6573. ssize_t cfg80211_defragment_element(const struct element *elem, const u8 *ies,
  6574. size_t ieslen, u8 *data, size_t data_len,
  6575. u8 frag_id);
  6576. /**
  6577. * cfg80211_send_layer2_update - send layer 2 update frame
  6578. *
  6579. * @dev: network device
  6580. * @addr: STA MAC address
  6581. *
  6582. * Wireless drivers can use this function to update forwarding tables in bridge
  6583. * devices upon STA association.
  6584. */
  6585. void cfg80211_send_layer2_update(struct net_device *dev, const u8 *addr);
  6586. /**
  6587. * DOC: Regulatory enforcement infrastructure
  6588. *
  6589. * TODO
  6590. */
  6591. /**
  6592. * regulatory_hint - driver hint to the wireless core a regulatory domain
  6593. * @wiphy: the wireless device giving the hint (used only for reporting
  6594. * conflicts)
  6595. * @alpha2: the ISO/IEC 3166 alpha2 the driver claims its regulatory domain
  6596. * should be in. If @rd is set this should be NULL. Note that if you
  6597. * set this to NULL you should still set rd->alpha2 to some accepted
  6598. * alpha2.
  6599. *
  6600. * Wireless drivers can use this function to hint to the wireless core
  6601. * what it believes should be the current regulatory domain by
  6602. * giving it an ISO/IEC 3166 alpha2 country code it knows its regulatory
  6603. * domain should be in or by providing a completely build regulatory domain.
  6604. * If the driver provides an ISO/IEC 3166 alpha2 userspace will be queried
  6605. * for a regulatory domain structure for the respective country.
  6606. *
  6607. * The wiphy must have been registered to cfg80211 prior to this call.
  6608. * For cfg80211 drivers this means you must first use wiphy_register(),
  6609. * for mac80211 drivers you must first use ieee80211_register_hw().
  6610. *
  6611. * Drivers should check the return value, its possible you can get
  6612. * an -ENOMEM.
  6613. *
  6614. * Return: 0 on success. -ENOMEM.
  6615. */
  6616. int regulatory_hint(struct wiphy *wiphy, const char *alpha2);
  6617. /**
  6618. * regulatory_set_wiphy_regd - set regdom info for self managed drivers
  6619. * @wiphy: the wireless device we want to process the regulatory domain on
  6620. * @rd: the regulatory domain information to use for this wiphy
  6621. *
  6622. * Set the regulatory domain information for self-managed wiphys, only they
  6623. * may use this function. See %REGULATORY_WIPHY_SELF_MANAGED for more
  6624. * information.
  6625. *
  6626. * Return: 0 on success. -EINVAL, -EPERM
  6627. */
  6628. int regulatory_set_wiphy_regd(struct wiphy *wiphy,
  6629. struct ieee80211_regdomain *rd);
  6630. /**
  6631. * regulatory_set_wiphy_regd_sync - set regdom for self-managed drivers
  6632. * @wiphy: the wireless device we want to process the regulatory domain on
  6633. * @rd: the regulatory domain information to use for this wiphy
  6634. *
  6635. * This functions requires the RTNL and the wiphy mutex to be held and
  6636. * applies the new regdomain synchronously to this wiphy. For more details
  6637. * see regulatory_set_wiphy_regd().
  6638. *
  6639. * Return: 0 on success. -EINVAL, -EPERM
  6640. */
  6641. int regulatory_set_wiphy_regd_sync(struct wiphy *wiphy,
  6642. struct ieee80211_regdomain *rd);
  6643. /**
  6644. * wiphy_apply_custom_regulatory - apply a custom driver regulatory domain
  6645. * @wiphy: the wireless device we want to process the regulatory domain on
  6646. * @regd: the custom regulatory domain to use for this wiphy
  6647. *
  6648. * Drivers can sometimes have custom regulatory domains which do not apply
  6649. * to a specific country. Drivers can use this to apply such custom regulatory
  6650. * domains. This routine must be called prior to wiphy registration. The
  6651. * custom regulatory domain will be trusted completely and as such previous
  6652. * default channel settings will be disregarded. If no rule is found for a
  6653. * channel on the regulatory domain the channel will be disabled.
  6654. * Drivers using this for a wiphy should also set the wiphy flag
  6655. * REGULATORY_CUSTOM_REG or cfg80211 will set it for the wiphy
  6656. * that called this helper.
  6657. */
  6658. void wiphy_apply_custom_regulatory(struct wiphy *wiphy,
  6659. const struct ieee80211_regdomain *regd);
  6660. /**
  6661. * freq_reg_info - get regulatory information for the given frequency
  6662. * @wiphy: the wiphy for which we want to process this rule for
  6663. * @center_freq: Frequency in KHz for which we want regulatory information for
  6664. *
  6665. * Use this function to get the regulatory rule for a specific frequency on
  6666. * a given wireless device. If the device has a specific regulatory domain
  6667. * it wants to follow we respect that unless a country IE has been received
  6668. * and processed already.
  6669. *
  6670. * Return: A valid pointer, or, when an error occurs, for example if no rule
  6671. * can be found, the return value is encoded using ERR_PTR(). Use IS_ERR() to
  6672. * check and PTR_ERR() to obtain the numeric return value. The numeric return
  6673. * value will be -ERANGE if we determine the given center_freq does not even
  6674. * have a regulatory rule for a frequency range in the center_freq's band.
  6675. * See freq_in_rule_band() for our current definition of a band -- this is
  6676. * purely subjective and right now it's 802.11 specific.
  6677. */
  6678. const struct ieee80211_reg_rule *freq_reg_info(struct wiphy *wiphy,
  6679. u32 center_freq);
  6680. /**
  6681. * reg_initiator_name - map regulatory request initiator enum to name
  6682. * @initiator: the regulatory request initiator
  6683. *
  6684. * You can use this to map the regulatory request initiator enum to a
  6685. * proper string representation.
  6686. *
  6687. * Return: pointer to string representation of the initiator
  6688. */
  6689. const char *reg_initiator_name(enum nl80211_reg_initiator initiator);
  6690. /**
  6691. * regulatory_pre_cac_allowed - check if pre-CAC allowed in the current regdom
  6692. * @wiphy: wiphy for which pre-CAC capability is checked.
  6693. *
  6694. * Pre-CAC is allowed only in some regdomains (notable ETSI).
  6695. *
  6696. * Return: %true if allowed, %false otherwise
  6697. */
  6698. bool regulatory_pre_cac_allowed(struct wiphy *wiphy);
  6699. /**
  6700. * DOC: Internal regulatory db functions
  6701. *
  6702. */
  6703. /**
  6704. * reg_query_regdb_wmm - Query internal regulatory db for wmm rule
  6705. * Regulatory self-managed driver can use it to proactively
  6706. *
  6707. * @alpha2: the ISO/IEC 3166 alpha2 wmm rule to be queried.
  6708. * @freq: the frequency (in MHz) to be queried.
  6709. * @rule: pointer to store the wmm rule from the regulatory db.
  6710. *
  6711. * Self-managed wireless drivers can use this function to query
  6712. * the internal regulatory database to check whether the given
  6713. * ISO/IEC 3166 alpha2 country and freq have wmm rule limitations.
  6714. *
  6715. * Drivers should check the return value, its possible you can get
  6716. * an -ENODATA.
  6717. *
  6718. * Return: 0 on success. -ENODATA.
  6719. */
  6720. int reg_query_regdb_wmm(char *alpha2, int freq,
  6721. struct ieee80211_reg_rule *rule);
  6722. /*
  6723. * callbacks for asynchronous cfg80211 methods, notification
  6724. * functions and BSS handling helpers
  6725. */
  6726. /**
  6727. * cfg80211_scan_done - notify that scan finished
  6728. *
  6729. * @request: the corresponding scan request
  6730. * @info: information about the completed scan
  6731. */
  6732. void cfg80211_scan_done(struct cfg80211_scan_request *request,
  6733. struct cfg80211_scan_info *info);
  6734. /**
  6735. * cfg80211_sched_scan_results - notify that new scan results are available
  6736. *
  6737. * @wiphy: the wiphy which got scheduled scan results
  6738. * @reqid: identifier for the related scheduled scan request
  6739. */
  6740. void cfg80211_sched_scan_results(struct wiphy *wiphy, u64 reqid);
  6741. /**
  6742. * cfg80211_sched_scan_stopped - notify that the scheduled scan has stopped
  6743. *
  6744. * @wiphy: the wiphy on which the scheduled scan stopped
  6745. * @reqid: identifier for the related scheduled scan request
  6746. *
  6747. * The driver can call this function to inform cfg80211 that the
  6748. * scheduled scan had to be stopped, for whatever reason. The driver
  6749. * is then called back via the sched_scan_stop operation when done.
  6750. */
  6751. void cfg80211_sched_scan_stopped(struct wiphy *wiphy, u64 reqid);
  6752. /**
  6753. * cfg80211_sched_scan_stopped_locked - notify that the scheduled scan has stopped
  6754. *
  6755. * @wiphy: the wiphy on which the scheduled scan stopped
  6756. * @reqid: identifier for the related scheduled scan request
  6757. *
  6758. * The driver can call this function to inform cfg80211 that the
  6759. * scheduled scan had to be stopped, for whatever reason. The driver
  6760. * is then called back via the sched_scan_stop operation when done.
  6761. * This function should be called with the wiphy mutex held.
  6762. */
  6763. void cfg80211_sched_scan_stopped_locked(struct wiphy *wiphy, u64 reqid);
  6764. /**
  6765. * cfg80211_inform_bss_frame_data - inform cfg80211 of a received BSS frame
  6766. * @wiphy: the wiphy reporting the BSS
  6767. * @data: the BSS metadata
  6768. * @mgmt: the management frame (probe response or beacon)
  6769. * @len: length of the management frame
  6770. * @gfp: context flags
  6771. *
  6772. * This informs cfg80211 that BSS information was found and
  6773. * the BSS should be updated/added.
  6774. *
  6775. * Return: A referenced struct, must be released with cfg80211_put_bss()!
  6776. * Or %NULL on error.
  6777. */
  6778. struct cfg80211_bss * __must_check
  6779. cfg80211_inform_bss_frame_data(struct wiphy *wiphy,
  6780. struct cfg80211_inform_bss *data,
  6781. struct ieee80211_mgmt *mgmt, size_t len,
  6782. gfp_t gfp);
  6783. static inline struct cfg80211_bss * __must_check
  6784. cfg80211_inform_bss_frame(struct wiphy *wiphy,
  6785. struct ieee80211_channel *rx_channel,
  6786. struct ieee80211_mgmt *mgmt, size_t len,
  6787. s32 signal, gfp_t gfp)
  6788. {
  6789. struct cfg80211_inform_bss data = {
  6790. .chan = rx_channel,
  6791. .signal = signal,
  6792. };
  6793. return cfg80211_inform_bss_frame_data(wiphy, &data, mgmt, len, gfp);
  6794. }
  6795. /**
  6796. * cfg80211_gen_new_bssid - generate a nontransmitted BSSID for multi-BSSID
  6797. * @bssid: transmitter BSSID
  6798. * @max_bssid: max BSSID indicator, taken from Multiple BSSID element
  6799. * @mbssid_index: BSSID index, taken from Multiple BSSID index element
  6800. * @new_bssid: calculated nontransmitted BSSID
  6801. */
  6802. static inline void cfg80211_gen_new_bssid(const u8 *bssid, u8 max_bssid,
  6803. u8 mbssid_index, u8 *new_bssid)
  6804. {
  6805. u64 bssid_u64 = ether_addr_to_u64(bssid);
  6806. u64 mask = GENMASK_ULL(max_bssid - 1, 0);
  6807. u64 new_bssid_u64;
  6808. new_bssid_u64 = bssid_u64 & ~mask;
  6809. new_bssid_u64 |= ((bssid_u64 & mask) + mbssid_index) & mask;
  6810. u64_to_ether_addr(new_bssid_u64, new_bssid);
  6811. }
  6812. /**
  6813. * cfg80211_is_element_inherited - returns if element ID should be inherited
  6814. * @element: element to check
  6815. * @non_inherit_element: non inheritance element
  6816. *
  6817. * Return: %true if should be inherited, %false otherwise
  6818. */
  6819. bool cfg80211_is_element_inherited(const struct element *element,
  6820. const struct element *non_inherit_element);
  6821. /**
  6822. * cfg80211_merge_profile - merges a MBSSID profile if it is split between IEs
  6823. * @ie: ies
  6824. * @ielen: length of IEs
  6825. * @mbssid_elem: current MBSSID element
  6826. * @sub_elem: current MBSSID subelement (profile)
  6827. * @merged_ie: location of the merged profile
  6828. * @max_copy_len: max merged profile length
  6829. *
  6830. * Return: the number of bytes merged
  6831. */
  6832. size_t cfg80211_merge_profile(const u8 *ie, size_t ielen,
  6833. const struct element *mbssid_elem,
  6834. const struct element *sub_elem,
  6835. u8 *merged_ie, size_t max_copy_len);
  6836. /**
  6837. * enum cfg80211_bss_frame_type - frame type that the BSS data came from
  6838. * @CFG80211_BSS_FTYPE_UNKNOWN: driver doesn't know whether the data is
  6839. * from a beacon or probe response
  6840. * @CFG80211_BSS_FTYPE_BEACON: data comes from a beacon
  6841. * @CFG80211_BSS_FTYPE_PRESP: data comes from a probe response
  6842. * @CFG80211_BSS_FTYPE_S1G_BEACON: data comes from an S1G beacon
  6843. */
  6844. enum cfg80211_bss_frame_type {
  6845. CFG80211_BSS_FTYPE_UNKNOWN,
  6846. CFG80211_BSS_FTYPE_BEACON,
  6847. CFG80211_BSS_FTYPE_PRESP,
  6848. CFG80211_BSS_FTYPE_S1G_BEACON,
  6849. };
  6850. /**
  6851. * cfg80211_get_ies_channel_number - returns the channel number from ies
  6852. * @ie: IEs
  6853. * @ielen: length of IEs
  6854. * @band: enum nl80211_band of the channel
  6855. *
  6856. * Return: the channel number, or -1 if none could be determined.
  6857. */
  6858. int cfg80211_get_ies_channel_number(const u8 *ie, size_t ielen,
  6859. enum nl80211_band band);
  6860. /**
  6861. * cfg80211_ssid_eq - compare two SSIDs
  6862. * @a: first SSID
  6863. * @b: second SSID
  6864. *
  6865. * Return: %true if SSIDs are equal, %false otherwise.
  6866. */
  6867. static inline bool
  6868. cfg80211_ssid_eq(struct cfg80211_ssid *a, struct cfg80211_ssid *b)
  6869. {
  6870. if (WARN_ON(!a || !b))
  6871. return false;
  6872. if (a->ssid_len != b->ssid_len)
  6873. return false;
  6874. return memcmp(a->ssid, b->ssid, a->ssid_len) ? false : true;
  6875. }
  6876. /**
  6877. * cfg80211_inform_bss_data - inform cfg80211 of a new BSS
  6878. *
  6879. * @wiphy: the wiphy reporting the BSS
  6880. * @data: the BSS metadata
  6881. * @ftype: frame type (if known)
  6882. * @bssid: the BSSID of the BSS
  6883. * @tsf: the TSF sent by the peer in the beacon/probe response (or 0)
  6884. * @capability: the capability field sent by the peer
  6885. * @beacon_interval: the beacon interval announced by the peer
  6886. * @ie: additional IEs sent by the peer
  6887. * @ielen: length of the additional IEs
  6888. * @gfp: context flags
  6889. *
  6890. * This informs cfg80211 that BSS information was found and
  6891. * the BSS should be updated/added.
  6892. *
  6893. * Return: A referenced struct, must be released with cfg80211_put_bss()!
  6894. * Or %NULL on error.
  6895. */
  6896. struct cfg80211_bss * __must_check
  6897. cfg80211_inform_bss_data(struct wiphy *wiphy,
  6898. struct cfg80211_inform_bss *data,
  6899. enum cfg80211_bss_frame_type ftype,
  6900. const u8 *bssid, u64 tsf, u16 capability,
  6901. u16 beacon_interval, const u8 *ie, size_t ielen,
  6902. gfp_t gfp);
  6903. static inline struct cfg80211_bss * __must_check
  6904. cfg80211_inform_bss(struct wiphy *wiphy,
  6905. struct ieee80211_channel *rx_channel,
  6906. enum cfg80211_bss_frame_type ftype,
  6907. const u8 *bssid, u64 tsf, u16 capability,
  6908. u16 beacon_interval, const u8 *ie, size_t ielen,
  6909. s32 signal, gfp_t gfp)
  6910. {
  6911. struct cfg80211_inform_bss data = {
  6912. .chan = rx_channel,
  6913. .signal = signal,
  6914. };
  6915. return cfg80211_inform_bss_data(wiphy, &data, ftype, bssid, tsf,
  6916. capability, beacon_interval, ie, ielen,
  6917. gfp);
  6918. }
  6919. /**
  6920. * __cfg80211_get_bss - get a BSS reference
  6921. * @wiphy: the wiphy this BSS struct belongs to
  6922. * @channel: the channel to search on (or %NULL)
  6923. * @bssid: the desired BSSID (or %NULL)
  6924. * @ssid: the desired SSID (or %NULL)
  6925. * @ssid_len: length of the SSID (or 0)
  6926. * @bss_type: type of BSS, see &enum ieee80211_bss_type
  6927. * @privacy: privacy filter, see &enum ieee80211_privacy
  6928. * @use_for: indicates which use is intended
  6929. *
  6930. * Return: Reference-counted BSS on success. %NULL on error.
  6931. */
  6932. struct cfg80211_bss *__cfg80211_get_bss(struct wiphy *wiphy,
  6933. struct ieee80211_channel *channel,
  6934. const u8 *bssid,
  6935. const u8 *ssid, size_t ssid_len,
  6936. enum ieee80211_bss_type bss_type,
  6937. enum ieee80211_privacy privacy,
  6938. u32 use_for);
  6939. /**
  6940. * cfg80211_get_bss - get a BSS reference
  6941. * @wiphy: the wiphy this BSS struct belongs to
  6942. * @channel: the channel to search on (or %NULL)
  6943. * @bssid: the desired BSSID (or %NULL)
  6944. * @ssid: the desired SSID (or %NULL)
  6945. * @ssid_len: length of the SSID (or 0)
  6946. * @bss_type: type of BSS, see &enum ieee80211_bss_type
  6947. * @privacy: privacy filter, see &enum ieee80211_privacy
  6948. *
  6949. * This version implies regular usage, %NL80211_BSS_USE_FOR_NORMAL.
  6950. *
  6951. * Return: Reference-counted BSS on success. %NULL on error.
  6952. */
  6953. static inline struct cfg80211_bss *
  6954. cfg80211_get_bss(struct wiphy *wiphy, struct ieee80211_channel *channel,
  6955. const u8 *bssid, const u8 *ssid, size_t ssid_len,
  6956. enum ieee80211_bss_type bss_type,
  6957. enum ieee80211_privacy privacy)
  6958. {
  6959. return __cfg80211_get_bss(wiphy, channel, bssid, ssid, ssid_len,
  6960. bss_type, privacy,
  6961. NL80211_BSS_USE_FOR_NORMAL);
  6962. }
  6963. static inline struct cfg80211_bss *
  6964. cfg80211_get_ibss(struct wiphy *wiphy,
  6965. struct ieee80211_channel *channel,
  6966. const u8 *ssid, size_t ssid_len)
  6967. {
  6968. return cfg80211_get_bss(wiphy, channel, NULL, ssid, ssid_len,
  6969. IEEE80211_BSS_TYPE_IBSS,
  6970. IEEE80211_PRIVACY_ANY);
  6971. }
  6972. /**
  6973. * cfg80211_ref_bss - reference BSS struct
  6974. * @wiphy: the wiphy this BSS struct belongs to
  6975. * @bss: the BSS struct to reference
  6976. *
  6977. * Increments the refcount of the given BSS struct.
  6978. */
  6979. void cfg80211_ref_bss(struct wiphy *wiphy, struct cfg80211_bss *bss);
  6980. /**
  6981. * cfg80211_put_bss - unref BSS struct
  6982. * @wiphy: the wiphy this BSS struct belongs to
  6983. * @bss: the BSS struct
  6984. *
  6985. * Decrements the refcount of the given BSS struct.
  6986. */
  6987. void cfg80211_put_bss(struct wiphy *wiphy, struct cfg80211_bss *bss);
  6988. /**
  6989. * cfg80211_unlink_bss - unlink BSS from internal data structures
  6990. * @wiphy: the wiphy
  6991. * @bss: the bss to remove
  6992. *
  6993. * This function removes the given BSS from the internal data structures
  6994. * thereby making it no longer show up in scan results etc. Use this
  6995. * function when you detect a BSS is gone. Normally BSSes will also time
  6996. * out, so it is not necessary to use this function at all.
  6997. */
  6998. void cfg80211_unlink_bss(struct wiphy *wiphy, struct cfg80211_bss *bss);
  6999. /**
  7000. * cfg80211_bss_iter - iterate all BSS entries
  7001. *
  7002. * This function iterates over the BSS entries associated with the given wiphy
  7003. * and calls the callback for the iterated BSS. The iterator function is not
  7004. * allowed to call functions that might modify the internal state of the BSS DB.
  7005. *
  7006. * @wiphy: the wiphy
  7007. * @chandef: if given, the iterator function will be called only if the channel
  7008. * of the currently iterated BSS is a subset of the given channel.
  7009. * @iter: the iterator function to call
  7010. * @iter_data: an argument to the iterator function
  7011. */
  7012. void cfg80211_bss_iter(struct wiphy *wiphy,
  7013. struct cfg80211_chan_def *chandef,
  7014. void (*iter)(struct wiphy *wiphy,
  7015. struct cfg80211_bss *bss,
  7016. void *data),
  7017. void *iter_data);
  7018. /**
  7019. * cfg80211_rx_mlme_mgmt - notification of processed MLME management frame
  7020. * @dev: network device
  7021. * @buf: authentication frame (header + body)
  7022. * @len: length of the frame data
  7023. *
  7024. * This function is called whenever an authentication, disassociation or
  7025. * deauthentication frame has been received and processed in station mode.
  7026. * After being asked to authenticate via cfg80211_ops::auth() the driver must
  7027. * call either this function or cfg80211_auth_timeout().
  7028. * After being asked to associate via cfg80211_ops::assoc() the driver must
  7029. * call either this function or cfg80211_auth_timeout().
  7030. * While connected, the driver must calls this for received and processed
  7031. * disassociation and deauthentication frames. If the frame couldn't be used
  7032. * because it was unprotected, the driver must call the function
  7033. * cfg80211_rx_unprot_mlme_mgmt() instead.
  7034. *
  7035. * This function may sleep. The caller must hold the corresponding wdev's mutex.
  7036. */
  7037. void cfg80211_rx_mlme_mgmt(struct net_device *dev, const u8 *buf, size_t len);
  7038. /**
  7039. * cfg80211_auth_timeout - notification of timed out authentication
  7040. * @dev: network device
  7041. * @addr: The MAC address of the device with which the authentication timed out
  7042. *
  7043. * This function may sleep. The caller must hold the corresponding wdev's
  7044. * mutex.
  7045. */
  7046. void cfg80211_auth_timeout(struct net_device *dev, const u8 *addr);
  7047. /**
  7048. * struct cfg80211_rx_assoc_resp_data - association response data
  7049. * @buf: (Re)Association Response frame (header + body)
  7050. * @len: length of the frame data
  7051. * @uapsd_queues: bitmap of queues configured for uapsd. Same format
  7052. * as the AC bitmap in the QoS info field
  7053. * @req_ies: information elements from the (Re)Association Request frame
  7054. * @req_ies_len: length of req_ies data
  7055. * @ap_mld_addr: AP MLD address (in case of MLO)
  7056. * @links: per-link information indexed by link ID, use links[0] for
  7057. * non-MLO connections
  7058. * @links.bss: the BSS that association was requested with, ownership of the
  7059. * pointer moves to cfg80211 in the call to cfg80211_rx_assoc_resp()
  7060. * @links.status: Set this (along with a BSS pointer) for links that
  7061. * were rejected by the AP.
  7062. */
  7063. struct cfg80211_rx_assoc_resp_data {
  7064. const u8 *buf;
  7065. size_t len;
  7066. const u8 *req_ies;
  7067. size_t req_ies_len;
  7068. int uapsd_queues;
  7069. const u8 *ap_mld_addr;
  7070. struct {
  7071. u8 addr[ETH_ALEN] __aligned(2);
  7072. struct cfg80211_bss *bss;
  7073. u16 status;
  7074. } links[IEEE80211_MLD_MAX_NUM_LINKS];
  7075. };
  7076. /**
  7077. * cfg80211_rx_assoc_resp - notification of processed association response
  7078. * @dev: network device
  7079. * @data: association response data, &struct cfg80211_rx_assoc_resp_data
  7080. *
  7081. * After being asked to associate via cfg80211_ops::assoc() the driver must
  7082. * call either this function or cfg80211_auth_timeout().
  7083. *
  7084. * This function may sleep. The caller must hold the corresponding wdev's mutex.
  7085. */
  7086. void cfg80211_rx_assoc_resp(struct net_device *dev,
  7087. const struct cfg80211_rx_assoc_resp_data *data);
  7088. /**
  7089. * struct cfg80211_assoc_failure - association failure data
  7090. * @ap_mld_addr: AP MLD address, or %NULL
  7091. * @bss: list of BSSes, must use entry 0 for non-MLO connections
  7092. * (@ap_mld_addr is %NULL)
  7093. * @timeout: indicates the association failed due to timeout, otherwise
  7094. * the association was abandoned for a reason reported through some
  7095. * other API (e.g. deauth RX)
  7096. */
  7097. struct cfg80211_assoc_failure {
  7098. const u8 *ap_mld_addr;
  7099. struct cfg80211_bss *bss[IEEE80211_MLD_MAX_NUM_LINKS];
  7100. bool timeout;
  7101. };
  7102. /**
  7103. * cfg80211_assoc_failure - notification of association failure
  7104. * @dev: network device
  7105. * @data: data describing the association failure
  7106. *
  7107. * This function may sleep. The caller must hold the corresponding wdev's mutex.
  7108. */
  7109. void cfg80211_assoc_failure(struct net_device *dev,
  7110. struct cfg80211_assoc_failure *data);
  7111. /**
  7112. * cfg80211_tx_mlme_mgmt - notification of transmitted deauth/disassoc frame
  7113. * @dev: network device
  7114. * @buf: 802.11 frame (header + body)
  7115. * @len: length of the frame data
  7116. * @reconnect: immediate reconnect is desired (include the nl80211 attribute)
  7117. *
  7118. * This function is called whenever deauthentication has been processed in
  7119. * station mode. This includes both received deauthentication frames and
  7120. * locally generated ones. This function may sleep. The caller must hold the
  7121. * corresponding wdev's mutex.
  7122. */
  7123. void cfg80211_tx_mlme_mgmt(struct net_device *dev, const u8 *buf, size_t len,
  7124. bool reconnect);
  7125. /**
  7126. * cfg80211_rx_unprot_mlme_mgmt - notification of unprotected mlme mgmt frame
  7127. * @dev: network device
  7128. * @buf: received management frame (header + body)
  7129. * @len: length of the frame data
  7130. *
  7131. * This function is called whenever a received deauthentication or dissassoc
  7132. * frame has been dropped in station mode because of MFP being used but the
  7133. * frame was not protected. This is also used to notify reception of a Beacon
  7134. * frame that was dropped because it did not include a valid MME MIC while
  7135. * beacon protection was enabled (BIGTK configured in station mode).
  7136. *
  7137. * This function may sleep.
  7138. */
  7139. void cfg80211_rx_unprot_mlme_mgmt(struct net_device *dev,
  7140. const u8 *buf, size_t len);
  7141. /**
  7142. * cfg80211_michael_mic_failure - notification of Michael MIC failure (TKIP)
  7143. * @dev: network device
  7144. * @addr: The source MAC address of the frame
  7145. * @key_type: The key type that the received frame used
  7146. * @key_id: Key identifier (0..3). Can be -1 if missing.
  7147. * @tsc: The TSC value of the frame that generated the MIC failure (6 octets)
  7148. * @gfp: allocation flags
  7149. *
  7150. * This function is called whenever the local MAC detects a MIC failure in a
  7151. * received frame. This matches with MLME-MICHAELMICFAILURE.indication()
  7152. * primitive.
  7153. */
  7154. void cfg80211_michael_mic_failure(struct net_device *dev, const u8 *addr,
  7155. enum nl80211_key_type key_type, int key_id,
  7156. const u8 *tsc, gfp_t gfp);
  7157. /**
  7158. * cfg80211_ibss_joined - notify cfg80211 that device joined an IBSS
  7159. *
  7160. * @dev: network device
  7161. * @bssid: the BSSID of the IBSS joined
  7162. * @channel: the channel of the IBSS joined
  7163. * @gfp: allocation flags
  7164. *
  7165. * This function notifies cfg80211 that the device joined an IBSS or
  7166. * switched to a different BSSID. Before this function can be called,
  7167. * either a beacon has to have been received from the IBSS, or one of
  7168. * the cfg80211_inform_bss{,_frame} functions must have been called
  7169. * with the locally generated beacon -- this guarantees that there is
  7170. * always a scan result for this IBSS. cfg80211 will handle the rest.
  7171. */
  7172. void cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid,
  7173. struct ieee80211_channel *channel, gfp_t gfp);
  7174. /**
  7175. * cfg80211_notify_new_peer_candidate - notify cfg80211 of a new mesh peer
  7176. * candidate
  7177. *
  7178. * @dev: network device
  7179. * @macaddr: the MAC address of the new candidate
  7180. * @ie: information elements advertised by the peer candidate
  7181. * @ie_len: length of the information elements buffer
  7182. * @sig_dbm: signal level in dBm
  7183. * @gfp: allocation flags
  7184. *
  7185. * This function notifies cfg80211 that the mesh peer candidate has been
  7186. * detected, most likely via a beacon or, less likely, via a probe response.
  7187. * cfg80211 then sends a notification to userspace.
  7188. */
  7189. void cfg80211_notify_new_peer_candidate(struct net_device *dev,
  7190. const u8 *macaddr, const u8 *ie, u8 ie_len,
  7191. int sig_dbm, gfp_t gfp);
  7192. /**
  7193. * DOC: RFkill integration
  7194. *
  7195. * RFkill integration in cfg80211 is almost invisible to drivers,
  7196. * as cfg80211 automatically registers an rfkill instance for each
  7197. * wireless device it knows about. Soft kill is also translated
  7198. * into disconnecting and turning all interfaces off. Drivers are
  7199. * expected to turn off the device when all interfaces are down.
  7200. *
  7201. * However, devices may have a hard RFkill line, in which case they
  7202. * also need to interact with the rfkill subsystem, via cfg80211.
  7203. * They can do this with a few helper functions documented here.
  7204. */
  7205. /**
  7206. * wiphy_rfkill_set_hw_state_reason - notify cfg80211 about hw block state
  7207. * @wiphy: the wiphy
  7208. * @blocked: block status
  7209. * @reason: one of reasons in &enum rfkill_hard_block_reasons
  7210. */
  7211. void wiphy_rfkill_set_hw_state_reason(struct wiphy *wiphy, bool blocked,
  7212. enum rfkill_hard_block_reasons reason);
  7213. static inline void wiphy_rfkill_set_hw_state(struct wiphy *wiphy, bool blocked)
  7214. {
  7215. wiphy_rfkill_set_hw_state_reason(wiphy, blocked,
  7216. RFKILL_HARD_BLOCK_SIGNAL);
  7217. }
  7218. /**
  7219. * wiphy_rfkill_start_polling - start polling rfkill
  7220. * @wiphy: the wiphy
  7221. */
  7222. void wiphy_rfkill_start_polling(struct wiphy *wiphy);
  7223. /**
  7224. * wiphy_rfkill_stop_polling - stop polling rfkill
  7225. * @wiphy: the wiphy
  7226. */
  7227. static inline void wiphy_rfkill_stop_polling(struct wiphy *wiphy)
  7228. {
  7229. rfkill_pause_polling(wiphy->rfkill);
  7230. }
  7231. /**
  7232. * DOC: Vendor commands
  7233. *
  7234. * Occasionally, there are special protocol or firmware features that
  7235. * can't be implemented very openly. For this and similar cases, the
  7236. * vendor command functionality allows implementing the features with
  7237. * (typically closed-source) userspace and firmware, using nl80211 as
  7238. * the configuration mechanism.
  7239. *
  7240. * A driver supporting vendor commands must register them as an array
  7241. * in struct wiphy, with handlers for each one. Each command has an
  7242. * OUI and sub command ID to identify it.
  7243. *
  7244. * Note that this feature should not be (ab)used to implement protocol
  7245. * features that could openly be shared across drivers. In particular,
  7246. * it must never be required to use vendor commands to implement any
  7247. * "normal" functionality that higher-level userspace like connection
  7248. * managers etc. need.
  7249. */
  7250. struct sk_buff *__cfg80211_alloc_reply_skb(struct wiphy *wiphy,
  7251. enum nl80211_commands cmd,
  7252. enum nl80211_attrs attr,
  7253. int approxlen);
  7254. struct sk_buff *__cfg80211_alloc_event_skb(struct wiphy *wiphy,
  7255. struct wireless_dev *wdev,
  7256. enum nl80211_commands cmd,
  7257. enum nl80211_attrs attr,
  7258. unsigned int portid,
  7259. int vendor_event_idx,
  7260. int approxlen, gfp_t gfp);
  7261. void __cfg80211_send_event_skb(struct sk_buff *skb, gfp_t gfp);
  7262. /**
  7263. * cfg80211_vendor_cmd_alloc_reply_skb - allocate vendor command reply
  7264. * @wiphy: the wiphy
  7265. * @approxlen: an upper bound of the length of the data that will
  7266. * be put into the skb
  7267. *
  7268. * This function allocates and pre-fills an skb for a reply to
  7269. * a vendor command. Since it is intended for a reply, calling
  7270. * it outside of a vendor command's doit() operation is invalid.
  7271. *
  7272. * The returned skb is pre-filled with some identifying data in
  7273. * a way that any data that is put into the skb (with skb_put(),
  7274. * nla_put() or similar) will end up being within the
  7275. * %NL80211_ATTR_VENDOR_DATA attribute, so all that needs to be done
  7276. * with the skb is adding data for the corresponding userspace tool
  7277. * which can then read that data out of the vendor data attribute.
  7278. * You must not modify the skb in any other way.
  7279. *
  7280. * When done, call cfg80211_vendor_cmd_reply() with the skb and return
  7281. * its error code as the result of the doit() operation.
  7282. *
  7283. * Return: An allocated and pre-filled skb. %NULL if any errors happen.
  7284. */
  7285. static inline struct sk_buff *
  7286. cfg80211_vendor_cmd_alloc_reply_skb(struct wiphy *wiphy, int approxlen)
  7287. {
  7288. return __cfg80211_alloc_reply_skb(wiphy, NL80211_CMD_VENDOR,
  7289. NL80211_ATTR_VENDOR_DATA, approxlen);
  7290. }
  7291. /**
  7292. * cfg80211_vendor_cmd_reply - send the reply skb
  7293. * @skb: The skb, must have been allocated with
  7294. * cfg80211_vendor_cmd_alloc_reply_skb()
  7295. *
  7296. * Since calling this function will usually be the last thing
  7297. * before returning from the vendor command doit() you should
  7298. * return the error code. Note that this function consumes the
  7299. * skb regardless of the return value.
  7300. *
  7301. * Return: An error code or 0 on success.
  7302. */
  7303. int cfg80211_vendor_cmd_reply(struct sk_buff *skb);
  7304. /**
  7305. * cfg80211_vendor_cmd_get_sender - get the current sender netlink ID
  7306. * @wiphy: the wiphy
  7307. *
  7308. * Return: the current netlink port ID in a vendor command handler.
  7309. *
  7310. * Context: May only be called from a vendor command handler
  7311. */
  7312. unsigned int cfg80211_vendor_cmd_get_sender(struct wiphy *wiphy);
  7313. /**
  7314. * cfg80211_vendor_event_alloc - allocate vendor-specific event skb
  7315. * @wiphy: the wiphy
  7316. * @wdev: the wireless device
  7317. * @event_idx: index of the vendor event in the wiphy's vendor_events
  7318. * @approxlen: an upper bound of the length of the data that will
  7319. * be put into the skb
  7320. * @gfp: allocation flags
  7321. *
  7322. * This function allocates and pre-fills an skb for an event on the
  7323. * vendor-specific multicast group.
  7324. *
  7325. * If wdev != NULL, both the ifindex and identifier of the specified
  7326. * wireless device are added to the event message before the vendor data
  7327. * attribute.
  7328. *
  7329. * When done filling the skb, call cfg80211_vendor_event() with the
  7330. * skb to send the event.
  7331. *
  7332. * Return: An allocated and pre-filled skb. %NULL if any errors happen.
  7333. */
  7334. static inline struct sk_buff *
  7335. cfg80211_vendor_event_alloc(struct wiphy *wiphy, struct wireless_dev *wdev,
  7336. int approxlen, int event_idx, gfp_t gfp)
  7337. {
  7338. return __cfg80211_alloc_event_skb(wiphy, wdev, NL80211_CMD_VENDOR,
  7339. NL80211_ATTR_VENDOR_DATA,
  7340. 0, event_idx, approxlen, gfp);
  7341. }
  7342. /**
  7343. * cfg80211_vendor_event_alloc_ucast - alloc unicast vendor-specific event skb
  7344. * @wiphy: the wiphy
  7345. * @wdev: the wireless device
  7346. * @event_idx: index of the vendor event in the wiphy's vendor_events
  7347. * @portid: port ID of the receiver
  7348. * @approxlen: an upper bound of the length of the data that will
  7349. * be put into the skb
  7350. * @gfp: allocation flags
  7351. *
  7352. * This function allocates and pre-fills an skb for an event to send to
  7353. * a specific (userland) socket. This socket would previously have been
  7354. * obtained by cfg80211_vendor_cmd_get_sender(), and the caller MUST take
  7355. * care to register a netlink notifier to see when the socket closes.
  7356. *
  7357. * If wdev != NULL, both the ifindex and identifier of the specified
  7358. * wireless device are added to the event message before the vendor data
  7359. * attribute.
  7360. *
  7361. * When done filling the skb, call cfg80211_vendor_event() with the
  7362. * skb to send the event.
  7363. *
  7364. * Return: An allocated and pre-filled skb. %NULL if any errors happen.
  7365. */
  7366. static inline struct sk_buff *
  7367. cfg80211_vendor_event_alloc_ucast(struct wiphy *wiphy,
  7368. struct wireless_dev *wdev,
  7369. unsigned int portid, int approxlen,
  7370. int event_idx, gfp_t gfp)
  7371. {
  7372. return __cfg80211_alloc_event_skb(wiphy, wdev, NL80211_CMD_VENDOR,
  7373. NL80211_ATTR_VENDOR_DATA,
  7374. portid, event_idx, approxlen, gfp);
  7375. }
  7376. /**
  7377. * cfg80211_vendor_event - send the event
  7378. * @skb: The skb, must have been allocated with cfg80211_vendor_event_alloc()
  7379. * @gfp: allocation flags
  7380. *
  7381. * This function sends the given @skb, which must have been allocated
  7382. * by cfg80211_vendor_event_alloc(), as an event. It always consumes it.
  7383. */
  7384. static inline void cfg80211_vendor_event(struct sk_buff *skb, gfp_t gfp)
  7385. {
  7386. __cfg80211_send_event_skb(skb, gfp);
  7387. }
  7388. #ifdef CONFIG_NL80211_TESTMODE
  7389. /**
  7390. * DOC: Test mode
  7391. *
  7392. * Test mode is a set of utility functions to allow drivers to
  7393. * interact with driver-specific tools to aid, for instance,
  7394. * factory programming.
  7395. *
  7396. * This chapter describes how drivers interact with it. For more
  7397. * information see the nl80211 book's chapter on it.
  7398. */
  7399. /**
  7400. * cfg80211_testmode_alloc_reply_skb - allocate testmode reply
  7401. * @wiphy: the wiphy
  7402. * @approxlen: an upper bound of the length of the data that will
  7403. * be put into the skb
  7404. *
  7405. * This function allocates and pre-fills an skb for a reply to
  7406. * the testmode command. Since it is intended for a reply, calling
  7407. * it outside of the @testmode_cmd operation is invalid.
  7408. *
  7409. * The returned skb is pre-filled with the wiphy index and set up in
  7410. * a way that any data that is put into the skb (with skb_put(),
  7411. * nla_put() or similar) will end up being within the
  7412. * %NL80211_ATTR_TESTDATA attribute, so all that needs to be done
  7413. * with the skb is adding data for the corresponding userspace tool
  7414. * which can then read that data out of the testdata attribute. You
  7415. * must not modify the skb in any other way.
  7416. *
  7417. * When done, call cfg80211_testmode_reply() with the skb and return
  7418. * its error code as the result of the @testmode_cmd operation.
  7419. *
  7420. * Return: An allocated and pre-filled skb. %NULL if any errors happen.
  7421. */
  7422. static inline struct sk_buff *
  7423. cfg80211_testmode_alloc_reply_skb(struct wiphy *wiphy, int approxlen)
  7424. {
  7425. return __cfg80211_alloc_reply_skb(wiphy, NL80211_CMD_TESTMODE,
  7426. NL80211_ATTR_TESTDATA, approxlen);
  7427. }
  7428. /**
  7429. * cfg80211_testmode_reply - send the reply skb
  7430. * @skb: The skb, must have been allocated with
  7431. * cfg80211_testmode_alloc_reply_skb()
  7432. *
  7433. * Since calling this function will usually be the last thing
  7434. * before returning from the @testmode_cmd you should return
  7435. * the error code. Note that this function consumes the skb
  7436. * regardless of the return value.
  7437. *
  7438. * Return: An error code or 0 on success.
  7439. */
  7440. static inline int cfg80211_testmode_reply(struct sk_buff *skb)
  7441. {
  7442. return cfg80211_vendor_cmd_reply(skb);
  7443. }
  7444. /**
  7445. * cfg80211_testmode_alloc_event_skb - allocate testmode event
  7446. * @wiphy: the wiphy
  7447. * @approxlen: an upper bound of the length of the data that will
  7448. * be put into the skb
  7449. * @gfp: allocation flags
  7450. *
  7451. * This function allocates and pre-fills an skb for an event on the
  7452. * testmode multicast group.
  7453. *
  7454. * The returned skb is set up in the same way as with
  7455. * cfg80211_testmode_alloc_reply_skb() but prepared for an event. As
  7456. * there, you should simply add data to it that will then end up in the
  7457. * %NL80211_ATTR_TESTDATA attribute. Again, you must not modify the skb
  7458. * in any other way.
  7459. *
  7460. * When done filling the skb, call cfg80211_testmode_event() with the
  7461. * skb to send the event.
  7462. *
  7463. * Return: An allocated and pre-filled skb. %NULL if any errors happen.
  7464. */
  7465. static inline struct sk_buff *
  7466. cfg80211_testmode_alloc_event_skb(struct wiphy *wiphy, int approxlen, gfp_t gfp)
  7467. {
  7468. return __cfg80211_alloc_event_skb(wiphy, NULL, NL80211_CMD_TESTMODE,
  7469. NL80211_ATTR_TESTDATA, 0, -1,
  7470. approxlen, gfp);
  7471. }
  7472. /**
  7473. * cfg80211_testmode_event - send the event
  7474. * @skb: The skb, must have been allocated with
  7475. * cfg80211_testmode_alloc_event_skb()
  7476. * @gfp: allocation flags
  7477. *
  7478. * This function sends the given @skb, which must have been allocated
  7479. * by cfg80211_testmode_alloc_event_skb(), as an event. It always
  7480. * consumes it.
  7481. */
  7482. static inline void cfg80211_testmode_event(struct sk_buff *skb, gfp_t gfp)
  7483. {
  7484. __cfg80211_send_event_skb(skb, gfp);
  7485. }
  7486. #define CFG80211_TESTMODE_CMD(cmd) .testmode_cmd = (cmd),
  7487. #define CFG80211_TESTMODE_DUMP(cmd) .testmode_dump = (cmd),
  7488. #else
  7489. #define CFG80211_TESTMODE_CMD(cmd)
  7490. #define CFG80211_TESTMODE_DUMP(cmd)
  7491. #endif
  7492. /**
  7493. * struct cfg80211_fils_resp_params - FILS connection response params
  7494. * @kek: KEK derived from a successful FILS connection (may be %NULL)
  7495. * @kek_len: Length of @fils_kek in octets
  7496. * @update_erp_next_seq_num: Boolean value to specify whether the value in
  7497. * @erp_next_seq_num is valid.
  7498. * @erp_next_seq_num: The next sequence number to use in ERP message in
  7499. * FILS Authentication. This value should be specified irrespective of the
  7500. * status for a FILS connection.
  7501. * @pmk: A new PMK if derived from a successful FILS connection (may be %NULL).
  7502. * @pmk_len: Length of @pmk in octets
  7503. * @pmkid: A new PMKID if derived from a successful FILS connection or the PMKID
  7504. * used for this FILS connection (may be %NULL).
  7505. */
  7506. struct cfg80211_fils_resp_params {
  7507. const u8 *kek;
  7508. size_t kek_len;
  7509. bool update_erp_next_seq_num;
  7510. u16 erp_next_seq_num;
  7511. const u8 *pmk;
  7512. size_t pmk_len;
  7513. const u8 *pmkid;
  7514. };
  7515. /**
  7516. * struct cfg80211_connect_resp_params - Connection response params
  7517. * @status: Status code, %WLAN_STATUS_SUCCESS for successful connection, use
  7518. * %WLAN_STATUS_UNSPECIFIED_FAILURE if your device cannot give you
  7519. * the real status code for failures. If this call is used to report a
  7520. * failure due to a timeout (e.g., not receiving an Authentication frame
  7521. * from the AP) instead of an explicit rejection by the AP, -1 is used to
  7522. * indicate that this is a failure, but without a status code.
  7523. * @timeout_reason is used to report the reason for the timeout in that
  7524. * case.
  7525. * @req_ie: Association request IEs (may be %NULL)
  7526. * @req_ie_len: Association request IEs length
  7527. * @resp_ie: Association response IEs (may be %NULL)
  7528. * @resp_ie_len: Association response IEs length
  7529. * @fils: FILS connection response parameters.
  7530. * @timeout_reason: Reason for connection timeout. This is used when the
  7531. * connection fails due to a timeout instead of an explicit rejection from
  7532. * the AP. %NL80211_TIMEOUT_UNSPECIFIED is used when the timeout reason is
  7533. * not known. This value is used only if @status < 0 to indicate that the
  7534. * failure is due to a timeout and not due to explicit rejection by the AP.
  7535. * This value is ignored in other cases (@status >= 0).
  7536. * @valid_links: For MLO connection, BIT mask of the valid link ids. Otherwise
  7537. * zero.
  7538. * @ap_mld_addr: For MLO connection, MLD address of the AP. Otherwise %NULL.
  7539. * @links : For MLO connection, contains link info for the valid links indicated
  7540. * using @valid_links. For non-MLO connection, links[0] contains the
  7541. * connected AP info.
  7542. * @links.addr: For MLO connection, MAC address of the STA link. Otherwise
  7543. * %NULL.
  7544. * @links.bssid: For MLO connection, MAC address of the AP link. For non-MLO
  7545. * connection, links[0].bssid points to the BSSID of the AP (may be %NULL).
  7546. * @links.bss: For MLO connection, entry of bss to which STA link is connected.
  7547. * For non-MLO connection, links[0].bss points to entry of bss to which STA
  7548. * is connected. It can be obtained through cfg80211_get_bss() (may be
  7549. * %NULL). It is recommended to store the bss from the connect_request and
  7550. * hold a reference to it and return through this param to avoid a warning
  7551. * if the bss is expired during the connection, esp. for those drivers
  7552. * implementing connect op. Only one parameter among @bssid and @bss needs
  7553. * to be specified.
  7554. * @links.status: per-link status code, to report a status code that's not
  7555. * %WLAN_STATUS_SUCCESS for a given link, it must also be in the
  7556. * @valid_links bitmap and may have a BSS pointer (which is then released)
  7557. */
  7558. struct cfg80211_connect_resp_params {
  7559. int status;
  7560. const u8 *req_ie;
  7561. size_t req_ie_len;
  7562. const u8 *resp_ie;
  7563. size_t resp_ie_len;
  7564. struct cfg80211_fils_resp_params fils;
  7565. enum nl80211_timeout_reason timeout_reason;
  7566. const u8 *ap_mld_addr;
  7567. u16 valid_links;
  7568. struct {
  7569. const u8 *addr;
  7570. const u8 *bssid;
  7571. struct cfg80211_bss *bss;
  7572. u16 status;
  7573. } links[IEEE80211_MLD_MAX_NUM_LINKS];
  7574. };
  7575. /**
  7576. * cfg80211_connect_done - notify cfg80211 of connection result
  7577. *
  7578. * @dev: network device
  7579. * @params: connection response parameters
  7580. * @gfp: allocation flags
  7581. *
  7582. * It should be called by the underlying driver once execution of the connection
  7583. * request from connect() has been completed. This is similar to
  7584. * cfg80211_connect_bss(), but takes a structure pointer for connection response
  7585. * parameters. Only one of the functions among cfg80211_connect_bss(),
  7586. * cfg80211_connect_result(), cfg80211_connect_timeout(),
  7587. * and cfg80211_connect_done() should be called.
  7588. */
  7589. void cfg80211_connect_done(struct net_device *dev,
  7590. struct cfg80211_connect_resp_params *params,
  7591. gfp_t gfp);
  7592. /**
  7593. * cfg80211_connect_bss - notify cfg80211 of connection result
  7594. *
  7595. * @dev: network device
  7596. * @bssid: the BSSID of the AP
  7597. * @bss: Entry of bss to which STA got connected to, can be obtained through
  7598. * cfg80211_get_bss() (may be %NULL). But it is recommended to store the
  7599. * bss from the connect_request and hold a reference to it and return
  7600. * through this param to avoid a warning if the bss is expired during the
  7601. * connection, esp. for those drivers implementing connect op.
  7602. * Only one parameter among @bssid and @bss needs to be specified.
  7603. * @req_ie: association request IEs (maybe be %NULL)
  7604. * @req_ie_len: association request IEs length
  7605. * @resp_ie: association response IEs (may be %NULL)
  7606. * @resp_ie_len: assoc response IEs length
  7607. * @status: status code, %WLAN_STATUS_SUCCESS for successful connection, use
  7608. * %WLAN_STATUS_UNSPECIFIED_FAILURE if your device cannot give you
  7609. * the real status code for failures. If this call is used to report a
  7610. * failure due to a timeout (e.g., not receiving an Authentication frame
  7611. * from the AP) instead of an explicit rejection by the AP, -1 is used to
  7612. * indicate that this is a failure, but without a status code.
  7613. * @timeout_reason is used to report the reason for the timeout in that
  7614. * case.
  7615. * @gfp: allocation flags
  7616. * @timeout_reason: reason for connection timeout. This is used when the
  7617. * connection fails due to a timeout instead of an explicit rejection from
  7618. * the AP. %NL80211_TIMEOUT_UNSPECIFIED is used when the timeout reason is
  7619. * not known. This value is used only if @status < 0 to indicate that the
  7620. * failure is due to a timeout and not due to explicit rejection by the AP.
  7621. * This value is ignored in other cases (@status >= 0).
  7622. *
  7623. * It should be called by the underlying driver once execution of the connection
  7624. * request from connect() has been completed. This is similar to
  7625. * cfg80211_connect_result(), but with the option of identifying the exact bss
  7626. * entry for the connection. Only one of the functions among
  7627. * cfg80211_connect_bss(), cfg80211_connect_result(),
  7628. * cfg80211_connect_timeout(), and cfg80211_connect_done() should be called.
  7629. */
  7630. static inline void
  7631. cfg80211_connect_bss(struct net_device *dev, const u8 *bssid,
  7632. struct cfg80211_bss *bss, const u8 *req_ie,
  7633. size_t req_ie_len, const u8 *resp_ie,
  7634. size_t resp_ie_len, int status, gfp_t gfp,
  7635. enum nl80211_timeout_reason timeout_reason)
  7636. {
  7637. struct cfg80211_connect_resp_params params;
  7638. memset(&params, 0, sizeof(params));
  7639. params.status = status;
  7640. params.links[0].bssid = bssid;
  7641. params.links[0].bss = bss;
  7642. params.req_ie = req_ie;
  7643. params.req_ie_len = req_ie_len;
  7644. params.resp_ie = resp_ie;
  7645. params.resp_ie_len = resp_ie_len;
  7646. params.timeout_reason = timeout_reason;
  7647. cfg80211_connect_done(dev, &params, gfp);
  7648. }
  7649. /**
  7650. * cfg80211_connect_result - notify cfg80211 of connection result
  7651. *
  7652. * @dev: network device
  7653. * @bssid: the BSSID of the AP
  7654. * @req_ie: association request IEs (maybe be %NULL)
  7655. * @req_ie_len: association request IEs length
  7656. * @resp_ie: association response IEs (may be %NULL)
  7657. * @resp_ie_len: assoc response IEs length
  7658. * @status: status code, %WLAN_STATUS_SUCCESS for successful connection, use
  7659. * %WLAN_STATUS_UNSPECIFIED_FAILURE if your device cannot give you
  7660. * the real status code for failures.
  7661. * @gfp: allocation flags
  7662. *
  7663. * It should be called by the underlying driver once execution of the connection
  7664. * request from connect() has been completed. This is similar to
  7665. * cfg80211_connect_bss() which allows the exact bss entry to be specified. Only
  7666. * one of the functions among cfg80211_connect_bss(), cfg80211_connect_result(),
  7667. * cfg80211_connect_timeout(), and cfg80211_connect_done() should be called.
  7668. */
  7669. static inline void
  7670. cfg80211_connect_result(struct net_device *dev, const u8 *bssid,
  7671. const u8 *req_ie, size_t req_ie_len,
  7672. const u8 *resp_ie, size_t resp_ie_len,
  7673. u16 status, gfp_t gfp)
  7674. {
  7675. cfg80211_connect_bss(dev, bssid, NULL, req_ie, req_ie_len, resp_ie,
  7676. resp_ie_len, status, gfp,
  7677. NL80211_TIMEOUT_UNSPECIFIED);
  7678. }
  7679. /**
  7680. * cfg80211_connect_timeout - notify cfg80211 of connection timeout
  7681. *
  7682. * @dev: network device
  7683. * @bssid: the BSSID of the AP
  7684. * @req_ie: association request IEs (maybe be %NULL)
  7685. * @req_ie_len: association request IEs length
  7686. * @gfp: allocation flags
  7687. * @timeout_reason: reason for connection timeout.
  7688. *
  7689. * It should be called by the underlying driver whenever connect() has failed
  7690. * in a sequence where no explicit authentication/association rejection was
  7691. * received from the AP. This could happen, e.g., due to not being able to send
  7692. * out the Authentication or Association Request frame or timing out while
  7693. * waiting for the response. Only one of the functions among
  7694. * cfg80211_connect_bss(), cfg80211_connect_result(),
  7695. * cfg80211_connect_timeout(), and cfg80211_connect_done() should be called.
  7696. */
  7697. static inline void
  7698. cfg80211_connect_timeout(struct net_device *dev, const u8 *bssid,
  7699. const u8 *req_ie, size_t req_ie_len, gfp_t gfp,
  7700. enum nl80211_timeout_reason timeout_reason)
  7701. {
  7702. cfg80211_connect_bss(dev, bssid, NULL, req_ie, req_ie_len, NULL, 0, -1,
  7703. gfp, timeout_reason);
  7704. }
  7705. /**
  7706. * struct cfg80211_roam_info - driver initiated roaming information
  7707. *
  7708. * @req_ie: association request IEs (maybe be %NULL)
  7709. * @req_ie_len: association request IEs length
  7710. * @resp_ie: association response IEs (may be %NULL)
  7711. * @resp_ie_len: assoc response IEs length
  7712. * @fils: FILS related roaming information.
  7713. * @valid_links: For MLO roaming, BIT mask of the new valid links is set.
  7714. * Otherwise zero.
  7715. * @ap_mld_addr: For MLO roaming, MLD address of the new AP. Otherwise %NULL.
  7716. * @links : For MLO roaming, contains new link info for the valid links set in
  7717. * @valid_links. For non-MLO roaming, links[0] contains the new AP info.
  7718. * @links.addr: For MLO roaming, MAC address of the STA link. Otherwise %NULL.
  7719. * @links.bssid: For MLO roaming, MAC address of the new AP link. For non-MLO
  7720. * roaming, links[0].bssid points to the BSSID of the new AP. May be
  7721. * %NULL if %links.bss is set.
  7722. * @links.channel: the channel of the new AP.
  7723. * @links.bss: For MLO roaming, entry of new bss to which STA link got
  7724. * roamed. For non-MLO roaming, links[0].bss points to entry of bss to
  7725. * which STA got roamed (may be %NULL if %links.bssid is set)
  7726. */
  7727. struct cfg80211_roam_info {
  7728. const u8 *req_ie;
  7729. size_t req_ie_len;
  7730. const u8 *resp_ie;
  7731. size_t resp_ie_len;
  7732. struct cfg80211_fils_resp_params fils;
  7733. const u8 *ap_mld_addr;
  7734. u16 valid_links;
  7735. struct {
  7736. const u8 *addr;
  7737. const u8 *bssid;
  7738. struct ieee80211_channel *channel;
  7739. struct cfg80211_bss *bss;
  7740. } links[IEEE80211_MLD_MAX_NUM_LINKS];
  7741. };
  7742. /**
  7743. * cfg80211_roamed - notify cfg80211 of roaming
  7744. *
  7745. * @dev: network device
  7746. * @info: information about the new BSS. struct &cfg80211_roam_info.
  7747. * @gfp: allocation flags
  7748. *
  7749. * This function may be called with the driver passing either the BSSID of the
  7750. * new AP or passing the bss entry to avoid a race in timeout of the bss entry.
  7751. * It should be called by the underlying driver whenever it roamed from one AP
  7752. * to another while connected. Drivers which have roaming implemented in
  7753. * firmware should pass the bss entry to avoid a race in bss entry timeout where
  7754. * the bss entry of the new AP is seen in the driver, but gets timed out by the
  7755. * time it is accessed in __cfg80211_roamed() due to delay in scheduling
  7756. * rdev->event_work. In case of any failures, the reference is released
  7757. * either in cfg80211_roamed() or in __cfg80211_romed(), Otherwise, it will be
  7758. * released while disconnecting from the current bss.
  7759. */
  7760. void cfg80211_roamed(struct net_device *dev, struct cfg80211_roam_info *info,
  7761. gfp_t gfp);
  7762. /**
  7763. * cfg80211_port_authorized - notify cfg80211 of successful security association
  7764. *
  7765. * @dev: network device
  7766. * @peer_addr: BSSID of the AP/P2P GO in case of STA/GC or STA/GC MAC address
  7767. * in case of AP/P2P GO
  7768. * @td_bitmap: transition disable policy
  7769. * @td_bitmap_len: Length of transition disable policy
  7770. * @gfp: allocation flags
  7771. *
  7772. * This function should be called by a driver that supports 4 way handshake
  7773. * offload after a security association was successfully established (i.e.,
  7774. * the 4 way handshake was completed successfully). The call to this function
  7775. * should be preceded with a call to cfg80211_connect_result(),
  7776. * cfg80211_connect_done(), cfg80211_connect_bss() or cfg80211_roamed() to
  7777. * indicate the 802.11 association.
  7778. * This function can also be called by AP/P2P GO driver that supports
  7779. * authentication offload. In this case the peer_mac passed is that of
  7780. * associated STA/GC.
  7781. */
  7782. void cfg80211_port_authorized(struct net_device *dev, const u8 *peer_addr,
  7783. const u8* td_bitmap, u8 td_bitmap_len, gfp_t gfp);
  7784. /**
  7785. * cfg80211_disconnected - notify cfg80211 that connection was dropped
  7786. *
  7787. * @dev: network device
  7788. * @ie: information elements of the deauth/disassoc frame (may be %NULL)
  7789. * @ie_len: length of IEs
  7790. * @reason: reason code for the disconnection, set it to 0 if unknown
  7791. * @locally_generated: disconnection was requested locally
  7792. * @gfp: allocation flags
  7793. *
  7794. * After it calls this function, the driver should enter an idle state
  7795. * and not try to connect to any AP any more.
  7796. */
  7797. void cfg80211_disconnected(struct net_device *dev, u16 reason,
  7798. const u8 *ie, size_t ie_len,
  7799. bool locally_generated, gfp_t gfp);
  7800. /**
  7801. * cfg80211_ready_on_channel - notification of remain_on_channel start
  7802. * @wdev: wireless device
  7803. * @cookie: the request cookie
  7804. * @chan: The current channel (from remain_on_channel request)
  7805. * @duration: Duration in milliseconds that the driver intents to remain on the
  7806. * channel
  7807. * @gfp: allocation flags
  7808. */
  7809. void cfg80211_ready_on_channel(struct wireless_dev *wdev, u64 cookie,
  7810. struct ieee80211_channel *chan,
  7811. unsigned int duration, gfp_t gfp);
  7812. /**
  7813. * cfg80211_remain_on_channel_expired - remain_on_channel duration expired
  7814. * @wdev: wireless device
  7815. * @cookie: the request cookie
  7816. * @chan: The current channel (from remain_on_channel request)
  7817. * @gfp: allocation flags
  7818. */
  7819. void cfg80211_remain_on_channel_expired(struct wireless_dev *wdev, u64 cookie,
  7820. struct ieee80211_channel *chan,
  7821. gfp_t gfp);
  7822. /**
  7823. * cfg80211_tx_mgmt_expired - tx_mgmt duration expired
  7824. * @wdev: wireless device
  7825. * @cookie: the requested cookie
  7826. * @chan: The current channel (from tx_mgmt request)
  7827. * @gfp: allocation flags
  7828. */
  7829. void cfg80211_tx_mgmt_expired(struct wireless_dev *wdev, u64 cookie,
  7830. struct ieee80211_channel *chan, gfp_t gfp);
  7831. /**
  7832. * cfg80211_sinfo_alloc_tid_stats - allocate per-tid statistics.
  7833. *
  7834. * @sinfo: the station information
  7835. * @gfp: allocation flags
  7836. *
  7837. * Return: 0 on success. Non-zero on error.
  7838. */
  7839. int cfg80211_sinfo_alloc_tid_stats(struct station_info *sinfo, gfp_t gfp);
  7840. /**
  7841. * cfg80211_sinfo_release_content - release contents of station info
  7842. * @sinfo: the station information
  7843. *
  7844. * Releases any potentially allocated sub-information of the station
  7845. * information, but not the struct itself (since it's typically on
  7846. * the stack.)
  7847. */
  7848. static inline void cfg80211_sinfo_release_content(struct station_info *sinfo)
  7849. {
  7850. kfree(sinfo->pertid);
  7851. }
  7852. /**
  7853. * cfg80211_new_sta - notify userspace about station
  7854. *
  7855. * @dev: the netdev
  7856. * @mac_addr: the station's address
  7857. * @sinfo: the station information
  7858. * @gfp: allocation flags
  7859. */
  7860. void cfg80211_new_sta(struct net_device *dev, const u8 *mac_addr,
  7861. struct station_info *sinfo, gfp_t gfp);
  7862. /**
  7863. * cfg80211_del_sta_sinfo - notify userspace about deletion of a station
  7864. * @dev: the netdev
  7865. * @mac_addr: the station's address. For MLD station, MLD address is used.
  7866. * @sinfo: the station information/statistics
  7867. * @gfp: allocation flags
  7868. */
  7869. void cfg80211_del_sta_sinfo(struct net_device *dev, const u8 *mac_addr,
  7870. struct station_info *sinfo, gfp_t gfp);
  7871. /**
  7872. * cfg80211_del_sta - notify userspace about deletion of a station
  7873. *
  7874. * @dev: the netdev
  7875. * @mac_addr: the station's address. For MLD station, MLD address is used.
  7876. * @gfp: allocation flags
  7877. */
  7878. static inline void cfg80211_del_sta(struct net_device *dev,
  7879. const u8 *mac_addr, gfp_t gfp)
  7880. {
  7881. cfg80211_del_sta_sinfo(dev, mac_addr, NULL, gfp);
  7882. }
  7883. /**
  7884. * cfg80211_conn_failed - connection request failed notification
  7885. *
  7886. * @dev: the netdev
  7887. * @mac_addr: the station's address
  7888. * @reason: the reason for connection failure
  7889. * @gfp: allocation flags
  7890. *
  7891. * Whenever a station tries to connect to an AP and if the station
  7892. * could not connect to the AP as the AP has rejected the connection
  7893. * for some reasons, this function is called.
  7894. *
  7895. * The reason for connection failure can be any of the value from
  7896. * nl80211_connect_failed_reason enum
  7897. */
  7898. void cfg80211_conn_failed(struct net_device *dev, const u8 *mac_addr,
  7899. enum nl80211_connect_failed_reason reason,
  7900. gfp_t gfp);
  7901. /**
  7902. * struct cfg80211_rx_info - received management frame info
  7903. *
  7904. * @freq: Frequency on which the frame was received in kHz
  7905. * @sig_dbm: signal strength in dBm, or 0 if unknown
  7906. * @have_link_id: indicates the frame was received on a link of
  7907. * an MLD, i.e. the @link_id field is valid
  7908. * @link_id: the ID of the link the frame was received on
  7909. * @buf: Management frame (header + body)
  7910. * @len: length of the frame data
  7911. * @flags: flags, as defined in &enum nl80211_rxmgmt_flags
  7912. * @rx_tstamp: Hardware timestamp of frame RX in nanoseconds
  7913. * @ack_tstamp: Hardware timestamp of ack TX in nanoseconds
  7914. */
  7915. struct cfg80211_rx_info {
  7916. int freq;
  7917. int sig_dbm;
  7918. bool have_link_id;
  7919. u8 link_id;
  7920. const u8 *buf;
  7921. size_t len;
  7922. u32 flags;
  7923. u64 rx_tstamp;
  7924. u64 ack_tstamp;
  7925. };
  7926. /**
  7927. * cfg80211_rx_mgmt_ext - management frame notification with extended info
  7928. * @wdev: wireless device receiving the frame
  7929. * @info: RX info as defined in struct cfg80211_rx_info
  7930. *
  7931. * This function is called whenever an Action frame is received for a station
  7932. * mode interface, but is not processed in kernel.
  7933. *
  7934. * Return: %true if a user space application has registered for this frame.
  7935. * For action frames, that makes it responsible for rejecting unrecognized
  7936. * action frames; %false otherwise, in which case for action frames the
  7937. * driver is responsible for rejecting the frame.
  7938. */
  7939. bool cfg80211_rx_mgmt_ext(struct wireless_dev *wdev,
  7940. struct cfg80211_rx_info *info);
  7941. /**
  7942. * cfg80211_rx_mgmt_khz - notification of received, unprocessed management frame
  7943. * @wdev: wireless device receiving the frame
  7944. * @freq: Frequency on which the frame was received in KHz
  7945. * @sig_dbm: signal strength in dBm, or 0 if unknown
  7946. * @buf: Management frame (header + body)
  7947. * @len: length of the frame data
  7948. * @flags: flags, as defined in enum nl80211_rxmgmt_flags
  7949. *
  7950. * This function is called whenever an Action frame is received for a station
  7951. * mode interface, but is not processed in kernel.
  7952. *
  7953. * Return: %true if a user space application has registered for this frame.
  7954. * For action frames, that makes it responsible for rejecting unrecognized
  7955. * action frames; %false otherwise, in which case for action frames the
  7956. * driver is responsible for rejecting the frame.
  7957. */
  7958. static inline bool cfg80211_rx_mgmt_khz(struct wireless_dev *wdev, int freq,
  7959. int sig_dbm, const u8 *buf, size_t len,
  7960. u32 flags)
  7961. {
  7962. struct cfg80211_rx_info info = {
  7963. .freq = freq,
  7964. .sig_dbm = sig_dbm,
  7965. .buf = buf,
  7966. .len = len,
  7967. .flags = flags
  7968. };
  7969. return cfg80211_rx_mgmt_ext(wdev, &info);
  7970. }
  7971. /**
  7972. * cfg80211_rx_mgmt - notification of received, unprocessed management frame
  7973. * @wdev: wireless device receiving the frame
  7974. * @freq: Frequency on which the frame was received in MHz
  7975. * @sig_dbm: signal strength in dBm, or 0 if unknown
  7976. * @buf: Management frame (header + body)
  7977. * @len: length of the frame data
  7978. * @flags: flags, as defined in enum nl80211_rxmgmt_flags
  7979. *
  7980. * This function is called whenever an Action frame is received for a station
  7981. * mode interface, but is not processed in kernel.
  7982. *
  7983. * Return: %true if a user space application has registered for this frame.
  7984. * For action frames, that makes it responsible for rejecting unrecognized
  7985. * action frames; %false otherwise, in which case for action frames the
  7986. * driver is responsible for rejecting the frame.
  7987. */
  7988. static inline bool cfg80211_rx_mgmt(struct wireless_dev *wdev, int freq,
  7989. int sig_dbm, const u8 *buf, size_t len,
  7990. u32 flags)
  7991. {
  7992. struct cfg80211_rx_info info = {
  7993. .freq = MHZ_TO_KHZ(freq),
  7994. .sig_dbm = sig_dbm,
  7995. .buf = buf,
  7996. .len = len,
  7997. .flags = flags
  7998. };
  7999. return cfg80211_rx_mgmt_ext(wdev, &info);
  8000. }
  8001. /**
  8002. * struct cfg80211_tx_status - TX status for management frame information
  8003. *
  8004. * @cookie: Cookie returned by cfg80211_ops::mgmt_tx()
  8005. * @tx_tstamp: hardware TX timestamp in nanoseconds
  8006. * @ack_tstamp: hardware ack RX timestamp in nanoseconds
  8007. * @buf: Management frame (header + body)
  8008. * @len: length of the frame data
  8009. * @ack: Whether frame was acknowledged
  8010. */
  8011. struct cfg80211_tx_status {
  8012. u64 cookie;
  8013. u64 tx_tstamp;
  8014. u64 ack_tstamp;
  8015. const u8 *buf;
  8016. size_t len;
  8017. bool ack;
  8018. };
  8019. /**
  8020. * cfg80211_mgmt_tx_status_ext - TX status notification with extended info
  8021. * @wdev: wireless device receiving the frame
  8022. * @status: TX status data
  8023. * @gfp: context flags
  8024. *
  8025. * This function is called whenever a management frame was requested to be
  8026. * transmitted with cfg80211_ops::mgmt_tx() to report the TX status of the
  8027. * transmission attempt with extended info.
  8028. */
  8029. void cfg80211_mgmt_tx_status_ext(struct wireless_dev *wdev,
  8030. struct cfg80211_tx_status *status, gfp_t gfp);
  8031. /**
  8032. * cfg80211_mgmt_tx_status - notification of TX status for management frame
  8033. * @wdev: wireless device receiving the frame
  8034. * @cookie: Cookie returned by cfg80211_ops::mgmt_tx()
  8035. * @buf: Management frame (header + body)
  8036. * @len: length of the frame data
  8037. * @ack: Whether frame was acknowledged
  8038. * @gfp: context flags
  8039. *
  8040. * This function is called whenever a management frame was requested to be
  8041. * transmitted with cfg80211_ops::mgmt_tx() to report the TX status of the
  8042. * transmission attempt.
  8043. */
  8044. static inline void cfg80211_mgmt_tx_status(struct wireless_dev *wdev,
  8045. u64 cookie, const u8 *buf,
  8046. size_t len, bool ack, gfp_t gfp)
  8047. {
  8048. struct cfg80211_tx_status status = {
  8049. .cookie = cookie,
  8050. .buf = buf,
  8051. .len = len,
  8052. .ack = ack
  8053. };
  8054. cfg80211_mgmt_tx_status_ext(wdev, &status, gfp);
  8055. }
  8056. /**
  8057. * cfg80211_control_port_tx_status - notification of TX status for control
  8058. * port frames
  8059. * @wdev: wireless device receiving the frame
  8060. * @cookie: Cookie returned by cfg80211_ops::tx_control_port()
  8061. * @buf: Data frame (header + body)
  8062. * @len: length of the frame data
  8063. * @ack: Whether frame was acknowledged
  8064. * @gfp: context flags
  8065. *
  8066. * This function is called whenever a control port frame was requested to be
  8067. * transmitted with cfg80211_ops::tx_control_port() to report the TX status of
  8068. * the transmission attempt.
  8069. */
  8070. void cfg80211_control_port_tx_status(struct wireless_dev *wdev, u64 cookie,
  8071. const u8 *buf, size_t len, bool ack,
  8072. gfp_t gfp);
  8073. /**
  8074. * cfg80211_rx_control_port - notification about a received control port frame
  8075. * @dev: The device the frame matched to
  8076. * @skb: The skbuf with the control port frame. It is assumed that the skbuf
  8077. * is 802.3 formatted (with 802.3 header). The skb can be non-linear.
  8078. * This function does not take ownership of the skb, so the caller is
  8079. * responsible for any cleanup. The caller must also ensure that
  8080. * skb->protocol is set appropriately.
  8081. * @unencrypted: Whether the frame was received unencrypted
  8082. * @link_id: the link the frame was received on, -1 if not applicable or unknown
  8083. *
  8084. * This function is used to inform userspace about a received control port
  8085. * frame. It should only be used if userspace indicated it wants to receive
  8086. * control port frames over nl80211.
  8087. *
  8088. * The frame is the data portion of the 802.3 or 802.11 data frame with all
  8089. * network layer headers removed (e.g. the raw EAPoL frame).
  8090. *
  8091. * Return: %true if the frame was passed to userspace
  8092. */
  8093. bool cfg80211_rx_control_port(struct net_device *dev, struct sk_buff *skb,
  8094. bool unencrypted, int link_id);
  8095. /**
  8096. * cfg80211_cqm_rssi_notify - connection quality monitoring rssi event
  8097. * @dev: network device
  8098. * @rssi_event: the triggered RSSI event
  8099. * @rssi_level: new RSSI level value or 0 if not available
  8100. * @gfp: context flags
  8101. *
  8102. * This function is called when a configured connection quality monitoring
  8103. * rssi threshold reached event occurs.
  8104. */
  8105. void cfg80211_cqm_rssi_notify(struct net_device *dev,
  8106. enum nl80211_cqm_rssi_threshold_event rssi_event,
  8107. s32 rssi_level, gfp_t gfp);
  8108. /**
  8109. * cfg80211_cqm_pktloss_notify - notify userspace about packetloss to peer
  8110. * @dev: network device
  8111. * @peer: peer's MAC address
  8112. * @num_packets: how many packets were lost -- should be a fixed threshold
  8113. * but probably no less than maybe 50, or maybe a throughput dependent
  8114. * threshold (to account for temporary interference)
  8115. * @gfp: context flags
  8116. */
  8117. void cfg80211_cqm_pktloss_notify(struct net_device *dev,
  8118. const u8 *peer, u32 num_packets, gfp_t gfp);
  8119. /**
  8120. * cfg80211_cqm_txe_notify - TX error rate event
  8121. * @dev: network device
  8122. * @peer: peer's MAC address
  8123. * @num_packets: how many packets were lost
  8124. * @rate: % of packets which failed transmission
  8125. * @intvl: interval (in s) over which the TX failure threshold was breached.
  8126. * @gfp: context flags
  8127. *
  8128. * Notify userspace when configured % TX failures over number of packets in a
  8129. * given interval is exceeded.
  8130. */
  8131. void cfg80211_cqm_txe_notify(struct net_device *dev, const u8 *peer,
  8132. u32 num_packets, u32 rate, u32 intvl, gfp_t gfp);
  8133. /**
  8134. * cfg80211_cqm_beacon_loss_notify - beacon loss event
  8135. * @dev: network device
  8136. * @gfp: context flags
  8137. *
  8138. * Notify userspace about beacon loss from the connected AP.
  8139. */
  8140. void cfg80211_cqm_beacon_loss_notify(struct net_device *dev, gfp_t gfp);
  8141. /**
  8142. * __cfg80211_radar_event - radar detection event
  8143. * @wiphy: the wiphy
  8144. * @chandef: chandef for the current channel
  8145. * @offchan: the radar has been detected on the offchannel chain
  8146. * @gfp: context flags
  8147. *
  8148. * This function is called when a radar is detected on the current chanenl.
  8149. */
  8150. void __cfg80211_radar_event(struct wiphy *wiphy,
  8151. struct cfg80211_chan_def *chandef,
  8152. bool offchan, gfp_t gfp);
  8153. static inline void
  8154. cfg80211_radar_event(struct wiphy *wiphy,
  8155. struct cfg80211_chan_def *chandef,
  8156. gfp_t gfp)
  8157. {
  8158. __cfg80211_radar_event(wiphy, chandef, false, gfp);
  8159. }
  8160. static inline void
  8161. cfg80211_background_radar_event(struct wiphy *wiphy,
  8162. struct cfg80211_chan_def *chandef,
  8163. gfp_t gfp)
  8164. {
  8165. __cfg80211_radar_event(wiphy, chandef, true, gfp);
  8166. }
  8167. /**
  8168. * cfg80211_sta_opmode_change_notify - STA's ht/vht operation mode change event
  8169. * @dev: network device
  8170. * @mac: MAC address of a station which opmode got modified
  8171. * @sta_opmode: station's current opmode value
  8172. * @gfp: context flags
  8173. *
  8174. * Driver should call this function when station's opmode modified via action
  8175. * frame.
  8176. */
  8177. void cfg80211_sta_opmode_change_notify(struct net_device *dev, const u8 *mac,
  8178. struct sta_opmode_info *sta_opmode,
  8179. gfp_t gfp);
  8180. /**
  8181. * cfg80211_cac_event - Channel availability check (CAC) event
  8182. * @netdev: network device
  8183. * @chandef: chandef for the current channel
  8184. * @event: type of event
  8185. * @gfp: context flags
  8186. * @link_id: valid link_id for MLO operation or 0 otherwise.
  8187. *
  8188. * This function is called when a Channel availability check (CAC) is finished
  8189. * or aborted. This must be called to notify the completion of a CAC process,
  8190. * also by full-MAC drivers.
  8191. */
  8192. void cfg80211_cac_event(struct net_device *netdev,
  8193. const struct cfg80211_chan_def *chandef,
  8194. enum nl80211_radar_event event, gfp_t gfp,
  8195. unsigned int link_id);
  8196. /**
  8197. * cfg80211_background_cac_abort - Channel Availability Check offchan abort event
  8198. * @wiphy: the wiphy
  8199. *
  8200. * This function is called by the driver when a Channel Availability Check
  8201. * (CAC) is aborted by a offchannel dedicated chain.
  8202. */
  8203. void cfg80211_background_cac_abort(struct wiphy *wiphy);
  8204. /**
  8205. * cfg80211_gtk_rekey_notify - notify userspace about driver rekeying
  8206. * @dev: network device
  8207. * @bssid: BSSID of AP (to avoid races)
  8208. * @replay_ctr: new replay counter
  8209. * @gfp: allocation flags
  8210. */
  8211. void cfg80211_gtk_rekey_notify(struct net_device *dev, const u8 *bssid,
  8212. const u8 *replay_ctr, gfp_t gfp);
  8213. /**
  8214. * cfg80211_pmksa_candidate_notify - notify about PMKSA caching candidate
  8215. * @dev: network device
  8216. * @index: candidate index (the smaller the index, the higher the priority)
  8217. * @bssid: BSSID of AP
  8218. * @preauth: Whether AP advertises support for RSN pre-authentication
  8219. * @gfp: allocation flags
  8220. */
  8221. void cfg80211_pmksa_candidate_notify(struct net_device *dev, int index,
  8222. const u8 *bssid, bool preauth, gfp_t gfp);
  8223. /**
  8224. * cfg80211_rx_spurious_frame - inform userspace about a spurious frame
  8225. * @dev: The device the frame matched to
  8226. * @addr: the transmitter address
  8227. * @gfp: context flags
  8228. *
  8229. * This function is used in AP mode (only!) to inform userspace that
  8230. * a spurious class 3 frame was received, to be able to deauth the
  8231. * sender.
  8232. * Return: %true if the frame was passed to userspace (or this failed
  8233. * for a reason other than not having a subscription.)
  8234. */
  8235. bool cfg80211_rx_spurious_frame(struct net_device *dev,
  8236. const u8 *addr, gfp_t gfp);
  8237. /**
  8238. * cfg80211_rx_unexpected_4addr_frame - inform about unexpected WDS frame
  8239. * @dev: The device the frame matched to
  8240. * @addr: the transmitter address
  8241. * @gfp: context flags
  8242. *
  8243. * This function is used in AP mode (only!) to inform userspace that
  8244. * an associated station sent a 4addr frame but that wasn't expected.
  8245. * It is allowed and desirable to send this event only once for each
  8246. * station to avoid event flooding.
  8247. * Return: %true if the frame was passed to userspace (or this failed
  8248. * for a reason other than not having a subscription.)
  8249. */
  8250. bool cfg80211_rx_unexpected_4addr_frame(struct net_device *dev,
  8251. const u8 *addr, gfp_t gfp);
  8252. /**
  8253. * cfg80211_probe_status - notify userspace about probe status
  8254. * @dev: the device the probe was sent on
  8255. * @addr: the address of the peer
  8256. * @cookie: the cookie filled in @probe_client previously
  8257. * @acked: indicates whether probe was acked or not
  8258. * @ack_signal: signal strength (in dBm) of the ACK frame.
  8259. * @is_valid_ack_signal: indicates the ack_signal is valid or not.
  8260. * @gfp: allocation flags
  8261. */
  8262. void cfg80211_probe_status(struct net_device *dev, const u8 *addr,
  8263. u64 cookie, bool acked, s32 ack_signal,
  8264. bool is_valid_ack_signal, gfp_t gfp);
  8265. /**
  8266. * cfg80211_report_obss_beacon_khz - report beacon from other APs
  8267. * @wiphy: The wiphy that received the beacon
  8268. * @frame: the frame
  8269. * @len: length of the frame
  8270. * @freq: frequency the frame was received on in KHz
  8271. * @sig_dbm: signal strength in dBm, or 0 if unknown
  8272. *
  8273. * Use this function to report to userspace when a beacon was
  8274. * received. It is not useful to call this when there is no
  8275. * netdev that is in AP/GO mode.
  8276. */
  8277. void cfg80211_report_obss_beacon_khz(struct wiphy *wiphy, const u8 *frame,
  8278. size_t len, int freq, int sig_dbm);
  8279. /**
  8280. * cfg80211_report_obss_beacon - report beacon from other APs
  8281. * @wiphy: The wiphy that received the beacon
  8282. * @frame: the frame
  8283. * @len: length of the frame
  8284. * @freq: frequency the frame was received on
  8285. * @sig_dbm: signal strength in dBm, or 0 if unknown
  8286. *
  8287. * Use this function to report to userspace when a beacon was
  8288. * received. It is not useful to call this when there is no
  8289. * netdev that is in AP/GO mode.
  8290. */
  8291. static inline void cfg80211_report_obss_beacon(struct wiphy *wiphy,
  8292. const u8 *frame, size_t len,
  8293. int freq, int sig_dbm)
  8294. {
  8295. cfg80211_report_obss_beacon_khz(wiphy, frame, len, MHZ_TO_KHZ(freq),
  8296. sig_dbm);
  8297. }
  8298. /**
  8299. * struct cfg80211_beaconing_check_config - beacon check configuration
  8300. * @iftype: the interface type to check for
  8301. * @relax: allow IR-relaxation conditions to apply (e.g. another
  8302. * interface connected already on the same channel)
  8303. * NOTE: If this is set, wiphy mutex must be held.
  8304. * @reg_power: &enum ieee80211_ap_reg_power value indicating the
  8305. * advertised/used 6 GHz regulatory power setting
  8306. */
  8307. struct cfg80211_beaconing_check_config {
  8308. enum nl80211_iftype iftype;
  8309. enum ieee80211_ap_reg_power reg_power;
  8310. bool relax;
  8311. };
  8312. /**
  8313. * cfg80211_reg_check_beaconing - check if beaconing is allowed
  8314. * @wiphy: the wiphy
  8315. * @chandef: the channel definition
  8316. * @cfg: additional parameters for the checking
  8317. *
  8318. * Return: %true if there is no secondary channel or the secondary channel(s)
  8319. * can be used for beaconing (i.e. is not a radar channel etc.)
  8320. */
  8321. bool cfg80211_reg_check_beaconing(struct wiphy *wiphy,
  8322. struct cfg80211_chan_def *chandef,
  8323. struct cfg80211_beaconing_check_config *cfg);
  8324. /**
  8325. * cfg80211_reg_can_beacon - check if beaconing is allowed
  8326. * @wiphy: the wiphy
  8327. * @chandef: the channel definition
  8328. * @iftype: interface type
  8329. *
  8330. * Return: %true if there is no secondary channel or the secondary channel(s)
  8331. * can be used for beaconing (i.e. is not a radar channel etc.)
  8332. */
  8333. static inline bool
  8334. cfg80211_reg_can_beacon(struct wiphy *wiphy,
  8335. struct cfg80211_chan_def *chandef,
  8336. enum nl80211_iftype iftype)
  8337. {
  8338. struct cfg80211_beaconing_check_config config = {
  8339. .iftype = iftype,
  8340. };
  8341. return cfg80211_reg_check_beaconing(wiphy, chandef, &config);
  8342. }
  8343. /**
  8344. * cfg80211_reg_can_beacon_relax - check if beaconing is allowed with relaxation
  8345. * @wiphy: the wiphy
  8346. * @chandef: the channel definition
  8347. * @iftype: interface type
  8348. *
  8349. * Return: %true if there is no secondary channel or the secondary channel(s)
  8350. * can be used for beaconing (i.e. is not a radar channel etc.). This version
  8351. * also checks if IR-relaxation conditions apply, to allow beaconing under
  8352. * more permissive conditions.
  8353. *
  8354. * Context: Requires the wiphy mutex to be held.
  8355. */
  8356. static inline bool
  8357. cfg80211_reg_can_beacon_relax(struct wiphy *wiphy,
  8358. struct cfg80211_chan_def *chandef,
  8359. enum nl80211_iftype iftype)
  8360. {
  8361. struct cfg80211_beaconing_check_config config = {
  8362. .iftype = iftype,
  8363. .relax = true,
  8364. };
  8365. return cfg80211_reg_check_beaconing(wiphy, chandef, &config);
  8366. }
  8367. /**
  8368. * cfg80211_ch_switch_notify - update wdev channel and notify userspace
  8369. * @dev: the device which switched channels
  8370. * @chandef: the new channel definition
  8371. * @link_id: the link ID for MLO, must be 0 for non-MLO
  8372. *
  8373. * Caller must hold wiphy mutex, therefore must only be called from sleepable
  8374. * driver context!
  8375. */
  8376. void cfg80211_ch_switch_notify(struct net_device *dev,
  8377. struct cfg80211_chan_def *chandef,
  8378. unsigned int link_id);
  8379. /**
  8380. * cfg80211_ch_switch_started_notify - notify channel switch start
  8381. * @dev: the device on which the channel switch started
  8382. * @chandef: the future channel definition
  8383. * @link_id: the link ID for MLO, must be 0 for non-MLO
  8384. * @count: the number of TBTTs until the channel switch happens
  8385. * @quiet: whether or not immediate quiet was requested by the AP
  8386. *
  8387. * Inform the userspace about the channel switch that has just
  8388. * started, so that it can take appropriate actions (eg. starting
  8389. * channel switch on other vifs), if necessary.
  8390. */
  8391. void cfg80211_ch_switch_started_notify(struct net_device *dev,
  8392. struct cfg80211_chan_def *chandef,
  8393. unsigned int link_id, u8 count,
  8394. bool quiet);
  8395. /**
  8396. * ieee80211_operating_class_to_band - convert operating class to band
  8397. *
  8398. * @operating_class: the operating class to convert
  8399. * @band: band pointer to fill
  8400. *
  8401. * Return: %true if the conversion was successful, %false otherwise.
  8402. */
  8403. bool ieee80211_operating_class_to_band(u8 operating_class,
  8404. enum nl80211_band *band);
  8405. /**
  8406. * ieee80211_operating_class_to_chandef - convert operating class to chandef
  8407. *
  8408. * @operating_class: the operating class to convert
  8409. * @chan: the ieee80211_channel to convert
  8410. * @chandef: a pointer to the resulting chandef
  8411. *
  8412. * Return: %true if the conversion was successful, %false otherwise.
  8413. */
  8414. bool ieee80211_operating_class_to_chandef(u8 operating_class,
  8415. struct ieee80211_channel *chan,
  8416. struct cfg80211_chan_def *chandef);
  8417. /**
  8418. * ieee80211_chandef_to_operating_class - convert chandef to operation class
  8419. *
  8420. * @chandef: the chandef to convert
  8421. * @op_class: a pointer to the resulting operating class
  8422. *
  8423. * Return: %true if the conversion was successful, %false otherwise.
  8424. */
  8425. bool ieee80211_chandef_to_operating_class(struct cfg80211_chan_def *chandef,
  8426. u8 *op_class);
  8427. /**
  8428. * ieee80211_chandef_to_khz - convert chandef to frequency in KHz
  8429. *
  8430. * @chandef: the chandef to convert
  8431. *
  8432. * Return: the center frequency of chandef (1st segment) in KHz.
  8433. */
  8434. static inline u32
  8435. ieee80211_chandef_to_khz(const struct cfg80211_chan_def *chandef)
  8436. {
  8437. return MHZ_TO_KHZ(chandef->center_freq1) + chandef->freq1_offset;
  8438. }
  8439. /**
  8440. * cfg80211_tdls_oper_request - request userspace to perform TDLS operation
  8441. * @dev: the device on which the operation is requested
  8442. * @peer: the MAC address of the peer device
  8443. * @oper: the requested TDLS operation (NL80211_TDLS_SETUP or
  8444. * NL80211_TDLS_TEARDOWN)
  8445. * @reason_code: the reason code for teardown request
  8446. * @gfp: allocation flags
  8447. *
  8448. * This function is used to request userspace to perform TDLS operation that
  8449. * requires knowledge of keys, i.e., link setup or teardown when the AP
  8450. * connection uses encryption. This is optional mechanism for the driver to use
  8451. * if it can automatically determine when a TDLS link could be useful (e.g.,
  8452. * based on traffic and signal strength for a peer).
  8453. */
  8454. void cfg80211_tdls_oper_request(struct net_device *dev, const u8 *peer,
  8455. enum nl80211_tdls_operation oper,
  8456. u16 reason_code, gfp_t gfp);
  8457. /**
  8458. * cfg80211_calculate_bitrate - calculate actual bitrate (in 100Kbps units)
  8459. * @rate: given rate_info to calculate bitrate from
  8460. *
  8461. * Return: calculated bitrate
  8462. */
  8463. u32 cfg80211_calculate_bitrate(struct rate_info *rate);
  8464. /**
  8465. * cfg80211_unregister_wdev - remove the given wdev
  8466. * @wdev: struct wireless_dev to remove
  8467. *
  8468. * This function removes the device so it can no longer be used. It is necessary
  8469. * to call this function even when cfg80211 requests the removal of the device
  8470. * by calling the del_virtual_intf() callback. The function must also be called
  8471. * when the driver wishes to unregister the wdev, e.g. when the hardware device
  8472. * is unbound from the driver.
  8473. *
  8474. * Context: Requires the RTNL and wiphy mutex to be held.
  8475. */
  8476. void cfg80211_unregister_wdev(struct wireless_dev *wdev);
  8477. /**
  8478. * cfg80211_register_netdevice - register the given netdev
  8479. * @dev: the netdev to register
  8480. *
  8481. * Note: In contexts coming from cfg80211 callbacks, you must call this rather
  8482. * than register_netdevice(), unregister_netdev() is impossible as the RTNL is
  8483. * held. Otherwise, both register_netdevice() and register_netdev() are usable
  8484. * instead as well.
  8485. *
  8486. * Context: Requires the RTNL and wiphy mutex to be held.
  8487. *
  8488. * Return: 0 on success. Non-zero on error.
  8489. */
  8490. int cfg80211_register_netdevice(struct net_device *dev);
  8491. /**
  8492. * cfg80211_unregister_netdevice - unregister the given netdev
  8493. * @dev: the netdev to register
  8494. *
  8495. * Note: In contexts coming from cfg80211 callbacks, you must call this rather
  8496. * than unregister_netdevice(), unregister_netdev() is impossible as the RTNL
  8497. * is held. Otherwise, both unregister_netdevice() and unregister_netdev() are
  8498. * usable instead as well.
  8499. *
  8500. * Context: Requires the RTNL and wiphy mutex to be held.
  8501. */
  8502. static inline void cfg80211_unregister_netdevice(struct net_device *dev)
  8503. {
  8504. #if IS_ENABLED(CONFIG_CFG80211)
  8505. cfg80211_unregister_wdev(dev->ieee80211_ptr);
  8506. #endif
  8507. }
  8508. /**
  8509. * struct cfg80211_ft_event_params - FT Information Elements
  8510. * @ies: FT IEs
  8511. * @ies_len: length of the FT IE in bytes
  8512. * @target_ap: target AP's MAC address
  8513. * @ric_ies: RIC IE
  8514. * @ric_ies_len: length of the RIC IE in bytes
  8515. */
  8516. struct cfg80211_ft_event_params {
  8517. const u8 *ies;
  8518. size_t ies_len;
  8519. const u8 *target_ap;
  8520. const u8 *ric_ies;
  8521. size_t ric_ies_len;
  8522. };
  8523. /**
  8524. * cfg80211_ft_event - notify userspace about FT IE and RIC IE
  8525. * @netdev: network device
  8526. * @ft_event: IE information
  8527. */
  8528. void cfg80211_ft_event(struct net_device *netdev,
  8529. struct cfg80211_ft_event_params *ft_event);
  8530. /**
  8531. * cfg80211_get_p2p_attr - find and copy a P2P attribute from IE buffer
  8532. * @ies: the input IE buffer
  8533. * @len: the input length
  8534. * @attr: the attribute ID to find
  8535. * @buf: output buffer, can be %NULL if the data isn't needed, e.g.
  8536. * if the function is only called to get the needed buffer size
  8537. * @bufsize: size of the output buffer
  8538. *
  8539. * The function finds a given P2P attribute in the (vendor) IEs and
  8540. * copies its contents to the given buffer.
  8541. *
  8542. * Return: A negative error code (-%EILSEQ or -%ENOENT) if the data is
  8543. * malformed or the attribute can't be found (respectively), or the
  8544. * length of the found attribute (which can be zero).
  8545. */
  8546. int cfg80211_get_p2p_attr(const u8 *ies, unsigned int len,
  8547. enum ieee80211_p2p_attr_id attr,
  8548. u8 *buf, unsigned int bufsize);
  8549. /**
  8550. * ieee80211_ie_split_ric - split an IE buffer according to ordering (with RIC)
  8551. * @ies: the IE buffer
  8552. * @ielen: the length of the IE buffer
  8553. * @ids: an array with element IDs that are allowed before
  8554. * the split. A WLAN_EID_EXTENSION value means that the next
  8555. * EID in the list is a sub-element of the EXTENSION IE.
  8556. * @n_ids: the size of the element ID array
  8557. * @after_ric: array IE types that come after the RIC element
  8558. * @n_after_ric: size of the @after_ric array
  8559. * @offset: offset where to start splitting in the buffer
  8560. *
  8561. * This function splits an IE buffer by updating the @offset
  8562. * variable to point to the location where the buffer should be
  8563. * split.
  8564. *
  8565. * It assumes that the given IE buffer is well-formed, this
  8566. * has to be guaranteed by the caller!
  8567. *
  8568. * It also assumes that the IEs in the buffer are ordered
  8569. * correctly, if not the result of using this function will not
  8570. * be ordered correctly either, i.e. it does no reordering.
  8571. *
  8572. * Return: The offset where the next part of the buffer starts, which
  8573. * may be @ielen if the entire (remainder) of the buffer should be
  8574. * used.
  8575. */
  8576. size_t ieee80211_ie_split_ric(const u8 *ies, size_t ielen,
  8577. const u8 *ids, int n_ids,
  8578. const u8 *after_ric, int n_after_ric,
  8579. size_t offset);
  8580. /**
  8581. * ieee80211_ie_split - split an IE buffer according to ordering
  8582. * @ies: the IE buffer
  8583. * @ielen: the length of the IE buffer
  8584. * @ids: an array with element IDs that are allowed before
  8585. * the split. A WLAN_EID_EXTENSION value means that the next
  8586. * EID in the list is a sub-element of the EXTENSION IE.
  8587. * @n_ids: the size of the element ID array
  8588. * @offset: offset where to start splitting in the buffer
  8589. *
  8590. * This function splits an IE buffer by updating the @offset
  8591. * variable to point to the location where the buffer should be
  8592. * split.
  8593. *
  8594. * It assumes that the given IE buffer is well-formed, this
  8595. * has to be guaranteed by the caller!
  8596. *
  8597. * It also assumes that the IEs in the buffer are ordered
  8598. * correctly, if not the result of using this function will not
  8599. * be ordered correctly either, i.e. it does no reordering.
  8600. *
  8601. * Return: The offset where the next part of the buffer starts, which
  8602. * may be @ielen if the entire (remainder) of the buffer should be
  8603. * used.
  8604. */
  8605. static inline size_t ieee80211_ie_split(const u8 *ies, size_t ielen,
  8606. const u8 *ids, int n_ids, size_t offset)
  8607. {
  8608. return ieee80211_ie_split_ric(ies, ielen, ids, n_ids, NULL, 0, offset);
  8609. }
  8610. /**
  8611. * ieee80211_fragment_element - fragment the last element in skb
  8612. * @skb: The skbuf that the element was added to
  8613. * @len_pos: Pointer to length of the element to fragment
  8614. * @frag_id: The element ID to use for fragments
  8615. *
  8616. * This function fragments all data after @len_pos, adding fragmentation
  8617. * elements with the given ID as appropriate. The SKB will grow in size
  8618. * accordingly.
  8619. */
  8620. void ieee80211_fragment_element(struct sk_buff *skb, u8 *len_pos, u8 frag_id);
  8621. /**
  8622. * cfg80211_report_wowlan_wakeup - report wakeup from WoWLAN
  8623. * @wdev: the wireless device reporting the wakeup
  8624. * @wakeup: the wakeup report
  8625. * @gfp: allocation flags
  8626. *
  8627. * This function reports that the given device woke up. If it
  8628. * caused the wakeup, report the reason(s), otherwise you may
  8629. * pass %NULL as the @wakeup parameter to advertise that something
  8630. * else caused the wakeup.
  8631. */
  8632. void cfg80211_report_wowlan_wakeup(struct wireless_dev *wdev,
  8633. struct cfg80211_wowlan_wakeup *wakeup,
  8634. gfp_t gfp);
  8635. /**
  8636. * cfg80211_crit_proto_stopped() - indicate critical protocol stopped by driver.
  8637. *
  8638. * @wdev: the wireless device for which critical protocol is stopped.
  8639. * @gfp: allocation flags
  8640. *
  8641. * This function can be called by the driver to indicate it has reverted
  8642. * operation back to normal. One reason could be that the duration given
  8643. * by .crit_proto_start() has expired.
  8644. */
  8645. void cfg80211_crit_proto_stopped(struct wireless_dev *wdev, gfp_t gfp);
  8646. /**
  8647. * ieee80211_get_num_supported_channels - get number of channels device has
  8648. * @wiphy: the wiphy
  8649. *
  8650. * Return: the number of channels supported by the device.
  8651. */
  8652. unsigned int ieee80211_get_num_supported_channels(struct wiphy *wiphy);
  8653. /**
  8654. * cfg80211_check_combinations - check interface combinations
  8655. *
  8656. * @wiphy: the wiphy
  8657. * @params: the interface combinations parameter
  8658. *
  8659. * This function can be called by the driver to check whether a
  8660. * combination of interfaces and their types are allowed according to
  8661. * the interface combinations.
  8662. *
  8663. * Return: 0 if combinations are allowed. Non-zero on error.
  8664. */
  8665. int cfg80211_check_combinations(struct wiphy *wiphy,
  8666. struct iface_combination_params *params);
  8667. /**
  8668. * cfg80211_iter_combinations - iterate over matching combinations
  8669. *
  8670. * @wiphy: the wiphy
  8671. * @params: the interface combinations parameter
  8672. * @iter: function to call for each matching combination
  8673. * @data: pointer to pass to iter function
  8674. *
  8675. * This function can be called by the driver to check what possible
  8676. * combinations it fits in at a given moment, e.g. for channel switching
  8677. * purposes.
  8678. *
  8679. * Return: 0 on success. Non-zero on error.
  8680. */
  8681. int cfg80211_iter_combinations(struct wiphy *wiphy,
  8682. struct iface_combination_params *params,
  8683. void (*iter)(const struct ieee80211_iface_combination *c,
  8684. void *data),
  8685. void *data);
  8686. /**
  8687. * cfg80211_stop_iface - trigger interface disconnection
  8688. *
  8689. * @wiphy: the wiphy
  8690. * @wdev: wireless device
  8691. * @gfp: context flags
  8692. *
  8693. * Trigger interface to be stopped as if AP was stopped, IBSS/mesh left, STA
  8694. * disconnected.
  8695. *
  8696. * Note: This doesn't need any locks and is asynchronous.
  8697. */
  8698. void cfg80211_stop_iface(struct wiphy *wiphy, struct wireless_dev *wdev,
  8699. gfp_t gfp);
  8700. /**
  8701. * cfg80211_shutdown_all_interfaces - shut down all interfaces for a wiphy
  8702. * @wiphy: the wiphy to shut down
  8703. *
  8704. * This function shuts down all interfaces belonging to this wiphy by
  8705. * calling dev_close() (and treating non-netdev interfaces as needed).
  8706. * It shouldn't really be used unless there are some fatal device errors
  8707. * that really can't be recovered in any other way.
  8708. *
  8709. * Callers must hold the RTNL and be able to deal with callbacks into
  8710. * the driver while the function is running.
  8711. */
  8712. void cfg80211_shutdown_all_interfaces(struct wiphy *wiphy);
  8713. /**
  8714. * wiphy_ext_feature_set - set the extended feature flag
  8715. *
  8716. * @wiphy: the wiphy to modify.
  8717. * @ftidx: extended feature bit index.
  8718. *
  8719. * The extended features are flagged in multiple bytes (see
  8720. * &struct wiphy.@ext_features)
  8721. */
  8722. static inline void wiphy_ext_feature_set(struct wiphy *wiphy,
  8723. enum nl80211_ext_feature_index ftidx)
  8724. {
  8725. u8 *ft_byte;
  8726. ft_byte = &wiphy->ext_features[ftidx / 8];
  8727. *ft_byte |= BIT(ftidx % 8);
  8728. }
  8729. /**
  8730. * wiphy_ext_feature_isset - check the extended feature flag
  8731. *
  8732. * @wiphy: the wiphy to modify.
  8733. * @ftidx: extended feature bit index.
  8734. *
  8735. * The extended features are flagged in multiple bytes (see
  8736. * &struct wiphy.@ext_features)
  8737. *
  8738. * Return: %true if extended feature flag is set, %false otherwise
  8739. */
  8740. static inline bool
  8741. wiphy_ext_feature_isset(struct wiphy *wiphy,
  8742. enum nl80211_ext_feature_index ftidx)
  8743. {
  8744. u8 ft_byte;
  8745. ft_byte = wiphy->ext_features[ftidx / 8];
  8746. return (ft_byte & BIT(ftidx % 8)) != 0;
  8747. }
  8748. /**
  8749. * cfg80211_free_nan_func - free NAN function
  8750. * @f: NAN function that should be freed
  8751. *
  8752. * Frees all the NAN function and all it's allocated members.
  8753. */
  8754. void cfg80211_free_nan_func(struct cfg80211_nan_func *f);
  8755. /**
  8756. * struct cfg80211_nan_match_params - NAN match parameters
  8757. * @type: the type of the function that triggered a match. If it is
  8758. * %NL80211_NAN_FUNC_SUBSCRIBE it means that we replied to a subscriber.
  8759. * If it is %NL80211_NAN_FUNC_PUBLISH, it means that we got a discovery
  8760. * result.
  8761. * If it is %NL80211_NAN_FUNC_FOLLOW_UP, we received a follow up.
  8762. * @inst_id: the local instance id
  8763. * @peer_inst_id: the instance id of the peer's function
  8764. * @addr: the MAC address of the peer
  8765. * @info_len: the length of the &info
  8766. * @info: the Service Specific Info from the peer (if any)
  8767. * @cookie: unique identifier of the corresponding function
  8768. */
  8769. struct cfg80211_nan_match_params {
  8770. enum nl80211_nan_function_type type;
  8771. u8 inst_id;
  8772. u8 peer_inst_id;
  8773. const u8 *addr;
  8774. u8 info_len;
  8775. const u8 *info;
  8776. u64 cookie;
  8777. };
  8778. /**
  8779. * cfg80211_nan_match - report a match for a NAN function.
  8780. * @wdev: the wireless device reporting the match
  8781. * @match: match notification parameters
  8782. * @gfp: allocation flags
  8783. *
  8784. * This function reports that the a NAN function had a match. This
  8785. * can be a subscribe that had a match or a solicited publish that
  8786. * was sent. It can also be a follow up that was received.
  8787. */
  8788. void cfg80211_nan_match(struct wireless_dev *wdev,
  8789. struct cfg80211_nan_match_params *match, gfp_t gfp);
  8790. /**
  8791. * cfg80211_nan_func_terminated - notify about NAN function termination.
  8792. *
  8793. * @wdev: the wireless device reporting the match
  8794. * @inst_id: the local instance id
  8795. * @reason: termination reason (one of the NL80211_NAN_FUNC_TERM_REASON_*)
  8796. * @cookie: unique NAN function identifier
  8797. * @gfp: allocation flags
  8798. *
  8799. * This function reports that the a NAN function is terminated.
  8800. */
  8801. void cfg80211_nan_func_terminated(struct wireless_dev *wdev,
  8802. u8 inst_id,
  8803. enum nl80211_nan_func_term_reason reason,
  8804. u64 cookie, gfp_t gfp);
  8805. /* ethtool helper */
  8806. void cfg80211_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info);
  8807. /**
  8808. * cfg80211_external_auth_request - userspace request for authentication
  8809. * @netdev: network device
  8810. * @params: External authentication parameters
  8811. * @gfp: allocation flags
  8812. * Returns: 0 on success, < 0 on error
  8813. */
  8814. int cfg80211_external_auth_request(struct net_device *netdev,
  8815. struct cfg80211_external_auth_params *params,
  8816. gfp_t gfp);
  8817. /**
  8818. * cfg80211_pmsr_report - report peer measurement result data
  8819. * @wdev: the wireless device reporting the measurement
  8820. * @req: the original measurement request
  8821. * @result: the result data
  8822. * @gfp: allocation flags
  8823. */
  8824. void cfg80211_pmsr_report(struct wireless_dev *wdev,
  8825. struct cfg80211_pmsr_request *req,
  8826. struct cfg80211_pmsr_result *result,
  8827. gfp_t gfp);
  8828. /**
  8829. * cfg80211_pmsr_complete - report peer measurement completed
  8830. * @wdev: the wireless device reporting the measurement
  8831. * @req: the original measurement request
  8832. * @gfp: allocation flags
  8833. *
  8834. * Report that the entire measurement completed, after this
  8835. * the request pointer will no longer be valid.
  8836. */
  8837. void cfg80211_pmsr_complete(struct wireless_dev *wdev,
  8838. struct cfg80211_pmsr_request *req,
  8839. gfp_t gfp);
  8840. /**
  8841. * cfg80211_iftype_allowed - check whether the interface can be allowed
  8842. * @wiphy: the wiphy
  8843. * @iftype: interface type
  8844. * @is_4addr: use_4addr flag, must be '0' when check_swif is '1'
  8845. * @check_swif: check iftype against software interfaces
  8846. *
  8847. * Check whether the interface is allowed to operate; additionally, this API
  8848. * can be used to check iftype against the software interfaces when
  8849. * check_swif is '1'.
  8850. *
  8851. * Return: %true if allowed, %false otherwise
  8852. */
  8853. bool cfg80211_iftype_allowed(struct wiphy *wiphy, enum nl80211_iftype iftype,
  8854. bool is_4addr, u8 check_swif);
  8855. /**
  8856. * cfg80211_assoc_comeback - notification of association that was
  8857. * temporarily rejected with a comeback
  8858. * @netdev: network device
  8859. * @ap_addr: AP (MLD) address that rejected the association
  8860. * @timeout: timeout interval value TUs.
  8861. *
  8862. * this function may sleep. the caller must hold the corresponding wdev's mutex.
  8863. */
  8864. void cfg80211_assoc_comeback(struct net_device *netdev,
  8865. const u8 *ap_addr, u32 timeout);
  8866. /* Logging, debugging and troubleshooting/diagnostic helpers. */
  8867. /* wiphy_printk helpers, similar to dev_printk */
  8868. #define wiphy_printk(level, wiphy, format, args...) \
  8869. dev_printk(level, &(wiphy)->dev, format, ##args)
  8870. #define wiphy_emerg(wiphy, format, args...) \
  8871. dev_emerg(&(wiphy)->dev, format, ##args)
  8872. #define wiphy_alert(wiphy, format, args...) \
  8873. dev_alert(&(wiphy)->dev, format, ##args)
  8874. #define wiphy_crit(wiphy, format, args...) \
  8875. dev_crit(&(wiphy)->dev, format, ##args)
  8876. #define wiphy_err(wiphy, format, args...) \
  8877. dev_err(&(wiphy)->dev, format, ##args)
  8878. #define wiphy_warn(wiphy, format, args...) \
  8879. dev_warn(&(wiphy)->dev, format, ##args)
  8880. #define wiphy_notice(wiphy, format, args...) \
  8881. dev_notice(&(wiphy)->dev, format, ##args)
  8882. #define wiphy_info(wiphy, format, args...) \
  8883. dev_info(&(wiphy)->dev, format, ##args)
  8884. #define wiphy_info_once(wiphy, format, args...) \
  8885. dev_info_once(&(wiphy)->dev, format, ##args)
  8886. #define wiphy_err_ratelimited(wiphy, format, args...) \
  8887. dev_err_ratelimited(&(wiphy)->dev, format, ##args)
  8888. #define wiphy_warn_ratelimited(wiphy, format, args...) \
  8889. dev_warn_ratelimited(&(wiphy)->dev, format, ##args)
  8890. #define wiphy_debug(wiphy, format, args...) \
  8891. wiphy_printk(KERN_DEBUG, wiphy, format, ##args)
  8892. #define wiphy_dbg(wiphy, format, args...) \
  8893. dev_dbg(&(wiphy)->dev, format, ##args)
  8894. #if defined(VERBOSE_DEBUG)
  8895. #define wiphy_vdbg wiphy_dbg
  8896. #else
  8897. #define wiphy_vdbg(wiphy, format, args...) \
  8898. ({ \
  8899. if (0) \
  8900. wiphy_printk(KERN_DEBUG, wiphy, format, ##args); \
  8901. 0; \
  8902. })
  8903. #endif
  8904. /*
  8905. * wiphy_WARN() acts like wiphy_printk(), but with the key difference
  8906. * of using a WARN/WARN_ON to get the message out, including the
  8907. * file/line information and a backtrace.
  8908. */
  8909. #define wiphy_WARN(wiphy, format, args...) \
  8910. WARN(1, "wiphy: %s\n" format, wiphy_name(wiphy), ##args);
  8911. /**
  8912. * cfg80211_update_owe_info_event - Notify the peer's OWE info to user space
  8913. * @netdev: network device
  8914. * @owe_info: peer's owe info
  8915. * @gfp: allocation flags
  8916. */
  8917. void cfg80211_update_owe_info_event(struct net_device *netdev,
  8918. struct cfg80211_update_owe_info *owe_info,
  8919. gfp_t gfp);
  8920. /**
  8921. * cfg80211_bss_flush - resets all the scan entries
  8922. * @wiphy: the wiphy
  8923. */
  8924. void cfg80211_bss_flush(struct wiphy *wiphy);
  8925. /**
  8926. * cfg80211_bss_color_notify - notify about bss color event
  8927. * @dev: network device
  8928. * @cmd: the actual event we want to notify
  8929. * @count: the number of TBTTs until the color change happens
  8930. * @color_bitmap: representations of the colors that the local BSS is aware of
  8931. * @link_id: valid link_id in case of MLO or 0 for non-MLO.
  8932. *
  8933. * Return: 0 on success. Non-zero on error.
  8934. */
  8935. int cfg80211_bss_color_notify(struct net_device *dev,
  8936. enum nl80211_commands cmd, u8 count,
  8937. u64 color_bitmap, u8 link_id);
  8938. /**
  8939. * cfg80211_obss_color_collision_notify - notify about bss color collision
  8940. * @dev: network device
  8941. * @color_bitmap: representations of the colors that the local BSS is aware of
  8942. * @link_id: valid link_id in case of MLO or 0 for non-MLO.
  8943. *
  8944. * Return: 0 on success. Non-zero on error.
  8945. */
  8946. static inline int cfg80211_obss_color_collision_notify(struct net_device *dev,
  8947. u64 color_bitmap,
  8948. u8 link_id)
  8949. {
  8950. return cfg80211_bss_color_notify(dev, NL80211_CMD_OBSS_COLOR_COLLISION,
  8951. 0, color_bitmap, link_id);
  8952. }
  8953. /**
  8954. * cfg80211_color_change_started_notify - notify color change start
  8955. * @dev: the device on which the color is switched
  8956. * @count: the number of TBTTs until the color change happens
  8957. * @link_id: valid link_id in case of MLO or 0 for non-MLO.
  8958. *
  8959. * Inform the userspace about the color change that has started.
  8960. *
  8961. * Return: 0 on success. Non-zero on error.
  8962. */
  8963. static inline int cfg80211_color_change_started_notify(struct net_device *dev,
  8964. u8 count, u8 link_id)
  8965. {
  8966. return cfg80211_bss_color_notify(dev, NL80211_CMD_COLOR_CHANGE_STARTED,
  8967. count, 0, link_id);
  8968. }
  8969. /**
  8970. * cfg80211_color_change_aborted_notify - notify color change abort
  8971. * @dev: the device on which the color is switched
  8972. * @link_id: valid link_id in case of MLO or 0 for non-MLO.
  8973. *
  8974. * Inform the userspace about the color change that has aborted.
  8975. *
  8976. * Return: 0 on success. Non-zero on error.
  8977. */
  8978. static inline int cfg80211_color_change_aborted_notify(struct net_device *dev,
  8979. u8 link_id)
  8980. {
  8981. return cfg80211_bss_color_notify(dev, NL80211_CMD_COLOR_CHANGE_ABORTED,
  8982. 0, 0, link_id);
  8983. }
  8984. /**
  8985. * cfg80211_color_change_notify - notify color change completion
  8986. * @dev: the device on which the color was switched
  8987. * @link_id: valid link_id in case of MLO or 0 for non-MLO.
  8988. *
  8989. * Inform the userspace about the color change that has completed.
  8990. *
  8991. * Return: 0 on success. Non-zero on error.
  8992. */
  8993. static inline int cfg80211_color_change_notify(struct net_device *dev,
  8994. u8 link_id)
  8995. {
  8996. return cfg80211_bss_color_notify(dev,
  8997. NL80211_CMD_COLOR_CHANGE_COMPLETED,
  8998. 0, 0, link_id);
  8999. }
  9000. /**
  9001. * cfg80211_links_removed - Notify about removed STA MLD setup links.
  9002. * @dev: network device.
  9003. * @link_mask: BIT mask of removed STA MLD setup link IDs.
  9004. *
  9005. * Inform cfg80211 and the userspace about removed STA MLD setup links due to
  9006. * AP MLD removing the corresponding affiliated APs with Multi-Link
  9007. * reconfiguration. Note that it's not valid to remove all links, in this
  9008. * case disconnect instead.
  9009. * Also note that the wdev mutex must be held.
  9010. */
  9011. void cfg80211_links_removed(struct net_device *dev, u16 link_mask);
  9012. /**
  9013. * cfg80211_schedule_channels_check - schedule regulatory check if needed
  9014. * @wdev: the wireless device to check
  9015. *
  9016. * In case the device supports NO_IR or DFS relaxations, schedule regulatory
  9017. * channels check, as previous concurrent operation conditions may not
  9018. * hold anymore.
  9019. */
  9020. void cfg80211_schedule_channels_check(struct wireless_dev *wdev);
  9021. #ifdef CONFIG_CFG80211_DEBUGFS
  9022. /**
  9023. * wiphy_locked_debugfs_read - do a locked read in debugfs
  9024. * @wiphy: the wiphy to use
  9025. * @file: the file being read
  9026. * @buf: the buffer to fill and then read from
  9027. * @bufsize: size of the buffer
  9028. * @userbuf: the user buffer to copy to
  9029. * @count: read count
  9030. * @ppos: read position
  9031. * @handler: the read handler to call (under wiphy lock)
  9032. * @data: additional data to pass to the read handler
  9033. *
  9034. * Return: the number of characters read, or a negative errno
  9035. */
  9036. ssize_t wiphy_locked_debugfs_read(struct wiphy *wiphy, struct file *file,
  9037. char *buf, size_t bufsize,
  9038. char __user *userbuf, size_t count,
  9039. loff_t *ppos,
  9040. ssize_t (*handler)(struct wiphy *wiphy,
  9041. struct file *file,
  9042. char *buf,
  9043. size_t bufsize,
  9044. void *data),
  9045. void *data);
  9046. /**
  9047. * wiphy_locked_debugfs_write - do a locked write in debugfs
  9048. * @wiphy: the wiphy to use
  9049. * @file: the file being written to
  9050. * @buf: the buffer to copy the user data to
  9051. * @bufsize: size of the buffer
  9052. * @userbuf: the user buffer to copy from
  9053. * @count: read count
  9054. * @handler: the write handler to call (under wiphy lock)
  9055. * @data: additional data to pass to the write handler
  9056. *
  9057. * Return: the number of characters written, or a negative errno
  9058. */
  9059. ssize_t wiphy_locked_debugfs_write(struct wiphy *wiphy, struct file *file,
  9060. char *buf, size_t bufsize,
  9061. const char __user *userbuf, size_t count,
  9062. ssize_t (*handler)(struct wiphy *wiphy,
  9063. struct file *file,
  9064. char *buf,
  9065. size_t count,
  9066. void *data),
  9067. void *data);
  9068. #endif
  9069. #endif /* __NET_CFG80211_H */