env: Add a function to convert pci addr to string
Convert an spdk_pci_addr to a string. Change-Id: Idab0a16822cc37d7095d19f062dfca65356211e8 Signed-off-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
8a9c1d4011
commit
4caf3c563a
@ -237,6 +237,19 @@ int spdk_pci_addr_compare(const struct spdk_pci_addr *a1, const struct spdk_pci_
|
|||||||
*/
|
*/
|
||||||
int spdk_pci_addr_parse(struct spdk_pci_addr *addr, const char *bdf);
|
int spdk_pci_addr_parse(struct spdk_pci_addr *addr, const char *bdf);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a struct spdk_pci_addr to a string.
|
||||||
|
*
|
||||||
|
* \param bdf String into which a string will be output in the format
|
||||||
|
* domain:bus:device.function. The string must be at least
|
||||||
|
* 14 characters in size.
|
||||||
|
* \param sz Size of bdf. Must be at least 14.
|
||||||
|
* \param addr PCI address input
|
||||||
|
*
|
||||||
|
* \return 0 on success, or a negated errno value on failure.
|
||||||
|
*/
|
||||||
|
int spdk_pci_addr_fmt(char *bdf, size_t sz, const struct spdk_pci_addr *addr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call a function with CPU affinity unset.
|
* Call a function with CPU affinity unset.
|
||||||
*
|
*
|
||||||
|
@ -429,3 +429,19 @@ spdk_pci_addr_parse(struct spdk_pci_addr *addr, const char *bdf)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
spdk_pci_addr_fmt(char *bdf, size_t sz, const struct spdk_pci_addr *addr)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
rc = snprintf(bdf, sz, PCI_PRI_FMT,
|
||||||
|
addr->domain, addr->bus,
|
||||||
|
addr->dev, addr->func);
|
||||||
|
|
||||||
|
if (rc > 0 && (size_t)rc < sz) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user