iwlwifi: removing IWL4965_HT config
[pandora-kernel.git] / drivers / net / wireless / iwlwifi / iwl4965-base.c
index ee9fe56..88229e2 100644 (file)
@@ -87,12 +87,6 @@ MODULE_VERSION(DRV_VERSION);
 MODULE_AUTHOR(DRV_COPYRIGHT);
 MODULE_LICENSE("GPL");
 
-static const struct ieee80211_supported_band *iwl_get_hw_mode(
-               struct iwl_priv *priv, enum ieee80211_band band)
-{
-       return priv->hw->wiphy->bands[band];
-}
-
 static int iwl4965_is_empty_essid(const char *essid, int essid_len)
 {
        /* Single white space is for Linksys APs */
@@ -140,49 +134,6 @@ static const char *iwl4965_escape_essid(const char *essid, u8 essid_len)
 
 /**************************************************************/
 
-#if 0 /* temporary disable till we add real remove station */
-/**
- * iwl4965_remove_station - Remove driver's knowledge of station.
- *
- * NOTE:  This does not remove station from device's station table.
- */
-static u8 iwl4965_remove_station(struct iwl_priv *priv, const u8 *addr, int is_ap)
-{
-       int index = IWL_INVALID_STATION;
-       int i;
-       unsigned long flags;
-
-       spin_lock_irqsave(&priv->sta_lock, flags);
-
-       if (is_ap)
-               index = IWL_AP_ID;
-       else if (is_broadcast_ether_addr(addr))
-               index = priv->hw_params.bcast_sta_id;
-       else
-               for (i = IWL_STA_ID; i < priv->hw_params.max_stations; i++)
-                       if (priv->stations[i].used &&
-                           !compare_ether_addr(priv->stations[i].sta.sta.addr,
-                                               addr)) {
-                               index = i;
-                               break;
-                       }
-
-       if (unlikely(index == IWL_INVALID_STATION))
-               goto out;
-
-       if (priv->stations[index].used) {
-               priv->stations[index].used = 0;
-               priv->num_stations--;
-       }
-
-       BUG_ON(priv->num_stations < 0);
-
-out:
-       spin_unlock_irqrestore(&priv->sta_lock, flags);
-       return 0;
-}
-#endif
-
 
 
 static void iwl4965_set_rxon_hwcrypto(struct iwl_priv *priv, int hw_decrypt)
@@ -404,6 +355,7 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv)
                return rc;
        }
 
+       iwl_remove_station(priv, iwl_bcast_addr, 0);
        iwlcore_clear_stations_table(priv);
 
        if (!priv->error_recovering)
@@ -682,7 +634,6 @@ static u16 iwl4965_supported_rate_to_ie(u8 *ie, u16 supported_rate,
        return ret_rates;
 }
 
-#ifdef CONFIG_IWL4965_HT
 static void iwl4965_ht_conf(struct iwl_priv *priv,
                            struct ieee80211_bss_conf *bss_conf)
 {
@@ -755,17 +706,6 @@ static void iwl_ht_cap_to_ie(const struct ieee80211_supported_band *sband,
                        IEEE80211_HT_CAP_AMPDU_DENSITY);
        *left -= sizeof(struct ieee80211_ht_cap);
 }
-#else
-static inline void iwl4965_ht_conf(struct iwl_priv *priv,
-                                  struct ieee80211_bss_conf *bss_conf)
-{
-}
-static void iwl_ht_cap_to_ie(const struct ieee80211_supported_band *sband,
-                       u8 *pos, int *left)
-{
-}
-#endif
-
 
 /**
  * iwl4965_fill_probe_req - fill in all required fields and IE for probe request
@@ -910,10 +850,8 @@ static void iwl4965_activate_qos(struct iwl_priv *priv, u8 force)
                priv->qos_data.def_qos_parm.qos_flags |=
                        QOS_PARAM_FLG_UPDATE_EDCA_MSK;
 
-#ifdef CONFIG_IWL4965_HT
        if (priv->current_ht_config.is_ht)
                priv->qos_data.def_qos_parm.qos_flags |= QOS_PARAM_FLG_TGN_MSK;
-#endif /* CONFIG_IWL4965_HT */
 
        spin_unlock_irqrestore(&priv->lock, flags);
 
