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>
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>
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>
Address python lint complaints about unused imports.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
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>
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>
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>
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>
Update the devbind script with new section of regex devices, also
added OCTEONTX2 REE device ID to regex device list
Signed-off-by: Guy Kaneti <guyk@marvell.com>
Intel Data Streaming Accelerator (Intel DSA) is a high-performance data
copy and transformation accelerator which will be integrated in future
Intel processors [1].
Add DSA device support to dpdk-devbind.py script.
[1] https://01.org/blogs/2019/introducing-intel-data-streaming-accelerator
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Signed-off-by: Kevin Laatz <kevin.laatz@intel.com>
Acked-by: Radu Nicolau <radu.nicolau@intel.com>
Add NTB device support (4th generation) for Intel Ice Lake platform.
Signed-off-by: Xiaoyun Li <xiaoyun.li@intel.com>
Acked-by: Jingjing Wu <jingjing.wu@intel.com>
Changed scripts to explicitly use Python 3 only, to avoid
maintaining Python 2.
Removed deprecation notices.
Signed-off-by: Louise Kilheeney <louise.kilheeney@intel.com>
Signed-off-by: Kevin Laatz <kevin.laatz@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Robin Jarry <robin.jarry@6wind.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Ray Kinsella <mdr@ashroe.eu>
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 <bruce.richardson@intel.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
Tested-by: Ferruh Yigit <ferruh.yigit@intel.com>
The "if", or interface, field in the status display of dpdk-devbind is only
relevant for network interfaces, so don't display it for other device
types.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
Prepare for python2 removal in 20.11.
Signed-off-by: Louise Kilheeney <louise.kilheeney@intel.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Acked-by: Nicolas Chautru <nicolas.chautru@intel.com>
Fixes the case where a PCI device string identifier
contains non-ASCII UTF-8
A particular example is Mellanox Connext-X 5 EN MT27800:
28:00.0 Ethernet controller: Mellanox Technologies
MT27800 Family [ConnectX-5]
Subsystem: Mellanox Technologies ConnectX®-5 EN network
interface card, 100GbE single-port QSFP28, PCIe3.0 x16,
tall bracket; MCX515A-CCAT
Signed-off-by: Christos Ricudis <ricudis@niometrics.com>
Acked-by: Andrew Rybchenko <arybchenko@solarflare.com>
Add support for Ice Lake IOAT DMA engine PCI Device ID.
Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
Reviewed-by: Bruce Richardson <bruce.richardson@intel.com>
Some kernel modules use '-' in their name when registering through
`pci_register_driver` and the same name is populated in
'/sys/bus/pci/drivers/'.
But the kernel always populates modules names replacing '-' with '_'
in '/sys/module/'.
Example:
# ./usertools/dpdk-devbind.py -b octeontx2-nicpf 0002:03:00.0
Error: Driver 'octeontx2-nicpf' is not loaded.
# ls /sys/bus/pci/drivers/octeontx2-nicpf
bind module new_id remove_id uevent unbind
# ls /sys/module/octeontx2_nicpf/
drivers uevent version
The patch addresses it by always replacing '-' with '_' when looking in
'/sys/module/'
Signed-off-by: Phanendra Vukkisala <pvukkisala@marvell.com>
Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
Bring consistency to error messages and output them to stderr.
Also, whenever the script tells the user to "check usage", don't
tell the user to do it and just display usage instead.
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Currently, if an attempt is made to bind a device to a driver that
is not loaded, a confusing and misleading error message appears.
Fix it so that, before binding to the driver, we actually check if
it is loaded in the kernel first.
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
A common user error is to forget driver to which the PCI devices should
be bound to. Currently, the error message in this case looks unhelpful
misleading and indecipherable to anyone but people who know how devbind
works.
Fix this by checking if the driver string is actually a valid device
string. If it is, we assume that the user has just forgot to specify the
driver, and display appropriate error. We also assume that no one will
name their driver in a format that looks like a PCI address, but that
seems like a reasonable assumption to make.
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Add in the list of registers for the device.
And enable NTB device ops for Intel Skylake platform.
Signed-off-by: Xiaoyun Li <xiaoyun.li@intel.com>
Acked-by: Jingjing Wu <jingjing.wu@intel.com>
Reviewed-by: Xiaolong Ye <xiaolong.ye@intel.com>
Update the devbind script with new section of DMA devices, also
added OCTEONTX2 DMA device ID to DMA device list
Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Signed-off-by: Satha Rao <skoteshwar@marvell.com>
Currently clear_data (dpdk-devbind.py) doesn't work as expected
since "global devices" is missing and so "devices" is considered
a local variable.
This commit changes "clear_data" function in order to really clear
devices by adding "global devices".
Fixes: ea9f00f728 ("usertools: refactor NIC and crypto binding details")
Cc: stable@dpdk.org
Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
Acked-by: Luca Boccassi <bluca@debian.org>
Reviewed-by: David Marchand <david.marchand@redhat.com>
In order to allow binding/unbinding of devices for use by the
ioat_rawdev, we need to update the devbind script to add a new class
of device, and add device ids for the specific HW instances.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Jiayu Hu <jiayu.hu@intel.com>
Tested-by: Harry van Haaren <harry.van.haaren@intel.com>
If there aren't any devices of a particular category on user's
system, we still display them, which is bad for usability. Fix
devbind to not print out a category unless there are devices in
it.
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Reviewed-by: David Hunt <david.hunt@intel.com>
On some distributions (such as CentOS 7) lspci may not be installed
by default, causing exceptions which are difficult to interpret.
Fix devbind script to check if lspci is installed at script startup.
Cc: stable@dpdk.org
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Reviewed-by: Rami Rosen <roszenrami@gmail.com>
lspci reports kernel modules in "Module" string, but devbind
expects it to be "Module_str". Fix it up similar to how we fix
up "Driver" to be "Driver_str".
Fixes: c3ce205d57 ("usertools: optimize lspci invocation")
Cc: stable@dpdk.org
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Replace the BSD license header with the SPDX tag for
scripting files with only an Intel copyright on them.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
When using Python 3, dpdk-devbind.py fails to detect modules other than
igb_uio.
Fixes: bb9f408550 ("tools: support binding to built-in kernel modules")
Signed-off-by: Omri Mor <omrimor2@illinois.edu>
If multiple devices of same class are added to a device type,
only devices that match first device listed in device type list are
processed.
Fixing it in device_type_match() by returning false after iterating
through all the devices listed in a device type list.
Fixes: 8ad08a2879 ("usertools: define DPDK PCI functional device")
Signed-off-by: Guduri Prathyusha <gprathyusha@caviumnetworks.com>
The existing code used to search for module files via modinfo has
several corner cases which can result in it failing where it should be
successful.
The call to lower() would cause results returned by 'modinfo' to be
forced to lowercase, results which were subsequently passed to
exists() which is case sensitive. This was most likely done to capture
all variants of failure strings modinfo might return
(ie. ERROR/Error/error/...) without thought negative effect to the
later call to exists(). For many this is a nonissue but if the module
path included non-lowercase alpha characters, something which is
easily possible with a non-lowercase kernel-extraversion string, this
would cause an issue.
We could move the call to lower() to the check for "error" but this
still leaves possible corner cases, for modules or module paths with
'error' in them.
Instead we will prevent modinfo's stderr from being used as a "good
value" for path, meaning we either get a valid path from modinfo, or
nothing at all. This removes all corner cases.
Ultimately these preliminary checks are unnecessary as exists() will
only return True if it is passed a valid path, passing it modinfo's
stderr would fail. In keeping with the original code, however, we do
some preliminary checks, but we are now free of corner cases.
Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com>
Script displays status for all device types and output is much
longer than it used to be. This makes harder to read script output.
This patch adds new --status-dev argument to the script to select
a device group to display status.
Supported device groups:
net
crypto
event
mempool
Sample usage:
./usertools/dpdk-devbind.py --status-dev mempool
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
The following sequence of operation gives error in binding devices
1) Bind a device using dpdk-devbind.py
2) Unbind the device using kernel tools(/sys/bus/pci/device/driver/unbind)
3) Bind the device using kernel tools(/sys/bus/pci/driver/new_id and
/sys/bus/pci/driver/bind)
The bind failure was due to cached driver name in 'driver_override'.
Fix it by writing 'null' to driver_override just after binding a
device so that any method of binding/unbinding can be used.
Fixes: 2fc3502935 ("usertools: use optimized driver override scheme to bind")
Reported-by: Lijuan A Tu <lijuanx.a.tu@intel.com>
Signed-off-by: Guduri Prathyusha <gprathyusha@caviumnetworks.com>
This patch creates the framework to define the DPDK PCI functional
device by specifying the pci attributes like Vendor ID, Device ID,
Sub Vendor ID, Sub Device ID and Class.This enables a flexible way to
add DPDK function devices based on PCI attributes.
Crypto devices can belong to Encryption class(0x10) or Processor
class(0x0b) based on the vendor preference.
Using this framework, The above disparity can be encoded in the following
format
encryption_class = [{'Class': '10', 'Vendor': None,
'Device': None, 'SVendor': None, 'SDevice': None}]
intel_processor_class = [{'Class': '0b', 'Vendor': '8086', 'Device': None,
'SVendor': None, 'SDevice': None}]
crypto_devices = [encryption_class, intel_processor_class]
Signed-off-by: Guduri Prathyusha <gprathyusha@caviumnetworks.com>
Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
The current device bind model uses /sys/bus/pci/driver/new_id scheme to
bind devices to the driver. This scheme has following operations to bind
a device to the driver.
1) Write device ID and vendor ID to /sys/bus/pci/driver/new_id
2) Write PCI BDF number to /sys/bus/pci/driver/bind
3) On step (1), _All_ the devices that match the device ID and vendor ID
get bound to the driver
4) Except for requested devices, Unbind the remaining devices
In kernels >= 3.15, An alternative scheme driver_override can be used to
bind a device to driver.This scheme has following operations to bind a
device to driver.
1) Write driver to /sys/bus/pci/device/driver_override
2) Write PCI BDF number to /sys/bus/pci/driver/bind
This script detects the presence of /sys/bus/pci/device/driver_override,
if available use optimized bind scheme to bind it
Signed-off-by: Guduri Prathyusha <gprathyusha@caviumnetworks.com>
Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
lspci invoked twice over all the pci devices in the system.
The first pass is to extract Numeric IDs and second pass to get extended
device details.
As an optimization, Used lspci with -nn option in get_device_details()
to obtain Numeric ID and extended device details in one shot.
In addition to this, After binding the PCI device, lspci needs to be
invoked again to confirm the proper bind operation. Used a boolean
argument to express this case in get_pci_device_details()
Signed-off-by: Guduri Prathyusha <gprathyusha@caviumnetworks.com>
Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
Identified and parameterized the common code in show_status() function as
show_device_status().This will enable to avoid code duplication when
additional devices added to the script.
Signed-off-by: Guduri Prathyusha <gprathyusha@caviumnetworks.com>
Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>