iwlwifi: make WEP key restoring explicit
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / iwlwifi / iwl-dev.h
index 3822cf53e36850003b1c636a20bbde21d2846e43..95c2bc3c79ed8e9b32f4868ec410538c6401534d 100644 (file)
@@ -1,6 +1,6 @@
 /******************************************************************************
  *
- * Copyright(c) 2003 - 2009 Intel Corporation. All rights reserved.
+ * Copyright(c) 2003 - 2010 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
@@ -43,6 +43,7 @@
 #include "iwl-debug.h"
 #include "iwl-4965-hw.h"
 #include "iwl-3945-hw.h"
+#include "iwl-agn-hw.h"
 #include "iwl-led.h"
 #include "iwl-power.h"
 #include "iwl-agn-rs.h"
@@ -57,6 +58,7 @@ extern struct iwl_cfg iwl5100_abg_cfg;
 extern struct iwl_cfg iwl5150_agn_cfg;
 extern struct iwl_cfg iwl5150_abg_cfg;
 extern struct iwl_cfg iwl6000i_2agn_cfg;
+extern struct iwl_cfg iwl6000i_g2_2agn_cfg;
 extern struct iwl_cfg iwl6000i_2abg_cfg;
 extern struct iwl_cfg iwl6000i_2bg_cfg;
 extern struct iwl_cfg iwl6000_3agn_cfg;
@@ -67,45 +69,6 @@ extern struct iwl_cfg iwl1000_bg_cfg;
 
 struct iwl_tx_queue;
 
-/* shared structures from iwl-5000.c */
-extern struct iwl_mod_params iwl50_mod_params;
-extern struct iwl_ucode_ops iwl5000_ucode;
-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);
-extern void iwl5000_nic_config(struct iwl_priv *priv);
-extern u16 iwl5000_eeprom_calib_version(struct iwl_priv *priv);
-extern const u8 *iwl5000_eeprom_query_addr(const struct iwl_priv *priv,
-                                   size_t offset);
-extern void iwl5000_txq_update_byte_cnt_tbl(struct iwl_priv *priv,
-                                           struct iwl_tx_queue *txq,
-                                           u16 byte_cnt);
-extern void iwl5000_txq_inval_byte_cnt_tbl(struct iwl_priv *priv,
-                                   struct iwl_tx_queue *txq);
-extern int iwl5000_load_ucode(struct iwl_priv *priv);
-extern void iwl5000_init_alive_start(struct iwl_priv *priv);
-extern int iwl5000_alive_notify(struct iwl_priv *priv);
-extern int iwl5000_hw_set_hw_params(struct iwl_priv *priv);
-extern int iwl5000_txq_agg_enable(struct iwl_priv *priv, int txq_id,
-                          int tx_fifo, int sta_id, int tid, u16 ssn_idx);
-extern int iwl5000_txq_agg_disable(struct iwl_priv *priv, u16 txq_id,
-                           u16 ssn_idx, u8 tx_fifo);
-extern void iwl5000_txq_set_sched(struct iwl_priv *priv, u32 mask);
-extern void iwl5000_setup_deferred_work(struct iwl_priv *priv);
-extern void iwl5000_rx_handler_setup(struct iwl_priv *priv);
-extern int iwl5000_hw_valid_rtc_data_addr(u32 addr);
-extern int iwl5000_send_tx_power(struct iwl_priv *priv);
-extern void iwl5000_temperature(struct iwl_priv *priv);
-
 /* CT-KILL constants */
 #define CT_KILL_THRESHOLD_LEGACY   110 /* in Celsius */
 #define CT_KILL_THRESHOLD         114 /* in Celsius */
