cfg80211.h 171 KB

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