DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Subject: [PATCH 08/10] examples/qos_sched: check return value from rte_eth_link_get
Date: Fri,  4 Oct 2024 09:21:55 -0700	[thread overview]
Message-ID: <20241004162418.52940-9-stephen@networkplumber.org> (raw)
In-Reply-To: <20241004162418.52940-1-stephen@networkplumber.org>

The return status of link is undefined if call to rte_eth_link_get
returns an error.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/qos_sched/init.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/examples/qos_sched/init.c b/examples/qos_sched/init.c
index 32964fd57e..ace7279c67 100644
--- a/examples/qos_sched/init.c
+++ b/examples/qos_sched/init.c
@@ -323,6 +323,7 @@ int app_init(void)
 	uint32_t i;
 	char ring_name[MAX_NAME_LEN];
 	char pool_name[MAX_NAME_LEN];
+	int ret;
 
 	if (rte_eth_dev_count_avail() == 0)
 		rte_exit(EXIT_FAILURE, "No Ethernet port - bye\n");
@@ -368,12 +369,20 @@ int app_init(void)
 		app_init_port(qos_conf[i].tx_port, qos_conf[i].mbuf_pool);
 
 		memset(&link, 0, sizeof(link));
-		rte_eth_link_get(qos_conf[i].tx_port, &link);
+		ret = rte_eth_link_get(qos_conf[i].tx_port, &link);
+		if (ret < 0)
+			rte_exit(EXIT_FAILURE,
+				 "rte_eth_link_get: err=%d, port=%u: %s\n",
+				 ret, qos_conf[i].tx_port, rte_strerror(-ret));
 		if (link.link_status == 0)
 			printf("Waiting for link on port %u\n", qos_conf[i].tx_port);
+
 		while (link.link_status == 0 && retry_count--) {
 			rte_delay_ms(retry_delay);
-			rte_eth_link_get(qos_conf[i].tx_port, &link);
+			ret = rte_eth_link_get(qos_conf[i].tx_port, &link);
+			rte_exit(EXIT_FAILURE,
+				 "rte_eth_link_get: err=%d, port=%u: %s\n",
+				 ret, qos_conf[i].tx_port, rte_strerror(-ret));
 		}
 
 		qos_conf[i].sched_port = app_init_sched_port(qos_conf[i].tx_port, socket);
-- 
2.45.2


  parent reply	other threads:[~2024-10-04 16:25 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-04 16:21 [PATCH 00/10] require checking ethdev get return value Stephen Hemminger
2024-10-04 16:21 ` [PATCH 01/10] app/test: remove redundant call Stephen Hemminger
2024-10-04 16:21 ` [PATCH 02/10] net/memif: check return value from rte_eth_dev_info_get Stephen Hemminger
2024-10-08  3:47   ` Ferruh Yigit
2024-10-04 16:21 ` [PATCH 03/10] graph: " Stephen Hemminger
2024-10-04 16:21 ` [PATCH 04/10] examples/ethtool: handle devices without registers Stephen Hemminger
2024-10-04 16:21 ` [PATCH 05/10] examples/l3fwd: check return value from ethdev info Stephen Hemminger
2024-10-04 16:21 ` [PATCH 06/10] examples/ntb: always check return value Stephen Hemminger
2024-10-04 16:21 ` [PATCH 07/10] examples/pipeline: check return value of ethdev functions Stephen Hemminger
2024-10-04 16:21 ` Stephen Hemminger [this message]
2024-10-04 16:21 ` [PATCH 09/10] ethdev: check return value from rte_eth_dev_info_get Stephen Hemminger
2024-10-08  3:47   ` Ferruh Yigit
2024-10-04 16:21 ` [PATCH 10/10] ethdev: require checking results of info_get functions Stephen Hemminger
2024-10-08  3:47   ` Ferruh Yigit
2024-10-08  9:33 ` [PATCH 00/10] require checking ethdev get return value Morten Brørup
2024-11-11 15:20 ` Thomas Monjalon

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=20241004162418.52940-9-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=cristian.dumitrescu@intel.com \
    --cc=dev@dpdk.org \
    /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).