~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to drivers/net/wireless/iwlwifi/iwl-dev.h

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/******************************************************************************
2
2
 *
3
 
 * Copyright(c) 2003 - 2010 Intel Corporation. All rights reserved.
 
3
 * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved.
4
4
 *
5
5
 * This program is free software; you can redistribute it and/or modify it
6
6
 * under the terms of version 2 of the GNU General Public License as
26
26
/*
27
27
 * Please use this file (iwl-dev.h) for driver implementation definitions.
28
28
 * Please use iwl-commands.h for uCode API definitions.
29
 
 * Please use iwl-4965-hw.h for hardware-related definitions.
30
29
 */
31
30
 
32
31
#ifndef __iwl_dev_h__
34
33
 
35
34
#include <linux/pci.h> /* for struct pci_device_id */
36
35
#include <linux/kernel.h>
 
36
#include <linux/wait.h>
 
37
#include <linux/leds.h>
37
38
#include <net/ieee80211_radiotap.h>
38
39
 
39
40
#include "iwl-eeprom.h"
41
42
#include "iwl-prph.h"
42
43
#include "iwl-fh.h"
43
44
#include "iwl-debug.h"
44
 
#include "iwl-4965-hw.h"
45
 
#include "iwl-3945-hw.h"
46
45
#include "iwl-agn-hw.h"
47
46
#include "iwl-led.h"
48
47
#include "iwl-power.h"
82
81
#define MAX_RTS_THRESHOLD         2347U
83
82
#define MAX_MSDU_SIZE             2304U
84
83
#define MAX_MPDU_SIZE             2346U
85
 
#define DEFAULT_BEACON_INTERVAL   100U
 
84
#define DEFAULT_BEACON_INTERVAL   200U
86
85
#define DEFAULT_SHORT_RETRY_LIMIT 7U
87
86
#define DEFAULT_LONG_RETRY_LIMIT  4U
88
87
 
111
110
                         struct iwl_device_cmd *cmd,
112
111
                         struct iwl_rx_packet *pkt);
113
112
 
114
 
        /* The CMD_SIZE_HUGE flag bit indicates that the command
115
 
         * structure is stored at the end of the shared queue memory. */
116
113
        u32 flags;
117
114
 
118
115
        DEFINE_DMA_UNMAP_ADDR(mapping);
122
119
/*
123
120
 * Generic queue structure
124
121
 *
125
 
 * Contains common data for Rx and Tx queues
 
122
 * Contains common data for Rx and Tx queues.
 
123
 *
 
124
 * Note the difference between n_bd and n_window: the hardware
 
125
 * always assumes 256 descriptors, so n_bd is always 256 (unless
 
126
 * there might be HW changes in the future). For the normal TX
 
127
 * queues, n_window, which is the size of the software queue data
 
128
 * is also 256; however, for the command queue, n_window is only
 
129
 * 32 since we don't need so many commands pending. Since the HW
 
130
 * still uses 256 BDs for DMA though, n_bd stays 256. As a result,
 
131
 * the software buffers (in the variables @meta, @txb in struct
 
132
 * iwl_tx_queue) only have 32 entries, while the HW buffers (@tfds
 
133
 * in the same struct) have 256.
 
134
 * This means that we end up with the following:
 
135
 *  HW entries: | 0 | ... | N * 32 | ... | N * 32 + 31 | ... | 255 |
 
136
 *  SW entries:           | 0      | ... | 31          |
 
137
 * where N is a number between 0 and 7. This means that the SW
 
138
 * data is a window overlayed over the HW queue.
126
139
 */
127
140
struct iwl_queue {
128
141
        int n_bd;              /* number of BDs in this queue */
136
149
                                * space more than this */
137
150
        int high_mark;         /* high watermark, stop queue if free
138
151
                                * space less than this */
139
 
} __packed;
 
152
};
140
153
 
141
154
/* One for each TFD */
142
155
struct iwl_tx_info {
164
177
 
165
178
struct iwl_tx_queue {
166
179
        struct iwl_queue q;
167
 
        void *tfds;
 
180
        struct iwl_tfd *tfds;
168
181
        struct iwl_device_cmd **cmd;
169
182
        struct iwl_cmd_meta *meta;
170
183
        struct iwl_tx_info *txb;
177
190
 
178
191
#define IWL_NUM_SCAN_RATES         (2)
179
192
 
180
 
struct iwl4965_channel_tgd_info {
181
 
        u8 type;
182
 
        s8 max_power;
183
 
};
184
 
 
185
 
struct iwl4965_channel_tgh_info {
186
 
        s64 last_radar_time;
187
 
};
188
 
 
189
 
#define IWL4965_MAX_RATE (33)
190
 
 
191
 
struct iwl3945_clip_group {
192
 
        /* maximum power level to prevent clipping for each rate, derived by
193
 
         *   us from this band's saturation power in EEPROM */
194
 
        const s8 clip_powers[IWL_MAX_RATES];
195
 
};
196
 
 
197
 
/* current Tx power values to use, one for each rate for each channel.
198
 
 * requested power is limited by:
199
 
 * -- regulatory EEPROM limits for this channel
200
 
 * -- hardware capabilities (clip-powers)
201
 
 * -- spectrum management
202
 
 * -- user preference (e.g. iwconfig)
203
 
 * when requested power is set, base power index must also be set. */
204
 
struct iwl3945_channel_power_info {
205
 
        struct iwl3945_tx_power tpc;    /* actual radio and DSP gain settings */
206
 
        s8 power_table_index;   /* actual (compenst'd) index into gain table */
207
 
        s8 base_power_index;    /* gain index for power at factory temp. */
208
 
        s8 requested_power;     /* power (dBm) requested for this chnl/rate */
209
 
};
210
 
 
211
 
/* current scan Tx power values to use, one for each scan rate for each
212
 
 * channel. */
213
 
struct iwl3945_scan_power_info {
214
 
        struct iwl3945_tx_power tpc;    /* actual radio and DSP gain settings */
215
 
        s8 power_table_index;   /* actual (compenst'd) index into gain table */
216
 
        s8 requested_power;     /* scan pwr (dBm) requested for chnl/rate */
217
 
};
218
 
 
219
193
/*
220
194
 * One for each channel, holds all channel setup data
221
195
 * Some of the fields (e.g. eeprom and flags/max_power_avg) are redundant
222
196
 *     with one another!
223
197
 */
224
198
struct iwl_channel_info {
225
 
        struct iwl4965_channel_tgd_info tgd;
226
 
        struct iwl4965_channel_tgh_info tgh;
227
199
        struct iwl_eeprom_channel eeprom;       /* EEPROM regulatory limit */
228
200
        struct iwl_eeprom_channel ht40_eeprom;  /* EEPROM regulatory limit for
229
201
                                                 * HT40 channel */
243
215
        s8 ht40_max_power_avg;  /* (dBm) regul. eeprom, normal Tx, any rate */
244
216
        u8 ht40_flags;          /* flags copied from EEPROM */
245
217
        u8 ht40_extension_channel; /* HT_IE_EXT_CHANNEL_* */
246
 
 
247
 
        /* Radio/DSP gain settings for each "normal" data Tx rate.
248
 
         * These include, in addition to RF and DSP gain, a few fields for
249
 
         *   remembering/modifying gain settings (indexes). */
250
 
        struct iwl3945_channel_power_info power_info[IWL4965_MAX_RATE];
251
 
 
252
 
        /* Radio/DSP gain settings for each scan rate, for directed scans. */
253
 
        struct iwl3945_scan_power_info scan_pwr_info[IWL_NUM_SCAN_RATES];
254
218
};
255
219
 
256
220
#define IWL_TX_FIFO_BK          0       /* shared */
286
250
#define IEEE80211_HLEN                  (IEEE80211_4ADDR_LEN)
287
251
#define IEEE80211_FRAME_LEN             (IEEE80211_DATA_LEN + IEEE80211_HLEN)
288
252
 
289
 
struct iwl_frame {
290
 
        union {
291
 
                struct ieee80211_hdr frame;
292
 
                struct iwl_tx_beacon_cmd beacon;
293
 
                u8 raw[IEEE80211_FRAME_LEN];
294
 
                u8 cmd[360];
295
 
        } u;
296
 
        struct list_head list;
297
 
};
298
253
 
299
254
#define SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
300
255
#define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ)
304
259
        CMD_SYNC = 0,
305
260
        CMD_SIZE_NORMAL = 0,
306
261
        CMD_NO_SKB = 0,
307
 
        CMD_SIZE_HUGE = (1 << 0),
308
262
        CMD_ASYNC = (1 << 1),
309
263
        CMD_WANT_SKB = (1 << 2),
 
264
        CMD_MAPPED = (1 << 3),
310
265
};
311
266
 
312
267
#define DEF_CMD_PAYLOAD_SIZE 320
315
270
 * struct iwl_device_cmd
316
271
 *
317
272
 * For allocation of the command and tx queues, this establishes the overall
318
 
 * size of the largest command we send to uCode, except for a scan command
319
 
 * (which is relatively huge; space is allocated separately).
 
273
 * size of the largest command we send to uCode, except for commands that
 
274
 * aren't fully copied and use other TFD space.
320
275
 */
321
276
struct iwl_device_cmd {
322
277
        struct iwl_cmd_header hdr;      /* uCode API */
333
288
 
334
289
#define TFD_MAX_PAYLOAD_SIZE (sizeof(struct iwl_device_cmd))
335
290
 
 
291
#define IWL_MAX_CMD_TFDS        2
 
292
 
 
293
enum iwl_hcmd_dataflag {
 
294
        IWL_HCMD_DFL_NOCOPY     = BIT(0),
 
295
};
336
296
 
337
297
struct iwl_host_cmd {
338
 
        const void *data;
 
298
        const void *data[IWL_MAX_CMD_TFDS];
339
299
        unsigned long reply_page;
340
300
        void (*callback)(struct iwl_priv *priv,
341
301
                         struct iwl_device_cmd *cmd,
342
302
                         struct iwl_rx_packet *pkt);
343
303
        u32 flags;
344
 
