Whamcloud - gitweb
fix building problem with 2.6.22 kernel.
[fs/lustre-release.git] / lnet / autoconf / lustre-lnet.m4
index 479a1f5..434cb1b 100644 (file)
@@ -42,52 +42,47 @@ fi
 ])
 
 #
-# LN_CONFIG_ZEROCOPY
+# LN_CONFIG_CDEBUG
 #
-# check if zerocopy is available/wanted
+# whether to enable various libcfs debugs (CDEBUG, ENTRY/EXIT, LASSERT, etc.)
 #
-AC_DEFUN([LN_CONFIG_ZEROCOPY],
-[AC_ARG_ENABLE([zerocopy],
-       AC_HELP_STRING([--disable-zerocopy],
-                      [disable socklnd zerocopy]),
-       [],[enable_zerocopy='yes'])
-AC_MSG_CHECKING([for zero-copy TCP support])
-if test x$enable_zerocopy = xno ; then
-       AC_MSG_RESULT([no (by request)])
+AC_DEFUN([LN_CONFIG_CDEBUG],
+[
+AC_MSG_CHECKING([whether to enable CDEBUG, CWARN])
+AC_ARG_ENABLE([libcfs_cdebug],
+       AC_HELP_STRING([--disable-libcfs-cdebug],
+                       [disable libcfs CDEBUG, CWARN]),
+       [],[enable_libcfs_cdebug='yes'])
+AC_MSG_RESULT([$enable_libcfs_cdebug])
+if test x$enable_libcfs_cdebug = xyes; then
+   AC_DEFINE(CDEBUG_ENABLED, 1, [enable libcfs CDEBUG, CWARN])
 else
-       ZCCD="`grep -c zccd $LINUX/include/linux/skbuff.h`"
-       if test "$ZCCD" = 0 ; then
-               AC_MSG_RESULT([no (no kernel support)])
-       else
-               AC_MSG_RESULT([yes])
-               AC_MSG_CHECKING([for up-to-date tcp zero-copy patch])
-               LB_LINUX_TRY_COMPILE([
-                       #include <linux/config.h>
-                       #include <linux/kernel.h>
-                       #include <linux/sched.h>
-                       #include <linux/types.h>
-                       #include <linux/in.h>
-                       #include <linux/string.h>
-                       #include <linux/init.h>
-                       #include <linux/errno.h>
-                       #include <linux/interrupt.h>
-                       #include <linux/netdevice.h>
-                       #include <linux/skbuff.h>
-               ],[
-                       struct zccd zc = {0};
-
-                       return atomic_read(&zc.zccd_refcount);
-               ],[
-                       AC_MSG_RESULT([yes])
-                       AC_DEFINE(SOCKNAL_ZC, 1, [enable zero-copy support])
-               ],[
-                       AC_MSG_RESULT([no])
-                       AC_MSG_ERROR([old TCP zero-copy in kernel (bug 10889) - use --disable-zerocopy to continue ])
-               ])
-       fi
+   AC_DEFINE(CDEBUG_ENABLED, 0, [disable libcfs CDEBUG, CWARN])
+fi
+
+AC_MSG_CHECKING([whether to enable ENTRY/EXIT])
+AC_ARG_ENABLE([libcfs_trace],
+       AC_HELP_STRING([--disable-libcfs-trace],
+                       [disable libcfs ENTRY/EXIT]),
+       [],[enable_libcfs_trace='yes'])
+AC_MSG_RESULT([$enable_libcfs_trace])
+if test x$enable_libcfs_trace = xyes; then
+   AC_DEFINE(CDEBUG_ENTRY_EXIT, 1, [enable libcfs ENTRY/EXIT])
+else
+   AC_DEFINE(CDEBUG_ENTRY_EXIT, 0, [disable libcfs ENTRY/EXIT])
 fi
-])
 
+AC_MSG_CHECKING([whether to enable LASSERT, LASSERTF])
+AC_ARG_ENABLE([libcfs_assert],
+       AC_HELP_STRING([--disable-libcfs-assert],
+                       [disable libcfs LASSERT, LASSERTF]),
+       [],[enable_libcfs_assert='yes'])
+AC_MSG_RESULT([$enable_libcfs_assert])
+if test x$enable_libcfs_assert = xyes; then
+   AC_DEFINE(LIBCFS_DEBUG, 1, [enable libcfs LASSERT, LASSERTF])
+fi
+])
 #
 # LN_CONFIG_AFFINITY
 #
