Whamcloud - gitweb
LU-13488 kernel: new kernel [RHEL 8.2 4.18.0-193.1.2.el8]
[fs/lustre-release.git] / lnet / autoconf / lustre-lnet.m4
index 2d2c2f0..318036b 100644 (file)
@@ -1,93 +1,3 @@
-#
-# LN_CONFIG_MAX_PAYLOAD
-#
-# configure maximum payload
-#
-AC_DEFUN([LN_CONFIG_MAX_PAYLOAD], [
-AC_MSG_CHECKING([for non-default maximum LNET payload])
-AC_ARG_WITH([max-payload-mb],
-       AC_HELP_STRING([--with-max-payload-mb=MBytes],
-               [set maximum lnet payload in MBytes]),
-       [
-               AC_MSG_RESULT([$with_max_payload_mb])
-               CONFIG_LNET_MAX_PAYLOAD_MB=$with_max_payload_mb
-               CONFIG_LNET_MAX_PAYLOAD="(($with_max_payload_mb)<<20)"
-       ], [
-               AC_MSG_RESULT([no])
-               CONFIG_LNET_MAX_PAYLOAD="LNET_MTU"
-       ])
-AC_DEFINE_UNQUOTED(CONFIG_LNET_MAX_PAYLOAD, $CONFIG_LNET_MAX_PAYLOAD,
-       [Max LNET payload])
-]) # LN_CONFIG_MAX_PAYLOAD
-
-#
-# LN_CHECK_GCC_VERSION
-#
-# Check compiler version
-#
-AC_DEFUN([LN_CHECK_GCC_VERSION], [
-AC_MSG_CHECKING([compiler version])
-PTL_CC_VERSION=`$CC --version | awk '/^gcc/{print $ 3}'`
-PTL_MIN_CC_VERSION="3.2.2"
-v2n() {
-       awk -F. '{printf "%d\n", (($ 1)*100+($ 2))*100+($ 3)}'
-}
-if test -z "$PTL_CC_VERSION" -o \
-       $(echo $PTL_CC_VERSION | v2n) -ge $(echo $PTL_MIN_CC_VERSION | v2n); then
-       AC_MSG_RESULT([ok])
-else
-       AC_MSG_RESULT([Buggy compiler found])
-       AC_MSG_ERROR([Need gcc version >= $PTL_MIN_CC_VERSION])
-fi
-]) # LN_CHECK_GCC_VERSION
-
-#
-# LN_FUNC_DEV_GET_BY_NAME_2ARG
-#
-AC_DEFUN([LN_FUNC_DEV_GET_BY_NAME_2ARG], [
-LB_CHECK_COMPILE([if 'dev_get_by_name' has two args],
-dev_get_by_name_2args, [
-       #include <linux/netdevice.h>
-],[
-       dev_get_by_name(NULL, NULL);
-],[
-       AC_DEFINE(HAVE_DEV_GET_BY_NAME_2ARG, 1,
-               [dev_get_by_name has 2 args])
-])
-]) # LN_FUNC_DEV_GET_BY_NAME_2ARG
-
-#
-# LN_CONFIG_AFFINITY
-#
-# check if cpu affinity is available/wanted
-#
-AC_DEFUN([LN_CONFIG_AFFINITY], [
-AC_MSG_CHECKING([whether to enable CPU affinity support])
-AC_ARG_ENABLE([affinity],
-       AC_HELP_STRING([--disable-affinity],
-               [disable process/irq affinity]),
-       [], [enable_affinity="yes"])
-AC_MSG_RESULT([$enable_affinity])
-AS_IF([test "x$enable_affinity" = xyes], [
-       LB_CHECK_COMPILE([if Linux kernel has cpu affinity support],
-       set_cpus_allowed_ptr, [
-               #include <linux/sched.h>
-       ],[
-               struct task_struct *t;
-               #if HAVE_CPUMASK_T
-               cpumask_t     m;
-               #else
-               unsigned long m;
-               #endif
-               set_cpus_allowed_ptr(t, &m);
-       ],[
-               AC_DEFINE(CPU_AFFINITY, 1,
-                       [kernel has cpu affinity support])
-       ])
-])
-]) # LN_CONFIG_AFFINITY
-
-#
 # LN_CONFIG_BACKOFF
 #
 # check if tunable tcp backoff is available/wanted
@@ -116,33 +26,17 @@ AS_IF([test "x$enable_backoff" = xyes], [
 #
 # LN_CONFIG_DLC
 #
-# Configure dlc if enabled
+# Configure dlc
 #
-# if libyaml is set (IE libyaml installed) and enable_dlc = yes then build
-# dlc other wise (IE if libyaml is not set or enable_dlc = no) then don't
-# build dlc.
+# fail to build if libyaml is not installed
 #
 AC_DEFUN([LN_CONFIG_DLC], [
-       AC_CHECK_LIB([yaml],  [yaml_parser_initialize],[
-               LIBYAML="libyaml"],[
-               LIBYAML=""],[-lm])
-       AC_MSG_CHECKING([whether to enable dlc])
-       AC_ARG_ENABLE([dlc],
-               AC_HELP_STRING([--disable-dlc],
-                       [disable building dlc]),
-                       [], [enable_dlc="yes"])
-       USE_DLC=""
-       AS_IF([test "x$enable_dlc" = xyes],
-               [AS_IF([test "x$LIBYAML" = xlibyaml], [
-                       USE_DLC="yes"
-                       AC_MSG_RESULT([yes])
-               ], [
-                       AC_MSG_RESULT([no (libyaml not present)])
-               ])
-       ], [
-               AC_MSG_RESULT([no])
+       AS_IF([test "x$enable_dist" = xno], [
+               AC_CHECK_LIB([yaml], [yaml_parser_initialize],
+                            [LIBYAML="libyaml"],
+                            [AC_MSG_ERROR([YAML development libraries not not installed])],
+                            [-lm])
        ])
-       AC_SUBST(USE_DLC)
 ])
 
 #
@@ -165,7 +59,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\|/ofa_kernel\)$' | 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.
@@ -180,6 +81,11 @@ If you still want to build Lustre for your OFED I/B stack, you need to install a
 Instead, if you want to build Lustre for your kernel's built-in I/B stack rather than your installed OFED stack, either remove the OFED package(s) or use --with-o2ib=no.
                                             ])
                        ])
