DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 00/18] ethdev: change link status get functions return value to int
@ 2019-09-10  8:25 Andrew Rybchenko
  2019-09-10  8:25 ` [dpdk-dev] [PATCH 01/18] net/bonding: fix link speed update in broadcast mode Andrew Rybchenko
                   ` (18 more replies)
  0 siblings, 19 replies; 22+ messages in thread
From: Andrew Rybchenko @ 2019-09-10  8:25 UTC (permalink / raw)
  To: Thomas Monjalon, Ferruh Yigit; +Cc: dev, Igor Romanov

It is the fifth patch series to get rid of void returning functions
in ethdev in accordance with deprecation notice [1].

It should be applied on top of [2], [3], [4] and [5].

Functions which return void are bad since they do not provide explicit
information to the caller if everything is OK or not.

In the case of link info get it is important to know if link info is
filled in or not.

Unlike previous patch series for other functions, this one does not
touch link_update driver callback since it already has return value
with different semantics (which is not used in fact). May be negative
return values should be kept for errors and positive 1 should report
no link status changes. That's why only negative values are treated
as errors in the patch series.

[1] https://patches.dpdk.org/patch/56969/
[2] https://patches.dpdk.org/project/dpdk/list/?series=6279
[3] https://patches.dpdk.org/project/dpdk/list/?series=6334
[4] https://patches.dpdk.org/project/dpdk/list/?series=6335
[5] https://patches.dpdk.org/project/dpdk/list/?series=6308

Andrew Rybchenko (2):
  net/memif: check status of getting link info
  app/pipeline: check status of getting link info

Igor Romanov (16):
  net/bonding: fix link speed update in broadcast mode
  ethdev: change link status get functions return value to int
  app/testpmd: check status of getting link info
  net/bonding: check status of getting link info
  net/ixgbe: check status of getting link info
  app/proc-info: check status of getting link info
  app/test: check status of getting link info
  examples: check status of getting link info
  examples/bbdev_app: check status of getting link info
  examples/ip_pipeline: check status of getting link info
  examples/ethtool: check status of getting link info
  examples/flow_filtering: check status of getting link info
  examples/link_status_interrupt: check status of getting link
  examples/distributor: check status of getting link info
  examples/qos_sched: check status of getting link info
  examples/kni: check status of getting link info

 app/proc-info/main.c                          | 19 +++---
 app/test-pipeline/init.c                      | 11 +++-
 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 +++++
 app/test/test_link_bonding.c                  | 12 +++-
 app/test/test_pmd_perf.c                      | 11 +++-
 app/test/test_pmd_ring.c                      |  8 ++-
 doc/guides/rel_notes/deprecation.rst          |  1 -
 doc/guides/rel_notes/release_19_11.rst        |  4 ++
 doc/guides/sample_app_ug/link_status_intr.rst |  9 ++-
 drivers/net/bonding/rte_eth_bond_8023ad.c     | 24 ++++++--
 drivers/net/bonding/rte_eth_bond_api.c        | 19 ++++--
 drivers/net/bonding/rte_eth_bond_pmd.c        | 59 ++++++++++++++++---
 drivers/net/ixgbe/ixgbe_ethdev.c              |  5 +-
 drivers/net/memif/rte_eth_memif.c             | 12 +++-
 examples/bbdev_app/main.c                     | 12 +++-
 examples/distributor/main.c                   | 14 +++--
 examples/ethtool/lib/rte_ethtool.c            |  6 +-
 examples/exception_path/main.c                | 10 +++-
 examples/flow_filtering/main.c                |  8 ++-
 examples/ip_fragmentation/main.c              | 10 +++-
 examples/ip_pipeline/cli.c                    |  9 ++-
 examples/ip_pipeline/link.c                   |  3 +-
 examples/ip_reassembly/main.c                 | 10 +++-
 examples/ipsec-secgw/ipsec-secgw.c            | 10 +++-
 examples/ipv4_multicast/main.c                | 10 +++-
 examples/kni/main.c                           | 19 +++++-
 examples/l2fwd-crypto/main.c                  | 10 +++-
 examples/l2fwd-jobstats/main.c                | 10 +++-
 examples/l2fwd-keepalive/main.c               | 10 +++-
 examples/l2fwd/main.c                         | 10 +++-
 examples/l3fwd-acl/main.c                     | 10 +++-
 examples/l3fwd-power/main.c                   | 10 +++-
 examples/l3fwd/main.c                         | 10 +++-
 examples/link_status_interrupt/main.c         | 26 ++++++--
 examples/load_balancer/init.c                 | 10 +++-
 .../client_server_mp/mp_server/init.c         | 10 +++-
 examples/multi_process/symmetric_mp/main.c    | 10 +++-
 .../performance-thread/l3fwd-thread/main.c    | 10 +++-
 examples/qos_sched/init.c                     | 13 +++-
 examples/server_node_efd/server/init.c        | 10 +++-
 examples/vm_power_manager/main.c              | 10 +++-
 lib/librte_ethdev/rte_ethdev.c                | 16 +++--
 lib/librte_ethdev/rte_ethdev.h                | 12 +++-
 47 files changed, 477 insertions(+), 89 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [dpdk-dev] [PATCH 01/18] net/bonding: fix link speed update in broadcast mode
  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 ` 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
                   ` (17 subsequent siblings)
  18 siblings, 1 reply; 22+ messages in thread
From: Andrew Rybchenko @ 2019-09-10  8:25 UTC (permalink / raw)
  To: Chas Williams; +Cc: dev, Igor Romanov, stable

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

Fix the issue that the link speed of the bond device was set to the
link speed of the first active slave in broadcast mode.

Set the link speed of the bond device to the minimum value across
all of the slaves in that case.

Fixes: deba8a2f8b0b ("net/bonding: fix link properties management")
Cc: stable@dpdk.org

Signed-off-by: Igor Romanov <igor.romanov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 drivers/net/bonding/rte_eth_bond_pmd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index f774e5677..fed71bd95 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -2395,8 +2395,8 @@ bond_ethdev_link_update(struct rte_eth_dev *ethdev, int wait_to_complete)
 		 * packet loss will occur on this slave if transmission at rates
 		 * greater than this are attempted
 		 */
