Whamcloud - gitweb
Branch HEAD
[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/Module.symvers])
524                                 cat $O2IBPATH/Module.symvers >> $PWD/Module.symvers
525                         else
526                                 AC_MSG_ERROR([an external source tree was specified for o2iblnd however I could not find a $O2IBPATH/Module.symvers there])
527                         fi
528                 fi
529
530                 # version checking is a hack and isn't reliable,
531                 # we need verify it with each new ofed release
532
533                 if grep -q ib_dma_map_single \
534                         ${O2IBPATH}/include/rdma/ib_verbs.h; then
535                         if grep -q comp_vector \
536                                 ${O2IBPATH}/include/rdma/ib_verbs.h; then
537                                 IBLND_OFED_VERSION="1025"
538                         else
539                                 IBLND_OFED_VERSION="1020"
540                         fi
541                 else
542                         IBLND_OFED_VERSION="1010"
543                 fi
544
545                 AC_DEFINE_UNQUOTED(IBLND_OFED_VERSION, $IBLND_OFED_VERSION,
546                                    [OFED version])
547
548                 EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
549         fi
550 fi
551
552 AC_SUBST(EXTRA_LNET_INCLUDE)
553 AC_SUBST(O2IBCPPFLAGS)
554 AC_SUBST(O2IBLND)
555 ])
556
557 #
558 # LN_CONFIG_OPENIB
559 #
560 # check for OpenIB in the kernel
561 AC_DEFUN([LN_CONFIG_OPENIB],[
562 AC_MSG_CHECKING([whether to enable OpenIB support])
563 # set default
564 OPENIBPATH="$LINUX/drivers/infiniband"
565 AC_ARG_WITH([openib],
566         AC_HELP_STRING([--with-openib=path],
567                        [build openiblnd against path]),
568         [
569                 case $with_openib in
570                 yes)    ENABLEOPENIB=2
571                         ;;
572                 no)     ENABLEOPENIB=0
573                         ;;
574                 *)      OPENIBPATH="$with_openib"
575                         ENABLEOPENIB=3
576                         ;;
577                 esac
578         ],[
579                 ENABLEOPENIB=1
580         ])
581 if test $ENABLEOPENIB -eq 0; then
582         AC_MSG_RESULT([disabled])
583 elif test ! \( -f ${OPENIBPATH}/include/ts_ib_core.h -a \
584                -f ${OPENIBPATH}/include/ts_ib_cm.h -a \
585                -f ${OPENIBPATH}/include/ts_ib_sa_client.h \); then
586         AC_MSG_RESULT([no])
587         case $ENABLEOPENIB in
588         1) ;;
589         2) AC_MSG_ERROR([kernel OpenIB headers not present]);;
590         3) AC_MSG_ERROR([bad --with-openib path]);;
591         *) AC_MSG_ERROR([internal error]);;
592         esac
593 else
594         case $ENABLEOPENIB in
595         1|2) OPENIBCPPFLAGS="-I$OPENIBPATH/include -DIN_TREE_BUILD";;
596         3)   OPENIBCPPFLAGS="-I$OPENIBPATH/include";;
597         *)   AC_MSG_RESULT([no])
598              AC_MSG_ERROR([internal error]);;
599         esac
600         OPENIBCPPFLAGS="$OPENIBCPPFLAGS -DIB_NTXRXPARAMS=4"
601         EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
602         EXTRA_KCFLAGS="$EXTRA_KCFLAGS $OPENIBCPPFLAGS"
603         LB_LINUX_TRY_COMPILE([
604                 #include <ts_ib_core.h>
605                 #include <ts_ib_cm.h>
606                 #include <ts_ib_sa_client.h>
607         ],[
608                 struct ib_device_properties dev_props;
609                 struct ib_cm_active_param   cm_active_params;
610                 tTS_IB_CLIENT_QUERY_TID     tid;
611                 int                         enum1 = IB_QP_ATTRIBUTE_STATE;
612                 int                         enum2 = IB_ACCESS_LOCAL_WRITE;
613                 int                         enum3 = IB_CQ_CALLBACK_INTERRUPT;
614                 int                         enum4 = IB_CQ_PROVIDER_REARM;
615                 return 0;
616         ],[
617                 AC_MSG_RESULT([yes])
618                 OPENIBLND="openiblnd"
619         ],[
620                 AC_MSG_RESULT([no])
621                 case $ENABLEOPENIB in
622                 1) ;;
623                 2) AC_MSG_ERROR([can't compile with kernel OpenIB headers]);;
624                 3) AC_MSG_ERROR([can't compile with OpenIB headers under $OPENIBPATH]);;
625                 *) AC_MSG_ERROR([internal error]);;
626                 esac
627                 OPENIBLND=""
628                 OPENIBCPPFLAGS=""
629         ])
630         EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
631 fi
632 AC_SUBST(OPENIBCPPFLAGS)
633 AC_SUBST(OPENIBLND)
634 ])
635
636 #
637 # LN_CONFIG_CIBLND
638 #
639 AC_DEFUN([LN_CONFIG_CIB],[
640 AC_MSG_CHECKING([whether to enable Cisco/TopSpin IB support])
641 # set default
642 CIBPATH=""
643 CIBLND=""
644 AC_ARG_WITH([cib],
645         AC_HELP_STRING([--with-cib=path],
646                        [build ciblnd against path]),
647         [
648                 case $with_cib in
649                 no)     AC_MSG_RESULT([no]);;
650                 *)      CIBPATH="$with_cib"
651                         if test -d "$CIBPATH"; then
652                                 AC_MSG_RESULT([yes])
653                         else
654                                 AC_MSG_RESULT([no])
655                                 AC_MSG_ERROR([No directory $CIBPATH])
656                         fi;;
657                 esac
658         ],[
659                 AC_MSG_RESULT([no])
660         ])
661 if test -n "$CIBPATH"; then
662         CIBCPPFLAGS="-I${CIBPATH}/ib/ts_api_ng/include -I${CIBPATH}/all/kernel_services/include -DUSING_TSAPI"
663         CIBCPPFLAGS="$CIBCPPFLAGS -DIB_NTXRXPARAMS=3"
664         EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
665         EXTRA_KCFLAGS="$EXTRA_KCFLAGS $CIBCPPFLAGS"
666         LB_LINUX_TRY_COMPILE([
667                 #include <ts_ib_core.h>
668                 #include <ts_ib_cm.h>
669                 #include <ts_ib_sa_client.h>
670         ],[
671                 struct ib_device_properties dev_props;
672                 struct ib_cm_active_param   cm_active_params;
673                 tTS_IB_CLIENT_QUERY_TID     tid;
674                 int                         enum1 = TS_IB_QP_ATTRIBUTE_STATE;
675                 int                         enum2 = TS_IB_ACCESS_LOCAL_WRITE;
676                 int                         enum3 = TS_IB_CQ_CALLBACK_INTERRUPT;
677                 int                         enum4 = TS_IB_CQ_PROVIDER_REARM;
678                 return 0;
679         ],[
680                 CIBLND="ciblnd"
681         ],[
682                 AC_MSG_ERROR([can't compile ciblnd with given path])
683                 CIBCPPFLAGS=""
684         ])
685         EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
686 fi
687 AC_SUBST(CIBCPPFLAGS)
688 AC_SUBST(CIBLND)
689 ])
690
691 #
692 # LN_CONFIG_IIB
693 #
694 # check for infinicon infiniband support
695 #
696 AC_DEFUN([LN_CONFIG_IIB],[
697 AC_MSG_CHECKING([whether to enable Infinicon support])
698 # set default
699 IIBPATH="/usr/include"
700 AC_ARG_WITH([iib],
701         AC_HELP_STRING([--with-iib=path],
702                        [build iiblnd against path]),
703         [
704                 case $with_iib in
705                 yes)    ENABLEIIB=2
706                         ;;
707                 no)     ENABLEIIB=0
708                         ;;
709                 *)      IIBPATH="${with_iib}/include"
710                         ENABLEIIB=3
711                         ;;
712                 esac
713         ],[
714                 ENABLEIIB=1
715         ])
716 if test $ENABLEIIB -eq 0; then
717         AC_MSG_RESULT([disabled])
718 elif test ! \( -f ${IIBPATH}/linux/iba/ibt.h \); then
719         AC_MSG_RESULT([no])
720         case $ENABLEIIB in
721         1) ;;
722         2) AC_MSG_ERROR([default Infinicon headers not present]);;
723         3) AC_MSG_ERROR([bad --with-iib path]);;
724         *) AC_MSG_ERROR([internal error]);;
725         esac
726 else
727         IIBCPPFLAGS="-I$IIBPATH"
728         if test $IIBPATH != "/usr/include"; then
729                 # we need /usr/include come what may
730                 IIBCPPFLAGS="$IIBCPPFLAGS -I/usr/include"
731         fi
732         EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
733         EXTRA_KCFLAGS="$EXTRA_KCFLAGS $IIBCPPFLAGS"
734         LB_LINUX_TRY_COMPILE([
735                 #include <linux/iba/ibt.h>
736         ],[
737                 IBT_INTERFACE_UNION interfaces;
738                 FSTATUS             rc;
739
740                  rc = IbtGetInterfaceByVersion(IBT_INTERFACE_VERSION_2,
741                                                &interfaces);
742
743                 return rc == FSUCCESS ? 0 : 1;
744         ],[
745                 AC_MSG_RESULT([yes])
746                 IIBLND="iiblnd"
747         ],[
748                 AC_MSG_RESULT([no])
749                 case $ENABLEIIB in
750                 1) ;;
751                 2) AC_MSG_ERROR([can't compile with default Infinicon headers]);;
752                 3) AC_MSG_ERROR([can't compile with Infinicon headers under $IIBPATH]);;
753                 *) AC_MSG_ERROR([internal error]);;
754                 esac
755                 IIBLND=""
756                 IIBCPPFLAGS=""
757         ])
758         EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
759 fi
760 AC_SUBST(IIBCPPFLAGS)
761 AC_SUBST(IIBLND)
762 ])
763
764 #
765 # LN_CONFIG_VIB
766 #
767 # check for Voltaire infiniband support
768 #
769 AC_DEFUN([LN_CONFIG_VIB],
770 [AC_MSG_CHECKING([whether to enable Voltaire IB support])
771 VIBPATH=""
772 AC_ARG_WITH([vib],
773         AC_HELP_STRING([--with-vib=path],
774                        [build viblnd against path]),
775         [
776                 case $with_vib in
777                 no)     AC_MSG_RESULT([no]);;
778                 *)      VIBPATH="${with_vib}/src/nvigor/ib-code"
779                         if test -d "$with_vib" -a -d "$VIBPATH"; then
780                                 AC_MSG_RESULT([yes])
781                         else
782                                 AC_MSG_RESULT([no])
783                                 AC_MSG_ERROR([No directory $VIBPATH])
784                         fi;;
785                 esac
786         ],[
787                 AC_MSG_RESULT([no])
788         ])
789 if test -z "$VIBPATH"; then
790         VIBLND=""
791 else
792         VIBCPPFLAGS="-I${VIBPATH}/include -I${VIBPATH}/cm"
793         EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
794         EXTRA_KCFLAGS="$EXTRA_KCFLAGS $VIBCPPFLAGS"
795         LB_LINUX_TRY_COMPILE([
796                 #include <linux/list.h>
797                 #include <asm/byteorder.h>
798                 #ifdef __BIG_ENDIAN
799                 # define CPU_BE 1
800                 # define CPU_LE 0
801                 #endif
802                 #ifdef __LITTLE_ENDIAN
803                 # define CPU_BE 0
804                 # define CPU_LE 1
805                 #endif
806                 #include <vverbs.h>
807                 #include <ib-cm.h>
808                 #include <ibat.h>
809         ],[
810                 vv_hca_h_t       kib_hca;
811                 vv_return_t      vvrc;
812                 cm_cep_handle_t  cep;
813                 ibat_arp_data_t  arp_data;
814                 ibat_stat_t      ibatrc;
815
816                 vvrc = vv_hca_open("ANY_HCA", NULL, &kib_hca);
817                 cep = cm_create_cep(cm_cep_transp_rc);
818                 ibatrc = ibat_get_ib_data((uint32_t)0, (uint32_t)0,
819                                           ibat_paths_primary, &arp_data,
820                                           (ibat_get_ib_data_reply_fn_t)NULL,
821                                           NULL, 0);
822                 return 0;
823         ],[
824                 VIBLND="viblnd"
825         ],[
826                 AC_MSG_ERROR([can't compile viblnd with given path])
827         ])
828         EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
829 fi
830 if test -n "$VIBLND"; then
831         EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
832         EXTRA_KCFLAGS="$EXTRA_KCFLAGS $VIBCPPFLAGS"
833         AC_MSG_CHECKING([if Voltaire still uses void * sg addresses])
834         LB_LINUX_TRY_COMPILE([
835                 #include <linux/list.h>
836                 #include <asm/byteorder.h>
837                 #ifdef __BIG_ENDIAN
838                 # define CPU_BE 1
839                 # define CPU_LE 0
840                 #endif
841                 #ifdef __LITTLE_ENDIAN
842                 # define CPU_BE 0
843                 # define CPU_LE 1
844                 #endif
845                 #include <vverbs.h>
846                 #include <ib-cm.h>
847                 #include <ibat.h>
848         ],[
849                 vv_scatgat_t  sg;
850
851                 return &sg.v_address[3] == NULL;
852         ],[
853                 AC_MSG_RESULT([yes])
854                 VIBCPPFLAGS="$VIBCPPFLAGS -DIBNAL_VOIDSTAR_SGADDR=1"
855         ],[
856                 AC_MSG_RESULT([no])
857         ])
858         EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
859 fi
860 AC_SUBST(VIBCPPFLAGS)
861 AC_SUBST(VIBLND)
862 ])
863
864 #
865 # LN_CONFIG_RALND
866 #
867 # check whether to use the RapidArray lnd
868 #
869 AC_DEFUN([LN_CONFIG_RALND],
870 [#### Rapid Array
871 AC_MSG_CHECKING([if RapidArray kernel headers are present])
872 # placeholder
873 RACPPFLAGS="-I${LINUX}/drivers/xd1/include"
874 EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
875 EXTRA_KCFLAGS="$EXTRA_KCFLAGS $RACPPFLAGS"
876 LB_LINUX_TRY_COMPILE([
877         #include <linux/types.h>
878         #include <rapl.h>
879 ],[
880         RAP_RETURN          rc;
881         RAP_PVOID           dev_handle;
882
883         rc = RapkGetDeviceByIndex(0, NULL, &dev_handle);
884
885         return rc == RAP_SUCCESS ? 0 : 1;
886 ],[
887         AC_MSG_RESULT([yes])
888         RALND="ralnd"
889 ],[
890         AC_MSG_RESULT([no])
891         RALND=""
892         RACPPFLAGS=""
893 ])
894 EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
895 AC_SUBST(RACPPFLAGS)
896 AC_SUBST(RALND)
897 ])
898
899
900
901 #
902 # LN_PROG_LINUX
903 #
904 # LNet linux kernel checks
905 #
906 AC_DEFUN([LN_PROG_LINUX],
907 [
908 LN_CONFIG_AFFINITY
909 LN_CONFIG_BACKOFF
910 LN_CONFIG_QUADRICS
911 LN_CONFIG_GM
912 LN_CONFIG_OPENIB
913 LN_CONFIG_CIB
914 LN_CONFIG_VIB
915 LN_CONFIG_IIB
916 LN_CONFIG_O2IB
917 LN_CONFIG_RALND
918 LN_CONFIG_PTLLND
919 LN_CONFIG_MX
920 ])
921
922 #
923 # LN_PROG_DARWIN
924 #
925 # Darwin checks
926 #
927 AC_DEFUN([LN_PROG_DARWIN],
928 [LB_DARWIN_CHECK_FUNCS([get_preemption_level])
929 ])
930
931 #
932 # LN_PATH_DEFAULTS
933 #
934 # default paths for installed files
935 #
936 AC_DEFUN([LN_PATH_DEFAULTS],
937 [
938 ])
939
940 #
941 # LN_CONFIGURE
942 #
943 # other configure checks
944 #
945 AC_DEFUN([LN_CONFIGURE],
946 [# lnet/utils/portals.c
947 AC_CHECK_HEADERS([netdb.h netinet/tcp.h asm/types.h endian.h sys/ioctl.h])
948 AC_CHECK_FUNCS([gethostbyname socket connect])
949
950 # lnet/utils/debug.c
951 AC_CHECK_HEADERS([linux/version.h])
952
953 AC_CHECK_TYPE([spinlock_t],
954         [AC_DEFINE(HAVE_SPINLOCK_T, 1, [spinlock_t is defined])],
955         [],
956         [#include <linux/spinlock.h>])
957
958 # lnet/utils/wirecheck.c
959 AC_CHECK_FUNCS([strnlen])
960
961 # --------  Check for required packages  --------------
962
963 #
964 # LC_CONFIG_READLINE
965 #
966 # Build with readline
967 #
968 AC_MSG_CHECKING([whether to enable readline support])
969 AC_ARG_ENABLE(readline,
970         AC_HELP_STRING([--disable-readline],
971                         [disable readline support]),
972         [],[enable_readline='yes'])
973 AC_MSG_RESULT([$enable_readline])
974
975 # -------- check for readline if enabled ----
976 if test x$enable_readline = xyes ; then
977         LIBS_save="$LIBS"
978         LIBS="-lncurses $LIBS"
979         AC_CHECK_LIB([readline],[readline],[
980         LIBREADLINE="-lreadline -lncurses"
981         AC_DEFINE(HAVE_LIBREADLINE, 1, [readline library is available])
982         ],[
983         LIBREADLINE=""
984         ])
985         LIBS="$LIBS_save"
986 else
987         LIBREADLINE=""
988 fi
989 AC_SUBST(LIBREADLINE)
990
991 # -------- enable acceptor libwrap (TCP wrappers) support? -------
992 AC_MSG_CHECKING([if libwrap support is requested])
993 AC_ARG_ENABLE([libwrap],
994         AC_HELP_STRING([--enable-libwrap], [use TCP wrappers]),
995         [case "${enableval}" in
996                 yes) enable_libwrap=yes ;;
997                 no) enable_libwrap=no ;;
998                 *) AC_MSG_ERROR(bad value ${enableval} for --enable-libwrap) ;;
999         esac],[enable_libwrap=no])
1000 AC_MSG_RESULT([$enable_libwrap])
1001 if test x$enable_libwrap = xyes ; then
1002         LIBWRAP="-lwrap"
1003         AC_DEFINE(HAVE_LIBWRAP, 1, [libwrap support is requested])
1004 else
1005         LIBWRAP=""
1006 fi
1007 AC_SUBST(LIBWRAP)
1008
1009 # ----------------------------------------
1010 # some tests for catamount-like systems
1011 # ----------------------------------------
1012 AC_ARG_ENABLE([sysio_init],
1013         AC_HELP_STRING([--disable-sysio-init],
1014                 [call sysio init functions when initializing liblustre]),
1015         [],[enable_sysio_init=yes])
1016 AC_MSG_CHECKING([whether to initialize libsysio])
1017 AC_MSG_RESULT([$enable_sysio_init])
1018 if test x$enable_sysio_init != xno ; then
1019         AC_DEFINE([INIT_SYSIO], 1, [call sysio init functions])
1020 fi
1021
1022 AC_ARG_ENABLE([urandom],
1023         AC_HELP_STRING([--disable-urandom],
1024                 [disable use of /dev/urandom for liblustre]),
1025         [],[enable_urandom=yes])
1026 AC_MSG_CHECKING([whether to use /dev/urandom for liblustre])
1027 AC_MSG_RESULT([$enable_urandom])
1028 if test x$enable_urandom != xno ; then
1029         AC_DEFINE([LIBLUSTRE_USE_URANDOM], 1, [use /dev/urandom for random data])
1030 fi
1031
1032 # -------- check for -lcap support ----
1033 if test x$enable_liblustre = xyes ; then
1034         AC_CHECK_LIB([cap], [cap_get_proc],
1035                 [
1036                         CAP_LIBS="-lcap"
1037                         AC_DEFINE([HAVE_LIBCAP], 1, [use libcap])
1038                 ],
1039                 [
1040                         CAP_LIBS=""
1041                 ])
1042         AC_SUBST(CAP_LIBS)
1043
1044 fi
1045
1046 LN_CONFIG_MAX_PAYLOAD
1047 LN_CONFIG_UPTLLND
1048 LN_CONFIG_USOCKLND
1049 ])
1050
1051 #
1052 # LN_CONDITIONALS
1053 #
1054 # AM_CONDITOINAL defines for lnet
1055 #
1056 AC_DEFUN([LN_CONDITIONALS],
1057 [AM_CONDITIONAL(BUILD_QSWLND, test x$QSWLND = "xqswlnd")
1058 AM_CONDITIONAL(BUILD_GMLND, test x$GMLND = "xgmlnd")
1059 AM_CONDITIONAL(BUILD_MXLND, test x$MXLND = "xmxlnd")
1060 AM_CONDITIONAL(BUILD_O2IBLND, test x$O2IBLND = "xo2iblnd")
1061 AM_CONDITIONAL(BUILD_OPENIBLND, test x$OPENIBLND = "xopeniblnd")
1062 AM_CONDITIONAL(BUILD_CIBLND, test x$CIBLND = "xciblnd")
1063 AM_CONDITIONAL(BUILD_IIBLND, test x$IIBLND = "xiiblnd")
1064 AM_CONDITIONAL(BUILD_VIBLND, test x$VIBLND = "xviblnd")
1065 AM_CONDITIONAL(BUILD_RALND, test x$RALND = "xralnd")
1066 AM_CONDITIONAL(BUILD_PTLLND, test x$PTLLND = "xptllnd")
1067 AM_CONDITIONAL(BUILD_UPTLLND, test x$UPTLLND = "xptllnd")
1068 AM_CONDITIONAL(BUILD_USOCKLND, test x$USOCKLND = "xusocklnd")
1069 ])
1070
1071 #
1072 # LN_CONFIG_FILES
1073 #
1074 # files that should be generated with AC_OUTPUT
1075 #
1076 AC_DEFUN([LN_CONFIG_FILES],
1077 [AC_CONFIG_FILES([
1078 lnet/Kernelenv
1079 lnet/Makefile
1080 lnet/autoMakefile
1081 lnet/autoconf/Makefile
1082 lnet/doc/Makefile
1083 lnet/include/Makefile
1084 lnet/include/lnet/Makefile
1085 lnet/include/lnet/linux/Makefile
1086 lnet/klnds/Makefile
1087 lnet/klnds/autoMakefile
1088 lnet/klnds/gmlnd/Makefile
1089 lnet/klnds/mxlnd/autoMakefile
1090 lnet/klnds/mxlnd/Makefile
1091 lnet/klnds/gmlnd/autoMakefile
1092 lnet/klnds/openiblnd/Makefile
1093 lnet/klnds/openiblnd/autoMakefile
1094 lnet/klnds/o2iblnd/Makefile
1095 lnet/klnds/o2iblnd/autoMakefile
1096 lnet/klnds/ciblnd/Makefile
1097 lnet/klnds/ciblnd/autoMakefile
1098 lnet/klnds/iiblnd/Makefile
1099 lnet/klnds/iiblnd/autoMakefile
1100 lnet/klnds/viblnd/Makefile
1101 lnet/klnds/viblnd/autoMakefile
1102 lnet/klnds/qswlnd/Makefile
1103 lnet/klnds/qswlnd/autoMakefile
1104 lnet/klnds/ralnd/Makefile
1105 lnet/klnds/ralnd/autoMakefile
1106 lnet/klnds/socklnd/Makefile
1107 lnet/klnds/socklnd/autoMakefile
1108 lnet/klnds/ptllnd/Makefile
1109 lnet/klnds/ptllnd/autoMakefile
1110 lnet/lnet/Makefile
1111 lnet/lnet/autoMakefile
1112 lnet/selftest/Makefile
1113 lnet/selftest/autoMakefile
1114 lnet/ulnds/Makefile
1115 lnet/ulnds/autoMakefile
1116 lnet/ulnds/socklnd/Makefile
1117 lnet/ulnds/ptllnd/Makefile
1118 lnet/utils/Makefile
1119 ])
1120 case $lb_target_os in
1121         darwin)
1122                 AC_CONFIG_FILES([
1123 lnet/include/lnet/darwin/Makefile
1124 ])
1125                 ;;
1126 esac
1127 ])