DPDK patches and discussions
 help / color / mirror / Atom feed
From: Adrien Mazarguil <adrien.mazarguil@6wind.com>
To: Ferruh Yigit <ferruh.yigit@intel.com>
Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>, dev@dpdk.org
Subject: [dpdk-dev] [PATCH v1 3/4] net/mlx4: fix indirection table error rollback
Date: Thu, 19 Oct 2017 18:11:07 +0200	[thread overview]
Message-ID: <1508429034-27506-4-git-send-email-adrien.mazarguil@6wind.com> (raw)
In-Reply-To: <1508429034-27506-1-git-send-email-adrien.mazarguil@6wind.com>

In case of error occurring while setting up indirection table and related
RSS context resources, intermediate objects are not cleaned up.

Moreover although unlikely, an error other than EINVAL (e.g. ENOMEM) may be
returned.

A description of mlx4_rss_attach()'s return value is also missing.

Fixes: 078b8b452e6b ("net/mlx4: add RSS flow rule action support")

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
---
 drivers/net/mlx4/mlx4_rxq.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/net/mlx4/mlx4_rxq.c b/drivers/net/mlx4/mlx4_rxq.c
index 65cf123..ee29556 100644
--- a/drivers/net/mlx4/mlx4_rxq.c
+++ b/drivers/net/mlx4/mlx4_rxq.c
@@ -185,6 +185,9 @@ void mlx4_rss_put(struct mlx4_rss *rss)
  *
  * @param rss
  *   RSS context to attach to.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
  */
 int mlx4_rss_attach(struct mlx4_rss *rss)
 {
@@ -202,6 +205,7 @@ int mlx4_rss_attach(struct mlx4_rss *rss)
 	int ret;
 
 	if (!rte_is_power_of_2(RTE_DIM(ind_tbl))) {
+		ret = EINVAL;
 		msg = "number of RSS queues must be a power of two";
 		goto error;
 	}
@@ -212,6 +216,7 @@ int mlx4_rss_attach(struct mlx4_rss *rss)
 		if (id < priv->dev->data->nb_rx_queues)
 			rxq = priv->dev->data->rx_queues[id];
 		if (!rxq) {
+			ret = EINVAL;
 			msg = "RSS target queue is not configured";
 			goto error;
 		}
@@ -225,6 +230,7 @@ int mlx4_rss_attach(struct mlx4_rss *rss)
 			.comp_mask = 0,
 		 });
 	if (!rss->ind) {
+		ret = errno ? errno : EINVAL;
 		msg = "RSS indirection table creation failure";
 		goto error;
 	}
@@ -245,6 +251,7 @@ int mlx4_rss_attach(struct mlx4_rss *rss)
 			},
 		 });
 	if (!rss->qp) {
+		ret = errno ? errno : EINVAL;
 		msg = "RSS hash QP creation failure";
 		goto error;
 	}
@@ -271,10 +278,18 @@ int mlx4_rss_attach(struct mlx4_rss *rss)
 	}
 	return 0;
 error:
+	if (rss->qp) {
+		claim_zero(ibv_destroy_qp(rss->qp));
+		rss->qp = NULL;
+	}
+	if (rss->ind) {
+		claim_zero(ibv_destroy_rwq_ind_table(rss->ind));
+		rss->ind = NULL;
+	}
 	ERROR("mlx4: %s", msg);
 	--rss->usecnt;
-	rte_errno = EINVAL;
-	return -rte_errno;
+	rte_errno = ret;
+	return -ret;
 }
 
 /**
-- 
2.1.4

  parent reply	other threads:[~2017-10-19 16:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-19 16:11 [dpdk-dev] [PATCH v1 0/4] net/mlx4: RSS fixes Adrien Mazarguil
2017-10-19 16:11 ` [dpdk-dev] [PATCH v1 1/4] net/mlx4: use dedicated list iterator Adrien Mazarguil
2017-10-19 16:11 ` [dpdk-dev] [PATCH v1 2/4] net/mlx4: fix useless flow rules synchronization Adrien Mazarguil
2017-10-19 16:11 ` Adrien Mazarguil [this message]
2017-10-19 16:11 ` [dpdk-dev] [PATCH v1 4/4] net/mlx4: relax Rx queue configuration order Adrien Mazarguil
2017-10-23 19:18 ` [dpdk-dev] [PATCH v1 0/4] net/mlx4: RSS fixes Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1508429034-27506-4-git-send-email-adrien.mazarguil@6wind.com \
    --to=adrien.mazarguil@6wind.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=nelio.laranjeiro@6wind.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).