net: convert print_mac to %pM
[safe/jmp/linux-2.6] / drivers / net / wireless / rt2x00 / rt2500pci.c
index ff2d632..8b772ab 100644 (file)
@@ -1,5 +1,5 @@
 /*
-       Copyright (C) 2004 - 2007 rt2x00 SourceForge Project
+       Copyright (C) 2004 - 2008 rt2x00 SourceForge Project
        <http://rt2x00.serialmonkey.com>
 
        This program is free software; you can redistribute it and/or modify
        Supported chipsets: RT2560.
  */
 
-/*
- * Set enviroment defines for rt2x00.h
- */
-#define DRV_NAME "rt2500pci"
-
 #include <linux/delay.h>
 #include <linux/etherdevice.h>
 #include <linux/init.h>
@@ -54,7 +49,7 @@
  * the access attempt is considered to have failed,
  * and we will print an error.
  */
-static u32 rt2500pci_bbp_check(const struct rt2x00_dev *rt2x00dev)
+static u32 rt2500pci_bbp_check(struct rt2x00_dev *rt2x00dev)
 {
        u32 reg;
        unsigned int i;
@@ -69,7 +64,7 @@ static u32 rt2500pci_bbp_check(const struct rt2x00_dev *rt2x00dev)
        return reg;
 }
 
