Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wirel...
[safe/jmp/linux-2.6] / drivers / net / wireless / iwlwifi / iwl-dev.h
index fd008ab..0baae80 100644 (file)
@@ -1,6 +1,6 @@
 /******************************************************************************
  *
- * Copyright(c) 2003 - 2008 Intel Corporation. All rights reserved.
+ * Copyright(c) 2003 - 2009 Intel Corporation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of version 2 of the GNU General Public License as
@@ -19,7 +19,7 @@
  * file called LICENSE.
  *
  * Contact Information:
- * James P. Ketrenos <ipw2100-admin@linux.intel.com>
+ *  Intel Linux Wireless <ilw@linux.intel.com>
  * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  *
  *****************************************************************************/
 #include <linux/kernel.h>
 #include <net/ieee80211_radiotap.h>
 
-#define DRV_NAME        "iwl4965"
-#include "iwl-rfkill.h"
 #include "iwl-eeprom.h"
-#include "iwl-4965-hw.h"
 #include "iwl-csr.h"
 #include "iwl-prph.h"
+#include "iwl-fh.h"
 #include "iwl-debug.h"
+#include "iwl-rfkill.h"
+#include "iwl-4965-hw.h"
+#include "iwl-3945-hw.h"
+#include "iwl-3945-led.h"
 #include "iwl-led.h"
 #include "iwl-power.h"
+#include "iwl-agn-rs.h"
 
 /* configuration for the iwl4965 */
 extern struct iwl_cfg iwl4965_agn_cfg;
 extern struct iwl_cfg iwl5300_agn_cfg;
 extern struct iwl_cfg iwl5100_agn_cfg;
 extern struct iwl_cfg iwl5350_agn_cfg;
-
-/* Change firmware file name, using "-" and incrementing number,
- *   *only* when uCode interface or architecture changes so that it
- *   is not compatible with earlier drivers.
- * This number will also appear in << 8 position of 1st dword of uCode file */
-#define IWL4965_UCODE_API "-1"
+extern struct iwl_cfg iwl5100_bg_cfg;
+extern struct iwl_cfg iwl5100_abg_cfg;
+extern struct iwl_cfg iwl5150_agn_cfg;
+extern struct iwl_cfg iwl6000_2ag_cfg;
+extern struct iwl_cfg iwl6000_2agn_cfg;
+extern struct iwl_cfg iwl6000_3agn_cfg;
+extern struct iwl_cfg iwl6050_2agn_cfg;
+extern struct iwl_cfg iwl6050_3agn_cfg;
+extern struct iwl_cfg iwl1000_bgn_cfg;
+
+/* shared structures from iwl-5000.c */
+extern struct iwl_mod_params iwl50_mod_params;
+extern struct iwl_ops iwl5000_ops;
+extern struct iwl_lib_ops iwl5000_lib;
+extern struct iwl_hcmd_ops iwl5000_hcmd;
+extern struct iwl_hcmd_utils_ops iwl5000_hcmd_utils;
+
+/* shared functions from iwl-5000.c */
+extern u16 iwl5000_get_hcmd_size(u8 cmd_id, u16 len);
+extern u16 iwl5000_build_addsta_hcmd(const struct iwl_addsta_cmd *cmd,
+                                    u8 *data);
+extern void iwl5000_rts_tx_cmd_flag(struct ieee80211_tx_info *info,
+                                   __le32 *tx_flags);
+extern int iwl5000_calc_rssi(struct iwl_priv *priv,
+                            struct iwl_rx_phy_res *rx_resp);
 
 /* CT-KILL constants */
 #define CT_KILL_THRESHOLD      110 /* in Celsius */
@@ -92,7 +114,8 @@ extern struct iwl_cfg iwl5350_agn_cfg;
 #define        DEFAULT_LONG_RETRY_LIMIT  4U
 
 struct iwl_rx_mem_buffer {
-       dma_addr_t dma_addr;
+       dma_addr_t real_dma_addr;
+       dma_addr_t aligned_dma_addr;
        struct sk_buff *skb;
        struct list_head list;
 };
@@ -115,11 +138,9 @@ struct iwl_queue {
                                * space less than this */
 } __attribute__ ((packed));
 
-#define MAX_NUM_OF_TBS          (20)
-
 /* One for each TFD */
 struct iwl_tx_info {
-       struct sk_buff *skb[MAX_NUM_OF_TBS];
+       struct sk_buff *skb[IWL_NUM_OF_TBS - 1];
 };
 
 /**
@@ -135,15 +156,18 @@ struct iwl_tx_info {
  * A Tx queue consists of circular buffer of BDs (a.k.a. TFDs, transmit frame
  * descriptors) and required locking structures.
  */
