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 inbox.dpdk.org (Postfix) with ESMTP id 432D7A04DB;
	Thu, 15 Oct 2020 15:32:01 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 640171E941;
	Thu, 15 Oct 2020 15:31:21 +0200 (CEST)
Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com
 [148.163.129.52]) by dpdk.org (Postfix) with ESMTP id 559831DDC3
 for <dev@dpdk.org>; Thu, 15 Oct 2020 15:31:16 +0200 (CEST)
Received: from mx1-us1.ppe-hosted.com (unknown [10.7.65.60])
 by dispatch1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id
 CE80E60163; Thu, 15 Oct 2020 13:31:14 +0000 (UTC)
Received: from us4-mdac16-66.ut7.mdlocal (unknown [10.7.64.78])
 by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id CA9E4200A3; 
 Thu, 15 Oct 2020 13:31:14 +0000 (UTC)
X-Virus-Scanned: Proofpoint Essentials engine
Received: from mx1-us1.ppe-hosted.com (unknown [10.7.65.174])
 by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 22A4C1C0057;
 Thu, 15 Oct 2020 13:31:14 +0000 (UTC)
Received: from webmail.solarflare.com (uk.solarflare.com [193.34.186.16])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits))
 (No client certificate requested)
 by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id C4ACF1C00A2;
 Thu, 15 Oct 2020 13:31:13 +0000 (UTC)
Received: from ukex01.SolarFlarecom.com (10.17.10.4) by
 ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server (TLS) id
 15.0.1497.2; Thu, 15 Oct 2020 14:31:10 +0100
Received: from opal.uk.solarflarecom.com (10.17.10.1) by
 ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server id
 15.0.1497.2 via Frontend Transport; Thu, 15 Oct 2020 14:31:10 +0100
Received: from ukv-loginhost.uk.solarflarecom.com
 (ukv-loginhost.uk.solarflarecom.com [10.17.10.39])
 by opal.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id 09FDVASV025329;
 Thu, 15 Oct 2020 14:31:10 +0100
Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1])
 by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id 854A81613AB;
 Thu, 15 Oct 2020 14:31:10 +0100 (BST)
From: Andrew Rybchenko <arybchenko@solarflare.com>
To: Harry van Haaren <harry.van.haaren@intel.com>, Ori Kam <orika@nvidia.com>, 
 Bruce Richardson <bruce.richardson@intel.com>, Radu Nicolau
 <radu.nicolau@intel.com>, Akhil Goyal <akhil.goyal@nxp.com>, Ferruh Yigit
 <ferruh.yigit@intel.com>, Sunil Kumar Kori <skori@marvell.com>, "Pavan
 Nikhilesh" <pbhagavatula@marvell.com>, Jerin Jacob <jerinj@marvell.com>,
 Kiran Kumar K <kirankumark@marvell.com>, Nithin Dabilpuram
 <ndabilpuram@marvell.com>, David Hunt <david.hunt@intel.com>
CC: <dev@dpdk.org>, Ivan Ilchenko <ivan.ilchenko@oktetlabs.ru>
Date: Thu, 15 Oct 2020 14:30:38 +0100
Message-ID: <1602768646-13142-5-git-send-email-arybchenko@solarflare.com>
X-Mailer: git-send-email 1.8.3.1
In-Reply-To: <1602768646-13142-1-git-send-email-arybchenko@solarflare.com>
References: <1602682146-4722-1-git-send-email-arybchenko@solarflare.com>
 <1602768646-13142-1-git-send-email-arybchenko@solarflare.com>
