X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=usertools%2Fdpdk-devbind.py;h=a9cd66a780fea3bc64916aff2ddee29725f8dc30;hb=9070f88b81dab42739fb169265e3ea727e47dfa2;hp=7d564634ca4b73eea91d432c7f3eb453dc43d591;hpb=9d35895e51539cef28e604a1ba8d4d521895cdd7;p=dpdk.git diff --git a/usertools/dpdk-devbind.py b/usertools/dpdk-devbind.py index 7d564634ca..a9cd66a780 100755 --- a/usertools/dpdk-devbind.py +++ b/usertools/dpdk-devbind.py @@ -546,14 +546,27 @@ def show_device_status(devices_type, device_name): else: kernel_drv.append(devices[d]) + n_devs = len(dpdk_drv) + len(kernel_drv) + len(no_drv) + + # don't bother displaying anything if there are no devices + if n_devs == 0: + msg = "No '%s' devices detected" % device_name + print("") + print(msg) + print("".join('=' * len(msg))) + return + # print each category separately, so we can clearly see what's used by DPDK - display_devices("%s devices using DPDK-compatible driver" % device_name, - dpdk_drv, "drv=%(Driver_str)s unused=%(Module_str)s") - display_devices("%s devices using kernel driver" % device_name, kernel_drv, - "if=%(Interface)s drv=%(Driver_str)s " - "unused=%(Module_str)s %(Active)s") - display_devices("Other %s devices" % device_name, no_drv, - "unused=%(Module_str)s") + if len(dpdk_drv) != 0: + display_devices("%s devices using DPDK-compatible driver" % device_name, + dpdk_drv, "drv=%(Driver_str)s unused=%(Module_str)s") + if len(kernel_drv) != 0: + display_devices("%s devices using kernel driver" % device_name, kernel_drv, + "if=%(Interface)s drv=%(Driver_str)s " + "unused=%(Module_str)s %(Active)s") + if len(no_drv) != 0: + display_devices("Other %s devices" % device_name, no_drv, + "unused=%(Module_str)s") def show_status(): '''Function called when the script is passed the "--status" option. @@ -655,6 +668,13 @@ def do_arg_actions(): def main(): '''program main function''' + # check if lspci is installed, suppress any output + with open(os.devnull, 'w') as devnull: + ret = subprocess.call(['which', 'lspci'], + stdout=devnull, stderr=devnull) + if ret != 0: + print("'lspci' not found - please install 'pciutils'") + sys.exit(1) parse_args() check_modules() clear_data()