Signed-off-by: Nelio Laranjeiro <nelio.laranje...@6wind.com>
---
 drivers/net/mlx5/mlx5_flow.c | 88 +++++++++++++++++++++-----------------------
 1 file changed, 41 insertions(+), 47 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 1eda83671..ff50470b5 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -654,6 +654,9 @@ priv_flow_convert_actions(struct priv *priv,
                          struct rte_flow_error *error,
                          struct mlx5_flow_parse *parser)
 {
+       int ret = 0;
+       const char *msg = NULL;
+       const struct rte_flow_action *action = NULL;
        /*
         * Add default RSS configuration necessary for Verbs to create QP even
         * if no RSS is necessary.
@@ -674,7 +677,7 @@ priv_flow_convert_actions(struct priv *priv,
                        uint16_t found = 0;
 
                        if (!queue || (queue->index > (priv->rxqs_n - 1)))
-                               goto exit_action_not_supported;
+                               goto error;
                        for (n = 0; n < parser->queues_n; ++n) {
                                if (parser->queues[n] == queue->index) {
                                        found = 1;
@@ -682,11 +685,10 @@ priv_flow_convert_actions(struct priv *priv,
                                }
                        }
                        if (parser->queues_n > 1 && !found) {
-                               rte_flow_error_set(error, ENOTSUP,
-                                          RTE_FLOW_ERROR_TYPE_ACTION,
-                                          actions,
-                                          "queue action not in RSS queues");
-                               return -rte_errno;
+                               ret = ENOTSUP;
+                               action = actions;
+                               msg = "queue action not in RSS queues";
+                               goto error;
                        }
                        if (!found) {
                                parser->queues_n = 1;
@@ -699,11 +701,10 @@ priv_flow_convert_actions(struct priv *priv,
                        uint16_t n;
 
                        if (!rss || !rss->num) {
-                               rte_flow_error_set(error, EINVAL,
-                                                  RTE_FLOW_ERROR_TYPE_ACTION,
-                                                  actions,
-                                                  "no valid queues");
-                               return -rte_errno;
+                               ret = EINVAL;
+                               action = actions;
+                               msg = "no valid queues";
+                               goto error;
                        }
                        if (parser->queues_n == 1) {
                                uint16_t found = 0;
@@ -717,22 +718,18 @@ priv_flow_convert_actions(struct priv *priv,
                                        }
                                }
                                if (!found) {
-                                       rte_flow_error_set(error, ENOTSUP,
-                                                  RTE_FLOW_ERROR_TYPE_ACTION,
-                                                  actions,
-                                                  "queue action not in RSS"
-                                                  " queues");
-                                       return -rte_errno;
+                                       ret = ENOTSUP;
+                                       action = actions;
+                                       msg = "queue action not in RSS queues";
+                                       goto error;
                                }
                        }
                        for (n = 0; n < rss->num; ++n) {
                                if (rss->queue[n] >= priv->rxqs_n) {
-                                       rte_flow_error_set(error, EINVAL,
-                                                  RTE_FLOW_ERROR_TYPE_ACTION,
-                                                  actions,
-                                                  "queue id > number of"
-                                                  " queues");
-                                       return -rte_errno;
+                                       ret = EINVAL;
+                                       action = actions;
+                                       msg = "queue id > number of queues";
+                                       goto error;
                                }
                        }
                        for (n = 0; n < rss->num; ++n)
@@ -740,11 +737,10 @@ priv_flow_convert_actions(struct priv *priv,
                        parser->queues_n = rss->num;
                        if (priv_flow_convert_rss_conf(priv, parser,
                                                       rss->rss_conf)) {
-                               rte_flow_error_set(error, EINVAL,
-                                                  RTE_FLOW_ERROR_TYPE_ACTION,
-                                                  actions,
-                                                  "wrong RSS configuration");
-                               return -rte_errno;
+                               ret = EINVAL;
+                               action = actions;
+                               msg = "wrong RSS configuration";
+                               goto error;
                        }
                } else if (actions->type == RTE_FLOW_ACTION_TYPE_MARK) {
                        const struct rte_flow_action_mark *mark =
@@ -752,18 +748,15 @@ priv_flow_convert_actions(struct priv *priv,
                                actions->conf;
 
                        if (!mark) {
-                               rte_flow_error_set(error, EINVAL,
-                                                  RTE_FLOW_ERROR_TYPE_ACTION,
-                                                  actions,
-                                                  "mark must be defined");
-                               return -rte_errno;
+                               ret = EINVAL;
+                               action = actions;
+                               msg = "mark must be defined";
+                               goto error;
                        } else if (mark->id >= MLX5_FLOW_MARK_MAX) {
-                               rte_flow_error_set(error, ENOTSUP,
-                                                  RTE_FLOW_ERROR_TYPE_ACTION,
-                                                  actions,
-                                                  "mark must be between 0"
-                                                  " and 16777199");
-                               return -rte_errno;
+                               ret = ENOTSUP;
+                               action = actions;
+                               msg = "mark must be between 0 and 16777199";
+                               goto error;
                        }
                        parser->mark = 1;
                        parser->mark_id = mark->id;
@@ -773,21 +766,22 @@ priv_flow_convert_actions(struct priv *priv,
                           priv->counter_set_supported) {
                        parser->count = 1;
                } else {
-                       goto exit_action_not_supported;
+                       goto error;
                }
        }
        if (parser->drop && parser->mark)
                parser->mark = 0;
        if (!parser->queues_n && !parser->drop) {
-               rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_HANDLE,
-                                  NULL, "no valid action");
-               return -rte_errno;
+               ret = ENOTSUP;
+               msg = "no valid action";
+               goto error;
        }
        return 0;
-exit_action_not_supported:
-       rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION,
-                          actions, "action not supported");
-       return -rte_errno;
+error:
+       return rte_flow_error_set(error, ret,
+                                 action ? RTE_FLOW_ERROR_TYPE_ACTION :
+                                 RTE_FLOW_ERROR_TYPE_HANDLE,
+                                 action, msg);
 }
 
 /**
-- 
2.11.0

Reply via email to