【开发工具】【ethtool】查询与设置网卡参数工具(ethtool)的安装与使用

目录

什么是ethtool?

ethtool的安装

ethtool的使用


什么是ethtool?

Ethtool是Linux下用于查询和设置网卡参数的命令。

用于控制网络驱动程序和硬件(尤其是有线以太网设备)的标准Linux实用程序。它可以用于:

  • 获取标识和诊断信息
  • 获取扩展的设备统计信息
  • 以太网设备的控制速度,双工,自动协商和流控制
  • 控制校验和卸载和其他硬件卸载功能
  • 控制DMA环大小和中断控制
  • 控制多队列设备的接收队列选择
  • 升级闪存中的固件

 


ethtool的安装

  • 下载tcpdump、libpcap官方源码:
https://mirrors.edge.kernel.org/pub/software/network/ethtool/
  • 解压缩
tar -vxzf ethtool-5.2.tar.gz

注:小技巧:Linux下一般压缩文件后缀为.tar.bz2和.tar.gz,
它们解压命令有两三个选项是一致的:
xf(v),前者再加上j选项,后者再加上z选项。
  • 进入目录
cd ethtool-5.2
  • 配置
3536:
	CC=arm-hisiv400-linux-gcc ./configure --host=arm-hisiv400-linux --target=arm-hisiv400-linux --program-prefix=arm-hisiv400-linux- --with-pcap=linux --prefix=$(pwd)/../output/3536
3519:
	CC=arm-hisiv600-linux-gcc ./configure --host=arm-hisiv600-linux --target=arm-hisiv600-linux --program-prefix=arm-hisiv600-linux- --with-pcap=linux --prefix=$(pwd)/../output/3519a
3519av100:
	CC=arm-himix200-linux-gcc ./configure --host=arm-himix200-linux --target=arm-himix200-linux --program-prefix=arm-himix200-linux- --with-pcap=linux --prefix=$(pwd)/../output/3519av100
开发机:
	./configure --with-pcap=linux --prefix=$(pwd)/../output/pc
 
 编译参数说明:
1)	CC:编译gdb使用的交叉编译工具链,3536和3519的工具不一样
2)	--host:编译出来的gdb运行在什么机器上
3)	--target:要调试的目标板
4)	--program-prefix:编译生成可执行文件的前缀
5)	--prefix:make install的的位置
注:–target=arm-linux意思是说目标平台是运行于ARM体系结构的linux内核;–program-prefix=arm-linux-是指生成的可执行文件的前缀,
比如arm-linux-gdb,–prefix是指生成的可执行文件安装在哪个目录,这个目录需要根据实际情况作选择。如果该目录不存在,会自动创建,当然,权限足够的话。
  • 编译、安装
make

make install

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-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]

参数说明:
-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        //修改网卡的部分配置,包括网卡速度、单工/全双工模式、mac地址等。加上-s选项修改的内容才会生效
-S        //显示NIC- and driver-specific 的统计参数,如网卡接收/发送的字节数、接收/发送的广播包个数等。
-t        //让网卡执行自我检测,有两种模式:offline or online.

获取更多相关的嵌入式开发工具,可收藏系列博文,持续更新中:
【开发工具】嵌入式常用开发工具汇总帖

  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Evan_ZGYF丶

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值