receive IRQ related patches
cover receive IRQ related patches
These are some of the patches to enhance the still as not yet merged receive interrupt functionality.
The big piece is support of UIO-MSI interrupts which is required to make the virtio and vmxnet3 receive IRQ functionality work. After this piece is reviewed, I will send those bits.
Stephen Hemminger (5):
ethdev: check for rxq interrupt support
ethdev: remove unnecessary checks
ethdev: fix errors if RTE_ETHDEV_DEBUG enabled
uio: new driver with MSI-X support
uio: integrate MSI-X support
config/common_linuxapp | 1 + lib/librte_eal/common/include/rte_pci.h | 1 + lib/librte_eal/linuxapp/Makefile | 3 + lib/librte_eal/linuxapp/eal/eal_interrupts.c | 94 +++++- lib/librte_eal/linuxapp/eal/eal_pci.c | 4 + lib/librte_eal/linuxapp/eal/eal_pci_uio.c | 59 +++- lib/librte_eal/linuxapp/eal/eal_uio_msi.h | 26 ++ .../linuxapp/eal/include/exec-env/rte_interrupts.h | 1 + lib/librte_eal/linuxapp/uio_msi/Makefile | 13 + lib/librte_eal/linuxapp/uio_msi/uio_msi.c | 365 +++++++++++++++++++++ lib/librte_eal/linuxapp/uio_msi/uio_msi.h | 22 ++ lib/librte_ether/rte_ethdev.c | 29 +- tools/dpdk_nic_bind.py | 2 +- 13 files changed, 580 insertions(+), 40 deletions(-) create mode 100644 lib/librte_eal/linuxapp/eal/eal_uio_msi.h create mode 100644 lib/librte_eal/linuxapp/uio_msi/Makefile create mode 100644 lib/librte_eal/linuxapp/uio_msi/uio_msi.c create mode 100644 lib/librte_eal/linuxapp/uio_msi/uio_msi.h
Signature · 1 line
2.1.4
PATCH 1/5 ethdev: check for rxq interrupt support
Not all devices support rxq interrupt yet.
It is better to check for interrupt support in driver at configuration time than waiting for later failures.
--- lib/librte_ether/rte_ethdev.c | 8 ++++++++ 1 file changed, 8 insertions(+)
lib/librte_ether/rte_ethdev.c +8 -0
@@ -1183,6 +1183,14 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, }/* +* If Receive Queue interrupt is enabled, check that +* the device supports interrupt control. +*/ +if (dev_conf->intr_conf.rxq ==1 ) +FUNC_PTR_OR_ERR_RET (*dev->dev_ops->rx_queue_intr_enable, + -EINVAL ); + +/* * If jumbo frames are enabled, check that the maximum RX packet * length is supported by the configured device. */
Signature · 1 line
2.1.4
PATCH 2/5 ethdev: remove unnecessary checks
In reply to Stephen HemmingerSince the code has just called rte_eth_dev_is_valid_port the following checks are unnecessary.
--- lib/librte_ether/rte_ethdev.c | 16 ---------------- 1 file changed, 16 deletions(-)
lib/librte_ether/rte_ethdev.c +0 -16
@@ -3305,10 +3305,6 @@ rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int op, void *data) } dev = &rte_eth_devices[port_id]; -if (dev ==NULL ) { -PMD_DEBUG_TRACE ("Invalid port device\n" ); -return -ENODEV ; - } intr_handle = &dev->pci_dev->intr_handle;if (!intr_handle->intr_vec) {
@@ -3350,10 +3346,6 @@ rte_eth_dev_rx_intr_ctl_q(uint8_t port_id, uint16_t queue_id, } dev = &rte_eth_devices[port_id]; -if (dev ==NULL ) { -PMD_DEBUG_TRACE ("Invalid port device\n" ); -return -ENODEV ; - }if (queue_id >= dev->data->nb_rx_queues) {PMD_DEBUG_TRACE ("Invalid RX queue_id=%d\n" , rx_queue_id);
@@ -3391,10 +3383,6 @@ rte_eth_dev_rx_intr_enable(uint8_t port_id, } dev = &rte_eth_devices[port_id]; -if (dev ==NULL ) { -PMD_DEBUG_TRACE ("Invalid port device\n" ); -return -ENODEV ; - }FUNC_PTR_OR_ERR_RET (*dev->dev_ops->rx_queue_intr_enable, -ENOTSUP );return (*dev->dev_ops->rx_queue_intr_enable)(dev, queue_id);
@@ -3412,10 +3400,6 @@ rte_eth_dev_rx_intr_disable(uint8_t port_id, } dev = &rte_eth_devices[port_id]; -if (dev ==NULL ) { -PMD_DEBUG_TRACE ("Invalid port device\n" ); -return -ENODEV ; - }FUNC_PTR_OR_ERR_RET (*dev->dev_ops->rx_queue_intr_disable, -ENOTSUP );return (*dev->dev_ops->rx_queue_intr_disable)(dev, queue_id);
Signature · 1 line
2.1.4
PATCH 3/5 ethdev: fix errors if RTE_ETHDEV_DEBUG enabled
In reply to Stephen HemmingerThe interrupt mode patches introduced some obvious errors if RTE_ETHDEV_DEBUG is defined.
--- lib/librte_ether/rte_ethdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/librte_ether/rte_ethdev.c +2 -2
@@ -3348,13 +3348,13 @@ rte_eth_dev_rx_intr_ctl_q(uint8_t port_id, uint16_t queue_id, dev = &rte_eth_devices[port_id];if (queue_id >= dev->data->nb_rx_queues) { -PMD_DEBUG_TRACE ("Invalid RX queue_id=%d\n" , rx_queue_id); +PMD_DEBUG_TRACE ("Invalid RX queue_id=%d\n" , queue_id);return -EINVAL ; } intr_handle = &dev->pci_dev->intr_handle;if (!intr_handle->intr_vec || intr_handle->intr_vec[queue_id] <0 ) { -PMD_DEBUG_TRACE ("RX Intr vector unset on %d\n" , rx_queue_id); +PMD_DEBUG_TRACE ("RX Intr vector unset on %d\n" , queue_id);return -EPERM ; }
Signature · 1 line
2.1.4
PATCH 4/5 uio: new driver with MSI-X support
In reply to Stephen HemmingerThis is a merge of igb_uio with the MSI-X support through eventfd (similar to VFIO). The driver requires a small change to upstream UIO driver to allow UIO drivers to support ioctl's.
See:
http://marc.info/?l=linux-kernel&m=143197030217434&w=2
http://www.spinics.net/lists/kernel/msg1993359.html
--- config/common_linuxapp | 1 + lib/librte_eal/linuxapp/Makefile | 3 + lib/librte_eal/linuxapp/uio_msi/Makefile | 13 ++ lib/librte_eal/linuxapp/uio_msi/uio_msi.c | 365 ++++++++++++++++++++++++++++++ lib/librte_eal/linuxapp/uio_msi/uio_msi.h | 22 ++ 5 files changed, 404 insertions(+) create mode 100644 lib/librte_eal/linuxapp/uio_msi/Makefile create mode 100644 lib/librte_eal/linuxapp/uio_msi/uio_msi.c create mode 100644 lib/librte_eal/linuxapp/uio_msi/uio_msi.h
config/common_linuxapp +1 -0
@@ -100,6 +100,7 @@ CONFIG_RTE_EAL_ALLOW_INV_SOCKET_ID=n CONFIG_RTE_EAL_ALWAYS_PANIC_ON_ERROR=n CONFIG_RTE_EAL_IGB_UIO=y CONFIG_RTE_EAL_VFIO=y +CONFIG_RTE_EAL_UIO_MSI=y # # Special configurations in PCI Config Space for high performance
lib/librte_eal/linuxapp/Makefile +3 -0
@@ -34,6 +34,9 @@ include $(RTE_SDK)/mk/rte.vars.mk ifeq ($(CONFIG_RTE_EAL_IGB_UIO),y) DIRS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += igb_uio endif +ifeq ($(CONFIG_RTE_EAL_UIO_MSI),y) +DIRS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += uio_msi +endif DIRS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal ifeq ($(CONFIG_RTE_LIBRTE_KNI),y) DIRS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += kni
lib/librte_eal/linuxapp/uio_msi/Makefile new file +13 -0
@@ -0,0 +1,13 @@ + +include $(RTE_SDK)/mk/rte.vars.mk + +MODULE = uio_msi +MODULE_PATH = drivers/uio/uio_msi + +MODULE_CFLAGS += -I$(SRCDIR) +MODULE_CFLAGS += -I$(RTE_OUTPUT)/include +MODULE_CFLAGS += -Winline -Wall -Werror + +SRCS-y := uio_msi.c + +include $(RTE_SDK)/mk/rte.module.mk
lib/librte_eal/linuxapp/uio_msi/uio_msi.c new file +365 -0
365 lines not on this page · raw message
lib/librte_eal/linuxapp/uio_msi/uio_msi.h new file +22 -0
@@ -0,0 +1,22 @@ +/* +* UIO_MSI API definition +* +* Copyright (c) 2015 by Brocade Communications Systems, Inc. +* All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ +#ifndef _UIO_PCI_MSI_H +#define _UIO_PCI_MSI_H + +struct uio_msi_irq_set { +u32 vec; +int fd; +}; + +#define UIO_MSI_BASE 0x86 +#define UIO_MSI_IRQ_SET _IOW('I', UIO_MSI_BASE+1, struct uio_msi_irq_set) + +#endif
Signature · 1 line
2.1.4
Re: [PATCH 4/5] uio: new driver with MSI-X support
Quoted 19 lines · Stephen Hemminger
lib/librte_eal/linuxapp/uio_msi/uio_msi.c new file +19
-0+ +/* set the mapping between vector # and existing eventfd. */ +static int set_irq_eventfd (struct uio_msi_pci_dev *udev,u32 vec,int fd) +{ +struct uio_msi_irq_ctx *ctx; +struct eventfd_ctx *trigger; +int irq, err; + +if (vec >= udev->num_vectors) { +dev_notice (&udev->pdev->dev,"vec %u >= num_vec %u\n" , + vec, udev->num_vectors); +return -ERANGE ; + } + + irq = udev->msix[vec].vector; + +/* Clearup existing irq mapping */ + ctx = &udev->ctx[vec]; +if (ctx->trigger) {
lib/librte_eal/linuxapp/uio_msi/uio_msi.c line 85
Quoted 10 lines
lib/librte_eal/linuxapp/uio_msi/uio_msi.c new file +10
-0+free_irq (irq, ctx->trigger); +eventfd_ctx_put (ctx->trigger); + ctx->trigger =NULL ; + } + +/* Passing -1 is used to disable interrupt */ +if (fd <0 ) +return 0 ; + +
One unnecessary blank line here.
Quoted 34 lines
lib/librte_eal/linuxapp/uio_msi/uio_msi.c new file +34
-0+ trigger =eventfd_ctx_fdget (fd); +if (IS_ERR (trigger)) { + err =PTR_ERR (trigger); +dev_notice (&udev->pdev->dev, +"eventfd ctx get failed: %d\n" , err); +return err; + } + + err =request_irq (irq, uio_msi_irqhandler,0 , ctx->name, trigger); +if (err) { +dev_notice (&udev->pdev->dev, +"request irq failed: %d\n" , err); +eventfd_ctx_put (trigger); +return err; + } + +dev_dbg (&udev->pdev->dev,"map vector %u to fd %d trigger %p\n" , + vec, fd, trigger); + ctx->trigger = trigger; +return 0 ; +} + +static int +uio_msi_ioctl (struct uio_info *info,unsigned int cmd,unsigned long arg) +{ +struct uio_msi_pci_dev *udev + = container_of(info, struct uio_msi_pci_dev, info); +struct uio_msi_irq_set hdr; +int err; + +switch (cmd) { +case UIO_MSI_IRQ_SET : +if (copy_from_user (&hdr, (void __user *)arg,sizeof (hdr))) +return -EFAULT ;
lib/librte_eal/linuxapp/uio_msi/uio_msi.c line 129
Quoted 10 lines
lib/librte_eal/linuxapp/uio_msi/uio_msi.c new file +10
-0+ +mutex_lock (&udev->mutex); + err =set_irq_eventfd (udev, hdr.vec, hdr.fd); +mutex_unlock (&udev->mutex); +break ; +default : + err = -EOPNOTSUPP ; + } +return err; +}
"uio_msi_irq_set" defines in single pattern. Compare with the bulk set in "vfio_irq_set", it requires additional syscall during uio_msix_enable().
Quoted 12 lines
lib/librte_eal/linuxapp/uio_msi/uio_msi.c new file +12
-0+ +static int uio_msi_probe (struct pci_dev *pdev,const struct pci_device_id *id) +{ +struct uio_msi_pci_dev *udev; +int i, err, vectors; + + udev =kzalloc (sizeof (struct uio_msi_pci_dev ),GFP_KERNEL ); +if (!udev) +return -ENOMEM ; + + err =pci_enable_device (pdev); +if (err !=0 ) {
lib/librte_eal/linuxapp/uio_msi/uio_msi.c line 261
Quoted 10 lines
lib/librte_eal/linuxapp/uio_msi/uio_msi.c new file +10
-0+dev_err (&pdev->dev,"cannot enable PCI device\n" ); + goto fail_free; + } + + vectors =pci_msix_vec_count (pdev); +if (vectors <0 ) { +dev_err (&pdev->dev,"device does not support MSI-X\n" ); + err = -EINVAL ; + goto fail_disable; + }
pci_msix_vec_count() is available since v3.14, it requires a compatible check. In order to support older version, probably a function 'uio_msix_vec_count()' is necessary.
I've one overall question, is there a special reason not enhance igb_uio but define a new uio_msi? And the looks like the piece could be add into igb_uio or uio_pci_generic as well. Do you have plan for the latter? Thanks.
Re: [PATCH 4/5] uio: new driver with MSI-X support
Quoted 71 lines · Cunming
Quoted 19 lines · Stephen Hemminger
lib/librte_eal/linuxapp/uio_msi/uio_msi.c new file +19
-0+ +/* set the mapping between vector # and existing eventfd. */ +static int set_irq_eventfd (struct uio_msi_pci_dev *udev,u32 vec,int fd) +{ +struct uio_msi_irq_ctx *ctx; +struct eventfd_ctx *trigger; +int irq, err; + +if (vec >= udev->num_vectors) { +dev_notice (&udev->pdev->dev,"vec %u >= num_vec %u\n" , + vec, udev->num_vectors); +return -ERANGE ; + } + + irq = udev->msix[vec].vector; + +/* Clearup existing irq mapping */ + ctx = &udev->ctx[vec]; +if (ctx->trigger) {lib/librte_eal/linuxapp/uio_msi/uio_msi.c line 85
Quoted 10 lines
lib/librte_eal/linuxapp/uio_msi/uio_msi.c new file +10
-0+free_irq (irq, ctx->trigger); +eventfd_ctx_put (ctx->trigger); + ctx->trigger =NULL ; + } + +/* Passing -1 is used to disable interrupt */ +if (fd <0 ) +return 0 ; + +One unnecessary blank line here.
Quoted 38 lines
lib/librte_eal/linuxapp/uio_msi/uio_msi.c new file +38
-0+ trigger =eventfd_ctx_fdget (fd); +if (IS_ERR (trigger)) { + err =PTR_ERR (trigger); +dev_notice (&udev->pdev->dev, +"eventfd ctx get failed: %d\n" , err); +return err; + } + + err =request_irq (irq, uio_msi_irqhandler,0 , ctx->name, trigger); +if (err) { +dev_notice (&udev->pdev->dev, +"request irq failed: %d\n" , err); +eventfd_ctx_put (trigger); +return err; + } + +dev_dbg (&udev->pdev->dev,"map vector %u to fd %d trigger %p\n" , + vec, fd, trigger); + ctx->trigger = trigger; +return 0 ; +} + +static int +uio_msi_ioctl (struct uio_info *info,unsigned int cmd,unsigned long arg) +{ +struct uio_msi_pci_dev *udev + = container_of(info, struct uio_msi_pci_dev, info); +struct uio_msi_irq_set hdr; +int err; + +switch (cmd) { +case UIO_MSI_IRQ_SET : +if (copy_from_user (&hdr, (void __user *)arg,sizeof (hdr))) +return -EFAULT ; + +mutex_lock (&udev->mutex); + err =set_irq_eventfd (udev, hdr.vec, hdr.fd); +mutex_unlock (&udev->mutex);
Quoted 8 lines
lib/librte_eal/linuxapp/uio_msi/uio_msi.c line 129
Quoted 6 lines
lib/librte_eal/linuxapp/uio_msi/uio_msi.c new file +6
-0+break ; +default : + err = -EOPNOTSUPP ; + } +return err; +}"
uio_msi_irq_set" defines in single pattern. Compare with the bulk set in "vfio_irq_set", it requires additional syscall duringuio_msix_enable().
The bulk operation is VFIO is actually a bad design,
It forces too many updates when manipulating individual vectors. Personally, the whole VFIO API has some questionable design choices that I did not want to repeat.
Quoted 26 lines
Quoted 11 lines
lib/librte_eal/linuxapp/uio_msi/uio_msi.c new file +11
-0+static int uio_msi_probe (struct pci_dev *pdev,const struct pci_device_id *id) +{ +struct uio_msi_pci_dev *udev; +int i, err, vectors; + + udev =kzalloc (sizeof (struct uio_msi_pci_dev ),GFP_KERNEL ); +if (!udev) +return -ENOMEM ; + + err =pci_enable_device (pdev); +if (err !=0 ) {lib/librte_eal/linuxapp/uio_msi/uio_msi.c line 261
Quoted 10 lines
lib/librte_eal/linuxapp/uio_msi/uio_msi.c new file +10
-0+dev_err (&pdev->dev,"cannot enable PCI device\n" ); + goto fail_free; + } + + vectors =pci_msix_vec_count (pdev); +if (vectors <0 ) { +dev_err (&pdev->dev,"device does not support MSI-X\n" ); + err = -EINVAL ; + goto fail_disable; + }
pci_msix_vec_count()is available since v3.14, it requires a compatible check.
In order to support older version, probably a function 'uio_msix_vec_count()' is necessary.
Quoted 4 lines
I've one overall question, is there a special reason not enhance
igb_uiobut define a newuio_msi? And the looks like the piece could be add intoigb_uiooruio_pci_genericas well. Do you have plan for the latter? Thanks.
I wanted something that could go upstream. igb_uio has some other things which make it unlikely to get accepted in current form, so seemed best to start fresh.
Also, intentionally did not want to address any kernel version earlier than the version where VFIO was added.
PATCH 5/5 uio: integrate MSI-X support
In reply to Stephen HemmingerAdd the new uio_msi as a supported driver model.
--- lib/librte_eal/common/include/rte_pci.h | 1 + lib/librte_eal/linuxapp/eal/eal_interrupts.c | 94 +++++++++++++++++++--- lib/librte_eal/linuxapp/eal/eal_pci.c | 4 + lib/librte_eal/linuxapp/eal/eal_pci_uio.c | 59 ++++++++++++-- lib/librte_eal/linuxapp/eal/eal_uio_msi.h | 26 ++++++ .../linuxapp/eal/include/exec-env/rte_interrupts.h | 1 + lib/librte_ether/rte_ethdev.c | 1 + tools/dpdk_nic_bind.py | 2 +- 8 files changed, 166 insertions(+), 22 deletions(-) create mode 100644 lib/librte_eal/linuxapp/eal/eal_uio_msi.h
lib/librte_eal/common/include/rte_pci.h +1 -0
@@ -147,6 +147,7 @@ enum rte_kernel_driver {RTE_KDRV_IGB_UIO ,RTE_KDRV_VFIO ,RTE_KDRV_UIO_GENERIC , + RTE_KDRV_UIO_MSIX, };/**
lib/librte_eal/linuxapp/eal/eal_interrupts.c +81 -13
147 lines not on this page · raw message
lib/librte_eal/linuxapp/eal/eal_pci.c +4 -0
@@ -345,6 +345,8 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus, dev->kdrv =RTE_KDRV_IGB_UIO ; else if (!strcmp(driver, "uio_pci_generic")) dev->kdrv =RTE_KDRV_UIO_GENERIC ; + else if (!strcmp(driver, "uio_msi")) + dev->kdrv =RTE_KDRV_UIO_MSIX ; else dev->kdrv = RTE_KDRV_UNKNOWN; }else if (ret <0 ) {
@@ -576,6 +578,7 @@ pci_map_device(struct rte_pci_device *dev) ret =pci_vfio_map_resource (dev);#endif break ; +case RTE_KDRV_UIO_MSIX :case RTE_KDRV_IGB_UIO :case RTE_KDRV_UIO_GENERIC :/* map resources for devices that use uio */
@@ -603,6 +606,7 @@ pci_unmap_device(struct rte_pci_device *dev)case RTE_KDRV_VFIO :RTE_LOG (ERR ,EAL ,"Hotplug doesn't support vfio yet\n" );break ; +case RTE_KDRV_UIO_MSIX :case RTE_KDRV_IGB_UIO :case RTE_KDRV_UIO_GENERIC :/* unmap resources for devices that use uio */
lib/librte_eal/linuxapp/eal/eal_pci_uio.c +51 -8
111 lines not on this page · raw message
lib/librte_eal/linuxapp/eal/eal_uio_msi.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* UIO_MSI API definition +* +* Copyright (c) 2015 by Brocade Communications Systems, Inc. +* All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ +#ifndef EAL_UIO_MSI_H +#define EAL_UIO_MSI_H + +/* Driver is not upstream yet. */ + +#include <sys/ioctl.h> + +struct uio_msi_irq_set { +uint32_t vec; +int fd; +}; + +#define UIO_MSI_BASE 0x86 +#define UIO_MSI_IRQ_SET _IOW('I', UIO_MSI_BASE+1, struct uio_msi_irq_set) + +#endif
lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h +1 -0
@@ -44,6 +44,7 @@ enum rte_intr_handle_type {RTE_INTR_HANDLE_UNKNOWN =0 ,RTE_INTR_HANDLE_UIO ,/**< uio device handle */ RTE_INTR_HANDLE_UIO_INTX ,/**< uio generic handle */ +RTE_INTR_HANDLE_UIO_MSIX ,/**< uio with MSI-X support */ RTE_INTR_HANDLE_VFIO_LEGACY ,/**< vfio device handle (legacy) */ RTE_INTR_HANDLE_VFIO_MSI ,/**< vfio device handle (MSI) */ RTE_INTR_HANDLE_VFIO_MSIX, /**< vfio device handle (MSIX) */
lib/librte_ether/rte_ethdev.c +1 -0
@@ -515,6 +515,7 @@ rte_eth_dev_is_detachable(uint8_t port_id)switch (rte_eth_devices[port_id].pci_dev->kdrv) {case RTE_KDRV_IGB_UIO :case RTE_KDRV_UIO_GENERIC : +case RTE_KDRV_UIO_MSIX :break ;case RTE_KDRV_VFIO :default :
tools/dpdk_nic_bind.py +1 -1
@@ -43,7 +43,7 @@ ETHERNET_CLASS = "0200" # Each device within this is itself a dictionary of device properties devices = {} # list of supported DPDK drivers -dpdk_drivers = [ "igb_uio", "vfio-pci", "uio_pci_generic" ] +dpdk_drivers = [ "igb_uio", "vfio-pci", "uio_pci_generic", "uio_msi" ] # command-line arg flags b_flag = None
Signature · 1 line
2.1.4
Re: [PATCH 5/5] uio: integrate MSI-X support
Quoted 13 lines · Stephen Hemminger
lib/librte_eal/linuxapp/eal/eal_interrupts.c +13
-0+/* enable MSI-X interrupts */ +static int +uio_msix_enable (struct rte_intr_handle *intr_handle) +{ +int i, max_intr; + +if (!intr_handle->max_intr || + intr_handle->max_intr >RTE_MAX_RXTX_INTR_VEC_ID ) + max_intr =RTE_MAX_RXTX_INTR_VEC_ID +1 ; +else + max_intr = intr_handle->max_intr; + +/* Actual number of MSI-X interrupts might be less than requested */
lib/librte_eal/linuxapp/eal/eal_interrupts.c vfio_disable_msix(struct rte_intr_handle *intr_handle) { · line 380
Quoted 10 lines
lib/librte_eal/linuxapp/eal/eal_interrupts.c +10
-0+for (i =0 ; i < max_intr; i++) { +struct uio_msi_irq_set irqs = { + .vec = i, + .fd = intr_handle->efds[i], + }; + +if (i == max_intr -1 ) + irqs.fd = intr_handle->fd; + +if (ioctl (intr_handle->vfio_dev_fd,UIO_MSI_IRQ_SET , &irqs) <0 ) {
It would be strange if using vfio_dev_fd in 'uio_msix_' related function.
Quoted 59 lines
lib/librte_eal/linuxapp/eal/eal_pci_uio.c +20
-6+RTE_LOG (ERR ,EAL , +"Error enabling MSI-X event %u fd %d (%s)\n" , + irqs.vec, irqs.fd,strerror (errno)); +return -1 ; + } + } + +return 0 ; +} + +/* map the PCI resource of a PCI device in virtual memory */ int pci_uio_map_resource (struct rte_pci_device *dev) { -int i, map_idx; +int i, fd, map_idx;char dirname[PATH_MAX ]; -char cfgname[PATH_MAX ];char devname[PATH_MAX ];/* contains the /dev/uioX */ void *mapaddr;int uio_num;@@ -274,11 +304,15 @@ pci_uio_map_resource(struct rte_pci_device *dev)struct mapped_pci_resource *uio_res;struct mapped_pci_res_list *uio_res_list =RTE_TAILQ_CAST (rte_uio_tailq.head, mapped_pci_res_list);struct pci_map *maps; +char cfgname[PATH_MAX ]; dev->intr_handle.fd =-1 ; - dev->intr_handle.uio_cfg_fd =-1 ; + dev->intr_handle.vfio_dev_fd =-1 ; dev->intr_handle.type =RTE_INTR_HANDLE_UNKNOWN ; +for (i =0 ; i <RTE_MAX_RXTX_INTR_VEC_ID ; i++) + dev->intr_handle.efds[i] =-1 ; +/* secondary processes - use already recorded details */ if (rte_eal_process_type () !=RTE_PROC_PRIMARY )return pci_uio_map_secondary (dev);@@ -293,15 +327,15 @@ pci_uio_map_resource(struct rte_pci_device *dev)snprintf (devname,sizeof (devname),"/dev/uio%u" , uio_num);/* save fd if in primary process */ - dev->intr_handle.fd =open (devname,O_RDWR ); -if (dev->intr_handle.fd <0 ) { + fd =open (devname,O_RDWR ); +if (fd <0 ) {RTE_LOG (ERR ,EAL ,"Cannot open %s: %s\n" , devname,strerror (errno));return -1 ; }snprintf (cfgname,sizeof (cfgname), -"/sys/class/uio/uio%u/device/config" , uio_num); +"/sys/class/uio/uio%u/device/config" , uio_num); dev->intr_handle.uio_cfg_fd =open (cfgname,O_RDWR );if (dev->intr_handle.uio_cfg_fd <0 ) { RTE_LOG(ERR, EAL, "Cannot open %s: %s\n",
lib/librte_eal/linuxapp/eal/eal_pci_uio.c pci_uio_map_resource(struct rte_pci_device *dev) · line 347
Quoted 6 lines
lib/librte_eal/linuxapp/eal/eal_pci_uio.c +2
-1@@ -309,9 +343,17 @@ pci_uio_map_resource(struct rte_pci_device *dev)return -1 ; } -if (dev->kdrv ==RTE_KDRV_IGB_UIO ) +if (dev->kdrv ==RTE_KDRV_UIO_MSIX ) { + dev->intr_handle.vfio_dev_fd = fd;
I understand now uio_cfg_fd is used for uio configure and intx, so one additional event fd required by uio_msi for msi/msix other cause intr.
What about store it in epfd[max_intr - 1] or define a new 'uio_msi_efd' so as to avoid using vfio_dev_fd.
As uio_msi defines only to support msi/msix mode, while igb_uio support either intx or msix(one intr vector).
It makes confusing for user to choose which to insmod.
The ideal way probably be one uio kernel module support all mode, by new added ioctl it can configure which intr mode {intx, msi, msix}(by new eal option --uio-intr or merge with --vfio-intr to an unify --intr-mode) user app expect to use.
Quoted 22 lines
lib/librte_eal/linuxapp/eal/eal_pci_uio.c +9
-1+ dev->intr_handle.type =RTE_INTR_HANDLE_UIO_MSIX ; +if (pci_uio_msix_init (dev) <0 ) +return -1 ; + }else if (dev->kdrv ==RTE_KDRV_IGB_UIO ) { + dev->intr_handle.fd = fd; dev->intr_handle.type =RTE_INTR_HANDLE_UIO ; - else { + }else { + + dev->intr_handle.fd = fd; dev->intr_handle.type =RTE_INTR_HANDLE_UIO_INTX ;/* set bus master that is not done by uio_pci_generic */ @@ -460,6 +502,7 @@ pci_uio_unmap_resource(struct rte_pci_device *dev)/* close fd if in primary process */ close (dev->intr_handle.fd); +close (dev->intr_handle.uio_cfg_fd); dev->intr_handle.fd =-1 ; dev->intr_handle.type =RTE_INTR_HANDLE_UNKNOWN ;
Re: [PATCH 5/5] uio: integrate MSI-X support
Quoted 4 lines · Cunming
lib/librte_eal/linuxapp/eal/eal_interrupts.c vfio_disable_msix(struct rte_intr_handle *intr_handle) { · line 380
Quoted 3 lines
lib/librte_eal/linuxapp/eal/eal_interrupts.c +3
-0+ irqs.fd = intr_handle->fd; + +if (ioctl (intr_handle->vfio_dev_fd,UIO_MSI_IRQ_SET , &irqs) <0 ) {It would be strange if using
vfio_dev_fdin 'uio_msix_' related function.
Just minor variable name. The whole set of fd's etc, probably need better names..
2015-05-18 10:40, Stephen Hemminger:
Quoted 2 lines
These are some of the patches to enhance the still as not yet merged receive interrupt functionality.
Have you made these comments in the interrupt mode thread?
Quoted 2 lines
The big piece is support of UIO-MSI interrupts which is required to make the virtio and vmxnet3 receive IRQ functionality work.
It seems better to wait that the kernel module is integrated upstream. Any news?
Then the last patch to use this new module will have to be carefully reviewed.