-		for (idx = 1; idx < bond_ctx->active_slave_count; idx++) {
-			link_update(bond_ctx->active_slaves[0],	&slave_link);
+		for (idx = 0; idx < bond_ctx->active_slave_count; idx++) {
+			link_update(bond_ctx->active_slaves[idx], &slave_link);
 
 			if (slave_link.link_speed <
 					ethdev->data->dev_link.link_speed)
-- 
2.17.1


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [dpdk-dev] [PATCH 02/18] ethdev: change link status get functions return value to int
  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  8:25 ` Andrew Rybchenko
  2019-09-10  8:25 ` [dpdk-dev] [PATCH 03/18] app/testpmd: check status of getting link info Andrew Rybchenko
                   ` (16 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Andrew Rybchenko @ 2019-09-10  8:25 UTC (permalink / raw)
  To: Neil Horman, John McNamara, Marko Kovacevic, Ori Kam,
	Bruce Richardson, Pablo de Lara, Radu Nicolau, Akhil Goyal,
	Tomasz Kantecki, Chas Williams, Thomas Monjalon, Ferruh Yigit
  Cc: dev, Igor Romanov

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

Change rte_eth_link_get() and rte_eth_link_get_nowait() return value
from void to int and return negative errno values in case of error
conditions.

Return value of link_update callback is ignored since the callback
returns not errors but whether link up status has changed or not.

Signed-off-by: Igor Romanov <igor.romanov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 doc/guides/rel_notes/deprecation.rst          |  1 -
 doc/guides/rel_notes/release_19_11.rst        |  4 ++++
 doc/guides/sample_app_ug/link_status_intr.rst |  9 ++++++---
 drivers/net/bonding/rte_eth_bond_pmd.c        |  2 +-
 lib/librte_ethdev/rte_ethdev.c                | 16 ++++++++++------
 lib/librte_ethdev/rte_ethdev.h                | 12 ++++++++++--
 6 files changed, 31 insertions(+), 13 deletions(-)

diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst
index 165d13726..43b15ec2f 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -88,7 +88,6 @@ Deprecation Notices
   negative errno values to indicate various error conditions (e.g.
   invalid port ID, unsupported operation, failed operation):
 
-  - ``rte_eth_link_get`` and ``rte_eth_link_get_nowait``
   - ``rte_eth_dev_stop``
   - ``rte_eth_dev_close``
   - ``rte_eth_macaddr_get``
diff --git a/doc/guides/rel_notes/release_19_11.rst b/doc/guides/rel_notes/release_19_11.rst
index d728592c8..3ff1296a2 100644
--- a/doc/guides/rel_notes/release_19_11.rst
+++ b/doc/guides/rel_notes/release_19_11.rst
@@ -108,6 +108,10 @@ API Changes
 * ethdev: changed ``rte_eth_dev_xstats_reset`` return value from ``void`` to
   ``int`` to provide a way to report various error conditions.
 
+* ethdev: changed ``rte_eth_link_get`` and ``rte_eth_link_get_nowait``
+  return value from ``void`` to ``int`` to provide a way to report various
+  error conditions.
+
 
 ABI Changes
 -----------
diff --git a/doc/guides/sample_app_ug/link_status_intr.rst b/doc/guides/sample_app_ug/link_status_intr.rst
index cfb1bcd58..5283be8b7 100644
--- a/doc/guides/sample_app_ug/link_status_intr.rst
+++ b/doc/guides/sample_app_ug/link_status_intr.rst
@@ -164,6 +164,7 @@ An example callback function that has been written as indicated below.
     lsi_event_callback(uint16_t port_id, enum rte_eth_event_type type, void *param)
     {
         struct rte_eth_link link;
+        int ret;
 
         RTE_SET_USED(param);
 
@@ -171,9 +172,11 @@ An example callback function that has been written as indicated below.
 
         printf("Event type: %s\n", type == RTE_ETH_EVENT_INTR_LSC ? "LSC interrupt" : "unknown event");
 
-        rte_eth_link_get_nowait(port_id, &link);
-
-        if (link.link_status) {
+        ret = rte_eth_link_get_nowait(port_id, &link);
+        if (ret < 0) {
+            printf("Failed to get port %d link status: %s\n\n",
+                   port_id, rte_strerror(-ret));
+        } else if (link.link_status) {
             printf("Port %d Link Up - speed %u Mbps - %s\n\n", port_id, (unsigned)link.link_speed,
                   (link.link_duplex == ETH_LINK_FULL_DUPLEX) ? ("full-duplex") : ("half-duplex"));
         } else
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index fed71bd95..9316f93f7 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -2358,7 +2358,7 @@ bond_ethdev_slave_link_status_change_monitor(void *cb_arg)
 static int
 bond_ethdev_link_update(struct rte_eth_dev *ethdev, int wait_to_complete)
 {
-	void (*link_update)(uint16_t port_id, struct rte_eth_link *eth_link);
+	int (*link_update)(uint16_t port_id, struct rte_eth_link *eth_link);
 
 	struct bond_dev_private *bond_ctx;
 	struct rte_eth_link slave_link;
diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index 1bd1e32b0..b9fa5f562 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -2015,40 +2015,44 @@ rte_eth_allmulticast_get(uint16_t port_id)
 	return dev->data->all_multicast;
 }
 
-void
+int
 rte_eth_link_get(uint16_t port_id, struct rte_eth_link *eth_link)
 {
 	struct rte_eth_dev *dev;
 
-	RTE_ETH_VALID_PORTID_OR_RET(port_id);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 
 	if (dev->data->dev_conf.intr_conf.lsc &&
 	    dev->data->dev_started)
 		rte_eth_linkstatus_get(dev, eth_link);
 	else {
-		RTE_FUNC_PTR_OR_RET(*dev->dev_ops->link_update);
+		RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->link_update, -ENOTSUP);
 		(*dev->dev_ops->link_update)(dev, 1);
 		*eth_link = dev->data->dev_link;
 	}
+
+	return 0;
 }
 
-void
+int
 rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link)
 {
 	struct rte_eth_dev *dev;
 
-	RTE_ETH_VALID_PORTID_OR_RET(port_id);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 
 	if (dev->data->dev_conf.intr_conf.lsc &&
 	    dev->data->dev_started)
 		rte_eth_linkstatus_get(dev, eth_link);
 	else {
-		RTE_FUNC_PTR_OR_RET(*dev->dev_ops->link_update);
+		RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->link_update, -ENOTSUP);
 		(*dev->dev_ops->link_update)(dev, 0);
 		*eth_link = dev->data->dev_link;
 	}
+
+	return 0;
 }
 
 int
diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h
index 14420dbbe..aba5b4c86 100644
--- a/lib/librte_ethdev/rte_ethdev.h
+++ b/lib/librte_ethdev/rte_ethdev.h
@@ -2103,8 +2103,12 @@ int rte_eth_allmulticast_get(uint16_t port_id);
  * @param link
  *   A pointer to an *rte_eth_link* structure to be filled with
  *   the status, the speed and the mode of the Ethernet device link.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENOTSUP) if the function is not supported in PMD driver.
+ *   - (-ENODEV) if *port_id* invalid.
  */
-void rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link);
+int rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link);
 
 /**
  * Retrieve the status (ON/OFF), the speed (in Mbps) and the mode (HALF-DUPLEX
@@ -2116,8 +2120,12 @@ void rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link);
  * @param link
  *   A pointer to an *rte_eth_link* structure to be filled with
  *   the status, the speed and the mode of the Ethernet device link.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENOTSUP) if the function is not supported in PMD driver.
+ *   - (-ENODEV) if *port_id* invalid.
  */
-void rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *link);
+int rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *link);
 
 /**
  * Retrieve the general I/O statistics of an Ethernet device.
-- 
2.17.1


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [dpdk-dev] [PATCH 03/18] app/testpmd: check status of getting link info
  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  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
  2019-09-10  8:25 ` [dpdk-dev] [PATCH 04/18] net/bonding: " Andrew Rybchenko
                   ` (15 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Andrew Rybchenko @ 2019-09-10  8:25 UTC (permalink / raw)
  To: Wenzhuo Lu, Jingjing Wu, Bernard Iremonger; +Cc: dev, Igor Romanov

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


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [dpdk-dev] [PATCH 04/18] net/bonding: check status of getting link info
  2019-09-10  8:25 [dpdk-dev] [PATCH 00/18] ethdev: change link status get functions return value to int Andrew Rybchenko
                   ` (2 preceding siblings ...)
  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 ` Andrew Rybchenko
  2019-09-10  8:25 ` [dpdk-dev] [PATCH 05/18] net/ixgbe: " Andrew Rybchenko
                   ` (14 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Andrew Rybchenko @ 2019-09-10  8:25 UTC (permalink / raw)
  To: Chas Williams; +Cc: dev, Igor Romanov

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>
---
 drivers/net/bonding/rte_eth_bond_8023ad.c | 24 +++++++---
 drivers/net/bonding/rte_eth_bond_api.c    | 19 ++++++--
 drivers/net/bonding/rte_eth_bond_pmd.c    | 55 ++++++++++++++++++++---
 3 files changed, 83 insertions(+), 15 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bonding/rte_eth_bond_8023ad.c
index e64fb6e41..e50d946eb 100644
--- a/drivers/net/bonding/rte_eth_bond_8023ad.c
+++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
@@ -675,6 +675,7 @@ selection_logic(struct bond_dev_private *internals, uint16_t slave_id)
 	uint16_t default_slave = 0;
 	uint8_t mode_count_id, mode_band_id;
 	struct rte_eth_link link_info;
+	int ret;
 
 	slaves = internals->active_slaves;
 	slaves_count = internals->active_slave_count;
@@ -687,8 +688,14 @@ selection_logic(struct bond_dev_private *internals, uint16_t slave_id)
 		if (agg->aggregator_port_id != slaves[i])
 			continue;
 
+		ret = rte_eth_link_get_nowait(slaves[i], &link_info);
+		if (ret < 0) {
+			RTE_BOND_LOG(ERR,
+				"Slave (port %u) link get failed: %s\n",
+				slaves[i], rte_strerror(-ret));
+			continue;
+		}
 		agg_count[agg->aggregator_port_id] += 1;
-		rte_eth_link_get_nowait(slaves[i], &link_info);
 		agg_bandwidth[agg->aggregator_port_id] += link_info.link_speed;
 
 		/* Actors system ID is not checked since all slave device have the same
@@ -821,18 +828,25 @@ bond_mode_8023ad_periodic_cb(void *arg)
 	/* Update link status on each port */
 	for (i = 0; i < internals->active_slave_count; i++) {
 		uint16_t key;
+		int ret;
 
 		slave_id = internals->active_slaves[i];
-		rte_eth_link_get_nowait(slave_id, &link_info);
-		rte_eth_macaddr_get(slave_id, &slave_addr);
+		ret = rte_eth_link_get_nowait(slave_id, &link_info);
+		if (ret < 0) {
+			RTE_BOND_LOG(ERR,
+				"Slave (port %u) link get failed: %s\n",
+				slave_id, rte_strerror(-ret));
+		}
 
-		if (link_info.link_status != 0) {
+		if (ret >= 0 && link_info.link_status != 0) {
 			key = link_speed_key(link_info.link_speed) << 1;
 			if (link_info.link_duplex == ETH_LINK_FULL_DUPLEX)
 				key |= BOND_LINK_FULL_DUPLEX_KEY;
-		} else
+		} else {
 			key = 0;
+		}
 
+		rte_eth_macaddr_get(slave_id, &slave_addr);
 		port = &bond_mode_8023ad_ports[slave_id];
 
 		key = rte_cpu_to_be_16(key);
diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c
index e2e27e9f2..2cef88720 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -557,9 +557,6 @@ __eth_bond_slave_add_lock_free(uint16_t bonded_port_id, uint16_t slave_port_id)
 		}
 	}
 
-	/* Add slave details to bonded device */
-	slave_eth_dev->data->dev_flags |= RTE_ETH_DEV_BONDED_SLAVE;
-
 	/* Update all slave devices MACs */
 	mac_address_slaves_update(bonded_eth_dev);
 
@@ -571,7 +568,18 @@ __eth_bond_slave_add_lock_free(uint16_t bonded_port_id, uint16_t slave_port_id)
 	/* If bonded device is started then we can add the slave to our active
 	 * slave array */
 	if (bonded_eth_dev->data->dev_started) {
-		rte_eth_link_get_nowait(slave_port_id, &link_props);
+		ret = rte_eth_link_get_nowait(slave_port_id, &link_props);
+		if (ret < 0) {
+			rte_eth_dev_callback_unregister(slave_port_id,
+					RTE_ETH_EVENT_INTR_LSC,
+					bond_ethdev_lsc_event_callback,
+					&bonded_eth_dev->data->port_id);
+			internals->slave_count--;
+			RTE_BOND_LOG(ERR,
+				"Slave (port %u) link get failed: %s\n",
+				slave_port_id, rte_strerror(-ret));
+			return -1;
+		}
 
 		 if (link_props.link_status == ETH_LINK_UP) {
 			if (internals->active_slave_count == 0 &&
@@ -581,6 +589,9 @@ __eth_bond_slave_add_lock_free(uint16_t bonded_port_id, uint16_t slave_port_id)
 		}
 	}
 
+	/* Add slave details to bonded device */
+	slave_eth_dev->data->dev_flags |= RTE_ETH_DEV_BONDED_SLAVE;
+
 	slave_vlan_filter_set(bonded_port_id, slave_port_id);
 
 	return 0;
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index 9316f93f7..a2d13d95c 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -846,8 +846,14 @@ bandwidth_left(uint16_t port_id, uint64_t load, uint8_t update_idx,
 		struct bwg_slave *bwg_slave)
 {
 	struct rte_eth_link link_status;
+	int ret;
 
-	rte_eth_link_get_nowait(port_id, &link_status);
+	ret = rte_eth_link_get_nowait(port_id, &link_status);
+	if (ret < 0) {
+		RTE_BOND_LOG(ERR, "Slave (port %u) link get failed: %s",
+			     port_id, rte_strerror(-ret));
+		return;
+	}
 	uint64_t link_bwg = link_status.link_speed * 1000000ULL / 8;
 	if (link_bwg == 0)
 		return;
@@ -2363,7 +2369,9 @@ bond_ethdev_link_update(struct rte_eth_dev *ethdev, int wait_to_complete)
 	struct bond_dev_private *bond_ctx;
 	struct rte_eth_link slave_link;
 
+	bool one_link_update_succeeded;
 	uint32_t idx;
+	int ret;
 
 	bond_ctx = ethdev->data->dev_private;
 
@@ -2396,7 +2404,17 @@ bond_ethdev_link_update(struct rte_eth_dev *ethdev, int wait_to_complete)
 		 * greater than this are attempted
 		 */
 		for (idx = 0; idx < bond_ctx->active_slave_count; idx++) {
-			link_update(bond_ctx->active_slaves[idx], &slave_link);
+			ret = link_update(bond_ctx->active_slaves[idx],
+					  &slave_link);
+			if (ret < 0) {
+				ethdev->data->dev_link.link_speed =
+					ETH_SPEED_NUM_NONE;
+				RTE_BOND_LOG(ERR,
+					"Slave (port %u) link get failed: %s",
+					bond_ctx->active_slaves[idx],
+					rte_strerror(-ret));
+				return 0;
+			}
 
 			if (slave_link.link_speed <
 					ethdev->data->dev_link.link_speed)
@@ -2406,7 +2424,13 @@ bond_ethdev_link_update(struct rte_eth_dev *ethdev, int wait_to_complete)
 		break;
 	case BONDING_MODE_ACTIVE_BACKUP:
 		/* Current primary slave */
-		link_update(bond_ctx->current_primary_port, &slave_link);
+		ret = link_update(bond_ctx->current_primary_port, &slave_link);
+		if (ret < 0) {
+			RTE_BOND_LOG(ERR, "Slave (port %u) link get failed: %s",
+				bond_ctx->current_primary_port,
+				rte_strerror(-ret));
+			return 0;
+		}
 
 		ethdev->data->dev_link.link_speed = slave_link.link_speed;
 		break;
@@ -2426,13 +2450,28 @@ bond_ethdev_link_update(struct rte_eth_dev *ethdev, int wait_to_complete)
 		 * of all the slaves
 		 */
 		ethdev->data->dev_link.link_speed = ETH_SPEED_NUM_NONE;
+		one_link_update_succeeded = false;
 
 		for (idx = 0; idx < bond_ctx->active_slave_count; idx++) {
-			link_update(bond_ctx->active_slaves[idx], &slave_link);
+			ret = link_update(bond_ctx->active_slaves[idx],
+					&slave_link);
+			if (ret < 0) {
+				RTE_BOND_LOG(ERR,
+					"Slave (port %u) link get failed: %s",
+					bond_ctx->active_slaves[idx],
+					rte_strerror(-ret));
+				continue;
+			}
 
+			one_link_update_succeeded = true;
 			ethdev->data->dev_link.link_speed +=
 					slave_link.link_speed;
 		}
+
+		if (!one_link_update_succeeded) {
+			RTE_BOND_LOG(ERR, "All slaves link get failed");
+			return 0;
+		}
 	}
 
 
@@ -2734,6 +2773,7 @@ bond_ethdev_lsc_event_callback(uint16_t port_id, enum rte_eth_event_type type,
 	struct bond_dev_private *internals;
 	struct rte_eth_link link;
 	int rc = -1;
+	int ret;
 
 	uint8_t lsc_flag = 0;
 	int valid_slave = 0;
@@ -2774,8 +2814,11 @@ bond_ethdev_lsc_event_callback(uint16_t port_id, enum rte_eth_event_type type,
 	active_pos = find_slave_by_id(internals->active_slaves,
 			internals->active_slave_count, port_id);
 
-	rte_eth_link_get_nowait(port_id, &link);
-	if (link.link_status) {
+	ret = rte_eth_link_get_nowait(port_id, &link);
+	if (ret < 0)
+		RTE_BOND_LOG(ERR, "Slave (port %u) link get failed", port_id);
+
+	if (ret == 0 && link.link_status) {
 		if (active_pos < internals->active_slave_count)
 			goto link_update;
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [dpdk-dev] [PATCH 05/18] net/ixgbe: check status of getting link info
  2019-09-10  8:25 [dpdk-dev] [PATCH 00/18] ethdev: change link status get functions return value to int Andrew Rybchenko
                   ` (3 preceding siblings ...)
  2019-09-10  8:25 ` [dpdk-dev] [PATCH 04/18] net/bonding: " Andrew Rybchenko
@ 2019-09-10  8:25 ` Andrew Rybchenko
  2019-09-10  8:25 ` [dpdk-dev] [PATCH 06/18] net/memif: " Andrew Rybchenko
                   ` (13 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Andrew Rybchenko @ 2019-09-10  8:25 UTC (permalink / raw)
  To: Wenzhuo Lu, Konstantin Ananyev; +Cc: dev, Igor Romanov

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>
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 715646b5a..0aa039a71 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -2514,9 +2514,12 @@ ixgbe_set_vf_rate_limit(struct rte_eth_dev *dev, uint16_t vf,
 	uint32_t queue_end;
 	uint16_t total_rate = 0;
 	struct rte_pci_device *pci_dev;
+	int ret;
 
 	pci_dev = RTE_ETH_DEV_TO_PCI(dev);
-	rte_eth_link_get_nowait(dev->data->port_id, &link);
+	ret = rte_eth_link_get_nowait(dev->data->port_id, &link);
+	if (ret < 0)
+		return ret;
 
 	if (vf >= pci_dev->max_vfs)
 		return -EINVAL;
-- 
2.17.1


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [dpdk-dev] [PATCH 06/18] net/memif: check status of getting link info
  2019-09-10  8:25 [dpdk-dev] [PATCH 00/18] ethdev: change link status get functions return value to int Andrew Rybchenko
                   ` (4 preceding siblings ...)
  2019-09-10  8:25 ` [dpdk-dev] [PATCH 05/18] net/ixgbe: " Andrew Rybchenko
@ 2019-09-10  8:25 ` Andrew Rybchenko
  2019-09-10  8:25 ` [dpdk-dev] [PATCH 07/18] app/proc-info: " Andrew Rybchenko
                   ` (12 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Andrew Rybchenko @ 2019-09-10  8:25 UTC (permalink / raw)
  To: Jakub Grajciar; +Cc: dev

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

Just log error if something goes wrong.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 drivers/net/memif/rte_eth_memif.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/net/memif/rte_eth_memif.c b/drivers/net/memif/rte_eth_memif.c
index af260f7a8..a347e27bd 100644
--- a/drivers/net/memif/rte_eth_memif.c
+++ b/drivers/net/memif/rte_eth_memif.c
@@ -266,7 +266,10 @@ eth_memif_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 		return 0;
 	if (unlikely(ring == NULL)) {
 		/* Secondary process will attempt to request regions. */
-		rte_eth_link_get(mq->in_port, &link);
+		ret = rte_eth_link_get(mq->in_port, &link);
+		if (ret < 0)
+			MIF_LOG(ERR, "Failed to get port %u link info: %s",
+				mq->in_port, rte_strerror(-ret));
 		return 0;
 	}
 
@@ -392,8 +395,13 @@ eth_memif_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 	if (unlikely((pmd->flags & ETH_MEMIF_FLAG_CONNECTED) == 0))
 		return 0;
 	if (unlikely(ring == NULL)) {
+		int ret;
+
 		/* Secondary process will attempt to request regions. */
-		rte_eth_link_get(mq->in_port, &link);
+		ret = rte_eth_link_get(mq->in_port, &link);
+		if (ret < 0)
+			MIF_LOG(ERR, "Failed to get port %u link info: %s",
+				mq->in_port, rte_strerror(-ret));
 		return 0;
 	}
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [dpdk-dev] [PATCH 07/18] app/proc-info: check status of getting link info
  2019-09-10  8:25 [dpdk-dev] [PATCH 00/18] ethdev: change link status get functions return value to int Andrew Rybchenko
                   ` (5 preceding siblings ...)
  2019-09-10  8:25 ` [dpdk-dev] [PATCH 06/18] net/memif: " Andrew Rybchenko
@ 2019-09-10  8:25 ` Andrew Rybchenko
  2019-09-10  8:25 ` [dpdk-dev] [PATCH 08/18] app/test: " Andrew Rybchenko
                   ` (11 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Andrew Rybchenko @ 2019-09-10  8:25 UTC (permalink / raw)
  To: Maryam Tahhan, Reshma Pattan; +Cc: dev, Igor Romanov

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>
---
 app/proc-info/main.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index 94e808dc6..a3f854b89 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -678,13 +678,18 @@ show_port(void)
 		printf("  - generic config\n");
 
 		printf("\t  -- Socket %d\n", rte_eth_dev_socket_id(i));
-		rte_eth_link_get(i, &link);
-		printf("\t  -- link speed %d duplex %d,"
-				" auto neg %d status %d\n",
-				link.link_speed,
-				link.link_duplex,
-				link.link_autoneg,
-				link.link_status);
+		ret = rte_eth_link_get(i, &link);
+		if (ret < 0) {
+			printf("Link get failed (port %u): %s\n",
+			       i, rte_strerror(-ret));
+		} else {
+			printf("\t  -- link speed %d duplex %d,"
+					" auto neg %d status %d\n",
+					link.link_speed,
+					link.link_duplex,
+					link.link_autoneg,
+					link.link_status);
+		}
 		printf("\t  -- promiscuous (%d)\n",
 				rte_eth_promiscuous_get(i));
 		ret = rte_eth_dev_get_mtu(i, &mtu);
-- 
2.17.1


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [dpdk-dev] [PATCH 08/18] app/test: check status of getting link info
  2019-09-10  8:25 [dpdk-dev] [PATCH 00/18] ethdev: change link status get functions return value to int Andrew Rybchenko
                   ` (6 preceding siblings ...)
  2019-09-10  8:25 ` [dpdk-dev] [PATCH 07/18] app/proc-info: " Andrew Rybchenko
@ 2019-09-10  8:25 ` Andrew Rybchenko
  2019-09-10  8:25 ` [dpdk-dev] [PATCH 09/18] app/pipeline: " Andrew Rybchenko
                   ` (10 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Andrew Rybchenko @ 2019-09-10  8:25 UTC (permalink / raw)
  To: Chas Williams, Bruce Richardson; +Cc: dev, Igor Romanov

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>
---
 app/test/test_link_bonding.c | 12 ++++++++++--
 app/test/test_pmd_perf.c     | 11 ++++++++++-
 app/test/test_pmd_ring.c     |  8 +++++++-
 3 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index cbbbc98a1..d0d6fc23d 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -554,6 +554,7 @@ test_start_bonded_device(void)
 
 	int current_slave_count, current_bonding_mode, primary_port;
 	uint16_t slaves[RTE_MAX_ETHPORTS];
+	int retval;
 
 	/* Add slave to bonded device*/
 	TEST_ASSERT_SUCCESS(test_add_slave_to_bonded_device(),
@@ -590,7 +591,10 @@ test_start_bonded_device(void)
 			"Primary port (%d) is not expected value (%d).",
 			primary_port, test_params->slave_port_ids[0]);
 
-	rte_eth_link_get(test_params->bonded_port_id, &link_status);
+	retval = rte_eth_link_get(test_params->bonded_port_id, &link_status);
+	TEST_ASSERT(retval >= 0,
+			"Bonded port (%d) link get failed: %s\n",
+			test_params->bonded_port_id, rte_strerror(-retval));
 	TEST_ASSERT_EQUAL(link_status.link_status, 1,
 			"Bonded port (%d) status (%d) is not expected value (%d).\n",
 			test_params->bonded_port_id, link_status.link_status, 1);
@@ -605,10 +609,14 @@ test_stop_bonded_device(void)
 	uint16_t slaves[RTE_MAX_ETHPORTS];
 
 	struct rte_eth_link link_status;
+	int retval;
 
 	rte_eth_dev_stop(test_params->bonded_port_id);
 
-	rte_eth_link_get(test_params->bonded_port_id, &link_status);
+	retval = rte_eth_link_get(test_params->bonded_port_id, &link_status);
+	TEST_ASSERT(retval >= 0,
+			"Bonded port (%d) link get failed: %s\n",
+			test_params->bonded_port_id, rte_strerror(-retval));
 	TEST_ASSERT_EQUAL(link_status.link_status, 0,
 			"Bonded port (%d) status (%d) is not expected value (%d).",
 			test_params->bonded_port_id, link_status.link_status, 0);
diff --git a/app/test/test_pmd_perf.c b/app/test/test_pmd_perf.c
index 85ef11899..36b06ce5d 100644
--- a/app/test/test_pmd_perf.c
+++ b/app/test/test_pmd_perf.c
@@ -125,6 +125,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
 	uint16_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);
@@ -134,7 +135,15 @@ check_all_ports_link_status(uint16_t port_num, 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/test_pmd_ring.c b/app/test/test_pmd_ring.c
index 65ab6e7e0..02873f26a 100644
--- a/app/test/test_pmd_ring.c
+++ b/app/test/test_pmd_ring.c
@@ -24,6 +24,7 @@ test_ethdev_configure_port(int port)
 {
 	struct rte_eth_conf null_conf;
 	struct rte_eth_link link;
+	int ret;
 
 	memset(&null_conf, 0, sizeof(struct rte_eth_conf));
 
@@ -54,7 +55,12 @@ test_ethdev_configure_port(int port)
 		return -1;
 	}
 
-	rte_eth_link_get(port, &link);
+	ret = rte_eth_link_get(port, &link);
+	if (ret < 0) {
+		printf("Link get failed for port %u: %s",
+		       port, rte_strerror(-ret));
+		return -1;
+	}
 
 	return 0;
 }
-- 
2.17.1


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [dpdk-dev] [PATCH 09/18] app/pipeline: check status of getting link info
  2019-09-10  8:25 [dpdk-dev] [PATCH 00/18] ethdev: change link status get functions return value to int Andrew Rybchenko
                   ` (7 preceding siblings ...)
  2019-09-10  8:25 ` [dpdk-dev] [PATCH 08/18] app/test: " Andrew Rybchenko
@ 2019-09-10  8:25 ` Andrew Rybchenko
  2019-09-10  8:25 ` [dpdk-dev] [PATCH 10/18] examples: " Andrew Rybchenko
                   ` (9 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Andrew Rybchenko @ 2019-09-10  8:25 UTC (permalink / raw)
  To: Cristian Dumitrescu; +Cc: dev

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

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 app/test-pipeline/init.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/app/test-pipeline/init.c b/app/test-pipeline/init.c
index 871d9fa2d..67d54ae05 100644
--- a/app/test-pipeline/init.c
+++ b/app/test-pipeline/init.c
@@ -161,10 +161,19 @@ app_ports_check_link(void)
 	for (i = 0; i < app.n_ports; i++) {
 		struct rte_eth_link link;
 		uint16_t port;
+		int ret;
 
 		port = app.ports[i];
 		memset(&link, 0, sizeof(link));
-		rte_eth_link_get_nowait(port, &link);
+		ret = rte_eth_link_get_nowait(port, &link);
+		if (ret < 0) {
+			RTE_LOG(INFO, USER1,
+				"Failed to get port %u link status: %s\n",
+				port, rte_strerror(-ret));
+			all_ports_up = 0;
+			continue;
+		}
+
 		RTE_LOG(INFO, USER1, "Port %u (%u Gbps) %s\n",
 			port,
 			link.link_speed / 1000,
-- 
2.17.1


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [dpdk-dev] [PATCH 10/18] examples: check status of getting link info
  2019-09-10  8:25 [dpdk-dev] [PATCH 00/18] ethdev: change link status get functions return value to int Andrew Rybchenko
                   ` (8 preceding siblings ...)
  2019-09-10  8:25 ` [dpdk-dev] [PATCH 09/18] app/pipeline: " Andrew Rybchenko
@ 2019-09-10  8:25 ` Andrew Rybchenko
  2019-09-10  8:25 ` [dpdk-dev] [PATCH 11/18] examples/bbdev_app: " Andrew Rybchenko
                   ` (8 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Andrew Rybchenko @ 2019-09-10  8:25 UTC (permalink / raw)
  To: Marko Kovacevic, Ori Kam, Bruce Richardson, Pablo de Lara,
	Radu Nicolau, Akhil Goyal, Tomasz Kantecki, Konstantin Ananyev,
	Ferruh Yigit, Declan Doherty, David Hunt, Anatoly Burakov,
	John McNamara, Harry van Haaren, Xiaoyun Li, Byron Marohn
  Cc: dev, Igor Romanov

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

Check return code of rte_eth_link_get_nowait() in all
check_all_ports_link_status() functions in examples.

Check is repeated for every function since the logic of some
of them is different from others.

Signed-off-by: Igor Romanov <igor.romanov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 examples/exception_path/main.c                         | 10 +++++++++-
 examples/ip_fragmentation/main.c                       | 10 +++++++++-
 examples/ip_reassembly/main.c                          | 10 +++++++++-
 examples/ipsec-secgw/ipsec-secgw.c                     | 10 +++++++++-
 examples/ipv4_multicast/main.c                         | 10 +++++++++-
 examples/kni/main.c                                    | 10 +++++++++-
 examples/l2fwd-crypto/main.c                           | 10 +++++++++-
 examples/l2fwd-jobstats/main.c                         | 10 +++++++++-
 examples/l2fwd-keepalive/main.c                        | 10 +++++++++-
 examples/l2fwd/main.c                                  | 10 +++++++++-
 examples/l3fwd-acl/main.c                              | 10 +++++++++-
 examples/l3fwd-power/main.c                            | 10 +++++++++-
 examples/l3fwd/main.c                                  | 10 +++++++++-
 examples/link_status_interrupt/main.c                  | 10 +++++++++-
 examples/load_balancer/init.c                          | 10 +++++++++-
 .../multi_process/client_server_mp/mp_server/init.c    | 10 +++++++++-
 examples/multi_process/symmetric_mp/main.c             | 10 +++++++++-
 examples/performance-thread/l3fwd-thread/main.c        | 10 +++++++++-
 examples/server_node_efd/server/init.c                 | 10 +++++++++-
 examples/vm_power_manager/main.c                       | 10 +++++++++-
 20 files changed, 180 insertions(+), 20 deletions(-)

diff --git a/examples/exception_path/main.c b/examples/exception_path/main.c
index f3c0206b5..85dbd7ec7 100644
--- a/examples/exception_path/main.c
+++ b/examples/exception_path/main.c
@@ -488,6 +488,7 @@ check_all_ports_link_status(uint32_t port_mask)
 	uint16_t portid;
 	uint8_t count, all_ports_up, print_flag = 0;
 	struct rte_eth_link link;
+	int ret;
 
 	printf("\nChecking link status");
 	fflush(stdout);
@@ -497,7 +498,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/examples/ip_fragmentation/main.c b/examples/ip_fragmentation/main.c
index 70139ee4d..f90edc5a2 100644
--- a/examples/ip_fragmentation/main.c
+++ b/examples/ip_fragmentation/main.c
@@ -592,6 +592,7 @@ check_all_ports_link_status(uint32_t port_mask)
 	uint16_t portid;
 	uint8_t count, all_ports_up, print_flag = 0;
 	struct rte_eth_link link;
+	int ret;
 
 	printf("\nChecking link status");
 	fflush(stdout);
@@ -601,7 +602,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/examples/ip_reassembly/main.c b/examples/ip_reassembly/main.c
index e810e9f3f..c822c8c58 100644
--- a/examples/ip_reassembly/main.c
+++ b/examples/ip_reassembly/main.c
@@ -711,6 +711,7 @@ check_all_ports_link_status(uint32_t port_mask)
 	uint16_t portid;
 	uint8_t count, all_ports_up, print_flag = 0;
 	struct rte_eth_link link;
+	int ret;
 
 	printf("\nChecking link status");
 	fflush(stdout);
@@ -720,7 +721,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/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c
index 8154fc76a..2520e5108 100644
--- a/examples/ipsec-secgw/ipsec-secgw.c
+++ b/examples/ipsec-secgw/ipsec-secgw.c
@@ -1629,6 +1629,7 @@ check_all_ports_link_status(uint32_t port_mask)
 	uint16_t portid;
 	uint8_t count, all_ports_up, print_flag = 0;
 	struct rte_eth_link link;
+	int ret;
 
 	printf("\nChecking link status");
 	fflush(stdout);
@@ -1638,7 +1639,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/examples/ipv4_multicast/main.c b/examples/ipv4_multicast/main.c
index 8fd19f4cf..6b165f2f0 100644
--- a/examples/ipv4_multicast/main.c
+++ b/examples/ipv4_multicast/main.c
@@ -575,6 +575,7 @@ check_all_ports_link_status(uint32_t port_mask)
 	uint16_t portid;
 	uint8_t count, all_ports_up, print_flag = 0;
 	struct rte_eth_link link;
+	int ret;
 
 	printf("\nChecking link status");
 	fflush(stdout);
@@ -584,7 +585,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/examples/kni/main.c b/examples/kni/main.c
index 1069fd08b..08366a5fa 100644
--- a/examples/kni/main.c
+++ b/examples/kni/main.c
@@ -654,6 +654,7 @@ check_all_ports_link_status(uint32_t port_mask)
 	uint16_t portid;
 	uint8_t count, all_ports_up, print_flag = 0;
 	struct rte_eth_link link;
+	int ret;
 
 	printf("\nChecking link status\n");
 	fflush(stdout);
@@ -663,7 +664,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/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
index c4ef31031..7c84b40ff 100644
--- a/examples/l2fwd-crypto/main.c
+++ b/examples/l2fwd-crypto/main.c
@@ -1731,6 +1731,7 @@ check_all_ports_link_status(uint32_t port_mask)
 	uint16_t portid;
 	uint8_t count, all_ports_up, print_flag = 0;
 	struct rte_eth_link link;
+	int ret;
 
 	printf("\nChecking link status");
 	fflush(stdout);
@@ -1740,7 +1741,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/examples/l2fwd-jobstats/main.c b/examples/l2fwd-jobstats/main.c
index 3dd6e45b8..4f930d097 100644
--- a/examples/l2fwd-jobstats/main.c
+++ b/examples/l2fwd-jobstats/main.c
@@ -685,6 +685,7 @@ check_all_ports_link_status(uint32_t port_mask)
 	uint16_t portid;
 	uint8_t count, all_ports_up, print_flag = 0;
 	struct rte_eth_link link;
+	int ret;
 
 	printf("\nChecking link status");
 	fflush(stdout);
@@ -694,7 +695,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/examples/l2fwd-keepalive/main.c b/examples/l2fwd-keepalive/main.c
index 708f44ee0..21278eed7 100644
--- a/examples/l2fwd-keepalive/main.c
+++ b/examples/l2fwd-keepalive/main.c
@@ -450,6 +450,7 @@ check_all_ports_link_status(uint32_t port_mask)
 	uint16_t portid;
 	uint8_t count, all_ports_up, print_flag = 0;
 	struct rte_eth_link link;
+	int ret;
 
 	printf("\nChecking link status");
 	fflush(stdout);
@@ -459,7 +460,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/examples/l2fwd/main.c b/examples/l2fwd/main.c
index db070a18b..6b9f09a4d 100644
--- a/examples/l2fwd/main.c
+++ b/examples/l2fwd/main.c
@@ -449,6 +449,7 @@ check_all_ports_link_status(uint32_t port_mask)
 	uint16_t portid;
 	uint8_t count, all_ports_up, print_flag = 0;
 	struct rte_eth_link link;
+	int ret;
 
 	printf("\nChecking link status");
 	fflush(stdout);
@@ -462,7 +463,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/examples/l3fwd-acl/main.c b/examples/l3fwd-acl/main.c
index c974a357b..0abb8cb5e 100644
--- a/examples/l3fwd-acl/main.c
+++ b/examples/l3fwd-acl/main.c
@@ -1814,6 +1814,7 @@ check_all_ports_link_status(uint32_t port_mask)
 	uint16_t portid;
 	uint8_t count, all_ports_up, print_flag = 0;
 	struct rte_eth_link link;
+	int ret;
 
 	printf("\nChecking link status");
 	fflush(stdout);
@@ -1823,7 +1824,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/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c
index 8ddc9ceb1..2e3b1d3c6 100644
--- a/examples/l3fwd-power/main.c
+++ b/examples/l3fwd-power/main.c
@@ -1970,6 +1970,7 @@ check_all_ports_link_status(uint32_t port_mask)
 	uint8_t count, all_ports_up, print_flag = 0;
 	uint16_t portid;
 	struct rte_eth_link link;
+	int ret;
 
 	printf("\nChecking link status");
 	fflush(stdout);
@@ -1979,7 +1980,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/examples/l3fwd/main.c b/examples/l3fwd/main.c
index 9ed495ee0..7253acac4 100644
--- a/examples/l3fwd/main.c
+++ b/examples/l3fwd/main.c
@@ -718,6 +718,7 @@ check_all_ports_link_status(uint32_t port_mask)
 	uint16_t portid;
 	uint8_t count, all_ports_up, print_flag = 0;
 	struct rte_eth_link link;
+	int ret;
 
 	printf("\nChecking link status");
 	fflush(stdout);
@@ -731,7 +732,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/examples/link_status_interrupt/main.c b/examples/link_status_interrupt/main.c
index be57e6a98..d42fef12b 100644
--- a/examples/link_status_interrupt/main.c
+++ b/examples/link_status_interrupt/main.c
@@ -465,6 +465,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
 	uint8_t count, all_ports_up, print_flag = 0;
 	uint16_t portid;
 	struct rte_eth_link link;
+	int ret;
 
 	printf("\nChecking link status");
 	fflush(stdout);
@@ -474,7 +475,14 @@ check_all_ports_link_status(uint16_t port_num, 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/examples/load_balancer/init.c b/examples/load_balancer/init.c
index 4d49c9514..762226754 100644
--- a/examples/load_balancer/init.c
+++ b/examples/load_balancer/init.c
@@ -331,6 +331,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
 	uint16_t portid;
 	uint8_t count, all_ports_up, print_flag = 0;
 	struct rte_eth_link link;
+	int ret;
 	uint32_t n_rx_queues, n_tx_queues;
 
 	printf("\nChecking link status");
@@ -345,7 +346,14 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
 			if ((n_rx_queues == 0) && (n_tx_queues == 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/examples/multi_process/client_server_mp/mp_server/init.c b/examples/multi_process/client_server_mp/mp_server/init.c
index e55def84b..3d4a9cdfa 100644
--- a/examples/multi_process/client_server_mp/mp_server/init.c
+++ b/examples/multi_process/client_server_mp/mp_server/init.c
@@ -184,6 +184,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
 	uint16_t portid;
 	uint8_t count, all_ports_up, print_flag = 0;
 	struct rte_eth_link link;
+	int ret;
 
 	printf("\nChecking link status");
 	fflush(stdout);
@@ -193,7 +194,14 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
 			if ((port_mask & (1 << ports->id[portid])) == 0)
 				continue;
 			memset(&link, 0, sizeof(link));
-			rte_eth_link_get_nowait(ports->id[portid], &link);
+			ret = rte_eth_link_get_nowait(ports->id[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/examples/multi_process/symmetric_mp/main.c b/examples/multi_process/symmetric_mp/main.c
index 95058a5dc..7f491452a 100644
--- a/examples/multi_process/symmetric_mp/main.c
+++ b/examples/multi_process/symmetric_mp/main.c
@@ -364,6 +364,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
 	uint16_t portid;
 	uint8_t count, all_ports_up, print_flag = 0;
 	struct rte_eth_link link;
+	int ret;
 
 	printf("\nChecking link status");
 	fflush(stdout);
@@ -373,7 +374,14 @@ check_all_ports_link_status(uint16_t port_num, 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/examples/performance-thread/l3fwd-thread/main.c b/examples/performance-thread/l3fwd-thread/main.c
index 9e25f064e..de0521922 100644
--- a/examples/performance-thread/l3fwd-thread/main.c
+++ b/examples/performance-thread/l3fwd-thread/main.c
@@ -3432,6 +3432,7 @@ check_all_ports_link_status(uint32_t port_mask)
 	uint16_t portid;
 	uint8_t count, all_ports_up, print_flag = 0;
 	struct rte_eth_link link;
+	int ret;
 
 	printf("\nChecking link status");
 	fflush(stdout);
@@ -3441,7 +3442,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/examples/server_node_efd/server/init.c b/examples/server_node_efd/server/init.c
index 335741a8f..00e2e4059 100644
--- a/examples/server_node_efd/server/init.c
+++ b/examples/server_node_efd/server/init.c
@@ -246,6 +246,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
 	uint8_t count, all_ports_up, print_flag = 0;
 	uint16_t portid;
 	struct rte_eth_link link;
+	int ret;
 
 	printf("\nChecking link status");
 	fflush(stdout);
@@ -255,7 +256,14 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
 			if ((port_mask & (1 << info->id[portid])) == 0)
 				continue;
 			memset(&link, 0, sizeof(link));
-			rte_eth_link_get_nowait(info->id[portid], &link);
+			ret = rte_eth_link_get_nowait(info->id[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/examples/vm_power_manager/main.c b/examples/vm_power_manager/main.c
index a3a747829..288a2462a 100644
--- a/examples/vm_power_manager/main.c
+++ b/examples/vm_power_manager/main.c
@@ -237,6 +237,7 @@ check_all_ports_link_status(uint32_t port_mask)
 #define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */
 	uint16_t portid, count, all_ports_up, print_flag = 0;
 	struct rte_eth_link link;
+	int ret;
 
 	printf("\nChecking link status");
 	fflush(stdout);
@@ -250,7 +251,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)
-- 
2.17.1


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [dpdk-dev] [PATCH 11/18] examples/bbdev_app: check status of getting link info
  2019-09-10  8:25 [dpdk-dev] [PATCH 00/18] ethdev: change link status get functions return value to int Andrew Rybchenko
                   ` (9 preceding siblings ...)
  2019-09-10  8:25 ` [dpdk-dev] [PATCH 10/18] examples: " Andrew Rybchenko
@ 2019-09-10  8:25 ` Andrew Rybchenko
  2019-09-10  8:25 ` [dpdk-dev] [PATCH 12/18] examples/ip_pipeline: " Andrew Rybchenko
                   ` (7 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Andrew Rybchenko @ 2019-09-10  8:25 UTC (permalink / raw)
  To: Nicolas Chautru; +Cc: dev, Igor Romanov

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/bbdev_app/main.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/examples/bbdev_app/main.c b/examples/bbdev_app/main.c
index 3d36629a1..349876589 100644
--- a/examples/bbdev_app/main.c
+++ b/examples/bbdev_app/main.c
@@ -312,6 +312,7 @@ check_port_link_status(uint16_t port_id)
 #define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */
 	uint8_t count;
 	struct rte_eth_link link;
+	int link_get_err = -EINVAL;
 
 	printf("\nChecking link status.");
 	fflush(stdout);
@@ -319,9 +320,9 @@ check_port_link_status(uint16_t port_id)
 	for (count = 0; count <= MAX_CHECK_TIME &&
 			!rte_atomic16_read(&global_exit_flag); count++) {
 		memset(&link, 0, sizeof(link));
-		rte_eth_link_get_nowait(port_id, &link);
+		link_get_err = rte_eth_link_get_nowait(port_id, &link);
 
-		if (link.link_status) {
+		if (link_get_err >= 0 && link.link_status) {
 			const char *dp = (link.link_duplex ==
 				ETH_LINK_FULL_DUPLEX) ?
 				"full-duplex" : "half-duplex";
@@ -334,7 +335,12 @@ check_port_link_status(uint16_t port_id)
 		rte_delay_ms(CHECK_INTERVAL);
 	}
 
-	printf("\nPort %d Link Down\n", port_id);
+	if (link_get_err >= 0)
+		printf("\nPort %d Link Down\n", port_id);
+	else
+		printf("\nGet link failed (port %d): %s\n", port_id,
+		       rte_strerror(-link_get_err));
+
 	return 0;
 }
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [dpdk-dev] [PATCH 12/18] examples/ip_pipeline: check status of getting link info
  2019-09-10  8:25 [dpdk-dev] [PATCH 00/18] ethdev: change link status get functions return value to int Andrew Rybchenko
                   ` (10 preceding siblings ...)
  2019-09-10  8:25 ` [dpdk-dev] [PATCH 11/18] examples/bbdev_app: " Andrew Rybchenko
@ 2019-09-10  8:25 ` Andrew Rybchenko
  2019-09-10  8:25 ` [dpdk-dev] [PATCH 13/18] examples/ethtool: " Andrew Rybchenko
                   ` (6 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Andrew Rybchenko @ 2019-09-10  8:25 UTC (permalink / raw)
  To: Cristian Dumitrescu; +Cc: dev, Igor Romanov

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/ip_pipeline/cli.c  | 9 ++++++++-
 examples/ip_pipeline/link.c | 3 ++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/examples/ip_pipeline/cli.c b/examples/ip_pipeline/cli.c
index c6cf4204e..4930310cc 100644
--- a/examples/ip_pipeline/cli.c
+++ b/examples/ip_pipeline/cli.c
@@ -248,12 +248,19 @@ print_link_info(struct link *link, char *out, size_t out_size)
 	struct rte_ether_addr mac_addr;
 	struct rte_eth_link eth_link;
 	uint16_t mtu;
+	int ret;
 
 	memset(&stats, 0, sizeof(stats));
 	rte_eth_stats_get(link->port_id, &stats);
 
 	rte_eth_macaddr_get(link->port_id, &mac_addr);
-	rte_eth_link_get(link->port_id, &eth_link);
+	ret = rte_eth_link_get(link->port_id, &eth_link);
+	if (ret < 0) {
+		snprintf(out, out_size, "\n%s: link get failed: %s",
+			 link->name, rte_strerror(-ret));
+		return;
+	}
+
 	rte_eth_dev_get_mtu(link->port_id, &mtu);
 
 	snprintf(out, out_size,
diff --git a/examples/ip_pipeline/link.c b/examples/ip_pipeline/link.c
index 744abf394..16bcffe35 100644
--- a/examples/ip_pipeline/link.c
+++ b/examples/ip_pipeline/link.c
@@ -264,7 +264,8 @@ link_is_up(const char *name)
 		return 0;
 
 	/* Resource */
-	rte_eth_link_get(link->port_id, &link_params);
+	if (rte_eth_link_get(link->port_id, &link_params) < 0)
+		return 0;
 
 	return (link_params.link_status == ETH_LINK_DOWN) ? 0 : 1;
 }
-- 
2.17.1


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [dpdk-dev] [PATCH 13/18] examples/ethtool: check status of getting link info
  2019-09-10  8:25 [dpdk-dev] [PATCH 00/18] ethdev: change link status get functions return value to int Andrew Rybchenko
                   ` (11 preceding siblings ...)
  2019-09-10  8:25 ` [dpdk-dev] [PATCH 12/18] examples/ip_pipeline: " Andrew Rybchenko
@ 2019-09-10  8:25 ` Andrew Rybchenko
  2019-09-10  8:25 ` [dpdk-dev] [PATCH 14/18] examples/flow_filtering: " Andrew Rybchenko
                   ` (5 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Andrew Rybchenko @ 2019-09-10  8:25 UTC (permalink / raw)
  To: Marko Kovacevic, Ori Kam, Bruce Richardson, Pablo de Lara,
	Radu Nicolau, Akhil Goyal, Tomasz Kantecki
  Cc: dev, Igor Romanov

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/ethtool/lib/rte_ethtool.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/examples/ethtool/lib/rte_ethtool.c b/examples/ethtool/lib/rte_ethtool.c
index 43cacc057..8393b0d60 100644
--- a/examples/ethtool/lib/rte_ethtool.c
+++ b/examples/ethtool/lib/rte_ethtool.c
@@ -124,9 +124,13 @@ int
 rte_ethtool_get_link(uint16_t port_id)
 {
 	struct rte_eth_link link;
+	int ret;
 
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
-	rte_eth_link_get(port_id, &link);
+	ret = rte_eth_link_get(port_id, &link);
+	if (ret < 0)
+		return ret;
+
 	return link.link_status;
 }
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [dpdk-dev] [PATCH 14/18] examples/flow_filtering: check status of getting link info
  2019-09-10  8:25 [dpdk-dev] [PATCH 00/18] ethdev: change link status get functions return value to int Andrew Rybchenko
                   ` (12 preceding siblings ...)
  2019-09-10  8:25 ` [dpdk-dev] [PATCH 13/18] examples/ethtool: " Andrew Rybchenko
@ 2019-09-10  8:25 ` 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
                   ` (4 subsequent siblings)
  18 siblings, 1 reply; 22+ messages in thread
From: Andrew Rybchenko @ 2019-09-10  8:25 UTC (permalink / raw)
  To: Marko Kovacevic, Ori Kam, Bruce Richardson, Pablo de Lara,
	Radu Nicolau, Akhil Goyal, Tomasz Kantecki
  Cc: dev, Igor Romanov

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/flow_filtering/main.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/examples/flow_filtering/main.c b/examples/flow_filtering/main.c
index c40cfd098..cc9e7e780 100644
--- a/examples/flow_filtering/main.c
+++ b/examples/flow_filtering/main.c
@@ -100,15 +100,19 @@ assert_link_status(void)
 {
 	struct rte_eth_link link;
 	uint8_t rep_cnt = MAX_REPEAT_TIMES;
+	int link_get_err = -EINVAL;
 
 	memset(&link, 0, sizeof(link));
 	do {
-		rte_eth_link_get(port_id, &link);
-		if (link.link_status == ETH_LINK_UP)
+		link_get_err = rte_eth_link_get(port_id, &link);
+		if (link_get_err == 0 && link.link_status == ETH_LINK_UP)
 			break;
 		rte_delay_ms(CHECK_INTERVAL);
 	} while (--rep_cnt);
 
+	if (link_get_err < 0)
+		rte_exit(EXIT_FAILURE, ":: error: link get is failing: %s\n",
+			 rte_strerror(-link_get_err));
 	if (link.link_status == ETH_LINK_DOWN)
 		rte_exit(EXIT_FAILURE, ":: error: link is still down\n");
 }
-- 
2.17.1


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [dpdk-dev] [PATCH 15/18] examples/link_status_interrupt: check status of getting link
  2019-09-10  8:25 [dpdk-dev] [PATCH 00/18] ethdev: change link status get functions return value to int Andrew Rybchenko
                   ` (13 preceding siblings ...)
  2019-09-10  8:25 ` [dpdk-dev] [PATCH 14/18] examples/flow_filtering: " Andrew Rybchenko
@ 2019-09-10  8:25 ` Andrew Rybchenko
  2019-09-10  8:25 ` [dpdk-dev] [PATCH 16/18] examples/distributor: check status of getting link info Andrew Rybchenko
                   ` (3 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Andrew Rybchenko @ 2019-09-10  8:25 UTC (permalink / raw)
  To: Marko Kovacevic, Ori Kam, Bruce Richardson, Pablo de Lara,
	Radu Nicolau, Akhil Goyal, Tomasz Kantecki
  Cc: dev, Igor Romanov

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


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [dpdk-dev] [PATCH 16/18] examples/distributor: check status of getting link info
  2019-09-10  8:25 [dpdk-dev] [PATCH 00/18] ethdev: change link status get functions return value to int Andrew Rybchenko
                   ` (14 preceding siblings ...)
  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 ` Andrew Rybchenko
  2019-09-10  8:25 ` [dpdk-dev] [PATCH 17/18] examples/qos_sched: " Andrew Rybchenko
                   ` (2 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Andrew Rybchenko @ 2019-09-10  8:25 UTC (permalink / raw)
  To: David Hunt; +Cc: dev, Igor Romanov

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/distributor/main.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/examples/distributor/main.c b/examples/distributor/main.c
index 125ee877f..49b4e611f 100644
--- a/examples/distributor/main.c
+++ b/examples/distributor/main.c
@@ -173,12 +173,18 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
 		return retval;
 
 	struct rte_eth_link link;
-	rte_eth_link_get_nowait(port, &link);
-	while (!link.link_status) {
+	do {
+		retval = rte_eth_link_get_nowait(port, &link);
+		if (retval < 0) {
+			printf("Failed link get (port %u): %s\n",
+				port, rte_strerror(-retval));
+			return retval;
+		} else if (link.link_status)
+			break;
+
 		printf("Waiting for Link up on port %"PRIu16"\n", port);
 		sleep(1);
-		rte_eth_link_get_nowait(port, &link);
-	}
+	} while (!link.link_status);
 
 	if (!link.link_status) {
 		printf("Link down on port %"PRIu16"\n", port);
-- 
2.17.1


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [dpdk-dev] [PATCH 17/18] examples/qos_sched: check status of getting link info
  2019-09-10  8:25 [dpdk-dev] [PATCH 00/18] ethdev: change link status get functions return value to int Andrew Rybchenko
                   ` (15 preceding siblings ...)
  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 ` 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
  18 siblings, 0 replies; 22+ messages in thread
From: Andrew Rybchenko @ 2019-09-10  8:25 UTC (permalink / raw)
  To: Cristian Dumitrescu, Jasvinder Singh; +Cc: dev, Igor Romanov

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/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 dbdbdefea..32e6e1ba2 100644
--- a/examples/qos_sched/init.c
+++ b/examples/qos_sched/init.c
@@ -154,7 +154,12 @@ app_init_port(uint16_t portid, struct rte_mempool *mp)
 	printf("done: ");
 
 	/* get link status */
-	rte_eth_link_get(portid, &link);
+	ret = rte_eth_link_get(portid, &link);
+	if (ret < 0)
+		rte_exit(EXIT_FAILURE,
+			 "rte_eth_link_get: err=%d, port=%u: %s\n",
+			 ret, portid, rte_strerror(-ret));
+
 	if (link.link_status) {
 		printf(" Link Up - speed %u Mbps - %s\n",
 			(uint32_t) link.link_speed,
@@ -295,7 +300,11 @@ app_init_sched_port(uint32_t portid, uint32_t socketid)
 	uint32_t pipe, subport;
 	int err;
 
-	rte_eth_link_get(portid, &link);
+	err = rte_eth_link_get(portid, &link);
+	if (err < 0)
+		rte_exit(EXIT_FAILURE,
+			 "rte_eth_link_get: err=%d, port=%u: %s\n",
+			 err, portid, rte_strerror(-err));
 
 	port_params.socket = socketid;
 	port_params.rate = (uint64_t) link.link_speed * 1000 * 1000 / 8;
-- 
2.17.1


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [dpdk-dev] [PATCH 18/18] examples/kni: check status of getting link info
  2019-09-10  8:25 [dpdk-dev] [PATCH 00/18] ethdev: change link status get functions return value to int Andrew Rybchenko
                   ` (16 preceding siblings ...)
  2019-09-10  8:25 ` [dpdk-dev] [PATCH 17/18] examples/qos_sched: " Andrew Rybchenko
@ 2019-09-10  8:25 ` Andrew Rybchenko
  2019-09-24 12:38 ` [dpdk-dev] [PATCH 00/18] ethdev: change link status get functions return value to int Ferruh Yigit
  18 siblings, 0 replies; 22+ messages in thread
From: Andrew Rybchenko @ 2019-09-10  8:25 UTC (permalink / raw)
  To: Ferruh Yigit; +Cc: dev, Igor Romanov

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/kni/main.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/examples/kni/main.c b/examples/kni/main.c
index 08366a5fa..8eb5b610e 100644
--- a/examples/kni/main.c
+++ b/examples/kni/main.c
@@ -739,6 +739,7 @@ monitor_all_ports_link_status(void *arg)
 	struct kni_port_params **p = kni_port_params_array;
 	int prev;
 	(void) arg;
+	int ret;
 
 	while (monitor_links) {
 		rte_delay_ms(500);
@@ -746,7 +747,13 @@ monitor_all_ports_link_status(void *arg)
 			if ((ports_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) {
+				RTE_LOG(ERR, APP,
+					"Get link failed (port %u): %s\n",
+					portid, rte_strerror(-ret));
+				continue;
+			}
 			for (i = 0; i < p[portid]->nb_kni; i++) {
 				prev = rte_kni_update_link(p[portid]->kni[i],
 						link.link_status);
-- 
2.17.1


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [dpdk-dev] [PATCH 01/18] net/bonding: fix link speed update in broadcast mode
  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
  0 siblings, 0 replies; 22+ messages in thread
From: Chas Williams @ 2019-09-10 23:01 UTC (permalink / raw)
  To: Andrew Rybchenko, Chas Williams; +Cc: dev, Igor Romanov, stable

Acked-by: Chas Williams <chas3@att.com>

On 9/10/19 4:25 AM, Andrew Rybchenko wrote:
> From: Igor Romanov <igor.romanov@oktetlabs.ru>
> 
> Fix the issue that the link speed of the bond device was set to the
> link speed of the first active slave in broadcast mode.
> 
> Set the link speed of the bond device to the minimum value across
> all of the slaves in that case.
> 
> Fixes: deba8a2f8b0b ("net/bonding: fix link properties management")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Igor Romanov <igor.romanov@oktetlabs.ru>
> Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
> ---
>   drivers/net/bonding/rte_eth_bond_pmd.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
> index f774e5677..fed71bd95 100644
> --- a/drivers/net/bonding/rte_eth_bond_pmd.c
> +++ b/drivers/net/bonding/rte_eth_bond_pmd.c
> @@ -2395,8 +2395,8 @@ bond_ethdev_link_update(struct rte_eth_dev *ethdev, int wait_to_complete)
>   		 * packet loss will occur on this slave if transmission at rates
>   		 * greater than this are attempted
>   		 */
> -		for (idx = 1; idx < bond_ctx->active_slave_count; idx++) {
> -			link_update(bond_ctx->active_slaves[0],	&slave_link);
> +		for (idx = 0; idx < bond_ctx->active_slave_count; idx++) {
> +			link_update(bond_ctx->active_slaves[idx], &slave_link);
>   
>   			if (slave_link.link_speed <
>   					ethdev->data->dev_link.link_speed)
> 

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [dpdk-dev] [PATCH 14/18] examples/flow_filtering: check status of getting link info
  2019-09-10  8:25 ` [dpdk-dev] [PATCH 14/18] examples/flow_filtering: " Andrew Rybchenko
@ 2019-09-12  5:16   ` Ori Kam
  0 siblings, 0 replies; 22+ messages in thread
From: Ori Kam @ 2019-09-12  5:16 UTC (permalink / raw)
  To: Andrew Rybchenko, Marko Kovacevic, Bruce Richardson,
	Pablo de Lara, Radu Nicolau, Akhil Goyal, Tomasz Kantecki
  Cc: dev, Igor Romanov



> -----Original Message-----
> From: Andrew Rybchenko <arybchenko@solarflare.com>
> Sent: Tuesday, September 10, 2019 11:26 AM
> 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: [PATCH 14/18] examples/flow_filtering: check status of getting link
> info
> 
> 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/flow_filtering/main.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/examples/flow_filtering/main.c b/examples/flow_filtering/main.c
> index c40cfd098..cc9e7e780 100644
> --- a/examples/flow_filtering/main.c
> +++ b/examples/flow_filtering/main.c
> @@ -100,15 +100,19 @@ assert_link_status(void)
>  {
>  	struct rte_eth_link link;
>  	uint8_t rep_cnt = MAX_REPEAT_TIMES;
> +	int link_get_err = -EINVAL;
> 
>  	memset(&link, 0, sizeof(link));
>  	do {
> -		rte_eth_link_get(port_id, &link);
> -		if (link.link_status == ETH_LINK_UP)
> +		link_get_err = rte_eth_link_get(port_id, &link);
> +		if (link_get_err == 0 && link.link_status == ETH_LINK_UP)
>  			break;
>  		rte_delay_ms(CHECK_INTERVAL);
>  	} while (--rep_cnt);
> 
> +	if (link_get_err < 0)
> +		rte_exit(EXIT_FAILURE, ":: error: link get is failing: %s\n",
> +			 rte_strerror(-link_get_err));
>  	if (link.link_status == ETH_LINK_DOWN)
>  		rte_exit(EXIT_FAILURE, ":: error: link is still down\n");
>  }
> --
> 2.17.1

Acked-by: Ori Kam <orika@mellanox.com>
Thanks,
Ori Kam



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [dpdk-dev] [PATCH 00/18] ethdev: change link status get functions return value to int
  2019-09-10  8:25 [dpdk-dev] [PATCH 00/18] ethdev: change link status get functions return value to int Andrew Rybchenko
                   ` (17 preceding siblings ...)
  2019-09-10  8:25 ` [dpdk-dev] [PATCH 18/18] examples/kni: " Andrew Rybchenko
@ 2019-09-24 12:38 ` Ferruh Yigit
  18 siblings, 0 replies; 22+ messages in thread
From: Ferruh Yigit @ 2019-09-24 12:38 UTC (permalink / raw)
  To: Andrew Rybchenko, Thomas Monjalon; +Cc: dev, Igor Romanov

On 9/10/2019 9:25 AM, Andrew Rybchenko wrote:
> It is the fifth patch series to get rid of void returning functions
> in ethdev in accordance with deprecation notice [1].
> 
> It should be applied on top of [2], [3], [4] and [5].
> 
> Functions which return void are bad since they do not provide explicit
> information to the caller if everything is OK or not.
> 
> In the case of link info get it is important to know if link info is
> filled in or not.
> 
> Unlike previous patch series for other functions, this one does not
> touch link_update driver callback since it already has return value
> with different semantics (which is not used in fact). May be negative
> return values should be kept for errors and positive 1 should report
> no link status changes. That's why only negative values are treated
> as errors in the patch series.
> 
> [1] https://patches.dpdk.org/patch/56969/
> [2] https://patches.dpdk.org/project/dpdk/list/?series=6279
> [3] https://patches.dpdk.org/project/dpdk/list/?series=6334
> [4] https://patches.dpdk.org/project/dpdk/list/?series=6335
> [5] https://patches.dpdk.org/project/dpdk/list/?series=6308
> 
> Andrew Rybchenko (2):
>   net/memif: check status of getting link info
>   app/pipeline: check status of getting link info
> 
> Igor Romanov (16):
>   net/bonding: fix link speed update in broadcast mode
>   ethdev: change link status get functions return value to int
>   app/testpmd: check status of getting link info
>   net/bonding: check status of getting link info
>   net/ixgbe: check status of getting link info
>   app/proc-info: check status of getting link info
>   app/test: check status of getting link info
>   examples: check status of getting link info
>   examples/bbdev_app: check status of getting link info
>   examples/ip_pipeline: check status of getting link info
>   examples/ethtool: check status of getting link info
>   examples/flow_filtering: check status of getting link info
>   examples/link_status_interrupt: check status of getting link
>   examples/distributor: check status of getting link info
>   examples/qos_sched: check status of getting link info
>   examples/kni: check status of getting link info

Series applied to dpdk-next-net/master, thanks.

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2019-09-24 12:38 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [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

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).