gve: AdminQ mode related refactors
Subsystems (4)
Harshitha Ramamurthy
maintainerv8 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 v8:
- Patch 6(Sashiko):
- call gve_queues_stop() directly in gve_queues_start() to handle XDP info unregistration
- drop gve_queues_mem_remove() from gve_queues_start() and leave it to the caller; this moves a few function definitions around to avoid forward declarations
- revert the gve_mgmnt_intr() behavior change from v7
- handle the TOCTOU when checking for a pending reset
- record all configurations in priv before sending an AQ command that can result in a reset
- update the commit description regarding teardown-related resets
- Patch 8(Sashiko):
- gate mgmt IRQ and notify block teardown on different conditions
- move gve_teardown_notify_blocks() from gve_reset_device() to gve_teardown_device(), and tear down notify blocks as part of the device reset
- don't set block->irq when tearing down notify blocks; instead guard the disable_irq() call in gve_remove_napi() on whether the IRQ was requested
- v7: https://lore.kernel.org/netdev/[email protected]/
Changes in v7:
- All changes are in patch 6(Sashiko):
- Return IRQ_HANDLED instead of IRQ_NONE in gve_mgmnt_intr()
- disable service task instead of stats report task for gve_probe() error
- cancel stats report in gve_free_stats_report()
- extract gve_teardown_control_plane_resouces() and gve_adminq_free() into new gve_reset_device() to ensure the device reset is triggered before stopping queues
- don't call gve_queues_stop() in the gve_close() error path since the gve_reset() takes care of that.
- v6: https://lore.kernel.org/netdev/[email protected]/
Changes in v6:
- update commit message to be more consistent with code (patch 1,9 Sashiko)
- call out MTU validation change (patch 1, Sashiko)
- A few other Sashiko related fixes (error propagation in patch 2, drop double logging in patch 5, drop unintentional type conversion in patch 11)
- v5: https://lore.kernel.org/netdev/[email protected]/
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 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 | 376 ++++++-- drivers/net/ethernet/google/gve/gve_adminq.h | 30 +- drivers/net/ethernet/google/gve/gve_ethtool.c | 5 +- drivers/net/ethernet/google/gve/gve_flow_rule.c | 15 +- drivers/net/ethernet/google/gve/gve_main.c | 1067 ++++++++++++----------- drivers/net/ethernet/google/gve/gve_utils.c | 4 +- 7 files changed, 972 insertions(+), 612 deletions(-)
Signature · 1 line
2.56.0.rc1.310.g51773c2048-goog
Harshitha Ramamurthy
maintainerPATCH v8 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.
Most of these changes are refactors only, except for one:
with the introduction of the central struct gve_device_info, in AdminQ mode, gve_set_mtu() now also validates the device provided mtu value from jumbo frames device option. This sets up the driver nicely for the MailboxQ mode where both the default and the maximum mtu are provided at once and they are validated in gve_set_mtu().
---
v6:
- update commit message to call out change in device provided MTU validation (Sashiko)
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
@@ -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
@@ -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.56.0.rc1.310.g51773c2048-goog
Harshitha Ramamurthy
maintainerPATCH v8 2/12 gve: introduce control plane operations structure
In reply to Harshitha RamamurthyTo 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.
---
v6:
- plumb through map_db_bar error instead of overwriting it
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 | 34 +++++++++++++++------------- 4 files changed, 52 insertions(+), 16 deletions(-)
drivers/net/ethernet/google/gve/gve.h +11 -0
@@ -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
@@ -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
@@ -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 +18 -16
@@ -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 (®_bar->driver_version);/* Get max queues to alloc etherdev */ max_tx_queues =ioread32be (®_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,25 @@ 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) + 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 +2982,12 @@ abort_with_gve_init: 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 +3003,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.56.0.rc1.310.g51773c2048-goog
Harshitha Ramamurthy
maintainerPATCH v8 3/12 gve: introduce ctrl ops to set vectors and Qs
In reply to Harshitha RamamurthyIntroduce 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
@@ -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
@@ -1592,7 +1592,7 @@ out: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
@@ -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
@@ -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.56.0.rc1.310.g51773c2048-goog
Harshitha Ramamurthy
maintainerPATCH v8 4/12 gve: introduce gve_adminq_get_device_properties()
In reply to Harshitha RamamurthyIntroduce 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 unnecessary __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
@@ -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 @@ free_device_descriptor: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
@@ -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.56.0.rc1.310.g51773c2048-goog
Harshitha Ramamurthy
maintainerPATCH v8 5/12 gve: refactor gve_init_priv for reset path
In reply to Harshitha RamamurthyThe 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.
---
v6:
- drop double logging on err of gve_adminq_get_device_properties()
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 | 143 +++++++++++++++------------ 4 files changed, 92 insertions(+), 67 deletions(-)
drivers/net/ethernet/google/gve/gve.h +2 -0
@@ -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
@@ -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 (®_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
@@ -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 +78 -65
228 lines not on this page · raw message
Signature · 1 line
2.56.0.rc1.310.g51773c2048-goog
Harshitha Ramamurthy
maintainerPATCH v8 6/12 gve: simplify reset logic
In reply to Harshitha RamamurthyFrom: 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 the teardown portion of reset. This is partly covered by removing recursive resets, but the primary goal in this case is to allow the driver to complete teardown in a more direct manner. Before this patch, gve_close() when called as part of gve_shutdown, could end up triggering a hardware reset, then attempt to close again. In such a case, destroying hardware queues would inevitably fail, causing a loop. gve_close() is no longer called directly in gve_reset() breaking any possibility of this loop.
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.
---
v8:
- call gve_queues_stop() directly in gve_queues_start to handle XDP info unregistration
- remove gve_queues_mem_remove() from gve_queues_start(); depend on caller to call instead. This involves moving function definitions around to avoid forward declaration.
- update commit description regarding teardown-related resets
- revert gve_mgmt_intr behavior
- handle TOCTOU when checking for reset
- record all configurations in priv before sending an AQ command that can result in reset
v7:
- Return IRQ_HANDLED instead of IRQ_NONE in gve_mgmnt_intr()
- disable service task instead of stats report task for gve_probe() error
- cancel stats report in gve_free_stats_report()
- extract gve_teardown_control_plane_resouces() and gve_adminq_free() into new function gve_reset_device() to ensure the device reset is triggered before stopping queues
- don't call gve_queues_stop() in the gve_close() error path since the gve_reset() takes care of that.
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 +- drivers/net/ethernet/google/gve/gve_flow_rule.c | 15 +- drivers/net/ethernet/google/gve/gve_main.c | 523 +++++++++++++----------- 6 files changed, 291 insertions(+), 261 deletions(-)
drivers/net/ethernet/google/gve/gve.h +1 -1
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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 @@ out: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 +273 -250
816 lines not on this page · raw message
Signature · 1 line
2.56.0.rc1.310.g51773c2048-goog
Harshitha Ramamurthy
maintainerPATCH v8 7/12 gve: add gve_ctrl_ops for gve initialization/teardown sequences
In reply to Harshitha RamamurthyFrom: 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
@@ -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
@@ -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
@@ -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
@@ -706,7 +706,8 @@ abort: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,
@@ -721,7 +722,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);
@@ -743,12 +744,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 ;
@@ -772,6 +774,7 @@ deconfigure_device:*/ 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 */
@@ -781,11 +784,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,
@@ -1819,6 +1824,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;
@@ -1834,15 +1840,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,
@@ -2483,6 +2491,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.56.0.rc1.310.g51773c2048-goog
Harshitha Ramamurthy
maintainerPATCH v8 8/12 gve: split up notify block allocation and setup paths
In reply to Harshitha RamamurthyFrom: 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.
---
v8:
- gate mgmt irq vs ntfy block teardown on different conditions
- move gve_teardown_notify_blocks() to gve_teardown_device() from gve_reset_device()
- don't set block->irq when tearing down notify blocks
- guard disable_irq() call in gve_remove_napi() on whether the irq was requested
- teardown notify blocks as part of device reset
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 +++++++++++++++------------- drivers/net/ethernet/google/gve/gve_utils.c | 4 +- 3 files changed, 89 insertions(+), 72 deletions(-)
drivers/net/ethernet/google/gve/gve.h +2 -0
@@ -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
233 lines not on this page · raw message
drivers/net/ethernet/google/gve/gve_utils.c +3 -1
@@ -119,6 +119,8 @@ void gve_remove_napi(struct gve_priv *priv, int ntfy_idx) {struct gve_notify_block *block = &priv->ntfy_blocks[ntfy_idx]; -disable_irq (block->irq); +if (block->irq_requested) +disable_irq (block->irq); +netif_napi_del_locked (&block->napi); }
Signature · 1 line
2.56.0.rc1.310.g51773c2048-goog
Harshitha Ramamurthy
maintainerPATCH v8 9/12 gve: introduce new methods to handle IRQ doorbells
In reply to Harshitha RamamurthyFrom: 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. 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.
---
v6:
- update commit message
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 | 100 +++++++++++++-------------- 4 files changed, 98 insertions(+), 51 deletions(-)
drivers/net/ethernet/google/gve/gve.h +10 -0
@@ -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
@@ -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
@@ -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 +49 -51
219 lines not on this page · raw message
Signature · 1 line
2.56.0.rc1.310.g51773c2048-goog
Harshitha Ramamurthy
maintainerPATCH v8 10/12 gve: setup and teardown management interrupts
In reply to Harshitha RamamurthyFrom: 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 | 32 ++++++++++++++++++++++++++++ drivers/net/ethernet/google/gve/gve_adminq.h | 2 ++ drivers/net/ethernet/google/gve/gve_main.c | 26 +++++++--------------- 4 files changed, 46 insertions(+), 18 deletions(-)
drivers/net/ethernet/google/gve/gve.h +4 -0
@@ -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 +32 -0
@@ -1755,3 +1755,35 @@ 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; + +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
@@ -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 +8 -18
@@ -291,14 +291,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; - -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;
@@ -523,12 +515,10 @@ abort:static void gve_teardown_notify_blocks (struct gve_priv *priv) { +const struct gve_ctrl_ops *ops = priv->ctrl_ops;int i; -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);if (!priv->ntfy_blocks)return ;
@@ -549,21 +539,19 @@ static void gve_teardown_notify_blocks(struct gve_priv *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 */ -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); + 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);
@@ -2505,6 +2493,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.56.0.rc1.310.g51773c2048-goog
Harshitha Ramamurthy
maintainerPATCH v8 11/12 gve: add ctrl ops for queue operations
In reply to Harshitha RamamurthyAdd the next few control ops to
- create queues
- destroy queues
These changes are just moving existing code into ops, no functional change.
---
v6:
- drop unintentional change of gve_priv from const to non-const
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_main.c | 43 ++++-------------------- 4 files changed, 63 insertions(+), 36 deletions(-)
drivers/net/ethernet/google/gve/gve.h +4 -0
@@ -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
@@ -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_main.c +7 -36
72 lines not on this page · raw message
Signature · 1 line
2.56.0.rc1.310.g51773c2048-goog
Harshitha Ramamurthy
maintainerPATCH v8 12/12 gve: add link status/speed ctrl ops
In reply to Harshitha RamamurthyFrom: 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
@@ -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
@@ -1837,3 +1837,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
@@ -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
@@ -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
@@ -1508,15 +1508,18 @@ reset: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 {
@@ -1543,7 +1546,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)) {
@@ -1570,8 +1572,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; }
@@ -2002,11 +2004,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,
@@ -2334,12 +2336,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)
@@ -2466,6 +2470,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.56.0.rc1.310.g51773c2048-goog
[email protected]
AI reviewRe: [PATCH net-next v8 01/12] gve: add struct gve_device_info to hold device properties
In reply to Harshitha RamamurthyThank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you…
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit message says the only functional change is that gve_set_mtu() "now also validates" the jumbo-frames MTU.
- [Low] The refactor leaves unused state and a stale comment behind.
--
gve: add struct gve_device_info to hold device properties
This commit adds struct gve_device_info to hold the properties negotiated with the device, in preparation for an upcoming MailboxQ mode. gve_adminq_describe_device() now fills this structure. gve_init_priv() then copies the values into gve_priv through gve_set_mtu(), gve_set_mac(), gve_set_queue_properties() and gve_set_buf_sizes().
Quoted 5 lines
drivers/net/ethernet/google/gve/gve.h +0
-0
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]
This isn't a bug, but gve_fill_device_info() never fills in max_tx_queues or max_rx_queues, and nothing reads them.
gve_set_num_queues() still takes its maximums from priv->tx_cfg.max_queues and priv->rx_cfg.max_queues, which gve_probe() reads from the register BAR.
Should these fields be dropped until MailboxQ needs them, or should gve_set_num_queues() use them?
Along the same lines, struct gve_priv still declares:
bool default_min_ring_size; ... u16 default_num_queues; /* default num queues to set up */
All readers and writers now go through priv->device_info, so these two fields are always zero. Can they be removed?
The comment in gve_probe() also still names gve_adminq_describe_device() as a place where features may be set:
/* Set default and supported features. * * Features might be set in other locations as well (such as ...
This patch moved the last such write (NETIF_F_NTUPLE) into gve_init_priv().
All three of these still seem to be present at the end of the series.
[ ... ]
Quoted 4 lines
drivers/net/ethernet/google/gve/gve_adminq.c +0
-0
[ ... ]
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 4 lines
drivers/net/ethernet/google/gve/gve_main.c +0
-0
[ ... ]
Quoted 18 lines
drivers/net/ethernet/google/gve/gve_main.c +4
-3-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 = mtu;return 0 ; }
[ ... ]
Quoted 4 lines
drivers/net/ethernet/google/gve/gve_main.c +4
-0+static void gve_set_buf_sizes (struct gve_priv *priv) +{ +struct gve_device_info *device_info = &priv->device_info; +
drivers/net/ethernet/google/gve/gve_main.c static const struct xdp_metadata_ops gve_xdp_metadata_ops = { · line 2461
Quoted 10 lines
drivers/net/ethernet/google/gve/gve_main.c +10
-0+if (device_info->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; +}
[Severity: Low]
The commit message says:
Most of these changes are refactors only, except for one:
with the introduction of the central struct gve_device_info, in AdminQ mode, gve_set_mtu() now also validates the device provided mtu value from jumbo frames device option.
Does this cover all the behaviour changes in the patch?
Before this patch, gve_adminq_describe_device() called gve_set_mtu(priv, descriptor) before gve_enable_supported_features(). That checked descriptor->mtu against ETH_MIN_MTU. The jumbo frames max_mtu then overwrote dev->max_mtu without a check.
After this patch, gve_fill_device_info() stores descriptor->mtu in device_info->max_mtu, and gve_enable_supported_features() overwrites it with the jumbo value. gve_set_mtu() then checks only that final value.
So when the jumbo frames option is present, descriptor->mtu is not checked at all. A device that reports descriptor->mtu below 68 together with a valid jumbo max_mtu used to fail probe, and now it probes. Isn't the check moved to a different value, rather than added?
There is a second change in gve_set_buf_sizes(). It now copies max_rx_buffer_size and header_buf_size only when they are non-zero.
Before, a BUFFER_SIZES option that reported packet_buffer_size == 0 set priv->max_rx_buffer_size to 0. Now the field keeps the GVE_DEFAULT_RX_BUFFER_SIZE value set in gve_probe(). That changes the result of checks like this one in gve_set_rx_buf_len_config():
if (!gve_is_dqo(priv) || priv->max_rx_buffer_size < SZ_4K) {The v5 changelog note "honor device provided rx buffer size correctly" is below the --- line, so it won't end up in the git history.
Could the commit message describe both of these changes?
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260924185316.2831077-1-hramamurthy%40google.com
[email protected]
AI reviewRe: [PATCH net-next v8 05/12] gve: refactor gve_init_priv for reset path
In reply to Harshitha RamamurthyThank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you…
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit message says "These changes are only code movement, no functional change".
- [Low] gve_write_version() is renamed to gve_adminq_write_version(), putting it in the gve_adminq_* namespace.
Pre-existing issues:
- [Medium] Existing AdminQ leak, fixed later in this series by "gve:
simplify reset logic".
- [Medium] Existing teardown ordering issue, fixed later in this series.
--
gve: refactor gve_init_priv for reset path
This commit moves AdminQ setup and device property negotiation out of gve_init_priv(). As a result, gve_init_priv() and gve_adminq_get_device_properties() run only once, from gve_probe(). A new gve_adminq_init() writes the driver version and allocates the AdminQ, a new gve_setup_device() handles per-reset device setup, and gve_reset_recovery() calls these helpers directly.
Quoted 1 line
These changes are only code movement, no functional change.
[Severity: Low]
Is this accurate? The patch seems to change behaviour in a few places.
The driver version is now written from gve_adminq_init():
int gve_adminq_init(struct gve_priv *priv)
{
...
gve_adminq_write_version(®_bar->driver_version);
return gve_adminq_alloc(priv);
}gve_reset_recovery() also calls gve_adminq_init(), so the version string is now written to the device on every reset and resume. Before this patch, gve_write_version() was called only once, from gve_probe().
The order in gve_probe() also changes. The version write now comes after the max_tx_queues/max_rx_queues register reads and after alloc_etherdev_mqs(). AdminQ allocation, driver compatibility verification and describe device now run before ctrl_ops is set, before map_db_bar(), before the workqueue is allocated, and before gve_set_probe_in_progress().
In gve_reset_recovery(), a gve_open() failure is now handled as:
if (was_up) {
err = gve_open(priv->dev);
if (err)
return err;
}It no longer does goto err, so the "Reset failed! !!! DISABLING ALL QUEUES !!!" message and the gve_turndown() call are skipped.
Callers such as gve_handle_reset() ignore the return value of gve_reset(). At this commit, then, the reset code does not log a reset that fails during queue bring-up.
The only related note is the v3 changelog below the --- line, and that text is dropped when the patch is applied.
Later in the series, "gve: simplify reset logic" replaces gve_reset_recovery() with gve_recover(), which logs "Recover failed!" when queue setup fails, so the missing log is fixed there. The version rewrite and the probe reordering are still present at the end of the series.
Could the commit message describe these changes rather than saying there is no functional change?
drivers/net/ethernet/google/gve/gve.h static inline bool gve_is_clock_enabled(struct gve_priv *priv) · line 1257
Quoted 10 lines
drivers/net/ethernet/google/gve/gve.h +2
-0@@ -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); +
[Severity: Low]
This isn't a bug, but the naming and placement here don't quite match. The function now has a gve_adminq_* name, but it is still defined in gve_main.c. Its prototype goes in gve.h rather than gve_adminq.h, which is where gve_adminq_init() and the other gve_adminq_* functions are declared.
The only caller is gve_adminq_init() in gve_adminq.c, so the adminq code now calls back into gve_main.c. This is probably because gve_version_prefix is static in gve_main.c.
Would it be cleaner to keep the old name, or to move the function and its declaration next to the rest of the adminq code?
[ ... ]
Quoted 17 lines
drivers/net/ethernet/google/gve/gve_main.c +9
-0@@ -2415,6 +2415,35 @@ static void gve_set_buf_sizes(struct gve_priv *priv) priv->header_buf_size = device_info->header_buf_size; } +static int gve_setup_device (struct gve_priv *priv) +{ +int err; + + priv->num_registered_pages =0 ; + + priv->xsk_pools =bitmap_zalloc (priv->rx_cfg.max_queues,GFP_KERNEL ); +if (!priv->xsk_pools) { + err = -ENOMEM ;
drivers/net/ethernet/google/gve/gve_main.c static void gve_set_buf_sizes(struct gve_priv *priv) · line 2436
Quoted 10 lines
drivers/net/ethernet/google/gve/gve_main.c +10
-0+ goto err; + } + +gve_set_netdev_xdp_features (priv); +if (!gve_is_gqi (priv)) + priv->dev->xdp_metadata_ops = &gve_xdp_metadata_ops; + + err =gve_setup_device_resources (priv); +if (err) + goto err_free_xsk_bitmap;
[Severity: Medium]
This is a pre-existing issue, but gve_setup_device_resources() allocates the stats report, and every reset frees and reallocates it. Is the teardown order for that buffer safe?
gve_free_stats_report() does:
timer_delete_sync(&priv->stats_report_timer); dma_free_coherent(&priv->pdev->dev, priv->stats_report_len, priv->stats_report, priv->stats_report_bus);
Nothing drains stats_report_task before this. If gve_stats_report_task() is already queued or running, could gve_handle_report_stats() access the freed stats_report buffer or the rings during reset, suspend or remove?
"gve: simplify reset logic" later in the series appears to fix this by adding cancel_work_sync(&priv->stats_report_task) to gve_free_stats_report() and gve_queues_stop().
[ ... ]
drivers/net/ethernet/google/gve/gve_main.c static int gve_reset_recovery(struct gve_priv *priv, bool was_up) · line 2549
Quoted 12 lines
drivers/net/ethernet/google/gve/gve_main.c +5
-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; + }
[Severity: Medium]
This isn't a bug introduced by this patch, but does the reset path that skips normal teardown leak the previous AdminQ here?
With gve_reset(priv, false):
gve_reset()
gve_reset_and_teardown()
gve_trigger_reset()
gve_adminq_release()
gve_clear_admin_queue_ok(priv);
gve_teardown_priv_resources()
gve_adminq_free()
if (!gve_get_admin_queue_ok(priv))
return;gve_adminq_free() therefore returns early and never calls dma_pool_free() or dma_pool_destroy().
gve_reset_recovery()->gve_adminq_init()->gve_adminq_alloc() then overwrites priv->adminq_pool and priv->adminq. The old dma_pool and its AdminQ buffer would be lost on each such reset.
This seems to be fixed later in the series by "gve: simplify reset logic", which removes gve_reset_and_teardown() and gve_trigger_reset().
[ ... ]
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260924185316.2831077-1-hramamurthy%40google.com
[email protected]
AI reviewRe: [PATCH net-next v8 06/12] gve: simplify reset logic
In reply to Harshitha RamamurthyThank you for your contribution! Sashiko AI review found 7 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 7 potential issue(s) to consider.
Critical: 0 · High: 2 (1) · Medium: 2 (2) · Low: 3 (1)
If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).
- [High] After a failed recovery, an unprivileged user can crash the kernel with an ethtool query.
- [High] When gve_recover() fails during a reset while the interface is up (service-task reset, ethtool reset, flow-rule timeout, or…
- [Medium] gve_teardown_control_plane_resources() (gve_main.c) now calls gve_teardown_clock().
- [Medium] The commit message does not mention several user-visible changes to error handling, and one of its design statements is not…
- [Low] This patch removed gve_queues_mem_remove() from gve_queues_start()'s error path.
- [Low] The commit fixes a real unbounded recursive reset but has no
Fixes: tag.
- [Low] Item 2 of the commit message describes the old bug this way:
gve_close() during gve_shutdown triggers a hardware reset and then…
Pre-existing issues:
- [High] This bug predates the patch, which rewrites the same path without fixing it.
- [Medium] This race predates the patch.
- [Medium] The moved and new reset triggers in gve_add_flow_rule(), gve_del_flow_rule() and gve_set_features() fire only on -ETIME, which…
- [Low] gve_handle_reset() re-checks do_reset under rtnl and the netdev lock, but that does not cover a service task that read device_status…
--
gve: simplify reset logic
This reworks the gve reset path to remove recursive resets and resets during teardown. It separates control plane allocation from device setup, adds gve_reset_device() and gve_teardown_device(), and replaces gve_reset_recovery() with gve_recover(). Flow rule timeout handling moves from the adminq layer into the ethtool callers.
Quoted 6 lines
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.
[Severity: Medium]
Is the last sentence still accurate? gve_reset() is still called inline, under rtnl, from the reset label in gve_queues_start(), the reset label in gve_close(), gve_add_flow_rule() and gve_del_flow_rule().
The commit message also doesn't mention several user-visible changes.
gve_queues_start() now ends with "return gve_reset(priv, false)". If the inline reset recovers, ndo_open and gve_adjust_config() (ethtool -L/-G, XDP attach, XSK) return 0 after a queue creation failure.
Every failure in gve_recover() now goes to teardown_device and calls gve_teardown_device(). That includes gve_queues_mem_alloc() and gve_queues_start() failures after the control plane is already up. gve_teardown_device() frees the admin queue, the notify block IRQs, the management IRQ and MSI-X. The old gve_reset_recovery() kept the control plane configured when only gve_open() failed.
gve_open() now returns -ENODEV until the user runs an explicit ethtool reset.
After a failed recovery nothing schedules a retry. With the management IRQ freed, the device can no longer request one.
Could the commit message describe these changes? Also, is it intended that the device stays unusable until someone resets it manually?
Quoted 8 lines
2) Removing resets during the teardown portion of reset. This is partly covered by removing recursive resets, but the primary goal in this case is to allow the driver to complete teardown in a more direct manner. Before this patch,
gve_close()when called as part ofgve_shutdown, could end up triggering a hardware reset, then attempt to close again. In such a case, destroying hardware queues would inevitably fail, causing a loop.gve_close()is no longer called directly ingve_reset()breaking any possibility of this loop.
[Severity: Low]
Can the loop described here actually happen? In the old code, gve_reset_and_teardown() reset the hardware before the second gve_close():
gve_reset_and_teardown()
gve_trigger_reset()
gve_adminq_release() <- clears DEVICE_RINGS_OK and DEVICE_RESOURCES_OK
gve_close()
gve_queues_stop() <- only destroys rings if rings_ok is set
The second close therefore skipped queue destruction.
The loop that could happen went through the flow rule -ETIME reset inside gve_teardown_device_resources() (see the comment on gve_adminq_configure_flow_rule() below). Could this paragraph describe that path instead?
Quoted 4 lines
drivers/net/ethernet/google/gve/gve_adminq.c +0
-0
[ ... ]
Quoted 4 lines
drivers/net/ethernet/google/gve/gve_adminq.c +0
-0@@ -1377,12 +1376,8 @@ gve_adminq_configure_flow_rule(struct gve_priv *priv,sizeof (struct gve_adminq_configure_flow_rule ), flow_rule_cmd);
drivers/net/ethernet/google/gve/gve_adminq.c gve_adminq_configure_flow_rule(struct gve_priv *priv, · line 1383
Quoted 10 lines
drivers/net/ethernet/google/gve/gve_adminq.c +1
-5-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; }
[Severity: Low]
Before this patch, the removed code could recurse without bound while holding rtnl:
gve_adminq_configure_flow_rule() <- returns -ETIME
gve_reset(priv, true)
gve_teardown_priv_resources()
gve_teardown_device_resources()
gve_flow_rules_reset()
gve_adminq_configure_flow_rule() <- -ETIME again
gve_reset(priv, true)
...
The old gve_reset() had no reset_in_progress guard. Since this patch fixes that, should it carry a Fixes: tag?
[ ... ]
drivers/net/ethernet/google/gve/gve_flow_rule.c int gve_add_flow_rule(struct gve_priv *priv, struct ethtool_rxnfc *cmd) · line 281
Quoted 9 lines
drivers/net/ethernet/google/gve/gve_flow_rule.c +1
-0@@ -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 ) {
[Severity: Medium]
This isn't a bug introduced by this patch, but these reset triggers fire only on -ETIME. That applies here, in gve_del_flow_rule(), and in the new gve_schedule_reset() call in gve_set_features(). The driver returns -ETIME only when the device itself reports GVE_ADMINQ_COMMAND_ERROR_DEADLINE_EXCEEDED.
A real AQ hang on the host side returns a different error from gve_adminq_kick_and_wait():
if (!gve_adminq_wait_for_cmd(priv, head)) {
dev_err(&priv->pdev->dev, "AQ commands timed out, need to reset AQ\n");
priv->adminq_timeouts++;
return -ENOTRECOVERABLE;Should -ENOTRECOVERABLE also trigger a reset in these paths?
Quoted 4 lines
drivers/net/ethernet/google/gve/gve_flow_rule.c +4
-0+dev_err (&priv->pdev->dev, +"Timeout to add flow rule, trigger reset." ); +gve_reset (priv, false); + }
[ ... ]
Quoted 4 lines
drivers/net/ethernet/google/gve/gve_main.c +0
-0
[ ... ]
Quoted 6 lines
drivers/net/ethernet/google/gve/gve_main.c +1
-0+static void gve_teardown_control_plane_resources (struct gve_priv *priv) {int err;/* Tell device its resources are being freed */ if (gve_get_device_resources_ok (priv)) {
[ ... ]
drivers/net/ethernet/google/gve/gve_main.c static int gve_setup_device_resources(struct gve_priv *priv) · line 789
Quoted 2 lines
drivers/net/ethernet/google/gve/gve_main.c +1
-0+gve_teardown_clock (priv); err =gve_adminq_deconfigure_device_resources (priv);
[Severity: Medium]
Can the device DMA into a freed nic_ts_report buffer here?
gve_teardown_clock() calls gve_ptp_release() and then dma_free_coherent() on priv->nic_ts_report. The device writes that buffer when it services GVE_ADMINQ_REPORT_NIC_TIMESTAMP. The free now happens before gve_adminq_deconfigure_device_resources(). It also happens before gve_reset_device()->gve_adminq_free(), which does the hardware reset.
The kdoc on gve_reset_device() says the teardown commands can fail and that the hardware reset is the only guarantee the device has stopped accessing shared memory. The commit message makes a similar claim.
Here is the sequence I'm worried about. An earlier report timestamp command times out on the host side. gve_adminq_kick_and_wait() then returns -ENOTRECOVERABLE without cancelling the command in hardware. If the teardown commands also time out, the device may still complete the stale command after dma_free_coherent() has run.
The old service task reset path called gve_trigger_reset() before gve_teardown_clock(). The teardown_clock label in gve_setup_control_plane_resources() has the same ordering.
Would it be safer to free nic_ts_report in gve_free_control_plane_resources(), after gve_adminq_free()?
[ ... ]
Quoted 14 lines
drivers/net/ethernet/google/gve/gve_main.c +0
-10@@ -1415,16 +1472,14 @@ static int gve_queues_start(struct gve_priv *priv, reset:if (gve_get_reset_in_progress (priv)) - goto stop_and_free_rings; -gve_reset_and_teardown (priv, true); -/* if this fails there is nothing we can do so just ignore the return */ -gve_reset_recovery (priv, false); -/* return the original error */ -return err; -stop_and_free_rings: -gve_tx_stop_rings (priv,gve_num_tx_queues (priv)); -gve_rx_stop_rings (priv, priv->rx_cfg.num_queues); -gve_queues_mem_remove (priv);
drivers/net/ethernet/google/gve/gve_main.c static int gve_queues_start(struct gve_priv *priv, · line 1484
Quoted 10 lines
drivers/net/ethernet/google/gve/gve_main.c +8
-0+ goto stop_rings; + +/* Attempt to reset. If reset is successful, gve_queues_start was +* successful with the new config. +*/ +return gve_reset (priv, false); +stop_rings: +gve_queues_stop (priv);return err; }
[Severity: Low]
The header comment above gve_queues_start() still says:
* No memory is allocated. Passed-in memory is freed on errors.
The stop_rings path now only calls gve_queues_stop(), and callers free the queue memory themselves. Should the comment be updated to match?
Quoted 1 line
drivers/net/ethernet/google/gve/gve_main.c +0
-0@@ -1435,70 +1490,55 @@ static int gve_open(struct net_device *dev)
[ ... ]
Quoted 25 lines
drivers/net/ethernet/google/gve/gve_main.c +10
-6+static int gve_close (struct net_device *dev) { +struct gve_priv *priv =netdev_priv (dev);int err; -netif_carrier_off (priv->dev); +gve_turndown (priv); + +/* Surrender to reset if the queue destroying adminq cmds fail. Reset +* will not re-enable the interface. +*/ if (gve_get_device_rings_ok (priv)) { -gve_turndown (priv); -gve_drain_page_cache (priv); +gve_clear_device_rings_ok (priv); err =gve_destroy_rings (priv);if (err) - goto err; + goto reset; err =gve_unregister_qpls (priv);if (err) - goto err; -gve_clear_device_rings_ok (priv); + goto reset; }
[ ... ]
drivers/net/ethernet/google/gve/gve_main.c static int gve_open(struct net_device *dev) · line 1542
Quoted 4 lines
drivers/net/ethernet/google/gve/gve_main.c +3
-0+reset: + err =gve_reset (priv, true); +return err; }
[Severity: High]
This is a pre-existing issue, but this patch rewrites the same path. Can the new rings end up with a stale napi pointer when gve_close() falls into this reset from gve_adjust_config()?
gve_adjust_config() allocates the new rings before it closes. On DQO-RDA, gve_rx_create_page_pool() stores .napi = &priv->ntfy_blocks[ntfy_id].napi in each new page pool:
gve_adjust_config()
gve_queues_mem_alloc() <- page pools point into old ntfy_blocks
gve_close()
gve_reset(priv, true)
gve_free_control_plane_resources()
gve_free_notify_blocks() <- kvfree(priv->ntfy_blocks)
gve_recover() <- allocates a new ntfy_blocks
gve_queues_start() <- pool->p.napi is stale
If recovery succeeds, gve_close() returns 0. The rings are then started, and the RX recycle path reads napi->list_owner from the freed array in page_pool_napi_local().
If recovery fails, gve_adjust_config() calls gve_queues_mem_free() on the unstarted rings. page_pool_destroy()->page_pool_disable_direct_recycling() ->napi_assert_will_not_race() then reads the stale napi.
Should gve_adjust_config() drop and re-allocate its pre-allocated rings when gve_close() had to reset?
drivers/net/ethernet/google/gve/gve_main.c int gve_adjust_config(struct gve_priv *priv, · line 1879
Quoted 11 lines
drivers/net/ethernet/google/gve/gve_main.c +1
-3@@ -1833,9 +1873,7 @@ int gve_adjust_config(struct gve_priv *priv,if (err) {netif_err (priv, drv, priv->dev,"Adjust config failed to start new queues, !!! DISABLING ALL QUEUES !!!\n" ); -/* No need to free on error: ownership of resources is lost after -* calling gve_queues_start. -*/ +gve_queues_mem_remove (priv);gve_turndown (priv);return err; }
[Severity: High]
Can gve_adjust_config() run after a failed recovery and oops on a NULL priv->ntfy_blocks?
When gve_recover() fails during a reset with the interface up, gve_teardown_device() sets priv->ntfy_blocks, priv->xsk_pools, priv->tx and priv->rx to NULL. netif_running() stays true.
Only gve_open() checks gve_get_device_resources_ok(). gve_adjust_config() doesn't, and it is reached from ethtool -L/-G, the HW-GRO toggle, XDP attach and XSK enable. gve_close() succeeds because rings_ok is clear. The start path then does this:
gve_adjust_config()
gve_queues_start()
gve_tx_start_rings()
gve_tx_add_to_block()
block = &priv->ntfy_blocks[ntfy_idx]; <- ntfy_blocks is NULL
block->tx = tx;gve_xsk_pool_disable() looks similar. It does clear_bit(qid, priv->xsk_pools) and dereferences priv->ntfy_blocks[priv->rx[qid].ntfy_id] with only a netif_running() check.
Should these paths also bail out when device resources are not set up?
[ ... ]
drivers/net/ethernet/google/gve/gve_main.c static void gve_handle_reset(struct gve_priv *priv) · line 2280
Quoted 7 lines
drivers/net/ethernet/google/gve/gve_main.c +2
-1@@ -2235,7 +2276,8 @@ static void gve_handle_reset(struct gve_priv *priv)if (gve_get_do_reset (priv)) {rtnl_lock ();netdev_lock (priv->dev); -gve_reset (priv, false); +if (gve_get_do_reset (priv)) +gve_reset (priv, false);
[Severity: Low]
This isn't a bug introduced by this patch, but the re-check can't tell a stale request from a new one.
gve_handle_status() calls gve_set_do_reset() without any lock, based on a device_status value it read earlier. Suppose a concurrent gve_reset() from ethtool or a flow rule timeout clears do_reset after that read. The service task can still set the flag afterwards. Once the first reset finishes, the service task sees do_reset set here and runs a second full reset.
Is that redundant reset expected?
Quoted 3 lines
drivers/net/ethernet/google/gve/gve_main.c +0
-0netdev_unlock (priv->dev);rtnl_unlock (); }
[ ... ]
Quoted 18 lines
drivers/net/ethernet/google/gve/gve_main.c +13
-1+if (setup_queues) { +struct gve_tx_alloc_rings_cfg tx_alloc_cfg = {0 }; +struct gve_rx_alloc_rings_cfg rx_alloc_cfg = {0 }; + +gve_get_curr_alloc_cfgs (priv, &tx_alloc_cfg, &rx_alloc_cfg); + + err =gve_queues_mem_alloc (priv, &tx_alloc_cfg, &rx_alloc_cfg);if (err) -return err; + goto teardown_device; + + err =gve_queues_start (priv, &tx_alloc_cfg, &rx_alloc_cfg); +if (err) + goto teardown_device; } +return 0 ;
drivers/net/ethernet/google/gve/gve_main.c static int gve_reset_recovery(struct gve_priv *priv, bool was_up) · line 2594
Quoted 10 lines
drivers/net/ethernet/google/gve/gve_main.c +3
-5-err_free_adminq: -gve_adminq_free (priv); -err: -dev_err (&priv->pdev->dev,"Reset failed! !!! DISABLING ALL QUEUES !!!\n" ); -gve_turndown (priv); +teardown_device: +dev_err (&priv->pdev->dev,"Recover failed! !!! DISABLING ALL QUEUES !!!\n" ); +gve_teardown_device (priv);return err; }
[Severity: High]
Can an unprivileged user oops the kernel with ethtool -x after this path runs?
A queue allocation failure, such as -ENOMEM from gve_queues_mem_alloc(), now frees the whole control plane:
gve_teardown_device()
gve_free_control_plane_resources()
gve_free_rss_config_cache() <- hash_key/hash_lut freed, rss_config zeroed
The netdev stays registered, and priv->rss_key_size, priv->rss_lut_size and priv->cache_rss_config stay set. ETHTOOL_GRSSH and ETHTOOL_GRXFHINDIR don't need CAP_NET_ADMIN:
__dev_ethtool()
gve_get_rxfh() <- only checks rss_key_size/rss_lut_size
gve_get_rss_config_cache()
memcpy(rxfh->key, rss_config->hash_key, priv->rss_key_size); <- NULLEarly failures such as adminq init could already leave the caches NULL before this patch. With this patch, queue-level recovery failures also reach this state.
Should gve_get_rxfh() check that the RSS cache exists?
[ ... ]
drivers/net/ethernet/google/gve/gve_main.c static int gve_reset_recovery(struct gve_priv *priv, bool was_up) · line 2618
Quoted 4 lines
drivers/net/ethernet/google/gve/gve_main.c +2
-2-/* Set it all back up */ - err =gve_reset_recovery (priv, was_up); +disable_work (&priv->service_task); +gve_reset_device (priv);
[Severity: Medium]
This is a pre-existing issue, but disable_work() does not wait for a service task that is already running.
gve_service_task()->gve_handle_link_status() takes neither rtnl nor the netdev lock. It uses the napi enabled bit as a gate before netif_carrier_on():
if (!gve_get_napi_enabled(priv))
return;
if (link_status == netif_carrier_ok(priv->dev))
return;
if (link_status) {
...
netif_carrier_on(priv->dev);A service task that has already passed the gve_get_napi_enabled() check can turn the carrier back on after gve_turndown() above has turned it off. The carrier then stays up while the device is torn down.
How is the link state update meant to be serialized against gve_turndown() here?
[ ... ]
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260924185316.2831077-1-hramamurthy%40google.com
[email protected]
AI reviewRe: [PATCH net-next v8 07/12] gve: add gve_ctrl_ops for gve initialization/teardown sequences
In reply to Harshitha RamamurthyThank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you…
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The kernel-doc for struct gve_ctrl_ops in drivers/net/ethernet/google/gve/gve.h says @setup_stats_report is…
- [Low] This patch changes the prototype to int gve_adminq_get_ptype_map_dqo(struct gve_priv *priv);, but…
--
gve: add gve_ctrl_ops for gve initialization/teardown sequences
This commit adds get_ptype_map, configure_rss, setup_stats_report and reset_flow_rules callbacks to struct gve_ctrl_ops. The control plane setup and teardown paths in gve_main.c now call them through priv->ctrl_ops. gve_adminq_get_ptype_map_dqo() also changes: it now writes into priv->ptype_lut_dqo directly and no longer takes a ptype_lut argument.
Quoted 15 lines
drivers/net/ethernet/google/gve/gve.h +4
-0@@ -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);
drivers/net/ethernet/google/gve/gve.h struct gve_device_info { · line 852
Quoted 10 lines
drivers/net/ethernet/google/gve/gve.h +7
-0void (*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 */
[Severity: Low]
This isn't a bug, but is setup_stats_report meant to be optional for back-ends other than AdminQ?
The kernel-doc says "(AdminQ only)" and the member has an "AQ-specific" comment. Someone writing a future mailbox ops table could read that as permission to leave the op NULL.
Both call sites use it without a NULL check, though. In gve_setup_control_plane_resources():
err = ops->setup_stats_report(priv, priv->stats_report_len, priv->stats_report_bus, GVE_STATS_REPORT_TIMER_PERIOD);
and in gve_teardown_control_plane_resources():
err = ops->setup_stats_report(priv, 0, 0x0, GVE_STATS_REPORT_TIMER_PERIOD);
A NULL call can't happen today. The only table, gve_adminq_ops, sets the op to gve_adminq_report_stats(). Later in the series, release_db_resources gets the same "(AdminQ only)" label and is also called without a NULL check.
Could the kernel-doc say whether the op must always be provided, with non-AdminQ back-ends supplying a stub? Or should the call sites check for NULL?
[ ... ]
drivers/net/ethernet/google/gve/gve_adminq.h int gve_adminq_report_nic_ts(struct gve_priv *priv, · line 655
Quoted 11 lines
drivers/net/ethernet/google/gve/gve_adminq.h +1
-2@@ -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);
[Severity: Low]
This isn't a bug, but now that the ptype_lut argument is gone, is the "struct gve_ptype_lut;" forward declaration above still needed?
Nothing else in gve_adminq.h refers to that type. The declaration is also still there at the end of the series.
[ ... ]
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260924185316.2831077-1-hramamurthy%40google.com
Harshitha Ramamurthy
maintainerQuoted 108 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) addgve_ctrl_opsstructure to the driver for various control plane operationsThe 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 v8:
- Patch 6(Sashiko):
- callgve_queues_stop()directly ingve_queues_start()to handle XDP info unregistration
- dropgve_queues_mem_remove()fromgve_queues_start()and leave it to the caller; this moves a few function definitions around to avoid forward declarations
- revert thegve_mgmnt_intr()behavior change from v7
- handle the TOCTOU when checking for a pending reset
- record all configurations in priv before sending an AQ command that can result in a reset
- update the commit description regarding teardown-related resets
- Patch 8(Sashiko):
- gate mgmt IRQ and notify block teardown on different conditions
- movegve_teardown_notify_blocks()fromgve_reset_device()togve_teardown_device(), and tear down notify blocks as part of the device reset
- don't setblock->irqwhen tearing down notify blocks; instead guard thedisable_irq()call ingve_remove_napi()on whether the IRQ was requested
- v7: https://lore.kernel.org/netdev/[email protected]/Changes in v7:
- All changes are in patch 6(Sashiko):
- ReturnIRQ_HANDLEDinstead ofIRQ_NONEingve_mgmnt_intr()
- disable service task instead of stats report task forgve_probe()error
- cancel stats report ingve_free_stats_report()
- extractgve_teardown_control_plane_resouces()andgve_adminq_free()into newgve_reset_device()to ensure the device reset is triggered before stopping queues
- don't callgve_queues_stop()in thegve_close()error path since thegve_reset()takes care of that.
- v6: https://lore.kernel.org/netdev/[email protected]/Changes in v6:
- update commit message to be more consistent with code (patch 1,9 Sashiko)
- call out MTU validation change (patch 1, Sashiko)
- A few other Sashiko related fixes (error propagation in patch 2, drop double logging in patch 5, drop unintentional type conversion in patch 11)
- v5: https://lore.kernel.org/netdev/[email protected]/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_unusedtag (patch 4, Sashiko)
- fix workqueue disable count, destroy rings before stopping Qs, stop queues in error path ingve_close, preserve ordering ofgve_turndown->gve_destroy_rings->gve_queues_stopduring 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 ingve_adminq.c, introducing final tab spacing and using local variable (Przemek Kitszel)
- Fix kdoc formatting and drop spurious management interrupt(patch 9)
- Propagaterelease_db_resourcesnaming 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).
- Markgve_adminq_get_device_properties()with__maybe_unusedahead 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 structgve_device_infoto hold device properties
gve: introduce control plane operations structure
gve: introduce ctrl ops to set vectors and Qs
gve: introducegve_adminq_get_device_properties()
gve: refactorgve_init_privfor reset path
gve: add ctrl ops for queue operations
Quoted 7 lines
Joshua Washington (6):
gve: simplify reset logic
gve: addgve_ctrl_opsfor 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
There are a few high/medium issues that Sashiko has spotted for patch
6. Will fix in v9.
Quoted 13 lines
drivers/net/ethernet/google/gve/gve.h | 87 +- drivers/net/ethernet/google/gve/gve_adminq.c | 376 ++++++-- drivers/net/ethernet/google/gve/gve_adminq.h | 30 +- drivers/net/ethernet/google/gve/gve_ethtool.c | 5 +- drivers/net/ethernet/google/gve/gve_flow_rule.c | 15 +- drivers/net/ethernet/google/gve/gve_main.c | 1067 ++++++++++++----------- drivers/net/ethernet/google/gve/gve_utils.c | 4 +- 7 files changed, 972 insertions(+), 612 deletions(-)--
2.56.0.rc1.310.g51773c2048-goog
Paolo Abeni
maintainerRe: [PATCH net-next v8 06/12] gve: simplify reset logic
In reply to [email protected]Quoted 11 lines · On 9/25/26 20:56, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 7 potential issue(s) to consider.
Critical: 0 · High: 2 (1) · Medium: 2 (2) · Low: 3 (1)
If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).
Quoted 14 lines
- [High] After a failed recovery, an unprivileged user can crash the kernel with an ethtool query.
- [High] Whengve_recover()fails during a reset while the interface is up (service-task reset, ethtool reset, flow-rule timeout, or…
- [Medium]gve_teardown_control_plane_resources()(gve_main.c) now callsgve_teardown_clock().
- [Medium] The commit message does not mention several user-visible changes to error handling, and one of its design statements is not…
- [Low] This patch removedgve_queues_mem_remove()from gve_queues_start()'s error path.
- [Low] The commit fixes a real unbounded recursive reset but has no
Fixes: tag.
- [Low] Item 2 of the commit message describes the old bug this way:
gve_close()duringgve_shutdowntriggers a hardware reset and then…
Low prio remarks could be ignored and we prefer no fixes tag in net-next patches, but the first 3 ones in the list look relevant and should be addressed.
Also please note you are supposed to address clashiko comments proactively.
/P
Joshua Washington
maintainerRe: [PATCH net-next v8 06/12] gve: simplify reset logic
Quoted 27 lines · Paolo Abeni
Quoted 11 lines · On 9/25/26 20:56, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 7 potential issue(s) to consider.
Critical: 0 · High: 2 (1) · Medium: 2 (2) · Low: 3 (1)
If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).
Quoted 14 lines
- [High] After a failed recovery, an unprivileged user can crash the kernel with an ethtool query.
- [High] Whengve_recover()fails during a reset while the interface is up (service-task reset, ethtool reset, flow-rule timeout, or…
- [Medium]gve_teardown_control_plane_resources()(gve_main.c) now callsgve_teardown_clock().
- [Medium] The commit message does not mention several user-visible changes to error handling, and one of its design statements is not…
- [Low] This patch removedgve_queues_mem_remove()from gve_queues_start()'s error path.
- [Low] The commit fixes a real unbounded recursive reset but has no
Fixes: tag.
- [Low] Item 2 of the commit message describes the old bug this way:
gve_close()duringgve_shutdowntriggers a hardware reset and then…
Quoted 8 lines
Low prio remarks could be ignored and we prefer no fixes tag in net-next patches, but the first 3 ones in the list look relevant and should be addressed.
Also please note you are supposed to address clashiko comments proactively.
/P
My apologies for not replying directly. Harshitha ultimately replied to the cover letter stating that we would be sending a v9 to address high/medium issues, so I thought that was sufficient.
In any case, I will add a response here for the planned fixes for v9:
Quoted 4 lines
- [High] After a failed recovery, an unprivileged user can crash the kernel with an ethtool query.
- [High] Whengve_recover()fails during a reset while the interface is up (service-task reset, ethtool reset, flow-rule timeout, or…
These first two are a result of the change to teardown when recover fails. For that, we will avoid tearing down when only queue creation fails, and call device_detach when the control plane itself cannot be set up. This should prevent any ethtool IOCTLs from going through.
Quoted 2 lines
- [Medium]
gve_teardown_control_plane_resources()(gve_main.c) now callsgve_teardown_clock().
gve_teardown_clock() will be called as part of gve_free_control_plane_resources() instead. Since it is only freeing memory, and is idempotent, this should be a safe change.
For the commit message issue, the commit message will be updated to reflect the latest changes. This code has changed quite a lot since v1, but the commit messages has not seen many of those updates.
-- Josh