Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wirel...
[safe/jmp/linux-2.6] / drivers / net / wireless / rt2x00 / rt2500usb.c
index 54d2716..9ae96a6 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 
 #include "rt2x00.h"
@@ -368,7 +369,7 @@ static int rt2500usb_config_key(struct rt2x00_dev *rt2x00dev,
 
                /*
                 * The encryption key doesn't fit within the CSR cache,
-                * this means we should allocate it seperately and use
+                * this means we should allocate it separately and use
                 * rt2x00usb_vendor_request() to send the key to the hardware.
                 */
                reg = KEY_ENTRY(key->hw_key_idx);
@@ -382,7 +383,7 @@ static int rt2500usb_config_key(struct rt2x00_dev *rt2x00dev,
                /*
                 * The driver does not support the IV/EIV generation
                 * in hardware. However it demands the data to be provided
-                * both seperately as well as inside the frame.
+                * both separately as well as inside the frame.
                 * We already provided the CONFIG_CRYPTO_COPY_IV to rt2x00lib
                 * to ensure rt2x00lib will not strip the data from the
                 * frame after the copy, now we must tell mac80211
@@ -1033,12 +1034,30 @@ static void rt2500usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,
                                    struct txentry_desc *txdesc)
 {
        struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb);
-       __le32 *txd = skbdesc->desc;
+       __le32 *txd = (__le32 *)(skb->data - TXD_DESC_SIZE);
        u32 word;
 
        /*
         * Start writing the descriptor words.
         */
+       rt2x00_desc_read(txd, 0, &word);
+       rt2x00_set_field32(&word, TXD_W0_RETRY_LIMIT, txdesc->retry_limit);
+       rt2x00_set_field32(&word, TXD_W0_MORE_FRAG,
+                          test_bit(ENTRY_TXD_MORE_FRAG, &txdesc->flags));
+       rt2x00_set_field32(&word, TXD_W0_ACK,
+                          test_bit(ENTRY_TXD_ACK, &txdesc->flags));
+       rt2x00_set_field32(&word, TXD_W0_TIMESTAMP,
+                          test_bit(ENTRY_TXD_REQ_TIMESTAMP, &txdesc->flags));
+       rt2x00_set_field32(&word, TXD_W0_OFDM,
+                          (txdesc->rate_mode == RATE_MODE_OFDM));
+       rt2x00_set_field32(&word, TXD_W0_NEW_SEQ,
+                          test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags));
+       rt2x00_set_field32(&word, TXD_W0_IFS, txdesc->ifs);
+       rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, txdesc->length);
+       rt2x00_set_field32(&word, TXD_W0_CIPHER, !!txdesc->cipher);
+       rt2x00_set_field32(&word, TXD_W0_KEY_ID, txdesc->key_idx);
+       rt2x00_desc_write(txd, 0, word);
+
        rt2x00_desc_read(txd, 1, &word);
        rt2x00_set_field32(&word, TXD_W1_IV_OFFSET, txdesc->iv_offset);
        rt2x00_set_field32(&word, TXD_W1_AIFS, txdesc->aifs);
@@ -1058,23 +1077,11 @@ static void rt2500usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,
                _rt2x00_desc_write(txd, 4, skbdesc->iv[1]);
        }
 
-       rt2x00_desc_read(txd, 0, &word);
-       rt2x00_set_field32(&word, TXD_W0_RETRY_LIMIT, txdesc->retry_limit);
-       rt2x00_set_field32(&word, TXD_W0_MORE_FRAG,
-                          test_bit(ENTRY_TXD_MORE_FRAG, &txdesc->flags));
-       rt2x00_set_field32(&word, TXD_W0_ACK,
-                          test_bit(ENTRY_TXD_ACK, &txdesc->flags));
-       rt2x00_set_field32(&word, TXD_W0_TIMESTAMP,
-                          test_bit(ENTRY_TXD_REQ_TIMESTAMP, &txdesc->flags));
-       rt2x00_set_field32(&word, TXD_W0_OFDM,
-                          (txdesc->rate_mode == RATE_MODE_OFDM));
-       rt2x00_set_field32(&word, TXD_W0_NEW_SEQ,
-                          test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags));
-       rt2x00_set_field32(&word, TXD_W0_IFS, txdesc->ifs);
-       rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, skb->len);
-       rt2x00_set_field32(&word, TXD_W0_CIPHER, !!txdesc->cipher);
-       rt2x00_set_field32(&word, TXD_W0_KEY_ID, txdesc->key_idx);
-       rt2x00_desc_write(txd, 0, word);
+       /*
+        * Register descriptor details in skb frame descriptor.
+        */
+       skbdesc->desc = txd;
+       skbdesc->desc_len = TXD_DESC_SIZE;
 }
 
 /*
@@ -1082,22 +1089,15 @@ static void rt2500usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,
  */
 static void rt2500usb_beacondone(struct urb *urb);
 
-static void rt2500usb_write_beacon(struct queue_entry *entry)
+static void rt2500usb_write_beacon(struct queue_entry *entry,
+                                  struct txentry_desc *txdesc)
 {
        struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
        struct usb_device *usb_dev = to_usb_device_intf(rt2x00dev->dev);
        struct queue_entry_priv_usb_bcn *bcn_priv = entry->priv_data;
-       struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
        int pipe = usb_sndbulkpipe(usb_dev, entry->queue->usb_endpoint);
        int length;
-       u16 reg;
-
-       /*
-        * Add the descriptor in front of the skb.
-        */
-       skb_push(entry->skb, entry->queue->desc_size);
-       memcpy(entry->skb->data, skbdesc->desc, skbdesc->desc_len);
-       skbdesc->desc = entry->skb->data;
+       u16 reg, reg0;
 
        /*
         * Disable beaconing while we are reloading the beacon data,
@@ -1108,6 +1108,11 @@ static void rt2500usb_write_beacon(struct queue_entry *entry)
        rt2500usb_register_write(rt2x00dev, TXRX_CSR19, reg);
 
        /*
+        * Take the descriptor in front of the skb into account.
+        */
+       skb_push(entry->skb, TXD_DESC_SIZE);
+
+       /*
         * USB devices cannot blindly pass the skb->len as the
         * length of the data to usb_fill_bulk_urb. Pass the skb
         * to the driver to determine what the length should be.
@@ -1132,6 +1137,26 @@ static void rt2500usb_write_beacon(struct queue_entry *entry)
         * Send out the guardian byte.
         */
        usb_submit_urb(bcn_priv->guardian_urb, GFP_ATOMIC);
+
+       /*
+        * Enable beaconing again.
+        */
+       rt2x00_set_field16(&reg, TXRX_CSR19_TSF_COUNT, 1);
+       rt2x00_set_field16(&reg, TXRX_CSR19_TBCN, 1);
+       reg0 = reg;
+       rt2x00_set_field16(&reg, TXRX_CSR19_BEACON_GEN, 1);
+       /*
+        * Beacon generation will fail initially.
+        * To prevent this we need to change the TXRX_CSR19
+        * register several times (reg0 is the same as reg
+        * except for TXRX_CSR19_BEACON_GEN, which is 0 in reg0
+        * and 1 in reg).
+        */
+       rt2500usb_register_write(rt2x00dev, TXRX_CSR19, reg);
+       rt2500usb_register_write(rt2x00dev, TXRX_CSR19, reg0);
+       rt2500usb_register_write(rt2x00dev, TXRX_CSR19, reg);
+       rt2500usb_register_write(rt2x00dev, TXRX_CSR19, reg0);
+       rt2500usb_register_write(rt2x00dev, TXRX_CSR19, reg);
 }
 
 static int rt2500usb_get_tx_data_len(struct queue_entry *entry)
