Skip to contentSkip to conversation

net/gve: add reset path

PATCH Superseded Jasper Tran O'Leary 2 participants 4 messages Jan 21 – Jan 22 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net/gve: add reset path

Currently, the driver does not include any reset functionality and hence cannot be reset by the application. This patch introduces a driver callback for the rte_eth_dev_reset function will which reset the device.

Also, as a precaution, null out device pointers to rx and tx queue arrays when we release the queues during a reset.

---
 doc/guides/nics/gve.rst                | 10 ++++-
 doc/guides/rel_notes/release_26_03.rst |  3 ++
 drivers/net/gve/gve_ethdev.c            | 40 ++++++++++++++++++++
 drivers/net/gve/gve_rx.c                |  2 +
 drivers/net/gve/gve_rx_dqo.c            |  2 +
 drivers/net/gve/gve_tx.c                |  2 +
 drivers/net/gve/gve_tx_dqo.c            |  2 +
 7 files changed, 60 insertions(+), 1 deletion(-)
doc/guides/nics/gve.rst +9 -1
index 2a6798d..415d060 100644
@@ -34,7 +34,7 @@ to find the original base code.
 GVE has 3 queue formats:
 
 - GQI_QPL - GQI with queue page list
-- GQI_RDA - GQI with raw DMA addressing
+- GQI_RDA - GQI with raw DMA addressing (deprecated)
 - DQO_RDA - DQO with raw DMA addressing
 
 GQI_QPL queue format is queue page list mode.
@@ -102,3 +102,11 @@ Because the initial RSS hash creates a default redirection table,
 the redirection table will be available for querying upon initial hash configuration.
 When performing redirection table updates,
 it is possible to update individual table entries.
+
+Application-Initiated Reset
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
+The driver allows an application to reset the gVNIC device. This function
+will tear down and reinitialize the device's resources, including queues and
+administrative queues. The device must be stopped prior to calling the reset
+function. It is the application's responsibility to reinitialize the device
+and restart the device after resetting it.
doc/guides/rel_notes/release_26_03.rst +3 -0
index add2251..fd0fc8e 100644
@@ -55,6 +55,9 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Updated Google Virtual Ethernet (gve) ethernet driver.**
+
+  Added application-initiated device reset.
 
 Removed Items
 -------------
drivers/net/gve/gve_ethdev.c +40 -0
index 6341d89..b280382 100644
@@ -12,6 +12,8 @@
 #include "gve_rss.h"
 #include <ethdev_driver.h>
 
+static int gve_init_priv(struct gve_priv *priv, bool skip_describe_device);
+
 static void
 gve_write_version(uint8_t *driver_version_register)
 {
@@ -550,6 +552,42 @@ gve_dev_close(struct rte_eth_dev *dev)
 	return err;
 }
 
+static int
+gve_dev_reset(struct rte_eth_dev *dev)
+{
+	struct gve_priv *priv = dev->data->dev_private;
+	int err;
+
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+		PMD_DRV_LOG(ERR,
+			"Device reset on port %u not supported in secondary processes.",
+			dev->data->port_id);
+		return -EPERM;
+	}
+
+	if (dev->data->dev_started) {
+		PMD_DRV_LOG(ERR,
+			"Must stop device on port %u before reset.",
+			dev->data->port_id);
+		return -EBUSY;
+	}
+
+	/* Tear down all device resources before re-initializing. */
+	gve_free_queues(dev);
+	gve_teardown_device_resources(priv);
+	gve_adminq_free(priv);
+
+	err = gve_init_priv(priv, true);
+	if (err != 0) {
+		PMD_DRV_LOG(ERR,
+			"Failed to re-init device on port %u after reset.",
+			dev->data->port_id);
+		return err;
+	}
+
+	return 0;
+}
+
 static int
 gve_verify_driver_compatibility(struct gve_priv *priv)
 {
@@ -1068,6 +1106,7 @@ static const struct eth_dev_ops gve_eth_dev_ops = {
 	.dev_start            = gve_dev_start,
 	.dev_stop             = gve_dev_stop,
 	.dev_close            = gve_dev_close,
+	.dev_reset            = gve_dev_reset,
 	.dev_infos_get        = gve_dev_info_get,
 	.rx_queue_setup       = gve_rx_queue_setup,
 	.tx_queue_setup       = gve_tx_queue_setup,
@@ -1094,6 +1133,7 @@ static const struct eth_dev_ops gve_eth_dev_ops_dqo = {
 	.dev_start            = gve_dev_start,
 	.dev_stop             = gve_dev_stop,
 	.dev_close            = gve_dev_close,
+	.dev_reset            = gve_dev_reset,
 	.dev_infos_get        = gve_dev_info_get,
 	.rx_queue_setup       = gve_rx_queue_setup_dqo,
 	.tx_queue_setup       = gve_tx_queue_setup_dqo,
drivers/net/gve/gve_rx.c +2 -0
index 7a91c31..625649c 100644
@@ -290,6 +290,8 @@ gve_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
 	rte_memzone_free(q->qres_mz);
 	q->qres = NULL;
 	rte_free(q);
+
+	dev->data->rx_queues[qid] = NULL;
 }
 
 int
drivers/net/gve/gve_rx_dqo.c +2 -0
index a0ef21b..3aa82b3 100644
@@ -252,6 +252,8 @@ gve_rx_queue_release_dqo(struct rte_eth_dev *dev, uint16_t qid)
 	rte_memzone_free(q->qres_mz);
 	q->qres = NULL;
 	rte_free(q);
+
+	dev->data->rx_queues[qid] = NULL;
 }
 
 static void
drivers/net/gve/gve_tx.c +2 -0
index 015ea96..5c73c21 100644
@@ -547,6 +547,8 @@ gve_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
 	rte_memzone_free(q->qres_mz);
 	q->qres = NULL;
 	rte_free(q);
+
+	dev->data->tx_queues[qid] = NULL;
 }
 
 int
drivers/net/gve/gve_tx_dqo.c +2 -0
index 64141ac..4c632d7 100644
@@ -379,6 +379,8 @@ gve_tx_queue_release_dqo(struct rte_eth_dev *dev, uint16_t qid)
 	rte_memzone_free(q->qres_mz);
 	q->qres = NULL;
 	rte_free(q);
+
+	dev->data->tx_queues[qid] = NULL;
 }
 
 static int
Signature · 1 line
2.52.0.457.g6b5491de43-goog
#1 lore raw
Quoted 9 lines · On Wed, 21 Jan 2026 19:30:18 +0000 "Jasper Tran O'Leary"…
drivers/net/gve/gve_ethdev.c +9 -0
+static int
+gve_dev_reset(struct rte_eth_dev *dev)
+{
+	struct gve_priv *priv = dev->data->dev_private;
+	int err;
+
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+		PMD_DRV_LOG(ERR,
+			"Device reset on port %u not supported in secondary processes.",

drivers/net/gve/gve_ethdev.c gve_dev_close(struct rte_eth_dev *dev) · line 573

Quoted 10 lines
drivers/net/gve/gve_ethdev.c +10 -0
+			dev->data->port_id);
+		return -EPERM;
+	}
+
+	if (dev->data->dev_started) {
+		PMD_DRV_LOG(ERR,
+			"Must stop device on port %u before reset.",
+			dev->data->port_id);
+		return -EBUSY;
+	}

That check is not necessary, because rte_eth_dev_reset always does stop:

int
rte_eth_dev_reset(uint16_t port_id)

{
	struct rte_eth_dev *dev;
	int ret;

	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
	dev = &rte_eth_devices[port_id];

	if (dev->dev_ops->dev_reset == NULL)
		return -ENOTSUP;

	ret = rte_eth_dev_stop(port_id);
	if (ret != 0) {
		RTE_ETHDEV_LOG_LINE(ERR,
			"Failed to stop device (port %u) before reset: %s - ignore",
			port_id, rte_strerror(-ret));
	}
	ret = eth_err(port_id, dev->dev_ops->dev_reset(dev));

	rte_ethdev_trace_reset(port_id, ret);

	return ret;
}

And therefore the documentation should be updated as well.

#2 lore raw

PATCH v3 1/1 net/gve: add reset path

In reply to Jasper Tran O'Leary

Currently, the driver does not include any reset functionality and hence cannot be reset by the application. This patch introduces a driver callback for the rte_eth_dev_reset function will which reset the device.

Also, as a precaution, null out device pointers to rx and tx queue arrays when we release the queues during a reset.

---
v3:
* Remove unnecessary check that device is stopped, update documentation accordingly.

v2:
* Remove unnecessary variable initialization.
* Document reset feature and add to release notes.

 doc/guides/nics/gve.rst                |  9 ++++++-
 doc/guides/rel_notes/release_26_03.rst |  3 +++
 drivers/net/gve/gve_ethdev.c            | 33 +++++++++++++++++++++++++
 drivers/net/gve/gve_rx.c                |  2 ++
 drivers/net/gve/gve_rx_dqo.c            |  2 ++
 drivers/net/gve/gve_tx.c                |  2 ++
 drivers/net/gve/gve_tx_dqo.c            |  2 ++
 7 files changed, 52 insertions(+), 1 deletion(-)
doc/guides/nics/gve.rst +8 -1
index 2a6798d..6b4d1f7 100644
@@ -34,7 +34,7 @@ to find the original base code.
 GVE has 3 queue formats:
 
 - GQI_QPL - GQI with queue page list
-- GQI_RDA - GQI with raw DMA addressing
+- GQI_RDA - GQI with raw DMA addressing (deprecated)
 - DQO_RDA - DQO with raw DMA addressing
 
 GQI_QPL queue format is queue page list mode.
@@ -102,3 +102,10 @@ Because the initial RSS hash creates a default redirection table,
 the redirection table will be available for querying upon initial hash configuration.
 When performing redirection table updates,
 it is possible to update individual table entries.