+                       if test -e $O2IBPATHS/${LINUXRELEASE}; then
+                           O2IBPATHS=$O2IBPATHS/${LINUXRELEASE}
+                       elif test -e $O2IBPATHS/default; then
+                           O2IBPATHS=$O2IBPATHS/default
+                       fi
                        OFED="yes"
                ], [
                        O2IBPATHS="$LINUX $LINUX/drivers/infiniband"
@@ -196,6 +102,8 @@ esac
 
 AS_IF([test $ENABLEO2IB = "no"], [
        AC_MSG_RESULT([no])
+       AC_DEFUN([LN_CONFIG_O2IB_SRC], [])
+       AC_DEFUN([LN_CONFIG_O2IB_RESULTS], [])
 ], [
        o2ib_found=false
        for O2IBPATH in $O2IBPATHS; do
@@ -203,18 +111,6 @@ AS_IF([test $ENABLEO2IB = "no"], [
                           -f ${O2IBPATH}/include/rdma/ib_cm.h -a \
                           -f ${O2IBPATH}/include/rdma/ib_verbs.h -a \
                           -f ${O2IBPATH}/include/rdma/ib_fmr_pool.h \)], [
-                       AS_IF([test \( \( \( -d ${O2IBPATH}/patches -a \
-                                  \( "x$OFED" = "xyes" \) \) -o \
-                                  -d ${O2IBPATH}/kernel_patches \) -a \
-                                  -f ${O2IBPATH}/Makefile \)], [
-                               AC_MSG_RESULT([no])
-                               AC_MSG_ERROR([
-
-trying to use the, explicit or detected, OFED distribution's source
-directory (${O2IBPATH}) rather than the "development/headers"
-directory which is likely in ${O2IBPATH%-*}
-])
-                       ])
                        o2ib_found=true
                        break
                ])
@@ -227,11 +123,16 @@ directory which is likely in ${O2IBPATH%-*}
                        *) AC_MSG_ERROR([internal error]) ;;
                esac
        else
+               COMPAT_AUTOCONF=""
                compatrdma_found=false
                if test -f ${O2IBPATH}/include/linux/compat-2.6.h; then
                        AC_MSG_RESULT([yes])
                        compatrdma_found=true
                        AC_DEFINE(HAVE_COMPAT_RDMA, 1, [compat rdma found])
+                       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
                else
                        AC_MSG_RESULT([no])
                fi
@@ -241,19 +142,21 @@ directory which is likely in ${O2IBPATH%-*}
                        elif test -f "$O2IBPATH/ofed_patch.mk"; then
                                . "$O2IBPATH/ofed_patch.mk"
                        fi
-               else
+               elif test -z "$COMPAT_AUTOCONF"; then
+                       # Depreciated checks
                        if test "x$RHEL_KERNEL" = xyes; then
-                               case "$RHEL_RELEASE_NO" in
-                                       64)
-                                               EXTRA_OFED_INCLUDE="$EXTRA_OFED_INCLUDE -DCONFIG_COMPAT_RHEL_6_4" ;;
-                                       65)
-                                               EXTRA_OFED_INCLUDE="$EXTRA_OFED_INCLUDE -DCONFIG_COMPAT_RHEL_6_4 -DCONFIG_COMPAT_RHEL_6_5" ;;
-                               esac
+                               RHEL_MAJOR=$(awk '/ RHEL_MAJOR / { print [$]3 }' $LINUX_OBJ/include/$VERSION_HDIR/version.h)
+                               I=$(awk '/ RHEL_MINOR / { print [$]3 }' $LINUX_OBJ/include/$VERSION_HDIR/version.h)
+                               while test "$I" -ge 0; do
+                                       EXTRA_OFED_INCLUDE="$EXTRA_OFED_INCLUDE -DCONFIG_COMPAT_RHEL_${RHEL_MAJOR}_$I"
+                                       I=$(($I-1))
+                               done
                        elif test "x$SUSE_KERNEL" = xyes; then
                                SP=$(grep PATCHLEVEL /etc/SuSE-release | sed -e 's/.*= *//')
                                EXTRA_OFED_INCLUDE="$EXTRA_OFED_INCLUDE -DCONFIG_COMPAT_SLES_11_$SP"
                        fi
                fi
+
                AC_MSG_CHECKING([whether to use any OFED backport headers])
                if test -n "$BACKPORT_INCLUDES"; then
                        AC_MSG_RESULT([yes])
@@ -265,15 +168,22 @@ directory which is likely in ${O2IBPATH%-*}
 
                O2IBLND=""
                O2IBPATH=$(readlink --canonicalize $O2IBPATH)
-               EXTRA_OFED_INCLUDE="$EXTRA_OFED_INCLUDE -I$O2IBPATH/include"
+               EXTRA_OFED_INCLUDE="$EXTRA_OFED_INCLUDE -I$O2IBPATH/include -I$O2IBPATH/include/uapi"
+               EXTRA_CHECK_INCLUDE="$EXTRA_OFED_CONFIG $EXTRA_OFED_INCLUDE"
                LB_CHECK_COMPILE([whether to enable OpenIB gen2 support],
                openib_gen2_support, [
-                       #include <linux/version.h>
-                       #include <linux/pci.h>
-                       #include <linux/gfp.h>
                        #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>
+                       #include <linux/pci.h>
+                       #include <linux/gfp.h>
                        #include <rdma/rdma_cm.h>
                        #include <rdma/ib_cm.h>
                        #include <rdma/ib_verbs.h>
@@ -298,41 +208,62 @@ directory which is likely in ${O2IBPATH%-*}
                # we know at this point that the found OFED source is good
                O2IB_SYMVER=""
                if test $ENABLEO2IB = "withpath" -o "x$OFED" = "xyes" ; then
-                       # OFED default rpm not handle sles10 Modules.symvers name
-                       for name in Module.symvers Modules.symvers; do
-                               if test -f $O2IBPATH/$name; then
-                                       O2IB_SYMVER=$name;
-                                       break;
-                               fi
-                       done
+                       if test -f $O2IBPATH/Module.symvers; then
+                               O2IB_SYMVER=$O2IBPATH/Module.symvers;
+                               break;
+                       fi
                        if test -n "$O2IB_SYMVER"; then
-                               AC_MSG_NOTICE([adding $O2IBPATH/$O2IB_SYMVER to $PWD/$SYMVERFILE])
-                               # strip out the existing symbols versions first
-                               if test -f $PWD/$SYMVERFILE; then
-                               egrep -v $(echo $(awk '{ print $2 }' $O2IBPATH/$O2IB_SYMVER) | tr ' ' '|') $PWD/$SYMVERFILE > $PWD/$SYMVERFILE.old
-                               else
-                                       touch $PWD/$SYMVERFILE.old
-                               fi
-                               cat $PWD/$SYMVERFILE.old $O2IBPATH/$O2IB_SYMVER > $PWD/$SYMVERFILE
-                               rm $PWD/$SYMVERFILE.old
+                               AC_MSG_NOTICE([adding $O2IB_SYMVER to Symbol Path])
+                               EXTRA_SYMBOLS="$EXTRA_SYMBOLS $O2IB_SYMVER"
+                               AC_SUBST(EXTRA_SYMBOLS)
                        else
                                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
 
-               LN_CONFIG_OFED_SPEC
+               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 = NULL;
+                       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>
@@ -342,7 +273,259 @@ 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])
+       ])
+
+       # 4.9 must stop using ib_get_dma_mr and the global MR
+       # We then have to use FMR/Fastreg for all RDMA.
+       LB_CHECK_COMPILE([if 'ib_get_dma_mr' exists],
+       ib_get_dma_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_get_dma_mr(NULL, 0);
+       ],[
+               AC_DEFINE(HAVE_IB_GET_DMA_MR, 1,
+                       [ib_get_dma_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 4arg 'ib_map_mr_sg' exists],
+       ib_map_mr_sg_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/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_map_mr_sg changes from 4 to 5 args (adding sg_offset_p)
+       # in kernel 4.7 (and RHEL 7.3)
+       LB_CHECK_COMPILE([if 5arg 'ib_map_mr_sg' exists],
+       ib_map_mr_sg_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/ib_verbs.h>
+       ],[
+               ib_map_mr_sg(NULL, NULL, 0, NULL, 0);
+       ],[
+               AC_DEFINE(HAVE_IB_MAP_MR_SG, 1,
+                       [ib_map_mr_sg exists])
+               AC_DEFINE(HAVE_IB_MAP_MR_SG_5ARGS, 1,
+                       [ib_map_mr_sg has 5 arguments])
+       ])
+
+       # 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])
+       ])
+
+       # A flags argument was added to ib_alloc_pd() in Linux 4.9,
+       # commit ed082d36a7b2c27d1cda55fdfb28af18040c4a89
+       LB_CHECK_COMPILE([if 2arg 'ib_alloc_pd' exists],
+       ib_alloc_pd, [
+               #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_pd(NULL, 0);
+       ],[
+               AC_DEFINE(HAVE_IB_ALLOC_PD_2ARGS, 1,
+                       [ib_alloc_pd has 2 arguments])
+       ])
+
+       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])
+       ])
+
+       # In MOFED 4.6, the second and third parameters for
+       # ib_post_send() and ib_post_recv() are declared with
+       # 'const'.
+       tmp_flags="$EXTRA_KCFLAGS"
+       EXTRA_KCFLAGS="-Werror"
+       LB_CHECK_COMPILE([if 'ib_post_send() and ib_post_recv()' have const parameters],
+       ib_post_send_recv_const, [
+               #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_post_send(NULL, (const struct ib_send_wr *)NULL,
+                            (const struct ib_send_wr **)NULL);
+       ],[
+               AC_DEFINE(HAVE_IB_POST_SEND_RECV_CONST, 1,
+                       [ib_post_send and ib_post_recv have const parameters])
+       ])
+       EXTRA_KCFLAGS="$tmp_flags"
+
+       # 5.0
+       LN_IB_DEVICE_OPS_EXISTS
+       # 5.1
+       LN_IB_SG_DMA_ADDRESS_EXISTS
+
+       EXTRA_CHECK_INCLUDE=""
+       AC_DEFUN([LN_CONFIG_O2IB_SRC], [])
+       AC_DEFUN([LN_CONFIG_O2IB_RESULTS], [])
+]) # ENABLEO2IB != "no"
 ]) # LN_CONFIG_O2IB
 
 #
