From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, linux-net-drivers@solarflare.com,
ecree@solarflare.com, mhabets@solarflare.com,
jaswinder.singh@linaro.org, ilias.apalodimas@linaro.org,
Jose.Abreu@synopsys.com, andy@greyhouse.net,
grygorii.strashko@ti.com, andrew@lunn.ch,
michal.simek@xilinx.com, radhey.shyam.pandey@xilinx.com,
mkubecek@suse.cz, Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH net-next 9/9] net: ethtool: require drivers to set supported_coalesce_params
Date: Mon, 16 Mar 2020 13:47:12 -0700 [thread overview]
Message-ID: <20200316204712.3098382-10-kuba@kernel.org> (raw)
In-Reply-To: <20200316204712.3098382-1-kuba@kernel.org>
Now that all in-tree drivers have been updated we can
make the supported_coalesce_params mandatory.
To save debugging time in case some driver was missed
(or is out of tree) add a warning when netdev is registered
with set_coalesce but without supported_coalesce_params.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
include/linux/ethtool.h | 2 ++
net/core/dev.c | 4 ++++
net/ethtool/common.c | 11 +++++++++++
net/ethtool/ioctl.c | 3 ---
4 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index be355f37337d..c1d379bf6ee1 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -458,6 +458,8 @@ struct ethtool_ops {
struct ethtool_stats *, u64 *);
};
+int ethtool_check_ops(const struct ethtool_ops *ops);
+
struct ethtool_rx_flow_rule {
struct flow_rule *rule;
unsigned long priv[0];
diff --git a/net/core/dev.c b/net/core/dev.c
index d84541c24446..021e18251465 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -9283,6 +9283,10 @@ int register_netdevice(struct net_device *dev)
BUG_ON(dev->reg_state != NETREG_UNINITIALIZED);
BUG_ON(!net);
+ ret = ethtool_check_ops(dev->ethtool_ops);
+ if (ret)
+ return ret;
+
spin_lock_init(&dev->addr_list_lock);
lockdep_set_class(&dev->addr_list_lock, &dev->addr_list_lock_key);
diff --git a/net/ethtool/common.c b/net/ethtool/common.c
index 0b22741b2f8f..dab047eec943 100644
--- a/net/ethtool/common.c
+++ b/net/ethtool/common.c
@@ -289,3 +289,14 @@ int ethtool_get_max_rxfh_channel(struct net_device *dev, u32 *max)
kfree(indir);
return ret;
}
+
+int ethtool_check_ops(const struct ethtool_ops *ops)
+{
+ if (WARN_ON(ops->set_coalesce && !ops->supported_coalesce_params))
+ return -EINVAL;
+ /* NOTE: sufficiently insane drivers may swap ethtool_ops at runtime,
+ * the fact that ops are checked at registration time does not
+ * mean the ops attached to a netdev later on are sane.
+ */
+ return 0;
+}
diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
index 258840b19fb5..3852a58d7f95 100644
--- a/net/ethtool/ioctl.c
+++ b/net/ethtool/ioctl.c
@@ -1519,9 +1519,6 @@ ethtool_set_coalesce_supported(struct net_device *dev,
u32 supported_params = dev->ethtool_ops->supported_coalesce_params;
u32 nonzero_params = 0;
- if (!supported_params)
- return true;
-
if (coalesce->rx_coalesce_usecs)
nonzero_params |= ETHTOOL_COALESCE_RX_USECS;
if (coalesce->rx_max_coalesced_frames)
--
2.24.1
next prev parent reply other threads:[~2020-03-16 20:47 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-16 20:47 [PATCH net-next 0/9] ethtool: consolidate irq coalescing - last part Jakub Kicinski
2020-03-16 20:47 ` [PATCH net-next 1/9] net: sfc: reject unsupported coalescing params Jakub Kicinski
2020-03-17 1:29 ` Edward Cree
2020-03-16 20:47 ` [PATCH net-next 2/9] net: socionext: " Jakub Kicinski
2020-03-17 7:51 ` Ilias Apalodimas
2020-03-16 20:47 ` [PATCH net-next 3/9] net: dwc-xlgmac: let core reject the unsupported coalescing parameters Jakub Kicinski
2020-03-16 20:47 ` [PATCH net-next 4/9] net: tehuti: reject unsupported coalescing params Jakub Kicinski
2020-03-16 20:47 ` [PATCH net-next 5/9] net: cpsw: " Jakub Kicinski
2020-03-17 6:38 ` Grygorii Strashko
2020-03-16 20:47 ` [PATCH net-next 6/9] net: davinci_emac: " Jakub Kicinski
2020-03-16 20:47 ` [PATCH net-next 7/9] net: ll_temac: let core reject the unsupported coalescing parameters Jakub Kicinski
2020-03-16 20:47 ` [PATCH net-next 8/9] net: axienet: " Jakub Kicinski
2020-03-16 20:47 ` Jakub Kicinski [this message]
2020-03-17 8:45 ` [PATCH net-next 9/9] net: ethtool: require drivers to set supported_coalesce_params Michal Kubecek
2020-03-18 3:57 ` [PATCH net-next 0/9] ethtool: consolidate irq coalescing - last part David Miller
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=20200316204712.3098382-10-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=Jose.Abreu@synopsys.com \
--cc=andrew@lunn.ch \
--cc=andy@greyhouse.net \
--cc=davem@davemloft.net \
--cc=ecree@solarflare.com \
--cc=grygorii.strashko@ti.com \
--cc=ilias.apalodimas@linaro.org \
--cc=jaswinder.singh@linaro.org \
--cc=linux-net-drivers@solarflare.com \
--cc=mhabets@solarflare.com \
--cc=michal.simek@xilinx.com \
--cc=mkubecek@suse.cz \
--cc=netdev@vger.kernel.org \
--cc=radhey.shyam.pandey@xilinx.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).