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 <declan.doherty at intel.com>
---
 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/common/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)

        /* call the init function for each virtual device */
        TAILQ_FOREACH(devargs, &devargs_list, next) {
+               uint8_t bdev = 0;

                if (devargs->type != RTE_DEVTYPE_VIRTUAL)
                        continue;

                TAILQ_FOREACH(driver, &dev_driver_list, next) {
-                       if (driver->type != PMD_VDEV)
+                       /* RTE_DEVTYPE_VIRTUAL can only be a virtual or bonded 
device*/
+                       if (driver->type != PMD_VDEV && driver->type != 
PMD_BDEV)
                                continue;

+                       /*
+                        * 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 == PMD_BDEV &&
+                                       !strncmp(driver->name, 
devargs->virtual.drv_name,
+                                                       strlen(driver->name))) {
+                               bdev = 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)
                        }
                }

-               if (driver == NULL) {
-                       rte_panic("no driver found for %s\n",
-                                 devargs->virtual.drv_name);
+               if (driver == NULL && !bdev) {
+                       rte_panic("no driver found for %s and is not a bonded 
vdev %d\n",
+                                 devargs->virtual.drv_name, bdev);
                }
        }

@@ -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 = 0;
+
+               if (devargs->type != RTE_DEVTYPE_VIRTUAL)
+                       continue;
+
+               TAILQ_FOREACH(driver, &dev_driver_list, next) {
+                       if (driver->type != PMD_VDEV && driver->type != 
PMD_BDEV)
+                               continue;
+
+                       /* Virtual devices have already been initialized so we 
skip them
+                        * here*/
+                       if (driver->type == PMD_VDEV &&
+                                       !strncmp(driver->name, 
devargs->virtual.drv_name,
+                                                       strlen(driver->name))) {
+                               vdev = 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 == 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/common/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);
        }

+#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
 }

 /* 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);

+#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/common/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 char 
*args);
 enum pmd_type {
        PMD_VDEV = 0,
        PMD_PDEV = 1,
+       PMD_BDEV = 2,   /**< Poll Mode Driver Bonded Device*/
 };

 /**
-- 
1.7.0.7

Reply via email to