All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
To: Ben Hutchings <bhutchings@solarflare.com>
Cc: netdev@vger.kernel.org, e1000-devel@lists.sourceforge.net,
	Steve Glendinning <steve.glendinning@smsc.com>,
	Greg Kroah-Hartman <gregkh@suse.de>,
	Rasesh Mody <rmody@brocade.com>,
	Debashis Dutt <ddutt@brocade.com>,
	Kristoffer Glembo <kristoffer@gaisler.com>,
	linux-driver@qlogic.com, linux-net-drivers@solarflare.com
Subject: Re: [PATCH 3/4] Ethtool: convert get_tso/set_tso calls to hw_features flags
Date: Tue, 2 Nov 2010 02:14:44 +0100	[thread overview]
Message-ID: <20101102011444.GD15848@rere.qmqm.pl> (raw)
In-Reply-To: <1288646754.2231.70.camel@achroite.uk.solarflarecom.com>

On Mon, Nov 01, 2010 at 09:25:54PM +0000, Ben Hutchings wrote:
> On Sat, 2010-10-30 at 10:44 +0200, Michał Mirosław wrote:
> [...]
> > @@ -1670,7 +1668,7 @@ struct net_device *nes_netdev_init(struct nes_device *nesdev,
> >  	netdev->type = ARPHRD_ETHER;
> >  	netdev->features = NETIF_F_HIGHDMA;
> >  	netdev->netdev_ops = &nes_netdev_ops;
> > -	netdev->hw_features |= NETIF_F_SG;
> > +	netdev->hw_features |= NETIF_F_SG|NETIF_F_TSO;
> 
> There should be spaces on either side of the '|' operator.

The style varies among drivers' sources. I don't have any preference
whatsoever.

> [...]
> > diff --git a/drivers/net/atlx/atl1.c b/drivers/net/atlx/atl1.c
> > index 9e27bd6..814a06c 100644
> > --- a/drivers/net/atlx/atl1.c
> > +++ b/drivers/net/atlx/atl1.c
> > @@ -2992,6 +2992,7 @@ static int __devinit atl1_probe(struct pci_dev *pdev,
> >  	netdev->watchdog_timeo = 5 * HZ;
> >  
> >  	netdev->hw_features |= NETIF_F_SG;
> > +	netdev->hw_features |= NETIF_F_TSO;
> 
> Why not set both flags in the same statement?  You might as well make
> the drivers consistent in this regard.

Will fix. The compiler should combine those anyway.

> [...]
> > diff --git a/net/core/ethtool.c b/net/core/ethtool.c
> > index 017667c..9b0e598 100644
> > --- a/net/core/ethtool.c
> > +++ b/net/core/ethtool.c
> [...]
> > @@ -1065,10 +1048,13 @@ static int __ethtool_set_sg(struct net_device *dev, u32 data)
> >  {
> >  	int err;
> >  
> > -	if (!data && dev->ethtool_ops->set_tso) {
> > -		err = dev->ethtool_ops->set_tso(dev, 0);
> > -		if (err)
> > -			return err;
> > +	if (!data && (dev->hw_features & NETIF_F_ALL_TSO)) {
> > +		if (dev->ethtool_ops->hw_set_tso) {
> > +			err = dev->ethtool_ops->hw_set_tso(dev, 0);
> > +			if (err < 0)
> > +				return err;
> > +		}
> > +		dev->features &= dev->hw_features & NETIF_F_ALL_TSO;
> 
> Surely this should be:
> 		dev->features &= ~NETIF_F_ALL_TSO;

I originally thought of hw_features as a bitfield of features changable
by ethtool.  So if driver writer wanted to have TSO permanently on but
allow toggling of TSO6 for debug than that would work.  There is actually
a bug in original code: it doesn't clear NETIF_F_TSO if there is no set_tso
function, but clears NETIF_F_SG anyway (the bug is preserved).  This is
a material for successive patches.

BTW, why is scatter-gather needed for TSO and TX checksumming?  I see
no interdependence on s-g for those offloads.

> [...]
> > @@ -1158,7 +1149,18 @@ static int ethtool_set_tso(struct net_device *dev, char __user *useraddr)
> >  	if (edata.data && !(dev->features & NETIF_F_SG))
> >  		return -EINVAL;
> >  
> > -	return dev->ethtool_ops->set_tso(dev, edata.data);
> > +	if (dev->ethtool_ops->hw_set_tso) {
> > +		int err = dev->ethtool_ops->hw_set_tso(dev, edata.data);
> > +		if (err)
> > +			return min(err, 0);
> [...]
> 
> Again, the odd semantics of a positive value need to be documented.

Of course.

Best Regards,
Michał Mirosław
 

  reply	other threads:[~2010-11-02  1:14 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-31  3:40 [PATCH 0/4] Ethtool: cleanup strategy Michał Mirosław
2010-10-30  4:27 ` [PATCH 1/4] Ethtool: Introduce hw_features field in struct netdevice Michał Mirosław
2010-10-30  4:28 ` [PATCH 2/4] Ethtool: convert get_sg/set_sg calls to hw_features flag Michał Mirosław
2010-11-01 21:15   ` Ben Hutchings
2010-11-02  0:59     ` Michał Mirosław
2010-11-02  2:24   ` Matt Carlson
2010-11-03 22:29     ` Micha?? Miros??aw
2010-11-03 22:42       ` Matt Carlson
2010-11-03 22:58         ` Michał Mirosław
2010-10-30  8:44 ` [PATCH 3/4] Ethtool: convert get_tso/set_tso calls to hw_features flags Michał Mirosław
2010-11-01 21:25   ` Ben Hutchings
2010-11-02  1:14     ` Michał Mirosław [this message]
2010-11-02  2:49   ` Matt Carlson
2010-10-31  0:09 ` [PATCH 4/4] Ethtool: convert get_tx_csum/set_tx_csum " Michał Mirosław
2010-11-01 21:38   ` Ben Hutchings
2010-11-02  1:23     ` Michał Mirosław
2010-10-31  4:18 ` [PATCH 0/4] Ethtool: cleanup strategy David Miller
2010-10-31  4:30   ` Michał Mirosław
2010-11-01 21:05 ` Ben Hutchings
2010-11-02  1:02   ` Michał Mirosław
2010-11-02  1:14     ` Ben Hutchings
2010-11-02  1:30       ` Michał Mirosław

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=20101102011444.GD15848@rere.qmqm.pl \
    --to=mirq-linux@rere.qmqm.pl \
    --cc=bhutchings@solarflare.com \
    --cc=ddutt@brocade.com \
    --cc=e1000-devel@lists.sourceforge.net \
    --cc=gregkh@suse.de \
    --cc=kristoffer@gaisler.com \
    --cc=linux-driver@qlogic.com \
    --cc=linux-net-drivers@solarflare.com \
    --cc=netdev@vger.kernel.org \
    --cc=rmody@brocade.com \
    --cc=steve.glendinning@smsc.com \
    /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.