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