@@ -183,6 +146,10 @@ struct iwl_queue {
        int n_bd;              /* number of BDs in this queue */
        int write_ptr;       /* 1-st empty entry (index) host_w*/
        int read_ptr;         /* last used entry (index) host_r*/
+       /* use for monitoring and recovering the stuck queue */
+       int last_read_ptr;      /* storing the last read_ptr */
+       /* number of time read_ptr and last_read_ptr are the same */
+       u8 repeat_same_read_ptr;
        dma_addr_t dma_addr;   /* physical addr for BD's */
        int n_window;          /* safe queue window */
        u32 id;
@@ -304,13 +271,11 @@ struct iwl_channel_info {
        struct iwl3945_scan_power_info scan_pwr_info[IWL_NUM_SCAN_RATES];
 };
 
-#define IWL_TX_FIFO_AC0        0
-#define IWL_TX_FIFO_AC1        1
-#define IWL_TX_FIFO_AC2        2
-#define IWL_TX_FIFO_AC3        3
-#define IWL_TX_FIFO_HCCA_1     5
-#define IWL_TX_FIFO_HCCA_2     6
-#define IWL_TX_FIFO_NONE       7
+#define IWL_TX_FIFO_BK         0
+#define IWL_TX_FIFO_BE         1
+#define IWL_TX_FIFO_VI         2
+#define IWL_TX_FIFO_VO         3
+#define IWL_TX_FIFO_UNUSED     -1
 
 /* Minimum number of queues. MAX_NUM is defined in hw specific files.
  * Set the minimum to accommodate the 4 standard TX queues, 1 command
@@ -361,13 +326,6 @@ enum {
 
 #define DEF_CMD_PAYLOAD_SIZE 320
 
-/*
- * IWL_LINK_HDR_MAX should include ieee80211_hdr, radiotap header,
- * SNAP header and alignment. It should also be big enough for 802.11
- * control frames.
- */
-#define IWL_LINK_HDR_MAX 64
-
 /**
  * struct iwl_device_cmd
  *
@@ -512,44 +470,31 @@ struct iwl_ht_config {
        bool is_ht;
        bool is_40mhz;
        bool single_chain_sufficient;
+       enum ieee80211_smps_mode smps; /* current smps mode */
        /* BSS related data */
        u8 extension_chan_offset;
        u8 ht_protection;
        u8 non_GF_STA_present;
 };
 
-union iwl_qos_capabity {
-       struct {
-               u8 edca_count:4;        /* bit 0-3 */
-               u8 q_ack:1;             /* bit 4 */
-               u8 queue_request:1;     /* bit 5 */
-               u8 txop_request:1;      /* bit 6 */
-               u8 reserved:1;          /* bit 7 */
-       } q_AP;
-       struct {
-               u8 acvo_APSD:1;         /* bit 0 */
-               u8 acvi_APSD:1;         /* bit 1 */
-               u8 ac_bk_APSD:1;        /* bit 2 */
-               u8 ac_be_APSD:1;        /* bit 3 */
-               u8 q_ack:1;             /* bit 4 */
-               u8 max_len:2;           /* bit 5-6 */
-               u8 more_data_ack:1;     /* bit 7 */
-       } q_STA;
-       u8 val;
-};
-
 /* QoS structures */
 struct iwl_qos_info {
        int qos_active;
-       union iwl_qos_capabity qos_cap;
        struct iwl_qosparam_cmd def_qos_parm;
 };
 
