From: Andrew Rybchenko <arybchenko@solarflare.com>
To: Neil Horman <nhorman@tuxdriver.com>,
John McNamara <john.mcnamara@intel.com>,
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>,
Chas Williams <chas3@att.com>,
Thomas Monjalon <thomas@monjalon.net>,
Ferruh Yigit <ferruh.yigit@intel.com>
Cc: <dev@dpdk.org>, Igor Romanov <igor.romanov@oktetlabs.ru>
Subject: [dpdk-dev] [PATCH 02/18] ethdev: change link status get functions return value to int
Date: Tue, 10 Sep 2019 09:25:42 +0100 [thread overview]
Message-ID: <1568103959-25572-3-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>
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
next prev parent reply other threads:[~2019-09-10 8:27 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-10 8:25 [dpdk-dev] [PATCH 00/18] " 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 ` Andrew Rybchenko [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1568103959-25572-3-git-send-email-arybchenko@solarflare.com \
--to=arybchenko@solarflare.com \
--cc=akhil.goyal@nxp.com \
--cc=bruce.richardson@intel.com \
--cc=chas3@att.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
--cc=igor.romanov@oktetlabs.ru \
--cc=john.mcnamara@intel.com \
--cc=marko.kovacevic@intel.com \
--cc=nhorman@tuxdriver.com \
--cc=orika@mellanox.com \
--cc=pablo.de.lara.guarch@intel.com \
--cc=radu.nicolau@intel.com \
--cc=thomas@monjalon.net \
--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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).