4 # Check compiler version
6 AC_DEFUN([LN_CHECK_GCC_VERSION], [
7 AC_MSG_CHECKING([compiler version])
8 PTL_CC_VERSION=`$CC --version | awk '/^gcc/{print $ 3}'`
9 PTL_MIN_CC_VERSION="3.2.2"
11 awk -F. '{printf "%d\n", (($ 1)*100+($ 2))*100+($ 3)}'
13 if test -z "$PTL_CC_VERSION" -o \
14 $(echo $PTL_CC_VERSION | v2n) -ge $(echo $PTL_MIN_CC_VERSION | v2n); then
17 AC_MSG_RESULT([Buggy compiler found])
18 AC_MSG_ERROR([Need gcc version >= $PTL_MIN_CC_VERSION])
20 ]) # LN_CHECK_GCC_VERSION
25 # check if cpu affinity is available/wanted
27 AC_DEFUN([LN_CONFIG_AFFINITY], [
28 AC_MSG_CHECKING([whether to enable CPU affinity support])
29 AC_ARG_ENABLE([affinity],
30 AC_HELP_STRING([--disable-affinity],
31 [disable process/irq affinity]),
32 [], [enable_affinity="yes"])
33 AC_MSG_RESULT([$enable_affinity])
34 AS_IF([test "x$enable_affinity" = xyes], [
35 LB_CHECK_COMPILE([if Linux kernel has cpu affinity support],
36 set_cpus_allowed_ptr, [
37 #include <linux/sched.h>
39 struct task_struct *t = NULL;
42 set_cpus_allowed_ptr(t, &m);
44 AC_DEFINE(CPU_AFFINITY, 1,
45 [kernel has cpu affinity support])
48 ]) # LN_CONFIG_AFFINITY
53 # check if tunable tcp backoff is available/wanted
55 AC_DEFUN([LN_CONFIG_BACKOFF], [
56 AC_MSG_CHECKING([whether to enable tunable backoff TCP support])
57 AC_ARG_ENABLE([backoff],
58 AC_HELP_STRING([--disable-backoff],
59 [disable socknal tunable backoff]),
60 [], [enable_backoff="yes"])
61 AC_MSG_RESULT([$enable_backoff])
62 AS_IF([test "x$enable_backoff" = xyes], [
63 AC_MSG_CHECKING([if Linux kernel has tunable backoff TCP support])
64 AS_IF([grep -c TCP_BACKOFF $LINUX/include/linux/tcp.h >/dev/null], [
66 AC_DEFINE(SOCKNAL_BACKOFF, 1, [use tunable backoff TCP])
67 AS_IF([grep rto_max $LINUX/include/linux/tcp.h | grep -q __u16 >/dev/null],
68 [AC_DEFINE(SOCKNAL_BACKOFF_MS, 1,
69 [tunable backoff TCP in ms])])
74 ]) # LN_CONFIG_BACKOFF
81 # fail to build if libyaml is not installed
83 AC_DEFUN([LN_CONFIG_DLC], [
84 AS_IF([test "x$enable_dist" = xno], [
85 AC_CHECK_LIB([yaml], [yaml_parser_initialize],
87 [AC_MSG_ERROR([YAML development libraries not not installed])],
95 # If current OFED installed (assume with "ofed_info") and devel
96 # headers are not found, error because we assume OFED infiniband
97 # driver needs to be used and we must configure/build with it.
98 # Current OFED headers detection mechanism allow for non-standard
99 # prefix but relies on "ofed_info" command and on "%prefix/openib"
100 # link (both are ok for 1.5.x and 3.x versions), and should work
101 # for both source and DKMS builds.
103 AC_DEFUN([LN_CONFIG_O2IB], [
104 AC_MSG_CHECKING([whether to use Compat RDMA])
106 AC_HELP_STRING([--with-o2ib=[yes|no|<path>]],
107 [build o2iblnd against path]),
108 [], [with_o2ib="yes"])
111 yes) AS_IF([which ofed_info 2>/dev/null], [
112 AS_IF([test x$uses_dpkg = xyes], [
113 OFED_INFO="ofed_info | awk '{print \[$]2}'"
114 LSPKG="dpkg --listfiles"
116 OFED_INFO="ofed_info"
119 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)
120 AS_IF([test -z "$O2IBPATHS"], [
122 You seem to have an OFED installed but have not installed it's devel package.
123 If you still want to build Lustre for your OFED I/B stack, you need to install its devel headers RPM.
124 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.
127 AS_IF([test $(echo $O2IBPATHS | wc -w) -ge 2], [
129 It appears that you have multiple OFED versions installed.
130 If you still want to build Lustre for your OFED I/B stack, you need to install a single version with its devel headers RPM.
131 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.
134 if test -e $O2IBPATHS/${LINUXRELEASE}; then
135 O2IBPATHS=$O2IBPATHS/${LINUXRELEASE}
136 elif test -e $O2IBPATHS/default; then
137 O2IBPATHS=$O2IBPATHS/default
141 O2IBPATHS="$LINUX $LINUX/drivers/infiniband"
147 *) O2IBPATHS=$with_o2ib
148 ENABLEO2IB="withpath"
153 AS_IF([test $ENABLEO2IB = "no"], [
157 for O2IBPATH in $O2IBPATHS; do
158 AS_IF([test \( -f ${O2IBPATH}/include/rdma/rdma_cm.h -a \
159 -f ${O2IBPATH}/include/rdma/ib_cm.h -a \
160 -f ${O2IBPATH}/include/rdma/ib_verbs.h \)], [
165 if ! $o2ib_found; then
168 "yes") AC_MSG_ERROR([no OFED nor kernel OpenIB gen2 headers present]) ;;
169 "withpath") AC_MSG_ERROR([bad --with-o2ib path]) ;;
170 *) AC_MSG_ERROR([internal error]) ;;
174 compatrdma_found=false
175 if test -f ${O2IBPATH}/include/linux/compat-2.6.h; then
177 compatrdma_found=true
178 AC_DEFINE(HAVE_COMPAT_RDMA, 1, [compat rdma found])
179 EXTRA_OFED_CONFIG="$EXTRA_OFED_CONFIG -include ${O2IBPATH}/include/linux/compat-2.6.h"
180 if test -f "$O2IBPATH/include/linux/compat_autoconf.h"; then
181 COMPAT_AUTOCONF="$O2IBPATH/include/linux/compat_autoconf.h"
186 if ! $compatrdma_found; then
187 if test -f "$O2IBPATH/config.mk"; then
188 . "$O2IBPATH/config.mk"
189 elif test -f "$O2IBPATH/ofed_patch.mk"; then
190 . "$O2IBPATH/ofed_patch.mk"
192 elif test -z "$COMPAT_AUTOCONF"; then
194 if test "x$RHEL_KERNEL" = xyes; then
195 RHEL_MAJOR=$(awk '/ RHEL_MAJOR / { print [$]3 }' $LINUX_OBJ/include/$VERSION_HDIR/version.h)
196 I=$(awk '/ RHEL_MINOR / { print [$]3 }' $LINUX_OBJ/include/$VERSION_HDIR/version.h)
197 while test "$I" -ge 0; do
198 EXTRA_OFED_INCLUDE="$EXTRA_OFED_INCLUDE -DCONFIG_COMPAT_RHEL_${RHEL_MAJOR}_$I"
201 elif test "x$SUSE_KERNEL" = xyes; then
202 SP=$(grep PATCHLEVEL /etc/SuSE-release | sed -e 's/.*= *//')
203 EXTRA_OFED_INCLUDE="$EXTRA_OFED_INCLUDE -DCONFIG_COMPAT_SLES_11_$SP"
207 AC_MSG_CHECKING([whether to use any OFED backport headers])
208 if test -n "$BACKPORT_INCLUDES"; then
210 OFED_BACKPORT_PATH="$O2IBPATH/${BACKPORT_INCLUDES/*\/kernel_addons/kernel_addons}/"
211 EXTRA_OFED_INCLUDE="-I$OFED_BACKPORT_PATH $EXTRA_OFED_INCLUDE"
217 O2IBPATH=$(readlink --canonicalize $O2IBPATH)
218 EXTRA_OFED_INCLUDE="$EXTRA_OFED_INCLUDE -I$O2IBPATH/include -I$O2IBPATH/include/uapi"
219 EXTRA_CHECK_INCLUDE="$EXTRA_OFED_CONFIG $EXTRA_OFED_INCLUDE"
220 LB_CHECK_COMPILE([whether to enable OpenIB gen2 support],
221 openib_gen2_support, [
222 #ifdef HAVE_COMPAT_RDMA
224 #undef PACKAGE_TARNAME
225 #undef PACKAGE_VERSION
226 #undef PACKAGE_STRING
227 #undef PACKAGE_BUGREPORT
229 #include <linux/compat-2.6.h>
231 #include <linux/version.h>
232 #include <linux/pci.h>
233 #include <linux/gfp.h>
234 #include <rdma/rdma_cm.h>
235 #include <rdma/ib_cm.h>
236 #include <rdma/ib_verbs.h>
238 struct rdma_cm_id *cm_idi __attribute__ ((unused));
239 struct rdma_conn_param conn_param __attribute__ ((unused));
240 struct ib_device_attr device_attr __attribute__ ((unused));
241 struct ib_qp_attr qp_attr __attribute__ ((unused));
242 enum ib_cm_rej_reason rej_reason __attribute__ ((unused));
243 rdma_destroy_id(NULL);
248 "yes") AC_MSG_ERROR([can't compile with OpenIB gen2 headers]) ;;
249 "withpath") AC_MSG_ERROR([can't compile with OpenIB gen2 headers under $O2IBPATH]) ;;
250 *) AC_MSG_ERROR([internal error]) ;;
253 # we know at this point that the found OFED source is good
255 if test $ENABLEO2IB = "withpath" -o "x$OFED" = "xyes" ; then
256 if test -f $O2IBPATH/Module.symvers; then
257 O2IB_SYMVER=$O2IBPATH/Module.symvers;
260 if test -n "$O2IB_SYMVER"; then
261 AC_MSG_NOTICE([adding $O2IB_SYMVER to Symbol Path])
262 EXTRA_SYMBOLS="$EXTRA_SYMBOLS $O2IB_SYMVER"
263 AC_SUBST(EXTRA_SYMBOLS)
265 AC_MSG_ERROR([an external source tree was, either specified or detected, for o2iblnd however I could not find a $O2IBPATH/Module.symvers there])
269 LB_CHECK_COMPILE([if Linux kernel has kthread_worker],
270 linux_kthread_worker, [
271 #ifdef HAVE_COMPAT_RDMA
273 #undef PACKAGE_TARNAME
274 #undef PACKAGE_VERSION
275 #undef PACKAGE_STRING
276 #undef PACKAGE_BUGREPORT
278 #include <linux/compat-2.6.h>
280 #include <linux/kthread.h>
282 struct kthread_work *kth_wrk = NULL;
283 flush_kthread_work(kth_wrk);
285 AC_DEFINE(HAVE_KTHREAD_WORK, 1, [kthread_worker found])
286 if test -z "$COMPAT_AUTOCONF"; then
287 EXTRA_OFED_INCLUDE="$EXTRA_OFED_INCLUDE -DCONFIG_COMPAT_IS_KTHREAD"
290 EXTRA_CHECK_INCLUDE=""
293 AC_SUBST(EXTRA_OFED_CONFIG)
294 AC_SUBST(EXTRA_OFED_INCLUDE)
299 AS_IF([test $ENABLEO2IB != "no"], [
300 EXTRA_CHECK_INCLUDE="$EXTRA_OFED_CONFIG $EXTRA_OFED_INCLUDE"
302 # In RHEL 6.2, rdma_create_id() takes the queue-pair type as a fourth argument
303 LB_CHECK_COMPILE([if 'rdma_create_id' wants four args],
304 rdma_create_id_4args, [
305 #ifdef HAVE_COMPAT_RDMA
307 #undef PACKAGE_TARNAME
308 #undef PACKAGE_VERSION
309 #undef PACKAGE_STRING
310 #undef PACKAGE_BUGREPORT
312 #include <linux/compat-2.6.h>
314 #include <rdma/rdma_cm.h>
316 rdma_create_id(NULL, NULL, 0, 0);
318 AC_DEFINE(HAVE_RDMA_CREATE_ID_4ARG, 1,
319 [rdma_create_id wants 4 args])
322 # 4.4 added network namespace parameter for rdma_create_id()
323 LB_CHECK_COMPILE([if 'rdma_create_id' wants five args],
324 rdma_create_id_5args, [
325 #ifdef HAVE_COMPAT_RDMA
327 #undef PACKAGE_TARNAME
328 #undef PACKAGE_VERSION
329 #undef PACKAGE_STRING
330 #undef PACKAGE_BUGREPORT
332 #include <linux/compat-2.6.h>
334 #include <rdma/rdma_cm.h>
336 rdma_create_id(NULL, NULL, NULL, 0, 0);
338 AC_DEFINE(HAVE_RDMA_CREATE_ID_5ARG, 1,
339 [rdma_create_id wants 5 args])
342 # 4.2 introduced struct ib_cq_init_attr which is used
343 # by ib_create_cq(). Note some OFED stacks only keep
344 # their headers in sync with latest kernels but not
345 # the functionality which means for infiniband testing
346 # we need to always test functionality testings.
347 LB_CHECK_COMPILE([if 'struct ib_cq_init_attr' is used],
349 #ifdef HAVE_COMPAT_RDMA
351 #undef PACKAGE_TARNAME
352 #undef PACKAGE_VERSION
353 #undef PACKAGE_STRING
354 #undef PACKAGE_BUGREPORT
356 #include <linux/compat-2.6.h>
358 #include <rdma/ib_verbs.h>
360 struct ib_cq_init_attr cq_attr;
362 ib_create_cq(NULL, NULL, NULL, NULL, &cq_attr);
364 AC_DEFINE(HAVE_IB_CQ_INIT_ATTR, 1,
365 [struct ib_cq_init_attr is used by ib_create_cq])
368 # 4.3 removed ib_alloc_fast_reg_mr()
369 LB_CHECK_COMPILE([if 'ib_alloc_fast_reg_mr' exists],
370 ib_alloc_fast_reg_mr, [
371 #ifdef HAVE_COMPAT_RDMA
373 #undef PACKAGE_TARNAME
374 #undef PACKAGE_VERSION
375 #undef PACKAGE_STRING
376 #undef PACKAGE_BUGREPORT
378 #include <linux/compat-2.6.h>
380 #include <rdma/ib_verbs.h>
382 ib_alloc_fast_reg_mr(NULL, 0);
384 AC_DEFINE(HAVE_IB_ALLOC_FAST_REG_MR, 1,
385 [ib_alloc_fast_reg_mr is defined])
388 # 4.9 must stop using ib_get_dma_mr and the global MR
389 # We then have to use FMR/Fastreg for all RDMA.
390 LB_CHECK_COMPILE([if 'ib_get_dma_mr' exists],
392 #ifdef HAVE_COMPAT_RDMA
394 #undef PACKAGE_TARNAME
395 #undef PACKAGE_VERSION
396 #undef PACKAGE_STRING
397 #undef PACKAGE_BUGREPORT
399 #include <linux/compat-2.6.h>
401 #include <rdma/ib_verbs.h>
403 ib_get_dma_mr(NULL, 0);
405 AC_DEFINE(HAVE_IB_GET_DMA_MR, 1,
406 [ib_get_dma_mr is defined])
409 # In v4.4 Linux kernel,
410 # commit e622f2f4ad2142d2a613a57fb85f8cf737935ef5
411 # split up struct ib_send_wr so that all non-trivial verbs
412 # use their own structure which embedds struct ib_send_wr.
413 LB_CHECK_COMPILE([if 'struct ib_rdma_wr' is defined],
415 #ifdef HAVE_COMPAT_RDMA
417 #undef PACKAGE_TARNAME
418 #undef PACKAGE_VERSION
419 #undef PACKAGE_STRING
420 #undef PACKAGE_BUGREPORT
422 #include <linux/compat-2.6.h>
424 #include <rdma/ib_verbs.h>
426 struct ib_rdma_wr *wr __attribute__ ((unused));
430 AC_DEFINE(HAVE_IB_RDMA_WR, 1,
431 [struct ib_rdma_wr is defined])
434 # new fast registration API introduced in 4.4
435 LB_CHECK_COMPILE([if 4arg 'ib_map_mr_sg' exists],
436 ib_map_mr_sg_4args, [
437 #ifdef HAVE_COMPAT_RDMA
439 #undef PACKAGE_TARNAME
440 #undef PACKAGE_VERSION
441 #undef PACKAGE_STRING
442 #undef PACKAGE_BUGREPORT
444 #include <linux/compat-2.6.h>
446 #include <rdma/ib_verbs.h>
448 ib_map_mr_sg(NULL, NULL, 0, 0);
450 AC_DEFINE(HAVE_IB_MAP_MR_SG, 1,
451 [ib_map_mr_sg exists])
454 # ib_map_mr_sg changes from 4 to 5 args (adding sg_offset_p)
455 # in kernel 4.7 (and RHEL 7.3)
456 LB_CHECK_COMPILE([if 5arg 'ib_map_mr_sg' exists],
457 ib_map_mr_sg_5args, [
458 #ifdef HAVE_COMPAT_RDMA
460 #undef PACKAGE_TARNAME
461 #undef PACKAGE_VERSION
462 #undef PACKAGE_STRING
463 #undef PACKAGE_BUGREPORT
465 #include <linux/compat-2.6.h>
467 #include <rdma/ib_verbs.h>
469 ib_map_mr_sg(NULL, NULL, 0, NULL, 0);
471 AC_DEFINE(HAVE_IB_MAP_MR_SG, 1,
472 [ib_map_mr_sg exists])
473 AC_DEFINE(HAVE_IB_MAP_MR_SG_5ARGS, 1,
474 [ib_map_mr_sg has 5 arguments])
477 # ib_query_device() removed in 4.5
478 LB_CHECK_COMPILE([if 'struct ib_device' has member 'attrs'],
480 #ifdef HAVE_COMPAT_RDMA
482 #undef PACKAGE_TARNAME
483 #undef PACKAGE_VERSION
484 #undef PACKAGE_STRING
485 #undef PACKAGE_BUGREPORT
487 #include <linux/compat-2.6.h>
489 #include <rdma/ib_verbs.h>
491 struct ib_device dev;
492 struct ib_device_attr dev_attr = {};
493 dev.attrs = dev_attr;
495 AC_DEFINE(HAVE_IB_DEVICE_ATTRS, 1,
496 [struct ib_device.attrs is defined])
499 # A flags argument was added to ib_alloc_pd() in Linux 4.9,
500 # commit ed082d36a7b2c27d1cda55fdfb28af18040c4a89
501 LB_CHECK_COMPILE([if 2arg 'ib_alloc_pd' exists],
503 #ifdef HAVE_COMPAT_RDMA
505 #undef PACKAGE_TARNAME
506 #undef PACKAGE_VERSION
507 #undef PACKAGE_STRING
508 #undef PACKAGE_BUGREPORT
510 #include <linux/compat-2.6.h>
512 #include <rdma/ib_verbs.h>
514 ib_alloc_pd(NULL, 0);
516 AC_DEFINE(HAVE_IB_ALLOC_PD_2ARGS, 1,
517 [ib_alloc_pd has 2 arguments])
520 LB_CHECK_COMPILE([if function 'ib_inc_rkey' is defined],
522 #ifdef HAVE_COMPAT_RDMA
524 #undef PACKAGE_TARNAME
525 #undef PACKAGE_VERSION
526 #undef PACKAGE_STRING
527 #undef PACKAGE_BUGREPORT
529 #include <linux/compat-2.6.h>
531 #include <rdma/ib_verbs.h>
533 (void)ib_inc_rkey(0);
535 AC_DEFINE(HAVE_IB_INC_RKEY, 1,
536 [function ib_inc_rkey exist])
539 # In MOFED 4.6, the second and third parameters for
540 # ib_post_send() and ib_post_recv() are declared with
542 tmp_flags="$EXTRA_KCFLAGS"
543 EXTRA_KCFLAGS="-Werror"
544 LB_CHECK_COMPILE([if 'ib_post_send() and ib_post_recv()' have const parameters],
545 ib_post_send_recv_const, [
546 #ifdef HAVE_COMPAT_RDMA
548 #undef PACKAGE_TARNAME
549 #undef PACKAGE_VERSION
550 #undef PACKAGE_STRING
551 #undef PACKAGE_BUGREPORT
553 #include <linux/compat-2.6.h>
555 #include <rdma/ib_verbs.h>
557 ib_post_send(NULL, (const struct ib_send_wr *)NULL,
558 (const struct ib_send_wr **)NULL);
560 AC_DEFINE(HAVE_IB_POST_SEND_RECV_CONST, 1,
561 [ib_post_send and ib_post_recv have const parameters])
563 EXTRA_KCFLAGS="$tmp_flags"
566 LN_IB_DEVICE_OPS_EXISTS
568 LN_IB_SG_DMA_ADDRESS_EXISTS
570 # A reason argument was added to rdma_reject() in Linux 5.8,
571 # commit 8094ba0ace7f6cd1e31ea8b151fba3594cadfa9a
572 LB_CHECK_COMPILE([if 4arg 'rdma_reject' exists],
574 #ifdef HAVE_COMPAT_RDMA
576 #undef PACKAGE_TARNAME
577 #undef PACKAGE_VERSION
578 #undef PACKAGE_STRING
579 #undef PACKAGE_BUGREPORT
581 #include <linux/compat-2.6.h>
583 #include <rdma/ib_verbs.h>
584 #include <rdma/ib_cm.h>
585 #include <rdma/rdma_cm.h>
587 rdma_reject(NULL, NULL, 0, 0);
589 AC_DEFINE(HAVE_RDMA_REJECT_4ARGS, 1,
590 [rdma_reject has 4 arguments])
593 # The FMR pool API was removed in Linux 5.8,
594 # commit 4e373d5417ecbb4f438a8500f0379a2fc29c2643
595 LB_CHECK_COMPILE([if FMR pools API available],
597 #include <rdma/ib_verbs.h>
599 struct ib_fmr fmr = {};
601 AC_DEFINE(HAVE_FMR_POOL_API, 1,
602 [FMR pool API is available])
605 EXTRA_CHECK_INCLUDE=""
606 ]) # ENABLEO2IB != "no"
612 # check whether to use the Gemini Network Interface lnd
614 AC_DEFUN([LN_CONFIG_GNILND], [
615 AC_MSG_CHECKING([whether to enable GNI lnd])
617 AC_HELP_STRING([--enable-gni],
619 [], [enable_gni="no"])
620 AC_MSG_RESULT([$enable_gni])
622 AS_IF([test "x$enable_gni" = xyes], [
623 # GNICPPFLAGS was set in spec file
624 EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
625 EXTRA_KCFLAGS="$EXTRA_KCFLAGS $GNICPPFLAGS"
626 LB_CHECK_COMPILE([if GNI kernel headers are present],
628 #include <linux/types.h>
631 gni_cdm_handle_t kgni_domain;
634 rc = gni_cdm_create(0, 1, 1, 0, &kgni_domain);
635 rrc = (rc == GNI_RC_SUCCESS) ? 0 : 1;
640 AC_MSG_ERROR([can't compile gnilnd with given GNICPPFLAGS: $GNICPPFLAGS])
642 # at this point, we have gnilnd basic support,
643 # now check for extra features
644 LB_CHECK_COMPILE([to use RCA in gnilnd],
646 #include <linux/types.h>
648 #include <krca_lib.h>
650 gni_cdm_handle_t kgni_domain;
652 krca_ticket_t ticket = KRCA_NULL_TICKET;
654 __u32 nid = 0, nic_addr;
655 rc = gni_cdm_create(0, 1, 1, 0, &kgni_domain);
656 rrc = (rc == GNI_RC_SUCCESS) ? 0 : 1;
657 rrc += krca_nid_to_nicaddrs(nid, 1, &nic_addr);
658 rrc += krca_register(&ticket, RCA_MAKE_SERVICE_INDEX(RCA_IO_CLASS, 9), 99, 0);
661 GNICPPFLAGS="$GNICPPFLAGS -DGNILND_USE_RCA=1"
663 EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
665 AC_SUBST(GNICPPFLAGS)
667 ]) # LN_CONFIG_GNILND
672 # 2.6.35 kernel has sk_sleep function
674 AC_DEFUN([LN_CONFIG_SK_SLEEP], [
675 LB_CHECK_COMPILE([if Linux kernel has 'sk_sleep'],
677 #include <net/sock.h>
681 AC_DEFINE(HAVE_SK_SLEEP, 1,
682 [kernel has sk_sleep])
684 ]) # LN_CONFIG_SK_SLEEP
687 # LN_CONFIG_TCP_SENDPAGE
689 # 2.6.36 tcp_sendpage() first parameter is 'struct sock'
690 # instead of 'struct socket'.
692 AC_DEFUN([LN_CONFIG_TCP_SENDPAGE], [
693 tmp_flags="$EXTRA_KCFLAGS"
694 EXTRA_KCFLAGS="-Werror"
695 LB_CHECK_COMPILE([if 'tcp_sendpage' first parameter is socket],
696 tcp_sendpage_socket, [
697 #include <linux/net.h>
700 tcp_sendpage((struct socket*)0, NULL, 0, 0, 0);
702 AC_DEFINE(HAVE_TCP_SENDPAGE_USE_SOCKET, 1,
703 [tcp_sendpage use socket as first parameter])
705 EXTRA_KCFLAGS="$tmp_flags"
706 ]) # LN_CONFIG_TCP_SENDPAGE
708 # LN_CONFIG_SOCK_CREATE_KERN
710 # 4.x sock_create_kern() added a first parameter as 'struct net *'
713 AC_DEFUN([LN_CONFIG_SOCK_CREATE_KERN], [
714 tmp_flags="$EXTRA_KCFLAGS"
715 EXTRA_KCFLAGS="-Werror"
716 LB_CHECK_COMPILE([if 'sock_create_kern' first parameter is net],
717 sock_create_kern_net, [
718 #include <linux/net.h>
719 #include <net/net_namespace.h>
721 sock_create_kern((struct net*)0, 0, 0, 0, NULL);
723 AC_DEFINE(HAVE_SOCK_CREATE_KERN_USE_NET, 1,
724 [sock_create_kern use net as first parameter])
726 EXTRA_KCFLAGS="$tmp_flags"
727 ]) # LN_CONFIG_SOCK_CREATE_KERN
730 # LN_CONFIG_SK_DATA_READY
732 # 3.15 for struct sock the *sk_data_ready() field only takes one argument now
734 AC_DEFUN([LN_CONFIG_SK_DATA_READY], [
735 tmp_flags="$EXTRA_KCFLAGS"
736 EXTRA_KCFLAGS="-Werror"
737 LB_CHECK_COMPILE([if 'sk_data_ready' takes only one argument],
739 #include <linux/net.h>
740 #include <net/sock.h>
742 ((struct sock *)0)->sk_data_ready(NULL);
744 AC_DEFINE(HAVE_SK_DATA_READY_ONE_ARG, 1,
745 [sk_data_ready uses only one argument])
747 EXTRA_KCFLAGS="$tmp_flags"
748 ]) # LN_CONFIG_SK_DATA_READY
751 # LN_EXPORT_KMAP_TO_PAGE
753 # 3.10 Export kmap_to_page
755 AC_DEFUN([LN_EXPORT_KMAP_TO_PAGE], [
756 LB_CHECK_EXPORT([kmap_to_page], [mm/highmem.c],
757 [AC_DEFINE(HAVE_KMAP_TO_PAGE, 1,
758 [kmap_to_page is exported by the kernel])])
759 ]) # LN_EXPORT_KMAP_TO_PAG
762 # LN_CONFIG_SOCK_ACCEPT
764 # 4.11 commit cdfbabfb2f0ce983fdaa42f20e5f7842178fc01e added a flag
765 # to handle a possible lockdep condition kernel socket accept.
767 AC_DEFUN([LN_CONFIG_SOCK_ACCEPT], [
768 tmp_flags="$EXTRA_KCFLAGS"
769 EXTRA_KCFLAGS="-Werror"
770 LB_CHECK_COMPILE([if 'struct sock' accept function requires a bool argument],
772 #include <linux/net.h>
774 ((struct socket *)0)->ops->accept(NULL, NULL, O_NONBLOCK, false);
776 AC_DEFINE(HAVE_KERN_SOCK_ACCEPT_FLAG_ARG, 1,
777 ['struct sock' accept function requires bool argument])
779 EXTRA_KCFLAGS="$tmp_flags"
780 ]) # LN_CONFIG_SOCK_ACCEPT
783 # LN_CONFIG_SOCK_GETNAME
785 # 4.17 commit 9b2c45d479d0fb8647c9e83359df69162b5fbe5f getname()
786 # does not take the length *int argument and returns the length
788 AC_DEFUN([LN_CONFIG_SOCK_GETNAME], [
789 tmp_flags="$EXTRA_KCFLAGS"
790 EXTRA_KCFLAGS="-Werror"
791 LB_CHECK_COMPILE([if 'getname' has two args],
792 kern_sock_getname_2args, [
793 #include <linux/net.h>
795 kernel_getsockname(NULL, NULL);
797 AC_DEFINE(HAVE_KERN_SOCK_GETNAME_2ARGS, 1,
798 ['getname' has two args])
800 EXTRA_KCFLAGS="$tmp_flags"
801 ]) # LN_CONFIG_SOCK_GETNAME
804 # LN_HAVE_IN_DEV_FOR_EACH_IFA_RTNL
806 # kernel 5.3 commit ef11db3310e272d3d8dbe8739e0770820dd20e52
807 # and kernel 4.18.0-193.el8:
808 # added in_dev_for_each_ifa_rtnl and in_dev_for_each_ifa_rcu
809 # and removed for_ifa and endfor_ifa.
810 # Use the _rntl variant as the current locking is rtnl.
812 AC_DEFUN([LN_HAVE_IN_DEV_FOR_EACH_IFA_RTNL], [
813 tmp_flags="$EXTRA_KCFLAGS"
814 EXTRA_KCFLAGS="-Werror"
815 LB_CHECK_COMPILE([if 'in_dev_for_each_ifa_rtnl' is defined],
816 in_dev_for_each_ifa_rtnl_test, [
817 #include <linux/inetdevice.h>
819 const struct in_ifaddr *ifa = NULL;
820 struct in_device *in_dev = NULL;
822 in_dev_for_each_ifa_rtnl(ifa, in_dev) {}
824 AC_DEFINE(HAVE_IN_DEV_FOR_EACH_IFA_RTNL, 1,
825 ['in_dev_for_each_ifa_rtnl' is defined])
827 EXTRA_KCFLAGS="$tmp_flags"
828 ]) # LN_HAVE_IN_DEV_FOR_EACH_IFA_RTNL
831 # LN_IB_DEVICE_OPS_EXISTS
833 # kernel 5.0 commit 521ed0d92ab0db3edd17a5f4716b7f698f4fce61
834 # RDMA/core: Introduce ib_device_ops
835 # ... introduces the ib_device_ops structure that defines all the
836 # InfiniBand device operations in one place ...
838 AC_DEFUN([LN_IB_DEVICE_OPS_EXISTS], [
839 tmp_flags="$EXTRA_KCFLAGS"
840 EXTRA_KCFLAGS="-Werror"
841 LB_CHECK_COMPILE([if struct ib_device_ops is defined],
842 ib_device_ops_test, [
843 #include <rdma/ib_verbs.h>
845 int x = offsetof(struct ib_device_ops, unmap_fmr);
849 AC_DEFINE(HAVE_IB_DEVICE_OPS, 1,
850 [if struct ib_device_ops is defined])
852 EXTRA_KCFLAGS="$tmp_flags"
853 ]) # LN_IB_DEVICE_OPS_EXISTS
856 # LN_IB_SG_DMA_ADDRESS_EXISTS
858 # kernel 5.1 commit a163afc88556e099271a7b423295bc5176fcecce
859 # IB/core: Remove ib_sg_dma_address() and ib_sg_dma_len()
860 # ... when dma_ops existed (3.6) ib_sg_dma_address() was not trivial ...
862 AC_DEFUN([LN_IB_SG_DMA_ADDRESS_EXISTS], [
863 tmp_flags="$EXTRA_KCFLAGS"
864 EXTRA_KCFLAGS="-Werror"
865 LB_CHECK_COMPILE([if ib_sg_dma_address wrapper exists],
866 ib_sg_dma_address_test, [
867 #include <rdma/ib_verbs.h>
869 u64 x = ib_sg_dma_address(NULL, NULL);
873 AC_DEFINE(HAVE_IB_SG_DMA_ADDRESS, 1,
874 [if ib_sg_dma_address wrapper exists])
876 EXTRA_KCFLAGS="$tmp_flags"
877 ]) # LN_IB_SG_DMA_ADDRESS_EXISTS
882 # LNet linux kernel checks
884 AC_DEFUN([LN_PROG_LINUX], [
885 AC_MSG_NOTICE([LNet kernel checks
886 ==============================================================================])
895 LN_CONFIG_TCP_SENDPAGE
897 LN_EXPORT_KMAP_TO_PAGE
899 LN_CONFIG_SK_DATA_READY
901 LN_CONFIG_SOCK_CREATE_KERN
903 LN_CONFIG_SOCK_ACCEPT
905 LN_CONFIG_SOCK_GETNAME
906 # 5.3 and 4.18.0-193.el8
907 LN_HAVE_IN_DEV_FOR_EACH_IFA_RTNL
913 # default paths for installed files
915 AC_DEFUN([LN_PATH_DEFAULTS], [
916 ]) # LN_PATH_DEFAULTS
921 # other configure checks
923 AC_DEFUN([LN_CONFIGURE], [
924 AC_MSG_NOTICE([LNet core checks
925 ==============================================================================])
927 # lnet/utils/portals.c
928 AC_CHECK_HEADERS([netdb.h])
929 AC_CHECK_FUNCS([gethostbyname])
931 # lnet/utils/wirecheck.c
932 AC_CHECK_FUNCS([strnlen])
934 # -------- Check for required packages --------------
936 AC_MSG_CHECKING([whether to enable 'efence' debugging support])
937 AC_ARG_ENABLE(efence,
938 AC_HELP_STRING([--enable-efence],
939 [use efence library]),
940 [], [enable_efence="no"])
941 AC_MSG_RESULT([$enable_efence])
944 AS_IF([test "$enable_efence" = yes], [
946 AC_DEFINE(HAVE_LIBEFENCE, 1,
947 [libefence support is requested])
957 # AM_CONDITIONAL defines for lnet
959 AC_DEFUN([LN_CONDITIONALS], [
960 AM_CONDITIONAL(BUILD_O2IBLND, test x$O2IBLND = "xo2iblnd")
961 AM_CONDITIONAL(BUILD_GNILND, test x$GNILND = "xgnilnd")
967 # files that should be generated with AC_OUTPUT
969 AC_DEFUN([LN_CONFIG_FILES], [
973 lnet/autoconf/Makefile
975 lnet/include/Makefile
976 lnet/include/lnet/Makefile
977 lnet/include/uapi/linux/lnet/Makefile
979 lnet/klnds/autoMakefile
980 lnet/klnds/o2iblnd/Makefile
981 lnet/klnds/o2iblnd/autoMakefile
982 lnet/klnds/gnilnd/Makefile
983 lnet/klnds/gnilnd/autoMakefile
984 lnet/klnds/socklnd/Makefile
985 lnet/klnds/socklnd/autoMakefile
987 lnet/lnet/autoMakefile
988 lnet/selftest/Makefile
989 lnet/selftest/autoMakefile
991 lnet/utils/lnetconfig/Makefile