From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id A8DBDA0C46;
	Fri, 18 Jun 2021 12:44:49 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 5EF3E411FF;
	Fri, 18 Jun 2021 12:41:16 +0200 (CEST)
Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com
 [67.231.148.174])
 by mails.dpdk.org (Postfix) with ESMTP id F0025411FD
 for <dev@dpdk.org>; Fri, 18 Jun 2021 12:41:14 +0200 (CEST)
Received: from pps.filterd (m0045849.ppops.net [127.0.0.1])
 by mx0a-0016f401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id
 15IAZVh0032321 for <dev@dpdk.org>; Fri, 18 Jun 2021 03:41:14 -0700
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com;
 h=from : to : cc :
 subject : date : message-id : in-reply-to : references : mime-version :
 content-type; s=pfpt0220; bh=GhxCDWRIrUhVFT1jwFyTIZaIoSZNtI9FimrVdqgX70o=;
 b=N1aCzZob8NE6zK59gXCsQuknlgUrFAvPRzqKJsw2kKzk8IewX9ZXK2nME2NDJrfMzbfS
 +X4e6HQ3hb6THuYBthlB4FnYQzVdhUIVPyXRjVnOshzBHp0ulHNbeDO313mTDoJjQ6CB
 gXB4N/6DmeVGzeq8teWQXeKb6VihoLHGiRdF0bhtG3WjlpR8Au5a81vLr5k/cUQ/6B7f
 77cB6IhG1GKEyZ/Ruw6nIRO9UBFw76Owzjm0N32b2bDmNNlUeZj1nCjIJ47rKFCZsJ78
 EpOjZrJD4Bt1G92wTEQSjnKdJu2RGEc/zzGRZBvNVmK8lmfA3La+Z0ODojYynX/AQxPt HQ== 
