DPDK patches and discussions
 help / color / mirror / Atom feed
From: Thomas Monjalon <thomas@monjalon.net>
To: gaetan.rivet@6wind.com
Cc: dev@dpdk.org
Subject: [dpdk-dev] [PATCH] net/failsafe: do not probe device if plugged out
Date: Wed, 12 Jul 2017 20:28:12 +0200	[thread overview]
Message-ID: <20170712182812.18404-1-thomas@monjalon.net> (raw)

When probing a sub-devices which does not exist in the system,
some errors are logged:
	EAL: Cannot find unplugged device (0002:00:02.0)
	PMD: net_failsafe: ERROR: sub_device 0 probe failed

It is normal to have these errors when initializing the failsafe
device and its sub-devices.
But we do not need to log them at each probe.
And it is even less relevant if the sub-device has been plugged out.

The unavailable devices are skipped after the first probe, considering
two exceptions:
- The vdevs are always probed because they do not really exist on the
virtual bus before probing them.
- The sub-device list given by an executed command line may change
from one call to the next one, therefore it is considered to be always
the first one. Anyway, such external command should check the
device availability before passing it to the failsafe PMD.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
This patch is on top of the failsafe series which is
pending for integration in 17.08-rc2.
---
 drivers/net/failsafe/failsafe_eal.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/net/failsafe/failsafe_eal.c b/drivers/net/failsafe/failsafe_eal.c
index 3321dda71..5181066ed 100644
--- a/drivers/net/failsafe/failsafe_eal.c
+++ b/drivers/net/failsafe/failsafe_eal.c
@@ -49,6 +49,11 @@ fs_find_ethdev(const struct rte_device *dev)
 	return NULL;
 }
 
+static int cmp_dev_name(const struct rte_device *dev, const void *name)
+{
+	return strcmp(dev->name, name);
+}
+
 static int
 fs_bus_init(struct rte_eth_dev *dev)
 {
@@ -56,12 +61,24 @@ fs_bus_init(struct rte_eth_dev *dev)
 	struct rte_device *rdev;
 	struct rte_devargs *da;
 	uint8_t i;
+	static int first_init = 1;
 	int ret;
 
 	FOREACH_SUBDEV(sdev, i, dev) {
 		if (sdev->state != DEV_PARSED)
 			continue;
 		da = &sdev->devargs;
+
+		/* skip plugged out devices */
+		if (! first_init
+				&& sdev->cmdline == NULL
+				&& strcmp(da->bus->name, "vdev") != 0) {
+			da->bus->scan();
+			if (bus->find_device(NULL, cmp_dev_name, da->name) == NULL)
+				continue; /* device not found */
+		}
+
+		/* probe device */
 		rdev = rte_eal_hotplug_add(da->bus->name,
 					   da->name,
 					   da->args);
@@ -84,6 +101,10 @@ fs_bus_init(struct rte_eth_dev *dev)
 		ETH(sdev)->state = RTE_ETH_DEV_DEFERRED;
 		sdev->state = DEV_PROBED;
 	}
+
+	if (first_init)
+		first_init = 0;
+
 	return 0;
 }
 
-- 
2.13.2

             reply	other threads:[~2017-07-12 18:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-12 18:28 Thomas Monjalon [this message]
2017-07-12 20:39 ` Gaëtan Rivet
2017-07-13  6:52   ` Thomas Monjalon
2017-07-13  8:14     ` Gaëtan Rivet
2017-07-13  9:17       ` Thomas Monjalon
2017-07-18  8:39         ` Ferruh Yigit
2017-07-18 20:49           ` Thomas Monjalon

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=20170712182812.18404-1-thomas@monjalon.net \
    --to=thomas@monjalon.net \
    --cc=dev@dpdk.org \
    --cc=gaetan.rivet@6wind.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).