From mboxrd@z Thu Jan 1 00:00:00 1970 From: Declan Doherty Subject: [PATCH v4 3/6] EAL support for link bonding device initialization Date: Mon, 16 Jun 2014 12:18:30 +0100 Message-ID: <1402917513-19495-4-git-send-email-declan.doherty@intel.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable To: dev-VfR2kkLFssw@public.gmane.org Return-path: In-Reply-To: List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" Updating functionality in EAL to support adding link bonding devices via =E2=80=93vdev option. Link bonding devices will be initialized after all physical devices have been probed and initialized. Signed-off-by: Declan Doherty --- lib/librte_eal/common/eal_common_dev.c | 66 +++++++++++++++++++++= ++++-- lib/librte_eal/common/eal_common_pci.c | 6 +++ lib/librte_eal/common/include/eal_private.h | 7 +++ lib/librte_eal/common/include/rte_dev.h | 1 + 4 files changed, 76 insertions(+), 4 deletions(-) diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/comm= on/eal_common_dev.c index eae5656..b50c908 100644 --- a/lib/librte_eal/common/eal_common_dev.c +++ b/lib/librte_eal/common/eal_common_dev.c @@ -75,14 +75,28 @@ rte_eal_dev_init(void) =20 /* call the init function for each virtual device */ TAILQ_FOREACH(devargs, &devargs_list, next) { + uint8_t bdev =3D 0; =20 if (devargs->type !=3D RTE_DEVTYPE_VIRTUAL) continue; =20 TAILQ_FOREACH(driver, &dev_driver_list, next) { - if (driver->type !=3D PMD_VDEV) + /* RTE_DEVTYPE_VIRTUAL can only be a virtual or bonded device*/ + if (driver->type !=3D PMD_VDEV && driver->type !=3D PMD_BDEV) continue; =20 + /* + * Bonded devices are not initialize here, we do it later in + * rte_eal_bonded_dev_init() after all physical devices have been + * probed and initialized + */ + if (driver->type =3D=3D PMD_BDEV && + !strncmp(driver->name, devargs->virtual.drv_name, + strlen(driver->name))) { + bdev =3D 1; + break; + } + /* search a driver prefix in virtual device name */ if (!strncmp(driver->name, devargs->virtual.drv_name, strlen(driver->name))) { @@ -92,9 +106,9 @@ rte_eal_dev_init(void) } } =20 - if (driver =3D=3D NULL) { - rte_panic("no driver found for %s\n", - devargs->virtual.drv_name); + if (driver =3D=3D NULL && !bdev) { + rte_panic("no driver found for %s and is not a bonded vdev %d\n", + devargs->virtual.drv_name, bdev); } } =20 @@ -107,3 +121,47 @@ rte_eal_dev_init(void) } return 0; } + +#ifdef RTE_LIBRTE_PMD_BOND +int +rte_eal_bonded_dev_init(void) +{ + struct rte_devargs *devargs; + struct rte_driver *driver; + + TAILQ_FOREACH(devargs, &devargs_list, next) { + int vdev =3D 0; + + if (devargs->type !=3D RTE_DEVTYPE_VIRTUAL) + continue; + + TAILQ_FOREACH(driver, &dev_driver_list, next) { + if (driver->type !=3D PMD_VDEV && driver->type !=3D PMD_BDEV) + continue; + + /* Virtual devices have already been initialized so we skip them + * here*/ + if (driver->type =3D=3D PMD_VDEV && + !strncmp(driver->name, devargs->virtual.drv_name, + strlen(driver->name))) { + vdev =3D 1; + break; + } + + /* search a driver prefix in bonded device name */ + if (!strncmp(driver->name, devargs->virtual.drv_name, + strlen(driver->name))) { + driver->init(devargs->virtual.drv_name, devargs->args); + break; + } + } + + if (driver =3D=3D NULL && !vdev) { + rte_panic("no driver found for %s\n", + devargs->virtual.drv_name); + } + } + return 0; +} +#endif + diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/comm= on/eal_common_pci.c index 4d877ea..9b584f5 100644 --- a/lib/librte_eal/common/eal_common_pci.c +++ b/lib/librte_eal/common/eal_common_pci.c @@ -166,7 +166,13 @@ rte_eal_pci_probe(void) dev->addr.devid, dev->addr.function); } =20 +#ifdef RTE_LIBRTE_PMD_BOND + /* After all physical PCI devices have been probed and initialized then= we + * initialize the bonded devices */ + return rte_eal_bonded_dev_init(); +#else return 0; +#endif } =20 /* dump one device */ diff --git a/lib/librte_eal/common/include/eal_private.h b/lib/librte_eal= /common/include/eal_private.h index 232fcec..f6081bb 100644 --- a/lib/librte_eal/common/include/eal_private.h +++ b/lib/librte_eal/common/include/eal_private.h @@ -203,4 +203,11 @@ int rte_eal_alarm_init(void); */ int rte_eal_dev_init(void); =20 +#ifdef RTE_LIBRTE_PMD_BOND +/** + * Initialize the bonded devices + */ +int rte_eal_bonded_dev_init(void); +#endif + #endif /* _EAL_PRIVATE_H_ */ diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/com= mon/include/rte_dev.h index f7e3a10..f0a780a 100644 --- a/lib/librte_eal/common/include/rte_dev.h +++ b/lib/librte_eal/common/include/rte_dev.h @@ -62,6 +62,7 @@ typedef int (rte_dev_init_t)(const char *name, const ch= ar *args); enum pmd_type { PMD_VDEV =3D 0, PMD_PDEV =3D 1, + PMD_BDEV =3D 2, /**< Poll Mode Driver Bonded Device*/ }; =20 /** --=20 1.7.0.7