Whamcloud - gitweb
b=15870
[fs/lustre-release.git] / lnet / autoconf / lustre-lnet.m4
index 9415370..2166980 100644 (file)
@@ -498,95 +498,115 @@ AC_SUBST(MXLND)
 AC_DEFUN([LN_CONFIG_O2IB],[
 AC_MSG_CHECKING([whether to enable OpenIB gen2 support])
 # set default
-O2IBPATH="$LINUX/drivers/infiniband"
 AC_ARG_WITH([o2ib],
        AC_HELP_STRING([--with-o2ib=path],
                       [build o2iblnd against path]),
        [
                case $with_o2ib in
-               yes)    ENABLEO2IB=2
+               yes)    O2IBPATHS="$LINUX $LINUX/drivers/infiniband"
+                       ENABLEO2IB=2
                        ;;
                no)     ENABLEO2IB=0
                        ;;
-               *)      O2IBPATH=$with_o2ib
+               *)      O2IBPATHS=$with_o2ib
                        ENABLEO2IB=3
                        ;;
                esac
        ],[
+               O2IBPATHS="$LINUX $LINUX/drivers/infiniband"
                ENABLEO2IB=1
        ])
 if test $ENABLEO2IB -eq 0; then
        AC_MSG_RESULT([disabled])
-elif test ! \( -f ${O2IBPATH}/include/rdma/rdma_cm.h -a \
-               -f ${O2IBPATH}/include/rdma/ib_cm.h -a\
-               -f ${O2IBPATH}/include/rdma/ib_verbs.h -a\
-              -f ${O2IBPATH}/include/rdma/ib_fmr_pool.h \); then
-       AC_MSG_RESULT([no])
-       case $ENABLEO2IB in
-       1) ;;
-       2) AC_MSG_ERROR([kernel OpenIB gen2 headers not present]);;
-       3) AC_MSG_ERROR([bad --with-o2ib path]);;
-       *) AC_MSG_ERROR([internal error]);;
-       esac
 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
-               #include <rdma/rdma_cm.h>
-               #include <rdma/ib_cm.h>
-               #include <rdma/ib_verbs.h>
-               #include <rdma/ib_fmr_pool.h>
-       ],[
-               struct rdma_cm_id          *cm_id;
-               struct rdma_conn_param      conn_param;
-               struct ib_device_attr       device_attr;
-               struct ib_qp_attr           qp_attr;
-               struct ib_pool_fmr          pool_fmr;
-               enum   ib_cm_rej_reason     rej_reason;
-
-               cm_id = rdma_create_id(NULL, NULL, RDMA_PS_TCP);
-               return PTR_ERR(cm_id);
-       ],[
-               AC_MSG_RESULT([yes])
-               O2IBLND="o2iblnd"
-       ],[
+       o2ib_found=false
+       for O2IBPATH in $O2IBPATHS; do
+               if test \( -f ${O2IBPATH}/include/rdma/rdma_cm.h -a \
+                          -f ${O2IBPATH}/include/rdma/ib_cm.h -a \
+                          -f ${O2IBPATH}/include/rdma/ib_verbs.h -a \
+                          -f ${O2IBPATH}/include/rdma/ib_fmr_pool.h \); then
+                       o2ib_found=true
+                       break
+               fi
+       done
+       if ! $o2ib_found; then
                AC_MSG_RESULT([no])
                case $ENABLEO2IB in
-               1) ;;
-               2) AC_MSG_ERROR([can't compile with kernel OpenIB gen2 headers]);;
-               3) AC_MSG_ERROR([can't compile with OpenIB gen2 headers under $O2IBPATH]);;
-               *) AC_MSG_ERROR([internal error]);;
+                       1) ;;
+                       2) AC_MSG_ERROR([kernel OpenIB gen2 headers not present]);;
+                       3) AC_MSG_ERROR([bad --with-o2ib path]);;
+                       *) AC_MSG_ERROR([internal error]);;
                esac
-               O2IBLND=""
-               O2IBCPPFLAGS=""
-       ])
+       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
+                       #include <rdma/rdma_cm.h>
+                       #include <rdma/ib_cm.h>
+                       #include <rdma/ib_verbs.h>
+                       #include <rdma/ib_fmr_pool.h>
+               ],[
+                       struct rdma_cm_id          *cm_id;
+                       struct rdma_conn_param      conn_param;
+                       struct ib_device_attr       device_attr;
+                       struct ib_qp_attr           qp_attr;
+                       struct ib_pool_fmr          pool_fmr;
+                       enum   ib_cm_rej_reason     rej_reason;
+
+                       cm_id = rdma_create_id(NULL, NULL, RDMA_PS_TCP);
+                       return PTR_ERR(cm_id);
+               ],[
+                       AC_MSG_RESULT([yes])
+                       O2IBLND="o2iblnd"
+               ],[
+                       AC_MSG_RESULT([no])
+                       case $ENABLEO2IB in
+                       1) ;;
+                       2) AC_MSG_ERROR([can't compile with kernel OpenIB gen2 headers]);;
+                       3) AC_MSG_ERROR([can't compile with OpenIB gen2 headers under $O2IBPATH]);;
+                       *) AC_MSG_ERROR([internal error]);;
+                       esac
+                       O2IBLND=""
+                       O2IBCPPFLAGS=""
+               ])
 
-# version checking is a hack and isn't reliable, we need verify it
-# with each new ofed release
+               # we know at this point that the found OFED source is good
+               if test \( $ENABLEO2IB = 3 \); then
+                       if test \( -f $O2IBPATH/Module.symvers \); then
+                               AC_MSG_NOTICE([adding $O2IBPATH/Module.symvers to $PWD/Module.symvers])
+                               cat $O2IBPATH/Module.symvers >> $PWD/Module.symvers
+                       else
+                               AC_MSG_ERROR([an external source tree was specified for o2iblnd however I could not find a $O2IBPATH/Module.symvers there])
+                       fi
+               fi
 
