A new single function that is able to parse all currently supported format:
* Domain-Bus-Device-Function * Bus-Device-Function Signed-off-by: Gaetan Rivet <gaetan.ri...@6wind.com> --- lib/librte_pci/include/rte_pci.h | 15 +++++++++++++++ lib/librte_pci/rte_pci.c | 10 ++++++++++ lib/librte_pci/rte_pci_version.map | 1 + 3 files changed, 26 insertions(+) diff --git a/lib/librte_pci/include/rte_pci.h b/lib/librte_pci/include/rte_pci.h index 38cbdb3..9e79557 100644 --- a/lib/librte_pci/include/rte_pci.h +++ b/lib/librte_pci/include/rte_pci.h @@ -256,6 +256,21 @@ int rte_eal_compare_pci_addr(const struct rte_pci_addr *addr, int pci_addr_cmp(const struct rte_pci_addr *addr, const struct rte_pci_addr *addr2); + +/** + * Utility function to parse a string into a PCI location. + * + * @param str + * The string to parse + * @param addr + * The reference to the structure where the location + * is stored. + * @return + * 0 on success + * <0 otherwise + */ +int pci_addr_parse(const char *str, struct rte_pci_addr *addr); + /** * Map a particular resource from a file. * diff --git a/lib/librte_pci/rte_pci.c b/lib/librte_pci/rte_pci.c index fc2fc7f..7ba472c 100644 --- a/lib/librte_pci/rte_pci.c +++ b/lib/librte_pci/rte_pci.c @@ -171,6 +171,16 @@ pci_addr_cmp(const struct rte_pci_addr *addr, return 0; } +int +pci_addr_parse(const char *str, struct rte_pci_addr *addr) +{ + if (pci_bdf_parse(str, addr) == 0 || + pci_dbdf_parse(str, addr) == 0) + return 0; + return -1; +} + + /* map a particular resource from a file */ void * pci_map_resource(void *requested_addr, int fd, off_t offset, size_t size, diff --git a/lib/librte_pci/rte_pci_version.map b/lib/librte_pci/rte_pci_version.map index 8d180e3..5f50f98 100644 --- a/lib/librte_pci/rte_pci_version.map +++ b/lib/librte_pci/rte_pci_version.map @@ -4,6 +4,7 @@ DPDK_17.11 { eal_parse_pci_BDF; eal_parse_pci_DomBDF; pci_addr_cmp; + pci_addr_parse; pci_bdf_parse; pci_dbdf_parse; pci_device_name; -- 2.1.4