DPDK patches and discussions
 help / color / mirror / Atom feed
From: Matan Azrad <matan@mellanox.com>
To: Ferruh Yigit <ferruh.yigit@intel.com>
Cc: Thomas Monjalon <thomas@monjalon.net>,
	dev@dpdk.org, stephen@networkplumber.org
Subject: [dpdk-dev] [PATCH v5 8/8] net/vdev_netvsc: add automatic probing
Date: Thu, 18 Jan 2018 10:01:49 +0000	[thread overview]
Message-ID: <1516269709-15252-9-git-send-email-matan@mellanox.com> (raw)
In-Reply-To: <1516269709-15252-1-git-send-email-matan@mellanox.com>

Using DPDK in Hyper-V VM systems requires vdev_netvsc driver to pair
the NetVSC netdev device with the same MAC address PCI device by
fail-safe PMD.

Add vdev_netvsc custom scan in vdev bus to allow automatic probing in
Hyper-V VM systems unless it was already specified by command line.

Add "ignore" parameter to disable this auto-detection.

Signed-off-by: Matan Azrad <matan@mellanox.com>
---
 doc/guides/nics/vdev_netvsc.rst       |  9 ++++--
 drivers/net/vdev_netvsc/vdev_netvsc.c | 55 +++++++++++++++++++++++++++++++++--
 2 files changed, 60 insertions(+), 4 deletions(-)

diff --git a/doc/guides/nics/vdev_netvsc.rst b/doc/guides/nics/vdev_netvsc.rst
index 3c26990..55d130a 100644
--- a/doc/guides/nics/vdev_netvsc.rst
+++ b/doc/guides/nics/vdev_netvsc.rst
@@ -71,8 +71,8 @@ Build options
 Run-time parameters
 -------------------
 
-To invoke this driver, applications have to explicitly provide the
-``--vdev=net_vdev_netvsc`` EAL option.
+This driver is invoked automatically in Hyper-V VM systems unless the user
+invoked it by command line using ``--vdev=net_vdev_netvsc`` EAL option.
 
 The following device parameters are supported:
 
@@ -91,5 +91,10 @@ The following device parameters are supported:
   If nonzero, forces the use of specified interfaces even if not detected as
   NetVSC or detected as routed NETVSC.
 
+- ``ignore`` [int]
+
+  If nonzero, ignores the driver runnig (actually used to disable the
+  auto-detection in Hyper-V VM).
+
 Not specifying either ``iface`` or ``mac`` makes this driver attach itself to
 all unrouted NetVSC interfaces found on the system.
diff --git a/drivers/net/vdev_netvsc/vdev_netvsc.c b/drivers/net/vdev_netvsc/vdev_netvsc.c
index 2d03033..a8a1a7f 100644
--- a/drivers/net/vdev_netvsc/vdev_netvsc.c
+++ b/drivers/net/vdev_netvsc/vdev_netvsc.c
@@ -30,13 +30,16 @@
 #include <rte_errno.h>
 #include <rte_ethdev.h>
 #include <rte_ether.h>
+#include <rte_hypervisor.h>
 #include <rte_kvargs.h>
 #include <rte_log.h>
 
 #define VDEV_NETVSC_DRIVER net_vdev_netvsc
+#define VDEV_NETVSC_DRIVER_NAME RTE_STR(VDEV_NETVSC_DRIVER)
 #define VDEV_NETVSC_ARG_IFACE "iface"
 #define VDEV_NETVSC_ARG_MAC "mac"
 #define VDEV_NETVSC_ARG_FORCE "force"
+#define VDEV_NETVSC_ARG_IGNORE "ignore"
 #define VDEV_NETVSC_PROBE_MS 1000
 
 #define NETVSC_CLASS_ID "{f8615163-df3e-46c5-913f-f2d2f965ed0e}"
