Skip to contentSkip to conversation

net/gve: add flow steering support

PATCH Superseded Jasper Tran O'Leary 2 participants 27 messages Feb 27 – Mar 4

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover net/gve: add flow steering support

This patch series adds flow steering support to the Google Virtual Ethernet (gve) driver. This functionality allows traffic to be directed to specific receive queues based on user-specified flow patterns.

The series includes foundational support for extended admin queue commands needed to handle flow rules, the specific adminqueue commands for flow rule management, and the integration with the DPDK rte_flow API. The series adds support flow matching on the following protocols:
IPv4, IPv6, TCP, UDP, SCTP, ESP, and AH.

Patch Overview:

1. "net/gve: add flow steering device option" checks for and enables the flow steering capability in the device options during initialization.
2. "net/gve: introduce extended adminq command" adds infrastructure for sending extended admin queue commands. These commands use a flexible buffer descriptor format required for flow rule management.
3. "net/gve: add adminq commands for flow steering" implements the specific admin queue commands to add and remove flow rules on the device, including handling of rule IDs and parameters.
4. "net/gve: add rte flow API integration" exposes the flow steering functionality via the DPDK rte_flow API. This includes strict pattern validation, rule parsing, and lifecycle management (create, destroy, flush). It ensures thread-safe access to the flow subsystem and proper resource cleanup during device reset.

Jasper Tran O'Leary (2):
net/gve: add adminq commands for flow steering
net/gve: add rte flow API integration

Vee Agarwal (2):
net/gve: add flow steering device option
net/gve: introduce extended adminq command

 doc/guides/nics/features/gve.ini       |  12 +
 doc/guides/nics/gve.rst                |  20 +
 doc/guides/rel_notes/release_26_03.rst |   1 +
 drivers/net/gve/base/gve.h             |   3 +-
 drivers/net/gve/base/gve_adminq.c      | 118 ++++-
 drivers/net/gve/base/gve_adminq.h      |  57 +++
 drivers/net/gve/gve_ethdev.c           |  87 +++-
 drivers/net/gve/gve_ethdev.h           |  46 ++
 drivers/net/gve/gve_flow_rule.c        | 645 +++++++++++++++++++++++++
 drivers/net/gve/gve_flow_rule.h        |  64 +++
 drivers/net/gve/meson.build            |   1 +
 11 files changed, 1049 insertions(+), 5 deletions(-)
 create mode 100644 dpdk/drivers/net/gve/gve_flow_rule.c
 create mode 100644 dpdk/drivers/net/gve/gve_flow_rule.h
Signature · 1 line
2.53.0.473.g4a7958ca14-goog
#1 lore raw

PATCH 1/4 net/gve: add flow steering device option

From: Vee Agarwal <[email protected]>

Add a new device option to signal to the driver that the device supports flow steering. This device option also carries the maximum number of flow steering rules that the device can store.

---
 drivers/net/gve/base/gve_adminq.c | 36 ++++++++++++++++++++++++++++---
 drivers/net/gve/base/gve_adminq.h | 11 ++++++++++
 drivers/net/gve/gve_ethdev.h      |  2 ++
 3 files changed, 46 insertions(+), 3 deletions(-)
