ath79/mikrotik: use routerbootpart partitions
[oweals/openwrt.git] / target / linux / layerscape / patches-5.4 / 303-core-0001-net-readd-skb_recycle.patch
1 From 446a17652a69f749dd7a50b28e984c4904dc3aaf Mon Sep 17 00:00:00 2001
2 From: Madalin Bucur <madalin.bucur@freescale.com>
3 Date: Tue, 5 Jan 2016 12:12:07 +0200
4 Subject: [PATCH] net: readd skb_recycle()
5
6 Adding back skb_recycle() as it's used by the DPAA Ethernet driver.
7 This was removed from the upstream kernel because it was lacking users.
8
9 Signed-off-by: Madalin Bucur <madalin.bucur@freescale.com>
10 ---
11  include/linux/skbuff.h |  1 +
12  net/core/skbuff.c      | 26 ++++++++++++++++++++++++++
13  2 files changed, 27 insertions(+)
14
15 --- a/include/linux/skbuff.h
16 +++ b/include/linux/skbuff.h
17 @@ -1025,6 +1025,7 @@ void skb_dump(const char *level, const s
18  void skb_tx_error(struct sk_buff *skb);
19  void consume_skb(struct sk_buff *skb);
20  void __consume_stateless_skb(struct sk_buff *skb);
21 +void skb_recycle(struct sk_buff *skb);
22  void  __kfree_skb(struct sk_buff *skb);
23  extern struct kmem_cache *skbuff_head_cache;
24  
25 --- a/net/core/skbuff.c
26 +++ b/net/core/skbuff.c
27 @@ -936,6 +936,32 @@ void napi_consume_skb(struct sk_buff *sk
28  }
29  EXPORT_SYMBOL(napi_consume_skb);
30  
31 +/**
32 + *     skb_recycle - clean up an skb for reuse
33 + *     @skb: buffer
34 + *
35 + *     Recycles the skb to be reused as a receive buffer. This
36 + *     function does any necessary reference count dropping, and
37 + *     cleans up the skbuff as if it just came from __alloc_skb().
38 + */
39 +void skb_recycle(struct sk_buff *skb)
40 +{
41 +       struct skb_shared_info *shinfo;
42 +       u8 head_frag = skb->head_frag;
43 +
44 +       skb_release_head_state(skb);
45 +
46 +       shinfo = skb_shinfo(skb);
47 +       memset(shinfo, 0, offsetof(struct skb_shared_info, dataref));
48 +       atomic_set(&shinfo->dataref, 1);
49 +
50 +       memset(skb, 0, offsetof(struct sk_buff, tail));
51 +       skb->data = skb->head + NET_SKB_PAD;
52 +       skb->head_frag = head_frag;
53 +       skb_reset_tail_pointer(skb);
54 +}
55 +EXPORT_SYMBOL(skb_recycle);
56 +
57  /* Make sure a field is enclosed inside headers_start/headers_end section */
58  #define CHECK_SKB_FIELD(field) \
59         BUILD_BUG_ON(offsetof(struct sk_buff, field) <          \