rt2x00: Simplify TXD handling of beacons.
authorGertjan van Wingerde <gwingerde@gmail.com>
Tue, 11 May 2010 21:51:40 +0000 (23:51 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Wed, 12 May 2010 20:41:44 +0000 (16:41 -0400)
The handling of tx descriptors for beacons can be simplified by updating
write_tx_desc implementations of each driver to write directly to the
queue entry descriptor instead of to a provided memory area.
This is also a preparation for further clean ups where descriptors are
properly reserved in the skb instead of fiddling with the skb data
pointer.

Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/rt2x00/rt2400pci.c
drivers/net/wireless/rt2x00/rt2500pci.c
drivers/net/wireless/rt2x00/rt2500usb.c
drivers/net/wireless/rt2x00/rt2800pci.c
drivers/net/wireless/rt2x00/rt2800usb.c
drivers/net/wireless/rt2x00/rt2x00pci.c
drivers/net/wireless/rt2x00/rt2x00queue.c
drivers/net/wireless/rt2x00/rt2x00usb.c
drivers/net/wireless/rt2x00/rt61pci.c
drivers/net/wireless/rt2x00/rt73usb.c

index 1eff6ec884578b95dccc64a8dfd35c83112117f3..def3fa45ae7ad20a7d743b78204aab0945d39158 100644 (file)
@@ -1006,15 +1006,15 @@ static void rt2400pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,
 {
        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;
+       __le32 *txd = entry_priv->desc;
        u32 word;
 
        /*
         * Start writing the descriptor words.
         */
-       rt2x00_desc_read(entry_priv->desc, 1, &word);
+       rt2x00_desc_read(txd, 1, &word);
        rt2x00_set_field32(&word, TXD_W1_BUFFER_ADDRESS, skbdesc->skb_dma);
-       rt2x00_desc_write(entry_priv->desc, 1, word);
+       rt2x00_desc_write(txd, 1, word);
 
        rt2x00_desc_read(txd, 2, &word);
        rt2x00_set_field32(&word, TXD_W2_BUFFER_LENGTH, txdesc->length);
@@ -1059,6 +1059,12 @@ static void rt2400pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,
        rt2x00_set_field32(&word, TXD_W0_RETRY_MODE,
                           test_bit(ENTRY_TXD_RETRY_MODE, &txdesc->flags));
        rt2x00_desc_write(txd, 0, word);
+
+       /*
+        * Register descriptor details in skb frame descriptor.
+        */
+       skbdesc->desc = txd;
+       skbdesc->desc_len = TXD_DESC_SIZE;
 }
 
 /*
@@ -1081,15 +1087,6 @@ static void rt2400pci_write_beacon(struct queue_entry *entry,
        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);
index 8d3e95e0dcfe5c0eba1b94d2d516b40f49f01a14..070c23ed4013525d0182067415bf851b015b2e55 100644 (file)
@@ -1164,15 +1164,15 @@ static void rt2500pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,
 {
        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;
+       __le32 *txd = entry_priv->desc;
        u32 word;
 
        /*
         * Start writing the descriptor words.
         */
-       rt2x00_desc_read(entry_priv->desc, 1, &word);
+       rt2x00_desc_read(txd, 1, &word);
        rt2x00_set_field32(&word, TXD_W1_BUFFER_ADDRESS, skbdesc->skb_dma);
-       rt2x00_desc_write(entry_priv->desc, 1, word);
+       rt2x00_desc_write(txd, 1, word);
 
        rt2x00_desc_read(txd, 2, &word);
        rt2x00_set_field32(&word, TXD_W2_IV_OFFSET, IEEE80211_HEADER);
@@ -1216,6 +1216,12 @@ static void rt2500pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,
        rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, txdesc->length);
        rt2x00_set_field32(&word, TXD_W0_CIPHER_ALG, CIPHER_NONE);
        rt2x00_desc_write(txd, 0, word);
