Send users mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        
http://rt2x00.serialmonkey.com/mailman/listinfo/users_rt2x00.serialmonkey.com

or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of users digest..."


Today's Topics:

   1. Re: [RFC] rt2800usb: remove usb pad after transmission
      (Jakub Kici?ski)
   2. Re: [RFC] Rework handling of usb padding (Jakub Kici?ski)


----------------------------------------------------------------------

Message: 1
Date: Mon, 19 Dec 2011 14:52:20 +0100
From: Jakub Kici?ski <[email protected]>
To: Helmut Schaa <[email protected]>
Cc: [email protected]
Subject: Re: [rt2x00-users] [RFC] rt2800usb: remove usb pad after
        transmission
Message-ID: <20111219145220.38ebf00c@north>
Content-Type: text/plain; charset=US-ASCII

Hi,

On Mon, 19 Dec 2011 10:00:37 +0100
Helmut Schaa <[email protected]> wrote:

> Hi,
> 
> On Mon, Dec 19, 2011 at 9:50 AM, Ivo Van Doorn <[email protected]> wrote:
> >> Isnt't entry->priv_data also used in the generic rt2x00 USB parts 
> >> (rt2x00usb.c)
> >> but casted to queue_entry_priv_usb. So this needs a comment why it doesn't
> >> break the generic USB routines ...
> >
> > Isn't this something which should be done in the rt2x00usb generic code 
> > anyway?
> 
> No objections from my side, is padding also used in older USB drivers?

Actually older drivers seem not to physically add this padding to skb just pass
something bigger than skb->length to usb_fill_bulk_urb as buffer_length. This 
way 
we don't have to remove padding after transmission but there is slight 
possibility 
of reading past skb->end (am I wrong?). Also that padding is not zeroed.

End padding in rt2800usb was introduced by:

commit b43d63bd69ae5464a52bf1796e84097607917b2f
Author: RA-Jay Hung <[email protected]>
Date:   Sat Nov 13 19:11:46 2010 +0100

    rt2x00: Fix rt2800 USB TX Path DMA issue

Should I revert rt2800usb's behaviour back to what older drivers did and adjust 
how
padding is handled in rt2x00usb_kick_tx_entry? To be honest I don't have any of 
the 
older devices, so I won't know when I break something for them.

> > Also how about the padding in the PCI drivers (if any)?
> 
> There seems to be no padding required for the PCI versions AFAIK.

I haven't found any padding at the end of frames in PCI code either.

  -- Kuba



------------------------------

Message: 2
Date: Mon, 19 Dec 2011 23:28:14 +0100
From: Jakub Kici?ski <[email protected]>
To: Ivo Van Doorn <[email protected]>, Helmut Schaa
        <[email protected]>
Cc: [email protected]
Subject: Re: [rt2x00-users] [RFC] Rework handling of usb padding
Message-ID: <20111219232814.34070bfd@north>
Content-Type: text/plain; charset=US-ASCII

Hello,

this patch kind of handles the padding in generic rt2x00usb code.

---

USB devices require padding at the end of frames and URBs. Drivers should not
add those paddings to skb, but take them into account in calculations in
get_tx_data_len callback.

Older drivers already work in that way, make rt2800usb follow this scheme 
as well. Also make sure padding is zeroed before sending URB.

Signed-off-by: Jakub Kicinski <[email protected]>
---

 drivers/net/wireless/rt2x00/rt2800usb.c |   37 ++++++++----------------------
 drivers/net/wireless/rt2x00/rt2x00usb.c |   20 ++++++++++++++--
 2 files changed, 27 insertions(+), 30 deletions(-)

diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c 
b/drivers/net/wireless/rt2x00/rt2800usb.c
index 3778763..3c4b88c 100644
--- a/drivers/net/wireless/rt2x00/rt2800usb.c
+++ b/drivers/net/wireless/rt2x00/rt2800usb.c
@@ -400,10 +400,10 @@ static void rt2800usb_write_tx_desc(struct queue_entry 
*entry,
        /*
         * The size of TXINFO_W0_USB_DMA_TX_PKT_LEN is
         * TXWI + 802.11 header + L2 pad + payload + pad,
-        * so need to decrease size of TXINFO and USB end pad.
+        * so need to decrease size of TXINFO.
         */
        rt2x00_set_field32(&word, TXINFO_W0_USB_DMA_TX_PKT_LEN,
-                          entry->skb->len - TXINFO_DESC_SIZE - 4);
+                          roundup(entry->skb->len, 4) - TXINFO_DESC_SIZE);
        rt2x00_set_field32(&word, TXINFO_W0_WIV,
                           !test_bit(ENTRY_TXD_ENCRYPT_IV, &txdesc->flags));
        rt2x00_set_field32(&word, TXINFO_W0_QSEL, 2);
