DPDK patches and discussions
 help / color / mirror / Atom feed
From: Andrew Rybchenko <arybchenko@solarflare.com>
To: Wenzhuo Lu <wenzhuo.lu@intel.com>,
	Jingjing Wu <jingjing.wu@intel.com>,
	Bernard Iremonger <bernard.iremonger@intel.com>
Cc: <dev@dpdk.org>, Igor Romanov <igor.romanov@oktetlabs.ru>
Subject: [dpdk-dev] [PATCH 03/18] app/testpmd: check status of getting link info
Date: Tue, 10 Sep 2019 09:25:43 +0100	[thread overview]
Message-ID: <1568103959-25572-4-git-send-email-arybchenko@solarflare.com> (raw)
In-Reply-To: <1568103959-25572-1-git-send-email-arybchenko@solarflare.com>

From: Igor Romanov <igor.romanov@oktetlabs.ru>

Add a wrapper for rte_eth_eth_link_get_nowait() that prints an
error and returns a status code if the function fails.

Signed-off-by: Igor Romanov <igor.romanov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 app/test-pmd/config.c     | 13 ++++++++++---
 app/test-pmd/softnicfwd.c | 16 +++++++++++++---
 app/test-pmd/testpmd.c    | 10 +++++++++-
 app/test-pmd/testpmd.h    |  1 +
 app/test-pmd/util.c       | 14 ++++++++++++++
 5 files changed, 47 insertions(+), 7 deletions(-)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 857b6dabc..33a4e9827 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -484,7 +484,9 @@ port_infos_display(portid_t port_id)
 		return;
 	}
 	port = &ports[port_id];
-	rte_eth_link_get_nowait(port_id, &link);
+	ret = eth_link_get_nowait_print_err(port_id, &link);
+	if (ret < 0)
+		return;
 
 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
 	if (ret != 0)
@@ -635,7 +637,9 @@ port_summary_display(portid_t port_id)
 		return;
 	}
 
-	rte_eth_link_get_nowait(port_id, &link);
+	ret = eth_link_get_nowait_print_err(port_id, &link);
+	if (ret < 0)
+		return;
 
 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
 	if (ret != 0)
@@ -3521,10 +3525,13 @@ set_queue_rate_limit(portid_t port_id, uint16_t queue_idx, uint16_t rate)
 {
 	int diag;
 	struct rte_eth_link link;
+	int ret;
 
 	if (port_id_is_invalid(port_id, ENABLED_WARN))
 		return 1;
-	rte_eth_link_get_nowait(port_id, &link);
+	ret = eth_link_get_nowait_print_err(port_id, &link);
+	if (ret < 0)
+		return 1;
 	if (rate > link.link_speed) {
 		printf("Invalid rate value:%u bigger than link speed: %u\n",
 			rate, link.link_speed);
diff --git a/app/test-pmd/softnicfwd.c b/app/test-pmd/softnicfwd.c
index 94e6669d3..e9d437364 100644
--- a/app/test-pmd/softnicfwd.c
+++ b/app/test-pmd/softnicfwd.c
@@ -163,16 +163,22 @@ softnic_begin(void *arg __rte_unused)
 	return 0;
 }
 
-static void
+static int
 set_tm_hiearchy_nodes_shaper_rate(portid_t port_id,
 	struct tm_hierarchy *h)
 {
 	struct rte_eth_link link_params;
 	uint64_t tm_port_rate;
+	int ret;
 
 	memset(&link_params, 0, sizeof(link_params));
 
-	rte_eth_link_get(port_id, &link_params);
+	ret = rte_eth_link_get(port_id, &link_params);
+	if (ret < 0) {
+		printf("Error during getting device (port %u) link info: %s\n",
+			port_id, rte_strerror(-ret));
+		return ret;
+	}
 	tm_port_rate = (uint64_t)ETH_SPEED_NUM_10G * BYTES_IN_MBPS;
 
 	/* Set tm hierarchy shapers rate */
@@ -183,6 +189,8 @@ set_tm_hiearchy_nodes_shaper_rate(portid_t port_id,
 		= h->subport_node_shaper_rate / PIPE_NODES_PER_SUBPORT;
 	h->tc_node_shaper_rate = h->pipe_node_shaper_rate;
 	h->tc_node_shared_shaper_rate = h->subport_node_shaper_rate;
+
+	return 0;
 }
 
 static int
@@ -554,7 +562,9 @@ softport_tm_hierarchy_specify(portid_t port_id,
 	memset(&h, 0, sizeof(struct tm_hierarchy));
 
 	/* TM hierarchy shapers rate */
-	set_tm_hiearchy_nodes_shaper_rate(port_id, &h);
+	status = set_tm_hiearchy_nodes_shaper_rate(port_id, &h);
+	if (status)
+		return status;
 
 	/* Add root node (level 0) */
 	status = softport_tm_root_node_add(port_id, &h, error);
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 2a57978fd..0f6e27962 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -2625,6 +2625,7 @@ check_all_ports_link_status(uint32_t port_mask)
 	portid_t portid;
 	uint8_t count, all_ports_up, print_flag = 0;
 	struct rte_eth_link link;
+	int ret;
 
 	printf("Checking link statuses...\n");
 	fflush(stdout);
@@ -2634,7 +2635,14 @@ check_all_ports_link_status(uint32_t port_mask)
 			if ((port_mask & (1 << portid)) == 0)
 				continue;
 			memset(&link, 0, sizeof(link));
-			rte_eth_link_get_nowait(portid, &link);
+			ret = rte_eth_link_get_nowait(portid, &link);
+			if (ret < 0) {
+				all_ports_up = 0;
+				if (print_flag == 1)
+					printf("Port %u link get failed: %s\n",
+						portid, rte_strerror(-ret));
+				continue;
+			}
 			/* print link status if flag set */
 			if (print_flag == 1) {
 				if (link.link_status)
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index f1529696f..c039e2961 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -826,6 +826,7 @@ int eth_dev_info_get_print_err(uint16_t port_id,
 			struct rte_eth_dev_info *dev_info);
 void eth_set_promisc_mode(uint16_t port_id, int enable);
 void eth_set_allmulticast_mode(uint16_t port, int enable);
+int eth_link_get_nowait_print_err(uint16_t port_id, struct rte_eth_link *link);
 
 
 /* Functions to manage the set of filtered Multicast MAC addresses */
diff --git a/app/test-pmd/util.c b/app/test-pmd/util.c
index 1aec5d755..6c24bf8d9 100644
--- a/app/test-pmd/util.c
+++ b/app/test-pmd/util.c
@@ -277,3 +277,17 @@ eth_set_allmulticast_mode(uint16_t port, int enable)
 			enable ? "enabling" : "disabling",
 			port, rte_strerror(-ret));
 }
+
+int
+eth_link_get_nowait_print_err(uint16_t port_id,
+					struct rte_eth_link *link)
+{
+	int ret;
+
+	ret = rte_eth_link_get_nowait(port_id, link);
+	if (ret < 0)
+		printf("Device (port %u) link get (without wait) failed: %s\n",
+			port_id, rte_strerror(-ret));
+
+	return ret;
+}
-- 
2.17.1


  parent reply	other threads:[~2019-09-10  8:26 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-10  8:25 [dpdk-dev] [PATCH 00/18] ethdev: change link status get functions return value to int Andrew Rybchenko
2019-09-10  8:25 ` [dpdk-dev] [PATCH 01/18] net/bonding: fix link speed update in broadcast mode Andrew Rybchenko
2019-09-10 23:01   ` Chas Williams
2019-09-10  8:25 ` [dpdk-dev] [PATCH 02/18] ethdev: change link status get functions return value to int Andrew Rybchenko
2019-09-10  8:25 ` Andrew Rybchenko [this message]
2019-09-10  8:25 ` [dpdk-dev] [PATCH 04/18] net/bonding: check status of getting link info Andrew Rybchenko
2019-09-10  8:25 ` [dpdk-dev] [PATCH 05/18] net/ixgbe: " Andrew Rybchenko
2019-09-10  8:25 ` [dpdk-dev] [PATCH 06/18] net/memif: " Andrew Rybchenko
2019-09-10  8:25 ` [dpdk-dev] [PATCH 07/18] app/proc-info: " Andrew Rybchenko
2019-09-10  8:25 ` [dpdk-dev] [PATCH 08/18] app/test: " Andrew Rybchenko
2019-09-10  8:25 ` [dpdk-dev] [PATCH 09/18] app/pipeline: " Andrew Rybchenko
2019-09-10  8:25 ` [dpdk-dev] [PATCH 10/18] examples: " Andrew Rybchenko
2019-09-10  8:25 ` [dpdk-dev] [PATCH 11/18] examples/bbdev_app: " Andrew Rybchenko
2019-09-10  8:25 ` [dpdk-dev] [PATCH 12/18] examples/ip_pipeline: " Andrew Rybchenko
2019-09-10  8:25 ` [dpdk-dev] [PATCH 13/18] examples/ethtool: " Andrew Rybchenko
2019-09-10  8:25 ` [dpdk-dev] [PATCH 14/18] examples/flow_filtering: " Andrew Rybchenko
2019-09-12  5:16   ` Ori Kam
2019-09-10  8:25 ` [dpdk-dev] [PATCH 15/18] examples/link_status_interrupt: check status of getting link Andrew Rybchenko
2019-09-10  8:25 ` [dpdk-dev] [PATCH 16/18] examples/distributor: check status of getting link info Andrew Rybchenko
2019-09-10  8:25 ` [dpdk-dev] [PATCH 17/18] examples/qos_sched: " Andrew Rybchenko
2019-09-10  8:25 ` [dpdk-dev] [PATCH 18/18] examples/kni: " Andrew Rybchenko
2019-09-24 12:38 ` [dpdk-dev] [PATCH 00/18] ethdev: change link status get functions return value to int 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=1568103959-25572-4-git-send-email-arybchenko@solarflare.com \
    --to=arybchenko@solarflare.com \
    --cc=bernard.iremonger@intel.com \
    --cc=dev@dpdk.org \
    --cc=igor.romanov@oktetlabs.ru \
    --cc=jingjing.wu@intel.com \
    --cc=wenzhuo.lu@intel.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).