+#define TFD_TX_CMD_SLOTS 256
+#define TFD_CMD_SLOTS 32
+
 struct iwl_tx_queue {
        struct iwl_queue q;
-       struct iwl_tfd_frame *bd;
-       struct iwl_cmd *cmd;
-       dma_addr_t dma_addr_cmd;
+       void *tfds;
+       struct iwl_cmd *cmd[TFD_TX_CMD_SLOTS];
        struct iwl_tx_info *txb;
-       int need_update;
-       int sched_retry;
-       int active;
+       u8 need_update;
+       u8 sched_retry;
+       u8 active;
+       u8 swq_id;
 };
 
 #define IWL_NUM_SCAN_RATES         (2)
@@ -157,6 +181,36 @@ struct iwl4965_channel_tgh_info {
        s64 last_radar_time;
 };
 
+#define IWL4965_MAX_RATE (33)
+
+struct iwl3945_clip_group {
+       /* maximum power level to prevent clipping for each rate, derived by
+        *   us from this band's saturation power in EEPROM */
+       const s8 clip_powers[IWL_MAX_RATES];
+};
+
+/* current Tx power values to use, one for each rate for each channel.
+ * requested power is limited by:
+ * -- regulatory EEPROM limits for this channel
+ * -- hardware capabilities (clip-powers)
+ * -- spectrum management
+ * -- user preference (e.g. iwconfig)
+ * when requested power is set, base power index must also be set. */
+struct iwl3945_channel_power_info {
+       struct iwl3945_tx_power tpc;    /* actual radio and DSP gain settings */
+       s8 power_table_index;   /* actual (compenst'd) index into gain table */
+       s8 base_power_index;    /* gain index for power at factory temp. */
+       s8 requested_power;     /* power (dBm) requested for this chnl/rate */
+};
+
+/* current scan Tx power values to use, one for each scan rate for each
+ * channel. */
+struct iwl3945_scan_power_info {
+       struct iwl3945_tx_power tpc;    /* actual radio and DSP gain settings */
+       s8 power_table_index;   /* actual (compenst'd) index into gain table */
+       s8 requested_power;     /* scan pwr (dBm) requested for chnl/rate */
+};
+
 /*
  * One for each channel, holds all channel setup data
  * Some of the fields (e.g. eeprom and flags/max_power_avg) are redundant
@@ -187,15 +241,15 @@ struct iwl_channel_info {
        s8 fat_scan_power;      /* (dBm) eeprom, direct scans, any rate */
        u8 fat_flags;           /* flags copied from EEPROM */
        u8 fat_extension_channel; /* HT_IE_EXT_CHANNEL_* */
-};
 
-struct iwl4965_clip_group {
-       /* maximum power level to prevent clipping for each rate, derived by
-        *   us from this band's saturation power in EEPROM */
-       const s8 clip_powers[IWL_MAX_RATES];
-};
+       /* Radio/DSP gain settings for each "normal" data Tx rate.
+        * These include, in addition to RF and DSP gain, a few fields for
+        *   remembering/modifying gain settings (indexes). */
+       struct iwl3945_channel_power_info power_info[IWL4965_MAX_RATE];
 
-#include "iwl-4965-rs.h"
+       /* Radio/DSP gain settings for each scan rate, for directed scans. */
+       struct iwl3945_scan_power_info scan_pwr_info[IWL_NUM_SCAN_RATES];
+};
 
 #define IWL_TX_FIFO_AC0        0
 #define IWL_TX_FIFO_AC1        1
