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