add ifcvf driver
cover add ifcvf driver
This patch set has dependency on http://dpdk.org/dev/patchwork/patch/35635/
(vhost: support selective datapath);
ifc VF is compatible with virtio vring operations, this driver implements vDPA driver ops which configures ifc VF to be a vhost data path accelerator.
ifcvf driver uses vdev as a control domain to manage ifc VFs that belong to it. It registers vDPA device ops to vhost lib to enable these VFs to be used as vhost data path accelerator.
Live migration feature is supported by ifc VF and this driver enables it based on vhost lib.
vDPA needs to create different containers for different devices, thus this patch set adds APIs in eal/vfio to support multiple container.
Junjie Chen (1):
eal/vfio: add support for multiple container
Xiao Wang (2):
bus/pci: expose sysfs parsing API
net/ifcvf: add ifcvf driver
config/common_base | 6 + config/common_linuxapp | 1 + drivers/bus/pci/linux/pci.c | 9 +- drivers/bus/pci/linux/pci_init.h | 8 + drivers/bus/pci/rte_bus_pci_version.map | 8 + drivers/net/Makefile | 1 + drivers/net/ifcvf/Makefile | 40 + drivers/net/ifcvf/base/ifcvf.c | 329 ++++++++ drivers/net/ifcvf/base/ifcvf.h | 156 ++++ drivers/net/ifcvf/base/ifcvf_osdep.h | 52 ++ drivers/net/ifcvf/ifcvf_ethdev.c | 1241 ++++++++++++++++++++++++++++++ drivers/net/ifcvf/rte_ifcvf_version.map | 4 + lib/librte_eal/bsdapp/eal/eal.c | 51 +- lib/librte_eal/common/include/rte_vfio.h | 117 ++- lib/librte_eal/linuxapp/eal/eal_vfio.c | 553 ++++++++++--- lib/librte_eal/linuxapp/eal/eal_vfio.h | 2 + lib/librte_eal/rte_eal_version.map | 7 + mk/rte.app.mk | 1 + 18 files changed, 2480 insertions(+), 106 deletions(-) create mode 100644 drivers/net/ifcvf/Makefile create mode 100644 drivers/net/ifcvf/base/ifcvf.c create mode 100644 drivers/net/ifcvf/base/ifcvf.h create mode 100644 drivers/net/ifcvf/base/ifcvf_osdep.h create mode 100644 drivers/net/ifcvf/ifcvf_ethdev.c create mode 100644 drivers/net/ifcvf/rte_ifcvf_version.map
Signature · 1 line
2.15.1
PATCH 1/3 eal/vfio: add support for multiple container
From: Junjie Chen <[email protected]>
Currently eal vfio framework binds vfio group fd to the default container fd, while in some cases, e.g. vDPA (vhost data path acceleration), we want to set vfio group to a new container and program DMA mapping via this new container, so this patch adds APIs to support multiple container.
--- lib/librte_eal/bsdapp/eal/eal.c | 51 ++- lib/librte_eal/common/include/rte_vfio.h | 117 ++++++- lib/librte_eal/linuxapp/eal/eal_vfio.c | 553 ++++++++++++++++++++++++++----- lib/librte_eal/linuxapp/eal/eal_vfio.h | 2 + lib/librte_eal/rte_eal_version.map | 7 + 5 files changed, 629 insertions(+), 101 deletions(-)
lib/librte_eal/bsdapp/eal/eal.c +42 -9
@@ -38,6 +38,7 @@#include <rte_interrupts.h> #include <rte_bus.h> #include <rte_dev.h> +#include <rte_vfio.h> #include <rte_devargs.h> #include <rte_version.h> #include <rte_atomic.h>
@@ -738,15 +739,6 @@ rte_eal_vfio_intr_mode(void)/* dummy forward declaration. */ struct vfio_device_info ; -/* dummy prototypes. */ -int rte_vfio_setup_device (const char *sysfs_base,const char *dev_addr, -int *vfio_dev_fd,struct vfio_device_info *device_info); -int rte_vfio_release_device (const char *sysfs_base,const char *dev_addr,int fd); -int rte_vfio_enable (const char *modname); -int rte_vfio_is_enabled (const char *modname); -int rte_vfio_noiommu_is_enabled (void ); -int rte_vfio_clear_group (int vfio_group_fd); - int rte_vfio_setup_device(__rte_unused const char *sysfs_base, __rte_unused const char *dev_addr, __rte_unused int *vfio_dev_fd,
@@ -781,3 +773,44 @@ int rte_vfio_clear_group(__rte_unused int vfio_group_fd) {return 0 ; } + +int rte_vfio_create_container (void ) +{ +return -1 ; +} + +int rte_vfio_destroy_container(__rte_unused int container_fd) +{ +return -1 ; +} + +int rte_vfio_bind_group_no(__rte_unused int container_fd, + __rte_unused int iommu_group_no) +{ +return -1 ; +} + +int rte_vfio_unbind_group_no(__rte_unused int container_fd, + __rte_unused int iommu_group_no) +{ +return -1 ; +} + +int rte_vfio_dma_map(__rte_unused int container_fd, + __rte_unused int dma_type, + __rte_unused const struct rte_memseg *ms) +{ +return -1 ; +} + +int rte_vfio_dma_unmap(__rte_unused int container_fd, + __rte_unused int dma_type, + __rte_unused const struct rte_memseg *ms) +{ +return -1 ; +} + +int rte_vfio_get_group_fd(__rte_unused int iommu_group_no) +{ +return -1 ; +}
lib/librte_eal/common/include/rte_vfio.h +116 -1
122 lines not on this page · raw message
lib/librte_eal/linuxapp/eal/eal_vfio.c +462 -91
754 lines not on this page · raw message
lib/librte_eal/linuxapp/eal/eal_vfio.h +2 -0
@@ -157,6 +157,8 @@ int vfio_mp_sync_setup(void);#define SOCKET_NO_FD 0x1#define SOCKET_ERR 0xFF +#define VFIO_MAX_CONTAINERS 256 +#endif /* VFIO_PRESENT */ #endif /* EAL_VFIO_H_ */
lib/librte_eal/rte_eal_version.map +7 -0
@@ -254,5 +254,12 @@ EXPERIMENTAL { rte_service_set_runstate_mapped_check; rte_service_set_stats_enable; rte_service_start_with_defaults; + rte_vfio_create_container; + rte_vfio_destroy_container; + rte_vfio_bind_group_no; + rte_vfio_unbind_group_no; + rte_vfio_dma_map; + rte_vfio_dma_unmap; + rte_vfio_get_group_fd; } DPDK_18.02;
Signature · 1 line
2.15.1
PATCH 2/3 bus/pci: expose sysfs parsing API
In reply to Xiao WangSome existing sysfs parsing functions are helpful for the later vDPA driver, this patch make them global and expose them to shared lib.
--- drivers/bus/pci/linux/pci.c | 9 ++++----- drivers/bus/pci/linux/pci_init.h | 8 ++++++++ drivers/bus/pci/rte_bus_pci_version.map | 8 ++++++++ 3 files changed, 20 insertions(+), 5 deletions(-)
drivers/bus/pci/linux/pci.c +4 -5
@@ -32,7 +32,7 @@extern struct rte_pci_bus rte_pci_bus; -static int +int pci_get_kernel_driver_by_path (const char *filename,char *dri_name) {int count;
@@ -168,9 +168,8 @@ pci_parse_one_sysfs_resource(char *line, size_t len, uint64_t *phys_addr,return 0 ; } -/* parse the "resource" sysfs file */ -static int -pci_parse_sysfs_resource (const char *filename,struct rte_pci_device *dev) +int +rte_pci_parse_sysfs_resource (const char *filename,struct rte_pci_device *dev) {FILE *f;char buf[BUFSIZ ];
@@ -302,7 +301,7 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)/* parse resources */ snprintf (filename,sizeof (filename),"%s/resource" , dirname); -if (pci_parse_sysfs_resource (filename, dev) <0 ) { +if (rte_pci_parse_sysfs_resource (filename, dev) <0 ) {RTE_LOG (ERR ,EAL ,"%s(): cannot parse resource\n" , __func__);free (dev);return -1 ;
drivers/bus/pci/linux/pci_init.h +8 -0
@@ -83,6 +83,14 @@ int pci_vfio_unmap_resource(struct rte_pci_device *dev);int pci_vfio_is_enabled (void ); +/* parse sysfs file path */ +int +pci_get_kernel_driver_by_path (const char *filename,char *dri_name); + +/* parse the "resource" sysfs file */ +int +rte_pci_parse_sysfs_resource (const char *filename,struct rte_pci_device *dev); +#endif #endif /* EAL_PCI_INIT_H_ */
drivers/bus/pci/rte_bus_pci_version.map +8 -0
@@ -16,3 +16,11 @@ DPDK_17.11 { local: *; }; + +DPDK_18.05 { + global: + + pci_get_kernel_driver_by_path; + rte_pci_parse_sysfs_resource; + +} DPDK_17.11;
Signature · 1 line
2.15.1
PATCH 3/3 net/ifcvf: add ifcvf driver
In reply to Xiao Wangifcvf driver uses vdev as a control domain to manage ifc VFs that belong to it. It registers vDPA device ops to vhost lib to enable these VFs to be used as vhost data path accelerator.
Live migration feature is supported by ifc VF and this driver enables it based on vhost lib.
Because vDPA driver needs to set up MSI-X vector to interrupt the guest, only vfio-pci is supported currently.
--- config/common_base | 6 + config/common_linuxapp | 1 + drivers/net/Makefile | 1 + drivers/net/ifcvf/Makefile | 40 + drivers/net/ifcvf/base/ifcvf.c | 329 ++++++++ drivers/net/ifcvf/base/ifcvf.h | 156 ++++ drivers/net/ifcvf/base/ifcvf_osdep.h | 52 ++ drivers/net/ifcvf/ifcvf_ethdev.c | 1241 +++++++++++++++++++++++++++++++ drivers/net/ifcvf/rte_ifcvf_version.map | 4 + mk/rte.app.mk | 1 + 10 files changed, 1831 insertions(+) create mode 100644 drivers/net/ifcvf/Makefile create mode 100644 drivers/net/ifcvf/base/ifcvf.c create mode 100644 drivers/net/ifcvf/base/ifcvf.h create mode 100644 drivers/net/ifcvf/base/ifcvf_osdep.h create mode 100644 drivers/net/ifcvf/ifcvf_ethdev.c create mode 100644 drivers/net/ifcvf/rte_ifcvf_version.map
config/common_base +6 -0
@@ -791,6 +791,12 @@ CONFIG_RTE_LIBRTE_VHOST_DEBUG=n # CONFIG_RTE_LIBRTE_PMD_VHOST=n +# +# Compile IFCVF driver +# To compile, CONFIG_RTE_LIBRTE_VHOST should be enabled. +# +CONFIG_RTE_LIBRTE_IFCVF=n + # # Compile the test application #
config/common_linuxapp +1 -0
@@ -15,6 +15,7 @@ CONFIG_RTE_LIBRTE_PMD_KNI=y CONFIG_RTE_LIBRTE_VHOST=y CONFIG_RTE_LIBRTE_VHOST_NUMA=y CONFIG_RTE_LIBRTE_PMD_VHOST=y +CONFIG_RTE_LIBRTE_IFCVF=y CONFIG_RTE_LIBRTE_PMD_AF_PACKET=y CONFIG_RTE_LIBRTE_PMD_TAP=y CONFIG_RTE_LIBRTE_AVP_PMD=y
drivers/net/Makefile +1 -0
@@ -53,6 +53,7 @@ endif # $(CONFIG_RTE_LIBRTE_SCHED) ifeq ($(CONFIG_RTE_LIBRTE_VHOST),y) DIRS-$(CONFIG_RTE_LIBRTE_PMD_VHOST) += vhost +DIRS-$(CONFIG_RTE_LIBRTE_IFCVF) += ifcvf endif # $(CONFIG_RTE_LIBRTE_VHOST) ifeq ($(CONFIG_RTE_LIBRTE_MRVL_PMD),y)
drivers/net/ifcvf/Makefile new file +40 -0
@@ -0,0 +1,40 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2018 Intel Corporation + +include $(RTE_SDK)/mk/rte.vars.mk + +# +# library name +# +LIB = librte_ifcvf.a + +LDLIBS += -lpthread +LDLIBS += -lrte_eal -lrte_mempool -lrte_pci +LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs -lrte_vhost +LDLIBS += -lrte_bus_vdev -lrte_bus_pci + +CFLAGS += -O3 +CFLAGS += $(WERROR_FLAGS) +CFLAGS += -I$(RTE_SDK)/lib/librte_eal/linuxapp/eal +CFLAGS += -I$(RTE_SDK)/drivers/bus/pci/linux +CFLAGS += -DALLOW_EXPERIMENTAL_API + +# +# Add extra flags for base driver source files to disable warnings in them +# +BASE_DRIVER_OBJS=$(sort $(patsubst %.c,%.o,$(notdir $(wildcard $(SRCDIR)/base/*.c)))) +$(foreach obj, $(BASE_DRIVER_OBJS), $(eval CFLAGS_$(obj)+=$(CFLAGS_BASE_DRIVER))) + +VPATH += $(SRCDIR)/base + +EXPORT_MAP := rte_ifcvf_version.map + +LIBABIVER := 1 + +# +# all source are stored in SRCS-y +# +SRCS-$(CONFIG_RTE_LIBRTE_PMD_VHOST) += ifcvf_ethdev.c +SRCS-$(CONFIG_RTE_LIBRTE_PMD_VHOST) += ifcvf.c + +include $(RTE_SDK)/mk/rte.lib.mk
drivers/net/ifcvf/base/ifcvf.c new file +329 -0
329 lines not on this page · raw message
drivers/net/ifcvf/base/ifcvf.h new file +156 -0
156 lines not on this page · raw message
drivers/net/ifcvf/base/ifcvf_osdep.h new file +52 -0
52 lines not on this page · raw message
drivers/net/ifcvf/ifcvf_ethdev.c new file +1241 -0
1,241 lines not on this page · raw message
drivers/net/ifcvf/rte_ifcvf_version.map new file +4 -0
@@ -0,0 +1,4 @@ +EXPERIMENTAL { + + local: *; +};
mk/rte.app.mk +1 -0
@@ -171,6 +171,7 @@ _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 +_LDLIBS-$(CONFIG_RTE_LIBRTE_IFCVF) += -lrte_ifcvf endif # $(CONFIG_RTE_LIBRTE_VHOST) _LDLIBS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += -lrte_pmd_vmxnet3_uio
Signature · 1 line
2.15.1
Hi Xiao,
Quoted 10 lines · Xiao Wang
This patch set has dependency on http://dpdk.org/dev/patchwork/patch/35635/
(vhost: support selective datapath);ifc VF is compatible with virtio vring operations, this driver implements vDPA driver ops which configures ifc VF to be a vhost data path accelerator.
ifcvf driver uses vdev as a control domain to manage ifc VFs that belong to it. It registers vDPA device ops to vhost lib to enable these VFs to be used as vhost data path accelerator.
Quoted 5 lines
Live migration feature is supported by ifc VF and this driver enables it based on vhost lib.
vDPA needs to create different containers for different devices, thus this patch set adds APIs in eal/vfio to support multiple container.
Thanks for this! That will avoind having to duplicate these functions for every new offload driver.
Quoted 6 lines
Junjie Chen (1):
eal/vfio: add support for multiple containerXiao Wang (2):
bus/pci: expose sysfs parsing API
Still, I'm not convinced the offload device should be a virtual device. It is a real PCI device, why not having a new device type for offload devices, and let the device to be probed automatically by the existing device model?
Thanks,
Maxime
Quoted 28 lines
net/ifcvf: add ifcvf driver
config/common_base | 6 + config/common_linuxapp | 1 + drivers/bus/pci/linux/pci.c | 9 +- drivers/bus/pci/linux/pci_init.h | 8 + drivers/bus/pci/rte_bus_pci_version.map | 8 + drivers/net/Makefile | 1 + drivers/net/ifcvf/Makefile | 40 + drivers/net/ifcvf/base/ifcvf.c | 329 ++++++++ drivers/net/ifcvf/base/ifcvf.h | 156 ++++ drivers/net/ifcvf/base/ifcvf_osdep.h | 52 ++ drivers/net/ifcvf/ifcvf_ethdev.c | 1241 ++++++++++++++++++++++++++++++ drivers/net/ifcvf/rte_ifcvf_version.map | 4 + lib/librte_eal/bsdapp/eal/eal.c | 51 +- lib/librte_eal/common/include/rte_vfio.h | 117 ++- lib/librte_eal/linuxapp/eal/eal_vfio.c | 553 ++++++++++--- lib/librte_eal/linuxapp/eal/eal_vfio.h | 2 + lib/librte_eal/rte_eal_version.map | 7 + mk/rte.app.mk | 1 + 18 files changed, 2480 insertions(+), 106 deletions(-)create mode 100644
drivers/net/ifcvf/Makefilecreate mode 100644drivers/net/ifcvf/base/ifcvf.ccreate mode 100644drivers/net/ifcvf/base/ifcvf.hcreate mode 100644drivers/net/ifcvf/base/ifcvf_osdep.hcreate mode 100644drivers/net/ifcvf/ifcvf_ethdev.ccreate mode 100644drivers/net/ifcvf/rte_ifcvf_version.map
Re: [PATCH 2/3] bus/pci: expose sysfs parsing API
In reply to Xiao WangQuoted 15 lines · Xiao Wang
Some existing sysfs parsing functions are helpful for the later vDPA driver, this patch make them global and expose them to shared lib.
Signed-off-by Xiao Wang <[email protected]>--- drivers/bus/pci/linux/pci.c | 9 ++++----- drivers/bus/pci/linux/pci_init.h | 8 ++++++++ drivers/bus/pci/rte_bus_pci_version.map | 8 ++++++++ 3 files changed, 20 insertions(+), 5 deletions(-)drivers/bus/pci/linux/pci.c +0
-0
drivers/bus/pci/linux/pci.c line 36
Quoted 6 lines
drivers/bus/pci/linux/pci.c +1
-1@@ -32,7 +32,7 @@extern struct rte_pci_bus rte_pci_bus; -static int +int pci_get_kernel_driver_by_path (const char *filename,char *dri_name)
Here and in other places - shouldn't this too be prefixed with rte_?
Signature · 2 lines
Thanks, Anatoly
Re: [PATCH 1/3] eal/vfio: add support for multiple container
In reply to Xiao WangQuoted 11 lines · Xiao Wang
From: Junjie Chen <[email protected]>
Currently eal vfio framework binds vfio group fd to the default container fd, while in some cases, e.g. vDPA (vhost data path acceleration), we want to set vfio group to a new container and program DMA mapping via this new container, so this patch adds APIs to support multiple container.
Signed-off-by Junjie Chen <[email protected]>Signed-off-by Xiao Wang <[email protected]>---
I'm not going to get into virtual vs. real device debate, but i do have some issues with VFIO side of things.
I'm not completely convinced this change is needed in the first place. If the device driver manages its own groups anyway, it knows which VFIO groups belong to it, so it can add/remove them without putting them into separate containers. What is the purpose of keeping them in a separate container as opposed to just keeping track of group id's?
<...>
lib/librte_eal/linuxapp/eal/eal_vfio.c vfio_get_group_fd(int iommu_group_no) · line 219
Quoted 7 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +7
-0+ vfio_cfg->vfio_container_fd =vfio_get_container_fd (); + +if (vfio_cfg->vfio_container_fd <0 ) +return -1 ; + +return vfio_cfg->vfio_container_fd; +}
Please correct me if i'm wrong, but this patch appears to be mistitled. You're not really creating multiple containers, you're just partitioning existing one. Do we really need to open/store/close container fd's separately, if all we have is a single container anyway?
The semantics of this are also weird in multiprocess. When secondary process requests a container, we always create a new one, send it over IPC and close it afterwards. It seems to be oblivious that you may have several container fd's, and does not know which one you are asking for. We know it's all the same container, but that's clearly not what the code appears to be doing.
Signature · 2 lines
Thanks, Anatoly
Re: [PATCH 2/3] bus/pci: expose sysfs parsing API
In reply to Burakov, AnatolyHi,
Quoted 11 lines · Anatoly
Quoted 10 lines · Xiao Wang
Some existing sysfs parsing functions are helpful for the later vDPA driver, this patch make them global and expose them to shared lib.
Signed-off-by Xiao Wang <[email protected]>--- drivers/bus/pci/linux/pci.c | 9 ++++----- drivers/bus/pci/linux/pci_init.h | 8 ++++++++ drivers/bus/pci/rte_bus_pci_version.map | 8 ++++++++ 3 files changed, 20 insertions(+), 5 deletions(-)
Quoted 12 lines
drivers/bus/pci/linux/pci.c line 34
Quoted 9 lines
drivers/bus/pci/linux/pci.c +1
-1@@ -32,7 +32,7 @@extern struct rte_pci_bus rte_pci_bus; -static int +int pci_get_kernel_driver_by_path (const char *filename,char *dri_name)Here and in other places - shouldn't this too be prefixed with
rte_?
A public PCI function should be prefixed by rte_pci_ yes.
Additionally, if this function was to be exposed, then there should be a BSD implementation as well (shared map file).
I don't know how BSD works, I'm not sure parsing the filesystem is the way to get a PCI driver name. If so, maybe the function should be called another, generic, way, that would work for both linux and BSD (and ideally, having a real BSD implementation).
Quoted 4 lines
Signature · 3 lines
-- Thanks, Anatoly
Signature · 2 lines
Gaëtan Rivet 6WIND
Hi Maxime,
Quoted 36 lines
-----Original Message-----
From: Maxime Coquelin [mailto:[email protected]]
Sent: Sunday, March 11, 2018 2:24 AM
To: Wang, Xiao W <[email protected]>; [email protected]
Cc: Wang, Zhihong <[email protected]>; [email protected]; Liang, Cunming <[email protected]>; Xu, Rosen <[email protected]>; Chen, Junjie J <[email protected]>; Daly, Dan <[email protected]>
Subject: Re: [PATCH 0/3] add ifcvf driverHi Xiao,
Quoted 1 line · Xiao Wang
This patch set has dependency on
http://dpdk.org/dev/patchwork/patch/35635/
Quoted 9 lines
(vhost: support selective datapath);
ifc VF is compatible with virtio vring operations, this driver implements vDPA driver ops which configures ifc VF to be a vhost data path accelerator.
ifcvf driver uses vdev as a control domain to manage ifc VFs that belong to it. It registers vDPA device ops to vhost lib to enable these VFs to be used as vhost data path accelerator.
Quoted 5 lines
Live migration feature is supported by ifc VF and this driver enables it based on vhost lib.
vDPA needs to create different containers for different devices, thus this patch set adds APIs in eal/vfio to support multiple container.
Thanks for this! That will avoind having to duplicate these functions for every new offload driver.
Quoted 4 lines
Junjie Chen (1):
eal/vfio: add support for multiple container
Quoted 7 lines
Quoted 2 lines
Xiao Wang (2):
bus/pci: expose sysfs parsing APIStill, I'm not convinced the offload device should be a virtual device. It is a real PCI device, why not having a new device type for offload devices, and let the device to be probed automatically by the existing device model?
IFC VFs are generated from SRIOV, with the PF driven by kernel driver. In DPDK we need to have something to represent PF, to register itself as a vDPA engine, so a virtual device is used for this purpose.
The VFs are used for vhost net offload, and we could implement exception traffic Rx/Tx function on the VFs in future via port-representor mechanism. So this patch keeps the device type as net.
BRs,
Xiao
Quoted 34 lines
Thanks,
MaximeQuoted 13 lines
net/ifcvf: add ifcvf driver
config/common_base | 6 + config/common_linuxapp | 1 + drivers/bus/pci/linux/pci.c | 9 +- drivers/bus/pci/linux/pci_init.h | 8 + drivers/bus/pci/rte_bus_pci_version.map | 8 + drivers/net/Makefile | 1 + drivers/net/ifcvf/Makefile | 40 + drivers/net/ifcvf/base/ifcvf.c | 329 ++++++++ drivers/net/ifcvf/base/ifcvf.h | 156 ++++ drivers/net/ifcvf/base/ifcvf_osdep.h | 52 ++ drivers/net/ifcvf/ifcvf_ethdev.c | 1241++++++++++++++++++++++++++++++
Quoted 15 lines
drivers/net/ifcvf/rte_ifcvf_version.map | 4 + lib/librte_eal/bsdapp/eal/eal.c | 51 +- lib/librte_eal/common/include/rte_vfio.h | 117 ++- lib/librte_eal/linuxapp/eal/eal_vfio.c | 553 ++++++++++--- lib/librte_eal/linuxapp/eal/eal_vfio.h | 2 + lib/librte_eal/rte_eal_version.map | 7 + mk/rte.app.mk | 1 + 18 files changed, 2480 insertions(+), 106 deletions(-)create mode 100644
drivers/net/ifcvf/Makefilecreate mode 100644drivers/net/ifcvf/base/ifcvf.ccreate mode 100644drivers/net/ifcvf/base/ifcvf.hcreate mode 100644drivers/net/ifcvf/base/ifcvf_osdep.hcreate mode 100644drivers/net/ifcvf/ifcvf_ethdev.ccreate mode 100644drivers/net/ifcvf/rte_ifcvf_version.map
Re: [PATCH 1/3] eal/vfio: add support for multiple container
In reply to Burakov, AnatolyHi Anatoly,
Quoted 24 lines
-----Original Message-----
From: Burakov, Anatoly
Sent: Wednesday, March 14, 2018 8:08 PM
To: Wang, Xiao W <[email protected]>; [email protected]
Cc: Wang, Zhihong <[email protected]>; [email protected]; [email protected]; Liang, Cunming <[email protected]>; Xu, Rosen <[email protected]>; Chen, Junjie J <[email protected]>; Daly, Dan <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 1/3] eal/vfio: add support for multiple containerQuoted 11 lines · Xiao Wang
From: Junjie Chen <[email protected]>
Currently eal vfio framework binds vfio group fd to the default container fd, while in some cases, e.g. vDPA (vhost data path acceleration), we want to set vfio group to a new container and program DMA mapping via this new container, so this patch adds APIs to support multiple container.
Signed-off-by Junjie Chen <[email protected]>Signed-off-by Xiao Wang <[email protected]>---
Quoted 8 lines
I'm not going to get into virtual vs. real device debate, but i do have some issues with VFIO side of things.
I'm not completely convinced this change is needed in the first place. If the device driver manages its own groups anyway, it knows which VFIO groups belong to it, so it can add/remove them without putting them into separate containers. What is the purpose of keeping them in a separate container as opposed to just keeping track of group id's?
The device driver needs to have a separate container to program IOMMU For the device, with the VM's addr translation table. So driver needs the Devices be put into new containers, rather than the default one.
Quoted 4 lines
<...>
Quoted 12 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c vfio_get_group_fd(int iommu_group_no) · line 219
Quoted 7 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +7
-0+ vfio_cfg->vfio_container_fd =vfio_get_container_fd (); + +if (vfio_cfg->vfio_container_fd <0 ) +return -1 ; + +return vfio_cfg->vfio_container_fd; +}Please correct me if i'm wrong, but this patch appears to be mistitled. You're not really creating multiple containers, you're just partitioning existing one. Do we really need to open/store/close container fd's separately, if all we have is a single container anyway?
This driver are creating new containers for devices, it needs each device to have its own container, then we can dma_map/ummap for the device via it's associated container.
BRs,
Xiao
Quoted 11 lines
The semantics of this are also weird in multiprocess. When secondary process requests a container, we always create a new one, send it over IPC and close it afterwards. It seems to be oblivious that you may have several container fd's, and does not know which one you are asking for. We know it's all the same container, but that's clearly not what the code appears to be doing.
--
Thanks,
Anatoly
Re: [PATCH 2/3] bus/pci: expose sysfs parsing API
In reply to Gaëtan RivetHi Rivet,
Quoted 38 lines
-----Original Message-----
From: Gaëtan Rivet [mailto:[email protected]]
Sent: Wednesday, March 14, 2018 9:31 PM
To: Burakov, Anatoly <[email protected]>
Cc: Wang, Xiao W <[email protected]>; [email protected]; Wang, Zhihong <[email protected]>; [email protected]; [email protected]; Liang, Cunming <[email protected]>; Xu, Rosen <[email protected]>; Chen, Junjie J <[email protected]>; Daly, Dan <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 2/3] bus/pci: expose sysfs parsing APIHi,
Quoted 11 lines · Anatoly
Quoted 10 lines · Xiao Wang
Some existing sysfs parsing functions are helpful for the later vDPA driver, this patch make them global and expose them to shared lib.
Signed-off-by Xiao Wang <[email protected]>--- drivers/bus/pci/linux/pci.c | 9 ++++----- drivers/bus/pci/linux/pci_init.h | 8 ++++++++ drivers/bus/pci/rte_bus_pci_version.map | 8 ++++++++ 3 files changed, 20 insertions(+), 5 deletions(-)Quoted 12 lines
drivers/bus/pci/linux/pci.c line 34
Quoted 9 lines
drivers/bus/pci/linux/pci.c +1
-1@@ -32,7 +32,7 @@extern struct rte_pci_bus rte_pci_bus; -static int +int pci_get_kernel_driver_by_path (const char *filename,char *dri_name)Here and in other places - shouldn't this too be prefixed with
rte_?
Quoted 1 line
A public PCI function should be prefixed by
rte_pci_yes.
OK, will add this prefix.
Quoted 8 lines
Additionally, if this function was to be exposed, then there should be a BSD implementation as well (shared map file).
I don't know how BSD works, I'm not sure parsing the filesystem is the way to get a PCI driver name. If so, maybe the function should be called another, generic, way, that would work for both linux and BSD (and ideally, having a real BSD implementation).
BSD is not parsing the filesystem, it uses PCIOCGETCONF ioctl to retrieve PCI device information.
This function is quite linux, especially for the API name. I'm afraid we can only return err on BSD for this API.
BRs,
Xiao
Quoted 9 lines
Quoted 5 lines
--
Thanks,
Anatoly--
Gaëtan Rivet
6WIND
Re: [PATCH 2/3] bus/pci: expose sysfs parsing API
Quoted 53 lines · Xiao W
Hi Rivet,
Quoted 38 lines
-----Original Message-----
From: Gaëtan Rivet [mailto:[email protected]]
Sent: Wednesday, March 14, 2018 9:31 PM
To: Burakov, Anatoly <[email protected]>
Cc: Wang, Xiao W <[email protected]>; [email protected]; Wang, Zhihong <[email protected]>; [email protected]; [email protected]; Liang, Cunming <[email protected]>; Xu, Rosen <[email protected]>; Chen, Junjie J <[email protected]>; Daly, Dan <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 2/3] bus/pci: expose sysfs parsing APIHi,
Quoted 11 lines · Anatoly
Quoted 10 lines · Xiao Wang
Some existing sysfs parsing functions are helpful for the later vDPA driver, this patch make them global and expose them to shared lib.
Signed-off-by Xiao Wang <[email protected]>--- drivers/bus/pci/linux/pci.c | 9 ++++----- drivers/bus/pci/linux/pci_init.h | 8 ++++++++ drivers/bus/pci/rte_bus_pci_version.map | 8 ++++++++ 3 files changed, 20 insertions(+), 5 deletions(-)Quoted 12 lines
drivers/bus/pci/linux/pci.c line 34
Quoted 9 lines
drivers/bus/pci/linux/pci.c +1
-1@@ -32,7 +32,7 @@extern struct rte_pci_bus rte_pci_bus; -static int +int pci_get_kernel_driver_by_path (const char *filename,char *dri_name)Here and in other places - shouldn't this too be prefixed with
rte_?Quoted 1 line
A public PCI function should be prefixed by
rte_pci_yes.OK, will add this prefix.
Quoted 8 lines
Additionally, if this function was to be exposed, then there should be a BSD implementation as well (shared map file).
I don't know how BSD works, I'm not sure parsing the filesystem is the way to get a PCI driver name. If so, maybe the function should be called another, generic, way, that would work for both linux and BSD (and ideally, having a real BSD implementation).
Quoted 4 lines
BSD is not parsing the filesystem, it uses PCIOCGETCONF ioctl to retrieve PCI device information.
This function is quite linux, especially for the API name. I'm afraid we can only return err on BSD for this API.
How about renaming the function to something likerte_pci_device_kdriver_name();
and allowing for a sensible BSD implementation to happen if someone needs it?
Signature · 2 lines
Gaëtan Rivet 6WIND
Re: [PATCH 2/3] bus/pci: expose sysfs parsing API
Hi Rivet,
Quoted 72 lines
-----Original Message-----
From: Gaëtan Rivet [mailto:[email protected]]
Sent: Friday, March 16, 2018 1:19 AM
To: Wang, Xiao W <[email protected]>
Cc: Burakov, Anatoly <[email protected]>; [email protected]; Wang, Zhihong <[email protected]>; [email protected]; [email protected]; Liang, Cunming <[email protected]>; Xu, Rosen <[email protected]>; Chen, Junjie J <[email protected]>; Daly, Dan <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 2/3] bus/pci: expose sysfs parsing APIQuoted 7 lines · Xiao W
Hi Rivet,
Quoted 5 lines
-----Original Message-----
From: Gaëtan Rivet [mailto:[email protected]]
Sent: Wednesday, March 14, 2018 9:31 PM
To: Burakov, Anatoly <[email protected]>
Cc: Wang, Xiao W <[email protected]>; [email protected]; Wang,Zhihong
Quoted 2 lines
Quoted 2 lines
<[email protected]>; [email protected]; [email protected]; Liang, Cunming <[email protected]>; Xu,
Rosen
Quoted 44 lines
Quoted 31 lines
<[email protected]>; Chen, Junjie J <[email protected]>; Daly, Dan <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 2/3] bus/pci: expose sysfs parsing APIHi,
Quoted 11 lines · Anatoly
Quoted 10 lines · Xiao Wang
Some existing sysfs parsing functions are helpful for the later vDPA driver, this patch make them global and expose them to shared lib.
Signed-off-by Xiao Wang <[email protected]>--- drivers/bus/pci/linux/pci.c | 9 ++++----- drivers/bus/pci/linux/pci_init.h | 8 ++++++++ drivers/bus/pci/rte_bus_pci_version.map | 8 ++++++++ 3 files changed, 20 insertions(+), 5 deletions(-)Quoted 12 lines
drivers/bus/pci/linux/pci.c line 34
Quoted 9 lines
drivers/bus/pci/linux/pci.c +1
-1@@ -32,7 +32,7 @@extern struct rte_pci_bus rte_pci_bus; -static int +int pci_get_kernel_driver_by_path (const char *filename,char *dri_name)Here and in other places - shouldn't this too be prefixed with
rte_?Quoted 1 line
A public PCI function should be prefixed by
rte_pci_yes.OK, will add this prefix.
Quoted 8 lines
Additionally, if this function was to be exposed, then there should be a BSD implementation as well (shared map file).
I don't know how BSD works, I'm not sure parsing the filesystem is the way to get a PCI driver name. If so, maybe the function should be called another, generic, way, that would work for both linux and BSD (and ideally, having a real BSD implementation).
Quoted 4 lines
BSD is not parsing the filesystem, it uses PCIOCGETCONF ioctl to retrieve PCI device information.
This function is quite linux, especially for the API name. I'm afraid we can only return err on BSD for this API.
Quoted 5 lines
How about renaming the function to something like
rte_pci_device_kdriver_name();and allowing for a sensible BSD implementation to happen if someone needs it?
Yes, it looks more generic, and allows a BSD implementation to happen. I will rename it as below in next version. rte_pci_device_kdriver_name(const struct rte_pci_addr *addr, char *dri_name)
BRs,
Xiao
Quoted 4 lines
--
Gaëtan Rivet
6WIND
v2 cover add ifcvf driver
In reply to Xiao WangThis patch set has dependency on http://dpdk.org/dev/patchwork/patch/36241/
(vhost: support selective datapath);
ifc VF is virtio vring compatible device, it can be used to accelerate vhost data path. This patch implements vDPA driver ops which configures ifc VF to be a vhost data path accelerator.
ifcvf driver uses vdev as a control domain to manage ifc VFs that belong to it. It registers vDPA device ops to vhost lib to enable these VFs to be used as vhost data path accelerator.
Live migration feature is supported by ifc VF and this driver enables it based on vhost lib.
vDPA needs to create different containers for different devices, thus this patch set adds some APIs in eal/vfio to support multiple container, e.g.
- rte_vfio_create_container
- rte_vfio_destroy_container
- rte_vfio_bind_group_no
- rte_vfio_unbind_group_no
By this extension, a device can be put into a new specific container, rather than the previous default container.
v2:
- Rename function pci_get_kernel_driver_by_path to rte_pci_device_kdriver_name to make the API generic cross Linux and BSD, make it as EXPERIMENTAL.
- Rebase on Zhihong's vDPA v3 patch set.
- Minor code cleanup on vfio extension.
Junjie Chen (1):
eal/vfio: add support for multiple container
Xiao Wang (2):
bus/pci: expose sysfs parsing API
net/ifcvf: add ifcvf driver
config/common_base | 6 + config/common_linuxapp | 1 + drivers/bus/pci/Makefile | 2 + drivers/bus/pci/bsd/pci.c | 14 + drivers/bus/pci/linux/pci.c | 22 +- drivers/bus/pci/rte_bus_pci.h | 32 + drivers/bus/pci/rte_bus_pci_version.map | 8 + drivers/net/Makefile | 1 + drivers/net/ifcvf/Makefile | 40 + drivers/net/ifcvf/base/ifcvf.c | 329 ++++++++ drivers/net/ifcvf/base/ifcvf.h | 156 ++++ drivers/net/ifcvf/base/ifcvf_osdep.h | 52 ++ drivers/net/ifcvf/ifcvf_ethdev.c | 1240 ++++++++++++++++++++++++++++++ drivers/net/ifcvf/rte_ifcvf_version.map | 4 + lib/librte_eal/bsdapp/eal/eal.c | 51 +- lib/librte_eal/common/include/rte_vfio.h | 117 ++- lib/librte_eal/linuxapp/eal/eal_vfio.c | 553 ++++++++++--- lib/librte_eal/linuxapp/eal/eal_vfio.h | 2 + lib/librte_eal/rte_eal_version.map | 7 + mk/rte.app.mk | 1 + 20 files changed, 2527 insertions(+), 111 deletions(-) create mode 100644 drivers/net/ifcvf/Makefile create mode 100644 drivers/net/ifcvf/base/ifcvf.c create mode 100644 drivers/net/ifcvf/base/ifcvf.h create mode 100644 drivers/net/ifcvf/base/ifcvf_osdep.h create mode 100644 drivers/net/ifcvf/ifcvf_ethdev.c create mode 100644 drivers/net/ifcvf/rte_ifcvf_version.map
Signature · 1 line
2.15.1
PATCH v2 1/3 eal/vfio: add support for multiple container
From: Junjie Chen <[email protected]>
Currently eal vfio framework binds vfio group fd to the default container fd, while in some cases, e.g. vDPA (vhost data path acceleration), we want to set vfio group to a new container and program DMA mapping via this new container, so this patch adds APIs to support multiple container.
---
v2:
- Free memory when create container fails.
- Add boundary check on group idx.
--- lib/librte_eal/bsdapp/eal/eal.c | 51 ++- lib/librte_eal/common/include/rte_vfio.h | 117 ++++++- lib/librte_eal/linuxapp/eal/eal_vfio.c | 553 ++++++++++++++++++++++++++----- lib/librte_eal/linuxapp/eal/eal_vfio.h | 2 + lib/librte_eal/rte_eal_version.map | 7 + 5 files changed, 628 insertions(+), 102 deletions(-)
lib/librte_eal/bsdapp/eal/eal.c +42 -9
@@ -38,6 +38,7 @@#include <rte_interrupts.h> #include <rte_bus.h> #include <rte_dev.h> +#include <rte_vfio.h> #include <rte_devargs.h> #include <rte_version.h> #include <rte_atomic.h>
@@ -738,15 +739,6 @@ rte_eal_vfio_intr_mode(void)/* dummy forward declaration. */ struct vfio_device_info ; -/* dummy prototypes. */ -int rte_vfio_setup_device (const char *sysfs_base,const char *dev_addr, -int *vfio_dev_fd,struct vfio_device_info *device_info); -int rte_vfio_release_device (const char *sysfs_base,const char *dev_addr,int fd); -int rte_vfio_enable (const char *modname); -int rte_vfio_is_enabled (const char *modname); -int rte_vfio_noiommu_is_enabled (void ); -int rte_vfio_clear_group (int vfio_group_fd); - int rte_vfio_setup_device(__rte_unused const char *sysfs_base, __rte_unused const char *dev_addr, __rte_unused int *vfio_dev_fd,
@@ -781,3 +773,44 @@ int rte_vfio_clear_group(__rte_unused int vfio_group_fd) {return 0 ; } + +int rte_vfio_create_container (void ) +{ +return -1 ; +} + +int rte_vfio_destroy_container(__rte_unused int container_fd) +{ +return -1 ; +} + +int rte_vfio_bind_group_no(__rte_unused int container_fd, + __rte_unused int iommu_group_no) +{ +return -1 ; +} + +int rte_vfio_unbind_group_no(__rte_unused int container_fd, + __rte_unused int iommu_group_no) +{ +return -1 ; +} + +int rte_vfio_dma_map(__rte_unused int container_fd, + __rte_unused int dma_type, + __rte_unused const struct rte_memseg *ms) +{ +return -1 ; +} + +int rte_vfio_dma_unmap(__rte_unused int container_fd, + __rte_unused int dma_type, + __rte_unused const struct rte_memseg *ms) +{ +return -1 ; +} + +int rte_vfio_get_group_fd(__rte_unused int iommu_group_no) +{ +return -1 ; +}
lib/librte_eal/common/include/rte_vfio.h +116 -1
122 lines not on this page · raw message
lib/librte_eal/linuxapp/eal/eal_vfio.c +461 -92
753 lines not on this page · raw message
lib/librte_eal/linuxapp/eal/eal_vfio.h +2 -0
@@ -157,6 +157,8 @@ int vfio_mp_sync_setup(void);#define SOCKET_NO_FD 0x1#define SOCKET_ERR 0xFF +#define VFIO_MAX_CONTAINERS 256 +#endif /* VFIO_PRESENT */ #endif /* EAL_VFIO_H_ */
lib/librte_eal/rte_eal_version.map +7 -0
@@ -254,5 +254,12 @@ EXPERIMENTAL { rte_service_set_runstate_mapped_check; rte_service_set_stats_enable; rte_service_start_with_defaults; + rte_vfio_create_container; + rte_vfio_destroy_container; + rte_vfio_bind_group_no; + rte_vfio_unbind_group_no; + rte_vfio_dma_map; + rte_vfio_dma_unmap; + rte_vfio_get_group_fd; } DPDK_18.02;
Signature · 1 line
2.15.1
PATCH v2 2/3 bus/pci: expose sysfs parsing API
In reply to Xiao WangSome existing sysfs parsing functions are helpful for the later vDPA driver, this patch make them global and expose them to shared lib.
---
v2:
- Rename function pci_get_kernel_driver_by_path to rte_pci_device_kdriver_name to make the API generic cross Linux and BSD, make it as EXPERIMENTAL.
--- drivers/bus/pci/Makefile | 2 ++ drivers/bus/pci/bsd/pci.c | 14 ++++++++++++++ drivers/bus/pci/linux/pci.c | 22 +++++++++++++--------- drivers/bus/pci/rte_bus_pci.h | 32 ++++++++++++++++++++++++++++++++ drivers/bus/pci/rte_bus_pci_version.map | 8 ++++++++ 5 files changed, 69 insertions(+), 9 deletions(-)
drivers/bus/pci/Makefile +2 -0
@@ -49,6 +49,8 @@ CFLAGS += -I$(RTE_SDK)/drivers/bus/pci/$(SYSTEM) CFLAGS += -I$(RTE_SDK)/lib/librte_eal/common CFLAGS += -I$(RTE_SDK)/lib/librte_eal/$(SYSTEM)app/eal +CFLAGS += -DALLOW_EXPERIMENTAL_API + LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring LDLIBS += -lrte_ethdev -lrte_pci
drivers/bus/pci/bsd/pci.c +14 -0
@@ -649,3 +649,17 @@ rte_pci_ioport_unmap(struct rte_pci_ioport *p)return ret; } + +int __rte_experimental +rte_pci_device_kdriver_name(__rte_unused const struct rte_pci_addr *addr, + __rte_unused char *dri_name) +{ +return -1 ; +} + +int __rte_experimental +rte_pci_parse_sysfs_resource(__rte_unused const char *filename, + __rte_unused struct rte_pci_device *dev) +{ +return -1 ; +}
drivers/bus/pci/linux/pci.c +13 -9
@@ -32,17 +32,22 @@extern struct rte_pci_bus rte_pci_bus; -static int -pci_get_kernel_driver_by_path (const char *filename,char *dri_name) +int __rte_experimental +rte_pci_device_kdriver_name (const struct rte_pci_addr *addr,char *dri_name) {int count; +char link[PATH_MAX ];char path[PATH_MAX ];char *name; -if (!filename || !dri_name) +if (!addr || !dri_name)return -1 ; - count =readlink (filename, path,PATH_MAX ); +snprintf (link,sizeof (link),"%s/" PCI_PRI_FMT "/driver" , +rte_pci_get_sysfs_path (), addr->domain, addr->bus, addr->devid, + addr->function); + + count =readlink (link, path,PATH_MAX );if (count >=PATH_MAX )return -1 ;
@@ -168,9 +173,8 @@ pci_parse_one_sysfs_resource(char *line, size_t len, uint64_t *phys_addr,return 0 ; } -/* parse the "resource" sysfs file */ -static int -pci_parse_sysfs_resource (const char *filename,struct rte_pci_device *dev) +int __rte_experimental +rte_pci_parse_sysfs_resource (const char *filename,struct rte_pci_device *dev) {FILE *f;char buf[BUFSIZ ];
@@ -302,7 +306,7 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)/* parse resources */ snprintf (filename,sizeof (filename),"%s/resource" , dirname); -if (pci_parse_sysfs_resource (filename, dev) <0 ) { +if (rte_pci_parse_sysfs_resource (filename, dev) <0 ) {RTE_LOG (ERR ,EAL ,"%s(): cannot parse resource\n" , __func__);free (dev);return -1 ;
@@ -310,7 +314,7 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)/* parse driver */ snprintf (filename,sizeof (filename),"%s/driver" , dirname); - ret =pci_get_kernel_driver_by_path (filename, driver); + ret =rte_pci_device_kdriver_name (addr, driver);if (ret <0 ) {RTE_LOG (ERR ,EAL ,"Fail to get kernel driver\n" );free (dev);
drivers/bus/pci/rte_bus_pci.h +32 -0
@@ -304,6 +304,38 @@ void rte_pci_ioport_read(struct rte_pci_ioport *p,void rte_pci_ioport_write (struct rte_pci_ioport *p,const void *data,size_t len,off_t offset); +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Get the name of kernel driver bound to PCI device. +* +* @param addr +* The PCI device's location. +* @param dri_name +* Output buffer pointer. +* @return +* 0 on success, negative on error. +*/ +int __rte_experimental +rte_pci_device_kdriver_name (const struct rte_pci_addr *addr,char *dri_name); + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Parse the "resource" sysfs file. +* +* @param filename +* The PCI resource file path. +* @dev +* Pointer of rte_pci_device object, into which the parse result is recorded. +* @return +* 0 on success, -1 on error, 1 on no driver found. +*/ +int __rte_experimental +rte_pci_parse_sysfs_resource (const char *filename,struct rte_pci_device *dev); + #ifdef __cplusplus }#endif
drivers/bus/pci/rte_bus_pci_version.map +8 -0
@@ -16,3 +16,11 @@ DPDK_17.11 { local: *; }; + +EXPERIMENTAL { + global: + + rte_pci_device_kdriver_name; + rte_pci_parse_sysfs_resource; + +} DPDK_17.11;
Signature · 1 line
2.15.1
PATCH v2 3/3 net/ifcvf: add ifcvf driver
In reply to Xiao Wangifcvf driver uses vdev as a control domain to manage ifc VFs that belong to it. It registers vDPA device ops to vhost lib to enable these VFs to be used as vhost data path accelerator.
Live migration feature is supported by ifc VF and this driver enables it based on vhost lib.
Because vDPA driver needs to set up MSI-X vector to interrupt the guest, only vfio-pci is supported currently.
---
v2:
- Rebase on Zhihong's vDPA v3 patch set.
--- config/common_base | 6 + config/common_linuxapp | 1 + drivers/net/Makefile | 1 + drivers/net/ifcvf/Makefile | 40 + drivers/net/ifcvf/base/ifcvf.c | 329 ++++++++ drivers/net/ifcvf/base/ifcvf.h | 156 ++++ drivers/net/ifcvf/base/ifcvf_osdep.h | 52 ++ drivers/net/ifcvf/ifcvf_ethdev.c | 1240 +++++++++++++++++++++++++++++++ drivers/net/ifcvf/rte_ifcvf_version.map | 4 + mk/rte.app.mk | 1 + 10 files changed, 1830 insertions(+) create mode 100644 drivers/net/ifcvf/Makefile create mode 100644 drivers/net/ifcvf/base/ifcvf.c create mode 100644 drivers/net/ifcvf/base/ifcvf.h create mode 100644 drivers/net/ifcvf/base/ifcvf_osdep.h create mode 100644 drivers/net/ifcvf/ifcvf_ethdev.c create mode 100644 drivers/net/ifcvf/rte_ifcvf_version.map
config/common_base +6 -0
@@ -791,6 +791,12 @@ CONFIG_RTE_LIBRTE_VHOST_DEBUG=n # CONFIG_RTE_LIBRTE_PMD_VHOST=n +# +# Compile IFCVF driver +# To compile, CONFIG_RTE_LIBRTE_VHOST should be enabled. +# +CONFIG_RTE_LIBRTE_IFCVF=n + # # Compile the test application #
config/common_linuxapp +1 -0
@@ -15,6 +15,7 @@ CONFIG_RTE_LIBRTE_PMD_KNI=y CONFIG_RTE_LIBRTE_VHOST=y CONFIG_RTE_LIBRTE_VHOST_NUMA=y CONFIG_RTE_LIBRTE_PMD_VHOST=y +CONFIG_RTE_LIBRTE_IFCVF=y CONFIG_RTE_LIBRTE_PMD_AF_PACKET=y CONFIG_RTE_LIBRTE_PMD_TAP=y CONFIG_RTE_LIBRTE_AVP_PMD=y
drivers/net/Makefile +1 -0
@@ -53,6 +53,7 @@ endif # $(CONFIG_RTE_LIBRTE_SCHED) ifeq ($(CONFIG_RTE_LIBRTE_VHOST),y) DIRS-$(CONFIG_RTE_LIBRTE_PMD_VHOST) += vhost +DIRS-$(CONFIG_RTE_LIBRTE_IFCVF) += ifcvf endif # $(CONFIG_RTE_LIBRTE_VHOST) ifeq ($(CONFIG_RTE_LIBRTE_MRVL_PMD),y)
drivers/net/ifcvf/Makefile new file +40 -0
@@ -0,0 +1,40 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2018 Intel Corporation + +include $(RTE_SDK)/mk/rte.vars.mk + +# +# library name +# +LIB = librte_ifcvf.a + +LDLIBS += -lpthread +LDLIBS += -lrte_eal -lrte_mempool -lrte_pci +LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs -lrte_vhost +LDLIBS += -lrte_bus_vdev -lrte_bus_pci + +CFLAGS += -O3 +CFLAGS += $(WERROR_FLAGS) +CFLAGS += -I$(RTE_SDK)/lib/librte_eal/linuxapp/eal +CFLAGS += -I$(RTE_SDK)/drivers/bus/pci/linux +CFLAGS += -DALLOW_EXPERIMENTAL_API + +# +# Add extra flags for base driver source files to disable warnings in them +# +BASE_DRIVER_OBJS=$(sort $(patsubst %.c,%.o,$(notdir $(wildcard $(SRCDIR)/base/*.c)))) +$(foreach obj, $(BASE_DRIVER_OBJS), $(eval CFLAGS_$(obj)+=$(CFLAGS_BASE_DRIVER))) + +VPATH += $(SRCDIR)/base + +EXPORT_MAP := rte_ifcvf_version.map + +LIBABIVER := 1 + +# +# all source are stored in SRCS-y +# +SRCS-$(CONFIG_RTE_LIBRTE_PMD_VHOST) += ifcvf_ethdev.c +SRCS-$(CONFIG_RTE_LIBRTE_PMD_VHOST) += ifcvf.c + +include $(RTE_SDK)/mk/rte.lib.mk
drivers/net/ifcvf/base/ifcvf.c new file +329 -0
329 lines not on this page · raw message
drivers/net/ifcvf/base/ifcvf.h new file +156 -0
156 lines not on this page · raw message
drivers/net/ifcvf/base/ifcvf_osdep.h new file +52 -0
52 lines not on this page · raw message
drivers/net/ifcvf/ifcvf_ethdev.c new file +1240 -0
1,240 lines not on this page · raw message
drivers/net/ifcvf/rte_ifcvf_version.map new file +4 -0
@@ -0,0 +1,4 @@ +EXPERIMENTAL { + + local: *; +};
mk/rte.app.mk +1 -0
@@ -171,6 +171,7 @@ _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 +_LDLIBS-$(CONFIG_RTE_LIBRTE_IFCVF) += -lrte_ifcvf endif # $(CONFIG_RTE_LIBRTE_VHOST) _LDLIBS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += -lrte_pmd_vmxnet3_uio
Signature · 1 line
2.15.1
Re: [PATCH v2 1/3] eal/vfio: add support for multiple container
In reply to Xiao WangHi,
21/03/2018 14:21, Xiao Wang:
Quoted 2 lines
+#endif /*
VFIO_PRESENT*/
#endif /* _RTE_VFIO_H_ */
Please keep the empty line which was present between endif.
lib/librte_eal/rte_eal_version.map EXPERIMENTAL { · line 263
Quoted 7 lines
lib/librte_eal/rte_eal_version.map +7
-0+ rte_vfio_create_container; + rte_vfio_destroy_container; + rte_vfio_bind_group_no; + rte_vfio_unbind_group_no; + rte_vfio_dma_map; + rte_vfio_dma_unmap; + rte_vfio_get_group_fd;
Please keep alphabetical order.
About the naming, I see "no" and "idx" are used.
Other APIs in DPDK are using "num" and "id". Any strong opinion?
Re: [PATCH v2 2/3] bus/pci: expose sysfs parsing API
In reply to Xiao Wang21/03/2018 14:21, Xiao Wang:
drivers/bus/pci/linux/pci.c pci_scan_one(const char *dirname, const struct rte_pci_addr *addr) · line 317
Quoted 9 lines
Some existing sysfs parsing functions are helpful for the later vDPA driver, this patch make them global and expose them to shared lib.
Signed-off-by Xiao Wang <[email protected]>---
drivers/bus/pci/linux/pci.c +1
-1/* parse driver */ snprintf (filename,sizeof (filename),"%s/driver" , dirname); - ret =pci_get_kernel_driver_by_path (filename, driver); + ret =rte_pci_device_kdriver_name (addr, driver);
I guess the snprintf above becomes useless.
Quoted 2 lines
+ * @param
dri_name
+ * Output buffer pointer.
Parameter name and comment can be improved here:
"kdrv_name" would be more meaningful.
As a comment, "Output buffer for kernel driver name"
Quoted 5 lines
drivers/bus/pci/rte_bus_pci.h +5
-0+/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Parse the "resource" sysfs file.
drivers/bus/pci/rte_bus_pci.h void rte_pci_ioport_read(struct rte_pci_ioport *p, · line 337
Quoted 10 lines
drivers/bus/pci/rte_bus_pci.h +10
-0+* +* @param filename +* The PCI resource file path. +* @dev +* Pointer of rte_pci_device object, into which the parse result is recorded. +* @return +* 0 on success, -1 on error, 1 on no driver found. +*/ +int __rte_experimental +rte_pci_parse_sysfs_resource (const char *filename,struct rte_pci_device *dev);
This is a Linux specific API.
Maybe remove "sysfs" and replace "filename" by "resource"?
Hi Xiao,
Quoted 41 lines · Xiao W
Hi Maxime,
Quoted 39 lines
-----Original Message-----
From: Maxime Coquelin [mailto:[email protected]]
Sent: Sunday, March 11, 2018 2:24 AM
To: Wang, Xiao W <[email protected]>; [email protected]
Cc: Wang, Zhihong <[email protected]>; [email protected]; Liang, Cunming <[email protected]>; Xu, Rosen <[email protected]>; Chen, Junjie J <[email protected]>; Daly, Dan <[email protected]>
Subject: Re: [PATCH 0/3] add ifcvf driverHi Xiao,
Quoted 1 line · Xiao Wang
This patch set has dependency on
http://dpdk.org/dev/patchwork/patch/35635/
Quoted 9 lines
(vhost: support selective datapath);
ifc VF is compatible with virtio vring operations, this driver implements vDPA driver ops which configures ifc VF to be a vhost data path accelerator.
ifcvf driver uses vdev as a control domain to manage ifc VFs that belong to it. It registers vDPA device ops to vhost lib to enable these VFs to be used as vhost data path accelerator.
Quoted 5 lines
Live migration feature is supported by ifc VF and this driver enables it based on vhost lib.
vDPA needs to create different containers for different devices, thus this patch set adds APIs in eal/vfio to support multiple container.
Thanks for this! That will avoind having to duplicate these functions for every new offload driver.
Quoted 6 lines
Junjie Chen (1):
eal/vfio: add support for multiple containerXiao Wang (2):
bus/pci: expose sysfs parsing API
Quoted 8 lines
Quoted 4 lines
Still, I'm not convinced the offload device should be a virtual device. It is a real PCI device, why not having a new device type for offload devices, and let the device to be probed automatically by the existing device model?
IFC VFs are generated from SRIOV, with the PF driven by kernel driver. In DPDK we need to have something to represent PF, to register itself as a vDPA engine, so a virtual device is used for this purpose.
I went through the code, and something is not clear to me.
Why do we need to have a representation of the PF in DPDK? Why cannot we just bind at VF level?
Quoted 41 lines
The VFs are used for vhost net offload, and we could implement exception traffic Rx/Tx function on the VFs in future via port-representor mechanism. So this patch keeps the device type as net.
BRs,
XiaoQuoted 34 lines
Thanks,
MaximeQuoted 13 lines
net/ifcvf: add ifcvf driver
config/common_base | 6 + config/common_linuxapp | 1 + drivers/bus/pci/linux/pci.c | 9 +- drivers/bus/pci/linux/pci_init.h | 8 + drivers/bus/pci/rte_bus_pci_version.map | 8 + drivers/net/Makefile | 1 + drivers/net/ifcvf/Makefile | 40 + drivers/net/ifcvf/base/ifcvf.c | 329 ++++++++ drivers/net/ifcvf/base/ifcvf.h | 156 ++++ drivers/net/ifcvf/base/ifcvf_osdep.h | 52 ++ drivers/net/ifcvf/ifcvf_ethdev.c | 1241++++++++++++++++++++++++++++++
Quoted 15 lines
drivers/net/ifcvf/rte_ifcvf_version.map | 4 + lib/librte_eal/bsdapp/eal/eal.c | 51 +- lib/librte_eal/common/include/rte_vfio.h | 117 ++- lib/librte_eal/linuxapp/eal/eal_vfio.c | 553 ++++++++++--- lib/librte_eal/linuxapp/eal/eal_vfio.h | 2 + lib/librte_eal/rte_eal_version.map | 7 + mk/rte.app.mk | 1 + 18 files changed, 2480 insertions(+), 106 deletions(-)create mode 100644
drivers/net/ifcvf/Makefilecreate mode 100644drivers/net/ifcvf/base/ifcvf.ccreate mode 100644drivers/net/ifcvf/base/ifcvf.hcreate mode 100644drivers/net/ifcvf/base/ifcvf_osdep.hcreate mode 100644drivers/net/ifcvf/ifcvf_ethdev.ccreate mode 100644drivers/net/ifcvf/rte_ifcvf_version.map
Re: [PATCH v2 3/3] net/ifcvf: add ifcvf driver
In reply to Xiao Wang21/03/2018 14:21, Xiao Wang:
Quoted 3 lines
ifcvf driver uses vdev as a control domain to manage ifc VFs that belong to it. It registers vDPA device ops to vhost lib to enable these VFs to be used as vhost data path accelerator.
Not everybody work at Intel.
Please explain what means ifcvf and what is a control domain.
Quoted 11 lines
Live migration feature is supported by ifc VF and this driver enables it based on vhost lib.
Because vDPA driver needs to set up MSI-X vector to interrupt the guest, only vfio-pci is supported currently.
Signed-off-by Xiao Wang <[email protected]>Signed-off-by Rosen Xu <[email protected]>---
v2:
- Rebase on Zhihong's vDPA v3 patch set.
Quoted 11 lines
--- config/common_base | 6 + config/common_linuxapp | 1 + drivers/net/Makefile | 1 + drivers/net/ifcvf/Makefile | 40 + drivers/net/ifcvf/base/ifcvf.c | 329 ++++++++ drivers/net/ifcvf/base/ifcvf.h | 156 ++++ drivers/net/ifcvf/base/ifcvf_osdep.h | 52 ++ drivers/net/ifcvf/ifcvf_ethdev.c | 1240 +++++++++++++++++++++++++++++++ drivers/net/ifcvf/rte_ifcvf_version.map | 4 + mk/rte.app.mk | 1 +
This feature needs to be explained and documented.
It will be helpful to understand the mechanism and to have a good review. Please do not merge it until there is a good documentation.
Re: [PATCH v2 3/3] net/ifcvf: add ifcvf driver
In reply to Xiao WangQuoted 34 lines · Xiao Wang
ifcvf driver uses vdev as a control domain to manage ifc VFs that belong to it. It registers vDPA device ops to vhost lib to enable these VFs to be used as vhost data path accelerator.
Live migration feature is supported by ifc VF and this driver enables it based on vhost lib.
Because vDPA driver needs to set up MSI-X vector to interrupt the guest, only vfio-pci is supported currently.
Signed-off-by Xiao Wang <[email protected]>Signed-off-by Rosen Xu <[email protected]>---
v2:
- Rebase on Zhihong's vDPA v3 patch set.--- config/common_base | 6 + config/common_linuxapp | 1 + drivers/net/Makefile | 1 + drivers/net/ifcvf/Makefile | 40 + drivers/net/ifcvf/base/ifcvf.c | 329 ++++++++ drivers/net/ifcvf/base/ifcvf.h | 156 ++++ drivers/net/ifcvf/base/ifcvf_osdep.h | 52 ++ drivers/net/ifcvf/ifcvf_ethdev.c | 1240 +++++++++++++++++++++++++++++++ drivers/net/ifcvf/rte_ifcvf_version.map | 4 + mk/rte.app.mk | 1 + 10 files changed, 1830 insertions(+)create mode 100644
drivers/net/ifcvf/Makefilecreate mode 100644drivers/net/ifcvf/base/ifcvf.ccreate mode 100644drivers/net/ifcvf/base/ifcvf.hcreate mode 100644drivers/net/ifcvf/base/ifcvf_osdep.hcreate mode 100644drivers/net/ifcvf/ifcvf_ethdev.ccreate mode 100644drivers/net/ifcvf/rte_ifcvf_version.map
...
Quoted 47 lines
drivers/net/ifcvf/ifcvf_ethdev.c new file +47
-0+static int +eth_dev_ifcvf_create (struct rte_vdev_device *dev, +struct rte_pci_addr *pci_addr,int devices) +{ +const char *name =rte_vdev_device_name (dev); +struct rte_eth_dev *eth_dev =NULL ; +struct ether_addr *eth_addr =NULL ; +struct ifcvf_internal *internal =NULL ; +struct internal_list *list =NULL ; +struct rte_eth_dev_data *data =NULL ; +struct rte_pci_addr pf_addr = *pci_addr; +int i; + + list =rte_zmalloc_socket (name,sizeof (*list),0 , + dev->device.numa_node); +if (list ==NULL ) + goto error; + +/* reserve an ethdev entry */ + eth_dev =rte_eth_vdev_allocate (dev,sizeof (*internal)); +if (eth_dev ==NULL ) + goto error; + + eth_addr =rte_zmalloc_socket (name,sizeof (*eth_addr),0 , + dev->device.numa_node); +if (eth_addr ==NULL ) + goto error; + + *eth_addr = base_eth_addr; + eth_addr->addr_bytes[5 ] = eth_dev->data->port_id; + + internal = eth_dev->data->dev_private; + internal->dev_name =strdup (name); +if (internal->dev_name ==NULL ) + goto error; + + internal->eng_addr.pci_addr = *pci_addr; +for (i =0 ; i < devices; i++) { + pf_addr.domain = pci_addr->domain; + pf_addr.bus = pci_addr->bus; + pf_addr.devid = pci_addr->devid + (i +1 ) /8 ; + pf_addr.function = pci_addr->function + (i +1 ) %8 ; + internal->vf_info[i].pdev.addr = pf_addr; +rte_spinlock_init (&internal->vf_info[i].lock); + } + internal->max_devices = devices; +
drivers/net/ifcvf/ifcvf_ethdev.c line 1087
Quoted 10 lines
drivers/net/ifcvf/ifcvf_ethdev.c new file +10
-0+ list->eth_dev = eth_dev; +pthread_mutex_lock (&internal_list_lock); +TAILQ_INSERT_TAIL (&internal_list, list, next); +pthread_mutex_unlock (&internal_list_lock); + + data = eth_dev->data; + data->nb_rx_queues =IFCVF_MAX_QUEUES ; + data->nb_tx_queues =IFCVF_MAX_QUEUES ; + data->dev_link = vdpa_link; + data->mac_addrs = eth_addr;
We might want one ethernet device per VF, as for example you set dev_link.link_status to UP as soon as a VF is configured, and DOWN as when a single VF is removed.
Quoted 61 lines
drivers/net/ifcvf/ifcvf_ethdev.c new file +61
-0+ data->dev_flags =RTE_ETH_DEV_INTR_LSC ; + eth_dev->dev_ops = &ops; + +/* assign rx and tx ops, could be used as vDPA fallback */ + eth_dev->rx_pkt_burst = eth_ifcvf_rx; + eth_dev->tx_pkt_burst = eth_ifcvf_tx; + +if (rte_vdpa_register_engine (vdpa_ifcvf_driver.name, + &internal->eng_addr) <0 ) + goto error; + +return 0 ; + +error: +rte_free (list); +rte_free (eth_addr); +if (internal && internal->dev_name) +free (internal->dev_name); +rte_free (internal); +if (eth_dev) +rte_eth_dev_release_port (eth_dev); + +return -1 ; +} + +static int +get_pci_addr(const char *key __rte_unused, const char *value, void *extra_args) +{ +if (value ==NULL || extra_args ==NULL ) +return -1 ; + +return rte_pci_addr_parse (value, extra_args); +} + +static inline int +open_int(const char *key __rte_unused, const char *value, void *extra_args) +{ +uint16_t *n = extra_args; + +if (value ==NULL || extra_args ==NULL ) +return -EINVAL ; + + *n = (uint16_t )strtoul (value,NULL ,0 ); +if (*n ==USHRT_MAX && errno ==ERANGE ) +return -1 ; + +return 0 ; +} + +/* +* If this vdev is created by user, then ifcvf will be taken by +* this vdev. +*/ +static int +ifcvf_take_over (struct rte_pci_addr *pci_addr,int num) +{ +uint16_t port_id; +int i, ret; +char devname[RTE_DEV_NAME_MAX_LEN ]; +struct rte_pci_addr vf_addr = *pci_addr; +
drivers/net/ifcvf/ifcvf_ethdev.c line 1158
Quoted 10 lines
drivers/net/ifcvf/ifcvf_ethdev.c new file +10
-0+for (i =0 ; i < num; i++) { + vf_addr.function += i %8 ; + vf_addr.devid += i /8 ; +rte_pci_device_name (&vf_addr, devname,RTE_DEV_NAME_MAX_LEN ); + ret =rte_eth_dev_get_port_by_name (devname, &port_id); +if (ret ==0 ) { +rte_eth_dev_close (port_id); +if (rte_eth_dev_detach (port_id, devname) <0 ) +return -1 ; + }
That seems a bit hard.
Shouldn't we at least check the port is not started?
Quoted 105 lines
drivers/net/ifcvf/ifcvf_ethdev.c new file +82
-0+ } + +return 0 ; +} + +static int +rte_ifcvf_probe (struct rte_vdev_device *dev) +{ +struct rte_kvargs *kvlist =NULL ; +int ret =0 ; +struct rte_pci_addr pci_addr; +int devices; + +RTE_LOG (INFO ,PMD ,"Initializing ifcvf for %s\n" , +rte_vdev_device_name (dev)); + + kvlist =rte_kvargs_parse (rte_vdev_device_args (dev), valid_arguments); +if (kvlist ==NULL ) +return -1 ; + +if (rte_kvargs_count (kvlist,ETH_IFCVF_BDF_ARG ) ==1 ) { + ret =rte_kvargs_process (kvlist,ETH_IFCVF_BDF_ARG , + &get_pci_addr, &pci_addr); +if (ret <0 ) + goto out_free; + + }else { + ret =-1 ; + goto out_free; + } + +if (rte_kvargs_count (kvlist,ETH_IFCVF_DEVICES_ARG ) ==1 ) { + ret =rte_kvargs_process (kvlist,ETH_IFCVF_DEVICES_ARG , + &open_int, &devices); +if (ret <0 || devices >IFCVF_MAX_DEVICES ) + goto out_free; + }else { + devices =1 ; + } + + ret =ifcvf_take_over (&pci_addr, devices); +if (ret <0 ) + goto out_free; + +eth_dev_ifcvf_create (dev, &pci_addr, devices); + +out_free: +rte_kvargs_free (kvlist); +return ret; +} + +static int +rte_ifcvf_remove (struct rte_vdev_device *dev) +{ +const char *name; +struct rte_eth_dev *eth_dev =NULL ; + + name =rte_vdev_device_name (dev); +RTE_LOG (INFO ,PMD ,"Un-Initializing ifcvf for %s\n" , name); + +/* find an ethdev entry */ + eth_dev =rte_eth_dev_allocated (name); +if (eth_dev ==NULL ) +return -ENODEV ; + +eth_dev_close (eth_dev); +rte_free (eth_dev->data); +rte_eth_dev_release_port (eth_dev); + +return 0 ; +} + +static struct rte_vdev_driver ifcvf_drv = { + .probe = rte_ifcvf_probe, + .remove = rte_ifcvf_remove, +}; + +RTE_PMD_REGISTER_VDEV (net_ifcvf, ifcvf_drv); +RTE_PMD_REGISTER_ALIAS (net_ifcvf, eth_ifcvf); +RTE_PMD_REGISTER_PARAM_STRING (net_ifcvf, +"bdf=<bdf> " +"devices=<int>" );drivers/net/ifcvf/rte_ifcvf_version.map new file +4
-0@@ -0,0 +1,4 @@ +EXPERIMENTAL { + + local: *; +};mk/rte.app.mk +1
-0@@ -171,6 +171,7 @@ _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 +_LDLIBS-$(CONFIG_RTE_LIBRTE_IFCVF) += -lrte_ifcvf endif # $(CONFIG_RTE_LIBRTE_VHOST) _LDLIBS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += -lrte_pmd_vmxnet3_uio
Re: [PATCH v2 1/3] eal/vfio: add support for multiple container
In reply to Thomas MonjalonQuoted 18 lines · Thomas Monjalon
Hi,
21/03/2018 14:21, Xiao Wang:
Quoted 2 lines
+#endif /*
VFIO_PRESENT*/
#endif /* _RTE_VFIO_H_ */Please keep the empty line which was present between endif.
lib/librte_eal/rte_eal_version.map EXPERIMENTAL { · line 263
Quoted 7 lines
lib/librte_eal/rte_eal_version.map +7
-0+ rte_vfio_create_container; + rte_vfio_destroy_container; + rte_vfio_bind_group_no; + rte_vfio_unbind_group_no; + rte_vfio_dma_map; + rte_vfio_dma_unmap; + rte_vfio_get_group_fd;Please keep alphabetical order.
Quoted 2 lines
About the naming, I see "no" and "idx" are used.
Other APIs in DPDK are using "num" and "id". Any strong opinion?
{bind,unbind}_group is sufficient as a name. _no is redundant as implicit from the parameter type.
Signature · 2 lines
Gaëtan Rivet 6WIND
Re: [PATCH v2 2/3] bus/pci: expose sysfs parsing API
In reply to Thomas MonjalonHi Thomas,
Quoted 15 lines
-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Thursday, March 22, 2018 4:45 AM
To: Wang, Xiao W <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Wang, Zhihong <[email protected]>; Bie, Tiwei <[email protected]>; Chen, Junjie J <[email protected]>; Xu, Rosen <[email protected]>; Daly, Dan <[email protected]>; Liang, Cunming <[email protected]>; Burakov, Anatoly <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v2 2/3] bus/pci: expose sysfs parsing API21/03/2018 14:21, Xiao Wang:
Quoted 3 lines
Some existing sysfs parsing functions are helpful for the later vDPA driver, this patch make them global and expose them to shared lib.
Quoted 8 lines
drivers/bus/pci/linux/pci.c pci_scan_one(const char *dirname, const struct rte_pci_addr *addr) · line 317
Quoted 6 lines
Signed-off-by Xiao Wang <[email protected]>---
drivers/bus/pci/linux/pci.c +1
-1/* parse driver */ snprintf (filename,sizeof (filename),"%s/driver" , dirname); - ret =pci_get_kernel_driver_by_path (filename, driver); + ret =rte_pci_device_kdriver_name (addr, driver);I guess the snprintf above becomes useless.
Will remove it.
Quoted 7 lines
Quoted 3 lines
+ * @param
dri_name
+ * Output buffer pointer.Parameter name and comment can be improved here:
"kdrv_name" would be more meaningful.
As a comment, "Output buffer for kernel driver name"
Thanks for the suggestion. Will improve it.
Quoted 19 lines
Quoted 4 lines
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without priornotice
Review
Quoted 12 lines
+ *
+ * Parse the "resource" sysfs file.
+ *
+ * @param filename
+ * The PCI resource file path.
+ * @dev
+ * Pointer ofrte_pci_deviceobject, into which the parse result is recorded.
+ * @return
+ * 0 on success, -1 on error, 1 on no driver found.
+ */(quoted diff) +2
-0+int __rte_experimental +rte_pci_parse_sysfs_resource(const char *filename, struct rte_pci_device*dev);
Quoted 2 lines
This is a Linux specific API.
Maybe remove "sysfs" and replace "filename" by "resource"?
Yes, "sysfs" makes it Linux specific. Will change it. Thanks for the above comments.
BRs,
Xiao
Re: [PATCH v2 1/3] eal/vfio: add support for multiple container
In reply to Gaëtan RivetHi Thomas, Rivet,
Quoted 13 lines
-----Original Message-----
From: Gaëtan Rivet [mailto:[email protected]]
Sent: Thursday, March 22, 2018 5:38 AM
To: Thomas Monjalon <[email protected]>
Cc: Wang, Xiao W <[email protected]>; Chen, Junjie J <[email protected]>; [email protected]; [email protected]; [email protected]; Wang, Zhihong <[email protected]>; Bie, Tiwei <[email protected]>; Xu, Rosen <[email protected]>; Daly, Dan <[email protected]>; Liang, Cunming <[email protected]>; Burakov, Anatoly <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2 1/3] eal/vfio: add support for multiple container
Quoted 8 lines
Quoted 7 lines · Thomas Monjalon
Hi,
21/03/2018 14:21, Xiao Wang:
Quoted 2 lines
+#endif /*
VFIO_PRESENT*/
#endif /* _RTE_VFIO_H_ */Please keep the empty line which was present between endif.
OK.
Quoted 10 lines
Quoted 10 lines
lib/librte_eal/rte_eal_version.map EXPERIMENTAL { · line 263
Quoted 8 lines
lib/librte_eal/rte_eal_version.map +7
-0+ rte_vfio_create_container; + rte_vfio_destroy_container; + rte_vfio_bind_group_no; + rte_vfio_unbind_group_no; + rte_vfio_dma_map; + rte_vfio_dma_unmap; + rte_vfio_get_group_fd;Please keep alphabetical order.
OK. Will do.
Quoted 6 lines
Quoted 3 lines
About the naming, I see "no" and "idx" are used.
Other APIs in DPDK are using "num" and "id". Any strong opinion?{bind,unbind}_group is sufficient as a name.
_nois redundant as implicit from the parameter type.
{bind,unbind}_group looks very neat. Will remove "_no".
For the eal_vfio.c internal API with "_idx" postfix, the return value is an index of an array. I think "idx" is appropriate. Before this patch, we already have function get_vfio_group_idx.
Thanks for the comments.
-Xiao
Quoted 4 lines
--
Gaëtan Rivet
6WIND
Re: [PATCH v2 3/3] net/ifcvf: add ifcvf driver
In reply to Xiao WangQuoted 15 lines · Xiao Wang
ifcvf driver uses vdev as a control domain to manage ifc VFs that belong to it. It registers vDPA device ops to vhost lib to enable these VFs to be used as vhost data path accelerator.
Live migration feature is supported by ifc VF and this driver enables it based on vhost lib.
Because vDPA driver needs to set up MSI-X vector to interrupt the guest, only vfio-pci is supported currently.
Signed-off-by Xiao Wang <[email protected]>Signed-off-by Rosen Xu <[email protected]>---
v2:
- Rebase on Zhihong's vDPA v3 patch set.
Quoted 11 lines
--- config/common_base | 6 + config/common_linuxapp | 1 + drivers/net/Makefile | 1 + drivers/net/ifcvf/Makefile | 40 + drivers/net/ifcvf/base/ifcvf.c | 329 ++++++++ drivers/net/ifcvf/base/ifcvf.h | 156 ++++ drivers/net/ifcvf/base/ifcvf_osdep.h | 52 ++ drivers/net/ifcvf/ifcvf_ethdev.c | 1240 +++++++++++++++++++++++++++++++ drivers/net/ifcvf/rte_ifcvf_version.map | 4 + mk/rte.app.mk | 1 +
Need .ini file to represent driver features.
Also it is good to add driver documentation and a note into release note to announce new driver.
Quoted 30 lines
10 files changed, 1830 insertions(+) create mode 100644 drivers/net/ifcvf/Makefile create mode 100644 drivers/net/ifcvf/base/ifcvf.c create mode 100644 drivers/net/ifcvf/base/ifcvf.h create mode 100644 drivers/net/ifcvf/base/ifcvf_osdep.h create mode 100644 drivers/net/ifcvf/ifcvf_ethdev.c create mode 100644 drivers/net/ifcvf/rte_ifcvf_version.mapconfig/common_base +6
-0@@ -791,6 +791,12 @@ CONFIG_RTE_LIBRTE_VHOST_DEBUG=n # CONFIG_RTE_LIBRTE_PMD_VHOST=n +# +# Compile IFCVF driver +# To compile, CONFIG_RTE_LIBRTE_VHOST should be enabled. +# +CONFIG_RTE_LIBRTE_IFCVF=n + # # Compile the test application #config/common_linuxapp +0
-0
config/common_linuxapp CONFIG_RTE_LIBRTE_PMD_KNI=y · line 18
Quoted 4 lines
config/common_linuxapp +1
-0@@ -15,6 +15,7 @@ CONFIG_RTE_LIBRTE_PMD_KNI=y CONFIG_RTE_LIBRTE_VHOST=y CONFIG_RTE_LIBRTE_VHOST_NUMA=y CONFIG_RTE_LIBRTE_PMD_VHOST=y +CONFIG_RTE_LIBRTE_IFCVF=y
Current syntax for PMD config options:
Virtual ones: CONFIG_RTE_LIBRTE_PMD_XXX
Physical ones: CONFIG_RTE_LIBRTE_XXX_PMD
Virtual / Physical difference most probably not done intentionally but that is what it is right now.
Is "PMD" not added intentionally to the config option?
And what is the config time dependency of the driver, I assume VHOST is one of them but are there more?
drivers/net/Makefile endif # $(CONFIG_RTE_LIBRTE_SCHED) · line 56
Quoted 12 lines
config/common_linuxapp +0
-0CONFIG_RTE_LIBRTE_PMD_AF_PACKET=y CONFIG_RTE_LIBRTE_PMD_TAP=y CONFIG_RTE_LIBRTE_AVP_PMD=ydrivers/net/Makefile +1
-0@@ -53,6 +53,7 @@ endif # $(CONFIG_RTE_LIBRTE_SCHED) ifeq ($(CONFIG_RTE_LIBRTE_VHOST),y) DIRS-$(CONFIG_RTE_LIBRTE_PMD_VHOST) += vhost +DIRS-$(CONFIG_RTE_LIBRTE_IFCVF) += ifcvf
Since this is mainly vpda driver, does it make sense to put it under drivers/net/virtio/vpda/ifcvf
When there are more vpda driver they can go into drivers/net/virtio/vpda/*
Combining with below not registering ethdev comment, virtual driver can register itself as vpda_ifcvf:RTE_PMD_REGISTER_VDEV(vpda_ifcvf, ifcvf_drv);
Quoted 25 lines
drivers/net/Makefile +0
-0endif # $(CONFIG_RTE_LIBRTE_VHOST) ifeq ($(CONFIG_RTE_LIBRTE_MRVL_PMD),y)drivers/net/ifcvf/Makefile new file +16
-0@@ -0,0 +1,40 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2018 Intel Corporation + +include $(RTE_SDK)/mk/rte.vars.mk + +# +# library name +# +LIB = librte_ifcvf.a + +LDLIBS += -lpthread +LDLIBS += -lrte_eal -lrte_mempool -lrte_pci +LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs -lrte_vhost +LDLIBS += -lrte_bus_vdev -lrte_bus_pci + +CFLAGS += -O3
drivers/net/ifcvf/Makefile line 26
Quoted 10 lines
drivers/net/ifcvf/Makefile new file +10
-0+CFLAGS += $(WERROR_FLAGS) +CFLAGS += -I$(RTE_SDK)/lib/librte_eal/linuxapp/eal +CFLAGS += -I$(RTE_SDK)/drivers/bus/pci/linux +CFLAGS += -DALLOW_EXPERIMENTAL_API + +# +# Add extra flags for base driver source files to disable warnings in them +# +BASE_DRIVER_OBJS=$(sort $(patsubst %.c,%.o,$(notdir $(wildcard $(SRCDIR)/base/*.c)))) +$(foreach obj, $(BASE_DRIVER_OBJS), $(eval CFLAGS_$(obj)+=$(CFLAGS_BASE_DRIVER)))
It seems no CFLAGS_BASE_DRIVER defined yet, above lines can be removed for now.
drivers/net/ifcvf/Makefile line 38
Quoted 12 lines
drivers/net/ifcvf/Makefile new file +12
-0+ +VPATH += $(SRCDIR)/base + +EXPORT_MAP := rte_ifcvf_version.map + +LIBABIVER := 1 + +# +# all source are stored in SRCS-y +# +SRCS-$(CONFIG_RTE_LIBRTE_PMD_VHOST) += ifcvf_ethdev.c +SRCS-$(CONFIG_RTE_LIBRTE_PMD_VHOST) += ifcvf.c
Is it intentionally used "RTE_LIBRTE_PMD_VHOST" because of dependency or typo?
Quoted 2 lines
drivers/net/ifcvf/Makefile new file +2
-0+ +include $(RTE_SDK)/mk/rte.lib.mk
<...>
Quoted 10 lines
drivers/net/ifcvf/Makefile new file +10
-0+static int +eth_dev_ifcvf_create(struct rte_vdev_device *dev, + struct rte_pci_addr *pci_addr, int devices) +{ + const char *name = rte_vdev_device_name(dev); + struct rte_eth_dev *eth_dev = NULL; + struct ether_addr *eth_addr = NULL; + struct ifcvf_internal *internal = NULL; + struct internal_list *list = NULL; + struct rte_eth_dev_data *data = NULL;
drivers/net/ifcvf/Makefile
Quoted 10 lines
drivers/net/ifcvf/Makefile new file +10
-0+ struct rte_pci_addr pf_addr = *pci_addr; + int i; + + list = rte_zmalloc_socket(name, sizeof(*list), 0, + dev->device.numa_node); + if (list == NULL) + goto error; + + /* reserve an ethdev entry */ + eth_dev = rte_eth_vdev_allocate(dev, sizeof(*internal));
Is this eth_dev used at all? It looks like it is only used for its private data, if so can it be possible to use something like:
struct ifdev {
void *private;
struct rte_device *dev;
}allocate memory for private and add this struct to the list, this may save ethdev overhead.
But I can see dev_start() and dev_stop() are used, not sure if they are the reason of the ethdev.
drivers/net/ifcvf/Makefile
Quoted 13 lines
drivers/net/ifcvf/Makefile new file +13
-0+ if (eth_dev == NULL) + goto error; + + eth_addr = rte_zmalloc_socket(name, sizeof(*eth_addr), 0, + dev->device.numa_node); + if (eth_addr == NULL) + goto error; + + *eth_addr = base_eth_addr; + eth_addr->addr_bytes[5] = eth_dev->data->port_id; + + internal = eth_dev->data->dev_private; + internal->dev_name = strdup(name);
Need to free this later and on error paths
drivers/net/ifcvf/Makefile
Quoted 13 lines
drivers/net/ifcvf/Makefile new file +13
-0+ if (internal->dev_name == NULL) + goto error; + + internal->eng_addr.pci_addr = *pci_addr; + for (i = 0; i < devices; i++) { + pf_addr.domain = pci_addr->domain; + pf_addr.bus = pci_addr->bus; + pf_addr.devid = pci_addr->devid + (i + 1) / 8; + pf_addr.function = pci_addr->function + (i + 1) % 8; + internal->vf_info[i].pdev.addr = pf_addr; + rte_spinlock_init(&internal->vf_info[i].lock); + } + internal->max_devices = devices;
is it max_devices or number of devices?
<...>
Quoted 2 lines
+/*
+ * If this vdev is created by user, then ifcvf will be taken by
created by user?
Quoted 5 lines
+ * this vdev.
+ */drivers/net/ifcvf/Makefile new file +3
-0+static int +ifcvf_take_over(struct rte_pci_addr *pci_addr, int num) +{
drivers/net/ifcvf/Makefile
Quoted 10 lines
drivers/net/ifcvf/Makefile new file +10
-0+ uint16_t port_id; + int i, ret; + char devname[RTE_DEV_NAME_MAX_LEN]; + struct rte_pci_addr vf_addr = *pci_addr; + + for (i = 0; i < num; i++) { + vf_addr.function += i % 8; + vf_addr.devid += i / 8; + rte_pci_device_name(&vf_addr, devname, RTE_DEV_NAME_MAX_LEN); + ret = rte_eth_dev_get_port_by_name(devname, &port_id);
Who probed this device at first place?
drivers/net/ifcvf/Makefile
Quoted 3 lines
drivers/net/ifcvf/Makefile new file +3
-0+ if (ret == 0) { + rte_eth_dev_close(port_id); + if (rte_eth_dev_detach(port_id, devname) < 0)
This will call the driver remov() also will remove device from device list, is it OK?
Quoted 4 lines
drivers/net/ifcvf/Makefile new file +4
-0+ return -1; + } + } +
drivers/net/ifcvf/Makefile
Quoted 10 lines
drivers/net/ifcvf/Makefile new file +10
-0+ return 0; +} + +static int +rte_ifcvf_probe(struct rte_vdev_device *dev) +{ + struct rte_kvargs *kvlist = NULL; + int ret = 0; + struct rte_pci_addr pci_addr; + int devices;
devices can't be negative, and according open_int() it is uint16_t, it is possible to pick an unsigned storage type for it.
<...>
Quoted 7 lines
drivers/net/ifcvf/Makefile new file +7
-0+static int +rte_ifcvf_remove(struct rte_vdev_device *dev) +{ + const char *name; + struct rte_eth_dev *eth_dev = NULL; + + name = rte_vdev_device_name(dev);
drivers/net/ifcvf/Makefile
Quoted 10 lines
drivers/net/ifcvf/Makefile new file +10
-0+ RTE_LOG(INFO, PMD, "Un-Initializing ifcvf for %s\n", name); + + /* find an ethdev entry */ + eth_dev = rte_eth_dev_allocated(name); + if (eth_dev == NULL) + return -ENODEV; + + eth_dev_close(eth_dev); + rte_free(eth_dev->data); + rte_eth_dev_release_port(eth_dev);
This does memset(ethdev->data, ..), so should be called before rte_free(data)
drivers/net/ifcvf/Makefile
Quoted 11 lines
drivers/net/ifcvf/Makefile new file +11
-0+ + return 0; +} + +static struct rte_vdev_driver ifcvf_drv = { + .probe = rte_ifcvf_probe, + .remove = rte_ifcvf_remove, +}; + +RTE_PMD_REGISTER_VDEV(net_ifcvf, ifcvf_drv); +RTE_PMD_REGISTER_ALIAS(net_ifcvf, eth_ifcvf);
Alias for backport support, not needed for new drivers.
drivers/net/ifcvf/Makefile
Quoted 3 lines
drivers/net/ifcvf/Makefile new file +3
-0+RTE_PMD_REGISTER_PARAM_STRING(net_ifcvf, + "bdf=<bdf> " + "devices=<int>");
Above says:
#define ETH_IFCVF_DEVICES_ARG "int"
Is argument "int" or "devices"? Using macro here helps preventing errors.
drivers/net/ifcvf/rte_ifcvf_version.map line 1
Quoted 7 lines
drivers/net/ifcvf/rte_ifcvf_version.map new file +1
-0@@ -0,0 +1,4 @@ +EXPERIMENTAL {
Please put release version here.
<...>
Re: [PATCH v2 3/3] net/ifcvf: add ifcvf driver
Hi Ferruh,
Quoted 37 lines
-----Original Message-----
From: Yigit, Ferruh
Sent: Thursday, March 22, 2018 4:51 PM
To: Wang, Xiao W <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; Wang, Zhihong <[email protected]>; Bie, Tiwei <[email protected]>; Chen, Junjie J <[email protected]>; Xu, Rosen <[email protected]>; Daly, Dan <[email protected]>; Liang, Cunming <[email protected]>; Burakov, Anatoly <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v2 3/3] net/ifcvf: add ifcvf driverQuoted 15 lines · Xiao Wang
ifcvf driver uses vdev as a control domain to manage ifc VFs that belong to it. It registers vDPA device ops to vhost lib to enable these VFs to be used as vhost data path accelerator.
Live migration feature is supported by ifc VF and this driver enables it based on vhost lib.
Because vDPA driver needs to set up MSI-X vector to interrupt the guest, only vfio-pci is supported currently.
Signed-off-by Xiao Wang <[email protected]>Signed-off-by Rosen Xu <[email protected]>---
v2:
- Rebase on Zhihong's vDPA v3 patch set.Quoted 9 lines
--- config/common_base | 6 + config/common_linuxapp | 1 + drivers/net/Makefile | 1 + drivers/net/ifcvf/Makefile | 40 + drivers/net/ifcvf/base/ifcvf.c | 329 ++++++++ drivers/net/ifcvf/base/ifcvf.h | 156 ++++ drivers/net/ifcvf/base/ifcvf_osdep.h | 52 ++ drivers/net/ifcvf/ifcvf_ethdev.c | 1240
Quoted 7 lines
+++++++++++++++++++++++++++++++
Quoted 2 lines
drivers/net/ifcvf/rte_ifcvf_version.map | 4 + mk/rte.app.mk | 1 +Need .ini file to represent driver features.
Also it is good to add driver documentation and a note into release note to announce new driver.
Will do.
Quoted 40 lines
Quoted 31 lines
10 files changed, 1830 insertions(+) create mode 100644 drivers/net/ifcvf/Makefile create mode 100644 drivers/net/ifcvf/base/ifcvf.c create mode 100644 drivers/net/ifcvf/base/ifcvf.h create mode 100644 drivers/net/ifcvf/base/ifcvf_osdep.h create mode 100644 drivers/net/ifcvf/ifcvf_ethdev.c create mode 100644 drivers/net/ifcvf/rte_ifcvf_version.mapconfig/common_base +6
-0@@ -791,6 +791,12 @@ CONFIG_RTE_LIBRTE_VHOST_DEBUG=n # CONFIG_RTE_LIBRTE_PMD_VHOST=n +# +# Compile IFCVF driver +# To compile, CONFIG_RTE_LIBRTE_VHOST should be enabled. +# +CONFIG_RTE_LIBRTE_IFCVF=n + # # Compile the test application #config/common_linuxapp +0
-0config/common_linuxapp CONFIG_RTE_LIBRTE_PMD_KNI=y · line 18
Quoted 4 lines
config/common_linuxapp +1
-0@@ -15,6 +15,7 @@ CONFIG_RTE_LIBRTE_PMD_KNI=y CONFIG_RTE_LIBRTE_VHOST=y CONFIG_RTE_LIBRTE_VHOST_NUMA=y CONFIG_RTE_LIBRTE_PMD_VHOST=y +CONFIG_RTE_LIBRTE_IFCVF=yCurrent syntax for PMD config options:
Virtual ones:CONFIG_RTE_LIBRTE_PMD_XXX
Physical ones:CONFIG_RTE_LIBRTE_XXX_PMD
Quoted 4 lines
Virtual / Physical difference most probably not done intentionally but that is what it is right now.
Is "PMD" not added intentionally to the config option?
I think vDPA driver is not polling mode, so I didn't put a "PMD" here. Do you think CONFIG_RTE_LIBRTE_VDPA_IFCVF is better?
Quoted 4 lines
And what is the config time dependency of the driver, I assume VHOST is one of
them but are there more?
This dependency is described in drivers/net/Makefile, CONFIG_RTE_EAL_VFIO is another one, will add it.
Quoted 10 lines
Quoted 10 lines
config/common_linuxapp +0
-0CONFIG_RTE_LIBRTE_PMD_AF_PACKET=y CONFIG_RTE_LIBRTE_PMD_TAP=y CONFIG_RTE_LIBRTE_AVP_PMD=ydrivers/net/Makefile +0
-0@@ -53,6 +53,7 @@ endif # $(CONFIG_RTE_LIBRTE_SCHED)
Quoted 8 lines
drivers/net/Makefile endif # $(CONFIG_RTE_LIBRTE_SCHED) · line 56
Quoted 3 lines
drivers/net/Makefile +1
-0ifeq ($(CONFIG_RTE_LIBRTE_VHOST),y) DIRS-$(CONFIG_RTE_LIBRTE_PMD_VHOST) += vhost +DIRS-$(CONFIG_RTE_LIBRTE_IFCVF) += ifcvfSince this is mainly vpda driver, does it make sense to put it under
drivers/net/virtio/vpda/ifcvfWhen there are more vpda driver they can go into
drivers/net/virtio/vpda/*
vDPA is for vhost offloading/acceleration, the device can be quite different from virtio, they just need to be virtio ring compatible, and the usage model is quite different from virtio pmd. I think vDPA driver should not go into drivers/net/virtio dir.
Quoted 5 lines
Combining with below not registering ethdev comment, virtual driver can register
itself asvpda_ifcvf:RTE_PMD_REGISTER_VDEV(vpda_ifcvf, ifcvf_drv);
Yes, very limited ethdev APIs can be implemented for this ethdev, I'll try to remove the ethdev registering.
Quoted 36 lines
Quoted 25 lines
drivers/net/Makefile +0
-0endif # $(CONFIG_RTE_LIBRTE_VHOST) ifeq ($(CONFIG_RTE_LIBRTE_MRVL_PMD),y)drivers/net/ifcvf/Makefile new file +15
-0@@ -0,0 +1,40 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2018 Intel Corporation + +include $(RTE_SDK)/mk/rte.vars.mk + +# +# library name +# +LIB = librte_ifcvf.a + +LDLIBS += -lpthread +LDLIBS += -lrte_eal -lrte_mempool -lrte_pci +LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs -lrte_vhost +LDLIBS += -lrte_bus_vdev -lrte_bus_pci +drivers/net/ifcvf/Makefile line 25
Quoted 10 lines
drivers/net/ifcvf/Makefile new file +10
-0+CFLAGS += -O3 +CFLAGS += $(WERROR_FLAGS) +CFLAGS += -I$(RTE_SDK)/lib/librte_eal/linuxapp/eal +CFLAGS += -I$(RTE_SDK)/drivers/bus/pci/linux +CFLAGS += -DALLOW_EXPERIMENTAL_API + +# +# Add extra flags for base driver source files to disable warnings in them +# +BASE_DRIVER_OBJS=$(sort $(patsubst %.c,%.o,$(notdir $(wildcard$(SRCDIR)/base/*.c))))
Quoted 5 lines
drivers/net/ifcvf/Makefile line 26
Quoted 1 line
drivers/net/ifcvf/Makefile new file +1
-0+$(foreach obj, $(BASE_DRIVER_OBJS), $(evalCFLAGS_$(obj)+=$(CFLAGS_BASE_DRIVER)))
It seems no
CFLAGS_BASE_DRIVERdefined yet, above lines can be removed for now.
Will remove it.
Quoted 16 lines
drivers/net/ifcvf/Makefile line 38
Quoted 13 lines
drivers/net/ifcvf/Makefile new file +12
-0+ +VPATH += $(SRCDIR)/base + +EXPORT_MAP := rte_ifcvf_version.map + +LIBABIVER := 1 + +# +# all source are stored in SRCS-y +# +SRCS-$(CONFIG_RTE_LIBRTE_PMD_VHOST) += ifcvf_ethdev.c +SRCS-$(CONFIG_RTE_LIBRTE_PMD_VHOST) += ifcvf.cIs it intentionally used "
RTE_LIBRTE_PMD_VHOST" because of dependency or typo?
Sorry for the typo.
Quoted 34 lines
Quoted 3 lines
drivers/net/ifcvf/Makefile new file +2
-0+ +include $(RTE_SDK)/mk/rte.lib.mk<...>
Quoted 10 lines
drivers/net/ifcvf/Makefile new file +10
-0+static int +eth_dev_ifcvf_create(struct rte_vdev_device *dev, + struct rte_pci_addr *pci_addr, int devices) +{ + const char *name = rte_vdev_device_name(dev); + struct rte_eth_dev *eth_dev = NULL; + struct ether_addr *eth_addr = NULL; + struct ifcvf_internal *internal = NULL; + struct internal_list *list = NULL; + struct rte_eth_dev_data *data = NULL;drivers/net/ifcvf/Makefile
Quoted 10 lines
drivers/net/ifcvf/Makefile new file +10
-0+ struct rte_pci_addr pf_addr = *pci_addr; + int i; + + list = rte_zmalloc_socket(name, sizeof(*list), 0, + dev->device.numa_node); + if (list == NULL) + goto error; + + /* reserve an ethdev entry */ + eth_dev = rte_eth_vdev_allocate(dev, sizeof(*internal));Is this
eth_devused at all? It looks like it is only used for its private data, if so can it be possible to use something like:struct ifdev { void *private; struct rte_device *dev; }
Quoted 5 lines
allocate memory for private and add this struct to the list, this may save ethdev overhead.
But I can see
dev_start()anddev_stop()are used, not sure if they are the reason of the ethdev.
Registering an ethdev allows to dev_start/stop, but it seems this overhead doesn’t bring much benefit. Your suggestion looks good.
Quoted 16 lines
Quoted 4 lines
drivers/net/ifcvf/Makefile new file +3
-0+ if (eth_dev == NULL) + goto error; +drivers/net/ifcvf/Makefile
Quoted 10 lines
drivers/net/ifcvf/Makefile new file +10
-0+ eth_addr = rte_zmalloc_socket(name, sizeof(*eth_addr), 0, + dev->device.numa_node); + if (eth_addr == NULL) + goto error; + + *eth_addr = base_eth_addr; + eth_addr->addr_bytes[5] = eth_dev->data->port_id; + + internal = eth_dev->data->dev_private; + internal->dev_name = strdup(name);Need to free this later and on error paths
The error path has it:
if (internal && internal->dev_name)
free(internal->dev_name);Quoted 16 lines
Quoted 4 lines
drivers/net/ifcvf/Makefile new file +3
-0+ if (internal->dev_name == NULL) + goto error; +drivers/net/ifcvf/Makefile
Quoted 10 lines
drivers/net/ifcvf/Makefile new file +10
-0+ internal->eng_addr.pci_addr = *pci_addr; + for (i = 0; i < devices; i++) { + pf_addr.domain = pci_addr->domain; + pf_addr.bus = pci_addr->bus; + pf_addr.devid = pci_addr->devid + (i + 1) / 8; + pf_addr.function = pci_addr->function + (i + 1) % 8; + internal->vf_info[i].pdev.addr = pf_addr; + rte_spinlock_init(&internal->vf_info[i].lock); + } + internal->max_devices = devices;is it
max_devicesor number of devices?
It's a field to describe how many devices are contained in this vDPA engine. The value is min(user argument, IFCVF MAX VFs). Rename it to dev_num looks better.
Quoted 7 lines
<...>
Quoted 2 lines
+/*
+ * If this vdev is created by user, then ifcvf will be taken bycreated by user?
I mean when app creates this vdev, we can assume app wants ifcvf to be used as vDPA device. Ifcvf has virtio's vendor ID and device ID, but it has its specific subsystem vendor ID and device ID. So virtio pmd can take ifcvf first, then app stops the virtio port, and creates ifcvf vdev to drive ifcvf.
Quoted 16 lines
Quoted 5 lines
+ * this vdev.
+ */drivers/net/ifcvf/Makefile new file +2
-0+static int +ifcvf_take_over(struct rte_pci_addr *pci_addr, int num)drivers/net/ifcvf/Makefile
Quoted 10 lines
drivers/net/ifcvf/Makefile new file +10
-0+{ + uint16_t port_id; + int i, ret; + char devname[RTE_DEV_NAME_MAX_LEN]; + struct rte_pci_addr vf_addr = *pci_addr; + + for (i = 0; i < num; i++) { + vf_addr.function += i % 8; + vf_addr.devid += i / 8; + rte_pci_device_name(&vf_addr, devname,
RTE_DEV_NAME_MAX_LEN);
Quoted 3 lines
drivers/net/ifcvf/Makefile
Quoted 1 line
drivers/net/ifcvf/Makefile new file +1
-0+ ret = rte_eth_dev_get_port_by_name(devname, &port_id);Who probed this device at first place?
If no whitelist specified, virtio pmd will probe it first.
Quoted 7 lines
drivers/net/ifcvf/Makefile
Quoted 4 lines
drivers/net/ifcvf/Makefile new file +3
-0+ if (ret == 0) { + rte_eth_dev_close(port_id); + if (rte_eth_dev_detach(port_id, devname) < 0)This will call the driver
remov()also will remove device from device list, is it OK?
Or we can just call rte_eth_dev_release_port, to keep the device in the device list. This will be better.
Quoted 10 lines
Quoted 10 lines
drivers/net/ifcvf/Makefile new file +9
-0+ return -1; + } + } + + return 0; +} + +static int +rte_ifcvf_probe(struct rte_vdev_device *dev)
Quoted 8 lines
drivers/net/ifcvf/Makefile
Quoted 5 lines
drivers/net/ifcvf/Makefile new file +5
-0+{ + struct rte_kvargs *kvlist = NULL; + int ret = 0; + struct rte_pci_addr pci_addr; + int devices;devices can't be negative, and according
open_int()it isuint16_t, it is possible to pick an unsigned storage type for it.
Will use unsigned type.
Quoted 14 lines
<...>
Quoted 11 lines
drivers/net/ifcvf/Makefile new file +11
-0+static int +rte_ifcvf_remove(struct rte_vdev_device *dev) +{ + const char *name; + struct rte_eth_dev *eth_dev = NULL; + + name = rte_vdev_device_name(dev); + RTE_LOG(INFO, PMD, "Un-Initializing ifcvf for %s\n", name); + + /* find an ethdev entry */ + eth_dev = rte_eth_dev_allocated(name);
Quoted 8 lines
drivers/net/ifcvf/Makefile
Quoted 6 lines
drivers/net/ifcvf/Makefile new file +6
-0+ if (eth_dev == NULL) + return -ENODEV; + + eth_dev_close(eth_dev); + rte_free(eth_dev->data); + rte_eth_dev_release_port(eth_dev);This does
memset(ethdev->data, ..), so should be called beforerte_free(data)
Agree, will change it .
Quoted 14 lines
drivers/net/ifcvf/Makefile
Quoted 12 lines
drivers/net/ifcvf/Makefile new file +11
-0+ + return 0; +} + +static struct rte_vdev_driver ifcvf_drv = { + .probe = rte_ifcvf_probe, + .remove = rte_ifcvf_remove, +}; + +RTE_PMD_REGISTER_VDEV(net_ifcvf, ifcvf_drv); +RTE_PMD_REGISTER_ALIAS(net_ifcvf, eth_ifcvf);Alias for backport support, not needed for new drivers.
OK, will remove it.
Quoted 9 lines
drivers/net/ifcvf/Makefile
Quoted 4 lines
drivers/net/ifcvf/Makefile new file +3
-0+RTE_PMD_REGISTER_PARAM_STRING(net_ifcvf, + "bdf=<bdf> " + "devices=<int>");Above says:
#defineETH_IFCVF_DEVICES_ARG"int"Is argument "int" or "devices"? Using macro here helps preventing errors.
It's "devices", will fix it with using macro.
Quoted 11 lines
Review
Quoted 2 lines
(quoted diff) +0
-0b/drivers/net/ifcvf/rte_ifcvf_version.map
drivers/net/ifcvf/rte_ifcvf_version.map line 1
Quoted 6 lines
new file mode 100644
index 000000000..33d237913drivers/net/ifcvf/rte_ifcvf_version.map new file +1
-0@@ -0,0 +1,4 @@ +EXPERIMENTAL {Please put release version here.
OK, will put "DPDK_18.05"
Thanks for the comments,
-Xiao
Quoted 2 lines
<...>
Hi Maxime,
Quoted 59 lines
-----Original Message-----
From: Maxime Coquelin [mailto:[email protected]]
Sent: Thursday, March 22, 2018 4:48 AM
To: Wang, Xiao W <[email protected]>; [email protected]
Cc: Wang, Zhihong <[email protected]>; [email protected]; Liang, Cunming <[email protected]>; Xu, Rosen <[email protected]>; Chen, Junjie J <[email protected]>; Daly, Dan <[email protected]>
Subject: Re: [PATCH 0/3] add ifcvf driverHi Xiao,
Quoted 8 lines · Xiao W
Hi Maxime,
Quoted 6 lines
-----Original Message-----
From: Maxime Coquelin [mailto:[email protected]]
Sent: Sunday, March 11, 2018 2:24 AM
To: Wang, Xiao W <[email protected]>; [email protected]
Cc: Wang, Zhihong <[email protected]>; [email protected]; Liang, Cunming <[email protected]>; Xu, Rosen <[email protected]>;Chen,
Quoted 38 lines
Quoted 37 lines
Junjie J <[email protected]>; Daly, Dan <[email protected]>
Subject: Re: [PATCH 0/3] add ifcvf driverHi Xiao,
Quoted 1 line · Xiao Wang
This patch set has dependency on
http://dpdk.org/dev/patchwork/patch/35635/
Quoted 9 lines
(vhost: support selective datapath);
ifc VF is compatible with virtio vring operations, this driver implements vDPA driver ops which configures ifc VF to be a vhost data path accelerator.
ifcvf driver uses vdev as a control domain to manage ifc VFs that belong to it. It registers vDPA device ops to vhost lib to enable these VFs to be used as vhost data path accelerator.
Quoted 5 lines
Live migration feature is supported by ifc VF and this driver enables it based on vhost lib.
vDPA needs to create different containers for different devices, thus this patch set adds APIs in eal/vfio to support multiple container.
Thanks for this! That will avoind having to duplicate these functions for every new offload driver.
Quoted 6 lines
Junjie Chen (1):
eal/vfio: add support for multiple containerXiao Wang (2):
bus/pci: expose sysfs parsing APIStill, I'm not convinced the offload device should be a virtual device. It is a real PCI device, why not having a new device type for offload devices, and let the device to be probed automatically by the existing device model?
Quoted 7 lines
Quoted 3 lines
IFC VFs are generated from SRIOV, with the PF driven by kernel driver. In DPDK we need to have something to represent PF, to register itself as a vDPA engine, so a virtual device is used for this purpose.
I went through the code, and something is not clear to me.
Why do we need to have a representation of the PF in DPDK? Why cannot we just bind at VF level?
1. With the vdev representation we could use it to talk to PF kernel driver to do flow configuration, we can implement flow API on the vdev in future for this purpose. Using a vdev allows introducing this kind of control plane thing.
2. When port representor is ready, we would integrate it into ifcvf driver, then each VF will have a Representor port. For now we don’t have port representor, so this patch set manages VF resource internally.
BRs,
Xiao
Re: [PATCH v2 3/3] net/ifcvf: add ifcvf driver
In reply to Maxime CoquelinHi Maxime,
Quoted 105 lines
-----Original Message-----
From: Maxime Coquelin [mailto:[email protected]]
Sent: Thursday, March 22, 2018 4:58 AM
To: Wang, Xiao W <[email protected]>; [email protected]
Cc: [email protected]; Wang, Zhihong <[email protected]>; Bie, Tiwei <[email protected]>; Chen, Junjie J <[email protected]>; Xu, Rosen <[email protected]>; Daly, Dan <[email protected]>; Liang, Cunming <[email protected]>; Burakov, Anatoly <[email protected]>; [email protected]
Subject: Re: [PATCH v2 3/3] net/ifcvf: add ifcvf driverQuoted 15 lines · Xiao Wang
ifcvf driver uses vdev as a control domain to manage ifc VFs that belong to it. It registers vDPA device ops to vhost lib to enable these VFs to be used as vhost data path accelerator.
Live migration feature is supported by ifc VF and this driver enables it based on vhost lib.
Because vDPA driver needs to set up MSI-X vector to interrupt the guest, only vfio-pci is supported currently.
Signed-off-by Xiao Wang <[email protected]>Signed-off-by Rosen Xu <[email protected]>---
v2:
- Rebase on Zhihong's vDPA v3 patch set.Quoted 9 lines
--- config/common_base | 6 + config/common_linuxapp | 1 + drivers/net/Makefile | 1 + drivers/net/ifcvf/Makefile | 40 + drivers/net/ifcvf/base/ifcvf.c | 329 ++++++++ drivers/net/ifcvf/base/ifcvf.h | 156 ++++ drivers/net/ifcvf/base/ifcvf_osdep.h | 52 ++ drivers/net/ifcvf/ifcvf_ethdev.c | 1240+++++++++++++++++++++++++++++++
Quoted 10 lines
drivers/net/ifcvf/rte_ifcvf_version.map | 4 + mk/rte.app.mk | 1 + 10 files changed, 1830 insertions(+)create mode 100644
drivers/net/ifcvf/Makefilecreate mode 100644drivers/net/ifcvf/base/ifcvf.ccreate mode 100644drivers/net/ifcvf/base/ifcvf.hcreate mode 100644drivers/net/ifcvf/base/ifcvf_osdep.hcreate mode 100644drivers/net/ifcvf/ifcvf_ethdev.ccreate mode 100644drivers/net/ifcvf/rte_ifcvf_version.map...
Quoted 53 lines
drivers/net/ifcvf/ifcvf_ethdev.c new file +53
-0+static int +eth_dev_ifcvf_create (struct rte_vdev_device *dev, +struct rte_pci_addr *pci_addr,int devices) +{ +const char *name =rte_vdev_device_name (dev); +struct rte_eth_dev *eth_dev =NULL ; +struct ether_addr *eth_addr =NULL ; +struct ifcvf_internal *internal =NULL ; +struct internal_list *list =NULL ; +struct rte_eth_dev_data *data =NULL ; +struct rte_pci_addr pf_addr = *pci_addr; +int i; + + list =rte_zmalloc_socket (name,sizeof (*list),0 , + dev->device.numa_node); +if (list ==NULL ) + goto error; + +/* reserve an ethdev entry */ + eth_dev =rte_eth_vdev_allocate (dev,sizeof (*internal)); +if (eth_dev ==NULL ) + goto error; + + eth_addr =rte_zmalloc_socket (name,sizeof (*eth_addr),0 , + dev->device.numa_node); +if (eth_addr ==NULL ) + goto error; + + *eth_addr = base_eth_addr; + eth_addr->addr_bytes[5 ] = eth_dev->data->port_id; + + internal = eth_dev->data->dev_private; + internal->dev_name =strdup (name); +if (internal->dev_name ==NULL ) + goto error; + + internal->eng_addr.pci_addr = *pci_addr; +for (i =0 ; i < devices; i++) { + pf_addr.domain = pci_addr->domain; + pf_addr.bus = pci_addr->bus; + pf_addr.devid = pci_addr->devid + (i +1 ) /8 ; + pf_addr.function = pci_addr->function + (i +1 ) %8 ; + internal->vf_info[i].pdev.addr = pf_addr; +rte_spinlock_init (&internal->vf_info[i].lock); + } + internal->max_devices = devices; + + list->eth_dev = eth_dev; +pthread_mutex_lock (&internal_list_lock); +TAILQ_INSERT_TAIL (&internal_list, list, next); +pthread_mutex_unlock (&internal_list_lock); + + data = eth_dev->data;
Quoted 8 lines
drivers/net/ifcvf/ifcvf_ethdev.c line 1087
Quoted 4 lines
drivers/net/ifcvf/ifcvf_ethdev.c new file +4
-0+ data->nb_rx_queues =IFCVF_MAX_QUEUES ; + data->nb_tx_queues =IFCVF_MAX_QUEUES ; + data->dev_link = vdpa_link; + data->mac_addrs = eth_addr;We might want one ethernet device per VF, as for example you set dev_link.link_status to UP as soon as a VF is configured, and DOWN as when a single VF is removed.
Ideally it will be one representor port per VF, each representor port has a link_status. Will integrate port representor when it's ready. I will remove the vdev's ethdev registering for now, and add it back when we need to implement flow APIs on the vdev.
Quoted 69 lines
Quoted 18 lines
drivers/net/ifcvf/ifcvf_ethdev.c new file +17
-0+ data->dev_flags =RTE_ETH_DEV_INTR_LSC ; + eth_dev->dev_ops = &ops; + +/* assign rx and tx ops, could be used as vDPA fallback */ + eth_dev->rx_pkt_burst = eth_ifcvf_rx; + eth_dev->tx_pkt_burst = eth_ifcvf_tx; + +if (rte_vdpa_register_engine (vdpa_ifcvf_driver.name, + &internal->eng_addr) <0 ) + goto error; + +return 0 ; + +error: +rte_free (list); +rte_free (eth_addr); +if (internal && internal->dev_name)drivers/net/ifcvf/ifcvf_ethdev.c
Quoted 10 lines
drivers/net/ifcvf/ifcvf_ethdev.c new file +10
-0+free (internal->dev_name); +rte_free (internal); +if (eth_dev) +rte_eth_dev_release_port (eth_dev); + +return -1 ; +} + +static int +get_pci_addr(const char *key __rte_unused, const char *value, void
*extra_args)drivers/net/ifcvf/ifcvf_ethdev.c
Quoted 9 lines
drivers/net/ifcvf/ifcvf_ethdev.c new file +9
-0+{ +if (value ==NULL || extra_args ==NULL ) +return -1 ; + +return rte_pci_addr_parse (value, extra_args); +} + +static inline int +open_int(const char *key __rte_unused, const char *value, void
*extra_args)Quoted 19 lines
drivers/net/ifcvf/ifcvf_ethdev.c new file +19
-0+{ +uint16_t *n = extra_args; + +if (value ==NULL || extra_args ==NULL ) +return -EINVAL ; + + *n = (uint16_t )strtoul (value,NULL ,0 ); +if (*n ==USHRT_MAX && errno ==ERANGE ) +return -1 ; + +return 0 ; +} + +/* +* If this vdev is created by user, then ifcvf will be taken by +* this vdev. +*/ +static int +ifcvf_take_over (struct rte_pci_addr *pci_addr,int num)drivers/net/ifcvf/ifcvf_ethdev.c
Quoted 10 lines
drivers/net/ifcvf/ifcvf_ethdev.c new file +10
-0+{ +uint16_t port_id; +int i, ret; +char devname[RTE_DEV_NAME_MAX_LEN ]; +struct rte_pci_addr vf_addr = *pci_addr; + +for (i =0 ; i < num; i++) { + vf_addr.function += i %8 ; + vf_addr.devid += i /8 ; + rte_pci_device_name(&vf_addr, devname,
RTE_DEV_NAME_MAX_LEN);
Quoted 8 lines
drivers/net/ifcvf/ifcvf_ethdev.c line 1158
Quoted 6 lines
drivers/net/ifcvf/ifcvf_ethdev.c new file +6
-0+ ret =rte_eth_dev_get_port_by_name (devname, &port_id); +if (ret ==0 ) { +rte_eth_dev_close (port_id); +if (rte_eth_dev_detach (port_id, devname) <0 ) +return -1 ; + }That seems a bit hard.
Shouldn't we at least check the port is not started?
That looks better, will do it.
Thanks for the comments,
-Xiao
Re: [PATCH v2 3/3] net/ifcvf: add ifcvf driver
In reply to Thomas MonjalonHi Thomas,
Quoted 11 lines
-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Thursday, March 22, 2018 4:52 AM
To: Wang, Xiao W <[email protected]>; Xu, Rosen <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Wang, Zhihong <[email protected]>; Bie, Tiwei <[email protected]>; Chen, Junjie J <[email protected]>; Daly, Dan <[email protected]>; Liang, Cunming <[email protected]>; Burakov, Anatoly <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v2 3/3] net/ifcvf: add ifcvf driver
Quoted 7 lines
21/03/2018 14:21, Xiao Wang:
Quoted 3 lines
ifcvf driver uses vdev as a control domain to manage ifc VFs that belong to it. It registers vDPA device ops to vhost lib to enable these VFs to be used as vhost data path accelerator.
Not everybody work at Intel.
Please explain what means ifcvf and what is a control domain.
OK, and I will add a document.
Quoted 21 lines
Quoted 12 lines
Live migration feature is supported by ifc VF and this driver enables it based on vhost lib.
Because vDPA driver needs to set up MSI-X vector to interrupt the guest, only vfio-pci is supported currently.
Signed-off-by Xiao Wang <[email protected]>Signed-off-by Rosen Xu <[email protected]>---
v2:
- Rebase on Zhihong's vDPA v3 patch set.Quoted 9 lines
--- config/common_base | 6 + config/common_linuxapp | 1 + drivers/net/Makefile | 1 + drivers/net/ifcvf/Makefile | 40 + drivers/net/ifcvf/base/ifcvf.c | 329 ++++++++ drivers/net/ifcvf/base/ifcvf.h | 156 ++++ drivers/net/ifcvf/base/ifcvf_osdep.h | 52 ++ drivers/net/ifcvf/ifcvf_ethdev.c | 1240
Quoted 8 lines
+++++++++++++++++++++++++++++++
Quoted 2 lines
drivers/net/ifcvf/rte_ifcvf_version.map | 4 + mk/rte.app.mk | 1 +This feature needs to be explained and documented.
It will be helpful to understand the mechanism and to have a good review. Please do not merge it until there is a good documentation.
Will add a doc with more details.
BRs,
Xiao
Quoted 66 lines · Xiao W
Hi Maxime,
Quoted 64 lines
-----Original Message-----
From: Maxime Coquelin [mailto:[email protected]]
Sent: Thursday, March 22, 2018 4:48 AM
To: Wang, Xiao W <[email protected]>; [email protected]
Cc: Wang, Zhihong <[email protected]>; [email protected]; Liang, Cunming <[email protected]>; Xu, Rosen <[email protected]>; Chen, Junjie J <[email protected]>; Daly, Dan <[email protected]>
Subject: Re: [PATCH 0/3] add ifcvf driverHi Xiao,
Quoted 8 lines · Xiao W
Hi Maxime,
Quoted 6 lines
-----Original Message-----
From: Maxime Coquelin [mailto:[email protected]]
Sent: Sunday, March 11, 2018 2:24 AM
To: Wang, Xiao W <[email protected]>; [email protected]
Cc: Wang, Zhihong <[email protected]>; [email protected]; Liang, Cunming <[email protected]>; Xu, Rosen <[email protected]>;Chen,
Quoted 33 lines
Quoted 33 lines
Junjie J <[email protected]>; Daly, Dan <[email protected]>
Subject: Re: [PATCH 0/3] add ifcvf driverHi Xiao,
Quoted 1 line · Xiao Wang
This patch set has dependency on
http://dpdk.org/dev/patchwork/patch/35635/
Quoted 9 lines
(vhost: support selective datapath);
ifc VF is compatible with virtio vring operations, this driver implements vDPA driver ops which configures ifc VF to be a vhost data path accelerator.
ifcvf driver uses vdev as a control domain to manage ifc VFs that belong to it. It registers vDPA device ops to vhost lib to enable these VFs to be used as vhost data path accelerator.
Quoted 5 lines
Live migration feature is supported by ifc VF and this driver enables it based on vhost lib.
vDPA needs to create different containers for different devices, thus this patch set adds APIs in eal/vfio to support multiple container.
Thanks for this! That will avoind having to duplicate these functions for every new offload driver.
Quoted 6 lines
Junjie Chen (1):
eal/vfio: add support for multiple containerXiao Wang (2):
bus/pci: expose sysfs parsing APIQuoted 8 lines
Quoted 4 lines
Still, I'm not convinced the offload device should be a virtual device. It is a real PCI device, why not having a new device type for offload devices, and let the device to be probed automatically by the existing device model?
IFC VFs are generated from SRIOV, with the PF driven by kernel driver. In DPDK we need to have something to represent PF, to register itself as a vDPA engine, so a virtual device is used for this purpose.
I went through the code, and something is not clear to me.
Quoted 8 lines
Quoted 2 lines
Why do we need to have a representation of the PF in DPDK? Why cannot we just bind at VF level?
1. With the vdev representation we could use it to talk to PF kernel driver to do flow configuration, we can implement flow API on the vdev in future for this purpose. Using a vdev allows introducing this kind of control plane thing.
2. When port representor is ready, we would integrate it into ifcvf driver, then each VF will have a Representor port. For now we don’t have port representor, so this patch set manages VF resource internally.
Ok, we may need to have a vdev to represent the PF, but we need to be able to bind at VF level anyway.
Else, how do you support passing two VFs of the same PF to different DPDK applications?
Or have some VFs managed by Kernel or QEMU and some by the DPDK application? My feeling is that current implementation is creating an artificial constraint.
Isn't there a possibility to have the virtual representation for the PF to be probed separately? Or created automatically when the first VF of a PF is probed (and later VFs attach to the PF rep when probed)?
Doing this, we could use the generic device probing.
For IFCVF, to specify we want it to be probed as an offload device instead of a virtio device, we could have a new EAL parameter to specify for a given device if we want it to be probed as an offload device (for example --offload=00:01.1).
Offload drivers would register by passing a flag that specifies they are an offload driver.
This new argument would be optional and only used to force the device to being probed in offload mode. For devices that have their own device IDs for offload mode, then it would be automatic.
Regards,
Maxime
Quoted 3 lines
BRs,
Xiao
Hi Maxime,
Quoted 89 lines
-----Original Message-----
From: Maxime Coquelin [mailto:[email protected]]
Sent: Sunday, March 25, 2018 5:51 PM
To: Wang, Xiao W <[email protected]>; [email protected]
Cc: Wang, Zhihong <[email protected]>; [email protected]; Liang, Cunming <[email protected]>; Xu, Rosen <[email protected]>; Chen, Junjie J <[email protected]>; Daly, Dan <[email protected]>
Subject: Re: [PATCH 0/3] add ifcvf driverQuoted 8 lines · Xiao W
Hi Maxime,
Quoted 6 lines
-----Original Message-----
From: Maxime Coquelin [mailto:[email protected]]
Sent: Thursday, March 22, 2018 4:48 AM
To: Wang, Xiao W <[email protected]>; [email protected]
Cc: Wang, Zhihong <[email protected]>; [email protected]; Liang, Cunming <[email protected]>; Xu, Rosen <[email protected]>;Chen,
Quoted 5 lines
Quoted 5 lines
Junjie J <[email protected]>; Daly, Dan <[email protected]>
Subject: Re: [PATCH 0/3] add ifcvf driverHi Xiao,
Quoted 8 lines
Quoted 8 lines · Xiao W
Quoted 7 lines
Hi Maxime,
Quoted 5 lines
-----Original Message-----
From: Maxime Coquelin [mailto:[email protected]]
Sent: Sunday, March 11, 2018 2:24 AM
To: Wang, Xiao W <[email protected]>; [email protected]
Cc: Wang, Zhihong <[email protected]>; [email protected];Liang,
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Cunming <[email protected]>; Xu, Rosen <[email protected]>;
Chen,
Quoted 5 lines
Quoted 5 lines
Junjie J <[email protected]>; Daly, Dan <[email protected]>
Subject: Re: [PATCH 0/3] add ifcvf driverHi Xiao,
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines · Xiao Wang
Quoted 1 line
This patch set has dependency on
http://dpdk.org/dev/patchwork/patch/35635/
Quoted 4 lines
(vhost: support selective datapath);
ifc VF is compatible with virtio vring operations, this driver implements vDPA driver ops which configures ifc VF to be a vhost data path
accelerator.
Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
Quoted 18 lines
Quoted 10 lines
ifcvf driver uses vdev as a control domain to manage ifc VFs that belong to it. It registers vDPA device ops to vhost lib to enable these VFs to be used as vhost data path accelerator.
Live migration feature is supported by ifc VF and this driver enables it based on vhost lib.
vDPA needs to create different containers for different devices, thus this patch set adds APIs in eal/vfio to support multiple container.
Thanks for this! That will avoind having to duplicate these functions for every new offload driver.
Quoted 4 lines
Junjie Chen (1):
eal/vfio: add support for multiple containerQuoted 7 lines
Quoted 2 lines
Xiao Wang (2):
bus/pci: expose sysfs parsing APIStill, I'm not convinced the offload device should be a virtual device. It is a real PCI device, why not having a new device type for offload devices, and let the device to be probed automatically by the existing device model?
IFC VFs are generated from SRIOV, with the PF driven by kernel driver. In DPDK we need to have something to represent PF, to register itself as a vDPA engine, so a virtual device is used for this purpose.
Quoted 6 lines
Quoted 4 lines
I went through the code, and something is not clear to me.
Why do we need to have a representation of the PF in DPDK? Why cannot we just bind at VF level?
1. With the vdev representation we could use it to talk to PF kernel driver to
do flow configuration, we can implement
Quoted 1 line
flow API on the vdev in future for this purpose. Using a vdev allows
introducing this kind of control plane thing.
Quoted 1 line
Quoted 7 lines
Quoted 1 line
2. When port representor is ready, we would integrate it into ifcvf driver,
then each VF will have a
Quoted 1 line
Representor port. For now we don’t have port representor, so this patch set
manages VF resource internally.
Ok, we may need to have a vdev to represent the PF, but we need to be able to bind at VF level anyway.
Device management on VF level is feasible, according to the previous port-representor patch. A tuple of (PF_addr, VF_index) can identify a certain VF, we have vport_mask and device addr to describe a PF, and we can specify a VF index to create a representor port, so , the VF port creation will be on-demand at VF level.
+struct port_rep_parameters {
+ uint64_t vport_mask;
+ struct {
+ char bus[RTE_DEV_NAME_MAX_LEN];
+ char device[RTE_DEV_NAME_MAX_LEN];
+ } parent;
+};
+int
+rte_representor_port_register(char *pf_addr_str,
+ uint32_t vport_id, uint16_t *port_id)
Besides, IFCVF supports live migration, vDPA exerts IFCVF device better than QEMU (this patch has enabled LM feature). vDPA is the main usage model for IFCVF, and one DPDK application taking control of all the VF resource management is a straightforward usage model.
Best Regards,
Xiao
Quoted 27 lines
Else, how do you support passing two VFs of the same PF to different DPDK applications?
Or have some VFs managed by Kernel or QEMU and some by the DPDK application? My feeling is that current implementation is creating an artificial constraint.Isn't there a possibility to have the virtual representation for the PF to be probed separately? Or created automatically when the first VF of a PF is probed (and later VFs attach to the PF rep when probed)?
Doing this, we could use the generic device probing.
For IFCVF, to specify we want it to be probed as an offload device instead of a virtio device, we could have a new EAL parameter to specify for a given device if we want it to be probed as an offload device (for example --offload=00:01.1).
Offload drivers would register by passing a flag that specifies they are an offload driver.
This new argument would be optional and only used to force the device to being probed in offload mode. For devices that have their own device IDs for offload mode, then it would be automatic.Regards,
MaximeQuoted 3 lines
BRs,
Xiao
Quoted 105 lines · Xiao W
Hi Maxime,
Quoted 89 lines
-----Original Message-----
From: Maxime Coquelin [mailto:[email protected]]
Sent: Sunday, March 25, 2018 5:51 PM
To: Wang, Xiao W <[email protected]>; [email protected]
Cc: Wang, Zhihong <[email protected]>; [email protected]; Liang, Cunming <[email protected]>; Xu, Rosen <[email protected]>; Chen, Junjie J <[email protected]>; Daly, Dan <[email protected]>
Subject: Re: [PATCH 0/3] add ifcvf driverQuoted 8 lines · Xiao W
Hi Maxime,
Quoted 6 lines
-----Original Message-----
From: Maxime Coquelin [mailto:[email protected]]
Sent: Thursday, March 22, 2018 4:48 AM
To: Wang, Xiao W <[email protected]>; [email protected]
Cc: Wang, Zhihong <[email protected]>; [email protected]; Liang, Cunming <[email protected]>; Xu, Rosen <[email protected]>;Chen,
Quoted 5 lines
Quoted 5 lines
Junjie J <[email protected]>; Daly, Dan <[email protected]>
Subject: Re: [PATCH 0/3] add ifcvf driverHi Xiao,
Quoted 8 lines
Quoted 8 lines · Xiao W
Quoted 7 lines
Hi Maxime,
Quoted 5 lines
-----Original Message-----
From: Maxime Coquelin [mailto:[email protected]]
Sent: Sunday, March 11, 2018 2:24 AM
To: Wang, Xiao W <[email protected]>; [email protected]
Cc: Wang, Zhihong <[email protected]>; [email protected];Liang,
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Cunming <[email protected]>; Xu, Rosen <[email protected]>;
Chen,
Quoted 5 lines
Quoted 5 lines
Junjie J <[email protected]>; Daly, Dan <[email protected]>
Subject: Re: [PATCH 0/3] add ifcvf driverHi Xiao,
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines · Xiao Wang
Quoted 1 line
This patch set has dependency on
http://dpdk.org/dev/patchwork/patch/35635/
Quoted 4 lines
(vhost: support selective datapath);
ifc VF is compatible with virtio vring operations, this driver implements vDPA driver ops which configures ifc VF to be a vhost data path
accelerator.
Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
Quoted 18 lines
Quoted 10 lines
ifcvf driver uses vdev as a control domain to manage ifc VFs that belong to it. It registers vDPA device ops to vhost lib to enable these VFs to be used as vhost data path accelerator.
Live migration feature is supported by ifc VF and this driver enables it based on vhost lib.
vDPA needs to create different containers for different devices, thus this patch set adds APIs in eal/vfio to support multiple container.
Thanks for this! That will avoind having to duplicate these functions for every new offload driver.
Quoted 4 lines
Junjie Chen (1):
eal/vfio: add support for multiple containerQuoted 7 lines
Quoted 2 lines
Xiao Wang (2):
bus/pci: expose sysfs parsing APIStill, I'm not convinced the offload device should be a virtual device. It is a real PCI device, why not having a new device type for offload devices, and let the device to be probed automatically by the existing device model?
IFC VFs are generated from SRIOV, with the PF driven by kernel driver. In DPDK we need to have something to represent PF, to register itself as a vDPA engine, so a virtual device is used for this purpose.
Quoted 6 lines
Quoted 4 lines
I went through the code, and something is not clear to me.
Why do we need to have a representation of the PF in DPDK? Why cannot we just bind at VF level?
1. With the vdev representation we could use it to talk to PF kernel driver to
do flow configuration, we can implement
Quoted 1 line
flow API on the vdev in future for this purpose. Using a vdev allows
introducing this kind of control plane thing.
Quoted 1 line
Quoted 7 lines
Quoted 1 line
2. When port representor is ready, we would integrate it into ifcvf driver,
then each VF will have a
Quoted 1 line
Representor port. For now we don’t have port representor, so this patch set
manages VF resource internally.
Ok, we may need to have a vdev to represent the PF, but we need to be able to bind at VF level anyway.
Device management on VF level is feasible, according to the previous port-representor patch. A tuple of (
PF_addr,VF_index) can identify a certain VF, we havevport_maskand device addr to describe a PF, and we can specify a VF index to create a representor port, so , the VF port creation will be on-demand at VF level.(quoted diff) +1
-0+struct port_rep_parameters {
Review
Quoted 10 lines
(quoted diff) +9
-0+ uint64_t vport_mask; + struct { + char bus[RTE_DEV_NAME_MAX_LEN]; + char device[RTE_DEV_NAME_MAX_LEN]; + } parent; +}; +int +rte_representor_port_register(char *pf_addr_str, + uint32_t vport_id, uint16_t *port_id)
IIUC, even with this using port representor, we'll still have the problem of having the VFs probed first as Virtio driver, right?
In my opinion, the IFCVF devices in offload mode are to be managed differently than having a way to represent on host side VFs assigned to a VM.
In offload case, you have a real device to deal with, else we wouldn't have to bind it with VFIO.
Maybe we could have a real device probed as proposed yesterday [0], and this device gets registered to the port representor for the PF?
Thanks,
Maxime
Quoted 4 lines
Besides, IFCVF supports live migration, vDPA exerts IFCVF device better than QEMU (this patch has enabled LM feature). vDPA is the main usage model for IFCVF, and one DPDK application taking control of all the VF resource management is a straightforward usage model.
Quoted 15 lines
Best Regards,
XiaoQuoted 12 lines
Else, how do you support passing two VFs of the same PF to different DPDK applications?
Or have some VFs managed by Kernel or QEMU and some by the DPDK application? My feeling is that current implementation is creating an artificial constraint.Isn't there a possibility to have the virtual representation for the PF to be probed separately? Or created automatically when the first VF of a PF is probed (and later VFs attach to the PF rep when probed)?
Doing this, we could use the generic device probing.
[0]:
Quoted 15 lines
Quoted 15 lines
For IFCVF, to specify we want it to be probed as an offload device instead of a virtio device, we could have a new EAL parameter to specify for a given device if we want it to be probed as an offload device (for example --offload=00:01.1).
Offload drivers would register by passing a flag that specifies they are an offload driver.
This new argument would be optional and only used to force the device to being probed in offload mode. For devices that have their own device IDs for offload mode, then it would be automatic.Regards,
MaximeQuoted 3 lines
BRs,
Xiao
Hi Maxime,
Quoted 146 lines
-----Original Message-----
From: Maxime Coquelin [mailto:[email protected]]
Sent: Monday, March 26, 2018 9:30 PM
To: Wang, Xiao W <[email protected]>; [email protected]
Cc: Wang, Zhihong <[email protected]>; [email protected]; Liang, Cunming <[email protected]>; Xu, Rosen <[email protected]>; Chen, Junjie J <[email protected]>; Daly, Dan <[email protected]>
Subject: Re: [PATCH 0/3] add ifcvf driverQuoted 8 lines · Xiao W
Hi Maxime,
Quoted 6 lines
-----Original Message-----
From: Maxime Coquelin [mailto:[email protected]]
Sent: Sunday, March 25, 2018 5:51 PM
To: Wang, Xiao W <[email protected]>; [email protected]
Cc: Wang, Zhihong <[email protected]>; [email protected]; Liang, Cunming <[email protected]>; Xu, Rosen <[email protected]>;Chen,
Quoted 5 lines
Quoted 5 lines
Junjie J <[email protected]>; Daly, Dan <[email protected]>
Subject: Re: [PATCH 0/3] add ifcvf driverQuoted 8 lines
Quoted 8 lines · Xiao W
Quoted 7 lines
Hi Maxime,
Quoted 5 lines
-----Original Message-----
From: Maxime Coquelin [mailto:[email protected]]
Sent: Thursday, March 22, 2018 4:48 AM
To: Wang, Xiao W <[email protected]>; [email protected]
Cc: Wang, Zhihong <[email protected]>; [email protected];Liang,
Quoted 10 lines
Quoted 10 lines
Quoted 1 line
Quoted 1 line
Cunming <[email protected]>; Xu, Rosen <[email protected]>;
Chen,
Quoted 8 lines
Quoted 8 lines
Junjie J <[email protected]>; Daly, Dan <[email protected]>
Subject: Re: [PATCH 0/3] add ifcvf driverHi Xiao,
Quoted 2 lines · Xiao W
Hi Maxime,
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
-----Original Message-----
From: Maxime Coquelin [mailto:[email protected]]
Sent: Sunday, March 11, 2018 2:24 AM
To: Wang, Xiao W <[email protected]>; [email protected]
Cc: Wang, Zhihong <[email protected]>; [email protected];Liang,
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Cunming <[email protected]>; Xu, Rosen
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Chen,
Quoted 3 lines
Quoted 3 lines
Junjie J <[email protected]>; Daly, Dan <[email protected]>
Subject: Re: [PATCH 0/3] add ifcvf driverQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Hi Xiao,
Quoted 1 line · Xiao Wang
This patch set has dependency on
http://dpdk.org/dev/patchwork/patch/35635/
Quoted 3 lines
(vhost: support selective datapath);
ifc VF is compatible with virtio vring operations, this driver
implements
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
vDPA driver ops which configures ifc VF to be a vhost data path
accelerator.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
ifcvf driver uses vdev as a control domain to manage ifc VFs that
belong
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
to it. It registers vDPA device ops to vhost lib to enable these VFs to
be
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
used as vhost data path accelerator.
Live migration feature is supported by ifc VF and this driver enables it based on vhost lib.
vDPA needs to create different containers for different devices, thus
this
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 9 lines
Quoted 1 line
patch set adds APIs in eal/vfio to support multiple container.
Thanks for this! That will avoind having to duplicate these functions for every new offload driver.
Quoted 4 lines
Junjie Chen (1):
eal/vfio: add support for multiple containerQuoted 7 lines
Quoted 2 lines
Xiao Wang (2):
bus/pci: expose sysfs parsing APIStill, I'm not convinced the offload device should be a virtual device. It is a real PCI device, why not having a new device type for offload devices, and let the device to be probed automatically by the existing device model?
IFC VFs are generated from SRIOV, with the PF driven by kernel driver. In DPDK we need to have something to represent PF, to register itself as a vDPA engine, so a virtual device is used for this purpose.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
I went through the code, and something is not clear to me.
Why do we need to have a representation of the PF in DPDK? Why cannot we just bind at VF level?
1. With the vdev representation we could use it to talk to PF kernel driver
to
Quoted 7 lines
Quoted 7 lines
do flow configuration, we can implement
Quoted 1 line
flow API on the vdev in future for this purpose. Using a vdev allows
introducing this kind of control plane thing.
Quoted 2 lines
2. When port representor is ready, we would integrate it into ifcvf driver,
then each VF will have a
Quoted 1 line
Representor port. For now we don’t have port representor, so this patch
set
Quoted 6 lines
Quoted 4 lines
manages VF resource internally.
Ok, we may need to have a vdev to represent the PF, but we need to be able to bind at VF level anyway.
Device management on VF level is feasible, according to the previous port-
representor patch.
Quoted 2 lines
A tuple of (
PF_addr,VF_index) can identify a certain VF, we havevport_maskand device addr to describe a PF, and we can specify a VF index to create arepresentor port,
Review
Quoted 13 lines
so , the VF port creation will be on-demand at VF level.
(quoted diff) +10
-0+struct port_rep_parameters { + uint64_t vport_mask; + struct { + char bus[RTE_DEV_NAME_MAX_LEN]; + char device[RTE_DEV_NAME_MAX_LEN]; + } parent; +}; +int +rte_representor_port_register(char *pf_addr_str, + uint32_t vport_id, uint16_t *port_id)IIUC, even with this using port representor, we'll still have the problem of having the VFs probed first as Virtio driver, right?
In my opinion, the IFCVF devices in offload mode are to be managed differently than having a way to represent on host side VFs assigned to a VM.
Quoted 5 lines
In offload case, you have a real device to deal with, else we wouldn't have to bind it with VFIO.
Maybe we could have a real device probed as proposed yesterday [0], and this device gets registered to the port representor for the PF?
Adding a list of offload-device in eal is a way to skip virtio pmd probe [0]. I think using device devargs could also achieve that: add a parameter "vdpa=1" to the device, virtio pmd parses the devargs and detects that the device is in vdpa mode, quits its probe immediately.
Devargs could be flexible of allowing one device with multi driver case.
BRs,
Xiao
Quoted 41 lines
Thanks,
MaximeQuoted 1 line
Besides, IFCVF supports live migration, vDPA exerts IFCVF device better than
QEMU (this patch has enabled LM feature).
Quoted 1 line
vDPA is the main usage model for IFCVF, and one DPDK application taking
control of all the VF resource
Quoted 17 lines
management is a straightforward usage model.
Best Regards,
XiaoQuoted 12 lines
Else, how do you support passing two VFs of the same PF to different DPDK applications?
Or have some VFs managed by Kernel or QEMU and some by the DPDK application? My feeling is that current implementation is creating an artificial constraint.Isn't there a possibility to have the virtual representation for the PF to be probed separately? Or created automatically when the first VF of a PF is probed (and later VFs attach to the PF rep when probed)?
Doing this, we could use the generic device probing.
[0]:
Quoted 15 lines
Quoted 15 lines
For IFCVF, to specify we want it to be probed as an offload device instead of a virtio device, we could have a new EAL parameter to specify for a given device if we want it to be probed as an offload device (for example --offload=00:01.1).
Offload drivers would register by passing a flag that specifies they are an offload driver.
This new argument would be optional and only used to force the device to being probed in offload mode. For devices that have their own device IDs for offload mode, then it would be automatic.Regards,
MaximeQuoted 3 lines
BRs,
Xiao
Hi Xiao,
Quoted 151 lines · Xiao W
Hi Maxime,
Quoted 149 lines
-----Original Message-----
From: Maxime Coquelin [mailto:[email protected]]
Sent: Monday, March 26, 2018 9:30 PM
To: Wang, Xiao W <[email protected]>; [email protected]
Cc: Wang, Zhihong <[email protected]>; [email protected]; Liang, Cunming <[email protected]>; Xu, Rosen <[email protected]>; Chen, Junjie J <[email protected]>; Daly, Dan <[email protected]>
Subject: Re: [PATCH 0/3] add ifcvf driverQuoted 8 lines · Xiao W
Hi Maxime,
Quoted 6 lines
-----Original Message-----
From: Maxime Coquelin [mailto:[email protected]]
Sent: Sunday, March 25, 2018 5:51 PM
To: Wang, Xiao W <[email protected]>; [email protected]
Cc: Wang, Zhihong <[email protected]>; [email protected]; Liang, Cunming <[email protected]>; Xu, Rosen <[email protected]>;Chen,
Quoted 5 lines
Quoted 5 lines
Junjie J <[email protected]>; Daly, Dan <[email protected]>
Subject: Re: [PATCH 0/3] add ifcvf driverQuoted 8 lines
Quoted 8 lines · Xiao W
Quoted 7 lines
Hi Maxime,
Quoted 5 lines
-----Original Message-----
From: Maxime Coquelin [mailto:[email protected]]
Sent: Thursday, March 22, 2018 4:48 AM
To: Wang, Xiao W <[email protected]>; [email protected]
Cc: Wang, Zhihong <[email protected]>; [email protected];Liang,
Quoted 10 lines
Quoted 10 lines
Quoted 1 line
Quoted 1 line
Cunming <[email protected]>; Xu, Rosen <[email protected]>;
Chen,
Quoted 8 lines
Quoted 8 lines
Junjie J <[email protected]>; Daly, Dan <[email protected]>
Subject: Re: [PATCH 0/3] add ifcvf driverHi Xiao,
Quoted 2 lines · Xiao W
Hi Maxime,
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
-----Original Message-----
From: Maxime Coquelin [mailto:[email protected]]
Sent: Sunday, March 11, 2018 2:24 AM
To: Wang, Xiao W <[email protected]>; [email protected]
Cc: Wang, Zhihong <[email protected]>; [email protected];Liang,
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Cunming <[email protected]>; Xu, Rosen
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Chen,
Quoted 3 lines
Quoted 3 lines
Junjie J <[email protected]>; Daly, Dan <[email protected]>
Subject: Re: [PATCH 0/3] add ifcvf driverQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Hi Xiao,
Quoted 1 line · Xiao Wang
This patch set has dependency on
http://dpdk.org/dev/patchwork/patch/35635/
Quoted 3 lines
(vhost: support selective datapath);
ifc VF is compatible with virtio vring operations, this driver
implements
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
vDPA driver ops which configures ifc VF to be a vhost data path
accelerator.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
ifcvf driver uses vdev as a control domain to manage ifc VFs that
belong
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
to it. It registers vDPA device ops to vhost lib to enable these VFs to
be
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
used as vhost data path accelerator.
Live migration feature is supported by ifc VF and this driver enables it based on vhost lib.
vDPA needs to create different containers for different devices, thus
this
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 9 lines
Quoted 1 line
patch set adds APIs in eal/vfio to support multiple container.
Thanks for this! That will avoind having to duplicate these functions for every new offload driver.
Quoted 4 lines
Junjie Chen (1):
eal/vfio: add support for multiple containerQuoted 7 lines
Quoted 2 lines
Xiao Wang (2):
bus/pci: expose sysfs parsing APIStill, I'm not convinced the offload device should be a virtual device. It is a real PCI device, why not having a new device type for offload devices, and let the device to be probed automatically by the existing device model?
IFC VFs are generated from SRIOV, with the PF driven by kernel driver. In DPDK we need to have something to represent PF, to register itself as a vDPA engine, so a virtual device is used for this purpose.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
I went through the code, and something is not clear to me.
Why do we need to have a representation of the PF in DPDK? Why cannot we just bind at VF level?
1. With the vdev representation we could use it to talk to PF kernel driver
to
Quoted 7 lines
Quoted 7 lines
do flow configuration, we can implement
Quoted 1 line
flow API on the vdev in future for this purpose. Using a vdev allows
introducing this kind of control plane thing.
Quoted 2 lines
2. When port representor is ready, we would integrate it into ifcvf driver,
then each VF will have a
Quoted 1 line
Representor port. For now we don’t have port representor, so this patch
set
Quoted 6 lines
Quoted 4 lines
manages VF resource internally.
Ok, we may need to have a vdev to represent the PF, but we need to be able to bind at VF level anyway.
Device management on VF level is feasible, according to the previous port-
representor patch.
Quoted 2 lines
A tuple of (
PF_addr,VF_index) can identify a certain VF, we havevport_maskand device addr to describe a PF, and we can specify a VF index to create arepresentor port,
Review
Quoted 13 lines
so , the VF port creation will be on-demand at VF level.
(quoted diff) +10
-0+struct port_rep_parameters { + uint64_t vport_mask; + struct { + char bus[RTE_DEV_NAME_MAX_LEN]; + char device[RTE_DEV_NAME_MAX_LEN]; + } parent; +}; +int +rte_representor_port_register(char *pf_addr_str, + uint32_t vport_id, uint16_t *port_id)IIUC, even with this using port representor, we'll still have the problem of having the VFs probed first as Virtio driver, right?
In my opinion, the IFCVF devices in offload mode are to be managed differently than having a way to represent on host side VFs assigned to a VM.
In offload case, you have a real device to deal with, else we wouldn't have to bind it with VFIO.
Quoted 8 lines
Quoted 2 lines
Maybe we could have a real device probed as proposed yesterday [0], and this device gets registered to the port representor for the PF?
Adding a list of offload-device in eal is a way to skip virtio pmd probe [0]. I think using device devargs could also achieve that: add a parameter "vdpa=1" to the device, virtio pmd parses the devargs and detects that the device is in vdpa mode, quits its probe immediately.
Devargs could be flexible of allowing one device with multi driver case.
That's a good idea, but if we want the vDPA VF to probed in a generic way, will it work? I think the Virtio PMD won't be probed but no other driver will be tried, but I might be wrong.
Thanks,
Maxime
Quoted 44 lines
BRs,
XiaoQuoted 41 lines
Thanks,
MaximeQuoted 1 line
Besides, IFCVF supports live migration, vDPA exerts IFCVF device better than
QEMU (this patch has enabled LM feature).
Quoted 1 line
vDPA is the main usage model for IFCVF, and one DPDK application taking
control of all the VF resource
Quoted 17 lines
management is a straightforward usage model.
Best Regards,
XiaoQuoted 12 lines
Else, how do you support passing two VFs of the same PF to different DPDK applications?
Or have some VFs managed by Kernel or QEMU and some by the DPDK application? My feeling is that current implementation is creating an artificial constraint.Isn't there a possibility to have the virtual representation for the PF to be probed separately? Or created automatically when the first VF of a PF is probed (and later VFs attach to the PF rep when probed)?
Doing this, we could use the generic device probing.
[0]:
Quoted 15 lines
Quoted 15 lines
For IFCVF, to specify we want it to be probed as an offload device instead of a virtio device, we could have a new EAL parameter to specify for a given device if we want it to be probed as an offload device (for example --offload=00:01.1).
Offload drivers would register by passing a flag that specifies they are an offload driver.
This new argument would be optional and only used to force the device to being probed in offload mode. For devices that have their own device IDs for offload mode, then it would be automatic.Regards,
MaximeQuoted 3 lines
BRs,
Xiao
v3 cover add ifcvf vdpa driver
In reply to Xiao WangThis patch set has dependency on http://dpdk.org/dev/patchwork/patch/36772/
(vhost: support selective datapath).
IFCVF driver
============
The IFCVF vDPA (vhost data path acceleration) driver provides support for the Intel FPGA 100G VF (IFCVF). IFCVF's datapath is virtio ring compatible, it works as a HW vhost backend which can send/receive packets to/from virtio directly by DMA. Besides, it supports dirty page logging and device state report/restore. This driver enables its vDPA functionality with live migration feature.
vDPA mode
=========
IFCVF's vendor ID and device ID are same as that of virtio net pci device, with its specific subsystem vendor ID and device ID. To let the device be probed by IFCVF driver, adding "vdpa=1" parameter helps to specify that this device is to be used in vDPA mode, rather than polling mode, virtio pmd will skip when it detects this message.
Container per device
====================
vDPA needs to create different containers for different devices, thus this patch set adds some APIs in eal/vfio to support multiple container, e.g.
- rte_vfio_create_container
- rte_vfio_destroy_container
- rte_vfio_bind_group
- rte_vfio_unbind_group
By this extension, a device can be put into a new specific container, rather than the previous default container.
IFCVF vDPA details
==================
Key vDPA driver ops implemented:
- ifcvf_dev_config:
Enable VF data path with virtio information provided by vhost lib, including IOMMU programming to enable VF DMA to VM's memory, VFIO interrupt setup to route HW interrupt to virtio driver, create notify relay thread to translate virtio driver's kick to a MMIO write onto HW, HW queues configuration.
This function gets called to set up HW data path backend when virtio driver in VM gets ready.
- ifcvf_dev_close:
Revoke all the setup in ifcvf_dev_config.
This function gets called when virtio driver stops device in VM.
Change log
==========
v3:
- Add doc and release note for the new driver.
- Remove the vdev concept, make the driver as a PCI driver, it will get probed by PCI bus driver.
- Rebase on the v4 vDPA lib patch, register a vDPA device instead of a engine.
- Remove the PCI API exposure accordingly.
- Move the MAX_VFIO_CONTAINERS definition to config file.
- Let virtio pmd skips when a virtio device needs to work in vDPA mode.
v2:
- Rename function pci_get_kernel_driver_by_path to rte_pci_device_kdriver_name to make the API generic cross Linux and BSD, make it as EXPERIMENTAL.
- Rebase on Zhihong's vDPA v3 patch set.
- Minor code cleanup on vfio extension.
Junjie Chen (1):
eal/vfio: add support for multiple container
Xiao Wang (3):
net/virtio: skip device probe in vdpa mode
net/ifcvf: add ifcvf vdpa driver
net/ifcvf: add driver document and release note
config/common_base | 8 + config/common_linuxapp | 1 + doc/guides/nics/features/ifcvf.ini | 8 + doc/guides/nics/ifcvf.rst | 85 ++++ doc/guides/nics/index.rst | 1 + doc/guides/rel_notes/release_18_05.rst | 9 + drivers/net/Makefile | 3 + drivers/net/ifc/Makefile | 36 ++ drivers/net/ifc/base/ifcvf.c | 329 ++++++++++++ drivers/net/ifc/base/ifcvf.h | 160 ++++++ drivers/net/ifc/base/ifcvf_osdep.h | 52 ++ drivers/net/ifc/ifcvf_vdpa.c | 842 +++++++++++++++++++++++++++++++ drivers/net/ifc/rte_ifcvf_version.map | 4 + drivers/net/virtio/virtio_ethdev.c | 43 ++ lib/librte_eal/bsdapp/eal/eal.c | 51 +- lib/librte_eal/common/include/rte_vfio.h | 116 +++++ lib/librte_eal/linuxapp/eal/eal_vfio.c | 552 ++++++++++++++++---- lib/librte_eal/linuxapp/eal/eal_vfio.h | 1 + lib/librte_eal/rte_eal_version.map | 7 + mk/rte.app.mk | 3 + 20 files changed, 2210 insertions(+), 101 deletions(-) create mode 100644 doc/guides/nics/features/ifcvf.ini create mode 100644 doc/guides/nics/ifcvf.rst create mode 100644 drivers/net/ifc/Makefile create mode 100644 drivers/net/ifc/base/ifcvf.c create mode 100644 drivers/net/ifc/base/ifcvf.h create mode 100644 drivers/net/ifc/base/ifcvf_osdep.h create mode 100644 drivers/net/ifc/ifcvf_vdpa.c create mode 100644 drivers/net/ifc/rte_ifcvf_version.map
Signature · 1 line
2.15.1
PATCH v3 1/4 eal/vfio: add support for multiple container
From: Junjie Chen <[email protected]>
Currently eal vfio framework binds vfio group fd to the default container fd, while in some cases, e.g. vDPA (vhost data path acceleration), we want to set vfio group to a new container and program DMA mapping via this new container, so this patch adds APIs to support multiple container.
--- config/common_base | 1 + lib/librte_eal/bsdapp/eal/eal.c | 51 ++- lib/librte_eal/common/include/rte_vfio.h | 116 +++++++ lib/librte_eal/linuxapp/eal/eal_vfio.c | 552 +++++++++++++++++++++++++------ lib/librte_eal/linuxapp/eal/eal_vfio.h | 1 + lib/librte_eal/rte_eal_version.map | 7 + 6 files changed, 627 insertions(+), 101 deletions(-)
config/common_base +1 -0
@@ -74,6 +74,7 @@ CONFIG_RTE_EAL_ALWAYS_PANIC_ON_ERROR=n CONFIG_RTE_EAL_IGB_UIO=n CONFIG_RTE_EAL_VFIO=n CONFIG_RTE_MAX_VFIO_GROUPS=64 +CONFIG_RTE_MAX_VFIO_CONTAINERS=64 CONFIG_RTE_MALLOC_DEBUG=n CONFIG_RTE_EAL_NUMA_AWARE_HUGEPAGES=n
lib/librte_eal/bsdapp/eal/eal.c +42 -9
66 lines not on this page · raw message
lib/librte_eal/common/include/rte_vfio.h +116 -0
122 lines not on this page · raw message
lib/librte_eal/linuxapp/eal/eal_vfio.c +460 -92
752 lines not on this page · raw message
lib/librte_eal/linuxapp/eal/eal_vfio.h +1 -0
@@ -86,6 +86,7 @@ struct vfio_iommu_spapr_tce_info {#endif #define VFIO_MAX_GROUPS RTE_MAX_VFIO_GROUPS +#define VFIO_MAX_CONTAINERS RTE_MAX_VFIO_CONTAINERS/* * Function prototypes for VFIO multiprocess sync functions
lib/librte_eal/rte_eal_version.map +7 -0
@@ -254,5 +254,12 @@ EXPERIMENTAL { rte_service_set_runstate_mapped_check; rte_service_set_stats_enable; rte_service_start_with_defaults; + rte_vfio_bind_group; + rte_vfio_create_container; + rte_vfio_destroy_container; + rte_vfio_dma_map; + rte_vfio_dma_unmap; + rte_vfio_get_group_fd; + rte_vfio_unbind_group; } DPDK_18.02;
Signature · 1 line
2.15.1
PATCH v3 2/4 net/virtio: skip device probe in vdpa mode
In reply to Xiao WangIf we want a virtio device to work in vDPA (vhost data path acceleration) mode, we could add a "vdpa=1" devarg for this device to specify the mode.
This patch let virtio pmd skip device probe when detecting this parameter.
--- drivers/net/virtio/virtio_ethdev.c | 43 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)
drivers/net/virtio/virtio_ethdev.c +43 -0
@@ -29,6 +29,7 @@#include <rte_eal.h> #include <rte_dev.h> #include <rte_cycles.h> +#include <rte_kvargs.h> #include "virtio_ethdev.h" #include "virtio_pci.h"
@@ -1744,9 +1745,51 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)return 0 ; } +static int vdpa_check_handler(__rte_unused const char *key, + const char *value, __rte_unused void *opaque) +{ +if (strcmp (value,"1" )) +return -1 ; + +return 0 ; +} + +static int +vdpa_mode_selected (struct rte_devargs *devargs) +{ +struct rte_kvargs *kvlist; +const char *key ="vdpa" ; +int ret =0 ; + +if (devargs ==NULL ) +return 0 ; + + kvlist =rte_kvargs_parse (devargs->args,NULL ); +if (kvlist ==NULL ) +return 0 ; + +if (!rte_kvargs_count (kvlist, key)) + goto exit; + +/* vdpa mode selected when there's a key-value pair: vdpa=1 */ +if (rte_kvargs_process (kvlist, key, + vdpa_check_handler,NULL ) <0 ) { + goto exit; + } + ret =1 ; + +exit: +rte_kvargs_free (kvlist); +return ret; +} + static int eth_virtio_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,struct rte_pci_device *pci_dev) { +/* virtio pmd skips probe if device needs to work in vdpa mode */ +if (vdpa_mode_selected (pci_dev->device.devargs)) +return 1 ; +return rte_eth_dev_pci_generic_probe (pci_dev,sizeof (struct virtio_hw ), eth_virtio_dev_init); }
Signature · 1 line
2.15.1
PATCH v3 3/4 net/ifcvf: add ifcvf vdpa driver
In reply to Xiao WangThe IFCVF vDPA (vhost data path acceleration) driver provides support for the Intel FPGA 100G VF (IFCVF). IFCVF's datapath is virtio ring compatible, it works as a HW vhost backend which can send/receive packets to/from virtio directly by DMA.
Different VF devices serve different virtio frontends which are in different VMs, so each VF needs to have its own DMA address translation service. During the driver probe a new container is created, with this container vDPA driver can program DMA remapping table with the VM's memory region information.
Key vDPA driver ops implemented:
- ifcvf_dev_config:
Enable VF data path with virtio information provided by vhost lib, including IOMMU programming to enable VF DMA to VM's memory, VFIO interrupt setup to route HW interrupt to virtio driver, create notify relay thread to translate virtio driver's kick to a MMIO write onto HW, HW queues configuration.
- ifcvf_dev_close:
Revoke all the setup in ifcvf_dev_config.
Live migration feature is supported by IFCVF and this driver enables it. For the dirty page logging, VF helps to log for packet buffer write, driver helps to make the used ring as dirty when device stops.
Because vDPA driver needs to set up MSI-X vector to interrupt the guest, only vfio-pci is supported currently.
--- config/common_base | 7 + config/common_linuxapp | 1 + drivers/net/Makefile | 3 + drivers/net/ifc/Makefile | 36 ++ drivers/net/ifc/base/ifcvf.c | 329 +++++++++++++ drivers/net/ifc/base/ifcvf.h | 160 +++++++ drivers/net/ifc/base/ifcvf_osdep.h | 52 +++ drivers/net/ifc/ifcvf_vdpa.c | 842 ++++++++++++++++++++++++++++++++++ drivers/net/ifc/rte_ifcvf_version.map | 4 + mk/rte.app.mk | 3 + 10 files changed, 1437 insertions(+) create mode 100644 drivers/net/ifc/Makefile create mode 100644 drivers/net/ifc/base/ifcvf.c create mode 100644 drivers/net/ifc/base/ifcvf.h create mode 100644 drivers/net/ifc/base/ifcvf_osdep.h create mode 100644 drivers/net/ifc/ifcvf_vdpa.c create mode 100644 drivers/net/ifc/rte_ifcvf_version.map
config/common_base +7 -0
@@ -792,6 +792,13 @@ CONFIG_RTE_LIBRTE_VHOST_DEBUG=n # CONFIG_RTE_LIBRTE_PMD_VHOST=n +# +# Compile IFCVF driver +# To compile, CONFIG_RTE_LIBRTE_VHOST and CONFIG_RTE_EAL_VFIO +# should be enabled. +# +CONFIG_RTE_LIBRTE_IFCVF_VDPA=n + # # Compile the test application #
config/common_linuxapp +1 -0
@@ -15,6 +15,7 @@ CONFIG_RTE_LIBRTE_PMD_KNI=y CONFIG_RTE_LIBRTE_VHOST=y CONFIG_RTE_LIBRTE_VHOST_NUMA=y CONFIG_RTE_LIBRTE_PMD_VHOST=y +CONFIG_RTE_LIBRTE_IFCVF_VDPA=y CONFIG_RTE_LIBRTE_PMD_AF_PACKET=y CONFIG_RTE_LIBRTE_PMD_TAP=y CONFIG_RTE_LIBRTE_AVP_PMD=y
drivers/net/Makefile +3 -0
@@ -53,6 +53,9 @@ endif # $(CONFIG_RTE_LIBRTE_SCHED) ifeq ($(CONFIG_RTE_LIBRTE_VHOST),y) DIRS-$(CONFIG_RTE_LIBRTE_PMD_VHOST) += vhost +ifeq ($(CONFIG_RTE_EAL_VFIO),y) +DIRS-$(CONFIG_RTE_LIBRTE_IFCVF_VDPA) += ifc +endif endif # $(CONFIG_RTE_LIBRTE_VHOST) ifeq ($(CONFIG_RTE_LIBRTE_MRVL_PMD),y)
drivers/net/ifc/Makefile new file +36 -0
@@ -0,0 +1,36 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2018 Intel Corporation + +include $(RTE_SDK)/mk/rte.vars.mk + +# +# library name +# +LIB = librte_ifcvf_vdpa.a + +LDLIBS += -lpthread +LDLIBS += -lrte_eal -lrte_pci -lrte_vhost -lrte_bus_pci + +CFLAGS += -O3 +CFLAGS += $(WERROR_FLAGS) +CFLAGS += -DALLOW_EXPERIMENTAL_API +CFLAGS += -I$(RTE_SDK)/lib/librte_eal/linuxapp/eal + +# +# Add extra flags for base driver source files to disable warnings in them +# +BASE_DRIVER_OBJS=$(sort $(patsubst %.c,%.o,$(notdir $(wildcard $(SRCDIR)/base/*.c)))) + +VPATH += $(SRCDIR)/base + +EXPORT_MAP := rte_ifcvf_version.map + +LIBABIVER := 1 + +# +# all source are stored in SRCS-y +# +SRCS-$(CONFIG_RTE_LIBRTE_IFCVF_VDPA) += ifcvf_vdpa.c +SRCS-$(CONFIG_RTE_LIBRTE_IFCVF_VDPA) += ifcvf.c + +include $(RTE_SDK)/mk/rte.lib.mk
drivers/net/ifc/base/ifcvf.c new file +329 -0
329 lines not on this page · raw message
drivers/net/ifc/base/ifcvf.h new file +160 -0
160 lines not on this page · raw message
drivers/net/ifc/base/ifcvf_osdep.h new file +52 -0
52 lines not on this page · raw message
drivers/net/ifc/ifcvf_vdpa.c new file +842 -0
842 lines not on this page · raw message
drivers/net/ifc/rte_ifcvf_version.map new file +4 -0
@@ -0,0 +1,4 @@ +DPDK_18.05 { + + local: *; +};
mk/rte.app.mk +3 -0
@@ -171,6 +171,9 @@ _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 +ifeq ($(CONFIG_RTE_EAL_VFIO),y) +_LDLIBS-$(CONFIG_RTE_LIBRTE_IFCVF_VDPA) += -lrte_ifcvf_vdpa +endif # $(CONFIG_RTE_EAL_VFIO) endif # $(CONFIG_RTE_LIBRTE_VHOST) _LDLIBS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += -lrte_pmd_vmxnet3_uio
Signature · 1 line
2.15.1
PATCH v3 4/4 net/ifcvf: add driver document and release note
In reply to Xiao Wang--- doc/guides/nics/features/ifcvf.ini | 8 ++++ doc/guides/nics/ifcvf.rst | 85 ++++++++++++++++++++++++++++++++++ doc/guides/nics/index.rst | 1 + doc/guides/rel_notes/release_18_05.rst | 9 ++++ 4 files changed, 103 insertions(+) create mode 100644 doc/guides/nics/features/ifcvf.ini create mode 100644 doc/guides/nics/ifcvf.rst
doc/guides/nics/features/ifcvf.ini new file +8 -0
@@ -0,0 +1,8 @@ +; +; Supported features of the 'ifcvf' vDPA driver. +; +; Refer to default.ini for the full list of available PMD features. +; +[Features] +x86-32 = Y +x86-64 = Y
doc/guides/nics/ifcvf.rst new file +85 -0
85 lines not on this page · raw message
doc/guides/nics/index.rst +1 -0
@@ -44,6 +44,7 @@ Network Interface Controller Drivers vmxnet3 pcap_ring fail_safe + ifcvf **Figures**
doc/guides/rel_notes/release_18_05.rst +9 -0
@@ -41,6 +41,15 @@ New Features Also, make sure to start the actual text at the margin. ========================================================= +* **Added IFCVF vDPA driver.** + + Added IFCVF vDPA driver to support Intel FPGA 100G VF device. IFCVF works + as a HW vhost data path accelerator, it supports live migration and is + compatible with virtio 0.95 and 1.0. This driver registers ifcvf vDPA driver + to vhost lib, when virtio connected, with the help of the registered vDPA + driver the assigned VF gets configured to Rx/Tx directly to VM's virtio + vrings. + API Changes -----------
Signature · 1 line
2.15.1
Re: [PATCH v3 1/4] eal/vfio: add support for multiple container
In reply to Xiao WangQuoted 10 lines · Xiao Wang
From: Junjie Chen <[email protected]>
Currently eal vfio framework binds vfio group fd to the default container fd, while in some cases, e.g. vDPA (vhost data path acceleration), we want to set vfio group to a new container and program DMA mapping via this new container, so this patch adds APIs to support multiple container.
Signed-off-by Junjie Chen <[email protected]>Signed-off-by Xiao Wang <[email protected]>
Quoted 9 lines
--- config/common_base | 1 + lib/librte_eal/bsdapp/eal/eal.c | 51 ++- lib/librte_eal/common/include/rte_vfio.h | 116 +++++++ lib/librte_eal/linuxapp/eal/eal_vfio.c | 552 +++++++++++++++++++++++++------ lib/librte_eal/linuxapp/eal/eal_vfio.h | 1 + lib/librte_eal/rte_eal_version.map | 7 + 6 files changed, 627 insertions(+), 101 deletions(-)
FWIW:
Thanks,
Maxime
Re: [PATCH v3 2/4] net/virtio: skip device probe in vdpa mode
In reply to Xiao WangHi Xiao,
Quoted 10 lines · Xiao Wang
If we want a virtio device to work in vDPA (vhost data path acceleration) mode, we could add a "vdpa=1" devarg for this device to specify the mode.
This patch let virtio pmd skip device probe when detecting this parameter.
Signed-off-by Xiao Wang <[email protected]>--- drivers/net/virtio/virtio_ethdev.c | 43 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)
As we discussed, I would prefer a generic solution at EAL level. But as a start, I agree with this solution:
Thanks!
Maxime
Re: [PATCH v3 3/4] net/ifcvf: add ifcvf vdpa driver
In reply to Xiao WangQuoted 44 lines · Xiao Wang
The IFCVF vDPA (vhost data path acceleration) driver provides support for the Intel FPGA 100G VF (IFCVF). IFCVF's datapath is virtio ring compatible, it works as a HW vhost backend which can send/receive packets to/from virtio directly by DMA.
Different VF devices serve different virtio frontends which are in different VMs, so each VF needs to have its own DMA address translation service. During the driver probe a new container is created, with this container vDPA driver can program DMA remapping table with the VM's memory region information.
Key vDPA driver ops implemented:
-
ifcvf_dev_config:
Enable VF data path with virtio information provided by vhost lib, including IOMMU programming to enable VF DMA to VM's memory, VFIO interrupt setup to route HW interrupt to virtio driver, create notify relay thread to translate virtio driver's kick to a MMIO write onto HW, HW queues configuration.-
ifcvf_dev_close:
Revoke all the setup inifcvf_dev_config.Live migration feature is supported by IFCVF and this driver enables it. For the dirty page logging, VF helps to log for packet buffer write, driver helps to make the used ring as dirty when device stops.
Because vDPA driver needs to set up MSI-X vector to interrupt the guest, only vfio-pci is supported currently.
Signed-off-by Xiao Wang <[email protected]>Signed-off-by Rosen Xu <[email protected]>--- config/common_base | 7 + config/common_linuxapp | 1 + drivers/net/Makefile | 3 + drivers/net/ifc/Makefile | 36 ++ drivers/net/ifc/base/ifcvf.c | 329 +++++++++++++ drivers/net/ifc/base/ifcvf.h | 160 +++++++ drivers/net/ifc/base/ifcvf_osdep.h | 52 +++ drivers/net/ifc/ifcvf_vdpa.c | 842 ++++++++++++++++++++++++++++++++++ drivers/net/ifc/rte_ifcvf_version.map | 4 + mk/rte.app.mk | 3 + 10 files changed, 1437 insertions(+)
Quoted 6 lines
create mode 100644
drivers/net/ifc/Makefilecreate mode 100644drivers/net/ifc/base/ifcvf.ccreate mode 100644drivers/net/ifc/base/ifcvf.hcreate mode 100644drivers/net/ifc/base/ifcvf_osdep.hcreate mode 100644drivers/net/ifc/ifcvf_vdpa.ccreate mode 100644drivers/net/ifc/rte_ifcvf_version.map
Thanks for having handled the changes, please see minor comments below.
Feel free to add my:
Thanks!
Maxime
drivers/net/ifc/ifcvf_vdpa.c line 227
Quoted 2 lines
drivers/net/ifc/ifcvf_vdpa.c new file +2
-0+static uint64_t +qva_to_gpa (int vid,uint64_t qva)
We might want to have this in vhost-lib to avoid duplication, but that can be done later.
Quoted 472 lines
drivers/net/ifc/ifcvf_vdpa.c new file +472
-0+{ +struct rte_vhost_memory *mem =NULL ; +struct rte_vhost_mem_region *reg; +uint32_t i; +uint64_t gpa =0 ; + +if (rte_vhost_get_mem_table (vid, &mem) <0 ) + goto exit; + +for (i =0 ; i < mem->nregions; i++) { + reg = &mem->regions[i]; + +if (qva >= reg->host_user_addr && + qva < reg->host_user_addr + reg->size) { + gpa = qva - reg->host_user_addr + reg->guest_phys_addr; +break ; + } + } + +exit: +if (gpa ==0 ) +rte_panic ("failed to get gpa\n" ); +if (mem) +free (mem); +return gpa; +} + +static int +vdpa_ifcvf_start (struct ifcvf_internal *internal) +{ +struct ifcvf_hw *hw = &internal->hw; +int i, nr_vring; +int vid; +struct rte_vhost_vring vq; + + vid = internal->vid; + nr_vring =rte_vhost_get_vring_num (vid); +rte_vhost_get_negotiated_features (vid, &hw->req_features); + +for (i =0 ; i < nr_vring; i++) { +rte_vhost_get_vhost_vring (vid, i, &vq); + hw->vring[i].desc =qva_to_gpa (vid, (uint64_t )vq.desc); + hw->vring[i].avail =qva_to_gpa (vid, (uint64_t )vq.avail); + hw->vring[i].used =qva_to_gpa (vid, (uint64_t )vq.used); + hw->vring[i].size = vq.size; +rte_vhost_get_vring_base (vid, i, &hw->vring[i].last_avail_idx, + &hw->vring[i].last_used_idx); + } + hw->nr_vring = i; + +return ifcvf_start_hw (&internal->hw); +} + +static void +vdpa_ifcvf_stop (struct ifcvf_internal *internal) +{ +struct ifcvf_hw *hw = &internal->hw; +int i, j; +int vid; +uint64_t features, pfn; +uint64_t log_base, log_size; +uint8_t *log_buf; + + vid = internal->vid; +ifcvf_stop_hw (hw); + +for (i =0 ; i < hw->nr_vring; i++) +rte_vhost_set_vring_base (vid, i, hw->vring[i].last_avail_idx, + hw->vring[i].last_used_idx); + +rte_vhost_get_negotiated_features (vid, &features); +if (RTE_VHOST_NEED_LOG (features)) { +ifcvf_disable_logging (hw); +rte_vhost_get_log_base (internal->vid, &log_base, &log_size); +/* +* IFCVF marks dirty memory pages for only packet buffer, +* SW helps to mark the used ring as dirty after device stops. +*/ + log_buf = (uint8_t *)(uintptr_t )log_base; +for (i =0 ; i < hw->nr_vring; i++) { + pfn = hw->vring[i].used /4096 ; +for (j =0 ; j <= hw->vring[i].size *8 /4096 ; j++) +__sync_fetch_and_or_8 (&log_buf[(pfn + j) /8 ], +1 << ((pfn + j) %8 )); + } + } +} + +#define MSIX_IRQ_SET_BUF_LEN (sizeof(struct vfio_irq_set) + \ + sizeof(int) * (IFCVF_MAX_QUEUES * 2 + 1)) +static int +vdpa_enable_vfio_intr (struct ifcvf_internal *internal) +{ +int ret; +uint32_t i, nr_vring; +char irq_set_buf[MSIX_IRQ_SET_BUF_LEN ]; +struct vfio_irq_set *irq_set; +int *fd_ptr; +struct rte_vhost_vring vring; + + nr_vring =rte_vhost_get_vring_num (internal->vid); + + irq_set = (struct vfio_irq_set *)irq_set_buf; + irq_set->argsz =sizeof (irq_set_buf); + irq_set->count = nr_vring +1 ; + irq_set->flags =VFIO_IRQ_SET_DATA_EVENTFD | +VFIO_IRQ_SET_ACTION_TRIGGER ; + irq_set->index =VFIO_PCI_MSIX_IRQ_INDEX ; + irq_set->start =0 ; + fd_ptr = (int *)&irq_set->data; + fd_ptr[RTE_INTR_VEC_ZERO_OFFSET ] = internal->pdev->intr_handle.fd; + +for (i =0 ; i < nr_vring; i++) { +rte_vhost_get_vhost_vring (internal->vid, i, &vring); + fd_ptr[RTE_INTR_VEC_RXTX_OFFSET + i] = vring.callfd; + } + + ret =ioctl (internal->vfio_dev_fd,VFIO_DEVICE_SET_IRQS , irq_set); +if (ret) { +DRV_LOG (ERR ,"Error enabling MSI-X interrupts: %s" , +strerror (errno)); +return -1 ; + } + +return 0 ; +} + +static int +vdpa_disable_vfio_intr (struct ifcvf_internal *internal) +{ +int ret; +char irq_set_buf[MSIX_IRQ_SET_BUF_LEN ]; +struct vfio_irq_set *irq_set; + + irq_set = (struct vfio_irq_set *)irq_set_buf; + irq_set->argsz =sizeof (irq_set_buf); + irq_set->count =0 ; + irq_set->flags =VFIO_IRQ_SET_DATA_NONE |VFIO_IRQ_SET_ACTION_TRIGGER ; + irq_set->index =VFIO_PCI_MSIX_IRQ_INDEX ; + irq_set->start =0 ; + + ret =ioctl (internal->vfio_dev_fd,VFIO_DEVICE_SET_IRQS , irq_set); +if (ret) { +DRV_LOG (ERR ,"Error disabling MSI-X interrupts: %s" , +strerror (errno)); +return -1 ; + } + +return 0 ; +} + +static void * +notify_relay (void *arg) +{ +int i, kickfd, epfd, nfds =0 ; +uint32_t qid, q_num; +struct epoll_event events[IFCVF_MAX_QUEUES *2 ]; +struct epoll_event ev; +uint64_t buf; +int nbytes; +struct rte_vhost_vring vring; +struct ifcvf_internal *internal = (struct ifcvf_internal *)arg; +struct ifcvf_hw *hw = &internal->hw; + + q_num =rte_vhost_get_vring_num (internal->vid); + + epfd =epoll_create (IFCVF_MAX_QUEUES *2 ); +if (epfd <0 ) { +DRV_LOG (ERR ,"failed to create epoll instance." ); +return NULL ; + } + internal->epfd = epfd; + +for (qid =0 ; qid < q_num; qid++) { + ev.events =EPOLLIN |EPOLLPRI ; +rte_vhost_get_vhost_vring (internal->vid, qid, &vring); + ev.data.u64 = qid | (uint64_t )vring.kickfd <<32 ; +if (epoll_ctl (epfd,EPOLL_CTL_ADD , vring.kickfd, &ev) <0 ) { +DRV_LOG (ERR ,"epoll add error: %s" ,strerror (errno)); +return NULL ; + } + } + +for (;;) { + nfds =epoll_wait (epfd, events, q_num,-1 ); +if (nfds <0 ) { +if (errno ==EINTR ) +continue ; +DRV_LOG (ERR ,"epoll_wait return fail\n" ); +return NULL ; + } + +for (i =0 ; i < nfds; i++) { + qid = events[i].data.u32; + kickfd = (uint32_t )(events[i].data.u64 >>32 ); +do { + nbytes =read (kickfd, &buf,8 ); +if (nbytes <0 ) { +if (errno ==EINTR || + errno ==EWOULDBLOCK || + errno ==EAGAIN ) +continue ; +DRV_LOG (INFO ,"Error reading " +"kickfd: %s" , +strerror (errno)); + } +break ; + }while (1 ); + +ifcvf_notify_queue (hw, qid); + } + } + +return NULL ; +} + +static int +setup_notify_relay (struct ifcvf_internal *internal) +{ +int ret; + + ret =pthread_create (&internal->tid,NULL , notify_relay, + (void *)internal); +if (ret) { +DRV_LOG (ERR ,"failed to create notify relay pthread." ); +return -1 ; + } +return 0 ; +} + +static int +unset_notify_relay (struct ifcvf_internal *internal) +{ +void *status; + +if (internal->tid) { +pthread_cancel (internal->tid); +pthread_join (internal->tid, &status); + } + internal->tid =0 ; + +if (internal->epfd >=0 ) +close (internal->epfd); + internal->epfd =-1 ; + +return 0 ; +} + +static int +update_datapath (struct ifcvf_internal *internal) +{ +int ret; + +rte_spinlock_lock (&internal->lock); + +if (!rte_atomic32_read (&internal->running) && + (rte_atomic32_read (&internal->started) && +rte_atomic32_read (&internal->dev_attached))) { + ret =ifcvf_dma_map (internal); +if (ret) + goto err; + + ret =vdpa_enable_vfio_intr (internal); +if (ret) + goto err; + + ret =setup_notify_relay (internal); +if (ret) + goto err; + + ret =vdpa_ifcvf_start (internal); +if (ret) + goto err; + +rte_atomic32_set (&internal->running,1 ); + }else if (rte_atomic32_read (&internal->running) && + (!rte_atomic32_read (&internal->started) || + !rte_atomic32_read (&internal->dev_attached))) { +vdpa_ifcvf_stop (internal); + + ret =unset_notify_relay (internal); +if (ret) + goto err; + + ret =vdpa_disable_vfio_intr (internal); +if (ret) + goto err; + + ret =ifcvf_dma_unmap (internal); +if (ret) + goto err; + +rte_atomic32_set (&internal->running,0 ); + } + +rte_spinlock_unlock (&internal->lock); +return 0 ; +err: +rte_spinlock_unlock (&internal->lock); +return ret; +} + +static int +ifcvf_dev_config (int vid) +{ +int did; +struct internal_list *list; +struct ifcvf_internal *internal; + + did =rte_vhost_get_vdpa_did (vid); + list =find_internal_resource_by_did (did); +if (list ==NULL ) { +DRV_LOG (ERR ,"Invalid device id: %d" , did); +return -1 ; + } + + internal = list->internal; + internal->vid = vid; +rte_atomic32_set (&internal->dev_attached,1 ); +update_datapath (internal); + +return 0 ; +} + +static int +ifcvf_dev_close (int vid) +{ +int did; +struct internal_list *list; +struct ifcvf_internal *internal; + + did =rte_vhost_get_vdpa_did (vid); + list =find_internal_resource_by_did (did); +if (list ==NULL ) { +DRV_LOG (ERR ,"Invalid device id: %d" , did); +return -1 ; + } + + internal = list->internal; +rte_atomic32_set (&internal->dev_attached,0 ); +update_datapath (internal); + +return 0 ; +} + +static int +ifcvf_feature_set (int vid) +{ +uint64_t features; +int did; +struct internal_list *list; +struct ifcvf_internal *internal; +uint64_t log_base, log_size; + + did =rte_vhost_get_vdpa_did (vid); + list =find_internal_resource_by_did (did); +if (list ==NULL ) { +DRV_LOG (ERR ,"Invalid device id: %d" , did); +return -1 ; + } + + internal = list->internal; +rte_vhost_get_negotiated_features (internal->vid, &features); + +if (RTE_VHOST_NEED_LOG (features)) { +rte_vhost_get_log_base (internal->vid, &log_base, &log_size); + log_base =rte_mem_virt2phy ((void *)(uintptr_t )log_base); +ifcvf_enable_logging (&internal->hw, log_base, log_size); + } + +return 0 ; +} + +static int +ifcvf_get_vfio_group_fd (int vid) +{ +int did; +struct internal_list *list; + + did =rte_vhost_get_vdpa_did (vid); + list =find_internal_resource_by_did (did); +if (list ==NULL ) { +DRV_LOG (ERR ,"Invalid device id: %d" , did); +return -1 ; + } + +return list->internal->vfio_group_fd; +} + +static int +ifcvf_get_vfio_device_fd (int vid) +{ +int did; +struct internal_list *list; + + did =rte_vhost_get_vdpa_did (vid); + list =find_internal_resource_by_did (did); +if (list ==NULL ) { +DRV_LOG (ERR ,"Invalid device id: %d" , did); +return -1 ; + } + +return list->internal->vfio_dev_fd; +} + +static int +ifcvf_get_notify_area (int vid,int qid,uint64_t *offset,uint64_t *size) +{ +int did; +struct internal_list *list; +struct ifcvf_internal *internal; +struct vfio_region_info reg = { .argsz =sizeof (reg) }; +int ret; + + did =rte_vhost_get_vdpa_did (vid); + list =find_internal_resource_by_did (did); +if (list ==NULL ) { +DRV_LOG (ERR ,"Invalid device id: %d" , did); +return -1 ; + } + + internal = list->internal; + + reg.index =ifcvf_get_notify_region (&internal->hw); + ret =ioctl (internal->vfio_dev_fd,VFIO_DEVICE_GET_REGION_INFO , ®); +if (ret) { +DRV_LOG (ERR ,"Get not get device region info: %s" , +strerror (errno)); +return -1 ; + } + + *offset =ifcvf_get_queue_notify_off (&internal->hw, qid) + reg.offset; + *size =0x1000 ; + +return 0 ; +} + +static int +ifcvf_get_queue_num (int did,uint32_t *queue_num) +{ +struct internal_list *list; + + list =find_internal_resource_by_did (did); +if (list ==NULL ) { +DRV_LOG (ERR ,"Invalid device id: %d" , did); +return -1 ; + } + + *queue_num = list->internal->max_queues; + +return 0 ; +} + +static int +ifcvf_get_vdpa_feature (int did,uint64_t *features) +{ +struct internal_list *list; + + list =find_internal_resource_by_did (did); +if (list ==NULL ) { +DRV_LOG (ERR ,"Invalid device id: %d" , did); +return -1 ; + } + + *features = list->internal->features; + +return 0 ; +} + +#define VDPA_SUPPORTED_PROTOCOL_FEATURES \ + (1ULL << VHOST_USER_PROTOCOL_F_REPLY_ACK) +static int
drivers/net/ifc/ifcvf_vdpa.c line 709
Quoted 10 lines
drivers/net/ifc/ifcvf_vdpa.c new file +10
-0+ifcvf_get_protocol_feature(int did __rte_unused, uint64_t *features) +{ + *features =VDPA_SUPPORTED_PROTOCOL_FEATURES ; +return 0 ; +} + +struct rte_vdpa_dev_ops ifcvf_ops = { + .queue_num_get = ifcvf_get_queue_num, + .feature_get = ifcvf_get_vdpa_feature, + .protocol_feature_get = ifcvf_get_protocol_feature,
I have proposed in vDPA series to rename the ops so that it is consistant with Vhost-user protocol:
e.g. get_protocol_features, get_features...
So you might have to rebase if this is change is implemented.
Quoted 158 lines
drivers/net/ifc/ifcvf_vdpa.c new file +133
-0+ .dev_conf = ifcvf_dev_config, + .dev_close = ifcvf_dev_close, + .vring_state_set = NULL, + .feature_set = ifcvf_feature_set, + .migration_done = NULL, + .get_vfio_group_fd = ifcvf_get_vfio_group_fd, + .get_vfio_device_fd = ifcvf_get_vfio_device_fd, + .get_notify_area = ifcvf_get_notify_area, +}; + +static int +ifcvf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, +struct rte_pci_device *pci_dev) +{ +uint64_t features; +struct ifcvf_internal *internal =NULL ; +struct internal_list *list =NULL ; + +if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) +return 0 ; + + list =rte_zmalloc ("ifcvf" ,sizeof (*list),0 ); +if (list ==NULL ) + goto error; + + internal =rte_zmalloc ("ifcvf" ,sizeof (*internal),0 ); +if (internal ==NULL ) + goto error; + + internal->pdev = pci_dev; +rte_spinlock_init (&internal->lock); +if (ifcvf_vfio_setup (internal) <0 ) +return -1 ; + + internal->max_queues =IFCVF_MAX_QUEUES ; + features =ifcvf_get_features (&internal->hw); + internal->features = (features & + ~(1ULL <<VIRTIO_F_IOMMU_PLATFORM )) | + (1ULL <<VHOST_USER_F_PROTOCOL_FEATURES ); + + internal->dev_addr.pci_addr = pci_dev->addr; + internal->dev_addr.type =PCI_ADDR ; + list->internal = internal; + +pthread_mutex_lock (&internal_list_lock); +TAILQ_INSERT_TAIL (&internal_list, list, next); +pthread_mutex_unlock (&internal_list_lock); + +if (rte_vdpa_register_device (&internal->dev_addr, + &ifcvf_ops) <0 ) + goto error; + +rte_atomic32_set (&internal->started,1 ); +update_datapath (internal); + +return 0 ; + +error: +rte_free (list); +rte_free (internal); +return -1 ; +} + +static int +ifcvf_pci_remove (struct rte_pci_device *pci_dev) +{ +struct ifcvf_internal *internal; +struct internal_list *list; + +if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) +return 0 ; + + list =find_internal_resource_by_dev (pci_dev); +if (list ==NULL ) { +DRV_LOG (ERR ,"Invalid device: %s" , pci_dev->name); +return -1 ; + } + + internal = list->internal; +rte_atomic32_set (&internal->started,0 ); +update_datapath (internal); + +rte_pci_unmap_device (internal->pdev); +rte_vfio_destroy_container (internal->vfio_container_fd); +rte_vdpa_unregister_device (internal->did); + +pthread_mutex_lock (&internal_list_lock); +TAILQ_REMOVE (&internal_list, list, next); +pthread_mutex_unlock (&internal_list_lock); + +rte_free (list); +rte_free (internal); + +return 0 ; +} + +/* +* The set of PCI devices this driver supports. +*/ +static const struct rte_pci_id pci_id_ifcvf_map[] = { + { .class_id =RTE_CLASS_ANY_ID , + .vendor_id =IFCVF_VENDOR_ID , + .device_id =IFCVF_DEVICE_ID , + .subsystem_vendor_id =IFCVF_SUBSYS_VENDOR_ID , + .subsystem_device_id =IFCVF_SUBSYS_DEVICE_ID , + }, + + { .vendor_id =0 ,/* sentinel */ + }, +}; + +static struct rte_pci_driver rte_ifcvf_vdpa = { + .driver = { + .name ="net_ifcvf" , + }, + .id_table = pci_id_ifcvf_map, + .drv_flags =0 , + .probe = ifcvf_pci_probe, + .remove = ifcvf_pci_remove, +}; + +RTE_PMD_REGISTER_PCI (net_ifcvf, rte_ifcvf_vdpa); +RTE_PMD_REGISTER_PCI_TABLE (net_ifcvf, pci_id_ifcvf_map); +RTE_PMD_REGISTER_KMOD_DEP (net_ifcvf,"* vfio-pci" ); + +RTE_INIT (ifcvf_vdpa_init_log); +static void +ifcvf_vdpa_init_log (void ) +{ + ifcvf_vdpa_logtype =rte_log_register ("net.ifcvf_vdpa" ); +if (ifcvf_vdpa_logtype >=0 ) +rte_log_set_level (ifcvf_vdpa_logtype,RTE_LOG_NOTICE ); +}drivers/net/ifc/rte_ifcvf_version.map new file +4
-0@@ -0,0 +1,4 @@ +DPDK_18.05 { + + local: *; +};mk/rte.app.mk +3
-0@@ -171,6 +171,9 @@ _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 +ifeq ($(CONFIG_RTE_EAL_VFIO),y) +_LDLIBS-$(CONFIG_RTE_LIBRTE_IFCVF_VDPA) += -lrte_ifcvf_vdpa +endif # $(CONFIG_RTE_EAL_VFIO) endif # $(CONFIG_RTE_LIBRTE_VHOST) _LDLIBS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += -lrte_pmd_vmxnet3_uio
Re: [PATCH v3 4/4] net/ifcvf: add driver document and release note
In reply to Xiao WangQuoted 10 lines · Xiao Wang
Signed-off-by Xiao Wang <[email protected]>--- doc/guides/nics/features/ifcvf.ini | 8 ++++ doc/guides/nics/ifcvf.rst | 85 ++++++++++++++++++++++++++++++++++ doc/guides/nics/index.rst | 1 + doc/guides/rel_notes/release_18_05.rst | 9 ++++ 4 files changed, 103 insertions(+)create mode 100644 doc/guides/nics/features/ifcvf.ini create mode 100644
doc/guides/nics/ifcvf.rst
Thanks!
Maxime
Re: [PATCH v3 2/4] net/virtio: skip device probe in vdpa mode
In reply to Maxime CoquelinHi,
31/03/2018 13:13, Maxime Coquelin:
Quoted 7 lines · Xiao Wang
Quoted 4 lines
If we want a virtio device to work in vDPA (vhost data path acceleration) mode, we could add a "vdpa=1" devarg for this device to specify the mode.
This patch let virtio pmd skip device probe when detecting this parameter.
As we discussed, I would prefer a generic solution at EAL level.
Please could you explain the requirement and the context? Can we use RTE_ETH_DEV_DEFERRED state and device ownership?
Without knowing what's behind, I would say that a PMD should never skip a device by itself, but let other entities decide what to do with the probed device (thanks to probe notifications).
Re: [PATCH v3 2/4] net/virtio: skip device probe in vdpa mode
Hi Thomas,
Quoted 21 lines
-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Saturday, March 31, 2018 9:16 PM
To: Maxime Coquelin <[email protected]>
Cc: Wang, Xiao W <[email protected]>; Yigit, Ferruh <[email protected]>; [email protected]; Wang, Zhihong <[email protected]>; [email protected]; Tan, Jianfeng <[email protected]>; Bie, Tiwei <[email protected]>; Liang, Cunming <[email protected]>; Daly, Dan <[email protected]>; [email protected]; Burakov, Anatoly <[email protected]>
Subject: Re: [PATCH v3 2/4] net/virtio: skip device probe in vdpa modeHi,
31/03/2018 13:13, Maxime Coquelin:
Quoted 6 lines · Xiao Wang
Quoted 4 lines
If we want a virtio device to work in vDPA (vhost data path acceleration) mode, we could add a "vdpa=1" devarg for this device to specify the mode.
This patch let virtio pmd skip device probe when detecting this parameter.
Quoted 9 lines
Quoted 1 line
As we discussed, I would prefer a generic solution at EAL level.
Please could you explain the requirement and the context? Can we use
RTE_ETH_DEV_DEFERREDstate and device ownership?Without knowing what's behind, I would say that a PMD should never skip a device by itself, but let other entities decide what to do with the probed device (thanks to probe notifications).
IFCVF's vendor ID and device ID are the same as that of virtio net pci device, with its specific subsystem vendor ID and device ID. The context is IFCVF can be driven by both virtio pmd and IFCVF driver, so we add this devarg to specify if we want the device to work in vDPA mode or not. For vdpa-mode IFCVF, virtio pmd should not take over it, so we let it skip.
BRs,
Xiao
Re: [PATCH v3 3/4] net/ifcvf: add ifcvf vdpa driver
In reply to Maxime CoquelinHi Maxime,
Quoted 93 lines
-----Original Message-----
From: Maxime Coquelin [mailto:[email protected]]
Sent: Saturday, March 31, 2018 7:27 PM
To: Wang, Xiao W <[email protected]>; Yigit, Ferruh <[email protected]>
Cc: [email protected]; Wang, Zhihong <[email protected]>; [email protected]; Tan, Jianfeng <[email protected]>; Bie, Tiwei <[email protected]>; Liang, Cunming <[email protected]>; Daly, Dan <[email protected]>; [email protected]; [email protected]; Burakov, Anatoly <[email protected]>; Xu, Rosen <[email protected]>
Subject: Re: [PATCH v3 3/4] net/ifcvf: add ifcvf vdpa driverQuoted 9 lines · Xiao Wang
The IFCVF vDPA (vhost data path acceleration) driver provides support for the Intel FPGA 100G VF (IFCVF). IFCVF's datapath is virtio ring compatible, it works as a HW vhost backend which can send/receive packets to/from virtio directly by DMA.
Different VF devices serve different virtio frontends which are in different VMs, so each VF needs to have its own DMA address translation service. During the driver probe a new container is created, with this container vDPA driver can program DMA remapping table with the VM's
memory
Quoted 23 lines
region information.
Key vDPA driver ops implemented:
-
ifcvf_dev_config:
Enable VF data path with virtio information provided by vhost lib, including IOMMU programming to enable VF DMA to VM's memory, VFIO interrupt setup to route HW interrupt to virtio driver, create notify relay thread to translate virtio driver's kick to a MMIO write onto HW, HW queues configuration.-
ifcvf_dev_close:
Revoke all the setup inifcvf_dev_config.Live migration feature is supported by IFCVF and this driver enables it. For the dirty page logging, VF helps to log for packet buffer write, driver helps to make the used ring as dirty when device stops.
Because vDPA driver needs to set up MSI-X vector to interrupt the guest, only vfio-pci is supported currently.
Signed-off-by Xiao Wang <[email protected]>Signed-off-by Rosen Xu <[email protected]>Quoted 9 lines
--- config/common_base | 7 + config/common_linuxapp | 1 + drivers/net/Makefile | 3 + drivers/net/ifc/Makefile | 36 ++ drivers/net/ifc/base/ifcvf.c | 329 +++++++++++++ drivers/net/ifc/base/ifcvf.h | 160 +++++++ drivers/net/ifc/base/ifcvf_osdep.h | 52 +++ drivers/net/ifc/ifcvf_vdpa.c | 842++++++++++++++++++++++++++++++++++
Quoted 9 lines
drivers/net/ifc/rte_ifcvf_version.map | 4 + mk/rte.app.mk | 3 + 10 files changed, 1437 insertions(+)create mode 100644
drivers/net/ifc/Makefilecreate mode 100644drivers/net/ifc/base/ifcvf.ccreate mode 100644drivers/net/ifc/base/ifcvf.hcreate mode 100644drivers/net/ifc/base/ifcvf_osdep.hcreate mode 100644drivers/net/ifc/ifcvf_vdpa.ccreate mode 100644drivers/net/ifc/rte_ifcvf_version.mapThanks for having handled the changes, please see minor comments below.
Feel free to add my:
Reviewed-by Maxime Coquelin <[email protected]>Thanks!
Maximedrivers/net/ifc/ifcvf_vdpa.c line 227
Quoted 2 lines
drivers/net/ifc/ifcvf_vdpa.c new file +2
-0+static uint64_t +qva_to_gpa (int vid,uint64_t qva)We might want to have this in vhost-lib to avoid duplication, but that can be done later.
Quoted 10 lines
drivers/net/ifc/ifcvf_vdpa.c new file +10
-0+{ +struct rte_vhost_memory *mem =NULL ; +struct rte_vhost_mem_region *reg; +uint32_t i; +uint64_t gpa =0 ; + +if (rte_vhost_get_mem_table (vid, &mem) <0 ) + goto exit; + +for (i =0 ; i < mem->nregions; i++) {
[...]
Quoted 10 lines
drivers/net/ifc/ifcvf_vdpa.c line 709
Quoted 5 lines
drivers/net/ifc/ifcvf_vdpa.c new file +5
-0+ +struct rte_vdpa_dev_ops ifcvf_ops = { + .queue_num_get = ifcvf_get_queue_num, + .feature_get = ifcvf_get_vdpa_feature, + .protocol_feature_get = ifcvf_get_protocol_feature,I have proposed in vDPA series to rename the ops so that it is consistant with Vhost-user protocol:
e.g.get_protocol_features,get_features...
Quoted 2 lines
So you might have to rebase if this is change is implemented.
Will rebase on the latest vDPA series.
Thanks,
Xiao
v4 cover add ifcvf vdpa driver
In reply to Xiao WangThis patch set has dependency on http://dpdk.org/dev/patchwork/patch/36772/
(vhost: support selective datapath).
IFCVF driver
============
The IFCVF vDPA (vhost data path acceleration) driver provides support for the Intel FPGA 100G VF (IFCVF). IFCVF's datapath is virtio ring compatible, it works as a HW vhost backend which can send/receive packets to/from virtio directly by DMA. Besides, it supports dirty page logging and device state report/restore. This driver enables its vDPA functionality with live migration feature.
vDPA mode
=========
IFCVF's vendor ID and device ID are same as that of virtio net pci device, with its specific subsystem vendor ID and device ID. To let the device be probed by IFCVF driver, adding "vdpa=1" parameter helps to specify that this device is to be used in vDPA mode, rather than polling mode, virtio pmd will skip when it detects this message.
Container per device
====================
vDPA needs to create different containers for different devices, thus this patch set adds some APIs in eal/vfio to support multiple container, e.g.
- rte_vfio_create_container
- rte_vfio_destroy_container
- rte_vfio_bind_group
- rte_vfio_unbind_group
By this extension, a device can be put into a new specific container, rather than the previous default container.
IFCVF vDPA details
==================
Key vDPA driver ops implemented:
- ifcvf_dev_config:
Enable VF data path with virtio information provided by vhost lib, including IOMMU programming to enable VF DMA to VM's memory, VFIO interrupt setup to route HW interrupt to virtio driver, create notify relay thread to translate virtio driver's kick to a MMIO write onto HW, HW queues configuration.
This function gets called to set up HW data path backend when virtio driver in VM gets ready.
- ifcvf_dev_close:
Revoke all the setup in ifcvf_dev_config.
This function gets called when virtio driver stops device in VM.
Change log
==========
v4:
- Rebase on Zhihong's latest vDPA lib patch, with vDPA ops names change.
- Remove API "rte_vfio_get_group_fd", "rte_vfio_bind_group" will return the fd.
- Align the internal vfio_cfg search APIs naming.
v3:
- Add doc and release note for the new driver.
- Remove the vdev concept, make the driver as a PCI driver, it will get probed by PCI bus driver.
- Rebase on the v4 vDPA lib patch, register a vDPA device instead of a engine.
- Remove the PCI API exposure accordingly.
- Move the MAX_VFIO_CONTAINERS definition to config file.
- Let virtio pmd skips when a virtio device needs to work in vDPA mode.
v2:
- Rename function pci_get_kernel_driver_by_path to rte_pci_device_kdriver_name to make the API generic cross Linux and BSD, make it as EXPERIMENTAL.
- Rebase on Zhihong's vDPA v3 patch set.
- Minor code cleanup on vfio extension.
Xiao Wang (4):
eal/vfio: add multiple container support
net/virtio: skip device probe in vdpa mode
net/ifcvf: add ifcvf vdpa driver
doc: add ifcvf driver document and release note
config/common_base | 8 + config/common_linuxapp | 1 + doc/guides/nics/features/ifcvf.ini | 8 + doc/guides/nics/ifcvf.rst | 85 ++++ doc/guides/nics/index.rst | 1 + doc/guides/rel_notes/release_18_05.rst | 9 + drivers/net/Makefile | 3 + drivers/net/ifc/Makefile | 36 ++ drivers/net/ifc/base/ifcvf.c | 329 ++++++++++++ drivers/net/ifc/base/ifcvf.h | 160 ++++++ drivers/net/ifc/base/ifcvf_osdep.h | 52 ++ drivers/net/ifc/ifcvf_vdpa.c | 840 +++++++++++++++++++++++++++++++ drivers/net/ifc/rte_ifcvf_version.map | 4 + drivers/net/virtio/virtio_ethdev.c | 43 ++ lib/librte_eal/bsdapp/eal/eal.c | 52 +- lib/librte_eal/common/include/rte_vfio.h | 113 +++++ lib/librte_eal/linuxapp/eal/eal_vfio.c | 521 +++++++++++++++---- lib/librte_eal/linuxapp/eal/eal_vfio.h | 1 + lib/librte_eal/rte_eal_version.map | 6 + mk/rte.app.mk | 3 + 20 files changed, 2174 insertions(+), 101 deletions(-) create mode 100644 doc/guides/nics/features/ifcvf.ini create mode 100644 doc/guides/nics/ifcvf.rst create mode 100644 drivers/net/ifc/Makefile create mode 100644 drivers/net/ifc/base/ifcvf.c create mode 100644 drivers/net/ifc/base/ifcvf.h create mode 100644 drivers/net/ifc/base/ifcvf_osdep.h create mode 100644 drivers/net/ifc/ifcvf_vdpa.c create mode 100644 drivers/net/ifc/rte_ifcvf_version.map
Signature · 1 line
2.15.1
PATCH v4 1/4 eal/vfio: add multiple container support
Currently eal vfio framework binds vfio group fd to the default container fd during rte_vfio_setup_device, while in some cases, e.g. vDPA (vhost data path acceleration), we want to put vfio group to a separate container and program IOMMU via this container.
This patch adds some APIs to support container creating and device binding with a container.
A driver could use "rte_vfio_create_container" helper to create a new container from eal, use "rte_vfio_bind_group" to bind a device to the newly created container.
During rte_vfio_setup_device, the container bound with the device will be used for IOMMU setup.
---
v4:
- Remove API "rte_vfio_get_group_fd", "rte_vfio_bind_group" will return the fd.
- Align the internal vfio_cfg search APIs naming.
--- config/common_base | 1 + lib/librte_eal/bsdapp/eal/eal.c | 52 ++- lib/librte_eal/common/include/rte_vfio.h | 113 +++++++ lib/librte_eal/linuxapp/eal/eal_vfio.c | 521 +++++++++++++++++++++++++------ lib/librte_eal/linuxapp/eal/eal_vfio.h | 1 + lib/librte_eal/rte_eal_version.map | 6 + 6 files changed, 593 insertions(+), 101 deletions(-)
config/common_base +1 -0
@@ -74,6 +74,7 @@ CONFIG_RTE_EAL_ALWAYS_PANIC_ON_ERROR=n CONFIG_RTE_EAL_IGB_UIO=n CONFIG_RTE_EAL_VFIO=n CONFIG_RTE_MAX_VFIO_GROUPS=64 +CONFIG_RTE_MAX_VFIO_CONTAINERS=64 CONFIG_RTE_MALLOC_DEBUG=n CONFIG_RTE_EAL_NUMA_AWARE_HUGEPAGES=n
lib/librte_eal/bsdapp/eal/eal.c +43 -9
67 lines not on this page · raw message
lib/librte_eal/common/include/rte_vfio.h +113 -0
125 lines not on this page · raw message
lib/librte_eal/linuxapp/eal/eal_vfio.c +429 -92
718 lines not on this page · raw message
lib/librte_eal/linuxapp/eal/eal_vfio.h +1 -0
@@ -86,6 +86,7 @@ struct vfio_iommu_spapr_tce_info {#endif #define VFIO_MAX_GROUPS RTE_MAX_VFIO_GROUPS +#define VFIO_MAX_CONTAINERS RTE_MAX_VFIO_CONTAINERS/* * Function prototypes for VFIO multiprocess sync functions
lib/librte_eal/rte_eal_version.map +6 -0
@@ -255,5 +255,11 @@ EXPERIMENTAL { rte_service_set_runstate_mapped_check; rte_service_set_stats_enable; rte_service_start_with_defaults; + rte_vfio_bind_group; + rte_vfio_create_container; + rte_vfio_destroy_container; + rte_vfio_dma_map; + rte_vfio_dma_unmap; + rte_vfio_unbind_group; } DPDK_18.02;
Signature · 1 line
2.15.1
PATCH v4 2/4 net/virtio: skip device probe in vdpa mode
In reply to Xiao WangIf we want a virtio device to work in vDPA (vhost data path acceleration) mode, we could add a "vdpa=1" devarg for this device to specify the mode.
This patch let virtio pmd skip device probe when detecting this parameter.
--- drivers/net/virtio/virtio_ethdev.c | 43 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)
drivers/net/virtio/virtio_ethdev.c +43 -0
@@ -28,6 +28,7 @@#include <rte_eal.h> #include <rte_dev.h> #include <rte_cycles.h> +#include <rte_kvargs.h> #include "virtio_ethdev.h" #include "virtio_pci.h"
@@ -1708,9 +1709,51 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)return 0 ; } +static int vdpa_check_handler(__rte_unused const char *key, + const char *value, __rte_unused void *opaque) +{ +if (strcmp (value,"1" )) +return -1 ; + +return 0 ; +} + +static int +vdpa_mode_selected (struct rte_devargs *devargs) +{ +struct rte_kvargs *kvlist; +const char *key ="vdpa" ; +int ret =0 ; + +if (devargs ==NULL ) +return 0 ; + + kvlist =rte_kvargs_parse (devargs->args,NULL ); +if (kvlist ==NULL ) +return 0 ; + +if (!rte_kvargs_count (kvlist, key)) + goto exit; + +/* vdpa mode selected when there's a key-value pair: vdpa=1 */ +if (rte_kvargs_process (kvlist, key, + vdpa_check_handler,NULL ) <0 ) { + goto exit; + } + ret =1 ; + +exit: +rte_kvargs_free (kvlist); +return ret; +} + static int eth_virtio_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,struct rte_pci_device *pci_dev) { +/* virtio pmd skips probe if device needs to work in vdpa mode */ +if (vdpa_mode_selected (pci_dev->device.devargs)) +return 1 ; +return rte_eth_dev_pci_generic_probe (pci_dev,sizeof (struct virtio_hw ), eth_virtio_dev_init); }
Signature · 1 line
2.15.1
PATCH v4 3/4 net/ifcvf: add ifcvf vdpa driver
In reply to Xiao WangThe IFCVF vDPA (vhost data path acceleration) driver provides support for the Intel FPGA 100G VF (IFCVF). IFCVF's datapath is virtio ring compatible, it works as a HW vhost backend which can send/receive packets to/from virtio directly by DMA.
Different VF devices serve different virtio frontends which are in different VMs, so each VF needs to have its own DMA address translation service. During the driver probe a new container is created, with this container vDPA driver can program DMA remapping table with the VM's memory region information.
Key vDPA driver ops implemented:
- ifcvf_dev_config:
Enable VF data path with virtio information provided by vhost lib, including IOMMU programming to enable VF DMA to VM's memory, VFIO interrupt setup to route HW interrupt to virtio driver, create notify relay thread to translate virtio driver's kick to a MMIO write onto HW, HW queues configuration.
- ifcvf_dev_close:
Revoke all the setup in ifcvf_dev_config.
Live migration feature is supported by IFCVF and this driver enables it. For the dirty page logging, VF helps to log for packet buffer write, driver helps to make the used ring as dirty when device stops.
Because vDPA driver needs to set up MSI-X vector to interrupt the guest, only vfio-pci is supported currently.
---
v4:
- Rebase on Zhihong's latest vDPA lib patch, with vDPA ops names change.
--- config/common_base | 7 + config/common_linuxapp | 1 + drivers/net/Makefile | 3 + drivers/net/ifc/Makefile | 36 ++ drivers/net/ifc/base/ifcvf.c | 329 +++++++++++++ drivers/net/ifc/base/ifcvf.h | 160 +++++++ drivers/net/ifc/base/ifcvf_osdep.h | 52 +++ drivers/net/ifc/ifcvf_vdpa.c | 840 ++++++++++++++++++++++++++++++++++ drivers/net/ifc/rte_ifcvf_version.map | 4 + mk/rte.app.mk | 3 + 10 files changed, 1435 insertions(+) create mode 100644 drivers/net/ifc/Makefile create mode 100644 drivers/net/ifc/base/ifcvf.c create mode 100644 drivers/net/ifc/base/ifcvf.h create mode 100644 drivers/net/ifc/base/ifcvf_osdep.h create mode 100644 drivers/net/ifc/ifcvf_vdpa.c create mode 100644 drivers/net/ifc/rte_ifcvf_version.map
config/common_base +7 -0
@@ -796,6 +796,13 @@ CONFIG_RTE_LIBRTE_VHOST_DEBUG=n # CONFIG_RTE_LIBRTE_PMD_VHOST=n +# +# Compile IFCVF driver +# To compile, CONFIG_RTE_LIBRTE_VHOST and CONFIG_RTE_EAL_VFIO +# should be enabled. +# +CONFIG_RTE_LIBRTE_IFCVF_VDPA=n + # # Compile the test application #
config/common_linuxapp +1 -0
@@ -15,6 +15,7 @@ CONFIG_RTE_LIBRTE_PMD_KNI=y CONFIG_RTE_LIBRTE_VHOST=y CONFIG_RTE_LIBRTE_VHOST_NUMA=y CONFIG_RTE_LIBRTE_PMD_VHOST=y +CONFIG_RTE_LIBRTE_IFCVF_VDPA=y CONFIG_RTE_LIBRTE_PMD_AF_PACKET=y CONFIG_RTE_LIBRTE_PMD_TAP=y CONFIG_RTE_LIBRTE_AVP_PMD=y
drivers/net/Makefile +3 -0
@@ -57,6 +57,9 @@ endif # $(CONFIG_RTE_LIBRTE_SCHED) ifeq ($(CONFIG_RTE_LIBRTE_VHOST),y) DIRS-$(CONFIG_RTE_LIBRTE_PMD_VHOST) += vhost +ifeq ($(CONFIG_RTE_EAL_VFIO),y) +DIRS-$(CONFIG_RTE_LIBRTE_IFCVF_VDPA) += ifc +endif endif # $(CONFIG_RTE_LIBRTE_VHOST) ifeq ($(CONFIG_RTE_LIBRTE_MVPP2_PMD),y)
drivers/net/ifc/Makefile new file +36 -0
@@ -0,0 +1,36 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2018 Intel Corporation + +include $(RTE_SDK)/mk/rte.vars.mk + +# +# library name +# +LIB = librte_ifcvf_vdpa.a + +LDLIBS += -lpthread +LDLIBS += -lrte_eal -lrte_pci -lrte_vhost -lrte_bus_pci + +CFLAGS += -O3 +CFLAGS += $(WERROR_FLAGS) +CFLAGS += -DALLOW_EXPERIMENTAL_API +CFLAGS += -I$(RTE_SDK)/lib/librte_eal/linuxapp/eal + +# +# Add extra flags for base driver source files to disable warnings in them +# +BASE_DRIVER_OBJS=$(sort $(patsubst %.c,%.o,$(notdir $(wildcard $(SRCDIR)/base/*.c)))) + +VPATH += $(SRCDIR)/base + +EXPORT_MAP := rte_ifcvf_version.map + +LIBABIVER := 1 + +# +# all source are stored in SRCS-y +# +SRCS-$(CONFIG_RTE_LIBRTE_IFCVF_VDPA) += ifcvf_vdpa.c +SRCS-$(CONFIG_RTE_LIBRTE_IFCVF_VDPA) += ifcvf.c + +include $(RTE_SDK)/mk/rte.lib.mk
drivers/net/ifc/base/ifcvf.c new file +329 -0
329 lines not on this page · raw message
drivers/net/ifc/base/ifcvf.h new file +160 -0
160 lines not on this page · raw message
drivers/net/ifc/base/ifcvf_osdep.h new file +52 -0
52 lines not on this page · raw message
drivers/net/ifc/ifcvf_vdpa.c new file +840 -0
840 lines not on this page · raw message
drivers/net/ifc/rte_ifcvf_version.map new file +4 -0
@@ -0,0 +1,4 @@ +DPDK_18.05 { + + local: *; +};
mk/rte.app.mk +3 -0
@@ -181,6 +181,9 @@ _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 +ifeq ($(CONFIG_RTE_EAL_VFIO),y) +_LDLIBS-$(CONFIG_RTE_LIBRTE_IFCVF_VDPA) += -lrte_ifcvf_vdpa +endif # $(CONFIG_RTE_EAL_VFIO) endif # $(CONFIG_RTE_LIBRTE_VHOST) _LDLIBS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += -lrte_pmd_vmxnet3_uio
Signature · 1 line
2.15.1
PATCH v4 4/4 doc: add ifcvf driver document and release note
In reply to Xiao Wang--- doc/guides/nics/features/ifcvf.ini | 8 ++++ doc/guides/nics/ifcvf.rst | 85 ++++++++++++++++++++++++++++++++++ doc/guides/nics/index.rst | 1 + doc/guides/rel_notes/release_18_05.rst | 9 ++++ 4 files changed, 103 insertions(+) create mode 100644 doc/guides/nics/features/ifcvf.ini create mode 100644 doc/guides/nics/ifcvf.rst
doc/guides/nics/features/ifcvf.ini new file +8 -0
@@ -0,0 +1,8 @@ +; +; Supported features of the 'ifcvf' vDPA driver. +; +; Refer to default.ini for the full list of available PMD features. +; +[Features] +x86-32 = Y +x86-64 = Y
doc/guides/nics/ifcvf.rst new file +85 -0
85 lines not on this page · raw message
doc/guides/nics/index.rst +1 -0
@@ -44,6 +44,7 @@ Network Interface Controller Drivers vmxnet3 pcap_ring fail_safe + ifcvf **Figures**
doc/guides/rel_notes/release_18_05.rst +9 -0
@@ -58,6 +58,15 @@ New Features * Added support for NVGRE, VXLAN and GENEVE filters in flow API. * Added support for DROP action in flow API. +* **Added IFCVF vDPA driver.** + + Added IFCVF vDPA driver to support Intel FPGA 100G VF device. IFCVF works + as a HW vhost data path accelerator, it supports live migration and is + compatible with virtio 0.95 and 1.0. This driver registers ifcvf vDPA driver + to vhost lib, when virtio connected, with the help of the registered vDPA + driver the assigned VF gets configured to Rx/Tx directly to VM's virtio + vrings. + API Changes -----------
Signature · 1 line
2.15.1
v5 cover add ifcvf vdpa driver
In reply to Xiao WangThis patch set has dependency on http://dpdk.org/dev/patchwork/patch/36772/
(vhost: support selective datapath).
IFCVF driver
============
The IFCVF vDPA (vhost data path acceleration) driver provides support for the Intel FPGA 100G VF (IFCVF). IFCVF's datapath is virtio ring compatible, it works as a HW vhost backend which can send/receive packets to/from virtio directly by DMA. Besides, it supports dirty page logging and device state report/restore. This driver enables its vDPA functionality with live migration feature.
vDPA mode
=========
IFCVF's vendor ID and device ID are same as that of virtio net pci device, with its specific subsystem vendor ID and device ID. To let the device be probed by IFCVF driver, adding "vdpa=1" parameter helps to specify that this device is to be used in vDPA mode, rather than polling mode, virtio pmd will skip when it detects this message.
Container per device
====================
vDPA needs to create different containers for different devices, thus this patch set adds some APIs in eal/vfio to support multiple container, e.g.
- rte_vfio_create_container
- rte_vfio_destroy_container
- rte_vfio_bind_group
- rte_vfio_unbind_group
By this extension, a device can be put into a new specific container, rather than the previous default container.
IFCVF vDPA details
==================
Key vDPA driver ops implemented:
- ifcvf_dev_config:
Enable VF data path with virtio information provided by vhost lib, including IOMMU programming to enable VF DMA to VM's memory, VFIO interrupt setup to route HW interrupt to virtio driver, create notify relay thread to translate virtio driver's kick to a MMIO write onto HW, HW queues configuration.
This function gets called to set up HW data path backend when virtio driver in VM gets ready.
- ifcvf_dev_close:
Revoke all the setup in ifcvf_dev_config.
This function gets called when virtio driver stops device in VM.
Change log
==========
v5:
- Fix compilation in BSD, remove the rte_vfio.h including in BSD.
v4:
- Rebase on Zhihong's latest vDPA lib patch, with vDPA ops names change.
- Remove API "rte_vfio_get_group_fd", "rte_vfio_bind_group" will return the fd.
- Align the vfio_cfg search internal APIs naming.
v3:
- Add doc and release note for the new driver.
- Remove the vdev concept, make the driver as a PCI driver, it will get probed by PCI bus driver.
- Rebase on the v4 vDPA lib patch, register a vDPA device instead of a engine.
- Remove the PCI API exposure accordingly.
- Move the MAX_VFIO_CONTAINERS definition to config file.
- Let virtio pmd skips when a virtio device needs to work in vDPA mode.
v2:
- Rename function pci_get_kernel_driver_by_path to rte_pci_device_kdriver_name to make the API generic cross Linux and BSD, make it as EXPERIMENTAL.
- Rebase on Zhihong's vDPA v3 patch set.
- Minor code cleanup on vfio extension.
Xiao Wang (4):
eal/vfio: add multiple container support
net/virtio: skip device probe in vdpa mode
net/ifcvf: add ifcvf vdpa driver
doc: add ifcvf driver document and release note
config/common_base | 8 + config/common_linuxapp | 1 + doc/guides/nics/features/ifcvf.ini | 8 + doc/guides/nics/ifcvf.rst | 85 ++++ doc/guides/nics/index.rst | 1 + doc/guides/rel_notes/release_18_05.rst | 9 + drivers/net/Makefile | 3 + drivers/net/ifc/Makefile | 36 ++ drivers/net/ifc/base/ifcvf.c | 329 ++++++++++++ drivers/net/ifc/base/ifcvf.h | 160 ++++++ drivers/net/ifc/base/ifcvf_osdep.h | 52 ++ drivers/net/ifc/ifcvf_vdpa.c | 840 +++++++++++++++++++++++++++++++ drivers/net/ifc/rte_ifcvf_version.map | 4 + drivers/net/virtio/virtio_ethdev.c | 43 ++ lib/librte_eal/bsdapp/eal/eal.c | 50 ++ lib/librte_eal/common/include/rte_vfio.h | 113 +++++ lib/librte_eal/linuxapp/eal/eal_vfio.c | 522 +++++++++++++++---- lib/librte_eal/linuxapp/eal/eal_vfio.h | 1 + lib/librte_eal/rte_eal_version.map | 6 + mk/rte.app.mk | 3 + 20 files changed, 2182 insertions(+), 92 deletions(-) create mode 100644 doc/guides/nics/features/ifcvf.ini create mode 100644 doc/guides/nics/ifcvf.rst create mode 100644 drivers/net/ifc/Makefile create mode 100644 drivers/net/ifc/base/ifcvf.c create mode 100644 drivers/net/ifc/base/ifcvf.h create mode 100644 drivers/net/ifc/base/ifcvf_osdep.h create mode 100644 drivers/net/ifc/ifcvf_vdpa.c create mode 100644 drivers/net/ifc/rte_ifcvf_version.map
Signature · 1 line
2.15.1
PATCH v5 1/4 eal/vfio: add multiple container support
Currently eal vfio framework binds vfio group fd to the default container fd during rte_vfio_setup_device, while in some cases, e.g. vDPA (vhost data path acceleration), we want to put vfio group to a separate container and program IOMMU via this container.
This patch adds some APIs to support container creating and device binding with a container.
A driver could use "rte_vfio_create_container" helper to create a new container from eal, use "rte_vfio_bind_group" to bind a device to the newly created container.
During rte_vfio_setup_device, the container bound with the device will be used for IOMMU setup.
--- config/common_base | 1 + lib/librte_eal/bsdapp/eal/eal.c | 50 +++ lib/librte_eal/common/include/rte_vfio.h | 113 +++++++ lib/librte_eal/linuxapp/eal/eal_vfio.c | 522 +++++++++++++++++++++++++------ lib/librte_eal/linuxapp/eal/eal_vfio.h | 1 + lib/librte_eal/rte_eal_version.map | 6 + 6 files changed, 601 insertions(+), 92 deletions(-)
config/common_base +1 -0
@@ -74,6 +74,7 @@ CONFIG_RTE_EAL_ALWAYS_PANIC_ON_ERROR=n CONFIG_RTE_EAL_IGB_UIO=n CONFIG_RTE_EAL_VFIO=n CONFIG_RTE_MAX_VFIO_GROUPS=64 +CONFIG_RTE_MAX_VFIO_CONTAINERS=64 CONFIG_RTE_MALLOC_DEBUG=n CONFIG_RTE_EAL_NUMA_AWARE_HUGEPAGES=n
lib/librte_eal/bsdapp/eal/eal.c +50 -0
59 lines not on this page · raw message
lib/librte_eal/common/include/rte_vfio.h +113 -0
125 lines not on this page · raw message
lib/librte_eal/linuxapp/eal/eal_vfio.c +430 -92
719 lines not on this page · raw message
lib/librte_eal/linuxapp/eal/eal_vfio.h +1 -0
@@ -86,6 +86,7 @@ struct vfio_iommu_spapr_tce_info {#endif #define VFIO_MAX_GROUPS RTE_MAX_VFIO_GROUPS +#define VFIO_MAX_CONTAINERS RTE_MAX_VFIO_CONTAINERS/* * Function prototypes for VFIO multiprocess sync functions
lib/librte_eal/rte_eal_version.map +6 -0
@@ -255,5 +255,11 @@ EXPERIMENTAL { rte_service_set_runstate_mapped_check; rte_service_set_stats_enable; rte_service_start_with_defaults; + rte_vfio_bind_group; + rte_vfio_create_container; + rte_vfio_destroy_container; + rte_vfio_dma_map; + rte_vfio_dma_unmap; + rte_vfio_unbind_group; } DPDK_18.02;
Signature · 1 line
2.15.1
PATCH v5 2/4 net/virtio: skip device probe in vdpa mode
In reply to Xiao WangIf we want a virtio device to work in vDPA (vhost data path acceleration) mode, we could add a "vdpa=1" devarg for this device to specify the mode.
This patch let virtio pmd skip device probe when detecting this parameter.
--- drivers/net/virtio/virtio_ethdev.c | 43 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)
drivers/net/virtio/virtio_ethdev.c +43 -0
@@ -28,6 +28,7 @@#include <rte_eal.h> #include <rte_dev.h> #include <rte_cycles.h> +#include <rte_kvargs.h> #include "virtio_ethdev.h" #include "virtio_pci.h"
@@ -1708,9 +1709,51 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)return 0 ; } +static int vdpa_check_handler(__rte_unused const char *key, + const char *value, __rte_unused void *opaque) +{ +if (strcmp (value,"1" )) +return -1 ; + +return 0 ; +} + +static int +vdpa_mode_selected (struct rte_devargs *devargs) +{ +struct rte_kvargs *kvlist; +const char *key ="vdpa" ; +int ret =0 ; + +if (devargs ==NULL ) +return 0 ; + + kvlist =rte_kvargs_parse (devargs->args,NULL ); +if (kvlist ==NULL ) +return 0 ; + +if (!rte_kvargs_count (kvlist, key)) + goto exit; + +/* vdpa mode selected when there's a key-value pair: vdpa=1 */ +if (rte_kvargs_process (kvlist, key, + vdpa_check_handler,NULL ) <0 ) { + goto exit; + } + ret =1 ; + +exit: +rte_kvargs_free (kvlist); +return ret; +} + static int eth_virtio_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,struct rte_pci_device *pci_dev) { +/* virtio pmd skips probe if device needs to work in vdpa mode */ +if (vdpa_mode_selected (pci_dev->device.devargs)) +return 1 ; +return rte_eth_dev_pci_generic_probe (pci_dev,sizeof (struct virtio_hw ), eth_virtio_dev_init); }
Signature · 1 line
2.15.1
PATCH v5 3/4 net/ifcvf: add ifcvf vdpa driver
In reply to Xiao WangThe IFCVF vDPA (vhost data path acceleration) driver provides support for the Intel FPGA 100G VF (IFCVF). IFCVF's datapath is virtio ring compatible, it works as a HW vhost backend which can send/receive packets to/from virtio directly by DMA.
Different VF devices serve different virtio frontends which are in different VMs, so each VF needs to have its own DMA address translation service. During the driver probe a new container is created, with this container vDPA driver can program DMA remapping table with the VM's memory region information.
Key vDPA driver ops implemented:
- ifcvf_dev_config:
Enable VF data path with virtio information provided by vhost lib, including IOMMU programming to enable VF DMA to VM's memory, VFIO interrupt setup to route HW interrupt to virtio driver, create notify relay thread to translate virtio driver's kick to a MMIO write onto HW, HW queues configuration.
- ifcvf_dev_close:
Revoke all the setup in ifcvf_dev_config.
Live migration feature is supported by IFCVF and this driver enables it. For the dirty page logging, VF helps to log for packet buffer write, driver helps to make the used ring as dirty when device stops.
Because vDPA driver needs to set up MSI-X vector to interrupt the guest, only vfio-pci is supported currently.
--- config/common_base | 7 + config/common_linuxapp | 1 + drivers/net/Makefile | 3 + drivers/net/ifc/Makefile | 36 ++ drivers/net/ifc/base/ifcvf.c | 329 +++++++++++++ drivers/net/ifc/base/ifcvf.h | 160 +++++++ drivers/net/ifc/base/ifcvf_osdep.h | 52 +++ drivers/net/ifc/ifcvf_vdpa.c | 840 ++++++++++++++++++++++++++++++++++ drivers/net/ifc/rte_ifcvf_version.map | 4 + mk/rte.app.mk | 3 + 10 files changed, 1435 insertions(+) create mode 100644 drivers/net/ifc/Makefile create mode 100644 drivers/net/ifc/base/ifcvf.c create mode 100644 drivers/net/ifc/base/ifcvf.h create mode 100644 drivers/net/ifc/base/ifcvf_osdep.h create mode 100644 drivers/net/ifc/ifcvf_vdpa.c create mode 100644 drivers/net/ifc/rte_ifcvf_version.map
config/common_base +7 -0
@@ -796,6 +796,13 @@ CONFIG_RTE_LIBRTE_VHOST_DEBUG=n # CONFIG_RTE_LIBRTE_PMD_VHOST=n +# +# Compile IFCVF driver +# To compile, CONFIG_RTE_LIBRTE_VHOST and CONFIG_RTE_EAL_VFIO +# should be enabled. +# +CONFIG_RTE_LIBRTE_IFCVF_VDPA=n + # # Compile the test application #
config/common_linuxapp +1 -0
@@ -15,6 +15,7 @@ CONFIG_RTE_LIBRTE_PMD_KNI=y CONFIG_RTE_LIBRTE_VHOST=y CONFIG_RTE_LIBRTE_VHOST_NUMA=y CONFIG_RTE_LIBRTE_PMD_VHOST=y +CONFIG_RTE_LIBRTE_IFCVF_VDPA=y CONFIG_RTE_LIBRTE_PMD_AF_PACKET=y CONFIG_RTE_LIBRTE_PMD_TAP=y CONFIG_RTE_LIBRTE_AVP_PMD=y
drivers/net/Makefile +3 -0
@@ -57,6 +57,9 @@ endif # $(CONFIG_RTE_LIBRTE_SCHED) ifeq ($(CONFIG_RTE_LIBRTE_VHOST),y) DIRS-$(CONFIG_RTE_LIBRTE_PMD_VHOST) += vhost +ifeq ($(CONFIG_RTE_EAL_VFIO),y) +DIRS-$(CONFIG_RTE_LIBRTE_IFCVF_VDPA) += ifc +endif endif # $(CONFIG_RTE_LIBRTE_VHOST) ifeq ($(CONFIG_RTE_LIBRTE_MVPP2_PMD),y)
drivers/net/ifc/Makefile new file +36 -0
@@ -0,0 +1,36 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2018 Intel Corporation + +include $(RTE_SDK)/mk/rte.vars.mk + +# +# library name +# +LIB = librte_ifcvf_vdpa.a + +LDLIBS += -lpthread +LDLIBS += -lrte_eal -lrte_pci -lrte_vhost -lrte_bus_pci + +CFLAGS += -O3 +CFLAGS += $(WERROR_FLAGS) +CFLAGS += -DALLOW_EXPERIMENTAL_API +CFLAGS += -I$(RTE_SDK)/lib/librte_eal/linuxapp/eal + +# +# Add extra flags for base driver source files to disable warnings in them +# +BASE_DRIVER_OBJS=$(sort $(patsubst %.c,%.o,$(notdir $(wildcard $(SRCDIR)/base/*.c)))) + +VPATH += $(SRCDIR)/base + +EXPORT_MAP := rte_ifcvf_version.map + +LIBABIVER := 1 + +# +# all source are stored in SRCS-y +# +SRCS-$(CONFIG_RTE_LIBRTE_IFCVF_VDPA) += ifcvf_vdpa.c +SRCS-$(CONFIG_RTE_LIBRTE_IFCVF_VDPA) += ifcvf.c + +include $(RTE_SDK)/mk/rte.lib.mk
drivers/net/ifc/base/ifcvf.c new file +329 -0
329 lines not on this page · raw message
drivers/net/ifc/base/ifcvf.h new file +160 -0
160 lines not on this page · raw message
drivers/net/ifc/base/ifcvf_osdep.h new file +52 -0
52 lines not on this page · raw message
drivers/net/ifc/ifcvf_vdpa.c new file +840 -0
840 lines not on this page · raw message
drivers/net/ifc/rte_ifcvf_version.map new file +4 -0
@@ -0,0 +1,4 @@ +DPDK_18.05 { + + local: *; +};
mk/rte.app.mk +3 -0
@@ -181,6 +181,9 @@ _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 +ifeq ($(CONFIG_RTE_EAL_VFIO),y) +_LDLIBS-$(CONFIG_RTE_LIBRTE_IFCVF_VDPA) += -lrte_ifcvf_vdpa +endif # $(CONFIG_RTE_EAL_VFIO) endif # $(CONFIG_RTE_LIBRTE_VHOST) _LDLIBS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += -lrte_pmd_vmxnet3_uio
Signature · 1 line
2.15.1
PATCH v5 4/4 doc: add ifcvf driver document and release note
In reply to Xiao Wang--- doc/guides/nics/features/ifcvf.ini | 8 ++++ doc/guides/nics/ifcvf.rst | 85 ++++++++++++++++++++++++++++++++++ doc/guides/nics/index.rst | 1 + doc/guides/rel_notes/release_18_05.rst | 9 ++++ 4 files changed, 103 insertions(+) create mode 100644 doc/guides/nics/features/ifcvf.ini create mode 100644 doc/guides/nics/ifcvf.rst
doc/guides/nics/features/ifcvf.ini new file +8 -0
@@ -0,0 +1,8 @@ +; +; Supported features of the 'ifcvf' vDPA driver. +; +; Refer to default.ini for the full list of available PMD features. +; +[Features] +x86-32 = Y +x86-64 = Y
doc/guides/nics/ifcvf.rst new file +85 -0
85 lines not on this page · raw message
doc/guides/nics/index.rst +1 -0
@@ -44,6 +44,7 @@ Network Interface Controller Drivers vmxnet3 pcap_ring fail_safe + ifcvf **Figures**
doc/guides/rel_notes/release_18_05.rst +9 -0
@@ -58,6 +58,15 @@ New Features * Added support for NVGRE, VXLAN and GENEVE filters in flow API. * Added support for DROP action in flow API. +* **Added IFCVF vDPA driver.** + + Added IFCVF vDPA driver to support Intel FPGA 100G VF device. IFCVF works + as a HW vhost data path accelerator, it supports live migration and is + compatible with virtio 0.95 and 1.0. This driver registers ifcvf vDPA driver + to vhost lib, when virtio connected, with the help of the registered vDPA + driver the assigned VF gets configured to Rx/Tx directly to VM's virtio + vrings. + API Changes -----------
Signature · 1 line
2.15.1
Re: [PATCH v5 3/4] net/ifcvf: add ifcvf vdpa driver
In reply to Xiao WangQuoted 57 lines · Xiao Wang
The IFCVF vDPA (vhost data path acceleration) driver provides support for the Intel FPGA 100G VF (IFCVF). IFCVF's datapath is virtio ring compatible, it works as a HW vhost backend which can send/receive packets to/from virtio directly by DMA.
Different VF devices serve different virtio frontends which are in different VMs, so each VF needs to have its own DMA address translation service. During the driver probe a new container is created, with this container vDPA driver can program DMA remapping table with the VM's memory region information.
Key vDPA driver ops implemented:
-
ifcvf_dev_config:
Enable VF data path with virtio information provided by vhost lib, including IOMMU programming to enable VF DMA to VM's memory, VFIO interrupt setup to route HW interrupt to virtio driver, create notify relay thread to translate virtio driver's kick to a MMIO write onto HW, HW queues configuration.-
ifcvf_dev_close:
Revoke all the setup inifcvf_dev_config.Live migration feature is supported by IFCVF and this driver enables it. For the dirty page logging, VF helps to log for packet buffer write, driver helps to make the used ring as dirty when device stops.
Because vDPA driver needs to set up MSI-X vector to interrupt the guest, only vfio-pci is supported currently.
Signed-off-by Xiao Wang <[email protected]>Signed-off-by Rosen Xu <[email protected]>Reviewed-by Maxime Coquelin <[email protected]>--- config/common_base | 7 + config/common_linuxapp | 1 + drivers/net/Makefile | 3 + drivers/net/ifc/Makefile | 36 ++ drivers/net/ifc/base/ifcvf.c | 329 +++++++++++++ drivers/net/ifc/base/ifcvf.h | 160 +++++++ drivers/net/ifc/base/ifcvf_osdep.h | 52 +++ drivers/net/ifc/ifcvf_vdpa.c | 840 ++++++++++++++++++++++++++++++++++ drivers/net/ifc/rte_ifcvf_version.map | 4 + mk/rte.app.mk | 3 + 10 files changed, 1435 insertions(+) create mode 100644 drivers/net/ifc/Makefile create mode 100644 drivers/net/ifc/base/ifcvf.c create mode 100644 drivers/net/ifc/base/ifcvf.h create mode 100644 drivers/net/ifc/base/ifcvf_osdep.h create mode 100644 drivers/net/ifc/ifcvf_vdpa.c create mode 100644 drivers/net/ifc/rte_ifcvf_version.mapconfig/common_base +0
-0
config/common_base CONFIG_RTE_LIBRTE_VHOST_DEBUG=n · line 804
Quoted 9 lines
config/common_base +6
-0@@ -796,6 +796,13 @@ CONFIG_RTE_LIBRTE_VHOST_DEBUG=n # CONFIG_RTE_LIBRTE_PMD_VHOST=n +# +# Compile IFCVF driver +# To compile, CONFIG_RTE_LIBRTE_VHOST and CONFIG_RTE_EAL_VFIO +# should be enabled. +# +CONFIG_RTE_LIBRTE_IFCVF_VDPA=n
I believe better to keep "PMD" in config option for consistency:CONFIG_RTE_LIBRTE_IFCVF_VDPA_PMD
And add this into PMD section of the doc.
<...>
config/common_base CONFIG_RTE_LIBRTE_VHOST_DEBUG=n
Quoted 9 lines
config/common_base +9
-0+/* + * The set of PCI devices this driver supports. + */ +static const struct rte_pci_id pci_id_ifcvf_map[] = { + { .class_id = RTE_CLASS_ANY_ID, + .vendor_id = IFCVF_VENDOR_ID, + .device_id = IFCVF_DEVICE_ID, + .subsystem_vendor_id = IFCVF_SUBSYS_VENDOR_ID, + .subsystem_device_id = IFCVF_SUBSYS_DEVICE_ID,
Can be good to add comment that these can be same with virtio device id to clarify this is known/expected.
config/common_base
Quoted 10 lines
config/common_base +10
-0+ }, + + { .vendor_id = 0, /* sentinel */ + }, +}; + +static struct rte_pci_driver rte_ifcvf_vdpa = { + .driver = { + .name = "net_ifcvf", + },
No need to set name, already done by RTE_PMD_REGISTER_PCI
<...>
config/common_base
Quoted 5 lines
config/common_base +5
-0+RTE_INIT(ifcvf_vdpa_init_log); +static void +ifcvf_vdpa_init_log(void) +{ + ifcvf_vdpa_logtype = rte_log_register("net.ifcvf_vdpa");
latest format is "pmd.net.ifcvf_vdpa"
Re: [PATCH v5 2/4] net/virtio: skip device probe in vdpa mode
In reply to Xiao Wangdrivers/net/virtio/virtio_ethdev.c
Quoted 15 lines · Xiao Wang
If we want a virtio device to work in vDPA (vhost data path acceleration) mode, we could add a "vdpa=1" devarg for this device to specify the mode.
This patch let virtio pmd skip device probe when detecting this parameter.
Signed-off-by Xiao Wang <[email protected]>Reviewed-by Maxime Coquelin <[email protected]>--- drivers/net/virtio/virtio_ethdev.c | 43 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)drivers/net/virtio/virtio_ethdev.c +0
-0
This devargs needs to be documented in virtio documentation.
Re: [PATCH v5 0/4] add ifcvf vdpa driver
In reply to Xiao WangQuoted 75 lines · Xiao Wang
This patch set has dependency on http://dpdk.org/dev/patchwork/patch/36772/
(vhost: support selective datapath).IFCVF driver
============
The IFCVF vDPA (vhost data path acceleration) driver provides support for the Intel FPGA 100G VF (IFCVF). IFCVF's datapath is virtio ring compatible, it works as a HW vhost backend which can send/receive packets to/from virtio directly by DMA. Besides, it supports dirty page logging and device state report/restore. This driver enables its vDPA functionality with live migration feature.vDPA mode
=========
IFCVF's vendor ID and device ID are same as that of virtio net pci device, with its specific subsystem vendor ID and device ID. To let the device be probed by IFCVF driver, adding "vdpa=1" parameter helps to specify that this device is to be used in vDPA mode, rather than polling mode, virtio pmd will skip when it detects this message.Container per device
====================
vDPA needs to create different containers for different devices, thus this patch set adds some APIs in eal/vfio to support multiple container, e.g.
-rte_vfio_create_container
-rte_vfio_destroy_container
-rte_vfio_bind_group
-rte_vfio_unbind_groupBy this extension, a device can be put into a new specific container, rather than the previous default container.
IFCVF vDPA details
==================
Key vDPA driver ops implemented:
-ifcvf_dev_config:
Enable VF data path with virtio information provided by vhost lib, including IOMMU programming to enable VF DMA to VM's memory, VFIO interrupt setup to route HW interrupt to virtio driver, create notify relay thread to translate virtio driver's kick to a MMIO write onto HW, HW queues configuration.This function gets called to set up HW data path backend when virtio driver in VM gets ready.
-
ifcvf_dev_close:
Revoke all the setup inifcvf_dev_config.This function gets called when virtio driver stops device in VM.
Change log
==========
v5:
- Fix compilation in BSD, remove therte_vfio.hincluding in BSD.v4:
- Rebase on Zhihong's latest vDPA lib patch, with vDPA ops names change.
- Remove API "rte_vfio_get_group_fd", "rte_vfio_bind_group" will return the fd.
- Align thevfio_cfgsearch internal APIs naming.v3:
- Add doc and release note for the new driver.
- Remove the vdev concept, make the driver as a PCI driver, it will get probed by PCI bus driver.
- Rebase on the v4 vDPA lib patch, register a vDPA device instead of a engine.
- Remove the PCI API exposure accordingly.
- Move theMAX_VFIO_CONTAINERSdefinition to config file.
- Let virtio pmd skips when a virtio device needs to work in vDPA mode.v2:
- Rename functionpci_get_kernel_driver_by_pathtorte_pci_device_kdriver_nameto make the API generic cross Linux and BSD, make it as EXPERIMENTAL.
- Rebase on Zhihong's vDPA v3 patch set.
- Minor code cleanup on vfio extension.
Quoted 5 lines
Xiao Wang (4):
eal/vfio: add multiple container support
net/virtio: skip device probe in vdpa mode
net/ifcvf: add ifcvf vdpa driver
doc: add ifcvf driver document and release note
Hi Xiao,
Current patch doesn't apply cleanly after latest updates, can you please rebase it onto latest next-net, also there are a few minor comments I put into individual patches can you please check them?
After above changes done, please add for series:
Re: [PATCH v5 0/4] add ifcvf vdpa driver
Hi,
Quoted 99 lines
-----Original Message-----
From: Yigit, Ferruh
Sent: Thursday, April 12, 2018 2:59 AM
To: Wang, Xiao W <[email protected]>
Cc: [email protected]; [email protected]; Wang, Zhihong <[email protected]>; Tan, Jianfeng <[email protected]>; Bie, Tiwei <[email protected]>; Liang, Cunming <[email protected]>; Daly, Dan <[email protected]>; [email protected]; [email protected]; Burakov, Anatoly <[email protected]>; [email protected]
Subject: Re: [PATCH v5 0/4] add ifcvf vdpa driverQuoted 1 line · Xiao Wang
This patch set has dependency on
http://dpdk.org/dev/patchwork/patch/36772/
Quoted 5 lines
(vhost: support selective datapath).
IFCVF driver
============
The IFCVF vDPA (vhost data path acceleration) driver provides support forthe
Quoted 26 lines
Intel FPGA 100G VF (IFCVF). IFCVF's datapath is virtio ring compatible, it works as a HW vhost backend which can send/receive packets to/from virtio directly by DMA. Besides, it supports dirty page logging and device state report/restore. This driver enables its vDPA functionality with live migration feature.
vDPA mode
=========
IFCVF's vendor ID and device ID are same as that of virtio net pci device, with its specific subsystem vendor ID and device ID. To let the device be probed by IFCVF driver, adding "vdpa=1" parameter helps to specify that this device is to be used in vDPA mode, rather than polling mode, virtio pmd will skip when it detects this message.Container per device
====================
vDPA needs to create different containers for different devices, thus this patch set adds some APIs in eal/vfio to support multiple container, e.g.
-rte_vfio_create_container
-rte_vfio_destroy_container
-rte_vfio_bind_group
-rte_vfio_unbind_groupBy this extension, a device can be put into a new specific container, rather than the previous default container.
Quoted 6 lines
IFCVF vDPA details
==================
Key vDPA driver ops implemented:
-ifcvf_dev_config:
Enable VF data path with virtio information provided by vhost lib, including IOMMU programming to enable VF DMA to VM's memory, VFIO interruptsetup to
Quoted 11 lines
route HW interrupt to virtio driver, create notify relay thread to translate virtio driver's kick to a MMIO write onto HW, HW queues configuration.
This function gets called to set up HW data path backend when virtio driver in VM gets ready.
-
ifcvf_dev_close:
Revoke all the setup inifcvf_dev_config.This function gets called when virtio driver stops device in VM.
Quoted 8 lines
Change log
==========
v5:
- Fix compilation in BSD, remove therte_vfio.hincluding in BSD.v4:
- Rebase on Zhihong's latest vDPA lib patch, with vDPA ops names change.
- Remove API "rte_vfio_get_group_fd", "rte_vfio_bind_group" will return thefd.
Quoted 11 lines
- Align the
vfio_cfgsearch internal APIs naming.v3:
- Add doc and release note for the new driver.
- Remove the vdev concept, make the driver as a PCI driver, it will get probed by PCI bus driver.
- Rebase on the v4 vDPA lib patch, register a vDPA device instead of a engine.
- Remove the PCI API exposure accordingly.
- Move theMAX_VFIO_CONTAINERSdefinition to config file.
- Let virtio pmd skips when a virtio device needs to work in vDPA mode.Quoted 2 lines
v2:
- Rename functionpci_get_kernel_driver_by_pathto
rte_pci_device_kdriver_nameQuoted 10 lines
to make the API generic cross Linux and BSD, make it as EXPERIMENTAL.
- Rebase on Zhihong's vDPA v3 patch set.
- Minor code cleanup on vfio extension.Xiao Wang (4):
eal/vfio: add multiple container support
net/virtio: skip device probe in vdpa mode
net/ifcvf: add ifcvf vdpa driver
doc: add ifcvf driver document and release note
Quoted 8 lines
Hi Xiao,
Current patch doesn't apply cleanly after latest updates, can you please rebase it onto latest next-net, also there are a few minor comments I put into individual patches can you please check them?
After above changes done, please add for series:
Reviewed-by Ferruh Yigit <[email protected]>
Thanks, will update according to that.
BRs,
Xiao
v6 cover add ifcvf vdpa driver
In reply to Xiao WangIFCVF driver
============
The IFCVF vDPA (vhost data path acceleration) driver provides support for the Intel FPGA 100G VF (IFCVF). IFCVF's datapath is virtio ring compatible, it works as a HW vhost backend which can send/receive packets to/from virtio directly by DMA. Besides, it supports dirty page logging and device state report/restore. This driver enables its vDPA functionality with live migration feature.
vDPA mode
=========
IFCVF's vendor ID and device ID are same as that of virtio net pci device, with its specific subsystem vendor ID and device ID. To let the device be probed by IFCVF driver, adding "vdpa=1" parameter helps to specify that this device is to be used in vDPA mode, rather than polling mode, virtio pmd will skip when it detects this message.
Container per device
====================
vDPA needs to create different containers for different devices, thus this patch set adds some APIs in eal/vfio to support multiple container, e.g.
- rte_vfio_create_container
- rte_vfio_destroy_container
- rte_vfio_bind_group
- rte_vfio_unbind_group
By this extension, a device can be put into a new specific container, rather than the previous default container.
IFCVF vDPA details
==================
Key vDPA driver ops implemented:
- ifcvf_dev_config:
Enable VF data path with virtio information provided by vhost lib, including IOMMU programming to enable VF DMA to VM's memory, VFIO interrupt setup to route HW interrupt to virtio driver, create notify relay thread to translate virtio driver's kick to a MMIO write onto HW, HW queues configuration.
This function gets called to set up HW data path backend when virtio driver in VM gets ready.
- ifcvf_dev_close:
Revoke all the setup in ifcvf_dev_config.
This function gets called when virtio driver stops device in VM.
Change log
==========
v6:
- Rebase on master branch.
- Document "vdpa" devarg in virtio documentation.
- Rename ifcvf config option to CONFIG_RTE_LIBRTE_IFCVF_VDPA_PMD for consistensy, and add it into driver documentation.
- Add comments for ifcvf device ID.
- Minor code cleaning.
v5:
- Fix compilation in BSD, remove the rte_vfio.h including in BSD.
v4:
- Rebase on Zhihong's latest vDPA lib patch, with vDPA ops names change.
- Remove API "rte_vfio_get_group_fd", "rte_vfio_bind_group" will return the fd.
- Align the vfio_cfg search internal APIs naming.
v3:
- Add doc and release note for the new driver.
- Remove the vdev concept, make the driver as a PCI driver, it will get probed by PCI bus driver.
- Rebase on the v4 vDPA lib patch, register a vDPA device instead of a engine.
- Remove the PCI API exposure accordingly.
- Move the MAX_VFIO_CONTAINERS definition to config file.
- Let virtio pmd skips when a virtio device needs to work in vDPA mode.
v2:
- Rename function pci_get_kernel_driver_by_path to rte_pci_device_kdriver_name to make the API generic cross Linux and BSD, make it as EXPERIMENTAL.
- Rebase on Zhihong's vDPA v3 patch set.
- Minor code cleanup on vfio extension.
Xiao Wang (4):
eal/vfio: add multiple container support
net/virtio: skip device probe in vdpa mode
net/ifcvf: add ifcvf vdpa driver
doc: add ifcvf driver document and release note
config/common_base | 8 + config/common_linuxapp | 1 + doc/guides/nics/features/ifcvf.ini | 8 + doc/guides/nics/ifcvf.rst | 98 ++++ doc/guides/nics/index.rst | 1 + doc/guides/nics/virtio.rst | 13 + doc/guides/rel_notes/release_18_05.rst | 9 + drivers/net/Makefile | 3 + drivers/net/ifc/Makefile | 36 ++ drivers/net/ifc/base/ifcvf.c | 329 ++++++++++++ drivers/net/ifc/base/ifcvf.h | 160 ++++++ drivers/net/ifc/base/ifcvf_osdep.h | 52 ++ drivers/net/ifc/ifcvf_vdpa.c | 845 +++++++++++++++++++++++++++++++ drivers/net/ifc/rte_ifcvf_version.map | 4 + drivers/net/virtio/virtio_ethdev.c | 43 ++ lib/librte_eal/bsdapp/eal/eal.c | 50 ++ lib/librte_eal/common/include/rte_vfio.h | 113 +++++ lib/librte_eal/linuxapp/eal/eal_vfio.c | 522 +++++++++++++++---- lib/librte_eal/linuxapp/eal/eal_vfio.h | 1 + lib/librte_eal/rte_eal_version.map | 6 + mk/rte.app.mk | 3 + 21 files changed, 2213 insertions(+), 92 deletions(-) create mode 100644 doc/guides/nics/features/ifcvf.ini create mode 100644 doc/guides/nics/ifcvf.rst create mode 100644 drivers/net/ifc/Makefile create mode 100644 drivers/net/ifc/base/ifcvf.c create mode 100644 drivers/net/ifc/base/ifcvf.h create mode 100644 drivers/net/ifc/base/ifcvf_osdep.h create mode 100644 drivers/net/ifc/ifcvf_vdpa.c create mode 100644 drivers/net/ifc/rte_ifcvf_version.map
Signature · 1 line
2.15.1
PATCH v6 1/4 eal/vfio: add multiple container support
Currently eal vfio framework binds vfio group fd to the default container fd during rte_vfio_setup_device, while in some cases, e.g. vDPA (vhost data path acceleration), we want to put vfio group to a separate container and program IOMMU via this container.
This patch adds some APIs to support container creating and device binding with a container.
A driver could use "rte_vfio_create_container" helper to create a new container from eal, use "rte_vfio_bind_group" to bind a device to the newly created container.
During rte_vfio_setup_device, the container bound with the device will be used for IOMMU setup.
--- config/common_base | 1 + lib/librte_eal/bsdapp/eal/eal.c | 50 +++ lib/librte_eal/common/include/rte_vfio.h | 113 +++++++ lib/librte_eal/linuxapp/eal/eal_vfio.c | 522 +++++++++++++++++++++++++------ lib/librte_eal/linuxapp/eal/eal_vfio.h | 1 + lib/librte_eal/rte_eal_version.map | 6 + 6 files changed, 601 insertions(+), 92 deletions(-)
config/common_base +1 -0
@@ -74,6 +74,7 @@ CONFIG_RTE_EAL_ALWAYS_PANIC_ON_ERROR=n CONFIG_RTE_EAL_IGB_UIO=n CONFIG_RTE_EAL_VFIO=n CONFIG_RTE_MAX_VFIO_GROUPS=64 +CONFIG_RTE_MAX_VFIO_CONTAINERS=64 CONFIG_RTE_MALLOC_DEBUG=n CONFIG_RTE_EAL_NUMA_AWARE_HUGEPAGES=n CONFIG_RTE_USE_LIBBSD=n
lib/librte_eal/bsdapp/eal/eal.c +50 -0
59 lines not on this page · raw message
lib/librte_eal/common/include/rte_vfio.h +113 -0
125 lines not on this page · raw message
lib/librte_eal/linuxapp/eal/eal_vfio.c +430 -92
719 lines not on this page · raw message
lib/librte_eal/linuxapp/eal/eal_vfio.h +1 -0
@@ -86,6 +86,7 @@ struct vfio_iommu_spapr_tce_info {#endif #define VFIO_MAX_GROUPS RTE_MAX_VFIO_GROUPS +#define VFIO_MAX_CONTAINERS RTE_MAX_VFIO_CONTAINERS/* * Function prototypes for VFIO multiprocess sync functions
lib/librte_eal/rte_eal_version.map +6 -0
@@ -258,5 +258,11 @@ EXPERIMENTAL { rte_service_start_with_defaults; rte_socket_count; rte_socket_id_by_idx; + rte_vfio_bind_group; + rte_vfio_create_container; + rte_vfio_destroy_container; + rte_vfio_dma_map; + rte_vfio_dma_unmap; + rte_vfio_unbind_group; } DPDK_18.02;
Signature · 1 line
2.15.1
PATCH v6 3/4 net/ifcvf: add ifcvf vdpa driver
In reply to Xiao WangThe IFCVF vDPA (vhost data path acceleration) driver provides support for the Intel FPGA 100G VF (IFCVF). IFCVF's datapath is virtio ring compatible, it works as a HW vhost backend which can send/receive packets to/from virtio directly by DMA.
Different VF devices serve different virtio frontends which are in different VMs, so each VF needs to have its own DMA address translation service. During the driver probe a new container is created, with this container vDPA driver can program DMA remapping table with the VM's memory region information.
Key vDPA driver ops implemented:
- ifcvf_dev_config:
Enable VF data path with virtio information provided by vhost lib, including IOMMU programming to enable VF DMA to VM's memory, VFIO interrupt setup to route HW interrupt to virtio driver, create notify relay thread to translate virtio driver's kick to a MMIO write onto HW, HW queues configuration.
- ifcvf_dev_close:
Revoke all the setup in ifcvf_dev_config.
Live migration feature is supported by IFCVF and this driver enables it. For the dirty page logging, VF helps to log for packet buffer write, driver helps to make the used ring as dirty when device stops.
Because vDPA driver needs to set up MSI-X vector to interrupt the guest, only vfio-pci is supported currently.
--- config/common_base | 7 + config/common_linuxapp | 1 + drivers/net/Makefile | 3 + drivers/net/ifc/Makefile | 36 ++ drivers/net/ifc/base/ifcvf.c | 329 +++++++++++++ drivers/net/ifc/base/ifcvf.h | 160 +++++++ drivers/net/ifc/base/ifcvf_osdep.h | 52 +++ drivers/net/ifc/ifcvf_vdpa.c | 845 ++++++++++++++++++++++++++++++++++ drivers/net/ifc/rte_ifcvf_version.map | 4 + mk/rte.app.mk | 3 + 10 files changed, 1440 insertions(+) create mode 100644 drivers/net/ifc/Makefile create mode 100644 drivers/net/ifc/base/ifcvf.c create mode 100644 drivers/net/ifc/base/ifcvf.h create mode 100644 drivers/net/ifc/base/ifcvf_osdep.h create mode 100644 drivers/net/ifc/ifcvf_vdpa.c create mode 100644 drivers/net/ifc/rte_ifcvf_version.map
config/common_base +7 -0
@@ -790,6 +790,13 @@ CONFIG_RTE_LIBRTE_VHOST_DEBUG=n # CONFIG_RTE_LIBRTE_PMD_VHOST=n +# +# Compile IFCVF driver +# To compile, CONFIG_RTE_LIBRTE_VHOST and CONFIG_RTE_EAL_VFIO +# should be enabled. +# +CONFIG_RTE_LIBRTE_IFCVF_VDPA_PMD=n + # # Compile the test application #
config/common_linuxapp +1 -0
@@ -15,6 +15,7 @@ CONFIG_RTE_LIBRTE_PMD_KNI=y CONFIG_RTE_LIBRTE_VHOST=y CONFIG_RTE_LIBRTE_VHOST_NUMA=y CONFIG_RTE_LIBRTE_PMD_VHOST=y +CONFIG_RTE_LIBRTE_IFCVF_VDPA_PMD=y CONFIG_RTE_LIBRTE_PMD_AF_PACKET=y CONFIG_RTE_LIBRTE_PMD_TAP=y CONFIG_RTE_LIBRTE_AVP_PMD=y
drivers/net/Makefile +3 -0
@@ -57,6 +57,9 @@ endif # $(CONFIG_RTE_LIBRTE_SCHED) ifeq ($(CONFIG_RTE_LIBRTE_VHOST),y) DIRS-$(CONFIG_RTE_LIBRTE_PMD_VHOST) += vhost +ifeq ($(CONFIG_RTE_EAL_VFIO),y) +DIRS-$(CONFIG_RTE_LIBRTE_IFCVF_VDPA_PMD) += ifc +endif endif # $(CONFIG_RTE_LIBRTE_VHOST) ifeq ($(CONFIG_RTE_LIBRTE_MVPP2_PMD),y)
drivers/net/ifc/Makefile new file +36 -0
@@ -0,0 +1,36 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2018 Intel Corporation + +include $(RTE_SDK)/mk/rte.vars.mk + +# +# library name +# +LIB = librte_ifcvf_vdpa.a + +LDLIBS += -lpthread +LDLIBS += -lrte_eal -lrte_pci -lrte_vhost -lrte_bus_pci + +CFLAGS += -O3 +CFLAGS += $(WERROR_FLAGS) +CFLAGS += -DALLOW_EXPERIMENTAL_API +CFLAGS += -I$(RTE_SDK)/lib/librte_eal/linuxapp/eal + +# +# Add extra flags for base driver source files to disable warnings in them +# +BASE_DRIVER_OBJS=$(sort $(patsubst %.c,%.o,$(notdir $(wildcard $(SRCDIR)/base/*.c)))) + +VPATH += $(SRCDIR)/base + +EXPORT_MAP := rte_ifcvf_version.map + +LIBABIVER := 1 + +# +# all source are stored in SRCS-y +# +SRCS-$(CONFIG_RTE_LIBRTE_IFCVF_VDPA_PMD) += ifcvf_vdpa.c +SRCS-$(CONFIG_RTE_LIBRTE_IFCVF_VDPA_PMD) += ifcvf.c + +include $(RTE_SDK)/mk/rte.lib.mk
drivers/net/ifc/base/ifcvf.c new file +329 -0
329 lines not on this page · raw message
drivers/net/ifc/base/ifcvf.h new file +160 -0
160 lines not on this page · raw message
drivers/net/ifc/base/ifcvf_osdep.h new file +52 -0
52 lines not on this page · raw message
drivers/net/ifc/ifcvf_vdpa.c new file +845 -0
845 lines not on this page · raw message
drivers/net/ifc/rte_ifcvf_version.map new file +4 -0
@@ -0,0 +1,4 @@ +DPDK_18.05 { + + local: *; +};
mk/rte.app.mk +3 -0
@@ -185,6 +185,9 @@ _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 +ifeq ($(CONFIG_RTE_EAL_VFIO),y) +_LDLIBS-$(CONFIG_RTE_LIBRTE_IFCVF_VDPA_PMD) += -lrte_ifcvf_vdpa +endif # $(CONFIG_RTE_EAL_VFIO) endif # $(CONFIG_RTE_LIBRTE_VHOST) _LDLIBS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += -lrte_pmd_vmxnet3_uio
Signature · 1 line
2.15.1
PATCH v6 4/4 doc: add ifcvf driver document and release note
In reply to Xiao Wang--- doc/guides/nics/features/ifcvf.ini | 8 +++ doc/guides/nics/ifcvf.rst | 98 ++++++++++++++++++++++++++++++++++ doc/guides/nics/index.rst | 1 + doc/guides/rel_notes/release_18_05.rst | 9 ++++ 4 files changed, 116 insertions(+) create mode 100644 doc/guides/nics/features/ifcvf.ini create mode 100644 doc/guides/nics/ifcvf.rst
doc/guides/nics/features/ifcvf.ini new file +8 -0
@@ -0,0 +1,8 @@ +; +; Supported features of the 'ifcvf' vDPA driver. +; +; Refer to default.ini for the full list of available PMD features. +; +[Features] +x86-32 = Y +x86-64 = Y
doc/guides/nics/ifcvf.rst new file +98 -0
98 lines not on this page · raw message
doc/guides/nics/index.rst +1 -0
@@ -44,6 +44,7 @@ Network Interface Controller Drivers vmxnet3 pcap_ring fail_safe + ifcvf **Figures**
doc/guides/rel_notes/release_18_05.rst +9 -0
@@ -84,6 +84,15 @@ API Changes Also, make sure to start the actual text at the margin. ========================================================= +* **Added IFCVF vDPA driver.** + + Added IFCVF vDPA driver to support Intel FPGA 100G VF device. IFCVF works + as a HW vhost data path accelerator, it supports live migration and is + compatible with virtio 0.95 and 1.0. This driver registers ifcvf vDPA driver + to vhost lib, when virtio connected, with the help of the registered vDPA + driver the assigned VF gets configured to Rx/Tx directly to VM's virtio + vrings. + ABI Changes -----------
Signature · 1 line
2.15.1
PATCH v6 2/4 net/virtio: skip device probe in vdpa mode
In reply to Xiao WangIf we want a virtio device to work in vDPA (vhost data path acceleration) mode, we could add a "vdpa=1" devarg for this device to specify the mode.
This patch let virtio pmd skip device probe when detecting this parameter.
--- doc/guides/nics/virtio.rst | 13 ++++++++++++ drivers/net/virtio/virtio_ethdev.c | 43 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+)
doc/guides/nics/virtio.rst +13 -0
@@ -318,3 +318,16 @@ Here we use l3fwd-power as an example to show how to get started. $ l3fwd-power -l 0-1 -- -p 1 -P --config="(0,0,1)" \ --no-numa --parse-ptype + + +Virtio PMD arguments +-------------------- + +The user can specify below argument in devargs. + +#. ``vdpa``: + + A virtio device could also be driven by vDPA (vhost data path acceleration) + driver, and works as a HW vhost backend. This argument is used to specify + a virtio device needs to work in vDPA mode. + (Default: 0 (disabled))
drivers/net/virtio/virtio_ethdev.c +43 -0
58 lines not on this page · raw message
Signature · 1 line
2.15.1
Re: [PATCH v6 1/4] eal/vfio: add multiple container support
In reply to Xiao WangQuoted 12 lines · Xiao Wang
Currently eal vfio framework binds vfio group fd to the default container fd during
rte_vfio_setup_device, while in some cases, e.g. vDPA (vhost data path acceleration), we want to put vfio group to a separate container and program IOMMU via this container.This patch adds some APIs to support container creating and device binding with a container.
A driver could use "
rte_vfio_create_container" helper to create a new container from eal, use "rte_vfio_bind_group" to bind a device to the newly created container.
Quoted 8 lines
During
rte_vfio_setup_device, the container bound with the device will be used for IOMMU setup.Signed-off-by Junjie Chen <[email protected]>Signed-off-by Xiao Wang <[email protected]>Reviewed-by Maxime Coquelin <[email protected]>Reviewed-by Ferruh Yigit <[email protected]>---
Apologies for late review. Some comments below.
<...>
Quoted 10 lines
lib/librte_eal/common/include/rte_vfio.h +2
-0+struct rte_memseg ; +/** * Setup vfio_cfg for the device identified by its address. * It discovers the configured I/O MMU groups or sets a new one for the device. @@ -131,6 +133,117 @@ rte_vfio_clear_group(int vfio_group_fd); }#endif
<...>
Quoted 12 lines
lib/librte_eal/common/include/rte_vfio.h +12
-0+/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Perform dma mapping for devices in a conainer. +* +* @param container_fd +* the specified container fd +* +* @param dma_type +* the dma map type +*
lib/librte_eal/common/include/rte_vfio.h rte_vfio_clear_group(int vfio_group_fd); · line 224
Quoted 10 lines
lib/librte_eal/common/include/rte_vfio.h +10
-0+* @param ms +* the dma address region to map +* +* @return +* 0 if successful +* <0 if failed +*/ +int __rte_experimental +rte_vfio_dma_map (int container_fd,int dma_type,const struct rte_memseg *ms); +
First of all, why memseg, instead of va/iova/len? This seems like unnecessary attachment to internals of DPDK memory representation. Not all memory comes in memsegs, this makes the API unnecessarily specific to DPDK memory.
Also, why providing DMA type? There's already a VFIO type pointer in vfio_config - you can set this pointer for every new created container, so the user wouldn't have to care about IOMMU type. Is it not possible to figure out DMA type from within EAL VFIO? If not, maybe provide an API to do so, e.g. rte_vfio_container_set_dma_type()?
This will also need to be rebased on top of latest HEAD because there already is a similar DMA map/unmap API added, only without the container parameter. Perhaps rename these new functions to rte_vfio_container_(create|destroy|dma_map|dma_unmap)?
Quoted 24 lines
lib/librte_eal/common/include/rte_vfio.h +22
-0+/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Perform dma unmapping for devices in a conainer. +* +* @param container_fd +* the specified container fd +* +* @param dma_type +* the dma map type +* +* @param ms +* the dma address region to unmap +* +* @return +* 0 if successful +* <0 if failed +*/ +int __rte_experimental +rte_vfio_dma_unmap (int container_fd,int dma_type,const struct rte_memseg *ms); +#endif /* VFIO_PRESENT */
<...>
lib/librte_eal/linuxapp/eal/eal_vfio.c vfio_get_group_fd(int iommu_group_no) · line 57
Quoted 8 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +2
-2@@ -75,8 +53,8 @@ vfio_get_group_fd(int iommu_group_no)if (vfio_group_fd <0 ) {/* if file not found, it's not an error */ if (errno !=ENOENT ) { -RTE_LOG (ERR ,EAL ,"Cannot open %s: %s\n" , filename, -strerror (errno)); +RTE_LOG (ERR ,EAL ,"Cannot open %s: %s\n" , + filename,strerror (errno));
This looks like unintended change.
lib/librte_eal/linuxapp/eal/eal_vfio.c vfio_get_group_fd(int iommu_group_no) · line 70
Quoted 13 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +4
-2return -1 ; }@@ -86,8 +64,10 @@ vfio_get_group_fd(int iommu_group_no) vfio_group_fd =open (filename,O_RDWR );if (vfio_group_fd <0 ) {if (errno !=ENOENT ) { -RTE_LOG (ERR ,EAL ,"Cannot open %s: %s\n" , filename, -strerror (errno)); +RTE_LOG (ERR ,EAL , +"Cannot open %s: %s\n" , + filename, +strerror (errno));
This looks like unintended change.
Quoted 7 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +0
-0return -1 ; }return 0 ;@@ -95,21 +75,19 @@ vfio_get_group_fd(int iommu_group_no)/* noiommu group found */ }
lib/librte_eal/linuxapp/eal/eal_vfio.c vfio_get_group_fd(int iommu_group_no) · line 83
Quoted 10 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +2
-4- cur_grp->group_no = iommu_group_no; - cur_grp->fd = vfio_group_fd; - vfio_cfg.vfio_active_groups++;return vfio_group_fd; } -/* if we're in a secondary process, request group fd from the primary +/* +* if we're in a secondary process, request group fd from the primary * process via our socket */
This looks like unintended change.
lib/librte_eal/linuxapp/eal/eal_vfio.c vfio_get_group_fd(int iommu_group_no) · line 90
Quoted 11 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +4
-4else { -int socket_fd, ret; - - socket_fd =vfio_mp_sync_connect_to_primary (); +int ret; +int socket_fd =vfio_mp_sync_connect_to_primary ();if (socket_fd <0 ) { -RTE_LOG (ERR ,EAL ," cannot connect to primary process!\n" ); +RTE_LOG (ERR ,EAL , +" cannot connect to primary process!\n" );
This looks like unintended change.
lib/librte_eal/linuxapp/eal/eal_vfio.c vfio_get_group_fd(int iommu_group_no) · line 104
Quoted 9 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +1
-0return -1 ; }if (vfio_mp_sync_send_request (socket_fd,SOCKET_REQ_GROUP ) <0 ) {@@ -122,6 +100,7 @@ vfio_get_group_fd(int iommu_group_no)close (socket_fd);return -1 ; } + ret =vfio_mp_sync_receive_request (socket_fd);
This looks like unintended change.
(hint: "git revert -n HEAD && git add -p" is your friend :) )
Quoted 14 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +0
-3switch (ret) {case SOCKET_NO_FD :@@ -132,9 +111,6 @@ vfio_get_group_fd(int iommu_group_no)/* if we got the fd, store it and return it */ if (vfio_group_fd >0 ) {close (socket_fd); - cur_grp->group_no = iommu_group_no; - cur_grp->fd = vfio_group_fd; - vfio_cfg.vfio_active_groups++;return vfio_group_fd; }/* fall-through on error */ @@ -147,70 +123,349 @@ vfio_get_group_fd(int iommu_group_no)return -1 ;
<...>
Quoted 11 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +11
-0+int __rte_experimental +rte_vfio_create_container (void) +{ +struct vfio_config *vfio_cfg; +int i; + +/* Find an empty slot to store new vfio config */ +for (i =1 ; i <VFIO_MAX_CONTAINERS ; i++) { +if (vfio_cfgs[i] ==NULL ) +break ; + }
lib/librte_eal/linuxapp/eal/eal_vfio.c vfio_get_group_fd(int iommu_group_no) · line 202
Quoted 10 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +10
-0+ +if (i ==VFIO_MAX_CONTAINERS ) { +RTE_LOG (ERR ,EAL ,"exceed max vfio container limit\n" ); +return -1 ; + } + + vfio_cfgs[i] =rte_zmalloc ("vfio_container" ,sizeof (struct vfio_config ), +RTE_CACHE_LINE_SIZE ); +if (vfio_cfgs[i] ==NULL ) +return -ENOMEM ;
Is there a specific reason why 1) dynamic allocation is used (as opposed to just storing a static array), and 2) DPDK memory allocation is used? This seems like unnecessary complication.
Even if you were to decide to allocate memory instead of having a static array, you'll have to register for rte_eal_cleanup() to delete any allocated containers on DPDK exit. But, as i said, i think it would be better to keep it as static array.
Quoted 17 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +17
-0+ +RTE_LOG (INFO ,EAL ,"alloc container at slot %d\n" , i); + vfio_cfg = vfio_cfgs[i]; + vfio_cfg->vfio_active_groups =0 ; + vfio_cfg->vfio_container_fd =vfio_get_container_fd (); + +if (vfio_cfg->vfio_container_fd <0 ) { +rte_free (vfio_cfgs[i]); + vfio_cfgs[i] =NULL ; +return -1 ; + } + +for (i =0 ; i <VFIO_MAX_GROUPS ; i++) { + vfio_cfg->vfio_groups[i].group_no =-1 ; + vfio_cfg->vfio_groups[i].fd =-1 ; + vfio_cfg->vfio_groups[i].devices =0 ; + }
<...>
Quoted 6 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +1
-1@@ -665,41 +931,80 @@ vfio_get_group_no(const char *sysfs_base, }static int -vfio_type1_dma_map (int vfio_container_fd) +do_vfio_type1_dma_map (int vfio_container_fd,const struct rte_memseg *ms)
<...>
lib/librte_eal/linuxapp/eal/eal_vfio.c vfio_get_group_no(const char *sysfs_base, · line 963
Quoted 2 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +2
-0+static int +do_vfio_type1_dma_unmap (int vfio_container_fd,const struct rte_memseg *ms)
API's such as these two were recently added to DPDK.
Signature · 2 lines
Thanks, Anatoly
Re: [PATCH v6 1/4] eal/vfio: add multiple container support
Hi Anatoly,
Quoted 75 lines
-----Original Message-----
From: Burakov, Anatoly
Sent: Thursday, April 12, 2018 10:04 PM
To: Wang, Xiao W <[email protected]>; Yigit, Ferruh <[email protected]>
Cc: [email protected]; [email protected]; Wang, Zhihong <[email protected]>; Bie, Tiwei <[email protected]>; Tan, Jianfeng <[email protected]>; Liang, Cunming <[email protected]>; Daly, Dan <[email protected]>; [email protected]; [email protected]; [email protected]; Chen, Junjie J <[email protected]>
Subject: Re: [PATCH v6 1/4] eal/vfio: add multiple container supportQuoted 12 lines · Xiao Wang
Currently eal vfio framework binds vfio group fd to the default container fd during
rte_vfio_setup_device, while in some cases, e.g. vDPA (vhost data path acceleration), we want to put vfio group to a separate container and program IOMMU via this container.This patch adds some APIs to support container creating and device binding with a container.
A driver could use "
rte_vfio_create_container" helper to create a new container from eal, use "rte_vfio_bind_group" to bind a device to the newly created container.Quoted 8 lines
During
rte_vfio_setup_device, the container bound with the device will be used for IOMMU setup.Signed-off-by Junjie Chen <[email protected]>Signed-off-by Xiao Wang <[email protected]>Reviewed-by Maxime Coquelin <[email protected]>Reviewed-by Ferruh Yigit <[email protected]>---
Apologies for late review. Some comments below.
<...>
lib/librte_eal/common/include/rte_vfio.h
Quoted 6 lines
lib/librte_eal/common/include/rte_vfio.h +2
-0+struct rte_memseg ; +/** * Setup vfio_cfg for the device identified by its address. * It discovers the configured I/O MMU groups or sets a new one for the device.
Quoted 4 lines
(quoted diff) +0
-0@@ -131,6 +133,117 @@ rte_vfio_clear_group(int vfio_group_fd); } #endif<...>
Quoted 3 lines
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without priornotice
Quoted 16 lines
+ *
+ * Perform dma mapping for devices in a conainer.
+ *
+ * @paramcontainer_fd
+ * the specified container fd
+ *
+ * @paramdma_type
+ * the dma map type
+ *
+ * @param ms
+ * the dma address region to map
+ *
+ * @return
+ * 0 if successful
+ * <0 if failed
+ */Review
Quoted 2 lines
(quoted diff) +2
-0+int __rte_experimental +rte_vfio_dma_map(int container_fd, int dma_type, const struct
rte_memseg*ms);
Quoted 6 lines
Quoted 1 line
+
First of all, why memseg, instead of va/iova/len? This seems like unnecessary attachment to internals of DPDK memory representation. Not all memory comes in memsegs, this makes the API unnecessarily specific to DPDK memory.
Agree, will use va/iova/len.
Quoted 6 lines
Also, why providing DMA type? There's already a VFIO type pointer in
vfio_config- you can set this pointer for every new created container, so the user wouldn't have to care about IOMMU type. Is it not possible to figure out DMA type from within EAL VFIO? If not, maybe provide an API to do so, e.g.rte_vfio_container_set_dma_type()?
It's possible, EAL VFIO should be able to figure out a container's DMA type.
Quoted 5 lines
This will also need to be rebased on top of latest HEAD because there already is a similar DMA map/unmap API added, only without the container parameter. Perhaps rename these new functions to
rte_vfio_container_(create|destroy|dma_map|dma_unmap)?
OK, will check the latest HEAD and rebase on that.
Quoted 107 lines
Quoted 4 lines
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without priornotice
Quoted 16 lines
+ *
+ * Perform dma unmapping for devices in a conainer.
+ *
+ * @paramcontainer_fd
+ * the specified container fd
+ *
+ * @paramdma_type
+ * the dma map type
+ *
+ * @param ms
+ * the dma address region to unmap
+ *
+ * @return
+ * 0 if successful
+ * <0 if failed
+ */Review
Quoted 2 lines
(quoted diff) +2
-0+int __rte_experimental +rte_vfio_dma_unmap(int container_fd, int dma_type, const struct
rte_memseg*ms);Quoted 3 lines
+
#endif /*VFIO_PRESENT*/<...>
lib/librte_eal/linuxapp/eal/eal_vfio.c vfio_get_group_fd(int iommu_group_no) · line 78
Quoted 5 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +0
-1@@ -75,8 +53,8 @@ vfio_get_group_fd(int iommu_group_no)if (vfio_group_fd <0 ) {/* if file not found, it's not an error */ if (errno !=ENOENT ) { - RTE_LOG(ERR, EAL, "Cannot open %s: %s\n",filename,
lib/librte_eal/linuxapp/eal/eal_vfio.c vfio_get_group_fd(int iommu_group_no) · line 57
Quoted 3 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +2
-1- strerror(errno)); +RTE_LOG (ERR ,EAL ,"Cannot open %s: %s\n" , + filename,strerror (errno));This looks like unintended change.
lib/librte_eal/linuxapp/eal/eal_vfio.c vfio_get_group_fd(int iommu_group_no) · line 89
Quoted 8 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +0
-1return -1 ; }@@ -86,8 +64,10 @@ vfio_get_group_fd(int iommu_group_no) vfio_group_fd =open (filename,O_RDWR );if (vfio_group_fd <0 ) {if (errno !=ENOENT ) { - RTE_LOG(ERR, EAL, "Cannotopen %s: %s\n", filename,
lib/librte_eal/linuxapp/eal/eal_vfio.c vfio_get_group_fd(int iommu_group_no) · line 70
Quoted 5 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +4
-1- strerror(errno)); +RTE_LOG (ERR ,EAL , +"Cannot open %s: %s\n" , + filename, +strerror (errno));This looks like unintended change.
Quoted 7 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +0
-0return -1 ; }return 0 ;@@ -95,21 +75,19 @@ vfio_get_group_fd(int iommu_group_no)/* noiommu group found */ }lib/librte_eal/linuxapp/eal/eal_vfio.c vfio_get_group_fd(int iommu_group_no) · line 83
Quoted 10 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +2
-4- cur_grp->group_no = iommu_group_no; - cur_grp->fd = vfio_group_fd; - vfio_cfg.vfio_active_groups++;return vfio_group_fd; } -/* if we're in a secondary process, request group fd from the primary +/* +* if we're in a secondary process, request group fd from the primary * process via our socket */ This looks like unintended change.
lib/librte_eal/linuxapp/eal/eal_vfio.c vfio_get_group_fd(int iommu_group_no)
Quoted 9 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +2
-4else { -int socket_fd, ret; - - socket_fd =vfio_mp_sync_connect_to_primary (); +int ret; +int socket_fd =vfio_mp_sync_connect_to_primary ();if (socket_fd <0 ) { - RTE_LOG(ERR, EAL, " cannot connect to primaryprocess!\n");
lib/librte_eal/linuxapp/eal/eal_vfio.c vfio_get_group_fd(int iommu_group_no) · line 90
Quoted 2 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +2
-0+RTE_LOG (ERR ,EAL , +" cannot connect to primary process!\n" );This looks like unintended change.
lib/librte_eal/linuxapp/eal/eal_vfio.c vfio_get_group_fd(int iommu_group_no)
Quoted 3 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +0
-0return -1 ; } if (vfio_mp_sync_send_request(socket_fd,
SOCKET_REQ_GROUP) < 0) {lib/librte_eal/linuxapp/eal/eal_vfio.c vfio_get_group_fd(int iommu_group_no) · line 104
Quoted 6 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +1
-0@@ -122,6 +100,7 @@ vfio_get_group_fd(int iommu_group_no)close (socket_fd);return -1 ; } + ret =vfio_mp_sync_receive_request (socket_fd);This looks like unintended change.
Quoted 1 line
(hint: "git revert -n HEAD && git add -p" is your friend :) )
Thanks, will remove these diff.
Quoted 44 lines
Quoted 15 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +0
-3switch (ret) {case SOCKET_NO_FD :@@ -132,9 +111,6 @@ vfio_get_group_fd(int iommu_group_no)/* if we got the fd, store it and return it */ if (vfio_group_fd >0 ) {close (socket_fd); - cur_grp->group_no = iommu_group_no; - cur_grp->fd = vfio_group_fd; - vfio_cfg.vfio_active_groups++;return vfio_group_fd; }/* fall-through on error */ @@ -147,70 +123,349 @@ vfio_get_group_fd(int iommu_group_no)return -1 ;<...>
Quoted 11 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +11
-0+int __rte_experimental +rte_vfio_create_container (void) +{ +struct vfio_config *vfio_cfg; +int i; + +/* Find an empty slot to store new vfio config */ +for (i =1 ; i <VFIO_MAX_CONTAINERS ; i++) { +if (vfio_cfgs[i] ==NULL ) +break ; + }lib/librte_eal/linuxapp/eal/eal_vfio.c vfio_get_group_fd(int iommu_group_no) · line 202
Quoted 10 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +10
-0+ +if (i ==VFIO_MAX_CONTAINERS ) { +RTE_LOG (ERR ,EAL ,"exceed max vfio container limit\n" ); +return -1 ; + } + + vfio_cfgs[i] =rte_zmalloc ("vfio_container" ,sizeof (struct vfio_config ), +RTE_CACHE_LINE_SIZE ); +if (vfio_cfgs[i] ==NULL ) +return -ENOMEM ;Is there a specific reason why 1) dynamic allocation is used (as opposed to just storing a static array), and 2) DPDK memory allocation is used? This seems like unnecessary complication.
Quoted 5 lines
Even if you were to decide to allocate memory instead of having a static array, you'll have to register for
rte_eal_cleanup()to delete any allocated containers on DPDK exit. But, as i said, i think it would be better to keep it as static array.
Thanks for the suggestion, static array looks simpler and cleaner.
Quoted 28 lines
Quoted 17 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +17
-0+ +RTE_LOG (INFO ,EAL ,"alloc container at slot %d\n" , i); + vfio_cfg = vfio_cfgs[i]; + vfio_cfg->vfio_active_groups =0 ; + vfio_cfg->vfio_container_fd =vfio_get_container_fd (); + +if (vfio_cfg->vfio_container_fd <0 ) { +rte_free (vfio_cfgs[i]); + vfio_cfgs[i] =NULL ; +return -1 ; + } + +for (i =0 ; i <VFIO_MAX_GROUPS ; i++) { + vfio_cfg->vfio_groups[i].group_no =-1 ; + vfio_cfg->vfio_groups[i].fd =-1 ; + vfio_cfg->vfio_groups[i].devices =0 ; + }<...>
lib/librte_eal/linuxapp/eal/eal_vfio.c vfio_get_group_no(const char *sysfs_base, · line 934
Quoted 6 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +1
-1@@ -665,41 +931,80 @@ vfio_get_group_no(const char *sysfs_base, }static int -vfio_type1_dma_map (int vfio_container_fd) +do_vfio_type1_dma_map(int vfio_container_fd, const struct rte_memseg*ms)
Quoted 8 lines
<...>
Review
Quoted 2 lines
(quoted diff) +2
-0+static int +do_vfio_type1_dma_unmap(int vfio_container_fd, const struct
rte_memseg*ms)API's such as these two were recently added to DPDK.
Will check and rebase.
BRs,
Xiao
Quoted 4 lines
--
Thanks,
Anatoly
Re: [PATCH v6 1/4] eal/vfio: add multiple container support
Quoted 2 lines · Xiao W
Hi Anatoly,
<...>
Quoted 8 lines
Quoted 6 lines
Also, why providing DMA type? There's already a VFIO type pointer in
vfio_config- you can set this pointer for every new created container, so the user wouldn't have to care about IOMMU type. Is it not possible to figure out DMA type from within EAL VFIO? If not, maybe provide an API to do so, e.g.rte_vfio_container_set_dma_type()?It's possible, EAL VFIO should be able to figure out a container's DMA type.
You probably won't be able to do it until you add a group into the container, so probably best place to do it would be on group_bind?
Signature · 2 lines
Thanks, Anatoly
Re: [PATCH v6 1/4] eal/vfio: add multiple container support
Quoted 27 lines
-----Original Message-----
From: Burakov, Anatoly
Sent: Friday, April 13, 2018 12:24 AM
To: Wang, Xiao W <[email protected]>; Yigit, Ferruh <[email protected]>
Cc: [email protected]; [email protected]; Wang, Zhihong <[email protected]>; Bie, Tiwei <[email protected]>; Tan, Jianfeng <[email protected]>; Liang, Cunming <[email protected]>; Daly, Dan <[email protected]>; [email protected]; [email protected]; [email protected]; Chen, Junjie J <[email protected]>
Subject: Re: [PATCH v6 1/4] eal/vfio: add multiple container supportQuoted 2 lines · Xiao W
Hi Anatoly,
<...>
Quoted 7 lines
Quoted 6 lines
Also, why providing DMA type? There's already a VFIO type pointer in
vfio_config- you can set this pointer for every new created container, so the user wouldn't have to care about IOMMU type. Is it not possible to figure out DMA type from within EAL VFIO? If not, maybe provide an API to do so, e.g.rte_vfio_container_set_dma_type()?
Quoted 4 lines
Quoted 1 line
It's possible, EAL VFIO should be able to figure out a container's DMA type.
You probably won't be able to do it until you add a group into the container, so probably best place to do it would be on
group_bind?
Yes, the IOMMU type pointer could be set when group binding.
BRs,
Xiao
Quoted 4 lines
--
Thanks,
Anatoly
v7 cover add ifcvf vdpa driver
In reply to Xiao WangIFCVF driver
============
The IFCVF vDPA (vhost data path acceleration) driver provides support for the Intel FPGA 100G VF (IFCVF). IFCVF's datapath is virtio ring compatible, it works as a HW vhost backend which can send/receive packets to/from virtio directly by DMA. Besides, it supports dirty page logging and device state report/restore. This driver enables its vDPA functionality with live migration feature.
vDPA mode
=========
IFCVF's vendor ID and device ID are same as that of virtio net pci device, with its specific subsystem vendor ID and device ID. To let the device be probed by IFCVF driver, adding "vdpa=1" parameter helps to specify that this device is to be used in vDPA mode, rather than polling mode, virtio pmd will skip when it detects this message.
Container per device
====================
vDPA needs to create different containers for different devices, thus this patch set adds some APIs in eal/vfio to support multiple container, e.g.
- rte_vfio_create_container
- rte_vfio_destroy_container
- rte_vfio_bind_group
- rte_vfio_unbind_group
By this extension, a device can be put into a new specific container, rather than the previous default container.
IFCVF vDPA details
==================
Key vDPA driver ops implemented:
- ifcvf_dev_config:
Enable VF data path with virtio information provided by vhost lib, including IOMMU programming to enable VF DMA to VM's memory, VFIO interrupt setup to route HW interrupt to virtio driver, create notify relay thread to translate virtio driver's kick to a MMIO write onto HW, HW queues configuration.
This function gets called to set up HW data path backend when virtio driver in VM gets ready.
- ifcvf_dev_close:
Revoke all the setup in ifcvf_dev_config.
This function gets called when virtio driver stops device in VM.
Change log
==========
v7:
- Rebase on HEAD.
- Split the vfio patch into 2 parts, one for data structure extension, one for adding new API.
- Use static vfio_config array instead of dynamic alloating.
- Change rte_vfio_container_dma_map/unmap's parameters to use (va, iova, len).
v6:
- Rebase on master branch.
- Document "vdpa" devarg in virtio documentation.
- Rename ifcvf config option to CONFIG_RTE_LIBRTE_IFCVF_VDPA_PMD for consistensy, and add it into driver documentation.
- Add comments for ifcvf device ID.
- Minor code cleaning.
v5:
- Fix compilation in BSD, remove the rte_vfio.h including in BSD.
v4:
- Rebase on Zhihong's latest vDPA lib patch, with vDPA ops names change.
- Remove API "rte_vfio_get_group_fd", "rte_vfio_bind_group" will return the fd.
- Align the vfio_cfg search internal APIs naming.
v3:
- Add doc and release note for the new driver.
- Remove the vdev concept, make the driver as a PCI driver, it will get probed by PCI bus driver.
- Rebase on the v4 vDPA lib patch, register a vDPA device instead of a engine.
- Remove the PCI API exposure accordingly.
- Move the MAX_VFIO_CONTAINERS definition to config file.
- Let virtio pmd skips when a virtio device needs to work in vDPA mode.
v2:
- Rename function pci_get_kernel_driver_by_path to rte_pci_device_kdriver_name to make the API generic cross Linux and BSD, make it as EXPERIMENTAL.
- Rebase on Zhihong's vDPA v3 patch set.
- Minor code cleanup on vfio extension.
Xiao Wang (5):
vfio: extend data structure for multi container
vfio: add multi container support
net/virtio: skip device probe in vdpa mode
net/ifcvf: add ifcvf vdpa driver
doc: add ifcvf driver document and release note
config/common_base | 8 + config/common_linuxapp | 1 + doc/guides/nics/features/ifcvf.ini | 8 + doc/guides/nics/ifcvf.rst | 98 ++++ doc/guides/nics/index.rst | 1 + doc/guides/nics/virtio.rst | 13 + doc/guides/rel_notes/release_18_05.rst | 9 + drivers/net/Makefile | 3 + drivers/net/ifc/Makefile | 36 ++ drivers/net/ifc/base/ifcvf.c | 329 ++++++++++++ drivers/net/ifc/base/ifcvf.h | 160 ++++++ drivers/net/ifc/base/ifcvf_osdep.h | 52 ++ drivers/net/ifc/ifcvf_vdpa.c | 842 +++++++++++++++++++++++++++++++ drivers/net/ifc/rte_ifcvf_version.map | 4 + drivers/net/virtio/virtio_ethdev.c | 43 ++ lib/librte_eal/bsdapp/eal/eal.c | 52 ++ lib/librte_eal/common/include/rte_vfio.h | 119 +++++ lib/librte_eal/linuxapp/eal/eal_vfio.c | 723 +++++++++++++++++++++----- lib/librte_eal/linuxapp/eal/eal_vfio.h | 19 +- lib/librte_eal/rte_eal_version.map | 6 + mk/rte.app.mk | 3 + 21 files changed, 2377 insertions(+), 152 deletions(-) create mode 100644 doc/guides/nics/features/ifcvf.ini create mode 100644 doc/guides/nics/ifcvf.rst create mode 100644 drivers/net/ifc/Makefile create mode 100644 drivers/net/ifc/base/ifcvf.c create mode 100644 drivers/net/ifc/base/ifcvf.h create mode 100644 drivers/net/ifc/base/ifcvf_osdep.h create mode 100644 drivers/net/ifc/ifcvf_vdpa.c create mode 100644 drivers/net/ifc/rte_ifcvf_version.map
Signature · 1 line
2.15.1
PATCH v7 1/5 vfio: extend data structure for multi container
Currently eal vfio framework binds vfio group fd to the default container fd during rte_vfio_setup_device, while in some cases, e.g. vDPA (vhost data path acceleration), we want to put vfio group to a separate container and program IOMMU via this container.
This patch extends the vfio_config structure to contain per-container user_mem_maps and defines an array of vfio_config. The next patch will base on this to add container API.
--- config/common_base | 1 + lib/librte_eal/linuxapp/eal/eal_vfio.c | 407 ++++++++++++++++++++++----------- lib/librte_eal/linuxapp/eal/eal_vfio.h | 19 +- 3 files changed, 275 insertions(+), 152 deletions(-)
config/common_base +1 -0
@@ -87,6 +87,7 @@ CONFIG_RTE_EAL_ALWAYS_PANIC_ON_ERROR=n CONFIG_RTE_EAL_IGB_UIO=n CONFIG_RTE_EAL_VFIO=n CONFIG_RTE_MAX_VFIO_GROUPS=64 +CONFIG_RTE_MAX_VFIO_CONTAINERS=64 CONFIG_RTE_MALLOC_DEBUG=n CONFIG_RTE_EAL_NUMA_AWARE_HUGEPAGES=n CONFIG_RTE_USE_LIBBSD=n
lib/librte_eal/linuxapp/eal/eal_vfio.c +273 -134
772 lines not on this page · raw message
lib/librte_eal/linuxapp/eal/eal_vfio.h +1 -18
@@ -88,6 +88,7 @@ struct vfio_iommu_spapr_tce_info {#endif #define VFIO_MAX_GROUPS RTE_MAX_VFIO_GROUPS +#define VFIO_MAX_CONTAINERS RTE_MAX_VFIO_CONTAINERS/* * Function prototypes for VFIO multiprocess sync functions
@@ -98,24 +99,6 @@ int vfio_mp_sync_send_fd(int socket, int fd);int vfio_mp_sync_receive_fd (int socket);int vfio_mp_sync_connect_to_primary (void ); -/* -* we don't need to store device fd's anywhere since they can be obtained from -* the group fd via an ioctl() call. -*/ -struct vfio_group { -int group_no; -int fd; -int devices; -}; - -struct vfio_config { -int vfio_enabled; -int vfio_container_fd; -int vfio_active_groups; -const struct vfio_iommu_type *vfio_iommu_type; -struct vfio_group vfio_groups[VFIO_MAX_GROUPS ]; -}; -/* DMA mapping function prototype. * Takes VFIO container fd as a parameter. * Returns 0 on success, -1 on error.
Signature · 1 line
2.15.1
PATCH v7 2/5 vfio: add multi container support
In reply to Xiao WangThis patch adds APIs to support container create/destroy and device bind/unbind with a container. It also provides API for IOMMU programing on a specified container.
A driver could use "rte_vfio_create_container" helper to create a new container from eal, use "rte_vfio_bind_group" to bind a device to the newly created container. During rte_vfio_setup_device the container bound with the device will be used for IOMMU setup.
--- lib/librte_eal/bsdapp/eal/eal.c | 52 +++++ lib/librte_eal/common/include/rte_vfio.h | 119 ++++++++++++ lib/librte_eal/linuxapp/eal/eal_vfio.c | 316 +++++++++++++++++++++++++++++++ lib/librte_eal/rte_eal_version.map | 6 + 4 files changed, 493 insertions(+)
lib/librte_eal/bsdapp/eal/eal.c +52 -0
@@ -769,6 +769,14 @@ int rte_vfio_noiommu_is_enabled(void);int rte_vfio_clear_group (int vfio_group_fd);int rte_vfio_dma_map (uint64_t vaddr,uint64_t iova,uint64_t len);int rte_vfio_dma_unmap (uint64_t vaddr,uint64_t iova,uint64_t len); +int rte_vfio_container_create (void ); +int rte_vfio_container_destroy (int container_fd); +int rte_vfio_bind_group (int container_fd,int iommu_group_no); +int rte_vfio_unbind_group (int container_fd,int iommu_group_no); +int rte_vfio_container_dma_map (int container_fd,uint64_t vaddr, +uint64_t iova,uint64_t len); +int rte_vfio_container_dma_unmap (int container_fd,uint64_t vaddr, +uint64_t iova,uint64_t len); int rte_vfio_setup_device(__rte_unused const char *sysfs_base, __rte_unused const char *dev_addr,
@@ -818,3 +826,47 @@ rte_vfio_dma_unmap(uint64_t __rte_unused vaddr, uint64_t __rte_unused iova, {return -1 ; } + +int __rte_experimental +rte_vfio_container_create (void) +{ +return -1 ; +} + +int __rte_experimental +rte_vfio_container_destroy(__rte_unused int container_fd) +{ +return -1 ; +} + +int __rte_experimental +rte_vfio_bind_group(__rte_unused int container_fd, + __rte_unused int iommu_group_no) +{ +return -1 ; +} + +int __rte_experimental +rte_vfio_unbind_group(__rte_unused int container_fd, + __rte_unused int iommu_group_no) +{ +return -1 ; +} + +int __rte_experimental +rte_vfio_container_dma_map(__rte_unused int container_fd, + __rte_unused uint64_t vaddr, + __rte_unused uint64_t iova, + __rte_unused uint64_t len) +{ +return -1 ; +} + +int __rte_experimental +rte_vfio_container_dma_unmap(__rte_unused int container_fd, + __rte_unused uint64_t vaddr, + __rte_unused uint64_t iova, + __rte_unused uint64_t len) +{ +return -1 ; +}
lib/librte_eal/common/include/rte_vfio.h +119 -0
125 lines not on this page · raw message
lib/librte_eal/linuxapp/eal/eal_vfio.c +316 -0
326 lines not on this page · raw message
lib/librte_eal/rte_eal_version.map +6 -0
@@ -284,7 +284,13 @@ EXPERIMENTAL { rte_service_start_with_defaults; rte_socket_count; rte_socket_id_by_idx; + rte_vfio_bind_group; + rte_vfio_container_create; + rte_vfio_container_destroy; + rte_vfio_container_dma_map; + rte_vfio_container_dma_unmap; rte_vfio_dma_map; rte_vfio_dma_unmap; + rte_vfio_unbind_group; } DPDK_18.02;
Signature · 1 line
2.15.1
PATCH v7 3/5 net/virtio: skip device probe in vdpa mode
In reply to Xiao WangIf we want a virtio device to work in vDPA (vhost data path acceleration) mode, we could add a "vdpa=1" devarg for this device to specify the mode.
This patch let virtio pmd skip device probe when detecting this parameter.
--- doc/guides/nics/virtio.rst | 13 ++++++++++++ drivers/net/virtio/virtio_ethdev.c | 43 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+)
doc/guides/nics/virtio.rst +13 -0
@@ -318,3 +318,16 @@ Here we use l3fwd-power as an example to show how to get started. $ l3fwd-power -l 0-1 -- -p 1 -P --config="(0,0,1)" \ --no-numa --parse-ptype + + +Virtio PMD arguments +-------------------- + +The user can specify below argument in devargs. + +#. ``vdpa``: + + A virtio device could also be driven by vDPA (vhost data path acceleration) + driver, and works as a HW vhost backend. This argument is used to specify + a virtio device needs to work in vDPA mode. + (Default: 0 (disabled))
drivers/net/virtio/virtio_ethdev.c +43 -0
58 lines not on this page · raw message
Signature · 1 line
2.15.1
PATCH v7 4/5 net/ifcvf: add ifcvf vdpa driver
In reply to Xiao WangThe IFCVF vDPA (vhost data path acceleration) driver provides support for the Intel FPGA 100G VF (IFCVF). IFCVF's datapath is virtio ring compatible, it works as a HW vhost backend which can send/receive packets to/from virtio directly by DMA.
Different VF devices serve different virtio frontends which are in different VMs, so each VF needs to have its own DMA address translation service. During the driver probe a new container is created, with this container vDPA driver can program DMA remapping table with the VM's memory region information.
Key vDPA driver ops implemented:
- ifcvf_dev_config:
Enable VF data path with virtio information provided by vhost lib, including IOMMU programming to enable VF DMA to VM's memory, VFIO interrupt setup to route HW interrupt to virtio driver, create notify relay thread to translate virtio driver's kick to a MMIO write onto HW, HW queues configuration.
- ifcvf_dev_close:
Revoke all the setup in ifcvf_dev_config.
Live migration feature is supported by IFCVF and this driver enables it. For the dirty page logging, VF helps to log for packet buffer write, driver helps to make the used ring as dirty when device stops.
Because vDPA driver needs to set up MSI-X vector to interrupt the guest, only vfio-pci is supported currently.
--- config/common_base | 7 + config/common_linuxapp | 1 + drivers/net/Makefile | 3 + drivers/net/ifc/Makefile | 36 ++ drivers/net/ifc/base/ifcvf.c | 329 +++++++++++++ drivers/net/ifc/base/ifcvf.h | 160 +++++++ drivers/net/ifc/base/ifcvf_osdep.h | 52 +++ drivers/net/ifc/ifcvf_vdpa.c | 842 ++++++++++++++++++++++++++++++++++ drivers/net/ifc/rte_ifcvf_version.map | 4 + mk/rte.app.mk | 3 + 10 files changed, 1437 insertions(+) create mode 100644 drivers/net/ifc/Makefile create mode 100644 drivers/net/ifc/base/ifcvf.c create mode 100644 drivers/net/ifc/base/ifcvf.h create mode 100644 drivers/net/ifc/base/ifcvf_osdep.h create mode 100644 drivers/net/ifc/ifcvf_vdpa.c create mode 100644 drivers/net/ifc/rte_ifcvf_version.map
config/common_base +7 -0
@@ -809,6 +809,13 @@ CONFIG_RTE_LIBRTE_VHOST_DEBUG=n # CONFIG_RTE_LIBRTE_PMD_VHOST=n +# +# Compile IFCVF driver +# To compile, CONFIG_RTE_LIBRTE_VHOST and CONFIG_RTE_EAL_VFIO +# should be enabled. +# +CONFIG_RTE_LIBRTE_IFCVF_VDPA_PMD=n + # # Compile the test application #
config/common_linuxapp +1 -0
@@ -15,6 +15,7 @@ CONFIG_RTE_LIBRTE_PMD_KNI=y CONFIG_RTE_LIBRTE_VHOST=y CONFIG_RTE_LIBRTE_VHOST_NUMA=y CONFIG_RTE_LIBRTE_PMD_VHOST=y +CONFIG_RTE_LIBRTE_IFCVF_VDPA_PMD=y CONFIG_RTE_LIBRTE_PMD_AF_PACKET=y CONFIG_RTE_LIBRTE_PMD_TAP=y CONFIG_RTE_LIBRTE_AVP_PMD=y
drivers/net/Makefile +3 -0
@@ -58,6 +58,9 @@ endif # $(CONFIG_RTE_LIBRTE_SCHED) ifeq ($(CONFIG_RTE_LIBRTE_VHOST),y) DIRS-$(CONFIG_RTE_LIBRTE_PMD_VHOST) += vhost +ifeq ($(CONFIG_RTE_EAL_VFIO),y) +DIRS-$(CONFIG_RTE_LIBRTE_IFCVF_VDPA_PMD) += ifc +endif endif # $(CONFIG_RTE_LIBRTE_VHOST) ifeq ($(CONFIG_RTE_LIBRTE_MVPP2_PMD),y)
drivers/net/ifc/Makefile new file +36 -0
@@ -0,0 +1,36 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2018 Intel Corporation + +include $(RTE_SDK)/mk/rte.vars.mk + +# +# library name +# +LIB = librte_ifcvf_vdpa.a + +LDLIBS += -lpthread +LDLIBS += -lrte_eal -lrte_pci -lrte_vhost -lrte_bus_pci + +CFLAGS += -O3 +CFLAGS += $(WERROR_FLAGS) +CFLAGS += -DALLOW_EXPERIMENTAL_API +CFLAGS += -I$(RTE_SDK)/lib/librte_eal/linuxapp/eal + +# +# Add extra flags for base driver source files to disable warnings in them +# +BASE_DRIVER_OBJS=$(sort $(patsubst %.c,%.o,$(notdir $(wildcard $(SRCDIR)/base/*.c)))) + +VPATH += $(SRCDIR)/base + +EXPORT_MAP := rte_ifcvf_version.map + +LIBABIVER := 1 + +# +# all source are stored in SRCS-y +# +SRCS-$(CONFIG_RTE_LIBRTE_IFCVF_VDPA_PMD) += ifcvf_vdpa.c +SRCS-$(CONFIG_RTE_LIBRTE_IFCVF_VDPA_PMD) += ifcvf.c + +include $(RTE_SDK)/mk/rte.lib.mk
drivers/net/ifc/base/ifcvf.c new file +329 -0
329 lines not on this page · raw message
drivers/net/ifc/base/ifcvf.h new file +160 -0
160 lines not on this page · raw message
drivers/net/ifc/base/ifcvf_osdep.h new file +52 -0
52 lines not on this page · raw message
drivers/net/ifc/ifcvf_vdpa.c new file +842 -0
842 lines not on this page · raw message
drivers/net/ifc/rte_ifcvf_version.map new file +4 -0
@@ -0,0 +1,4 @@ +DPDK_18.05 { + + local: *; +};
mk/rte.app.mk +3 -0
@@ -186,6 +186,9 @@ _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 +ifeq ($(CONFIG_RTE_EAL_VFIO),y) +_LDLIBS-$(CONFIG_RTE_LIBRTE_IFCVF_VDPA_PMD) += -lrte_ifcvf_vdpa +endif # $(CONFIG_RTE_EAL_VFIO) endif # $(CONFIG_RTE_LIBRTE_VHOST) _LDLIBS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += -lrte_pmd_vmxnet3_uio
Signature · 1 line
2.15.1
PATCH v7 5/5 doc: add ifcvf driver document and release note
In reply to Xiao Wang--- doc/guides/nics/features/ifcvf.ini | 8 +++ doc/guides/nics/ifcvf.rst | 98 ++++++++++++++++++++++++++++++++++ doc/guides/nics/index.rst | 1 + doc/guides/rel_notes/release_18_05.rst | 9 ++++ 4 files changed, 116 insertions(+) create mode 100644 doc/guides/nics/features/ifcvf.ini create mode 100644 doc/guides/nics/ifcvf.rst
doc/guides/nics/features/ifcvf.ini new file +8 -0
@@ -0,0 +1,8 @@ +; +; Supported features of the 'ifcvf' vDPA driver. +; +; Refer to default.ini for the full list of available PMD features. +; +[Features] +x86-32 = Y +x86-64 = Y
doc/guides/nics/ifcvf.rst new file +98 -0
98 lines not on this page · raw message
doc/guides/nics/index.rst +1 -0
@@ -45,6 +45,7 @@ Network Interface Controller Drivers vmxnet3 pcap_ring fail_safe + ifcvf **Figures**
doc/guides/rel_notes/release_18_05.rst +9 -0
@@ -82,6 +82,15 @@ New Features backend connects to. This means that if the backend restarts, it can reconnect to virtio-user and continue communications. +* **Added IFCVF vDPA driver.** + + Added IFCVF vDPA driver to support Intel FPGA 100G VF device. IFCVF works + as a HW vhost data path accelerator, it supports live migration and is + compatible with virtio 0.95 and 1.0. This driver registers ifcvf vDPA driver + to vhost lib, when virtio connected, with the help of the registered vDPA + driver the assigned VF gets configured to Rx/Tx directly to VM's virtio + vrings. + API Changes -----------
Signature · 1 line
2.15.1
Re: [PATCH v7 1/5] vfio: extend data structure for multi container
In reply to Xiao WangQuoted 38 lines · Xiao Wang
Currently eal vfio framework binds vfio group fd to the default container fd during
rte_vfio_setup_device, while in some cases, e.g. vDPA (vhost data path acceleration), we want to put vfio group to a separate container and program IOMMU via this container.This patch extends the
vfio_configstructure to contain per-containeruser_mem_mapsand defines an array ofvfio_config. The next patch will base on this to add container API.Signed-off-by Junjie Chen <[email protected]>Signed-off-by Xiao Wang <[email protected]>Reviewed-by Maxime Coquelin <[email protected]>Reviewed-by Ferruh Yigit <[email protected]>--- config/common_base | 1 + lib/librte_eal/linuxapp/eal/eal_vfio.c | 407 ++++++++++++++++++++++----------- lib/librte_eal/linuxapp/eal/eal_vfio.h | 19 +- 3 files changed, 275 insertions(+), 152 deletions(-)config/common_base +1
-0@@ -87,6 +87,7 @@ CONFIG_RTE_EAL_ALWAYS_PANIC_ON_ERROR=n CONFIG_RTE_EAL_IGB_UIO=n CONFIG_RTE_EAL_VFIO=n CONFIG_RTE_MAX_VFIO_GROUPS=64 +CONFIG_RTE_MAX_VFIO_CONTAINERS=64 CONFIG_RTE_MALLOC_DEBUG=n CONFIG_RTE_EAL_NUMA_AWARE_HUGEPAGES=n CONFIG_RTE_USE_LIBBSD=nlib/librte_eal/linuxapp/eal/eal_vfio.c +0
-0@@ -22,8 +22,46 @@#define VFIO_MEM_EVENT_CLB_NAME "vfio_mem_event_clb"
lib/librte_eal/linuxapp/eal/eal_vfio.c line 33
Quoted 10 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +9
-0+/* +* we don't need to store device fd's anywhere since they can be obtained from +* the group fd via an ioctl() call. +*/ +struct vfio_group { +int group_no; +int fd; +int devices; +};
What is the purpose of moving this into .c file? Seems like an unnecessary change.
Quoted 13 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +13
-0+ +/* hot plug/unplug of VFIO groups may cause all DMA maps to be dropped. we can +* recreate the mappings for DPDK segments, but we cannot do so for memory that +* was registered by the user themselves, so we need to store the user mappings +* somewhere, to recreate them later. +*/ +#define VFIO_MAX_USER_MEM_MAPS 256 +struct user_mem_map { +uint64_t addr; +uint64_t iova; +uint64_t len; +}; +
<...>
Quoted 6 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +6
-0+static struct vfio_config * +get_vfio_cfg_by_group_no (int iommu_group_no) +{ +struct vfio_config *vfio_cfg; +int i, j; +
lib/librte_eal/linuxapp/eal/eal_vfio.c vfio_get_group_fd(int iommu_group_no) · line 401
Quoted 10 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +10
-0+for (i =0 ; i <VFIO_MAX_CONTAINERS ; i++) { + vfio_cfg = &vfio_cfgs[i]; +for (j =0 ; j <VFIO_MAX_GROUPS ; j++) { +if (vfio_cfg->vfio_groups[j].group_no == + iommu_group_no) +return vfio_cfg; + } + } + +return default_vfio_cfg;
Here and in other places: i'm not sure returning default vfio config if group not found is such a good idea. It would be better if calling code explicitly handled case of group not existing yet.
Quoted 15 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +14
-0+} + +static struct vfio_config * +get_vfio_cfg_by_group_fd (int vfio_group_fd) +{ +struct vfio_config *vfio_cfg; +int i, j; + +for (i =0 ; i <VFIO_MAX_CONTAINERS ; i++) { + vfio_cfg = &vfio_cfgs[i]; +for (j =0 ; j <VFIO_MAX_GROUPS ; j++) +if (vfio_cfg->vfio_groups[j].fd == vfio_group_fd) +return vfio_cfg; + }
<...>
lib/librte_eal/linuxapp/eal/eal_vfio.c int · line 946
Quoted 11 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +7
-4-for (i =0 ; i <VFIO_MAX_GROUPS ; i++) { - vfio_cfg.vfio_groups[i].fd =-1 ; - vfio_cfg.vfio_groups[i].group_no =-1 ; - vfio_cfg.vfio_groups[i].devices =0 ; +rte_spinlock_recursive_t lock =RTE_SPINLOCK_RECURSIVE_INITIALIZER ; + +for (i =0 ; i <VFIO_MAX_CONTAINERS ; i++) { + vfio_cfgs[i].vfio_container_fd =-1 ; + vfio_cfgs[i].vfio_active_groups =0 ; + vfio_cfgs[i].vfio_iommu_type =NULL ; + vfio_cfgs[i].mem_maps.lock = lock;
Nitpick - why copy, instead of straight up initializing with RTE_SPINLOCK_RECURSIVE_INITIALIZER?
Quoted 12 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +6
-0+ +for (j =0 ; j <VFIO_MAX_GROUPS ; j++) { + vfio_cfgs[i].vfio_groups[j].fd =-1 ; + vfio_cfgs[i].vfio_groups[j].group_no =-1 ; + vfio_cfgs[i].vfio_groups[j].devices =0 ; + } }/* inform the user that we are probing for VFIO */ @@ -841,12 +971,12 @@ rte_vfio_enable(const char *modname)return 0 ; }
<...>
Signature · 2 lines
Thanks, Anatoly
Re: [PATCH v7 2/5] vfio: add multi container support
In reply to Xiao WangQuoted 5 lines · Xiao Wang
This patch adds APIs to support container create/destroy and device bind/unbind with a container. It also provides API for IOMMU programing on a specified container.
A driver could use "
rte_vfio_create_container" helper to create a
^^ wrong API name in commit message :)
Quoted 20 lines
new container from eal, use "
rte_vfio_bind_group" to bind a device to the newly created container. Duringrte_vfio_setup_devicethe container bound with the device will be used for IOMMU setup.Signed-off-by Junjie Chen <[email protected]>Signed-off-by Xiao Wang <[email protected]>Reviewed-by Maxime Coquelin <[email protected]>Reviewed-by Ferruh Yigit <[email protected]>--- lib/librte_eal/bsdapp/eal/eal.c | 52 +++++ lib/librte_eal/common/include/rte_vfio.h | 119 ++++++++++++ lib/librte_eal/linuxapp/eal/eal_vfio.c | 316 +++++++++++++++++++++++++++++++ lib/librte_eal/rte_eal_version.map | 6 + 4 files changed, 493 insertions(+)lib/librte_eal/bsdapp/eal/eal.c +0
-0
lib/librte_eal/bsdapp/eal/eal.c int rte_vfio_noiommu_is_enabled(void); · line 775
Quoted 7 lines
lib/librte_eal/bsdapp/eal/eal.c +4
-0@@ -769,6 +769,14 @@ int rte_vfio_noiommu_is_enabled(void);int rte_vfio_clear_group (int vfio_group_fd);int rte_vfio_dma_map (uint64_t vaddr,uint64_t iova,uint64_t len);int rte_vfio_dma_unmap (uint64_t vaddr,uint64_t iova,uint64_t len); +int rte_vfio_container_create (void ); +int rte_vfio_container_destroy (int container_fd); +int rte_vfio_bind_group (int container_fd,int iommu_group_no); +int rte_vfio_unbind_group (int container_fd,int iommu_group_no);
Maybe have these under "container" too? e.g. rte_vfio_container_group_bind/unbind? Seems like it would be more consistent that way - anything to do with custom containers would be under rte_vfio_container_* namespace.
Quoted 12 lines
lib/librte_eal/bsdapp/eal/eal.c +5
-0+int rte_vfio_container_dma_map (int container_fd,uint64_t vaddr, +uint64_t iova,uint64_t len); +int rte_vfio_container_dma_unmap (int container_fd,uint64_t vaddr, +uint64_t iova,uint64_t len); int rte_vfio_setup_device(__rte_unused const char *sysfs_base, __rte_unused const char *dev_addr,@@ -818,3 +826,47 @@ rte_vfio_dma_unmap(uint64_t __rte_unused vaddr, uint64_t __rte_unused iova, {return -1 ; } +
<...>
lib/librte_eal/common/include/rte_vfio.h rte_vfio_dma_map(uint64_t vaddr, uint64_t iova, uint64_t len); · line 175
Quoted 13 lines
lib/librte_eal/common/include/rte_vfio.h +5
-0@@ -168,6 +168,125 @@ rte_vfio_dma_map(uint64_t vaddr, uint64_t iova, uint64_t len); int __rte_experimentalrte_vfio_dma_unmap (uint64_t vaddr,uint64_t iova,uint64_t len); +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Create a new container for device binding.
I would add a note that any newly allocated DPDK memory will not be mapped into these containers by default.
Quoted 8 lines
lib/librte_eal/common/include/rte_vfio.h +8
-0+* +* @return +* the container fd if successful +* <0 if failed +*/ +int __rte_experimental +rte_vfio_container_create (void); +
<...>
lib/librte_eal/common/include/rte_vfio.h rte_vfio_dma_map(uint64_t vaddr, uint64_t iova, uint64_t len); · line 242
Quoted 11 lines
+ * 0 if successful
+ * <0 if failed
+ */lib/librte_eal/common/include/rte_vfio.h +8
-0+int __rte_experimental +rte_vfio_unbind_group (int container_fd,int iommu_group_no); + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Perform dma mapping for devices in a conainer.
Here and in other places: "dma" should be DMA, and typo: "conainer" :)
I think you should also add a note to the original API (not this one, but the old one) that DMA maps done via that API will only apply to default container and will not apply to any of the containers created via container_create(). IOW, documentation should make it clear that if you use this functionality, you're on your own and you have to manage your own DMA mappings for any containers you create.
Quoted 7 lines
+ *
+ * @paramcontainer_fd
+ * the specified container fd
+ *
+ * @param vaddr
+ * Starting virtual address of memory to be mapped.
+ *
<...>
Quoted 42 lines
lib/librte_eal/common/include/rte_vfio.h +42
-0+ +int __rte_experimental +rte_vfio_container_dma_map (int container_fd,uint64_t vaddr,uint64_t iova, +uint64_t len) +{ +struct user_mem_map *new_map; +struct vfio_config *vfio_cfg; +struct user_mem_maps *user_mem_maps; +int ret =0 ; + +if (len ==0 ) { + rte_errno =EINVAL ; +return -1 ; + } + + vfio_cfg =get_vfio_cfg_by_container_fd (container_fd); +if (vfio_cfg ==NULL ) { +RTE_LOG (ERR ,EAL ,"Invalid container fd\n" ); +return -1 ; + } + + user_mem_maps = &vfio_cfg->mem_maps; +rte_spinlock_recursive_lock (&user_mem_maps->lock); +if (user_mem_maps->n_maps ==VFIO_MAX_USER_MEM_MAPS ) { +RTE_LOG (ERR ,EAL ,"No more space for user mem maps\n" ); + rte_errno =ENOMEM ; + ret =-1 ; + goto out; + } +/* map the entry */ +if (vfio_dma_mem_map (vfio_cfg, vaddr, iova, len,1 )) { +/* technically, this will fail if there are currently no devices +* plugged in, even if a device were added later, this mapping +* might have succeeded. however, since we cannot verify if this +* is a valid mapping without having a device attached, consider +* this to be unsupported, because we can't just store any old +* mapping and pollute list of active mappings willy-nilly. +*/ +RTE_LOG (ERR ,EAL ,"Couldn't map new region for DMA\n" ); + ret =-1 ; + goto out; + }
lib/librte_eal/common/include/rte_vfio.h
Quoted 10 lines
lib/librte_eal/common/include/rte_vfio.h +10
-0+/* create new user mem map entry */ + new_map = &user_mem_maps->maps[user_mem_maps->n_maps++]; + new_map->addr = vaddr; + new_map->iova = iova; + new_map->len = len; + +compact_user_maps (user_mem_maps); +out: +rte_spinlock_recursive_unlock (&user_mem_maps->lock); +return ret;
Please correct me if i'm wrong, but it looks like you've just duplicated the code for rte_vfio_dma_map() here and made a few small changes. It would be better if you moved most of this into a static function (e.g. static int container_dma_map(vfio_cfg, vaddr, iova, len)) and called it with either default vfio_cfg from rte_vfio_dma_map, or found vfio_cfg from rte_vfio_container_dma_map. Same applies to function below.
Quoted 16 lines
lib/librte_eal/common/include/rte_vfio.h +16
-0+} + +int __rte_experimental +rte_vfio_container_dma_unmap (int container_fd,uint64_t vaddr,uint64_t iova, +uint64_t len) +{ +struct user_mem_map *map, *new_map =NULL ; +struct vfio_config *vfio_cfg; +struct user_mem_maps *user_mem_maps; +int ret =0 ; + +if (len ==0 ) { + rte_errno =EINVAL ; +return -1 ; + } +
<...>
Signature · 2 lines
Thanks, Anatoly
Re: [PATCH v7 1/5] vfio: extend data structure for multi container
In reply to Burakov, AnatolyHi Anatoly,
Quoted 57 lines
-----Original Message-----
From: Burakov, Anatoly
Sent: Monday, April 16, 2018 6:03 PM
To: Wang, Xiao W <[email protected]>; Yigit, Ferruh <[email protected]>
Cc: [email protected]; [email protected]; Wang, Zhihong <[email protected]>; Bie, Tiwei <[email protected]>; Tan, Jianfeng <[email protected]>; Liang, Cunming <[email protected]>; Daly, Dan <[email protected]>; [email protected]; Chen, Junjie J <[email protected]>
Subject: Re: [PATCH v7 1/5] vfio: extend data structure for multi containerQuoted 9 lines · Xiao Wang
Currently eal vfio framework binds vfio group fd to the default container fd during
rte_vfio_setup_device, while in some cases, e.g. vDPA (vhost data path acceleration), we want to put vfio group to a separate container and program IOMMU via this container.This patch extends the
vfio_configstructure to contain per-containeruser_mem_mapsand defines an array ofvfio_config. The next patch will base on this to add container API.Quoted 7 lines
Signed-off-by Junjie Chen <[email protected]>Signed-off-by Xiao Wang <[email protected]>Reviewed-by Maxime Coquelin <[email protected]>Reviewed-by Ferruh Yigit <[email protected]>--- config/common_base | 1 + lib/librte_eal/linuxapp/eal/eal_vfio.c | 407 ++++++++++++++++++++++-----------
Review
Quoted 16 lines
lib/librte_eal/linuxapp/eal/eal_vfio.h | 19 +- 3 files changed, 275 insertions(+), 152 deletions(-)config/common_base +1
-0@@ -87,6 +87,7 @@ CONFIG_RTE_EAL_ALWAYS_PANIC_ON_ERROR=n CONFIG_RTE_EAL_IGB_UIO=n CONFIG_RTE_EAL_VFIO=n CONFIG_RTE_MAX_VFIO_GROUPS=64 +CONFIG_RTE_MAX_VFIO_CONTAINERS=64 CONFIG_RTE_MALLOC_DEBUG=n CONFIG_RTE_EAL_NUMA_AWARE_HUGEPAGES=n CONFIG_RTE_USE_LIBBSD=n(quoted diff) +0
-0
b/lib/librte_eal/linuxapp/eal/eal_vfio.clib/librte_eal/linuxapp/eal/eal_vfio.c line 26
Quoted 9 lines
index
589d7d478..46fba2d8d100644lib/librte_eal/linuxapp/eal/eal_vfio.c +2
-0@@ -22,8 +22,46 @@#define VFIO_MEM_EVENT_CLB_NAME "vfio_mem_event_clb" +/* +* we don't need to store device fd's anywhere since they can be obtained from
Quoted 10 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c line 33
Quoted 7 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +7
-0+* the group fd via an ioctl() call. +*/ +struct vfio_group { +int group_no; +int fd; +int devices; +};What is the purpose of moving this into .c file? Seems like an unnecessary change.
Yes, we can let vfio_group stay at .h, and move vfio_config into .c
Quoted 32 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c line 35
Quoted 3 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +2
-0+ +/* hot plug/unplug of VFIO groups may cause all DMA maps to be dropped. we can
lib/librte_eal/linuxapp/eal/eal_vfio.c line 36
Quoted 1 line
lib/librte_eal/linuxapp/eal/eal_vfio.c +1
-0+* recreate the mappings for DPDK segments, but we cannot do so for memory that
lib/librte_eal/linuxapp/eal/eal_vfio.c line 37
Quoted 1 line
lib/librte_eal/linuxapp/eal/eal_vfio.c +1
-0+* was registered by the user themselves, so we need to store the user mappings
Quoted 9 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +9
-0+* somewhere, to recreate them later. +*/ +#define VFIO_MAX_USER_MEM_MAPS 256 +struct user_mem_map { +uint64_t addr; +uint64_t iova; +uint64_t len; +}; +<...>
Quoted 12 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +12
-0+static struct vfio_config * +get_vfio_cfg_by_group_no (int iommu_group_no) +{ +struct vfio_config *vfio_cfg; +int i, j; + +for (i =0 ; i <VFIO_MAX_CONTAINERS ; i++) { + vfio_cfg = &vfio_cfgs[i]; +for (j =0 ; j <VFIO_MAX_GROUPS ; j++) { +if (vfio_cfg->vfio_groups[j].group_no == + iommu_group_no) +return vfio_cfg;
Quoted 8 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c vfio_get_group_fd(int iommu_group_no) · line 401
Quoted 4 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +4
-0+ } + } + +return default_vfio_cfg;Here and in other places: i'm not sure returning default vfio config if group not found is such a good idea. It would be better if calling code explicitly handled case of group not existing yet.
Agree. It would be explicit.
Quoted 25 lines
Quoted 16 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +14
-0+} + +static struct vfio_config * +get_vfio_cfg_by_group_fd (int vfio_group_fd) +{ +struct vfio_config *vfio_cfg; +int i, j; + +for (i =0 ; i <VFIO_MAX_CONTAINERS ; i++) { + vfio_cfg = &vfio_cfgs[i]; +for (j =0 ; j <VFIO_MAX_GROUPS ; j++) +if (vfio_cfg->vfio_groups[j].fd == vfio_group_fd) +return vfio_cfg; + }<...>
lib/librte_eal/linuxapp/eal/eal_vfio.c int
Quoted 5 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +1
-4-for (i =0 ; i <VFIO_MAX_GROUPS ; i++) { - vfio_cfg.vfio_groups[i].fd =-1 ; - vfio_cfg.vfio_groups[i].group_no =-1 ; - vfio_cfg.vfio_groups[i].devices =0 ; + rte_spinlock_recursive_t lock =
RTE_SPINLOCK_RECURSIVE_INITIALIZER;
Quoted 9 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c int · line 946
Quoted 6 lines
lib/librte_eal/linuxapp/eal/eal_vfio.c +6
-0+ +for (i =0 ; i <VFIO_MAX_CONTAINERS ; i++) { + vfio_cfgs[i].vfio_container_fd =-1 ; + vfio_cfgs[i].vfio_active_groups =0 ; + vfio_cfgs[i].vfio_iommu_type =NULL ; + vfio_cfgs[i].mem_maps.lock = lock;Nitpick - why copy, instead of straight up initializing with
RTE_SPINLOCK_RECURSIVE_INITIALIZER?
I tried but compiler doesn't allow this assignment. RTE_SPINLOCK_RECURSIVE_INITIALIZER could only be used for initialization.
Thanks for the comments,
Xiao
Re: [PATCH v7 2/5] vfio: add multi container support
In reply to Burakov, AnatolyHi Anatoly,
Quoted 12 lines
-----Original Message-----
From: Burakov, Anatoly
Sent: Monday, April 16, 2018 6:03 PM
To: Wang, Xiao W <[email protected]>; Yigit, Ferruh <[email protected]>
Cc: [email protected]; [email protected]; Wang, Zhihong <[email protected]>; Bie, Tiwei <[email protected]>; Tan, Jianfeng <[email protected]>; Liang, Cunming <[email protected]>; Daly, Dan <[email protected]>; [email protected]; Chen, Junjie J <[email protected]>
Subject: Re: [PATCH v7 2/5] vfio: add multi container support
Quoted 8 lines
Quoted 5 lines · Xiao Wang
This patch adds APIs to support container create/destroy and device bind/unbind with a container. It also provides API for IOMMU programing on a specified container.
A driver could use "
rte_vfio_create_container" helper to create a^^ wrong API name in commit message :)
Thanks for the catch. Will fix it.
Quoted 26 lines
Quoted 5 lines
new container from eal, use "
rte_vfio_bind_group" to bind a device to the newly created container. Duringrte_vfio_setup_devicethe container bound with the device will be used for IOMMU setup.Quoted 8 lines
Signed-off-by Junjie Chen <[email protected]>Signed-off-by Xiao Wang <[email protected]>Reviewed-by Maxime Coquelin <[email protected]>Reviewed-by Ferruh Yigit <[email protected]>--- lib/librte_eal/bsdapp/eal/eal.c | 52 +++++ lib/librte_eal/common/include/rte_vfio.h | 119 ++++++++++++ lib/librte_eal/linuxapp/eal/eal_vfio.c | 316+++++++++++++++++++++++++++++++
Quoted 12 lines
lib/librte_eal/rte_eal_version.map | 6 + 4 files changed, 493 insertions(+)lib/librte_eal/bsdapp/eal/eal.c +1
-0@@ -769,6 +769,14 @@ int rte_vfio_noiommu_is_enabled(void);int rte_vfio_clear_group (int vfio_group_fd);int rte_vfio_dma_map (uint64_t vaddr,uint64_t iova,uint64_t len);int rte_vfio_dma_unmap (uint64_t vaddr,uint64_t iova,uint64_t len); +int rte_vfio_container_create (void );
Quoted 8 lines
lib/librte_eal/bsdapp/eal/eal.c int rte_vfio_noiommu_is_enabled(void); · line 775
Quoted 3 lines
lib/librte_eal/bsdapp/eal/eal.c +3
-0+int rte_vfio_container_destroy (int container_fd); +int rte_vfio_bind_group (int container_fd,int iommu_group_no); +int rte_vfio_unbind_group (int container_fd,int iommu_group_no);Maybe have these under "container" too? e.g. rte_vfio_container_group_bind/unbind? Seems like it would be more consistent that way - anything to do with custom containers would be under rte_vfio_container_* namespace.
Agree.
Quoted 30 lines
lib/librte_eal/bsdapp/eal/eal.c rte_vfio_dma_unmap(uint64_t __rte_unused vaddr,
Quoted 9 lines
lib/librte_eal/bsdapp/eal/eal.c +4
-0+int rte_vfio_container_dma_map (int container_fd,uint64_t vaddr, +uint64_t iova,uint64_t len); +int rte_vfio_container_dma_unmap (int container_fd,uint64_t vaddr, +uint64_t iova,uint64_t len); int rte_vfio_setup_device(__rte_unused const char *sysfs_base, __rte_unused const char *dev_addr,@@ -818,3 +826,47 @@ rte_vfio_dma_unmap(uint64_t __rte_unused vaddr,
uint64_t__rte_unusediova,Quoted 4 lines
lib/librte_eal/bsdapp/eal/eal.c +1
-0{return -1 ; } +<...>
Review
Quoted 1 line
(quoted diff) +0
-0
b/lib/librte_eal/common/include/rte_vfio.hlib/librte_eal/common/include/rte_vfio.h rte_vfio_dma_map(uint64_t vaddr, uint64_t iova,
Quoted 4 lines
index
d26ab01cb..0c1509b29100644lib/librte_eal/common/include/rte_vfio.h +0
-0@@ -168,6 +168,125 @@ rte_vfio_dma_map(uint64_t vaddr, uint64_t iova,
uint64_tlen);lib/librte_eal/common/include/rte_vfio.h rte_vfio_dma_map(uint64_t vaddr, uint64_t iova, uint64_t len);
Quoted 6 lines
lib/librte_eal/common/include/rte_vfio.h +3
-0int __rte_experimentalrte_vfio_dma_unmap (uint64_t vaddr,uint64_t iova,uint64_t len); +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior
Quoted 6 lines
notice
lib/librte_eal/common/include/rte_vfio.h rte_vfio_dma_map(uint64_t vaddr, uint64_t iova, uint64_t len); · line 175
Quoted 2 lines
lib/librte_eal/common/include/rte_vfio.h +2
-0+* +* Create a new container for device binding. I would add a note that any newly allocated DPDK memory will not be mapped into these containers by default.
Will add it.
Quoted 25 lines
Quoted 9 lines
lib/librte_eal/common/include/rte_vfio.h +8
-0+* +* @return +* the container fd if successful +* <0 if failed +*/ +int __rte_experimental +rte_vfio_container_create (void); +<...>
lib/librte_eal/common/include/rte_vfio.h rte_vfio_dma_map(uint64_t vaddr, uint64_t iova, uint64_t len);
Quoted 9 lines
+ * 0 if successful
+ * <0 if failed
+ */lib/librte_eal/common/include/rte_vfio.h +6
-0+int __rte_experimental +rte_vfio_unbind_group (int container_fd,int iommu_group_no); + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice
Quoted 2 lines
+ *
+ * Perform dma mapping for devices in a conainer.
Quoted 8 lines
Here and in other places: "dma" should be DMA, and typo: "conainer" :)
I think you should also add a note to the original API (not this one, but the old one) that DMA maps done via that API will only apply to default container and will not apply to any of the containers created via
container_create(). IOW, documentation should make it clear that if you use this functionality, you're on your own and you have to manage your own DMA mappings for any containers you create.
OK, will add note to clearly describe it.
Quoted 65 lines
Quoted 8 lines
+ *
+ * @paramcontainer_fd
+ * the specified container fd
+ *
+ * @param vaddr
+ * Starting virtual address of memory to be mapped.
+ *<...>
lib/librte_eal/common/include/rte_vfio.h
Quoted 3 lines
lib/librte_eal/common/include/rte_vfio.h +3
-0+ +int __rte_experimental +rte_vfio_container_dma_map(int container_fd, uint64_t vaddr, uint64_tiova,
Quoted 21 lines
lib/librte_eal/common/include/rte_vfio.h +21
-0+ uint64_t len) +{ +struct user_mem_map *new_map; +struct vfio_config *vfio_cfg; +struct user_mem_maps *user_mem_maps; +int ret =0 ; + +if (len ==0 ) { + rte_errno =EINVAL ; +return -1 ; + } + + vfio_cfg =get_vfio_cfg_by_container_fd (container_fd); +if (vfio_cfg ==NULL ) { +RTE_LOG (ERR ,EAL ,"Invalid container fd\n" ); +return -1 ; + } + + user_mem_maps = &vfio_cfg->mem_maps; +rte_spinlock_recursive_lock (&user_mem_maps->lock); +if (user_mem_maps->n_maps ==VFIO_MAX_USER_MEM_MAPS ) {lib/librte_eal/common/include/rte_vfio.h
Quoted 10 lines
lib/librte_eal/common/include/rte_vfio.h +10
-0+RTE_LOG (ERR ,EAL ,"No more space for user mem maps\n" ); + rte_errno =ENOMEM ; + ret =-1 ; + goto out; + } +/* map the entry */ +if (vfio_dma_mem_map (vfio_cfg, vaddr, iova, len,1 )) { +/* technically, this will fail if there are currently no devices +* plugged in, even if a device were added later, this mapping +* might have succeeded. however, since we cannot verify if this
lib/librte_eal/common/include/rte_vfio.h
Quoted 1 line
lib/librte_eal/common/include/rte_vfio.h +1
-0+* is a valid mapping without having a device attached, consider
Quoted 16 lines
lib/librte_eal/common/include/rte_vfio.h +16
-0+* this to be unsupported, because we can't just store any old +* mapping and pollute list of active mappings willy-nilly. +*/ +RTE_LOG (ERR ,EAL ,"Couldn't map new region for DMA\n" ); + ret =-1 ; + goto out; + } +/* create new user mem map entry */ + new_map = &user_mem_maps->maps[user_mem_maps->n_maps++]; + new_map->addr = vaddr; + new_map->iova = iova; + new_map->len = len; + +compact_user_maps (user_mem_maps); +out: +rte_spinlock_recursive_unlock (&user_mem_maps->lock);
Quoted 8 lines
lib/librte_eal/common/include/rte_vfio.h
Quoted 1 line
lib/librte_eal/common/include/rte_vfio.h +1
-0+return ret;Please correct me if i'm wrong, but it looks like you've just duplicated the code for
rte_vfio_dma_map()here and made a few small changes. It would be better if you moved most of this into a static function (e.g. static intcontainer_dma_map(vfio_cfg, vaddr, iova, len)) and called it with either defaultvfio_cfgfromrte_vfio_dma_map, or foundvfio_cfgfromrte_vfio_container_dma_map. Same applies to function below.
Agree, will do it in v8.
BRs,
Xiao
Quoted 24 lines
lib/librte_eal/common/include/rte_vfio.h
Quoted 5 lines
lib/librte_eal/common/include/rte_vfio.h +4
-0+} + +int __rte_experimental +rte_vfio_container_dma_unmap(int container_fd, uint64_t vaddr, uint64_tiova,
lib/librte_eal/common/include/rte_vfio.h
Quoted 12 lines
lib/librte_eal/common/include/rte_vfio.h +12
-0+ uint64_t len) +{ +struct user_mem_map *map, *new_map =NULL ; +struct vfio_config *vfio_cfg; +struct user_mem_maps *user_mem_maps; +int ret =0 ; + +if (len ==0 ) { + rte_errno =EINVAL ; +return -1 ; + } +<...>
--
Thanks,
Anatoly
v8 cover add ifcvf vdpa driver
In reply to Xiao WangIFCVF driver
============
The IFCVF vDPA (vhost data path acceleration) driver provides support for the Intel FPGA 100G VF (IFCVF). IFCVF's datapath is virtio ring compatible, it works as a HW vhost backend which can send/receive packets to/from virtio directly by DMA. Besides, it supports dirty page logging and device state report/restore. This driver enables its vDPA functionality with live migration feature.
vDPA mode
=========
IFCVF's vendor ID and device ID are same as that of virtio net pci device, with its specific subsystem vendor ID and device ID. To let the device be probed by IFCVF driver, adding "vdpa=1" parameter helps to specify that this device is to be used in vDPA mode, rather than polling mode, virtio pmd will skip when it detects this message.
Container per device
====================
vDPA needs to create different containers for different devices, thus this patch set adds some APIs in eal/vfio to support multiple container, e.g.
- rte_vfio_create_container
- rte_vfio_destroy_container
- rte_vfio_bind_group
- rte_vfio_unbind_group
By this extension, a device can be put into a new specific container, rather than the previous default container.
IFCVF vDPA details
==================
Key vDPA driver ops implemented:
- ifcvf_dev_config:
Enable VF data path with virtio information provided by vhost lib, including IOMMU programming to enable VF DMA to VM's memory, VFIO interrupt setup to route HW interrupt to virtio driver, create notify relay thread to translate virtio driver's kick to a MMIO write onto HW, HW queues configuration.
This function gets called to set up HW data path backend when virtio driver in VM gets ready.
- ifcvf_dev_close:
Revoke all the setup in ifcvf_dev_config.
This function gets called when virtio driver stops device in VM.
Change log
==========
v8:
- Rebase on HEAD.
- Move vfio_group definition back to eal_vfio.h.
- Return NULL when vfio group num/fd is not found, let caller handle that.
- Fix wrong API name in commit log.
- Rename bind/unbind function to rte_vfio_container_group_bind/unbind for consistensy.
- Add note for rte_vfio_container_create and rte_vfio_dma_map and fix typo in comment.
- Extract out the shared code snip of rte_vfio_dma_map and rte_vfio_container_dma_map to avoid code duplication. So do for the unmap.
v7:
- Rebase on HEAD.
- Split the vfio patch into 2 parts, one for data structure extension, one for adding new API.
- Use static vfio_config array instead of dynamic alloating.
- Change rte_vfio_container_dma_map/unmap's parameters to use (va, iova, len).
v6:
- Rebase on master branch.
- Document "vdpa" devarg in virtio documentation.
- Rename ifcvf config option to CONFIG_RTE_LIBRTE_IFCVF_VDPA_PMD for consistensy, and add it into driver documentation.
- Add comments for ifcvf device ID.
- Minor code cleaning.
v5:
- Fix compilation in BSD, remove the rte_vfio.h including in BSD.
v4:
- Rebase on Zhihong's latest vDPA lib patch, with vDPA ops names change.
- Remove API "rte_vfio_get_group_fd", "rte_vfio_bind_group" will return the fd.
- Align the vfio_cfg search internal APIs naming.
v3:
- Add doc and release note for the new driver.
- Remove the vdev concept, make the driver as a PCI driver, it will get probed by PCI bus driver.
- Rebase on the v4 vDPA lib patch, register a vDPA device instead of a engine.
- Remove the PCI API exposure accordingly.
- Move the MAX_VFIO_CONTAINERS definition to config file.
- Let virtio pmd skips when a virtio device needs to work in vDPA mode.
v2:
- Rename function pci_get_kernel_driver_by_path to rte_pci_device_kdriver_name to make the API generic cross Linux and BSD, make it as EXPERIMENTAL.
- Rebase on Zhihong's vDPA v3 patch set.
- Minor code cleanup on vfio extension.
Xiao Wang (5):
vfio: extend data structure for multi container
vfio: add multi container support
net/virtio: skip device probe in vdpa mode
net/ifcvf: add ifcvf vdpa driver
doc: add ifcvf driver document and release note
config/common_base | 8 + config/common_linuxapp | 1 + doc/guides/nics/features/ifcvf.ini | 8 + doc/guides/nics/ifcvf.rst | 98 ++++ doc/guides/nics/index.rst | 1 + doc/guides/nics/virtio.rst | 13 + doc/guides/rel_notes/release_18_05.rst | 9 + drivers/net/Makefile | 3 + drivers/net/ifc/Makefile | 35 ++ drivers/net/ifc/base/ifcvf.c | 329 ++++++++++++ drivers/net/ifc/base/ifcvf.h | 160 ++++++ drivers/net/ifc/base/ifcvf_osdep.h | 52 ++ drivers/net/ifc/ifcvf_vdpa.c | 842 +++++++++++++++++++++++++++++++ drivers/net/ifc/rte_ifcvf_version.map | 4 + drivers/net/virtio/virtio_ethdev.c | 43 ++ lib/librte_eal/bsdapp/eal/eal.c | 52 ++ lib/librte_eal/common/include/rte_vfio.h | 128 ++++- lib/librte_eal/linuxapp/eal/eal_vfio.c | 681 +++++++++++++++++++------ lib/librte_eal/linuxapp/eal/eal_vfio.h | 9 +- lib/librte_eal/rte_eal_version.map | 6 + mk/rte.app.mk | 3 + 21 files changed, 2329 insertions(+), 156 deletions(-) create mode 100644 doc/guides/nics/features/ifcvf.ini create mode 100644 doc/guides/nics/ifcvf.rst create mode 100644 drivers/net/ifc/Makefile create mode 100644 drivers/net/ifc/base/ifcvf.c create mode 100644 drivers/net/ifc/base/ifcvf.h create mode 100644 drivers/net/ifc/base/ifcvf_osdep.h create mode 100644 drivers/net/ifc/ifcvf_vdpa.c create mode 100644 drivers/net/ifc/rte_ifcvf_version.map
Signature · 1 line
2.15.1
PATCH v8 1/5 vfio: extend data structure for multi container
Currently eal vfio framework binds vfio group fd to the default container fd during rte_vfio_setup_device, while in some cases, e.g. vDPA (vhost data path acceleration), we want to put vfio group to a separate container and program IOMMU via this container.
This patch extends the vfio_config structure to contain per-container user_mem_maps and defines an array of vfio_config. The next patch will base on this to add container API.
--- config/common_base | 1 + lib/librte_eal/linuxapp/eal/eal_vfio.c | 420 ++++++++++++++++++++++----------- lib/librte_eal/linuxapp/eal/eal_vfio.h | 9 +- 3 files changed, 289 insertions(+), 141 deletions(-)
config/common_base +1 -0
@@ -87,6 +87,7 @@ CONFIG_RTE_EAL_ALWAYS_PANIC_ON_ERROR=n CONFIG_RTE_EAL_IGB_UIO=n CONFIG_RTE_EAL_VFIO=n CONFIG_RTE_MAX_VFIO_GROUPS=64 +CONFIG_RTE_MAX_VFIO_CONTAINERS=64 CONFIG_RTE_MALLOC_DEBUG=n CONFIG_RTE_EAL_NUMA_AWARE_HUGEPAGES=n CONFIG_RTE_USE_LIBBSD=n
lib/librte_eal/linuxapp/eal/eal_vfio.c +287 -133
787 lines not on this page · raw message
lib/librte_eal/linuxapp/eal/eal_vfio.h +1 -8
@@ -82,6 +82,7 @@ struct vfio_iommu_spapr_tce_info {#endif #define VFIO_MAX_GROUPS RTE_MAX_VFIO_GROUPS +#define VFIO_MAX_CONTAINERS RTE_MAX_VFIO_CONTAINERS/* * Function prototypes for VFIO multiprocess sync functions
@@ -102,14 +103,6 @@ struct vfio_group {int devices; }; -struct vfio_config { -int vfio_enabled; -int vfio_container_fd; -int vfio_active_groups; -const struct vfio_iommu_type *vfio_iommu_type; -struct vfio_group vfio_groups[VFIO_MAX_GROUPS ]; -}; -/* DMA mapping function prototype. * Takes VFIO container fd as a parameter. * Returns 0 on success, -1 on error.
Signature · 1 line
2.15.1
PATCH v8 2/5 vfio: add multi container support
In reply to Xiao WangThis patch adds APIs to support container create/destroy and device bind/unbind with a container. It also provides API for IOMMU programing on a specified container.
A driver could use "rte_vfio_container_create" helper to create a new container from eal, use "rte_vfio_container_group_bind" to bind a device to the newly created container. During rte_vfio_setup_device the container bound with the device will be used for IOMMU setup.
--- lib/librte_eal/bsdapp/eal/eal.c | 52 ++++++ lib/librte_eal/common/include/rte_vfio.h | 128 ++++++++++++++- lib/librte_eal/linuxapp/eal/eal_vfio.c | 269 ++++++++++++++++++++++++++++--- lib/librte_eal/rte_eal_version.map | 6 + 4 files changed, 436 insertions(+), 19 deletions(-)
lib/librte_eal/bsdapp/eal/eal.c +52 -0
@@ -769,6 +769,14 @@ int rte_vfio_noiommu_is_enabled(void);int rte_vfio_clear_group (int vfio_group_fd);int rte_vfio_dma_map (uint64_t vaddr,uint64_t iova,uint64_t len);int rte_vfio_dma_unmap (uint64_t vaddr,uint64_t iova,uint64_t len); +int rte_vfio_container_create (void ); +int rte_vfio_container_destroy (int container_fd); +int rte_vfio_container_group_bind (int container_fd,int iommu_group_num); +int rte_vfio_container_group_unbind (int container_fd,int iommu_group_num); +int rte_vfio_container_dma_map (int container_fd,uint64_t vaddr, +uint64_t iova,uint64_t len); +int rte_vfio_container_dma_unmap (int container_fd,uint64_t vaddr, +uint64_t iova,uint64_t len); int rte_vfio_setup_device(__rte_unused const char *sysfs_base, __rte_unused const char *dev_addr,
@@ -838,3 +846,47 @@ rte_vfio_get_group_fd(__rte_unused int iommu_group_num) {return -1 ; } + +int __rte_experimental +rte_vfio_container_create (void) +{ +return -1 ; +} + +int __rte_experimental +rte_vfio_container_destroy(__rte_unused int container_fd) +{ +return -1 ; +} + +int __rte_experimental +rte_vfio_container_group_bind(__rte_unused int container_fd, + __rte_unused int iommu_group_num) +{ +return -1 ; +} + +int __rte_experimental +rte_vfio_container_group_unbind(__rte_unused int container_fd, + __rte_unused int iommu_group_num) +{ +return -1 ; +} + +int __rte_experimental +rte_vfio_container_dma_map(__rte_unused int container_fd, + __rte_unused uint64_t vaddr, + __rte_unused uint64_t iova, + __rte_unused uint64_t len) +{ +return -1 ; +} + +int __rte_experimental +rte_vfio_container_dma_unmap(__rte_unused int container_fd, + __rte_unused uint64_t vaddr, + __rte_unused uint64_t iova, + __rte_unused uint64_t len) +{ +return -1 ; +}
lib/librte_eal/common/include/rte_vfio.h +127 -1
140 lines not on this page · raw message
lib/librte_eal/linuxapp/eal/eal_vfio.c +251 -18
319 lines not on this page · raw message
lib/librte_eal/rte_eal_version.map +6 -0
@@ -293,5 +293,11 @@ EXPERIMENTAL { rte_vfio_get_container_fd; rte_vfio_get_group_fd; rte_vfio_get_group_num; + rte_vfio_container_create; + rte_vfio_container_destroy; + rte_vfio_container_dma_map; + rte_vfio_container_dma_unmap; + rte_vfio_container_group_bind; + rte_vfio_container_group_unbind; } DPDK_18.02;
Signature · 1 line
2.15.1
PATCH v8 3/5 net/virtio: skip device probe in vdpa mode
In reply to Xiao WangIf we want a virtio device to work in vDPA (vhost data path acceleration) mode, we could add a "vdpa=1" devarg for this device to specify the mode.
This patch let virtio pmd skip device probe when detecting this parameter.
--- doc/guides/nics/virtio.rst | 13 ++++++++++++ drivers/net/virtio/virtio_ethdev.c | 43 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+)
doc/guides/nics/virtio.rst +13 -0
@@ -318,3 +318,16 @@ Here we use l3fwd-power as an example to show how to get started. $ l3fwd-power -l 0-1 -- -p 1 -P --config="(0,0,1)" \ --no-numa --parse-ptype + + +Virtio PMD arguments +-------------------- + +The user can specify below argument in devargs. + +#. ``vdpa``: + + A virtio device could also be driven by vDPA (vhost data path acceleration) + driver, and works as a HW vhost backend. This argument is used to specify + a virtio device needs to work in vDPA mode. + (Default: 0 (disabled))
drivers/net/virtio/virtio_ethdev.c +43 -0
58 lines not on this page · raw message
Signature · 1 line
2.15.1
PATCH v8 4/5 net/ifcvf: add ifcvf vdpa driver
In reply to Xiao WangThe IFCVF vDPA (vhost data path acceleration) driver provides support for the Intel FPGA 100G VF (IFCVF). IFCVF's datapath is virtio ring compatible, it works as a HW vhost backend which can send/receive packets to/from virtio directly by DMA.
Different VF devices serve different virtio frontends which are in different VMs, so each VF needs to have its own DMA address translation service. During the driver probe a new container is created, with this container vDPA driver can program DMA remapping table with the VM's memory region information.
Key vDPA driver ops implemented:
- ifcvf_dev_config:
Enable VF data path with virtio information provided by vhost lib, including IOMMU programming to enable VF DMA to VM's memory, VFIO interrupt setup to route HW interrupt to virtio driver, create notify relay thread to translate virtio driver's kick to a MMIO write onto HW, HW queues configuration.
- ifcvf_dev_close:
Revoke all the setup in ifcvf_dev_config.
Live migration feature is supported by IFCVF and this driver enables it. For the dirty page logging, VF helps to log for packet buffer write, driver helps to make the used ring as dirty when device stops.
Because vDPA driver needs to set up MSI-X vector to interrupt the guest, only vfio-pci is supported currently.
--- config/common_base | 7 + config/common_linuxapp | 1 + drivers/net/Makefile | 3 + drivers/net/ifc/Makefile | 35 ++ drivers/net/ifc/base/ifcvf.c | 329 +++++++++++++ drivers/net/ifc/base/ifcvf.h | 160 +++++++ drivers/net/ifc/base/ifcvf_osdep.h | 52 +++ drivers/net/ifc/ifcvf_vdpa.c | 842 ++++++++++++++++++++++++++++++++++ drivers/net/ifc/rte_ifcvf_version.map | 4 + mk/rte.app.mk | 3 + 10 files changed, 1436 insertions(+) create mode 100644 drivers/net/ifc/Makefile create mode 100644 drivers/net/ifc/base/ifcvf.c create mode 100644 drivers/net/ifc/base/ifcvf.h create mode 100644 drivers/net/ifc/base/ifcvf_osdep.h create mode 100644 drivers/net/ifc/ifcvf_vdpa.c create mode 100644 drivers/net/ifc/rte_ifcvf_version.map
config/common_base +7 -0
@@ -804,6 +804,13 @@ CONFIG_RTE_LIBRTE_VHOST_DEBUG=n # CONFIG_RTE_LIBRTE_PMD_VHOST=n +# +# Compile IFCVF driver +# To compile, CONFIG_RTE_LIBRTE_VHOST and CONFIG_RTE_EAL_VFIO +# should be enabled. +# +CONFIG_RTE_LIBRTE_IFCVF_VDPA_PMD=n + # # Compile the test application #
config/common_linuxapp +1 -0
@@ -15,6 +15,7 @@ CONFIG_RTE_LIBRTE_PMD_KNI=y CONFIG_RTE_LIBRTE_VHOST=y CONFIG_RTE_LIBRTE_VHOST_NUMA=y CONFIG_RTE_LIBRTE_PMD_VHOST=y +CONFIG_RTE_LIBRTE_IFCVF_VDPA_PMD=y CONFIG_RTE_LIBRTE_PMD_AF_PACKET=y CONFIG_RTE_LIBRTE_PMD_TAP=y CONFIG_RTE_LIBRTE_AVP_PMD=y
drivers/net/Makefile +3 -0
@@ -58,6 +58,9 @@ endif # $(CONFIG_RTE_LIBRTE_SCHED) ifeq ($(CONFIG_RTE_LIBRTE_VHOST),y) DIRS-$(CONFIG_RTE_LIBRTE_PMD_VHOST) += vhost +ifeq ($(CONFIG_RTE_EAL_VFIO),y) +DIRS-$(CONFIG_RTE_LIBRTE_IFCVF_VDPA_PMD) += ifc +endif endif # $(CONFIG_RTE_LIBRTE_VHOST) ifeq ($(CONFIG_RTE_LIBRTE_MVPP2_PMD),y)
drivers/net/ifc/Makefile new file +35 -0
@@ -0,0 +1,35 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2018 Intel Corporation + +include $(RTE_SDK)/mk/rte.vars.mk + +# +# library name +# +LIB = librte_ifcvf_vdpa.a + +LDLIBS += -lpthread +LDLIBS += -lrte_eal -lrte_pci -lrte_vhost -lrte_bus_pci + +CFLAGS += -O3 +CFLAGS += $(WERROR_FLAGS) +CFLAGS += -DALLOW_EXPERIMENTAL_API + +# +# Add extra flags for base driver source files to disable warnings in them +# +BASE_DRIVER_OBJS=$(sort $(patsubst %.c,%.o,$(notdir $(wildcard $(SRCDIR)/base/*.c)))) + +VPATH += $(SRCDIR)/base + +EXPORT_MAP := rte_ifcvf_version.map + +LIBABIVER := 1 + +# +# all source are stored in SRCS-y +# +SRCS-$(CONFIG_RTE_LIBRTE_IFCVF_VDPA_PMD) += ifcvf_vdpa.c +SRCS-$(CONFIG_RTE_LIBRTE_IFCVF_VDPA_PMD) += ifcvf.c + +include $(RTE_SDK)/mk/rte.lib.mk
drivers/net/ifc/base/ifcvf.c new file +329 -0
329 lines not on this page · raw message
drivers/net/ifc/base/ifcvf.h new file +160 -0
160 lines not on this page · raw message
drivers/net/ifc/base/ifcvf_osdep.h new file +52 -0
52 lines not on this page · raw message
drivers/net/ifc/ifcvf_vdpa.c new file +842 -0
842 lines not on this page · raw message
drivers/net/ifc/rte_ifcvf_version.map new file +4 -0
@@ -0,0 +1,4 @@ +DPDK_18.05 { + + local: *; +};
mk/rte.app.mk +3 -0
@@ -186,6 +186,9 @@ _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 +ifeq ($(CONFIG_RTE_EAL_VFIO),y) +_LDLIBS-$(CONFIG_RTE_LIBRTE_IFCVF_VDPA_PMD) += -lrte_ifcvf_vdpa +endif # $(CONFIG_RTE_EAL_VFIO) endif # $(CONFIG_RTE_LIBRTE_VHOST) _LDLIBS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += -lrte_pmd_vmxnet3_uio
Signature · 1 line
2.15.1
PATCH v8 5/5 doc: add ifcvf driver document and release note
In reply to Xiao Wang--- doc/guides/nics/features/ifcvf.ini | 8 +++ doc/guides/nics/ifcvf.rst | 98 ++++++++++++++++++++++++++++++++++ doc/guides/nics/index.rst | 1 + doc/guides/rel_notes/release_18_05.rst | 9 ++++ 4 files changed, 116 insertions(+) create mode 100644 doc/guides/nics/features/ifcvf.ini create mode 100644 doc/guides/nics/ifcvf.rst
doc/guides/nics/features/ifcvf.ini new file +8 -0
@@ -0,0 +1,8 @@ +; +; Supported features of the 'ifcvf' vDPA driver. +; +; Refer to default.ini for the full list of available PMD features. +; +[Features] +x86-32 = Y +x86-64 = Y
doc/guides/nics/ifcvf.rst new file +98 -0
98 lines not on this page · raw message
doc/guides/nics/index.rst +1 -0
@@ -45,6 +45,7 @@ Network Interface Controller Drivers vmxnet3 pcap_ring fail_safe + ifcvf **Figures**
doc/guides/rel_notes/release_18_05.rst +9 -0
@@ -108,6 +108,15 @@ New Features Linux uevent is supported as backend of this device event notification framework. +* **Added IFCVF vDPA driver.** + + Added IFCVF vDPA driver to support Intel FPGA 100G VF device. IFCVF works + as a HW vhost data path accelerator, it supports live migration and is + compatible with virtio 0.95 and 1.0. This driver registers ifcvf vDPA driver + to vhost lib, when virtio connected, with the help of the registered vDPA + driver the assigned VF gets configured to Rx/Tx directly to VM's virtio + vrings. + API Changes -----------
Signature · 1 line
2.15.1
Re: [PATCH v8 1/5] vfio: extend data structure for multi container
In reply to Xiao WangQuoted 9 lines · Xiao Wang
Currently eal vfio framework binds vfio group fd to the default container fd during
rte_vfio_setup_device, while in some cases, e.g. vDPA (vhost data path acceleration), we want to put vfio group to a separate container and program IOMMU via this container.This patch extends the
vfio_configstructure to contain per-containeruser_mem_mapsand defines an array ofvfio_config. The next patch will base on this to add container API.
Quoted 5 lines
Signed-off-by Junjie Chen <[email protected]>Signed-off-by Xiao Wang <[email protected]>Reviewed-by Maxime Coquelin <[email protected]>Reviewed-by Ferruh Yigit <[email protected]>---
Signature · 2 lines
Thanks, Anatoly
Re: [PATCH v8 2/5] vfio: add multi container support
In reply to Xiao WangQuoted 9 lines · Xiao Wang
This patch adds APIs to support container create/destroy and device bind/unbind with a container. It also provides API for IOMMU programing on a specified container.
A driver could use "
rte_vfio_container_create" helper to create a new container from eal, use "rte_vfio_container_group_bind" to bind a device to the newly created container. Duringrte_vfio_setup_devicethe container bound with the device will be used for IOMMU setup.
Quoted 5 lines
Signed-off-by Junjie Chen <[email protected]>Signed-off-by Xiao Wang <[email protected]>Reviewed-by Maxime Coquelin <[email protected]>Reviewed-by Ferruh Yigit <[email protected]>---
Signature · 2 lines
Thanks, Anatoly
Re: [PATCH v8 0/5] add ifcvf vdpa driver
In reply to Xiao WangQuoted 99 lines · Xiao Wang
IFCVF driver
============
The IFCVF vDPA (vhost data path acceleration) driver provides support for the Intel FPGA 100G VF (IFCVF). IFCVF's datapath is virtio ring compatible, it works as a HW vhost backend which can send/receive packets to/from virtio directly by DMA. Besides, it supports dirty page logging and device state report/restore. This driver enables its vDPA functionality with live migration feature.vDPA mode
=========
IFCVF's vendor ID and device ID are same as that of virtio net pci device, with its specific subsystem vendor ID and device ID. To let the device be probed by IFCVF driver, adding "vdpa=1" parameter helps to specify that this device is to be used in vDPA mode, rather than polling mode, virtio pmd will skip when it detects this message.Container per device
====================
vDPA needs to create different containers for different devices, thus this patch set adds some APIs in eal/vfio to support multiple container, e.g.
-rte_vfio_create_container
-rte_vfio_destroy_container
-rte_vfio_bind_group
-rte_vfio_unbind_groupBy this extension, a device can be put into a new specific container, rather than the previous default container.
IFCVF vDPA details
==================
Key vDPA driver ops implemented:
-ifcvf_dev_config:
Enable VF data path with virtio information provided by vhost lib, including IOMMU programming to enable VF DMA to VM's memory, VFIO interrupt setup to route HW interrupt to virtio driver, create notify relay thread to translate virtio driver's kick to a MMIO write onto HW, HW queues configuration.This function gets called to set up HW data path backend when virtio driver in VM gets ready.
-
ifcvf_dev_close:
Revoke all the setup inifcvf_dev_config.This function gets called when virtio driver stops device in VM.
Change log
==========
v8:
- Rebase on HEAD.
- Movevfio_groupdefinition back toeal_vfio.h.
- Return NULL when vfio group num/fd is not found, let caller handle that.
- Fix wrong API name in commit log.
- Rename bind/unbind function to rte_vfio_container_group_bind/unbind for consistensy.
- Add note forrte_vfio_container_createandrte_vfio_dma_mapand fix typo in comment.
- Extract out the shared code snip ofrte_vfio_dma_mapandrte_vfio_container_dma_mapto avoid code duplication. So do for the unmap.v7:
- Rebase on HEAD.
- Split the vfio patch into 2 parts, one for data structure extension, one for adding new API.
- Use staticvfio_configarray instead of dynamic alloating.
- Change rte_vfio_container_dma_map/unmap's parameters to use (va, iova, len).v6:
- Rebase on master branch.
- Document "vdpa" devarg in virtio documentation.
- Rename ifcvf config option toCONFIG_RTE_LIBRTE_IFCVF_VDPA_PMDfor consistensy, and add it into driver documentation.
- Add comments for ifcvf device ID.
- Minor code cleaning.v5:
- Fix compilation in BSD, remove therte_vfio.hincluding in BSD.v4:
- Rebase on Zhihong's latest vDPA lib patch, with vDPA ops names change.
- Remove API "rte_vfio_get_group_fd", "rte_vfio_bind_group" will return the fd.
- Align thevfio_cfgsearch internal APIs naming.v3:
- Add doc and release note for the new driver.
- Remove the vdev concept, make the driver as a PCI driver, it will get probed by PCI bus driver.
- Rebase on the v4 vDPA lib patch, register a vDPA device instead of a engine.
- Remove the PCI API exposure accordingly.
- Move theMAX_VFIO_CONTAINERSdefinition to config file.
- Let virtio pmd skips when a virtio device needs to work in vDPA mode.v2:
- Rename functionpci_get_kernel_driver_by_pathtorte_pci_device_kdriver_nameto make the API generic cross Linux and BSD, make it as EXPERIMENTAL.
- Rebase on Zhihong's vDPA v3 patch set.
- Minor code cleanup on vfio extension.
Quoted 6 lines
Xiao Wang (5):
vfio: extend data structure for multi container
vfio: add multi container support
net/virtio: skip device probe in vdpa mode
net/ifcvf: add ifcvf vdpa driver
doc: add ifcvf driver document and release note
Hi Xiao,
Getting following build error for 32bit [1], can you please check them?
[1].../dpdk/drivers/net/ifc/ifcvf_vdpa.c: In function ‘ifcvf_dma_map’:.../dpdk/drivers/net/ifc/ifcvf_vdpa.c:24:3: error: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 6 has type ‘uint64_t {aka long long unsigned int}’ [-Werror=format=]
"%s(): " fmt "\n", __func__, ##args)
^.../dpdk/drivers/net/ifc/ifcvf_vdpa.c:178:22:
"size 0x%lx.", i, reg->host_user_addr,
~~~~~~.../dpdk/drivers/net/ifc/ifcvf_vdpa.c:177:3: note: in expansion of macro ‘DRV_LOG’
DRV_LOG(INFO, "region %u: HVA 0x%lx, GPA 0x%lx, "
^~~~~~~.../dpdk/drivers/net/ifc/ifcvf_vdpa.c:177:37: note: format string is defined here
DRV_LOG(INFO, "region %u: HVA 0x%lx, GPA 0x%lx, "
~~^
%llx.../dpdk/drivers/net/ifc/ifcvf_vdpa.c:24:3: error: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 7 has type ‘uint64_t {aka long long unsigned int}’ [-Werror=format=]
"%s(): " fmt "\n", __func__, ##args)
^.../dpdk/drivers/net/ifc/ifcvf_vdpa.c:179:4:
reg->guest_phys_addr, reg->size);
~~~~~~.../dpdk/drivers/net/ifc/ifcvf_vdpa.c:177:3: note: in expansion of macro ‘DRV_LOG’
DRV_LOG(INFO, "region %u: HVA 0x%lx, GPA 0x%lx, "
^~~~~~~.../dpdk/drivers/net/ifc/ifcvf_vdpa.c:177:48: note: format string is defined here
DRV_LOG(INFO, "region %u: HVA 0x%lx, GPA 0x%lx, "
~~^
%llx.../dpdk/drivers/net/ifc/ifcvf_vdpa.c:24:3: error: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 8 has type ‘uint64_t {aka long long unsigned int}’ [-Werror=format=]
"%s(): " fmt "\n", __func__, ##args)
^.../dpdk/drivers/net/ifc/ifcvf_vdpa.c:179:26:
reg->guest_phys_addr, reg->size);
~~~~~~.../dpdk/drivers/net/ifc/ifcvf_vdpa.c:177:3: note: in expansion of macro ‘DRV_LOG’
DRV_LOG(INFO, "region %u: HVA 0x%lx, GPA 0x%lx, "
^~~~~~~.../dpdk/drivers/net/ifc/ifcvf_vdpa.c:178:14: note: format string is defined here
"size 0x%lx.", i, reg->host_user_addr,
~~^
%llx
.../dpdk/drivers/net/ifc/ifcvf_vdpa.c: In function ‘vdpa_ifcvf_start’:
.../dpdk/drivers/net/ifc/ifcvf_vdpa.c:266:39: error: cast from pointer to
integer of different size [-Werror=pointer-to-int-cast]
hw->vring[i].desc = qva_to_gpa(vid, (uint64_t)vq.desc);
^
.../dpdk/drivers/net/ifc/ifcvf_vdpa.c:267:40: error: cast from pointer to
integer of different size [-Werror=pointer-to-int-cast]
hw->vring[i].avail = qva_to_gpa(vid, (uint64_t)vq.avail);
^
.../dpdk/drivers/net/ifc/ifcvf_vdpa.c:268:39: error: cast from pointer to
integer of different size [-Werror=pointer-to-int-cast]
hw->vring[i].used = qva_to_gpa(vid, (uint64_t)vq.used);
^Re: [PATCH v8 0/5] add ifcvf vdpa driver
16/04/2018 18:36, Ferruh Yigit:
Quoted 9 lines
Hi Xiao,
Getting following build error for 32bit [1], can you please check them?
[1]
.../dpdk/drivers/net/ifc/ifcvf_vdpa.c: In function ‘ifcvf_dma_map’:.../dpdk/drivers/net/ifc/ifcvf_vdpa.c:24:3: error: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 6 has type ‘uint64_t {aka long long unsigned int}’ [-Werror=format=]
Reminder from this recent post:
http://dpdk.org/ml/archives/dev/2018-February/090882.html
"
Most of the times, using %l is wrong (except when printing a long). So next time you write %l, please think "I am probably wrong". "
Re: [PATCH v8 0/5] add ifcvf vdpa driver
Thanks for the reminder. Will fix it.
BRs,
Xiao
Quoted 31 lines
-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Tuesday, April 17, 2018 2:07 AM
To: Wang, Xiao W <[email protected]>
Cc: Yigit, Ferruh <[email protected]>; Burakov, Anatoly <[email protected]>; [email protected]; [email protected]; Wang, Zhihong <[email protected]>; Bie, Tiwei <[email protected]>; Tan, Jianfeng <[email protected]>; Liang, Cunming <[email protected]>; Daly, Dan <[email protected]>
Subject: Re: [PATCH v8 0/5] add ifcvf vdpa driver16/04/2018 18:36, Ferruh Yigit:
Quoted 7 lines
Hi Xiao,
Getting following build error for 32bit [1], can you please check them?
[1]
.../dpdk/drivers/net/ifc/ifcvf_vdpa.c: In function ‘ifcvf_dma_map’:.../dpdk/drivers/net/ifc/ifcvf_vdpa.c:24:3: error: format ‘%lx’ expectsargument
Quoted 2 lines
of type ‘long unsigned int’, but argument 6 has type ‘uint64_t {aka long long unsigned int}’ [-Werror=format=]
Reminder from this recent post:
http://dpdk.org/ml/archives/dev/2018-February/090882.html"
Most of the times, using %l is wrong (except when printing a long). So next time you write %l, please think "I am probably wrong". "
v9 cover add ifcvf vdpa driver
In reply to Xiao WangIFCVF driver
============
The IFCVF vDPA (vhost data path acceleration) driver provides support for the Intel FPGA 100G VF (IFCVF). IFCVF's datapath is virtio ring compatible, it works as a HW vhost backend which can send/receive packets to/from virtio directly by DMA. Besides, it supports dirty page logging and device state report/restore. This driver enables its vDPA functionality with live migration feature.
vDPA mode
=========
IFCVF's vendor ID and device ID are same as that of virtio net pci device, with its specific subsystem vendor ID and device ID. To let the device be probed by IFCVF driver, adding "vdpa=1" parameter helps to specify that this device is to be used in vDPA mode, rather than polling mode, virtio pmd will skip when it detects this message.
Container per device
====================
vDPA needs to create different containers for different devices, thus this patch set adds some APIs in eal/vfio to support multiple container, e.g.
- rte_vfio_container_create
- rte_vfio_container_destroy
- rte_vfio_container_group_bind
- rte_vfio_container_group_unbind
By this extension, a device can be put into a new specific container, rather than the previous default container.
Two APIs are added for IOMMU programming for a specified container:
- rte_vfio_container_dma_map
- rte_vfio_container_dma_unmap
IFCVF vDPA details
==================
Key vDPA driver ops implemented:
- ifcvf_dev_config:
Enable VF data path with virtio information provided by vhost lib, including IOMMU programming to enable VF DMA to VM's memory, VFIO interrupt setup to route HW interrupt to virtio driver, create notify relay thread to translate virtio driver's kick to a MMIO write onto HW, HW queues configuration.
This function gets called to set up HW data path backend when virtio driver in VM gets ready.
- ifcvf_dev_close:
Revoke all the setup in ifcvf_dev_config.
This function gets called when virtio driver stops device in VM.
Change log
==========
v9:
- Rebase on master tree's HEAD.
- Fix compile error on 32-bit platform.
v8:
- Rebase on HEAD.
- Move vfio_group definition back to eal_vfio.h.
- Return NULL when vfio group num/fd is not found, let caller handle that.
- Fix wrong API name in commit log.
- Rename bind/unbind function to rte_vfio_container_group_bind/unbind for consistensy.
- Add note for rte_vfio_container_create and rte_vfio_dma_map and fix typo in comment.
- Extract out the shared code snip of rte_vfio_dma_map and rte_vfio_container_dma_map to avoid code duplication. So do for the unmap.
v7:
- Rebase on HEAD.
- Split the vfio patch into 2 parts, one for data structure extension, one for adding new API.
- Use static vfio_config array instead of dynamic alloating.
- Change rte_vfio_container_dma_map/unmap's parameters to use (va, iova, len).
v6:
- Rebase on master branch.
- Document "vdpa" devarg in virtio documentation.
- Rename ifcvf config option to CONFIG_RTE_LIBRTE_IFCVF_VDPA_PMD for consistensy, and add it into driver documentation.
- Add comments for ifcvf device ID.
- Minor code cleaning.
v5:
- Fix compilation in BSD, remove the rte_vfio.h including in BSD.
v4:
- Rebase on Zhihong's latest vDPA lib patch, with vDPA ops names change.
- Remove API "rte_vfio_get_group_fd", "rte_vfio_bind_group" will return the fd.
- Align the vfio_cfg search internal APIs naming.
v3:
- Add doc and release note for the new driver.
- Remove the vdev concept, make the driver as a PCI driver, it will get probed by PCI bus driver.
- Rebase on the v4 vDPA lib patch, register a vDPA device instead of a engine.
- Remove the PCI API exposure accordingly.
- Move the MAX_VFIO_CONTAINERS definition to config file.
- Let virtio pmd skips when a virtio device needs to work in vDPA mode.
v2:
- Rename function pci_get_kernel_driver_by_path to rte_pci_device_kdriver_name to make the API generic cross Linux and BSD, make it as EXPERIMENTAL.
- Rebase on Zhihong's vDPA v3 patch set.
- Minor code cleanup on vfio extension.
Xiao Wang (5):
vfio: extend data structure for multi container
vfio: add multi container support
net/virtio: skip device probe in vdpa mode
net/ifcvf: add ifcvf vdpa driver
doc: add ifcvf driver document and release note
config/common_base | 8 + config/common_linuxapp | 1 + doc/guides/nics/features/ifcvf.ini | 8 + doc/guides/nics/ifcvf.rst | 98 ++++ doc/guides/nics/index.rst | 1 + doc/guides/nics/virtio.rst | 13 + doc/guides/rel_notes/release_18_05.rst | 9 + drivers/net/Makefile | 3 + drivers/net/ifc/Makefile | 35 ++ drivers/net/ifc/base/ifcvf.c | 329 ++++++++++++ drivers/net/ifc/base/ifcvf.h | 160 ++++++ drivers/net/ifc/base/ifcvf_osdep.h | 52 ++ drivers/net/ifc/ifcvf_vdpa.c | 846 +++++++++++++++++++++++++++++++ drivers/net/ifc/rte_ifcvf_version.map | 4 + drivers/net/virtio/virtio_ethdev.c | 43 ++ lib/librte_eal/bsdapp/eal/eal.c | 44 ++ lib/librte_eal/common/include/rte_vfio.h | 128 ++++- lib/librte_eal/linuxapp/eal/eal_vfio.c | 681 +++++++++++++++++++------ lib/librte_eal/linuxapp/eal/eal_vfio.h | 9 +- lib/librte_eal/rte_eal_version.map | 6 + mk/rte.app.mk | 3 + 21 files changed, 2325 insertions(+), 156 deletions(-) create mode 100644 doc/guides/nics/features/ifcvf.ini create mode 100644 doc/guides/nics/ifcvf.rst create mode 100644 drivers/net/ifc/Makefile create mode 100644 drivers/net/ifc/base/ifcvf.c create mode 100644 drivers/net/ifc/base/ifcvf.h create mode 100644 drivers/net/ifc/base/ifcvf_osdep.h create mode 100644 drivers/net/ifc/ifcvf_vdpa.c create mode 100644 drivers/net/ifc/rte_ifcvf_version.map
Signature · 1 line
2.15.1
PATCH v9 1/5 vfio: extend data structure for multi container
Currently eal vfio framework binds vfio group fd to the default container fd during rte_vfio_setup_device, while in some cases, e.g. vDPA (vhost data path acceleration), we want to put vfio group to a separate container and program IOMMU via this container.
This patch extends the vfio_config structure to contain per-container user_mem_maps and defines an array of vfio_config. The next patch will base on this to add container API.
--- config/common_base | 1 + lib/librte_eal/linuxapp/eal/eal_vfio.c | 420 ++++++++++++++++++++++----------- lib/librte_eal/linuxapp/eal/eal_vfio.h | 9 +- 3 files changed, 289 insertions(+), 141 deletions(-)
config/common_base +1 -0
@@ -87,6 +87,7 @@ CONFIG_RTE_EAL_ALWAYS_PANIC_ON_ERROR=n CONFIG_RTE_EAL_IGB_UIO=n CONFIG_RTE_EAL_VFIO=n CONFIG_RTE_MAX_VFIO_GROUPS=64 +CONFIG_RTE_MAX_VFIO_CONTAINERS=64 CONFIG_RTE_MALLOC_DEBUG=n CONFIG_RTE_EAL_NUMA_AWARE_HUGEPAGES=n CONFIG_RTE_USE_LIBBSD=n
lib/librte_eal/linuxapp/eal/eal_vfio.c +287 -133
787 lines not on this page · raw message
lib/librte_eal/linuxapp/eal/eal_vfio.h +1 -8
@@ -82,6 +82,7 @@ struct vfio_iommu_spapr_tce_info {#endif #define VFIO_MAX_GROUPS RTE_MAX_VFIO_GROUPS +#define VFIO_MAX_CONTAINERS RTE_MAX_VFIO_CONTAINERS/* * Function prototypes for VFIO multiprocess sync functions
@@ -102,14 +103,6 @@ struct vfio_group {int devices; }; -struct vfio_config { -int vfio_enabled; -int vfio_container_fd; -int vfio_active_groups; -const struct vfio_iommu_type *vfio_iommu_type; -struct vfio_group vfio_groups[VFIO_MAX_GROUPS ]; -}; -/* DMA mapping function prototype. * Takes VFIO container fd as a parameter. * Returns 0 on success, -1 on error.
Signature · 1 line
2.15.1
PATCH v9 2/5 vfio: add multi container support
In reply to Xiao WangThis patch adds APIs to support container create/destroy and device bind/unbind with a container. It also provides API for IOMMU programing on a specified container.
A driver could use "rte_vfio_container_create" helper to create a new container from eal, use "rte_vfio_container_group_bind" to bind a device to the newly created container. During rte_vfio_setup_device the container bound with the device will be used for IOMMU setup.
--- lib/librte_eal/bsdapp/eal/eal.c | 44 +++++ lib/librte_eal/common/include/rte_vfio.h | 128 ++++++++++++++- lib/librte_eal/linuxapp/eal/eal_vfio.c | 269 ++++++++++++++++++++++++++++--- lib/librte_eal/rte_eal_version.map | 6 + 4 files changed, 428 insertions(+), 19 deletions(-)
lib/librte_eal/bsdapp/eal/eal.c +44 -0
@@ -825,3 +825,47 @@ rte_vfio_get_group_fd(__rte_unused int iommu_group_num) {return -1 ; } + +int __rte_experimental +rte_vfio_container_create (void) +{ +return -1 ; +} + +int __rte_experimental +rte_vfio_container_destroy(__rte_unused int container_fd) +{ +return -1 ; +} + +int __rte_experimental +rte_vfio_container_group_bind(__rte_unused int container_fd, + __rte_unused int iommu_group_num) +{ +return -1 ; +} + +int __rte_experimental +rte_vfio_container_group_unbind(__rte_unused int container_fd, + __rte_unused int iommu_group_num) +{ +return -1 ; +} + +int __rte_experimental +rte_vfio_container_dma_map(__rte_unused int container_fd, + __rte_unused uint64_t vaddr, + __rte_unused uint64_t iova, + __rte_unused uint64_t len) +{ +return -1 ; +} + +int __rte_experimental +rte_vfio_container_dma_unmap(__rte_unused int container_fd, + __rte_unused uint64_t vaddr, + __rte_unused uint64_t iova, + __rte_unused uint64_t len) +{ +return -1 ; +}
lib/librte_eal/common/include/rte_vfio.h +127 -1
140 lines not on this page · raw message
lib/librte_eal/linuxapp/eal/eal_vfio.c +251 -18
319 lines not on this page · raw message
lib/librte_eal/rte_eal_version.map +6 -0
@@ -293,5 +293,11 @@ EXPERIMENTAL { rte_vfio_get_container_fd; rte_vfio_get_group_fd; rte_vfio_get_group_num; + rte_vfio_container_create; + rte_vfio_container_destroy; + rte_vfio_container_dma_map; + rte_vfio_container_dma_unmap; + rte_vfio_container_group_bind; + rte_vfio_container_group_unbind; } DPDK_18.02;
Signature · 1 line
2.15.1
PATCH v9 3/5 net/virtio: skip device probe in vdpa mode
In reply to Xiao WangIf we want a virtio device to work in vDPA (vhost data path acceleration) mode, we could add a "vdpa=1" devarg for this device to specify the mode.
This patch let virtio pmd skip device probe when detecting this parameter.
--- doc/guides/nics/virtio.rst | 13 ++++++++++++ drivers/net/virtio/virtio_ethdev.c | 43 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+)
doc/guides/nics/virtio.rst +13 -0
@@ -318,3 +318,16 @@ Here we use l3fwd-power as an example to show how to get started. $ l3fwd-power -l 0-1 -- -p 1 -P --config="(0,0,1)" \ --no-numa --parse-ptype + + +Virtio PMD arguments +-------------------- + +The user can specify below argument in devargs. + +#. ``vdpa``: + + A virtio device could also be driven by vDPA (vhost data path acceleration) + driver, and works as a HW vhost backend. This argument is used to specify + a virtio device needs to work in vDPA mode. + (Default: 0 (disabled))
drivers/net/virtio/virtio_ethdev.c +43 -0
58 lines not on this page · raw message
Signature · 1 line
2.15.1
PATCH v9 4/5 net/ifcvf: add ifcvf vdpa driver
In reply to Xiao WangThe IFCVF vDPA (vhost data path acceleration) driver provides support for the Intel FPGA 100G VF (IFCVF). IFCVF's datapath is virtio ring compatible, it works as a HW vhost backend which can send/receive packets to/from virtio directly by DMA.
Different VF devices serve different virtio frontends which are in different VMs, so each VF needs to have its own DMA address translation service. During the driver probe a new container is created, with this container vDPA driver can program DMA remapping table with the VM's memory region information.
Key vDPA driver ops implemented:
- ifcvf_dev_config:
Enable VF data path with virtio information provided by vhost lib, including IOMMU programming to enable VF DMA to VM's memory, VFIO interrupt setup to route HW interrupt to virtio driver, create notify relay thread to translate virtio driver's kick to a MMIO write onto HW, HW queues configuration.
- ifcvf_dev_close:
Revoke all the setup in ifcvf_dev_config.
Live migration feature is supported by IFCVF and this driver enables it. For the dirty page logging, VF helps to log for packet buffer write, driver helps to make the used ring as dirty when device stops.
Because vDPA driver needs to set up MSI-X vector to interrupt the guest, only vfio-pci is supported currently.
--- config/common_base | 7 + config/common_linuxapp | 1 + drivers/net/Makefile | 3 + drivers/net/ifc/Makefile | 35 ++ drivers/net/ifc/base/ifcvf.c | 329 +++++++++++++ drivers/net/ifc/base/ifcvf.h | 160 +++++++ drivers/net/ifc/base/ifcvf_osdep.h | 52 +++ drivers/net/ifc/ifcvf_vdpa.c | 846 ++++++++++++++++++++++++++++++++++ drivers/net/ifc/rte_ifcvf_version.map | 4 + mk/rte.app.mk | 3 + 10 files changed, 1440 insertions(+) create mode 100644 drivers/net/ifc/Makefile create mode 100644 drivers/net/ifc/base/ifcvf.c create mode 100644 drivers/net/ifc/base/ifcvf.h create mode 100644 drivers/net/ifc/base/ifcvf_osdep.h create mode 100644 drivers/net/ifc/ifcvf_vdpa.c create mode 100644 drivers/net/ifc/rte_ifcvf_version.map
config/common_base +7 -0
@@ -805,6 +805,13 @@ CONFIG_RTE_LIBRTE_VHOST_DEBUG=n # CONFIG_RTE_LIBRTE_PMD_VHOST=n +# +# Compile IFCVF driver +# To compile, CONFIG_RTE_LIBRTE_VHOST and CONFIG_RTE_EAL_VFIO +# should be enabled. +# +CONFIG_RTE_LIBRTE_IFCVF_VDPA_PMD=n + # # Compile the test application #
config/common_linuxapp +1 -0
@@ -15,6 +15,7 @@ CONFIG_RTE_LIBRTE_PMD_KNI=y CONFIG_RTE_LIBRTE_VHOST=y CONFIG_RTE_LIBRTE_VHOST_NUMA=y CONFIG_RTE_LIBRTE_PMD_VHOST=y +CONFIG_RTE_LIBRTE_IFCVF_VDPA_PMD=y CONFIG_RTE_LIBRTE_PMD_AF_PACKET=y CONFIG_RTE_LIBRTE_PMD_TAP=y CONFIG_RTE_LIBRTE_AVP_PMD=y
drivers/net/Makefile +3 -0
@@ -58,6 +58,9 @@ endif # $(CONFIG_RTE_LIBRTE_SCHED) ifeq ($(CONFIG_RTE_LIBRTE_VHOST),y) DIRS-$(CONFIG_RTE_LIBRTE_PMD_VHOST) += vhost +ifeq ($(CONFIG_RTE_EAL_VFIO),y) +DIRS-$(CONFIG_RTE_LIBRTE_IFCVF_VDPA_PMD) += ifc +endif endif # $(CONFIG_RTE_LIBRTE_VHOST) ifeq ($(CONFIG_RTE_LIBRTE_MVPP2_PMD),y)
drivers/net/ifc/Makefile new file +35 -0
@@ -0,0 +1,35 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2018 Intel Corporation + +include $(RTE_SDK)/mk/rte.vars.mk + +# +# library name +# +LIB = librte_ifcvf_vdpa.a + +LDLIBS += -lpthread +LDLIBS += -lrte_eal -lrte_pci -lrte_vhost -lrte_bus_pci + +CFLAGS += -O3 +CFLAGS += $(WERROR_FLAGS) +CFLAGS += -DALLOW_EXPERIMENTAL_API + +# +# Add extra flags for base driver source files to disable warnings in them +# +BASE_DRIVER_OBJS=$(sort $(patsubst %.c,%.o,$(notdir $(wildcard $(SRCDIR)/base/*.c)))) + +VPATH += $(SRCDIR)/base + +EXPORT_MAP := rte_ifcvf_version.map + +LIBABIVER := 1 + +# +# all source are stored in SRCS-y +# +SRCS-$(CONFIG_RTE_LIBRTE_IFCVF_VDPA_PMD) += ifcvf_vdpa.c +SRCS-$(CONFIG_RTE_LIBRTE_IFCVF_VDPA_PMD) += ifcvf.c + +include $(RTE_SDK)/mk/rte.lib.mk
drivers/net/ifc/base/ifcvf.c new file +329 -0
329 lines not on this page · raw message
drivers/net/ifc/base/ifcvf.h new file +160 -0
160 lines not on this page · raw message
drivers/net/ifc/base/ifcvf_osdep.h new file +52 -0
52 lines not on this page · raw message
drivers/net/ifc/ifcvf_vdpa.c new file +846 -0
846 lines not on this page · raw message
drivers/net/ifc/rte_ifcvf_version.map new file +4 -0
@@ -0,0 +1,4 @@ +DPDK_18.05 { + + local: *; +};
mk/rte.app.mk +3 -0
@@ -186,6 +186,9 @@ _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 +ifeq ($(CONFIG_RTE_EAL_VFIO),y) +_LDLIBS-$(CONFIG_RTE_LIBRTE_IFCVF_VDPA_PMD) += -lrte_ifcvf_vdpa +endif # $(CONFIG_RTE_EAL_VFIO) endif # $(CONFIG_RTE_LIBRTE_VHOST) _LDLIBS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += -lrte_pmd_vmxnet3_uio
Signature · 1 line
2.15.1
PATCH v9 5/5 doc: add ifcvf driver document and release note
In reply to Xiao Wang--- doc/guides/nics/features/ifcvf.ini | 8 +++ doc/guides/nics/ifcvf.rst | 98 ++++++++++++++++++++++++++++++++++ doc/guides/nics/index.rst | 1 + doc/guides/rel_notes/release_18_05.rst | 9 ++++ 4 files changed, 116 insertions(+) create mode 100644 doc/guides/nics/features/ifcvf.ini create mode 100644 doc/guides/nics/ifcvf.rst
doc/guides/nics/features/ifcvf.ini new file +8 -0
@@ -0,0 +1,8 @@ +; +; Supported features of the 'ifcvf' vDPA driver. +; +; Refer to default.ini for the full list of available PMD features. +; +[Features] +x86-32 = Y +x86-64 = Y
doc/guides/nics/ifcvf.rst new file +98 -0
98 lines not on this page · raw message
doc/guides/nics/index.rst +1 -0
@@ -45,6 +45,7 @@ Network Interface Controller Drivers vmxnet3 pcap_ring fail_safe + ifcvf **Figures**
doc/guides/rel_notes/release_18_05.rst +9 -0
@@ -115,6 +115,15 @@ New Features Linux uevent is supported as backend of this device event notification framework. +* **Added IFCVF vDPA driver.** + + Added IFCVF vDPA driver to support Intel FPGA 100G VF device. IFCVF works + as a HW vhost data path accelerator, it supports live migration and is + compatible with virtio 0.95 and 1.0. This driver registers ifcvf vDPA driver + to vhost lib, when virtio connected, with the help of the registered vDPA + driver the assigned VF gets configured to Rx/Tx directly to VM's virtio + vrings. + API Changes -----------
Signature · 1 line
2.15.1
Re: [PATCH v9 0/5] add ifcvf vdpa driver
In reply to Xiao WangQuoted 107 lines · Xiao Wang
IFCVF driver
============
The IFCVF vDPA (vhost data path acceleration) driver provides support for the Intel FPGA 100G VF (IFCVF). IFCVF's datapath is virtio ring compatible, it works as a HW vhost backend which can send/receive packets to/from virtio directly by DMA. Besides, it supports dirty page logging and device state report/restore. This driver enables its vDPA functionality with live migration feature.vDPA mode
=========
IFCVF's vendor ID and device ID are same as that of virtio net pci device, with its specific subsystem vendor ID and device ID. To let the device be probed by IFCVF driver, adding "vdpa=1" parameter helps to specify that this device is to be used in vDPA mode, rather than polling mode, virtio pmd will skip when it detects this message.Container per device
====================
vDPA needs to create different containers for different devices, thus this patch set adds some APIs in eal/vfio to support multiple container, e.g.
-rte_vfio_container_create
-rte_vfio_container_destroy
-rte_vfio_container_group_bind
-rte_vfio_container_group_unbindBy this extension, a device can be put into a new specific container, rather than the previous default container.
Two APIs are added for IOMMU programming for a specified container:
-rte_vfio_container_dma_map
-rte_vfio_container_dma_unmapIFCVF vDPA details
==================
Key vDPA driver ops implemented:
-ifcvf_dev_config:
Enable VF data path with virtio information provided by vhost lib, including IOMMU programming to enable VF DMA to VM's memory, VFIO interrupt setup to route HW interrupt to virtio driver, create notify relay thread to translate virtio driver's kick to a MMIO write onto HW, HW queues configuration.This function gets called to set up HW data path backend when virtio driver in VM gets ready.
-
ifcvf_dev_close:
Revoke all the setup inifcvf_dev_config.This function gets called when virtio driver stops device in VM.
Change log
==========
v9:
- Rebase on master tree's HEAD.
- Fix compile error on 32-bit platform.v8:
- Rebase on HEAD.
- Movevfio_groupdefinition back toeal_vfio.h.
- Return NULL when vfio group num/fd is not found, let caller handle that.
- Fix wrong API name in commit log.
- Rename bind/unbind function to rte_vfio_container_group_bind/unbind for consistensy.
- Add note forrte_vfio_container_createandrte_vfio_dma_mapand fix typo in comment.
- Extract out the shared code snip ofrte_vfio_dma_mapandrte_vfio_container_dma_mapto avoid code duplication. So do for the unmap.v7:
- Rebase on HEAD.
- Split the vfio patch into 2 parts, one for data structure extension, one for adding new API.
- Use staticvfio_configarray instead of dynamic alloating.
- Change rte_vfio_container_dma_map/unmap's parameters to use (va, iova, len).v6:
- Rebase on master branch.
- Document "vdpa" devarg in virtio documentation.
- Rename ifcvf config option toCONFIG_RTE_LIBRTE_IFCVF_VDPA_PMDfor consistensy, and add it into driver documentation.
- Add comments for ifcvf device ID.
- Minor code cleaning.v5:
- Fix compilation in BSD, remove therte_vfio.hincluding in BSD.v4:
- Rebase on Zhihong's latest vDPA lib patch, with vDPA ops names change.
- Remove API "rte_vfio_get_group_fd", "rte_vfio_bind_group" will return the fd.
- Align thevfio_cfgsearch internal APIs naming.v3:
- Add doc and release note for the new driver.
- Remove the vdev concept, make the driver as a PCI driver, it will get probed by PCI bus driver.
- Rebase on the v4 vDPA lib patch, register a vDPA device instead of a engine.
- Remove the PCI API exposure accordingly.
- Move theMAX_VFIO_CONTAINERSdefinition to config file.
- Let virtio pmd skips when a virtio device needs to work in vDPA mode.v2:
- Rename functionpci_get_kernel_driver_by_pathtorte_pci_device_kdriver_nameto make the API generic cross Linux and BSD, make it as EXPERIMENTAL.
- Rebase on Zhihong's vDPA v3 patch set.
- Minor code cleanup on vfio extension.
Quoted 6 lines
Xiao Wang (5):
vfio: extend data structure for multi container
vfio: add multi container support
net/virtio: skip device probe in vdpa mode
net/ifcvf: add ifcvf vdpa driver
doc: add ifcvf driver document and release note
Series applied to dpdk-next-net/master, thanks.