Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the Linux ethtool command

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to use the Linux ethtool command". Friends who are interested might as well take a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn how to use the Linux ethtool command.

The Linux common command ethtool is used to get the configuration information of the Ethernet card, or to modify these configurations. This command is more complex and has many functions.

Ethtool displays or modifies the configuration information of the Ethernet card

Syntax ethtool [- a |-c |-g |-d |-k |-r |-S |] ethX ethtool [- A] ethX [autoneg on | off] [rx on | off] [rx 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] [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] [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] option-a check the status of the receiving module RX, the sending module TX and the Autonegotiate module in the network card: start on or deactivate off. -A modifies the status of 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 the information of the network card driver, such as the name and version of the driver. -d displays register dump information, which is not supported by some Nic drivers. -e displays EEPROM dump information, which is not supported by some Nic drivers. -E modify the network card EEPROM byte. -k displays the status of the Offload parameters of the network card: on or off, including rx-checksumming, tx-checksumming, etc. -K modifies the status of Nic Offload parameters. -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 flash, in seconds. -r if the state of the auto-negotiation module is on, then restarts auto-negotiation. -S displays the statistical parameters of NIC- and driver-specific, such as the number of bytes received / sent by the network card, the number of broadcast packets received / sent, and so on. -t let the network card perform self-testing, there are two modes: offline or online. -s modify part of the configuration of the network card, including network card speed, simplex / full-duplex mode, mac address, etc. The information displayed by the data source Ethtool command comes from the network card driver layer, that is, the link layer of the TCP/ip protocol. The logical levels of this command implemented in the Linux kernel are:

The most important structure, struct ethtool_ops, consists of a series of function pointers used to display or modify the Ethernet card configuration, as shown in the second column of the table below.

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

Command option struct ethtool_ops member function Ethtool command displays the source of parameters (take the network card driver BNX2 as an example) No-sget_settingsget_wol get_msglevel get_link set_settings set_wol set_msglevel obtains information such as the network card speed from the network card register, which can be configured. -a-Aget_pauseparam set_pauseparam gets the status of the Autonegotiate/RX/TX module from the network card register: on oroff, configurable. -c-Cget_coalesceset_coalesce gets the coalescing parameter from the network card register: after TX/RX a packet, delay the time of TX/RX interrupt (us) / the number of packets. -decreasing this value can improve the response time of the network card. When rx-usecs&rx-frames is also set to 0, the RX interrupt stops. When tx-usecs&tx-frames is also set to 0, the TX interrupt stops. -g-Gget_ringparam set_ringparam in addition to the current TX/RX ring value (read from the network card register, configurable), the other fixed information for the network card bnx2. The-k-Kget_rx_csumget_tx_csum get_sg get_tso set_rx_csum set_tx_csum set_sg set_tso display information is read from the variable that holds the state, and there is no corresponding register. Therefore, modules such as TX/RX parity have been in the on state and cannot actually be modified. -iget_ drvinf [self _ test_count, get_stats_coun,t get_regs_len, get_eeprom_len] the information fixed by the network card bnx2, such as:-- driver: bnx2 version: 1.4.30 firmware-version: 1.8.0.5 bus-info: 0000 get_stats_coun,t get_regs_len 00.0-dget_drvinfoget_regs is not supported That is, the function get_regs is not implemented in bnx2. -e-Eget_eepromset_eeprom is not supported, that is, the function get_eeprom is not implemented in bnx2. -rnway_reset configures the network card MII_BMCR register and restarts the Auto negotiation module. -pphys_id configures the network card BNX2_EMAC_LED register to realize the LED flash function. -tself_test tests the hardware module of the network card one by one by configuring the network card register: registers,memory,loopback,Link stat,interrupt. -the Sget_ethtool_stats display 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 structural volume variable struct statistics_block * stats_blk in real time through DMA. )-the data displayed are all calculated from the network card register, and the meaning of each item needs to be consulted in the network card (chip) manual. As can be seen above, the ethtool command is used to display / configure the Nic hardware (registers).

For an example to view the speed of the network card on the machine: 100 megabytes or gigabytes, please enter:

After the ethool eth0 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:

After the ethtool-A tx off eth0 operation is complete, enter ethtool-an eth0 to see if the tx module has been stopped. To see what kind of driver is used for the network card eth0, please enter:

After the ethtool-I eth0 operation is completed, information such as driver: bnx2;version: 1.4.30 is displayed. To turn off the verification function of the network card for the received packets, please enter:

After the ethtool-K eth0 rx off operation is completed, you can enter ethtool-k eth0 to see if the verification function has been stopped. If there are two network cards installed on the machine, which network card does eth0 correspond to? Enter:

After the operation of ethtool-p eth0 10, to see which network card's led light is flashing, eth0 corresponds to which network card. Check the network card, is there any error when receiving / sending data? Please enter:

Ethtool-S eth0 slows down the speed of the gigabit network card to 100 megabits, please enter:

Ethtool-s eth0 speed 100s so far, I believe you have a deeper understanding of "how to use the Linux ethtool command". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report