netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michal Kubecek <mkubecek@suse.cz>
To: netdev@vger.kernel.org
Cc: Luigi Rizzo <lrizzo@google.com>, Andrew Lunn <andrew@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>
Subject: Re: [PATCH] net-core: remove unnecessary ETHTOOL_GCHANNELS initialization
Date: Thu, 23 Jan 2020 09:40:00 +0100	[thread overview]
Message-ID: <20200123084000.GT22304@unicorn.suse.cz> (raw)
In-Reply-To: <CAMOZA0LiSV2WyzfHuU5=_g0Ru2z-osx0B-WkS-QHMaQeY4GXeA@mail.gmail.com>

On Wed, Jan 22, 2020 at 04:18:56PM -0800, Luigi Rizzo wrote:
> On Wed, Jan 22, 2020 at 3:47 PM Andrew Lunn <andrew@lunn.ch> wrote:
> >
> > On Wed, Jan 22, 2020 at 02:33:26PM -0800, Luigi Rizzo wrote:
> > > struct ethtool_channels does not need .cmd to be set when calling the
> > > driver's ethtool methods. Just zero-initialize it.
> > >
> > > Tested: run ethtool -l and ethtool -L
> >
> > Hi Luigi
> >
> > This seems pretty risky. You are assuming ethtool is the only user of
> > this API. What is actually wrong with putting a sane cmd value, rather
> > than the undefined value 0.
> 
> Hi Andrew, if I understand correctly your suggestion is that even if
> the values are unused, it is better to stay compliant with the header
> file include/uapi/linux/ethtool.h, which does suggest a value for .cmd
> for the various structs

Unless you check all in tree drivers, you cannot be sure there isn't one
which would in fact rely on .cmd being set to expected value. And even
then there could be some out of tree driver; we usually don't care too
much about them but it's always matter of what you gain by the cleanup.
AFAICS it might be just few CPU cycles in this case - if we are lucky.

> and only replace the value in ethtool_set_channels() with the correct
> one ETHTOOL_SCHANNELS ?

That would be incorrect. The initialization in ethtool_set_channels() is
for curr variable which is passed to ->get_channels() (to get current
values for checking new values against maximum). Therefore the correct
command really is ETHTOOL_GCHANNELS.

Michal

  parent reply	other threads:[~2020-01-23  8:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-22 22:33 [PATCH] net-core: remove unnecessary ETHTOOL_GCHANNELS initialization Luigi Rizzo
2020-01-22 23:47 ` Andrew Lunn
2020-01-23  0:18   ` Luigi Rizzo
2020-01-23  8:28     ` Michal Kubecek
2020-01-23  8:40     ` Michal Kubecek [this message]
2020-01-23 17:47       ` Luigi Rizzo
2020-01-23 20:01         ` Michal Kubecek

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=20200123084000.GT22304@unicorn.suse.cz \
    --to=mkubecek@suse.cz \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=lrizzo@google.com \
    --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).