[dpdk-dev,v5,13/20] pci: introduce PCI address parsing function
Checks
Commit Message
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.rivet@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(+)
@@ -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.
*
@@ -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,
@@ -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;