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