目錄
什麼是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.
獲取更多相關的嵌入式開發工具,可收藏系列博文,持續更新中:
【開發工具】嵌入式常用開發工具彙總帖