cfg80211.h 218 KB

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