bus/pci: consider only usable devices for IOVA mode
[dpdk.git] / drivers / bus / pci / bsd / pci.c
index 40641ca..a2de709 100644 (file)
@@ -145,7 +145,7 @@ pci_uio_alloc_resource(struct rte_pci_device *dev,
                goto error;
        }
 
-       snprintf((*uio_res)->path, sizeof((*uio_res)->path), "%s", devname);
+       strlcpy((*uio_res)->path, devname, sizeof((*uio_res)->path));
        memcpy(&(*uio_res)->pci_addr, &dev->addr, sizeof((*uio_res)->pci_addr));
 
        return 0;
@@ -376,13 +376,14 @@ error:
        return -1;
 }
 
-/*
- * Get iommu class of PCI devices on the bus.
- */
 enum rte_iova_mode
-rte_pci_get_iommu_class(void)
+pci_device_iova_mode(const struct rte_pci_driver *pdrv __rte_unused,
+                    const struct rte_pci_device *pdev)
 {
        /* Supports only RTE_KDRV_NIC_UIO */
+       if (pdev->kdrv != RTE_KDRV_NIC_UIO)
+               RTE_LOG(DEBUG, EAL, "Unsupported kernel driver? Defaulting to IOVA as 'PA'\n");
+
        return RTE_IOVA_PA;
 }
 
@@ -441,6 +442,8 @@ int rte_pci_read_config(const struct rte_pci_device *dev,
 {
        int fd = -1;
        int size;
+       /* Copy Linux implementation's behaviour */
+       const int return_len = len;
        struct pci_io pi = {
                .pi_sel = {
                        .pc_domain = dev->addr.domain,
@@ -471,7 +474,7 @@ int rte_pci_read_config(const struct rte_pci_device *dev,
        }
        close(fd);
 
-       return 0;
+       return return_len;
 
  error:
        if (fd >= 0)