--- dpdk-stable-23.11.1/usertools/dpdk-devbind.py 2024-05-17 14:46:11.000000000 +0800 +++ dpdk-stable-23.11.1-mr/usertools/dpdk-devbind.py 2024-07-12 15:50:28.665305357 +0800 @@ -8,6 +8,7 @@ import subprocess import argparse import platform +import json from glob import glob from os.path import exists, basename @@ -103,6 +104,7 @@ # command-line arg flags b_flag = None status_flag = False +dump_flag = False force_flag = False args = [] @@ -585,6 +587,11 @@ display_devices("%s devices using kernel driver" % device_name, kernel_drv, if_text + "drv=%(Driver_str)s " "unused=%(Module_str)s %(Active)s") + if dump_flag and dump_path == 'stdout': + print(kernel_drv) + if dump_flag and dump_path != 'stdout': + f = open(dump_path, "w") + f.write(json.dumps(kernel_drv, sort_keys=True,indent=4)) if no_drv: display_devices("Other %s devices" % device_name, no_drv, "unused=%(Module_str)s") @@ -646,6 +653,8 @@ global status_dev global force_flag global args + global dump_flag + global dump_path parser = argparse.ArgumentParser( description='Utility to bind and unbind devices from Linux kernel', @@ -660,6 +669,9 @@ To display current network device status: %(prog)s --status-dev net +To dump current kernel network device status for json: + %(prog)s --status-dev net --dump ('stdout' | 'path') + To bind eth1 from the current driver and move to use vfio-pci %(prog)s --bind=vfio-pci eth1 @@ -671,6 +683,10 @@ """) parser.add_argument( + '-d', + '--dump', + help="Dump the status of kernel net group.") + parser.add_argument( '-s', '--status', action='store_true', @@ -712,6 +728,9 @@ if opt.status_dev: status_flag = True status_dev = opt.status_dev + if opt.dump: + dump_flag = True + dump_path = opt.dump if opt.status: status_flag = True status_dev = "all"