linux-command
  • Introduction
  • linux-command
    • ab.md
    • accept.md
    • ack.md
    • alias.md
    • apachectl.md
    • apk.md
    • apropos.md
    • apt-get.md
    • aptitude.md
    • apt-key.md
    • apt-sortpkgs.md
    • ar.md
    • arch.md
    • arj.md
    • arp.md
    • arpd.md
    • arping.md
    • arptables.md
    • arpwatch.md
    • as.md
    • at.md
    • atop.md
    • atq.md
    • atrm.md
    • awk.md
    • axel.md
    • badblocks.md
    • basename.md
    • batch.md
    • bc.md
    • bg.md
    • bind.md
    • blkid.md
    • blockdev.md
    • bmodinfo.md
    • builtin.md
    • bunzip2.md
    • bye.md
    • bzcat.md
    • bzcmp.md
    • bzdiff.md
    • bzgrep.md
    • bzip2.md
    • bzip2recover.md
    • bzless.md
    • bzmore.md
    • cal.md
    • cancel.md
    • cat.md
    • cd.md
    • cdrecord.md
    • chage.md
    • chattr.md
    • chcon.md
    • chfn.md
    • chgrp.md
    • chkconfig.md
    • chmod.md
    • chown.md
    • chpasswd.md
    • chroot.md
    • chsh.md
    • cksum.md
    • clear.md
    • clock.md
    • clockdiff.md
    • cmp.md
    • col.md
    • colrm.md
    • comm.md
    • command.md
    • compress.md
    • consoletype.md
    • convertquota.md
    • cp.md
    • cpio.md
    • crontab.md
    • csplit.md
    • cu.md
    • cupsdisable.md
    • cupsenable.md
    • curl.md
    • cut.md
    • date.md
    • dd.md
    • declare.md
    • depmod.md
    • df.md
    • dhclient.md
    • dhcpd.md
    • dhcrelay.md
    • diff.md
    • diff3.md
    • diffstat.md
    • dig.md
    • dircolors.md
    • dirname.md
    • dirs.md
    • dmesg.md
    • dmidecode.md
    • dnf.md
    • dnsdomainname.md
    • domainname.md
    • dos2unix.md
    • dpkg.md
    • dpkg-deb.md
    • dpkg-divert.md
    • dpkg-preconfigure.md
    • dpkg-query.md
    • dpkg-reconfigure.md
    • dpkg-split.md
    • dpkg-statoverride.md
    • dpkg-trigger.md
    • dris.md
    • dstat.md
    • du.md
    • dump.md
    • e2fsck.md
    • e2label.md
    • echo.md
    • ed.md
    • edquota.md
    • egrep.md
    • eject.md
    • elinks.md
    • elm.md
    • emacs.md
    • enable.md
    • env.md
    • ethtool.md
    • ex.md
    • exec.md
    • exit.md
    • expand.md
    • export.md
    • exportfs.md
    • expr.md
    • fc.md
    • fdisk.md
    • fg.md
    • fgrep.md
    • file.md
    • find.md
    • findfs.md
    • finger.md
    • firewall-cmd.md
    • fishshell.md
    • fmt.md
    • fold.md
    • free.md
    • fsck.md
    • ftp.md
    • ftpcount.md
    • ftpshut.md
    • ftptop.md
    • ftpwho.md
    • fuser.md
    • gcc.md
    • gcov.md
    • gdb.md
    • get_module.md
    • getenforce.md
    • getsebool.md
    • git.md
    • gpasswd.md
    • gpm.md
    • grep.md
    • groupadd.md
    • groupdel.md
    • groupmod.md
    • groups.md
    • grpck.md
    • grpconv.md
    • grpunconv.md
    • grub.md
    • gunzip.md
    • gzexe.md
    • gzip.md
    • halt.md
    • hdparm.md
    • head.md
    • help.md
    • hexdump.md
    • history.md
    • host.md
    • hostid.md
    • hostname.md
    • hping3.md
    • htdigest.md
    • htop.md
    • htpasswd.md
    • hwclock.md
    • iconv.md
    • id.md
    • ifcfg.md
    • ifconfig.md
    • ifdown.md
    • ifstat.md
    • iftop.md
    • ifup.md
    • indent.md
    • info.md
    • init.md
    • inotifywait.md
    • insmod.md
    • install.md
    • iostat.md
    • iotop.md
    • ip.md
    • ip6tables.md
    • ip6tables-restore.md
    • ip6tables-save.md
    • ipcalc.md
    • ipcrm.md
    • ipcs.md
    • iperf.md
    • iptables.md
    • iptables-restore.md
    • iptables-save.md
    • iptraf.md
    • iptstate.md
    • ispell.md
    • jed.md
    • jobs.md
    • joe.md
    • join.md
    • jwhois.md
    • kernelversion.md
    • kexec.md
    • kill.md
    • killall.md
    • last.md
    • lastb.md
    • lastlog.md
    • ld.md
    • ldconfig.md
    • ldd.md
    • less.md
    • let.md
    • lftp.md
    • lftpget.md
    • lha.md
    • lilo.md
    • ln.md
    • lnstat.md
    • locate.md
    • logger.md
    • login.md
    • logname.md
    • logout.md
    • logrotate.md
    • logsave.md
    • logwatch.md
    • look.md
    • losetup.md
    • lp.md
    • lpadmin.md
    • lpc.md
    • lpq.md
    • lpr.md
    • lprm.md
    • lpstat.md
    • ls.md
    • lsattr.md
    • lsb_release.md
    • lsblk.md
    • lscpu.md
    • lsmod.md
    • lsof.md
    • lspci.md
    • lsusb.md
    • ltrace.md
    • lvcreate.md
    • lvdisplay.md
    • lvextend.md
    • lvreduce.md
    • lvremove.md
    • lvresize.md
    • lvscan.md
    • lynx.md
    • mail.md
    • mailq.md
    • mailstat.md
    • make.md
    • man.md
    • md5sum.md
    • mesg.md
    • mii-tool.md
    • mkbootdisk.md
    • mkdir.md
    • mke2fs.md
    • mkfs.md
    • mkinitrd.md
    • mkisofs.md
    • mknod.md
    • mkswap.md
    • mktemp.md
    • modprobe.md
    • more.md
    • mount.md
    • mpstat.md
    • mtools.md
    • mv.md
    • mysql.md
    • mysqladmin.md
    • mysqldump.md
    • mysqlimport.md
    • mysqlshow.md
    • named-checkzone.md
    • nano.md
    • nc.md
    • ncftp.md
    • nethogs.md
    • netstat.md
    • newusers.md
    • nfsstat.md
    • ngrep.md
    • nice.md
    • nisdomainname.md
    • nl.md
    • nm.md
    • nmap.md
    • nmcli.md
    • nohup.md
    • nologin.md
    • nslookup.md
    • ntpdate.md
    • ntsysv.md
    • objdump.md
    • od.md
    • openssl.md
    • parted.md
    • partprobe.md
    • passwd.md
    • paste.md
    • patch.md
    • pathchk.md
    • perl.md
    • pfctl.md
    • pgrep.md
    • php.md
    • pico.md
    • pidof.md
    • pigz.md
    • ping.md
    • pkill.md
    • pmap.md
    • popd.md
    • poweroff.md
    • ppp-off.md
    • pr.md
    • printf.md
    • protoize.md
    • ps.md
    • pssh.md
    • pstack.md
    • pstree.md
    • pushd.md
    • pv.md
    • pvchange.md
    • pvck.md
    • pvcreate.md
    • pvdisplay.md
    • pvremove.md
    • pvs.md
    • pvscan.md
    • pwck.md
    • pwconv.md
    • pwd.md
    • pwunconv.md
    • quota.md
    • quotacheck.md
    • quotaoff.md
    • quotaon.md
    • rcconf.md
    • rcp.md
    • read.md
    • readelf.md
    • readonly.md
    • reboot.md
    • reject.md
    • rename.md
    • renice.md
    • repquota.md
    • resize.md
    • restore.md
    • restorecon.md
    • rev.md
    • rexec.md
    • rlogin.md
    • rm.md
    • rmdir.md
    • rmmod.md
    • route.md
    • rpm.md
    • rpm2cpio.md
    • rpmbuild.md
    • rpmdb.md
    • rpmquery.md
    • rpmsign.md
    • rpmverify.md
    • rsh.md
    • rsync.md
    • runlevel.md
    • sar.md
    • scp.md
    • screen.md
    • sed.md
    • seinfo.md
    • semanage.md
    • sendmail.md
    • seq.md
    • service.md
    • ss.md