MIME-Version: 1.0
Content-Type: text/plain
X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.6.1012-25726.003
X-TM-AS-Result: No-2.300100-8.000000-10
X-TMASE-MatchedRID: 7SLQpEcfW2LRlxaUc/KTYX4neC0h7SAD3V4UShoTXad+SLLtNOiBhhOv
 qWE4CGBUQ0ew+orY3L24HGCfl+dhoCHhSBQfglfsA9lly13c/gHpVMb1xnESMqzk9k6NqjPuokW
 ZuZ853DcpVsEDak15htyo1A7d4w060X+0CFhNLNf9tX9U6GuaihfbPFE2GHrVVWQnHKxp38heUN
 p8uxj+xJv95NYHIKAjkth3obE9lGBZT98H9cWYnFVeGWZmxN2MBGvINcfHqhcRQQ4kFqjjJCOGa
 xJXnUqc4u2WwMxMdpLvK3TBvg+vxe1KuqFSI2KuTauf2PrRb1vdYVrFVbszaGz3xnx8b/qRcHKR
 PTYj/V07OJE/RLyfLuXcvHH+KGk9Q9tg+p38ZonHmyDJSEsI25yqUJ2uHKFAKBVvFbsUM5WX35n
 GkdKgi+LzNWBegCW2wgn7iDBesS0nRE+fI6etkgnsbzHpYjvhuxpkqxafWL5EBS3KcDyYkcVQU8
 YbML/FtmFdb/3pS0HeQgfNIzFT9RMvyGZyKSqgt62H/TaJzn1dkhglm41jPL1NuKS30BZnQIFIZ
 LtsgG0DUH+nVLNyiCsqIP9TxvtJMb6p570ilnc=
X-TM-AS-User-Approved-Sender: Yes
X-TM-AS-User-Blocked-Sender: No
X-TMASE-Result: 10--2.300100-8.000000
X-TMASE-Version: SMEX-12.5.0.1300-8.6.1012-25726.003
X-MDID: 1602768674-uvrqOX5CJeQA
X-PPE-DISP: 1602768674;uvrqOX5CJeQA
Subject: [dpdk-dev] [PATCH v2 04/11] examples: check eth dev stop status
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>

From: Ivan Ilchenko <ivan.ilchenko@oktetlabs.ru>

rte_eth_dev_stop() return value was changed from void to int,
so this patch modify usage of this function across examples
according to new return type.

Signed-off-by: Ivan Ilchenko <ivan.ilchenko@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 examples/ethtool/lib/rte_ethtool.c  | 15 ++++++++------
 examples/eventdev_pipeline/main.c   |  3 ++-
 examples/flow_filtering/main.c      | 13 +++++++-----
 examples/ioat/ioatfwd.c             |  6 +++++-
 examples/ipsec-secgw/event_helper.c |  7 ++++++-
 examples/ipsec-secgw/ipsec-secgw.c  |  7 ++++++-
 examples/kni/main.c                 | 32 ++++++++++++++++++++++++-----
 examples/l2fwd-event/main.c         | 10 +++++++--
 examples/l2fwd/main.c               |  5 ++++-
 examples/l3fwd-graph/main.c         |  5 ++++-
 examples/l3fwd-power/main.c         |  6 +++++-
 examples/l3fwd/main.c               | 10 +++++++--
 12 files changed, 92 insertions(+), 27 deletions(-)

