+
+ # 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
+
+#
+# LN_CONFIG_GNILND
+#
+# check whether to use the Gemini Network Interface lnd
+#
+AC_DEFUN([LN_CONFIG_GNILND], [
+AC_MSG_CHECKING([whether to enable GNI lnd])
+AC_ARG_ENABLE([gni],
+ AC_HELP_STRING([--enable-gni],
+ [enable GNI lnd]),
+ [], [enable_gni="no"])
+AC_MSG_RESULT([$enable_gni])
+
+AS_IF([test "x$enable_gni" = xyes], [
+ # GNICPPFLAGS was set in spec file
+ EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
+ EXTRA_KCFLAGS="$EXTRA_KCFLAGS $GNICPPFLAGS"
+ LB_CHECK_COMPILE([if GNI kernel headers are present],
+ GNI_header, [
+ #include <linux/types.h>
+ #include <gni_pub.h>
+ ],[
+ gni_cdm_handle_t kgni_domain;
+ gni_return_t rc;
+ int rrc;
+ rc = gni_cdm_create(0, 1, 1, 0, &kgni_domain);
+ rrc = (rc == GNI_RC_SUCCESS) ? 0 : 1;
+ return rrc;
+ ],[
+ GNILND="gnilnd"
+ ],[
+ AC_MSG_ERROR([can't compile gnilnd with given GNICPPFLAGS: $GNICPPFLAGS])
+ ])
+ # at this point, we have gnilnd basic support,
+ # now check for extra features
+ LB_CHECK_COMPILE([to use RCA in gnilnd],
+ RCA_gnilnd, [
+ #include <linux/types.h>
+ #include <gni_pub.h>
+ #include <krca_lib.h>
+ ],[
+ gni_cdm_handle_t kgni_domain;
+ gni_return_t rc;
+ krca_ticket_t ticket = KRCA_NULL_TICKET;
+ int rrc;
+ __u32 nid = 0, nic_addr;
+ rc = gni_cdm_create(0, 1, 1, 0, &kgni_domain);
+ rrc = (rc == GNI_RC_SUCCESS) ? 0 : 1;
+ rrc += krca_nid_to_nicaddrs(nid, 1, &nic_addr);
+ rrc += krca_register(&ticket, RCA_MAKE_SERVICE_INDEX(RCA_IO_CLASS, 9), 99, 0);
+ return rrc;
+ ],[
+ GNICPPFLAGS="$GNICPPFLAGS -DGNILND_USE_RCA=1"
+ ])
+ EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"