From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <qi.z.zhang@intel.com>
Received: from mga01.intel.com (mga01.intel.com [192.55.52.88])
 by dpdk.org (Postfix) with ESMTP id 04A4A5A6E
 for <dev@dpdk.org>; Mon, 25 Mar 2019 06:43:38 +0100 (CET)
X-Amp-Result: SKIPPED(no attachment in message)
X-Amp-File-Uploaded: False
Received: from orsmga008.jf.intel.com ([10.7.209.65])
 by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;
 24 Mar 2019 22:43:38 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.60,256,1549958400"; d="scan'208";a="128368771"
Received: from dpdk51.sh.intel.com ([10.67.110.245])
 by orsmga008.jf.intel.com with ESMTP; 24 Mar 2019 22:43:36 -0700
From: Qi Zhang <qi.z.zhang@intel.com>
To: wenzhuo.lu@intel.com,
	qiming.yang@intel.com
Cc: dev@dpdk.org, paul.m.stillwell.jr@intel.com, ferruh.yigit@intel.com,
 Qi Zhang <qi.z.zhang@intel.com>,
 Vignesh Sridhar <vignesh.sridhar@intel.com>
Date: Mon, 25 Mar 2019 13:44:38 +0800
Message-Id: <20190325054452.2616-25-qi.z.zhang@intel.com>
X-Mailer: git-send-email 2.13.6
In-Reply-To: <20190325054452.2616-1-qi.z.zhang@intel.com>
References: <20190228055650.25237-1-qi.z.zhang@intel.com>
 <20190325054452.2616-1-qi.z.zhang@intel.com>
Subject: [dpdk-dev] [PATCH v4 24/38] net/ice/base: remove local VSIG
	allocations
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Mon, 25 Mar 2019 05:43:39 -0000

If allocating a VSI to a VSIG fails the local allocations made for VSIG
profiles and change-lists will not be removed. Adding calls to free these
entries on error in VSIG management calls.

Signed-off-by: Vignesh Sridhar <vignesh.sridhar@intel.com>
Signed-off-by: Paul M Stillwell Jr <paul.m.stillwell.jr@intel.com>
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
Reviewed-by: Qiming Yang <qiming.yang@intel.com>
Reviewed-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
---
 drivers/net/ice/base/ice_flex_pipe.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ice/base/ice_flex_pipe.c b/drivers/net/ice/base/ice_flex_pipe.c
index 900a19387..887609204 100644
--- a/drivers/net/ice/base/ice_flex_pipe.c
+++ b/drivers/net/ice/base/ice_flex_pipe.c
@@ -4523,8 +4523,10 @@ ice_add_prof_id_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsig, u64 hdl,
 
 		/* allocate the TCAM entry index */
 		status = ice_alloc_tcam_ent(hw, blk, &tcam_idx);
-		if (status)
+		if (status) {
+			ice_free(hw, p);
 			goto err_ice_add_prof_id_vsig;
+		}
 
 		t->tcam[i].ptg = ptg;
 		t->tcam[i].prof_id = map->prof_id;
@@ -4563,6 +4565,7 @@ ice_add_prof_id_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsig, u64 hdl,
 
 err_ice_add_prof_id_vsig:
 	/* let caller clean up the change list */
+	ice_free(hw, t);
 	return ICE_ERR_NO_MEMORY;
 }
 
@@ -4587,16 +4590,18 @@ ice_create_prof_id_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsi, u64 hdl,
 		return ICE_ERR_NO_MEMORY;
 
 	new_vsig = ice_vsig_alloc(hw, blk);
-	if (!new_vsig)
-		return ICE_ERR_HW_TABLE;
+	if (!new_vsig) {
+		status = ICE_ERR_HW_TABLE;
+		goto err_ice_create_prof_id_vsig;
+	}
 
 	status = ice_move_vsi(hw, blk, vsi, new_vsig, chg);
 	if (status)
-		return status;
+		goto err_ice_create_prof_id_vsig;
 
 	status = ice_add_prof_id_vsig(hw, blk, new_vsig, hdl, chg);
 	if (status)
-		return status;
+		goto err_ice_create_prof_id_vsig;
 
 	p->type = ICE_VSIG_ADD;
 	p->vsi = vsi;
@@ -4606,6 +4611,11 @@ ice_create_prof_id_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsi, u64 hdl,
 	LIST_ADD(&p->list_entry, chg);
 
 	return ICE_SUCCESS;
