Skip to content

Commit

Permalink
script/nicctl: add create_tvf command (#563)
Browse files Browse the repository at this point in the history
To create trusted VFs

Signed-off-by: Frank Du <[email protected]>
  • Loading branch information
frankdjx authored Nov 3, 2023
1 parent 20ffcbe commit 624d96d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 12 deletions.
24 changes: 19 additions & 5 deletions doc/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -494,13 +494,27 @@ sudo ./script/nicctl.sh bind_kernel 0000:af:00.0
sudo ./script/nicctl.sh bind_pmd 0000:af:00.0
```
### 8.9 How to find the BDF number for NICs
### 8.9 Create trusted VFs
To allow privileged usage in use cases that require Trusted Virtual Functions (VFs), you can utilize the following command:
```bash
sudo ./script/nicctl.sh create_tvf 0000:af:00.0
```
If you need to control the Trusted setting on a per-VF basis, you can use the following example command:
```bash
sudo ip link set enp24s0f0 vf 0 trust on
```
### 8.10 How to find the BDF number for NICs
```bash
dpdk-devbind.py -s
```
### 8.10 How to find the BDF number which is ready for IMTL usage
### 8.11 How to find the BDF number which is ready for IMTL usage
```bash
dpdk-devbind.py -s
Expand All @@ -519,7 +533,7 @@ Network devices using DPDK-compatible driver
0000:af:01.5 'Ethernet Adaptive Virtual Function 1889' drv=vfio-pci unused=iavf
```
### 8.11 Lower fps if ptp4l&phc2sys is enabled
### 8.12 Lower fps if ptp4l&phc2sys is enabled
You may have noticed a similar epoch drop log, which is likely caused by both NTP and phc2sys adjusting the system. To address this issue, please disable the NTP service.
Expand All @@ -533,15 +547,15 @@ MT: TX_VIDEO_SESSION(0,0): mismatch epoch troffset 275
MT: TX_VIDEO_SESSION(0,0): epoch drop 275
```
### 8.12 NO-IOMMU mode for vfio
### 8.13 NO-IOMMU mode for vfio
The VFIO driver can run without the IOMMU feature, enable it with below command to bypass IOMMU. As the name suggests, `enable_unsafe_noiommu_mode` is considered unsafe, and should only be used if you understand the risks.
```bash
sudo bash -c 'echo 1 > /sys/module/vfio/parameters/enable_unsafe_noiommu_mode'
```
### 8.12 Fail to loading shared libraries
### 8.13 Fail to loading shared libraries
If you get below similar message when runing the RxTxApp, it's likely a ld library path problem.

Expand Down
30 changes: 23 additions & 7 deletions script/nicctl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ if [ $# -lt 2 ]; then
echo "Commands:"
echo " bind_pmd bind driver to DPDK PMD driver"
echo " bind_kernel bind driver to kernel driver"
echo " create_vf create VF and bind to VFIO"
echo " create_kvf create VF and bind to kernel driver"
echo " create_dcf_vf create DCF VF and bind to VFIO"
echo " create_vf create VFs and bind to VFIO"
echo " create_kvf create VFs and bind to kernel driver"
echo " create_tvf create trusted VFs and bind to VFIO"
echo " create_dcf_vf create DCF VFs and bind to VFIO"
echo " disable_vf Disable VF"
echo " status List the DPDK port status"
exit 0
Expand Down Expand Up @@ -85,8 +86,10 @@ create_vf() {
if [ -n "$vfif" ]; then
ip link set "$vfif" down
fi
#enable trust
#ip link set $port vf $i trust on
if [ "$2" == "trusted" ]; then
# enable trust
ip link set "$inf" vf $i trust on
fi
if [ $bifurcated_driver -eq 0 ]; then
if dpdk-devbind.py -b vfio-pci "$vfport"; then
echo "Bind $vfport($vfif) to vfio-pci success"
Expand All @@ -109,7 +112,7 @@ create_kvf() {
done
}

cmdlist=("bind_kernel" "create_vf" "create_kvf" "disable_vf" "bind_pmd" "create_dcf_vf" "status")
cmdlist=("bind_kernel" "create_vf" "create_kvf" "create_tvf" "disable_vf" "bind_pmd" "create_dcf_vf" "status")

for c in "${cmdlist[@]}"; do
if [ "$c" == "$1" ]; then
Expand Down Expand Up @@ -194,7 +197,20 @@ if [ "$cmd" == "create_vf" ]; then
modprobe vfio-pci
disable_vf
create_vf $numvfs
echo "Create VFs on PF bdf: $bdf $inf succ"
echo "Create $numvfs VFs on PF bdf: $bdf $inf succ"
fi

if [ "$cmd" == "create_tvf" ]; then
if [ -n "$3" ]; then
numvfs=$(($3+0))
else
# default VF number
numvfs=6
fi
modprobe vfio-pci
disable_vf
create_vf $numvfs trusted
echo "Create trusted $numvfs VFs on PF bdf: $bdf $inf succ"
fi

if [ "$cmd" == "create_kvf" ]; then
Expand Down

0 comments on commit 624d96d

Please sign in to comment.