Oracle Cloud で DPDKをインストールしてみた

#■インストール環境
　DPDK : 17.11.2
　OS：CentOS Linux release 7.5.1804
　OCI Shape : VM2.1


##■Cent OS インスタンス確認
#●OS情報

```
[root@vm01 ~]# uname -a
	Linux vm01 3.10.0-862.6.3.el7.x86_64 #1 SMP Tue Jun 26 16:32:21 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
```

```
[root@vm01 ~]# cat /etc/redhat-release
	CentOS Linux release 7.5.1804 (Core)
```

#●NICドライバー確認

```
[root@vm01 ~]#　lspci
　　・・・
	00:03.0 Ethernet controller: Broadcom Limited NetXtreme-E Ethernet Virtual Function
	00:04.0 Ethernet controller: Broadcom Limited NetXtreme-E Ethernet Virtual Function
```

#■OCI設定
①DPDK用VNIC追加
・OCIコンソールからAttached VNICs画面にてDPDK用VNICを追加

<img width="621" alt="1_VNIC追加(加工).png" src="https://qiita-image-store.s3.amazonaws.com/0/109087/66cd2359-7f64-5603-6541-c18347a2fbe6.png">


②DPDK依存RPMをInstall

```
[root@vm01 ~]# yum install -y gcc  gcc-c++  kernel-devel 
	Loaded plugins: security, ulninfo
	Setting up Install Process
	ol6_UEKR4                                                | 2.5 kB     00:00
  ・・・
	Installed:
	  gcc-c++.x86_64 0:4.4.7-23.0.1.el6       kernel.x86_64 0:2.6.32-754.el6
	  kernel-devel.x86_64 0:2.6.32-754.el6    numactl-devel.x86_64 0:2.0.9-2.el6

	Dependency Installed:
	  libstdc++-devel.x86_64 0:4.4.7-23.0.1.el6

	Dependency Updated:
	  libstdc++.x86_64 0:4.4.7-23.0.1.el6

	Complete!

```

③/etc/default/grub 設定
・ /etc/default/grubのGRUB_CMDLINE_LINUX項に以下２つのパラメータを追加
　intel_iommu=on
　iommu=pt

```
[root@vm01 ~]# cp -p /etc/default/grub /etc/default/grub.org
[root@vm01 ~]# vi /etc/default/grub
	GRUB_CMDLINE_LINUX="crashkernel=auto LANG=en_US.UTF-8 transparent_hugepage=never console=tty0 console=ttyS0,9600 rd.luks=0 rd.lvm=0 rd.md=0 rd.dm=0 netroot=iscsi:169.254.0.2:::1:iqn.2015-02.oracle.boot:uefi iscsi_param=node.session.timeo.replacement_timeout=6000 net.ifnames=1 nvme_core.shutdown_timeout=10 ipmi_si.tryacpi=0 ipmi_si.trydmi=0 ipmi_si.trydefaults=0 libiscsi.debug_libiscsi_eh=1 network-config=e2NvbmZpZzogZGlzYWJsZWR9Cg== intel_iommu=on iommu=pt"
```

・grub.cfg ファイルの再構築

```
[root@vm01 ~]# grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
```

④grub設定のため再起動

```
[root@vm01 ~]# reboot
```

#■DPDKダウンロード

```
[root@vm01 ~]# wget https://fast.dpdk.org/rel/dpdk-17.11.2.tar.xz
```

#■DPDK インストール事前準備

・tarファイル解凍

```
[root@vm01 ~]# ls
	dpdk-17.11.2.tar.xz
[root@vm01 ~]# tar xJf dpdk-17.11.2.tar.xz
```

・Change make option 

