summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorBogdan Hamciuc <bogdan.hamciuc@freescale.com>2013-02-05 12:52:33 (GMT)
committerEmil Medve <Emilian.Medve@Freescale.com>2013-03-21 18:42:12 (GMT)
commit9126496b944c60065992c6d7b9677ce2a3582dd8 (patch)
treea5c86bcf3267f5d257469275c28a3074687137ba /net
parentede9248699f79f15aae5eaae224de7c688fab4a0 (diff)
downloadlinux-fsl-qoriq-9126496b944c60065992c6d7b9677ce2a3582dd8.tar.xz
dpaa_eth,temp: Temporarily revert skb recycling removal
Partially reverting commit acb600def2110b1310466c0e485c0d26299898ae, in that we leave the skb recycling functions around until we rebase our code onto the new 3.8 kernel base. 1. We'll first move this capability back into our driver. 2. At a later stage, we'll remove this capability in this particular form from the driver altogether, as we integrate the new net APIs. Signed-off-by: Bogdan Hamciuc <bogdan.hamciuc@freescale.com>
Diffstat (limited to 'net')
-rw-r--r--net/core/skbuff.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 32443eb..f4a73cb 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -675,6 +675,53 @@ void consume_skb(struct sk_buff *skb)
}
EXPORT_SYMBOL(consume_skb);
+/**
+ * skb_recycle - clean up an skb for reuse
+ * @skb: buffer
+ *
+ * Recycles the skb to be reused as a receive buffer. This
+ * function does any necessary reference count dropping, and
+ * cleans up the skbuff as if it just came from __alloc_skb().
+ */
+void skb_recycle(struct sk_buff *skb)
+{
+ struct skb_shared_info *shinfo;
+
+ skb_release_head_state(skb);
+
+ shinfo = skb_shinfo(skb);
+ memset(shinfo, 0, offsetof(struct skb_shared_info, dataref));
+ atomic_set(&shinfo->dataref, 1);
+
+ memset(skb, 0, offsetof(struct sk_buff, tail));
+ skb->data = skb->head + NET_SKB_PAD;
+ skb_reset_tail_pointer(skb);
+}
+EXPORT_SYMBOL(skb_recycle);
+
+/**
+ * skb_recycle_check - check if skb can be reused for receive
+ * @skb: buffer
+ * @skb_size: minimum receive buffer size
+ *
+ * Checks that the skb passed in is not shared or cloned, and
+ * that it is linear and its head portion at least as large as
+ * skb_size so that it can be recycled as a receive buffer.
+ * If these conditions are met, this function does any necessary
+ * reference count dropping and cleans up the skbuff as if it
+ * just came from __alloc_skb().
+ */
+bool skb_recycle_check(struct sk_buff *skb, int skb_size)
+{
+ if (!skb_is_recycleable(skb, skb_size))
+ return false;
+
+ skb_recycle(skb);
+
+ return true;
+}
+EXPORT_SYMBOL(skb_recycle_check);
+
static void __copy_skb_header(struct sk_buff *new, const struct sk_buff *old)
{
new->tstamp = old->tstamp;