Re: [PATCH v5] net: bnx2x: convert to hw_features

Ben Hutchings
2011-04-21T22:52:25Z

On Fri, 2011-04-22 at 00:15 +0200, Michał Mirosław wrote:
> On Thu, Apr 21, 2011 at 08:19:19PM +0100, Ben Hutchings wrote:
> > /* Transfer changeable features to wanted_features and enable
> > * software offloads (GSO and GRO).
> > */
> > dev->hw_features |= NETIF_F_SOFT_FEATURES;
> > dev->features |= NETIF_F_SOFT_FEATURES;
> > dev->wanted_features = dev->features & dev->hw_features;
> >
> > This doesn't work correctly for features that are always enabled, like
> > NETIF_F_HW_VLAN_RX in bnx2x, which are set in dev->features but not in
> > dev->hw_features.
>
> > The name 'hw_features' really wasn't a good choice - the obvious meaning
> > and the meaning assumed by this code is 'hardware-supported features'
> > and not 'hardware-supported features that can be toggled'. And since we
> > add NETIF_F_SOFT_FEATURES, it really only means 'features that can be
> > toggled'.
>
> I won't argue about hw_features name - I just couldn't find a better one.
> Comment in include/linux/netdevice.h clearly explains the purpose of this
> field.
>
> wanted_features is supposed to be limited by hw_features (so that it's always
> true that (hw_features & wanted_features) == wanted_features). If you have
> an idea how to make that more clear, I'd be happy to update descriptions.

Then the computation of 'changed' in __ethtool_set_flags() is wrong:

/* allow changing only bits set in hw_features */
changed = (data ^ dev->wanted_features) & flags_dup_features;
if (changed & ~dev->hw_features)
return (changed & dev->hw_features) ? -EINVAL : -EOPNOTSUPP;

You need to add something like:

/* Features that are requested to be on, are already on, and cannot
* be changed, have not changed.
*/
changes &= ~(data & dev->features & ~dev->hw_features);

It seems like there ought to be a way to simplify that, though!

Ben.

--
Ben Hutchings, Senior Software 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.