diff --git a/examples/ethtool/lib/rte_ethtool.c b/examples/ethtool/lib/rte_ethtool.c
index db8150efd5..86e3de078c 100644
--- a/examples/ethtool/lib/rte_ethtool.c
+++ b/examples/ethtool/lib/rte_ethtool.c
@@ -297,7 +297,11 @@ rte_ethtool_set_pauseparam(uint16_t port_id,
 int
 rte_ethtool_net_open(uint16_t port_id)
 {
-	rte_eth_dev_stop(port_id);
+	int ret;
+
+	ret = rte_eth_dev_stop(port_id);
+	if (ret != 0)
+		return ret;
 
 	return rte_eth_dev_start(port_id);
 }
@@ -305,10 +309,7 @@ rte_ethtool_net_open(uint16_t port_id)
 int
 rte_ethtool_net_stop(uint16_t port_id)
 {
-	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
-	rte_eth_dev_stop(port_id);
-
-	return 0;
+	return rte_eth_dev_stop(port_id);
 }
 
 int
@@ -459,7 +460,9 @@ rte_ethtool_set_ringparam(uint16_t port_id,
 	if (stat != 0)
 		return stat;
 
-	rte_eth_dev_stop(port_id);
+	stat = rte_eth_dev_stop(port_id);
+	if (stat != 0)
+		return stat;
 
 	stat = rte_eth_tx_queue_setup(port_id, 0, ring_param->tx_pending,
 		rte_socket_id(), NULL);
diff --git a/examples/eventdev_pipeline/main.c b/examples/eventdev_pipeline/main.c
index 4ac5821539..597540c3d6 100644
--- a/examples/eventdev_pipeline/main.c
+++ b/examples/eventdev_pipeline/main.c
@@ -296,7 +296,8 @@ signal_handler(int signum)
 		RTE_ETH_FOREACH_DEV(portid) {
 			rte_event_eth_rx_adapter_stop(portid);
 			rte_event_eth_tx_adapter_stop(portid);
-			rte_eth_dev_stop(portid);
+			if (rte_eth_dev_stop(portid) < 0)
+				printf("Failed to stop port %u", portid);
 		}
 
 		rte_eal_mp_wait_lcore();
diff --git a/examples/flow_filtering/main.c b/examples/flow_filtering/main.c
index cc9e7e7808..93523d625b 100644
--- a/examples/flow_filtering/main.c
+++ b/examples/flow_filtering/main.c
@@ -52,7 +52,7 @@ print_ether_addr(const char *what, struct rte_ether_addr *eth_addr)
 	printf("%s%s", what, buf);
 }
 
-static void
+static int
 main_loop(void)
 {
 	struct rte_mbuf *mbufs[32];
@@ -61,6 +61,7 @@ main_loop(void)
 	uint16_t nb_rx;
 	uint16_t i;
 	uint16_t j;
+	int ret;
 
 	while (!force_quit) {
 		for (i = 0; i < nr_queues; i++) {
@@ -88,8 +89,12 @@ main_loop(void)
 
 	/* closing and releasing resources */
 	rte_flow_flush(port_id, &error);
-	rte_eth_dev_stop(port_id);
+	ret = rte_eth_dev_stop(port_id);
+	if (ret < 0)
+		printf("Failed to stop port %u: %s",
+		       port_id, rte_strerror(-ret));
 	rte_eth_dev_close(port_id);
+	return ret;
 }
 
 #define CHECK_INTERVAL 1000  /* 100ms */
@@ -254,7 +259,5 @@ main(int argc, char **argv)
 		rte_exit(EXIT_FAILURE, "error in creating flow");
 	}
 
-	main_loop();
-
-	return 0;
+	return main_loop();
 }
diff --git a/examples/ioat/ioatfwd.c b/examples/ioat/ioatfwd.c
index 8cf606e25b..dc1ef951c1 100644
--- a/examples/ioat/ioatfwd.c
+++ b/examples/ioat/ioatfwd.c
@@ -995,7 +995,11 @@ main(int argc, char **argv)
 	uint32_t j;
 	for (i = 0; i < cfg.nb_ports; i++) {
 		printf("Closing port %d\n", cfg.ports[i].rxtx_port);
-		rte_eth_dev_stop(cfg.ports[i].rxtx_port);
+		ret = rte_eth_dev_stop(cfg.ports[i].rxtx_port);
+		if (ret != 0)
+			RTE_LOG(ERR, IOAT, "rte_eth_dev_stop: err=%s, port=%u\n",
+				rte_strerror(-ret), cfg.ports[i].rxtx_port);
+
 		rte_eth_dev_close(cfg.ports[i].rxtx_port);
 		if (copy_mode == COPY_MODE_IOAT_NUM) {
 			for (j = 0; j < cfg.ports[i].nb_queues; j++) {
diff --git a/examples/ipsec-secgw/event_helper.c b/examples/ipsec-secgw/event_helper.c
index 865dc911b8..ce4dbdc085 100644
--- a/examples/ipsec-secgw/event_helper.c
+++ b/examples/ipsec-secgw/event_helper.c
@@ -1583,7 +1583,12 @@ eh_devs_init(struct eh_conf *conf)
 		if ((conf->eth_portmask & (1 << port_id)) == 0)
 			continue;
 
-		rte_eth_dev_stop(port_id);
+		ret = rte_eth_dev_stop(port_id);
+		if (ret != 0) {
+			EH_LOG_ERR("Failed to stop port %u, err: %d",
+					port_id, ret);
+			return ret;
+		}
 	}
 
 	/* Setup eventdev */
diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c
index 60132c4bd7..58ecfd6f76 100644
--- a/examples/ipsec-secgw/ipsec-secgw.c
+++ b/examples/ipsec-secgw/ipsec-secgw.c
@@ -3032,7 +3032,12 @@ main(int32_t argc, char **argv)
 					" for port %u, err msg: %s\n", portid,
 					err.message);
 		}
-		rte_eth_dev_stop(portid);
+		ret = rte_eth_dev_stop(portid);
+		if (ret != 0)
+			RTE_LOG(ERR, IPSEC,
+				"rte_eth_dev_stop: err=%s, port=%u\n",
+				rte_strerror(-ret), portid);
+
 		rte_eth_dev_close(portid);
 		printf(" Done\n");
 	}
