blob: 7d9dc20ee42f3976a2dbd87d4419cf2259b7b883 [file] [log] [blame]
Jiri Bencf0706e822007-05-05 11:45:53 -07001/*
Johannes Berg3017b802007-08-28 17:01:53 -04002 * mac80211 <-> driver interface
3 *
Jiri Bencf0706e822007-05-05 11:45:53 -07004 * Copyright 2002-2005, Devicescape Software, Inc.
5 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
Johannes Berg3017b802007-08-28 17:01:53 -04006 * Copyright 2007 Johannes Berg <johannes@sipsolutions.net>
Jiri Bencf0706e822007-05-05 11:45:53 -07007 *
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 */
61struct 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
Jiri Bencf0706e822007-05-05 11:45:53 -070076#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
Johannes Bergb708e612007-09-14 11:10:25 -040082/* Low-level driver should set PREAMBLE2, OFDM and CCK flags.
Jiri Bencf0706e822007-05-05 11:45:53 -070083 * BASIC, SUPPORTED, ERP, and MANDATORY flags are set in 80211.o based on the
84 * configuration. */
85struct 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/* 802.11g is backwards-compatible with 802.11b, so a wlan card can
102 * actually be both in 11b and 11g modes at the same time. */
Johannes Bergb708e612007-09-14 11:10:25 -0400103enum ieee80211_phymode {
Jiri Bencf0706e822007-05-05 11:45:53 -0700104 MODE_IEEE80211A, /* IEEE 802.11a */
105 MODE_IEEE80211B, /* IEEE 802.11b only */
Jiri Bencf0706e822007-05-05 11:45:53 -0700106 MODE_IEEE80211G, /* IEEE 802.11g (and 802.11b compatibility) */
Jiri Bencf0706e822007-05-05 11:45:53 -0700107
108 /* keep last */
109 NUM_IEEE80211_MODES
110};
111
112struct ieee80211_hw_mode {
113 int mode; /* MODE_IEEE80211... */
114 int num_channels; /* Number of channels (below) */
115 struct ieee80211_channel *channels; /* Array of supported channels */
116 int num_rates; /* Number of rates (below) */
117 struct ieee80211_rate *rates; /* Array of supported rates */
118
119 struct list_head list; /* Internal, don't touch */
120};
121
122struct ieee80211_tx_queue_params {
123 int aifs; /* 0 .. 255; -1 = use default */
124 int cw_min; /* 2^n-1: 1, 3, 7, .. , 1023; 0 = use default */
125 int cw_max; /* 2^n-1: 1, 3, 7, .. , 1023; 0 = use default */
126 int burst_time; /* maximum burst time in 0.1 ms (i.e., 10 = 1 ms);
127 * 0 = disabled */
128};
129
130struct ieee80211_tx_queue_stats_data {
131 unsigned int len; /* num packets in queue */
132 unsigned int limit; /* queue len (soft) limit */
133 unsigned int count; /* total num frames sent */
134};
135
136enum {
137 IEEE80211_TX_QUEUE_DATA0,
138 IEEE80211_TX_QUEUE_DATA1,
139 IEEE80211_TX_QUEUE_DATA2,
140 IEEE80211_TX_QUEUE_DATA3,
141 IEEE80211_TX_QUEUE_DATA4,
142 IEEE80211_TX_QUEUE_SVP,
143
144 NUM_TX_DATA_QUEUES,
145
146/* due to stupidity in the sub-ioctl userspace interface, the items in
147 * this struct need to have fixed values. As soon as it is removed, we can
148 * fix these entries. */
149 IEEE80211_TX_QUEUE_AFTER_BEACON = 6,
150 IEEE80211_TX_QUEUE_BEACON = 7
151};
152
153struct ieee80211_tx_queue_stats {
154 struct ieee80211_tx_queue_stats_data data[NUM_TX_DATA_QUEUES];
155};
156
157struct ieee80211_low_level_stats {
158 unsigned int dot11ACKFailureCount;
159 unsigned int dot11RTSFailureCount;
160 unsigned int dot11FCSErrorCount;
161 unsigned int dot11RTSSuccessCount;
162};
163
164/* Transmit control fields. This data structure is passed to low-level driver
165 * with each TX frame. The low-level driver is responsible for configuring
166 * the hardware to use given values (depending on what is supported). */
Jiri Bencf0706e822007-05-05 11:45:53 -0700167
168struct ieee80211_tx_control {
169 int tx_rate; /* Transmit rate, given as the hw specific value for the
170 * rate (from struct ieee80211_rate) */
171 int rts_cts_rate; /* Transmit rate for RTS/CTS frame, given as the hw
172 * specific value for the rate (from
173 * struct ieee80211_rate) */
174
175#define IEEE80211_TXCTL_REQ_TX_STATUS (1<<0)/* request TX status callback for
176 * this frame */
177#define IEEE80211_TXCTL_DO_NOT_ENCRYPT (1<<1) /* send this frame without
178 * encryption; e.g., for EAPOL
179 * frames */
180#define IEEE80211_TXCTL_USE_RTS_CTS (1<<2) /* use RTS-CTS before sending
181 * frame */
182#define IEEE80211_TXCTL_USE_CTS_PROTECT (1<<3) /* use CTS protection for the
183 * frame (e.g., for combined
184 * 802.11g / 802.11b networks) */
185#define IEEE80211_TXCTL_NO_ACK (1<<4) /* tell the low level not to
186 * wait for an ack */
187#define IEEE80211_TXCTL_RATE_CTRL_PROBE (1<<5)
188#define IEEE80211_TXCTL_CLEAR_DST_MASK (1<<6)
189#define IEEE80211_TXCTL_REQUEUE (1<<7)
190#define IEEE80211_TXCTL_FIRST_FRAGMENT (1<<8) /* this is a first fragment of
191 * the frame */
Ivo van Doornd5d08de2007-07-27 15:43:23 +0200192#define IEEE80211_TXCTL_LONG_RETRY_LIMIT (1<<10) /* this frame should be send
193 * using the through
194 * set_retry_limit configured
195 * long retry value */
Jiri Bencf0706e822007-05-05 11:45:53 -0700196 u32 flags; /* tx control flags defined
197 * above */
Johannes Berg6a7664d2007-09-14 11:10:25 -0400198 u8 key_idx; /* keyidx from hw->set_key(), undefined if
199 * IEEE80211_TXCTL_DO_NOT_ENCRYPT is set */
Ivo van Doornd5d08de2007-07-27 15:43:23 +0200200 u8 retry_limit; /* 1 = only first attempt, 2 = one retry, ..
201 * This could be used when set_retry_limit
202 * is not implemented by the driver */
Jiri Bencf0706e822007-05-05 11:45:53 -0700203 u8 power_level; /* per-packet transmit power level, in dBm */
204 u8 antenna_sel_tx; /* 0 = default/diversity, 1 = Ant0, 2 = Ant1 */
Jiri Bencf0706e822007-05-05 11:45:53 -0700205 u8 icv_len; /* length of the ICV/MIC field in octets */
206 u8 iv_len; /* length of the IV field in octets */
Jiri Bencf0706e822007-05-05 11:45:53 -0700207 u8 queue; /* hardware queue to use for this frame;
208 * 0 = highest, hw->queues-1 = lowest */
209 u8 sw_retry_attempt; /* number of times hw has tried to
210 * transmit frame (not incl. hw retries) */
211
212 struct ieee80211_rate *rate; /* internal 80211.o rate */
213 struct ieee80211_rate *rts_rate; /* internal 80211.o rate
214 * for RTS/CTS */
215 int alt_retry_rate; /* retry rate for the last retries, given as the
216 * hw specific value for the rate (from
217 * struct ieee80211_rate). To be used to limit
218 * packet dropping when probing higher rates, if hw
219 * supports multiple retry rates. -1 = not used */
220 int type; /* internal */
221 int ifindex; /* internal */
222};
223
Johannes Berg7ac1bd62007-09-14 11:10:25 -0400224
225/**
226 * enum mac80211_rx_flags - receive flags
227 *
228 * These flags are used with the @flag member of &struct ieee80211_rx_status.
229 * @RX_FLAG_MMIC_ERROR: Michael MIC error was reported on this frame.
230 * Use together with %RX_FLAG_MMIC_STRIPPED.
231 * @RX_FLAG_DECRYPTED: This frame was decrypted in hardware.
232 * @RX_FLAG_RADIOTAP: This frame starts with a radiotap header.
233 * @RX_FLAG_MMIC_STRIPPED: the Michael MIC is stripped off this frame,
234 * verification has been done by the hardware.
235 * @RX_FLAG_IV_STRIPPED: The IV/ICV are stripped from this frame.
236 * If this flag is set, the stack cannot do any replay detection
237 * hence the driver or hardware will have to do that.
Johannes Berg72abd812007-09-17 01:29:22 -0400238 * @RX_FLAG_FAILED_FCS_CRC: Set this flag if the FCS check failed on
239 * the frame.
240 * @RX_FLAG_FAILED_PLCP_CRC: Set this flag if the PCLP check failed on
241 * the frame.
Johannes Berg7ac1bd62007-09-14 11:10:25 -0400242 */
243enum mac80211_rx_flags {
244 RX_FLAG_MMIC_ERROR = 1<<0,
245 RX_FLAG_DECRYPTED = 1<<1,
246 RX_FLAG_RADIOTAP = 1<<2,
247 RX_FLAG_MMIC_STRIPPED = 1<<3,
248 RX_FLAG_IV_STRIPPED = 1<<4,
Johannes Berg72abd812007-09-17 01:29:22 -0400249 RX_FLAG_FAILED_FCS_CRC = 1<<5,
250 RX_FLAG_FAILED_PLCP_CRC = 1<<6,
Johannes Berg7ac1bd62007-09-14 11:10:25 -0400251};
252
253/**
254 * struct ieee80211_rx_status - receive status
255 *
256 * The low-level driver should provide this information (the subset
257 * supported by hardware) to the 802.11 code with each received
258 * frame.
259 * @mactime: MAC timestamp as defined by 802.11
260 * @freq: frequency the radio was tuned to when receiving this frame, in MHz
261 * @channel: channel the radio was tuned to
262 * @phymode: active PHY mode
263 * @ssi: signal strength when receiving this frame
264 * @signal: used as 'qual' in statistics reporting
265 * @noise: PHY noise when receiving this frame
266 * @antenna: antenna used
267 * @rate: data rate
268 * @flag: %RX_FLAG_*
269 */
Jiri Bencf0706e822007-05-05 11:45:53 -0700270struct ieee80211_rx_status {
271 u64 mactime;
Johannes Berg7ac1bd62007-09-14 11:10:25 -0400272 int freq;
Jiri Bencf0706e822007-05-05 11:45:53 -0700273 int channel;
274 int phymode;
275 int ssi;
Johannes Berg7ac1bd62007-09-14 11:10:25 -0400276 int signal;
Jiri Bencf0706e822007-05-05 11:45:53 -0700277 int noise;
278 int antenna;
279 int rate;
Jiri Bencf0706e822007-05-05 11:45:53 -0700280 int flag;
281};
282
283/* Transmit status. The low-level driver should provide this information
284 * (the subset supported by hardware) to the 802.11 code for each transmit
285 * frame. */
286struct ieee80211_tx_status {
287 /* copied ieee80211_tx_control structure */
288 struct ieee80211_tx_control control;
289
290#define IEEE80211_TX_STATUS_TX_FILTERED (1<<0)
291#define IEEE80211_TX_STATUS_ACK (1<<1) /* whether the TX frame was ACKed */
292 u32 flags; /* tx staus flags defined above */
293
294 int ack_signal; /* measured signal strength of the ACK frame */
295 int excessive_retries;
296 int retry_count;
297
298 int queue_length; /* information about TX queue */
299 int queue_number;
300};
301
302
303/**
304 * struct ieee80211_conf - configuration of the device
305 *
306 * This struct indicates how the driver shall configure the hardware.
307 *
308 * @radio_enabled: when zero, driver is required to switch off the radio.
309 */
310struct ieee80211_conf {
311 int channel; /* IEEE 802.11 channel number */
312 int freq; /* MHz */
313 int channel_val; /* hw specific value for the channel */
314
315 int phymode; /* MODE_IEEE80211A, .. */
316 struct ieee80211_channel *chan;
317 struct ieee80211_hw_mode *mode;
318 unsigned int regulatory_domain;
319 int radio_enabled;
320
321 int beacon_int;
322
323#define IEEE80211_CONF_SHORT_SLOT_TIME (1<<0) /* use IEEE 802.11g Short Slot
324 * Time */
325#define IEEE80211_CONF_SSID_HIDDEN (1<<1) /* do not broadcast the ssid */
326#define IEEE80211_CONF_RADIOTAP (1<<2) /* use radiotap if supported
327 check this bit at RX time */
328 u32 flags; /* configuration flags defined above */
329
330 u8 power_level; /* transmit power limit for current
331 * regulatory domain; in dBm */
332 u8 antenna_max; /* maximum antenna gain */
Jiri Bencf0706e822007-05-05 11:45:53 -0700333
334 /* 0 = default/diversity, 1 = Ant0, 2 = Ant1 */
335 u8 antenna_sel_tx;
336 u8 antenna_sel_rx;
Jiri Bencf0706e822007-05-05 11:45:53 -0700337};
338
339/**
340 * enum ieee80211_if_types - types of 802.11 network interfaces
341 *
342 * @IEEE80211_IF_TYPE_AP: interface in AP mode.
343 * @IEEE80211_IF_TYPE_MGMT: special interface for communication with hostap
344 * daemon. Drivers should never see this type.
345 * @IEEE80211_IF_TYPE_STA: interface in STA (client) mode.
346 * @IEEE80211_IF_TYPE_IBSS: interface in IBSS (ad-hoc) mode.
347 * @IEEE80211_IF_TYPE_MNTR: interface in monitor (rfmon) mode.
348 * @IEEE80211_IF_TYPE_WDS: interface in WDS mode.
349 * @IEEE80211_IF_TYPE_VLAN: not used.
350 */
351enum ieee80211_if_types {
352 IEEE80211_IF_TYPE_AP = 0x00000000,
353 IEEE80211_IF_TYPE_MGMT = 0x00000001,
354 IEEE80211_IF_TYPE_STA = 0x00000002,
355 IEEE80211_IF_TYPE_IBSS = 0x00000003,
356 IEEE80211_IF_TYPE_MNTR = 0x00000004,
357 IEEE80211_IF_TYPE_WDS = 0x5A580211,
358 IEEE80211_IF_TYPE_VLAN = 0x00080211,
359};
360
361/**
362 * struct ieee80211_if_init_conf - initial configuration of an interface
363 *
364 * @if_id: internal interface ID. This number has no particular meaning to
365 * drivers and the only allowed usage is to pass it to
366 * ieee80211_beacon_get() and ieee80211_get_buffered_bc() functions.
367 * This field is not valid for monitor interfaces
368 * (interfaces of %IEEE80211_IF_TYPE_MNTR type).
369 * @type: one of &enum ieee80211_if_types constants. Determines the type of
370 * added/removed interface.
371 * @mac_addr: pointer to MAC address of the interface. This pointer is valid
372 * until the interface is removed (i.e. it cannot be used after
373 * remove_interface() callback was called for this interface).
Johannes Berg4480f15c2007-07-10 19:32:10 +0200374 * This pointer will be %NULL for monitor interfaces, be careful.
Jiri Bencf0706e822007-05-05 11:45:53 -0700375 *
376 * This structure is used in add_interface() and remove_interface()
377 * callbacks of &struct ieee80211_hw.
Johannes Berg4480f15c2007-07-10 19:32:10 +0200378 *
379 * When you allow multiple interfaces to be added to your PHY, take care
380 * that the hardware can actually handle multiple MAC addresses. However,
381 * also take care that when there's no interface left with mac_addr != %NULL
382 * you remove the MAC address from the device to avoid acknowledging packets
383 * in pure monitor mode.
Jiri Bencf0706e822007-05-05 11:45:53 -0700384 */
385struct ieee80211_if_init_conf {
386 int if_id;
387 int type;
388 void *mac_addr;
389};
390
391/**
392 * struct ieee80211_if_conf - configuration of an interface
393 *
394 * @type: type of the interface. This is always the same as was specified in
395 * &struct ieee80211_if_init_conf. The type of an interface never changes
396 * during the life of the interface; this field is present only for
397 * convenience.
398 * @bssid: BSSID of the network we are associated to/creating.
399 * @ssid: used (together with @ssid_len) by drivers for hardware that
400 * generate beacons independently. The pointer is valid only during the
401 * config_interface() call, so copy the value somewhere if you need
402 * it.
403 * @ssid_len: length of the @ssid field.
404 * @generic_elem: used (together with @generic_elem_len) by drivers for
405 * hardware that generate beacons independently. The pointer is valid
406 * only during the config_interface() call, so copy the value somewhere
407 * if you need it.
408 * @generic_elem_len: length of the generic element.
409 * @beacon: beacon template. Valid only if @host_gen_beacon_template in
410 * &struct ieee80211_hw is set. The driver is responsible of freeing
411 * the sk_buff.
412 * @beacon_control: tx_control for the beacon template, this field is only
413 * valid when the @beacon field was set.
414 *
415 * This structure is passed to the config_interface() callback of
416 * &struct ieee80211_hw.
417 */
418struct ieee80211_if_conf {
419 int type;
420 u8 *bssid;
421 u8 *ssid;
422 size_t ssid_len;
423 u8 *generic_elem;
424 size_t generic_elem_len;
425 struct sk_buff *beacon;
426 struct ieee80211_tx_control *beacon_control;
427};
428
Johannes Berg7ac1bd62007-09-14 11:10:25 -0400429/**
430 * enum ieee80211_key_alg - key algorithm
431 * @ALG_NONE: Unset key algorithm, will never be passed to the driver
432 * @ALG_WEP: WEP40 or WEP104
433 * @ALG_TKIP: TKIP
434 * @ALG_CCMP: CCMP (AES)
435 */
436typedef enum ieee80211_key_alg {
Johannes Berg8f20fc22007-08-28 17:01:54 -0400437 ALG_NONE,
438 ALG_WEP,
439 ALG_TKIP,
440 ALG_CCMP,
441} ieee80211_key_alg;
Jiri Bencf0706e822007-05-05 11:45:53 -0700442
Johannes Berg11a843b2007-08-28 17:01:55 -0400443
Johannes Berg7ac1bd62007-09-14 11:10:25 -0400444/**
445 * enum ieee80211_key_flags - key flags
446 *
447 * These flags are used for communication about keys between the driver
448 * and mac80211, with the @flags parameter of &struct ieee80211_key_conf.
449 *
450 * @IEEE80211_KEY_FLAG_WMM_STA: Set by mac80211, this flag indicates
451 * that the STA this key will be used with could be using QoS.
452 * @IEEE80211_KEY_FLAG_GENERATE_IV: This flag should be set by the
453 * driver to indicate that it requires IV generation for this
454 * particular key.
455 * @IEEE80211_KEY_FLAG_GENERATE_MMIC: This flag should be set by
456 * the driver for a TKIP key if it requires Michael MIC
457 * generation in software.
458 */
459enum ieee80211_key_flags {
460 IEEE80211_KEY_FLAG_WMM_STA = 1<<0,
461 IEEE80211_KEY_FLAG_GENERATE_IV = 1<<1,
462 IEEE80211_KEY_FLAG_GENERATE_MMIC= 1<<2,
463};
464
465/**
466 * struct ieee80211_key_conf - key information
467 *
468 * This key information is given by mac80211 to the driver by
469 * the set_key() callback in &struct ieee80211_ops.
470 *
471 * @hw_key_idx: To be set by the driver, this is the key index the driver
472 * wants to be given when a frame is transmitted and needs to be
Johannes Berg6a7664d2007-09-14 11:10:25 -0400473 * encrypted in hardware.
Johannes Berg7ac1bd62007-09-14 11:10:25 -0400474 * @alg: The key algorithm.
475 * @flags: key flags, see &enum ieee80211_key_flags.
476 * @keyidx: the key index (0-3)
477 * @keylen: key material length
478 * @key: key material
479 */
Jiri Bencf0706e822007-05-05 11:45:53 -0700480struct ieee80211_key_conf {
Jiri Bencf0706e822007-05-05 11:45:53 -0700481 ieee80211_key_alg alg;
Johannes Berg6a7664d2007-09-14 11:10:25 -0400482 u8 hw_key_idx;
Johannes Berg11a843b2007-08-28 17:01:55 -0400483 u8 flags;
Johannes Berg11a843b2007-08-28 17:01:55 -0400484 s8 keyidx;
Johannes Berg11a843b2007-08-28 17:01:55 -0400485 u8 keylen;
Jiri Bencf0706e822007-05-05 11:45:53 -0700486 u8 key[0];
487};
488
489#define IEEE80211_SEQ_COUNTER_RX 0
490#define IEEE80211_SEQ_COUNTER_TX 1
491
Johannes Berg7ac1bd62007-09-14 11:10:25 -0400492/**
493 * enum set_key_cmd - key command
494 *
495 * Used with the set_key() callback in &struct ieee80211_ops, this
496 * indicates whether a key is being removed or added.
497 *
498 * @SET_KEY: a key is set
499 * @DISABLE_KEY: a key must be disabled
500 */
501typedef enum set_key_cmd {
Johannes Berg11a843b2007-08-28 17:01:55 -0400502 SET_KEY, DISABLE_KEY,
Jiri Bencf0706e822007-05-05 11:45:53 -0700503} set_key_cmd;
504
Johannes Berg7ac1bd62007-09-14 11:10:25 -0400505/**
506 * struct ieee80211_hw - hardware information and state
507 * TODO: move documentation into kernel-doc format
508 */
Jiri Bencf0706e822007-05-05 11:45:53 -0700509struct ieee80211_hw {
510 /* points to the cfg80211 wiphy for this piece. Note
511 * that you must fill in the perm_addr and dev fields
512 * of this structure, use the macros provided below. */
513 struct wiphy *wiphy;
514
515 /* assigned by mac80211, don't write */
516 struct ieee80211_conf conf;
517
518 /* Single thread workqueue available for driver use
519 * Allocated by mac80211 on registration */
520 struct workqueue_struct *workqueue;
521
522 /* Pointer to the private area that was
523 * allocated with this struct for you. */
524 void *priv;
525
526 /* The rest is information about your hardware */
527
528 /* TODO: frame_type 802.11/802.3, sw_encryption requirements */
529
Johannes Berg0ef6e492007-08-28 17:01:52 -0400530/* hole at 0 */
Jiri Bencf0706e822007-05-05 11:45:53 -0700531
Johannes Berg0ef6e492007-08-28 17:01:52 -0400532 /*
533 * The device only needs to be supplied with a beacon template.
534 * If you need the host to generate each beacon then don't use
535 * this flag and use ieee80211_beacon_get().
536 */
Jiri Bencf0706e822007-05-05 11:45:53 -0700537#define IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE (1<<1)
538
Johannes Berg7848ba72007-09-14 11:10:25 -0400539/* hole at 2 */
Jiri Bencf0706e822007-05-05 11:45:53 -0700540
541 /* Whether RX frames passed to ieee80211_rx() include FCS in the end */
542#define IEEE80211_HW_RX_INCLUDES_FCS (1<<3)
543
544 /* Some wireless LAN chipsets buffer broadcast/multicast frames for
545 * power saving stations in the hardware/firmware and others rely on
546 * the host system for such buffering. This option is used to
547 * configure the IEEE 802.11 upper layer to buffer broadcast/multicast
548 * frames when there are power saving stations so that low-level driver
549 * can fetch them with ieee80211_get_buffered_bc(). */
550#define IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING (1<<4)
551
Johannes Berg7848ba72007-09-14 11:10:25 -0400552/* hole at 5 */
Jiri Bencf0706e822007-05-05 11:45:53 -0700553
Johannes Bergaaa92e92007-09-06 03:36:10 -0700554/* hole at 6 */
Jiri Bencf0706e822007-05-05 11:45:53 -0700555
Johannes Berg11a843b2007-08-28 17:01:55 -0400556/* hole at 7 */
Jiri Bencf0706e822007-05-05 11:45:53 -0700557
Johannes Berg7848ba72007-09-14 11:10:25 -0400558/* hole at 8 */
Jiri Bencf0706e822007-05-05 11:45:53 -0700559
560 /* Device is capable of performing full monitor mode even during
561 * normal operation. */
562#define IEEE80211_HW_MONITOR_DURING_OPER (1<<9)
563
564 /* Device does not need BSSID filter set to broadcast in order to
565 * receive all probe responses while scanning */
566#define IEEE80211_HW_NO_PROBE_FILTERING (1<<10)
567
568 /* Channels are already configured to the default regulatory domain
569 * specified in the device's EEPROM */
570#define IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED (1<<11)
571
Jiri Bencf0706e822007-05-05 11:45:53 -0700572 u32 flags; /* hardware flags defined above */
573
574 /* Set to the size of a needed device specific skb headroom for TX skbs. */
575 unsigned int extra_tx_headroom;
576
577 /* This is the time in us to change channels
578 */
579 int channel_change_time;
580 /* Maximum values for various statistics.
581 * Leave at 0 to indicate no support. Use negative numbers for dBm. */
582 s8 max_rssi;
583 s8 max_signal;
584 s8 max_noise;
585
586 /* Number of available hardware TX queues for data packets.
587 * WMM requires at least four queues. */
588 int queues;
589};
590
591static inline void SET_IEEE80211_DEV(struct ieee80211_hw *hw, struct device *dev)
592{
593 set_wiphy_dev(hw->wiphy, dev);
594}
595
596static inline void SET_IEEE80211_PERM_ADDR(struct ieee80211_hw *hw, u8 *addr)
597{
598 memcpy(hw->wiphy->perm_addr, addr, ETH_ALEN);
599}
600
601/* Configuration block used by the low-level driver to tell the 802.11 code
602 * about supported hardware features and to pass function pointers to callback
603 * functions. */
604struct ieee80211_ops {
605 /* Handler that 802.11 module calls for each transmitted frame.
606 * skb contains the buffer starting from the IEEE 802.11 header.
607 * The low-level driver should send the frame out based on
608 * configuration in the TX control data.
609 * Must be atomic. */
610 int (*tx)(struct ieee80211_hw *hw, struct sk_buff *skb,
611 struct ieee80211_tx_control *control);
612
Jiri Bencf0706e822007-05-05 11:45:53 -0700613 /* Handler that is called when any netdevice attached to the hardware
614 * device is set UP for the first time. This can be used, e.g., to
615 * enable interrupts and beacon sending. */
616 int (*open)(struct ieee80211_hw *hw);
617
618 /* Handler that is called when the last netdevice attached to the
619 * hardware device is set DOWN. This can be used, e.g., to disable
620 * interrupts and beacon sending. */
621 int (*stop)(struct ieee80211_hw *hw);
622
623 /* Handler for asking a driver if a new interface can be added (or,
624 * more exactly, set UP). If the handler returns zero, the interface
625 * is added. Driver should perform any initialization it needs prior
626 * to returning zero. By returning non-zero addition of the interface
627 * is inhibited. Unless monitor_during_oper is set, it is guaranteed
628 * that monitor interfaces and normal interfaces are mutually
Johannes Berg4480f15c2007-07-10 19:32:10 +0200629 * exclusive. If assigned, the open() handler is called after
630 * add_interface() if this is the first device added. The
631 * add_interface() callback has to be assigned because it is the only
632 * way to obtain the requested MAC address for any interface.
633 */
Jiri Bencf0706e822007-05-05 11:45:53 -0700634 int (*add_interface)(struct ieee80211_hw *hw,
635 struct ieee80211_if_init_conf *conf);
636
637 /* Notify a driver that an interface is going down. The stop() handler
638 * is called prior to this if this is a last interface. */
639 void (*remove_interface)(struct ieee80211_hw *hw,
640 struct ieee80211_if_init_conf *conf);
641
642 /* Handler for configuration requests. IEEE 802.11 code calls this
643 * function to change hardware configuration, e.g., channel. */
644 int (*config)(struct ieee80211_hw *hw, struct ieee80211_conf *conf);
645
646 /* Handler for configuration requests related to interfaces (e.g.
647 * BSSID). */
648 int (*config_interface)(struct ieee80211_hw *hw,
649 int if_id, struct ieee80211_if_conf *conf);
650
651 /* ieee80211 drivers do not have access to the &struct net_device
652 * that is (are) connected with their device. Hence (and because
653 * we need to combine the multicast lists and flags for multiple
654 * virtual interfaces), they cannot assign set_multicast_list.
655 * The parameters here replace dev->flags and dev->mc_count,
656 * dev->mc_list is replaced by calling ieee80211_get_mc_list_item.
657 * Must be atomic. */
658 void (*set_multicast_list)(struct ieee80211_hw *hw,
659 unsigned short flags, int mc_count);
660
661 /* Set TIM bit handler. If the hardware/firmware takes care of beacon
662 * generation, IEEE 802.11 code uses this function to tell the
663 * low-level to set (or clear if set==0) TIM bit for the given aid. If
664 * host system is used to generate beacons, this handler is not used
665 * and low-level driver should set it to NULL.
666 * Must be atomic. */
667 int (*set_tim)(struct ieee80211_hw *hw, int aid, int set);
668
Johannes Berg8f20fc22007-08-28 17:01:54 -0400669 /*
670 * Set encryption key.
671 *
672 * This is called to enable hardware acceleration of encryption and
673 * decryption. The address will be the broadcast address for default
Johannes Berg11a843b2007-08-28 17:01:55 -0400674 * keys, the other station's hardware address for individual keys or
675 * the zero address for keys that will be used only for transmission.
676 *
677 * The local_address parameter will always be set to our own address,
678 * this is only relevant if you support multiple local addresses.
679 *
Johannes Berg8f20fc22007-08-28 17:01:54 -0400680 * When transmitting, the TX control data will use the hw_key_idx
681 * selected by the low-level driver.
Johannes Berg11a843b2007-08-28 17:01:55 -0400682 *
683 * Return 0 if the key is now in use, -EOPNOTSUPP or -ENOSPC if it
Johannes Berg6a7664d2007-09-14 11:10:25 -0400684 * couldn't be added; if you return 0 then hw_key_idx must be assigned
685 * to the hardware key index, you are free to use the full u8 range.
686 *
687 * When the cmd is DISABLE_KEY then it must succeed.
Johannes Berg11a843b2007-08-28 17:01:55 -0400688 *
Johannes Berg7ac1bd62007-09-14 11:10:25 -0400689 * Note that it is permissible to not decrypt a frame even if a key
690 * for it has been uploaded to hardware, the stack will not make any
691 * decision based on whether a key has been uploaded or not but rather
692 * based on the receive flags.
693 *
Johannes Berg11a843b2007-08-28 17:01:55 -0400694 * This callback can sleep, and is only called between add_interface
695 * and remove_interface calls, i.e. while the interface with the
696 * given local_address is enabled.
697 *
698 * The ieee80211_key_conf structure pointed to by the key parameter
699 * is guaranteed to be valid until another call to set_key removes
700 * it, but it can only be used as a cookie to differentiate keys.
Johannes Berg8f20fc22007-08-28 17:01:54 -0400701 */
Jiri Bencf0706e822007-05-05 11:45:53 -0700702 int (*set_key)(struct ieee80211_hw *hw, set_key_cmd cmd,
Johannes Berg11a843b2007-08-28 17:01:55 -0400703 const u8 *local_address, const u8 *address,
704 struct ieee80211_key_conf *key);
Jiri Bencf0706e822007-05-05 11:45:53 -0700705
Jiri Bencf0706e822007-05-05 11:45:53 -0700706 /* Enable/disable IEEE 802.1X. This item requests wlan card to pass
707 * unencrypted EAPOL-Key frames even when encryption is configured.
708 * If the wlan card does not require such a configuration, this
709 * function pointer can be set to NULL. */
710 int (*set_ieee8021x)(struct ieee80211_hw *hw, int use_ieee8021x);
711
712 /* Set port authorization state (IEEE 802.1X PAE) to be authorized
713 * (authorized=1) or unauthorized (authorized=0). This function can be
714 * used if the wlan hardware or low-level driver implements PAE.
715 * 80211.o module will anyway filter frames based on authorization
716 * state, so this function pointer can be NULL if low-level driver does
717 * not require event notification about port state changes.
718 * Currently unused. */
719 int (*set_port_auth)(struct ieee80211_hw *hw, u8 *addr,
720 int authorized);
721
722 /* Ask the hardware to service the scan request, no need to start
723 * the scan state machine in stack. */
724 int (*hw_scan)(struct ieee80211_hw *hw, u8 *ssid, size_t len);
725
726 /* return low-level statistics */
727 int (*get_stats)(struct ieee80211_hw *hw,
728 struct ieee80211_low_level_stats *stats);
729
730 /* For devices that generate their own beacons and probe response
731 * or association responses this updates the state of privacy_invoked
732 * returns 0 for success or an error number */
733 int (*set_privacy_invoked)(struct ieee80211_hw *hw,
734 int privacy_invoked);
735
736 /* For devices that have internal sequence counters, allow 802.11
737 * code to access the current value of a counter */
738 int (*get_sequence_counter)(struct ieee80211_hw *hw,
739 u8* addr, u8 keyidx, u8 txrx,
740 u32* iv32, u16* iv16);
741
742 /* Configuration of RTS threshold (if device needs it) */
743 int (*set_rts_threshold)(struct ieee80211_hw *hw, u32 value);
744
745 /* Configuration of fragmentation threshold.
746 * Assign this if the device does fragmentation by itself,
747 * if this method is assigned then the stack will not do
748 * fragmentation. */
749 int (*set_frag_threshold)(struct ieee80211_hw *hw, u32 value);
750
751 /* Configuration of retry limits (if device needs it) */
752 int (*set_retry_limit)(struct ieee80211_hw *hw,
753 u32 short_retry, u32 long_retr);
754
755 /* Number of STAs in STA table notification (NULL = disabled).
756 * Must be atomic. */
757 void (*sta_table_notification)(struct ieee80211_hw *hw,
758 int num_sta);
759
Daniel Draked9430a32007-07-27 15:43:24 +0200760 /* Handle ERP IE change notifications. Must be atomic. */
761 void (*erp_ie_changed)(struct ieee80211_hw *hw, u8 changes,
762 int cts_protection, int preamble);
763
764 /* Flags for the erp_ie_changed changes parameter */
765#define IEEE80211_ERP_CHANGE_PROTECTION (1<<0) /* protection flag changed */
766#define IEEE80211_ERP_CHANGE_PREAMBLE (1<<1) /* barker preamble mode changed */
767
Jiri Bencf0706e822007-05-05 11:45:53 -0700768 /* Configure TX queue parameters (EDCF (aifs, cw_min, cw_max),
769 * bursting) for a hardware TX queue.
770 * queue = IEEE80211_TX_QUEUE_*.
771 * Must be atomic. */
772 int (*conf_tx)(struct ieee80211_hw *hw, int queue,
773 const struct ieee80211_tx_queue_params *params);
774
775 /* Get statistics of the current TX queue status. This is used to get
776 * number of currently queued packets (queue length), maximum queue
777 * size (limit), and total number of packets sent using each TX queue
778 * (count).
779 * Currently unused. */
780 int (*get_tx_stats)(struct ieee80211_hw *hw,
781 struct ieee80211_tx_queue_stats *stats);
782
783 /* Get the current TSF timer value from firmware/hardware. Currently,
784 * this is only used for IBSS mode debugging and, as such, is not a
785 * required function.
786 * Must be atomic. */
787 u64 (*get_tsf)(struct ieee80211_hw *hw);
788
789 /* Reset the TSF timer and allow firmware/hardware to synchronize with
790 * other STAs in the IBSS. This is only used in IBSS mode. This
791 * function is optional if the firmware/hardware takes full care of
792 * TSF synchronization. */
793 void (*reset_tsf)(struct ieee80211_hw *hw);
794
795 /* Setup beacon data for IBSS beacons. Unlike access point (Master),
796 * IBSS uses a fixed beacon frame which is configured using this
797 * function. This handler is required only for IBSS mode. */
798 int (*beacon_update)(struct ieee80211_hw *hw,
799 struct sk_buff *skb,
800 struct ieee80211_tx_control *control);
801
802 /* Determine whether the last IBSS beacon was sent by us. This is
803 * needed only for IBSS mode and the result of this function is used to
804 * determine whether to reply to Probe Requests. */
805 int (*tx_last_beacon)(struct ieee80211_hw *hw);
806};
807
808/* Allocate a new hardware device. This must be called once for each
809 * hardware device. The returned pointer must be used to refer to this
810 * device when calling other functions. 802.11 code allocates a private data
811 * area for the low-level driver. The size of this area is given as
812 * priv_data_len.
813 */
814struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
815 const struct ieee80211_ops *ops);
816
817/* Register hardware device to the IEEE 802.11 code and kernel. Low-level
818 * drivers must call this function before using any other IEEE 802.11
819 * function except ieee80211_register_hwmode. */
820int ieee80211_register_hw(struct ieee80211_hw *hw);
821
822/* driver can use this and ieee80211_get_rx_led_name to get the
823 * name of the registered LEDs after ieee80211_register_hw
824 * was called.
825 * This is useful to set the default trigger on the LED class
826 * device that your driver should export for each LED the device
827 * has, that way the default behaviour will be as expected but
828 * the user can still change it/turn off the LED etc.
829 */
830#ifdef CONFIG_MAC80211_LEDS
831extern char *__ieee80211_get_tx_led_name(struct ieee80211_hw *hw);
832extern char *__ieee80211_get_rx_led_name(struct ieee80211_hw *hw);
833#endif
834static inline char *ieee80211_get_tx_led_name(struct ieee80211_hw *hw)
835{
836#ifdef CONFIG_MAC80211_LEDS
837 return __ieee80211_get_tx_led_name(hw);
838#else
839 return NULL;
840#endif
841}
842
843static inline char *ieee80211_get_rx_led_name(struct ieee80211_hw *hw)
844{
845#ifdef CONFIG_MAC80211_LEDS
846 return __ieee80211_get_rx_led_name(hw);
847#else
848 return NULL;
849#endif
850}
851
852/* Register a new hardware PHYMODE capability to the stack. */
853int ieee80211_register_hwmode(struct ieee80211_hw *hw,
854 struct ieee80211_hw_mode *mode);
855
856/* Unregister a hardware device. This function instructs 802.11 code to free
857 * allocated resources and unregister netdevices from the kernel. */
858void ieee80211_unregister_hw(struct ieee80211_hw *hw);
859
860/* Free everything that was allocated including private data of a driver. */
861void ieee80211_free_hw(struct ieee80211_hw *hw);
862
863/* Receive frame callback function. The low-level driver uses this function to
864 * send received frames to the IEEE 802.11 code. Receive buffer (skb) must
865 * start with IEEE 802.11 header. */
866void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb,
867 struct ieee80211_rx_status *status);
868void ieee80211_rx_irqsafe(struct ieee80211_hw *hw,
869 struct sk_buff *skb,
870 struct ieee80211_rx_status *status);
871
872/* Transmit status callback function. The low-level driver must call this
873 * function to report transmit status for all the TX frames that had
874 * req_tx_status set in the transmit control fields. In addition, this should
875 * be called at least for all unicast frames to provide information for TX rate
876 * control algorithm. In order to maintain all statistics, this function is
877 * recommended to be called after each frame, including multicast/broadcast, is
878 * sent. */
879void ieee80211_tx_status(struct ieee80211_hw *hw,
880 struct sk_buff *skb,
881 struct ieee80211_tx_status *status);
882void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw,
883 struct sk_buff *skb,
884 struct ieee80211_tx_status *status);
885
886/**
887 * ieee80211_beacon_get - beacon generation function
888 * @hw: pointer obtained from ieee80211_alloc_hw().
889 * @if_id: interface ID from &struct ieee80211_if_init_conf.
890 * @control: will be filled with information needed to send this beacon.
891 *
892 * If the beacon frames are generated by the host system (i.e., not in
893 * hardware/firmware), the low-level driver uses this function to receive
894 * the next beacon frame from the 802.11 code. The low-level is responsible
895 * for calling this function before beacon data is needed (e.g., based on
896 * hardware interrupt). Returned skb is used only once and low-level driver
897 * is responsible of freeing it.
898 */
899struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
900 int if_id,
901 struct ieee80211_tx_control *control);
902
903/**
904 * ieee80211_rts_get - RTS frame generation function
905 * @hw: pointer obtained from ieee80211_alloc_hw().
Daniel Drake7e9ed182007-07-27 15:43:24 +0200906 * @if_id: interface ID from &struct ieee80211_if_init_conf.
Jiri Bencf0706e822007-05-05 11:45:53 -0700907 * @frame: pointer to the frame that is going to be protected by the RTS.
908 * @frame_len: the frame length (in octets).
909 * @frame_txctl: &struct ieee80211_tx_control of the frame.
910 * @rts: The buffer where to store the RTS frame.
911 *
912 * If the RTS frames are generated by the host system (i.e., not in
913 * hardware/firmware), the low-level driver uses this function to receive
914 * the next RTS frame from the 802.11 code. The low-level is responsible
915 * for calling this function before and RTS frame is needed.
916 */
Daniel Drake7e9ed182007-07-27 15:43:24 +0200917void ieee80211_rts_get(struct ieee80211_hw *hw, int if_id,
Jiri Bencf0706e822007-05-05 11:45:53 -0700918 const void *frame, size_t frame_len,
919 const struct ieee80211_tx_control *frame_txctl,
920 struct ieee80211_rts *rts);
921
922/**
923 * ieee80211_rts_duration - Get the duration field for an RTS frame
924 * @hw: pointer obtained from ieee80211_alloc_hw().
Daniel Drake7e9ed182007-07-27 15:43:24 +0200925 * @if_id: interface ID from &struct ieee80211_if_init_conf.
Jiri Bencf0706e822007-05-05 11:45:53 -0700926 * @frame_len: the length of the frame that is going to be protected by the RTS.
927 * @frame_txctl: &struct ieee80211_tx_control of the frame.
928 *
929 * If the RTS is generated in firmware, but the host system must provide
930 * the duration field, the low-level driver uses this function to receive
931 * the duration field value in little-endian byteorder.
932 */
Daniel Drake7e9ed182007-07-27 15:43:24 +0200933__le16 ieee80211_rts_duration(struct ieee80211_hw *hw, int if_id,
Jiri Bencf0706e822007-05-05 11:45:53 -0700934 size_t frame_len,
935 const struct ieee80211_tx_control *frame_txctl);
936
937/**
938 * ieee80211_ctstoself_get - CTS-to-self frame generation function
939 * @hw: pointer obtained from ieee80211_alloc_hw().
Daniel Drake7e9ed182007-07-27 15:43:24 +0200940 * @if_id: interface ID from &struct ieee80211_if_init_conf.
Jiri Bencf0706e822007-05-05 11:45:53 -0700941 * @frame: pointer to the frame that is going to be protected by the CTS-to-self.
942 * @frame_len: the frame length (in octets).
943 * @frame_txctl: &struct ieee80211_tx_control of the frame.
944 * @cts: The buffer where to store the CTS-to-self frame.
945 *
946 * If the CTS-to-self frames are generated by the host system (i.e., not in
947 * hardware/firmware), the low-level driver uses this function to receive
948 * the next CTS-to-self frame from the 802.11 code. The low-level is responsible
949 * for calling this function before and CTS-to-self frame is needed.
950 */
Daniel Drake7e9ed182007-07-27 15:43:24 +0200951void ieee80211_ctstoself_get(struct ieee80211_hw *hw, int if_id,
Jiri Bencf0706e822007-05-05 11:45:53 -0700952 const void *frame, size_t frame_len,
953 const struct ieee80211_tx_control *frame_txctl,
954 struct ieee80211_cts *cts);
955
956/**
957 * ieee80211_ctstoself_duration - Get the duration field for a CTS-to-self frame
958 * @hw: pointer obtained from ieee80211_alloc_hw().
Daniel Drake7e9ed182007-07-27 15:43:24 +0200959 * @if_id: interface ID from &struct ieee80211_if_init_conf.
Jiri Bencf0706e822007-05-05 11:45:53 -0700960 * @frame_len: the length of the frame that is going to be protected by the CTS-to-self.
961 * @frame_txctl: &struct ieee80211_tx_control of the frame.
962 *
963 * If the CTS-to-self is generated in firmware, but the host system must provide
964 * the duration field, the low-level driver uses this function to receive
965 * the duration field value in little-endian byteorder.
966 */
Daniel Drake7e9ed182007-07-27 15:43:24 +0200967__le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw, int if_id,
Jiri Bencf0706e822007-05-05 11:45:53 -0700968 size_t frame_len,
969 const struct ieee80211_tx_control *frame_txctl);
970
971/**
972 * ieee80211_generic_frame_duration - Calculate the duration field for a frame
973 * @hw: pointer obtained from ieee80211_alloc_hw().
Daniel Drake7e9ed182007-07-27 15:43:24 +0200974 * @if_id: interface ID from &struct ieee80211_if_init_conf.
Jiri Bencf0706e822007-05-05 11:45:53 -0700975 * @frame_len: the length of the frame.
976 * @rate: the rate (in 100kbps) at which the frame is going to be transmitted.
977 *
978 * Calculate the duration field of some generic frame, given its
979 * length and transmission rate (in 100kbps).
980 */
Daniel Drake7e9ed182007-07-27 15:43:24 +0200981__le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw, int if_id,
Jiri Bencf0706e822007-05-05 11:45:53 -0700982 size_t frame_len,
983 int rate);
984
985/**
986 * ieee80211_get_buffered_bc - accessing buffered broadcast and multicast frames
987 * @hw: pointer as 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 returned frame.
990 *
991 * Function for accessing buffered broadcast and multicast frames. If
992 * hardware/firmware does not implement buffering of broadcast/multicast
993 * frames when power saving is used, 802.11 code buffers them in the host
994 * memory. The low-level driver uses this function to fetch next buffered
995 * frame. In most cases, this is used when generating beacon frame. This
996 * function returns a pointer to the next buffered skb or NULL if no more
997 * buffered frames are available.
998 *
999 * Note: buffered frames are returned only after DTIM beacon frame was
1000 * generated with ieee80211_beacon_get() and the low-level driver must thus
1001 * call ieee80211_beacon_get() first. ieee80211_get_buffered_bc() returns
1002 * NULL if the previous generated beacon was not DTIM, so the low-level driver
1003 * does not need to check for DTIM beacons separately and should be able to
1004 * use common code for all beacons.
1005 */
1006struct sk_buff *
1007ieee80211_get_buffered_bc(struct ieee80211_hw *hw, int if_id,
1008 struct ieee80211_tx_control *control);
1009
Jiri Bencf0706e822007-05-05 11:45:53 -07001010/* Given an sk_buff with a raw 802.11 header at the data pointer this function
1011 * returns the 802.11 header length in bytes (not including encryption
1012 * headers). If the data in the sk_buff is too short to contain a valid 802.11
1013 * header the function returns 0.
1014 */
1015int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb);
1016
1017/* Like ieee80211_get_hdrlen_from_skb() but takes a FC in CPU order. */
1018int ieee80211_get_hdrlen(u16 fc);
1019
1020/**
1021 * ieee80211_wake_queue - wake specific queue
1022 * @hw: pointer as obtained from ieee80211_alloc_hw().
1023 * @queue: queue number (counted from zero).
1024 *
1025 * Drivers should use this function instead of netif_wake_queue.
1026 */
1027void ieee80211_wake_queue(struct ieee80211_hw *hw, int queue);
1028
1029/**
1030 * ieee80211_stop_queue - stop specific queue
1031 * @hw: pointer as obtained from ieee80211_alloc_hw().
1032 * @queue: queue number (counted from zero).
1033 *
1034 * Drivers should use this function instead of netif_stop_queue.
1035 */
1036void ieee80211_stop_queue(struct ieee80211_hw *hw, int queue);
1037
1038/**
1039 * ieee80211_start_queues - start all queues
1040 * @hw: pointer to as obtained from ieee80211_alloc_hw().
1041 *
1042 * Drivers should use this function instead of netif_start_queue.
1043 */
1044void ieee80211_start_queues(struct ieee80211_hw *hw);
1045
1046/**
1047 * ieee80211_stop_queues - stop all queues
1048 * @hw: pointer as obtained from ieee80211_alloc_hw().
1049 *
1050 * Drivers should use this function instead of netif_stop_queue.
1051 */
1052void ieee80211_stop_queues(struct ieee80211_hw *hw);
1053
1054/**
1055 * ieee80211_wake_queues - wake all queues
1056 * @hw: pointer as obtained from ieee80211_alloc_hw().
1057 *
1058 * Drivers should use this function instead of netif_wake_queue.
1059 */
1060void ieee80211_wake_queues(struct ieee80211_hw *hw);
1061
1062/**
1063 * ieee80211_get_mc_list_item - iteration over items in multicast list
1064 * @hw: pointer as obtained from ieee80211_alloc_hw().
1065 * @prev: value returned by previous call to ieee80211_get_mc_list_item() or
1066 * NULL to start a new iteration.
1067 * @ptr: pointer to buffer of void * type for internal usage of
1068 * ieee80211_get_mc_list_item().
1069 *
1070 * Iterates over items in multicast list of given device. To get the first
1071 * item, pass NULL in @prev and in *@ptr. In subsequent calls, pass the
1072 * value returned by previous call in @prev. Don't alter *@ptr during
1073 * iteration. When there are no more items, NULL is returned.
1074 */
1075struct dev_mc_list *
1076ieee80211_get_mc_list_item(struct ieee80211_hw *hw,
1077 struct dev_mc_list *prev,
1078 void **ptr);
1079
1080/* called by driver to notify scan status completed */
1081void ieee80211_scan_completed(struct ieee80211_hw *hw);
1082
Jiri Bencf0706e822007-05-05 11:45:53 -07001083/* return a pointer to the source address (SA) */
1084static inline u8 *ieee80211_get_SA(struct ieee80211_hdr *hdr)
1085{
1086 u8 *raw = (u8 *) hdr;
1087 u8 tofrom = (*(raw+1)) & 3; /* get the TODS and FROMDS bits */
1088
1089 switch (tofrom) {
1090 case 2:
1091 return hdr->addr3;
1092 case 3:
1093 return hdr->addr4;
1094 }
1095 return hdr->addr2;
1096}
1097
1098/* return a pointer to the destination address (DA) */
1099static inline u8 *ieee80211_get_DA(struct ieee80211_hdr *hdr)
1100{
1101 u8 *raw = (u8 *) hdr;
1102 u8 to_ds = (*(raw+1)) & 1; /* get the TODS bit */
1103
1104 if (to_ds)
1105 return hdr->addr3;
1106 return hdr->addr1;
1107}
1108
1109static inline int ieee80211_get_morefrag(struct ieee80211_hdr *hdr)
1110{
1111 return (le16_to_cpu(hdr->frame_control) &
1112 IEEE80211_FCTL_MOREFRAGS) != 0;
1113}
1114
Jiri Bencf0706e822007-05-05 11:45:53 -07001115#endif /* MAC80211_H */