* [PATCH] Fix tx transfer padding for full-speed USB
@ 2012-04-20 10:00 Ingo van Lil
2012-04-24 4:28 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: Ingo van Lil @ 2012-04-20 10:00 UTC (permalink / raw)
To: netdev; +Cc: Ingo van Lil
The asix.c USB Ethernet driver avoids ending a tx transfer with a zero-
length packet by appending a four-byte padding to transfers whose length
is a multiple of maxpacket. However, the hard-coded 512 byte maxpacket
length is valid for high-speed USB only; full-speed USB uses 64 byte
packets.
Signed-off-by: Ingo van Lil <inguin@gmx.de>
---
drivers/net/usb/asix.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c
index 5ee032c..aeb2702 100644
--- a/drivers/net/usb/asix.c
+++ b/drivers/net/usb/asix.c
@@ -355,7 +355,7 @@ static struct sk_buff *asix_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
u32 packet_len;
u32 padbytes = 0xffff0000;
- padlen = ((skb->len + 4) % 512) ? 0 : 4;
+ padlen = ((skb->len + 4) % dev->maxpacket) ? 0 : 4;
if ((!skb_cloned(skb)) &&
((headroom + tailroom) >= (4 + padlen))) {
@@ -377,7 +377,7 @@ static struct sk_buff *asix_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
cpu_to_le32s(&packet_len);
skb_copy_to_linear_data(skb, &packet_len, sizeof(packet_len));
- if ((skb->len % 512) == 0) {
+ if (padlen) {
cpu_to_le32s(&padbytes);
memcpy(skb_tail_pointer(skb), &padbytes, sizeof(padbytes));
skb_put(skb, sizeof(padbytes));
--
1.7.7.6
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] Fix tx transfer padding for full-speed USB
2012-04-20 10:00 [PATCH] Fix tx transfer padding for full-speed USB Ingo van Lil
@ 2012-04-24 4:28 ` David Miller
2012-04-24 8:05 ` Ingo van Lil
0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2012-04-24 4:28 UTC (permalink / raw)
To: inguin; +Cc: netdev
From: Ingo van Lil <inguin@gmx.de>
Date: Fri, 20 Apr 2012 12:00:21 +0200
> - padlen = ((skb->len + 4) % 512) ? 0 : 4;
> + padlen = ((skb->len + 4) % dev->maxpacket) ? 0 : 4;
This is now an expensive modulus operation, instead of
a cheap mask.
Since you know that dev->maxpacket is always a power of two, tell the
compiler this so it can still optimize the expression by changing this
to "& (dev->maxpacket - 1)" and we'll thus avoid the costly modulus.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] Fix tx transfer padding for full-speed USB
2012-04-24 4:28 ` David Miller
@ 2012-04-24 8:05 ` Ingo van Lil
2012-04-24 8:12 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: Ingo van Lil @ 2012-04-24 8:05 UTC (permalink / raw)
To: David Miller; +Cc: netdev, Ingo van Lil
The asix.c USB Ethernet driver avoids ending a tx transfer with a zero-
length packet by appending a four-byte padding to transfers whose length
is a multiple of maxpacket. However, the hard-coded 512 byte maxpacket
length is valid for high-speed USB only; full-speed USB uses 64 byte
packets.
Signed-off-by: Ingo van Lil <inguin@gmx.de>
---
drivers/net/usb/asix.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c
index 5ee032c..42b5151 100644
--- a/drivers/net/usb/asix.c
+++ b/drivers/net/usb/asix.c
@@ -355,7 +355,7 @@ static struct sk_buff *asix_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
u32 packet_len;
u32 padbytes = 0xffff0000;
- padlen = ((skb->len + 4) % 512) ? 0 : 4;
+ padlen = ((skb->len + 4) & (dev->maxpacket - 1)) ? 0 : 4;
if ((!skb_cloned(skb)) &&
((headroom + tailroom) >= (4 + padlen))) {
@@ -377,7 +377,7 @@ static struct sk_buff *asix_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
cpu_to_le32s(&packet_len);
skb_copy_to_linear_data(skb, &packet_len, sizeof(packet_len));
- if ((skb->len % 512) == 0) {
+ if (padlen) {
cpu_to_le32s(&padbytes);
memcpy(skb_tail_pointer(skb), &padbytes, sizeof(padbytes));
skb_put(skb, sizeof(padbytes));
--
1.7.7.6
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] Fix tx transfer padding for full-speed USB
2012-04-24 8:05 ` Ingo van Lil
@ 2012-04-24 8:12 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2012-04-24 8:12 UTC (permalink / raw)
To: inguin; +Cc: netdev
From: Ingo van Lil <inguin@gmx.de>
Date: Tue, 24 Apr 2012 10:05:38 +0200
> The asix.c USB Ethernet driver avoids ending a tx transfer with a zero-
> length packet by appending a four-byte padding to transfers whose length
> is a multiple of maxpacket. However, the hard-coded 512 byte maxpacket
> length is valid for high-speed USB only; full-speed USB uses 64 byte
> packets.
>
> Signed-off-by: Ingo van Lil <inguin@gmx.de>
Applied.
Please in the future indicate the driver or subsystem you are
modifying in the subject. In this case prefixing your subject
with "[PATCH] asix: " would have been the appropriate thing
to do.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-04-24 8:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-20 10:00 [PATCH] Fix tx transfer padding for full-speed USB Ingo van Lil
2012-04-24 4:28 ` David Miller
2012-04-24 8:05 ` Ingo van Lil
2012-04-24 8:12 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox