Skip to content

Commit 9b051c8

Browse files
authored
Merge pull request #17 from Mellanox/latest
switchdev/legacy mode visibility
2 parents 1ea0454 + 0b82898 commit 9b051c8

File tree

1 file changed

+107
-2
lines changed

1 file changed

+107
-2
lines changed

sysinfo-snapshot.py

Lines changed: 107 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def __ge__(self, other):
116116
######################################################################################################
117117
# GLOBAL GENERAL VARIABLES
118118

119-
version = "3.7.9"
119+
version = "3.7.9.1"
120120
sys_argv = sys.argv
121121
len_argv = len(sys.argv)
122122
driver_required_loading = False
@@ -292,7 +292,7 @@ def __ge__(self, other):
292292
"service cpuspeed status", "service iptables status", "service irqbalance status", "show_irq_affinity_all", "tgtadm --mode target --op show", "tgtadm --version", "tuned-adm active", "ulimit -a", "uname", \
293293
"yy_MLX_modules_parameters", "sysclass_IB_modules_parameters", "proc_net_bonding_files","Mellanox_Nvidia_pci_buses" ,"sys_class_net_files", "teamdctl_state", "teamdctl_state_view", "teamdctl_config_dump", "teamdctl_config_dump_actual", "teamdctl_config_dump_noports", \
294294
"mlxconfig_query", "mst status", "mst status -v", "mlxcables", "ip -6 addr show", "ip -6 route show", "modinfo", "show_pretty_gids", "flint -v", "mstflint -v","dkms status",\
295-
"mlxdump", "gcc --version", "python_used_version", "cma_roce_mode", "cma_roce_tos", "service firewalld status", "mlxlink / mstlink", "mget_temp_query", "mlnx_qos_handler", "devlink_handler", "se_linux_status", \
295+
"mlxdump", "gcc --version", "python_used_version", "cma_roce_mode", "cma_roce_tos", "service firewalld status", "mlxlink / mstlink", "mget_temp_query", "mlnx_qos_handler", "devlink_handler", "switchdev_legacy_mode","se_linux_status", \
296296
"ufm_logs", "virsh version","virsh list --all", "virsh vcpupin", "sys_class_infiniband_ib_paameters", "sys_class_net_ecn_ib","roce counters","route -n","numastat -n","NetworkManager --print-config","networkManager_system_connections","USER","mlxreg -d --reg_name ROCE_ACCL --get"\
297297
,"mlxreg -d -y --get --op 'cmd_type' --reg_name PPCC","congestion_control_parameters","doca_pcc_counter","ecn_configuration","lsblk", "journalctl -u mlnx_snap","flint -d xx q","virtnet query --all","journalctl -u virtio-net-controller","/etc/mlnx_snap","snap_rpc.py emulation_functions_list","snap_rpc.py controller_list"\
298298
,"nvidia-smi topo -m", "nvidia-smi", "lspci -tv |grep 'NVIDIA' -A7", "nvidia-smi -q -d clock", "nvidia-smi --format=csv --query-supported-clocks=gr,mem", "ib_write_bw -h | grep -i cuda", "modinfo nv_peer_mem",\
@@ -1019,6 +1019,105 @@ def modinfo_handler():
10191019
modinfo += modinfo_module + "\n"
10201020
return modinfo
10211021

