Commit Graph

118 Commits

Author SHA1 Message Date
Thomas Monjalon
b41bd04636 usertools/hugepages: show usage if no action specified
Previously, the script was doing nothing if no argument was provided.

If neither show, mount/unmount, clear/reserve are specified,
it is assumed that the user does not know how to use the script.
So the usage and an error message are printed.
The exit code will be non-zero.
The user will understand something is wrong,
and can recall the script with the option -h to get more information.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: David Marchand <david.marchand@redhat.com>
2022-11-22 16:42:07 +01:00
Chengwen Feng
66542840df usertools/telemetry: add JSON pretty print
Currently, the dpdk-telemetry.py show JSON in raw format under
interactive mode, which is not good for human reading.

E.g. The command '/ethdev/xstats,0' will output:
{"/ethdev/xstats": {"rx_good_packets": 0, "tx_good_packets": 0,
"rx_good_bytes": 0, "tx_good_bytes": 0, "rx_missed_errors": 0,
"rx_errors": 0, "tx_errors": 0, "rx_mbuf_allocation_errors": 0,
"rx_q0_packets": 0,...}}

This patch supports JSON pretty print by adding extra indent=2
parameter under interactive mode, so the same command will output:
{
  "/ethdev/xstats": {
    "rx_good_packets": 0,
    "tx_good_packets": 0,
    "rx_good_bytes": 0,
    "tx_good_bytes": 0,
    "rx_missed_errors": 0,
    "rx_errors": 0,
    "rx_mbuf_allocation_errors": 0,
    "rx_q0_packets": 0,
    ...
  }
}

