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