```
[root@vm01 ~]# cd /home/opc/dpdk-stable-17.11.2/config
[root@vm01 config]# cp common_linuxapp common_linuxapp.org
[root@vm01 config]# vi common_linuxapp
		CONFIG_RTE_KNI_KMOD=y
		CONFIG_RTE_LIBRTE_KNI=y 
		CONFIG_RTE_LIBRTE_PMD_KNI=y

	==>上記を以下のように変更
		CONFIG_RTE_KNI_KMOD=n
		CONFIG_RTE_LIBRTE_KNI=n 
		CONFIG_RTE_LIBRTE_PMD_KNI=n

[root@vm01 config]# cat common_linuxapp | grep =n
	CONFIG_RTE_KNI_KMOD=n
	CONFIG_RTE_LIBRTE_KNI=n
	CONFIG_RTE_LIBRTE_PMD_KNI=n
```

#■DPDK インストール

```
[root@vm01 ~]# cd /home/opc/dpdk-stable-17.11.2/usertools
[root@vm01 usertools]# ls
	cpu_layout.py  dpdk-devbind.py  dpdk-pmdinfo.py  dpdk-setup.sh
[root@vm01 usertools]# ./dpdk-setup.sh
		------------------------------------------------------------------------------
		 RTE_SDK exported as /home/opc/dpdk-stable-17.11.2
		------------------------------------------------------------------------------
		----------------------------------------------------------
		 Step 1: Select the DPDK environment to build
		----------------------------------------------------------
		[1] arm64-armv8a-linuxapp-clang
		[2] arm64-armv8a-linuxapp-gcc
		[3] arm64-dpaa2-linuxapp-gcc
		[4] arm64-dpaa-linuxapp-gcc
		[5] arm64-thunderx-linuxapp-gcc
		[6] arm64-xgene1-linuxapp-gcc
		[7] arm-armv7a-linuxapp-gcc
		[8] i686-native-linuxapp-gcc
		[9] i686-native-linuxapp-icc
		[10] ppc_64-power8-linuxapp-gcc
		[11] x86_64-native-bsdapp-clang
		[12] x86_64-native-bsdapp-gcc
		[13] x86_64-native-linuxapp-clang
		[14] x86_64-native-linuxapp-gcc
		[15] x86_64-native-linuxapp-icc
		[16] x86_x32-native-linuxapp-gcc

		----------------------------------------------------------
		 Step 2: Setup linuxapp environment
		----------------------------------------------------------
		[17] Insert IGB UIO module
		[18] Insert VFIO module
		[19] Insert KNI module
		[20] Setup hugepage mappings for non-NUMA systems
		[21] Setup hugepage mappings for NUMA systems
		[22] Display current Ethernet/Crypto device settings
		[23] Bind Ethernet/Crypto device to IGB UIO module
		[24] Bind Ethernet/Crypto device to VFIO module
		[25] Setup VFIO permissions

		----------------------------------------------------------
		 Step 3: Run test application for linuxapp environment
		----------------------------------------------------------
		[26] Run test application ($RTE_TARGET/app/test)
		[27] Run testpmd application in interactive mode ($RTE_TARGET/app/testpmd)

		----------------------------------------------------------
		 Step 4: Other tools
		----------------------------------------------------------
		[28] List hugepage info from /proc/meminfo

		----------------------------------------------------------
		 Step 5: Uninstall and system cleanup
		----------------------------------------------------------
		[29] Unbind devices from IGB UIO or VFIO driver
		[30] Remove IGB UIO module
		[31] Remove VFIO module
		[32] Remove KNI module
		[33] Remove hugepage mappings

		[34] Exit Script

		Option:

```

dpdk-setup.shを実行すると上記のように [34] 個の設定項目が出力されるので、
以下番号を実行して設定していく

①[14]入力して実行：ソースコードを実行可能なライブラリにコンパイル

```
Option: 14

	Configuration done using x86_64-native-linuxapp-gcc
	== Build lib
	== Build lib/librte_compat
	・・・
	Build complete [x86_64-native-linuxapp-gcc]
	Installation cannot run with T defined and DESTDIR undefined
	------------------------------------------------------------------------------
	 RTE_TARGET exported as x86_64-native-linuxapp-gcc
	------------------------------------------------------------------------------

	Press enter to continue ...

```

②[17]実行後 [18]を実行して Driver Module をLoad

