From: =?iso-8859-2?Q?Micha=B3_Miros=B3aw?= Subject: Re: [PATCH v5 5/9] net: Define enum for net device features. Date: Thu, 17 Nov 2011 01:11:09 +0100 Message-ID: <20111117001109.GA9596@rere.qmqm.pl> References: <1321483177.2709.28.camel@bwh-desktop> <20111116233408.GB8476@rere.qmqm.pl> <1321488024.2709.66.camel@bwh-desktop> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-2 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: netdev@vger.kernel.org, "David S. Miller" To: Ben Hutchings Return-path: Received: from rere.qmqm.pl ([89.167.52.164]:39143 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753810Ab1KQALK (ORCPT ); Wed, 16 Nov 2011 19:11:10 -0500 Content-Disposition: inline In-Reply-To: <1321488024.2709.66.camel@bwh-desktop> Sender: netdev-owner@vger.kernel.org List-ID: On Thu, Nov 17, 2011 at 12:00:24AM +0000, Ben Hutchings wrote: > On Thu, 2011-11-17 at 00:34 +0100, Micha=B3 Miros=B3aw wrote: > > On Wed, Nov 16, 2011 at 10:39:37PM +0000, Ben Hutchings wrote: > > > On Wed, 2011-11-16 at 02:29 +0100, Micha=B3 Miros=B3aw wrote: > > > > Define feature values by bit position instead of direct 2**i va= lues > > > > and force the values to be of type netdev_features_t. > > > >=20 > > > > Cleaned and extended from patch by Mahesh Bandewar : > > > > + added netdev_features_t casts > > > > + included bits under NETIF_F_GSO_MASK > > > > + moved feature #defines out of struct net_device definition > > > >=20 > > > > Signed-off-by: Micha=B3 Miros=B3aw > > > > --- > > > > include/linux/netdev_features.h | 129 +++++++++++++++++++++++= ++++----------- > > > > 1 files changed, 91 insertions(+), 38 deletions(-) > > > >=20 > > > > diff --git a/include/linux/netdev_features.h b/include/linux/ne= tdev_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 */ > > > > + =3D 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) = */ > > > > + =3D NETIF_F_GSO_LAST, > > > > =20 > > > > -/* 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) > > > [...] > > >=20 > > > You should either add BUILD_BUG_ON()s somewhere to ensure that th= e > > > 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 rea= son for > > > moving features to their own header). > >=20 > > 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. > >=20 > > BUILD_BUG_ON() is a good idea. It should go to skbuff.h and as sepa= rate > > patch as it's something new and independent. > It may be functionally independent, but this change is unsafe without > the addition of such assertions. Please take a look at a patch I just sent ("net: verify GSO flag bits a= gainst netdev features") other way would be to define SKB_GSO_* in terms of corresponding NETIF_F_* flags. Best Regards, Micha=B3 Miros=B3aw