Due to HW limitation, not all the fields are available as ADD_FIELD destination.
This commit adds the validation to the destinations. Signed-off-by: Suanming Mou <suanmi...@nvidia.com> --- doc/guides/rel_notes/release_24_03.rst | 4 ++++ drivers/net/mlx5/mlx5_flow_hw.c | 32 ++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/doc/guides/rel_notes/release_24_03.rst b/doc/guides/rel_notes/release_24_03.rst index e9c9717706..2c0e2930cc 100644 --- a/doc/guides/rel_notes/release_24_03.rst +++ b/doc/guides/rel_notes/release_24_03.rst @@ -55,6 +55,10 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Updated NVIDIA mlx5 driver.** + + * Added support for accumulating from src field to dst field. + Removed Items ------------- diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index d224979ee8..c4a90a3690 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -4948,6 +4948,33 @@ flow_hw_modify_field_is_used(const struct rte_flow_action_modify_field *action, return action->src.field == field || action->dst.field == field; } +static bool +flow_hw_modify_field_is_add_dst_valid(const struct rte_flow_action_modify_field *conf) +{ + if (conf->operation != RTE_FLOW_MODIFY_ADD) + return true; + if (conf->src.field == RTE_FLOW_FIELD_POINTER || + conf->src.field == RTE_FLOW_FIELD_VALUE) + return true; + switch (conf->dst.field) { + case RTE_FLOW_FIELD_IPV4_TTL: + case RTE_FLOW_FIELD_IPV6_HOPLIMIT: + case RTE_FLOW_FIELD_TCP_SEQ_NUM: + case RTE_FLOW_FIELD_TCP_ACK_NUM: + case RTE_FLOW_FIELD_TAG: + case RTE_FLOW_FIELD_META: + case RTE_FLOW_FIELD_FLEX_ITEM: + case RTE_FLOW_FIELD_TCP_DATA_OFFSET: + case RTE_FLOW_FIELD_IPV4_IHL: + case RTE_FLOW_FIELD_IPV4_TOTAL_LEN: + case RTE_FLOW_FIELD_IPV6_PAYLOAD_LEN: + return true; + default: + break; + } + return false; +} + static int flow_hw_validate_action_modify_field(struct rte_eth_dev *dev, const struct rte_flow_action *action, @@ -5060,6 +5087,11 @@ flow_hw_validate_action_modify_field(struct rte_eth_dev *dev, return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, action, "MPLS cannot be used as destination"); + /* ADD_FIELD is not supported for all the fields. */ + if (!flow_hw_modify_field_is_add_dst_valid(action_conf)) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, action, + "invalid add_field destination"); return 0; } static int -- 2.34.1