
    G%@i                     ,    d dl mZmZ  G d dee      Zy)    )PluginIndependentPluginc                   2    e Zd ZdZdZdZdZed        Zd Z	y)Spyreu   Spyre 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 Informationspyre)zppc.*c                    g }| sy| j                         D ]  }|j                         s	 |j                  d      \  }}}}|j                         j                  d      \  }}|dk(  sT|dv sY|j                  d      dk(  rd|z   }	 |j                  d      \  }	}
}|j                  d	      \  }}|j                  |	|
||f        |S # t        $ r Y w xY w# t        $ r Y w xY w)
a  Extract 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:1014)06a706a8   z0000:.)
splitlinesstripsplitlower
ValueErrorcountappend)lspci_outputspyre_cardslinepci_addr_classids_restvendordevicedomainbusdev_func
pci_devicefunctions                 :/usr/lib/python3/dist-packages/sos/report/plugins/spyre.pyget_ibm_spyre_deviceszSpyre.get_ibm_spyre_devices   s   $  ++- 	HD::</3zz1z/E,&#u!$!2!23!7 F.>$>>>#&!+&1H,4NN3,?)FC+3>>#+>(J ""FCX#FG'	H*    " s#   9C	)C	CC	C&%C&c                     | j                  d      }|d   dk7  ry | j                  |d         }|sy |D ]3  \  }}}}| d| d| d| }d| d| d| d	}| j                  |d
       5 | j                  g d       y )Nzlspci -nstatusr   outputr   r   z/sys/devices/pci/z	/vfio-devT)tree)z/etc/modprobe.d/vfio-pci.confz!/etc/udev/rules.d/95-vfio-3.rulesz#/etc/security/limits.d/memlock.conf)exec_cmdr'   add_dir_listingadd_copy_spec)	selflspcir   r!   r"   r    r%   r   pci_vfios	            r&   setupzSpyre.setupH   s    j)?a00xA  .9 	6)FC 3%q(<H)&3%q
)LH   5	6 	 
 	    N)
__name__
__module____qualname____doc__
short_descplugin_namearchitecturesstaticmethodr'   r3    r4   r&   r   r      s0     5JKM+ +Zr4   r   N)sos.report.pluginsr   r   r   r=   r4   r&   <module>r?      s    9QF% Qr4   