From: Harshitha Ramamurthy <hramamurthy@google.com>
To: netdev@vger.kernel.org
Cc: joshwash@google.com, hramamurthy@google.com,
andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, ast@kernel.org,
daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com,
sdf@fomichev.me, willemb@google.com, jordanrhee@google.com,
jfraker@google.com, nktgrg@google.com, bpf@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH net-next 12/15] gve: introduce new methods to handle IRQ doorbells
Date: Mon, 1 Jun 2026 17:54:34 +0000 [thread overview]
Message-ID: <20260601175437.3767283-13-hramamurthy@google.com> (raw)
In-Reply-To: <20260601175437.3767283-1-hramamurthy@google.com>
From: Joshua Washington <joshwash@google.com>
Introduce `request_db_info` and `free_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. All behaviors related to the IRQ doorbell
indices 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`.
Reviewed-by: Willem de Bruijn <willemb@google.com>
Reviewed-by: Jordan Rhee <jordanrhee@google.com>
Signed-off-by: Joshua Washington <joshwash@google.com>
Signed-off-by: Harshitha Ramamurthy <hramamurthy@google.com>
---
drivers/net/ethernet/google/gve/gve.h | 12 ++++
drivers/net/ethernet/google/gve/gve_adminq.c | 71 ++++++++++++++++++++
drivers/net/ethernet/google/gve/gve_adminq.h | 2 +
drivers/net/ethernet/google/gve/gve_main.c | 70 +++++--------------
4 files changed, 103 insertions(+), 52 deletions(-)
diff --git a/drivers/net/ethernet/google/gve/gve.h b/drivers/net/ethernet/google/gve/gve.h
index 12591a1fd746..2cc66dfb6098 100644
--- a/drivers/net/ethernet/google/gve/gve.h
+++ b/drivers/net/ethernet/google/gve/gve.h
@@ -836,6 +836,8 @@ 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
+ * @free_db_resources: Free 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)
@@ -846,6 +848,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 (*free_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);
@@ -1172,6 +1176,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 ||
@@ -1384,6 +1393,9 @@ int gve_adjust_queues(struct gve_priv *priv,
struct gve_rx_queue_config new_rx_config,
struct gve_tx_queue_config new_tx_config,
bool reset_rss);
+/* Initialization sequence */
+int gve_alloc_counter_array(struct gve_priv *priv);
+void gve_free_counter_array(struct gve_priv *priv);
/* flow steering rule */
int gve_get_flow_rule_entry(struct gve_priv *priv, struct ethtool_rxnfc *cmd);
int gve_get_flow_rule_ids(struct gve_priv *priv, struct ethtool_rxnfc *cmd, u32 *rule_locs);
diff --git a/drivers/net/ethernet/google/gve/gve_adminq.c b/drivers/net/ethernet/google/gve/gve_adminq.c
index a9752525d974..966b1776ae44 100644
--- a/drivers/net/ethernet/google/gve/gve_adminq.c
+++ b/drivers/net/ethernet/google/gve/gve_adminq.c
@@ -1744,3 +1744,74 @@ void gve_adminq_set_num_queues(struct gve_priv *priv)
device_info->default_rx_queues,
priv->rx_cfg.num_queues);
}
+
+int gve_adminq_request_db_info(struct gve_priv *priv)
+{
+ int err;
+ int i;
+
+ /* Alloc dma addrs needed for shm regions */
+ err = gve_alloc_counter_array(priv);
+ if (err) {
+ dev_err(&priv->pdev->dev,
+ "Failed to alloc db counter array.");
+ return err;
+ }
+
+ 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) {
+ err = -ENOMEM;
+ goto abort_with_counter_array;
+ }
+
+ 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);
+ err = -ENXIO;
+ goto abort_with_irq_db_indices;
+ }
+
+ for (i = 0; i < priv->num_ntfy_blks; i++)
+ priv->ntfy_blocks[i].irq_db_index =
+ &priv->irq_db_indices[i].index;
+ return 0;
+
+abort_with_irq_db_indices:
+ 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;
+abort_with_counter_array:
+ gve_free_counter_array(priv);
+ return err;
+}
+
+void gve_adminq_free_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);
+
+ 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;
+ gve_free_counter_array(priv);
+}
diff --git a/drivers/net/ethernet/google/gve/gve_adminq.h b/drivers/net/ethernet/google/gve/gve_adminq.h
index e783589c5ed6..948bd3b17496 100644
--- a/drivers/net/ethernet/google/gve/gve_adminq.h
+++ b/drivers/net/ethernet/google/gve/gve_adminq.h
@@ -657,5 +657,7 @@ int gve_adminq_map_db_bar(struct gve_priv *priv);
void gve_adminq_unmap_db_bar(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_request_db_info(struct gve_priv *priv);
+void gve_adminq_free_db_resources(struct gve_priv *priv);
#endif /* _GVE_ADMINQ_H */
diff --git a/drivers/net/ethernet/google/gve/gve_main.c b/drivers/net/ethernet/google/gve/gve_main.c
index 98970508ae54..55f48aee125e 100644
--- a/drivers/net/ethernet/google/gve/gve_main.c
+++ b/drivers/net/ethernet/google/gve/gve_main.c
@@ -179,7 +179,7 @@ static void gve_free_rss_config_cache(struct gve_priv *priv)
memset(rss_config, 0, sizeof(*rss_config));
}
-static int gve_alloc_counter_array(struct gve_priv *priv)
+int gve_alloc_counter_array(struct gve_priv *priv)
{
priv->counter_array =
dma_alloc_coherent(&priv->pdev->dev,
@@ -192,7 +192,7 @@ static int gve_alloc_counter_array(struct gve_priv *priv)
return 0;
}
-static void gve_free_counter_array(struct gve_priv *priv)
+void gve_free_counter_array(struct gve_priv *priv)
{
if (!priv->counter_array)
return;
@@ -428,15 +428,6 @@ int gve_napi_poll_dqo(struct napi_struct *napi, int budget)
static void gve_free_notify_blocks(struct gve_priv *priv)
{
pci_disable_msix(priv->pdev);
- if (priv->irq_db_indices) {
- 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;
- }
-
kvfree(priv->ntfy_blocks);
priv->ntfy_blocks = NULL;
kvfree(priv->msix_vectors);
@@ -493,24 +484,14 @@ static int gve_alloc_notify_blocks(struct gve_priv *priv)
priv->rx_cfg.num_queues = priv->rx_cfg.max_queues;
}
- 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) {
- err = -ENOMEM;
- goto abort;
- }
-
priv->ntfy_blocks = kvzalloc(priv->num_ntfy_blks *
sizeof(*priv->ntfy_blocks), GFP_KERNEL);
if (!priv->ntfy_blocks) {
err = -ENOMEM;
goto abort;
}
- return 0;
+ return 0;
abort:
gve_free_notify_blocks(priv);
return err;
@@ -525,13 +506,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;
}
@@ -560,12 +542,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));
@@ -575,14 +556,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);
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
@@ -599,7 +579,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);
@@ -608,9 +587,8 @@ 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_counter_array(priv);
+ gve_free_stats_report(priv);
gve_free_rss_config_cache(priv);
gve_free_flow_rule_caches(priv);
}
@@ -623,9 +601,6 @@ 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);
@@ -661,15 +636,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,
- 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");
return err;
}
@@ -678,7 +647,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 free_db_resources;
}
}
@@ -708,8 +677,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);
+free_db_resources:
+ ops->free_db_resources(priv);
return err;
}
@@ -739,12 +708,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->free_db_resources(priv);
}
gve_clear_device_resources_ok(priv);
@@ -2494,6 +2458,8 @@ static const struct gve_ctrl_ops gve_adminq_ops = {
.reset_flow_rules = gve_adminq_reset_flow_rules,
.setup_stats_report = gve_adminq_report_stats,
.configure_rss = gve_adminq_configure_rss,
+ .request_db_info = gve_adminq_request_db_info,
+ .free_db_resources = gve_adminq_free_db_resources,
};
static int gve_init_priv(struct gve_priv *priv)
--
2.54.0.669.g59709faab0-goog
next prev parent reply other threads:[~2026-06-01 17:54 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-01 17:54 [PATCH net-next 00/15] gve: AdminQ mode related refactors Harshitha Ramamurthy
2026-06-01 17:54 ` [PATCH net-next 01/15] gve: don't pass in unused parameter to gve_adminq_free Harshitha Ramamurthy
2026-06-01 17:54 ` [PATCH net-next 02/15] gve: refactor initialization with helper functions Harshitha Ramamurthy
2026-06-01 17:54 ` [PATCH net-next 03/15] gve: introduce gve_adminq_get_device_properties() Harshitha Ramamurthy
2026-06-01 17:54 ` [PATCH net-next 04/15] gve: add a few helper functions to set device properties Harshitha Ramamurthy
2026-06-01 17:54 ` [PATCH net-next 05/15] gve: add struct gve_device_info to hold " Harshitha Ramamurthy
2026-06-01 17:54 ` [PATCH net-next 06/15] gve: introduce control plane operations structure Harshitha Ramamurthy
2026-06-01 17:54 ` [PATCH net-next 07/15] gve: introduce ctrl ops to set vectors and Qs Harshitha Ramamurthy
2026-06-01 17:54 ` [PATCH net-next 08/15] gve: refactor gve_init_priv for reset path Harshitha Ramamurthy
2026-06-01 17:54 ` [PATCH net-next 09/15] gve: simplify reset logic Harshitha Ramamurthy
2026-06-01 17:54 ` [PATCH net-next 10/15] gve: add gve_ctrl_ops for gve initialization/teardown sequences Harshitha Ramamurthy
2026-06-01 17:54 ` [PATCH net-next 11/15] gve: split up notify block allocation and setup paths Harshitha Ramamurthy
2026-06-01 17:54 ` Harshitha Ramamurthy [this message]
2026-06-01 17:54 ` [PATCH net-next 13/15] gve: setup and teardown management interrupts Harshitha Ramamurthy
2026-06-01 17:54 ` [PATCH net-next 14/15] gve: add ctrl ops to for queue operations Harshitha Ramamurthy
2026-06-01 17:54 ` [PATCH net-next 15/15] gve: add link status/speed ctrl ops Harshitha Ramamurthy
2026-06-01 22:01 ` [PATCH net-next 00/15] gve: AdminQ mode related refactors Harshitha Ramamurthy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260601175437.3767283-13-hramamurthy@google.com \
--to=hramamurthy@google.com \
--cc=andrew+netdev@lunn.ch \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hawk@kernel.org \
--cc=jfraker@google.com \
--cc=john.fastabend@gmail.com \
--cc=jordanrhee@google.com \
--cc=joshwash@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nktgrg@google.com \
--cc=pabeni@redhat.com \
--cc=sdf@fomichev.me \
--cc=willemb@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox