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