layerscape: reverse changes to ndo_get_stats64
[openwrt/staging/chunkeey.git] / target / linux / layerscape / patches-4.9 / 601-net-readd-skb_recycle.patch
1 From 9527ee5eb436ad773acc7320b372a5f4825a920d 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 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
16 index 32810f279f8e..a52a6fb0ac2e 100644
17 --- a/include/linux/skbuff.h
18 +++ b/include/linux/skbuff.h
19 @@ -902,6 +902,7 @@ void kfree_skb(struct sk_buff *skb);
20 void kfree_skb_list(struct sk_buff *segs);
21 void skb_tx_error(struct sk_buff *skb);
22 void consume_skb(struct sk_buff *skb);
23 +void skb_recycle(struct sk_buff *skb);
24 void __kfree_skb(struct sk_buff *skb);
25 extern struct kmem_cache *skbuff_head_cache;
26
27 diff --git a/net/core/skbuff.c b/net/core/skbuff.c
28 index fe008f1bd930..ab1038083df2 100644
29 --- a/net/core/skbuff.c
30 +++ b/net/core/skbuff.c
31 @@ -825,6 +825,32 @@ void napi_consume_skb(struct sk_buff *skb, int budget)
32 }
33 EXPORT_SYMBOL(napi_consume_skb);
34
35 +/**
36 + * skb_recycle - clean up an skb for reuse
37 + * @skb: buffer
38 + *
39 + * Recycles the skb to be reused as a receive buffer. This
40 + * function does any necessary reference count dropping, and
41 + * cleans up the skbuff as if it just came from __alloc_skb().
42 + */
43 +void skb_recycle(struct sk_buff *skb)
44 +{
45 + struct skb_shared_info *shinfo;
46 + u8 head_frag = skb->head_frag;
47 +
48 + skb_release_head_state(skb);
49 +
50 + shinfo = skb_shinfo(skb);
51 + memset(shinfo, 0, offsetof(struct skb_shared_info, dataref));
52 + atomic_set(&shinfo->dataref, 1);
53 +
54 + memset(skb, 0, offsetof(struct sk_buff, tail));
55 + skb->data = skb->head + NET_SKB_PAD;
56 + skb->head_frag = head_frag;
57 + skb_reset_tail_pointer(skb);
58 +}
59 +EXPORT_SYMBOL(skb_recycle);
60 +
61 /* Make sure a field is enclosed inside headers_start/headers_end section */
62 #define CHECK_SKB_FIELD(field) \
63 BUILD_BUG_ON(offsetof(struct sk_buff, field) < \
64 --
65 2.11.1
66