From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-we0-f177.google.com (mail-we0-f177.google.com [74.125.82.177]) by dpdk.org (Postfix) with ESMTP id 2C6751F3 for ; Mon, 16 Sep 2013 22:28:25 +0200 (CEST) Received: by mail-we0-f177.google.com with SMTP id t60so4165399wes.22 for ; Mon, 16 Sep 2013 13:29:03 -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:subject:date:message-id; bh=aaRdbsQVgh7K5YvWenRWGGaOU6lWO6tAHrL8O5AdB8s=; b=dGBd/PxwUPr6mPFabU4fxK+p0voRJiYZiWMomRHu4O7bte8SjVBJvvmc4gx6SuSUAM 7vxbsc2u5YqJL5dZG0+yxjDDhCXaKl6J/2PhVItbsWge6+DP19JFHbzGNCc69GPKLw7n g0QjXhrOIKkIgYX/y4tqJCJZo4szOj9H7eqZ1z5PlP+tcmYTOwyrrKKQNTXk8SL44/ra 1hB2tHtKMSVBumnNjZksCCER7h8SpIANcKfEe4TZsIRCFt++cPVBT2t1n/eX7IyFAuK1 u+mDd0nOBMbcc5viRGBDA5cCpL47QP82yPBNgt8oitpypYA8rr1kc74d2Z+tT42DDo2Y SD4w== X-Gm-Message-State: ALoCoQld+HK9pN4Xj8XSurmWeG7nVE3zMr6+PxVpuRSTGKHySaONiHhwLa4AAyNJnA+8dyINt0gU X-Received: by 10.194.80.39 with SMTP id o7mr3720128wjx.39.1379363343019; Mon, 16 Sep 2013 13:29:03 -0700 (PDT) Received: from 6wind.com (guy78-3-82-239-227-177.fbx.proxad.net. [82.239.227.177]) by mx.google.com with ESMTPSA id q5sm26184376wiz.3.1969.12.31.16.00.00 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 16 Sep 2013 13:29:02 -0700 (PDT) Received: by 6wind.com (sSMTP sendmail emulation); Mon, 16 Sep 2013 22:29:00 +0200 From: Thomas Monjalon To: dev@dpdk.org Date: Mon, 16 Sep 2013 22:29:00 +0200 Message-Id: <1379363340-20870-1-git-send-email-thomas.monjalon@6wind.com> X-Mailer: git-send-email 1.7.10.4 Subject: [dpdk-dev] [PATCH] pci: fix non-Intel devices probing 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: Mon, 16 Sep 2013 20:28:25 -0000 From: David Marchand There is no need to check for bars mapping, especially BAR0 is not required. If bars mapping failed, then pci_uio_map_resource will fail and we won't reach this check. So get rid of BAR0 check. Besides, pci_uio_map_resource should only be called for Intel devices. The flag RTE_PCI_DRV_NEED_IGB_UIO is set for all Intel devices, even when RTE_EAL_UNBIND_PORTS is disabled. Signed-off-by: David Marchand Signed-off-by: Thomas Monjalon --- app/test/test_pci.c | 2 -- lib/librte_eal/common/include/rte_pci.h | 2 -- lib/librte_eal/linuxapp/eal/eal_pci.c | 30 +++++++----------------------- lib/librte_pmd_e1000/em_ethdev.c | 2 -- lib/librte_pmd_e1000/igb_ethdev.c | 4 ---- lib/librte_pmd_ixgbe/ixgbe_ethdev.c | 4 ---- 6 files changed, 7 insertions(+), 37 deletions(-) diff --git a/app/test/test_pci.c b/app/test/test_pci.c index 30d3c9f..55f603d 100644 --- a/app/test/test_pci.c +++ b/app/test/test_pci.c @@ -95,9 +95,7 @@ struct rte_pci_driver my_driver = { .name = "test_driver", .devinit = my_driver_init, .id_table = my_driver_id, -#ifdef RTE_EAL_UNBIND_PORTS .drv_flags = RTE_PCI_DRV_NEED_IGB_UIO, -#endif }; struct rte_pci_driver my_driver2 = { diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h index c3ff5b9..affaae0 100644 --- a/lib/librte_eal/common/include/rte_pci.h +++ b/lib/librte_eal/common/include/rte_pci.h @@ -184,10 +184,8 @@ struct rte_pci_driver { uint32_t drv_flags; /**< Flags contolling handling of device. */ }; -#ifdef RTE_EAL_UNBIND_PORTS /** Device needs igb_uio kernel module */ #define RTE_PCI_DRV_NEED_IGB_UIO 0x0001 -#endif /** Device driver must be registered several times until failure */ #define RTE_PCI_DRV_MULTIPLE 0x0002 /** Device needs to be unbound even if no module is provided */ diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c index eeb6cd7..998d5ba 100644 --- a/lib/librte_eal/linuxapp/eal/eal_pci.c +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c @@ -913,13 +913,6 @@ int rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *dev) { struct rte_pci_id *id_table; -#ifdef RTE_EAL_UNBIND_PORTS - const char *module_name = NULL; - int uio_status = -1; - - if (dr->drv_flags & RTE_PCI_DRV_NEED_IGB_UIO) - module_name = IGB_UIO_NAME; -#endif for (id_table = dr->id_table ; id_table->vendor_id != 0; id_table++) { @@ -953,10 +946,10 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *d } #ifdef RTE_EAL_UNBIND_PORTS - /* Unbind PCI devices if needed */ - if (module_name != NULL) + /* Unbind Intel devices and load uio ressources */ + if (dr->drv_flags & RTE_PCI_DRV_NEED_IGB_UIO) { - if (pci_switch_module(dr, dev, uio_status, module_name) < 0) + if (pci_switch_module(dr, dev, 1, IGB_UIO_NAME) < 0) return -1; } else if (dr->drv_flags & RTE_PCI_DRV_FORCE_UNBIND && @@ -966,21 +959,12 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *d return -1; } #else - /* just map the NIC resources */ - if (pci_uio_map_resource(dev) < 0) - return -1; + /* just map the NIC resources for Intel devices */ + if (dr->drv_flags & RTE_PCI_DRV_NEED_IGB_UIO) + if (pci_uio_map_resource(dev) < 0) + return -1; #endif - /* We always should have BAR0 mapped */ - if (!(dr->drv_flags & RTE_PCI_DRV_FORCE_UNBIND) && - (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); - } - /* reference driver structure */ dev->driver = dr; diff --git a/lib/librte_pmd_e1000/em_ethdev.c b/lib/librte_pmd_e1000/em_ethdev.c index fc63557..4fccc1d 100644 --- a/lib/librte_pmd_e1000/em_ethdev.c +++ b/lib/librte_pmd_e1000/em_ethdev.c @@ -280,9 +280,7 @@ static struct eth_driver rte_em_pmd = { { .name = "rte_em_pmd", .id_table = pci_id_em_map, -#ifdef RTE_EAL_UNBIND_PORTS .drv_flags = RTE_PCI_DRV_NEED_IGB_UIO, -#endif }, .eth_dev_init = eth_em_dev_init, .dev_private_size = sizeof(struct e1000_adapter), diff --git a/lib/librte_pmd_e1000/igb_ethdev.c b/lib/librte_pmd_e1000/igb_ethdev.c index 85835f7..c4cdae9 100644 --- a/lib/librte_pmd_e1000/igb_ethdev.c +++ b/lib/librte_pmd_e1000/igb_ethdev.c @@ -522,9 +522,7 @@ static struct eth_driver rte_igb_pmd = { { .name = "rte_igb_pmd", .id_table = pci_id_igb_map, -#ifdef RTE_EAL_UNBIND_PORTS .drv_flags = RTE_PCI_DRV_NEED_IGB_UIO, -#endif }, .eth_dev_init = eth_igb_dev_init, .dev_private_size = sizeof(struct e1000_adapter), @@ -537,9 +535,7 @@ static struct eth_driver rte_igbvf_pmd = { { .name = "rte_igbvf_pmd", .id_table = pci_id_igbvf_map, -#ifdef RTE_EAL_UNBIND_PORTS .drv_flags = RTE_PCI_DRV_NEED_IGB_UIO, -#endif }, .eth_dev_init = eth_igbvf_dev_init, .dev_private_size = sizeof(struct e1000_adapter), diff --git a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c index 516fed4..9235f9d 100644 --- a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c +++ b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c @@ -807,9 +807,7 @@ static struct eth_driver rte_ixgbe_pmd = { { .name = "rte_ixgbe_pmd", .id_table = pci_id_ixgbe_map, -#ifdef RTE_EAL_UNBIND_PORTS .drv_flags = RTE_PCI_DRV_NEED_IGB_UIO, -#endif }, .eth_dev_init = eth_ixgbe_dev_init, .dev_private_size = sizeof(struct ixgbe_adapter), @@ -822,9 +820,7 @@ static struct eth_driver rte_ixgbevf_pmd = { { .name = "rte_ixgbevf_pmd", .id_table = pci_id_ixgbevf_map, -#ifdef RTE_EAL_UNBIND_PORTS .drv_flags = RTE_PCI_DRV_NEED_IGB_UIO, -#endif }, .eth_dev_init = eth_ixgbevf_dev_init, .dev_private_size = sizeof(struct ixgbe_adapter), -- 1.7.10.4