Whamcloud - gitweb
LU-8401 lnet: remove dependency on OFED headers from lnet
[fs/lustre-release.git] / lnet / autoconf / lustre-lnet.m4
index a03611c..47a4ff1 100644 (file)
@@ -150,7 +150,14 @@ AC_ARG_WITH([o2ib],
 
 case $with_o2ib in
        yes)    AS_IF([which ofed_info 2>/dev/null], [
-                       O2IBPATHS=$(ofed_info | egrep -w 'compat-rdma-devel|kernel-ib-devel|ofa_kernel-devel' | xargs rpm -ql | grep '/openib$')
+                       AS_IF([test x$uses_dpkg = xyes], [
+                               OFED_INFO="ofed_info | awk '{print \[$]2}'"
+                               LSPKG="dpkg --listfiles"
+                       ], [
+                               OFED_INFO="ofed_info"
+                               LSPKG="rpm -ql"
+                       ])
+                       O2IBPATHS=$(eval $OFED_INFO | egrep -w 'mlnx-ofed-kernel-dkms|mlnx-ofa_kernel-devel|compat-rdma-devel|kernel-ib-devel|ofa_kernel-devel' | xargs $LSPKG | grep '\(/openib\|/ofa_kernel/default\)$' | head -n1)
                        AS_IF([test -z "$O2IBPATHS"], [
                                AC_MSG_ERROR([
 You seem to have an OFED installed but have not installed it's devel package.
@@ -206,7 +213,7 @@ AS_IF([test $ENABLEO2IB = "no"], [
                        AC_MSG_RESULT([yes])
                        compatrdma_found=true
                        AC_DEFINE(HAVE_COMPAT_RDMA, 1, [compat rdma found])
-                       EXTRA_OFED_INCLUDE="$EXTRA_OFED_INCLUDE -include ${O2IBPATH}/include/linux/compat-2.6.h"
+                       EXTRA_OFED_CONFIG="$EXTRA_OFED_CONFIG -include ${O2IBPATH}/include/linux/compat-2.6.h"
                        if test -f "$O2IBPATH/include/linux/compat_autoconf.h"; then
                                COMPAT_AUTOCONF="$O2IBPATH/include/linux/compat_autoconf.h"
                        fi
@@ -234,19 +241,6 @@ AS_IF([test $ENABLEO2IB = "no"], [
                        fi
                fi
 
-               LB_CHECK_COMPILE([if Linux kernel has kthread_worker],
-               linux_kthread_worker, [
-                       #include <linux/kthread.h>
-               ],[
-                       struct kthread_work     *kth_wrk __attribute__ ((unused));
-                       flush_kthread_work(kth_wrk);
-               ],[
-                       AC_DEFINE(HAVE_KTHREAD_WORK, 1, [kthread_worker found])
-                       if test -z "$COMPAT_AUTOCONF"; then
-                               EXTRA_OFED_INCLUDE="$EXTRA_OFED_INCLUDE -DCONFIG_COMPAT_IS_KTHREAD"
-                       fi
-               ])
-
                AC_MSG_CHECKING([whether to use any OFED backport headers])
                if test -n "$BACKPORT_INCLUDES"; then
                        AC_MSG_RESULT([yes])
@@ -259,9 +253,16 @@ AS_IF([test $ENABLEO2IB = "no"], [
                O2IBLND=""
                O2IBPATH=$(readlink --canonicalize $O2IBPATH)
                EXTRA_OFED_INCLUDE="$EXTRA_OFED_INCLUDE -I$O2IBPATH/include"
+               EXTRA_CHECK_INCLUDE="$EXTRA_OFED_CONFIG $EXTRA_OFED_INCLUDE"
                LB_CHECK_COMPILE([whether to enable OpenIB gen2 support],
                openib_gen2_support, [
                        #ifdef HAVE_COMPAT_RDMA
+                       #undef PACKAGE_NAME
+                       #undef PACKAGE_TARNAME
+                       #undef PACKAGE_VERSION
+                       #undef PACKAGE_STRING
+                       #undef PACKAGE_BUGREPORT
+                       #undef PACKAGE_URL
                        #include <linux/compat-2.6.h>
                        #endif
                        #include <linux/version.h>
@@ -306,18 +307,50 @@ AS_IF([test $ENABLEO2IB = "no"], [
                                AC_MSG_ERROR([an external source tree was, either specified or detected, for o2iblnd however I could not find a $O2IBPATH/Module.symvers there])
                        fi
                fi
+
+               LB_CHECK_COMPILE([if Linux kernel has kthread_worker],
+               linux_kthread_worker, [
+                       #ifdef HAVE_COMPAT_RDMA
+                       #undef PACKAGE_NAME
+                       #undef PACKAGE_TARNAME
+                       #undef PACKAGE_VERSION
+                       #undef PACKAGE_STRING
+                       #undef PACKAGE_BUGREPORT
+                       #undef PACKAGE_URL
+                       #include <linux/compat-2.6.h>
+                       #endif
+                       #include <linux/kthread.h>
+               ],[
+                       struct kthread_work     *kth_wrk __attribute__ ((unused));
+                       flush_kthread_work(kth_wrk);
+               ],[
+                       AC_DEFINE(HAVE_KTHREAD_WORK, 1, [kthread_worker found])
+                       if test -z "$COMPAT_AUTOCONF"; then
+                               EXTRA_OFED_INCLUDE="$EXTRA_OFED_INCLUDE -DCONFIG_COMPAT_IS_KTHREAD"
+                       fi
+               ])
+               EXTRA_CHECK_INCLUDE=""
        fi
 ])
+AC_SUBST(EXTRA_OFED_CONFIG)
 AC_SUBST(EXTRA_OFED_INCLUDE)
 AC_SUBST(O2IBLND)
-AC_SUBST(O2IBPATHS)
+AC_SUBST(O2IBPATH)
 AC_SUBST(ENABLEO2IB)
 
-# In RHEL 6.2, rdma_create_id() takes the queue-pair type as a fourth argument
 AS_IF([test $ENABLEO2IB != "no"], [
+       EXTRA_CHECK_INCLUDE="$EXTRA_OFED_CONFIG $EXTRA_OFED_INCLUDE"
+
+       # In RHEL 6.2, rdma_create_id() takes the queue-pair type as a fourth argument
        LB_CHECK_COMPILE([if 'rdma_create_id' wants four args],
        rdma_create_id_4args, [
                #ifdef HAVE_COMPAT_RDMA
+               #undef PACKAGE_NAME
+               #undef PACKAGE_TARNAME
+               #undef PACKAGE_VERSION
+               #undef PACKAGE_STRING
+               #undef PACKAGE_BUGREPORT
+               #undef PACKAGE_URL
                #include <linux/compat-2.6.h>
                #endif
                #include <rdma/rdma_cm.h>
@@ -327,7 +360,161 @@ AS_IF([test $ENABLEO2IB != "no"], [
                AC_DEFINE(HAVE_RDMA_CREATE_ID_4ARG, 1,
                        [rdma_create_id wants 4 args])
        ])
-])
+
+       # 4.4 added network namespace parameter for rdma_create_id()
+       LB_CHECK_COMPILE([if 'rdma_create_id' wants five args],
+       rdma_create_id_5args, [
+               #ifdef HAVE_COMPAT_RDMA
+               #undef PACKAGE_NAME
+               #undef PACKAGE_TARNAME
+               #undef PACKAGE_VERSION
+               #undef PACKAGE_STRING
+               #undef PACKAGE_BUGREPORT
+               #undef PACKAGE_URL
+               #include <linux/compat-2.6.h>
+               #endif
+               #include <rdma/rdma_cm.h>
+       ],[
+               rdma_create_id(NULL, NULL, NULL, 0, 0);
+       ],[
+               AC_DEFINE(HAVE_RDMA_CREATE_ID_5ARG, 1,
+                       [rdma_create_id wants 5 args])
+       ])
+
+       # 4.2 introduced struct ib_cq_init_attr which is used
+       # by ib_create_cq(). Note some OFED stacks only keep
+       # their headers in sync with latest kernels but not
+       # the functionality which means for infiniband testing
+       # we need to always test functionality testings.
+       LB_CHECK_COMPILE([if 'struct ib_cq_init_attr' is used],
+       ib_cq_init_attr, [
+               #ifdef HAVE_COMPAT_RDMA
+               #undef PACKAGE_NAME
+               #undef PACKAGE_TARNAME
+               #undef PACKAGE_VERSION
+               #undef PACKAGE_STRING
+               #undef PACKAGE_BUGREPORT
+               #undef PACKAGE_URL
+               #include <linux/compat-2.6.h>
+               #endif
+               #include <rdma/ib_verbs.h>
+       ],[
+               struct ib_cq_init_attr cq_attr;
+
+               ib_create_cq(NULL, NULL, NULL, NULL, &cq_attr);
+       ],[
+               AC_DEFINE(HAVE_IB_CQ_INIT_ATTR, 1,
+                       [struct ib_cq_init_attr is used by ib_create_cq])
+       ])
+
+       # 4.3 removed ib_alloc_fast_reg_mr()
+       LB_CHECK_COMPILE([if 'ib_alloc_fast_reg_mr' exists],
+       ib_alloc_fast_reg_mr, [
+               #ifdef HAVE_COMPAT_RDMA
+               #undef PACKAGE_NAME
+               #undef PACKAGE_TARNAME
+               #undef PACKAGE_VERSION
+               #undef PACKAGE_STRING
+               #undef PACKAGE_BUGREPORT
+               #undef PACKAGE_URL
+               #include <linux/compat-2.6.h>
+               #endif
+               #include <rdma/ib_verbs.h>
+       ],[
+               ib_alloc_fast_reg_mr(NULL, 0);
+       ],[
+               AC_DEFINE(HAVE_IB_ALLOC_FAST_REG_MR, 1,
+                       [ib_alloc_fast_reg_mr is defined])
+       ])
+
+       # In v4.4 Linux kernel,
+       # commit e622f2f4ad2142d2a613a57fb85f8cf737935ef5
+       # split up struct ib_send_wr so that all non-trivial verbs
+       # use their own structure which embedds struct ib_send_wr.
+       LB_CHECK_COMPILE([if 'struct ib_rdma_wr' is defined],
+       ib_rdma_wr, [
+               #ifdef HAVE_COMPAT_RDMA
+               #undef PACKAGE_NAME
+               #undef PACKAGE_TARNAME
+               #undef PACKAGE_VERSION
+               #undef PACKAGE_STRING
+               #undef PACKAGE_BUGREPORT
+               #undef PACKAGE_URL
+               #include <linux/compat-2.6.h>
+               #endif
+               #include <rdma/ib_verbs.h>
+       ],[
+               struct ib_rdma_wr *wr __attribute__ ((unused));
+
+               wr = rdma_wr(NULL);
+       ],[
+               AC_DEFINE(HAVE_IB_RDMA_WR, 1,
+                       [struct ib_rdma_wr is defined])
+       ])
+
+       # new fast registration API introduced in 4.4
+       LB_CHECK_COMPILE([if 'ib_map_mr_sg' exists],
+       ib_map_mr_sg, [
+               #ifdef HAVE_COMPAT_RDMA
+               #undef PACKAGE_NAME
+               #undef PACKAGE_TARNAME
+               #undef PACKAGE_VERSION
+               #undef PACKAGE_STRING
+               #undef PACKAGE_BUGREPORT
+               #undef PACKAGE_URL
+               #include <linux/compat-2.6.h>
+               #endif
+               #include <rdma/ib_verbs.h>
+       ],[
+               ib_map_mr_sg(NULL, NULL, 0, 0);
+       ],[
+               AC_DEFINE(HAVE_IB_MAP_MR_SG, 1,
+                       [ib_map_mr_sg exists])
+       ])
+
+       # ib_query_device() removed in 4.5
+       LB_CHECK_COMPILE([if 'struct ib_device' has member 'attrs'],
+       ib_device.attrs, [
+               #ifdef HAVE_COMPAT_RDMA
+               #undef PACKAGE_NAME
+               #undef PACKAGE_TARNAME
+               #undef PACKAGE_VERSION
+               #undef PACKAGE_STRING
+               #undef PACKAGE_BUGREPORT
+               #undef PACKAGE_URL
+               #include <linux/compat-2.6.h>
+               #endif
+               #include <rdma/ib_verbs.h>
+       ],[
+               struct ib_device dev;
+               struct ib_device_attr dev_attr = {};
+               dev.attrs = dev_attr;
+       ],[
+               AC_DEFINE(HAVE_IB_DEVICE_ATTRS, 1,
+                       [struct ib_device.attrs is defined])
+       ])
+
+       LB_CHECK_COMPILE([if function 'ib_inc_rkey' is defined],
+       ib_inc_rkey, [
+               #ifdef HAVE_COMPAT_RDMA
+               #undef PACKAGE_NAME
+               #undef PACKAGE_TARNAME
+               #undef PACKAGE_VERSION
+               #undef PACKAGE_STRING
+               #undef PACKAGE_BUGREPORT
+               #undef PACKAGE_URL
+               #include <linux/compat-2.6.h>
+               #endif
+               #include <rdma/ib_verbs.h>
+       ],[
+               (void)ib_inc_rkey(0);
+       ],[
+               AC_DEFINE(HAVE_IB_INC_RKEY, 1,
+                         [function ib_inc_rkey exist])
+       ])
+
+       EXTRA_CHECK_INCLUDE=""
+]) # ENABLEO2IB != "no"
 ]) # LN_CONFIG_O2IB
 
 #
@@ -398,9 +585,6 @@ AC_SUBST(GNILND)
 AC_DEFUN([LN_CONFIG_SK_SLEEP], [
 LB_CHECK_COMPILE([if Linux kernel has 'sk_sleep'],
 sk_sleep, [
-       #ifdef HAVE_COMPAT_RDMA
-       #include <linux/compat-2.6.h>
-       #endif
        #include <net/sock.h>
 ],[
        sk_sleep(NULL);
@@ -413,7 +597,8 @@ sk_sleep, [
 #
 # LN_CONFIG_TCP_SENDPAGE
 #
-# 2.6.36 tcp_sendpage() first parameter is 'struct sock' instead of 'struct socket'.
+# 2.6.36 tcp_sendpage() first parameter is 'struct sock'
+# instead of 'struct socket'.
 #
 AC_DEFUN([LN_CONFIG_TCP_SENDPAGE], [
 tmp_flags="$EXTRA_KCFLAGS"