Whamcloud - gitweb
i=brian,b=15870:
[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_CDEBUG
46 #
47 # whether to enable various libcfs debugs (CDEBUG, ENTRY/EXIT, LASSERT, etc.)
48 #
49 AC_DEFUN([LN_CONFIG_CDEBUG],
50 [
51 AC_MSG_CHECKING([whether to enable CDEBUG, CWARN])
52 AC_ARG_ENABLE([libcfs_cdebug],
53         AC_HELP_STRING([--disable-libcfs-cdebug],
54                         [disable libcfs CDEBUG, CWARN]),
55         [],[enable_libcfs_cdebug='yes'])
56 AC_MSG_RESULT([$enable_libcfs_cdebug])
57 if test x$enable_libcfs_cdebug = xyes; then
58    AC_DEFINE(CDEBUG_ENABLED, 1, [enable libcfs CDEBUG, CWARN])
59 else
60    AC_DEFINE(CDEBUG_ENABLED, 0, [disable libcfs CDEBUG, CWARN])
61 fi
62
63 AC_MSG_CHECKING([whether to enable ENTRY/EXIT])
64 AC_ARG_ENABLE([libcfs_trace],
65         AC_HELP_STRING([--disable-libcfs-trace],
66                         [disable libcfs ENTRY/EXIT]),
67         [],[enable_libcfs_trace='yes'])
68 AC_MSG_RESULT([$enable_libcfs_trace])
69 if test x$enable_libcfs_trace = xyes; then
70    AC_DEFINE(CDEBUG_ENTRY_EXIT, 1, [enable libcfs ENTRY/EXIT])
71 else
72    AC_DEFINE(CDEBUG_ENTRY_EXIT, 0, [disable libcfs ENTRY/EXIT])
73 fi
74
75 AC_MSG_CHECKING([whether to enable LASSERT, LASSERTF])
76 AC_ARG_ENABLE([libcfs_assert],
77         AC_HELP_STRING([--disable-libcfs-assert],
78                         [disable libcfs LASSERT, LASSERTF]),
79         [],[enable_libcfs_assert='yes'])
80 AC_MSG_RESULT([$enable_libcfs_assert])
81 if test x$enable_libcfs_assert = xyes; then
82    AC_DEFINE(LIBCFS_DEBUG, 1, [enable libcfs LASSERT, LASSERTF])
83 fi
84 ])
85
86 #
87 # LN_CONFIG_AFFINITY
88 #
89 # check if cpu affinity is available/wanted
90 #
91 AC_DEFUN([LN_CONFIG_AFFINITY],
92 [AC_ARG_ENABLE([affinity],
93         AC_HELP_STRING([--disable-affinity],
94                        [disable process/irq affinity]),
95         [],[enable_affinity='yes'])
96
97 AC_MSG_CHECKING([for CPU affinity support])
98 if test x$enable_affinity = xno ; then
99         AC_MSG_RESULT([no (by request)])
100 else
101         LB_LINUX_TRY_COMPILE([
102                 #include <linux/sched.h>
103         ],[
104                 struct task_struct t;
105                 #if HAVE_CPUMASK_T
106                 cpumask_t     m;
107                 #else
108                 unsigned long m;
109                 #endif
110                 set_cpus_allowed(&t, m);
111         ],[
112                 AC_DEFINE(CPU_AFFINITY, 1, [kernel has cpu affinity support])
113                 AC_MSG_RESULT([yes])
114         ],[
115                 AC_MSG_RESULT([no (no kernel support)])
116         ])
117 fi
118 ])
119
120 #
121 # LN_CONFIG_PORTALS
122 #
123 # configure support for Portals
124 #
125 AC_DEFUN([LN_CONFIG_PORTALS],
126 [AC_MSG_CHECKING([for portals])
127 AC_ARG_WITH([portals],
128         AC_HELP_STRING([--with-portals=path],
129                        [set path to portals]),
130         [
131                 case $with_portals in
132                         no)     ENABLEPORTALS=0
133                                 ;;
134                         *)      PORTALS="${with_portals}"
135                                 ENABLEPORTALS=1
136                                 ;;
137                 esac
138         ], [
139                 ENABLEPORTALS=0
140         ])
141 PTLLNDCPPFLAGS=""
142 if test $ENABLEPORTALS -eq 0; then
143         AC_MSG_RESULT([no])
144 elif test ! \( -f ${PORTALS}/include/portals/p30.h \); then
145         AC_MSG_RESULT([no])
146         AC_MSG_ERROR([bad --with-portals path])
147 else
148         AC_MSG_RESULT([$PORTALS])
149         PTLLNDCPPFLAGS="-I${PORTALS}/include"
150 fi
151 AC_SUBST(PTLLNDCPPFLAGS)
152 ])
153
154 #
155 # LN_CONFIG_BACKOFF
156 #
157 # check if tunable tcp backoff is available/wanted
158 #
159 AC_DEFUN([LN_CONFIG_BACKOFF],
160 [AC_MSG_CHECKING([for tunable backoff TCP support])
161 AC_ARG_ENABLE([backoff],
162        AC_HELP_STRING([--disable-backoff],
163                       [disable socknal tunable backoff]),
164        [],[enable_backoff='yes'])
165 if test x$enable_backoff = xno ; then
166        AC_MSG_RESULT([no (by request)])
167 else
168        BOCD="`grep -c TCP_BACKOFF $LINUX/include/linux/tcp.h`"
169        if test "$BOCD" != 0 ; then
170                AC_DEFINE(SOCKNAL_BACKOFF, 1, [use tunable backoff TCP])
171                AC_MSG_RESULT(yes)
172                if grep rto_max $LINUX/include/linux/tcp.h|grep -q __u16; then
173                    AC_DEFINE(SOCKNAL_BACKOFF_MS, 1, [tunable backoff TCP in ms])
174                fi
175        else
176                AC_MSG_RESULT([no (no kernel support)])
177        fi
178 fi
179 ])
180
181 #
182 # LN_CONFIG_PANIC_DUMPLOG
183 #
184 # check if tunable panic_dumplog is wanted
185 #
186 AC_DEFUN([LN_CONFIG_PANIC_DUMPLOG],
187 [AC_MSG_CHECKING([for tunable panic_dumplog support])
188 AC_ARG_ENABLE([panic_dumplog],
189        AC_HELP_STRING([--enable-panic_dumplog],
190                       [enable panic_dumplog]),
191        [],[enable_panic_dumplog='no'])
192 if test x$enable_panic_dumplog = xyes ; then
193        AC_DEFINE(LNET_DUMP_ON_PANIC, 1, [use dumplog on panic])
194        AC_MSG_RESULT([yes (by request)])
195 else
196        AC_MSG_RESULT([no])
197 fi
198 ])
199
200 #
201 # LN_CONFIG_PTLLND
202 #
203 # configure support for Portals LND
204 #
205 AC_DEFUN([LN_CONFIG_PTLLND],
206 [
207 if test -z "$ENABLEPORTALS"; then
208         LN_CONFIG_PORTALS
209 fi
210
211 AC_MSG_CHECKING([whether to build the kernel portals LND])
212
213 PTLLND=""
214 if test $ENABLEPORTALS -ne 0; then
215         AC_MSG_RESULT([yes])
216         PTLLND="ptllnd"
217 else
218         AC_MSG_RESULT([no])
219 fi
220 AC_SUBST(PTLLND)
221 ])
222
223 #
224 # LN_CONFIG_UPTLLND
225 #
226 # configure support for Portals LND
227 #
228 AC_DEFUN([LN_CONFIG_UPTLLND],
229 [
230 if test -z "$ENABLEPORTALS"; then
231         LN_CONFIG_PORTALS
232 fi
233
234 AC_MSG_CHECKING([whether to build the userspace portals LND])
235
236 UPTLLND=""
237 if test $ENABLEPORTALS -ne 0; then
238         AC_MSG_RESULT([yes])
239         UPTLLND="ptllnd"
240 else
241         AC_MSG_RESULT([no])
242 fi
243 AC_SUBST(UPTLLND)
244 ])
245
246 #
247 # LN_CONFIG_USOCKLND
248 #
249 # configure support for userspace TCP/IP LND
250 #
251 AC_DEFUN([LN_CONFIG_USOCKLND],
252 [AC_MSG_CHECKING([whether to build usocklnd])
253 AC_ARG_ENABLE([usocklnd],
254         AC_HELP_STRING([--disable-usocklnd],
255                         [disable usocklnd]),
256         [],[enable_usocklnd='yes'])
257
258 if test x$enable_usocklnd = xyes ; then
259         if test "$ENABLE_LIBPTHREAD" = "yes" ; then
260                 AC_MSG_RESULT([yes])
261                 USOCKLND="usocklnd"
262         else
263                 AC_MSG_RESULT([no (libpthread not present or disabled)])
264                 USOCKLND=""
265         fi
266 else
267         AC_MSG_RESULT([no (disabled explicitly)])
268         USOCKLND=""
269 fi
270 AC_SUBST(USOCKLND)
271 ])
272
273 #
274 # LN_CONFIG_QUADRICS
275 #
276 # check if quadrics support is in this kernel
277 #
278 AC_DEFUN([LN_CONFIG_QUADRICS],
279 [AC_MSG_CHECKING([for QsNet sources])
280 AC_ARG_WITH([qsnet],
281         AC_HELP_STRING([--with-qsnet=path],
282                        [set path to qsnet source (default=$LINUX)]),
283         [QSNET=$with_qsnet],
284         [QSNET=$LINUX])
285 AC_MSG_RESULT([$QSNET])
286
287 AC_MSG_CHECKING([if quadrics kernel headers are present])
288 if test -d $QSNET/drivers/net/qsnet ; then
289         AC_MSG_RESULT([yes])
290         QSWLND="qswlnd"
291         AC_MSG_CHECKING([for multirail EKC])
292         if test -f $QSNET/include/elan/epcomms.h; then
293                 AC_MSG_RESULT([supported])
294                 QSWCPPFLAGS="-I$QSNET/include -DMULTIRAIL_EKC=1"
295         else
296                 AC_MSG_RESULT([not supported])
297                 AC_MSG_ERROR([Need multirail EKC])
298         fi
299
300         if test x$QSNET = x$LINUX ; then
301                 LB_LINUX_CONFIG([QSNET],[],[
302                         LB_LINUX_CONFIG([QSNET_MODULE],[],[
303                                 AC_MSG_WARN([QSNET is not enabled in this kernel; not building qswlnd.])
304                                 QSWLND=""
305                                 QSWCPPFLAGS=""
306                         ])
307                 ])
308         fi
309 else
310         AC_MSG_RESULT([no])
311         QSWLND=""
312         QSWCPPFLAGS=""
313 fi
314 AC_SUBST(QSWCPPFLAGS)
315 AC_SUBST(QSWLND)
316 ])
317
318 #
319 # LN_CONFIG_GM
320 #
321 # check if GM support is available
322 #
323 AC_DEFUN([LN_CONFIG_GM],[
324 AC_MSG_CHECKING([whether to enable GM support])
325 AC_ARG_WITH([gm],
326         AC_HELP_STRING([--with-gm=path-to-gm-source-tree],
327                        [build gmlnd against path]),
328         [
329                 case $with_gm in
330                 no)    ENABLE_GM=0
331                        ;;
332                 *)     ENABLE_GM=1
333                        GM_SRC="$with_gm"
334                        ;;
335                 esac
336         ],[
337                 ENABLE_GM=0
338         ])
339 AC_ARG_WITH([gm-install],
340         AC_HELP_STRING([--with-gm-install=path-to-gm-install-tree],
341                        [say where GM has been installed]),
342         [
343                 GM_INSTALL=$with_gm_install
344         ],[
345                 GM_INSTALL="/opt/gm"
346         ])
347 if test $ENABLE_GM -eq 0; then
348         AC_MSG_RESULT([no])
349 else
350         AC_MSG_RESULT([yes])
351
352         GMLND="gmlnd"
353         GMCPPFLAGS="-I$GM_SRC/include -I$GM_SRC/drivers -I$GM_SRC/drivers/linux/gm"
354
355         if test -f $GM_INSTALL/lib/libgm.a -o \
356                 -f $GM_INSTALL/lib64/libgm.a; then
357                 GMLIBS="-L$GM_INSTALL/lib -L$GM_INSTALL/lib64"
358         else
359                 AC_MSG_ERROR([Cant find GM libraries under $GM_INSTALL])
360         fi
361
362         EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
363         EXTRA_KCFLAGS="$GMCPPFLAGS -DGM_KERNEL $EXTRA_KCFLAGS"
364
365         AC_MSG_CHECKING([that code using GM compiles with given path])
366         LB_LINUX_TRY_COMPILE([
367                 #define GM_STRONG_TYPES 1
368                 #ifdef VERSION
369                 #undef VERSION
370                 #endif
371                 #include "gm.h"
372                 #include "gm_internal.h"
373         ],[
374                 struct gm_port *port = NULL;
375                 gm_recv_event_t *rxevent = gm_blocking_receive_no_spin(port);
376                 return 0;
377         ],[
378                 AC_MSG_RESULT([yes])
379         ],[
380                 AC_MSG_RESULT([no])
381                 AC_MSG_ERROR([Bad --with-gm path])
382         ])
383
384         AC_MSG_CHECKING([that GM has gm_register_memory_ex_phys()])
385         LB_LINUX_TRY_COMPILE([
386                 #define GM_STRONG_TYPES 1
387                 #ifdef VERSION
388                 #undef VERSION
389                 #endif
390                 #include "gm.h"
391                 #include "gm_internal.h"
392         ],[
393                 gm_status_t     gmrc;
394                 struct gm_port *port = NULL;
395                 gm_u64_t        phys = 0;
396                 gm_up_t         pvma = 0;
397
398                 gmrc = gm_register_memory_ex_phys(port, phys, 100, pvma);
399                 return 0;
400         ],[
401                 AC_MSG_RESULT([yes])
402         ],[
403                 AC_MSG_RESULT([no.
404 Please patch the GM sources as follows...
405     cd $GM_SRC
406     patch -p0 < $PWD/lnet/klnds/gmlnd/gm-reg-phys.patch
407 ...then rebuild and re-install them])
408                 AC_MSG_ERROR([Can't build GM without gm_register_memory_ex_phys()])
409         ])
410
411         EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
412 fi
413 AC_SUBST(GMCPPFLAGS)
414 AC_SUBST(GMLIBS)
415 AC_SUBST(GMLND)
416 ])
417
418
419 #
420 # LN_CONFIG_MX
421 #
422 AC_DEFUN([LN_CONFIG_MX],
423 [AC_MSG_CHECKING([whether to enable Myrinet MX support])
424 # set default
425 MXPATH="/opt/mx"
426 AC_ARG_WITH([mx],
427        AC_HELP_STRING([--with-mx=path],
428                       [build mxlnd against path]),
429        [
430                case $with_mx in
431                yes)    ENABLEMX=2
432                        ;;
433                no)     ENABLEMX=0
434                        ;;
435                *)      MXPATH=$with_mx
436                        ENABLEMX=3
437                        ;;
438                esac
439        ],[
440                ENABLEMX=1
441        ])
442 if test $ENABLEMX -eq 0; then
443        AC_MSG_RESULT([disabled])
444 elif test ! \( -f ${MXPATH}/include/myriexpress.h -a \
445               -f ${MXPATH}/include/mx_kernel_api.h -a \
446               -f ${MXPATH}/include/mx_pin.h \); then
447        AC_MSG_RESULT([no])
448        case $ENABLEMX in
449        1) ;;
450        2) AC_MSG_ERROR([Myrinet MX kernel headers not present]);;
451        3) AC_MSG_ERROR([bad --with-mx path]);;
452        *) AC_MSG_ERROR([internal error]);;
453        esac
454 else
455        MXCPPFLAGS="-I$MXPATH/include"
456        EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
457        EXTRA_KCFLAGS="$EXTRA_KCFLAGS $MXCPPFLAGS"
458        MXLIBS="-L$MXPATH/lib"
459        LB_LINUX_TRY_COMPILE([
460                #define MX_KERNEL 1
461                #include <mx_extensions.h>
462                #include <myriexpress.h>
463        ],[
464                mx_endpoint_t   end;
465                mx_status_t     status;
466                mx_request_t    request;
467                int             result;
468
469                mx_init();
470                mx_open_endpoint(MX_ANY_NIC, MX_ANY_ENDPOINT, 0, NULL, 0, &end);
471                mx_register_unexp_handler(end, (mx_unexp_handler_t) NULL, NULL);
472                mx_wait_any(end, MX_INFINITE, 0LL, 0LL, &status, &result);
473                mx_iconnect(end, 0LL, 0, 0, 0, NULL, &request);
474                return 0;
475        ],[
476                AC_MSG_RESULT([yes])
477                MXLND="mxlnd"
478        ],[
479                AC_MSG_RESULT([no])
480                case $ENABLEMX in
481                1) ;;
482                2) AC_MSG_ERROR([can't compile with Myrinet MX kernel headers]);;
483                3) AC_MSG_ERROR([can't compile with Myrinet MX headers under $MXPATH]);;
484                *) AC_MSG_ERROR([internal error]);;
485                esac
486                MXLND=""
487                MXCPPFLAGS=""
488        ])
489        EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
490 fi
491 AC_SUBST(MXCPPFLAGS)
492 AC_SUBST(MXLIBS)
493 AC_SUBST(MXLND)
494 ])
495
496
497
498 #
499 # LN_CONFIG_O2IB
500 #
501 AC_DEFUN([LN_CONFIG_O2IB],[
502 AC_MSG_CHECKING([whether to enable OpenIB gen2 support])
503 # set default
504 AC_ARG_WITH([o2ib],
505         AC_HELP_STRING([--with-o2ib=path],
506                        [build o2iblnd against path]),
507         [
508                 case $with_o2ib in
509                 yes)    O2IBPATHS="$LINUX $LINUX/drivers/infiniband"
510                         ENABLEO2IB=2
511                         ;;
512                 no)     ENABLEO2IB=0
513                         ;;
514                 *)      O2IBPATHS=$with_o2ib
515                         ENABLEO2IB=3
516                         ;;
517                 esac
518         ],[
519                 O2IBPATHS="$LINUX $LINUX/drivers/infiniband"
520                 ENABLEO2IB=1
521         ])
522 if test $ENABLEO2IB -eq 0; then
523         AC_MSG_RESULT([disabled])
524 else
525         o2ib_found=false
526
527         for O2IBPATH in $O2IBPATHS; do
528                 if test \( -f ${O2IBPATH}/include/rdma/rdma_cm.h -a \
529                            -f ${O2IBPATH}/include/rdma/ib_cm.h -a \
530                            -f ${O2IBPATH}/include/rdma/ib_verbs.h -a \
531                            -f ${O2IBPATH}/include/rdma/ib_fmr_pool.h \); then
532                         o2ib_found=true
533                         break
534                 fi
535         done
536
537         if ! $o2ib_found; then
538                 AC_MSG_RESULT([no])
539                 case $ENABLEO2IB in
540                         1) ;;
541                         2) AC_MSG_ERROR([kernel OpenIB gen2 headers not present]);;
542                         3) AC_MSG_ERROR([bad --with-o2ib path]);;
543                         *) AC_MSG_ERROR([internal error]);;
544                 esac
545         else
546                 O2IBCPPFLAGS="-I$O2IBPATH/include"
547                 EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
548                 EXTRA_KCFLAGS="$EXTRA_KCFLAGS $O2IBCPPFLAGS"
549                 EXTRA_LNET_INCLUDE="$EXTRA_LNET_INCLUDE $O2IBCPPFLAGS"
550
551                 LB_LINUX_TRY_COMPILE([
552                         #include <linux/version.h>
553                         #include <linux/pci.h>
554                         #if !HAVE_GFP_T
555                         typedef int gfp_t;
556                         #endif
557                         #include <rdma/rdma_cm.h>
558                         #include <rdma/ib_cm.h>
559                         #include <rdma/ib_verbs.h>
560                         #include <rdma/ib_fmr_pool.h>
561                 ],[
562                         struct rdma_cm_id          *cm_id;
563                         struct rdma_conn_param      conn_param;
564                         struct ib_device_attr       device_attr;
565                         struct ib_qp_attr           qp_attr;
566                         struct ib_pool_fmr          pool_fmr;
567                         enum   ib_cm_rej_reason     rej_reason;
568
569                         cm_id = rdma_create_id(NULL, NULL, RDMA_PS_TCP);
570                         return PTR_ERR(cm_id);
571                 ],[
572                         AC_MSG_RESULT([yes])
573                         O2IBLND="o2iblnd"
574                 ],[
575                         AC_MSG_RESULT([no])
576                         case $ENABLEO2IB in
577                         1) ;;
578                         2) AC_MSG_ERROR([can't compile with kernel OpenIB gen2 headers]);;
579                         3) AC_MSG_ERROR([can't compile with OpenIB gen2 headers under $O2IBPATH]);;
580                         *) AC_MSG_ERROR([internal error]);;
581                         esac
582                         O2IBLND=""
583                         O2IBCPPFLAGS=""
584                 ])
585                 # we know at this point that the found OFED source is good
586                 O2IB_SYMVER=""
587                 if test $ENABLEO2IB -eq 3 ; then
588                         # OFED default rpm not handle sles10 Modules.symvers name
589                         for name in Module.symvers Modules.symvers; do
590                                 if test -f $O2IBPATH/$name; then
591                                         O2IB_SYMVER=$name;
592                                         break;
593                                 fi
594                         done
595                         if test -n "$O2IB_SYMVER"; then
596                                 AC_MSG_NOTICE([adding $O2IBPATH/Module.symvers to $PWD/$SYMVERFILE])
597                                 # strip out the existing symbols versions first
598                                 if test -f $PWD/$SYMVERFILE; then
599                                     egrep -v $(echo $(awk '{ print $2 }' $O2IBPATH/$O2IB_SYMVER) | tr ' ' '|') $PWD/$SYMVERFILE > $PWD/$SYMVERFILE.old
600                                 else
601                                     touch $PWD/$SYMVERFILE.old
602                                 fi
603                                 cat $PWD/$SYMVERFILE.old $O2IBPATH/$O2IB_SYMVER > $PWD/$SYMVERFILE
604                                 rm $PWD/$SYMVERFILE.old
605                         else
606                                 AC_MSG_ERROR([an external source tree was specified for o2iblnd however I could not find a $O2IBPATH/Module.symvers there])
607                         fi
608                 fi
609
610                 AC_MSG_CHECKING([for ib_dma_map_single support])
611                 LB_LINUX_TRY_COMPILE([
612                         #include <linux/version.h>
613                         #include <linux/pci.h>
614                         #if !HAVE_GFP_T
615                         typedef int gfp_t;
616                         #endif
617                         #include <rdma/ib_verbs.h>
618                 ],[
619                         ib_dma_map_single(NULL, NULL, 0, 0);
620                         return 0;
621                 ],[
622                         AC_MSG_RESULT(yes)
623                         AC_DEFINE(HAVE_OFED_IB_DMA_MAP, 1,
624                                   [ib_dma_map_single defined])
625                 ],[
626                         AC_MSG_RESULT(no)
627                 ])
628
629                 AC_MSG_CHECKING([for OFED completion vector])
630                 LB_LINUX_TRY_COMPILE([
631                         #include <linux/version.h>
632                         #include <linux/pci.h>
633                         #if !HAVE_GFP_T
634                         typedef int gfp_t;
635                         #endif
636                         #include <rdma/ib_verbs.h>
637                 ],[
638                         ib_create_cq(NULL, NULL, NULL, NULL, 0, 0);
639                         return 0;
640                 ],[
641                         AC_MSG_RESULT(yes)
642                         AC_DEFINE(HAVE_OFED_IB_COMP_VECTOR, 1,
643                                   [has completion vector])
644                 ],[
645                         AC_MSG_RESULT(no)
646                 ])
647
648                 EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
649         fi
650 fi
651
652 AC_SUBST(EXTRA_LNET_INCLUDE)
653 AC_SUBST(O2IBCPPFLAGS)
654 AC_SUBST(O2IBLND)
655 ])
656
657 #
658 # LN_CONFIG_OPENIB
659 #
660 # check for OpenIB in the kernel
661 AC_DEFUN([LN_CONFIG_OPENIB],[
662 AC_MSG_CHECKING([whether to enable OpenIB support])
663 # set default
664 OPENIBPATH="$LINUX/drivers/infiniband"
665 AC_ARG_WITH([openib],
666         AC_HELP_STRING([--with-openib=path],
667                        [build openiblnd against path]),
668         [
669                 case $with_openib in
670                 yes)    ENABLEOPENIB=2
671                         ;;
672                 no)     ENABLEOPENIB=0
673                         ;;
674                 *)      OPENIBPATH="$with_openib"
675                         ENABLEOPENIB=3
676                         ;;
677                 esac
678         ],[
679                 ENABLEOPENIB=1
680         ])
681 if test $ENABLEOPENIB -eq 0; then
682         AC_MSG_RESULT([disabled])
683 elif test ! \( -f ${OPENIBPATH}/include/ts_ib_core.h -a \
684                -f ${OPENIBPATH}/include/ts_ib_cm.h -a \
685                -f ${OPENIBPATH}/include/ts_ib_sa_client.h \); then
686         AC_MSG_RESULT([no])
687         case $ENABLEOPENIB in
688         1) ;;
689         2) AC_MSG_ERROR([kernel OpenIB headers not present]);;
690         3) AC_MSG_ERROR([bad --with-openib path]);;
691         *) AC_MSG_ERROR([internal error]);;
692         esac
693 else
694         case $ENABLEOPENIB in
695         1|2) OPENIBCPPFLAGS="-I$OPENIBPATH/include -DIN_TREE_BUILD";;
696         3)   OPENIBCPPFLAGS="-I$OPENIBPATH/include";;
697         *)   AC_MSG_RESULT([no])
698              AC_MSG_ERROR([internal error]);;
699         esac
700         OPENIBCPPFLAGS="$OPENIBCPPFLAGS -DIB_NTXRXPARAMS=4"
701         EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
702         EXTRA_KCFLAGS="$EXTRA_KCFLAGS $OPENIBCPPFLAGS"
703         LB_LINUX_TRY_COMPILE([
704                 #include <ts_ib_core.h>
705                 #include <ts_ib_cm.h>
706                 #include <ts_ib_sa_client.h>
707         ],[
708                 struct ib_device_properties dev_props;
709                 struct ib_cm_active_param   cm_active_params;
710                 tTS_IB_CLIENT_QUERY_TID     tid;
711                 int                         enum1 = IB_QP_ATTRIBUTE_STATE;
712                 int                         enum2 = IB_ACCESS_LOCAL_WRITE;
713                 int                         enum3 = IB_CQ_CALLBACK_INTERRUPT;
714                 int                         enum4 = IB_CQ_PROVIDER_REARM;
715                 return 0;
716         ],[
717                 AC_MSG_RESULT([yes])
718                 OPENIBLND="openiblnd"
719         ],[
720                 AC_MSG_RESULT([no])
721                 case $ENABLEOPENIB in
722                 1) ;;
723                 2) AC_MSG_ERROR([can't compile with kernel OpenIB headers]);;
724                 3) AC_MSG_ERROR([can't compile with OpenIB headers under $OPENIBPATH]);;
725                 *) AC_MSG_ERROR([internal error]);;
726                 esac
727                 OPENIBLND=""
728                 OPENIBCPPFLAGS=""
729         ])
730         EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
731 fi
732 AC_SUBST(OPENIBCPPFLAGS)
733 AC_SUBST(OPENIBLND)
734 ])
735
736 #
737 # LN_CONFIG_CIBLND
738 #
739 AC_DEFUN([LN_CONFIG_CIB],[
740 AC_MSG_CHECKING([whether to enable Cisco/TopSpin IB support])
741 # set default
742 CIBPATH=""
743 CIBLND=""
744 AC_ARG_WITH([cib],
745         AC_HELP_STRING([--with-cib=path],
746                        [build ciblnd against path]),
747         [
748                 case $with_cib in
749                 no)     AC_MSG_RESULT([no]);;
750                 *)      CIBPATH="$with_cib"
751                         if test -d "$CIBPATH"; then
752                                 AC_MSG_RESULT([yes])
753                         else
754                                 AC_MSG_RESULT([no])
755                                 AC_MSG_ERROR([No directory $CIBPATH])
756                         fi;;
757                 esac
758         ],[
759                 AC_MSG_RESULT([no])
760         ])
761 if test -n "$CIBPATH"; then
762         CIBCPPFLAGS="-I${CIBPATH}/ib/ts_api_ng/include -I${CIBPATH}/all/kernel_services/include -DUSING_TSAPI"
763         CIBCPPFLAGS="$CIBCPPFLAGS -DIB_NTXRXPARAMS=3"
764         EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
765         EXTRA_KCFLAGS="$EXTRA_KCFLAGS $CIBCPPFLAGS"
766         LB_LINUX_TRY_COMPILE([
767                 #include <ts_ib_core.h>
768                 #include <ts_ib_cm.h>
769                 #include <ts_ib_sa_client.h>
770         ],[
771                 struct ib_device_properties dev_props;
772                 struct ib_cm_active_param   cm_active_params;
773                 tTS_IB_CLIENT_QUERY_TID     tid;
774                 int                         enum1 = TS_IB_QP_ATTRIBUTE_STATE;
775                 int                         enum2 = TS_IB_ACCESS_LOCAL_WRITE;
776                 int                         enum3 = TS_IB_CQ_CALLBACK_INTERRUPT;
777                 int                         enum4 = TS_IB_CQ_PROVIDER_REARM;
778                 return 0;
779         ],[
780                 CIBLND="ciblnd"
781         ],[
782                 AC_MSG_ERROR([can't compile ciblnd with given path])
783                 CIBCPPFLAGS=""
784         ])
785         EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
786 fi
787 AC_SUBST(CIBCPPFLAGS)
788 AC_SUBST(CIBLND)
789 ])
790
791 #
792 # LN_CONFIG_IIB
793 #
794 # check for infinicon infiniband support
795 #
796 AC_DEFUN([LN_CONFIG_IIB],[
797 AC_MSG_CHECKING([whether to enable Infinicon support])
798 # set default
799 IIBPATH="/usr/include"
800 AC_ARG_WITH([iib],
801         AC_HELP_STRING([--with-iib=path],
802                        [build iiblnd against path]),
803         [
804                 case $with_iib in
805                 yes)    ENABLEIIB=2
806                         ;;
807                 no)     ENABLEIIB=0
808                         ;;
809                 *)      IIBPATH="${with_iib}/include"
810                         ENABLEIIB=3
811                         ;;
812                 esac
813         ],[
814                 ENABLEIIB=1
815         ])
816 if test $ENABLEIIB -eq 0; then
817         AC_MSG_RESULT([disabled])
818 elif test ! \( -f ${IIBPATH}/linux/iba/ibt.h \); then
819         AC_MSG_RESULT([no])
820         case $ENABLEIIB in
821         1) ;;
822         2) AC_MSG_ERROR([default Infinicon headers not present]);;
823         3) AC_MSG_ERROR([bad --with-iib path]);;
824         *) AC_MSG_ERROR([internal error]);;
825         esac
826 else
827         IIBCPPFLAGS="-I$IIBPATH"
828         if test $IIBPATH != "/usr/include"; then
829                 # we need /usr/include come what may
830                 IIBCPPFLAGS="$IIBCPPFLAGS -I/usr/include"
831         fi
832         EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
833         EXTRA_KCFLAGS="$EXTRA_KCFLAGS $IIBCPPFLAGS"
834         LB_LINUX_TRY_COMPILE([
835                 #include <linux/iba/ibt.h>
836         ],[
837                 IBT_INTERFACE_UNION interfaces;
838                 FSTATUS             rc;
839
840                  rc = IbtGetInterfaceByVersion(IBT_INTERFACE_VERSION_2,
841                                                &interfaces);
842
843                 return rc == FSUCCESS ? 0 : 1;
844         ],[
845                 AC_MSG_RESULT([yes])
846                 IIBLND="iiblnd"
847         ],[
848                 AC_MSG_RESULT([no])
849                 case $ENABLEIIB in
850                 1) ;;
851                 2) AC_MSG_ERROR([can't compile with default Infinicon headers]);;
852                 3) AC_MSG_ERROR([can't compile with Infinicon headers under $IIBPATH]);;
853                 *) AC_MSG_ERROR([internal error]);;
854                 esac
855                 IIBLND=""
856                 IIBCPPFLAGS=""
857         ])
858         EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
859 fi
860 AC_SUBST(IIBCPPFLAGS)
861 AC_SUBST(IIBLND)
862 ])
863
864 #
865 # LN_CONFIG_VIB
866 #
867 # check for Voltaire infiniband support
868 #
869 AC_DEFUN([LN_CONFIG_VIB],
870 [AC_MSG_CHECKING([whether to enable Voltaire IB support])
871 VIBPATH=""
872 AC_ARG_WITH([vib],
873         AC_HELP_STRING([--with-vib=path],
874                        [build viblnd against path]),
875         [
876                 case $with_vib in
877                 no)     AC_MSG_RESULT([no]);;
878                 *)      VIBPATH="${with_vib}/src/nvigor/ib-code"
879                         if test -d "$with_vib" -a -d "$VIBPATH"; then
880                                 AC_MSG_RESULT([yes])
881                         else
882                                 AC_MSG_RESULT([no])
883                                 AC_MSG_ERROR([No directory $VIBPATH])
884                         fi;;
885                 esac
886         ],[
887                 AC_MSG_RESULT([no])
888         ])
889 if test -z "$VIBPATH"; then
890         VIBLND=""
891 else
892         VIBCPPFLAGS="-I${VIBPATH}/include -I${VIBPATH}/cm"
893         EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
894         EXTRA_KCFLAGS="$EXTRA_KCFLAGS $VIBCPPFLAGS"
895         LB_LINUX_TRY_COMPILE([
896                 #include <linux/list.h>
897                 #include <asm/byteorder.h>
898                 #ifdef __BIG_ENDIAN
899                 # define CPU_BE 1
900                 # define CPU_LE 0
901                 #endif
902                 #ifdef __LITTLE_ENDIAN
903                 # define CPU_BE 0
904                 # define CPU_LE 1
905                 #endif
906                 #include <vverbs.h>
907                 #include <ib-cm.h>
908                 #include <ibat.h>
909         ],[
910                 vv_hca_h_t       kib_hca;
911                 vv_return_t      vvrc;
912                 cm_cep_handle_t  cep;
913                 ibat_arp_data_t  arp_data;
914                 ibat_stat_t      ibatrc;
915
916                 vvrc = vv_hca_open("ANY_HCA", NULL, &kib_hca);
917                 cep = cm_create_cep(cm_cep_transp_rc);
918                 ibatrc = ibat_get_ib_data((uint32_t)0, (uint32_t)0,
919                                           ibat_paths_primary, &arp_data,
920                                           (ibat_get_ib_data_reply_fn_t)NULL,
921                                           NULL, 0);
922                 return 0;
923         ],[
924                 VIBLND="viblnd"
925         ],[
926                 AC_MSG_ERROR([can't compile viblnd with given path])
927         ])
928         EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
929 fi
930 if test -n "$VIBLND"; then
931         EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
932         EXTRA_KCFLAGS="$EXTRA_KCFLAGS $VIBCPPFLAGS"
933         AC_MSG_CHECKING([if Voltaire still uses void * sg addresses])
934         LB_LINUX_TRY_COMPILE([
935                 #include <linux/list.h>
936                 #include <asm/byteorder.h>
937                 #ifdef __BIG_ENDIAN
938                 # define CPU_BE 1
939                 # define CPU_LE 0
940                 #endif
941                 #ifdef __LITTLE_ENDIAN
942                 # define CPU_BE 0
943                 # define CPU_LE 1
944                 #endif
945                 #include <vverbs.h>
946                 #include <ib-cm.h>
947                 #include <ibat.h>
948         ],[
949                 vv_scatgat_t  sg;
950
951                 return &sg.v_address[3] == NULL;
952         ],[
953                 AC_MSG_RESULT([yes])
954                 VIBCPPFLAGS="$VIBCPPFLAGS -DIBNAL_VOIDSTAR_SGADDR=1"
955         ],[
956                 AC_MSG_RESULT([no])
957         ])
958         EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
959 fi
960 AC_SUBST(VIBCPPFLAGS)
961 AC_SUBST(VIBLND)
962 ])
963
964 #
965 # LN_CONFIG_RALND
966 #
967 # check whether to use the RapidArray lnd
968 #
969 AC_DEFUN([LN_CONFIG_RALND],
970 [#### Rapid Array
971 AC_MSG_CHECKING([if RapidArray kernel headers are present])
972 # placeholder
973 RACPPFLAGS="-I${LINUX}/drivers/xd1/include"
974 EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
975 EXTRA_KCFLAGS="$EXTRA_KCFLAGS $RACPPFLAGS"
976 LB_LINUX_TRY_COMPILE([
977         #include <linux/types.h>
978         #include <rapl.h>
979 ],[
980         RAP_RETURN          rc;
981         RAP_PVOID           dev_handle;
982
983         rc = RapkGetDeviceByIndex(0, NULL, &dev_handle);
984
985         return rc == RAP_SUCCESS ? 0 : 1;
986 ],[
987         AC_MSG_RESULT([yes])
988         RALND="ralnd"
989 ],[
990         AC_MSG_RESULT([no])
991         RALND=""
992         RACPPFLAGS=""
993 ])
994 EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
995 AC_SUBST(RACPPFLAGS)
996 AC_SUBST(RALND)
997 ])
998
999 #
1000 # LN_STRUCT_PAGE_LIST
1001 #
1002 # 2.6.4 no longer has page->list
1003 #
1004 AC_DEFUN([LN_STRUCT_PAGE_LIST],
1005 [AC_MSG_CHECKING([if struct page has a list field])
1006 LB_LINUX_TRY_COMPILE([
1007         #include <linux/mm.h>
1008 ],[
1009         struct page page;
1010         &page.list;
1011 ],[
1012         AC_MSG_RESULT([yes])
1013         AC_DEFINE(HAVE_PAGE_LIST, 1, [struct page has a list field])
1014 ],[
1015         AC_MSG_RESULT([no])
1016 ])
1017 ])
1018
1019 #
1020 # LN_STRUCT_SIGHAND
1021 #
1022 # red hat 2.4 adds sighand to struct task_struct
1023 #
1024 AC_DEFUN([LN_STRUCT_SIGHAND],
1025 [AC_MSG_CHECKING([if task_struct has a sighand field])
1026 LB_LINUX_TRY_COMPILE([
1027         #include <linux/sched.h>
1028 ],[
1029         struct task_struct p;
1030         p.sighand = NULL;
1031 ],[
1032         AC_DEFINE(CONFIG_RH_2_4_20, 1, [this kernel contains Red Hat 2.4.20 patches])
1033         AC_MSG_RESULT([yes])
1034 ],[
1035         AC_MSG_RESULT([no])
1036 ])
1037 ])
1038
1039 #
1040 # LN_FUNC_CPU_ONLINE
1041 #
1042 # cpu_online is different in rh 2.4, vanilla 2.4, and 2.6
1043 #
1044 AC_DEFUN([LN_FUNC_CPU_ONLINE],
1045 [AC_MSG_CHECKING([if kernel defines cpu_online()])
1046 LB_LINUX_TRY_COMPILE([
1047         #include <linux/sched.h>
1048 ],[
1049         cpu_online(0);
1050 ],[
1051         AC_MSG_RESULT([yes])
1052         AC_DEFINE(HAVE_CPU_ONLINE, 1, [cpu_online found])
1053 ],[
1054         AC_MSG_RESULT([no])
1055 ])
1056 ])
1057
1058 #
1059 # LN_TYPE_GFP_T
1060 #
1061 # check if gfp_t is typedef-ed
1062 #
1063 AC_DEFUN([LN_TYPE_GFP_T],
1064 [AC_MSG_CHECKING([if kernel defines gfp_t])
1065 LB_LINUX_TRY_COMPILE([
1066         #include <linux/gfp.h>
1067 ],[
1068         return sizeof(gfp_t);
1069 ],[
1070         AC_MSG_RESULT([yes])
1071         AC_DEFINE(HAVE_GFP_T, 1, [gfp_t found])
1072 ],[
1073         AC_MSG_RESULT([no])
1074 ])
1075 ])
1076
1077 #
1078 # LN_TYPE_CPUMASK_T
1079 #
1080 # same goes for cpumask_t
1081 #
1082 AC_DEFUN([LN_TYPE_CPUMASK_T],
1083 [AC_MSG_CHECKING([if kernel defines cpumask_t])
1084 LB_LINUX_TRY_COMPILE([
1085         #include <linux/sched.h>
1086 ],[
1087         return sizeof (cpumask_t);
1088 ],[
1089         AC_MSG_RESULT([yes])
1090         AC_DEFINE(HAVE_CPUMASK_T, 1, [cpumask_t found])
1091 ],[
1092         AC_MSG_RESULT([no])
1093 ])
1094 ])
1095
1096 #
1097 # LN_FUNC_SHOW_TASK
1098 #
1099 # we export show_task(), but not all kernels have it (yet)
1100 #
1101 AC_DEFUN([LN_FUNC_SHOW_TASK],
1102 [LB_CHECK_SYMBOL_EXPORT([show_task],
1103 [kernel/ksyms.c kernel/sched.c],[
1104 AC_DEFINE(HAVE_SHOW_TASK, 1, [show_task is exported])
1105 ],[
1106 ])
1107 ])
1108
1109 # check userland __u64 type
1110 AC_DEFUN([LN_U64_LONG_LONG],
1111 [AC_MSG_CHECKING([__u64 is long long type])
1112 tmp_flags="$CFLAGS"
1113 CFLAGS="$CFLAGS -Werror"
1114 AC_COMPILE_IFELSE([
1115         #include <linux/types.h>
1116         int main(void) {
1117                 unsigned long long *data1;
1118                 __u64 *data2;
1119                 
1120                 data1 = data2;
1121                 return 0;
1122         }
1123 ],[
1124         AC_MSG_RESULT([yes])
1125         AC_DEFINE(HAVE_U64_LONG_LONG, 1,
1126                   [__u64 is long long type])
1127 ],[
1128         AC_MSG_RESULT([no])
1129 ])
1130 CFLAGS="$tmp_flags"
1131 ])
1132
1133 # check userland size_t type
1134 AC_DEFUN([LN_SIZE_T_LONG],
1135 [AC_MSG_CHECKING([size_t is unsigned long type])
1136 tmp_flags="$CFLAGS"
1137 CFLAGS="$CFLAGS -Werror"
1138 AC_COMPILE_IFELSE([
1139         #include <linux/types.h>
1140         int main(void) {
1141                 unsigned long *data1;
1142                 size_t *data2;
1143                 
1144                 data1 = data2;
1145                 return 0;
1146         }
1147 ],[
1148         AC_MSG_RESULT([yes])
1149         AC_DEFINE(HAVE_SIZE_T_LONG, 1,
1150                   [size_t is long type])
1151 ],[
1152         AC_MSG_RESULT([no])
1153 ])
1154 CFLAGS="$tmp_flags"
1155 ])
1156
1157 AC_DEFUN([LN_SSIZE_T_LONG],
1158 [AC_MSG_CHECKING([ssize_t is signed long type])
1159 tmp_flags="$CFLAGS"
1160 CFLAGS="$CFLAGS -Werror"
1161 AC_COMPILE_IFELSE([
1162         #include <linux/types.h>
1163         int main(void) {
1164                 long *data1;
1165                 ssize_t *data2;
1166                 
1167                 data1 = data2;
1168                 return 0;
1169         }
1170 ],[
1171         AC_MSG_RESULT([yes])
1172         AC_DEFINE(HAVE_SSIZE_T_LONG, 1,
1173                   [ssize_t is long type])
1174 ],[
1175         AC_MSG_RESULT([no])
1176 ])
1177 CFLAGS="$tmp_flags"
1178 ])
1179
1180
1181 # check kernel __le16, __le32 types
1182 AC_DEFUN([LN_LE_TYPES],
1183 [AC_MSG_CHECKING([__le16 and __le32 types are defined])
1184 LB_LINUX_TRY_COMPILE([
1185         #include <linux/types.h>
1186 ],[
1187         __le16 a;
1188         __le32 b;
1189 ],[
1190         AC_MSG_RESULT([yes])
1191         AC_DEFINE(HAVE_LE_TYPES, 1,
1192                   [__le16 and __le32 types are defined])
1193 ],[
1194         AC_MSG_RESULT([no])
1195 ])
1196 ])
1197
1198
1199 # check if task_struct with rcu memeber
1200 AC_DEFUN([LN_TASK_RCU],
1201 [AC_MSG_CHECKING([if task_struct has a rcu field])
1202 LB_LINUX_TRY_COMPILE([
1203         #include <linux/sched.h>
1204 ],[
1205         struct task_struct tsk;
1206
1207         tsk.rcu.next = NULL;
1208 ],[
1209         AC_MSG_RESULT([yes])
1210         AC_DEFINE(HAVE_TASK_RCU, 1,
1211                   [task_struct has rcu field])
1212 ],[
1213         AC_MSG_RESULT([no])
1214 ])
1215 ])
1216
1217 # LN_TASKLIST_LOCK
1218 # 2.6.18 remove tasklist_lock export
1219 AC_DEFUN([LN_TASKLIST_LOCK],
1220 [LB_CHECK_SYMBOL_EXPORT([tasklist_lock],
1221 [kernel/fork.c],[
1222 AC_DEFINE(HAVE_TASKLIST_LOCK, 1,
1223          [tasklist_lock exported])
1224 ],[
1225 ])
1226 ])
1227
1228 # 2.6.19 API changes
1229 # kmem_cache_destroy(cachep) return void instead of
1230 # int
1231 AC_DEFUN([LN_KMEM_CACHE_DESTROY_INT],
1232 [AC_MSG_CHECKING([kmem_cache_destroy(cachep) return int])
1233 LB_LINUX_TRY_COMPILE([
1234         #include <linux/slab.h>
1235 ],[
1236         int i = kmem_cache_destroy(NULL);
1237 ],[
1238         AC_MSG_RESULT(yes)
1239         AC_DEFINE(HAVE_KMEM_CACHE_DESTROY_INT, 1,
1240                 [kmem_cache_destroy(cachep) return int])
1241 ],[
1242         AC_MSG_RESULT(no)
1243 ])
1244 ])
1245
1246 # 2.6.19 API change
1247 #panic_notifier_list use atomic_notifier operations
1248 #
1249 AC_DEFUN([LN_ATOMIC_PANIC_NOTIFIER],
1250 [AC_MSG_CHECKING([panic_notifier_list is atomic])
1251 LB_LINUX_TRY_COMPILE([
1252         #include <linux/notifier.h>
1253         #include <linux/kernel.h>
1254 ],[
1255         struct atomic_notifier_head panic_notifier_list;
1256 ],[
1257         AC_MSG_RESULT(yes)
1258         AC_DEFINE(HAVE_ATOMIC_PANIC_NOTIFIER, 1,
1259                 [panic_notifier_list is atomic_notifier_head])
1260 ],[
1261         AC_MSG_RESULT(no)
1262 ])
1263 ])
1264
1265 # 2.6.20 API change INIT_WORK use 2 args and not
1266 # store data inside
1267 AC_DEFUN([LN_3ARGS_INIT_WORK],
1268 [AC_MSG_CHECKING([check INIT_WORK want 3 args])
1269 LB_LINUX_TRY_COMPILE([
1270         #include <linux/workqueue.h>
1271 ],[
1272         struct work_struct work;
1273
1274         INIT_WORK(&work, NULL, NULL);
1275 ],[
1276         AC_MSG_RESULT(yes)
1277         AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
1278                   [INIT_WORK use 3 args and store data inside])
1279 ],[
1280         AC_MSG_RESULT(no)
1281 ])
1282 ])
1283
1284 # 2.6.21 api change. 'register_sysctl_table' use only one argument,
1285 # instead of more old which need two.
1286 AC_DEFUN([LN_2ARGS_REGISTER_SYSCTL],
1287 [AC_MSG_CHECKING([check register_sysctl_table want 2 args])
1288 LB_LINUX_TRY_COMPILE([
1289         #include <linux/sysctl.h>
1290 ],[
1291         return register_sysctl_table(NULL,0);
1292 ],[
1293         AC_MSG_RESULT(yes)
1294         AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
1295                   [register_sysctl_table want 2 args])
1296 ],[
1297         AC_MSG_RESULT(no)
1298 ])
1299 ])
1300
1301 # 2.6.21 marks kmem_cache_t deprecated and uses struct kmem_cache
1302 # instead
1303 AC_DEFUN([LN_KMEM_CACHE],
1304 [AC_MSG_CHECKING([check kernel has struct kmem_cache])
1305 tmp_flags="$EXTRA_KCFLAGS"
1306 EXTRA_KCFLAGS="-Werror"
1307 LB_LINUX_TRY_COMPILE([
1308         #include <linux/slab.h>
1309         typedef struct kmem_cache cache_t;
1310 ],[
1311         cache_t *cachep = NULL;
1312
1313         kmem_cache_alloc(cachep, 0);
1314 ],[
1315         AC_MSG_RESULT(yes)
1316         AC_DEFINE(HAVE_KMEM_CACHE, 1,
1317                   [kernel has struct kmem_cache])
1318 ],[
1319         AC_MSG_RESULT(no)
1320 ])
1321 EXTRA_KCFLAGS="$tmp_flags"
1322 ])
1323 # 2.6.23 lost dtor argument
1324 AC_DEFUN([LN_KMEM_CACHE_CREATE_DTOR],
1325 [AC_MSG_CHECKING([check kmem_cache_create has dtor argument])
1326 LB_LINUX_TRY_COMPILE([
1327         #include <linux/slab.h>
1328 ],[
1329         kmem_cache_create(NULL, 0, 0, 0, NULL, NULL);
1330 ],[
1331         AC_MSG_RESULT(yes)
1332         AC_DEFINE(HAVE_KMEM_CACHE_CREATE_DTOR, 1,
1333                   [kmem_cache_create has dtor argument])
1334 ],[
1335         AC_MSG_RESULT(no)
1336 ])
1337 ])
1338
1339 # 2.6.24 request not use real numbers for ctl_name
1340 AC_DEFUN([LN_SYSCTL_UNNUMBERED],
1341 [AC_MSG_CHECKING([for CTL_UNNUMBERED])
1342 LB_LINUX_TRY_COMPILE([
1343         #include <linux/sysctl.h>
1344 ],[
1345         #ifndef CTL_UNNUMBERED
1346         #error CTL_UNNUMBERED not exist in kernel
1347         #endif
1348 ],[
1349         AC_MSG_RESULT(yes)
1350         AC_DEFINE(HAVE_SYSCTL_UNNUMBERED, 1,
1351                   [sysctl has CTL_UNNUMBERED])
1352 ],[
1353         AC_MSG_RESULT(no)
1354 ])
1355 ])
1356
1357 # 2.6.24 lost scatterlist->page
1358 AC_DEFUN([LN_SCATTERLIST_SETPAGE],
1359 [AC_MSG_CHECKING([for exist sg_set_page])
1360 LB_LINUX_TRY_COMPILE([
1361         #include <linux/scatterlist.h>
1362 ],[
1363         sg_set_page(NULL,NULL,0,0);
1364 ],[
1365         AC_MSG_RESULT(yes)
1366         AC_DEFINE(HAVE_SCATTERLIST_SETPAGE, 1,
1367                   [struct scatterlist has page member])
1368 ],[
1369         AC_MSG_RESULT(no)
1370 ])
1371 ])
1372
1373 # 2.6.26 use int instead of atomic for sem.count
1374 AC_DEFUN([LN_SEM_COUNT],
1375 [AC_MSG_CHECKING([atomic sem.count])
1376 LB_LINUX_TRY_COMPILE([
1377         #include <asm/semaphore.h>
1378 ],[
1379         struct semaphore s;
1380         
1381         atomic_read(&s.count);
1382 ],[
1383         AC_MSG_RESULT(yes)
1384         AC_DEFINE(HAVE_SEM_COUNT_ATOMIC, 1,
1385                   [semaphore counter is atomic])
1386 ],[
1387         AC_MSG_RESULT(no)
1388 ])
1389 ])
1390
1391 #
1392 # LN_FUNC_DUMP_TRACE
1393 #
1394 # 2.6.27 exports dump_trace() so we can dump_stack() on any task
1395 #
1396 AC_DEFUN([LN_FUNC_DUMP_TRACE],
1397 [LB_CHECK_SYMBOL_EXPORT([dump_trace],
1398 [kernel/ksyms.c arch/${LINUX_ARCH%_64}/kernel/traps_64.c],[
1399         AC_DEFINE(HAVE_DUMP_TRACE, 1, [dump_trace is exported])
1400 ],[
1401 ])
1402 ])
1403
1404 # 2.6.27 have second argument to sock_map_fd
1405 AC_DEFUN([LN_SOCK_MAP_FD_2ARG],
1406 [AC_MSG_CHECKING([sock_map_fd have second argument])
1407 LB_LINUX_TRY_COMPILE([
1408         #include <linux/net.h>
1409 ],[
1410         sock_map_fd(NULL, 0);
1411 ],[
1412         AC_MSG_RESULT(yes)
1413         AC_DEFINE(HAVE_SOCK_MAP_FD_2ARG, 1,
1414                   [sock_map_fd have second argument])
1415 ],[
1416         AC_MSG_RESULT(no)
1417 ])
1418 ])
1419
1420 #
1421 # LN_PROG_LINUX
1422 #
1423 # LNet linux kernel checks
1424 #
1425 AC_DEFUN([LN_PROG_LINUX],
1426 [
1427 LN_FUNC_CPU_ONLINE
1428 LN_TYPE_GFP_T
1429 LN_TYPE_CPUMASK_T
1430 LN_CONFIG_AFFINITY
1431 LN_CONFIG_BACKOFF
1432 LN_CONFIG_PANIC_DUMPLOG
1433 LN_CONFIG_QUADRICS
1434 LN_CONFIG_GM
1435 LN_CONFIG_OPENIB
1436 LN_CONFIG_CIB
1437 LN_CONFIG_VIB
1438 LN_CONFIG_IIB
1439 LN_CONFIG_O2IB
1440 LN_CONFIG_RALND
1441 LN_CONFIG_PTLLND
1442 LN_CONFIG_MX
1443
1444 LN_STRUCT_PAGE_LIST
1445 LN_STRUCT_SIGHAND
1446 LN_FUNC_SHOW_TASK
1447 LN_U64_LONG_LONG
1448 LN_SSIZE_T_LONG
1449 LN_SIZE_T_LONG
1450 LN_LE_TYPES
1451 LN_TASK_RCU
1452 # 2.6.18
1453 LN_TASKLIST_LOCK
1454 # 2.6.19
1455 LN_KMEM_CACHE_DESTROY_INT
1456 LN_ATOMIC_PANIC_NOTIFIER
1457 # 2.6.20
1458 LN_3ARGS_INIT_WORK
1459 # 2.6.21
1460 LN_2ARGS_REGISTER_SYSCTL
1461 LN_KMEM_CACHE
1462 # 2.6.23
1463 LN_KMEM_CACHE_CREATE_DTOR
1464 # 2.6.24
1465 LN_SYSCTL_UNNUMBERED
1466 LN_SCATTERLIST_SETPAGE
1467 # 2.6.26
1468 LN_SEM_COUNT
1469 # 2.6.27
1470 LN_SOCK_MAP_FD_2ARG
1471 LN_FUNC_DUMP_TRACE
1472 ])
1473
1474 #
1475 # LN_PROG_DARWIN
1476 #
1477 # Darwin checks
1478 #
1479 AC_DEFUN([LN_PROG_DARWIN],
1480 [LB_DARWIN_CHECK_FUNCS([get_preemption_level])
1481 ])
1482
1483 #
1484 # LN_PATH_DEFAULTS
1485 #
1486 # default paths for installed files
1487 #
1488 AC_DEFUN([LN_PATH_DEFAULTS],
1489 [
1490 ])
1491
1492 #
1493 # LN_CONFIGURE
1494 #
1495 # other configure checks
1496 #
1497 AC_DEFUN([LN_CONFIGURE],
1498 [# lnet/utils/portals.c
1499 AC_CHECK_HEADERS([netdb.h netinet/tcp.h asm/types.h endian.h sys/ioctl.h])
1500 AC_CHECK_FUNCS([gethostbyname socket connect])
1501
1502 # lnet/utils/debug.c
1503 AC_CHECK_HEADERS([linux/version.h])
1504
1505 AC_CHECK_TYPE([spinlock_t],
1506         [AC_DEFINE(HAVE_SPINLOCK_T, 1, [spinlock_t is defined])],
1507         [],
1508         [#include <linux/spinlock.h>])
1509
1510 # lnet/utils/wirecheck.c
1511 AC_CHECK_FUNCS([strnlen])
1512
1513 # --------  Check for required packages  --------------
1514
1515 #
1516 # LC_CONFIG_READLINE
1517 #
1518 # Build with readline
1519 #
1520 AC_MSG_CHECKING([whether to enable readline support])
1521 AC_ARG_ENABLE(readline,
1522         AC_HELP_STRING([--disable-readline],
1523                         [disable readline support]),
1524         [],[enable_readline='yes'])
1525 AC_MSG_RESULT([$enable_readline])
1526
1527 # -------- check for readline if enabled ----
1528 if test x$enable_readline = xyes ; then
1529         LIBS_save="$LIBS"
1530         LIBS="-lncurses $LIBS"
1531         AC_CHECK_LIB([readline],[readline],[
1532         LIBREADLINE="-lreadline -lncurses"
1533         AC_DEFINE(HAVE_LIBREADLINE, 1, [readline library is available])
1534         ],[
1535         LIBREADLINE=""
1536         ])
1537         LIBS="$LIBS_save"
1538 else
1539         LIBREADLINE=""
1540 fi
1541 AC_SUBST(LIBREADLINE)
1542
1543 AC_MSG_CHECKING([if efence debugging support is requested])
1544 AC_ARG_ENABLE(efence,
1545         AC_HELP_STRING([--enable-efence],
1546                         [use efence library]),
1547         [],[enable_efence='no'])
1548 AC_MSG_RESULT([$enable_efence])
1549 if test "$enable_efence" = "yes" ; then
1550         LIBEFENCE="-lefence"
1551         AC_DEFINE(HAVE_LIBEFENCE, 1, [libefence support is requested])
1552 else
1553         LIBEFENCE=""
1554 fi
1555 AC_SUBST(LIBEFENCE)
1556
1557 # -------- enable acceptor libwrap (TCP wrappers) support? -------
1558 AC_MSG_CHECKING([if libwrap support is requested])
1559 AC_ARG_ENABLE([libwrap],
1560         AC_HELP_STRING([--enable-libwrap], [use TCP wrappers]),
1561         [case "${enableval}" in
1562                 yes) enable_libwrap=yes ;;
1563                 no) enable_libwrap=no ;;
1564                 *) AC_MSG_ERROR(bad value ${enableval} for --enable-libwrap) ;;
1565         esac],[enable_libwrap=no])
1566 AC_MSG_RESULT([$enable_libwrap])
1567 if test x$enable_libwrap = xyes ; then
1568         LIBWRAP="-lwrap"
1569         AC_DEFINE(HAVE_LIBWRAP, 1, [libwrap support is requested])
1570 else
1571         LIBWRAP=""
1572 fi
1573 AC_SUBST(LIBWRAP)
1574
1575 # -------- check for -lpthread support ----
1576 AC_MSG_CHECKING([whether to use libpthread for lnet library])
1577 AC_ARG_ENABLE([libpthread],
1578         AC_HELP_STRING([--disable-libpthread],
1579                 [disable libpthread]),
1580         [],[enable_libpthread=yes])
1581 if test "$enable_libpthread" = "yes" ; then
1582         AC_CHECK_LIB([pthread], [pthread_create],
1583                 [ENABLE_LIBPTHREAD="yes"],
1584                 [ENABLE_LIBPTHREAD="no"])
1585         if test "$ENABLE_LIBPTHREAD" = "yes" ; then
1586                 AC_MSG_RESULT([$ENABLE_LIBPTHREAD])
1587                 PTHREAD_LIBS="-lpthread"
1588                 AC_DEFINE([HAVE_LIBPTHREAD], 1, [use libpthread])
1589         else
1590                 PTHREAD_LIBS=""
1591                 AC_MSG_RESULT([no libpthread is found])
1592         fi
1593         AC_SUBST(PTHREAD_LIBS)
1594 else
1595         AC_MSG_RESULT([no (disabled explicitly)])
1596         ENABLE_LIBPTHREAD="no"
1597 fi
1598 AC_SUBST(ENABLE_LIBPTHREAD)
1599
1600 # ----------------------------------------
1601 # some tests for catamount-like systems
1602 # ----------------------------------------
1603 AC_ARG_ENABLE([sysio_init],
1604         AC_HELP_STRING([--disable-sysio-init],
1605                 [call sysio init functions when initializing liblustre]),
1606         [],[enable_sysio_init=yes])
1607 AC_MSG_CHECKING([whether to initialize libsysio])
1608 AC_MSG_RESULT([$enable_sysio_init])
1609 if test x$enable_sysio_init != xno ; then
1610         AC_DEFINE([INIT_SYSIO], 1, [call sysio init functions])
1611 fi
1612
1613 AC_ARG_ENABLE([urandom],
1614         AC_HELP_STRING([--disable-urandom],
1615                 [disable use of /dev/urandom for liblustre]),
1616         [],[enable_urandom=yes])
1617 AC_MSG_CHECKING([whether to use /dev/urandom for liblustre])
1618 AC_MSG_RESULT([$enable_urandom])
1619 if test x$enable_urandom != xno ; then
1620         AC_DEFINE([LIBLUSTRE_USE_URANDOM], 1, [use /dev/urandom for random data])
1621 fi
1622
1623 # -------- check for -lcap support ----
1624 if test x$enable_liblustre = xyes ; then
1625         AC_CHECK_LIB([cap], [cap_get_proc],
1626                 [
1627                         CAP_LIBS="-lcap"
1628                         AC_DEFINE([HAVE_LIBCAP], 1, [use libcap])
1629                 ],
1630                 [
1631                         CAP_LIBS=""
1632                 ])
1633         AC_SUBST(CAP_LIBS)
1634
1635 fi
1636
1637 LN_CONFIG_MAX_PAYLOAD
1638 LN_CONFIG_UPTLLND
1639 LN_CONFIG_USOCKLND
1640 ])
1641
1642 #
1643 # LN_CONDITIONALS
1644 #
1645 # AM_CONDITOINAL defines for lnet
1646 #
1647 AC_DEFUN([LN_CONDITIONALS],
1648 [AM_CONDITIONAL(BUILD_QSWLND, test x$QSWLND = "xqswlnd")
1649 AM_CONDITIONAL(BUILD_GMLND, test x$GMLND = "xgmlnd")
1650 AM_CONDITIONAL(BUILD_MXLND, test x$MXLND = "xmxlnd")
1651 AM_CONDITIONAL(BUILD_O2IBLND, test x$O2IBLND = "xo2iblnd")
1652 AM_CONDITIONAL(BUILD_OPENIBLND, test x$OPENIBLND = "xopeniblnd")
1653 AM_CONDITIONAL(BUILD_CIBLND, test x$CIBLND = "xciblnd")
1654 AM_CONDITIONAL(BUILD_IIBLND, test x$IIBLND = "xiiblnd")
1655 AM_CONDITIONAL(BUILD_VIBLND, test x$VIBLND = "xviblnd")
1656 AM_CONDITIONAL(BUILD_RALND, test x$RALND = "xralnd")
1657 AM_CONDITIONAL(BUILD_PTLLND, test x$PTLLND = "xptllnd")
1658 AM_CONDITIONAL(BUILD_UPTLLND, test x$UPTLLND = "xptllnd")
1659 AM_CONDITIONAL(BUILD_USOCKLND, test x$USOCKLND = "xusocklnd")
1660 ])
1661
1662 #
1663 # LN_CONFIG_FILES
1664 #
1665 # files that should be generated with AC_OUTPUT
1666 #
1667 AC_DEFUN([LN_CONFIG_FILES],
1668 [AC_CONFIG_FILES([
1669 lnet/Kernelenv
1670 lnet/Makefile
1671 lnet/autoMakefile
1672 lnet/autoconf/Makefile
1673 lnet/doc/Makefile
1674 lnet/include/Makefile
1675 lnet/include/libcfs/Makefile
1676 lnet/include/libcfs/linux/Makefile
1677 lnet/include/lnet/Makefile
1678 lnet/include/lnet/linux/Makefile
1679 lnet/klnds/Makefile
1680 lnet/klnds/autoMakefile
1681 lnet/klnds/gmlnd/Makefile
1682 lnet/klnds/mxlnd/autoMakefile
1683 lnet/klnds/mxlnd/Makefile
1684 lnet/klnds/gmlnd/autoMakefile
1685 lnet/klnds/openiblnd/Makefile
1686 lnet/klnds/openiblnd/autoMakefile
1687 lnet/klnds/o2iblnd/Makefile
1688 lnet/klnds/o2iblnd/autoMakefile
1689 lnet/klnds/ciblnd/Makefile
1690 lnet/klnds/ciblnd/autoMakefile
1691 lnet/klnds/iiblnd/Makefile
1692 lnet/klnds/iiblnd/autoMakefile
1693 lnet/klnds/viblnd/Makefile
1694 lnet/klnds/viblnd/autoMakefile
1695 lnet/klnds/qswlnd/Makefile
1696 lnet/klnds/qswlnd/autoMakefile
1697 lnet/klnds/ralnd/Makefile
1698 lnet/klnds/ralnd/autoMakefile
1699 lnet/klnds/socklnd/Makefile
1700 lnet/klnds/socklnd/autoMakefile
1701 lnet/klnds/ptllnd/Makefile
1702 lnet/klnds/ptllnd/autoMakefile
1703 lnet/libcfs/Makefile
1704 lnet/libcfs/autoMakefile
1705 lnet/libcfs/linux/Makefile
1706 lnet/lnet/Makefile
1707 lnet/lnet/autoMakefile
1708 lnet/selftest/Makefile
1709 lnet/selftest/autoMakefile
1710 lnet/ulnds/Makefile
1711 lnet/ulnds/autoMakefile
1712 lnet/ulnds/socklnd/Makefile
1713 lnet/ulnds/ptllnd/Makefile
1714 lnet/utils/Makefile
1715 ])
1716 case $lb_target_os in
1717         darwin)
1718                 AC_CONFIG_FILES([
1719 lnet/include/libcfs/darwin/Makefile
1720 lnet/include/lnet/darwin/Makefile
1721 lnet/libcfs/darwin/Makefile
1722 ])
1723                 ;;
1724 esac
1725 ])
1726
1727 #
1728 # LIBCFS stub macros. (These are defined in the libcfs module on HEAD))
1729 #
1730 AC_DEFUN([LIBCFS_PATH_DEFAULTS], [])
1731 AC_DEFUN([LIBCFS_PROG_LINUX], [])
1732 AC_DEFUN([LIBCFS_CONDITIONALS], [])
1733 AC_DEFUN([LIBCFS_CONFIGURE], [])
1734 AC_DEFUN([LIBCFS_CONFIG_FILES], [])