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