Whamcloud - gitweb
LU-15888 build: Debian dkms-debs requires ed and libkeyutils
[fs/lustre-release.git] / lnet / autoconf / lustre-lnet.m4
1 # LN_CONFIG_BACKOFF
2 #
3 # check if tunable tcp backoff is available/wanted
4 #
5 AC_DEFUN([LN_CONFIG_BACKOFF], [
6 AC_MSG_CHECKING([whether to enable tunable backoff TCP support])
7 AC_ARG_ENABLE([backoff],
8         AS_HELP_STRING([--disable-backoff],
9                 [disable socknal tunable backoff]),
10         [], [enable_backoff="yes"])
11 AC_MSG_RESULT([$enable_backoff])
12 AS_IF([test "x$enable_backoff" = xyes], [
13         AC_MSG_CHECKING([if Linux kernel has tunable backoff TCP support])
14         AS_IF([grep -c TCP_BACKOFF $LINUX/include/linux/tcp.h >/dev/null], [
15                 AC_MSG_RESULT([yes])
16                 AC_DEFINE(SOCKNAL_BACKOFF, 1, [use tunable backoff TCP])
17                 AS_IF([grep rto_max $LINUX/include/linux/tcp.h | grep -q __u16 >/dev/null],
18                         [AC_DEFINE(SOCKNAL_BACKOFF_MS, 1,
19                                 [tunable backoff TCP in ms])])
20         ], [
21                 AC_MSG_RESULT([no])
22         ])
23 ])
24 ]) # LN_CONFIG_BACKOFF
25
26 #
27 # LN_CONFIG_DLC
28 #
29 # Configure dlc
30 #
31 # fail to build if libyaml is not installed
32 #
33 AC_DEFUN([LN_CONFIG_DLC], [
34         AS_IF([test "x$enable_dist" = xno], [
35                 AC_CHECK_LIB([yaml], [yaml_parser_initialize],
36                              [LIBYAML="libyaml"],
37                              [AC_MSG_ERROR([YAML development libraries not not installed])],
38                              [-lm])
39         ])
40 ])
41
42 #
43 # LN_CONFIG_O2IB
44 #
45 # If current OFED installed (assume with "ofed_info") and devel
46 # headers are not found, error because we assume OFED infiniband
47 # driver needs to be used and we must configure/build with it.
48 # Current OFED headers detection mechanism allow for non-standard
49 # prefix but relies on "ofed_info" command and on "%prefix/openib"
50 # link (both are ok for 1.5.x and 3.x versions), and should work
51 # for both source and DKMS builds.
52 #
53 AC_DEFUN([LN_CONFIG_O2IB], [
54 AC_MSG_CHECKING([whether to use Compat RDMA])
55 AC_ARG_WITH([o2ib],
56         AS_HELP_STRING([--with-o2ib=[yes|no|<path>]],
57                 [build o2iblnd against path]),
58         [], [with_o2ib="yes"])
59
60 case $with_o2ib in
61         yes)    AS_IF([which ofed_info 2>/dev/null], [
62                         AS_IF([test x$uses_dpkg = xyes], [
63                                 OFED_INFO="ofed_info | awk '{print \[$]2}'"
64                                 LSPKG="dpkg --listfiles"
65                         ], [
66                                 OFED_INFO="ofed_info"
67                                 LSPKG="rpm -ql"
68                         ])
69                         O2IBPATHS=$(eval $OFED_INFO |
70                                     egrep -w 'mlnx-ofed-kernel-dkms|mlnx-ofa_kernel-devel|compat-rdma-devel|kernel-ib-devel|ofa_kernel-devel' |
71                                     xargs $LSPKG | grep -v 'ofa_kernel-' | grep rdma_cm.h | sed 's/\/include\/rdma\/rdma_cm.h//')
72                         AS_IF([test -z "$O2IBPATHS"], [
73                                 AC_MSG_ERROR([
74 You seem to have an OFED installed but have not installed it's devel package.
75 If you still want to build Lustre for your OFED I/B stack, you need to install its devel headers RPM.
76 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.
77                                              ])
78                         ])
79                         AS_IF([test $(echo $O2IBPATHS | wc -w) -ge 2], [
80                                 AC_MSG_ERROR([
81 It appears that you have multiple OFED versions installed.
82 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.
83 Instead, if you want to build Lustre for your in-kernel I/B stack rather than your installed external OFED stack, either remove the OFED package(s) or use --with-o2ib=no.
84                                              ])
85                         ])
86                         if test -e $O2IBPATHS/${LINUXRELEASE}; then
87                             O2IBPATHS=$O2IBPATHS/${LINUXRELEASE}
88                         elif test -e $O2IBPATHS/default; then
89                             O2IBPATHS=$O2IBPATHS/default
90                         fi
91                         OFED="yes"
92                 ], [
93                         O2IBPATHS="$LINUX $LINUX/drivers/infiniband"
94                 ])
95                 ENABLEO2IB="yes"
96                 ;;
97         no)     ENABLEO2IB="no"
98                 ;;
99         *)      O2IBPATHS=$with_o2ib
100                 ENABLEO2IB="withpath"
101                 OFED="yes"
102                 ;;
103 esac
104
105 AS_IF([test $ENABLEO2IB = "no"], [
106         AC_MSG_RESULT([no])
107         AC_DEFUN([LN_CONFIG_O2IB_SRC], [])
108         AC_DEFUN([LN_CONFIG_O2IB_RESULTS], [])
109 ], [
110         o2ib_found=false
111         for O2IBPATH in $O2IBPATHS; do
112                 AS_IF([test \( -f ${O2IBPATH}/include/rdma/rdma_cm.h -a \
113                            -f ${O2IBPATH}/include/rdma/ib_cm.h -a \
114                            -f ${O2IBPATH}/include/rdma/ib_verbs.h \)], [
115                         o2ib_found=true
116                         break
117                 ])
118         done
119         if ! $o2ib_found; then
120                 AC_MSG_RESULT([no])
121                 case $ENABLEO2IB in
122                         "yes") AC_MSG_ERROR([no OFED nor kernel OpenIB gen2 headers present]) ;;
123                         "withpath") AC_MSG_ERROR([bad --with-o2ib path]) ;;
124                         *) AC_MSG_ERROR([internal error]) ;;
125                 esac
126         else
127                 COMPAT_AUTOCONF=""
128                 compatrdma_found=false
129                 if test -f ${O2IBPATH}/include/linux/compat-2.6.h; then
130                         AC_MSG_RESULT([yes])
131                         compatrdma_found=true
132                         AC_DEFINE(HAVE_COMPAT_RDMA, 1, [compat rdma found])
133                         EXTRA_OFED_CONFIG="$EXTRA_OFED_CONFIG -include ${O2IBPATH}/include/linux/compat-2.6.h"
134                         if test -f "$O2IBPATH/include/linux/compat_autoconf.h"; then
135                                 COMPAT_AUTOCONF="$O2IBPATH/include/linux/compat_autoconf.h"
136                         fi
137                 else
138                         AC_MSG_RESULT([no])
139                 fi
140                 if ! $compatrdma_found; then
141                         if test -f "$O2IBPATH/config.mk"; then
142                                 . "$O2IBPATH/config.mk"
143                         elif test -f "$O2IBPATH/ofed_patch.mk"; then
144                                 . "$O2IBPATH/ofed_patch.mk"
145                         fi
146                 elif test -z "$COMPAT_AUTOCONF"; then
147                         # Depreciated checks
148                         if test "x$RHEL_KERNEL" = xyes; then
149                                 RHEL_MAJOR=$(awk '/ RHEL_MAJOR / { print [$]3 }' $LINUX_OBJ/include/$VERSION_HDIR/version.h)
150                                 I=$(awk '/ RHEL_MINOR / { print [$]3 }' $LINUX_OBJ/include/$VERSION_HDIR/version.h)
151                                 while test "$I" -ge 0; do
152                                         EXTRA_OFED_INCLUDE="$EXTRA_OFED_INCLUDE -DCONFIG_COMPAT_RHEL_${RHEL_MAJOR}_$I"
153                                         I=$(($I-1))
154                                 done
155                         elif test "x$SUSE_KERNEL" = xyes; then
156                                 SP=$(grep PATCHLEVEL /etc/SuSE-release | sed -e 's/.*= *//')
157                                 EXTRA_OFED_INCLUDE="$EXTRA_OFED_INCLUDE -DCONFIG_COMPAT_SLES_11_$SP"
158                         fi
159                 fi
160
161                 AC_MSG_CHECKING([whether to use any OFED backport headers])
162                 if test -n "$BACKPORT_INCLUDES"; then
163                         AC_MSG_RESULT([yes])
164                         OFED_BACKPORT_PATH="$O2IBPATH/${BACKPORT_INCLUDES/*\/kernel_addons/kernel_addons}/"
165                         EXTRA_OFED_INCLUDE="-I$OFED_BACKPORT_PATH $EXTRA_OFED_INCLUDE"
166                 else
167                         AC_MSG_RESULT([no])
168                 fi
169
170                 O2IBLND=""
171                 O2IBPATH=$(readlink --canonicalize $O2IBPATH)
172                 EXTRA_OFED_INCLUDE="$EXTRA_OFED_INCLUDE -I$O2IBPATH/include -I$O2IBPATH/include/uapi"
173                 EXTRA_CHECK_INCLUDE="$EXTRA_OFED_CONFIG $EXTRA_OFED_INCLUDE"
174                 LB_CHECK_COMPILE([whether to enable OpenIB gen2 support],
175                 openib_gen2_support, [
176                         #ifdef HAVE_COMPAT_RDMA
177                         #undef PACKAGE_NAME
178                         #undef PACKAGE_TARNAME
179                         #undef PACKAGE_VERSION
180                         #undef PACKAGE_STRING
181                         #undef PACKAGE_BUGREPORT
182                         #undef PACKAGE_URL
183                         #include <linux/compat-2.6.h>
184                         #endif
185                         #include <linux/version.h>
186                         #include <linux/pci.h>
187                         #include <linux/gfp.h>
188                         #include <rdma/rdma_cm.h>
189                         #include <rdma/ib_cm.h>
190                         #include <rdma/ib_verbs.h>
191                 ],[
192                         struct rdma_cm_id      *cm_idi __attribute__ ((unused));
193                         struct rdma_conn_param  conn_param __attribute__ ((unused));
194                         struct ib_device_attr   device_attr __attribute__ ((unused));
195                         struct ib_qp_attr       qp_attr __attribute__ ((unused));
196                         enum   ib_cm_rej_reason rej_reason __attribute__ ((unused));
197                         rdma_destroy_id(NULL);
198                 ],[
199                         O2IBLND="o2iblnd"
200                 ],[
201                         case $ENABLEO2IB in
202                         "yes") AC_MSG_ERROR([can't compile with OpenIB gen2 headers]) ;;
203                         "withpath") AC_MSG_ERROR([can't compile with OpenIB gen2 headers under $O2IBPATH]) ;;
204                         *) AC_MSG_ERROR([internal error]) ;;
205                         esac
206                 ])
207                 # we know at this point that the found OFED source is good
208                 O2IB_SYMVER=""
209                 if test -f $O2IBPATH/Module.symvers; then
210                         O2IB_SYMVER=$O2IBPATH/Module.symvers
211                 elif test "x$SUSE_KERNEL" = "xyes"; then
212                         O2IB_SYMVER=$(find ${O2IBPATH}* -name Module.symvers)
213                 elif test -f $LINUX_OBJ/Module.symvers; then
214                         # Debian symvers is in the arch tree
215                         O2IB_SYMVER=$LINUX_OBJ/Module.symvers
216                 fi
217                 if test -n "$O2IB_SYMVER"; then
218                         AC_MSG_NOTICE([adding $O2IB_SYMVER to Symbol Path])
219                         EXTRA_SYMBOLS="$EXTRA_SYMBOLS $O2IB_SYMVER"
220                         AC_SUBST(EXTRA_SYMBOLS)
221                 else
222                         AC_MSG_ERROR([an external source tree was, either specified or detected, for o2iblnd however I could not find a $O2IBPATH/Module.symvers there])
223                 fi
224
225                 LB_CHECK_COMPILE([if Linux kernel has kthread_worker],
226                 linux_kthread_worker, [
227                         #ifdef HAVE_COMPAT_RDMA
228                         #undef PACKAGE_NAME
229                         #undef PACKAGE_TARNAME
230                         #undef PACKAGE_VERSION
231                         #undef PACKAGE_STRING
232                         #undef PACKAGE_BUGREPORT
233                         #undef PACKAGE_URL
234                         #include <linux/compat-2.6.h>
235                         #endif
236                         #include <linux/kthread.h>
237                 ],[
238                         struct kthread_work *kth_wrk = NULL;
239                         flush_kthread_work(kth_wrk);
240                 ],[
241                         AC_DEFINE(HAVE_KTHREAD_WORK, 1, [kthread_worker found])
242                         if test -z "$COMPAT_AUTOCONF"; then
243                                 EXTRA_OFED_INCLUDE="$EXTRA_OFED_INCLUDE -DCONFIG_COMPAT_IS_KTHREAD"
244                         fi
245                 ])
246                 EXTRA_CHECK_INCLUDE=""
247         fi
248 ])
249 AC_SUBST(EXTRA_OFED_CONFIG)
250 AC_SUBST(EXTRA_OFED_INCLUDE)
251 AC_SUBST(O2IBLND)
252 AC_SUBST(O2IBPATH)
253 AC_SUBST(ENABLEO2IB)
254
255 AS_IF([test $ENABLEO2IB != "no"], [
256         EXTRA_CHECK_INCLUDE="$EXTRA_OFED_CONFIG $EXTRA_OFED_INCLUDE"
257         KBUILD_EXTRA_SYMBOLS="$KBUILD_EXTRA_SYMBOLS $O2IBPATH/Module.symvers"
258
259         # In RHEL 6.2, rdma_create_id() takes the queue-pair type as a fourth argument
260         LB_CHECK_COMPILE([if 'rdma_create_id' wants four args],
261         rdma_create_id_4args, [
262                 #ifdef HAVE_COMPAT_RDMA
263                 #undef PACKAGE_NAME
264                 #undef PACKAGE_TARNAME
265                 #undef PACKAGE_VERSION
266                 #undef PACKAGE_STRING
267                 #undef PACKAGE_BUGREPORT
268                 #undef PACKAGE_URL
269                 #include <linux/compat-2.6.h>
270                 #endif
271                 #include <rdma/rdma_cm.h>
272         ],[
273                 rdma_create_id(NULL, NULL, 0, 0);
274         ],[
275                 AC_DEFINE(HAVE_RDMA_CREATE_ID_4ARG, 1,
276                         [rdma_create_id wants 4 args])
277         ])
278
279         # 4.4 added network namespace parameter for rdma_create_id()
280         LB_CHECK_COMPILE([if 'rdma_create_id' wants five args],
281         rdma_create_id_5args, [
282                 #ifdef HAVE_COMPAT_RDMA
283                 #undef PACKAGE_NAME
284                 #undef PACKAGE_TARNAME
285                 #undef PACKAGE_VERSION
286                 #undef PACKAGE_STRING
287                 #undef PACKAGE_BUGREPORT
288                 #undef PACKAGE_URL
289                 #include <linux/compat-2.6.h>
290                 #endif
291                 #include <rdma/rdma_cm.h>
292         ],[
293                 rdma_create_id(NULL, NULL, NULL, 0, 0);
294         ],[
295                 AC_DEFINE(HAVE_RDMA_CREATE_ID_5ARG, 1,
296                         [rdma_create_id wants 5 args])
297         ])
298
299         # 4.2 introduced struct ib_cq_init_attr which is used
300         # by ib_create_cq(). Note some OFED stacks only keep
301         # their headers in sync with latest kernels but not
302         # the functionality which means for infiniband testing
303         # we need to always test functionality testings.
304         LB_CHECK_COMPILE([if 'struct ib_cq_init_attr' is used],
305         ib_cq_init_attr, [
306                 #ifdef HAVE_COMPAT_RDMA
307                 #undef PACKAGE_NAME
308                 #undef PACKAGE_TARNAME
309                 #undef PACKAGE_VERSION
310                 #undef PACKAGE_STRING
311                 #undef PACKAGE_BUGREPORT
312                 #undef PACKAGE_URL
313                 #include <linux/compat-2.6.h>
314                 #endif
315                 #include <rdma/ib_verbs.h>
316         ],[
317                 struct ib_cq_init_attr cq_attr;
318
319                 ib_create_cq(NULL, NULL, NULL, NULL, &cq_attr);
320         ],[
321                 AC_DEFINE(HAVE_IB_CQ_INIT_ATTR, 1,
322                         [struct ib_cq_init_attr is used by ib_create_cq])
323         ])
324
325         # 4.3 removed ib_alloc_fast_reg_mr()
326         LB_CHECK_COMPILE([if 'ib_alloc_fast_reg_mr' exists],
327         ib_alloc_fast_reg_mr, [
328                 #ifdef HAVE_COMPAT_RDMA
329                 #undef PACKAGE_NAME
330                 #undef PACKAGE_TARNAME
331                 #undef PACKAGE_VERSION
332                 #undef PACKAGE_STRING
333                 #undef PACKAGE_BUGREPORT
334                 #undef PACKAGE_URL
335                 #include <linux/compat-2.6.h>
336                 #endif
337                 #include <rdma/ib_verbs.h>
338         ],[
339                 ib_alloc_fast_reg_mr(NULL, 0);
340         ],[
341                 AC_DEFINE(HAVE_IB_ALLOC_FAST_REG_MR, 1,
342                         [ib_alloc_fast_reg_mr is defined])
343         ])
344
345         # 4.9 must stop using ib_get_dma_mr and the global MR
346         # We then have to use FMR/Fastreg for all RDMA.
347         LB_CHECK_COMPILE([if 'ib_get_dma_mr' exists],
348         ib_get_dma_mr, [
349                 #ifdef HAVE_COMPAT_RDMA
350                 #undef PACKAGE_NAME
351                 #undef PACKAGE_TARNAME
352                 #undef PACKAGE_VERSION
353                 #undef PACKAGE_STRING
354                 #undef PACKAGE_BUGREPORT
355                 #undef PACKAGE_URL
356                 #include <linux/compat-2.6.h>
357                 #endif
358                 #include <rdma/ib_verbs.h>
359         ],[
360                 ib_get_dma_mr(NULL, 0);
361         ],[
362                 AC_DEFINE(HAVE_IB_GET_DMA_MR, 1,
363                         [ib_get_dma_mr is defined])
364         ])
365
366         # In v4.4 Linux kernel,
367         # commit e622f2f4ad2142d2a613a57fb85f8cf737935ef5
368         # split up struct ib_send_wr so that all non-trivial verbs
369         # use their own structure which embedds struct ib_send_wr.
370         LB_CHECK_COMPILE([if 'struct ib_rdma_wr' is defined],
371         ib_rdma_wr, [
372                 #ifdef HAVE_COMPAT_RDMA
373                 #undef PACKAGE_NAME
374                 #undef PACKAGE_TARNAME
375                 #undef PACKAGE_VERSION
376                 #undef PACKAGE_STRING
377                 #undef PACKAGE_BUGREPORT
378                 #undef PACKAGE_URL
379                 #include <linux/compat-2.6.h>
380                 #endif
381                 #include <rdma/ib_verbs.h>
382         ],[
383                 struct ib_rdma_wr *wr __attribute__ ((unused));
384
385                 wr = rdma_wr(NULL);
386         ],[
387                 AC_DEFINE(HAVE_IB_RDMA_WR, 1,
388                         [struct ib_rdma_wr is defined])
389         ])
390
391         # new fast registration API introduced in 4.4
392         LB_CHECK_COMPILE([if 4arg 'ib_map_mr_sg' exists],
393         ib_map_mr_sg_4args, [
394                 #ifdef HAVE_COMPAT_RDMA
395                 #undef PACKAGE_NAME
396                 #undef PACKAGE_TARNAME
397                 #undef PACKAGE_VERSION
398                 #undef PACKAGE_STRING
399                 #undef PACKAGE_BUGREPORT
400                 #undef PACKAGE_URL
401                 #include <linux/compat-2.6.h>
402                 #endif
403                 #include <rdma/ib_verbs.h>
404         ],[
405                 ib_map_mr_sg(NULL, NULL, 0, 0);
406         ],[
407                 AC_DEFINE(HAVE_IB_MAP_MR_SG, 1,
408                         [ib_map_mr_sg exists])
409         ])
410
411         # ib_map_mr_sg changes from 4 to 5 args (adding sg_offset_p)
412         # in kernel 4.7 (and RHEL 7.3)
413         LB_CHECK_COMPILE([if 5arg 'ib_map_mr_sg' exists],
414         ib_map_mr_sg_5args, [
415                 #ifdef HAVE_COMPAT_RDMA
416                 #undef PACKAGE_NAME
417                 #undef PACKAGE_TARNAME
418                 #undef PACKAGE_VERSION
419                 #undef PACKAGE_STRING
420                 #undef PACKAGE_BUGREPORT
421                 #undef PACKAGE_URL
422                 #include <linux/compat-2.6.h>
423                 #endif
424                 #include <rdma/ib_verbs.h>
425         ],[
426                 ib_map_mr_sg(NULL, NULL, 0, NULL, 0);
427         ],[
428                 AC_DEFINE(HAVE_IB_MAP_MR_SG, 1,
429                         [ib_map_mr_sg exists])
430                 AC_DEFINE(HAVE_IB_MAP_MR_SG_5ARGS, 1,
431                         [ib_map_mr_sg has 5 arguments])
432         ])
433
434         # ib_query_device() removed in 4.5
435         LB_CHECK_COMPILE([if 'struct ib_device' has member 'attrs'],
436         ib_device.attrs, [
437                 #ifdef HAVE_COMPAT_RDMA
438                 #undef PACKAGE_NAME
439                 #undef PACKAGE_TARNAME
440                 #undef PACKAGE_VERSION
441                 #undef PACKAGE_STRING
442                 #undef PACKAGE_BUGREPORT
443                 #undef PACKAGE_URL
444                 #include <linux/compat-2.6.h>
445                 #endif
446                 #include <rdma/ib_verbs.h>
447         ],[
448                 struct ib_device dev;
449                 struct ib_device_attr dev_attr = {};
450                 dev.attrs = dev_attr;
451         ],[
452                 AC_DEFINE(HAVE_IB_DEVICE_ATTRS, 1,
453                         [struct ib_device.attrs is defined])
454         ])
455
456         # A flags argument was added to ib_alloc_pd() in Linux 4.9,
457         # commit ed082d36a7b2c27d1cda55fdfb28af18040c4a89
458         LB_CHECK_COMPILE([if 2arg 'ib_alloc_pd' exists],
459         ib_alloc_pd, [
460                 #ifdef HAVE_COMPAT_RDMA
461                 #undef PACKAGE_NAME
462                 #undef PACKAGE_TARNAME
463                 #undef PACKAGE_VERSION
464                 #undef PACKAGE_STRING
465                 #undef PACKAGE_BUGREPORT
466                 #undef PACKAGE_URL
467                 #include <linux/compat-2.6.h>
468                 #endif
469                 #include <rdma/ib_verbs.h>
470         ],[
471                 ib_alloc_pd(NULL, 0);
472         ],[
473                 AC_DEFINE(HAVE_IB_ALLOC_PD_2ARGS, 1,
474                         [ib_alloc_pd has 2 arguments])
475         ])
476
477         LB_CHECK_COMPILE([if function 'ib_inc_rkey' is defined],
478         ib_inc_rkey, [
479                 #ifdef HAVE_COMPAT_RDMA
480                 #undef PACKAGE_NAME
481                 #undef PACKAGE_TARNAME
482                 #undef PACKAGE_VERSION
483                 #undef PACKAGE_STRING
484                 #undef PACKAGE_BUGREPORT
485                 #undef PACKAGE_URL
486                 #include <linux/compat-2.6.h>
487                 #endif
488                 #include <rdma/ib_verbs.h>
489         ],[
490                 (void)ib_inc_rkey(0);
491         ],[
492                 AC_DEFINE(HAVE_IB_INC_RKEY, 1,
493                           [function ib_inc_rkey exist])
494         ])
495
496         # In MOFED 4.6, the second and third parameters for
497         # ib_post_send() and ib_post_recv() are declared with
498         # 'const'.
499         tmp_flags="$EXTRA_KCFLAGS"
500         EXTRA_KCFLAGS="-Werror"
501         LB_CHECK_COMPILE([if 'ib_post_send() and ib_post_recv()' have const parameters],
502         ib_post_send_recv_const, [
503                 #ifdef HAVE_COMPAT_RDMA
504                 #undef PACKAGE_NAME
505                 #undef PACKAGE_TARNAME
506                 #undef PACKAGE_VERSION
507                 #undef PACKAGE_STRING
508                 #undef PACKAGE_BUGREPORT
509                 #undef PACKAGE_URL
510                 #include <linux/compat-2.6.h>
511                 #endif
512                 #include <rdma/ib_verbs.h>
513         ],[
514                 ib_post_send(NULL, (const struct ib_send_wr *)NULL,
515                              (const struct ib_send_wr **)NULL);
516         ],[
517                 AC_DEFINE(HAVE_IB_POST_SEND_RECV_CONST, 1,
518                         [ib_post_send and ib_post_recv have const parameters])
519         ])
520         EXTRA_KCFLAGS="$tmp_flags"
521
522         # 5.0
523         LN_IB_DEVICE_OPS_EXISTS
524         # 5.1
525         LN_IB_SG_DMA_ADDRESS_EXISTS
526
527         # A reason argument was added to rdma_reject() in Linux 5.8,
528         # commit 8094ba0ace7f6cd1e31ea8b151fba3594cadfa9a
529         LB_CHECK_COMPILE([if 4arg 'rdma_reject' exists],
530         rdma_reject, [
531                 #ifdef HAVE_COMPAT_RDMA
532                 #undef PACKAGE_NAME
533                 #undef PACKAGE_TARNAME
534                 #undef PACKAGE_VERSION
535                 #undef PACKAGE_STRING
536                 #undef PACKAGE_BUGREPORT
537                 #undef PACKAGE_URL
538                 #include <linux/compat-2.6.h>
539                 #endif
540                 #include <rdma/ib_verbs.h>
541                 #include <rdma/ib_cm.h>
542                 #include <rdma/rdma_cm.h>
543         ],[
544                 rdma_reject(NULL, NULL, 0, 0);
545         ],[
546                 AC_DEFINE(HAVE_RDMA_REJECT_4ARGS, 1,
547                         [rdma_reject has 4 arguments])
548         ])
549
550         # The FMR pool API was removed in Linux 5.8,
551         # commit 4e373d5417ecbb4f438a8500f0379a2fc29c2643
552         LB_CHECK_COMPILE([if FMR pools API available],
553         ib_fmr, [
554                 #include <rdma/ib_verbs.h>
555         ],[
556                 struct ib_fmr fmr = {};
557         ],[
558                 AC_DEFINE(HAVE_FMR_POOL_API, 1,
559                         [FMR pool API is available])
560         ])
561
562         # rdma_connect_locked() was added in Linux 5.10,
563         # commit 071ba4cc559de47160761b9500b72e8fa09d923d
564         # and in MOFED-5.2-2. rdma_connect_locked() must
565         # be called instead of rdma_connect() in
566         # RDMA_CM_EVENT_ROUTE_RESOLVED handler.
567         LB_CHECK_COMPILE([if 'rdma_connect_locked' exists],
568         rdma_connect_locked, [
569                 #include <rdma/rdma_cm.h>
570         ],[
571                 rdma_connect_locked(NULL, NULL);
572         ],[
573                 AC_DEFINE(HAVE_RDMA_CONNECT_LOCKED, 1,
574                         [rdma_connect_locked is defined])
575         ])
576
577         # ethtool_link_settings was added in Linux 4.6
578         LB_CHECK_COMPILE([if 'ethtool_link_settings' exists],
579         ethtool_link_settings, [
580                 #include <linux/ethtool.h>
581         ],[
582                 struct ethtool_link_ksettings cmd;
583         ],[
584                 AC_DEFINE(HAVE_ETHTOOL_LINK_SETTINGS, 1,
585                         [ethtool_link_settings is defined])
586         ])
587
588         EXTRA_CHECK_INCLUDE=""
589         AC_DEFUN([LN_CONFIG_O2IB_SRC], [])
590         AC_DEFUN([LN_CONFIG_O2IB_RESULTS], [])
591 ]) # ENABLEO2IB != "no"
592 ]) # LN_CONFIG_O2IB
593
594 #
595 # LN_CONFIG_GNILND
596 #
597 # check whether to use the Gemini Network Interface lnd
598 #
599 AC_DEFUN([LN_CONFIG_GNILND], [
600 AC_MSG_CHECKING([whether to enable GNI lnd])
601 AC_ARG_ENABLE([gni],
602         AS_HELP_STRING([--enable-gni],
603                 [enable GNI lnd]),
604         [], [enable_gni="no"])
605 AC_MSG_RESULT([$enable_gni])
606
607 AS_IF([test "x$enable_gni" = xyes], [
608         # GNICPPFLAGS was set in spec file
609         EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
610         EXTRA_KCFLAGS="$EXTRA_KCFLAGS $GNICPPFLAGS"
611         LB_CHECK_COMPILE([if GNI kernel headers are present],
612         GNI_header, [
613                 #include <linux/types.h>
614                 #include <gni_pub.h>
615         ],[
616                 gni_cdm_handle_t kgni_domain;
617                 gni_return_t     rc;
618                 int              rrc;
619                 rc = gni_cdm_create(0, 1, 1, 0, &kgni_domain);
620                 rrc = (rc == GNI_RC_SUCCESS) ? 0 : 1;
621                 return rrc;
622         ],[
623                 GNILND="gnilnd"
624         ],[
625                 AC_MSG_ERROR([cannot compile gnilnd with given GNICPPFLAGS: $GNICPPFLAGS])
626         ])
627         # at this point, we have gnilnd basic support,
628         # now check for extra features
629         LB_CHECK_COMPILE([to use RCA in gnilnd],
630         RCA_gnilnd, [
631                 #include <linux/types.h>
632                 #include <gni_pub.h>
633                 #include <krca_lib.h>
634         ],[
635                 gni_cdm_handle_t kgni_domain;
636                 gni_return_t     rc;
637                 krca_ticket_t    ticket = KRCA_NULL_TICKET;
638                 int              rrc;
639                 __u32            nid = 0, nic_addr;
640                 rc = gni_cdm_create(0, 1, 1, 0, &kgni_domain);
641                 rrc = (rc == GNI_RC_SUCCESS) ? 0 : 1;
642                 rrc += krca_nid_to_nicaddrs(nid, 1, &nic_addr);
643                 rrc += krca_register(&ticket, RCA_MAKE_SERVICE_INDEX(RCA_IO_CLASS, 9), 99, 0);
644                 return rrc;
645         ],[
646                 GNICPPFLAGS="$GNICPPFLAGS -DGNILND_USE_RCA=1"
647         ])
648         EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
649 ])
650 AC_SUBST(GNICPPFLAGS)
651 AC_SUBST(GNILND)
652 ]) # LN_CONFIG_GNILND
653
654 # LN_CONFIG_STRSCPY_EXISTS
655 #
656 # If strscpy exists, prefer it over strlcpy
657 #
658 AC_DEFUN([LN_CONFIG_STRSCPY_EXISTS], [
659 tmp_flags="$EXTRA_KCFLAGS"
660 EXTRA_KCFLAGS="-Werror"
661 LB_CHECK_COMPILE([kernel strscpy is available],
662 strscpy_exists, [
663         #include <linux/string.h>
664 ],[
665         strscpy((char *)NULL, (const char *)NULL, 0);
666 ],[
667         AC_DEFINE(HAVE_STRSCPY, 1,
668                 [kernel strscpy is available])
669 ])
670 EXTRA_KCFLAGS="$tmp_flags"
671 ]) # LN_CONFIG_STRSCPY_EXISTS
672
673 # LN_CONFIG_SOCK_CREATE_KERN
674 #
675 # 4.x sock_create_kern() added a first parameter as 'struct net *'
676 # instead of int.
677 #
678 AC_DEFUN([LN_CONFIG_SOCK_CREATE_KERN], [
679 tmp_flags="$EXTRA_KCFLAGS"
680 EXTRA_KCFLAGS="-Werror"
681 LB_CHECK_COMPILE([if 'sock_create_kern' first parameter is net],
682 sock_create_kern_net, [
683         #include <linux/net.h>
684         #include <net/net_namespace.h>
685 ],[
686         sock_create_kern((struct net*)0, 0, 0, 0, NULL);
687 ],[
688         AC_DEFINE(HAVE_SOCK_CREATE_KERN_USE_NET, 1,
689                 [sock_create_kern use net as first parameter])
690 ])
691 EXTRA_KCFLAGS="$tmp_flags"
692 ]) # LN_CONFIG_SOCK_CREATE_KERN
693
694 #
695 # LN_CONFIG_SK_DATA_READY
696 #
697 # 3.15 for struct sock the *sk_data_ready() field only takes one argument now
698 #
699 AC_DEFUN([LN_CONFIG_SK_DATA_READY], [
700 tmp_flags="$EXTRA_KCFLAGS"
701 EXTRA_KCFLAGS="-Werror"
702 LB_CHECK_COMPILE([if 'sk_data_ready' takes only one argument],
703 sk_data_ready, [
704         #include <linux/net.h>
705         #include <net/sock.h>
706 ],[
707         ((struct sock *)0)->sk_data_ready(NULL);
708 ],[
709         AC_DEFINE(HAVE_SK_DATA_READY_ONE_ARG, 1,
710                 [sk_data_ready uses only one argument])
711 ])
712 EXTRA_KCFLAGS="$tmp_flags"
713 ]) # LN_CONFIG_SK_DATA_READY
714
715 #
716 # LN_EXPORT_KMAP_TO_PAGE
717 #
718 # 3.10 Export kmap_to_page
719 #
720 AC_DEFUN([LN_EXPORT_KMAP_TO_PAGE], [
721 LB_CHECK_EXPORT([kmap_to_page], [mm/highmem.c],
722         [AC_DEFINE(HAVE_KMAP_TO_PAGE, 1,
723                 [kmap_to_page is exported by the kernel])])
724 ]) # LN_EXPORT_KMAP_TO_PAG
725
726 #
727 # LN_HAVE_HYPERVISOR_IS_TYPE
728 #
729 # 4.14 commit 79cc74155218316b9a5d28577c7077b2adba8e58
730 # x86/paravirt: Provide a way to check for hypervisors
731 #
732 AC_DEFUN([LN_HAVE_HYPERVISOR_IS_TYPE], [
733 tmp_flags="$EXTRA_KCFLAGS"
734 EXTRA_KCFLAGS="-Werror"
735 LB_CHECK_COMPILE([if hypervisor_is_type function is available],
736 hypervisor_is_type_exists, [
737         #include <asm/hypervisor.h>
738 ],[
739         (void)hypervisor_is_type(X86_HYPER_NATIVE);
740 ],[
741         AC_DEFINE(HAVE_HYPERVISOR_IS_TYPE, 1,
742                 [hypervisor_is_type function exists])
743 ])
744 EXTRA_KCFLAGS="$tmp_flags"
745 ]) # LN_HAVE_HYPERVISOR_IS_TYPE
746
747 #
748 # LN_HAVE_ORACLE_OFED_EXTENSIONS
749 #
750 # Oracle UEK 5
751 #
752 AC_DEFUN([LN_HAVE_ORACLE_OFED_EXTENSIONS], [
753 LB_CHECK_COMPILE([if Oracle OFED Extensions are enabled],
754 oracle_ofed_ext, [
755         #include <rdma/ib_fmr_pool.h>
756 ],[
757         struct ib_fmr_pool_param param = {
758                 .relaxed           = 0
759         };
760         (void)param;
761 ],[
762         AC_DEFINE(HAVE_ORACLE_OFED_EXTENSIONS, 1,
763                 [if Oracle OFED Extensions are enabled])
764 ])
765 ]) # LN_HAVE_ORACLE_OFED_EXTENSIONS
766
767 #
768 # LN_CONFIG_SOCK_GETNAME
769 #
770 # 4.17 commit 9b2c45d479d0fb8647c9e83359df69162b5fbe5f getname()
771 # does not take the length *int argument and returns the length
772 #
773 AC_DEFUN([LN_CONFIG_SOCK_GETNAME], [
774 tmp_flags="$EXTRA_KCFLAGS"
775 EXTRA_KCFLAGS="-Werror"
776 LB_CHECK_COMPILE([if 'getname' has two args],
777 kern_sock_getname_2args, [
778         #include <linux/net.h>
779 ],[
780         kernel_getsockname(NULL, NULL);
781 ],[
782         AC_DEFINE(HAVE_KERN_SOCK_GETNAME_2ARGS, 1,
783                 ['getname' has two args])
784 ])
785 EXTRA_KCFLAGS="$tmp_flags"
786 ]) # LN_CONFIG_SOCK_GETNAME
787
788 #
789 # LN_HAVE_IN_DEV_FOR_EACH_IFA_RTNL
790 #
791 # kernel 5.3 commit ef11db3310e272d3d8dbe8739e0770820dd20e52
792 # and kernel 4.18.0-193.el8:
793 # added in_dev_for_each_ifa_rtnl and in_dev_for_each_ifa_rcu
794 # and removed for_ifa and endfor_ifa.
795 # Use the _rntl variant as the current locking is rtnl.
796 #
797 AC_DEFUN([LN_HAVE_IN_DEV_FOR_EACH_IFA_RTNL], [
798 tmp_flags="$EXTRA_KCFLAGS"
799 EXTRA_KCFLAGS="-Werror"
800 LB_CHECK_COMPILE([if 'in_dev_for_each_ifa_rtnl' is defined],
801 in_dev_for_each_ifa_rtnl_test, [
802         #include <linux/inetdevice.h>
803 ],[
804         const struct in_ifaddr *ifa = NULL;
805         struct in_device *in_dev = NULL;
806
807         in_dev_for_each_ifa_rtnl(ifa, in_dev) {}
808 ],[
809         AC_DEFINE(HAVE_IN_DEV_FOR_EACH_IFA_RTNL, 1,
810                 ['in_dev_for_each_ifa_rtnl' is defined])
811 ])
812 EXTRA_KCFLAGS="$tmp_flags"
813 ]) # LN_HAVE_IN_DEV_FOR_EACH_IFA_RTNL
814
815 #
816 # LN_IB_DEVICE_OPS_EXISTS
817 #
818 # kernel 5.0 commit 521ed0d92ab0db3edd17a5f4716b7f698f4fce61
819 # RDMA/core: Introduce ib_device_ops
820 # ... introduces the ib_device_ops structure that defines all the
821 # InfiniBand device operations in one place ...
822 #
823 AC_DEFUN([LN_IB_DEVICE_OPS_EXISTS], [
824 tmp_flags="$EXTRA_KCFLAGS"
825 EXTRA_KCFLAGS="-Werror"
826 LB_CHECK_COMPILE([if struct ib_device_ops is defined],
827 ib_device_ops_test, [
828         #include <rdma/ib_verbs.h>
829 ],[
830         int x = offsetof(struct ib_device_ops, unmap_fmr);
831         x = x;
832         (void)x;
833 ],[
834         AC_DEFINE(HAVE_IB_DEVICE_OPS, 1,
835                 [if struct ib_device_ops is defined])
836 ])
837 EXTRA_KCFLAGS="$tmp_flags"
838 ]) # LN_IB_DEVICE_OPS_EXISTS
839
840 #
841 # LN_IB_SG_DMA_ADDRESS_EXISTS
842 #
843 # kernel 5.1 commit a163afc88556e099271a7b423295bc5176fcecce
844 # IB/core: Remove ib_sg_dma_address() and ib_sg_dma_len()
845 # ... when dma_ops existed (3.6) ib_sg_dma_address() was not trivial ...
846 #
847 AC_DEFUN([LN_IB_SG_DMA_ADDRESS_EXISTS], [
848 tmp_flags="$EXTRA_KCFLAGS"
849 EXTRA_KCFLAGS="-Werror"
850 LB_CHECK_COMPILE([if ib_sg_dma_address wrapper exists],
851 ib_sg_dma_address_test, [
852         #include <rdma/ib_verbs.h>
853 ],[
854         u64 x = ib_sg_dma_address(NULL, NULL);
855         x = x;
856         (void)x;
857 ],[
858         AC_DEFINE(HAVE_IB_SG_DMA_ADDRESS, 1,
859                 [if ib_sg_dma_address wrapper exists])
860 ])
861 EXTRA_KCFLAGS="$tmp_flags"
862 ]) # LN_IB_SG_DMA_ADDRESS_EXISTS
863
864 #
865 # LN_USR_RDMA
866 #
867 #
868 AC_DEFUN([LN_USR_RDMA], [
869 AC_MSG_CHECKING([if RDMA_PS_TCP exists])
870 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
871         #include <rdma/rdma_user_cm.h>
872
873         int main(void) {
874                 int x = (int)RDMA_PS_TCP;
875                 return x;
876         }
877 ])],[
878         AC_DEFINE(HAVE_USRSPC_RDMA_PS_TCP, 1,
879                 [RDMA_PS_TCP exists])
880 ])
881 ]) # LN_USR_RDMA
882
883
884 AC_DEFUN([LN_PROG_LINUX_SRC], [])
885 AC_DEFUN([LN_PROG_LINUX_RESULTS], [])
886
887 #
888 # LN_PROG_LINUX
889 #
890 # LNet linux kernel checks
891 #
892 AC_DEFUN([LN_PROG_LINUX], [
893 AC_MSG_NOTICE([LNet kernel checks
894 ==============================================================================])
895
896 LN_CONFIG_BACKOFF
897 LN_CONFIG_O2IB
898 LN_CONFIG_GNILND
899 LN_CONFIG_STRSCPY_EXISTS
900 # 3.10
901 LN_EXPORT_KMAP_TO_PAGE
902 # 3.15
903 LN_CONFIG_SK_DATA_READY
904 # 4.x
905 LN_CONFIG_SOCK_CREATE_KERN
906 # 4.14
907 LN_HAVE_HYPERVISOR_IS_TYPE
908 LN_HAVE_ORACLE_OFED_EXTENSIONS
909 # 4.17
910 LN_CONFIG_SOCK_GETNAME
911 # 5.3 and 4.18.0-193.el8
912 LN_HAVE_IN_DEV_FOR_EACH_IFA_RTNL
913 ]) # LN_PROG_LINUX
914
915 #
916 # LN_PATH_DEFAULTS
917 #
918 # default paths for installed files
919 #
920 AC_DEFUN([LN_PATH_DEFAULTS], [
921 ]) # LN_PATH_DEFAULTS
922
923 #
924 # LN_CONFIGURE
925 #
926 # other configure checks
927 #
928 AC_DEFUN([LN_CONFIGURE], [
929 AC_MSG_NOTICE([LNet core checks
930 ==============================================================================])
931
932 AC_ARG_WITH([cuda],
933         AS_HELP_STRING([--with-cuda=path],
934                         [Use a CUDA sources.]),
935         [LB_ARG_CANON_PATH([cuda], [CUDA_PATH])],
936         [CUDA_PATH=`ls -d1 /usr/src/nvidia-*/nvidia/ | tail -1`]
937 )
938
939 AC_ARG_WITH([gds],
940         AS_HELP_STRING([--with-gds=path],
941                         [Use a gds sources.]),
942         [LB_ARG_CANON_PATH([gds], [GDS_PATH])],
943         [GDS_PATH=`ls -d1 /usr/src/nvidia-fs* | tail -1`]
944 )
945
946 AS_IF([test -n "${CUDA_PATH}" && test -n "${GDS_PATH}"],[
947 LB_CHECK_FILE([$CUDA_PATH/nv-p2p.h],
948         [
949         AC_MSG_RESULT([CUDA path is $CUDA_PATH])
950         AC_SUBST(CUDA_PATH)
951         ],
952         [AC_MSG_ERROR([CUDA sources don't found. nv-p2p.h don't exit])]
953 )
954
955 LB_CHECK_FILE([$GDS_PATH/nvfs-dma.h],
956         [
957         LB_CHECK_FILE([$GDS_PATH/config-host.h], [
958         AC_MSG_RESULT([GDS path is $GDS_PATH])
959         AC_SUBST(GDS_PATH)
960         AC_DEFINE(WITH_GDS, 1, "GDS build enabled")
961         ], [])
962         ],
963         [])
964 ],[
965         AC_MSG_WARN([CUDA or GDS sources not found. GDS support disabled])
966 ]
967 )
968
969 # lnet/utils/lnetconfig/liblnetconfig_netlink.c
970 AS_IF([test "x$enable_dist" = xno], [
971         PKG_CHECK_MODULES(LIBNL3, [libnl-genl-3.0 >= 3.1])
972 ])
973
974 AC_CHECK_LIB([nl-3], [nla_get_s32], [
975         AC_DEFINE(HAVE_NLA_GET_S32, 1,
976                 [libnl3 supports nla_get_s32])
977         ], [
978 ])
979
980 AC_CHECK_LIB([nl-3], [nla_get_s64], [
981         AC_DEFINE(HAVE_NLA_GET_S64, 1,
982                 [libnl3 supports nla_get_s64])
983         ], [
984 ])
985
986 #
987 # LN_USR_NLMSGERR
988 #
989 AC_DEFUN([LN_USR_NLMSGERR], [
990 AC_MSG_CHECKING([if 'enum nlmsgerr_attrs' exists])
991 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
992         #include <linux/netlink.h>
993
994         int main(void) {
995                 int x = (int)NLMSGERR_ATTR_MAX;
996                 return x;
997         }
998 ])],[
999         AC_DEFINE(HAVE_USRSPC_NLMSGERR, 1,
1000                 ['enum nlmsgerr_attrs' exists])
1001 ])
1002 ]) # LN_USR_NLMGSERR
1003
1004 # lnet/utils/portals.c
1005 AC_CHECK_HEADERS([netdb.h])
1006 AC_CHECK_FUNCS([gethostbyname])
1007
1008 # lnet/utils/wirecheck.c
1009 AC_CHECK_FUNCS([strnlen])
1010
1011 # --------  Check for required packages  --------------
1012
1013 AC_MSG_CHECKING([whether to enable 'efence' debugging support])
1014 AC_ARG_ENABLE(efence,
1015         AS_HELP_STRING([--enable-efence],
1016                 [use efence library]),
1017         [], [enable_efence="no"])
1018 AC_MSG_RESULT([$enable_efence])
1019
1020 LIBEFENCE=""
1021 AS_IF([test "$enable_efence" = yes], [
1022         LIBEFENCE="-lefence"
1023         AC_DEFINE(HAVE_LIBEFENCE, 1,
1024                 [libefence support is requested])
1025 ])
1026 AC_SUBST(LIBEFENCE)
1027
1028 LN_CONFIG_DLC
1029 LN_USR_RDMA
1030 LN_USR_NLMSGERR
1031 ]) # LN_CONFIGURE
1032
1033 #
1034 # LN_CONDITIONALS
1035 #
1036 # AM_CONDITIONAL defines for lnet
1037 #
1038 AC_DEFUN([LN_CONDITIONALS], [
1039 AM_CONDITIONAL(BUILD_O2IBLND,    test x$O2IBLND = "xo2iblnd")
1040 AM_CONDITIONAL(BUILD_GNILND,     test x$GNILND  = "xgnilnd")
1041 ]) # LN_CONDITIONALS
1042
1043 #
1044 # LN_CONFIG_FILES
1045 #
1046 # files that should be generated with AC_OUTPUT
1047 #
1048 AC_DEFUN([LN_CONFIG_FILES], [
1049 AC_CONFIG_FILES([
1050 lnet/Makefile
1051 lnet/autoMakefile
1052 lnet/autoconf/Makefile
1053 lnet/doc/Makefile
1054 lnet/include/Makefile
1055 lnet/include/lnet/Makefile
1056 lnet/include/uapi/linux/lnet/Makefile
1057 lnet/klnds/Makefile
1058 lnet/klnds/autoMakefile
1059 lnet/klnds/o2iblnd/Makefile
1060 lnet/klnds/o2iblnd/autoMakefile
1061 lnet/klnds/gnilnd/Makefile
1062 lnet/klnds/gnilnd/autoMakefile
1063 lnet/klnds/socklnd/Makefile
1064 lnet/klnds/socklnd/autoMakefile
1065 lnet/lnet/Makefile
1066 lnet/lnet/autoMakefile
1067 lnet/selftest/Makefile
1068 lnet/selftest/autoMakefile
1069 lnet/utils/Makefile
1070 lnet/utils/lnetconfig/Makefile
1071 ])
1072 ]) # LN_CONFIG_FILES