@@ -223,19 +277,13 @@ enum iwl_pwr_src {
 struct iwl_frame {
        union {
                struct ieee80211_hdr frame;
-               struct iwl4965_tx_beacon_cmd beacon;
+               struct iwl_tx_beacon_cmd beacon;
                u8 raw[IEEE80211_FRAME_LEN];
                u8 cmd[360];
        } u;
        struct list_head list;
 };
 
-#define SEQ_TO_QUEUE(x)  ((x >> 8) & 0xbf)
-#define QUEUE_TO_SEQ(x)  ((x & 0xbf) << 8)
-#define SEQ_TO_INDEX(x) ((u8)(x & 0xff))
-#define INDEX_TO_SEQ(x) ((u8)(x & 0xff))
-#define SEQ_HUGE_FRAME  (0x4000)
-#define SEQ_RX_FRAME    __constant_cpu_to_le16(0x8000)
 #define SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
 #define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ)
 #define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4)
@@ -263,7 +311,8 @@ struct iwl_cmd_meta {
        /* The CMD_SIZE_HUGE flag bit indicates that the command
         * structure is stored at the end of the shared queue memory. */
        u32 flags;
-
+       DECLARE_PCI_UNMAP_ADDR(mapping)
+       DECLARE_PCI_UNMAP_LEN(len)
 } __attribute__ ((packed));
 
 #define IWL_CMD_MAX_PAYLOAD 320
@@ -279,25 +328,16 @@ struct iwl_cmd {
        struct iwl_cmd_meta meta;       /* driver data */
        struct iwl_cmd_header hdr;      /* uCode API */
        union {
-               struct iwl_addsta_cmd addsta;
-               struct iwl4965_led_cmd led;
                u32 flags;
                u8 val8;
                u16 val16;
                u32 val32;
-               struct iwl4965_bt_cmd bt;
-               struct iwl4965_rxon_time_cmd rxon_time;
-               struct iwl4965_powertable_cmd powertable;
-               struct iwl4965_qosparam_cmd qosparam;
                struct iwl_tx_cmd tx;
-               struct iwl4965_tx_beacon_cmd tx_beacon;
-               struct iwl4965_rxon_assoc_cmd rxon_assoc;
-               struct iwl_rem_sta_cmd rm_sta;
-               u8 *indirect;
                u8 payload[IWL_CMD_MAX_PAYLOAD];
        } __attribute__ ((packed)) cmd;
 } __attribute__ ((packed));
 
+
 struct iwl_host_cmd {
        u8 id;
        u16 len;
@@ -320,7 +360,6 @@ struct iwl_host_cmd {
 
 /**
  * struct iwl_rx_queue - Rx queue
- * @processed: Internal index to last handled Rx packet
  * @read: Shared index to newest available Rx buffer
  * @write: Shared index to oldest written Rx packet
  * @free_count: Number of pre-allocated buffers in rx_free
@@ -335,26 +374,19 @@ struct iwl_rx_queue {
        dma_addr_t dma_addr;
        struct iwl_rx_mem_buffer pool[RX_QUEUE_SIZE + RX_FREE_BUFFERS];
        struct iwl_rx_mem_buffer *queue[RX_QUEUE_SIZE];
-       u32 processed;
        u32 read;
        u32 write;
        u32 free_count;
        struct list_head rx_free;
        struct list_head rx_used;
        int need_update;
+       struct iwl_rb_status *rb_stts;
+       dma_addr_t rb_stts_dma;
        spinlock_t lock;
 };
 
 #define IWL_SUPPORTED_RATES_IE_LEN         8
 
-#define SCAN_INTERVAL 100
-
-#define MAX_A_CHANNELS  252
-#define MIN_A_CHANNELS  7
-
-#define MAX_B_CHANNELS  14
-#define MIN_B_CHANNELS  1
-
 #define MAX_TID_COUNT        9
 
 #define IWL_INVALID_RATE     0xFF
@@ -402,7 +434,7 @@ struct iwl_hw_key {
        u8 key[32];
 };
 
-union iwl4965_ht_rate_supp {
+union iwl_ht_rate_supp {
        u16 rates;
        struct {
                u8 siso_rate;
@@ -418,22 +450,21 @@ struct iwl_ht_info {
        /* self configuration data */
        u8 is_ht;
        u8 supported_chan_width;
-       u16 tx_mimo_ps_mode;
+       u8 sm_ps;
        u8 is_green_field;
        u8 sgf;                 /* HT_SHORT_GI_* short guard interval */
        u8 max_amsdu_size;
        u8 ampdu_factor;
        u8 mpdu_density;
-       u8 supp_mcs_set[16];
+       struct ieee80211_mcs_info mcs;
        /* BSS related data */
-       u8 control_channel;
        u8 extension_chan_offset;
        u8 tx_chan_width;
        u8 ht_protection;
        u8 non_GF_STA_present;
 };
 
-union iwl4965_qos_capabity {
+union iwl_qos_capabity {
        struct {
                u8 edca_count:4;        /* bit 0-3 */
                u8 q_ack:1;             /* bit 4 */
@@ -454,16 +485,33 @@ union iwl4965_qos_capabity {
 };
 
 /* QoS structures */
-struct iwl4965_qos_info {
-       int qos_enable;
+struct iwl_qos_info {
        int qos_active;
-       union iwl4965_qos_capabity qos_cap;
-       struct iwl4965_qosparam_cmd def_qos_parm;
+       union iwl_qos_capabity qos_cap;
+       struct iwl_qosparam_cmd def_qos_parm;
 };
 
 #define STA_PS_STATUS_WAKE             0
 #define STA_PS_STATUS_SLEEP            1
 
+struct iwl3945_tid_data {
+       u16 seq_number;
+};
+
+struct iwl3945_hw_key {
+       enum ieee80211_key_alg alg;
+       int keylen;
+       u8 key[32];
+};
+
+struct iwl3945_station_entry {
+       struct iwl3945_addsta_cmd sta;
+       struct iwl3945_tid_data tid[MAX_TID_COUNT];
+       u8 used;
+       u8 ps_status;
+       struct iwl3945_hw_key keyinfo;
+};
+
 struct iwl_station_entry {
        struct iwl_addsta_cmd sta;
        struct iwl_tid_data tid[MAX_TID_COUNT];
@@ -481,7 +529,7 @@ struct fw_desc {
 
 /* uCode file layout */
 struct iwl_ucode {
-       __le32 ver;             /* major/minor/subminor */
+       __le32 ver;             /* major/minor/API/serial */
        __le32 inst_size;       /* bytes of runtime instructions */
        __le32 data_size;       /* bytes of runtime data */
        __le32 init_size;       /* bytes of initialization instructions */
@@ -490,8 +538,6 @@ struct iwl_ucode {
        u8 data[0];             /* data in same order as "size" elements */
 };
 
-#define IWL_IBSS_MAC_HASH_SIZE 32
-
 struct iwl4965_ibss_seq {
        u8 mac[ETH_ALEN];
        u16 seq_num;
@@ -524,16 +570,22 @@ struct iwl_sensitivity_ranges {
 };
 
 
-#define IWL_FAT_CHANNEL_52 BIT(IEEE80211_BAND_5GHZ)
+#define KELVIN_TO_CELSIUS(x) ((x)-273)
+#define CELSIUS_TO_KELVIN(x) ((x)+273)
+
 
 /**
  * struct iwl_hw_params
  * @max_txq_num: Max # Tx queues supported
+ * @dma_chnl_num: Number of Tx DMA/FIFO channels
+ * @scd_bc_tbls_size: size of scheduler byte count tables
+ * @tfd_size: TFD size
  * @tx/rx_chains_num: Number of TX/RX chains
  * @valid_tx/rx_ant: usable antennas
  * @max_rxq_size: Max # Rx frames in Rx queue (must be power-of-2)
  * @max_rxq_log: Log-base-2 of max_rxq_size
  * @rx_buf_size: Rx buffer size
+ * @rx_wrt_ptr_reg: FH{39}_RSCSR_CHNL0_WPTR
  * @max_stations:
  * @bcast_sta_id:
  * @fat_channel: is 40MHz width possible in band 2.4
@@ -541,11 +593,14 @@ struct iwl_sensitivity_ranges {
  * @sw_crypto: 0 for hw, 1 for sw
  * @max_xxx_size: for ucode uses
  * @ct_kill_threshold: temperature threshold
+ * @calib_init_cfg: setup initial calibrations for the hw
  * @struct iwl_sensitivity_ranges: range of sensitivity values
- * @first_ampdu_q: first HW queue available for ampdu
  */
 struct iwl_hw_params {
-       u16 max_txq_num;
+       u8 max_txq_num;
+       u8 dma_chnl_num;
+       u16 scd_bc_tbls_size;
+       u32 tfd_size;
        u8  tx_chains_num;
        u8  rx_chains_num;
        u8  valid_tx_ant;
@@ -553,6 +608,7 @@ struct iwl_hw_params {
        u16 max_rxq_size;
        u16 max_rxq_log;
        u32 rx_buf_size;
+       u32 rx_wrt_ptr_reg;
        u32 max_pkt_size;
        u8  max_stations;
        u8  bcast_sta_id;
@@ -562,73 +618,31 @@ struct iwl_hw_params {
        u32 max_data_size;
        u32 max_bsm_size;
        u32 ct_kill_threshold; /* value in hw-dependent units */
+       u32 calib_init_cfg;
        const struct iwl_sensitivity_ranges *sens;
-       u8 first_ampdu_q;
 };
 
-#define HT_SHORT_GI_20MHZ      (1 << 0)
-#define HT_SHORT_GI_40MHZ      (1 << 1)
-
-
-#define IWL_RX_HDR(x) ((struct iwl4965_rx_frame_hdr *)(\
-                      x->u.rx_frame.stats.payload + \
-                      x->u.rx_frame.stats.phy_count))
-#define IWL_RX_END(x) ((struct iwl4965_rx_frame_end *)(\
-                      IWL_RX_HDR(x)->payload + \
-                      le16_to_cpu(IWL_RX_HDR(x)->len)))
-#define IWL_RX_STATS(x) (&x->u.rx_frame.stats)
-#define IWL_RX_DATA(x) (IWL_RX_HDR(x)->payload)
-
-
-/******************************************************************************
- *
- * Functions implemented in iwl-base.c which are forward declared here
- * for use by iwl-*.c
- *
- *****************************************************************************/
-struct iwl_addsta_cmd;
-extern int iwl_send_add_sta(struct iwl_priv *priv,
-                           struct iwl_addsta_cmd *sta, u8 flags);
-u8 iwl_add_station_flags(struct iwl_priv *priv, const u8 *addr, int is_ap,
-                        u8 flags, struct ieee80211_ht_info *ht_info);
-extern int iwl4965_is_network_packet(struct iwl_priv *priv,
-                                struct ieee80211_hdr *header);
-extern int iwl4965_is_duplicate_packet(struct iwl_priv *priv,
-                                      struct ieee80211_hdr *header);
-extern int iwl4965_calc_sig_qual(int rssi_dbm, int noise_dbm);
-extern unsigned int iwl4965_fill_beacon_frame(struct iwl_priv *priv,
-                                       struct ieee80211_hdr *hdr,
-                                       const u8 *dest, int left);
-extern void iwl4965_update_chain_flags(struct iwl_priv *priv);
-int iwl4965_set_pwr_src(struct iwl_priv *priv, enum iwl_pwr_src src);
-
-extern const u8 iwl_bcast_addr[ETH_ALEN];
 
 /******************************************************************************
  *
- * Functions implemented in iwl-[34]*.c which are forward declared here
- * for use by iwl-base.c
+ * Functions implemented in core module which are forward declared here
+ * for use by iwl-[4-5].c
  *
- * NOTE:  The implementation of these functions are hardware specific
- * which is why they are in the hardware specific files (vs. iwl-base.c)
+ * NOTE:  The implementation of these functions are not hardware specific
+ * which is why they are in the core module files.
  *
  * Naming convention --
- * iwl4965_         <-- Its part of iwlwifi (should be changed to iwl4965_)
- * iwl4965_hw_      <-- Hardware specific (implemented in iwl-XXXX.c by all HW)
+ * iwl_         <-- Is part of iwlwifi
  * iwlXXXX_     <-- Hardware specific (implemented in iwl-XXXX.c for XXXX)
  * iwl4965_bg_      <-- Called from work queue context
  * iwl4965_mac_     <-- mac80211 callback
  *
  ****************************************************************************/
+extern void iwl_update_chain_flags(struct iwl_priv *priv);
+extern int iwl_set_pwr_src(struct iwl_priv *priv, enum iwl_pwr_src src);
+extern const u8 iwl_bcast_addr[ETH_ALEN];
 extern int iwl_rxq_stop(struct iwl_priv *priv);
 extern void iwl_txq_ctx_stop(struct iwl_priv *priv);
-extern unsigned int iwl4965_hw_get_beacon_cmd(struct iwl_priv *priv,
-                                struct iwl_frame *frame, u8 rate);
-extern void iwl4965_disable_events(struct iwl_priv *priv);
-extern void iwl4965_rx_reply_rx(struct iwl_priv *priv,
-                               struct iwl_rx_mem_buffer *rxb);
-
-extern int iwl4965_hw_channel_switch(struct iwl_priv *priv, u16 channel);
 extern int iwl_queue_space(const struct iwl_queue *q);
 static inline int iwl_queue_used(const struct iwl_queue *q, int i)
 {
@@ -649,37 +663,18 @@ static inline u8 get_cmd_index(struct iwl_queue *q, u32 index, int is_huge)
 }
 
 
-struct iwl_priv;
-
-/*
- * Forward declare iwl-4965.c functions for iwl-base.c
- */
-extern void iwl4965_rf_kill_ct_config(struct iwl_priv *priv);
-
-int iwl4965_mac_ampdu_action(struct ieee80211_hw *hw,
-                                   enum ieee80211_ampdu_mlme_action action,
-                                   const u8 *addr, u16 tid, u16 *ssn);
-int iwl4965_check_empty_hw_queue(struct iwl_priv *priv, int sta_id,
-                                       u8 tid, int txq_id);
-
-/* Structures, enum, and defines specific to the 4965 */
-
-#define IWL_KW_SIZE 0x1000     /*4k */
-
-struct iwl_kw {
-       dma_addr_t dma_addr;
-       void *v_addr;
+struct iwl_dma_ptr {
+       dma_addr_t dma;
+       void *addr;
        size_t size;
 };
 
+#define HT_SHORT_GI_20MHZ      (1 << 0)
+#define HT_SHORT_GI_40MHZ      (1 << 1)
+
 #define IWL_CHANNEL_WIDTH_20MHZ   0
 #define IWL_CHANNEL_WIDTH_40MHZ   1
 
-#define IWL_MIMO_PS_STATIC        0
-#define IWL_MIMO_PS_NONE          3
-#define IWL_MIMO_PS_DYNAMIC       1
-#define IWL_MIMO_PS_INVALID       2
-
 #define IWL_OPERATION_MODE_AUTO     0
 #define IWL_OPERATION_MODE_HT_ONLY  1
 #define IWL_OPERATION_MODE_MIXED    2
@@ -690,21 +685,7 @@ struct iwl_kw {
 
 #define TX_POWER_IWL_ILLEGAL_VOLTAGE -10000
 
-struct iwl4965_lq_mngr {
-       spinlock_t lock;
-       s32 max_window_size;
-       s32 *expected_tpt;
-       u8 *next_higher_rate;
-       u8 *next_lower_rate;
-       unsigned long stamp;
-       unsigned long stamp_last;
-       u32 flush_time;
-       u32 tx_packets;
-       u8 lq_ready;
-};
-
 /* Sensitivity and chain noise calibration */
-#define INTERFERENCE_DATA_AVAILABLE    __constant_cpu_to_le32(1)
 #define INITIALIZATION_VALUE           0xFFFF
 #define CAL_NUM_OF_BEACONS             20
 #define MAXIMUM_ALLOWED_PATHLOSS       15
@@ -747,8 +728,9 @@ enum iwl4965_false_alarm_state {
 
 enum iwl4965_chain_noise_state {
        IWL_CHAIN_NOISE_ALIVE = 0,  /* must be 0 */
-       IWL_CHAIN_NOISE_ACCUMULATE = 1,
-       IWL_CHAIN_NOISE_CALIBRATED = 2,
+       IWL_CHAIN_NOISE_ACCUMULATE,
+       IWL_CHAIN_NOISE_CALIBRATED,
+       IWL_CHAIN_NOISE_DONE,
 };
 
 enum iwl4965_calib_enabled_state {
@@ -756,22 +738,26 @@ enum iwl4965_calib_enabled_state {
        IWL_CALIB_ENABLED = 1,
 };
 
-struct statistics_general_data {
-       u32 beacon_silence_rssi_a;
-       u32 beacon_silence_rssi_b;
-       u32 beacon_silence_rssi_c;
-       u32 beacon_energy_a;
-       u32 beacon_energy_b;
-       u32 beacon_energy_c;
+
+/*
+ * enum iwl_calib
+ * defines the order in which results of initial calibrations
+ * should be sent to the runtime uCode
+ */
+enum iwl_calib {
+       IWL_CALIB_XTAL,
+       IWL_CALIB_DC,
+       IWL_CALIB_LO,
+       IWL_CALIB_TX_IQ,
+       IWL_CALIB_TX_IQ_PERD,
+       IWL_CALIB_BASE_BAND,
+       IWL_CALIB_MAX
 };
 
-struct iwl_calib_results {
-       void *tx_iq_res;
-       void *tx_iq_perd_res;
-       void *lo_res;
-       u32 tx_iq_res_len;
-       u32 tx_iq_perd_res_len;
-       u32 lo_res_len;
+/* Opaque calibration results */
+struct iwl_calib_result {
+       void *buf;
+       size_t buf_len;
 };
 
 enum ucode_type {
@@ -809,31 +795,29 @@ struct iwl_sensitivity_data {
 
 /* Chain noise (differential Rx gain) calib data */
 struct iwl_chain_noise_data {
-       u8 state;
-       u16 beacon_count;
+       u32 active_chains;
        u32 chain_noise_a;
        u32 chain_noise_b;
        u32 chain_noise_c;
        u32 chain_signal_a;
        u32 chain_signal_b;
        u32 chain_signal_c;
+       u16 beacon_count;
        u8 disconn_array[NUM_RX_CHAINS];
        u8 delta_gain_code[NUM_RX_CHAINS];
        u8 radio_write;
+       u8 state;
 };
 
 #define        EEPROM_SEM_TIMEOUT 10           /* milliseconds */
 #define EEPROM_SEM_RETRY_LIMIT 1000    /* number of attempts (not time) */
 
 
-#ifdef CONFIG_IWL4965_SPECTRUM_MEASUREMENT
-
 enum {
        MEASUREMENT_READY = (1 << 0),
        MEASUREMENT_ACTIVE = (1 << 1),
 };
 
-#endif
 
 #define IWL_MAX_NUM_QUEUES     20 /* FIXME: do dynamic allocation */
 
@@ -851,16 +835,15 @@ struct iwl_priv {
 
        enum ieee80211_band band;
        int alloc_rxb_skb;
-       bool add_radiotap;
 
        void (*rx_handlers[REPLY_MAX])(struct iwl_priv *priv,
                                       struct iwl_rx_mem_buffer *rxb);
 
        struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS];
 
-#ifdef CONFIG_IWL4965_SPECTRUM_MEASUREMENT
+#if defined(CONFIG_IWLWIFI_SPECTRUM_MEASUREMENT) || defined(CONFIG_IWL3945_SPECTRUM_MEASUREMENT)
        /* spectrum measurement report caching */
-       struct iwl4965_spectrum_notification measure_report;
+       struct iwl_spectrum_notification measure_report;
        u8 measurement_status;
 #endif
        /* ucode beacon time */
@@ -872,15 +855,15 @@ struct iwl_priv {
        u8 channel_count;       /* # of channels */
 
        /* each calibration channel group in the EEPROM has a derived
-        * clip setting for each rate. */
-       const struct iwl4965_clip_group clip_groups[5];
+        * clip setting for each rate. 3945 only.*/
+       const struct iwl3945_clip_group clip39_groups[5];
 
        /* thermal calibration */
        s32 temperature;        /* degrees Kelvin */
        s32 last_temperature;
 
        /* init calibration results */
-       struct iwl_calib_results calib_results;
+       struct iwl_calib_result calib_results[IWL_CALIB_MAX];
 
        /* Scan related variables */
        unsigned long last_scan_jiffies;
@@ -888,12 +871,13 @@ struct iwl_priv {
        unsigned long scan_start;
        unsigned long scan_pass_start;
        unsigned long scan_start_tsf;
+       void *scan;
        int scan_bands;
        int one_direct_scan;
        u8 direct_ssid_len;
        u8 direct_ssid[IW_ESSID_MAX_SIZE];
-       struct iwl_scan_cmd *scan;
-       u32 scan_tx_ant[IEEE80211_NUM_BANDS];
+       u8 scan_tx_ant[IEEE80211_NUM_BANDS];
+       u8 mgmt_tx_ant;
 
        /* spinlock */
        spinlock_t lock;        /* protect general shared data */
@@ -910,6 +894,8 @@ struct iwl_priv {
        u8   rev_id;
 
        /* uCode images, save to reload in case of failure */
+       u32 ucode_ver;                  /* version of ucode, copy of
+                                          iwl_ucode.ver */
        struct fw_desc ucode_code;      /* runtime inst */
        struct fw_desc ucode_data;      /* runtime data original */
        struct fw_desc ucode_data_backup;       /* runtime data save/restore */
@@ -920,7 +906,7 @@ struct iwl_priv {
        u8 ucode_write_complete;        /* the image write is complete */
 
 
-       struct iwl4965_rxon_time_cmd rxon_timing;
+       struct iwl_rxon_time_cmd rxon_timing;
 
        /* We declare this const so it can only be
         * changed via explicit cast within the
@@ -936,23 +922,22 @@ struct iwl_priv {
         * 4965's initialize alive response contains some calibration data. */
        struct iwl_init_alive_resp card_alive_init;
        struct iwl_alive_resp card_alive;
-#ifdef CONFIG_IWLWIFI_RFKILL
-       struct iwl_rfkill_mngr rfkill_mngr;
+#if defined(CONFIG_IWLWIFI_RFKILL)
+       struct rfkill *rfkill;
 #endif
 
 #ifdef CONFIG_IWLWIFI_LEDS
-       struct iwl4965_led led[IWL_LED_TRG_MAX];
        unsigned long last_blink_time;
        u8 last_blink_rate;
        u8 allow_blinking;
        u64 led_tpt;
+       struct iwl_led led[IWL_LED_TRG_MAX];
+       unsigned int rxtxpackets;
 #endif
-
        u16 active_rate;
        u16 active_rate_basic;
 
        u8 assoc_station_added;
-       u8 use_ant_b_for_management_frame;      /* Tx antenna selection */
        u8 start_calib;
        struct iwl_sensitivity_data sensitivity_data;
        struct iwl_chain_noise_data chain_noise_data;
@@ -962,9 +947,6 @@ struct iwl_priv {
        u8 last_phy_res[100];
 
        /* Rate scaling data */
-       struct iwl4965_lq_mngr lq_mngr;
-
-       /* Rate scaling data */
        s8 data_retry_limit;
        u8 retry_rate;
 
@@ -976,12 +958,14 @@ struct iwl_priv {
        struct iwl_rx_queue rxq;
        struct iwl_tx_queue txq[IWL_MAX_NUM_QUEUES];
        unsigned long txq_ctx_active_msk;
-       struct iwl_kw kw;       /* keep warm address */
+       struct iwl_dma_ptr  kw; /* keep warm address */
+       struct iwl_dma_ptr  scd_bc_tbls;
+
        u32 scd_base_addr;      /* scheduler sram base address */
 
        unsigned long status;
 
-       int last_rx_rssi;       /* From Rx packet statisitics */
+       int last_rx_rssi;       /* From Rx packet statistics */
        int last_rx_noise;      /* From beacon statistics */
 
        /* counts mgmt, ctl, and data packets */
@@ -996,12 +980,9 @@ struct iwl_priv {
        unsigned long last_statistics_time;
 
        /* context information */
-       u8 essid[IW_ESSID_MAX_SIZE];
-       u8 essid_len;
        u16 rates_mask;
 
        u32 power_mode;
-       u32 antenna;
        u8 bssid[ETH_ALEN];
        u16 rts_threshold;
        u8 mac_addr[ETH_ALEN];
@@ -1024,19 +1005,11 @@ struct iwl_priv {
        u32 last_beacon_time;
        u64 last_tsf;
 
-       /* Duplicate packet detection */
-       u16 last_seq_num;
-       u16 last_frag_num;
-       unsigned long last_packet_time;
-
-       /* Hash table for finding stations in IBSS network */
-       struct list_head ibss_mac_hash[IWL_IBSS_MAC_HASH_SIZE];
-
        /* eeprom */
        u8 *eeprom;
        struct iwl_eeprom_calib_info *calib_info;
 
-       enum ieee80211_if_types iw_mode;
+       enum nl80211_iftype iw_mode;
 
        struct sk_buff *ibss_beacon;
 
@@ -1045,20 +1018,19 @@ struct iwl_priv {
        u16 beacon_int;
        struct ieee80211_vif *vif;
 
-       struct iwl_hw_params hw_params;
-       /* driver/uCode shared Tx Byte Counts and Rx status */
+       /*Added for 3945 */
        void *shared_virt;
-       int rb_closed_offset;
-       /* Physical Pointer to Tx Byte Counts and Rx status */
        dma_addr_t shared_phys;
+       /*End*/
+       struct iwl_hw_params hw_params;
+
 
        /* Current association information needed to configure the
         * hardware */
        u16 assoc_id;
        u16 assoc_capability;
-       u8 ps_mode;
 
-       struct iwl4965_qos_info qos_data;
+       struct iwl_qos_info qos_data;
 
        struct workqueue_struct *workqueue;
 
@@ -1074,21 +1046,22 @@ struct iwl_priv {
        struct work_struct report_work;
        struct work_struct request_scan;
        struct work_struct beacon_update;
-       struct work_struct set_monitor;
 
        struct tasklet_struct irq_tasklet;
 
+       struct delayed_work set_power_save;
        struct delayed_work init_alive_start;
        struct delayed_work alive_start;
        struct delayed_work scan_check;
-       struct delayed_work post_associate;
+
+       /*For 3945 only*/
+       struct delayed_work thermal_periodic;
+       struct delayed_work rfkill_poll;
+
        /* TX Power */
        s8 tx_power_user_lmt;
        s8 tx_power_channel_lmt;
 
-#ifdef CONFIG_PM
-       u32 pm_state[16];
-#endif
 
 #ifdef CONFIG_IWLWIFI_DEBUG
        /* debugging info */
@@ -1107,6 +1080,15 @@ struct iwl_priv {
        u32 disable_tx_power_cal;
        struct work_struct run_time_calib_work;
        struct timer_list statistics_periodic;
+
+       /*For 3945*/
+#define IWL_DEFAULT_TX_POWER 0x0F
+
+       struct iwl3945_notif_statistics statistics_39;
+
+       struct iwl3945_station_entry stations_39[IWL_STATION_COUNT];
+
+       u32 sta_supp_rates;
 }; /*iwl_priv */
 
 static inline void iwl_txq_ctx_activate(struct iwl_priv *priv, int txq_id)
@@ -1119,7 +1101,7 @@ static inline void iwl_txq_ctx_deactivate(struct iwl_priv *priv, int txq_id)
        clear_bit(txq_id, &priv->txq_ctx_active_msk);
 }
 
-#ifdef CONFIG_IWLWIF_DEBUG
+#ifdef CONFIG_IWLWIFI_DEBUG
 const char *iwl_get_tx_fail_reason(u32 status);
 #else
 static inline const char *iwl_get_tx_fail_reason(u32 status) { return ""; }
@@ -1173,26 +1155,4 @@ static inline int is_channel_ibss(const struct iwl_channel_info *ch)
        return ((ch->flags & EEPROM_CHANNEL_IBSS)) ? 1 : 0;
 }
 
-#ifdef CONFIG_IWLWIFI_DEBUG
-static inline void iwl_print_hex_dump(struct iwl_priv *priv, int level,
-                                     void *p, u32 len)
-{
-       if (!(priv->debug_level & level))
-               return;
-
-       print_hex_dump(KERN_DEBUG, "iwl data: ", DUMP_PREFIX_OFFSET, 16, 1,
-                       p, len, 1);
-}
-#else
-static inline void iwl_print_hex_dump(struct iwl_priv *priv, int level,
-                                     void *p, u32 len)
-{
-}
-#endif
-
-extern const struct iwl_channel_info *iwl_get_channel_info(
-       const struct iwl_priv *priv, enum ieee80211_band band, u16 channel);
-
-/* Requires full declaration of iwl_priv before including */
-
 #endif                         /* __iwl_dev_h__ */