+
+       /*
+        * Register descriptor details in skb frame descriptor.
+        */
+       skbdesc->desc = txd;
+       skbdesc->desc_len = TXD_DESC_SIZE;
 }
 
 /*
@@ -1238,15 +1244,6 @@ static void rt2500pci_write_beacon(struct queue_entry *entry,
        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);
index 9a915be547b3346a6c26baf407b4a9d39a390d3f..b985d8f8cc6ed615ebee0aa6f1d572e1e7370327 100644 (file)
@@ -1033,7 +1033,7 @@ 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;
 
        /*
@@ -1075,6 +1075,12 @@ static void rt2500usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,
                _rt2x00_desc_write(txd, 3, skbdesc->iv[0]);
                _rt2x00_desc_write(txd, 4, skbdesc->iv[1]);
        }
+
+       /*
+        * Register descriptor details in skb frame descriptor.
+        */
+       skbdesc->desc = txd;
+       skbdesc->desc_len = TXD_DESC_SIZE;
 }
 
 /*
@@ -1088,18 +1094,10 @@ static void rt2500usb_write_beacon(struct queue_entry *entry,
        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, reg0;
 
-       /*
-        * 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;
-
        /*
         * Disable beaconing while we are reloading the beacon data,
         * otherwise we might be sending out invalid data.
@@ -1108,6 +1106,11 @@ static void rt2500usb_write_beacon(struct queue_entry *entry,
        rt2x00_set_field16(&reg, TXRX_CSR19_BEACON_GEN, 0);
        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
index 7d4778d66e77b2040104617fddc7fc8d9da28993..b2f23272c3aae3efa74524f10b894bc88d521637 100644 (file)
@@ -633,7 +633,8 @@ static void rt2800pci_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;
+       struct queue_entry_priv_pci *entry_priv = skbdesc->entry->priv_data;
+       __le32 *txd = entry_priv->desc;
        u32 word;
 
        /*
@@ -657,15 +658,14 @@ static void rt2800pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,
                           !test_bit(ENTRY_TXD_MORE_FRAG, &txdesc->flags));
        rt2x00_set_field32(&word, TXD_W1_BURST,
                           test_bit(ENTRY_TXD_BURST, &txdesc->flags));
-       rt2x00_set_field32(&word, TXD_W1_SD_LEN0,
-                          rt2x00dev->ops->extra_tx_headroom);
+       rt2x00_set_field32(&word, TXD_W1_SD_LEN0, TXWI_DESC_SIZE);
        rt2x00_set_field32(&word, TXD_W1_LAST_SEC0, 0);
        rt2x00_set_field32(&word, TXD_W1_DMA_DONE, 0);
        rt2x00_desc_write(txd, 1, word);
 
        rt2x00_desc_read(txd, 2, &word);
        rt2x00_set_field32(&word, TXD_W2_SD_PTR1,
-                          skbdesc->skb_dma + rt2x00dev->ops->extra_tx_headroom);
+                          skbdesc->skb_dma + TXWI_DESC_SIZE);
        rt2x00_desc_write(txd, 2, word);
 
        rt2x00_desc_read(txd, 3, &word);
@@ -673,6 +673,12 @@ static void rt2800pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,
                           !test_bit(ENTRY_TXD_ENCRYPT_IV, &txdesc->flags));
        rt2x00_set_field32(&word, TXD_W3_QSEL, 2);
        rt2x00_desc_write(txd, 3, word);
+
+       /*
+        * Register descriptor details in skb frame descriptor.
+        */
+       skbdesc->desc = txd;
+       skbdesc->desc_len = TXD_DESC_SIZE;
 }
 
 /*
index d48d705d1808548d7a5b0704810ce72cae8f5bf3..1b87daa1945694e90b242a3a6340df17253271ba 100644 (file)
@@ -400,7 +400,7 @@ static void rt2800usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,
                                    struct txentry_desc *txdesc)
 {
        struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb);
-       __le32 *txi = skbdesc->desc;
+       __le32 *txi = (__le32 *)(skb->data - TXWI_DESC_SIZE - TXINFO_DESC_SIZE);
        u32 word;
 
        /*
@@ -422,6 +422,12 @@ static void rt2800usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,
        rt2x00_set_field32(&word, TXINFO_W0_USB_DMA_TX_BURST,
                           test_bit(ENTRY_TXD_BURST, &txdesc->flags));
        rt2x00_desc_write(txi, 0, word);
+
+       /*
+        * Register descriptor details in skb frame descriptor.
+        */
+       skbdesc->desc = txi;
+       skbdesc->desc_len = TXINFO_DESC_SIZE + TXWI_DESC_SIZE;
 }
 
 /*
index 2fe9f295351f2b6809d28033fcd270aaade7284f..ff80ef710d4eb25edced0eda6d020d4d6243f658 100644 (file)
@@ -66,8 +66,6 @@ int rt2x00pci_write_tx_data(struct queue_entry *entry,
                            struct txentry_desc *txdesc)
 {
        struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
-       struct queue_entry_priv_pci *entry_priv = entry->priv_data;
-       struct skb_frame_desc *skbdesc;
 
        /*
         * This should not happen, we already checked the entry
@@ -82,13 +80,6 @@ int rt2x00pci_write_tx_data(struct queue_entry *entry,
                return -EINVAL;
        }
 
-       /*
-        * Fill in skb descriptor
-        */
-       skbdesc = get_skb_frame_desc(entry->skb);
-       skbdesc->desc = entry_priv->desc;
-       skbdesc->desc_len = entry->queue->desc_size;
-
        return 0;
 }
 EXPORT_SYMBOL_GPL(rt2x00pci_write_tx_data);
index 97b2c76506560cb5b5f13bd50d8d33854405f22c..891d5f72716ecdd70d5bb69b03364a560ed5debf 100644 (file)
@@ -552,7 +552,6 @@ int rt2x00queue_update_beacon(struct rt2x00_dev *rt2x00dev,
        struct rt2x00_intf *intf = vif_to_intf(vif);
        struct skb_frame_desc *skbdesc;
        struct txentry_desc txdesc;
-       __le32 desc[16];
 
        if (unlikely(!intf->beacon))
                return -ENOBUFS;
@@ -584,20 +583,11 @@ int rt2x00queue_update_beacon(struct rt2x00_dev *rt2x00dev,
         */
        rt2x00queue_create_tx_descriptor(intf->beacon, &txdesc);
 
-       /*
-        * For the descriptor we use a local array from where the
-        * driver can move it to the correct location required for
-        * the hardware.
-        */
-       memset(desc, 0, sizeof(desc));
-
        /*
         * Fill in skb descriptor
         */
        skbdesc = get_skb_frame_desc(intf->beacon->skb);
        memset(skbdesc, 0, sizeof(*skbdesc));
-       skbdesc->desc = desc;
-       skbdesc->desc_len = intf->beacon->queue->desc_size;
        skbdesc->entry = intf->beacon;
 
        /*
index acf3282fc13e10aca74932705c9b8e5fb5083736..a4f0551422aeb58c40c39c39c3dce3d50ac939ed 100644 (file)
@@ -221,7 +221,6 @@ int rt2x00usb_write_tx_data(struct queue_entry *entry,
        struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
        struct usb_device *usb_dev = to_usb_device_intf(rt2x00dev->dev);
        struct queue_entry_priv_usb *entry_priv = entry->priv_data;
-       struct skb_frame_desc *skbdesc;
        u32 length;
 
        /*
@@ -230,13 +229,6 @@ int rt2x00usb_write_tx_data(struct queue_entry *entry,
        skb_push(entry->skb, entry->queue->desc_size);
        memset(entry->skb->data, 0, entry->queue->desc_size);
 
-       /*
-        * Fill in skb descriptor
-        */
-       skbdesc = get_skb_frame_desc(entry->skb);
-       skbdesc->desc = entry->skb->data;
-       skbdesc->desc_len = entry->queue->desc_size;
-
        /*
         * USB devices cannot blindly pass the skb->len as the
         * length of the data to usb_fill_bulk_urb. Pass the skb
index 55aa010aeee284a1a24210c838d8a95e886634fe..1be1d7d585d84545513cf32d12fe323ac0b9f0a2 100644 (file)
@@ -1763,7 +1763,8 @@ static void rt61pci_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;
+       struct queue_entry_priv_pci *entry_priv = skbdesc->entry->priv_data;
+       __le32 *txd = entry_priv->desc;
        u32 word;
 
        /*
@@ -1842,6 +1843,13 @@ static void rt61pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,
                           test_bit(ENTRY_TXD_BURST, &txdesc->flags));
        rt2x00_set_field32(&word, TXD_W0_CIPHER_ALG, txdesc->cipher);
        rt2x00_desc_write(txd, 0, word);
+
+       /*
+        * Register descriptor details in skb frame descriptor.
+        */
+       skbdesc->desc = txd;
+       skbdesc->desc_len =
+               (txdesc->queue == QID_BEACON) ?  TXINFO_SIZE : TXD_DESC_SIZE;
 }
 
 /*
@@ -1851,7 +1859,7 @@ static void rt61pci_write_beacon(struct queue_entry *entry,
                                 struct txentry_desc *txdesc)
 {
        struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
-       struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
+       struct queue_entry_priv_pci *entry_priv = entry->priv_data;
        unsigned int beacon_base;
        u32 reg;
 
@@ -1867,11 +1875,9 @@ static void rt61pci_write_beacon(struct queue_entry *entry,
         * Write entire beacon with descriptor to register.
         */
        beacon_base = HW_BEACON_OFFSET(entry->entry_idx);
-       rt2x00pci_register_multiwrite(rt2x00dev,
-                                     beacon_base,
-                                     skbdesc->desc, skbdesc->desc_len);
-       rt2x00pci_register_multiwrite(rt2x00dev,
-                                     beacon_base + skbdesc->desc_len,
+       rt2x00pci_register_multiwrite(rt2x00dev, beacon_base,
+                                     entry_priv->desc, TXINFO_SIZE);
+       rt2x00pci_register_multiwrite(rt2x00dev, beacon_base + TXINFO_SIZE,
                                      entry->skb->data, entry->skb->len);
 
        /*
index fa40d434e7296f41ddd5f5356fdc20adb43f46d9..fca661c2e2a3dd8190e4a2dce745740a4d0ef273 100644 (file)
@@ -1440,7 +1440,7 @@ static void rt73usb_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;
 
        /*
@@ -1499,6 +1499,12 @@ static void rt73usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,
                           TXPOWER_TO_DEV(rt2x00dev->tx_power));
        rt2x00_set_field32(&word, TXD_W5_WAITING_DMA_DONE_INT, 1);
        rt2x00_desc_write(txd, 5, word);
+
+       /*
+        * Register descriptor details in skb frame descriptor.
+        */
+       skbdesc->desc = txd;
+       skbdesc->desc_len = TXD_DESC_SIZE;
 }
 
 /*
@@ -1508,17 +1514,9 @@ static void rt73usb_write_beacon(struct queue_entry *entry,
                                 struct txentry_desc *txdesc)
 {
        struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
-       struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
        unsigned int beacon_base;
        u32 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;
-
        /*
         * Disable beaconing while we are reloading the beacon data,
         * otherwise we might be sending out invalid data.
@@ -1527,6 +1525,11 @@ static void rt73usb_write_beacon(struct queue_entry *entry,
        rt2x00_set_field32(&reg, TXRX_CSR9_BEACON_GEN, 0);
        rt2x00usb_register_write(rt2x00dev, TXRX_CSR9, reg);
 
+       /*
+        * Take the descriptor in front of the skb into account.
+        */
+       skb_push(entry->skb, TXD_DESC_SIZE);
+
        /*
         * Write entire beacon with descriptor to register.
         */