diff mbox series

[RFC,net,3/3] virtio-net: block ethtool from converting a ring to a small ring

Message ID 20230430131518.2708471-4-alvaro.karsz@solid-run.com (mailing list archive)
State RFC
Delegated to: Netdev Maintainers
Headers show
Series virtio-net: allow usage of small vrings | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net
netdev/fixes_present fail Series targets non-next tree, but doesn't contain any Fixes tags
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 24 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Alvaro Karsz April 30, 2023, 1:15 p.m. UTC
Stop ethtool from resizing a TX/RX ring to size less than
MAX_SKB_FRAGS + 2, if the ring was initialized with a bigger size.

We cannot convert a "normal" ring to a "small" ring in runtime.

Signed-off-by: Alvaro Karsz <alvaro.karsz@solid-run.com>
---
 drivers/net/virtio_net.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
diff mbox series

Patch

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index b4441d63890..b8238eaa1e4 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -2071,6 +2071,12 @@  static int virtnet_rx_resize(struct virtnet_info *vi,
 	bool running = netif_running(vi->dev);
 	int err, qindex;
 
+	/* We cannot convert a ring to a small vring */
+	if (!vi->svring && IS_SMALL_VRING(ring_num)) {
+		netdev_err(vi->dev, "resize rx fail: size is too small..\n");
+		return -EINVAL;
+	}
+
 	qindex = rq - vi->rq;
 
 	if (running)
@@ -2097,6 +2103,12 @@  static int virtnet_tx_resize(struct virtnet_info *vi,
 
 	qindex = sq - vi->sq;
 
+	/* We cannot convert a ring to a small vring */
+	if (!vi->svring && IS_SMALL_VRING(ring_num)) {
+		netdev_err(vi->dev, "resize tx fail: size is too small..\n");
+		return -EINVAL;
+	}
+
 	if (running)
 		virtnet_napi_tx_disable(&sq->napi);