mac80211.h 42 KB

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