Received: from dc5-exch02.marvell.com ([199.233.59.182])
 by mx0a-0016f401.pphosted.com with ESMTP id 398r750d71-1
 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT)
 for <dev@dpdk.org>; Fri, 18 Jun 2021 03:41:13 -0700
Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com
 (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18;
 Fri, 18 Jun 2021 03:41:12 -0700
Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com
 (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend
 Transport; Fri, 18 Jun 2021 03:41:12 -0700
Received: from hyd1588t430.marvell.com (unknown [10.29.52.204])
 by maili.marvell.com (Postfix) with ESMTP id 9B8445B69A3;
 Fri, 18 Jun 2021 03:40:56 -0700 (PDT)
From: Nithin Dabilpuram <ndabilpuram@marvell.com>
To: <dev@dpdk.org>
CC: <jerinj@marvell.com>, <skori@marvell.com>, <skoteshwar@marvell.com>,
 <pbhagavatula@marvell.com>, <kirankumark@marvell.com>,
 <psatheesh@marvell.com>, <asekhar@marvell.com>, <hkalra@marvell.com>
Date: Fri, 18 Jun 2021 16:07:25 +0530
Message-ID: <20210618103741.26526-47-ndabilpuram@marvell.com>
X-Mailer: git-send-email 2.8.4
In-Reply-To: <20210618103741.26526-1-ndabilpuram@marvell.com>
References: <20210306153404.10781-1-ndabilpuram@marvell.com>
 <20210618103741.26526-1-ndabilpuram@marvell.com>
MIME-Version: 1.0
Content-Type: text/plain
X-Proofpoint-ORIG-GUID: AksIhuUb_Qcx40RtkiVFbnsZdq2sQDMd
X-Proofpoint-GUID: AksIhuUb_Qcx40RtkiVFbnsZdq2sQDMd
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790
 definitions=2021-06-18_04:2021-06-18,
 2021-06-18 signatures=0
Subject: [dpdk-dev] [PATCH v3 46/62] net/cnxk: add device close and reset
 operations
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
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>

From: Sunil Kumar Kori <skori@marvell.com>

Patch implements device close and reset operations for cn9k
and cn10k platforms.

Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
---
 drivers/net/cnxk/cnxk_ethdev.c | 35 ++++++++++++++++++++++++++++-------
 1 file changed, 28 insertions(+), 7 deletions(-)

diff --git a/drivers/net/cnxk/cnxk_ethdev.c b/drivers/net/cnxk/cnxk_ethdev.c
index 288e069..3929e7e 100644
--- a/drivers/net/cnxk/cnxk_ethdev.c
+++ b/drivers/net/cnxk/cnxk_ethdev.c
@@ -1154,6 +1154,9 @@ cnxk_nix_dev_start(struct rte_eth_dev *eth_dev)
 	return rc;
 }
 
+static int cnxk_nix_dev_reset(struct rte_eth_dev *eth_dev);
+static int cnxk_nix_dev_close(struct rte_eth_dev *eth_dev);
+
 /* CNXK platform independent eth dev ops */
 struct eth_dev_ops cnxk_eth_dev_ops = {
 	.mtu_set = cnxk_nix_mtu_set,
@@ -1165,6 +1168,8 @@ struct eth_dev_ops cnxk_eth_dev_ops = {
 	.tx_queue_release = cnxk_nix_tx_queue_release,
 	.rx_queue_release = cnxk_nix_rx_queue_release,
 	.dev_stop = cnxk_nix_dev_stop,
+	.dev_close = cnxk_nix_dev_close,
+	.dev_reset = cnxk_nix_dev_reset,
 	.tx_queue_start = cnxk_nix_tx_queue_start,
 	.rx_queue_start = cnxk_nix_rx_queue_start,
 	.rx_queue_stop = cnxk_nix_rx_queue_stop,
@@ -1304,7 +1309,7 @@ cnxk_eth_dev_init(struct rte_eth_dev *eth_dev)
 }
 
 static int
-cnxk_eth_dev_uninit(struct rte_eth_dev *eth_dev, bool mbox_close)
+cnxk_eth_dev_uninit(struct rte_eth_dev *eth_dev, bool reset)
 {
 	struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
 	const struct eth_dev_ops *dev_ops = eth_dev->dev_ops;
@@ -1358,14 +1363,11 @@ cnxk_eth_dev_uninit(struct rte_eth_dev *eth_dev, bool mbox_close)
 	rte_free(eth_dev->data->mac_addrs);
 	eth_dev->data->mac_addrs = NULL;
 
-	/* Check if mbox close is needed */
-	if (!mbox_close)
-		return 0;
-
 	rc = roc_nix_dev_fini(nix);
 	/* Can be freed later by PMD if NPA LF is in use */
 	if (rc == -EAGAIN) {
-		eth_dev->data->dev_private = NULL;
+		if (!reset)
+			eth_dev->data->dev_private = NULL;
 		return 0;
 	} else if (rc) {
 		plt_err("Failed in nix dev fini, rc=%d", rc);
@@ -1374,6 +1376,25 @@ cnxk_eth_dev_uninit(struct rte_eth_dev *eth_dev, bool mbox_close)
 	return rc;
 }
 
+static int
+cnxk_nix_dev_close(struct rte_eth_dev *eth_dev)
+{
+	cnxk_eth_dev_uninit(eth_dev, false);
+	return 0;
+}
+
+static int
+cnxk_nix_dev_reset(struct rte_eth_dev *eth_dev)
+{
+	int rc;
+
+	rc = cnxk_eth_dev_uninit(eth_dev, true);
+	if (rc)
+		return rc;
+
+	return cnxk_eth_dev_init(eth_dev);
+}
+
 int
 cnxk_nix_remove(struct rte_pci_device *pci_dev)
 {
@@ -1384,7 +1405,7 @@ cnxk_nix_remove(struct rte_pci_device *pci_dev)
 	eth_dev = rte_eth_dev_allocated(pci_dev->device.name);
 	if (eth_dev) {
 		/* Cleanup eth dev */
-		rc = cnxk_eth_dev_uninit(eth_dev, true);
+		rc = cnxk_eth_dev_uninit(eth_dev, false);
 		if (rc)
 			return rc;
 
-- 
2.8.4