diff --git a/examples/kni/main.c b/examples/kni/main.c
index 2223bd367d..ac6309e072 100644
--- a/examples/kni/main.c
+++ b/examples/kni/main.c
@@ -782,7 +782,12 @@ kni_change_mtu_(uint16_t port_id, unsigned int new_mtu)
 	RTE_LOG(INFO, APP, "Change MTU of port %d to %u\n", port_id, new_mtu);
 
 	/* Stop specific port */
-	rte_eth_dev_stop(port_id);
+	ret = rte_eth_dev_stop(port_id);
+	if (ret != 0) {
+		RTE_LOG(ERR, APP, "Failed to stop port %d: %s\n",
+			port_id, rte_strerror(-ret));
+		return ret;
+	}
 
 	memcpy(&conf, &port_conf, sizeof(conf));
 	/* Set new MTU */
@@ -875,10 +880,23 @@ kni_config_network_interface(uint16_t port_id, uint8_t if_up)
 	rte_atomic32_inc(&kni_pause);
 
 	if (if_up != 0) { /* Configure network interface up */
-		rte_eth_dev_stop(port_id);
+		ret = rte_eth_dev_stop(port_id);
+		if (ret != 0) {
+			RTE_LOG(ERR, APP, "Failed to stop port %d: %s\n",
+				port_id, rte_strerror(-ret));
+			rte_atomic32_dec(&kni_pause);
+			return ret;
+		}
 		ret = rte_eth_dev_start(port_id);
-	} else /* Configure network interface down */
-		rte_eth_dev_stop(port_id);
+	} else { /* Configure network interface down */
+		ret = rte_eth_dev_stop(port_id);
+		if (ret != 0) {
+			RTE_LOG(ERR, APP, "Failed to stop port %d: %s\n",
+				port_id, rte_strerror(-ret));
+			rte_atomic32_dec(&kni_pause);
+			return ret;
+		}
+	}
 
 	rte_atomic32_dec(&kni_pause);
 
@@ -998,6 +1016,7 @@ static int
 kni_free_kni(uint16_t port_id)
 {
 	uint8_t i;
+	int ret;
 	struct kni_port_params **p = kni_port_params_array;
 
 	if (port_id >= RTE_MAX_ETHPORTS || !p[port_id])
@@ -1008,7 +1027,10 @@ kni_free_kni(uint16_t port_id)
 			printf("Fail to release kni\n");
 		p[port_id]->kni[i] = NULL;
 	}
-	rte_eth_dev_stop(port_id);
+	ret = rte_eth_dev_stop(port_id);
+	if (ret != 0)
+		RTE_LOG(ERR, APP, "Failed to stop port %d: %s\n",
+			port_id, rte_strerror(-ret));
 
 	return 0;
 }
diff --git a/examples/l2fwd-event/main.c b/examples/l2fwd-event/main.c
index 9f831b1266..b48794d6bc 100644
--- a/examples/l2fwd-event/main.c
+++ b/examples/l2fwd-event/main.c
@@ -683,7 +683,10 @@ main(int argc, char **argv)
 			if ((rsrc->enabled_port_mask &
 							(1 << port_id)) == 0)
 				continue;
