るいすのブログ

オタクエンジニアの雑記

激安10G NIC - Mellanox ConnectX-2 on CentOS 7でSR-IOVを使う


覚書っていうのと、ConnectX/ConnectX-2でのSR-IOV有効化の情報が少なすぎるのでまとめてみます。 ドライバーのインストール方法などはMellanoxの公式サイトからダウンロードすれば何となく分かると思います。

 

 

img_0837

ちょっと前に10G NICを買いまいた。Mellanox ConnectX-2 EN というやつです。 中古で1枚3,000円ぐらいで買えます。安い!

Single-Port 10G(SFP+)が使えます。 他にも仮想支援と言う名のSR-IOVという機能、その他諸々あります。

今回はSR-IOVの有効化を覚書で書き残します?

 

 

SR-IOV とは

IIJさんが詳しく解説しています。 OpenStack環境でのSR-IOV活用法 - IIJ

hypervisor(VMM)が処理していた要求を、NICに直接やらせて ネイティブに近いパフォーマンスを出そうといった感じです。

 

 

SR-IOV の利用条件

・VT-x 対応のCPUとマザーボード ・SR-IOV 対応のNIC の2つが絶対条件

 

 

SR-IOVの有効化

ドライバーはCentOS7(多分CentOS5も)で標準で入ってますが このままではSR-IOVが有効化できない(Mellanoxのツール郡が入ってない)ので OFED版をインストールしてください。

# mst start
# mst status

MST modules:
------------
    MST PCI module loaded
    MST PCI configuration module loaded

MST devices:
------------
/dev/mst/mt26448_pci_cr0         - PCI direct access.
                                   domain:bus:dev.fn=0000:03:00.0 bar=0xfbb00000 size=0x100000
                                   Chip revision is: B0
/dev/mst/mt26448_pciconf0        - PCI configuration cycles access.
                                   domain:bus:dev.fn=0000:03:00.0 addr.reg=88 data.reg=92
                                   Chip revision is: B0
# flint -d /dev/mst/mt26448_pci_cr0 dc > connectx-2.ini
# wget http://www.mellanox.com/downloads/firmware/ConnectX2-rel-2_9_1000.tgz
# tar azxvf ConnectX2-rel-2_9_1000.tgz
# mv connectx-2.ini ConnectX2-rel-2_9_1000/
# cd ConnectX2-rel-2_9_1000
# vim connectx-2.ini

[HCA]
hca_header_device_id = 0x6750
hca_header_subsystem_id = 0x0015
eth_xfi_en = true
mdio_en_port1 = 0
+total_vfs = 126 //下記で説明
+sriov_en = true //SR-IOVの有効化(コメントは削除)
# mlxburn -d /dev/mst/mt26448_pci_cr0 -fw fw-ConnectX2-rel.mlx -conf connectx-2.ini
# vim /etc/modprobe.d/mlx4.conf

options mlx4_core port_type_array=2 num_vfs=6 probe_vf=6
total_vfs

NICで作成可能な最大VF数 ファームウェアのバージョンによって最大数が変わる。 ConnectX/ConnectX-2の最新ファームウェアでは63が最大 実際に作成するVF数に関わらずここで設定したVF数分のMMIO領域が確保される。 BIOSによっては最大が6ぐらいだったりする。(今回使用したPCが6 GA-X58-UD3R)

MMIO領域が足りないと not enough MMIO resources for SR-IOV とdmesgに吐き出されてSR-IOVが無効になります。

 

port_type_array

1= InfiniBand, 2 = Ethernet

 

num_vfs

実際に作成するVF数 もちろん total_vfs > num_vfs じゃないとエラーになります。

 

probe_vf

良くわかってない...。 Mellanoxフォーラムには

probe_vf - is the number of VF to be probed in the hypervisor. Probed in the hypervisor means that the VF will also have interface in the hypervisor (e.g. can be seen using the command ifconfig). In this example there are no probed VFs. when running ifconfig, no new interfaces will be added (per VF). In case, probe_vf was equal to 1 for example, we would get 2 new interfaces in the hypervisor (check ifconfig -a), one each port. Probed VFs can be used by the IT administrator to monitor the traffic on that hypervisor without the need of doing that via logging to the VM itself.

と書かれてる。 分からねえ!グループで囲うってことか?

 

snapcrab_noname_2016-10-6_22-31-26_no-00

例があった → https://community.mellanox.com/docs/DOC-1484 何となく分かるような分からないような。コメント下さると助かります\(^o^)/

試しにポートは1つ、1:1の関係がいいので num_vfs=6 probe_vf=6 としてみた。

 

snapcrab_noname_2016-10-6_21-53-20_no-00

見えてる見えてる。

SR-IOVの優位性などは冒頭に書いた IIJさんの資料がめっちゃ参考になるので 見てみてください。