iwlwifi: clean up some unused definitions in iwl-4965.h and iwl-3945.h
[powerpc.git] / drivers / net / wireless / iwlwifi / iwl-4965-commands.h
index 5524bf7..bd55709 100644 (file)
@@ -61,8 +61,8 @@
  *
  *****************************************************************************/
 
-#ifndef __iwl_commands_h__
-#define __iwl_commands_h__
+#ifndef __iwl4965_commands_h__
+#define __iwl4965_commands_h__
 
 enum {
        REPLY_ALIVE = 0x1,
@@ -141,13 +141,14 @@ enum {
 
 /******************************************************************************
  * (0)
- * Header
+ * Commonly used structures and definitions:
+ * Command header, rate_n_flags
  *
  *****************************************************************************/
 
 #define IWL_CMD_FAILED_MSK 0x40
 
-struct iwl_cmd_header {
+struct iwl4965_cmd_header {
        u8 cmd;
        u8 flags;
        /* We have 15 LSB to use as we please (MSB indicates
@@ -167,6 +168,89 @@ struct iwl_cmd_header {
        u8 data[0];
 } __attribute__ ((packed));
 
+/**
+ * 4965 rate_n_flags bit fields
+ *
+ * rate_n_flags format is used in following 4965 commands:
+ *  REPLY_4965_RX (response only)
+ *  REPLY_TX (both command and response)
+ *  REPLY_TX_LINK_QUALITY_CMD
+ *
+ * High-throughput (HT) rate format for bits 7:0 (bit 8 must be "1"):
+ *  2-0:  0)   6 Mbps
+ *        1)  12 Mbps
+ *        2)  18 Mbps
+ *        3)  24 Mbps
+ *        4)  36 Mbps
+ *        5)  48 Mbps
+ *        6)  54 Mbps
+ *        7)  60 Mbps
+ *
+ *    3:  0)  Single stream (SISO)
+ *        1)  Dual stream (MIMO)
+ *
+ *    5:  Value of 0x20 in bits 7:0 indicates 6 Mbps FAT duplicate data
+ *
+ * Legacy OFDM rate format for bits 7:0 (bit 8 must be "0", bit 9 "0"):
+ *  3-0:  0xD)   6 Mbps
+ *        0xF)   9 Mbps
+ *        0x5)  12 Mbps
+ *        0x7)  18 Mbps
+ *        0x9)  24 Mbps
+ *        0xB)  36 Mbps
+ *        0x1)  48 Mbps
+ *        0x3)  54 Mbps
+ *
+ * Legacy CCK rate format for bits 7:0 (bit 8 must be "0", bit 9 "1"):
+ *  3-0:   10)  1 Mbps
+ *         20)  2 Mbps
+ *         55)  5.5 Mbps
+ *        110)  11 Mbps
+ */
+#define RATE_MCS_CODE_MSK 0x7
+#define RATE_MCS_MIMO_POS 3
+#define RATE_MCS_MIMO_MSK 0x8
+#define RATE_MCS_HT_DUP_POS 5
+#define RATE_MCS_HT_DUP_MSK 0x20
+
+/* (1) HT format, (0) legacy format in bits 7:0 */
+#define RATE_MCS_FLAGS_POS 8
+#define RATE_MCS_HT_POS 8
+#define RATE_MCS_HT_MSK 0x100
+
+/* (1) CCK, (0) OFDM.  HT (bit 8) must be "0" for this bit to be valid */
+#define RATE_MCS_CCK_POS 9
+#define RATE_MCS_CCK_MSK 0x200
+
+/* (1) Use Green Field preamble */
+#define RATE_MCS_GF_POS 10
+#define RATE_MCS_GF_MSK 0x400
+
+/* (1) Use 40Mhz FAT channel width, (0) use 20 MHz legacy channel width */
+#define RATE_MCS_FAT_POS 11
+#define RATE_MCS_FAT_MSK 0x800
+
+/* (1) Duplicate data on both 20MHz channels.  FAT (bit 11) must be set. */
+#define RATE_MCS_DUP_POS 12
+#define RATE_MCS_DUP_MSK 0x1000
+
+/* (1) Short guard interval (0.4 usec), (0) normal GI (0.8 usec) */
+#define RATE_MCS_SGI_POS 13
+#define RATE_MCS_SGI_MSK 0x2000
+
+/**
+ * rate_n_flags Tx antenna masks (4965 has 2 transmitters):
+ * bit14:15 01 B inactive, A active
+ *          10 B active, A inactive
+ *          11 Both active
+ */
+#define RATE_MCS_ANT_A_POS     14
+#define RATE_MCS_ANT_B_POS     15
+#define RATE_MCS_ANT_A_MSK     0x4000
+#define RATE_MCS_ANT_B_MSK     0x8000
+#define RATE_MCS_ANT_AB_MSK    0xc000
+
+
 /******************************************************************************
  * (0a)
  * Alive and Error Commands & Responses:
@@ -179,7 +263,7 @@ struct iwl_cmd_header {
 /*
  * REPLY_ALIVE = 0x1 (response only, not a command)
  */
-struct iwl_alive_resp {
+struct iwl4965_alive_resp {
        u8 ucode_minor;
        u8 ucode_major;
        __le16 reserved1;
@@ -193,7 +277,7 @@ struct iwl_alive_resp {
        __le32 is_valid;
 } __attribute__ ((packed));
 
-struct iwl_init_alive_resp {
+struct iwl4965_init_alive_resp {
        u8 ucode_minor;
        u8 ucode_major;
        __le16 reserved1;
@@ -225,7 +309,7 @@ union tsf {
 /*
  * REPLY_ERROR = 0x2 (response only, not a command)
  */
-struct iwl_error_resp {
+struct iwl4965_error_resp {
        __le32 error_type;
        u8 cmd_id;
        u8 reserved1;
@@ -293,7 +377,7 @@ enum {
 /*
  * REPLY_RXON = 0x10 (command, has simple generic response)
  */
-struct iwl_rxon_cmd {
+struct iwl4965_rxon_cmd {
        u8 node_addr[6];
        __le16 reserved1;
        u8 bssid_addr[6];
@@ -316,7 +400,7 @@ struct iwl_rxon_cmd {
 /*
  * REPLY_RXON_ASSOC = 0x11 (command, has simple generic response)
  */
-struct iwl_rxon_assoc_cmd {
+struct iwl4965_rxon_assoc_cmd {
        __le32 flags;
        __le32 filter_flags;
        u8 ofdm_basic_rates;
@@ -330,7 +414,7 @@ struct iwl_rxon_assoc_cmd {
 /*
  * REPLY_RXON_TIMING = 0x14 (command, has simple generic response)
  */
-struct iwl_rxon_time_cmd {
+struct iwl4965_rxon_time_cmd {
        union tsf timestamp;
        __le16 beacon_interval;
        __le16 atim_window;
@@ -339,7 +423,7 @@ struct iwl_rxon_time_cmd {
        __le16 reserved;
 } __attribute__ ((packed));
 
-struct iwl_tx_power {
+struct iwl4965_tx_power {
        u8 tx_gain;             /* gain for analog radio */
        u8 dsp_atten;           /* gain for DSP */
 } __attribute__ ((packed));
@@ -351,27 +435,27 @@ struct tx_power_dual_stream {
        __le32 dw;
 } __attribute__ ((packed));
 
-struct iwl_tx_power_db {
+struct iwl4965_tx_power_db {
        struct tx_power_dual_stream power_tbl[POWER_TABLE_NUM_ENTRIES];
 } __attribute__ ((packed));
 
 /*
  * REPLY_CHANNEL_SWITCH = 0x72 (command, has simple generic response)
  */
-struct iwl_channel_switch_cmd {
+struct iwl4965_channel_switch_cmd {
        u8 band;
        u8 expect_beacon;
        __le16 channel;
        __le32 rxon_flags;
        __le32 rxon_filter_flags;
        __le32 switch_time;
-       struct iwl_tx_power_db tx_power;
+       struct iwl4965_tx_power_db tx_power;
 } __attribute__ ((packed));
 
 /*
  * CHANNEL_SWITCH_NOTIFICATION = 0x73 (notification only, not a command)
  */
-struct iwl_csa_notification {
+struct iwl4965_csa_notification {
        __le16 band;
        __le16 channel;
        __le32 status;          /* 0 - OK, 1 - fail */
@@ -382,7 +466,7 @@ struct iwl_csa_notification {
  * Quality-of-Service (QOS) Commands & Responses:
  *
  *****************************************************************************/
-struct iwl_ac_qos {
+struct iwl4965_ac_qos {
        __le16 cw_min;
        __le16 cw_max;
        u8 aifsn;
@@ -404,9 +488,9 @@ struct iwl_ac_qos {
 /*
  * REPLY_QOS_PARAM = 0x13 (command, has simple generic response)
  */
-struct iwl_qosparam_cmd {
+struct iwl4965_qosparam_cmd {
        __le32 qos_flags;
-       struct iwl_ac_qos ac[AC_NUM];
+       struct iwl4965_ac_qos ac[AC_NUM];
 } __attribute__ ((packed));
 
 /******************************************************************************
@@ -431,6 +515,14 @@ struct iwl_qosparam_cmd {
 #define        IWL_INVALID_STATION     255
 
 #define STA_FLG_PWR_SAVE_MSK           __constant_cpu_to_le32(1<<8);
+#define STA_FLG_RTS_MIMO_PROT_MSK      __constant_cpu_to_le32(1 << 17)
+#define STA_FLG_AGG_MPDU_8US_MSK       __constant_cpu_to_le32(1 << 18)
+#define STA_FLG_MAX_AGG_SIZE_POS       (19)
+#define STA_FLG_MAX_AGG_SIZE_MSK       __constant_cpu_to_le32(3 << 19)
+#define STA_FLG_FAT_EN_MSK             __constant_cpu_to_le32(1 << 21)
+#define STA_FLG_MIMO_DIS_MSK           __constant_cpu_to_le32(1 << 22)
+#define STA_FLG_AGG_MPDU_DENSITY_POS   (23)
+#define STA_FLG_AGG_MPDU_DENSITY_MSK   __constant_cpu_to_le32(7 << 23)
 
 #define STA_CONTROL_MODIFY_MSK         0x01
 
@@ -452,19 +544,7 @@ struct iwl_qosparam_cmd {
 #define STA_MODIFY_DELBA_TID_MSK       0x10
 #define BUILD_RAxTID(sta_id, tid)      (((sta_id) << 4) + (tid))
 
-/*
- * Antenna masks:
- * bit14:15 01 B inactive, A active
- *          10 B active, A inactive
- *          11 Both active
- */
-#define RATE_MCS_ANT_A_POS     14
-#define RATE_MCS_ANT_B_POS     15
-#define RATE_MCS_ANT_A_MSK     0x4000
-#define RATE_MCS_ANT_B_MSK     0x8000
-#define RATE_MCS_ANT_AB_MSK    0xc000
-
-struct iwl_keyinfo {
+struct iwl4965_keyinfo {
        __le16 key_flags;
        u8 tkip_rx_tsc_byte2;   /* TSC[2] for key mix ph1 detection */
        u8 reserved1;
@@ -484,11 +564,11 @@ struct sta_id_modify {
 /*
  * REPLY_ADD_STA = 0x18 (command)
  */
-struct iwl_addsta_cmd {
+struct iwl4965_addsta_cmd {
        u8 mode;
        u8 reserved[3];
        struct sta_id_modify sta;
-       struct iwl_keyinfo key;
+       struct iwl4965_keyinfo key;
        __le32 station_flags;
        __le32 station_flags_msk;
        __le16 tid_disable_tx;
@@ -502,7 +582,7 @@ struct iwl_addsta_cmd {
 /*
  * REPLY_ADD_STA = 0x18 (response)
  */
-struct iwl_add_sta_resp {
+struct iwl4965_add_sta_resp {
        u8 status;
 } __attribute__ ((packed));
 
@@ -514,7 +594,7 @@ struct iwl_add_sta_resp {
  *
  *****************************************************************************/
 
-struct iwl_rx_frame_stats {
+struct iwl4965_rx_frame_stats {
        u8 phy_count;
        u8 id;
        u8 rssi;
@@ -524,7 +604,7 @@ struct iwl_rx_frame_stats {
        u8 payload[0];
 } __attribute__ ((packed));
 
-struct iwl_rx_frame_hdr {
+struct iwl4965_rx_frame_hdr {
        __le16 channel;
        __le16 phy_flags;
        u8 reserved1;
@@ -554,7 +634,7 @@ struct iwl_rx_frame_hdr {
 #define        RX_RES_STATUS_BAD_ICV_MIC       (0x1 << 11)
 #define        RX_RES_STATUS_BAD_KEY_TTAK      (0x2 << 11)
 
-struct iwl_rx_frame_end {
+struct iwl4965_rx_frame_end {
        __le32 status;
        __le64 timestamp;
        __le32 beacon_timestamp;
@@ -568,10 +648,10 @@ struct iwl_rx_frame_end {
  * The actual offsets of the hdr and end are dynamic based on
  * stats.phy_count
  */
-struct iwl_rx_frame {
-       struct iwl_rx_frame_stats stats;
-       struct iwl_rx_frame_hdr hdr;
-       struct iwl_rx_frame_end end;
+struct iwl4965_rx_frame {
+       struct iwl4965_rx_frame_stats stats;
+       struct iwl4965_rx_frame_hdr hdr;
+       struct iwl4965_rx_frame_end end;
 } __attribute__ ((packed));
 
 /* Fixed (non-configurable) rx data from phy */
@@ -666,7 +746,7 @@ struct iwl4965_rx_mpdu_res_start {
  * TX command Frame life time
  */
 
-struct iwl_dram_scratch {
+struct iwl4965_dram_scratch {
        u8 try_cnt;
        u8 bt_kill_cnt;
        __le16 reserved;
@@ -675,11 +755,11 @@ struct iwl_dram_scratch {
 /*
  * REPLY_TX = 0x1c (command)
  */
-struct iwl_tx_cmd {
+struct iwl4965_tx_cmd {
        __le16 len;
        __le16 next_frame_len;
        __le32 tx_flags;
-       struct iwl_dram_scratch scratch;
+       struct iwl4965_dram_scratch scratch;
        __le32 rate_n_flags;
        u8 sta_id;
        u8 sec_ctl;
@@ -807,7 +887,7 @@ enum {
 /*
  * REPLY_TX = 0x1c (response)
  */
-struct iwl_tx_resp {
+struct iwl4965_tx_resp {
        u8 frame_count;         /* 1 no aggregation, >1 aggregation */
        u8 bt_kill_count;
        u8 failure_rts;
@@ -823,7 +903,7 @@ struct iwl_tx_resp {
 /*
  * REPLY_COMPRESSED_BA = 0xc5 (response only, not a command)
  */
-struct iwl_compressed_ba_resp {
+struct iwl4965_compressed_ba_resp {
        __le32 sta_addr_lo32;
        __le16 sta_addr_hi16;
        __le16 reserved;
@@ -839,11 +919,11 @@ struct iwl_compressed_ba_resp {
 /*
  * REPLY_TX_PWR_TABLE_CMD = 0x97 (command, has simple generic response)
  */
-struct iwl_txpowertable_cmd {
+struct iwl4965_txpowertable_cmd {
        u8 band;                /* 0: 5 GHz, 1: 2.4 GHz */
        u8 reserved;
        __le16 channel;
-       struct iwl_tx_power_db tx_power;
+       struct iwl4965_tx_power_db tx_power;
 } __attribute__ ((packed));
 
 /*RS_NEW_API: only TLC_RTS remains and moved to bit 0 */
@@ -856,7 +936,7 @@ struct iwl_txpowertable_cmd {
 #define  LINK_QUAL_ANT_B_MSK (1<<1)
 #define  LINK_QUAL_ANT_MSK   (LINK_QUAL_ANT_A_MSK|LINK_QUAL_ANT_B_MSK)
 
-struct iwl_link_qual_general_params {
+struct iwl4965_link_qual_general_params {
        u8 flags;
        u8 mimo_delimiter;
        u8 single_stream_ant_msk;
@@ -864,7 +944,7 @@ struct iwl_link_qual_general_params {
        u8 start_rate_index[LINK_QUAL_AC_NUM];
 } __attribute__ ((packed));
 
-struct iwl_link_qual_agg_params {
+struct iwl4965_link_qual_agg_params {
        __le16 agg_time_limit;
        u8 agg_dis_start_th;
        u8 agg_frame_cnt_limit;
@@ -874,12 +954,12 @@ struct iwl_link_qual_agg_params {
 /*
  * REPLY_TX_LINK_QUALITY_CMD = 0x4e (command, has simple generic response)
  */
-struct iwl_link_quality_cmd {
+struct iwl4965_link_quality_cmd {
        u8 sta_id;
        u8 reserved1;
        __le16 control;
-       struct iwl_link_qual_general_params general_params;
-       struct iwl_link_qual_agg_params agg_params;
+       struct iwl4965_link_qual_general_params general_params;
+       struct iwl4965_link_qual_agg_params agg_params;
        struct {
                __le32 rate_n_flags;
        } rs_table[LINK_QUAL_MAX_RETRY_NUM];
@@ -889,7 +969,7 @@ struct iwl_link_quality_cmd {
 /*
  * REPLY_BT_CONFIG = 0x9b (command, has simple generic response)
  */
-struct iwl_bt_cmd {
+struct iwl4965_bt_cmd {
        u8 flags;
        u8 lead_time;
        u8 max_kill;
@@ -915,18 +995,18 @@ struct iwl_bt_cmd {
                                 RXON_FILTER_ASSOC_MSK           | \
                                 RXON_FILTER_BCON_AWARE_MSK)
 
-struct iwl_measure_channel {
+struct iwl4965_measure_channel {
        __le32 duration;        /* measurement duration in extended beacon
                                 * format */
        u8 channel;             /* channel to measure */
-       u8 type;                /* see enum iwl_measure_type */
+       u8 type;                /* see enum iwl4965_measure_type */
        __le16 reserved;
 } __attribute__ ((packed));
 
 /*
  * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (command)
  */
-struct iwl_spectrum_cmd {
+struct iwl4965_spectrum_cmd {
        __le16 len;             /* number of bytes starting from token */
        u8 token;               /* token id */
        u8 id;                  /* measurement id -- 0 or 1 */
@@ -939,13 +1019,13 @@ struct iwl_spectrum_cmd {
        __le32 filter_flags;    /* rxon filter flags */
        __le16 channel_count;   /* minimum 1, maximum 10 */
        __le16 reserved3;
-       struct iwl_measure_channel channels[10];
+       struct iwl4965_measure_channel channels[10];
 } __attribute__ ((packed));
 
 /*
  * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (response)
  */
-struct iwl_spectrum_resp {
+struct iwl4965_spectrum_resp {
        u8 token;
        u8 id;                  /* id of the prior command replaced, or 0xff */
        __le16 status;          /* 0 - command will be handled
@@ -953,12 +1033,12 @@ struct iwl_spectrum_resp {
                                 *     measurement) */
 } __attribute__ ((packed));
 
-enum iwl_measurement_state {
+enum iwl4965_measurement_state {
        IWL_MEASUREMENT_START = 0,
        IWL_MEASUREMENT_STOP = 1,
 };
 
-enum iwl_measurement_status {
+enum iwl4965_measurement_status {
        IWL_MEASUREMENT_OK = 0,
        IWL_MEASUREMENT_CONCURRENT = 1,
        IWL_MEASUREMENT_CSA_CONFLICT = 2,
@@ -971,18 +1051,18 @@ enum iwl_measurement_status {
 
 #define NUM_ELEMENTS_IN_HISTOGRAM 8
 
-struct iwl_measurement_histogram {
+struct iwl4965_measurement_histogram {
        __le32 ofdm[NUM_ELEMENTS_IN_HISTOGRAM]; /* in 0.8usec counts */
        __le32 cck[NUM_ELEMENTS_IN_HISTOGRAM];  /* in 1usec counts */
 } __attribute__ ((packed));
 
 /* clear channel availability counters */
-struct iwl_measurement_cca_counters {
+struct iwl4965_measurement_cca_counters {
        __le32 ofdm;
        __le32 cck;
 } __attribute__ ((packed));
 
-enum iwl_measure_type {
+enum iwl4965_measure_type {
        IWL_MEASURE_BASIC = (1 << 0),
        IWL_MEASURE_CHANNEL_LOAD = (1 << 1),
        IWL_MEASURE_HISTOGRAM_RPI = (1 << 2),
@@ -995,7 +1075,7 @@ enum iwl_measure_type {
 /*
  * SPECTRUM_MEASURE_NOTIFICATION = 0x75 (notification only, not a command)
  */
-struct iwl_spectrum_notification {
+struct iwl4965_spectrum_notification {
        u8 id;                  /* measurement id -- 0 or 1 */
        u8 token;
        u8 channel_index;       /* index in measurement channel list */
@@ -1003,7 +1083,7 @@ struct iwl_spectrum_notification {
        __le32 start_time;      /* lower 32-bits of TSF */
        u8 band;                /* 0 - 5.2GHz, 1 - 2.4GHz */
        u8 channel;
-       u8 type;                /* see enum iwl_measurement_type */
+       u8 type;                /* see enum iwl4965_measurement_type */
        u8 reserved1;
        /* NOTE:  cca_ofdm, cca_cck, basic_type, and histogram are only only
         * valid if applicable for measurement type requested. */
@@ -1013,9 +1093,9 @@ struct iwl_spectrum_notification {
        u8 basic_type;          /* 0 - bss, 1 - ofdm preamble, 2 -
                                 * unidentified */
        u8 reserved2[3];
-       struct iwl_measurement_histogram histogram;
+       struct iwl4965_measurement_histogram histogram;
        __le32 stop_time;       /* lower 32-bits of TSF */
-       __le32 status;          /* see iwl_measurement_status */
+       __le32 status;          /* see iwl4965_measurement_status */
 } __attribute__ ((packed));
 
 /******************************************************************************
@@ -1025,7 +1105,7 @@ struct iwl_spectrum_notification {
  *****************************************************************************/
 
 /**
- * struct iwl_powertable_cmd - Power Table Command
+ * struct iwl4965_powertable_cmd - Power Table Command
  * @flags: See below:
  *
  * POWER_TABLE_CMD = 0x77 (command, has simple generic response)
@@ -1058,7 +1138,7 @@ struct iwl_spectrum_notification {
 #define IWL_POWER_SLEEP_OVER_DTIM_MSK          __constant_cpu_to_le16(1<<2)
 #define IWL_POWER_PCI_PM_MSK                   __constant_cpu_to_le16(1<<3)
 
-struct iwl_powertable_cmd {
+struct iwl4965_powertable_cmd {
        __le16 flags;
        u8 keep_alive_seconds;
        u8 debug_flags;
@@ -1072,7 +1152,7 @@ struct iwl_powertable_cmd {
  * PM_SLEEP_NOTIFICATION = 0x7A (notification only, not a command)
  * 3945 and 4965 identical.
  */
-struct iwl_sleep_notification {
+struct iwl4965_sleep_notification {
        u8 pm_sleep_mode;
        u8 pm_wakeup_src;
        __le16 reserved;
@@ -1102,14 +1182,14 @@ enum {
 #define CARD_STATE_CMD_DISABLE 0x00    /* Put card to sleep */
 #define CARD_STATE_CMD_ENABLE  0x01    /* Wake up card */
 #define CARD_STATE_CMD_HALT    0x02    /* Power down permanently */
-struct iwl_card_state_cmd {
+struct iwl4965_card_state_cmd {
        __le32 status;          /* CARD_STATE_CMD_* request new power state */
 } __attribute__ ((packed));
 
 /*
  * CARD_STATE_NOTIFICATION = 0xa1 (notification only, not a command)
  */
-struct iwl_card_state_notif {
+struct iwl4965_card_state_notif {
        __le32 flags;
 } __attribute__ ((packed));
 
@@ -1118,7 +1198,7 @@ struct iwl_card_state_notif {
 #define RF_CARD_DISABLED   0x04
 #define RXON_CARD_DISABLED 0x10
 
-struct iwl_ct_kill_config {
+struct iwl4965_ct_kill_config {
        __le32   reserved;
        __le32   critical_temperature_M;
        __le32   critical_temperature_R;
@@ -1130,7 +1210,7 @@ struct iwl_ct_kill_config {
  *
  *****************************************************************************/
 
-struct iwl_scan_channel {
+struct iwl4965_scan_channel {
        /* type is defined as:
         * 0:0 active (0 - passive)
         * 1:4 SSID direct
@@ -1139,12 +1219,12 @@ struct iwl_scan_channel {
         */
        u8 type;
        u8 channel;
-       struct iwl_tx_power tpc;
+       struct iwl4965_tx_power tpc;
        __le16 active_dwell;
        __le16 passive_dwell;
 } __attribute__ ((packed));
 
-struct iwl_ssid_ie {
+struct iwl4965_ssid_ie {
        u8 id;
        u8 len;
        u8 ssid[32];
@@ -1158,7 +1238,7 @@ struct iwl_ssid_ie {
 /*
  * REPLY_SCAN_CMD = 0x80 (command)
  */
-struct iwl_scan_cmd {
+struct iwl4965_scan_cmd {
        __le16 len;
        u8 reserved0;
        u8 channel_count;
@@ -1177,14 +1257,14 @@ struct iwl_scan_cmd {
        __le32 flags;
        __le32 filter_flags;
 
-       struct iwl_tx_cmd tx_cmd;
-       struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX];
+       struct iwl4965_tx_cmd tx_cmd;
+       struct iwl4965_ssid_ie direct_scan[PROBE_OPTION_MAX];
 
        u8 data[0];
        /*
         * The channels start after the probe request payload and are of type:
         *
-        * struct iwl_scan_channel channels[0];
+        * struct iwl4965_scan_channel channels[0];
         *
         * NOTE:  Only one band of channels can be scanned per pass.  You
         * can not mix 2.4GHz channels and 5.2GHz channels and must
@@ -1201,14 +1281,14 @@ struct iwl_scan_cmd {
 /*
  * REPLY_SCAN_CMD = 0x80 (response)
  */
-struct iwl_scanreq_notification {
+struct iwl4965_scanreq_notification {
        __le32 status;          /* 1: okay, 2: cannot fulfill request */
 } __attribute__ ((packed));
 
 /*
  * SCAN_START_NOTIFICATION = 0x82 (notification only, not a command)
  */
-struct iwl_scanstart_notification {
+struct iwl4965_scanstart_notification {
        __le32 tsf_low;
        __le32 tsf_high;
        __le32 beacon_timer;
@@ -1225,7 +1305,7 @@ struct iwl_scanstart_notification {
 /*
  * SCAN_RESULTS_NOTIFICATION = 0x83 (notification only, not a command)
  */
-struct iwl_scanresults_notification {
+struct iwl4965_scanresults_notification {
        u8 channel;
        u8 band;
        u8 reserved[2];
@@ -1237,7 +1317,7 @@ struct iwl_scanresults_notification {
 /*
  * SCAN_COMPLETE_NOTIFICATION = 0x84 (notification only, not a command)
  */
-struct iwl_scancomplete_notification {
+struct iwl4965_scancomplete_notification {
        u8 scanned_channels;
        u8 status;
        u8 reserved;
@@ -1256,8 +1336,8 @@ struct iwl_scancomplete_notification {
 /*
  * BEACON_NOTIFICATION = 0x90 (notification only, not a command)
  */
-struct iwl_beacon_notif {
-       struct iwl_tx_resp beacon_notify_hdr;
+struct iwl4965_beacon_notif {
+       struct iwl4965_tx_resp beacon_notify_hdr;
        __le32 low_tsf;
        __le32 high_tsf;
        __le32 ibss_mgr_status;
@@ -1266,8 +1346,8 @@ struct iwl_beacon_notif {
 /*
  * REPLY_TX_BEACON = 0x91 (command, has simple generic response)
  */
-struct iwl_tx_beacon_cmd {
-       struct iwl_tx_cmd tx;
+struct iwl4965_tx_beacon_cmd {
+       struct iwl4965_tx_cmd tx;
        __le16 tim_idx;
        u8 tim_size;
        u8 reserved1;
@@ -1458,7 +1538,7 @@ struct statistics_general {
  */
 #define IWL_STATS_CONF_CLEAR_STATS __constant_cpu_to_le32(0x1) /* see above */
 #define IWL_STATS_CONF_DISABLE_NOTIF __constant_cpu_to_le32(0x2)/* see above */
-struct iwl_statistics_cmd {
+struct iwl4965_statistics_cmd {
        __le32 configuration_flags;     /* IWL_STATS_CONF_* */
 } __attribute__ ((packed));
 
@@ -1479,7 +1559,7 @@ struct iwl_statistics_cmd {
  */
 #define STATISTICS_REPLY_FLG_BAND_24G_MSK         __constant_cpu_to_le32(0x2)
 #define STATISTICS_REPLY_FLG_FAT_MODE_MSK         __constant_cpu_to_le32(0x8)
-struct iwl_notif_statistics {
+struct iwl4965_notif_statistics {
        __le32 flag;
        struct statistics_rx rx;
        struct statistics_tx tx;
@@ -1494,32 +1574,285 @@ struct iwl_notif_statistics {
  * then this notification will be sent. */
 #define CONSECUTIVE_MISSED_BCONS_TH 20
 
-struct iwl_missed_beacon_notif {
+struct iwl4965_missed_beacon_notif {
        __le32 consequtive_missed_beacons;
        __le32 total_missed_becons;
        __le32 num_expected_beacons;
        __le32 num_recvd_beacons;
 } __attribute__ ((packed));
 
+
 /******************************************************************************
  * (11)
  * Rx Calibration Commands:
  *
+ * With the uCode used for open source drivers, most Tx calibration (except
+ * for Tx Power) and most Rx calibration is done by uCode during the
+ * "initialize" phase of uCode boot.  Driver must calibrate only:
+ *
+ * 1)  Tx power (depends on temperature), described elsewhere
+ * 2)  Receiver gain balance (optimize MIMO, and detect disconnected antennas)
+ * 3)  Receiver sensitivity (to optimize signal detection)
+ *
  *****************************************************************************/
 
-#define PHY_CALIBRATE_DIFF_GAIN_CMD (7)
-#define HD_TABLE_SIZE  (11)
+/**
+ * SENSITIVITY_CMD = 0xa8 (command, has simple generic response)
+ *
+ * This command sets up the Rx signal detector for a sensitivity level that
+ * is high enough to lock onto all signals within the associated network,
+ * but low enough to ignore signals that are below a certain threshold, so as
+ * not to have too many "false alarms".  False alarms are signals that the
+ * Rx DSP tries to lock onto, but then discards after determining that they
+ * are noise.
+ *
+ * The optimum number of false alarms is between 5 and 50 per 200 TUs
+ * (200 * 1024 uSecs, i.e. 204.8 milliseconds) of actual Rx time (i.e.
+ * time listening, not transmitting).  Driver must adjust sensitivity so that
+ * the ratio of actual false alarms to actual Rx time falls within this range.
+ *
+ * While associated, uCode delivers STATISTICS_NOTIFICATIONs after each
+ * received beacon.  These provide information to the driver to analyze the
+ * sensitivity.  Don't analyze statistics that come in from scanning, or any
+ * other non-associated-network source.  Pertinent statistics include:
+ *
+ * From "general" statistics (struct statistics_rx_non_phy):
+ *
+ * (beacon_energy_[abc] & 0x0FF00) >> 8 (unsigned, higher value is lower level)
+ *   Measure of energy of desired signal.  Used for establishing a level
+ *   below which the device does not detect signals.
+ *
+ * (beacon_silence_rssi_[abc] & 0x0FF00) >> 8 (unsigned, units in dB)
+ *   Measure of background noise in silent period after beacon.
+ *
+ * channel_load
+ *   uSecs of actual Rx time during beacon period (varies according to
+ *   how much time was spent transmitting).
+ *
+ * From "cck" and "ofdm" statistics (struct statistics_rx_phy), separately:
+ *
+ * false_alarm_cnt
+ *   Signal locks abandoned early (before phy-level header).
+ *
+ * plcp_err
+ *   Signal locks abandoned late (during phy-level header).
+ *
+ * NOTE:  Both false_alarm_cnt and plcp_err increment monotonically from
+ *        beacon to beacon, i.e. each value is an accumulation of all errors
+ *        before and including the latest beacon.  Values will wrap around to 0
+ *        after counting up to 2^32 - 1.  Driver must differentiate vs.
+ *        previous beacon's values to determine # false alarms in the current
+ *        beacon period.
+ *
+ * Total number of false alarms = false_alarms + plcp_errs
+ *
+ * For OFDM, adjust the following table entries in struct iwl_sensitivity_cmd
+ * (notice that the start points for OFDM are at or close to settings for
+ * maximum sensitivity):
+ *
+ *                                             START  /  MIN  /  MAX
+ *   HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX          90   /   85  /  120
+ *   HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX     170   /  170  /  210
+ *   HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX         105   /  105  /  140
+ *   HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX     220   /  220  /  270
+ *
+ *   If actual rate of OFDM false alarms (+ plcp_errors) is too high
+ *   (greater than 50 for each 204.8 msecs listening), reduce sensitivity
+ *   by *adding* 1 to all 4 of the table entries above, up to the max for
+ *   each entry.  Conversely, if false alarm rate is too low (less than 5
+ *   for each 204.8 msecs listening), *subtract* 1 from each entry to
+ *   increase sensitivity.
+ *
+ * For CCK sensitivity, keep track of the following:
+ *
+ *   1).  20-beacon history of maximum background noise, indicated by
+ *        (beacon_silence_rssi_[abc] & 0x0FF00), units in dB, across the
+ *        3 receivers.  For any given beacon, the "silence reference" is
+ *        the maximum of last 60 samples (20 beacons * 3 receivers).
+ *
+ *   2).  10-beacon history of strongest signal level, as indicated
+ *        by (beacon_energy_[abc] & 0x0FF00) >> 8, across the 3 receivers,
+ *        i.e. the strength of the signal through the best receiver at the
+ *        moment.  These measurements are "upside down", with lower values
+ *        for stronger signals, so max energy will be *minimum* value.
+ *
+ *        Then for any given beacon, the driver must determine the *weakest*
+ *        of the strongest signals; this is the minimum level that needs to be
+ *        successfully detected, when using the best receiver at the moment.
+ *        "Max cck energy" is the maximum (higher value means lower energy!)
+ *        of the last 10 minima.  Once this is determined, driver must add
+ *        a little margin by adding "6" to it.
+ *
+ *   3).  Number of consecutive beacon periods with too few false alarms.
+ *        Reset this to 0 at the first beacon period that falls within the
+ *        "good" range (5 to 50 false alarms per 204.8 milliseconds rx).
+ *
+ * Then, adjust the following CCK table entries in struct iwl_sensitivity_cmd
+ * (notice that the start points for CCK are at maximum sensitivity):
+ *
+ *                                             START  /  MIN  /  MAX
+ *   HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX         125   /  125  /  200
+ *   HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX     200   /  200  /  400
+ *   HD_MIN_ENERGY_CCK_DET_INDEX                100   /    0  /  100
+ *
+ *   If actual rate of CCK false alarms (+ plcp_errors) is too high
+ *   (greater than 50 for each 204.8 msecs listening), method for reducing
+ *   sensitivity is:
+ *
+ *   1)  *Add* 3 to value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX,
+ *       up to max 400.
+ *
+ *   2)  If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX is < 160,
+ *       sensitivity has been reduced a significant amount; bring it up to
+ *       a moderate 161.  Otherwise, *add* 3, up to max 200.
+ *
+ *   3)  a)  If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX is > 160,
+ *       sensitivity has been reduced only a moderate or small amount;
+ *       *subtract* 2 from value in HD_MIN_ENERGY_CCK_DET_INDEX,
+ *       down to min 0.  Otherwise (if gain has been significantly reduced),
+ *       don't change the HD_MIN_ENERGY_CCK_DET_INDEX value.
+ *
+ *       b)  Save a snapshot of the "silence reference".
+ *
+ *   If actual rate of CCK false alarms (+ plcp_errors) is too low
+ *   (less than 5 for each 204.8 msecs listening), method for increasing
+ *   sensitivity is used only if:
+ *
+ *   1a)  Previous beacon did not have too many false alarms
+ *   1b)  AND difference between previous "silence reference" and current
+ *        "silence reference" (prev - current) is 2 or more,
+ *   OR 2)  100 or more consecutive beacon periods have had rate of
+ *          less than 5 false alarms per 204.8 milliseconds rx time.
+ *
+ *   Method for increasing sensitivity:
+ *
+ *   1)  *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX,
+ *       down to min 125.
+ *
+ *   2)  *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX,
+ *       down to min 200.
+ *
+ *   3)  *Add* 2 to value in HD_MIN_ENERGY_CCK_DET_INDEX, up to max 100.
+ *
+ *   If actual rate of CCK false alarms (+ plcp_errors) is within good range
+ *   (between 5 and 50 for each 204.8 msecs listening):
+ *
+ *   1)  Save a snapshot of the silence reference.
+ *
+ *   2)  If previous beacon had too many CCK false alarms (+ plcp_errors),
+ *       give some extra margin to energy threshold by *subtracting* 8
+ *       from value in HD_MIN_ENERGY_CCK_DET_INDEX.
+ *
+ *   For all cases (too few, too many, good range), make sure that the CCK
+ *   detection threshold (energy) is below the energy level for robust
+ *   detection over the past 10 beacon periods, the "Max cck energy".
+ *   Lower values mean higher energy; this means making sure that the value
+ *   in HD_MIN_ENERGY_CCK_DET_INDEX is at or *above* "Max cck energy".
+ *
+ * Driver should set the following entries to fixed values:
+ *
+ *   HD_MIN_ENERGY_OFDM_DET_INDEX               100
+ *   HD_BARKER_CORR_TH_ADD_MIN_INDEX            190
+ *   HD_BARKER_CORR_TH_ADD_MIN_MRC_INDEX        390
+ *   HD_OFDM_ENERGY_TH_IN_INDEX                  62
+ */
 
-struct iwl_sensitivity_cmd {
-       __le16 control;
-       __le16 table[HD_TABLE_SIZE];
+/*
+ * Table entries in SENSITIVITY_CMD (struct iwl4965_sensitivity_cmd)
+ */
+#define HD_TABLE_SIZE  (11)    /* number of entries */
+#define HD_MIN_ENERGY_CCK_DET_INDEX                 (0)        /* table indexes */
+#define HD_MIN_ENERGY_OFDM_DET_INDEX                (1)
+#define HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX          (2)
+#define HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX      (3)
+#define HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX      (4)
+#define HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX          (5)
+#define HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX      (6)
+#define HD_BARKER_CORR_TH_ADD_MIN_INDEX             (7)
+#define HD_BARKER_CORR_TH_ADD_MIN_MRC_INDEX         (8)
+#define HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX          (9)
+#define HD_OFDM_ENERGY_TH_IN_INDEX                  (10)
+
+/* Control field in struct iwl4965_sensitivity_cmd */
+#define SENSITIVITY_CMD_CONTROL_DEFAULT_TABLE  __constant_cpu_to_le16(0)
+#define SENSITIVITY_CMD_CONTROL_WORK_TABLE     __constant_cpu_to_le16(1)
+
+/**
+ * struct iwl4965_sensitivity_cmd
+ * @control:  (1) updates working table, (0) updates default table
+ * @table:  energy threshold values, use HD_* as index into table
+ *
+ * Always use "1" in "control" to update uCode's working table and DSP.
+ */
+struct iwl4965_sensitivity_cmd {
+       __le16 control;                 /* always use "1" */
+       __le16 table[HD_TABLE_SIZE];    /* use HD_* as index */
 } __attribute__ ((packed));
 
-struct iwl_calibration_cmd {
-       u8 opCode;
-       u8 flags;
+
+/**
+ * REPLY_PHY_CALIBRATION_CMD = 0xb0 (command, has simple generic response)
+ *
+ * This command sets the relative gains of 4965's 3 radio receiver chains.
+ *
+ * After the first association, driver should accumulate signal and noise
+ * statistics from the STATISTICS_NOTIFICATIONs that follow the first 20
+ * beacons from the associated network (don't collect statistics that come
+ * in from scanning, or any other non-network source).
+ *
+ * DISCONNECTED ANTENNA:
+ *
+ * Driver should determine which antennas are actually connected, by comparing
+ * average beacon signal levels for the 3 Rx chains.  Accumulate (add) the
+ * following values over 20 beacons, one accumulator for each of the chains
+ * a/b/c, from struct statistics_rx_non_phy:
+ *
+ * beacon_rssi_[abc] & 0x0FF (unsigned, units in dB)
+ *
+ * Find the strongest signal from among a/b/c.  Compare the other two to the
+ * strongest.  If any signal is more than 15 dB (times 20, unless you
+ * divide the accumulated values by 20) below the strongest, the driver
+ * considers that antenna to be disconnected, and should not try to use that
+ * antenna/chain for Rx or Tx.  If both A and B seem to be disconnected,
+ * driver should declare the stronger one as connected, and attempt to use it
+ * (A and B are the only 2 Tx chains!).
+ *
+ *
+ * RX BALANCE:
+ *
+ * Driver should balance the 3 receivers (but just the ones that are connected
+ * to antennas, see above) for gain, by comparing the average signal levels
+ * detected during the silence after each beacon (background noise).
+ * Accumulate (add) the following values over 20 beacons, one accumulator for
+ * each of the chains a/b/c, from struct statistics_rx_non_phy:
+ *
+ * beacon_silence_rssi_[abc] & 0x0FF (unsigned, units in dB)
+ *
+ * Find the weakest background noise level from among a/b/c.  This Rx chain
+ * will be the reference, with 0 gain adjustment.  Attenuate other channels by
+ * finding noise difference:
+ *
+ * (accum_noise[i] - accum_noise[reference]) / 30
+ *
+ * The "30" adjusts the dB in the 20 accumulated samples to units of 1.5 dB.
+ * For use in diff_gain_[abc] fields of struct iwl_calibration_cmd, the
+ * driver should limit the difference results to a range of 0-3 (0-4.5 dB),
+ * and set bit 2 to indicate "reduce gain".  The value for the reference
+ * (weakest) chain should be "0".
+ *
+ * diff_gain_[abc] bit fields:
+ *   2: (1) reduce gain, (0) increase gain
+ * 1-0: amount of gain, units of 1.5 dB
+ */
+
+/* "Differential Gain" opcode used in REPLY_PHY_CALIBRATION_CMD. */
+#define PHY_CALIBRATE_DIFF_GAIN_CMD (7)
+
+struct iwl4965_calibration_cmd {
+       u8 opCode;              /* PHY_CALIBRATE_DIFF_GAIN_CMD (7) */
+       u8 flags;               /* not used */
        __le16 reserved;
-       s8 diff_gain_a;
+       s8 diff_gain_a;         /* see above */
        s8 diff_gain_b;
        s8 diff_gain_c;
        u8 reserved1;
@@ -1538,7 +1871,7 @@ struct iwl_calibration_cmd {
  * For each of 3 possible LEDs (Activity/Link/Tech, selected by "id" field),
  * this command turns it on or off, or sets up a periodic blinking cycle.
  */
-struct iwl_led_cmd {
+struct iwl4965_led_cmd {
        __le32 interval;        /* "interval" in uSec */
        u8 id;                  /* 1: Activity, 2: Link, 3: Tech */
        u8 off;                 /* # intervals off while blinking;
@@ -1554,29 +1887,29 @@ struct iwl_led_cmd {
  *
  *****************************************************************************/
 
-struct iwl_rx_packet {
+struct iwl4965_rx_packet {
        __le32 len;
-       struct iwl_cmd_header hdr;
+       struct iwl4965_cmd_header hdr;
        union {
-               struct iwl_alive_resp alive_frame;
-               struct iwl_rx_frame rx_frame;
-               struct iwl_tx_resp tx_resp;
-               struct iwl_spectrum_notification spectrum_notif;
-               struct iwl_csa_notification csa_notif;
-               struct iwl_error_resp err_resp;
-               struct iwl_card_state_notif card_state_notif;
-               struct iwl_beacon_notif beacon_status;
-               struct iwl_add_sta_resp add_sta;
-               struct iwl_sleep_notification sleep_notif;
-               struct iwl_spectrum_resp spectrum;
-               struct iwl_notif_statistics stats;
-               struct iwl_compressed_ba_resp compressed_ba;
-               struct iwl_missed_beacon_notif missed_beacon;
+               struct iwl4965_alive_resp alive_frame;
+               struct iwl4965_rx_frame rx_frame;
+               struct iwl4965_tx_resp tx_resp;
+               struct iwl4965_spectrum_notification spectrum_notif;
+               struct iwl4965_csa_notification csa_notif;
+               struct iwl4965_error_resp err_resp;
+               struct iwl4965_card_state_notif card_state_notif;
+               struct iwl4965_beacon_notif beacon_status;
+               struct iwl4965_add_sta_resp add_sta;
+               struct iwl4965_sleep_notification sleep_notif;
+               struct iwl4965_spectrum_resp spectrum;
+               struct iwl4965_notif_statistics stats;
+               struct iwl4965_compressed_ba_resp compressed_ba;
+               struct iwl4965_missed_beacon_notif missed_beacon;
                __le32 status;
                u8 raw[0];
        } u;
 } __attribute__ ((packed));
 
-#define IWL_RX_FRAME_SIZE        (4 + sizeof(struct iwl_rx_frame))
+#define IWL_RX_FRAME_SIZE        (4 + sizeof(struct iwl4965_rx_frame))
 
-#endif                         /* __iwl_commands_h__ */
+#endif                         /* __iwl4965_commands_h__ */