include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / drivers / net / wireless / rt2x00 / rt2x00dev.c
index 16b560a..eda73ba 100644 (file)
@@ -1,5 +1,5 @@
 /*
-       Copyright (C) 2004 - 2009 rt2x00 SourceForge Project
+       Copyright (C) 2004 - 2009 Ivo van Doorn <IvDoorn@gmail.com>
        <http://rt2x00.serialmonkey.com>
 
        This program is free software; you can redistribute it and/or modify
@@ -25,6 +25,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 
 #include "rt2x00.h"
 #include "rt2x00lib.h"
@@ -123,7 +124,6 @@ static void rt2x00lib_intf_scheduled_iter(void *data, u8 *mac,
 {
        struct rt2x00_dev *rt2x00dev = data;
        struct rt2x00_intf *intf = vif_to_intf(vif);
-       struct ieee80211_bss_conf conf;
        int delayed_flags;
 
        /*
@@ -133,7 +133,6 @@ static void rt2x00lib_intf_scheduled_iter(void *data, u8 *mac,
         */
        spin_lock(&intf->lock);
 
-       memcpy(&conf, &vif->bss_conf, sizeof(conf));
        delayed_flags = intf->delayed_flags;
        intf->delayed_flags = 0;
 
@@ -150,12 +149,6 @@ static void rt2x00lib_intf_scheduled_iter(void *data, u8 *mac,
 
        if (delayed_flags & DELAYED_UPDATE_BEACON)
                rt2x00queue_update_beacon(rt2x00dev, vif, true);
-
-       if (delayed_flags & DELAYED_CONFIG_ERP)
-               rt2x00lib_config_erp(rt2x00dev, intf, &conf);
-
-       if (delayed_flags & DELAYED_LED_ASSOC)
-               rt2x00leds_led_assoc(rt2x00dev, !!rt2x00dev->intf_associated);
 }
 
 static void rt2x00lib_intf_scheduled(struct work_struct *work)
@@ -213,7 +206,9 @@ void rt2x00lib_txdone(struct queue_entry *entry,
        enum data_queue_qid qid = skb_get_queue_mapping(entry->skb);
        unsigned int header_length = ieee80211_get_hdrlen_from_skb(entry->skb);
        u8 rate_idx, rate_flags, retry_rates;
+       u8 skbdesc_flags = skbdesc->flags;
        unsigned int i;
+       bool success;
 
        /*
         * Unmap the skb.
@@ -224,7 +219,7 @@ void rt2x00lib_txdone(struct queue_entry *entry,
         * Remove L2 padding which was added during
         */
        if (test_bit(DRIVER_REQUIRE_L2PAD, &rt2x00dev->flags))
-               rt2x00queue_payload_align(entry->skb, true, header_length);
+               rt2x00queue_remove_l2pad(entry->skb, header_length);
 
        /*
         * If the IV/EIV data was stripped from the frame before it was
@@ -242,13 +237,18 @@ void rt2x00lib_txdone(struct queue_entry *entry,
        rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_TXDONE, entry->skb);
 
        /*
-        * Update TX statistics.
+        * Determine if the frame has been successfully transmitted.
         */
-       rt2x00dev->link.qual.tx_success +=
+       success =
            test_bit(TXDONE_SUCCESS, &txdesc->flags) ||
-           test_bit(TXDONE_UNKNOWN, &txdesc->flags);
-       rt2x00dev->link.qual.tx_failed +=
-           test_bit(TXDONE_FAILURE, &txdesc->flags);
+           test_bit(TXDONE_UNKNOWN, &txdesc->flags) ||
+           test_bit(TXDONE_FALLBACK, &txdesc->flags);
+
+       /*
+        * Update TX statistics.
+        */
+       rt2x00dev->link.qual.tx_success += success;
+       rt2x00dev->link.qual.tx_failed += !success;
 
        rate_idx = skbdesc->tx_rate_idx;
        rate_flags = skbdesc->tx_rate_flags;
@@ -271,32 +271,30 @@ void rt2x00lib_txdone(struct queue_entry *entry,
                tx_info->status.rates[i].flags = rate_flags;
                tx_info->status.rates[i].count = 1;
        }
-       if (i < (IEEE80211_TX_MAX_RATES -1))
+       if (i < (IEEE80211_TX_MAX_RATES - 1))
                tx_info->status.rates[i].idx = -1; /* terminate */
 
        if (!(tx_info->flags & IEEE80211_TX_CTL_NO_ACK)) {
-               if (test_bit(TXDONE_SUCCESS, &txdesc->flags) ||
-                               test_bit(TXDONE_UNKNOWN, &txdesc->flags))
+               if (success)
                        tx_info->flags |= IEEE80211_TX_STAT_ACK;
-               else if (test_bit(TXDONE_FAILURE, &txdesc->flags))
+               else
                        rt2x00dev->low_level_stats.dot11ACKFailureCount++;
        }
 
        if (rate_flags & IEEE80211_TX_RC_USE_RTS_CTS) {
-               if (test_bit(TXDONE_SUCCESS, &txdesc->flags) ||
-                               test_bit(TXDONE_UNKNOWN, &txdesc->flags))
+               if (success)
                        rt2x00dev->low_level_stats.dot11RTSSuccessCount++;
-               else if (test_bit(TXDONE_FAILURE, &txdesc->flags))
+               else
                        rt2x00dev->low_level_stats.dot11RTSFailureCount++;
        }
 
        /*
-        * Only send the status report to mac80211 when TX status was
-        * requested by it. If this was a extra frame coming through
-        * a mac80211 library call (RTS/CTS) then we should not send the
-        * status report back.
+        * Only send the status report to mac80211 when it's a frame
+        * that originated in mac80211. If this was a extra frame coming
+        * through a mac80211 library call (RTS/CTS) then we should not
+        * send the status report back.
         */
-       if (tx_info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS)
+       if (!(skbdesc_flags & SKBDESC_NOT_MAC80211))
                ieee80211_tx_status_irqsafe(rt2x00dev->hw, entry->skb);
        else
                dev_kfree_skb_irq(entry->skb);
@@ -368,7 +366,6 @@ void rt2x00lib_rxdone(struct rt2x00_dev *rt2x00dev,
        struct sk_buff *skb;
        struct ieee80211_rx_status *rx_status = &rt2x00dev->rx_status;
        unsigned int header_length;
-       bool l2pad;
        int rate_idx;
        /*
         * Allocate a new sk_buffer. If no new buffer available, drop the
@@ -389,28 +386,31 @@ void rt2x00lib_rxdone(struct rt2x00_dev *rt2x00dev,
        memset(&rxdesc, 0, sizeof(rxdesc));
        rt2x00dev->ops->lib->fill_rxdone(entry, &rxdesc);
 
-       /* Trim buffer to correct size */
-       skb_trim(entry->skb, rxdesc.size);
-
        /*
         * The data behind the ieee80211 header must be
         * aligned on a 4 byte boundary.
         */
        header_length = ieee80211_get_hdrlen_from_skb(entry->skb);
-       l2pad = !!(rxdesc.dev_flags & RXDONE_L2PAD);
 
        /*
         * Hardware might have stripped the IV/EIV/ICV data,
         * in that case it is possible that the data was
-        * provided seperately (through hardware descriptor)
+        * provided separately (through hardware descriptor)
         * in which case we should reinsert the data into the frame.
         */
        if ((rxdesc.dev_flags & RXDONE_CRYPTO_IV) &&
            (rxdesc.flags & RX_FLAG_IV_STRIPPED))
-               rt2x00crypto_rx_insert_iv(entry->skb, l2pad, header_length,
+               rt2x00crypto_rx_insert_iv(entry->skb, header_length,
                                          &rxdesc);
+       else if (header_length &&
+                (rxdesc.size > header_length) &&
+                (rxdesc.dev_flags & RXDONE_L2PAD))
+               rt2x00queue_remove_l2pad(entry->skb, header_length);
        else
-               rt2x00queue_payload_align(entry->skb, l2pad, header_length);
+               rt2x00queue_align_payload(entry->skb, header_length);
+
+       /* Trim buffer to correct size */
+       skb_trim(entry->skb, rxdesc.size);
 
        /*
         * Check if the frame was received using HT. In that case,
@@ -434,7 +434,6 @@ void rt2x00lib_rxdone(struct rt2x00_dev *rt2x00dev,
 
        rx_status->mactime = rxdesc.timestamp;
        rx_status->rate_idx = rate_idx;
-       rx_status->qual = rt2x00link_calculate_signal(rt2x00dev, rxdesc.rssi);
        rx_status->signal = rxdesc.rssi;
        rx_status->noise = rxdesc.noise;
        rx_status->flag = rxdesc.flags;
@@ -688,6 +687,21 @@ static int rt2x00lib_probe_hw(struct rt2x00_dev *rt2x00dev)
        rt2x00dev->hw->queues = rt2x00dev->ops->tx_queues;
 
        /*
+        * Initialize extra TX headroom required.
+        */
+       rt2x00dev->hw->extra_tx_headroom =
+               max_t(unsigned int, IEEE80211_TX_STATUS_HEADROOM,
+                     rt2x00dev->ops->extra_tx_headroom);
+
+       /*
+        * Take TX headroom required for alignment into account.
+        */
+       if (test_bit(DRIVER_REQUIRE_L2PAD, &rt2x00dev->flags))
+               rt2x00dev->hw->extra_tx_headroom += RT2X00_L2PAD_SIZE;
+       else if (test_bit(DRIVER_REQUIRE_DMA, &rt2x00dev->flags))
+               rt2x00dev->hw->extra_tx_headroom += RT2X00_ALIGN_SIZE;
+
+       /*
         * Register HW.
         */
        status = ieee80211_register_hw(rt2x00dev->hw);
@@ -819,6 +833,8 @@ int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev)
 
        mutex_init(&rt2x00dev->csr_mutex);
 
+       set_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags);
+
        /*
         * Make room for rt2x00_intf inside the per-interface
         * structure ieee80211_vif.
@@ -875,8 +891,6 @@ int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev)
        rt2x00leds_register(rt2x00dev);
        rt2x00debug_register(rt2x00dev);
 
-       set_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags);
-
        return 0;
 
 exit: