Introduce net bus
cover Introduce net bus
This new bus takes as devices kernel netdevices.
It offers an API for drivers to register a translation layer that would transform the netdev name to one their regular PMD would be able to probe.
This is PoC. It currently only works for MLX4 and MLX5 PMDs as they were bifurcated and had very little work to do otherwise.
The planned feature is for at least all PCI drivers, be able to unbind the device from its kmod and bind it to a choosen IO module, prior to probing.
Additional possible feature would be a close integration with eventually NCI-like lib, to transparently capture kernel devices, keep a control interface present and bind / unbind the underlying hardware function as necessary.
This bus depends on plug / unplug being implemented for the sub-bus (here, PCI or vdev). If new buses wants to be able to capture kernel netdevices this way, they should implement plug / unplug.
This patchset depends on:
[PATCH 0/8] bus/pci: remove PCI bus from EAL
http://dpdk.org/dev/patchwork/patch/24972/
http://dpdk.org/ml/archives/dev/2017-June/067061.html
Gaetan Rivet (3):
bus/net: introduce net bus
net/mlx4: net bus support
net/mlx5: net bus support
MAINTAINERS | 6 + config/common_linuxapp | 2 + drivers/bus/Makefile | 2 + drivers/bus/net/Makefile | 66 +++++++ drivers/bus/net/bsd/Makefile | 33 ++++ drivers/bus/net/include/rte_bus_net.h | 145 ++++++++++++++++ drivers/bus/net/linux/Makefile | 35 ++++ drivers/bus/net/linux/rte_bus_net.c | 237 ++++++++++++++++++++++++++ drivers/bus/net/linux/rte_bus_net_version.map | 5 + drivers/bus/net/private.h | 143 ++++++++++++++++ drivers/bus/net/rte_bus_net.c | 210 +++++++++++++++++++++++ drivers/net/mlx4/mlx4.c | 10 ++ drivers/net/mlx5/mlx5.c | 10 ++ mk/rte.app.mk | 1 + 14 files changed, 905 insertions(+) create mode 100644 drivers/bus/net/Makefile create mode 100644 drivers/bus/net/bsd/Makefile create mode 100644 drivers/bus/net/include/rte_bus_net.h create mode 100644 drivers/bus/net/linux/Makefile create mode 100644 drivers/bus/net/linux/rte_bus_net.c create mode 100644 drivers/bus/net/linux/rte_bus_net_version.map create mode 100644 drivers/bus/net/private.h create mode 100644 drivers/bus/net/rte_bus_net.c
Signature · 1 line
2.1.4
PATCH 1/3 bus/net: introduce net bus
--- MAINTAINERS | 6 + config/common_linuxapp | 2 + drivers/bus/Makefile | 2 + drivers/bus/net/Makefile | 66 +++++++ drivers/bus/net/bsd/Makefile | 33 ++++ drivers/bus/net/include/rte_bus_net.h | 145 ++++++++++++++++ drivers/bus/net/linux/Makefile | 35 ++++ drivers/bus/net/linux/rte_bus_net.c | 237 ++++++++++++++++++++++++++ drivers/bus/net/linux/rte_bus_net_version.map | 5 + drivers/bus/net/private.h | 143 ++++++++++++++++ drivers/bus/net/rte_bus_net.c | 210 +++++++++++++++++++++++ mk/rte.app.mk | 1 + 12 files changed, 885 insertions(+) create mode 100644 drivers/bus/net/Makefile create mode 100644 drivers/bus/net/bsd/Makefile create mode 100644 drivers/bus/net/include/rte_bus_net.h create mode 100644 drivers/bus/net/linux/Makefile create mode 100644 drivers/bus/net/linux/rte_bus_net.c create mode 100644 drivers/bus/net/linux/rte_bus_net_version.map create mode 100644 drivers/bus/net/private.h create mode 100644 drivers/bus/net/rte_bus_net.c
MAINTAINERS +6 -0
@@ -253,6 +253,12 @@ F: lib/librte_eventdev/ F: drivers/event/skeleton/ F: test/test/test_eventdev.c +Bus Drivers +----------- + +Net +M: Gaetan Rivet <[email protected]> +F: drivers/bus/net/ Networking Drivers ------------------
config/common_linuxapp +2 -0
@@ -48,3 +48,5 @@ CONFIG_RTE_LIBRTE_AVP_PMD=y CONFIG_RTE_LIBRTE_NFP_PMD=y CONFIG_RTE_LIBRTE_POWER=y CONFIG_RTE_VIRTIO_USER=y +CONFIG_RTE_LIBRTE_NET_BUS=y +CONFIG_RTE_LIBRTE_NET_BUS_DEBUG=n
drivers/bus/Makefile +2 -0
@@ -37,5 +37,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_FSLMC_BUS) += fslmc DEPDIRS-fslmc = $(core-libs) DIRS-$(CONFIG_RTE_LIBRTE_PCI_BUS) += pci DEPDIRS-pci = $(core-libs) +DIRS-$(CONFIG_RTE_LIBRTE_NET_BUS) += net +DEPDIRS-net = $(core-libs) pci include $(RTE_SDK)/mk/rte.subdir.mk
drivers/bus/net/Makefile new file +66 -0
66 lines not on this page · raw message
drivers/bus/net/bsd/Makefile new file +33 -0
@@ -0,0 +1,33 @@ +# BSD LICENSE +# +# Copyright(c) 2017 6WIND S.A. +# Author: Gaetan Rivet +# All rights reserved. +# +# 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 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. + +$(error Net BUS not supported on BSD yet)
drivers/bus/net/include/rte_bus_net.h new file +145 -0
145 lines not on this page · raw message
drivers/bus/net/linux/Makefile new file +35 -0
@@ -0,0 +1,35 @@ +# BSD LICENSE +# +# Copyright(c) 2017 6WIND S.A. +# Author: Gaetan Rivet +# All rights reserved. +# +# 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 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. + +SRCS += rte_bus_net.c + +CFLAGS += -D_GNU_SOURCE
drivers/bus/net/linux/rte_bus_net.c new file +237 -0
237 lines not on this page · raw message
drivers/bus/net/linux/rte_bus_net_version.map new file +5 -0
@@ -0,0 +1,5 @@ +DPDK_17.08 { + global: + + local: *; +};
drivers/bus/net/private.h new file +143 -0
143 lines not on this page · raw message
drivers/bus/net/rte_bus_net.c new file +210 -0
210 lines not on this page · raw message
mk/rte.app.mk +1 -0
@@ -104,6 +104,7 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_KNI) += -lrte_kni endif _LDLIBS-$(CONFIG_RTE_LIBRTE_PCI_BUS) += -lrte_bus_pci +_LDLIBS-$(CONFIG_RTE_LIBRTE_NET_BUS) += -lrte_bus_net ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),n) # plugins (link only if static libraries)
Signature · 1 line
2.1.4
PATCH 2/3 net/mlx4: net bus support
In reply to Gaetan Rivet--- drivers/net/mlx4/mlx4.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/net/mlx4/mlx4.c +10 -0
@@ -62,6 +62,7 @@#include <rte_ethdev.h> #include <rte_ethdev_pci.h> #include <rte_dev.h> +#include <rte_bus_net.h> #include <rte_mbuf.h> #include <rte_errno.h> #include <rte_mempool.h>
@@ -6097,3 +6098,12 @@ RTE_PMD_EXPORT_NAME(net_mlx4, __COUNTER__);RTE_PMD_REGISTER_PCI_TABLE (net_mlx4, mlx4_pci_id_map);RTE_PMD_REGISTER_KMOD_DEP (net_mlx4,"* ib_uverbs & mlx4_en & mlx4_core & mlx4_ib" ); + +static struct rte_net_driver mlx4_net_driver = { + RTE_BUS_NET_PCI_HEADER + .driver = { + .name =MLX4_DRIVER_NAME , + }, + .kmod ="mlx4_core" , +}; +RTE_PMD_REGISTER_NET (mlx4, mlx4_net_driver);
Signature · 1 line
2.1.4
PATCH 3/3 net/mlx5: net bus support
In reply to Gaetan Rivet--- drivers/net/mlx5/mlx5.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/net/mlx5/mlx5.c +10 -0
@@ -58,6 +58,7 @@#include <rte_ethdev.h> #include <rte_ethdev_pci.h> #include <rte_pci.h> +#include <rte_bus_net.h> #include <rte_common.h> #include <rte_kvargs.h> #ifdef PEDANTIC
@@ -898,3 +899,12 @@ rte_mlx5_pmd_init(void)RTE_PMD_EXPORT_NAME (net_mlx5, __COUNTER__);RTE_PMD_REGISTER_PCI_TABLE (net_mlx5, mlx5_pci_id_map);RTE_PMD_REGISTER_KMOD_DEP (net_mlx5,"* ib_uverbs & mlx5_core & mlx5_ib" ); + +static struct rte_net_driver mlx5_net_driver = { + RTE_BUS_NET_PCI_HEADER + .driver = { + .name =MLX5_DRIVER_NAME , + }, + .kmod ="mlx5_core" , +}; +RTE_PMD_REGISTER_NET (mlx5, mlx5_net_driver);
Signature · 1 line
2.1.4
v2 cover Introduce net bus
In reply to Gaetan RivetThis new bus takes as devices kernel netdevices.
It offers an API for drivers to register a translation layer that would transform the netdev name to one their regular PMD would be able to probe.
This is PoC. It currently only works for MLX4 and MLX5 PMDs as they were bifurcated and had very little work to do otherwise.
The planned feature is for at least all PCI drivers, be able to unbind the device from its kmod and bind it to a choosen IO module, prior to probing.
Additional possible feature would be a close integration with eventually NCI-like lib, to transparently capture kernel devices, keep a control interface present and bind / unbind the underlying hardware function as necessary.
This bus depends on plug / unplug being implemented for the sub-bus (here, PCI or vdev). If new buses wants to be able to capture kernel netdevices this way, they should implement plug / unplug.
This patchset depends on:
[PATCH 0/8] bus/pci: remove PCI bus from EAL
http://dpdk.org/dev/patchwork/patch/24972/
http://dpdk.org/ml/archives/dev/2017-June/067061.html
v1 --> v2:
* New xfrm callback type.
* System access helpers now exposed.
* Fixes a log of edge-cases.
* Better mlx4 support with phys port autodetect.
* Support new plug / unplug API.
* Fixes map files.
Gaetan Rivet (4):
bus/net: introduce net bus
bus/net: implement hotplug bus operations
net/mlx4: net bus support
net/mlx5: net bus support
MAINTAINERS | 6 + config/common_linuxapp | 2 + drivers/bus/Makefile | 2 + drivers/bus/net/Makefile | 66 ++++++ drivers/bus/net/bsd/Makefile | 33 +++ drivers/bus/net/bsd/rte_bus_net_version.map | 14 ++ drivers/bus/net/include/rte_bus_net.h | 205 ++++++++++++++++ drivers/bus/net/linux/Makefile | 35 +++ drivers/bus/net/linux/rte_bus_net.c | 225 ++++++++++++++++++ drivers/bus/net/linux/rte_bus_net_version.map | 14 ++ drivers/bus/net/private.h | 144 ++++++++++++ drivers/bus/net/rte_bus_net.c | 325 ++++++++++++++++++++++++++ drivers/net/mlx4/mlx4.c | 35 +++ drivers/net/mlx5/mlx5.c | 9 + mk/rte.app.mk | 1 + 15 files changed, 1116 insertions(+) create mode 100644 drivers/bus/net/Makefile create mode 100644 drivers/bus/net/bsd/Makefile create mode 100644 drivers/bus/net/bsd/rte_bus_net_version.map create mode 100644 drivers/bus/net/include/rte_bus_net.h create mode 100644 drivers/bus/net/linux/Makefile create mode 100644 drivers/bus/net/linux/rte_bus_net.c create mode 100644 drivers/bus/net/linux/rte_bus_net_version.map create mode 100644 drivers/bus/net/private.h create mode 100644 drivers/bus/net/rte_bus_net.c
Signature · 1 line
2.1.4
PATCH v2 1/4 bus/net: introduce net bus
--- MAINTAINERS | 6 + config/common_linuxapp | 2 + drivers/bus/Makefile | 2 + drivers/bus/net/Makefile | 66 +++++++ drivers/bus/net/bsd/Makefile | 33 ++++ drivers/bus/net/bsd/rte_bus_net_version.map | 14 ++ drivers/bus/net/include/rte_bus_net.h | 205 ++++++++++++++++++++ drivers/bus/net/linux/Makefile | 35 ++++ drivers/bus/net/linux/rte_bus_net.c | 225 ++++++++++++++++++++++ drivers/bus/net/linux/rte_bus_net_version.map | 14 ++ drivers/bus/net/private.h | 144 ++++++++++++++ drivers/bus/net/rte_bus_net.c | 265 ++++++++++++++++++++++++++ mk/rte.app.mk | 1 + 13 files changed, 1012 insertions(+) create mode 100644 drivers/bus/net/Makefile create mode 100644 drivers/bus/net/bsd/Makefile create mode 100644 drivers/bus/net/bsd/rte_bus_net_version.map create mode 100644 drivers/bus/net/include/rte_bus_net.h create mode 100644 drivers/bus/net/linux/Makefile create mode 100644 drivers/bus/net/linux/rte_bus_net.c create mode 100644 drivers/bus/net/linux/rte_bus_net_version.map create mode 100644 drivers/bus/net/private.h create mode 100644 drivers/bus/net/rte_bus_net.c
MAINTAINERS +6 -0
@@ -253,6 +253,12 @@ F: lib/librte_eventdev/ F: drivers/event/skeleton/ F: test/test/test_eventdev.c +Bus Drivers +----------- + +Net +M: Gaetan Rivet <[email protected]> +F: drivers/bus/net/ Networking Drivers ------------------
config/common_linuxapp +2 -0
@@ -48,3 +48,5 @@ CONFIG_RTE_LIBRTE_AVP_PMD=y CONFIG_RTE_LIBRTE_NFP_PMD=y CONFIG_RTE_LIBRTE_POWER=y CONFIG_RTE_VIRTIO_USER=y +CONFIG_RTE_LIBRTE_NET_BUS=y +CONFIG_RTE_LIBRTE_NET_BUS_DEBUG=n
drivers/bus/Makefile +2 -0
@@ -37,5 +37,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_FSLMC_BUS) += fslmc DEPDIRS-fslmc = $(core-libs) DIRS-$(CONFIG_RTE_LIBRTE_PCI_BUS) += pci DEPDIRS-pci = $(core-libs) +DIRS-$(CONFIG_RTE_LIBRTE_NET_BUS) += net +DEPDIRS-net = $(core-libs) pci include $(RTE_SDK)/mk/rte.subdir.mk
drivers/bus/net/Makefile new file +66 -0
66 lines not on this page · raw message
drivers/bus/net/bsd/Makefile new file +33 -0
@@ -0,0 +1,33 @@ +# BSD LICENSE +# +# Copyright(c) 2017 6WIND S.A. +# Author: Gaetan Rivet +# All rights reserved. +# +# 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 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. + +$(error Net BUS not supported on BSD yet)
drivers/bus/net/bsd/rte_bus_net_version.map new file +14 -0
@@ -0,0 +1,14 @@ +DPDK_17.08 { + global: + + rte_net_register; + rte_net_unregister; + rte_bus_net_dev_stat; + rte_bus_net_driver; + rte_bus_net_pci_loc; + rte_bus_net_virtual_xfrm; + rte_bus_net_pci_xfrm; + rte_bus_net_path_read; + + local: *; +};
drivers/bus/net/include/rte_bus_net.h new file +205 -0
205 lines not on this page · raw message
drivers/bus/net/linux/Makefile new file +35 -0
@@ -0,0 +1,35 @@ +# BSD LICENSE +# +# Copyright(c) 2017 6WIND S.A. +# Author: Gaetan Rivet +# All rights reserved. +# +# 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 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. + +SRCS += rte_bus_net.c + +CFLAGS += -D_GNU_SOURCE
drivers/bus/net/linux/rte_bus_net.c new file +225 -0
225 lines not on this page · raw message
drivers/bus/net/linux/rte_bus_net_version.map new file +14 -0
@@ -0,0 +1,14 @@ +DPDK_17.08 { + global: + + rte_net_register; + rte_net_unregister; + rte_bus_net_dev_stat; + rte_bus_net_driver; + rte_bus_net_pci_loc; + rte_bus_net_virtual_xfrm; + rte_bus_net_pci_xfrm; + rte_bus_net_path_read; + + local: *; +};
drivers/bus/net/private.h new file +144 -0
144 lines not on this page · raw message
drivers/bus/net/rte_bus_net.c new file +265 -0
265 lines not on this page · raw message
mk/rte.app.mk +1 -0
@@ -104,6 +104,7 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_KNI) += -lrte_kni endif _LDLIBS-$(CONFIG_RTE_LIBRTE_PCI_BUS) += -lrte_bus_pci +_LDLIBS-$(CONFIG_RTE_LIBRTE_NET_BUS) += -lrte_bus_net ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),n) # plugins (link only if static libraries)
Signature · 1 line
2.1.4
PATCH v2 2/4 bus/net: implement hotplug bus operations
In reply to Gaetan Rivet--- drivers/bus/net/rte_bus_net.c | 60 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+)
drivers/bus/net/rte_bus_net.c +60 -0
@@ -253,11 +253,71 @@ rte_bus_net_pci_xfrm(const struct rte_devargs *src,return ret <0 || ret > (int )sizeof (dst->name) || dst->args ==NULL ; } +static struct rte_device * +net_plug (struct rte_devargs *da) +{ +struct rte_net_device *dev; + + dev =net_scan_one (da->name); +if (dev ==NULL ) { + rte_errno =EFAULT ; +return NULL ; + } +if (net_probe_one (dev)) { + rte_errno =ENODEV ; +return NULL ; + } +return dev->sh_dev; +} + +static int +net_unplug (struct rte_device *dev) +{ +struct rte_net_device *ndev; +void *tmp; +int ret; +int err; + + FOREACH_NET_DEVICE_SAFE(ndev, tmp) { +struct rte_device *rdev; +struct rte_devargs *da; +struct rte_devargs *sub; + +if (dev != &ndev->device && + dev != ndev->sh_dev) +continue ; + rdev = ndev->sh_dev; +if (rdev ==NULL ) +continue ; + da = ndev->device.devargs; + sub = rdev->devargs; + ret = sub->bus->unplug (rdev); +if (ret) { + err = rte_errno; +ERROR ("unplug failed" ); + rte_errno = err; +return ret; + } +free (sub); +rte_eal_devargs_rmv (da); +REMOVE_NET_DEVICE (ndev); +free (ndev); +break ; + } +if (ndev ==NULL ) { +ERROR ("no such device" ); +return -ENODEV ; + } +return 0 ; +} +struct rte_bus rte_bus_net = { .scan = net_scan, .probe = net_probe, .find_device = net_find_device, .parse = net_parse, + .plug = net_plug, + .unplug = net_unplug, .conf = { .scan_mode =RTE_BUS_SCAN_UNDEFINED , },
Signature · 1 line
2.1.4
PATCH v2 3/4 net/mlx4: net bus support
In reply to Gaetan Rivet--- drivers/net/mlx4/mlx4.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
drivers/net/mlx4/mlx4.c +35 -0
@@ -62,6 +62,7 @@#include <rte_ethdev.h> #include <rte_ethdev_pci.h> #include <rte_dev.h> +#include <rte_bus_net.h> #include <rte_mbuf.h> #include <rte_errno.h> #include <rte_mempool.h>
@@ -6302,3 +6303,37 @@ RTE_PMD_EXPORT_NAME(net_mlx4, __COUNTER__);RTE_PMD_REGISTER_PCI_TABLE (net_mlx4, mlx4_pci_id_map);RTE_PMD_REGISTER_KMOD_DEP (net_mlx4,"* ib_uverbs & mlx4_en & mlx4_core & mlx4_ib" ); + +static int +mlx4_net_pci_xfrm (const struct rte_devargs *src, +struct rte_devargs *dst) +{ +char buf[32 ] ="" ; +size_t arglen; +int ret; + + ret =rte_bus_net_pci_loc (src->name, buf,sizeof (buf)); +if (ret) +return ret; +snprintf (dst->name,sizeof (dst->name),"%s" , buf); +memset (buf,0 ,sizeof (buf)); + ret =rte_bus_net_path_read (buf,sizeof (buf), +"/sys/class/net/%s/dev_port" , src->name); +if (ret) +return ret; + arglen =snprintf (NULL ,0 ,"port=%s,%s" , buf, src->args) +1 ; + dst->args =calloc (1 , arglen); +if (dst->args ==NULL ) +return -ENOMEM ; +snprintf (dst->args, arglen,"port=%s,%s" , buf, src->args); +return 0 ; +} + +static struct rte_net_driver mlx4_net_driver = { + .driver = { + .name =MLX4_DRIVER_NAME , + }, + .kmod ="mlx4_core" , + .xfrm = mlx4_net_pci_xfrm, +}; +RTE_PMD_REGISTER_NET (mlx4, mlx4_net_driver);
Signature · 1 line
2.1.4
PATCH v2 4/4 net/mlx5: net bus support
In reply to Gaetan Rivet--- drivers/net/mlx5/mlx5.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/net/mlx5/mlx5.c +9 -0
@@ -58,6 +58,7 @@#include <rte_ethdev.h> #include <rte_ethdev_pci.h> #include <rte_pci.h> +#include <rte_bus_net.h> #include <rte_common.h> #include <rte_kvargs.h> #ifdef PEDANTIC
@@ -899,3 +900,11 @@ rte_mlx5_pmd_init(void)RTE_PMD_EXPORT_NAME (net_mlx5, __COUNTER__);RTE_PMD_REGISTER_PCI_TABLE (net_mlx5, mlx5_pci_id_map);RTE_PMD_REGISTER_KMOD_DEP (net_mlx5,"* ib_uverbs & mlx5_core & mlx5_ib" ); + +static struct rte_net_driver mlx5_net_driver = { + .driver = { + .name =MLX5_DRIVER_NAME , + }, + .kmod ="mlx5_core" , +}; +RTE_PMD_REGISTER_NET (mlx5, mlx5_net_driver);
Signature · 1 line
2.1.4
08/06/2017 02:00, Gaetan Rivet:
Quoted 8 lines
This new bus takes as devices kernel netdevices.
It offers an API for drivers to register a translation layer that would transform the netdev name to one their regular PMD would be able to probe.This is PoC. It currently only works for MLX4 and MLX5 PMDs as they were bifurcated and had very little work to do otherwise.
Quoted 8 lines
The planned feature is for at least all PCI drivers, be able to unbind the device from its kmod and bind it to a choosen IO module, prior to probing.
Additional possible feature would be a close integration with eventually NCI-like lib, to transparently capture kernel devices, keep a control interface present and bind / unbind the underlying hardware function as necessary.
I'm sorry, I do not understand the description.
Please start with a real problem statement and explain how it is solved. Thanks
Hi Thomas,
Quoted 3 lines · Thomas Monjalon
I'm sorry, I do not understand the description.
Please start with a real problem statement and explain how it is solved. Thanks
Sure.
Currently, we probe devices by using
./usertools/dpkd-devbind.py -b igb_uio 00:02.0
./build/app/whatever -w 00:02.0./usertools/dpkd-devbind.py -b ixgbe 00:02.0
Wouldn't it be nice to be able to:
./build/app/whatever -w ens2
Instead?
Many things are missing for this. This PoC only shows the simplest case with a bifurcated driver, but the concept is there.
This bus is an intepretation layer to transform a kernel netdevice name into a usable DPDK device, which should give enough info about its
dependencies: bus, IO module, resource management policies, etc... to prepare it.
I plan to add binding / unbinding afterward, and I wanted to propose this early enough as there were talks of kernel control plane, and this could be a building block to this general direction.
Auto-unbind assumes a clean exit from the DPDK application. This might be a big departure from current assumptions, where buses very seldom plan for ending operations. i.e. rte_bus has scan and probe, but no remove API. While unplug should soon exist, this is a crude workaround.
Signature · 2 lines
Gaëtan Rivet 6WIND