
    -_g                     <    d dl Z d dlZd dlmZmZ  G d dee      Zy)    N)PluginIndependentPluginc                   2    e Zd ZdZdZdZdZdZd Zd Z	d Z
y	)
MellanoxFirmwarez&Nvidia(Mellanox) firmware tools outputmellanox_firmware)hardwaresystem)mstmstflintzMellanox Technologiesc                 Z    | j                  d      }|d   dk(  xr | j                  |d   v S )z
        Checks if this plugin should be executed at all.
        We will only enable the plugin if there is a
        Mellanox Technologies network adapter
        lspci -D -d 15b3::0200statusr   output)exec_cmdMLNX_STRING)selflspcis     F/usr/lib/python3/dist-packages/sos/report/plugins/mellanox_firmware.pycheck_enabledzMellanoxFirmware.check_enabled   s6     67X!#K(8(8E(O(KK    c                    | j                  d      s| j                  d       y | j                  d      }|d   dk7  ry | j                  d      }|d   dk7  ry | j                  d       | j                  dd	
       | j                  dd	
       t	        j
                  d      }g }|D ]  }d|v s|j                  |        |D ]0  }| j                  d| dd	
       | j                  d| dd	
       2 | j                  dd       y )Nallow_system_changesztSkipping mst/mlx cable commands as system changeswould be made. Use --allow-system-changes toenable this collection.flint --versionr   r   z	mst startzmst cable addzmst status -v
   timeout	mlxcablesz/dev/mstcablezmlxcables -d z --DDMz --dumpzmst stopT)changes)
get_option	_log_infor   collect_cmd_outputoslistdirappend)r   coutr   devicemlxcables        r   collectzMellanoxFirmware.collect#   s8   56NN 5 6  }}./>Q&&{3>Q0<R8zz*%	 	)F&   (	) " 	0H##mH:V$D,. $ 0##mH:W$E,. $ 0	0
 	
D9r   c           
         g }| j                  d      }|d   dk7  ry |d   j                         D ]  }|j                  |dd dz           t        |      }g }| j	                  d      }|d   dk7  rdd	gd
dgd
dgddgddgg}nddgdd	gddgddgddgddgddgg}|D ]c  }|D ]#  }| j                  |d    d| d|d    d       % t        d      D ]+  }| j                  d|        t        j                  d       - e y )Nr   r   r   r      z00.0r   zmstconfig -d z -e qzmstflint -d z dcz qz
mstreg -d z --reg_name ROCE_ACCL --getzmstlink -d  zmlxdump -d z pcie_uc --allz	flint -d z
mlxreg -d zmlxlink -d zfwtrace -d z -i all --tracer_mode FIFO       r      zmstdump )	r"   
splitlinesr%   setr   add_cmd_outputrangetimesleep)	r   devicesdevice_listlinecommandsr&   r'   command_s	            r   setupzMellanoxFirmware.setupC   s   --.FG x A%)446 	-D
 NN4!9V+,	- g,  }}./>Q !'*'&<=#H  01 '*e$d#<=# <=H  
	F# A##wqzl!F81'.qzl%4=? $ AA 1X ##hvh$78

1
	r   N)__name__
__module____qualname__
short_descplugin_nameprofilespackagesr   r   r)   r=    r   r   r   r      s,    9J%K%H"H)KL:@9r   r   )r#   r5   sos.report.pluginsr   r   r   rE   r   r   <module>rG      s!    
  8lv0 lr   