Whamcloud - gitweb
3443063a84ccfeaeb03cea8173416b62b5388384
[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                 LNET_MAX_PAYLOAD_MB=$with_max_payload_mb
14                 LNET_MAX_PAYLOAD="(($with_max_payload_mb)<<20)"
15         ], [
16                 AC_MSG_RESULT([no])
17                 LNET_MAX_PAYLOAD="LNET_MTU"
18         ])
19         AC_DEFINE_UNQUOTED(LNET_MAX_PAYLOAD, $LNET_MAX_PAYLOAD,
20                            [Max LNET payload])
21 ])
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 ])
43
44 #
45 # LN_CONFIG_AFFINITY
46 #
47 # check if cpu affinity is available/wanted
48 #
49 AC_DEFUN([LN_CONFIG_AFFINITY],
50 [AC_ARG_ENABLE([affinity],
51         AC_HELP_STRING([--disable-affinity],
52                        [disable process/irq affinity]),
53         [],[enable_affinity='yes'])
54
55 AC_MSG_CHECKING([for CPU affinity support])
56 if test x$enable_affinity = xno ; then
57         AC_MSG_RESULT([no (by request)])
58 else
59         LB_LINUX_TRY_COMPILE([
60                 #include <linux/sched.h>
61         ],[
62                 struct task_struct t;
63                 #if HAVE_CPUMASK_T
64                 cpumask_t     m;
65                 #else
66                 unsigned long m;
67                 #endif
68                 set_cpus_allowed(&t, m);
69         ],[
70                 AC_DEFINE(CPU_AFFINITY, 1, [kernel has cpu affinity support])
71                 AC_MSG_RESULT([yes])
72         ],[
73                 AC_MSG_RESULT([no (no kernel support)])
74         ])
75 fi
76 ])
77
78 #
79 # LN_CONFIG_PORTALS
80 #
81 # configure support for Portals
82 #
83 AC_DEFUN([LN_CONFIG_PORTALS],
84 [AC_MSG_CHECKING([for portals])
85 AC_ARG_WITH([portals],
86         AC_HELP_STRING([--with-portals=path],
87                        [set path to portals]),
88         [
89                 case $with_portals in
90                         no)     ENABLEPORTALS=0
91                                 ;;
92                         *)      PORTALS="${with_portals}"
93                                 ENABLEPORTALS=1
94                                 ;;
95                 esac
96         ], [
97                 ENABLEPORTALS=0
98         ])
99 PTLLNDCPPFLAGS=""
100 if test $ENABLEPORTALS -eq 0; then
101         AC_MSG_RESULT([no])
102 elif test ! \( -f ${PORTALS}/include/portals/p30.h \); then
103         AC_MSG_RESULT([no])
104         AC_MSG_ERROR([bad --with-portals path])
105 else
106         AC_MSG_RESULT([$PORTALS])
107         PTLLNDCPPFLAGS="-I${PORTALS}/include"
108 fi
109 AC_SUBST(PTLLNDCPPFLAGS)
110 ])
111
112 #
113 # LN_CONFIG_BACKOFF
114 #
115 # check if tunable tcp backoff is available/wanted
116 #
117 AC_DEFUN([LN_CONFIG_BACKOFF],
118 [AC_MSG_CHECKING([for tunable backoff TCP support])
119 AC_ARG_ENABLE([backoff],
120        AC_HELP_STRING([--disable-backoff],
121                       [disable socknal tunable backoff]),
122        [],[enable_backoff='yes'])
123 if test x$enable_backoff = xno ; then
124        AC_MSG_RESULT([no (by request)])
125 else
126        BOCD="`grep -c TCP_BACKOFF $LINUX/include/linux/tcp.h`"
127        if test "$BOCD" != 0 ; then
128                AC_DEFINE(SOCKNAL_BACKOFF, 1, [use tunable backoff TCP])
129                AC_MSG_RESULT(yes)
130        else
131                AC_MSG_RESULT([no (no kernel support)])
132        fi
133 fi
134 ])
135
136
137 #
138 # LN_CONFIG_PTLLND
139 #
140 # configure support for Portals LND
141 #
142 AC_DEFUN([LN_CONFIG_PTLLND],
143 [
144 if test -z "$ENABLEPORTALS"; then
145         LN_CONFIG_PORTALS
146 fi
147
148 AC_MSG_CHECKING([whether to build the kernel portals LND])
149
150 PTLLND=""
151 if test $ENABLEPORTALS -ne 0; then
152         AC_MSG_RESULT([yes])
153         PTLLND="ptllnd"
154 else
155         AC_MSG_RESULT([no])
156 fi
157 AC_SUBST(PTLLND)
158 ])
159
160 #
161 # LN_CONFIG_UPTLLND
162 #
163 # configure support for Portals LND
164 #
165 AC_DEFUN([LN_CONFIG_UPTLLND],
166 [
167 if test -z "$ENABLEPORTALS"; then
168         LN_CONFIG_PORTALS
169 fi
170
171 AC_MSG_CHECKING([whether to build the userspace portals LND])
172
173 UPTLLND=""
174 if test $ENABLEPORTALS -ne 0; then
175         AC_MSG_RESULT([yes])
176         UPTLLND="ptllnd"
177 else
178         AC_MSG_RESULT([no])
179 fi
180 AC_SUBST(UPTLLND)
181 ])
182
183 #
184 # LN_CONFIG_USOCKLND
185 #
186 # configure support for userspace TCP/IP LND
187 #
188 AC_DEFUN([LN_CONFIG_USOCKLND],
189 [AC_MSG_CHECKING([whether to build usocklnd])
190 AC_ARG_ENABLE([usocklnd],
191         AC_HELP_STRING([--disable-usocklnd],
192                         [disable usocklnd]),
193         [],[enable_usocklnd='yes'])
194
195 if test x$enable_usocklnd = xyes ; then
196         if test "$ENABLE_LIBPTHREAD" = "yes" ; then
197                 AC_MSG_RESULT([yes])
198                 USOCKLND="usocklnd"
199         else
200                 AC_MSG_RESULT([no (libpthread not present or disabled)])
201                 USOCKLND=""
202         fi
203 else
204         AC_MSG_RESULT([no (disabled explicitly)])
205         USOCKLND=""
206 fi
207 AC_SUBST(USOCKLND)
208 ])
209
210 #
211 # LN_CONFIG_QUADRICS
212 #
213 # check if quadrics support is in this kernel
214 #
215 AC_DEFUN([LN_CONFIG_QUADRICS],
216 [AC_MSG_CHECKING([for QsNet sources])
217 AC_ARG_WITH([qsnet],
218         AC_HELP_STRING([--with-qsnet=path],
219                        [set path to qsnet source (default=$LINUX)]),
220         [QSNET=$with_qsnet],
221         [QSNET=$LINUX])
222 AC_MSG_RESULT([$QSNET])
223
224 AC_MSG_CHECKING([if quadrics kernel headers are present])
225 if test -d $QSNET/drivers/net/qsnet ; then
226         AC_MSG_RESULT([yes])
227         QSWLND="qswlnd"
228         AC_MSG_CHECKING([for multirail EKC])
229         if test -f $QSNET/include/elan/epcomms.h; then
230                 AC_MSG_RESULT([supported])
231                 QSWCPPFLAGS="-I$QSNET/include -DMULTIRAIL_EKC=1"
232         else
233                 AC_MSG_RESULT([not supported])
234                 AC_MSG_ERROR([Need multirail EKC])
235         fi
236
237         if test x$QSNET = x$LINUX ; then
238                 LB_LINUX_CONFIG([QSNET],[],[
239                         LB_LINUX_CONFIG([QSNET_MODULE],[],[
240                                 AC_MSG_WARN([QSNET is not enabled in this kernel; not building qswlnd.])
241                                 QSWLND=""
242                                 QSWCPPFLAGS=""
243                         ])
244                 ])
245         fi
246 else
247         AC_MSG_RESULT([no])
248         QSWLND=""
249         QSWCPPFLAGS=""
250 fi
251 AC_SUBST(QSWCPPFLAGS)
252 AC_SUBST(QSWLND)
253 ])
254
255 #
256 # LN_CONFIG_GM
257 #
258 # check if GM support is available
259 #
260 AC_DEFUN([LN_CONFIG_GM],[
261 AC_MSG_CHECKING([whether to enable GM support])
262 AC_ARG_WITH([gm],
263         AC_HELP_STRING([--with-gm=path-to-gm-source-tree],
264                        [build gmlnd against path]),
265         [
266                 case $with_gm in
267                 no)    ENABLE_GM=0
268                        ;;
269                 *)     ENABLE_GM=1
270                        GM_SRC="$with_gm"
271                        ;;
272                 esac
273         ],[
274                 ENABLE_GM=0
275         ])
276 AC_ARG_WITH([gm-install],
277         AC_HELP_STRING([--with-gm-install=path-to-gm-install-tree],
278                        [say where GM has been installed]),
279         [
280                 GM_INSTALL=$with_gm_install
281         ],[
282                 GM_INSTALL="/opt/gm"
283         ])
284 if test $ENABLE_GM -eq 0; then
285         AC_MSG_RESULT([no])
286 else
287         AC_MSG_RESULT([yes])
288
289         GMLND="gmlnd"
290         GMCPPFLAGS="-I$GM_SRC/include -I$GM_SRC/drivers -I$GM_SRC/drivers/linux/gm"
291
292         if test -f $GM_INSTALL/lib/libgm.a -o \
293                 -f $GM_INSTALL/lib64/libgm.a; then
294                 GMLIBS="-L$GM_INSTALL/lib -L$GM_INSTALL/lib64"
295         else
296                 AC_MSG_ERROR([Cant find GM libraries under $GM_INSTALL])
297         fi
298
299         EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
300         EXTRA_KCFLAGS="$GMCPPFLAGS -DGM_KERNEL $EXTRA_KCFLAGS"
301
302         AC_MSG_CHECKING([that code using GM compiles with given path])
303         LB_LINUX_TRY_COMPILE([
304                 #define GM_STRONG_TYPES 1
305                 #ifdef VERSION
306                 #undef VERSION
307                 #endif
308                 #include "gm.h"
309                 #include "gm_internal.h"
310         ],[
311                 struct gm_port *port = NULL;
312                 gm_recv_event_t *rxevent = gm_blocking_receive_no_spin(port);
313                 return 0;
314         ],[
315                 AC_MSG_RESULT([yes])
316         ],[
317                 AC_MSG_RESULT([no])
318                 AC_MSG_ERROR([Bad --with-gm path])
319         ])
320
321         AC_MSG_CHECKING([that GM has gm_register_memory_ex_phys()])
322         LB_LINUX_TRY_COMPILE([
323                 #define GM_STRONG_TYPES 1
324                 #ifdef VERSION
325                 #undef VERSION
326                 #endif
327                 #include "gm.h"
328                 #include "gm_internal.h"
329         ],[
330                 gm_status_t     gmrc;
331                 struct gm_port *port = NULL;
332                 gm_u64_t        phys = 0;
333                 gm_up_t         pvma = 0;
334
335                 gmrc = gm_register_memory_ex_phys(port, phys, 100, pvma);
336                 return 0;
337         ],[
338                 AC_MSG_RESULT([yes])
339         ],[
340                 AC_MSG_RESULT([no.
341 Please patch the GM sources as follows...
342     cd $GM_SRC
343     patch -p0 < $PWD/lnet/klnds/gmlnd/gm-reg-phys.patch
344 ...then rebuild and re-install them])
345                 AC_MSG_ERROR([Can't build GM without gm_register_memory_ex_phys()])
346         ])
347
348         EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
349 fi
350 AC_SUBST(GMCPPFLAGS)
351 AC_SUBST(GMLIBS)
352 AC_SUBST(GMLND)
353 ])
354
355
356 #
357 # LN_CONFIG_MX
358 #
359 AC_DEFUN([LN_CONFIG_MX],
360 [AC_MSG_CHECKING([whether to enable Myrinet MX support])
361 # set default
362 MXPATH="/opt/mx"
363 AC_ARG_WITH([mx],
364        AC_HELP_STRING([--with-mx=path],
365                       [build mxlnd against path]),
366        [
367                case $with_mx in
368                yes)    ENABLEMX=2
369                        ;;
370                no)     ENABLEMX=0
371                        ;;
372                *)      MXPATH=$with_mx
373                        ENABLEMX=3
374                        ;;
375                esac
376        ],[
377                ENABLEMX=1
378        ])
379 if test $ENABLEMX -eq 0; then
380        AC_MSG_RESULT([disabled])
381 elif test ! \( -f ${MXPATH}/include/myriexpress.h -a \
382               -f ${MXPATH}/include/mx_kernel_api.h -a \
383               -f ${MXPATH}/include/mx_pin.h \); then
384        AC_MSG_RESULT([no])
385        case $ENABLEMX in
386        1) ;;
387        2) AC_MSG_ERROR([Myrinet MX kernel headers not present]);;
388        3) AC_MSG_ERROR([bad --with-mx path]);;
389        *) AC_MSG_ERROR([internal error]);;
390        esac
391 else
392        MXCPPFLAGS="-I$MXPATH/include"
393        EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
394        EXTRA_KCFLAGS="$EXTRA_KCFLAGS $MXCPPFLAGS"
395        MXLIBS="-L$MXPATH/lib"
396        LB_LINUX_TRY_COMPILE([
397                #define MX_KERNEL 1
398                #include <mx_extensions.h>
399                #include <myriexpress.h>
400        ],[
401                mx_endpoint_t   end;
402                mx_status_t     status;
403                mx_request_t    request;
404                int             result;
405
406                mx_init();
407                mx_open_endpoint(MX_ANY_NIC, MX_ANY_ENDPOINT, 0, NULL, 0, &end);
408                mx_register_unexp_handler(end, (mx_unexp_handler_t) NULL, NULL);
409                mx_wait_any(end, MX_INFINITE, 0LL, 0LL, &status, &result);
410                mx_iconnect(end, 0LL, 0, 0, 0, NULL, &request);
411                return 0;
412        ],[
413                AC_MSG_RESULT([yes])
414                MXLND="mxlnd"
415        ],[
416                AC_MSG_RESULT([no])
417                case $ENABLEMX in
418                1) ;;
419                2) AC_MSG_ERROR([can't compile with Myrinet MX kernel headers]);;
420                3) AC_MSG_ERROR([can't compile with Myrinet MX headers under $MXPATH]);;
421                *) AC_MSG_ERROR([internal error]);;
422                esac
423                MXLND=""
424                MXCPPFLAGS=""
425        ])
426        EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
427 fi
428 AC_SUBST(MXCPPFLAGS)
429 AC_SUBST(MXLIBS)
430 AC_SUBST(MXLND)
431 ])
432
433
434
435 #
436 # LN_CONFIG_O2IB
437 #
438 AC_DEFUN([LN_CONFIG_O2IB],[
439 AC_MSG_CHECKING([whether to enable OpenIB gen2 support])
440 # set default
441 AC_ARG_WITH([o2ib],
442         AC_HELP_STRING([--with-o2ib=path],
443                        [build o2iblnd against path]),
444         [
445                 case $with_o2ib in
446                 yes)    O2IBPATHS="$LINUX $LINUX/drivers/infiniband"
447                         ENABLEO2IB=2
448                         ;;
449                 no)     ENABLEO2IB=0
450                         ;;
451                 *)      O2IBPATHS=$with_o2ib
452                         ENABLEO2IB=3
453                         ;;
454                 esac
455         ],[
456                 O2IBPATHS="$LINUX $LINUX/drivers/infiniband"
457                 ENABLEO2IB=1
458         ])
459 if test $ENABLEO2IB -eq 0; then
460         AC_MSG_RESULT([disabled])
461 else
462         o2ib_found=false
463         for O2IBPATH in $O2IBPATHS; do
464                 if test \( -f ${O2IBPATH}/include/rdma/rdma_cm.h -a \
465                            -f ${O2IBPATH}/include/rdma/ib_cm.h -a \
466                            -f ${O2IBPATH}/include/rdma/ib_verbs.h -a \
467                            -f ${O2IBPATH}/include/rdma/ib_fmr_pool.h \); then
468                         o2ib_found=true
469                         break
470                 fi
471         done
472         if ! $o2ib_found; then
473                 AC_MSG_RESULT([no])
474                 case $ENABLEO2IB in
475                         1) ;;
476                         2) AC_MSG_ERROR([kernel OpenIB gen2 headers not present]);;
477                         3) AC_MSG_ERROR([bad --with-o2ib path]);;
478                         *) AC_MSG_ERROR([internal error]);;
479                 esac
480         else
481                 O2IBCPPFLAGS="-I$O2IBPATH/include"
482                 EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
483                 EXTRA_KCFLAGS="$EXTRA_KCFLAGS $O2IBCPPFLAGS"
484                 EXTRA_LNET_INCLUDE="$O2IBCPPFLAGS $EXTRA_LNET_INCLUDE"
485                 LB_LINUX_TRY_COMPILE([
486                         #include <linux/version.h>
487                         #include <linux/pci.h>
488                         #if !HAVE_GFP_T
489                         typedef int gfp_t;
490                         #endif
491                         #include <rdma/rdma_cm.h>
492                         #include <rdma/ib_cm.h>
493                         #include <rdma/ib_verbs.h>
494                         #include <rdma/ib_fmr_pool.h>
495                 ],[
496                         struct rdma_cm_id          *cm_id;
497                         struct rdma_conn_param      conn_param;
498                         struct ib_device_attr       device_attr;
499                         struct ib_qp_attr           qp_attr;
500                         struct ib_pool_fmr          pool_fmr;
501                         enum   ib_cm_rej_reason     rej_reason;
502
503                         cm_id = rdma_create_id(NULL, NULL, RDMA_PS_TCP);
504                         return PTR_ERR(cm_id);
505                 ],[
506                         AC_MSG_RESULT([yes])
507                         O2IBLND="o2iblnd"
508                 ],[
509                         AC_MSG_RESULT([no])
510                         case $ENABLEO2IB in
511                         1) ;;
512                         2) AC_MSG_ERROR([can't compile with kernel OpenIB gen2 headers]);;
513                         3) AC_MSG_ERROR([can't compile with OpenIB gen2 headers under $O2IBPATH]);;
514                         *) AC_MSG_ERROR([internal error]);;
515                         esac
516                         O2IBLND=""
517                         O2IBCPPFLAGS=""
518                 ])
519
520                 # we know at this point that the found OFED source is good
521                 if test \( $ENABLEO2IB = 3 \); then
522                         if test \( -f $O2IBPATH/Module.symvers \); then
523                                 AC_MSG_NOTICE([adding $O2IBPATH/Module.symvers to $PWD/$SYMVERFILE])
524                                 # strip out the existing symbols versions first
525                                 touch $O2IBPATH/Module.symvers
526                                 egrep -v $(echo $(awk '{ print $2 }' $O2IBPATH/Module.symvers) | tr ' ' '|') $PWD/$SYMVERFILE > $PWD/$SYMVERFILE.old
527                                 cat $PWD/$SYMVERFILE.old $O2IBPATH/Module.symvers > $PWD/$SYMVERFILE
528                         else
529                                 AC_MSG_ERROR([an external source tree was specified for o2iblnd however I could not find a $O2IBPATH/Module.symvers there])
530                         fi
531                 fi
532
533                 # version checking is a hack and isn't reliable,
534                 # we need verify it with each new ofed release
535
536                 if grep -q ib_dma_map_single \
537                         ${O2IBPATH}/include/rdma/ib_verbs.h; then
538                         if grep -q comp_vector \
539                                 ${O2IBPATH}/include/rdma/ib_verbs.h; then
540                                 IBLND_OFED_VERSION="1025"
541                         else
542                                 IBLND_OFED_VERSION="1020"
543                         fi
544                 else
545                         IBLND_OFED_VERSION="1010"
546                 fi
547
548                 AC_DEFINE_UNQUOTED(IBLND_OFED_VERSION, $IBLND_OFED_VERSION,
549                                    [OFED version])
550
551                 EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
552         fi
553 fi
554
555 AC_SUBST(EXTRA_LNET_INCLUDE)
556 AC_SUBST(O2IBCPPFLAGS)
557 AC_SUBST(O2IBLND)
558 ])
559
560 #
561 # LN_CONFIG_OPENIB
562 #
563 # check for OpenIB in the kernel
564 AC_DEFUN([LN_CONFIG_OPENIB],[
565 AC_MSG_CHECKING([whether to enable OpenIB support])
566 # set default
567 OPENIBPATH="$LINUX/drivers/infiniband"
568 AC_ARG_WITH([openib],
569         AC_HELP_STRING([--with-openib=path],
570                        [build openiblnd against path]),
571         [
572                 case $with_openib in
573                 yes)    ENABLEOPENIB=2
574                         ;;
575                 no)     ENABLEOPENIB=0
576                         ;;
577                 *)      OPENIBPATH="$with_openib"
578                         ENABLEOPENIB=3
579                         ;;
580                 esac
581         ],[
582                 ENABLEOPENIB=1
583         ])
584 if test $ENABLEOPENIB -eq 0; then
585         AC_MSG_RESULT([disabled])
586 elif test ! \( -f ${OPENIBPATH}/include/ts_ib_core.h -a \
587                -f ${OPENIBPATH}/include/ts_ib_cm.h -a \
588                -f ${OPENIBPATH}/include/ts_ib_sa_client.h \); then
589         AC_MSG_RESULT([no])
590         case $ENABLEOPENIB in
591         1) ;;
592         2) AC_MSG_ERROR([kernel OpenIB headers not present]);;
593         3) AC_MSG_ERROR([bad --with-openib path]);;
594         *) AC_MSG_ERROR([internal error]);;
595         esac
596 else
597         case $ENABLEOPENIB in
598         1|2) OPENIBCPPFLAGS="-I$OPENIBPATH/include -DIN_TREE_BUILD";;
599         3)   OPENIBCPPFLAGS="-I$OPENIBPATH/include";;
600         *)   AC_MSG_RESULT([no])
601              AC_MSG_ERROR([internal error]);;
602         esac
603         OPENIBCPPFLAGS="$OPENIBCPPFLAGS -DIB_NTXRXPARAMS=4"
604         EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
605         EXTRA_KCFLAGS="$EXTRA_KCFLAGS $OPENIBCPPFLAGS"
606         LB_LINUX_TRY_COMPILE([
607                 #include <ts_ib_core.h>
608                 #include <ts_ib_cm.h>
609                 #include <ts_ib_sa_client.h>
610         ],[
611                 struct ib_device_properties dev_props;
612                 struct ib_cm_active_param   cm_active_params;
613                 tTS_IB_CLIENT_QUERY_TID     tid;
614                 int                         enum1 = IB_QP_ATTRIBUTE_STATE;
615                 int                         enum2 = IB_ACCESS_LOCAL_WRITE;
616                 int                         enum3 = IB_CQ_CALLBACK_INTERRUPT;
617                 int                         enum4 = IB_CQ_PROVIDER_REARM;
618                 return 0;
619         ],[
620                 AC_MSG_RESULT([yes])
621                 OPENIBLND="openiblnd"
622         ],[
623                 AC_MSG_RESULT([no])
624                 case $ENABLEOPENIB in
625                 1) ;;
626                 2) AC_MSG_ERROR([can't compile with kernel OpenIB headers]);;
627                 3) AC_MSG_ERROR([can't compile with OpenIB headers under $OPENIBPATH]);;
628                 *) AC_MSG_ERROR([internal error]);;
629                 esac
630                 OPENIBLND=""
631                 OPENIBCPPFLAGS=""
632         ])
633         EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
634 fi
635 AC_SUBST(OPENIBCPPFLAGS)
636 AC_SUBST(OPENIBLND)
637 ])
638
639 #
640 # LN_CONFIG_CIBLND
641 #
642 AC_DEFUN([LN_CONFIG_CIB],[
643 AC_MSG_CHECKING([whether to enable Cisco/TopSpin IB support])
644 # set default
645 CIBPATH=""
646 CIBLND=""
647 AC_ARG_WITH([cib],
648         AC_HELP_STRING([--with-cib=path],
649                        [build ciblnd against path]),
650         [
651                 case $with_cib in
652                 no)     AC_MSG_RESULT([no]);;
653                 *)      CIBPATH="$with_cib"
654                         if test -d "$CIBPATH"; then
655                                 AC_MSG_RESULT([yes])
656                         else
657                                 AC_MSG_RESULT([no])
658                                 AC_MSG_ERROR([No directory $CIBPATH])
659                         fi;;
660                 esac
661         ],[
662                 AC_MSG_RESULT([no])
663         ])
664 if test -n "$CIBPATH"; then
665         CIBCPPFLAGS="-I${CIBPATH}/ib/ts_api_ng/include -I${CIBPATH}/all/kernel_services/include -DUSING_TSAPI"
666         CIBCPPFLAGS="$CIBCPPFLAGS -DIB_NTXRXPARAMS=3"
667         EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
668         EXTRA_KCFLAGS="$EXTRA_KCFLAGS $CIBCPPFLAGS"
669         LB_LINUX_TRY_COMPILE([
670                 #include <ts_ib_core.h>
671                 #include <ts_ib_cm.h>
672                 #include <ts_ib_sa_client.h>
673         ],[
674                 struct ib_device_properties dev_props;
675                 struct ib_cm_active_param   cm_active_params;
676                 tTS_IB_CLIENT_QUERY_TID     tid;
677                 int                         enum1 = TS_IB_QP_ATTRIBUTE_STATE;
678                 int                         enum2 = TS_IB_ACCESS_LOCAL_WRITE;
679                 int                         enum3 = TS_IB_CQ_CALLBACK_INTERRUPT;
680                 int                         enum4 = TS_IB_CQ_PROVIDER_REARM;
681                 return 0;
682         ],[
683                 CIBLND="ciblnd"
684         ],[
685                 AC_MSG_ERROR([can't compile ciblnd with given path])
686                 CIBCPPFLAGS=""
687         ])
688         EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
689 fi
690 AC_SUBST(CIBCPPFLAGS)
691 AC_SUBST(CIBLND)
692 ])
693
694 #
695 # LN_CONFIG_IIB
696 #
697 # check for infinicon infiniband support
698 #
699 AC_DEFUN([LN_CONFIG_IIB],[
700 AC_MSG_CHECKING([whether to enable Infinicon support])
701 # set default
702 IIBPATH="/usr/include"
703 AC_ARG_WITH([iib],
704         AC_HELP_STRING([--with-iib=path],
705                        [build iiblnd against path]),
706         [
707                 case $with_iib in
708                 yes)    ENABLEIIB=2
709                         ;;
710                 no)     ENABLEIIB=0
711                         ;;
712                 *)      IIBPATH="${with_iib}/include"
713                         ENABLEIIB=3
714                         ;;
715                 esac
716         ],[
717                 ENABLEIIB=1
718         ])
719 if test $ENABLEIIB -eq 0; then
720         AC_MSG_RESULT([disabled])
721 elif test ! \( -f ${IIBPATH}/linux/iba/ibt.h \); then
722         AC_MSG_RESULT([no])
723         case $ENABLEIIB in
724         1) ;;
725         2) AC_MSG_ERROR([default Infinicon headers not present]);;
726         3) AC_MSG_ERROR([bad --with-iib path]);;
727         *) AC_MSG_ERROR([internal error]);;
728         esac
729 else
730         IIBCPPFLAGS="-I$IIBPATH"
731         if test $IIBPATH != "/usr/include"; then
732                 # we need /usr/include come what may
733                 IIBCPPFLAGS="$IIBCPPFLAGS -I/usr/include"
734         fi
735         EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
736         EXTRA_KCFLAGS="$EXTRA_KCFLAGS $IIBCPPFLAGS"
737         LB_LINUX_TRY_COMPILE([
738                 #include <linux/iba/ibt.h>
739         ],[
740                 IBT_INTERFACE_UNION interfaces;
741                 FSTATUS             rc;
742
743                  rc = IbtGetInterfaceByVersion(IBT_INTERFACE_VERSION_2,
744                                                &interfaces);
745
746                 return rc == FSUCCESS ? 0 : 1;
747         ],[
748                 AC_MSG_RESULT([yes])
749                 IIBLND="iiblnd"
750         ],[
751                 AC_MSG_RESULT([no])
752                 case $ENABLEIIB in
753                 1) ;;
754                 2) AC_MSG_ERROR([can't compile with default Infinicon headers]);;
755                 3) AC_MSG_ERROR([can't compile with Infinicon headers under $IIBPATH]);;
756                 *) AC_MSG_ERROR([internal error]);;
757                 esac
758                 IIBLND=""
759                 IIBCPPFLAGS=""
760         ])
761         EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
762 fi
763 AC_SUBST(IIBCPPFLAGS)
764 AC_SUBST(IIBLND)
765 ])
766
767 #
768 # LN_CONFIG_VIB
769 #
770 # check for Voltaire infiniband support
771 #
772 AC_DEFUN([LN_CONFIG_VIB],
773 [AC_MSG_CHECKING([whether to enable Voltaire IB support])
774 VIBPATH=""
775 AC_ARG_WITH([vib],
776         AC_HELP_STRING([--with-vib=path],
777                        [build viblnd against path]),
778         [
779                 case $with_vib in
780                 no)     AC_MSG_RESULT([no]);;
781                 *)      VIBPATH="${with_vib}/src/nvigor/ib-code"
782                         if test -d "$with_vib" -a -d "$VIBPATH"; then
783                                 AC_MSG_RESULT([yes])
784                         else
785                                 AC_MSG_RESULT([no])
786                                 AC_MSG_ERROR([No directory $VIBPATH])
787                         fi;;
788                 esac
789         ],[
790                 AC_MSG_RESULT([no])
791         ])
792 if test -z "$VIBPATH"; then
793         VIBLND=""
794 else
795         VIBCPPFLAGS="-I${VIBPATH}/include -I${VIBPATH}/cm"
796         EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
797         EXTRA_KCFLAGS="$EXTRA_KCFLAGS $VIBCPPFLAGS"
798         LB_LINUX_TRY_COMPILE([
799                 #include <linux/list.h>
800                 #include <asm/byteorder.h>
801                 #ifdef __BIG_ENDIAN
802                 # define CPU_BE 1
803                 # define CPU_LE 0
804                 #endif
805                 #ifdef __LITTLE_ENDIAN
806                 # define CPU_BE 0
807                 # define CPU_LE 1
808                 #endif
809                 #include <vverbs.h>
810                 #include <ib-cm.h>
811                 #include <ibat.h>
812         ],[
813                 vv_hca_h_t       kib_hca;
814                 vv_return_t      vvrc;
815                 cm_cep_handle_t  cep;
816                 ibat_arp_data_t  arp_data;
817                 ibat_stat_t      ibatrc;
818
819                 vvrc = vv_hca_open("ANY_HCA", NULL, &kib_hca);
820                 cep = cm_create_cep(cm_cep_transp_rc);
821                 ibatrc = ibat_get_ib_data((uint32_t)0, (uint32_t)0,
822                                           ibat_paths_primary, &arp_data,
823                                           (ibat_get_ib_data_reply_fn_t)NULL,
824                                           NULL, 0);
825                 return 0;
826         ],[
827                 VIBLND="viblnd"
828         ],[
829                 AC_MSG_ERROR([can't compile viblnd with given path])
830         ])
831         EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
832 fi
833 if test -n "$VIBLND"; then
834         EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
835         EXTRA_KCFLAGS="$EXTRA_KCFLAGS $VIBCPPFLAGS"
836         AC_MSG_CHECKING([if Voltaire still uses void * sg addresses])
837         LB_LINUX_TRY_COMPILE([
838                 #include <linux/list.h>
839                 #include <asm/byteorder.h>
840                 #ifdef __BIG_ENDIAN
841                 # define CPU_BE 1
842                 # define CPU_LE 0
843                 #endif
844                 #ifdef __LITTLE_ENDIAN
845                 # define CPU_BE 0
846                 # define CPU_LE 1
847                 #endif
848                 #include <vverbs.h>
849                 #include <ib-cm.h>
850                 #include <ibat.h>
851         ],[
852                 vv_scatgat_t  sg;
853
854                 return &sg.v_address[3] == NULL;
855         ],[
856                 AC_MSG_RESULT([yes])
857                 VIBCPPFLAGS="$VIBCPPFLAGS -DIBNAL_VOIDSTAR_SGADDR=1"
858         ],[
859                 AC_MSG_RESULT([no])
860         ])
861         EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
862 fi
863 AC_SUBST(VIBCPPFLAGS)
864 AC_SUBST(VIBLND)
865 ])
866
867 #
868 # LN_CONFIG_RALND
869 #
870 # check whether to use the RapidArray lnd
871 #
872 AC_DEFUN([LN_CONFIG_RALND],
873 [#### Rapid Array
874 AC_MSG_CHECKING([if RapidArray kernel headers are present])
875 # placeholder
876 RACPPFLAGS="-I${LINUX}/drivers/xd1/include"
877 EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
878 EXTRA_KCFLAGS="$EXTRA_KCFLAGS $RACPPFLAGS"
879 LB_LINUX_TRY_COMPILE([
880         #include <linux/types.h>
881         #include <rapl.h>
882 ],[
883         RAP_RETURN          rc;
884         RAP_PVOID           dev_handle;
885
886         rc = RapkGetDeviceByIndex(0, NULL, &dev_handle);
887
888         return rc == RAP_SUCCESS ? 0 : 1;
889 ],[
890         AC_MSG_RESULT([yes])
891         RALND="ralnd"
892 ],[
893         AC_MSG_RESULT([no])
894         RALND=""
895         RACPPFLAGS=""
896 ])
897 EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
898 AC_SUBST(RACPPFLAGS)
899 AC_SUBST(RALND)
900 ])
901
902
903
904 #
905 # LN_PROG_LINUX
906 #
907 # LNet linux kernel checks
908 #
909 AC_DEFUN([LN_PROG_LINUX],
910 [
911 LN_CONFIG_AFFINITY
912 LN_CONFIG_BACKOFF
913 LN_CONFIG_QUADRICS
914 LN_CONFIG_GM
915 LN_CONFIG_OPENIB
916 LN_CONFIG_CIB
917 LN_CONFIG_VIB
918 LN_CONFIG_IIB
919 LN_CONFIG_O2IB
920 LN_CONFIG_RALND
921 LN_CONFIG_PTLLND
922 LN_CONFIG_MX
923 ])
924
925 #
926 # LN_PROG_DARWIN
927 #
928 # Darwin checks
929 #
930 AC_DEFUN([LN_PROG_DARWIN],
931 [LB_DARWIN_CHECK_FUNCS([get_preemption_level])
932 ])
933
934 #
935 # LN_PATH_DEFAULTS
936 #
937 # default paths for installed files
938 #
939 AC_DEFUN([LN_PATH_DEFAULTS],
940 [
941 ])
942
943 #
944 # LN_CONFIGURE
945 #
946 # other configure checks
947 #
948 AC_DEFUN([LN_CONFIGURE],
949 [# lnet/utils/portals.c
950 AC_CHECK_HEADERS([netdb.h netinet/tcp.h asm/types.h endian.h sys/ioctl.h])
951 AC_CHECK_FUNCS([gethostbyname socket connect])
952
953 # lnet/utils/debug.c
954 AC_CHECK_HEADERS([linux/version.h])
955
956 AC_CHECK_TYPE([spinlock_t],
957         [AC_DEFINE(HAVE_SPINLOCK_T, 1, [spinlock_t is defined])],
958         [],
959         [#include <linux/spinlock.h>])
960
961 # lnet/utils/wirecheck.c
962 AC_CHECK_FUNCS([strnlen])
963
964 # --------  Check for required packages  --------------
965
966 #
967 # LC_CONFIG_READLINE
968 #
969 # Build with readline
970 #
971 AC_MSG_CHECKING([whether to enable readline support])
972 AC_ARG_ENABLE(readline,
973         AC_HELP_STRING([--disable-readline],
974                         [disable readline support]),
975         [],[enable_readline='yes'])
976 AC_MSG_RESULT([$enable_readline])
977
978 # -------- check for readline if enabled ----
979 if test x$enable_readline = xyes ; then
980         LIBS_save="$LIBS"
981         LIBS="-lncurses $LIBS"
982         AC_CHECK_LIB([readline],[readline],[
983         LIBREADLINE="-lreadline -lncurses"
984         AC_DEFINE(HAVE_LIBREADLINE, 1, [readline library is available])
985         ],[
986         LIBREADLINE=""
987         ])
988         LIBS="$LIBS_save"
989 else
990         LIBREADLINE=""
991 fi
992 AC_SUBST(LIBREADLINE)
993
994 # -------- enable acceptor libwrap (TCP wrappers) support? -------
995 AC_MSG_CHECKING([if libwrap support is requested])
996 AC_ARG_ENABLE([libwrap],
997         AC_HELP_STRING([--enable-libwrap], [use TCP wrappers]),
998         [case "${enableval}" in
999                 yes) enable_libwrap=yes ;;
1000                 no) enable_libwrap=no ;;
1001                 *) AC_MSG_ERROR(bad value ${enableval} for --enable-libwrap) ;;
1002         esac],[enable_libwrap=no])
1003 AC_MSG_RESULT([$enable_libwrap])
1004 if test x$enable_libwrap = xyes ; then
1005         LIBWRAP="-lwrap"
1006         AC_DEFINE(HAVE_LIBWRAP, 1, [libwrap support is requested])
1007 else
1008         LIBWRAP=""
1009 fi
1010 AC_SUBST(LIBWRAP)
1011
1012 # ----------------------------------------
1013 # some tests for catamount-like systems
1014 # ----------------------------------------
1015 AC_ARG_ENABLE([sysio_init],
1016         AC_HELP_STRING([--disable-sysio-init],
1017                 [call sysio init functions when initializing liblustre]),
1018         [],[enable_sysio_init=yes])
1019 AC_MSG_CHECKING([whether to initialize libsysio])
1020 AC_MSG_RESULT([$enable_sysio_init])
1021 if test x$enable_sysio_init != xno ; then
1022         AC_DEFINE([INIT_SYSIO], 1, [call sysio init functions])
1023 fi
1024
1025 AC_ARG_ENABLE([urandom],
1026         AC_HELP_STRING([--disable-urandom],
1027                 [disable use of /dev/urandom for liblustre]),
1028         [],[enable_urandom=yes])
1029 AC_MSG_CHECKING([whether to use /dev/urandom for liblustre])
1030 AC_MSG_RESULT([$enable_urandom])
1031 if test x$enable_urandom != xno ; then
1032         AC_DEFINE([LIBLUSTRE_USE_URANDOM], 1, [use /dev/urandom for random data])
1033 fi
1034
1035 # -------- check for -lcap support ----
1036 if test x$enable_liblustre = xyes ; then
1037         AC_CHECK_LIB([cap], [cap_get_proc],
1038                 [
1039                         CAP_LIBS="-lcap"
1040                         AC_DEFINE([HAVE_LIBCAP], 1, [use libcap])
1041                 ],
1042                 [
1043                         CAP_LIBS=""
1044                 ])
1045         AC_SUBST(CAP_LIBS)
1046
1047 fi
1048
1049 LN_CONFIG_MAX_PAYLOAD
1050 LN_CONFIG_UPTLLND
1051 LN_CONFIG_USOCKLND
1052 ])
1053
1054 #
1055 # LN_CONDITIONALS
1056 #
1057 # AM_CONDITOINAL defines for lnet
1058 #
1059 AC_DEFUN([LN_CONDITIONALS],
1060 [AM_CONDITIONAL(BUILD_QSWLND, test x$QSWLND = "xqswlnd")
1061 AM_CONDITIONAL(BUILD_GMLND, test x$GMLND = "xgmlnd")
1062 AM_CONDITIONAL(BUILD_MXLND, test x$MXLND = "xmxlnd")
1063 AM_CONDITIONAL(BUILD_O2IBLND, test x$O2IBLND = "xo2iblnd")
1064 AM_CONDITIONAL(BUILD_OPENIBLND, test x$OPENIBLND = "xopeniblnd")
1065 AM_CONDITIONAL(BUILD_CIBLND, test x$CIBLND = "xciblnd")
1066 AM_CONDITIONAL(BUILD_IIBLND, test x$IIBLND = "xiiblnd")
1067 AM_CONDITIONAL(BUILD_VIBLND, test x$VIBLND = "xviblnd")
1068 AM_CONDITIONAL(BUILD_RALND, test x$RALND = "xralnd")
1069 AM_CONDITIONAL(BUILD_PTLLND, test x$PTLLND = "xptllnd")
1070 AM_CONDITIONAL(BUILD_UPTLLND, test x$UPTLLND = "xptllnd")
1071 AM_CONDITIONAL(BUILD_USOCKLND, test x$USOCKLND = "xusocklnd")
1072 ])
1073
1074 #
1075 # LN_CONFIG_FILES
1076 #
1077 # files that should be generated with AC_OUTPUT
1078 #
1079 AC_DEFUN([LN_CONFIG_FILES],
1080 [AC_CONFIG_FILES([
1081 lnet/Kernelenv
1082 lnet/Makefile
1083 lnet/autoMakefile
1084 lnet/autoconf/Makefile
1085 lnet/doc/Makefile
1086 lnet/include/Makefile
1087 lnet/include/lnet/Makefile
1088 lnet/include/lnet/linux/Makefile
1089 lnet/klnds/Makefile
1090 lnet/klnds/autoMakefile
1091 lnet/klnds/gmlnd/Makefile
1092 lnet/klnds/mxlnd/autoMakefile
1093 lnet/klnds/mxlnd/Makefile
1094 lnet/klnds/gmlnd/autoMakefile
1095 lnet/klnds/openiblnd/Makefile
1096 lnet/klnds/openiblnd/autoMakefile
1097 lnet/klnds/o2iblnd/Makefile
1098 lnet/klnds/o2iblnd/autoMakefile
1099 lnet/klnds/ciblnd/Makefile
1100 lnet/klnds/ciblnd/autoMakefile
1101 lnet/klnds/iiblnd/Makefile
1102 lnet/klnds/iiblnd/autoMakefile
1103 lnet/klnds/viblnd/Makefile
1104 lnet/klnds/viblnd/autoMakefile
1105 lnet/klnds/qswlnd/Makefile
1106 lnet/klnds/qswlnd/autoMakefile
1107 lnet/klnds/ralnd/Makefile
1108 lnet/klnds/ralnd/autoMakefile
1109 lnet/klnds/socklnd/Makefile
1110 lnet/klnds/socklnd/autoMakefile
1111 lnet/klnds/ptllnd/Makefile
1112 lnet/klnds/ptllnd/autoMakefile
1113 lnet/lnet/Makefile
1114 lnet/lnet/autoMakefile
1115 lnet/selftest/Makefile
1116 lnet/selftest/autoMakefile
1117 lnet/ulnds/Makefile
1118 lnet/ulnds/autoMakefile
1119 lnet/ulnds/socklnd/Makefile
1120 lnet/ulnds/ptllnd/Makefile
1121 lnet/utils/Makefile
1122 ])
1123 case $lb_target_os in
1124         darwin)
1125                 AC_CONFIG_FILES([
1126 lnet/include/lnet/darwin/Makefile
1127 ])
1128                 ;;
1129 esac
1130 ])