Allow copy of the hash result via modify_field Flow API.
Setting this value is not allowed, it is read-only field.

Signed-off-by: Alexander Kozyrev <akozy...@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow_dv.c | 12 ++++++++++++
 drivers/net/mlx5/mlx5_flow_hw.c |  5 +++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 7ca909999b..84fc725738 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -1390,6 +1390,8 @@ mlx5_flow_item_field_width(struct rte_eth_dev *dev,
        case RTE_FLOW_FIELD_IPV6_ECN:
        case RTE_FLOW_FIELD_METER_COLOR:
                return 2;
+       case RTE_FLOW_FIELD_HASH_RESULT:
+               return 32;
        default:
                MLX5_ASSERT(false);
        }
@@ -1883,6 +1885,16 @@ mlx5_flow_field_id_to_modify_info
                                info[idx].offset = data->offset;
                }
                break;
+       case RTE_FLOW_FIELD_HASH_RESULT:
+               MLX5_ASSERT(data->offset + width <= 32);
+               off_be = 32 - (data->offset + width);
+               info[idx] = (struct field_modify_info){4, 0,
+                                                      MLX5_MODI_HASH_RESULT};
+               if (mask)
+                       mask[idx] = flow_modify_info_mask_32(width, off_be);
+               else
+                       info[idx].offset = off_be;
+               break;
        case RTE_FLOW_FIELD_POINTER:
        case RTE_FLOW_FIELD_VALUE:
        default:
diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index b209b448c6..6f391d990d 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -3530,10 +3530,11 @@ flow_hw_validate_action_modify_field(const struct 
rte_flow_action *action,
                                RTE_FLOW_ERROR_TYPE_ACTION, action,
                                "destination field mask and template are not 
equal");
        if (action_conf->dst.field == RTE_FLOW_FIELD_POINTER ||
-           action_conf->dst.field == RTE_FLOW_FIELD_VALUE)
+           action_conf->dst.field == RTE_FLOW_FIELD_VALUE ||
+           action_conf->dst.field == RTE_FLOW_FIELD_HASH_RESULT)
                return rte_flow_error_set(error, EINVAL,
                                RTE_FLOW_ERROR_TYPE_ACTION, action,
-                               "immediate value and pointer cannot be used as 
destination");
+                               "immediate value, pointer and hash result 
cannot be used as destination");
        if (mask_conf->dst.level != UINT32_MAX)
                return rte_flow_error_set(error, EINVAL,
                        RTE_FLOW_ERROR_TYPE_ACTION, action,
-- 
2.18.2

Reply via email to