-
Notifications
You must be signed in to change notification settings - Fork 8
/
set_mode
executable file
·55 lines (43 loc) · 1.36 KB
/
set_mode
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
#!/usr/bin/env python3
import argparse
import os
import common_bf
def main() -> None:
parser = argparse.ArgumentParser(description="Reads the current mode of the BF-2.")
parser.add_argument(
"mode", metavar="mode", type=str, help="which mode to set the BF-2 to."
)
parser.add_argument(
"-i",
"--id",
dest="id",
default=0,
action="store",
type=int,
help="Specify the id of the BF-2.",
)
args = parser.parse_args()
bf = common_bf.find_bf_pci_addresses_or_quit(args.id)
dpu_mode = {
"INTERNAL_CPU_MODEL": "EMBEDDED_CPU(1)",
"INTERNAL_CPU_PAGE_SUPPLIER": "ECPF(0)",
"INTERNAL_CPU_ESWITCH_MANAGER": "ECPF(0)",
"INTERNAL_CPU_IB_VPORT0": "ECPF(0)",
"INTERNAL_CPU_OFFLOAD_ENGINE": "ENABLED(0)",
}
nic_mode = {
"INTERNAL_CPU_MODEL": "EMBEDDED_CPU(1)",
"INTERNAL_CPU_PAGE_SUPPLIER": "ECPF(1)",
"INTERNAL_CPU_ESWITCH_MANAGER": "ECPF(1)",
"INTERNAL_CPU_IB_VPORT0": "ECPF(1)",
"INTERNAL_CPU_OFFLOAD_ENGINE": "ENABLED(1)",
}
settings = dpu_mode if args.mode == "dpu" else nic_mode
joined = ""
for k, v in settings.items():
value = v[-3:].strip("()")
joined += f"{k}={value} "
cmd = f"mstconfig -y -d {bf} s {joined}"
os.system(cmd)
if __name__ == "__main__":
main()