Thread (47 messages) 47 messages, 6 authors, 2012-06-12

Re: [PATCH v9] tilegx network driver: initial support

From: Eric Dumazet <hidden>
Date: 2012-06-06 17:41:09
Also in: lkml

On Mon, 2012-06-04 at 16:12 -0400, Chris Metcalf wrote:
+/* Allocate and push a buffer. */
+static bool tile_net_provide_buffer(bool small)
+{
+	int stack = small ? small_buffer_stack : large_buffer_stack;
+	const unsigned long buffer_alignment = 128;
+	struct sk_buff *skb;
+	int len;
+
+	len = sizeof(struct sk_buff **) + buffer_alignment;
+	len += (small ? 128 : 1664);
1664 is a magic number, it should be a nice define

#define ..... ( ETH_DATA_LEN + .... )
+	skb = dev_alloc_skb(len);
+	if (skb == NULL)
+		return false;
+
+	/* Make room for a back-pointer to 'skb' and guarantee alignment. */
+	skb_reserve(skb, sizeof(struct sk_buff **));
+	skb_reserve(skb, -(long)skb->data & (buffer_alignment - 1));
+
+	/* Save a back-pointer to 'skb'. */
+	*(struct sk_buff **)(skb->data - sizeof(struct sk_buff **)) = skb;
+
+	/* Make sure "skb" and the back-pointer have been flushed. */
+	wmb();
Interesting, have you considered using build_skb() instead of this
convoluted thing ?

This could save some cache misses...
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help