-static void rt2500pci_bbp_write(const struct rt2x00_dev *rt2x00dev,
+static void rt2500pci_bbp_write(struct rt2x00_dev *rt2x00dev,
                                const unsigned int word, const u8 value)
 {
        u32 reg;
@@ -95,7 +90,7 @@ static void rt2500pci_bbp_write(const struct rt2x00_dev *rt2x00dev,
        rt2x00pci_register_write(rt2x00dev, BBPCSR, reg);
 }
 
-static void rt2500pci_bbp_read(const struct rt2x00_dev *rt2x00dev,
+static void rt2500pci_bbp_read(struct rt2x00_dev *rt2x00dev,
                               const unsigned int word, u8 *value)
 {
        u32 reg;
@@ -132,7 +127,7 @@ static void rt2500pci_bbp_read(const struct rt2x00_dev *rt2x00dev,
        *value = rt2x00_get_field32(reg, BBPCSR_VALUE);
 }
 
-static void rt2500pci_rf_write(const struct rt2x00_dev *rt2x00dev,
+static void rt2500pci_rf_write(struct rt2x00_dev *rt2x00dev,
                               const unsigned int word, const u32 value)
 {
        u32 reg;
@@ -195,13 +190,13 @@ static void rt2500pci_eepromregister_write(struct eeprom_93cx6 *eeprom)
 #ifdef CONFIG_RT2X00_LIB_DEBUGFS
 #define CSR_OFFSET(__word)     ( CSR_REG_BASE + ((__word) * sizeof(u32)) )
 
-static void rt2500pci_read_csr(const struct rt2x00_dev *rt2x00dev,
+static void rt2500pci_read_csr(struct rt2x00_dev *rt2x00dev,
                               const unsigned int word, u32 *data)
 {
        rt2x00pci_register_read(rt2x00dev, CSR_OFFSET(word), data);
 }
 
-static void rt2500pci_write_csr(const struct rt2x00_dev *rt2x00dev,
+static void rt2500pci_write_csr(struct rt2x00_dev *rt2x00dev,
                                const unsigned int word, u32 data)
 {
        rt2x00pci_register_write(rt2x00dev, CSR_OFFSET(word), data);
@@ -236,7 +231,7 @@ static const struct rt2x00debug rt2500pci_rt2x00debug = {
 };
 #endif /* CONFIG_RT2X00_LIB_DEBUGFS */
 
-#ifdef CONFIG_RT2500PCI_RFKILL
+#ifdef CONFIG_RT2X00_LIB_RFKILL
 static int rt2500pci_rfkill_poll(struct rt2x00_dev *rt2x00dev)
 {
        u32 reg;
@@ -246,59 +241,128 @@ static int rt2500pci_rfkill_poll(struct rt2x00_dev *rt2x00dev)
 }
 #else
 #define rt2500pci_rfkill_poll  NULL
-#endif /* CONFIG_RT2500PCI_RFKILL */
+#endif /* CONFIG_RT2X00_LIB_RFKILL */
 
-/*
- * Configuration handlers.
- */
-static void rt2500pci_config_mac_addr(struct rt2x00_dev *rt2x00dev,
-                                     __le32 *mac)
+#ifdef CONFIG_RT2X00_LIB_LEDS
+static void rt2500pci_brightness_set(struct led_classdev *led_cdev,
+                                    enum led_brightness brightness)
+{
+       struct rt2x00_led *led =
+           container_of(led_cdev, struct rt2x00_led, led_dev);
+       unsigned int enabled = brightness != LED_OFF;
+       u32 reg;
+
+       rt2x00pci_register_read(led->rt2x00dev, LEDCSR, &reg);
+
+       if (led->type == LED_TYPE_RADIO || led->type == LED_TYPE_ASSOC)
+               rt2x00_set_field32(&reg, LEDCSR_LINK, enabled);
+       else if (led->type == LED_TYPE_ACTIVITY)
+               rt2x00_set_field32(&reg, LEDCSR_ACTIVITY, enabled);
+
+       rt2x00pci_register_write(led->rt2x00dev, LEDCSR, reg);
+}
+
+static int rt2500pci_blink_set(struct led_classdev *led_cdev,
+                              unsigned long *delay_on,
+                              unsigned long *delay_off)
 {
-       rt2x00pci_register_multiwrite(rt2x00dev, CSR3, mac,
-                                     (2 * sizeof(__le32)));
+       struct rt2x00_led *led =
+           container_of(led_cdev, struct rt2x00_led, led_dev);
+       u32 reg;
+
+       rt2x00pci_register_read(led->rt2x00dev, LEDCSR, &reg);
+       rt2x00_set_field32(&reg, LEDCSR_ON_PERIOD, *delay_on);
+       rt2x00_set_field32(&reg, LEDCSR_OFF_PERIOD, *delay_off);
+       rt2x00pci_register_write(led->rt2x00dev, LEDCSR, reg);
+
+       return 0;
 }
 
-static void rt2500pci_config_bssid(struct rt2x00_dev *rt2x00dev,
-                                  __le32 *bssid)
+static void rt2500pci_init_led(struct rt2x00_dev *rt2x00dev,
+                              struct rt2x00_led *led,
+                              enum led_type type)
 {
-       rt2x00pci_register_multiwrite(rt2x00dev, CSR5, bssid,
-                                     (2 * sizeof(__le32)));
+       led->rt2x00dev = rt2x00dev;
+       led->type = type;
+       led->led_dev.brightness_set = rt2500pci_brightness_set;
+       led->led_dev.blink_set = rt2500pci_blink_set;
+       led->flags = LED_INITIALIZED;
 }
+#endif /* CONFIG_RT2X00_LIB_LEDS */
 
-static void rt2500pci_config_type(struct rt2x00_dev *rt2x00dev, const int type,
-                                 const int tsf_sync)
+/*
+ * Configuration handlers.
+ */
+static void rt2500pci_config_filter(struct rt2x00_dev *rt2x00dev,
+                                   const unsigned int filter_flags)
 {
        u32 reg;
 
-       rt2x00pci_register_write(rt2x00dev, CSR14, 0);
-
        /*
-        * Enable beacon config
+        * Start configuration steps.
+        * Note that the version error will always be dropped
+        * and broadcast frames will always be accepted since
+        * there is no filter for it at this time.
         */
-       rt2x00pci_register_read(rt2x00dev, BCNCSR1, &reg);
-       rt2x00_set_field32(&reg, BCNCSR1_PRELOAD,
-                          PREAMBLE + get_duration(IEEE80211_HEADER, 20));
-       rt2x00_set_field32(&reg, BCNCSR1_BEACON_CWMIN,
-                          rt2x00lib_get_ring(rt2x00dev,
-                                             IEEE80211_TX_QUEUE_BEACON)
-                          ->tx_params.cw_min);
-       rt2x00pci_register_write(rt2x00dev, BCNCSR1, reg);
+       rt2x00pci_register_read(rt2x00dev, RXCSR0, &reg);
+       rt2x00_set_field32(&reg, RXCSR0_DROP_CRC,
+                          !(filter_flags & FIF_FCSFAIL));
+       rt2x00_set_field32(&reg, RXCSR0_DROP_PHYSICAL,
+                          !(filter_flags & FIF_PLCPFAIL));
+       rt2x00_set_field32(&reg, RXCSR0_DROP_CONTROL,
+                          !(filter_flags & FIF_CONTROL));
+       rt2x00_set_field32(&reg, RXCSR0_DROP_NOT_TO_ME,
+                          !(filter_flags & FIF_PROMISC_IN_BSS));
+       rt2x00_set_field32(&reg, RXCSR0_DROP_TODS,
+                          !(filter_flags & FIF_PROMISC_IN_BSS) &&
+                          !rt2x00dev->intf_ap_count);
+       rt2x00_set_field32(&reg, RXCSR0_DROP_VERSION_ERROR, 1);
+       rt2x00_set_field32(&reg, RXCSR0_DROP_MCAST,
+                          !(filter_flags & FIF_ALLMULTI));
+       rt2x00_set_field32(&reg, RXCSR0_DROP_BCAST, 0);
+       rt2x00pci_register_write(rt2x00dev, RXCSR0, reg);
+}
 
-       /*
-        * Enable synchronisation.
-        */
-       rt2x00pci_register_read(rt2x00dev, CSR14, &reg);
-       rt2x00_set_field32(&reg, CSR14_TSF_COUNT, 1);
-       rt2x00_set_field32(&reg, CSR14_TBCN, 1);
-       rt2x00_set_field32(&reg, CSR14_BEACON_GEN, 0);
-       rt2x00_set_field32(&reg, CSR14_TSF_SYNC, tsf_sync);
-       rt2x00pci_register_write(rt2x00dev, CSR14, reg);
+static void rt2500pci_config_intf(struct rt2x00_dev *rt2x00dev,
+                                 struct rt2x00_intf *intf,
+                                 struct rt2x00intf_conf *conf,
+                                 const unsigned int flags)
+{
+       struct data_queue *queue = rt2x00queue_get_queue(rt2x00dev, QID_BEACON);
+       unsigned int bcn_preload;
+       u32 reg;
+
+       if (flags & CONFIG_UPDATE_TYPE) {
+               /*
+                * Enable beacon config
+                */
+               bcn_preload = PREAMBLE + get_duration(IEEE80211_HEADER, 20);
+               rt2x00pci_register_read(rt2x00dev, BCNCSR1, &reg);
+               rt2x00_set_field32(&reg, BCNCSR1_PRELOAD, bcn_preload);
+               rt2x00_set_field32(&reg, BCNCSR1_BEACON_CWMIN, queue->cw_min);
+               rt2x00pci_register_write(rt2x00dev, BCNCSR1, reg);
+
+               /*
+                * Enable synchronisation.
+                */
+               rt2x00pci_register_read(rt2x00dev, CSR14, &reg);
+               rt2x00_set_field32(&reg, CSR14_TSF_COUNT, 1);
+               rt2x00_set_field32(&reg, CSR14_TSF_SYNC, conf->sync);
+               rt2x00_set_field32(&reg, CSR14_TBCN, 1);
+               rt2x00pci_register_write(rt2x00dev, CSR14, reg);
+       }
+
+       if (flags & CONFIG_UPDATE_MAC)
+               rt2x00pci_register_multiwrite(rt2x00dev, CSR3,
+                                             conf->mac, sizeof(conf->mac));
+
+       if (flags & CONFIG_UPDATE_BSSID)
+               rt2x00pci_register_multiwrite(rt2x00dev, CSR5,
+                                             conf->bssid, sizeof(conf->bssid));
 }
 
-static void rt2500pci_config_preamble(struct rt2x00_dev *rt2x00dev,
-                                     const int short_preamble,
-                                     const int ack_timeout,
-                                     const int ack_consume_time)
+static void rt2500pci_config_erp(struct rt2x00_dev *rt2x00dev,
+                                struct rt2x00lib_erp *erp)
 {
        int preamble_mask;
        u32 reg;
@@ -306,15 +370,17 @@ static void rt2500pci_config_preamble(struct rt2x00_dev *rt2x00dev,
        /*
         * When short preamble is enabled, we should set bit 0x08
         */
-       preamble_mask = short_preamble << 3;
+       preamble_mask = erp->short_preamble << 3;
 
        rt2x00pci_register_read(rt2x00dev, TXCSR1, &reg);
-       rt2x00_set_field32(&reg, TXCSR1_ACK_TIMEOUT, ack_timeout);
-       rt2x00_set_field32(&reg, TXCSR1_ACK_CONSUME_TIME, ack_consume_time);
+       rt2x00_set_field32(&reg, TXCSR1_ACK_TIMEOUT,
+                          erp->ack_timeout);
+       rt2x00_set_field32(&reg, TXCSR1_ACK_CONSUME_TIME,
+                          erp->ack_consume_time);
        rt2x00pci_register_write(rt2x00dev, TXCSR1, reg);
 
        rt2x00pci_register_read(rt2x00dev, ARCSR2, &reg);
-       rt2x00_set_field32(&reg, ARCSR2_SIGNAL, 0x00 | preamble_mask);
+       rt2x00_set_field32(&reg, ARCSR2_SIGNAL, 0x00);
        rt2x00_set_field32(&reg, ARCSR2_SERVICE, 0x04);
        rt2x00_set_field32(&reg, ARCSR2_LENGTH, get_duration(ACK_SIZE, 10));
        rt2x00pci_register_write(rt2x00dev, ARCSR2, reg);
@@ -424,12 +490,19 @@ static void rt2500pci_config_txpower(struct rt2x00_dev *rt2x00dev,
 }
 
 static void rt2500pci_config_antenna(struct rt2x00_dev *rt2x00dev,
-                                    const int antenna_tx, const int antenna_rx)
+                                    struct antenna_setup *ant)
 {
        u32 reg;
        u8 r14;
        u8 r2;
 
+       /*
+        * We should never come here because rt2x00lib is supposed
+        * to catch this and send us the correct antenna explicitely.
+        */
+       BUG_ON(ant->rx == ANTENNA_SW_DIVERSITY ||
+              ant->tx == ANTENNA_SW_DIVERSITY);
+
        rt2x00pci_register_read(rt2x00dev, BBPCSR1, &reg);
        rt2500pci_bbp_read(rt2x00dev, 14, &r14);
        rt2500pci_bbp_read(rt2x00dev, 2, &r2);
@@ -437,19 +510,14 @@ static void rt2500pci_config_antenna(struct rt2x00_dev *rt2x00dev,
        /*
         * Configure the TX antenna.
         */
-       switch (antenna_tx) {
-       case ANTENNA_SW_DIVERSITY:
-       case ANTENNA_HW_DIVERSITY:
-               rt2x00_set_field8(&r2, BBP_R2_TX_ANTENNA, 2);
-               rt2x00_set_field32(&reg, BBPCSR1_CCK, 2);
-               rt2x00_set_field32(&reg, BBPCSR1_OFDM, 2);
-               break;
+       switch (ant->tx) {
        case ANTENNA_A:
                rt2x00_set_field8(&r2, BBP_R2_TX_ANTENNA, 0);
                rt2x00_set_field32(&reg, BBPCSR1_CCK, 0);
                rt2x00_set_field32(&reg, BBPCSR1_OFDM, 0);
                break;
        case ANTENNA_B:
+       default:
                rt2x00_set_field8(&r2, BBP_R2_TX_ANTENNA, 2);
                rt2x00_set_field32(&reg, BBPCSR1_CCK, 2);
                rt2x00_set_field32(&reg, BBPCSR1_OFDM, 2);
@@ -459,15 +527,12 @@ static void rt2500pci_config_antenna(struct rt2x00_dev *rt2x00dev,
        /*
         * Configure the RX antenna.
         */
-       switch (antenna_rx) {
-       case ANTENNA_SW_DIVERSITY:
-       case ANTENNA_HW_DIVERSITY:
-               rt2x00_set_field8(&r14, BBP_R14_RX_ANTENNA, 2);
-               break;
+       switch (ant->rx) {
        case ANTENNA_A:
                rt2x00_set_field8(&r14, BBP_R14_RX_ANTENNA, 0);
                break;
        case ANTENNA_B:
+       default:
                rt2x00_set_field8(&r14, BBP_R14_RX_ANTENNA, 2);
                break;
        }
@@ -529,8 +594,8 @@ static void rt2500pci_config_duration(struct rt2x00_dev *rt2x00dev,
 }
 
 static void rt2500pci_config(struct rt2x00_dev *rt2x00dev,
-                            const unsigned int flags,
-                            struct rt2x00lib_conf *libconf)
+                            struct rt2x00lib_conf *libconf,
+                            const unsigned int flags)
 {
        if (flags & CONFIG_UPDATE_PHYMODE)
                rt2500pci_config_phymode(rt2x00dev, libconf->basic_rates);
@@ -541,53 +606,16 @@ static void rt2500pci_config(struct rt2x00_dev *rt2x00dev,
                rt2500pci_config_txpower(rt2x00dev,
                                         libconf->conf->power_level);
        if (flags & CONFIG_UPDATE_ANTENNA)
-               rt2500pci_config_antenna(rt2x00dev,
-                                        libconf->conf->antenna_sel_tx,
-                                        libconf->conf->antenna_sel_rx);
+               rt2500pci_config_antenna(rt2x00dev, &libconf->ant);
        if (flags & (CONFIG_UPDATE_SLOT_TIME | CONFIG_UPDATE_BEACON_INT))
                rt2500pci_config_duration(rt2x00dev, libconf);
 }
 
 /*
- * LED functions.
- */
-static void rt2500pci_enable_led(struct rt2x00_dev *rt2x00dev)
-{
-       u32 reg;
-
-       rt2x00pci_register_read(rt2x00dev, LEDCSR, &reg);
-
-       rt2x00_set_field32(&reg, LEDCSR_ON_PERIOD, 70);
-       rt2x00_set_field32(&reg, LEDCSR_OFF_PERIOD, 30);
-
-       if (rt2x00dev->led_mode == LED_MODE_TXRX_ACTIVITY) {
-               rt2x00_set_field32(&reg, LEDCSR_LINK, 1);
-               rt2x00_set_field32(&reg, LEDCSR_ACTIVITY, 0);
-       } else if (rt2x00dev->led_mode == LED_MODE_ASUS) {
-               rt2x00_set_field32(&reg, LEDCSR_LINK, 0);
-               rt2x00_set_field32(&reg, LEDCSR_ACTIVITY, 1);
-       } else {
-               rt2x00_set_field32(&reg, LEDCSR_LINK, 1);
-               rt2x00_set_field32(&reg, LEDCSR_ACTIVITY, 1);
-       }
-
-       rt2x00pci_register_write(rt2x00dev, LEDCSR, reg);
-}
-
-static void rt2500pci_disable_led(struct rt2x00_dev *rt2x00dev)
-{
-       u32 reg;
-
-       rt2x00pci_register_read(rt2x00dev, LEDCSR, &reg);
-       rt2x00_set_field32(&reg, LEDCSR_LINK, 0);
-       rt2x00_set_field32(&reg, LEDCSR_ACTIVITY, 0);
-       rt2x00pci_register_write(rt2x00dev, LEDCSR, reg);
-}
-
-/*
  * Link tuning
  */
-static void rt2500pci_link_stats(struct rt2x00_dev *rt2x00dev)
+static void rt2500pci_link_stats(struct rt2x00_dev *rt2x00dev,
+                                struct link_qual *qual)
 {
        u32 reg;
 
@@ -595,13 +623,13 @@ static void rt2500pci_link_stats(struct rt2x00_dev *rt2x00dev)
         * Update FCS error count from register.
         */
        rt2x00pci_register_read(rt2x00dev, CNT0, &reg);
-       rt2x00dev->link.rx_failed = rt2x00_get_field32(reg, CNT0_FCS_ERROR);
+       qual->rx_failed = rt2x00_get_field32(reg, CNT0_FCS_ERROR);
 
        /*
         * Update False CCA count from register.
         */
        rt2x00pci_register_read(rt2x00dev, CNT3, &reg);
-       rt2x00dev->link.false_cca = rt2x00_get_field32(reg, CNT3_FALSE_CCA);
+       qual->false_cca = rt2x00_get_field32(reg, CNT3_FALSE_CCA);
 }
 
 static void rt2500pci_reset_tuner(struct rt2x00_dev *rt2x00dev)
@@ -618,9 +646,10 @@ static void rt2500pci_link_tuner(struct rt2x00_dev *rt2x00dev)
        /*
         * To prevent collisions with MAC ASIC on chipsets
         * up to version C the link tuning should halt after 20
-        * seconds.
+        * seconds while being associated.
         */
-       if (rt2x00_get_rev(&rt2x00dev->chip) < RT2560_VERSION_D &&
+       if (rt2x00_rev(&rt2x00dev->chip) < RT2560_VERSION_D &&
+           rt2x00dev->intf_associated &&
            rt2x00dev->link.count > 20)
                return;
 
@@ -628,9 +657,12 @@ static void rt2500pci_link_tuner(struct rt2x00_dev *rt2x00dev)
 
        /*
         * Chipset versions C and lower should directly continue
-        * to the dynamic CCA tuning.
+        * to the dynamic CCA tuning. Chipset version D and higher
+        * should go straight to dynamic CCA tuning when they
+        * are not associated.
         */
-       if (rt2x00_get_rev(&rt2x00dev->chip) < RT2560_VERSION_D)
+       if (rt2x00_rev(&rt2x00dev->chip) < RT2560_VERSION_D ||
+           !rt2x00dev->intf_associated)
                goto dynamic_cca_tune;
 
        /*
@@ -679,10 +711,10 @@ dynamic_cca_tune:
         * R17 is inside the dynamic tuning range,
         * start tuning the link based on the false cca counter.
         */
-       if (rt2x00dev->link.false_cca > 512 && r17 < 0x40) {
+       if (rt2x00dev->link.qual.false_cca > 512 && r17 < 0x40) {
                rt2500pci_bbp_write(rt2x00dev, 17, ++r17);
                rt2x00dev->link.vgc_level = r17;
-       } else if (rt2x00dev->link.false_cca < 100 && r17 > 0x32) {
+       } else if (rt2x00dev->link.qual.false_cca < 100 && r17 > 0x32) {
                rt2500pci_bbp_write(rt2x00dev, 17, --r17);
                rt2x00dev->link.vgc_level = r17;
        }
@@ -691,112 +723,82 @@ dynamic_cca_tune:
 /*
  * Initialization functions.
  */
-static void rt2500pci_init_rxring(struct rt2x00_dev *rt2x00dev)
+static void rt2500pci_init_rxentry(struct rt2x00_dev *rt2x00dev,
+                                  struct queue_entry *entry)
 {
-       struct data_ring *ring = rt2x00dev->rx;
-       struct data_desc *rxd;
-       unsigned int i;
+       struct queue_entry_priv_pci *entry_priv = entry->priv_data;
+       struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
        u32 word;
 
-       memset(ring->data_addr, 0x00, rt2x00_get_ring_size(ring));
-
-       for (i = 0; i < ring->stats.limit; i++) {
-               rxd = ring->entry[i].priv;
+       rt2x00_desc_read(entry_priv->desc, 1, &word);
+       rt2x00_set_field32(&word, RXD_W1_BUFFER_ADDRESS, skbdesc->skb_dma);
+       rt2x00_desc_write(entry_priv->desc, 1, word);
 
-               rt2x00_desc_read(rxd, 1, &word);
-               rt2x00_set_field32(&word, RXD_W1_BUFFER_ADDRESS,
-                                  ring->entry[i].data_dma);
-               rt2x00_desc_write(rxd, 1, word);
-
-               rt2x00_desc_read(rxd, 0, &word);
-               rt2x00_set_field32(&word, RXD_W0_OWNER_NIC, 1);
-               rt2x00_desc_write(rxd, 0, word);
-       }
-
-       rt2x00_ring_index_clear(rt2x00dev->rx);
+       rt2x00_desc_read(entry_priv->desc, 0, &word);
+       rt2x00_set_field32(&word, RXD_W0_OWNER_NIC, 1);
+       rt2x00_desc_write(entry_priv->desc, 0, word);
 }
 
-static void rt2500pci_init_txring(struct rt2x00_dev *rt2x00dev, const int queue)
+static void rt2500pci_init_txentry(struct rt2x00_dev *rt2x00dev,
+                                  struct queue_entry *entry)
 {
-       struct data_ring *ring = rt2x00lib_get_ring(rt2x00dev, queue);
-       struct data_desc *txd;
-       unsigned int i;
+       struct queue_entry_priv_pci *entry_priv = entry->priv_data;
        u32 word;
 
-       memset(ring->data_addr, 0x00, rt2x00_get_ring_size(ring));
-
-       for (i = 0; i < ring->stats.limit; i++) {
-               txd = ring->entry[i].priv;
-
-               rt2x00_desc_read(txd, 1, &word);
-               rt2x00_set_field32(&word, TXD_W1_BUFFER_ADDRESS,
-                                  ring->entry[i].data_dma);
-               rt2x00_desc_write(txd, 1, word);
-
-               rt2x00_desc_read(txd, 0, &word);
-               rt2x00_set_field32(&word, TXD_W0_VALID, 0);
-               rt2x00_set_field32(&word, TXD_W0_OWNER_NIC, 0);
-               rt2x00_desc_write(txd, 0, word);
-       }
-
-       rt2x00_ring_index_clear(ring);
+       rt2x00_desc_read(entry_priv->desc, 0, &word);
+       rt2x00_set_field32(&word, TXD_W0_VALID, 0);
+       rt2x00_set_field32(&word, TXD_W0_OWNER_NIC, 0);
+       rt2x00_desc_write(entry_priv->desc, 0, word);
 }
 
-static int rt2500pci_init_rings(struct rt2x00_dev *rt2x00dev)
+static int rt2500pci_init_queues(struct rt2x00_dev *rt2x00dev)
 {
+       struct queue_entry_priv_pci *entry_priv;
        u32 reg;
 
        /*
-        * Initialize rings.
-        */
-       rt2500pci_init_rxring(rt2x00dev);
-       rt2500pci_init_txring(rt2x00dev, IEEE80211_TX_QUEUE_DATA0);
-       rt2500pci_init_txring(rt2x00dev, IEEE80211_TX_QUEUE_DATA1);
-       rt2500pci_init_txring(rt2x00dev, IEEE80211_TX_QUEUE_AFTER_BEACON);
-       rt2500pci_init_txring(rt2x00dev, IEEE80211_TX_QUEUE_BEACON);
-
-       /*
         * Initialize registers.
         */
        rt2x00pci_register_read(rt2x00dev, TXCSR2, &reg);
-       rt2x00_set_field32(&reg, TXCSR2_TXD_SIZE,
-                          rt2x00dev->tx[IEEE80211_TX_QUEUE_DATA0].desc_size);
-       rt2x00_set_field32(&reg, TXCSR2_NUM_TXD,
-                          rt2x00dev->tx[IEEE80211_TX_QUEUE_DATA1].stats.limit);
-       rt2x00_set_field32(&reg, TXCSR2_NUM_ATIM,
-                          rt2x00dev->bcn[1].stats.limit);
-       rt2x00_set_field32(&reg, TXCSR2_NUM_PRIO,
-                          rt2x00dev->tx[IEEE80211_TX_QUEUE_DATA0].stats.limit);
+       rt2x00_set_field32(&reg, TXCSR2_TXD_SIZE, rt2x00dev->tx[0].desc_size);
+       rt2x00_set_field32(&reg, TXCSR2_NUM_TXD, rt2x00dev->tx[1].limit);
+       rt2x00_set_field32(&reg, TXCSR2_NUM_ATIM, rt2x00dev->bcn[1].limit);
+       rt2x00_set_field32(&reg, TXCSR2_NUM_PRIO, rt2x00dev->tx[0].limit);
        rt2x00pci_register_write(rt2x00dev, TXCSR2, reg);
 
+       entry_priv = rt2x00dev->tx[1].entries[0].priv_data;
        rt2x00pci_register_read(rt2x00dev, TXCSR3, &reg);
        rt2x00_set_field32(&reg, TXCSR3_TX_RING_REGISTER,
-                          rt2x00dev->tx[IEEE80211_TX_QUEUE_DATA1].data_dma);
+                          entry_priv->desc_dma);
        rt2x00pci_register_write(rt2x00dev, TXCSR3, reg);
 
+       entry_priv = rt2x00dev->tx[0].entries[0].priv_data;
        rt2x00pci_register_read(rt2x00dev, TXCSR5, &reg);
        rt2x00_set_field32(&reg, TXCSR5_PRIO_RING_REGISTER,
-                          rt2x00dev->tx[IEEE80211_TX_QUEUE_DATA0].data_dma);
+                          entry_priv->desc_dma);
        rt2x00pci_register_write(rt2x00dev, TXCSR5, reg);
 
+       entry_priv = rt2x00dev->bcn[1].entries[0].priv_data;
        rt2x00pci_register_read(rt2x00dev, TXCSR4, &reg);
        rt2x00_set_field32(&reg, TXCSR4_ATIM_RING_REGISTER,
-                          rt2x00dev->bcn[1].data_dma);
+                          entry_priv->desc_dma);
        rt2x00pci_register_write(rt2x00dev, TXCSR4, reg);
 
+       entry_priv = rt2x00dev->bcn[0].entries[0].priv_data;
        rt2x00pci_register_read(rt2x00dev, TXCSR6, &reg);
        rt2x00_set_field32(&reg, TXCSR6_BEACON_RING_REGISTER,
-                          rt2x00dev->bcn[0].data_dma);
+                          entry_priv->desc_dma);
        rt2x00pci_register_write(rt2x00dev, TXCSR6, reg);
 
        rt2x00pci_register_read(rt2x00dev, RXCSR1, &reg);
        rt2x00_set_field32(&reg, RXCSR1_RXD_SIZE, rt2x00dev->rx->desc_size);
-       rt2x00_set_field32(&reg, RXCSR1_NUM_RXD, rt2x00dev->rx->stats.limit);
+       rt2x00_set_field32(&reg, RXCSR1_NUM_RXD, rt2x00dev->rx->limit);
        rt2x00pci_register_write(rt2x00dev, RXCSR1, reg);
 
+       entry_priv = rt2x00dev->rx->entries[0].priv_data;
        rt2x00pci_register_read(rt2x00dev, RXCSR2, &reg);
        rt2x00_set_field32(&reg, RXCSR2_RX_RING_REGISTER,
-                          rt2x00dev->rx->data_dma);
+                          entry_priv->desc_dma);
        rt2x00pci_register_write(rt2x00dev, RXCSR2, reg);
 
        return 0;
@@ -829,6 +831,17 @@ static int rt2500pci_init_registers(struct rt2x00_dev *rt2x00dev)
        rt2x00_set_field32(&reg, CSR11_CW_SELECT, 0);
        rt2x00pci_register_write(rt2x00dev, CSR11, reg);
 
+       rt2x00pci_register_read(rt2x00dev, CSR14, &reg);
+       rt2x00_set_field32(&reg, CSR14_TSF_COUNT, 0);
+       rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 0);
+       rt2x00_set_field32(&reg, CSR14_TBCN, 0);
+       rt2x00_set_field32(&reg, CSR14_TCFP, 0);
+       rt2x00_set_field32(&reg, CSR14_TATIMW, 0);
+       rt2x00_set_field32(&reg, CSR14_BEACON_GEN, 0);
+       rt2x00_set_field32(&reg, CSR14_CFP_COUNT_PRELOAD, 0);
+       rt2x00_set_field32(&reg, CSR14_TBCM_PRELOAD, 0);
+       rt2x00pci_register_write(rt2x00dev, CSR14, reg);
+
        rt2x00pci_register_write(rt2x00dev, CNT3, 0);
 
        rt2x00pci_register_read(rt2x00dev, TXCSR8, &reg);
@@ -934,25 +947,32 @@ static int rt2500pci_init_registers(struct rt2x00_dev *rt2x00dev)
        return 0;
 }
 
-static int rt2500pci_init_bbp(struct rt2x00_dev *rt2x00dev)
+static int rt2500pci_wait_bbp_ready(struct rt2x00_dev *rt2x00dev)
 {
        unsigned int i;
-       u16 eeprom;
-       u8 reg_id;
        u8 value;
 
        for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
                rt2500pci_bbp_read(rt2x00dev, 0, &value);
                if ((value != 0xff) && (value != 0x00))
-                       goto continue_csr_init;
-               NOTICE(rt2x00dev, "Waiting for BBP register.\n");
+                       return 0;
                udelay(REGISTER_BUSY_DELAY);
        }
 
        ERROR(rt2x00dev, "BBP register access failed, aborting.\n");
        return -EACCES;
+}
+
+static int rt2500pci_init_bbp(struct rt2x00_dev *rt2x00dev)
+{
+       unsigned int i;
+       u16 eeprom;
+       u8 reg_id;
+       u8 value;
+
+       if (unlikely(rt2500pci_wait_bbp_ready(rt2x00dev)))
+               return -EACCES;
 
-continue_csr_init:
        rt2500pci_bbp_write(rt2x00dev, 3, 0x02);
        rt2500pci_bbp_write(rt2x00dev, 4, 0x19);
        rt2500pci_bbp_write(rt2x00dev, 14, 0x1c);
@@ -984,19 +1004,15 @@ continue_csr_init:
        rt2500pci_bbp_write(rt2x00dev, 61, 0x6d);
        rt2500pci_bbp_write(rt2x00dev, 62, 0x10);
 
-       DEBUG(rt2x00dev, "Start initialization from EEPROM...\n");
        for (i = 0; i < EEPROM_BBP_SIZE; i++) {
                rt2x00_eeprom_read(rt2x00dev, EEPROM_BBP_START + i, &eeprom);
 
                if (eeprom != 0xffff && eeprom != 0x0000) {
                        reg_id = rt2x00_get_field16(eeprom, EEPROM_BBP_REG_ID);
                        value = rt2x00_get_field16(eeprom, EEPROM_BBP_VALUE);
-                       DEBUG(rt2x00dev, "BBP: 0x%02x, value: 0x%02x.\n",
-                             reg_id, value);
                        rt2500pci_bbp_write(rt2x00dev, reg_id, value);
                }
        }
-       DEBUG(rt2x00dev, "...End initialization from EEPROM.\n");
 
        return 0;
 }
@@ -1011,7 +1027,8 @@ static void rt2500pci_toggle_rx(struct rt2x00_dev *rt2x00dev,
 
        rt2x00pci_register_read(rt2x00dev, RXCSR0, &reg);
        rt2x00_set_field32(&reg, RXCSR0_DISABLE_RX,
-                          state == STATE_RADIO_RX_OFF);
+                          (state == STATE_RADIO_RX_OFF) ||
+                          (state == STATE_RADIO_RX_OFF_LINK));
        rt2x00pci_register_write(rt2x00dev, RXCSR0, reg);
 }
 
@@ -1048,22 +1065,10 @@ static int rt2500pci_enable_radio(struct rt2x00_dev *rt2x00dev)
        /*
         * Initialize all registers.
         */
-       if (rt2500pci_init_rings(rt2x00dev) ||
-           rt2500pci_init_registers(rt2x00dev) ||
-           rt2500pci_init_bbp(rt2x00dev)) {
-               ERROR(rt2x00dev, "Register initialization failed.\n");
+       if (unlikely(rt2500pci_init_queues(rt2x00dev) ||
+                    rt2500pci_init_registers(rt2x00dev) ||
+                    rt2500pci_init_bbp(rt2x00dev)))
                return -EIO;
-       }
-
-       /*
-        * Enable interrupts.
-        */
-       rt2500pci_toggle_irq(rt2x00dev, STATE_RADIO_IRQ_ON);
-
-       /*
-        * Enable LED
-        */
-       rt2500pci_enable_led(rt2x00dev);
 
        return 0;
 }
@@ -1072,11 +1077,6 @@ static void rt2500pci_disable_radio(struct rt2x00_dev *rt2x00dev)
 {
        u32 reg;
 
-       /*
-        * Disable LED
-        */
-       rt2500pci_disable_led(rt2x00dev);
-
        rt2x00pci_register_write(rt2x00dev, PWRCSR0, 0);
 
        /*
@@ -1090,11 +1090,6 @@ static void rt2500pci_disable_radio(struct rt2x00_dev *rt2x00dev)
        rt2x00pci_register_read(rt2x00dev, TXCSR0, &reg);
        rt2x00_set_field32(&reg, TXCSR0_ABORT, 1);
        rt2x00pci_register_write(rt2x00dev, TXCSR0, reg);
-
-       /*
-        * Disable interrupts.
-        */
-       rt2500pci_toggle_irq(rt2x00dev, STATE_RADIO_IRQ_OFF);
 }
 
 static int rt2500pci_set_state(struct rt2x00_dev *rt2x00dev,
@@ -1129,10 +1124,6 @@ static int rt2500pci_set_state(struct rt2x00_dev *rt2x00dev,
                msleep(10);
        }
 
-       NOTICE(rt2x00dev, "Device failed to enter state %d, "
-              "current device state: bbp %d and rf %d.\n",
-              state, bbp_state, rf_state);
-
        return -EBUSY;
 }
 
@@ -1149,9 +1140,15 @@ static int rt2500pci_set_device_state(struct rt2x00_dev *rt2x00dev,
                rt2500pci_disable_radio(rt2x00dev);
                break;
        case STATE_RADIO_RX_ON:
+       case STATE_RADIO_RX_ON_LINK:
        case STATE_RADIO_RX_OFF:
+       case STATE_RADIO_RX_OFF_LINK:
                rt2500pci_toggle_rx(rt2x00dev, state);
                break;
+       case STATE_RADIO_IRQ_ON:
+       case STATE_RADIO_IRQ_OFF:
+               rt2500pci_toggle_irq(rt2x00dev, state);
+               break;
        case STATE_DEEP_SLEEP:
        case STATE_SLEEP:
        case STATE_STANDBY:
@@ -1163,6 +1160,10 @@ static int rt2500pci_set_device_state(struct rt2x00_dev *rt2x00dev,
                break;
        }
 
+       if (unlikely(retval))
+               ERROR(rt2x00dev, "Device failed to enter state %d (%d).\n",
+                     state, retval);
+
        return retval;
 }
 
@@ -1170,53 +1171,56 @@ static int rt2500pci_set_device_state(struct rt2x00_dev *rt2x00dev,
  * TX descriptor initialization
  */
 static void rt2500pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,
-                                   struct data_desc *txd,
-                                   struct txdata_entry_desc *desc,
-                                   struct ieee80211_hdr *ieee80211hdr,
-                                   unsigned int length,
-                                   struct ieee80211_tx_control *control)
+                                   struct sk_buff *skb,
+                                   struct txentry_desc *txdesc)
 {
+       struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb);
+       struct queue_entry_priv_pci *entry_priv = skbdesc->entry->priv_data;
+       __le32 *txd = skbdesc->desc;
        u32 word;
 
        /*
         * Start writing the descriptor words.
         */
+       rt2x00_desc_read(entry_priv->desc, 1, &word);
+       rt2x00_set_field32(&word, TXD_W1_BUFFER_ADDRESS, skbdesc->skb_dma);
+       rt2x00_desc_write(entry_priv->desc, 1, word);
+
        rt2x00_desc_read(txd, 2, &word);
        rt2x00_set_field32(&word, TXD_W2_IV_OFFSET, IEEE80211_HEADER);
-       rt2x00_set_field32(&word, TXD_W2_AIFS, desc->aifs);
-       rt2x00_set_field32(&word, TXD_W2_CWMIN, desc->cw_min);
-       rt2x00_set_field32(&word, TXD_W2_CWMAX, desc->cw_max);
+       rt2x00_set_field32(&word, TXD_W2_AIFS, txdesc->aifs);
+       rt2x00_set_field32(&word, TXD_W2_CWMIN, txdesc->cw_min);
+       rt2x00_set_field32(&word, TXD_W2_CWMAX, txdesc->cw_max);
        rt2x00_desc_write(txd, 2, word);
 
        rt2x00_desc_read(txd, 3, &word);
-       rt2x00_set_field32(&word, TXD_W3_PLCP_SIGNAL, desc->signal);
-       rt2x00_set_field32(&word, TXD_W3_PLCP_SERVICE, desc->service);
-       rt2x00_set_field32(&word, TXD_W3_PLCP_LENGTH_LOW, desc->length_low);
-       rt2x00_set_field32(&word, TXD_W3_PLCP_LENGTH_HIGH, desc->length_high);
+       rt2x00_set_field32(&word, TXD_W3_PLCP_SIGNAL, txdesc->signal);
+       rt2x00_set_field32(&word, TXD_W3_PLCP_SERVICE, txdesc->service);
+       rt2x00_set_field32(&word, TXD_W3_PLCP_LENGTH_LOW, txdesc->length_low);
+       rt2x00_set_field32(&word, TXD_W3_PLCP_LENGTH_HIGH, txdesc->length_high);
        rt2x00_desc_write(txd, 3, word);
 
        rt2x00_desc_read(txd, 10, &word);
        rt2x00_set_field32(&word, TXD_W10_RTS,
-                          test_bit(ENTRY_TXD_RTS_FRAME, &desc->flags));
+                          test_bit(ENTRY_TXD_RTS_FRAME, &txdesc->flags));
        rt2x00_desc_write(txd, 10, word);
 
        rt2x00_desc_read(txd, 0, &word);
        rt2x00_set_field32(&word, TXD_W0_OWNER_NIC, 1);
        rt2x00_set_field32(&word, TXD_W0_VALID, 1);
        rt2x00_set_field32(&word, TXD_W0_MORE_FRAG,
-                          test_bit(ENTRY_TXD_MORE_FRAG, &desc->flags));
+                          test_bit(ENTRY_TXD_MORE_FRAG, &txdesc->flags));
        rt2x00_set_field32(&word, TXD_W0_ACK,
-                          !(control->flags & IEEE80211_TXCTL_NO_ACK));
+                          test_bit(ENTRY_TXD_ACK, &txdesc->flags));
        rt2x00_set_field32(&word, TXD_W0_TIMESTAMP,
-                          test_bit(ENTRY_TXD_REQ_TIMESTAMP, &desc->flags));
+                          test_bit(ENTRY_TXD_REQ_TIMESTAMP, &txdesc->flags));
        rt2x00_set_field32(&word, TXD_W0_OFDM,
-                          test_bit(ENTRY_TXD_OFDM_RATE, &desc->flags));
+                          test_bit(ENTRY_TXD_OFDM_RATE, &txdesc->flags));
        rt2x00_set_field32(&word, TXD_W0_CIPHER_OWNER, 1);
-       rt2x00_set_field32(&word, TXD_W0_IFS, desc->ifs);
+       rt2x00_set_field32(&word, TXD_W0_IFS, txdesc->ifs);
        rt2x00_set_field32(&word, TXD_W0_RETRY_MODE,
-                          !!(control->flags &
-                             IEEE80211_TXCTL_LONG_RETRY_LIMIT));
-       rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, length);
+                          test_bit(ENTRY_TXD_RETRY_MODE, &txdesc->flags));
+       rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, skb->len);
        rt2x00_set_field32(&word, TXD_W0_CIPHER_ALG, CIPHER_NONE);
        rt2x00_desc_write(txd, 0, word);
 }
@@ -1224,14 +1228,50 @@ static void rt2500pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,
 /*
  * TX data initialization
  */
+static void rt2500pci_write_beacon(struct queue_entry *entry)
+{
+       struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
+       struct queue_entry_priv_pci *entry_priv = entry->priv_data;
+       struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
+       u32 word;
+       u32 reg;
+
+       /*
+        * Disable beaconing while we are reloading the beacon data,
+        * otherwise we might be sending out invalid data.
+        */
+       rt2x00pci_register_read(rt2x00dev, CSR14, &reg);
+       rt2x00_set_field32(&reg, CSR14_TSF_COUNT, 0);
+       rt2x00_set_field32(&reg, CSR14_TBCN, 0);
+       rt2x00_set_field32(&reg, CSR14_BEACON_GEN, 0);
+       rt2x00pci_register_write(rt2x00dev, CSR14, reg);
+
+       /*
+        * Replace rt2x00lib allocated descriptor with the
+        * pointer to the _real_ hardware descriptor.
+        * After that, map the beacon to DMA and update the
+        * descriptor.
+        */
+       memcpy(entry_priv->desc, skbdesc->desc, skbdesc->desc_len);
+       skbdesc->desc = entry_priv->desc;
+
+       rt2x00queue_map_txskb(rt2x00dev, entry->skb);
+
+       rt2x00_desc_read(entry_priv->desc, 1, &word);
+       rt2x00_set_field32(&word, TXD_W1_BUFFER_ADDRESS, skbdesc->skb_dma);
+       rt2x00_desc_write(entry_priv->desc, 1, word);
+}
+
 static void rt2500pci_kick_tx_queue(struct rt2x00_dev *rt2x00dev,
-                                   unsigned int queue)
+                                   const enum data_queue_qid queue)
 {
        u32 reg;
 
-       if (queue == IEEE80211_TX_QUEUE_BEACON) {
+       if (queue == QID_BEACON) {
                rt2x00pci_register_read(rt2x00dev, CSR14, &reg);
                if (!rt2x00_get_field32(reg, CSR14_BEACON_GEN)) {
+                       rt2x00_set_field32(&reg, CSR14_TSF_COUNT, 1);
+                       rt2x00_set_field32(&reg, CSR14_TBCN, 1);
                        rt2x00_set_field32(&reg, CSR14_BEACON_GEN, 1);
                        rt2x00pci_register_write(rt2x00dev, CSR14, reg);
                }
@@ -1239,57 +1279,65 @@ static void rt2500pci_kick_tx_queue(struct rt2x00_dev *rt2x00dev,
        }
 
        rt2x00pci_register_read(rt2x00dev, TXCSR0, &reg);
-       if (queue == IEEE80211_TX_QUEUE_DATA0)
-               rt2x00_set_field32(&reg, TXCSR0_KICK_PRIO, 1);
-       else if (queue == IEEE80211_TX_QUEUE_DATA1)
-               rt2x00_set_field32(&reg, TXCSR0_KICK_TX, 1);
-       else if (queue == IEEE80211_TX_QUEUE_AFTER_BEACON)
-               rt2x00_set_field32(&reg, TXCSR0_KICK_ATIM, 1);
+       rt2x00_set_field32(&reg, TXCSR0_KICK_PRIO, (queue == QID_AC_BE));
+       rt2x00_set_field32(&reg, TXCSR0_KICK_TX, (queue == QID_AC_BK));
+       rt2x00_set_field32(&reg, TXCSR0_KICK_ATIM, (queue == QID_ATIM));
        rt2x00pci_register_write(rt2x00dev, TXCSR0, reg);
 }
 
 /*
  * RX control handlers
  */
-static void rt2500pci_fill_rxdone(struct data_entry *entry,
-                                 struct rxdata_entry_desc *desc)
+static void rt2500pci_fill_rxdone(struct queue_entry *entry,
+                                 struct rxdone_entry_desc *rxdesc)
 {
-       struct data_desc *rxd = entry->priv;
+       struct queue_entry_priv_pci *entry_priv = entry->priv_data;
        u32 word0;
        u32 word2;
 
-       rt2x00_desc_read(rxd, 0, &word0);
-       rt2x00_desc_read(rxd, 2, &word2);
+       rt2x00_desc_read(entry_priv->desc, 0, &word0);
+       rt2x00_desc_read(entry_priv->desc, 2, &word2);
 
-       desc->flags = 0;
        if (rt2x00_get_field32(word0, RXD_W0_CRC_ERROR))
-               desc->flags |= RX_FLAG_FAILED_FCS_CRC;
+               rxdesc->flags |= RX_FLAG_FAILED_FCS_CRC;
        if (rt2x00_get_field32(word0, RXD_W0_PHYSICAL_ERROR))
-               desc->flags |= RX_FLAG_FAILED_PLCP_CRC;
+               rxdesc->flags |= RX_FLAG_FAILED_PLCP_CRC;
 
-       desc->signal = rt2x00_get_field32(word2, RXD_W2_SIGNAL);
-       desc->rssi = rt2x00_get_field32(word2, RXD_W2_RSSI) -
-           entry->ring->rt2x00dev->rssi_offset;
-       desc->ofdm = rt2x00_get_field32(word0, RXD_W0_OFDM);
-       desc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT);
+       /*
+        * Obtain the status about this packet.
+        * When frame was received with an OFDM bitrate,
+        * the signal is the PLCP value. If it was received with
+        * a CCK bitrate the signal is the rate in 100kbit/s.
+        */
+       rxdesc->signal = rt2x00_get_field32(word2, RXD_W2_SIGNAL);
+       rxdesc->rssi = rt2x00_get_field32(word2, RXD_W2_RSSI) -
+           entry->queue->rt2x00dev->rssi_offset;
+       rxdesc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT);
+
+       if (rt2x00_get_field32(word0, RXD_W0_OFDM))
+               rxdesc->dev_flags |= RXDONE_SIGNAL_PLCP;
+       else
+               rxdesc->dev_flags |= RXDONE_SIGNAL_BITRATE;
+       if (rt2x00_get_field32(word0, RXD_W0_MY_BSS))
+               rxdesc->dev_flags |= RXDONE_MY_BSS;
 }
 
 /*
  * Interrupt functions.
  */
-static void rt2500pci_txdone(struct rt2x00_dev *rt2x00dev, const int queue)
+static void rt2500pci_txdone(struct rt2x00_dev *rt2x00dev,
+                            const enum data_queue_qid queue_idx)
 {
-       struct data_ring *ring = rt2x00lib_get_ring(rt2x00dev, queue);
-       struct data_entry *entry;
-       struct data_desc *txd;
+       struct data_queue *queue = rt2x00queue_get_queue(rt2x00dev, queue_idx);
+       struct queue_entry_priv_pci *entry_priv;
+       struct queue_entry *entry;
+       struct txdone_entry_desc txdesc;
        u32 word;
-       int tx_status;
-       int retry;
 
-       while (!rt2x00_ring_empty(ring)) {
-               entry = rt2x00_get_data_entry_done(ring);
-               txd = entry->priv;
-               rt2x00_desc_read(txd, 0, &word);
+       while (!rt2x00queue_empty(queue)) {
+               entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE);
+               entry_priv = entry->priv_data;
+               rt2x00_desc_read(entry_priv->desc, 0, &word);
 
                if (rt2x00_get_field32(word, TXD_W0_OWNER_NIC) ||
                    !rt2x00_get_field32(word, TXD_W0_VALID))
@@ -1298,29 +1346,22 @@ static void rt2500pci_txdone(struct rt2x00_dev *rt2x00dev, const int queue)
                /*
                 * Obtain the status about this packet.
                 */
-               tx_status = rt2x00_get_field32(word, TXD_W0_RESULT);
-               retry = rt2x00_get_field32(word, TXD_W0_RETRY_COUNT);
-
-               rt2x00lib_txdone(entry, tx_status, retry);
+               txdesc.flags = 0;
+               switch (rt2x00_get_field32(word, TXD_W0_RESULT)) {
+               case 0: /* Success */
+               case 1: /* Success with retry */
+                       __set_bit(TXDONE_SUCCESS, &txdesc.flags);
+                       break;
+               case 2: /* Failure, excessive retries */
+                       __set_bit(TXDONE_EXCESSIVE_RETRY, &txdesc.flags);
+                       /* Don't break, this is a failed frame! */
+               default: /* Failure */
+                       __set_bit(TXDONE_FAILURE, &txdesc.flags);
+               }
+               txdesc.retry = rt2x00_get_field32(word, TXD_W0_RETRY_COUNT);
 
-               /*
-                * Make this entry available for reuse.
-                */
-               entry->flags = 0;
-               rt2x00_set_field32(&word, TXD_W0_VALID, 0);
-               rt2x00_desc_write(txd, 0, word);
-               rt2x00_ring_index_done_inc(ring);
+               rt2x00lib_txdone(entry, &txdesc);
        }
-
-       /*
-        * If the data ring was full before the txdone handler
-        * we must make sure the packet queue in the mac80211 stack
-        * is reenabled when the txdone handler has finished.
-        */
-       entry = ring->entry;
-       if (!rt2x00_ring_full(ring))
-               ieee80211_wake_queue(rt2x00dev->hw,
-                                    entry->tx_status.control.queue);
 }
 
 static irqreturn_t rt2500pci_interrupt(int irq, void *dev_instance)
