]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/net/wireless/iwlwifi/iwl-4965.c
iwlwifi: use type uint for module param debug
[karo-tx-linux.git] / drivers / net / wireless / iwlwifi / iwl-4965.c
index 23fed32989624a586216405303d118f85df7bc83..3a78d860631d9fc579f13aa8218b5163b5ef7bcc 100644 (file)
@@ -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
  *
  *****************************************************************************/
 static int iwl4965_send_tx_power(struct iwl_priv *priv);
 static int iwl4965_hw_get_temperature(const struct iwl_priv *priv);
 
-/* 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 "-2"
+/* Highest firmware API version supported */
+#define IWL4965_UCODE_API_MAX 2
+
+/* Lowest firmware API version supported */
+#define IWL4965_UCODE_API_MIN 2
+
+#define IWL4965_FW_PRE "iwlwifi-4965-"
+#define _IWL4965_MODULE_FIRMWARE(api) IWL4965_FW_PRE #api ".ucode"
+#define IWL4965_MODULE_FIRMWARE(api) _IWL4965_MODULE_FIRMWARE(api)
 
 
 /* module parameters */
 static struct iwl_mod_params iwl4965_mod_params = {
        .num_of_queues = IWL49_NUM_QUEUES,
        .num_of_ampdu_queues = IWL49_NUM_AMPDU_QUEUES,
-       .enable_qos = 1,
        .amsdu_size_8K = 1,
        .restart_fw = 1,
        /* the rest are 0 by default */
@@ -246,7 +249,7 @@ static int iwl4965_set_ucode_ptrs(struct iwl_priv *priv)
        iwl_write_prph(priv, BSM_DRAM_DATA_BYTECOUNT_REG,
                                 priv->ucode_data.len);
 
-       /* Inst bytecount must be last to set up, bit 31 signals uCode
+       /* Inst byte count must be last to set up, bit 31 signals uCode
         *   that all new ptr/size info is in place */
        iwl_write_prph(priv, BSM_DRAM_INST_BYTECOUNT_REG,
                                 priv->ucode_code.len | BSM_DRAM_INST_LOAD);
@@ -318,31 +321,13 @@ static int is_fat_channel(__le32 rxon_flags)
 /*
  * EEPROM handlers
  */
-
-static int iwl4965_eeprom_check_version(struct iwl_priv *priv)
+static u16 iwl4965_eeprom_calib_version(struct iwl_priv *priv)
 {
-       u16 eeprom_ver;
-       u16 calib_ver;
-
-       eeprom_ver = iwl_eeprom_query16(priv, EEPROM_VERSION);
-
-       calib_ver = iwl_eeprom_query16(priv, EEPROM_4965_CALIB_VERSION_OFFSET);
-
-       if (eeprom_ver < EEPROM_4965_EEPROM_VERSION ||
-           calib_ver < EEPROM_4965_TX_POWER_VERSION)
-               goto err;
-
-       return 0;
-err:
-       IWL_ERROR("Unsuported EEPROM VER=0x%x < 0x%x CALIB=0x%x < 0x%x\n",
-                 eeprom_ver, EEPROM_4965_EEPROM_VERSION,
-                 calib_ver, EEPROM_4965_TX_POWER_VERSION);
-       return -EINVAL;
-
+       return iwl_eeprom_query16(priv, EEPROM_4965_CALIB_VERSION_OFFSET);
 }
 
 /*
- * Activate/Deactivat Tx DMA/FIFO channels according tx fifos mask
+ * Activate/Deactivate Tx DMA/FIFO channels according tx fifos mask
  * must be called under priv->lock and mac access
  */
 static void iwl4965_txq_set_sched(struct iwl_priv *priv, u32 mask)
@@ -366,9 +351,8 @@ static int iwl4965_apm_init(struct iwl_priv *priv)
        iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
 
        /* wait for clock stabilization */
-       ret = iwl_poll_bit(priv, CSR_GP_CNTRL,
-                          CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY,
-                          CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
+       ret = iwl_poll_direct_bit(priv, CSR_GP_CNTRL,
+                       CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
        if (ret < 0) {
                IWL_DEBUG_INFO("Failed to init the card\n");
                goto out;
@@ -399,7 +383,7 @@ static void iwl4965_nic_config(struct iwl_priv *priv)
        unsigned long flags;
        u32 val;
        u16 radio_cfg;
-       u8 val_link;
+       u16 link;
 
        spin_lock_irqsave(&priv->lock, flags);
 
@@ -410,11 +394,11 @@ static void iwl4965_nic_config(struct iwl_priv *priv)
                                       val & ~(1 << 11));
        }
 
-       pci_read_config_byte(priv->pci_dev, PCI_LINK_CTRL, &val_link);
+       pci_read_config_word(priv->pci_dev, PCI_CFG_LINK_CTRL, &link);
 
        /* L1 is enabled by BIOS */
-       if ((val_link & PCI_LINK_VAL_L1_EN) == PCI_LINK_VAL_L1_EN)
-               /* diable L0S disabled L1A enabled */
+       if ((link & PCI_CFG_LINK_CTRL_VAL_L1_EN) == PCI_CFG_LINK_CTRL_VAL_L1_EN)
+               /* disable L0S disabled L1A enabled */
                iwl_set_bit(priv, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED);
        else
                /* L0S enabled L1A disabled */
@@ -450,9 +434,8 @@ static int iwl4965_apm_stop_master(struct iwl_priv *priv)
        /* set stop master bit */
        iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER);
 
-       ret = iwl_poll_bit(priv, CSR_RESET,
-                                 CSR_RESET_REG_FLAG_MASTER_DISABLED,
-                                 CSR_RESET_REG_FLAG_MASTER_DISABLED, 100);
+       ret = iwl_poll_direct_bit(priv, CSR_RESET,
+                       CSR_RESET_REG_FLAG_MASTER_DISABLED, 100);
        if (ret < 0)
                goto out;
 
@@ -496,11 +479,9 @@ static int iwl4965_apm_reset(struct iwl_priv *priv)
 
        iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
 
-       ret = iwl_poll_bit(priv, CSR_RESET,
-                         CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY,
-                         CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25);
-
-       if (ret)
+       ret = iwl_poll_direct_bit(priv, CSR_GP_CNTRL,
+                       CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
+       if (ret < 0)
                goto out;
 
        udelay(10);
@@ -537,10 +518,10 @@ static void iwl4965_chain_noise_reset(struct iwl_priv *priv)
        struct iwl_chain_noise_data *data = &(priv->chain_noise_data);
 
        if ((data->state == IWL_CHAIN_NOISE_ALIVE) && iwl_is_associated(priv)) {
-               struct iwl4965_calibration_cmd cmd;
+               struct iwl_calib_diff_gain_cmd cmd;
 
                memset(&cmd, 0, sizeof(cmd));
-               cmd.opCode = PHY_CALIBRATE_DIFF_GAIN_CMD;
+               cmd.hdr.op_code = IWL_PHY_CALIBRATE_DIFF_GAIN_CMD;
                cmd.diff_gain_a = 0;
                cmd.diff_gain_b = 0;
                cmd.diff_gain_c = 0;
@@ -587,11 +568,11 @@ static void iwl4965_gain_computation(struct iwl_priv *priv,
 
        /* Differential gain gets sent to uCode only once */
        if (!data->radio_write) {
-               struct iwl4965_calibration_cmd cmd;
+               struct iwl_calib_diff_gain_cmd cmd;
                data->radio_write = 1;
 
                memset(&cmd, 0, sizeof(cmd));
-               cmd.opCode = PHY_CALIBRATE_DIFF_GAIN_CMD;
+               cmd.hdr.op_code = IWL_PHY_CALIBRATE_DIFF_GAIN_CMD;
                cmd.diff_gain_a = data->delta_gain_code[0];
                cmd.diff_gain_b = data->delta_gain_code[1];
                cmd.diff_gain_c = data->delta_gain_code[2];
@@ -619,10 +600,10 @@ static void iwl4965_gain_computation(struct iwl_priv *priv,
 static void iwl4965_rts_tx_cmd_flag(struct ieee80211_tx_info *info,
                        __le32 *tx_flags)
 {
-       if (info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) {
+       if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) {
                *tx_flags |= TX_CMD_FLG_RTS_MSK;
                *tx_flags &= ~TX_CMD_FLG_CTS_MSK;
-       } else if (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT) {
+       } else if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT) {
                *tx_flags &= ~TX_CMD_FLG_RTS_MSK;
                *tx_flags |= TX_CMD_FLG_CTS_MSK;
        }
@@ -643,7 +624,7 @@ static void iwl4965_bg_txpower_work(struct work_struct *work)
 
        mutex_lock(&priv->mutex);
 
-       /* Regardless of if we are assocaited, we must reconfigure the
+       /* Regardless of if we are associated, we must reconfigure the
         * TX power since frames can be sent on non-radar channels while
         * not associated */
        iwl4965_send_tx_power(priv);
@@ -679,7 +660,7 @@ static void iwl4965_tx_queue_set_status(struct iwl_priv *priv,
        int txq_id = txq->q.id;
 
        /* Find out whether to activate Tx queue */
-       int active = test_bit(txq_id, &priv->txq_ctx_active_msk)?1:0;
+       int active = test_bit(txq_id, &priv->txq_ctx_active_msk) ? 1 : 0;
 
        /* Set up and activate */
        iwl_write_prph(priv, IWL49_SCD_QUEUE_STATUS_BITS(txq_id),
@@ -709,9 +690,10 @@ static const u16 default_queue_to_tx_fifo[] = {
 static int iwl4965_alive_notify(struct iwl_priv *priv)
 {
        u32 a;
-       int i = 0;
        unsigned long flags;
        int ret;
+       int i, chan;
+       u32 reg_val;
 
        spin_lock_irqsave(&priv->lock, flags);
 
@@ -733,8 +715,18 @@ static int iwl4965_alive_notify(struct iwl_priv *priv)
 
        /* Tel 4965 where to find Tx byte count tables */
        iwl_write_prph(priv, IWL49_SCD_DRAM_BASE_ADDR,
-               (priv->shared_phys +
-                offsetof(struct iwl4965_shared, queues_byte_cnt_tbls)) >> 10);
+                       priv->scd_bc_tbls.dma >> 10);
+
+       /* Enable DMA channel */
+       for (chan = 0; chan < FH49_TCSR_CHNL_NUM ; chan++)
+               iwl_write_direct32(priv, FH_TCSR_CHNL_TX_CONFIG_REG(chan),
+                               FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE |
+                               FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE);
+
+       /* Update FH chicken bits */
+       reg_val = iwl_read_direct32(priv, FH_TX_CHICKEN_BITS_REG);
+       iwl_write_direct32(priv, FH_TX_CHICKEN_BITS_REG,
+                          reg_val | FH_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN);
 
        /* Disable chain mode for all queues */
        iwl_write_prph(priv, IWL49_SCD_QUEUECHAIN_SEL, 0);
@@ -766,7 +758,7 @@ static int iwl4965_alive_notify(struct iwl_priv *priv)
                                 (1 << priv->hw_params.max_txq_num) - 1);
 
        /* Activate all Tx DMA/FIFO channels */
-       priv->cfg->ops->lib->txq_set_sched(priv, IWL_MASK(0, 7));
+       priv->cfg->ops->lib->txq_set_sched(priv, IWL_MASK(0, 6));
 
        iwl4965_set_wr_ptrs(priv, IWL_CMD_QUEUE_NUM, 0);
 
@@ -822,7 +814,9 @@ static int iwl4965_hw_set_hw_params(struct iwl_priv *priv)
        }
 
        priv->hw_params.max_txq_num = priv->cfg->mod_params->num_of_queues;
-       priv->hw_params.first_ampdu_q = IWL49_FIRST_AMPDU_QUEUE;
+       priv->hw_params.dma_chnl_num = FH49_TCSR_CHNL_NUM;
+       priv->hw_params.scd_bc_tbls_size =
+                       IWL49_NUM_QUEUES * sizeof(struct iwl4965_scd_bc_tbl);
        priv->hw_params.max_stations = IWL4965_STATION_COUNT;
        priv->hw_params.bcast_sta_id = IWL4965_BROADCAST_ID;
        priv->hw_params.max_data_size = IWL49_RTC_DATA_SIZE;
@@ -1607,8 +1601,8 @@ static int iwl4965_send_rxon_assoc(struct iwl_priv *priv)
        return ret;
 }
 
-
-int iwl4965_hw_channel_switch(struct iwl_priv *priv, u16 channel)
+#ifdef IEEE80211_CONF_CHANNEL_SWITCH
+static int iwl4965_hw_channel_switch(struct iwl_priv *priv, u16 channel)
 {
        int rc;
        u8 band = 0;
@@ -1648,36 +1642,7 @@ int iwl4965_hw_channel_switch(struct iwl_priv *priv, u16 channel)
        rc = iwl_send_cmd_pdu(priv, REPLY_CHANNEL_SWITCH, sizeof(cmd), &cmd);
        return rc;
 }
-
-static int iwl4965_shared_mem_rx_idx(struct iwl_priv *priv)
-{
-       struct iwl4965_shared *s = priv->shared_virt;
-       return le32_to_cpu(s->rb_closed) & 0xFFF;
-}
-
-static int iwl4965_alloc_shared_mem(struct iwl_priv *priv)
-{
-       priv->shared_virt = pci_alloc_consistent(priv->pci_dev,
-                                       sizeof(struct iwl4965_shared),
-                                       &priv->shared_phys);
-       if (!priv->shared_virt)
-               return -ENOMEM;
-
-       memset(priv->shared_virt, 0, sizeof(struct iwl4965_shared));
-
-       priv->rb_closed_offset = offsetof(struct iwl4965_shared, rb_closed);
-
-       return 0;
-}
-
-static void iwl4965_free_shared_mem(struct iwl_priv *priv)
-{
-       if (priv->shared_virt)
-               pci_free_consistent(priv->pci_dev,
-                                   sizeof(struct iwl4965_shared),
-                                   priv->shared_virt,
-                                   priv->shared_phys);
-}
+#endif
 
 /**
  * iwl4965_txq_update_byte_cnt_tbl - Set up entry in Tx byte-count array
@@ -1686,21 +1651,22 @@ static void iwl4965_txq_update_byte_cnt_tbl(struct iwl_priv *priv,
                                            struct iwl_tx_queue *txq,
                                            u16 byte_cnt)
 {
-       int len;
+       struct iwl4965_scd_bc_tbl *scd_bc_tbl = priv->scd_bc_tbls.addr;
        int txq_id = txq->q.id;
-       struct iwl4965_shared *shared_data = priv->shared_virt;
+       int write_ptr = txq->q.write_ptr;
+       int len = byte_cnt + IWL_TX_CRC_SIZE + IWL_TX_DELIMITER_SIZE;
+       __le16 bc_ent;
 
-       len = byte_cnt + IWL_TX_CRC_SIZE + IWL_TX_DELIMITER_SIZE;
+       WARN_ON(len > 0xFFF || write_ptr >= TFD_QUEUE_SIZE_MAX);
 
+       bc_ent = cpu_to_le16(len & 0xFFF);
        /* Set up byte count within first 256 entries */
-       IWL_SET_BITS16(shared_data->queues_byte_cnt_tbls[txq_id].
-                      tfd_offset[txq->q.write_ptr], byte_cnt, len);
+       scd_bc_tbl[txq_id].tfd_offset[write_ptr] = bc_ent;
 
        /* If within first 64 entries, duplicate at end */
-       if (txq->q.write_ptr < IWL49_MAX_WIN_SIZE)
-               IWL_SET_BITS16(shared_data->queues_byte_cnt_tbls[txq_id].
-                       tfd_offset[IWL49_QUEUE_SIZE + txq->q.write_ptr],
-                       byte_cnt, len);
+       if (write_ptr < TFD_QUEUE_SIZE_BC_DUP)
+               scd_bc_tbl[txq_id].
+                       tfd_offset[TFD_QUEUE_SIZE_MAX + write_ptr] = bc_ent;
 }
 
 /**
@@ -1955,7 +1921,7 @@ static int iwl4965_txq_agg_enable(struct iwl_priv *priv, int txq_id,
        ra_tid = BUILD_RAxTID(sta_id, tid);
 
        /* Modify device's station table to Tx this TID */
-       iwl_sta_modify_enable_tid_tx(priv, sta_id, tid);
+       iwl_sta_tx_modify_enable_tid(priv, sta_id, tid);
 
        spin_lock_irqsave(&priv->lock, flags);
        ret = iwl_grab_nic_access(priv);
@@ -2036,7 +2002,7 @@ static inline u32 iwl4965_get_scd_ssn(struct iwl4965_tx_resp *tx_resp)
 }
 
 /**
- * iwl4965_tx_status_reply_tx - Handle Tx rspnse for frames in aggregation queue
+ * iwl4965_tx_status_reply_tx - Handle Tx response for frames in aggregation queue
  */
 static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv,
                                      struct iwl_ht_agg *agg,
@@ -2058,7 +2024,7 @@ static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv,
        agg->rate_n_flags = rate_n_flags;
        agg->bitmap = 0;
 
-       /* # frames attempted by Tx command */
+       /* num frames attempted by Tx command */
        if (agg->frame_count == 1) {
                /* Only one frame was attempted; no block-ack will arrive */
                status = le16_to_cpu(frame_status[0].status);
@@ -2069,9 +2035,9 @@ static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv,
                                   agg->frame_count, agg->start_idx, idx);
 
                info = IEEE80211_SKB_CB(priv->txq[txq_id].txb[idx].skb[0]);
-               info->status.retry_count = tx_resp->failure_frame;
+               info->status.rates[0].count = tx_resp->failure_frame + 1;
                info->flags &= ~IEEE80211_TX_CTL_AMPDU;
-               info->flags |= iwl_is_tx_success(status)?
+               info->flags |= iwl_is_tx_success(status) ?
                        IEEE80211_TX_STAT_ACK : 0;
                iwl_hwrate_to_tx_control(priv, rate_n_flags, info);
                /* FIXME: code repetition end */
@@ -2157,12 +2123,13 @@ static void iwl4965_rx_reply_tx(struct iwl_priv *priv,
        int txq_id = SEQ_TO_QUEUE(sequence);
        int index = SEQ_TO_INDEX(sequence);
        struct iwl_tx_queue *txq = &priv->txq[txq_id];
+       struct ieee80211_hdr *hdr;
        struct ieee80211_tx_info *info;
        struct iwl4965_tx_resp *tx_resp = (void *)&pkt->u.raw[0];
        u32  status = le32_to_cpu(tx_resp->u.status);
-       int tid = MAX_TID_COUNT, sta_id = IWL_INVALID_STATION;
-       __le16 fc;
-       struct ieee80211_hdr *hdr;
+       int tid = MAX_TID_COUNT;
+       int sta_id;
+       int freed;
        u8 *qc = NULL;
 
        if ((index >= txq->q.n_bd) || (iwl_queue_used(&txq->q, index) == 0)) {
@@ -2177,8 +2144,7 @@ static void iwl4965_rx_reply_tx(struct iwl_priv *priv,
        memset(&info->status, 0, sizeof(info->status));
 
        hdr = iwl_tx_queue_get_hdr(priv, txq_id, index);
-       fc = hdr->frame_control;
-       if (ieee80211_is_data_qos(fc)) {
+       if (ieee80211_is_data_qos(hdr->frame_control)) {
                qc = ieee80211_get_qos_ctl(hdr);
                tid = qc[0] & 0xf;
        }
@@ -2193,8 +2159,7 @@ static void iwl4965_rx_reply_tx(struct iwl_priv *priv,
                const u32 scd_ssn = iwl4965_get_scd_ssn(tx_resp);
                struct iwl_ht_agg *agg = NULL;
 
-               if (!qc)
-                       return;
+               WARN_ON(!qc);
 
                agg = &priv->stations[sta_id].tid[tid].agg;
 
@@ -2205,54 +2170,49 @@ static void iwl4965_rx_reply_tx(struct iwl_priv *priv,
                        info->flags |= IEEE80211_TX_STAT_AMPDU_NO_BACK;
 
                if (txq->q.read_ptr != (scd_ssn & 0xff)) {
-                       int freed, ampdu_q;
                        index = iwl_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd);
                        IWL_DEBUG_TX_REPLY("Retry scheduler reclaim scd_ssn "
                                           "%d index %d\n", scd_ssn , index);
                        freed = iwl_tx_queue_reclaim(priv, txq_id, index);
                        priv->stations[sta_id].tid[tid].tfds_in_queue -= freed;
 
-                       if (iwl_queue_space(&txq->q) > txq->q.low_mark &&
-                           txq_id >= 0 && priv->mac80211_registered &&
-                           agg->state != IWL_EMPTYING_HW_QUEUE_DELBA) {
-                               /* calculate mac80211 ampdu sw queue to wake */
-                               ampdu_q = txq_id - IWL49_FIRST_AMPDU_QUEUE +
-                                         priv->hw->queues;
+                       if (priv->mac80211_registered &&
+                           (iwl_queue_space(&txq->q) > txq->q.low_mark) &&
+                           (agg->state != IWL_EMPTYING_HW_QUEUE_DELBA)) {
                                if (agg->state == IWL_AGG_OFF)
                                        ieee80211_wake_queue(priv->hw, txq_id);
                                else
-                                       ieee80211_wake_queue(priv->hw, ampdu_q);
+                                       ieee80211_wake_queue(priv->hw,
+                                                            txq->swq_id);
                        }
-                       iwl_txq_check_empty(priv, sta_id, tid, txq_id);
                }
        } else {
-               info->status.retry_count = tx_resp->failure_frame;
-               info->flags |=
-                       iwl_is_tx_success(status) ? IEEE80211_TX_STAT_ACK : 0;
+               info->status.rates[0].count = tx_resp->failure_frame + 1;
+               info->flags |= iwl_is_tx_success(status) ?
+                                       IEEE80211_TX_STAT_ACK : 0;
                iwl_hwrate_to_tx_control(priv,
                                        le32_to_cpu(tx_resp->rate_n_flags),
                                        info);
 
-               IWL_DEBUG_TX("Tx queue %d Status %s (0x%08x) rate_n_flags "
-                            "0x%x retries %d\n", txq_id,
-                               iwl_get_tx_fail_reason(status),
-                               status, le32_to_cpu(tx_resp->rate_n_flags),
-                               tx_resp->failure_frame);
+               IWL_DEBUG_TX_REPLY("TXQ %d status %s (0x%08x) "
+                                  "rate_n_flags 0x%x retries %d\n",
+                                  txq_id,
+                                  iwl_get_tx_fail_reason(status), status,
+                                  le32_to_cpu(tx_resp->rate_n_flags),
+                                  tx_resp->failure_frame);
 
-               IWL_DEBUG_TX_REPLY("Tx queue reclaim %d\n", index);
-
-               if (index != -1) {
-                   int freed = iwl_tx_queue_reclaim(priv, txq_id, index);
-                   if (tid != MAX_TID_COUNT)
+               freed = iwl_tx_queue_reclaim(priv, txq_id, index);
+               if (qc && likely(sta_id != IWL_INVALID_STATION))
                        priv->stations[sta_id].tid[tid].tfds_in_queue -= freed;
-                   if (iwl_queue_space(&txq->q) > txq->q.low_mark &&
-                       (txq_id >= 0) && priv->mac80211_registered)
+
+               if (priv->mac80211_registered &&
+                   (iwl_queue_space(&txq->q) > txq->q.low_mark))
                        ieee80211_wake_queue(priv->hw, txq_id);
-                   if (tid != MAX_TID_COUNT)
-                       iwl_txq_check_empty(priv, sta_id, tid, txq_id);
-               }
        }
 
+       if (qc && likely(sta_id != IWL_INVALID_STATION))
+               iwl_txq_check_empty(priv, sta_id, tid, txq_id);
+
        if (iwl_check_bits(status, TX_ABORT_REQUIRED_MSK))
                IWL_ERROR("TODO:  Implement Tx ABORT REQUIRED!!!\n");
 }
@@ -2327,9 +2287,6 @@ static struct iwl_hcmd_utils_ops iwl4965_hcmd_utils = {
 
 static struct iwl_lib_ops iwl4965_lib = {
        .set_hw_params = iwl4965_hw_set_hw_params,
-       .alloc_shared_mem = iwl4965_alloc_shared_mem,
-       .free_shared_mem = iwl4965_free_shared_mem,
-       .shared_mem_rx_idx = iwl4965_shared_mem_rx_idx,
        .txq_update_byte_cnt_tbl = iwl4965_txq_update_byte_cnt_tbl,
        .txq_set_sched = iwl4965_txq_set_sched,
        .txq_agg_enable = iwl4965_txq_agg_enable,
@@ -2346,7 +2303,7 @@ static struct iwl_lib_ops iwl4965_lib = {
                .reset = iwl4965_apm_reset,
                .stop = iwl4965_apm_stop,
                .config = iwl4965_nic_config,
-               .set_pwr_src = iwl4965_set_pwr_src,
+               .set_pwr_src = iwl_set_pwr_src,
        },
        .eeprom_ops = {
                .regulatory_bands = {
@@ -2361,11 +2318,11 @@ static struct iwl_lib_ops iwl4965_lib = {
                .verify_signature  = iwlcore_eeprom_verify_signature,
                .acquire_semaphore = iwlcore_eeprom_acquire_semaphore,
                .release_semaphore = iwlcore_eeprom_release_semaphore,
-               .check_version = iwl4965_eeprom_check_version,
+               .calib_version = iwl4965_eeprom_calib_version,
                .query_addr = iwlcore_eeprom_query_addr,
        },
        .send_tx_power  = iwl4965_send_tx_power,
-       .update_chain_flags = iwl4965_update_chain_flags,
+       .update_chain_flags = iwl_update_chain_flags,
        .temperature = iwl4965_temperature_calib,
 };
 
@@ -2377,15 +2334,19 @@ static struct iwl_ops iwl4965_ops = {
 
 struct iwl_cfg iwl4965_agn_cfg = {
        .name = "4965AGN",
-       .fw_name = "iwlwifi-4965" IWL4965_UCODE_API ".ucode",
+       .fw_name_pre = IWL4965_FW_PRE,
+       .ucode_api_max = IWL4965_UCODE_API_MAX,
+       .ucode_api_min = IWL4965_UCODE_API_MIN,
        .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
        .eeprom_size = IWL4965_EEPROM_IMG_SIZE,
+       .eeprom_ver = EEPROM_4965_EEPROM_VERSION,
+       .eeprom_calib_ver = EEPROM_4965_TX_POWER_VERSION,
        .ops = &iwl4965_ops,
        .mod_params = &iwl4965_mod_params,
 };
 
 /* Module firmware */
-MODULE_FIRMWARE("iwlwifi-4965" IWL4965_UCODE_API ".ucode");
+MODULE_FIRMWARE(IWL4965_MODULE_FIRMWARE(IWL4965_UCODE_API_MAX));
 
 module_param_named(antenna, iwl4965_mod_params.antenna, int, 0444);
 MODULE_PARM_DESC(antenna, "select antenna (1=Main, 2=Aux, default 0 [both])");
@@ -2393,7 +2354,7 @@ module_param_named(disable, iwl4965_mod_params.disable, int, 0444);
 MODULE_PARM_DESC(disable, "manually disable the radio (default 0 [radio on])");
 module_param_named(swcrypto, iwl4965_mod_params.sw_crypto, int, 0444);
 MODULE_PARM_DESC(swcrypto, "using crypto in software (default 0 [hardware])");
-module_param_named(debug, iwl4965_mod_params.debug, int, 0444);
+module_param_named(debug, iwl4965_mod_params.debug, uint, 0444);
 MODULE_PARM_DESC(debug, "debug output mask");
 module_param_named(
        disable_hw_scan, iwl4965_mod_params.disable_hw_scan, int, 0444);
@@ -2401,9 +2362,6 @@ MODULE_PARM_DESC(disable_hw_scan, "disable hardware scanning (default 0)");
 
 module_param_named(queues_num, iwl4965_mod_params.num_of_queues, int, 0444);
 MODULE_PARM_DESC(queues_num, "number of hw queues.");
-/* QoS */
-module_param_named(qos_enable, iwl4965_mod_params.enable_qos, int, 0444);
-MODULE_PARM_DESC(qos_enable, "enable all QoS functionality");
 /* 11n */
 module_param_named(11n_disable, iwl4965_mod_params.disable_11n, int, 0444);
 MODULE_PARM_DESC(11n_disable, "disable 11n functionality");