@@ -398,40 +581,38 @@ AS_IF([test "x$enable_gni" = xyes], [
                return rrc;
        ],[
                GNICPPFLAGS="$GNICPPFLAGS -DGNILND_USE_RCA=1"
-               GNILNDRCA="gnilndrca"
        ])
        EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
 ])
 AC_SUBST(GNICPPFLAGS)
-AC_SUBST(GNILNDRCA)
 AC_SUBST(GNILND)
 ]) # LN_CONFIG_GNILND
 
+# LN_CONFIG_SOCK_CREATE_KERN
 #
-# LN_CONFIG_TCP_SENDPAGE
-#
-# 2.6.36 tcp_sendpage() first parameter is 'struct sock' instead of 'struct socket'.
+# 4.x sock_create_kern() added a first parameter as 'struct net *'
+# instead of int.
 #
-AC_DEFUN([LN_CONFIG_TCP_SENDPAGE], [
+AC_DEFUN([LN_CONFIG_SOCK_CREATE_KERN], [
 tmp_flags="$EXTRA_KCFLAGS"
 EXTRA_KCFLAGS="-Werror"
-LB_CHECK_COMPILE([if 'tcp_sendpage' first parameter is socket],
-tcp_sendpage_socket, [
+LB_CHECK_COMPILE([if 'sock_create_kern' first parameter is net],
+sock_create_kern_net, [
        #include <linux/net.h>
-       #include <net/tcp.h>
+       #include <net/net_namespace.h>
 ],[
-       tcp_sendpage((struct socket*)0, NULL, 0, 0, 0);
+       sock_create_kern((struct net*)0, 0, 0, 0, NULL);
 ],[
-       AC_DEFINE(HAVE_TCP_SENDPAGE_USE_SOCKET, 1,
-               [tcp_sendpage use socket as first parameter])
+       AC_DEFINE(HAVE_SOCK_CREATE_KERN_USE_NET, 1,
+               [sock_create_kern use net as first parameter])
 ])
 EXTRA_KCFLAGS="$tmp_flags"
-]) # LN_CONFIG_TCP_SENDPAGE
+]) # LN_CONFIG_SOCK_CREATE_KERN
 
 #
 # LN_CONFIG_SK_DATA_READY
 #
-# 2.6.36 tcp_sendpage() first parameter is 'struct sock' instead of 'struct socket'.
+# 3.15 for struct sock the *sk_data_ready() field only takes one argument now
 #
 AC_DEFUN([LN_CONFIG_SK_DATA_READY], [
 tmp_flags="$EXTRA_KCFLAGS"
@@ -450,6 +631,178 @@ EXTRA_KCFLAGS="$tmp_flags"
 ]) # LN_CONFIG_SK_DATA_READY
 
 #
+# LN_EXPORT_KMAP_TO_PAGE
+#
+# 3.10 Export kmap_to_page
+#
+AC_DEFUN([LN_EXPORT_KMAP_TO_PAGE], [
+LB_CHECK_EXPORT([kmap_to_page], [mm/highmem.c],
+       [AC_DEFINE(HAVE_KMAP_TO_PAGE, 1,
+               [kmap_to_page is exported by the kernel])])
+]) # LN_EXPORT_KMAP_TO_PAG
+
+#
+# LN_HAVE_HYPERVISOR_IS_TYPE
+#
+# 4.14 commit 79cc74155218316b9a5d28577c7077b2adba8e58
+# x86/paravirt: Provide a way to check for hypervisors
+#
+AC_DEFUN([LN_HAVE_HYPERVISOR_IS_TYPE], [
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_CHECK_COMPILE([if hypervisor_is_type function is available],
+hypervisor_is_type_exists, [
+       #include <asm/hypervisor.h>
+],[
+       (void)hypervisor_is_type(X86_HYPER_NATIVE);
+],[
+       AC_DEFINE(HAVE_HYPERVISOR_IS_TYPE, 1,
+               [hypervisor_is_type function exists])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+]) # LN_HAVE_HYPERVISOR_IS_TYPE
+
+#
+# LN_HAVE_ORACLE_OFED_EXTENSIONS
+#
+# Oracle UEK 5
+#
+AC_DEFUN([LN_HAVE_ORACLE_OFED_EXTENSIONS], [
+LB_CHECK_COMPILE([if Oracle OFED Extensions are enabled],
+oracle_ofed_ext, [
+       #include <rdma/ib_fmr_pool.h>
+],[
+       struct ib_fmr_pool_param param = {
+               .relaxed           = 0
+       };
+       (void)param;
+],[
+       AC_DEFINE(HAVE_ORACLE_OFED_EXTENSIONS, 1,
+               [if Oracle OFED Extensions are enabled])
+])
+]) # LN_HAVE_ORACLE_OFED_EXTENSIONS
+
+#
+# LN_CONFIG_SOCK_GETNAME
+#
+# 4.17 commit 9b2c45d479d0fb8647c9e83359df69162b5fbe5f getname()
+# does not take the length *int argument and returns the length
+#
+AC_DEFUN([LN_CONFIG_SOCK_GETNAME], [
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_CHECK_COMPILE([if 'getname' has two args],
+kern_sock_getname_2args, [
+       #include <linux/net.h>
+],[
+       kernel_getsockname(NULL, NULL);
+],[
+       AC_DEFINE(HAVE_KERN_SOCK_GETNAME_2ARGS, 1,
+               ['getname' has two args])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+]) # LN_CONFIG_SOCK_GETNAME
+
+#
+# LN_HAVE_IN_DEV_FOR_EACH_IFA_RTNL
+#
+# kernel 5.3 commit ef11db3310e272d3d8dbe8739e0770820dd20e52
+# and kernel 4.18.0-193.el8:
+# added in_dev_for_each_ifa_rtnl and in_dev_for_each_ifa_rcu
+# and removed for_ifa and endfor_ifa.
+# Use the _rntl variant as the current locking is rtnl.
+#
+AC_DEFUN([LN_HAVE_IN_DEV_FOR_EACH_IFA_RTNL], [
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_CHECK_COMPILE([if 'in_dev_for_each_ifa_rtnl' is defined],
+in_dev_for_each_ifa_rtnl_test, [
+       #include <linux/inetdevice.h>
+],[
+       const struct in_ifaddr *ifa = NULL;
+       struct in_device *in_dev = NULL;
+
+       in_dev_for_each_ifa_rtnl(ifa, in_dev) {}
+],[
+       AC_DEFINE(HAVE_IN_DEV_FOR_EACH_IFA_RTNL, 1,
+               ['in_dev_for_each_ifa_rtnl' is defined])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+]) # LN_HAVE_IN_DEV_FOR_EACH_IFA_RTNL
+
+#
+# LN_IB_DEVICE_OPS_EXISTS
+#
+# kernel 5.0 commit 521ed0d92ab0db3edd17a5f4716b7f698f4fce61
+# RDMA/core: Introduce ib_device_ops
+# ... introduces the ib_device_ops structure that defines all the
+# InfiniBand device operations in one place ...
+#
+AC_DEFUN([LN_IB_DEVICE_OPS_EXISTS], [
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_CHECK_COMPILE([if struct ib_device_ops is defined],
+ib_device_ops_test, [
+       #include <rdma/ib_verbs.h>
+],[
+       int x = offsetof(struct ib_device_ops, unmap_fmr);
+       x = x;
+       (void)x;
+],[
+       AC_DEFINE(HAVE_IB_DEVICE_OPS, 1,
+               [if struct ib_device_ops is defined])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+]) # LN_IB_DEVICE_OPS_EXISTS
+
+#
+# LN_IB_SG_DMA_ADDRESS_EXISTS
+#
+# kernel 5.1 commit a163afc88556e099271a7b423295bc5176fcecce
+# IB/core: Remove ib_sg_dma_address() and ib_sg_dma_len()
+# ... when dma_ops existed (3.6) ib_sg_dma_address() was not trivial ...
+#
+AC_DEFUN([LN_IB_SG_DMA_ADDRESS_EXISTS], [
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_CHECK_COMPILE([if ib_sg_dma_address wrapper exists],
+ib_sg_dma_address_test, [
+       #include <rdma/ib_verbs.h>
+],[
+       u64 x = ib_sg_dma_address(NULL, NULL);
+       x = x;
+       (void)x;
+],[
+       AC_DEFINE(HAVE_IB_SG_DMA_ADDRESS, 1,
+               [if ib_sg_dma_address wrapper exists])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+]) # LN_IB_SG_DMA_ADDRESS_EXISTS
+
+#
+# LN_USR_RDMA
+#
+#
+AC_DEFUN([LN_USR_RDMA], [
+AC_MSG_CHECKING([if RDMA_PS_TCP exists])
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+       #include <rdma/rdma_user_cm.h>
+
+       int main(void) {
+               int x = (int)RDMA_PS_TCP;
+               return x;
+       }
+])],[
+       AC_DEFINE(HAVE_USRSPC_RDMA_PS_TCP, 1,
+               [RDMA_PS_TCP exists])
+])
+]) # LN_USR_RDMA
+
+
+AC_DEFUN([LN_PROG_LINUX_SRC], [])
+AC_DEFUN([LN_PROG_LINUX_RESULTS], [])
+
+#
 # LN_PROG_LINUX
 #
 # LNet linux kernel checks
@@ -458,15 +811,22 @@ AC_DEFUN([LN_PROG_LINUX], [
 AC_MSG_NOTICE([LNet kernel checks
 ==============================================================================])
 
-LN_FUNC_DEV_GET_BY_NAME_2ARG
-LN_CONFIG_AFFINITY
 LN_CONFIG_BACKOFF
 LN_CONFIG_O2IB
 LN_CONFIG_GNILND
-# 2.6.36
-LN_CONFIG_TCP_SENDPAGE
+# 3.10
+LN_EXPORT_KMAP_TO_PAGE
 # 3.15
 LN_CONFIG_SK_DATA_READY
+# 4.x
+LN_CONFIG_SOCK_CREATE_KERN
+# 4.14
+LN_HAVE_HYPERVISOR_IS_TYPE
+LN_HAVE_ORACLE_OFED_EXTENSIONS
+# 4.17
+LN_CONFIG_SOCK_GETNAME
+# 5.3 and 4.18.0-193.el8
+LN_HAVE_IN_DEV_FOR_EACH_IFA_RTNL
 ]) # LN_PROG_LINUX
 
 #
@@ -487,61 +847,31 @@ AC_MSG_NOTICE([LNet core checks
 ==============================================================================])
 
 # lnet/utils/portals.c
-AC_CHECK_HEADERS([netdb.h netinet/tcp.h asm/types.h endian.h sys/ioctl.h])
-AC_CHECK_FUNCS([gethostbyname socket connect])
-
-# lnet/utils/debug.c
-AC_CHECK_HEADERS([linux/version.h])
+AC_CHECK_HEADERS([netdb.h])
+AC_CHECK_FUNCS([gethostbyname])
 
 # lnet/utils/wirecheck.c
 AC_CHECK_FUNCS([strnlen])
 
 # --------  Check for required packages  --------------
 
-#
-# LC_CONFIG_READLINE
-#
-# Build with readline
-#
-AC_MSG_CHECKING([whether to enable readline support])
-AC_ARG_ENABLE(readline,
-       AC_HELP_STRING([--disable-readline],
-               [disable readline support]),
-       [], [enable_readline="yes"])
-AC_MSG_RESULT([$enable_readline])
-
-# -------- check for readline if enabled ----
-
-LIBREADLINE=""
-AS_IF([test "x$enable_readline" = xyes], [
-       AC_CHECK_LIB([readline], [readline], [
-               LIBREADLINE="-lreadline"
-               AC_DEFINE(HAVE_LIBREADLINE, 1,
-                       [readline library is available])])
-])
-AC_SUBST(LIBREADLINE)
-
-# -------- enable acceptor libwrap (TCP wrappers) support? -------
-
-AC_MSG_CHECKING([if libwrap support is requested])
-AC_ARG_ENABLE([libwrap],
-       AC_HELP_STRING([--enable-libwrap], [use TCP wrappers]),
-       [case "${enableval}" in
-               yes) enable_libwrap="yes" ;;
-               no)  enable_libwrap="no" ;;
-               *) AC_MSG_ERROR(bad value ${enableval} for --enable-libwrap) ;;
-       esac], [enable_libwrap="no"])
-AC_MSG_RESULT([$enable_libwrap])
-LIBWRAP=""
-AS_IF([test "x$enable_libwrap" = xyes], [
-       LIBWRAP="-lwrap"
-       AC_DEFINE(HAVE_LIBWRAP, 1,
-               [libwrap support is requested])
+AC_MSG_CHECKING([whether to enable 'efence' debugging support])
+AC_ARG_ENABLE(efence,
+       AC_HELP_STRING([--enable-efence],
+               [use efence library]),
+       [], [enable_efence="no"])
+AC_MSG_RESULT([$enable_efence])
+
+LIBEFENCE=""
+AS_IF([test "$enable_efence" = yes], [
+       LIBEFENCE="-lefence"
+       AC_DEFINE(HAVE_LIBEFENCE, 1,
+               [libefence support is requested])
 ])
-AC_SUBST(LIBWRAP)
+AC_SUBST(LIBEFENCE)
 
-LN_CONFIG_MAX_PAYLOAD
 LN_CONFIG_DLC
+LN_USR_RDMA
 ]) # LN_CONFIGURE
 
 #
@@ -551,9 +881,7 @@ LN_CONFIG_DLC
 #
 AC_DEFUN([LN_CONDITIONALS], [
 AM_CONDITIONAL(BUILD_O2IBLND,    test x$O2IBLND = "xo2iblnd")
-AM_CONDITIONAL(BUILD_GNILND,     test x$GNILND = "xgnilnd")
-AM_CONDITIONAL(BUILD_GNILND_RCA, test x$GNILNDRCA = "xgnilndrca")
-AM_CONDITIONAL(BUILD_DLC,        test x$USE_DLC = "xyes")
+AM_CONDITIONAL(BUILD_GNILND,     test x$GNILND  = "xgnilnd")
 ]) # LN_CONDITIONALS
 
 #
@@ -569,6 +897,7 @@ lnet/autoconf/Makefile
 lnet/doc/Makefile
 lnet/include/Makefile
 lnet/include/lnet/Makefile
+lnet/include/uapi/linux/lnet/Makefile
 lnet/klnds/Makefile
 lnet/klnds/autoMakefile
 lnet/klnds/o2iblnd/Makefile