@@ -1338,7 +1379,7 @@ static irqreturn_t rt2500pci_interrupt(int irq, void *dev_instance)
        if (!reg)
                return IRQ_NONE;
 
-       if (!test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags))
+       if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
                return IRQ_HANDLED;
 
        /*
@@ -1363,19 +1404,19 @@ static irqreturn_t rt2500pci_interrupt(int irq, void *dev_instance)
         * 3 - Atim ring transmit done interrupt.
         */
        if (rt2x00_get_field32(reg, CSR7_TXDONE_ATIMRING))
-               rt2500pci_txdone(rt2x00dev, IEEE80211_TX_QUEUE_AFTER_BEACON);
+               rt2500pci_txdone(rt2x00dev, QID_ATIM);
 
        /*
         * 4 - Priority ring transmit done interrupt.
         */
        if (rt2x00_get_field32(reg, CSR7_TXDONE_PRIORING))
-               rt2500pci_txdone(rt2x00dev, IEEE80211_TX_QUEUE_DATA0);
+               rt2500pci_txdone(rt2x00dev, QID_AC_BE);
 
        /*
         * 5 - Tx ring transmit done interrupt.
         */
        if (rt2x00_get_field32(reg, CSR7_TXDONE_TXRING))
-               rt2500pci_txdone(rt2x00dev, IEEE80211_TX_QUEUE_DATA1);
+               rt2500pci_txdone(rt2x00dev, QID_AC_BK);
 
        return IRQ_HANDLED;
 }
