Whamcloud - gitweb
LU-8056 llite: use inode_lock to access i_mutex
[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                 CONFIG_LNET_MAX_PAYLOAD_MB=$with_max_payload_mb
14                 CONFIG_LNET_MAX_PAYLOAD="(($with_max_payload_mb)<<20)"
15         ], [
16                 AC_MSG_RESULT([no])
17                 CONFIG_LNET_MAX_PAYLOAD="LNET_MTU"
18         ])
19 AC_DEFINE_UNQUOTED(CONFIG_LNET_MAX_PAYLOAD, $CONFIG_LNET_MAX_PAYLOAD,
20         [Max LNET payload])
21 ]) # LN_CONFIG_MAX_PAYLOAD
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 ]) # LN_CHECK_GCC_VERSION
43
44 #
45 # LN_CONFIG_AFFINITY
46 #
47 # check if cpu affinity is available/wanted
48 #
49 AC_DEFUN([LN_CONFIG_AFFINITY], [
50 AC_MSG_CHECKING([whether to enable CPU affinity support])
51 AC_ARG_ENABLE([affinity],
52         AC_HELP_STRING([--disable-affinity],
53                 [disable process/irq affinity]),
54         [], [enable_affinity="yes"])
55 AC_MSG_RESULT([$enable_affinity])
56 AS_IF([test "x$enable_affinity" = xyes], [
57         LB_CHECK_COMPILE([if Linux kernel has cpu affinity support],
58         set_cpus_allowed_ptr, [
59                 #include <linux/sched.h>
60         ],[
61                 struct task_struct *t;
62                 #if HAVE_CPUMASK_T
63                 cpumask_t     m;
64                 #else
65                 unsigned long m;
66                 #endif
67                 set_cpus_allowed_ptr(t, &m);
68         ],[
69                 AC_DEFINE(CPU_AFFINITY, 1,
70                         [kernel has cpu affinity support])
71         ])
72 ])
73 ]) # LN_CONFIG_AFFINITY
74
75 #
76 # LN_CONFIG_BACKOFF
77 #
78 # check if tunable tcp backoff is available/wanted
79 #
80 AC_DEFUN([LN_CONFIG_BACKOFF], [
81 AC_MSG_CHECKING([whether to enable tunable backoff TCP support])
82 AC_ARG_ENABLE([backoff],
83         AC_HELP_STRING([--disable-backoff],
84                 [disable socknal tunable backoff]),
85         [], [enable_backoff="yes"])
86 AC_MSG_RESULT([$enable_backoff])
87 AS_IF([test "x$enable_backoff" = xyes], [
88         AC_MSG_CHECKING([if Linux kernel has tunable backoff TCP support])
89         AS_IF([grep -c TCP_BACKOFF $LINUX/include/linux/tcp.h >/dev/null], [
90                 AC_MSG_RESULT([yes])
91                 AC_DEFINE(SOCKNAL_BACKOFF, 1, [use tunable backoff TCP])
92                 AS_IF([grep rto_max $LINUX/include/linux/tcp.h | grep -q __u16 >/dev/null],
93                         [AC_DEFINE(SOCKNAL_BACKOFF_MS, 1,
94                                 [tunable backoff TCP in ms])])
95         ], [
96                 AC_MSG_RESULT([no])
97         ])
98 ])
99 ]) # LN_CONFIG_BACKOFF
100
101 #
102 # LN_CONFIG_DLC
103 #
104 # Configure dlc if enabled
105 #
106 # if libyaml is set (IE libyaml installed) and enable_dlc = yes then build
107 # dlc other wise (IE if libyaml is not set or enable_dlc = no) then don't
108 # build dlc.
109 #
110 AC_DEFUN([LN_CONFIG_DLC], [
111         AC_CHECK_LIB([yaml],  [yaml_parser_initialize],[
112                 LIBYAML="libyaml"],[
113                 LIBYAML=""],[-lm])
114         AC_MSG_CHECKING([whether to enable dlc])
115         AC_ARG_ENABLE([dlc],
116                 AC_HELP_STRING([--disable-dlc],
117                         [disable building dlc]),
118                         [], [enable_dlc="yes"])
119         USE_DLC=""
120         AS_IF([test "x$enable_dlc" = xyes],
121                 [AS_IF([test "x$LIBYAML" = xlibyaml], [
122                         USE_DLC="yes"
123                         AC_MSG_RESULT([yes])
124                 ], [
125                         AC_MSG_RESULT([no (libyaml not present)])
126                 ])
127         ], [
128                 AC_MSG_RESULT([no])
129         ])
130         AC_SUBST(USE_DLC)
131 ])
132
133 #
134 # LN_CONFIG_O2IB
135 #
136 # If current OFED installed (assume with "ofed_info") and devel
137 # headers are not found, error because we assume OFED infiniband
138 # driver needs to be used and we must configure/build with it.
139 # Current OFED headers detection mechanism allow for non-standard
140 # prefix but relies on "ofed_info" command and on "%prefix/openib"
141 # link (both are ok for 1.5.x and 3.x versions), and should work
142 # for both source and DKMS builds.
143 #
144 AC_DEFUN([LN_CONFIG_O2IB], [
145 AC_MSG_CHECKING([whether to use Compat RDMA])
146 AC_ARG_WITH([o2ib],
147         AC_HELP_STRING([--with-o2ib=[yes|no|<path>]],
148                 [build o2iblnd against path]),
149         [], [with_o2ib="yes"])
150
151 case $with_o2ib in
152         yes)    AS_IF([which ofed_info 2>/dev/null], [
153                         AS_IF([test x$uses_dpkg = xyes], [
154                                 OFED_INFO="ofed_info | awk '{print \[$]2}'"
155                                 LSPKG="dpkg --listfiles"
156                         ], [
157                                 OFED_INFO="ofed_info"
158                                 LSPKG="rpm -ql"
159                         ])
160                         O2IBPATHS=$(eval $OFED_INFO | egrep -w 'mlnx-ofed-kernel-dkms|mlnx-ofa_kernel-devel|compat-rdma-devel|kernel-ib-devel|ofa_kernel-devel' | xargs $LSPKG | grep '\(/openib\|/ofa_kernel/default\)$' | head -n1)
161                         AS_IF([test -z "$O2IBPATHS"], [
162                                 AC_MSG_ERROR([
163 You seem to have an OFED installed but have not installed it's devel package.
164 If you still want to build Lustre for your OFED I/B stack, you need to install its devel headers RPM.
165 Instead, if you want to build Lustre for your kernel's built-in I/B stack rather than your installed OFED stack, either remove the OFED package(s) or use --with-o2ib=no.
166                                              ])
167                         ])
168                         AS_IF([test $(echo $O2IBPATHS | wc -w) -ge 2], [
169                                 AC_MSG_ERROR([
170 It appears that you have multiple OFED versions installed.
171 If you still want to build Lustre for your OFED I/B stack, you need to install a single version with its devel headers RPM.
172 Instead, if you want to build Lustre for your kernel's built-in I/B stack rather than your installed OFED stack, either remove the OFED package(s) or use --with-o2ib=no.
173                                              ])
174                         ])
175                         OFED="yes"
176                 ], [
177                         O2IBPATHS="$LINUX $LINUX/drivers/infiniband"
178                 ])
179                 ENABLEO2IB="yes"
180                 ;;
181         no)     ENABLEO2IB="no"
182                 ;;
183         *)      O2IBPATHS=$with_o2ib
184                 ENABLEO2IB="withpath"
185                 OFED="yes"
186                 ;;
187 esac
188
189 AS_IF([test $ENABLEO2IB = "no"], [
190         AC_MSG_RESULT([no])
191 ], [
192         o2ib_found=false
193         for O2IBPATH in $O2IBPATHS; do
194                 AS_IF([test \( -f ${O2IBPATH}/include/rdma/rdma_cm.h -a \
195                            -f ${O2IBPATH}/include/rdma/ib_cm.h -a \
196                            -f ${O2IBPATH}/include/rdma/ib_verbs.h -a \
197                            -f ${O2IBPATH}/include/rdma/ib_fmr_pool.h \)], [
198                         o2ib_found=true
199                         break
200                 ])
201         done
202         if ! $o2ib_found; then
203                 AC_MSG_RESULT([no])
204                 case $ENABLEO2IB in
205                         "yes") AC_MSG_ERROR([no OFED nor kernel OpenIB gen2 headers present]) ;;
206                         "withpath") AC_MSG_ERROR([bad --with-o2ib path]) ;;
207                         *) AC_MSG_ERROR([internal error]) ;;
208                 esac
209         else
210                 COMPAT_AUTOCONF=""
211                 compatrdma_found=false
212                 if test -f ${O2IBPATH}/include/linux/compat-2.6.h; then
213                         AC_MSG_RESULT([yes])
214                         compatrdma_found=true
215                         AC_DEFINE(HAVE_COMPAT_RDMA, 1, [compat rdma found])
216                         EXTRA_OFED_CONFIG="$EXTRA_OFED_CONFIG -include ${O2IBPATH}/include/linux/compat-2.6.h"
217                         if test -f "$O2IBPATH/include/linux/compat_autoconf.h"; then
218                                 COMPAT_AUTOCONF="$O2IBPATH/include/linux/compat_autoconf.h"
219                         fi
220                 else
221                         AC_MSG_RESULT([no])
222                 fi
223                 if ! $compatrdma_found; then
224                         if test -f "$O2IBPATH/config.mk"; then
225                                 . "$O2IBPATH/config.mk"
226                         elif test -f "$O2IBPATH/ofed_patch.mk"; then
227                                 . "$O2IBPATH/ofed_patch.mk"
228                         fi
229                 elif test -z "$COMPAT_AUTOCONF"; then
230                         # Depreciated checks
231                         if test "x$RHEL_KERNEL" = xyes; then
232                                 RHEL_MAJOR=$(awk '/ RHEL_MAJOR / { print [$]3 }' $LINUX_OBJ/include/$VERSION_HDIR/version.h)
233                                 I=$(awk '/ RHEL_MINOR / { print [$]3 }' $LINUX_OBJ/include/$VERSION_HDIR/version.h)
234                                 while test "$I" -ge 0; do
235                                         EXTRA_OFED_INCLUDE="$EXTRA_OFED_INCLUDE -DCONFIG_COMPAT_RHEL_${RHEL_MAJOR}_$I"
236                                         I=$(($I-1))
237                                 done
238                         elif test "x$SUSE_KERNEL" = xyes; then
239                                 SP=$(grep PATCHLEVEL /etc/SuSE-release | sed -e 's/.*= *//')
240                                 EXTRA_OFED_INCLUDE="$EXTRA_OFED_INCLUDE -DCONFIG_COMPAT_SLES_11_$SP"
241                         fi
242                 fi
243
244                 AC_MSG_CHECKING([whether to use any OFED backport headers])
245                 if test -n "$BACKPORT_INCLUDES"; then
246                         AC_MSG_RESULT([yes])
247                         OFED_BACKPORT_PATH="$O2IBPATH/${BACKPORT_INCLUDES/*\/kernel_addons/kernel_addons}/"
248                         EXTRA_OFED_INCLUDE="-I$OFED_BACKPORT_PATH $EXTRA_OFED_INCLUDE"
249                 else
250                         AC_MSG_RESULT([no])
251                 fi
252
253                 O2IBLND=""
254                 O2IBPATH=$(readlink --canonicalize $O2IBPATH)
255                 EXTRA_OFED_INCLUDE="$EXTRA_OFED_INCLUDE -I$O2IBPATH/include"
256                 EXTRA_CHECK_INCLUDE="$EXTRA_OFED_CONFIG $EXTRA_OFED_INCLUDE"
257                 LB_CHECK_COMPILE([whether to enable OpenIB gen2 support],
258                 openib_gen2_support, [
259                         #ifdef HAVE_COMPAT_RDMA
260                         #undef PACKAGE_NAME
261                         #undef PACKAGE_TARNAME
262                         #undef PACKAGE_VERSION
263                         #undef PACKAGE_STRING
264                         #undef PACKAGE_BUGREPORT
265                         #undef PACKAGE_URL
266                         #include <linux/compat-2.6.h>
267                         #endif
268                         #include <linux/version.h>
269                         #include <linux/pci.h>
270                         #include <linux/gfp.h>
271                         #include <rdma/rdma_cm.h>
272                         #include <rdma/ib_cm.h>
273                         #include <rdma/ib_verbs.h>
274                         #include <rdma/ib_fmr_pool.h>
275                 ],[
276                         struct rdma_cm_id      *cm_idi __attribute__ ((unused));
277                         struct rdma_conn_param  conn_param __attribute__ ((unused));
278                         struct ib_device_attr   device_attr __attribute__ ((unused));
279                         struct ib_qp_attr       qp_attr __attribute__ ((unused));
280                         struct ib_pool_fmr      pool_fmr __attribute__ ((unused));
281                         enum   ib_cm_rej_reason rej_reason __attribute__ ((unused));
282                         rdma_destroy_id(NULL);
283                 ],[
284                         O2IBLND="o2iblnd"
285                 ],[
286                         case $ENABLEO2IB in
287                         "yes") AC_MSG_ERROR([can't compile with OpenIB gen2 headers]) ;;
288                         "withpath") AC_MSG_ERROR([can't compile with OpenIB gen2 headers under $O2IBPATH]) ;;
289                         *) AC_MSG_ERROR([internal error]) ;;
290                         esac
291                 ])
292                 # we know at this point that the found OFED source is good
293                 O2IB_SYMVER=""
294                 if test $ENABLEO2IB = "withpath" -o "x$OFED" = "xyes" ; then
295                         # OFED default rpm not handle sles10 Modules.symvers name
296                         for name in Module.symvers Modules.symvers; do
297                                 if test -f $O2IBPATH/$name; then
298                                         O2IB_SYMVER=$name;
299                                         break;
300                                 fi
301                         done
302                         if test -n "$O2IB_SYMVER"; then
303                                 AC_MSG_NOTICE([adding $O2IBPATH/$O2IB_SYMVER to Symbol Path])
304                                 EXTRA_SYMBOLS="$EXTRA_SYMBOLS $O2IBPATH/$O2IB_SYMVER"
305                                 AC_SUBST(EXTRA_SYMBOLS)
306                         else
307                                 AC_MSG_ERROR([an external source tree was, either specified or detected, for o2iblnd however I could not find a $O2IBPATH/Module.symvers there])
308                         fi
309                 fi
310
311                 LB_CHECK_COMPILE([if Linux kernel has kthread_worker],
312                 linux_kthread_worker, [
313                         #ifdef HAVE_COMPAT_RDMA
314                         #undef PACKAGE_NAME
315                         #undef PACKAGE_TARNAME
316                         #undef PACKAGE_VERSION
317                         #undef PACKAGE_STRING
318                         #undef PACKAGE_BUGREPORT
319                         #undef PACKAGE_URL
320                         #include <linux/compat-2.6.h>
321                         #endif
322                         #include <linux/kthread.h>
323                 ],[
324                         struct kthread_work     *kth_wrk __attribute__ ((unused));
325                         flush_kthread_work(kth_wrk);
326                 ],[
327                         AC_DEFINE(HAVE_KTHREAD_WORK, 1, [kthread_worker found])
328                         if test -z "$COMPAT_AUTOCONF"; then
329                                 EXTRA_OFED_INCLUDE="$EXTRA_OFED_INCLUDE -DCONFIG_COMPAT_IS_KTHREAD"
330                         fi
331                 ])
332                 EXTRA_CHECK_INCLUDE=""
333         fi
334 ])
335 AC_SUBST(EXTRA_OFED_CONFIG)
336 AC_SUBST(EXTRA_OFED_INCLUDE)
337 AC_SUBST(O2IBLND)
338 AC_SUBST(O2IBPATH)
339 AC_SUBST(ENABLEO2IB)
340
341 AS_IF([test $ENABLEO2IB != "no"], [
342         EXTRA_CHECK_INCLUDE="$EXTRA_OFED_CONFIG $EXTRA_OFED_INCLUDE"
343         # In RHEL 6.2, rdma_create_id() takes the queue-pair type as a fourth argument
344         LB_CHECK_COMPILE([if 'rdma_create_id' wants four args],
345         rdma_create_id_4args, [
346                 #ifdef HAVE_COMPAT_RDMA
347                 #undef PACKAGE_NAME
348                 #undef PACKAGE_TARNAME
349                 #undef PACKAGE_VERSION
350                 #undef PACKAGE_STRING
351                 #undef PACKAGE_BUGREPORT
352                 #undef PACKAGE_URL
353                 #include <linux/compat-2.6.h>
354                 #endif
355                 #include <rdma/rdma_cm.h>
356         ],[
357                 rdma_create_id(NULL, NULL, 0, 0);
358         ],[
359                 AC_DEFINE(HAVE_RDMA_CREATE_ID_4ARG, 1,
360                         [rdma_create_id wants 4 args])
361         ])
362
363         # 4.4 added network namespace parameter for rdma_create_id()
364         LB_CHECK_COMPILE([if 'rdma_create_id' wants five args],
365         rdma_create_id_5args, [
366                 #ifdef HAVE_COMPAT_RDMA
367                 #undef PACKAGE_NAME
368                 #undef PACKAGE_TARNAME
369                 #undef PACKAGE_VERSION
370                 #undef PACKAGE_STRING
371                 #undef PACKAGE_BUGREPORT
372                 #undef PACKAGE_URL
373                 #include <linux/compat-2.6.h>
374                 #endif
375                 #include <rdma/rdma_cm.h>
376         ],[
377                 rdma_create_id(NULL, NULL, NULL, 0, 0);
378         ],[
379                 AC_DEFINE(HAVE_RDMA_CREATE_ID_5ARG, 1,
380                         [rdma_create_id wants 5 args])
381         ])
382
383         # 4.2 introduced struct ib_cq_init_attr which is used
384         # by ib_create_cq(). Note some OFED stacks only keep
385         # their headers in sync with latest kernels but not
386         # the functionality which means for infiniband testing
387         # we need to always test functionality testings.
388         LB_CHECK_COMPILE([if 'struct ib_cq_init_attr' is used],
389         ib_cq_init_attr, [
390                 #ifdef HAVE_COMPAT_RDMA
391                 #undef PACKAGE_NAME
392                 #undef PACKAGE_TARNAME
393                 #undef PACKAGE_VERSION
394                 #undef PACKAGE_STRING
395                 #undef PACKAGE_BUGREPORT
396                 #undef PACKAGE_URL
397                 #include <linux/compat-2.6.h>
398                 #endif
399                 #include <rdma/ib_verbs.h>
400         ],[
401                 struct ib_cq_init_attr cq_attr;
402
403                 ib_create_cq(NULL, NULL, NULL, NULL, &cq_attr);
404         ],[
405                 AC_DEFINE(HAVE_IB_CQ_INIT_ATTR, 1,
406                         [struct ib_cq_init_attr is used by ib_create_cq])
407         ])
408
409         # 4.3 removed ib_alloc_fast_reg_mr()
410         LB_CHECK_COMPILE([if 'ib_alloc_fast_reg_mr' exists],
411         ib_alloc_fast_reg_mr, [
412                 #ifdef HAVE_COMPAT_RDMA
413                 #undef PACKAGE_NAME
414                 #undef PACKAGE_TARNAME
415                 #undef PACKAGE_VERSION
416                 #undef PACKAGE_STRING
417                 #undef PACKAGE_BUGREPORT
418                 #undef PACKAGE_URL
419                 #include <linux/compat-2.6.h>
420                 #endif
421                 #include <rdma/ib_verbs.h>
422         ],[
423                 ib_alloc_fast_reg_mr(NULL, 0);
424         ],[
425                 AC_DEFINE(HAVE_IB_ALLOC_FAST_REG_MR, 1,
426                         [ib_alloc_fast_reg_mr is defined])
427         ])
428
429         # In v4.4 Linux kernel,
430         # commit e622f2f4ad2142d2a613a57fb85f8cf737935ef5
431         # split up struct ib_send_wr so that all non-trivial verbs
432         # use their own structure which embedds struct ib_send_wr.
433         LB_CHECK_COMPILE([if 'struct ib_rdma_wr' is defined],
434         ib_rdma_wr, [
435                 #ifdef HAVE_COMPAT_RDMA
436                 #undef PACKAGE_NAME
437                 #undef PACKAGE_TARNAME
438                 #undef PACKAGE_VERSION
439                 #undef PACKAGE_STRING
440                 #undef PACKAGE_BUGREPORT
441                 #undef PACKAGE_URL
442                 #include <linux/compat-2.6.h>
443                 #endif
444                 #include <rdma/ib_verbs.h>
445         ],[
446                 struct ib_rdma_wr *wr __attribute__ ((unused));
447
448                 wr = rdma_wr(NULL);
449         ],[
450                 AC_DEFINE(HAVE_IB_RDMA_WR, 1,
451                         [struct ib_rdma_wr is defined])
452         ])
453
454         # new fast registration API introduced in 4.4
455         LB_CHECK_COMPILE([if 'ib_map_mr_sg' exists],
456         ib_map_mr_sg, [
457                 #ifdef HAVE_COMPAT_RDMA
458                 #undef PACKAGE_NAME
459                 #undef PACKAGE_TARNAME
460                 #undef PACKAGE_VERSION
461                 #undef PACKAGE_STRING
462                 #undef PACKAGE_BUGREPORT
463                 #undef PACKAGE_URL
464                 #include <linux/compat-2.6.h>
465                 #endif
466                 #include <rdma/ib_verbs.h>
467         ],[
468                 ib_map_mr_sg(NULL, NULL, 0, 0);
469         ],[
470                 AC_DEFINE(HAVE_IB_MAP_MR_SG, 1,
471                         [ib_map_mr_sg exists])
472         ])
473
474         # ib_query_device() removed in 4.5
475         LB_CHECK_COMPILE([if 'struct ib_device' has member 'attrs'],
476         ib_device.attrs, [
477                 #ifdef HAVE_COMPAT_RDMA
478                 #undef PACKAGE_NAME
479                 #undef PACKAGE_TARNAME
480                 #undef PACKAGE_VERSION
481                 #undef PACKAGE_STRING
482                 #undef PACKAGE_BUGREPORT
483                 #undef PACKAGE_URL
484                 #include <linux/compat-2.6.h>
485                 #endif
486                 #include <rdma/ib_verbs.h>
487         ],[
488                 struct ib_device dev;
489                 struct ib_device_attr dev_attr = {};
490                 dev.attrs = dev_attr;
491         ],[
492                 AC_DEFINE(HAVE_IB_DEVICE_ATTRS, 1,
493                         [struct ib_device.attrs is defined])
494         ])
495         EXTRA_CHECK_INCLUDE=""
496 ]) # ENABLEO2IB != "no"
497 ]) # LN_CONFIG_O2IB
498
499 #
500 # LN_CONFIG_GNILND
501 #
502 # check whether to use the Gemini Network Interface lnd
503 #
504 AC_DEFUN([LN_CONFIG_GNILND], [
505 AC_MSG_CHECKING([whether to enable GNI lnd])
506 AC_ARG_ENABLE([gni],
507         AC_HELP_STRING([--enable-gni],
508                 [enable GNI lnd]),
509         [], [enable_gni="no"])
510 AC_MSG_RESULT([$enable_gni])
511
512 AS_IF([test "x$enable_gni" = xyes], [
513         # GNICPPFLAGS was set in spec file
514         EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
515         EXTRA_KCFLAGS="$EXTRA_KCFLAGS $GNICPPFLAGS"
516         LB_CHECK_COMPILE([if GNI kernel headers are present],
517         GNI_header, [
518                 #include <linux/types.h>
519                 #include <gni_pub.h>
520         ],[
521                 gni_cdm_handle_t kgni_domain;
522                 gni_return_t     rc;
523                 int              rrc;
524                 rc = gni_cdm_create(0, 1, 1, 0, &kgni_domain);
525                 rrc = (rc == GNI_RC_SUCCESS) ? 0 : 1;
526                 return rrc;
527         ],[
528                 GNILND="gnilnd"
529         ],[
530                 AC_MSG_ERROR([can't compile gnilnd with given GNICPPFLAGS: $GNICPPFLAGS])
531         ])
532         # at this point, we have gnilnd basic support,
533         # now check for extra features
534         LB_CHECK_COMPILE([to use RCA in gnilnd],
535         RCA_gnilnd, [
536                 #include <linux/types.h>
537                 #include <gni_pub.h>
538                 #include <krca_lib.h>
539         ],[
540                 gni_cdm_handle_t kgni_domain;
541                 gni_return_t     rc;
542                 krca_ticket_t    ticket = KRCA_NULL_TICKET;
543                 int              rrc;
544                 __u32            nid = 0, nic_addr;
545                 rc = gni_cdm_create(0, 1, 1, 0, &kgni_domain);
546                 rrc = (rc == GNI_RC_SUCCESS) ? 0 : 1;
547                 rrc += krca_nid_to_nicaddrs(nid, 1, &nic_addr);
548                 rrc += krca_register(&ticket, RCA_MAKE_SERVICE_INDEX(RCA_IO_CLASS, 9), 99, 0);
549                 return rrc;
550         ],[
551                 GNICPPFLAGS="$GNICPPFLAGS -DGNILND_USE_RCA=1"
552         ])
553         EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
554 ])
555 AC_SUBST(GNICPPFLAGS)
556 AC_SUBST(GNILND)
557 ]) # LN_CONFIG_GNILND
558
559 #
560 # LN_CONFIG_SK_SLEEP
561 #
562 # 2.6.35 kernel has sk_sleep function
563 #
564 AC_DEFUN([LN_CONFIG_SK_SLEEP], [
565 LB_CHECK_COMPILE([if Linux kernel has 'sk_sleep'],
566 sk_sleep, [
567         #ifdef HAVE_COMPAT_RDMA
568         #undef PACKAGE_NAME
569         #undef PACKAGE_TARNAME
570         #undef PACKAGE_VERSION
571         #undef PACKAGE_STRING
572         #undef PACKAGE_BUGREPORT
573         #undef PACKAGE_URL
574         #include <linux/compat-2.6.h>
575         #endif
576         #include <net/sock.h>
577 ],[
578         sk_sleep(NULL);
579 ],[
580         AC_DEFINE(HAVE_SK_SLEEP, 1,
581                   [kernel has sk_sleep])
582 ])
583 ]) # LN_CONFIG_SK_SLEEP
584
585 #
586 # LN_CONFIG_TCP_SENDPAGE
587 #
588 # 2.6.36 tcp_sendpage() first parameter is 'struct sock' instead of 'struct socket'.
589 #
590 AC_DEFUN([LN_CONFIG_TCP_SENDPAGE], [
591 tmp_flags="$EXTRA_KCFLAGS"
592 EXTRA_KCFLAGS="-Werror"
593 LB_CHECK_COMPILE([if 'tcp_sendpage' first parameter is socket],
594 tcp_sendpage_socket, [
595         #ifdef HAVE_COMPAT_RDMA
596         #undef PACKAGE_NAME
597         #undef PACKAGE_TARNAME
598         #undef PACKAGE_VERSION
599         #undef PACKAGE_STRING
600         #undef PACKAGE_BUGREPORT
601         #undef PACKAGE_URL
602         #include <linux/compat-2.6.h>
603         #endif
604         #include <linux/net.h>
605         #include <net/tcp.h>
606 ],[
607         tcp_sendpage((struct socket*)0, NULL, 0, 0, 0);
608 ],[
609         AC_DEFINE(HAVE_TCP_SENDPAGE_USE_SOCKET, 1,
610                 [tcp_sendpage use socket as first parameter])
611 ])
612 EXTRA_KCFLAGS="$tmp_flags"
613 ]) # LN_CONFIG_TCP_SENDPAGE
614
615 #
616 # LN_CONFIG_SK_DATA_READY
617 #
618 # 3.15 for struct sock the *sk_data_ready() field only takes one argument now
619 #
620 AC_DEFUN([LN_CONFIG_SK_DATA_READY], [
621 tmp_flags="$EXTRA_KCFLAGS"
622 EXTRA_KCFLAGS="-Werror"
623 LB_CHECK_COMPILE([if 'sk_data_ready' takes only one argument],
624 sk_data_ready, [
625         #ifdef HAVE_COMPAT_RDMA
626         #undef PACKAGE_NAME
627         #undef PACKAGE_TARNAME
628         #undef PACKAGE_VERSION
629         #undef PACKAGE_STRING
630         #undef PACKAGE_BUGREPORT
631         #undef PACKAGE_URL
632         #include <linux/compat-2.6.h>
633         #endif
634         #include <linux/net.h>
635         #include <net/sock.h>
636 ],[
637         ((struct sock *)0)->sk_data_ready(NULL);
638 ],[
639         AC_DEFINE(HAVE_SK_DATA_READY_ONE_ARG, 1,
640                 [sk_data_ready uses only one argument])
641 ])
642 EXTRA_KCFLAGS="$tmp_flags"
643 ]) # LN_CONFIG_SK_DATA_READY
644
645 #
646 # LN_CONFIG_IB_INC_RKEY
647 #
648 AC_DEFUN([LN_CONFIG_IB_INC_RKEY], [
649 tmp_flags="$EXTRA_KCFLAGS"
650 EXTRA_KCFLAGS="-Werror"
651 LB_CHECK_COMPILE([if function 'ib_inc_rkey' is defined],
652 ib_inc_rkey, [
653         #ifdef HAVE_COMPAT_RDMA
654         #undef PACKAGE_NAME
655         #undef PACKAGE_TARNAME
656         #undef PACKAGE_VERSION
657         #undef PACKAGE_STRING
658         #undef PACKAGE_BUGREPORT
659         #undef PACKAGE_URL
660         #include <linux/compat-2.6.h>
661         #endif
662         #include <rdma/ib_verbs.h>
663 ],[
664         (void)ib_inc_rkey(0);
665 ],[
666         AC_DEFINE(HAVE_IB_INC_RKEY, 1,
667                   [function ib_inc_rkey exist])
668 ])
669 EXTRA_KCFLAGS="$tmp_flags"
670 ]) # LN_CONFIG_IB_INC_RKEY
671
672 #
673 # LN_PROG_LINUX
674 #
675 # LNet linux kernel checks
676 #
677 AC_DEFUN([LN_PROG_LINUX], [
678 AC_MSG_NOTICE([LNet kernel checks
679 ==============================================================================])
680
681 LN_CONFIG_AFFINITY
682 LN_CONFIG_BACKOFF
683 LN_CONFIG_O2IB
684 LN_CONFIG_GNILND
685 # OFED checks, so add extra OFED include
686 EXTRA_CHECK_INCLUDE="$EXTRA_OFED_CONFIG $EXTRA_OFED_INCLUDE"
687 # 2.6.35
688 LN_CONFIG_SK_SLEEP
689 # 2.6.36
690 LN_CONFIG_TCP_SENDPAGE
691 # 3.8.1
692 LN_CONFIG_IB_INC_RKEY
693 # 3.15
694 LN_CONFIG_SK_DATA_READY
695 # remove extra include for none OFED code
696 EXTRA_CHECK_INCLUDE=""
697 ]) # LN_PROG_LINUX
698
699 #
700 # LN_PATH_DEFAULTS
701 #
702 # default paths for installed files
703 #
704 AC_DEFUN([LN_PATH_DEFAULTS], [
705 ]) # LN_PATH_DEFAULTS
706
707 #
708 # LN_CONFIGURE
709 #
710 # other configure checks
711 #
712 AC_DEFUN([LN_CONFIGURE], [
713 AC_MSG_NOTICE([LNet core checks
714 ==============================================================================])
715
716 # lnet/utils/portals.c
717 AC_CHECK_HEADERS([netdb.h])
718 AC_CHECK_FUNCS([gethostbyname])
719
720 # lnet/utils/wirecheck.c
721 AC_CHECK_FUNCS([strnlen])
722
723 # --------  Check for required packages  --------------
724
725 AC_MSG_CHECKING([whether to enable 'efence' debugging support])
726 AC_ARG_ENABLE(efence,
727         AC_HELP_STRING([--enable-efence],
728                 [use efence library]),
729         [], [enable_efence="no"])
730 AC_MSG_RESULT([$enable_efence])
731
732 LIBEFENCE=""
733 AS_IF([test "$enable_efence" = yes], [
734         LIBEFENCE="-lefence"
735         AC_DEFINE(HAVE_LIBEFENCE, 1,
736                 [libefence support is requested])
737 ])
738 AC_SUBST(LIBEFENCE)
739
740 LN_CONFIG_MAX_PAYLOAD
741 LN_CONFIG_DLC
742 ]) # LN_CONFIGURE
743
744 #
745 # LN_CONDITIONALS
746 #
747 # AM_CONDITIONAL defines for lnet
748 #
749 AC_DEFUN([LN_CONDITIONALS], [
750 AM_CONDITIONAL(BUILD_O2IBLND,    test x$O2IBLND = "xo2iblnd")
751 AM_CONDITIONAL(BUILD_GNILND,     test x$GNILND  = "xgnilnd")
752 AM_CONDITIONAL(BUILD_DLC,        test x$USE_DLC = "xyes")
753 ]) # LN_CONDITIONALS
754
755 #
756 # LN_CONFIG_FILES
757 #
758 # files that should be generated with AC_OUTPUT
759 #
760 AC_DEFUN([LN_CONFIG_FILES], [
761 AC_CONFIG_FILES([
762 lnet/Makefile
763 lnet/autoMakefile
764 lnet/autoconf/Makefile
765 lnet/doc/Makefile
766 lnet/include/Makefile
767 lnet/include/lnet/Makefile
768 lnet/klnds/Makefile
769 lnet/klnds/autoMakefile
770 lnet/klnds/o2iblnd/Makefile
771 lnet/klnds/o2iblnd/autoMakefile
772 lnet/klnds/gnilnd/Makefile
773 lnet/klnds/gnilnd/autoMakefile
774 lnet/klnds/socklnd/Makefile
775 lnet/klnds/socklnd/autoMakefile
776 lnet/lnet/Makefile
777 lnet/lnet/autoMakefile
778 lnet/selftest/Makefile
779 lnet/selftest/autoMakefile
780 lnet/utils/Makefile
781 lnet/utils/lnetconfig/Makefile
782 ])
783 ]) # LN_CONFIG_FILES