Change the PCI address output format used by dpdk-devbind.py to match that used on linux, where we have the bus values in hex rather than in decimal, "pci0" is replaced with "0000", and the final separator is a "." rather than a ":". As well as having consistent output across platforms, this also aligns the output format with the BDF format accepted by EAL -a/-b flags.
Signed-off-by: Bruce Richardson <[email protected]> --- doc/guides/tools/devbind.rst | 4 ++++ usertools/dpdk-devbind.py | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/doc/guides/tools/devbind.rst b/doc/guides/tools/devbind.rst index 90b289de1e..f36e8c4de7 100644 --- a/doc/guides/tools/devbind.rst +++ b/doc/guides/tools/devbind.rst @@ -8,6 +8,10 @@ The ``dpdk-devbind`` tool is a Data Plane Development Kit (DPDK) utility that helps binding and unbinding devices from specific drivers. As well as checking their status in that regard. +PCI addresses use the hexadecimal ``dddd:bb:dd.f`` format on both Linux and FreeBSD. +For example, FreeBSD's ``pci0:152:0:1`` is displayed as ``0000:98:00.1``, +and this address can be used directly in EAL device arguments. + Running the Application ----------------------- diff --git a/usertools/dpdk-devbind.py b/usertools/dpdk-devbind.py index 00d7188618..c62b3ad6d8 100755 --- a/usertools/dpdk-devbind.py +++ b/usertools/dpdk-devbind.py @@ -286,8 +286,9 @@ def init_devices_cache_bsd(): # Parse slot/address from first part name_addr, fields = line.split(maxsplit=1) devname, addr = name_addr.split('@') - # Remove trailing colon from address - addr = addr.rstrip(':') + # Convert the decimal pciconf address to hexadecimal DPDK format. + domain, bus, slot, function = map(int, addr[3:].rstrip(':').split(':')) + addr = f"{domain:04x}:{bus:02x}:{slot:02x}.{function:x}" current_dev = {} current_dev["Slot"] = addr -- 2.55.0

