HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/ethtool.cpython-310.pyc
o

�N�g^,�	@s�dZddlZddlZddlZddlmZzddlZdZWne	y'dZYnwe�
e�Zidd�dd�dd	�d
d�dd
�dd�dd�dd�dd�dd�dd�dd�dd�dd�d d!�d"d#�d$d%�d&d'd(d)d*d+��Z
iZe
��D]\ZZeee<qpd,d-d.d/d0d1d2d3d4�ZiZe��D]\ZZeee<q�d5Zd6d7�Zd8d9�Zd:d;�Zd<d=�Zd>d?�Zd@dA�ZdBdC�ZdDdE�ZdFdG�ZdHdI�ZdJdK�ZdLdM�Z dNdO�Z!dPdQ�Z"dS)Rz�
Module for running ethtool command

.. versionadded:: 2016.3.0

:codeauthor:    Krzysztof Pawlowski <msciciel@msciciel.eu>
:maturity:      new
:depends:       python-ethtool
:platform:      linux
�N)�CommandExecutionErrorTFZ
pkt_rate_highZpkt_rate_lowZsample_intervalZrate_sample_intervalZrx_usecsZrx_coalesce_usecsZ
rx_usecs_highZrx_coalesce_usecs_highZrx_usecs_irqZrx_coalesce_usecs_irqZrx_usecs_lowZrx_coalesce_usecs_lowZ	rx_framesZrx_max_coalesced_framesZrx_frames_highZrx_max_coalesced_frames_highZ
rx_frames_irgZrx_max_coalesced_frames_irqZ
rx_frames_lowZrx_max_coalesced_frames_lowZstats_block_usecsZstats_block_coalesce_usecsZtx_usecsZtx_coalesce_usecsZ
tx_usecs_highZtx_coalesce_usecs_highZtx_usecs_irqZtx_coalesce_usecs_irqZtx_usecs_lowZtx_coalesce_usecs_lowZ	tx_framesZtx_max_coalesced_framesZtx_max_coalesced_frames_highZtx_max_coalesced_frames_irqZtx_max_coalesced_frames_lowZuse_adaptive_rx_coalesceZuse_adaptive_tx_coalesce)Ztx_frames_highZ
tx_frames_irqZ
tx_frames_lowZadaptive_rxZadaptive_txZ
rx_pendingZrx_max_pendingZrx_mini_pendingZrx_mini_max_pendingZrx_jumbo_pendingZrx_jumbo_max_pendingZ
tx_pendingZtx_max_pending)�rxZrx_maxZrx_miniZrx_mini_maxZrx_jumboZrx_jumbo_max�txZtx_max�ethtoolcCstrtSdS)z>
    Only load this module if python-ethtool is installed
    )FzKThe ethtool module could not be loaded: ethtool python libraries not found.)�HAS_ETHTOOL�__virtualname__�rr�H/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/ethtool.py�__virtual__Ksr
cC�Zzt�|�}Wntyt�d|�YdSwi}|��D]\}}|||t|<q|S)z�
    Queries the specified network device for rx/tx ring parameter information

    CLI Example:

    .. code-block:: bash

        salt '*' ethtool.show_ring <devname>
    �#Ring parameters not supported on %s�
Not supported)r�
get_ringparam�OSError�log�error�items�ethtool_ring_remap)�devname�ring�ret�key�valuerrr	�	show_ringY��rcCr)z�
    Queries the specified network device for coalescing information

    CLI Example:

    .. code-block:: bash

        salt '*' ethtool.show_coalesce <devname>
    �(Interrupt coalescing not supported on %sr
)r�get_coalescerrrr�ethtool_coalesce_remap)r�coalescerrrrrr	�
show_coalesceqrrcCsnzt�|�}Wntyt�d|�YdSwzt�|�}Wnty/t�d|�YdSw||d�}|S)z�
    Queries the specified network device for associated driver information

    CLI Example:

    .. code-block:: bash

        salt '*' ethtool.show_driver <devname>
    z(Driver information not implemented on %szNot implementedz"Bus information no available on %sz
Not available)ZdriverZbus_info)rZ
get_modulerrrZget_businfo)r�moduleZbusinforrrr	�show_driver�s ���r!cK�zt�|�}Wntyt�d|�YdSwd}|��D]\}}|tvr:t|}||vr:|||kr:|||<d}qz
|rDt�||�t|�WStyYt�d||�YdSw)z�
    Changes the rx/tx ring parameters of the specified network device

    CLI Example:

    .. code-block:: bash

        salt '*' ethtool.set_ring <devname> [rx=N] [rx_mini=N] [rx_jumbo=N] [tx=N]
    rr