-       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"
+               # version checking is a hack and isn't reliable,
+               # we need verify it with each new ofed release
+
+               if grep -q ib_dma_map_single \
+                       ${O2IBPATH}/include/rdma/ib_verbs.h; then
+                       if grep -q comp_vector \
+                               ${O2IBPATH}/include/rdma/ib_verbs.h; then
+                               IBLND_OFED_VERSION="1025"
+                       else
+                               IBLND_OFED_VERSION="1020"
+                       fi
                else
-                       IBLND_OFED_VERSION="1020"
+                       IBLND_OFED_VERSION="1010"
                fi
-       else
-               IBLND_OFED_VERSION="1010"
-       fi
 
-        AC_DEFINE_UNQUOTED(IBLND_OFED_VERSION, $IBLND_OFED_VERSION,
-                          [OFED version])
+               AC_DEFINE_UNQUOTED(IBLND_OFED_VERSION, $IBLND_OFED_VERSION,
+                                  [OFED version])
 
-       EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
+               EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
+       fi
 fi
 
 AC_SUBST(EXTRA_LNET_INCLUDE)
@@ -621,7 +641,7 @@ AC_ARG_WITH([openib],
 if test $ENABLEOPENIB -eq 0; then
        AC_MSG_RESULT([disabled])
 elif test ! \( -f ${OPENIBPATH}/include/ts_ib_core.h -a \
-               -f ${OPENIBPATH}/include/ts_ib_cm.h -a\
+               -f ${OPENIBPATH}/include/ts_ib_cm.h -a \
               -f ${OPENIBPATH}/include/ts_ib_sa_client.h \); then
        AC_MSG_RESULT([no])
        case $ENABLEOPENIB in
@@ -1046,6 +1066,78 @@ AC_DEFINE(HAVE_SHOW_TASK, 1, [show_task is exported])
 ])
 ])
 
+# check userland __u64 type
+AC_DEFUN([LN_U64_LONG_LONG],
+[AC_MSG_CHECKING([u64 is long long type])
+tmp_flags="$CFLAGS"
+CFLAGS="$CFLAGS -Werror"
+AC_COMPILE_IFELSE([
+       #include <linux/types.h>
+       int main(void) {
+               unsigned long long *data1;
+               __u64 *data2;
+               
+               data1 = data2;
+               return 0;
+       }
+],[
+       AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_U64_LONG_LONG, 1,
+                  [__u64 is long long type])
+],[
+       AC_MSG_RESULT([no])
+])
+CFLAGS="$tmp_flags"
+])
+
+# check userland size_t type
+AC_DEFUN([LN_SIZE_T_LONG],
+[AC_MSG_CHECKING([size_t is unsigned long type])
+tmp_flags="$CFLAGS"
+CFLAGS="$CFLAGS -Werror"
+AC_COMPILE_IFELSE([
+       #include <linux/types.h>
+       int main(void) {
+               unsigned long *data1;
+               size_t *data2;
+               
+               data1 = data2;
+               return 0;
+       }
+],[
+       AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_SIZE_T_LONG, 1,
+                  [size_t is long type])
+],[
+       AC_MSG_RESULT([no])
+])
+CFLAGS="$tmp_flags"
+])
+
+AC_DEFUN([LN_SSIZE_T_LONG],
+[AC_MSG_CHECKING([ssize_t is signed long type])
+tmp_flags="$CFLAGS"
+CFLAGS="$CFLAGS -Werror"
+AC_COMPILE_IFELSE([
+       #include <linux/types.h>
+       int main(void) {
+               long *data1;
+               ssize_t *data2;
+               
+               data1 = data2;
+               return 0;
+       }
+],[
+       AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_SSIZE_T_LONG, 1,
+                  [ssize_t is long type])
+],[
+       AC_MSG_RESULT([no])
+])
+CFLAGS="$tmp_flags"
+])
+
+
 # LN_TASKLIST_LOCK
 # 2.6.18 remove tasklist_lock export
 AC_DEFUN([LN_TASKLIST_LOCK],
@@ -1168,18 +1260,6 @@ LB_LINUX_TRY_COMPILE([
 ])
 ])
 
-# asm/segment.h does not exist on all architectures.
-# e.g. the file is empty for ia64 and does not exist for PPC.
-AC_DEFUN([LC_SEGMENT_H],
-        [LB_CHECK_FILE([$LINUX/include/asm/segment.h],
-                       [AC_MSG_CHECKING([if asm/segment.h is present])
-                        LB_LINUX_TRY_COMPILE([#include <asm/segment.h>], [],
-                                             [AC_MSG_RESULT([yes])
-                                              AC_DEFINE(HAVE_SEGMENT_H, 1,
-                                                        [asm/segment.h exists])],
-                                             [AC_MSG_RESULT([no])])])
-]) # LC_SEGMENT_H
-
 #
 # LN_PROG_LINUX
 #
@@ -1207,6 +1287,9 @@ LN_CONFIG_MX
 LN_STRUCT_PAGE_LIST
 LN_STRUCT_SIGHAND
 LN_FUNC_SHOW_TASK
+LN_U64_LONG_LONG
+LN_SSIZE_T_LONG
+LN_SIZE_T_LONG
 # 2.6.18
 LN_TASKLIST_LOCK
 # 2.6.19
@@ -1219,8 +1302,6 @@ LN_2ARGS_REGISTER_SYSCTL
 LN_KMEM_CACHE
 # 2.6.23
 LN_KMEM_CACHE_CREATE_DTOR
-# PPC/PPC64 support
-LC_SEGMENT_H
 ])
 
 #