]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/wireless/iwlwifi/iwl-4965.h
iwlwifi: Add power level support
[linux-2.6-omap-h63xx.git] / drivers / net / wireless / iwlwifi / iwl-4965.h
index 069e591981b264b074b6e754d3d6e5d89a416b27..0550d12e5c6066c85e2876a41e38b150e32a0967 100644 (file)
 #include <linux/kernel.h>
 #include <net/ieee80211_radiotap.h>
 
-/* Hardware specific file defines the PCI IDs table for that hardware module */
-extern struct pci_device_id iwl4965_hw_card_ids[];
-
 #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-debug.h"
 #include "iwl-led.h"
+#include "iwl-power.h"
+
+/* configuration for the iwl4965 */
+extern struct iwl_cfg iwl4965_agn_cfg;
 
 /* Change firmware file name, using "-" and incrementing number,
  *   *only* when uCode interface or architecture changes so that it
@@ -251,29 +253,9 @@ struct iwl4965_clip_group {
 
 /* Power management (not Tx power) structures */
 
-struct iwl4965_power_vec_entry {
-       struct iwl4965_powertable_cmd cmd;
-       u8 no_dtim;
-};
-#define IWL_POWER_RANGE_0  (0)
-#define IWL_POWER_RANGE_1  (1)
-
-#define IWL_POWER_MODE_CAM     0x00    /* Continuously Aware Mode, always on */
-#define IWL_POWER_INDEX_3      0x03
-#define IWL_POWER_INDEX_5      0x05
-#define IWL_POWER_AC           0x06
-#define IWL_POWER_BATTERY      0x07
-#define IWL_POWER_LIMIT                0x07
-#define IWL_POWER_MASK         0x0F
-#define IWL_POWER_ENABLED      0x10
-#define IWL_POWER_LEVEL(x)     ((x) & IWL_POWER_MASK)
-
-struct iwl4965_power_mgr {
-       spinlock_t lock;
-       struct iwl4965_power_vec_entry pwr_range_0[IWL_POWER_AC];
-       struct iwl4965_power_vec_entry pwr_range_1[IWL_POWER_AC];
-       u8 active_index;
-       u32 dtim_val;
+enum iwl_pwr_src {
+       IWL_PWR_SRC_VMAIN,
+       IWL_PWR_SRC_VAUX,
 };
 
 #define IEEE80211_DATA_LEN              2304
@@ -293,8 +275,8 @@ struct iwl4965_frame {
 
 #define SEQ_TO_QUEUE(x)  ((x >> 8) & 0xbf)
 #define QUEUE_TO_SEQ(x)  ((x & 0xbf) << 8)
-#define SEQ_TO_INDEX(x) (x & 0xff)
-#define INDEX_TO_SEQ(x) (x & 0xff)
+#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)
@@ -413,25 +395,6 @@ struct iwl4965_rx_queue {
 #define MAX_B_CHANNELS  14
 #define MIN_B_CHANNELS  1
 
-#define STATUS_HCMD_ACTIVE     0       /* host command in progress */
-#define STATUS_INT_ENABLED     1
-#define STATUS_RF_KILL_HW      2
-#define STATUS_RF_KILL_SW      3
-#define STATUS_INIT            4
-#define STATUS_ALIVE           5
-#define STATUS_READY           6
-#define STATUS_TEMPERATURE     7
-#define STATUS_GEO_CONFIGURED  8
-#define STATUS_EXIT_PENDING    9
-#define STATUS_IN_SUSPEND      10
-#define STATUS_STATISTICS      11
-#define STATUS_SCANNING                12
-#define STATUS_SCAN_ABORTING   13
-#define STATUS_SCAN_HW         14
-#define STATUS_POWER_PMI       15
-#define STATUS_FW_ERROR                16
-#define STATUS_CONF_PENDING    17
-
 #define MAX_TID_COUNT        9
 
 #define IWL_INVALID_RATE     0xFF
@@ -479,6 +442,7 @@ struct iwl4965_tid_data {
 struct iwl4965_hw_key {
        enum ieee80211_key_alg alg;
        int keylen;
+       u8 keyidx;
        struct ieee80211_key_conf *conf;
        u8 key[32];
 };
@@ -583,8 +547,31 @@ struct iwl4965_ibss_seq {
        struct list_head list;
 };
 
+struct iwl_sensitivity_ranges {
+       u16 min_nrg_cck;
+       u16 max_nrg_cck;
+
+       u16 nrg_th_cck;
+       u16 nrg_th_ofdm;
+
+       u16 auto_corr_min_ofdm;
+       u16 auto_corr_min_ofdm_mrc;
+       u16 auto_corr_min_ofdm_x1;
+       u16 auto_corr_min_ofdm_mrc_x1;
+
+       u16 auto_corr_max_ofdm;
+       u16 auto_corr_max_ofdm_mrc;
+       u16 auto_corr_max_ofdm_x1;
+       u16 auto_corr_max_ofdm_mrc_x1;
+
+       u16 auto_corr_max_cck;
+       u16 auto_corr_max_cck_mrc;
+       u16 auto_corr_min_cck;
+       u16 auto_corr_min_cck_mrc;
+};
+
 /**
- * struct iwl4965_driver_hw_info
+ * struct iwl_hw_params
  * @max_txq_num: Max # Tx queues supported
  * @tx_cmd_len: Size of Tx command (but not including frame itself)
  * @tx_ant_num: Number of TX antennas
@@ -593,21 +580,24 @@ struct iwl4965_ibss_seq {
  * @max_rxq_log: Log-base-2 of max_rxq_size
  * @max_stations:
  * @bcast_sta_id:
- * @shared_virt: Pointer to driver/uCode shared Tx Byte Counts and Rx status
- * @shared_phys: Physical Pointer to Tx Byte Counts and Rx status
+ * @struct iwl_sensitivity_ranges: range of sensitivity values
  */
-struct iwl4965_driver_hw_info {
+struct iwl_hw_params {
        u16 max_txq_num;
        u16 tx_cmd_len;
-       u16 tx_ant_num;
+       u8  tx_chains_num;
+       u8  rx_chains_num;
+       u8  valid_tx_ant;
+       u8  valid_rx_ant;
        u16 max_rxq_size;
+       u16 max_rxq_log;
        u32 rx_buf_size;
        u32 max_pkt_size;
-       u16 max_rxq_log;
        u8  max_stations;
        u8  bcast_sta_id;
-       void *shared_virt;
-       dma_addr_t shared_phys;
+#ifdef CONFIG_IWLWIFI_RUN_TIME_CALIB
+       const struct iwl_sensitivity_ranges *sens;
+#endif
 };
 
 #define HT_SHORT_GI_20MHZ_ONLY          (1 << 0)
@@ -659,11 +649,10 @@ extern unsigned int iwl4965_fill_beacon_frame(struct iwl_priv *priv,
                                        const u8 *dest, int left);
 extern int iwl4965_rx_queue_update_write_ptr(struct iwl_priv *priv,
                                         struct iwl4965_rx_queue *q);
-extern int iwl4965_send_statistics_request(struct iwl_priv *priv);
-extern void iwl4965_set_decrypted_flag(struct iwl_priv *priv, struct sk_buff *skb,
-                                  u32 decrypt_res,
-                                  struct ieee80211_rx_status *stats);
 extern __le16 *ieee80211_get_qos_ctrl(struct ieee80211_hdr *hdr);
+extern void iwl4965_update_chain_flags(struct iwl_priv *priv);
+int iwl4965_set_pwr_src(struct iwl_priv *priv, enum iwl_pwr_src src);
+
 int iwl4965_init_geos(struct iwl_priv *priv);
 void iwl4965_free_geos(struct iwl_priv *priv);
 
@@ -697,7 +686,7 @@ extern void iwl4965_hw_rx_handler_setup(struct iwl_priv *priv);
 extern void iwl4965_hw_setup_deferred_work(struct iwl_priv *priv);
 extern void iwl4965_hw_cancel_deferred_work(struct iwl_priv *priv);
 extern int iwl4965_hw_rxq_stop(struct iwl_priv *priv);
-extern int iwl4965_hw_set_hw_setting(struct iwl_priv *priv);
+extern int iwl4965_hw_set_hw_params(struct iwl_priv *priv);
 extern int iwl4965_hw_nic_init(struct iwl_priv *priv);
 extern int iwl4965_hw_nic_stop_master(struct iwl_priv *priv);
 extern void iwl4965_hw_txq_ctx_free(struct iwl_priv *priv);
@@ -725,20 +714,21 @@ extern void iwl4965_disable_events(struct iwl_priv *priv);
 extern int iwl4965_get_temperature(const struct iwl_priv *priv);
 
 /**
- * iwl4965_hw_find_station - Find station id for a given BSSID
+ * iwl_find_station - Find station id for a given BSSID
  * @bssid: MAC address of station ID to find
  *
  * NOTE:  This should not be hardware specific but the code has
  * not yet been merged into a single common layer for managing the
  * station tables.
  */
-extern u8 iwl4965_hw_find_station(struct iwl_priv *priv, const u8 *bssid);
+extern u8 iwl_find_station(struct iwl_priv *priv, const u8 *bssid);
 
 extern int iwl4965_hw_channel_switch(struct iwl_priv *priv, u16 channel);
 extern int iwl4965_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index);
 extern int iwl4965_queue_space(const struct iwl4965_queue *q);
 struct iwl_priv;
 
+extern void iwl4965_radio_kill_sw(struct iwl_priv *priv, int disable_radio);
 /*
  * Forward declare iwl-4965.c functions for iwl-base.c
  */
@@ -750,9 +740,6 @@ extern void iwl4965_add_station(struct iwl_priv *priv, const u8 *addr,
 extern void iwl4965_set_rxon_chain(struct iwl_priv *priv);
 extern int iwl4965_alive_notify(struct iwl_priv *priv);
 extern void iwl4965_update_rate_scaling(struct iwl_priv *priv, u8 mode);
-extern void iwl4965_chain_noise_reset(struct iwl_priv *priv);
-extern void iwl4965_init_sensitivity(struct iwl_priv *priv, u8 flags,
-                                    u8 force);
 extern void iwl4965_rf_kill_ct_config(struct iwl_priv *priv);
 extern void iwl4965_hwrate_to_tx_control(struct iwl_priv *priv,
                                         u32 rate_n_flags,
@@ -836,23 +823,8 @@ struct iwl4965_lq_mngr {
 #define MAX_FA_CCK   50
 #define MIN_FA_CCK   5
 
-#define NRG_MIN_CCK  97
-#define NRG_MAX_CCK  0
-
-#define AUTO_CORR_MIN_OFDM        85
-#define AUTO_CORR_MIN_OFDM_MRC    170
-#define AUTO_CORR_MIN_OFDM_X1     105
-#define AUTO_CORR_MIN_OFDM_MRC_X1 220
-#define AUTO_CORR_MAX_OFDM        120
-#define AUTO_CORR_MAX_OFDM_MRC    210
-#define AUTO_CORR_MAX_OFDM_X1     140
-#define AUTO_CORR_MAX_OFDM_MRC_X1 270
 #define AUTO_CORR_STEP_OFDM       1
 
-#define AUTO_CORR_MIN_CCK      (125)
-#define AUTO_CORR_MAX_CCK      (200)
-#define AUTO_CORR_MIN_CCK_MRC  200
-#define AUTO_CORR_MAX_CCK_MRC  400
 #define AUTO_CORR_STEP_CCK     3
 #define AUTO_CORR_MAX_TH_CCK   160
 
@@ -883,11 +855,6 @@ enum iwl4965_chain_noise_state {
        IWL_CHAIN_NOISE_CALIBRATED = 2,
 };
 
-enum iwl4965_sensitivity_state {
-       IWL_SENS_CALIB_ALLOWED = 0,
-       IWL_SENS_CALIB_NEED_REINIT = 1,
-};
-
 enum iwl4965_calib_enabled_state {
        IWL_CALIB_DISABLED = 0,  /* must be 0 */
        IWL_CALIB_ENABLED = 1,
@@ -902,8 +869,9 @@ struct statistics_general_data {
        u32 beacon_energy_c;
 };
 
+#ifdef CONFIG_IWLWIFI_RUN_TIME_CALIB
 /* Sensitivity calib data */
-struct iwl4965_sensitivity_data {
+struct iwl_sensitivity_data {
        u32 auto_corr_ofdm;
        u32 auto_corr_ofdm_mrc;
        u32 auto_corr_ofdm_x1;
@@ -927,12 +895,10 @@ struct iwl4965_sensitivity_data {
        s32 nrg_auto_corr_silence_diff;
        u32 num_in_cck_no_fa;
        u32 nrg_th_ofdm;
-
-       u8 state;
 };
 
 /* Chain noise (differential Rx gain) calib data */
-struct iwl4965_chain_noise_data {
+struct iwl_chain_noise_data {
        u8 state;
        u16 beacon_count;
        u32 chain_noise_a;
@@ -945,6 +911,7 @@ struct iwl4965_chain_noise_data {
        u8 delta_gain_code[NUM_RX_CHAINS];
        u8 radio_write;
 };
+#endif /* CONFIG_IWLWIFI_RUN_TIME_CALIB */
 
 #define        EEPROM_SEM_TIMEOUT 10           /* milliseconds */
 #define EEPROM_SEM_RETRY_LIMIT 1000    /* number of attempts (not time) */
@@ -959,6 +926,8 @@ enum {
 
 #endif
 
+#define IWL_MAX_NUM_QUEUES     20 /* FIXME: do dynamic allocation */
+
 struct iwl_priv {
 
        /* ieee device used by generic ieee processing code */
@@ -1012,7 +981,6 @@ struct iwl_priv {
        u8 direct_ssid_len;
        u8 direct_ssid[IW_ESSID_MAX_SIZE];
        struct iwl4965_scan_cmd *scan;
-       u8 only_active_channel;
 
        /* spinlock */
        spinlock_t lock;        /* protect general shared data */
@@ -1050,8 +1018,11 @@ struct iwl_priv {
         * 4965's initialize alive response contains some calibration data. */
        struct iwl4965_init_alive_resp card_alive_init;
        struct iwl4965_alive_resp card_alive;
+#ifdef CONFIG_IWLWIFI_RFKILL
+       struct iwl_rfkill_mngr rfkill_mngr;
+#endif
 
-#ifdef CONFIG_IWL4965_LEDS
+#ifdef CONFIG_IWLWIFI_LEDS
        struct iwl4965_led led[IWL_LED_TRG_MAX];
        unsigned long last_blink_time;
        u8 last_blink_rate;
@@ -1062,16 +1033,15 @@ struct iwl_priv {
        u16 active_rate;
        u16 active_rate_basic;
 
-       u8 call_post_assoc_from_beacon;
        u8 assoc_station_added;
        u8 use_ant_b_for_management_frame;      /* Tx antenna selection */
        u8 valid_antenna;       /* Bit mask of antennas actually connected */
-#ifdef CONFIG_IWL4965_SENSITIVITY
-       struct iwl4965_sensitivity_data sensitivity_data;
-       struct iwl4965_chain_noise_data chain_noise_data;
        u8 start_calib;
+#ifdef CONFIG_IWLWIFI_RUN_TIME_CALIB
+       struct iwl_sensitivity_data sensitivity_data;
+       struct iwl_chain_noise_data chain_noise_data;
        __le16 sensitivity_tbl[HD_TABLE_SIZE];
-#endif /*CONFIG_IWL4965_SENSITIVITY*/
+#endif /*CONFIG_IWLWIFI_RUN_TIME_CALIB*/
 
 #ifdef CONFIG_IWL4965_HT
        struct iwl_ht_info current_ht_config;
@@ -1107,7 +1077,7 @@ struct iwl_priv {
                u64 bytes;
        } tx_stats[3], rx_stats[3];
 
-       struct iwl4965_power_mgr power_data;
+       struct iwl_power_mgr power_data;
 
        struct iwl4965_notif_statistics statistics;
        unsigned long last_statistics_time;
@@ -1127,6 +1097,10 @@ struct iwl_priv {
        spinlock_t sta_lock;
        int num_stations;
        struct iwl4965_station_entry stations[IWL_STATION_COUNT];
+       struct iwl_wep_key wep_keys[WEP_KEYS_MAX];
+       u8 default_wep_key;
+       u8 key_mapping_key;
+       unsigned long ucode_key_table;
 
        /* Indication if ieee80211_ops->open has been called */
        u8 is_open;
@@ -1155,12 +1129,16 @@ struct iwl_priv {
        struct sk_buff *ibss_beacon;
 
        /* Last Rx'd beacon timestamp */
-       u32 timestamp0;
-       u32 timestamp1;
+       u64 timestamp;
        u16 beacon_int;
-       struct iwl4965_driver_hw_info hw_setting;
        struct ieee80211_vif *vif;
 
+       struct iwl_hw_params hw_params;
+       /* driver/uCode shared Tx Byte Counts and Rx status */
+       void *shared_virt;
+       /* Physical Pointer to Tx Byte Counts and Rx status */
+       dma_addr_t shared_phys;
+
        /* Current association information needed to configure the
         * hardware */
        u16 assoc_id;
@@ -1213,14 +1191,13 @@ struct iwl_priv {
 #endif /* CONFIG_IWLWIFI_DEBUG */
 
        struct work_struct txpower_work;
-#ifdef CONFIG_IWL4965_SENSITIVITY
+#ifdef CONFIG_IWL4965_RUN_TIME_CALIB
        struct work_struct sensitivity_work;
 #endif
-       struct work_struct statistics_work;
        struct timer_list statistics_periodic;
 }; /*iwl_priv */
 
-static inline int iwl4965_is_associated(struct iwl_priv *priv)
+static inline int iwl_is_associated(struct iwl_priv *priv)
 {
        return (priv->active_rxon.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0;
 }