mfd-ethtool 3.14.0
Module wrapping multiple ethtool operations.
Requires Python: <3.14,>=3.10

> [!IMPORTANT]  
> This project is under development. All source code and features on the main branch are for the purpose of testing or evaluation and not production ready.

# MFD Ethtool

Module for Ethtool, module implements [mfd-base-tool](https://github.com/intel/mfd-tool)

## Usage
```python
from mfd_connect import SSHConnection
from mfd_ethtool import Ethtool

conn = SSHConnection(username="your_username", password="your_password", ip="x.x.x.x")
ethtool_obj = Ethtool(connection=conn)
print(ethtool_obj.get_version())
print(ethtool_obj.execute_ethtool_command(device_name="intf1"))
print(ethtool_obj.execute_ethtool_command(device_name="intf1", namespace="NS1"))
dev_info = ethtool_obj.get_standard_device_info(device_name="intf1")
print(dev_info.supported_ports)
print(dev_info.supports_auto_negotiation)
pause_options = ethtool_obj.get_pause_options(device_name="intf1", namespace="NS1")
print(pause_options.autonegotiate)
print(ethtool_obj.set_pause_options(device_name="intf1", param_name="autoneg", param_value="off"))
coalesce_options = ethtool_obj.get_coalesce_options(device_name="intf1")
print(coalesce_options.adaptive_tx)
print(ethtool_obj.set_coalesce_options(device_name="intf1", param_name="rx-usecs", param_value="1", namespace="NS1"))
ring_params = ethtool_obj.get_ring_parameters(device_name="intf1")
print(ring_params.preset_max_rx)
print(ring_params.current_hw_rx)
print(ethtool_obj.set_ring_parameters(device_name="intf1", param_name="rx", param_value="512"))
drv_info = ethtool_obj.get_driver_information(device_name="intf1")
print(drv_info.firmware_version)
features = ethtool_obj.get_protocol_offload_and_feature_state(device_name="intf1")
print(features.rx_checksumming, features.tx_checksumming)
print(ethtool_obj.set_protocol_offload_and_feature_state(device_name="intf1", param_name="tso", param_value="on"))
channel_params = ethtool_obj.get_channel_parameters(device_name="intf1")
print(channel_params.preset_max_rx)
print(channel_params.current_hw_rx)
print(ethtool_obj.set_channel_parameters(device_name="intf1", param_name="combined", param_value="2"))
print(ethtool_obj.set_channel_parameters_ice_idpf_aligned(device_name="intf1", param_name="combined rx tx", param_value="5 10 0"))
print(ethtool_obj.get_receive_network_flow_classification(device_name="intf1", param_name="rx-flow-hash",
                                                          param_value="tcp4"))
print(ethtool_obj.set_receive_network_flow_classification(device_name="intf1",
                                                          params="flow-type ip4 proto 1 action -1"))
print(ethtool_obj.show_visible_port_identification(device_name="intf1", duration=5))
print(ethtool_obj.change_eeprom_settings(device_name="intf1", params="offset 0x12 value 0x41", namespace="NS1"))
print(ethtool_obj.do_eeprom_dump(device_name="intf1"))
print(ethtool_obj.restart_negotiation(device_name="intf1"))
stats = ethtool_obj.get_adapter_statistics(device_name="inf1")
print(stats.rx_packets)
print(ethtool_obj.get_statistics_xonn_xoff(device_name="eth1"))
print(ethtool_obj.execute_self_test(device_name="intf1", test_mode="offline"))
print(ethtool_obj.change_generic_options(device_name="intf1", param_name="autoneg", param_value="on"))
priv_flags_output = ethtool_obj.get_private_flags(device_name="intf1")
print(priv_flags_output.priv_flags["flag_name"])
print(ethtool_obj.set_private_flags(device_name="intf1", flag_name="legacy-rx", flag_value="on"))
print(ethtool_obj.get_rss_indirection_table(device_name="intf1"))
print(ethtool_obj.set_rss_indirection_table(device_name="intf1", param_name="equal", param_value="20"))
print(ethtool_obj.flash_firmware_image(device_name="intf1", file="gtp.pkgo", region=100))
print(ethtool_obj.unload_ddp_profile(device_name="intf1", region=100))
fec_settings = ethtool_obj.get_fec_settings(device_name="intf1")
print(fec_settings.active_fec_encodings)
print(ethtool_obj.set_fec_settings(device_name="intf1", setting_name="encoding", setting_value="on"))
print(ethtool_obj.do_register_dump(device_name="intf1"))
print(ethtool_obj.get_time_stamping_capabilities(device_name="intf1"))
print(ethtool_obj.get_perm_hw_address(device_name="intf1"))
print(ethtool_obj.dump_module_eeprom(device_name="intf1"))
eee_settings = ethtool_obj.get_eee_settings(device_name="intf1")
print(eee_settings.eee_status)
print(ethtool_obj.set_eee_settings(device_name="intf1", param_name="eee", param_value="on"))
print(ethtool_obj.set_phy_tunable(device_name="intf1", params="downshift on count 2"))
print(ethtool_obj.reset_components(device_name="intf1", param_name="phy", namespace="NS1"))
print(ethtool_obj.get_dump(device_name="intf1", params="data file.bin"))
print(ethtool_obj.set_dump(device_name="intf1", params="3"))
```

## Ethtool structures:
```python
class GetReceiveNetworkFlowClassification(Enum):
    """Structure for get receive network flow classification options."""

    N = "-n"
    U = "-u"
    ShowNFC = "--show-nfc"
    ShowNtuple = "--show-ntuple"


class SetReceiveNetworkFlowClassification(Enum):
    """ Structure for set receive network flow classification options."""

    N = "-N"
    U = "-U"
    ConfigNFC = "--config-nfc"
    ConfigNtuple = "--config-ntuple"

```

## Implemented methods
`check_if_available() -> None` - checks if Ethtool is available in system, raises `EthtoolNotAvailable` if not

`get_version() -> str` - returns Ethtool version

`execute_ethtool_command(device_name: str, option: str = "", params: str = "", namespace: str | None = None, succeed_codes: frozenset
    ) -> str:` - Executes ethtool command for given device with specified options and parameters

`get_standard_device_info(device_name: str, namespace: str | None = None
    ) -> type[dataclass]` - Get standard information about device, return parsed output 

`get_pause_options(device_name: str, namespace: str | None = None) -> type[dataclass]` - Get pause options

`set_pause_options(device_name: str, param_name: str, param_value: str, namespace: str | None = None, expected_codes: frozenset
    ) -> str` - Set pause options 

`get_coalesce_options(device_name: str, namespace: str | None = None
    ) -> type[dataclass]` - Get coalesce options, return parsed output

`set_coalesce_options(device_name: str, param_name: str, param_value: str, namespace: str | None = None, expected_codes: frozenset
    ) -> str:` - Set coalesce options 

`get_ring_parameters(device_name: str, namespace: str | None = None) -> type[dataclass]:` - Query RX/TX ring parameters, return parsed output

`set_ring_parameters(device_name: str, param_name: str, param_value: str, namespace: str | None = None, expected_codes: frozenset
    ) -> str:` - Set RX/TX ring parameters

`get_driver_information(device_name: str, namespace: str | None = None) -> type[dataclass]`: - Display driver information, return parsed output

`get_protocol_offload_and_feature_state(device_name: str, namespace: str | None = None
    ) -> type[dataclass]:` - Get state of protocol offload and other features, return parsed output

`set_protocol_offload_and_feature_state(device_name: str, param_name: str, param_value: str, namespace: str | None = None, expected_codes: frozenset
    ) -> str:` - Set protocol offload and other features

`get_channel_parameters(device_name: str, namespace: str | None = None) -> type[dataclass]:` - Get channels, return parsed output

`set_channel_parameters(device_name: str, param_name: str, param_value: str, namespace: str | None = None, expected_codes: frozenset
    ) -> str:` - Set channels

`set_channel_parameters_ice_idpf_aligned(device_name: str, param_name: str, param_value: str, namespace: str | None = None, expected_codes: Iterable
    ) -> str:` - Set channels (aligned with ice/idpf implementation according to DCR-5402)

`get_receive_network_flow_classification(device_name: str, option: GetReceiveNetworkFlowClassification = GetReceiveNetworkFlowClassification.U,, param_name: str = "", param_value: str = "", 
    namespace: str | None = None, expected_codes: frozenset) -> str:` - Get Rx network flow classification options or rules

`set_receive_network_flow_classification(device_name: str, params: str, option: SetReceiveNetworkFlowClassification = SetReceiveNetworkFlowClassification.U, namespace: str | None = None, expected_codes: frozenset
    ) -> str:` - Configure Rx network flow classification options or rules

`show_visible_port_identification(device_name: str, duration: str, namespace: str | None = None
    ) -> str:` - Show visible port identification (e.g. blinking)

`change_eeprom_settings(device_name: str, params: str, namespace: str | None = None) -> str:` - Change bytes in device EEPROM

`do_eeprom_dump(device_name: str, params: str = "", namespace: str | None = None) -> str:` - Do EEPROM dump

`restart_negotiation(device_name: str, namespace: str | None = None) -> str:` - Restart N-WAY negotiation

`get_adapter_statistics(device_name: str, namespace: str | None = None) -> type[dataclass]` - Get adapter statistics, return parsed output

`get_statistics_xonn_xoff(self, device_name: str, namespace: str | None = None) -> type[dataclass]` - Show interface statistics - ethtool -S|--statistics DEVNAME with filtered out xon/xoff only.

`execute_self_test(device_name: str, test_mode: str, namespace: str | None = None) -> str` - Execute adapter self test

`change_generic_options(device_name: str, param_name: str, param_value: str, namespace: str | None = None) -> str` - Change generic options

`set_private_flags(device_name: str, flag_name: str, flag_value: str, namespace: str | None = None, expected_codes: frozenset
    ) -> str:` - Set private flags

`get_private_flags(device_name: str, namespace: str | None = None) -> type[dataclass]` - Get private flags, return parsed output

`get_rss_indirection_table(device_name: str, namespace: str | None = None) -> str` - Get Rx flow hash indirection table and/or RSS hash key

`set_rss_indirection_table(device_name: str, param_name: str, param_value: str = "", namespace: str | None = None
    ) -> str` - Set Rx flow hash indirection table and/or RSS hash key

`flash_firmware_image(device_name: str, file: str, region: int, namespace: str | None = None
    ) -> str` - Flash firmware image from the specified file to a region on the device

`unload_ddp_profile(device_name, region: int, namespace: str | None = None) -> str` - Rollback to a previously loaded profile

`get_fec_settings(device_name: str, namespace: str | None = None) -> type[dataclass]` - Get FEC settings, return parsed output

`set_fec_settings(device_name: str, setting_name: str, setting_value: str, namespace: str | None = None) -> str` - Set specified FEC setting

`do_register_dump(device_name: str, params: str = "", namespace: str | None = None) -> str` - Do register dump

`get_time_stamping_capabilities(device_name: str, namespace: str | None = None) -> str` - Get time stamping capabilities

`get_perm_hw_address(device_name: str, namespace: str | None = None) -> str` - Get permanent hardware address

`dump_module_eeprom(device_name: str, params: str = "", namespace: str | None = None
) -> str` - Query/Decode Module EEPROM information and optical diagnostics if available

`get_eee_settings(device_name: str, namespace: str | None = None) -> type[dataclass]` - Get EEE settings, return parsed output

`set_eee_settings(device_name: str, param_name: str, param_value: str, namespace: str | None = None, expected_codes: frozenset) -> str` - Set EEE settings

`set_phy_tunable(device_name: str, params: str, namespace: str | None = None, expected_codes: frozenset) -> str` - Set PHY tunable

`reset_components(device_name: str, param_name: str, param_value: str = "", namespace: str | None = None) -> str` - Reset components

`get_dump(device_name: str, params: str = "", namespace: str | None = None) -> str` - Get dump flag, data

`set_dump(device_name: str, params: str, namespace: str | None = None, expected_codes: frozenset) -> str` - Set dump flag of the device

## OS supported:

Here is a place to write what OSes support your MFD module:
* LINUX

## Issue reporting

If you encounter any bugs or have suggestions for improvements, you're welcome to contribute directly or open an issue [here](https://github.com/intel/mfd-ethtool/issues).