@@ -1410,19 +1451,19 @@ static int rt2500pci_validate_eeprom(struct rt2x00_dev *rt2x00dev)
         */
        mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0);
        if (!is_valid_ether_addr(mac)) {
-               DECLARE_MAC_BUF(macbuf);
-
                random_ether_addr(mac);
-               EEPROM(rt2x00dev, "MAC: %s\n",
-                      print_mac(macbuf, mac));
+               EEPROM(rt2x00dev, "MAC: %pM\n", mac);
        }
 
        rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &word);
        if (word == 0xffff) {
                rt2x00_set_field16(&word, EEPROM_ANTENNA_NUM, 2);
-               rt2x00_set_field16(&word, EEPROM_ANTENNA_TX_DEFAULT, 0);
-               rt2x00_set_field16(&word, EEPROM_ANTENNA_RX_DEFAULT, 0);
-               rt2x00_set_field16(&word, EEPROM_ANTENNA_LED_MODE, 0);
+               rt2x00_set_field16(&word, EEPROM_ANTENNA_TX_DEFAULT,
+                                  ANTENNA_SW_DIVERSITY);
+               rt2x00_set_field16(&word, EEPROM_ANTENNA_RX_DEFAULT,
+                                  ANTENNA_SW_DIVERSITY);
+               rt2x00_set_field16(&word, EEPROM_ANTENNA_LED_MODE,
+                                  LED_MODE_DEFAULT);
                rt2x00_set_field16(&word, EEPROM_ANTENNA_DYN_TXAGC, 0);
                rt2x00_set_field16(&word, EEPROM_ANTENNA_HARDWARE_RADIO, 0);
                rt2x00_set_field16(&word, EEPROM_ANTENNA_RF_TYPE, RF2522);
@@ -1481,24 +1522,30 @@ static int rt2500pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
        /*
         * Identify default antenna configuration.
         */
-       rt2x00dev->hw->conf.antenna_sel_tx =
+       rt2x00dev->default_ant.tx =
            rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TX_DEFAULT);
