~ubuntu-branches/ubuntu/hardy/linux-backports-modules-2.6.24/hardy-security

« back to all changes in this revision

Viewing changes to updates/wireless/iwlwifi/mac80211/compatible/include/net/mac80211.h

  • Committer: Bazaar Package Importer
  • Author(s): , Ben Collins
  • Date: 2008-04-02 06:59:04 UTC
  • Revision ID: james.westby@ubuntu.com-20080402065904-e5knh2gn2hms3xbb
Tags: 2.6.24-14.11
[Ben Collins]

* iwlwifi: Update to iwlwifi-1.2.25 and mac80211-10.0.4
  - LP: #200950
* ubuntu: Slight cleanups to module hiearchy and Makefiles
* mac80211: Enable LED triggers
* iwlwifi: Add LED trigger support (rx and tx only)
  - LP: #176090

Show diffs side-by-side

added added

removed removed

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