cfg80211.h 188 KB

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