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