+/*
+ * Structure should be accessed with sta_lock held. When station addition
+ * is in progress (IWL_STA_UCODE_INPROGRESS) it is possible to access only
+ * the commands (iwl_addsta_cmd and iwl_link_quality_cmd) without sta_lock
+ * held.
+ */
 struct iwl_station_entry {
        struct iwl_addsta_cmd sta;
        struct iwl_tid_data tid[MAX_TID_COUNT];
        u8 used;
        struct iwl_hw_key keyinfo;
+       struct iwl_link_quality_cmd *lq;
 };
 
 /*
@@ -984,6 +929,79 @@ struct iwl_switch_rxon {
        __le16 channel;
 };
 
+/*
+ * schedule the timer to wake up every UCODE_TRACE_PERIOD milliseconds
+ * to perform continuous uCode event logging operation if enabled
+ */
+#define UCODE_TRACE_PERIOD (100)
+
+/*
+ * iwl_event_log: current uCode event log position
+ *
+ * @ucode_trace: enable/disable ucode continuous trace timer
+ * @num_wraps: how many times the event buffer wraps
+ * @next_entry:  the entry just before the next one that uCode would fill
+ * @non_wraps_count: counter for no wrap detected when dump ucode events
+ * @wraps_once_count: counter for wrap once detected when dump ucode events
+ * @wraps_more_count: counter for wrap more than once detected
+ *                   when dump ucode events
+ */
+struct iwl_event_log {
+       bool ucode_trace;
+       u32 num_wraps;
+       u32 next_entry;
+       int non_wraps_count;
+       int wraps_once_count;
+       int wraps_more_count;
+};
+
+/*
+ * host interrupt timeout value
+ * used with setting interrupt coalescing timer
+ * the CSR_INT_COALESCING is an 8 bit register in 32-usec unit
+ *
+ * default interrupt coalescing timer is 64 x 32 = 2048 usecs
+ * default interrupt coalescing calibration timer is 16 x 32 = 512 usecs
+ */
+#define IWL_HOST_INT_TIMEOUT_MAX       (0xFF)
+#define IWL_HOST_INT_TIMEOUT_DEF       (0x40)
+#define IWL_HOST_INT_TIMEOUT_MIN       (0x0)
+#define IWL_HOST_INT_CALIB_TIMEOUT_MAX (0xFF)
+#define IWL_HOST_INT_CALIB_TIMEOUT_DEF (0x10)
+#define IWL_HOST_INT_CALIB_TIMEOUT_MIN (0x0)
+
+/*
+ * This is the threshold value of plcp error rate per 100mSecs.  It is
+ * used to set and check for the validity of plcp_delta.
+ */
+#define IWL_MAX_PLCP_ERR_THRESHOLD_MIN (0)
+#define IWL_MAX_PLCP_ERR_THRESHOLD_DEF (50)
+#define IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF    (100)
+#define IWL_MAX_PLCP_ERR_EXT_LONG_THRESHOLD_DEF        (200)
+#define IWL_MAX_PLCP_ERR_THRESHOLD_MAX (255)
+
+#define IWL_DELAY_NEXT_FORCE_RF_RESET  (HZ*3)
+#define IWL_DELAY_NEXT_FORCE_FW_RELOAD (HZ*5)
+
+/* timer constants use to monitor and recover stuck tx queues in mSecs */
+#define IWL_MONITORING_PERIOD  (1000)
+#define IWL_ONE_HUNDRED_MSECS   (100)
+#define IWL_SIXTY_SECS          (60000)
+
+enum iwl_reset {
+       IWL_RF_RESET = 0,
+       IWL_FW_RESET,
+       IWL_MAX_FORCE_RESET,
+};
+
+struct iwl_force_reset {
+       int reset_request_count;
+       int reset_success_count;
+       int reset_reject_count;
+       unsigned long reset_duration;
+       unsigned long last_force_reset_jiffies;
+};
+
 struct iwl_priv {
 
        /* ieee device used by generic ieee processing code */
@@ -1004,23 +1022,25 @@ struct iwl_priv {
 
        struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS];
 
-#if defined(CONFIG_IWLWIFI_SPECTRUM_MEASUREMENT) || defined(CONFIG_IWL3945_SPECTRUM_MEASUREMENT)
        /* spectrum measurement report caching */
        struct iwl_spectrum_notification measure_report;
        u8 measurement_status;
-#endif
+
        /* ucode beacon time */
        u32 ucode_beacon_time;
+       int missed_beacon_threshold;
+
+       /* storing the jiffies when the plcp error rate is received */
+       unsigned long plcp_jiffies;
+
+       /* force reset */
+       struct iwl_force_reset force_reset[IWL_MAX_FORCE_RESET];
 
        /* we allocate array of iwl4965_channel_info for NIC's valid channels.
         *    Access via channel # using indirect index array */
        struct iwl_channel_info *channel_info;  /* channel info array */
        u8 channel_count;       /* # of channels */
 
-       /* each calibration channel group in the EEPROM has a derived
-        * clip setting for each rate. 3945 only.*/
-       const struct iwl3945_clip_group clip39_groups[5];
-
        /* thermal calibration */
        s32 temperature;        /* degrees Kelvin */
        s32 last_temperature;
@@ -1029,7 +1049,6 @@ struct iwl_priv {
        struct iwl_calib_result calib_results[IWL_CALIB_MAX];
 
        /* Scan related variables */
-       unsigned long last_scan_jiffies;
        unsigned long next_scan_jiffies;
        unsigned long scan_start;
        unsigned long scan_pass_start;
@@ -1037,6 +1056,7 @@ struct iwl_priv {
        void *scan;
        int scan_bands;
        struct cfg80211_scan_request *scan_request;
+       bool is_internal_short_scan;
        u8 scan_tx_ant[IEEE80211_NUM_BANDS];
        u8 mgmt_tx_ant;
 
@@ -1045,6 +1065,7 @@ struct iwl_priv {
        spinlock_t hcmd_lock;   /* protect hcmd */
        spinlock_t reg_lock;    /* protect hw register access */
        struct mutex mutex;
+       struct mutex sync_cmd_mutex; /* enable serialization of sync commands */
 
        /* basic pci-network driver stuff */
        struct pci_dev *pci_dev;
@@ -1056,6 +1077,7 @@ struct iwl_priv {
        u8   rev_id;
 
        /* uCode images, save to reload in case of failure */
+       int fw_index;                   /* firmware we're trying to load */
        u32 ucode_ver;                  /* version of ucode, copy of
                                           iwl_ucode.ver */
        struct fw_desc ucode_code;      /* runtime inst */
@@ -1066,6 +1088,7 @@ struct iwl_priv {
        struct fw_desc ucode_boot;      /* bootstrap inst */
        enum ucode_type ucode_type;
        u8 ucode_write_complete;        /* the image write is complete */
+       char firmware_name[25];
 
 
        struct iwl_rxon_time_cmd rxon_timing;
@@ -1090,9 +1113,7 @@ struct iwl_priv {
        u64 led_tpt;
 
        u16 active_rate;
-       u16 active_rate_basic;
 
-       u8 assoc_station_added;
        u8 start_calib;
        struct iwl_sensitivity_data sensitivity_data;
        struct iwl_chain_noise_data chain_noise_data;
@@ -1119,9 +1140,6 @@ struct iwl_priv {
 
        unsigned long status;
 
-       int last_rx_rssi;       /* From Rx packet statistics */
-       int last_rx_noise;      /* From beacon statistics */
-
        /* counts mgmt, ctl, and data packets */
        struct traffic_stats tx_stats;
        struct traffic_stats rx_stats;
@@ -1135,11 +1153,11 @@ struct iwl_priv {
        struct iwl_notif_statistics statistics;
 #ifdef CONFIG_IWLWIFI_DEBUG
        struct iwl_notif_statistics accum_statistics;
+       struct iwl_notif_statistics delta_statistics;
+       struct iwl_notif_statistics max_delta;
 #endif
 
        /* context information */
-       u16 rates_mask;
-
        u8 bssid[ETH_ALEN];
        u16 rts_threshold;
        u8 mac_addr[ETH_ALEN];
@@ -1148,8 +1166,7 @@ struct iwl_priv {
        spinlock_t sta_lock;
        int num_stations;
        struct iwl_station_entry stations[IWL_STATION_COUNT];
-       struct iwl_wep_key wep_keys[WEP_KEYS_MAX];
-       u8 default_wep_key;
+       struct iwl_wep_key wep_keys[WEP_KEYS_MAX]; /* protected by mutex */
        u8 key_mapping_key;
        unsigned long ucode_key_table;
 
@@ -1164,10 +1181,6 @@ struct iwl_priv {
 
        u8 mac80211_registered;
 
-       /* Rx'd packet timing information */
-       u32 last_beacon_time;
-       u64 last_tsf;
-
        /* eeprom -- this is in the card's little endian byte order */
        u8 *eeprom;
        int    nvm_device_type;
@@ -1182,20 +1195,53 @@ struct iwl_priv {
        u16 beacon_int;
        struct ieee80211_vif *vif;
 
-       /*Added for 3945 */
-       void *shared_virt;
-       dma_addr_t shared_phys;
-       /*End*/
-       struct iwl_hw_params hw_params;
+       union {
+#if defined(CONFIG_IWL3945) || defined(CONFIG_IWL3945_MODULE)
+               struct {
+                       void *shared_virt;
+                       dma_addr_t shared_phys;
 
-       /* INT ICT Table */
-       __le32 *ict_tbl;
-       dma_addr_t ict_tbl_dma;
-       dma_addr_t aligned_ict_tbl_dma;
-       int ict_index;
-       void *ict_tbl_vir;
-       u32 inta;
-       bool use_ict;
+                       struct delayed_work thermal_periodic;
+                       struct delayed_work rfkill_poll;
+
+                       struct iwl3945_notif_statistics statistics;
+
+                       u32 sta_supp_rates;
+                       int last_rx_rssi;       /* From Rx packet statistics */
+
+                       /* Rx'd packet timing information */
+                       u32 last_beacon_time;
+                       u64 last_tsf;
+
+                       /*
+                        * each calibration channel group in the
+                        * EEPROM has a derived clip setting for
+                        * each rate.
+                        */
+                       const struct iwl3945_clip_group clip_groups[5];
+
+               } _3945;
+#endif
+#if defined(CONFIG_IWLAGN) || defined(CONFIG_IWLAGN_MODULE)
+               struct {
+                       /* INT ICT Table */
+                       __le32 *ict_tbl;
+                       void *ict_tbl_vir;
+                       dma_addr_t ict_tbl_dma;
+                       dma_addr_t aligned_ict_tbl_dma;
+                       int ict_index;
+                       u32 inta;
+                       bool use_ict;
+                       /*
+                        * reporting the number of tids has AGG on. 0 means
+                        * no AGGREGATION
+                        */
+                       u8 agg_tids_count;
+               } _agn;
+#endif
+       };
+
+       struct iwl_hw_params hw_params;
 
        u32 inta_mask;
        /* Current association information needed to configure the
@@ -1207,15 +1253,10 @@ struct iwl_priv {
 
        struct workqueue_struct *workqueue;
 
-       struct work_struct up;
        struct work_struct restart;
-       struct work_struct calibrated_work;
        struct work_struct scan_completed;
        struct work_struct rx_replenish;
        struct work_struct abort_scan;
-       struct work_struct update_link_led;
-       struct work_struct auth_work;
-       struct work_struct report_work;
        struct work_struct request_scan;
        struct work_struct beacon_update;
        struct work_struct tt_work;
@@ -1228,10 +1269,6 @@ struct iwl_priv {
        struct delayed_work alive_start;
        struct delayed_work scan_check;
 
-       /*For 3945 only*/
-       struct delayed_work thermal_periodic;
-       struct delayed_work rfkill_poll;
-
        /* TX Power */
        s8 tx_power_user_lmt;
        s8 tx_power_device_lmt;
@@ -1251,7 +1288,8 @@ struct iwl_priv {
        u16 rx_traffic_idx;
        u8 *tx_traffic;
        u8 *rx_traffic;
-       struct iwl_debugfs *dbgfs;
+       struct dentry *debugfs_dir;
+       u32 dbgfs_sram_offset, dbgfs_sram_len;
 #endif /* CONFIG_IWLWIFI_DEBUGFS */
 #endif /* CONFIG_IWLWIFI_DEBUG */
 
@@ -1261,13 +1299,11 @@ struct iwl_priv {
        u32 disable_tx_power_cal;
        struct work_struct run_time_calib_work;
        struct timer_list statistics_periodic;
+       struct timer_list ucode_trace;
+       struct timer_list monitor_recover;
        bool hw_ready;
-       /*For 3945*/
-#define IWL_DEFAULT_TX_POWER 0x0F
-
-       struct iwl3945_notif_statistics statistics_39;
 
-       u32 sta_supp_rates;
+       struct iwl_event_log event_log;
 }; /*iwl_priv */
 
 static inline void iwl_txq_ctx_activate(struct iwl_priv *priv, int txq_id)