iwlwifi: fix locking unbalance in 4965 rate scale
[safe/jmp/linux-2.6] / drivers / net / wireless / iwlwifi / iwl-4965.h
index 42ce27f..057fa15 100644 (file)
@@ -41,9 +41,17 @@ extern struct pci_device_id iwl4965_hw_card_ids[];
 
 #define DRV_NAME        "iwl4965"
 #include "iwl-4965-hw.h"
+#include "iwl-csr.h"
 #include "iwl-prph.h"
 #include "iwl-4965-debug.h"
 
+/* 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"
+
+
 /* Default noise level to report when noise measurement is not available.
  *   This may be because we're:
  *   1)  Not associated (4965, no beacon statistics being sent to driver)
@@ -60,6 +68,7 @@ extern struct pci_device_id iwl4965_hw_card_ids[];
 /* Module parameters accessible from iwl-*.c */
 extern int iwl4965_param_hwcrypto;
 extern int iwl4965_param_queues_num;
+extern int iwl4965_param_amsdu_size_8K;
 
 enum iwl4965_antenna {
        IWL_ANTENNA_DIVERSITY,
@@ -90,29 +99,6 @@ struct iwl4965_rx_mem_buffer {
        struct list_head list;
 };
 
-struct iwl4965_rt_rx_hdr {
-       struct ieee80211_radiotap_header rt_hdr;
-       __le64 rt_tsf;          /* TSF */
-       u8 rt_flags;            /* radiotap packet flags */
-       u8 rt_rate;             /* rate in 500kb/s */
-       __le16 rt_channelMHz;   /* channel in MHz */
-       __le16 rt_chbitmask;    /* channel bitfield */
-       s8 rt_dbmsignal;        /* signal in dBm, kluged to signed */
-       s8 rt_dbmnoise;
-       u8 rt_antenna;          /* antenna number */
-       u8 payload[0];          /* payload... */
-} __attribute__ ((packed));
-
-struct iwl4965_rt_tx_hdr {
-       struct ieee80211_radiotap_header rt_hdr;
-       u8 rt_rate;             /* rate in 500kb/s */
-       __le16 rt_channel;      /* channel in mHz */
-       __le16 rt_chbitmask;    /* channel bitfield */
-       s8 rt_dbmsignal;        /* signal in dBm, kluged to signed */
-       u8 rt_antenna;          /* antenna number */
-       u8 payload[0];          /* payload... */
-} __attribute__ ((packed));
-
 /*
  * Generic queue structure
  *
@@ -228,7 +214,7 @@ struct iwl4965_channel_info {
 
        u8 group_index;   /* 0-4, maps channel to group1/2/3/4/5 */
        u8 band_index;    /* 0-4, maps channel to band1/2/3/4/5 */
-       u8 phymode;       /* MODE_IEEE80211{A,B,G} */
+       enum ieee80211_band band;
 
        /* Radio/DSP gain settings for each "normal" data Tx rate.
         * These include, in addition to RF and DSP gain, a few fields for
@@ -447,6 +433,7 @@ struct iwl4965_rx_queue {
 #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
 
@@ -454,7 +441,6 @@ struct iwl4965_rx_queue {
 #define IWL_INVALID_VALUE    -1
 
 #ifdef CONFIG_IWL4965_HT
-#ifdef CONFIG_IWL4965_HT_AGG
 /**
  * struct iwl4965_ht_agg -- aggregation status while waiting for block-ack
  * @txq_id: Tx queue used for Tx attempt
@@ -474,19 +460,22 @@ struct iwl4965_ht_agg {
        u16 frame_count;
        u16 wait_for_ba;
        u16 start_idx;
-       u32 bitmap0;
-       u32 bitmap1;
+       u64 bitmap;
        u32 rate_n_flags;
+#define IWL_AGG_OFF 0
+#define IWL_AGG_ON 1
+#define IWL_EMPTYING_HW_QUEUE_ADDBA 2
+#define IWL_EMPTYING_HW_QUEUE_DELBA 3
+       u8 state;
 };
-#endif /* CONFIG_IWL4965_HT_AGG */
+
 #endif /* CONFIG_IWL4965_HT */
 
 struct iwl4965_tid_data {
        u16 seq_number;
+       u16 tfds_in_queue;
 #ifdef CONFIG_IWL4965_HT
-#ifdef CONFIG_IWL4965_HT_AGG
        struct iwl4965_ht_agg agg;
-#endif /* CONFIG_IWL4965_HT_AGG */
 #endif /* CONFIG_IWL4965_HT */
 };
 
@@ -506,31 +495,29 @@ union iwl4965_ht_rate_supp {
 
 #ifdef CONFIG_IWL4965_HT
 #define CFG_HT_RX_AMPDU_FACTOR_DEF  (0x3)
-#define HT_IE_MAX_AMSDU_SIZE_4K     (0)
 #define CFG_HT_MPDU_DENSITY_2USEC   (0x5)
 #define CFG_HT_MPDU_DENSITY_DEF CFG_HT_MPDU_DENSITY_2USEC
 
-struct sta_ht_info {
+struct iwl_ht_info {
+       /* self configuration data */
        u8 is_ht;
-       u16 rx_mimo_ps_mode;
+       u8 supported_chan_width;
        u16 tx_mimo_ps_mode;
-       u16 control_channel;
+       u8 is_green_field;
+       u8 sgf;                 /* HT_SHORT_GI_* short guard interval */
        u8 max_amsdu_size;
        u8 ampdu_factor;
        u8 mpdu_density;
-       u8 operating_mode;
-       u8 supported_chan_width;
+       u8 supp_mcs_set[16];
+       /* BSS related data */
+       u8 control_channel;
        u8 extension_chan_offset;
-       u8 is_green_field;
-       u8 sgf;                 /* HT_SHORT_GI_* short guard interval */
-       u8 supp_rates[16];
        u8 tx_chan_width;
-       u8 chan_width_cap;
+       u8 ht_protection;
+       u8 non_GF_STA_present;
 };
 #endif                         /*CONFIG_IWL4965_HT */
 
-#ifdef CONFIG_IWL4965_QOS
-
 union iwl4965_qos_capabity {
        struct {
                u8 edca_count:4;        /* bit 0-3 */
@@ -558,7 +545,6 @@ struct iwl4965_qos_info {
        union iwl4965_qos_capabity qos_cap;
        struct iwl4965_qosparam_cmd def_qos_parm;
 };
-#endif /*CONFIG_IWL4965_QOS */
 
 #define STA_PS_STATUS_WAKE             0
 #define STA_PS_STATUS_SLEEP            1
@@ -602,8 +588,8 @@ struct iwl4965_ibss_seq {
 /**
  * struct iwl4965_driver_hw_info
  * @max_txq_num: Max # Tx queues supported
- * @ac_queue_count: # Tx queues for EDCA Access Categories (AC)
  * @tx_cmd_len: Size of Tx command (but not including frame itself)
+ * @tx_ant_num: Number of TX antennas
  * @max_rxq_size: Max # Rx frames in Rx queue (must be power-of-2)
  * @rx_buffer_size:
  * @max_rxq_log: Log-base-2 of max_rxq_size
@@ -614,10 +600,11 @@ struct iwl4965_ibss_seq {
  */
 struct iwl4965_driver_hw_info {
        u16 max_txq_num;
-       u16 ac_queue_count;
        u16 tx_cmd_len;
+       u16 tx_ant_num;
        u16 max_rxq_size;
-       u32 rx_buffer_size;
+       u32 rx_buf_size;
+       u32 max_pkt_size;
        u16 max_rxq_log;
        u8  max_stations;
        u8  bcast_sta_id;
@@ -648,22 +635,12 @@ struct iwl4965_driver_hw_info {
 struct iwl4965_addsta_cmd;
 extern int iwl4965_send_add_station(struct iwl4965_priv *priv,
                                struct iwl4965_addsta_cmd *sta, u8 flags);
-extern u8 iwl4965_add_station_flags(struct iwl4965_priv *priv, const u8 *bssid,
-                         int is_ap, u8 flags);
+extern u8 iwl4965_add_station_flags(struct iwl4965_priv *priv, const u8 *addr,
+                         int is_ap, u8 flags, void *ht_data);
 extern int iwl4965_is_network_packet(struct iwl4965_priv *priv,
                                 struct ieee80211_hdr *header);
 extern int iwl4965_power_init_handle(struct iwl4965_priv *priv);
 extern int iwl4965_eeprom_init(struct iwl4965_priv *priv);
-#ifdef CONFIG_IWL4965_DEBUG
-extern void iwl4965_report_frame(struct iwl4965_priv *priv,
-                            struct iwl4965_rx_packet *pkt,
-                            struct ieee80211_hdr *header, int group100);
-#else
-static inline void iwl4965_report_frame(struct iwl4965_priv *priv,
-                                   struct iwl4965_rx_packet *pkt,
-                                   struct ieee80211_hdr *header,
-                                   int group100) {}
-#endif
 extern void iwl4965_handle_data_packet_monitor(struct iwl4965_priv *priv,
                                           struct iwl4965_rx_mem_buffer *rxb,
                                           void *data, short len,
@@ -763,54 +740,51 @@ extern u8 iwl4965_hw_find_station(struct iwl4965_priv *priv, const u8 *bssid);
 
 extern int iwl4965_hw_channel_switch(struct iwl4965_priv *priv, u16 channel);
 extern int iwl4965_tx_queue_reclaim(struct iwl4965_priv *priv, int txq_id, int index);
-
+extern int iwl4965_queue_space(const struct iwl4965_queue *q);
 struct iwl4965_priv;
-struct sta_ht_info;
 
 /*
  * Forward declare iwl-4965.c functions for iwl-base.c
  */
 extern int iwl4965_eeprom_acquire_semaphore(struct iwl4965_priv *priv);
-extern void iwl4965_eeprom_release_semaphore(struct iwl4965_priv *priv);
 
 extern int iwl4965_tx_queue_update_wr_ptr(struct iwl4965_priv *priv,
                                          struct iwl4965_tx_queue *txq,
                                          u16 byte_cnt);
 extern void iwl4965_add_station(struct iwl4965_priv *priv, const u8 *addr,
                                int is_ap);
-extern void iwl4965_set_rxon_ht(struct iwl4965_priv *priv,
-                               struct sta_ht_info *ht_info);
-
 extern void iwl4965_set_rxon_chain(struct iwl4965_priv *priv);
-extern int iwl4965_tx_cmd(struct iwl4965_priv *priv, struct iwl4965_cmd *out_cmd,
-                         u8 sta_id, dma_addr_t txcmd_phys,
-                         struct ieee80211_hdr *hdr, u8 hdr_len,
-                         struct ieee80211_tx_control *ctrl, void *sta_in);
 extern int iwl4965_alive_notify(struct iwl4965_priv *priv);
 extern void iwl4965_update_rate_scaling(struct iwl4965_priv *priv, u8 mode);
-extern void iwl4965_set_ht_add_station(struct iwl4965_priv *priv, u8 index);
-
 extern void iwl4965_chain_noise_reset(struct iwl4965_priv *priv);
 extern void iwl4965_init_sensitivity(struct iwl4965_priv *priv, u8 flags,
                                     u8 force);
-extern int iwl4965_set_fat_chan_info(struct iwl4965_priv *priv, int phymode,
+extern int iwl4965_set_fat_chan_info(struct iwl4965_priv *priv,
+                               enum ieee80211_band band,
                                u16 channel,
                                const struct iwl4965_eeprom_channel *eeprom_ch,
                                u8 fat_extension_channel);
 extern void iwl4965_rf_kill_ct_config(struct iwl4965_priv *priv);
+extern void iwl4965_hwrate_to_tx_control(struct iwl4965_priv *priv,
+                                        u32 rate_n_flags,
+                                        struct ieee80211_tx_control *control);
 
 #ifdef CONFIG_IWL4965_HT
-#ifdef CONFIG_IWL4965_HT_AGG
-extern int iwl4965_mac_ht_tx_agg_start(struct ieee80211_hw *hw, u8 *da,
-                                  u16 tid, u16 *start_seq_num);
-extern int iwl4965_mac_ht_rx_agg_start(struct ieee80211_hw *hw, u8 *da,
-                                  u16 tid, u16 start_seq_num);
-extern int iwl4965_mac_ht_rx_agg_stop(struct ieee80211_hw *hw, u8 *da,
-                                 u16 tid, int generator);
-extern int iwl4965_mac_ht_tx_agg_stop(struct ieee80211_hw *hw, u8 *da,
-                                 u16 tid, int generator);
-extern void iwl4965_turn_off_agg(struct iwl4965_priv *priv, u8 tid);
-#endif /* CONFIG_IWL4965_HT_AGG */
+void iwl4965_init_ht_hw_capab(struct ieee80211_ht_info *ht_info,
+                             enum ieee80211_band band);
+void iwl4965_set_rxon_ht(struct iwl4965_priv *priv,
+                        struct iwl_ht_info *ht_info);
+void iwl4965_set_ht_add_station(struct iwl4965_priv *priv, u8 index,
+                               struct ieee80211_ht_info *sta_ht_inf);
+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 iwl4965_priv *priv, int sta_id,
+                                       u8 tid, int txq_id);
+#else
+static inline void iwl4965_init_ht_hw_capab(struct ieee80211_ht_info *ht_info,
+                                           enum ieee80211_band band) {}
+
 #endif /*CONFIG_IWL4965_HT */
 /* Structures, enum, and defines specific to the 4965 */
 
@@ -822,18 +796,6 @@ struct iwl4965_kw {
        size_t size;
 };
 
-#define TID_QUEUE_CELL_SPACING 50      /*mS */
-#define TID_QUEUE_MAX_SIZE     20
-#define TID_ROUND_VALUE        5       /* mS */
-#define TID_MAX_LOAD_COUNT     8
-
-#define TID_MAX_TIME_DIFF ((TID_QUEUE_MAX_SIZE - 1) * TID_QUEUE_CELL_SPACING)
-#define TIME_WRAP_AROUND(x, y) (((y) > (x)) ? (y) - (x) : (0-(x)) + (y))
-
-#define TID_ALL_ENABLED                0x7f
-#define TID_ALL_SPECIFIED       0xff
-#define TID_AGG_TPT_THREHOLD    0x0
-
 #define IWL_CHANNEL_WIDTH_20MHZ   0
 #define IWL_CHANNEL_WIDTH_40MHZ   1
 
@@ -847,48 +809,17 @@ struct iwl4965_kw {
 #define IWL_OPERATION_MODE_MIXED    2
 #define IWL_OPERATION_MODE_20MHZ    3
 
-#define IWL_EXT_CHANNEL_OFFSET_AUTO   0
-#define IWL_EXT_CHANNEL_OFFSET_ABOVE  1
-#define IWL_EXT_CHANNEL_OFFSET_       2
-#define IWL_EXT_CHANNEL_OFFSET_BELOW  3
-#define IWL_EXT_CHANNEL_OFFSET_MAX    4
+#define IWL_EXT_CHANNEL_OFFSET_NONE      0
+#define IWL_EXT_CHANNEL_OFFSET_ABOVE     1
+#define IWL_EXT_CHANNEL_OFFSET_RESERVE1  2
+#define IWL_EXT_CHANNEL_OFFSET_BELOW     3
 
 #define NRG_NUM_PREV_STAT_L     20
 #define NUM_RX_CHAINS           (3)
 
 #define TX_POWER_IWL_ILLEGAL_VOLTAGE -10000
 
-struct iwl4965_traffic_load {
-       unsigned long time_stamp;
-       u32 packet_count[TID_QUEUE_MAX_SIZE];
-       u8 queue_count;
-       u8 head;
-       u32 total;
-};
-
-#ifdef CONFIG_IWL4965_HT_AGG
-/**
- * struct iwl4965_agg_control
- * @requested_ba: bit map of tids requesting aggregation/block-ack
- * @granted_ba: bit map of tids granted aggregation/block-ack
- */
-struct iwl4965_agg_control {
-       unsigned long next_retry;
-       u32 wait_for_agg_status;
-       u32 tid_retry;
-       u32 requested_ba;
-       u32 granted_ba;
-       u8 auto_agg;
-       u32 tid_traffic_load_threshold;
-       u32 ba_timeout;
-       struct iwl4965_traffic_load traffic_load[TID_MAX_LOAD_COUNT];
-};
-#endif                         /*CONFIG_IWL4965_HT_AGG */
-
 struct iwl4965_lq_mngr {
-#ifdef CONFIG_IWL4965_HT_AGG
-       struct iwl4965_agg_control agg_ctrl;
-#endif
        spinlock_t lock;
        s32 max_window_size;
        s32 *expected_tpt;
@@ -901,7 +832,6 @@ struct iwl4965_lq_mngr {
        u8 lq_ready;
 };
 
-
 /* Sensitivity and chain noise calibration */
 #define INTERFERENCE_DATA_AVAILABLE    __constant_cpu_to_le32(1)
 #define INITIALIZATION_VALUE           0xFFFF
@@ -1044,18 +974,20 @@ struct iwl4965_priv {
        struct ieee80211_hw *hw;
        struct ieee80211_channel *ieee_channels;
        struct ieee80211_rate *ieee_rates;
+       struct iwl_cfg *cfg;
 
        /* temporary frame storage list */
        struct list_head free_frames;
        int frames_count;
 
-       u8 phymode;
+       enum ieee80211_band band;
        int alloc_rxb_skb;
+       bool add_radiotap;
 
        void (*rx_handlers[REPLY_MAX])(struct iwl4965_priv *priv,
                                       struct iwl4965_rx_mem_buffer *rxb);
 
-       const struct ieee80211_hw_mode *modes;
+       struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS];
 
 #ifdef CONFIG_IWL4965_SPECTRUM_MEASUREMENT
        /* spectrum measurement report caching */
@@ -1141,12 +1073,6 @@ struct iwl4965_priv {
        u8 call_post_assoc_from_beacon;
        u8 assoc_station_added;
        u8 use_ant_b_for_management_frame;      /* Tx antenna selection */
-
-       /* High Throughput (HT) variables */
-       u8 is_dup;
-       u8 is_ht_enabled;
-       u8 channel_width;       /* 0=20MHZ, 1=40MHZ supported */
-       u8 current_channel_width;
        u8 valid_antenna;       /* Bit mask of antennas actually connected */
 #ifdef CONFIG_IWL4965_SENSITIVITY
        struct iwl4965_sensitivity_data sensitivity_data;
@@ -1156,9 +1082,8 @@ struct iwl4965_priv {
 #endif /*CONFIG_IWL4965_SENSITIVITY*/
 
 #ifdef CONFIG_IWL4965_HT
-       struct sta_ht_info current_assoc_ht;
+       struct iwl_ht_info current_ht_config;
 #endif
-       u8 active_rate_ht[2];
        u8 last_phy_res[100];
 
        /* Rate scaling data */
@@ -1180,7 +1105,6 @@ struct iwl4965_priv {
        u32 scd_base_addr;      /* scheduler sram base address */
 
        unsigned long status;
-       u32 config;
 
        int last_rx_rssi;       /* From Rx packet statisitics */
        int last_rx_noise;      /* From beacon statistics */
@@ -1210,7 +1134,6 @@ struct iwl4965_priv {
        int is_open;
 
        u8 mac80211_registered;
-       int is_abg;
 
        u32 notif_missed_beacons;
 
@@ -1238,7 +1161,7 @@ struct iwl4965_priv {
        u32 timestamp1;
        u16 beacon_int;
        struct iwl4965_driver_hw_info hw_setting;
-       int interface_id;
+       struct ieee80211_vif *vif;
 
        /* Current association information needed to configure the
         * hardware */
@@ -1246,9 +1169,7 @@ struct iwl4965_priv {
        u16 assoc_capability;
        u8 ps_mode;
 
-#ifdef CONFIG_IWL4965_QOS
        struct iwl4965_qos_info qos_data;
-#endif /*CONFIG_IWL4965_QOS */
 
        struct workqueue_struct *workqueue;
 
@@ -1295,11 +1216,7 @@ struct iwl4965_priv {
 #endif
        struct work_struct statistics_work;
        struct timer_list statistics_periodic;
-
-#ifdef CONFIG_IWL4965_HT_AGG
-       struct work_struct agg_work;
-#endif
-};                             /*iwl4965_priv */
+}; /*iwl4965_priv */
 
 static inline int iwl4965_is_associated(struct iwl4965_priv *priv)
 {
@@ -1325,13 +1242,12 @@ static inline int is_channel_radar(const struct iwl4965_channel_info *ch_info)
 
 static inline u8 is_channel_a_band(const struct iwl4965_channel_info *ch_info)
 {
-       return ch_info->phymode == MODE_IEEE80211A;
+       return ch_info->band == IEEE80211_BAND_5GHZ;
 }
 
 static inline u8 is_channel_bg_band(const struct iwl4965_channel_info *ch_info)
 {
-       return ((ch_info->phymode == MODE_IEEE80211B) ||
-               (ch_info->phymode == MODE_IEEE80211G));
+       return ch_info->band == IEEE80211_BAND_2GHZ;
 }
 
 static inline int is_channel_passive(const struct iwl4965_channel_info *ch)
@@ -1345,7 +1261,7 @@ static inline int is_channel_ibss(const struct iwl4965_channel_info *ch)
 }
 
 extern const struct iwl4965_channel_info *iwl4965_get_channel_info(
-       const struct iwl4965_priv *priv, int phymode, u16 channel);
+       const struct iwl4965_priv *priv, enum ieee80211_band band, u16 channel);
 
 /* Requires full declaration of iwl4965_priv before including */
 #include "iwl-4965-io.h"