DPDK patches and discussions
 help / color / Atom feed
From: Andrew Rybchenko <arybchenko@solarflare.com>
To: Marko Kovacevic <marko.kovacevic@intel.com>,
	Ori Kam <orika@mellanox.com>,
	 Bruce Richardson <bruce.richardson@intel.com>,
	Pablo de Lara <pablo.de.lara.guarch@intel.com>,
	Radu Nicolau <radu.nicolau@intel.com>,
	Akhil Goyal <akhil.goyal@nxp.com>,
	Tomasz Kantecki <tomasz.kantecki@intel.com>
Cc: <dev@dpdk.org>, Igor Romanov <igor.romanov@oktetlabs.ru>
Subject: [dpdk-dev] [PATCH 15/18] examples/link_status_interrupt: check status of getting link
Date: Tue, 10 Sep 2019 09:25:55 +0100
Message-ID: <1568103959-25572-16-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>

The return value of rte_eth_link_get() and rte_eth_link_get_nowait()
was changed from void to int. Update the usage of the functions
according to the new return type.

Signed-off-by: Igor Romanov <igor.romanov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 examples/link_status_interrupt/main.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/examples/link_status_interrupt/main.c b/examples/link_status_interrupt/main.c
index d42fef12b..a0b75d9f6 100644
--- a/examples/link_status_interrupt/main.c
+++ b/examples/link_status_interrupt/main.c
@@ -117,6 +117,7 @@ print_stats(void)
 
 	const char clr[] = { 27, '[', '2', 'J', '\0' };
 	const char topLeft[] = { 27, '[', '1', ';', '1', 'H','\0' };
+	int link_get_err;
 
 		/* Clear screen and move to top left */
 	printf("%s%s", clr, topLeft);
@@ -129,7 +130,7 @@ print_stats(void)
 			continue;
 
 		memset(&link, 0, sizeof(link));
-		rte_eth_link_get_nowait(portid, &link);
+		link_get_err = rte_eth_link_get_nowait(portid, &link);
 		printf("\nStatistics for port %u ------------------------------"
 			   "\nLink status: %25s"
 			   "\nLink speed: %26u"
@@ -138,8 +139,11 @@ print_stats(void)
 			   "\nPackets received: %20"PRIu64
 			   "\nPackets dropped: %21"PRIu64,
 			   portid,
+			   link_get_err < 0 ? "Link get failed" :
 			   (link.link_status ? "Link up" : "Link down"),
-			   (unsigned)link.link_speed,
+			   link_get_err < 0 ? 0 :
+					(unsigned int)link.link_speed,
+			   link_get_err < 0 ? "Link get failed" :
 			   (link.link_duplex == ETH_LINK_FULL_DUPLEX ? \
 					"full-duplex" : "half-duplex"),
 			   port_statistics[portid].tx,
@@ -438,13 +442,19 @@ lsi_event_callback(uint16_t port_id, enum rte_eth_event_type type, void *param,
 		    void *ret_param)
 {
 	struct rte_eth_link link;
+	int ret;
 
 	RTE_SET_USED(param);
 	RTE_SET_USED(ret_param);
 
 	printf("\n\nIn registered callback...\n");
 	printf("Event type: %s\n", type == RTE_ETH_EVENT_INTR_LSC ? "LSC interrupt" : "unknown event");
-	rte_eth_link_get_nowait(port_id, &link);
+	ret = rte_eth_link_get_nowait(port_id, &link);
+	if (ret < 0) {
+		printf("Failed link get on port %d: %s\n",
+		       port_id, rte_strerror(-ret));
+		return ret;
+	}
 	if (link.link_status) {
 		printf("Port %d Link Up - speed %u Mbps - %s\n\n",
 				port_id, (unsigned)link.link_speed,
-- 
2.17.1


  parent reply index

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 ` [dpdk-dev] [PATCH 03/18] app/testpmd: check status of getting link info Andrew Rybchenko
2019-09-10  8:25 ` [dpdk-dev] [PATCH 04/18] net/bonding: " 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 ` Andrew Rybchenko [this message]
2019-09-10  8:25 ` [dpdk-dev] [PATCH 16/18] examples/distributor: " 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 publically 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-16-git-send-email-arybchenko@solarflare.com \
    --to=arybchenko@solarflare.com \
    --cc=akhil.goyal@nxp.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=igor.romanov@oktetlabs.ru \
    --cc=marko.kovacevic@intel.com \
    --cc=orika@mellanox.com \
    --cc=pablo.de.lara.guarch@intel.com \
    --cc=radu.nicolau@intel.com \
    --cc=tomasz.kantecki@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

DPDK patches and discussions

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ http://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/ public-inbox