[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200304043354.716290-13-kuba@kernel.org>
Date: Tue, 3 Mar 2020 20:33:54 -0800
From: Jakub Kicinski <kuba@...nel.org>
To: davem@...emloft.net
Cc: mkubecek@...e.cz, 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,
Jakub Kicinski <kuba@...nel.org>
Subject: [PATCH net-next v2 12/12] virtio_net: reject unsupported coalescing params
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@...nel.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
Powered by blists - more mailing lists