+
+ # 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=""
+]) # ENABLEO2IB != "no"