        u16 len;
 
304
        u16 len[IWL_MAX_CMD_TFDS];
 
305
        u8 dataflags[IWL_MAX_CMD_TFDS];
345
306
        u8 id;
346
307
};
347
308
 
414
375
#define IWL_EMPTYING_HW_QUEUE_ADDBA 2
415
376
#define IWL_EMPTYING_HW_QUEUE_DELBA 3
416
377
        u8 state;
 
378
        u8 tx_fifo;
417
379
};
418
380
 
419
381
 
497
459
 * When mac80211 creates a station it reserves some space (hw->sta_data_size)
498
460
 * in the structure for use by driver. This structure is places in that
499
461
 * space.
500
 
 *
501
 
 * The common struct MUST be first because it is shared between
502
 
 * 3945 and agn!
503
462
 */
504
463
struct iwl_station_priv {
505
464
        struct iwl_station_priv_common common;
507
466
        atomic_t pending_frames;
508
467
        bool client;
509
468
        bool asleep;
 
469
        u8 max_agg_bufsize;
510
470
};
511
471
 
512
472
/**
527
487
        u32 len;                /* bytes */
528
488
};
529
489
 
 
490
struct fw_img {
 
491
        struct fw_desc code, data;
 
492
};
 
493
 
530
494
/* v1/v2 uCode file layout */
531
495
struct iwl_ucode_header {
532
496
        __le32 ver;     /* major/minor/API/serial */
583
547
        IWL_UCODE_TLV_INIT_ERRLOG_PTR   = 13,
584
548
        IWL_UCODE_TLV_ENHANCE_SENS_TBL  = 14,
585
549
        IWL_UCODE_TLV_PHY_CALIBRATION_SIZE = 15,
 
550
        /* 16 and 17 reserved for future use */
 
551
        IWL_UCODE_TLV_FLAGS             = 18,
 
552
};
 
553
 
 
554
/**
 
555
 * enum iwl_ucode_tlv_flag - ucode API flags
 
556
 * @IWL_UCODE_TLV_FLAGS_PAN: This is PAN capable microcode; this previously
 
557
 *      was a separate TLV but moved here to save space.
 
558
 * @IWL_UCODE_TLV_FLAGS_NEWSCAN: new uCode scan behaviour on hidden SSID,
 
559
 *      treats good CRC threshold as a boolean
 
560
 * @IWL_UCODE_TLV_FLAGS_MFP: This uCode image supports MFP (802.11w).
 
561
 */
 
562
enum iwl_ucode_tlv_flag {
 
563
        IWL_UCODE_TLV_FLAGS_PAN         = BIT(0),
 
564
        IWL_UCODE_TLV_FLAGS_NEWSCAN     = BIT(1),
 
565
        IWL_UCODE_TLV_FLAGS_MFP         = BIT(2),
586
566
};
587
567
 
588
568
struct iwl_ucode_tlv {
616
596
        u8 data[0];
617
597
};
618
598
 
619
 
struct iwl4965_ibss_seq {
620
 
        u8 mac[ETH_ALEN];
621
 
        u16 seq_num;
622
 
        u16 frag_num;
623
 
        unsigned long packet_time;
624
 
        struct list_head list;
625
 
};
626
 
 
627
599
struct iwl_sensitivity_ranges {
628
600
        u16 min_nrg_cck;
629
601
        u16 max_nrg_cck;
697
669
        u8  max_beacon_itrvl;   /* in 1024 ms */
698
670
        u32 max_inst_size;
699
671
        u32 max_data_size;
700
 
        u32 max_bsm_size;
701
672
        u32 ct_kill_threshold; /* value in hw-dependent units */
702
673
        u32 ct_kill_exit_threshold; /* value in hw-dependent units */
703
674
                                    /* for 1000, 6000 series and up */
719
690
 * Naming convention --
720
691
 * iwl_         <-- Is part of iwlwifi
721
692
 * iwlXXXX_     <-- Hardware specific (implemented in iwl-XXXX.c for XXXX)
722
 
 * iwl4965_bg_      <-- Called from work queue context
723
 
 * iwl4965_mac_     <-- mac80211 callback
724
693
 *
725
694
 ****************************************************************************/
726
695
extern void iwl_update_chain_flags(struct iwl_priv *priv);
736
705
}
737
706
 
738
707
 
739
 
static inline u8 get_cmd_index(struct iwl_queue *q, u32 index, int is_huge)
 
708
static inline u8 get_cmd_index(struct iwl_queue *q, u32 index)
740
709
{
741
 
        /*
742
 
         * This is for init calibration result and scan command which
743
 
         * required buffer > TFD_MAX_PAYLOAD_SIZE,
744
 
         * the big buffer at end of command array
745
 
         */
746
 
        if (is_huge)
747
 
                return q->n_window;     /* must be power of 2 */
748
 
 
749
 
        /* Otherwise, use normal size buffers */
750
710
        return index & (q->n_window - 1);
751
711
}
752
712
 