@@ -957,33 +895,7 @@ int iwl4965_is_network_packet(struct iwl_priv *priv, struct ieee80211_hdr *heade
        return 1;
 }
 
-#define TX_STATUS_ENTRY(x) case TX_STATUS_FAIL_ ## x: return #x
 
-static const char *iwl4965_get_tx_fail_reason(u32 status)
-{
-       switch (status & TX_STATUS_MSK) {
-       case TX_STATUS_SUCCESS:
-               return "SUCCESS";
-               TX_STATUS_ENTRY(SHORT_LIMIT);
-               TX_STATUS_ENTRY(LONG_LIMIT);
-               TX_STATUS_ENTRY(FIFO_UNDERRUN);
-               TX_STATUS_ENTRY(MGMNT_ABORT);
-               TX_STATUS_ENTRY(NEXT_FRAG);
-               TX_STATUS_ENTRY(LIFE_EXPIRE);
-               TX_STATUS_ENTRY(DEST_PS);
-               TX_STATUS_ENTRY(ABORTED);
-               TX_STATUS_ENTRY(BT_RETRY);
-               TX_STATUS_ENTRY(STA_INVALID);
-               TX_STATUS_ENTRY(FRAG_DROPPED);
-               TX_STATUS_ENTRY(TID_DISABLE);
-               TX_STATUS_ENTRY(FRAME_FLUSHED);
-               TX_STATUS_ENTRY(INSUFFICIENT_CF_POLL);
-               TX_STATUS_ENTRY(TX_LOCKED);
-               TX_STATUS_ENTRY(NO_BEACON_ON_RADAR);
-       }
-
-       return "UNKNOWN";
-}
 
 /**
  * iwl4965_scan_cancel - Cancel any currently executing HW scan
@@ -1158,8 +1070,8 @@ static int iwl4965_scan_initiate(struct iwl_priv *priv)
 }
 
 
-static void iwl4965_set_flags_for_phymode(struct iwl_priv *priv,
-                                         enum ieee80211_band band)
+static void iwl_set_flags_for_band(struct iwl_priv *priv,
+                                  enum ieee80211_band band)
 {
        if (band == IEEE80211_BAND_5GHZ) {
                priv->staging_rxon.flags &=
@@ -1244,7 +1156,7 @@ static void iwl4965_connection_init_rx_config(struct iwl_priv *priv)
        priv->staging_rxon.channel = cpu_to_le16(ch_info->channel);
        priv->band = ch_info->band;
 
-       iwl4965_set_flags_for_phymode(priv, priv->band);
+       iwl_set_flags_for_band(priv, priv->band);
 
        priv->staging_rxon.ofdm_basic_rates =
            (IWL_OFDM_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF;
@@ -1603,330 +1515,11 @@ static int iwl4965_get_measurement(struct iwl_priv *priv,
 }
 #endif
 
-static void iwl4965_txstatus_to_ieee(struct iwl_priv *priv,
-                                    struct iwl_tx_info *tx_sta)
-{
-       ieee80211_tx_status_irqsafe(priv->hw, tx_sta->skb[0]);
-       tx_sta->skb[0] = NULL;
-}
-
-/**
- * iwl4965_tx_queue_reclaim - Reclaim Tx queue entries already Tx'd
- *
- * When FW advances 'R' index, all entries between old and new 'R' index
- * need to be reclaimed. As result, some free space forms.  If there is
- * enough free space (> low mark), wake the stack that feeds us.
- */
-int iwl4965_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index)
-{
-       struct iwl_tx_queue *txq = &priv->txq[txq_id];
-       struct iwl_queue *q = &txq->q;
-       int nfreed = 0;
-
-       if ((index >= q->n_bd) || (iwl_queue_used(q, index) == 0)) {
-               IWL_ERROR("Read index for DMA queue txq id (%d), index %d, "
-                         "is out of range [0-%d] %d %d.\n", txq_id,
-                         index, q->n_bd, q->write_ptr, q->read_ptr);
-               return 0;
-       }
-
-       for (index = iwl_queue_inc_wrap(index, q->n_bd);
-               q->read_ptr != index;
-               q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd)) {
-               if (txq_id != IWL_CMD_QUEUE_NUM) {
-                       iwl4965_txstatus_to_ieee(priv,
-                                       &(txq->txb[txq->q.read_ptr]));
-                       iwl_hw_txq_free_tfd(priv, txq);
-               } else if (nfreed > 1) {
-                       IWL_ERROR("HCMD skipped: index (%d) %d %d\n", index,
-                                       q->write_ptr, q->read_ptr);
-                       queue_work(priv->workqueue, &priv->restart);
-               }
-               nfreed++;
-       }
-
-       return nfreed;
-}
-
-static int iwl4965_is_tx_success(u32 status)
-{
-       status &= TX_STATUS_MSK;
-       return (status == TX_STATUS_SUCCESS)
-           || (status == TX_STATUS_DIRECT_DONE);
-}
-
 /******************************************************************************
  *
  * Generic RX handler implementations
  *
  ******************************************************************************/