Powered by GitBook
On this page
  • 补充说明
  • 语法
  • 选项
  • 数据来源
  • 实例

Was this helpful?

  1. linux-command

ethtool.md

显示或修改以太网卡的配置信息

补充说明

ethtool命令用于获取以太网卡的配置信息,或者修改这些配置。这个命令比较复杂,功能特别多。

语法

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]

选项

-a 查看网卡中 接收模块RX、发送模块TX和Autonegotiate模块的状态:启动on 或 停用off。
-A 修改网卡中 接收模块RX、发送模块TX和Autonegotiate模块的状态:启动on 或 停用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 显示网卡驱动的信息,如驱动的名称、版本等。
-d 显示register dump信息, 部分网卡驱动不支持该选项。
-e 显示EEPROM dump信息,部分网卡驱动不支持该选项。
-E 修改网卡EEPROM byte。
-k 显示网卡Offload参数的状态:on 或 off,包括rx-checksumming、tx-checksumming等。
-K 修改网卡Offload参数的状态。
-p 用于区别不同ethX对应网卡的物理位置,常用的方法是使网卡port上的led不断的闪;N指示了网卡闪的持续时间,以秒为单位。
-r 如果auto-negotiation模块的状态为on,则restarts auto-negotiation。
-S 显示NIC- and driver-specific 的统计参数,如网卡接收/发送的字节数、接收/发送的广播包个数等。
-t 让网卡执行自我检测,有两种模式:offline or online。
-s 修改网卡的部分配置,包括网卡速度、单工/全双工模式、mac地址等。

