From: Thomas Monjalon <thomas@monjalon.net>
To: dev@dpdk.org
Cc: Ferruh Yigit <ferruh.yigit@intel.com>,
Andrew Rybchenko <arybchenko@solarflare.com>
Subject: [dpdk-dev] [PATCH 1/2] ethdev: deduplicate functions to get link infos
Date: Wed, 8 Apr 2020 00:26:36 +0200 [thread overview]
Message-ID: <20200407222637.55289-2-thomas@monjalon.net> (raw)
In-Reply-To: <20200407222637.55289-1-thomas@monjalon.net>
There are two function to retrieve link informations.
The only small difference is a boolean timeout parameter.
Adding a new static function, with an additional parameter,
removes the code redundancy.
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
lib/librte_ethdev/rte_ethdev.c | 52 ++++++++++++++--------------------
1 file changed, 22 insertions(+), 30 deletions(-)
diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index 0854ef8832..0df39dff97 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -2332,44 +2332,36 @@ rte_eth_allmulticast_get(uint16_t port_id)
return dev->data->all_multicast;
}
+static int
+get_link_infos(uint16_t port_id, struct rte_eth_link *eth_link, int wait)
+{
+ struct rte_eth_dev *dev;
+
+ 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_ERR_RET(*dev->dev_ops->link_update, -ENOTSUP);
+ (*dev->dev_ops->link_update)(dev, wait);
+ *eth_link = dev->data->dev_link;
+ }
+
+ return 0;
+}
+
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_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_ERR_RET(*dev->dev_ops->link_update, -ENOTSUP);
- (*dev->dev_ops->link_update)(dev, 1);
- *eth_link = dev->data->dev_link;
- }
-
- return 0;
+ return get_link_infos(port_id, eth_link, 1);
}
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_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_ERR_RET(*dev->dev_ops->link_update, -ENOTSUP);
- (*dev->dev_ops->link_update)(dev, 0);
- *eth_link = dev->data->dev_link;
- }
-
- return 0;
+ return get_link_infos(port_id, eth_link, 0);
}
int
--
2.26.0
next prev parent reply other threads:[~2020-04-07 22:27 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-01 9:33 [dpdk-dev] [RFC] ethdev: use special speed for virtual Ethernet devices Morten Brørup
2020-04-01 9:53 ` Thomas Monjalon
2020-04-01 10:03 ` Benoit Ganne (bganne)
2020-04-01 10:06 ` [dpdk-dev] [RFC] ethdev: use special speed for virtual Ethernetdevices Morten Brørup
2020-04-02 12:54 ` Ivan Dyukov
2020-04-02 13:50 ` Morten Brørup
2020-04-02 15:29 ` Stephen Hemminger
2020-04-02 20:41 ` Ivan Dyukov
2020-04-02 20:58 ` Thomas Monjalon
2020-04-03 8:05 ` Ivan Dyukov
2020-04-03 9:45 ` Morten Brørup
2020-04-03 11:01 ` Thomas Monjalon
2020-04-07 22:26 ` [dpdk-dev] [PATCH 0/2] ethdev link speed Thomas Monjalon
2020-04-07 22:26 ` Thomas Monjalon [this message]
2020-04-08 5:21 ` [dpdk-dev] [PATCH 1/2] ethdev: deduplicate functions to get link infos Asaf Penso
2020-04-08 12:49 ` Thomas Monjalon
2020-04-13 14:14 ` Andrew Rybchenko
2020-04-07 22:26 ` [dpdk-dev] [PATCH 2/2] ethdev: allow unknown link speed Thomas Monjalon
2020-04-08 5:39 ` Jerin Jacob
2020-04-10 10:53 ` Morten Brørup
2020-04-13 14:26 ` Andrew Rybchenko
2020-04-16 13:42 ` Ferruh Yigit
2020-04-26 11:44 ` Matan Azrad
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=20200407222637.55289-2-thomas@monjalon.net \
--to=thomas@monjalon.net \
--cc=arybchenko@solarflare.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@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).