diff mbox

changing usbnet's API to better deal with cdc-ncm

Message ID 1346923336.2484.7.camel@edumazet-glaptop
State RFC, archived
Delegated to: David Miller
Headers show

Commit Message

Eric Dumazet Sept. 6, 2012, 9:22 a.m. UTC
On Thu, 2012-09-06 at 11:11 +0200, Eric Dumazet wrote:

> Really skb_clone() use should be removed from cdc_ncm_rx_fixup()
> 
> Unless you expect 10Gbit speed from this driver, skb_clone() is the
> worst possible strategy.
> 
> Allocating fresh skbs of the right size permits better memory use and
> allows TCP coalescing as well.
> 
> The use of skb_clone() forces some parts of the stack to perform a full
> copy anyway.
> 
> It's still unclear to me with we use up to 32KB blocks in USB drivers...
> 

So I advise testing this patch :



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 4cd582a..c0821f7 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -1052,12 +1052,11 @@  static int cdc_ncm_rx_fixup(struct usbnet *dev, struct sk_buff *skb_in)
 			break;
 
 		} else {
-			skb = skb_clone(skb_in, GFP_ATOMIC);
+			skb = netdev_alloc_skb_ip_align(dev->net, len);
 			if (!skb)
 				goto error;
-			skb->len = len;
-			skb->data = ((u8 *)skb_in->data) + offset;
-			skb_set_tail_pointer(skb, len);
+			skb_put(skb, len);
+			memcpy(skb->data, skb_in->data + offset, len);
 			usbnet_skb_return(dev, skb);
 		}
 	}