```
	Option: 17

		Unloading any existing DPDK UIO module
		Loading DPDK UIO module

		Press enter to continue ...

	・・・

	Option: 18

		Unloading any existing VFIO module
		Loading VFIO module
		chmod /dev/vfio
		OK

		Press enter to continue ...
```

③[22]実行して現在のDPDK Driver の設定を確認
・初期状態では登録されていないので、「etwork devices using kernel driver」項から、DPDK-compatibleに設定するNetwork devices番号を確認

```
Option: 22

	Network devices using DPDK-compatible driver
	============================================
	<none>

	Network devices using kernel driver
	===================================
	0000:00:03.0 'NetXtreme-E Ethernet Virtual Function 16dc' if=ens3 drv=bnxt_en unused=igb_uio *Active*
	0000:00:04.0 'NetXtreme-E Ethernet Virtual Function 16dc' if=ens4 drv=bnxt_en unused=igb_uio
	・・・

	==> DPDK用に0000:00:04.0 番を追加していく
```

④[23]実行してDPDK Driver を設定
・[22]で確認した追加するNetwork devices番号を設定

```
Option: 23

	Network devices using DPDK-compatible driver
	============================================
	<none>
	・・・
	Enter PCI address of device to bind to IGB UIO driver: 0000:00:04.0
	OK

	Press enter to continue ...
```

⑤[22]実行してDPDK Driver設定確認

```
Option: 22

	Network devices using DPDK-compatible driver
	============================================
	0000:00:04.0 'NetXtreme-E Ethernet Virtual Function 16dc' drv=igb_uio unused=bnxt_en

	Network devices using kernel driver
	===================================
	0000:00:03.0 'NetXtreme-E Ethernet Virtual Function 16dc' if=ens3 drv=bnxt_en unused=igb_uio *Active*
	・・・
```

⑥設定されたことを確認したら[34]実行して終了

```
Option: 34

　[root@vm01 usertools]#
```

#■DPDK インストール確認
・testpmdツールでInterfaceテストを実施

```
[root@vm01 usertools]# cd /home/opc/dpdk-stable-17.11.2/x86_64-native-linuxapp-gcc/app
[root@vm01 app]# ls
	dpdk-pdump       dpdk-procinfo          dpdk-test-crypto-perf.map  testpmd
	dpdk-pdump.map   dpdk-procinfo.map      dpdk-test-eventdev         testpmd.map
	dpdk-pmdinfogen  dpdk-test-crypto-perf  dpdk-test-eventdev.map

[root@vm01 app]# testpmd -- -i
testpmd> 
testpmd> show port info all

		********************* Infos for port 0  *********************
		MAC address: 00:00:17:00:83:79
		Driver name: net_bnxt
		Connect to socket: 0
		memory allocation on the socket: 0
		Link status: up
		Link speed: 25000 Mbps
		Link duplex: full-duplex
		MTU: 1500
		Allmulticast mode: disabled
		Maximum number of MAC addresses: 4
		Maximum number of MAC addresses of hash filtering: 0
		VLAN offload:
		  strip on
		  filter on
		  qinq(extend) off
		Hash key size in bytes: 40
		Redirection table size: 1
		No flow type is supported.
		Max possible RX queues: 1
		Max possible number of RXDs per queue: 65535
		Min possible number of RXDs per queue: 0
		RXDs number alignment: 1
		Max possible TX queues: 1
		Max possible number of TXDs per queue: 65535
		Min possible number of TXDs per queue: 0
		TXDs number alignment: 1
		testpmd>

testpmd> show port stats all

	  ######################## NIC statistics for port 0  ########################
	  RX-packets: 0          RX-missed: 0          RX-bytes:  0
	  RX-errors: 0
	  RX-nombuf:  0
	  TX-packets: 0          TX-errors: 0          TX-bytes:  0

	  Throughput (since last show)
	  Rx-pps:            0
	  Tx-pps:            0
	  ############################################################################
testpmd> quit

```

#■参考
　・DPDK.org： https://www.dpdk.org/