[rt2x00-users] RT2800USB fail to ping WMM AP

fengche n2795130 at mail.ncku.edu.tw
Thu Apr 2 12:26:41 CDT 2009


Hi,

Here is a patch for rt2800usb to fix the problem when ping WMM AP.

I found that the 802.11 header in RT2870 must be 4 byte aligned.

If we enable wmm, the qos field will be added to 802.11 header.
The header length will change from 24 to 26.
So we must add padding bytes for header.

Note that the TXWI_W1_MPDU_TOTAL_BYTE_COUNT should not containing padding
byte.


diff -ur a/rt2800usb.c b/rt2800usb.c
--- a/rt2800usb.c       2009-03-31 11:37:53.000000000 +0800
+++ b/rt2800usb.c       2009-04-03 01:12:41.000000000 +0800
@@ -1976,6 +1976,7 @@
        __le32 *txi = skbdesc->desc;
        __le32 *txwi = &txi[TXINFO_DESC_SIZE / sizeof(__le32)];
        u32 word;
+       struct queue_entry_priv_usb *entry_priv = skbdesc->entry->priv_data;

        /*
         * Initialize TX Info descriptor
@@ -2009,11 +2010,13 @@
        rt2x00_set_field32(&word, TXWI_W1_WIRELESS_CLI_ID,
                           test_bit(ENTRY_TXD_ENCRYPT, &txdesc->flags) ?
                               txdesc->key_idx : 0xff);
-       rt2x00_set_field32(&word, TXWI_W1_MPDU_TOTAL_BYTE_COUNT, skb->len);
+       /*
+        * TXWI_W1_MPDU_TOTAL_BYTE_COUNT should not contain header padding.
+        */
+       rt2x00_set_field32(&word, TXWI_W1_MPDU_TOTAL_BYTE_COUNT, skb->len -
entry_priv->hdr_padding);
        rt2x00_set_field32(&word, TXWI_W1_PACKETID,
                           skbdesc->entry->entry_idx);
        rt2x00_desc_write(txwi, 1, word);
-
        /*
         * Always write 0 to IV/EIV fields, hardware will insert the IV
         * from the IVEIV register when TXINFO_W0_WIV is set to 0.
@@ -2086,7 +2089,20 @@
 static int rt2800usb_get_tx_data_len(struct queue_entry *entry)
 {
        int length;
-
+       int hdr_len = 0;
+       struct ieee80211_hdr *hdr = (struct ieee80211_hdr
*)(entry->skb->data + entry->queue->desc_size);
+       struct skb_frame_desc *skbdesc;
+       struct queue_entry_priv_usb *entry_priv = entry->priv_data;
+
+       hdr_len = ieee80211_hdrlen(hdr->frame_control);
+       entry_priv->hdr_padding = (roundup((unsigned int)hdr,4)  - (unsigned
int)hdr);
+       if(entry_priv->hdr_padding > 0){
+               skb_push(entry->skb,entry_priv->hdr_padding);
+               memmove(entry->skb->data,(unsigned char *)(entry->skb->data
+ entry_priv->hdr_padding),
+                               hdr_len + entry->queue->desc_size);
+               skbdesc = get_skb_frame_desc(entry->skb);
+               skbdesc->desc = entry->skb->data;
+       }
        /*
         * The length _must_ include 4 bytes padding,
         * it should always be multiple of 4,
@@ -2132,7 +2148,17 @@
        u32 rxwi1;
        u32 rxwi2;
        u32 rxwi3;
-
+       struct ieee80211_hdr *hdr = (struct ieee80211_hdr
*)(entry->skb->data + skbdesc->desc_len);
+       int hdr_len = 0;
+       int padding = 0;
+
+       hdr_len = ieee80211_hdrlen(hdr->frame_control);;
+       padding = hdr_len & 3;
+       if(padding > 0){
+               memmove(entry->skb->data + padding,entry->skb->data,hdr_len
+ skbdesc->desc_len);
+               skb_pull(entry->skb, padding);
+               rxd = (__le32 *)entry->skb->data;
+       }
        /*
         * Copy descriptor to the skbdesc->desc buffer, making it safe from
         * moving of frame data in rt2x00usb.
@@ -2189,7 +2215,6 @@
        rxdesc->dev_flags |= RXDONE_SIGNAL_MCS;
        rxdesc->rate_mode = rt2x00_get_field32(rxwi1, RXWI_W1_PHYMODE);
        rxdesc->signal = rt2x00_get_field32(rxwi1, RXWI_W1_MCS);
-
        /*
         * Mask of 0x8 bit to remove the short preamble flag.
         */
diff -ur a/rt2x00usb.h b/rt2x00usb.h
--- a/rt2x00usb.h       2009-03-31 11:37:53.000000000 +0800
+++ b/rt2x00usb.h       2009-04-03 01:13:43.000000000 +0800
@@ -388,6 +388,7 @@
  */
 struct queue_entry_priv_usb {
        struct urb *urb;
+       int hdr_padding;
 };

 /**

regards,
fengche
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rt2x00.serialmonkey.com/pipermail/users_rt2x00.serialmonkey.com/attachments/20090403/870963f4/attachment.html>


More information about the users mailing list