From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id A4644A04B1; Mon, 24 Aug 2020 19:05:18 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7CFDE2B96; Mon, 24 Aug 2020 19:05:18 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id A2F31DE3 for ; Mon, 24 Aug 2020 19:05:16 +0200 (CEST) IronPort-SDR: KOdlNnfGkLVqEnpB3rrPW2IbypldXNmoA+/IRFAHJNg9p69g0XA8uU5s6QDg0pMjLmVOJAPyWv DSHXIO5TwFeg== X-IronPort-AV: E=McAfee;i="6000,8403,9723"; a="240767656" X-IronPort-AV: E=Sophos;i="5.76,349,1592895600"; d="scan'208";a="240767656" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Aug 2020 10:05:13 -0700 IronPort-SDR: 9q9iLepV8qZ34cOmGxzhi0x+D1gHZq5/w0a/nM+KdwGCFNucc9BDgN0zTmZbnqbLH9PLx/YX4U 7csw23mb4K2Q== X-IronPort-AV: E=Sophos;i="5.76,349,1592895600"; d="scan'208";a="443292950" Received: from bricha3-mobl.ger.corp.intel.com ([10.252.20.200]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-SHA; 24 Aug 2020 10:05:11 -0700 Date: Mon, 24 Aug 2020 18:05:08 +0100 From: Bruce Richardson To: "Burakov, Anatoly" Cc: dev@dpdk.org, Ferruh Yigit Message-ID: <20200824170508.GC547@bricha3-MOBL.ger.corp.intel.com> References: <20200820154308.3212-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [dpdk-dev] [PATCH v2] usertools/dpdk-devbind: add support for PCI wildcards 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" On Fri, Aug 21, 2020 at 10:14:19AM +0100, Burakov, Anatoly wrote: > On 20-Aug-20 4:43 PM, Bruce Richardson wrote: > > When binding or unbinding a range of devices, it can be useful to use > > wildcards to specify the devices rather than repeating the same prefix > > multiple times. We can use the python "glob" module to give us this > > functionality - at least for PCI devices - by checking /sys for matching > > files. > > > > Examples of use from my system: > > > > ./dpdk-devbind.py -b vfio-pci 80:04.* > > ./dpdk-devbind.py -u 80:04.[2-7] > > > > The first example binds eight devices, 80:04.0..80:04.7, to vfio-pci. The > > second then unbinds six of those devices, 80:04.2..80:04.7, from any > > driver. > > > > Signed-off-by: Bruce Richardson > > Tested-by: Ferruh Yigit > > --- > > V2: added help text additions > > --- > > usertools/dpdk-devbind.py | 16 ++++++++++++++++ > > 1 file changed, 16 insertions(+) > > > > diff --git a/usertools/dpdk-devbind.py b/usertools/dpdk-devbind.py > > index 86b6b53c40..d13defbe1a 100755 > > --- a/usertools/dpdk-devbind.py > > +++ b/usertools/dpdk-devbind.py > > @@ -8,6 +8,7 @@ > > import os > > import getopt > > import subprocess > > +from glob import glob > > from os.path import exists, abspath, dirname, basename > > if sys.version_info.major < 3: > > @@ -89,6 +90,8 @@ def usage(): > > 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: > > @@ -145,6 +148,9 @@ def usage(): > > 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 funcions on device 0000:02:00 to ixgbe kernel driver > > + %(argv0)s -b ixgbe 02:00.* > > + > > """ % locals()) # replace items from local variables > > @@ -689,6 +695,16 @@ def parse_args(): > > else: > > b_flag = arg > > + # resolve any PCI globs in the args > > + new_args = [] > > + sysfs_path = "/sys/bus/pci/devices/" > > + for arg in args: > > + globbed_arg = glob(sysfs_path + arg) + glob(sysfs_path + "0000:" + arg) > > os.path.join()? > > > + if globbed_arg: > > + new_args.extend([a[len(sysfs_path):] for a in globbed_arg]) > > os.path.basename()? > These are used in V4.