]> err.no Git - linux-2.6/blobdiff - drivers/net/wireless/rt2x00/rt2400pci.c
[PATCH] rt2x00: Correctly translate mac80211 antenna setup to rt2x00
[linux-2.6] / drivers / net / wireless / rt2x00 / rt2400pci.c
index 38e2188937c5b46b6213f9d74bad8f773537fb14..2284cb3089715edae797077a388a88917cfc0908 100644 (file)
@@ -244,200 +244,114 @@ static int rt2400pci_rfkill_poll(struct rt2x00_dev *rt2x00dev)
        rt2x00pci_register_read(rt2x00dev, GPIOCSR, &reg);
        return rt2x00_get_field32(reg, GPIOCSR_BIT0);
 }
+#else
+#define rt2400pci_rfkill_poll  NULL
 #endif /* CONFIG_RT2400PCI_RFKILL */
 
 /*
  * Configuration handlers.
  */
-static void rt2400pci_config_mac_addr(struct rt2x00_dev *rt2x00dev, u8 *addr)
+static void rt2400pci_config_mac_addr(struct rt2x00_dev *rt2x00dev,
+                                     __le32 *mac)
 {
-       __le32 reg[2];
-
-       memset(&reg, 0, sizeof(reg));
-       memcpy(&reg, addr, ETH_ALEN);
-
-       /*
-        * The MAC address is passed to us as an array of bytes,
-        * that array is little endian, so no need for byte ordering.
-        */
-       rt2x00pci_register_multiwrite(rt2x00dev, CSR3, &reg, sizeof(reg));
-}
-
-static void rt2400pci_config_bssid(struct rt2x00_dev *rt2x00dev, u8 *bssid)
-{
-       __le32 reg[2];
-
-       memset(&reg, 0, sizeof(reg));
-       memcpy(&reg, bssid, ETH_ALEN);
-
-       /*
-        * The BSSID is passed to us as an array of bytes,
-        * that array is little endian, so no need for byte ordering.
-        */
-       rt2x00pci_register_multiwrite(rt2x00dev, CSR5, &reg, sizeof(reg));
+       rt2x00pci_register_multiwrite(rt2x00dev, CSR3, mac,
+                                     (2 * sizeof(__le32)));
 }
 
-static void rt2400pci_config_packet_filter(struct rt2x00_dev *rt2x00dev,
-                                          const unsigned int filter)
+static void rt2400pci_config_bssid(struct rt2x00_dev *rt2x00dev,
+                                  __le32 *bssid)
 {
-       int promisc = !!(filter & IFF_PROMISC);
-       u32 reg;
-
-       rt2x00pci_register_read(rt2x00dev, RXCSR0, &reg);
-       rt2x00_set_field32(&reg, RXCSR0_DROP_NOT_TO_ME, !promisc);
-       rt2x00pci_register_write(rt2x00dev, RXCSR0, reg);
+       rt2x00pci_register_multiwrite(rt2x00dev, CSR5, bssid,
+                                     (2 * sizeof(__le32)));
 }
 
-static void rt2400pci_config_type(struct rt2x00_dev *rt2x00dev, int type)
+static void rt2400pci_config_type(struct rt2x00_dev *rt2x00dev, const int type,
+                                 const int tsf_sync)
 {
        u32 reg;
 
        rt2x00pci_register_write(rt2x00dev, CSR14, 0);
 
-       /*
-        * Apply hardware packet filter.
-        */
-       rt2x00pci_register_read(rt2x00dev, RXCSR0, &reg);
-
-       if (!is_monitor_present(&rt2x00dev->interface) &&
-           (type == IEEE80211_IF_TYPE_IBSS || type == IEEE80211_IF_TYPE_STA))
-               rt2x00_set_field32(&reg, RXCSR0_DROP_TODS, 1);
-       else
-               rt2x00_set_field32(&reg, RXCSR0_DROP_TODS, 0);
-
-       /*
-        * If there is a non-monitor interface present
-        * the packet should be strict (even if a monitor interface is present!).
-        * When there is only 1 interface present which is in monitor mode
-        * we should start accepting _all_ frames.
-        */
-       if (is_interface_present(&rt2x00dev->interface)) {
-               rt2x00_set_field32(&reg, RXCSR0_DROP_CRC, 1);
-               rt2x00_set_field32(&reg, RXCSR0_DROP_PHYSICAL, 1);
-               rt2x00_set_field32(&reg, RXCSR0_DROP_CONTROL, 1);
-               rt2x00_set_field32(&reg, RXCSR0_DROP_VERSION_ERROR, 1);
-       } else if (is_monitor_present(&rt2x00dev->interface)) {
-               rt2x00_set_field32(&reg, RXCSR0_DROP_CRC, 0);
-               rt2x00_set_field32(&reg, RXCSR0_DROP_PHYSICAL, 0);
-               rt2x00_set_field32(&reg, RXCSR0_DROP_CONTROL, 0);
-               rt2x00_set_field32(&reg, RXCSR0_DROP_VERSION_ERROR, 0);
-       }
-
-       rt2x00pci_register_write(rt2x00dev, RXCSR0, reg);
-
        /*
         * Enable beacon config
         */
        rt2x00pci_register_read(rt2x00dev, BCNCSR1, &reg);
        rt2x00_set_field32(&reg, BCNCSR1_PRELOAD,
-                          PREAMBLE + get_duration(IEEE80211_HEADER, 2));
+                          PREAMBLE + get_duration(IEEE80211_HEADER, 20));
        rt2x00pci_register_write(rt2x00dev, BCNCSR1, reg);
 
        /*
         * Enable synchronisation.
         */
        rt2x00pci_register_read(rt2x00dev, CSR14, &reg);
