From: Luc Pelletier <lucp.at.work@gmail.com>
To: grive@u256.net
Cc: dev@dpdk.org, stephen@networkplumber.org,
konstantin.ananyev@huawei.com,
Luc Pelletier <lucp.at.work@gmail.com>,
Matan Azrad <matan@nvidia.com>,
stable@dpdk.org
Subject: [PATCH v3 4/5] failsafe: use public APIs in fs_link_update
Date: Tue, 29 Nov 2022 09:48:32 -0500 [thread overview]
Message-ID: <20221129144832.2750-5-lucp.at.work@gmail.com> (raw)
In-Reply-To: <20221110163410.12734-1-lucp.at.work@gmail.com>
The link_update function pointer is called directly on a sub-device, via
its rte_eth_dev structure. In addition, it assumes that if link_update
returns a value other than 0 or -1, an error occurred. That's not
accurate. For example, the mlx5 PMD returns a positive value to indicate
that the link status was updated. This results in fs_link_update failing
when it really should have succeeded.
The code now uses the public APIs rte_eth_link_get and
rte_eth_link_get_nowait to query the link status of each sub-device. It
also uses rte_eth_linkstatus_set to set the link status of the failsafe
device.
Fixes: ae80146c5a1b ("net/failsafe: fix removed device handling")
Cc: Matan Azrad <matan@nvidia.com>
Cc: stable@dpdk.org
Signed-off-by: Luc Pelletier <lucp.at.work@gmail.com>
---
drivers/net/failsafe/failsafe_ops.c | 38 ++++++++++++++---------------
1 file changed, 18 insertions(+), 20 deletions(-)
diff --git a/drivers/net/failsafe/failsafe_ops.c b/drivers/net/failsafe/failsafe_ops.c
index d357e1bc83..7bd223af37 100644
--- a/drivers/net/failsafe/failsafe_ops.c
+++ b/drivers/net/failsafe/failsafe_ops.c
@@ -820,34 +820,32 @@ fs_link_update(struct rte_eth_dev *dev,
{
struct sub_device *sdev;
uint8_t i;
- int ret;
+ int ret = -1;
+ int sdev_link_ret;
+ struct rte_eth_link link_info;
fs_lock(dev, 0);
FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
- DEBUG("Calling link_update on sub_device %d", i);
- ret = (SUBOPS(sdev, link_update))(ETH(sdev), wait_to_complete);
- if (ret && ret != -1 && sdev->remove == 0 &&
- rte_eth_dev_is_removed(PORT_ID(sdev)) == 0) {
- ERROR("Link update failed for sub_device %d with error %d",
- i, ret);
- fs_unlock(dev, 0);
- return ret;
+ DEBUG("Calling rte_eth_link_get on sub_device %d", i);
+ if (wait_to_complete) {
+ sdev_link_ret = rte_eth_link_get(PORT_ID(sdev), &link_info);
+ } else {
+ sdev_link_ret = rte_eth_link_get_nowait(PORT_ID(sdev),
+ &link_info);
}
- }
- if (TX_SUBDEV(dev)) {
- struct rte_eth_link *l1;
- struct rte_eth_link *l2;
- l1 = &dev->data->dev_link;
- l2 = Ð(TX_SUBDEV(dev))->data->dev_link;
- if (memcmp(l1, l2, sizeof(*l1))) {
- *l1 = *l2;
- fs_unlock(dev, 0);
- return 0;
+ if (likely(sdev_link_ret == 0)) {
+ if (TX_SUBDEV(dev) == sdev)
+ ret = rte_eth_linkstatus_set(dev, &link_info);
+ }
+ else if (sdev->remove == 0 &&
+ rte_eth_dev_is_removed(PORT_ID(sdev)) == 0) {
+ ERROR("Link get failed for sub_device %d with error %d",
+ i, sdev_link_ret);
}
}
fs_unlock(dev, 0);
- return -1;
+ return ret;
}
static int
--
2.38.1
next prev parent reply other threads:[~2022-11-29 14:50 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-10 16:34 [PATCH] failsafe: fix segfault on hotplug event Luc Pelletier
2022-11-10 17:42 ` [PATCH v2] " Luc Pelletier
2022-11-10 23:33 ` Stephen Hemminger
2022-11-16 17:35 ` [PATCH] " Konstantin Ananyev
2022-11-16 21:51 ` Luc Pelletier
2022-11-16 22:25 ` Stephen Hemminger
2022-11-18 16:31 ` Konstantin Ananyev
2022-11-29 14:48 ` [PATCH v3 1/5] " Luc Pelletier
2023-10-31 17:35 ` Stephen Hemminger
2022-11-29 14:48 ` [PATCH v3 3/5] failsafe: fix double release of port Luc Pelletier
2022-11-29 14:48 ` Luc Pelletier [this message]
2022-11-29 14:48 ` [PATCH v3 5/5] failsafe: make sub-device remove flag thread-safe Luc Pelletier
2022-11-29 15:25 ` [PATCH v4 1/5] failsafe: fix segfault on hotplug event Luc Pelletier
2022-11-29 15:25 ` [PATCH v4 3/5] failsafe: fix double release of port Luc Pelletier
2022-11-29 15:25 ` [PATCH v4 4/5] failsafe: use public APIs in fs_link_update Luc Pelletier
2022-11-29 15:25 ` [PATCH v4 5/5] failsafe: make sub-device remove flag thread-safe Luc Pelletier
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=20221129144832.2750-5-lucp.at.work@gmail.com \
--to=lucp.at.work@gmail.com \
--cc=dev@dpdk.org \
--cc=grive@u256.net \
--cc=konstantin.ananyev@huawei.com \
--cc=matan@nvidia.com \
--cc=stable@dpdk.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).