mac80211.h 63 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699
  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 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/wireless.h>
  21. #include <net/cfg80211.h>
  22. /**
  23. * DOC: Introduction
  24. *
  25. * mac80211 is the Linux stack for 802.11 hardware that implements
  26. * only partial functionality in hard- or firmware. This document
  27. * defines the interface between mac80211 and low-level hardware
  28. * drivers.
  29. */
  30. /**
  31. * DOC: Calling mac80211 from interrupts
  32. *
  33. * Only ieee80211_tx_status_irqsafe() and ieee80211_rx_irqsafe() can be
  34. * called in hardware interrupt context. The low-level driver must not call any
  35. * other functions in hardware interrupt context. If there is a need for such
  36. * call, the low-level driver should first ACK the interrupt and perform the
  37. * IEEE 802.11 code call after this, e.g. from a scheduled workqueue or even
  38. * tasklet function.
  39. *
  40. * NOTE: If the driver opts to use the _irqsafe() functions, it may not also
  41. * use the non-irqsafe functions!
  42. */
  43. /**
  44. * DOC: Warning
  45. *
  46. * If you're reading this document and not the header file itself, it will
  47. * be incomplete because not all documentation has been converted yet.
  48. */
  49. /**
  50. * DOC: Frame format
  51. *
  52. * As a general rule, when frames are passed between mac80211 and the driver,
  53. * they start with the IEEE 802.11 header and include the same octets that are
  54. * sent over the air except for the FCS which should be calculated by the
  55. * hardware.
  56. *
  57. * There are, however, various exceptions to this rule for advanced features:
  58. *
  59. * The first exception is for hardware encryption and decryption offload
  60. * where the IV/ICV may or may not be generated in hardware.
  61. *
  62. * Secondly, when the hardware handles fragmentation, the frame handed to
  63. * the driver from mac80211 is the MSDU, not the MPDU.
  64. *
  65. * Finally, for received frames, the driver is able to indicate that it has
  66. * filled a radiotap header and put that in front of the frame; if it does
  67. * not do so then mac80211 may add this under certain circumstances.
  68. */
  69. /**
  70. * enum ieee80211_notification_type - Low level driver notification
  71. * @IEEE80211_NOTIFY_RE_ASSOC: start the re-association sequence
  72. */
  73. enum ieee80211_notification_types {
  74. IEEE80211_NOTIFY_RE_ASSOC,
  75. };
  76. /**
  77. * struct ieee80211_ht_bss_info - describing BSS's HT characteristics
  78. *
  79. * This structure describes most essential parameters needed
  80. * to describe 802.11n HT characteristics in a BSS
  81. *
  82. * @primary_channel: channel number of primery channel
  83. * @bss_cap: 802.11n's general BSS capabilities (e.g. channel width)
  84. * @bss_op_mode: 802.11n's BSS operation modes (e.g. HT protection)
  85. */
  86. struct ieee80211_ht_bss_info {
  87. u8 primary_channel;
  88. u8 bss_cap; /* use IEEE80211_HT_IE_CHA_ */
  89. u8 bss_op_mode; /* use IEEE80211_HT_IE_ */
  90. };
  91. /**
  92. * enum ieee80211_max_queues - maximum number of queues
  93. *
  94. * @IEEE80211_MAX_QUEUES: Maximum number of regular device queues.
  95. * @IEEE80211_MAX_AMPDU_QUEUES: Maximum number of queues usable
  96. * for A-MPDU operation.
  97. */
  98. enum ieee80211_max_queues {
  99. IEEE80211_MAX_QUEUES = 16,
  100. IEEE80211_MAX_AMPDU_QUEUES = 16,
  101. };
  102. /**
  103. * struct ieee80211_tx_queue_params - transmit queue configuration
  104. *
  105. * The information provided in this structure is required for QoS
  106. * transmit queue configuration. Cf. IEEE 802.11 7.3.2.29.
  107. *
  108. * @aifs: arbitration interface space [0..255, -1: use default]
  109. * @cw_min: minimum contention window [will be a value of the form
  110. * 2^n-1 in the range 1..1023; 0: use default]
  111. * @cw_max: maximum contention window [like @cw_min]
  112. * @txop: maximum burst time in units of 32 usecs, 0 meaning disabled
  113. */
  114. struct ieee80211_tx_queue_params {
  115. s16 aifs;
  116. u16 cw_min;
  117. u16 cw_max;
  118. u16 txop;
  119. };
  120. /**
  121. * struct ieee80211_tx_queue_stats - transmit queue statistics
  122. *
  123. * @len: number of packets in queue
  124. * @limit: queue length limit
  125. * @count: number of frames sent
  126. */
  127. struct ieee80211_tx_queue_stats {
  128. unsigned int len;
  129. unsigned int limit;
  130. unsigned int count;
  131. };
  132. struct ieee80211_low_level_stats {
  133. unsigned int dot11ACKFailureCount;
  134. unsigned int dot11RTSFailureCount;
  135. unsigned int dot11FCSErrorCount;
  136. unsigned int dot11RTSSuccessCount;
  137. };
  138. /**
  139. * enum ieee80211_bss_change - BSS change notification flags
  140. *
  141. * These flags are used with the bss_info_changed() callback
  142. * to indicate which BSS parameter changed.
  143. *
  144. * @BSS_CHANGED_ASSOC: association status changed (associated/disassociated),
  145. * also implies a change in the AID.
  146. * @BSS_CHANGED_ERP_CTS_PROT: CTS protection changed
  147. * @BSS_CHANGED_ERP_PREAMBLE: preamble changed
  148. * @BSS_CHANGED_HT: 802.11n parameters changed
  149. */
  150. enum ieee80211_bss_change {
  151. BSS_CHANGED_ASSOC = 1<<0,
  152. BSS_CHANGED_ERP_CTS_PROT = 1<<1,
  153. BSS_CHANGED_ERP_PREAMBLE = 1<<2,
  154. BSS_CHANGED_HT = 1<<4,
  155. };
  156. /**
  157. * struct ieee80211_bss_conf - holds the BSS's changing parameters
  158. *
  159. * This structure keeps information about a BSS (and an association
  160. * to that BSS) that can change during the lifetime of the BSS.
  161. *
  162. * @assoc: association status
  163. * @aid: association ID number, valid only when @assoc is true
  164. * @use_cts_prot: use CTS protection
  165. * @use_short_preamble: use 802.11b short preamble
  166. * @timestamp: beacon timestamp
  167. * @beacon_int: beacon interval
  168. * @assoc_capability: capabbilities taken from assoc resp
  169. * @assoc_ht: association in HT mode
  170. * @ht_conf: ht capabilities
  171. * @ht_bss_conf: ht extended capabilities
  172. */
  173. struct ieee80211_bss_conf {
  174. /* association related data */
  175. bool assoc;
  176. u16 aid;
  177. /* erp related data */
  178. bool use_cts_prot;
  179. bool use_short_preamble;
  180. u16 beacon_int;
  181. u16 assoc_capability;
  182. u64 timestamp;
  183. /* ht related data */
  184. bool assoc_ht;
  185. struct ieee80211_ht_info *ht_conf;
  186. struct ieee80211_ht_bss_info *ht_bss_conf;
  187. };
  188. /**
  189. * enum mac80211_tx_control_flags - flags to describe Tx configuration for
  190. * the Tx frame
  191. *
  192. * These flags are used with the @flags member of &ieee80211_tx_control
  193. *
  194. * @IEEE80211_TXCTL_REQ_TX_STATUS: request TX status callback for this frame.
  195. * @IEEE80211_TXCTL_DO_NOT_ENCRYPT: send this frame without encryption;
  196. * e.g., for EAPOL frame
  197. * @IEEE80211_TXCTL_USE_RTS_CTS: use RTS-CTS before sending frame
  198. * @IEEE80211_TXCTL_USE_CTS_PROTECT: use CTS protection for the frame (e.g.,
  199. * for combined 802.11g / 802.11b networks)
  200. * @IEEE80211_TXCTL_NO_ACK: tell the low level not to wait for an ack
  201. * @IEEE80211_TXCTL_RATE_CTRL_PROBE
  202. * @EEE80211_TXCTL_CLEAR_PS_FILT: clear powersave filter
  203. * for destination station
  204. * @IEEE80211_TXCTL_REQUEUE:
  205. * @IEEE80211_TXCTL_FIRST_FRAGMENT: this is a first fragment of the frame
  206. * @IEEE80211_TXCTL_LONG_RETRY_LIMIT: this frame should be send using the
  207. * through set_retry_limit configured long
  208. * retry value
  209. * @IEEE80211_TXCTL_EAPOL_FRAME: internal to mac80211
  210. * @IEEE80211_TXCTL_SEND_AFTER_DTIM: send this frame after DTIM beacon
  211. * @IEEE80211_TXCTL_AMPDU: this frame should be sent as part of an A-MPDU
  212. * @IEEE80211_TXCTL_OFDM_HT: this frame can be sent in HT OFDM rates. number
  213. * of streams when this flag is on can be extracted
  214. * from antenna_sel_tx, so if 1 antenna is marked
  215. * use SISO, 2 antennas marked use MIMO, n antennas
  216. * marked use MIMO_n.
  217. * @IEEE80211_TXCTL_GREEN_FIELD: use green field protection for this frame
  218. * @IEEE80211_TXCTL_40_MHZ_WIDTH: send this frame using 40 Mhz channel width
  219. * @IEEE80211_TXCTL_DUP_DATA: duplicate data frame on both 20 Mhz channels
  220. * @IEEE80211_TXCTL_SHORT_GI: send this frame using short guard interval
  221. */
  222. enum mac80211_tx_control_flags {
  223. IEEE80211_TXCTL_REQ_TX_STATUS = (1<<0),
  224. IEEE80211_TXCTL_DO_NOT_ENCRYPT = (1<<1),
  225. IEEE80211_TXCTL_USE_RTS_CTS = (1<<2),
  226. IEEE80211_TXCTL_USE_CTS_PROTECT = (1<<3),
  227. IEEE80211_TXCTL_NO_ACK = (1<<4),
  228. IEEE80211_TXCTL_RATE_CTRL_PROBE = (1<<5),
  229. IEEE80211_TXCTL_CLEAR_PS_FILT = (1<<6),
  230. IEEE80211_TXCTL_REQUEUE = (1<<7),
  231. IEEE80211_TXCTL_FIRST_FRAGMENT = (1<<8),
  232. IEEE80211_TXCTL_SHORT_PREAMBLE = (1<<9),
  233. IEEE80211_TXCTL_LONG_RETRY_LIMIT = (1<<10),
  234. IEEE80211_TXCTL_EAPOL_FRAME = (1<<11),
  235. IEEE80211_TXCTL_SEND_AFTER_DTIM = (1<<12),
  236. IEEE80211_TXCTL_AMPDU = (1<<13),
  237. IEEE80211_TXCTL_OFDM_HT = (1<<14),
  238. IEEE80211_TXCTL_GREEN_FIELD = (1<<15),
  239. IEEE80211_TXCTL_40_MHZ_WIDTH = (1<<16),
  240. IEEE80211_TXCTL_DUP_DATA = (1<<17),
  241. IEEE80211_TXCTL_SHORT_GI = (1<<18),
  242. };
  243. /* Transmit control fields. This data structure is passed to low-level driver
  244. * with each TX frame. The low-level driver is responsible for configuring
  245. * the hardware to use given values (depending on what is supported).
  246. *
  247. * NOTE: Be careful with using the pointers outside of the ieee80211_ops->tx()
  248. * context (i.e. when defering the work to a workqueue).
  249. * The vif pointer is valid until the it has been removed with the
  250. * ieee80211_ops->remove_interface() callback funtion.
  251. * The hw_key pointer is valid until it has been removed with the
  252. * ieee80211_ops->set_key() callback function.
  253. * The tx_rate and alt_retry_rate pointers are valid until the phy is
  254. * deregistered.
  255. */
  256. struct ieee80211_tx_control {
  257. struct ieee80211_vif *vif;
  258. struct ieee80211_rate *tx_rate;
  259. /* Transmit rate for RTS/CTS frame */
  260. struct ieee80211_rate *rts_cts_rate;
  261. /* retry rate for the last retries */
  262. struct ieee80211_rate *alt_retry_rate;
  263. /* Key used for hardware encryption
  264. * NULL if IEEE80211_TXCTL_DO_NOT_ENCRYPT is set */
  265. struct ieee80211_key_conf *hw_key;
  266. u32 flags; /* tx control flags defined above */
  267. u8 retry_limit; /* 1 = only first attempt, 2 = one retry, ..
  268. * This could be used when set_retry_limit
  269. * is not implemented by the driver */
  270. u8 antenna_sel_tx; /* 0 = default/diversity, otherwise bit
  271. * position represents antenna number used */
  272. u8 icv_len; /* length of the ICV/MIC field in octets */
  273. u8 iv_len; /* length of the IV field in octets */
  274. u16 queue; /* hardware queue to use for this frame;
  275. * 0 = highest, hw->queues-1 = lowest */
  276. u16 aid; /* Station AID */
  277. int type; /* internal */
  278. };
  279. /**
  280. * enum mac80211_rx_flags - receive flags
  281. *
  282. * These flags are used with the @flag member of &struct ieee80211_rx_status.
  283. * @RX_FLAG_MMIC_ERROR: Michael MIC error was reported on this frame.
  284. * Use together with %RX_FLAG_MMIC_STRIPPED.
  285. * @RX_FLAG_DECRYPTED: This frame was decrypted in hardware.
  286. * @RX_FLAG_RADIOTAP: This frame starts with a radiotap header.
  287. * @RX_FLAG_MMIC_STRIPPED: the Michael MIC is stripped off this frame,
  288. * verification has been done by the hardware.
  289. * @RX_FLAG_IV_STRIPPED: The IV/ICV are stripped from this frame.
  290. * If this flag is set, the stack cannot do any replay detection
  291. * hence the driver or hardware will have to do that.
  292. * @RX_FLAG_FAILED_FCS_CRC: Set this flag if the FCS check failed on
  293. * the frame.
  294. * @RX_FLAG_FAILED_PLCP_CRC: Set this flag if the PCLP check failed on
  295. * the frame.
  296. * @RX_FLAG_TSFT: The timestamp passed in the RX status (@mactime field)
  297. * is valid. This is useful in monitor mode and necessary for beacon frames
  298. * to enable IBSS merging.
  299. */
  300. enum mac80211_rx_flags {
  301. RX_FLAG_MMIC_ERROR = 1<<0,
  302. RX_FLAG_DECRYPTED = 1<<1,
  303. RX_FLAG_RADIOTAP = 1<<2,
  304. RX_FLAG_MMIC_STRIPPED = 1<<3,
  305. RX_FLAG_IV_STRIPPED = 1<<4,
  306. RX_FLAG_FAILED_FCS_CRC = 1<<5,
  307. RX_FLAG_FAILED_PLCP_CRC = 1<<6,
  308. RX_FLAG_TSFT = 1<<7,
  309. };
  310. /**
  311. * struct ieee80211_rx_status - receive status
  312. *
  313. * The low-level driver should provide this information (the subset
  314. * supported by hardware) to the 802.11 code with each received
  315. * frame.
  316. *
  317. * @mactime: value in microseconds of the 64-bit Time Synchronization Function
  318. * (TSF) timer when the first data symbol (MPDU) arrived at the hardware.
  319. * @band: the active band when this frame was received
  320. * @freq: frequency the radio was tuned to when receiving this frame, in MHz
  321. * @signal: signal strength when receiving this frame, either in dBm, in dB or
  322. * unspecified depending on the hardware capabilities flags
  323. * @IEEE80211_HW_SIGNAL_*
  324. * @noise: noise when receiving this frame, in dBm.
  325. * @qual: overall signal quality indication, in percent (0-100).
  326. * @antenna: antenna used
  327. * @rate_idx: index of data rate into band's supported rates
  328. * @flag: %RX_FLAG_*
  329. */
  330. struct ieee80211_rx_status {
  331. u64 mactime;
  332. enum ieee80211_band band;
  333. int freq;
  334. int signal;
  335. int noise;
  336. int qual;
  337. int antenna;
  338. int rate_idx;
  339. int flag;
  340. };
  341. /**
  342. * enum ieee80211_tx_status_flags - transmit status flags
  343. *
  344. * Status flags to indicate various transmit conditions.
  345. *
  346. * @IEEE80211_TX_STATUS_TX_FILTERED: The frame was not transmitted
  347. * because the destination STA was in powersave mode.
  348. * @IEEE80211_TX_STATUS_ACK: Frame was acknowledged
  349. * @IEEE80211_TX_STATUS_AMPDU: The frame was aggregated, so status
  350. * is for the whole aggregation.
  351. */
  352. enum ieee80211_tx_status_flags {
  353. IEEE80211_TX_STATUS_TX_FILTERED = 1<<0,
  354. IEEE80211_TX_STATUS_ACK = 1<<1,
  355. IEEE80211_TX_STATUS_AMPDU = 1<<2,
  356. };
  357. /**
  358. * struct ieee80211_tx_status - transmit status
  359. *
  360. * As much information as possible should be provided for each transmitted
  361. * frame with ieee80211_tx_status().
  362. *
  363. * @control: a copy of the &struct ieee80211_tx_control passed to the driver
  364. * in the tx() callback.
  365. * @flags: transmit status flags, defined above
  366. * @retry_count: number of retries
  367. * @excessive_retries: set to 1 if the frame was retried many times
  368. * but not acknowledged
  369. * @ampdu_ack_len: number of aggregated frames.
  370. * relevant only if IEEE80211_TX_STATUS_AMPDU was set.
  371. * @ampdu_ack_map: block ack bit map for the aggregation.
  372. * relevant only if IEEE80211_TX_STATUS_AMPDU was set.
  373. * @ack_signal: signal strength of the ACK frame either in dBm, dB or unspec
  374. * depending on hardware capabilites flags @IEEE80211_HW_SIGNAL_*
  375. */
  376. struct ieee80211_tx_status {
  377. struct ieee80211_tx_control control;
  378. u8 flags;
  379. u8 retry_count;
  380. bool excessive_retries;
  381. u8 ampdu_ack_len;
  382. u64 ampdu_ack_map;
  383. int ack_signal;
  384. };
  385. /**
  386. * enum ieee80211_conf_flags - configuration flags
  387. *
  388. * Flags to define PHY configuration options
  389. *
  390. * @IEEE80211_CONF_SHORT_SLOT_TIME: use 802.11g short slot time
  391. * @IEEE80211_CONF_RADIOTAP: add radiotap header at receive time (if supported)
  392. * @IEEE80211_CONF_SUPPORT_HT_MODE: use 802.11n HT capabilities (if supported)
  393. */
  394. enum ieee80211_conf_flags {
  395. IEEE80211_CONF_SHORT_SLOT_TIME = (1<<0),
  396. IEEE80211_CONF_RADIOTAP = (1<<1),
  397. IEEE80211_CONF_SUPPORT_HT_MODE = (1<<2),
  398. };
  399. /**
  400. * struct ieee80211_conf - configuration of the device
  401. *
  402. * This struct indicates how the driver shall configure the hardware.
  403. *
  404. * @radio_enabled: when zero, driver is required to switch off the radio.
  405. * TODO make a flag
  406. * @beacon_int: beacon interval (TODO make interface config)
  407. * @flags: configuration flags defined above
  408. * @power_level: requested transmit power (in dBm)
  409. * @max_antenna_gain: maximum antenna gain (in dBi)
  410. * @antenna_sel_tx: transmit antenna selection, 0: default/diversity,
  411. * 1/2: antenna 0/1
  412. * @antenna_sel_rx: receive antenna selection, like @antenna_sel_tx
  413. * @ht_conf: describes current self configuration of 802.11n HT capabilies
  414. * @ht_bss_conf: describes current BSS configuration of 802.11n HT parameters
  415. * @channel: the channel to tune to
  416. */
  417. struct ieee80211_conf {
  418. int radio_enabled;
  419. int beacon_int;
  420. u32 flags;
  421. int power_level;
  422. int max_antenna_gain;
  423. u8 antenna_sel_tx;
  424. u8 antenna_sel_rx;
  425. struct ieee80211_channel *channel;
  426. struct ieee80211_ht_info ht_conf;
  427. struct ieee80211_ht_bss_info ht_bss_conf;
  428. };
  429. /**
  430. * enum ieee80211_if_types - types of 802.11 network interfaces
  431. *
  432. * @IEEE80211_IF_TYPE_INVALID: invalid interface type, not used
  433. * by mac80211 itself
  434. * @IEEE80211_IF_TYPE_AP: interface in AP mode.
  435. * @IEEE80211_IF_TYPE_MGMT: special interface for communication with hostap
  436. * daemon. Drivers should never see this type.
  437. * @IEEE80211_IF_TYPE_STA: interface in STA (client) mode.
  438. * @IEEE80211_IF_TYPE_IBSS: interface in IBSS (ad-hoc) mode.
  439. * @IEEE80211_IF_TYPE_MNTR: interface in monitor (rfmon) mode.
  440. * @IEEE80211_IF_TYPE_WDS: interface in WDS mode.
  441. * @IEEE80211_IF_TYPE_VLAN: VLAN interface bound to an AP, drivers
  442. * will never see this type.
  443. * @IEEE80211_IF_TYPE_MESH_POINT: 802.11s mesh point
  444. */
  445. enum ieee80211_if_types {
  446. IEEE80211_IF_TYPE_INVALID,
  447. IEEE80211_IF_TYPE_AP,
  448. IEEE80211_IF_TYPE_STA,
  449. IEEE80211_IF_TYPE_IBSS,
  450. IEEE80211_IF_TYPE_MESH_POINT,
  451. IEEE80211_IF_TYPE_MNTR,
  452. IEEE80211_IF_TYPE_WDS,
  453. IEEE80211_IF_TYPE_VLAN,
  454. };
  455. /**
  456. * struct ieee80211_vif - per-interface data
  457. *
  458. * Data in this structure is continually present for driver
  459. * use during the life of a virtual interface.
  460. *
  461. * @type: type of this virtual interface
  462. * @drv_priv: data area for driver use, will always be aligned to
  463. * sizeof(void *).
  464. */
  465. struct ieee80211_vif {
  466. enum ieee80211_if_types type;
  467. /* must be last */
  468. u8 drv_priv[0] __attribute__((__aligned__(sizeof(void *))));
  469. };
  470. static inline bool ieee80211_vif_is_mesh(struct ieee80211_vif *vif)
  471. {
  472. #ifdef CONFIG_MAC80211_MESH
  473. return vif->type == IEEE80211_IF_TYPE_MESH_POINT;
  474. #endif
  475. return false;
  476. }
  477. /**
  478. * struct ieee80211_if_init_conf - initial configuration of an interface
  479. *
  480. * @vif: pointer to a driver-use per-interface structure. The pointer
  481. * itself is also used for various functions including
  482. * ieee80211_beacon_get() and ieee80211_get_buffered_bc().
  483. * @type: one of &enum ieee80211_if_types constants. Determines the type of
  484. * added/removed interface.
  485. * @mac_addr: pointer to MAC address of the interface. This pointer is valid
  486. * until the interface is removed (i.e. it cannot be used after
  487. * remove_interface() callback was called for this interface).
  488. *
  489. * This structure is used in add_interface() and remove_interface()
  490. * callbacks of &struct ieee80211_hw.
  491. *
  492. * When you allow multiple interfaces to be added to your PHY, take care
  493. * that the hardware can actually handle multiple MAC addresses. However,
  494. * also take care that when there's no interface left with mac_addr != %NULL
  495. * you remove the MAC address from the device to avoid acknowledging packets
  496. * in pure monitor mode.
  497. */
  498. struct ieee80211_if_init_conf {
  499. enum ieee80211_if_types type;
  500. struct ieee80211_vif *vif;
  501. void *mac_addr;
  502. };
  503. /**
  504. * struct ieee80211_if_conf - configuration of an interface
  505. *
  506. * @type: type of the interface. This is always the same as was specified in
  507. * &struct ieee80211_if_init_conf. The type of an interface never changes
  508. * during the life of the interface; this field is present only for
  509. * convenience.
  510. * @bssid: BSSID of the network we are associated to/creating.
  511. * @ssid: used (together with @ssid_len) by drivers for hardware that
  512. * generate beacons independently. The pointer is valid only during the
  513. * config_interface() call, so copy the value somewhere if you need
  514. * it.
  515. * @ssid_len: length of the @ssid field.
  516. * @beacon: beacon template. Valid only if @host_gen_beacon_template in
  517. * &struct ieee80211_hw is set. The driver is responsible of freeing
  518. * the sk_buff.
  519. * @beacon_control: tx_control for the beacon template, this field is only
  520. * valid when the @beacon field was set.
  521. *
  522. * This structure is passed to the config_interface() callback of
  523. * &struct ieee80211_hw.
  524. */
  525. struct ieee80211_if_conf {
  526. int type;
  527. u8 *bssid;
  528. u8 *ssid;
  529. size_t ssid_len;
  530. struct sk_buff *beacon;
  531. struct ieee80211_tx_control *beacon_control;
  532. };
  533. /**
  534. * enum ieee80211_key_alg - key algorithm
  535. * @ALG_WEP: WEP40 or WEP104
  536. * @ALG_TKIP: TKIP
  537. * @ALG_CCMP: CCMP (AES)
  538. */
  539. enum ieee80211_key_alg {
  540. ALG_WEP,
  541. ALG_TKIP,
  542. ALG_CCMP,
  543. };
  544. /**
  545. * enum ieee80211_key_flags - key flags
  546. *
  547. * These flags are used for communication about keys between the driver
  548. * and mac80211, with the @flags parameter of &struct ieee80211_key_conf.
  549. *
  550. * @IEEE80211_KEY_FLAG_WMM_STA: Set by mac80211, this flag indicates
  551. * that the STA this key will be used with could be using QoS.
  552. * @IEEE80211_KEY_FLAG_GENERATE_IV: This flag should be set by the
  553. * driver to indicate that it requires IV generation for this
  554. * particular key.
  555. * @IEEE80211_KEY_FLAG_GENERATE_MMIC: This flag should be set by
  556. * the driver for a TKIP key if it requires Michael MIC
  557. * generation in software.
  558. * @IEEE80211_KEY_FLAG_PAIRWISE: Set by mac80211, this flag indicates
  559. * that the key is pairwise rather then a shared key.
  560. */
  561. enum ieee80211_key_flags {
  562. IEEE80211_KEY_FLAG_WMM_STA = 1<<0,
  563. IEEE80211_KEY_FLAG_GENERATE_IV = 1<<1,
  564. IEEE80211_KEY_FLAG_GENERATE_MMIC= 1<<2,
  565. IEEE80211_KEY_FLAG_PAIRWISE = 1<<3,
  566. };
  567. /**
  568. * struct ieee80211_key_conf - key information
  569. *
  570. * This key information is given by mac80211 to the driver by
  571. * the set_key() callback in &struct ieee80211_ops.
  572. *
  573. * @hw_key_idx: To be set by the driver, this is the key index the driver
  574. * wants to be given when a frame is transmitted and needs to be
  575. * encrypted in hardware.
  576. * @alg: The key algorithm.
  577. * @flags: key flags, see &enum ieee80211_key_flags.
  578. * @keyidx: the key index (0-3)
  579. * @keylen: key material length
  580. * @key: key material
  581. */
  582. struct ieee80211_key_conf {
  583. enum ieee80211_key_alg alg;
  584. u8 hw_key_idx;
  585. u8 flags;
  586. s8 keyidx;
  587. u8 keylen;
  588. u8 key[0];
  589. };
  590. /**
  591. * enum set_key_cmd - key command
  592. *
  593. * Used with the set_key() callback in &struct ieee80211_ops, this
  594. * indicates whether a key is being removed or added.
  595. *
  596. * @SET_KEY: a key is set
  597. * @DISABLE_KEY: a key must be disabled
  598. */
  599. enum set_key_cmd {
  600. SET_KEY, DISABLE_KEY,
  601. };
  602. /**
  603. * enum sta_notify_cmd - sta notify command
  604. *
  605. * Used with the sta_notify() callback in &struct ieee80211_ops, this
  606. * indicates addition and removal of a station to station table
  607. *
  608. * @STA_NOTIFY_ADD: a station was added to the station table
  609. * @STA_NOTIFY_REMOVE: a station being removed from the station table
  610. */
  611. enum sta_notify_cmd {
  612. STA_NOTIFY_ADD, STA_NOTIFY_REMOVE
  613. };
  614. /**
  615. * enum ieee80211_tkip_key_type - get tkip key
  616. *
  617. * Used by drivers which need to get a tkip key for skb. Some drivers need a
  618. * phase 1 key, others need a phase 2 key. A single function allows the driver
  619. * to get the key, this enum indicates what type of key is required.
  620. *
  621. * @IEEE80211_TKIP_P1_KEY: the driver needs a phase 1 key
  622. * @IEEE80211_TKIP_P2_KEY: the driver needs a phase 2 key
  623. */
  624. enum ieee80211_tkip_key_type {
  625. IEEE80211_TKIP_P1_KEY,
  626. IEEE80211_TKIP_P2_KEY,
  627. };
  628. /**
  629. * enum ieee80211_hw_flags - hardware flags
  630. *
  631. * These flags are used to indicate hardware capabilities to
  632. * the stack. Generally, flags here should have their meaning
  633. * done in a way that the simplest hardware doesn't need setting
  634. * any particular flags. There are some exceptions to this rule,
  635. * however, so you are advised to review these flags carefully.
  636. *
  637. * @IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE:
  638. * The device only needs to be supplied with a beacon template.
  639. * If you need the host to generate each beacon then don't use
  640. * this flag and call ieee80211_beacon_get() when you need the
  641. * next beacon frame. Note that if you set this flag, you must
  642. * implement the set_tim() callback for powersave mode to work
  643. * properly.
  644. * This flag is only relevant for access-point mode.
  645. *
  646. * @IEEE80211_HW_RX_INCLUDES_FCS:
  647. * Indicates that received frames passed to the stack include
  648. * the FCS at the end.
  649. *
  650. * @IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING:
  651. * Some wireless LAN chipsets buffer broadcast/multicast frames
  652. * for power saving stations in the hardware/firmware and others
  653. * rely on the host system for such buffering. This option is used
  654. * to configure the IEEE 802.11 upper layer to buffer broadcast and
  655. * multicast frames when there are power saving stations so that
  656. * the driver can fetch them with ieee80211_get_buffered_bc(). Note
  657. * that not setting this flag works properly only when the
  658. * %IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE is also not set because
  659. * otherwise the stack will not know when the DTIM beacon was sent.
  660. *
  661. * @IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE:
  662. * Hardware is not capable of short slot operation on the 2.4 GHz band.
  663. *
  664. * @IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE:
  665. * Hardware is not capable of receiving frames with short preamble on
  666. * the 2.4 GHz band.
  667. *
  668. * @IEEE80211_HW_SIGNAL_UNSPEC:
  669. * Hardware can provide signal values but we don't know its units. We
  670. * expect values between 0 and @max_signal.
  671. * If possible please provide dB or dBm instead.
  672. *
  673. * @IEEE80211_HW_SIGNAL_DB:
  674. * Hardware gives signal values in dB, decibel difference from an
  675. * arbitrary, fixed reference. We expect values between 0 and @max_signal.
  676. * If possible please provide dBm instead.
  677. *
  678. * @IEEE80211_HW_SIGNAL_DBM:
  679. * Hardware gives signal values in dBm, decibel difference from
  680. * one milliwatt. This is the preferred method since it is standardized
  681. * between different devices. @max_signal does not need to be set.
  682. *
  683. * @IEEE80211_HW_NOISE_DBM:
  684. * Hardware can provide noise (radio interference) values in units dBm,
  685. * decibel difference from one milliwatt.
  686. */
  687. enum ieee80211_hw_flags {
  688. IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE = 1<<0,
  689. IEEE80211_HW_RX_INCLUDES_FCS = 1<<1,
  690. IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING = 1<<2,
  691. IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE = 1<<3,
  692. IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE = 1<<4,
  693. IEEE80211_HW_SIGNAL_UNSPEC = 1<<5,
  694. IEEE80211_HW_SIGNAL_DB = 1<<6,
  695. IEEE80211_HW_SIGNAL_DBM = 1<<7,
  696. IEEE80211_HW_NOISE_DBM = 1<<8,
  697. };
  698. /**
  699. * struct ieee80211_hw - hardware information and state
  700. *
  701. * This structure contains the configuration and hardware
  702. * information for an 802.11 PHY.
  703. *
  704. * @wiphy: This points to the &struct wiphy allocated for this
  705. * 802.11 PHY. You must fill in the @perm_addr and @dev
  706. * members of this structure using SET_IEEE80211_DEV()
  707. * and SET_IEEE80211_PERM_ADDR(). Additionally, all supported
  708. * bands (with channels, bitrates) are registered here.
  709. *
  710. * @conf: &struct ieee80211_conf, device configuration, don't use.
  711. *
  712. * @workqueue: single threaded workqueue available for driver use,
  713. * allocated by mac80211 on registration and flushed on
  714. * unregistration.
  715. *
  716. * @priv: pointer to private area that was allocated for driver use
  717. * along with this structure.
  718. *
  719. * @flags: hardware flags, see &enum ieee80211_hw_flags.
  720. *
  721. * @extra_tx_headroom: headroom to reserve in each transmit skb
  722. * for use by the driver (e.g. for transmit headers.)
  723. *
  724. * @channel_change_time: time (in microseconds) it takes to change channels.
  725. *
  726. * @max_signal: Maximum value for signal (rssi) in RX information, used
  727. * only when @IEEE80211_HW_SIGNAL_UNSPEC or @IEEE80211_HW_SIGNAL_DB
  728. *
  729. * @queues: number of available hardware transmit queues for
  730. * data packets. WMM/QoS requires at least four, these
  731. * queues need to have configurable access parameters.
  732. *
  733. * @ampdu_queues: number of available hardware transmit queues
  734. * for A-MPDU packets, these have no access parameters
  735. * because they're used only for A-MPDU frames. Note that
  736. * mac80211 will not currently use any of the regular queues
  737. * for aggregation.
  738. *
  739. * @rate_control_algorithm: rate control algorithm for this hardware.
  740. * If unset (NULL), the default algorithm will be used. Must be
  741. * set before calling ieee80211_register_hw().
  742. *
  743. * @vif_data_size: size (in bytes) of the drv_priv data area
  744. * within &struct ieee80211_vif.
  745. */
  746. struct ieee80211_hw {
  747. struct ieee80211_conf conf;
  748. struct wiphy *wiphy;
  749. struct workqueue_struct *workqueue;
  750. const char *rate_control_algorithm;
  751. void *priv;
  752. u32 flags;
  753. unsigned int extra_tx_headroom;
  754. int channel_change_time;
  755. int vif_data_size;
  756. u16 queues, ampdu_queues;
  757. s8 max_signal;
  758. };
  759. /**
  760. * SET_IEEE80211_DEV - set device for 802.11 hardware
  761. *
  762. * @hw: the &struct ieee80211_hw to set the device for
  763. * @dev: the &struct device of this 802.11 device
  764. */
  765. static inline void SET_IEEE80211_DEV(struct ieee80211_hw *hw, struct device *dev)
  766. {
  767. set_wiphy_dev(hw->wiphy, dev);
  768. }
  769. /**
  770. * SET_IEEE80211_PERM_ADDR - set the permanenet MAC address for 802.11 hardware
  771. *
  772. * @hw: the &struct ieee80211_hw to set the MAC address for
  773. * @addr: the address to set
  774. */
  775. static inline void SET_IEEE80211_PERM_ADDR(struct ieee80211_hw *hw, u8 *addr)
  776. {
  777. memcpy(hw->wiphy->perm_addr, addr, ETH_ALEN);
  778. }
  779. /**
  780. * DOC: Hardware crypto acceleration
  781. *
  782. * mac80211 is capable of taking advantage of many hardware
  783. * acceleration designs for encryption and decryption operations.
  784. *
  785. * The set_key() callback in the &struct ieee80211_ops for a given
  786. * device is called to enable hardware acceleration of encryption and
  787. * decryption. The callback takes an @address parameter that will be
  788. * the broadcast address for default keys, the other station's hardware
  789. * address for individual keys or the zero address for keys that will
  790. * be used only for transmission.
  791. * Multiple transmission keys with the same key index may be used when
  792. * VLANs are configured for an access point.
  793. *
  794. * The @local_address parameter will always be set to our own address,
  795. * this is only relevant if you support multiple local addresses.
  796. *
  797. * When transmitting, the TX control data will use the @hw_key_idx
  798. * selected by the driver by modifying the &struct ieee80211_key_conf
  799. * pointed to by the @key parameter to the set_key() function.
  800. *
  801. * The set_key() call for the %SET_KEY command should return 0 if
  802. * the key is now in use, -%EOPNOTSUPP or -%ENOSPC if it couldn't be
  803. * added; if you return 0 then hw_key_idx must be assigned to the
  804. * hardware key index, you are free to use the full u8 range.
  805. *
  806. * When the cmd is %DISABLE_KEY then it must succeed.
  807. *
  808. * Note that it is permissible to not decrypt a frame even if a key
  809. * for it has been uploaded to hardware, the stack will not make any
  810. * decision based on whether a key has been uploaded or not but rather
  811. * based on the receive flags.
  812. *
  813. * The &struct ieee80211_key_conf structure pointed to by the @key
  814. * parameter is guaranteed to be valid until another call to set_key()
  815. * removes it, but it can only be used as a cookie to differentiate
  816. * keys.
  817. *
  818. * In TKIP some HW need to be provided a phase 1 key, for RX decryption
  819. * acceleration (i.e. iwlwifi). Those drivers should provide update_tkip_key
  820. * handler.
  821. * The update_tkip_key() call updates the driver with the new phase 1 key.
  822. * This happens everytime the iv16 wraps around (every 65536 packets). The
  823. * set_key() call will happen only once for each key (unless the AP did
  824. * rekeying), it will not include a valid phase 1 key. The valid phase 1 key is
  825. * provided by udpate_tkip_key only. The trigger that makes mac80211 call this
  826. * handler is software decryption with wrap around of iv16.
  827. */
  828. /**
  829. * DOC: Frame filtering
  830. *
  831. * mac80211 requires to see many management frames for proper
  832. * operation, and users may want to see many more frames when
  833. * in monitor mode. However, for best CPU usage and power consumption,
  834. * having as few frames as possible percolate through the stack is
  835. * desirable. Hence, the hardware should filter as much as possible.
  836. *
  837. * To achieve this, mac80211 uses filter flags (see below) to tell
  838. * the driver's configure_filter() function which frames should be
  839. * passed to mac80211 and which should be filtered out.
  840. *
  841. * The configure_filter() callback is invoked with the parameters
  842. * @mc_count and @mc_list for the combined multicast address list
  843. * of all virtual interfaces, @changed_flags telling which flags
  844. * were changed and @total_flags with the new flag states.
  845. *
  846. * If your device has no multicast address filters your driver will
  847. * need to check both the %FIF_ALLMULTI flag and the @mc_count
  848. * parameter to see whether multicast frames should be accepted
  849. * or dropped.
  850. *
  851. * All unsupported flags in @total_flags must be cleared.
  852. * Hardware does not support a flag if it is incapable of _passing_
  853. * the frame to the stack. Otherwise the driver must ignore
  854. * the flag, but not clear it.
  855. * You must _only_ clear the flag (announce no support for the
  856. * flag to mac80211) if you are not able to pass the packet type
  857. * to the stack (so the hardware always filters it).
  858. * So for example, you should clear @FIF_CONTROL, if your hardware
  859. * always filters control frames. If your hardware always passes
  860. * control frames to the kernel and is incapable of filtering them,
  861. * you do _not_ clear the @FIF_CONTROL flag.
  862. * This rule applies to all other FIF flags as well.
  863. */
  864. /**
  865. * enum ieee80211_filter_flags - hardware filter flags
  866. *
  867. * These flags determine what the filter in hardware should be
  868. * programmed to let through and what should not be passed to the
  869. * stack. It is always safe to pass more frames than requested,
  870. * but this has negative impact on power consumption.
  871. *
  872. * @FIF_PROMISC_IN_BSS: promiscuous mode within your BSS,
  873. * think of the BSS as your network segment and then this corresponds
  874. * to the regular ethernet device promiscuous mode.
  875. *
  876. * @FIF_ALLMULTI: pass all multicast frames, this is used if requested
  877. * by the user or if the hardware is not capable of filtering by
  878. * multicast address.
  879. *
  880. * @FIF_FCSFAIL: pass frames with failed FCS (but you need to set the
  881. * %RX_FLAG_FAILED_FCS_CRC for them)
  882. *
  883. * @FIF_PLCPFAIL: pass frames with failed PLCP CRC (but you need to set
  884. * the %RX_FLAG_FAILED_PLCP_CRC for them
  885. *
  886. * @FIF_BCN_PRBRESP_PROMISC: This flag is set during scanning to indicate
  887. * to the hardware that it should not filter beacons or probe responses
  888. * by BSSID. Filtering them can greatly reduce the amount of processing
  889. * mac80211 needs to do and the amount of CPU wakeups, so you should
  890. * honour this flag if possible.
  891. *
  892. * @FIF_CONTROL: pass control frames, if PROMISC_IN_BSS is not set then
  893. * only those addressed to this station
  894. *
  895. * @FIF_OTHER_BSS: pass frames destined to other BSSes
  896. */
  897. enum ieee80211_filter_flags {
  898. FIF_PROMISC_IN_BSS = 1<<0,
  899. FIF_ALLMULTI = 1<<1,
  900. FIF_FCSFAIL = 1<<2,
  901. FIF_PLCPFAIL = 1<<3,
  902. FIF_BCN_PRBRESP_PROMISC = 1<<4,
  903. FIF_CONTROL = 1<<5,
  904. FIF_OTHER_BSS = 1<<6,
  905. };
  906. /**
  907. * enum ieee80211_ampdu_mlme_action - A-MPDU actions
  908. *
  909. * These flags are used with the ampdu_action() callback in
  910. * &struct ieee80211_ops to indicate which action is needed.
  911. * @IEEE80211_AMPDU_RX_START: start Rx aggregation
  912. * @IEEE80211_AMPDU_RX_STOP: stop Rx aggregation
  913. * @IEEE80211_AMPDU_TX_START: start Tx aggregation
  914. * @IEEE80211_AMPDU_TX_STOP: stop Tx aggregation
  915. */
  916. enum ieee80211_ampdu_mlme_action {
  917. IEEE80211_AMPDU_RX_START,
  918. IEEE80211_AMPDU_RX_STOP,
  919. IEEE80211_AMPDU_TX_START,
  920. IEEE80211_AMPDU_TX_STOP,
  921. };
  922. /**
  923. * struct ieee80211_ops - callbacks from mac80211 to the driver
  924. *
  925. * This structure contains various callbacks that the driver may
  926. * handle or, in some cases, must handle, for example to configure
  927. * the hardware to a new channel or to transmit a frame.
  928. *
  929. * @tx: Handler that 802.11 module calls for each transmitted frame.
  930. * skb contains the buffer starting from the IEEE 802.11 header.
  931. * The low-level driver should send the frame out based on
  932. * configuration in the TX control data. Must be implemented and
  933. * atomic.
  934. *
  935. * @start: Called before the first netdevice attached to the hardware
  936. * is enabled. This should turn on the hardware and must turn on
  937. * frame reception (for possibly enabled monitor interfaces.)
  938. * Returns negative error codes, these may be seen in userspace,
  939. * or zero.
  940. * When the device is started it should not have a MAC address
  941. * to avoid acknowledging frames before a non-monitor device
  942. * is added.
  943. * Must be implemented.
  944. *
  945. * @stop: Called after last netdevice attached to the hardware
  946. * is disabled. This should turn off the hardware (at least
  947. * it must turn off frame reception.)
  948. * May be called right after add_interface if that rejects
  949. * an interface.
  950. * Must be implemented.
  951. *
  952. * @add_interface: Called when a netdevice attached to the hardware is
  953. * enabled. Because it is not called for monitor mode devices, @open
  954. * and @stop must be implemented.
  955. * The driver should perform any initialization it needs before
  956. * the device can be enabled. The initial configuration for the
  957. * interface is given in the conf parameter.
  958. * The callback may refuse to add an interface by returning a
  959. * negative error code (which will be seen in userspace.)
  960. * Must be implemented.
  961. *
  962. * @remove_interface: Notifies a driver that an interface is going down.
  963. * The @stop callback is called after this if it is the last interface
  964. * and no monitor interfaces are present.
  965. * When all interfaces are removed, the MAC address in the hardware
  966. * must be cleared so the device no longer acknowledges packets,
  967. * the mac_addr member of the conf structure is, however, set to the
  968. * MAC address of the device going away.
  969. * Hence, this callback must be implemented.
  970. *
  971. * @config: Handler for configuration requests. IEEE 802.11 code calls this
  972. * function to change hardware configuration, e.g., channel.
  973. *
  974. * @config_interface: Handler for configuration requests related to interfaces
  975. * (e.g. BSSID changes.)
  976. *
  977. * @bss_info_changed: Handler for configuration requests related to BSS
  978. * parameters that may vary during BSS's lifespan, and may affect low
  979. * level driver (e.g. assoc/disassoc status, erp parameters).
  980. * This function should not be used if no BSS has been set, unless
  981. * for association indication. The @changed parameter indicates which
  982. * of the bss parameters has changed when a call is made.
  983. *
  984. * @configure_filter: Configure the device's RX filter.
  985. * See the section "Frame filtering" for more information.
  986. * This callback must be implemented and atomic.
  987. *
  988. * @set_tim: Set TIM bit. If the hardware/firmware takes care of beacon
  989. * generation (that is, %IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE is set)
  990. * mac80211 calls this function when a TIM bit must be set or cleared
  991. * for a given AID. Must be atomic.
  992. *
  993. * @set_key: See the section "Hardware crypto acceleration"
  994. * This callback can sleep, and is only called between add_interface
  995. * and remove_interface calls, i.e. while the interface with the
  996. * given local_address is enabled.
  997. *
  998. * @update_tkip_key: See the section "Hardware crypto acceleration"
  999. * This callback will be called in the context of Rx. Called for drivers
  1000. * which set IEEE80211_KEY_FLAG_TKIP_REQ_RX_P1_KEY.
  1001. *
  1002. * @hw_scan: Ask the hardware to service the scan request, no need to start
  1003. * the scan state machine in stack. The scan must honour the channel
  1004. * configuration done by the regulatory agent in the wiphy's registered
  1005. * bands.
  1006. *
  1007. * @get_stats: return low-level statistics
  1008. *
  1009. * @get_tkip_seq: If your device implements TKIP encryption in hardware this
  1010. * callback should be provided to read the TKIP transmit IVs (both IV32
  1011. * and IV16) for the given key from hardware.
  1012. *
  1013. * @set_rts_threshold: Configuration of RTS threshold (if device needs it)
  1014. *
  1015. * @set_frag_threshold: Configuration of fragmentation threshold. Assign this if
  1016. * the device does fragmentation by itself; if this method is assigned then
  1017. * the stack will not do fragmentation.
  1018. *
  1019. * @set_retry_limit: Configuration of retry limits (if device needs it)
  1020. *
  1021. * @sta_notify: Notifies low level driver about addition or removal
  1022. * of assocaited station or AP.
  1023. *
  1024. * @conf_tx: Configure TX queue parameters (EDCF (aifs, cw_min, cw_max),
  1025. * bursting) for a hardware TX queue. Must be atomic.
  1026. *
  1027. * @get_tx_stats: Get statistics of the current TX queue status. This is used
  1028. * to get number of currently queued packets (queue length), maximum queue
  1029. * size (limit), and total number of packets sent using each TX queue
  1030. * (count). The 'stats' pointer points to an array that has hw->queues +
  1031. * hw->ampdu_queues items.
  1032. *
  1033. * @get_tsf: Get the current TSF timer value from firmware/hardware. Currently,
  1034. * this is only used for IBSS mode debugging and, as such, is not a
  1035. * required function. Must be atomic.
  1036. *
  1037. * @reset_tsf: Reset the TSF timer and allow firmware/hardware to synchronize
  1038. * with other STAs in the IBSS. This is only used in IBSS mode. This
  1039. * function is optional if the firmware/hardware takes full care of
  1040. * TSF synchronization.
  1041. *
  1042. * @beacon_update: Setup beacon data for IBSS beacons. Unlike access point,
  1043. * IBSS uses a fixed beacon frame which is configured using this
  1044. * function.
  1045. * If the driver returns success (0) from this callback, it owns
  1046. * the skb. That means the driver is responsible to kfree_skb() it.
  1047. * The control structure is not dynamically allocated. That means the
  1048. * driver does not own the pointer and if it needs it somewhere
  1049. * outside of the context of this function, it must copy it
  1050. * somewhere else.
  1051. * This handler is required only for IBSS mode.
  1052. *
  1053. * @tx_last_beacon: Determine whether the last IBSS beacon was sent by us.
  1054. * This is needed only for IBSS mode and the result of this function is
  1055. * used to determine whether to reply to Probe Requests.
  1056. *
  1057. * @conf_ht: Configures low level driver with 802.11n HT data. Must be atomic.
  1058. *
  1059. * @ampdu_action: Perform a certain A-MPDU action
  1060. * The RA/TID combination determines the destination and TID we want
  1061. * the ampdu action to be performed for. The action is defined through
  1062. * ieee80211_ampdu_mlme_action. Starting sequence number (@ssn)
  1063. * is the first frame we expect to perform the action on. notice
  1064. * that TX/RX_STOP can pass NULL for this parameter.
  1065. */
  1066. struct ieee80211_ops {
  1067. int (*tx)(struct ieee80211_hw *hw, struct sk_buff *skb,
  1068. struct ieee80211_tx_control *control);
  1069. int (*start)(struct ieee80211_hw *hw);
  1070. void (*stop)(struct ieee80211_hw *hw);
  1071. int (*add_interface)(struct ieee80211_hw *hw,
  1072. struct ieee80211_if_init_conf *conf);
  1073. void (*remove_interface)(struct ieee80211_hw *hw,
  1074. struct ieee80211_if_init_conf *conf);
  1075. int (*config)(struct ieee80211_hw *hw, struct ieee80211_conf *conf);
  1076. int (*config_interface)(struct ieee80211_hw *hw,
  1077. struct ieee80211_vif *vif,
  1078. struct ieee80211_if_conf *conf);
  1079. void (*bss_info_changed)(struct ieee80211_hw *hw,
  1080. struct ieee80211_vif *vif,
  1081. struct ieee80211_bss_conf *info,
  1082. u32 changed);
  1083. void (*configure_filter)(struct ieee80211_hw *hw,
  1084. unsigned int changed_flags,
  1085. unsigned int *total_flags,
  1086. int mc_count, struct dev_addr_list *mc_list);
  1087. int (*set_tim)(struct ieee80211_hw *hw, int aid, int set);
  1088. int (*set_key)(struct ieee80211_hw *hw, enum set_key_cmd cmd,
  1089. const u8 *local_address, const u8 *address,
  1090. struct ieee80211_key_conf *key);
  1091. void (*update_tkip_key)(struct ieee80211_hw *hw,
  1092. struct ieee80211_key_conf *conf, const u8 *address,
  1093. u32 iv32, u16 *phase1key);
  1094. int (*hw_scan)(struct ieee80211_hw *hw, u8 *ssid, size_t len);
  1095. int (*get_stats)(struct ieee80211_hw *hw,
  1096. struct ieee80211_low_level_stats *stats);
  1097. void (*get_tkip_seq)(struct ieee80211_hw *hw, u8 hw_key_idx,
  1098. u32 *iv32, u16 *iv16);
  1099. int (*set_rts_threshold)(struct ieee80211_hw *hw, u32 value);
  1100. int (*set_frag_threshold)(struct ieee80211_hw *hw, u32 value);
  1101. int (*set_retry_limit)(struct ieee80211_hw *hw,
  1102. u32 short_retry, u32 long_retr);
  1103. void (*sta_notify)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  1104. enum sta_notify_cmd, const u8 *addr);
  1105. int (*conf_tx)(struct ieee80211_hw *hw, u16 queue,
  1106. const struct ieee80211_tx_queue_params *params);
  1107. int (*get_tx_stats)(struct ieee80211_hw *hw,
  1108. struct ieee80211_tx_queue_stats *stats);
  1109. u64 (*get_tsf)(struct ieee80211_hw *hw);
  1110. void (*reset_tsf)(struct ieee80211_hw *hw);
  1111. int (*beacon_update)(struct ieee80211_hw *hw,
  1112. struct sk_buff *skb,
  1113. struct ieee80211_tx_control *control);
  1114. int (*tx_last_beacon)(struct ieee80211_hw *hw);
  1115. int (*ampdu_action)(struct ieee80211_hw *hw,
  1116. enum ieee80211_ampdu_mlme_action action,
  1117. const u8 *addr, u16 tid, u16 *ssn);
  1118. };
  1119. /**
  1120. * ieee80211_alloc_hw - Allocate a new hardware device
  1121. *
  1122. * This must be called once for each hardware device. The returned pointer
  1123. * must be used to refer to this device when calling other functions.
  1124. * mac80211 allocates a private data area for the driver pointed to by
  1125. * @priv in &struct ieee80211_hw, the size of this area is given as
  1126. * @priv_data_len.
  1127. *
  1128. * @priv_data_len: length of private data
  1129. * @ops: callbacks for this device
  1130. */
  1131. struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
  1132. const struct ieee80211_ops *ops);
  1133. /**
  1134. * ieee80211_register_hw - Register hardware device
  1135. *
  1136. * You must call this function before any other functions in
  1137. * mac80211. Note that before a hardware can be registered, you
  1138. * need to fill the contained wiphy's information.
  1139. *
  1140. * @hw: the device to register as returned by ieee80211_alloc_hw()
  1141. */
  1142. int ieee80211_register_hw(struct ieee80211_hw *hw);
  1143. #ifdef CONFIG_MAC80211_LEDS
  1144. extern char *__ieee80211_get_tx_led_name(struct ieee80211_hw *hw);
  1145. extern char *__ieee80211_get_rx_led_name(struct ieee80211_hw *hw);
  1146. extern char *__ieee80211_get_assoc_led_name(struct ieee80211_hw *hw);
  1147. extern char *__ieee80211_get_radio_led_name(struct ieee80211_hw *hw);
  1148. #endif
  1149. /**
  1150. * ieee80211_get_tx_led_name - get name of TX LED
  1151. *
  1152. * mac80211 creates a transmit LED trigger for each wireless hardware
  1153. * that can be used to drive LEDs if your driver registers a LED device.
  1154. * This function returns the name (or %NULL if not configured for LEDs)
  1155. * of the trigger so you can automatically link the LED device.
  1156. *
  1157. * @hw: the hardware to get the LED trigger name for
  1158. */
  1159. static inline char *ieee80211_get_tx_led_name(struct ieee80211_hw *hw)
  1160. {
  1161. #ifdef CONFIG_MAC80211_LEDS
  1162. return __ieee80211_get_tx_led_name(hw);
  1163. #else
  1164. return NULL;
  1165. #endif
  1166. }
  1167. /**
  1168. * ieee80211_get_rx_led_name - get name of RX LED
  1169. *
  1170. * mac80211 creates a receive LED trigger for each wireless hardware
  1171. * that can be used to drive LEDs if your driver registers a LED device.
  1172. * This function returns the name (or %NULL if not configured for LEDs)
  1173. * of the trigger so you can automatically link the LED device.
  1174. *
  1175. * @hw: the hardware to get the LED trigger name for
  1176. */
  1177. static inline char *ieee80211_get_rx_led_name(struct ieee80211_hw *hw)
  1178. {
  1179. #ifdef CONFIG_MAC80211_LEDS
  1180. return __ieee80211_get_rx_led_name(hw);
  1181. #else
  1182. return NULL;
  1183. #endif
  1184. }
  1185. /**
  1186. * ieee80211_get_assoc_led_name - get name of association LED
  1187. *
  1188. * mac80211 creates a association LED trigger for each wireless hardware
  1189. * that can be used to drive LEDs if your driver registers a LED device.
  1190. * This function returns the name (or %NULL if not configured for LEDs)
  1191. * of the trigger so you can automatically link the LED device.
  1192. *
  1193. * @hw: the hardware to get the LED trigger name for
  1194. */
  1195. static inline char *ieee80211_get_assoc_led_name(struct ieee80211_hw *hw)
  1196. {
  1197. #ifdef CONFIG_MAC80211_LEDS
  1198. return __ieee80211_get_assoc_led_name(hw);
  1199. #else
  1200. return NULL;
  1201. #endif
  1202. }
  1203. /**
  1204. * ieee80211_get_radio_led_name - get name of radio LED
  1205. *
  1206. * mac80211 creates a radio change LED trigger for each wireless hardware
  1207. * that can be used to drive LEDs if your driver registers a LED device.
  1208. * This function returns the name (or %NULL if not configured for LEDs)
  1209. * of the trigger so you can automatically link the LED device.
  1210. *
  1211. * @hw: the hardware to get the LED trigger name for
  1212. */
  1213. static inline char *ieee80211_get_radio_led_name(struct ieee80211_hw *hw)
  1214. {
  1215. #ifdef CONFIG_MAC80211_LEDS
  1216. return __ieee80211_get_radio_led_name(hw);
  1217. #else
  1218. return NULL;
  1219. #endif
  1220. }
  1221. /**
  1222. * ieee80211_unregister_hw - Unregister a hardware device
  1223. *
  1224. * This function instructs mac80211 to free allocated resources
  1225. * and unregister netdevices from the networking subsystem.
  1226. *
  1227. * @hw: the hardware to unregister
  1228. */
  1229. void ieee80211_unregister_hw(struct ieee80211_hw *hw);
  1230. /**
  1231. * ieee80211_free_hw - free hardware descriptor
  1232. *
  1233. * This function frees everything that was allocated, including the
  1234. * private data for the driver. You must call ieee80211_unregister_hw()
  1235. * before calling this function
  1236. *
  1237. * @hw: the hardware to free
  1238. */
  1239. void ieee80211_free_hw(struct ieee80211_hw *hw);
  1240. /* trick to avoid symbol clashes with the ieee80211 subsystem */
  1241. void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb,
  1242. struct ieee80211_rx_status *status);
  1243. /**
  1244. * ieee80211_rx - receive frame
  1245. *
  1246. * Use this function to hand received frames to mac80211. The receive
  1247. * buffer in @skb must start with an IEEE 802.11 header or a radiotap
  1248. * header if %RX_FLAG_RADIOTAP is set in the @status flags.
  1249. *
  1250. * This function may not be called in IRQ context. Calls to this function
  1251. * for a single hardware must be synchronized against each other. Calls
  1252. * to this function and ieee80211_rx_irqsafe() may not be mixed for a
  1253. * single hardware.
  1254. *
  1255. * @hw: the hardware this frame came in on
  1256. * @skb: the buffer to receive, owned by mac80211 after this call
  1257. * @status: status of this frame; the status pointer need not be valid
  1258. * after this function returns
  1259. */
  1260. static inline void ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb,
  1261. struct ieee80211_rx_status *status)
  1262. {
  1263. __ieee80211_rx(hw, skb, status);
  1264. }
  1265. /**
  1266. * ieee80211_rx_irqsafe - receive frame
  1267. *
  1268. * Like ieee80211_rx() but can be called in IRQ context
  1269. * (internally defers to a tasklet.)
  1270. *
  1271. * Calls to this function and ieee80211_rx() may not be mixed for a
  1272. * single hardware.
  1273. *
  1274. * @hw: the hardware this frame came in on
  1275. * @skb: the buffer to receive, owned by mac80211 after this call
  1276. * @status: status of this frame; the status pointer need not be valid
  1277. * after this function returns and is not freed by mac80211,
  1278. * it is recommended that it points to a stack area
  1279. */
  1280. void ieee80211_rx_irqsafe(struct ieee80211_hw *hw,
  1281. struct sk_buff *skb,
  1282. struct ieee80211_rx_status *status);
  1283. /**
  1284. * ieee80211_tx_status - transmit status callback
  1285. *
  1286. * Call this function for all transmitted frames after they have been
  1287. * transmitted. It is permissible to not call this function for
  1288. * multicast frames but this can affect statistics.
  1289. *
  1290. * This function may not be called in IRQ context. Calls to this function
  1291. * for a single hardware must be synchronized against each other. Calls
  1292. * to this function and ieee80211_tx_status_irqsafe() may not be mixed
  1293. * for a single hardware.
  1294. *
  1295. * @hw: the hardware the frame was transmitted by
  1296. * @skb: the frame that was transmitted, owned by mac80211 after this call
  1297. * @status: status information for this frame; the status pointer need not
  1298. * be valid after this function returns and is not freed by mac80211,
  1299. * it is recommended that it points to a stack area
  1300. */
  1301. void ieee80211_tx_status(struct ieee80211_hw *hw,
  1302. struct sk_buff *skb,
  1303. struct ieee80211_tx_status *status);
  1304. /**
  1305. * ieee80211_tx_status_irqsafe - irq-safe transmit status callback
  1306. *
  1307. * Like ieee80211_tx_status() but can be called in IRQ context
  1308. * (internally defers to a tasklet.)
  1309. *
  1310. * Calls to this function and ieee80211_tx_status() may not be mixed for a
  1311. * single hardware.
  1312. *
  1313. * @hw: the hardware the frame was transmitted by
  1314. * @skb: the frame that was transmitted, owned by mac80211 after this call
  1315. * @status: status information for this frame; the status pointer need not
  1316. * be valid after this function returns and is not freed by mac80211,
  1317. * it is recommended that it points to a stack area
  1318. */
  1319. void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw,
  1320. struct sk_buff *skb,
  1321. struct ieee80211_tx_status *status);
  1322. /**
  1323. * ieee80211_beacon_get - beacon generation function
  1324. * @hw: pointer obtained from ieee80211_alloc_hw().
  1325. * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf.
  1326. * @control: will be filled with information needed to send this beacon.
  1327. *
  1328. * If the beacon frames are generated by the host system (i.e., not in
  1329. * hardware/firmware), the low-level driver uses this function to receive
  1330. * the next beacon frame from the 802.11 code. The low-level is responsible
  1331. * for calling this function before beacon data is needed (e.g., based on
  1332. * hardware interrupt). Returned skb is used only once and low-level driver
  1333. * is responsible of freeing it.
  1334. */
  1335. struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
  1336. struct ieee80211_vif *vif,
  1337. struct ieee80211_tx_control *control);
  1338. /**
  1339. * ieee80211_rts_get - RTS frame generation function
  1340. * @hw: pointer obtained from ieee80211_alloc_hw().
  1341. * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf.
  1342. * @frame: pointer to the frame that is going to be protected by the RTS.
  1343. * @frame_len: the frame length (in octets).
  1344. * @frame_txctl: &struct ieee80211_tx_control of the frame.
  1345. * @rts: The buffer where to store the RTS frame.
  1346. *
  1347. * If the RTS frames are generated by the host system (i.e., not in
  1348. * hardware/firmware), the low-level driver uses this function to receive
  1349. * the next RTS frame from the 802.11 code. The low-level is responsible
  1350. * for calling this function before and RTS frame is needed.
  1351. */
  1352. void ieee80211_rts_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  1353. const void *frame, size_t frame_len,
  1354. const struct ieee80211_tx_control *frame_txctl,
  1355. struct ieee80211_rts *rts);
  1356. /**
  1357. * ieee80211_rts_duration - Get the duration field for an RTS frame
  1358. * @hw: pointer obtained from ieee80211_alloc_hw().
  1359. * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf.
  1360. * @frame_len: the length of the frame that is going to be protected by the RTS.
  1361. * @frame_txctl: &struct ieee80211_tx_control of the frame.
  1362. *
  1363. * If the RTS is generated in firmware, but the host system must provide
  1364. * the duration field, the low-level driver uses this function to receive
  1365. * the duration field value in little-endian byteorder.
  1366. */
  1367. __le16 ieee80211_rts_duration(struct ieee80211_hw *hw,
  1368. struct ieee80211_vif *vif, size_t frame_len,
  1369. const struct ieee80211_tx_control *frame_txctl);
  1370. /**
  1371. * ieee80211_ctstoself_get - CTS-to-self frame generation function
  1372. * @hw: pointer obtained from ieee80211_alloc_hw().
  1373. * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf.
  1374. * @frame: pointer to the frame that is going to be protected by the CTS-to-self.
  1375. * @frame_len: the frame length (in octets).
  1376. * @frame_txctl: &struct ieee80211_tx_control of the frame.
  1377. * @cts: The buffer where to store the CTS-to-self frame.
  1378. *
  1379. * If the CTS-to-self frames are generated by the host system (i.e., not in
  1380. * hardware/firmware), the low-level driver uses this function to receive
  1381. * the next CTS-to-self frame from the 802.11 code. The low-level is responsible
  1382. * for calling this function before and CTS-to-self frame is needed.
  1383. */
  1384. void ieee80211_ctstoself_get(struct ieee80211_hw *hw,
  1385. struct ieee80211_vif *vif,
  1386. const void *frame, size_t frame_len,
  1387. const struct ieee80211_tx_control *frame_txctl,
  1388. struct ieee80211_cts *cts);
  1389. /**
  1390. * ieee80211_ctstoself_duration - Get the duration field for a CTS-to-self frame
  1391. * @hw: pointer obtained from ieee80211_alloc_hw().
  1392. * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf.
  1393. * @frame_len: the length of the frame that is going to be protected by the CTS-to-self.
  1394. * @frame_txctl: &struct ieee80211_tx_control of the frame.
  1395. *
  1396. * If the CTS-to-self is generated in firmware, but the host system must provide
  1397. * the duration field, the low-level driver uses this function to receive
  1398. * the duration field value in little-endian byteorder.
  1399. */
  1400. __le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw,
  1401. struct ieee80211_vif *vif,
  1402. size_t frame_len,
  1403. const struct ieee80211_tx_control *frame_txctl);
  1404. /**
  1405. * ieee80211_generic_frame_duration - Calculate the duration field for a frame
  1406. * @hw: pointer obtained from ieee80211_alloc_hw().
  1407. * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf.
  1408. * @frame_len: the length of the frame.
  1409. * @rate: the rate at which the frame is going to be transmitted.
  1410. *
  1411. * Calculate the duration field of some generic frame, given its
  1412. * length and transmission rate (in 100kbps).
  1413. */
  1414. __le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw,
  1415. struct ieee80211_vif *vif,
  1416. size_t frame_len,
  1417. struct ieee80211_rate *rate);
  1418. /**
  1419. * ieee80211_get_buffered_bc - accessing buffered broadcast and multicast frames
  1420. * @hw: pointer as obtained from ieee80211_alloc_hw().
  1421. * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf.
  1422. * @control: will be filled with information needed to send returned frame.
  1423. *
  1424. * Function for accessing buffered broadcast and multicast frames. If
  1425. * hardware/firmware does not implement buffering of broadcast/multicast
  1426. * frames when power saving is used, 802.11 code buffers them in the host
  1427. * memory. The low-level driver uses this function to fetch next buffered
  1428. * frame. In most cases, this is used when generating beacon frame. This
  1429. * function returns a pointer to the next buffered skb or NULL if no more
  1430. * buffered frames are available.
  1431. *
  1432. * Note: buffered frames are returned only after DTIM beacon frame was
  1433. * generated with ieee80211_beacon_get() and the low-level driver must thus
  1434. * call ieee80211_beacon_get() first. ieee80211_get_buffered_bc() returns
  1435. * NULL if the previous generated beacon was not DTIM, so the low-level driver
  1436. * does not need to check for DTIM beacons separately and should be able to
  1437. * use common code for all beacons.
  1438. */
  1439. struct sk_buff *
  1440. ieee80211_get_buffered_bc(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  1441. struct ieee80211_tx_control *control);
  1442. /**
  1443. * ieee80211_get_hdrlen_from_skb - get header length from data
  1444. *
  1445. * Given an skb with a raw 802.11 header at the data pointer this function
  1446. * returns the 802.11 header length in bytes (not including encryption
  1447. * headers). If the data in the sk_buff is too short to contain a valid 802.11
  1448. * header the function returns 0.
  1449. *
  1450. * @skb: the frame
  1451. */
  1452. int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb);
  1453. /**
  1454. * ieee80211_get_hdrlen - get header length from frame control
  1455. *
  1456. * This function returns the 802.11 header length in bytes (not including
  1457. * encryption headers.)
  1458. *
  1459. * @fc: the frame control field (in CPU endianness)
  1460. */
  1461. int ieee80211_get_hdrlen(u16 fc);
  1462. /**
  1463. * ieee80211_get_tkip_key - get a TKIP rc4 for skb
  1464. *
  1465. * This function computes a TKIP rc4 key for an skb. It computes
  1466. * a phase 1 key if needed (iv16 wraps around). This function is to
  1467. * be used by drivers which can do HW encryption but need to compute
  1468. * to phase 1/2 key in SW.
  1469. *
  1470. * @keyconf: the parameter passed with the set key
  1471. * @skb: the skb for which the key is needed
  1472. * @rc4key: a buffer to which the key will be written
  1473. */
  1474. void ieee80211_get_tkip_key(struct ieee80211_key_conf *keyconf,
  1475. struct sk_buff *skb,
  1476. enum ieee80211_tkip_key_type type, u8 *key);
  1477. /**
  1478. * ieee80211_wake_queue - wake specific queue
  1479. * @hw: pointer as obtained from ieee80211_alloc_hw().
  1480. * @queue: queue number (counted from zero).
  1481. *
  1482. * Drivers should use this function instead of netif_wake_queue.
  1483. */
  1484. void ieee80211_wake_queue(struct ieee80211_hw *hw, int queue);
  1485. /**
  1486. * ieee80211_stop_queue - stop specific queue
  1487. * @hw: pointer as obtained from ieee80211_alloc_hw().
  1488. * @queue: queue number (counted from zero).
  1489. *
  1490. * Drivers should use this function instead of netif_stop_queue.
  1491. */
  1492. void ieee80211_stop_queue(struct ieee80211_hw *hw, int queue);
  1493. /**
  1494. * ieee80211_stop_queues - stop all queues
  1495. * @hw: pointer as obtained from ieee80211_alloc_hw().
  1496. *
  1497. * Drivers should use this function instead of netif_stop_queue.
  1498. */
  1499. void ieee80211_stop_queues(struct ieee80211_hw *hw);
  1500. /**
  1501. * ieee80211_wake_queues - wake all queues
  1502. * @hw: pointer as obtained from ieee80211_alloc_hw().
  1503. *
  1504. * Drivers should use this function instead of netif_wake_queue.
  1505. */
  1506. void ieee80211_wake_queues(struct ieee80211_hw *hw);
  1507. /**
  1508. * ieee80211_scan_completed - completed hardware scan
  1509. *
  1510. * When hardware scan offload is used (i.e. the hw_scan() callback is
  1511. * assigned) this function needs to be called by the driver to notify
  1512. * mac80211 that the scan finished.
  1513. *
  1514. * @hw: the hardware that finished the scan
  1515. */
  1516. void ieee80211_scan_completed(struct ieee80211_hw *hw);
  1517. /**
  1518. * ieee80211_iterate_active_interfaces - iterate active interfaces
  1519. *
  1520. * This function iterates over the interfaces associated with a given
  1521. * hardware that are currently active and calls the callback for them.
  1522. *
  1523. * @hw: the hardware struct of which the interfaces should be iterated over
  1524. * @iterator: the iterator function to call, cannot sleep
  1525. * @data: first argument of the iterator function
  1526. */
  1527. void ieee80211_iterate_active_interfaces(struct ieee80211_hw *hw,
  1528. void (*iterator)(void *data, u8 *mac,
  1529. struct ieee80211_vif *vif),
  1530. void *data);
  1531. /**
  1532. * ieee80211_start_tx_ba_session - Start a tx Block Ack session.
  1533. * @hw: pointer as obtained from ieee80211_alloc_hw().
  1534. * @ra: receiver address of the BA session recipient
  1535. * @tid: the TID to BA on.
  1536. * @return: success if addBA request was sent, failure otherwise
  1537. *
  1538. * Although mac80211/low level driver/user space application can estimate
  1539. * the need to start aggregation on a certain RA/TID, the session level
  1540. * will be managed by the mac80211.
  1541. */
  1542. int ieee80211_start_tx_ba_session(struct ieee80211_hw *hw, u8 *ra, u16 tid);
  1543. /**
  1544. * ieee80211_start_tx_ba_cb - low level driver ready to aggregate.
  1545. * @hw: pointer as obtained from ieee80211_alloc_hw().
  1546. * @ra: receiver address of the BA session recipient.
  1547. * @tid: the TID to BA on.
  1548. *
  1549. * This function must be called by low level driver once it has
  1550. * finished with preparations for the BA session.
  1551. */
  1552. void ieee80211_start_tx_ba_cb(struct ieee80211_hw *hw, u8 *ra, u16 tid);
  1553. /**
  1554. * ieee80211_start_tx_ba_cb_irqsafe - low level driver ready to aggregate.
  1555. * @hw: pointer as obtained from ieee80211_alloc_hw().
  1556. * @ra: receiver address of the BA session recipient.
  1557. * @tid: the TID to BA on.
  1558. *
  1559. * This function must be called by low level driver once it has
  1560. * finished with preparations for the BA session.
  1561. * This version of the function is irq safe.
  1562. */
  1563. void ieee80211_start_tx_ba_cb_irqsafe(struct ieee80211_hw *hw, const u8 *ra,
  1564. u16 tid);
  1565. /**
  1566. * ieee80211_stop_tx_ba_session - Stop a Block Ack session.
  1567. * @hw: pointer as obtained from ieee80211_alloc_hw().
  1568. * @ra: receiver address of the BA session recipient
  1569. * @tid: the TID to stop BA.
  1570. * @initiator: if indicates initiator DELBA frame will be sent.
  1571. * @return: error if no sta with matching da found, success otherwise
  1572. *
  1573. * Although mac80211/low level driver/user space application can estimate
  1574. * the need to stop aggregation on a certain RA/TID, the session level
  1575. * will be managed by the mac80211.
  1576. */
  1577. int ieee80211_stop_tx_ba_session(struct ieee80211_hw *hw,
  1578. u8 *ra, u16 tid,
  1579. enum ieee80211_back_parties initiator);
  1580. /**
  1581. * ieee80211_stop_tx_ba_cb - low level driver ready to stop aggregate.
  1582. * @hw: pointer as obtained from ieee80211_alloc_hw().
  1583. * @ra: receiver address of the BA session recipient.
  1584. * @tid: the desired TID to BA on.
  1585. *
  1586. * This function must be called by low level driver once it has
  1587. * finished with preparations for the BA session tear down.
  1588. */
  1589. void ieee80211_stop_tx_ba_cb(struct ieee80211_hw *hw, u8 *ra, u8 tid);
  1590. /**
  1591. * ieee80211_stop_tx_ba_cb_irqsafe - low level driver ready to stop aggregate.
  1592. * @hw: pointer as obtained from ieee80211_alloc_hw().
  1593. * @ra: receiver address of the BA session recipient.
  1594. * @tid: the desired TID to BA on.
  1595. *
  1596. * This function must be called by low level driver once it has
  1597. * finished with preparations for the BA session tear down.
  1598. * This version of the function is irq safe.
  1599. */
  1600. void ieee80211_stop_tx_ba_cb_irqsafe(struct ieee80211_hw *hw, const u8 *ra,
  1601. u16 tid);
  1602. /**
  1603. * ieee80211_notify_mac - low level driver notification
  1604. * @hw: pointer as obtained from ieee80211_alloc_hw().
  1605. * @notification_types: enum ieee80211_notification_types
  1606. *
  1607. * This function must be called by low level driver to inform mac80211 of
  1608. * low level driver status change or force mac80211 to re-assoc for low
  1609. * level driver internal error that require re-assoc.
  1610. */
  1611. void ieee80211_notify_mac(struct ieee80211_hw *hw,
  1612. enum ieee80211_notification_types notif_type);
  1613. #endif /* MAC80211_H */