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, jordanrhee@google.com, willemb@google.com,
nktgrg@google.com, maolson@google.com, thostet@google.com,
jacob.e.keller@intel.com, przemyslaw.kitszel@intel.com,
debarghyak@google.com, kees@kernel.org, bpf@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH net-next v4 03/15] gve: add a few helper functions to set device properties
Date: Fri, 14 Aug 2026 02:13:53 +0000 [thread overview]
Message-ID: <20260814021406.3044324-4-hramamurthy@google.com> (raw)
In-Reply-To: <20260814021406.3044324-1-hramamurthy@google.com>
For the mailbox ABI, device properties will come from a different
source compared to the AdminQ mode. To accommodate the new source
when the mailbox ABI is added, add a few helper functions to set a
few device properties. Those functions are:
- gve_set_queue_properties() to set no. of pages for QPL mode and
number of queues in general
- gve_set_mtu()
- gve_set_mac()
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>
---
v4: move mac to a variable to reduce diff for next patch
drivers/net/ethernet/google/gve/gve_adminq.c | 38 +++------------
drivers/net/ethernet/google/gve/gve_adminq.h | 7 ++-
drivers/net/ethernet/google/gve/gve_main.c | 49 ++++++++++++++++++++
3 files changed, 62 insertions(+), 32 deletions(-)
diff --git a/drivers/net/ethernet/google/gve/gve_adminq.c b/drivers/net/ethernet/google/gve/gve_adminq.c
index 7e242a0c8edc..8156c6f8c3b0 100644
--- a/drivers/net/ethernet/google/gve/gve_adminq.c
+++ b/drivers/net/ethernet/google/gve/gve_adminq.c
@@ -920,19 +920,6 @@ int gve_adminq_destroy_rx_queues(struct gve_priv *priv, u32 num_queues)
return err;
}
-static void gve_set_default_desc_cnt(struct gve_priv *priv,
- const struct gve_device_descriptor *descriptor)
-{
- priv->tx_desc_cnt = be16_to_cpu(descriptor->tx_queue_entries);
- priv->rx_desc_cnt = be16_to_cpu(descriptor->rx_queue_entries);
-
- /* set default ranges */
- priv->max_tx_desc_cnt = priv->tx_desc_cnt;
- priv->max_rx_desc_cnt = priv->rx_desc_cnt;
- priv->min_tx_desc_cnt = priv->tx_desc_cnt;
- priv->min_rx_desc_cnt = priv->rx_desc_cnt;
-}
-
static void gve_set_default_rss_sizes(struct gve_priv *priv)
{
if (!gve_is_gqi(priv)) {
@@ -1049,8 +1036,6 @@ int gve_adminq_describe_device(struct gve_priv *priv)
union gve_adminq_command cmd;
dma_addr_t descriptor_bus;
int err = 0;
- u8 *mac;
- u16 mtu;
memset(&cmd, 0, sizeof(cmd));
descriptor = dma_pool_alloc(priv->adminq_pool, GFP_KERNEL,
@@ -1112,26 +1097,17 @@ int gve_adminq_describe_device(struct gve_priv *priv)
"Driver is running with GQI QPL queue format.\n");
}
- /* set default descriptor counts */
- gve_set_default_desc_cnt(priv, descriptor);
-
gve_set_default_rss_sizes(priv);
- priv->max_registered_pages =
- be64_to_cpu(descriptor->max_registered_pages);
- mtu = be16_to_cpu(descriptor->mtu);
- if (mtu < ETH_MIN_MTU) {
- dev_err(&priv->pdev->dev, "MTU %d below minimum MTU\n", mtu);
- err = -EINVAL;
+ err = gve_set_mtu(priv, descriptor);
+ if (err)
goto free_device_descriptor;
- }
- priv->dev->max_mtu = mtu;
+
priv->num_event_counters = be16_to_cpu(descriptor->counters);
- eth_hw_addr_set(priv->dev, descriptor->mac);
- mac = descriptor->mac;
- dev_info(&priv->pdev->dev, "MAC addr: %pM\n", mac);
- 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_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,
diff --git a/drivers/net/ethernet/google/gve/gve_adminq.h b/drivers/net/ethernet/google/gve/gve_adminq.h
index 82b52424a63f..68c63ce75505 100644
--- a/drivers/net/ethernet/google/gve/gve_adminq.h
+++ b/drivers/net/ethernet/google/gve/gve_adminq.h
@@ -658,5 +658,10 @@ 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 */
diff --git a/drivers/net/ethernet/google/gve/gve_main.c b/drivers/net/ethernet/google/gve/gve_main.c
index 5ba534beb40f..dc6c2d08540f 100644
--- a/drivers/net/ethernet/google/gve/gve_main.c
+++ b/drivers/net/ethernet/google/gve/gve_main.c
@@ -2398,6 +2398,55 @@ static const struct xdp_metadata_ops gve_xdp_metadata_ops = {
.xmo_rx_timestamp = gve_xdp_rx_timestamp,
};
+static void gve_set_default_desc_cnt(struct gve_priv *priv,
+ const struct gve_device_descriptor *descriptor)
+{
+ priv->tx_desc_cnt = be16_to_cpu(descriptor->tx_queue_entries);
+ priv->rx_desc_cnt = be16_to_cpu(descriptor->rx_queue_entries);
+
+ /* set default ranges */
+ priv->max_tx_desc_cnt = priv->tx_desc_cnt;
+ priv->max_rx_desc_cnt = priv->rx_desc_cnt;
+ priv->min_tx_desc_cnt = priv->tx_desc_cnt;
+ priv->min_rx_desc_cnt = priv->rx_desc_cnt;
+}
+
+void gve_set_queue_properties(struct gve_priv *priv,
+ struct gve_device_descriptor *descriptor)
+{
+ /* set default descriptor counts */
+ gve_set_default_desc_cnt(priv, descriptor);
+
+ 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);
+}
+
+int gve_set_mtu(struct gve_priv *priv,
+ struct gve_device_descriptor *descriptor)
+{
+ u16 mtu;
+
+ mtu = be16_to_cpu(descriptor->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;
+
+ return 0;
+}
+
+void gve_set_mac(struct gve_priv *priv,
+ struct gve_device_descriptor *descriptor)
+{
+ u8 *mac;
+
+ mac = descriptor->mac;
+ eth_hw_addr_set(priv->dev, mac);
+ dev_info(&priv->pdev->dev, "MAC addr: %pM\n", mac);
+}
+
static int gve_init_priv(struct gve_priv *priv, bool skip_describe_device)
{
int err;
--
2.55.0.691.gc56d675ccc-goog
next prev parent reply other threads:[~2026-08-14 2:14 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-14 2:13 [PATCH net-next v4 00/15] gve: AdminQ mode related refactors Harshitha Ramamurthy
2026-08-14 2:13 ` [PATCH net-next v4 01/15] gve: don't pass in unused parameter to gve_adminq_free Harshitha Ramamurthy
2026-08-15 2:14 ` sashiko-bot
2026-08-14 2:13 ` [PATCH net-next v4 02/15] gve: refactor initialization with helper functions Harshitha Ramamurthy
2026-08-15 2:14 ` sashiko-bot
2026-08-14 2:13 ` Harshitha Ramamurthy [this message]
2026-08-14 2:13 ` [PATCH net-next v4 04/15] gve: add struct gve_device_info to hold device properties Harshitha Ramamurthy
2026-08-15 2:14 ` sashiko-bot
2026-08-14 2:13 ` [PATCH net-next v4 05/15] gve: introduce control plane operations structure Harshitha Ramamurthy
2026-08-15 2:14 ` sashiko-bot
2026-08-14 2:13 ` [PATCH net-next v4 06/15] gve: introduce ctrl ops to set vectors and Qs Harshitha Ramamurthy
2026-08-15 2:14 ` sashiko-bot
2026-08-14 2:13 ` [PATCH net-next v4 07/15] gve: introduce gve_adminq_get_device_properties() Harshitha Ramamurthy
2026-08-14 2:13 ` [PATCH net-next v4 08/15] gve: refactor gve_init_priv for reset path Harshitha Ramamurthy
2026-08-15 2:14 ` sashiko-bot
2026-08-14 2:13 ` [PATCH net-next v4 09/15] gve: simplify reset logic Harshitha Ramamurthy
2026-08-15 2:14 ` sashiko-bot
2026-08-14 2:14 ` [PATCH net-next v4 10/15] gve: add gve_ctrl_ops for gve initialization/teardown sequences Harshitha Ramamurthy
2026-08-14 2:14 ` [PATCH net-next v4 11/15] gve: split up notify block allocation and setup paths Harshitha Ramamurthy
2026-08-14 2:14 ` [PATCH net-next v4 12/15] gve: introduce new methods to handle IRQ doorbells Harshitha Ramamurthy
2026-08-14 2:14 ` [PATCH net-next v4 13/15] gve: setup and teardown management interrupts Harshitha Ramamurthy
2026-08-14 2:14 ` [PATCH net-next v4 14/15] gve: add ctrl ops to for queue operations Harshitha Ramamurthy
2026-08-15 2:14 ` sashiko-bot
2026-08-14 2:14 ` [PATCH net-next v4 15/15] gve: add link status/speed ctrl ops Harshitha Ramamurthy
2026-08-15 2:14 ` sashiko-bot
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=20260814021406.3044324-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=debarghyak@google.com \
--cc=edumazet@google.com \
--cc=hawk@kernel.org \
--cc=jacob.e.keller@intel.com \
--cc=john.fastabend@gmail.com \
--cc=jordanrhee@google.com \
--cc=joshwash@google.com \
--cc=kees@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maolson@google.com \
--cc=netdev@vger.kernel.org \
--cc=nktgrg@google.com \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=sdf@fomichev.me \
--cc=thostet@google.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.