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 03/15] gve: introduce gve_adminq_get_device_properties()
Date: Mon, 1 Jun 2026 17:54:25 +0000 [thread overview]
Message-ID: <20260601175437.3767283-4-hramamurthy@google.com> (raw)
In-Reply-To: <20260601175437.3767283-1-hramamurthy@google.com>
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.
Reviewed-by: Willem de Bruijn <willemb@google.com>
Reviewed-by: Jordan Rhee <jordanrhee@google.com>
Signed-off-by: Harshitha Ramamurthy <hramamurthy@google.com>
---
drivers/net/ethernet/google/gve/gve.h | 2 +
drivers/net/ethernet/google/gve/gve_adminq.c | 66 ++++++++++++++++++--
drivers/net/ethernet/google/gve/gve_adminq.h | 5 +-
drivers/net/ethernet/google/gve/gve_main.c | 59 +----------------
4 files changed, 66 insertions(+), 66 deletions(-)
diff --git a/drivers/net/ethernet/google/gve/gve.h b/drivers/net/ethernet/google/gve/gve.h
index 4de3ce60060e..0980e8ecbda2 100644
--- a/drivers/net/ethernet/google/gve/gve.h
+++ b/drivers/net/ethernet/google/gve/gve.h
@@ -15,6 +15,8 @@
#include <linux/pci.h>
#include <linux/ptp_clock_kernel.h>
#include <linux/u64_stats_sync.h>
+#include <linux/utsname.h>
+#include <linux/version.h>
#include <net/page_pool/helpers.h>
#include <net/xdp.h>
diff --git a/drivers/net/ethernet/google/gve/gve_adminq.c b/drivers/net/ethernet/google/gve/gve_adminq.c
index f3227bb58ced..c102f707e284 100644
--- a/drivers/net/ethernet/google/gve/gve_adminq.c
+++ b/drivers/net/ethernet/google/gve/gve_adminq.c
@@ -1169,6 +1169,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)
{
@@ -1231,20 +1252,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)
diff --git a/drivers/net/ethernet/google/gve/gve_adminq.h b/drivers/net/ethernet/google/gve/gve_adminq.h
index 9fbea0cc6513..107c21b7b047 100644
--- a/drivers/net/ethernet/google/gve/gve_adminq.h
+++ b/drivers/net/ethernet/google/gve/gve_adminq.h
@@ -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);
diff --git a/drivers/net/ethernet/google/gve/gve_main.c b/drivers/net/ethernet/google/gve/gve_main.c
index b9542ef36b29..eb2d768e5881 100644
--- a/drivers/net/ethernet/google/gve/gve_main.c
+++ b/drivers/net/ethernet/google/gve/gve_main.c
@@ -17,7 +17,6 @@
#include <linux/sched.h>
#include <linux/timer.h>
#include <linux/workqueue.h>
-#include <linux/utsname.h>
#include <linux/version.h>
#include <net/netdev_queues.h>
#include <net/sch_generic.h>
@@ -41,49 +40,6 @@ char gve_driver_name[] = "gve";
const char gve_version_str[] = GVE_VERSION;
static const char gve_version_prefix[] = GVE_VERSION_PREFIX;
-static int gve_verify_driver_compatibility(struct gve_priv *priv)
-{
- int err;
- struct gve_driver_info *driver_info;
- dma_addr_t driver_info_bus;
-
- 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));
-
- err = gve_adminq_verify_driver_compatibility(priv,
- sizeof(struct gve_driver_info),
- driver_info_bus);
-
- /* 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;
-}
-
static netdev_features_t gve_features_check(struct sk_buff *skb,
struct net_device *dev,
netdev_features_t features)
@@ -2461,21 +2417,10 @@ static int gve_init_priv(struct gve_priv *priv, bool skip_describe_device)
if (skip_describe_device)
goto setup_device;
- err = gve_verify_driver_compatibility(priv);
- if (err) {
- dev_err(&priv->pdev->dev,
- "Could not verify driver compatibility: err=%d\n", err);
- goto err;
- }
-
- /* Get the initial information we need from the device */
priv->queue_format = GVE_QUEUE_FORMAT_UNSPECIFIED;
- err = gve_adminq_describe_device(priv);
- if (err) {
- dev_err(&priv->pdev->dev,
- "Could not get device information: err=%d\n", err);
+ err = gve_adminq_get_device_properties(priv);
+ if (err)
goto err;
- }
err = gve_set_num_ntfy_blks(priv);
if (err) {
--
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 ` Harshitha Ramamurthy [this message]
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 ` [PATCH net-next 12/15] gve: introduce new methods to handle IRQ doorbells Harshitha Ramamurthy
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-4-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