FTz Invalid ring arguments on %s: %s�Invalid arguments)	rrrrrr�ethtool_ring_mapZ
set_ringparamr)r�kwargsr�changed�paramrrrr	�set_ring�s.��
�r(cKr")aY
    Changes the coalescing settings of the specified network device

    CLI Example:

    .. code-block:: bash

        salt '*' ethtool.set_coalesce <devname> [adaptive_rx=on|off] [adaptive_tx=on|off] [rx_usecs=N] [rx_frames=N]
            [rx_usecs_irq=N] [rx_frames_irq=N] [tx_usecs=N] [tx_frames=N] [tx_usecs_irq=N] [tx_frames_irq=N]
            [stats_block_usecs=N] [pkt_rate_low=N] [rx_usecs_low=N] [rx_frames_low=N] [tx_usecs_low=N] [tx_frames_low=N]
            [pkt_rate_high=N] [rx_usecs_high=N] [rx_frames_high=N] [tx_usecs_high=N] [tx_frames_high=N]
            [sample_interval=N]
    rr
FTz$Invalid coalesce arguments on %s: %sr#)	rrrrrr�ethtool_coalesce_map�set_coalescer)rr%rr&r'rrrr	r*�s.��
�r*cCs�zt�|�rdp	d}Wntyd}Ynwzt�|�rdp d}Wnty-d}Ynwzt�|�r6dp7d}WntyDd}Ynwzt�|�rMdpNd}Wnty[d}Ynw||||d�}|S)z�
    Queries the specified network device for the state of protocol offload and other features

    CLI Example:

    .. code-block:: bash

        salt '*' ethtool.show_offload <devname>
    �on�offz
not supported)Zscatter_gather�tcp_segmentation_offloadZudp_fragmentation_offloadZgeneric_segmentation_offload)rZget_sgrZget_tsoZget_ufoZget_gso)r�sg�tso�ufo�gsoZoffloadrrr	�show_offload�s4�����r2c	KsZ|��D]$\}}|dkr(|dkrdpd}zt�||�Wqty'YdSwqt|�S)z�
    Changes the offload parameters and other features of the specified network device

    CLI Example:

    .. code-block:: bash

        salt '*' ethtool.set_offload <devname> tcp_segmentation_offload=on
    r-r+�rr
)rrZset_tsorr2)rr%r'rrrr	�set_offloads��r4cOs�tjj�d�}|s
td��d�dd�|D��}d�dd�|��D��}|�d|�d|�d|����}td|dd	��	�}|rK|d
�
d�rKt|d
��|S)z5
    Helper function to build an ethtool command
    rz!Command 'ethtool' cannot be found� css�|]}|VqdS�Nr)�.0�argrrr	�	<genexpr>:s�z#_ethtool_command.<locals>.<genexpr>css"�|]\}}|�d|��VqdS)r5Nr)r7r�valrrr	r9;s� zcmd.runT)Zignore_retcoderZCannot)�salt�utils�path�whichr�joinr�stripZ__salt__�
splitlines�
startswith)r�argsr%rZswitches�params�cmdrrrr	�_ethtool_command3srFcCs^i}|��D]\}}|��}||vr#|durd}n|durd}|||<q|s-td|����|S)z�
    Helper function to validate parameters to ethtool commands. Boolean values
    will be transformed into ``on`` and ``off`` to match expected syntax.
    Tr+Fr,z,None of the valid parameters were provided: )r�lowerr)�valid_paramsr%Z	validatedrr:rrr	�_validate_paramsCs��rIcCsRi}t|d�}|dd�D]}|��r&dd�|�dd�D�\}}|dk||<q
|S)z�
    .. versionadded:: 3006.0

    Queries the specified network device for associated pause information

    CLI Example:

    .. code-block:: bash

        salt '*' ethtool.show_pause <devname>
    z-ar3Ncs��|]}|��VqdSr6�r@�r7�srrr	r9j��zshow_pause.<locals>.<genexpr>�:r+�rFr@�split)r�data�content�linerrrrr	�
show_pauseXs
�rUcKs0gd�}t||�}t|dfi|��}|sdS|S)z�
    .. versionadded:: 3006.0

    Changes the pause parameters of the specified network device

    CLI Example:

    .. code-block:: bash

        salt '*' ethtool.set_pause <devname> autoneg=off rx=off tx=off
    )Zautonegrrz-AT)rIrF�rr%rHrDrrrr	�	set_pauseps
rWcCs|i}t|d�}|dd�D].}d|vr;dd�|���dd�D�\}}d|v}|r0|��d��}|d	k|d
�||��<q
|S)z�
    .. versionadded:: 3006.0

    Queries the specified network device for associated feature information

    CLI Example:

    .. code-block:: bash

        salt '*' ethtool.show_features <devname>
    z-kr3NrOcsrJr6rKrLrrr	r9�rNz show_features.<locals>.<genexpr>�fixedrr+)r+rXrP)rrRrSrTrrrXrrr	�
show_features�s
�rYcKs8gd�}t||�}t|dfi|��}|sdStj�|�S)z�
    .. versionadded:: 3006.0

    Changes the feature parameters of the specified network device

    CLI Example:

    .. code-block:: bash

        salt '*' ethtool.set_feature <devname> sg=off
    )rrr.r/r0r1ZgroZlroZrxvlanZtxvlanZntupleZrxhashz-KT)rIrF�os�linesepr?rVrrr	�set_feature�s
r\)#�__doc__�loggingrZZsalt.utils.pathr;Zsalt.exceptionsrrr�ImportError�	getLogger�__name__rr)rr�k�vr$rrr
rrr!r(r*r2r4rFrIrUrWrYr\rrrr	�<module>s��
��������	�
���
������
�
#))