Home / ethtool

概要

ethtool を追加インストール (2014-1-26)

12.04 LTSにて:

$ ethtool
プログラム 'ethtool' はまだインストールされていません。  次のように入力することでインストールできます:
sudo apt-get install ethtool

言われるままに...

$ sudo apt-get install ethtool
[sudo] password for xxx:
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています
状態情報を読み取っています... 完了
以下のパッケージが新たにインストールされます:
  ethtool
アップグレード: 0 個、新規インストール: 1 個、削除: 0 個、保留: 670 個。
91.6 kB のアーカイブを取得する必要があります。
この操作後に追加で 293 kB のディスク容量が消費されます。
取得:1 http://jp.archive.ubuntu.com/ubuntu/ precise/main ethtool i386 1:3.1-1 [9
1.6 kB]
91.6 kB を 0秒 で取得しました (111 kB/s)
Selecting previously unselected package ethtool.
(データベースを読み込んでいます ... 現在 167413 個のファイルとディレクトリがイン
ストールされています。)
(.../ethtool_1%3a3.1-1_i386.deb から) ethtool を展開しています...
man-db のトリガを処理しています ...

ethtool (1:3.1-1) を設定しています ...

オプションはとても多い

$ man ethtool
ETHTOOL(8)

NAME
       ethtool - query or control network driver and hardware settings

SYNOPSIS
       ethtool devname
       ...

使えるか...

$ ethtool -i eth0
driver: e1000
version: 7.3.21-k8-NAPI
firmware-version: N/A
bus-info: 0000:00:03.0
supports-statistics: yes
supports-test: yes
supports-eeprom-access: yes
supports-register-dump: yes

devname だけ与えるとステータス表示...

$ ethtool eth0
Settings for eth0:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Supported pause frame use: No
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Advertised pause frame use: No
        Advertised auto-negotiation: Yes
        Speed: 1000Mb/s
        Duplex: Full
        Port: Twisted Pair
        PHYAD: 0
        Transceiver: internal
        Auto-negotiation: on
        MDI-X: Unknown
Cannot get wake-on-lan settings: Operation not permitted
        Current message level: 0x00000007 (7)
                               drv probe link
Cannot get link status: Operation not permitted

'Operation not permitted' と表示されているのは root でないから。

ちょっとソースを覗く

netdevice のようなマニュアルは無い。どの道、調査を要する事態になればコントローラの資料やドライバソースが必要になると思う。

ioctl で SIOCETHTOOL、struct ifreq の ifr_data に struct ethtool_cmd を渡してやり取りしているようだ。↓

int send_ioctl(struct cmd_context *ctx, void *cmd)
{
#ifndef TEST_ETHTOOL
	ctx->ifr.ifr_data = cmd;
	return ioctl(ctx->fd, SIOCETHTOOL, &ctx->ifr);
	...

struct ethtool_cmd のコマンドには多数定義された ETHTOOL_xxxx 識別子が使われている。

Flow Control

Supported/Advertised の意味が判らない。また、pause frame use: が表示されない物?もあるようだ。上の例だと No になっているが -a で見れば on になっている。ネゴの結果なのかデフォルトなのか...

# ethtool -a eth0
Pause parameters for eth0:
Autonegotiate:  on
RX:             on
TX:             off

dmesg には RX側を on にした形跡が残っている。

[xx.xxxxxx] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX

VM のブリッジではハードな処は制限されているかも知れぬので、別のネイティブなPC環境で見てみる。但し、こっちは pause frame use: が表示されない物。

普通に起動した後で RX off にし、ifconfig dwon/up やLAN ケーブルを抜き差ししてネゴやり直してみる。

# ethtool -A eth0 rx off

# ethtool -a eth0
Pause parameters for eth0:
Autonegotiate:  on
RX:             off
TX:             on

# dmesg |less
...
tg3: eth0: Link is down.
tg3: eth0: Link is up at 100 Mbps, full duplex.
tg3: eth0: Flow control is on for TX and off for RX.
tg3: eth0: Link is down.
tg3: eth0: Link is up at 100 Mbps, full duplex.
tg3: eth0: Flow control is on for TX and off for RX.

# ethtool -a eth0
Pause parameters for eth0:
Autonegotiate:  on
RX:             off
TX:             on

指定したRXはどうやら効いてるようだ。
なお、この辺の情報を調べているうちに「OSSメッセージペディア」なるサイトを知った。大変有り難い。
そこの説明を借りてざっくり表現に言い換えると...

ってところか。
また、..リンクアップを検知した場合に出力される。 の処は、「Autonegotiate が on なら、当然、その結果を出力する」、ではないかと思う。

モジュールロード時のオプションパラメータ

リンク速度やフロー制御等、ロード時に初期設定すれば良いと考えるが、ドライバによってはオプションパラメータを渡せない(設計されていない)ものも有るようだ。
そう言う場合に ethtool を使う。どうせ ethtool とのやり取りに従うようにドライバ作成する訳だから、確かにスマートな方法と思う。

tg3 は Debug のみ。

$ modinfo tg3
parm:           tg3_debug:Tigon3 bitmapped debugging message enable value (int)

e1000 は豊富。

$ modinfo e1000
...
parm:           TxDescriptors:Number of transmit descriptors (array of int)
parm:           RxDescriptors:Number of receive descriptors (array of int)
parm:           Speed:Speed setting (array of int)
parm:           Duplex:Duplex setting (array of int)
parm:           AutoNeg:Advertised auto-negotiation setting (array of int)
parm:           FlowControl:Flow Control setting (array of int)
parm:           XsumRX:Disable or enable Receive Checksum offload (array of int)
parm:           TxIntDelay:Transmit Interrupt Delay (array of int)
parm:           TxAbsIntDelay:Transmit Absolute Interrupt Delay (array of int)
parm:           RxIntDelay:Receive Interrupt Delay (array of int)
parm:           RxAbsIntDelay:Receive Absolute Interrupt Delay (array of int)
parm:           InterruptThrottleRate:Interrupt Throttling Rate (array of int)
parm:           SmartPowerDownEnable:Enable PHY smart power down (array of int)
parm:           copybreak:Maximum size of packet that is copied to a new buffer on receive (uint)
parm:           debug:Debug level (0=none,...,16=all) (int)

NetworkManager

さて、では NetworkManager を使いつつ、どこでパラメータを渡せば良いか?

# less /etc/NetworkManager/system-connections/xxxxx
[connection]
id=xxxxx
uuid=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
type=802-3-ethernet
autoconnect=true
timestamp=0

[ipv4]
method=manual
dns=xx.xxx.xx.xxx;
addresses1=192.168.x.x;24;192.168.1.1;
ignore-auto-routes=false
ignore-auto-dns=false
never-default=false

[802-3-ethernet]
speed=0
duplex=full
auto-negotiate=true
mac-address=x:xx:xx:xx:xx:xx
mtu=0

参考、引用


Home / ethtool
© 2008 usskim    http://usskim.web.fc2.com/
inserted by FC2 system