mac80211.h 40 KB

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