Whamcloud - gitweb
LU-10886 build: fix warnings during autoconf
[fs/lustre-release.git] / lnet / autoconf / lustre-lnet.m4
1 #
2 # LN_CHECK_GCC_VERSION
3 #
4 # Check compiler version
5 #
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"
10 v2n() {
11         awk -F. '{printf "%d\n", (($ 1)*100+($ 2))*100+($ 3)}'
12 }
13 if test -z "$PTL_CC_VERSION" -o \
14         $(echo $PTL_CC_VERSION | v2n) -ge $(echo $PTL_MIN_CC_VERSION | v2n); then
15         AC_MSG_RESULT([ok])
16 else
17         AC_MSG_RESULT([Buggy compiler found])
18         AC_MSG_ERROR([Need gcc version >= $PTL_MIN_CC_VERSION])
19 fi
20 ]) # LN_CHECK_GCC_VERSION
21
22 #
23 # LN_CONFIG_AFFINITY
24 #
25 # check if cpu affinity is available/wanted
26 #
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>
38         ],[
39                 struct task_struct *t = NULL;
40                 cpumask_t m = { };
41
42                 set_cpus_allowed_ptr(t, &m);
43         ],[
44                 AC_DEFINE(CPU_AFFINITY, 1,
45                         [kernel has cpu affinity support])
46         ])
47 ])
48 ]) # LN_CONFIG_AFFINITY
49
50 #
51 # LN_CONFIG_BACKOFF
52 #
53 # check if tunable tcp backoff is available/wanted
54 #
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], [
65                 AC_MSG_RESULT([yes])
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])])
70         ], [
71                 AC_MSG_RESULT([no])
72         ])
73 ])
74 ]) # LN_CONFIG_BACKOFF
75
76 #
77 # LN_CONFIG_DLC
78 #
79 # Configure dlc
80 #
81 # fail to build if libyaml is not installed
82 #
83 AC_DEFUN([LN_CONFIG_DLC], [
84         AC_CHECK_LIB([yaml], [yaml_parser_initialize],
85                      [LIBYAML="libyaml"],
86                      [AC_MSG_ERROR([YAML development libraries not not installed])],
87                      [-lm])
88 ])
89
90 #
91 # LN_CONFIG_O2IB
92 #
93 # If current OFED installed (assume with "ofed_info") and devel
94 # headers are not found, error because we assume OFED infiniband
95 # driver needs to be used and we must configure/build with it.
96 # Current OFED headers detection mechanism allow for non-standard
97 # prefix but relies on "ofed_info" command and on "%prefix/openib"
98 # link (both are ok for 1.5.x and 3.x versions), and should work
99 # for both source and DKMS builds.
100 #
101 AC_DEFUN([LN_CONFIG_O2IB], [
102 AC_MSG_CHECKING([whether to use Compat RDMA])
103 AC_ARG_WITH([o2ib],
104         AC_HELP_STRING([--with-o2ib=[yes|no|<path>]],
105                 [build o2iblnd against path]),
106         [], [with_o2ib="yes"])
107
108 case $with_o2ib in
109         yes)    AS_IF([which ofed_info 2>/dev/null], [
110                         AS_IF([test x$uses_dpkg = xyes], [
111                                 OFED_INFO="ofed_info | awk '{print \[$]2}'"
112                                 LSPKG="dpkg --listfiles"
113                         ], [
114                                 OFED_INFO="ofed_info"
115                                 LSPKG="rpm -ql"
116                         ])
117                         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)
118                         AS_IF([test -z "$O2IBPATHS"], [
119                                 AC_MSG_ERROR([
120 You seem to have an OFED installed but have not installed it's devel package.
121 If you still want to build Lustre for your OFED I/B stack, you need to install its devel headers RPM.
122 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.
123                                              ])
124                         ])
125                         AS_IF([test $(echo $O2IBPATHS | wc -w) -ge 2], [
126                                 AC_MSG_ERROR([
127 It appears that you have multiple OFED versions installed.
128 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.
129 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.
130                                              ])
131                         ])
132                         OFED="yes"
133                 ], [
134                         O2IBPATHS="$LINUX $LINUX/drivers/infiniband"
135                 ])
136                 ENABLEO2IB="yes"
137                 ;;
138         no)     ENABLEO2IB="no"
139                 ;;
140         *)      O2IBPATHS=$with_o2ib
141                 ENABLEO2IB="withpath"
142                 OFED="yes"
143                 ;;
144 esac
145
146 AS_IF([test $ENABLEO2IB = "no"], [
147         AC_MSG_RESULT([no])
148 ], [
149         o2ib_found=false
150         for O2IBPATH in $O2IBPATHS; do
151                 AS_IF([test \( -f ${O2IBPATH}/include/rdma/rdma_cm.h -a \
152                            -f ${O2IBPATH}/include/rdma/ib_cm.h -a \
153                            -f ${O2IBPATH}/include/rdma/ib_verbs.h -a \
154                            -f ${O2IBPATH}/include/rdma/ib_fmr_pool.h \)], [
155                         o2ib_found=true
156                         break
157                 ])
158         done
159         if ! $o2ib_found; then
160                 AC_MSG_RESULT([no])
161                 case $ENABLEO2IB in
162                         "yes") AC_MSG_ERROR([no OFED nor kernel OpenIB gen2 headers present]) ;;
163                         "withpath") AC_MSG_ERROR([bad --with-o2ib path]) ;;
164                         *) AC_MSG_ERROR([internal error]) ;;
165                 esac
166         else
167                 COMPAT_AUTOCONF=""
168                 compatrdma_found=false
169                 if test -f ${O2IBPATH}/include/linux/compat-2.6.h; then
170                         AC_MSG_RESULT([yes])
171                         compatrdma_found=true
172                         AC_DEFINE(HAVE_COMPAT_RDMA, 1, [compat rdma found])
173                         EXTRA_OFED_CONFIG="$EXTRA_OFED_CONFIG -include ${O2IBPATH}/include/linux/compat-2.6.h"
174                         if test -f "$O2IBPATH/include/linux/compat_autoconf.h"; then
175                                 COMPAT_AUTOCONF="$O2IBPATH/include/linux/compat_autoconf.h"
176                         fi
177                 else
178                         AC_MSG_RESULT([no])
179                 fi
180                 if ! $compatrdma_found; then
181                         if test -f "$O2IBPATH/config.mk"; then
182                                 . "$O2IBPATH/config.mk"
183                         elif test -f "$O2IBPATH/ofed_patch.mk"; then
184                                 . "$O2IBPATH/ofed_patch.mk"
185                         fi
186                 elif test -z "$COMPAT_AUTOCONF"; then
187                         # Depreciated checks
188                         if test "x$RHEL_KERNEL" = xyes; then
189                                 RHEL_MAJOR=$(awk '/ RHEL_MAJOR / { print [$]3 }' $LINUX_OBJ/include/$VERSION_HDIR/version.h)
190                                 I=$(awk '/ RHEL_MINOR / { print [$]3 }' $LINUX_OBJ/include/$VERSION_HDIR/version.h)
191                                 while test "$I" -ge 0; do
192                                         EXTRA_OFED_INCLUDE="$EXTRA_OFED_INCLUDE -DCONFIG_COMPAT_RHEL_${RHEL_MAJOR}_$I"
193                                         I=$(($I-1))
194                                 done
195                         elif test "x$SUSE_KERNEL" = xyes; then
196                                 SP=$(grep PATCHLEVEL /etc/SuSE-release | sed -e 's/.*= *//')
197                                 EXTRA_OFED_INCLUDE="$EXTRA_OFED_INCLUDE -DCONFIG_COMPAT_SLES_11_$SP"
198                         fi
199                 fi
200
201                 AC_MSG_CHECKING([whether to use any OFED backport headers])
202                 if test -n "$BACKPORT_INCLUDES"; then
203                         AC_MSG_RESULT([yes])
204                         OFED_BACKPORT_PATH="$O2IBPATH/${BACKPORT_INCLUDES/*\/kernel_addons/kernel_addons}/"
205                         EXTRA_OFED_INCLUDE="-I$OFED_BACKPORT_PATH $EXTRA_OFED_INCLUDE"
206                 else
207                         AC_MSG_RESULT([no])
208                 fi
209
210                 O2IBLND=""
211                 O2IBPATH=$(readlink --canonicalize $O2IBPATH)
212                 EXTRA_OFED_INCLUDE="$EXTRA_OFED_INCLUDE -I$O2IBPATH/include -I$O2IBPATH/include/uapi"
213                 EXTRA_CHECK_INCLUDE="$EXTRA_OFED_CONFIG $EXTRA_OFED_INCLUDE"
214                 LB_CHECK_COMPILE([whether to enable OpenIB gen2 support],
215                 openib_gen2_support, [
216                         #ifdef HAVE_COMPAT_RDMA
217                         #undef PACKAGE_NAME
218                         #undef PACKAGE_TARNAME
219                         #undef PACKAGE_VERSION
220                         #undef PACKAGE_STRING
221                         #undef PACKAGE_BUGREPORT
222                         #undef PACKAGE_URL
223                         #include <linux/compat-2.6.h>
224                         #endif
225                         #include <linux/version.h>
226                         #include <linux/pci.h>
227                         #include <linux/gfp.h>
228                         #include <rdma/rdma_cm.h>
229                         #include <rdma/ib_cm.h>
230                         #include <rdma/ib_verbs.h>
231                         #include <rdma/ib_fmr_pool.h>
232                 ],[
233                         struct rdma_cm_id      *cm_idi __attribute__ ((unused));
234                         struct rdma_conn_param  conn_param __attribute__ ((unused));
235                         struct ib_device_attr   device_attr __attribute__ ((unused));
236                         struct ib_qp_attr       qp_attr __attribute__ ((unused));
237                         struct ib_pool_fmr      pool_fmr __attribute__ ((unused));
238                         enum   ib_cm_rej_reason rej_reason __attribute__ ((unused));
239                         rdma_destroy_id(NULL);
240                 ],[
241                         O2IBLND="o2iblnd"
242                 ],[
243                         case $ENABLEO2IB in
244                         "yes") AC_MSG_ERROR([can't compile with OpenIB gen2 headers]) ;;
245                         "withpath") AC_MSG_ERROR([can't compile with OpenIB gen2 headers under $O2IBPATH]) ;;
246                         *) AC_MSG_ERROR([internal error]) ;;
247                         esac
248                 ])
249                 # we know at this point that the found OFED source is good
250                 O2IB_SYMVER=""
251                 if test $ENABLEO2IB = "withpath" -o "x$OFED" = "xyes" ; then
252                         # OFED default rpm not handle sles10 Modules.symvers name
253                         for name in Module.symvers Modules.symvers; do
254                                 if test -f $O2IBPATH/$name; then
255                                         O2IB_SYMVER=$name;
256                                         break;
257                                 fi
258                         done
259                         if test -n "$O2IB_SYMVER"; then
260                                 AC_MSG_NOTICE([adding $O2IBPATH/$O2IB_SYMVER to Symbol Path])
261                                 EXTRA_SYMBOLS="$EXTRA_SYMBOLS $O2IBPATH/$O2IB_SYMVER"
262                                 AC_SUBST(EXTRA_SYMBOLS)
263                         else
264                                 AC_MSG_ERROR([an external source tree was, either specified or detected, for o2iblnd however I could not find a $O2IBPATH/Module.symvers there])
265                         fi
266                 fi
267
268                 LB_CHECK_COMPILE([if Linux kernel has kthread_worker],
269                 linux_kthread_worker, [
270                         #ifdef HAVE_COMPAT_RDMA
271                         #undef PACKAGE_NAME
272                         #undef PACKAGE_TARNAME
273                         #undef PACKAGE_VERSION
274                         #undef PACKAGE_STRING
275                         #undef PACKAGE_BUGREPORT
276                         #undef PACKAGE_URL
277                         #include <linux/compat-2.6.h>
278                         #endif
279                         #include <linux/kthread.h>
280                 ],[
281                         struct kthread_work *kth_wrk = NULL;
282                         flush_kthread_work(kth_wrk);
283                 ],[
284                         AC_DEFINE(HAVE_KTHREAD_WORK, 1, [kthread_worker found])
285                         if test -z "$COMPAT_AUTOCONF"; then
286                                 EXTRA_OFED_INCLUDE="$EXTRA_OFED_INCLUDE -DCONFIG_COMPAT_IS_KTHREAD"
287                         fi
288                 ])
289                 EXTRA_CHECK_INCLUDE=""
290         fi
291 ])
292 AC_SUBST(EXTRA_OFED_CONFIG)
293 AC_SUBST(EXTRA_OFED_INCLUDE)
294 AC_SUBST(O2IBLND)
295 AC_SUBST(O2IBPATH)
296 AC_SUBST(ENABLEO2IB)
297
298 AS_IF([test $ENABLEO2IB != "no"], [
299         EXTRA_CHECK_INCLUDE="$EXTRA_OFED_CONFIG $EXTRA_OFED_INCLUDE"
300
301         # In RHEL 6.2, rdma_create_id() takes the queue-pair type as a fourth argument
302         LB_CHECK_COMPILE([if 'rdma_create_id' wants four args],
303         rdma_create_id_4args, [
304                 #ifdef HAVE_COMPAT_RDMA
305                 #undef PACKAGE_NAME
306                 #undef PACKAGE_TARNAME
307                 #undef PACKAGE_VERSION
308                 #undef PACKAGE_STRING
309                 #undef PACKAGE_BUGREPORT
310                 #undef PACKAGE_URL
311                 #include <linux/compat-2.6.h>
312                 #endif
313                 #include <rdma/rdma_cm.h>
314         ],[
315                 rdma_create_id(NULL, NULL, 0, 0);
316         ],[
317                 AC_DEFINE(HAVE_RDMA_CREATE_ID_4ARG, 1,
318                         [rdma_create_id wants 4 args])
319         ])
320
321         # 4.4 added network namespace parameter for rdma_create_id()
322         LB_CHECK_COMPILE([if 'rdma_create_id' wants five args],
323         rdma_create_id_5args, [
324                 #ifdef HAVE_COMPAT_RDMA
325                 #undef PACKAGE_NAME
326                 #undef PACKAGE_TARNAME
327                 #undef PACKAGE_VERSION
328                 #undef PACKAGE_STRING
329                 #undef PACKAGE_BUGREPORT
330                 #undef PACKAGE_URL
331                 #include <linux/compat-2.6.h>
332                 #endif
333                 #include <rdma/rdma_cm.h>
334         ],[
335                 rdma_create_id(NULL, NULL, NULL, 0, 0);
336         ],[
337                 AC_DEFINE(HAVE_RDMA_CREATE_ID_5ARG, 1,
338                         [rdma_create_id wants 5 args])
339         ])
340
341         # 4.2 introduced struct ib_cq_init_attr which is used
342         # by ib_create_cq(). Note some OFED stacks only keep
343         # their headers in sync with latest kernels but not
344         # the functionality which means for infiniband testing
345         # we need to always test functionality testings.
346         LB_CHECK_COMPILE([if 'struct ib_cq_init_attr' is used],
347         ib_cq_init_attr, [
348                 #ifdef HAVE_COMPAT_RDMA
349                 #undef PACKAGE_NAME
350                 #undef PACKAGE_TARNAME
351                 #undef PACKAGE_VERSION
352                 #undef PACKAGE_STRING
353                 #undef PACKAGE_BUGREPORT
354                 #undef PACKAGE_URL
355                 #include <linux/compat-2.6.h>
356                 #endif
357                 #include <rdma/ib_verbs.h>
358         ],[
359                 struct ib_cq_init_attr cq_attr;
360
361                 ib_create_cq(NULL, NULL, NULL, NULL, &cq_attr);
362         ],[
363                 AC_DEFINE(HAVE_IB_CQ_INIT_ATTR, 1,
364                         [struct ib_cq_init_attr is used by ib_create_cq])
365         ])
366
367         # 4.3 removed ib_alloc_fast_reg_mr()
368         LB_CHECK_COMPILE([if 'ib_alloc_fast_reg_mr' exists],
369         ib_alloc_fast_reg_mr, [
370                 #ifdef HAVE_COMPAT_RDMA
371                 #undef PACKAGE_NAME
372                 #undef PACKAGE_TARNAME
373                 #undef PACKAGE_VERSION
374                 #undef PACKAGE_STRING
375                 #undef PACKAGE_BUGREPORT
376                 #undef PACKAGE_URL
377                 #include <linux/compat-2.6.h>
378                 #endif
379                 #include <rdma/ib_verbs.h>
380         ],[
381                 ib_alloc_fast_reg_mr(NULL, 0);
382         ],[
383                 AC_DEFINE(HAVE_IB_ALLOC_FAST_REG_MR, 1,
384                         [ib_alloc_fast_reg_mr is defined])
385         ])
386
387         # 4.9 must stop using ib_get_dma_mr and the global MR
388         # We then have to use FMR/Fastreg for all RDMA.
389         LB_CHECK_COMPILE([if 'ib_get_dma_mr' exists],
390         ib_get_dma_mr, [
391                 #ifdef HAVE_COMPAT_RDMA
392                 #undef PACKAGE_NAME
393                 #undef PACKAGE_TARNAME
394                 #undef PACKAGE_VERSION
395                 #undef PACKAGE_STRING
396                 #undef PACKAGE_BUGREPORT
397                 #undef PACKAGE_URL
398                 #include <linux/compat-2.6.h>
399                 #endif
400                 #include <rdma/ib_verbs.h>
401         ],[
402                 ib_get_dma_mr(NULL, 0);
403         ],[
404                 AC_DEFINE(HAVE_IB_GET_DMA_MR, 1,
405                         [ib_get_dma_mr is defined])
406         ])
407
408         # In v4.4 Linux kernel,
409         # commit e622f2f4ad2142d2a613a57fb85f8cf737935ef5
410         # split up struct ib_send_wr so that all non-trivial verbs
411         # use their own structure which embedds struct ib_send_wr.
412         LB_CHECK_COMPILE([if 'struct ib_rdma_wr' is defined],
413         ib_rdma_wr, [
414                 #ifdef HAVE_COMPAT_RDMA
415                 #undef PACKAGE_NAME
416                 #undef PACKAGE_TARNAME
417                 #undef PACKAGE_VERSION
418                 #undef PACKAGE_STRING
419                 #undef PACKAGE_BUGREPORT
420                 #undef PACKAGE_URL
421                 #include <linux/compat-2.6.h>
422                 #endif
423                 #include <rdma/ib_verbs.h>
424         ],[
425                 struct ib_rdma_wr *wr __attribute__ ((unused));
426
427                 wr = rdma_wr(NULL);
428         ],[
429                 AC_DEFINE(HAVE_IB_RDMA_WR, 1,
430                         [struct ib_rdma_wr is defined])
431         ])
432
433         # new fast registration API introduced in 4.4
434         LB_CHECK_COMPILE([if 4arg 'ib_map_mr_sg' exists],
435         ib_map_mr_sg_4args, [
436                 #ifdef HAVE_COMPAT_RDMA
437                 #undef PACKAGE_NAME
438                 #undef PACKAGE_TARNAME
439                 #undef PACKAGE_VERSION
440                 #undef PACKAGE_STRING
441                 #undef PACKAGE_BUGREPORT
442                 #undef PACKAGE_URL
443                 #include <linux/compat-2.6.h>
444                 #endif
445                 #include <rdma/ib_verbs.h>
446         ],[
447                 ib_map_mr_sg(NULL, NULL, 0, 0);
448         ],[
449                 AC_DEFINE(HAVE_IB_MAP_MR_SG, 1,
450                         [ib_map_mr_sg exists])
451         ])
452
453         # ib_map_mr_sg changes from 4 to 5 args (adding sg_offset_p)
454         # in kernel 4.7 (and RHEL 7.3)
455         LB_CHECK_COMPILE([if 5arg 'ib_map_mr_sg' exists],
456         ib_map_mr_sg_5args, [
457                 #ifdef HAVE_COMPAT_RDMA
458                 #undef PACKAGE_NAME
459                 #undef PACKAGE_TARNAME
460                 #undef PACKAGE_VERSION
461                 #undef PACKAGE_STRING
462                 #undef PACKAGE_BUGREPORT
463                 #undef PACKAGE_URL
464                 #include <linux/compat-2.6.h>
465                 #endif
466                 #include <rdma/ib_verbs.h>
467         ],[
468                 ib_map_mr_sg(NULL, NULL, 0, NULL, 0);
469         ],[
470                 AC_DEFINE(HAVE_IB_MAP_MR_SG, 1,
471                         [ib_map_mr_sg exists])
472                 AC_DEFINE(HAVE_IB_MAP_MR_SG_5ARGS, 1,
473                         [ib_map_mr_sg has 5 arguments])
474         ])
475
476         # ib_query_device() removed in 4.5
477         LB_CHECK_COMPILE([if 'struct ib_device' has member 'attrs'],
478         ib_device.attrs, [
479                 #ifdef HAVE_COMPAT_RDMA
480                 #undef PACKAGE_NAME
481                 #undef PACKAGE_TARNAME
482                 #undef PACKAGE_VERSION
483                 #undef PACKAGE_STRING
484                 #undef PACKAGE_BUGREPORT
485                 #undef PACKAGE_URL
486                 #include <linux/compat-2.6.h>
487                 #endif
488                 #include <rdma/ib_verbs.h>
489         ],[
490                 struct ib_device dev;
491                 struct ib_device_attr dev_attr = {};
492                 dev.attrs = dev_attr;
493         ],[
494                 AC_DEFINE(HAVE_IB_DEVICE_ATTRS, 1,
495                         [struct ib_device.attrs is defined])
496         ])
497
498         # A flags argument was added to ib_alloc_pd() in Linux 4.9,
499         # commit ed082d36a7b2c27d1cda55fdfb28af18040c4a89
500         LB_CHECK_COMPILE([if 2arg 'ib_alloc_pd' exists],
501         ib_alloc_pd, [
502                 #ifdef HAVE_COMPAT_RDMA
503                 #undef PACKAGE_NAME
504                 #undef PACKAGE_TARNAME
505                 #undef PACKAGE_VERSION
506                 #undef PACKAGE_STRING
507                 #undef PACKAGE_BUGREPORT
508                 #undef PACKAGE_URL
509                 #include <linux/compat-2.6.h>
510                 #endif
511                 #include <rdma/ib_verbs.h>
512         ],[
513                 ib_alloc_pd(NULL, 0);
514         ],[
515                 AC_DEFINE(HAVE_IB_ALLOC_PD_2ARGS, 1,
516                         [ib_alloc_pd has 2 arguments])
517         ])
518
519         LB_CHECK_COMPILE([if function 'ib_inc_rkey' is defined],
520         ib_inc_rkey, [
521                 #ifdef HAVE_COMPAT_RDMA
522                 #undef PACKAGE_NAME
523                 #undef PACKAGE_TARNAME
524                 #undef PACKAGE_VERSION
525                 #undef PACKAGE_STRING
526                 #undef PACKAGE_BUGREPORT
527                 #undef PACKAGE_URL
528                 #include <linux/compat-2.6.h>
529                 #endif
530                 #include <rdma/ib_verbs.h>
531         ],[
532                 (void)ib_inc_rkey(0);
533         ],[
534                 AC_DEFINE(HAVE_IB_INC_RKEY, 1,
535                           [function ib_inc_rkey exist])
536         ])
537
538         EXTRA_CHECK_INCLUDE=""
539 ]) # ENABLEO2IB != "no"
540 ]) # LN_CONFIG_O2IB
541
542 #
543 # LN_CONFIG_GNILND
544 #
545 # check whether to use the Gemini Network Interface lnd
546 #
547 AC_DEFUN([LN_CONFIG_GNILND], [
548 AC_MSG_CHECKING([whether to enable GNI lnd])
549 AC_ARG_ENABLE([gni],
550         AC_HELP_STRING([--enable-gni],
551                 [enable GNI lnd]),
552         [], [enable_gni="no"])
553 AC_MSG_RESULT([$enable_gni])
554
555 AS_IF([test "x$enable_gni" = xyes], [
556         # GNICPPFLAGS was set in spec file
557         EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
558         EXTRA_KCFLAGS="$EXTRA_KCFLAGS $GNICPPFLAGS"
559         LB_CHECK_COMPILE([if GNI kernel headers are present],
560         GNI_header, [
561                 #include <linux/types.h>
562                 #include <gni_pub.h>
563         ],[
564                 gni_cdm_handle_t kgni_domain;
565                 gni_return_t     rc;
566                 int              rrc;
567                 rc = gni_cdm_create(0, 1, 1, 0, &kgni_domain);
568                 rrc = (rc == GNI_RC_SUCCESS) ? 0 : 1;
569                 return rrc;
570         ],[
571                 GNILND="gnilnd"
572         ],[
573                 AC_MSG_ERROR([can't compile gnilnd with given GNICPPFLAGS: $GNICPPFLAGS])
574         ])
575         # at this point, we have gnilnd basic support,
576         # now check for extra features
577         LB_CHECK_COMPILE([to use RCA in gnilnd],
578         RCA_gnilnd, [
579                 #include <linux/types.h>
580                 #include <gni_pub.h>
581                 #include <krca_lib.h>
582         ],[
583                 gni_cdm_handle_t kgni_domain;
584                 gni_return_t     rc;
585                 krca_ticket_t    ticket = KRCA_NULL_TICKET;
586                 int              rrc;
587                 __u32            nid = 0, nic_addr;
588                 rc = gni_cdm_create(0, 1, 1, 0, &kgni_domain);
589                 rrc = (rc == GNI_RC_SUCCESS) ? 0 : 1;
590                 rrc += krca_nid_to_nicaddrs(nid, 1, &nic_addr);
591                 rrc += krca_register(&ticket, RCA_MAKE_SERVICE_INDEX(RCA_IO_CLASS, 9), 99, 0);
592                 return rrc;
593         ],[
594                 GNICPPFLAGS="$GNICPPFLAGS -DGNILND_USE_RCA=1"
595         ])
596         EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
597 ])
598 AC_SUBST(GNICPPFLAGS)
599 AC_SUBST(GNILND)
600 ]) # LN_CONFIG_GNILND
601
602 #
603 # LN_CONFIG_SK_SLEEP
604 #
605 # 2.6.35 kernel has sk_sleep function
606 #
607 AC_DEFUN([LN_CONFIG_SK_SLEEP], [
608 LB_CHECK_COMPILE([if Linux kernel has 'sk_sleep'],
609 sk_sleep, [
610         #include <net/sock.h>
611 ],[
612         sk_sleep(NULL);
613 ],[
614         AC_DEFINE(HAVE_SK_SLEEP, 1,
615                   [kernel has sk_sleep])
616 ])
617 ]) # LN_CONFIG_SK_SLEEP
618
619 #
620 # LN_CONFIG_TCP_SENDPAGE
621 #
622 # 2.6.36 tcp_sendpage() first parameter is 'struct sock'
623 # instead of 'struct socket'.
624 #
625 AC_DEFUN([LN_CONFIG_TCP_SENDPAGE], [
626 tmp_flags="$EXTRA_KCFLAGS"
627 EXTRA_KCFLAGS="-Werror"
628 LB_CHECK_COMPILE([if 'tcp_sendpage' first parameter is socket],
629 tcp_sendpage_socket, [
630         #include <linux/net.h>
631         #include <net/tcp.h>
632 ],[
633         tcp_sendpage((struct socket*)0, NULL, 0, 0, 0);
634 ],[
635         AC_DEFINE(HAVE_TCP_SENDPAGE_USE_SOCKET, 1,
636                 [tcp_sendpage use socket as first parameter])
637 ])
638 EXTRA_KCFLAGS="$tmp_flags"
639 ]) # LN_CONFIG_TCP_SENDPAGE
640
641 # LN_CONFIG_SOCK_CREATE_KERN
642 #
643 # 4.x sock_create_kern() added a first parameter as 'struct net *'
644 # instead of int.
645 #
646 AC_DEFUN([LN_CONFIG_SOCK_CREATE_KERN], [
647 tmp_flags="$EXTRA_KCFLAGS"
648 EXTRA_KCFLAGS="-Werror"
649 LB_CHECK_COMPILE([if 'sock_create_kern' first parameter is net],
650 sock_create_kern_net, [
651         #include <linux/net.h>
652         #include <net/net_namespace.h>
653 ],[
654         sock_create_kern((struct net*)0, 0, 0, 0, NULL);
655 ],[
656         AC_DEFINE(HAVE_SOCK_CREATE_KERN_USE_NET, 1,
657                 [sock_create_kern use net as first parameter])
658 ])
659 EXTRA_KCFLAGS="$tmp_flags"
660 ]) # LN_CONFIG_SOCK_CREATE_KERN
661
662 #
663 # LN_CONFIG_SK_DATA_READY
664 #
665 # 3.15 for struct sock the *sk_data_ready() field only takes one argument now
666 #
667 AC_DEFUN([LN_CONFIG_SK_DATA_READY], [
668 tmp_flags="$EXTRA_KCFLAGS"
669 EXTRA_KCFLAGS="-Werror"
670 LB_CHECK_COMPILE([if 'sk_data_ready' takes only one argument],
671 sk_data_ready, [
672         #include <linux/net.h>
673         #include <net/sock.h>
674 ],[
675         ((struct sock *)0)->sk_data_ready(NULL);
676 ],[
677         AC_DEFINE(HAVE_SK_DATA_READY_ONE_ARG, 1,
678                 [sk_data_ready uses only one argument])
679 ])
680 EXTRA_KCFLAGS="$tmp_flags"
681 ]) # LN_CONFIG_SK_DATA_READY
682
683 #
684 # LN_EXPORT_KMAP_TO_PAGE
685 #
686 # 3.10 Export kmap_to_page
687 #
688 AC_DEFUN([LN_EXPORT_KMAP_TO_PAGE], [
689 LB_CHECK_EXPORT([kmap_to_page], [mm/highmem.c],
690         [AC_DEFINE(HAVE_KMAP_TO_PAGE, 1,
691                 [kmap_to_page is exported by the kernel])])
692 ]) # LN_EXPORT_KMAP_TO_PAG
693
694 #
695 # LN_CONFIG_SOCK_ACCEPT
696 #
697 # 4.11 commit cdfbabfb2f0ce983fdaa42f20e5f7842178fc01e added a flag
698 # to handle a possible lockdep condition kernel socket accept.
699 #
700 AC_DEFUN([LN_CONFIG_SOCK_ACCEPT], [
701 tmp_flags="$EXTRA_KCFLAGS"
702 EXTRA_KCFLAGS="-Werror"
703 LB_CHECK_COMPILE([if 'struct sock' accept function requires a bool argument],
704 kern_sock_flag, [
705         #include <linux/net.h>
706 ],[
707         ((struct socket *)0)->ops->accept(NULL, NULL, O_NONBLOCK, false);
708 ],[
709         AC_DEFINE(HAVE_KERN_SOCK_ACCEPT_FLAG_ARG, 1,
710                 ['struct sock' accept function requires bool argument])
711 ])
712 EXTRA_KCFLAGS="$tmp_flags"
713 ]) # LN_CONFIG_SOCK_ACCEPT
714
715 #
716 # LN_PROG_LINUX
717 #
718 # LNet linux kernel checks
719 #
720 AC_DEFUN([LN_PROG_LINUX], [
721 AC_MSG_NOTICE([LNet kernel checks
722 ==============================================================================])
723
724 LN_CONFIG_AFFINITY
725 LN_CONFIG_BACKOFF
726 LN_CONFIG_O2IB
727 LN_CONFIG_GNILND
728 # 2.6.35
729 LN_CONFIG_SK_SLEEP
730 # 2.6.36
731 LN_CONFIG_TCP_SENDPAGE
732 # 3.10
733 LN_EXPORT_KMAP_TO_PAGE
734 # 3.15
735 LN_CONFIG_SK_DATA_READY
736 # 4.x
737 LN_CONFIG_SOCK_CREATE_KERN
738 # 4.11
739 LN_CONFIG_SOCK_ACCEPT
740 ]) # LN_PROG_LINUX
741
742 #
743 # LN_PATH_DEFAULTS
744 #
745 # default paths for installed files
746 #
747 AC_DEFUN([LN_PATH_DEFAULTS], [
748 ]) # LN_PATH_DEFAULTS
749
750 #
751 # LN_CONFIGURE
752 #
753 # other configure checks
754 #
755 AC_DEFUN([LN_CONFIGURE], [
756 AC_MSG_NOTICE([LNet core checks
757 ==============================================================================])
758
759 # lnet/utils/portals.c
760 AC_CHECK_HEADERS([netdb.h])
761 AC_CHECK_FUNCS([gethostbyname])
762
763 # lnet/utils/wirecheck.c
764 AC_CHECK_FUNCS([strnlen])
765
766 # --------  Check for required packages  --------------
767
768 AC_MSG_CHECKING([whether to enable 'efence' debugging support])
769 AC_ARG_ENABLE(efence,
770         AC_HELP_STRING([--enable-efence],
771                 [use efence library]),
772         [], [enable_efence="no"])
773 AC_MSG_RESULT([$enable_efence])
774
775 LIBEFENCE=""
776 AS_IF([test "$enable_efence" = yes], [
777         LIBEFENCE="-lefence"
778         AC_DEFINE(HAVE_LIBEFENCE, 1,
779                 [libefence support is requested])
780 ])
781 AC_SUBST(LIBEFENCE)
782
783 LN_CONFIG_DLC
784 ]) # LN_CONFIGURE
785
786 #
787 # LN_CONDITIONALS
788 #
789 # AM_CONDITIONAL defines for lnet
790 #
791 AC_DEFUN([LN_CONDITIONALS], [
792 AM_CONDITIONAL(BUILD_O2IBLND,    test x$O2IBLND = "xo2iblnd")
793 AM_CONDITIONAL(BUILD_GNILND,     test x$GNILND  = "xgnilnd")
794 ]) # LN_CONDITIONALS
795
796 #
797 # LN_CONFIG_FILES
798 #
799 # files that should be generated with AC_OUTPUT
800 #
801 AC_DEFUN([LN_CONFIG_FILES], [
802 AC_CONFIG_FILES([
803 lnet/Makefile
804 lnet/autoMakefile
805 lnet/autoconf/Makefile
806 lnet/doc/Makefile
807 lnet/include/Makefile
808 lnet/include/lnet/Makefile
809 lnet/include/uapi/linux/lnet/Makefile
810 lnet/klnds/Makefile
811 lnet/klnds/autoMakefile
812 lnet/klnds/o2iblnd/Makefile
813 lnet/klnds/o2iblnd/autoMakefile
814 lnet/klnds/gnilnd/Makefile
815 lnet/klnds/gnilnd/autoMakefile
816 lnet/klnds/socklnd/Makefile
817 lnet/klnds/socklnd/autoMakefile
818 lnet/lnet/Makefile
819 lnet/lnet/autoMakefile
820 lnet/selftest/Makefile
821 lnet/selftest/autoMakefile
822 lnet/utils/Makefile
823 lnet/utils/lnetconfig/Makefile
824 ])
825 ]) # LN_CONFIG_FILES