-       rt2x00dev->hw->conf.antenna_sel_rx =
+       rt2x00dev->default_ant.rx =
            rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RX_DEFAULT);
 
        /*
         * Store led mode, for correct led behaviour.
         */
-       rt2x00dev->led_mode =
-           rt2x00_get_field16(eeprom, EEPROM_ANTENNA_LED_MODE);
+#ifdef CONFIG_RT2X00_LIB_LEDS
+       value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_LED_MODE);
+
+       rt2500pci_init_led(rt2x00dev, &rt2x00dev->led_radio, LED_TYPE_RADIO);
+       if (value == LED_MODE_TXRX_ACTIVITY)
+               rt2500pci_init_led(rt2x00dev, &rt2x00dev->led_qual,
+                                  LED_TYPE_ACTIVITY);
+#endif /* CONFIG_RT2X00_LIB_LEDS */
 
        /*
         * Detect if this device has an hardware controlled radio.
         */
-#ifdef CONFIG_RT2500PCI_RFKILL
+#ifdef CONFIG_RT2X00_LIB_RFKILL
        if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_HARDWARE_RADIO))
                __set_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags);
-#endif /* CONFIG_RT2500PCI_RFKILL */
+#endif /* CONFIG_RT2X00_LIB_RFKILL */
 
        /*
         * Check if the BBP tuning should be enabled.
@@ -1673,41 +1720,31 @@ static const struct rf_channel rf_vals_5222[] = {
        { 161, 0x00022020, 0x000090be, 0x00000101, 0x00000a07 },
 };
 
-static void rt2500pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
+static int rt2500pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
 {
        struct hw_mode_spec *spec = &rt2x00dev->spec;
-       u8 *txpower;
+       struct channel_info *info;
+       char *tx_power;
        unsigned int i;
 
        /*
         * Initialize all hw fields.
         */
-       rt2x00dev->hw->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING;
+       rt2x00dev->hw->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
+                              IEEE80211_HW_SIGNAL_DBM;
+
        rt2x00dev->hw->extra_tx_headroom = 0;
-       rt2x00dev->hw->max_signal = MAX_SIGNAL;
-       rt2x00dev->hw->max_rssi = MAX_RX_SSI;
-       rt2x00dev->hw->queues = 2;
 
-       SET_IEEE80211_DEV(rt2x00dev->hw, &rt2x00dev_pci(rt2x00dev)->dev);
+       SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev);
        SET_IEEE80211_PERM_ADDR(rt2x00dev->hw,
                                rt2x00_eeprom_addr(rt2x00dev,
                                                   EEPROM_MAC_ADDR_0));
 
        /*
-        * Convert tx_power array in eeprom.
-        */
-       txpower = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_START);
-       for (i = 0; i < 14; i++)
-               txpower[i] = TXPOWER_FROM_DEV(txpower[i]);
-
-       /*
         * Initialize hw_mode information.
         */
-       spec->num_modes = 2;
-       spec->num_rates = 12;
-       spec->tx_power_a = NULL;
-       spec->tx_power_bg = txpower;
-       spec->tx_power_default = DEFAULT_TXPOWER;
+       spec->supported_bands = SUPPORT_BAND_2GHZ;
+       spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM;
 
        if (rt2x00_rf(&rt2x00dev->chip, RF2522)) {
                spec->num_channels = ARRAY_SIZE(rf_vals_bg_2522);
@@ -1725,10 +1762,30 @@ static void rt2500pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
                spec->num_channels = ARRAY_SIZE(rf_vals_bg_2525e);
                spec->channels = rf_vals_bg_2525e;
        } else if (rt2x00_rf(&rt2x00dev->chip, RF5222)) {
+               spec->supported_bands |= SUPPORT_BAND_5GHZ;
                spec->num_channels = ARRAY_SIZE(rf_vals_5222);
                spec->channels = rf_vals_5222;
-               spec->num_modes = 3;
        }
+
+       /*
+        * Create channel information array
+        */
+       info = kzalloc(spec->num_channels * sizeof(*info), GFP_KERNEL);
+       if (!info)
+               return -ENOMEM;
+
+       spec->channels_info = info;
+
+       tx_power = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_START);
+       for (i = 0; i < 14; i++)
+               info[i].tx_power1 = TXPOWER_FROM_DEV(tx_power[i]);
+
+       if (spec->num_channels > 14) {
+               for (i = 14; i < spec->num_channels; i++)
+                       info[i].tx_power1 = DEFAULT_TXPOWER;
+       }
+
+       return 0;
 }
 
 static int rt2500pci_probe_hw(struct rt2x00_dev *rt2x00dev)
@@ -1749,12 +1806,15 @@ static int rt2500pci_probe_hw(struct rt2x00_dev *rt2x00dev)
        /*
         * Initialize hw specifications.
         */
-       rt2500pci_probe_hw_mode(rt2x00dev);
+       retval = rt2500pci_probe_hw_mode(rt2x00dev);
+       if (retval)
+               return retval;
 
        /*
-        * This device requires the beacon ring
+        * This device requires the atim queue and DMA-mapped skbs.
         */
-       __set_bit(DRIVER_REQUIRE_BEACON_RING, &rt2x00dev->flags);
+       __set_bit(DRIVER_REQUIRE_ATIM_QUEUE, &rt2x00dev->flags);
+       __set_bit(DRIVER_REQUIRE_DMA, &rt2x00dev->flags);
 
        /*
         * Set the rssi offset.
@@ -1767,73 +1827,6 @@ static int rt2500pci_probe_hw(struct rt2x00_dev *rt2x00dev)
 /*
  * IEEE80211 stack callback functions.
  */
