Whamcloud - gitweb
LU-11393 osd-zfs: time struct changes
[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                         if test -f $O2IBPATH/Module.symvers; then
253                                 O2IB_SYMVER=$O2IBPATH/Module.symvers;
254                                 break;
255                         fi
256                         if test -n "$O2IB_SYMVER"; then
257                                 AC_MSG_NOTICE([adding $O2IB_SYMVER to Symbol Path])
258                                 EXTRA_SYMBOLS="$EXTRA_SYMBOLS $O2IB_SYMVER"
259                                 AC_SUBST(EXTRA_SYMBOLS)
260                         else
261                                 AC_MSG_ERROR([an external source tree was, either specified or detected, for o2iblnd however I could not find a $O2IBPATH/Module.symvers there])
262                         fi
263                 fi
264
265                 LB_CHECK_COMPILE([if Linux kernel has kthread_worker],
266                 linux_kthread_worker, [
267                         #ifdef HAVE_COMPAT_RDMA
268                         #undef PACKAGE_NAME
269                         #undef PACKAGE_TARNAME
270                         #undef PACKAGE_VERSION
271                         #undef PACKAGE_STRING
272                         #undef PACKAGE_BUGREPORT
273                         #undef PACKAGE_URL
274                         #include <linux/compat-2.6.h>
275                         #endif
276                         #include <linux/kthread.h>
277                 ],[
278                         struct kthread_work *kth_wrk = NULL;
279                         flush_kthread_work(kth_wrk);
280                 ],[
281                         AC_DEFINE(HAVE_KTHREAD_WORK, 1, [kthread_worker found])
282                         if test -z "$COMPAT_AUTOCONF"; then
283                                 EXTRA_OFED_INCLUDE="$EXTRA_OFED_INCLUDE -DCONFIG_COMPAT_IS_KTHREAD"
284                         fi
285                 ])
286                 EXTRA_CHECK_INCLUDE=""
287         fi
288 ])
289 AC_SUBST(EXTRA_OFED_CONFIG)
290 AC_SUBST(EXTRA_OFED_INCLUDE)
291 AC_SUBST(O2IBLND)
292 AC_SUBST(O2IBPATH)
293 AC_SUBST(ENABLEO2IB)
294
295 AS_IF([test $ENABLEO2IB != "no"], [
296         EXTRA_CHECK_INCLUDE="$EXTRA_OFED_CONFIG $EXTRA_OFED_INCLUDE"
297
298         # In RHEL 6.2, rdma_create_id() takes the queue-pair type as a fourth argument
299         LB_CHECK_COMPILE([if 'rdma_create_id' wants four args],
300         rdma_create_id_4args, [
301                 #ifdef HAVE_COMPAT_RDMA
302                 #undef PACKAGE_NAME
303                 #undef PACKAGE_TARNAME
304                 #undef PACKAGE_VERSION
305                 #undef PACKAGE_STRING
306                 #undef PACKAGE_BUGREPORT
307                 #undef PACKAGE_URL
308                 #include <linux/compat-2.6.h>
309                 #endif
310                 #include <rdma/rdma_cm.h>
311         ],[
312                 rdma_create_id(NULL, NULL, 0, 0);
313         ],[
314                 AC_DEFINE(HAVE_RDMA_CREATE_ID_4ARG, 1,
315                         [rdma_create_id wants 4 args])
316         ])
317
318         # 4.4 added network namespace parameter for rdma_create_id()
319         LB_CHECK_COMPILE([if 'rdma_create_id' wants five args],
320         rdma_create_id_5args, [
321                 #ifdef HAVE_COMPAT_RDMA
322                 #undef PACKAGE_NAME
323                 #undef PACKAGE_TARNAME
324                 #undef PACKAGE_VERSION
325                 #undef PACKAGE_STRING
326                 #undef PACKAGE_BUGREPORT
327                 #undef PACKAGE_URL
328                 #include <linux/compat-2.6.h>
329                 #endif
330                 #include <rdma/rdma_cm.h>
331         ],[
332                 rdma_create_id(NULL, NULL, NULL, 0, 0);
333         ],[
334                 AC_DEFINE(HAVE_RDMA_CREATE_ID_5ARG, 1,
335                         [rdma_create_id wants 5 args])
336         ])
337
338         # 4.2 introduced struct ib_cq_init_attr which is used
339         # by ib_create_cq(). Note some OFED stacks only keep
340         # their headers in sync with latest kernels but not
341         # the functionality which means for infiniband testing
342         # we need to always test functionality testings.
343         LB_CHECK_COMPILE([if 'struct ib_cq_init_attr' is used],
344         ib_cq_init_attr, [
345                 #ifdef HAVE_COMPAT_RDMA
346                 #undef PACKAGE_NAME
347                 #undef PACKAGE_TARNAME
348                 #undef PACKAGE_VERSION
349                 #undef PACKAGE_STRING
350                 #undef PACKAGE_BUGREPORT
351                 #undef PACKAGE_URL
352                 #include <linux/compat-2.6.h>
353                 #endif
354                 #include <rdma/ib_verbs.h>
355         ],[
356                 struct ib_cq_init_attr cq_attr;
357
358                 ib_create_cq(NULL, NULL, NULL, NULL, &cq_attr);
359         ],[
360                 AC_DEFINE(HAVE_IB_CQ_INIT_ATTR, 1,
361                         [struct ib_cq_init_attr is used by ib_create_cq])
362         ])
363
364         # 4.3 removed ib_alloc_fast_reg_mr()
365         LB_CHECK_COMPILE([if 'ib_alloc_fast_reg_mr' exists],
366         ib_alloc_fast_reg_mr, [
367                 #ifdef HAVE_COMPAT_RDMA
368                 #undef PACKAGE_NAME
369                 #undef PACKAGE_TARNAME
370                 #undef PACKAGE_VERSION
371                 #undef PACKAGE_STRING
372                 #undef PACKAGE_BUGREPORT
373                 #undef PACKAGE_URL
374                 #include <linux/compat-2.6.h>
375                 #endif
376                 #include <rdma/ib_verbs.h>
377         ],[
378                 ib_alloc_fast_reg_mr(NULL, 0);
379         ],[
380                 AC_DEFINE(HAVE_IB_ALLOC_FAST_REG_MR, 1,
381                         [ib_alloc_fast_reg_mr is defined])
382         ])
383
384         # 4.9 must stop using ib_get_dma_mr and the global MR
385         # We then have to use FMR/Fastreg for all RDMA.
386         LB_CHECK_COMPILE([if 'ib_get_dma_mr' exists],
387         ib_get_dma_mr, [
388                 #ifdef HAVE_COMPAT_RDMA
389                 #undef PACKAGE_NAME
390                 #undef PACKAGE_TARNAME
391                 #undef PACKAGE_VERSION
392                 #undef PACKAGE_STRING
393                 #undef PACKAGE_BUGREPORT
394                 #undef PACKAGE_URL
395                 #include <linux/compat-2.6.h>
396                 #endif
397                 #include <rdma/ib_verbs.h>
398         ],[
399                 ib_get_dma_mr(NULL, 0);
400         ],[
401                 AC_DEFINE(HAVE_IB_GET_DMA_MR, 1,
402                         [ib_get_dma_mr is defined])
403         ])
404
405         # In v4.4 Linux kernel,
406         # commit e622f2f4ad2142d2a613a57fb85f8cf737935ef5
407         # split up struct ib_send_wr so that all non-trivial verbs
408         # use their own structure which embedds struct ib_send_wr.
409         LB_CHECK_COMPILE([if 'struct ib_rdma_wr' is defined],
410         ib_rdma_wr, [
411                 #ifdef HAVE_COMPAT_RDMA
412                 #undef PACKAGE_NAME
413                 #undef PACKAGE_TARNAME
414                 #undef PACKAGE_VERSION
415                 #undef PACKAGE_STRING
416                 #undef PACKAGE_BUGREPORT
417                 #undef PACKAGE_URL
418                 #include <linux/compat-2.6.h>
419                 #endif
420                 #include <rdma/ib_verbs.h>
421         ],[
422                 struct ib_rdma_wr *wr __attribute__ ((unused));
423
424                 wr = rdma_wr(NULL);
425         ],[
426                 AC_DEFINE(HAVE_IB_RDMA_WR, 1,
427                         [struct ib_rdma_wr is defined])
428         ])
429
430         # new fast registration API introduced in 4.4
431         LB_CHECK_COMPILE([if 4arg 'ib_map_mr_sg' exists],
432         ib_map_mr_sg_4args, [
433                 #ifdef HAVE_COMPAT_RDMA
434                 #undef PACKAGE_NAME
435                 #undef PACKAGE_TARNAME
436                 #undef PACKAGE_VERSION
437                 #undef PACKAGE_STRING
438                 #undef PACKAGE_BUGREPORT
439                 #undef PACKAGE_URL
440                 #include <linux/compat-2.6.h>
441                 #endif
442                 #include <rdma/ib_verbs.h>
443         ],[
444                 ib_map_mr_sg(NULL, NULL, 0, 0);
445         ],[
446                 AC_DEFINE(HAVE_IB_MAP_MR_SG, 1,
447                         [ib_map_mr_sg exists])
448         ])
449
450         # ib_map_mr_sg changes from 4 to 5 args (adding sg_offset_p)
451         # in kernel 4.7 (and RHEL 7.3)
452         LB_CHECK_COMPILE([if 5arg 'ib_map_mr_sg' exists],
453         ib_map_mr_sg_5args, [
454                 #ifdef HAVE_COMPAT_RDMA
455                 #undef PACKAGE_NAME
456                 #undef PACKAGE_TARNAME
457                 #undef PACKAGE_VERSION
458                 #undef PACKAGE_STRING
459                 #undef PACKAGE_BUGREPORT
460                 #undef PACKAGE_URL
461                 #include <linux/compat-2.6.h>
462                 #endif
463                 #include <rdma/ib_verbs.h>
464         ],[
465                 ib_map_mr_sg(NULL, NULL, 0, NULL, 0);
466         ],[
467                 AC_DEFINE(HAVE_IB_MAP_MR_SG, 1,
468                         [ib_map_mr_sg exists])
469                 AC_DEFINE(HAVE_IB_MAP_MR_SG_5ARGS, 1,
470                         [ib_map_mr_sg has 5 arguments])
471         ])
472
473         # ib_query_device() removed in 4.5
474         LB_CHECK_COMPILE([if 'struct ib_device' has member 'attrs'],
475         ib_device.attrs, [
476                 #ifdef HAVE_COMPAT_RDMA
477                 #undef PACKAGE_NAME
478                 #undef PACKAGE_TARNAME
479                 #undef PACKAGE_VERSION
480                 #undef PACKAGE_STRING
481                 #undef PACKAGE_BUGREPORT
482                 #undef PACKAGE_URL
483                 #include <linux/compat-2.6.h>
484                 #endif
485                 #include <rdma/ib_verbs.h>
486         ],[
487                 struct ib_device dev;
488                 struct ib_device_attr dev_attr = {};
489                 dev.attrs = dev_attr;
490         ],[
491                 AC_DEFINE(HAVE_IB_DEVICE_ATTRS, 1,
492                         [struct ib_device.attrs is defined])
493         ])
494
495         # A flags argument was added to ib_alloc_pd() in Linux 4.9,
496         # commit ed082d36a7b2c27d1cda55fdfb28af18040c4a89
497         LB_CHECK_COMPILE([if 2arg 'ib_alloc_pd' exists],
498         ib_alloc_pd, [
499                 #ifdef HAVE_COMPAT_RDMA
500                 #undef PACKAGE_NAME
501                 #undef PACKAGE_TARNAME
502                 #undef PACKAGE_VERSION
503                 #undef PACKAGE_STRING
504                 #undef PACKAGE_BUGREPORT
505                 #undef PACKAGE_URL
506                 #include <linux/compat-2.6.h>
507                 #endif
508                 #include <rdma/ib_verbs.h>
509         ],[
510                 ib_alloc_pd(NULL, 0);
511         ],[
512                 AC_DEFINE(HAVE_IB_ALLOC_PD_2ARGS, 1,
513                         [ib_alloc_pd has 2 arguments])
514         ])
515
516         LB_CHECK_COMPILE([if function 'ib_inc_rkey' is defined],
517         ib_inc_rkey, [
518                 #ifdef HAVE_COMPAT_RDMA
519                 #undef PACKAGE_NAME
520                 #undef PACKAGE_TARNAME
521                 #undef PACKAGE_VERSION
522                 #undef PACKAGE_STRING
523                 #undef PACKAGE_BUGREPORT
524                 #undef PACKAGE_URL
525                 #include <linux/compat-2.6.h>
526                 #endif
527                 #include <rdma/ib_verbs.h>
528         ],[
529                 (void)ib_inc_rkey(0);
530         ],[
531                 AC_DEFINE(HAVE_IB_INC_RKEY, 1,
532                           [function ib_inc_rkey exist])
533         ])
534
535         EXTRA_CHECK_INCLUDE=""
536 ]) # ENABLEO2IB != "no"
537 ]) # LN_CONFIG_O2IB
538
539 #
540 # LN_CONFIG_GNILND
541 #
542 # check whether to use the Gemini Network Interface lnd
543 #
544 AC_DEFUN([LN_CONFIG_GNILND], [
545 AC_MSG_CHECKING([whether to enable GNI lnd])
546 AC_ARG_ENABLE([gni],
547         AC_HELP_STRING([--enable-gni],
548                 [enable GNI lnd]),
549         [], [enable_gni="no"])
550 AC_MSG_RESULT([$enable_gni])
551
552 AS_IF([test "x$enable_gni" = xyes], [
553         # GNICPPFLAGS was set in spec file
554         EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
555         EXTRA_KCFLAGS="$EXTRA_KCFLAGS $GNICPPFLAGS"
556         LB_CHECK_COMPILE([if GNI kernel headers are present],
557         GNI_header, [
558                 #include <linux/types.h>
559                 #include <gni_pub.h>
560         ],[
561                 gni_cdm_handle_t kgni_domain;
562                 gni_return_t     rc;
563                 int              rrc;
564                 rc = gni_cdm_create(0, 1, 1, 0, &kgni_domain);
565                 rrc = (rc == GNI_RC_SUCCESS) ? 0 : 1;
566                 return rrc;
567         ],[
568                 GNILND="gnilnd"
569         ],[
570                 AC_MSG_ERROR([can't compile gnilnd with given GNICPPFLAGS: $GNICPPFLAGS])
571         ])
572         # at this point, we have gnilnd basic support,
573         # now check for extra features
574         LB_CHECK_COMPILE([to use RCA in gnilnd],
575         RCA_gnilnd, [
576                 #include <linux/types.h>
577                 #include <gni_pub.h>
578                 #include <krca_lib.h>
579         ],[
580                 gni_cdm_handle_t kgni_domain;
581                 gni_return_t     rc;
582                 krca_ticket_t    ticket = KRCA_NULL_TICKET;
583                 int              rrc;
584                 __u32            nid = 0, nic_addr;
585                 rc = gni_cdm_create(0, 1, 1, 0, &kgni_domain);
586                 rrc = (rc == GNI_RC_SUCCESS) ? 0 : 1;
587                 rrc += krca_nid_to_nicaddrs(nid, 1, &nic_addr);
588                 rrc += krca_register(&ticket, RCA_MAKE_SERVICE_INDEX(RCA_IO_CLASS, 9), 99, 0);
589                 return rrc;
590         ],[
591                 GNICPPFLAGS="$GNICPPFLAGS -DGNILND_USE_RCA=1"
592         ])
593         EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
594 ])
595 AC_SUBST(GNICPPFLAGS)
596 AC_SUBST(GNILND)
597 ]) # LN_CONFIG_GNILND
598
599 #
600 # LN_CONFIG_SK_SLEEP
601 #
602 # 2.6.35 kernel has sk_sleep function
603 #
604 AC_DEFUN([LN_CONFIG_SK_SLEEP], [
605 LB_CHECK_COMPILE([if Linux kernel has 'sk_sleep'],
606 sk_sleep, [
607         #include <net/sock.h>
608 ],[
609         sk_sleep(NULL);
610 ],[
611         AC_DEFINE(HAVE_SK_SLEEP, 1,
612                   [kernel has sk_sleep])
613 ])
614 ]) # LN_CONFIG_SK_SLEEP
615
616 #
617 # LN_CONFIG_TCP_SENDPAGE
618 #
619 # 2.6.36 tcp_sendpage() first parameter is 'struct sock'
620 # instead of 'struct socket'.
621 #
622 AC_DEFUN([LN_CONFIG_TCP_SENDPAGE], [
623 tmp_flags="$EXTRA_KCFLAGS"
624 EXTRA_KCFLAGS="-Werror"
625 LB_CHECK_COMPILE([if 'tcp_sendpage' first parameter is socket],
626 tcp_sendpage_socket, [
627         #include <linux/net.h>
628         #include <net/tcp.h>
629 ],[
630         tcp_sendpage((struct socket*)0, NULL, 0, 0, 0);
631 ],[
632         AC_DEFINE(HAVE_TCP_SENDPAGE_USE_SOCKET, 1,
633                 [tcp_sendpage use socket as first parameter])
634 ])
635 EXTRA_KCFLAGS="$tmp_flags"
636 ]) # LN_CONFIG_TCP_SENDPAGE
637
638 # LN_CONFIG_SOCK_CREATE_KERN
639 #
640 # 4.x sock_create_kern() added a first parameter as 'struct net *'
641 # instead of int.
642 #
643 AC_DEFUN([LN_CONFIG_SOCK_CREATE_KERN], [
644 tmp_flags="$EXTRA_KCFLAGS"
645 EXTRA_KCFLAGS="-Werror"
646 LB_CHECK_COMPILE([if 'sock_create_kern' first parameter is net],
647 sock_create_kern_net, [
648         #include <linux/net.h>
649         #include <net/net_namespace.h>
650 ],[
651         sock_create_kern((struct net*)0, 0, 0, 0, NULL);
652 ],[
653         AC_DEFINE(HAVE_SOCK_CREATE_KERN_USE_NET, 1,
654                 [sock_create_kern use net as first parameter])
655 ])
656 EXTRA_KCFLAGS="$tmp_flags"
657 ]) # LN_CONFIG_SOCK_CREATE_KERN
658
659 #
660 # LN_CONFIG_SK_DATA_READY
661 #
662 # 3.15 for struct sock the *sk_data_ready() field only takes one argument now
663 #
664 AC_DEFUN([LN_CONFIG_SK_DATA_READY], [
665 tmp_flags="$EXTRA_KCFLAGS"
666 EXTRA_KCFLAGS="-Werror"
667 LB_CHECK_COMPILE([if 'sk_data_ready' takes only one argument],
668 sk_data_ready, [
669         #include <linux/net.h>
670         #include <net/sock.h>
671 ],[
672         ((struct sock *)0)->sk_data_ready(NULL);
673 ],[
674         AC_DEFINE(HAVE_SK_DATA_READY_ONE_ARG, 1,
675                 [sk_data_ready uses only one argument])
676 ])
677 EXTRA_KCFLAGS="$tmp_flags"
678 ]) # LN_CONFIG_SK_DATA_READY
679
680 #
681 # LN_EXPORT_KMAP_TO_PAGE
682 #
683 # 3.10 Export kmap_to_page
684 #
685 AC_DEFUN([LN_EXPORT_KMAP_TO_PAGE], [
686 LB_CHECK_EXPORT([kmap_to_page], [mm/highmem.c],
687         [AC_DEFINE(HAVE_KMAP_TO_PAGE, 1,
688                 [kmap_to_page is exported by the kernel])])
689 ]) # LN_EXPORT_KMAP_TO_PAG
690
691 #
692 # LN_CONFIG_SOCK_ACCEPT
693 #
694 # 4.11 commit cdfbabfb2f0ce983fdaa42f20e5f7842178fc01e added a flag
695 # to handle a possible lockdep condition kernel socket accept.
696 #
697 AC_DEFUN([LN_CONFIG_SOCK_ACCEPT], [
698 tmp_flags="$EXTRA_KCFLAGS"
699 EXTRA_KCFLAGS="-Werror"
700 LB_CHECK_COMPILE([if 'struct sock' accept function requires a bool argument],
701 kern_sock_flag, [
702         #include <linux/net.h>
703 ],[
704         ((struct socket *)0)->ops->accept(NULL, NULL, O_NONBLOCK, false);
705 ],[
706         AC_DEFINE(HAVE_KERN_SOCK_ACCEPT_FLAG_ARG, 1,
707                 ['struct sock' accept function requires bool argument])
708 ])
709 EXTRA_KCFLAGS="$tmp_flags"
710 ]) # LN_CONFIG_SOCK_ACCEPT
711
712 #
713 # LN_PROG_LINUX
714 #
715 # LNet linux kernel checks
716 #
717 AC_DEFUN([LN_PROG_LINUX], [
718 AC_MSG_NOTICE([LNet kernel checks
719 ==============================================================================])
720
721 LN_CONFIG_AFFINITY
722 LN_CONFIG_BACKOFF
723 LN_CONFIG_O2IB
724 LN_CONFIG_GNILND
725 # 2.6.35
726 LN_CONFIG_SK_SLEEP
727 # 2.6.36
728 LN_CONFIG_TCP_SENDPAGE
729 # 3.10
730 LN_EXPORT_KMAP_TO_PAGE
731 # 3.15
732 LN_CONFIG_SK_DATA_READY
733 # 4.x
734 LN_CONFIG_SOCK_CREATE_KERN
735 # 4.11
736 LN_CONFIG_SOCK_ACCEPT
737 ]) # LN_PROG_LINUX
738
739 #
740 # LN_PATH_DEFAULTS
741 #
742 # default paths for installed files
743 #
744 AC_DEFUN([LN_PATH_DEFAULTS], [
745 ]) # LN_PATH_DEFAULTS
746
747 #
748 # LN_CONFIGURE
749 #
750 # other configure checks
751 #
752 AC_DEFUN([LN_CONFIGURE], [
753 AC_MSG_NOTICE([LNet core checks
754 ==============================================================================])
755
756 # lnet/utils/portals.c
757 AC_CHECK_HEADERS([netdb.h])
758 AC_CHECK_FUNCS([gethostbyname])
759
760 # lnet/utils/wirecheck.c
761 AC_CHECK_FUNCS([strnlen])
762
763 # --------  Check for required packages  --------------
764
765 AC_MSG_CHECKING([whether to enable 'efence' debugging support])
766 AC_ARG_ENABLE(efence,
767         AC_HELP_STRING([--enable-efence],
768                 [use efence library]),
769         [], [enable_efence="no"])
770 AC_MSG_RESULT([$enable_efence])
771
772 LIBEFENCE=""
773 AS_IF([test "$enable_efence" = yes], [
774         LIBEFENCE="-lefence"
775         AC_DEFINE(HAVE_LIBEFENCE, 1,
776                 [libefence support is requested])
777 ])
778 AC_SUBST(LIBEFENCE)
779
780 LN_CONFIG_DLC
781 ]) # LN_CONFIGURE
782
783 #
784 # LN_CONDITIONALS
785 #
786 # AM_CONDITIONAL defines for lnet
787 #
788 AC_DEFUN([LN_CONDITIONALS], [
789 AM_CONDITIONAL(BUILD_O2IBLND,    test x$O2IBLND = "xo2iblnd")
790 AM_CONDITIONAL(BUILD_GNILND,     test x$GNILND  = "xgnilnd")
791 ]) # LN_CONDITIONALS
792
793 #
794 # LN_CONFIG_FILES
795 #
796 # files that should be generated with AC_OUTPUT
797 #
798 AC_DEFUN([LN_CONFIG_FILES], [
799 AC_CONFIG_FILES([
800 lnet/Makefile
801 lnet/autoMakefile
802 lnet/autoconf/Makefile
803 lnet/doc/Makefile
804 lnet/include/Makefile
805 lnet/include/lnet/Makefile
806 lnet/include/uapi/linux/lnet/Makefile
807 lnet/klnds/Makefile
808 lnet/klnds/autoMakefile
809 lnet/klnds/o2iblnd/Makefile
810 lnet/klnds/o2iblnd/autoMakefile
811 lnet/klnds/gnilnd/Makefile
812 lnet/klnds/gnilnd/autoMakefile
813 lnet/klnds/socklnd/Makefile
814 lnet/klnds/socklnd/autoMakefile
815 lnet/lnet/Makefile
816 lnet/lnet/autoMakefile
817 lnet/selftest/Makefile
818 lnet/selftest/autoMakefile
819 lnet/utils/Makefile
820 lnet/utils/lnetconfig/Makefile
821 ])
822 ]) # LN_CONFIG_FILES