netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ben Hutchings <bhutchings@solarflare.com>
To: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
Cc: <netdev@vger.kernel.org>, "David S. Miller" <davem@davemloft.net>
Subject: Re: [PATCH v5 5/9] net: Define enum for net device features.
Date: Thu, 17 Nov 2011 00:00:24 +0000	[thread overview]
Message-ID: <1321488024.2709.66.camel@bwh-desktop> (raw)
In-Reply-To: <20111116233408.GB8476@rere.qmqm.pl>

On Thu, 2011-11-17 at 00:34 +0100, Michał Mirosław wrote:
> On Wed, Nov 16, 2011 at 10:39:37PM +0000, Ben Hutchings wrote:
> > On Wed, 2011-11-16 at 02:29 +0100, Michał Mirosław wrote:
> > > Define feature values by bit position instead of direct 2**i values
> > > and force the values to be of type netdev_features_t.
> > > 
> > > Cleaned and extended from patch by Mahesh Bandewar <maheshb@google.com>:
> > > + added netdev_features_t casts
> > > + included bits under NETIF_F_GSO_MASK
> > > + moved feature #defines out of struct net_device definition
> > > 
> > > Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> > > ---
> > >  include/linux/netdev_features.h |  129 +++++++++++++++++++++++++++-----------
> > >  1 files changed, 91 insertions(+), 38 deletions(-)
> > > 
> > > diff --git a/include/linux/netdev_features.h b/include/linux/netdev_features.h
> > > index af52381..04ac8f8 100644
> > > --- a/include/linux/netdev_features.h
> > > +++ b/include/linux/netdev_features.h
> > [...]
> > > +	/**/NETIF_F_GSO_SHIFT,		/* keep the order of SKB_GSO_* bits */
> > > +	NETIF_F_TSO_BIT			/* ... TCPv4 segmentation */
> > > +		= NETIF_F_GSO_SHIFT,
> > > +	NETIF_F_UFO_BIT,		/* ... UDPv4 fragmentation */
> > > +	NETIF_F_GSO_ROBUST_BIT,		/* ... ->SKB_GSO_DODGY */
> > > +	NETIF_F_TSO_ECN_BIT,		/* ... TCP ECN support */
> > > +	NETIF_F_TSO6_BIT,		/* ... TCPv6 segmentation */
> > > +	NETIF_F_FSO_BIT,		/* ... FCoE segmentation */
> > > +	NETIF_F_GSO_RESERVED1,		/* ... free (fill GSO_MASK to 8 bits) */
> > > +	/**/NETIF_F_GSO_LAST,		/* [can't be last bit, see GSO_MASK] */
> > > +	NETIF_F_GSO_RESERVED2		/* ... free (fill GSO_MASK to 8 bits) */
> > > +		= NETIF_F_GSO_LAST,
> > >  
> > > -/* Segmentation offload features */
> > > -#define NETIF_F_GSO_SHIFT	16
> > > -#define NETIF_F_GSO_MASK	0x00ff0000
> > > -#define NETIF_F_TSO		(SKB_GSO_TCPV4 << NETIF_F_GSO_SHIFT)
> > > -#define NETIF_F_UFO		(SKB_GSO_UDP << NETIF_F_GSO_SHIFT)
> > > -#define NETIF_F_GSO_ROBUST	(SKB_GSO_DODGY << NETIF_F_GSO_SHIFT)
> > > -#define NETIF_F_TSO_ECN		(SKB_GSO_TCP_ECN << NETIF_F_GSO_SHIFT)
> > > -#define NETIF_F_TSO6		(SKB_GSO_TCPV6 << NETIF_F_GSO_SHIFT)
> > > -#define NETIF_F_FSO		(SKB_GSO_FCOE << NETIF_F_GSO_SHIFT)
> > [...]
> > 
> > You should either add BUILD_BUG_ON()s somewhere to ensure that the
> > netdev feature and skb GSO flags remain in sync, or redefine the skb GSO
> > flags using the netdev feature flags (which I thought was the reason for
> > moving features to their own header).
> 
> Main motiviation for the moving out of features to separate headers was
> to avoid circular inclusion of linux/netdevice.h from linux/skbuff.h.
> We get readability for free.
> 
> BUILD_BUG_ON() is a good idea. It should go to skbuff.h and as separate
> patch as it's something new and independent.

It may be functionally independent, but this change is unsafe without
the addition of such assertions.

Ben.

-- 
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.

  reply	other threads:[~2011-11-17  0:00 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-16  1:29 [PATCH v5 0/9] Cleanup and extension of netdev features Michał Mirosław
2011-11-16  1:29 ` [PATCH v5 2/9] net: ethtool: break association of ETH_FLAG_* with NETIF_F_* Michał Mirosław
2011-11-16  2:06   ` Ben Hutchings
2011-11-16  1:29 ` [PATCH v5 8/9] net: extend netdev_features_t to 64 bits Michał Mirosław
2011-11-16 22:43   ` Ben Hutchings
2011-11-16  1:29 ` [PATCH v5 6/9] net: ethtool: use C99 array initialization for feature-names table Michał Mirosław
2011-11-16 22:40   ` Ben Hutchings
2011-11-16  1:29 ` [PATCH v5 9/9] net: remove NETIF_F_NO_CSUM feature bit Michał Mirosław
2011-11-16  1:29 ` [PATCH v5 3/9] net: split netdev features to separate header Michał Mirosław
2011-11-16  2:14   ` Ben Hutchings
2011-11-16  1:29 ` [PATCH v5 7/9] ethtool: prepare for larger netdev_features_t type Michał Mirosław
2011-11-16 22:43   ` Ben Hutchings
2011-11-16 23:18     ` Michał Mirosław
2011-11-16  1:29 ` [PATCH v5 1/9] net: remove legacy ethtool ops Michał Mirosław
2011-11-16  2:04   ` Ben Hutchings
2011-11-16  1:29 ` [PATCH v5 5/9] net: Define enum for net device features Michał Mirosław
2011-11-16 22:39   ` Ben Hutchings
2011-11-16 23:34     ` Michał Mirosław
2011-11-17  0:00       ` Ben Hutchings [this message]
2011-11-17  0:11         ` Michał Mirosław
2011-11-16  1:29 ` [PATCH v5 4/9] net: introduce and use netdev_features_t for device features sets Michał Mirosław
2011-11-16 22:30   ` Ben Hutchings
2011-11-16 22:49 ` [PATCH v5 0/9] Cleanup and extension of netdev features David Miller
2011-11-16 23:06   ` David Miller

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=1321488024.2709.66.camel@bwh-desktop \
    --to=bhutchings@solarflare.com \
    --cc=davem@davemloft.net \
    --cc=mirq-linux@rere.qmqm.pl \
    --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).