1 From: Stanislaw Gruszka <sgruszka@redhat.com>
2 Date: Sun, 2 Nov 2014 13:38:47 +0100
3 Subject: [PATCH] rt2x00: do not align payload on modern H/W
5 RT2800 and newer hardware require padding between header and payload if
6 header length is not multiple of 4.
8 For historical reasons we also align payload to to 4 bytes boundary, but
9 such alignment is not needed on modern H/W.
11 Patch improve performance on embedded CPUs and _possibly_ fixes
12 skb_under_panic problems reported from time to time:
14 https://bugzilla.kernel.org/show_bug.cgi?id=84911
15 https://bugzilla.kernel.org/show_bug.cgi?id=72471
16 http://marc.info/?l=linux-wireless&m=139108549530402&w=2
17 https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1087591
19 But we can not explain or otherwise confirm the patch fixes this panic
22 Originally-From: Helmut Schaa <helmut.schaa@googlemail.com>
23 Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
26 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
27 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
28 @@ -158,55 +158,29 @@ void rt2x00queue_align_frame(struct sk_b
29 skb_trim(skb, frame_length);
32 -void rt2x00queue_insert_l2pad(struct sk_buff *skb, unsigned int header_length)
34 + * H/W needs L2 padding between the header and the paylod if header size
35 + * is not 4 bytes aligned.
37 +void rt2x00queue_insert_l2pad(struct sk_buff *skb, unsigned int hdr_len)
39 - unsigned int payload_length = skb->len - header_length;
40 - unsigned int header_align = ALIGN_SIZE(skb, 0);
41 - unsigned int payload_align = ALIGN_SIZE(skb, header_length);
42 - unsigned int l2pad = payload_length ? L2PAD_SIZE(header_length) : 0;
43 + unsigned int l2pad = (skb->len > hdr_len) ? L2PAD_SIZE(hdr_len) : 0;
46 - * Adjust the header alignment if the payload needs to be moved more
49 - if (payload_align > header_align)
52 - /* There is nothing to do if no alignment is needed */
57 - /* Reserve the amount of space needed in front of the frame */
58 - skb_push(skb, header_align);
63 - memmove(skb->data, skb->data + header_align, header_length);
65 - /* Move the payload, if present and if required */
66 - if (payload_length && payload_align)
67 - memmove(skb->data + header_length + l2pad,
68 - skb->data + header_length + l2pad + payload_align,
71 - /* Trim the skb to the correct size */
72 - skb_trim(skb, header_length + l2pad + payload_length);
73 + skb_push(skb, l2pad);
74 + memmove(skb->data, skb->data + l2pad, hdr_len);
77 -void rt2x00queue_remove_l2pad(struct sk_buff *skb, unsigned int header_length)
78 +void rt2x00queue_remove_l2pad(struct sk_buff *skb, unsigned int hdr_len)
81 - * L2 padding is only present if the skb contains more than just the
82 - * IEEE 802.11 header.
84 - unsigned int l2pad = (skb->len > header_length) ?
85 - L2PAD_SIZE(header_length) : 0;
86 + unsigned int l2pad = (skb->len > hdr_len) ? L2PAD_SIZE(hdr_len) : 0;
91 - memmove(skb->data + l2pad, skb->data, header_length);
92 + memmove(skb->data + l2pad, skb->data, hdr_len);