netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net
Cc: mkubecek@suse.cz, 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, alexander.h.duyck@linux.intel.com,
	michael.chan@broadcom.com, saeedm@mellanox.com, leon@kernel.org,
	netdev@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH net-next v2 12/12] virtio_net: reject unsupported coalescing params
Date: Tue,  3 Mar 2020 20:33:54 -0800	[thread overview]
Message-ID: <20200304043354.716290-13-kuba@kernel.org> (raw)
In-Reply-To: <20200304043354.716290-1-kuba@kernel.org>

Set ethtool_ops->coalesce_types to let the core reject
unsupported coalescing parameters.

This driver correctly rejects all unsupported parameters.
No functional changes.

v2: correctly handle rx-frames (and adjust the commit msg)

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 drivers/net/virtio_net.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 84c0d9581f93..c2f2cb933ff7 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -2202,23 +2202,14 @@ static int virtnet_get_link_ksettings(struct net_device *dev,
 static int virtnet_set_coalesce(struct net_device *dev,
 				struct ethtool_coalesce *ec)
 {
-	struct ethtool_coalesce ec_default = {
-		.cmd = ETHTOOL_SCOALESCE,
-		.rx_max_coalesced_frames = 1,
-	};
 	struct virtnet_info *vi = netdev_priv(dev);
 	int i, napi_weight;
 
-	if (ec->tx_max_coalesced_frames > 1)
+	if (ec->tx_max_coalesced_frames > 1 ||
+	    ec->rx_max_coalesced_frames != 1)
 		return -EINVAL;
 
-	ec_default.tx_max_coalesced_frames = ec->tx_max_coalesced_frames;
 	napi_weight = ec->tx_max_coalesced_frames ? NAPI_POLL_WEIGHT : 0;
-
-	/* disallow changes to fields not explicitly tested above */
-	if (memcmp(ec, &ec_default, sizeof(ec_default)))
-		return -EINVAL;
-
 	if (napi_weight ^ vi->sq[0].napi.weight) {
 		if (dev->flags & IFF_UP)
 			return -EBUSY;
@@ -2273,6 +2264,7 @@ static void virtnet_update_settings(struct virtnet_info *vi)
 }
 
 static const struct ethtool_ops virtnet_ethtool_ops = {
+	.coalesce_types = ETHTOOL_COALESCE_MAX_FRAMES,
 	.get_drvinfo = virtnet_get_drvinfo,
 	.get_link = ethtool_op_get_link,
 	.get_ringparam = virtnet_get_ringparam,
-- 
2.24.1


      parent reply	other threads:[~2020-03-04  4:34 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
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 ` Jakub Kicinski [this message]

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=20200304043354.716290-13-kuba@kernel.org \
    --to=kuba@kernel.org \
    --cc=_govind@gmx.com \
    --cc=alexander.h.duyck@linux.intel.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=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).