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