cfg80211.h 156 KB

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