From 8e5f9df258e5f149a31847fab08a334541f7331a Mon Sep 17 00:00:00 2001 From: David Marchand Date: Fri, 9 May 2014 15:15:54 +0200 Subject: [PATCH] pci: align bsd implementation on linux bsd implementation lacks check on driver flags, fix this. Besides, check on BAR0 is not needed and could cause trouble for devices that have no BAR0. Signed-off-by: David Marchand Acked-by: Anatoly Burakov Acked-by: Neil Horman --- lib/librte_eal/bsdapp/eal/eal_pci.c | 42 ++++++++++++++++------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c b/lib/librte_eal/bsdapp/eal/eal_pci.c index 987b44687c..5d8bcbd3d3 100644 --- a/lib/librte_eal/bsdapp/eal/eal_pci.c +++ b/lib/librte_eal/bsdapp/eal/eal_pci.c @@ -108,8 +108,14 @@ TAILQ_HEAD(uio_res_list, uio_resource); static struct uio_res_list *uio_res_list = NULL; -/* forward prototype of function called in pci_switch_module below */ -static int pci_uio_map_resource(struct rte_pci_device *dev); +/* unbind kernel driver for this device */ +static int +pci_unbind_kernel_driver(struct rte_pci_device *dev) +{ + RTE_LOG(ERR, EAL, "RTE_PCI_DRV_FORCE_UNBIND flag is not implemented " + "for BSD\n"); + return -ENOTSUP; +} /* map a particular resource from a file */ static void * @@ -214,6 +220,11 @@ pci_uio_map_resource(struct rte_pci_device *dev) dev->intr_handle.fd = -1; + /* secondary processes - use already recorded details */ + if ((rte_eal_process_type() != RTE_PROC_PRIMARY) && + (dev->id.vendor_id != PCI_VENDOR_ID_QUMRANET)) + return (pci_uio_map_secondary(dev)); + rte_snprintf(devname, sizeof(devname), "/dev/uio@pci:%u:%u:%u", dev->addr.bus, dev->addr.devid, dev->addr.function); @@ -223,11 +234,6 @@ pci_uio_map_resource(struct rte_pci_device *dev) return -1; } - /* secondary processes - use already recorded details */ - if ((rte_eal_process_type() != RTE_PROC_PRIMARY) && - (dev->id.vendor_id != PCI_VENDOR_ID_QUMRANET)) - return (pci_uio_map_secondary(dev)); - if(dev->id.vendor_id == PCI_VENDOR_ID_QUMRANET) { /* I/O port address already assigned */ /* rte_virtio_pmd does not need any other bar even if available */ @@ -479,19 +485,17 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *d return 0; } - /* just map the NIC resources */ - if (pci_uio_map_resource(dev) < 0) - return -1; - - /* We always should have BAR0 mapped */ - if (rte_eal_process_type() == RTE_PROC_PRIMARY && - dev->mem_resource[0].addr == NULL) { - RTE_LOG(ERR, EAL, - "%s(): BAR0 is not mapped\n", - __func__); - return (-1); + if (dr->drv_flags & RTE_PCI_DRV_NEED_IGB_UIO) { + /* map resources for devices that use igb_uio */ + if (pci_uio_map_resource(dev) < 0) + return -1; + } else if (dr->drv_flags & RTE_PCI_DRV_FORCE_UNBIND && + rte_eal_process_type() == RTE_PROC_PRIMARY) { + /* unbind current driver */ + if (pci_unbind_kernel_driver(dev) < 0) + return -1; } - + /* reference driver structure */ dev->driver = dr; -- 2.20.1