1

Is there any way in Linux to see if an ethernet auto-negotiation is ongoing or has already terminated?

For instance, I see that in my network it takes a 1Gb interface 3 to 4 seconds to correctly update its link status after I set its administrative status to "up".

For now I see that /sys/class/net/$eth/speed yields invalid argument if the interface is down, -1 if a negotiation is ongoing and the negotiated speed value once the negotiation is done. This might be a first approximation for a solution. Anything more precise than this?

On a side note, /sys/class/net/$eth/operstate is down both when speed is -1 and when it is invalid value, so I can't use it.

1

It looks like we can get what you need with "ethtool" and "perf".

From the ethtool man page:

-r --negotiate

Restarts auto-negotiation on the specified Ethernet device, if auto-negotiation is enabled.

To learn more about the perf command, and there is much to know, check out Brendan Gregg's website: http://www.brendangregg.com/perf.html

We can do a perf record of the ethtool renegotiation:

# perf record ethtool -r <interface>

And then display the report

# perf report --stdio

On my virtual machine which is using the Intel e1000 driver, I get these results for the report... your results may vary.

# Overhead  Command      Shared Object                                 Symbol
# ........  .......  .................  .....................................
#
    17.39%  ethtool  [kernel.kallsyms]  [k] e1000_raise_ee_clk.isra.7
    13.04%  ethtool  [kernel.kallsyms]  [k] __lock_text_start
    13.04%  ethtool  [kernel.kallsyms]  [k] delay_tsc
    13.04%  ethtool  [kernel.kallsyms]  [k] e1000_shift_in_ee_bits
     8.70%  ethtool  [kernel.kallsyms]  [k] e1000_lower_ee_clk.isra.8
     4.35%  ethtool  [kernel.kallsyms]  [k] e1000_acquire_eeprom
     4.35%  ethtool  [kernel.kallsyms]  [k] e1000_configure_rx
     4.35%  ethtool  [kernel.kallsyms]  [k] e1000_init_hw
     4.35%  ethtool  [kernel.kallsyms]  [k] e1000_release_eeprom
     4.35%  ethtool  [kernel.kallsyms]  [k] e1000_standby_eeprom
     4.35%  ethtool  [kernel.kallsyms]  [k] finish_task_switch
     4.35%  ethtool  [kernel.kallsyms]  [k] kmem_cache_free
     4.35%  ethtool  [kernel.kallsyms]  [k] native_read_tsc

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.