All of lore.kernel.org
 help / color / mirror / Atom feed
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>
Subject: [dpdk-dev] [PATCH 04/11] examples: check eth dev stop status
Date: Wed, 14 Oct 2020 14:28:59 +0100	[thread overview]
Message-ID: <1602682146-4722-5-git-send-email-arybchenko@solarflare.com> (raw)
In-Reply-To: <1602682146-4722-1-git-send-email-arybchenko@solarflare.com>

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  | 17 ++++++++++-------
 examples/eventdev_pipeline/main.c   |  3 ++-
 examples/flow_filtering/main.c      | 12 +++++++-----
 examples/ioat/ioatfwd.c             |  5 ++++-
 examples/ipsec-secgw/event_helper.c |  7 ++++++-
 examples/ipsec-secgw/ipsec-secgw.c  |  6 +++++-
 examples/kni/main.c                 | 28 +++++++++++++++++++++++-----
 examples/l2fwd-event/main.c         | 10 ++++++++--
 examples/l2fwd/main.c               |  5 ++++-
 examples/l3fwd-graph/main.c         |  6 +++++-
 examples/l3fwd-power/main.c         |  6 +++++-
 examples/l3fwd/main.c               | 10 ++++++++--
 12 files changed, 87 insertions(+), 28 deletions(-)

diff --git a/examples/ethtool/lib/rte_ethtool.c b/examples/ethtool/lib/rte_ethtool.c
index db8150efd5..78321b32ee 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
@@ -450,7 +451,7 @@ rte_ethtool_set_ringparam(uint16_t port_id,
 	struct ethtool_ringparam *ring_param)
 {
 	struct rte_eth_rxq_info rx_qinfo;
-	int stat;
+	int stat, ret;
 
 	if (ring_param == NULL)
 		return -EINVAL;
@@ -459,7 +460,9 @@ rte_ethtool_set_ringparam(uint16_t port_id,
 	if (stat != 0)
 		return stat;
 
-	rte_eth_dev_stop(port_id);
+	ret = rte_eth_dev_stop(port_id);
+	if (ret != 0)
+		return ret;
 
 	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..a92a4aa04e 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,11 @@ 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", port_id);
 	rte_eth_dev_close(port_id);
+	return ret;
 }
 
 #define CHECK_INTERVAL 1000  /* 100ms */
@@ -254,7 +258,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..73edb5da27 100644
--- a/examples/ioat/ioatfwd.c
+++ b/examples/ioat/ioatfwd.c
@@ -995,7 +995,10 @@ 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_exit(EXIT_FAILURE, "rte_eth_dev_stop: err=%s, port=%d\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..d83d9d8d5d 100644
--- a/examples/ipsec-secgw/ipsec-secgw.c
+++ b/examples/ipsec-secgw/ipsec-secgw.c
@@ -3032,7 +3032,11 @@ 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_exit(EXIT_FAILURE, "rte_eth_dev_stop: err=%s, port=%d\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..4998111d2c 100644
--- a/examples/kni/main.c
+++ b/examples/kni/main.c
@@ -782,7 +782,11 @@ 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\n", port_id);
+		return ret;
+	}
 
 	memcpy(&conf, &port_conf, sizeof(conf));
 	/* Set new MTU */
@@ -875,10 +879,19 @@ 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\n", port_id);
+			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\n", port_id);
+			return ret;
+		}
+	}
 
 	rte_atomic32_dec(&kni_pause);
 
@@ -998,6 +1011,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 +1022,11 @@ 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\n", port_id);
+		return ret;
+	}
 
 	return 0;
 }
diff --git a/examples/l2fwd-event/main.c b/examples/l2fwd-event/main.c
index 9f831b1266..ed60240083 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)
+				rte_panic("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)
+				rte_panic("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..8d6c7ec237 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)
+			rte_exit(EXIT_FAILURE, "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..fbe680aa5d 100644
--- a/examples/l3fwd-graph/main.c
+++ b/examples/l3fwd-graph/main.c
@@ -1116,7 +1116,11 @@ 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..9094cbc4e2 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


  parent reply	other threads:[~2020-10-14 13:30 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-14 13:28 [dpdk-dev] [PATCH 00/11] ethdev: change device stop to return status Andrew Rybchenko
2020-10-14 13:28 ` [dpdk-dev] [PATCH 01/11] ethdev: change eth dev stop function to return int Andrew Rybchenko
2020-10-14 13:33   ` Thomas Monjalon
2020-10-14 13:40     ` Andrew Rybchenko
2020-10-14 17:29   ` Ferruh Yigit
2020-10-14 13:28 ` [dpdk-dev] [PATCH 02/11] test/event: check eth dev stop status Andrew Rybchenko
2020-10-14 13:28 ` [dpdk-dev] [PATCH 03/11] app: " Andrew Rybchenko
2020-10-14 17:34   ` Ferruh Yigit
2020-10-14 13:28 ` Andrew Rybchenko [this message]
2020-10-14 17:38   ` [dpdk-dev] [PATCH 04/11] examples: " Ferruh Yigit
2020-10-14 13:29 ` [dpdk-dev] [PATCH 05/11] net/bonding: " Andrew Rybchenko
2020-10-14 17:45   ` Ferruh Yigit
2020-10-14 13:29 ` [dpdk-dev] [PATCH 06/11] kni: " Andrew Rybchenko
2020-10-14 13:29 ` [dpdk-dev] [PATCH 07/11] test/bonding: " Andrew Rybchenko
2020-10-14 13:29 ` [dpdk-dev] [PATCH 08/11] app/flow-perf: " Andrew Rybchenko
2020-10-15  8:04   ` Wisam Monther
2020-10-14 13:29 ` [dpdk-dev] [PATCH 09/11] app/testpmd: " Andrew Rybchenko
2020-10-14 13:29 ` [dpdk-dev] [PATCH 10/11] net/failsafe: " Andrew Rybchenko
2020-10-15 10:37   ` [dpdk-dev] [PATCH v2] " Gaetan Rivet
2020-10-14 13:29 ` [dpdk-dev] [PATCH 11/11] ethdev: change stop device callback to return int Andrew Rybchenko
2020-10-14 18:08   ` Ferruh Yigit
2020-10-15 10:40     ` Gaëtan Rivet
2020-10-15 13:30 ` [dpdk-dev] [PATCH v2 00/11] ethdev: change device stop to return status Andrew Rybchenko
2020-10-15 13:30   ` [dpdk-dev] [PATCH v2 01/11] ethdev: change eth dev stop function to return int Andrew Rybchenko
2020-10-16  9:22     ` Ferruh Yigit
2020-10-16 11:20     ` Kinsella, Ray
2020-10-16 17:13       ` Andrew Rybchenko
2020-10-19  9:37         ` Kinsella, Ray
2020-10-16 16:20     ` Ferruh Yigit
2020-10-15 13:30   ` [dpdk-dev] [PATCH v2 02/11] test/event: check eth dev stop status Andrew Rybchenko
2020-10-15 13:30   ` [dpdk-dev] [PATCH v2 03/11] app: " Andrew Rybchenko
2020-10-16  1:28     ` Min Hu (Connor)
2020-10-15 13:30   ` [dpdk-dev] [PATCH v2 04/11] examples: " Andrew Rybchenko
2020-10-15 13:30   ` [dpdk-dev] [PATCH v2 05/11] net/bonding: " Andrew Rybchenko
2020-10-15 13:30   ` [dpdk-dev] [PATCH v2 06/11] kni: " Andrew Rybchenko
2020-10-15 13:30   ` [dpdk-dev] [PATCH v2 07/11] test/bonding: " Andrew Rybchenko
2020-10-15 13:30   ` [dpdk-dev] [PATCH v2 08/11] app/flow-perf: " Andrew Rybchenko
2020-10-15 13:30   ` [dpdk-dev] [PATCH v2 09/11] app/testpmd: " Andrew Rybchenko
2020-10-15 13:30   ` [dpdk-dev] [PATCH v2 10/11] net/failsafe: " Andrew Rybchenko
2020-10-15 13:30   ` [dpdk-dev] [PATCH v2 11/11] ethdev: change stop device callback to return int Andrew Rybchenko
2020-10-16 18:37     ` Ferruh Yigit
2020-10-18  8:55     ` Xu, Rosen
2020-10-16 18:54   ` [dpdk-dev] [PATCH v2 00/11] ethdev: change device stop to return status 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=1602682146-4722-5-git-send-email-arybchenko@solarflare.com \
    --to=arybchenko@solarflare.com \
    --cc=Ivan.Ilchenko@oktetlabs.ru \
    --cc=akhil.goyal@nxp.com \
    --cc=bruce.richardson@intel.com \
    --cc=david.hunt@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=harry.van.haaren@intel.com \
    --cc=jerinj@marvell.com \
    --cc=kirankumark@marvell.com \
    --cc=ndabilpuram@marvell.com \
    --cc=orika@nvidia.com \
    --cc=pbhagavatula@marvell.com \
    --cc=radu.nicolau@intel.com \
    --cc=skori@marvell.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.