Patchwork virtio_net: Clean up set_skb_frag()

login
register
mail settings
Submitter Krishna Kumar
Date Oct. 20, 2011, 8:17 a.m.
Message ID <20111020081727.509.83122.sendpatchset@krkumar2.in.ibm.com>
Download mbox | patch
Permalink /patch/120758/
State Accepted
Delegated to: David Miller
Headers show

Comments

Krishna Kumar - Oct. 20, 2011, 8:17 a.m.
Remove manual initialization in set_skb_frag, and instead
use __skb_fill_page_desc() to do the same. Patch tested
on net-next.

Signed-off-by: Krishna Kumar <krkumar2@in.ibm.com>
---
 drivers/net/virtio_net.c |   13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)


--
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
Eric Dumazet - Oct. 20, 2011, 8:46 a.m.
Le jeudi 20 octobre 2011 à 13:47 +0530, Krishna Kumar a écrit :
> Remove manual initialization in set_skb_frag, and instead
> use __skb_fill_page_desc() to do the same. Patch tested
> on net-next.
> 
> Signed-off-by: Krishna Kumar <krkumar2@in.ibm.com>
> ---
>  drivers/net/virtio_net.c |   13 +++++--------
>  1 file changed, 5 insertions(+), 8 deletions(-)
> 
> diff -ruNp org/drivers/net/virtio_net.c new/drivers/net/virtio_net.c
> --- org/drivers/net/virtio_net.c	2011-10-20 08:34:31.000000000 +0530
> +++ new/drivers/net/virtio_net.c	2011-10-20 08:43:57.000000000 +0530
> @@ -143,18 +143,15 @@ static void skb_xmit_done(struct virtque
>  static void set_skb_frag(struct sk_buff *skb, struct page *page,
>  			 unsigned int offset, unsigned int *len)
>  {
> +	int size = min((unsigned)PAGE_SIZE - offset, *len);
>  	int i = skb_shinfo(skb)->nr_frags;
> -	skb_frag_t *f;
>  
> -	f = &skb_shinfo(skb)->frags[i];
> -	skb_frag_size_set(f, min((unsigned)PAGE_SIZE - offset, *len));
> -	f->page_offset = offset;
> -	__skb_frag_set_page(f, page);
> +	__skb_fill_page_desc(skb, i, page, offset, size);
>  
> -	skb->data_len += skb_frag_size(f);
> -	skb->len += skb_frag_size(f);
> +	skb->data_len += size;
> +	skb->len += size;
>  	skb_shinfo(skb)->nr_frags++;
> -	*len -= skb_frag_size(f);
> +	*len -= size;
>  }
>  
>  static struct sk_buff *page_to_skb(struct virtnet_info *vi,
> 
> --

Acked-by: Eric Dumazet <eric.dumazet@gmail.com>

Seems fine to me. There is a truesize patch for this driver, I'll send
it once your patch is in.



--
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
David Miller - Oct. 20, 2011, 8:54 a.m.
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Thu, 20 Oct 2011 10:46:02 +0200

> Le jeudi 20 octobre 2011 à 13:47 +0530, Krishna Kumar a écrit :
>> Remove manual initialization in set_skb_frag, and instead
>> use __skb_fill_page_desc() to do the same. Patch tested
>> on net-next.
>> 
>> Signed-off-by: Krishna Kumar <krkumar2@in.ibm.com>
...
> Acked-by: Eric Dumazet <eric.dumazet@gmail.com>

Applied, thanks.
--
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

Patch

diff -ruNp org/drivers/net/virtio_net.c new/drivers/net/virtio_net.c
--- org/drivers/net/virtio_net.c	2011-10-20 08:34:31.000000000 +0530
+++ new/drivers/net/virtio_net.c	2011-10-20 08:43:57.000000000 +0530
@@ -143,18 +143,15 @@  static void skb_xmit_done(struct virtque
 static void set_skb_frag(struct sk_buff *skb, struct page *page,
 			 unsigned int offset, unsigned int *len)
 {
+	int size = min((unsigned)PAGE_SIZE - offset, *len);
 	int i = skb_shinfo(skb)->nr_frags;
-	skb_frag_t *f;
 
-	f = &skb_shinfo(skb)->frags[i];
-	skb_frag_size_set(f, min((unsigned)PAGE_SIZE - offset, *len));
-	f->page_offset = offset;
-	__skb_frag_set_page(f, page);
+	__skb_fill_page_desc(skb, i, page, offset, size);
 
-	skb->data_len += skb_frag_size(f);
-	skb->len += skb_frag_size(f);
+	skb->data_len += size;
+	skb->len += size;
 	skb_shinfo(skb)->nr_frags++;
-	*len -= skb_frag_size(f);
+	*len -= size;
 }
 
 static struct sk_buff *page_to_skb(struct virtnet_info *vi,