From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pd0-f173.google.com (mail-pd0-f173.google.com [209.85.192.173]) by dpdk.org (Postfix) with ESMTP id D2B665A6D for ; Fri, 10 Jul 2015 01:26:19 +0200 (CEST) Received: by pdrg1 with SMTP id g1so41190470pdr.2 for ; Thu, 09 Jul 2015 16:26:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=IS0tQbUlqMbnSQM2z9ggii+gULu9pgVHTOZmjAGEfXw=; b=QtgyBC5ry2W1EE/7lyqQP/sK7x/+TXLjTEOv6TriEgCTWPSvFZVwy3VuvxXcKvnmLK oWqevws1oaNB5adT7lyhmm+eNjo4n924R+JKWcdwL+2AZ40eQoH5+uVjuygsqb2UwWcY prDc+U7fh+55+d6hJXCRfQb6ttrLPVLl5UEKyROOTxiPoXsNLcoLUWCToeOGXydnpk3e 38/1BvJ070B0XP3MV+LckmPfWbGB9lVNzqFyUj3XX3zibMnC2VCr0Husdy3nmAehwqyu w3lyG9kyDP9IeXO4hecDJczE9TXiL8qTLNfwA/rDCTF5pzDxAxx1iMoxuimj6IJa6mcn auUQ== X-Gm-Message-State: ALoCoQknmJL4WtdmydfapTvglaOLMZUEXuX9mYg9kdDw9zerfonQeml5jMhmsPhX+xiCEuJQpCDz X-Received: by 10.70.52.1 with SMTP id p1mr35263130pdo.113.1436484379118; Thu, 09 Jul 2015 16:26:19 -0700 (PDT) Received: from urahara.home.lan (static-50-53-82-155.bvtn.or.frontiernet.net. [50.53.82.155]) by smtp.gmail.com with ESMTPSA id ky17sm583659pab.31.2015.07.09.16.26.18 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 09 Jul 2015 16:26:18 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Date: Thu, 9 Jul 2015 16:26:26 -0700 Message-Id: <1436484387-29273-2-git-send-email-stephen@networkplumber.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1436484387-29273-1-git-send-email-stephen@networkplumber.org> References: <1436484387-29273-1-git-send-email-stephen@networkplumber.org> Cc: Stephen Hemminger Subject: [dpdk-dev] [PATCH v2 1/2] vfio: fix build if build envrionment is on old kernel 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: Thu, 09 Jul 2015 23:26:20 -0000 From: Stephen Hemminger The build of DPDK may be done on a system where Linux headers in /usr/include (and therefore kernel version macro) are much older than the target runtime system. In order to work around this, one solution is to put in simplified kernel header (this is what the compat stuff is already doing). The application will still have to check at runtime that VFIO is present, but that is manageable. Signed-off-by: Stephen Hemminger --- lib/librte_eal/linuxapp/eal/compat_vfio.h | 181 ++++++++++++++++++++++++++++++ lib/librte_eal/linuxapp/eal/eal_vfio.h | 13 ++- 2 files changed, 188 insertions(+), 6 deletions(-) create mode 100644 lib/librte_eal/linuxapp/eal/compat_vfio.h diff --git a/lib/librte_eal/linuxapp/eal/compat_vfio.h b/lib/librte_eal/linuxapp/eal/compat_vfio.h new file mode 100644 index 0000000..c0a82c7 --- /dev/null +++ b/lib/librte_eal/linuxapp/eal/compat_vfio.h @@ -0,0 +1,181 @@ +#ifndef VFIO_H +#define VFIO_H +/* This is a santized version of the kernel header for vfio. + * It is included to allow build DPDK with VFIO when build system + * kernel version is older than runtime system kernel version. + */ + +#include +#include +#define VFIO_API_VERSION 0 +#define VFIO_TYPE1_IOMMU 1 +#define VFIO_SPAPR_TCE_IOMMU 2 +#define VFIO_TYPE1v2_IOMMU 3 +#define VFIO_DMA_CC_IOMMU 4 +#define VFIO_EEH 5 +#define VFIO_TYPE1_NESTING_IOMMU 6 +#define VFIO_TYPE (';') +#define VFIO_BASE 100 +#define VFIO_GET_API_VERSION _IO(VFIO_TYPE, VFIO_BASE + 0) +#define VFIO_CHECK_EXTENSION _IO(VFIO_TYPE, VFIO_BASE + 1) +#define VFIO_SET_IOMMU _IO(VFIO_TYPE, VFIO_BASE + 2) +struct vfio_group_status { + __u32 argsz; + __u32 flags; +#define VFIO_GROUP_FLAGS_VIABLE (1 << 0) +#define VFIO_GROUP_FLAGS_CONTAINER_SET (1 << 1) +}; +#define VFIO_GROUP_GET_STATUS _IO(VFIO_TYPE, VFIO_BASE + 3) +#define VFIO_GROUP_SET_CONTAINER _IO(VFIO_TYPE, VFIO_BASE + 4) +#define VFIO_GROUP_UNSET_CONTAINER _IO(VFIO_TYPE, VFIO_BASE + 5) +#define VFIO_GROUP_GET_DEVICE_FD _IO(VFIO_TYPE, VFIO_BASE + 6) +struct vfio_device_info { + __u32 argsz; + __u32 flags; +#define VFIO_DEVICE_FLAGS_RESET (1 << 0) +#define VFIO_DEVICE_FLAGS_PCI (1 << 1) +#define VFIO_DEVICE_FLAGS_PLATFORM (1 << 2) +#define VFIO_DEVICE_FLAGS_AMBA (1 << 3) + __u32 num_regions; + __u32 num_irqs; +}; +#define VFIO_DEVICE_GET_INFO _IO(VFIO_TYPE, VFIO_BASE + 7) +struct vfio_region_info { + __u32 argsz; + __u32 flags; +#define VFIO_REGION_INFO_FLAG_READ (1 << 0) +#define VFIO_REGION_INFO_FLAG_WRITE (1 << 1) +#define VFIO_REGION_INFO_FLAG_MMAP (1 << 2) + __u32 index; + __u32 resv; + __u64 size; + __u64 offset; +}; +#define VFIO_DEVICE_GET_REGION_INFO _IO(VFIO_TYPE, VFIO_BASE + 8) +struct vfio_irq_info { + __u32 argsz; + __u32 flags; +#define VFIO_IRQ_INFO_EVENTFD (1 << 0) +#define VFIO_IRQ_INFO_MASKABLE (1 << 1) +#define VFIO_IRQ_INFO_AUTOMASKED (1 << 2) +#define VFIO_IRQ_INFO_NORESIZE (1 << 3) + __u32 index; + __u32 count; +}; +#define VFIO_DEVICE_GET_IRQ_INFO _IO(VFIO_TYPE, VFIO_BASE + 9) +struct vfio_irq_set { + __u32 argsz; + __u32 flags; +#define VFIO_IRQ_SET_DATA_NONE (1 << 0) +#define VFIO_IRQ_SET_DATA_BOOL (1 << 1) +#define VFIO_IRQ_SET_DATA_EVENTFD (1 << 2) +#define VFIO_IRQ_SET_ACTION_MASK (1 << 3) +#define VFIO_IRQ_SET_ACTION_UNMASK (1 << 4) +#define VFIO_IRQ_SET_ACTION_TRIGGER (1 << 5) + __u32 index; + __u32 start; + __u32 count; + __u8 data[]; +}; +#define VFIO_DEVICE_SET_IRQS _IO(VFIO_TYPE, VFIO_BASE + 10) +#define VFIO_IRQ_SET_DATA_TYPE_MASK (VFIO_IRQ_SET_DATA_NONE | \ + VFIO_IRQ_SET_DATA_BOOL | \ + VFIO_IRQ_SET_DATA_EVENTFD) +#define VFIO_IRQ_SET_ACTION_TYPE_MASK (VFIO_IRQ_SET_ACTION_MASK | \ + VFIO_IRQ_SET_ACTION_UNMASK | \ + VFIO_IRQ_SET_ACTION_TRIGGER) +#define VFIO_DEVICE_RESET _IO(VFIO_TYPE, VFIO_BASE + 11) +enum { + VFIO_PCI_BAR0_REGION_INDEX, + VFIO_PCI_BAR1_REGION_INDEX, + VFIO_PCI_BAR2_REGION_INDEX, + VFIO_PCI_BAR3_REGION_INDEX, + VFIO_PCI_BAR4_REGION_INDEX, + VFIO_PCI_BAR5_REGION_INDEX, + VFIO_PCI_ROM_REGION_INDEX, + VFIO_PCI_CONFIG_REGION_INDEX, + VFIO_PCI_VGA_REGION_INDEX, + VFIO_PCI_NUM_REGIONS +}; +enum { + VFIO_PCI_INTX_IRQ_INDEX, + VFIO_PCI_MSI_IRQ_INDEX, + VFIO_PCI_MSIX_IRQ_INDEX, + VFIO_PCI_ERR_IRQ_INDEX, + VFIO_PCI_REQ_IRQ_INDEX, + VFIO_PCI_NUM_IRQS +}; +struct vfio_pci_dependent_device { + __u32 group_id; + __u16 segment; + __u8 bus; + __u8 devfn; +}; +struct vfio_pci_hot_reset_info { + __u32 argsz; + __u32 flags; + __u32 count; + struct vfio_pci_dependent_device devices[]; +}; +#define VFIO_DEVICE_GET_PCI_HOT_RESET_INFO _IO(VFIO_TYPE, VFIO_BASE + 12) +struct vfio_pci_hot_reset { + __u32 argsz; + __u32 flags; + __u32 count; + __s32 group_fds[]; +}; +#define VFIO_DEVICE_PCI_HOT_RESET _IO(VFIO_TYPE, VFIO_BASE + 13) +struct vfio_iommu_type1_info { + __u32 argsz; + __u32 flags; +#define VFIO_IOMMU_INFO_PGSIZES (1 << 0) + __u64 iova_pgsizes; +}; +#define VFIO_IOMMU_GET_INFO _IO(VFIO_TYPE, VFIO_BASE + 12) +struct vfio_iommu_type1_dma_map { + __u32 argsz; + __u32 flags; +#define VFIO_DMA_MAP_FLAG_READ (1 << 0) +#define VFIO_DMA_MAP_FLAG_WRITE (1 << 1) + __u64 vaddr; + __u64 iova; + __u64 size; +}; +#define VFIO_IOMMU_MAP_DMA _IO(VFIO_TYPE, VFIO_BASE + 13) +struct vfio_iommu_type1_dma_unmap { + __u32 argsz; + __u32 flags; + __u64 iova; + __u64 size; +}; +#define VFIO_IOMMU_UNMAP_DMA _IO(VFIO_TYPE, VFIO_BASE + 14) +#define VFIO_IOMMU_ENABLE _IO(VFIO_TYPE, VFIO_BASE + 15) +#define VFIO_IOMMU_DISABLE _IO(VFIO_TYPE, VFIO_BASE + 16) +struct vfio_iommu_spapr_tce_info { + __u32 argsz; + __u32 flags; + __u32 dma32_window_start; + __u32 dma32_window_size; +}; +#define VFIO_IOMMU_SPAPR_TCE_GET_INFO _IO(VFIO_TYPE, VFIO_BASE + 12) +struct vfio_eeh_pe_op { + __u32 argsz; + __u32 flags; + __u32 op; +}; +#define VFIO_EEH_PE_DISABLE 0 +#define VFIO_EEH_PE_ENABLE 1 +#define VFIO_EEH_PE_UNFREEZE_IO 2 +#define VFIO_EEH_PE_UNFREEZE_DMA 3 +#define VFIO_EEH_PE_GET_STATE 4 +#define VFIO_EEH_PE_STATE_NORMAL 0 +#define VFIO_EEH_PE_STATE_RESET 1 +#define VFIO_EEH_PE_STATE_STOPPED 2 +#define VFIO_EEH_PE_STATE_STOPPED_DMA 4 +#define VFIO_EEH_PE_STATE_UNAVAIL 5 +#define VFIO_EEH_PE_RESET_DEACTIVATE 5 +#define VFIO_EEH_PE_RESET_HOT 6 +#define VFIO_EEH_PE_RESET_FUNDAMENTAL 7 +#define VFIO_EEH_PE_CONFIGURE 8 +#define VFIO_EEH_PE_OP _IO(VFIO_TYPE, VFIO_BASE + 21) +#endif diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.h b/lib/librte_eal/linuxapp/eal/eal_vfio.h index 72ec3f6..b2c89ad 100644 --- a/lib/librte_eal/linuxapp/eal/eal_vfio.h +++ b/lib/librte_eal/linuxapp/eal/eal_vfio.h @@ -34,15 +34,16 @@ #ifndef EAL_VFIO_H_ #define EAL_VFIO_H_ -/* - * determine if VFIO is present on the system - */ #ifdef RTE_EAL_VFIO #include -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0) + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0) +#include "compat_vfio.h" +#else #include +#endif /* kernel version */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 10, 0) +#ifndef PCI_MSIX_TABLE_BIR #define RTE_PCI_MSIX_TABLE_BIR 0x7 #define RTE_PCI_MSIX_TABLE_OFFSET 0xfffffff8 #define RTE_PCI_MSIX_FLAGS_QSIZE 0x07ff @@ -53,7 +54,7 @@ #endif #define VFIO_PRESENT -#endif /* kernel version */ + #endif /* RTE_EAL_VFIO */ #endif /* EAL_VFIO_H_ */ -- 2.1.4