-static void rt2500pci_configure_filter(struct ieee80211_hw *hw,
-                                      unsigned int changed_flags,
-                                      unsigned int *total_flags,
-                                      int mc_count,
-                                      struct dev_addr_list *mc_list)
-{
-       struct rt2x00_dev *rt2x00dev = hw->priv;
-       struct interface *intf = &rt2x00dev->interface;
-       u32 reg;
-
-       /*
-        * Mask off any flags we are going to ignore from
-        * the total_flags field.
-        */
-       *total_flags &=
-           FIF_ALLMULTI |
-           FIF_FCSFAIL |
-           FIF_PLCPFAIL |
-           FIF_CONTROL |
-           FIF_OTHER_BSS |
-           FIF_PROMISC_IN_BSS;
-
-       /*
-        * Apply some rules to the filters:
-        * - Some filters imply different filters to be set.
-        * - Some things we can't filter out at all.
-        * - Some filters are set based on interface type.
-        */
-       if (mc_count)
-               *total_flags |= FIF_ALLMULTI;
-       if (*total_flags & FIF_OTHER_BSS ||
-           *total_flags & FIF_PROMISC_IN_BSS)
-               *total_flags |= FIF_PROMISC_IN_BSS | FIF_OTHER_BSS;
-       if (is_interface_type(intf, IEEE80211_IF_TYPE_AP))
-               *total_flags |= FIF_PROMISC_IN_BSS;
-
-       /*
-        * Check if there is any work left for us.
-        */
-       if (intf->filter == *total_flags)
-               return;
-       intf->filter = *total_flags;
-
-       /*
-        * Start configuration steps.
-        * Note that the version error will always be dropped
-        * and broadcast frames will always be accepted since
-        * there is no filter for it at this time.
-        */
-       rt2x00pci_register_read(rt2x00dev, RXCSR0, &reg);
-       rt2x00_set_field32(&reg, RXCSR0_DROP_CRC,
-                          !(*total_flags & FIF_FCSFAIL));
-       rt2x00_set_field32(&reg, RXCSR0_DROP_PHYSICAL,
-                          !(*total_flags & FIF_PLCPFAIL));
-       rt2x00_set_field32(&reg, RXCSR0_DROP_CONTROL,
-                          !(*total_flags & FIF_CONTROL));
-       rt2x00_set_field32(&reg, RXCSR0_DROP_NOT_TO_ME,
-                          !(*total_flags & FIF_PROMISC_IN_BSS));
-       rt2x00_set_field32(&reg, RXCSR0_DROP_TODS,
-                          !(*total_flags & FIF_PROMISC_IN_BSS));
-       rt2x00_set_field32(&reg, RXCSR0_DROP_VERSION_ERROR, 1);
-       rt2x00_set_field32(&reg, RXCSR0_DROP_MCAST,
-                          !(*total_flags & FIF_ALLMULTI));
-       rt2x00_set_field32(&reg, RXCSR0_DROP_BCAST, 0);
-       rt2x00pci_register_write(rt2x00dev, RXCSR0, reg);
-}
-
 static int rt2500pci_set_retry_limit(struct ieee80211_hw *hw,
                                     u32 short_retry, u32 long_retry)
 {
@@ -1862,14 +1855,6 @@ static u64 rt2500pci_get_tsf(struct ieee80211_hw *hw)
        return tsf;
 }
 
-static void rt2500pci_reset_tsf(struct ieee80211_hw *hw)
-{
-       struct rt2x00_dev *rt2x00dev = hw->priv;
-
-       rt2x00pci_register_write(rt2x00dev, CSR16, 0);
-       rt2x00pci_register_write(rt2x00dev, CSR17, 0);
-}
-
 static int rt2500pci_tx_last_beacon(struct ieee80211_hw *hw)
 {
        struct rt2x00_dev *rt2x00dev = hw->priv;
@@ -1887,15 +1872,13 @@ static const struct ieee80211_ops rt2500pci_mac80211_ops = {
        .remove_interface       = rt2x00mac_remove_interface,
        .config                 = rt2x00mac_config,
        .config_interface       = rt2x00mac_config_interface,
-       .configure_filter       = rt2500pci_configure_filter,
+       .configure_filter       = rt2x00mac_configure_filter,
        .get_stats              = rt2x00mac_get_stats,
        .set_retry_limit        = rt2500pci_set_retry_limit,
-       .erp_ie_changed         = rt2x00mac_erp_ie_changed,
+       .bss_info_changed       = rt2x00mac_bss_info_changed,
        .conf_tx                = rt2x00mac_conf_tx,
        .get_tx_stats           = rt2x00mac_get_tx_stats,
        .get_tsf                = rt2500pci_get_tsf,
-       .reset_tsf              = rt2500pci_reset_tsf,
-       .beacon_update          = rt2x00pci_beacon_update,
        .tx_last_beacon         = rt2500pci_tx_last_beacon,
 };
 
@@ -1904,6 +1887,8 @@ static const struct rt2x00lib_ops rt2500pci_rt2x00_ops = {
        .probe_hw               = rt2500pci_probe_hw,
        .initialize             = rt2x00pci_initialize,
        .uninitialize           = rt2x00pci_uninitialize,
+       .init_rxentry           = rt2500pci_init_rxentry,
+       .init_txentry           = rt2500pci_init_txentry,
        .set_device_state       = rt2500pci_set_device_state,
        .rfkill_poll            = rt2500pci_rfkill_poll,
        .link_stats             = rt2500pci_link_stats,
@@ -1911,21 +1896,54 @@ static const struct rt2x00lib_ops rt2500pci_rt2x00_ops = {
        .link_tuner             = rt2500pci_link_tuner,
        .write_tx_desc          = rt2500pci_write_tx_desc,
        .write_tx_data          = rt2x00pci_write_tx_data,
+       .write_beacon           = rt2500pci_write_beacon,
        .kick_tx_queue          = rt2500pci_kick_tx_queue,
        .fill_rxdone            = rt2500pci_fill_rxdone,
-       .config_mac_addr        = rt2500pci_config_mac_addr,
-       .config_bssid           = rt2500pci_config_bssid,
-       .config_type            = rt2500pci_config_type,
-       .config_preamble        = rt2500pci_config_preamble,
+       .config_filter          = rt2500pci_config_filter,
+       .config_intf            = rt2500pci_config_intf,
+       .config_erp             = rt2500pci_config_erp,
        .config                 = rt2500pci_config,
 };
 
+static const struct data_queue_desc rt2500pci_queue_rx = {
+       .entry_num              = RX_ENTRIES,
+       .data_size              = DATA_FRAME_SIZE,
+       .desc_size              = RXD_DESC_SIZE,
+       .priv_size              = sizeof(struct queue_entry_priv_pci),
+};
+
+static const struct data_queue_desc rt2500pci_queue_tx = {
+       .entry_num              = TX_ENTRIES,
+       .data_size              = DATA_FRAME_SIZE,
+       .desc_size              = TXD_DESC_SIZE,
+       .priv_size              = sizeof(struct queue_entry_priv_pci),
+};
+
+static const struct data_queue_desc rt2500pci_queue_bcn = {
+       .entry_num              = BEACON_ENTRIES,
+       .data_size              = MGMT_FRAME_SIZE,
+       .desc_size              = TXD_DESC_SIZE,
+       .priv_size              = sizeof(struct queue_entry_priv_pci),
+};
+
+static const struct data_queue_desc rt2500pci_queue_atim = {
+       .entry_num              = ATIM_ENTRIES,
+       .data_size              = DATA_FRAME_SIZE,
+       .desc_size              = TXD_DESC_SIZE,
+       .priv_size              = sizeof(struct queue_entry_priv_pci),
+};
+
 static const struct rt2x00_ops rt2500pci_ops = {
-       .name           = DRV_NAME,
-       .rxd_size       = RXD_DESC_SIZE,
-       .txd_size       = TXD_DESC_SIZE,
+       .name           = KBUILD_MODNAME,
+       .max_sta_intf   = 1,
+       .max_ap_intf    = 1,
        .eeprom_size    = EEPROM_SIZE,
        .rf_size        = RF_SIZE,
+       .tx_queues      = NUM_TX_QUEUES,
+       .rx             = &rt2500pci_queue_rx,
+       .tx             = &rt2500pci_queue_tx,
+       .bcn            = &rt2500pci_queue_bcn,
+       .atim           = &rt2500pci_queue_atim,
        .lib            = &rt2500pci_rt2x00_ops,
        .hw             = &rt2500pci_mac80211_ops,
 #ifdef CONFIG_RT2X00_LIB_DEBUGFS
@@ -1949,7 +1967,7 @@ MODULE_DEVICE_TABLE(pci, rt2500pci_device_table);
 MODULE_LICENSE("GPL");
 
 static struct pci_driver rt2500pci_driver = {
-       .name           = DRV_NAME,
+       .name           = KBUILD_MODNAME,
        .id_table       = rt2500pci_device_table,
        .probe          = rt2x00pci_probe,
        .remove         = __devexit_p(rt2x00pci_remove),