update copyright date to 2013
[dpdk.git] / tools / setup.sh
index 058bc86..9326d84 100755 (executable)
@@ -2,7 +2,7 @@
 
 #   BSD LICENSE
 # 
-#   Copyright(c) 2010-2012 Intel Corporation. All rights reserved.
+#   Copyright(c) 2010-2013 Intel Corporation. All rights reserved.
 #   All rights reserved.
 # 
 #   Redistribution and use in source and binary forms, with or without 
@@ -59,7 +59,7 @@ quit()
 }
 
 #
-# Sets up envronment variables for ICC.
+# Sets up environmental variables for ICC.
 #
 setup_icc()
 {
@@ -187,6 +187,42 @@ load_igb_uio_module()
        fi
 }
 
+#
+# Unloads the rte_kni.ko module.
+#
+remove_kni_module()
+{
+       echo "Unloading any existing DPDK KNI module"
+       /sbin/lsmod | grep -s rte_kni > /dev/null
+       if [ $? -eq 0 ] ; then
+               sudo /sbin/rmmod rte_kni
+       fi
+}
+
+#
+# Loads the rte_kni.ko module.
+#
+load_kni_module()
+{
+    # Check that the KNI module is already built.
+       if [ ! -f $RTE_SDK/$RTE_TARGET/kmod/rte_kni.ko ];then
+               echo "## ERROR: Target does not have the DPDK KNI Module."
+               echo "       To fix, please try to rebuild target."
+               return
+       fi
+
+    # Unload existing version if present.
+       remove_kni_module
+
+    # Now try load the KNI module.
+       echo "Loading DPDK KNI module"
+       sudo /sbin/insmod $RTE_SDK/$RTE_TARGET/kmod/rte_kni.ko
+       if [ $? -ne 0 ] ; then
+               echo "## ERROR: Could not load kmod/rte_kni.ko."
+               quit
+       fi
+}
+
 #
 # Removes all reserved hugepages.
 #
@@ -324,11 +360,14 @@ step2_func()
        TEXT[1]="Insert IGB UIO module"
        FUNC[1]="load_igb_uio_module"
 
-       TEXT[2]="Setup hugepage mappings for non-NUMA systems"
-       FUNC[2]="set_non_numa_pages"
+       TEXT[2]="Insert KNI module"
+       FUNC[2]="load_kni_module"
 
-       TEXT[3]="Setup hugepage mappings for NUMA systems"
-       FUNC[3]="set_numa_pages"
+       TEXT[3]="Setup hugepage mappings for non-NUMA systems"
+       FUNC[3]="set_non_numa_pages"
+
+       TEXT[4]="Setup hugepage mappings for NUMA systems"
+       FUNC[4]="set_numa_pages"
 }
 
 #
@@ -372,8 +411,11 @@ step5_func()
        TEXT[2]="Remove IGB UIO module"
        FUNC[2]="remove_igb_uio_module"
 
-       TEXT[3]="Remove hugepage mappings"
-       FUNC[3]="clear_huge_pages"
+       TEXT[3]="Remove KNI module"
+       FUNC[3]="remove_kni_module"
+
+       TEXT[4]="Remove hugepage mappings"
+       FUNC[4]="clear_huge_pages"
 }
 
 STEPS[1]="step1_func"