From: Matan Azrad <matan@nvidia.com>
To: Stephen Hemminger <stephen@networkplumber.org>,
"matan@mellanox.com" <matan@mellanox.com>,
"grive@u246.net" <grive@u246.net>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH] net/vdev_netvsc: handle removal of associated pci device
Date: Sun, 6 Sep 2020 12:38:18 +0000 [thread overview]
Message-ID: <MW2PR12MB2492D5F88DF930BC0EA188DDDF2B0@MW2PR12MB2492.namprd12.prod.outlook.com> (raw)
In-Reply-To: <20200819175333.19601-1-stephen@networkplumber.org>
Hi Stephen
From: Stephen Hemminger:
> The vdev_netvsc was not detecting when the associated PCI device
> (SRIOV) was removed. Because of that it would keep feeding the same
> (removed) device to failsafe PMD which would then unsuccessfully try and
> probe for it.
>
> Change to use a mark/sweep method to detect that PCI device was
> removed, and also only tell failsafe about new PCI devices.
> Vdev_netvsc does not have to keep stuffing the pipe with the same already
> existing PCI device.
As I know, the vdev_netvsc driver doesn't call to failsafe if the PCI device is not detected by the readlink command(considered as removed)...
Am I missing something?
>
> Fixes: e7dc5d7becc5 ("net/vdev_netvsc: implement core functionality")
> Cc: matan@mellanox.com, stable@dpdk.org
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
> drivers/net/vdev_netvsc/vdev_netvsc.c | 39 +++++++++++++++++++++++-
> ---
> 1 file changed, 34 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/vdev_netvsc/vdev_netvsc.c
> b/drivers/net/vdev_netvsc/vdev_netvsc.c
> index 1ecb0b3e6a34..80a3158012ce 100644
> --- a/drivers/net/vdev_netvsc/vdev_netvsc.c
> +++ b/drivers/net/vdev_netvsc/vdev_netvsc.c
> @@ -66,6 +66,7 @@ struct vdev_netvsc_ctx {
> char devargs[256]; /**< Fail-safe device arguments. */
> char if_name[IF_NAMESIZE]; /**< NetVSC netdevice name. */
> unsigned int if_index; /**< NetVSC netdevice index. */
> + int pci_found; /**< Device detection */
> struct rte_ether_addr if_addr; /**< NetVSC MAC address. */
> int pipe[2]; /**< Fail-safe communication pipe. */
> char yield[256]; /**< PCI sub-device arguments. */
> @@ -405,11 +406,18 @@ vdev_netvsc_device_probe(const struct
> if_nameindex *iface,
> len = strlen(addr);
> if (!len)
> return 0;
> +
The file code convention is to use blank lines in blocks only after variables declarations.
> + ctx->pci_found = 1;
> +
> + /* Skip if this is same device already sent to failsafe */
> + if (strcmp(addr, ctx->yield) == 0)
> + return 0;
> +
> + DRV_LOG(DEBUG, "associating PCI device \"%s\" with NetVSC"
> + " interface \"%s\" (index %u)", addr, ctx->if_name,
> + ctx->if_index);
> +
> /* Send PCI device argument to fail-safe PMD instance. */
> - if (strcmp(addr, ctx->yield))
> - DRV_LOG(DEBUG, "associating PCI device \"%s\" with NetVSC"
> - " interface \"%s\" (index %u)", addr, ctx->if_name,
> - ctx->if_index);
> memmove(buf, addr, len + 1);
> addr = buf;
> buf[len] = '\n';
> @@ -452,12 +460,33 @@ vdev_netvsc_alarm(__rte_unused void *arg)
> struct vdev_netvsc_ctx *ctx;
> int ret;
>
> + /* 1st pass: clear PCI flag on all devices */
> + LIST_FOREACH(ctx, &vdev_netvsc_ctx_list, entry) {
> + ctx->pci_found = 0;
> + }
> +
> + /* 2nd pass: scan all system devices to look for changes to this
> + device */
> LIST_FOREACH(ctx, &vdev_netvsc_ctx_list, entry) {
> ret = vdev_netvsc_foreach_iface(vdev_netvsc_device_probe, 0,
> ctx);
> - if (ret < 0)
> +
> + if (ret < 0) {
> + DRV_LOG(NOTICE, "can not scan devices for %s\n",
> + ctx->if_name);
> break;
> + }
> }
> +
> + /* 3rd pass: detect PCI removal */
> + LIST_FOREACH(ctx, &vdev_netvsc_ctx_list, entry) {
> + if (!ctx->pci_found && ctx->yield[0]) {
> + DRV_LOG(DEBUG, "disassociating PCI device \"%s\" from
> NetVSC"
> + " interface \"%s\" (index %u)", ctx->yield, ctx->if_name,
> + ctx->if_index);
> + ctx->yield[0] = '\0';
> + }
> + }
> +
> if (!vdev_netvsc_ctx_count)
> return;
> ret = rte_eal_alarm_set(VDEV_NETVSC_PROBE_MS * 1000,
> --
> 2.27.0
next prev parent reply other threads:[~2020-09-06 12:38 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-19 17:53 Stephen Hemminger
2020-09-06 8:11 ` Long Li
2020-09-06 12:38 ` Matan Azrad [this message]
2020-09-06 18:33 ` Stephen Hemminger
2020-09-07 8:09 ` Matan Azrad
2020-09-15 4:53 ` Long Li
2020-09-15 7:00 ` Matan Azrad
2020-09-25 20:30 ` Long Li
2020-10-19 22:33 ` Thomas Monjalon
2020-10-19 22:36 ` Thomas Monjalon
2020-10-20 9:13 ` Gaëtan Rivet
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=MW2PR12MB2492D5F88DF930BC0EA188DDDF2B0@MW2PR12MB2492.namprd12.prod.outlook.com \
--to=matan@nvidia.com \
--cc=dev@dpdk.org \
--cc=grive@u246.net \
--cc=matan@mellanox.com \
--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).