1. Add rte_eth_dev parameter to the `flow_hw_get_reg_id()`

2. Add mlx5_flow_hw_get_reg_id()

Signed-off-by: Gregory Etelson <getel...@nvidia.com>
Acked-by: Ori Kam <or...@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow.c    |  2 +-
 drivers/net/mlx5/mlx5_flow.h    | 13 +++++++++++--
 drivers/net/mlx5/mlx5_flow_dv.c | 12 ++++++------
 drivers/net/mlx5/mlx5_flow_hw.c |  7 +++----
 4 files changed, 21 insertions(+), 13 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index a500afd4f7..45a67607ed 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -1718,7 +1718,7 @@ flow_drv_rxq_flags_set(struct rte_eth_dev *dev,
        }
 }
 
-static void
+void
 flow_rxq_mark_flag_set(struct rte_eth_dev *dev)
 {
        struct mlx5_priv *priv = dev->data->dev_private;
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index de31ab56bc..dc4ced711d 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -1681,8 +1681,10 @@ void flow_hw_clear_flow_metadata_config(void);
  * TODO: Per port / device, FDB or NIC for Meta matching.
  */
 static __rte_always_inline int
-flow_hw_get_reg_id(enum rte_flow_item_type type, uint32_t id)
+flow_hw_get_reg_id(struct rte_eth_dev *dev,
+                  enum rte_flow_item_type type, uint32_t id)
 {
+       RTE_SET_USED(dev);
        switch (type) {
        case RTE_FLOW_ITEM_TYPE_META:
 #ifdef HAVE_MLX5_HWS_SUPPORT
@@ -1726,7 +1728,8 @@ flow_hw_get_reg_id_from_ctx(void *dr_ctx,
 
                priv = rte_eth_devices[port].data->dev_private;
                if (priv->dr_ctx == dr_ctx)
-                       return flow_hw_get_reg_id(type, id);
+                       return flow_hw_get_reg_id(&rte_eth_devices[port],
+                                                 type, id);
        }
 #else
        RTE_SET_USED(dr_ctx);
@@ -2877,6 +2880,12 @@ flow_hw_get_srh_flex_parser_byte_off_from_ctx(void 
*dr_ctx __rte_unused)
 }
 void
 mlx5_indirect_list_handles_release(struct rte_eth_dev *dev);
+void
+flow_rxq_mark_flag_set(struct rte_eth_dev *dev);
+int
+mlx5_flow_hw_get_reg_id(struct mlx5dr_context *ctx,
+                       enum rte_flow_item_type type, uint32_t id);
+
 #ifdef HAVE_MLX5_HWS_SUPPORT
 struct mlx5_mirror;
 void
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 3dc2fe5c71..05a374493d 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -1919,8 +1919,8 @@ mlx5_flow_field_id_to_modify_info
                        off_be = (tag_index == MLX5_LINEAR_HASH_TAG_INDEX) ?
                                 16 - (data->offset + width) + 16 : 
data->offset;
                        if (priv->sh->config.dv_flow_en == 2)
-                               reg = flow_hw_get_reg_id(RTE_FLOW_ITEM_TYPE_TAG,
-                                                        tag_index);
+                               reg = flow_hw_get_reg_id(dev, 
RTE_FLOW_ITEM_TYPE_TAG,
+                                                        data->level);
                        else
                                reg = mlx5_flow_get_reg_id(dev, MLX5_APP_TAG,
                                                           tag_index, error);
@@ -2025,7 +2025,7 @@ mlx5_flow_field_id_to_modify_info
 
                        if (priv->sh->config.dv_flow_en == 2)
                                reg = flow_hw_get_reg_id
-                                       (RTE_FLOW_ITEM_TYPE_METER_COLOR, 0);
+                                       (dev, RTE_FLOW_ITEM_TYPE_METER_COLOR, 
0);
                        else
                                reg = mlx5_flow_get_reg_id(dev, MLX5_MTR_COLOR,
                                                       0, error);
@@ -10256,7 +10256,7 @@ flow_dv_translate_item_meta(struct rte_eth_dev *dev,
        if (!!(key_type & MLX5_SET_MATCHER_SW))
                reg = flow_dv_get_metadata_reg(dev, attr, NULL);
        else
-               reg = flow_hw_get_reg_id(RTE_FLOW_ITEM_TYPE_META, 0);
+               reg = flow_hw_get_reg_id(dev, RTE_FLOW_ITEM_TYPE_META, 0);
        if (reg < 0)
                return;
        MLX5_ASSERT(reg != REG_NON);
@@ -10359,7 +10359,7 @@ flow_dv_translate_item_tag(struct rte_eth_dev *dev, 
void *key,
        if (!!(key_type & MLX5_SET_MATCHER_SW))
                reg = mlx5_flow_get_reg_id(dev, MLX5_APP_TAG, index, NULL);
        else
-               reg = flow_hw_get_reg_id(RTE_FLOW_ITEM_TYPE_TAG, index);
+               reg = flow_hw_get_reg_id(dev, RTE_FLOW_ITEM_TYPE_TAG, index);
        MLX5_ASSERT(reg > 0);
        flow_dv_match_meta_reg(key, (enum modify_reg)reg, tag_v->data, 
tag_m->data);
 }
@@ -11057,7 +11057,7 @@ flow_dv_translate_item_meter_color(struct rte_eth_dev 
*dev, void *key,
        if (!!(key_type & MLX5_SET_MATCHER_SW))
                reg = mlx5_flow_get_reg_id(dev, MLX5_MTR_COLOR, 0, NULL);
        else
-               reg = flow_hw_get_reg_id(RTE_FLOW_ITEM_TYPE_METER_COLOR, 0);
+               reg = flow_hw_get_reg_id(dev, RTE_FLOW_ITEM_TYPE_METER_COLOR, 
0);
        if (reg == REG_NON)
                return;
        flow_dv_match_meta_reg(key, (enum modify_reg)reg, value, mask);
diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index 1777cda9f7..ef55c41f83 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -5595,9 +5595,8 @@ flow_hw_pattern_validate(struct rte_eth_dev *dev,
                        if (tag == NULL)
                                return rte_flow_error_set(error, EINVAL,
                                                          
RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
-                                                         NULL,
-                                                         "Tag spec is NULL");
-                       tag_idx = flow_hw_get_reg_id(RTE_FLOW_ITEM_TYPE_TAG, 
tag->index);
+                                                         NULL, "Tag spec is 
NULL");
+                       tag_idx = flow_hw_get_reg_id(dev, 
RTE_FLOW_ITEM_TYPE_TAG, tag->index);
                        if (tag_idx == REG_NON)
                                return rte_flow_error_set(error, EINVAL,
                                                          
RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
@@ -5655,7 +5654,7 @@ flow_hw_pattern_validate(struct rte_eth_dev *dev,
                        break;
                case RTE_FLOW_ITEM_TYPE_METER_COLOR:
                {
-                       int reg = 
flow_hw_get_reg_id(RTE_FLOW_ITEM_TYPE_METER_COLOR, 0);
+                       int reg = flow_hw_get_reg_id(dev, 
RTE_FLOW_ITEM_TYPE_METER_COLOR, 0);
                        if (reg == REG_NON)
                                return rte_flow_error_set(error, EINVAL,
                                                          
RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
-- 
2.39.2

Reply via email to