mac80211.h 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250
  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. /* Note! Only ieee80211_tx_status_irqsafe() and ieee80211_rx_irqsafe() can be
  23. * called in hardware interrupt context. The low-level driver must not call any
  24. * other functions in hardware interrupt context. If there is a need for such
  25. * call, the low-level driver should first ACK the interrupt and perform the
  26. * IEEE 802.11 code call after this, e.g., from a scheduled tasklet (in
  27. * software interrupt context).
  28. */
  29. /*
  30. * Frame format used when passing frame between low-level hardware drivers
  31. * and IEEE 802.11 driver the same as used in the wireless media, i.e.,
  32. * buffers start with IEEE 802.11 header and include the same octets that
  33. * are sent over air.
  34. *
  35. * If hardware uses IEEE 802.3 headers (and perform 802.3 <-> 802.11
  36. * conversion in firmware), upper layer 802.11 code needs to be changed to
  37. * support this.
  38. *
  39. * If the receive frame format is not the same as the real frame sent
  40. * on the wireless media (e.g., due to padding etc.), upper layer 802.11 code
  41. * could be updated to provide support for such format assuming this would
  42. * optimize the performance, e.g., by removing need to re-allocation and
  43. * copying of the data.
  44. */
  45. #define IEEE80211_CHAN_W_SCAN 0x00000001
  46. #define IEEE80211_CHAN_W_ACTIVE_SCAN 0x00000002
  47. #define IEEE80211_CHAN_W_IBSS 0x00000004
  48. /* Channel information structure. Low-level driver is expected to fill in chan,
  49. * freq, and val fields. Other fields will be filled in by 80211.o based on
  50. * hostapd information and low-level driver does not need to use them. The
  51. * limits for each channel will be provided in 'struct ieee80211_conf' when
  52. * configuring the low-level driver with hw->config callback. If a device has
  53. * a default regulatory domain, IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED
  54. * can be set to let the driver configure all fields */
  55. struct ieee80211_channel {
  56. short chan; /* channel number (IEEE 802.11) */
  57. short freq; /* frequency in MHz */
  58. int val; /* hw specific value for the channel */
  59. int flag; /* flag for hostapd use (IEEE80211_CHAN_*) */
  60. unsigned char power_level;
  61. unsigned char antenna_max;
  62. };
  63. #define IEEE80211_RATE_ERP 0x00000001
  64. #define IEEE80211_RATE_BASIC 0x00000002
  65. #define IEEE80211_RATE_PREAMBLE2 0x00000004
  66. #define IEEE80211_RATE_SUPPORTED 0x00000010
  67. #define IEEE80211_RATE_OFDM 0x00000020
  68. #define IEEE80211_RATE_CCK 0x00000040
  69. #define IEEE80211_RATE_MANDATORY 0x00000100
  70. #define IEEE80211_RATE_CCK_2 (IEEE80211_RATE_CCK | IEEE80211_RATE_PREAMBLE2)
  71. #define IEEE80211_RATE_MODULATION(f) \
  72. (f & (IEEE80211_RATE_CCK | IEEE80211_RATE_OFDM))
  73. /* Low-level driver should set PREAMBLE2, OFDM and CCK flags.
  74. * BASIC, SUPPORTED, ERP, and MANDATORY flags are set in 80211.o based on the
  75. * configuration. */
  76. struct ieee80211_rate {
  77. int rate; /* rate in 100 kbps */
  78. int val; /* hw specific value for the rate */
  79. int flags; /* IEEE80211_RATE_ flags */
  80. int val2; /* hw specific value for the rate when using short preamble
  81. * (only when IEEE80211_RATE_PREAMBLE2 flag is set, i.e., for
  82. * 2, 5.5, and 11 Mbps) */
  83. signed char min_rssi_ack;
  84. unsigned char min_rssi_ack_delta;
  85. /* following fields are set by 80211.o and need not be filled by the
  86. * low-level driver */
  87. int rate_inv; /* inverse of the rate (LCM(all rates) / rate) for
  88. * optimizing channel utilization estimates */
  89. };
  90. /**
  91. * enum ieee80211_phymode - PHY modes
  92. *
  93. * @MODE_IEEE80211A: 5GHz as defined by 802.11a/802.11h
  94. * @MODE_IEEE80211B: 2.4 GHz as defined by 802.11b
  95. * @MODE_IEEE80211G: 2.4 GHz as defined by 802.11g (with OFDM),
  96. * backwards compatible with 11b mode
  97. * @NUM_IEEE80211_MODES: internal
  98. */
  99. enum ieee80211_phymode {
  100. MODE_IEEE80211A,
  101. MODE_IEEE80211B,
  102. MODE_IEEE80211G,
  103. /* keep last */
  104. NUM_IEEE80211_MODES
  105. };
  106. /**
  107. * struct ieee80211_hw_mode - PHY mode definition
  108. *
  109. * This structure describes the capabilities supported by the device
  110. * in a single PHY mode.
  111. *
  112. * @mode: the PHY mode for this definition
  113. * @num_channels: number of supported channels
  114. * @channels: pointer to array of supported channels
  115. * @num_rates: number of supported bitrates
  116. * @rates: pointer to array of supported bitrates
  117. * @list: internal
  118. */
  119. struct ieee80211_hw_mode {
  120. struct list_head list;
  121. struct ieee80211_channel *channels;
  122. struct ieee80211_rate *rates;
  123. enum ieee80211_phymode mode;
  124. int num_channels;
  125. int num_rates;
  126. };
  127. /**
  128. * struct ieee80211_tx_queue_params - transmit queue configuration
  129. *
  130. * The information provided in this structure is required for QoS
  131. * transmit queue configuration.
  132. *
  133. * @aifs: arbitration interface space [0..255, -1: use default]
  134. * @cw_min: minimum contention window [will be a value of the form
  135. * 2^n-1 in the range 1..1023; 0: use default]
  136. * @cw_max: maximum contention window [like @cw_min]
  137. * @burst_time: maximum burst time in units of 0.1ms, 0 meaning disabled
  138. */
  139. struct ieee80211_tx_queue_params {
  140. int aifs;
  141. int cw_min;
  142. int cw_max;
  143. int burst_time;
  144. };
  145. /**
  146. * struct ieee80211_tx_queue_stats_data - transmit queue statistics
  147. *
  148. * @len: number of packets in queue
  149. * @limit: queue length limit
  150. * @count: number of frames sent
  151. */
  152. struct ieee80211_tx_queue_stats_data {
  153. unsigned int len;
  154. unsigned int limit;
  155. unsigned int count;
  156. };
  157. /**
  158. * enum ieee80211_tx_queue - transmit queue number
  159. *
  160. * These constants are used with some callbacks that take a
  161. * queue number to set parameters for a queue.
  162. *
  163. * @IEEE80211_TX_QUEUE_DATA0: data queue 0
  164. * @IEEE80211_TX_QUEUE_DATA1: data queue 1
  165. * @IEEE80211_TX_QUEUE_DATA2: data queue 2
  166. * @IEEE80211_TX_QUEUE_DATA3: data queue 3
  167. * @IEEE80211_TX_QUEUE_DATA4: data queue 4
  168. * @IEEE80211_TX_QUEUE_SVP: ??
  169. * @NUM_TX_DATA_QUEUES: number of data queues
  170. * @IEEE80211_TX_QUEUE_AFTER_BEACON: transmit queue for frames to be
  171. * sent after a beacon
  172. * @IEEE80211_TX_QUEUE_BEACON: transmit queue for beacon frames
  173. */
  174. enum ieee80211_tx_queue {
  175. IEEE80211_TX_QUEUE_DATA0,
  176. IEEE80211_TX_QUEUE_DATA1,
  177. IEEE80211_TX_QUEUE_DATA2,
  178. IEEE80211_TX_QUEUE_DATA3,
  179. IEEE80211_TX_QUEUE_DATA4,
  180. IEEE80211_TX_QUEUE_SVP,
  181. NUM_TX_DATA_QUEUES,
  182. /* due to stupidity in the sub-ioctl userspace interface, the items in
  183. * this struct need to have fixed values. As soon as it is removed, we can
  184. * fix these entries. */
  185. IEEE80211_TX_QUEUE_AFTER_BEACON = 6,
  186. IEEE80211_TX_QUEUE_BEACON = 7
  187. };
  188. struct ieee80211_tx_queue_stats {
  189. struct ieee80211_tx_queue_stats_data data[NUM_TX_DATA_QUEUES];
  190. };
  191. struct ieee80211_low_level_stats {
  192. unsigned int dot11ACKFailureCount;
  193. unsigned int dot11RTSFailureCount;
  194. unsigned int dot11FCSErrorCount;
  195. unsigned int dot11RTSSuccessCount;
  196. };
  197. /* Transmit control fields. This data structure is passed to low-level driver
  198. * with each TX frame. The low-level driver is responsible for configuring
  199. * the hardware to use given values (depending on what is supported). */
  200. struct ieee80211_tx_control {
  201. int tx_rate; /* Transmit rate, given as the hw specific value for the
  202. * rate (from struct ieee80211_rate) */
  203. int rts_cts_rate; /* Transmit rate for RTS/CTS frame, given as the hw
  204. * specific value for the rate (from
  205. * struct ieee80211_rate) */
  206. #define IEEE80211_TXCTL_REQ_TX_STATUS (1<<0)/* request TX status callback for
  207. * this frame */
  208. #define IEEE80211_TXCTL_DO_NOT_ENCRYPT (1<<1) /* send this frame without
  209. * encryption; e.g., for EAPOL
  210. * frames */
  211. #define IEEE80211_TXCTL_USE_RTS_CTS (1<<2) /* use RTS-CTS before sending
  212. * frame */
  213. #define IEEE80211_TXCTL_USE_CTS_PROTECT (1<<3) /* use CTS protection for the
  214. * frame (e.g., for combined
  215. * 802.11g / 802.11b networks) */
  216. #define IEEE80211_TXCTL_NO_ACK (1<<4) /* tell the low level not to
  217. * wait for an ack */
  218. #define IEEE80211_TXCTL_RATE_CTRL_PROBE (1<<5)
  219. #define IEEE80211_TXCTL_CLEAR_DST_MASK (1<<6)
  220. #define IEEE80211_TXCTL_REQUEUE (1<<7)
  221. #define IEEE80211_TXCTL_FIRST_FRAGMENT (1<<8) /* this is a first fragment of
  222. * the frame */
  223. #define IEEE80211_TXCTL_LONG_RETRY_LIMIT (1<<10) /* this frame should be send
  224. * using the through
  225. * set_retry_limit configured
  226. * long retry value */
  227. u32 flags; /* tx control flags defined
  228. * above */
  229. u8 key_idx; /* keyidx from hw->set_key(), undefined if
  230. * IEEE80211_TXCTL_DO_NOT_ENCRYPT is set */
  231. u8 retry_limit; /* 1 = only first attempt, 2 = one retry, ..
  232. * This could be used when set_retry_limit
  233. * is not implemented by the driver */
  234. u8 power_level; /* per-packet transmit power level, in dBm */
  235. u8 antenna_sel_tx; /* 0 = default/diversity, 1 = Ant0, 2 = Ant1 */
  236. u8 icv_len; /* length of the ICV/MIC field in octets */
  237. u8 iv_len; /* length of the IV field in octets */
  238. u8 queue; /* hardware queue to use for this frame;
  239. * 0 = highest, hw->queues-1 = lowest */
  240. struct ieee80211_rate *rate; /* internal 80211.o rate */
  241. struct ieee80211_rate *rts_rate; /* internal 80211.o rate
  242. * for RTS/CTS */
  243. int alt_retry_rate; /* retry rate for the last retries, given as the
  244. * hw specific value for the rate (from
  245. * struct ieee80211_rate). To be used to limit
  246. * packet dropping when probing higher rates, if hw
  247. * supports multiple retry rates. -1 = not used */
  248. int type; /* internal */
  249. int ifindex; /* internal */
  250. };
  251. /**
  252. * enum mac80211_rx_flags - receive flags
  253. *
  254. * These flags are used with the @flag member of &struct ieee80211_rx_status.
  255. * @RX_FLAG_MMIC_ERROR: Michael MIC error was reported on this frame.
  256. * Use together with %RX_FLAG_MMIC_STRIPPED.
  257. * @RX_FLAG_DECRYPTED: This frame was decrypted in hardware.
  258. * @RX_FLAG_RADIOTAP: This frame starts with a radiotap header.
  259. * @RX_FLAG_MMIC_STRIPPED: the Michael MIC is stripped off this frame,
  260. * verification has been done by the hardware.
  261. * @RX_FLAG_IV_STRIPPED: The IV/ICV are stripped from this frame.
  262. * If this flag is set, the stack cannot do any replay detection
  263. * hence the driver or hardware will have to do that.
  264. * @RX_FLAG_FAILED_FCS_CRC: Set this flag if the FCS check failed on
  265. * the frame.
  266. * @RX_FLAG_FAILED_PLCP_CRC: Set this flag if the PCLP check failed on
  267. * the frame.
  268. */
  269. enum mac80211_rx_flags {
  270. RX_FLAG_MMIC_ERROR = 1<<0,
  271. RX_FLAG_DECRYPTED = 1<<1,
  272. RX_FLAG_RADIOTAP = 1<<2,
  273. RX_FLAG_MMIC_STRIPPED = 1<<3,
  274. RX_FLAG_IV_STRIPPED = 1<<4,
  275. RX_FLAG_FAILED_FCS_CRC = 1<<5,
  276. RX_FLAG_FAILED_PLCP_CRC = 1<<6,
  277. };
  278. /**
  279. * struct ieee80211_rx_status - receive status
  280. *
  281. * The low-level driver should provide this information (the subset
  282. * supported by hardware) to the 802.11 code with each received
  283. * frame.
  284. * @mactime: MAC timestamp as defined by 802.11
  285. * @freq: frequency the radio was tuned to when receiving this frame, in MHz
  286. * @channel: channel the radio was tuned to
  287. * @phymode: active PHY mode
  288. * @ssi: signal strength when receiving this frame
  289. * @signal: used as 'qual' in statistics reporting
  290. * @noise: PHY noise when receiving this frame
  291. * @antenna: antenna used
  292. * @rate: data rate
  293. * @flag: %RX_FLAG_*
  294. */
  295. struct ieee80211_rx_status {
  296. u64 mactime;
  297. int freq;
  298. int channel;
  299. enum ieee80211_phymode phymode;
  300. int ssi;
  301. int signal;
  302. int noise;
  303. int antenna;
  304. int rate;
  305. int flag;
  306. };
  307. /**
  308. * enum ieee80211_tx_status_flags - transmit status flags
  309. *
  310. * Status flags to indicate various transmit conditions.
  311. *
  312. * @IEEE80211_TX_STATUS_TX_FILTERED: The frame was not transmitted
  313. * because the destination STA was in powersave mode.
  314. *
  315. * @IEEE80211_TX_STATUS_ACK: Frame was acknowledged
  316. */
  317. enum ieee80211_tx_status_flags {
  318. IEEE80211_TX_STATUS_TX_FILTERED = 1<<0,
  319. IEEE80211_TX_STATUS_ACK = 1<<1,
  320. };
  321. /**
  322. * struct ieee80211_tx_status - transmit status
  323. *
  324. * As much information as possible should be provided for each transmitted
  325. * frame with ieee80211_tx_status().
  326. *
  327. * @control: a copy of the &struct ieee80211_tx_control passed to the driver
  328. * in the tx() callback.
  329. *
  330. * @flags: transmit status flags, defined above
  331. *
  332. * @ack_signal: signal strength of the ACK frame
  333. *
  334. * @excessive_retries: set to 1 if the frame was retried many times
  335. * but not acknowledged
  336. *
  337. * @retry_count: number of retries
  338. *
  339. * @queue_length: ?? REMOVE
  340. * @queue_number: ?? REMOVE
  341. */
  342. struct ieee80211_tx_status {
  343. struct ieee80211_tx_control control;
  344. u8 flags;
  345. bool excessive_retries;
  346. u8 retry_count;
  347. int ack_signal;
  348. int queue_length;
  349. int queue_number;
  350. };
  351. /**
  352. * enum ieee80211_conf_flags - configuration flags
  353. *
  354. * Flags to define PHY configuration options
  355. *
  356. * @IEEE80211_CONF_SHORT_SLOT_TIME: use 802.11g short slot time
  357. * @IEEE80211_CONF_RADIOTAP: add radiotap header at receive time (if supported)
  358. *
  359. */
  360. enum ieee80211_conf_flags {
  361. IEEE80211_CONF_SHORT_SLOT_TIME = 1<<0,
  362. IEEE80211_CONF_RADIOTAP = 1<<1,
  363. };
  364. /**
  365. * struct ieee80211_conf - configuration of the device
  366. *
  367. * This struct indicates how the driver shall configure the hardware.
  368. *
  369. * @radio_enabled: when zero, driver is required to switch off the radio.
  370. * TODO make a flag
  371. * @channel: IEEE 802.11 channel number
  372. * @freq: frequency in MHz
  373. * @channel_val: hardware specific channel value for the channel
  374. * @phymode: PHY mode to activate (REMOVE)
  375. * @chan: channel to switch to, pointer to the channel information
  376. * @mode: pointer to mode definition
  377. * @regulatory_domain: ??
  378. * @beacon_int: beacon interval (TODO make interface config)
  379. * @flags: configuration flags defined above
  380. * @power_level: transmit power limit for current regulatory domain in dBm
  381. * @antenna_max: maximum antenna gain
  382. * @antenna_sel_tx: transmit antenna selection, 0: default/diversity,
  383. * 1/2: antenna 0/1
  384. * @antenna_sel_rx: receive antenna selection, like @antenna_sel_tx
  385. */
  386. struct ieee80211_conf {
  387. int channel; /* IEEE 802.11 channel number */
  388. int freq; /* MHz */
  389. int channel_val; /* hw specific value for the channel */
  390. enum ieee80211_phymode phymode;
  391. struct ieee80211_channel *chan;
  392. struct ieee80211_hw_mode *mode;
  393. unsigned int regulatory_domain;
  394. int radio_enabled;
  395. int beacon_int;
  396. u32 flags;
  397. u8 power_level;
  398. u8 antenna_max;
  399. u8 antenna_sel_tx;
  400. u8 antenna_sel_rx;
  401. };
  402. /**
  403. * enum ieee80211_if_types - types of 802.11 network interfaces
  404. *
  405. * @IEEE80211_IF_TYPE_AP: interface in AP mode.
  406. * @IEEE80211_IF_TYPE_MGMT: special interface for communication with hostap
  407. * daemon. Drivers should never see this type.
  408. * @IEEE80211_IF_TYPE_STA: interface in STA (client) mode.
  409. * @IEEE80211_IF_TYPE_IBSS: interface in IBSS (ad-hoc) mode.
  410. * @IEEE80211_IF_TYPE_MNTR: interface in monitor (rfmon) mode.
  411. * @IEEE80211_IF_TYPE_WDS: interface in WDS mode.
  412. * @IEEE80211_IF_TYPE_VLAN: not used.
  413. */
  414. enum ieee80211_if_types {
  415. IEEE80211_IF_TYPE_AP = 0x00000000,
  416. IEEE80211_IF_TYPE_MGMT = 0x00000001,
  417. IEEE80211_IF_TYPE_STA = 0x00000002,
  418. IEEE80211_IF_TYPE_IBSS = 0x00000003,
  419. IEEE80211_IF_TYPE_MNTR = 0x00000004,
  420. IEEE80211_IF_TYPE_WDS = 0x5A580211,
  421. IEEE80211_IF_TYPE_VLAN = 0x00080211,
  422. };
  423. /**
  424. * struct ieee80211_if_init_conf - initial configuration of an interface
  425. *
  426. * @if_id: internal interface ID. This number has no particular meaning to
  427. * drivers and the only allowed usage is to pass it to
  428. * ieee80211_beacon_get() and ieee80211_get_buffered_bc() functions.
  429. * This field is not valid for monitor interfaces
  430. * (interfaces of %IEEE80211_IF_TYPE_MNTR type).
  431. * @type: one of &enum ieee80211_if_types constants. Determines the type of
  432. * added/removed interface.
  433. * @mac_addr: pointer to MAC address of the interface. This pointer is valid
  434. * until the interface is removed (i.e. it cannot be used after
  435. * remove_interface() callback was called for this interface).
  436. *
  437. * This structure is used in add_interface() and remove_interface()
  438. * callbacks of &struct ieee80211_hw.
  439. *
  440. * When you allow multiple interfaces to be added to your PHY, take care
  441. * that the hardware can actually handle multiple MAC addresses. However,
  442. * also take care that when there's no interface left with mac_addr != %NULL
  443. * you remove the MAC address from the device to avoid acknowledging packets
  444. * in pure monitor mode.
  445. */
  446. struct ieee80211_if_init_conf {
  447. int if_id;
  448. int type;
  449. void *mac_addr;
  450. };
  451. /**
  452. * struct ieee80211_if_conf - configuration of an interface
  453. *
  454. * @type: type of the interface. This is always the same as was specified in
  455. * &struct ieee80211_if_init_conf. The type of an interface never changes
  456. * during the life of the interface; this field is present only for
  457. * convenience.
  458. * @bssid: BSSID of the network we are associated to/creating.
  459. * @ssid: used (together with @ssid_len) by drivers for hardware that
  460. * generate beacons independently. The pointer is valid only during the
  461. * config_interface() call, so copy the value somewhere if you need
  462. * it.
  463. * @ssid_len: length of the @ssid field.
  464. * @generic_elem: used (together with @generic_elem_len) by drivers for
  465. * hardware that generate beacons independently. The pointer is valid
  466. * only during the config_interface() call, so copy the value somewhere
  467. * if you need it.
  468. * @generic_elem_len: length of the generic element.
  469. * @beacon: beacon template. Valid only if @host_gen_beacon_template in
  470. * &struct ieee80211_hw is set. The driver is responsible of freeing
  471. * the sk_buff.
  472. * @beacon_control: tx_control for the beacon template, this field is only
  473. * valid when the @beacon field was set.
  474. *
  475. * This structure is passed to the config_interface() callback of
  476. * &struct ieee80211_hw.
  477. */
  478. struct ieee80211_if_conf {
  479. int type;
  480. u8 *bssid;
  481. u8 *ssid;
  482. size_t ssid_len;
  483. u8 *generic_elem;
  484. size_t generic_elem_len;
  485. struct sk_buff *beacon;
  486. struct ieee80211_tx_control *beacon_control;
  487. };
  488. /**
  489. * enum ieee80211_key_alg - key algorithm
  490. * @ALG_NONE: Unset key algorithm, will never be passed to the driver
  491. * @ALG_WEP: WEP40 or WEP104
  492. * @ALG_TKIP: TKIP
  493. * @ALG_CCMP: CCMP (AES)
  494. */
  495. typedef enum ieee80211_key_alg {
  496. ALG_NONE,
  497. ALG_WEP,
  498. ALG_TKIP,
  499. ALG_CCMP,
  500. } ieee80211_key_alg;
  501. /**
  502. * enum ieee80211_key_flags - key flags
  503. *
  504. * These flags are used for communication about keys between the driver
  505. * and mac80211, with the @flags parameter of &struct ieee80211_key_conf.
  506. *
  507. * @IEEE80211_KEY_FLAG_WMM_STA: Set by mac80211, this flag indicates
  508. * that the STA this key will be used with could be using QoS.
  509. * @IEEE80211_KEY_FLAG_GENERATE_IV: This flag should be set by the
  510. * driver to indicate that it requires IV generation for this
  511. * particular key.
  512. * @IEEE80211_KEY_FLAG_GENERATE_MMIC: This flag should be set by
  513. * the driver for a TKIP key if it requires Michael MIC
  514. * generation in software.
  515. */
  516. enum ieee80211_key_flags {
  517. IEEE80211_KEY_FLAG_WMM_STA = 1<<0,
  518. IEEE80211_KEY_FLAG_GENERATE_IV = 1<<1,
  519. IEEE80211_KEY_FLAG_GENERATE_MMIC= 1<<2,
  520. };
  521. /**
  522. * struct ieee80211_key_conf - key information
  523. *
  524. * This key information is given by mac80211 to the driver by
  525. * the set_key() callback in &struct ieee80211_ops.
  526. *
  527. * @hw_key_idx: To be set by the driver, this is the key index the driver
  528. * wants to be given when a frame is transmitted and needs to be
  529. * encrypted in hardware.
  530. * @alg: The key algorithm.
  531. * @flags: key flags, see &enum ieee80211_key_flags.
  532. * @keyidx: the key index (0-3)
  533. * @keylen: key material length
  534. * @key: key material
  535. */
  536. struct ieee80211_key_conf {
  537. ieee80211_key_alg alg;
  538. u8 hw_key_idx;
  539. u8 flags;
  540. s8 keyidx;
  541. u8 keylen;
  542. u8 key[0];
  543. };
  544. #define IEEE80211_SEQ_COUNTER_RX 0
  545. #define IEEE80211_SEQ_COUNTER_TX 1
  546. /**
  547. * enum set_key_cmd - key command
  548. *
  549. * Used with the set_key() callback in &struct ieee80211_ops, this
  550. * indicates whether a key is being removed or added.
  551. *
  552. * @SET_KEY: a key is set
  553. * @DISABLE_KEY: a key must be disabled
  554. */
  555. typedef enum set_key_cmd {
  556. SET_KEY, DISABLE_KEY,
  557. } set_key_cmd;
  558. /**
  559. * struct ieee80211_hw - hardware information and state
  560. * TODO: move documentation into kernel-doc format
  561. */
  562. struct ieee80211_hw {
  563. /* points to the cfg80211 wiphy for this piece. Note
  564. * that you must fill in the perm_addr and dev fields
  565. * of this structure, use the macros provided below. */
  566. struct wiphy *wiphy;
  567. /* assigned by mac80211, don't write */
  568. struct ieee80211_conf conf;
  569. /* Single thread workqueue available for driver use
  570. * Allocated by mac80211 on registration */
  571. struct workqueue_struct *workqueue;
  572. /* Pointer to the private area that was
  573. * allocated with this struct for you. */
  574. void *priv;
  575. /* The rest is information about your hardware */
  576. /* TODO: frame_type 802.11/802.3, sw_encryption requirements */
  577. /* hole at 0 */
  578. /*
  579. * The device only needs to be supplied with a beacon template.
  580. * If you need the host to generate each beacon then don't use
  581. * this flag and use ieee80211_beacon_get().
  582. */
  583. #define IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE (1<<1)
  584. /* hole at 2 */
  585. /* Whether RX frames passed to ieee80211_rx() include FCS in the end */
  586. #define IEEE80211_HW_RX_INCLUDES_FCS (1<<3)
  587. /* Some wireless LAN chipsets buffer broadcast/multicast frames for
  588. * power saving stations in the hardware/firmware and others rely on
  589. * the host system for such buffering. This option is used to
  590. * configure the IEEE 802.11 upper layer to buffer broadcast/multicast
  591. * frames when there are power saving stations so that low-level driver
  592. * can fetch them with ieee80211_get_buffered_bc(). */
  593. #define IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING (1<<4)
  594. /* hole at 5 */
  595. /* hole at 6 */
  596. /* hole at 7 */
  597. /* hole at 8 */
  598. /* hole at 9 */
  599. /* hole at 10 */
  600. /* Channels are already configured to the default regulatory domain
  601. * specified in the device's EEPROM */
  602. #define IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED (1<<11)
  603. u32 flags; /* hardware flags defined above */
  604. /* Set to the size of a needed device specific skb headroom for TX skbs. */
  605. unsigned int extra_tx_headroom;
  606. /* This is the time in us to change channels
  607. */
  608. int channel_change_time;
  609. /* Maximum values for various statistics.
  610. * Leave at 0 to indicate no support. Use negative numbers for dBm. */
  611. s8 max_rssi;
  612. s8 max_signal;
  613. s8 max_noise;
  614. /* Number of available hardware TX queues for data packets.
  615. * WMM requires at least four queues. */
  616. int queues;
  617. };
  618. static inline void SET_IEEE80211_DEV(struct ieee80211_hw *hw, struct device *dev)
  619. {
  620. set_wiphy_dev(hw->wiphy, dev);
  621. }
  622. static inline void SET_IEEE80211_PERM_ADDR(struct ieee80211_hw *hw, u8 *addr)
  623. {
  624. memcpy(hw->wiphy->perm_addr, addr, ETH_ALEN);
  625. }
  626. /*
  627. * flags for change_filter_flags()
  628. *
  629. * Note that e.g. if PROMISC_IN_BSS is unset then
  630. * you should still do MAC address filtering if
  631. * possible even if OTHER_BSS is set to indicate
  632. * no BSSID filtering should be done.
  633. */
  634. /*
  635. * promiscuous mode within your BSS,
  636. * think of the BSS as your network segment and then this corresponds
  637. * to the regular ethernet device promiscuous mode
  638. */
  639. #define FIF_PROMISC_IN_BSS 0x01
  640. /* show all multicast frames */
  641. #define FIF_ALLMULTI 0x02
  642. /* show frames with failed FCS, but set RX_FLAG_FAILED_FCS_CRC for them */
  643. #define FIF_FCSFAIL 0x04
  644. /* show frames with failed PLCP CRC, but set RX_FLAG_FAILED_PLCP_CRC for them */
  645. #define FIF_PLCPFAIL 0x08
  646. /*
  647. * This flag is set during scanning to indicate to the hardware
  648. * that it should not filter beacons or probe responses by BSSID.
  649. */
  650. #define FIF_BCN_PRBRESP_PROMISC 0x10
  651. /*
  652. * show control frames, if PROMISC_IN_BSS is not set then
  653. * only those addressed to this station
  654. */
  655. #define FIF_CONTROL 0x20
  656. /* show frames from other BSSes */
  657. #define FIF_OTHER_BSS 0x40
  658. /* Configuration block used by the low-level driver to tell the 802.11 code
  659. * about supported hardware features and to pass function pointers to callback
  660. * functions. */
  661. struct ieee80211_ops {
  662. /* Handler that 802.11 module calls for each transmitted frame.
  663. * skb contains the buffer starting from the IEEE 802.11 header.
  664. * The low-level driver should send the frame out based on
  665. * configuration in the TX control data.
  666. * Must be atomic. */
  667. int (*tx)(struct ieee80211_hw *hw, struct sk_buff *skb,
  668. struct ieee80211_tx_control *control);
  669. /*
  670. * Called before the first netdevice attached to the hardware
  671. * is enabled. This should turn on the hardware and must turn on
  672. * frame reception (for possibly enabled monitor interfaces.)
  673. * Returns negative error codes, these may be seen in userspace,
  674. * or zero.
  675. * When the device is started it should not have a MAC address
  676. * to avoid acknowledging frames before a non-monitor device
  677. * is added.
  678. *
  679. * Must be implemented.
  680. */
  681. int (*start)(struct ieee80211_hw *hw);
  682. /*
  683. * Called after last netdevice attached to the hardware
  684. * is disabled. This should turn off the hardware (at least
  685. * it must turn off frame reception.)
  686. * May be called right after add_interface if that rejects
  687. * an interface.
  688. *
  689. * Must be implemented.
  690. */
  691. void (*stop)(struct ieee80211_hw *hw);
  692. /*
  693. * Called when a netdevice attached to the hardware is enabled.
  694. * Because it is not called for monitor mode devices, open()
  695. * and stop() must be implemented.
  696. * The driver should perform any initialization it needs before
  697. * the device can be enabled. The initial configuration for the
  698. * interface is given in the conf parameter.
  699. *
  700. * Must be implemented.
  701. */
  702. int (*add_interface)(struct ieee80211_hw *hw,
  703. struct ieee80211_if_init_conf *conf);
  704. /*
  705. * Notifies a driver that an interface is going down. The stop() handler
  706. * is called after this if it is the last interface and no monitor
  707. * interfaces are present.
  708. * When all interfaces are removed, the MAC address in the hardware
  709. * must be cleared so the device no longer acknowledges packets,
  710. * the mac_addr member of the conf structure is, however, set to the
  711. * MAC address of the device going away.
  712. *
  713. * Hence, this callback must be implemented.
  714. */
  715. void (*remove_interface)(struct ieee80211_hw *hw,
  716. struct ieee80211_if_init_conf *conf);
  717. /* Handler for configuration requests. IEEE 802.11 code calls this
  718. * function to change hardware configuration, e.g., channel. */
  719. int (*config)(struct ieee80211_hw *hw, struct ieee80211_conf *conf);
  720. /* Handler for configuration requests related to interfaces (e.g.
  721. * BSSID). */
  722. int (*config_interface)(struct ieee80211_hw *hw,
  723. int if_id, struct ieee80211_if_conf *conf);
  724. /*
  725. * Configure the device's RX filter.
  726. *
  727. * The multicast address filter must be changed if the hardware flags
  728. * indicate that one is present.
  729. *
  730. * All unsupported flags in 'total_flags' must be cleared,
  731. * clear all bits except those you honoured.
  732. *
  733. * The callback must be implemented and must be atomic.
  734. */
  735. void (*configure_filter)(struct ieee80211_hw *hw,
  736. unsigned int changed_flags,
  737. unsigned int *total_flags,
  738. int mc_count, struct dev_addr_list *mc_list);
  739. /* Set TIM bit handler. If the hardware/firmware takes care of beacon
  740. * generation, IEEE 802.11 code uses this function to tell the
  741. * low-level to set (or clear if set==0) TIM bit for the given aid. If
  742. * host system is used to generate beacons, this handler is not used
  743. * and low-level driver should set it to NULL.
  744. * Must be atomic. */
  745. int (*set_tim)(struct ieee80211_hw *hw, int aid, int set);
  746. /*
  747. * Set encryption key.
  748. *
  749. * This is called to enable hardware acceleration of encryption and
  750. * decryption. The address will be the broadcast address for default
  751. * keys, the other station's hardware address for individual keys or
  752. * the zero address for keys that will be used only for transmission.
  753. *
  754. * The local_address parameter will always be set to our own address,
  755. * this is only relevant if you support multiple local addresses.
  756. *
  757. * When transmitting, the TX control data will use the hw_key_idx
  758. * selected by the low-level driver.
  759. *
  760. * Return 0 if the key is now in use, -EOPNOTSUPP or -ENOSPC if it
  761. * couldn't be added; if you return 0 then hw_key_idx must be assigned
  762. * to the hardware key index, you are free to use the full u8 range.
  763. *
  764. * When the cmd is DISABLE_KEY then it must succeed.
  765. *
  766. * Note that it is permissible to not decrypt a frame even if a key
  767. * for it has been uploaded to hardware, the stack will not make any
  768. * decision based on whether a key has been uploaded or not but rather
  769. * based on the receive flags.
  770. *
  771. * This callback can sleep, and is only called between add_interface
  772. * and remove_interface calls, i.e. while the interface with the
  773. * given local_address is enabled.
  774. *
  775. * The ieee80211_key_conf structure pointed to by the key parameter
  776. * is guaranteed to be valid until another call to set_key removes
  777. * it, but it can only be used as a cookie to differentiate keys.
  778. */
  779. int (*set_key)(struct ieee80211_hw *hw, set_key_cmd cmd,
  780. const u8 *local_address, const u8 *address,
  781. struct ieee80211_key_conf *key);
  782. /* Enable/disable IEEE 802.1X. This item requests wlan card to pass
  783. * unencrypted EAPOL-Key frames even when encryption is configured.
  784. * If the wlan card does not require such a configuration, this
  785. * function pointer can be set to NULL. */
  786. int (*set_ieee8021x)(struct ieee80211_hw *hw, int use_ieee8021x);
  787. /* Set port authorization state (IEEE 802.1X PAE) to be authorized
  788. * (authorized=1) or unauthorized (authorized=0). This function can be
  789. * used if the wlan hardware or low-level driver implements PAE.
  790. * 80211.o module will anyway filter frames based on authorization
  791. * state, so this function pointer can be NULL if low-level driver does
  792. * not require event notification about port state changes.
  793. * Currently unused. */
  794. int (*set_port_auth)(struct ieee80211_hw *hw, u8 *addr,
  795. int authorized);
  796. /* Ask the hardware to service the scan request, no need to start
  797. * the scan state machine in stack. */
  798. int (*hw_scan)(struct ieee80211_hw *hw, u8 *ssid, size_t len);
  799. /* return low-level statistics */
  800. int (*get_stats)(struct ieee80211_hw *hw,
  801. struct ieee80211_low_level_stats *stats);
  802. /* For devices that generate their own beacons and probe response
  803. * or association responses this updates the state of privacy_invoked
  804. * returns 0 for success or an error number */
  805. int (*set_privacy_invoked)(struct ieee80211_hw *hw,
  806. int privacy_invoked);
  807. /* For devices that have internal sequence counters, allow 802.11
  808. * code to access the current value of a counter */
  809. int (*get_sequence_counter)(struct ieee80211_hw *hw,
  810. u8* addr, u8 keyidx, u8 txrx,
  811. u32* iv32, u16* iv16);
  812. /* Configuration of RTS threshold (if device needs it) */
  813. int (*set_rts_threshold)(struct ieee80211_hw *hw, u32 value);
  814. /* Configuration of fragmentation threshold.
  815. * Assign this if the device does fragmentation by itself,
  816. * if this method is assigned then the stack will not do
  817. * fragmentation. */
  818. int (*set_frag_threshold)(struct ieee80211_hw *hw, u32 value);
  819. /* Configuration of retry limits (if device needs it) */
  820. int (*set_retry_limit)(struct ieee80211_hw *hw,
  821. u32 short_retry, u32 long_retr);
  822. /* Number of STAs in STA table notification (NULL = disabled).
  823. * Must be atomic. */
  824. void (*sta_table_notification)(struct ieee80211_hw *hw,
  825. int num_sta);
  826. /* Handle ERP IE change notifications. Must be atomic. */
  827. void (*erp_ie_changed)(struct ieee80211_hw *hw, u8 changes,
  828. int cts_protection, int preamble);
  829. /* Flags for the erp_ie_changed changes parameter */
  830. #define IEEE80211_ERP_CHANGE_PROTECTION (1<<0) /* protection flag changed */
  831. #define IEEE80211_ERP_CHANGE_PREAMBLE (1<<1) /* barker preamble mode changed */
  832. /* Configure TX queue parameters (EDCF (aifs, cw_min, cw_max),
  833. * bursting) for a hardware TX queue.
  834. * queue = IEEE80211_TX_QUEUE_*.
  835. * Must be atomic. */
  836. int (*conf_tx)(struct ieee80211_hw *hw, int queue,
  837. const struct ieee80211_tx_queue_params *params);
  838. /* Get statistics of the current TX queue status. This is used to get
  839. * number of currently queued packets (queue length), maximum queue
  840. * size (limit), and total number of packets sent using each TX queue
  841. * (count).
  842. * Currently unused. */
  843. int (*get_tx_stats)(struct ieee80211_hw *hw,
  844. struct ieee80211_tx_queue_stats *stats);
  845. /* Get the current TSF timer value from firmware/hardware. Currently,
  846. * this is only used for IBSS mode debugging and, as such, is not a
  847. * required function.
  848. * Must be atomic. */
  849. u64 (*get_tsf)(struct ieee80211_hw *hw);
  850. /* Reset the TSF timer and allow firmware/hardware to synchronize with
  851. * other STAs in the IBSS. This is only used in IBSS mode. This
  852. * function is optional if the firmware/hardware takes full care of
  853. * TSF synchronization. */
  854. void (*reset_tsf)(struct ieee80211_hw *hw);
  855. /* Setup beacon data for IBSS beacons. Unlike access point (Master),
  856. * IBSS uses a fixed beacon frame which is configured using this
  857. * function. This handler is required only for IBSS mode. */
  858. int (*beacon_update)(struct ieee80211_hw *hw,
  859. struct sk_buff *skb,
  860. struct ieee80211_tx_control *control);
  861. /* Determine whether the last IBSS beacon was sent by us. This is
  862. * needed only for IBSS mode and the result of this function is used to
  863. * determine whether to reply to Probe Requests. */
  864. int (*tx_last_beacon)(struct ieee80211_hw *hw);
  865. };
  866. /* Allocate a new hardware device. This must be called once for each
  867. * hardware device. The returned pointer must be used to refer to this
  868. * device when calling other functions. 802.11 code allocates a private data
  869. * area for the low-level driver. The size of this area is given as
  870. * priv_data_len.
  871. */
  872. struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
  873. const struct ieee80211_ops *ops);
  874. /* Register hardware device to the IEEE 802.11 code and kernel. Low-level
  875. * drivers must call this function before using any other IEEE 802.11
  876. * function except ieee80211_register_hwmode. */
  877. int ieee80211_register_hw(struct ieee80211_hw *hw);
  878. /* driver can use this and ieee80211_get_rx_led_name to get the
  879. * name of the registered LEDs after ieee80211_register_hw
  880. * was called.
  881. * This is useful to set the default trigger on the LED class
  882. * device that your driver should export for each LED the device
  883. * has, that way the default behaviour will be as expected but
  884. * the user can still change it/turn off the LED etc.
  885. */
  886. #ifdef CONFIG_MAC80211_LEDS
  887. extern char *__ieee80211_get_tx_led_name(struct ieee80211_hw *hw);
  888. extern char *__ieee80211_get_rx_led_name(struct ieee80211_hw *hw);
  889. #endif
  890. static inline char *ieee80211_get_tx_led_name(struct ieee80211_hw *hw)
  891. {
  892. #ifdef CONFIG_MAC80211_LEDS
  893. return __ieee80211_get_tx_led_name(hw);
  894. #else
  895. return NULL;
  896. #endif
  897. }
  898. static inline char *ieee80211_get_rx_led_name(struct ieee80211_hw *hw)
  899. {
  900. #ifdef CONFIG_MAC80211_LEDS
  901. return __ieee80211_get_rx_led_name(hw);
  902. #else
  903. return NULL;
  904. #endif
  905. }
  906. /* Register a new hardware PHYMODE capability to the stack. */
  907. int ieee80211_register_hwmode(struct ieee80211_hw *hw,
  908. struct ieee80211_hw_mode *mode);
  909. /* Unregister a hardware device. This function instructs 802.11 code to free
  910. * allocated resources and unregister netdevices from the kernel. */
  911. void ieee80211_unregister_hw(struct ieee80211_hw *hw);
  912. /* Free everything that was allocated including private data of a driver. */
  913. void ieee80211_free_hw(struct ieee80211_hw *hw);
  914. /* Receive frame callback function. The low-level driver uses this function to
  915. * send received frames to the IEEE 802.11 code. Receive buffer (skb) must
  916. * start with IEEE 802.11 header. */
  917. void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb,
  918. struct ieee80211_rx_status *status);
  919. void ieee80211_rx_irqsafe(struct ieee80211_hw *hw,
  920. struct sk_buff *skb,
  921. struct ieee80211_rx_status *status);
  922. /* Transmit status callback function. The low-level driver must call this
  923. * function to report transmit status for all the TX frames that had
  924. * req_tx_status set in the transmit control fields. In addition, this should
  925. * be called at least for all unicast frames to provide information for TX rate
  926. * control algorithm. In order to maintain all statistics, this function is
  927. * recommended to be called after each frame, including multicast/broadcast, is
  928. * sent. */
  929. void ieee80211_tx_status(struct ieee80211_hw *hw,
  930. struct sk_buff *skb,
  931. struct ieee80211_tx_status *status);
  932. void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw,
  933. struct sk_buff *skb,
  934. struct ieee80211_tx_status *status);
  935. /**
  936. * ieee80211_beacon_get - beacon generation function
  937. * @hw: pointer obtained from ieee80211_alloc_hw().
  938. * @if_id: interface ID from &struct ieee80211_if_init_conf.
  939. * @control: will be filled with information needed to send this beacon.
  940. *
  941. * If the beacon frames are generated by the host system (i.e., not in
  942. * hardware/firmware), the low-level driver uses this function to receive
  943. * the next beacon frame from the 802.11 code. The low-level is responsible
  944. * for calling this function before beacon data is needed (e.g., based on
  945. * hardware interrupt). Returned skb is used only once and low-level driver
  946. * is responsible of freeing it.
  947. */
  948. struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
  949. int if_id,
  950. struct ieee80211_tx_control *control);
  951. /**
  952. * ieee80211_rts_get - RTS frame generation function
  953. * @hw: pointer obtained from ieee80211_alloc_hw().
  954. * @if_id: interface ID from &struct ieee80211_if_init_conf.
  955. * @frame: pointer to the frame that is going to be protected by the RTS.
  956. * @frame_len: the frame length (in octets).
  957. * @frame_txctl: &struct ieee80211_tx_control of the frame.
  958. * @rts: The buffer where to store the RTS frame.
  959. *
  960. * If the RTS frames are generated by the host system (i.e., not in
  961. * hardware/firmware), the low-level driver uses this function to receive
  962. * the next RTS frame from the 802.11 code. The low-level is responsible
  963. * for calling this function before and RTS frame is needed.
  964. */
  965. void ieee80211_rts_get(struct ieee80211_hw *hw, int if_id,
  966. const void *frame, size_t frame_len,
  967. const struct ieee80211_tx_control *frame_txctl,
  968. struct ieee80211_rts *rts);
  969. /**
  970. * ieee80211_rts_duration - Get the duration field for an RTS frame
  971. * @hw: pointer obtained from ieee80211_alloc_hw().
  972. * @if_id: interface ID from &struct ieee80211_if_init_conf.
  973. * @frame_len: the length of the frame that is going to be protected by the RTS.
  974. * @frame_txctl: &struct ieee80211_tx_control of the frame.
  975. *
  976. * If the RTS is generated in firmware, but the host system must provide
  977. * the duration field, the low-level driver uses this function to receive
  978. * the duration field value in little-endian byteorder.
  979. */
  980. __le16 ieee80211_rts_duration(struct ieee80211_hw *hw, int if_id,
  981. size_t frame_len,
  982. const struct ieee80211_tx_control *frame_txctl);
  983. /**
  984. * ieee80211_ctstoself_get - CTS-to-self frame generation function
  985. * @hw: pointer obtained from ieee80211_alloc_hw().
  986. * @if_id: interface ID from &struct ieee80211_if_init_conf.
  987. * @frame: pointer to the frame that is going to be protected by the CTS-to-self.
  988. * @frame_len: the frame length (in octets).
  989. * @frame_txctl: &struct ieee80211_tx_control of the frame.
  990. * @cts: The buffer where to store the CTS-to-self frame.
  991. *
  992. * If the CTS-to-self frames are generated by the host system (i.e., not in
  993. * hardware/firmware), the low-level driver uses this function to receive
  994. * the next CTS-to-self frame from the 802.11 code. The low-level is responsible
  995. * for calling this function before and CTS-to-self frame is needed.
  996. */
  997. void ieee80211_ctstoself_get(struct ieee80211_hw *hw, int if_id,
  998. const void *frame, size_t frame_len,
  999. const struct ieee80211_tx_control *frame_txctl,
  1000. struct ieee80211_cts *cts);
  1001. /**
  1002. * ieee80211_ctstoself_duration - Get the duration field for a CTS-to-self frame
  1003. * @hw: pointer obtained from ieee80211_alloc_hw().
  1004. * @if_id: interface ID from &struct ieee80211_if_init_conf.
  1005. * @frame_len: the length of the frame that is going to be protected by the CTS-to-self.
  1006. * @frame_txctl: &struct ieee80211_tx_control of the frame.
  1007. *
  1008. * If the CTS-to-self is generated in firmware, but the host system must provide
  1009. * the duration field, the low-level driver uses this function to receive
  1010. * the duration field value in little-endian byteorder.
  1011. */
  1012. __le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw, int if_id,
  1013. size_t frame_len,
  1014. const struct ieee80211_tx_control *frame_txctl);
  1015. /**
  1016. * ieee80211_generic_frame_duration - Calculate the duration field for a frame
  1017. * @hw: pointer obtained from ieee80211_alloc_hw().
  1018. * @if_id: interface ID from &struct ieee80211_if_init_conf.
  1019. * @frame_len: the length of the frame.
  1020. * @rate: the rate (in 100kbps) at which the frame is going to be transmitted.
  1021. *
  1022. * Calculate the duration field of some generic frame, given its
  1023. * length and transmission rate (in 100kbps).
  1024. */
  1025. __le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw, int if_id,
  1026. size_t frame_len,
  1027. int rate);
  1028. /**
  1029. * ieee80211_get_buffered_bc - accessing buffered broadcast and multicast frames
  1030. * @hw: pointer as obtained from ieee80211_alloc_hw().
  1031. * @if_id: interface ID from &struct ieee80211_if_init_conf.
  1032. * @control: will be filled with information needed to send returned frame.
  1033. *
  1034. * Function for accessing buffered broadcast and multicast frames. If
  1035. * hardware/firmware does not implement buffering of broadcast/multicast
  1036. * frames when power saving is used, 802.11 code buffers them in the host
  1037. * memory. The low-level driver uses this function to fetch next buffered
  1038. * frame. In most cases, this is used when generating beacon frame. This
  1039. * function returns a pointer to the next buffered skb or NULL if no more
  1040. * buffered frames are available.
  1041. *
  1042. * Note: buffered frames are returned only after DTIM beacon frame was
  1043. * generated with ieee80211_beacon_get() and the low-level driver must thus
  1044. * call ieee80211_beacon_get() first. ieee80211_get_buffered_bc() returns
  1045. * NULL if the previous generated beacon was not DTIM, so the low-level driver
  1046. * does not need to check for DTIM beacons separately and should be able to
  1047. * use common code for all beacons.
  1048. */
  1049. struct sk_buff *
  1050. ieee80211_get_buffered_bc(struct ieee80211_hw *hw, int if_id,
  1051. struct ieee80211_tx_control *control);
  1052. /* Given an sk_buff with a raw 802.11 header at the data pointer this function
  1053. * returns the 802.11 header length in bytes (not including encryption
  1054. * headers). If the data in the sk_buff is too short to contain a valid 802.11
  1055. * header the function returns 0.
  1056. */
  1057. int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb);
  1058. /* Like ieee80211_get_hdrlen_from_skb() but takes a FC in CPU order. */
  1059. int ieee80211_get_hdrlen(u16 fc);
  1060. /**
  1061. * ieee80211_wake_queue - wake specific queue
  1062. * @hw: pointer as obtained from ieee80211_alloc_hw().
  1063. * @queue: queue number (counted from zero).
  1064. *
  1065. * Drivers should use this function instead of netif_wake_queue.
  1066. */
  1067. void ieee80211_wake_queue(struct ieee80211_hw *hw, int queue);
  1068. /**
  1069. * ieee80211_stop_queue - stop specific queue
  1070. * @hw: pointer as obtained from ieee80211_alloc_hw().
  1071. * @queue: queue number (counted from zero).
  1072. *
  1073. * Drivers should use this function instead of netif_stop_queue.
  1074. */
  1075. void ieee80211_stop_queue(struct ieee80211_hw *hw, int queue);
  1076. /**
  1077. * ieee80211_start_queues - start all queues
  1078. * @hw: pointer to as obtained from ieee80211_alloc_hw().
  1079. *
  1080. * Drivers should use this function instead of netif_start_queue.
  1081. */
  1082. void ieee80211_start_queues(struct ieee80211_hw *hw);
  1083. /**
  1084. * ieee80211_stop_queues - stop all queues
  1085. * @hw: pointer as obtained from ieee80211_alloc_hw().
  1086. *
  1087. * Drivers should use this function instead of netif_stop_queue.
  1088. */
  1089. void ieee80211_stop_queues(struct ieee80211_hw *hw);
  1090. /**
  1091. * ieee80211_wake_queues - wake all queues
  1092. * @hw: pointer as obtained from ieee80211_alloc_hw().
  1093. *
  1094. * Drivers should use this function instead of netif_wake_queue.
  1095. */
  1096. void ieee80211_wake_queues(struct ieee80211_hw *hw);
  1097. /* called by driver to notify scan status completed */
  1098. void ieee80211_scan_completed(struct ieee80211_hw *hw);
  1099. /* return a pointer to the source address (SA) */
  1100. static inline u8 *ieee80211_get_SA(struct ieee80211_hdr *hdr)
  1101. {
  1102. u8 *raw = (u8 *) hdr;
  1103. u8 tofrom = (*(raw+1)) & 3; /* get the TODS and FROMDS bits */
  1104. switch (tofrom) {
  1105. case 2:
  1106. return hdr->addr3;
  1107. case 3:
  1108. return hdr->addr4;
  1109. }
  1110. return hdr->addr2;
  1111. }
  1112. /* return a pointer to the destination address (DA) */
  1113. static inline u8 *ieee80211_get_DA(struct ieee80211_hdr *hdr)
  1114. {
  1115. u8 *raw = (u8 *) hdr;
  1116. u8 to_ds = (*(raw+1)) & 1; /* get the TODS bit */
  1117. if (to_ds)
  1118. return hdr->addr3;
  1119. return hdr->addr1;
  1120. }
  1121. static inline int ieee80211_get_morefrag(struct ieee80211_hdr *hdr)
  1122. {
  1123. return (le16_to_cpu(hdr->frame_control) &
  1124. IEEE80211_FCTL_MOREFRAGS) != 0;
  1125. }
  1126. #endif /* MAC80211_H */