netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Duyck <alexander.h.duyck@linux.intel.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: Michal Kubecek <mkubecek@suse.cz>,
	davem@davemloft.net, thomas.lendacky@amd.com, benve@cisco.com,
	_govind@gmx.com, pkaustub@cisco.com, peppe.cavallaro@st.com,
	alexandre.torgue@st.com, joabreu@synopsys.com,
	snelson@pensando.io, yisen.zhuang@huawei.com,
	salil.mehta@huawei.com, jeffrey.t.kirsher@intel.com,
	jacob.e.keller@intel.com, michael.chan@broadcom.com,
	saeedm@mellanox.com, leon@kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH net-next v2 01/12] ethtool: add infrastructure for centralized checking of coalescing parameters
Date: Wed, 04 Mar 2020 10:50:57 -0800	[thread overview]
Message-ID: <443c085ff3bcc06ad15c34f44f0407a0861dadeb.camel@linux.intel.com> (raw)
In-Reply-To: <20200304102705.192d3b0a@kicinski-fedora-PC1C0HJN>

On Wed, 2020-03-04 at 10:27 -0800, Jakub Kicinski wrote:
> On Wed, 04 Mar 2020 10:12:30 -0800 Alexander Duyck wrote:
> > On Wed, 2020-03-04 at 10:00 -0800, Jakub Kicinski wrote:
> > > On Wed, 4 Mar 2020 08:59:26 +0100 Michal Kubecek wrote:  
> > > > Just an idea: perhaps we could use the fact that struct ethtool_coalesce
> > > > is de facto an array so that this block could be replaced by a loop like
> > > > 
> > > > 	u32 supported_types = dev->ethtool_ops->coalesce_types;
> > > > 	const u32 *values = &coalesce->rx_coalesce_usecs;
> > > > 
> > > > 	for (i = 0; i < __ETHTOOL_COALESCE_COUNT; i++)
> > > > 		if (values[i] && !(supported_types & BIT(i)))
> > > > 			return false;
> > > > 
> > > > and to be sure, BUILD_BUG_ON() or static_assert() check that the offset
> > > > of ->rate_sample_interval matches ETHTOOL_COALESCE_RATE_SAMPLE_INTERVAL.  
> > > 
> > > I kind of prefer the greppability over the saved 40 lines :(
> > > But I'm happy to change if we get more votes for the more concise
> > > version. Or perhaps the Intel version with the warnings printed.  
> > 
> > I agree that it would make more sense to replace the types with an enum
> > definition, and then use the enum to define bits to be used by the
> > drivers.
> 
> The only use for the enum would then be to automate the bit assignment?
> Sounds like we would save some lines for the code and added some for
> the definition. Maybe I'm missing the advantage the enum brings 🤔

Well if you wanted to you could probably also update ethtool_coalesce to
support a unioned __u32 array if you wanted to be more explicit about it. 

I just figured that by making in an enum it becomes less error prone since
you can't accidentally leave a gap or end up renumbering things
unintentionally. Combine that with some logic to take care of the bit
shifting and it wouldn't differ much from how we handle the netdev feature
flags and the like.

> > > > > +	return !dev->ethtool_ops->coalesce_types ||
> > > > > +		(dev->ethtool_ops->coalesce_types & used_types) == used_types;
> > > > > +}    
> > > > 
> > > > I suggest to move the check for !dev->ethtool_ops->coalesce_types to the
> > > > beginning of the function so that we avoid calculating the bitmap if we
> > > > are not going to check it anyway.  
> > > 
> > > Good point!  
> > 
> > So one thing I just wanted to point out. The used_types won't necessarily
> > be correct because it is only actually checking for non-zero types. There
> > are some of these values where a zero is a valid input and the driver will
> > accept it, such as rx_coalesce_usecs for ixgbe. As such we might want to
> > rename the value to nonzero_types instead of used_types.
> 
> Okay, I'll rename. I was also wondering if it should be "params" not
> "types". Initially I was hoping there are categories of coalescing that
> drivers implement, each with set of params. But it seems each vendor is
> just picking fields they like. I think I'll do s/types/params/ as well.

Makes sense to me.


  reply	other threads:[~2020-03-04 18:51 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-04  4:33 [PATCH net-next v2 00/12] ethtool: consolidate parameter checking for irq coalescing Jakub Kicinski
2020-03-04  4:33 ` [PATCH net-next v2 01/12] ethtool: add infrastructure for centralized checking of coalescing parameters Jakub Kicinski
2020-03-04  7:59   ` Michal Kubecek
2020-03-04 18:00     ` Jakub Kicinski
2020-03-04 18:12       ` Alexander Duyck
2020-03-04 18:16         ` Edward Cree
2020-03-04 18:28           ` Jakub Kicinski
2020-03-04 18:34           ` Michal Kubecek
2020-03-04 18:27         ` Jakub Kicinski
2020-03-04 18:50           ` Alexander Duyck [this message]
2020-03-05  4:34             ` Jakub Kicinski
2020-03-04 18:36       ` Michal Kubecek
2020-03-04 21:22       ` Jacob Keller
2020-03-04 21:15   ` Jacob Keller
2020-03-04  4:33 ` [PATCH net-next v2 02/12] xgbe: let core reject the unsupported " Jakub Kicinski
2020-03-04  4:33 ` [PATCH net-next v2 03/12] enic: " Jakub Kicinski
2020-03-04  4:33 ` [PATCH net-next v2 04/12] stmmac: " Jakub Kicinski
2020-03-04  4:33 ` [PATCH net-next v2 05/12] nfp: " Jakub Kicinski
2020-03-04  4:33 ` [PATCH net-next v2 06/12] ionic: " Jakub Kicinski
2020-03-04  4:33 ` [PATCH net-next v2 07/12] hisilicon: " Jakub Kicinski
2020-03-04  4:33 ` [PATCH net-next v2 08/12] ice: " Jakub Kicinski
2020-03-04 18:08   ` Jeff Kirsher
2020-03-04 21:20   ` Jacob Keller
2020-03-04  4:33 ` [PATCH net-next v2 09/12] bnxt: reject unsupported coalescing params Jakub Kicinski
2020-03-04  6:16   ` Michael Chan
2020-03-04  4:33 ` [PATCH net-next v2 10/12] mlx5: " Jakub Kicinski
2020-03-04  4:33 ` [PATCH net-next v2 11/12] e1000e: " Jakub Kicinski
2020-03-04 18:08   ` Jeff Kirsher
2020-03-04  4:33 ` [PATCH net-next v2 12/12] virtio_net: " Jakub Kicinski

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=443c085ff3bcc06ad15c34f44f0407a0861dadeb.camel@linux.intel.com \
    --to=alexander.h.duyck@linux.intel.com \
    --cc=_govind@gmx.com \
    --cc=alexandre.torgue@st.com \
    --cc=benve@cisco.com \
    --cc=davem@davemloft.net \
    --cc=jacob.e.keller@intel.com \
    --cc=jeffrey.t.kirsher@intel.com \
    --cc=joabreu@synopsys.com \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=michael.chan@broadcom.com \
    --cc=mkubecek@suse.cz \
    --cc=netdev@vger.kernel.org \
    --cc=peppe.cavallaro@st.com \
    --cc=pkaustub@cisco.com \
    --cc=saeedm@mellanox.com \
    --cc=salil.mehta@huawei.com \
    --cc=snelson@pensando.io \
    --cc=thomas.lendacky@amd.com \
    --cc=yisen.zhuang@huawei.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 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).