From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 5A8C2B147 for ; Wed, 18 Jun 2014 17:07:11 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 18 Jun 2014 08:07:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,501,1400050800"; d="scan'208";a="559605006" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga002.jf.intel.com with ESMTP; 18 Jun 2014 08:07:19 -0700 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id s5IF7IYC001850; Wed, 18 Jun 2014 16:07:18 +0100 Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id s5IF7IxH030501; Wed, 18 Jun 2014 16:07:18 +0100 Received: (from aburakov@localhost) by sivswdev01.ir.intel.com with id s5IF7HQN030497; Wed, 18 Jun 2014 16:07:17 +0100 From: Anatoly Burakov To: dev@dpdk.org Date: Wed, 18 Jun 2014 16:07:17 +0100 Message-Id: <1e8d108af6424e9e9666329b8cecc90918b3b90b.1403104031.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v3 2/2] vfio: more verbose error messages 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: Wed, 18 Jun 2014 15:07:34 -0000 also, making VFIO code distinguish between actual unexpected values and ioctl() failures, providing appropriate error messages. Signed-off-by: Anatoly Burakov --- lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 48 ++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c index 9eb5dcd..bf765b5 100644 --- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c +++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c @@ -180,7 +180,8 @@ pci_vfio_setup_dma_maps(int vfio_container_fd) ret = ioctl(vfio_container_fd, VFIO_SET_IOMMU, VFIO_TYPE1_IOMMU); if (ret) { - RTE_LOG(ERR, EAL, " cannot set IOMMU type!\n"); + RTE_LOG(ERR, EAL, " cannot set IOMMU type, " + "error %i (%s)\n", errno, strerror(errno)); return -1; } @@ -201,7 +202,8 @@ pci_vfio_setup_dma_maps(int vfio_container_fd) ret = ioctl(vfio_container_fd, VFIO_IOMMU_MAP_DMA, &dma_map); if (ret) { - RTE_LOG(ERR, EAL, " cannot set up DMA remapping!\n"); + RTE_LOG(ERR, EAL, " cannot set up DMA remapping, " + "error %i (%s)\n", errno, strerror(errno)); return -1; } } @@ -253,7 +255,8 @@ pci_vfio_setup_interrupts(struct rte_pci_device *dev, int vfio_dev_fd) ret = ioctl(vfio_dev_fd, VFIO_DEVICE_GET_IRQ_INFO, &irq); if (ret < 0) { - RTE_LOG(ERR, EAL, " cannot get IRQ info!\n"); + RTE_LOG(ERR, EAL, " cannot get IRQ info, " + "error %i (%s)\n", errno, strerror(errno)); return -1; } @@ -271,7 +274,8 @@ pci_vfio_setup_interrupts(struct rte_pci_device *dev, int vfio_dev_fd) /* set up an eventfd for interrupts */ fd = eventfd(0, 0); if (fd < 0) { - RTE_LOG(ERR, EAL, " cannot set up eventfd!\n"); + RTE_LOG(ERR, EAL, " cannot set up eventfd, " + "error %i (%s)\n", errno, strerror(errno)); return -1; } @@ -313,22 +317,31 @@ pci_vfio_get_container_fd(void) if (internal_config.process_type == RTE_PROC_PRIMARY) { vfio_container_fd = open(VFIO_CONTAINER_PATH, O_RDWR); if (vfio_container_fd < 0) { - RTE_LOG(ERR, EAL, " cannot open VFIO container!\n"); + RTE_LOG(ERR, EAL, " cannot open VFIO container, " + "error %i (%s)\n", errno, strerror(errno)); return -1; } /* check VFIO API version */ ret = ioctl(vfio_container_fd, VFIO_GET_API_VERSION); if (ret != VFIO_API_VERSION) { - RTE_LOG(ERR, EAL, " unknown VFIO API version!\n"); + if (ret < 0) + RTE_LOG(ERR, EAL, " could not get VFIO API version, " + "error %i (%s)\n", errno, strerror(errno)); + else + RTE_LOG(ERR, EAL, " unsupported VFIO API version!\n"); close(vfio_container_fd); return -1; } /* check if we support IOMMU type 1 */ ret = ioctl(vfio_container_fd, VFIO_CHECK_EXTENSION, VFIO_TYPE1_IOMMU); - if (!ret) { - RTE_LOG(ERR, EAL, " unknown IOMMU driver!\n"); + if (ret != 1) { + if (ret < 0) + RTE_LOG(ERR, EAL, " could not get IOMMU type, " + "error %i (%s)\n", errno, strerror(errno)); + else + RTE_LOG(ERR, EAL, " unsupported IOMMU type!\n"); close(vfio_container_fd); return -1; } @@ -564,7 +577,8 @@ pci_vfio_map_resource(struct rte_pci_device *dev) /* check if the group is viable */ ret = ioctl(vfio_group_fd, VFIO_GROUP_GET_STATUS, &group_status); if (ret) { - RTE_LOG(ERR, EAL, " %s cannot get group status!\n", pci_addr); + RTE_LOG(ERR, EAL, " %s cannot get group status, " + "error %i (%s)\n", pci_addr, errno, strerror(errno)); close(vfio_group_fd); clear_current_group(); return -1; @@ -587,8 +601,8 @@ pci_vfio_map_resource(struct rte_pci_device *dev) ret = ioctl(vfio_group_fd, VFIO_GROUP_SET_CONTAINER, &vfio_cfg.vfio_container_fd); if (ret) { - RTE_LOG(ERR, EAL, " %s cannot add VFIO group to container!\n", - pci_addr); + RTE_LOG(ERR, EAL, " %s cannot add VFIO group to container, " + "error %i (%s)\n", pci_addr, errno, strerror(errno)); close(vfio_group_fd); clear_current_group(); return -1; @@ -611,7 +625,8 @@ pci_vfio_map_resource(struct rte_pci_device *dev) vfio_cfg.vfio_container_has_dma == 0) { ret = pci_vfio_setup_dma_maps(vfio_cfg.vfio_container_fd); if (ret) { - RTE_LOG(ERR, EAL, " %s DMA remapping failed!\n", pci_addr); + RTE_LOG(ERR, EAL, " %s DMA remapping failed, " + "error %i (%s)\n", pci_addr, errno, strerror(errno)); return -1; } vfio_cfg.vfio_container_has_dma = 1; @@ -631,7 +646,8 @@ pci_vfio_map_resource(struct rte_pci_device *dev) /* test and setup the device */ ret = ioctl(vfio_dev_fd, VFIO_DEVICE_GET_INFO, &device_info); if (ret) { - RTE_LOG(ERR, EAL, " %s cannot get device info!\n", pci_addr); + RTE_LOG(ERR, EAL, " %s cannot get device info, " + "error %i (%s)\n", pci_addr, errno, strerror(errno)); close(vfio_dev_fd); return -1; } @@ -688,8 +704,8 @@ pci_vfio_map_resource(struct rte_pci_device *dev) ret = ioctl(vfio_dev_fd, VFIO_DEVICE_GET_REGION_INFO, ®); if (ret) { - RTE_LOG(ERR, EAL, " %s cannot get device region info!\n", - pci_addr); + RTE_LOG(ERR, EAL, " %s cannot get device region info " + "error %i (%s)\n", pci_addr, errno, strerror(errno)); close(vfio_dev_fd); if (internal_config.process_type == RTE_PROC_PRIMARY) rte_free(vfio_res); @@ -765,7 +781,7 @@ pci_vfio_enable(void) if (vfio_cfg.vfio_container_fd != -1) vfio_cfg.vfio_enabled = 1; else - RTE_LOG(INFO, EAL, "VFIO driver not loaded or wrong permissions\n"); + RTE_LOG(INFO, EAL, "VFIO support could not be initialized\n"); return 0; } -- 1.8.1.4