mac80211.h 41 KB

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