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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 :

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);
 		}
 	}


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


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux