linux修改mac ethtool,ethtool命令
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
數據來源
Ethtool命令顯示的信息來源于網卡驅動層,即TCP/
最重要的結構體struct ethtool_ops,該結構體成員為用于顯示或修改以太網卡配置的一系列函數指針,見下表中的第二列。
網卡驅動負責實現(部分)這些函數,并將其封裝入ethtool_ops結構體,為網絡核心層提供統一的調用接口。因此,不同的網卡驅動會給應用層返回不同的信息。Ethtool命令選項、struct ethtool_ops成員函數、Ethtool命令顯示參數的來源,三者間的對應關系如下表所示:命令選項struct ethtool_ops成員函數Ethtool命令顯示參數的來源(以網卡驅動BNX2為例)
無 -sget_settingsget_wol get_msglevel get_link set_settings set_wol set_msglevel從網卡寄存器中獲得網卡速度等信息,可配置。
-a -Aget_pauseparam set_pauseparam從網卡寄存器中獲得Autonegotiate/RX/TX模塊的狀態:on oroff,可配置。
-c -Cget_coalesceset_coalesce從網卡寄存器中獲得coalescing參數:TX/RX一個數據包后,推遲發生TX/RX中斷的時間(us)/數據包個數。—減小該值可以提高網卡的響應時間。 當rx-usecs&rx-frames同時被設為0時,RX中斷停止。 當tx-usecs&tx-frames同時被設為0時,TX中斷停止。
-g -Gget_ringparam set_ringparam除當前TX/RX ring的值(從網卡寄存器中讀取得到,可配置)外,其它為網卡bnx2自己固定的信息。
-k -Kget_rx_csumget_tx_csum get_sg get_tso set_rx_csum set_tx_csum set_sg set_tso顯示信息從保存該狀態的變量中讀取得到,沒有對應的寄存器。因此,TX/RX校驗等模塊一直處于on狀態,實際上是無法修改的。
-iget_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-
-dget_drvinfoget_regs不支持,即bnx2中沒有實現函數get_regs。
-e -Eget_eepromset_eeprom不支持,即bnx2中沒有實現函數get_eeprom。
-rnway_reset配置網卡MII_BMCR寄存器,重啟Auto negotiation模塊。
-pphys_id配置網卡BNX2_EMAC_LED寄存器,實現LED閃功能。
-tself_test通過配置網卡寄存器,逐一測試網卡的硬件模塊:registers,memory,loopback,Link
-Sget_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
總結
以上是生活随笔為你收集整理的linux修改mac ethtool,ethtool命令的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux怎么装mac系统,Linux/
- 下一篇: linux关闭开发者模式的命今,Cent