用途

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

语法

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-low N] [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]

描述

Ethtool命令用于获取以太网卡的配置信息,或者修改这些配置。

ethX是以太网卡的名称,Linux系统将检测到的第一块以太网卡命名为eth0, 第二块为eth1,…….。

标志
-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地址等
示例
  1. 查看机器上网卡的速度:百兆还是千兆,请输入:

ethool eth0

操作完毕后,输出信息中‘Speed:’ 这一项就指示了网卡的速度。

  1. 停止网卡的发送模块TX,请输入:

ethtool -A tx off eth0

操作完毕后,可输入:ethtool -a eth0,查看tx模块是否已被停止。

  1. 查看网卡eth0采用了何种驱动,请输入:

ethtool -i eth0

操作完毕后,显示 driver: bnx2;version: 1.4.30 等信息。

  1. 关闭网卡对收到的数据包的校验功能,请输入:

ethtool -K eth0 rx off

操作完毕后,可输入:ethtool –k eth0,查看校验功能是否已被停止。

  1. 如果机器上安装了两块网卡,那么eth0对应着哪块网卡呢?输入:

ethtool -p eth0 10

操作完毕后,看哪块网卡的led灯在闪,eth0就对应着哪块网卡。

  1. 查看网卡,在接收/发送数据时,有没有出错?请输入:

ethtool –S eth0

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

ethtool -s eth0 speed 100

数据来源

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 or off可配置
-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命令用于显示/配置网卡硬件(寄存器)。

ethtool命令的更多相关文章

  1. 用ethtool 命令解决Linux 网卡丢包【转】

    转自:https://blog.csdn.net/chengxuyuanyonghu/article/details/73739516 生产中有一台Linux设备并发比较大,droped包比较多,尤其 ...

  2. Linux ethtool命令

    一.简介 ethtool 是用于查询及设置网卡参数的命令. 二.常用选项 ethtool ethx //查询ethx网口基本设置,其中 x 是对应网卡的编号,如eth0.eth1等等 ethtool ...

  3. ethtool 命令详解

    命令描述: ethtool 是用于查询及设置网卡参数的命令. 使用概要:ethtool ethx       //查询ethx网口基本设置,其中 x 是对应网卡的编号,如eth0.eth1等等 转自: ...

  4. 【linux命令与工具】ethtool命令

    ethtool是用于查询及设置网卡参数的命令. 如果command not found可以用apt-get/yum添加. 主要参数: ethtool ethX//查看ethX设备属性 ethtool ...

  5. 【转】ethtool 命令详解

    命令描述: ethtool 是用于查询及设置网卡参数的命令. 使用概要:ethtool ethx       //查询ethx网口基本设置,其中 x 是对应网卡的编号,如eth0.eth1等等etht ...

  6. Linux ethtool 命令

    ethtool 是用于查询及设置网卡参数的命令,常见用法如下: 注意:该命令只是临时设置,如果网卡重启就失效了,如果想要永久保存应该配置 /etc/sysconfig/network-scripts/ ...

  7. ethtool命令详解

    命令描述: ethtool 是用于查询及设置网卡参数的命令. 使用概要:ethtool ethx       //查询ethx网口基本设置,其中 x 是对应网卡的编号,如eth0.eth1等等etht ...

  8. ethtool命令使用

    [root@localhost ~]# ethtool -s eth0 speed 100 duplex full #设置网口的speed和duplex # ethtool eth0Settings ...

  9. ethtool - 命令

    ethtool 导览:     1. 如何查看 Linux 中可用的网卡接口     2. 如何查看 Linux 中网卡信息     3. 如何查看网卡驱动版本以及硬件版本     4. 如何查看网络 ...

随机推荐

  1. 统计难题(trie树)

    统计难题 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131070/65535 K (Java/Others)Total Submi ...

  2. Why is celsius = 5 * (fahr - 32) / 9 ?

    Go to my personal blog There is a program to print Fahrenheit-Celsius table as below. #include <s ...

  3. 利用Linux命令行进行文本按行去重并按重复次数排序

    最近杂事太多,正事进展缓慢.Fighting! linux命令行提供了非常强大的文本处理功能,组合利用linux命令能实现好多强大的功能.本文这里举例说明如何利用Linux命令行进行文本按行去重并按重 ...

  4. BI系统的应用组织思路与数据分析模式

    BI商业智能软件一般都会提供若干数据整合.数据查询.分析与评价.数据可视化及数据分享的手段,但是在BI项目的构建与实施过程中,如果不按照一定的应用组织思路.数据分析模式及分析流程使用这些工具或手段,呈 ...

  5. nodejs hello world (调用文件执行没反应)

    今天学习了node.js ,来看一下hello world 的写法. 1. 首先安装node.js的驱动文件.http://nodejs.org/ 2. a:安装好node之后,在CMD窗口输入nod ...

  6. Web开发者的10个最好的云开发环境

    1. Cloud9 IDE cloud9 Cloud9是我最喜欢的一个最好的云开发环境,它可以让我在任何时间任何地点进行代码编写.运行和调试.Cloud9对Node.js 和 JavaScript代码 ...

  7. Mysql的执行顺序

    参考:http://blog.csdn.net/jintao_ma/article/details/51253356 http://www.cnblogs.com/rollenholt/p/37769 ...

  8. 解决了clang: error: linker command failed with exit code 1 (use -v to see invocation) 解决方法

    1.”Build Settings”->”Enable Bitcode”设置为NO 2.TARGETS -->  Build Settings --> Architectures - ...

  9. Qt SQL Programming 部分翻译

    简介:      Qt SQL 是 Qt 的重要模块之一,为了方便,Qt 对 SQL 进行了一系列的封装,并将 SQL API 分为如下三层:      (1)驱动层      (2)SQL API ...

  10. jQuery入门学习贴

    先引一下阮一峰大牛翻译的书<软件随想录>中的一句话: “ joel认为,软件开发,最缺的是天才.而我认为,最缺的是全才.什么“全”:全面.全局.全心全意.全力以赴. ” 最近再学习jQue ...