From: Anatoly Burakov <anatoly.burakov@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v3 2/2] vfio: more verbose error messages
Date: Wed, 18 Jun 2014 16:07:17 +0100 [thread overview]
Message-ID: <1e8d108af6424e9e9666329b8cecc90918b3b90b.1403104031.git.anatoly.burakov@intel.com> (raw)
In-Reply-To: <cover.1403096022.git.anatoly.burakov@intel.com>
In-Reply-To: <cover.1403104031.git.anatoly.burakov@intel.com>
also, making VFIO code distinguish between actual unexpected values
and ioctl() failures, providing appropriate error messages.
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
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
next prev parent reply other threads:[~2014-06-18 15:07 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-17 9:12 [dpdk-dev] [PATCH] vfio: open VFIO container at startup rather than during init Anatoly Burakov
2014-06-17 16:50 ` Richardson, Bruce
2014-06-17 16:55 ` Thomas Monjalon
2014-06-18 8:57 ` Burakov, Anatoly
2014-06-18 10:08 ` Dumitrescu, Cristian
2014-06-18 10:26 ` Burakov, Anatoly
2014-06-18 11:00 ` Neil Horman
2014-06-18 11:02 ` Burakov, Anatoly
2014-06-18 11:07 ` Neil Horman
2014-06-18 13:07 ` [dpdk-dev] [PATCH v2 0/2] Fix issues with VFIO Anatoly Burakov
2014-06-18 13:07 ` [dpdk-dev] [PATCH v2 1/2] vfio: open VFIO container at startup rather than during init Anatoly Burakov
2014-06-18 13:07 ` [dpdk-dev] [PATCH v2 2/2] vfio: more verbose error messages Anatoly Burakov
2014-06-18 13:44 ` [dpdk-dev] [PATCH v2 0/2] Fix issues with VFIO Neil Horman
2014-06-18 15:07 ` [dpdk-dev] [PATCH v3 " Anatoly Burakov
2014-06-18 15:07 ` [dpdk-dev] [PATCH v3 1/2] vfio: open VFIO container at startup rather than during init Anatoly Burakov
2014-06-18 15:07 ` Anatoly Burakov [this message]
2014-06-18 17:55 ` [dpdk-dev] [PATCH v3 0/2] Fix issues with VFIO Richardson, Bruce
2014-06-18 23:09 ` Thomas Monjalon
2014-06-18 18:51 ` Neil Horman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1e8d108af6424e9e9666329b8cecc90918b3b90b.1403104031.git.anatoly.burakov@intel.com \
--to=anatoly.burakov@intel.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).