3 #/******************************************************************************
5 #* Copyright (c) 2019 Intel.
7 #* Licensed under the Apache License, Version 2.0 (the "License");
8 #* you may not use this file except in compliance with the License.
9 #* You may obtain a copy of the License at
11 #* http://www.apache.org/licenses/LICENSE-2.0
13 #* Unless required by applicable law or agreed to in writing, software
14 #* distributed under the License is distributed on an "AS IS" BASIS,
15 #* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 #* See the License for the specific language governing permissions and
17 #* limitations under the License.
19 #*******************************************************************************/
22 export RTE_SDK=/home/turner/dpdk
23 export RTE_TARGET=x86_64-native-linuxapp-icc
28 remove_igb_uio_module()
30 echo "Unloading any existing DPDK UIO module"
31 /sbin/lsmod | grep -s igb_uio > /dev/null
32 if [ $? -eq 0 ] ; then
33 sudo /sbin/rmmod igb_uio
38 # Loads new igb_uio.ko (and uio module if needed).
42 if [ ! -f $RTE_SDK/$RTE_TARGET/kmod/igb_uio.ko ];then
43 echo "## ERROR: Target does not have the DPDK UIO Kernel Module."
44 echo " To fix, please try to rebuild target."
50 /sbin/lsmod | grep -s uio > /dev/null
51 if [ $? -ne 0 ] ; then
52 if [ -f /lib/modules/$(uname -r)/kernel/drivers/uio/uio.ko ] ; then
53 echo "Loading uio module"
54 sudo /sbin/modprobe uio
58 # UIO may be compiled into kernel, so it may not be an error if it can't
61 echo "Loading DPDK UIO module"
62 sudo /sbin/insmod $RTE_SDK/$RTE_TARGET/kmod/igb_uio.ko
63 if [ $? -ne 0 ] ; then
64 echo "## ERROR: Could not load kmod/igb_uio.ko."
70 # Unloads VFIO modules.
74 echo "Unloading any existing VFIO module"
75 /sbin/lsmod | grep -s vfio > /dev/null
76 if [ $? -eq 0 ] ; then
77 sudo /sbin/rmmod vfio-pci
78 sudo /sbin/rmmod vfio_iommu_type1
84 # Loads new vfio-pci (and vfio module if needed).
90 VFIO_PATH="kernel/drivers/vfio/pci/vfio-pci.ko"
92 echo "Loading VFIO module"
93 /sbin/lsmod | grep -s vfio_pci > /dev/null
94 if [ $? -ne 0 ] ; then
95 if [ -f /lib/modules/$(uname -r)/$VFIO_PATH ] ; then
96 sudo /sbin/modprobe vfio-pci
100 # make sure regular users can read /dev/vfio
101 echo "chmod /dev/vfio"
102 sudo chmod a+x /dev/vfio
103 if [ $? -ne 0 ] ; then
109 # check if /dev/vfio/vfio exists - that way we
110 # know we either loaded the module, or it was
111 # compiled into the kernel
112 if [ ! -e /dev/vfio/vfio ] ; then
113 echo "## ERROR: VFIO not found!"
121 CPU_FEATURES_DETECT=`cat /proc/cpuinfo |grep hypervisor | wc -l`
123 if [ "$CPU_FEATURES_DETECT" -eq "0" ]
132 $RTE_SDK/usertools/dpdk-devbind.py --status
133 if [ ${VM_DETECT} == 'HOST' ]; then
135 $RTE_SDK/usertools/dpdk-devbind.py --bind=vfio-pci 0000:22:02.0
136 $RTE_SDK/usertools/dpdk-devbind.py --bind=vfio-pci 0000:22:02.1
137 $RTE_SDK/usertools/dpdk-devbind.py --bind=vfio-pci 0000:22:0a.0
138 $RTE_SDK/usertools/dpdk-devbind.py --bind=vfio-pci 0000:22:0a.1
141 $RTE_SDK/usertools/dpdk-devbind.py --bind=igb_uio 0000:00:04.0
142 $RTE_SDK/usertools/dpdk-devbind.py --bind=igb_uio 0000:00:05.0
143 $RTE_SDK/usertools/dpdk-devbind.py --bind=igb_uio 0000:00:06.0
144 $RTE_SDK/usertools/dpdk-devbind.py --bind=igb_uio 0000:00:07.0
147 $RTE_SDK/usertools/dpdk-devbind.py --status