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
71
|
--- dpdk-stable-21.11.4/usertools/dpdk-devbind.py 2023-05-17 07:27:18.000000000 -0400
+++ dpdk-stable-21.11.4-mr4/usertools/dpdk-devbind.py 2023-06-26 07:47:31.226072861 -0400
@@ -8,6 +8,7 @@ import os
import subprocess
import argparse
import platform
+import json
from glob import glob
from os.path import exists, basename
@@ -95,6 +96,7 @@ loaded_modules = None
# command-line arg flags
b_flag = None
status_flag = False
+dump_flag = False
force_flag = False
args = []
@@ -577,6 +579,11 @@ def show_device_status(devices_type, dev
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")
@@ -635,6 +642,8 @@ def parse_args():
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',
@@ -649,6 +658,9 @@ To display current device status:
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
@@ -669,6 +681,11 @@ To bind 0000:02:00.0 and 0000:02:00.1 to
help="Print the status of given device group.",
choices=['baseband', 'compress', 'crypto', 'dma', 'event',
'mempool', 'misc', 'net', 'regex'])
+ parser.add_argument(
+ '-d',
+ '--dump',
+ help="Dump the status of kernel net group.")
+
bind_group = parser.add_mutually_exclusive_group()
bind_group.add_argument(
'-b',
@@ -701,6 +718,9 @@ For devices bound to Linux kernel driver
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"
|