Whamcloud - gitweb
LU-10391 lnet: discard lnet_sock_accept()
[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         AC_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         AC_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 | 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\|/ofa_kernel\)$' | head -n1)
70                         AS_IF([test -z "$O2IBPATHS"], [
71                                 AC_MSG_ERROR([
72 You seem to have an OFED installed but have not installed it's devel package.
73 If you still want to build Lustre for your OFED I/B stack, you need to install its devel headers RPM.
74 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.
75                                              ])
76                         ])
77                         AS_IF([test $(echo $O2IBPATHS | wc -w) -ge 2], [
78                                 AC_MSG_ERROR([
79 It appears that you have multiple OFED versions installed.
80 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.
81 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.
82                                              ])
83                         ])
84                         if test -e $O2IBPATHS/${LINUXRELEASE}; then
85                             O2IBPATHS=$O2IBPATHS/${LINUXRELEASE}
86                         elif test -e $O2IBPATHS/default; then
87                             O2IBPATHS=$O2IBPATHS/default
88                         fi
89                         OFED="yes"
90                 ], [
91                         O2IBPATHS="$LINUX $LINUX/drivers/infiniband"
92                 ])
93                 ENABLEO2IB="yes"
94                 ;;
95         no)     ENABLEO2IB="no"
96                 ;;
97         *)      O2IBPATHS=$with_o2ib
98                 ENABLEO2IB="withpath"
99                 OFED="yes"
100                 ;;
101 esac
102
103 AS_IF([test $ENABLEO2IB = "no"], [
104         AC_MSG_RESULT([no])
105 ], [
106         o2ib_found=false
107         for O2IBPATH in $O2IBPATHS; do
108                 AS_IF([test \( -f ${O2IBPATH}/include/rdma/rdma_cm.h -a \
109                            -f ${O2IBPATH}/include/rdma/ib_cm.h -a \
110                            -f ${O2IBPATH}/include/rdma/ib_verbs.h -a \
111                            -f ${O2IBPATH}/include/rdma/ib_fmr_pool.h \)], [
112                         o2ib_found=true
113                         break
114                 ])
115         done
116         if ! $o2ib_found; then
117                 AC_MSG_RESULT([no])
118                 case $ENABLEO2IB in
119                         "yes") AC_MSG_ERROR([no OFED nor kernel OpenIB gen2 headers present]) ;;
120                         "withpath") AC_MSG_ERROR([bad --with-o2ib path]) ;;
121                         *) AC_MSG_ERROR([internal error]) ;;
122                 esac
123         else
124                 COMPAT_AUTOCONF=""
125                 compatrdma_found=false
126                 if test -f ${O2IBPATH}/include/linux/compat-2.6.h; then
127                         AC_MSG_RESULT([yes])
128                         compatrdma_found=true
129                         AC_DEFINE(HAVE_COMPAT_RDMA, 1, [compat rdma found])
130                         EXTRA_OFED_CONFIG="$EXTRA_OFED_CONFIG -include ${O2IBPATH}/include/linux/compat-2.6.h"
131                         if test -f "$O2IBPATH/include/linux/compat_autoconf.h"; then
132                                 COMPAT_AUTOCONF="$O2IBPATH/include/linux/compat_autoconf.h"
133                         fi
134                 else
135                         AC_MSG_RESULT([no])
136                 fi
137                 if ! $compatrdma_found; then
138                         if test -f "$O2IBPATH/config.mk"; then
139                                 . "$O2IBPATH/config.mk"
140                         elif test -f "$O2IBPATH/ofed_patch.mk"; then
141                                 . "$O2IBPATH/ofed_patch.mk"
142                         fi
143                 elif test -z "$COMPAT_AUTOCONF"; then
144                         # Depreciated checks
145                         if test "x$RHEL_KERNEL" = xyes; then
146                                 RHEL_MAJOR=$(awk '/ RHEL_MAJOR / { print [$]3 }' $LINUX_OBJ/include/$VERSION_HDIR/version.h)
147                                 I=$(awk '/ RHEL_MINOR / { print [$]3 }' $LINUX_OBJ/include/$VERSION_HDIR/version.h)
148                                 while test "$I" -ge 0; do
149                                         EXTRA_OFED_INCLUDE="$EXTRA_OFED_INCLUDE -DCONFIG_COMPAT_RHEL_${RHEL_MAJOR}_$I"
150                                         I=$(($I-1))
151                                 done
152                         elif test "x$SUSE_KERNEL" = xyes; then
153                                 SP=$(grep PATCHLEVEL /etc/SuSE-release | sed -e 's/.*= *//')
154                                 EXTRA_OFED_INCLUDE="$EXTRA_OFED_INCLUDE -DCONFIG_COMPAT_SLES_11_$SP"
155                         fi
156                 fi
157
158                 AC_MSG_CHECKING([whether to use any OFED backport headers])
159                 if test -n "$BACKPORT_INCLUDES"; then
160                         AC_MSG_RESULT([yes])
161                         OFED_BACKPORT_PATH="$O2IBPATH/${BACKPORT_INCLUDES/*\/kernel_addons/kernel_addons}/"
162                         EXTRA_OFED_INCLUDE="-I$OFED_BACKPORT_PATH $EXTRA_OFED_INCLUDE"
163                 else
164                         AC_MSG_RESULT([no])
165                 fi
166
167                 O2IBLND=""
168                 O2IBPATH=$(readlink --canonicalize $O2IBPATH)
169                 EXTRA_OFED_INCLUDE="$EXTRA_OFED_INCLUDE -I$O2IBPATH/include -I$O2IBPATH/include/uapi"
170                 EXTRA_CHECK_INCLUDE="$EXTRA_OFED_CONFIG $EXTRA_OFED_INCLUDE"
171                 LB_CHECK_COMPILE([whether to enable OpenIB gen2 support],
172                 openib_gen2_support, [
173                         #ifdef HAVE_COMPAT_RDMA
174                         #undef PACKAGE_NAME
175                         #undef PACKAGE_TARNAME
176                         #undef PACKAGE_VERSION
177                         #undef PACKAGE_STRING
178                         #undef PACKAGE_BUGREPORT
179                         #undef PACKAGE_URL
180                         #include <linux/compat-2.6.h>
181                         #endif
182                         #include <linux/version.h>
183                         #include <linux/pci.h>
184                         #include <linux/gfp.h>
185                         #include <rdma/rdma_cm.h>
186                         #include <rdma/ib_cm.h>
187                         #include <rdma/ib_verbs.h>
188                         #include <rdma/ib_fmr_pool.h>
189                 ],[
190                         struct rdma_cm_id      *cm_idi __attribute__ ((unused));
191                         struct rdma_conn_param  conn_param __attribute__ ((unused));
192                         struct ib_device_attr   device_attr __attribute__ ((unused));
193                         struct ib_qp_attr       qp_attr __attribute__ ((unused));
194                         struct ib_pool_fmr      pool_fmr __attribute__ ((unused));
195                         enum   ib_cm_rej_reason rej_reason __attribute__ ((unused));
196                         rdma_destroy_id(NULL);
197                 ],[
198                         O2IBLND="o2iblnd"
199                 ],[
200                         case $ENABLEO2IB in
201                         "yes") AC_MSG_ERROR([can't compile with OpenIB gen2 headers]) ;;
202                         "withpath") AC_MSG_ERROR([can't compile with OpenIB gen2 headers under $O2IBPATH]) ;;
203                         *) AC_MSG_ERROR([internal error]) ;;
204                         esac
205                 ])
206                 # we know at this point that the found OFED source is good
207                 O2IB_SYMVER=""
208                 if test $ENABLEO2IB = "withpath" -o "x$OFED" = "xyes" ; then
209                         if test -f $O2IBPATH/Module.symvers; then
210                                 O2IB_SYMVER=$O2IBPATH/Module.symvers;
211                                 break;
212                         fi
213                         if test -n "$O2IB_SYMVER"; then
214                                 AC_MSG_NOTICE([adding $O2IB_SYMVER to Symbol Path])
215                                 EXTRA_SYMBOLS="$EXTRA_SYMBOLS $O2IB_SYMVER"
216                                 AC_SUBST(EXTRA_SYMBOLS)
217                         else
218                                 AC_MSG_ERROR([an external source tree was, either specified or detected, for o2iblnd however I could not find a $O2IBPATH/Module.symvers there])
219                         fi
220                 fi
221
222                 LB_CHECK_COMPILE([if Linux kernel has kthread_worker],
223                 linux_kthread_worker, [
224                         #ifdef HAVE_COMPAT_RDMA
225                         #undef PACKAGE_NAME
226                         #undef PACKAGE_TARNAME
227                         #undef PACKAGE_VERSION
228                         #undef PACKAGE_STRING
229                         #undef PACKAGE_BUGREPORT
230                         #undef PACKAGE_URL
231                         #include <linux/compat-2.6.h>
232                         #endif
233                         #include <linux/kthread.h>
234                 ],[
235                         struct kthread_work *kth_wrk = NULL;
236                         flush_kthread_work(kth_wrk);
237                 ],[
238                         AC_DEFINE(HAVE_KTHREAD_WORK, 1, [kthread_worker found])
239                         if test -z "$COMPAT_AUTOCONF"; then
240                                 EXTRA_OFED_INCLUDE="$EXTRA_OFED_INCLUDE -DCONFIG_COMPAT_IS_KTHREAD"
241                         fi
242                 ])
243                 EXTRA_CHECK_INCLUDE=""
244         fi
245 ])
246 AC_SUBST(EXTRA_OFED_CONFIG)
247 AC_SUBST(EXTRA_OFED_INCLUDE)
248 AC_SUBST(O2IBLND)
249 AC_SUBST(O2IBPATH)
250 AC_SUBST(ENABLEO2IB)
251
252 AS_IF([test $ENABLEO2IB != "no"], [
253         EXTRA_CHECK_INCLUDE="$EXTRA_OFED_CONFIG $EXTRA_OFED_INCLUDE"
254
255         # In RHEL 6.2, rdma_create_id() takes the queue-pair type as a fourth argument
256         LB_CHECK_COMPILE([if 'rdma_create_id' wants four args],
257         rdma_create_id_4args, [
258                 #ifdef HAVE_COMPAT_RDMA
259                 #undef PACKAGE_NAME
260                 #undef PACKAGE_TARNAME
261                 #undef PACKAGE_VERSION
262                 #undef PACKAGE_STRING
263                 #undef PACKAGE_BUGREPORT
264                 #undef PACKAGE_URL
265                 #include <linux/compat-2.6.h>
266                 #endif
267                 #include <rdma/rdma_cm.h>
268         ],[
269                 rdma_create_id(NULL, NULL, 0, 0);
270         ],[
271                 AC_DEFINE(HAVE_RDMA_CREATE_ID_4ARG, 1,
272                         [rdma_create_id wants 4 args])
273         ])
274
275         # 4.4 added network namespace parameter for rdma_create_id()
276         LB_CHECK_COMPILE([if 'rdma_create_id' wants five args],
277         rdma_create_id_5args, [
278                 #ifdef HAVE_COMPAT_RDMA
279                 #undef PACKAGE_NAME
280                 #undef PACKAGE_TARNAME
281                 #undef PACKAGE_VERSION
282                 #undef PACKAGE_STRING
283                 #undef PACKAGE_BUGREPORT
284                 #undef PACKAGE_URL
285                 #include <linux/compat-2.6.h>
286                 #endif
287                 #include <rdma/rdma_cm.h>
288         ],[
289                 rdma_create_id(NULL, NULL, NULL, 0, 0);
290         ],[
291                 AC_DEFINE(HAVE_RDMA_CREATE_ID_5ARG, 1,
292                         [rdma_create_id wants 5 args])
293         ])
294
295         # 4.2 introduced struct ib_cq_init_attr which is used
296         # by ib_create_cq(). Note some OFED stacks only keep
297         # their headers in sync with latest kernels but not
298         # the functionality which means for infiniband testing
299         # we need to always test functionality testings.
300         LB_CHECK_COMPILE([if 'struct ib_cq_init_attr' is used],
301         ib_cq_init_attr, [
302                 #ifdef HAVE_COMPAT_RDMA
303                 #undef PACKAGE_NAME
304                 #undef PACKAGE_TARNAME
305                 #undef PACKAGE_VERSION
306                 #undef PACKAGE_STRING
307                 #undef PACKAGE_BUGREPORT
308                 #undef PACKAGE_URL
309                 #include <linux/compat-2.6.h>
310                 #endif
311                 #include <rdma/ib_verbs.h>
312         ],[
313                 struct ib_cq_init_attr cq_attr;
314
315                 ib_create_cq(NULL, NULL, NULL, NULL, &cq_attr);
316         ],[
317                 AC_DEFINE(HAVE_IB_CQ_INIT_ATTR, 1,
318                         [struct ib_cq_init_attr is used by ib_create_cq])
319         ])
320
321         # 4.3 removed ib_alloc_fast_reg_mr()
322         LB_CHECK_COMPILE([if 'ib_alloc_fast_reg_mr' exists],
323         ib_alloc_fast_reg_mr, [
324                 #ifdef HAVE_COMPAT_RDMA
325                 #undef PACKAGE_NAME
326                 #undef PACKAGE_TARNAME
327                 #undef PACKAGE_VERSION
328                 #undef PACKAGE_STRING
329                 #undef PACKAGE_BUGREPORT
330                 #undef PACKAGE_URL
331                 #include <linux/compat-2.6.h>
332                 #endif
333                 #include <rdma/ib_verbs.h>
334         ],[
335                 ib_alloc_fast_reg_mr(NULL, 0);
336         ],[
337                 AC_DEFINE(HAVE_IB_ALLOC_FAST_REG_MR, 1,
338                         [ib_alloc_fast_reg_mr is defined])
339         ])
340
341         # 4.9 must stop using ib_get_dma_mr and the global MR
342         # We then have to use FMR/Fastreg for all RDMA.
343         LB_CHECK_COMPILE([if 'ib_get_dma_mr' exists],
344         ib_get_dma_mr, [
345                 #ifdef HAVE_COMPAT_RDMA
346                 #undef PACKAGE_NAME
347                 #undef PACKAGE_TARNAME
348                 #undef PACKAGE_VERSION
349                 #undef PACKAGE_STRING
350                 #undef PACKAGE_BUGREPORT
351                 #undef PACKAGE_URL
352                 #include <linux/compat-2.6.h>
353                 #endif
354                 #include <rdma/ib_verbs.h>
355         ],[
356                 ib_get_dma_mr(NULL, 0);
357         ],[
358                 AC_DEFINE(HAVE_IB_GET_DMA_MR, 1,
359                         [ib_get_dma_mr is defined])
360         ])
361
362         # In v4.4 Linux kernel,
363         # commit e622f2f4ad2142d2a613a57fb85f8cf737935ef5
364         # split up struct ib_send_wr so that all non-trivial verbs
365         # use their own structure which embedds struct ib_send_wr.
366         LB_CHECK_COMPILE([if 'struct ib_rdma_wr' is defined],
367         ib_rdma_wr, [
368                 #ifdef HAVE_COMPAT_RDMA
369                 #undef PACKAGE_NAME
370                 #undef PACKAGE_TARNAME
371                 #undef PACKAGE_VERSION
372                 #undef PACKAGE_STRING
373                 #undef PACKAGE_BUGREPORT
374                 #undef PACKAGE_URL
375                 #include <linux/compat-2.6.h>
376                 #endif
377                 #include <rdma/ib_verbs.h>
378         ],[
379                 struct ib_rdma_wr *wr __attribute__ ((unused));
380
381                 wr = rdma_wr(NULL);
382         ],[
383                 AC_DEFINE(HAVE_IB_RDMA_WR, 1,
384                         [struct ib_rdma_wr is defined])
385         ])
386
387         # new fast registration API introduced in 4.4
388         LB_CHECK_COMPILE([if 4arg 'ib_map_mr_sg' exists],
389         ib_map_mr_sg_4args, [
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                 ib_map_mr_sg(NULL, NULL, 0, 0);
402         ],[
403                 AC_DEFINE(HAVE_IB_MAP_MR_SG, 1,
404                         [ib_map_mr_sg exists])
405         ])
406
407         # ib_map_mr_sg changes from 4 to 5 args (adding sg_offset_p)
408         # in kernel 4.7 (and RHEL 7.3)
409         LB_CHECK_COMPILE([if 5arg 'ib_map_mr_sg' exists],
410         ib_map_mr_sg_5args, [
411                 #ifdef HAVE_COMPAT_RDMA
412                 #undef PACKAGE_NAME
413                 #undef PACKAGE_TARNAME
414                 #undef PACKAGE_VERSION
415                 #undef PACKAGE_STRING
416                 #undef PACKAGE_BUGREPORT
417                 #undef PACKAGE_URL
418                 #include <linux/compat-2.6.h>
419                 #endif
420                 #include <rdma/ib_verbs.h>
421         ],[
422                 ib_map_mr_sg(NULL, NULL, 0, NULL, 0);
423         ],[
424                 AC_DEFINE(HAVE_IB_MAP_MR_SG, 1,
425                         [ib_map_mr_sg exists])
426                 AC_DEFINE(HAVE_IB_MAP_MR_SG_5ARGS, 1,
427                         [ib_map_mr_sg has 5 arguments])
428         ])
429
430         # ib_query_device() removed in 4.5
431         LB_CHECK_COMPILE([if 'struct ib_device' has member 'attrs'],
432         ib_device.attrs, [
433                 #ifdef HAVE_COMPAT_RDMA
434                 #undef PACKAGE_NAME
435                 #undef PACKAGE_TARNAME
436                 #undef PACKAGE_VERSION
437                 #undef PACKAGE_STRING
438                 #undef PACKAGE_BUGREPORT
439                 #undef PACKAGE_URL
440                 #include <linux/compat-2.6.h>
441                 #endif
442                 #include <rdma/ib_verbs.h>
443         ],[
444                 struct ib_device dev;
445                 struct ib_device_attr dev_attr = {};
446                 dev.attrs = dev_attr;
447         ],[
448                 AC_DEFINE(HAVE_IB_DEVICE_ATTRS, 1,
449                         [struct ib_device.attrs is defined])
450         ])
451
452         # A flags argument was added to ib_alloc_pd() in Linux 4.9,
453         # commit ed082d36a7b2c27d1cda55fdfb28af18040c4a89
454         LB_CHECK_COMPILE([if 2arg 'ib_alloc_pd' exists],
455         ib_alloc_pd, [
456                 #ifdef HAVE_COMPAT_RDMA
457                 #undef PACKAGE_NAME
458                 #undef PACKAGE_TARNAME
459                 #undef PACKAGE_VERSION
460                 #undef PACKAGE_STRING
461                 #undef PACKAGE_BUGREPORT
462                 #undef PACKAGE_URL
463                 #include <linux/compat-2.6.h>
464                 #endif
465                 #include <rdma/ib_verbs.h>
466         ],[
467                 ib_alloc_pd(NULL, 0);
468         ],[
469                 AC_DEFINE(HAVE_IB_ALLOC_PD_2ARGS, 1,
470                         [ib_alloc_pd has 2 arguments])
471         ])
472
473         LB_CHECK_COMPILE([if function 'ib_inc_rkey' is defined],
474         ib_inc_rkey, [
475                 #ifdef HAVE_COMPAT_RDMA
476                 #undef PACKAGE_NAME
477                 #undef PACKAGE_TARNAME
478                 #undef PACKAGE_VERSION
479                 #undef PACKAGE_STRING
480                 #undef PACKAGE_BUGREPORT
481                 #undef PACKAGE_URL
482                 #include <linux/compat-2.6.h>
483                 #endif
484                 #include <rdma/ib_verbs.h>
485         ],[
486                 (void)ib_inc_rkey(0);
487         ],[
488                 AC_DEFINE(HAVE_IB_INC_RKEY, 1,
489                           [function ib_inc_rkey exist])
490         ])
491
492         # In MOFED 4.6, the second and third parameters for
493         # ib_post_send() and ib_post_recv() are declared with
494         # 'const'.
495         tmp_flags="$EXTRA_KCFLAGS"
496         EXTRA_KCFLAGS="-Werror"
497         LB_CHECK_COMPILE([if 'ib_post_send() and ib_post_recv()' have const parameters],
498         ib_post_send_recv_const, [
499                 #ifdef HAVE_COMPAT_RDMA
500                 #undef PACKAGE_NAME
501                 #undef PACKAGE_TARNAME
502                 #undef PACKAGE_VERSION
503                 #undef PACKAGE_STRING
504                 #undef PACKAGE_BUGREPORT
505                 #undef PACKAGE_URL
506                 #include <linux/compat-2.6.h>
507                 #endif
508                 #include <rdma/ib_verbs.h>
509         ],[
510                 ib_post_send(NULL, (const struct ib_send_wr *)NULL,
511                              (const struct ib_send_wr **)NULL);
512         ],[
513                 AC_DEFINE(HAVE_IB_POST_SEND_RECV_CONST, 1,
514                         [ib_post_send and ib_post_recv have const parameters])
515         ])
516         EXTRA_KCFLAGS="$tmp_flags"
517
518         # 5.0
519         LN_IB_DEVICE_OPS_EXISTS
520         # 5.1
521         LN_IB_SG_DMA_ADDRESS_EXISTS
522
523         EXTRA_CHECK_INCLUDE=""
524 ]) # ENABLEO2IB != "no"
525 ]) # LN_CONFIG_O2IB
526
527 #
528 # LN_CONFIG_GNILND
529 #
530 # check whether to use the Gemini Network Interface lnd
531 #
532 AC_DEFUN([LN_CONFIG_GNILND], [
533 AC_MSG_CHECKING([whether to enable GNI lnd])
534 AC_ARG_ENABLE([gni],
535         AC_HELP_STRING([--enable-gni],
536                 [enable GNI lnd]),
537         [], [enable_gni="no"])
538 AC_MSG_RESULT([$enable_gni])
539
540 AS_IF([test "x$enable_gni" = xyes], [
541         # GNICPPFLAGS was set in spec file
542         EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
543         EXTRA_KCFLAGS="$EXTRA_KCFLAGS $GNICPPFLAGS"
544         LB_CHECK_COMPILE([if GNI kernel headers are present],
545         GNI_header, [
546                 #include <linux/types.h>
547                 #include <gni_pub.h>
548         ],[
549                 gni_cdm_handle_t kgni_domain;
550                 gni_return_t     rc;
551                 int              rrc;
552                 rc = gni_cdm_create(0, 1, 1, 0, &kgni_domain);
553                 rrc = (rc == GNI_RC_SUCCESS) ? 0 : 1;
554                 return rrc;
555         ],[
556                 GNILND="gnilnd"
557         ],[
558                 AC_MSG_ERROR([can't compile gnilnd with given GNICPPFLAGS: $GNICPPFLAGS])
559         ])
560         # at this point, we have gnilnd basic support,
561         # now check for extra features
562         LB_CHECK_COMPILE([to use RCA in gnilnd],
563         RCA_gnilnd, [
564                 #include <linux/types.h>
565                 #include <gni_pub.h>
566                 #include <krca_lib.h>
567         ],[
568                 gni_cdm_handle_t kgni_domain;
569                 gni_return_t     rc;
570                 krca_ticket_t    ticket = KRCA_NULL_TICKET;
571                 int              rrc;
572                 __u32            nid = 0, nic_addr;
573                 rc = gni_cdm_create(0, 1, 1, 0, &kgni_domain);
574                 rrc = (rc == GNI_RC_SUCCESS) ? 0 : 1;
575                 rrc += krca_nid_to_nicaddrs(nid, 1, &nic_addr);
576                 rrc += krca_register(&ticket, RCA_MAKE_SERVICE_INDEX(RCA_IO_CLASS, 9), 99, 0);
577                 return rrc;
578         ],[
579                 GNICPPFLAGS="$GNICPPFLAGS -DGNILND_USE_RCA=1"
580         ])
581         EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
582 ])
583 AC_SUBST(GNICPPFLAGS)
584 AC_SUBST(GNILND)
585 ]) # LN_CONFIG_GNILND
586
587 # LN_CONFIG_SOCK_CREATE_KERN
588 #
589 # 4.x sock_create_kern() added a first parameter as 'struct net *'
590 # instead of int.
591 #
592 AC_DEFUN([LN_CONFIG_SOCK_CREATE_KERN], [
593 tmp_flags="$EXTRA_KCFLAGS"
594 EXTRA_KCFLAGS="-Werror"
595 LB_CHECK_COMPILE([if 'sock_create_kern' first parameter is net],
596 sock_create_kern_net, [
597         #include <linux/net.h>
598         #include <net/net_namespace.h>
599 ],[
600         sock_create_kern((struct net*)0, 0, 0, 0, NULL);
601 ],[
602         AC_DEFINE(HAVE_SOCK_CREATE_KERN_USE_NET, 1,
603                 [sock_create_kern use net as first parameter])
604 ])
605 EXTRA_KCFLAGS="$tmp_flags"
606 ]) # LN_CONFIG_SOCK_CREATE_KERN
607
608 #
609 # LN_CONFIG_SK_DATA_READY
610 #
611 # 3.15 for struct sock the *sk_data_ready() field only takes one argument now
612 #
613 AC_DEFUN([LN_CONFIG_SK_DATA_READY], [
614 tmp_flags="$EXTRA_KCFLAGS"
615 EXTRA_KCFLAGS="-Werror"
616 LB_CHECK_COMPILE([if 'sk_data_ready' takes only one argument],
617 sk_data_ready, [
618         #include <linux/net.h>
619         #include <net/sock.h>
620 ],[
621         ((struct sock *)0)->sk_data_ready(NULL);
622 ],[
623         AC_DEFINE(HAVE_SK_DATA_READY_ONE_ARG, 1,
624                 [sk_data_ready uses only one argument])
625 ])
626 EXTRA_KCFLAGS="$tmp_flags"
627 ]) # LN_CONFIG_SK_DATA_READY
628
629 #
630 # LN_EXPORT_KMAP_TO_PAGE
631 #
632 # 3.10 Export kmap_to_page
633 #
634 AC_DEFUN([LN_EXPORT_KMAP_TO_PAGE], [
635 LB_CHECK_EXPORT([kmap_to_page], [mm/highmem.c],
636         [AC_DEFINE(HAVE_KMAP_TO_PAGE, 1,
637                 [kmap_to_page is exported by the kernel])])
638 ]) # LN_EXPORT_KMAP_TO_PAG
639
640 #
641 # LN_HAVE_ORACLE_OFED_EXTENSIONS
642 #
643 # Oracle UEK 5
644 #
645 AC_DEFUN([LN_HAVE_ORACLE_OFED_EXTENSIONS], [
646 LB_CHECK_COMPILE([if Oracle OFED Extensions are enabled],
647 oracle_ofed_ext, [
648         #include <rdma/ib_fmr_pool.h>
649 ],[
650         struct ib_fmr_pool_param param = {
651                 .relaxed           = 0
652         };
653         (void)param;
654 ],[
655         AC_DEFINE(HAVE_ORACLE_OFED_EXTENSIONS, 1,
656                 [if Oracle OFED Extensions are enabled])
657 ])
658 ]) # LN_HAVE_ORACLE_OFED_EXTENSIONS
659
660 #
661 # LN_CONFIG_SOCK_GETNAME
662 #
663 # 4.17 commit 9b2c45d479d0fb8647c9e83359df69162b5fbe5f getname()
664 # does not take the length *int argument and returns the length
665 #
666 AC_DEFUN([LN_CONFIG_SOCK_GETNAME], [
667 tmp_flags="$EXTRA_KCFLAGS"
668 EXTRA_KCFLAGS="-Werror"
669 LB_CHECK_COMPILE([if 'getname' has two args],
670 kern_sock_getname_2args, [
671         #include <linux/net.h>
672 ],[
673         kernel_getsockname(NULL, NULL);
674 ],[
675         AC_DEFINE(HAVE_KERN_SOCK_GETNAME_2ARGS, 1,
676                 ['getname' has two args])
677 ])
678 EXTRA_KCFLAGS="$tmp_flags"
679 ]) # LN_CONFIG_SOCK_GETNAME
680
681 #
682 # LN_IB_DEVICE_OPS_EXISTS
683 #
684 # kernel 5.0 commit 521ed0d92ab0db3edd17a5f4716b7f698f4fce61
685 # RDMA/core: Introduce ib_device_ops
686 # ... introduces the ib_device_ops structure that defines all the
687 # InfiniBand device operations in one place ...
688 #
689 AC_DEFUN([LN_IB_DEVICE_OPS_EXISTS], [
690 tmp_flags="$EXTRA_KCFLAGS"
691 EXTRA_KCFLAGS="-Werror"
692 LB_CHECK_COMPILE([if struct ib_device_ops is defined],
693 ib_device_ops_test, [
694         #include <rdma/ib_verbs.h>
695 ],[
696         int x = offsetof(struct ib_device_ops, unmap_fmr);
697         x = x;
698         (void)x;
699 ],[
700         AC_DEFINE(HAVE_IB_DEVICE_OPS, 1,
701                 [if struct ib_device_ops is defined])
702 ])
703 EXTRA_KCFLAGS="$tmp_flags"
704 ]) # LN_IB_DEVICE_OPS_EXISTS
705
706 #
707 # LN_IB_SG_DMA_ADDRESS_EXISTS
708 #
709 # kernel 5.1 commit a163afc88556e099271a7b423295bc5176fcecce
710 # IB/core: Remove ib_sg_dma_address() and ib_sg_dma_len()
711 # ... when dma_ops existed (3.6) ib_sg_dma_address() was not trivial ...
712 #
713 AC_DEFUN([LN_IB_SG_DMA_ADDRESS_EXISTS], [
714 tmp_flags="$EXTRA_KCFLAGS"
715 EXTRA_KCFLAGS="-Werror"
716 LB_CHECK_COMPILE([if ib_sg_dma_address wrapper exists],
717 ib_sg_dma_address_test, [
718         #include <rdma/ib_verbs.h>
719 ],[
720         u64 x = ib_sg_dma_address(NULL, NULL);
721         x = x;
722         (void)x;
723 ],[
724         AC_DEFINE(HAVE_IB_SG_DMA_ADDRESS, 1,
725                 [if ib_sg_dma_address wrapper exists])
726 ])
727 EXTRA_KCFLAGS="$tmp_flags"
728 ]) # LN_IB_SG_DMA_ADDRESS_EXISTS
729
730 #
731 # LN_PROG_LINUX
732 #
733 # LNet linux kernel checks
734 #
735 AC_DEFUN([LN_PROG_LINUX], [
736 AC_MSG_NOTICE([LNet kernel checks
737 ==============================================================================])
738
739 LN_CONFIG_BACKOFF
740 LN_CONFIG_O2IB
741 LN_CONFIG_GNILND
742 # 3.10
743 LN_EXPORT_KMAP_TO_PAGE
744 # 3.15
745 LN_CONFIG_SK_DATA_READY
746 # 4.x
747 LN_CONFIG_SOCK_CREATE_KERN
748 # 4.14
749 LN_HAVE_ORACLE_OFED_EXTENSIONS
750 # 4.17
751 LN_CONFIG_SOCK_GETNAME
752 ]) # LN_PROG_LINUX
753
754 #
755 # LN_PATH_DEFAULTS
756 #
757 # default paths for installed files
758 #
759 AC_DEFUN([LN_PATH_DEFAULTS], [
760 ]) # LN_PATH_DEFAULTS
761
762 #
763 # LN_CONFIGURE
764 #
765 # other configure checks
766 #
767 AC_DEFUN([LN_CONFIGURE], [
768 AC_MSG_NOTICE([LNet core checks
769 ==============================================================================])
770
771 # lnet/utils/portals.c
772 AC_CHECK_HEADERS([netdb.h])
773 AC_CHECK_FUNCS([gethostbyname])
774
775 # lnet/utils/wirecheck.c
776 AC_CHECK_FUNCS([strnlen])
777
778 # --------  Check for required packages  --------------
779
780 AC_MSG_CHECKING([whether to enable 'efence' debugging support])
781 AC_ARG_ENABLE(efence,
782         AC_HELP_STRING([--enable-efence],
783                 [use efence library]),
784         [], [enable_efence="no"])
785 AC_MSG_RESULT([$enable_efence])
786
787 LIBEFENCE=""
788 AS_IF([test "$enable_efence" = yes], [
789         LIBEFENCE="-lefence"
790         AC_DEFINE(HAVE_LIBEFENCE, 1,
791                 [libefence support is requested])
792 ])
793 AC_SUBST(LIBEFENCE)
794
795 LN_CONFIG_DLC
796 ]) # LN_CONFIGURE
797
798 #
799 # LN_CONDITIONALS
800 #
801 # AM_CONDITIONAL defines for lnet
802 #
803 AC_DEFUN([LN_CONDITIONALS], [
804 AM_CONDITIONAL(BUILD_O2IBLND,    test x$O2IBLND = "xo2iblnd")
805 AM_CONDITIONAL(BUILD_GNILND,     test x$GNILND  = "xgnilnd")
806 ]) # LN_CONDITIONALS
807
808 #
809 # LN_CONFIG_FILES
810 #
811 # files that should be generated with AC_OUTPUT
812 #
813 AC_DEFUN([LN_CONFIG_FILES], [
814 AC_CONFIG_FILES([
815 lnet/Makefile
816 lnet/autoMakefile
817 lnet/autoconf/Makefile
818 lnet/doc/Makefile
819 lnet/include/Makefile
820 lnet/include/lnet/Makefile
821 lnet/include/uapi/linux/lnet/Makefile
822 lnet/klnds/Makefile
823 lnet/klnds/autoMakefile
824 lnet/klnds/o2iblnd/Makefile
825 lnet/klnds/o2iblnd/autoMakefile
826 lnet/klnds/gnilnd/Makefile
827 lnet/klnds/gnilnd/autoMakefile
828 lnet/klnds/socklnd/Makefile
829 lnet/klnds/socklnd/autoMakefile
830 lnet/lnet/Makefile
831 lnet/lnet/autoMakefile
832 lnet/selftest/Makefile
833 lnet/selftest/autoMakefile
834 lnet/utils/Makefile
835 lnet/utils/lnetconfig/Makefile
836 ])
837 ]) # LN_CONFIG_FILES