From: =?iso-8859-2?Q?Micha=B3_Miros=B3aw?= Subject: Re: [RFC PATCH 02/12] net: Introduce new feature setting ops Date: Mon, 20 Dec 2010 00:43:43 +0100 Message-ID: <20101219234343.GA15644@rere.qmqm.pl> References: <822f5776f99cab9889cd72d658d5fe50c56bb247.1292451559.git.mirq-linux@rere.qmqm.pl> <1292541186.18294.16.camel@bwh-desktop> <20101219004959.GA12005@rere.qmqm.pl> <1292793759.2874.14.camel@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-2 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: netdev@vger.kernel.org To: Ben Hutchings Return-path: Received: from rere.qmqm.pl ([89.167.52.164]:34727 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932528Ab0LSXnp (ORCPT ); Sun, 19 Dec 2010 18:43:45 -0500 Content-Disposition: inline In-Reply-To: <1292793759.2874.14.camel@localhost> Sender: netdev-owner@vger.kernel.org List-ID: On Sun, Dec 19, 2010 at 09:22:39PM +0000, Ben Hutchings wrote: > On Sun, 2010-12-19 at 01:49 +0100, Micha=B3 Miros=B3aw wrote: > > On Thu, Dec 16, 2010 at 11:13:06PM +0000, Ben Hutchings wrote: > > > On Wed, 2010-12-15 at 23:24 +0100, Micha=B3 Miros=B3aw wrote: > [...] > > > > +static int ethtool_set_features(struct net_device *dev, void _= _user *useraddr) > > > > +{ > > > > + struct ethtool_features cmd; > > > > + struct ethtool_set_features_block features[ETHTOOL_DEV_FEATUR= E_WORDS]; > > > > + > > > > + if (copy_from_user(&cmd, useraddr, sizeof(cmd))) > > > > + return -EFAULT; > > > > + useraddr +=3D sizeof(cmd); > > > > + > > > > + if (cmd.count > ETHTOOL_DEV_FEATURE_WORDS) > > > > + cmd.count =3D ETHTOOL_DEV_FEATURE_WORDS; > > > So additional feature words will be silently ignored... > > > > + if (copy_from_user(features, useraddr, sizeof(*features) * cm= d.count)) > > > > + return -EFAULT; > > > > + memset(features + cmd.count, 0, > > > > + sizeof(features) - sizeof(*features) * cmd.count); > > > > + > > > > + features[0].valid &=3D dev->hw_features | NETIF_F_SOFT_FEATUR= ES; > > > [...] > > >=20 > > > ...as will any other unsupported features. This is not a good id= ea. > > > (However, remembering which features are wanted does seem like a = good > > > idea.) > >=20 > > That's intentional. Unsupported features can't be enabled anyway. > > hw_features is supposed to contain all features that the device can= support > > and is able to enable/disable. This set should be constant and anyt= hing that > > is in the wanted_features set but is not supported because of other= conditions > > will be stripped by ndo_fix_features() call. > >=20 > > Other way would be to return EINVAL when bits not changeable are pr= esent in > > the valid mask. I don't want to do that, since then your example of= changing > > a feature without GFEATURES first will not work. > That's right, it shouldn't work. A user says "enable any TSO available". This means ethtool could issue a request with .valid =3D NETIF_F_ALL_TSO, .requested =3D NETIF_F_ALL_T= SO. If the device supports only TSOv4 this should enable it and leave other= s alone as whatever the user wants they can't be enabled. This is 1-1 conversion of the semantics current ethtool ops have - set_= tso corresponds exactly to the request described above. This behaviour also allows to execute a command like "enable as many as you can of ..." tha= t is usual goal of user enabling hardware offloads - to get best possible performance. Nevertheless, what problem is generated by ignoring unsupported bits he= re? I can see the point of returning -EINVAL on bits that are not defined, = though. Is that a good direction? Best Regards, Micha=B3 Miros=B3aw