The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Linux::Ethtool::Settings - Manipulate link-level network interface settings

SYNOPSIS

  use Linux::Ethtool::Settings;
  
  my $settings = Linux::Ethtool::Settings->new("eth0") or die($!);
  
  # Show the current/supported modes.
  
  my $current_speed  = $settings->speed();
  my $current_duplex = $settings->duplex() ? "full" : "half";
  
  print "Current speed:    $current_speed Mbps, $current_duplex duplex\n";
  
  my @supported_modes = $settings->supported_modes();
  
  print "Supported speeds: @supported_modes\n";
  
  # Force the interface to 10Mbps, half duplex
  
  $settings->autoneg(0);
  $settings->speed(10);
  $settings->duplex(0);
  
  $settings->apply() or die($!);
  
  # Turn auto-negotiation back on. Setting advertising to supported is required
  # if the object was constructed when auto-negotiation was disabled or Linux
  # will try to auto-negotiate with no speeds...
  
  $settings->autoneg(1);
  $settings->advertising($settings->supported);
  
  $settings->apply() or die($!);

DESCRIPTION

This module provides a wrapper around the ethtool_cmd structure and associated ioctls, mainly used for configuring link-level settings such as speed/duplex and auto-negotiation.

All the constants in this module may be imported individually or by using the all import tag.

METHODS

new($dev)

Construct a new instance using the settings of the named interface.

Returns an object instance on success, undef on failure.

apply()

Apply any changed settings to the interface.

Returns true on success, false on failure.

supported()

Returns the features supported by this interface as a bit field. The following constants are useful here:

  SUPPORTED_TP
  SUPPORTED_AUI
  SUPPORTED_MII
  SUPPORTED_FIBRE
  SUPPORTED_BNC
  
  SUPPORTED_Autoneg
  
  SUPPORTED_10baseT_Half
  SUPPORTED_10baseT_Full
  SUPPORTED_100baseT_Half
  SUPPORTED_100baseT_Full
  SUPPORTED_1000baseT_Half
  SUPPORTED_1000baseT_Full
  SUPPORTED_2500baseX_Full
  SUPPORTED_1000baseKX_Full
  SUPPORTED_10000baseT_Full
  SUPPORTED_10000baseKX4_Full
  SUPPORTED_10000baseKR_Full
  SUPPORTED_10000baseR_FEC
  
  SUPPORTED_Pause
  SUPPORTED_Asym_Pause
  SUPPORTED_Backplane

supported_modes()

Returns a sorted list of supported speed/duplex settings suitable for showing to the user.

supported_ports()

Returns a list of ports on this interface suitable for showing to the user.

NOTE: This is unrelated to cards that have multiple interfaces on them, this is for (old fashioned) cards that have multiple ports (AUI, BNC, etc) for the same interface,only one of which may be used at a time. See the port method for more information.

advertising([ $advertising ])

Gets or sets the modes being advertised for auto-negotiation as a bit field. Returns the current/new value.

The following constants are useful here:

  ADVERTISED_10baseT_Half
  ADVERTISED_10baseT_Full
  ADVERTISED_100baseT_Half
  ADVERTISED_100baseT_Full
  ADVERTISED_1000baseT_Half
  ADVERTISED_1000baseT_Full
  ADVERTISED_2500baseX_Full
  ADVERTISED_1000baseKX_Full
  ADVERTISED_10000baseT_Full
  ADVERTISED_10000baseKX4_Full
  ADVERTISED_10000baseKR_Full
  ADVERTISED_10000baseR_FEC
  ADVERTISED_Pause
  ADVERTISED_Asym_Pause

advertising_modes()

Returns a sorted list of advertised speed/duplex settings suitable for showing to the user.

speed([ $speed ])

Get or set the link speed in Mbps. Returns the current/new value.

Setting this field will only have an effect if auto-negotiation is also disabled before calling apply.

duplex([ $duplex ])

Get or set the duplex of the link, full is true, half is false and unknown is undefined. Returns the current/new value.

Setting this field will only have an effect if auto-negotiation is also disabled before calling apply.

autoneg([ $autoneg ])

Get or set the auto-negotiation flag. Returns the current/new value.

port([ $port ])

Get or set the port type. Returns the current/new value.

The following constants are useful here:

  PORT_TP     (Twisted Pair)
  PORT_AUI
  PORT_MII    (Media Independent Interface)
  PORT_FIBRE
  PORT_BNC
  PORT_OTHER

port_name()

Return a user-friendly name for the port type.

transceiver([ $transceiver ])

Get or set the transceiver type. Returns the current/new value.

The following constants are useful here:

  XCVR_INTERNAL
  XCVR_EXTERNAL
  XCVR_DUMMY1
  XCVR_DUMMY2
  XCVR_DUMMY3

transceiver_name()

Return a user-friendly name for the transceiver type.

lp_advertising()

Gets the modes being advertised for auto-negotiation by the other end of the link as a bit field.

The following constants are useful here:

  ADVERTISED_10baseT_Half
  ADVERTISED_10baseT_Full
  ADVERTISED_100baseT_Half
  ADVERTISED_100baseT_Full
  ADVERTISED_1000baseT_Half
  ADVERTISED_1000baseT_Full
  ADVERTISED_2500baseX_Full
  ADVERTISED_1000baseKX_Full
  ADVERTISED_10000baseT_Full
  ADVERTISED_10000baseKX4_Full
  ADVERTISED_10000baseKR_Full
  ADVERTISED_10000baseR_FEC
  ADVERTISED_Pause
  ADVERTISED_Asym_Pause

lp_advertising_modes()

Returns a sorted list of speed/duplex settings advertised by the other end of the link suitable for showing to the user.

SEE ALSO

Linux::Ethtool, Linux::Ethtool::WOL