cfg80211.h 234 KB

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