net/vdev_netvsc: introduce Hyper-V platform driver
authorMatan Azrad <matan@mellanox.com>
Thu, 18 Jan 2018 13:51:42 +0000 (13:51 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Sun, 21 Jan 2018 14:51:52 +0000 (15:51 +0100)
This patch lays the groundwork for this driver (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@6wind.com>
Signed-off-by: Matan Azrad <matan@mellanox.com>
MAINTAINERS
config/common_base
config/common_linuxapp
doc/guides/nics/features/vdev_netvsc.ini [new file with mode: 0644]
doc/guides/nics/index.rst
doc/guides/nics/vdev_netvsc.rst [new file with mode: 0644]
drivers/net/Makefile
drivers/net/vdev_netvsc/Makefile [new file with mode: 0644]
drivers/net/vdev_netvsc/rte_pmd_vdev_netvsc_version.map [new file with mode: 0644]
drivers/net/vdev_netvsc/vdev_netvsc.c [new file with mode: 0644]
mk/rte.app.mk

index 88f3c28e20f152fbd665c23dd2f727b7a00b5a76..5788ea004caa937cf9c73a1eced7f0872c12a32f 100644 (file)
@@ -473,6 +473,12 @@ F: drivers/net/mrvl/
 F: doc/guides/nics/mrvl.rst
 F: doc/guides/nics/features/mrvl.ini
 
+Microsoft vdev_netvsc - EXPERIMENTAL
+M: Matan Azrad <matan@mellanox.com>
+F: drivers/net/vdev_netvsc/
+F: doc/guides/nics/vdev_netvsc.rst
+F: doc/guides/nics/features/vdev_netvsc.ini
+
 Netcope szedata2
 M: Matej Vido <vido@cesnet.cz>
 F: drivers/net/szedata2/
index 396ae3a57cf331b9c71d02be7a51e60eb6ae4d76..4abddced80cd6828db9d5c6b29b0efbd36215862 100644 (file)
@@ -278,6 +278,11 @@ CONFIG_RTE_LIBRTE_NFP_DEBUG_RX=n
 #
 CONFIG_RTE_LIBRTE_MRVL_PMD=n
 
+#
+# Compile virtual device driver for NetVSC on Hyper-V/Azure
+#
+CONFIG_RTE_LIBRTE_VDEV_NETVSC_PMD=n
+
 #
 # Compile burst-oriented Broadcom BNXT PMD driver
 #
index 15c69616846b2f4f1fb5919f4c1c88866b50df3c..425730d18f8f819faf47b0851b3f594963be79a4 100644 (file)
@@ -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_VDEV_NETVSC_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/vdev_netvsc.ini b/doc/guides/nics/features/vdev_netvsc.ini
new file mode 100644 (file)
index 0000000..cfc5cb9
--- /dev/null
@@ -0,0 +1,12 @@
+;
+; Supported features of the 'vdev_netvsc' 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
index 23babe9339f0271957e499acd174405a28fe8c3c..5666046713dc756c254177ad566af38e016066e9 100644 (file)
@@ -64,6 +64,7 @@ Network Interface Controller Drivers
     szedata2
     tap
     thunderx
+    vdev_netvsc
     virtio
     vhost
     vmxnet3
diff --git a/doc/guides/nics/vdev_netvsc.rst b/doc/guides/nics/vdev_netvsc.rst
new file mode 100644 (file)
index 0000000..a952908
--- /dev/null
@@ -0,0 +1,20 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+    Copyright 2017 6WIND S.A.
+    Copyright 2017 Mellanox Technologies, Ltd.
+
+VDEV_NETVSC driver
+==================
+
+The VDEV_NETVSC driver (librte_pmd_vdev_netvsc) 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_VDEV_NETVSC_PMD`` (default ``y``)
+
+   Toggle compilation of this driver.
index c2fd7f59030f88501dc6c140b147a1e19910eef6..e1127326b5a622ace453d45958b43fa74e5a4614 100644 (file)
@@ -39,6 +39,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_SZEDATA2) += szedata2
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_TAP) += tap
 DIRS-$(CONFIG_RTE_LIBRTE_THUNDERX_NICVF_PMD) += thunderx
+DIRS-$(CONFIG_RTE_LIBRTE_VDEV_NETVSC_PMD) += vdev_netvsc
 DIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio
 DIRS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += vmxnet3
 
diff --git a/drivers/net/vdev_netvsc/Makefile b/drivers/net/vdev_netvsc/Makefile
new file mode 100644 (file)
index 0000000..2fb059d
--- /dev/null
@@ -0,0 +1,27 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright 2017 6WIND S.A.
+# Copyright 2017 Mellanox Technologies, Ltd.
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+# Properties of the generated library.
+LIB = librte_pmd_vdev_netvsc.a
+LIBABIVER := 1
+EXPORT_MAP := rte_pmd_vdev_netvsc_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_VDEV_NETVSC_PMD) += vdev_netvsc.c
+
+include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/drivers/net/vdev_netvsc/rte_pmd_vdev_netvsc_version.map b/drivers/net/vdev_netvsc/rte_pmd_vdev_netvsc_version.map
new file mode 100644 (file)
index 0000000..179140f
--- /dev/null
@@ -0,0 +1,4 @@
+DPDK_18.02 {
+
+       local: *;
+};
diff --git a/drivers/net/vdev_netvsc/vdev_netvsc.c b/drivers/net/vdev_netvsc/vdev_netvsc.c
new file mode 100644 (file)
index 0000000..e895b32
--- /dev/null
@@ -0,0 +1,99 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2017 6WIND S.A.
+ * Copyright 2017 Mellanox Technologies, Ltd.
+ */
+
+#include <stddef.h>
+
+#include <rte_bus_vdev.h>
+#include <rte_common.h>
+#include <rte_config.h>
+#include <rte_kvargs.h>
+#include <rte_log.h>
+
+#define VDEV_NETVSC_DRIVER net_vdev_netvsc
+#define VDEV_NETVSC_ARG_IFACE "iface"
+#define VDEV_NETVSC_ARG_MAC "mac"
+
+#define DRV_LOG(level, ...) \
+       rte_log(RTE_LOG_ ## level, \
+               vdev_netvsc_logtype, \
+               RTE_FMT(RTE_STR(VDEV_NETVSC_DRIVER) ": " \
+                       RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
+               RTE_FMT_TAIL(__VA_ARGS__,)))
+
+/** Driver-specific log messages type. */
+static int vdev_netvsc_logtype;
+
+/** Number of driver instances relying on context list. */
+static unsigned int vdev_netvsc_ctx_inst;
+
+/**
+ * Probe NetVSC interfaces.
+ *
+ * @param dev
+ *   Virtual device context for driver instance.
+ *
+ * @return
+ *    Always 0, even in case of errors.
+ */
+static int
+vdev_netvsc_vdev_probe(struct rte_vdev_device *dev)
+{
+       static const char *const vdev_netvsc_arg[] = {
+               VDEV_NETVSC_ARG_IFACE,
+               VDEV_NETVSC_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 : "",
+                                                    vdev_netvsc_arg);
+
+       DRV_LOG(DEBUG, "invoked as \"%s\", using arguments \"%s\"", name, args);
+       if (!kvargs) {
+               DRV_LOG(ERR, "cannot parse arguments list");
+               goto error;
+       }
+error:
+       if (kvargs)
+               rte_kvargs_free(kvargs);
+       ++vdev_netvsc_ctx_inst;
+       return 0;
+}
+
+/**
+ * Remove driver instance.
+ *
+ * @param dev
+ *   Virtual device context for driver instance.
+ *
+ * @return
+ *   Always 0.
+ */
+static int
+vdev_netvsc_vdev_remove(__rte_unused struct rte_vdev_device *dev)
+{
+       --vdev_netvsc_ctx_inst;
+       return 0;
+}
+
+/** Virtual device descriptor. */
+static struct rte_vdev_driver vdev_netvsc_vdev = {
+       .probe = vdev_netvsc_vdev_probe,
+       .remove = vdev_netvsc_vdev_remove,
+};
+
+RTE_PMD_REGISTER_VDEV(VDEV_NETVSC_DRIVER, vdev_netvsc_vdev);
+RTE_PMD_REGISTER_ALIAS(VDEV_NETVSC_DRIVER, eth_vdev_netvsc);
+RTE_PMD_REGISTER_PARAM_STRING(net_vdev_netvsc,
+                             VDEV_NETVSC_ARG_IFACE "=<string> "
+                             VDEV_NETVSC_ARG_MAC "=<string>");
+
+/** Initialize driver log type. */
+RTE_INIT(vdev_netvsc_init_log)
+{
+       vdev_netvsc_logtype = rte_log_register("pmd.vdev_netvsc");
+       if (vdev_netvsc_logtype >= 0)
+               rte_log_set_level(vdev_netvsc_logtype, RTE_LOG_NOTICE);
+}
index 270bbeca4b81ee709a5bdc1bc6a2d4de24a9f61c..0169f3f5b95e65dd3dda4fcaea1b4b5f8848eb19 100644 (file)
@@ -158,6 +158,7 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD)    += -lrte_pmd_sfc_efx
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SZEDATA2)   += -lrte_pmd_szedata2 -lsze2
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_TAP)        += -lrte_pmd_tap
 _LDLIBS-$(CONFIG_RTE_LIBRTE_THUNDERX_NICVF_PMD) += -lrte_pmd_thunderx_nicvf
+_LDLIBS-$(CONFIG_RTE_LIBRTE_VDEV_NETVSC_PMD) += -lrte_pmd_vdev_netvsc
 _LDLIBS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD)     += -lrte_pmd_virtio
 ifeq ($(CONFIG_RTE_LIBRTE_VHOST),y)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_VHOST)      += -lrte_pmd_vhost