1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
--- dpdk-stable-23.11.1/usertools/dpdk-devbind.py 2024-05-17 14:46:11.000000000 +0800
+++ dpdk-stable-23.11.1-mr/usertools/dpdk-devbind.py 2024-07-12 15:50:28.665305357 +0800
@@ -8,6 +8,7 @@
import subprocess
import argparse
import platform
+import json
from glob import glob
from os.path import exists, basename
@@ -103,6 +104,7 @@
# command-line arg flags
b_flag = None
status_flag = False
+dump_flag = False
force_flag = False
args = []
@@ -585,6 +587,11 @@
display_devices("%s devices using kernel driver" % device_name, kernel_drv,
if_text + "drv=%(Driver_str)s "
"unused=%(Module_str)s %(Active)s")
+ if dump_flag and dump_path == 'stdout':
+ print(kernel_drv)
+ if dump_flag and dump_path != 'stdout':
+ f = open(dump_path, "w")
+ f.write(json.dumps(kernel_drv, sort_keys=True,indent=4))
if no_drv:
display_devices("Other %s devices" % device_name, no_drv,
"unused=%(Module_str)s")
@@ -646,6 +653,8 @@
global status_dev
global force_flag
global args
+ global dump_flag
+ global dump_path
parser = argparse.ArgumentParser(
description='Utility to bind and unbind devices from Linux kernel',
@@ -660,6 +669,9 @@
To display current network device status:
%(prog)s --status-dev net
+To dump current kernel network device status for json:
+ %(prog)s --status-dev net --dump ('stdout' | 'path')
+
To bind eth1 from the current driver and move to use vfio-pci
%(prog)s --bind=vfio-pci eth1
@@ -671,6 +683,10 @@
""")
parser.add_argument(
+ '-d',
+ '--dump',
+ help="Dump the status of kernel net group.")
+ parser.add_argument(
'-s',
'--status',
action='store_true',
@@ -712,6 +728,9 @@
if opt.status_dev:
status_flag = True
status_dev = opt.status_dev
+ if opt.dump:
+ dump_flag = True
+ dump_path = opt.dump
if opt.status:
status_flag = True
status_dev = "all"
|