[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200304100050.14a95c36@kicinski-fedora-PC1C0HJN>
Date: Wed, 4 Mar 2020 10:00:50 -0800
From: Jakub Kicinski <kuba@...nel.org>
To: Michal Kubecek <mkubecek@...e.cz>
Cc: davem@...emloft.net, thomas.lendacky@....com, benve@...co.com,
_govind@....com, pkaustub@...co.com, peppe.cavallaro@...com,
alexandre.torgue@...com, joabreu@...opsys.com, snelson@...sando.io,
yisen.zhuang@...wei.com, salil.mehta@...wei.com,
jeffrey.t.kirsher@...el.com, jacob.e.keller@...el.com,
alexander.h.duyck@...ux.intel.com, michael.chan@...adcom.com,
saeedm@...lanox.com, leon@...nel.org, netdev@...r.kernel.org
Subject: Re: [PATCH net-next v2 01/12] ethtool: add infrastructure for
centralized checking of coalescing parameters
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.
> > + 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!
Powered by blists - more mailing lists