From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2C2BEA0547; Fri, 28 May 2021 15:35:01 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9E3E440143; Fri, 28 May 2021 15:35:00 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id C28FE40040 for ; Fri, 28 May 2021 15:34:58 +0200 (CEST) IronPort-SDR: UftQgpqcTXFetd5LqMoWcyzMTkt8SkIoSB86jOD227whdu5zNrn1upOnNLg/XyMLKVWAAh1HcD zb3DEZ98xxXA== X-IronPort-AV: E=McAfee;i="6200,9189,9998"; a="190328087" X-IronPort-AV: E=Sophos;i="5.83,229,1616482800"; d="scan'208";a="190328087" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2021 06:34:57 -0700 IronPort-SDR: lNA/2kzRWrU8Wt89E/tc/q3oS0E2/FsJoh53le+v05tk6P7u3M3n1hKvTGMxi6OGyyfUve8hyg 6Cz3QC2NnjUA== X-IronPort-AV: E=Sophos;i="5.83,229,1616482800"; d="scan'208";a="477929989" Received: from bricha3-mobl.ger.corp.intel.com ([10.252.7.179]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-SHA; 28 May 2021 06:34:56 -0700 Date: Fri, 28 May 2021 14:34:51 +0100 From: Bruce Richardson To: Kevin Laatz Cc: dev@dpdk.org Message-ID: References: <20210527132646.3565721-1-kevin.laatz@intel.com> <20210528131902.344423-1-kevin.laatz@intel.com> <20210528131902.344423-2-kevin.laatz@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210528131902.344423-2-kevin.laatz@intel.com> Subject: Re: [dpdk-dev] [PATCH v2 1/2] raw/ioat: add pci address handling to python script X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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, May 28, 2021 at 02:19:01PM +0100, Kevin Laatz wrote: > Currently the user needs to find the DSA instance number for any DSA device > they would like to configure using this script, which can be cumbersome and > error-prone since the instance numbering changes when changing the binding > of the devices between vfio-pci and idxd. > s/changes/may change/ I've found a number of times that after unbinding and rebinding a device the number did not change. > This patch improved the usability of the script by adding the ability to s/improved/improves/ > specify the DSA device to configure using the device's PCI address instead > of the DSA instance number. For example, "$dpdk_idxd_cfg.py 0" and > "$dpdk_idxd_cfg.py 6a:01.0" are both valid references to the same device > (assuming the numbering). > > Signed-off-by: Kevin Laatz > With the above minor commit-log tweaks Acked-by: Bruce Richardson > --- > v2: > - split the device reset change into its own patch > - changed sysfs dir search > - improved error case handling > --- > drivers/raw/ioat/dpdk_idxd_cfg.py | 28 ++++++++++++++++++++++++++-- > 1 file changed, 26 insertions(+), 2 deletions(-) > > diff --git a/drivers/raw/ioat/dpdk_idxd_cfg.py b/drivers/raw/ioat/dpdk_idxd_cfg.py > index ff06d9e240..ad8393a645 100755 > --- a/drivers/raw/ioat/dpdk_idxd_cfg.py > +++ b/drivers/raw/ioat/dpdk_idxd_cfg.py > @@ -29,6 +29,26 @@ def write_values(self, values): > f.write(str(contents)) > > > +def get_pci_dir(pci): > + "Search for the sysfs directory of the PCI device" > + base_dir = '/sys/bus/pci/devices/' > + for path, dirs, files in os.walk(base_dir): > + for dir in dirs: > + if pci in dir: > + return os.path.join(base_dir, dir) > + sys.exit(f"Could not find sysfs directory for device {pci}") > + > + > +def get_dsa_id(pci): > + "Get the DSA instance ID using the PCI address of the device" > + pci_dir = get_pci_dir(pci) > + for path, dirs, files in os.walk(pci_dir): > + for dir in dirs: > + if dir.startswith('dsa') and 'wq' not in dir: > + return int(dir[3:]) > + sys.exit(f"Could not get device ID for device {pci}") > + > + > def configure_dsa(dsa_id, queues, prefix): > "Configure the DSA instance with appropriate number of queues" > dsa_dir = SysfsDir(f"/sys/bus/dsa/devices/dsa{dsa_id}") > @@ -68,14 +88,18 @@ def main(args): > "Main function, does arg parsing and calls config function" > arg_p = argparse.ArgumentParser( > description="Configure whole DSA device instance for DPDK use") > - arg_p.add_argument('dsa_id', type=int, help="DSA instance number") > + arg_p.add_argument('dsa_id', > + help="Specify DSA instance either via DSA instance number or PCI address") > arg_p.add_argument('-q', metavar='queues', type=int, default=255, > help="Number of queues to set up") > arg_p.add_argument('--name-prefix', metavar='prefix', dest='prefix', > default="dpdk", > help="Prefix for workqueue name to mark for DPDK use [default: 'dpdk']") > parsed_args = arg_p.parse_args(args[1:]) > - configure_dsa(parsed_args.dsa_id, parsed_args.q, parsed_args.prefix) > + > + dsa_id = parsed_args.dsa_id > + dsa_id = get_dsa_id(dsa_id) if ':' in dsa_id else dsa_id > + configure_dsa(dsa_id, parsed_args.q, parsed_args.prefix) > > > if __name__ == "__main__": > -- > 2.30.2 >