diff options
author | Jason Wang <jasowang@redhat.com> | 2013-11-01 02:07:47 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-11-04 20:03:52 -0500 |
commit | f8e617e100d7369a0108f96abf4414e9fb82ced7 (patch) | |
tree | 669f70c7c3ce6ed05097771890d708d83f1eb8be | |
parent | e50fddc8b0c0698cba446221be3654aa0a642372 (diff) |
net: introduce skb_coalesce_rx_frag()
Sometimes we need to coalesce the rx frags to avoid frag list. One example is
virtio-net driver which tries to use small frags for both MTU sized packet and
GSO packet. So this patch introduce skb_coalesce_rx_frag() to do this.
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Michael Dalton <mwdalton@google.com>
Cc: Eric Dumazet <edumazet@google.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/linux/skbuff.h | 3 | ||||
-rw-r--r-- | net/core/skbuff.c | 12 |
2 files changed, 15 insertions, 0 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 44727b5d4981..2e153b69d318 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h | |||
@@ -1372,6 +1372,9 @@ static inline void skb_fill_page_desc(struct sk_buff *skb, int i, | |||
1372 | void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, int off, | 1372 | void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, int off, |
1373 | int size, unsigned int truesize); | 1373 | int size, unsigned int truesize); |
1374 | 1374 | ||
1375 | void skb_coalesce_rx_frag(struct sk_buff *skb, int i, int size, | ||
1376 | unsigned int truesize); | ||
1377 | |||
1375 | #define SKB_PAGE_ASSERT(skb) BUG_ON(skb_shinfo(skb)->nr_frags) | 1378 | #define SKB_PAGE_ASSERT(skb) BUG_ON(skb_shinfo(skb)->nr_frags) |
1376 | #define SKB_FRAG_ASSERT(skb) BUG_ON(skb_has_frag_list(skb)) | 1379 | #define SKB_FRAG_ASSERT(skb) BUG_ON(skb_has_frag_list(skb)) |
1377 | #define SKB_LINEAR_ASSERT(skb) BUG_ON(skb_is_nonlinear(skb)) | 1380 | #define SKB_LINEAR_ASSERT(skb) BUG_ON(skb_is_nonlinear(skb)) |
diff --git a/net/core/skbuff.c b/net/core/skbuff.c index e4115597b38b..3735fad5616e 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c | |||
@@ -476,6 +476,18 @@ void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, int off, | |||
476 | } | 476 | } |
477 | EXPORT_SYMBOL(skb_add_rx_frag); | 477 | EXPORT_SYMBOL(skb_add_rx_frag); |
478 | 478 | ||
479 | void skb_coalesce_rx_frag(struct sk_buff *skb, int i, int size, | ||
480 | unsigned int truesize) | ||
481 | { | ||
482 | skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; | ||
483 | |||
484 | skb_frag_size_add(frag, size); | ||
485 | skb->len += size; | ||
486 | skb->data_len += size; | ||
487 | skb->truesize += truesize; | ||
488 | } | ||
489 | EXPORT_SYMBOL(skb_coalesce_rx_frag); | ||
490 | |||
479 | static void skb_drop_list(struct sk_buff **listp) | 491 | static void skb_drop_list(struct sk_buff **listp) |
480 | { | 492 | { |
481 | kfree_skb_list(*listp); | 493 | kfree_skb_list(*listp); |