Skip to contentSkip to conversation

gve: AdminQ mode related refactors

PATCH Superseded Harshitha Ramamurthy 4 participants 29 messages Sep 3 – Sep 8

Subsystems (4)

v5 of 9 Superseded Latest is v9 →

lore
Share & tools
lore

Harshitha Ramamurthy

author maintainer
#0 lore raw

v5 cover gve: AdminQ mode related refactors

This series is preparing the driver for the addition of a new control plane mode(MailboxQ) by commonizing and reusing as much code as possible. MailboxQ is a new control plane infrastructure which uses mailbox queues. This is a new control plane to communicate with the device when the driver is running on bare-metal instances as well as newer versions of the device.

This series contains 2 main changes to the gve driver's existing control plane(AdminQ):
1) refactor some initialization/teardown path methods to make it work for both control planes.
2) add gve_ctrl_ops structure to the driver for various control plane operations

The refactors are mainly around the init, reset and recover paths so that functionalities could be moved into the control ops like 'set_num_queues', 'set_num_ntfy_blks' etc.

This patch series only sets the control ops for AdminQ mode. This is intended as a preparation for adding MailboxQ mode in upcoming series which will add the new control plane infrastructure and then introduce the corresponding control ops for MailboxQ mode.

The entire list of future patches can be found here for reference:
https://github.com/hramamurthy12/linux/commits/gve-mailbox-queues/

Changes in v5:
- This series contains 12 patches since 3 patches from v4 were applied
- Picked up Przemek Kitszel's Reviewed-by tag
- Honor device provided default no. of Qs and max rx buffer size correctly (patch 1, Sashiko)
- drop unnecessary header files and __maybe_unused tag (patch 4, Sashiko)
- fix workqueue disable count, destroy rings before stopping Qs, stop queues in error path in gve_close, preserve ordering of gve_turndown->gve_destroy_rings->gve_queues_stop during close and reset (patch 6, Sashiko)
- drop double logging in all paths for queue creation/destruction (patch 11, Sashiko)
- v4: https://lore.kernel.org/netdev/[email protected]/

Changes in v4:
- Reduce code churn by placing new functions directly in gve_adminq.c, introducing final tab spacing and using local variable (Przemek Kitszel)
- Fix kdoc formatting and drop spurious management interrupt(patch 9)
- Propagate release_db_resources naming change (patch 12)
- Remove double logging in destroy queues path (patch 14)
- v3: https://lore.kernel.org/netdev/[email protected]/

Changes in v3:
- Fix driver compatibility verification in the reset and recovery paths (patches 2, 8).
- Mark gve_adminq_get_device_properties() with __maybe_unused ahead of its usage (patch 7).
- Refine error handling and resource cleanup in reset, probe, and queue creation paths (patches 8, 9, 11, 14).
- Keep IRQ doorbell allocation/release in control plane resource helpers (patch 12).
- Minor fixes: fix TOCTOU issue for link speed, correct kdoc comments, and remove redundant teardown calls (patches 4, 11, 15).
- v2: https://lore.kernel.org/netdev/[email protected]/

Changes in v2:
- Rebased against latest net-next to resolve apply failure for patch 5
- Fixed a few typos in commit messages of patch 9 and 14
- Fixed a kdoc warning in patch 9
- v1: https://lore.kernel.org/netdev/[email protected]/
Harshitha Ramamurthy (6):
gve: add struct gve_device_info to hold device properties
gve: introduce control plane operations structure
gve: introduce ctrl ops to set vectors and Qs
gve: introduce gve_adminq_get_device_properties()
gve: refactor gve_init_priv for reset path
gve: add ctrl ops to for queue operations

Joshua Washington (6):
gve: simplify reset logic
gve: add gve_ctrl_ops for gve initialization/teardown sequences
gve: split up notify block allocation and setup paths
gve: introduce new methods to handle IRQ doorbells
gve: setup and teardown management interrupts
gve: add link status/speed ctrl ops

 drivers/net/ethernet/google/gve/gve.h         |  87 +-
 drivers/net/ethernet/google/gve/gve_adminq.c  | 380 ++++++--
 drivers/net/ethernet/google/gve/gve_adminq.h  |  30 +-
 drivers/net/ethernet/google/gve/gve_dqo.h     |   2 +-
 drivers/net/ethernet/google/gve/gve_ethtool.c |   5 +-
 .../net/ethernet/google/gve/gve_flow_rule.c   |  15 +-
 drivers/net/ethernet/google/gve/gve_main.c    | 886 +++++++++---------
 7 files changed, 876 insertions(+), 529 deletions(-)
Signature · 1 line
2.55.0.979.g7e5102b832-goog
author maintainer
#1 lore raw

PATCH v5 1/12 gve: add struct gve_device_info to hold device properties

In the current AdminQ mode, device properties are written into struct gve_device_descriptor that is allocated in shared memory between the driver and device. In the upcoming MailboxQ mode, these properties will be returned in the response of a mailbox message. Hence, add struct gve_device_info as the structure that holds all the properties that are negotiated with the device in either mode.

Change the AdminQ mode method gve_adminq_describe_device() and its children to fill up device information into this newly introduced struct gve_device_info. Move a few helper functions and code that set device properties in the priv structure into gve_init_priv(). So now gve_init_priv() calls/does the following:

- gve_set_mtu()
- gve_set_mac()
- gve_set_queue_properties()
- gve_set_buf_sizes()
- set flow steering and RSS properties
- set other priv properties

When MailboxQ support is added, device information will be filled into the same structure and the same gve_init_priv() path would be used to set device properties to ensure common code reusage.

These changes are refactors only, no functional change.

---
v5:
- ensure using default_tx/rx_queues (Sashiko)
- honor device provided rx buffer size correctly (Sashiko)

v4:
- reuse mtu variable

v3:
- Read default_min_ring_size from device info instead of priv

 drivers/net/ethernet/google/gve/gve.h        |  29 +++++
 drivers/net/ethernet/google/gve/gve_adminq.c | 128 +++++++++++--------
 drivers/net/ethernet/google/gve/gve_adminq.h |   6 -
 drivers/net/ethernet/google/gve/gve_main.c   |  86 +++++++++----
 4 files changed, 169 insertions(+), 80 deletions(-)
drivers/net/ethernet/google/gve/gve.h +29 -0
index c280ff35ee77..021adb9108df 100644
@@ -797,6 +797,34 @@ struct gve_ptp {
 	struct gve_priv *priv;
 };
 
