mac80211.h 40 KB

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