From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [143.182.124.21]) by dpdk.org (Postfix) with ESMTP id 2C8FDAFD5 for ; Wed, 25 Jun 2014 22:07:41 +0200 (CEST) Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga101.ch.intel.com with ESMTP; 25 Jun 2014 13:07:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,547,1400050800"; d="scan'208";a="449991975" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by azsmga001.ch.intel.com with ESMTP; 25 Jun 2014 13:07:57 -0700 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id s5PK7uCV024390; Wed, 25 Jun 2014 21:07:56 +0100 Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id s5PK7uoD008713; Wed, 25 Jun 2014 21:07:56 +0100 Received: (from dwdohert@localhost) by sivswdev02.ir.intel.com with id s5PK7uaF008709; Wed, 25 Jun 2014 21:07:56 +0100 From: Declan Doherty To: dev@dpdk.org Date: Wed, 25 Jun 2014 21:07:45 +0100 Message-Id: <1403726868-8161-4-git-send-email-declan.doherty@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1403625828-20956-1-git-send-email-declan.doherty@intel.com> References: <1403625828-20956-1-git-send-email-declan.doherty@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v8 3/6] EAL support for link bonding device initialization 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, 25 Jun 2014 20:07:43 -0000 Updating functionality in EAL to support adding link bonding devices via –vdev option. Link bonding devices will be initialized after all physical devices have been probed and initialized. Signed-off-by: Declan Doherty --- lib/librte_eal/bsdapp/eal/eal.c | 10 ++++- lib/librte_eal/common/eal_common_dev.c | 58 ++++++++++++++++++-------- lib/librte_eal/common/eal_common_pci.c | 3 + lib/librte_eal/common/include/eal_private.h | 7 --- lib/librte_eal/common/include/rte_dev.h | 13 +++++- lib/librte_eal/linuxapp/eal/eal.c | 11 +++++- 6 files changed, 73 insertions(+), 29 deletions(-) diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c index a1f014f..c53f63e 100644 --- a/lib/librte_eal/bsdapp/eal/eal.c +++ b/lib/librte_eal/bsdapp/eal/eal.c @@ -874,7 +874,7 @@ rte_eal_init(int argc, char **argv) rte_eal_mcfg_complete(); - if (rte_eal_dev_init() < 0) + if (rte_eal_dev_init(PMD_INIT_PRE_PCI_PROBE) < 0) rte_panic("Cannot init pmd devices\n"); RTE_LCORE_FOREACH_SLAVE(i) { @@ -906,6 +906,14 @@ rte_eal_init(int argc, char **argv) rte_eal_mp_remote_launch(sync_func, NULL, SKIP_MASTER); rte_eal_mp_wait_lcore(); + /* Probe & Initialize PCI devices */ + if (rte_eal_pci_probe()) + rte_panic("Cannot probe PCI\n"); + + /* Initialize any outstanding devices */ + if (rte_eal_dev_init(PMD_INIT_POST_PCI_PROBE) < 0) + rte_panic("Cannot init pmd devices\n"); + return fctret; } diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c index eae5656..8e80093 100644 --- a/lib/librte_eal/common/eal_common_dev.c +++ b/lib/librte_eal/common/eal_common_dev.c @@ -62,7 +62,7 @@ rte_eal_driver_unregister(struct rte_driver *driver) } int -rte_eal_dev_init(void) +rte_eal_dev_init(uint8_t init_pri) { struct rte_devargs *devargs; struct rte_driver *driver; @@ -80,30 +80,52 @@ rte_eal_dev_init(void) continue; TAILQ_FOREACH(driver, &dev_driver_list, next) { - if (driver->type != PMD_VDEV) - continue; + /* RTE_DEVTYPE_VIRTUAL can only be a virtual or bonded device, + * virtual devices are initialized pre PCI probing and bonded + * device are post pci probing */ + if ((driver->type == PMD_VDEV && init_pri == + PMD_INIT_PRE_PCI_PROBE) || + (driver->type == PMD_BDEV && init_pri == + PMD_INIT_POST_PCI_PROBE)) { - /* search a driver prefix in virtual device name */ - if (!strncmp(driver->name, devargs->virtual.drv_name, - strlen(driver->name))) { - driver->init(devargs->virtual.drv_name, - devargs->args); - break; + /* search a driver prefix in virtual device name */ + if (!strncmp(driver->name, devargs->virtual.drv_name, + strlen(driver->name))) { + printf("init (%u) %s\n", init_pri, devargs->virtual.drv_name); + driver->init(devargs->virtual.drv_name, + devargs->args); + break; + } } } - if (driver == NULL) { - rte_panic("no driver found for %s\n", - devargs->virtual.drv_name); + /* If initializing pre PCI probe, then we don't expect a bonded driver + * to be found */ + if (init_pri == PMD_INIT_PRE_PCI_PROBE && + strncmp(RTE_PMD_BOND, devargs->virtual.drv_name, + strlen(RTE_PMD_BOND)) != 0) { + if (driver == NULL) { + rte_panic("no driver found for virtual device %s\n", + devargs->virtual.drv_name); + } + } else if (init_pri == PMD_INIT_POST_PCI_PROBE && + strncmp(RTE_PMD_BOND, devargs->virtual.drv_name, + strlen(RTE_PMD_BOND)) == 0) { + if (driver == NULL) { + rte_panic("no driver found for bonded device %s\n", + devargs->virtual.drv_name); + } } } - /* Once the vdevs are initalized, start calling all the pdev drivers */ - TAILQ_FOREACH(driver, &dev_driver_list, next) { - if (driver->type != PMD_PDEV) - continue; - /* PDEV drivers don't get passed any parameters */ - driver->init(NULL, NULL); + /* Once the vdevs are initialized, start calling all the pdev drivers */ + if (init_pri == PMD_INIT_PRE_PCI_PROBE) { + TAILQ_FOREACH(driver, &dev_driver_list, next) { + if (driver->type != PMD_PDEV) + continue; + /* PDEV drivers don't get passed any parameters */ + driver->init(NULL, NULL); + } } return 0; } diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c index af809a8..c637361 100644 --- a/lib/librte_eal/common/eal_common_pci.c +++ b/lib/librte_eal/common/eal_common_pci.c @@ -150,6 +150,9 @@ rte_eal_pci_probe(void) probe_all = 1; TAILQ_FOREACH(dev, &pci_device_list, next) { + /* check if device has already been initialized */ + if (dev->driver != NULL) + continue; /* set devargs in PCI structure */ devargs = pci_devargs_lookup(dev); diff --git a/lib/librte_eal/common/include/eal_private.h b/lib/librte_eal/common/include/eal_private.h index 232fcec..b440ffb 100644 --- a/lib/librte_eal/common/include/eal_private.h +++ b/lib/librte_eal/common/include/eal_private.h @@ -196,11 +196,4 @@ int rte_eal_intr_init(void); */ int rte_eal_alarm_init(void); -/** - * This function initialises any virtual devices - * - * This function is private to the EAL. - */ -int rte_eal_dev_init(void); - #endif /* _EAL_PRIVATE_H_ */ diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h index f7e3a10..eaf3284 100644 --- a/lib/librte_eal/common/include/rte_dev.h +++ b/lib/librte_eal/common/include/rte_dev.h @@ -62,6 +62,15 @@ typedef int (rte_dev_init_t)(const char *name, const char *args); enum pmd_type { PMD_VDEV = 0, PMD_PDEV = 1, + PMD_BDEV = 2, /**< Poll Mode Driver Bonded Device*/ +}; + +#define RTE_PMD_BOND ("eth_bond") +/** + * Driver initialization */ +enum pmd_init_priority { + PMD_INIT_PRE_PCI_PROBE = 0, + PMD_INIT_POST_PCI_PROBE = 1, }; /** @@ -93,9 +102,9 @@ void rte_eal_driver_register(struct rte_driver *driver); void rte_eal_driver_unregister(struct rte_driver *driver); /** - * Initalize all the registered drivers in this process + * Initialize all the registered drivers in this process */ -int rte_eal_dev_init(void); +int rte_eal_dev_init(uint8_t init_priority); #define PMD_REGISTER_DRIVER(d)\ void devinitfn_ ##d(void);\ diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c index d204387..573fd06 100644 --- a/lib/librte_eal/linuxapp/eal/eal.c +++ b/lib/librte_eal/linuxapp/eal/eal.c @@ -75,6 +75,7 @@ #include #include #include +#include #include "eal_private.h" #include "eal_thread.h" @@ -1097,7 +1098,7 @@ rte_eal_init(int argc, char **argv) RTE_LOG(DEBUG, EAL, "Master core %u is ready (tid=%x)\n", rte_config.master_lcore, (int)thread_id); - if (rte_eal_dev_init() < 0) + if (rte_eal_dev_init(PMD_INIT_PRE_PCI_PROBE) < 0) rte_panic("Cannot init pmd devices\n"); RTE_LCORE_FOREACH_SLAVE(i) { @@ -1127,6 +1128,14 @@ rte_eal_init(int argc, char **argv) rte_eal_mp_remote_launch(sync_func, NULL, SKIP_MASTER); rte_eal_mp_wait_lcore(); + /* Probe & Initialize PCI devices */ + if (rte_eal_pci_probe()) + rte_panic("Cannot probe PCI\n"); + + /* Initialize any outstanding devices */ + if (rte_eal_dev_init(PMD_INIT_POST_PCI_PROBE) < 0) + rte_panic("Cannot init pmd devices\n"); + return fctret; } -- 1.7.0.7