+
+err_ice_create_prof_id_vsig:
+	/* let caller clean up the change list */
+	ice_free(hw, p);
+	return status;
 }
 
 /**
-- 
2.13.6

From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by dpdk.space (Postfix) with ESMTP id 9D0B6A05D3
	for <public@inbox.dpdk.org>; Mon, 25 Mar 2019 06:46:47 +0100 (CET)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id F10DA3256;
	Mon, 25 Mar 2019 06:44:12 +0100 (CET)
Received: from mga01.intel.com (mga01.intel.com [192.55.52.88])
 by dpdk.org (Postfix) with ESMTP id 04A4A5A6E
 for <dev@dpdk.org>; Mon, 25 Mar 2019 06:43:38 +0100 (CET)
X-Amp-Result: SKIPPED(no attachment in message)
X-Amp-File-Uploaded: False
Received: from orsmga008.jf.intel.com ([10.7.209.65])
 by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;
 24 Mar 2019 22:43:38 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.60,256,1549958400"; d="scan'208";a="128368771"
Received: from dpdk51.sh.intel.com ([10.67.110.245])
 by orsmga008.jf.intel.com with ESMTP; 24 Mar 2019 22:43:36 -0700
From: Qi Zhang <qi.z.zhang@intel.com>
To: wenzhuo.lu@intel.com,
	qiming.yang@intel.com
Cc: dev@dpdk.org, paul.m.stillwell.jr@intel.com, ferruh.yigit@intel.com,
 Qi Zhang <qi.z.zhang@intel.com>,
 Vignesh Sridhar <vignesh.sridhar@intel.com>
Date: Mon, 25 Mar 2019 13:44:38 +0800
Message-Id: <20190325054452.2616-25-qi.z.zhang@intel.com>
X-Mailer: git-send-email 2.13.6
In-Reply-To: <20190325054452.2616-1-qi.z.zhang@intel.com>
References: <20190228055650.25237-1-qi.z.zhang@intel.com>
 <20190325054452.2616-1-qi.z.zhang@intel.com>
Subject: [dpdk-dev] [PATCH v4 24/38] net/ice/base: remove local VSIG
	allocations
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>
Content-Type: text/plain; charset="UTF-8"
Message-ID: <20190325054438.5tImJKAB4NPXIYq9uIY10RodCNaaCyvOOM8Q940sj7w@z>

If allocating a VSI to a VSIG fails the local allocations made for VSIG
profiles and change-lists will not be removed. Adding calls to free these
entries on error in VSIG management calls.

Signed-off-by: Vignesh Sridhar <vignesh.sridhar@intel.com>
Signed-off-by: Paul M Stillwell Jr <paul.m.stillwell.jr@intel.com>
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
Reviewed-by: Qiming Yang <qiming.yang@intel.com>
Reviewed-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
---
 drivers/net/ice/base/ice_flex_pipe.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ice/base/ice_flex_pipe.c b/drivers/net/ice/base/ice_flex_pipe.c
index 900a19387..887609204 100644
--- a/drivers/net/ice/base/ice_flex_pipe.c
+++ b/drivers/net/ice/base/ice_flex_pipe.c
@@ -4523,8 +4523,10 @@ ice_add_prof_id_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsig, u64 hdl,
 
 		/* allocate the TCAM entry index */
 		status = ice_alloc_tcam_ent(hw, blk, &tcam_idx);
-		if (status)
+		if (status) {
+			ice_free(hw, p);
 			goto err_ice_add_prof_id_vsig;
+		}
 
 		t->tcam[i].ptg = ptg;
 		t->tcam[i].prof_id = map->prof_id;
@@ -4563,6 +4565,7 @@ ice_add_prof_id_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsig, u64 hdl,
 
 err_ice_add_prof_id_vsig:
 	/* let caller clean up the change list */
+	ice_free(hw, t);
 	return ICE_ERR_NO_MEMORY;
 }
 
@@ -4587,16 +4590,18 @@ ice_create_prof_id_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsi, u64 hdl,
 		return ICE_ERR_NO_MEMORY;
 
 	new_vsig = ice_vsig_alloc(hw, blk);
-	if (!new_vsig)
-		return ICE_ERR_HW_TABLE;
+	if (!new_vsig) {
+		status = ICE_ERR_HW_TABLE;
+		goto err_ice_create_prof_id_vsig;
+	}
 
 	status = ice_move_vsi(hw, blk, vsi, new_vsig, chg);
 	if (status)
-		return status;
+		goto err_ice_create_prof_id_vsig;
 
 	status = ice_add_prof_id_vsig(hw, blk, new_vsig, hdl, chg);
 	if (status)
-		return status;
+		goto err_ice_create_prof_id_vsig;
 
 	p->type = ICE_VSIG_ADD;
 	p->vsi = vsi;
@@ -4606,6 +4611,11 @@ ice_create_prof_id_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsi, u64 hdl,
 	LIST_ADD(&p->list_entry, chg);
 
 	return ICE_SUCCESS;
+
+err_ice_create_prof_id_vsig:
+	/* let caller clean up the change list */
+	ice_free(hw, p);
+	return status;
 }
 
 /**
-- 
2.13.6