From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by dpdk.org (Postfix) with ESMTP id 7818829CF for ; Mon, 18 Dec 2017 17:46:34 +0100 (CET) Received: by mail-wm0-f66.google.com with SMTP id g75so30391020wme.0 for ; Mon, 18 Dec 2017 08:46:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=XndR4sW/Z2pxOteRcUgDNpk58SjZWbpqZ5NFXH6RHiE=; b=HbPzW23PGsTnDhe17Wys0oTtuEZVtHiVYjDnGY0umym5lLf4A1pZExi2J1kkGAUnoX 5xv+AUD1y0qxZQmAOrIU5TZRl8PYEX2w7wsspziMgKqkS56wbpJ02OMIYnM2yoRg3SYX 4korN0NZPLJeI23p6qkx+EmGTh9HVnt4HRdYldV612HQdY5cuTah6YG3h0RyTg758tiO aTPy18X4Kl+kaI5a8nARIvInVN9cAxcWluKmccq/K/Z0OHQvgD3Y+NqNnTKHJI/JNufJ wg91C0n87+0obA2uYGEM4lRb/yiueSXdBmYQTfX5iJb6cqGLFHLqtGKih62oQI60+u5B sx8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=XndR4sW/Z2pxOteRcUgDNpk58SjZWbpqZ5NFXH6RHiE=; b=UhNePjzCPWZPMJuGmEEYcEcfj2ngtNrYSTWlgTvfbFq/W3yQaJZWu2xaF4deLPsBeB WnHZuJKAVtt36Sx/uUudYnkZb/+OYtSwezQrEEmpgKhqawqf4KZv/aVVxDt5ymze/GCy fun5al7RXoZI9hW8crinV7KVeQORwOctGhA07BGkvIkRECk/OwsYLFsoS+Pr9H80JUxL ryXq2bxg7rFxKmf37QSu/ON8nimervOEgjoHZqhQLqSnpwtigjMrp2wajqrB0aksnGPY zZNKRaAgpkZAHZ1JZw9k125J3gXjjVOWtUqDzen5hlfPLn8CxigUzWLJ5Bocba92qkc5 Cv3g== X-Gm-Message-State: AKGB3mIJmZ7Wc+B++IAQq415baSjov41VHA+DNOZrNqqI1fkYjKviomZ 0VuL1xq03VSiiU1pDwbm1C0Zng== X-Google-Smtp-Source: ACJfBovIDMZG5+YQ0WvN6sUQzW0rbVkJnlCc+x8/+5j9dXPxAWU43BJWu63ie9CayketCvCwxE3a9w== X-Received: by 10.28.181.209 with SMTP id e200mr328839wmf.68.1513615593975; Mon, 18 Dec 2017 08:46:33 -0800 (PST) Received: from 6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id u79sm7281851wma.26.2017.12.18.08.46.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Dec 2017 08:46:33 -0800 (PST) Date: Mon, 18 Dec 2017 17:46:21 +0100 From: Adrien Mazarguil To: Ferruh Yigit Cc: dev@dpdk.org, Stephen Hemminger Message-ID: <20171218162443.12971-2-adrien.mazarguil@6wind.com> References: <20171124172132.GW4062@6wind.com> <20171218162443.12971-1-adrien.mazarguil@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171218162443.12971-1-adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.11.0 Subject: [dpdk-dev] [PATCH v1 1/3] net/hyperv: introduce MS Hyper-V platform driver X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Dec 2017 16:46:35 -0000 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 --- 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 +F: drivers/net/hyperv/ +F: doc/guides/nics/hyperv.rst +F: doc/guides/nics/features/hyperv.ini + Netcope szedata2 M: Matej Vido 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 +#include + +#include +#include +#include +#include + +#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 "= " + HYPERV_ARG_MAC "="); 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