mac80211.h 98 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604
  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. /**
  22. * DOC: Introduction
  23. *
  24. * mac80211 is the Linux stack for 802.11 hardware that implements
  25. * only partial functionality in hard- or firmware. This document
  26. * defines the interface between mac80211 and low-level hardware
  27. * drivers.
  28. */
  29. /**
  30. * DOC: Calling mac80211 from interrupts
  31. *
  32. * Only ieee80211_tx_status_irqsafe() and ieee80211_rx_irqsafe() can be
  33. * called in hardware interrupt context. The low-level driver must not call any
  34. * other functions in hardware interrupt context. If there is a need for such
  35. * call, the low-level driver should first ACK the interrupt and perform the
  36. * IEEE 802.11 code call after this, e.g. from a scheduled workqueue or even
  37. * tasklet function.
  38. *
  39. * NOTE: If the driver opts to use the _irqsafe() functions, it may not also
  40. * use the non-IRQ-safe functions!
  41. */
  42. /**
  43. * DOC: Warning
  44. *
  45. * If you're reading this document and not the header file itself, it will
  46. * be incomplete because not all documentation has been converted yet.
  47. */
  48. /**
  49. * DOC: Frame format
  50. *
  51. * As a general rule, when frames are passed between mac80211 and the driver,
  52. * they start with the IEEE 802.11 header and include the same octets that are
  53. * sent over the air except for the FCS which should be calculated by the
  54. * hardware.
  55. *
  56. * There are, however, various exceptions to this rule for advanced features:
  57. *
  58. * The first exception is for hardware encryption and decryption offload
  59. * where the IV/ICV may or may not be generated in hardware.
  60. *
  61. * Secondly, when the hardware handles fragmentation, the frame handed to
  62. * the driver from mac80211 is the MSDU, not the MPDU.
  63. *
  64. * Finally, for received frames, the driver is able to indicate that it has
  65. * filled a radiotap header and put that in front of the frame; if it does
  66. * not do so then mac80211 may add this under certain circumstances.
  67. */
  68. /**
  69. * DOC: mac80211 workqueue
  70. *
  71. * mac80211 provides its own workqueue for drivers and internal mac80211 use.
  72. * The workqueue is a single threaded workqueue and can only be accessed by
  73. * helpers for sanity checking. Drivers must ensure all work added onto the
  74. * mac80211 workqueue should be cancelled on the driver stop() callback.
  75. *
  76. * mac80211 will flushed the workqueue upon interface removal and during
  77. * suspend.
  78. *
  79. * All work performed on the mac80211 workqueue must not acquire the RTNL lock.
  80. *
  81. */
  82. /**
  83. * enum ieee80211_max_queues - maximum number of queues
  84. *
  85. * @IEEE80211_MAX_QUEUES: Maximum number of regular device queues.
  86. */
  87. enum ieee80211_max_queues {
  88. IEEE80211_MAX_QUEUES = 4,
  89. };
  90. /**
  91. * struct ieee80211_tx_queue_params - transmit queue configuration
  92. *
  93. * The information provided in this structure is required for QoS
  94. * transmit queue configuration. Cf. IEEE 802.11 7.3.2.29.
  95. *
  96. * @aifs: arbitration interframe space [0..255]
  97. * @cw_min: minimum contention window [a value of the form
  98. * 2^n-1 in the range 1..32767]
  99. * @cw_max: maximum contention window [like @cw_min]
  100. * @txop: maximum burst time in units of 32 usecs, 0 meaning disabled
  101. * @uapsd: is U-APSD mode enabled for the queue
  102. */
  103. struct ieee80211_tx_queue_params {
  104. u16 txop;
  105. u16 cw_min;
  106. u16 cw_max;
  107. u8 aifs;
  108. bool uapsd;
  109. };
  110. struct ieee80211_low_level_stats {
  111. unsigned int dot11ACKFailureCount;
  112. unsigned int dot11RTSFailureCount;
  113. unsigned int dot11FCSErrorCount;
  114. unsigned int dot11RTSSuccessCount;
  115. };
  116. /**
  117. * enum ieee80211_bss_change - BSS change notification flags
  118. *
  119. * These flags are used with the bss_info_changed() callback
  120. * to indicate which BSS parameter changed.
  121. *
  122. * @BSS_CHANGED_ASSOC: association status changed (associated/disassociated),
  123. * also implies a change in the AID.
  124. * @BSS_CHANGED_ERP_CTS_PROT: CTS protection changed
  125. * @BSS_CHANGED_ERP_PREAMBLE: preamble changed
  126. * @BSS_CHANGED_ERP_SLOT: slot timing changed
  127. * @BSS_CHANGED_HT: 802.11n parameters changed
  128. * @BSS_CHANGED_BASIC_RATES: Basic rateset changed
  129. * @BSS_CHANGED_BEACON_INT: Beacon interval changed
  130. * @BSS_CHANGED_BSSID: BSSID changed, for whatever
  131. * reason (IBSS and managed mode)
  132. * @BSS_CHANGED_BEACON: Beacon data changed, retrieve
  133. * new beacon (beaconing modes)
  134. * @BSS_CHANGED_BEACON_ENABLED: Beaconing should be
  135. * enabled/disabled (beaconing modes)
  136. * @BSS_CHANGED_CQM: Connection quality monitor config changed
  137. * @BSS_CHANGED_IBSS: IBSS join status changed
  138. */
  139. enum ieee80211_bss_change {
  140. BSS_CHANGED_ASSOC = 1<<0,
  141. BSS_CHANGED_ERP_CTS_PROT = 1<<1,
  142. BSS_CHANGED_ERP_PREAMBLE = 1<<2,
  143. BSS_CHANGED_ERP_SLOT = 1<<3,
  144. BSS_CHANGED_HT = 1<<4,
  145. BSS_CHANGED_BASIC_RATES = 1<<5,
  146. BSS_CHANGED_BEACON_INT = 1<<6,
  147. BSS_CHANGED_BSSID = 1<<7,
  148. BSS_CHANGED_BEACON = 1<<8,
  149. BSS_CHANGED_BEACON_ENABLED = 1<<9,
  150. BSS_CHANGED_CQM = 1<<10,
  151. BSS_CHANGED_IBSS = 1<<11,
  152. };
  153. /**
  154. * struct ieee80211_bss_conf - holds the BSS's changing parameters
  155. *
  156. * This structure keeps information about a BSS (and an association
  157. * to that BSS) that can change during the lifetime of the BSS.
  158. *
  159. * @assoc: association status
  160. * @ibss_joined: indicates whether this station is part of an IBSS
  161. * or not
  162. * @aid: association ID number, valid only when @assoc is true
  163. * @use_cts_prot: use CTS protection
  164. * @use_short_preamble: use 802.11b short preamble;
  165. * if the hardware cannot handle this it must set the
  166. * IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE hardware flag
  167. * @use_short_slot: use short slot time (only relevant for ERP);
  168. * if the hardware cannot handle this it must set the
  169. * IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE hardware flag
  170. * @dtim_period: num of beacons before the next DTIM, for beaconing,
  171. * not valid in station mode (cf. hw conf ps_dtim_period)
  172. * @timestamp: beacon timestamp
  173. * @beacon_int: beacon interval
  174. * @assoc_capability: capabilities taken from assoc resp
  175. * @basic_rates: bitmap of basic rates, each bit stands for an
  176. * index into the rate table configured by the driver in
  177. * the current band.
  178. * @bssid: The BSSID for this BSS
  179. * @enable_beacon: whether beaconing should be enabled or not
  180. * @ht_operation_mode: HT operation mode (like in &struct ieee80211_ht_info).
  181. * This field is only valid when the channel type is one of the HT types.
  182. * @cqm_rssi_thold: Connection quality monitor RSSI threshold, a zero value
  183. * implies disabled
  184. * @cqm_rssi_hyst: Connection quality monitor RSSI hysteresis
  185. */
  186. struct ieee80211_bss_conf {
  187. const u8 *bssid;
  188. /* association related data */
  189. bool assoc, ibss_joined;
  190. u16 aid;
  191. /* erp related data */
  192. bool use_cts_prot;
  193. bool use_short_preamble;
  194. bool use_short_slot;
  195. bool enable_beacon;
  196. u8 dtim_period;
  197. u16 beacon_int;
  198. u16 assoc_capability;
  199. u64 timestamp;
  200. u32 basic_rates;
  201. u16 ht_operation_mode;
  202. s32 cqm_rssi_thold;
  203. u32 cqm_rssi_hyst;
  204. };
  205. /**
  206. * enum mac80211_tx_control_flags - flags to describe transmission information/status
  207. *
  208. * These flags are used with the @flags member of &ieee80211_tx_info.
  209. *
  210. * @IEEE80211_TX_CTL_REQ_TX_STATUS: require TX status callback for this frame.
  211. * @IEEE80211_TX_CTL_ASSIGN_SEQ: The driver has to assign a sequence
  212. * number to this frame, taking care of not overwriting the fragment
  213. * number and increasing the sequence number only when the
  214. * IEEE80211_TX_CTL_FIRST_FRAGMENT flag is set. mac80211 will properly
  215. * assign sequence numbers to QoS-data frames but cannot do so correctly
  216. * for non-QoS-data and management frames because beacons need them from
  217. * that counter as well and mac80211 cannot guarantee proper sequencing.
  218. * If this flag is set, the driver should instruct the hardware to
  219. * assign a sequence number to the frame or assign one itself. Cf. IEEE
  220. * 802.11-2007 7.1.3.4.1 paragraph 3. This flag will always be set for
  221. * beacons and always be clear for frames without a sequence number field.
  222. * @IEEE80211_TX_CTL_NO_ACK: tell the low level not to wait for an ack
  223. * @IEEE80211_TX_CTL_CLEAR_PS_FILT: clear powersave filter for destination
  224. * station
  225. * @IEEE80211_TX_CTL_FIRST_FRAGMENT: this is a first fragment of the frame
  226. * @IEEE80211_TX_CTL_SEND_AFTER_DTIM: send this frame after DTIM beacon
  227. * @IEEE80211_TX_CTL_AMPDU: this frame should be sent as part of an A-MPDU
  228. * @IEEE80211_TX_CTL_INJECTED: Frame was injected, internal to mac80211.
  229. * @IEEE80211_TX_STAT_TX_FILTERED: The frame was not transmitted
  230. * because the destination STA was in powersave mode. Note that to
  231. * avoid race conditions, the filter must be set by the hardware or
  232. * firmware upon receiving a frame that indicates that the station
  233. * went to sleep (must be done on device to filter frames already on
  234. * the queue) and may only be unset after mac80211 gives the OK for
  235. * that by setting the IEEE80211_TX_CTL_CLEAR_PS_FILT (see above),
  236. * since only then is it guaranteed that no more frames are in the
  237. * hardware queue.
  238. * @IEEE80211_TX_STAT_ACK: Frame was acknowledged
  239. * @IEEE80211_TX_STAT_AMPDU: The frame was aggregated, so status
  240. * is for the whole aggregation.
  241. * @IEEE80211_TX_STAT_AMPDU_NO_BACK: no block ack was returned,
  242. * so consider using block ack request (BAR).
  243. * @IEEE80211_TX_CTL_RATE_CTRL_PROBE: internal to mac80211, can be
  244. * set by rate control algorithms to indicate probe rate, will
  245. * be cleared for fragmented frames (except on the last fragment)
  246. * @IEEE80211_TX_INTFL_NEED_TXPROCESSING: completely internal to mac80211,
  247. * used to indicate that a pending frame requires TX processing before
  248. * it can be sent out.
  249. * @IEEE80211_TX_INTFL_RETRIED: completely internal to mac80211,
  250. * used to indicate that a frame was already retried due to PS
  251. * @IEEE80211_TX_INTFL_DONT_ENCRYPT: completely internal to mac80211,
  252. * used to indicate frame should not be encrypted
  253. * @IEEE80211_TX_CTL_PSPOLL_RESPONSE: (internal?)
  254. * This frame is a response to a PS-poll frame and should be sent
  255. * although the station is in powersave mode.
  256. * @IEEE80211_TX_CTL_MORE_FRAMES: More frames will be passed to the
  257. * transmit function after the current frame, this can be used
  258. * by drivers to kick the DMA queue only if unset or when the
  259. * queue gets full.
  260. * @IEEE80211_TX_INTFL_RETRANSMISSION: This frame is being retransmitted
  261. * after TX status because the destination was asleep, it must not
  262. * be modified again (no seqno assignment, crypto, etc.)
  263. * @IEEE80211_TX_INTFL_HAS_RADIOTAP: This frame was injected and still
  264. * has a radiotap header at skb->data.
  265. * @IEEE80211_TX_INTFL_NL80211_FRAME_TX: Frame was requested through nl80211
  266. * MLME command (internal to mac80211 to figure out whether to send TX
  267. * status to user space)
  268. * @IEEE80211_TX_CTL_LDPC: tells the driver to use LDPC for this frame
  269. * @IEEE80211_TX_CTL_STBC: Enables Space-Time Block Coding (STBC) for this
  270. * frame and selects the maximum number of streams that it can use.
  271. */
  272. enum mac80211_tx_control_flags {
  273. IEEE80211_TX_CTL_REQ_TX_STATUS = BIT(0),
  274. IEEE80211_TX_CTL_ASSIGN_SEQ = BIT(1),
  275. IEEE80211_TX_CTL_NO_ACK = BIT(2),
  276. IEEE80211_TX_CTL_CLEAR_PS_FILT = BIT(3),
  277. IEEE80211_TX_CTL_FIRST_FRAGMENT = BIT(4),
  278. IEEE80211_TX_CTL_SEND_AFTER_DTIM = BIT(5),
  279. IEEE80211_TX_CTL_AMPDU = BIT(6),
  280. IEEE80211_TX_CTL_INJECTED = BIT(7),
  281. IEEE80211_TX_STAT_TX_FILTERED = BIT(8),
  282. IEEE80211_TX_STAT_ACK = BIT(9),
  283. IEEE80211_TX_STAT_AMPDU = BIT(10),
  284. IEEE80211_TX_STAT_AMPDU_NO_BACK = BIT(11),
  285. IEEE80211_TX_CTL_RATE_CTRL_PROBE = BIT(12),
  286. IEEE80211_TX_INTFL_NEED_TXPROCESSING = BIT(14),
  287. IEEE80211_TX_INTFL_RETRIED = BIT(15),
  288. IEEE80211_TX_INTFL_DONT_ENCRYPT = BIT(16),
  289. IEEE80211_TX_CTL_PSPOLL_RESPONSE = BIT(17),
  290. IEEE80211_TX_CTL_MORE_FRAMES = BIT(18),
  291. IEEE80211_TX_INTFL_RETRANSMISSION = BIT(19),
  292. IEEE80211_TX_INTFL_HAS_RADIOTAP = BIT(20),
  293. IEEE80211_TX_INTFL_NL80211_FRAME_TX = BIT(21),
  294. IEEE80211_TX_CTL_LDPC = BIT(22),
  295. IEEE80211_TX_CTL_STBC = BIT(23) | BIT(24),
  296. #define IEEE80211_TX_CTL_STBC_SHIFT 23
  297. };
  298. /**
  299. * enum mac80211_rate_control_flags - per-rate flags set by the
  300. * Rate Control algorithm.
  301. *
  302. * These flags are set by the Rate control algorithm for each rate during tx,
  303. * in the @flags member of struct ieee80211_tx_rate.
  304. *
  305. * @IEEE80211_TX_RC_USE_RTS_CTS: Use RTS/CTS exchange for this rate.
  306. * @IEEE80211_TX_RC_USE_CTS_PROTECT: CTS-to-self protection is required.
  307. * This is set if the current BSS requires ERP protection.
  308. * @IEEE80211_TX_RC_USE_SHORT_PREAMBLE: Use short preamble.
  309. * @IEEE80211_TX_RC_MCS: HT rate.
  310. * @IEEE80211_TX_RC_GREEN_FIELD: Indicates whether this rate should be used in
  311. * Greenfield mode.
  312. * @IEEE80211_TX_RC_40_MHZ_WIDTH: Indicates if the Channel Width should be 40 MHz.
  313. * @IEEE80211_TX_RC_DUP_DATA: The frame should be transmitted on both of the
  314. * adjacent 20 MHz channels, if the current channel type is
  315. * NL80211_CHAN_HT40MINUS or NL80211_CHAN_HT40PLUS.
  316. * @IEEE80211_TX_RC_SHORT_GI: Short Guard interval should be used for this rate.
  317. */
  318. enum mac80211_rate_control_flags {
  319. IEEE80211_TX_RC_USE_RTS_CTS = BIT(0),
  320. IEEE80211_TX_RC_USE_CTS_PROTECT = BIT(1),
  321. IEEE80211_TX_RC_USE_SHORT_PREAMBLE = BIT(2),
  322. /* rate index is an MCS rate number instead of an index */
  323. IEEE80211_TX_RC_MCS = BIT(3),
  324. IEEE80211_TX_RC_GREEN_FIELD = BIT(4),
  325. IEEE80211_TX_RC_40_MHZ_WIDTH = BIT(5),
  326. IEEE80211_TX_RC_DUP_DATA = BIT(6),
  327. IEEE80211_TX_RC_SHORT_GI = BIT(7),
  328. };
  329. /* there are 40 bytes if you don't need the rateset to be kept */
  330. #define IEEE80211_TX_INFO_DRIVER_DATA_SIZE 40
  331. /* if you do need the rateset, then you have less space */
  332. #define IEEE80211_TX_INFO_RATE_DRIVER_DATA_SIZE 24
  333. /* maximum number of rate stages */
  334. #define IEEE80211_TX_MAX_RATES 5
  335. /**
  336. * struct ieee80211_tx_rate - rate selection/status
  337. *
  338. * @idx: rate index to attempt to send with
  339. * @flags: rate control flags (&enum mac80211_rate_control_flags)
  340. * @count: number of tries in this rate before going to the next rate
  341. *
  342. * A value of -1 for @idx indicates an invalid rate and, if used
  343. * in an array of retry rates, that no more rates should be tried.
  344. *
  345. * When used for transmit status reporting, the driver should
  346. * always report the rate along with the flags it used.
  347. *
  348. * &struct ieee80211_tx_info contains an array of these structs
  349. * in the control information, and it will be filled by the rate
  350. * control algorithm according to what should be sent. For example,
  351. * if this array contains, in the format { <idx>, <count> } the
  352. * information
  353. * { 3, 2 }, { 2, 2 }, { 1, 4 }, { -1, 0 }, { -1, 0 }
  354. * then this means that the frame should be transmitted
  355. * up to twice at rate 3, up to twice at rate 2, and up to four
  356. * times at rate 1 if it doesn't get acknowledged. Say it gets
  357. * acknowledged by the peer after the fifth attempt, the status
  358. * information should then contain
  359. * { 3, 2 }, { 2, 2 }, { 1, 1 }, { -1, 0 } ...
  360. * since it was transmitted twice at rate 3, twice at rate 2
  361. * and once at rate 1 after which we received an acknowledgement.
  362. */
  363. struct ieee80211_tx_rate {
  364. s8 idx;
  365. u8 count;
  366. u8 flags;
  367. } __attribute__((packed));
  368. /**
  369. * struct ieee80211_tx_info - skb transmit information
  370. *
  371. * This structure is placed in skb->cb for three uses:
  372. * (1) mac80211 TX control - mac80211 tells the driver what to do
  373. * (2) driver internal use (if applicable)
  374. * (3) TX status information - driver tells mac80211 what happened
  375. *
  376. * The TX control's sta pointer is only valid during the ->tx call,
  377. * it may be NULL.
  378. *
  379. * @flags: transmit info flags, defined above
  380. * @band: the band to transmit on (use for checking for races)
  381. * @antenna_sel_tx: antenna to use, 0 for automatic diversity
  382. * @pad: padding, ignore
  383. * @control: union for control data
  384. * @status: union for status data
  385. * @driver_data: array of driver_data pointers
  386. * @ampdu_ack_len: number of acked aggregated frames.
  387. * relevant only if IEEE80211_TX_STAT_AMPDU was set.
  388. * @ampdu_ack_map: block ack bit map for the aggregation.
  389. * relevant only if IEEE80211_TX_STAT_AMPDU was set.
  390. * @ampdu_len: number of aggregated frames.
  391. * relevant only if IEEE80211_TX_STAT_AMPDU was set.
  392. * @ack_signal: signal strength of the ACK frame
  393. */
  394. struct ieee80211_tx_info {
  395. /* common information */
  396. u32 flags;
  397. u8 band;
  398. u8 antenna_sel_tx;
  399. /* 2 byte hole */
  400. u8 pad[2];
  401. union {
  402. struct {
  403. union {
  404. /* rate control */
  405. struct {
  406. struct ieee80211_tx_rate rates[
  407. IEEE80211_TX_MAX_RATES];
  408. s8 rts_cts_rate_idx;
  409. };
  410. /* only needed before rate control */
  411. unsigned long jiffies;
  412. };
  413. /* NB: vif can be NULL for injected frames */
  414. struct ieee80211_vif *vif;
  415. struct ieee80211_key_conf *hw_key;
  416. struct ieee80211_sta *sta;
  417. } control;
  418. struct {
  419. struct ieee80211_tx_rate rates[IEEE80211_TX_MAX_RATES];
  420. u8 ampdu_ack_len;
  421. u64 ampdu_ack_map;
  422. int ack_signal;
  423. u8 ampdu_len;
  424. /* 7 bytes free */
  425. } status;
  426. struct {
  427. struct ieee80211_tx_rate driver_rates[
  428. IEEE80211_TX_MAX_RATES];
  429. void *rate_driver_data[
  430. IEEE80211_TX_INFO_RATE_DRIVER_DATA_SIZE / sizeof(void *)];
  431. };
  432. void *driver_data[
  433. IEEE80211_TX_INFO_DRIVER_DATA_SIZE / sizeof(void *)];
  434. };
  435. };
  436. static inline struct ieee80211_tx_info *IEEE80211_SKB_CB(struct sk_buff *skb)
  437. {
  438. return (struct ieee80211_tx_info *)skb->cb;
  439. }
  440. static inline struct ieee80211_rx_status *IEEE80211_SKB_RXCB(struct sk_buff *skb)
  441. {
  442. return (struct ieee80211_rx_status *)skb->cb;
  443. }
  444. /**
  445. * ieee80211_tx_info_clear_status - clear TX status
  446. *
  447. * @info: The &struct ieee80211_tx_info to be cleared.
  448. *
  449. * When the driver passes an skb back to mac80211, it must report
  450. * a number of things in TX status. This function clears everything
  451. * in the TX status but the rate control information (it does clear
  452. * the count since you need to fill that in anyway).
  453. *
  454. * NOTE: You can only use this function if you do NOT use
  455. * info->driver_data! Use info->rate_driver_data
  456. * instead if you need only the less space that allows.
  457. */
  458. static inline void
  459. ieee80211_tx_info_clear_status(struct ieee80211_tx_info *info)
  460. {
  461. int i;
  462. BUILD_BUG_ON(offsetof(struct ieee80211_tx_info, status.rates) !=
  463. offsetof(struct ieee80211_tx_info, control.rates));
  464. BUILD_BUG_ON(offsetof(struct ieee80211_tx_info, status.rates) !=
  465. offsetof(struct ieee80211_tx_info, driver_rates));
  466. BUILD_BUG_ON(offsetof(struct ieee80211_tx_info, status.rates) != 8);
  467. /* clear the rate counts */
  468. for (i = 0; i < IEEE80211_TX_MAX_RATES; i++)
  469. info->status.rates[i].count = 0;
  470. BUILD_BUG_ON(
  471. offsetof(struct ieee80211_tx_info, status.ampdu_ack_len) != 23);
  472. memset(&info->status.ampdu_ack_len, 0,
  473. sizeof(struct ieee80211_tx_info) -
  474. offsetof(struct ieee80211_tx_info, status.ampdu_ack_len));
  475. }
  476. /**
  477. * enum mac80211_rx_flags - receive flags
  478. *
  479. * These flags are used with the @flag member of &struct ieee80211_rx_status.
  480. * @RX_FLAG_MMIC_ERROR: Michael MIC error was reported on this frame.
  481. * Use together with %RX_FLAG_MMIC_STRIPPED.
  482. * @RX_FLAG_DECRYPTED: This frame was decrypted in hardware.
  483. * @RX_FLAG_MMIC_STRIPPED: the Michael MIC is stripped off this frame,
  484. * verification has been done by the hardware.
  485. * @RX_FLAG_IV_STRIPPED: The IV/ICV are stripped from this frame.
  486. * If this flag is set, the stack cannot do any replay detection
  487. * hence the driver or hardware will have to do that.
  488. * @RX_FLAG_FAILED_FCS_CRC: Set this flag if the FCS check failed on
  489. * the frame.
  490. * @RX_FLAG_FAILED_PLCP_CRC: Set this flag if the PCLP check failed on
  491. * the frame.
  492. * @RX_FLAG_TSFT: The timestamp passed in the RX status (@mactime field)
  493. * is valid. This is useful in monitor mode and necessary for beacon frames
  494. * to enable IBSS merging.
  495. * @RX_FLAG_SHORTPRE: Short preamble was used for this frame
  496. * @RX_FLAG_HT: HT MCS was used and rate_idx is MCS index
  497. * @RX_FLAG_40MHZ: HT40 (40 MHz) was used
  498. * @RX_FLAG_SHORT_GI: Short guard interval was used
  499. * @RX_FLAG_INTERNAL_CMTR: set internally after frame was reported
  500. * on cooked monitor to avoid double-reporting it for multiple
  501. * virtual interfaces
  502. */
  503. enum mac80211_rx_flags {
  504. RX_FLAG_MMIC_ERROR = 1<<0,
  505. RX_FLAG_DECRYPTED = 1<<1,
  506. RX_FLAG_MMIC_STRIPPED = 1<<3,
  507. RX_FLAG_IV_STRIPPED = 1<<4,
  508. RX_FLAG_FAILED_FCS_CRC = 1<<5,
  509. RX_FLAG_FAILED_PLCP_CRC = 1<<6,
  510. RX_FLAG_TSFT = 1<<7,
  511. RX_FLAG_SHORTPRE = 1<<8,
  512. RX_FLAG_HT = 1<<9,
  513. RX_FLAG_40MHZ = 1<<10,
  514. RX_FLAG_SHORT_GI = 1<<11,
  515. RX_FLAG_INTERNAL_CMTR = 1<<12,
  516. };
  517. /**
  518. * struct ieee80211_rx_status - receive status
  519. *
  520. * The low-level driver should provide this information (the subset
  521. * supported by hardware) to the 802.11 code with each received
  522. * frame, in the skb's control buffer (cb).
  523. *
  524. * @mactime: value in microseconds of the 64-bit Time Synchronization Function
  525. * (TSF) timer when the first data symbol (MPDU) arrived at the hardware.
  526. * @band: the active band when this frame was received
  527. * @freq: frequency the radio was tuned to when receiving this frame, in MHz
  528. * @signal: signal strength when receiving this frame, either in dBm, in dB or
  529. * unspecified depending on the hardware capabilities flags
  530. * @IEEE80211_HW_SIGNAL_*
  531. * @antenna: antenna used
  532. * @rate_idx: index of data rate into band's supported rates or MCS index if
  533. * HT rates are use (RX_FLAG_HT)
  534. * @flag: %RX_FLAG_*
  535. */
  536. struct ieee80211_rx_status {
  537. u64 mactime;
  538. enum ieee80211_band band;
  539. int freq;
  540. int signal;
  541. int antenna;
  542. int rate_idx;
  543. int flag;
  544. };
  545. /**
  546. * enum ieee80211_conf_flags - configuration flags
  547. *
  548. * Flags to define PHY configuration options
  549. *
  550. * @IEEE80211_CONF_MONITOR: there's a monitor interface present -- use this
  551. * to determine for example whether to calculate timestamps for packets
  552. * or not, do not use instead of filter flags!
  553. * @IEEE80211_CONF_PS: Enable 802.11 power save mode (managed mode only).
  554. * This is the power save mode defined by IEEE 802.11-2007 section 11.2,
  555. * meaning that the hardware still wakes up for beacons, is able to
  556. * transmit frames and receive the possible acknowledgment frames.
  557. * Not to be confused with hardware specific wakeup/sleep states,
  558. * driver is responsible for that. See the section "Powersave support"
  559. * for more.
  560. * @IEEE80211_CONF_IDLE: The device is running, but idle; if the flag is set
  561. * the driver should be prepared to handle configuration requests but
  562. * may turn the device off as much as possible. Typically, this flag will
  563. * be set when an interface is set UP but not associated or scanning, but
  564. * it can also be unset in that case when monitor interfaces are active.
  565. * @IEEE80211_CONF_QOS: Enable 802.11e QoS also know as WMM (Wireless
  566. * Multimedia). On some drivers (iwlwifi is one of know) we have
  567. * to enable/disable QoS explicitly.
  568. */
  569. enum ieee80211_conf_flags {
  570. IEEE80211_CONF_MONITOR = (1<<0),
  571. IEEE80211_CONF_PS = (1<<1),
  572. IEEE80211_CONF_IDLE = (1<<2),
  573. IEEE80211_CONF_QOS = (1<<3),
  574. };
  575. /**
  576. * enum ieee80211_conf_changed - denotes which configuration changed
  577. *
  578. * @IEEE80211_CONF_CHANGE_LISTEN_INTERVAL: the listen interval changed
  579. * @IEEE80211_CONF_CHANGE_MONITOR: the monitor flag changed
  580. * @IEEE80211_CONF_CHANGE_PS: the PS flag or dynamic PS timeout changed
  581. * @IEEE80211_CONF_CHANGE_POWER: the TX power changed
  582. * @IEEE80211_CONF_CHANGE_CHANNEL: the channel/channel_type changed
  583. * @IEEE80211_CONF_CHANGE_RETRY_LIMITS: retry limits changed
  584. * @IEEE80211_CONF_CHANGE_IDLE: Idle flag changed
  585. * @IEEE80211_CONF_CHANGE_SMPS: Spatial multiplexing powersave mode changed
  586. * @IEEE80211_CONF_CHANGE_QOS: Quality of service was enabled or disabled
  587. */
  588. enum ieee80211_conf_changed {
  589. IEEE80211_CONF_CHANGE_SMPS = BIT(1),
  590. IEEE80211_CONF_CHANGE_LISTEN_INTERVAL = BIT(2),
  591. IEEE80211_CONF_CHANGE_MONITOR = BIT(3),
  592. IEEE80211_CONF_CHANGE_PS = BIT(4),
  593. IEEE80211_CONF_CHANGE_POWER = BIT(5),
  594. IEEE80211_CONF_CHANGE_CHANNEL = BIT(6),
  595. IEEE80211_CONF_CHANGE_RETRY_LIMITS = BIT(7),
  596. IEEE80211_CONF_CHANGE_IDLE = BIT(8),
  597. IEEE80211_CONF_CHANGE_QOS = BIT(9),
  598. };
  599. /**
  600. * enum ieee80211_smps_mode - spatial multiplexing power save mode
  601. *
  602. * @IEEE80211_SMPS_AUTOMATIC: automatic
  603. * @IEEE80211_SMPS_OFF: off
  604. * @IEEE80211_SMPS_STATIC: static
  605. * @IEEE80211_SMPS_DYNAMIC: dynamic
  606. * @IEEE80211_SMPS_NUM_MODES: internal, don't use
  607. */
  608. enum ieee80211_smps_mode {
  609. IEEE80211_SMPS_AUTOMATIC,
  610. IEEE80211_SMPS_OFF,
  611. IEEE80211_SMPS_STATIC,
  612. IEEE80211_SMPS_DYNAMIC,
  613. /* keep last */
  614. IEEE80211_SMPS_NUM_MODES,
  615. };
  616. /**
  617. * struct ieee80211_conf - configuration of the device
  618. *
  619. * This struct indicates how the driver shall configure the hardware.
  620. *
  621. * @flags: configuration flags defined above
  622. *
  623. * @listen_interval: listen interval in units of beacon interval
  624. * @max_sleep_period: the maximum number of beacon intervals to sleep for
  625. * before checking the beacon for a TIM bit (managed mode only); this
  626. * value will be only achievable between DTIM frames, the hardware
  627. * needs to check for the multicast traffic bit in DTIM beacons.
  628. * This variable is valid only when the CONF_PS flag is set.
  629. * @ps_dtim_period: The DTIM period of the AP we're connected to, for use
  630. * in power saving. Power saving will not be enabled until a beacon
  631. * has been received and the DTIM period is known.
  632. * @dynamic_ps_timeout: The dynamic powersave timeout (in ms), see the
  633. * powersave documentation below. This variable is valid only when
  634. * the CONF_PS flag is set.
  635. * @dynamic_ps_forced_timeout: The dynamic powersave timeout (in ms) configured
  636. * by cfg80211 (essentially, wext) If set, this value overrules the value
  637. * chosen by mac80211 based on ps qos network latency.
  638. *
  639. * @power_level: requested transmit power (in dBm)
  640. *
  641. * @channel: the channel to tune to
  642. * @channel_type: the channel (HT) type
  643. *
  644. * @long_frame_max_tx_count: Maximum number of transmissions for a "long" frame
  645. * (a frame not RTS protected), called "dot11LongRetryLimit" in 802.11,
  646. * but actually means the number of transmissions not the number of retries
  647. * @short_frame_max_tx_count: Maximum number of transmissions for a "short"
  648. * frame, called "dot11ShortRetryLimit" in 802.11, but actually means the
  649. * number of transmissions not the number of retries
  650. *
  651. * @smps_mode: spatial multiplexing powersave mode; note that
  652. * %IEEE80211_SMPS_STATIC is used when the device is not
  653. * configured for an HT channel
  654. */
  655. struct ieee80211_conf {
  656. u32 flags;
  657. int power_level, dynamic_ps_timeout, dynamic_ps_forced_timeout;
  658. int max_sleep_period;
  659. u16 listen_interval;
  660. u8 ps_dtim_period;
  661. u8 long_frame_max_tx_count, short_frame_max_tx_count;
  662. struct ieee80211_channel *channel;
  663. enum nl80211_channel_type channel_type;
  664. enum ieee80211_smps_mode smps_mode;
  665. };
  666. /**
  667. * struct ieee80211_vif - per-interface data
  668. *
  669. * Data in this structure is continually present for driver
  670. * use during the life of a virtual interface.
  671. *
  672. * @type: type of this virtual interface
  673. * @bss_conf: BSS configuration for this interface, either our own
  674. * or the BSS we're associated to
  675. * @addr: address of this interface
  676. * @drv_priv: data area for driver use, will always be aligned to
  677. * sizeof(void *).
  678. */
  679. struct ieee80211_vif {
  680. enum nl80211_iftype type;
  681. struct ieee80211_bss_conf bss_conf;
  682. u8 addr[ETH_ALEN];
  683. /* must be last */
  684. u8 drv_priv[0] __attribute__((__aligned__(sizeof(void *))));
  685. };
  686. static inline bool ieee80211_vif_is_mesh(struct ieee80211_vif *vif)
  687. {
  688. #ifdef CONFIG_MAC80211_MESH
  689. return vif->type == NL80211_IFTYPE_MESH_POINT;
  690. #endif
  691. return false;
  692. }
  693. /**
  694. * enum ieee80211_key_alg - key algorithm
  695. * @ALG_WEP: WEP40 or WEP104
  696. * @ALG_TKIP: TKIP
  697. * @ALG_CCMP: CCMP (AES)
  698. * @ALG_AES_CMAC: AES-128-CMAC
  699. */
  700. enum ieee80211_key_alg {
  701. ALG_WEP,
  702. ALG_TKIP,
  703. ALG_CCMP,
  704. ALG_AES_CMAC,
  705. };
  706. /**
  707. * enum ieee80211_key_flags - key flags
  708. *
  709. * These flags are used for communication about keys between the driver
  710. * and mac80211, with the @flags parameter of &struct ieee80211_key_conf.
  711. *
  712. * @IEEE80211_KEY_FLAG_WMM_STA: Set by mac80211, this flag indicates
  713. * that the STA this key will be used with could be using QoS.
  714. * @IEEE80211_KEY_FLAG_GENERATE_IV: This flag should be set by the
  715. * driver to indicate that it requires IV generation for this
  716. * particular key.
  717. * @IEEE80211_KEY_FLAG_GENERATE_MMIC: This flag should be set by
  718. * the driver for a TKIP key if it requires Michael MIC
  719. * generation in software.
  720. * @IEEE80211_KEY_FLAG_PAIRWISE: Set by mac80211, this flag indicates
  721. * that the key is pairwise rather then a shared key.
  722. * @IEEE80211_KEY_FLAG_SW_MGMT: This flag should be set by the driver for a
  723. * CCMP key if it requires CCMP encryption of management frames (MFP) to
  724. * be done in software.
  725. */
  726. enum ieee80211_key_flags {
  727. IEEE80211_KEY_FLAG_WMM_STA = 1<<0,
  728. IEEE80211_KEY_FLAG_GENERATE_IV = 1<<1,
  729. IEEE80211_KEY_FLAG_GENERATE_MMIC= 1<<2,
  730. IEEE80211_KEY_FLAG_PAIRWISE = 1<<3,
  731. IEEE80211_KEY_FLAG_SW_MGMT = 1<<4,
  732. };
  733. /**
  734. * struct ieee80211_key_conf - key information
  735. *
  736. * This key information is given by mac80211 to the driver by
  737. * the set_key() callback in &struct ieee80211_ops.
  738. *
  739. * @hw_key_idx: To be set by the driver, this is the key index the driver
  740. * wants to be given when a frame is transmitted and needs to be
  741. * encrypted in hardware.
  742. * @alg: The key algorithm.
  743. * @flags: key flags, see &enum ieee80211_key_flags.
  744. * @keyidx: the key index (0-3)
  745. * @keylen: key material length
  746. * @key: key material. For ALG_TKIP the key is encoded as a 256-bit (32 byte)
  747. * data block:
  748. * - Temporal Encryption Key (128 bits)
  749. * - Temporal Authenticator Tx MIC Key (64 bits)
  750. * - Temporal Authenticator Rx MIC Key (64 bits)
  751. * @icv_len: The ICV length for this key type
  752. * @iv_len: The IV length for this key type
  753. */
  754. struct ieee80211_key_conf {
  755. enum ieee80211_key_alg alg;
  756. u8 icv_len;
  757. u8 iv_len;
  758. u8 hw_key_idx;
  759. u8 flags;
  760. u8 *ap_addr;
  761. s8 keyidx;
  762. u8 keylen;
  763. u8 key[0];
  764. };
  765. /**
  766. * enum set_key_cmd - key command
  767. *
  768. * Used with the set_key() callback in &struct ieee80211_ops, this
  769. * indicates whether a key is being removed or added.
  770. *
  771. * @SET_KEY: a key is set
  772. * @DISABLE_KEY: a key must be disabled
  773. */
  774. enum set_key_cmd {
  775. SET_KEY, DISABLE_KEY,
  776. };
  777. /**
  778. * struct ieee80211_sta - station table entry
  779. *
  780. * A station table entry represents a station we are possibly
  781. * communicating with. Since stations are RCU-managed in
  782. * mac80211, any ieee80211_sta pointer you get access to must
  783. * either be protected by rcu_read_lock() explicitly or implicitly,
  784. * or you must take good care to not use such a pointer after a
  785. * call to your sta_remove callback that removed it.
  786. *
  787. * @addr: MAC address
  788. * @aid: AID we assigned to the station if we're an AP
  789. * @supp_rates: Bitmap of supported rates (per band)
  790. * @ht_cap: HT capabilities of this STA; restricted to our own TX capabilities
  791. * @drv_priv: data area for driver use, will always be aligned to
  792. * sizeof(void *), size is determined in hw information.
  793. */
  794. struct ieee80211_sta {
  795. u32 supp_rates[IEEE80211_NUM_BANDS];
  796. u8 addr[ETH_ALEN];
  797. u16 aid;
  798. struct ieee80211_sta_ht_cap ht_cap;
  799. /* must be last */
  800. u8 drv_priv[0] __attribute__((__aligned__(sizeof(void *))));
  801. };
  802. /**
  803. * enum sta_notify_cmd - sta notify command
  804. *
  805. * Used with the sta_notify() callback in &struct ieee80211_ops, this
  806. * indicates addition and removal of a station to station table,
  807. * or if a associated station made a power state transition.
  808. *
  809. * @STA_NOTIFY_ADD: (DEPRECATED) a station was added to the station table
  810. * @STA_NOTIFY_REMOVE: (DEPRECATED) a station being removed from the station table
  811. * @STA_NOTIFY_SLEEP: a station is now sleeping
  812. * @STA_NOTIFY_AWAKE: a sleeping station woke up
  813. */
  814. enum sta_notify_cmd {
  815. STA_NOTIFY_ADD, STA_NOTIFY_REMOVE,
  816. STA_NOTIFY_SLEEP, STA_NOTIFY_AWAKE,
  817. };
  818. /**
  819. * enum ieee80211_tkip_key_type - get tkip key
  820. *
  821. * Used by drivers which need to get a tkip key for skb. Some drivers need a
  822. * phase 1 key, others need a phase 2 key. A single function allows the driver
  823. * to get the key, this enum indicates what type of key is required.
  824. *
  825. * @IEEE80211_TKIP_P1_KEY: the driver needs a phase 1 key
  826. * @IEEE80211_TKIP_P2_KEY: the driver needs a phase 2 key
  827. */
  828. enum ieee80211_tkip_key_type {
  829. IEEE80211_TKIP_P1_KEY,
  830. IEEE80211_TKIP_P2_KEY,
  831. };
  832. /**
  833. * enum ieee80211_hw_flags - hardware flags
  834. *
  835. * These flags are used to indicate hardware capabilities to
  836. * the stack. Generally, flags here should have their meaning
  837. * done in a way that the simplest hardware doesn't need setting
  838. * any particular flags. There are some exceptions to this rule,
  839. * however, so you are advised to review these flags carefully.
  840. *
  841. * @IEEE80211_HW_HAS_RATE_CONTROL:
  842. * The hardware or firmware includes rate control, and cannot be
  843. * controlled by the stack. As such, no rate control algorithm
  844. * should be instantiated, and the TX rate reported to userspace
  845. * will be taken from the TX status instead of the rate control
  846. * algorithm.
  847. * Note that this requires that the driver implement a number of
  848. * callbacks so it has the correct information, it needs to have
  849. * the @set_rts_threshold callback and must look at the BSS config
  850. * @use_cts_prot for G/N protection, @use_short_slot for slot
  851. * timing in 2.4 GHz and @use_short_preamble for preambles for
  852. * CCK frames.
  853. *
  854. * @IEEE80211_HW_RX_INCLUDES_FCS:
  855. * Indicates that received frames passed to the stack include
  856. * the FCS at the end.
  857. *
  858. * @IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING:
  859. * Some wireless LAN chipsets buffer broadcast/multicast frames
  860. * for power saving stations in the hardware/firmware and others
  861. * rely on the host system for such buffering. This option is used
  862. * to configure the IEEE 802.11 upper layer to buffer broadcast and
  863. * multicast frames when there are power saving stations so that
  864. * the driver can fetch them with ieee80211_get_buffered_bc().
  865. *
  866. * @IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE:
  867. * Hardware is not capable of short slot operation on the 2.4 GHz band.
  868. *
  869. * @IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE:
  870. * Hardware is not capable of receiving frames with short preamble on
  871. * the 2.4 GHz band.
  872. *
  873. * @IEEE80211_HW_SIGNAL_UNSPEC:
  874. * Hardware can provide signal values but we don't know its units. We
  875. * expect values between 0 and @max_signal.
  876. * If possible please provide dB or dBm instead.
  877. *
  878. * @IEEE80211_HW_SIGNAL_DBM:
  879. * Hardware gives signal values in dBm, decibel difference from
  880. * one milliwatt. This is the preferred method since it is standardized
  881. * between different devices. @max_signal does not need to be set.
  882. *
  883. * @IEEE80211_HW_SPECTRUM_MGMT:
  884. * Hardware supports spectrum management defined in 802.11h
  885. * Measurement, Channel Switch, Quieting, TPC
  886. *
  887. * @IEEE80211_HW_AMPDU_AGGREGATION:
  888. * Hardware supports 11n A-MPDU aggregation.
  889. *
  890. * @IEEE80211_HW_SUPPORTS_PS:
  891. * Hardware has power save support (i.e. can go to sleep).
  892. *
  893. * @IEEE80211_HW_PS_NULLFUNC_STACK:
  894. * Hardware requires nullfunc frame handling in stack, implies
  895. * stack support for dynamic PS.
  896. *
  897. * @IEEE80211_HW_SUPPORTS_DYNAMIC_PS:
  898. * Hardware has support for dynamic PS.
  899. *
  900. * @IEEE80211_HW_MFP_CAPABLE:
  901. * Hardware supports management frame protection (MFP, IEEE 802.11w).
  902. *
  903. * @IEEE80211_HW_BEACON_FILTER:
  904. * Hardware supports dropping of irrelevant beacon frames to
  905. * avoid waking up cpu.
  906. *
  907. * @IEEE80211_HW_SUPPORTS_STATIC_SMPS:
  908. * Hardware supports static spatial multiplexing powersave,
  909. * ie. can turn off all but one chain even on HT connections
  910. * that should be using more chains.
  911. *
  912. * @IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS:
  913. * Hardware supports dynamic spatial multiplexing powersave,
  914. * ie. can turn off all but one chain and then wake the rest
  915. * up as required after, for example, rts/cts handshake.
  916. *
  917. * @IEEE80211_HW_SUPPORTS_UAPSD:
  918. * Hardware supports Unscheduled Automatic Power Save Delivery
  919. * (U-APSD) in managed mode. The mode is configured with
  920. * conf_tx() operation.
  921. *
  922. * @IEEE80211_HW_REPORTS_TX_ACK_STATUS:
  923. * Hardware can provide ack status reports of Tx frames to
  924. * the stack.
  925. *
  926. * @IEEE80211_HW_CONNECTION_MONITOR:
  927. * The hardware performs its own connection monitoring, including
  928. * periodic keep-alives to the AP and probing the AP on beacon loss.
  929. * When this flag is set, signaling beacon-loss will cause an immediate
  930. * change to disassociated state.
  931. *
  932. * @IEEE80211_HW_SUPPORTS_CQM_RSSI:
  933. * Hardware can do connection quality monitoring - i.e. it can monitor
  934. * connection quality related parameters, such as the RSSI level and
  935. * provide notifications if configured trigger levels are reached.
  936. *
  937. */
  938. enum ieee80211_hw_flags {
  939. IEEE80211_HW_HAS_RATE_CONTROL = 1<<0,
  940. IEEE80211_HW_RX_INCLUDES_FCS = 1<<1,
  941. IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING = 1<<2,
  942. IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE = 1<<3,
  943. IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE = 1<<4,
  944. IEEE80211_HW_SIGNAL_UNSPEC = 1<<5,
  945. IEEE80211_HW_SIGNAL_DBM = 1<<6,
  946. /* use this hole */
  947. IEEE80211_HW_SPECTRUM_MGMT = 1<<8,
  948. IEEE80211_HW_AMPDU_AGGREGATION = 1<<9,
  949. IEEE80211_HW_SUPPORTS_PS = 1<<10,
  950. IEEE80211_HW_PS_NULLFUNC_STACK = 1<<11,
  951. IEEE80211_HW_SUPPORTS_DYNAMIC_PS = 1<<12,
  952. IEEE80211_HW_MFP_CAPABLE = 1<<13,
  953. IEEE80211_HW_BEACON_FILTER = 1<<14,
  954. IEEE80211_HW_SUPPORTS_STATIC_SMPS = 1<<15,
  955. IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS = 1<<16,
  956. IEEE80211_HW_SUPPORTS_UAPSD = 1<<17,
  957. IEEE80211_HW_REPORTS_TX_ACK_STATUS = 1<<18,
  958. IEEE80211_HW_CONNECTION_MONITOR = 1<<19,
  959. IEEE80211_HW_SUPPORTS_CQM_RSSI = 1<<20,
  960. };
  961. /**
  962. * struct ieee80211_hw - hardware information and state
  963. *
  964. * This structure contains the configuration and hardware
  965. * information for an 802.11 PHY.
  966. *
  967. * @wiphy: This points to the &struct wiphy allocated for this
  968. * 802.11 PHY. You must fill in the @perm_addr and @dev
  969. * members of this structure using SET_IEEE80211_DEV()
  970. * and SET_IEEE80211_PERM_ADDR(). Additionally, all supported
  971. * bands (with channels, bitrates) are registered here.
  972. *
  973. * @conf: &struct ieee80211_conf, device configuration, don't use.
  974. *
  975. * @priv: pointer to private area that was allocated for driver use
  976. * along with this structure.
  977. *
  978. * @flags: hardware flags, see &enum ieee80211_hw_flags.
  979. *
  980. * @extra_tx_headroom: headroom to reserve in each transmit skb
  981. * for use by the driver (e.g. for transmit headers.)
  982. *
  983. * @channel_change_time: time (in microseconds) it takes to change channels.
  984. *
  985. * @max_signal: Maximum value for signal (rssi) in RX information, used
  986. * only when @IEEE80211_HW_SIGNAL_UNSPEC or @IEEE80211_HW_SIGNAL_DB
  987. *
  988. * @max_listen_interval: max listen interval in units of beacon interval
  989. * that HW supports
  990. *
  991. * @queues: number of available hardware transmit queues for
  992. * data packets. WMM/QoS requires at least four, these
  993. * queues need to have configurable access parameters.
  994. *
  995. * @rate_control_algorithm: rate control algorithm for this hardware.
  996. * If unset (NULL), the default algorithm will be used. Must be
  997. * set before calling ieee80211_register_hw().
  998. *
  999. * @vif_data_size: size (in bytes) of the drv_priv data area
  1000. * within &struct ieee80211_vif.
  1001. * @sta_data_size: size (in bytes) of the drv_priv data area
  1002. * within &struct ieee80211_sta.
  1003. *
  1004. * @max_rates: maximum number of alternate rate retry stages
  1005. * @max_rate_tries: maximum number of tries for each stage
  1006. */
  1007. struct ieee80211_hw {
  1008. struct ieee80211_conf conf;
  1009. struct wiphy *wiphy;
  1010. const char *rate_control_algorithm;
  1011. void *priv;
  1012. u32 flags;
  1013. unsigned int extra_tx_headroom;
  1014. int channel_change_time;
  1015. int vif_data_size;
  1016. int sta_data_size;
  1017. u16 queues;
  1018. u16 max_listen_interval;
  1019. s8 max_signal;
  1020. u8 max_rates;
  1021. u8 max_rate_tries;
  1022. };
  1023. /**
  1024. * wiphy_to_ieee80211_hw - return a mac80211 driver hw struct from a wiphy
  1025. *
  1026. * @wiphy: the &struct wiphy which we want to query
  1027. *
  1028. * mac80211 drivers can use this to get to their respective
  1029. * &struct ieee80211_hw. Drivers wishing to get to their own private
  1030. * structure can then access it via hw->priv. Note that mac802111 drivers should
  1031. * not use wiphy_priv() to try to get their private driver structure as this
  1032. * is already used internally by mac80211.
  1033. */
  1034. struct ieee80211_hw *wiphy_to_ieee80211_hw(struct wiphy *wiphy);
  1035. /**
  1036. * SET_IEEE80211_DEV - set device for 802.11 hardware
  1037. *
  1038. * @hw: the &struct ieee80211_hw to set the device for
  1039. * @dev: the &struct device of this 802.11 device
  1040. */
  1041. static inline void SET_IEEE80211_DEV(struct ieee80211_hw *hw, struct device *dev)
  1042. {
  1043. set_wiphy_dev(hw->wiphy, dev);
  1044. }
  1045. /**
  1046. * SET_IEEE80211_PERM_ADDR - set the permanent MAC address for 802.11 hardware
  1047. *
  1048. * @hw: the &struct ieee80211_hw to set the MAC address for
  1049. * @addr: the address to set
  1050. */
  1051. static inline void SET_IEEE80211_PERM_ADDR(struct ieee80211_hw *hw, u8 *addr)
  1052. {
  1053. memcpy(hw->wiphy->perm_addr, addr, ETH_ALEN);
  1054. }
  1055. static inline struct ieee80211_rate *
  1056. ieee80211_get_tx_rate(const struct ieee80211_hw *hw,
  1057. const struct ieee80211_tx_info *c)
  1058. {
  1059. if (WARN_ON(c->control.rates[0].idx < 0))
  1060. return NULL;
  1061. return &hw->wiphy->bands[c->band]->bitrates[c->control.rates[0].idx];
  1062. }
  1063. static inline struct ieee80211_rate *
  1064. ieee80211_get_rts_cts_rate(const struct ieee80211_hw *hw,
  1065. const struct ieee80211_tx_info *c)
  1066. {
  1067. if (c->control.rts_cts_rate_idx < 0)
  1068. return NULL;
  1069. return &hw->wiphy->bands[c->band]->bitrates[c->control.rts_cts_rate_idx];
  1070. }
  1071. static inline struct ieee80211_rate *
  1072. ieee80211_get_alt_retry_rate(const struct ieee80211_hw *hw,
  1073. const struct ieee80211_tx_info *c, int idx)
  1074. {
  1075. if (c->control.rates[idx + 1].idx < 0)
  1076. return NULL;
  1077. return &hw->wiphy->bands[c->band]->bitrates[c->control.rates[idx + 1].idx];
  1078. }
  1079. /**
  1080. * DOC: Hardware crypto acceleration
  1081. *
  1082. * mac80211 is capable of taking advantage of many hardware
  1083. * acceleration designs for encryption and decryption operations.
  1084. *
  1085. * The set_key() callback in the &struct ieee80211_ops for a given
  1086. * device is called to enable hardware acceleration of encryption and
  1087. * decryption. The callback takes a @sta parameter that will be NULL
  1088. * for default keys or keys used for transmission only, or point to
  1089. * the station information for the peer for individual keys.
  1090. * Multiple transmission keys with the same key index may be used when
  1091. * VLANs are configured for an access point.
  1092. *
  1093. * When transmitting, the TX control data will use the @hw_key_idx
  1094. * selected by the driver by modifying the &struct ieee80211_key_conf
  1095. * pointed to by the @key parameter to the set_key() function.
  1096. *
  1097. * The set_key() call for the %SET_KEY command should return 0 if
  1098. * the key is now in use, -%EOPNOTSUPP or -%ENOSPC if it couldn't be
  1099. * added; if you return 0 then hw_key_idx must be assigned to the
  1100. * hardware key index, you are free to use the full u8 range.
  1101. *
  1102. * When the cmd is %DISABLE_KEY then it must succeed.
  1103. *
  1104. * Note that it is permissible to not decrypt a frame even if a key
  1105. * for it has been uploaded to hardware, the stack will not make any
  1106. * decision based on whether a key has been uploaded or not but rather
  1107. * based on the receive flags.
  1108. *
  1109. * The &struct ieee80211_key_conf structure pointed to by the @key
  1110. * parameter is guaranteed to be valid until another call to set_key()
  1111. * removes it, but it can only be used as a cookie to differentiate
  1112. * keys.
  1113. *
  1114. * In TKIP some HW need to be provided a phase 1 key, for RX decryption
  1115. * acceleration (i.e. iwlwifi). Those drivers should provide update_tkip_key
  1116. * handler.
  1117. * The update_tkip_key() call updates the driver with the new phase 1 key.
  1118. * This happens everytime the iv16 wraps around (every 65536 packets). The
  1119. * set_key() call will happen only once for each key (unless the AP did
  1120. * rekeying), it will not include a valid phase 1 key. The valid phase 1 key is
  1121. * provided by update_tkip_key only. The trigger that makes mac80211 call this
  1122. * handler is software decryption with wrap around of iv16.
  1123. */
  1124. /**
  1125. * DOC: Powersave support
  1126. *
  1127. * mac80211 has support for various powersave implementations.
  1128. *
  1129. * First, it can support hardware that handles all powersaving by itself,
  1130. * such hardware should simply set the %IEEE80211_HW_SUPPORTS_PS hardware
  1131. * flag. In that case, it will be told about the desired powersave mode
  1132. * with the %IEEE80211_CONF_PS flag depending on the association status.
  1133. * The hardware must take care of sending nullfunc frames when necessary,
  1134. * i.e. when entering and leaving powersave mode. The hardware is required
  1135. * to look at the AID in beacons and signal to the AP that it woke up when
  1136. * it finds traffic directed to it.
  1137. *
  1138. * %IEEE80211_CONF_PS flag enabled means that the powersave mode defined in
  1139. * IEEE 802.11-2007 section 11.2 is enabled. This is not to be confused
  1140. * with hardware wakeup and sleep states. Driver is responsible for waking
  1141. * up the hardware before issueing commands to the hardware and putting it
  1142. * back to sleep at approriate times.
  1143. *
  1144. * When PS is enabled, hardware needs to wakeup for beacons and receive the
  1145. * buffered multicast/broadcast frames after the beacon. Also it must be
  1146. * possible to send frames and receive the acknowledment frame.
  1147. *
  1148. * Other hardware designs cannot send nullfunc frames by themselves and also
  1149. * need software support for parsing the TIM bitmap. This is also supported
  1150. * by mac80211 by combining the %IEEE80211_HW_SUPPORTS_PS and
  1151. * %IEEE80211_HW_PS_NULLFUNC_STACK flags. The hardware is of course still
  1152. * required to pass up beacons. The hardware is still required to handle
  1153. * waking up for multicast traffic; if it cannot the driver must handle that
  1154. * as best as it can, mac80211 is too slow to do that.
  1155. *
  1156. * Dynamic powersave is an extension to normal powersave in which the
  1157. * hardware stays awake for a user-specified period of time after sending a
  1158. * frame so that reply frames need not be buffered and therefore delayed to
  1159. * the next wakeup. It's compromise of getting good enough latency when
  1160. * there's data traffic and still saving significantly power in idle
  1161. * periods.
  1162. *
  1163. * Dynamic powersave is supported by simply mac80211 enabling and disabling
  1164. * PS based on traffic. Driver needs to only set %IEEE80211_HW_SUPPORTS_PS
  1165. * flag and mac80211 will handle everything automatically. Additionally,
  1166. * hardware having support for the dynamic PS feature may set the
  1167. * %IEEE80211_HW_SUPPORTS_DYNAMIC_PS flag to indicate that it can support
  1168. * dynamic PS mode itself. The driver needs to look at the
  1169. * @dynamic_ps_timeout hardware configuration value and use it that value
  1170. * whenever %IEEE80211_CONF_PS is set. In this case mac80211 will disable
  1171. * dynamic PS feature in stack and will just keep %IEEE80211_CONF_PS
  1172. * enabled whenever user has enabled powersave.
  1173. *
  1174. * Driver informs U-APSD client support by enabling
  1175. * %IEEE80211_HW_SUPPORTS_UAPSD flag. The mode is configured through the
  1176. * uapsd paramater in conf_tx() operation. Hardware needs to send the QoS
  1177. * Nullfunc frames and stay awake until the service period has ended. To
  1178. * utilize U-APSD, dynamic powersave is disabled for voip AC and all frames
  1179. * from that AC are transmitted with powersave enabled.
  1180. *
  1181. * Note: U-APSD client mode is not yet supported with
  1182. * %IEEE80211_HW_PS_NULLFUNC_STACK.
  1183. */
  1184. /**
  1185. * DOC: Beacon filter support
  1186. *
  1187. * Some hardware have beacon filter support to reduce host cpu wakeups
  1188. * which will reduce system power consumption. It usuallly works so that
  1189. * the firmware creates a checksum of the beacon but omits all constantly
  1190. * changing elements (TSF, TIM etc). Whenever the checksum changes the
  1191. * beacon is forwarded to the host, otherwise it will be just dropped. That
  1192. * way the host will only receive beacons where some relevant information
  1193. * (for example ERP protection or WMM settings) have changed.
  1194. *
  1195. * Beacon filter support is advertised with the %IEEE80211_HW_BEACON_FILTER
  1196. * hardware capability. The driver needs to enable beacon filter support
  1197. * whenever power save is enabled, that is %IEEE80211_CONF_PS is set. When
  1198. * power save is enabled, the stack will not check for beacon loss and the
  1199. * driver needs to notify about loss of beacons with ieee80211_beacon_loss().
  1200. *
  1201. * The time (or number of beacons missed) until the firmware notifies the
  1202. * driver of a beacon loss event (which in turn causes the driver to call
  1203. * ieee80211_beacon_loss()) should be configurable and will be controlled
  1204. * by mac80211 and the roaming algorithm in the future.
  1205. *
  1206. * Since there may be constantly changing information elements that nothing
  1207. * in the software stack cares about, we will, in the future, have mac80211
  1208. * tell the driver which information elements are interesting in the sense
  1209. * that we want to see changes in them. This will include
  1210. * - a list of information element IDs
  1211. * - a list of OUIs for the vendor information element
  1212. *
  1213. * Ideally, the hardware would filter out any beacons without changes in the
  1214. * requested elements, but if it cannot support that it may, at the expense
  1215. * of some efficiency, filter out only a subset. For example, if the device
  1216. * doesn't support checking for OUIs it should pass up all changes in all
  1217. * vendor information elements.
  1218. *
  1219. * Note that change, for the sake of simplification, also includes information
  1220. * elements appearing or disappearing from the beacon.
  1221. *
  1222. * Some hardware supports an "ignore list" instead, just make sure nothing
  1223. * that was requested is on the ignore list, and include commonly changing
  1224. * information element IDs in the ignore list, for example 11 (BSS load) and
  1225. * the various vendor-assigned IEs with unknown contents (128, 129, 133-136,
  1226. * 149, 150, 155, 156, 173, 176, 178, 179, 219); for forward compatibility
  1227. * it could also include some currently unused IDs.
  1228. *
  1229. *
  1230. * In addition to these capabilities, hardware should support notifying the
  1231. * host of changes in the beacon RSSI. This is relevant to implement roaming
  1232. * when no traffic is flowing (when traffic is flowing we see the RSSI of
  1233. * the received data packets). This can consist in notifying the host when
  1234. * the RSSI changes significantly or when it drops below or rises above
  1235. * configurable thresholds. In the future these thresholds will also be
  1236. * configured by mac80211 (which gets them from userspace) to implement
  1237. * them as the roaming algorithm requires.
  1238. *
  1239. * If the hardware cannot implement this, the driver should ask it to
  1240. * periodically pass beacon frames to the host so that software can do the
  1241. * signal strength threshold checking.
  1242. */
  1243. /**
  1244. * DOC: Spatial multiplexing power save
  1245. *
  1246. * SMPS (Spatial multiplexing power save) is a mechanism to conserve
  1247. * power in an 802.11n implementation. For details on the mechanism
  1248. * and rationale, please refer to 802.11 (as amended by 802.11n-2009)
  1249. * "11.2.3 SM power save".
  1250. *
  1251. * The mac80211 implementation is capable of sending action frames
  1252. * to update the AP about the station's SMPS mode, and will instruct
  1253. * the driver to enter the specific mode. It will also announce the
  1254. * requested SMPS mode during the association handshake. Hardware
  1255. * support for this feature is required, and can be indicated by
  1256. * hardware flags.
  1257. *
  1258. * The default mode will be "automatic", which nl80211/cfg80211
  1259. * defines to be dynamic SMPS in (regular) powersave, and SMPS
  1260. * turned off otherwise.
  1261. *
  1262. * To support this feature, the driver must set the appropriate
  1263. * hardware support flags, and handle the SMPS flag to the config()
  1264. * operation. It will then with this mechanism be instructed to
  1265. * enter the requested SMPS mode while associated to an HT AP.
  1266. */
  1267. /**
  1268. * DOC: Frame filtering
  1269. *
  1270. * mac80211 requires to see many management frames for proper
  1271. * operation, and users may want to see many more frames when
  1272. * in monitor mode. However, for best CPU usage and power consumption,
  1273. * having as few frames as possible percolate through the stack is
  1274. * desirable. Hence, the hardware should filter as much as possible.
  1275. *
  1276. * To achieve this, mac80211 uses filter flags (see below) to tell
  1277. * the driver's configure_filter() function which frames should be
  1278. * passed to mac80211 and which should be filtered out.
  1279. *
  1280. * Before configure_filter() is invoked, the prepare_multicast()
  1281. * callback is invoked with the parameters @mc_count and @mc_list
  1282. * for the combined multicast address list of all virtual interfaces.
  1283. * It's use is optional, and it returns a u64 that is passed to
  1284. * configure_filter(). Additionally, configure_filter() has the
  1285. * arguments @changed_flags telling which flags were changed and
  1286. * @total_flags with the new flag states.
  1287. *
  1288. * If your device has no multicast address filters your driver will
  1289. * need to check both the %FIF_ALLMULTI flag and the @mc_count
  1290. * parameter to see whether multicast frames should be accepted
  1291. * or dropped.
  1292. *
  1293. * All unsupported flags in @total_flags must be cleared.
  1294. * Hardware does not support a flag if it is incapable of _passing_
  1295. * the frame to the stack. Otherwise the driver must ignore
  1296. * the flag, but not clear it.
  1297. * You must _only_ clear the flag (announce no support for the
  1298. * flag to mac80211) if you are not able to pass the packet type
  1299. * to the stack (so the hardware always filters it).
  1300. * So for example, you should clear @FIF_CONTROL, if your hardware
  1301. * always filters control frames. If your hardware always passes
  1302. * control frames to the kernel and is incapable of filtering them,
  1303. * you do _not_ clear the @FIF_CONTROL flag.
  1304. * This rule applies to all other FIF flags as well.
  1305. */
  1306. /**
  1307. * enum ieee80211_filter_flags - hardware filter flags
  1308. *
  1309. * These flags determine what the filter in hardware should be
  1310. * programmed to let through and what should not be passed to the
  1311. * stack. It is always safe to pass more frames than requested,
  1312. * but this has negative impact on power consumption.
  1313. *
  1314. * @FIF_PROMISC_IN_BSS: promiscuous mode within your BSS,
  1315. * think of the BSS as your network segment and then this corresponds
  1316. * to the regular ethernet device promiscuous mode.
  1317. *
  1318. * @FIF_ALLMULTI: pass all multicast frames, this is used if requested
  1319. * by the user or if the hardware is not capable of filtering by
  1320. * multicast address.
  1321. *
  1322. * @FIF_FCSFAIL: pass frames with failed FCS (but you need to set the
  1323. * %RX_FLAG_FAILED_FCS_CRC for them)
  1324. *
  1325. * @FIF_PLCPFAIL: pass frames with failed PLCP CRC (but you need to set
  1326. * the %RX_FLAG_FAILED_PLCP_CRC for them
  1327. *
  1328. * @FIF_BCN_PRBRESP_PROMISC: This flag is set during scanning to indicate
  1329. * to the hardware that it should not filter beacons or probe responses
  1330. * by BSSID. Filtering them can greatly reduce the amount of processing
  1331. * mac80211 needs to do and the amount of CPU wakeups, so you should
  1332. * honour this flag if possible.
  1333. *
  1334. * @FIF_CONTROL: pass control frames (except for PS Poll), if PROMISC_IN_BSS
  1335. * is not set then only those addressed to this station.
  1336. *
  1337. * @FIF_OTHER_BSS: pass frames destined to other BSSes
  1338. *
  1339. * @FIF_PSPOLL: pass PS Poll frames, if PROMISC_IN_BSS is not set then only
  1340. * those addressed to this station.
  1341. */
  1342. enum ieee80211_filter_flags {
  1343. FIF_PROMISC_IN_BSS = 1<<0,
  1344. FIF_ALLMULTI = 1<<1,
  1345. FIF_FCSFAIL = 1<<2,
  1346. FIF_PLCPFAIL = 1<<3,
  1347. FIF_BCN_PRBRESP_PROMISC = 1<<4,
  1348. FIF_CONTROL = 1<<5,
  1349. FIF_OTHER_BSS = 1<<6,
  1350. FIF_PSPOLL = 1<<7,
  1351. };
  1352. /**
  1353. * enum ieee80211_ampdu_mlme_action - A-MPDU actions
  1354. *
  1355. * These flags are used with the ampdu_action() callback in
  1356. * &struct ieee80211_ops to indicate which action is needed.
  1357. *
  1358. * Note that drivers MUST be able to deal with a TX aggregation
  1359. * session being stopped even before they OK'ed starting it by
  1360. * calling ieee80211_start_tx_ba_cb(_irqsafe), because the peer
  1361. * might receive the addBA frame and send a delBA right away!
  1362. *
  1363. * @IEEE80211_AMPDU_RX_START: start Rx aggregation
  1364. * @IEEE80211_AMPDU_RX_STOP: stop Rx aggregation
  1365. * @IEEE80211_AMPDU_TX_START: start Tx aggregation
  1366. * @IEEE80211_AMPDU_TX_STOP: stop Tx aggregation
  1367. * @IEEE80211_AMPDU_TX_OPERATIONAL: TX aggregation has become operational
  1368. */
  1369. enum ieee80211_ampdu_mlme_action {
  1370. IEEE80211_AMPDU_RX_START,
  1371. IEEE80211_AMPDU_RX_STOP,
  1372. IEEE80211_AMPDU_TX_START,
  1373. IEEE80211_AMPDU_TX_STOP,
  1374. IEEE80211_AMPDU_TX_OPERATIONAL,
  1375. };
  1376. /**
  1377. * struct ieee80211_ops - callbacks from mac80211 to the driver
  1378. *
  1379. * This structure contains various callbacks that the driver may
  1380. * handle or, in some cases, must handle, for example to configure
  1381. * the hardware to a new channel or to transmit a frame.
  1382. *
  1383. * @tx: Handler that 802.11 module calls for each transmitted frame.
  1384. * skb contains the buffer starting from the IEEE 802.11 header.
  1385. * The low-level driver should send the frame out based on
  1386. * configuration in the TX control data. This handler should,
  1387. * preferably, never fail and stop queues appropriately, more
  1388. * importantly, however, it must never fail for A-MPDU-queues.
  1389. * This function should return NETDEV_TX_OK except in very
  1390. * limited cases.
  1391. * Must be implemented and atomic.
  1392. *
  1393. * @start: Called before the first netdevice attached to the hardware
  1394. * is enabled. This should turn on the hardware and must turn on
  1395. * frame reception (for possibly enabled monitor interfaces.)
  1396. * Returns negative error codes, these may be seen in userspace,
  1397. * or zero.
  1398. * When the device is started it should not have a MAC address
  1399. * to avoid acknowledging frames before a non-monitor device
  1400. * is added.
  1401. * Must be implemented and can sleep.
  1402. *
  1403. * @stop: Called after last netdevice attached to the hardware
  1404. * is disabled. This should turn off the hardware (at least
  1405. * it must turn off frame reception.)
  1406. * May be called right after add_interface if that rejects
  1407. * an interface. If you added any work onto the mac80211 workqueue
  1408. * you should ensure to cancel it on this callback.
  1409. * Must be implemented and can sleep.
  1410. *
  1411. * @add_interface: Called when a netdevice attached to the hardware is
  1412. * enabled. Because it is not called for monitor mode devices, @start
  1413. * and @stop must be implemented.
  1414. * The driver should perform any initialization it needs before
  1415. * the device can be enabled. The initial configuration for the
  1416. * interface is given in the conf parameter.
  1417. * The callback may refuse to add an interface by returning a
  1418. * negative error code (which will be seen in userspace.)
  1419. * Must be implemented and can sleep.
  1420. *
  1421. * @remove_interface: Notifies a driver that an interface is going down.
  1422. * The @stop callback is called after this if it is the last interface
  1423. * and no monitor interfaces are present.
  1424. * When all interfaces are removed, the MAC address in the hardware
  1425. * must be cleared so the device no longer acknowledges packets,
  1426. * the mac_addr member of the conf structure is, however, set to the
  1427. * MAC address of the device going away.
  1428. * Hence, this callback must be implemented. It can sleep.
  1429. *
  1430. * @config: Handler for configuration requests. IEEE 802.11 code calls this
  1431. * function to change hardware configuration, e.g., channel.
  1432. * This function should never fail but returns a negative error code
  1433. * if it does. The callback can sleep.
  1434. *
  1435. * @bss_info_changed: Handler for configuration requests related to BSS
  1436. * parameters that may vary during BSS's lifespan, and may affect low
  1437. * level driver (e.g. assoc/disassoc status, erp parameters).
  1438. * This function should not be used if no BSS has been set, unless
  1439. * for association indication. The @changed parameter indicates which
  1440. * of the bss parameters has changed when a call is made. The callback
  1441. * can sleep.
  1442. *
  1443. * @prepare_multicast: Prepare for multicast filter configuration.
  1444. * This callback is optional, and its return value is passed
  1445. * to configure_filter(). This callback must be atomic.
  1446. *
  1447. * @configure_filter: Configure the device's RX filter.
  1448. * See the section "Frame filtering" for more information.
  1449. * This callback must be implemented and can sleep.
  1450. *
  1451. * @set_tim: Set TIM bit. mac80211 calls this function when a TIM bit
  1452. * must be set or cleared for a given STA. Must be atomic.
  1453. *
  1454. * @set_key: See the section "Hardware crypto acceleration"
  1455. * This callback is only called between add_interface and
  1456. * remove_interface calls, i.e. while the given virtual interface
  1457. * is enabled.
  1458. * Returns a negative error code if the key can't be added.
  1459. * The callback can sleep.
  1460. *
  1461. * @update_tkip_key: See the section "Hardware crypto acceleration"
  1462. * This callback will be called in the context of Rx. Called for drivers
  1463. * which set IEEE80211_KEY_FLAG_TKIP_REQ_RX_P1_KEY.
  1464. * The callback must be atomic.
  1465. *
  1466. * @hw_scan: Ask the hardware to service the scan request, no need to start
  1467. * the scan state machine in stack. The scan must honour the channel
  1468. * configuration done by the regulatory agent in the wiphy's
  1469. * registered bands. The hardware (or the driver) needs to make sure
  1470. * that power save is disabled.
  1471. * The @req ie/ie_len members are rewritten by mac80211 to contain the
  1472. * entire IEs after the SSID, so that drivers need not look at these
  1473. * at all but just send them after the SSID -- mac80211 includes the
  1474. * (extended) supported rates and HT information (where applicable).
  1475. * When the scan finishes, ieee80211_scan_completed() must be called;
  1476. * note that it also must be called when the scan cannot finish due to
  1477. * any error unless this callback returned a negative error code.
  1478. * The callback can sleep.
  1479. *
  1480. * @sw_scan_start: Notifier function that is called just before a software scan
  1481. * is started. Can be NULL, if the driver doesn't need this notification.
  1482. * The callback can sleep.
  1483. *
  1484. * @sw_scan_complete: Notifier function that is called just after a
  1485. * software scan finished. Can be NULL, if the driver doesn't need
  1486. * this notification.
  1487. * The callback can sleep.
  1488. *
  1489. * @get_stats: Return low-level statistics.
  1490. * Returns zero if statistics are available.
  1491. * The callback can sleep.
  1492. *
  1493. * @get_tkip_seq: If your device implements TKIP encryption in hardware this
  1494. * callback should be provided to read the TKIP transmit IVs (both IV32
  1495. * and IV16) for the given key from hardware.
  1496. * The callback must be atomic.
  1497. *
  1498. * @set_rts_threshold: Configuration of RTS threshold (if device needs it)
  1499. * The callback can sleep.
  1500. *
  1501. * @sta_add: Notifies low level driver about addition of an associated station,
  1502. * AP, IBSS/WDS/mesh peer etc. This callback can sleep.
  1503. *
  1504. * @sta_remove: Notifies low level driver about removal of an associated
  1505. * station, AP, IBSS/WDS/mesh peer etc. This callback can sleep.
  1506. *
  1507. * @sta_notify: Notifies low level driver about power state transition of an
  1508. * associated station, AP, IBSS/WDS/mesh peer etc. Must be atomic.
  1509. *
  1510. * @conf_tx: Configure TX queue parameters (EDCF (aifs, cw_min, cw_max),
  1511. * bursting) for a hardware TX queue.
  1512. * Returns a negative error code on failure.
  1513. * The callback can sleep.
  1514. *
  1515. * @get_tsf: Get the current TSF timer value from firmware/hardware. Currently,
  1516. * this is only used for IBSS mode BSSID merging and debugging. Is not a
  1517. * required function.
  1518. * The callback can sleep.
  1519. *
  1520. * @set_tsf: Set the TSF timer to the specified value in the firmware/hardware.
  1521. * Currently, this is only used for IBSS mode debugging. Is not a
  1522. * required function.
  1523. * The callback can sleep.
  1524. *
  1525. * @reset_tsf: Reset the TSF timer and allow firmware/hardware to synchronize
  1526. * with other STAs in the IBSS. This is only used in IBSS mode. This
  1527. * function is optional if the firmware/hardware takes full care of
  1528. * TSF synchronization.
  1529. * The callback can sleep.
  1530. *
  1531. * @tx_last_beacon: Determine whether the last IBSS beacon was sent by us.
  1532. * This is needed only for IBSS mode and the result of this function is
  1533. * used to determine whether to reply to Probe Requests.
  1534. * Returns non-zero if this device sent the last beacon.
  1535. * The callback can sleep.
  1536. *
  1537. * @ampdu_action: Perform a certain A-MPDU action
  1538. * The RA/TID combination determines the destination and TID we want
  1539. * the ampdu action to be performed for. The action is defined through
  1540. * ieee80211_ampdu_mlme_action. Starting sequence number (@ssn)
  1541. * is the first frame we expect to perform the action on. Notice
  1542. * that TX/RX_STOP can pass NULL for this parameter.
  1543. * Returns a negative error code on failure.
  1544. * The callback must be atomic.
  1545. *
  1546. * @rfkill_poll: Poll rfkill hardware state. If you need this, you also
  1547. * need to set wiphy->rfkill_poll to %true before registration,
  1548. * and need to call wiphy_rfkill_set_hw_state() in the callback.
  1549. * The callback can sleep.
  1550. *
  1551. * @set_coverage_class: Set slot time for given coverage class as specified
  1552. * in IEEE 802.11-2007 section 17.3.8.6 and modify ACK timeout
  1553. * accordingly. This callback is not required and may sleep.
  1554. *
  1555. * @testmode_cmd: Implement a cfg80211 test mode command.
  1556. * The callback can sleep.
  1557. *
  1558. * @flush: Flush all pending frames from the hardware queue, making sure
  1559. * that the hardware queues are empty. If the parameter @drop is set
  1560. * to %true, pending frames may be dropped. The callback can sleep.
  1561. */
  1562. struct ieee80211_ops {
  1563. int (*tx)(struct ieee80211_hw *hw, struct sk_buff *skb);
  1564. int (*start)(struct ieee80211_hw *hw);
  1565. void (*stop)(struct ieee80211_hw *hw);
  1566. int (*add_interface)(struct ieee80211_hw *hw,
  1567. struct ieee80211_vif *vif);
  1568. void (*remove_interface)(struct ieee80211_hw *hw,
  1569. struct ieee80211_vif *vif);
  1570. int (*config)(struct ieee80211_hw *hw, u32 changed);
  1571. void (*bss_info_changed)(struct ieee80211_hw *hw,
  1572. struct ieee80211_vif *vif,
  1573. struct ieee80211_bss_conf *info,
  1574. u32 changed);
  1575. u64 (*prepare_multicast)(struct ieee80211_hw *hw,
  1576. int mc_count, struct dev_addr_list *mc_list);
  1577. void (*configure_filter)(struct ieee80211_hw *hw,
  1578. unsigned int changed_flags,
  1579. unsigned int *total_flags,
  1580. u64 multicast);
  1581. int (*set_tim)(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
  1582. bool set);
  1583. int (*set_key)(struct ieee80211_hw *hw, enum set_key_cmd cmd,
  1584. struct ieee80211_vif *vif, struct ieee80211_sta *sta,
  1585. struct ieee80211_key_conf *key);
  1586. void (*update_tkip_key)(struct ieee80211_hw *hw,
  1587. struct ieee80211_vif *vif,
  1588. struct ieee80211_key_conf *conf,
  1589. struct ieee80211_sta *sta,
  1590. u32 iv32, u16 *phase1key);
  1591. int (*hw_scan)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  1592. struct cfg80211_scan_request *req);
  1593. void (*sw_scan_start)(struct ieee80211_hw *hw);
  1594. void (*sw_scan_complete)(struct ieee80211_hw *hw);
  1595. int (*get_stats)(struct ieee80211_hw *hw,
  1596. struct ieee80211_low_level_stats *stats);
  1597. void (*get_tkip_seq)(struct ieee80211_hw *hw, u8 hw_key_idx,
  1598. u32 *iv32, u16 *iv16);
  1599. int (*set_rts_threshold)(struct ieee80211_hw *hw, u32 value);
  1600. int (*sta_add)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  1601. struct ieee80211_sta *sta);
  1602. int (*sta_remove)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  1603. struct ieee80211_sta *sta);
  1604. void (*sta_notify)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  1605. enum sta_notify_cmd, struct ieee80211_sta *sta);
  1606. int (*conf_tx)(struct ieee80211_hw *hw, u16 queue,
  1607. const struct ieee80211_tx_queue_params *params);
  1608. u64 (*get_tsf)(struct ieee80211_hw *hw);
  1609. void (*set_tsf)(struct ieee80211_hw *hw, u64 tsf);
  1610. void (*reset_tsf)(struct ieee80211_hw *hw);
  1611. int (*tx_last_beacon)(struct ieee80211_hw *hw);
  1612. int (*ampdu_action)(struct ieee80211_hw *hw,
  1613. struct ieee80211_vif *vif,
  1614. enum ieee80211_ampdu_mlme_action action,
  1615. struct ieee80211_sta *sta, u16 tid, u16 *ssn);
  1616. int (*get_survey)(struct ieee80211_hw *hw, int idx,
  1617. struct survey_info *survey);
  1618. void (*rfkill_poll)(struct ieee80211_hw *hw);
  1619. void (*set_coverage_class)(struct ieee80211_hw *hw, u8 coverage_class);
  1620. #ifdef CONFIG_NL80211_TESTMODE
  1621. int (*testmode_cmd)(struct ieee80211_hw *hw, void *data, int len);
  1622. #endif
  1623. void (*flush)(struct ieee80211_hw *hw, bool drop);
  1624. };
  1625. /**
  1626. * ieee80211_alloc_hw - Allocate a new hardware device
  1627. *
  1628. * This must be called once for each hardware device. The returned pointer
  1629. * must be used to refer to this device when calling other functions.
  1630. * mac80211 allocates a private data area for the driver pointed to by
  1631. * @priv in &struct ieee80211_hw, the size of this area is given as
  1632. * @priv_data_len.
  1633. *
  1634. * @priv_data_len: length of private data
  1635. * @ops: callbacks for this device
  1636. */
  1637. struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
  1638. const struct ieee80211_ops *ops);
  1639. /**
  1640. * ieee80211_register_hw - Register hardware device
  1641. *
  1642. * You must call this function before any other functions in
  1643. * mac80211. Note that before a hardware can be registered, you
  1644. * need to fill the contained wiphy's information.
  1645. *
  1646. * @hw: the device to register as returned by ieee80211_alloc_hw()
  1647. */
  1648. int ieee80211_register_hw(struct ieee80211_hw *hw);
  1649. #ifdef CONFIG_MAC80211_LEDS
  1650. extern char *__ieee80211_get_tx_led_name(struct ieee80211_hw *hw);
  1651. extern char *__ieee80211_get_rx_led_name(struct ieee80211_hw *hw);
  1652. extern char *__ieee80211_get_assoc_led_name(struct ieee80211_hw *hw);
  1653. extern char *__ieee80211_get_radio_led_name(struct ieee80211_hw *hw);
  1654. #endif
  1655. /**
  1656. * ieee80211_get_tx_led_name - get name of TX LED
  1657. *
  1658. * mac80211 creates a transmit LED trigger for each wireless hardware
  1659. * that can be used to drive LEDs if your driver registers a LED device.
  1660. * This function returns the name (or %NULL if not configured for LEDs)
  1661. * of the trigger so you can automatically link the LED device.
  1662. *
  1663. * @hw: the hardware to get the LED trigger name for
  1664. */
  1665. static inline char *ieee80211_get_tx_led_name(struct ieee80211_hw *hw)
  1666. {
  1667. #ifdef CONFIG_MAC80211_LEDS
  1668. return __ieee80211_get_tx_led_name(hw);
  1669. #else
  1670. return NULL;
  1671. #endif
  1672. }
  1673. /**
  1674. * ieee80211_get_rx_led_name - get name of RX LED
  1675. *
  1676. * mac80211 creates a receive LED trigger for each wireless hardware
  1677. * that can be used to drive LEDs if your driver registers a LED device.
  1678. * This function returns the name (or %NULL if not configured for LEDs)
  1679. * of the trigger so you can automatically link the LED device.
  1680. *
  1681. * @hw: the hardware to get the LED trigger name for
  1682. */
  1683. static inline char *ieee80211_get_rx_led_name(struct ieee80211_hw *hw)
  1684. {
  1685. #ifdef CONFIG_MAC80211_LEDS
  1686. return __ieee80211_get_rx_led_name(hw);
  1687. #else
  1688. return NULL;
  1689. #endif
  1690. }
  1691. /**
  1692. * ieee80211_get_assoc_led_name - get name of association LED
  1693. *
  1694. * mac80211 creates a association LED trigger for each wireless hardware
  1695. * that can be used to drive LEDs if your driver registers a LED device.
  1696. * This function returns the name (or %NULL if not configured for LEDs)
  1697. * of the trigger so you can automatically link the LED device.
  1698. *
  1699. * @hw: the hardware to get the LED trigger name for
  1700. */
  1701. static inline char *ieee80211_get_assoc_led_name(struct ieee80211_hw *hw)
  1702. {
  1703. #ifdef CONFIG_MAC80211_LEDS
  1704. return __ieee80211_get_assoc_led_name(hw);
  1705. #else
  1706. return NULL;
  1707. #endif
  1708. }
  1709. /**
  1710. * ieee80211_get_radio_led_name - get name of radio LED
  1711. *
  1712. * mac80211 creates a radio change LED trigger for each wireless hardware
  1713. * that can be used to drive LEDs if your driver registers a LED device.
  1714. * This function returns the name (or %NULL if not configured for LEDs)
  1715. * of the trigger so you can automatically link the LED device.
  1716. *
  1717. * @hw: the hardware to get the LED trigger name for
  1718. */
  1719. static inline char *ieee80211_get_radio_led_name(struct ieee80211_hw *hw)
  1720. {
  1721. #ifdef CONFIG_MAC80211_LEDS
  1722. return __ieee80211_get_radio_led_name(hw);
  1723. #else
  1724. return NULL;
  1725. #endif
  1726. }
  1727. /**
  1728. * ieee80211_unregister_hw - Unregister a hardware device
  1729. *
  1730. * This function instructs mac80211 to free allocated resources
  1731. * and unregister netdevices from the networking subsystem.
  1732. *
  1733. * @hw: the hardware to unregister
  1734. */
  1735. void ieee80211_unregister_hw(struct ieee80211_hw *hw);
  1736. /**
  1737. * ieee80211_free_hw - free hardware descriptor
  1738. *
  1739. * This function frees everything that was allocated, including the
  1740. * private data for the driver. You must call ieee80211_unregister_hw()
  1741. * before calling this function.
  1742. *
  1743. * @hw: the hardware to free
  1744. */
  1745. void ieee80211_free_hw(struct ieee80211_hw *hw);
  1746. /**
  1747. * ieee80211_restart_hw - restart hardware completely
  1748. *
  1749. * Call this function when the hardware was restarted for some reason
  1750. * (hardware error, ...) and the driver is unable to restore its state
  1751. * by itself. mac80211 assumes that at this point the driver/hardware
  1752. * is completely uninitialised and stopped, it starts the process by
  1753. * calling the ->start() operation. The driver will need to reset all
  1754. * internal state that it has prior to calling this function.
  1755. *
  1756. * @hw: the hardware to restart
  1757. */
  1758. void ieee80211_restart_hw(struct ieee80211_hw *hw);
  1759. /**
  1760. * ieee80211_rx - receive frame
  1761. *
  1762. * Use this function to hand received frames to mac80211. The receive
  1763. * buffer in @skb must start with an IEEE 802.11 header. In case of a
  1764. * paged @skb is used, the driver is recommended to put the ieee80211
  1765. * header of the frame on the linear part of the @skb to avoid memory
  1766. * allocation and/or memcpy by the stack.
  1767. *
  1768. * This function may not be called in IRQ context. Calls to this function
  1769. * for a single hardware must be synchronized against each other. Calls to
  1770. * this function, ieee80211_rx_ni() and ieee80211_rx_irqsafe() may not be
  1771. * mixed for a single hardware.
  1772. *
  1773. * In process context use instead ieee80211_rx_ni().
  1774. *
  1775. * @hw: the hardware this frame came in on
  1776. * @skb: the buffer to receive, owned by mac80211 after this call
  1777. */
  1778. void ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb);
  1779. /**
  1780. * ieee80211_rx_irqsafe - receive frame
  1781. *
  1782. * Like ieee80211_rx() but can be called in IRQ context
  1783. * (internally defers to a tasklet.)
  1784. *
  1785. * Calls to this function, ieee80211_rx() or ieee80211_rx_ni() may not
  1786. * be mixed for a single hardware.
  1787. *
  1788. * @hw: the hardware this frame came in on
  1789. * @skb: the buffer to receive, owned by mac80211 after this call
  1790. */
  1791. void ieee80211_rx_irqsafe(struct ieee80211_hw *hw, struct sk_buff *skb);
  1792. /**
  1793. * ieee80211_rx_ni - receive frame (in process context)
  1794. *
  1795. * Like ieee80211_rx() but can be called in process context
  1796. * (internally disables bottom halves).
  1797. *
  1798. * Calls to this function, ieee80211_rx() and ieee80211_rx_irqsafe() may
  1799. * not be mixed for a single hardware.
  1800. *
  1801. * @hw: the hardware this frame came in on
  1802. * @skb: the buffer to receive, owned by mac80211 after this call
  1803. */
  1804. static inline void ieee80211_rx_ni(struct ieee80211_hw *hw,
  1805. struct sk_buff *skb)
  1806. {
  1807. local_bh_disable();
  1808. ieee80211_rx(hw, skb);
  1809. local_bh_enable();
  1810. }
  1811. /*
  1812. * The TX headroom reserved by mac80211 for its own tx_status functions.
  1813. * This is enough for the radiotap header.
  1814. */
  1815. #define IEEE80211_TX_STATUS_HEADROOM 13
  1816. /**
  1817. * ieee80211_tx_status - transmit status callback
  1818. *
  1819. * Call this function for all transmitted frames after they have been
  1820. * transmitted. It is permissible to not call this function for
  1821. * multicast frames but this can affect statistics.
  1822. *
  1823. * This function may not be called in IRQ context. Calls to this function
  1824. * for a single hardware must be synchronized against each other. Calls
  1825. * to this function and ieee80211_tx_status_irqsafe() may not be mixed
  1826. * for a single hardware.
  1827. *
  1828. * @hw: the hardware the frame was transmitted by
  1829. * @skb: the frame that was transmitted, owned by mac80211 after this call
  1830. */
  1831. void ieee80211_tx_status(struct ieee80211_hw *hw,
  1832. struct sk_buff *skb);
  1833. /**
  1834. * ieee80211_tx_status_irqsafe - IRQ-safe transmit status callback
  1835. *
  1836. * Like ieee80211_tx_status() but can be called in IRQ context
  1837. * (internally defers to a tasklet.)
  1838. *
  1839. * Calls to this function and ieee80211_tx_status() may not be mixed for a
  1840. * single hardware.
  1841. *
  1842. * @hw: the hardware the frame was transmitted by
  1843. * @skb: the frame that was transmitted, owned by mac80211 after this call
  1844. */
  1845. void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw,
  1846. struct sk_buff *skb);
  1847. /**
  1848. * ieee80211_beacon_get_tim - beacon generation function
  1849. * @hw: pointer obtained from ieee80211_alloc_hw().
  1850. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  1851. * @tim_offset: pointer to variable that will receive the TIM IE offset.
  1852. * Set to 0 if invalid (in non-AP modes).
  1853. * @tim_length: pointer to variable that will receive the TIM IE length,
  1854. * (including the ID and length bytes!).
  1855. * Set to 0 if invalid (in non-AP modes).
  1856. *
  1857. * If the driver implements beaconing modes, it must use this function to
  1858. * obtain the beacon frame/template.
  1859. *
  1860. * If the beacon frames are generated by the host system (i.e., not in
  1861. * hardware/firmware), the driver uses this function to get each beacon
  1862. * frame from mac80211 -- it is responsible for calling this function
  1863. * before the beacon is needed (e.g. based on hardware interrupt).
  1864. *
  1865. * If the beacon frames are generated by the device, then the driver
  1866. * must use the returned beacon as the template and change the TIM IE
  1867. * according to the current DTIM parameters/TIM bitmap.
  1868. *
  1869. * The driver is responsible for freeing the returned skb.
  1870. */
  1871. struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,
  1872. struct ieee80211_vif *vif,
  1873. u16 *tim_offset, u16 *tim_length);
  1874. /**
  1875. * ieee80211_beacon_get - beacon generation function
  1876. * @hw: pointer obtained from ieee80211_alloc_hw().
  1877. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  1878. *
  1879. * See ieee80211_beacon_get_tim().
  1880. */
  1881. static inline struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
  1882. struct ieee80211_vif *vif)
  1883. {
  1884. return ieee80211_beacon_get_tim(hw, vif, NULL, NULL);
  1885. }
  1886. /**
  1887. * ieee80211_pspoll_get - retrieve a PS Poll template
  1888. * @hw: pointer obtained from ieee80211_alloc_hw().
  1889. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  1890. *
  1891. * Creates a PS Poll a template which can, for example, uploaded to
  1892. * hardware. The template must be updated after association so that correct
  1893. * AID, BSSID and MAC address is used.
  1894. *
  1895. * Note: Caller (or hardware) is responsible for setting the
  1896. * &IEEE80211_FCTL_PM bit.
  1897. */
  1898. struct sk_buff *ieee80211_pspoll_get(struct ieee80211_hw *hw,
  1899. struct ieee80211_vif *vif);
  1900. /**
  1901. * ieee80211_nullfunc_get - retrieve a nullfunc template
  1902. * @hw: pointer obtained from ieee80211_alloc_hw().
  1903. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  1904. *
  1905. * Creates a Nullfunc template which can, for example, uploaded to
  1906. * hardware. The template must be updated after association so that correct
  1907. * BSSID and address is used.
  1908. *
  1909. * Note: Caller (or hardware) is responsible for setting the
  1910. * &IEEE80211_FCTL_PM bit as well as Duration and Sequence Control fields.
  1911. */
  1912. struct sk_buff *ieee80211_nullfunc_get(struct ieee80211_hw *hw,
  1913. struct ieee80211_vif *vif);
  1914. /**
  1915. * ieee80211_probereq_get - retrieve a Probe Request template
  1916. * @hw: pointer obtained from ieee80211_alloc_hw().
  1917. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  1918. * @ssid: SSID buffer
  1919. * @ssid_len: length of SSID
  1920. * @ie: buffer containing all IEs except SSID for the template
  1921. * @ie_len: length of the IE buffer
  1922. *
  1923. * Creates a Probe Request template which can, for example, be uploaded to
  1924. * hardware.
  1925. */
  1926. struct sk_buff *ieee80211_probereq_get(struct ieee80211_hw *hw,
  1927. struct ieee80211_vif *vif,
  1928. const u8 *ssid, size_t ssid_len,
  1929. const u8 *ie, size_t ie_len);
  1930. /**
  1931. * ieee80211_rts_get - RTS frame generation function
  1932. * @hw: pointer obtained from ieee80211_alloc_hw().
  1933. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  1934. * @frame: pointer to the frame that is going to be protected by the RTS.
  1935. * @frame_len: the frame length (in octets).
  1936. * @frame_txctl: &struct ieee80211_tx_info of the frame.
  1937. * @rts: The buffer where to store the RTS frame.
  1938. *
  1939. * If the RTS frames are generated by the host system (i.e., not in
  1940. * hardware/firmware), the low-level driver uses this function to receive
  1941. * the next RTS frame from the 802.11 code. The low-level is responsible
  1942. * for calling this function before and RTS frame is needed.
  1943. */
  1944. void ieee80211_rts_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  1945. const void *frame, size_t frame_len,
  1946. const struct ieee80211_tx_info *frame_txctl,
  1947. struct ieee80211_rts *rts);
  1948. /**
  1949. * ieee80211_rts_duration - Get the duration field for an RTS frame
  1950. * @hw: pointer obtained from ieee80211_alloc_hw().
  1951. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  1952. * @frame_len: the length of the frame that is going to be protected by the RTS.
  1953. * @frame_txctl: &struct ieee80211_tx_info of the frame.
  1954. *
  1955. * If the RTS is generated in firmware, but the host system must provide
  1956. * the duration field, the low-level driver uses this function to receive
  1957. * the duration field value in little-endian byteorder.
  1958. */
  1959. __le16 ieee80211_rts_duration(struct ieee80211_hw *hw,
  1960. struct ieee80211_vif *vif, size_t frame_len,
  1961. const struct ieee80211_tx_info *frame_txctl);
  1962. /**
  1963. * ieee80211_ctstoself_get - CTS-to-self frame generation function
  1964. * @hw: pointer obtained from ieee80211_alloc_hw().
  1965. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  1966. * @frame: pointer to the frame that is going to be protected by the CTS-to-self.
  1967. * @frame_len: the frame length (in octets).
  1968. * @frame_txctl: &struct ieee80211_tx_info of the frame.
  1969. * @cts: The buffer where to store the CTS-to-self frame.
  1970. *
  1971. * If the CTS-to-self frames are generated by the host system (i.e., not in
  1972. * hardware/firmware), the low-level driver uses this function to receive
  1973. * the next CTS-to-self frame from the 802.11 code. The low-level is responsible
  1974. * for calling this function before and CTS-to-self frame is needed.
  1975. */
  1976. void ieee80211_ctstoself_get(struct ieee80211_hw *hw,
  1977. struct ieee80211_vif *vif,
  1978. const void *frame, size_t frame_len,
  1979. const struct ieee80211_tx_info *frame_txctl,
  1980. struct ieee80211_cts *cts);
  1981. /**
  1982. * ieee80211_ctstoself_duration - Get the duration field for a CTS-to-self frame
  1983. * @hw: pointer obtained from ieee80211_alloc_hw().
  1984. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  1985. * @frame_len: the length of the frame that is going to be protected by the CTS-to-self.
  1986. * @frame_txctl: &struct ieee80211_tx_info of the frame.
  1987. *
  1988. * If the CTS-to-self is generated in firmware, but the host system must provide
  1989. * the duration field, the low-level driver uses this function to receive
  1990. * the duration field value in little-endian byteorder.
  1991. */
  1992. __le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw,
  1993. struct ieee80211_vif *vif,
  1994. size_t frame_len,
  1995. const struct ieee80211_tx_info *frame_txctl);
  1996. /**
  1997. * ieee80211_generic_frame_duration - Calculate the duration field for a frame
  1998. * @hw: pointer obtained from ieee80211_alloc_hw().
  1999. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  2000. * @frame_len: the length of the frame.
  2001. * @rate: the rate at which the frame is going to be transmitted.
  2002. *
  2003. * Calculate the duration field of some generic frame, given its
  2004. * length and transmission rate (in 100kbps).
  2005. */
  2006. __le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw,
  2007. struct ieee80211_vif *vif,
  2008. size_t frame_len,
  2009. struct ieee80211_rate *rate);
  2010. /**
  2011. * ieee80211_get_buffered_bc - accessing buffered broadcast and multicast frames
  2012. * @hw: pointer as obtained from ieee80211_alloc_hw().
  2013. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  2014. *
  2015. * Function for accessing buffered broadcast and multicast frames. If
  2016. * hardware/firmware does not implement buffering of broadcast/multicast
  2017. * frames when power saving is used, 802.11 code buffers them in the host
  2018. * memory. The low-level driver uses this function to fetch next buffered
  2019. * frame. In most cases, this is used when generating beacon frame. This
  2020. * function returns a pointer to the next buffered skb or NULL if no more
  2021. * buffered frames are available.
  2022. *
  2023. * Note: buffered frames are returned only after DTIM beacon frame was
  2024. * generated with ieee80211_beacon_get() and the low-level driver must thus
  2025. * call ieee80211_beacon_get() first. ieee80211_get_buffered_bc() returns
  2026. * NULL if the previous generated beacon was not DTIM, so the low-level driver
  2027. * does not need to check for DTIM beacons separately and should be able to
  2028. * use common code for all beacons.
  2029. */
  2030. struct sk_buff *
  2031. ieee80211_get_buffered_bc(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
  2032. /**
  2033. * ieee80211_get_tkip_key - get a TKIP rc4 for skb
  2034. *
  2035. * This function computes a TKIP rc4 key for an skb. It computes
  2036. * a phase 1 key if needed (iv16 wraps around). This function is to
  2037. * be used by drivers which can do HW encryption but need to compute
  2038. * to phase 1/2 key in SW.
  2039. *
  2040. * @keyconf: the parameter passed with the set key
  2041. * @skb: the skb for which the key is needed
  2042. * @type: TBD
  2043. * @key: a buffer to which the key will be written
  2044. */
  2045. void ieee80211_get_tkip_key(struct ieee80211_key_conf *keyconf,
  2046. struct sk_buff *skb,
  2047. enum ieee80211_tkip_key_type type, u8 *key);
  2048. /**
  2049. * ieee80211_wake_queue - wake specific queue
  2050. * @hw: pointer as obtained from ieee80211_alloc_hw().
  2051. * @queue: queue number (counted from zero).
  2052. *
  2053. * Drivers should use this function instead of netif_wake_queue.
  2054. */
  2055. void ieee80211_wake_queue(struct ieee80211_hw *hw, int queue);
  2056. /**
  2057. * ieee80211_stop_queue - stop specific queue
  2058. * @hw: pointer as obtained from ieee80211_alloc_hw().
  2059. * @queue: queue number (counted from zero).
  2060. *
  2061. * Drivers should use this function instead of netif_stop_queue.
  2062. */
  2063. void ieee80211_stop_queue(struct ieee80211_hw *hw, int queue);
  2064. /**
  2065. * ieee80211_queue_stopped - test status of the queue
  2066. * @hw: pointer as obtained from ieee80211_alloc_hw().
  2067. * @queue: queue number (counted from zero).
  2068. *
  2069. * Drivers should use this function instead of netif_stop_queue.
  2070. */
  2071. int ieee80211_queue_stopped(struct ieee80211_hw *hw, int queue);
  2072. /**
  2073. * ieee80211_stop_queues - stop all queues
  2074. * @hw: pointer as obtained from ieee80211_alloc_hw().
  2075. *
  2076. * Drivers should use this function instead of netif_stop_queue.
  2077. */
  2078. void ieee80211_stop_queues(struct ieee80211_hw *hw);
  2079. /**
  2080. * ieee80211_wake_queues - wake all queues
  2081. * @hw: pointer as obtained from ieee80211_alloc_hw().
  2082. *
  2083. * Drivers should use this function instead of netif_wake_queue.
  2084. */
  2085. void ieee80211_wake_queues(struct ieee80211_hw *hw);
  2086. /**
  2087. * ieee80211_scan_completed - completed hardware scan
  2088. *
  2089. * When hardware scan offload is used (i.e. the hw_scan() callback is
  2090. * assigned) this function needs to be called by the driver to notify
  2091. * mac80211 that the scan finished.
  2092. *
  2093. * @hw: the hardware that finished the scan
  2094. * @aborted: set to true if scan was aborted
  2095. */
  2096. void ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted);
  2097. /**
  2098. * ieee80211_iterate_active_interfaces - iterate active interfaces
  2099. *
  2100. * This function iterates over the interfaces associated with a given
  2101. * hardware that are currently active and calls the callback for them.
  2102. * This function allows the iterator function to sleep, when the iterator
  2103. * function is atomic @ieee80211_iterate_active_interfaces_atomic can
  2104. * be used.
  2105. *
  2106. * @hw: the hardware struct of which the interfaces should be iterated over
  2107. * @iterator: the iterator function to call
  2108. * @data: first argument of the iterator function
  2109. */
  2110. void ieee80211_iterate_active_interfaces(struct ieee80211_hw *hw,
  2111. void (*iterator)(void *data, u8 *mac,
  2112. struct ieee80211_vif *vif),
  2113. void *data);
  2114. /**
  2115. * ieee80211_iterate_active_interfaces_atomic - iterate active interfaces
  2116. *
  2117. * This function iterates over the interfaces associated with a given
  2118. * hardware that are currently active and calls the callback for them.
  2119. * This function requires the iterator callback function to be atomic,
  2120. * if that is not desired, use @ieee80211_iterate_active_interfaces instead.
  2121. *
  2122. * @hw: the hardware struct of which the interfaces should be iterated over
  2123. * @iterator: the iterator function to call, cannot sleep
  2124. * @data: first argument of the iterator function
  2125. */
  2126. void ieee80211_iterate_active_interfaces_atomic(struct ieee80211_hw *hw,
  2127. void (*iterator)(void *data,
  2128. u8 *mac,
  2129. struct ieee80211_vif *vif),
  2130. void *data);
  2131. /**
  2132. * ieee80211_queue_work - add work onto the mac80211 workqueue
  2133. *
  2134. * Drivers and mac80211 use this to add work onto the mac80211 workqueue.
  2135. * This helper ensures drivers are not queueing work when they should not be.
  2136. *
  2137. * @hw: the hardware struct for the interface we are adding work for
  2138. * @work: the work we want to add onto the mac80211 workqueue
  2139. */
  2140. void ieee80211_queue_work(struct ieee80211_hw *hw, struct work_struct *work);
  2141. /**
  2142. * ieee80211_queue_delayed_work - add work onto the mac80211 workqueue
  2143. *
  2144. * Drivers and mac80211 use this to queue delayed work onto the mac80211
  2145. * workqueue.
  2146. *
  2147. * @hw: the hardware struct for the interface we are adding work for
  2148. * @dwork: delayable work to queue onto the mac80211 workqueue
  2149. * @delay: number of jiffies to wait before queueing
  2150. */
  2151. void ieee80211_queue_delayed_work(struct ieee80211_hw *hw,
  2152. struct delayed_work *dwork,
  2153. unsigned long delay);
  2154. /**
  2155. * ieee80211_start_tx_ba_session - Start a tx Block Ack session.
  2156. * @sta: the station for which to start a BA session
  2157. * @tid: the TID to BA on.
  2158. *
  2159. * Return: success if addBA request was sent, failure otherwise
  2160. *
  2161. * Although mac80211/low level driver/user space application can estimate
  2162. * the need to start aggregation on a certain RA/TID, the session level
  2163. * will be managed by the mac80211.
  2164. */
  2165. int ieee80211_start_tx_ba_session(struct ieee80211_sta *sta, u16 tid);
  2166. /**
  2167. * ieee80211_start_tx_ba_cb - low level driver ready to aggregate.
  2168. * @vif: &struct ieee80211_vif pointer from the add_interface callback
  2169. * @ra: receiver address of the BA session recipient.
  2170. * @tid: the TID to BA on.
  2171. *
  2172. * This function must be called by low level driver once it has
  2173. * finished with preparations for the BA session.
  2174. */
  2175. void ieee80211_start_tx_ba_cb(struct ieee80211_vif *vif, u8 *ra, u16 tid);
  2176. /**
  2177. * ieee80211_start_tx_ba_cb_irqsafe - low level driver ready to aggregate.
  2178. * @vif: &struct ieee80211_vif pointer from the add_interface callback
  2179. * @ra: receiver address of the BA session recipient.
  2180. * @tid: the TID to BA on.
  2181. *
  2182. * This function must be called by low level driver once it has
  2183. * finished with preparations for the BA session.
  2184. * This version of the function is IRQ-safe.
  2185. */
  2186. void ieee80211_start_tx_ba_cb_irqsafe(struct ieee80211_vif *vif, const u8 *ra,
  2187. u16 tid);
  2188. /**
  2189. * ieee80211_stop_tx_ba_session - Stop a Block Ack session.
  2190. * @sta: the station whose BA session to stop
  2191. * @tid: the TID to stop BA.
  2192. * @initiator: if indicates initiator DELBA frame will be sent.
  2193. *
  2194. * Return: error if no sta with matching da found, success otherwise
  2195. *
  2196. * Although mac80211/low level driver/user space application can estimate
  2197. * the need to stop aggregation on a certain RA/TID, the session level
  2198. * will be managed by the mac80211.
  2199. */
  2200. int ieee80211_stop_tx_ba_session(struct ieee80211_sta *sta, u16 tid,
  2201. enum ieee80211_back_parties initiator);
  2202. /**
  2203. * ieee80211_stop_tx_ba_cb - low level driver ready to stop aggregate.
  2204. * @vif: &struct ieee80211_vif pointer from the add_interface callback
  2205. * @ra: receiver address of the BA session recipient.
  2206. * @tid: the desired TID to BA on.
  2207. *
  2208. * This function must be called by low level driver once it has
  2209. * finished with preparations for the BA session tear down.
  2210. */
  2211. void ieee80211_stop_tx_ba_cb(struct ieee80211_vif *vif, u8 *ra, u8 tid);
  2212. /**
  2213. * ieee80211_stop_tx_ba_cb_irqsafe - low level driver ready to stop aggregate.
  2214. * @vif: &struct ieee80211_vif pointer from the add_interface callback
  2215. * @ra: receiver address of the BA session recipient.
  2216. * @tid: the desired TID to BA on.
  2217. *
  2218. * This function must be called by low level driver once it has
  2219. * finished with preparations for the BA session tear down.
  2220. * This version of the function is IRQ-safe.
  2221. */
  2222. void ieee80211_stop_tx_ba_cb_irqsafe(struct ieee80211_vif *vif, const u8 *ra,
  2223. u16 tid);
  2224. /**
  2225. * ieee80211_find_sta - find a station
  2226. *
  2227. * @vif: virtual interface to look for station on
  2228. * @addr: station's address
  2229. *
  2230. * This function must be called under RCU lock and the
  2231. * resulting pointer is only valid under RCU lock as well.
  2232. */
  2233. struct ieee80211_sta *ieee80211_find_sta(struct ieee80211_vif *vif,
  2234. const u8 *addr);
  2235. /**
  2236. * ieee80211_find_sta_by_hw - find a station on hardware
  2237. *
  2238. * @hw: pointer as obtained from ieee80211_alloc_hw()
  2239. * @addr: station's address
  2240. *
  2241. * This function must be called under RCU lock and the
  2242. * resulting pointer is only valid under RCU lock as well.
  2243. *
  2244. * NOTE: This function should not be used! When mac80211 is converted
  2245. * internally to properly keep track of stations on multiple
  2246. * virtual interfaces, it will not always know which station to
  2247. * return here since a single address might be used by multiple
  2248. * logical stations (e.g. consider a station connecting to another
  2249. * BSSID on the same AP hardware without disconnecting first).
  2250. *
  2251. * DO NOT USE THIS FUNCTION.
  2252. */
  2253. struct ieee80211_sta *ieee80211_find_sta_by_hw(struct ieee80211_hw *hw,
  2254. const u8 *addr);
  2255. /**
  2256. * ieee80211_sta_block_awake - block station from waking up
  2257. * @hw: the hardware
  2258. * @pubsta: the station
  2259. * @block: whether to block or unblock
  2260. *
  2261. * Some devices require that all frames that are on the queues
  2262. * for a specific station that went to sleep are flushed before
  2263. * a poll response or frames after the station woke up can be
  2264. * delivered to that it. Note that such frames must be rejected
  2265. * by the driver as filtered, with the appropriate status flag.
  2266. *
  2267. * This function allows implementing this mode in a race-free
  2268. * manner.
  2269. *
  2270. * To do this, a driver must keep track of the number of frames
  2271. * still enqueued for a specific station. If this number is not
  2272. * zero when the station goes to sleep, the driver must call
  2273. * this function to force mac80211 to consider the station to
  2274. * be asleep regardless of the station's actual state. Once the
  2275. * number of outstanding frames reaches zero, the driver must
  2276. * call this function again to unblock the station. That will
  2277. * cause mac80211 to be able to send ps-poll responses, and if
  2278. * the station queried in the meantime then frames will also
  2279. * be sent out as a result of this. Additionally, the driver
  2280. * will be notified that the station woke up some time after
  2281. * it is unblocked, regardless of whether the station actually
  2282. * woke up while blocked or not.
  2283. */
  2284. void ieee80211_sta_block_awake(struct ieee80211_hw *hw,
  2285. struct ieee80211_sta *pubsta, bool block);
  2286. /**
  2287. * ieee80211_beacon_loss - inform hardware does not receive beacons
  2288. *
  2289. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  2290. *
  2291. * When beacon filtering is enabled with %IEEE80211_HW_BEACON_FILTERING and
  2292. * %IEEE80211_CONF_PS is set, the driver needs to inform whenever the
  2293. * hardware is not receiving beacons with this function.
  2294. */
  2295. void ieee80211_beacon_loss(struct ieee80211_vif *vif);
  2296. /**
  2297. * ieee80211_connection_loss - inform hardware has lost connection to the AP
  2298. *
  2299. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  2300. *
  2301. * When beacon filtering is enabled with %IEEE80211_HW_BEACON_FILTERING, and
  2302. * %IEEE80211_CONF_PS and %IEEE80211_HW_CONNECTION_MONITOR are set, the driver
  2303. * needs to inform if the connection to the AP has been lost.
  2304. *
  2305. * This function will cause immediate change to disassociated state,
  2306. * without connection recovery attempts.
  2307. */
  2308. void ieee80211_connection_loss(struct ieee80211_vif *vif);
  2309. /**
  2310. * ieee80211_cqm_rssi_notify - inform a configured connection quality monitoring
  2311. * rssi threshold triggered
  2312. *
  2313. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  2314. * @rssi_event: the RSSI trigger event type
  2315. * @gfp: context flags
  2316. *
  2317. * When the %IEEE80211_HW_SUPPORTS_CQM_RSSI is set, and a connection quality
  2318. * monitoring is configured with an rssi threshold, the driver will inform
  2319. * whenever the rssi level reaches the threshold.
  2320. */
  2321. void ieee80211_cqm_rssi_notify(struct ieee80211_vif *vif,
  2322. enum nl80211_cqm_rssi_threshold_event rssi_event,
  2323. gfp_t gfp);
  2324. /* Rate control API */
  2325. /**
  2326. * enum rate_control_changed - flags to indicate which parameter changed
  2327. *
  2328. * @IEEE80211_RC_HT_CHANGED: The HT parameters of the operating channel have
  2329. * changed, rate control algorithm can update its internal state if needed.
  2330. */
  2331. enum rate_control_changed {
  2332. IEEE80211_RC_HT_CHANGED = BIT(0)
  2333. };
  2334. /**
  2335. * struct ieee80211_tx_rate_control - rate control information for/from RC algo
  2336. *
  2337. * @hw: The hardware the algorithm is invoked for.
  2338. * @sband: The band this frame is being transmitted on.
  2339. * @bss_conf: the current BSS configuration
  2340. * @reported_rate: The rate control algorithm can fill this in to indicate
  2341. * which rate should be reported to userspace as the current rate and
  2342. * used for rate calculations in the mesh network.
  2343. * @rts: whether RTS will be used for this frame because it is longer than the
  2344. * RTS threshold
  2345. * @short_preamble: whether mac80211 will request short-preamble transmission
  2346. * if the selected rate supports it
  2347. * @max_rate_idx: user-requested maximum rate (not MCS for now)
  2348. * (deprecated; this will be removed once drivers get updated to use
  2349. * rate_idx_mask)
  2350. * @rate_idx_mask: user-requested rate mask (not MCS for now)
  2351. * @skb: the skb that will be transmitted, the control information in it needs
  2352. * to be filled in
  2353. * @ap: whether this frame is sent out in AP mode
  2354. */
  2355. struct ieee80211_tx_rate_control {
  2356. struct ieee80211_hw *hw;
  2357. struct ieee80211_supported_band *sband;
  2358. struct ieee80211_bss_conf *bss_conf;
  2359. struct sk_buff *skb;
  2360. struct ieee80211_tx_rate reported_rate;
  2361. bool rts, short_preamble;
  2362. u8 max_rate_idx;
  2363. u32 rate_idx_mask;
  2364. bool ap;
  2365. };
  2366. struct rate_control_ops {
  2367. struct module *module;
  2368. const char *name;
  2369. void *(*alloc)(struct ieee80211_hw *hw, struct dentry *debugfsdir);
  2370. void (*free)(void *priv);
  2371. void *(*alloc_sta)(void *priv, struct ieee80211_sta *sta, gfp_t gfp);
  2372. void (*rate_init)(void *priv, struct ieee80211_supported_band *sband,
  2373. struct ieee80211_sta *sta, void *priv_sta);
  2374. void (*rate_update)(void *priv, struct ieee80211_supported_band *sband,
  2375. struct ieee80211_sta *sta,
  2376. void *priv_sta, u32 changed,
  2377. enum nl80211_channel_type oper_chan_type);
  2378. void (*free_sta)(void *priv, struct ieee80211_sta *sta,
  2379. void *priv_sta);
  2380. void (*tx_status)(void *priv, struct ieee80211_supported_band *sband,
  2381. struct ieee80211_sta *sta, void *priv_sta,
  2382. struct sk_buff *skb);
  2383. void (*get_rate)(void *priv, struct ieee80211_sta *sta, void *priv_sta,
  2384. struct ieee80211_tx_rate_control *txrc);
  2385. void (*add_sta_debugfs)(void *priv, void *priv_sta,
  2386. struct dentry *dir);
  2387. void (*remove_sta_debugfs)(void *priv, void *priv_sta);
  2388. };
  2389. static inline int rate_supported(struct ieee80211_sta *sta,
  2390. enum ieee80211_band band,
  2391. int index)
  2392. {
  2393. return (sta == NULL || sta->supp_rates[band] & BIT(index));
  2394. }
  2395. /**
  2396. * rate_control_send_low - helper for drivers for management/no-ack frames
  2397. *
  2398. * Rate control algorithms that agree to use the lowest rate to
  2399. * send management frames and NO_ACK data with the respective hw
  2400. * retries should use this in the beginning of their mac80211 get_rate
  2401. * callback. If true is returned the rate control can simply return.
  2402. * If false is returned we guarantee that sta and sta and priv_sta is
  2403. * not null.
  2404. *
  2405. * Rate control algorithms wishing to do more intelligent selection of
  2406. * rate for multicast/broadcast frames may choose to not use this.
  2407. *
  2408. * @sta: &struct ieee80211_sta pointer to the target destination. Note
  2409. * that this may be null.
  2410. * @priv_sta: private rate control structure. This may be null.
  2411. * @txrc: rate control information we sholud populate for mac80211.
  2412. */
  2413. bool rate_control_send_low(struct ieee80211_sta *sta,
  2414. void *priv_sta,
  2415. struct ieee80211_tx_rate_control *txrc);
  2416. static inline s8
  2417. rate_lowest_index(struct ieee80211_supported_band *sband,
  2418. struct ieee80211_sta *sta)
  2419. {
  2420. int i;
  2421. for (i = 0; i < sband->n_bitrates; i++)
  2422. if (rate_supported(sta, sband->band, i))
  2423. return i;
  2424. /* warn when we cannot find a rate. */
  2425. WARN_ON(1);
  2426. return 0;
  2427. }
  2428. static inline
  2429. bool rate_usable_index_exists(struct ieee80211_supported_band *sband,
  2430. struct ieee80211_sta *sta)
  2431. {
  2432. unsigned int i;
  2433. for (i = 0; i < sband->n_bitrates; i++)
  2434. if (rate_supported(sta, sband->band, i))
  2435. return true;
  2436. return false;
  2437. }
  2438. int ieee80211_rate_control_register(struct rate_control_ops *ops);
  2439. void ieee80211_rate_control_unregister(struct rate_control_ops *ops);
  2440. static inline bool
  2441. conf_is_ht20(struct ieee80211_conf *conf)
  2442. {
  2443. return conf->channel_type == NL80211_CHAN_HT20;
  2444. }
  2445. static inline bool
  2446. conf_is_ht40_minus(struct ieee80211_conf *conf)
  2447. {
  2448. return conf->channel_type == NL80211_CHAN_HT40MINUS;
  2449. }
  2450. static inline bool
  2451. conf_is_ht40_plus(struct ieee80211_conf *conf)
  2452. {
  2453. return conf->channel_type == NL80211_CHAN_HT40PLUS;
  2454. }
  2455. static inline bool
  2456. conf_is_ht40(struct ieee80211_conf *conf)
  2457. {
  2458. return conf_is_ht40_minus(conf) || conf_is_ht40_plus(conf);
  2459. }
  2460. static inline bool
  2461. conf_is_ht(struct ieee80211_conf *conf)
  2462. {
  2463. return conf->channel_type != NL80211_CHAN_NO_HT;
  2464. }
  2465. #endif /* MAC80211_H */