数据来源

Ethtool命令显示的信息来源于网卡驱动层,即TCP/ip协议的链路层。该命令在Linux内核中实现的逻辑层次为:

最重要的结构体struct ethtool_ops,该结构体成员为用于显示或修改以太网卡配置的一系列函数指针,见下表中的第二列。

网卡驱动负责实现(部分)这些函数,并将其封装入ethtool_ops结构体,为网络核心层提供统一的调用接口。因此,不同的网卡驱动会给应用层返回不同的信息。Ethtool命令选项、struct ethtool_ops成员函数、Ethtool命令显示参数的来源,三者间的对应关系如下表所示:

命令选项

struct ethtool_ops成员函数

Ethtool命令显示参数的来源(以网卡驱动BNX2为例)

无 -s

get_settingsget_wol get_msglevel get_link set_settings set_wol set_msglevel

从网卡寄存器中获得网卡速度等信息,可配置。

-a -A

get_pauseparam set_pauseparam

从网卡寄存器中获得Autonegotiate/RX/TX模块的状态:on oroff,可配置。

-c -C

get_coalesceset_coalesce

从网卡寄存器中获得coalescing参数:TX/RX一个数据包后,推迟发生TX/RX中断的时间(us)/数据包个数。—减小该值可以提高网卡的响应时间。 当rx-usecs&rx-frames同时被设为0时,RX中断停止。 当tx-usecs&tx-frames同时被设为0时,TX中断停止。

-g -G

get_ringparam set_ringparam

除当前TX/RX ring的值(从网卡寄存器中读取得到,可配置)外,其它为网卡bnx2自己固定的信息。

-k -K

get_rx_csumget_tx_csum get_sg get_tso set_rx_csum set_tx_csum set_sg set_tso

显示信息从保存该状态的变量中读取得到,没有对应的寄存器。因此,TX/RX校验等模块一直处于on状态,实际上是无法修改的。

-i

get_drvinfo[self_test_count, get_stats_coun,t get_regs_len, get_eeprom_len]

网卡bnx2自己固定的信息,如: ——————————————————– driver: bnx2 version: 1.4.30 firmware-version: 1.8.0.5 bus-info: 0000:09:00.0 ——————————————————–

-d

get_drvinfoget_regs

不支持,即bnx2中没有实现函数get_regs。

-e -E

get_eepromset_eeprom

不支持,即bnx2中没有实现函数get_eeprom。

-r

nway_reset

配置网卡MII_BMCR寄存器,重启Auto negotiation模块。

-p

phys_id

配置网卡BNX2_EMAC_LED寄存器,实现LED闪功能。

-t

self_test

通过配置网卡寄存器,逐一测试网卡的硬件模块:registers,memory,loopback,Link stat,interrupt。

-S

get_ethtool_stats

显示信息来源于网卡驱动中的结构体变量stats_blk。(网卡通过DMA方式,将寄存器BNX2_HC_STATISTICS _ADDR_L和BNX2_HC_STATISTICS_ADDR_H中的数据实时地读取到结构体变量struct statistics_block *stats_blk中。) —显示的数据都是从网卡寄存器中统计得到的,各项的含义需查询网卡(芯片)手册。

由上可见,ethtool命令用于显示/配置网卡硬件(寄存器)。

实例

查看机器上网卡的速度:百兆还是千兆,请输入:

ethool eth0

操作完毕后,输出信息中Speed:这一项就指示了网卡的速度。停止网卡的发送模块TX,请输入:

ethtool -A tx off eth0

操作完毕后,可输入ethtool -a eth0,查看tx模块是否已被停止。查看网卡eth0采用了何种驱动,请输入:

ethtool -i eth0

操作完毕后,显示 driver: bnx2;version: 1.4.30 等信息。关闭网卡对收到的数据包的校验功能,请输入:

ethtool -K eth0 rx off

操作完毕后,可输入ethtool –k eth0,查看校验功能是否已被停止。如果机器上安装了两块网卡,那么eth0对应着哪块网卡呢?输入:

ethtool -p eth0 10

操作完毕后,看哪块网卡的led灯在闪,eth0就对应着哪块网卡。查看网卡,在接收/发送数据时,有没有出错?请输入:

ethtool –S eth0

将千兆网卡的速度降为百兆,请输入:

ethtool -s eth0 speed 100
Previousenv.mdNextex.md

Last updated 5 years ago

Was this helpful?