@@ -538,8 +533,10 @@ else
        O2IBCPPFLAGS="-I$O2IBPATH/include"
        EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
        EXTRA_KCFLAGS="$EXTRA_KCFLAGS $O2IBCPPFLAGS"
+       EXTRA_LNET_INCLUDE="$O2IBCPPFLAGS $EXTRA_LNET_INCLUDE"
        LB_LINUX_TRY_COMPILE([
                #include <linux/version.h>
+               #include <linux/pci.h>
                #if !HAVE_GFP_T
                typedef int gfp_t;
                #endif
@@ -571,8 +568,29 @@ else
                O2IBLND=""
                O2IBCPPFLAGS=""
        ])
+
+# version checking is a hack and isn't reliable, we need verify it
+# with each new ofed release
+
+       IB_DMA_MAP="`grep -c ib_dma_map_single ${O2IBPATH}/include/rdma/ib_verbs.h`"
+       if test "$IB_DMA_MAP" != 0 ; then
+               IB_COMP_VECT="`grep -c comp_vector ${O2IBPATH}/include/rdma/ib_verbs.h`"
+               if test "$IB_COMP_VECT" != 0 ; then
+                       IBLND_OFED_VERSION="1025"
+               else
+                       IBLND_OFED_VERSION="1020"
+               fi
+       else
+               IBLND_OFED_VERSION="1010"
+       fi
+
+        AC_DEFINE_UNQUOTED(IBLND_OFED_VERSION, $IBLND_OFED_VERSION,
+                          [OFED version])
+
        EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
 fi
+
+AC_SUBST(EXTRA_LNET_INCLUDE)
 AC_SUBST(O2IBCPPFLAGS)
 AC_SUBST(O2IBLND)
 ])
