ethtool

Display or modify the configuration information of the Ethernet card

Supplementary instructions

The ethtool command is used to obtain the configuration information of the Ethernet card or modify these configurations. This command is relatively complex and has many functions.

grammar

ethtool [ -a | -c | -g | -i | -d | -k | -r | -S |] ethX
ethtool [-A] ethX [autoneg on|off] [rx on|off] [tx on|off]
ethtool [-C] ethX [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-lowN] [pkt-rate-high N] [rx-usecs-high N] [rx-frames-high N] [ tx-usecs-high N] [tx-frames-high N] [sample-interval N]
ethtool [-G] ethX [rx N] [rx-mini N] [rx-jumbo N] [tx N]
ethtool [-e] ethX [raw on|off] [offset N] [length N]
ethtool [-E] ethX [magic N] [offset N] [value N]
ethtool [-K] ethX [rx on|off] [tx on|off] [sg on|off] [tso on|off]
ethtool [-p] ethX [N]
ethtool [-t] ethX [offline|online]
ethtool [-s] ethX [speed 10|100|1000] [duplex half|full] [autoneg on|off] [port tp|aui|bnc|mii] [phyad N] [xcvr internal|external]
[wol p|u|m|b|a|g|s|d...] [sopass xx:yy:zz:aa:bb:cc] [msglvl N]

Options

-a Check the status of the receiving module RX, sending module TX and Autonegotiate module in the network card: start on or deactivate off.
-A Modifies the status of the receiving module RX, sending module TX and Autonegotiate module in the network card: start on or deactivate off.
-c display the Coalesce information of the specified ethernet card.
-C Change the Coalesce setting of the specified ethernet card.
-g Display the rx/tx ring parameter information of the specified ethernet card.
-G change the rx/tx ring setting of the specified ethernet card.
-i displays network card driver information, such as driver name, version, etc.
-d displays register dump information. Some network card drivers do not support this option.
-e displays EEPROM dump information. Some network card drivers do not support this option.
-E Modifies the network card EEPROM byte.
-k displays the status of the network card Offload parameter: on or off, including rx-checksumming, tx-checksumming, etc.
-K Modifies the status of the network card Offload parameter.
-p is used to distinguish the physical location of the network card corresponding to different ethX. The common method is to make the LED on the network card port flash continuously; N indicates the duration of the network card flashing, in seconds.
-r If the status of the auto-negotiation module is on, restarts auto-negotiation.
-S displays NIC- and driver-specific statistical parameters, such as the number of bytes received/sent by the network card, the number of broadcast packets received/sent, etc.
-t allows the network card to perform self-test. There are two modes: offline or online.
-s Modifies some configurations of the network card, including network card speed, simplex/full-duplex mode, mac address, etc.

Data Sources

The information displayed by the Ethtool command comes from the network card driver layer, which is the link layer of the TCP/ip protocol. The logical level of this command implemented in the Linux kernel is:

The most important structure is struct ethtool_ops. The members of this structure are a series of function pointers used to display or modify the Ethernet card configuration, see the second column in the table below.

The network card driver is responsible for implementing (part of) these functions and encapsulating them into the ethtool_ops structure to provide a unified calling interface for the network core layer. Therefore, different network card drivers will return different information to the application layer. Ethtool command options, struct ethtool_ops member function, Ethtool command display parameter source, the corresponding relationship between the three is shown in the following table:

Command optionsstruct ethtool_ops member functionEthtool command displays the source of parameters (taking the network card driver BNX2 as an example)
None -sget_settingsget_wol get_msglevel get_link set_settings set_wol set_msglevelGet network card speed and other information from the network card register, configurable.
-a -Aget_pauseparam set_pauseparamGet the status of the Autonegotiate/RX/TX module from the network card register: on oroff, configurable.
-c -Cget_coalesceset_coalesceObtain the coalescing parameter from the network card register: after TX/RX a data packet, delay the occurrence of TX/RX interrupt by the time (us)/number of data packets. —Decreasing this value can improve the response time of the network card. When rx-usecs&rx-frames are set to 0 at the same time, the RX interrupt is stopped. When tx-usecs&tx-frames are set to 0 at the same time, the TX interrupt stops.
-g -Gget_ringparam set_ringparamExcept for the current TX/RX ring value (which is read from the network card register and configurable), the other information is fixed by the network card bnx2 itself.
-k -Kget_rx_csumget_tx_csum get_sg get_tso set_rx_csum set_tx_csum set_sg set_tsoThe display information is read from the variable that saves the status , there is no corresponding register. Therefore, the TX/RX verification and other modules are always on and cannot actually be modified.
-iget_drvinfo[self_test_count, get_stats_coun,t get_regs_len, get_eeprom_len]Fixed information of network card bnx2, such as: —————— driver: bnx2 version: 1.4.30 firmware-version: 1.8.0.5 bus-info: 0000:09:00.0 ———————————–
-dget_drvinfoget_regsNot supported, that is, the function get_regs is not implemented in bnx2.
-e -Eget_eepromset_eepromNot supported, that is, the function get_eeprom is not implemented in bnx2.
-rnway_resetConfigure the network card MII_BMCR register and restart the Auto negotiation module.
-pphys_idConfigure the network card BNX2_EMAC_LED register to implement the LED flash function.
-tself_testTest the hardware modules of the network card one by one by configuring the network card registers: registers, memory, loopback, Link stat, interrupt.
-Sget_ethtool_statsThe displayed information comes from the structure variable stats_blk in the network card driver. (The network card reads the data in the registers BNX2_HC_STATISTICS _ADDR_L and BNX2_HC_STATISTICS_ADDR_H into the structure variable struct statistics_block *stats_blk in real time through DMA.) —The displayed data are all statistically obtained from the network card registers. Please consult the network card (chip) manual for the meaning of each item.

As can be seen from the above, the ethtool command is used to display/configure the network card hardware (register). ​

Example

To check the speed of the machine's network card: 100 Mbit or Gigabit, please enter:

ethool eth0

After the operation is completed, the Speed: item in the output information indicates the speed of the network card. To stop the sending module TX of the network card, please enter:

ethtool -A tx off eth0

After the operation is completed, you can enter ethtool -a eth0 to check whether the tx module has been stopped. To check which driver is used by the network card eth0, please enter:

ethtool -i eth0

After the operation is completed, driver: bnx2; version: 1.4.30 and other information are displayed. To turn off the network card's verification function of received data packets, please enter:

ethtool -K eth0 rx off

After the operation is completed, you can enter ethtool –k eth0 to check whether the verification function has been stopped. If two network cards are installed on the machine, which network card does eth0 correspond to? enter:

ethtool -p eth0 10

After the operation is completed, see which network card's LED light is flashing, and eth0 corresponds to which network card. Check the network card. Are there any errors when receiving/sending data? please enter:

ethtool –S eth0

To reduce the speed of the Gigabit network card to 100 Mbit/s, please enter:

ethtool -s eth0 speed 100