+
+Application-Initiated Reset
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
+The driver allows an application to reset the gVNIC device. This function
+will tear down and reinitialize the device's resources, including queues and
+administrative queues. It is the application's responsibility to reinitialize
+and restart the device after resetting it.
doc/guides/rel_notes/release_26_03.rst +3 -0
index add2251..fd0fc8e 100644
@@ -55,6 +55,9 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Updated Google Virtual Ethernet (gve) ethernet driver.**
+
+  Added application-initiated device reset.
 
 Removed Items
 -------------
drivers/net/gve/gve_ethdev.c +33 -0
index 6341d89..5912fec 100644
@@ -12,6 +12,8 @@
 #include "gve_rss.h"
 #include <ethdev_driver.h>
 
+static int gve_init_priv(struct gve_priv *priv, bool skip_describe_device);
+
 static void
 gve_write_version(uint8_t *driver_version_register)
 {
@@ -550,6 +552,35 @@ gve_dev_close(struct rte_eth_dev *dev)
 	return err;
 }
 
+static int
+gve_dev_reset(struct rte_eth_dev *dev)
+{
+	struct gve_priv *priv = dev->data->dev_private;
+	int err;
+
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+		PMD_DRV_LOG(ERR,
+			"Device reset on port %u not supported in secondary processes.",
+			dev->data->port_id);
+		return -EPERM;
+	}
+
+	/* Tear down all device resources before re-initializing. */
+	gve_free_queues(dev);
+	gve_teardown_device_resources(priv);
+	gve_adminq_free(priv);
+
+	err = gve_init_priv(priv, true);
+	if (err != 0) {
+		PMD_DRV_LOG(ERR,
+			"Failed to re-init device on port %u after reset.",
+			dev->data->port_id);
+		return err;
+	}
+
+	return 0;
+}
+
 static int
 gve_verify_driver_compatibility(struct gve_priv *priv)
 {
@@ -1068,6 +1099,7 @@ static const struct eth_dev_ops gve_eth_dev_ops = {
 	.dev_start            = gve_dev_start,
 	.dev_stop             = gve_dev_stop,
 	.dev_close            = gve_dev_close,
+	.dev_reset            = gve_dev_reset,
 	.dev_infos_get        = gve_dev_info_get,
 	.rx_queue_setup       = gve_rx_queue_setup,
 	.tx_queue_setup       = gve_tx_queue_setup,
@@ -1094,6 +1126,7 @@ static const struct eth_dev_ops gve_eth_dev_ops_dqo = {
 	.dev_start            = gve_dev_start,
 	.dev_stop             = gve_dev_stop,
 	.dev_close            = gve_dev_close,
+	.dev_reset            = gve_dev_reset,
 	.dev_infos_get        = gve_dev_info_get,
 	.rx_queue_setup       = gve_rx_queue_setup_dqo,
 	.tx_queue_setup       = gve_tx_queue_setup_dqo,
drivers/net/gve/gve_rx.c +2 -0
index 7a91c31..625649c 100644
@@ -290,6 +290,8 @@ gve_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
 	rte_memzone_free(q->qres_mz);
 	q->qres = NULL;
 	rte_free(q);
+
+	dev->data->rx_queues[qid] = NULL;
 }
 
 int
drivers/net/gve/gve_rx_dqo.c +2 -0
index a0ef21b..3aa82b3 100644
@@ -252,6 +252,8 @@ gve_rx_queue_release_dqo(struct rte_eth_dev *dev, uint16_t qid)
 	rte_memzone_free(q->qres_mz);
 	q->qres = NULL;
 	rte_free(q);
+
+	dev->data->rx_queues[qid] = NULL;
 }
 
 static void
drivers/net/gve/gve_tx.c +2 -0
index 015ea96..5c73c21 100644
@@ -547,6 +547,8 @@ gve_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
 	rte_memzone_free(q->qres_mz);
 	q->qres = NULL;
 	rte_free(q);
+
+	dev->data->tx_queues[qid] = NULL;
 }
 
 int
drivers/net/gve/gve_tx_dqo.c +2 -0
index 64141ac..4c632d7 100644
@@ -379,6 +379,8 @@ gve_tx_queue_release_dqo(struct rte_eth_dev *dev, uint16_t qid)
 	rte_memzone_free(q->qres_mz);
 	q->qres = NULL;
 	rte_free(q);
+
+	dev->data->tx_queues[qid] = NULL;
 }
 
 static int
Signature · 1 line
2.52.0.457.g6b5491de43-goog
#3 lore raw
Quoted 11 lines · On Wed, 21 Jan 2026 22:00:35 +0000 "Jasper Tran O'Leary"…

Currently, the driver does not include any reset functionality and hence cannot be reset by the application. This patch introduces a driver callback for the rte_eth_dev_reset function will which reset the device.

Also, as a precaution, null out device pointers to rx and tx queue arrays when we release the queues during a reset.

---

Thanks, updated to this version in next-net