+struct gve_device_info {
+	enum gve_queue_format queue_format;
+	u16 default_tx_queues;
+	u16 default_rx_queues;
+	u16 max_tx_queues;
+	u16 max_rx_queues;
+	u16 default_tx_ring_size;
+	u16 default_rx_ring_size;
+	u16 max_tx_ring_size;
+	u16 max_rx_ring_size;
+	u16 min_tx_ring_size;
+	u16 min_rx_ring_size;
+	u16 max_mtu;
+	u8 mac[ETH_ALEN];
+	u16 max_rx_buffer_size;
+	u16 header_buf_size;
+	u32 max_flow_rules;
+	u16 rss_key_size;
+	u16 rss_lut_size;
+	u16 tx_pages_per_qpl;
+	u16 num_event_counters;
+	u64 max_registered_pages;
+	bool default_min_ring_size;
+	bool nic_timestamp_supported;
+	bool modify_ring_size_enabled;
+	bool cache_rss_config;
+};
+
 struct gve_priv {
 	struct net_device *dev;
 	struct gve_tx_ring *tx; /* array of tx_cfg.num_queues */
@@ -929,6 +957,7 @@ struct gve_priv {
 	struct gve_nic_ts_report *nic_ts_report;
 	dma_addr_t nic_ts_report_bus;
 	u64 last_sync_nic_counter; /* Clock counter from last NIC TS report */
+	struct gve_device_info device_info;
 };
 
 enum gve_service_task_flags_bit {
drivers/net/ethernet/google/gve/gve_adminq.c +78 -50

245 lines not on this page · raw message

drivers/net/ethernet/google/gve/gve_adminq.h +0 -6
index 68c63ce75505..a17af755b454 100644
@@ -658,10 +658,4 @@ int gve_adminq_get_ptype_map_dqo(struct gve_priv *priv,
 				 struct gve_ptype_lut *ptype_lut);
 int gve_set_num_ntfy_blks(struct gve_priv *priv);
 void gve_set_num_queues(struct gve_priv *priv);
-void gve_set_queue_properties(struct gve_priv *priv,
-			      struct gve_device_descriptor *descriptor);
-int gve_set_mtu(struct gve_priv *priv,
-		struct gve_device_descriptor *descriptor);
-void gve_set_mac(struct gve_priv *priv,
-		 struct gve_device_descriptor *descriptor);
 #endif /* _GVE_ADMINQ_H */
drivers/net/ethernet/google/gve/gve_main.c +62 -24

144 lines not on this page · raw message

Signature · 1 line
2.55.0.979.g7e5102b832-goog
author maintainer
#4 lore raw

PATCH v5 2/12 gve: introduce control plane operations structure

In reply to Harshitha Ramamurthy

To abstract out the difference in implementation of control plane operations between the existing Adminq ABI and the upcoming Mailbox ABI, introduce a new gve_ctrl_ops structure which will contain the basic operations. At probe, these ops will be set based on the ABI and the corresponding ops will be called in relevant places.

As of this patch, only Adminq ops are set. In future patches, corresponding ops will be set for the new mailbox mode.

Implement a ctrl op to map/unmap the doorbell bar. Since this functionality has moved to a control op, call this op after control ops are set for AdminQ mode.

---
 drivers/net/ethernet/google/gve/gve.h        | 11 ++++++
 drivers/net/ethernet/google/gve/gve_adminq.c | 21 ++++++++++++
 drivers/net/ethernet/google/gve/gve_adminq.h |  2 ++
 drivers/net/ethernet/google/gve/gve_main.c   | 36 +++++++++++---------
 4 files changed, 54 insertions(+), 16 deletions(-)
drivers/net/ethernet/google/gve/gve.h +11 -0
index 021adb9108df..56148ea3cfbf 100644
@@ -825,6 +825,16 @@ struct gve_device_info {
 	bool cache_rss_config;
 };
 
+/**
+ * struct gve_ctrl_ops - Control plane operations structure
+ * @map_db_bar: Maps the doorbell BAR for the device and store in @priv.
+ * @unmap_db_bar: Unmaps the doorbell BAR previously mapped by @map_db_bar.
+ */
+struct gve_ctrl_ops {
+	int (*map_db_bar)(struct gve_priv *priv);
+	void (*unmap_db_bar)(struct gve_priv *priv);
+};
+
 struct gve_priv {
 	struct net_device *dev;
 	struct gve_tx_ring *tx; /* array of tx_cfg.num_queues */
@@ -958,6 +968,7 @@ struct gve_priv {
 	dma_addr_t nic_ts_report_bus;
 	u64 last_sync_nic_counter; /* Clock counter from last NIC TS report */
 	struct gve_device_info device_info;
+	const struct gve_ctrl_ops *ctrl_ops;
 };
 
 enum gve_service_task_flags_bit {
drivers/net/ethernet/google/gve/gve_adminq.c +21 -0
index 512349c5517f..08d8e49d563e 100644
@@ -1637,3 +1637,24 @@ void gve_set_num_queues(struct gve_priv *priv)
 						device_info->default_rx_queues,
 						priv->rx_cfg.num_queues);
 }
+
+int gve_adminq_map_db_bar(struct gve_priv *priv)
+{
+	struct pci_dev *pdev = priv->pdev;
+	void __iomem *db_bar;
+
+	db_bar = pci_iomap(pdev, GVE_DOORBELL_BAR, 0);
+	if (!db_bar) {
+		dev_err(&pdev->dev, "Failed to map doorbell bar!\n");
+		return -ENOMEM;
+	}
+	priv->db_bar2 = db_bar;
+	return 0;
+}
+
+void gve_adminq_unmap_db_bar(struct gve_priv *priv)
+{
+	struct pci_dev *pdev = priv->pdev;
+
+	pci_iounmap(pdev, priv->db_bar2);
+}
drivers/net/ethernet/google/gve/gve_adminq.h +2 -0
index a17af755b454..93d3cabb67f1 100644
@@ -658,4 +658,6 @@ int gve_adminq_get_ptype_map_dqo(struct gve_priv *priv,
 				 struct gve_ptype_lut *ptype_lut);
 int gve_set_num_ntfy_blks(struct gve_priv *priv);
 void gve_set_num_queues(struct gve_priv *priv);
+int gve_adminq_map_db_bar(struct gve_priv *priv);
+void gve_adminq_unmap_db_bar(struct gve_priv *priv);
 #endif /* _GVE_ADMINQ_H */
drivers/net/ethernet/google/gve/gve_main.c +20 -16
index d3882de584e3..93b714e1d130 100644
@@ -2460,6 +2460,11 @@ static void gve_set_buf_sizes(struct gve_priv *priv)
 		priv->header_buf_size = device_info->header_buf_size;
 }
 
+static const struct gve_ctrl_ops gve_adminq_ops = {
+	.map_db_bar		= gve_adminq_map_db_bar,
+	.unmap_db_bar		= gve_adminq_unmap_db_bar,
+};
+
 static int gve_init_priv(struct gve_priv *priv, bool skip_describe_device)
 {
 	struct gve_device_info *device_info = &priv->device_info;
@@ -2861,7 +2866,6 @@ static int gve_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
 	int max_tx_queues, max_rx_queues;
 	struct net_device *dev;
-	__be32 __iomem *db_bar;
 	struct gve_registers __iomem *reg_bar;
 	struct gve_priv *priv;
 	int err;
@@ -2889,13 +2893,6 @@ static int gve_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 		goto abort_with_pci_region;
 	}
 
-	db_bar = pci_iomap(pdev, GVE_DOORBELL_BAR, 0);
-	if (!db_bar) {
-		dev_err(&pdev->dev, "Failed to map doorbell bar!\n");
-		err = -ENOMEM;
-		goto abort_with_reg_bar;
-	}
-
 	gve_write_version(&reg_bar->driver_version);
 	/* Get max queues to alloc etherdev */
 	max_tx_queues = ioread32be(&reg_bar->max_tx_queues);
@@ -2905,7 +2902,7 @@ static int gve_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (!dev) {
 		dev_err(&pdev->dev, "could not allocate netdev\n");
 		err = -ENOMEM;
-		goto abort_with_db_bar;
+		goto abort_with_reg_bar;
 	}
 	SET_NETDEV_DEV(dev, &pdev->dev);
 	pci_set_drvdata(pdev, dev);
@@ -2937,19 +2934,27 @@ static int gve_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	priv->pdev = pdev;
 	priv->msg_enable = DEFAULT_MSG_LEVEL;
 	priv->reg_bar0 = reg_bar;
-	priv->db_bar2 = db_bar;
 	priv->service_task_flags = 0x0;
 	priv->state_flags = 0x0;
 	priv->ethtool_flags = 0x0;
 	priv->rx_cfg.packet_buffer_size = GVE_DEFAULT_RX_BUFFER_SIZE;
 	priv->max_rx_buffer_size = GVE_DEFAULT_RX_BUFFER_SIZE;
 
+	/* Set adminq ctrl ops */
+	priv->ctrl_ops = &gve_adminq_ops;
+
+	err = priv->ctrl_ops->map_db_bar(priv);
+	if (err) {
+		err = -ENOMEM;
+		goto abort_with_netdev;
+	}
+
 	gve_set_probe_in_progress(priv);
 	priv->gve_wq = alloc_ordered_workqueue("gve", 0);
 	if (!priv->gve_wq) {
 		dev_err(&pdev->dev, "Could not allocate workqueue");
 		err = -ENOMEM;
-		goto abort_with_netdev;
+		goto abort_with_unmap_db_bar;
 	}
 	INIT_WORK(&priv->service_task, gve_service_task);
 	INIT_WORK(&priv->stats_report_task, gve_stats_report_task);
@@ -2979,12 +2984,12 @@ static int gve_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 abort_with_wq:
 	destroy_workqueue(priv->gve_wq);
 
+abort_with_unmap_db_bar:
+	priv->ctrl_ops->unmap_db_bar(priv);
+
 abort_with_netdev:
 	free_netdev(dev);
 
-abort_with_db_bar:
-	pci_iounmap(pdev, db_bar);
-
 abort_with_reg_bar:
 	pci_iounmap(pdev, reg_bar);
 
@@ -3000,14 +3005,13 @@ static void gve_remove(struct pci_dev *pdev)
 {
 	struct net_device *netdev = pci_get_drvdata(pdev);
 	struct gve_priv *priv = netdev_priv(netdev);
-	__be32 __iomem *db_bar = priv->db_bar2;
 	void __iomem *reg_bar = priv->reg_bar0;
 
 	unregister_netdev(netdev);
 	gve_teardown_priv_resources(priv);
 	destroy_workqueue(priv->gve_wq);
+	priv->ctrl_ops->unmap_db_bar(priv);
 	free_netdev(netdev);
-	pci_iounmap(pdev, db_bar);
 	pci_iounmap(pdev, reg_bar);
 	pci_release_regions(pdev);
 	pci_disable_device(pdev);
Signature · 1 line
2.55.0.979.g7e5102b832-goog
author maintainer
#6 lore raw

PATCH v5 3/12 gve: introduce ctrl ops to set vectors and Qs

In reply to Harshitha Ramamurthy

Introduce following ctrl ops for Adminq mode.

- set_num_queues to set maximum and default TX/RX queues in the alloc structures used in the initialization flow.
- set_num_ntfy_blks op to set number of vectors(ntfy_blks) in the initialization flow.

This is done by attaching the adminq_ prefix to the existing functions placed in the gve_adminq.c file.

---
v4: Attach 'adminq_' prefix in the function names for gve_set_num_queues
and gve_set_num_ntfy_blks and set them as ops (Przemek Kitszel)

 drivers/net/ethernet/google/gve/gve.h        | 6 ++++++
 drivers/net/ethernet/google/gve/gve_adminq.c | 4 ++--
 drivers/net/ethernet/google/gve/gve_adminq.h | 4 ++--
 drivers/net/ethernet/google/gve/gve_main.c   | 6 ++++--
 4 files changed, 14 insertions(+), 6 deletions(-)
drivers/net/ethernet/google/gve/gve.h +6 -0
index 56148ea3cfbf..1bc5e32b6618 100644
@@ -829,10 +829,16 @@ struct gve_device_info {
  * struct gve_ctrl_ops - Control plane operations structure
  * @map_db_bar: Maps the doorbell BAR for the device and store in @priv.
  * @unmap_db_bar: Unmaps the doorbell BAR previously mapped by @map_db_bar.
+ * @set_num_queues: Sets default and max TX/RX queues into allocation
+ *                  structures stored in @priv to be used during initialization.
+ * @set_num_ntfy_blks: Sets no. of vectors into @priv to be used during
+ *                     initialization.
  */
 struct gve_ctrl_ops {
 	int (*map_db_bar)(struct gve_priv *priv);
 	void (*unmap_db_bar)(struct gve_priv *priv);
+	void (*set_num_queues)(struct gve_priv *priv);
+	int (*set_num_ntfy_blks)(struct gve_priv *priv);
 };
 
 struct gve_priv {
drivers/net/ethernet/google/gve/gve_adminq.c +2 -2
index 08d8e49d563e..046155ae7d66 100644
@@ -1592,7 +1592,7 @@ int gve_adminq_query_rss_config(struct gve_priv *priv, struct ethtool_rxfh_param
 	return err;
 }
 
-int gve_set_num_ntfy_blks(struct gve_priv *priv)
+int gve_adminq_set_num_ntfy_blks(struct gve_priv *priv)
 {
 	int num_ntfy;
 
@@ -1616,7 +1616,7 @@ int gve_set_num_ntfy_blks(struct gve_priv *priv)
 	return 0;
 }
 
-void gve_set_num_queues(struct gve_priv *priv)
+void gve_adminq_set_num_queues(struct gve_priv *priv)
 {
 	struct gve_device_info *device_info = &priv->device_info;
 
drivers/net/ethernet/google/gve/gve_adminq.h +2 -2
index 93d3cabb67f1..ed3504853908 100644
@@ -656,8 +656,8 @@ int gve_adminq_report_nic_ts(struct gve_priv *priv,
 struct gve_ptype_lut;
 int gve_adminq_get_ptype_map_dqo(struct gve_priv *priv,
 				 struct gve_ptype_lut *ptype_lut);
-int gve_set_num_ntfy_blks(struct gve_priv *priv);
-void gve_set_num_queues(struct gve_priv *priv);
+int gve_adminq_set_num_ntfy_blks(struct gve_priv *priv);
+void gve_adminq_set_num_queues(struct gve_priv *priv);
 int gve_adminq_map_db_bar(struct gve_priv *priv);
 void gve_adminq_unmap_db_bar(struct gve_priv *priv);
 #endif /* _GVE_ADMINQ_H */
drivers/net/ethernet/google/gve/gve_main.c +4 -2
index 93b714e1d130..12b23c2f948f 100644
@@ -2463,6 +2463,8 @@ static void gve_set_buf_sizes(struct gve_priv *priv)
 static const struct gve_ctrl_ops gve_adminq_ops = {
 	.map_db_bar		= gve_adminq_map_db_bar,
 	.unmap_db_bar		= gve_adminq_unmap_db_bar,
+	.set_num_queues		= gve_adminq_set_num_queues,
+	.set_num_ntfy_blks	= gve_adminq_set_num_ntfy_blks,
 };
 
 static int gve_init_priv(struct gve_priv *priv, bool skip_describe_device)
@@ -2501,14 +2503,14 @@ static int gve_init_priv(struct gve_priv *priv, bool skip_describe_device)
 
 	priv->queue_format = priv->device_info.queue_format;
 
-	err = gve_set_num_ntfy_blks(priv);
+	err = priv->ctrl_ops->set_num_ntfy_blks(priv);
 	if (err) {
 		dev_err(&priv->pdev->dev,
 			"Could not setup notify blocks: err=%d\n", err);
 		goto err;
 	}
 
-	gve_set_num_queues(priv);
+	priv->ctrl_ops->set_num_queues(priv);
 	dev_info(&priv->pdev->dev, "TX queues %d, RX queues %d\n",
 		 priv->tx_cfg.num_queues, priv->rx_cfg.num_queues);
 	dev_info(&priv->pdev->dev, "Max TX queues %d, Max RX queues %d\n",
Signature · 1 line
2.55.0.979.g7e5102b832-goog
author maintainer
#7 lore raw

PATCH v5 4/12 gve: introduce gve_adminq_get_device_properties()

In reply to Harshitha Ramamurthy

Introduce gve_adminq_get_device_properties() which executes the first two Adminq commands: VERIFY_DRIVER_COMPATIBILITY and DESCRIBE_DEVICE so that this can be called during initialization.

Move these to Adminq specific files. This is just code movement, no functional change.

---
v5:
- Place the utsname.h and version.h header files only where needed
- drop uneccessary __maybe_unused (Sashiko)

v3:
- move patch down so that the function is introduced just before usage
- mark function as maybe_unused
- update commit message

 drivers/net/ethernet/google/gve/gve_adminq.c | 68 ++++++++++++++++++--
 drivers/net/ethernet/google/gve/gve_adminq.h |  5 +-
 drivers/net/ethernet/google/gve/gve_main.c   | 47 +-------------
 3 files changed, 65 insertions(+), 55 deletions(-)
drivers/net/ethernet/google/gve/gve_adminq.c +62 -6
index 046155ae7d66..f420a8e1dd3d 100644
@@ -6,6 +6,8 @@
 
 #include <linux/etherdevice.h>
 #include <linux/pci.h>
+#include <linux/utsname.h>
+#include <linux/version.h>
 #include "gve.h"
 #include "gve_adminq.h"
 #include "gve_register.h"
@@ -1143,6 +1145,27 @@ int gve_adminq_describe_device(struct gve_priv *priv)
 	return err;
 }
 
+int gve_adminq_get_device_properties(struct gve_priv *priv)
+{
+	int err;
+
+	err = gve_adminq_verify_driver_compatibility(priv);
+	if (err) {
+		dev_err(&priv->pdev->dev,
+			"Could not verify driver compatibility: err=%d\n", err);
+		return err;
+	}
+
+	/* Get the initial information we need from the device */
+	err = gve_adminq_describe_device(priv);
+	if (err) {
+		dev_err(&priv->pdev->dev,
+			"Could not get device information: err=%d\n", err);
+		return err;
+	}
+	return 0;
+}
+
 int gve_adminq_register_page_list(struct gve_priv *priv,
 				  struct gve_queue_page_list *qpl)
 {
@@ -1205,20 +1228,53 @@ int gve_adminq_report_stats(struct gve_priv *priv, u64 stats_report_len,
 	return gve_adminq_execute_cmd(priv, &cmd);
 }
 
-int gve_adminq_verify_driver_compatibility(struct gve_priv *priv,
-					   u64 driver_info_len,
-					   dma_addr_t driver_info_addr)
+int gve_adminq_verify_driver_compatibility(struct gve_priv *priv)
 {
+	struct gve_driver_info *driver_info;
 	union gve_adminq_command cmd;
+	dma_addr_t driver_info_bus;
+	int err;
+
+	driver_info = dma_alloc_coherent(&priv->pdev->dev,
+					 sizeof(struct gve_driver_info),
+					 &driver_info_bus, GFP_KERNEL);
+	if (!driver_info)
+		return -ENOMEM;
+
+	*driver_info = (struct gve_driver_info) {
+		.os_type = 1, /* Linux */
+		.os_version_major = cpu_to_be32(LINUX_VERSION_MAJOR),
+		.os_version_minor = cpu_to_be32(LINUX_VERSION_SUBLEVEL),
+		.os_version_sub = cpu_to_be32(LINUX_VERSION_PATCHLEVEL),
+		.driver_capability_flags = {
+			cpu_to_be64(GVE_DRIVER_CAPABILITY_FLAGS1),
+			cpu_to_be64(GVE_DRIVER_CAPABILITY_FLAGS2),
+			cpu_to_be64(GVE_DRIVER_CAPABILITY_FLAGS3),
+			cpu_to_be64(GVE_DRIVER_CAPABILITY_FLAGS4),
+		},
+	};
+	strscpy(driver_info->os_version_str1, utsname()->release,
+		sizeof(driver_info->os_version_str1));
+	strscpy(driver_info->os_version_str2, utsname()->version,
+		sizeof(driver_info->os_version_str2));
 
 	memset(&cmd, 0, sizeof(cmd));
 	cmd.opcode = cpu_to_be32(GVE_ADMINQ_VERIFY_DRIVER_COMPATIBILITY);
 	cmd.verify_driver_compatibility = (struct gve_adminq_verify_driver_compatibility) {
-		.driver_info_len = cpu_to_be64(driver_info_len),
-		.driver_info_addr = cpu_to_be64(driver_info_addr),
+		.driver_info_len = cpu_to_be64(sizeof(struct gve_driver_info)),
+		.driver_info_addr = cpu_to_be64(driver_info_bus),
 	};
 
-	return gve_adminq_execute_cmd(priv, &cmd);
+	err = gve_adminq_execute_cmd(priv, &cmd);
+
+	/* It's ok if the device doesn't support this */
+	if (err == -EOPNOTSUPP)
+		err = 0;
+
+	dma_free_coherent(&priv->pdev->dev,
+			  sizeof(struct gve_driver_info),
+			  driver_info, driver_info_bus);
+	return err;
 }
 
 int gve_adminq_report_link_speed(struct gve_priv *priv)
drivers/net/ethernet/google/gve/gve_adminq.h +2 -3
index ed3504853908..2ab68c822e22 100644
@@ -640,9 +640,8 @@ int gve_adminq_register_page_list(struct gve_priv *priv,
 int gve_adminq_unregister_page_list(struct gve_priv *priv, u32 page_list_id);
 int gve_adminq_report_stats(struct gve_priv *priv, u64 stats_report_len,
 			    dma_addr_t stats_report_addr, u64 interval);
-int gve_adminq_verify_driver_compatibility(struct gve_priv *priv,
-					   u64 driver_info_len,
-					   dma_addr_t driver_info_addr);
+int gve_adminq_verify_driver_compatibility(struct gve_priv *priv);
+int gve_adminq_get_device_properties(struct gve_priv *priv);
 int gve_adminq_report_link_speed(struct gve_priv *priv);
 int gve_adminq_add_flow_rule(struct gve_priv *priv, struct gve_adminq_flow_rule *rule, u32 loc);
 int gve_adminq_del_flow_rule(struct gve_priv *priv, u32 loc);
drivers/net/ethernet/google/gve/gve_main.c +1 -46

65 lines not on this page · raw message

Signature · 1 line
2.55.0.979.g7e5102b832-goog
author maintainer
#8 lore raw

PATCH v5 5/12 gve: refactor gve_init_priv for reset path

In reply to Harshitha Ramamurthy

The driver does not need to renegotiate all properties with the device on a reset since those should stay constant through a reset. Hence change gve_init_priv() into a method that only sets these properties into the priv structure and hence needs to be only called once during gve_probe().

To achieve this end state of gve_init_priv(), do the following:
- introduce gve_adminq_init() which writes the driver version register and allocates the AdminQ and call it in gve_probe()
- call gve_adminq_get_device_properties() into gve_probe() to learn device properties
- introduce gve_setup_device() which deals with device setup logic and call it in gve_probe()
- resetting no. of registered pages is moved into gve_setup_device() since that needs to be reset every time queues are re-created.

With these changes, gve_adminq_get_device_properties() and gve_init_priv() are only called once during gve_probe. gve_reset_recovery() now calls targeted setup functions directly.

This prepares the driver to add mailbox mode's control plane initialization and device properties negotiation in the same place as is done in AdminQ mode in the upcoming patches when adding the mailbox ABI.

These changes are only code movement, no functional change.

---
v3:
- gve_reset_recovery also calls verify driver compatibility
- don't free device resources if gve_open() fails in the reset path
- move resetting no. of registered pages to gve_setup_device()

 drivers/net/ethernet/google/gve/gve.h        |   2 +
 drivers/net/ethernet/google/gve/gve_adminq.c |  12 +-
 drivers/net/ethernet/google/gve/gve_adminq.h |   2 +-
 drivers/net/ethernet/google/gve/gve_main.c   | 146 ++++++++++---------
 4 files changed, 95 insertions(+), 67 deletions(-)
drivers/net/ethernet/google/gve/gve.h +2 -0
index 1bc5e32b6618..48cc8a6be186 100644
@@ -1253,6 +1253,8 @@ static inline bool gve_is_clock_enabled(struct gve_priv *priv)
 	return priv->nic_ts_report;
 }
 
+void gve_adminq_write_version(u8 __iomem *driver_version_register);
+
 /* gqi napi handler defined in gve_main.c */
 int gve_napi_poll(struct napi_struct *napi, int budget);
 
drivers/net/ethernet/google/gve/gve_adminq.c +11 -1
index f420a8e1dd3d..a62cb7a921d0 100644
@@ -298,8 +298,10 @@ gve_process_device_options(struct gve_priv *priv,
 	return 0;
 }
 
-int gve_adminq_alloc(struct device *dev, struct gve_priv *priv)
+static int gve_adminq_alloc(struct gve_priv *priv)
 {
+	struct device *dev = &priv->pdev->dev;
+
 	priv->adminq_pool = dma_pool_create("adminq_pool", dev,
 					    GVE_ADMINQ_BUFFER_SIZE, 0, 0);
 	if (unlikely(!priv->adminq_pool))
@@ -355,6 +357,14 @@ int gve_adminq_alloc(struct device *dev, struct gve_priv *priv)
 	return 0;
 }
 
+int gve_adminq_init(struct gve_priv *priv)
+{
+	struct gve_registers __iomem *reg_bar = priv->reg_bar0;
+
+	gve_adminq_write_version(&reg_bar->driver_version);
+	return gve_adminq_alloc(priv);
+}
+
 void gve_adminq_release(struct gve_priv *priv)
 {
 	int i = 0;
drivers/net/ethernet/google/gve/gve_adminq.h +1 -1
index 2ab68c822e22..78eee3b5cb7f 100644
@@ -619,7 +619,7 @@ union gve_adminq_command {
 
 static_assert(sizeof(union gve_adminq_command) == 64);
 
-int gve_adminq_alloc(struct device *dev, struct gve_priv *priv);
+int gve_adminq_init(struct gve_priv *priv);
 void gve_adminq_free(struct gve_priv *priv);
 void gve_adminq_release(struct gve_priv *priv);
 int gve_adminq_describe_device(struct gve_priv *priv);
drivers/net/ethernet/google/gve/gve_main.c +81 -65

232 lines not on this page · raw message

Signature · 1 line
2.55.0.979.g7e5102b832-goog
author maintainer
#10 lore raw

PATCH v5 6/12 gve: simplify reset logic

In reply to Harshitha Ramamurthy

From: Joshua Washington <[email protected]>

Current GVE reset logic is quite complex, with a number of methods with similar names and functionalities. This complexity has allowed a number of bugs to enter the reset/recovery path, including the potential for reset loops if an operation fails during teardown.

Simplify the reset path by doing the following:
1) Removing recursive resets. Recursive resets have two major issues. First, there is the potential for stack overflows if resets are invoked too many times in a row. Second, long recursive calls mean that GVE never gives up the RTNL lock, or at the very least holds it for too long. If a reset must occur anywhere during the reset/recovery path, it should be scheduled as a separate task.
2) Removing resets during teardown. This is partly covered by removing recursive resets, but the primary goal in this case is to ensure that the driver is capable of actually executing a hardware reset if something goes wrong with a control plane operation. As it stands, if deconfigure_device_resources fails, for example, GVE will preempt its reset with another reset without actually invoking a hardware reset, which could actually help with recovery.
3) Decompose allocation/de-allocation and setup/teardown. Performing allocation and setup for each control plane system (RSS, ptype map, etc) leaves many more error conditions to handle, causing teardown in the case of failures to be much more complex than they need to be. This will also be useful to better align a major behavioral change in mailbox mode, which will use separate response buffers instead to get data from the device instead of a pre-allocated shared memory region.

With the new reset functionality, shared resources between the device and driver are not freed until after the hardware reset has completed in the event that deconfigure_device_resources fails, meaning that the device could potentially still be holding on to shared memory.

---
v5:
- fix workqueue disable count imbalance in reset and suspend path (Sashiko)
- destroy rings before stopping queues (Sashiko)
- ensure to call gve_queues_stop in error path in gve_close()
- pull out gve_turndown out of gve_queues_stop so the ordering of gve_turndown(stop NAPIs) -> gve_destroy_rings -> gve_queues_stop(free rings) can be preserved

v4:
- fix kdoc formatting for gve_teardown_control_plane_resources
- ignore management interrupt if device is not okay

v3:
- only reset when failing to program flow rules as ethtool op
- don't attempt to teardown rings in reset path if AQ is not allocated
- fix work queue semantics related to management IRQ handler

v2:
- Fixed typos in commit message (recursive, preempt)
- Fixed a kdoc warning

 drivers/net/ethernet/google/gve/gve.h         |   2 +-
 drivers/net/ethernet/google/gve/gve_adminq.c  |   9 +-
 drivers/net/ethernet/google/gve/gve_adminq.h  |   1 -
 drivers/net/ethernet/google/gve/gve_ethtool.c |   2 +-
 .../net/ethernet/google/gve/gve_flow_rule.c   |  15 +-
 drivers/net/ethernet/google/gve/gve_main.c    | 351 +++++++++---------
 6 files changed, 197 insertions(+), 183 deletions(-)
drivers/net/ethernet/google/gve/gve.h +1 -1
index 48cc8a6be186..026d685ecaee 100644
@@ -1348,7 +1348,7 @@ struct page_pool *gve_rx_create_page_pool(struct gve_priv *priv,
 
 /* Reset */
 void gve_schedule_reset(struct gve_priv *priv);
-int gve_reset(struct gve_priv *priv, bool attempt_teardown);
+int gve_reset(struct gve_priv *priv, bool skip_queue_setup);
 void gve_get_curr_alloc_cfgs(struct gve_priv *priv,
 			     struct gve_tx_alloc_rings_cfg *tx_alloc_cfg,
 			     struct gve_rx_alloc_rings_cfg *rx_alloc_cfg);
drivers/net/ethernet/google/gve/gve_adminq.c +2 -7
index a62cb7a921d0..901673d2e264 100644
@@ -365,7 +365,7 @@ int gve_adminq_init(struct gve_priv *priv)
 	return gve_adminq_alloc(priv);
 }
 
-void gve_adminq_release(struct gve_priv *priv)
+static void gve_adminq_release(struct gve_priv *priv)
 {
 	int i = 0;
 
@@ -394,7 +394,6 @@ void gve_adminq_release(struct gve_priv *priv)
 	}
 	gve_clear_device_rings_ok(priv);
 	gve_clear_device_resources_ok(priv);
-	gve_clear_admin_queue_ok(priv);
 }
 
 void gve_adminq_free(struct gve_priv *priv)
@@ -1377,12 +1376,8 @@ gve_adminq_configure_flow_rule(struct gve_priv *priv,
 			sizeof(struct gve_adminq_configure_flow_rule),
 			flow_rule_cmd);
 
-	if (err == -ETIME) {
-		dev_err(&priv->pdev->dev, "Timeout to configure the flow rule, trigger reset");
-		gve_reset(priv, true);
-	} else if (!err) {
+	if (!err)
 		priv->flow_rules_cache.rules_cache_synced = false;
-	}
 
 	return err;
 }
drivers/net/ethernet/google/gve/gve_adminq.h +0 -1
index 78eee3b5cb7f..fe1e8868cdfe 100644
@@ -621,7 +621,6 @@ static_assert(sizeof(union gve_adminq_command) == 64);
 
 int gve_adminq_init(struct gve_priv *priv);
 void gve_adminq_free(struct gve_priv *priv);
-void gve_adminq_release(struct gve_priv *priv);
 int gve_adminq_describe_device(struct gve_priv *priv);
 int gve_adminq_configure_device_resources(struct gve_priv *priv,
 					  dma_addr_t counter_array_bus_addr,
drivers/net/ethernet/google/gve/gve_ethtool.c +1 -1
index 8199738ba979..dd1c44fedc77 100644
@@ -651,7 +651,7 @@ static int gve_user_reset(struct net_device *netdev, u32 *flags)
 
 	if (*flags == ETH_RESET_ALL) {
 		*flags = 0;
-		return gve_reset(priv, true);
+		return gve_reset(priv, false);
 	}
 
 	return -EOPNOTSUPP;
drivers/net/ethernet/google/gve/gve_flow_rule.c +14 -1
index 2c80cda28ef3..fae552f4ad6f 100644
@@ -278,6 +278,11 @@ int gve_add_flow_rule(struct gve_priv *priv, struct ethtool_rxnfc *cmd)
 		goto out;
 
 	err = gve_adminq_add_flow_rule(priv, rule, fsp->location);
+	if (err == -ETIME) {
+		dev_err(&priv->pdev->dev,
+			"Timeout to add flow rule, trigger reset.");
+		gve_reset(priv, false);
+	}
 
 out:
 	kvfree(rule);
@@ -290,9 +295,17 @@ int gve_add_flow_rule(struct gve_priv *priv, struct ethtool_rxnfc *cmd)
 int gve_del_flow_rule(struct gve_priv *priv, struct ethtool_rxnfc *cmd)
 {
 	struct ethtool_rx_flow_spec *fsp = (struct ethtool_rx_flow_spec *)&cmd->fs;
+	int err;
 
 	if (!priv->max_flow_rules)
 		return -EOPNOTSUPP;
 
-	return gve_adminq_del_flow_rule(priv, fsp->location);
+	err = gve_adminq_del_flow_rule(priv, fsp->location);
+	if (err == -ETIME) {
+		dev_err(&priv->pdev->dev,
+			"Timeout to delete flow rule, trigger reset.");
+		gve_reset(priv, false);
+	}
+
+	return err;
 }
drivers/net/ethernet/google/gve/gve_main.c +179 -172

575 lines not on this page · raw message

Signature · 1 line
2.55.0.979.g7e5102b832-goog
author maintainer
#13 lore raw

PATCH v5 7/12 gve: add gve_ctrl_ops for gve initialization/teardown sequences

In reply to Harshitha Ramamurthy

From: Joshua Washington <[email protected]>

Driver initialization and teardown involve a number of control plane operations that need to be defined for gve_probe to operate in both mailbox and adminq modes. This list includes:

- get_ptype_map: a mapping of packet types (L3+L4) held in RX completion descriptors
- configure_rss: set up default RSS configuration if the device is not queryable
- setup_stats_report: set up DMA region for stats report (AQ-only)
- reset_flow_rules: needed in teardown; flushes all flow rules from device

---
 drivers/net/ethernet/google/gve/gve.h        | 12 ++++++++++
 drivers/net/ethernet/google/gve/gve_adminq.c |  7 +++---
 drivers/net/ethernet/google/gve/gve_adminq.h |  3 +--
 drivers/net/ethernet/google/gve/gve_main.c   | 24 +++++++++++++++-----
 4 files changed, 34 insertions(+), 12 deletions(-)
drivers/net/ethernet/google/gve/gve.h +12 -0
index 026d685ecaee..e0583e8cd2cd 100644
@@ -833,12 +833,24 @@ struct gve_device_info {
  *                  structures stored in @priv to be used during initialization.
  * @set_num_ntfy_blks: Sets no. of vectors into @priv to be used during
  *                     initialization.
+ * @get_ptype_map: Learn packet type map from device and store it in @priv
+ * @configure_rss: Set up default RSS configuration
+ * @setup_stats_report: Set up DMA region for stats report (AdminQ only)
+ * @reset_flow_rules: Flush all flow rules from device
  */
 struct gve_ctrl_ops {
 	int (*map_db_bar)(struct gve_priv *priv);
 	void (*unmap_db_bar)(struct gve_priv *priv);
 	void (*set_num_queues)(struct gve_priv *priv);
 	int (*set_num_ntfy_blks)(struct gve_priv *priv);
+	int (*get_ptype_map)(struct gve_priv *priv);
+	int (*configure_rss)(struct gve_priv *priv,
+			     struct ethtool_rxfh_param *param);
+	int (*setup_stats_report)(struct gve_priv *priv,
+				  u64 stats_report_len,
+				  dma_addr_t stats_report_addr,
+				  u64 interval_ms); /* AQ-specific */
+	int (*reset_flow_rules)(struct gve_priv *priv);
 };
 
 struct gve_priv {
drivers/net/ethernet/google/gve/gve_adminq.c +3 -4
index 901673d2e264..1176e13fafc0 100644
@@ -1329,8 +1329,7 @@ int gve_adminq_report_nic_ts(struct gve_priv *priv,
 	return gve_adminq_execute_cmd(priv, &cmd);
 }
 
-int gve_adminq_get_ptype_map_dqo(struct gve_priv *priv,
-				 struct gve_ptype_lut *ptype_lut)
+int gve_adminq_get_ptype_map_dqo(struct gve_priv *priv)
 {
 	struct gve_ptype_map *ptype_map;
 	union gve_adminq_command cmd;
@@ -1356,9 +1355,9 @@ int gve_adminq_get_ptype_map_dqo(struct gve_priv *priv,
 
 	/* Populate ptype_lut. */
 	for (i = 0; i < GVE_NUM_PTYPES; i++) {
-		ptype_lut->ptypes[i].l3_type =
+		priv->ptype_lut_dqo->ptypes[i].l3_type =
 			ptype_map->ptypes[i].l3_type;
-		ptype_lut->ptypes[i].l4_type =
+		priv->ptype_lut_dqo->ptypes[i].l4_type =
 			ptype_map->ptypes[i].l4_type;
 	}
 err:
drivers/net/ethernet/google/gve/gve_adminq.h +1 -2
index fe1e8868cdfe..5e51c060e237 100644
@@ -652,8 +652,7 @@ int gve_adminq_report_nic_ts(struct gve_priv *priv,
 			     dma_addr_t nic_ts_report_addr);
 
 struct gve_ptype_lut;
-int gve_adminq_get_ptype_map_dqo(struct gve_priv *priv,
-				 struct gve_ptype_lut *ptype_lut);
+int gve_adminq_get_ptype_map_dqo(struct gve_priv *priv);
 int gve_adminq_set_num_ntfy_blks(struct gve_priv *priv);
 void gve_adminq_set_num_queues(struct gve_priv *priv);
 int gve_adminq_map_db_bar(struct gve_priv *priv);
drivers/net/ethernet/google/gve/gve_main.c +18 -6
index acd09e9f416c..5ad7a8f9bbdd 100644
@@ -652,7 +652,8 @@ static int gve_alloc_control_plane_resources(struct gve_priv *priv)
 
 static int gve_setup_control_plane_resources(struct gve_priv *priv)
 {
-	int err = 0;
+	const struct gve_ctrl_ops *ops = priv->ctrl_ops;
+	int err;
 
 	err = gve_adminq_configure_device_resources(priv,
 						    priv->counter_array_bus,
@@ -667,7 +668,7 @@ static int gve_setup_control_plane_resources(struct gve_priv *priv)
 	}
 
 	if (!gve_is_gqi(priv)) {
-		err = gve_adminq_get_ptype_map_dqo(priv, priv->ptype_lut_dqo);
+		err = ops->get_ptype_map(priv);
 		if (err) {
 			dev_err(&priv->pdev->dev,
 				"Failed to get ptype map: err=%d\n", err);
@@ -689,12 +690,13 @@ static int gve_setup_control_plane_resources(struct gve_priv *priv)
 		goto teardown_clock;
 	}
 
-	err = gve_adminq_report_stats(priv, priv->stats_report_len,
+	err = ops->setup_stats_report(priv, priv->stats_report_len,
 				      priv->stats_report_bus,
 				      GVE_STATS_REPORT_TIMER_PERIOD);
 	if (err)
 		dev_err(&priv->pdev->dev,
 			"Failed to report stats: err=%d\n", err);
+
 	gve_set_device_resources_ok(priv);
 	return 0;
 
@@ -718,6 +720,7 @@ static int gve_setup_control_plane_resources(struct gve_priv *priv)
  */
 static void gve_teardown_control_plane_resources(struct gve_priv *priv)
 {
+	const struct gve_ctrl_ops *ops = priv->ctrl_ops;
 	int err;
 
 	/* Tell device its resources are being freed */
@@ -727,11 +730,13 @@ static void gve_teardown_control_plane_resources(struct gve_priv *priv)
 			dev_err(&priv->pdev->dev,
 				"Failed to reset flow rules: err=%d\n", err);
 		/* detach the stats report */
-		err = gve_adminq_report_stats(priv, 0, 0x0, GVE_STATS_REPORT_TIMER_PERIOD);
+		err = ops->setup_stats_report(priv, 0, 0x0,
+					      GVE_STATS_REPORT_TIMER_PERIOD);
 		if (err)
 			dev_err(&priv->pdev->dev,
 				"Failed to detach stats report: err=%d\n", err);
 		gve_teardown_clock(priv);
+
 		err = gve_adminq_deconfigure_device_resources(priv);
 		if (err)
 			dev_err(&priv->pdev->dev,
@@ -1815,6 +1820,7 @@ static int gve_xdp(struct net_device *dev, struct netdev_bpf *xdp)
 
 int gve_init_rss_config(struct gve_priv *priv, u16 num_queues)
 {
+	const struct gve_ctrl_ops *ops = priv->ctrl_ops;
 	struct gve_rss_config *rss_config = &priv->rss_config;
 	struct ethtool_rxfh_param rxfh = {0};
 	u16 i;
@@ -1830,15 +1836,17 @@ int gve_init_rss_config(struct gve_priv *priv, u16 num_queues)
 
 	rxfh.hfunc = ETH_RSS_HASH_TOP;
 
-	return gve_adminq_configure_rss(priv, &rxfh);
+	return ops->configure_rss(priv, &rxfh);
 }
 
 int gve_flow_rules_reset(struct gve_priv *priv)
 {
+	const struct gve_ctrl_ops *ops = priv->ctrl_ops;
+
 	if (!priv->max_flow_rules)
 		return 0;
 
-	return gve_adminq_reset_flow_rules(priv);
+	return ops->reset_flow_rules(priv);
 }
 
 int gve_adjust_config(struct gve_priv *priv,
@@ -2477,6 +2485,10 @@ static const struct gve_ctrl_ops gve_adminq_ops = {
 	.unmap_db_bar		= gve_adminq_unmap_db_bar,
 	.set_num_queues		= gve_adminq_set_num_queues,
 	.set_num_ntfy_blks	= gve_adminq_set_num_ntfy_blks,
+	.get_ptype_map		= gve_adminq_get_ptype_map_dqo,
+	.reset_flow_rules	= gve_adminq_reset_flow_rules,
+	.setup_stats_report	= gve_adminq_report_stats,
+	.configure_rss		= gve_adminq_configure_rss,
 };
 
 static int gve_init_priv(struct gve_priv *priv)
Signature · 1 line
2.55.0.979.g7e5102b832-goog
author maintainer
#15 lore raw

PATCH v5 8/12 gve: split up notify block allocation and setup paths

In reply to Harshitha Ramamurthy

From: Joshua Washington <[email protected]>

Before this patch, notify block allocation and setup occurred in the same method. This all occurred before gve_adminq_configure_device_resources, which populates the irq_db_indicies array, a DMA region with BAR offsets for MSI-X vectors.

The coming mailbox mode will require notify blocks to be set up only after receiving the IRQ doorbell offsets, as the request does not work with a supplied DMA buffer in the way that admin queue mode does. The intended flow in that case would be:

1) allocate notify blocks
2) request doorbell information
3) set up MSI-X vectors based on doorbell info

This ordering also works for admin queue mode, so it will be updated to match.

---
v3:
- remove redundant call to gve_teardown_clock()

 drivers/net/ethernet/google/gve/gve.h      |   2 +
 drivers/net/ethernet/google/gve/gve_main.c | 155 +++++++++++----------
 2 files changed, 86 insertions(+), 71 deletions(-)
drivers/net/ethernet/google/gve/gve.h +2 -0
index e0583e8cd2cd..f624a3e385e4 100644
@@ -674,6 +674,7 @@ struct gve_notify_block {
 	struct gve_tx_ring *tx; /* tx rings on this block */
 	struct gve_rx_ring *rx; /* rx rings on this block */
 	u32 irq;
+	bool irq_requested;
 };
 
 /* Tracks allowed and current rx queue settings */
@@ -954,6 +955,7 @@ struct gve_priv {
 	u64 link_speed;
 	bool up_before_suspend; /* True if dev was up before suspend */
 
+	bool mgmt_irq_requested;
 	struct gve_ptype_lut *ptype_lut_dqo;
 
 	/* Must be a power of two. */
drivers/net/ethernet/google/gve/gve_main.c +84 -71

227 lines not on this page · raw message

Signature · 1 line
2.55.0.979.g7e5102b832-goog
author maintainer
#17 lore raw

PATCH v5 9/12 gve: introduce new methods to handle IRQ doorbells

In reply to Harshitha Ramamurthy

From: Joshua Washington <[email protected]>

Introduce request_db_info and release_db_resources to struct gve_ctrl_ops. These encapsulate the configuration of device resources (counter arrays and IRQ doorbell indices) which vary between Admin Queue and Mailbox modes. Registration and de-registratino of IRQ dorrbell indices with the device will be managed by these new methods instead of occurring directly in notify_block setup/teardown methods. Similarly, GQ ring counters will be managed in request_db_info.

---
v4:
- propagate code changes as specified by v3.
v3:
- move allocation of IRQ DB indices and counter array back into gve_alloc_control_plane_resources() from gve_adminq_request_db_info().
- Similar to above, move free logic out of gve_adminq_free_db_resources() and rename all introduced methods from *free_db_resources to *release_db_resources to reflect the behavioral change.

 drivers/net/ethernet/google/gve/gve.h        | 10 ++
 drivers/net/ethernet/google/gve/gve_adminq.c | 37 ++++++++
 drivers/net/ethernet/google/gve/gve_adminq.h |  2 +
 drivers/net/ethernet/google/gve/gve_main.c   | 98 ++++++++++----------
 4 files changed, 97 insertions(+), 50 deletions(-)
drivers/net/ethernet/google/gve/gve.h +10 -0
index f624a3e385e4..6c46c842070b 100644
@@ -834,6 +834,9 @@ struct gve_device_info {
  *                  structures stored in @priv to be used during initialization.
  * @set_num_ntfy_blks: Sets no. of vectors into @priv to be used during
  *                     initialization.
+ * @request_db_info: Request and store doorbell information into @priv
+ * @release_db_resources: Release device hold on DMA memory holding doorbell
+ *			  info (AdminQ only)
  * @get_ptype_map: Learn packet type map from device and store it in @priv
  * @configure_rss: Set up default RSS configuration
  * @setup_stats_report: Set up DMA region for stats report (AdminQ only)
@@ -844,6 +847,8 @@ struct gve_ctrl_ops {
 	void (*unmap_db_bar)(struct gve_priv *priv);
 	void (*set_num_queues)(struct gve_priv *priv);
 	int (*set_num_ntfy_blks)(struct gve_priv *priv);
+	int (*request_db_info)(struct gve_priv *priv);
+	void (*release_db_resources)(struct gve_priv *priv);
 	int (*get_ptype_map)(struct gve_priv *priv);
 	int (*configure_rss)(struct gve_priv *priv,
 			     struct ethtool_rxfh_param *param);
@@ -1164,6 +1169,11 @@ static inline u32 gve_rx_idx_to_ntfy(struct gve_priv *priv, u32 queue_idx)
 	return (priv->num_ntfy_blks / 2) + queue_idx;
 }
 
+static inline u32 gve_ntfy_to_msix_idx(struct gve_priv *priv, u32 ntfy_blk_idx)
+{
+	return ntfy_blk_idx;
+}
+
 static inline bool gve_is_qpl(struct gve_priv *priv)
 {
 	return priv->queue_format == GVE_GQI_QPL_FORMAT ||
drivers/net/ethernet/google/gve/gve_adminq.c +37 -0
index 1176e13fafc0..b89825a85db8 100644
@@ -1718,3 +1718,40 @@ void gve_adminq_unmap_db_bar(struct gve_priv *priv)
 
 	pci_iounmap(pdev, priv->db_bar2);
 }
+
+int gve_adminq_request_db_info(struct gve_priv *priv)
+{
+	int err;
+	int i;
+
+	err = gve_adminq_configure_device_resources(priv,
+						    priv->counter_array_bus,
+						    priv->num_event_counters,
+						    priv->irq_db_indices_bus,
+						    priv->num_ntfy_blks);
+	if (unlikely(err)) {
+		dev_err(&priv->pdev->dev,
+			"could not setup device_resources: err=%d\n", err);
+		return -ENXIO;
+	}
+
+	for (i = 0; i < priv->num_ntfy_blks; i++)
+		priv->ntfy_blocks[i].irq_db_index =
+			&priv->irq_db_indices[i].index;
+	return 0;
+}
+
+void gve_adminq_release_db_resources(struct gve_priv *priv)
+{
+	int err;
+
+	/* Log error in deconfigure device, but don't fail. This is only ever
+	 * called as a reset is about to be triggered, so it would be redundant
+	 * to trigger a reset.
+	 */
+	err = gve_adminq_deconfigure_device_resources(priv);
+	if (err)
+		dev_err(&priv->pdev->dev,
+			"Could not deconfigure device resources: err=%d\n",
+			err);
+}
drivers/net/ethernet/google/gve/gve_adminq.h +2 -0
index 5e51c060e237..52172bf228eb 100644
@@ -657,4 +657,6 @@ int gve_adminq_set_num_ntfy_blks(struct gve_priv *priv);
 void gve_adminq_set_num_queues(struct gve_priv *priv);
 int gve_adminq_map_db_bar(struct gve_priv *priv);
 void gve_adminq_unmap_db_bar(struct gve_priv *priv);
+int gve_adminq_request_db_info(struct gve_priv *priv);
+void gve_adminq_release_db_resources(struct gve_priv *priv);
 #endif /* _GVE_ADMINQ_H */
drivers/net/ethernet/google/gve/gve_main.c +48 -50

211 lines not on this page · raw message

Signature · 1 line
2.55.0.979.g7e5102b832-goog
author maintainer
#20 lore raw

PATCH v5 10/12 gve: setup and teardown management interrupts

In reply to Harshitha Ramamurthy

From: Joshua Washington <[email protected]>

Introduce control ops to setup/teardown control plane IRQs. Admin queue-specific functionality is moved to admin queue files.

---
 drivers/net/ethernet/google/gve/gve.h        |  4 +++
 drivers/net/ethernet/google/gve/gve_adminq.c | 36 ++++++++++++++++++++
 drivers/net/ethernet/google/gve/gve_adminq.h |  2 ++
 drivers/net/ethernet/google/gve/gve_main.c   | 32 +++++------------
 4 files changed, 51 insertions(+), 23 deletions(-)
drivers/net/ethernet/google/gve/gve.h +4 -0
index 6c46c842070b..016e85ed91a5 100644
@@ -837,6 +837,8 @@ struct gve_device_info {
  * @request_db_info: Request and store doorbell information into @priv
  * @release_db_resources: Release device hold on DMA memory holding doorbell
  *			  info (AdminQ only)
+ * @setup_mgmt_irq: Setup control plane IRQ
+ * @teardown_mgmt_irq: Teardown control plane IRQ
  * @get_ptype_map: Learn packet type map from device and store it in @priv
  * @configure_rss: Set up default RSS configuration
  * @setup_stats_report: Set up DMA region for stats report (AdminQ only)
@@ -849,6 +851,8 @@ struct gve_ctrl_ops {
 	int (*set_num_ntfy_blks)(struct gve_priv *priv);
 	int (*request_db_info)(struct gve_priv *priv);
 	void (*release_db_resources)(struct gve_priv *priv);
+	int (*setup_mgmt_irq)(struct gve_priv *priv);
+	void (*teardown_mgmt_irq)(struct gve_priv *priv);
 	int (*get_ptype_map)(struct gve_priv *priv);
 	int (*configure_rss)(struct gve_priv *priv,
 			     struct ethtool_rxfh_param *param);
drivers/net/ethernet/google/gve/gve_adminq.c +36 -0
index b89825a85db8..c3c10d5062f5 100644
@@ -1755,3 +1755,39 @@ void gve_adminq_release_db_resources(struct gve_priv *priv)
 			"Could not deconfigure device resources: err=%d\n",
 			err);
 }
+
+static irqreturn_t gve_mgmnt_intr(int irq, void *arg)
+{
+	struct gve_priv *priv = arg;
+
+	/* Device resources are not okay; consider the interrupt spurious. */
+	if (!gve_get_device_resources_ok(priv))
+		return IRQ_NONE;
+
+	queue_work(priv->gve_wq, &priv->service_task);
+	return IRQ_HANDLED;
+}
+
+int gve_adminq_setup_mgmt_irq(struct gve_priv *priv)
+{
+	int err;
+
+	snprintf(priv->mgmt_msix_name, sizeof(priv->mgmt_msix_name),
+		 "gve-mgmnt@pci:%s", pci_name(priv->pdev));
+	err = request_irq(priv->msix_vectors[priv->mgmt_msix_idx].vector,
+			  gve_mgmnt_intr, 0, priv->mgmt_msix_name, priv);
+	if (err)
+		return err;
+
+	priv->mgmt_irq_requested = true;
+
+	return 0;
+}
+
+void gve_adminq_teardown_mgmt_irq(struct gve_priv *priv)
+{
+	if (priv->mgmt_irq_requested) {
+		free_irq(priv->msix_vectors[priv->mgmt_msix_idx].vector, priv);
+		priv->mgmt_irq_requested = false;
+	}
+}
drivers/net/ethernet/google/gve/gve_adminq.h +2 -0
index 52172bf228eb..0b48e9f2a82a 100644
@@ -659,4 +659,6 @@ int gve_adminq_map_db_bar(struct gve_priv *priv);
 void gve_adminq_unmap_db_bar(struct gve_priv *priv);
 int gve_adminq_request_db_info(struct gve_priv *priv);
 void gve_adminq_release_db_resources(struct gve_priv *priv);
+int gve_adminq_setup_mgmt_irq(struct gve_priv *priv);
+void gve_adminq_teardown_mgmt_irq(struct gve_priv *priv);
 #endif /* _GVE_ADMINQ_H */
drivers/net/ethernet/google/gve/gve_main.c +9 -23
index a160d36f718b..8522a495b78a 100644
@@ -290,18 +290,6 @@ static void gve_free_stats_report(struct gve_priv *priv)
 	priv->stats_report = NULL;
 }
 
-static irqreturn_t gve_mgmnt_intr(int irq, void *arg)
-{
-	struct gve_priv *priv = arg;
-
-	/* Device resources are not okay; consider the interrupt spurious. */
-	if (!gve_get_device_resources_ok(priv))
-		return IRQ_NONE;
-
-	queue_work(priv->gve_wq, &priv->service_task);
-	return IRQ_HANDLED;
-}
-
 static irqreturn_t gve_intr(int irq, void *arg)
 {
 	struct gve_notify_block *block = arg;
@@ -526,6 +514,7 @@ static int gve_alloc_notify_blocks(struct gve_priv *priv)
 
 static void gve_teardown_notify_blocks(struct gve_priv *priv)
 {
+	const struct gve_ctrl_ops *ops = priv->ctrl_ops;
 	int i;
 
 	if (!priv->ntfy_blocks)
@@ -545,29 +534,24 @@ static void gve_teardown_notify_blocks(struct gve_priv *priv)
 		block->irq_requested = false;
 	}
 
-	if (priv->mgmt_irq_requested) {
-		free_irq(priv->msix_vectors[priv->mgmt_msix_idx].vector, priv);
-		priv->mgmt_irq_requested = false;
-	}
+	ops->teardown_mgmt_irq(priv);
 }
 
 static int gve_setup_notify_blocks(struct gve_priv *priv)
 {
+	const struct gve_ctrl_ops *ops = priv->ctrl_ops;
 	const struct cpumask *node_mask;
 	unsigned int cur_cpu;
 	int i;
 	int err;
 
-	/* Setup Management Vector  - the last vector */
-	snprintf(priv->mgmt_msix_name, sizeof(priv->mgmt_msix_name),
-		 "gve-mgmnt@pci:%s", pci_name(priv->pdev));
-	err = request_irq(priv->msix_vectors[priv->mgmt_msix_idx].vector,
-			  gve_mgmnt_intr, 0, priv->mgmt_msix_name, priv);
+	/* Setup Management Vector */
+	err = ops->setup_mgmt_irq(priv);
 	if (err) {
-		dev_err(&priv->pdev->dev, "Did not receive management vector.\n");
+		dev_err(&priv->pdev->dev,
+			"Did not receive management vector.\n");
 		return err;
 	}
-	priv->mgmt_irq_requested = true;
 
 	node_mask = gve_get_node_mask(priv);
 	cur_cpu = cpumask_first(node_mask);
@@ -2500,6 +2484,8 @@ static const struct gve_ctrl_ops gve_adminq_ops = {
 	.configure_rss		= gve_adminq_configure_rss,
 	.request_db_info	= gve_adminq_request_db_info,
 	.release_db_resources	= gve_adminq_release_db_resources,
+	.setup_mgmt_irq		= gve_adminq_setup_mgmt_irq,
+	.teardown_mgmt_irq	= gve_adminq_teardown_mgmt_irq,
 };
 
 static int gve_init_priv(struct gve_priv *priv)
Signature · 1 line
2.55.0.979.g7e5102b832-goog
author maintainer
#22 lore raw

PATCH v5 11/12 gve: add ctrl ops to for queue operations

In reply to Harshitha Ramamurthy

Add the next few control ops to

- create queues
- destroy queues

These changes are just moving existing code into ops, no functional change.

---
v5:
- remove double logging during queue creation/destruction on err also (Sashiko)

 drivers/net/ethernet/google/gve/gve.h        |  4 ++
 drivers/net/ethernet/google/gve/gve_adminq.c | 50 ++++++++++++++++++++
 drivers/net/ethernet/google/gve/gve_adminq.h |  2 +
 drivers/net/ethernet/google/gve/gve_dqo.h    |  2 +-
 drivers/net/ethernet/google/gve/gve_main.c   | 43 +++--------------
 5 files changed, 64 insertions(+), 37 deletions(-)
drivers/net/ethernet/google/gve/gve.h +4 -0
index 016e85ed91a5..00966b6a730f 100644
@@ -843,6 +843,8 @@ struct gve_device_info {
  * @configure_rss: Set up default RSS configuration
  * @setup_stats_report: Set up DMA region for stats report (AdminQ only)
  * @reset_flow_rules: Flush all flow rules from device
+ * @create_queues: Sends commands to the device to create TX/RX queues.
+ * @destroy_queues: Sends commands to the device to destroy TX/RX queues.
  */
 struct gve_ctrl_ops {
 	int (*map_db_bar)(struct gve_priv *priv);
@@ -861,6 +863,8 @@ struct gve_ctrl_ops {
 				  dma_addr_t stats_report_addr,
 				  u64 interval_ms); /* AQ-specific */
 	int (*reset_flow_rules)(struct gve_priv *priv);
+	int (*create_queues)(struct gve_priv *priv);
+	int (*destroy_queues)(struct gve_priv *priv);
 };
 
 struct gve_priv {
drivers/net/ethernet/google/gve/gve_adminq.c +50 -0

59 lines not on this page · raw message

drivers/net/ethernet/google/gve/gve_adminq.h +2 -0
index 0b48e9f2a82a..d696e4932a8b 100644
@@ -628,6 +628,8 @@ int gve_adminq_configure_device_resources(struct gve_priv *priv,
 					  dma_addr_t db_array_bus_addr,
 					  u32 num_ntfy_blks);
 int gve_adminq_deconfigure_device_resources(struct gve_priv *priv);
+int gve_adminq_create_queues(struct gve_priv *priv);
+int gve_adminq_destroy_queues(struct gve_priv *priv);
 int gve_adminq_create_tx_queues(struct gve_priv *priv, u32 start_id, u32 num_queues);
 int gve_adminq_destroy_tx_queues(struct gve_priv *priv, u32 start_id, u32 num_queues);
 int gve_adminq_create_single_rx_queue(struct gve_priv *priv, u32 queue_index);
drivers/net/ethernet/google/gve/gve_dqo.h +1 -1
index 5871f773f0c7..ce402020dff6 100644
@@ -66,7 +66,7 @@ void gve_rx_write_doorbell_dqo(const struct gve_priv *priv, int queue_idx);
 void gve_xdp_tx_flush_dqo(struct gve_priv *priv, u32 xdp_qid);
 
 static inline void
-gve_tx_put_doorbell_dqo(const struct gve_priv *priv,
+gve_tx_put_doorbell_dqo(struct gve_priv *priv,
 			const struct gve_queue_resources *q_resources, u32 val)
 {
 	u64 index;
drivers/net/ethernet/google/gve/gve_main.c +7 -36

72 lines not on this page · raw message

Signature · 1 line
2.55.0.979.g7e5102b832-goog
author maintainer
#24 lore raw

PATCH v5 12/12 gve: add link status/speed ctrl ops

In reply to Harshitha Ramamurthy

From: Joshua Washington <[email protected]>

Refactor link status check to use a control plane op. Introduce new op for retrieving the link status in AQ mode. This op reads the link status from the device status register and stores the value in priv.

Also add an op for retrieving link speed in AQ mode which calls into gve_adminq_report_link_speed.

---
v3:
- Fix kdoc typo ("set link status" -> "set link speed")
- Copy link status into local variable instead of reading twice to prevent TOCTOU issue.

 drivers/net/ethernet/google/gve/gve.h         |  5 ++++
 drivers/net/ethernet/google/gve/gve_adminq.c  | 10 +++++++
 drivers/net/ethernet/google/gve/gve_adminq.h  |  1 +
 drivers/net/ethernet/google/gve/gve_ethtool.c |  3 +--
 drivers/net/ethernet/google/gve/gve_main.c    | 26 ++++++++++++-------
 5 files changed, 33 insertions(+), 12 deletions(-)
drivers/net/ethernet/google/gve/gve.h +5 -0
index 00966b6a730f..b7ce6e8632db 100644
@@ -845,6 +845,8 @@ struct gve_device_info {
  * @reset_flow_rules: Flush all flow rules from device
  * @create_queues: Sends commands to the device to create TX/RX queues.
  * @destroy_queues: Sends commands to the device to destroy TX/RX queues.
+ * @report_link_status: Set link status into @priv->link_up
+ * @report_link_speed: Set link speed into @priv->link_speed
  */
 struct gve_ctrl_ops {
 	int (*map_db_bar)(struct gve_priv *priv);
@@ -865,6 +867,8 @@ struct gve_ctrl_ops {
 	int (*reset_flow_rules)(struct gve_priv *priv);
 	int (*create_queues)(struct gve_priv *priv);
 	int (*destroy_queues)(struct gve_priv *priv);
+	int (*report_link_status)(struct gve_priv *priv);
+	int (*report_link_speed)(struct gve_priv *priv);
 };
 
 struct gve_priv {
@@ -966,6 +970,7 @@ struct gve_priv {
 
 	/* Gvnic device link speed from hypervisor. */
 	u64 link_speed;
+	bool link_up;
 	bool up_before_suspend; /* True if dev was up before suspend */
 
 	bool mgmt_irq_requested;
drivers/net/ethernet/google/gve/gve_adminq.c +10 -0
index 9a0a94ebdcd8..ed64f298e80d 100644
@@ -1841,3 +1841,13 @@ int gve_adminq_create_queues(struct gve_priv *priv)
 
 	return err;
 }
+
+int gve_adminq_report_link_status(struct gve_priv *priv)
+{
+	u32 status;
+
+	status = ioread32be(&priv->reg_bar0->device_status);
+	WRITE_ONCE(priv->link_up,
+		   !!(GVE_DEVICE_STATUS_LINK_STATUS_MASK & status));
+	return 0;
+}
drivers/net/ethernet/google/gve/gve_adminq.h +1 -0
index d696e4932a8b..8daac5fd685a 100644
@@ -643,6 +643,7 @@ int gve_adminq_report_stats(struct gve_priv *priv, u64 stats_report_len,
 			    dma_addr_t stats_report_addr, u64 interval);
 int gve_adminq_verify_driver_compatibility(struct gve_priv *priv);
 int gve_adminq_get_device_properties(struct gve_priv *priv);
+int gve_adminq_report_link_status(struct gve_priv *priv);
 int gve_adminq_report_link_speed(struct gve_priv *priv);
 int gve_adminq_add_flow_rule(struct gve_priv *priv, struct gve_adminq_flow_rule *rule, u32 loc);
 int gve_adminq_del_flow_rule(struct gve_priv *priv, u32 loc);
drivers/net/ethernet/google/gve/gve_ethtool.c +1 -2
index dd1c44fedc77..a3220c651438 100644
@@ -749,12 +749,11 @@ static int gve_get_link_ksettings(struct net_device *netdev,
 	int err = 0;
 
 	if (priv->link_speed == 0)
-		err = gve_adminq_report_link_speed(priv);
+		err = priv->ctrl_ops->report_link_speed(priv);
 
 	cmd->base.speed = priv->link_speed;
 
 	cmd->base.duplex = DUPLEX_FULL;
-
 	return err;
 }
 
drivers/net/ethernet/google/gve/gve_main.c +16 -10
index f09df9ca36fe..9af9eef64382 100644
@@ -1501,15 +1501,18 @@ static int gve_close(struct net_device *dev)
 	return err;
 }
 
-static void gve_handle_link_status(struct gve_priv *priv, bool link_status)
+static void gve_handle_link_status(struct gve_priv *priv)
 {
+	bool link_up;
+
 	if (!gve_get_napi_enabled(priv))
 		return;
 
-	if (link_status == netif_carrier_ok(priv->dev))
+	link_up = READ_ONCE(priv->link_up);
+	if (link_up == netif_carrier_ok(priv->dev))
 		return;
 
-	if (link_status) {
+	if (link_up) {
 		netdev_info(priv->dev, "Device link is up.\n");
 		netif_carrier_on(priv->dev);
 	} else {
@@ -1536,7 +1539,6 @@ static int gve_set_xdp(struct gve_priv *priv, struct bpf_prog *prog,
 {
 	struct bpf_prog *old_prog;
 	int err = 0;
-	u32 status;
 
 	old_prog = READ_ONCE(priv->xdp_prog);
 	if (!netif_running(priv->dev)) {
@@ -1563,8 +1565,8 @@ static int gve_set_xdp(struct gve_priv *priv, struct bpf_prog *prog,
 		bpf_prog_put(old_prog);
 
 out:
-	status = ioread32be(&priv->reg_bar0->device_status);
-	gve_handle_link_status(priv, GVE_DEVICE_STATUS_LINK_STATUS_MASK & status);
+	priv->ctrl_ops->report_link_status(priv);
+	gve_handle_link_status(priv);
 	return err;
 }
 
@@ -1997,11 +1999,11 @@ static void gve_turnup(struct gve_priv *priv)
 
 static void gve_turnup_and_check_status(struct gve_priv *priv)
 {
-	u32 status;
+	const struct gve_ctrl_ops *ops = priv->ctrl_ops;
 
 	gve_turnup(priv);
-	status = ioread32be(&priv->reg_bar0->device_status);
-	gve_handle_link_status(priv, GVE_DEVICE_STATUS_LINK_STATUS_MASK & status);
+	ops->report_link_status(priv);
+	gve_handle_link_status(priv);
 }
 
 static struct gve_notify_block *gve_get_tx_notify_block(struct gve_priv *priv,
@@ -2325,12 +2327,14 @@ static void gve_service_task(struct work_struct *work)
 {
 	struct gve_priv *priv = container_of(work, struct gve_priv,
 					     service_task);
+	const struct gve_ctrl_ops *ops = priv->ctrl_ops;
 	u32 status = ioread32be(&priv->reg_bar0->device_status);
 
 	gve_handle_status(priv, status);
 
 	gve_handle_reset(priv);
-	gve_handle_link_status(priv, GVE_DEVICE_STATUS_LINK_STATUS_MASK & status);
+	ops->report_link_status(priv);
+	gve_handle_link_status(priv);
 }
 
 static void gve_set_netdev_xdp_features(struct gve_priv *priv)
@@ -2457,6 +2461,8 @@ static const struct gve_ctrl_ops gve_adminq_ops = {
 	.teardown_mgmt_irq	= gve_adminq_teardown_mgmt_irq,
 	.create_queues		= gve_adminq_create_queues,
 	.destroy_queues		= gve_adminq_destroy_queues,
+	.report_link_status	= gve_adminq_report_link_status,
+	.report_link_speed	= gve_adminq_report_link_speed,
 };
 
 static int gve_init_priv(struct gve_priv *priv)
Signature · 1 line
2.55.0.979.g7e5102b832-goog
#2 lore raw

Re: [PATCH net-next v5 01/12] gve: add struct gve_device_info to hold device properties

In reply to Harshitha Ramamurthy
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] The driver trusts the device-provided descriptor->total_length without clamping it to the actual allocated DMA buffer size, leading to an out-of-bounds read vulnerability. --

commit c3056c70d520a5fcb8777d7ecaee3b31bf27e333
Author: Harshitha Ramamurthy <[email protected]>

gve: add struct gve_device_info to hold device properties

The commit refactors the initialization flow by adding struct gve_device_info to store negotiated device properties. It fills it in gve_adminq_describe_device() and its callees to prepare the driver for the upcoming MailboxQ mode without changing functional behavior.

drivers/net/ethernet/google/gve/gve_adminq.c void gve_parse_device_option(struct gve_priv *priv, · line 74

Quoted 11 lines
drivers/net/ethernet/google/gve/gve_adminq.c +1 -1
index f05f4895f4c74..512349c5517f4 100644
@@ -70,7 +70,7 @@ void gve_parse_device_option(struct gve_priv *priv,
 
 		dev_info(&priv->pdev->dev,
 			 "Gqi raw addressing device option enabled.\n");
-		priv->queue_format = GVE_GQI_RDA_FORMAT;
+		priv->device_info.queue_format = GVE_GQI_RDA_FORMAT;
 		break;

[Severity: High]
This isn't a bug introduced by this patch, but I noticed a potential out-of-bounds read vulnerability in the device option parsing logic.

When traversing the options in gve_process_device_options(), the code relies on gve_get_next_option() which does not clamp the untrusted total_length to the allocated buffer size:

drivers/net/ethernet/google/gve/gve_adminq.c:gve_get_next_option() {
	void *option_end, *descriptor_end;

	option_end = (void *)(option + 1) + be16_to_cpu(option->option_length);
	descriptor_end = (void *)descriptor + be16_to_cpu(descriptor->total_length);

	return option_end > descriptor_end ? NULL : (struct gve_device_option *)option_end;
}

If a malicious device provides an AdminQ response where descriptor->total_length exceeds GVE_ADMINQ_BUFFER_SIZE (4096), descriptor_end will point far beyond the actual allocated DMA buffer.

This could allow gve_get_next_option() to return an out-of-bounds pointer, which is then dereferenced in the option parsing loop in gve_process_device_options():

drivers/net/ethernet/google/gve/gve_adminq.c:gve_process_device_options() {
	...
	for (i = 0; i < num_options; i++) {
		struct gve_device_option *next_opt;

		next_opt = gve_get_next_option(descriptor, dev_opt);
	...
}

Could descriptor->total_length be validated against GVE_ADMINQ_BUFFER_SIZE before using it to calculate descriptor_end?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#11 lore raw

Re: [PATCH net-next v5 06/12] gve: simplify reset logic

In reply to Harshitha Ramamurthy
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] AF_XDP (XSK) pools configuration is silently dropped during device reset, breaking the zero-copy datapath. --

commit 5f54ed314a139ce612a748bc097cf6b6779ac055
Author: Joshua Washington <[email protected]>
Subject: gve: simplify reset logic

This commit simplifies the GVE reset path by removing recursive resets, removing resets during teardown, and decomposing the allocation and setup of control plane systems. It delays freeing shared resources until after a hardware reset completes if device deconfiguration fails.

Quoted 5 lines
drivers/net/ethernet/google/gve/gve_main.c +0 -0
index 16ce55c6d74f6..acd09e9f416c1 100644
@@ -590,7 +594,22 @@ static void gve_free_notify_blocks(struct gve_priv *priv)

[ ... ]

Quoted 5 lines
drivers/net/ethernet/google/gve/gve_main.c +5 -0
+static void gve_free_control_plane_resources(struct gve_priv *priv)
+{
+	bitmap_free(priv->xsk_pools);
+	priv->xsk_pools = NULL;
+

[ ... ]

Quoted 2 lines
drivers/net/ethernet/google/gve/gve_main.c +2 -0
+static int gve_alloc_control_plane_resources(struct gve_priv *priv)
+{

[ ... ]

drivers/net/ethernet/google/gve/gve_main.c static int gve_setup_device_resources(struct gve_priv *priv) · line 647

Quoted 7 lines
drivers/net/ethernet/google/gve/gve_main.c +7 -0
+	priv->xsk_pools = bitmap_zalloc(priv->rx_cfg.max_queues, GFP_KERNEL);
+	if (!priv->xsk_pools) {
+		err = -ENOMEM;
+		goto abort;
+	}
+
+	return 0;

[Severity: High]
This is a pre-existing issue, but does unconditionally freeing and reallocating the xsk_pools bitmap during a device reset drop the AF_XDP pool configuration?

When gve_reset() is triggered (for example, by a TX timeout or an MTU change), it calls gve_teardown_device() which leads to gve_free_control_plane_resources() unconditionally freeing the bitmap. During recovery, gve_alloc_control_plane_resources() allocates a fresh zero-initialized bitmap.

If an application was actively using the XDP zero-copy datapath, wouldn't gve_reg_xdp_info() subsequently find no registered pools and silently fall back to standard page pools, breaking the application's zero-copy packet flow?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
#14 lore raw

Re: [PATCH net-next v5 07/12] gve: add gve_ctrl_ops for gve initialization/teardown sequences

In reply to Harshitha Ramamurthy
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] The ethtool callback `gve_set_rxfh` bypasses the `gve_ctrl_ops` abstraction by calling…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The ethtool callback gve_set_rxfh bypasses the gve_ctrl_ops abstraction by calling gve_adminq_configure_rss directly. --

commit 10b1b0685ff2bac01a7188b6c0dc5c2a0e9dae42
Author: Joshua Washington <[email protected]>

gve: add gve_ctrl_ops for gve initialization/teardown sequences

Driver initialization and teardown involve a number of control plane operations that need to be defined for gve_probe to operate in both mailbox and adminq modes.

Quoted 4 lines
drivers/net/ethernet/google/gve/gve_main.c +0 -0
index acd09e9f416c1..5ad7a8f9bbddb 100644

[ ... ]

Quoted 9 lines
drivers/net/ethernet/google/gve/gve_main.c +1 -0
@@ -1815,6 +1820,7 @@ static int gve_xdp(struct net_device *dev, struct netdev_bpf *xdp)
 
 int gve_init_rss_config(struct gve_priv *priv, u16 num_queues)
 {
+	const struct gve_ctrl_ops *ops = priv->ctrl_ops;
 	struct gve_rss_config *rss_config = &priv->rss_config;
 	struct ethtool_rxfh_param rxfh = {0};
 	u16 i;

drivers/net/ethernet/google/gve/gve_main.c int gve_init_rss_config(struct gve_priv *priv, u16 num_queues) · line 1840

Quoted 6 lines
drivers/net/ethernet/google/gve/gve_main.c +1 -1
@@ -1830,15 +1836,17 @@ int gve_init_rss_config(struct gve_priv *priv, u16 num_queues)
 
 	rxfh.hfunc = ETH_RSS_HASH_TOP;
 
-	return gve_adminq_configure_rss(priv, &rxfh);
+	return ops->configure_rss(priv, &rxfh);
 }

[Severity: Medium]
While this function is updated to use the new ops->configure_rss abstraction, does gve_set_rxfh() in drivers/net/ethernet/google/gve/gve_ethtool.c also need to be updated?

It appears to still call gve_adminq_configure_rss() directly:

drivers/net/ethernet/google/gve/gve_ethtool.c:gve_set_rxfh() {
    ...
	if (!priv->rss_key_size || !priv->rss_lut_size)
		return -EOPNOTSUPP;

	err = gve_adminq_configure_rss(priv, rxfh);
    ...
}

Should this also be calling ops->configure_rss() to prevent bypassing the abstraction and potentially causing undefined behavior when alternative control plane modes are used?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=7
#18 lore raw

Re: [PATCH net-next v5 09/12] gve: introduce new methods to handle IRQ doorbells

In reply to Harshitha Ramamurthy
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Missing cancellation of stats_report_task leads to NULL pointer dereference on stats_report --

commit 2f8461aff00d2f3a048492ca3caad4204f7dac28
Author: Joshua Washington <[email protected]>

gve: introduce new methods to handle IRQ doorbells

This commit introduces request_db_info and release_db_resources to struct gve_ctrl_ops. It encapsulates the configuration of device resources such as counter arrays and IRQ doorbell indices.

Quoted 4 lines
drivers/net/ethernet/google/gve/gve_main.c +0 -0
index 619ef46a7b30a..a160d36f718b9 100644

[ ... ]

Quoted 9 lines
drivers/net/ethernet/google/gve/gve_main.c +0 -1
@@ -602,7 +606,6 @@ static int gve_setup_notify_blocks(struct gve_priv *priv)
 	return err;
 }
 
-
 static void gve_free_control_plane_resources(struct gve_priv *priv)
 {
 	bitmap_free(priv->xsk_pools);

drivers/net/ethernet/google/gve/gve_main.c static void gve_free_control_plane_resources(struct gve_priv *priv) · line 620

Quoted 9 lines
drivers/net/ethernet/google/gve/gve_main.c +3 -2
@@ -611,9 +614,10 @@ static void gve_free_control_plane_resources(struct gve_priv *priv)
 	kvfree(priv->ptype_lut_dqo);
 	priv->ptype_lut_dqo = NULL;
 
-	gve_free_stats_report(priv);
-	gve_free_notify_blocks(priv);
+	gve_free_irq_db_indices(priv);
 	gve_free_counter_array(priv);
+	gve_free_notify_blocks(priv);
+	gve_free_stats_report(priv);

[Severity: High]
This isn't a bug introduced by this patch, but could this lead to a NULL pointer dereference when the uncancelled work item executes?

Looking at gve_free_stats_report(), it stops the timer and frees the priv->stats_report memory, but it does not cancel the stats_report_task work item.

If the network interface is down but the report-stats feature is enabled via ethtool, gve_queues_stop() is never called during device removal or suspend. This means the work item remains pending because the only cancel_work_sync() for this task happens in gve_queues_stop().

When the device is later removed or suspended, the workqueue is flushed (or executes concurrently), which allows gve_stats_report_task() to run after the memory is freed. This eventually calls into gve_handle_report_stats(), which dereferences the NULL pointer:

drivers/net/ethernet/google/gve/gve_main.c:gve_handle_report_stats() {
	struct stats *stats = priv->stats_report->stats;
	...
}

Should a call to cancel_work_sync(&priv->stats_report_task) be added to gve_free_stats_report() to ensure the work item cannot execute after the underlying memory is destroyed?

Quoted 3 lines
drivers/net/ethernet/google/gve/gve_main.c +0 -0
 	gve_free_rss_config_cache(priv);
 	gve_free_flow_rule_caches(priv);
 }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=9
#21 lore raw

Re: [PATCH net-next v5 10/12] gve: setup and teardown management interrupts

In reply to Harshitha Ramamurthy
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] The stats_report_task is not canceled during device removal if the network interface was down, leading to a NULL pointer dereference when the workqueue is destroyed. --

commit b267ee52d04bbd318d288ea0576f1ecaaa85d7ae
Author: Joshua Washington <[email protected]>

gve: setup and teardown management interrupts

This patch introduces control ops to set up and tear down control plane IRQs. It moves the admin queue-specific functionality to the admin queue files.

drivers/net/ethernet/google/gve/gve_main.c static void gve_free_stats_report(struct gve_priv *priv) · line 291

Quoted 7 lines
drivers/net/ethernet/google/gve/gve_main.c +0 -0
index a160d36f718b9..8522a495b78aa 100644
@@ -290,18 +290,6 @@ static void gve_free_stats_report(struct gve_priv *priv)
 	priv->stats_report = NULL;
 }

[Severity: High]
This is a pre-existing issue, but since the stats report is freed here, can the subsequent workqueue destruction in gve_remove() cause a NULL pointer dereference?

If the network interface was down, unregister_netdev() bypasses gve_close(), omitting the cancellation of stats_report_task. The stats_report_task can be queued by gve_stats_report_timer() if the timer executes just before timer_delete_sync() runs in gve_free_stats_report().

Because gve_free_stats_report() frees priv->stats_report and sets the pointer to NULL, when gve_remove() later calls:

    disable_work_sync(&priv->service_task);
    gve_teardown_device(priv);
    destroy_workqueue(priv->gve_wq);

The destroy_workqueue() call synchronously flushes and executes the pending stats_report_task. This executes gve_handle_report_stats(), which does:

    struct stats *stats = priv->stats_report->stats;

This unconditionally dereferences the NULL priv->stats_report pointer, leading to a system crash. Should stats_report_task be explicitly canceled in gve_remove() before destroying the workqueue?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=10
#25 lore raw

Re: [PATCH net-next v5 12/12] gve: add link status/speed ctrl ops

In reply to Harshitha Ramamurthy
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Potential DMA use-after-free when an admin queue command times out. --

commit fd1cf5f7dd6ca7a5afb5900e7042fea37b95574b
Author: Joshua Washington <[email protected]>

gve: add link status/speed ctrl ops

This patch refactors the link status check and link speed retrieval to use new control plane operations. It adds report_link_status and report_link_speed to gve_ctrl_ops to handle these tasks in AQ mode.

drivers/net/ethernet/google/gve/gve_ethtool.c static int gve_get_link_ksettings(struct net_device *netdev, · line 752

Quoted 10 lines
drivers/net/ethernet/google/gve/gve_ethtool.c +1 -1
index dd1c44fedc771..a3220c6514382 100644
@@ -749,12 +749,11 @@ static int gve_get_link_ksettings(struct net_device *netdev,
 	int err = 0;
 
 	if (priv->link_speed == 0)
-		err = gve_adminq_report_link_speed(priv);
+		err = priv->ctrl_ops->report_link_speed(priv);

[Severity: High]
This is a pre-existing issue, but is there a potential DMA use-after-free when an admin queue command times out here?

In the implementation of gve_adminq_report_link_speed(), we allocate a DMA buffer for the hardware to write into:

drivers/net/ethernet/google/gve/gve_adminq.c:gve_adminq_report_link_speed() {
...

	link_speed_region =
		dma_alloc_coherent(&priv->pdev->dev,
				   sizeof(*link_speed_region),
				   &link_speed_region_bus, GFP_KERNEL);
...
	err = gve_adminq_execute_cmd(priv, &gvnic_cmd);

	priv->link_speed = be64_to_cpu(*link_speed_region);
	dma_free_coherent(&priv->pdev->dev, sizeof(*link_speed_region),
			  link_speed_region, link_speed_region_bus);
	return err;
}

If gve_adminq_execute_cmd() times out because the hardware is slow to respond, it returns -ENOTRECOVERABLE. However, the driver unconditionally frees the DMA buffer via dma_free_coherent().

If the hardware is not synchronously reset and eventually completes the command, could it asynchronously write the 8-byte link speed to the freed DMA address and corrupt memory?

Since this path can be reached by an unprivileged user reading /sys/class/net/ethX/speed, could this cause remote memory corruption?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=12
#3 lore raw

Re: [PATCH net-next v5 01/12] gve: add struct gve_device_info to hold device properties

In reply to Harshitha Ramamurthy
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:

Critical: 0 · High: 0 · Medium: 1 · Low: 3

- [Medium] The ETH_MIN_MTU validation now applies to a different value than before, contradicting the commit message claim that these changes…
- [Low] struct gve_priv still declares bool default_min_ring_size; (drivers/net/ethernet/google/gve/gve.h:849) and `u16…
- [Low] The newly added struct gve_device_info declares u16 max_tx_queues; and u16 max_rx_queues;…
- [Low] The comment above the netdev feature initialization in gve_probe() (drivers/net/ethernet/google/gve/gve_main.c, target…

--

gve: add struct gve_device_info to hold device properties

This adds struct gve_device_info to hold the properties negotiated with the device, converts gve_adminq_describe_device() and its helpers to fill that structure, and moves the code that applies those properties to priv into gve_init_priv(). The commit message states the changes are refactors only with no functional change.

Quoted 5 lines
drivers/net/ethernet/google/gve/gve.h +0 -0
index c280ff35ee771..021adb9108dff 100644

drivers/net/ethernet/google/gve/gve.h struct gve_ptp { · line 805

Quoted 9 lines
drivers/net/ethernet/google/gve/gve.h +6 -0
@@ -797,6 +797,34 @@ struct gve_ptp {
 	struct gve_priv *priv;
 };
 
+struct gve_device_info {
+	enum gve_queue_format queue_format;
+	u16 default_tx_queues;
+	u16 default_rx_queues;
+	u16 max_tx_queues;
+	u16 max_rx_queues;

[Severity: Low]
Who fills in max_tx_queues and max_rx_queues? gve_fill_device_info() in gve_adminq.c sets tx_pages_per_qpl, max_registered_pages, num_event_counters, mac, max_mtu, default_tx/rx_queues and the four ring-size fields, but never these two, and nothing reads them either.

Meanwhile the one consumer that needs device queue maxima, gve_set_num_queues(), still derives them from priv->tx_cfg.max_queues and priv->rx_cfg.max_queues (read from the BAR registers in gve_probe()) while this patch converts the defaults to come from device_info:

	priv->tx_cfg.max_queues =
		min_t(int, priv->tx_cfg.max_queues, priv->num_ntfy_blks / 2);
	...
	if (device_info->default_tx_queues > 0)
		priv->tx_cfg.num_queues = min_t(int,
						device_info->default_tx_queues,
						priv->tx_cfg.num_queues);

Would it be clearer to either populate the two fields in gve_fill_device_info() and have gve_set_num_queues() use them, or drop them until there is a producer? As it stands a later MailboxQ consumer reading device_info->max_tx_queues in AdminQ mode would see 0.

Quoted 22 lines
drivers/net/ethernet/google/gve/gve.h +22 -0
+	u16 default_tx_ring_size;
+	u16 default_rx_ring_size;
+	u16 max_tx_ring_size;
+	u16 max_rx_ring_size;
+	u16 min_tx_ring_size;
+	u16 min_rx_ring_size;
+	u16 max_mtu;
+	u8 mac[ETH_ALEN];
+	u16 max_rx_buffer_size;
+	u16 header_buf_size;
+	u32 max_flow_rules;
+	u16 rss_key_size;
+	u16 rss_lut_size;
+	u16 tx_pages_per_qpl;
+	u16 num_event_counters;
+	u64 max_registered_pages;
+	bool default_min_ring_size;
+	bool nic_timestamp_supported;
+	bool modify_ring_size_enabled;
+	bool cache_rss_config;
+};
+

[ ... ]

Quoted 4 lines
drivers/net/ethernet/google/gve/gve_adminq.c +0 -0
index f05f4895f4c74..512349c5517f4 100644

[ ... ]

drivers/net/ethernet/google/gve/gve_adminq.c void gve_parse_device_option(struct gve_priv *priv, · line 193

Quoted 6 lines
drivers/net/ethernet/google/gve/gve_adminq.c +1 -1
@@ -190,7 +190,7 @@ void gve_parse_device_option(struct gve_priv *priv,
 
 		/* device has not provided min ring size */
 		if (option_length == GVE_DEVICE_OPTION_NO_MIN_RING_SIZE)
-			priv->default_min_ring_size = true;
+			priv->device_info.default_min_ring_size = true;

[Severity: Low]
Should the now-orphaned copies in struct gve_priv be removed in the same patch? This was the only writer of priv->default_min_ring_size, and gve_enable_supported_features() now reads info->default_min_ring_size, so gve.h still carries

	bool default_min_ring_size;

with no writer and no reader.

The same applies to priv->default_num_queues: gve_set_queue_properties() in gve_main.c no longer assigns it and gve_set_num_queues() now reads device_info->default_tx_queues / default_rx_queues, yet gve.h keeps

u16 default_num_queues; /* default num queues to set up */

Both priv fields stay 0/false forever after this change, and the comment describes behaviour no code implements. A follow-on MailboxQ patch reading priv->default_num_queues (always 0, meaning "no default") or priv->default_min_ring_size (always false, meaning "device provided minimums") would get the opposite of what the device reported.

Quoted 3 lines
drivers/net/ethernet/google/gve/gve_adminq.c +0 -0
 		break;
 	case GVE_DEV_OPT_ID_FLOW_STEERING:
 		if (option_length < sizeof(**dev_op_flow_steering) ||

[ ... ]

Quoted 18 lines
drivers/net/ethernet/google/gve/gve_adminq.c +4 -2
@@ -946,77 +949,105 @@ static void gve_enable_supported_features(struct gve_priv *priv,
 					  const struct gve_device_option_modify_ring
 					  *dev_op_modify_ring)
 {
+	struct gve_device_info *info = &priv->device_info;
+
 	/* Before control reaches this point, the page-size-capped max MTU from
 	 * the gve_device_descriptor field has already been stored in
-	 * priv->dev->max_mtu. We overwrite it with the true max MTU below.
+	 * device_info->max_mtu. We overwrite it with the true max MTU below.
 	 */
 	if (dev_op_jumbo_frames &&
 	    (supported_features_mask & GVE_SUP_JUMBO_FRAMES_MASK)) {
 		dev_info(&priv->pdev->dev,
 			 "JUMBO FRAMES device option enabled.\n");
-		priv->dev->max_mtu = be16_to_cpu(dev_op_jumbo_frames->max_mtu);
+		info->max_mtu = be16_to_cpu(dev_op_jumbo_frames->max_mtu);
 	}

[ ... ]

drivers/net/ethernet/google/gve/gve_adminq.c static void gve_enable_supported_features(struct gve_priv *priv, · line 998

Quoted 7 lines
drivers/net/ethernet/google/gve/gve_adminq.c +1 -2
 	if (dev_op_flow_steering &&
 	    (supported_features_mask & GVE_SUP_FLOW_STEERING_MASK)) {
 		if (dev_op_flow_steering->max_flow_rules) {
-			priv->max_flow_rules =
+			info->max_flow_rules =
 				be32_to_cpu(dev_op_flow_steering->max_flow_rules);
-			priv->dev->hw_features |= NETIF_F_NTUPLE;

[Severity: Low]
Does this leave the comment in gve_probe() pointing at the wrong function? gve_main.c still says:

	/* Set default and supported features.
	 *
	 * Features might be set in other locations as well (such as
	 * `gve_adminq_describe_device`).
	 */
	dev->hw_features = NETIF_F_HIGHDMA;

After this change gve_adminq_describe_device() and gve_enable_supported_features() only record properties into struct gve_device_info, and the NETIF_F_NTUPLE update lives in gve_init_priv(). Should the comment reference gve_init_priv() instead?

Quoted 6 lines
drivers/net/ethernet/google/gve/gve_adminq.c +1 -1
 			dev_info(&priv->pdev->dev,
 				 "FLOW STEERING device option enabled with max rule limit of %u.\n",
-				 priv->max_flow_rules);
+				 info->max_flow_rules);
 		}
 	}

[ ... ]

Quoted 20 lines
drivers/net/ethernet/google/gve/gve_adminq.c +1 -10
@@ -1097,18 +1129,9 @@ int gve_adminq_describe_device(struct gve_priv *priv)
 			 "Driver is running with GQI QPL queue format.\n");
 	}
 
+	gve_fill_device_info(priv, descriptor);
 	gve_set_default_rss_sizes(priv);
 
-	err = gve_set_mtu(priv, descriptor);
-	if (err)
-		goto free_device_descriptor;
-
-	priv->num_event_counters = be16_to_cpu(descriptor->counters);
-
-	gve_set_mac(priv, descriptor);
-
-	gve_set_queue_properties(priv, descriptor);
-
 	gve_enable_supported_features(priv, supported_features_mask,
 				      dev_op_jumbo_frames, dev_op_dqo_qpl,
 				      dev_op_buffer_sizes, dev_op_flow_steering,

[ ... ]

Quoted 27 lines
drivers/net/ethernet/google/gve/gve_adminq.c +9 -4
@@ -1595,6 +1618,8 @@ int gve_set_num_ntfy_blks(struct gve_priv *priv)
 
 void gve_set_num_queues(struct gve_priv *priv)
 {
+	struct gve_device_info *device_info = &priv->device_info;
+
 	priv->tx_cfg.max_queues =
 		min_t(int, priv->tx_cfg.max_queues, priv->num_ntfy_blks / 2);
 	priv->rx_cfg.max_queues =
@@ -1602,10 +1627,13 @@ int gve_set_num_ntfy_blks(struct gve_priv *priv)
 
 	priv->tx_cfg.num_queues = priv->tx_cfg.max_queues;
 	priv->rx_cfg.num_queues = priv->rx_cfg.max_queues;
-	if (priv->default_num_queues > 0) {
-		priv->tx_cfg.num_queues = min_t(int, priv->default_num_queues,
+	if (device_info->default_tx_queues > 0)
+		priv->tx_cfg.num_queues = min_t(int,
+						device_info->default_tx_queues,
 						priv->tx_cfg.num_queues);
-		priv->rx_cfg.num_queues = min_t(int, priv->default_num_queues,
+
+	if (device_info->default_rx_queues > 0)
+		priv->rx_cfg.num_queues = min_t(int,
+						device_info->default_rx_queues,
 						priv->rx_cfg.num_queues);
-	}
 }

[ ... ]

Quoted 4 lines
drivers/net/ethernet/google/gve/gve_main.c +0 -0
index 9cc343a162712..d3882de584e36 100644

[ ... ]

Quoted 24 lines
drivers/net/ethernet/google/gve/gve_main.c +7 -10
-void gve_set_queue_properties(struct gve_priv *priv,
-			      struct gve_device_descriptor *descriptor)
+static void gve_set_queue_properties(struct gve_priv *priv)
 {
-	/* set default descriptor counts */
-	gve_set_default_desc_cnt(priv, descriptor);
+	struct gve_device_info *device_info = &priv->device_info;
 
-	priv->max_registered_pages = be64_to_cpu(descriptor->max_registered_pages);
-	priv->tx_pages_per_qpl = be16_to_cpu(descriptor->tx_pages_per_qpl);
-	priv->default_num_queues = be16_to_cpu(descriptor->default_num_queues);
+	gve_set_desc_cnt(priv);
+	priv->max_registered_pages = device_info->max_registered_pages;
+	priv->tx_pages_per_qpl = device_info->tx_pages_per_qpl;
 }
 
-int gve_set_mtu(struct gve_priv *priv,
-		struct gve_device_descriptor *descriptor)
+static int gve_set_mtu(struct gve_priv *priv)
 {
+	struct gve_device_info *device_info = &priv->device_info;
 	u16 mtu;
 
-	mtu = be16_to_cpu(descriptor->mtu);

drivers/net/ethernet/google/gve/gve_main.c static const struct xdp_metadata_ops gve_xdp_metadata_ops = { · line 2436

Quoted 10 lines
drivers/net/ethernet/google/gve/gve_main.c +2 -0
+	mtu = device_info->max_mtu;
 	if (mtu < ETH_MIN_MTU) {
 		dev_err(&priv->pdev->dev, "MTU %d below minimum MTU\n", mtu);
 		return -EINVAL;
 	}
 	priv->dev->max_mtu = mtu;
+	priv->dev->mtu = mtu;
 
 	return 0;
 }

[Severity: Medium]
Is the ETH_MIN_MTU check still validating the same value? The commit message says:

These changes are refactors only, no functional change.

Before this patch, gve_adminq_describe_device() called gve_set_mtu(priv, descriptor), which checked be16_to_cpu(descriptor->mtu) and returned -EINVAL before gve_enable_supported_features() could overwrite priv->dev->max_mtu from the JUMBO_FRAMES option, and the jumbo value itself was never re-checked.

Now gve_fill_device_info() stores descriptor->mtu into device_info->max_mtu unchecked, gve_enable_supported_features() may overwrite it with dev_op_jumbo_frames->max_mtu, and gve_init_priv() checks whatever value survived.

So two device-supplied combinations change outcome:

descriptor->mtu < ETH_MIN_MTU plus a valid jumbo max_mtu:
probe used to fail with -EINVAL, now succeeds.

valid descriptor->mtu plus a JUMBO_FRAMES option advertising max_mtu < ETH_MIN_MTU (for example 0):
probe used to succeed and register the netdev, now fails with -EINVAL and the device is unusable.

The end of the series still validates device_info->max_mtu, so this is not restored by a later patch. Could the commit message mention the moved validation point, or could the check be kept on the descriptor MTU?

Quoted 13 lines
drivers/net/ethernet/google/gve/gve_main.c +3 -3
-void gve_set_mac(struct gve_priv *priv,
-		 struct gve_device_descriptor *descriptor)
+static void gve_set_mac(struct gve_priv *priv)
 {
+	struct gve_device_info *device_info = &priv->device_info;
 	u8 *mac;
 
-	mac = descriptor->mac;
+	mac = device_info->mac;
 	eth_hw_addr_set(priv->dev, mac);
 	dev_info(&priv->pdev->dev, "MAC addr: %pM\n", mac);
 }

[ ... ]

Quoted 22 lines
drivers/net/ethernet/google/gve/gve_main.c +17 -1
@@ -2507,12 +2523,34 @@ static int gve_init_priv(struct gve_priv *priv, bool skip_describe_device)
 		netif_set_tso_max_size(priv->dev, GVE_DQO_TX_MAX);
 	}
 
-	priv->dev->mtu = priv->dev->max_mtu;
+	if (gve_set_mtu(priv)) {
+		err = -EINVAL;
+		goto err;
+	}
+
+	priv->num_event_counters = device_info->num_event_counters;
+
+	gve_set_mac(priv);
+
+	gve_set_queue_properties(priv);
+	priv->modify_ring_size_enabled = device_info->modify_ring_size_enabled;
+
+	gve_set_buf_sizes(priv);
+
+	priv->max_flow_rules = device_info->max_flow_rules;
+	if (priv->max_flow_rules)
+		priv->dev->hw_features |= NETIF_F_NTUPLE;

[ ... ]

Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260903215606.31633-1-hramamurthy%40google.com
#5 lore raw

Re: [PATCH net-next v5 02/12] gve: introduce control plane operations structure

In reply to Harshitha Ramamurthy
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Critical: 0 · High: 0 · Medium: 0 · Low: 1

- [Low] New indirect control-plane op return value is discarded in gve_probe().

--

gve: introduce control plane operations structure

This adds a gve_ctrl_ops structure to abstract control plane operations between the existing Adminq ABI and an upcoming Mailbox ABI, and moves the doorbell BAR map/unmap into the first two ops. Only the Adminq ops are populated by this patch, and gve_probe()/gve_remove() now call through priv->ctrl_ops.

Quoted 17 lines
drivers/net/ethernet/google/gve/gve.h +9 -0
index 021adb9108dff..56148ea3cfbf5 100644
@@ -825,6 +825,16 @@ struct gve_device_info {
 	bool cache_rss_config;
 };
 
+/**
+ * struct gve_ctrl_ops - Control plane operations structure
+ * @map_db_bar: Maps the doorbell BAR for the device and store in @priv.
+ * @unmap_db_bar: Unmaps the doorbell BAR previously mapped by @map_db_bar.
+ */
+struct gve_ctrl_ops {
+	int (*map_db_bar)(struct gve_priv *priv);
+	void (*unmap_db_bar)(struct gve_priv *priv);
+};

[ ... ]

Quoted 18 lines
drivers/net/ethernet/google/gve/gve_adminq.c +13 -0
index 512349c5517f4..08d8e49d563eb 100644
@@ -1637,3 +1637,24 @@ void gve_set_num_queues(struct gve_priv *priv)
+int gve_adminq_map_db_bar(struct gve_priv *priv)
+{
+	struct pci_dev *pdev = priv->pdev;
+	void __iomem *db_bar;
+
+	db_bar = pci_iomap(pdev, GVE_DOORBELL_BAR, 0);
+	if (!db_bar) {
+		dev_err(&pdev->dev, "Failed to map doorbell bar!\n");
+		return -ENOMEM;
+	}
+	priv->db_bar2 = db_bar;
+	return 0;
+}

[ ... ]

Quoted 4 lines
drivers/net/ethernet/google/gve/gve_main.c +0 -0
index d3882de584e36..93b714e1d1307 100644

[ ... ]

drivers/net/ethernet/google/gve/gve_main.c static int gve_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 2942

Quoted 10 lines
drivers/net/ethernet/google/gve/gve_main.c +6 -0
@@ -2937,19 +2934,27 @@ static int gve_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	priv->rx_cfg.packet_buffer_size = GVE_DEFAULT_RX_BUFFER_SIZE;
 	priv->max_rx_buffer_size = GVE_DEFAULT_RX_BUFFER_SIZE;
 
+	/* Set adminq ctrl ops */
+	priv->ctrl_ops = &gve_adminq_ops;
+
+	err = priv->ctrl_ops->map_db_bar(priv);
+	if (err) {
+		err = -ENOMEM;
                ^^^^

[Severity: Low]
Is the err = -ENOMEM; assignment here intentional? The new op is declared as returning an int errno in struct gve_ctrl_ops, and gve_adminq_map_db_bar() already returns 0 or -ENOMEM and prints its own dev_err(), so the captured value is overwritten before it is ever used.

With only the Adminq implementation present the resulting errno happens to be identical, so there is no change in behaviour today. Once the Mailbox op mentioned in the commit message is added, would an -EINVAL, -EIO, -ENODEV or -EPROBE_DEFER from map_db_bar() be reported to the PCI core as -ENOMEM instead? -EPROBE_DEFER in particular would turn a deferred probe into a hard failure.

The other failure sites in gve_probe(), for example gve_init_priv() and register_netdev(), propagate err unchanged, so would just dropping the err = -ENOMEM; line match the surrounding convention?

Quoted 11 lines
drivers/net/ethernet/google/gve/gve_main.c +4 -1
+		goto abort_with_netdev;
+	}
+
 	gve_set_probe_in_progress(priv);
 	priv->gve_wq = alloc_ordered_workqueue("gve", 0);
 	if (!priv->gve_wq) {
 		dev_err(&pdev->dev, "Could not allocate workqueue");
 		err = -ENOMEM;
-		goto abort_with_netdev;
+		goto abort_with_unmap_db_bar;
 	}

[ ... ]

Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260903215606.31633-1-hramamurthy%40google.com
#9 lore raw

Re: [PATCH net-next v5 05/12] gve: refactor gve_init_priv for reset path

In reply to Harshitha Ramamurthy
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:

Critical: 0 · High: 0 · Medium: 0 · Low: 4

- [Low] gve_reset_recovery() error-path change contradicts the "only code movement, no functional change" claim: when gve_open() fails during…
- [Low] Folding gve_adminq_write_version() into the new gve_adminq_init() changes when and how often the driver version register is written,…
- [Low] Duplicated / misattributed error reporting: the new gve_probe() call site prints "Could not get device information: err=%d" for any…
- [Low] Stale comment in gve_probe(): the "Set default and supported features" block still says features "might be set in other locations…

--

gve: refactor gve_init_priv for reset path

This splits gve_init_priv() so that device property negotiation and AdminQ setup happen once in gve_probe(), introduces gve_adminq_init() and gve_setup_device(), and makes gve_reset_recovery() call the setup helpers directly.

A few questions on the "no functional change" claim and on the new diagnostics below.

Quoted 17 lines
drivers/net/ethernet/google/gve/gve.h +2 -0
index 1bc5e32b6618e..48cc8a6be186c 100644
@@ -1253,6 +1253,8 @@ static inline bool gve_is_clock_enabled(struct gve_priv *priv)
 	return priv->nic_ts_report;
 }
 
+void gve_adminq_write_version(u8 __iomem *driver_version_register);
+
 /* gqi napi handler defined in gve_main.c */
 int gve_napi_poll(struct napi_struct *napi, int budget);
 
drivers/net/ethernet/google/gve/gve_adminq.c +0 -0
index f420a8e1dd3df..a62cb7a921d07 100644

[ ... ]

drivers/net/ethernet/google/gve/gve_adminq.c int gve_adminq_alloc(struct device *dev, struct gve_priv *priv) · line 367

Quoted 12 lines
drivers/net/ethernet/google/gve/gve_adminq.c +8 -0
@@ -355,6 +357,14 @@ int gve_adminq_alloc(struct device *dev, struct gve_priv *priv)
 	return 0;
 }
 
+int gve_adminq_init(struct gve_priv *priv)
+{
+	struct gve_registers __iomem *reg_bar = priv->reg_bar0;
+
+	gve_adminq_write_version(&reg_bar->driver_version);
+	return gve_adminq_alloc(priv);
+}
+

[Severity: Low]
Folding the version write into gve_adminq_init() changes when and how often the driver version register is written, so is the commit message statement "These changes are only code movement, no functional change" accurate here?

Before this patch the string was written exactly once per probe, from gve_probe(), and before max_tx_queues/max_rx_queues were read. After this patch gve_reset_recovery() also calls gve_adminq_init(), so the version string is re-emitted to the device on every gve_reset() (ethtool reset, device-requested reset from the service task, adminq timeout) and on gve_resume().

struct gve_registers::driver_version is a single byte write port that gve_adminq_write_version() feeds a byte at a time, so re-writing it looks harmless from the driver side, but it is a device-visible change. Is re-writing the version on each AdminQ re-init intentional, and could the changelog say so?

Quoted 3 lines
drivers/net/ethernet/google/gve/gve_adminq.c +0 -0
 void gve_adminq_release(struct gve_priv *priv)
 {
 	int i = 0;

[ ... ]

Quoted 4 lines
drivers/net/ethernet/google/gve/gve_main.c +0 -0
index 08859611a96e4..16ce55c6d74f6 100644

[ ... ]

Quoted 18 lines
drivers/net/ethernet/google/gve/gve_main.c +11 -2
@@ -2566,15 +2541,32 @@ static int gve_reset_recovery(struct gve_priv *priv, bool was_up)
 {
 	int err;
 
-	err = gve_init_priv(priv, true);
-	if (err)
+	err = gve_adminq_init(priv);
+	if (err) {
+		dev_err(&priv->pdev->dev,
+			"Failed to alloc admin queue: err=%d\n", err);
 		goto err;
+	}
+
+	err = gve_adminq_verify_driver_compatibility(priv);
+	if (err) {
+		dev_err(&priv->pdev->dev,
+			"Could not verify driver compatibility: err=%d\n", err);
+		goto err_free_adminq;

drivers/net/ethernet/google/gve/gve_main.c static int gve_reset_recovery(struct gve_priv *priv, bool was_up) · line 2564

Quoted 10 lines
drivers/net/ethernet/google/gve/gve_main.c +6 -1
+	}
+
+	err = gve_setup_device(priv);
+	if (err)
+		goto err_free_adminq;
 	if (was_up) {
 		err = gve_open(priv->dev);
 		if (err)
-			goto err;
+			return err;

[Severity: Low]
Is this error path change also covered by "These changes are only code movement, no functional change"?

Previously a gve_open() failure here fell into the err: label:

err:

	dev_err(&priv->pdev->dev, "Reset failed! !!! DISABLING ALL QUEUES !!!\n");
	gve_turndown(priv);

Now it returns silently, so the "Reset failed!" message is no longer printed when gve_open() fails during reset or resume recovery, for example on an -ENOMEM from gve_queues_mem_alloc(). The path is reachable from both gve_reset()->gve_reset_recovery(priv, true) and gve_resume()->gve_reset_recovery(priv, priv->up_before_suspend).

The gve_turndown(priv) call looks like a no-op at that point, since it returns early unless gve_get_napi_enabled(priv) is set and every caller reaching gve_reset_recovery() with was_up already turned the device down, so the observable difference appears to be only the missing dev_err().

The behaviour change is described in the post-"---" v3 notes as "don't free device resources if gve_open() fails in the reset path", but the old err: label did not free device resources either, it only logged and called gve_turndown(). Could that note be reworded, or the change mentioned in the commit message proper?

Note the next patch in the series, "gve: simplify reset logic", turns this into gve_recover() where a gve_open() failure does "goto teardown_device;" and the log message comes back, so this only affects the intermediate state.

Quoted 18 lines
drivers/net/ethernet/google/gve/gve_main.c +4 -1
 	}
 	return 0;
+
+err_free_adminq:
+	gve_adminq_free(priv);
 err:
 	dev_err(&priv->pdev->dev, "Reset failed! !!! DISABLING ALL QUEUES !!!\n");
 	gve_turndown(priv);
@@ -2617,7 +2609,7 @@ int gve_reset(struct gve_priv *priv, bool attempt_teardown)
 	return err;
 }
 
-static void gve_write_version(u8 __iomem *driver_version_register)
+void gve_adminq_write_version(u8 __iomem *driver_version_register)
 {
 	const char *c = gve_version_prefix;
 

drivers/net/ethernet/google/gve/gve_main.c static int gve_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 2847

Quoted 7 lines
drivers/net/ethernet/google/gve/gve_main.c +0 -1
@@ -2850,7 +2842,6 @@ static int gve_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 		goto abort_with_pci_region;
 	}
 
-	gve_write_version(&reg_bar->driver_version);
 	/* Get max queues to alloc etherdev */
 	max_tx_queues = ioread32be(&reg_bar->max_tx_queues);
 	max_rx_queues = ioread32be(&reg_bar->max_rx_queues);

[Severity: Low]
Related to the gve_adminq_init() comment above: this removal also reverses the probe-time ordering between the driver version write and the reads of max_tx_queues/max_rx_queues. The version string is now written later, from gve_adminq_init(), after the netdev has been allocated. Does the device care about that ordering?

Quoted 8 lines
drivers/net/ethernet/google/gve/gve_main.c +4 -0
@@ -2897,13 +2888,28 @@ static int gve_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	priv->rx_cfg.packet_buffer_size = GVE_DEFAULT_RX_BUFFER_SIZE;
 	priv->max_rx_buffer_size = GVE_DEFAULT_RX_BUFFER_SIZE;
 
+	err = gve_adminq_init(priv);
+	if (err) {
+		dev_err(&priv->pdev->dev,
+			"Failed to alloc admin queue: err=%d\n", err);

drivers/net/ethernet/google/gve/gve_main.c static int gve_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 2904

Quoted 10 lines
drivers/net/ethernet/google/gve/gve_main.c +10 -0
+		goto abort_with_netdev;
+	}
+
+	priv->device_info.queue_format = GVE_QUEUE_FORMAT_UNSPECIFIED;
+	err = gve_adminq_get_device_properties(priv);
+	if (err) {
+		dev_err(&priv->pdev->dev,
+			"Could not get device information: err=%d\n", err);
+		goto abort_with_adminq;
+	}

[Severity: Low]
Is this dev_err() redundant, and misleading for one of the two failure causes? gve_adminq_get_device_properties() in gve_adminq.c already logs each sub-step:

	err = gve_adminq_verify_driver_compatibility(priv);
	if (err) {
		dev_err(&priv->pdev->dev,
			"Could not verify driver compatibility: err=%d\n", err);
		return err;
	}

	/* Get the initial information we need from the device */
	err = gve_adminq_describe_device(priv);
	if (err) {
		dev_err(&priv->pdev->dev,
			"Could not get device information: err=%d\n", err);
		return err;
	}

So a VERIFY_DRIVER_COMPATIBILITY failure during probe prints the correct "Could not verify driver compatibility" line and is then followed by "Could not get device information", and a DESCRIBE_DEVICE failure prints the same line twice.

Would dropping the dev_err() at this call site, or making the helper silent and logging only in the callers, be preferable? The reset path added in this patch does the latter, calling gve_adminq_verify_driver_compatibility() directly and logging itself.

[Severity: Low]
Separate from the hunk itself: while this region of gve_probe() is being rearranged, is the feature comment a little higher up in the same function still accurate?

	/* Set default and supported features.
	 *
	 * Features might be set in other locations as well (such as
	 * `gve_adminq_describe_device`).
	 */
	dev->hw_features = NETIF_F_HIGHDMA;

After this series gve_adminq_describe_device() and gve_enable_supported_features() only fill priv->device_info; the netdev feature bits (NETIF_F_GRO_HW, NETIF_F_GSO_UDP_L4, NETIF_F_NTUPLE, plus netif_set_tso_max_size()) are set in gve_init_priv() in gve_main.c. The only remaining reference to priv->dev->features in gve_adminq.c is the read in the create RX queue path. Should the comment point at gve_init_priv() instead?

Quoted 11 lines
drivers/net/ethernet/google/gve/gve_main.c +1 -1
 	/* Set adminq ctrl ops */
 	priv->ctrl_ops = &gve_adminq_ops;
 
 	err = priv->ctrl_ops->map_db_bar(priv);
 	if (err) {
 		err = -ENOMEM;
-		goto abort_with_netdev;
+		goto abort_with_adminq;
 	}
 
 	gve_set_probe_in_progress(priv);

[ ... ]

Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260903215606.31633-1-hramamurthy%40google.com
#12 lore raw

Re: [PATCH net-next v5 06/12] gve: simplify reset logic

In reply to Harshitha Ramamurthy
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Critical: 0 · High: 0 (1) · Medium: 0 · Low: 2

- [Low] The patch silently fixes a real pre-existing adminq DMA/dma_pool leak without a Fixes: tag and without disclosing it in the commit…
- [Low] Commit message goal 2 misdescribes the pre-patch defect and overstates the change.

Pre-existing issues:
- [High] The stats-report DMA buffer can be freed while priv->stats_report_task is queued or running, giving a NULL-pointer…

--

gve: simplify reset logic

This reworks the gve reset path: recursive resets and resets issued from the teardown path are removed, control plane resource allocation is split from device setup, and resources shared with the device are only freed after gve_adminq_free() has reset the hardware. Flow rule timeout handling moves from the adminq layer into the ethtool add/delete entry points.

A few questions on the changelog and on the stats report worker below.

[Severity: Low]
The changelog says:

2) Removing resets during teardown. ... As it stands, if deconfigure_device_resources fails, for example, GVE will preempt its reset with another reset without actually invoking a hardware reset, which could actually help with recovery.

Is the "without actually invoking a hardware reset" part accurate?

gve_trigger_reset() was just a call to gve_adminq_release(), and that function does poke the reset registers and wait for the device:

	iowrite32be(GVE_DRIVER_STATUS_RESET_MASK, &priv->reg_bar0->driver_status);
	while (!(ioread32be(&priv->reg_bar0->device_status)
			& GVE_DEVICE_STATUS_DEVICE_IS_RESET)) {

(older revisions zero adminq_pfn and poll it instead). So a hardware reset did happen on that path; what was missing afterwards was the adminq/dma_pool teardown, see the next comment.

Also, is "Removing resets during teardown" fully true after this change? The new gve_close() still has a reset label calling gve_reset(priv, true) when gve_destroy_rings() or gve_unregister_qpls() fails, and both gve_shutdown() and gve_suspend() call gve_close(), so queue teardown can still perform a full hardware reset plus recovery before the caller tears the device down again. Could the changelog mention that remaining path?

Quoted 4 lines
drivers/net/ethernet/google/gve/gve_adminq.c +0 -0
index a62cb7a921d07..901673d2e2648 100644

[ ... ]

drivers/net/ethernet/google/gve/gve_adminq.c void gve_adminq_release(struct gve_priv *priv) · line 399

Quoted 8 lines
drivers/net/ethernet/google/gve/gve_adminq.c +0 -1
@@ -394,7 +394,6 @@ void gve_adminq_release(struct gve_priv *priv)
 	}
 	gve_clear_device_rings_ok(priv);
 	gve_clear_device_resources_ok(priv);
-	gve_clear_admin_queue_ok(priv);
 }
 
 void gve_adminq_free(struct gve_priv *priv)

[Severity: Low]
Does this one-line removal fix a pre-existing leak of the adminq buffer and its dma_pool?

Before this patch gve_adminq_release() cleared admin_queue_ok, and gve_adminq_free() starts with an early return keyed off that same bit:

	void gve_adminq_free(struct gve_priv *priv)
	{
		if (!gve_get_admin_queue_ok(priv))
			return;
		gve_adminq_release(priv);
		dma_pool_free(priv->adminq_pool, priv->adminq, priv->adminq_bus_addr);
		dma_pool_destroy(priv->adminq_pool);

so every caller of gve_trigger_reset() skipped the dma_pool_free() and dma_pool_destroy() that followed:

gve_reset_and_teardown()
gve_trigger_reset() /* gve_adminq_release(), clears admin_queue_ok */
gve_teardown_priv_resources()
gve_adminq_free() /* early return, pool and buffer leaked */

The same happened for the three error branches in gve_teardown_device_resources(). Would it make sense to split this into its own patch with a Fixes: tag, or at least mention the leak in the changelog? As written the fix is buried in a ~350 line refactor and stable tooling has nothing to pick up.

[ ... ]

Quoted 4 lines
drivers/net/ethernet/google/gve/gve_main.c +0 -0
index 16ce55c6d74f6..acd09e9f416c1 100644

[ ... ]

Quoted 17 lines
drivers/net/ethernet/google/gve/gve_main.c +3 -8
@@ -1451,41 +1494,16 @@ static int gve_open(struct net_device *dev)
 	return 0;
 }
 
-static int gve_queues_stop(struct gve_priv *priv)
+static void gve_queues_stop(struct gve_priv *priv)
 {
-	int err;
+	gve_unreg_xdp_info(priv);
+	gve_drain_page_cache(priv);
 
-	netif_carrier_off(priv->dev);
-	if (gve_get_device_rings_ok(priv)) {
-		gve_turndown(priv);
-		gve_drain_page_cache(priv);
-		err = gve_destroy_rings(priv);
-		if (err)

drivers/net/ethernet/google/gve/gve_main.c static int gve_open(struct net_device *dev) · line 1503

Quoted 10 lines
drivers/net/ethernet/google/gve/gve_main.c +1 -8
-			goto err;
-		err = gve_unregister_qpls(priv);
-		if (err)
-			goto err;
-		gve_clear_device_rings_ok(priv);
-	}
 	timer_delete_sync(&priv->stats_report_timer);
-
-	gve_unreg_xdp_info(priv);
+	cancel_work_sync(&priv->stats_report_task);

[Severity: High]
This isn't a bug introduced by this patch, since before it nothing cancelled stats_report_task at all, but the new cancel_work_sync() only runs on the interface-up path. Should it live in gve_free_stats_report() or gve_teardown_device() instead so it covers the down-interface cases?

gve_free_stats_report() only synchronizes the timer before freeing the coherent buffer:

	timer_delete_sync(&priv->stats_report_timer);
	dma_free_coherent(&priv->pdev->dev, priv->stats_report_len,
			  priv->stats_report, priv->stats_report_bus);
	priv->stats_report = NULL;

An already queued stats_report_task survives that. The timer can be armed from ethtool with the interface down, there is no netif_running() or resource-state check in gve_set_priv_flags():

	if (flags & BIT(0)) {
		mod_timer(&priv->stats_report_timer,
			  round_jiffies(jiffies +
				msecs_to_jiffies(priv->stats_report_timer_period)));
	}

and gve_stats_report_timer() -> gve_stats_report_schedule() queues priv->stats_report_task, whose gve_handle_report_stats() writes into the buffer:

	be64_add_cpu(&priv->stats_report->written_count, 1);

Can that write land on a NULL priv->stats_report, or into memory dma_free_coherent() has already released? The paths that skip gve_queues_stop() look like:

gve_reset() with was_up == false /* ethtool --reset all on a down iface */
disable_work(&priv->service_task) /* stats_report_task not disabled */ gve_teardown_device()
gve_free_control_plane_resources()
gve_free_stats_report()

Quoted 33 lines
drivers/net/ethernet/google/gve/gve_main.c +1 -24
@@ -2514,30 +2542,7 @@ static int gve_init_priv(struct gve_priv *priv)
 	return 0;
 }
 
-static void gve_teardown_priv_resources(struct gve_priv *priv)
-{
-	gve_teardown_device_resources(priv);
-	gve_adminq_free(priv);
-	bitmap_free(priv->xsk_pools);
-	priv->xsk_pools = NULL;
-}
-
-static void gve_trigger_reset(struct gve_priv *priv)
-{
-	/* Reset the device by releasing the AQ */
-	gve_adminq_release(priv);
-}
-
-static void gve_reset_and_teardown(struct gve_priv *priv, bool was_up)
-{
-	gve_trigger_reset(priv);
-	/* With the reset having already happened, close cannot fail */
-	if (was_up)
-		gve_close(priv->dev);
-	gve_teardown_priv_resources(priv);
-}
-
-static int gve_reset_recovery(struct gve_priv *priv, bool was_up)
+static int gve_recover(struct gve_priv *priv, bool setup_queues)
 {
 	int err;
 
@@ -2545,62 +2550,66 @@ static int gve_reset_recovery(struct gve_priv *priv, bool was_up)

[ ... ]

Quoted 32 lines
drivers/net/ethernet/google/gve/gve_main.c +10 -13
-int gve_reset(struct gve_priv *priv, bool attempt_teardown)
+int gve_reset(struct gve_priv *priv, bool skip_queue_setup)
 {
 	bool was_up = netif_running(priv->dev);
 	int err;
 
+	if (gve_get_reset_in_progress(priv))
+		return 0;
+
 	dev_info(&priv->pdev->dev, "Performing reset\n");
 	gve_clear_do_reset(priv);
 	gve_set_reset_in_progress(priv);
-	/* If we aren't attempting to teardown normally, just go turndown and
-	 * reset right away.
-	 */
-	if (!attempt_teardown) {
+
+	if (was_up) {
 		gve_turndown(priv);
-		gve_reset_and_teardown(priv, was_up);
-	} else {
-		/* Otherwise attempt to close normally */
-		if (was_up) {
-			err = gve_close(priv->dev);
-			/* If that fails reset as we did above */
-			if (err)
-				gve_reset_and_teardown(priv, was_up);
+		if (gve_get_device_rings_ok(priv)) {
+			gve_clear_device_rings_ok(priv);
+			gve_destroy_rings(priv);
+			gve_unregister_qpls(priv);
 		}

drivers/net/ethernet/google/gve/gve_main.c static int gve_reset_recovery(struct gve_priv *priv, bool was_up) · line 2605

Quoted 10 lines
drivers/net/ethernet/google/gve/gve_main.c +4 -4
-		/* Clean up any remaining resources */
-		gve_teardown_priv_resources(priv);
+		gve_queues_stop(priv);
 	}
 
-	/* Set it all back up */
-	err = gve_reset_recovery(priv, was_up);
+	disable_work(&priv->service_task);
+	gve_teardown_device(priv);
+	gve_queues_mem_remove(priv);

Following the comment above: with was_up == false, gve_queues_stop() is not called here, so the new cancel_work_sync(&priv->stats_report_task) is skipped while gve_teardown_device() frees the stats report buffer. Only service_task is covered by disable_work() here.

[ ... ]

drivers/net/ethernet/google/gve/gve_main.c static void gve_remove(struct pci_dev *pdev) · line 2996

Quoted 8 lines
drivers/net/ethernet/google/gve/gve_main.c +2 -1
@@ -2981,7 +2991,8 @@ static void gve_remove(struct pci_dev *pdev)
 	void __iomem *reg_bar = priv->reg_bar0;
 
 	unregister_netdev(netdev);
-	gve_teardown_priv_resources(priv);
+	disable_work_sync(&priv->service_task);
+	gve_teardown_device(priv);
 	destroy_workqueue(priv->gve_wq);

Same question for removal of a down interface: stats_report_task is not synchronized before gve_teardown_device() frees priv->stats_report.

[ ... ]

Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260903215606.31633-1-hramamurthy%40google.com
#16 lore raw

Re: [PATCH net-next v5 08/12] gve: split up notify block allocation and setup paths

In reply to Harshitha Ramamurthy
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Critical: 0 · High: 0 · Medium: 0 · Low: 1

- [Low] Style artifact: removing the old gve_free_notify_blocks() body leaves two consecutive blank lines between the end of…

--

gve: split up notify block allocation and setup paths

This splits gve_alloc_notify_blocks() into separate allocation and setup phases so that MSI-X vectors can be requested after the IRQ doorbell offsets are known. Teardown is handled by a new gve_teardown_notify_blocks(), tracked by the new irq_requested and mgmt_irq_requested flags.

Quoted 4 lines
drivers/net/ethernet/google/gve/gve_main.c +0 -0
index 5ad7a8f9bbddb..619ef46a7b30a 100644

[ ... ]

Quoted 4 lines
drivers/net/ethernet/google/gve/gve_main.c +0 -0
@@ -538,61 +596,12 @@ static int gve_alloc_notify_blocks(struct gve_priv *priv)
 			cur_cpu = cpumask_first(node_mask);
 	}
 	return 0;

[ ... ]

Quoted 11 lines
drivers/net/ethernet/google/gve/gve_main.c +2 -6
+abort:
+	gve_teardown_notify_blocks(priv);
 	return err;
 }
 
-static void gve_free_notify_blocks(struct gve_priv *priv)
-{
-	int i;
-
-	if (!priv->msix_vectors)
-		return;

[ ... ]

drivers/net/ethernet/google/gve/gve_main.c static int gve_alloc_notify_blocks(struct gve_priv *priv) · line 607

Quoted 7 lines
drivers/net/ethernet/google/gve/gve_main.c +0 -4
-	pci_disable_msix(priv->pdev);
-	kvfree(priv->msix_vectors);
-	priv->msix_vectors = NULL;
-}
 
 static void gve_free_control_plane_resources(struct gve_priv *priv)
 {

[Severity: Low]
This isn't a bug, but removing the old gve_free_notify_blocks() body leaves two consecutive blank lines between the closing brace of gve_setup_notify_blocks() and gve_free_control_plane_resources():

	abort:
		gve_teardown_notify_blocks(priv);
		return err;
	}

	static void gve_free_control_plane_resources(struct gve_priv *priv)

checkpatch reports "CHECK: Please don't use multiple blank lines" here. Worth dropping one of them so the submission is checkpatch clean?

Note that the next patch in the series, "gve: introduce new methods to handle IRQ doorbells", happens to remove the extra blank line, so the artifact does not survive to the end of the series.

Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260903215606.31633-1-hramamurthy%40google.com
#19 lore raw

Re: [PATCH net-next v5 09/12] gve: introduce new methods to handle IRQ doorbells

In reply to Harshitha Ramamurthy
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:

Critical: 0 · High: 0 · Medium: 1 · Low: 3

- [Medium] The commit message does not describe what the patch actually does.
- [Low] The patch adds gve_ntfy_to_msix_idx() in gve.h — an identity function that ignores its priv argument and returns ntfy_blk_idx…
- [Low] The replacement error log in gve_setup_control_plane_resources()…
- [Low] The new kernel-doc for struct gve_ctrl_ops (gve.h:837-839) describes the two new callbacks purely in terms of doorbells —…

--

gve: introduce new methods to handle IRQ doorbells

This adds request_db_info and release_db_resources callbacks to struct gve_ctrl_ops, wires the AdminQ implementations into gve_setup_control_plane_resources() and gve_teardown_control_plane_resources(), and moves the irq_db_indices DMA buffer allocation into new helpers in gve_main.c.

A few questions below about the changelog and some of the hunks.

Quoted 7 lines

Introduce request_db_info and release_db_resources to struct gve_ctrl_ops. These encapsulate the configuration of device resources (counter arrays and IRQ doorbell indices) which vary between Admin Queue and Mailbox modes. Registration and de-registratino of IRQ dorrbell indices with the device will be managed by these new methods instead of occurring directly in notify_block setup/teardown methods. Similarly, GQ ring counters will be managed in request_db_info.

[Severity: Medium]
Does the changelog match what the diff does?

"Registration and de-registratino of IRQ dorrbell indices with the device will be managed by these new methods instead of occurring directly in notify_block setup/teardown methods" — registration with the device was not in the notify-block methods before this patch. As the diff itself shows, gve_setup_control_plane_resources() already called gve_adminq_configure_device_resources() and gve_teardown_control_plane_resources() already called gve_adminq_deconfigure_device_resources(). The new callbacks are invoked from those same two functions.

What actually leaves gve_alloc_notify_blocks()/gve_free_notify_blocks() is the dma_alloc_coherent()/dma_free_coherent() of priv->irq_db_indices, which moves into the new gve_alloc_irq_db_indices()/ gve_free_irq_db_indices() helpers called from gve_alloc_control_plane_resources()/gve_free_control_plane_resources() — not into the new ops — plus the per-block

	block->irq_db_index = &priv->irq_db_indices[i].index;

assignment, which moves into gve_adminq_request_db_info().

"Similarly, GQ ring counters will be managed in request_db_info" also looks stale relative to the code. Per the v3 changelog the counter array allocation was moved back into gve_alloc_control_plane_resources(), and gve_adminq_request_db_info() only forwards priv->counter_array_bus to the device exactly as the removed code did.

Two further changes in the diff are not mentioned at all: the new gve_ntfy_to_msix_idx() indirection, and the reordering of the counter array and irq db indices allocation and free relative to the notify blocks and the stats report. Could the changelog be updated to describe these?

Also, "de-registratino" and "dorrbell" are typos.

drivers/net/ethernet/google/gve/gve.h struct gve_device_info { · line 839

Quoted 11 lines
drivers/net/ethernet/google/gve/gve.h +3 -0
index f624a3e385e4c..6c46c842070b7 100644
@@ -834,6 +834,9 @@ struct gve_device_info {
  *                  structures stored in @priv to be used during initialization.
  * @set_num_ntfy_blks: Sets no. of vectors into @priv to be used during
  *                     initialization.
+ * @request_db_info: Request and store doorbell information into @priv
+ * @release_db_resources: Release device hold on DMA memory holding doorbell
+ *			  info (AdminQ only)

[Severity: Low]
Should this kernel-doc also mention the event counter array?

The only implementation does more than doorbells:
gve_adminq_request_db_info() passes priv->counter_array_bus and priv->num_event_counters into gve_adminq_configure_device_resources(), and gve_adminq_release_db_resources() calls gve_adminq_deconfigure_device_resources(), which revokes the device's hold on the counter array as well as the doorbell index array. No other hook in struct gve_ctrl_ops covers the counter array, so a future Mailbox implementer following this description would not know it has to register and revoke priv->counter_array.

The "(AdminQ only)" annotation on release_db_resources also reads as optional, but both call sites dereference it unconditionally — the
release_db_resources: label in gve_setup_control_plane_resources() and the call in gve_teardown_control_plane_resources() — so every implementation of the table must provide it.

Quoted 3 lines
drivers/net/ethernet/google/gve/gve.h +0 -0
  * @get_ptype_map: Learn packet type map from device and store it in @priv
  * @configure_rss: Set up default RSS configuration
  * @setup_stats_report: Set up DMA region for stats report (AdminQ only)

[ ... ]

drivers/net/ethernet/google/gve/gve.h static inline u32 gve_rx_idx_to_ntfy(struct gve_priv *priv, u32 queue_idx) · line 1176

Quoted 9 lines
drivers/net/ethernet/google/gve/gve.h +5 -0
@@ -1164,6 +1169,11 @@ static inline u32 gve_rx_idx_to_ntfy(struct gve_priv *priv, u32 queue_idx)
 	return (priv->num_ntfy_blks / 2) + queue_idx;
 }
 
+static inline u32 gve_ntfy_to_msix_idx(struct gve_priv *priv, u32 ntfy_blk_idx)
+{
+	return ntfy_blk_idx;
+}
+

[Severity: Low]
What is this helper for in this patch? It returns its argument unchanged and ignores priv, and it is still an identity function at the end of the series. It is also unrelated to the doorbell-info ops the changelog describes, so a reader cannot tell what mapping is intended later or verify that a future non-identity version will be correct.

Could it be introduced in the patch that actually needs a non-trivial mapping, or at least described in the changelog?

Quoted 33 lines
drivers/net/ethernet/google/gve/gve.h +0 -0
 static inline bool gve_is_qpl(struct gve_priv *priv)
 {
 	return priv->queue_format == GVE_GQI_QPL_FORMAT ||
drivers/net/ethernet/google/gve/gve_adminq.c +22 -0
index 1176e13fafc0c..b89825a85db82 100644
@@ -1718,3 +1718,40 @@ void gve_adminq_unmap_db_bar(struct gve_priv *priv)
 
 	pci_iounmap(pdev, priv->db_bar2);
 }
+
+int gve_adminq_request_db_info(struct gve_priv *priv)
+{
+	int err;
+	int i;
+
+	err = gve_adminq_configure_device_resources(priv,
+						    priv->counter_array_bus,
+						    priv->num_event_counters,
+						    priv->irq_db_indices_bus,
+						    priv->num_ntfy_blks);
+	if (unlikely(err)) {
+		dev_err(&priv->pdev->dev,
+			"could not setup device_resources: err=%d\n", err);
+		return -ENXIO;
+	}
+
+	for (i = 0; i < priv->num_ntfy_blks; i++)
+		priv->ntfy_blocks[i].irq_db_index =
+			&priv->irq_db_indices[i].index;
+	return 0;
+}

[ ... ]

Quoted 32 lines
drivers/net/ethernet/google/gve/gve_main.c +24 -0
index 619ef46a7b30a..a160d36f718b9 100644
@@ -203,6 +203,30 @@ static void gve_free_counter_array(struct gve_priv *priv)
 	priv->counter_array = NULL;
 }
 
+static int gve_alloc_irq_db_indices(struct gve_priv *priv)
+{
+	priv->irq_db_indices =
+		dma_alloc_coherent(&priv->pdev->dev,
+				   priv->num_ntfy_blks *
+				   sizeof(*priv->irq_db_indices),
+				   &priv->irq_db_indices_bus, GFP_KERNEL);
+	if (!priv->irq_db_indices)
+		return -ENOMEM;
+
+	return 0;
+}
+
+static void gve_free_irq_db_indices(struct gve_priv *priv)
+{
+	if (!priv->irq_db_indices)
+		return;
+
+	dma_free_coherent(&priv->pdev->dev, priv->num_ntfy_blks *
+			  sizeof(*priv->irq_db_indices),
+			  priv->irq_db_indices, priv->irq_db_indices_bus);
+	priv->irq_db_indices = NULL;
+}
+

[ ... ]

Quoted 32 lines
drivers/net/ethernet/google/gve/gve_main.c +4 -4
@@ -528,13 +533,14 @@ static void gve_teardown_notify_blocks(struct gve_priv *priv)
 
 	for (i = 0; i < priv->num_ntfy_blks; i++) {
 		struct gve_notify_block *block = &priv->ntfy_blocks[i];
+		int msix_idx = gve_ntfy_to_msix_idx(priv, i);
 
 		if (!block->irq_requested)
 			continue;
 
-		irq_set_affinity_hint(priv->msix_vectors[i].vector,
+		irq_set_affinity_hint(priv->msix_vectors[msix_idx].vector,
 				      NULL);
-		free_irq(priv->msix_vectors[i].vector, block);
+		free_irq(priv->msix_vectors[msix_idx].vector, block);
 		block->irq = 0;
 		block->irq_requested = false;
 	}
@@ -563,12 +569,11 @@ static int gve_setup_notify_blocks(struct gve_priv *priv)
 	}
 	priv->mgmt_irq_requested = true;
 
-	/* Setup the other blocks - the first n-1 vectors */
 	node_mask = gve_get_node_mask(priv);
 	cur_cpu = cpumask_first(node_mask);
 	for (i = 0; i < priv->num_ntfy_blks; i++) {
 		struct gve_notify_block *block = &priv->ntfy_blocks[i];
-		int msix_idx = i;
+		int msix_idx = gve_ntfy_to_msix_idx(priv, i);
 
 		snprintf(block->name, sizeof(block->name), "gve-ntfy-blk%d@pci:%s",
 			 i, pci_name(priv->pdev));

drivers/net/ethernet/google/gve/gve_main.c static int gve_setup_notify_blocks(struct gve_priv *priv) · line 586

Quoted 5 lines
drivers/net/ethernet/google/gve/gve_main.c +1 -1
@@ -578,14 +583,13 @@ static int gve_setup_notify_blocks(struct gve_priv *priv)
 				  IRQF_NO_AUTOEN, block->name, block);
 		if (err) {
 			dev_err(&priv->pdev->dev,
-				"Failed to receive msix vector %d\n", i);
+				"Failed to receive msix vector %d\n", msix_idx);

[Severity: Low]
Is this part of the same intended change? Two unrelated bits ride along in this hunk: the "/* Setup the other blocks - the first n-1 vectors */" comment describing the vector layout is dropped, and this error message now prints msix_idx rather than the notify block index i, while block->name a few lines above is still built from i. With gve_ntfy_to_msix_idx() being an identity function the printed value is unchanged today, but the message no longer names the notify block that failed.

Quoted 10 lines
drivers/net/ethernet/google/gve/gve_main.c +0 -1
 			goto abort;
 		}
 		block->irq = priv->msix_vectors[msix_idx].vector;
 		block->irq_requested = true;
 		irq_set_affinity_and_hint(block->irq,
 					  cpumask_of(cur_cpu));
-		block->irq_db_index = &priv->irq_db_indices[i].index;
 
 		cur_cpu = cpumask_next(cur_cpu, node_mask);
 		/* Wrap once CPUs in the node have been exhausted, or when

[ ... ]

Quoted 41 lines
drivers/net/ethernet/google/gve/gve_main.c +9 -7
@@ -611,9 +614,10 @@ static void gve_free_control_plane_resources(struct gve_priv *priv)
 	kvfree(priv->ptype_lut_dqo);
 	priv->ptype_lut_dqo = NULL;
 
-	gve_free_stats_report(priv);
-	gve_free_notify_blocks(priv);
+	gve_free_irq_db_indices(priv);
 	gve_free_counter_array(priv);
+	gve_free_notify_blocks(priv);
+	gve_free_stats_report(priv);
 	gve_free_rss_config_cache(priv);
 	gve_free_flow_rule_caches(priv);
 }
@@ -626,15 +630,18 @@ static int gve_alloc_control_plane_resources(struct gve_priv *priv)
 	if (err)
 		return err;
 	err = gve_alloc_rss_config_cache(priv);
-	if (err)
-		goto abort;
-	err = gve_alloc_counter_array(priv);
 	if (err)
 		goto abort;
 	err = gve_alloc_notify_blocks(priv);
 	if (err)
 		goto abort;
 	err = gve_alloc_stats_report(priv);
+	if (err)
+		goto abort;
+	err = gve_alloc_counter_array(priv);
+	if (err)
+		goto abort;
+	err = gve_alloc_irq_db_indices(priv);
 	if (err)
 		goto abort;
 
@@ -664,15 +671,9 @@ static int gve_setup_control_plane_resources(struct gve_priv *priv)
 	const struct gve_ctrl_ops *ops = priv->ctrl_ops;
 	int err;
 
-	err = gve_adminq_configure_device_resources(priv,
-						    priv->counter_array_bus,

drivers/net/ethernet/google/gve/gve_main.c static int gve_setup_control_plane_resources(struct gve_priv *priv) · line 676

Quoted 10 lines
drivers/net/ethernet/google/gve/gve_main.c +3 -7
-						    priv->num_event_counters,
-						    priv->irq_db_indices_bus,
-						    priv->num_ntfy_blks);
-	if (unlikely(err)) {
-		dev_err(&priv->pdev->dev,
-			"could not setup device_resources: err=%d\n", err);
-		err = -ENXIO;
+	err = ops->request_db_info(priv);
+	if (err) {
+		dev_err(&priv->pdev->dev, "Failed to get db info");

[Severity: Low]
Is the missing '\n' here intentional? Without it the message stays in the printk continuation buffer and the next unrelated kernel message can end up spliced onto the same line.

The new text also drops the error code that the removed message carried ("could not setup device_resources: err=%d\n"), and duplicates the log that gve_adminq_request_db_info() already emits for the same failure:

	if (unlikely(err)) {
		dev_err(&priv->pdev->dev,
			"could not setup device_resources: err=%d\n", err);
		return -ENXIO;
	}

Would dropping this dev_err(), or adding '\n' plus err=%d, be preferable?

Quoted 37 lines
drivers/net/ethernet/google/gve/gve_main.c +4 -9
 		return err;
 	}
 
@@ -681,7 +682,7 @@ static int gve_setup_control_plane_resources(struct gve_priv *priv)
 		if (err) {
 			dev_err(&priv->pdev->dev,
 				"Failed to get ptype map: err=%d\n", err);
-			goto deconfigure_device;
+			goto release_db_resources;
 		}
 	}
 
@@ -711,8 +712,8 @@ static int gve_setup_control_plane_resources(struct gve_priv *priv)
 
 teardown_clock:
 	gve_teardown_clock(priv);
-deconfigure_device:
-	gve_adminq_deconfigure_device_resources(priv);
+release_db_resources:
+	ops->release_db_resources(priv);
 	return err;
 }
 
@@ -745,12 +746,7 @@ static void gve_teardown_control_plane_resources(struct gve_priv *priv)
 			dev_err(&priv->pdev->dev,
 				"Failed to detach stats report: err=%d\n", err);
 		gve_teardown_clock(priv);
-
-		err = gve_adminq_deconfigure_device_resources(priv);
-		if (err)
-			dev_err(&priv->pdev->dev,
-				"Could not deconfigure device resources: err=%d\n",
-				err);
+		ops->release_db_resources(priv);
 	}
 
 	gve_clear_device_resources_ok(priv);

[ ... ]

Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260903215606.31633-1-hramamurthy%40google.com
#23 lore raw

Re: [PATCH net-next v5 11/12] gve: add ctrl ops to for queue operations

In reply to Harshitha Ramamurthy
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Critical: 0 · High: 0 · Medium: 0 · Low: 2

- [Low] Unrelated, undocumented interface change: the patch drops the const qualifier from the first parameter of the inline helper…
- [Low] Commit message defects that will be permanently recorded in git
history: the subject line reads 'gve: add ctrl ops to for queue…

--

gve: add ctrl ops to for queue operations

This adds create_queues and destroy_queues control ops to struct gve_ctrl_ops, moves the existing per-queue create/destroy loops and their logging into gve_adminq_create_queues() and gve_adminq_destroy_queues(), and makes gve_create_rings()/gve_destroy_rings() call through the new ops.

Quoted 6 lines

gve: add ctrl ops to for queue operations

Add the next few control ops to

- create queues
- destroy queues

[Severity: Low]
This isn't a bug, but the subject line has a stray "to": "add ctrl ops to for queue operations" reads better as "add ctrl ops for queue operations".

The body sentence "Add the next few control ops to" also ends without an object before the bullet list. Should it read something like "Add the next few control ops to:"?

[ ... ]

drivers/net/ethernet/google/gve/gve_dqo.h void gve_rx_write_doorbell_dqo(const struct gve_priv *priv, int queue_idx); · line 72

Quoted 13 lines
drivers/net/ethernet/google/gve/gve_dqo.h +1 -1
index 5871f773f0c70..ce402020dff6a 100644
@@ -66,7 +66,7 @@ void gve_rx_write_doorbell_dqo(const struct gve_priv *priv, int queue_idx);
 void gve_xdp_tx_flush_dqo(struct gve_priv *priv, u32 xdp_qid);
 
 static inline void
-gve_tx_put_doorbell_dqo(const struct gve_priv *priv,
+gve_tx_put_doorbell_dqo(struct gve_priv *priv,
 			const struct gve_queue_resources *q_resources, u32 val)
 {
 	u64 index;

[Severity: Low]
What motivates dropping const from priv in gve_tx_put_doorbell_dqo()? The commit message says the change is "just moving existing code into ops, no functional change", and this hunk isn't mentioned.

The body is unchanged and only reads from priv:

	index = be32_to_cpu(q_resources->db_index);
	iowrite32(val, &priv->db_bar2[index]);

All callers in gve_tx_dqo.c (gve_xdp_tx_flush_dqo(), gve_tx_dqo(), gve_xsk_tx_dqo() and gve_xdp_xmit_dqo()) already pass a non-const struct gve_priv *, and the signature is still the same at the tip of the series, so nothing later in the series appears to need a mutable priv here.

It also leaves the neighbouring helpers in the same header inconsistent, since they keep the const qualifier:

void gve_rx_write_doorbell_dqo(const struct gve_priv *priv, int queue_idx);

static inline void
gve_write_irq_doorbell_dqo(const struct gve_priv *priv,
const struct gve_notify_block *block, u32 val)

Could this hunk be dropped, or the reason for it be spelled out in the changelog?

[ ... ]

Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260903215606.31633-1-hramamurthy%40google.com
#26 lore raw

Re: [PATCH net-next v5 12/12] gve: add link status/speed ctrl ops

In reply to Harshitha Ramamurthy
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Critical: 0 · High: 0 · Medium: 0 · Low: 1

- [Low] Unrelated whitespace-only churn bundled into the functional hunk of gve_get_link_ksettings().

--

gve: add link status/speed ctrl ops

This converts the gve link status check into a control plane op and adds an AQ-mode implementation that reads the device status register into priv->link_up. It also adds a report_link_speed op that wraps gve_adminq_report_link_speed().

Quoted 6 lines
drivers/net/ethernet/google/gve/gve_ethtool.c +0 -0
index dd1c44fedc771..a3220c6514382 100644
@@ -749,12 +749,11 @@ static int gve_get_link_ksettings(struct net_device *netdev,
 	int err = 0;

drivers/net/ethernet/google/gve/gve_ethtool.c static int gve_get_link_ksettings(struct net_device *netdev, · line 757

Quoted 10 lines
drivers/net/ethernet/google/gve/gve_ethtool.c +1 -2
 
 	if (priv->link_speed == 0)
-		err = gve_adminq_report_link_speed(priv);
+		err = priv->ctrl_ops->report_link_speed(priv);
 
 	cmd->base.speed = priv->link_speed;
 
 	cmd->base.duplex = DUPLEX_FULL;
-
 	return err;

[Severity: Low]
This isn't a bug, but is the removal of the blank line between cmd->base.duplex = DUPLEX_FULL; and return err; in gve_get_link_ksettings() intentional?

The only functional change described for gve_ethtool.c is swapping gve_adminq_report_link_speed(priv) for priv->ctrl_ops->report_link_speed(priv), and neither the commit message nor the v3 changelog mentions a whitespace change here. Could that blank line be left alone to keep the hunk limited to the ctrl op conversion?

Quoted 2 lines
drivers/net/ethernet/google/gve/gve_ethtool.c +0 -0
 }
 

[ ... ]

Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260903215606.31633-1-hramamurthy%40google.com
maintainer
#27 lore raw
In reply to Harshitha Ramamurthy
Quoted 17 lines · Harshitha Ramamurthy

This series is preparing the driver for the addition of a new control plane mode(MailboxQ) by commonizing and reusing as much code as possible. MailboxQ is a new control plane infrastructure which uses mailbox queues. This is a new control plane to communicate with the device when the driver is running on bare-metal instances as well as newer versions of the device.

This series contains 2 main changes to the gve driver's existing control plane(AdminQ):
1) refactor some initialization/teardown path methods to make it work for both control planes.
2) add gve_ctrl_ops structure to the driver for various control plane operations

The refactors are mainly around the init, reset and recover paths so that functionalities could be moved into the control ops like 'set_num_queues', 'set_num_ntfy_blks' etc.

Quoted 7 lines

This patch series only sets the control ops for AdminQ mode. This is intended as a preparation for adding MailboxQ mode in upcoming series which will add the new control plane infrastructure and then introduce the corresponding control ops for MailboxQ mode.

The entire list of future patches can be found here for reference:
https://github.com/hramamurthy12/linux/commits/gve-mailbox-queues/

Imho the 'medium' severity issues raised by clashiko on patches 1 should be addressed in this same series.

Please note that you are supposed to act on sashiko reviews, see commit c82ff94592fb68f529afe63ca7f5ddb7dae4ba83. Lacking such feedback, I'll tend to err on the safe side - i.e. requesting a new revision.

/P

author maintainer
#28 lore raw
Quoted 24 lines · Paolo Abeni
Quoted 22 lines · Harshitha Ramamurthy

This series is preparing the driver for the addition of a new control plane mode(MailboxQ) by commonizing and reusing as much code as possible. MailboxQ is a new control plane infrastructure which uses mailbox queues. This is a new control plane to communicate with the device when the driver is running on bare-metal instances as well as newer versions of the device.

This series contains 2 main changes to the gve driver's existing control plane(AdminQ):
1) refactor some initialization/teardown path methods to make it work for both control planes.
2) add gve_ctrl_ops structure to the driver for various control plane operations

The refactors are mainly around the init, reset and recover paths so that functionalities could be moved into the control ops like 'set_num_queues', 'set_num_ntfy_blks' etc.

This patch series only sets the control ops for AdminQ mode. This is intended as a preparation for adding MailboxQ mode in upcoming series which will add the new control plane infrastructure and then introduce the corresponding control ops for MailboxQ mode.

Quoted 5 lines
Quoted 2 lines

The entire list of future patches can be found here for reference:
https://github.com/hramamurthy12/linux/commits/gve-mailbox-queues/

Imho the 'medium' severity issues raised by clashiko on patches 1 should be addressed in this same series.

Will fix in v6.

Quoted 3 lines

Please note that you are supposed to act on sashiko reviews, see commit c82ff94592fb68f529afe63ca7f5ddb7dae4ba83. Lacking such feedback, I'll tend to err on the safe side - i.e. requesting a new revision.

Acknowledged.

Thanks,
Harshitha

Quoted 3 lines

/P