1022+
def switchdev_legacy_mode_handler():
1023+
net_path = "/sys/class/net"
1024+
if os.path.exists(net_path):
1025+
result = []
1026+
for dev in all_net_devices:
1027+
mode_path = "{}/{}/compat/devlink/mode".format(net_path, dev)
1028+
if os.path.exists(mode_path):
1029+
try:
1030+
with open(mode_path, "r") as mode_file:
1031+
mode = mode_file.read().strip()
1032+
result.append("{}: {}".format(dev, mode))
1033+
except IOError:
1034+
result.append("{}: Error reading mode".format(dev))
1035+
else:
1036+
result.append("{}: Not Found".format(dev))
1037+
return 0 ,"\n".join(result)
1038+
else:
1039+
return 1, '/sys/class/net does not exist.'
1040+
1041+
1042+
#**********************************************************
1043+
# devlink handler
1044+
1045+
def devlink_handler():
1046+
dev_st, devlink_health = get_status_output("devlink health show")
1047+
if (dev_st != 0):
1048+
return "There are no devices"
1049+
dev_st, devlink_health_j = get_status_output("devlink health show -j")
1050+
if (dev_st != 0):
1051+
return "There are no devices"
1052+
1053+
if (os.path.exists(path + file_name + "/devlink") == False):
1054+
os.mkdir(path + file_name + "/devlink")
1055+
1056+
devlink_health_json = json.loads(devlink_health_j)['health']
1057+
pci_devices = devlink_health_json.keys()
1058+
if (len(pci_devices) < 1):
1059+
return "There are no devices"
1060+
result = "\n" + devlink_health + "\n"
1061+
result += "\n--------------------------------------------------\n"
1062+
1063+
options = ["diagnose", "dump show"]
1064+
if interfaces_flag:
1065+
pci_dev = []
1066+
for device in pci_devices:
1067+
if device.split("/")[-1] in specific_pci_devices:
1068+
pci_dev.append(device)
1069+
pci_devices = pci_dev
1070+
for device in pci_devices:
1071+
for i, reporter in enumerate(devlink_health_json[device]):
1072+
filtered_device_name = device.replace(":", "").replace(".", "").replace("/", "")
1073+
if 'name' in reporter.keys():
1074+
reporter_key = 'name'
1075+
elif 'reporter' in reporter.keys():
1076+
reporter_key = 'reporter'
1077+
else:
1078+
result += '\nError in parsing ' + device + 'information from: "devlink health show -j"\n'
1079+
continue
1080+
if reporter[reporter_key] == "fw_fatal" and 'last_dump_time' in devlink_health_json[device][i].keys():
1081+
command = "devlink health dump show %s reporter %s " % (device, reporter[reporter_key])
1082+
dump_output_result = command + "\n\n"
1083+
dump_output_st, dump_output = get_status_output(command)
1084+
if (dump_output_st != 0):
1085+
dump_output_result += "Error while reading output from command - " + command + "\n"
1086+
dump_output = dump_output.split()
1087+
space = dump_output[1]
1088+
snapshot_id = dump_output[3]
1089+
#devlink health dump show pci/0000:06:00.0/cr-space snapshot 1
1090+
dump_output_st, dump_output = get_status_output("devlink region dump " + device + "/" + space + " snapshot " + snapshot_id)
1091+
if (dump_output_st != 0):
1092+
dump_output_result += "Error while reading output from command - " + command + "\n"
1093+
dump_output_result += dump_output
1094+
devlink_file_name = filtered_device_name + "_" + option.replace(" ", "_") + "_" + reporter[reporter_key] + ".txt"
1095+
full_file_name = "devlink/devlink_" + devlink_file_name
1096+
file = open(path + file_name + "/" + full_file_name, 'w+')
1097+
file.write(dump_output_result)
1098+
file.close()
1099+
result += "<td><a href=" + full_file_name + "> " + devlink_file_name + "</a></td>"
1100+
result += "\n--------------------------------------------------\n"
1101+
else:
1102+
for option in options:
1103+
if 'last_dump_time' in devlink_health_json[device][i].keys() or (not option == "dump show"):
1104+
command = "devlink health %s %s reporter %s " % ( option, device, reporter[reporter_key])
1105+
dump_output_result = command + "\n\n"
1106+
dump_output_st, dump_output = get_status_output(command)
1107+
if (dump_output_st != 0):
1108+
dump_output_result += "Error while reading output from command - " + command + "\n"
1109+
dump_output_result += dump_output
1110+
devlink_file_name = filtered_device_name + "_" + option.replace(" ", "_") + "_" + reporter[reporter_key] + ".txt"
1111+
full_file_name = "devlink/devlink_" + devlink_file_name
1112+
file = open(path + file_name + "/" + full_file_name, 'w+')
1113+
file.write(dump_output_result)
1114+
file.close()
1115+
#dump_output_result += "<td><a href=" + full_file_name + "> " file_name + "</a></td>"
1116+
result += "<td><a href=" + full_file_name + "> " + devlink_file_name + "</a></td>"
1117+
result += "\n--------------------------------------------------\n"
1118+
return result
1119+
1120+
#**********************************************************
10221121

10231122
#**********************************************************
10241123
# devlink handler
@@ -2701,6 +2800,12 @@ def add_command_if_exists(command):
27012800
status = 0
27022801
print_err_flag = 0
27032802
command_is_string = False
2803+
elif (command == "switchdev_legacy_mode"):
2804+
st, result = switchdev_legacy_mode_handler()
2805+
status = 0
2806+
if st != 0:
2807+
status = 1
2808+
print_err_flag = 1
27042809
elif (command == "show_pretty_gids"):
27052810
result = show_pretty_gids_handler()
27062811
status = 0

0 commit comments

Comments
 (0)