@@ -45,7 +48,7 @@
 #define DRV_LOG(level, ...) \
 	rte_log(RTE_LOG_ ## level, \
 		vdev_netvsc_logtype, \
-		RTE_FMT(RTE_STR(VDEV_NETVSC_DRIVER) ": " \
+		RTE_FMT(VDEV_NETVSC_DRIVER_NAME ": " \
 			RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
 		RTE_FMT_TAIL(__VA_ARGS__,)))
 
@@ -601,6 +604,7 @@ static LIST_HEAD(, vdev_netvsc_ctx) vdev_netvsc_ctx_list =
 		VDEV_NETVSC_ARG_IFACE,
 		VDEV_NETVSC_ARG_MAC,
 		VDEV_NETVSC_ARG_FORCE,
+		VDEV_NETVSC_ARG_IGNORE,
 		NULL,
 	};
 	const char *name = rte_vdev_device_name(dev);
@@ -610,6 +614,7 @@ static LIST_HEAD(, vdev_netvsc_ctx) vdev_netvsc_ctx_list =
 	unsigned int specified = 0;
 	unsigned int matched = 0;
 	int force = 0;
+	int ignore = 0;
 	unsigned int i;
 	int ret;
 
@@ -623,10 +628,17 @@ static LIST_HEAD(, vdev_netvsc_ctx) vdev_netvsc_ctx_list =
 
 		if (!strcmp(pair->key, VDEV_NETVSC_ARG_FORCE))
 			force = !!atoi(pair->value);
+		else if (!strcmp(pair->key, VDEV_NETVSC_ARG_IGNORE))
+			ignore = !!atoi(pair->value);
 		else if (!strcmp(pair->key, VDEV_NETVSC_ARG_IFACE) ||
 			 !strcmp(pair->key, VDEV_NETVSC_ARG_MAC))
 			++specified;
 	}
+	if (ignore) {
+		if (kvargs)
+			rte_kvargs_free(kvargs);
+		return 0;
+	}
 	rte_eal_alarm_cancel(vdev_netvsc_alarm, NULL);
 	/* Gather interfaces. */
 	ret = vdev_netvsc_foreach_iface(vdev_netvsc_netvsc_probe, name, kvargs,
@@ -690,7 +702,8 @@ static LIST_HEAD(, vdev_netvsc_ctx) vdev_netvsc_ctx_list =
 RTE_PMD_REGISTER_PARAM_STRING(net_vdev_netvsc,
 			      VDEV_NETVSC_ARG_IFACE "=<string> "
 			      VDEV_NETVSC_ARG_MAC "=<string> "
-			      VDEV_NETVSC_ARG_FORCE "=<int>");
+			      VDEV_NETVSC_ARG_FORCE "=<int> "
+			      VDEV_NETVSC_ARG_IGNORE "=<int>");
 
 /** Initialize driver log type. */
 RTE_INIT(vdev_netvsc_init_log)
@@ -699,3 +712,41 @@ static LIST_HEAD(, vdev_netvsc_ctx) vdev_netvsc_ctx_list =
 	if (vdev_netvsc_logtype >= 0)
 		rte_log_set_level(vdev_netvsc_logtype, RTE_LOG_NOTICE);
 }
+
+/** Compare function for vdev find device operation. */
+static int
+vdev_netvsc_cmp_rte_device(const struct rte_device *dev1,
+			   __rte_unused const void *_dev2)
+{
+	return strcmp(dev1->devargs->name, VDEV_NETVSC_DRIVER_NAME);
+}
+
+/**
+ * A callback called by vdev bus scan function to ensure this driver probing
+ * automatically in Hyper-V VM system unless it already exists in the
+ * devargs list.
+ */
+static void
+vdev_netvsc_scan_callback(__rte_unused void *arg)
+{
+	struct rte_vdev_device *dev;
+	struct rte_devargs *devargs;
+	struct rte_bus *vbus = rte_bus_find_by_name("vdev");
+
+	TAILQ_FOREACH(devargs, &devargs_list, next)
+		if (!strcmp(devargs->name, VDEV_NETVSC_DRIVER_NAME))
+			return;
+	dev = (struct rte_vdev_device *)vbus->find_device(NULL,
+		vdev_netvsc_cmp_rte_device, VDEV_NETVSC_DRIVER_NAME);
+	if (dev)
+		return;
+	if (rte_eal_devargs_add(RTE_DEVTYPE_VIRTUAL, VDEV_NETVSC_DRIVER_NAME))
+		DRV_LOG(ERR, "unable to add netvsc devargs.");
+}
+
+/** Initialize the custom scan. */
+RTE_INIT(vdev_netvsc_custom_scan_add)
+{
+	if (rte_hypervisor_get() == RTE_HYPERVISOR_HYPERV)
+		rte_vdev_add_custom_scan(vdev_netvsc_scan_callback, NULL);
+}
-- 
1.8.3.1

  parent reply	other threads:[~2018-01-18 10:02 UTC|newest]

Thread overview: 112+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20171124160801.GU4062@6wind.com>
     [not found] ` <20171124164812.GV4062@6wind.com>
2017-11-24 17:21   ` [dpdk-dev] [RFC] Introduce virtual PMD for Hyper-V/Azure platforms Adrien Mazarguil
2017-12-18 16:46     ` [dpdk-dev] [PATCH v1 0/3] " Adrien Mazarguil
2017-12-18 16:46       ` [dpdk-dev] [PATCH v1 1/3] net/hyperv: introduce MS Hyper-V platform driver Adrien Mazarguil
2017-12-18 18:28         ` Stephen Hemminger
2017-12-18 19:54           ` Thomas Monjalon
2017-12-18 21:17             ` Stephen Hemminger
2017-12-19 10:01               ` Adrien Mazarguil
2017-12-19 11:15                 ` Thomas Monjalon
2017-12-19 13:13                   ` Adrien Mazarguil
2017-12-18 16:46       ` [dpdk-dev] [PATCH v1 2/3] net/hyperv: implement core functionality Adrien Mazarguil
2017-12-18 17:04         ` Wiles, Keith
2017-12-18 17:59           ` Adrien Mazarguil
2017-12-18 18:43             ` Wiles, Keith
2017-12-19  8:25               ` Nelio Laranjeiro
2017-12-18 18:26         ` Stephen Hemminger
2017-12-18 20:21           ` Adrien Mazarguil
2017-12-18 21:03             ` Thomas Monjalon
2017-12-18 21:19               ` Stephen Hemminger
2017-12-18 18:34         ` Stephen Hemminger
2017-12-18 20:23           ` Adrien Mazarguil
2017-12-19  9:53             ` Bruce Richardson
2017-12-19 10:15               ` Adrien Mazarguil
2017-12-19 15:31                 ` Stephen Hemminger
2017-12-18 23:59         ` Stephen Hemminger
2017-12-19 10:01           ` Adrien Mazarguil
2017-12-19 15:37             ` Stephen Hemminger
2017-12-19  1:54         ` Ferruh Yigit
2017-12-19 15:06           ` Adrien Mazarguil
2017-12-19 20:44             ` Ferruh Yigit
2017-12-20 14:13               ` Thomas Monjalon
2017-12-21 16:19               ` Adrien Mazarguil
2017-12-18 16:46       ` [dpdk-dev] [PATCH v1 3/3] net/hyperv: add "force" parameter Adrien Mazarguil
2017-12-18 18:23       ` [dpdk-dev] [PATCH v1 0/3] Introduce virtual PMD for Hyper-V/Azure platforms Stephen Hemminger
2017-12-18 20:13         ` Thomas Monjalon
2017-12-19  0:40           ` Stephen Hemminger
2017-12-18 20:21         ` Adrien Mazarguil
2017-12-22 18:01       ` [dpdk-dev] [PATCH v2 0/5] " Adrien Mazarguil
2017-12-22 18:01         ` [dpdk-dev] [PATCH v2 1/5] net/failsafe: fix invalid free Adrien Mazarguil
2017-12-22 18:01         ` [dpdk-dev] [PATCH v2 2/5] net/failsafe: add "fd" parameter Adrien Mazarguil
2017-12-22 18:01         ` [dpdk-dev] [PATCH v2 3/5] net/vdev_netvsc: introduce Hyper-V platform driver Adrien Mazarguil
2017-12-22 18:01         ` [dpdk-dev] [PATCH v2 4/5] net/vdev_netvsc: implement core functionality Adrien Mazarguil
2017-12-22 18:01         ` [dpdk-dev] [PATCH v2 5/5] net/vdev_netvsc: add "force" parameter Adrien Mazarguil
2017-12-23  2:06         ` [dpdk-dev] [PATCH v2 0/5] Introduce virtual PMD for Hyper-V/Azure platforms Stephen Hemminger
2017-12-23 14:28           ` Thomas Monjalon
2018-01-09 14:47         ` [dpdk-dev] [PATCH v3 0/8] Introduce virtual driver " Matan Azrad
2018-01-09 14:47           ` [dpdk-dev] [PATCH v3 1/8] net/failsafe: fix invalid free Matan Azrad
2018-01-16 10:24             ` Gaëtan Rivet
2018-01-09 14:47           ` [dpdk-dev] [PATCH v3 2/8] net/failsafe: add "fd" parameter Matan Azrad
2018-01-16 10:54             ` Gaëtan Rivet
2018-01-16 11:19               ` Gaëtan Rivet
2018-01-16 16:17                 ` Matan Azrad
2018-01-09 14:47           ` [dpdk-dev] [PATCH v3 3/8] net/failsafe: support probed sub-devices getting Matan Azrad
2018-01-16 11:09             ` Gaëtan Rivet
2018-01-16 12:27               ` Matan Azrad
2018-01-16 14:40                 ` Gaëtan Rivet
2018-01-16 16:15                   ` Matan Azrad
2018-01-16 16:54                     ` Gaëtan Rivet
2018-01-16 17:20                       ` Matan Azrad
2018-01-16 22:31                         ` Gaëtan Rivet
2018-01-17  8:40                           ` Matan Azrad
2018-01-09 14:47           ` [dpdk-dev] [PATCH v3 4/8] net/vdev_netvsc: introduce Hyper-V platform driver Matan Azrad
2018-01-09 14:47           ` [dpdk-dev] [PATCH v3 5/8] net/vdev_netvsc: implement core functionality Matan Azrad
2018-01-09 18:49             ` Stephen Hemminger
2018-01-10 15:02               ` Matan Azrad
2018-01-17 16:51                 ` Thomas Monjalon
2018-01-09 14:47           ` [dpdk-dev] [PATCH v3 6/8] net/vdev_netvsc: skip routed netvsc probing Matan Azrad
2018-01-09 18:51             ` Stephen Hemminger
2018-01-10 15:07               ` Matan Azrad
2018-01-10 16:43                 ` Stephen Hemminger
2018-01-11  9:00                   ` Matan Azrad
2018-01-17 16:59                     ` Thomas Monjalon
2018-01-09 14:47           ` [dpdk-dev] [PATCH v3 7/8] net/vdev_netvsc: add "force" parameter Matan Azrad
2018-01-09 14:47           ` [dpdk-dev] [PATCH v3 8/8] net/vdev_netvsc: add automatic probing Matan Azrad
2018-01-18  8:43           ` [dpdk-dev] [PATCH v4 0/8] Introduce virtual driver for Hyper-V/Azure platforms Matan Azrad
2018-01-18  8:43             ` [dpdk-dev] [PATCH v4 1/8] net/failsafe: fix invalid free Matan Azrad
2018-01-18  8:43             ` [dpdk-dev] [PATCH v4 2/8] net/failsafe: add "fd" parameter Matan Azrad
2018-01-18  8:51               ` Gaëtan Rivet
2018-01-18  8:43             ` [dpdk-dev] [PATCH v4 3/8] net/failsafe: add probed etherdev capture Matan Azrad
2018-01-18  9:10               ` Gaëtan Rivet
2018-01-18  9:33                 ` Matan Azrad
2018-01-18  8:43             ` [dpdk-dev] [PATCH v4 4/8] net/vdev_netvsc: introduce Hyper-V platform driver Matan Azrad
2018-01-18  8:43             ` [dpdk-dev] [PATCH v4 5/8] net/vdev_netvsc: implement core functionality Matan Azrad
2018-01-18 18:25               ` Stephen Hemminger
2018-01-18 18:28                 ` Matan Azrad
2018-01-18  8:43             ` [dpdk-dev] [PATCH v4 6/8] net/vdev_netvsc: skip routed netvsc probing Matan Azrad
2018-01-18 18:26               ` Stephen Hemminger
2018-01-18 18:47                 ` Thomas Monjalon
2018-01-18  8:43             ` [dpdk-dev] [PATCH v4 7/8] net/vdev_netvsc: add "force" parameter Matan Azrad
2018-01-18 18:27               ` Stephen Hemminger
2018-01-18 18:30                 ` Matan Azrad
2018-01-18  8:43             ` [dpdk-dev] [PATCH v4 8/8] net/vdev_netvsc: add automatic probing Matan Azrad
2018-01-18 10:01             ` [dpdk-dev] [PATCH v5 0/8] Introduce virtual driver for Hyper-V/Azure platforms Matan Azrad
2018-01-18 10:01               ` [dpdk-dev] [PATCH v5 1/8] net/failsafe: fix invalid free Matan Azrad
2018-01-18 10:01               ` [dpdk-dev] [PATCH v5 2/8] net/failsafe: add "fd" parameter Matan Azrad
2018-01-18 10:01               ` [dpdk-dev] [PATCH v5 3/8] net/failsafe: add probed etherdev capture Matan Azrad
2018-01-18 10:08                 ` Gaëtan Rivet
2018-01-18 10:01               ` [dpdk-dev] [PATCH v5 4/8] net/vdev_netvsc: introduce Hyper-V platform driver Matan Azrad
2018-01-18 10:01               ` [dpdk-dev] [PATCH v5 5/8] net/vdev_netvsc: implement core functionality Matan Azrad
2018-01-18 10:01               ` [dpdk-dev] [PATCH v5 6/8] net/vdev_netvsc: skip routed netvsc probing Matan Azrad
2018-01-18 10:01               ` [dpdk-dev] [PATCH v5 7/8] net/vdev_netvsc: add "force" parameter Matan Azrad
2018-01-18 10:01               ` Matan Azrad [this message]
2018-01-18 13:51               ` [dpdk-dev] [PATCH v6 0/8] Introduce virtual driver for Hyper-V/Azure platforms Matan Azrad
2018-01-18 13:51                 ` [dpdk-dev] [PATCH v6 1/8] net/failsafe: fix invalid free Matan Azrad
2018-01-18 13:51                 ` [dpdk-dev] [PATCH v6 2/8] net/failsafe: add "fd" parameter Matan Azrad
2018-01-18 13:51                 ` [dpdk-dev] [PATCH v6 3/8] net/failsafe: add probed etherdev capture Matan Azrad
2018-01-18 22:34                   ` Thomas Monjalon
2018-01-18 13:51                 ` [dpdk-dev] [PATCH v6 4/8] net/vdev_netvsc: introduce Hyper-V platform driver Matan Azrad
2018-01-18 13:51                 ` [dpdk-dev] [PATCH v6 5/8] net/vdev_netvsc: implement core functionality Matan Azrad
2018-01-18 13:51                 ` [dpdk-dev] [PATCH v6 6/8] net/vdev_netvsc: skip routed netvsc probing Matan Azrad
2018-01-18 13:51                 ` [dpdk-dev] [PATCH v6 7/8] net/vdev_netvsc: add "force" parameter Matan Azrad
2018-01-18 13:51                 ` [dpdk-dev] [PATCH v6 8/8] net/vdev_netvsc: add automatic probing Matan Azrad
2018-01-20  1:15                 ` [dpdk-dev] [PATCH v6 0/8] Introduce virtual driver for Hyper-V/Azure platforms 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=1516269709-15252-9-git-send-email-matan@mellanox.com \
    --to=matan@mellanox.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=stephen@networkplumber.org \
    --cc=thomas@monjalon.net \
    /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).