All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Metcalf <cmetcalf@tilera.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 5/6] arch/tile: provide kernel support for the tilegx mPIPE shim
Date: Mon, 9 Apr 2012 17:04:49 -0400	[thread overview]
Message-ID: <4F834EF1.4080006@tilera.com> (raw)
In-Reply-To: <201204091334.28991.arnd@arndb.de>

On 4/9/2012 9:34 AM, Arnd Bergmann wrote:
> On Friday 06 April 2012, Chris Metcalf wrote:
>> The TILE-Gx chip includes a packet-processing network engine called
>> mPIPE ("Multicore Programmable Intelligent Packet Engine").  This
>> change adds support for using the mPIPE engine from within the
>> kernel.  The engine has more functionality than is exposed here,
>> but to keep the kernel code and binary simpler, this is a subset
>> of the full API designed to enable standard Linux networking only.
>>
>> Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
>>
>>
>> +config TILE_GXIO_MPIPE
>> +	bool "Tilera Gx mPIPE I/O support"
>> [...]
> Since this is all library code and does not provide any functionality itself,
> you can make the option invisible and just select it from the drivers that
> need it.

Good point.  Before last week they were actually full-scale user options
that you had select to be able to enable networking support, which I
realized was pretty broken when I looked at it.  I had reversed the
"depends" to be "selects", but I hadn't realized I should just make them
purely internal.  Done.

>> +EXPORT_SYMBOL(gxio_mpipe_alloc_buffer_stacks);
> Since these are all pretty specific low-level functions, I think it would be
> more appropriate to mark them all EXPORT_SYMBOL_GPL.

Done.

>> +
>> +typedef struct {
>> +	iorpc_mem_buffer_t buffer;
>> +	unsigned int stack;
>> +	unsigned int buffer_size_enum;
>> +} init_buffer_stack_aux_param_t;
> In kernel coding style, we don't use typedef for structures like this.
> Just call this a 'struct init_buffer_stack_aux_param' so that a reader
> can see that it is a complex data structure and not just a scalar.

This is machine-generated code from "upstream" (the Tilera hypervisor).  I
will look into how straightforward it is to use plain structs here.

>> +int gxio_mpipe_link_close(gxio_mpipe_link_t * link)
>> +{
>> +	return gxio_mpipe_link_close_aux(link->context, link->mac);
>> +}
>> +
>> +EXPORT_SYMBOL(gxio_mpipe_init);
>> +EXPORT_SYMBOL(gxio_mpipe_buffer_size_to_buffer_size_enum);
>> +EXPORT_SYMBOL(gxio_mpipe_buffer_size_enum_to_buffer_size);
>> +EXPORT_SYMBOL(gxio_mpipe_calc_buffer_stack_bytes);
>> +EXPORT_SYMBOL(gxio_mpipe_init_buffer_stack);
>> +EXPORT_SYMBOL(gxio_mpipe_init_notif_ring);
>> +EXPORT_SYMBOL(gxio_mpipe_init_notif_group_and_buckets);
>> +EXPORT_SYMBOL(gxio_mpipe_rules_init);
>> +EXPORT_SYMBOL(gxio_mpipe_rules_begin);
> Move the EXPORT_SYMBOL (_GPL) right after the function, not at the end of the file.

Done.  There were some shared-code issues that made this initially ugly
(this code is shared by a userspace library and by the kernel), but some
more aggressive use of "unifdef" and "sed" left things cleaner when the
dust settled. :-)

>> +// MMIO Ingress DMA Release Region Address.
>> +// This is a description of the physical addresses used to manipulate ingress
>> +// credit counters.  Accesses to this address space should use an address of
>> +// this form and a value like that specified in IDMA_RELEASE_REGION_VAL.
>> +
> Comment style

Yes, more of the machine-generated code here.  I will look into this one as
well.

> [...]
> +    uint_reg_t __reserved_0  : 3;
> +#endif
> +  };
> +  uint_reg_t word;
> +} MPIPE_IDMA_RELEASE_REGION_ADDR_t;
> Best try to avoid all bitfields for interfaces like this. Make it an le32
> or be32 variable instead and use masks for the accessing the individual
> fields.

We've had good experiences with bitfields, in fact.  In practice, in our
experience, bitfields result in code that's easier to get right, especially
when doing read-modify-write of something that's more than a bit wide, vs.
using shifts/masks.  (And especially when the overall item is 64 bits wide;
you have to remember to make your masks properly "UL" or you get mysterious
truncation, etc.)  Our compiler has well-understood bitfield management
properties.  This was less true with older compilers on other
architectures, I think.

> Do not use capital letters for types.

We normally don't, but these types are in fact exactly the representation
of the structure of the MMIO word whose structure is given by #defines of
the form MPIPE_IDMA_RELEASE_REGION_ADDR__* in the lower-level headers. 
(Note that I've pruned the headers so as not to spam the kernel with
multiple 200KB+ headers that we only use a few dozen lines in, so this is
less obvious than it otherwise would be.)

-- 
Chris Metcalf, Tilera Corp.
http://www.tilera.com


  reply	other threads:[~2012-04-09 21:04 UTC|newest]

Thread overview: 61+ 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-04 20:39 ` [PATCH 1/6] arch/tile: introduce GXIO IORPC framework for tilegx Chris Metcalf
2012-04-04 20:58 ` [PATCH 4/6] arch/tile: common DMA code for the GXIO IORPC subsystem Chris Metcalf
2012-04-06 17:41 ` [PATCH 2/6] arch/tile: fix set_pte() to properly handle kernel MMIO mappings Chris Metcalf
2012-04-06 17:52 ` [PATCH 3/6] arch/tile: support MMIO-based readb/writeb etc Chris Metcalf
2012-04-09 13:24   ` Arnd Bergmann
2012-04-09 20:53     ` Chris Metcalf
2012-04-06 20:38 ` [PATCH 5/6] arch/tile: provide kernel support for the tilegx mPIPE shim Chris Metcalf
2012-04-09 13:34   ` Arnd Bergmann
2012-04-09 21:04     ` Chris Metcalf [this message]
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-04 20:39                 ` [PATCH v2 1/6] arch/tile: introduce GXIO IORPC framework " Chris Metcalf
2012-04-04 20:58                 ` [PATCH v2 3/6] arch/tile: common DMA code for the GXIO IORPC subsystem Chris Metcalf
2012-04-06 17:52                 ` [PATCH v2 2/6] arch/tile: support MMIO-based readb/writeb etc Chris Metcalf
2012-04-06 20:38                 ` [PATCH v2 4/6] arch/tile: provide kernel support for the tilegx mPIPE shim 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
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-28 19:41                 ` [PATCH v2 5/6] arch/tile: break out the "csum a long" function to <asm/checksum.h> Chris Metcalf
2012-04-29 11:15               ` [PATCH 6/6] tilegx network driver: initial support 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=4F834EF1.4080006@tilera.com \
    --to=cmetcalf@tilera.com \
    --cc=arnd@arndb.de \
    --cc=linux-kernel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.