3 ܓi @s&ddlmZmZGdddeeZdS))PluginIndependentPluginc@s0eZdZdZdZdZd ZeddZddZ d S) SpyreuSpyre chip is IBM’s AI accelerator, designed to handle AI inferencing and workloads. The Spyre plugin collects data about the Spyre card’s VFIO device node tree, configuration files, and more. z!IBM Spyre Accelerator InformationZspyreppc.*cCsg}|s dSx|jD]}|js$qy*|jdd\}}}}|jjd\}}Wntk rdwYnX|dkr|d kr|jddkrd |}y"|jd\} } } | jd \} } Wntk rwYnX|j| | | | fqW|S) aExtract PCI domain, bus, device, function for devices that match: - Vendor ID = 0x1014 (IBM) - Device ID = 0x06a7 or 0x06a8 Parameters ---------- lspci_out : str The output string from `lspci -n`. Returns ------- list of tuples A list of (domain, bus, device, function) tuples for each matching card. N)maxsplit:Z101406a706a8z0000:.)r r ) splitlinesstripsplitlower ValueErrorcountappend)Z lspci_output spyre_cardslinepci_addrZ_classZidsZ_restZvendordevicedomainbusZdev_funcZ pci_devicefunctionr/usr/lib/python3.6/spyre.pyget_ibm_spyre_devicess*zSpyre.get_ibm_spyre_devicesc Cs|jd}|ddkrdS|j|d}|s0dSxT|D]L\}}}}|d|d|d|}d|d|d|d }|j|d d q6W|jd d dgdS)Nzlspci -nZstatusroutputrr z/sys/devices/pci/z /vfio-devT)Ztreez/etc/modprobe.d/vfio-pci.confz!/etc/udev/rules.d/95-vfio-3.rulesz#/etc/security/limits.d/memlock.conf)Zexec_cmdrZadd_dir_listingZ add_copy_spec) selfZlspcirrrrrrZpci_vfiorrrsetupHs  z Spyre.setupN)r) __name__ __module__ __qualname____doc__Z short_descZ plugin_nameZ architectures staticmethodrr!rrrrrs  .rN)Zsos.report.pluginsrrrrrrr s