[dpdk-dev] Add option to dpdk-devbind.py to restore kernel driver binding
Tosatti, Giovanni
GTosatti at empirix.com
Tue Apr 10 13:10:06 CEST 2018
--- /opt/Perforce/gtosatti_centos/E-XMS/CSA-Mainline/Third-Party/dpdk/dpdk-16.07.orig/tools/dpdk-devbind.py
+++ /opt/Perforce/gtosatti_centos/E-XMS/CSA-Mainline/Third-Party/dpdk/dp
+++ dk-16.07/tools/dpdk-devbind.py
@@ -91,6 +91,9 @@
-u, --unbind:
Unbind a device (Equivalent to \"-b none\")
+ -r, --restore
+ Restore ALL the DPDK devices to their kernel drivers
+
--force:
By default, devices which are used by Linux - as indicated by having
routes in the routing table - cannot be modified. Using the --force @@ -448,6 +451,21 @@
if "Driver_str" in devices[d]:
unbind_one(d, force)
+def restore_all_to_kernel():
+ global force_flag
+ # List all the available devices
+ for d in devices.keys():
+ if not has_driver(d):
+ # Discard the unbinded devices
+ continue
+ if devices[d]["Driver_str"] in dpdk_drivers:
+ # List the unused Drivers of the the DPDK Devices
+ unused_drivers = devices[d]["Module_str"].split(",")
+ print("Restoring kernel driver for: %s '%s' '%s'" % (devices[d]["Slot"],
+ devices[d]["Device_str"], devices[d]["Module_str"]))
+ # Bind the current Device to the FIRST unused Driver
+ if unused_drivers:
+ bind_one(devices[d]["Slot"], unused_drivers[0],
+force_flag)
def display_devices(title, dev_list, extra_params=None):
'''Displays to the user the details of a list of devices given in @@ -513,7 +531,7 @@
try:
opts, args = getopt.getopt(sys.argv[1:], "b:us",
["help", "usage", "status", "force",
- "bind=", "unbind"])
+ "bind=", "unbind", "restore"])
except getopt.GetoptError as error:
print(str(error))
print("Run '%s --usage' for further information" % sys.argv[0]) @@ -527,11 +545,15 @@
status_flag = True
if opt == "--force":
force_flag = True
- if opt == "-b" or opt == "-u" or opt == "--bind" or opt == "--unbind":
+ if (opt == "-b" or opt == "--bind" or
+ opt == "-u" or opt == "--unbind" or
+ opt == "-r" or opt == "--restore"):
if b_flag is not None:
print("Error - Only one bind or unbind may be specified\n")
sys.exit(1)
- if opt == "-u" or opt == "--unbind":
+ if opt == "-r" or opt == "--restore":
+ b_flag = "restore"
+ elif opt == "-u" or opt == "--unbind":
b_flag = "none"
else:
b_flag = arg
@@ -551,11 +573,14 @@
sys.exit(1)
if b_flag is not None and len(args) == 0:
- print("Error: No devices specified.")
- print("Run '%s --usage' for further information" % sys.argv[0])
- sys.exit(1)
-
- if b_flag == "none" or b_flag == "None":
+ if b_flag != "restore":
+ print("Error: No devices specified.")
+ print("Run '%s --usage' for further information" % sys.argv[0])
+ sys.exit(1)
+
+ if b_flag == "restore":
+ restore_all_to_kernel()
+ elif b_flag == "none" or b_flag == "None":
unbind_all(args, force_flag)
elif b_flag is not None:
bind_all(args, b_flag, force_flag)
More information about the dev
mailing list