-			rte_eth_dev_stop(port_id);
+			ret = rte_eth_dev_stop(port_id);
+			if (ret < 0)
+				printf("rte_eth_dev_stop:err=%d, port=%u\n",
+				       ret, port_id);
 		}
 
 		rte_eal_mp_wait_lcore();
@@ -705,7 +708,10 @@ main(int argc, char **argv)
 							(1 << port_id)) == 0)
 				continue;
 			printf("Closing port %d...", port_id);
-			rte_eth_dev_stop(port_id);
+			ret = rte_eth_dev_stop(port_id);
+			if (ret < 0)
+				printf("rte_eth_dev_stop:err=%d, port=%u\n",
+				       ret, port_id);
 			rte_eth_dev_close(port_id);
 			printf(" Done\n");
 		}
diff --git a/examples/l2fwd/main.c b/examples/l2fwd/main.c
index 7e3078788e..7d1b08a8f7 100644
--- a/examples/l2fwd/main.c
+++ b/examples/l2fwd/main.c
@@ -896,7 +896,10 @@ main(int argc, char **argv)
 		if ((l2fwd_enabled_port_mask & (1 << portid)) == 0)
 			continue;
 		printf("Closing port %d...", portid);
-		rte_eth_dev_stop(portid);
+		ret = rte_eth_dev_stop(portid);
+		if (ret != 0)
+			printf("rte_eth_dev_stop: err=%d, port=%d\n",
+			       ret, portid);
 		rte_eth_dev_close(portid);
 		printf(" Done\n");
 	}
diff --git a/examples/l3fwd-graph/main.c b/examples/l3fwd-graph/main.c
index 2306ba9b07..2fd536e592 100644
--- a/examples/l3fwd-graph/main.c
+++ b/examples/l3fwd-graph/main.c
@@ -1116,7 +1116,10 @@ main(int argc, char **argv)
 		if ((enabled_port_mask & (1 << portid)) == 0)
 			continue;
 		printf("Closing port %d...", portid);
-		rte_eth_dev_stop(portid);
+		ret = rte_eth_dev_stop(portid);
+		if (ret != 0)
+			printf("Failed to stop port %u: %s\n",
+			       portid, rte_strerror(-ret));
 		rte_eth_dev_close(portid);
 		printf(" Done\n");
 	}
diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c
index d0e6c9bd77..b1535b2749 100644
--- a/examples/l3fwd-power/main.c
+++ b/examples/l3fwd-power/main.c
@@ -2805,7 +2805,11 @@ main(int argc, char **argv)
 		if ((enabled_port_mask & (1 << portid)) == 0)
 			continue;
 
-		rte_eth_dev_stop(portid);
+		ret = rte_eth_dev_stop(portid);
+		if (ret != 0)
+			RTE_LOG(ERR, L3FWD_POWER, "rte_eth_dev_stop: err=%d, port=%u\n",
+				ret, portid);
+
 		rte_eth_dev_close(portid);
 	}
 
diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c
index 80f3434ec2..3811a1efbf 100644
--- a/examples/l3fwd/main.c
+++ b/examples/l3fwd/main.c
@@ -1284,7 +1284,10 @@ main(int argc, char **argv)
 		RTE_ETH_FOREACH_DEV(portid) {
 			if ((enabled_port_mask & (1 << portid)) == 0)
 				continue;
-			rte_eth_dev_stop(portid);
+			ret = rte_eth_dev_stop(portid);
+			if (ret != 0)
+				printf("rte_eth_dev_stop: err=%d, port=%u\n",
+				       ret, portid);
 		}
 
 		rte_eal_mp_wait_lcore();
@@ -1304,7 +1307,10 @@ main(int argc, char **argv)
 			if ((enabled_port_mask & (1 << portid)) == 0)
 				continue;
 			printf("Closing port %d...", portid);
-			rte_eth_dev_stop(portid);
+			ret = rte_eth_dev_stop(portid);
+			if (ret != 0)
+				printf("rte_eth_dev_stop: err=%d, port=%u\n",
+				       ret, portid);
 			rte_eth_dev_close(portid);
 			printf(" Done\n");
 		}
-- 
2.17.1