-       if (is_interface_present(&rt2x00dev->interface)) {
-               rt2x00_set_field32(&reg, CSR14_TSF_COUNT, 1);
-               rt2x00_set_field32(&reg, CSR14_TBCN, 1);
-       }
-
+       rt2x00_set_field32(&reg, CSR14_TSF_COUNT, 1);
+       rt2x00_set_field32(&reg, CSR14_TBCN, 1);
        rt2x00_set_field32(&reg, CSR14_BEACON_GEN, 0);
-       if (type == IEEE80211_IF_TYPE_IBSS || type == IEEE80211_IF_TYPE_AP)
-               rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 2);
-       else if (type == IEEE80211_IF_TYPE_STA)
-               rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 1);
-       else if (is_monitor_present(&rt2x00dev->interface) &&
-                !is_interface_present(&rt2x00dev->interface))
-               rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 0);
-
+       rt2x00_set_field32(&reg, CSR14_TSF_SYNC, tsf_sync);
        rt2x00pci_register_write(rt2x00dev, CSR14, reg);
 }
 
-static void rt2400pci_config_rate(struct rt2x00_dev *rt2x00dev, const int rate)
+static void rt2400pci_config_preamble(struct rt2x00_dev *rt2x00dev,
+                                     const int short_preamble,
+                                     const int ack_timeout,
+                                     const int ack_consume_time)
 {
-       struct ieee80211_conf *conf = &rt2x00dev->hw->conf;
+       int preamble_mask;
        u32 reg;
-       u32 preamble;
-       u16 value;
 
-       if (DEVICE_GET_RATE_FIELD(rate, PREAMBLE))
-               preamble = SHORT_PREAMBLE;
-       else
-               preamble = PREAMBLE;
-
-       reg = DEVICE_GET_RATE_FIELD(rate, RATEMASK) & DEV_BASIC_RATEMASK;
-       rt2x00pci_register_write(rt2x00dev, ARCSR1, reg);
+       /*
+        * When short preamble is enabled, we should set bit 0x08
+        */
+       preamble_mask = short_preamble << 3;
 
        rt2x00pci_register_read(rt2x00dev, TXCSR1, &reg);
-       value = ((conf->flags & IEEE80211_CONF_SHORT_SLOT_TIME) ?
-                SHORT_DIFS : DIFS) +
-           PLCP + preamble + get_duration(ACK_SIZE, 10);
-       rt2x00_set_field32(&reg, TXCSR1_ACK_TIMEOUT, value);
-       value = SIFS + PLCP + preamble + get_duration(ACK_SIZE, 10);
-       rt2x00_set_field32(&reg, TXCSR1_ACK_CONSUME_TIME, value);
+       rt2x00_set_field32(&reg, TXCSR1_ACK_TIMEOUT, ack_timeout);
+       rt2x00_set_field32(&reg, TXCSR1_ACK_CONSUME_TIME, ack_consume_time);
        rt2x00pci_register_write(rt2x00dev, TXCSR1, reg);
 
-       preamble = DEVICE_GET_RATE_FIELD(rate, PREAMBLE) ? 0x08 : 0x00;
-
        rt2x00pci_register_read(rt2x00dev, ARCSR2, &reg);
-       rt2x00_set_field32(&reg, ARCSR2_SIGNAL, 0x00 | preamble);
+       rt2x00_set_field32(&reg, ARCSR2_SIGNAL, 0x00 | preamble_mask);
        rt2x00_set_field32(&reg, ARCSR2_SERVICE, 0x04);
        rt2x00_set_field32(&reg, ARCSR2_LENGTH, get_duration(ACK_SIZE, 10));
        rt2x00pci_register_write(rt2x00dev, ARCSR2, reg);
 
        rt2x00pci_register_read(rt2x00dev, ARCSR3, &reg);
-       rt2x00_set_field32(&reg, ARCSR3_SIGNAL, 0x01 | preamble);
+       rt2x00_set_field32(&reg, ARCSR3_SIGNAL, 0x01 | preamble_mask);
        rt2x00_set_field32(&reg, ARCSR3_SERVICE, 0x04);
        rt2x00_set_field32(&reg, ARCSR2_LENGTH, get_duration(ACK_SIZE, 20));
        rt2x00pci_register_write(rt2x00dev, ARCSR3, reg);
 
        rt2x00pci_register_read(rt2x00dev, ARCSR4, &reg);
-       rt2x00_set_field32(&reg, ARCSR4_SIGNAL, 0x02 | preamble);
+       rt2x00_set_field32(&reg, ARCSR4_SIGNAL, 0x02 | preamble_mask);
        rt2x00_set_field32(&reg, ARCSR4_SERVICE, 0x04);
        rt2x00_set_field32(&reg, ARCSR2_LENGTH, get_duration(ACK_SIZE, 55));
        rt2x00pci_register_write(rt2x00dev, ARCSR4, reg);
 
        rt2x00pci_register_read(rt2x00dev, ARCSR5, &reg);
-       rt2x00_set_field32(&reg, ARCSR5_SIGNAL, 0x03 | preamble);
+       rt2x00_set_field32(&reg, ARCSR5_SIGNAL, 0x03 | preamble_mask);
        rt2x00_set_field32(&reg, ARCSR5_SERVICE, 0x84);
        rt2x00_set_field32(&reg, ARCSR2_LENGTH, get_duration(ACK_SIZE, 110));
        rt2x00pci_register_write(rt2x00dev, ARCSR5, reg);
 }
 
 static void rt2400pci_config_phymode(struct rt2x00_dev *rt2x00dev,
-                                    const int phymode)
+                                    const int basic_rate_mask)
 {
-       struct ieee80211_hw_mode *mode;
-       struct ieee80211_rate *rate;
-
-       rt2x00dev->curr_hwmode = HWMODE_B;
-
-       mode = &rt2x00dev->hwmodes[rt2x00dev->curr_hwmode];
-       rate = &mode->rates[mode->num_rates - 1];
-
-       rt2400pci_config_rate(rt2x00dev, rate->val2);
+       rt2x00pci_register_write(rt2x00dev, ARCSR1, basic_rate_mask);
 }
 
 static void rt2400pci_config_channel(struct rt2x00_dev *rt2x00dev,
-                                    const int index, const int channel)
+                                    struct rf_channel *rf)
 {
-       struct rf_channel reg;
-
-       /*
-        * Fill rf_reg structure.
-        */
-       memcpy(&reg, &rt2x00dev->spec.channels[index], sizeof(reg));
-
        /*
         * Switch on tuning bits.
         */
-       rt2x00_set_field32(&reg.rf1, RF1_TUNER, 1);
-       rt2x00_set_field32(&reg.rf3, RF3_TUNER, 1);
+       rt2x00_set_field32(&rf->rf1, RF1_TUNER, 1);
+       rt2x00_set_field32(&rf->rf3, RF3_TUNER, 1);
 
-       rt2400pci_rf_write(rt2x00dev, 1, reg.rf1);
-       rt2400pci_rf_write(rt2x00dev, 2, reg.rf2);
-       rt2400pci_rf_write(rt2x00dev, 3, reg.rf3);
+       rt2400pci_rf_write(rt2x00dev, 1, rf->rf1);
+       rt2400pci_rf_write(rt2x00dev, 2, rf->rf2);
+       rt2400pci_rf_write(rt2x00dev, 3, rf->rf3);
 
        /*
         * RF2420 chipset don't need any additional actions.
@@ -450,31 +364,31 @@ static void rt2400pci_config_channel(struct rt2x00_dev *rt2x00dev,
         * reference clock rate to activate auto_tune.
         * After that we set the value back to the correct channel.
         */
-       rt2400pci_rf_write(rt2x00dev, 1, reg.rf1);
+       rt2400pci_rf_write(rt2x00dev, 1, rf->rf1);
        rt2400pci_rf_write(rt2x00dev, 2, 0x000c2a32);
-       rt2400pci_rf_write(rt2x00dev, 3, reg.rf3);
+       rt2400pci_rf_write(rt2x00dev, 3, rf->rf3);
 
        msleep(1);
 
-       rt2400pci_rf_write(rt2x00dev, 1, reg.rf1);
-       rt2400pci_rf_write(rt2x00dev, 2, reg.rf2);
-       rt2400pci_rf_write(rt2x00dev, 3, reg.rf3);
+       rt2400pci_rf_write(rt2x00dev, 1, rf->rf1);
+       rt2400pci_rf_write(rt2x00dev, 2, rf->rf2);
+       rt2400pci_rf_write(rt2x00dev, 3, rf->rf3);
 
        msleep(1);
 
        /*
         * Switch off tuning bits.
         */
-       rt2x00_set_field32(&reg.rf1, RF1_TUNER, 0);
-       rt2x00_set_field32(&reg.rf3, RF3_TUNER, 0);
+       rt2x00_set_field32(&rf->rf1, RF1_TUNER, 0);
+       rt2x00_set_field32(&rf->rf3, RF3_TUNER, 0);
 
-       rt2400pci_rf_write(rt2x00dev, 1, reg.rf1);
-       rt2400pci_rf_write(rt2x00dev, 3, reg.rf3);
+       rt2400pci_rf_write(rt2x00dev, 1, rf->rf1);
+       rt2400pci_rf_write(rt2x00dev, 3, rf->rf3);
 
        /*
         * Clear false CRC during channel switch.
         */
-       rt2x00pci_register_read(rt2x00dev, CNT0, &reg.rf1);
+       rt2x00pci_register_read(rt2x00dev, CNT0, &rf->rf1);
 }
 
 static void rt2400pci_config_txpower(struct rt2x00_dev *rt2x00dev, int txpower)
