[PATCH v1 1/1] ethdev: add flow item structure size query
Anatoly Burakov
anatoly.burakov at intel.com
Fri Oct 23 14:15:46 CEST 2026
Add RTE_FLOW_CONV_OP_ITEM_SIZE to retrieve the fixed specification
structure size for a flow item type using the existing descriptor table.
Signed-off-by: Anatoly Burakov <anatoly.burakov at intel.com>
---
lib/ethdev/rte_flow.c | 16 ++++++++++++++++
lib/ethdev/rte_flow.h | 18 ++++++++++++++++++
2 files changed, 34 insertions(+)
diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c
index 0ebf59165d4..1b2d263331a 100644
--- a/lib/ethdev/rte_flow.c
+++ b/lib/ethdev/rte_flow.c
@@ -1266,6 +1266,22 @@ rte_flow_conv(enum rte_flow_conv_op op,
case RTE_FLOW_CONV_OP_ITEM_DEFAULT_MASK_PTR:
ret = rte_flow_conv_item_default_mask(dst, size, src, error);
break;
+ case RTE_FLOW_CONV_OP_ITEM_SIZE:
+ {
+ uintptr_t type = (uintptr_t)src;
+
+ if (type >= RTE_DIM(rte_flow_desc_item) ||
+ rte_flow_desc_item[type].name == NULL) {
+ ret = rte_flow_error_set(error, EINVAL,
+ RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
+ "unknown item type to retrieve the size of");
+ break;
+ }
+ if (size >= sizeof(size_t))
+ *(size_t *)dst = rte_flow_desc_item[type].size;
+ ret = sizeof(size_t);
+ break;
+ }
default:
ret = rte_flow_error_set
(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h
index df8101e4395..3d6a56f51e3 100644
--- a/lib/ethdev/rte_flow.h
+++ b/lib/ethdev/rte_flow.h
@@ -4426,6 +4426,24 @@ enum rte_flow_conv_op {
* @code const void ** @endcode
*/
RTE_FLOW_CONV_OP_ITEM_DEFAULT_MASK_PTR,
+
+ /**
+ * Retrieve the fixed size of an item specification structure.
+ *
+ * Writes the size of rte_flow_item_{name} to @p dst, or zero for
+ * known item types without a specification structure. Does not include
+ * variable-length or externally referenced data (for example, RAW
+ * pattern bytes). Unknown and PMD-private item types return an error.
+ *
+ * No output is written if @p size is smaller than sizeof(size_t).
+ * The return value is sizeof(size_t), not the item structure size.
+ *
+ * - @p src type:
+ * @code (const void *)(uintptr_t)enum rte_flow_item_type @endcode
+ * - @p dst type:
+ * @code size_t * @endcode
+ */
+ RTE_FLOW_CONV_OP_ITEM_SIZE,
};
/**
--
2.52.0
More information about the dev
mailing list