@@ -421,37 +421,20 @@ static void rt2800usb_write_tx_desc(struct queue_entry 
*entry,
        skbdesc->desc_len = TXINFO_DESC_SIZE + TXWI_DESC_SIZE;
 }
 
-static void rt2800usb_write_tx_data(struct queue_entry *entry,
-                                       struct txentry_desc *txdesc)
+/*
+ * TX data initialization
+ */
+static int rt2800usb_get_tx_data_len(struct queue_entry *entry)
 {
-       unsigned int len;
-       int err;
-
-       rt2800_write_tx_data(entry, txdesc);
-
        /*
-        * pad(1~3 bytes) is added after each 802.11 payload.
-        * USB end pad(4 bytes) is added at each USB bulk out packet end.
+        * pad(1~3 bytes) is needed after each 802.11 payload.
+        * USB end pad(4 bytes) is needed at each USB bulk out packet end.
         * TX frame format is :
         * | TXINFO | TXWI | 802.11 header | L2 pad | payload | pad | USB end 
pad |
         *                 |<------------- tx_pkt_len ------------->|
         */
-       len = roundup(entry->skb->len, 4) + 4;
-       err = skb_padto(entry->skb, len);
-       if (unlikely(err)) {
-               WARNING(entry->queue->rt2x00dev, "TX SKB padding error, out of 
memory\n");
-               return;
-       }
 
-       entry->skb->len = len;
-}
-
-/*
- * TX data initialization
- */
-static int rt2800usb_get_tx_data_len(struct queue_entry *entry)
-{
-       return entry->skb->len;
+       return roundup(entry->skb->len, 4) + 4;
 }
 
 /*
@@ -807,7 +790,7 @@ static const struct rt2x00lib_ops rt2800usb_rt2x00_ops = {
        .flush_queue            = rt2x00usb_flush_queue,
        .tx_dma_done            = rt2800usb_tx_dma_done,
        .write_tx_desc          = rt2800usb_write_tx_desc,
-       .write_tx_data          = rt2800usb_write_tx_data,
+       .write_tx_data          = rt2800_write_tx_data,
        .write_beacon           = rt2800_write_beacon,
        .clear_beacon           = rt2800_clear_beacon,
        .get_tx_data_len        = rt2800usb_get_tx_data_len,
diff --git a/drivers/net/wireless/rt2x00/rt2x00usb.c 
b/drivers/net/wireless/rt2x00/rt2x00usb.c
index 1e31050..5dfa1a8 100644
--- a/drivers/net/wireless/rt2x00/rt2x00usb.c
+++ b/drivers/net/wireless/rt2x00/rt2x00usb.c
@@ -298,12 +298,26 @@ static bool rt2x00usb_kick_tx_entry(struct queue_entry 
*entry, void* data)
                return false;
 
        /*
-        * 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.
+        * USB devices require certain padding at the end of each frame
+        * and urb. Those paddings are not included in skbs. Pass entry
+        * to the driver to determine what the overall length should be.
         */
        length = rt2x00dev->ops->lib->get_tx_data_len(entry);
 
+       status = skb_padto(entry->skb, length);
+       if (unlikely(status)) {
+               /*
+                * Transmission of this frame should fail, because we
+                * shouldn't leave frames in queue and hope that someone
+                * will kick it again in the future.
+                */
+               WARNING(rt2x00dev, "TX SKB padding error, out of memory\n");
+               set_bit(ENTRY_DATA_IO_FAILED, &entry->flags);
+               rt2x00lib_dmadone(entry);
+
+               return false;
+       }
+
        usb_fill_bulk_urb(entry_priv->urb, usb_dev,
                          usb_sndbulkpipe(usb_dev, entry->queue->usb_endpoint),
                          entry->skb->data, length,



------------------------------

_______________________________________________
users mailing list
[email protected]
http://rt2x00.serialmonkey.com/mailman/listinfo/users_rt2x00.serialmonkey.com


End of users Digest, Vol 34, Issue 7
************************************

Reply via email to