769
729
 
770
730
/* Sensitivity and chain noise calibration */
771
731
#define INITIALIZATION_VALUE            0xFFFF
772
 
#define IWL4965_CAL_NUM_BEACONS         20
773
732
#define IWL_CAL_NUM_BEACONS             16
774
733
#define MAXIMUM_ALLOWED_PATHLOSS        15
775
734
 
803
762
#define NRG_NUM_PREV_STAT_L     20
804
763
#define NUM_RX_CHAINS           3
805
764
 
806
 
enum iwl4965_false_alarm_state {
 
765
enum iwlagn_false_alarm_state {
807
766
        IWL_FA_TOO_MANY = 0,
808
767
        IWL_FA_TOO_FEW = 1,
809
768
        IWL_FA_GOOD_RANGE = 2,
810
769
};
811
770
 
812
 
enum iwl4965_chain_noise_state {
 
771
enum iwlagn_chain_noise_state {
813
772
        IWL_CHAIN_NOISE_ALIVE = 0,  /* must be 0 */
814
773
        IWL_CHAIN_NOISE_ACCUMULATE,
815
774
        IWL_CHAIN_NOISE_CALIBRATED,
816
775
        IWL_CHAIN_NOISE_DONE,
817
776
};
818
777
 
819
 
enum iwl4965_calib_enabled_state {
820
 
        IWL_CALIB_DISABLED = 0,  /* must be 0 */
821
 
        IWL_CALIB_ENABLED = 1,
822
 
};
823
 
 
824
778
 
825
779
/*
826
780
 * enum iwl_calib
844
798
        size_t buf_len;
845
799
};
846
800
 
847
 
enum ucode_type {
848
 
        UCODE_NONE = 0,
849
 
        UCODE_INIT,
850
 
        UCODE_RT
851
 
};
852
 
 
853
801
/* Sensitivity calib data */
854
802
struct iwl_sensitivity_data {
855
803
        u32 auto_corr_ofdm;
995
943
        u32 unknown;
996
944
};
997
945
 
998
 
#ifdef CONFIG_IWLWIFI_DEBUGFS
999
946
/* management statistics */
1000
947
enum iwl_mgmt_stats {
1001
948
        MANAGEMENT_ASSOC_REQ = 0,
1026
973
};
1027
974
 
1028
975
struct traffic_stats {
 
976
#ifdef CONFIG_IWLWIFI_DEBUGFS
1029
977
        u32 mgmt[MANAGEMENT_MAX];
1030
978
        u32 ctrl[CONTROL_MAX];
1031
979
        u32 data_cnt;
1032
980
        u64 data_bytes;
1033
 
};
1034
 
#else
1035
 
struct traffic_stats {
1036
 
        u64 data_bytes;
1037
 
};
1038
981
#endif
1039
 
 
1040
 
/*
1041
 
 * iwl_switch_rxon: "channel switch" structure
1042
 
 *
1043
 
 * @ switch_in_progress: channel switch in progress
1044
 
 * @ channel: new channel
1045
 
 */
1046
 
struct iwl_switch_rxon {
1047
 
        bool switch_in_progress;
1048
 
