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