mac80211.h 64 KB

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