# Virtual Function Installation Guide
###### tags: `ORAN`
* [Reference - Configuration of System](https://docs.o-ran-sc.org/projects/o-ran-sc-o-du-phy/en/latest/Setup-Configuration_fh.html#a-3-configuration-of-system)
---
###### tags: `CHT Technical Document`
:::success
**Outline:**
[TOC]
:::
## Background
:::info
- This is the library needed if you want to use L1app with Radio mode (O-DU Low + RU)
- This guide will cover on how to update the required driver for the NIC and also create VF needed for FHI connection
- If you only need O-DU Low & High integration on radio mode you can skip this guide and go to the next step
:::
## Prerequisites
:::warning
Please follow the notes to do the setting first
- RT Host Installation
- [Install CentOS-7.7](https://hackmd.io/@ChiehChun/HyNXWdATI/https%3A%2F%2Fhackmd.io%2FfGrhOVHnR0as43FcYIWrvQ%3Fview)
- [Bios Configuration](https://hackmd.io/@ChiehChun/HyNXWdATI/https%3A%2F%2Fhackmd.io%2FmT3fzBDMTtqyYSQ9Zzo-5A%3Fview)
- [OS Configuration](https://hackmd.io/@ChiehChun/HyNXWdATI/https%3A%2F%2Fhackmd.io%2FOsPSqoVDRQS0hbrCjL85CQ%3Fview)
- Others Prerequisites
- [ICC](https://hackmd.io/@ChiehChun/HyNXWdATI/https%3A%2F%2Fhackmd.io%2F%40nadhifmr%2FBkmuLwxLo%2Fhttps%253A%252F%252Fhackmd.io%252FpHC0zUaSSeu42yNNjk9rqA)
- [DPDK](https://hackmd.io/@ChiehChun/HyNXWdATI/https%3A%2F%2Fhackmd.io%2F%40nadhifmr%2FSy24dwgUj%2Fhttps%253A%252F%252Fhackmd.io%252FhUgJAojCT3qpBMKKggieFQ%253Fview)
- [Google test](https://hackmd.io/@ChiehChun/HyNXWdATI/https%3A%2F%2Fhackmd.io%2FXCDUl21LTKaCKZ-UeYxObw%3Fview)
:::
:::danger
If your NIC is E810, please check [this note](https://hackmd.io/9xkPG7niTaapaGRgecBWMw?view) for the update.
:::
## 1. Update i40e driver
:::warning
The recommended version is 2.10.19.82, but for all the version over than x2.9.21 should also work
:::
- Download file from [here](https://www.intel.com/content/www/us/en/download/18026/29658/intel-network-adapter-driver-for-pcie-40-gigabit-ethernet-network-connections-under-linux.html)
:::info
you can try
```shell=
wget https://downloadmirror.intel.com/29658/eng/i40e-2.10.19.82.tar.gz
```
:::
```shell=
[oai@ee705-7-ip120 ~]$ tar -zxvf i40e-2.10.19.82.tar.gz
[oai@ee705-7-ip120 ~]$ cd i40e-2.10.19.82/src/
### install the driver
[oai@ee705-7-ip120 src]$ sudo make install
### see the drvier info
[oai@ee705-7-ip120 src]$ modinfo i40e
### remove the older i40e driver
[oai@ee705-7-ip120 src]$ sudo rmmod i40e
### load the driver
[oai@ee705-7-ip120 src]$ sudo modprobe i40e
### check the driver
[oai@ee705-7-ip120 src]$ ethtool -i enp134s0f0
```

### Update X710 Firmware
We try to use version 8.3 of X710 network adapter
- Download file from [here](https://www.intel.com/content/www/us/en/download/18190/30600/non-volatile-memory-nvm-update-utility-for-intel-ethernet-network-adapter-700-series.html)

```shell=
wget https://downloadmirror.intel.com/30600/eng/nvmupdatepackage_700_series_v8_30.zip
```
```shell=
# unzip file
[oai@ee705-7-ip120 ~]$ unzip nvmupdatepackage_700_series_v8_30.zip
[oai@ee705-7-ip120 ~]$ tar zxvf 700Series_NVMUpdatePackage_v8_30_Linux.tar.gz
[oai@ee705-7-ip120 ~]$ cd 700Series/Linux_x64
[oai@ee705-7-ip120 Linux_x64]$ chmod 755 nvmupdate64e
[oai@ee705-7-ip120 Linux_x64]$ sudo ./nvmupdate64e
```

- Choose the interface you want to update (in my case I choose `4`)
- For the `Would you like to back up the NVM images ?` -> type `n`
- After update, reboot the server
```shell=
[oai@ee705-7-ip120 Linux_x64]$ sudo reboot
```
Check the firmware version
```shell=
[oai@ee705-7-ip120 ~]$ ethtool -i enp134s0f0
```

## 2. Enable virtual functions (VF) on the device
You can get the ethernet interface and the corresponding bus info by using this command:
`sudo lshw -c network -businfo`
:::info
- Shell file will create Virtual Function on your chosen NIC with echo command (echo 1 mean it will create 1 VF)
- ip link set will set the vlan number to the created VF
:::
```shell=
sudo su
# run shell file content is below
source setupvf.sh
exit
```
:::spoiler setupvf.sh
```
#!/bin/bash
echo 0 > /sys/bus/pci/devices/0000\:3b\:00.0/sriov_numvfs
echo 0 > /sys/bus/pci/devices/0000\:3b\:01.0/sriov_numvfs
modprobe -r iavf
modprobe iavf
echo 1 > /sys/bus/pci/devices/0000\:3b\:00.0/sriov_numvfs
echo 1 > /sys/bus/pci/devices/0000\:3b\:01.0/sriov_numvfs
a=8
if [ -z "$1" ]
then
b=0
elif [ $1 -lt $a ]
then
b=$1
else
echo " Usage $0 qos with 0<= qos <= 7 with 0 as a default if no qos is provided"
exit 1
fi
#O-DU
ip link set p1p1 vf 0 mac 00:11:22:33:44:66 vlan 3 qos $b
ip link set p1p2 vf 0 mac 00:11:22:33:44:55 vlan 3 qos $b
```
:::
:::info
- Bind created VF to DPDK
- Check created VF bus number first with **--status** command and change them accordingly
:::
```shell=
cd
sudo modprobe vfio-pci
cd DPDK/dpdk-stable-20.11.3
sudo ./usertools/dpdk-devbind.py --status
sudo ./usertools/dpdk-devbind.py --bind=vfio-pci 0000:3b:02.0 0000:3b:0a.0
```
:::danger
If DPDK cannot bind your virtual function
Check again your BIOS if you have added iommu=pt and intel_iommu=on on the OS configuration
Check the IO virtualization too in BIOS setting, turn it to on so that your server could use SR-IOV
:::
:::success
The virtual function port must be in the DPDK-compatible driver

:::