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