-#ifdef CONFIG_IWL4965_HT
-
-static inline int iwl4965_get_ra_sta_id(struct iwl_priv *priv,
-                                   struct ieee80211_hdr *hdr)
-{
-       if (priv->iw_mode == IEEE80211_IF_TYPE_STA)
-               return IWL_AP_ID;
-       else {
-               u8 *da = ieee80211_get_DA(hdr);
-               return iwl_find_station(priv, da);
-       }
-}
-
-static struct ieee80211_hdr *iwl4965_tx_queue_get_hdr(
-       struct iwl_priv *priv, int txq_id, int idx)
-{
-       if (priv->txq[txq_id].txb[idx].skb[0])
-               return (struct ieee80211_hdr *)priv->txq[txq_id].
-                               txb[idx].skb[0]->data;
-       return NULL;
-}
-
-static inline u32 iwl4965_get_scd_ssn(struct iwl4965_tx_resp *tx_resp)
-{
-       __le32 *scd_ssn = (__le32 *)((u32 *)&tx_resp->status +
-                               tx_resp->frame_count);
-       return le32_to_cpu(*scd_ssn) & MAX_SN;
-
-}
-
-/**
- * iwl4965_tx_status_reply_tx - Handle Tx rspnse for frames in aggregation queue
- */
-static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv,
-                                     struct iwl_ht_agg *agg,
-                                     struct iwl4965_tx_resp_agg *tx_resp,
-                                     u16 start_idx)
-{
-       u16 status;
-       struct agg_tx_status *frame_status = &tx_resp->status;
-       struct ieee80211_tx_info *info = NULL;
-       struct ieee80211_hdr *hdr = NULL;
-       int i, sh;
-       int txq_id, idx;
-       u16 seq;
-
-       if (agg->wait_for_ba)
-               IWL_DEBUG_TX_REPLY("got tx response w/o block-ack\n");
-
-       agg->frame_count = tx_resp->frame_count;
-       agg->start_idx = start_idx;
-       agg->rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags);
-       agg->bitmap = 0;
-
-       /* # 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);
-               seq  = le16_to_cpu(frame_status[0].sequence);
-               idx = SEQ_TO_INDEX(seq);
-               txq_id = SEQ_TO_QUEUE(seq);
-
-               /* FIXME: code repetition */
-               IWL_DEBUG_TX_REPLY("FrameCnt = %d, StartIdx=%d idx=%d\n",
-                                  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->flags &= ~IEEE80211_TX_CTL_AMPDU;
-               info->flags |= iwl4965_is_tx_success(status)?
-                       IEEE80211_TX_STAT_ACK : 0;
-               iwl4965_hwrate_to_tx_control(priv,
-                                            le32_to_cpu(tx_resp->rate_n_flags),
-                                            info);
-               /* FIXME: code repetition end */
-
-               IWL_DEBUG_TX_REPLY("1 Frame 0x%x failure :%d\n",
-                                   status & 0xff, tx_resp->failure_frame);
-               IWL_DEBUG_TX_REPLY("Rate Info rate_n_flags=%x\n",
-                               iwl4965_hw_get_rate_n_flags(tx_resp->rate_n_flags));
-
-               agg->wait_for_ba = 0;
-       } else {
-               /* Two or more frames were attempted; expect block-ack */
-               u64 bitmap = 0;
-               int start = agg->start_idx;
-
-               /* Construct bit-map of pending frames within Tx window */
-               for (i = 0; i < agg->frame_count; i++) {
-                       u16 sc;
-                       status = le16_to_cpu(frame_status[i].status);
-                       seq  = le16_to_cpu(frame_status[i].sequence);
-                       idx = SEQ_TO_INDEX(seq);
-                       txq_id = SEQ_TO_QUEUE(seq);
-
-                       if (status & (AGG_TX_STATE_FEW_BYTES_MSK |
-                                     AGG_TX_STATE_ABORT_MSK))
-                               continue;
-
-                       IWL_DEBUG_TX_REPLY("FrameCnt = %d, txq_id=%d idx=%d\n",
-                                          agg->frame_count, txq_id, idx);
-
-                       hdr = iwl4965_tx_queue_get_hdr(priv, txq_id, idx);
-
-                       sc = le16_to_cpu(hdr->seq_ctrl);
-                       if (idx != (SEQ_TO_SN(sc) & 0xff)) {
-                               IWL_ERROR("BUG_ON idx doesn't match seq control"
-                                         " idx=%d, seq_idx=%d, seq=%d\n",
-                                         idx, SEQ_TO_SN(sc),
-                                         hdr->seq_ctrl);
-                               return -1;
-                       }
-
-                       IWL_DEBUG_TX_REPLY("AGG Frame i=%d idx %d seq=%d\n",
-                                          i, idx, SEQ_TO_SN(sc));
-
-                       sh = idx - start;
-                       if (sh > 64) {
-                               sh = (start - idx) + 0xff;
-                               bitmap = bitmap << sh;
-                               sh = 0;
-                               start = idx;
-                       } else if (sh < -64)
-                               sh  = 0xff - (start - idx);
-                       else if (sh < 0) {
-                               sh = start - idx;
-                               start = idx;
-                               bitmap = bitmap << sh;
-                               sh = 0;
-                       }
-                       bitmap |= (1 << sh);
-                       IWL_DEBUG_TX_REPLY("start=%d bitmap=0x%x\n",
-                                          start, (u32)(bitmap & 0xFFFFFFFF));
-               }
-
-               agg->bitmap = bitmap;
-               agg->start_idx = start;
-               agg->rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags);
-               IWL_DEBUG_TX_REPLY("Frames %d start_idx=%d bitmap=0x%llx\n",
-                                  agg->frame_count, agg->start_idx,
-                                  (unsigned long long)agg->bitmap);
-
-               if (bitmap)
-                       agg->wait_for_ba = 1;
-       }
-       return 0;
-}
-#endif
-
-/**
- * iwl4965_rx_reply_tx - Handle standard (non-aggregation) Tx response
- */
-static void iwl4965_rx_reply_tx(struct iwl_priv *priv,
-                               struct iwl_rx_mem_buffer *rxb)
-{
-       struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data;
-       u16 sequence = le16_to_cpu(pkt->hdr.sequence);
-       int txq_id = SEQ_TO_QUEUE(sequence);
-       int index = SEQ_TO_INDEX(sequence);
-       struct iwl_tx_queue *txq = &priv->txq[txq_id];
-       struct ieee80211_tx_info *info;
-       struct iwl4965_tx_resp *tx_resp = (void *)&pkt->u.raw[0];
-       u32  status = le32_to_cpu(tx_resp->status);
-#ifdef CONFIG_IWL4965_HT
-       int tid = MAX_TID_COUNT, sta_id = IWL_INVALID_STATION;
-       u16 fc;
-       struct ieee80211_hdr *hdr;
-       u8 *qc = NULL;
-#endif
-
-       if ((index >= txq->q.n_bd) || (iwl_queue_used(&txq->q, index) == 0)) {
-               IWL_ERROR("Read index for DMA queue txq_id (%d) index %d "
-                         "is out of range [0-%d] %d %d\n", txq_id,
-                         index, txq->q.n_bd, txq->q.write_ptr,
-                         txq->q.read_ptr);
-               return;
-       }
-
-       info = IEEE80211_SKB_CB(txq->txb[txq->q.read_ptr].skb[0]);
-       memset(&info->status, 0, sizeof(info->status));
-
-#ifdef CONFIG_IWL4965_HT
-       hdr = iwl4965_tx_queue_get_hdr(priv, txq_id, index);
-       fc = le16_to_cpu(hdr->frame_control);
-       if (ieee80211_is_qos_data(fc)) {
-               qc = ieee80211_get_qos_ctrl(hdr, ieee80211_get_hdrlen(fc));
-               tid = qc[0] & 0xf;
-       }
-
-       sta_id = iwl4965_get_ra_sta_id(priv, hdr);
-       if (txq->sched_retry && unlikely(sta_id == IWL_INVALID_STATION)) {
-               IWL_ERROR("Station not known\n");
-               return;
-       }
-
-       if (txq->sched_retry) {
-               const u32 scd_ssn = iwl4965_get_scd_ssn(tx_resp);
-               struct iwl_ht_agg *agg = NULL;
-
-               if (!qc)
-                       return;
-
-               agg = &priv->stations[sta_id].tid[tid].agg;
-
-               iwl4965_tx_status_reply_tx(priv, agg,
-                               (struct iwl4965_tx_resp_agg *)tx_resp, index);
-
-               if ((tx_resp->frame_count == 1) &&
-                   !iwl4965_is_tx_success(status)) {
-                       /* TODO: send BAR */
-               }
-
-               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 = iwl4965_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 - IWL_BACK_QUEUE_FIRST_ID +
-                                         priv->hw->queues;
-                               if (agg->state == IWL_AGG_OFF)
-                                       ieee80211_wake_queue(priv->hw, txq_id);
-                               else
-                                       ieee80211_wake_queue(priv->hw, ampdu_q);
-                       }
-                       iwl4965_check_empty_hw_queue(priv, sta_id, tid, txq_id);
-               }
-       } else {
-#endif /* CONFIG_IWL4965_HT */
-
-       info->status.retry_count = tx_resp->failure_frame;
-       info->flags |=
-           iwl4965_is_tx_success(status) ? IEEE80211_TX_STAT_ACK : 0;
-       iwl4965_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, iwl4965_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);
-#ifdef CONFIG_IWL4965_HT
-       if (index != -1) {
-               int freed = iwl4965_tx_queue_reclaim(priv, txq_id, index);
-               if (tid != MAX_TID_COUNT)
-                       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)
-                       ieee80211_wake_queue(priv->hw, txq_id);
-               if (tid != MAX_TID_COUNT)
-                       iwl4965_check_empty_hw_queue(priv, sta_id, tid, txq_id);
-       }
-       }
-#endif /* CONFIG_IWL4965_HT */
-
-       if (iwl_check_bits(status, TX_ABORT_REQUIRED_MSK))
-               IWL_ERROR("TODO:  Implement Tx ABORT REQUIRED!!!\n");
-}
-
-
 static void iwl_rx_reply_alive(struct iwl_priv *priv,
                                struct iwl_rx_mem_buffer *rxb)
 {
@@ -1963,15 +1556,6 @@ static void iwl_rx_reply_alive(struct iwl_priv *priv,
                IWL_WARNING("uCode did not respond OK.\n");
 }
 
-static void iwl4965_rx_reply_add_sta(struct iwl_priv *priv,
-                                    struct iwl_rx_mem_buffer *rxb)
-{
-       struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data;
-
-       IWL_DEBUG_RX("Received REPLY_ADD_STA: 0x%02X\n", pkt->u.status);
-       return;
-}
-
 static void iwl4965_rx_reply_error(struct iwl_priv *priv,
                                   struct iwl_rx_mem_buffer *rxb)
 {
@@ -2268,6 +1852,17 @@ static void iwl4965_rx_card_state_notif(struct iwl_priv *priv,
                wake_up_interruptible(&priv->wait_command_queue);
 }
 
+/* Cache phy data (Rx signal strength, etc) for HT frame (REPLY_RX_PHY_CMD).
+ * This will be used later in iwl4965_rx_reply_rx() for REPLY_RX_MPDU_CMD. */
+static void iwl4965_rx_reply_rx_phy(struct iwl_priv *priv,
+                                   struct iwl_rx_mem_buffer *rxb)
+{
+       struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data;
+       priv->last_phy_res[0] = 1;
+       memcpy(&priv->last_phy_res[1], &(pkt->u.raw[0]),
+              sizeof(struct iwl4965_rx_phy_res));
+}
+
 /**
  * iwl4965_setup_rx_handlers - Initialize Rx handler callbacks
  *
@@ -2280,7 +1875,6 @@ static void iwl4965_rx_card_state_notif(struct iwl_priv *priv,
 static void iwl4965_setup_rx_handlers(struct iwl_priv *priv)
 {
        priv->rx_handlers[REPLY_ALIVE] = iwl_rx_reply_alive;
-       priv->rx_handlers[REPLY_ADD_STA] = iwl4965_rx_reply_add_sta;
        priv->rx_handlers[REPLY_ERROR] = iwl4965_rx_reply_error;
        priv->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = iwl4965_rx_csa;
        priv->rx_handlers[SPECTRUM_MEASURE_NOTIFICATION] =
@@ -2297,66 +1891,25 @@ static void iwl4965_setup_rx_handlers(struct iwl_priv *priv)
         */
        priv->rx_handlers[REPLY_STATISTICS_CMD] = iwl4965_hw_rx_statistics;
        priv->rx_handlers[STATISTICS_NOTIFICATION] = iwl4965_hw_rx_statistics;
-
+       /* scan handlers */
        priv->rx_handlers[REPLY_SCAN_CMD] = iwl4965_rx_reply_scan;
        priv->rx_handlers[SCAN_START_NOTIFICATION] = iwl4965_rx_scan_start_notif;
        priv->rx_handlers[SCAN_RESULTS_NOTIFICATION] =
            iwl4965_rx_scan_results_notif;
        priv->rx_handlers[SCAN_COMPLETE_NOTIFICATION] =
            iwl4965_rx_scan_complete_notif;
+       /* status change handler */
        priv->rx_handlers[CARD_STATE_NOTIFICATION] = iwl4965_rx_card_state_notif;
-       priv->rx_handlers[REPLY_TX] = iwl4965_rx_reply_tx;
 
+       priv->rx_handlers[MISSED_BEACONS_NOTIFICATION] =
+           iwl_rx_missed_beacon_notif;
+       /* Rx handlers */
+       priv->rx_handlers[REPLY_RX_PHY_CMD] = iwl4965_rx_reply_rx_phy;
+       priv->rx_handlers[REPLY_RX_MPDU_CMD] = iwl4965_rx_reply_rx;
        /* Set up hardware specific Rx handlers */
        priv->cfg->ops->lib->rx_handler_setup(priv);
 }
 
-/**
- * iwl4965_tx_cmd_complete - Pull unused buffers off the queue and reclaim them
- * @rxb: Rx buffer to reclaim
- *
- * If an Rx buffer has an async callback associated with it the callback
- * will be executed.  The attached skb (if present) will only be freed
- * if the callback returns 1
- */
-static void iwl4965_tx_cmd_complete(struct iwl_priv *priv,
-                                   struct iwl_rx_mem_buffer *rxb)
-{
-       struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data;
-       u16 sequence = le16_to_cpu(pkt->hdr.sequence);
-       int txq_id = SEQ_TO_QUEUE(sequence);
-       int index = SEQ_TO_INDEX(sequence);
-       int huge = sequence & SEQ_HUGE_FRAME;
-       int cmd_index;
-       struct iwl_cmd *cmd;
-
-       /* If a Tx command is being handled and it isn't in the actual
-        * command queue then there a command routing bug has been introduced
-        * in the queue management code. */
-       if (txq_id != IWL_CMD_QUEUE_NUM)
-               IWL_ERROR("Error wrong command queue %d command id 0x%X\n",
-                         txq_id, pkt->hdr.cmd);
-       BUG_ON(txq_id != IWL_CMD_QUEUE_NUM);
-
-       cmd_index = get_cmd_index(&priv->txq[IWL_CMD_QUEUE_NUM].q, index, huge);
-       cmd = &priv->txq[IWL_CMD_QUEUE_NUM].cmd[cmd_index];
-
-       /* Input error checking is done when commands are added to queue. */
-       if (cmd->meta.flags & CMD_WANT_SKB) {
-               cmd->meta.source->u.skb = rxb->skb;
-               rxb->skb = NULL;
-       } else if (cmd->meta.u.callback &&
-                  !cmd->meta.u.callback(priv, cmd, rxb->skb))
-               rxb->skb = NULL;
-
-       iwl4965_tx_queue_reclaim(priv, txq_id, index);
-
-       if (!(cmd->meta.flags & CMD_ASYNC)) {
-               clear_bit(STATUS_HCMD_ACTIVE, &priv->status);
-               wake_up_interruptible(&priv->wait_command_queue);
-       }
-}
-
 /*
  * this should be called while priv->lock is locked
 */
@@ -2445,7 +1998,7 @@ void iwl_rx_handle(struct iwl_priv *priv)
                         * fire off the (possibly) blocking iwl_send_cmd()
                         * as we reclaim the driver command queue */
                        if (rxb && rxb->skb)
-                               iwl4965_tx_cmd_complete(priv, rxb);
+                               iwl_tx_cmd_complete(priv, rxb);
                        else
                                IWL_WARNING("Claim null rxb?\n");
                }
