4040DEFAULT_PATH = '/tmp/'
4141SUCCESS_STATUS = 0
4242FAILED_STATUS = 1
43+ HIDE_STATUS = 2
4344
4445######################################################################################################
4546# no_log_status_output
@@ -118,7 +119,7 @@ def __ge__(self, other):
118119######################################################################################################
119120# GLOBAL GENERAL VARIABLES
120121
121- version = "3.7.9.4 "
122+ version = "3.7.9.5 "
122123sys_argv = sys .argv
123124len_argv = len (sys .argv )
124125driver_required_loading = False
@@ -139,6 +140,7 @@ def __ge__(self, other):
139140asap_devices = []
140141mtusb_devices = []
141142vf_pf_devices = []
143+ mft_tools_pci_devices = []
142144config_dict = {}
143145local_mst_devices = []
144146json_flag = False
@@ -741,6 +743,7 @@ def update_net_devices():
741743 global mst_devices_exist
742744 global is_bluefield_involved
743745 global is_run_from_bluefield_host
746+ global mft_tools_pci_devices
744747
745748 errors = []
746749
@@ -795,6 +798,9 @@ def update_net_devices():
795798 mtusb_dev .append (dev )
796799 mtusb_devices = mtusb_dev
797800 for lspci_device in pci_devices :
801+ is_valid_mft_tools_dev = is_valid_mft_tools_device (lspci_device )
802+ if is_valid_mft_tools_dev :
803+ mft_tools_pci_devices .append (lspci_device )
798804 device = lspci_device .split ()[0 ]
799805 if "function" in lspci_device .lower ():
800806 if not device in vf_pf_devices :
@@ -1242,6 +1248,10 @@ def mlxdump_handler():
12421248 options = ["fsdump" ]
12431249 temp = '_run_'
12441250 for pci_device in pci_devices :
1251+ is_valid_mft_tools_dev = is_valid_mft_tools_device (pci_device ["name" ])
1252+ if not is_valid_mft_tools_dev :
1253+ # Not valid for mft tools commands
1254+ continue
12451255 device = pci_device ["device" ]
12461256 if device in vf_pf_devices :
12471257 continue
@@ -1444,6 +1454,10 @@ def fwtrace_handler():
14441454 options = ["-i all --tracer_mode FIFO" ]
14451455 fwtrace = ""
14461456 for pci_device in pci_devices :
1457+ is_valid_mft_tools_dev = is_valid_mft_tools_device (pci_device ["name" ])
1458+ if not is_valid_mft_tools_dev :
1459+ # Not valid for mft tools commands
1460+ continue
14471461 device = pci_device ["device" ]
14481462 if device .split ('.' )[1 ].strip () != "0" :
14491463 continue
@@ -1708,6 +1722,10 @@ def mstcommand_d_handler(command,pcie_debug = False):
17081722 mst_status_rs , mst_status_output = get_status_output ("mst status -v" )
17091723 # PCIe ports
17101724 for pci_device in pci_devices :
1725+ is_valid_mft_tools_dev = is_valid_mft_tools_device (pci_device ["name" ])
1726+ if not is_valid_mft_tools_dev :
1727+ # Not valid for mft tools commands
1728+ continue
17111729 device = pci_device ["device" ]
17121730 if is_MFT_installed :
17131731 if device not in mst_status_output :
@@ -1789,6 +1807,15 @@ def _handle_tools_cmd(command, card, timeout = '80'):
17891807 fw_query_full_cmd = "%s %s" % (fw_query_base_cmd , flint_flags )
17901808 else :
17911809 fw_query_full_cmd = ""
1810+ if command == "mlxdump" :
1811+ mlxdump_pcie_cmd = None
1812+ mlxdump_version_cmd = "mlxdump -v"
1813+ rs , res = get_status_output (mlxdump_version_cmd )
1814+ if rs == 0 :
1815+ if "internal" in res :
1816+ # This command works only for internal MFT
1817+ mlxdump_pcie_cmd = commands_dict ["mlxdump" ][0 ]
1818+
17921819 running_command_dict = {"fwflint_q" : {"cmd" : fw_query_full_cmd , "error" : fwflint_error },
17931820 "fwflint_dc" : {"cmd" : fw_query_full_cmd , "error" : fwflint_error },
17941821 "fwdump" : {"cmd" : fw_dump_cmd , "error" : fwdump_error },
@@ -1800,7 +1827,7 @@ def _handle_tools_cmd(command, card, timeout = '80'):
18001827 running_command = running_command_dict [command ]["cmd" ]
18011828 # Check if running_command is None (e.g., mlxdump when MFT is not installed)
18021829 if running_command is None :
1803- return (FAILED_STATUS , running_command_dict [command ]["error" ], tool_error )
1830+ return (HIDE_STATUS , running_command_dict [command ]["error" ], running_package )
18041831 st , command_output = get_status_output (running_command , timeout )
18051832 if st == SUCCESS_STATUS : # Success
18061833 return (SUCCESS_STATUS , command_output , running_package )
@@ -1814,8 +1841,9 @@ def _handle_tools_cmd(command, card, timeout = '80'):
18141841 command_error = fwflint_dc_error
18151842 ret_status = SUCCESS_STATUS
18161843 else :
1844+ command_error = tool_error
18171845 ret_status = FAILED_STATUS
1818- return (ret_status , command_error , tool_error )
1846+ return (ret_status , command_error , running_package )
18191847
18201848def general_fw_command_output (command , card , timeout = '80' ):
18211849 command_error = "Could not run firmware command: " + command
@@ -1970,6 +1998,8 @@ def general_fw_commands_handler(command, card, filtered_file_name, timeout = '80
19701998 return ("Error in creating new file in the system" , "Error in creating new file in the system" , 1 )
19711999 elif (command == 'mlxdump' ):
19722000 st , res , tool_used = general_fw_command_output (command , card , timeout )
2001+ if st == FAILED_STATUS and tool_used == 'mst' or st == HIDE_STATUS :
2002+ return (command , res , FAILED_STATUS )
19732003 try :
19742004 f = open (path + file_name + "/firmware/mlxdump_" + filtered_file_name + "_pcie_uc" , "w+" )
19752005 f .write (" mlxdump -d " + card + " pcie_uc" + "\n " )
@@ -2051,6 +2081,13 @@ def process_card_worker(args):
20512081 generate_mst_config (device , local_output )
20522082 return local_output
20532083
2084+ def is_valid_mft_tools_device (device_desc ):
2085+ if "mlx5Gen PCIe Bridge" not in device_desc \
2086+ and "DMA controller" not in device_desc \
2087+ and "SoC PCIe Bridge" not in device_desc :
2088+ return True
2089+ return False
2090+
20542091def mst_func_handler ():
20552092 all_devices = []
20562093 mstregdump_out = []
@@ -2059,6 +2096,9 @@ def mst_func_handler():
20592096 mstregdump_out .append ("There are no Mellanox cards.\n " )
20602097 return 2 , mstregdump_out
20612098 for pci_device in pci_devices :
2099+ is_valid_mft_tools_dev = is_valid_mft_tools_device (pci_device ["name" ])
2100+ if not is_valid_mft_tools_dev :
2101+ continue
20622102 all_devices .append (pci_device ["device" ])
20632103 if mtusb_flag :
20642104 if len (mtusb_devices ) < 1 :
@@ -2080,7 +2120,6 @@ def mst_func_handler():
20802120 args = (card , temp , mst_status_output , is_MFT_installed , is_MST_installed , vf_pf_devices )
20812121 result = process_card_worker (args )
20822122 mstregdump_out .extend (result )
2083-
20842123 for card in all_devices :
20852124 generate_card_logs (card , mstregdump_out , mst_status_output )
20862125
@@ -2523,26 +2562,36 @@ def mlxreg_handler_ppcc():
25232562 result = []
25242563 cmd_type_values = ['0' ,'3' ,'4' ,'5' ,'0xa' ]
25252564 algo_slot_range = 16
2526- if (not os .path .exists (path + file_name + "/mlxreg_pcc/" )):
2527- no_log_status_output ("mkdir " + path + file_name + "/mlxreg_pcc" )
2565+ if is_MFT_installed :
2566+ mlxreg_bas_cmd = "mlxreg"
2567+ elif is_MST_installed :
2568+ mlxreg_bas_cmd = "mstreg"
2569+ else :
2570+ mlxreg_bas_cmd = None
2571+ if (not os .path .exists (path + file_name + "/%s_pcc/" % mlxreg_bas_cmd )):
2572+ no_log_status_output ("mkdir " + path + file_name + "/%s_pcc" % mlxreg_bas_cmd )
25282573 for pci_device in pci_devices :
2574+ is_valid_mft_tools_dev = is_valid_mft_tools_device (pci_device ["name" ])
2575+ if not is_valid_mft_tools_dev :
2576+ # Not valid for mft tools commands
2577+ continue
25292578 device = pci_device ["device" ]
25302579 filter_file_name = device .replace ("." ,"_" ).replace (":" ,"_" )
25312580 for cmd_type in cmd_type_values :
25322581 for algoSlot in range (algo_slot_range ):
2533- mlxreg_ppc_cmd = "mlxreg -d " + device + " -y --get --op 'cmd_type=" + cmd_type + "' --reg_name PPCC --indexes 'local_port=1,pnat=0,lp_msb=0,algo_slot=" + str (algoSlot )+ ",algo_param_index=0'"
2582+ mlxreg_ppc_cmd = "%s -d " % mlxreg_bas_cmd + device + " -y --get --op 'cmd_type=" + cmd_type + "' --reg_name PPCC --indexes 'local_port=1,pnat=0,lp_msb=0,algo_slot=" + str (algoSlot )+ ",algo_param_index=0'"
25342583 st ,res = get_status_output (mlxreg_ppc_cmd )
25352584 try :
2536- with open (path + file_name + "/mlxreg_pcc/" + filter_file_name , "a+" ) as outF :
2537- outF .write ("mlxreg -d " + device + " -y --get --op 'cmd_type=" + cmd_type + "' --reg_name PPCC --indexes 'local_port=1,pnat=0,lp_msb=0,algo_slot=" + str (algoSlot ) + ",algo_param_index=0' \n \n " )
2585+ with open (path + file_name + "/%s_pcc/" % mlxreg_bas_cmd + filter_file_name , "a+" ) as outF :
2586+ outF .write ("%s -d " % mlxreg_bas_cmd + device + " -y --get --op 'cmd_type=" + cmd_type + "' --reg_name PPCC --indexes 'local_port=1,pnat=0,lp_msb=0,algo_slot=" + str (algoSlot ) + ",algo_param_index=0' \n \n " )
25382587 if cmd_type == '4' : # If cmd_type is '4', write only the first 11 lines
25392588 lines = res .splitlines ()[:15 ] # Split into lines and take the first 11
25402589 outF .write ("\n " .join (lines ) + "\n " )
25412590 else :
25422591 outF .write (res + "\n " )
25432592 except :
2544- print ("Could not open the file: " + file_name + "mlxreg_pcc/" + filter_file_name )
2545- result .append ("<td><a href='mlxreg_pcc/" + filter_file_name + "'> " + device + " </a></td>" )
2593+ print ("Could not open the file: " + file_name + "%s_pcc/" % mlxreg_bas_cmd + filter_file_name )
2594+ result .append ("<td><a href='%s_pcc/" % mlxreg_bas_cmd + filter_file_name + "'> " + device + " </a></td>" )
25462595 if not result :
25472596 return 1 , "No devices found"
25482597 return 0 , result
@@ -4004,6 +4053,7 @@ def arrange_server_commands_section():
40044053 if is_run_from_bluefield_host :
40054054 commands_collection .append ('bfver' )
40064055
4056+
40074057 for cmd in commands_collection :
40084058 related_flag = ""
40094059 if cmd in pcie_collection :
@@ -4735,6 +4785,7 @@ def performance_lspci(check_latest=False):
47354785 global pci_devices
47364786 global direct
47374787 global running_warnings
4788+ global mft_tools_pci_devices
47384789
47394790 key = "PCI Configurations"
47404791 #lspci -d 15b3: - e.g 81:00.0 Ethernet controller: Mellanox Technologies MT27800 Family [ConnectX-5]
@@ -4756,10 +4807,20 @@ def performance_lspci(check_latest=False):
47564807 direct = True
47574808 return
47584809 mlnx_cards = mlnx_cards .splitlines ()
4810+ for card in mlnx_cards :
4811+ is_valid_mft_tools_dev = is_valid_mft_tools_device (card )
4812+ if not is_valid_mft_tools_dev :
4813+ # Not valid for mft tools commands
4814+ continue
4815+ mft_tools_pci_devices .append (card )
47594816 i = - 1
47604817 is_all_failed = True
47614818 for card in mlnx_cards :
47624819 i += 1
4820+ if card not in mft_tools_pci_devices :
4821+ mft_tools_cmd_run = False
4822+ else :
4823+ mft_tools_cmd_run = True
47634824 card_pci = card .split ()[0 ]
47644825 pci_devices .append ({"status" :"OK" , "name" :card , "device" :card_pci , "current_fw" :"" , "psid" :"" , "desired_gen" :3.0 , "current_gen" :3.0 , "desired_speed" :8.0 , "current_speed" :8.0 , "desired_width" :8.0 , "current_width" :8.0 , "desired_payload_size" :256.0 , "current_payload_size" :8.0 , "desired_max_read_request" :4096.0 , "current_max_read_request" :4096.0 })
47654826 if ( (not "[" in card ) or (not "]" in card ) ):
@@ -4779,6 +4840,10 @@ def performance_lspci(check_latest=False):
47794840 else :
47804841 pci_devices [i ]["desired_payload_size" ] = 256.0
47814842 pci_devices [i ]["desired_max_read_request" ] = 512.0
4843+ if not mft_tools_cmd_run :
4844+ # skip if card is in mft_tools_pci_devices
4845+ # flint query will not work for these cards
4846+ continue
47824847 st , firmwares_query , tool_used = general_fw_command_output ('fwflint_q' , card_pci )
47834848 if (st == 0 ):
47844849 #firmwares_query :-
@@ -4848,6 +4913,7 @@ def performance_lspci(check_latest=False):
48484913 return
48494914 i = - 1
48504915 cards_speed_width = cards_speed_width .splitlines ()
4916+
48514917 for line in cards_speed_width :
48524918 line = line .lower ()
48534919 if ("lnksta:" in line ):
@@ -5904,6 +5970,7 @@ def load_modules():
59045970 global mst_devices_exist
59055971 global MFT_INSTALLED_MESSAGE
59065972 is_MFT_installed , MFT_INSTALLED_MESSAGE = is_mft_installed ()
5973+ is_MST_installed , _ = is_mstflint_installed ()
59075974 get_status_output ("mst start > /dev/null 2>&1" , timeout = "30" )
59085975 if with_inband_flag :
59095976 get_status_output ("mst cable add --with_ib > /dev/null 2>&1" , timeout = "30" )
@@ -5921,8 +5988,6 @@ def load_modules():
59215988 if ((device .startswith ('SW' ) or device .startswith ('CA' )) and ('cable' ) in device ):
59225989 are_inband_cables_loaded = True
59235990 break
5924-
5925- is_MST_installed , _ = is_mstflint_installed ()
59265991 return
59275992
59285993def generate_pcie_debug_info ():
0 commit comments