@@ -483,7 +397,7 @@ static void rt2400pci_config_txpower(struct rt2x00_dev *rt2x00dev, int txpower)
 }
 
 static void rt2400pci_config_antenna(struct rt2x00_dev *rt2x00dev,
-                                    int antenna_tx, int antenna_rx)
+                                    struct antenna_setup *ant)
 {
        u8 r1;
        u8 r4;
@@ -494,7 +408,7 @@ static void rt2400pci_config_antenna(struct rt2x00_dev *rt2x00dev,
        /*
         * Configure the TX antenna.
         */
-       switch (antenna_tx) {
+       switch (ant->tx) {
        case ANTENNA_SW_DIVERSITY:
        case ANTENNA_HW_DIVERSITY:
                rt2x00_set_field8(&r1, BBP_R1_TX_ANTENNA, 1);
@@ -510,7 +424,7 @@ static void rt2400pci_config_antenna(struct rt2x00_dev *rt2x00dev,
        /*
         * Configure the RX antenna.
         */
-       switch (antenna_rx) {
+       switch (ant->rx) {
        case ANTENNA_SW_DIVERSITY:
        case ANTENNA_HW_DIVERSITY:
                rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA, 1);
@@ -528,25 +442,22 @@ static void rt2400pci_config_antenna(struct rt2x00_dev *rt2x00dev,
 }
 
 static void rt2400pci_config_duration(struct rt2x00_dev *rt2x00dev,
-                                     int short_slot_time, int beacon_int)
+                                     struct rt2x00lib_conf *libconf)
 {
        u32 reg;
 
        rt2x00pci_register_read(rt2x00dev, CSR11, &reg);
-       rt2x00_set_field32(&reg, CSR11_SLOT_TIME,
-                          short_slot_time ? SHORT_SLOT_TIME : SLOT_TIME);
+       rt2x00_set_field32(&reg, CSR11_SLOT_TIME, libconf->slot_time);
        rt2x00pci_register_write(rt2x00dev, CSR11, reg);
 
        rt2x00pci_register_read(rt2x00dev, CSR18, &reg);
-       rt2x00_set_field32(&reg, CSR18_SIFS, SIFS);
-       rt2x00_set_field32(&reg, CSR18_PIFS,
-                          short_slot_time ? SHORT_PIFS : PIFS);
+       rt2x00_set_field32(&reg, CSR18_SIFS, libconf->sifs);
+       rt2x00_set_field32(&reg, CSR18_PIFS, libconf->pifs);
        rt2x00pci_register_write(rt2x00dev, CSR18, reg);
 
        rt2x00pci_register_read(rt2x00dev, CSR19, &reg);
-       rt2x00_set_field32(&reg, CSR19_DIFS,
-                          short_slot_time ? SHORT_DIFS : DIFS);
-       rt2x00_set_field32(&reg, CSR19_EIFS, EIFS);
+       rt2x00_set_field32(&reg, CSR19_DIFS, libconf->difs);
+       rt2x00_set_field32(&reg, CSR19_EIFS, libconf->eifs);
        rt2x00pci_register_write(rt2x00dev, CSR19, reg);
 
        rt2x00pci_register_read(rt2x00dev, TXCSR1, &reg);
@@ -555,30 +466,28 @@ static void rt2400pci_config_duration(struct rt2x00_dev *rt2x00dev,
        rt2x00pci_register_write(rt2x00dev, TXCSR1, reg);
 
        rt2x00pci_register_read(rt2x00dev, CSR12, &reg);
-       rt2x00_set_field32(&reg, CSR12_BEACON_INTERVAL, beacon_int * 16);
-       rt2x00_set_field32(&reg, CSR12_CFP_MAX_DURATION, beacon_int * 16);
+       rt2x00_set_field32(&reg, CSR12_BEACON_INTERVAL,
+                          libconf->conf->beacon_int * 16);
+       rt2x00_set_field32(&reg, CSR12_CFP_MAX_DURATION,
+                          libconf->conf->beacon_int * 16);
        rt2x00pci_register_write(rt2x00dev, CSR12, reg);
 }
 
 static void rt2400pci_config(struct rt2x00_dev *rt2x00dev,
                             const unsigned int flags,
-                            struct ieee80211_conf *conf)
+                            struct rt2x00lib_conf *libconf)
 {
-       int short_slot_time = conf->flags & IEEE80211_CONF_SHORT_SLOT_TIME;
-
        if (flags & CONFIG_UPDATE_PHYMODE)
-               rt2400pci_config_phymode(rt2x00dev, conf->phymode);
+               rt2400pci_config_phymode(rt2x00dev, libconf->basic_rates);
        if (flags & CONFIG_UPDATE_CHANNEL)
-               rt2400pci_config_channel(rt2x00dev, conf->channel_val,
-                                        conf->channel);
+               rt2400pci_config_channel(rt2x00dev, &libconf->rf);
        if (flags & CONFIG_UPDATE_TXPOWER)
-               rt2400pci_config_txpower(rt2x00dev, conf->power_level);
+               rt2400pci_config_txpower(rt2x00dev,
+                                        libconf->conf->power_level);
        if (flags & CONFIG_UPDATE_ANTENNA)
-               rt2400pci_config_antenna(rt2x00dev, conf->antenna_sel_tx,
-                                        conf->antenna_sel_rx);
+               rt2400pci_config_antenna(rt2x00dev, &libconf->ant);
        if (flags & (CONFIG_UPDATE_SLOT_TIME | CONFIG_UPDATE_BEACON_INT))
-               rt2400pci_config_duration(rt2x00dev, short_slot_time,
-                                         conf->beacon_int);
+               rt2400pci_config_duration(rt2x00dev, libconf);
 }
 
 static void rt2400pci_config_cw(struct rt2x00_dev *rt2x00dev,
@@ -631,7 +540,8 @@ static void rt2400pci_disable_led(struct rt2x00_dev *rt2x00dev)
 /*
  * Link tuning
  */
-static void rt2400pci_link_stats(struct rt2x00_dev *rt2x00dev)
+static void rt2400pci_link_stats(struct rt2x00_dev *rt2x00dev,
+                                struct link_qual *qual)
 {
        u32 reg;
        u8 bbp;
@@ -640,13 +550,13 @@ static void rt2400pci_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.
         */
        rt2400pci_bbp_read(rt2x00dev, 39, &bbp);
-       rt2x00dev->link.false_cca = bbp;
+       qual->false_cca = bbp;
 }
 
 static void rt2400pci_reset_tuner(struct rt2x00_dev *rt2x00dev)
@@ -671,10 +581,10 @@ static void rt2400pci_link_tuner(struct rt2x00_dev *rt2x00dev)
         */
        rt2400pci_bbp_read(rt2x00dev, 13, &reg);
 
-       if (rt2x00dev->link.false_cca > 512 && reg < 0x20) {
+       if (rt2x00dev->link.qual.false_cca > 512 && reg < 0x20) {
                rt2400pci_bbp_write(rt2x00dev, 13, ++reg);
                rt2x00dev->link.vgc_level = reg;
-       } else if (rt2x00dev->link.false_cca < 100 && reg > 0x08) {
+       } else if (rt2x00dev->link.qual.false_cca < 100 && reg > 0x08) {
                rt2400pci_bbp_write(rt2x00dev, 13, --reg);
                rt2x00dev->link.vgc_level = reg;
        }
@@ -1104,7 +1014,7 @@ static int rt2400pci_set_device_state(struct rt2x00_dev *rt2x00dev,
  */
 static void rt2400pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,
                                    struct data_desc *txd,
-                                   struct data_entry_desc *desc,
+                                   struct txdata_entry_desc *desc,
                                    struct ieee80211_hdr *ieee80211hdr,
                                    unsigned int length,
                                    struct ieee80211_tx_control *control)
@@ -1200,8 +1110,8 @@ static void rt2400pci_kick_tx_queue(struct rt2x00_dev *rt2x00dev,
 /*
  * RX control handlers
  */
-static int rt2400pci_fill_rxdone(struct data_entry *entry,
-                                int *signal, int *rssi, int *ofdm, int *size)
+static void rt2400pci_fill_rxdone(struct data_entry *entry,
+                                 struct rxdata_entry_desc *desc)
 {
        struct data_desc *rxd = entry->priv;
        u32 word0;
@@ -1210,20 +1120,20 @@ static int rt2400pci_fill_rxdone(struct data_entry *entry,
        rt2x00_desc_read(rxd, 0, &word0);
        rt2x00_desc_read(rxd, 2, &word2);
 
-       if (rt2x00_get_field32(word0, RXD_W0_CRC_ERROR) ||
-           rt2x00_get_field32(word0, RXD_W0_PHYSICAL_ERROR))
-               return -EINVAL;
+       desc->flags = 0;
+       if (rt2x00_get_field32(word0, RXD_W0_CRC_ERROR))
+               desc->flags |= RX_FLAG_FAILED_FCS_CRC;
+       if (rt2x00_get_field32(word0, RXD_W0_PHYSICAL_ERROR))
+               desc->flags |= RX_FLAG_FAILED_PLCP_CRC;
 
        /*
         * Obtain the status about this packet.
         */
-       *signal = rt2x00_get_field32(word2, RXD_W2_SIGNAL);
-       *rssi = rt2x00_get_field32(word2, RXD_W2_RSSI) -
+       desc->signal = rt2x00_get_field32(word2, RXD_W2_SIGNAL);
+       desc->rssi = rt2x00_get_field32(word2, RXD_W2_RSSI) -
            entry->ring->rt2x00dev->rssi_offset;
-       *ofdm = 0;
-       *size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT);
-
-       return 0;
+       desc->ofdm = 0;
+       desc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT);
 }
 
 /*
@@ -1362,8 +1272,10 @@ static int rt2400pci_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: " MAC_FMT "\n", MAC_ARG(mac));
+               EEPROM(rt2x00dev, "MAC: %s\n", print_mac(macbuf, mac));
        }
 
        rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &word);
@@ -1402,11 +1314,22 @@ static int rt2400pci_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);
 
+       /*
+        * When the eeprom indicates SW_DIVERSITY use HW_DIVERSITY instead.
+        * I am not 100% sure about this, but the legacy drivers do not
+        * indicate antenna swapping in software is required when
+        * diversity is enabled.
+        */
+       if (rt2x00dev->default_ant.tx == ANTENNA_SW_DIVERSITY)
+               rt2x00dev->default_ant.tx = ANTENNA_HW_DIVERSITY;
+       if (rt2x00dev->default_ant.rx == ANTENNA_SW_DIVERSITY)
+               rt2x00dev->default_ant.rx = ANTENNA_HW_DIVERSITY;
+
        /*
         * Store led mode, for correct led behaviour.
         */
@@ -1416,8 +1339,10 @@ static int rt2400pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
        /*
         * Detect if this device has an hardware controlled radio.
         */
+#ifdef CONFIG_RT2400PCI_RFKILL
        if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_HARDWARE_RADIO))
-               __set_bit(DEVICE_SUPPORT_HW_BUTTON, &rt2x00dev->flags);
+               __set_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags);
+#endif /* CONFIG_RT2400PCI_RFKILL */
 
        /*
         * Check if the BBP tuning should be enabled.
@@ -1458,10 +1383,7 @@ static void rt2400pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
        /*
         * Initialize all hw fields.
         */
-       rt2x00dev->hw->flags =
-           IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
-           IEEE80211_HW_MONITOR_DURING_OPER |
-           IEEE80211_HW_NO_PROBE_FILTERING;
+       rt2x00dev->hw->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING;
        rt2x00dev->hw->extra_tx_headroom = 0;
        rt2x00dev->hw->max_signal = MAX_SIGNAL;
        rt2x00dev->hw->max_rssi = MAX_RX_SSI;
@@ -1515,7 +1437,7 @@ static int rt2400pci_probe_hw(struct rt2x00_dev *rt2x00dev)
        /*
         * This device requires the beacon ring
         */
-       __set_bit(REQUIRE_BEACON_RING, &rt2x00dev->flags);
+       __set_bit(DRIVER_REQUIRE_BEACON_RING, &rt2x00dev->flags);
 
        /*
         * Set the rssi offset.
@@ -1528,6 +1450,68 @@ static int rt2400pci_probe_hw(struct rt2x00_dev *rt2x00dev)
 /*
  * IEEE80211 stack callback functions.
  */
+static void rt2400pci_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.
+        */
+       *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
+        * 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);
+       rt2x00pci_register_write(rt2x00dev, RXCSR0, reg);
+}
+
 static int rt2400pci_set_retry_limit(struct ieee80211_hw *hw,
                                     u32 short_retry, u32 long_retry)
 {
@@ -1600,13 +1584,16 @@ static int rt2400pci_tx_last_beacon(struct ieee80211_hw *hw)
 
 static const struct ieee80211_ops rt2400pci_mac80211_ops = {
        .tx                     = rt2x00mac_tx,
+       .start                  = rt2x00mac_start,
+       .stop                   = rt2x00mac_stop,
        .add_interface          = rt2x00mac_add_interface,
        .remove_interface       = rt2x00mac_remove_interface,
        .config                 = rt2x00mac_config,
        .config_interface       = rt2x00mac_config_interface,
-       .set_multicast_list     = rt2x00mac_set_multicast_list,
+       .configure_filter       = rt2400pci_configure_filter,
        .get_stats              = rt2x00mac_get_stats,
        .set_retry_limit        = rt2400pci_set_retry_limit,
+       .erp_ie_changed         = rt2x00mac_erp_ie_changed,
        .conf_tx                = rt2400pci_conf_tx,
        .get_tx_stats           = rt2x00mac_get_tx_stats,
        .get_tsf                = rt2400pci_get_tsf,
@@ -1621,9 +1608,7 @@ static const struct rt2x00lib_ops rt2400pci_rt2x00_ops = {
        .initialize             = rt2x00pci_initialize,
        .uninitialize           = rt2x00pci_uninitialize,
        .set_device_state       = rt2400pci_set_device_state,
-#ifdef CONFIG_RT2400PCI_RFKILL
        .rfkill_poll            = rt2400pci_rfkill_poll,
-#endif /* CONFIG_RT2400PCI_RFKILL */
        .link_stats             = rt2400pci_link_stats,
        .reset_tuner            = rt2400pci_reset_tuner,
        .link_tuner             = rt2400pci_link_tuner,
@@ -1633,8 +1618,8 @@ static const struct rt2x00lib_ops rt2400pci_rt2x00_ops = {
        .fill_rxdone            = rt2400pci_fill_rxdone,
        .config_mac_addr        = rt2400pci_config_mac_addr,
        .config_bssid           = rt2400pci_config_bssid,
-       .config_packet_filter   = rt2400pci_config_packet_filter,
        .config_type            = rt2400pci_config_type,
+       .config_preamble        = rt2400pci_config_preamble,
        .config                 = rt2400pci_config,
 };