@@ -3404,8 +2957,8 @@ static void __iwl4965_down(struct iwl_priv *priv)
                         CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
        spin_unlock_irqrestore(&priv->lock, flags);
 
-       iwl4965_hw_txq_ctx_stop(priv);
-       iwl4965_hw_rxq_stop(priv);
+       iwl_txq_ctx_stop(priv);
+       iwl_rxq_stop(priv);
 
        spin_lock_irqsave(&priv->lock, flags);
        if (!iwl_grab_nic_access(priv)) {
@@ -3417,9 +2970,8 @@ static void __iwl4965_down(struct iwl_priv *priv)
 
        udelay(5);
 
-       iwl4965_hw_nic_stop_master(priv);
-       iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET);
-       iwl4965_hw_nic_reset(priv);
+       /* FIXME: apm_ops.suspend(priv) */
+       priv->cfg->ops->lib->apm_ops.reset(priv);
        priv->cfg->ops->lib->free_shared_mem(priv);
 
  exit:
@@ -3949,10 +3501,9 @@ static void iwl4965_post_associate(struct iwl_priv *priv)
 
        priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK;
 
-#ifdef CONFIG_IWL4965_HT
        if (priv->current_ht_config.is_ht)
                iwl_set_rxon_ht(priv, &priv->current_ht_config);
