[dpdk-dev] [PATCH v1 1/3] net/hyperv: introduce MS Hyper-V platform driver

Adrien Mazarguil adrien.mazarguil at 6wind.com
Mon Dec 18 17:46:21 CET 2017


This patch lays the groundwork for this PMD (draft documentation, copyright
notices, code base skeleton and build system hooks). While it can be
successfully compiled and invoked, it's an empty shell at this stage.

Signed-off-by: Adrien Mazarguil <adrien.mazarguil at 6wind.com>
---
 MAINTAINERS                                   |   6 +
 config/common_base                            |   6 +
 config/common_linuxapp                        |   1 +
 doc/guides/nics/features/hyperv.ini           |  12 ++
 doc/guides/nics/hyperv.rst                    |  49 ++++++++
 doc/guides/nics/index.rst                     |   1 +
 drivers/net/Makefile                          |   1 +
 drivers/net/hyperv/Makefile                   |  54 +++++++++
 drivers/net/hyperv/hyperv.c                   | 135 +++++++++++++++++++++
 drivers/net/hyperv/rte_pmd_hyperv_version.map |   4 +
 mk/rte.app.mk                                 |   1 +
 11 files changed, 270 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 5a63b40c2..fe686f4c5 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -451,6 +451,12 @@ F: drivers/net/mrvl/
 F: doc/guides/nics/mrvl.rst
 F: doc/guides/nics/features/mrvl.ini
 
+Microsoft hyperv
+M: Adrien Mazarguil <adrien.mazarguil at 6wind.com>
+F: drivers/net/hyperv/
+F: doc/guides/nics/hyperv.rst
+F: doc/guides/nics/features/hyperv.ini
+
 Netcope szedata2
 M: Matej Vido <vido at cesnet.cz>
 F: drivers/net/szedata2/
diff --git a/config/common_base b/config/common_base
index b8ee8f91c..8bc83c8c9 100644
--- a/config/common_base
+++ b/config/common_base
@@ -280,6 +280,12 @@ CONFIG_RTE_LIBRTE_NFP_DEBUG=n
 CONFIG_RTE_LIBRTE_MRVL_PMD=n
 
 #
+# Compile Microsoft Hyper-V/Azure driver
+#
+CONFIG_RTE_LIBRTE_HYPERV_PMD=n
+CONFIG_RTE_LIBRTE_HYPERV_DEBUG=n
+
+#
 # Compile burst-oriented Broadcom BNXT PMD driver
 #
 CONFIG_RTE_LIBRTE_BNXT_PMD=y
diff --git a/config/common_linuxapp b/config/common_linuxapp
index 74c7d64ec..fac6cb172 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -47,6 +47,7 @@ CONFIG_RTE_LIBRTE_PMD_VHOST=y
 CONFIG_RTE_LIBRTE_PMD_AF_PACKET=y
 CONFIG_RTE_LIBRTE_PMD_TAP=y
 CONFIG_RTE_LIBRTE_AVP_PMD=y
+CONFIG_RTE_LIBRTE_HYPERV_PMD=y
 CONFIG_RTE_LIBRTE_NFP_PMD=y
 CONFIG_RTE_LIBRTE_POWER=y
 CONFIG_RTE_VIRTIO_USER=y
diff --git a/doc/guides/nics/features/hyperv.ini b/doc/guides/nics/features/hyperv.ini
new file mode 100644
index 000000000..170912c25
--- /dev/null
+++ b/doc/guides/nics/features/hyperv.ini
@@ -0,0 +1,12 @@
+;
+; Supported features of the 'hyperv' network poll mode driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+[Features]
+ARMv7                = Y
+ARMv8                = Y
+Power8               = Y
+x86-32               = Y
+x86-64               = Y
+Usage doc            = Y
diff --git a/doc/guides/nics/hyperv.rst b/doc/guides/nics/hyperv.rst
new file mode 100644
index 000000000..28c4443d6
--- /dev/null
+++ b/doc/guides/nics/hyperv.rst
@@ -0,0 +1,49 @@
+..  BSD LICENSE
+    Copyright 2017 6WIND S.A.
+    Copyright 2017 Mellanox
+
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following conditions
+    are met:
+
+    * Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in
+    the documentation and/or other materials provided with the
+    distribution.
+    * Neither the name of 6WIND S.A. nor the names of its
+    contributors may be used to endorse or promote products derived
+    from this software without specific prior written permission.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+    A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+    OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+    THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+HYPERV poll mode driver
+=======================
+
+The HYPERV PMD (librte_pmd_hyperv) provides support for NetVSC interfaces
+and associated SR-IOV virtual function (VF) devices found in Linux virtual
+machines running on Microsoft Hyper-V_ (including Azure) platforms.
+
+.. _Hyper-V: https://docs.microsoft.com/en-us/windows-hardware/drivers/network/overview-of-hyper-v
+
+Build options
+-------------
+
+- ``CONFIG_RTE_LIBRTE_HYPERV_PMD`` (default ``y``)
+
+   Toggle compilation of this driver.
+
+- ``CONFIG_RTE_LIBRTE_HYPERV_DEBUG`` (default ``n``)
+
+   Toggle additional debugging code.
diff --git a/doc/guides/nics/index.rst b/doc/guides/nics/index.rst
index 23babe933..9d66353a1 100644
--- a/doc/guides/nics/index.rst
+++ b/doc/guides/nics/index.rst
@@ -49,6 +49,7 @@ Network Interface Controller Drivers
     ena
     enic
     fm10k
+    hyperv
     i40e
     ixgbe
     intel_vf
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index ef09b4e16..5bcc37cb3 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -55,6 +55,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_LIO_PMD) += liquidio
 DIRS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4
 DIRS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5
 DIRS-$(CONFIG_RTE_LIBRTE_MRVL_PMD) += mrvl
+DIRS-$(CONFIG_RTE_LIBRTE_HYPERV_PMD) += hyperv
 DIRS-$(CONFIG_RTE_LIBRTE_NFP_PMD) += nfp
 DIRS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_NULL) += null
diff --git a/drivers/net/hyperv/Makefile b/drivers/net/hyperv/Makefile
new file mode 100644
index 000000000..82c720353
--- /dev/null
+++ b/drivers/net/hyperv/Makefile
@@ -0,0 +1,54 @@
+#   BSD LICENSE
+#
+#   Copyright 2017 6WIND S.A.
+#   Copyright 2017 Mellanox
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+#     * Redistributions of source code must retain the above copyright
+#       notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above copyright
+#       notice, this list of conditions and the following disclaimer in
+#       the documentation and/or other materials provided with the
+#       distribution.
+#     * Neither the name of 6WIND S.A. nor the names of its
+#       contributors may be used to endorse or promote products derived
+#       from this software without specific prior written permission.
+#
+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+#   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+#   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+#   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+#   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+#   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+# Properties of the generated library.
+LIB = librte_pmd_hyperv.a
+LIBABIVER := 1
+EXPORT_MAP := rte_pmd_hyperv_version.map
+
+# Additional compilation flags.
+CFLAGS += -O3
+CFLAGS += -g
+CFLAGS += -std=c11 -pedantic -Wall -Wextra
+CFLAGS += $(WERROR_FLAGS)
+
+# Dependencies.
+LDLIBS += -lrte_bus_vdev
+LDLIBS += -lrte_eal
+LDLIBS += -lrte_ethdev
+LDLIBS += -lrte_kvargs
+
+# Source files.
+SRCS-$(CONFIG_RTE_LIBRTE_HYPERV_PMD) += hyperv.c
+
+include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/drivers/net/hyperv/hyperv.c b/drivers/net/hyperv/hyperv.c
new file mode 100644
index 000000000..2f940c76f
--- /dev/null
+++ b/drivers/net/hyperv/hyperv.c
@@ -0,0 +1,135 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright 2017 6WIND S.A.
+ *   Copyright 2017 Mellanox
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in
+ *       the documentation and/or other materials provided with the
+ *       distribution.
+ *     * Neither the name of 6WIND S.A. nor the names of its
+ *       contributors may be used to endorse or promote products derived
+ *       from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stddef.h>
+#include <string.h>
+
+#include <rte_bus_vdev.h>
+#include <rte_config.h>
+#include <rte_kvargs.h>
+#include <rte_log.h>
+
+#define HYPERV_DRIVER net_hyperv
+#define HYPERV_ARG_IFACE "iface"
+#define HYPERV_ARG_MAC "mac"
+
+#ifdef RTE_LIBRTE_HYPERV_DEBUG
+
+#define PMD_DRV_LOG(level, ...) \
+	RTE_LOG(level, PMD, \
+		RTE_FMT("%s:%u: %s(): " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
+			strrchr("/" __FILE__, '/') + 1, \
+			__LINE__, \
+			__func__, \
+			RTE_FMT_TAIL(__VA_ARGS__,)))
+
+#else /* RTE_LIBRTE_HYPERV_DEBUG */
+
+#define PMD_DRV_LOG(level, ...) \
+	RTE_LOG(level, PMD, \
+		RTE_FMT(RTE_STR(HYPERV_DRIVER) ": " \
+			RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
+		RTE_FMT_TAIL(__VA_ARGS__,)))
+
+#endif /* RTE_LIBRTE_HYPERV_DEBUG */
+
+#define DEBUG(...) PMD_DRV_LOG(DEBUG, __VA_ARGS__)
+#define INFO(...) PMD_DRV_LOG(INFO, __VA_ARGS__)
+#define WARN(...) PMD_DRV_LOG(WARNING, __VA_ARGS__)
+#define ERROR(...) PMD_DRV_LOG(ERR, __VA_ARGS__)
+
+/** Number of PMD instances relying on context list. */
+static unsigned int hyperv_ctx_inst;
+
+/**
+ * Probe NetVSC interfaces.
+ *
+ * @param dev
+ *   Virtual device context for PMD instance.
+ *
+ * @return
+ *    Always 0, even in case of errors.
+ */
+static int
+hyperv_vdev_probe(struct rte_vdev_device *dev)
+{
+	static const char *const hyperv_arg[] = {
+		HYPERV_ARG_IFACE,
+		HYPERV_ARG_MAC,
+		NULL,
+	};
+	const char *name = rte_vdev_device_name(dev);
+	const char *args = rte_vdev_device_args(dev);
+	struct rte_kvargs *kvargs = rte_kvargs_parse(args ? args : "",
+						     hyperv_arg);
+
+	DEBUG("invoked as \"%s\", using arguments \"%s\"", name, args);
+	if (!kvargs) {
+		ERROR("cannot parse arguments list");
+		goto error;
+	}
+error:
+	if (kvargs)
+		rte_kvargs_free(kvargs);
+	++hyperv_ctx_inst;
+	return 0;
+}
+
+/**
+ * Remove PMD instance.
+ *
+ * @param dev
+ *   Virtual device context for PMD instance.
+ *
+ * @return
+ *   Always 0.
+ */
+static int
+hyperv_vdev_remove(struct rte_vdev_device *dev)
+{
+	(void)dev;
+	--hyperv_ctx_inst;
+	return 0;
+}
+
+/** Virtual device descriptor. */
+static struct rte_vdev_driver hyperv_vdev = {
+	.probe = hyperv_vdev_probe,
+	.remove = hyperv_vdev_remove,
+};
+
+RTE_PMD_REGISTER_VDEV(HYPERV_DRIVER, hyperv_vdev);
+RTE_PMD_REGISTER_ALIAS(HYPERV_DRIVER, eth_hyperv);
+RTE_PMD_REGISTER_PARAM_STRING(net_hyperv,
+			      HYPERV_ARG_IFACE "=<string> "
+			      HYPERV_ARG_MAC "=<string>");
diff --git a/drivers/net/hyperv/rte_pmd_hyperv_version.map b/drivers/net/hyperv/rte_pmd_hyperv_version.map
new file mode 100644
index 000000000..179140fb8
--- /dev/null
+++ b/drivers/net/hyperv/rte_pmd_hyperv_version.map
@@ -0,0 +1,4 @@
+DPDK_18.02 {
+
+	local: *;
+};
diff --git a/mk/rte.app.mk b/mk/rte.app.mk
index 6a6a7452e..b0701c49f 100644
--- a/mk/rte.app.mk
+++ b/mk/rte.app.mk
@@ -134,6 +134,7 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_E1000_PMD)      += -lrte_pmd_e1000
 _LDLIBS-$(CONFIG_RTE_LIBRTE_ENA_PMD)        += -lrte_pmd_ena
 _LDLIBS-$(CONFIG_RTE_LIBRTE_ENIC_PMD)       += -lrte_pmd_enic
 _LDLIBS-$(CONFIG_RTE_LIBRTE_FM10K_PMD)      += -lrte_pmd_fm10k
+_LDLIBS-$(CONFIG_RTE_LIBRTE_HYPERV_PMD)     += -lrte_pmd_hyperv
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_FAILSAFE)   += -lrte_pmd_failsafe
 _LDLIBS-$(CONFIG_RTE_LIBRTE_I40E_PMD)       += -lrte_pmd_i40e
 _LDLIBS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD)      += -lrte_pmd_ixgbe
-- 
2.11.0


More information about the dev mailing list