mac80211.h 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057
  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. /* Some wireless LAN chipsets generate beacons in the hardware/firmware
  410. * and others rely on host generated beacons. This option is used to
  411. * configure the upper layer IEEE 802.11 module to generate beacons.
  412. * The low-level driver can use ieee80211_beacon_get() to fetch the
  413. * next beacon frame. */
  414. #define IEEE80211_HW_HOST_GEN_BEACON (1<<0)
  415. /* The device needs to be supplied with a beacon template only. */
  416. #define IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE (1<<1)
  417. /* Some devices handle decryption internally and do not
  418. * indicate whether the frame was encrypted (unencrypted frames
  419. * will be dropped by the hardware, unless specifically allowed
  420. * through) */
  421. #define IEEE80211_HW_DEVICE_HIDES_WEP (1<<2)
  422. /* Whether RX frames passed to ieee80211_rx() include FCS in the end */
  423. #define IEEE80211_HW_RX_INCLUDES_FCS (1<<3)
  424. /* Some wireless LAN chipsets buffer broadcast/multicast frames for
  425. * power saving stations in the hardware/firmware and others rely on
  426. * the host system for such buffering. This option is used to
  427. * configure the IEEE 802.11 upper layer to buffer broadcast/multicast
  428. * frames when there are power saving stations so that low-level driver
  429. * can fetch them with ieee80211_get_buffered_bc(). */
  430. #define IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING (1<<4)
  431. #define IEEE80211_HW_WEP_INCLUDE_IV (1<<5)
  432. /* will data nullfunc frames get proper TX status callback */
  433. #define IEEE80211_HW_DATA_NULLFUNC_ACK (1<<6)
  434. /* Force software encryption for TKIP packets if WMM is enabled. */
  435. #define IEEE80211_HW_NO_TKIP_WMM_HWACCEL (1<<7)
  436. /* Some devices handle Michael MIC internally and do not include MIC in
  437. * the received packets passed up. device_strips_mic must be set
  438. * for such devices. The 'encryption' frame control bit is expected to
  439. * be still set in the IEEE 802.11 header with this option unlike with
  440. * the device_hides_wep configuration option.
  441. */
  442. #define IEEE80211_HW_DEVICE_STRIPS_MIC (1<<8)
  443. /* Device is capable of performing full monitor mode even during
  444. * normal operation. */
  445. #define IEEE80211_HW_MONITOR_DURING_OPER (1<<9)
  446. /* Device does not need BSSID filter set to broadcast in order to
  447. * receive all probe responses while scanning */
  448. #define IEEE80211_HW_NO_PROBE_FILTERING (1<<10)
  449. /* Channels are already configured to the default regulatory domain
  450. * specified in the device's EEPROM */
  451. #define IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED (1<<11)
  452. /* calculate Michael MIC for an MSDU when doing hwcrypto */
  453. #define IEEE80211_HW_TKIP_INCLUDE_MMIC (1<<12)
  454. /* Do TKIP phase1 key mixing in stack to support cards only do
  455. * phase2 key mixing when doing hwcrypto */
  456. #define IEEE80211_HW_TKIP_REQ_PHASE1_KEY (1<<13)
  457. /* Do TKIP phase1 and phase2 key mixing in stack and send the generated
  458. * per-packet RC4 key with each TX frame when doing hwcrypto */
  459. #define IEEE80211_HW_TKIP_REQ_PHASE2_KEY (1<<14)
  460. u32 flags; /* hardware flags defined above */
  461. /* Set to the size of a needed device specific skb headroom for TX skbs. */
  462. unsigned int extra_tx_headroom;
  463. /* This is the time in us to change channels
  464. */
  465. int channel_change_time;
  466. /* Maximum values for various statistics.
  467. * Leave at 0 to indicate no support. Use negative numbers for dBm. */
  468. s8 max_rssi;
  469. s8 max_signal;
  470. s8 max_noise;
  471. /* Number of available hardware TX queues for data packets.
  472. * WMM requires at least four queues. */
  473. int queues;
  474. };
  475. static inline void SET_IEEE80211_DEV(struct ieee80211_hw *hw, struct device *dev)
  476. {
  477. set_wiphy_dev(hw->wiphy, dev);
  478. }
  479. static inline void SET_IEEE80211_PERM_ADDR(struct ieee80211_hw *hw, u8 *addr)
  480. {
  481. memcpy(hw->wiphy->perm_addr, addr, ETH_ALEN);
  482. }
  483. /* Configuration block used by the low-level driver to tell the 802.11 code
  484. * about supported hardware features and to pass function pointers to callback
  485. * functions. */
  486. struct ieee80211_ops {
  487. /* Handler that 802.11 module calls for each transmitted frame.
  488. * skb contains the buffer starting from the IEEE 802.11 header.
  489. * The low-level driver should send the frame out based on
  490. * configuration in the TX control data.
  491. * Must be atomic. */
  492. int (*tx)(struct ieee80211_hw *hw, struct sk_buff *skb,
  493. struct ieee80211_tx_control *control);
  494. /* Handler for performing hardware reset. */
  495. int (*reset)(struct ieee80211_hw *hw);
  496. /* Handler that is called when any netdevice attached to the hardware
  497. * device is set UP for the first time. This can be used, e.g., to
  498. * enable interrupts and beacon sending. */
  499. int (*open)(struct ieee80211_hw *hw);
  500. /* Handler that is called when the last netdevice attached to the
  501. * hardware device is set DOWN. This can be used, e.g., to disable
  502. * interrupts and beacon sending. */
  503. int (*stop)(struct ieee80211_hw *hw);
  504. /* Handler for asking a driver if a new interface can be added (or,
  505. * more exactly, set UP). If the handler returns zero, the interface
  506. * is added. Driver should perform any initialization it needs prior
  507. * to returning zero. By returning non-zero addition of the interface
  508. * is inhibited. Unless monitor_during_oper is set, it is guaranteed
  509. * that monitor interfaces and normal interfaces are mutually
  510. * exclusive. If assigned, the open() handler is called after
  511. * add_interface() if this is the first device added. The
  512. * add_interface() callback has to be assigned because it is the only
  513. * way to obtain the requested MAC address for any interface.
  514. */
  515. int (*add_interface)(struct ieee80211_hw *hw,
  516. struct ieee80211_if_init_conf *conf);
  517. /* Notify a driver that an interface is going down. The stop() handler
  518. * is called prior to this if this is a last interface. */
  519. void (*remove_interface)(struct ieee80211_hw *hw,
  520. struct ieee80211_if_init_conf *conf);
  521. /* Handler for configuration requests. IEEE 802.11 code calls this
  522. * function to change hardware configuration, e.g., channel. */
  523. int (*config)(struct ieee80211_hw *hw, struct ieee80211_conf *conf);
  524. /* Handler for configuration requests related to interfaces (e.g.
  525. * BSSID). */
  526. int (*config_interface)(struct ieee80211_hw *hw,
  527. int if_id, struct ieee80211_if_conf *conf);
  528. /* ieee80211 drivers do not have access to the &struct net_device
  529. * that is (are) connected with their device. Hence (and because
  530. * we need to combine the multicast lists and flags for multiple
  531. * virtual interfaces), they cannot assign set_multicast_list.
  532. * The parameters here replace dev->flags and dev->mc_count,
  533. * dev->mc_list is replaced by calling ieee80211_get_mc_list_item.
  534. * Must be atomic. */
  535. void (*set_multicast_list)(struct ieee80211_hw *hw,
  536. unsigned short flags, int mc_count);
  537. /* Set TIM bit handler. If the hardware/firmware takes care of beacon
  538. * generation, IEEE 802.11 code uses this function to tell the
  539. * low-level to set (or clear if set==0) TIM bit for the given aid. If
  540. * host system is used to generate beacons, this handler is not used
  541. * and low-level driver should set it to NULL.
  542. * Must be atomic. */
  543. int (*set_tim)(struct ieee80211_hw *hw, int aid, int set);
  544. /* Set encryption key. IEEE 802.11 module calls this function to set
  545. * encryption keys. addr is ff:ff:ff:ff:ff:ff for default keys and
  546. * station hwaddr for individual keys. aid of the station is given
  547. * to help low-level driver in selecting which key->hw_key_idx to use
  548. * for this key. TX control data will use the hw_key_idx selected by
  549. * the low-level driver. */
  550. int (*set_key)(struct ieee80211_hw *hw, set_key_cmd cmd,
  551. u8 *addr, struct ieee80211_key_conf *key, int aid);
  552. /* Set TX key index for default/broadcast keys. This is needed in cases
  553. * where wlan card is doing full WEP/TKIP encapsulation (wep_include_iv
  554. * is not set), in other cases, this function pointer can be set to
  555. * NULL since the IEEE 802. 11 module takes care of selecting the key
  556. * index for each TX frame. */
  557. int (*set_key_idx)(struct ieee80211_hw *hw, int idx);
  558. /* Enable/disable IEEE 802.1X. This item requests wlan card to pass
  559. * unencrypted EAPOL-Key frames even when encryption is configured.
  560. * If the wlan card does not require such a configuration, this
  561. * function pointer can be set to NULL. */
  562. int (*set_ieee8021x)(struct ieee80211_hw *hw, int use_ieee8021x);
  563. /* Set port authorization state (IEEE 802.1X PAE) to be authorized
  564. * (authorized=1) or unauthorized (authorized=0). This function can be
  565. * used if the wlan hardware or low-level driver implements PAE.
  566. * 80211.o module will anyway filter frames based on authorization
  567. * state, so this function pointer can be NULL if low-level driver does
  568. * not require event notification about port state changes.
  569. * Currently unused. */
  570. int (*set_port_auth)(struct ieee80211_hw *hw, u8 *addr,
  571. int authorized);
  572. /* Ask the hardware to service the scan request, no need to start
  573. * the scan state machine in stack. */
  574. int (*hw_scan)(struct ieee80211_hw *hw, u8 *ssid, size_t len);
  575. /* return low-level statistics */
  576. int (*get_stats)(struct ieee80211_hw *hw,
  577. struct ieee80211_low_level_stats *stats);
  578. /* For devices that generate their own beacons and probe response
  579. * or association responses this updates the state of privacy_invoked
  580. * returns 0 for success or an error number */
  581. int (*set_privacy_invoked)(struct ieee80211_hw *hw,
  582. int privacy_invoked);
  583. /* For devices that have internal sequence counters, allow 802.11
  584. * code to access the current value of a counter */
  585. int (*get_sequence_counter)(struct ieee80211_hw *hw,
  586. u8* addr, u8 keyidx, u8 txrx,
  587. u32* iv32, u16* iv16);
  588. /* Configuration of RTS threshold (if device needs it) */
  589. int (*set_rts_threshold)(struct ieee80211_hw *hw, u32 value);
  590. /* Configuration of fragmentation threshold.
  591. * Assign this if the device does fragmentation by itself,
  592. * if this method is assigned then the stack will not do
  593. * fragmentation. */
  594. int (*set_frag_threshold)(struct ieee80211_hw *hw, u32 value);
  595. /* Configuration of retry limits (if device needs it) */
  596. int (*set_retry_limit)(struct ieee80211_hw *hw,
  597. u32 short_retry, u32 long_retr);
  598. /* Number of STAs in STA table notification (NULL = disabled).
  599. * Must be atomic. */
  600. void (*sta_table_notification)(struct ieee80211_hw *hw,
  601. int num_sta);
  602. /* Configure TX queue parameters (EDCF (aifs, cw_min, cw_max),
  603. * bursting) for a hardware TX queue.
  604. * queue = IEEE80211_TX_QUEUE_*.
  605. * Must be atomic. */
  606. int (*conf_tx)(struct ieee80211_hw *hw, int queue,
  607. const struct ieee80211_tx_queue_params *params);
  608. /* Get statistics of the current TX queue status. This is used to get
  609. * number of currently queued packets (queue length), maximum queue
  610. * size (limit), and total number of packets sent using each TX queue
  611. * (count).
  612. * Currently unused. */
  613. int (*get_tx_stats)(struct ieee80211_hw *hw,
  614. struct ieee80211_tx_queue_stats *stats);
  615. /* Get the current TSF timer value from firmware/hardware. Currently,
  616. * this is only used for IBSS mode debugging and, as such, is not a
  617. * required function.
  618. * Must be atomic. */
  619. u64 (*get_tsf)(struct ieee80211_hw *hw);
  620. /* Reset the TSF timer and allow firmware/hardware to synchronize with
  621. * other STAs in the IBSS. This is only used in IBSS mode. This
  622. * function is optional if the firmware/hardware takes full care of
  623. * TSF synchronization. */
  624. void (*reset_tsf)(struct ieee80211_hw *hw);
  625. /* Setup beacon data for IBSS beacons. Unlike access point (Master),
  626. * IBSS uses a fixed beacon frame which is configured using this
  627. * function. This handler is required only for IBSS mode. */
  628. int (*beacon_update)(struct ieee80211_hw *hw,
  629. struct sk_buff *skb,
  630. struct ieee80211_tx_control *control);
  631. /* Determine whether the last IBSS beacon was sent by us. This is
  632. * needed only for IBSS mode and the result of this function is used to
  633. * determine whether to reply to Probe Requests. */
  634. int (*tx_last_beacon)(struct ieee80211_hw *hw);
  635. };
  636. /* Allocate a new hardware device. This must be called once for each
  637. * hardware device. The returned pointer must be used to refer to this
  638. * device when calling other functions. 802.11 code allocates a private data
  639. * area for the low-level driver. The size of this area is given as
  640. * priv_data_len.
  641. */
  642. struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
  643. const struct ieee80211_ops *ops);
  644. /* Register hardware device to the IEEE 802.11 code and kernel. Low-level
  645. * drivers must call this function before using any other IEEE 802.11
  646. * function except ieee80211_register_hwmode. */
  647. int ieee80211_register_hw(struct ieee80211_hw *hw);
  648. /* driver can use this and ieee80211_get_rx_led_name to get the
  649. * name of the registered LEDs after ieee80211_register_hw
  650. * was called.
  651. * This is useful to set the default trigger on the LED class
  652. * device that your driver should export for each LED the device
  653. * has, that way the default behaviour will be as expected but
  654. * the user can still change it/turn off the LED etc.
  655. */
  656. #ifdef CONFIG_MAC80211_LEDS
  657. extern char *__ieee80211_get_tx_led_name(struct ieee80211_hw *hw);
  658. extern char *__ieee80211_get_rx_led_name(struct ieee80211_hw *hw);
  659. #endif
  660. static inline char *ieee80211_get_tx_led_name(struct ieee80211_hw *hw)
  661. {
  662. #ifdef CONFIG_MAC80211_LEDS
  663. return __ieee80211_get_tx_led_name(hw);
  664. #else
  665. return NULL;
  666. #endif
  667. }
  668. static inline char *ieee80211_get_rx_led_name(struct ieee80211_hw *hw)
  669. {
  670. #ifdef CONFIG_MAC80211_LEDS
  671. return __ieee80211_get_rx_led_name(hw);
  672. #else
  673. return NULL;
  674. #endif
  675. }
  676. /* Register a new hardware PHYMODE capability to the stack. */
  677. int ieee80211_register_hwmode(struct ieee80211_hw *hw,
  678. struct ieee80211_hw_mode *mode);
  679. /* Unregister a hardware device. This function instructs 802.11 code to free
  680. * allocated resources and unregister netdevices from the kernel. */
  681. void ieee80211_unregister_hw(struct ieee80211_hw *hw);
  682. /* Free everything that was allocated including private data of a driver. */
  683. void ieee80211_free_hw(struct ieee80211_hw *hw);
  684. /* Receive frame callback function. The low-level driver uses this function to
  685. * send received frames to the IEEE 802.11 code. Receive buffer (skb) must
  686. * start with IEEE 802.11 header. */
  687. void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb,
  688. struct ieee80211_rx_status *status);
  689. void ieee80211_rx_irqsafe(struct ieee80211_hw *hw,
  690. struct sk_buff *skb,
  691. struct ieee80211_rx_status *status);
  692. /* Transmit status callback function. The low-level driver must call this
  693. * function to report transmit status for all the TX frames that had
  694. * req_tx_status set in the transmit control fields. In addition, this should
  695. * be called at least for all unicast frames to provide information for TX rate
  696. * control algorithm. In order to maintain all statistics, this function is
  697. * recommended to be called after each frame, including multicast/broadcast, is
  698. * sent. */
  699. void ieee80211_tx_status(struct ieee80211_hw *hw,
  700. struct sk_buff *skb,
  701. struct ieee80211_tx_status *status);
  702. void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw,
  703. struct sk_buff *skb,
  704. struct ieee80211_tx_status *status);
  705. /**
  706. * ieee80211_beacon_get - beacon generation function
  707. * @hw: pointer obtained from ieee80211_alloc_hw().
  708. * @if_id: interface ID from &struct ieee80211_if_init_conf.
  709. * @control: will be filled with information needed to send this beacon.
  710. *
  711. * If the beacon frames are generated by the host system (i.e., not in
  712. * hardware/firmware), the low-level driver uses this function to receive
  713. * the next beacon frame from the 802.11 code. The low-level is responsible
  714. * for calling this function before beacon data is needed (e.g., based on
  715. * hardware interrupt). Returned skb is used only once and low-level driver
  716. * is responsible of freeing it.
  717. */
  718. struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
  719. int if_id,
  720. struct ieee80211_tx_control *control);
  721. /**
  722. * ieee80211_rts_get - RTS frame generation function
  723. * @hw: pointer obtained from ieee80211_alloc_hw().
  724. * @if_id: interface ID from &struct ieee80211_if_init_conf.
  725. * @frame: pointer to the frame that is going to be protected by the RTS.
  726. * @frame_len: the frame length (in octets).
  727. * @frame_txctl: &struct ieee80211_tx_control of the frame.
  728. * @rts: The buffer where to store the RTS frame.
  729. *
  730. * If the RTS frames are generated by the host system (i.e., not in
  731. * hardware/firmware), the low-level driver uses this function to receive
  732. * the next RTS frame from the 802.11 code. The low-level is responsible
  733. * for calling this function before and RTS frame is needed.
  734. */
  735. void ieee80211_rts_get(struct ieee80211_hw *hw, int if_id,
  736. const void *frame, size_t frame_len,
  737. const struct ieee80211_tx_control *frame_txctl,
  738. struct ieee80211_rts *rts);
  739. /**
  740. * ieee80211_rts_duration - Get the duration field for an RTS frame
  741. * @hw: pointer obtained from ieee80211_alloc_hw().
  742. * @if_id: interface ID from &struct ieee80211_if_init_conf.
  743. * @frame_len: the length of the frame that is going to be protected by the RTS.
  744. * @frame_txctl: &struct ieee80211_tx_control of the frame.
  745. *
  746. * If the RTS is generated in firmware, but the host system must provide
  747. * the duration field, the low-level driver uses this function to receive
  748. * the duration field value in little-endian byteorder.
  749. */
  750. __le16 ieee80211_rts_duration(struct ieee80211_hw *hw, int if_id,
  751. size_t frame_len,
  752. const struct ieee80211_tx_control *frame_txctl);
  753. /**
  754. * ieee80211_ctstoself_get - CTS-to-self frame generation function
  755. * @hw: pointer obtained from ieee80211_alloc_hw().
  756. * @if_id: interface ID from &struct ieee80211_if_init_conf.
  757. * @frame: pointer to the frame that is going to be protected by the CTS-to-self.
  758. * @frame_len: the frame length (in octets).
  759. * @frame_txctl: &struct ieee80211_tx_control of the frame.
  760. * @cts: The buffer where to store the CTS-to-self frame.
  761. *
  762. * If the CTS-to-self frames are generated by the host system (i.e., not in
  763. * hardware/firmware), the low-level driver uses this function to receive
  764. * the next CTS-to-self frame from the 802.11 code. The low-level is responsible
  765. * for calling this function before and CTS-to-self frame is needed.
  766. */
  767. void ieee80211_ctstoself_get(struct ieee80211_hw *hw, int if_id,
  768. const void *frame, size_t frame_len,
  769. const struct ieee80211_tx_control *frame_txctl,
  770. struct ieee80211_cts *cts);
  771. /**
  772. * ieee80211_ctstoself_duration - Get the duration field for a CTS-to-self frame
  773. * @hw: pointer obtained from ieee80211_alloc_hw().
  774. * @if_id: interface ID from &struct ieee80211_if_init_conf.
  775. * @frame_len: the length of the frame that is going to be protected by the CTS-to-self.
  776. * @frame_txctl: &struct ieee80211_tx_control of the frame.
  777. *
  778. * If the CTS-to-self is generated in firmware, but the host system must provide
  779. * the duration field, the low-level driver uses this function to receive
  780. * the duration field value in little-endian byteorder.
  781. */
  782. __le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw, int if_id,
  783. size_t frame_len,
  784. const struct ieee80211_tx_control *frame_txctl);
  785. /**
  786. * ieee80211_generic_frame_duration - Calculate the duration field for a frame
  787. * @hw: pointer obtained from ieee80211_alloc_hw().
  788. * @if_id: interface ID from &struct ieee80211_if_init_conf.
  789. * @frame_len: the length of the frame.
  790. * @rate: the rate (in 100kbps) at which the frame is going to be transmitted.
  791. *
  792. * Calculate the duration field of some generic frame, given its
  793. * length and transmission rate (in 100kbps).
  794. */
  795. __le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw, int if_id,
  796. size_t frame_len,
  797. int rate);
  798. /**
  799. * ieee80211_get_buffered_bc - accessing buffered broadcast and multicast frames
  800. * @hw: pointer as obtained from ieee80211_alloc_hw().
  801. * @if_id: interface ID from &struct ieee80211_if_init_conf.
  802. * @control: will be filled with information needed to send returned frame.
  803. *
  804. * Function for accessing buffered broadcast and multicast frames. If
  805. * hardware/firmware does not implement buffering of broadcast/multicast
  806. * frames when power saving is used, 802.11 code buffers them in the host
  807. * memory. The low-level driver uses this function to fetch next buffered
  808. * frame. In most cases, this is used when generating beacon frame. This
  809. * function returns a pointer to the next buffered skb or NULL if no more
  810. * buffered frames are available.
  811. *
  812. * Note: buffered frames are returned only after DTIM beacon frame was
  813. * generated with ieee80211_beacon_get() and the low-level driver must thus
  814. * call ieee80211_beacon_get() first. ieee80211_get_buffered_bc() returns
  815. * NULL if the previous generated beacon was not DTIM, so the low-level driver
  816. * does not need to check for DTIM beacons separately and should be able to
  817. * use common code for all beacons.
  818. */
  819. struct sk_buff *
  820. ieee80211_get_buffered_bc(struct ieee80211_hw *hw, int if_id,
  821. struct ieee80211_tx_control *control);
  822. /* Given an sk_buff with a raw 802.11 header at the data pointer this function
  823. * returns the 802.11 header length in bytes (not including encryption
  824. * headers). If the data in the sk_buff is too short to contain a valid 802.11
  825. * header the function returns 0.
  826. */
  827. int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb);
  828. /* Like ieee80211_get_hdrlen_from_skb() but takes a FC in CPU order. */
  829. int ieee80211_get_hdrlen(u16 fc);
  830. /**
  831. * ieee80211_wake_queue - wake specific queue
  832. * @hw: pointer as obtained from ieee80211_alloc_hw().
  833. * @queue: queue number (counted from zero).
  834. *
  835. * Drivers should use this function instead of netif_wake_queue.
  836. */
  837. void ieee80211_wake_queue(struct ieee80211_hw *hw, int queue);
  838. /**
  839. * ieee80211_stop_queue - stop specific queue
  840. * @hw: pointer as obtained from ieee80211_alloc_hw().
  841. * @queue: queue number (counted from zero).
  842. *
  843. * Drivers should use this function instead of netif_stop_queue.
  844. */
  845. void ieee80211_stop_queue(struct ieee80211_hw *hw, int queue);
  846. /**
  847. * ieee80211_start_queues - start all queues
  848. * @hw: pointer to as obtained from ieee80211_alloc_hw().
  849. *
  850. * Drivers should use this function instead of netif_start_queue.
  851. */
  852. void ieee80211_start_queues(struct ieee80211_hw *hw);
  853. /**
  854. * ieee80211_stop_queues - stop all queues
  855. * @hw: pointer as obtained from ieee80211_alloc_hw().
  856. *
  857. * Drivers should use this function instead of netif_stop_queue.
  858. */
  859. void ieee80211_stop_queues(struct ieee80211_hw *hw);
  860. /**
  861. * ieee80211_wake_queues - wake all queues
  862. * @hw: pointer as obtained from ieee80211_alloc_hw().
  863. *
  864. * Drivers should use this function instead of netif_wake_queue.
  865. */
  866. void ieee80211_wake_queues(struct ieee80211_hw *hw);
  867. /**
  868. * ieee80211_get_mc_list_item - iteration over items in multicast list
  869. * @hw: pointer as obtained from ieee80211_alloc_hw().
  870. * @prev: value returned by previous call to ieee80211_get_mc_list_item() or
  871. * NULL to start a new iteration.
  872. * @ptr: pointer to buffer of void * type for internal usage of
  873. * ieee80211_get_mc_list_item().
  874. *
  875. * Iterates over items in multicast list of given device. To get the first
  876. * item, pass NULL in @prev and in *@ptr. In subsequent calls, pass the
  877. * value returned by previous call in @prev. Don't alter *@ptr during
  878. * iteration. When there are no more items, NULL is returned.
  879. */
  880. struct dev_mc_list *
  881. ieee80211_get_mc_list_item(struct ieee80211_hw *hw,
  882. struct dev_mc_list *prev,
  883. void **ptr);
  884. /* called by driver to notify scan status completed */
  885. void ieee80211_scan_completed(struct ieee80211_hw *hw);
  886. /* Function to indicate Radar Detection. The low level driver must call this
  887. * function to indicate the presence of radar in the current channel.
  888. * Additionally the radar type also could be sent */
  889. int ieee80211_radar_status(struct ieee80211_hw *hw, int channel,
  890. int radar, int radar_type);
  891. /* return a pointer to the source address (SA) */
  892. static inline u8 *ieee80211_get_SA(struct ieee80211_hdr *hdr)
  893. {
  894. u8 *raw = (u8 *) hdr;
  895. u8 tofrom = (*(raw+1)) & 3; /* get the TODS and FROMDS bits */
  896. switch (tofrom) {
  897. case 2:
  898. return hdr->addr3;
  899. case 3:
  900. return hdr->addr4;
  901. }
  902. return hdr->addr2;
  903. }
  904. /* return a pointer to the destination address (DA) */
  905. static inline u8 *ieee80211_get_DA(struct ieee80211_hdr *hdr)
  906. {
  907. u8 *raw = (u8 *) hdr;
  908. u8 to_ds = (*(raw+1)) & 1; /* get the TODS bit */
  909. if (to_ds)
  910. return hdr->addr3;
  911. return hdr->addr1;
  912. }
  913. static inline int ieee80211_get_morefrag(struct ieee80211_hdr *hdr)
  914. {
  915. return (le16_to_cpu(hdr->frame_control) &
  916. IEEE80211_FCTL_MOREFRAGS) != 0;
  917. }
  918. #define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
  919. #define MAC_ARG(x) ((u8*)(x))[0], ((u8*)(x))[1], ((u8*)(x))[2], \
  920. ((u8*)(x))[3], ((u8*)(x))[4], ((u8*)(x))[5]
  921. #endif /* MAC80211_H */