From patchwork Wed Nov 4 07:03:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 83653 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 88A14A04E7; Wed, 4 Nov 2020 08:04:14 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E1A8AC7F2; Wed, 4 Nov 2020 08:03:58 +0100 (CET) Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) by dpdk.org (Postfix) with ESMTP id 477ACC7EC for ; Wed, 4 Nov 2020 08:03:56 +0100 (CET) Received: by mail-pg1-f170.google.com with SMTP id h6so15786250pgk.4 for ; Tue, 03 Nov 2020 23:03:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=e62eUSfYVM32CBxr7qEPtl3Cg2KA1jl/r9oJeSqgJeo=; b=yztRbIpC33wqAhWJa7qw1G1wbU4ZnmAg2Tn8jNJw9v+jOiLfImg6hQ+GcaSBQaUBqP FnbhlZb7X1oUsqUR3VrFsPTVqaMyggYam9idQXH850sMvZwAic5Bzqk+enQURuFJg4iA KTevxNpxJALWRQkX9vrp8glYzPbK0x/nia/mn9414Sa2mK4ZJm0g0gZDb042eD2fT0iM aGrQZDz7GtnL3e3wxe5QMMit1XwKnPYlUZ8PuVCytk4mSkTIGkFTsTZxpsQFN/Sdg5Xi a5X9MEFpe6QFv/AUof0VP7cizF9wBbDLryOiCScyhPcacysC5fNlljwmDT45WeNAy1g2 3cTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=e62eUSfYVM32CBxr7qEPtl3Cg2KA1jl/r9oJeSqgJeo=; b=QMUIengqwK8ZAykbeB+BqxUrU6RNGsFPYWlf1fttd4DomhhBLprfGPsThO0dGm88bs xnCso5Mv3C6H5MHQ5dPnuNBdj6C0PcAa77d/cnSPbIgDQLmOpI13hlKvGVg0mqeL3tcY 3gnDlj9MpXtFIDYCF0vqploJsk+cXNZEG/3xgAMcGNKVPCN8TT3xukky67fQ6vybVx7z WHIv1QkDizgTJ/yWEEu62B0lluNzE0fr6PJN5fRHePHu1tOjCEdRBSjx6kV2M2a6Iilk BTpahk7xmzlkUVTiQ7aB2vOF1xfxDHslrPRWCOuPVezZsZEJM6YeOGh25KhZVxSr1oHI zFag== X-Gm-Message-State: AOAM531HL6V+LHODqhOJNWhVikKTbO+HnCMzjItfdKMBsZsi/+GIQ6Wc iusPluKwVl8tHIE78zAGPvyzutm3enTMMLri X-Google-Smtp-Source: ABdhPJwmiz85hl7Ycw/JqSGMIL+vu7fSSKs5+cDRziZ2dNZaZnjfvFa7yGiF+P/funzV79MwlL2BUw== X-Received: by 2002:a63:f445:: with SMTP id p5mr19928168pgk.293.1604473433899; Tue, 03 Nov 2020 23:03:53 -0800 (PST) Received: from hermes.corp.microsoft.com (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id z21sm1181177pfa.158.2020.11.03.23.03.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 23:03:53 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 3 Nov 2020 23:03:45 -0800 Message-Id: <20201104070350.28224-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201104070350.28224-1-stephen@networkplumber.org> References: <20200906013133.26360-12-stephen@networkplumber.org> <20201104070350.28224-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 1/6] dpdk-devbind: use argparse instead of getopt X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Using the python standard argument parser instead of C library style getopt gives a number of advantages such as checking for conflicting arguments, restricting choices, and automatically generating help messages. The result is similar to the original the only visible change is that some of the help messages are now less wordy. Signed-off-by: Stephen Hemminger --- usertools/dpdk-devbind.py | 203 ++++++++++++++++---------------------- 1 file changed, 86 insertions(+), 117 deletions(-) diff --git a/usertools/dpdk-devbind.py b/usertools/dpdk-devbind.py index 99112b7ab794..e0b74c5a3e41 100755 --- a/usertools/dpdk-devbind.py +++ b/usertools/dpdk-devbind.py @@ -5,8 +5,9 @@ import sys import os -import getopt import subprocess +import argparse + from glob import glob from os.path import exists, abspath, dirname, basename from os.path import join as path_join @@ -82,82 +83,6 @@ force_flag = False args = [] - -def usage(): - '''Print usage information for the program''' - argv0 = basename(sys.argv[0]) - print(""" -Usage: ------- - - %(argv0)s [options] DEVICE1 DEVICE2 .... - -where DEVICE1, DEVICE2 etc, are specified via PCI "domain:bus:slot.func" syntax -or "bus:slot.func" syntax. For devices bound to Linux kernel drivers, they may -also be referred to by Linux interface name e.g. eth0, eth1, em0, em1, etc. -If devices are specified using PCI bus:device:func format, then -shell wildcards and ranges may be used, e.g. 80:04.*, 80:04.[0-3] - -Options: - --help, --usage: - Display usage information and quit - - -s, --status: - Print the current status of all known network, crypto, event - and mempool devices. - For each device, it displays the PCI domain, bus, slot and function, - along with a text description of the device. Depending upon whether the - device is being used by a kernel driver, the igb_uio driver, or no - driver, other relevant information will be displayed: - * the Linux interface name e.g. if=eth0 - * the driver being used e.g. drv=igb_uio - * any suitable drivers not currently using that device - e.g. unused=igb_uio - NOTE: if this flag is passed along with a bind/unbind option, the - status display will always occur after the other operations have taken - place. - - --status-dev: - Print the status of given device group. Supported device groups are: - "net", "baseband", "crypto", "event", "mempool" and "compress" - - -b driver, --bind=driver: - Select the driver to use or \"none\" to unbind the device - - -u, --unbind: - Unbind a device (Equivalent to \"-b none\") - - --force: - By default, network devices which are used by Linux - as indicated by - having routes in the routing table - cannot be modified. Using the - --force flag overrides this behavior, allowing active links to be - forcibly unbound. - WARNING: This can lead to loss of network connection and should be used - with caution. - -Examples: ---------- - -To display current device status: - %(argv0)s --status - -To display current network device status: - %(argv0)s --status-dev net - -To bind eth1 from the current driver and move to use igb_uio - %(argv0)s --bind=igb_uio eth1 - -To unbind 0000:01:00.0 from using any driver - %(argv0)s -u 0000:01:00.0 - -To bind 0000:02:00.0 and 0000:02:00.1 to the ixgbe kernel driver - %(argv0)s -b ixgbe 02:00.0 02:00.1 - -To bind all functions on device 0000:02:00 to ixgbe kernel driver - %(argv0)s -b ixgbe 02:00.* - - """ % locals()) # replace items from local variables - # check if a specific kernel module is loaded def module_is_loaded(module): global loaded_modules @@ -677,38 +602,93 @@ def parse_args(): global status_dev global force_flag global args - if len(sys.argv) <= 1: - usage() - sys.exit(0) - try: - opts, args = getopt.getopt(sys.argv[1:], "b:us", - ["help", "usage", "status", "status-dev=", - "force", "bind=", "unbind", ]) - except getopt.GetoptError as error: - print(str(error)) - print("Run '%s --usage' for further information" % sys.argv[0]) + parser = argparse.ArgumentParser( + description='Utility to bind and unbind devices from Linux kernel', + formatter_class=argparse.RawDescriptionHelpFormatter, + epilog=""" +Examples: +--------- + +To display current device status: + %(prog)s --status + +To display current network device status: + %(prog)s --status-dev net + +To bind eth1 from the current driver and move to use vfio-pci + %(prog)s --bind=vfio-pci eth1 + +To unbind 0000:01:00.0 from using any driver + %(prog)s -u 0000:01:00.0 + +To bind 0000:02:00.0 and 0000:02:00.1 to the ixgbe kernel driver + %(prog)s -b ixgbe 02:00.0 02:00.1 +""") + + parser.add_argument( + '-s', + '--status', + action='store_true', + help="Print the current status of all known devices.") + parser.add_argument( + '--status-dev', + help="Print the status of given device group.", + choices=['net', 'baseband', 'crypto', 'event', 'mempool', 'compress']) + bind_group = parser.add_mutually_exclusive_group() + bind_group.add_argument( + '-b', + '--bind', + metavar='DRIVER', + help="Select the driver to use or \"none\" to unbind the device") + bind_group.add_argument( + '-u', + '--unbind', + action='store_true', + help="Unbind a device (equivalent to \"-b none\")") + parser.add_argument( + '--force', + action='store_true', + help=""" +Override restriction on binding devices in use by Linux" +WARNING: This can lead to loss of network connection and should be used with caution. +""") + parser.add_argument( + 'devices', + metavar='DEVICE', + nargs='*', + help=""" +Device specified as PCI "domain:bus:slot.func" syntax or "bus:slot.func" syntax. +For devices bound to Linux kernel drivers, they may be referred to by interface name. +""") + + opt = parser.parse_args() + + if opt.status_dev: + status_flag = True + status_dev = opt.status_dev + if opt.status: + status_flag = True + status_dev = "all" + if opt.force: + force_flag = True + if opt.bind: + b_flag = opt.bind + elif opt.unbind: + b_flag = "none" + args = opt.devices + + if not b_flag and not status_flag: + print("Error: No action specified for devices. " + "Please give a --bind, --ubind or --status option", + file=sys.stderr) + parser.print_usage() sys.exit(1) - for opt, arg in opts: - if opt == "--help" or opt == "--usage": - usage() - sys.exit(0) - if opt == "--status-dev": - status_flag = True - status_dev = arg - if opt == "--status" or opt == "-s": - status_flag = True - status_dev = "all" - if opt == "--force": - force_flag = True - if opt == "-b" or opt == "-u" or opt == "--bind" or opt == "--unbind": - if b_flag is not None: - sys.exit("Error: binding and unbinding are mutually exclusive") - if opt == "-u" or opt == "--unbind": - b_flag = "none" - else: - b_flag = arg + if b_flag and not args: + print("Error: No devices specified.", file=sys.stderr) + parser.print_usage() + sys.exit(1) # resolve any PCI globs in the args new_args = [] @@ -723,17 +703,6 @@ def do_arg_actions(): global force_flag global args - if b_flag is None and not status_flag: - print("Error: No action specified for devices. " - "Please give a -b or -u option", file=sys.stderr) - usage() - sys.exit(1) - - if b_flag is not None and len(args) == 0: - print("Error: No devices specified.", file=sys.stderr) - usage() - sys.exit(1) - if b_flag == "none" or b_flag == "None": unbind_all(args, force_flag) elif b_flag is not None: From patchwork Wed Nov 4 07:03:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 83654 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id E5964A04E7; Wed, 4 Nov 2020 08:04:34 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 864D6C804; Wed, 4 Nov 2020 08:04:00 +0100 (CET) Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by dpdk.org (Postfix) with ESMTP id 9BB8BC7F2 for ; Wed, 4 Nov 2020 08:03:57 +0100 (CET) Received: by mail-pl1-f193.google.com with SMTP id k7so556420plk.3 for ; Tue, 03 Nov 2020 23:03:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cqarFFgOJ7La2Qn6/42IDnxeSQzmzQv4ASLxcqQ21p4=; b=gSb0LQuVwmnkrGUMX7wbYU+os/CQ3zkJcO1QKcSolgfhK4xZN8l9TrqjhfhfWcJxN8 xGMmLf4WlUzHyTlE4Lm9zknZg8yKXsVT+CtJah6QS28+AKECxBc7wJ5nQHNAbzSxAW/R xg+jNNoqBPNUlz0Ec0GTWngWojEKz1DKAQQlfVJpWRcQR0J/V5xgf67vraFnsdjotMln lMJGH09XrLxZIY0HlNU2Igzj1XrP04oyI6l6S+MgyvWMpg/OjPZ//zdimwZmJ5C97nL/ i4ZE7gECpv3SRNyLzER8/3+YQx+RPgq3y3WPS9WcQH37X8a01ysPwhIw6SGFQ3lLY9ke wKUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cqarFFgOJ7La2Qn6/42IDnxeSQzmzQv4ASLxcqQ21p4=; b=IfHZF4Qrlsf6jIPOW6Diq/+ox4G39BN9MXgcvzf73Uk6B99yNAqiWrEoZQswXAoI12 dx1Z2nwCluG+UNoy4TS4TI9u9DYtBIFpy9I//6ESJn/3+rQ7TQUjaFu2r0ht8NxpOx5U bI4CF+vkaYamF/sEAVBuJ0QKgODKYGyWzZaCCjPP1/kMmf1pdxjSx5oc66y4Gm+WKym2 r7e43tOHC0MOyZnvvtlYgCoLhkVKBMAcbf/8F0kNXG4hNFoXclF2/O/dlFJK+6faVe4v jmq+YCKqD4kra+1rBIgTUMyDXsMs5Mm9ZBDh85altdM5gMOTFImSrtQmCL1P5+6uarXo OUhg== X-Gm-Message-State: AOAM5335n9w1ZS7z7qIllOxrQO0bcy2vLU/cnwn3M9Vr2TWgjBbyAsPS NNhxv3sqOSSASuRxEcWdG98OHxOW0/7oiNiT X-Google-Smtp-Source: ABdhPJxTtIO9wOs3Ed2qtAdn2EvvsAQqimR068OOVtp8U8e/QloPXRUyoFvkJXhtG/CeoNebBIE98w== X-Received: by 2002:a17:902:26a:b029:d6:caca:620a with SMTP id 97-20020a170902026ab02900d6caca620amr13342322plc.46.1604473435341; Tue, 03 Nov 2020 23:03:55 -0800 (PST) Received: from hermes.corp.microsoft.com (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id z21sm1181177pfa.158.2020.11.03.23.03.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 23:03:54 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 3 Nov 2020 23:03:46 -0800 Message-Id: <20201104070350.28224-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201104070350.28224-1-stephen@networkplumber.org> References: <20200906013133.26360-12-stephen@networkplumber.org> <20201104070350.28224-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 2/6] dpdk-devbind: fix indentation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Python lint complains about identation and missing spaces around commas in this script. Signed-off-by: Stephen Hemminger --- usertools/dpdk-devbind.py | 53 ++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/usertools/dpdk-devbind.py b/usertools/dpdk-devbind.py index e0b74c5a3e41..3a27641d0e08 100755 --- a/usertools/dpdk-devbind.py +++ b/usertools/dpdk-devbind.py @@ -14,15 +14,15 @@ # The PCI base class for all devices network_class = {'Class': '02', 'Vendor': None, 'Device': None, - 'SVendor': None, 'SDevice': None} + 'SVendor': None, 'SDevice': None} acceleration_class = {'Class': '12', 'Vendor': None, 'Device': None, 'SVendor': None, 'SDevice': None} ifpga_class = {'Class': '12', 'Vendor': '8086', 'Device': '0b30', - 'SVendor': None, 'SDevice': None} + 'SVendor': None, 'SDevice': None} encryption_class = {'Class': '10', 'Vendor': None, 'Device': None, - 'SVendor': None, 'SDevice': None} + 'SVendor': None, 'SDevice': None} intel_processor_class = {'Class': '0b', 'Vendor': '8086', 'Device': None, - 'SVendor': None, 'SDevice': None} + 'SVendor': None, 'SDevice': None} cavium_sso = {'Class': '08', 'Vendor': '177d', 'Device': 'a04b,a04d', 'SVendor': None, 'SDevice': None} cavium_fpa = {'Class': '08', 'Vendor': '177d', 'Device': 'a053', @@ -34,29 +34,30 @@ cavium_zip = {'Class': '12', 'Vendor': '177d', 'Device': 'a037', 'SVendor': None, 'SDevice': None} avp_vnic = {'Class': '05', 'Vendor': '1af4', 'Device': '1110', - 'SVendor': None, 'SDevice': None} + 'SVendor': None, 'SDevice': None} octeontx2_sso = {'Class': '08', 'Vendor': '177d', 'Device': 'a0f9,a0fa', - 'SVendor': None, 'SDevice': None} + 'SVendor': None, 'SDevice': None} octeontx2_npa = {'Class': '08', 'Vendor': '177d', 'Device': 'a0fb,a0fc', - 'SVendor': None, 'SDevice': None} + 'SVendor': None, 'SDevice': None} octeontx2_dma = {'Class': '08', 'Vendor': '177d', 'Device': 'a081', - 'SVendor': None, 'SDevice': None} + 'SVendor': None, 'SDevice': None} octeontx2_ree = {'Class': '08', 'Vendor': '177d', 'Device': 'a0f4', - 'SVendor': None, 'SDevice': None} + 'SVendor': None, 'SDevice': None} -intel_ioat_bdw = {'Class': '08', 'Vendor': '8086', 'Device': '6f20,6f21,6f22,6f23,6f24,6f25,6f26,6f27,6f2e,6f2f', - 'SVendor': None, 'SDevice': None} +intel_ioat_bdw = {'Class': '08', 'Vendor': '8086', + 'Device': '6f20,6f21,6f22,6f23,6f24,6f25,6f26,6f27,6f2e,6f2f', + 'SVendor': None, 'SDevice': None} intel_ioat_skx = {'Class': '08', 'Vendor': '8086', 'Device': '2021', - 'SVendor': None, 'SDevice': None} + 'SVendor': None, 'SDevice': None} intel_ioat_icx = {'Class': '08', 'Vendor': '8086', 'Device': '0b00', - 'SVendor': None, 'SDevice': None} + 'SVendor': None, 'SDevice': None} intel_idxd_spr = {'Class': '08', 'Vendor': '8086', 'Device': '0b25', - 'SVendor': None, 'SDevice': None} + 'SVendor': None, 'SDevice': None} intel_ntb_skx = {'Class': '06', 'Vendor': '8086', 'Device': '201c', - 'SVendor': None, 'SDevice': None} + 'SVendor': None, 'SDevice': None} intel_ntb_icx = {'Class': '06', 'Vendor': '8086', 'Device': '347e', - 'SVendor': None, 'SDevice': None} + 'SVendor': None, 'SDevice': None} network_devices = [network_class, cavium_pkx, avp_vnic, ifpga_class] baseband_devices = [acceleration_class] @@ -206,7 +207,7 @@ def get_device_details(devices_type): route = subprocess.check_output(["ip", "-o", "route"]) # filter out all lines for 169.254 routes route = "\n".join(filter(lambda ln: not ln.startswith("169.254"), - route.decode().splitlines())) + route.decode().splitlines())) rt_info = route.split() for i in range(len(rt_info) - 1): if rt_info[i] == "dev": @@ -366,8 +367,8 @@ def bind_one(dev_id, driver, force): return try: # Convert Device and Vendor Id to int to write to new_id - f.write("%04x %04x" % (int(dev["Vendor"],16), - int(dev["Device"], 16))) + f.write("%04x %04x" % (int(dev["Vendor"], 16), + int(dev["Device"], 16))) f.close() except: print("Error: bind failed for %s - Cannot write new PCI ID to " @@ -409,13 +410,13 @@ def bind_one(dev_id, driver, force): f = open(filename, "w") except: sys.exit("Error: unbind failed for %s - Cannot open %s" - % (dev_id, filename)) + % (dev_id, filename)) try: f.write("\00") f.close() except: sys.exit("Error: unbind failed for %s - Cannot open %s" - % (dev_id, filename)) + % (dev_id, filename)) def unbind_all(dev_list, force=False): @@ -456,7 +457,7 @@ def bind_all(dev_list, driver, force=False): pass # check if we're attempting to bind to a driver that isn't loaded - if not module_is_loaded(driver.replace('-','_')): + if not module_is_loaded(driver.replace('-', '_')): sys.exit("Error: Driver '%s' is not loaded." % driver) try: @@ -501,9 +502,9 @@ def display_devices(title, dev_list, extra_params=None): for dev in dev_list: if extra_params is not None: strings.append("%s '%s %s' %s" % (dev["Slot"], - dev["Device_str"], - dev["Device"], - extra_params % dev)) + dev["Device_str"], + dev["Device"], + extra_params % dev)) else: strings.append("%s '%s'" % (dev["Slot"], dev["Device_str"])) # sort before printing, so that the entries appear in PCI order @@ -573,7 +574,7 @@ def show_status(): show_device_status(mempool_devices, "Mempool") if status_dev == "compress" or status_dev == "all": - show_device_status(compress_devices , "Compress") + show_device_status(compress_devices, "Compress") if status_dev == "misc" or status_dev == "all": show_device_status(misc_devices, "Misc (rawdev)") From patchwork Wed Nov 4 07:03:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 83655 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7C9AAA04E7; Wed, 4 Nov 2020 08:04:54 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4DBB8C814; Wed, 4 Nov 2020 08:04:02 +0100 (CET) Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) by dpdk.org (Postfix) with ESMTP id 0016EC7FA for ; Wed, 4 Nov 2020 08:03:58 +0100 (CET) Received: by mail-pg1-f171.google.com with SMTP id g12so15777990pgm.8 for ; Tue, 03 Nov 2020 23:03:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0sQzGL8TcXmEvvxZ1HAAB61ZBOoIxCoHB2bG7Yk5dL0=; b=JYoRhvqg/dEc497leNf03dQYCe5MMxc4NLw43uOk7z8x63Ie2QFyEBe4BCLehuVljt FYlRIln3+VaQbfi1bkfMdSDqPdipG9Se/8BQ7/rVG7JofSmzp2zlGJ2LoJyphGH5JlhZ nHbWihD/aJmIBUHVsQ7v7/LXw8+ixGjB9MKw0MGeY5qi11rWWGzWQVw1ESYR5REU9HEj /kSXJath+p2ONJWPyAoLKPE1OJWNzBJlURpCBoi3cydfBJwheOPgh6WhhKe4i+MGYOMC EtFAmhTNNcgBhvzAL2/dNCe9RwcL6c+2dytVmBPubsYDc8vGD//K6qo9B6hdmrsabRr1 ZHUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0sQzGL8TcXmEvvxZ1HAAB61ZBOoIxCoHB2bG7Yk5dL0=; b=bNHeg84PQ+Umj5l0hv6y7C5YqN1VWVMWogL6euuyAPlYPR/yqXGl5JujleiV3U7gef jEyvAu6vFap841q+t6IvPWIA/knL13egOEKuiTgzG5qDOmTP23GV6mgd3ZNWEqZtw5QY akQ4BP/5mmZFzmbYOs2gIBbyXo+nt+mWHlABf3khKKEaxZRmJSSZ8mmVV5Fr71/n3koB yxF3wCaxcdN+hh6mNSGxYpjUVyRgTOCYXIEw53UZP3t52Be+K38LaKm+1Gl7rXEuenb0 asujfBgpxBf3+bmHpJ2UcJHaRTrs3/LABDXv+xluGpSeOl2gvY8FHnlfAanLcf7p7/hW gjcA== X-Gm-Message-State: AOAM532k3shhDYh6cO0bUb6kIOfWY/B9r5zwYFNiRPF+OrVfjVu3Xdqx D0IgWOs3foM0EwzayeCSWBBOxM0YW35H/ybZ X-Google-Smtp-Source: ABdhPJwskW/OEIG7QOfXmyVJUSlhc4tC16pvrB2FEFTXltj7UWu5XgCA06gSiIBrpkDhVS5hnwqYlg== X-Received: by 2002:a63:9909:: with SMTP id d9mr19864071pge.360.1604473436748; Tue, 03 Nov 2020 23:03:56 -0800 (PST) Received: from hermes.corp.microsoft.com (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id z21sm1181177pfa.158.2020.11.03.23.03.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 23:03:55 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 3 Nov 2020 23:03:47 -0800 Message-Id: <20201104070350.28224-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201104070350.28224-1-stephen@networkplumber.org> References: <20200906013133.26360-12-stephen@networkplumber.org> <20201104070350.28224-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 3/6] dpdk-devbind: fix python lint warnings for imports X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Address python lint complaints about unused imports. Signed-off-by: Stephen Hemminger --- usertools/dpdk-devbind.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/usertools/dpdk-devbind.py b/usertools/dpdk-devbind.py index 3a27641d0e08..4148b66b6841 100755 --- a/usertools/dpdk-devbind.py +++ b/usertools/dpdk-devbind.py @@ -9,7 +9,7 @@ import argparse from glob import glob -from os.path import exists, abspath, dirname, basename +from os.path import exists, basename from os.path import join as path_join # The PCI base class for all devices @@ -342,7 +342,7 @@ def bind_one(dev_id, driver, force): # of unbinding those devices if driver in dpdk_drivers: filename = "/sys/bus/pci/devices/%s/driver_override" % dev_id - if os.path.exists(filename): + if exists(filename): try: f = open(filename, "w") except: @@ -405,7 +405,7 @@ def bind_one(dev_id, driver, force): # Before unbinding it, overwrite driver_override with empty string so that # the device can be bound to any other driver filename = "/sys/bus/pci/devices/%s/driver_override" % dev_id - if os.path.exists(filename): + if exists(filename): try: f = open(filename, "w") except: @@ -473,7 +473,7 @@ def bind_all(dev_list, driver, force=False): # that are not bound to any other driver could be bound even if no one has # asked them to. hence, we check the list of drivers again, and see if # some of the previously-unbound devices were erroneously bound. - if not os.path.exists("/sys/bus/pci/devices/%s/driver_override" % d): + if not exists("/sys/bus/pci/devices/%s/driver_override" % d): for d in devices.keys(): # skip devices that were already bound or that we know should be bound if "Driver_str" in devices[d] or d in dev_list: From patchwork Wed Nov 4 07:03:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 83656 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 97D6DA04E7; Wed, 4 Nov 2020 08:05:09 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1021AC820; Wed, 4 Nov 2020 08:04:04 +0100 (CET) Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by dpdk.org (Postfix) with ESMTP id 6375BC800 for ; Wed, 4 Nov 2020 08:04:00 +0100 (CET) Received: by mail-pl1-f181.google.com with SMTP id p4so2520155plr.1 for ; Tue, 03 Nov 2020 23:04:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HVmy6jIyBJ3FxEhLvU+pl0hzRKROkGn/d3GPRV8rMps=; b=RBYmDP44cfeKkhwst0B+dFIuDh+OwCQIybFt1PKEs6XuaHIfIq/zBNBTiLhiUz6Xbf 9OWhkn0fCwxRK9BMBGho31zGuDyxCUdkLsEPMb/i7em/Ey/b/QVP8c/37nm+y4V161fH +/z/Wy6bGKXhko+v+cZoCs4z2uLUk1L9/t3aSlA0ZTAAcPC11BMj+aXafWtnXawpqbsQ zHKotGus1d5oD2KnIhKPYjuy6R7iC2NTOJal2eJnXyT3b2PNbKIQrdHCIyv1tmZ5YHno 05MfTFc+R4DAKtFGGlPglFnCsnVzZyLBNaeDhTEwR6EKwoerm0uUjVaFLXNTpUf8Okcv b79g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HVmy6jIyBJ3FxEhLvU+pl0hzRKROkGn/d3GPRV8rMps=; b=bT4DSrqvMLJxnDqPubBfpaMqge+ZPwxfjI7XvAbMaq956COZeTGrEo9hag6XgvaXhq PO7/TndQO4GpUSkh2gia5M9FYMoFAU0SuLv/rMJVnBaLp7Ss3YvdMujnorq+xuSuIR/1 CC32eB53g9FlEYpJd2bK3TrnnWe47HoEKq+9XrtHRy8u+kNtt3EacHef6MtCCebNEwN/ snl7kcDchJQZGgG3cA7gHpjeDAw0+ERUx9hgnw2b0gS7A+ngwK4RSrxgvv/06xltvXC4 8Op7mgOSInMC3uBz8sFmD5uWw4Ip2+AYKYSEFKsfRWOXZQRTxd4udr7F/DazpchwRsVM iy8g== X-Gm-Message-State: AOAM531BSnJVatkmYfkzOwEzavt83qvxk2YgqvFyvh91K5t/e9PXQX1g /17sCoFwyv3qQ1xF05K4FJnZSF/X6lm0HlN5 X-Google-Smtp-Source: ABdhPJyGXOWSoKHRStYeH2Lyv2SKf8wgV5sv5w93OlUblzsxkHfeCSJFkIKz9t2hkMiXmMNeOkVGrQ== X-Received: by 2002:a17:902:82c3:b029:d6:c377:c87d with SMTP id u3-20020a17090282c3b02900d6c377c87dmr14917077plz.37.1604473438098; Tue, 03 Nov 2020 23:03:58 -0800 (PST) Received: from hermes.corp.microsoft.com (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id z21sm1181177pfa.158.2020.11.03.23.03.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 23:03:57 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 3 Nov 2020 23:03:48 -0800 Message-Id: <20201104070350.28224-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201104070350.28224-1-stephen@networkplumber.org> References: <20200906013133.26360-12-stephen@networkplumber.org> <20201104070350.28224-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 4/6] dpdk-devbind: do not use len(x) to test for empty X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Python lint warns about using len(SEQUENCE) to determine if sequence is empty. Signed-off-by: Stephen Hemminger --- usertools/dpdk-devbind.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/usertools/dpdk-devbind.py b/usertools/dpdk-devbind.py index 4148b66b6841..afe93a217d79 100755 --- a/usertools/dpdk-devbind.py +++ b/usertools/dpdk-devbind.py @@ -143,7 +143,7 @@ def get_pci_device_details(dev_id, probe_lspci): extra_info = subprocess.check_output(["lspci", "-vmmks", dev_id]).splitlines() # parse lspci details for line in extra_info: - if len(line) == 0: + if not line: continue name, value = line.decode("utf8").split("\t", 1) name = name.strip(":") + "_str" @@ -178,7 +178,7 @@ def get_device_details(devices_type): dev = {} dev_lines = subprocess.check_output(["lspci", "-Dvmmnnk"]).splitlines() for dev_line in dev_lines: - if len(dev_line) == 0: + if not dev_line: if device_type_match(dev, devices_type): # Replace "Driver" with "Driver_str" to have consistency of # of dictionary key names @@ -193,7 +193,7 @@ def get_device_details(devices_type): else: name, value = dev_line.decode("utf8").split("\t", 1) value_list = value.rsplit(' ', 1) - if len(value_list) > 1: + if value_list: # String stored in _str dev[name.rstrip(":") + '_str'] = value_list[0] # Numeric IDs @@ -496,7 +496,7 @@ def display_devices(title, dev_list, extra_params=None): strings = [] # this holds the strings to print. We sort before printing print("\n%s" % title) print("="*len(title)) - if len(dev_list) == 0: + if not dev_list: strings.append("") else: for dev in dev_list: @@ -539,17 +539,17 @@ def show_device_status(devices_type, device_name, if_field=False): return # print each category separately, so we can clearly see what's used by DPDK - if len(dpdk_drv) != 0: + if dpdk_drv: 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: + if kernel_drv: if_text = "" if if_field: if_text = "if=%(Interface)s " display_devices("%s devices using kernel driver" % device_name, kernel_drv, if_text + "drv=%(Driver_str)s " "unused=%(Module_str)s %(Active)s") - if len(no_drv) != 0: + if no_drv: display_devices("Other %s devices" % device_name, no_drv, "unused=%(Module_str)s") From patchwork Wed Nov 4 07:03:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 83657 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 53708A04E7; Wed, 4 Nov 2020 08:05:36 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E81B7C83A; Wed, 4 Nov 2020 08:04:05 +0100 (CET) Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) by dpdk.org (Postfix) with ESMTP id 9DF75C81A for ; Wed, 4 Nov 2020 08:04:01 +0100 (CET) Received: by mail-pg1-f196.google.com with SMTP id i7so13845304pgh.6 for ; Tue, 03 Nov 2020 23:04:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=O0hDDPqJ1rsd2SwIvXX4b+gAgam1T4WP0pY3Y22C0tg=; b=UroUDCQW7wPSaOuYWSQx7ohSl41y4aVWBK9gCZpcHdzSWmXv/UV/w4RoWKkgYjIeId YWk+s7JFqe/On8VxHy/uIi7rEG/79MhYhOy2J1d3P3cnN9MgkOr2wuncKIKMZ1YPUHsb H9n2QsjsqxaFjYBZnLSDD4P2ymExP73MBeaRrF9EBWpAxWCAg/3kIwsOzJru/BKcN5u6 2dRia9pxMTwwbd4SsYh80GWYadfknjMSIg9LdDvbIHtTGQN3LHN5JEdK/C1uG05lYvHN Aa2u/Ic7uMUXLL0iSF7g69C0v5wfY51K2+/MLugjy1i+ulr/LNAP7hKQYZkY7Wo9XY0m GwZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=O0hDDPqJ1rsd2SwIvXX4b+gAgam1T4WP0pY3Y22C0tg=; b=fm1aPVfxeXE6qPB8wdVTe1I6JmabVrcAYHFkHBBh+qicdNeyVRBUiQOQkcBLVyS2Mo Z7MVPH5hkMRhUCI2vAUkDYpK4X2FiudJF825FXqTUdhUQWVdUMVJArFB3oFXL7OEP6F1 XAUi/FHaNw9MvQm+bVX0BVDFnq02RulE+DRd0y+H40PDOK1o0umKZhZRGHEVC+nOvklh bTjhfTiGcJ51SYu36fSdkSfCszhrYikKnwKzmsXlJl9+uzVdBU2Xg5X+sgYpaTru2+KF 6xaqd6eD/rygEIqgX8hLizsYsuqzO9nnmKQiQPx6QlVgxthPqRPFCYozajIgvlMsAX8z NLFA== X-Gm-Message-State: AOAM5315nMrUo20chRt1Zx93HN6F6eYQgOZIA6SS4HqGlcJNDf50B+7E 1zPt6T50hd1SW6I2ViCdYxPDzC10nvnqI4Oq X-Google-Smtp-Source: ABdhPJx1NLMsjoBDJxSRAKOQIV7/OvVix4pmkLS4dNZvrwFnZJ8TqQdcCgG/LGTbYHUHbb+B5XFOKQ== X-Received: by 2002:a17:90a:1546:: with SMTP id y6mr2920386pja.167.1604473439422; Tue, 03 Nov 2020 23:03:59 -0800 (PST) Received: from hermes.corp.microsoft.com (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id z21sm1181177pfa.158.2020.11.03.23.03.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 23:03:58 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 3 Nov 2020 23:03:49 -0800 Message-Id: <20201104070350.28224-6-stephen@networkplumber.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201104070350.28224-1-stephen@networkplumber.org> References: <20200906013133.26360-12-stephen@networkplumber.org> <20201104070350.28224-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 5/6] dpdk-devbind: fix unnecessary else after return X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Python lint complains about Unnecessary "else" after "return" (no-else-return) Signed-off-by: Stephen Hemminger --- usertools/dpdk-devbind.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/usertools/dpdk-devbind.py b/usertools/dpdk-devbind.py index afe93a217d79..47373e27bd74 100755 --- a/usertools/dpdk-devbind.py +++ b/usertools/dpdk-devbind.py @@ -274,13 +274,13 @@ def dev_id_from_dev_name(dev_name): if dev_name in devices: return dev_name # check if it's an index just missing the domain part - elif "0000:" + dev_name in devices: + if "0000:" + dev_name in devices: return "0000:" + dev_name - else: - # check if it's an interface name, e.g. eth1 - for d in devices.keys(): - if dev_name in devices[d]["Interface"].split(","): - return devices[d]["Slot"] + + # check if it's an interface name, e.g. eth1 + for d in devices.keys(): + if dev_name in devices[d]["Interface"].split(","): + return devices[d]["Slot"] # if nothing else matches - error raise ValueError("Unknown device: %s. " "Please specify device in \"bus:slot.func\" format" % dev_name) @@ -329,10 +329,9 @@ def bind_one(dev_id, driver, force): print("Notice: %s already bound to driver %s, skipping" % (dev_id, driver), file=sys.stderr) return - else: - saved_driver = dev["Driver_str"] - unbind_one(dev_id, force) - dev["Driver_str"] = "" # clear driver string + saved_driver = dev["Driver_str"] + unbind_one(dev_id, force) + dev["Driver_str"] = "" # clear driver string # For kernels >= 3.15 driver_override can be used to specify the driver # for a device rather than relying on the driver to provide a positive From patchwork Wed Nov 4 07:03:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 83658 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B7E7EA04E7; Wed, 4 Nov 2020 08:05:54 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2F25CC848; Wed, 4 Nov 2020 08:04:07 +0100 (CET) Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by dpdk.org (Postfix) with ESMTP id CB891C81C for ; Wed, 4 Nov 2020 08:04:01 +0100 (CET) Received: by mail-pf1-f194.google.com with SMTP id 10so16529824pfp.5 for ; Tue, 03 Nov 2020 23:04:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ssx7rkqCID6yWPtFHHoaUynqyCRsHtvcuTNn18C7qCE=; b=pRshjgmPQl3siNCmWT8pbHpZTIZoRTXeQvK10v6/Tt3KKRIQ8NmqcKNCKbpLFUqzbH hksGoW1fw+fAHylgfVnBFryYcX2UK2jVAu7kkvcLRWeHVDDAIisZYWqPANK8q4UeQpXA 4sdQBlQ4qeYXrQbMa/IvHpgWyY4V13TNQyAHyAx4pimj++35vQ5LhS8GWNcwsQc4iISr OTTZtlvhd/EroP/QwJu0A7fVL0tdC37sG++ae/sMDIi5zGSSJHMnI9mlgbby+eH6y3KC yls0D+TKidVCpN1gpd7I/w7+aYszTuIc4Yyl/Miq8kH3n0WMQyP5/k8EOLoav57FctBU JAzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ssx7rkqCID6yWPtFHHoaUynqyCRsHtvcuTNn18C7qCE=; b=ShdwXTxRo5CMmqtDFWLTquND9I1OqYdYEKN7UoMi1HUVRAPJ508jVFjkv8rMzzUdQe idX4oB1Qsu708SYdXGrtRpO6ai2bb1kltpDNGMbw4I7LkFYs3S9K7d5Nm2XD9NMV3al/ VUEtFzU3IsFpEQFdndYewp3ORdspEUj4T065xSB7Gncx0S71iVAYYXyAeXbVqshkYZ+4 drBrcM8mJgRhBocH4SHOIsnT+FRHeyC9Wq3WywOrOctVcKh5BOLJQNGIiBBmqmBFujWh fYWNj5fxeHRS6AX/8xif3Vg+yHFsZD8yoyNx/IoVIn74qkYIFDsYbjkrDlNAj43QJnFg GM0w== X-Gm-Message-State: AOAM532WHG3eZy+zACg+NpWoeibpqy2hrCLjnYW8uNkwmVMkV45exZ1y kqj1Y2ZL8bYjH3QNP/pmsvjS3xxnJNjeqR8Z X-Google-Smtp-Source: ABdhPJx9EUitgcdgy/3fV67h0J+78uYTt9rlcfpsqlkCTJCmfDr/NHMcSaHC/Lc7MxWkw4p2GuiVlw== X-Received: by 2002:a62:7a8d:0:b029:160:9e0:5ff6 with SMTP id v135-20020a627a8d0000b029016009e05ff6mr30425444pfc.52.1604473440688; Tue, 03 Nov 2020 23:04:00 -0800 (PST) Received: from hermes.corp.microsoft.com (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id z21sm1181177pfa.158.2020.11.03.23.03.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 23:03:59 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 3 Nov 2020 23:03:50 -0800 Message-Id: <20201104070350.28224-7-stephen@networkplumber.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201104070350.28224-1-stephen@networkplumber.org> References: <20200906013133.26360-12-stephen@networkplumber.org> <20201104070350.28224-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 6/6] dpdk-devbind: use in to test for multiple strings X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Python lint suggests using in instead of multiple comparisons. Signed-off-by: Stephen Hemminger --- usertools/dpdk-devbind.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/usertools/dpdk-devbind.py b/usertools/dpdk-devbind.py index 47373e27bd74..054ad2e1cfbd 100755 --- a/usertools/dpdk-devbind.py +++ b/usertools/dpdk-devbind.py @@ -557,28 +557,28 @@ def show_status(): Displays to the user what devices are bound to the igb_uio driver, the kernel driver or to no driver''' - if status_dev == "net" or status_dev == "all": + if status_dev in ["net", "all"]: show_device_status(network_devices, "Network", if_field=True) - if status_dev == "baseband" or status_dev == "all": + if status_dev in ["baseband", "all"]: show_device_status(baseband_devices, "Baseband") - if status_dev == "crypto" or status_dev == "all": + if status_dev in ["crypto", "all"]: show_device_status(crypto_devices, "Crypto") - if status_dev == "event" or status_dev == "all": + if status_dev in ["event", "all"]: show_device_status(eventdev_devices, "Eventdev") - if status_dev == "mempool" or status_dev == "all": + if status_dev in ["mempool", "all"]: show_device_status(mempool_devices, "Mempool") - if status_dev == "compress" or status_dev == "all": + if status_dev in ["compress", "all"]: show_device_status(compress_devices, "Compress") - if status_dev == "misc" or status_dev == "all": + if status_dev in ["misc", "all"]: show_device_status(misc_devices, "Misc (rawdev)") - if status_dev == "regex" or status_dev == "all": + if status_dev in ["regex", "all"]: show_device_status(regex_devices, "Regex") @@ -703,7 +703,7 @@ def do_arg_actions(): global force_flag global args - if b_flag == "none" or b_flag == "None": + if b_flag in ["none", "None"]: unbind_all(args, force_flag) elif b_flag is not None: bind_all(args, b_flag, force_flag)