[dpdk-dev] [PATCH v2 6/7] dpdk-pmdinfo: replace deprecated optparse with argparse
Jiang, YuX
yux.jiang at intel.com
Tue Nov 24 07:35:54 CET 2020
Hi Hemminger,
Latest "dpdk-devbind.py --status-dev" just can support {net,baseband,crypto,event,mempool,compress} devices,
But can not support show Misc devices, can you fix it or provide new method to show?
Notes: Old dpdk-devbind.py can support show cbdma device by cmd " ./usertools/dpdk-devbind.py --status-dev misc "
Trace Log:
root at dpdk-yaobing-purely147:~/dpdk# ./usertools/dpdk-devbind.py --status-dev misc
usage: dpdk-devbind.py [-h] [-s]
[--status-dev {net,baseband,crypto,event,mempool,compress}]
[-b DRIVER | -u] [--force]
[DEVICE [DEVICE ...]]
dpdk-devbind.py: error: argument --status-dev: invalid choice: 'misc' (choose from 'net', 'baseband', 'crypto', 'event', 'mempool', 'compress')
root at dpdk-yaobing-purely147:~/dpdk# ./usertools/dpdk-devbind.py -s
Misc (rawdev) devices using kernel driver
=========================================
0000:00:04.0 'Sky Lake-E CBDMA Registers 2021' drv=ioatdma unused=vfio-pci
Best Regards
Jiang yu
> -----Original Message-----
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Stephen
> Hemminger
> Sent: Wednesday, November 4, 2020 2:49 PM
> To: nhorman at tuxdriver.com
> Cc: dev at dpdk.org; Stephen Hemminger <stephen at networkplumber.org>
> Subject: [dpdk-dev] [PATCH v2 6/7] dpdk-pmdinfo: replace deprecated
> optparse with argparse
>
> The optparse module is deprecated and replaced with new argparse.
> The code now enforces the rule that only one of the output formats can be
> specified: raw or json.
>
> Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
> ---
> usertools/dpdk-pmdinfo.py | 70 ++++++++++++++++++---------------------
> 1 file changed, 32 insertions(+), 38 deletions(-)
>
> diff --git a/usertools/dpdk-pmdinfo.py b/usertools/dpdk-pmdinfo.py index
> aec2abe9a683..1c2c3d05fea6 100755
> --- a/usertools/dpdk-pmdinfo.py
> +++ b/usertools/dpdk-pmdinfo.py
> @@ -11,10 +11,11 @@
> import os
> import platform
> import sys
> +import argparse
> from elftools.common.exceptions import ELFError from
> elftools.common.py3compat import byte2int from elftools.elf.elffile import
> ELFFile -from optparse import OptionParser
> +
>
> # For running from development directory. It should take precedence over
> the # installed pyelftools.
> @@ -563,56 +564,49 @@ def main(stream=None):
> if not os.path.exists(pcifile_default):
> pcifile_default = "/usr/share/misc/pci_vendors"
>
> - optparser = OptionParser(
> - usage='usage: %prog [-hrtp] [-d <pci id file] <elf-file>',
> - description="Dump pmd hardware support info",
> - add_help_option=True)
> - optparser.add_option('-r', '--raw',
> - action='store_true', dest='raw_output',
> - help='Dump raw json strings')
> - optparser.add_option("-d", "--pcidb", dest="pcifile",
> - help="specify a pci database "
> - "to get vendor names from",
> - default=pcifile_default, metavar="FILE")
> - optparser.add_option("-t", "--table", dest="tblout",
> - help="output information on hw support as a "
> - "hex table",
> - action='store_true')
> - optparser.add_option("-p", "--plugindir", dest="pdir",
> - help="scan dpdk for autoload plugins",
> - action='store_true')
> -
> - options, args = optparser.parse_args()
> -
> - if options.raw_output:
> + parser = argparse.ArgumentParser(
> + usage='usage: %(prog)s [-hrtp] [-d <pci id file>] elf_file',
> + description="Dump pmd hardware support info")
> + group = parser.add_mutually_exclusive_group()
> + group.add_argument('-r', '--raw',
> + action='store_true', dest='raw_output',
> + help='dump raw json strings')
> + group.add_argument("-t", "--table", dest="tblout",
> + help="output information on hw support as a hex table",
> + action='store_true')
> + parser.add_argument("-d", "--pcidb", dest="pcifile",
> + help="specify a pci database to get vendor names from",
> + default=pcifile_default, metavar="FILE")
> + parser.add_argument("-p", "--plugindir", dest="pdir",
> + help="scan dpdk for autoload plugins",
> + action='store_true')
> + parser.add_argument("elf_file", help="driver shared object file")
> + args = parser.parse_args()
> +
> + if args.raw_output:
> raw_output = True
>
> - if options.pcifile:
> - pcidb = PCIIds(options.pcifile)
> + if args.tblout:
> + args.pcifile = None
> +
> + if args.pcifile:
> + pcidb = PCIIds(args.pcifile)
> if pcidb is None:
> print("Pci DB file not found")
> exit(1)
>
> - if options.tblout:
> - options.pcifile = None
> - pcidb = None
> -
> - if len(args) == 0:
> - optparser.print_usage()
> - exit(1)
> -
> - if options.pdir:
> + if args.pdir:
> exit(scan_for_autoload_pmds(args[0]))
>
> ldlibpath = os.environ.get('LD_LIBRARY_PATH')
> if ldlibpath is None:
> ldlibpath = ""
>
> - if os.path.exists(args[0]):
> - myelffile = args[0]
> + if os.path.exists(args.elf_file):
> + myelffile = args.elf_file
> else:
> - myelffile = search_file(
> - args[0], ldlibpath + ":/usr/lib64:/lib64:/usr/lib:/lib")
> + myelffile = search_file(args.elf_file,
> + ldlibpath +
> + ":/usr/lib64:/lib64:/usr/lib:/lib")
>
> if myelffile is None:
> print("File not found")
> --
> 2.27.0
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: dpdk-devbind-cmd.txt
URL: <http://mails.dpdk.org/archives/dev/attachments/20201124/a5d851d3/attachment.txt>
More information about the dev
mailing list