mac80211.h 41 KB

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