Note: the non-interactive mode is made machine-readable and remains the
original way (it means don't use indent to pretty print).

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Acked-by: David Marchand <david.marchand@redhat.com>
Acked-by: Ciara Power <ciara.power@intel.com>
Tested-by: Bruce Richardson <bruce.richardson@intel.com>
2022-10-31 16:13:55 +01:00
Robin Jarry
0ce3cf4afd usertools/pmdinfo: rewrite simpler script
dpdk-pmdinfo.py does not produce any parseable output. The -r/--raw flag
merely prints multiple independent JSON lines which cannot be fed
directly to any JSON parser. Moreover, the script complexity is rather
high for such a simple task: extracting PMD_INFO_STRING from .rodata ELF
sections. Rewrite it so that it can produce valid JSON.

Remove the PCI database parsing for PCI-ID to Vendor-Device names
conversion. This should be done by external scripts (if really needed).

The script passes flake8, black, isort and pylint checks.

I have tested this with a matrix of python/pyelftools versions:

                                 pyelftools
               0.22  0.23  0.24  0.25  0.26  0.27  0.28  0.29
        3.6      ok    ok    ok    ok    ok    ok    ok    ok
        3.7      ok    ok    ok    ok    ok    ok    ok    ok
 Python 3.8      ok    ok    ok    ok    ok    ok    ok    ok
        3.9      ok    ok    ok    ok    ok   *ok    ok    ok
        3.10   fail  fail  fail  fail    ok    ok    ok    ok

                                     * Also tested on FreeBSD

All failures with python 3.10 are related to the same issue:

  File "elftools/construct/lib/container.py", line 5, in <module>
    from collections import MutableMapping
  ImportError: cannot import name 'MutableMapping' from 'collections'

Python 3.10 support is only available since pyelftools 0.26. The script
will only work with Python 3.6 and later.

Update the minimal system requirements, docs and release notes.

Signed-off-by: Robin Jarry <rjarry@redhat.com>
Tested-by: Ferruh Yigit <ferruh.yigit@amd.com>
Tested-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
2022-10-11 02:11:33 +02:00
Dmitry Kozlyuk
8d73de6f7f usertools: add options for hugetlbfs mount point owner
Per mount(8), the previous owner and mode of the mount point
become invisible as long as this filesystem remains mounted.
Because dpdk-hugepages.py must be run as root,
the new owner would be root.
This is undesirable if the hugepage directory is being set up
by the administrator for an unprivileged user.
HugeTLB filesystem has options to set the mount point owner.
Add --user/-U and --group/-G options to apply this when mounting.
The benefit of performing this in dpdk-hugepages.py
is that the user does not need to care about this detail
of mount command operation.

Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
2022-06-27 02:24:12 +02:00
Dmitry Kozlyuk
31af02ef6f usertools: add option for hugetlbfs directory
dpdk-hugepages.py had /dev/hugepages hardcoded as the mount point.
It may be desirable to setup hugepage directory at another path,
for example, when using hugepages of multiple sizes in different
directories or when granting different permissions to mount points.
Add --directory/-d option to the script.

Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
2022-06-27 02:24:06 +02:00
Andy Pei
1216ac76d5 usertools/devbind: support virtio block device
Add virtio blk device support to devbind.

Signed-off-by: Andy Pei <andy.pei@intel.com>
Acked-by: Chenbo Xia <chenbo.xia@intel.com>
2022-06-01 11:50:10 +02:00
Stephen Hemminger
1835a22f34 support systemd service convention for runtime directory
Systemd.exec supports configuring the runtime directory of a service
via RuntimeDirectory=. This creates the directory with the necessary
permissions which actual service may not have if running in container.

The change to DPDK is to look for the environment RUNTIME_DIRECTORY
first and use that in preference to the fallback alternatives.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Reviewed-by: Morten Brørup <mb@smartsharesystems.com>
2022-02-09 19:12:40 +01:00
Jerin Jacob
33e71acf3d drivers: remove octeontx2 drivers
As per the deprecation notice,  In the view of enabling unified driver
for octeontx2(cn9k)/octeontx3(cn10k), removing drivers/octeontx2
drivers and replace with drivers/cnxk/ which
supports both octeontx2(cn9k) and octeontx3(cn10k) SoCs.

This patch does the following

- Replace drivers/common/octeontx2/ with drivers/common/cnxk/
- Replace drivers/mempool/octeontx2/ with drivers/mempool/cnxk/
- Replace drivers/net/octeontx2/ with drivers/net/cnxk/
- Replace drivers/event/octeontx2/ with drivers/event/cnxk/
- Replace drivers/crypto/octeontx2/ with drivers/crypto/cnxk/
- Rename config/arm/arm64_octeontx2_linux_gcc as
  config/arm/arm64_cn9k_linux_gcc
- Update the documentation and MAINTAINERS to reflect the same.
- Change the reference to OCTEONTX2 as OCTEON 9. Old release notes and
the kernel related documentation is not accounted for this change.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Akhil Goyal <gakhil@marvell.com>
Acked-by: Ruifeng Wang <ruifeng.wang@arm.com>
2022-01-12 15:36:32 +01:00
Radha Mohan Chintakuntla
2ff801515e usertools/devbind: update octeontx2 DMA device
The octeontx2_dma rawdev driver is removed in DPDK-21.11. The new driver
for the same device uses the dmadev. So this patch updates the device
naming and lists it under dma devices section.

Signed-off-by: Radha Mohan Chintakuntla <radhac@marvell.com>
2021-11-10 14:15:39 +01:00
Chengwen Feng
fb73eb2fb1 usertools/devbind: add Kunpeng DMA
Add Kunpeng DMA device ID to dmadev category.

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
2021-11-07 20:04:28 +01:00
Stephen Hemminger
62d3ce6043 usertools/devbind: conform to PEP8 recommended style
This fixes most of the warnings from the Flake8 style checker.
The ones remaining are long lines (we allow > 79 characters)
and a line break warning.  The line break style changed in later
versions of PEP 8 and the tool is not updated.

https://www.flake8rules.com/rules/W503.html

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Tested-by: Bruce Richardson <bruce.richardson@intel.com>
2021-10-25 22:31:53 +02:00
David Marchand
4976250ea8 usertools/pmdinfo: fix plugin auto scan
Migration to argparse was incomplete.

$ dpdk-pmdinfo.py -p $(which dpdk-testpmd)
Traceback (most recent call last):
  File "/usr/bin/dpdk-pmdinfo.py", line 626, in <module>
    main()
  File "/usr/bin/dpdk-pmdinfo.py", line 596, in main
    exit(scan_for_autoload_pmds(args[0]))
TypeError: 'Namespace' object does not support indexing

Fixes: 81255f27c6 ("usertools: replace optparse with argparse")
Cc: stable@dpdk.org

Signed-off-by: David Marchand <david.marchand@redhat.com>
Reviewed-by: Robin Jarry <robin.jarry@6wind.com>
2021-10-25 17:09:01 +02:00
Conor Walsh
e6f6dda60a usertools/devbind: move ioat device IDs to DMA class
Move Intel IOAT devices from Misc to DMA devices.

Signed-off-by: Conor Walsh <conor.walsh@intel.com>
Reviewed-by: Kevin Laatz <kevin.laatz@intel.com>
Reviewed-by: Bruce Richardson <bruce.richardson@intel.com>
2021-10-22 22:40:59 +02:00
Kevin Laatz
db7f9ec2f1 usertools/devbind: move idxd device ID to DMA class
The dmadev library is the preferred abstraction for using IDXD devices and
will replace the rawdev implementation in future. This patch moves the IDXD
device ID to the dmadev class.

Signed-off-by: Kevin Laatz <kevin.laatz@intel.com>
Reviewed-by: Conor Walsh <conor.walsh@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
2021-10-22 22:40:59 +02:00
Kevin Laatz
9afeef14cb usertools/devbind: add DMA device class
Add a new class for DMA devices.
Devices listed under the DMA class are to be used with the dmadev library.

Signed-off-by: Kevin Laatz <kevin.laatz@intel.com>
Reviewed-by: Conor Walsh <conor.walsh@intel.com>
Reviewed-by: Bruce Richardson <bruce.richardson@intel.com>
Reviewed-by: Chengwen Feng <fengchengwen@huawei.com>
2021-10-22 22:40:59 +02:00
Conor Walsh
9055bcde19 usertools/telemetry: list file-prefixes
This patch adds the option --list (-l) to dpdk-telemetry.py which will
print all of the available file-prefixes for DPDK processes that have
telemetry enabled.
The prefixes will also be printed if the user passes an incorrect prefix
in the --file-prefix (-f) option.

Signed-off-by: Conor Walsh <conor.walsh@intel.com>
Acked-by: Ciara Power <ciara.power@intel.com>
2021-10-19 17:15:10 +02:00
Conor Walsh
6839b8ade4 usertools/telemetry: fix instance option help
The instance option help text was incorrect, this patch corrects it.

Fixes: 11435aae20 ("usertools/telemetry: connect to separate instances")

Signed-off-by: Conor Walsh <conor.walsh@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
2021-10-19 17:15:10 +02:00
Bruce Richardson
b95af1946a usertools/telemetry: provide info on available sockets
When a user runs the dpdk-telemetry script and fails to connect because
the socket path does not exist, run a scan for possible sockets that
could be connected to and inform the user of the command needed to
connect to those.

For example:

  $ ./dpdk-telemetry.py -i4
  Connecting to /run/user/1000/dpdk/rte/dpdk_telemetry.v2:4
  Error connecting to /run/user/1000/dpdk/rte/dpdk_telemetry.v2:4

  Other DPDK telemetry sockets found:
  - dpdk_telemetry.v2  # Connect with './dpdk-telemetry.py'
  - dpdk_telemetry.v2:2  # Connect with './dpdk-telemetry.py -i 2'
  - dpdk_telemetry.v2:1  # Connect with './dpdk-telemetry.py -i 1'

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Ciara Power <ciara.power@intel.com>
Reviewed-by: Conor Walsh <conor.walsh@intel.com>
2021-10-14 20:57:07 +02:00
Bruce Richardson
11435aae20 usertools/telemetry: connect to separate instances
For processes run using "in-memory" mode sharing the same runtime dir,
we add support for connecting to the separate instance sockets created
using ":1", ":2" etc. via new "-i" or "--instance" argument. Add details
on connecting to separate instances to the telemetry howto document.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Ciara Power <ciara.power@intel.com>
Tested-by: Conor Walsh <conor.walsh@intel.com>
2021-10-14 20:57:06 +02:00
Nithin Dabilpuram
69daa9e502 net/cnxk: support inline security setup for cn10k
Add support for inline inbound and outbound IPSec for SA create,
destroy and other NIX / CPT LF configurations.

This patch also changes dpdk-devbind.py to list new inline
device as misc device.

Signed-off-by: Nithin Dabilpuram <ndabilpuram@marvell.com>
Acked-by: Jerin Jacob <jerinj@marvell.com>
2021-10-02 15:45:05 +02:00
Bruce Richardson
72727e0d56 usertools: silence prompts for telemetry input pipe
When the input to the script is coming from a device which is not a TTY
then we become less verbose and skip the prompts and helpful messages
about what is happening.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Ciara Power <ciara.power@intel.com>
2021-10-01 17:30:27 +02:00
Bruce Richardson
744e9a87c5 usertools: fix handling EOF for telemetry input pipe
To allow the script to take queries from input pipes e.g. "echo
/ethdev/stats,0 | dpdk-telemetry.py", we need to handle the case of EOF
correctly without crashing with an exception. Do this by using a
try-except block around the input handling.

Fixes: 6a2967c112 ("usertools: add new telemetry script")
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Ciara Power <ciara.power@intel.com>
2021-10-01 17:30:26 +02:00
Bruce Richardson
ea3ef0b85f usertools: fix flake8 compliance of telemetry script
Fix style errors reported by flake8.

Fixes: 6a2967c112 ("usertools: add new telemetry script")
Fixes: 2d9a697e41 ("usertools: add file-prefix option for telemetry")
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Kevin Laatz <kevin.laatz@intel.com>
Acked-by: Ciara Power <ciara.power@intel.com>
2021-10-01 17:30:01 +02:00
Tomasz Duszynski
24d9c5d59d raw/cnxk_bphy: add baseband PHY skeleton driver
Add baseband phy skeleton driver. Baseband phy is a hardware subsystem
accelerating 5G/LTE related tasks. Note this driver isn't involved into
any sort baseband protocol processing. Instead it just provides means
for configuring hardware.

Signed-off-by: Jakub Palider <jpalider@marvell.com>
Signed-off-by: Tomasz Duszynski <tduszynski@marvell.com>
Reviewed-by: Jerin Jacob <jerinj@marvell.com>
2021-07-05 23:08:11 +02:00
Tomasz Duszynski
3d27e49e07 raw/cnxk_bphy: add BPHY CGX/RPM skeleton driver
Add baseband PHY CGX/RPM skeleton driver which merely probes a matching
device. CGX/RPM are Ethernet MACs hardwired to baseband subsystem.

Signed-off-by: Tomasz Duszynski <tduszynski@marvell.com>
Signed-off-by: Jakub Palider <jpalider@marvell.com>
Reviewed-by: Jerin Jacob <jerinj@marvell.com>
2021-07-05 23:07:16 +02:00
Timothy McDaniel
240078c071 usertools: add Intel DLB device binding
Add DLB to usertools/dpdk-devbind.py so that it shows up
as an eventdev, and is identified as Intel DLB.

Signed-off-by: Timothy McDaniel <timothy.mcdaniel@intel.com>
2021-05-19 11:49:48 +02:00
Bruce Richardson
8dcb898c65 build: change indentation in infrastructure files
Switch from using tabs to 4 spaces for meson.build indentation, for the
basic infrastructure and tooling files, as well as doc and kernel
directories.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2021-04-21 14:04:09 +02:00
Thomas Monjalon
defd7f5a53 usertools: show hugepages requested/set on failure
In case the number of requested hugepages cannot be set,
a more detailed error message is printed.
The new message does not mention "reserve" because setting
can be reserving or clearing.
The filename and numbers requested/set are printed to ease debugging.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
2021-03-25 18:07:47 +01:00
Thomas Monjalon
01ae049dda usertools: check 0-division with hugepage size
The default page size can be None, and the page size from user request
can be 0 kB if lower than 1024. In these cases, a division will fail.
In order to avoid a Python exception, the page size is checked
and an error message "Invalid page size" is printed.

A similar error message is printed in set_hugepages()
if the size is not supported, except at this stage the message can be
completed with "Valid page sizes".
Unfortunately the first check is too early to print such information.

A third error message can be printed in a different place (get_memsize)
in case of a format issue, e.g. a negative size.
The function get_memsize() is also used for total requested size,
so the error message "not a valid page size" was potentially wrong.
This message is replaced with the more general "is not a valid size".

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
2021-03-25 18:04:32 +01:00
Bruce Richardson
d786e30e80 usertools: print process name when telemetry connects
When the dpdk-telemetry client connects to a DPDK instance, we can use the
PID provided in the initial connection message to query from /proc the name
of the process we are connected to, and display that to the user. We use
the "cmdline" procfs entry for the query since that is available on both
Linux and FreeBSD (assuming procfs is mounted on the BSD instance).

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Kevin Laatz <kevin.laatz@intel.com>
2021-03-25 18:00:46 +01:00
Kevin Laatz
2d9a697e41 usertools: add file-prefix option for telemetry
Currently the dpdk-telemetry.py script connects to all running DPDK apps
consecutively. With the addition of this file-prefix argument, we can limit
the amount of information returned providing improved consumability and
precision to the user.

Signed-off-by: Kevin Laatz <kevin.laatz@intel.com>
Reviewed-by: Bruce Richardson <bruce.richardson@intel.com>
Tested-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
2021-03-25 17:53:10 +01:00
Yongxin Liu
7a016af4aa usertools: fix binding built-in kernel driver
A driver can be loaded as a dynamic module or a built-in module.
In commit 681a672886 ("usertools: check if module is loaded
before binding"), the script only checks modules in /sys/module/.

However, for built-in kernel driver, it only shows up in /sys/module/,
if it has a version or at least one parameter. So add check for
modules in /lib/modules/$(uname -r)/modules.builtin.

Fixes: 681a672886 ("usertools: check if module is loaded before binding")
Cc: stable@dpdk.org

Signed-off-by: Yongxin Liu <yongxin.liu@windriver.com>
Reviewed-by: Anatoly Burakov <anatoly.burakov@intel.com>
2021-02-11 23:23:02 +01:00
Sarosh Arif
0b89dbc259 usertools: show valid hugepage sizes if wrong request
If user requests a hugepage size which is not supported by the system,
currently user gets an error message saying that the requested size
is not a valid system huge page size. In addition to this if we display
the valid hugepage sizes it will be convenient for the user to request
the right size next time.

Signed-off-by: Sarosh Arif <sarosh.arif@emumba.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
2021-02-11 22:45:20 +01:00
Sarosh Arif
b25f0a7df8 usertools: show error if unable to reserve hugepages
Sometimes the system is unable to reserve the requested hugepages because
enough space is not available in the RAM. In that case, currently the
script displays no error message hence the user can be under the delusion
that the hugepages requested are all successfully reserved. This patch
displays an error message if the pages reserved are different from the
requested pages.

Signed-off-by: Sarosh Arif <sarosh.arif@emumba.com>
2021-02-05 19:49:32 +01:00
David Christensen
2204feccf2 usertools: show hugepages on POWER systems
The IBM PowerNV systems include NUMA nodes that don't have associated
CPUs or hugepage memory.  Here is an example on an IBM AC922 system:

$ lscpu
...
NUMA node0 CPU(s):   0-63
NUMA node8 CPU(s):   64-127
NUMA node252 CPU(s):
...

$ numastat -m
...
                          Node 0          Node 8        Node 252
                 --------------- --------------- ---------------
MemTotal               126763.19       130785.06            0.00
MemFree                119513.38       125294.44            0.00
MemUsed                  7249.81         5490.62            0.00
...
HugePages_Total             4.00         1734.00            0.00
HugePages_Free              0.00            4.00            0.00
HugePages_Surp              4.00         1730.00            0.00
...

Modify dpdk-hugepages.py to test for the ../hugepages directory before
attempting to parse the hugepage entries.

Signed-off-by: David Christensen <drc@linux.vnet.ibm.com>
2021-02-05 19:49:32 +01:00
David Marchand
b0a49787b4 usertools: remove dpdk-setup.sh
This old script relied on deprecated stuff, and especially make.
It also applied some scary 666 permissions on files under /dev/vfio.

Its deprecation had been notified in a previous release, remove it.

Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Maxime Coquelin <maxime.coquelin@redhat.com>
2020-11-27 17:25:24 +01:00
Bruce Richardson
f32fed83db usertools: fix binding regex or misc device
The "misc" and "regex" device classes were missing from the list used to
check arguments, preventing them from being used with "--status-dev"
flag to list only devices of those types.

When adding them to the list, the list is also sorted alphabetically for
consistency.

Bugzilla ID: 582
Fixes: 81255f27c6 ("usertools: replace optparse with argparse")

Reported-by: Wei Ling <weix.ling@intel.com>
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Tested-by: Yu Jiang <yux.jiang@intel.com>
2020-11-25 14:04:58 +01:00
Stephen Hemminger
6e1b58fa84 usertools: add huge page setup script
This is an improved version of the setup of huge pages
bases on earlier DPDK setup.

Differences are:
   * autodetects NUMA vs non NUMA
   * allows setting different page sizes
     recent kernels support multiple sizes.
   * accepts a parameter in bytes (not pages).
   * can display current hugepage settings.

Most users will just use --setup argument but if necessary
the steps of clearing old settings and mounting/umounting
can be done individually.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
2020-11-22 22:38:03 +01:00
Julien Massonneau
3515fa1e5e usertools: fix pmdinfo parsing
In the display_pmd_info_strings function, the script parses the section
until to find a byte between 32 and 127, and get all data
until a byte equals to 0.
After, it searches "PMD_INFO_STRING" in the data and passes the whole
string in the parse_pmd_info_string function, which split the string
with "=" and convert it in python dict with json.loads().

But the string may contain a "=" before "PMD_INFO_STRING",
so it is not correctly split and will lead to an error
(json.decoder.JSONDecodeError).

Example of a string encountered that leads to an error:

"Ag%=C£°ÐÊ+Ë®{0´wË-£0òjB·;¾¬úPMD_INFO_STRING= {"name" :
"net_octeontx", "params" : "nr_port=<int> ", "pci_ids" : []}"

Fixes: c67c9a5c64 ("tools: query binaries for HW and other support information")
Cc: stable@dpdk.org

Signed-off-by: Julien Massonneau <julien.massonneau@6wind.com>
2020-11-22 22:22:44 +01:00
Stephen Hemminger
0a3f92cd3e usertools: test multiple strings with operator in
Python lint suggests using in instead of multiple comparisons.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
2020-11-22 22:22:44 +01:00
Stephen Hemminger
1bb98a9083 usertools: remove unused imports in devbind
Address python lint complaints about unused imports.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
2020-11-22 22:22:44 +01:00
Stephen Hemminger
d58360c6d3 usertools: do not test empty with function len
Python lint warns about using len(SEQUENCE) to determine if sequence is empty.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
2020-11-22 22:22:36 +01:00
Stephen Hemminger
81255f27c6 usertools: replace optparse with argparse
The optparse module is deprecated and replaced with new argparse.
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.

Some of the help messages are now less wordy.

The code now enforces the rule that only one of the pmdinfo formats
can be specified: raw or json.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
2020-11-22 22:16:04 +01:00
Stephen Hemminger
c358ba7a17 usertools: fix indentation
Python lint complains about indentation and missing spaces around commas.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
2020-11-22 22:15:14 +01:00
Stephen Hemminger
55f58d7f7d usertools: replace explicit boolean checks
Code reads better if unnecessary comparison with False and True
is not used.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2020-11-22 22:15:13 +01:00
Stephen Hemminger
b5685e3900 usertools: remove unnecessary parens and else
Python lint complains:
Unnecessary parens after 'if' keyword
Unnecessary parens after 'not' keyword
Unnecessary "else" after "return"

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
2020-11-22 22:14:12 +01:00
Stephen Hemminger
5b8c137650 usertools: replace io.open
The builtin open() is the recommended approach in python3.
io.open was for compatibility with older versions.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2020-11-22 22:04:11 +01:00
Stephen Hemminger
ecdd471171 usertools: replace string.split
In python3 the standard way to split strings is to use the
split() on the string object itself. The old way is broken
and would cause a traceback.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2020-11-22 22:04:10 +01:00
Ciara Power
b0dcd61052 usertools: fix CPU layout script to be PEP8 compliant
The pycodestyle tool flagged the following issues, which are now fixed.

$ pycodestyle cpu_layout.py
  cpu_layout.py:18:5: E722 do not use bare 'except'
  cpu_layout.py:62:14: E231 missing whitespace after ','

Fixes: deb87e6777 ("usertools: use sysfs for CPU layout")
Fixes: c9208f1dc9 ("usertools: fix CPU layout with python 3")
Cc: stable@dpdk.org

Signed-off-by: Ciara Power <ciara.power@intel.com>
2020-11-13 15:40:21 +01:00
David Marchand
4760b32b64 usertools: fix pmdinfo parsing
This script inspects an ELF file (binary or shared library) and its
linked dependencies by following DT_NEEDED tags.
So far a simple librte_pmd prefix was used as a filter to only parse
DPDK drivers dependencies.
While the reason is not clear from the commitlog of the patch that
introduced this filter, it was probably added for performance reasons,
since going through all dependencies can be quite long.
Testing with a DPDK built before the driver name changes:
- running the script takes ~0.3s with the filter,
- running the script takes ~9s without the filter,

Now that we changed the driver library names, it becomes more difficult
to identify only DPDK drivers, but we can just filter on the librte_
prefix to identify DPDK libraries: the script later checks for the
PMD_INFO_STRING string in .rodata and it is enough to differentiate the
DPDK drivers from the other DPDK libraries.

Running the script with this patch takes ~0.5s.

A debug message was logged for each inspected file, it gives no useful
information and is removed.

Fixes: a20b2c01a7 ("build: standardize component names and defines")

Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Robin Jarry <robin.jarry@6wind.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
2020-11-12 14:26:42 +01:00