From: Przemek Kitszel <przemyslaw.kitszel@intel.com>
To: Harshitha Ramamurthy <hramamurthy@google.com>, <netdev@vger.kernel.org>
Cc: <joshwash@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>, <debarghyak@google.com>,
<kees@kernel.org>, <bpf@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net-next v3 04/15] gve: add struct gve_device_info to hold device properties
Date: Thu, 6 Aug 2026 09:19:16 +0200 [thread overview]
Message-ID: <6bb3205d-e9b9-4f18-8d8a-5bde4d014084@intel.com> (raw)
In-Reply-To: <20260803184630.3813311-5-hramamurthy@google.com>
On 8/3/26 20:46, Harshitha Ramamurthy wrote:
> 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.
>
> Reviewed-by: Willem de Bruijn <willemb@google.com>
> Reviewed-by: Jordan Rhee <jordanrhee@google.com>
> Signed-off-by: Harshitha Ramamurthy <hramamurthy@google.com>
> ---
> Changes in 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 | 115 +++++++++++--------
> drivers/net/ethernet/google/gve/gve_adminq.h | 6 -
> drivers/net/ethernet/google/gve/gve_main.c | 101 +++++++++++-----
> 4 files changed, 170 insertions(+), 81 deletions(-)
>
> diff --git a/drivers/net/ethernet/google/gve/gve.h b/drivers/net/ethernet/google/gve/gve.h
> index c280ff35ee77..021adb9108df 100644
> --- a/drivers/net/ethernet/google/gve/gve.h
> +++ b/drivers/net/ethernet/google/gve/gve.h
> @@ -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;
> +};
you could save some bytes of the struct size by reordering fields
> +
> 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;
> };
[..]
> -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);
> + 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 = priv->dev->max_mtu;
nit: I would just use `= mtu`
>
> return 0;
> }
>
> -void gve_set_mac(struct gve_priv *priv,
> - struct gve_device_descriptor *descriptor)
> +static void gve_set_mac(struct gve_priv *priv)
> {
> - eth_hw_addr_set(priv->dev, descriptor->mac);
> - dev_info(&priv->pdev->dev, "MAC addr: %pM\n", descriptor->mac);
> + struct gve_device_info *device_info = &priv->device_info;
> +
> + eth_hw_addr_set(priv->dev, device_info->mac);
> + dev_info(&priv->pdev->dev, "MAC addr: %pM\n", device_info->mac);
> +}
whole function is rewritten (in git sense), and it was just added in
previous commit
one way to avoid that is to extract "mac" variable in the prev patch,
and here only update the assignement and function signature
> +
> +static void gve_set_buf_sizes(struct gve_priv *priv)
> +{
> + struct gve_device_info *device_info = &priv->device_info;
> +
> + if (device_info->max_rx_buffer_size > priv->max_rx_buffer_size)
> + priv->max_rx_buffer_size = device_info->max_rx_buffer_size;
> +
> + if (gve_is_dqo(priv) &&
> + priv->max_rx_buffer_size > GVE_DEFAULT_RX_BUFFER_SIZE)
> + priv->rx_cfg.packet_buffer_size = priv->max_rx_buffer_size;
> +
> + if (device_info->header_buf_size)
> + priv->header_buf_size = device_info->header_buf_size;
> }
>
> static int gve_init_priv(struct gve_priv *priv, bool skip_describe_device)
> {
> + struct gve_device_info *device_info = &priv->device_info;
> int err;
>
> /* Set up the adminq */
> @@ -2514,7 +2533,7 @@ static int gve_init_priv(struct gve_priv *priv, bool skip_describe_device)
> if (skip_describe_device)
> goto setup_device;
>
> - priv->queue_format = GVE_QUEUE_FORMAT_UNSPECIFIED;
> + device_info->queue_format = GVE_QUEUE_FORMAT_UNSPECIFIED;
> /* Get the initial information we need from the device */
> err = gve_adminq_describe_device(priv);
> if (err) {
> @@ -2523,6 +2542,8 @@ static int gve_init_priv(struct gve_priv *priv, bool skip_describe_device)
> goto err;
> }
>
> + priv->queue_format = priv->device_info.queue_format;
> +
> err = gve_set_num_ntfy_blks(priv);
> if (err) {
> dev_err(&priv->pdev->dev,
> @@ -2546,12 +2567,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;
> +
> + priv->rss_key_size = device_info->rss_key_size;
> + priv->rss_lut_size = device_info->rss_lut_size;
> + priv->cache_rss_config = device_info->cache_rss_config;
I don't know, especially with your MailboxQ coming next, if following
makes sense, but I wonder why you have to copy whole device info into
priv (or IOW, hold two copies of most params)?
Alternative will be to use variables from device info everywhere,
you could even achieve that without any code changes via struct_group
> +
> priv->numa_node = dev_to_node(&priv->pdev->dev);
> priv->tx_cfg.num_xdp_queues = 0;
> priv->rx_copybreak = GVE_DEFAULT_RX_COPYBREAK;
> priv->ts_config.tx_type = HWTSTAMP_TX_OFF;
> priv->ts_config.rx_filter = HWTSTAMP_FILTER_NONE;
> + priv->nic_timestamp_supported = device_info->nic_timestamp_supported;
>
> setup_device:
> priv->xsk_pools = bitmap_zalloc(priv->rx_cfg.max_queues, GFP_KERNEL);
next prev parent reply other threads:[~2026-08-06 7:19 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-03 18:46 [PATCH net-next v3 00/15] gve: AdminQ mode related refactors Harshitha Ramamurthy
2026-08-03 18:46 ` [PATCH net-next v3 01/15] gve: don't pass in unused parameter to gve_adminq_free Harshitha Ramamurthy
2026-08-03 18:46 ` [PATCH net-next v3 02/15] gve: refactor initialization with helper functions Harshitha Ramamurthy
2026-08-03 18:46 ` [PATCH net-next v3 03/15] gve: add a few helper functions to set device properties Harshitha Ramamurthy
2026-08-03 18:46 ` [PATCH net-next v3 04/15] gve: add struct gve_device_info to hold " Harshitha Ramamurthy
2026-08-06 7:19 ` Przemek Kitszel [this message]
2026-08-07 2:14 ` Harshitha Ramamurthy
2026-08-03 18:46 ` [PATCH net-next v3 05/15] gve: introduce control plane operations structure Harshitha Ramamurthy
2026-08-03 18:46 ` [PATCH net-next v3 06/15] gve: introduce ctrl ops to set vectors and Qs Harshitha Ramamurthy
2026-08-06 7:33 ` Przemek Kitszel
2026-08-07 2:41 ` Harshitha Ramamurthy
2026-08-03 18:46 ` [PATCH net-next v3 07/15] gve: introduce gve_adminq_get_device_properties() Harshitha Ramamurthy
2026-08-03 18:46 ` [PATCH net-next v3 08/15] gve: refactor gve_init_priv for reset path Harshitha Ramamurthy
2026-08-03 18:46 ` [PATCH net-next v3 09/15] gve: simplify reset logic Harshitha Ramamurthy
2026-08-06 1:37 ` Jakub Kicinski
2026-08-07 0:18 ` Joshua Washington
2026-08-03 18:46 ` [PATCH net-next v3 10/15] gve: add gve_ctrl_ops for gve initialization/teardown sequences Harshitha Ramamurthy
2026-08-03 18:46 ` [PATCH net-next v3 11/15] gve: split up notify block allocation and setup paths Harshitha Ramamurthy
2026-08-03 18:46 ` [PATCH net-next v3 12/15] gve: introduce new methods to handle IRQ doorbells Harshitha Ramamurthy
2026-08-03 18:46 ` [PATCH net-next v3 13/15] gve: setup and teardown management interrupts Harshitha Ramamurthy
2026-08-03 18:46 ` [PATCH net-next v3 14/15] gve: add ctrl ops to for queue operations Harshitha Ramamurthy
2026-08-03 18:46 ` [PATCH net-next v3 15/15] gve: add link status/speed ctrl ops 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=6bb3205d-e9b9-4f18-8d8a-5bde4d014084@intel.com \
--to=przemyslaw.kitszel@intel.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=hramamurthy@google.com \
--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=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox