diff options
author | Eric Dumazet <edumazet@google.com> | 2013-08-01 09:49:52 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-08-04 00:55:52 -0400 |
commit | f27070158d6754765f2f5fd1617e8e42a0ea2318 (patch) | |
tree | e203a11394a14d0a4659933e6210e7bfe0f50661 /drivers/net/usb/ax88179_178a.c | |
parent | 0e76a3a587fc7abda2badf249053b427baad255e (diff) |
ax88179_178a: avoid copy of tx tcp packets
ax88179_tx_fixup() has quite complex code trying to push 8 bytes
of control data (len/mss), but fails to do it properly for TCP packets,
incurring an extra copy and point of memory allocation failure.
Lets use the simple and approved way.
dev->needed_headroom being 8, all frames should have 8 bytes of
headroom, so the extra copy should be unlikely anyway.
This patch should improve performance for TCP xmits.
Reported-by: Ming Lei <ming.lei@canonical.com>
Tested-by: Ming Lei <ming.lei@canonical.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/usb/ax88179_178a.c')
-rw-r--r-- | drivers/net/usb/ax88179_178a.c | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c index 5a468f317ca5..fb0caa289d0b 100644 --- a/drivers/net/usb/ax88179_178a.c +++ b/drivers/net/usb/ax88179_178a.c | |||
@@ -1169,31 +1169,18 @@ ax88179_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) | |||
1169 | int frame_size = dev->maxpacket; | 1169 | int frame_size = dev->maxpacket; |
1170 | int mss = skb_shinfo(skb)->gso_size; | 1170 | int mss = skb_shinfo(skb)->gso_size; |
1171 | int headroom; | 1171 | int headroom; |
1172 | int tailroom; | ||
1173 | 1172 | ||
1174 | tx_hdr1 = skb->len; | 1173 | tx_hdr1 = skb->len; |
1175 | tx_hdr2 = mss; | 1174 | tx_hdr2 = mss; |
1176 | if (((skb->len + 8) % frame_size) == 0) | 1175 | if (((skb->len + 8) % frame_size) == 0) |
1177 | tx_hdr2 |= 0x80008000; /* Enable padding */ | 1176 | tx_hdr2 |= 0x80008000; /* Enable padding */ |
1178 | 1177 | ||
1179 | headroom = skb_headroom(skb); | 1178 | headroom = skb_headroom(skb) - 8; |
1180 | tailroom = skb_tailroom(skb); | ||
1181 | 1179 | ||
1182 | if (!skb_header_cloned(skb) && | 1180 | if ((skb_header_cloned(skb) || headroom < 0) && |
1183 | !skb_cloned(skb) && | 1181 | pskb_expand_head(skb, headroom < 0 ? 8 : 0, 0, GFP_ATOMIC)) { |
1184 | (headroom + tailroom) >= 8) { | ||
1185 | if (headroom < 8) { | ||
1186 | skb->data = memmove(skb->head + 8, skb->data, skb->len); | ||
1187 | skb_set_tail_pointer(skb, skb->len); | ||
1188 | } | ||
1189 | } else { | ||
1190 | struct sk_buff *skb2; | ||
1191 | |||
1192 | skb2 = skb_copy_expand(skb, 8, 0, flags); | ||
1193 | dev_kfree_skb_any(skb); | 1182 | dev_kfree_skb_any(skb); |
1194 | skb = skb2; | 1183 | return NULL; |
1195 | if (!skb) | ||
1196 | return NULL; | ||
1197 | } | 1184 | } |
1198 | 1185 | ||
1199 | skb_push(skb, 4); | 1186 | skb_push(skb, 4); |