        __le16 channel;
1049
982
};
1050
983
 
1051
984
/*
1111
1044
/* BT Antenna Coupling Threshold (dB) */
1112
1045
#define IWL_BT_ANTENNA_COUPLING_THRESHOLD       (35)
1113
1046
 
 
1047
/* Firmware reload counter and Timestamp */
 
1048
#define IWL_MIN_RELOAD_DURATION         1000 /* 1000 ms */
 
1049
#define IWL_MAX_CONTINUE_RELOAD_CNT     4
 
1050
 
 
1051
 
1114
1052
enum iwl_reset {
1115
1053
        IWL_RF_RESET = 0,
1116
1054
        IWL_FW_RESET,
1127
1065
 
1128
1066
/* extend beacon time format bit shifting  */
1129
1067
/*
1130
 
 * for _3945 devices
1131
 
 * bits 31:24 - extended
1132
 
 * bits 23:0  - interval
1133
 
 */
1134
 
#define IWL3945_EXT_BEACON_TIME_POS     24
1135
 
/*
1136
1068
 * for _agn devices
1137
1069
 * bits 31:22 - extended
1138
1070
 * bits 21:0  - interval
1139
1071
 */
1140
1072
#define IWLAGN_EXT_BEACON_TIME_POS      22
1141
1073
 
 
1074
/**
 
1075
 * struct iwl_notification_wait - notification wait entry
 
1076
 * @list: list head for global list
 
1077
 * @fn: function called with the notification
 
1078
 * @cmd: command ID
 
1079
 *
 
1080
 * This structure is not used directly, to wait for a
 
1081
 * notification declare it on the stack, and call
 
1082
 * iwlagn_init_notification_wait() with appropriate
 
1083
 * parameters. Then do whatever will cause the ucode
 
1084
 * to notify the driver, and to wait for that then
 
1085
 * call iwlagn_wait_notification().
 
1086
 *
 
1087
 * Each notification is one-shot. If at some point we
 
1088
 * need to support multi-shot notifications (which
 
1089
 * can't be allocated on the stack) we need to modify
 
1090
 * the code for them.
 
1091
 */
 
1092
struct iwl_notification_wait {
 
1093
        struct list_head list;
 
1094
 
 
1095
        void (*fn)(struct iwl_priv *priv, struct iwl_rx_packet *pkt,
 
1096
                   void *data);
 
1097
        void *fn_data;
 
1098
 
 
1099
        u8 cmd;
 
1100
        bool triggered, aborted;
 
1101
};
 
1102
 
1142
1103
enum iwl_rxon_context_id {
1143
1104
        IWL_RXON_CTX_BSS,
1144
1105
        IWL_RXON_CTX_PAN,
1197
1158
                bool enabled, is_40mhz;
1198
1159
                u8 extension_chan_offset;
1199
1160
        } ht;
1200
 
};
1201
 
 
 
1161
 
 
1162
        bool last_tx_rejected;
 
1163
};
 
1164
 
 
1165
enum iwl_scan_type {
 
1166
        IWL_SCAN_NORMAL,
 
1167
        IWL_SCAN_RADIO_RESET,
 
1168
        IWL_SCAN_OFFCH_TX,
 
1169
};
 
1170
 
 
1171
#ifdef CONFIG_IWLWIFI_DEVICE_SVTOOL
 
1172
struct iwl_testmode_trace {
 
1173
        u8 *cpu_addr;
 
1174
        u8 *trace_addr;
 
1175
        dma_addr_t dma_addr;
 
1176
        bool trace_enabled;
 
1177
};
 
1178
#endif
1202
1179
struct iwl_priv {
1203
1180
 
1204
1181
        /* ieee device used by generic ieee processing code */
1207
1184
        struct ieee80211_rate *ieee_rates;
1208
1185
        struct iwl_cfg *cfg;
1209
1186
 
1210
 
        /* temporary frame storage list */
1211
 
        struct list_head free_frames;
1212
 
        int frames_count;
1213
 
 
1214
1187
        enum ieee80211_band band;
1215
 
        int alloc_rxb_page;
1216
1188
 
 
1189
        void (*pre_rx_handler)(struct iwl_priv *priv,
 
1190
                               struct iwl_rx_mem_buffer *rxb);
1217
1191
        void (*rx_handlers[REPLY_MAX])(struct iwl_priv *priv,
1218
1192
                                       struct iwl_rx_mem_buffer *rxb);
1219
1193
 
1230
1204
        /* track IBSS manager (last beacon) status */
1231
1205
        u32 ibss_manager;
1232
1206
 
1233
 
        /* storing the jiffies when the plcp error rate is received */
1234
 
        unsigned long plcp_jiffies;
 
1207
        /* jiffies when last recovery from statistics was performed */
 
1208
        unsigned long rx_statistics_jiffies;
1235
1209
 
1236
1210
        /* force reset */
1237
1211
        struct iwl_force_reset force_reset[IWL_MAX_FORCE_RESET];
1238
1212
 
 
1213
        /* firmware reload counter and timestamp */
 
1214
        unsigned long reload_jiffies;
 
1215
        int reload_count;
 
1216
 
1239
1217
        /* we allocate array of iwl_channel_info for NIC's valid channels.
1240
1218
         *    Access via channel # using indirect index array */
1241
1219
        struct iwl_channel_info *channel_info;  /* channel info array */
1255
1233
        enum ieee80211_band scan_band;
1256
1234
        struct cfg80211_scan_request *scan_request;
1257
1235
        struct ieee80211_vif *scan_vif;
1258
 
        bool is_internal_short_scan;
 
1236
        enum iwl_scan_type scan_type;
1259
1237
        u8 scan_tx_ant[IEEE80211_NUM_BANDS];
1260
1238
        u8 mgmt_tx_ant;
1261
1239
 
1264
1242
        spinlock_t hcmd_lock;   /* protect hcmd */
1265
1243
        spinlock_t reg_lock;    /* protect hw register access */
1266
1244
        struct mutex mutex;
1267
 
        struct mutex sync_cmd_mutex; /* enable serialization of sync commands */
1268
1245
 
1269
1246
        /* basic pci-network driver stuff */
1270
1247
        struct pci_dev *pci_dev;
1271
1248
 
1272
1249
        /* pci hardware address support */
1273
1250
        void __iomem *hw_base;
1274
 
        u32  hw_rev;
1275
 
        u32  hw_wa_rev;
1276
 
        u8   rev_id;
1277
1251
 
1278
1252
        /* microcode/device supports multiple contexts */
1279
1253
        u8 valid_contexts;
1284
1258
        /* max number of station keys */
1285
1259
        u8 sta_key_max_num;
1286
1260
 
 
1261
        bool new_scan_threshold_behaviour;
 
1262
 
1287
1263
        /* EEPROM MAC addresses */
1288
1264
        struct mac_address addresses[2];
1289
1265
 
1291
1267
        int fw_index;                   /* firmware we're trying to load */
1292
1268
        u32 ucode_ver;                  /* version of ucode, copy of
1293
1269
                                           iwl_ucode.ver */
1294
 
        struct fw_desc ucode_code;      /* runtime inst */
1295
 
        struct fw_desc ucode_data;      /* runtime data original */
1296
 
        struct fw_desc ucode_data_backup;       /* runtime data save/restore */
1297
 
        struct fw_desc ucode_init;      /* initialization inst */
1298
 
        struct fw_desc ucode_init_data; /* initialization data */
1299
 
        struct fw_desc ucode_boot;      /* bootstrap inst */
1300
 
        enum ucode_type ucode_type;
 
1270
        struct fw_img ucode_rt;
 
1271
        struct fw_img ucode_init;
 
1272
 
 
1273
        enum iwlagn_ucode_subtype ucode_type;
1301
1274
        u8 ucode_write_complete;        /* the image write is complete */
1302
1275
        char firmware_name[25];
1303
1276
 
1304
1277
        struct iwl_rxon_context contexts[NUM_IWL_RXON_CTX];
1305
1278
 
1306
 
        struct iwl_switch_rxon switch_rxon;
1307
 
 
1308
 
        /* 1st responses from initialize and runtime uCode images.
1309
 
         * _agn's initialize alive response contains some calibration data. */
1310
 
        struct iwl_init_alive_resp card_alive_init;
1311
 
        struct iwl_alive_resp card_alive;
1312
 
 
1313
 
        unsigned long last_blink_time;
1314
 
        u8 last_blink_rate;
1315
 
        u8 allow_blinking;
1316
 
        u64 led_tpt;
 
1279
        __le16 switch_channel;
 
1280
 
 
1281
        struct {
 
1282
                u32 error_event_table;
 
1283
                u32 log_event_table;
 
1284
        } device_pointers;
1317
1285
 
1318
1286
        u16 active_rate;
1319
1287
 
1354
1322
        struct iwl_power_mgr power_data;
1355
1323
        struct iwl_tt_mgmt thermal_throttle;
1356
1324
 
1357
 
        /* context information */
1358
 
        u8 bssid[ETH_ALEN]; /* used only on 3945 but filled by core */
1359
 
 
1360
1325
        /* station table variables */
1361
1326
 
1362
1327
        /* Note: if lock and sta_lock are needed, lock must be acquired first */
1363
1328
        spinlock_t sta_lock;
1364
1329
        int num_stations;
1365
 
        struct iwl_station_entry stations[IWL_STATION_COUNT];
 
1330
        struct iwl_station_entry stations[IWLAGN_STATION_COUNT];
1366
1331
        unsigned long ucode_key_table;
1367
1332
 
1368
1333
        /* queue refcounts */
1386
1351
        /* Last Rx'd beacon timestamp */
1387
1352
        u64 timestamp;
1388
1353
 
1389
 
        union {
1390
 
#if defined(CONFIG_IWL3945) || defined(CONFIG_IWL3945_MODULE)
1391
 
                struct {
1392
 
                        void *shared_virt;
1393
 
                        dma_addr_t shared_phys;
1394
 
 
1395
 
                        struct delayed_work thermal_periodic;
1396
 
                        struct delayed_work rfkill_poll;
1397
 
 
1398
 
                        struct iwl3945_notif_statistics statistics;
1399
 
#ifdef CONFIG_IWLWIFI_DEBUGFS
1400
 
                        struct iwl3945_notif_statistics accum_statistics;
1401
 
                        struct iwl3945_notif_statistics delta_statistics;
1402
 
                        struct iwl3945_notif_statistics max_delta;
1403
 
#endif
1404
 
 
1405
 
                        u32 sta_supp_rates;
1406
 
                        int last_rx_rssi;       /* From Rx packet statistics */
1407
 
 
1408
 
                        /* Rx'd packet timing information */
1409
 
                        u32 last_beacon_time;
1410
 
                        u64 last_tsf;
1411
 
 
1412
 
                        /*
1413
 
                         * each calibration channel group in the
1414
 
                         * EEPROM has a derived clip setting for
1415
 
                         * each rate.
1416
 
                         */
1417
 
                        const struct iwl3945_clip_group clip_groups[5];
1418
 
 
1419
 
                } _3945;
1420
 
#endif
1421
 
#if defined(CONFIG_IWLAGN) || defined(CONFIG_IWLAGN_MODULE)
1422
 
                struct {
1423
 
                        /* INT ICT Table */
1424
 
                        __le32 *ict_tbl;
1425
 
                        void *ict_tbl_vir;
1426
 
                        dma_addr_t ict_tbl_dma;
1427
 
                        dma_addr_t aligned_ict_tbl_dma;
1428
 
                        int ict_index;
1429
 
                        u32 inta;
1430
 
                        bool use_ict;
1431
 
                        /*
1432
 
                         * reporting the number of tids has AGG on. 0 means
1433
 
                         * no AGGREGATION
1434
 
                         */
1435
 
                        u8 agg_tids_count;
1436
 
 
1437
 
                        struct iwl_rx_phy_res last_phy_res;
1438
 
                        bool last_phy_res_valid;
1439
 
 
1440
 
                        struct completion firmware_loading_complete;
1441
 
 
1442
 
                        u32 init_evtlog_ptr, init_evtlog_size, init_errlog_ptr;
1443
 
                        u32 inst_evtlog_ptr, inst_evtlog_size, inst_errlog_ptr;
1444
 
 
1445
 
                        /*
1446
 
                         * chain noise reset and gain commands are the
1447
 
                         * two extra calibration commands follows the standard
1448
 
                         * phy calibration commands
1449
 
                         */
1450
 
                        u8 phy_calib_chain_noise_reset_cmd;
1451
 
                        u8 phy_calib_chain_noise_gain_cmd;
1452
 
 
1453
 
                        struct iwl_notif_statistics statistics;
1454
 
                        struct iwl_bt_notif_statistics statistics_bt;
1455
 
                        /* counts reply_tx error */
1456
 
                        struct reply_tx_error_statistics reply_tx_stats;
1457
 
                        struct reply_agg_tx_error_statistics reply_agg_tx_stats;
1458
 
#ifdef CONFIG_IWLWIFI_DEBUGFS
1459
 
                        struct iwl_notif_statistics accum_statistics;
1460
 
                        struct iwl_notif_statistics delta_statistics;
1461
 
                        struct iwl_notif_statistics max_delta;
1462
 
                        struct iwl_bt_notif_statistics accum_statistics_bt;
1463
 
                        struct iwl_bt_notif_statistics delta_statistics_bt;
1464
 
                        struct iwl_bt_notif_statistics max_delta_bt;
1465
 
#endif
1466
 
                } _agn;
1467
 
#endif
1468
 
        };
 
1354
        struct {
 
1355
                __le32 flag;
 
1356
                struct statistics_general_common common;
 
1357
                struct statistics_rx_non_phy rx_non_phy;
 
1358
                struct statistics_rx_phy rx_ofdm;
 
1359
                struct statistics_rx_ht_phy rx_ofdm_ht;
 
1360
                struct statistics_rx_phy rx_cck;
 
1361
                struct statistics_tx tx;
 
1362
#ifdef CONFIG_IWLWIFI_DEBUGFS
 
1363
                struct statistics_bt_activity bt_activity;
 
1364
                __le32 num_bt_kills, accum_num_bt_kills;
 
1365
#endif
 
1366
        } statistics;
 
1367
#ifdef CONFIG_IWLWIFI_DEBUGFS
 
1368
        struct {
 
1369
                struct statistics_general_common common;
 
1370
                struct statistics_rx_non_phy rx_non_phy;
 
1371
                struct statistics_rx_phy rx_ofdm;
 
1372
                struct statistics_rx_ht_phy rx_ofdm_ht;
 
1373
                struct statistics_rx_phy rx_cck;
 
1374
                struct statistics_tx tx;
 
1375
                struct statistics_bt_activity bt_activity;
 
1376
        } accum_stats, delta_stats, max_delta_stats;
 
1377
#endif
 
1378
 
 
1379
        struct {
 
1380
                /* INT ICT Table */
 
1381
                __le32 *ict_tbl;
 
1382
                void *ict_tbl_vir;
 
1383
                dma_addr_t ict_tbl_dma;
 
1384
                dma_addr_t aligned_ict_tbl_dma;
 
1385
                int ict_index;
 
1386
                u32 inta;
 
1387
                bool use_ict;
 
1388
                /*
 
1389
                 * reporting the number of tids has AGG on. 0 means
 
1390
                 * no AGGREGATION
 
1391
                 */
 
1392
                u8 agg_tids_count;
 
1393
 
 
1394
                struct iwl_rx_phy_res last_phy_res;
 
1395
                bool last_phy_res_valid;
 
1396
 
 
1397
                struct completion firmware_loading_complete;
 
1398
 
 
1399
                u32 init_evtlog_ptr, init_evtlog_size, init_errlog_ptr;
 
1400
                u32 inst_evtlog_ptr, inst_evtlog_size, inst_errlog_ptr;
 
1401
 
 
1402
                /*
 
1403
                 * chain noise reset and gain commands are the
 
1404
                 * two extra calibration commands follows the standard
 
1405
                 * phy calibration commands
 
1406
                 */
 
1407
                u8 phy_calib_chain_noise_reset_cmd;
 
1408
                u8 phy_calib_chain_noise_gain_cmd;
 
1409
 
 
1410
                /* counts reply_tx error */
 
1411
                struct reply_tx_error_statistics reply_tx_stats;
 
1412
                struct reply_agg_tx_error_statistics reply_agg_tx_stats;
 
1413
                /* notification wait support */
 
1414
                struct list_head notif_waits;
 
1415
                spinlock_t notif_wait_lock;
 
1416
                wait_queue_head_t notif_waitq;
 
1417
 
 
1418
                /* remain-on-channel offload support */
 
1419
                struct ieee80211_channel *hw_roc_channel;
 
1420
                struct delayed_work hw_roc_work;
 
1421
                enum nl80211_channel_type hw_roc_chantype;
 
1422
                int hw_roc_duration;
 
1423
                bool hw_roc_setup;
 
1424
 
 
1425
                struct sk_buff *offchan_tx_skb;
 
1426
                int offchan_tx_timeout;
 
1427
                struct ieee80211_channel *offchan_tx_chan;
 
1428
        } _agn;
1469
1429
 
1470
1430
        /* bt coex */
1471
1431
        u8 bt_enable_flag;
1472
1432
        u8 bt_status;
1473
1433
        u8 bt_traffic_load, last_bt_traffic_load;
1474
1434
        bool bt_ch_announce;
1475
 
        bool bt_sco_active;
1476
1435
        bool bt_full_concurrent;
1477
1436
        bool bt_ant_couple_ok;
1478
1437
        __le32 kill_ack_mask;
1498
1457
        struct work_struct beacon_update;
1499
1458
        struct iwl_rxon_context *beacon_ctx;
1500
1459
        struct sk_buff *beacon_skb;
 
1460
        void *beacon_cmd;
1501
1461
 
1502
1462
        struct work_struct tt_work;
1503
1463
        struct work_struct ct_enter;
1509
1469
 
1510
1470
        struct tasklet_struct irq_tasklet;
1511
1471
 
1512
 
        struct delayed_work init_alive_start;
1513
 
        struct delayed_work alive_start;
1514
1472
        struct delayed_work scan_check;
1515
1473
 
1516
1474
        /* TX Power */
1539
1497
        struct work_struct txpower_work;
1540
1498
        u32 disable_sens_cal;
1541
1499
        u32 disable_chain_noise_cal;
1542
 
        u32 disable_tx_power_cal;
1543
1500
        struct work_struct run_time_calib_work;
1544
1501
        struct timer_list statistics_periodic;
1545
1502
        struct timer_list ucode_trace;
1546
1503
        struct timer_list watchdog;
1547
 
        bool hw_ready;
1548
1504
 
1549
1505
        struct iwl_event_log event_log;
 
1506
 
 
1507
        struct led_classdev led;
 
1508
        unsigned long blink_on, blink_off;
 
1509
        bool led_registered;
 
1510
#ifdef CONFIG_IWLWIFI_DEVICE_SVTOOL
 
1511
        struct iwl_testmode_trace testmode_trace;
 
1512
#endif
 
1513
        u32 dbg_fixed_rate;
 
1514
 
1550
1515
}; /*iwl_priv */
1551
1516
 
1552
1517
static inline void iwl_txq_ctx_activate(struct iwl_priv *priv, int txq_id)
1604
1569
             ctx < &priv->contexts[NUM_IWL_RXON_CTX]; ctx++)    \
1605
1570
                if (priv->valid_contexts & BIT(ctx->ctxid))
1606
1571
 
 
1572
static inline int iwl_is_associated_ctx(struct iwl_rxon_context *ctx)
 
1573
{
 
1574
        return (ctx->active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0;
 
1575
}
 
1576
 
1607
1577
static inline int iwl_is_associated(struct iwl_priv *priv,
1608
1578
                                    enum iwl_rxon_context_id ctxid)
1609
1579
{
1610
 
        return (priv->contexts[ctxid].active.filter_flags &
1611
 
                        RXON_FILTER_ASSOC_MSK) ? 1 : 0;
 
1580
        return iwl_is_associated_ctx(&priv->contexts[ctxid]);
1612
1581
}
1613
1582
 
1614
1583
static inline int iwl_is_any_associated(struct iwl_priv *priv)
1615
1584
{
1616
 
        return iwl_is_associated(priv, IWL_RXON_CTX_BSS);
1617
 
}
1618
 
 
1619
 
static inline int iwl_is_associated_ctx(struct iwl_rxon_context *ctx)
1620
 
{
1621
 
        return (ctx->active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0;
 
1585
        struct iwl_rxon_context *ctx;
 
1586
        for_each_context(priv, ctx)
 
1587
                if (iwl_is_associated_ctx(ctx))
 
1588
                        return true;
 
1589
        return false;
1622
1590
}
1623
1591
 
1624
1592
static inline int is_channel_valid(const struct iwl_channel_info *ch_info)
1656
1624
static inline void __iwl_free_pages(struct iwl_priv *priv, struct page *page)
1657
1625
{
1658
1626
        __free_pages(page, priv->hw_params.rx_page_order);
1659
 
        priv->alloc_rxb_page--;
1660
1627
}
1661
1628
 
1662
1629
static inline void iwl_free_pages(struct iwl_priv *priv, unsigned long page)
1663
1630
{
1664
1631
        free_pages(page, priv->hw_params.rx_page_order);
1665
 
        priv->alloc_rxb_page--;
1666
1632
}
1667
1633
#endif                          /* __iwl_dev_h__ */