cfg80211.h 370 KB

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