@@ -1148,37 +1173,6 @@ static int rt2500usb_get_tx_data_len(struct queue_entry *entry)
        return length;
 }
 
-static void rt2500usb_kick_tx_queue(struct rt2x00_dev *rt2x00dev,
-                                   const enum data_queue_qid queue)
-{
-       u16 reg, reg0;
-
-       if (queue != QID_BEACON) {
-               rt2x00usb_kick_tx_queue(rt2x00dev, queue);
-               return;
-       }
-
-       rt2500usb_register_read(rt2x00dev, TXRX_CSR19, &reg);
-       if (!rt2x00_get_field16(reg, TXRX_CSR19_BEACON_GEN)) {
-               rt2x00_set_field16(&reg, TXRX_CSR19_TSF_COUNT, 1);
-               rt2x00_set_field16(&reg, TXRX_CSR19_TBCN, 1);
-               reg0 = reg;
-               rt2x00_set_field16(&reg, TXRX_CSR19_BEACON_GEN, 1);
-               /*
-                * Beacon generation will fail initially.
-                * To prevent this we need to change the TXRX_CSR19
-                * register several times (reg0 is the same as reg
-                * except for TXRX_CSR19_BEACON_GEN, which is 0 in reg0
-                * and 1 in reg).
-                */
-               rt2500usb_register_write(rt2x00dev, TXRX_CSR19, reg);
-               rt2500usb_register_write(rt2x00dev, TXRX_CSR19, reg0);
-               rt2500usb_register_write(rt2x00dev, TXRX_CSR19, reg);
-               rt2500usb_register_write(rt2x00dev, TXRX_CSR19, reg0);
-               rt2500usb_register_write(rt2x00dev, TXRX_CSR19, reg);
-       }
-}
-
 /*
  * RX control handlers
  */
@@ -1213,11 +1207,9 @@ static void rt2500usb_fill_rxdone(struct queue_entry *entry,
        if (rt2x00_get_field32(word0, RXD_W0_PHYSICAL_ERROR))
                rxdesc->flags |= RX_FLAG_FAILED_PLCP_CRC;
 
-       if (test_bit(CONFIG_SUPPORT_HW_CRYPTO, &rt2x00dev->flags)) {
-               rxdesc->cipher = rt2x00_get_field32(word0, RXD_W0_CIPHER);
-               if (rt2x00_get_field32(word0, RXD_W0_CIPHER_ERROR))
-                       rxdesc->cipher_status = RX_CRYPTO_FAIL_KEY;
-       }
+       rxdesc->cipher = rt2x00_get_field32(word0, RXD_W0_CIPHER);
+       if (rt2x00_get_field32(word0, RXD_W0_CIPHER_ERROR))
+               rxdesc->cipher_status = RX_CRYPTO_FAIL_KEY;
 
        if (rxdesc->cipher != CIPHER_NONE) {
                _rt2x00_desc_read(rxd, 2, &rxdesc->iv[0]);
@@ -1647,11 +1639,6 @@ static int rt2500usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
        unsigned int i;
 
        /*
-        * Disable powersaving as default.
-        */
-       rt2x00dev->hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
-
-       /*
         * Initialize all hw fields.
         */
        rt2x00dev->hw->flags =
@@ -1784,7 +1771,7 @@ static const struct rt2x00lib_ops rt2500usb_rt2x00_ops = {
        .write_tx_data          = rt2x00usb_write_tx_data,
        .write_beacon           = rt2500usb_write_beacon,
        .get_tx_data_len        = rt2500usb_get_tx_data_len,
-       .kick_tx_queue          = rt2500usb_kick_tx_queue,
+       .kick_tx_queue          = rt2x00usb_kick_tx_queue,
        .kill_tx_queue          = rt2x00usb_kill_tx_queue,
        .fill_rxdone            = rt2500usb_fill_rxdone,
        .config_shared_key      = rt2500usb_config_key,