From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [143.182.124.21]) by dpdk.org (Postfix) with ESMTP id D31A0B0C1 for ; Fri, 13 Jun 2014 16:52:45 +0200 (CEST) Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga101.ch.intel.com with ESMTP; 13 Jun 2014 07:53:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,471,1400050800"; d="scan'208";a="445224074" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by azsmga001.ch.intel.com with ESMTP; 13 Jun 2014 07:52:57 -0700 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id s5DEqujt004324; Fri, 13 Jun 2014 15:52:57 +0100 Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id s5DEquZe017207; Fri, 13 Jun 2014 15:52:56 +0100 Received: (from aburakov@localhost) by sivswdev02.ir.intel.com with id s5DEquYx017203; Fri, 13 Jun 2014 15:52:56 +0100 From: Anatoly Burakov To: dev@dpdk.org Date: Fri, 13 Jun 2014 15:52:41 +0100 Message-Id: X-Mailer: git-send-email 1.7.0.7 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v6 07/20] igb_uio: Moved interrupt type out of igb_uio X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Jun 2014 14:52:48 -0000 Moving interrupt type enum out of igb_uio and renaming it to be more generic. Such a strange header naming and separation is done mostly to make coming virtio patches easier to port to dpdk.org tree. --- lib/librte_eal/common/Makefile | 1 + lib/librte_eal/common/include/rte_pci.h | 1 + .../common/include/rte_pci_dev_feature_defs.h | 46 +++++++++++++++++++++ .../common/include/rte_pci_dev_features.h | 44 ++++++++++++++++++++ lib/librte_eal/linuxapp/igb_uio/igb_uio.c | 48 +++++++++------------- 5 files changed, 112 insertions(+), 28 deletions(-) create mode 100644 lib/librte_eal/common/include/rte_pci_dev_feature_defs.h create mode 100644 lib/librte_eal/common/include/rte_pci_dev_features.h diff --git a/lib/librte_eal/common/Makefile b/lib/librte_eal/common/Makefile index 915cef1..7f27966 100644 --- a/lib/librte_eal/common/Makefile +++ b/lib/librte_eal/common/Makefile @@ -40,6 +40,7 @@ INC += rte_string_fns.h rte_cpuflags.h rte_version.h rte_tailq_elem.h INC += rte_eal_memconfig.h rte_malloc_heap.h INC += rte_hexdump.h rte_devargs.h rte_dev.h INC += rte_common_vect.h +INC += rte_pci_dev_feature_defs.h rte_pci_dev_features.h ifeq ($(CONFIG_RTE_INSECURE_FUNCTION_WARNING),y) INC += rte_warnings.h diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h index 3857584..3608ee0 100644 --- a/lib/librte_eal/common/include/rte_pci.h +++ b/lib/librte_eal/common/include/rte_pci.h @@ -80,6 +80,7 @@ extern "C" { #include #include #include + #include TAILQ_HEAD(pci_device_list, rte_pci_device); /**< PCI devices in D-linked Q. */ diff --git a/lib/librte_eal/common/include/rte_pci_dev_feature_defs.h b/lib/librte_eal/common/include/rte_pci_dev_feature_defs.h new file mode 100644 index 0000000..82f2c00 --- /dev/null +++ b/lib/librte_eal/common/include/rte_pci_dev_feature_defs.h @@ -0,0 +1,46 @@ +/*- + * BSD LICENSE + * + * Copyright(c) 2010-2014 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _RTE_PCI_DEV_DEFS_H_ +#define _RTE_PCI_DEV_DEFS_H_ + +/* interrupt mode */ +enum rte_intr_mode { + RTE_INTR_MODE_NONE = 0, + RTE_INTR_MODE_LEGACY, + RTE_INTR_MODE_MSI, + RTE_INTR_MODE_MSIX, + RTE_INTR_MODE_MAX +}; + +#endif /* _RTE_PCI_DEV_DEFS_H_ */ diff --git a/lib/librte_eal/common/include/rte_pci_dev_features.h b/lib/librte_eal/common/include/rte_pci_dev_features.h new file mode 100644 index 0000000..01200de --- /dev/null +++ b/lib/librte_eal/common/include/rte_pci_dev_features.h @@ -0,0 +1,44 @@ +/*- + * BSD LICENSE + * + * Copyright(c) 2010-2014 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _RTE_PCI_DEV_FEATURES_H +#define _RTE_PCI_DEV_FEATURES_H + +#include + +#define RTE_INTR_MODE_NONE_NAME "none" +#define RTE_INTR_MODE_LEGACY_NAME "legacy" +#define RTE_INTR_MODE_MSI_NAME "msi" +#define RTE_INTR_MODE_MSIX_NAME "msix" + +#endif diff --git a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c index 6fa7396..8e467a2 100644 --- a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c +++ b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c @@ -33,6 +33,7 @@ #ifdef CONFIG_XEN_DOM0 #include #endif +#include /** * MSI-X related macros, copy from linux/pci_regs.h in kernel 2.6.39, @@ -49,14 +50,6 @@ #define IGBUIO_NUM_MSI_VECTORS 1 -/* interrupt mode */ -enum igbuio_intr_mode { - IGBUIO_LEGACY_INTR_MODE = 0, - IGBUIO_MSI_INTR_MODE, - IGBUIO_MSIX_INTR_MODE, - IGBUIO_INTR_MODE_MAX -}; - /** * A structure describing the private information for a uio device. */ @@ -64,13 +57,13 @@ struct rte_uio_pci_dev { struct uio_info info; struct pci_dev *pdev; spinlock_t lock; /* spinlock for accessing PCI config space or msix data in multi tasks/isr */ - enum igbuio_intr_mode mode; + enum rte_intr_mode mode; struct msix_entry \ msix_entries[IGBUIO_NUM_MSI_VECTORS]; /* pointer to the msix vectors to be allocated later */ }; static char *intr_mode = NULL; -static enum igbuio_intr_mode igbuio_intr_mode_preferred = IGBUIO_MSIX_INTR_MODE; +static enum rte_intr_mode igbuio_intr_mode_preferred = RTE_INTR_MODE_MSIX; /* PCI device id table */ static struct pci_device_id igbuio_pci_ids[] = { @@ -222,14 +215,13 @@ igbuio_set_interrupt_mask(struct rte_uio_pci_dev *udev, int32_t state) { struct pci_dev *pdev = udev->pdev; - if (udev->mode == IGBUIO_MSIX_INTR_MODE) { + if (udev->mode == RTE_INTR_MODE_MSIX) { struct msi_desc *desc; list_for_each_entry(desc, &pdev->msi_list, list) { igbuio_msix_mask_irq(desc, state); } - } - else if (udev->mode == IGBUIO_LEGACY_INTR_MODE) { + } else if (udev->mode == RTE_INTR_MODE_LEGACY) { uint32_t status; uint16_t old, new; @@ -301,7 +293,7 @@ igbuio_pci_irqhandler(int irq, struct uio_info *info) goto spin_unlock; /* for legacy mode, interrupt maybe shared */ - if (udev->mode == IGBUIO_LEGACY_INTR_MODE) { + if (udev->mode == RTE_INTR_MODE_LEGACY) { pci_read_config_dword(pdev, PCI_COMMAND, &cmd_status_dword); status = cmd_status_dword >> 16; /* interrupt is not ours, goes to out */ @@ -520,18 +512,18 @@ igbuio_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) #endif udev->info.priv = udev; udev->pdev = dev; - udev->mode = 0; /* set the default value for interrupt mode */ + udev->mode = RTE_INTR_MODE_LEGACY; spin_lock_init(&udev->lock); /* check if it need to try msix first */ - if (igbuio_intr_mode_preferred == IGBUIO_MSIX_INTR_MODE) { + if (igbuio_intr_mode_preferred == RTE_INTR_MODE_MSIX) { int vector; for (vector = 0; vector < IGBUIO_NUM_MSI_VECTORS; vector ++) udev->msix_entries[vector].entry = vector; if (pci_enable_msix(udev->pdev, udev->msix_entries, IGBUIO_NUM_MSI_VECTORS) == 0) { - udev->mode = IGBUIO_MSIX_INTR_MODE; + udev->mode = RTE_INTR_MODE_MSIX; } else { pci_disable_msix(udev->pdev); @@ -539,13 +531,13 @@ igbuio_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) } } switch (udev->mode) { - case IGBUIO_MSIX_INTR_MODE: + case RTE_INTR_MODE_MSIX: udev->info.irq_flags = 0; udev->info.irq = udev->msix_entries[0].vector; break; - case IGBUIO_MSI_INTR_MODE: + case RTE_INTR_MODE_MSI: break; - case IGBUIO_LEGACY_INTR_MODE: + case RTE_INTR_MODE_LEGACY: udev->info.irq_flags = IRQF_SHARED; udev->info.irq = dev->irq; break; @@ -570,7 +562,7 @@ igbuio_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) fail_release_iomem: sysfs_remove_group(&dev->dev.kobj, &dev_attr_grp); igbuio_pci_release_iomem(&udev->info); - if (udev->mode == IGBUIO_MSIX_INTR_MODE) + if (udev->mode == RTE_INTR_MODE_MSIX) pci_disable_msix(udev->pdev); pci_release_regions(dev); fail_disable: @@ -595,7 +587,7 @@ igbuio_pci_remove(struct pci_dev *dev) uio_unregister_device(info); igbuio_pci_release_iomem(info); if (((struct rte_uio_pci_dev *)info->priv)->mode == - IGBUIO_MSIX_INTR_MODE) + RTE_INTR_MODE_MSIX) pci_disable_msix(dev); pci_release_regions(dev); pci_disable_device(dev); @@ -611,11 +603,11 @@ igbuio_config_intr_mode(char *intr_str) return 0; } - if (!strcmp(intr_str, "msix")) { - igbuio_intr_mode_preferred = IGBUIO_MSIX_INTR_MODE; + if (!strcmp(intr_str, RTE_INTR_MODE_MSIX_NAME)) { + igbuio_intr_mode_preferred = RTE_INTR_MODE_MSIX; printk(KERN_INFO "Use MSIX interrupt\n"); - } else if (!strcmp(intr_str, "legacy")) { - igbuio_intr_mode_preferred = IGBUIO_LEGACY_INTR_MODE; + } else if (!strcmp(intr_str, RTE_INTR_MODE_LEGACY_NAME)) { + igbuio_intr_mode_preferred = RTE_INTR_MODE_LEGACY; printk(KERN_INFO "Use legacy interrupt\n"); } else { printk(KERN_INFO "Error: bad parameter - %s\n", intr_str); @@ -656,8 +648,8 @@ module_exit(igbuio_pci_exit_module); module_param(intr_mode, charp, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(intr_mode, "igb_uio interrupt mode (default=msix):\n" -" msix Use MSIX interrupt\n" -" legacy Use Legacy interrupt\n" +" " RTE_INTR_MODE_MSIX_NAME " Use MSIX interrupt\n" +" " RTE_INTR_MODE_LEGACY_NAME " Use Legacy interrupt\n" "\n"); MODULE_DESCRIPTION("UIO driver for Intel IGB PCI cards"); -- 1.8.1.4