bus/pci: implement parse bus operation
authorGaetan Rivet <gaetan.rivet@6wind.com>
Fri, 7 Jul 2017 00:03:10 +0000 (02:03 +0200)
committerThomas Monjalon <thomas@monjalon.net>
Sat, 8 Jul 2017 20:29:21 +0000 (22:29 +0200)
Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
lib/librte_eal/common/eal_common_pci.c

index f3830a1..1d3eaed 100644 (file)
@@ -448,6 +448,20 @@ rte_pci_dump(FILE *f)
        }
 }
 
+static int
+pci_parse(const char *name, void *addr)
+{
+       struct rte_pci_addr *out = addr;
+       struct rte_pci_addr pci_addr;
+       bool parse;
+
+       parse = (eal_parse_pci_BDF(name, &pci_addr) == 0 ||
+                eal_parse_pci_DomBDF(name, &pci_addr) == 0);
+       if (parse && addr != NULL)
+               *out = pci_addr;
+       return parse == false;
+}
+
 /* register a driver */
 void
 rte_pci_register(struct rte_pci_driver *driver)
@@ -542,6 +556,7 @@ struct rte_pci_bus rte_pci_bus = {
                .find_device = pci_find_device,
                .plug = pci_plug,
                .unplug = pci_unplug,
+               .parse = pci_parse,
        },
        .device_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.device_list),
        .driver_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.driver_list),