mac80211.h 40 KB

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