git.droids-corp.org
/
dpdk.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
pdump: replace constant for device name size
[dpdk.git]
/
usertools
/
dpdk-devbind.py
diff --git
a/usertools/dpdk-devbind.py
b/usertools/dpdk-devbind.py
index
bd7dc09
..
c2ede3d
100755
(executable)
--- a/
usertools/dpdk-devbind.py
+++ b/
usertools/dpdk-devbind.py
@@
-9,7
+9,7
@@
import subprocess
import argparse
from glob import glob
import argparse
from glob import glob
-from os.path import exists,
abspath, dirname,
basename
+from os.path import exists, basename
from os.path import join as path_join
# The PCI base class for all devices
from os.path import join as path_join
# The PCI base class for all devices
@@
-143,7
+143,7
@@
def get_pci_device_details(dev_id, probe_lspci):
extra_info = subprocess.check_output(["lspci", "-vmmks", dev_id]).splitlines()
# parse lspci details
for line in extra_info:
extra_info = subprocess.check_output(["lspci", "-vmmks", dev_id]).splitlines()
# parse lspci details
for line in extra_info:
- if
len(line) == 0
:
+ if
not line
:
continue
name, value = line.decode("utf8").split("\t", 1)
name = name.strip(":") + "_str"
continue
name, value = line.decode("utf8").split("\t", 1)
name = name.strip(":") + "_str"
@@
-178,7
+178,7
@@
def get_device_details(devices_type):
dev = {}
dev_lines = subprocess.check_output(["lspci", "-Dvmmnnk"]).splitlines()
for dev_line in dev_lines:
dev = {}
dev_lines = subprocess.check_output(["lspci", "-Dvmmnnk"]).splitlines()
for dev_line in dev_lines:
- if
len(dev_line) == 0
:
+ if
not dev_line
:
if device_type_match(dev, devices_type):
# Replace "Driver" with "Driver_str" to have consistency of
# of dictionary key names
if device_type_match(dev, devices_type):
# Replace "Driver" with "Driver_str" to have consistency of
# of dictionary key names
@@
-193,7
+193,7
@@
def get_device_details(devices_type):
else:
name, value = dev_line.decode("utf8").split("\t", 1)
value_list = value.rsplit(' ', 1)
else:
name, value = dev_line.decode("utf8").split("\t", 1)
value_list = value.rsplit(' ', 1)
- if
len(value_list) > 1
:
+ if
value_list
:
# String stored in <name>_str
dev[name.rstrip(":") + '_str'] = value_list[0]
# Numeric IDs
# String stored in <name>_str
dev[name.rstrip(":") + '_str'] = value_list[0]
# Numeric IDs
@@
-341,7
+341,7
@@
def bind_one(dev_id, driver, force):
# of unbinding those devices
if driver in dpdk_drivers:
filename = "/sys/bus/pci/devices/%s/driver_override" % dev_id
# of unbinding those devices
if driver in dpdk_drivers:
filename = "/sys/bus/pci/devices/%s/driver_override" % dev_id
- if
os.path.
exists(filename):
+ if exists(filename):
try:
f = open(filename, "w")
except:
try:
f = open(filename, "w")
except:
@@
-404,7
+404,7
@@
def bind_one(dev_id, driver, force):
# Before unbinding it, overwrite driver_override with empty string so that
# the device can be bound to any other driver
filename = "/sys/bus/pci/devices/%s/driver_override" % dev_id
# Before unbinding it, overwrite driver_override with empty string so that
# the device can be bound to any other driver
filename = "/sys/bus/pci/devices/%s/driver_override" % dev_id
- if
os.path.
exists(filename):
+ if exists(filename):
try:
f = open(filename, "w")
except:
try:
f = open(filename, "w")
except:
@@
-472,7
+472,7
@@
def bind_all(dev_list, driver, force=False):
# that are not bound to any other driver could be bound even if no one has
# asked them to. hence, we check the list of drivers again, and see if
# some of the previously-unbound devices were erroneously bound.
# that are not bound to any other driver could be bound even if no one has
# asked them to. hence, we check the list of drivers again, and see if
# some of the previously-unbound devices were erroneously bound.
- if not
os.path.
exists("/sys/bus/pci/devices/%s/driver_override" % d):
+ if not exists("/sys/bus/pci/devices/%s/driver_override" % d):
for d in devices.keys():
# skip devices that were already bound or that we know should be bound
if "Driver_str" in devices[d] or d in dev_list:
for d in devices.keys():
# skip devices that were already bound or that we know should be bound
if "Driver_str" in devices[d] or d in dev_list:
@@
-495,7
+495,7
@@
def display_devices(title, dev_list, extra_params=None):
strings = [] # this holds the strings to print. We sort before printing
print("\n%s" % title)
print("="*len(title))
strings = [] # this holds the strings to print. We sort before printing
print("\n%s" % title)
print("="*len(title))
- if
len(dev_list) == 0
:
+ if
not dev_list
:
strings.append("<none>")
else:
for dev in dev_list:
strings.append("<none>")
else:
for dev in dev_list:
@@
-538,17
+538,17
@@
def show_device_status(devices_type, device_name, if_field=False):
return
# print each category separately, so we can clearly see what's used by DPDK
return
# print each category separately, so we can clearly see what's used by DPDK
- if
len(dpdk_drv) != 0
:
+ if
dpdk_drv
:
display_devices("%s devices using DPDK-compatible driver" % device_name,
dpdk_drv, "drv=%(Driver_str)s unused=%(Module_str)s")
display_devices("%s devices using DPDK-compatible driver" % device_name,
dpdk_drv, "drv=%(Driver_str)s unused=%(Module_str)s")
- if
len(kernel_drv) != 0
:
+ if
kernel_drv
:
if_text = ""
if if_field:
if_text = "if=%(Interface)s "
display_devices("%s devices using kernel driver" % device_name, kernel_drv,
if_text + "drv=%(Driver_str)s "
"unused=%(Module_str)s %(Active)s")
if_text = ""
if if_field:
if_text = "if=%(Interface)s "
display_devices("%s devices using kernel driver" % device_name, kernel_drv,
if_text + "drv=%(Driver_str)s "
"unused=%(Module_str)s %(Active)s")
- if
len(no_drv) != 0
:
+ if
no_drv
:
display_devices("Other %s devices" % device_name, no_drv,
"unused=%(Module_str)s")
display_devices("Other %s devices" % device_name, no_drv,
"unused=%(Module_str)s")
@@
-557,28
+557,28
@@
def show_status():
Displays to the user what devices are bound to the igb_uio driver, the
kernel driver or to no driver'''
Displays to the user what devices are bound to the igb_uio driver, the
kernel driver or to no driver'''
- if status_dev
== "net" or status_dev == "all"
:
+ if status_dev
in ["net", "all"]
:
show_device_status(network_devices, "Network", if_field=True)
show_device_status(network_devices, "Network", if_field=True)
- if status_dev
== "baseband" or status_dev == "all"
:
+ if status_dev
in ["baseband", "all"]
:
show_device_status(baseband_devices, "Baseband")
show_device_status(baseband_devices, "Baseband")
- if status_dev
== "crypto" or status_dev == "all"
:
+ if status_dev
in ["crypto", "all"]
:
show_device_status(crypto_devices, "Crypto")
show_device_status(crypto_devices, "Crypto")
- if status_dev
== "event" or status_dev == "all"
:
+ if status_dev
in ["event", "all"]
:
show_device_status(eventdev_devices, "Eventdev")
show_device_status(eventdev_devices, "Eventdev")
- if status_dev
== "mempool" or status_dev == "all"
:
+ if status_dev
in ["mempool", "all"]
:
show_device_status(mempool_devices, "Mempool")
show_device_status(mempool_devices, "Mempool")
- if status_dev
== "compress" or status_dev == "all"
:
+ if status_dev
in ["compress", "all"]
:
show_device_status(compress_devices, "Compress")
show_device_status(compress_devices, "Compress")
- if status_dev
== "misc" or status_dev == "all"
:
+ if status_dev
in ["misc", "all"]
:
show_device_status(misc_devices, "Misc (rawdev)")
show_device_status(misc_devices, "Misc (rawdev)")
- if status_dev
== "regex" or status_dev == "all"
:
+ if status_dev
in ["regex", "all"]
:
show_device_status(regex_devices, "Regex")
show_device_status(regex_devices, "Regex")
@@
-634,7
+634,8
@@
To bind 0000:02:00.0 and 0000:02:00.1 to the ixgbe kernel driver
parser.add_argument(
'--status-dev',
help="Print the status of given device group.",
parser.add_argument(
'--status-dev',
help="Print the status of given device group.",
- choices=['net', 'baseband', 'crypto', 'event', 'mempool', 'compress'])
+ choices=['baseband', 'compress', 'crypto', 'event',
+ 'mempool', 'misc', 'net', 'regex'])
bind_group = parser.add_mutually_exclusive_group()
bind_group.add_argument(
'-b',
bind_group = parser.add_mutually_exclusive_group()
bind_group.add_argument(
'-b',
@@
-703,7
+704,7
@@
def do_arg_actions():
global force_flag
global args
global force_flag
global args
- if b_flag
== "none" or b_flag == "None"
:
+ if b_flag
in ["none", "None"]
:
unbind_all(args, force_flag)
elif b_flag is not None:
bind_all(args, b_flag, force_flag)
unbind_all(args, force_flag)
elif b_flag is not None:
bind_all(args, b_flag, force_flag)