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