From: Chris Metcalf <cmetcalf@tilera.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: <bhutchings@solarflare.com>, <arnd@arndb.de>,
David Miller <davem@davemloft.net>,
<linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>
Subject: Re: [PATCH v9] tilegx network driver: initial support
Date: Wed, 6 Jun 2012 14:36:02 -0400 [thread overview]
Message-ID: <4FCFA312.4020505@tilera.com> (raw)
In-Reply-To: <1339004459.26966.31.camel@edumazet-glaptop>
On 6/6/2012 1:40 PM, Eric Dumazet wrote:
> 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 + .... )
Fair enough. However, the magic-ness comes from the hardware header code
in arch/tile/gxio/mpipe.h, which provides a limited set of allowed buffer
sizes, including 1664. But I can add these #defines at the top of this driver:
/* Buffer sizes and mpipe enum codes for buffer stacks.
* See arch/tile/include/gxio/mpipe.h for the set of possible values.
*/
#define BUFFER_SIZE_SMALL_ENUM GXIO_MPIPE_BUFFER_SIZE_128
#define BUFFER_SIZE_SMALL 128
#define BUFFER_SIZE_LARGE_ENUM GXIO_MPIPE_BUFFER_SIZE_1664
#define BUFFER_SIZE_LARGE 1664
>> + 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...
I hadn't looked at build_skb() before; we built up this driver mostly on a
base of 2.6.38, where it doesn't exist. That said, it doesn't seem like it
matters; dev_alloc_skb() will just end up calling down to build_skb()
anyway, as far as I can tell.
The code where we do the two skb_reserves and then stuff in a backpointer
and do a barrier are because we track the skbuffs in hardware, and hardware
ignores the low 7 bits aof the address (thus the "buffer_alignment" part)
and we need to be able to pull the actual skb address out of the data when
the hardware returns a pointer to the data to us.
By the way, your question about tx_queue_len is a good one; I'm roping in
our other network developer folks to figure it out. Originally it was a
performance optimization, I believe; I'm not sure it's still required.
I'll follow up on that one when we've tracked it down.
--
Chris Metcalf, Tilera Corp.
http://www.tilera.com
next prev parent reply other threads:[~2012-06-06 18:36 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-04 20:39 [PATCH 0/6] arch/tile: provide tilegx networking support Chris Metcalf
2012-04-06 20:42 ` [PATCH 6/6] tilegx network driver: initial support Chris Metcalf
2012-04-09 13:49 ` Arnd Bergmann
2012-04-09 21:30 ` Chris Metcalf
2012-04-10 10:42 ` Arnd Bergmann
2012-04-12 23:23 ` Chris Metcalf
2012-04-13 10:34 ` Arnd Bergmann
2012-04-28 22:07 ` Chris Metcalf
2012-04-04 20:39 ` [PATCH v2 0/6] arch/tile: networking support for tilegx Chris Metcalf
2012-04-06 20:42 ` [PATCH v2 6/6] tilegx network driver: initial support Chris Metcalf
2012-04-30 14:35 ` Arnd Bergmann
2001-09-17 4:00 ` [PATCH v3] " Chris Metcalf
2012-05-03 5:41 ` David Miller
2012-05-03 15:45 ` Chris Metcalf
2012-05-03 17:07 ` David Miller
2012-05-03 17:25 ` Chris Metcalf
2012-05-03 16:41 ` [PATCH v4] " Chris Metcalf
2012-05-04 6:42 ` David Miller
2012-05-09 10:42 ` [PATCH v5] " Chris Metcalf
2012-05-11 13:54 ` Ben Hutchings
2012-05-20 4:42 ` [PATCH v6] " Chris Metcalf
2012-05-20 20:55 ` David Miller
2012-05-23 20:42 ` [PATCH v7] " Chris Metcalf
2012-05-24 4:31 ` David Miller
2012-05-25 14:42 ` [PATCH v8] " Chris Metcalf
2012-06-04 20:12 ` [PATCH v9] " Chris Metcalf
2012-06-06 16:41 ` David Miller
2012-06-06 17:31 ` Eric Dumazet
2012-06-06 17:40 ` Eric Dumazet
2012-06-06 18:36 ` Chris Metcalf [this message]
2012-06-06 18:54 ` David Miller
2001-09-17 4:00 ` [PATCH v10] " Chris Metcalf
2012-04-06 20:42 ` Chris Metcalf
2012-06-07 20:39 ` David Miller
2012-06-07 20:44 ` Chris Metcalf
2012-06-07 20:47 ` Chris Metcalf
2012-06-07 20:50 ` Ben Hutchings
2012-06-07 20:52 ` Joe Perches
2012-06-07 20:45 ` Chris Metcalf
2012-06-12 0:03 ` David Miller
2012-06-12 13:14 ` Chris Metcalf
2012-06-06 18:10 ` [PATCH v9] " Eric Dumazet
2012-06-06 18:17 ` David Miller
2012-06-06 18:19 ` Ben Hutchings
2012-05-20 16:35 ` [PATCH v5] " Chris Metcalf
2012-04-29 11:15 ` [PATCH 6/6] " Arnd Bergmann
2012-04-15 23:06 ` Chris Metcalf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4FCFA312.4020505@tilera.com \
--to=cmetcalf@tilera.com \
--cc=arnd@arndb.de \
--cc=bhutchings@solarflare.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).