@@ -1022,35 +1040,22 @@ LB_LINUX_TRY_COMPILE([
 # we export show_task(), but not all kernels have it (yet)
 #
 AC_DEFUN([LN_FUNC_SHOW_TASK],
-[AC_MSG_CHECKING([if kernel exports show_task])
-have_show_task=0
-for file in ksyms sched ; do
-       if grep -q "EXPORT_SYMBOL(show_task)" \
-                "$LINUX/kernel/$file.c" 2>/dev/null ; then
-               have_show_task=1
-               break
-       fi
-done
-if test x$have_show_task = x1 ; then
-       AC_DEFINE(HAVE_SHOW_TASK, 1, [show_task is exported])
-       AC_MSG_RESULT([yes])
-else
-       AC_MSG_RESULT([no])
-fi
+[LB_CHECK_SYMBOL_EXPORT([show_task],
+[kernel/ksyms.c kernel/sched.c],[
+AC_DEFINE(HAVE_SHOW_TASK, 1, [show_task is exported])
+],[
+])
 ])
 
 # LN_TASKLIST_LOCK
 # 2.6.18 remove tasklist_lock export
 AC_DEFUN([LN_TASKLIST_LOCK],
-[AC_MSG_CHECKING([kernel export tasklist_lock])
-        if grep -q "EXPORT_SYMBOL(tasklist_lock)" \
-                 "$LINUX/kernel/fork.c" 2>/dev/null ; then
-                AC_DEFINE(HAVE_TASKLIST_LOCK, 1,
-                          [tasklist_lock exported])
-                AC_MSG_RESULT([yes])
-        else
-                AC_MSG_RESULT([no])
-        fi
+[LB_CHECK_SYMBOL_EXPORT([tasklist_lock],
+[kernel/fork.c],[
+AC_DEFINE(HAVE_TASKLIST_LOCK, 1,
+         [tasklist_lock exported])
+],[
+])
 ])
 
 # 2.6.19 API changes
@@ -1071,7 +1076,7 @@ LB_LINUX_TRY_COMPILE([
 ])
 ])
 
-#2.6.19 API change
+# 2.6.19 API change
 #panic_notifier_list use atomic_notifier operations
 #
 AC_DEFUN([LN_ATOMIC_PANIC_NOTIFIER],
@@ -1090,13 +1095,88 @@ LB_LINUX_TRY_COMPILE([
 ])
 ])
 
+# 2.6.20 API change INIT_WORK use 2 args and not 
+# store data inside
+AC_DEFUN([LN_3ARGS_INIT_WORK],
+[AC_MSG_CHECKING([check INIT_WORK want 3 args])
+LB_LINUX_TRY_COMPILE([
+       #include <linux/workqueue.h>
+],[
+       struct work_struct work;
+
+       INIT_WORK(&work, NULL, NULL);
+],[
+        AC_MSG_RESULT(yes)
+        AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
+                  [INIT_WORK use 3 args and store data inside])
+],[
+        AC_MSG_RESULT(NO)
+])
+])
+
+# 2.6.21 api change. 'register_sysctl_table' use only one argument,
+# instead of more old which need two.
+AC_DEFUN([LN_2ARGS_REGISTER_SYSCTL],
+[AC_MSG_CHECKING([check register_sysctl_table want 2 args])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/sysctl.h>
+],[
+       return register_sysctl_table(NULL,0);
+],[
+        AC_MSG_RESULT(yes)
+        AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
+                  [register_sysctl_table want 2 args])
+],[
+        AC_MSG_RESULT(NO)
+])
+])
+
+# 2.6.21 uses struct kmem_cache instead of kmem_cache_s for
+# kmem_cache_t
+AC_DEFUN([LN_KMEM_CACHE_S],
+[AC_MSG_CHECKING([check kernel has struct kmem_cache_s])
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_LINUX_TRY_COMPILE([
+        #include <linux/slab.h>
+],[
+       kmem_cache_t *cachep = NULL;
+       
+       kmem_cache_free(cachep, NULL);
+
+],[
+        AC_MSG_RESULT(yes)
+        AC_DEFINE(HAVE_KMEM_CACHE_S, 1,
+                  [kernel has struct kmem_cache_s])
+],[
+        AC_MSG_RESULT(NO)
+])
+EXTRA_KCFLAGS="$tmp_flags"
+])
+# 2.6.23 lost dtor argument
+AC_DEFUN([LN_KMEM_CACHE_CREATE_DTOR],
+[AC_MSG_CHECKING([check kmem_cache_create has dtor argument])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/slab.h>
+],[
+        struct kmem_cache_s *cachep = NULL;
+       kmem_cache_create(NULL, 0, 0, 0, NULL, NULL);
+],[
+        AC_MSG_RESULT(yes)
+        AC_DEFINE(HAVE_KMEM_CACHE_CREATE_DTOR, 1,
+                  [kmem_cache_create has dtor argument])
+],[
+        AC_MSG_RESULT(NO)
+])
+])
+
 #
 # LN_PROG_LINUX
 #
 # LNet linux kernel checks
 #
 AC_DEFUN([LN_PROG_LINUX],
-[LN_CONFIG_ZEROCOPY
+[
 LN_FUNC_CPU_ONLINE
 LN_TYPE_GFP_T
 LN_TYPE_CPUMASK_T
@@ -1122,6 +1202,13 @@ LN_TASKLIST_LOCK
 # 2.6.19
 LN_KMEM_CACHE_DESTROY_INT
 LN_ATOMIC_PANIC_NOTIFIER
+# 2.6.20
+LN_3ARGS_INIT_WORK
+# 2.6.21
+LN_2ARGS_REGISTER_SYSCTL
+LN_KMEM_CACHE_S
+# 2.6.23
+LN_KMEM_CACHE_CREATE_DTOR
 ])
 
 #
@@ -1358,8 +1445,8 @@ lnet/libcfs/autoMakefile
 lnet/libcfs/linux/Makefile
 lnet/lnet/Makefile
 lnet/lnet/autoMakefile
-lnet/tests/Makefile
-lnet/tests/autoMakefile
+lnet/selftest/Makefile
+lnet/selftest/autoMakefile
 lnet/ulnds/Makefile
 lnet/ulnds/autoMakefile
 lnet/ulnds/socklnd/Makefile