-#endif /* CONFIG_IWL4965_HT*/
+
        iwl_set_rxon_chain(priv);
        priv->staging_rxon.assoc_id = cpu_to_le16(priv->assoc_id);
 
@@ -4124,21 +3675,23 @@ static int iwl4965_mac_start(struct ieee80211_hw *hw)
        if (test_bit(STATUS_IN_SUSPEND, &priv->status))
                return 0;
 
-       /* Wait for START_ALIVE from ucode. Otherwise callbacks from
+       /* Wait for START_ALIVE from Run Time ucode. Otherwise callbacks from
         * mac80211 will not be run successfully. */
-       ret = wait_event_interruptible_timeout(priv->wait_command_queue,
-                       test_bit(STATUS_READY, &priv->status),
-                       UCODE_READY_TIMEOUT);
-       if (!ret) {
-               if (!test_bit(STATUS_READY, &priv->status)) {
-                       IWL_ERROR("Wait for START_ALIVE timeout after %dms.\n",
-                                 jiffies_to_msecs(UCODE_READY_TIMEOUT));
-                       ret = -ETIMEDOUT;
-                       goto out_release_irq;
+       if (priv->ucode_type == UCODE_RT) {
+               ret = wait_event_interruptible_timeout(priv->wait_command_queue,
+                               test_bit(STATUS_READY, &priv->status),
+                               UCODE_READY_TIMEOUT);
+               if (!ret) {
+                       if (!test_bit(STATUS_READY, &priv->status)) {
+                               IWL_ERROR("START_ALIVE timeout after %dms.\n",
+                                       jiffies_to_msecs(UCODE_READY_TIMEOUT));
+                               ret = -ETIMEDOUT;
+                               goto out_release_irq;
+                       }
                }
-       }
 
-       priv->is_open = 1;
+               priv->is_open = 1;
+       }
        IWL_DEBUG_MAC80211("leave\n");
        return 0;
 
@@ -4255,6 +3808,7 @@ static int iwl4965_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *co
        const struct iwl_channel_info *ch_info;
        unsigned long flags;
        int ret = 0;
+       u16 channel;
 
        mutex_lock(&priv->mutex);
        IWL_DEBUG_MAC80211("enter to channel %d\n", conf->channel->hw_value);
@@ -4275,33 +3829,29 @@ static int iwl4965_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *co
                return 0;
        }
 
