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