From: Gregory Etelson <getel...@nvidia.com>

HWS ASO actions validation required PMD to allocate resources during
the port configuration, before the action validation was called.

That approach does not work in the HWS non-template setup, because
non-template setup does not have explicit port configuration
procedure and port allocates ASO resources "on demand".

The patch assumes that if port did not have ASO resources during
action validation PMD was configured for the non-template and
allocates missing resources.

Signed-off-by: Gregory Etelson <getel...@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow_hw.c | 41 +++++++++++++++++++++------------
 1 file changed, 26 insertions(+), 15 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index f2ed2d8e46..66e0b46f9b 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -207,6 +207,11 @@ mlx5_destroy_multi_pattern_segment(struct 
mlx5_multi_pattern_segment *segment);
 static __rte_always_inline enum mlx5_indirect_list_type
 flow_hw_inlist_type_get(const struct rte_flow_action *actions);
 
+static int
+flow_hw_allocate_actions(struct rte_eth_dev *dev,
+                        uint64_t action_flags,
+                        struct rte_flow_error *error);
+
 static __rte_always_inline int
 mlx5_multi_pattern_reformat_to_index(enum mlx5dr_action_type type)
 {
@@ -11361,25 +11366,31 @@ flow_hw_action_handle_validate(struct rte_eth_dev 
*dev, uint32_t queue,
        RTE_SET_USED(user_data);
        switch (action->type) {
        case RTE_FLOW_ACTION_TYPE_AGE:
-               if (!priv->hws_age_req)
-                       return rte_flow_error_set(error, EINVAL,
-                                                 RTE_FLOW_ERROR_TYPE_ACTION,
-                                                 NULL,
-                                                 "aging pool not initialized");
+               if (!priv->hws_age_req) {
+                       if (flow_hw_allocate_actions(dev, MLX5_FLOW_ACTION_AGE,
+                                                    error))
+                               return rte_flow_error_set
+                                       (error, EINVAL, 
RTE_FLOW_ERROR_TYPE_ACTION,
+                                        NULL, "aging pool not initialized");
+               }
                break;
        case RTE_FLOW_ACTION_TYPE_COUNT:
-               if (!priv->hws_cpool)
-                       return rte_flow_error_set(error, EINVAL,
-                                                 RTE_FLOW_ERROR_TYPE_ACTION,
-                                                 NULL,
-                                                 "counters pool not 
initialized");
+               if (!priv->hws_cpool) {
+                       if (flow_hw_allocate_actions(dev, 
MLX5_FLOW_ACTION_COUNT,
+                                                    error))
+                               return rte_flow_error_set
+                                       (error, EINVAL, 
RTE_FLOW_ERROR_TYPE_ACTION,
+                                        NULL, "counters pool not initialized");
+               }
                break;
        case RTE_FLOW_ACTION_TYPE_CONNTRACK:
-               if (priv->hws_ctpool == NULL)
-                       return rte_flow_error_set(error, EINVAL,
-                                                 RTE_FLOW_ERROR_TYPE_ACTION,
-                                                 NULL,
-                                                 "CT pool not initialized");
+               if (priv->hws_ctpool == NULL) {
+                       if (flow_hw_allocate_actions(dev, MLX5_FLOW_ACTION_CT,
+                                                    error))
+                               return rte_flow_error_set
+                                       (error, EINVAL, 
RTE_FLOW_ERROR_TYPE_ACTION,
+                                        NULL, "CT pool not initialized");
+               }
                return mlx5_validate_action_ct(dev, action->conf, error);
        case RTE_FLOW_ACTION_TYPE_METER_MARK:
                return flow_hw_validate_action_meter_mark(dev, action, true, 
error);
-- 
2.25.1

Reply via email to