mac80211.h 126 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319
  1. /*
  2. * mac80211 <-> driver interface
  3. *
  4. * Copyright 2002-2005, Devicescape Software, Inc.
  5. * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
  6. * Copyright 2007-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. #ifndef MAC80211_H
  13. #define MAC80211_H
  14. #include <linux/kernel.h>
  15. #include <linux/if_ether.h>
  16. #include <linux/skbuff.h>
  17. #include <linux/wireless.h>
  18. #include <linux/device.h>
  19. #include <linux/ieee80211.h>
  20. #include <net/cfg80211.h>
  21. #include <asm/unaligned.h>
  22. /**
  23. * DOC: Introduction
  24. *
  25. * mac80211 is the Linux stack for 802.11 hardware that implements
  26. * only partial functionality in hard- or firmware. This document
  27. * defines the interface between mac80211 and low-level hardware
  28. * drivers.
  29. */
  30. /**
  31. * DOC: Calling mac80211 from interrupts
  32. *
  33. * Only ieee80211_tx_status_irqsafe() and ieee80211_rx_irqsafe() can be
  34. * called in hardware interrupt context. The low-level driver must not call any
  35. * other functions in hardware interrupt context. If there is a need for such
  36. * call, the low-level driver should first ACK the interrupt and perform the
  37. * IEEE 802.11 code call after this, e.g. from a scheduled workqueue or even
  38. * tasklet function.
  39. *
  40. * NOTE: If the driver opts to use the _irqsafe() functions, it may not also
  41. * use the non-IRQ-safe functions!
  42. */
  43. /**
  44. * DOC: Warning
  45. *
  46. * If you're reading this document and not the header file itself, it will
  47. * be incomplete because not all documentation has been converted yet.
  48. */
  49. /**
  50. * DOC: Frame format
  51. *
  52. * As a general rule, when frames are passed between mac80211 and the driver,
  53. * they start with the IEEE 802.11 header and include the same octets that are
  54. * sent over the air except for the FCS which should be calculated by the
  55. * hardware.
  56. *
  57. * There are, however, various exceptions to this rule for advanced features:
  58. *
  59. * The first exception is for hardware encryption and decryption offload
  60. * where the IV/ICV may or may not be generated in hardware.
  61. *
  62. * Secondly, when the hardware handles fragmentation, the frame handed to
  63. * the driver from mac80211 is the MSDU, not the MPDU.
  64. *
  65. * Finally, for received frames, the driver is able to indicate that it has
  66. * filled a radiotap header and put that in front of the frame; if it does
  67. * not do so then mac80211 may add this under certain circumstances.
  68. */
  69. /**
  70. * DOC: mac80211 workqueue
  71. *
  72. * mac80211 provides its own workqueue for drivers and internal mac80211 use.
  73. * The workqueue is a single threaded workqueue and can only be accessed by
  74. * helpers for sanity checking. Drivers must ensure all work added onto the
  75. * mac80211 workqueue should be cancelled on the driver stop() callback.
  76. *
  77. * mac80211 will flushed the workqueue upon interface removal and during
  78. * suspend.
  79. *
  80. * All work performed on the mac80211 workqueue must not acquire the RTNL lock.
  81. *
  82. */
  83. /**
  84. * enum ieee80211_max_queues - maximum number of queues
  85. *
  86. * @IEEE80211_MAX_QUEUES: Maximum number of regular device queues.
  87. */
  88. enum ieee80211_max_queues {
  89. IEEE80211_MAX_QUEUES = 4,
  90. };
  91. /**
  92. * enum ieee80211_ac_numbers - AC numbers as used in mac80211
  93. * @IEEE80211_AC_VO: voice
  94. * @IEEE80211_AC_VI: video
  95. * @IEEE80211_AC_BE: best effort
  96. * @IEEE80211_AC_BK: background
  97. */
  98. enum ieee80211_ac_numbers {
  99. IEEE80211_AC_VO = 0,
  100. IEEE80211_AC_VI = 1,
  101. IEEE80211_AC_BE = 2,
  102. IEEE80211_AC_BK = 3,
  103. };
  104. /**
  105. * struct ieee80211_tx_queue_params - transmit queue configuration
  106. *
  107. * The information provided in this structure is required for QoS
  108. * transmit queue configuration. Cf. IEEE 802.11 7.3.2.29.
  109. *
  110. * @aifs: arbitration interframe space [0..255]
  111. * @cw_min: minimum contention window [a value of the form
  112. * 2^n-1 in the range 1..32767]
  113. * @cw_max: maximum contention window [like @cw_min]
  114. * @txop: maximum burst time in units of 32 usecs, 0 meaning disabled
  115. * @uapsd: is U-APSD mode enabled for the queue
  116. */
  117. struct ieee80211_tx_queue_params {
  118. u16 txop;
  119. u16 cw_min;
  120. u16 cw_max;
  121. u8 aifs;
  122. bool uapsd;
  123. };
  124. struct ieee80211_low_level_stats {
  125. unsigned int dot11ACKFailureCount;
  126. unsigned int dot11RTSFailureCount;
  127. unsigned int dot11FCSErrorCount;
  128. unsigned int dot11RTSSuccessCount;
  129. };
  130. /**
  131. * enum ieee80211_bss_change - BSS change notification flags
  132. *
  133. * These flags are used with the bss_info_changed() callback
  134. * to indicate which BSS parameter changed.
  135. *
  136. * @BSS_CHANGED_ASSOC: association status changed (associated/disassociated),
  137. * also implies a change in the AID.
  138. * @BSS_CHANGED_ERP_CTS_PROT: CTS protection changed
  139. * @BSS_CHANGED_ERP_PREAMBLE: preamble changed
  140. * @BSS_CHANGED_ERP_SLOT: slot timing changed
  141. * @BSS_CHANGED_HT: 802.11n parameters changed
  142. * @BSS_CHANGED_BASIC_RATES: Basic rateset changed
  143. * @BSS_CHANGED_BEACON_INT: Beacon interval changed
  144. * @BSS_CHANGED_BSSID: BSSID changed, for whatever
  145. * reason (IBSS and managed mode)
  146. * @BSS_CHANGED_BEACON: Beacon data changed, retrieve
  147. * new beacon (beaconing modes)
  148. * @BSS_CHANGED_BEACON_ENABLED: Beaconing should be
  149. * enabled/disabled (beaconing modes)
  150. * @BSS_CHANGED_CQM: Connection quality monitor config changed
  151. * @BSS_CHANGED_IBSS: IBSS join status changed
  152. * @BSS_CHANGED_ARP_FILTER: Hardware ARP filter address list or state changed.
  153. * @BSS_CHANGED_QOS: QoS for this association was enabled/disabled. Note
  154. * that it is only ever disabled for station mode.
  155. * @BSS_CHANGED_IDLE: Idle changed for this BSS/interface.
  156. */
  157. enum ieee80211_bss_change {
  158. BSS_CHANGED_ASSOC = 1<<0,
  159. BSS_CHANGED_ERP_CTS_PROT = 1<<1,
  160. BSS_CHANGED_ERP_PREAMBLE = 1<<2,
  161. BSS_CHANGED_ERP_SLOT = 1<<3,
  162. BSS_CHANGED_HT = 1<<4,
  163. BSS_CHANGED_BASIC_RATES = 1<<5,
  164. BSS_CHANGED_BEACON_INT = 1<<6,
  165. BSS_CHANGED_BSSID = 1<<7,
  166. BSS_CHANGED_BEACON = 1<<8,
  167. BSS_CHANGED_BEACON_ENABLED = 1<<9,
  168. BSS_CHANGED_CQM = 1<<10,
  169. BSS_CHANGED_IBSS = 1<<11,
  170. BSS_CHANGED_ARP_FILTER = 1<<12,
  171. BSS_CHANGED_QOS = 1<<13,
  172. BSS_CHANGED_IDLE = 1<<14,
  173. /* when adding here, make sure to change ieee80211_reconfig */
  174. };
  175. /*
  176. * The maximum number of IPv4 addresses listed for ARP filtering. If the number
  177. * of addresses for an interface increase beyond this value, hardware ARP
  178. * filtering will be disabled.
  179. */
  180. #define IEEE80211_BSS_ARP_ADDR_LIST_LEN 4
  181. /**
  182. * struct ieee80211_bss_conf - holds the BSS's changing parameters
  183. *
  184. * This structure keeps information about a BSS (and an association
  185. * to that BSS) that can change during the lifetime of the BSS.
  186. *
  187. * @assoc: association status
  188. * @ibss_joined: indicates whether this station is part of an IBSS
  189. * or not
  190. * @aid: association ID number, valid only when @assoc is true
  191. * @use_cts_prot: use CTS protection
  192. * @use_short_preamble: use 802.11b short preamble;
  193. * if the hardware cannot handle this it must set the
  194. * IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE hardware flag
  195. * @use_short_slot: use short slot time (only relevant for ERP);
  196. * if the hardware cannot handle this it must set the
  197. * IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE hardware flag
  198. * @dtim_period: num of beacons before the next DTIM, for beaconing,
  199. * valid in station mode only while @assoc is true and if also
  200. * requested by %IEEE80211_HW_NEED_DTIM_PERIOD (cf. also hw conf
  201. * @ps_dtim_period)
  202. * @timestamp: beacon timestamp
  203. * @beacon_int: beacon interval
  204. * @assoc_capability: capabilities taken from assoc resp
  205. * @basic_rates: bitmap of basic rates, each bit stands for an
  206. * index into the rate table configured by the driver in
  207. * the current band.
  208. * @mcast_rate: per-band multicast rate index + 1 (0: disabled)
  209. * @bssid: The BSSID for this BSS
  210. * @enable_beacon: whether beaconing should be enabled or not
  211. * @channel_type: Channel type for this BSS -- the hardware might be
  212. * configured for HT40+ while this BSS only uses no-HT, for
  213. * example.
  214. * @ht_operation_mode: HT operation mode (like in &struct ieee80211_ht_info).
  215. * This field is only valid when the channel type is one of the HT types.
  216. * @cqm_rssi_thold: Connection quality monitor RSSI threshold, a zero value
  217. * implies disabled
  218. * @cqm_rssi_hyst: Connection quality monitor RSSI hysteresis
  219. * @arp_addr_list: List of IPv4 addresses for hardware ARP filtering. The
  220. * may filter ARP queries targeted for other addresses than listed here.
  221. * The driver must allow ARP queries targeted for all address listed here
  222. * to pass through. An empty list implies no ARP queries need to pass.
  223. * @arp_addr_cnt: Number of addresses currently on the list.
  224. * @arp_filter_enabled: Enable ARP filtering - if enabled, the hardware may
  225. * filter ARP queries based on the @arp_addr_list, if disabled, the
  226. * hardware must not perform any ARP filtering. Note, that the filter will
  227. * be enabled also in promiscuous mode.
  228. * @qos: This is a QoS-enabled BSS.
  229. * @idle: This interface is idle. There's also a global idle flag in the
  230. * hardware config which may be more appropriate depending on what
  231. * your driver/device needs to do.
  232. */
  233. struct ieee80211_bss_conf {
  234. const u8 *bssid;
  235. /* association related data */
  236. bool assoc, ibss_joined;
  237. u16 aid;
  238. /* erp related data */
  239. bool use_cts_prot;
  240. bool use_short_preamble;
  241. bool use_short_slot;
  242. bool enable_beacon;
  243. u8 dtim_period;
  244. u16 beacon_int;
  245. u16 assoc_capability;
  246. u64 timestamp;
  247. u32 basic_rates;
  248. int mcast_rate[IEEE80211_NUM_BANDS];
  249. u16 ht_operation_mode;
  250. s32 cqm_rssi_thold;
  251. u32 cqm_rssi_hyst;
  252. enum nl80211_channel_type channel_type;
  253. __be32 arp_addr_list[IEEE80211_BSS_ARP_ADDR_LIST_LEN];
  254. u8 arp_addr_cnt;
  255. bool arp_filter_enabled;
  256. bool qos;
  257. bool idle;
  258. };
  259. /**
  260. * enum mac80211_tx_control_flags - flags to describe transmission information/status
  261. *
  262. * These flags are used with the @flags member of &ieee80211_tx_info.
  263. *
  264. * @IEEE80211_TX_CTL_REQ_TX_STATUS: require TX status callback for this frame.
  265. * @IEEE80211_TX_CTL_ASSIGN_SEQ: The driver has to assign a sequence
  266. * number to this frame, taking care of not overwriting the fragment
  267. * number and increasing the sequence number only when the
  268. * IEEE80211_TX_CTL_FIRST_FRAGMENT flag is set. mac80211 will properly
  269. * assign sequence numbers to QoS-data frames but cannot do so correctly
  270. * for non-QoS-data and management frames because beacons need them from
  271. * that counter as well and mac80211 cannot guarantee proper sequencing.
  272. * If this flag is set, the driver should instruct the hardware to
  273. * assign a sequence number to the frame or assign one itself. Cf. IEEE
  274. * 802.11-2007 7.1.3.4.1 paragraph 3. This flag will always be set for
  275. * beacons and always be clear for frames without a sequence number field.
  276. * @IEEE80211_TX_CTL_NO_ACK: tell the low level not to wait for an ack
  277. * @IEEE80211_TX_CTL_CLEAR_PS_FILT: clear powersave filter for destination
  278. * station
  279. * @IEEE80211_TX_CTL_FIRST_FRAGMENT: this is a first fragment of the frame
  280. * @IEEE80211_TX_CTL_SEND_AFTER_DTIM: send this frame after DTIM beacon
  281. * @IEEE80211_TX_CTL_AMPDU: this frame should be sent as part of an A-MPDU
  282. * @IEEE80211_TX_CTL_INJECTED: Frame was injected, internal to mac80211.
  283. * @IEEE80211_TX_STAT_TX_FILTERED: The frame was not transmitted
  284. * because the destination STA was in powersave mode. Note that to
  285. * avoid race conditions, the filter must be set by the hardware or
  286. * firmware upon receiving a frame that indicates that the station
  287. * went to sleep (must be done on device to filter frames already on
  288. * the queue) and may only be unset after mac80211 gives the OK for
  289. * that by setting the IEEE80211_TX_CTL_CLEAR_PS_FILT (see above),
  290. * since only then is it guaranteed that no more frames are in the
  291. * hardware queue.
  292. * @IEEE80211_TX_STAT_ACK: Frame was acknowledged
  293. * @IEEE80211_TX_STAT_AMPDU: The frame was aggregated, so status
  294. * is for the whole aggregation.
  295. * @IEEE80211_TX_STAT_AMPDU_NO_BACK: no block ack was returned,
  296. * so consider using block ack request (BAR).
  297. * @IEEE80211_TX_CTL_RATE_CTRL_PROBE: internal to mac80211, can be
  298. * set by rate control algorithms to indicate probe rate, will
  299. * be cleared for fragmented frames (except on the last fragment)
  300. * @IEEE80211_TX_INTFL_NEED_TXPROCESSING: completely internal to mac80211,
  301. * used to indicate that a pending frame requires TX processing before
  302. * it can be sent out.
  303. * @IEEE80211_TX_INTFL_RETRIED: completely internal to mac80211,
  304. * used to indicate that a frame was already retried due to PS
  305. * @IEEE80211_TX_INTFL_DONT_ENCRYPT: completely internal to mac80211,
  306. * used to indicate frame should not be encrypted
  307. * @IEEE80211_TX_CTL_PSPOLL_RESPONSE: (internal?)
  308. * This frame is a response to a PS-poll frame and should be sent
  309. * although the station is in powersave mode.
  310. * @IEEE80211_TX_CTL_MORE_FRAMES: More frames will be passed to the
  311. * transmit function after the current frame, this can be used
  312. * by drivers to kick the DMA queue only if unset or when the
  313. * queue gets full.
  314. * @IEEE80211_TX_INTFL_RETRANSMISSION: This frame is being retransmitted
  315. * after TX status because the destination was asleep, it must not
  316. * be modified again (no seqno assignment, crypto, etc.)
  317. * @IEEE80211_TX_INTFL_HAS_RADIOTAP: This frame was injected and still
  318. * has a radiotap header at skb->data.
  319. * @IEEE80211_TX_INTFL_NL80211_FRAME_TX: Frame was requested through nl80211
  320. * MLME command (internal to mac80211 to figure out whether to send TX
  321. * status to user space)
  322. * @IEEE80211_TX_CTL_LDPC: tells the driver to use LDPC for this frame
  323. * @IEEE80211_TX_CTL_STBC: Enables Space-Time Block Coding (STBC) for this
  324. * frame and selects the maximum number of streams that it can use.
  325. * @IEEE80211_TX_CTL_TX_OFFCHAN: Marks this packet to be transmitted on
  326. * the off-channel channel when a remain-on-channel offload is done
  327. * in hardware -- normal packets still flow and are expected to be
  328. * handled properly by the device.
  329. * @IEEE80211_TX_INTFL_TKIP_MIC_FAILURE: Marks this packet to be used for TKIP
  330. * testing. It will be sent out with incorrect Michael MIC key to allow
  331. * TKIP countermeasures to be tested.
  332. *
  333. * Note: If you have to add new flags to the enumeration, then don't
  334. * forget to update %IEEE80211_TX_TEMPORARY_FLAGS when necessary.
  335. */
  336. enum mac80211_tx_control_flags {
  337. IEEE80211_TX_CTL_REQ_TX_STATUS = BIT(0),
  338. IEEE80211_TX_CTL_ASSIGN_SEQ = BIT(1),
  339. IEEE80211_TX_CTL_NO_ACK = BIT(2),
  340. IEEE80211_TX_CTL_CLEAR_PS_FILT = BIT(3),
  341. IEEE80211_TX_CTL_FIRST_FRAGMENT = BIT(4),
  342. IEEE80211_TX_CTL_SEND_AFTER_DTIM = BIT(5),
  343. IEEE80211_TX_CTL_AMPDU = BIT(6),
  344. IEEE80211_TX_CTL_INJECTED = BIT(7),
  345. IEEE80211_TX_STAT_TX_FILTERED = BIT(8),
  346. IEEE80211_TX_STAT_ACK = BIT(9),
  347. IEEE80211_TX_STAT_AMPDU = BIT(10),
  348. IEEE80211_TX_STAT_AMPDU_NO_BACK = BIT(11),
  349. IEEE80211_TX_CTL_RATE_CTRL_PROBE = BIT(12),
  350. IEEE80211_TX_INTFL_NEED_TXPROCESSING = BIT(14),
  351. IEEE80211_TX_INTFL_RETRIED = BIT(15),
  352. IEEE80211_TX_INTFL_DONT_ENCRYPT = BIT(16),
  353. IEEE80211_TX_CTL_PSPOLL_RESPONSE = BIT(17),
  354. IEEE80211_TX_CTL_MORE_FRAMES = BIT(18),
  355. IEEE80211_TX_INTFL_RETRANSMISSION = BIT(19),
  356. IEEE80211_TX_INTFL_HAS_RADIOTAP = BIT(20),
  357. IEEE80211_TX_INTFL_NL80211_FRAME_TX = BIT(21),
  358. IEEE80211_TX_CTL_LDPC = BIT(22),
  359. IEEE80211_TX_CTL_STBC = BIT(23) | BIT(24),
  360. IEEE80211_TX_CTL_TX_OFFCHAN = BIT(25),
  361. IEEE80211_TX_INTFL_TKIP_MIC_FAILURE = BIT(26),
  362. };
  363. #define IEEE80211_TX_CTL_STBC_SHIFT 23
  364. /*
  365. * This definition is used as a mask to clear all temporary flags, which are
  366. * set by the tx handlers for each transmission attempt by the mac80211 stack.
  367. */
  368. #define IEEE80211_TX_TEMPORARY_FLAGS (IEEE80211_TX_CTL_NO_ACK | \
  369. IEEE80211_TX_CTL_CLEAR_PS_FILT | IEEE80211_TX_CTL_FIRST_FRAGMENT | \
  370. IEEE80211_TX_CTL_SEND_AFTER_DTIM | IEEE80211_TX_CTL_AMPDU | \
  371. IEEE80211_TX_STAT_TX_FILTERED | IEEE80211_TX_STAT_ACK | \
  372. IEEE80211_TX_STAT_AMPDU | IEEE80211_TX_STAT_AMPDU_NO_BACK | \
  373. IEEE80211_TX_CTL_RATE_CTRL_PROBE | IEEE80211_TX_CTL_PSPOLL_RESPONSE | \
  374. IEEE80211_TX_CTL_MORE_FRAMES | IEEE80211_TX_CTL_LDPC | \
  375. IEEE80211_TX_CTL_STBC)
  376. /**
  377. * enum mac80211_rate_control_flags - per-rate flags set by the
  378. * Rate Control algorithm.
  379. *
  380. * These flags are set by the Rate control algorithm for each rate during tx,
  381. * in the @flags member of struct ieee80211_tx_rate.
  382. *
  383. * @IEEE80211_TX_RC_USE_RTS_CTS: Use RTS/CTS exchange for this rate.
  384. * @IEEE80211_TX_RC_USE_CTS_PROTECT: CTS-to-self protection is required.
  385. * This is set if the current BSS requires ERP protection.
  386. * @IEEE80211_TX_RC_USE_SHORT_PREAMBLE: Use short preamble.
  387. * @IEEE80211_TX_RC_MCS: HT rate.
  388. * @IEEE80211_TX_RC_GREEN_FIELD: Indicates whether this rate should be used in
  389. * Greenfield mode.
  390. * @IEEE80211_TX_RC_40_MHZ_WIDTH: Indicates if the Channel Width should be 40 MHz.
  391. * @IEEE80211_TX_RC_DUP_DATA: The frame should be transmitted on both of the
  392. * adjacent 20 MHz channels, if the current channel type is
  393. * NL80211_CHAN_HT40MINUS or NL80211_CHAN_HT40PLUS.
  394. * @IEEE80211_TX_RC_SHORT_GI: Short Guard interval should be used for this rate.
  395. */
  396. enum mac80211_rate_control_flags {
  397. IEEE80211_TX_RC_USE_RTS_CTS = BIT(0),
  398. IEEE80211_TX_RC_USE_CTS_PROTECT = BIT(1),
  399. IEEE80211_TX_RC_USE_SHORT_PREAMBLE = BIT(2),
  400. /* rate index is an MCS rate number instead of an index */
  401. IEEE80211_TX_RC_MCS = BIT(3),
  402. IEEE80211_TX_RC_GREEN_FIELD = BIT(4),
  403. IEEE80211_TX_RC_40_MHZ_WIDTH = BIT(5),
  404. IEEE80211_TX_RC_DUP_DATA = BIT(6),
  405. IEEE80211_TX_RC_SHORT_GI = BIT(7),
  406. };
  407. /* there are 40 bytes if you don't need the rateset to be kept */
  408. #define IEEE80211_TX_INFO_DRIVER_DATA_SIZE 40
  409. /* if you do need the rateset, then you have less space */
  410. #define IEEE80211_TX_INFO_RATE_DRIVER_DATA_SIZE 24
  411. /* maximum number of rate stages */
  412. #define IEEE80211_TX_MAX_RATES 5
  413. /**
  414. * struct ieee80211_tx_rate - rate selection/status
  415. *
  416. * @idx: rate index to attempt to send with
  417. * @flags: rate control flags (&enum mac80211_rate_control_flags)
  418. * @count: number of tries in this rate before going to the next rate
  419. *
  420. * A value of -1 for @idx indicates an invalid rate and, if used
  421. * in an array of retry rates, that no more rates should be tried.
  422. *
  423. * When used for transmit status reporting, the driver should
  424. * always report the rate along with the flags it used.
  425. *
  426. * &struct ieee80211_tx_info contains an array of these structs
  427. * in the control information, and it will be filled by the rate
  428. * control algorithm according to what should be sent. For example,
  429. * if this array contains, in the format { <idx>, <count> } the
  430. * information
  431. * { 3, 2 }, { 2, 2 }, { 1, 4 }, { -1, 0 }, { -1, 0 }
  432. * then this means that the frame should be transmitted
  433. * up to twice at rate 3, up to twice at rate 2, and up to four
  434. * times at rate 1 if it doesn't get acknowledged. Say it gets
  435. * acknowledged by the peer after the fifth attempt, the status
  436. * information should then contain
  437. * { 3, 2 }, { 2, 2 }, { 1, 1 }, { -1, 0 } ...
  438. * since it was transmitted twice at rate 3, twice at rate 2
  439. * and once at rate 1 after which we received an acknowledgement.
  440. */
  441. struct ieee80211_tx_rate {
  442. s8 idx;
  443. u8 count;
  444. u8 flags;
  445. } __packed;
  446. /**
  447. * struct ieee80211_tx_info - skb transmit information
  448. *
  449. * This structure is placed in skb->cb for three uses:
  450. * (1) mac80211 TX control - mac80211 tells the driver what to do
  451. * (2) driver internal use (if applicable)
  452. * (3) TX status information - driver tells mac80211 what happened
  453. *
  454. * The TX control's sta pointer is only valid during the ->tx call,
  455. * it may be NULL.
  456. *
  457. * @flags: transmit info flags, defined above
  458. * @band: the band to transmit on (use for checking for races)
  459. * @antenna_sel_tx: antenna to use, 0 for automatic diversity
  460. * @pad: padding, ignore
  461. * @control: union for control data
  462. * @status: union for status data
  463. * @driver_data: array of driver_data pointers
  464. * @ampdu_ack_len: number of acked aggregated frames.
  465. * relevant only if IEEE80211_TX_STAT_AMPDU was set.
  466. * @ampdu_len: number of aggregated frames.
  467. * relevant only if IEEE80211_TX_STAT_AMPDU was set.
  468. * @ack_signal: signal strength of the ACK frame
  469. */
  470. struct ieee80211_tx_info {
  471. /* common information */
  472. u32 flags;
  473. u8 band;
  474. u8 antenna_sel_tx;
  475. /* 2 byte hole */
  476. u8 pad[2];
  477. union {
  478. struct {
  479. union {
  480. /* rate control */
  481. struct {
  482. struct ieee80211_tx_rate rates[
  483. IEEE80211_TX_MAX_RATES];
  484. s8 rts_cts_rate_idx;
  485. };
  486. /* only needed before rate control */
  487. unsigned long jiffies;
  488. };
  489. /* NB: vif can be NULL for injected frames */
  490. struct ieee80211_vif *vif;
  491. struct ieee80211_key_conf *hw_key;
  492. struct ieee80211_sta *sta;
  493. } control;
  494. struct {
  495. struct ieee80211_tx_rate rates[IEEE80211_TX_MAX_RATES];
  496. u8 ampdu_ack_len;
  497. int ack_signal;
  498. u8 ampdu_len;
  499. /* 15 bytes free */
  500. } status;
  501. struct {
  502. struct ieee80211_tx_rate driver_rates[
  503. IEEE80211_TX_MAX_RATES];
  504. void *rate_driver_data[
  505. IEEE80211_TX_INFO_RATE_DRIVER_DATA_SIZE / sizeof(void *)];
  506. };
  507. void *driver_data[
  508. IEEE80211_TX_INFO_DRIVER_DATA_SIZE / sizeof(void *)];
  509. };
  510. };
  511. /**
  512. * struct ieee80211_sched_scan_ies - scheduled scan IEs
  513. *
  514. * This structure is used to pass the appropriate IEs to be used in scheduled
  515. * scans for all bands. It contains both the IEs passed from the userspace
  516. * and the ones generated by mac80211.
  517. *
  518. * @ie: array with the IEs for each supported band
  519. * @len: array with the total length of the IEs for each band
  520. */
  521. struct ieee80211_sched_scan_ies {
  522. u8 *ie[IEEE80211_NUM_BANDS];
  523. size_t len[IEEE80211_NUM_BANDS];
  524. };
  525. static inline struct ieee80211_tx_info *IEEE80211_SKB_CB(struct sk_buff *skb)
  526. {
  527. return (struct ieee80211_tx_info *)skb->cb;
  528. }
  529. static inline struct ieee80211_rx_status *IEEE80211_SKB_RXCB(struct sk_buff *skb)
  530. {
  531. return (struct ieee80211_rx_status *)skb->cb;
  532. }
  533. /**
  534. * ieee80211_tx_info_clear_status - clear TX status
  535. *
  536. * @info: The &struct ieee80211_tx_info to be cleared.
  537. *
  538. * When the driver passes an skb back to mac80211, it must report
  539. * a number of things in TX status. This function clears everything
  540. * in the TX status but the rate control information (it does clear
  541. * the count since you need to fill that in anyway).
  542. *
  543. * NOTE: You can only use this function if you do NOT use
  544. * info->driver_data! Use info->rate_driver_data
  545. * instead if you need only the less space that allows.
  546. */
  547. static inline void
  548. ieee80211_tx_info_clear_status(struct ieee80211_tx_info *info)
  549. {
  550. int i;
  551. BUILD_BUG_ON(offsetof(struct ieee80211_tx_info, status.rates) !=
  552. offsetof(struct ieee80211_tx_info, control.rates));
  553. BUILD_BUG_ON(offsetof(struct ieee80211_tx_info, status.rates) !=
  554. offsetof(struct ieee80211_tx_info, driver_rates));
  555. BUILD_BUG_ON(offsetof(struct ieee80211_tx_info, status.rates) != 8);
  556. /* clear the rate counts */
  557. for (i = 0; i < IEEE80211_TX_MAX_RATES; i++)
  558. info->status.rates[i].count = 0;
  559. BUILD_BUG_ON(
  560. offsetof(struct ieee80211_tx_info, status.ampdu_ack_len) != 23);
  561. memset(&info->status.ampdu_ack_len, 0,
  562. sizeof(struct ieee80211_tx_info) -
  563. offsetof(struct ieee80211_tx_info, status.ampdu_ack_len));
  564. }
  565. /**
  566. * enum mac80211_rx_flags - receive flags
  567. *
  568. * These flags are used with the @flag member of &struct ieee80211_rx_status.
  569. * @RX_FLAG_MMIC_ERROR: Michael MIC error was reported on this frame.
  570. * Use together with %RX_FLAG_MMIC_STRIPPED.
  571. * @RX_FLAG_DECRYPTED: This frame was decrypted in hardware.
  572. * @RX_FLAG_MMIC_STRIPPED: the Michael MIC is stripped off this frame,
  573. * verification has been done by the hardware.
  574. * @RX_FLAG_IV_STRIPPED: The IV/ICV are stripped from this frame.
  575. * If this flag is set, the stack cannot do any replay detection
  576. * hence the driver or hardware will have to do that.
  577. * @RX_FLAG_FAILED_FCS_CRC: Set this flag if the FCS check failed on
  578. * the frame.
  579. * @RX_FLAG_FAILED_PLCP_CRC: Set this flag if the PCLP check failed on
  580. * the frame.
  581. * @RX_FLAG_MACTIME_MPDU: The timestamp passed in the RX status (@mactime
  582. * field) is valid and contains the time the first symbol of the MPDU
  583. * was received. This is useful in monitor mode and for proper IBSS
  584. * merging.
  585. * @RX_FLAG_SHORTPRE: Short preamble was used for this frame
  586. * @RX_FLAG_HT: HT MCS was used and rate_idx is MCS index
  587. * @RX_FLAG_40MHZ: HT40 (40 MHz) was used
  588. * @RX_FLAG_SHORT_GI: Short guard interval was used
  589. */
  590. enum mac80211_rx_flags {
  591. RX_FLAG_MMIC_ERROR = 1<<0,
  592. RX_FLAG_DECRYPTED = 1<<1,
  593. RX_FLAG_MMIC_STRIPPED = 1<<3,
  594. RX_FLAG_IV_STRIPPED = 1<<4,
  595. RX_FLAG_FAILED_FCS_CRC = 1<<5,
  596. RX_FLAG_FAILED_PLCP_CRC = 1<<6,
  597. RX_FLAG_MACTIME_MPDU = 1<<7,
  598. RX_FLAG_SHORTPRE = 1<<8,
  599. RX_FLAG_HT = 1<<9,
  600. RX_FLAG_40MHZ = 1<<10,
  601. RX_FLAG_SHORT_GI = 1<<11,
  602. };
  603. /**
  604. * struct ieee80211_rx_status - receive status
  605. *
  606. * The low-level driver should provide this information (the subset
  607. * supported by hardware) to the 802.11 code with each received
  608. * frame, in the skb's control buffer (cb).
  609. *
  610. * @mactime: value in microseconds of the 64-bit Time Synchronization Function
  611. * (TSF) timer when the first data symbol (MPDU) arrived at the hardware.
  612. * @band: the active band when this frame was received
  613. * @freq: frequency the radio was tuned to when receiving this frame, in MHz
  614. * @signal: signal strength when receiving this frame, either in dBm, in dB or
  615. * unspecified depending on the hardware capabilities flags
  616. * @IEEE80211_HW_SIGNAL_*
  617. * @antenna: antenna used
  618. * @rate_idx: index of data rate into band's supported rates or MCS index if
  619. * HT rates are use (RX_FLAG_HT)
  620. * @flag: %RX_FLAG_*
  621. * @rx_flags: internal RX flags for mac80211
  622. */
  623. struct ieee80211_rx_status {
  624. u64 mactime;
  625. enum ieee80211_band band;
  626. int freq;
  627. int signal;
  628. int antenna;
  629. int rate_idx;
  630. int flag;
  631. unsigned int rx_flags;
  632. };
  633. /**
  634. * enum ieee80211_conf_flags - configuration flags
  635. *
  636. * Flags to define PHY configuration options
  637. *
  638. * @IEEE80211_CONF_MONITOR: there's a monitor interface present -- use this
  639. * to determine for example whether to calculate timestamps for packets
  640. * or not, do not use instead of filter flags!
  641. * @IEEE80211_CONF_PS: Enable 802.11 power save mode (managed mode only).
  642. * This is the power save mode defined by IEEE 802.11-2007 section 11.2,
  643. * meaning that the hardware still wakes up for beacons, is able to
  644. * transmit frames and receive the possible acknowledgment frames.
  645. * Not to be confused with hardware specific wakeup/sleep states,
  646. * driver is responsible for that. See the section "Powersave support"
  647. * for more.
  648. * @IEEE80211_CONF_IDLE: The device is running, but idle; if the flag is set
  649. * the driver should be prepared to handle configuration requests but
  650. * may turn the device off as much as possible. Typically, this flag will
  651. * be set when an interface is set UP but not associated or scanning, but
  652. * it can also be unset in that case when monitor interfaces are active.
  653. * @IEEE80211_CONF_OFFCHANNEL: The device is currently not on its main
  654. * operating channel.
  655. */
  656. enum ieee80211_conf_flags {
  657. IEEE80211_CONF_MONITOR = (1<<0),
  658. IEEE80211_CONF_PS = (1<<1),
  659. IEEE80211_CONF_IDLE = (1<<2),
  660. IEEE80211_CONF_OFFCHANNEL = (1<<3),
  661. };
  662. /**
  663. * enum ieee80211_conf_changed - denotes which configuration changed
  664. *
  665. * @IEEE80211_CONF_CHANGE_LISTEN_INTERVAL: the listen interval changed
  666. * @IEEE80211_CONF_CHANGE_MONITOR: the monitor flag changed
  667. * @IEEE80211_CONF_CHANGE_PS: the PS flag or dynamic PS timeout changed
  668. * @IEEE80211_CONF_CHANGE_POWER: the TX power changed
  669. * @IEEE80211_CONF_CHANGE_CHANNEL: the channel/channel_type changed
  670. * @IEEE80211_CONF_CHANGE_RETRY_LIMITS: retry limits changed
  671. * @IEEE80211_CONF_CHANGE_IDLE: Idle flag changed
  672. * @IEEE80211_CONF_CHANGE_SMPS: Spatial multiplexing powersave mode changed
  673. */
  674. enum ieee80211_conf_changed {
  675. IEEE80211_CONF_CHANGE_SMPS = BIT(1),
  676. IEEE80211_CONF_CHANGE_LISTEN_INTERVAL = BIT(2),
  677. IEEE80211_CONF_CHANGE_MONITOR = BIT(3),
  678. IEEE80211_CONF_CHANGE_PS = BIT(4),
  679. IEEE80211_CONF_CHANGE_POWER = BIT(5),
  680. IEEE80211_CONF_CHANGE_CHANNEL = BIT(6),
  681. IEEE80211_CONF_CHANGE_RETRY_LIMITS = BIT(7),
  682. IEEE80211_CONF_CHANGE_IDLE = BIT(8),
  683. };
  684. /**
  685. * enum ieee80211_smps_mode - spatial multiplexing power save mode
  686. *
  687. * @IEEE80211_SMPS_AUTOMATIC: automatic
  688. * @IEEE80211_SMPS_OFF: off
  689. * @IEEE80211_SMPS_STATIC: static
  690. * @IEEE80211_SMPS_DYNAMIC: dynamic
  691. * @IEEE80211_SMPS_NUM_MODES: internal, don't use
  692. */
  693. enum ieee80211_smps_mode {
  694. IEEE80211_SMPS_AUTOMATIC,
  695. IEEE80211_SMPS_OFF,
  696. IEEE80211_SMPS_STATIC,
  697. IEEE80211_SMPS_DYNAMIC,
  698. /* keep last */
  699. IEEE80211_SMPS_NUM_MODES,
  700. };
  701. /**
  702. * struct ieee80211_conf - configuration of the device
  703. *
  704. * This struct indicates how the driver shall configure the hardware.
  705. *
  706. * @flags: configuration flags defined above
  707. *
  708. * @listen_interval: listen interval in units of beacon interval
  709. * @max_sleep_period: the maximum number of beacon intervals to sleep for
  710. * before checking the beacon for a TIM bit (managed mode only); this
  711. * value will be only achievable between DTIM frames, the hardware
  712. * needs to check for the multicast traffic bit in DTIM beacons.
  713. * This variable is valid only when the CONF_PS flag is set.
  714. * @ps_dtim_period: The DTIM period of the AP we're connected to, for use
  715. * in power saving. Power saving will not be enabled until a beacon
  716. * has been received and the DTIM period is known.
  717. * @dynamic_ps_timeout: The dynamic powersave timeout (in ms), see the
  718. * powersave documentation below. This variable is valid only when
  719. * the CONF_PS flag is set.
  720. *
  721. * @power_level: requested transmit power (in dBm)
  722. *
  723. * @channel: the channel to tune to
  724. * @channel_type: the channel (HT) type
  725. *
  726. * @long_frame_max_tx_count: Maximum number of transmissions for a "long" frame
  727. * (a frame not RTS protected), called "dot11LongRetryLimit" in 802.11,
  728. * but actually means the number of transmissions not the number of retries
  729. * @short_frame_max_tx_count: Maximum number of transmissions for a "short"
  730. * frame, called "dot11ShortRetryLimit" in 802.11, but actually means the
  731. * number of transmissions not the number of retries
  732. *
  733. * @smps_mode: spatial multiplexing powersave mode; note that
  734. * %IEEE80211_SMPS_STATIC is used when the device is not
  735. * configured for an HT channel
  736. */
  737. struct ieee80211_conf {
  738. u32 flags;
  739. int power_level, dynamic_ps_timeout;
  740. int max_sleep_period;
  741. u16 listen_interval;
  742. u8 ps_dtim_period;
  743. u8 long_frame_max_tx_count, short_frame_max_tx_count;
  744. struct ieee80211_channel *channel;
  745. enum nl80211_channel_type channel_type;
  746. enum ieee80211_smps_mode smps_mode;
  747. };
  748. /**
  749. * struct ieee80211_channel_switch - holds the channel switch data
  750. *
  751. * The information provided in this structure is required for channel switch
  752. * operation.
  753. *
  754. * @timestamp: value in microseconds of the 64-bit Time Synchronization
  755. * Function (TSF) timer when the frame containing the channel switch
  756. * announcement was received. This is simply the rx.mactime parameter
  757. * the driver passed into mac80211.
  758. * @block_tx: Indicates whether transmission must be blocked before the
  759. * scheduled channel switch, as indicated by the AP.
  760. * @channel: the new channel to switch to
  761. * @count: the number of TBTT's until the channel switch event
  762. */
  763. struct ieee80211_channel_switch {
  764. u64 timestamp;
  765. bool block_tx;
  766. struct ieee80211_channel *channel;
  767. u8 count;
  768. };
  769. /**
  770. * struct ieee80211_vif - per-interface data
  771. *
  772. * Data in this structure is continually present for driver
  773. * use during the life of a virtual interface.
  774. *
  775. * @type: type of this virtual interface
  776. * @bss_conf: BSS configuration for this interface, either our own
  777. * or the BSS we're associated to
  778. * @addr: address of this interface
  779. * @p2p: indicates whether this AP or STA interface is a p2p
  780. * interface, i.e. a GO or p2p-sta respectively
  781. * @drv_priv: data area for driver use, will always be aligned to
  782. * sizeof(void *).
  783. */
  784. struct ieee80211_vif {
  785. enum nl80211_iftype type;
  786. struct ieee80211_bss_conf bss_conf;
  787. u8 addr[ETH_ALEN];
  788. bool p2p;
  789. /* must be last */
  790. u8 drv_priv[0] __attribute__((__aligned__(sizeof(void *))));
  791. };
  792. static inline bool ieee80211_vif_is_mesh(struct ieee80211_vif *vif)
  793. {
  794. #ifdef CONFIG_MAC80211_MESH
  795. return vif->type == NL80211_IFTYPE_MESH_POINT;
  796. #endif
  797. return false;
  798. }
  799. /**
  800. * enum ieee80211_key_flags - key flags
  801. *
  802. * These flags are used for communication about keys between the driver
  803. * and mac80211, with the @flags parameter of &struct ieee80211_key_conf.
  804. *
  805. * @IEEE80211_KEY_FLAG_WMM_STA: Set by mac80211, this flag indicates
  806. * that the STA this key will be used with could be using QoS.
  807. * @IEEE80211_KEY_FLAG_GENERATE_IV: This flag should be set by the
  808. * driver to indicate that it requires IV generation for this
  809. * particular key.
  810. * @IEEE80211_KEY_FLAG_GENERATE_MMIC: This flag should be set by
  811. * the driver for a TKIP key if it requires Michael MIC
  812. * generation in software.
  813. * @IEEE80211_KEY_FLAG_PAIRWISE: Set by mac80211, this flag indicates
  814. * that the key is pairwise rather then a shared key.
  815. * @IEEE80211_KEY_FLAG_SW_MGMT: This flag should be set by the driver for a
  816. * CCMP key if it requires CCMP encryption of management frames (MFP) to
  817. * be done in software.
  818. */
  819. enum ieee80211_key_flags {
  820. IEEE80211_KEY_FLAG_WMM_STA = 1<<0,
  821. IEEE80211_KEY_FLAG_GENERATE_IV = 1<<1,
  822. IEEE80211_KEY_FLAG_GENERATE_MMIC= 1<<2,
  823. IEEE80211_KEY_FLAG_PAIRWISE = 1<<3,
  824. IEEE80211_KEY_FLAG_SW_MGMT = 1<<4,
  825. };
  826. /**
  827. * struct ieee80211_key_conf - key information
  828. *
  829. * This key information is given by mac80211 to the driver by
  830. * the set_key() callback in &struct ieee80211_ops.
  831. *
  832. * @hw_key_idx: To be set by the driver, this is the key index the driver
  833. * wants to be given when a frame is transmitted and needs to be
  834. * encrypted in hardware.
  835. * @cipher: The key's cipher suite selector.
  836. * @flags: key flags, see &enum ieee80211_key_flags.
  837. * @keyidx: the key index (0-3)
  838. * @keylen: key material length
  839. * @key: key material. For ALG_TKIP the key is encoded as a 256-bit (32 byte)
  840. * data block:
  841. * - Temporal Encryption Key (128 bits)
  842. * - Temporal Authenticator Tx MIC Key (64 bits)
  843. * - Temporal Authenticator Rx MIC Key (64 bits)
  844. * @icv_len: The ICV length for this key type
  845. * @iv_len: The IV length for this key type
  846. */
  847. struct ieee80211_key_conf {
  848. u32 cipher;
  849. u8 icv_len;
  850. u8 iv_len;
  851. u8 hw_key_idx;
  852. u8 flags;
  853. s8 keyidx;
  854. u8 keylen;
  855. u8 key[0];
  856. };
  857. /**
  858. * enum set_key_cmd - key command
  859. *
  860. * Used with the set_key() callback in &struct ieee80211_ops, this
  861. * indicates whether a key is being removed or added.
  862. *
  863. * @SET_KEY: a key is set
  864. * @DISABLE_KEY: a key must be disabled
  865. */
  866. enum set_key_cmd {
  867. SET_KEY, DISABLE_KEY,
  868. };
  869. /**
  870. * struct ieee80211_sta - station table entry
  871. *
  872. * A station table entry represents a station we are possibly
  873. * communicating with. Since stations are RCU-managed in
  874. * mac80211, any ieee80211_sta pointer you get access to must
  875. * either be protected by rcu_read_lock() explicitly or implicitly,
  876. * or you must take good care to not use such a pointer after a
  877. * call to your sta_remove callback that removed it.
  878. *
  879. * @addr: MAC address
  880. * @aid: AID we assigned to the station if we're an AP
  881. * @supp_rates: Bitmap of supported rates (per band)
  882. * @ht_cap: HT capabilities of this STA; restricted to our own TX capabilities
  883. * @wme: indicates whether the STA supports WME. Only valid during AP-mode.
  884. * @drv_priv: data area for driver use, will always be aligned to
  885. * sizeof(void *), size is determined in hw information.
  886. */
  887. struct ieee80211_sta {
  888. u32 supp_rates[IEEE80211_NUM_BANDS];
  889. u8 addr[ETH_ALEN];
  890. u16 aid;
  891. struct ieee80211_sta_ht_cap ht_cap;
  892. bool wme;
  893. /* must be last */
  894. u8 drv_priv[0] __attribute__((__aligned__(sizeof(void *))));
  895. };
  896. /**
  897. * enum sta_notify_cmd - sta notify command
  898. *
  899. * Used with the sta_notify() callback in &struct ieee80211_ops, this
  900. * indicates if an associated station made a power state transition.
  901. *
  902. * @STA_NOTIFY_SLEEP: a station is now sleeping
  903. * @STA_NOTIFY_AWAKE: a sleeping station woke up
  904. */
  905. enum sta_notify_cmd {
  906. STA_NOTIFY_SLEEP, STA_NOTIFY_AWAKE,
  907. };
  908. /**
  909. * enum ieee80211_hw_flags - hardware flags
  910. *
  911. * These flags are used to indicate hardware capabilities to
  912. * the stack. Generally, flags here should have their meaning
  913. * done in a way that the simplest hardware doesn't need setting
  914. * any particular flags. There are some exceptions to this rule,
  915. * however, so you are advised to review these flags carefully.
  916. *
  917. * @IEEE80211_HW_HAS_RATE_CONTROL:
  918. * The hardware or firmware includes rate control, and cannot be
  919. * controlled by the stack. As such, no rate control algorithm
  920. * should be instantiated, and the TX rate reported to userspace
  921. * will be taken from the TX status instead of the rate control
  922. * algorithm.
  923. * Note that this requires that the driver implement a number of
  924. * callbacks so it has the correct information, it needs to have
  925. * the @set_rts_threshold callback and must look at the BSS config
  926. * @use_cts_prot for G/N protection, @use_short_slot for slot
  927. * timing in 2.4 GHz and @use_short_preamble for preambles for
  928. * CCK frames.
  929. *
  930. * @IEEE80211_HW_RX_INCLUDES_FCS:
  931. * Indicates that received frames passed to the stack include
  932. * the FCS at the end.
  933. *
  934. * @IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING:
  935. * Some wireless LAN chipsets buffer broadcast/multicast frames
  936. * for power saving stations in the hardware/firmware and others
  937. * rely on the host system for such buffering. This option is used
  938. * to configure the IEEE 802.11 upper layer to buffer broadcast and
  939. * multicast frames when there are power saving stations so that
  940. * the driver can fetch them with ieee80211_get_buffered_bc().
  941. *
  942. * @IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE:
  943. * Hardware is not capable of short slot operation on the 2.4 GHz band.
  944. *
  945. * @IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE:
  946. * Hardware is not capable of receiving frames with short preamble on
  947. * the 2.4 GHz band.
  948. *
  949. * @IEEE80211_HW_SIGNAL_UNSPEC:
  950. * Hardware can provide signal values but we don't know its units. We
  951. * expect values between 0 and @max_signal.
  952. * If possible please provide dB or dBm instead.
  953. *
  954. * @IEEE80211_HW_SIGNAL_DBM:
  955. * Hardware gives signal values in dBm, decibel difference from
  956. * one milliwatt. This is the preferred method since it is standardized
  957. * between different devices. @max_signal does not need to be set.
  958. *
  959. * @IEEE80211_HW_SPECTRUM_MGMT:
  960. * Hardware supports spectrum management defined in 802.11h
  961. * Measurement, Channel Switch, Quieting, TPC
  962. *
  963. * @IEEE80211_HW_AMPDU_AGGREGATION:
  964. * Hardware supports 11n A-MPDU aggregation.
  965. *
  966. * @IEEE80211_HW_SUPPORTS_PS:
  967. * Hardware has power save support (i.e. can go to sleep).
  968. *
  969. * @IEEE80211_HW_PS_NULLFUNC_STACK:
  970. * Hardware requires nullfunc frame handling in stack, implies
  971. * stack support for dynamic PS.
  972. *
  973. * @IEEE80211_HW_SUPPORTS_DYNAMIC_PS:
  974. * Hardware has support for dynamic PS.
  975. *
  976. * @IEEE80211_HW_MFP_CAPABLE:
  977. * Hardware supports management frame protection (MFP, IEEE 802.11w).
  978. *
  979. * @IEEE80211_HW_BEACON_FILTER:
  980. * Hardware supports dropping of irrelevant beacon frames to
  981. * avoid waking up cpu.
  982. *
  983. * @IEEE80211_HW_SUPPORTS_STATIC_SMPS:
  984. * Hardware supports static spatial multiplexing powersave,
  985. * ie. can turn off all but one chain even on HT connections
  986. * that should be using more chains.
  987. *
  988. * @IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS:
  989. * Hardware supports dynamic spatial multiplexing powersave,
  990. * ie. can turn off all but one chain and then wake the rest
  991. * up as required after, for example, rts/cts handshake.
  992. *
  993. * @IEEE80211_HW_SUPPORTS_UAPSD:
  994. * Hardware supports Unscheduled Automatic Power Save Delivery
  995. * (U-APSD) in managed mode. The mode is configured with
  996. * conf_tx() operation.
  997. *
  998. * @IEEE80211_HW_REPORTS_TX_ACK_STATUS:
  999. * Hardware can provide ack status reports of Tx frames to
  1000. * the stack.
  1001. *
  1002. * @IEEE80211_HW_CONNECTION_MONITOR:
  1003. * The hardware performs its own connection monitoring, including
  1004. * periodic keep-alives to the AP and probing the AP on beacon loss.
  1005. * When this flag is set, signaling beacon-loss will cause an immediate
  1006. * change to disassociated state.
  1007. *
  1008. * @IEEE80211_HW_SUPPORTS_CQM_RSSI:
  1009. * Hardware can do connection quality monitoring - i.e. it can monitor
  1010. * connection quality related parameters, such as the RSSI level and
  1011. * provide notifications if configured trigger levels are reached.
  1012. *
  1013. * @IEEE80211_HW_NEED_DTIM_PERIOD:
  1014. * This device needs to know the DTIM period for the BSS before
  1015. * associating.
  1016. *
  1017. * @IEEE80211_HW_SUPPORTS_PER_STA_GTK: The device's crypto engine supports
  1018. * per-station GTKs as used by IBSS RSN or during fast transition. If
  1019. * the device doesn't support per-station GTKs, but can be asked not
  1020. * to decrypt group addressed frames, then IBSS RSN support is still
  1021. * possible but software crypto will be used. Advertise the wiphy flag
  1022. * only in that case.
  1023. *
  1024. * @IEEE80211_HW_AP_LINK_PS: When operating in AP mode the device
  1025. * autonomously manages the PS status of connected stations. When
  1026. * this flag is set mac80211 will not trigger PS mode for connected
  1027. * stations based on the PM bit of incoming frames.
  1028. * Use ieee80211_start_ps()/ieee8021_end_ps() to manually configure
  1029. * the PS mode of connected stations.
  1030. */
  1031. enum ieee80211_hw_flags {
  1032. IEEE80211_HW_HAS_RATE_CONTROL = 1<<0,
  1033. IEEE80211_HW_RX_INCLUDES_FCS = 1<<1,
  1034. IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING = 1<<2,
  1035. IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE = 1<<3,
  1036. IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE = 1<<4,
  1037. IEEE80211_HW_SIGNAL_UNSPEC = 1<<5,
  1038. IEEE80211_HW_SIGNAL_DBM = 1<<6,
  1039. IEEE80211_HW_NEED_DTIM_PERIOD = 1<<7,
  1040. IEEE80211_HW_SPECTRUM_MGMT = 1<<8,
  1041. IEEE80211_HW_AMPDU_AGGREGATION = 1<<9,
  1042. IEEE80211_HW_SUPPORTS_PS = 1<<10,
  1043. IEEE80211_HW_PS_NULLFUNC_STACK = 1<<11,
  1044. IEEE80211_HW_SUPPORTS_DYNAMIC_PS = 1<<12,
  1045. IEEE80211_HW_MFP_CAPABLE = 1<<13,
  1046. IEEE80211_HW_BEACON_FILTER = 1<<14,
  1047. IEEE80211_HW_SUPPORTS_STATIC_SMPS = 1<<15,
  1048. IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS = 1<<16,
  1049. IEEE80211_HW_SUPPORTS_UAPSD = 1<<17,
  1050. IEEE80211_HW_REPORTS_TX_ACK_STATUS = 1<<18,
  1051. IEEE80211_HW_CONNECTION_MONITOR = 1<<19,
  1052. IEEE80211_HW_SUPPORTS_CQM_RSSI = 1<<20,
  1053. IEEE80211_HW_SUPPORTS_PER_STA_GTK = 1<<21,
  1054. IEEE80211_HW_AP_LINK_PS = 1<<22,
  1055. };
  1056. /**
  1057. * struct ieee80211_hw - hardware information and state
  1058. *
  1059. * This structure contains the configuration and hardware
  1060. * information for an 802.11 PHY.
  1061. *
  1062. * @wiphy: This points to the &struct wiphy allocated for this
  1063. * 802.11 PHY. You must fill in the @perm_addr and @dev
  1064. * members of this structure using SET_IEEE80211_DEV()
  1065. * and SET_IEEE80211_PERM_ADDR(). Additionally, all supported
  1066. * bands (with channels, bitrates) are registered here.
  1067. *
  1068. * @conf: &struct ieee80211_conf, device configuration, don't use.
  1069. *
  1070. * @priv: pointer to private area that was allocated for driver use
  1071. * along with this structure.
  1072. *
  1073. * @flags: hardware flags, see &enum ieee80211_hw_flags.
  1074. *
  1075. * @extra_tx_headroom: headroom to reserve in each transmit skb
  1076. * for use by the driver (e.g. for transmit headers.)
  1077. *
  1078. * @channel_change_time: time (in microseconds) it takes to change channels.
  1079. *
  1080. * @max_signal: Maximum value for signal (rssi) in RX information, used
  1081. * only when @IEEE80211_HW_SIGNAL_UNSPEC or @IEEE80211_HW_SIGNAL_DB
  1082. *
  1083. * @max_listen_interval: max listen interval in units of beacon interval
  1084. * that HW supports
  1085. *
  1086. * @queues: number of available hardware transmit queues for
  1087. * data packets. WMM/QoS requires at least four, these
  1088. * queues need to have configurable access parameters.
  1089. *
  1090. * @rate_control_algorithm: rate control algorithm for this hardware.
  1091. * If unset (NULL), the default algorithm will be used. Must be
  1092. * set before calling ieee80211_register_hw().
  1093. *
  1094. * @vif_data_size: size (in bytes) of the drv_priv data area
  1095. * within &struct ieee80211_vif.
  1096. * @sta_data_size: size (in bytes) of the drv_priv data area
  1097. * within &struct ieee80211_sta.
  1098. *
  1099. * @max_rates: maximum number of alternate rate retry stages the hw
  1100. * can handle.
  1101. * @max_report_rates: maximum number of alternate rate retry stages
  1102. * the hw can report back.
  1103. * @max_rate_tries: maximum number of tries for each stage
  1104. *
  1105. * @napi_weight: weight used for NAPI polling. You must specify an
  1106. * appropriate value here if a napi_poll operation is provided
  1107. * by your driver.
  1108. *
  1109. * @max_rx_aggregation_subframes: maximum buffer size (number of
  1110. * sub-frames) to be used for A-MPDU block ack receiver
  1111. * aggregation.
  1112. * This is only relevant if the device has restrictions on the
  1113. * number of subframes, if it relies on mac80211 to do reordering
  1114. * it shouldn't be set.
  1115. *
  1116. * @max_tx_aggregation_subframes: maximum number of subframes in an
  1117. * aggregate an HT driver will transmit, used by the peer as a
  1118. * hint to size its reorder buffer.
  1119. */
  1120. struct ieee80211_hw {
  1121. struct ieee80211_conf conf;
  1122. struct wiphy *wiphy;
  1123. const char *rate_control_algorithm;
  1124. void *priv;
  1125. u32 flags;
  1126. unsigned int extra_tx_headroom;
  1127. int channel_change_time;
  1128. int vif_data_size;
  1129. int sta_data_size;
  1130. int napi_weight;
  1131. u16 queues;
  1132. u16 max_listen_interval;
  1133. s8 max_signal;
  1134. u8 max_rates;
  1135. u8 max_report_rates;
  1136. u8 max_rate_tries;
  1137. u8 max_rx_aggregation_subframes;
  1138. u8 max_tx_aggregation_subframes;
  1139. };
  1140. /**
  1141. * wiphy_to_ieee80211_hw - return a mac80211 driver hw struct from a wiphy
  1142. *
  1143. * @wiphy: the &struct wiphy which we want to query
  1144. *
  1145. * mac80211 drivers can use this to get to their respective
  1146. * &struct ieee80211_hw. Drivers wishing to get to their own private
  1147. * structure can then access it via hw->priv. Note that mac802111 drivers should
  1148. * not use wiphy_priv() to try to get their private driver structure as this
  1149. * is already used internally by mac80211.
  1150. */
  1151. struct ieee80211_hw *wiphy_to_ieee80211_hw(struct wiphy *wiphy);
  1152. /**
  1153. * SET_IEEE80211_DEV - set device for 802.11 hardware
  1154. *
  1155. * @hw: the &struct ieee80211_hw to set the device for
  1156. * @dev: the &struct device of this 802.11 device
  1157. */
  1158. static inline void SET_IEEE80211_DEV(struct ieee80211_hw *hw, struct device *dev)
  1159. {
  1160. set_wiphy_dev(hw->wiphy, dev);
  1161. }
  1162. /**
  1163. * SET_IEEE80211_PERM_ADDR - set the permanent MAC address for 802.11 hardware
  1164. *
  1165. * @hw: the &struct ieee80211_hw to set the MAC address for
  1166. * @addr: the address to set
  1167. */
  1168. static inline void SET_IEEE80211_PERM_ADDR(struct ieee80211_hw *hw, u8 *addr)
  1169. {
  1170. memcpy(hw->wiphy->perm_addr, addr, ETH_ALEN);
  1171. }
  1172. static inline struct ieee80211_rate *
  1173. ieee80211_get_tx_rate(const struct ieee80211_hw *hw,
  1174. const struct ieee80211_tx_info *c)
  1175. {
  1176. if (WARN_ON(c->control.rates[0].idx < 0))
  1177. return NULL;
  1178. return &hw->wiphy->bands[c->band]->bitrates[c->control.rates[0].idx];
  1179. }
  1180. static inline struct ieee80211_rate *
  1181. ieee80211_get_rts_cts_rate(const struct ieee80211_hw *hw,
  1182. const struct ieee80211_tx_info *c)
  1183. {
  1184. if (c->control.rts_cts_rate_idx < 0)
  1185. return NULL;
  1186. return &hw->wiphy->bands[c->band]->bitrates[c->control.rts_cts_rate_idx];
  1187. }
  1188. static inline struct ieee80211_rate *
  1189. ieee80211_get_alt_retry_rate(const struct ieee80211_hw *hw,
  1190. const struct ieee80211_tx_info *c, int idx)
  1191. {
  1192. if (c->control.rates[idx + 1].idx < 0)
  1193. return NULL;
  1194. return &hw->wiphy->bands[c->band]->bitrates[c->control.rates[idx + 1].idx];
  1195. }
  1196. /**
  1197. * DOC: Hardware crypto acceleration
  1198. *
  1199. * mac80211 is capable of taking advantage of many hardware
  1200. * acceleration designs for encryption and decryption operations.
  1201. *
  1202. * The set_key() callback in the &struct ieee80211_ops for a given
  1203. * device is called to enable hardware acceleration of encryption and
  1204. * decryption. The callback takes a @sta parameter that will be NULL
  1205. * for default keys or keys used for transmission only, or point to
  1206. * the station information for the peer for individual keys.
  1207. * Multiple transmission keys with the same key index may be used when
  1208. * VLANs are configured for an access point.
  1209. *
  1210. * When transmitting, the TX control data will use the @hw_key_idx
  1211. * selected by the driver by modifying the &struct ieee80211_key_conf
  1212. * pointed to by the @key parameter to the set_key() function.
  1213. *
  1214. * The set_key() call for the %SET_KEY command should return 0 if
  1215. * the key is now in use, -%EOPNOTSUPP or -%ENOSPC if it couldn't be
  1216. * added; if you return 0 then hw_key_idx must be assigned to the
  1217. * hardware key index, you are free to use the full u8 range.
  1218. *
  1219. * When the cmd is %DISABLE_KEY then it must succeed.
  1220. *
  1221. * Note that it is permissible to not decrypt a frame even if a key
  1222. * for it has been uploaded to hardware, the stack will not make any
  1223. * decision based on whether a key has been uploaded or not but rather
  1224. * based on the receive flags.
  1225. *
  1226. * The &struct ieee80211_key_conf structure pointed to by the @key
  1227. * parameter is guaranteed to be valid until another call to set_key()
  1228. * removes it, but it can only be used as a cookie to differentiate
  1229. * keys.
  1230. *
  1231. * In TKIP some HW need to be provided a phase 1 key, for RX decryption
  1232. * acceleration (i.e. iwlwifi). Those drivers should provide update_tkip_key
  1233. * handler.
  1234. * The update_tkip_key() call updates the driver with the new phase 1 key.
  1235. * This happens every time the iv16 wraps around (every 65536 packets). The
  1236. * set_key() call will happen only once for each key (unless the AP did
  1237. * rekeying), it will not include a valid phase 1 key. The valid phase 1 key is
  1238. * provided by update_tkip_key only. The trigger that makes mac80211 call this
  1239. * handler is software decryption with wrap around of iv16.
  1240. */
  1241. /**
  1242. * DOC: Powersave support
  1243. *
  1244. * mac80211 has support for various powersave implementations.
  1245. *
  1246. * First, it can support hardware that handles all powersaving by itself,
  1247. * such hardware should simply set the %IEEE80211_HW_SUPPORTS_PS hardware
  1248. * flag. In that case, it will be told about the desired powersave mode
  1249. * with the %IEEE80211_CONF_PS flag depending on the association status.
  1250. * The hardware must take care of sending nullfunc frames when necessary,
  1251. * i.e. when entering and leaving powersave mode. The hardware is required
  1252. * to look at the AID in beacons and signal to the AP that it woke up when
  1253. * it finds traffic directed to it.
  1254. *
  1255. * %IEEE80211_CONF_PS flag enabled means that the powersave mode defined in
  1256. * IEEE 802.11-2007 section 11.2 is enabled. This is not to be confused
  1257. * with hardware wakeup and sleep states. Driver is responsible for waking
  1258. * up the hardware before issuing commands to the hardware and putting it
  1259. * back to sleep at appropriate times.
  1260. *
  1261. * When PS is enabled, hardware needs to wakeup for beacons and receive the
  1262. * buffered multicast/broadcast frames after the beacon. Also it must be
  1263. * possible to send frames and receive the acknowledment frame.
  1264. *
  1265. * Other hardware designs cannot send nullfunc frames by themselves and also
  1266. * need software support for parsing the TIM bitmap. This is also supported
  1267. * by mac80211 by combining the %IEEE80211_HW_SUPPORTS_PS and
  1268. * %IEEE80211_HW_PS_NULLFUNC_STACK flags. The hardware is of course still
  1269. * required to pass up beacons. The hardware is still required to handle
  1270. * waking up for multicast traffic; if it cannot the driver must handle that
  1271. * as best as it can, mac80211 is too slow to do that.
  1272. *
  1273. * Dynamic powersave is an extension to normal powersave in which the
  1274. * hardware stays awake for a user-specified period of time after sending a
  1275. * frame so that reply frames need not be buffered and therefore delayed to
  1276. * the next wakeup. It's compromise of getting good enough latency when
  1277. * there's data traffic and still saving significantly power in idle
  1278. * periods.
  1279. *
  1280. * Dynamic powersave is simply supported by mac80211 enabling and disabling
  1281. * PS based on traffic. Driver needs to only set %IEEE80211_HW_SUPPORTS_PS
  1282. * flag and mac80211 will handle everything automatically. Additionally,
  1283. * hardware having support for the dynamic PS feature may set the
  1284. * %IEEE80211_HW_SUPPORTS_DYNAMIC_PS flag to indicate that it can support
  1285. * dynamic PS mode itself. The driver needs to look at the
  1286. * @dynamic_ps_timeout hardware configuration value and use it that value
  1287. * whenever %IEEE80211_CONF_PS is set. In this case mac80211 will disable
  1288. * dynamic PS feature in stack and will just keep %IEEE80211_CONF_PS
  1289. * enabled whenever user has enabled powersave.
  1290. *
  1291. * Some hardware need to toggle a single shared antenna between WLAN and
  1292. * Bluetooth to facilitate co-existence. These types of hardware set
  1293. * limitations on the use of host controlled dynamic powersave whenever there
  1294. * is simultaneous WLAN and Bluetooth traffic. For these types of hardware, the
  1295. * driver may request temporarily going into full power save, in order to
  1296. * enable toggling the antenna between BT and WLAN. If the driver requests
  1297. * disabling dynamic powersave, the @dynamic_ps_timeout value will be
  1298. * temporarily set to zero until the driver re-enables dynamic powersave.
  1299. *
  1300. * Driver informs U-APSD client support by enabling
  1301. * %IEEE80211_HW_SUPPORTS_UAPSD flag. The mode is configured through the
  1302. * uapsd paramater in conf_tx() operation. Hardware needs to send the QoS
  1303. * Nullfunc frames and stay awake until the service period has ended. To
  1304. * utilize U-APSD, dynamic powersave is disabled for voip AC and all frames
  1305. * from that AC are transmitted with powersave enabled.
  1306. *
  1307. * Note: U-APSD client mode is not yet supported with
  1308. * %IEEE80211_HW_PS_NULLFUNC_STACK.
  1309. */
  1310. /**
  1311. * DOC: Beacon filter support
  1312. *
  1313. * Some hardware have beacon filter support to reduce host cpu wakeups
  1314. * which will reduce system power consumption. It usuallly works so that
  1315. * the firmware creates a checksum of the beacon but omits all constantly
  1316. * changing elements (TSF, TIM etc). Whenever the checksum changes the
  1317. * beacon is forwarded to the host, otherwise it will be just dropped. That
  1318. * way the host will only receive beacons where some relevant information
  1319. * (for example ERP protection or WMM settings) have changed.
  1320. *
  1321. * Beacon filter support is advertised with the %IEEE80211_HW_BEACON_FILTER
  1322. * hardware capability. The driver needs to enable beacon filter support
  1323. * whenever power save is enabled, that is %IEEE80211_CONF_PS is set. When
  1324. * power save is enabled, the stack will not check for beacon loss and the
  1325. * driver needs to notify about loss of beacons with ieee80211_beacon_loss().
  1326. *
  1327. * The time (or number of beacons missed) until the firmware notifies the
  1328. * driver of a beacon loss event (which in turn causes the driver to call
  1329. * ieee80211_beacon_loss()) should be configurable and will be controlled
  1330. * by mac80211 and the roaming algorithm in the future.
  1331. *
  1332. * Since there may be constantly changing information elements that nothing
  1333. * in the software stack cares about, we will, in the future, have mac80211
  1334. * tell the driver which information elements are interesting in the sense
  1335. * that we want to see changes in them. This will include
  1336. * - a list of information element IDs
  1337. * - a list of OUIs for the vendor information element
  1338. *
  1339. * Ideally, the hardware would filter out any beacons without changes in the
  1340. * requested elements, but if it cannot support that it may, at the expense
  1341. * of some efficiency, filter out only a subset. For example, if the device
  1342. * doesn't support checking for OUIs it should pass up all changes in all
  1343. * vendor information elements.
  1344. *
  1345. * Note that change, for the sake of simplification, also includes information
  1346. * elements appearing or disappearing from the beacon.
  1347. *
  1348. * Some hardware supports an "ignore list" instead, just make sure nothing
  1349. * that was requested is on the ignore list, and include commonly changing
  1350. * information element IDs in the ignore list, for example 11 (BSS load) and
  1351. * the various vendor-assigned IEs with unknown contents (128, 129, 133-136,
  1352. * 149, 150, 155, 156, 173, 176, 178, 179, 219); for forward compatibility
  1353. * it could also include some currently unused IDs.
  1354. *
  1355. *
  1356. * In addition to these capabilities, hardware should support notifying the
  1357. * host of changes in the beacon RSSI. This is relevant to implement roaming
  1358. * when no traffic is flowing (when traffic is flowing we see the RSSI of
  1359. * the received data packets). This can consist in notifying the host when
  1360. * the RSSI changes significantly or when it drops below or rises above
  1361. * configurable thresholds. In the future these thresholds will also be
  1362. * configured by mac80211 (which gets them from userspace) to implement
  1363. * them as the roaming algorithm requires.
  1364. *
  1365. * If the hardware cannot implement this, the driver should ask it to
  1366. * periodically pass beacon frames to the host so that software can do the
  1367. * signal strength threshold checking.
  1368. */
  1369. /**
  1370. * DOC: Spatial multiplexing power save
  1371. *
  1372. * SMPS (Spatial multiplexing power save) is a mechanism to conserve
  1373. * power in an 802.11n implementation. For details on the mechanism
  1374. * and rationale, please refer to 802.11 (as amended by 802.11n-2009)
  1375. * "11.2.3 SM power save".
  1376. *
  1377. * The mac80211 implementation is capable of sending action frames
  1378. * to update the AP about the station's SMPS mode, and will instruct
  1379. * the driver to enter the specific mode. It will also announce the
  1380. * requested SMPS mode during the association handshake. Hardware
  1381. * support for this feature is required, and can be indicated by
  1382. * hardware flags.
  1383. *
  1384. * The default mode will be "automatic", which nl80211/cfg80211
  1385. * defines to be dynamic SMPS in (regular) powersave, and SMPS
  1386. * turned off otherwise.
  1387. *
  1388. * To support this feature, the driver must set the appropriate
  1389. * hardware support flags, and handle the SMPS flag to the config()
  1390. * operation. It will then with this mechanism be instructed to
  1391. * enter the requested SMPS mode while associated to an HT AP.
  1392. */
  1393. /**
  1394. * DOC: Frame filtering
  1395. *
  1396. * mac80211 requires to see many management frames for proper
  1397. * operation, and users may want to see many more frames when
  1398. * in monitor mode. However, for best CPU usage and power consumption,
  1399. * having as few frames as possible percolate through the stack is
  1400. * desirable. Hence, the hardware should filter as much as possible.
  1401. *
  1402. * To achieve this, mac80211 uses filter flags (see below) to tell
  1403. * the driver's configure_filter() function which frames should be
  1404. * passed to mac80211 and which should be filtered out.
  1405. *
  1406. * Before configure_filter() is invoked, the prepare_multicast()
  1407. * callback is invoked with the parameters @mc_count and @mc_list
  1408. * for the combined multicast address list of all virtual interfaces.
  1409. * It's use is optional, and it returns a u64 that is passed to
  1410. * configure_filter(). Additionally, configure_filter() has the
  1411. * arguments @changed_flags telling which flags were changed and
  1412. * @total_flags with the new flag states.
  1413. *
  1414. * If your device has no multicast address filters your driver will
  1415. * need to check both the %FIF_ALLMULTI flag and the @mc_count
  1416. * parameter to see whether multicast frames should be accepted
  1417. * or dropped.
  1418. *
  1419. * All unsupported flags in @total_flags must be cleared.
  1420. * Hardware does not support a flag if it is incapable of _passing_
  1421. * the frame to the stack. Otherwise the driver must ignore
  1422. * the flag, but not clear it.
  1423. * You must _only_ clear the flag (announce no support for the
  1424. * flag to mac80211) if you are not able to pass the packet type
  1425. * to the stack (so the hardware always filters it).
  1426. * So for example, you should clear @FIF_CONTROL, if your hardware
  1427. * always filters control frames. If your hardware always passes
  1428. * control frames to the kernel and is incapable of filtering them,
  1429. * you do _not_ clear the @FIF_CONTROL flag.
  1430. * This rule applies to all other FIF flags as well.
  1431. */
  1432. /**
  1433. * enum ieee80211_filter_flags - hardware filter flags
  1434. *
  1435. * These flags determine what the filter in hardware should be
  1436. * programmed to let through and what should not be passed to the
  1437. * stack. It is always safe to pass more frames than requested,
  1438. * but this has negative impact on power consumption.
  1439. *
  1440. * @FIF_PROMISC_IN_BSS: promiscuous mode within your BSS,
  1441. * think of the BSS as your network segment and then this corresponds
  1442. * to the regular ethernet device promiscuous mode.
  1443. *
  1444. * @FIF_ALLMULTI: pass all multicast frames, this is used if requested
  1445. * by the user or if the hardware is not capable of filtering by
  1446. * multicast address.
  1447. *
  1448. * @FIF_FCSFAIL: pass frames with failed FCS (but you need to set the
  1449. * %RX_FLAG_FAILED_FCS_CRC for them)
  1450. *
  1451. * @FIF_PLCPFAIL: pass frames with failed PLCP CRC (but you need to set
  1452. * the %RX_FLAG_FAILED_PLCP_CRC for them
  1453. *
  1454. * @FIF_BCN_PRBRESP_PROMISC: This flag is set during scanning to indicate
  1455. * to the hardware that it should not filter beacons or probe responses
  1456. * by BSSID. Filtering them can greatly reduce the amount of processing
  1457. * mac80211 needs to do and the amount of CPU wakeups, so you should
  1458. * honour this flag if possible.
  1459. *
  1460. * @FIF_CONTROL: pass control frames (except for PS Poll), if PROMISC_IN_BSS
  1461. * is not set then only those addressed to this station.
  1462. *
  1463. * @FIF_OTHER_BSS: pass frames destined to other BSSes
  1464. *
  1465. * @FIF_PSPOLL: pass PS Poll frames, if PROMISC_IN_BSS is not set then only
  1466. * those addressed to this station.
  1467. *
  1468. * @FIF_PROBE_REQ: pass probe request frames
  1469. */
  1470. enum ieee80211_filter_flags {
  1471. FIF_PROMISC_IN_BSS = 1<<0,
  1472. FIF_ALLMULTI = 1<<1,
  1473. FIF_FCSFAIL = 1<<2,
  1474. FIF_PLCPFAIL = 1<<3,
  1475. FIF_BCN_PRBRESP_PROMISC = 1<<4,
  1476. FIF_CONTROL = 1<<5,
  1477. FIF_OTHER_BSS = 1<<6,
  1478. FIF_PSPOLL = 1<<7,
  1479. FIF_PROBE_REQ = 1<<8,
  1480. };
  1481. /**
  1482. * enum ieee80211_ampdu_mlme_action - A-MPDU actions
  1483. *
  1484. * These flags are used with the ampdu_action() callback in
  1485. * &struct ieee80211_ops to indicate which action is needed.
  1486. *
  1487. * Note that drivers MUST be able to deal with a TX aggregation
  1488. * session being stopped even before they OK'ed starting it by
  1489. * calling ieee80211_start_tx_ba_cb_irqsafe, because the peer
  1490. * might receive the addBA frame and send a delBA right away!
  1491. *
  1492. * @IEEE80211_AMPDU_RX_START: start Rx aggregation
  1493. * @IEEE80211_AMPDU_RX_STOP: stop Rx aggregation
  1494. * @IEEE80211_AMPDU_TX_START: start Tx aggregation
  1495. * @IEEE80211_AMPDU_TX_STOP: stop Tx aggregation
  1496. * @IEEE80211_AMPDU_TX_OPERATIONAL: TX aggregation has become operational
  1497. */
  1498. enum ieee80211_ampdu_mlme_action {
  1499. IEEE80211_AMPDU_RX_START,
  1500. IEEE80211_AMPDU_RX_STOP,
  1501. IEEE80211_AMPDU_TX_START,
  1502. IEEE80211_AMPDU_TX_STOP,
  1503. IEEE80211_AMPDU_TX_OPERATIONAL,
  1504. };
  1505. /**
  1506. * struct ieee80211_ops - callbacks from mac80211 to the driver
  1507. *
  1508. * This structure contains various callbacks that the driver may
  1509. * handle or, in some cases, must handle, for example to configure
  1510. * the hardware to a new channel or to transmit a frame.
  1511. *
  1512. * @tx: Handler that 802.11 module calls for each transmitted frame.
  1513. * skb contains the buffer starting from the IEEE 802.11 header.
  1514. * The low-level driver should send the frame out based on
  1515. * configuration in the TX control data. This handler should,
  1516. * preferably, never fail and stop queues appropriately, more
  1517. * importantly, however, it must never fail for A-MPDU-queues.
  1518. * This function should return NETDEV_TX_OK except in very
  1519. * limited cases.
  1520. * Must be implemented and atomic.
  1521. *
  1522. * @start: Called before the first netdevice attached to the hardware
  1523. * is enabled. This should turn on the hardware and must turn on
  1524. * frame reception (for possibly enabled monitor interfaces.)
  1525. * Returns negative error codes, these may be seen in userspace,
  1526. * or zero.
  1527. * When the device is started it should not have a MAC address
  1528. * to avoid acknowledging frames before a non-monitor device
  1529. * is added.
  1530. * Must be implemented and can sleep.
  1531. *
  1532. * @stop: Called after last netdevice attached to the hardware
  1533. * is disabled. This should turn off the hardware (at least
  1534. * it must turn off frame reception.)
  1535. * May be called right after add_interface if that rejects
  1536. * an interface. If you added any work onto the mac80211 workqueue
  1537. * you should ensure to cancel it on this callback.
  1538. * Must be implemented and can sleep.
  1539. *
  1540. * @suspend: Suspend the device; mac80211 itself will quiesce before and
  1541. * stop transmitting and doing any other configuration, and then
  1542. * ask the device to suspend. This is only invoked when WoWLAN is
  1543. * configured, otherwise the device is deconfigured completely and
  1544. * reconfigured at resume time.
  1545. * The driver may also impose special conditions under which it
  1546. * wants to use the "normal" suspend (deconfigure), say if it only
  1547. * supports WoWLAN when the device is associated. In this case, it
  1548. * must return 1 from this function.
  1549. *
  1550. * @resume: If WoWLAN was configured, this indicates that mac80211 is
  1551. * now resuming its operation, after this the device must be fully
  1552. * functional again. If this returns an error, the only way out is
  1553. * to also unregister the device. If it returns 1, then mac80211
  1554. * will also go through the regular complete restart on resume.
  1555. *
  1556. * @add_interface: Called when a netdevice attached to the hardware is
  1557. * enabled. Because it is not called for monitor mode devices, @start
  1558. * and @stop must be implemented.
  1559. * The driver should perform any initialization it needs before
  1560. * the device can be enabled. The initial configuration for the
  1561. * interface is given in the conf parameter.
  1562. * The callback may refuse to add an interface by returning a
  1563. * negative error code (which will be seen in userspace.)
  1564. * Must be implemented and can sleep.
  1565. *
  1566. * @change_interface: Called when a netdevice changes type. This callback
  1567. * is optional, but only if it is supported can interface types be
  1568. * switched while the interface is UP. The callback may sleep.
  1569. * Note that while an interface is being switched, it will not be
  1570. * found by the interface iteration callbacks.
  1571. *
  1572. * @remove_interface: Notifies a driver that an interface is going down.
  1573. * The @stop callback is called after this if it is the last interface
  1574. * and no monitor interfaces are present.
  1575. * When all interfaces are removed, the MAC address in the hardware
  1576. * must be cleared so the device no longer acknowledges packets,
  1577. * the mac_addr member of the conf structure is, however, set to the
  1578. * MAC address of the device going away.
  1579. * Hence, this callback must be implemented. It can sleep.
  1580. *
  1581. * @config: Handler for configuration requests. IEEE 802.11 code calls this
  1582. * function to change hardware configuration, e.g., channel.
  1583. * This function should never fail but returns a negative error code
  1584. * if it does. The callback can sleep.
  1585. *
  1586. * @bss_info_changed: Handler for configuration requests related to BSS
  1587. * parameters that may vary during BSS's lifespan, and may affect low
  1588. * level driver (e.g. assoc/disassoc status, erp parameters).
  1589. * This function should not be used if no BSS has been set, unless
  1590. * for association indication. The @changed parameter indicates which
  1591. * of the bss parameters has changed when a call is made. The callback
  1592. * can sleep.
  1593. *
  1594. * @prepare_multicast: Prepare for multicast filter configuration.
  1595. * This callback is optional, and its return value is passed
  1596. * to configure_filter(). This callback must be atomic.
  1597. *
  1598. * @configure_filter: Configure the device's RX filter.
  1599. * See the section "Frame filtering" for more information.
  1600. * This callback must be implemented and can sleep.
  1601. *
  1602. * @set_tim: Set TIM bit. mac80211 calls this function when a TIM bit
  1603. * must be set or cleared for a given STA. Must be atomic.
  1604. *
  1605. * @set_key: See the section "Hardware crypto acceleration"
  1606. * This callback is only called between add_interface and
  1607. * remove_interface calls, i.e. while the given virtual interface
  1608. * is enabled.
  1609. * Returns a negative error code if the key can't be added.
  1610. * The callback can sleep.
  1611. *
  1612. * @update_tkip_key: See the section "Hardware crypto acceleration"
  1613. * This callback will be called in the context of Rx. Called for drivers
  1614. * which set IEEE80211_KEY_FLAG_TKIP_REQ_RX_P1_KEY.
  1615. * The callback must be atomic.
  1616. *
  1617. * @set_rekey_data: If the device supports GTK rekeying, for example while the
  1618. * host is suspended, it can assign this callback to retrieve the data
  1619. * necessary to do GTK rekeying, this is the KEK, KCK and replay counter.
  1620. * After rekeying was done it should (for example during resume) notify
  1621. * userspace of the new replay counter using ieee80211_gtk_rekey_notify().
  1622. *
  1623. * @hw_scan: Ask the hardware to service the scan request, no need to start
  1624. * the scan state machine in stack. The scan must honour the channel
  1625. * configuration done by the regulatory agent in the wiphy's
  1626. * registered bands. The hardware (or the driver) needs to make sure
  1627. * that power save is disabled.
  1628. * The @req ie/ie_len members are rewritten by mac80211 to contain the
  1629. * entire IEs after the SSID, so that drivers need not look at these
  1630. * at all but just send them after the SSID -- mac80211 includes the
  1631. * (extended) supported rates and HT information (where applicable).
  1632. * When the scan finishes, ieee80211_scan_completed() must be called;
  1633. * note that it also must be called when the scan cannot finish due to
  1634. * any error unless this callback returned a negative error code.
  1635. * The callback can sleep.
  1636. *
  1637. * @cancel_hw_scan: Ask the low-level tp cancel the active hw scan.
  1638. * The driver should ask the hardware to cancel the scan (if possible),
  1639. * but the scan will be completed only after the driver will call
  1640. * ieee80211_scan_completed().
  1641. * This callback is needed for wowlan, to prevent enqueueing a new
  1642. * scan_work after the low-level driver was already suspended.
  1643. * The callback can sleep.
  1644. *
  1645. * @sched_scan_start: Ask the hardware to start scanning repeatedly at
  1646. * specific intervals. The driver must call the
  1647. * ieee80211_sched_scan_results() function whenever it finds results.
  1648. * This process will continue until sched_scan_stop is called.
  1649. *
  1650. * @sched_scan_stop: Tell the hardware to stop an ongoing scheduled scan.
  1651. *
  1652. * @sw_scan_start: Notifier function that is called just before a software scan
  1653. * is started. Can be NULL, if the driver doesn't need this notification.
  1654. * The callback can sleep.
  1655. *
  1656. * @sw_scan_complete: Notifier function that is called just after a
  1657. * software scan finished. Can be NULL, if the driver doesn't need
  1658. * this notification.
  1659. * The callback can sleep.
  1660. *
  1661. * @get_stats: Return low-level statistics.
  1662. * Returns zero if statistics are available.
  1663. * The callback can sleep.
  1664. *
  1665. * @get_tkip_seq: If your device implements TKIP encryption in hardware this
  1666. * callback should be provided to read the TKIP transmit IVs (both IV32
  1667. * and IV16) for the given key from hardware.
  1668. * The callback must be atomic.
  1669. *
  1670. * @set_frag_threshold: Configuration of fragmentation threshold. Assign this
  1671. * if the device does fragmentation by itself; if this callback is
  1672. * implemented then the stack will not do fragmentation.
  1673. * The callback can sleep.
  1674. *
  1675. * @set_rts_threshold: Configuration of RTS threshold (if device needs it)
  1676. * The callback can sleep.
  1677. *
  1678. * @sta_add: Notifies low level driver about addition of an associated station,
  1679. * AP, IBSS/WDS/mesh peer etc. This callback can sleep.
  1680. *
  1681. * @sta_remove: Notifies low level driver about removal of an associated
  1682. * station, AP, IBSS/WDS/mesh peer etc. This callback can sleep.
  1683. *
  1684. * @sta_notify: Notifies low level driver about power state transition of an
  1685. * associated station, AP, IBSS/WDS/mesh peer etc. For a VIF operating
  1686. * in AP mode, this callback will not be called when the flag
  1687. * %IEEE80211_HW_AP_LINK_PS is set. Must be atomic.
  1688. *
  1689. * @conf_tx: Configure TX queue parameters (EDCF (aifs, cw_min, cw_max),
  1690. * bursting) for a hardware TX queue.
  1691. * Returns a negative error code on failure.
  1692. * The callback can sleep.
  1693. *
  1694. * @get_tsf: Get the current TSF timer value from firmware/hardware. Currently,
  1695. * this is only used for IBSS mode BSSID merging and debugging. Is not a
  1696. * required function.
  1697. * The callback can sleep.
  1698. *
  1699. * @set_tsf: Set the TSF timer to the specified value in the firmware/hardware.
  1700. * Currently, this is only used for IBSS mode debugging. Is not a
  1701. * required function.
  1702. * The callback can sleep.
  1703. *
  1704. * @reset_tsf: Reset the TSF timer and allow firmware/hardware to synchronize
  1705. * with other STAs in the IBSS. This is only used in IBSS mode. This
  1706. * function is optional if the firmware/hardware takes full care of
  1707. * TSF synchronization.
  1708. * The callback can sleep.
  1709. *
  1710. * @tx_last_beacon: Determine whether the last IBSS beacon was sent by us.
  1711. * This is needed only for IBSS mode and the result of this function is
  1712. * used to determine whether to reply to Probe Requests.
  1713. * Returns non-zero if this device sent the last beacon.
  1714. * The callback can sleep.
  1715. *
  1716. * @ampdu_action: Perform a certain A-MPDU action
  1717. * The RA/TID combination determines the destination and TID we want
  1718. * the ampdu action to be performed for. The action is defined through
  1719. * ieee80211_ampdu_mlme_action. Starting sequence number (@ssn)
  1720. * is the first frame we expect to perform the action on. Notice
  1721. * that TX/RX_STOP can pass NULL for this parameter.
  1722. * The @buf_size parameter is only valid when the action is set to
  1723. * %IEEE80211_AMPDU_TX_OPERATIONAL and indicates the peer's reorder
  1724. * buffer size (number of subframes) for this session -- the driver
  1725. * may neither send aggregates containing more subframes than this
  1726. * nor send aggregates in a way that lost frames would exceed the
  1727. * buffer size. If just limiting the aggregate size, this would be
  1728. * possible with a buf_size of 8:
  1729. * - TX: 1.....7
  1730. * - RX: 2....7 (lost frame #1)
  1731. * - TX: 8..1...
  1732. * which is invalid since #1 was now re-transmitted well past the
  1733. * buffer size of 8. Correct ways to retransmit #1 would be:
  1734. * - TX: 1 or 18 or 81
  1735. * Even "189" would be wrong since 1 could be lost again.
  1736. *
  1737. * Returns a negative error code on failure.
  1738. * The callback can sleep.
  1739. *
  1740. * @get_survey: Return per-channel survey information
  1741. *
  1742. * @rfkill_poll: Poll rfkill hardware state. If you need this, you also
  1743. * need to set wiphy->rfkill_poll to %true before registration,
  1744. * and need to call wiphy_rfkill_set_hw_state() in the callback.
  1745. * The callback can sleep.
  1746. *
  1747. * @set_coverage_class: Set slot time for given coverage class as specified
  1748. * in IEEE 802.11-2007 section 17.3.8.6 and modify ACK timeout
  1749. * accordingly. This callback is not required and may sleep.
  1750. *
  1751. * @testmode_cmd: Implement a cfg80211 test mode command.
  1752. * The callback can sleep.
  1753. * @testmode_dump: Implement a cfg80211 test mode dump. The callback can sleep.
  1754. *
  1755. * @flush: Flush all pending frames from the hardware queue, making sure
  1756. * that the hardware queues are empty. If the parameter @drop is set
  1757. * to %true, pending frames may be dropped. The callback can sleep.
  1758. *
  1759. * @channel_switch: Drivers that need (or want) to offload the channel
  1760. * switch operation for CSAs received from the AP may implement this
  1761. * callback. They must then call ieee80211_chswitch_done() to indicate
  1762. * completion of the channel switch.
  1763. *
  1764. * @napi_poll: Poll Rx queue for incoming data frames.
  1765. *
  1766. * @set_antenna: Set antenna configuration (tx_ant, rx_ant) on the device.
  1767. * Parameters are bitmaps of allowed antennas to use for TX/RX. Drivers may
  1768. * reject TX/RX mask combinations they cannot support by returning -EINVAL
  1769. * (also see nl80211.h @NL80211_ATTR_WIPHY_ANTENNA_TX).
  1770. *
  1771. * @get_antenna: Get current antenna configuration from device (tx_ant, rx_ant).
  1772. *
  1773. * @remain_on_channel: Starts an off-channel period on the given channel, must
  1774. * call back to ieee80211_ready_on_channel() when on that channel. Note
  1775. * that normal channel traffic is not stopped as this is intended for hw
  1776. * offload. Frames to transmit on the off-channel channel are transmitted
  1777. * normally except for the %IEEE80211_TX_CTL_TX_OFFCHAN flag. When the
  1778. * duration (which will always be non-zero) expires, the driver must call
  1779. * ieee80211_remain_on_channel_expired(). This callback may sleep.
  1780. * @cancel_remain_on_channel: Requests that an ongoing off-channel period is
  1781. * aborted before it expires. This callback may sleep.
  1782. * @offchannel_tx: Transmit frame on another channel, wait for a response
  1783. * and return. Reliable TX status must be reported for the frame. If the
  1784. * return value is 1, then the @remain_on_channel will be used with a
  1785. * regular transmission (if supported.)
  1786. * @offchannel_tx_cancel_wait: cancel wait associated with offchannel TX
  1787. *
  1788. * @set_ringparam: Set tx and rx ring sizes.
  1789. *
  1790. * @get_ringparam: Get tx and rx ring current and maximum sizes.
  1791. *
  1792. * @tx_frames_pending: Check if there is any pending frame in the hardware
  1793. * queues before entering power save.
  1794. *
  1795. * @set_bitrate_mask: Set a mask of rates to be used for rate control selection
  1796. * when transmitting a frame. Currently only legacy rates are handled.
  1797. * The callback can sleep.
  1798. */
  1799. struct ieee80211_ops {
  1800. void (*tx)(struct ieee80211_hw *hw, struct sk_buff *skb);
  1801. int (*start)(struct ieee80211_hw *hw);
  1802. void (*stop)(struct ieee80211_hw *hw);
  1803. #ifdef CONFIG_PM
  1804. int (*suspend)(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan);
  1805. int (*resume)(struct ieee80211_hw *hw);
  1806. #endif
  1807. int (*add_interface)(struct ieee80211_hw *hw,
  1808. struct ieee80211_vif *vif);
  1809. int (*change_interface)(struct ieee80211_hw *hw,
  1810. struct ieee80211_vif *vif,
  1811. enum nl80211_iftype new_type, bool p2p);
  1812. void (*remove_interface)(struct ieee80211_hw *hw,
  1813. struct ieee80211_vif *vif);
  1814. int (*config)(struct ieee80211_hw *hw, u32 changed);
  1815. void (*bss_info_changed)(struct ieee80211_hw *hw,
  1816. struct ieee80211_vif *vif,
  1817. struct ieee80211_bss_conf *info,
  1818. u32 changed);
  1819. u64 (*prepare_multicast)(struct ieee80211_hw *hw,
  1820. struct netdev_hw_addr_list *mc_list);
  1821. void (*configure_filter)(struct ieee80211_hw *hw,
  1822. unsigned int changed_flags,
  1823. unsigned int *total_flags,
  1824. u64 multicast);
  1825. int (*set_tim)(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
  1826. bool set);
  1827. int (*set_key)(struct ieee80211_hw *hw, enum set_key_cmd cmd,
  1828. struct ieee80211_vif *vif, struct ieee80211_sta *sta,
  1829. struct ieee80211_key_conf *key);
  1830. void (*update_tkip_key)(struct ieee80211_hw *hw,
  1831. struct ieee80211_vif *vif,
  1832. struct ieee80211_key_conf *conf,
  1833. struct ieee80211_sta *sta,
  1834. u32 iv32, u16 *phase1key);
  1835. void (*set_rekey_data)(struct ieee80211_hw *hw,
  1836. struct ieee80211_vif *vif,
  1837. struct cfg80211_gtk_rekey_data *data);
  1838. int (*hw_scan)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  1839. struct cfg80211_scan_request *req);
  1840. void (*cancel_hw_scan)(struct ieee80211_hw *hw,
  1841. struct ieee80211_vif *vif);
  1842. int (*sched_scan_start)(struct ieee80211_hw *hw,
  1843. struct ieee80211_vif *vif,
  1844. struct cfg80211_sched_scan_request *req,
  1845. struct ieee80211_sched_scan_ies *ies);
  1846. void (*sched_scan_stop)(struct ieee80211_hw *hw,
  1847. struct ieee80211_vif *vif);
  1848. void (*sw_scan_start)(struct ieee80211_hw *hw);
  1849. void (*sw_scan_complete)(struct ieee80211_hw *hw);
  1850. int (*get_stats)(struct ieee80211_hw *hw,
  1851. struct ieee80211_low_level_stats *stats);
  1852. void (*get_tkip_seq)(struct ieee80211_hw *hw, u8 hw_key_idx,
  1853. u32 *iv32, u16 *iv16);
  1854. int (*set_frag_threshold)(struct ieee80211_hw *hw, u32 value);
  1855. int (*set_rts_threshold)(struct ieee80211_hw *hw, u32 value);
  1856. int (*sta_add)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  1857. struct ieee80211_sta *sta);
  1858. int (*sta_remove)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  1859. struct ieee80211_sta *sta);
  1860. void (*sta_notify)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  1861. enum sta_notify_cmd, struct ieee80211_sta *sta);
  1862. int (*conf_tx)(struct ieee80211_hw *hw, u16 queue,
  1863. const struct ieee80211_tx_queue_params *params);
  1864. u64 (*get_tsf)(struct ieee80211_hw *hw);
  1865. void (*set_tsf)(struct ieee80211_hw *hw, u64 tsf);
  1866. void (*reset_tsf)(struct ieee80211_hw *hw);
  1867. int (*tx_last_beacon)(struct ieee80211_hw *hw);
  1868. int (*ampdu_action)(struct ieee80211_hw *hw,
  1869. struct ieee80211_vif *vif,
  1870. enum ieee80211_ampdu_mlme_action action,
  1871. struct ieee80211_sta *sta, u16 tid, u16 *ssn,
  1872. u8 buf_size);
  1873. int (*get_survey)(struct ieee80211_hw *hw, int idx,
  1874. struct survey_info *survey);
  1875. void (*rfkill_poll)(struct ieee80211_hw *hw);
  1876. void (*set_coverage_class)(struct ieee80211_hw *hw, u8 coverage_class);
  1877. #ifdef CONFIG_NL80211_TESTMODE
  1878. int (*testmode_cmd)(struct ieee80211_hw *hw, void *data, int len);
  1879. int (*testmode_dump)(struct ieee80211_hw *hw, struct sk_buff *skb,
  1880. struct netlink_callback *cb,
  1881. void *data, int len);
  1882. #endif
  1883. void (*flush)(struct ieee80211_hw *hw, bool drop);
  1884. void (*channel_switch)(struct ieee80211_hw *hw,
  1885. struct ieee80211_channel_switch *ch_switch);
  1886. int (*napi_poll)(struct ieee80211_hw *hw, int budget);
  1887. int (*set_antenna)(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant);
  1888. int (*get_antenna)(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant);
  1889. int (*remain_on_channel)(struct ieee80211_hw *hw,
  1890. struct ieee80211_channel *chan,
  1891. enum nl80211_channel_type channel_type,
  1892. int duration);
  1893. int (*cancel_remain_on_channel)(struct ieee80211_hw *hw);
  1894. int (*offchannel_tx)(struct ieee80211_hw *hw, struct sk_buff *skb,
  1895. struct ieee80211_channel *chan,
  1896. enum nl80211_channel_type channel_type,
  1897. unsigned int wait);
  1898. int (*offchannel_tx_cancel_wait)(struct ieee80211_hw *hw);
  1899. int (*set_ringparam)(struct ieee80211_hw *hw, u32 tx, u32 rx);
  1900. void (*get_ringparam)(struct ieee80211_hw *hw,
  1901. u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max);
  1902. bool (*tx_frames_pending)(struct ieee80211_hw *hw);
  1903. int (*set_bitrate_mask)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  1904. const struct cfg80211_bitrate_mask *mask);
  1905. };
  1906. /**
  1907. * ieee80211_alloc_hw - Allocate a new hardware device
  1908. *
  1909. * This must be called once for each hardware device. The returned pointer
  1910. * must be used to refer to this device when calling other functions.
  1911. * mac80211 allocates a private data area for the driver pointed to by
  1912. * @priv in &struct ieee80211_hw, the size of this area is given as
  1913. * @priv_data_len.
  1914. *
  1915. * @priv_data_len: length of private data
  1916. * @ops: callbacks for this device
  1917. */
  1918. struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
  1919. const struct ieee80211_ops *ops);
  1920. /**
  1921. * ieee80211_register_hw - Register hardware device
  1922. *
  1923. * You must call this function before any other functions in
  1924. * mac80211. Note that before a hardware can be registered, you
  1925. * need to fill the contained wiphy's information.
  1926. *
  1927. * @hw: the device to register as returned by ieee80211_alloc_hw()
  1928. */
  1929. int ieee80211_register_hw(struct ieee80211_hw *hw);
  1930. /**
  1931. * struct ieee80211_tpt_blink - throughput blink description
  1932. * @throughput: throughput in Kbit/sec
  1933. * @blink_time: blink time in milliseconds
  1934. * (full cycle, ie. one off + one on period)
  1935. */
  1936. struct ieee80211_tpt_blink {
  1937. int throughput;
  1938. int blink_time;
  1939. };
  1940. /**
  1941. * enum ieee80211_tpt_led_trigger_flags - throughput trigger flags
  1942. * @IEEE80211_TPT_LEDTRIG_FL_RADIO: enable blinking with radio
  1943. * @IEEE80211_TPT_LEDTRIG_FL_WORK: enable blinking when working
  1944. * @IEEE80211_TPT_LEDTRIG_FL_CONNECTED: enable blinking when at least one
  1945. * interface is connected in some way, including being an AP
  1946. */
  1947. enum ieee80211_tpt_led_trigger_flags {
  1948. IEEE80211_TPT_LEDTRIG_FL_RADIO = BIT(0),
  1949. IEEE80211_TPT_LEDTRIG_FL_WORK = BIT(1),
  1950. IEEE80211_TPT_LEDTRIG_FL_CONNECTED = BIT(2),
  1951. };
  1952. #ifdef CONFIG_MAC80211_LEDS
  1953. extern char *__ieee80211_get_tx_led_name(struct ieee80211_hw *hw);
  1954. extern char *__ieee80211_get_rx_led_name(struct ieee80211_hw *hw);
  1955. extern char *__ieee80211_get_assoc_led_name(struct ieee80211_hw *hw);
  1956. extern char *__ieee80211_get_radio_led_name(struct ieee80211_hw *hw);
  1957. extern char *__ieee80211_create_tpt_led_trigger(
  1958. struct ieee80211_hw *hw, unsigned int flags,
  1959. const struct ieee80211_tpt_blink *blink_table,
  1960. unsigned int blink_table_len);
  1961. #endif
  1962. /**
  1963. * ieee80211_get_tx_led_name - get name of TX LED
  1964. *
  1965. * mac80211 creates a transmit LED trigger for each wireless hardware
  1966. * that can be used to drive LEDs if your driver registers a LED device.
  1967. * This function returns the name (or %NULL if not configured for LEDs)
  1968. * of the trigger so you can automatically link the LED device.
  1969. *
  1970. * @hw: the hardware to get the LED trigger name for
  1971. */
  1972. static inline char *ieee80211_get_tx_led_name(struct ieee80211_hw *hw)
  1973. {
  1974. #ifdef CONFIG_MAC80211_LEDS
  1975. return __ieee80211_get_tx_led_name(hw);
  1976. #else
  1977. return NULL;
  1978. #endif
  1979. }
  1980. /**
  1981. * ieee80211_get_rx_led_name - get name of RX LED
  1982. *
  1983. * mac80211 creates a receive LED trigger for each wireless hardware
  1984. * that can be used to drive LEDs if your driver registers a LED device.
  1985. * This function returns the name (or %NULL if not configured for LEDs)
  1986. * of the trigger so you can automatically link the LED device.
  1987. *
  1988. * @hw: the hardware to get the LED trigger name for
  1989. */
  1990. static inline char *ieee80211_get_rx_led_name(struct ieee80211_hw *hw)
  1991. {
  1992. #ifdef CONFIG_MAC80211_LEDS
  1993. return __ieee80211_get_rx_led_name(hw);
  1994. #else
  1995. return NULL;
  1996. #endif
  1997. }
  1998. /**
  1999. * ieee80211_get_assoc_led_name - get name of association LED
  2000. *
  2001. * mac80211 creates a association LED trigger for each wireless hardware
  2002. * that can be used to drive LEDs if your driver registers a LED device.
  2003. * This function returns the name (or %NULL if not configured for LEDs)
  2004. * of the trigger so you can automatically link the LED device.
  2005. *
  2006. * @hw: the hardware to get the LED trigger name for
  2007. */
  2008. static inline char *ieee80211_get_assoc_led_name(struct ieee80211_hw *hw)
  2009. {
  2010. #ifdef CONFIG_MAC80211_LEDS
  2011. return __ieee80211_get_assoc_led_name(hw);
  2012. #else
  2013. return NULL;
  2014. #endif
  2015. }
  2016. /**
  2017. * ieee80211_get_radio_led_name - get name of radio LED
  2018. *
  2019. * mac80211 creates a radio change LED trigger for each wireless hardware
  2020. * that can be used to drive LEDs if your driver registers a LED device.
  2021. * This function returns the name (or %NULL if not configured for LEDs)
  2022. * of the trigger so you can automatically link the LED device.
  2023. *
  2024. * @hw: the hardware to get the LED trigger name for
  2025. */
  2026. static inline char *ieee80211_get_radio_led_name(struct ieee80211_hw *hw)
  2027. {
  2028. #ifdef CONFIG_MAC80211_LEDS
  2029. return __ieee80211_get_radio_led_name(hw);
  2030. #else
  2031. return NULL;
  2032. #endif
  2033. }
  2034. /**
  2035. * ieee80211_create_tpt_led_trigger - create throughput LED trigger
  2036. * @hw: the hardware to create the trigger for
  2037. * @flags: trigger flags, see &enum ieee80211_tpt_led_trigger_flags
  2038. * @blink_table: the blink table -- needs to be ordered by throughput
  2039. * @blink_table_len: size of the blink table
  2040. *
  2041. * This function returns %NULL (in case of error, or if no LED
  2042. * triggers are configured) or the name of the new trigger.
  2043. * This function must be called before ieee80211_register_hw().
  2044. */
  2045. static inline char *
  2046. ieee80211_create_tpt_led_trigger(struct ieee80211_hw *hw, unsigned int flags,
  2047. const struct ieee80211_tpt_blink *blink_table,
  2048. unsigned int blink_table_len)
  2049. {
  2050. #ifdef CONFIG_MAC80211_LEDS
  2051. return __ieee80211_create_tpt_led_trigger(hw, flags, blink_table,
  2052. blink_table_len);
  2053. #else
  2054. return NULL;
  2055. #endif
  2056. }
  2057. /**
  2058. * ieee80211_unregister_hw - Unregister a hardware device
  2059. *
  2060. * This function instructs mac80211 to free allocated resources
  2061. * and unregister netdevices from the networking subsystem.
  2062. *
  2063. * @hw: the hardware to unregister
  2064. */
  2065. void ieee80211_unregister_hw(struct ieee80211_hw *hw);
  2066. /**
  2067. * ieee80211_free_hw - free hardware descriptor
  2068. *
  2069. * This function frees everything that was allocated, including the
  2070. * private data for the driver. You must call ieee80211_unregister_hw()
  2071. * before calling this function.
  2072. *
  2073. * @hw: the hardware to free
  2074. */
  2075. void ieee80211_free_hw(struct ieee80211_hw *hw);
  2076. /**
  2077. * ieee80211_restart_hw - restart hardware completely
  2078. *
  2079. * Call this function when the hardware was restarted for some reason
  2080. * (hardware error, ...) and the driver is unable to restore its state
  2081. * by itself. mac80211 assumes that at this point the driver/hardware
  2082. * is completely uninitialised and stopped, it starts the process by
  2083. * calling the ->start() operation. The driver will need to reset all
  2084. * internal state that it has prior to calling this function.
  2085. *
  2086. * @hw: the hardware to restart
  2087. */
  2088. void ieee80211_restart_hw(struct ieee80211_hw *hw);
  2089. /** ieee80211_napi_schedule - schedule NAPI poll
  2090. *
  2091. * Use this function to schedule NAPI polling on a device.
  2092. *
  2093. * @hw: the hardware to start polling
  2094. */
  2095. void ieee80211_napi_schedule(struct ieee80211_hw *hw);
  2096. /** ieee80211_napi_complete - complete NAPI polling
  2097. *
  2098. * Use this function to finish NAPI polling on a device.
  2099. *
  2100. * @hw: the hardware to stop polling
  2101. */
  2102. void ieee80211_napi_complete(struct ieee80211_hw *hw);
  2103. /**
  2104. * ieee80211_rx - receive frame
  2105. *
  2106. * Use this function to hand received frames to mac80211. The receive
  2107. * buffer in @skb must start with an IEEE 802.11 header. In case of a
  2108. * paged @skb is used, the driver is recommended to put the ieee80211
  2109. * header of the frame on the linear part of the @skb to avoid memory
  2110. * allocation and/or memcpy by the stack.
  2111. *
  2112. * This function may not be called in IRQ context. Calls to this function
  2113. * for a single hardware must be synchronized against each other. Calls to
  2114. * this function, ieee80211_rx_ni() and ieee80211_rx_irqsafe() may not be
  2115. * mixed for a single hardware.
  2116. *
  2117. * In process context use instead ieee80211_rx_ni().
  2118. *
  2119. * @hw: the hardware this frame came in on
  2120. * @skb: the buffer to receive, owned by mac80211 after this call
  2121. */
  2122. void ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb);
  2123. /**
  2124. * ieee80211_rx_irqsafe - receive frame
  2125. *
  2126. * Like ieee80211_rx() but can be called in IRQ context
  2127. * (internally defers to a tasklet.)
  2128. *
  2129. * Calls to this function, ieee80211_rx() or ieee80211_rx_ni() may not
  2130. * be mixed for a single hardware.
  2131. *
  2132. * @hw: the hardware this frame came in on
  2133. * @skb: the buffer to receive, owned by mac80211 after this call
  2134. */
  2135. void ieee80211_rx_irqsafe(struct ieee80211_hw *hw, struct sk_buff *skb);
  2136. /**
  2137. * ieee80211_rx_ni - receive frame (in process context)
  2138. *
  2139. * Like ieee80211_rx() but can be called in process context
  2140. * (internally disables bottom halves).
  2141. *
  2142. * Calls to this function, ieee80211_rx() and ieee80211_rx_irqsafe() may
  2143. * not be mixed for a single hardware.
  2144. *
  2145. * @hw: the hardware this frame came in on
  2146. * @skb: the buffer to receive, owned by mac80211 after this call
  2147. */
  2148. static inline void ieee80211_rx_ni(struct ieee80211_hw *hw,
  2149. struct sk_buff *skb)
  2150. {
  2151. local_bh_disable();
  2152. ieee80211_rx(hw, skb);
  2153. local_bh_enable();
  2154. }
  2155. /**
  2156. * ieee80211_sta_ps_transition - PS transition for connected sta
  2157. *
  2158. * When operating in AP mode with the %IEEE80211_HW_AP_LINK_PS
  2159. * flag set, use this function to inform mac80211 about a connected station
  2160. * entering/leaving PS mode.
  2161. *
  2162. * This function may not be called in IRQ context or with softirqs enabled.
  2163. *
  2164. * Calls to this function for a single hardware must be synchronized against
  2165. * each other.
  2166. *
  2167. * The function returns -EINVAL when the requested PS mode is already set.
  2168. *
  2169. * @sta: currently connected sta
  2170. * @start: start or stop PS
  2171. */
  2172. int ieee80211_sta_ps_transition(struct ieee80211_sta *sta, bool start);
  2173. /**
  2174. * ieee80211_sta_ps_transition_ni - PS transition for connected sta
  2175. * (in process context)
  2176. *
  2177. * Like ieee80211_sta_ps_transition() but can be called in process context
  2178. * (internally disables bottom halves). Concurrent call restriction still
  2179. * applies.
  2180. *
  2181. * @sta: currently connected sta
  2182. * @start: start or stop PS
  2183. */
  2184. static inline int ieee80211_sta_ps_transition_ni(struct ieee80211_sta *sta,
  2185. bool start)
  2186. {
  2187. int ret;
  2188. local_bh_disable();
  2189. ret = ieee80211_sta_ps_transition(sta, start);
  2190. local_bh_enable();
  2191. return ret;
  2192. }
  2193. /*
  2194. * The TX headroom reserved by mac80211 for its own tx_status functions.
  2195. * This is enough for the radiotap header.
  2196. */
  2197. #define IEEE80211_TX_STATUS_HEADROOM 13
  2198. /**
  2199. * ieee80211_sta_set_tim - set the TIM bit for a sleeping station
  2200. * @sta: &struct ieee80211_sta pointer for the sleeping station
  2201. *
  2202. * If a driver buffers frames for a powersave station instead of passing
  2203. * them back to mac80211 for retransmission, the station needs to be told
  2204. * to wake up using the TIM bitmap in the beacon.
  2205. *
  2206. * This function sets the station's TIM bit - it will be cleared when the
  2207. * station wakes up.
  2208. */
  2209. void ieee80211_sta_set_tim(struct ieee80211_sta *sta);
  2210. /**
  2211. * ieee80211_tx_status - transmit status callback
  2212. *
  2213. * Call this function for all transmitted frames after they have been
  2214. * transmitted. It is permissible to not call this function for
  2215. * multicast frames but this can affect statistics.
  2216. *
  2217. * This function may not be called in IRQ context. Calls to this function
  2218. * for a single hardware must be synchronized against each other. Calls
  2219. * to this function, ieee80211_tx_status_ni() and ieee80211_tx_status_irqsafe()
  2220. * may not be mixed for a single hardware.
  2221. *
  2222. * @hw: the hardware the frame was transmitted by
  2223. * @skb: the frame that was transmitted, owned by mac80211 after this call
  2224. */
  2225. void ieee80211_tx_status(struct ieee80211_hw *hw,
  2226. struct sk_buff *skb);
  2227. /**
  2228. * ieee80211_tx_status_ni - transmit status callback (in process context)
  2229. *
  2230. * Like ieee80211_tx_status() but can be called in process context.
  2231. *
  2232. * Calls to this function, ieee80211_tx_status() and
  2233. * ieee80211_tx_status_irqsafe() may not be mixed
  2234. * for a single hardware.
  2235. *
  2236. * @hw: the hardware the frame was transmitted by
  2237. * @skb: the frame that was transmitted, owned by mac80211 after this call
  2238. */
  2239. static inline void ieee80211_tx_status_ni(struct ieee80211_hw *hw,
  2240. struct sk_buff *skb)
  2241. {
  2242. local_bh_disable();
  2243. ieee80211_tx_status(hw, skb);
  2244. local_bh_enable();
  2245. }
  2246. /**
  2247. * ieee80211_tx_status_irqsafe - IRQ-safe transmit status callback
  2248. *
  2249. * Like ieee80211_tx_status() but can be called in IRQ context
  2250. * (internally defers to a tasklet.)
  2251. *
  2252. * Calls to this function, ieee80211_tx_status() and
  2253. * ieee80211_tx_status_ni() may not be mixed for a single hardware.
  2254. *
  2255. * @hw: the hardware the frame was transmitted by
  2256. * @skb: the frame that was transmitted, owned by mac80211 after this call
  2257. */
  2258. void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw,
  2259. struct sk_buff *skb);
  2260. /**
  2261. * ieee80211_report_low_ack - report non-responding station
  2262. *
  2263. * When operating in AP-mode, call this function to report a non-responding
  2264. * connected STA.
  2265. *
  2266. * @sta: the non-responding connected sta
  2267. * @num_packets: number of packets sent to @sta without a response
  2268. */
  2269. void ieee80211_report_low_ack(struct ieee80211_sta *sta, u32 num_packets);
  2270. /**
  2271. * ieee80211_beacon_get_tim - beacon generation function
  2272. * @hw: pointer obtained from ieee80211_alloc_hw().
  2273. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  2274. * @tim_offset: pointer to variable that will receive the TIM IE offset.
  2275. * Set to 0 if invalid (in non-AP modes).
  2276. * @tim_length: pointer to variable that will receive the TIM IE length,
  2277. * (including the ID and length bytes!).
  2278. * Set to 0 if invalid (in non-AP modes).
  2279. *
  2280. * If the driver implements beaconing modes, it must use this function to
  2281. * obtain the beacon frame/template.
  2282. *
  2283. * If the beacon frames are generated by the host system (i.e., not in
  2284. * hardware/firmware), the driver uses this function to get each beacon
  2285. * frame from mac80211 -- it is responsible for calling this function
  2286. * before the beacon is needed (e.g. based on hardware interrupt).
  2287. *
  2288. * If the beacon frames are generated by the device, then the driver
  2289. * must use the returned beacon as the template and change the TIM IE
  2290. * according to the current DTIM parameters/TIM bitmap.
  2291. *
  2292. * The driver is responsible for freeing the returned skb.
  2293. */
  2294. struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,
  2295. struct ieee80211_vif *vif,
  2296. u16 *tim_offset, u16 *tim_length);
  2297. /**
  2298. * ieee80211_beacon_get - beacon generation function
  2299. * @hw: pointer obtained from ieee80211_alloc_hw().
  2300. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  2301. *
  2302. * See ieee80211_beacon_get_tim().
  2303. */
  2304. static inline struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
  2305. struct ieee80211_vif *vif)
  2306. {
  2307. return ieee80211_beacon_get_tim(hw, vif, NULL, NULL);
  2308. }
  2309. /**
  2310. * ieee80211_pspoll_get - retrieve a PS Poll template
  2311. * @hw: pointer obtained from ieee80211_alloc_hw().
  2312. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  2313. *
  2314. * Creates a PS Poll a template which can, for example, uploaded to
  2315. * hardware. The template must be updated after association so that correct
  2316. * AID, BSSID and MAC address is used.
  2317. *
  2318. * Note: Caller (or hardware) is responsible for setting the
  2319. * &IEEE80211_FCTL_PM bit.
  2320. */
  2321. struct sk_buff *ieee80211_pspoll_get(struct ieee80211_hw *hw,
  2322. struct ieee80211_vif *vif);
  2323. /**
  2324. * ieee80211_nullfunc_get - retrieve a nullfunc template
  2325. * @hw: pointer obtained from ieee80211_alloc_hw().
  2326. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  2327. *
  2328. * Creates a Nullfunc template which can, for example, uploaded to
  2329. * hardware. The template must be updated after association so that correct
  2330. * BSSID and address is used.
  2331. *
  2332. * Note: Caller (or hardware) is responsible for setting the
  2333. * &IEEE80211_FCTL_PM bit as well as Duration and Sequence Control fields.
  2334. */
  2335. struct sk_buff *ieee80211_nullfunc_get(struct ieee80211_hw *hw,
  2336. struct ieee80211_vif *vif);
  2337. /**
  2338. * ieee80211_probereq_get - retrieve a Probe Request template
  2339. * @hw: pointer obtained from ieee80211_alloc_hw().
  2340. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  2341. * @ssid: SSID buffer
  2342. * @ssid_len: length of SSID
  2343. * @ie: buffer containing all IEs except SSID for the template
  2344. * @ie_len: length of the IE buffer
  2345. *
  2346. * Creates a Probe Request template which can, for example, be uploaded to
  2347. * hardware.
  2348. */
  2349. struct sk_buff *ieee80211_probereq_get(struct ieee80211_hw *hw,
  2350. struct ieee80211_vif *vif,
  2351. const u8 *ssid, size_t ssid_len,
  2352. const u8 *ie, size_t ie_len);
  2353. /**
  2354. * ieee80211_rts_get - RTS frame generation function
  2355. * @hw: pointer obtained from ieee80211_alloc_hw().
  2356. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  2357. * @frame: pointer to the frame that is going to be protected by the RTS.
  2358. * @frame_len: the frame length (in octets).
  2359. * @frame_txctl: &struct ieee80211_tx_info of the frame.
  2360. * @rts: The buffer where to store the RTS frame.
  2361. *
  2362. * If the RTS frames are generated by the host system (i.e., not in
  2363. * hardware/firmware), the low-level driver uses this function to receive
  2364. * the next RTS frame from the 802.11 code. The low-level is responsible
  2365. * for calling this function before and RTS frame is needed.
  2366. */
  2367. void ieee80211_rts_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  2368. const void *frame, size_t frame_len,
  2369. const struct ieee80211_tx_info *frame_txctl,
  2370. struct ieee80211_rts *rts);
  2371. /**
  2372. * ieee80211_rts_duration - Get the duration field for an RTS frame
  2373. * @hw: pointer obtained from ieee80211_alloc_hw().
  2374. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  2375. * @frame_len: the length of the frame that is going to be protected by the RTS.
  2376. * @frame_txctl: &struct ieee80211_tx_info of the frame.
  2377. *
  2378. * If the RTS is generated in firmware, but the host system must provide
  2379. * the duration field, the low-level driver uses this function to receive
  2380. * the duration field value in little-endian byteorder.
  2381. */
  2382. __le16 ieee80211_rts_duration(struct ieee80211_hw *hw,
  2383. struct ieee80211_vif *vif, size_t frame_len,
  2384. const struct ieee80211_tx_info *frame_txctl);
  2385. /**
  2386. * ieee80211_ctstoself_get - CTS-to-self frame generation function
  2387. * @hw: pointer obtained from ieee80211_alloc_hw().
  2388. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  2389. * @frame: pointer to the frame that is going to be protected by the CTS-to-self.
  2390. * @frame_len: the frame length (in octets).
  2391. * @frame_txctl: &struct ieee80211_tx_info of the frame.
  2392. * @cts: The buffer where to store the CTS-to-self frame.
  2393. *
  2394. * If the CTS-to-self frames are generated by the host system (i.e., not in
  2395. * hardware/firmware), the low-level driver uses this function to receive
  2396. * the next CTS-to-self frame from the 802.11 code. The low-level is responsible
  2397. * for calling this function before and CTS-to-self frame is needed.
  2398. */
  2399. void ieee80211_ctstoself_get(struct ieee80211_hw *hw,
  2400. struct ieee80211_vif *vif,
  2401. const void *frame, size_t frame_len,
  2402. const struct ieee80211_tx_info *frame_txctl,
  2403. struct ieee80211_cts *cts);
  2404. /**
  2405. * ieee80211_ctstoself_duration - Get the duration field for a CTS-to-self frame
  2406. * @hw: pointer obtained from ieee80211_alloc_hw().
  2407. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  2408. * @frame_len: the length of the frame that is going to be protected by the CTS-to-self.
  2409. * @frame_txctl: &struct ieee80211_tx_info of the frame.
  2410. *
  2411. * If the CTS-to-self is generated in firmware, but the host system must provide
  2412. * the duration field, the low-level driver uses this function to receive
  2413. * the duration field value in little-endian byteorder.
  2414. */
  2415. __le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw,
  2416. struct ieee80211_vif *vif,
  2417. size_t frame_len,
  2418. const struct ieee80211_tx_info *frame_txctl);
  2419. /**
  2420. * ieee80211_generic_frame_duration - Calculate the duration field for a frame
  2421. * @hw: pointer obtained from ieee80211_alloc_hw().
  2422. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  2423. * @frame_len: the length of the frame.
  2424. * @rate: the rate at which the frame is going to be transmitted.
  2425. *
  2426. * Calculate the duration field of some generic frame, given its
  2427. * length and transmission rate (in 100kbps).
  2428. */
  2429. __le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw,
  2430. struct ieee80211_vif *vif,
  2431. size_t frame_len,
  2432. struct ieee80211_rate *rate);
  2433. /**
  2434. * ieee80211_get_buffered_bc - accessing buffered broadcast and multicast frames
  2435. * @hw: pointer as obtained from ieee80211_alloc_hw().
  2436. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  2437. *
  2438. * Function for accessing buffered broadcast and multicast frames. If
  2439. * hardware/firmware does not implement buffering of broadcast/multicast
  2440. * frames when power saving is used, 802.11 code buffers them in the host
  2441. * memory. The low-level driver uses this function to fetch next buffered
  2442. * frame. In most cases, this is used when generating beacon frame. This
  2443. * function returns a pointer to the next buffered skb or NULL if no more
  2444. * buffered frames are available.
  2445. *
  2446. * Note: buffered frames are returned only after DTIM beacon frame was
  2447. * generated with ieee80211_beacon_get() and the low-level driver must thus
  2448. * call ieee80211_beacon_get() first. ieee80211_get_buffered_bc() returns
  2449. * NULL if the previous generated beacon was not DTIM, so the low-level driver
  2450. * does not need to check for DTIM beacons separately and should be able to
  2451. * use common code for all beacons.
  2452. */
  2453. struct sk_buff *
  2454. ieee80211_get_buffered_bc(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
  2455. /**
  2456. * ieee80211_get_tkip_p1k_iv - get a TKIP phase 1 key for IV32
  2457. *
  2458. * This function returns the TKIP phase 1 key for the given IV32.
  2459. *
  2460. * @keyconf: the parameter passed with the set key
  2461. * @iv32: IV32 to get the P1K for
  2462. * @p1k: a buffer to which the key will be written, as 5 u16 values
  2463. */
  2464. void ieee80211_get_tkip_p1k_iv(struct ieee80211_key_conf *keyconf,
  2465. u32 iv32, u16 *p1k);
  2466. /**
  2467. * ieee80211_get_tkip_p1k - get a TKIP phase 1 key
  2468. *
  2469. * This function returns the TKIP phase 1 key for the IV32 taken
  2470. * from the given packet.
  2471. *
  2472. * @keyconf: the parameter passed with the set key
  2473. * @skb: the packet to take the IV32 value from that will be encrypted
  2474. * with this P1K
  2475. * @p1k: a buffer to which the key will be written, as 5 u16 values
  2476. */
  2477. static inline void ieee80211_get_tkip_p1k(struct ieee80211_key_conf *keyconf,
  2478. struct sk_buff *skb, u16 *p1k)
  2479. {
  2480. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
  2481. const u8 *data = (u8 *)hdr + ieee80211_hdrlen(hdr->frame_control);
  2482. u32 iv32 = get_unaligned_le32(&data[4]);
  2483. ieee80211_get_tkip_p1k_iv(keyconf, iv32, p1k);
  2484. }
  2485. /**
  2486. * ieee80211_get_tkip_p2k - get a TKIP phase 2 key
  2487. *
  2488. * This function computes the TKIP RC4 key for the IV values
  2489. * in the packet.
  2490. *
  2491. * @keyconf: the parameter passed with the set key
  2492. * @skb: the packet to take the IV32/IV16 values from that will be
  2493. * encrypted with this key
  2494. * @p2k: a buffer to which the key will be written, 16 bytes
  2495. */
  2496. void ieee80211_get_tkip_p2k(struct ieee80211_key_conf *keyconf,
  2497. struct sk_buff *skb, u8 *p2k);
  2498. /**
  2499. * struct ieee80211_key_seq - key sequence counter
  2500. *
  2501. * @tkip: TKIP data, containing IV32 and IV16 in host byte order
  2502. * @ccmp: PN data, most significant byte first (big endian,
  2503. * reverse order than in packet)
  2504. * @aes_cmac: PN data, most significant byte first (big endian,
  2505. * reverse order than in packet)
  2506. */
  2507. struct ieee80211_key_seq {
  2508. union {
  2509. struct {
  2510. u32 iv32;
  2511. u16 iv16;
  2512. } tkip;
  2513. struct {
  2514. u8 pn[6];
  2515. } ccmp;
  2516. struct {
  2517. u8 pn[6];
  2518. } aes_cmac;
  2519. };
  2520. };
  2521. /**
  2522. * ieee80211_get_key_tx_seq - get key TX sequence counter
  2523. *
  2524. * @keyconf: the parameter passed with the set key
  2525. * @seq: buffer to receive the sequence data
  2526. *
  2527. * This function allows a driver to retrieve the current TX IV/PN
  2528. * for the given key. It must not be called if IV generation is
  2529. * offloaded to the device.
  2530. *
  2531. * Note that this function may only be called when no TX processing
  2532. * can be done concurrently, for example when queues are stopped
  2533. * and the stop has been synchronized.
  2534. */
  2535. void ieee80211_get_key_tx_seq(struct ieee80211_key_conf *keyconf,
  2536. struct ieee80211_key_seq *seq);
  2537. /**
  2538. * ieee80211_get_key_rx_seq - get key RX sequence counter
  2539. *
  2540. * @keyconf: the parameter passed with the set key
  2541. * @tid: The TID, or -1 for the management frame value (CCMP only);
  2542. * the value on TID 0 is also used for non-QoS frames. For
  2543. * CMAC, only TID 0 is valid.
  2544. * @seq: buffer to receive the sequence data
  2545. *
  2546. * This function allows a driver to retrieve the current RX IV/PNs
  2547. * for the given key. It must not be called if IV checking is done
  2548. * by the device and not by mac80211.
  2549. *
  2550. * Note that this function may only be called when no RX processing
  2551. * can be done concurrently.
  2552. */
  2553. void ieee80211_get_key_rx_seq(struct ieee80211_key_conf *keyconf,
  2554. int tid, struct ieee80211_key_seq *seq);
  2555. /**
  2556. * ieee80211_gtk_rekey_notify - notify userspace supplicant of rekeying
  2557. * @vif: virtual interface the rekeying was done on
  2558. * @bssid: The BSSID of the AP, for checking association
  2559. * @replay_ctr: the new replay counter after GTK rekeying
  2560. * @gfp: allocation flags
  2561. */
  2562. void ieee80211_gtk_rekey_notify(struct ieee80211_vif *vif, const u8 *bssid,
  2563. const u8 *replay_ctr, gfp_t gfp);
  2564. /**
  2565. * ieee80211_wake_queue - wake specific queue
  2566. * @hw: pointer as obtained from ieee80211_alloc_hw().
  2567. * @queue: queue number (counted from zero).
  2568. *
  2569. * Drivers should use this function instead of netif_wake_queue.
  2570. */
  2571. void ieee80211_wake_queue(struct ieee80211_hw *hw, int queue);
  2572. /**
  2573. * ieee80211_stop_queue - stop specific queue
  2574. * @hw: pointer as obtained from ieee80211_alloc_hw().
  2575. * @queue: queue number (counted from zero).
  2576. *
  2577. * Drivers should use this function instead of netif_stop_queue.
  2578. */
  2579. void ieee80211_stop_queue(struct ieee80211_hw *hw, int queue);
  2580. /**
  2581. * ieee80211_queue_stopped - test status of the queue
  2582. * @hw: pointer as obtained from ieee80211_alloc_hw().
  2583. * @queue: queue number (counted from zero).
  2584. *
  2585. * Drivers should use this function instead of netif_stop_queue.
  2586. */
  2587. int ieee80211_queue_stopped(struct ieee80211_hw *hw, int queue);
  2588. /**
  2589. * ieee80211_stop_queues - stop all queues
  2590. * @hw: pointer as obtained from ieee80211_alloc_hw().
  2591. *
  2592. * Drivers should use this function instead of netif_stop_queue.
  2593. */
  2594. void ieee80211_stop_queues(struct ieee80211_hw *hw);
  2595. /**
  2596. * ieee80211_wake_queues - wake all queues
  2597. * @hw: pointer as obtained from ieee80211_alloc_hw().
  2598. *
  2599. * Drivers should use this function instead of netif_wake_queue.
  2600. */
  2601. void ieee80211_wake_queues(struct ieee80211_hw *hw);
  2602. /**
  2603. * ieee80211_scan_completed - completed hardware scan
  2604. *
  2605. * When hardware scan offload is used (i.e. the hw_scan() callback is
  2606. * assigned) this function needs to be called by the driver to notify
  2607. * mac80211 that the scan finished. This function can be called from
  2608. * any context, including hardirq context.
  2609. *
  2610. * @hw: the hardware that finished the scan
  2611. * @aborted: set to true if scan was aborted
  2612. */
  2613. void ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted);
  2614. /**
  2615. * ieee80211_sched_scan_results - got results from scheduled scan
  2616. *
  2617. * When a scheduled scan is running, this function needs to be called by the
  2618. * driver whenever there are new scan results available.
  2619. *
  2620. * @hw: the hardware that is performing scheduled scans
  2621. */
  2622. void ieee80211_sched_scan_results(struct ieee80211_hw *hw);
  2623. /**
  2624. * ieee80211_sched_scan_stopped - inform that the scheduled scan has stopped
  2625. *
  2626. * When a scheduled scan is running, this function can be called by
  2627. * the driver if it needs to stop the scan to perform another task.
  2628. * Usual scenarios are drivers that cannot continue the scheduled scan
  2629. * while associating, for instance.
  2630. *
  2631. * @hw: the hardware that is performing scheduled scans
  2632. */
  2633. void ieee80211_sched_scan_stopped(struct ieee80211_hw *hw);
  2634. /**
  2635. * ieee80211_iterate_active_interfaces - iterate active interfaces
  2636. *
  2637. * This function iterates over the interfaces associated with a given
  2638. * hardware that are currently active and calls the callback for them.
  2639. * This function allows the iterator function to sleep, when the iterator
  2640. * function is atomic @ieee80211_iterate_active_interfaces_atomic can
  2641. * be used.
  2642. * Does not iterate over a new interface during add_interface()
  2643. *
  2644. * @hw: the hardware struct of which the interfaces should be iterated over
  2645. * @iterator: the iterator function to call
  2646. * @data: first argument of the iterator function
  2647. */
  2648. void ieee80211_iterate_active_interfaces(struct ieee80211_hw *hw,
  2649. void (*iterator)(void *data, u8 *mac,
  2650. struct ieee80211_vif *vif),
  2651. void *data);
  2652. /**
  2653. * ieee80211_iterate_active_interfaces_atomic - iterate active interfaces
  2654. *
  2655. * This function iterates over the interfaces associated with a given
  2656. * hardware that are currently active and calls the callback for them.
  2657. * This function requires the iterator callback function to be atomic,
  2658. * if that is not desired, use @ieee80211_iterate_active_interfaces instead.
  2659. * Does not iterate over a new interface during add_interface()
  2660. *
  2661. * @hw: the hardware struct of which the interfaces should be iterated over
  2662. * @iterator: the iterator function to call, cannot sleep
  2663. * @data: first argument of the iterator function
  2664. */
  2665. void ieee80211_iterate_active_interfaces_atomic(struct ieee80211_hw *hw,
  2666. void (*iterator)(void *data,
  2667. u8 *mac,
  2668. struct ieee80211_vif *vif),
  2669. void *data);
  2670. /**
  2671. * ieee80211_queue_work - add work onto the mac80211 workqueue
  2672. *
  2673. * Drivers and mac80211 use this to add work onto the mac80211 workqueue.
  2674. * This helper ensures drivers are not queueing work when they should not be.
  2675. *
  2676. * @hw: the hardware struct for the interface we are adding work for
  2677. * @work: the work we want to add onto the mac80211 workqueue
  2678. */
  2679. void ieee80211_queue_work(struct ieee80211_hw *hw, struct work_struct *work);
  2680. /**
  2681. * ieee80211_queue_delayed_work - add work onto the mac80211 workqueue
  2682. *
  2683. * Drivers and mac80211 use this to queue delayed work onto the mac80211
  2684. * workqueue.
  2685. *
  2686. * @hw: the hardware struct for the interface we are adding work for
  2687. * @dwork: delayable work to queue onto the mac80211 workqueue
  2688. * @delay: number of jiffies to wait before queueing
  2689. */
  2690. void ieee80211_queue_delayed_work(struct ieee80211_hw *hw,
  2691. struct delayed_work *dwork,
  2692. unsigned long delay);
  2693. /**
  2694. * ieee80211_start_tx_ba_session - Start a tx Block Ack session.
  2695. * @sta: the station for which to start a BA session
  2696. * @tid: the TID to BA on.
  2697. * @timeout: session timeout value (in TUs)
  2698. *
  2699. * Return: success if addBA request was sent, failure otherwise
  2700. *
  2701. * Although mac80211/low level driver/user space application can estimate
  2702. * the need to start aggregation on a certain RA/TID, the session level
  2703. * will be managed by the mac80211.
  2704. */
  2705. int ieee80211_start_tx_ba_session(struct ieee80211_sta *sta, u16 tid,
  2706. u16 timeout);
  2707. /**
  2708. * ieee80211_start_tx_ba_cb_irqsafe - low level driver ready to aggregate.
  2709. * @vif: &struct ieee80211_vif pointer from the add_interface callback
  2710. * @ra: receiver address of the BA session recipient.
  2711. * @tid: the TID to BA on.
  2712. *
  2713. * This function must be called by low level driver once it has
  2714. * finished with preparations for the BA session. It can be called
  2715. * from any context.
  2716. */
  2717. void ieee80211_start_tx_ba_cb_irqsafe(struct ieee80211_vif *vif, const u8 *ra,
  2718. u16 tid);
  2719. /**
  2720. * ieee80211_stop_tx_ba_session - Stop a Block Ack session.
  2721. * @sta: the station whose BA session to stop
  2722. * @tid: the TID to stop BA.
  2723. *
  2724. * Return: negative error if the TID is invalid, or no aggregation active
  2725. *
  2726. * Although mac80211/low level driver/user space application can estimate
  2727. * the need to stop aggregation on a certain RA/TID, the session level
  2728. * will be managed by the mac80211.
  2729. */
  2730. int ieee80211_stop_tx_ba_session(struct ieee80211_sta *sta, u16 tid);
  2731. /**
  2732. * ieee80211_stop_tx_ba_cb_irqsafe - low level driver ready to stop aggregate.
  2733. * @vif: &struct ieee80211_vif pointer from the add_interface callback
  2734. * @ra: receiver address of the BA session recipient.
  2735. * @tid: the desired TID to BA on.
  2736. *
  2737. * This function must be called by low level driver once it has
  2738. * finished with preparations for the BA session tear down. It
  2739. * can be called from any context.
  2740. */
  2741. void ieee80211_stop_tx_ba_cb_irqsafe(struct ieee80211_vif *vif, const u8 *ra,
  2742. u16 tid);
  2743. /**
  2744. * ieee80211_find_sta - find a station
  2745. *
  2746. * @vif: virtual interface to look for station on
  2747. * @addr: station's address
  2748. *
  2749. * This function must be called under RCU lock and the
  2750. * resulting pointer is only valid under RCU lock as well.
  2751. */
  2752. struct ieee80211_sta *ieee80211_find_sta(struct ieee80211_vif *vif,
  2753. const u8 *addr);
  2754. /**
  2755. * ieee80211_find_sta_by_ifaddr - find a station on hardware
  2756. *
  2757. * @hw: pointer as obtained from ieee80211_alloc_hw()
  2758. * @addr: remote station's address
  2759. * @localaddr: local address (vif->sdata->vif.addr). Use NULL for 'any'.
  2760. *
  2761. * This function must be called under RCU lock and the
  2762. * resulting pointer is only valid under RCU lock as well.
  2763. *
  2764. * NOTE: You may pass NULL for localaddr, but then you will just get
  2765. * the first STA that matches the remote address 'addr'.
  2766. * We can have multiple STA associated with multiple
  2767. * logical stations (e.g. consider a station connecting to another
  2768. * BSSID on the same AP hardware without disconnecting first).
  2769. * In this case, the result of this method with localaddr NULL
  2770. * is not reliable.
  2771. *
  2772. * DO NOT USE THIS FUNCTION with localaddr NULL if at all possible.
  2773. */
  2774. struct ieee80211_sta *ieee80211_find_sta_by_ifaddr(struct ieee80211_hw *hw,
  2775. const u8 *addr,
  2776. const u8 *localaddr);
  2777. /**
  2778. * ieee80211_sta_block_awake - block station from waking up
  2779. * @hw: the hardware
  2780. * @pubsta: the station
  2781. * @block: whether to block or unblock
  2782. *
  2783. * Some devices require that all frames that are on the queues
  2784. * for a specific station that went to sleep are flushed before
  2785. * a poll response or frames after the station woke up can be
  2786. * delivered to that it. Note that such frames must be rejected
  2787. * by the driver as filtered, with the appropriate status flag.
  2788. *
  2789. * This function allows implementing this mode in a race-free
  2790. * manner.
  2791. *
  2792. * To do this, a driver must keep track of the number of frames
  2793. * still enqueued for a specific station. If this number is not
  2794. * zero when the station goes to sleep, the driver must call
  2795. * this function to force mac80211 to consider the station to
  2796. * be asleep regardless of the station's actual state. Once the
  2797. * number of outstanding frames reaches zero, the driver must
  2798. * call this function again to unblock the station. That will
  2799. * cause mac80211 to be able to send ps-poll responses, and if
  2800. * the station queried in the meantime then frames will also
  2801. * be sent out as a result of this. Additionally, the driver
  2802. * will be notified that the station woke up some time after
  2803. * it is unblocked, regardless of whether the station actually
  2804. * woke up while blocked or not.
  2805. */
  2806. void ieee80211_sta_block_awake(struct ieee80211_hw *hw,
  2807. struct ieee80211_sta *pubsta, bool block);
  2808. /**
  2809. * ieee80211_iter_keys - iterate keys programmed into the device
  2810. * @hw: pointer obtained from ieee80211_alloc_hw()
  2811. * @vif: virtual interface to iterate, may be %NULL for all
  2812. * @iter: iterator function that will be called for each key
  2813. * @iter_data: custom data to pass to the iterator function
  2814. *
  2815. * This function can be used to iterate all the keys known to
  2816. * mac80211, even those that weren't previously programmed into
  2817. * the device. This is intended for use in WoWLAN if the device
  2818. * needs reprogramming of the keys during suspend. Note that due
  2819. * to locking reasons, it is also only safe to call this at few
  2820. * spots since it must hold the RTNL and be able to sleep.
  2821. */
  2822. void ieee80211_iter_keys(struct ieee80211_hw *hw,
  2823. struct ieee80211_vif *vif,
  2824. void (*iter)(struct ieee80211_hw *hw,
  2825. struct ieee80211_vif *vif,
  2826. struct ieee80211_sta *sta,
  2827. struct ieee80211_key_conf *key,
  2828. void *data),
  2829. void *iter_data);
  2830. /**
  2831. * ieee80211_ap_probereq_get - retrieve a Probe Request template
  2832. * @hw: pointer obtained from ieee80211_alloc_hw().
  2833. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  2834. *
  2835. * Creates a Probe Request template which can, for example, be uploaded to
  2836. * hardware. The template is filled with bssid, ssid and supported rate
  2837. * information. This function must only be called from within the
  2838. * .bss_info_changed callback function and only in managed mode. The function
  2839. * is only useful when the interface is associated, otherwise it will return
  2840. * NULL.
  2841. */
  2842. struct sk_buff *ieee80211_ap_probereq_get(struct ieee80211_hw *hw,
  2843. struct ieee80211_vif *vif);
  2844. /**
  2845. * ieee80211_beacon_loss - inform hardware does not receive beacons
  2846. *
  2847. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  2848. *
  2849. * When beacon filtering is enabled with %IEEE80211_HW_BEACON_FILTER and
  2850. * %IEEE80211_CONF_PS is set, the driver needs to inform whenever the
  2851. * hardware is not receiving beacons with this function.
  2852. */
  2853. void ieee80211_beacon_loss(struct ieee80211_vif *vif);
  2854. /**
  2855. * ieee80211_connection_loss - inform hardware has lost connection to the AP
  2856. *
  2857. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  2858. *
  2859. * When beacon filtering is enabled with %IEEE80211_HW_BEACON_FILTER, and
  2860. * %IEEE80211_CONF_PS and %IEEE80211_HW_CONNECTION_MONITOR are set, the driver
  2861. * needs to inform if the connection to the AP has been lost.
  2862. *
  2863. * This function will cause immediate change to disassociated state,
  2864. * without connection recovery attempts.
  2865. */
  2866. void ieee80211_connection_loss(struct ieee80211_vif *vif);
  2867. /**
  2868. * ieee80211_disable_dyn_ps - force mac80211 to temporarily disable dynamic psm
  2869. *
  2870. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  2871. *
  2872. * Some hardware require full power save to manage simultaneous BT traffic
  2873. * on the WLAN frequency. Full PSM is required periodically, whenever there are
  2874. * burst of BT traffic. The hardware gets information of BT traffic via
  2875. * hardware co-existence lines, and consequentially requests mac80211 to
  2876. * (temporarily) enter full psm.
  2877. * This function will only temporarily disable dynamic PS, not enable PSM if
  2878. * it was not already enabled.
  2879. * The driver must make sure to re-enable dynamic PS using
  2880. * ieee80211_enable_dyn_ps() if the driver has disabled it.
  2881. *
  2882. */
  2883. void ieee80211_disable_dyn_ps(struct ieee80211_vif *vif);
  2884. /**
  2885. * ieee80211_enable_dyn_ps - restore dynamic psm after being disabled
  2886. *
  2887. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  2888. *
  2889. * This function restores dynamic PS after being temporarily disabled via
  2890. * ieee80211_disable_dyn_ps(). Each ieee80211_disable_dyn_ps() call must
  2891. * be coupled with an eventual call to this function.
  2892. *
  2893. */
  2894. void ieee80211_enable_dyn_ps(struct ieee80211_vif *vif);
  2895. /**
  2896. * ieee80211_cqm_rssi_notify - inform a configured connection quality monitoring
  2897. * rssi threshold triggered
  2898. *
  2899. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  2900. * @rssi_event: the RSSI trigger event type
  2901. * @gfp: context flags
  2902. *
  2903. * When the %IEEE80211_HW_SUPPORTS_CQM_RSSI is set, and a connection quality
  2904. * monitoring is configured with an rssi threshold, the driver will inform
  2905. * whenever the rssi level reaches the threshold.
  2906. */
  2907. void ieee80211_cqm_rssi_notify(struct ieee80211_vif *vif,
  2908. enum nl80211_cqm_rssi_threshold_event rssi_event,
  2909. gfp_t gfp);
  2910. /**
  2911. * ieee80211_get_operstate - get the operstate of the vif
  2912. *
  2913. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  2914. *
  2915. * The driver might need to know the operstate of the net_device
  2916. * (specifically, whether the link is IF_OPER_UP after resume)
  2917. */
  2918. unsigned char ieee80211_get_operstate(struct ieee80211_vif *vif);
  2919. /**
  2920. * ieee80211_chswitch_done - Complete channel switch process
  2921. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  2922. * @success: make the channel switch successful or not
  2923. *
  2924. * Complete the channel switch post-process: set the new operational channel
  2925. * and wake up the suspended queues.
  2926. */
  2927. void ieee80211_chswitch_done(struct ieee80211_vif *vif, bool success);
  2928. /**
  2929. * ieee80211_request_smps - request SM PS transition
  2930. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  2931. * @smps_mode: new SM PS mode
  2932. *
  2933. * This allows the driver to request an SM PS transition in managed
  2934. * mode. This is useful when the driver has more information than
  2935. * the stack about possible interference, for example by bluetooth.
  2936. */
  2937. void ieee80211_request_smps(struct ieee80211_vif *vif,
  2938. enum ieee80211_smps_mode smps_mode);
  2939. /**
  2940. * ieee80211_key_removed - disable hw acceleration for key
  2941. * @key_conf: The key hw acceleration should be disabled for
  2942. *
  2943. * This allows drivers to indicate that the given key has been
  2944. * removed from hardware acceleration, due to a new key that
  2945. * was added. Don't use this if the key can continue to be used
  2946. * for TX, if the key restriction is on RX only it is permitted
  2947. * to keep the key for TX only and not call this function.
  2948. *
  2949. * Due to locking constraints, it may only be called during
  2950. * @set_key. This function must be allowed to sleep, and the
  2951. * key it tries to disable may still be used until it returns.
  2952. */
  2953. void ieee80211_key_removed(struct ieee80211_key_conf *key_conf);
  2954. /**
  2955. * ieee80211_ready_on_channel - notification of remain-on-channel start
  2956. * @hw: pointer as obtained from ieee80211_alloc_hw()
  2957. */
  2958. void ieee80211_ready_on_channel(struct ieee80211_hw *hw);
  2959. /**
  2960. * ieee80211_remain_on_channel_expired - remain_on_channel duration expired
  2961. * @hw: pointer as obtained from ieee80211_alloc_hw()
  2962. */
  2963. void ieee80211_remain_on_channel_expired(struct ieee80211_hw *hw);
  2964. /**
  2965. * ieee80211_stop_rx_ba_session - callback to stop existing BA sessions
  2966. *
  2967. * in order not to harm the system performance and user experience, the device
  2968. * may request not to allow any rx ba session and tear down existing rx ba
  2969. * sessions based on system constraints such as periodic BT activity that needs
  2970. * to limit wlan activity (eg.sco or a2dp)."
  2971. * in such cases, the intention is to limit the duration of the rx ppdu and
  2972. * therefore prevent the peer device to use a-mpdu aggregation.
  2973. *
  2974. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  2975. * @ba_rx_bitmap: Bit map of open rx ba per tid
  2976. * @addr: & to bssid mac address
  2977. */
  2978. void ieee80211_stop_rx_ba_session(struct ieee80211_vif *vif, u16 ba_rx_bitmap,
  2979. const u8 *addr);
  2980. /* Rate control API */
  2981. /**
  2982. * enum rate_control_changed - flags to indicate which parameter changed
  2983. *
  2984. * @IEEE80211_RC_HT_CHANGED: The HT parameters of the operating channel have
  2985. * changed, rate control algorithm can update its internal state if needed.
  2986. */
  2987. enum rate_control_changed {
  2988. IEEE80211_RC_HT_CHANGED = BIT(0)
  2989. };
  2990. /**
  2991. * struct ieee80211_tx_rate_control - rate control information for/from RC algo
  2992. *
  2993. * @hw: The hardware the algorithm is invoked for.
  2994. * @sband: The band this frame is being transmitted on.
  2995. * @bss_conf: the current BSS configuration
  2996. * @reported_rate: The rate control algorithm can fill this in to indicate
  2997. * which rate should be reported to userspace as the current rate and
  2998. * used for rate calculations in the mesh network.
  2999. * @rts: whether RTS will be used for this frame because it is longer than the
  3000. * RTS threshold
  3001. * @short_preamble: whether mac80211 will request short-preamble transmission
  3002. * if the selected rate supports it
  3003. * @max_rate_idx: user-requested maximum rate (not MCS for now)
  3004. * (deprecated; this will be removed once drivers get updated to use
  3005. * rate_idx_mask)
  3006. * @rate_idx_mask: user-requested rate mask (not MCS for now)
  3007. * @skb: the skb that will be transmitted, the control information in it needs
  3008. * to be filled in
  3009. * @bss: whether this frame is sent out in AP or IBSS mode
  3010. */
  3011. struct ieee80211_tx_rate_control {
  3012. struct ieee80211_hw *hw;
  3013. struct ieee80211_supported_band *sband;
  3014. struct ieee80211_bss_conf *bss_conf;
  3015. struct sk_buff *skb;
  3016. struct ieee80211_tx_rate reported_rate;
  3017. bool rts, short_preamble;
  3018. u8 max_rate_idx;
  3019. u32 rate_idx_mask;
  3020. bool bss;
  3021. };
  3022. struct rate_control_ops {
  3023. struct module *module;
  3024. const char *name;
  3025. void *(*alloc)(struct ieee80211_hw *hw, struct dentry *debugfsdir);
  3026. void (*free)(void *priv);
  3027. void *(*alloc_sta)(void *priv, struct ieee80211_sta *sta, gfp_t gfp);
  3028. void (*rate_init)(void *priv, struct ieee80211_supported_band *sband,
  3029. struct ieee80211_sta *sta, void *priv_sta);
  3030. void (*rate_update)(void *priv, struct ieee80211_supported_band *sband,
  3031. struct ieee80211_sta *sta,
  3032. void *priv_sta, u32 changed,
  3033. enum nl80211_channel_type oper_chan_type);
  3034. void (*free_sta)(void *priv, struct ieee80211_sta *sta,
  3035. void *priv_sta);
  3036. void (*tx_status)(void *priv, struct ieee80211_supported_band *sband,
  3037. struct ieee80211_sta *sta, void *priv_sta,
  3038. struct sk_buff *skb);
  3039. void (*get_rate)(void *priv, struct ieee80211_sta *sta, void *priv_sta,
  3040. struct ieee80211_tx_rate_control *txrc);
  3041. void (*add_sta_debugfs)(void *priv, void *priv_sta,
  3042. struct dentry *dir);
  3043. void (*remove_sta_debugfs)(void *priv, void *priv_sta);
  3044. };
  3045. static inline int rate_supported(struct ieee80211_sta *sta,
  3046. enum ieee80211_band band,
  3047. int index)
  3048. {
  3049. return (sta == NULL || sta->supp_rates[band] & BIT(index));
  3050. }
  3051. /**
  3052. * rate_control_send_low - helper for drivers for management/no-ack frames
  3053. *
  3054. * Rate control algorithms that agree to use the lowest rate to
  3055. * send management frames and NO_ACK data with the respective hw
  3056. * retries should use this in the beginning of their mac80211 get_rate
  3057. * callback. If true is returned the rate control can simply return.
  3058. * If false is returned we guarantee that sta and sta and priv_sta is
  3059. * not null.
  3060. *
  3061. * Rate control algorithms wishing to do more intelligent selection of
  3062. * rate for multicast/broadcast frames may choose to not use this.
  3063. *
  3064. * @sta: &struct ieee80211_sta pointer to the target destination. Note
  3065. * that this may be null.
  3066. * @priv_sta: private rate control structure. This may be null.
  3067. * @txrc: rate control information we sholud populate for mac80211.
  3068. */
  3069. bool rate_control_send_low(struct ieee80211_sta *sta,
  3070. void *priv_sta,
  3071. struct ieee80211_tx_rate_control *txrc);
  3072. static inline s8
  3073. rate_lowest_index(struct ieee80211_supported_band *sband,
  3074. struct ieee80211_sta *sta)
  3075. {
  3076. int i;
  3077. for (i = 0; i < sband->n_bitrates; i++)
  3078. if (rate_supported(sta, sband->band, i))
  3079. return i;
  3080. /* warn when we cannot find a rate. */
  3081. WARN_ON(1);
  3082. return 0;
  3083. }
  3084. static inline
  3085. bool rate_usable_index_exists(struct ieee80211_supported_band *sband,
  3086. struct ieee80211_sta *sta)
  3087. {
  3088. unsigned int i;
  3089. for (i = 0; i < sband->n_bitrates; i++)
  3090. if (rate_supported(sta, sband->band, i))
  3091. return true;
  3092. return false;
  3093. }
  3094. int ieee80211_rate_control_register(struct rate_control_ops *ops);
  3095. void ieee80211_rate_control_unregister(struct rate_control_ops *ops);
  3096. static inline bool
  3097. conf_is_ht20(struct ieee80211_conf *conf)
  3098. {
  3099. return conf->channel_type == NL80211_CHAN_HT20;
  3100. }
  3101. static inline bool
  3102. conf_is_ht40_minus(struct ieee80211_conf *conf)
  3103. {
  3104. return conf->channel_type == NL80211_CHAN_HT40MINUS;
  3105. }
  3106. static inline bool
  3107. conf_is_ht40_plus(struct ieee80211_conf *conf)
  3108. {
  3109. return conf->channel_type == NL80211_CHAN_HT40PLUS;
  3110. }
  3111. static inline bool
  3112. conf_is_ht40(struct ieee80211_conf *conf)
  3113. {
  3114. return conf_is_ht40_minus(conf) || conf_is_ht40_plus(conf);
  3115. }
  3116. static inline bool
  3117. conf_is_ht(struct ieee80211_conf *conf)
  3118. {
  3119. return conf->channel_type != NL80211_CHAN_NO_HT;
  3120. }
  3121. static inline enum nl80211_iftype
  3122. ieee80211_iftype_p2p(enum nl80211_iftype type, bool p2p)
  3123. {
  3124. if (p2p) {
  3125. switch (type) {
  3126. case NL80211_IFTYPE_STATION:
  3127. return NL80211_IFTYPE_P2P_CLIENT;
  3128. case NL80211_IFTYPE_AP:
  3129. return NL80211_IFTYPE_P2P_GO;
  3130. default:
  3131. break;
  3132. }
  3133. }
  3134. return type;
  3135. }
  3136. static inline enum nl80211_iftype
  3137. ieee80211_vif_type_p2p(struct ieee80211_vif *vif)
  3138. {
  3139. return ieee80211_iftype_p2p(vif->type, vif->p2p);
  3140. }
  3141. #endif /* MAC80211_H */