mac80211.h 41 KB

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