mac80211.h 41 KB

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