-       spin_lock_irqsave(&priv->lock, flags);
-
-       ch_info = iwl_get_channel_info(priv, conf->channel->band,
-                       ieee80211_frequency_to_channel(conf->channel->center_freq));
+       channel = ieee80211_frequency_to_channel(conf->channel->center_freq);
+       ch_info = iwl_get_channel_info(priv, conf->channel->band, channel);
        if (!is_channel_valid(ch_info)) {
                IWL_DEBUG_MAC80211("leave - invalid channel\n");
-               spin_unlock_irqrestore(&priv->lock, flags);
                ret = -EINVAL;
                goto out;
        }
 
-#ifdef CONFIG_IWL4965_HT
+       spin_lock_irqsave(&priv->lock, flags);
+
        /* if we are switching from ht to 2.4 clear flags
         * from any ht related info since 2.4 does not
         * support ht */
-       if ((le16_to_cpu(priv->staging_rxon.channel) != conf->channel->hw_value)
+       if ((le16_to_cpu(priv->staging_rxon.channel) != channel)
 #ifdef IEEE80211_CONF_CHANNEL_SWITCH
            && !(conf->flags & IEEE80211_CONF_CHANNEL_SWITCH)
 #endif
        )
                priv->staging_rxon.flags = 0;
-#endif /* CONFIG_IWL4965_HT */
 
-       iwl_set_rxon_channel(priv, conf->channel->band,
-               ieee80211_frequency_to_channel(conf->channel->center_freq));
+       iwl_set_rxon_channel(priv, conf->channel->band, channel);
 
-       iwl4965_set_flags_for_phymode(priv, conf->channel->band);
+       iwl_set_flags_for_band(priv, conf->channel->band);
 
        /* The list of supported rates and rate mask can be different
         * for each band; since the band may have changed, reset
@@ -4922,11 +4472,9 @@ static void iwl4965_mac_reset_tsf(struct ieee80211_hw *hw)
        IWL_DEBUG_MAC80211("enter\n");
 
        priv->lq_mngr.lq_ready = 0;
-#ifdef CONFIG_IWL4965_HT
        spin_lock_irqsave(&priv->lock, flags);
        memset(&priv->current_ht_config, 0, sizeof(struct iwl_ht_info));
        spin_unlock_irqrestore(&priv->lock, flags);
-#endif /* CONFIG_IWL4965_HT */
 
        iwl_reset_qos(priv);
 
@@ -5533,9 +5081,7 @@ static struct ieee80211_ops iwl4965_hw_ops = {
        .reset_tsf = iwl4965_mac_reset_tsf,
        .beacon_update = iwl4965_mac_beacon_update,
        .bss_info_changed = iwl4965_bss_info_changed,
-#ifdef CONFIG_IWL4965_HT
        .ampdu_action = iwl4965_mac_ampdu_action,
-#endif  /* CONFIG_IWL4965_HT */
        .hw_scan = iwl4965_mac_hw_scan
 };
 
@@ -5755,6 +5301,9 @@ static void __devexit iwl4965_pci_remove(struct pci_dev *pdev)
 
        IWL_DEBUG_INFO("*** UNLOAD DRIVER ***\n");
 
+       iwl_dbgfs_unregister(priv);
+       sysfs_remove_group(&pdev->dev.kobj, &iwl4965_attribute_group);
+
        if (priv->mac80211_registered) {
                ieee80211_unregister_hw(priv->hw);
                priv->mac80211_registered = 0;
@@ -5782,8 +5331,6 @@ static void __devexit iwl4965_pci_remove(struct pci_dev *pdev)
        }
 
        iwlcore_low_level_notify(priv, IWLCORE_REMOVE_EVT);
-       iwl_dbgfs_unregister(priv);
-       sysfs_remove_group(&pdev->dev.kobj, &iwl4965_attribute_group);
 
        iwl4965_dealloc_ucode_pci(priv);