drivers/net/gve/base/gve_adminq.c +33 -3
index 6bd98d5..64b9468 100644
@@ -36,6 +36,7 @@ void gve_parse_device_option(struct gve_priv *priv,
 			     struct gve_device_option_gqi_rda **dev_op_gqi_rda,
 			     struct gve_device_option_gqi_qpl **dev_op_gqi_qpl,
 			     struct gve_device_option_dqo_rda **dev_op_dqo_rda,
+			     struct gve_device_option_flow_steering **dev_op_flow_steering,
 			     struct gve_device_option_modify_ring **dev_op_modify_ring,
 			     struct gve_device_option_jumbo_frames **dev_op_jumbo_frames)
 {
@@ -109,6 +110,22 @@ void gve_parse_device_option(struct gve_priv *priv,
 		}
 		*dev_op_dqo_rda = RTE_PTR_ADD(option, sizeof(*option));
 		break;
+	case GVE_DEV_OPT_ID_FLOW_STEERING:
+		if (option_length < sizeof(**dev_op_flow_steering) ||
+		    req_feat_mask != GVE_DEV_OPT_REQ_FEAT_MASK_FLOW_STEERING) {
+			PMD_DRV_LOG(WARNING, GVE_DEVICE_OPTION_ERROR_FMT,
+				    "Flow Steering", (int)sizeof(**dev_op_flow_steering),
+				    GVE_DEV_OPT_REQ_FEAT_MASK_FLOW_STEERING,
+				    option_length, req_feat_mask);
+			break;
+		}
+
+		if (option_length > sizeof(**dev_op_flow_steering)) {
+			PMD_DRV_LOG(WARNING,
+				    GVE_DEVICE_OPTION_TOO_BIG_FMT, "Flow Steering");
+		}
+		*dev_op_flow_steering = RTE_PTR_ADD(option, sizeof(*option));
+		break;
 	case GVE_DEV_OPT_ID_MODIFY_RING:
 		/* Min ring size bound is optional. */
 		if (option_length < (sizeof(**dev_op_modify_ring) -
@@ -167,6 +184,7 @@ gve_process_device_options(struct gve_priv *priv,
 			   struct gve_device_option_gqi_rda **dev_op_gqi_rda,
 			   struct gve_device_option_gqi_qpl **dev_op_gqi_qpl,
 			   struct gve_device_option_dqo_rda **dev_op_dqo_rda,
+			   struct gve_device_option_flow_steering **dev_op_flow_steering,
 			   struct gve_device_option_modify_ring **dev_op_modify_ring,
 			   struct gve_device_option_jumbo_frames **dev_op_jumbo_frames)
 {
@@ -188,8 +206,8 @@ gve_process_device_options(struct gve_priv *priv,
 
 		gve_parse_device_option(priv, dev_opt,
 					dev_op_gqi_rda, dev_op_gqi_qpl,
-					dev_op_dqo_rda, dev_op_modify_ring,
-					dev_op_jumbo_frames);
+					dev_op_dqo_rda, dev_op_flow_steering,
+					dev_op_modify_ring, dev_op_jumbo_frames);
 		dev_opt = next_opt;
 	}
 
@@ -777,9 +795,19 @@ gve_set_max_desc_cnt(struct gve_priv *priv,
 
 static void gve_enable_supported_features(struct gve_priv *priv,
 	u32 supported_features_mask,
+	const struct gve_device_option_flow_steering *dev_op_flow_steering,
 	const struct gve_device_option_modify_ring *dev_op_modify_ring,
 	const struct gve_device_option_jumbo_frames *dev_op_jumbo_frames)
 {
+	if (dev_op_flow_steering &&
+	    (supported_features_mask & GVE_SUP_FLOW_STEERING_MASK) &&
+	    dev_op_flow_steering->max_flow_rules) {
+		priv->max_flow_rules =
+			be32_to_cpu(dev_op_flow_steering->max_flow_rules);
+		PMD_DRV_LOG(INFO,
+			    "FLOW STEERING device option enabled with max rule limit of %u.",
+			    priv->max_flow_rules);
+	}
 	if (dev_op_modify_ring &&
 	    (supported_features_mask & GVE_SUP_MODIFY_RING_MASK)) {
 		PMD_DRV_LOG(INFO, "MODIFY RING device option enabled.");
@@ -802,6 +830,7 @@ int gve_adminq_describe_device(struct gve_priv *priv)
 {
 	struct gve_device_option_jumbo_frames *dev_op_jumbo_frames = NULL;
 	struct gve_device_option_modify_ring *dev_op_modify_ring = NULL;
+	struct gve_device_option_flow_steering *dev_op_flow_steering = NULL;
 	struct gve_device_option_gqi_rda *dev_op_gqi_rda = NULL;
 	struct gve_device_option_gqi_qpl *dev_op_gqi_qpl = NULL;
 	struct gve_device_option_dqo_rda *dev_op_dqo_rda = NULL;
@@ -829,6 +858,7 @@ int gve_adminq_describe_device(struct gve_priv *priv)
 
 	err = gve_process_device_options(priv, descriptor, &dev_op_gqi_rda,
 					 &dev_op_gqi_qpl, &dev_op_dqo_rda,
+					 &dev_op_flow_steering,
 					 &dev_op_modify_ring,
 					 &dev_op_jumbo_frames);
 	if (err)
@@ -884,7 +914,7 @@ int gve_adminq_describe_device(struct gve_priv *priv)
 	priv->default_num_queues = be16_to_cpu(descriptor->default_num_queues);
 
 	gve_enable_supported_features(priv, supported_features_mask,
-				      dev_op_modify_ring,
+				      dev_op_flow_steering, dev_op_modify_ring,
 				      dev_op_jumbo_frames);
 
 free_device_descriptor:
drivers/net/gve/base/gve_adminq.h +11 -0
index 6a3d469..e237353 100644
@@ -117,6 +117,14 @@ struct gve_ring_size_bound {
 
 GVE_CHECK_STRUCT_LEN(4, gve_ring_size_bound);
 
+struct gve_device_option_flow_steering {
+	__be32 supported_features_mask;
+	__be32 reserved;
+	__be32 max_flow_rules;
+};
+
+GVE_CHECK_STRUCT_LEN(12, gve_device_option_flow_steering);
+
 struct gve_device_option_modify_ring {
 	__be32 supported_features_mask;
 	struct gve_ring_size_bound max_ring_size;
@@ -148,6 +156,7 @@ enum gve_dev_opt_id {
 	GVE_DEV_OPT_ID_DQO_RDA = 0x4,
 	GVE_DEV_OPT_ID_MODIFY_RING = 0x6,
 	GVE_DEV_OPT_ID_JUMBO_FRAMES = 0x8,
+	GVE_DEV_OPT_ID_FLOW_STEERING = 0xb,
 };
 
 enum gve_dev_opt_req_feat_mask {
@@ -155,6 +164,7 @@ enum gve_dev_opt_req_feat_mask {
 	GVE_DEV_OPT_REQ_FEAT_MASK_GQI_RDA = 0x0,
 	GVE_DEV_OPT_REQ_FEAT_MASK_GQI_QPL = 0x0,
 	GVE_DEV_OPT_REQ_FEAT_MASK_DQO_RDA = 0x0,
+	GVE_DEV_OPT_REQ_FEAT_MASK_FLOW_STEERING = 0x0,
 	GVE_DEV_OPT_REQ_FEAT_MASK_MODIFY_RING = 0x0,
 	GVE_DEV_OPT_REQ_FEAT_MASK_JUMBO_FRAMES = 0x0,
 };
@@ -162,6 +172,7 @@ enum gve_dev_opt_req_feat_mask {
 enum gve_sup_feature_mask {
 	GVE_SUP_MODIFY_RING_MASK = 1 << 0,
 	GVE_SUP_JUMBO_FRAMES_MASK = 1 << 2,
+	GVE_SUP_FLOW_STEERING_MASK = 1 << 5,
 };
 
 #define GVE_DEV_OPT_LEN_GQI_RAW_ADDRESSING 0x0
drivers/net/gve/gve_ethdev.h +2 -0
index f7cc781..3a810b6 100644
@@ -332,6 +332,8 @@ struct gve_priv {
 
 	struct gve_rss_config rss_config;
 	struct gve_ptype_lut *ptype_lut_dqo;
+
+	uint32_t max_flow_rules;
 };
 
 static inline bool
Signature · 1 line
2.53.0.473.g4a7958ca14-goog
#2 lore raw

PATCH 2/4 net/gve: introduce extended adminq command

In reply to Jasper Tran O'Leary

From: Vee Agarwal <[email protected]>

Flow steering adminq commands are too large to fit into a normal adminq command buffer which accepts at most 56 bytes. As a result, introduce extended adminq commands which permit larger command buffers using indirection. Namely, extended command operations point to inner command buffers allocated at a specified DMA address. As specified with the device, all extended commands will use inner opcodes larger than 0xFF.

---
 drivers/net/gve/base/gve_adminq.c | 30 ++++++++++++++++++++++++++++++
 drivers/net/gve/base/gve_adminq.h | 16 ++++++++++++++++
 2 files changed, 46 insertions(+)
drivers/net/gve/base/gve_adminq.c +30 -0
index 64b9468..0cc6d44 100644
@@ -438,6 +438,8 @@ static int gve_adminq_issue_cmd(struct gve_priv *priv,
 
 	memcpy(cmd, cmd_orig, sizeof(*cmd_orig));
 	opcode = be32_to_cpu(READ_ONCE32(cmd->opcode));
+	if (opcode == GVE_ADMINQ_EXTENDED_COMMAND)
+		opcode = be32_to_cpu(READ_ONCE32(cmd->extended_command.inner_opcode));
 
 	switch (opcode) {
 	case GVE_ADMINQ_DESCRIBE_DEVICE:
@@ -516,6 +518,34 @@ static int gve_adminq_execute_cmd(struct gve_priv *priv,
 	return gve_adminq_kick_and_wait(priv);
 }
 
+static int gve_adminq_execute_extended_cmd(struct gve_priv *priv, u32 opcode,
+					   size_t cmd_size, void *cmd_orig)
+{
+	union gve_adminq_command cmd;
+	struct gve_dma_mem inner_cmd_dma_mem;
+	void *inner_cmd;
+	int err;
+
+	inner_cmd = gve_alloc_dma_mem(&inner_cmd_dma_mem, cmd_size);
+	if (!inner_cmd)
+		return -ENOMEM;
+
+	memcpy(inner_cmd, cmd_orig, cmd_size);
+
+	memset(&cmd, 0, sizeof(cmd));
+	cmd.opcode = cpu_to_be32(GVE_ADMINQ_EXTENDED_COMMAND);
+	cmd.extended_command = (struct gve_adminq_extended_command) {
+		.inner_opcode = cpu_to_be32(opcode),
+		.inner_length = cpu_to_be32(cmd_size),
+		.inner_command_addr = cpu_to_be64(inner_cmd_dma_mem.pa),
+	};
+
+	err = gve_adminq_execute_cmd(priv, &cmd);
+
+	gve_free_dma_mem(&inner_cmd_dma_mem);
+	return err;
+}
+
 /* The device specifies that the management vector can either be the first irq
  * or the last irq. ntfy_blk_msix_base_idx indicates the first irq assigned to
  * the ntfy blks. It if is 0 then the management vector is last, if it is 1 then
drivers/net/gve/base/gve_adminq.h +16 -0
index e237353..f52658e 100644
@@ -25,8 +25,15 @@ enum gve_adminq_opcodes {
 	GVE_ADMINQ_REPORT_LINK_SPEED		= 0xD,
 	GVE_ADMINQ_GET_PTYPE_MAP		= 0xE,
 	GVE_ADMINQ_VERIFY_DRIVER_COMPATIBILITY	= 0xF,
+	/* For commands that are larger than 56 bytes */
+	GVE_ADMINQ_EXTENDED_COMMAND		= 0xFF,
 };
 
+/* The normal adminq command is restricted to be 56 bytes at maximum. For the
+ * longer adminq command, it is wrapped by GVE_ADMINQ_EXTENDED_COMMAND with
+ * inner opcode of gve_adminq_extended_cmd_opcodes specified. The inner command
+ * is written in the dma memory allocated by GVE_ADMINQ_EXTENDED_COMMAND.
+ */
 /* Admin queue status codes */
 enum gve_adminq_statuses {
 	GVE_ADMINQ_COMMAND_UNSET			= 0x0,
@@ -194,6 +201,14 @@ enum gve_driver_capbility {
 #define GVE_DRIVER_CAPABILITY_FLAGS3 0x0
 #define GVE_DRIVER_CAPABILITY_FLAGS4 0x0
 
+struct gve_adminq_extended_command {
+	__be32 inner_opcode;
+	__be32 inner_length;
+	__be64 inner_command_addr;
+};
+
+GVE_CHECK_STRUCT_LEN(16, gve_adminq_extended_command);
+
 struct gve_driver_info {
 	u8 os_type;	/* 0x05 = DPDK */
 	u8 driver_major;
@@ -440,6 +455,7 @@ union gve_adminq_command {
 			struct gve_adminq_get_ptype_map get_ptype_map;
 			struct gve_adminq_verify_driver_compatibility
 				verify_driver_compatibility;
+			struct gve_adminq_extended_command extended_command;
 		};
 	};
 	u8 reserved[64];
Signature · 1 line
2.53.0.473.g4a7958ca14-goog
#3 lore raw

PATCH 3/4 net/gve: add adminq commands for flow steering

In reply to Jasper Tran O'Leary

Add new adminq commands for the driver to configure flow rules that are stored in the device. For configuring flow rules, 3 sub commands are supported.
- create: creates a new flow rule with a specific rule_id.
- destroy: deletes an existing flow rule with the specified rule_id.
- flush: clears and deletes all currently active flow rules.

---
 drivers/net/gve/base/gve_adminq.c | 52 +++++++++++++++++++++++++++
 drivers/net/gve/base/gve_adminq.h | 30 ++++++++++++++++
 drivers/net/gve/gve_ethdev.h      |  1 +
 drivers/net/gve/gve_flow_rule.h   | 59 +++++++++++++++++++++++++++++++
 4 files changed, 142 insertions(+)
 create mode 100644 dpdk/drivers/net/gve/gve_flow_rule.h
drivers/net/gve/base/gve_adminq.c +52 -0
index 0cc6d44..9a94591 100644
@@ -239,6 +239,7 @@ int gve_adminq_alloc(struct gve_priv *priv)
 	priv->adminq_report_stats_cnt = 0;
 	priv->adminq_report_link_speed_cnt = 0;
 	priv->adminq_get_ptype_map_cnt = 0;
+	priv->adminq_cfg_flow_rule_cnt = 0;
 
 	/* Setup Admin queue with the device */
 	rte_pci_read_config(priv->pci_dev, &pci_rev_id, sizeof(pci_rev_id),
@@ -487,6 +488,9 @@ static int gve_adminq_issue_cmd(struct gve_priv *priv,
 	case GVE_ADMINQ_VERIFY_DRIVER_COMPATIBILITY:
 		priv->adminq_verify_driver_compatibility_cnt++;
 		break;
+	case GVE_ADMINQ_CONFIGURE_FLOW_RULE:
+		priv->adminq_cfg_flow_rule_cnt++;
+		break;
 	default:
 		PMD_DRV_LOG(ERR, "unknown AQ command opcode %d", opcode);
 	}
@@ -546,6 +550,54 @@ static int gve_adminq_execute_extended_cmd(struct gve_priv *priv, u32 opcode,
 	return err;
 }
 
+static int
+gve_adminq_configure_flow_rule(struct gve_priv *priv,
+			       struct gve_adminq_configure_flow_rule *flow_rule_cmd)
+{
+	int err = gve_adminq_execute_extended_cmd(priv,
+			GVE_ADMINQ_CONFIGURE_FLOW_RULE,
+			sizeof(struct gve_adminq_configure_flow_rule),
+			flow_rule_cmd);
+
+	return err;
+}
+
+int gve_adminq_add_flow_rule(struct gve_priv *priv,
+			     struct gve_flow_rule_params *rule, u32 loc)
+{
+	struct gve_adminq_configure_flow_rule flow_rule_cmd = {
+		.opcode = cpu_to_be16(GVE_FLOW_RULE_CFG_ADD),
+		.location = cpu_to_be32(loc),
+		.rule = {
+			.flow_type = cpu_to_be16(rule->flow_type),
+			.action = cpu_to_be16(rule->action),
+			.key = rule->key,
+			.mask = rule->mask,
+		},
+	};
+
+	return gve_adminq_configure_flow_rule(priv, &flow_rule_cmd);
+}
+
+int gve_adminq_del_flow_rule(struct gve_priv *priv, u32 loc)
+{
+	struct gve_adminq_configure_flow_rule flow_rule_cmd = {
+		.opcode = cpu_to_be16(GVE_FLOW_RULE_CFG_DEL),
+		.location = cpu_to_be32(loc),
+	};
+
+	return gve_adminq_configure_flow_rule(priv, &flow_rule_cmd);
+}
+
+int gve_adminq_reset_flow_rules(struct gve_priv *priv)
+{
+	struct gve_adminq_configure_flow_rule flow_rule_cmd = {
+		.opcode = cpu_to_be16(GVE_FLOW_RULE_CFG_RESET),
+	};
+
+	return gve_adminq_configure_flow_rule(priv, &flow_rule_cmd);
+}
+
 /* The device specifies that the management vector can either be the first irq
  * or the last irq. ntfy_blk_msix_base_idx indicates the first irq assigned to
  * the ntfy blks. It if is 0 then the management vector is last, if it is 1 then
drivers/net/gve/base/gve_adminq.h +30 -0
index f52658e..d8e5e6a 100644
@@ -7,6 +7,7 @@
 #define _GVE_ADMINQ_H
 
 #include "gve_osdep.h"
+#include "../gve_flow_rule.h"
 
 /* Admin queue opcodes */
 enum gve_adminq_opcodes {
@@ -34,6 +35,10 @@ enum gve_adminq_opcodes {
  * inner opcode of gve_adminq_extended_cmd_opcodes specified. The inner command
  * is written in the dma memory allocated by GVE_ADMINQ_EXTENDED_COMMAND.
  */
+enum gve_adminq_extended_cmd_opcodes {
+	GVE_ADMINQ_CONFIGURE_FLOW_RULE	= 0x101,
+};
+
 /* Admin queue status codes */
 enum gve_adminq_statuses {
 	GVE_ADMINQ_COMMAND_UNSET			= 0x0,
@@ -434,6 +439,26 @@ struct gve_adminq_configure_rss {
 	__be64 indir_addr;
 };
 
+/* Flow rule definition for the admin queue using network byte order (big
+ * endian). This struct represents the hardware wire format and should not be
+ * used outside of admin queue contexts.
+ */
+struct gve_adminq_flow_rule {
+	__be16 flow_type;
+	__be16 action; /* RX queue id */
+	struct gve_flow_spec key;
+	struct gve_flow_spec mask;
+};
+
+struct gve_adminq_configure_flow_rule {
+	__be16 opcode;
+	u8 padding[2];
+	struct gve_adminq_flow_rule rule;
+	__be32 location;
+};
+
+GVE_CHECK_STRUCT_LEN(92, gve_adminq_configure_flow_rule);
+
 union gve_adminq_command {
 	struct {
 		__be32 opcode;
@@ -499,4 +524,9 @@ int gve_adminq_verify_driver_compatibility(struct gve_priv *priv,
 int gve_adminq_configure_rss(struct gve_priv *priv,
 			     struct gve_rss_config *rss_config);
 
+int gve_adminq_add_flow_rule(struct gve_priv *priv,
+			     struct gve_flow_rule_params *rule, u32 loc);
+int gve_adminq_del_flow_rule(struct gve_priv *priv, u32 loc);
+int gve_adminq_reset_flow_rules(struct gve_priv *priv);
+
 #endif /* _GVE_ADMINQ_H */
drivers/net/gve/gve_ethdev.h +1 -0
index 3a810b6..4e07ca8 100644
@@ -314,6 +314,7 @@ struct gve_priv {
 	uint32_t adminq_report_link_speed_cnt;
 	uint32_t adminq_get_ptype_map_cnt;
 	uint32_t adminq_verify_driver_compatibility_cnt;
+	uint32_t adminq_cfg_flow_rule_cnt;
 	volatile uint32_t state_flags;
 
 	/* Gvnic device link speed from hypervisor. */
drivers/net/gve/gve_flow_rule.h new file +59 -0

59 lines not on this page · raw message

Signature · 1 line
2.53.0.473.g4a7958ca14-goog
#4 lore raw

PATCH 4/4 net/gve: add rte flow API integration

In reply to Jasper Tran O'Leary

Implement driver callbacks for the following rte flow operations:
create, destroy, and flush. This change enables receive flow steering (RFS) for n-tuple based flow rules for the gve driver.

The implementation supports matching ingress IPv4/IPv6 traffic combined with TCP, UDP, SCTP, ESP, or AH protocols. Supported fields for matching include IP source/destination addresses, L4 source/destination ports (for TCP/UDP/SCTP), and SPI (for ESP/AH). The only supported action is RTE_FLOW_ACTION_TYPE_QUEUE, which steers matching packets to a specified rx queue.

---
 doc/guides/nics/features/gve.ini       |  12 +
 doc/guides/nics/gve.rst                |  20 +
 doc/guides/rel_notes/release_26_03.rst |   1 +
 drivers/net/gve/base/gve.h             |   3 +-
 drivers/net/gve/gve_ethdev.c           |  87 +++-
 drivers/net/gve/gve_ethdev.h           |  43 ++
 drivers/net/gve/gve_flow_rule.c        | 645 +++++++++++++++++++++++++
 drivers/net/gve/gve_flow_rule.h        |   5 +
 drivers/net/gve/meson.build            |   1 +
 9 files changed, 815 insertions(+), 2 deletions(-)
 create mode 100644 dpdk/drivers/net/gve/gve_flow_rule.c
doc/guides/nics/features/gve.ini +12 -0
index ed040a0..89c97fd 100644
@@ -19,3 +19,15 @@ Linux                = Y
 x86-32               = Y
 x86-64               = Y
 Usage doc            = Y
+
+[rte_flow items]
+ah                   = Y
+esp                  = Y
+ipv4                 = Y
+ipv6                 = Y
+sctp                 = Y
+tcp                  = Y
+udp                  = Y
+
+[rte_flow actions]
+queue                = Y
doc/guides/nics/gve.rst +20 -0
index 6b4d1f7..59e0066 100644
@@ -103,6 +103,26 @@ the redirection table will be available for querying upon initial hash configura
 When performing redirection table updates,
 it is possible to update individual table entries.
 
+Flow Steering
+^^^^^^^^^^^^^
+
+The driver supports receive flow steering (RFS) via the standard ``rte_flow``
+API. This allows applications to steer traffic to specific queues based on
+5-tuple matching. 3-tuple matching may be supported in future releases.
+
+Supported Patterns:
+  - IPv4/IPv6 source and destination addresses.
+  - TCP/UDP/SCTP source and destination ports.
+  - ESP/AH SPI.
+
+Supported Actions:
+  - ``RTE_FLOW_ACTION_TYPE_QUEUE``: Steer packets to a specific Rx queue.
+
+Limitations:
+  - Only ingress flow rules are supported.
+  - Flow priorities are not supported (must be 0).
+  - Masking is limited to full matches i.e. 0x00...0 or 0xFF...F.
+
 Application-Initiated Reset
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 

The driver allows an application to reset the gVNIC device.

doc/guides/rel_notes/release_26_03.rst +1 -0
index 1855d90..e45ed27 100644
@@ -78,6 +78,7 @@ New Features
 * **Updated Google Virtual Ethernet (gve) driver.**
 
   * Added application-initiated device reset.
+  * Add support for receive flow steering.
 
 * **Updated Intel iavf driver.**
 
drivers/net/gve/base/gve.h +2 -1
index 99514cb..18363fa 100644
@@ -50,7 +50,8 @@ enum gve_state_flags_bit {
 	GVE_PRIV_FLAGS_ADMIN_QUEUE_OK		= 1,
 	GVE_PRIV_FLAGS_DEVICE_RESOURCES_OK	= 2,
 	GVE_PRIV_FLAGS_DEVICE_RINGS_OK		= 3,
-	GVE_PRIV_FLAGS_NAPI_ENABLED		= 4,
+	GVE_PRIV_FLAGS_FLOW_SUBSYSTEM_OK	= 4,
+	GVE_PRIV_FLAGS_NAPI_ENABLED		= 5,
 };
 
 enum gve_rss_hash_algorithm {
drivers/net/gve/gve_ethdev.c +86 -1

141 lines not on this page · raw message

drivers/net/gve/gve_ethdev.h +43 -0

68 lines not on this page · raw message

drivers/net/gve/gve_flow_rule.c new file +645 -0

645 lines not on this page · raw message

drivers/net/gve/gve_flow_rule.h +5 -0
index d1a2622..d483914 100644
@@ -56,4 +56,9 @@ struct gve_flow_rule_params {
 	struct gve_flow_spec mask;
 };
 
+struct gve_priv;
+
+int gve_flow_init_bmp(struct gve_priv *priv);
+int gve_free_flow_rules(struct gve_priv *priv);
+
 #endif /* _GVE_FLOW_RULE_H_ */
drivers/net/gve/meson.build +1 -0
index c6a9f36..7074988 100644
@@ -16,5 +16,6 @@ sources = files(
         'gve_ethdev.c',
         'gve_version.c',
         'gve_rss.c',
+        'gve_flow_rule.c',
 )
 includes += include_directories('base')
Signature · 1 line
2.53.0.473.g4a7958ca14-goog
#5 lore raw
In reply to Jasper Tran O'Leary
Quoted 35 lines · On Fri, 27 Feb 2026 19:51:22 +0000 "Jasper Tran O'Leary"…

This patch series adds flow steering support to the Google Virtual Ethernet (gve) driver. This functionality allows traffic to be directed to specific receive queues based on user-specified flow patterns.

The series includes foundational support for extended admin queue commands needed to handle flow rules, the specific adminqueue commands for flow rule management, and the integration with the DPDK rte_flow API. The series adds support flow matching on the following protocols:
IPv4, IPv6, TCP, UDP, SCTP, ESP, and AH.

Patch Overview:

1. "net/gve: add flow steering device option" checks for and enables the flow steering capability in the device options during initialization.
2. "net/gve: introduce extended adminq command" adds infrastructure for sending extended admin queue commands. These commands use a flexible buffer descriptor format required for flow rule management.
3. "net/gve: add adminq commands for flow steering" implements the specific admin queue commands to add and remove flow rules on the device, including handling of rule IDs and parameters.
4. "net/gve: add rte flow API integration" exposes the flow steering functionality via the DPDK rte_flow API. This includes strict pattern validation, rule parsing, and lifecycle management (create, destroy, flush). It ensures thread-safe access to the flow subsystem and proper resource cleanup during device reset.

Jasper Tran O'Leary (2):
net/gve: add adminq commands for flow steering
net/gve: add rte flow API integration

Vee Agarwal (2):
net/gve: add flow steering device option
net/gve: introduce extended adminq command

Quoted 15 lines
 doc/guides/nics/features/gve.ini       |  12 +
 doc/guides/nics/gve.rst                |  20 +
 doc/guides/rel_notes/release_26_03.rst |   1 +
 drivers/net/gve/base/gve.h             |   3 +-
 drivers/net/gve/base/gve_adminq.c      | 118 ++++-
 drivers/net/gve/base/gve_adminq.h      |  57 +++
 drivers/net/gve/gve_ethdev.c           |  87 +++-
 drivers/net/gve/gve_ethdev.h           |  46 ++
 drivers/net/gve/gve_flow_rule.c        | 645 +++++++++++++++++++++++++
 drivers/net/gve/gve_flow_rule.h        |  64 +++
 drivers/net/gve/meson.build            |   1 +
 11 files changed, 1049 insertions(+), 5 deletions(-)
 create mode 100644 dpdk/drivers/net/gve/gve_flow_rule.c
 create mode 100644 dpdk/drivers/net/gve/gve_flow_rule.h

There is a lot here, so sent AI to take a look.

Summary:
Error 1 — Resource leak: If gve_flush_flow_rules fails and disables the flow subsystem via gve_clear_flow_subsystem_ok(), the bitmap memory (avail_flow_rule_bmp_mem) is never freed because both gve_dev_close and gve_dev_reset gate their teardown on gve_get_flow_subsystem_ok() returning true. The guard needs to check for allocated memory rather than subsystem state.

Error 2 — pthread_mutex_init with NULL attributes in shared memory: The flow_rule_lock lives in dev_private (DPDK shared memory) but is initialized without PTHREAD_PROCESS_SHARED. This will cause undefined behavior with secondary processes. Switching to rte_spinlock_t would be the simplest fix since the critical sections are short (bitmap scan + TAILQ operations).

Patches 1–3 are clean. The overall structure and error handling in patch 4 is solid — the allocation-before-lock pattern, bitmap rollback on adminq failure, and defense-in-depth validation in destroy are all well done. Long form:
# Code Review: GVE Flow Steering Patch Series (4 patches)

**Series**: [PATCH 1/4] through [PATCH 4/4]
**Author**: Jasper Tran O'Leary / Vee Agarwal (Google) **Subject**: Add receive flow steering (RFS) support to the GVE driver

---

## Summary

This series adds n-tuple flow steering to the GVE (Google Virtual Ethernet) driver via the rte_flow API. The implementation is cleanly structured across four patches: device option discovery (1/4), extended adminq infrastructure (2/4), flow rule adminq commands (3/4), and full rte_flow integration (4/4). The code quality is generally good with thorough validation, proper locking, and well-structured error handling.

Two correctness issues were identified: a resource leak when the flow subsystem is disabled on error, and a missing PTHREAD_PROCESS_SHARED attribute on a mutex in shared memory.

---

## Patch 1/4: net/gve: add flow steering device option

### Errors

None.

### Warnings

None.

This patch is clean. The device option parsing follows the established pattern for existing options (modify_ring, jumbo_frames), the byte-swap of max_flow_rules is correct, and the zero-check on the big-endian value before byte-swap is valid (non-zero in any byte order is still non-zero).

---

## Patch 2/4: net/gve: introduce extended adminq command

### Errors

None.

### Warnings

None.

The extended command mechanism is straightforward: allocate DMA memory for the inner command, copy the command in, set up the outer wrapper with the DMA address, execute, and free. The error path is correct — gve_free_dma_mem is called after gve_adminq_execute_cmd regardless of success or failure.

---

## Patch 3/4: net/gve: add adminq commands for flow steering

### Errors

None.

### Warnings

**1. gve_flow_rule.h copyright appears to be copied from an Intel driver file.**

```c
/* SPDX-License-Identifier: BSD-3-Clause
 * Copyright(C) 2022 Intel Corporation
 */
```

This is a new file in the Google GVE driver. The Intel copyright and 2022 date look like they were carried over from whichever file was used as a template. This should be updated to reflect the actual author.

---

## Patch 4/4: net/gve: add rte flow API integration

This is the largest patch (815 lines added) and where the significant findings are.

### Errors

**1. Resource leak: bitmap memory leaked when flow subsystem is disabled on error.**

In gve_flush_flow_rules, if either gve_free_flow_rules() or gve_flow_init_bmp() fails, the code disables the subsystem:

```c
gve_clear_flow_subsystem_ok(priv);
```

However, in both gve_dev_close and gve_dev_reset, teardown is gated on the flag:

```c
if (gve_get_flow_subsystem_ok(priv))
    gve_teardown_flow_subsystem(priv);
```

If the subsystem was disabled by a failed flush, gve_teardown_flow_subsystem is never called, and priv->avail_flow_rule_bmp_mem is never freed. This is a memory leak.

**Suggested fix**: Either (a) always call gve_flow_free_bmp(priv) in close/reset regardless of the flag, or (b) have the flush error path free the bitmap memory itself, or (c) unconditionally call teardown in close/reset:

```c
/* In gve_dev_close / gve_dev_reset: */
if (priv->avail_flow_rule_bmp_mem)
    gve_teardown_flow_subsystem(priv);
```

**2. pthread_mutex_init without PTHREAD_PROCESS_SHARED on a mutex in shared memory.**

In gve_dev_init:

```c
pthread_mutex_init(&priv->flow_rule_lock, NULL);
```

priv is dev->data->dev_private, which is allocated in DPDK shared memory accessible by both primary and secondary processes. A pthread mutex in shared memory initialized with NULL attributes has undefined behavior when used across processes. It may appear to work in testing but fail in production with secondary processes.

**Suggested fix**: Either use PTHREAD_PROCESS_SHARED:

```c
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);
pthread_mutex_init(&priv->flow_rule_lock, &attr);
pthread_mutexattr_destroy(&attr);
```

Or switch to rte_spinlock_t which works correctly in shared memory without special initialization (appropriate here since the critical sections are short — bitmap scan, TAILQ insert/remove):

```c
rte_spinlock_t flow_rule_lock;
/* ... */
rte_spinlock_init(&priv->flow_rule_lock);
```

### Warnings

**3. Implicit pointer comparisons throughout gve_flow_rule.c.**

Several places use !pointer instead of pointer == NULL:

```c
if (!flow) {          /* line ~1641, ~1710 */
if (!action->conf) {  /* line ~1510 */
if (!attr) {          /* line ~1173 */
if (!actions) {       /* line ~1498 */
if (!pattern) {       /* line ~1329 */
```

DPDK coding style requires explicit comparison with NULL for pointers. The idiomatic form is if (flow == NULL).

**4. rte_zmalloc used for flow rule metadata that does not require hugepage memory.**

The gve_flow structs (8 bytes: a uint32_t + TAILQ pointers) are allocated via rte_zmalloc. These are small control-plane structures not accessed by DMA and not requiring NUMA placement. Standard malloc would be more appropriate per DPDK guidelines and would not consume limited hugepage resources.

Similarly, priv->avail_flow_rule_bmp_mem is allocated with rte_zmalloc. Since rte_bitmap may require specific alignment, this one is more defensible, but worth considering whether standard allocation would suffice.

**5. Standalone rte_atomic_thread_fence() in flow subsystem flag accessors.**

The gve_get_flow_subsystem_ok / gve_set_flow_subsystem_ok / gve_clear_flow_subsystem_ok functions use standalone fences with rte_bit_relaxed_* operations:

```c
static inline bool
gve_get_flow_subsystem_ok(struct gve_priv *priv)
{
    bool ret;
    ret = !!rte_bit_relaxed_get32(GVE_PRIV_FLAGS_FLOW_SUBSYSTEM_OK,
                                  &priv->state_flags);
    rte_atomic_thread_fence(rte_memory_order_acquire);
    return ret;
}
```

These follow the existing pattern for other state flags in the driver, so this is consistent. However, it's worth noting that in every call site in this patch, the flag is checked while holding flow_rule_lock, which already provides the necessary memory ordering. The fences are redundant in those paths (but harmless).

**6. RST documentation uses simple bullet lists where definition lists would be cleaner.**

In doc/guides/nics/gve.rst:

```rst
Supported Patterns:
  - IPv4/IPv6 source and destination addresses.
  - TCP/UDP/SCTP source and destination ports.
  - ESP/AH SPI.
```

These term+list groupings would read better as RST definition lists. This is minor given the lists are short.

### Design Notes (Info)

**Well-structured error handling in gve_create_flow_rule**: The allocation-before-lock pattern avoids holding the mutex during memory allocation, and the free_flow_and_unlock goto label correctly handles all error paths. The bitmap-set-on-error rollback in the adminq failure case is also correct.

**gve_destroy_flow_rule double-validates flow state**: The function checks both the flow pointer for NULL and verifies rule_id < max_flow_rules before checking the bitmap. This defense-in-depth is good practice.

**IPv6 word-reversal in gve_parse_ipv6**: The comment explaining the device's expected word order is clear and the implementation correctly reverses the 32-bit words. This is the kind of hardware-specific detail that benefits from the inline comment.

---

## Cross-Patch Observations

The series is well-ordered: each patch builds incrementally and the dependencies flow naturally (device option → extended command infrastructure → flow rule commands → rte_flow integration). The documentation, feature matrix, and release notes are all updated in patch 4/4 together with the code, which is correct per DPDK guidelines.

The Co-developed-by / Signed-off-by tag sequences are correctly formatted per Linux kernel convention.

#6 lore raw

Thanks for the notes, I've addressed the issues as follows and submitted a v2 revision.

[Patch 3/4]

1. Updated copyright header in gve_flow_rule.h.

[Patch 4/4]

0. Similar to patch 3, updated the copyright header in gve_flow_rule.c.
1. Fixed the memory leak in rule flush by freeing the bitmap on flush failure. This preserves the invariant where gve_get_flow_subsystem_okay is true if and only if the flow ID bitmap and flow rule tail queue are initialized.
2. Added a mutexattr_t with PTHREAD_PROCESS_SHARED to the flow mutex initialization.
3. Changed the aforementioned instances of (!pointer) and a few others to use pointer == NULL.
4. Retained the use of rte_zmalloc for both struct gve_flow and priv->avail_flow_rule_bmp_mem because this memory is shared between processes.
5. Retained memory barriers in case we call the flag checks from non-critical paths in the future.
6. Updated the documentation to use a definition list for supported protocols, and made minor formatting adjustments to make the definition list look more natural in the flow steering subsection.

Quoted 333 lines · Stephen Hemminger
Quoted 35 lines · On Fri, 27 Feb 2026 19:51:22 +0000 "Jasper Tran O'Leary"…

This patch series adds flow steering support to the Google Virtual Ethernet (gve) driver. This functionality allows traffic to be directed to specific receive queues based on user-specified flow patterns.

The series includes foundational support for extended admin queue commands needed to handle flow rules, the specific adminqueue commands for flow rule management, and the integration with the DPDK rte_flow API. The series adds support flow matching on the following protocols:
IPv4, IPv6, TCP, UDP, SCTP, ESP, and AH.

Patch Overview:

1. "net/gve: add flow steering device option" checks for and enables the flow steering capability in the device options during initialization.
2. "net/gve: introduce extended adminq command" adds infrastructure for sending extended admin queue commands. These commands use a flexible buffer descriptor format required for flow rule management.
3. "net/gve: add adminq commands for flow steering" implements the specific admin queue commands to add and remove flow rules on the device, including handling of rule IDs and parameters.
4. "net/gve: add rte flow API integration" exposes the flow steering functionality via the DPDK rte_flow API. This includes strict pattern validation, rule parsing, and lifecycle management (create, destroy, flush). It ensures thread-safe access to the flow subsystem and proper resource cleanup during device reset.

Jasper Tran O'Leary (2):
net/gve: add adminq commands for flow steering
net/gve: add rte flow API integration

Vee Agarwal (2):
net/gve: add flow steering device option
net/gve: introduce extended adminq command

Quoted 15 lines
 doc/guides/nics/features/gve.ini       |  12 +
 doc/guides/nics/gve.rst                |  20 +
 doc/guides/rel_notes/release_26_03.rst |   1 +
 drivers/net/gve/base/gve.h             |   3 +-
 drivers/net/gve/base/gve_adminq.c      | 118 ++++-
 drivers/net/gve/base/gve_adminq.h      |  57 +++
 drivers/net/gve/gve_ethdev.c           |  87 +++-
 drivers/net/gve/gve_ethdev.h           |  46 ++
 drivers/net/gve/gve_flow_rule.c        | 645 +++++++++++++++++++++++++
 drivers/net/gve/gve_flow_rule.h        |  64 +++
 drivers/net/gve/meson.build            |   1 +
 11 files changed, 1049 insertions(+), 5 deletions(-)
 create mode 100644 dpdk/drivers/net/gve/gve_flow_rule.c
 create mode 100644 dpdk/drivers/net/gve/gve_flow_rule.h

There is a lot here, so sent AI to take a look.

Summary:
Error 1 — Resource leak: If gve_flush_flow_rules fails and disables the flow subsystem via gve_clear_flow_subsystem_ok(), the bitmap memory (avail_flow_rule_bmp_mem) is never freed because both gve_dev_close and gve_dev_reset gate their teardown on gve_get_flow_subsystem_ok() returning true. The guard needs to check for allocated memory rather than subsystem state.

Error 2 — pthread_mutex_init with NULL attributes in shared memory: The flow_rule_lock lives in dev_private (DPDK shared memory) but is initialized without PTHREAD_PROCESS_SHARED. This will cause undefined behavior with secondary processes. Switching to rte_spinlock_t would be the simplest fix since the critical sections are short (bitmap scan + TAILQ operations).

Patches 1–3 are clean. The overall structure and error handling in patch 4 is solid — the allocation-before-lock pattern, bitmap rollback on adminq failure, and defense-in-depth validation in destroy are all well done. Long form:
# Code Review: GVE Flow Steering Patch Series (4 patches)

**Series**: [PATCH 1/4] through [PATCH 4/4]
**Author**: Jasper Tran O'Leary / Vee Agarwal (Google) **Subject**: Add receive flow steering (RFS) support to the GVE driver

---

## Summary

This series adds n-tuple flow steering to the GVE (Google Virtual Ethernet) driver via the rte_flow API. The implementation is cleanly structured across four patches: device option discovery (1/4), extended adminq infrastructure (2/4), flow rule adminq commands (3/4), and full rte_flow integration (4/4). The code quality is generally good with thorough validation, proper locking, and well-structured error handling.

Two correctness issues were identified: a resource leak when the flow subsystem is disabled on error, and a missing PTHREAD_PROCESS_SHARED attribute on a mutex in shared memory.

---

## Patch 1/4: net/gve: add flow steering device option

### Errors

None.

### Warnings

None.

This patch is clean. The device option parsing follows the established pattern for existing options (modify_ring, jumbo_frames), the byte-swap of max_flow_rules is correct, and the zero-check on the big-endian value before byte-swap is valid (non-zero in any byte order is still non-zero).

---

## Patch 2/4: net/gve: introduce extended adminq command

### Errors

None.

### Warnings

None.

The extended command mechanism is straightforward: allocate DMA memory for the inner command, copy the command in, set up the outer wrapper with the DMA address, execute, and free. The error path is correct — gve_free_dma_mem is called after gve_adminq_execute_cmd regardless of success or failure.

---

## Patch 3/4: net/gve: add adminq commands for flow steering

### Errors

None.

### Warnings

**1. gve_flow_rule.h copyright appears to be copied from an Intel driver file.**

```c
/* SPDX-License-Identifier: BSD-3-Clause
 * Copyright(C) 2022 Intel Corporation
 */
```

This is a new file in the Google GVE driver. The Intel copyright and 2022 date look like they were carried over from whichever file was used as a template. This should be updated to reflect the actual author.

---

## Patch 4/4: net/gve: add rte flow API integration

This is the largest patch (815 lines added) and where the significant findings are.

### Errors

**1. Resource leak: bitmap memory leaked when flow subsystem is disabled on error.**

In gve_flush_flow_rules, if either gve_free_flow_rules() or gve_flow_init_bmp() fails, the code disables the subsystem:

```c
gve_clear_flow_subsystem_ok(priv);
```

However, in both gve_dev_close and gve_dev_reset, teardown is gated on the flag:

```c
if (gve_get_flow_subsystem_ok(priv))
    gve_teardown_flow_subsystem(priv);
```

If the subsystem was disabled by a failed flush, gve_teardown_flow_subsystem is never called, and priv->avail_flow_rule_bmp_mem is never freed. This is a memory leak.

**Suggested fix**: Either (a) always call gve_flow_free_bmp(priv) in close/reset regardless of the flag, or (b) have the flush error path free the bitmap memory itself, or (c) unconditionally call teardown in close/reset:

```c
/* In gve_dev_close / gve_dev_reset: */
if (priv->avail_flow_rule_bmp_mem)
    gve_teardown_flow_subsystem(priv);
```

**2. pthread_mutex_init without PTHREAD_PROCESS_SHARED on a mutex in shared memory.**

In gve_dev_init:

```c
pthread_mutex_init(&priv->flow_rule_lock, NULL);
```

priv is dev->data->dev_private, which is allocated in DPDK shared memory accessible by both primary and secondary processes. A pthread mutex in shared memory initialized with NULL attributes has undefined behavior when used across processes. It may appear to work in testing but fail in production with secondary processes.

**Suggested fix**: Either use PTHREAD_PROCESS_SHARED:

```c
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);
pthread_mutex_init(&priv->flow_rule_lock, &attr);
pthread_mutexattr_destroy(&attr);
```

Or switch to rte_spinlock_t which works correctly in shared memory without special initialization (appropriate here since the critical sections are short — bitmap scan, TAILQ insert/remove):

```c
rte_spinlock_t flow_rule_lock;
/* ... */
rte_spinlock_init(&priv->flow_rule_lock);
```

### Warnings

**3. Implicit pointer comparisons throughout gve_flow_rule.c.**

Several places use !pointer instead of pointer == NULL:

```c
if (!flow) {          /* line ~1641, ~1710 */
if (!action->conf) {  /* line ~1510 */
if (!attr) {          /* line ~1173 */
if (!actions) {       /* line ~1498 */
if (!pattern) {       /* line ~1329 */
```

DPDK coding style requires explicit comparison with NULL for pointers. The idiomatic form is if (flow == NULL).

**4. rte_zmalloc used for flow rule metadata that does not require hugepage memory.**

The gve_flow structs (8 bytes: a uint32_t + TAILQ pointers) are allocated via rte_zmalloc. These are small control-plane structures not accessed by DMA and not requiring NUMA placement. Standard malloc would be more appropriate per DPDK guidelines and would not consume limited hugepage resources.

Similarly, priv->avail_flow_rule_bmp_mem is allocated with rte_zmalloc. Since rte_bitmap may require specific alignment, this one is more defensible, but worth considering whether standard allocation would suffice.

**5. Standalone rte_atomic_thread_fence() in flow subsystem flag accessors.**

The gve_get_flow_subsystem_ok / gve_set_flow_subsystem_ok / gve_clear_flow_subsystem_ok functions use standalone fences with rte_bit_relaxed_* operations:

```c
static inline bool
gve_get_flow_subsystem_ok(struct gve_priv *priv)
{
    bool ret;
    ret = !!rte_bit_relaxed_get32(GVE_PRIV_FLAGS_FLOW_SUBSYSTEM_OK,
                                  &priv->state_flags);
    rte_atomic_thread_fence(rte_memory_order_acquire);
    return ret;
}
```

These follow the existing pattern for other state flags in the driver, so this is consistent. However, it's worth noting that in every call site in this patch, the flag is checked while holding flow_rule_lock, which already provides the necessary memory ordering. The fences are redundant in those paths (but harmless).

**6. RST documentation uses simple bullet lists where definition lists would be cleaner.**

In doc/guides/nics/gve.rst:

```rst
Supported Patterns:
  - IPv4/IPv6 source and destination addresses.
  - TCP/UDP/SCTP source and destination ports.
  - ESP/AH SPI.
```

These term+list groupings would read better as RST definition lists. This is minor given the lists are short.

### Design Notes (Info)

**Well-structured error handling in gve_create_flow_rule**: The allocation-before-lock pattern avoids holding the mutex during memory allocation, and the free_flow_and_unlock goto label correctly handles all error paths. The bitmap-set-on-error rollback in the adminq failure case is also correct.

**gve_destroy_flow_rule double-validates flow state**: The function checks both the flow pointer for NULL and verifies rule_id < max_flow_rules before checking the bitmap. This defense-in-depth is good practice.

**IPv6 word-reversal in gve_parse_ipv6**: The comment explaining the device's expected word order is clear and the implementation correctly reverses the 32-bit words. This is the kind of hardware-specific detail that benefits from the inline comment.

---

## Cross-Patch Observations

The series is well-ordered: each patch builds incrementally and the dependencies flow naturally (device option → extended command infrastructure → flow rule commands → rte_flow integration). The documentation, feature matrix, and release notes are all updated in patch 4/4 together with the code, which is correct per DPDK guidelines.

The Co-developed-by / Signed-off-by tag sequences are correctly formatted per Linux kernel convention.

#7 lore raw

v2 cover net/gve: add flow steering support

In reply to Jasper Tran O'Leary

This patch series adds flow steering support to the Google Virtual Ethernet (gve) driver. This functionality allows traffic to be directed to specific receive queues based on user-specified flow patterns.

The series includes foundational support for extended admin queue commands needed to handle flow rules, the specific adminqueue commands for flow rule management, and the integration with the DPDK rte_flow API. The series adds support flow matching on the following protocols:
IPv4, IPv6, TCP, UDP, SCTP, ESP, and AH.

Patch Overview:

1. "net/gve: add flow steering device option" checks for and enables the flow steering capability in the device options during initialization.
2. "net/gve: introduce extended adminq command" adds infrastructure for sending extended admin queue commands. These commands use a flexible buffer descriptor format required for flow rule management.
3. "net/gve: add adminq commands for flow steering" implements the specific admin queue commands to add and remove flow rules on the device, including handling of rule IDs and parameters.
4. "net/gve: add rte flow API integration" exposes the flow steering functionality via the DPDK rte_flow API. This includes strict pattern validation, rule parsing, and lifecycle management (create, destroy, flush). It ensures thread-safe access to the flow subsystem and proper resource cleanup during device reset.

Jasper Tran O'Leary (2):
net/gve: add adminq commands for flow steering
net/gve: add rte flow API integration

Vee Agarwal (2):
net/gve: add flow steering device option
net/gve: introduce extended adminq command

 doc/guides/nics/features/gve.ini       |  12 +
 doc/guides/nics/gve.rst                |  26 +
 doc/guides/rel_notes/release_26_03.rst |   1 +
 drivers/net/gve/base/gve.h             |   3 +-
 drivers/net/gve/base/gve_adminq.c      | 118 ++++-
 drivers/net/gve/base/gve_adminq.h      |  57 +++
 drivers/net/gve/gve_ethdev.c           |  83 +++-
 drivers/net/gve/gve_ethdev.h           |  46 ++
 drivers/net/gve/gve_flow_rule.c        | 656 +++++++++++++++++++++++++
 drivers/net/gve/gve_flow_rule.h        |  65 +++
 drivers/net/gve/meson.build            |   1 +
 11 files changed, 1063 insertions(+), 5 deletions(-)
 create mode 100644 dpdk/drivers/net/gve/gve_flow_rule.c
 create mode 100644 dpdk/drivers/net/gve/gve_flow_rule.h
Signature · 1 line
2.53.0.473.g4a7958ca14-goog
#8 lore raw

PATCH v2 1/4 net/gve: add flow steering device option

From: Vee Agarwal <[email protected]>

Add a new device option to signal to the driver that the device supports flow steering. This device option also carries the maximum number of flow steering rules that the device can store.

---
 drivers/net/gve/base/gve_adminq.c | 36 ++++++++++++++++++++++++++++---
 drivers/net/gve/base/gve_adminq.h | 11 ++++++++++
 drivers/net/gve/gve_ethdev.h      |  2 ++
 3 files changed, 46 insertions(+), 3 deletions(-)
drivers/net/gve/base/gve_adminq.c +33 -3
index 6bd98d5..64b9468 100644
@@ -36,6 +36,7 @@ void gve_parse_device_option(struct gve_priv *priv,
 			     struct gve_device_option_gqi_rda **dev_op_gqi_rda,
 			     struct gve_device_option_gqi_qpl **dev_op_gqi_qpl,
 			     struct gve_device_option_dqo_rda **dev_op_dqo_rda,
+			     struct gve_device_option_flow_steering **dev_op_flow_steering,
 			     struct gve_device_option_modify_ring **dev_op_modify_ring,
 			     struct gve_device_option_jumbo_frames **dev_op_jumbo_frames)
 {
@@ -109,6 +110,22 @@ void gve_parse_device_option(struct gve_priv *priv,
 		}
 		*dev_op_dqo_rda = RTE_PTR_ADD(option, sizeof(*option));
 		break;
+	case GVE_DEV_OPT_ID_FLOW_STEERING:
+		if (option_length < sizeof(**dev_op_flow_steering) ||
+		    req_feat_mask != GVE_DEV_OPT_REQ_FEAT_MASK_FLOW_STEERING) {
+			PMD_DRV_LOG(WARNING, GVE_DEVICE_OPTION_ERROR_FMT,
+				    "Flow Steering", (int)sizeof(**dev_op_flow_steering),
+				    GVE_DEV_OPT_REQ_FEAT_MASK_FLOW_STEERING,
+				    option_length, req_feat_mask);
+			break;
+		}
+
+		if (option_length > sizeof(**dev_op_flow_steering)) {
+			PMD_DRV_LOG(WARNING,
+				    GVE_DEVICE_OPTION_TOO_BIG_FMT, "Flow Steering");
+		}
+		*dev_op_flow_steering = RTE_PTR_ADD(option, sizeof(*option));
+		break;
 	case GVE_DEV_OPT_ID_MODIFY_RING:
 		/* Min ring size bound is optional. */
 		if (option_length < (sizeof(**dev_op_modify_ring) -
@@ -167,6 +184,7 @@ gve_process_device_options(struct gve_priv *priv,
 			   struct gve_device_option_gqi_rda **dev_op_gqi_rda,
 			   struct gve_device_option_gqi_qpl **dev_op_gqi_qpl,
 			   struct gve_device_option_dqo_rda **dev_op_dqo_rda,
+			   struct gve_device_option_flow_steering **dev_op_flow_steering,
 			   struct gve_device_option_modify_ring **dev_op_modify_ring,
 			   struct gve_device_option_jumbo_frames **dev_op_jumbo_frames)
 {
@@ -188,8 +206,8 @@ gve_process_device_options(struct gve_priv *priv,
 
 		gve_parse_device_option(priv, dev_opt,
 					dev_op_gqi_rda, dev_op_gqi_qpl,
-					dev_op_dqo_rda, dev_op_modify_ring,
-					dev_op_jumbo_frames);
+					dev_op_dqo_rda, dev_op_flow_steering,
+					dev_op_modify_ring, dev_op_jumbo_frames);
 		dev_opt = next_opt;
 	}
 
@@ -777,9 +795,19 @@ gve_set_max_desc_cnt(struct gve_priv *priv,
 
 static void gve_enable_supported_features(struct gve_priv *priv,
 	u32 supported_features_mask,
+	const struct gve_device_option_flow_steering *dev_op_flow_steering,
 	const struct gve_device_option_modify_ring *dev_op_modify_ring,
 	const struct gve_device_option_jumbo_frames *dev_op_jumbo_frames)
 {
+	if (dev_op_flow_steering &&
+	    (supported_features_mask & GVE_SUP_FLOW_STEERING_MASK) &&
+	    dev_op_flow_steering->max_flow_rules) {
+		priv->max_flow_rules =
+			be32_to_cpu(dev_op_flow_steering->max_flow_rules);
+		PMD_DRV_LOG(INFO,
+			    "FLOW STEERING device option enabled with max rule limit of %u.",
+			    priv->max_flow_rules);
+	}
 	if (dev_op_modify_ring &&
 	    (supported_features_mask & GVE_SUP_MODIFY_RING_MASK)) {
 		PMD_DRV_LOG(INFO, "MODIFY RING device option enabled.");
@@ -802,6 +830,7 @@ int gve_adminq_describe_device(struct gve_priv *priv)
 {
 	struct gve_device_option_jumbo_frames *dev_op_jumbo_frames = NULL;
 	struct gve_device_option_modify_ring *dev_op_modify_ring = NULL;
+	struct gve_device_option_flow_steering *dev_op_flow_steering = NULL;
 	struct gve_device_option_gqi_rda *dev_op_gqi_rda = NULL;
 	struct gve_device_option_gqi_qpl *dev_op_gqi_qpl = NULL;
 	struct gve_device_option_dqo_rda *dev_op_dqo_rda = NULL;
@@ -829,6 +858,7 @@ int gve_adminq_describe_device(struct gve_priv *priv)
 
 	err = gve_process_device_options(priv, descriptor, &dev_op_gqi_rda,
 					 &dev_op_gqi_qpl, &dev_op_dqo_rda,
+					 &dev_op_flow_steering,
 					 &dev_op_modify_ring,
 					 &dev_op_jumbo_frames);
 	if (err)
@@ -884,7 +914,7 @@ int gve_adminq_describe_device(struct gve_priv *priv)
 	priv->default_num_queues = be16_to_cpu(descriptor->default_num_queues);
 
 	gve_enable_supported_features(priv, supported_features_mask,
-				      dev_op_modify_ring,
+				      dev_op_flow_steering, dev_op_modify_ring,
 				      dev_op_jumbo_frames);
 
 free_device_descriptor:
drivers/net/gve/base/gve_adminq.h +11 -0
index 6a3d469..e237353 100644
@@ -117,6 +117,14 @@ struct gve_ring_size_bound {
 
 GVE_CHECK_STRUCT_LEN(4, gve_ring_size_bound);
 
+struct gve_device_option_flow_steering {
+	__be32 supported_features_mask;
+	__be32 reserved;
+	__be32 max_flow_rules;
+};
+
+GVE_CHECK_STRUCT_LEN(12, gve_device_option_flow_steering);
+
 struct gve_device_option_modify_ring {
 	__be32 supported_features_mask;
 	struct gve_ring_size_bound max_ring_size;
@@ -148,6 +156,7 @@ enum gve_dev_opt_id {
 	GVE_DEV_OPT_ID_DQO_RDA = 0x4,
 	GVE_DEV_OPT_ID_MODIFY_RING = 0x6,
 	GVE_DEV_OPT_ID_JUMBO_FRAMES = 0x8,
+	GVE_DEV_OPT_ID_FLOW_STEERING = 0xb,
 };
 
 enum gve_dev_opt_req_feat_mask {
@@ -155,6 +164,7 @@ enum gve_dev_opt_req_feat_mask {
 	GVE_DEV_OPT_REQ_FEAT_MASK_GQI_RDA = 0x0,
 	GVE_DEV_OPT_REQ_FEAT_MASK_GQI_QPL = 0x0,
 	GVE_DEV_OPT_REQ_FEAT_MASK_DQO_RDA = 0x0,
+	GVE_DEV_OPT_REQ_FEAT_MASK_FLOW_STEERING = 0x0,
 	GVE_DEV_OPT_REQ_FEAT_MASK_MODIFY_RING = 0x0,
 	GVE_DEV_OPT_REQ_FEAT_MASK_JUMBO_FRAMES = 0x0,
 };
@@ -162,6 +172,7 @@ enum gve_dev_opt_req_feat_mask {
 enum gve_sup_feature_mask {
 	GVE_SUP_MODIFY_RING_MASK = 1 << 0,
 	GVE_SUP_JUMBO_FRAMES_MASK = 1 << 2,
+	GVE_SUP_FLOW_STEERING_MASK = 1 << 5,
 };
 
 #define GVE_DEV_OPT_LEN_GQI_RAW_ADDRESSING 0x0
drivers/net/gve/gve_ethdev.h +2 -0
index f7cc781..3a810b6 100644
@@ -332,6 +332,8 @@ struct gve_priv {
 
 	struct gve_rss_config rss_config;
 	struct gve_ptype_lut *ptype_lut_dqo;
+
+	uint32_t max_flow_rules;
 };
 
 static inline bool
Signature · 1 line
2.53.0.473.g4a7958ca14-goog
#9 lore raw

PATCH v2 2/4 net/gve: introduce extended adminq command

In reply to Jasper Tran O'Leary

From: Vee Agarwal <[email protected]>

Flow steering adminq commands are too large to fit into a normal adminq command buffer which accepts at most 56 bytes. As a result, introduce extended adminq commands which permit larger command buffers using indirection. Namely, extended command operations point to inner command buffers allocated at a specified DMA address. As specified with the device, all extended commands will use inner opcodes larger than 0xFF.

---
 drivers/net/gve/base/gve_adminq.c | 30 ++++++++++++++++++++++++++++++
 drivers/net/gve/base/gve_adminq.h | 16 ++++++++++++++++
 2 files changed, 46 insertions(+)
drivers/net/gve/base/gve_adminq.c +30 -0
index 64b9468..0cc6d44 100644
@@ -438,6 +438,8 @@ static int gve_adminq_issue_cmd(struct gve_priv *priv,
 
 	memcpy(cmd, cmd_orig, sizeof(*cmd_orig));
 	opcode = be32_to_cpu(READ_ONCE32(cmd->opcode));
+	if (opcode == GVE_ADMINQ_EXTENDED_COMMAND)
+		opcode = be32_to_cpu(READ_ONCE32(cmd->extended_command.inner_opcode));
 
 	switch (opcode) {
 	case GVE_ADMINQ_DESCRIBE_DEVICE:
@@ -516,6 +518,34 @@ static int gve_adminq_execute_cmd(struct gve_priv *priv,
 	return gve_adminq_kick_and_wait(priv);
 }
 
+static int gve_adminq_execute_extended_cmd(struct gve_priv *priv, u32 opcode,
+					   size_t cmd_size, void *cmd_orig)
+{
+	union gve_adminq_command cmd;
+	struct gve_dma_mem inner_cmd_dma_mem;
+	void *inner_cmd;
+	int err;
+
+	inner_cmd = gve_alloc_dma_mem(&inner_cmd_dma_mem, cmd_size);
+	if (!inner_cmd)
+		return -ENOMEM;
+
+	memcpy(inner_cmd, cmd_orig, cmd_size);
+
+	memset(&cmd, 0, sizeof(cmd));
+	cmd.opcode = cpu_to_be32(GVE_ADMINQ_EXTENDED_COMMAND);
+	cmd.extended_command = (struct gve_adminq_extended_command) {
+		.inner_opcode = cpu_to_be32(opcode),
+		.inner_length = cpu_to_be32(cmd_size),
+		.inner_command_addr = cpu_to_be64(inner_cmd_dma_mem.pa),
+	};
+
+	err = gve_adminq_execute_cmd(priv, &cmd);
+
+	gve_free_dma_mem(&inner_cmd_dma_mem);
+	return err;
+}
+
 /* The device specifies that the management vector can either be the first irq
  * or the last irq. ntfy_blk_msix_base_idx indicates the first irq assigned to
  * the ntfy blks. It if is 0 then the management vector is last, if it is 1 then
drivers/net/gve/base/gve_adminq.h +16 -0
index e237353..f52658e 100644
@@ -25,8 +25,15 @@ enum gve_adminq_opcodes {
 	GVE_ADMINQ_REPORT_LINK_SPEED		= 0xD,
 	GVE_ADMINQ_GET_PTYPE_MAP		= 0xE,
 	GVE_ADMINQ_VERIFY_DRIVER_COMPATIBILITY	= 0xF,
+	/* For commands that are larger than 56 bytes */
+	GVE_ADMINQ_EXTENDED_COMMAND		= 0xFF,
 };
 
+/* The normal adminq command is restricted to be 56 bytes at maximum. For the
+ * longer adminq command, it is wrapped by GVE_ADMINQ_EXTENDED_COMMAND with
+ * inner opcode of gve_adminq_extended_cmd_opcodes specified. The inner command
+ * is written in the dma memory allocated by GVE_ADMINQ_EXTENDED_COMMAND.
+ */
 /* Admin queue status codes */
 enum gve_adminq_statuses {
 	GVE_ADMINQ_COMMAND_UNSET			= 0x0,
@@ -194,6 +201,14 @@ enum gve_driver_capbility {
 #define GVE_DRIVER_CAPABILITY_FLAGS3 0x0
 #define GVE_DRIVER_CAPABILITY_FLAGS4 0x0
 
+struct gve_adminq_extended_command {
+	__be32 inner_opcode;
+	__be32 inner_length;
+	__be64 inner_command_addr;
+};
+
+GVE_CHECK_STRUCT_LEN(16, gve_adminq_extended_command);
+
 struct gve_driver_info {
 	u8 os_type;	/* 0x05 = DPDK */
 	u8 driver_major;
@@ -440,6 +455,7 @@ union gve_adminq_command {
 			struct gve_adminq_get_ptype_map get_ptype_map;
 			struct gve_adminq_verify_driver_compatibility
 				verify_driver_compatibility;
+			struct gve_adminq_extended_command extended_command;
 		};
 	};
 	u8 reserved[64];
Signature · 1 line
2.53.0.473.g4a7958ca14-goog
#10 lore raw

PATCH v2 3/4 net/gve: add adminq commands for flow steering

In reply to Jasper Tran O'Leary

Add new adminq commands for the driver to configure flow rules that are stored in the device. For configuring flow rules, 3 sub commands are supported.
- create: creates a new flow rule with a specific rule_id.
- destroy: deletes an existing flow rule with the specified rule_id.
- flush: clears and deletes all currently active flow rules.

---
 drivers/net/gve/base/gve_adminq.c | 52 +++++++++++++++++++++++++++
 drivers/net/gve/base/gve_adminq.h | 30 ++++++++++++++++
 drivers/net/gve/gve_ethdev.h      |  1 +
 drivers/net/gve/gve_flow_rule.h   | 59 +++++++++++++++++++++++++++++++
 4 files changed, 142 insertions(+)
 create mode 100644 dpdk/drivers/net/gve/gve_flow_rule.h
drivers/net/gve/base/gve_adminq.c +52 -0
index 0cc6d44..9a94591 100644
@@ -239,6 +239,7 @@ int gve_adminq_alloc(struct gve_priv *priv)
 	priv->adminq_report_stats_cnt = 0;
 	priv->adminq_report_link_speed_cnt = 0;
 	priv->adminq_get_ptype_map_cnt = 0;
+	priv->adminq_cfg_flow_rule_cnt = 0;
 
 	/* Setup Admin queue with the device */
 	rte_pci_read_config(priv->pci_dev, &pci_rev_id, sizeof(pci_rev_id),
@@ -487,6 +488,9 @@ static int gve_adminq_issue_cmd(struct gve_priv *priv,
 	case GVE_ADMINQ_VERIFY_DRIVER_COMPATIBILITY:
 		priv->adminq_verify_driver_compatibility_cnt++;
 		break;
+	case GVE_ADMINQ_CONFIGURE_FLOW_RULE:
+		priv->adminq_cfg_flow_rule_cnt++;
+		break;
 	default:
 		PMD_DRV_LOG(ERR, "unknown AQ command opcode %d", opcode);
 	}
@@ -546,6 +550,54 @@ static int gve_adminq_execute_extended_cmd(struct gve_priv *priv, u32 opcode,
 	return err;
 }
 
+static int
+gve_adminq_configure_flow_rule(struct gve_priv *priv,
+			       struct gve_adminq_configure_flow_rule *flow_rule_cmd)
+{
+	int err = gve_adminq_execute_extended_cmd(priv,
+			GVE_ADMINQ_CONFIGURE_FLOW_RULE,
+			sizeof(struct gve_adminq_configure_flow_rule),
+			flow_rule_cmd);
+
+	return err;
+}
+
+int gve_adminq_add_flow_rule(struct gve_priv *priv,
+			     struct gve_flow_rule_params *rule, u32 loc)
+{
+	struct gve_adminq_configure_flow_rule flow_rule_cmd = {
+		.opcode = cpu_to_be16(GVE_FLOW_RULE_CFG_ADD),
+		.location = cpu_to_be32(loc),
+		.rule = {
+			.flow_type = cpu_to_be16(rule->flow_type),
+			.action = cpu_to_be16(rule->action),
+			.key = rule->key,
+			.mask = rule->mask,
+		},
+	};
+
+	return gve_adminq_configure_flow_rule(priv, &flow_rule_cmd);
+}
+
+int gve_adminq_del_flow_rule(struct gve_priv *priv, u32 loc)
+{
+	struct gve_adminq_configure_flow_rule flow_rule_cmd = {
+		.opcode = cpu_to_be16(GVE_FLOW_RULE_CFG_DEL),
+		.location = cpu_to_be32(loc),
+	};
+
+	return gve_adminq_configure_flow_rule(priv, &flow_rule_cmd);
+}
+
+int gve_adminq_reset_flow_rules(struct gve_priv *priv)
+{
+	struct gve_adminq_configure_flow_rule flow_rule_cmd = {
+		.opcode = cpu_to_be16(GVE_FLOW_RULE_CFG_RESET),
+	};
+
+	return gve_adminq_configure_flow_rule(priv, &flow_rule_cmd);
+}
+
 /* The device specifies that the management vector can either be the first irq
  * or the last irq. ntfy_blk_msix_base_idx indicates the first irq assigned to
  * the ntfy blks. It if is 0 then the management vector is last, if it is 1 then
drivers/net/gve/base/gve_adminq.h +30 -0
index f52658e..d8e5e6a 100644
@@ -7,6 +7,7 @@
 #define _GVE_ADMINQ_H
 
 #include "gve_osdep.h"
+#include "../gve_flow_rule.h"
 
 /* Admin queue opcodes */
 enum gve_adminq_opcodes {
@@ -34,6 +35,10 @@ enum gve_adminq_opcodes {
  * inner opcode of gve_adminq_extended_cmd_opcodes specified. The inner command
  * is written in the dma memory allocated by GVE_ADMINQ_EXTENDED_COMMAND.
  */
+enum gve_adminq_extended_cmd_opcodes {
+	GVE_ADMINQ_CONFIGURE_FLOW_RULE	= 0x101,
+};
+
 /* Admin queue status codes */
 enum gve_adminq_statuses {
 	GVE_ADMINQ_COMMAND_UNSET			= 0x0,
@@ -434,6 +439,26 @@ struct gve_adminq_configure_rss {
 	__be64 indir_addr;
 };
 
+/* Flow rule definition for the admin queue using network byte order (big
+ * endian). This struct represents the hardware wire format and should not be
+ * used outside of admin queue contexts.
+ */
+struct gve_adminq_flow_rule {
+	__be16 flow_type;
+	__be16 action; /* RX queue id */
+	struct gve_flow_spec key;
+	struct gve_flow_spec mask;
+};
+
+struct gve_adminq_configure_flow_rule {
+	__be16 opcode;
+	u8 padding[2];
+	struct gve_adminq_flow_rule rule;
+	__be32 location;
+};
+
+GVE_CHECK_STRUCT_LEN(92, gve_adminq_configure_flow_rule);
+
 union gve_adminq_command {
 	struct {
 		__be32 opcode;
@@ -499,4 +524,9 @@ int gve_adminq_verify_driver_compatibility(struct gve_priv *priv,
 int gve_adminq_configure_rss(struct gve_priv *priv,
 			     struct gve_rss_config *rss_config);
 
+int gve_adminq_add_flow_rule(struct gve_priv *priv,
+			     struct gve_flow_rule_params *rule, u32 loc);
+int gve_adminq_del_flow_rule(struct gve_priv *priv, u32 loc);
+int gve_adminq_reset_flow_rules(struct gve_priv *priv);
+
 #endif /* _GVE_ADMINQ_H */
drivers/net/gve/gve_ethdev.h +1 -0
index 3a810b6..4e07ca8 100644
@@ -314,6 +314,7 @@ struct gve_priv {
 	uint32_t adminq_report_link_speed_cnt;
 	uint32_t adminq_get_ptype_map_cnt;
 	uint32_t adminq_verify_driver_compatibility_cnt;
+	uint32_t adminq_cfg_flow_rule_cnt;
 	volatile uint32_t state_flags;
 
 	/* Gvnic device link speed from hypervisor. */
drivers/net/gve/gve_flow_rule.h new file +59 -0

59 lines not on this page · raw message

Signature · 1 line
2.53.0.473.g4a7958ca14-goog
#11 lore raw

PATCH v2 4/4 net/gve: add rte flow API integration

In reply to Jasper Tran O'Leary

Implement driver callbacks for the following rte flow operations:
create, destroy, and flush. This change enables receive flow steering (RFS) for n-tuple based flow rules for the gve driver.

The implementation supports matching ingress IPv4/IPv6 traffic combined with TCP, UDP, SCTP, ESP, or AH protocols. Supported fields for matching include IP source/destination addresses, L4 source/destination ports (for TCP/UDP/SCTP), and SPI (for ESP/AH). The only supported action is RTE_FLOW_ACTION_TYPE_QUEUE, which steers matching packets to a specified rx queue.

---
 doc/guides/nics/features/gve.ini       |  12 +
 doc/guides/nics/gve.rst                |  26 +
 doc/guides/rel_notes/release_26_03.rst |   1 +
 drivers/net/gve/base/gve.h             |   3 +-
 drivers/net/gve/gve_ethdev.c           |  83 +++-
 drivers/net/gve/gve_ethdev.h           |  43 ++
 drivers/net/gve/gve_flow_rule.c        | 656 +++++++++++++++++++++++++
 drivers/net/gve/gve_flow_rule.h        |   6 +
 drivers/net/gve/meson.build            |   1 +
 9 files changed, 829 insertions(+), 2 deletions(-)
 create mode 100644 dpdk/drivers/net/gve/gve_flow_rule.c
doc/guides/nics/features/gve.ini +12 -0
index ed040a0..89c97fd 100644
@@ -19,3 +19,15 @@ Linux                = Y
 x86-32               = Y
 x86-64               = Y
 Usage doc            = Y
+
+[rte_flow items]
+ah                   = Y
+esp                  = Y
+ipv4                 = Y
+ipv6                 = Y
+sctp                 = Y
+tcp                  = Y
+udp                  = Y
+
+[rte_flow actions]
+queue                = Y
doc/guides/nics/gve.rst +26 -0
index 6b4d1f7..64cd931 100644
@@ -103,6 +103,32 @@ the redirection table will be available for querying upon initial hash configura
 When performing redirection table updates,
 it is possible to update individual table entries.
 
+Flow Steering
+^^^^^^^^^^^^^
+
+The driver supports receive flow steering (RFS) via the standard ``rte_flow``
+API. This allows applications to steer traffic to specific queues based on
+5-tuple matching. 3-tuple matching may be supported in future releases.
+
+**Supported Patterns**
+
+L3 Protocols
+  IPv4/IPv6 source and destination addresses.
+L4 Protocols
+  TCP/UDP/SCTP source and destination ports.
+Security Protocols
+  ESP/AH SPI.
+
+**Supported Actions**
+
+- ``RTE_FLOW_ACTION_TYPE_QUEUE``: Steer packets to a specific Rx queue.
+
+**Limitations**
+
+- Only ingress flow rules are supported.
+- Flow priorities are not supported (must be 0).
+- Masking is limited to full matches i.e. 0x00...0 or 0xFF...F.
+
 Application-Initiated Reset
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 

The driver allows an application to reset the gVNIC device.

doc/guides/rel_notes/release_26_03.rst +1 -0
index 1855d90..e45ed27 100644
@@ -78,6 +78,7 @@ New Features
 * **Updated Google Virtual Ethernet (gve) driver.**
 
   * Added application-initiated device reset.
+  * Add support for receive flow steering.
 
 * **Updated Intel iavf driver.**
 
drivers/net/gve/base/gve.h +2 -1
index 99514cb..18363fa 100644
@@ -50,7 +50,8 @@ enum gve_state_flags_bit {
 	GVE_PRIV_FLAGS_ADMIN_QUEUE_OK		= 1,
 	GVE_PRIV_FLAGS_DEVICE_RESOURCES_OK	= 2,
 	GVE_PRIV_FLAGS_DEVICE_RINGS_OK		= 3,
-	GVE_PRIV_FLAGS_NAPI_ENABLED		= 4,
+	GVE_PRIV_FLAGS_FLOW_SUBSYSTEM_OK	= 4,
+	GVE_PRIV_FLAGS_NAPI_ENABLED		= 5,
 };
 
 enum gve_rss_hash_algorithm {
drivers/net/gve/gve_ethdev.c +82 -1

143 lines not on this page · raw message

drivers/net/gve/gve_ethdev.h +43 -0

68 lines not on this page · raw message

drivers/net/gve/gve_flow_rule.c new file +656 -0

656 lines not on this page · raw message

drivers/net/gve/gve_flow_rule.h +6 -0
index 8c17ddd..d597a6c 100644
@@ -56,4 +56,10 @@ struct gve_flow_rule_params {
 	struct gve_flow_spec mask;
 };
 
+struct gve_priv;
+
+int gve_flow_init_bmp(struct gve_priv *priv);
+void gve_flow_free_bmp(struct gve_priv *priv);
+int gve_free_flow_rules(struct gve_priv *priv);
+
 #endif /* _GVE_FLOW_RULE_H_ */
drivers/net/gve/meson.build +1 -0
index c6a9f36..7074988 100644
@@ -16,5 +16,6 @@ sources = files(
         'gve_ethdev.c',
         'gve_version.c',
         'gve_rss.c',
+        'gve_flow_rule.c',
 )
 includes += include_directories('base')
Signature · 1 line
2.53.0.473.g4a7958ca14-goog
#12 lore raw
In reply to Jasper Tran O'Leary
Quoted 35 lines · On Tue, 3 Mar 2026 00:58:00 +0000 "Jasper Tran O'Leary"…

This patch series adds flow steering support to the Google Virtual Ethernet (gve) driver. This functionality allows traffic to be directed to specific receive queues based on user-specified flow patterns.

The series includes foundational support for extended admin queue commands needed to handle flow rules, the specific adminqueue commands for flow rule management, and the integration with the DPDK rte_flow API. The series adds support flow matching on the following protocols:
IPv4, IPv6, TCP, UDP, SCTP, ESP, and AH.

Patch Overview:

1. "net/gve: add flow steering device option" checks for and enables the flow steering capability in the device options during initialization.
2. "net/gve: introduce extended adminq command" adds infrastructure for sending extended admin queue commands. These commands use a flexible buffer descriptor format required for flow rule management.
3. "net/gve: add adminq commands for flow steering" implements the specific admin queue commands to add and remove flow rules on the device, including handling of rule IDs and parameters.
4. "net/gve: add rte flow API integration" exposes the flow steering functionality via the DPDK rte_flow API. This includes strict pattern validation, rule parsing, and lifecycle management (create, destroy, flush). It ensures thread-safe access to the flow subsystem and proper resource cleanup during device reset.

Jasper Tran O'Leary (2):
net/gve: add adminq commands for flow steering
net/gve: add rte flow API integration

Vee Agarwal (2):
net/gve: add flow steering device option
net/gve: introduce extended adminq command

Quoted 15 lines
 doc/guides/nics/features/gve.ini       |  12 +
 doc/guides/nics/gve.rst                |  26 +
 doc/guides/rel_notes/release_26_03.rst |   1 +
 drivers/net/gve/base/gve.h             |   3 +-
 drivers/net/gve/base/gve_adminq.c      | 118 ++++-
 drivers/net/gve/base/gve_adminq.h      |  57 +++
 drivers/net/gve/gve_ethdev.c           |  83 +++-
 drivers/net/gve/gve_ethdev.h           |  46 ++
 drivers/net/gve/gve_flow_rule.c        | 656 +++++++++++++++++++++++++
 drivers/net/gve/gve_flow_rule.h        |  65 +++
 drivers/net/gve/meson.build            |   1 +
 11 files changed, 1063 insertions(+), 5 deletions(-)
 create mode 100644 dpdk/drivers/net/gve/gve_flow_rule.c
 create mode 100644 dpdk/drivers/net/gve/gve_flow_rule.h

Automated review spotted a few things:

1. rte_bitmap_scan usage is incorrect.
2. Using rte_malloc where not necessary
3. Grammar in the release note.

I can fix the last one when merging, the second one is not a big issue but would be good to have.

---

Error: Incorrect rte_bitmap_scan usage — wrong rule ID allocation (~85% confidence)

In gve_create_flow_rule():
c

uint64_t bmp_slab __rte_unused;
...
if (rte_bitmap_scan(priv->avail_flow_rule_bmp, &flow->rule_id,

        &bmp_slab) == 1) {
    rte_bitmap_clear(priv->avail_flow_rule_bmp, flow->rule_id);
}

rte_bitmap_scan() writes the slab base position to pos and the slab bit pattern to slab. The actual bit position of the first available rule is pos + __builtin_ctzll(slab), not pos alone. The __rte_unused annotation on bmp_slab confirms the slab value is being ignored entirely.

After the first rule allocation clears bit 0, a subsequent scan returns the same slab base (pos=0) with bit 0 now clear in the slab. The code would again set rule_id=0 and attempt to clear an already-clear bit, then try to create a duplicate rule on the device.

Suggested fix:
c

uint64_t bmp_slab;
uint32_t pos;
...
if (rte_bitmap_scan(priv->avail_flow_rule_bmp, &pos,

        &bmp_slab) == 1) {
    flow->rule_id = pos + __builtin_ctzll(bmp_slab);
    rte_bitmap_clear(priv->avail_flow_rule_bmp, flow->rule_id);
}

Warning: rte_zmalloc used for ordinary control structures

Both avail_flow_rule_bmp_mem and individual gve_flow structures are allocated with rte_zmalloc, but they don't require DMA access, NUMA placement, or multi-process shared memory. Standard calloc/malloc would be more appropriate and wouldn't consume limited hugepage resources.

Warning: Release notes tense inconsistency
rst

* Added application-initiated device reset.
+ * Add support for receive flow steering.

"Added" (past tense) vs "Add" (imperative). Both entries should use the same tense for consistency. The DPDK convention is imperative mood.

#13 lore raw

Thank you for these notes. I submitted a v3 with the following changes.

1. Fixed bit allocation in the flow rule bitmap using the suggestion given.
2. Changed rte_zmalloc/rte_free for struct gve_flow to calloc/free. In making this change, I realized that the driver currently would not support flow operations from secondary processes, so I made a note of that in gve.rst.
3. Changed both verbs to "added" to match the notes from other drivers.

Quoted 118 lines · Stephen Hemminger
Quoted 35 lines · On Tue, 3 Mar 2026 00:58:00 +0000 "Jasper Tran O'Leary"…

This patch series adds flow steering support to the Google Virtual Ethernet (gve) driver. This functionality allows traffic to be directed to specific receive queues based on user-specified flow patterns.

The series includes foundational support for extended admin queue commands needed to handle flow rules, the specific adminqueue commands for flow rule management, and the integration with the DPDK rte_flow API. The series adds support flow matching on the following protocols:
IPv4, IPv6, TCP, UDP, SCTP, ESP, and AH.

Patch Overview:

1. "net/gve: add flow steering device option" checks for and enables the flow steering capability in the device options during initialization.
2. "net/gve: introduce extended adminq command" adds infrastructure for sending extended admin queue commands. These commands use a flexible buffer descriptor format required for flow rule management.
3. "net/gve: add adminq commands for flow steering" implements the specific admin queue commands to add and remove flow rules on the device, including handling of rule IDs and parameters.
4. "net/gve: add rte flow API integration" exposes the flow steering functionality via the DPDK rte_flow API. This includes strict pattern validation, rule parsing, and lifecycle management (create, destroy, flush). It ensures thread-safe access to the flow subsystem and proper resource cleanup during device reset.

Jasper Tran O'Leary (2):
net/gve: add adminq commands for flow steering
net/gve: add rte flow API integration

Vee Agarwal (2):
net/gve: add flow steering device option
net/gve: introduce extended adminq command

Quoted 15 lines
 doc/guides/nics/features/gve.ini       |  12 +
 doc/guides/nics/gve.rst                |  26 +
 doc/guides/rel_notes/release_26_03.rst |   1 +
 drivers/net/gve/base/gve.h             |   3 +-
 drivers/net/gve/base/gve_adminq.c      | 118 ++++-
 drivers/net/gve/base/gve_adminq.h      |  57 +++
 drivers/net/gve/gve_ethdev.c           |  83 +++-
 drivers/net/gve/gve_ethdev.h           |  46 ++
 drivers/net/gve/gve_flow_rule.c        | 656 +++++++++++++++++++++++++
 drivers/net/gve/gve_flow_rule.h        |  65 +++
 drivers/net/gve/meson.build            |   1 +
 11 files changed, 1063 insertions(+), 5 deletions(-)
 create mode 100644 dpdk/drivers/net/gve/gve_flow_rule.c
 create mode 100644 dpdk/drivers/net/gve/gve_flow_rule.h

Automated review spotted a few things:

1. rte_bitmap_scan usage is incorrect.
2. Using rte_malloc where not necessary
3. Grammar in the release note.

I can fix the last one when merging, the second one is not a big issue but would be good to have.

---

Error: Incorrect rte_bitmap_scan usage — wrong rule ID allocation (~85% confidence)

In gve_create_flow_rule():
c

uint64_t bmp_slab __rte_unused;
...
if (rte_bitmap_scan(priv->avail_flow_rule_bmp, &flow->rule_id,

        &bmp_slab) == 1) {
    rte_bitmap_clear(priv->avail_flow_rule_bmp, flow->rule_id);
}

rte_bitmap_scan() writes the slab base position to pos and the slab bit pattern to slab. The actual bit position of the first available rule is pos
+ __builtin_ctzll(slab), not pos alone. The __rte_unused annotation on bmp_slab confirms the slab value is being ignored entirely.

After the first rule allocation clears bit 0, a subsequent scan returns the same slab base (pos=0) with bit 0 now clear in the slab. The code would again set rule_id=0 and attempt to clear an already-clear bit, then try to create a duplicate rule on the device.

Suggested fix:
c

uint64_t bmp_slab;
uint32_t pos;
...
if (rte_bitmap_scan(priv->avail_flow_rule_bmp, &pos,

        &bmp_slab) == 1) {
    flow->rule_id = pos + __builtin_ctzll(bmp_slab);
    rte_bitmap_clear(priv->avail_flow_rule_bmp, flow->rule_id);
}

Warning: rte_zmalloc used for ordinary control structures

Both avail_flow_rule_bmp_mem and individual gve_flow structures are allocated with rte_zmalloc, but they don't require DMA access, NUMA placement, or multi-process shared memory. Standard calloc/malloc would be more appropriate and wouldn't consume limited hugepage resources.

Warning: Release notes tense inconsistency
rst

* Added application-initiated device reset.
+ * Add support for receive flow steering.

"Added" (past tense) vs "Add" (imperative). Both entries should use the same tense for consistency. The DPDK convention is imperative mood.

#14 lore raw

v3 cover net/gve: add flow steering support

In reply to Jasper Tran O'Leary

This patch series adds flow steering support to the Google Virtual Ethernet (gve) driver. This functionality allows traffic to be directed to specific receive queues based on user-specified flow patterns.

The series includes foundational support for extended admin queue commands needed to handle flow rules, the specific adminqueue commands for flow rule management, and the integration with the DPDK rte_flow API. The series adds support flow matching on the following protocols:
IPv4, IPv6, TCP, UDP, SCTP, ESP, and AH.

Patch Overview:

1. "net/gve: add flow steering device option" checks for and enables the flow steering capability in the device options during initialization.
2. "net/gve: introduce extended adminq command" adds infrastructure for sending extended admin queue commands. These commands use a flexible buffer descriptor format required for flow rule management.
3. "net/gve: add adminq commands for flow steering" implements the specific admin queue commands to add and remove flow rules on the device, including handling of rule IDs and parameters.
4. "net/gve: add rte flow API integration" exposes the flow steering functionality via the DPDK rte_flow API. This includes strict pattern validation, rule parsing, and lifecycle management (create, destroy, flush). It ensures thread-safe access to the flow subsystem and proper resource cleanup during device reset.

Jasper Tran O'Leary (2):
net/gve: add adminq commands for flow steering
net/gve: add rte flow API integration

Vee Agarwal (2):
net/gve: add flow steering device option
net/gve: introduce extended adminq command

 doc/guides/nics/features/gve.ini       |  12 +
 doc/guides/nics/gve.rst                |  27 +
 doc/guides/rel_notes/release_26_03.rst |   1 +
 drivers/net/gve/base/gve.h             |   3 +-
 drivers/net/gve/base/gve_adminq.c      | 118 ++++-
 drivers/net/gve/base/gve_adminq.h      |  57 +++
 drivers/net/gve/gve_ethdev.c           |  83 +++-
 drivers/net/gve/gve_ethdev.h           |  46 ++
 drivers/net/gve/gve_flow_rule.c        | 658 +++++++++++++++++++++++++
 drivers/net/gve/gve_flow_rule.h        |  65 +++
 drivers/net/gve/meson.build            |   1 +
 11 files changed, 1066 insertions(+), 5 deletions(-)
 create mode 100644 dpdk/drivers/net/gve/gve_flow_rule.c
 create mode 100644 dpdk/drivers/net/gve/gve_flow_rule.h
Signature · 1 line
2.53.0.473.g4a7958ca14-goog
#15 lore raw

PATCH v3 1/4 net/gve: add flow steering device option

From: Vee Agarwal <[email protected]>

Add a new device option to signal to the driver that the device supports flow steering. This device option also carries the maximum number of flow steering rules that the device can store.

---
 drivers/net/gve/base/gve_adminq.c | 36 ++++++++++++++++++++++++++++---
 drivers/net/gve/base/gve_adminq.h | 11 ++++++++++
 drivers/net/gve/gve_ethdev.h      |  2 ++
 3 files changed, 46 insertions(+), 3 deletions(-)
drivers/net/gve/base/gve_adminq.c +33 -3
index 6bd98d5..64b9468 100644
@@ -36,6 +36,7 @@ void gve_parse_device_option(struct gve_priv *priv,
 			     struct gve_device_option_gqi_rda **dev_op_gqi_rda,
 			     struct gve_device_option_gqi_qpl **dev_op_gqi_qpl,
 			     struct gve_device_option_dqo_rda **dev_op_dqo_rda,
+			     struct gve_device_option_flow_steering **dev_op_flow_steering,
 			     struct gve_device_option_modify_ring **dev_op_modify_ring,
 			     struct gve_device_option_jumbo_frames **dev_op_jumbo_frames)
 {
@@ -109,6 +110,22 @@ void gve_parse_device_option(struct gve_priv *priv,
 		}
 		*dev_op_dqo_rda = RTE_PTR_ADD(option, sizeof(*option));
 		break;
+	case GVE_DEV_OPT_ID_FLOW_STEERING:
+		if (option_length < sizeof(**dev_op_flow_steering) ||
+		    req_feat_mask != GVE_DEV_OPT_REQ_FEAT_MASK_FLOW_STEERING) {
+			PMD_DRV_LOG(WARNING, GVE_DEVICE_OPTION_ERROR_FMT,
+				    "Flow Steering", (int)sizeof(**dev_op_flow_steering),
+				    GVE_DEV_OPT_REQ_FEAT_MASK_FLOW_STEERING,
+				    option_length, req_feat_mask);
+			break;
+		}
+
+		if (option_length > sizeof(**dev_op_flow_steering)) {
+			PMD_DRV_LOG(WARNING,
+				    GVE_DEVICE_OPTION_TOO_BIG_FMT, "Flow Steering");
+		}
+		*dev_op_flow_steering = RTE_PTR_ADD(option, sizeof(*option));
+		break;
 	case GVE_DEV_OPT_ID_MODIFY_RING:
 		/* Min ring size bound is optional. */
 		if (option_length < (sizeof(**dev_op_modify_ring) -
@@ -167,6 +184,7 @@ gve_process_device_options(struct gve_priv *priv,
 			   struct gve_device_option_gqi_rda **dev_op_gqi_rda,
 			   struct gve_device_option_gqi_qpl **dev_op_gqi_qpl,
 			   struct gve_device_option_dqo_rda **dev_op_dqo_rda,
+			   struct gve_device_option_flow_steering **dev_op_flow_steering,
 			   struct gve_device_option_modify_ring **dev_op_modify_ring,
 			   struct gve_device_option_jumbo_frames **dev_op_jumbo_frames)
 {
@@ -188,8 +206,8 @@ gve_process_device_options(struct gve_priv *priv,
 
 		gve_parse_device_option(priv, dev_opt,
 					dev_op_gqi_rda, dev_op_gqi_qpl,
-					dev_op_dqo_rda, dev_op_modify_ring,
-					dev_op_jumbo_frames);
+					dev_op_dqo_rda, dev_op_flow_steering,
+					dev_op_modify_ring, dev_op_jumbo_frames);
 		dev_opt = next_opt;
 	}
 
@@ -777,9 +795,19 @@ gve_set_max_desc_cnt(struct gve_priv *priv,
 
 static void gve_enable_supported_features(struct gve_priv *priv,
 	u32 supported_features_mask,
+	const struct gve_device_option_flow_steering *dev_op_flow_steering,
 	const struct gve_device_option_modify_ring *dev_op_modify_ring,
 	const struct gve_device_option_jumbo_frames *dev_op_jumbo_frames)
 {
+	if (dev_op_flow_steering &&
+	    (supported_features_mask & GVE_SUP_FLOW_STEERING_MASK) &&
+	    dev_op_flow_steering->max_flow_rules) {
+		priv->max_flow_rules =
+			be32_to_cpu(dev_op_flow_steering->max_flow_rules);
+		PMD_DRV_LOG(INFO,
+			    "FLOW STEERING device option enabled with max rule limit of %u.",
+			    priv->max_flow_rules);
+	}
 	if (dev_op_modify_ring &&
 	    (supported_features_mask & GVE_SUP_MODIFY_RING_MASK)) {
 		PMD_DRV_LOG(INFO, "MODIFY RING device option enabled.");
@@ -802,6 +830,7 @@ int gve_adminq_describe_device(struct gve_priv *priv)
 {
 	struct gve_device_option_jumbo_frames *dev_op_jumbo_frames = NULL;
 	struct gve_device_option_modify_ring *dev_op_modify_ring = NULL;
+	struct gve_device_option_flow_steering *dev_op_flow_steering = NULL;
 	struct gve_device_option_gqi_rda *dev_op_gqi_rda = NULL;
 	struct gve_device_option_gqi_qpl *dev_op_gqi_qpl = NULL;
 	struct gve_device_option_dqo_rda *dev_op_dqo_rda = NULL;
@@ -829,6 +858,7 @@ int gve_adminq_describe_device(struct gve_priv *priv)
 
 	err = gve_process_device_options(priv, descriptor, &dev_op_gqi_rda,
 					 &dev_op_gqi_qpl, &dev_op_dqo_rda,
+					 &dev_op_flow_steering,
 					 &dev_op_modify_ring,
 					 &dev_op_jumbo_frames);
 	if (err)
@@ -884,7 +914,7 @@ int gve_adminq_describe_device(struct gve_priv *priv)
 	priv->default_num_queues = be16_to_cpu(descriptor->default_num_queues);
 
 	gve_enable_supported_features(priv, supported_features_mask,
-				      dev_op_modify_ring,
+				      dev_op_flow_steering, dev_op_modify_ring,
 				      dev_op_jumbo_frames);
 
 free_device_descriptor:
drivers/net/gve/base/gve_adminq.h +11 -0
index 6a3d469..e237353 100644
@@ -117,6 +117,14 @@ struct gve_ring_size_bound {
 
 GVE_CHECK_STRUCT_LEN(4, gve_ring_size_bound);
 
+struct gve_device_option_flow_steering {
+	__be32 supported_features_mask;
+	__be32 reserved;
+	__be32 max_flow_rules;
+};
+
+GVE_CHECK_STRUCT_LEN(12, gve_device_option_flow_steering);
+
 struct gve_device_option_modify_ring {
 	__be32 supported_features_mask;
 	struct gve_ring_size_bound max_ring_size;
@@ -148,6 +156,7 @@ enum gve_dev_opt_id {
 	GVE_DEV_OPT_ID_DQO_RDA = 0x4,
 	GVE_DEV_OPT_ID_MODIFY_RING = 0x6,
 	GVE_DEV_OPT_ID_JUMBO_FRAMES = 0x8,
+	GVE_DEV_OPT_ID_FLOW_STEERING = 0xb,
 };
 
 enum gve_dev_opt_req_feat_mask {
@@ -155,6 +164,7 @@ enum gve_dev_opt_req_feat_mask {
 	GVE_DEV_OPT_REQ_FEAT_MASK_GQI_RDA = 0x0,
 	GVE_DEV_OPT_REQ_FEAT_MASK_GQI_QPL = 0x0,
 	GVE_DEV_OPT_REQ_FEAT_MASK_DQO_RDA = 0x0,
+	GVE_DEV_OPT_REQ_FEAT_MASK_FLOW_STEERING = 0x0,
 	GVE_DEV_OPT_REQ_FEAT_MASK_MODIFY_RING = 0x0,
 	GVE_DEV_OPT_REQ_FEAT_MASK_JUMBO_FRAMES = 0x0,
 };
@@ -162,6 +172,7 @@ enum gve_dev_opt_req_feat_mask {
 enum gve_sup_feature_mask {
 	GVE_SUP_MODIFY_RING_MASK = 1 << 0,
 	GVE_SUP_JUMBO_FRAMES_MASK = 1 << 2,
+	GVE_SUP_FLOW_STEERING_MASK = 1 << 5,
 };
 
 #define GVE_DEV_OPT_LEN_GQI_RAW_ADDRESSING 0x0
drivers/net/gve/gve_ethdev.h +2 -0
index f7cc781..3a810b6 100644
@@ -332,6 +332,8 @@ struct gve_priv {
 
 	struct gve_rss_config rss_config;
 	struct gve_ptype_lut *ptype_lut_dqo;
+
+	uint32_t max_flow_rules;
 };
 
 static inline bool
Signature · 1 line
2.53.0.473.g4a7958ca14-goog
#16 lore raw

PATCH v3 2/4 net/gve: introduce extended adminq command

In reply to Jasper Tran O'Leary

From: Vee Agarwal <[email protected]>

Flow steering adminq commands are too large to fit into a normal adminq command buffer which accepts at most 56 bytes. As a result, introduce extended adminq commands which permit larger command buffers using indirection. Namely, extended command operations point to inner command buffers allocated at a specified DMA address. As specified with the device, all extended commands will use inner opcodes larger than 0xFF.

---
 drivers/net/gve/base/gve_adminq.c | 30 ++++++++++++++++++++++++++++++
 drivers/net/gve/base/gve_adminq.h | 16 ++++++++++++++++
 2 files changed, 46 insertions(+)
drivers/net/gve/base/gve_adminq.c +30 -0
index 64b9468..0cc6d44 100644
@@ -438,6 +438,8 @@ static int gve_adminq_issue_cmd(struct gve_priv *priv,
 
 	memcpy(cmd, cmd_orig, sizeof(*cmd_orig));
 	opcode = be32_to_cpu(READ_ONCE32(cmd->opcode));
+	if (opcode == GVE_ADMINQ_EXTENDED_COMMAND)
+		opcode = be32_to_cpu(READ_ONCE32(cmd->extended_command.inner_opcode));
 
 	switch (opcode) {
 	case GVE_ADMINQ_DESCRIBE_DEVICE:
@@ -516,6 +518,34 @@ static int gve_adminq_execute_cmd(struct gve_priv *priv,
 	return gve_adminq_kick_and_wait(priv);
 }
 
+static int gve_adminq_execute_extended_cmd(struct gve_priv *priv, u32 opcode,
+					   size_t cmd_size, void *cmd_orig)
+{
+	union gve_adminq_command cmd;
+	struct gve_dma_mem inner_cmd_dma_mem;
+	void *inner_cmd;
+	int err;
+
+	inner_cmd = gve_alloc_dma_mem(&inner_cmd_dma_mem, cmd_size);
+	if (!inner_cmd)
+		return -ENOMEM;
+
+	memcpy(inner_cmd, cmd_orig, cmd_size);
+
+	memset(&cmd, 0, sizeof(cmd));
+	cmd.opcode = cpu_to_be32(GVE_ADMINQ_EXTENDED_COMMAND);
+	cmd.extended_command = (struct gve_adminq_extended_command) {
+		.inner_opcode = cpu_to_be32(opcode),
+		.inner_length = cpu_to_be32(cmd_size),
+		.inner_command_addr = cpu_to_be64(inner_cmd_dma_mem.pa),
+	};
+
+	err = gve_adminq_execute_cmd(priv, &cmd);
+
+	gve_free_dma_mem(&inner_cmd_dma_mem);
+	return err;
+}
+
 /* The device specifies that the management vector can either be the first irq
  * or the last irq. ntfy_blk_msix_base_idx indicates the first irq assigned to
  * the ntfy blks. It if is 0 then the management vector is last, if it is 1 then
drivers/net/gve/base/gve_adminq.h +16 -0
index e237353..f52658e 100644
@@ -25,8 +25,15 @@ enum gve_adminq_opcodes {
 	GVE_ADMINQ_REPORT_LINK_SPEED		= 0xD,
 	GVE_ADMINQ_GET_PTYPE_MAP		= 0xE,
 	GVE_ADMINQ_VERIFY_DRIVER_COMPATIBILITY	= 0xF,
+	/* For commands that are larger than 56 bytes */
+	GVE_ADMINQ_EXTENDED_COMMAND		= 0xFF,
 };
 
+/* The normal adminq command is restricted to be 56 bytes at maximum. For the
+ * longer adminq command, it is wrapped by GVE_ADMINQ_EXTENDED_COMMAND with
+ * inner opcode of gve_adminq_extended_cmd_opcodes specified. The inner command
+ * is written in the dma memory allocated by GVE_ADMINQ_EXTENDED_COMMAND.
+ */
 /* Admin queue status codes */
 enum gve_adminq_statuses {
 	GVE_ADMINQ_COMMAND_UNSET			= 0x0,
@@ -194,6 +201,14 @@ enum gve_driver_capbility {
 #define GVE_DRIVER_CAPABILITY_FLAGS3 0x0
 #define GVE_DRIVER_CAPABILITY_FLAGS4 0x0
 
+struct gve_adminq_extended_command {
+	__be32 inner_opcode;
+	__be32 inner_length;
+	__be64 inner_command_addr;
+};
+
+GVE_CHECK_STRUCT_LEN(16, gve_adminq_extended_command);
+
 struct gve_driver_info {
 	u8 os_type;	/* 0x05 = DPDK */
 	u8 driver_major;
@@ -440,6 +455,7 @@ union gve_adminq_command {
 			struct gve_adminq_get_ptype_map get_ptype_map;
 			struct gve_adminq_verify_driver_compatibility
 				verify_driver_compatibility;
+			struct gve_adminq_extended_command extended_command;
 		};
 	};
 	u8 reserved[64];
Signature · 1 line
2.53.0.473.g4a7958ca14-goog
#17 lore raw

PATCH v3 3/4 net/gve: add adminq commands for flow steering

In reply to Jasper Tran O'Leary

Add new adminq commands for the driver to configure flow rules that are stored in the device. For configuring flow rules, 3 sub commands are supported.
- create: creates a new flow rule with a specific rule_id.
- destroy: deletes an existing flow rule with the specified rule_id.
- flush: clears and deletes all currently active flow rules.

---
 drivers/net/gve/base/gve_adminq.c | 52 +++++++++++++++++++++++++++
 drivers/net/gve/base/gve_adminq.h | 30 ++++++++++++++++
 drivers/net/gve/gve_ethdev.h      |  1 +
 drivers/net/gve/gve_flow_rule.h   | 59 +++++++++++++++++++++++++++++++
 4 files changed, 142 insertions(+)
 create mode 100644 dpdk/drivers/net/gve/gve_flow_rule.h
drivers/net/gve/base/gve_adminq.c +52 -0
index 0cc6d44..9a94591 100644
@@ -239,6 +239,7 @@ int gve_adminq_alloc(struct gve_priv *priv)
 	priv->adminq_report_stats_cnt = 0;
 	priv->adminq_report_link_speed_cnt = 0;
 	priv->adminq_get_ptype_map_cnt = 0;
+	priv->adminq_cfg_flow_rule_cnt = 0;
 
 	/* Setup Admin queue with the device */
 	rte_pci_read_config(priv->pci_dev, &pci_rev_id, sizeof(pci_rev_id),
@@ -487,6 +488,9 @@ static int gve_adminq_issue_cmd(struct gve_priv *priv,
 	case GVE_ADMINQ_VERIFY_DRIVER_COMPATIBILITY:
 		priv->adminq_verify_driver_compatibility_cnt++;
 		break;
+	case GVE_ADMINQ_CONFIGURE_FLOW_RULE:
+		priv->adminq_cfg_flow_rule_cnt++;
+		break;
 	default:
 		PMD_DRV_LOG(ERR, "unknown AQ command opcode %d", opcode);
 	}
@@ -546,6 +550,54 @@ static int gve_adminq_execute_extended_cmd(struct gve_priv *priv, u32 opcode,
 	return err;
 }
 
+static int
+gve_adminq_configure_flow_rule(struct gve_priv *priv,
+			       struct gve_adminq_configure_flow_rule *flow_rule_cmd)
+{
+	int err = gve_adminq_execute_extended_cmd(priv,
+			GVE_ADMINQ_CONFIGURE_FLOW_RULE,
+			sizeof(struct gve_adminq_configure_flow_rule),
+			flow_rule_cmd);
+
+	return err;
+}
+
+int gve_adminq_add_flow_rule(struct gve_priv *priv,
+			     struct gve_flow_rule_params *rule, u32 loc)
+{
+	struct gve_adminq_configure_flow_rule flow_rule_cmd = {
+		.opcode = cpu_to_be16(GVE_FLOW_RULE_CFG_ADD),
+		.location = cpu_to_be32(loc),
+		.rule = {
+			.flow_type = cpu_to_be16(rule->flow_type),
+			.action = cpu_to_be16(rule->action),
+			.key = rule->key,
+			.mask = rule->mask,
+		},
+	};
+
+	return gve_adminq_configure_flow_rule(priv, &flow_rule_cmd);
+}
+
+int gve_adminq_del_flow_rule(struct gve_priv *priv, u32 loc)
+{
+	struct gve_adminq_configure_flow_rule flow_rule_cmd = {
+		.opcode = cpu_to_be16(GVE_FLOW_RULE_CFG_DEL),
+		.location = cpu_to_be32(loc),
+	};
+
+	return gve_adminq_configure_flow_rule(priv, &flow_rule_cmd);
+}
+
+int gve_adminq_reset_flow_rules(struct gve_priv *priv)
+{
+	struct gve_adminq_configure_flow_rule flow_rule_cmd = {
+		.opcode = cpu_to_be16(GVE_FLOW_RULE_CFG_RESET),
+	};
+
+	return gve_adminq_configure_flow_rule(priv, &flow_rule_cmd);
+}
+
 /* The device specifies that the management vector can either be the first irq
  * or the last irq. ntfy_blk_msix_base_idx indicates the first irq assigned to
  * the ntfy blks. It if is 0 then the management vector is last, if it is 1 then
drivers/net/gve/base/gve_adminq.h +30 -0
index f52658e..d8e5e6a 100644
@@ -7,6 +7,7 @@
 #define _GVE_ADMINQ_H
 
 #include "gve_osdep.h"
+#include "../gve_flow_rule.h"
 
 /* Admin queue opcodes */
 enum gve_adminq_opcodes {
@@ -34,6 +35,10 @@ enum gve_adminq_opcodes {
  * inner opcode of gve_adminq_extended_cmd_opcodes specified. The inner command
  * is written in the dma memory allocated by GVE_ADMINQ_EXTENDED_COMMAND.
  */
+enum gve_adminq_extended_cmd_opcodes {
+	GVE_ADMINQ_CONFIGURE_FLOW_RULE	= 0x101,
+};
+
 /* Admin queue status codes */
 enum gve_adminq_statuses {
 	GVE_ADMINQ_COMMAND_UNSET			= 0x0,
@@ -434,6 +439,26 @@ struct gve_adminq_configure_rss {
 	__be64 indir_addr;
 };
 
+/* Flow rule definition for the admin queue using network byte order (big
+ * endian). This struct represents the hardware wire format and should not be
+ * used outside of admin queue contexts.
+ */
+struct gve_adminq_flow_rule {
+	__be16 flow_type;
+	__be16 action; /* RX queue id */
+	struct gve_flow_spec key;
+	struct gve_flow_spec mask;
+};
+
+struct gve_adminq_configure_flow_rule {
+	__be16 opcode;
+	u8 padding[2];
+	struct gve_adminq_flow_rule rule;
+	__be32 location;
+};
+
+GVE_CHECK_STRUCT_LEN(92, gve_adminq_configure_flow_rule);
+
 union gve_adminq_command {
 	struct {
 		__be32 opcode;
@@ -499,4 +524,9 @@ int gve_adminq_verify_driver_compatibility(struct gve_priv *priv,
 int gve_adminq_configure_rss(struct gve_priv *priv,
 			     struct gve_rss_config *rss_config);
 
+int gve_adminq_add_flow_rule(struct gve_priv *priv,
+			     struct gve_flow_rule_params *rule, u32 loc);
+int gve_adminq_del_flow_rule(struct gve_priv *priv, u32 loc);
+int gve_adminq_reset_flow_rules(struct gve_priv *priv);
+
 #endif /* _GVE_ADMINQ_H */
drivers/net/gve/gve_ethdev.h +1 -0
index 3a810b6..4e07ca8 100644
@@ -314,6 +314,7 @@ struct gve_priv {
 	uint32_t adminq_report_link_speed_cnt;
 	uint32_t adminq_get_ptype_map_cnt;
 	uint32_t adminq_verify_driver_compatibility_cnt;
+	uint32_t adminq_cfg_flow_rule_cnt;
 	volatile uint32_t state_flags;
 
 	/* Gvnic device link speed from hypervisor. */
drivers/net/gve/gve_flow_rule.h new file +59 -0

59 lines not on this page · raw message

Signature · 1 line
2.53.0.473.g4a7958ca14-goog
#18 lore raw

PATCH v3 4/4 net/gve: add rte flow API integration

In reply to Jasper Tran O'Leary

Implement driver callbacks for the following rte flow operations:
create, destroy, and flush. This change enables receive flow steering (RFS) for n-tuple based flow rules for the gve driver.

The implementation supports matching ingress IPv4/IPv6 traffic combined with TCP, UDP, SCTP, ESP, or AH protocols. Supported fields for matching include IP source/destination addresses, L4 source/destination ports (for TCP/UDP/SCTP), and SPI (for ESP/AH). The only supported action is RTE_FLOW_ACTION_TYPE_QUEUE, which steers matching packets to a specified rx queue.

---
 doc/guides/nics/features/gve.ini       |  12 +
 doc/guides/nics/gve.rst                |  27 +
 doc/guides/rel_notes/release_26_03.rst |   1 +
 drivers/net/gve/base/gve.h             |   3 +-
 drivers/net/gve/gve_ethdev.c           |  83 +++-
 drivers/net/gve/gve_ethdev.h           |  43 ++
 drivers/net/gve/gve_flow_rule.c        | 658 +++++++++++++++++++++++++
 drivers/net/gve/gve_flow_rule.h        |   6 +
 drivers/net/gve/meson.build            |   1 +
 9 files changed, 832 insertions(+), 2 deletions(-)
 create mode 100644 dpdk/drivers/net/gve/gve_flow_rule.c
doc/guides/nics/features/gve.ini +12 -0
index ed040a0..89c97fd 100644
@@ -19,3 +19,15 @@ Linux                = Y
 x86-32               = Y
 x86-64               = Y
 Usage doc            = Y
+
+[rte_flow items]
+ah                   = Y
+esp                  = Y
+ipv4                 = Y
+ipv6                 = Y
+sctp                 = Y
+tcp                  = Y
+udp                  = Y
+
+[rte_flow actions]
+queue                = Y
doc/guides/nics/gve.rst +27 -0
index 6b4d1f7..8367ca9 100644
@@ -103,6 +103,33 @@ the redirection table will be available for querying upon initial hash configura
 When performing redirection table updates,
 it is possible to update individual table entries.
 
+Flow Steering
+^^^^^^^^^^^^^
+
+The driver supports receive flow steering (RFS) via the standard ``rte_flow``
+API. This allows applications to steer traffic to specific queues based on
+5-tuple matching. 3-tuple matching may be supported in future releases.
+
+**Supported Patterns**
+
+L3 Protocols
+  IPv4/IPv6 source and destination addresses.
+L4 Protocols
+  TCP/UDP/SCTP source and destination ports.
+Security Protocols
+  ESP/AH SPI.
+
+**Supported Actions**
+
+- ``RTE_FLOW_ACTION_TYPE_QUEUE``: Steer packets to a specific Rx queue.
+
+**Limitations**
+
+- Flow steering operations are only supported in the primary process.
+- Only ingress flow rules are allowed.
+- Flow priorities are not supported (must be 0).
+- Masking is limited to full matches i.e. 0x00...0 or 0xFF...F.
+
 Application-Initiated Reset
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 

The driver allows an application to reset the gVNIC device.

doc/guides/rel_notes/release_26_03.rst +1 -0
index 1855d90..b643809 100644
@@ -78,6 +78,7 @@ New Features
 * **Updated Google Virtual Ethernet (gve) driver.**
 
   * Added application-initiated device reset.
+  * Added support for receive flow steering.
 
 * **Updated Intel iavf driver.**
 
drivers/net/gve/base/gve.h +2 -1
index 99514cb..18363fa 100644
@@ -50,7 +50,8 @@ enum gve_state_flags_bit {
 	GVE_PRIV_FLAGS_ADMIN_QUEUE_OK		= 1,
 	GVE_PRIV_FLAGS_DEVICE_RESOURCES_OK	= 2,
 	GVE_PRIV_FLAGS_DEVICE_RINGS_OK		= 3,
-	GVE_PRIV_FLAGS_NAPI_ENABLED		= 4,
+	GVE_PRIV_FLAGS_FLOW_SUBSYSTEM_OK	= 4,
+	GVE_PRIV_FLAGS_NAPI_ENABLED		= 5,
 };
 
 enum gve_rss_hash_algorithm {
drivers/net/gve/gve_ethdev.c +82 -1

143 lines not on this page · raw message

drivers/net/gve/gve_ethdev.h +43 -0

68 lines not on this page · raw message

drivers/net/gve/gve_flow_rule.c new file +658 -0

658 lines not on this page · raw message

drivers/net/gve/gve_flow_rule.h +6 -0
index 8c17ddd..d597a6c 100644
@@ -56,4 +56,10 @@ struct gve_flow_rule_params {
 	struct gve_flow_spec mask;
 };
 
+struct gve_priv;
+
+int gve_flow_init_bmp(struct gve_priv *priv);
+void gve_flow_free_bmp(struct gve_priv *priv);
+int gve_free_flow_rules(struct gve_priv *priv);
+
 #endif /* _GVE_FLOW_RULE_H_ */
drivers/net/gve/meson.build +1 -0
index c6a9f36..7074988 100644
@@ -16,5 +16,6 @@ sources = files(
         'gve_ethdev.c',
         'gve_version.c',
         'gve_rss.c',
+        'gve_flow_rule.c',
 )
 includes += include_directories('base')
Signature · 1 line
2.53.0.473.g4a7958ca14-goog
#20 lore raw

v4 cover net/gve: add flow steering support

In reply to Jasper Tran O'Leary

This patch series adds flow steering support to the Google Virtual Ethernet (gve) driver. This functionality allows traffic to be directed to specific receive queues based on user-specified flow patterns.

The series includes foundational support for extended admin queue commands needed to handle flow rules, the specific adminqueue commands for flow rule management, and the integration with the DPDK rte_flow API. The series adds support flow matching on the following protocols:
IPv4, IPv6, TCP, UDP, SCTP, ESP, and AH.

Patch Overview:

1. "net/gve: add flow steering device option" checks for and enables the flow steering capability in the device options during initialization.
2. "net/gve: introduce extended adminq command" adds infrastructure for sending extended admin queue commands. These commands use a flexible buffer descriptor format required for flow rule management.
3. "net/gve: add adminq commands for flow steering" implements the specific admin queue commands to add and remove flow rules on the device, including handling of rule IDs and parameters.
4. "net/gve: add rte flow API integration" exposes the flow steering functionality via the DPDK rte_flow API. This includes strict pattern validation, rule parsing, and lifecycle management (create, destroy, flush). It ensures thread-safe access to the flow subsystem and proper resource cleanup during device reset.

Jasper Tran O'Leary (2):
net/gve: add adminq commands for flow steering
net/gve: add rte flow API integration

Vee Agarwal (2):
net/gve: add flow steering device option
net/gve: introduce extended adminq command

 doc/guides/nics/features/gve.ini       |  12 +
 doc/guides/nics/gve.rst                |  27 +
 doc/guides/rel_notes/release_26_03.rst |   1 +
 drivers/net/gve/base/gve.h             |   3 +-
 drivers/net/gve/base/gve_adminq.c      | 118 ++++-
 drivers/net/gve/base/gve_adminq.h      |  57 +++
 drivers/net/gve/gve_ethdev.c           |  83 +++-
 drivers/net/gve/gve_ethdev.h           |  46 ++
 drivers/net/gve/gve_flow_rule.c        | 658 +++++++++++++++++++++++++
 drivers/net/gve/gve_flow_rule.h        |  65 +++
 drivers/net/gve/meson.build            |   1 +
 11 files changed, 1066 insertions(+), 5 deletions(-)
 create mode 100644 dpdk/drivers/net/gve/gve_flow_rule.c
 create mode 100644 dpdk/drivers/net/gve/gve_flow_rule.h
Signature · 1 line
2.53.0.473.g4a7958ca14-goog
#21 lore raw

PATCH v4 1/4 net/gve: add flow steering device option

From: Vee Agarwal <[email protected]>

Add a new device option to signal to the driver that the device supports flow steering. This device option also carries the maximum number of flow steering rules that the device can store.

---
 drivers/net/gve/base/gve_adminq.c | 36 ++++++++++++++++++++++++++++---
 drivers/net/gve/base/gve_adminq.h | 11 ++++++++++
 drivers/net/gve/gve_ethdev.h      |  2 ++
 3 files changed, 46 insertions(+), 3 deletions(-)
drivers/net/gve/base/gve_adminq.c +33 -3
index 6bd98d5..64b9468 100644
@@ -36,6 +36,7 @@ void gve_parse_device_option(struct gve_priv *priv,
 			     struct gve_device_option_gqi_rda **dev_op_gqi_rda,
 			     struct gve_device_option_gqi_qpl **dev_op_gqi_qpl,
 			     struct gve_device_option_dqo_rda **dev_op_dqo_rda,
+			     struct gve_device_option_flow_steering **dev_op_flow_steering,
 			     struct gve_device_option_modify_ring **dev_op_modify_ring,
 			     struct gve_device_option_jumbo_frames **dev_op_jumbo_frames)
 {
@@ -109,6 +110,22 @@ void gve_parse_device_option(struct gve_priv *priv,
 		}
 		*dev_op_dqo_rda = RTE_PTR_ADD(option, sizeof(*option));
 		break;
+	case GVE_DEV_OPT_ID_FLOW_STEERING:
+		if (option_length < sizeof(**dev_op_flow_steering) ||
+		    req_feat_mask != GVE_DEV_OPT_REQ_FEAT_MASK_FLOW_STEERING) {
+			PMD_DRV_LOG(WARNING, GVE_DEVICE_OPTION_ERROR_FMT,
+				    "Flow Steering", (int)sizeof(**dev_op_flow_steering),
+				    GVE_DEV_OPT_REQ_FEAT_MASK_FLOW_STEERING,
+				    option_length, req_feat_mask);
+			break;
+		}
+
+		if (option_length > sizeof(**dev_op_flow_steering)) {
+			PMD_DRV_LOG(WARNING,
+				    GVE_DEVICE_OPTION_TOO_BIG_FMT, "Flow Steering");
+		}
+		*dev_op_flow_steering = RTE_PTR_ADD(option, sizeof(*option));
+		break;
 	case GVE_DEV_OPT_ID_MODIFY_RING:
 		/* Min ring size bound is optional. */
 		if (option_length < (sizeof(**dev_op_modify_ring) -
@@ -167,6 +184,7 @@ gve_process_device_options(struct gve_priv *priv,
 			   struct gve_device_option_gqi_rda **dev_op_gqi_rda,
 			   struct gve_device_option_gqi_qpl **dev_op_gqi_qpl,
 			   struct gve_device_option_dqo_rda **dev_op_dqo_rda,
+			   struct gve_device_option_flow_steering **dev_op_flow_steering,
 			   struct gve_device_option_modify_ring **dev_op_modify_ring,
 			   struct gve_device_option_jumbo_frames **dev_op_jumbo_frames)
 {
@@ -188,8 +206,8 @@ gve_process_device_options(struct gve_priv *priv,
 
 		gve_parse_device_option(priv, dev_opt,
 					dev_op_gqi_rda, dev_op_gqi_qpl,
-					dev_op_dqo_rda, dev_op_modify_ring,
-					dev_op_jumbo_frames);
+					dev_op_dqo_rda, dev_op_flow_steering,
+					dev_op_modify_ring, dev_op_jumbo_frames);
 		dev_opt = next_opt;
 	}
 
@@ -777,9 +795,19 @@ gve_set_max_desc_cnt(struct gve_priv *priv,
 
 static void gve_enable_supported_features(struct gve_priv *priv,
 	u32 supported_features_mask,
+	const struct gve_device_option_flow_steering *dev_op_flow_steering,
 	const struct gve_device_option_modify_ring *dev_op_modify_ring,
 	const struct gve_device_option_jumbo_frames *dev_op_jumbo_frames)
 {
+	if (dev_op_flow_steering &&
+	    (supported_features_mask & GVE_SUP_FLOW_STEERING_MASK) &&
+	    dev_op_flow_steering->max_flow_rules) {
+		priv->max_flow_rules =
+			be32_to_cpu(dev_op_flow_steering->max_flow_rules);
+		PMD_DRV_LOG(INFO,
+			    "FLOW STEERING device option enabled with max rule limit of %u.",
+			    priv->max_flow_rules);
+	}
 	if (dev_op_modify_ring &&
 	    (supported_features_mask & GVE_SUP_MODIFY_RING_MASK)) {
 		PMD_DRV_LOG(INFO, "MODIFY RING device option enabled.");
@@ -802,6 +830,7 @@ int gve_adminq_describe_device(struct gve_priv *priv)
 {
 	struct gve_device_option_jumbo_frames *dev_op_jumbo_frames = NULL;
 	struct gve_device_option_modify_ring *dev_op_modify_ring = NULL;
+	struct gve_device_option_flow_steering *dev_op_flow_steering = NULL;
 	struct gve_device_option_gqi_rda *dev_op_gqi_rda = NULL;
 	struct gve_device_option_gqi_qpl *dev_op_gqi_qpl = NULL;
 	struct gve_device_option_dqo_rda *dev_op_dqo_rda = NULL;
@@ -829,6 +858,7 @@ int gve_adminq_describe_device(struct gve_priv *priv)
 
 	err = gve_process_device_options(priv, descriptor, &dev_op_gqi_rda,
 					 &dev_op_gqi_qpl, &dev_op_dqo_rda,
+					 &dev_op_flow_steering,
 					 &dev_op_modify_ring,
 					 &dev_op_jumbo_frames);
 	if (err)
@@ -884,7 +914,7 @@ int gve_adminq_describe_device(struct gve_priv *priv)
 	priv->default_num_queues = be16_to_cpu(descriptor->default_num_queues);
 
 	gve_enable_supported_features(priv, supported_features_mask,
-				      dev_op_modify_ring,
+				      dev_op_flow_steering, dev_op_modify_ring,
 				      dev_op_jumbo_frames);
 
 free_device_descriptor:
drivers/net/gve/base/gve_adminq.h +11 -0
index 6a3d469..e237353 100644
@@ -117,6 +117,14 @@ struct gve_ring_size_bound {
 
 GVE_CHECK_STRUCT_LEN(4, gve_ring_size_bound);
 
+struct gve_device_option_flow_steering {
+	__be32 supported_features_mask;
+	__be32 reserved;
+	__be32 max_flow_rules;
+};
+
+GVE_CHECK_STRUCT_LEN(12, gve_device_option_flow_steering);
+
 struct gve_device_option_modify_ring {
 	__be32 supported_features_mask;
 	struct gve_ring_size_bound max_ring_size;
@@ -148,6 +156,7 @@ enum gve_dev_opt_id {
 	GVE_DEV_OPT_ID_DQO_RDA = 0x4,
 	GVE_DEV_OPT_ID_MODIFY_RING = 0x6,
 	GVE_DEV_OPT_ID_JUMBO_FRAMES = 0x8,
+	GVE_DEV_OPT_ID_FLOW_STEERING = 0xb,
 };
 
 enum gve_dev_opt_req_feat_mask {
@@ -155,6 +164,7 @@ enum gve_dev_opt_req_feat_mask {
 	GVE_DEV_OPT_REQ_FEAT_MASK_GQI_RDA = 0x0,
 	GVE_DEV_OPT_REQ_FEAT_MASK_GQI_QPL = 0x0,
 	GVE_DEV_OPT_REQ_FEAT_MASK_DQO_RDA = 0x0,
+	GVE_DEV_OPT_REQ_FEAT_MASK_FLOW_STEERING = 0x0,
 	GVE_DEV_OPT_REQ_FEAT_MASK_MODIFY_RING = 0x0,
 	GVE_DEV_OPT_REQ_FEAT_MASK_JUMBO_FRAMES = 0x0,
 };
@@ -162,6 +172,7 @@ enum gve_dev_opt_req_feat_mask {
 enum gve_sup_feature_mask {
 	GVE_SUP_MODIFY_RING_MASK = 1 << 0,
 	GVE_SUP_JUMBO_FRAMES_MASK = 1 << 2,
+	GVE_SUP_FLOW_STEERING_MASK = 1 << 5,
 };
 
 #define GVE_DEV_OPT_LEN_GQI_RAW_ADDRESSING 0x0
drivers/net/gve/gve_ethdev.h +2 -0
index f7cc781..3a810b6 100644
@@ -332,6 +332,8 @@ struct gve_priv {
 
 	struct gve_rss_config rss_config;
 	struct gve_ptype_lut *ptype_lut_dqo;
+
+	uint32_t max_flow_rules;
 };
 
 static inline bool
Signature · 1 line
2.53.0.473.g4a7958ca14-goog
#22 lore raw

PATCH v4 2/4 net/gve: introduce extended adminq command

In reply to Jasper Tran O'Leary

From: Vee Agarwal <[email protected]>

Flow steering adminq commands are too large to fit into a normal adminq command buffer which accepts at most 56 bytes. As a result, introduce extended adminq commands which permit larger command buffers using indirection. Namely, extended command operations point to inner command buffers allocated at a specified DMA address. As specified with the device, all extended commands will use inner opcodes larger than 0xFF.

---
 drivers/net/gve/base/gve_adminq.c | 30 ++++++++++++++++++++++++++++++
 drivers/net/gve/base/gve_adminq.h | 16 ++++++++++++++++
 2 files changed, 46 insertions(+)
drivers/net/gve/base/gve_adminq.c +30 -0
index 64b9468..0cc6d44 100644
@@ -438,6 +438,8 @@ static int gve_adminq_issue_cmd(struct gve_priv *priv,
 
 	memcpy(cmd, cmd_orig, sizeof(*cmd_orig));
 	opcode = be32_to_cpu(READ_ONCE32(cmd->opcode));
+	if (opcode == GVE_ADMINQ_EXTENDED_COMMAND)
+		opcode = be32_to_cpu(READ_ONCE32(cmd->extended_command.inner_opcode));
 
 	switch (opcode) {
 	case GVE_ADMINQ_DESCRIBE_DEVICE:
@@ -516,6 +518,34 @@ static int gve_adminq_execute_cmd(struct gve_priv *priv,
 	return gve_adminq_kick_and_wait(priv);
 }
 
+static int gve_adminq_execute_extended_cmd(struct gve_priv *priv, u32 opcode,
+					   size_t cmd_size, void *cmd_orig)
+{
+	union gve_adminq_command cmd;
+	struct gve_dma_mem inner_cmd_dma_mem;
+	void *inner_cmd;
+	int err;
+
+	inner_cmd = gve_alloc_dma_mem(&inner_cmd_dma_mem, cmd_size);
+	if (!inner_cmd)
+		return -ENOMEM;
+
+	memcpy(inner_cmd, cmd_orig, cmd_size);
+
+	memset(&cmd, 0, sizeof(cmd));
+	cmd.opcode = cpu_to_be32(GVE_ADMINQ_EXTENDED_COMMAND);
+	cmd.extended_command = (struct gve_adminq_extended_command) {
+		.inner_opcode = cpu_to_be32(opcode),
+		.inner_length = cpu_to_be32(cmd_size),
+		.inner_command_addr = cpu_to_be64(inner_cmd_dma_mem.pa),
+	};
+
+	err = gve_adminq_execute_cmd(priv, &cmd);
+
+	gve_free_dma_mem(&inner_cmd_dma_mem);
+	return err;
+}
+
 /* The device specifies that the management vector can either be the first irq
  * or the last irq. ntfy_blk_msix_base_idx indicates the first irq assigned to
  * the ntfy blks. It if is 0 then the management vector is last, if it is 1 then
drivers/net/gve/base/gve_adminq.h +16 -0
index e237353..f52658e 100644
@@ -25,8 +25,15 @@ enum gve_adminq_opcodes {
 	GVE_ADMINQ_REPORT_LINK_SPEED		= 0xD,
 	GVE_ADMINQ_GET_PTYPE_MAP		= 0xE,
 	GVE_ADMINQ_VERIFY_DRIVER_COMPATIBILITY	= 0xF,
+	/* For commands that are larger than 56 bytes */
+	GVE_ADMINQ_EXTENDED_COMMAND		= 0xFF,
 };
 
+/* The normal adminq command is restricted to be 56 bytes at maximum. For the
+ * longer adminq command, it is wrapped by GVE_ADMINQ_EXTENDED_COMMAND with
+ * inner opcode of gve_adminq_extended_cmd_opcodes specified. The inner command
+ * is written in the dma memory allocated by GVE_ADMINQ_EXTENDED_COMMAND.
+ */
 /* Admin queue status codes */
 enum gve_adminq_statuses {
 	GVE_ADMINQ_COMMAND_UNSET			= 0x0,
@@ -194,6 +201,14 @@ enum gve_driver_capbility {
 #define GVE_DRIVER_CAPABILITY_FLAGS3 0x0
 #define GVE_DRIVER_CAPABILITY_FLAGS4 0x0
 
+struct gve_adminq_extended_command {
+	__be32 inner_opcode;
+	__be32 inner_length;
+	__be64 inner_command_addr;
+};
+
+GVE_CHECK_STRUCT_LEN(16, gve_adminq_extended_command);
+
 struct gve_driver_info {
 	u8 os_type;	/* 0x05 = DPDK */
 	u8 driver_major;
@@ -440,6 +455,7 @@ union gve_adminq_command {
 			struct gve_adminq_get_ptype_map get_ptype_map;
 			struct gve_adminq_verify_driver_compatibility
 				verify_driver_compatibility;
+			struct gve_adminq_extended_command extended_command;
 		};
 	};
 	u8 reserved[64];
Signature · 1 line
2.53.0.473.g4a7958ca14-goog
#23 lore raw

PATCH v4 3/4 net/gve: add adminq commands for flow steering

In reply to Jasper Tran O'Leary

Add new adminq commands for the driver to configure flow rules that are stored in the device. For configuring flow rules, 3 sub commands are supported.
- create: creates a new flow rule with a specific rule_id.
- destroy: deletes an existing flow rule with the specified rule_id.
- flush: clears and deletes all currently active flow rules.

---
 drivers/net/gve/base/gve_adminq.c | 52 +++++++++++++++++++++++++++
 drivers/net/gve/base/gve_adminq.h | 30 ++++++++++++++++
 drivers/net/gve/gve_ethdev.h      |  1 +
 drivers/net/gve/gve_flow_rule.h   | 59 +++++++++++++++++++++++++++++++
 4 files changed, 142 insertions(+)
 create mode 100644 dpdk/drivers/net/gve/gve_flow_rule.h
drivers/net/gve/base/gve_adminq.c +52 -0
index 0cc6d44..9a94591 100644
@@ -239,6 +239,7 @@ int gve_adminq_alloc(struct gve_priv *priv)
 	priv->adminq_report_stats_cnt = 0;
 	priv->adminq_report_link_speed_cnt = 0;
 	priv->adminq_get_ptype_map_cnt = 0;
+	priv->adminq_cfg_flow_rule_cnt = 0;
 
 	/* Setup Admin queue with the device */
 	rte_pci_read_config(priv->pci_dev, &pci_rev_id, sizeof(pci_rev_id),
@@ -487,6 +488,9 @@ static int gve_adminq_issue_cmd(struct gve_priv *priv,
 	case GVE_ADMINQ_VERIFY_DRIVER_COMPATIBILITY:
 		priv->adminq_verify_driver_compatibility_cnt++;
 		break;
+	case GVE_ADMINQ_CONFIGURE_FLOW_RULE:
+		priv->adminq_cfg_flow_rule_cnt++;
+		break;
 	default:
 		PMD_DRV_LOG(ERR, "unknown AQ command opcode %d", opcode);
 	}
@@ -546,6 +550,54 @@ static int gve_adminq_execute_extended_cmd(struct gve_priv *priv, u32 opcode,
 	return err;
 }
 
+static int
+gve_adminq_configure_flow_rule(struct gve_priv *priv,
+			       struct gve_adminq_configure_flow_rule *flow_rule_cmd)
+{
+	int err = gve_adminq_execute_extended_cmd(priv,
+			GVE_ADMINQ_CONFIGURE_FLOW_RULE,
+			sizeof(struct gve_adminq_configure_flow_rule),
+			flow_rule_cmd);
+
+	return err;
+}
+
+int gve_adminq_add_flow_rule(struct gve_priv *priv,
+			     struct gve_flow_rule_params *rule, u32 loc)
+{
+	struct gve_adminq_configure_flow_rule flow_rule_cmd = {
+		.opcode = cpu_to_be16(GVE_FLOW_RULE_CFG_ADD),
+		.location = cpu_to_be32(loc),
+		.rule = {
+			.flow_type = cpu_to_be16(rule->flow_type),
+			.action = cpu_to_be16(rule->action),
+			.key = rule->key,
+			.mask = rule->mask,
+		},
+	};
+
+	return gve_adminq_configure_flow_rule(priv, &flow_rule_cmd);
+}
+
+int gve_adminq_del_flow_rule(struct gve_priv *priv, u32 loc)
+{
+	struct gve_adminq_configure_flow_rule flow_rule_cmd = {
+		.opcode = cpu_to_be16(GVE_FLOW_RULE_CFG_DEL),
+		.location = cpu_to_be32(loc),
+	};
+
+	return gve_adminq_configure_flow_rule(priv, &flow_rule_cmd);
+}
+
+int gve_adminq_reset_flow_rules(struct gve_priv *priv)
+{
+	struct gve_adminq_configure_flow_rule flow_rule_cmd = {
+		.opcode = cpu_to_be16(GVE_FLOW_RULE_CFG_RESET),
+	};
+
+	return gve_adminq_configure_flow_rule(priv, &flow_rule_cmd);
+}
+
 /* The device specifies that the management vector can either be the first irq
  * or the last irq. ntfy_blk_msix_base_idx indicates the first irq assigned to
  * the ntfy blks. It if is 0 then the management vector is last, if it is 1 then
drivers/net/gve/base/gve_adminq.h +30 -0
index f52658e..d8e5e6a 100644
@@ -7,6 +7,7 @@
 #define _GVE_ADMINQ_H
 
 #include "gve_osdep.h"
+#include "../gve_flow_rule.h"
 
 /* Admin queue opcodes */
 enum gve_adminq_opcodes {
@@ -34,6 +35,10 @@ enum gve_adminq_opcodes {
  * inner opcode of gve_adminq_extended_cmd_opcodes specified. The inner command
  * is written in the dma memory allocated by GVE_ADMINQ_EXTENDED_COMMAND.
  */
+enum gve_adminq_extended_cmd_opcodes {
+	GVE_ADMINQ_CONFIGURE_FLOW_RULE	= 0x101,
+};
+
 /* Admin queue status codes */
 enum gve_adminq_statuses {
 	GVE_ADMINQ_COMMAND_UNSET			= 0x0,
@@ -434,6 +439,26 @@ struct gve_adminq_configure_rss {
 	__be64 indir_addr;
 };
 
+/* Flow rule definition for the admin queue using network byte order (big
+ * endian). This struct represents the hardware wire format and should not be
+ * used outside of admin queue contexts.
+ */
+struct gve_adminq_flow_rule {
+	__be16 flow_type;
+	__be16 action; /* RX queue id */
+	struct gve_flow_spec key;
+	struct gve_flow_spec mask;
+};
+
+struct gve_adminq_configure_flow_rule {
+	__be16 opcode;
+	u8 padding[2];
+	struct gve_adminq_flow_rule rule;
+	__be32 location;
+};
+
+GVE_CHECK_STRUCT_LEN(92, gve_adminq_configure_flow_rule);
+
 union gve_adminq_command {
 	struct {
 		__be32 opcode;
@@ -499,4 +524,9 @@ int gve_adminq_verify_driver_compatibility(struct gve_priv *priv,
 int gve_adminq_configure_rss(struct gve_priv *priv,
 			     struct gve_rss_config *rss_config);
 
+int gve_adminq_add_flow_rule(struct gve_priv *priv,
+			     struct gve_flow_rule_params *rule, u32 loc);
+int gve_adminq_del_flow_rule(struct gve_priv *priv, u32 loc);
+int gve_adminq_reset_flow_rules(struct gve_priv *priv);
+
 #endif /* _GVE_ADMINQ_H */
drivers/net/gve/gve_ethdev.h +1 -0
index 3a810b6..4e07ca8 100644
@@ -314,6 +314,7 @@ struct gve_priv {
 	uint32_t adminq_report_link_speed_cnt;
 	uint32_t adminq_get_ptype_map_cnt;
 	uint32_t adminq_verify_driver_compatibility_cnt;
+	uint32_t adminq_cfg_flow_rule_cnt;
 	volatile uint32_t state_flags;
 
 	/* Gvnic device link speed from hypervisor. */
drivers/net/gve/gve_flow_rule.h new file +59 -0

59 lines not on this page · raw message

Signature · 1 line
2.53.0.473.g4a7958ca14-goog
#24 lore raw

PATCH v4 4/4 net/gve: add rte flow API integration

In reply to Jasper Tran O'Leary

Implement driver callbacks for the following rte flow operations:
create, destroy, and flush. This change enables receive flow steering (RFS) for n-tuple based flow rules for the gve driver.

The implementation supports matching ingress IPv4/IPv6 traffic combined with TCP, UDP, SCTP, ESP, or AH protocols. Supported fields for matching include IP source/destination addresses, L4 source/destination ports (for TCP/UDP/SCTP), and SPI (for ESP/AH). The only supported action is RTE_FLOW_ACTION_TYPE_QUEUE, which steers matching packets to a specified rx queue.

---
 doc/guides/nics/features/gve.ini       |  12 +
 doc/guides/nics/gve.rst                |  27 +
 doc/guides/rel_notes/release_26_03.rst |   1 +
 drivers/net/gve/base/gve.h             |   3 +-
 drivers/net/gve/gve_ethdev.c           |  83 +++-
 drivers/net/gve/gve_ethdev.h           |  43 ++
 drivers/net/gve/gve_flow_rule.c        | 658 +++++++++++++++++++++++++
 drivers/net/gve/gve_flow_rule.h        |   6 +
 drivers/net/gve/meson.build            |   1 +
 9 files changed, 832 insertions(+), 2 deletions(-)
 create mode 100644 dpdk/drivers/net/gve/gve_flow_rule.c
doc/guides/nics/features/gve.ini +12 -0
index ed040a0..89c97fd 100644
@@ -19,3 +19,15 @@ Linux                = Y
 x86-32               = Y
 x86-64               = Y
 Usage doc            = Y
+
+[rte_flow items]
+ah                   = Y
+esp                  = Y
+ipv4                 = Y
+ipv6                 = Y
+sctp                 = Y
+tcp                  = Y
+udp                  = Y
+
+[rte_flow actions]
+queue                = Y
doc/guides/nics/gve.rst +27 -0
index 6b4d1f7..8367ca9 100644
@@ -103,6 +103,33 @@ the redirection table will be available for querying upon initial hash configura
 When performing redirection table updates,
 it is possible to update individual table entries.
 
+Flow Steering
+^^^^^^^^^^^^^
+
+The driver supports receive flow steering (RFS) via the standard ``rte_flow``
+API. This allows applications to steer traffic to specific queues based on
+5-tuple matching. 3-tuple matching may be supported in future releases.
+
+**Supported Patterns**
+
+L3 Protocols
+  IPv4/IPv6 source and destination addresses.
+L4 Protocols
+  TCP/UDP/SCTP source and destination ports.
+Security Protocols
+  ESP/AH SPI.
+
+**Supported Actions**
+
+- ``RTE_FLOW_ACTION_TYPE_QUEUE``: Steer packets to a specific Rx queue.
+
+**Limitations**
+
+- Flow steering operations are only supported in the primary process.
+- Only ingress flow rules are allowed.
+- Flow priorities are not supported (must be 0).
+- Masking is limited to full matches i.e. 0x00...0 or 0xFF...F.
+
 Application-Initiated Reset
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 

The driver allows an application to reset the gVNIC device.

doc/guides/rel_notes/release_26_03.rst +1 -0
index 1855d90..b643809 100644
@@ -78,6 +78,7 @@ New Features
 * **Updated Google Virtual Ethernet (gve) driver.**
 
   * Added application-initiated device reset.
+  * Added support for receive flow steering.
 
 * **Updated Intel iavf driver.**
 
drivers/net/gve/base/gve.h +2 -1
index 99514cb..18363fa 100644
@@ -50,7 +50,8 @@ enum gve_state_flags_bit {
 	GVE_PRIV_FLAGS_ADMIN_QUEUE_OK		= 1,
 	GVE_PRIV_FLAGS_DEVICE_RESOURCES_OK	= 2,
 	GVE_PRIV_FLAGS_DEVICE_RINGS_OK		= 3,
-	GVE_PRIV_FLAGS_NAPI_ENABLED		= 4,
+	GVE_PRIV_FLAGS_FLOW_SUBSYSTEM_OK	= 4,
+	GVE_PRIV_FLAGS_NAPI_ENABLED		= 5,
 };
 
 enum gve_rss_hash_algorithm {
drivers/net/gve/gve_ethdev.c +82 -1

143 lines not on this page · raw message

drivers/net/gve/gve_ethdev.h +43 -0

68 lines not on this page · raw message

drivers/net/gve/gve_flow_rule.c new file +658 -0

658 lines not on this page · raw message

drivers/net/gve/gve_flow_rule.h +6 -0
index 8c17ddd..d597a6c 100644
@@ -56,4 +56,10 @@ struct gve_flow_rule_params {
 	struct gve_flow_spec mask;
 };
 
+struct gve_priv;
+
+int gve_flow_init_bmp(struct gve_priv *priv);
+void gve_flow_free_bmp(struct gve_priv *priv);
+int gve_free_flow_rules(struct gve_priv *priv);
+
 #endif /* _GVE_FLOW_RULE_H_ */
drivers/net/gve/meson.build +1 -0
index c6a9f36..7074988 100644
@@ -16,5 +16,6 @@ sources = files(
         'gve_ethdev.c',
         'gve_version.c',
         'gve_rss.c',
+        'gve_flow_rule.c',
 )
 includes += include_directories('base')
Signature · 1 line
2.53.0.473.g4a7958ca14-goog
#25 lore raw
In reply to Jasper Tran O'Leary
Quoted 35 lines · On Wed, 4 Mar 2026 04:50:29 +0000 "Jasper Tran O'Leary"…

This patch series adds flow steering support to the Google Virtual Ethernet (gve) driver. This functionality allows traffic to be directed to specific receive queues based on user-specified flow patterns.

The series includes foundational support for extended admin queue commands needed to handle flow rules, the specific adminqueue commands for flow rule management, and the integration with the DPDK rte_flow API. The series adds support flow matching on the following protocols:
IPv4, IPv6, TCP, UDP, SCTP, ESP, and AH.

Patch Overview:

1. "net/gve: add flow steering device option" checks for and enables the flow steering capability in the device options during initialization.
2. "net/gve: introduce extended adminq command" adds infrastructure for sending extended admin queue commands. These commands use a flexible buffer descriptor format required for flow rule management.
3. "net/gve: add adminq commands for flow steering" implements the specific admin queue commands to add and remove flow rules on the device, including handling of rule IDs and parameters.
4. "net/gve: add rte flow API integration" exposes the flow steering functionality via the DPDK rte_flow API. This includes strict pattern validation, rule parsing, and lifecycle management (create, destroy, flush). It ensures thread-safe access to the flow subsystem and proper resource cleanup during device reset.

Jasper Tran O'Leary (2):
net/gve: add adminq commands for flow steering
net/gve: add rte flow API integration

Vee Agarwal (2):
net/gve: add flow steering device option
net/gve: introduce extended adminq command

Quoted 15 lines
 doc/guides/nics/features/gve.ini       |  12 +
 doc/guides/nics/gve.rst                |  27 +
 doc/guides/rel_notes/release_26_03.rst |   1 +
 drivers/net/gve/base/gve.h             |   3 +-
 drivers/net/gve/base/gve_adminq.c      | 118 ++++-
 drivers/net/gve/base/gve_adminq.h      |  57 +++
 drivers/net/gve/gve_ethdev.c           |  83 +++-
 drivers/net/gve/gve_ethdev.h           |  46 ++
 drivers/net/gve/gve_flow_rule.c        | 658 +++++++++++++++++++++++++
 drivers/net/gve/gve_flow_rule.h        |  65 +++
 drivers/net/gve/meson.build            |   1 +
 11 files changed, 1066 insertions(+), 5 deletions(-)
 create mode 100644 dpdk/drivers/net/gve/gve_flow_rule.c
 create mode 100644 dpdk/drivers/net/gve/gve_flow_rule.h

Applied to next-net

The detailed review report if you are interested.

Reviewed the v4 series. Overall this is well-structured — locking discipline is sound, create/destroy/flush paths handle errors correctly with proper resource cleanup, and the bitmap slot is restored on adminq failure. Patches 1/4 and 2/4 are clean.

A few items on 3/4 and 4/4:

Patch 3/4:

[Warning] struct gve_flow_spec has a padding hole after the tos/tclass u8 field (37 bytes of data, padded to 40 by the compiler). Callers zero-initialize today so no live bug, but consider adding GVE_CHECK_STRUCT_LEN for gve_flow_spec and gve_flow_rule_params to guard against future changes, consistent with other adminq structures.

Patch 4/4:

[Warning] In gve_setup_flow_subsystem, the rte_zmalloc failure path does goto free_flow_rule_bmp which calls gve_flow_free_bmp(priv). This is safe (rte_free(NULL) is a no-op) but misleading — the label says "free" when there's nothing to free. Cleaner to just return -ENOMEM directly on the first failure.

[Warning] gve_dev_reset tears down the flow subsystem and re-initializes via gve_init_priv, but does not destroy/recreate flow_rule_lock. This works today because gve_teardown_flow_subsystem doesn't destroy the mutex (only gve_dev_close does), but it's worth a comment to document this invariant.

#26 lore raw

Thank you, I will address the additional patch 3/4 and patch 4/4 comments in a future cleanup patch.

Quoted 91 lines · Stephen Hemminger
Quoted 35 lines · On Wed, 4 Mar 2026 04:50:29 +0000 "Jasper Tran O'Leary"…

This patch series adds flow steering support to the Google Virtual Ethernet (gve) driver. This functionality allows traffic to be directed to specific receive queues based on user-specified flow patterns.

The series includes foundational support for extended admin queue commands needed to handle flow rules, the specific adminqueue commands for flow rule management, and the integration with the DPDK rte_flow API. The series adds support flow matching on the following protocols:
IPv4, IPv6, TCP, UDP, SCTP, ESP, and AH.

Patch Overview:

1. "net/gve: add flow steering device option" checks for and enables the flow steering capability in the device options during initialization.
2. "net/gve: introduce extended adminq command" adds infrastructure for sending extended admin queue commands. These commands use a flexible buffer descriptor format required for flow rule management.
3. "net/gve: add adminq commands for flow steering" implements the specific admin queue commands to add and remove flow rules on the device, including handling of rule IDs and parameters.
4. "net/gve: add rte flow API integration" exposes the flow steering functionality via the DPDK rte_flow API. This includes strict pattern validation, rule parsing, and lifecycle management (create, destroy, flush). It ensures thread-safe access to the flow subsystem and proper resource cleanup during device reset.

Jasper Tran O'Leary (2):
net/gve: add adminq commands for flow steering
net/gve: add rte flow API integration

Vee Agarwal (2):
net/gve: add flow steering device option
net/gve: introduce extended adminq command

Quoted 15 lines
 doc/guides/nics/features/gve.ini       |  12 +
 doc/guides/nics/gve.rst                |  27 +
 doc/guides/rel_notes/release_26_03.rst |   1 +
 drivers/net/gve/base/gve.h             |   3 +-
 drivers/net/gve/base/gve_adminq.c      | 118 ++++-
 drivers/net/gve/base/gve_adminq.h      |  57 +++
 drivers/net/gve/gve_ethdev.c           |  83 +++-
 drivers/net/gve/gve_ethdev.h           |  46 ++
 drivers/net/gve/gve_flow_rule.c        | 658 +++++++++++++++++++++++++
 drivers/net/gve/gve_flow_rule.h        |  65 +++
 drivers/net/gve/meson.build            |   1 +
 11 files changed, 1066 insertions(+), 5 deletions(-)
 create mode 100644 dpdk/drivers/net/gve/gve_flow_rule.c
 create mode 100644 dpdk/drivers/net/gve/gve_flow_rule.h

Applied to next-net

The detailed review report if you are interested.

Reviewed the v4 series. Overall this is well-structured — locking discipline is sound, create/destroy/flush paths handle errors correctly with proper resource cleanup, and the bitmap slot is restored on adminq failure. Patches 1/4 and 2/4 are clean.

A few items on 3/4 and 4/4:

Patch 3/4:

[Warning] struct gve_flow_spec has a padding hole after the tos/tclass u8 field (37 bytes of data, padded to 40 by the compiler). Callers zero-initialize today so no live bug, but consider adding GVE_CHECK_STRUCT_LEN for gve_flow_spec and gve_flow_rule_params to guard against future changes, consistent with other adminq structures.

Patch 4/4:

[Warning] In gve_setup_flow_subsystem, the rte_zmalloc failure path does goto free_flow_rule_bmp which calls gve_flow_free_bmp(priv). This is safe (rte_free(NULL) is a no-op) but misleading — the label says "free" when there's nothing to free. Cleaner to just return -ENOMEM directly on the first failure.

[Warning] gve_dev_reset tears down the flow subsystem and re-initializes via gve_init_priv, but does not destroy/recreate flow_rule_lock. This works today because gve_teardown_flow_subsystem doesn't destroy the mutex (only gve_dev_close does), but it's worth a comment to document this invariant.