checkout_files: Added drivers/net/ethernet/hisilicon/Kconfig
[compat-rdma/compat-rdma.git] / configure
1 #!/bin/bash
2 #
3 # Copyright (c) 2006 Mellanox Technologies. All rights reserved.
4 #
5 # This Software is licensed under one of the following licenses:
6 #
7 # 1) under the terms of the "Common Public License 1.0" a copy of which is
8 #    available from the Open Source Initiative, see
9 #    http://www.opensource.org/licenses/cpl.php.
10 #
11 # 2) under the terms of the "The BSD License" a copy of which is
12 #    available from the Open Source Initiative, see
13 #    http://www.opensource.org/licenses/bsd-license.php.
14 #
15 # 3) under the terms of the "GNU General Public License (GPL) Version 2" a
16 #    copy of which is available from the Open Source Initiative, see
17 #    http://www.opensource.org/licenses/gpl-license.php.
18 #
19 # Licensee has the right to choose one of the above licenses.
20 #
21 # Redistributions of source code must retain the above copyright
22 # notice and one of the license notices.
23 #
24 # Redistributions in binary form must reproduce both the above copyright
25 # notice, one of the license notices in the documentation
26 # and/or other materials provided with the distribution.
27 #
28 #  $Id: configure 9097 2006-08-24 06:39:09Z vlad $
29 #
30
31 usage()
32 {
33         cat << EOF
34         \`configure' configures variables for kernel modules compilation
35
36         Usage:  `basename $0` [options]
37
38         --prefix=PREFIX  for userspace components []
39         --build_root=BUILD_ROOT  root directory to build RPM packages
40         --kernel-version=VERSION  make for this kernel [$(uname -r)]
41         --modules-dir=DIR  modules directory [/lib/modules/$(uname -r)]
42         --kernel-sources=DIR  make for this kernel [/lib/modules/$(uname -r)/source]
43         --with-linux=DIR  kernel sources directory [/lib/modules/$(uname -r)/source]
44         --with-linux-obj=DIR  kernel obj directory [/lib/modules/$(uname -r)/build]
45         --skip-autoconf
46
47         Kernel modules configuration:
48
49         --with-core-mod    make CONFIG_INFINIBAND=m [no]
50         --without-core-mod   [yes]
51
52         --with-ipoib-mod    make CONFIG_INFINIBAND_IPOIB=m [no]
53         --without-ipoib-mod   [yes]
54
55         --with-ipoib-cm    make CONFIG_INFINIBAND_IPOIB_CM=y [yes]
56         --without-ipoib-cm   [no]
57
58         --with-ipoib_debug-mod    make CONFIG_INFINIBAND_IPOIB_DEBUG=y [yes]
59         --without-ipoib_debug-mod    [no]
60
61         --with-ipoib_debug_data-mod    make CONFIG_INFINIBAND_IPOIB_DEBUG_DATA=y [no]
62         --without-ipoib_debug_data-mod    [yes]
63
64         --with-srp-mod    make CONFIG_INFINIBAND_SRP=m [no]
65         --without-srp-mod    [yes]
66
67         --with-srp-target-mod    make CONFIG_INFINIBAND_SRPT=m [no]
68         --without-srp-target-mod    [yes]
69
70         --with-user_mad-mod    make CONFIG_INFINIBAND_USER_MAD=m [no]
71         --without-user_mad-mod    [yes]
72
73         --with-user_access-mod    make CONFIG_INFINIBAND_USER_ACCESS=m [no]
74         --without-user_access-mod    [yes]
75
76         --with-addr_trans-mod    make CONFIG_INFINIBAND_ADDR_TRANS=y [no]
77         --without-addr_trans-mod    [yes]
78
79         --with-mthca-mod    make CONFIG_INFINIBAND_MTHCA=m [no]
80         --without-mthca-mod    [yes]
81
82         --with-mthca_debug-mod    make CONFIG_INFINIBAND_MTHCA_DEBUG=y [yes]
83         --without-mthca_debug-mod    [no]
84
85         --with-mlx4-mod         make CONFIG_MLX4_CORE=y CONFIG_MLX4_INFINIBAND=y [no]
86         --without-mlx4-mod      [yes]
87
88         --with-mlx5-mod         make CONFIG_MLX5_CORE=y CONFIG_MLX5_INFINIBAND=y [no]
89         --without-mlx5-mod      [yes]
90
91         --with-mlx4_core-mod         make CONFIG_MLX4_CORE=y [no]
92         --without-mlx4_core-mod      [yes]
93
94         --with-mlx5_core-mod         make CONFIG_MLX5_CORE=y [no]
95         --without-mlx5_core-mod      [yes]
96
97         --with-mlx4_en-mod         make CONFIG_MLX4_EN=y [no]
98         --without-mlx4_en-mod      [yes]
99
100         --with-mlx4_inf-mod         make CONFIG_MLX4_INFINIBAND=y [no]
101         --without-mlx4_inf-mod      [yes]
102
103         --with-mlx5_inf-mod         make CONFIG_MLX5_INFINIBAND=y [no]
104         --without-mlx5_inf-mod      [yes]
105
106         --with-mlx4_debug-mod         make CONFIG_MLX4_DEBUG=y [yes]
107         --without-mlx4_debug-mod      [no]
108
109         --with-mlx5_debug-mod         make CONFIG_MLX5_DEBUG=y [yes]
110         --without-mlx5_debug-mod      [no]
111
112         --with-ibscif-mod    make CONFIG_INFINIBAND_SCIF=m [no]
113         --without-ibscif-mod    [yes]
114
115         --with-ibp-server-mod    make CONFIG_IBP_SERVER=m [no]
116         --without-ibp-server-mod    [yes]
117
118         --with-ibp-debug-mod    make CONFIG_IBP_DEBUG=y [no]
119         --without-ibp-debug-mod    [yes]
120
121         --with-ipath_inf-mod    make CONFIG_INFINIBAND_IPATH=m [no]
122         --without-ipath_inf-mod    [yes]
123
124         --with-qib-mod    make CONFIG_INFINIBAND_QIB=m [no]
125         --without-qib-mod    [yes]
126
127         --with-rxe-mod    make CONFIG_RDMA_RXE=m [no]
128         --without-rxe-mod    [yes]
129
130         --with-rdmavt-mod    make CONFIG_INFINIBAND_RDMAVT=m [no]
131         --without-rdmavt-mod    [yes]
132
133         --with-iser-mod    make CONFIG_INFINIBAND_ISER=m [no]
134         --without-iser-mod    [yes]
135
136         --with-isert-mod    make CONFIG_INFINIBAND_ISERT=m [no]
137         --without-isert-mod    [yes]
138
139         --with-ehca-mod    make CONFIG_INFINIBAND_EHCA=m [no]
140         --without-ehca-mod    [yes]
141
142         --with-rds-mod    make CONFIG_RDS=m [no]
143         --without-rds-mod   [no]
144
145         --with-rds_debug-mod    make CONFIG_RDS_DEBUG=y [no]
146         --without-rds_debug-mod    [yes]
147
148         --with-madeye-mod   make CONFIG_INFINIBAND_MADEYE=m [no]
149         --without-madeye-mod    [yes]
150
151         --with-qlgc_vnic-mod    make CONFIG_INFINIBAND_QLGC_VNIC=m [no]
152         --without-qlgc_vnic-mod    [yes]
153
154         --with-qlgc_vnic_stats-mod    make CONFIG_INFINIBAND_QLGC_VNIC_STATS=y [no]
155         --without-qlgc_vnic_stats-mod    [yes]
156
157         --with-cxgb3-mod    make CONFIG_INFINIBAND_CXGB3=m [no]
158         --without-cxgb3-mod    [yes]
159
160         --with-cxgb3_debug-mod    make CONFIG_INFINIBAND_CXGB3_DEBUG=y [no]
161         --without-cxgb3_debug-mod    [yes]
162
163         --with-cxgb4-mod    make CONFIG_INFINIBAND_CXGB4=m [no]
164         --without-cxgb4-mod    [yes]
165
166         --with-i40iw-mod    make CONFIG_INFINIBAND_I40IW=m [no]
167         --without-i40iw-mod    [yes]
168
169         --with-nes-mod    make CONFIG_INFINIBAND_NES=m [no]
170         --without-nes-mod    [yes]
171
172         --with-ocrdma-mod    make CONFIG_INFINIBAND_OCRDMA=m [no]
173         --without-ocrdma-mod    [yes]
174
175         --with-be2net-mod    make CONFIG_BE2NET=m [no]
176         --without-be2net-mod    [yes]
177
178         --with-bnxt_en-mod    make CONFIG_BNXT=m [no]
179         --without-bnxt_en-mod    [yes]
180
181         --with-bnxt_re-mod    make CONFIG_INFINIBAND_BNXT_RE=m [no]
182         --without-bnxt_re-mod    [yes]
183
184         --with-nes_debug-mod    make CONFIG_INFINIBAND_NES_DEBUG=y [no]
185         --without-nes_debug-mod    [yes]
186
187         --with-memtrack  enable momory tracking [no]
188         --without-memtrack disable memory tracking [yes]
189
190         --with-debug-info  make CONFIG_DEBUG_INFO=y [yes]
191         --without-debug-info [no]
192
193         --with-nfsrdma-mod    make CONFIG_SUNRPC_XPRT_RDMA=m [no]
194         --without-nfsrdma-mod    [yes]
195
196         --with-vmw_pvrdma-mod    make CONFIG_INFINIBAND_VMWARE_PVRDMA=m [no]
197         --without-vmw_pvrdma-mod    [yes]
198
199         --with-qedr-mod    make CONFIG_INFINIBAND_QEDR [no]
200         --without-qedr-mod    [yes]
201
202         --with-nvme_host-mod
203         --without-nvme_host-mod
204         --with-nvme_host-without-fc
205         --without-nvme_host-without-fc
206         --with-nvme_target-mod
207         --without-nvme_target-mod
208
209         --help - print out options
210
211
212 EOF
213
214 }
215
216 # Execute command w/ echo and exit if it fail
217 ex()
218 {
219         echo "$@"
220         if ! "$@"; then
221                 printf "\nFailed executing $@\n\n"
222                 exit 1
223         fi
224 }
225
226 # Compare 2 kernel versions
227 check_kerver()
228 {
229         local kver=$1
230         local min_kver=$2
231         shift 2
232
233         kver_a=$(echo -n ${kver} | cut -d '.' -f 1)
234         kver_b=$(echo -n ${kver} | cut -d '.' -f 2)
235         kver_c=$(echo -n ${kver} | cut -d '.' -f 3 | cut -d '-' -f 1 | tr -d [:alpha:][:punct:])
236
237         min_kver_a=$(echo -n ${min_kver} | cut -d '.' -f 1)
238         min_kver_b=$(echo -n ${min_kver} | cut -d '.' -f 2)
239         min_kver_c=$(echo -n ${min_kver} | cut -d '.' -f 3 | cut -d '-' -f 1 | tr -d [:alpha:][:punct:])
240
241         if [ ${kver_a} -lt ${min_kver_a} ] ||
242                 [[ ${kver_a} -eq ${min_kver_a} && ${kver_b} -lt ${min_kver_b} ]] ||
243                 [[ ${kver_a} -eq ${min_kver_a} && ${kver_b} -eq ${min_kver_b} && ${kver_c} -lt ${min_kver_c} ]]; then
244         return 1
245 fi
246
247 return 0
248 }
249
250 function check_autofconf {
251 VAR=$1
252 VALUE=$(tac ${KSRC_OBJ}/include/*/autoconf.h | grep -m1 ${VAR} | sed -ne 's/.*\([01]\)$/\1/gp')
253
254 eval "export $VAR=$VALUE"
255 }
256
257 function add_conf {
258 COMMENT=$1
259 PARAM=${2%=*}
260 VALUE=${2#*=}
261 OICONF=${PWD}/ofed_scripts/openib.conf.tmp
262
263 touch $OICONF
264 if ! (grep -wq "^$PARAM" $OICONF > /dev/null 2>&1); then
265         echo >> "${OICONF}"
266         echo "${COMMENT}" >> "${OICONF}"
267         echo "${PARAM}=${VALUE}" >> "${OICONF}"
268 fi
269 }
270
271 main()
272 {
273         ofed_patch_params=
274         # Parsing parameters
275         while [ ! -z "$1" ]
276         do
277                 case $1 in
278                         -prefix | --prefix | --prefi | --pref | --pre | --pr | --p | -p)
279                                 shift
280                                 prefix=$1
281                                 PREFIX="--prefix ${prefix}"
282                                 ;;
283                         -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=* | -p=*)
284                                 prefix=`expr "x$1" : 'x[^=]*=\(.*\)'`
285                                 PREFIX="--prefix ${prefix}"
286                                 ;;
287                         -kernel-version | --kernel-version | --kern-ver | --ker-ver)
288                                 ofed_patch_params="$ofed_patch_params $1"
289                                 shift
290                                 ofed_patch_params="$ofed_patch_params $1"
291                                 KVERSION=$1
292                                 ;;
293                         -kernel-version=* | --kernel-version=* | --kern-ver=* | --ker-ver=*)
294                                 ofed_patch_params="$ofed_patch_params $1"
295                                 KVERSION=`expr "x$1" : 'x[^=]*=\(.*\)'`
296                                 ;;
297                         -modules-dir | --modules-dir | --mod-dir)
298                                 shift
299                                 MODULES_DIR=$1
300                                 ;;
301                         -modules-dir=* | --modules-dir=* | --mod-dir=*)
302                                 MODULES_DIR=`expr "x$1" : 'x[^=]*=\(.*\)'`
303                                 ;;
304                         --skip-autoconf)
305                                 SKIP_AUTOCONF=1
306                                 ;;
307                         --force-autogen)
308                                 FORCE_AUTOGEN=1
309                                 ;;
310                         -kernel-sources | --kernel-sources | --kernel-src | --kern-src | --ker-src)
311                                 shift
312                                 KSRC=$1
313                                 ;;
314                         -kernel-sources=* | --kernel-sources=* | --kernel-src=* | --kern-src=* | --ker-src=*)
315                                 KSRC=`expr "x$1" : 'x[^=]*=\(.*\)'`
316                                 ;;
317                         --with-linux)
318                                 shift
319                                 KSRC=$1
320                                 ;;
321                         --with-linux=*)
322                                 KSRC=`expr "x$1" : 'x[^=]*=\(.*\)'`
323                                 ;;
324                         --with-linux-obj)
325                                 shift
326                                 KSRC_OBJ=$1
327                                 ;;
328                         --with-linux-obj=*)
329                                 KSRC_OBJ=`expr "x$1" : 'x[^=]*=\(.*\)'`
330                                 ;;
331                         -with-quilt | --with-quilt)
332                                 ofed_patch_params="$ofed_patch_params $1"
333                                 if [ ! -z "$2" ] && [ "`echo -n $2 | cut -c 1`" != '-' ]; then
334                                         shift
335                                         ofed_patch_params="$ofed_patch_params $1"
336                                 fi
337                                 ;;
338                         -with-quilt=* | --with-quilt=*)
339                                 ofed_patch_params="$ofed_patch_params $1"
340                                 ;;
341                         --without-quilt)
342                                 ofed_patch_params="$ofed_patch_params $1"
343                                 ;;
344                         -with-patchdir | --with-patchdir)
345                                 ofed_patch_params="$ofed_patch_params $1"
346                                 shift
347                                 ofed_patch_params="$ofed_patch_params $1"
348                                 ;;
349                         -with-patchdir=* | --with-patchdir=*)
350                                 ofed_patch_params="$ofed_patch_params $1"
351                                 ;;
352                         --without-patch)
353                                 ofed_patch_params="$ofed_patch_params $1"
354                                 ;;
355                         --with-kernel-fixes)
356                                 ofed_patch_params="$ofed_patch_params $1"
357                                 ;;
358                         --without-kernel-fixes)
359                                 ofed_patch_params="$ofed_patch_params $1"
360                                 ;;
361                         --with-hpage-patch)
362                                 ofed_patch_params="$ofed_patch_params $1"
363                                 ;;
364                         --without-hpage-patch)
365                                 ofed_patch_params="$ofed_patch_params $1"
366                                 ;;
367                         --with-backport-patches)
368                                 ofed_patch_params="$ofed_patch_params $1"
369                                 ;;
370                         --without-backport-patches)
371                                 ofed_patch_params="$ofed_patch_params $1"
372                                 ;;
373                         --with-memtrack)
374                                 CONFIG_MEMTRACK="m"
375                                 ;;
376                         --without-memtrack)
377                                 CONFIG_MEMTRACK=
378                                 ;;
379                         --with-debug-info)
380                                 CONFIG_DEBUG_INFO="y"
381                                 ;;
382                         --without-debug-info)
383                                 CONFIG_DEBUG_INFO=
384                                 ;;
385                         --with-core-mod)
386                                 CONFIG_INFINIBAND="m"
387                                 ;;
388                         --without-core-mod)
389                                 CONFIG_INFINIBAND=
390                                 ;;
391                         --with-ipoib-mod)
392                                 CONFIG_INFINIBAND_IPOIB="m"
393                                 CONFIG_INFINIBAND_IPOIB_CM="y"
394                                 CONFIG_INFINIBAND_IPOIB_DEBUG="y"
395                                 add_conf "# Load IPoIB" "IPOIB_LOAD=yes"
396                                 add_conf "# Enable IPoIB Connected Mode" "SET_IPOIB_CM=yes"
397                                 ;;
398                         --without-ipoib-mod)
399                                 CONFIG_INFINIBAND_IPOIB=
400                                 ;;
401                         --with-ipoib-cm)
402                                 CONFIG_INFINIBAND_IPOIB_CM="y"
403                                 ;;
404                         --without-ipoib-cm)
405                                 CONFIG_INFINIBAND_IPOIB_CM=
406                                 ;;
407                         --with-ipoib_debug-mod)
408                                 CONFIG_INFINIBAND_IPOIB_DEBUG="y"
409                                 ;;
410                         --without-ipoib_debug-mod)
411                                 CONFIG_INFINIBAND_IPOIB_DEBUG=
412                                 ;;
413                         --with-ipoib_debug_data-mod)
414                                 CONFIG_INFINIBAND_IPOIB_DEBUG_DATA="y"
415                                 ;;
416                         --without-ipoib_debug_data-mod)
417                                 CONFIG_INFINIBAND_IPOIB_DEBUG_DATA=
418                                 ;;
419                         --with-srp-mod)
420                                 CONFIG_INFINIBAND_SRP="m"
421                                 CONFIG_SCSI_SRP_ATTRS="m"
422                                 add_conf "# Load SRP module" "SRP_LOAD=no"
423                                 ;;
424                         --without-srp-mod)
425                                 CONFIG_INFINIBAND_SRP=
426                                 CONFIG_SCSI_SRP_ATTRS=
427                                 ;;
428                         --with-srp-target-mod)
429                                 CONFIG_INFINIBAND_SRPT="m"
430                                 add_conf "# Load SRP Target module" "SRPT_LOAD=no"
431                                 ;;
432                         --without-srp-target-mod)
433                                 CONFIG_INFINIBAND_SRPT=
434                                 ;;
435                         --with-user_mad-mod)
436                                 CONFIG_INFINIBAND_USER_MAD="m"
437                                 add_conf "# Load UMAD module" "UMAD_LOAD=yes"
438                                 ;;
439                         --without-user_mad-mod)
440                                 CONFIG_INFINIBAND_USER_MAD=
441                                 ;;
442                         --with-user_access-mod)
443                                 CONFIG_INFINIBAND_USER_ACCESS="m"
444                                 CONFIG_INFINIBAND_USER_MEM=y
445                                 add_conf "# Load UVERBS module" "UVERBS_LOAD=yes"
446                                 add_conf "# Load UCM module" "UCM_LOAD=yes"
447                                 ;;
448                         --without-user_access-mod)
449                                 CONFIG_INFINIBAND_USER_ACCESS=
450                                 CONFIG_INFINIBAND_USER_MEM=
451                                 ;;
452                         --with-user_memory-mod)
453                                 CONFIG_INFINIBAND_USER_MEM=y
454                                 ;;
455                         --without-user_memory-mod)
456                                 CONFIG_INFINIBAND_USER_MEM=
457                                 ;;
458                         --with-addr_trans-mod)
459                                 CONFIG_INFINIBAND_ADDR_TRANS=y
460                                 add_conf "# Load RDMA_CM module" "RDMA_CM_LOAD=yes"
461                                 add_conf "# Load RDMA_UCM module" "RDMA_UCM_LOAD=yes"
462                                 ;;
463                         --without-addr_trans-mod)
464                                 CONFIG_INFINIBAND_ADDR_TRANS=
465                                 ;;
466                         --with-mthca-mod)
467                                 CONFIG_INFINIBAND_MTHCA="m"
468                                 CONFIG_INFINIBAND_MTHCA_DEBUG="y"
469                                 add_conf "# Load MTHCA" "MTHCA_LOAD=no"
470                                 ;;
471                         --without-mthca-mod)
472                                 CONFIG_INFINIBAND_MTHCA=
473                                 ;;
474                         --with-mthca_debug-mod)
475                                 CONFIG_INFINIBAND_MTHCA_DEBUG="y"
476                                 ;;
477                         --without-mthca_debug-mod)
478                                 CONFIG_INFINIBAND_MTHCA_DEBUG=
479                                 ;;
480                         --with-mlx4-mod)
481                                 CONFIG_MLX4_CORE="m"
482                                 CONFIG_MLX4_INFINIBAND="m"
483                                 CONFIG_MLX4_DEBUG="y"
484                                 add_conf "# Load MLX4 modules" "MLX4_LOAD=yes"
485                                 ;;
486                         --with-mlx5-mod)
487                                 CONFIG_MLX5_CORE="m"
488                                 CONFIG_MLX5_CORE_EN="y"
489                                 CONFIG_MLX5_CORE_EN_DCB="y"
490                                 CONFIG_MLX5_INFINIBAND="m"
491                                 CONFIG_BACKPORT_LRO="m"
492                                 CONFIG_MLX5_DEBUG="y"
493                                 CONFIG_MLX5_ESWITCH="y"
494                                 CONFIG_MLXFW="m"
495                                 add_conf "# Load MLX5 modules" "MLX5_LOAD=yes"
496                                 ;;
497                                 --with-mlxfw-mod)
498                                         CONFIG_MLXFW="m"
499                                 ;;
500                                 --without-mlxfw-mod)
501                                         CONFIG_MLXFW=
502                                 ;;
503                         --with-mlx4_core-mod)
504                                 CONFIG_MLX4_CORE="m"
505                                 ;;
506                         --without-mlx4_core-mod)
507                                 CONFIG_MLX4_CORE=
508                                 ;;
509                         --with-mlx5_core-mod)
510                                 CONFIG_MLX5_CORE="m"
511                                 CONFIG_MLX5_CORE_EN="y"
512                                 CONFIG_MLX5_CORE_EN_DCB="y"
513                                 CONFIG_MLX5_ESWITCH="y"
514                                 ;;
515                         --without-mlx5_core-mod)
516                                 CONFIG_MLX5_CORE=
517                                 CONFIG_MLX5_CORE_EN=
518                                 CONFIG_MLX5_CORE_EN_DCB=
519                                 CONFIG_MLX5_ESWITCH=
520                                 ;;
521                         --without-mlx4-mod)
522                                 CONFIG_MLX4_CORE=
523                                 CONFIG_MLX4_INFINIBAND=
524                                 CONFIG_MLX4_DEBUG=
525                                 ;;
526                         --without-mlx5-mod)
527                                 CONFIG_MLX5_CORE=
528                                 CONFIG_MLX5_CORE_EN=
529                                 CONFIG_MLX5_CORE_EN_DCB=
530                                 CONFIG_MLX5_INFINIBAND=
531                                 CONFIG_MLX5_DEBUG=
532                                 CONFIG_MLX5_ESWITCH=
533                                 ;;
534                         --with-mlx4_en-mod)
535                                 CONFIG_MLX4_CORE="m"
536                                 CONFIG_MLX4_EN="m"
537                                 add_conf "# Load MLX4_EN module" "MLX4_EN_LOAD=yes"
538                                 ;;
539                         --without-mlx4_en-mod)
540                                 CONFIG_MLX4_EN=
541                                 ;;
542                         --with-mlx4_inf-mod)
543                                 CONFIG_MLX4_CORE="m"
544                                 CONFIG_MLX4_INFINIBAND="m"
545                                 ;;
546                         --without-mlx4_inf-mod)
547                                 CONFIG_MLX4_INFINIBAND=
548                                 ;;
549                         --with-mlx5_inf-mod)
550                                 CONFIG_MLX5_CORE="m"
551                                 CONFIG_MLX5_CORE_EN="y"
552                                 CONFIG_MLX5_CORE_EN_DCB="y"
553                                 CONFIG_MLX5_INFINIBAND="m"
554                                 ;;
555                         --without-mlx5_inf-mod)
556                                 CONFIG_MLX5_INFINIBAND=
557                                 CONFIG_MLX5_CORE_EN=
558                                 CONFIG_MLX5_CORE_EN_DCB=
559                                 ;;
560                         --with-mlx4_debug-mod)
561                                 CONFIG_MLX4_DEBUG="y"
562                                 ;;
563                         --without-mlx4_debug-mod)
564                                 CONFIG_MLX4_DEBUG=
565                                 ;;
566                         --with-mlx5_debug-mod)
567                                 CONFIG_MLX5_DEBUG="y"
568                                 ;;
569                         --without-mlx5_debug-mod)
570                                 CONFIG_MLX5_DEBUG=
571                                 ;;
572                         --with-ibscif-mod)
573                                 CONFIG_INFINIBAND_SCIF="m"
574                                 ;;
575                         --with-ibp-server-mod)
576                                 CONFIG_IBP_SERVER="m"
577                                 ;;
578                         --with-ibp-debug-mod)
579                                 CONFIG_IBP_DEBUG="y"
580                                 ;;
581                         --with-ipath_inf-mod)
582                                 CONFIG_INFINIBAND_IPATH="m"
583                                 add_conf "# Load IPATH" "IPATH_LOAD=yes"
584                                 ;;
585                         --without-ipath_inf-mod)
586                                 CONFIG_INFINIBAND_IPATH=
587                                 ;;
588                         --with-rxe-mod)
589                                 CONFIG_RDMA_RXE="m"
590                                 ;;
591                         --without-rxe-mod)
592                                 CONFIG_RDMA_RXE=
593                                 ;;
594                         --with-rdmavt-mod)
595                                 CONFIG_INFINIBAND_RDMAVT="m"
596                                 ;;
597                         --without-rdmavt-mod)
598                                 CONFIG_INFINIBAND_RDMAVT=
599                                 ;;
600                         --with-qib-mod)
601                                 CONFIG_INFINIBAND_QIB="m"
602                                 add_conf "# Load QIB" "QIB_LOAD=yes"
603                                 add_conf "# QIB QME BP VER" "QIB_QME_BPVER=1"
604                                 ;;
605                         --without-qib-mod)
606                                 CONFIG_INFINIBAND_QIB=
607                                 ;;
608                         --with-iser-mod)
609                                 CONFIG_INFINIBAND_ISER="m"
610                                 add_conf "# Load ISER module" "ISER_LOAD=no"
611                                 ;;
612                         --with-iscsi-mod)
613                                 CONFIG_SCSI_ISCSI_ATTRS="m"
614                                 CONFIG_ISCSI_TCP="m"
615                                 ;;
616                         --without-iser-mod)
617                                 CONFIG_INFINIBAND_ISER=
618                                 CONFIG_SCSI_ISCSI_ATTRS=
619                                 CONFIG_ISCSI_TCP=
620                                 ;;
621                         --with-isert-mod)
622                                 CONFIG_INFINIBAND_ISERT="m"
623                                 ;;
624                         --without-isert-mod)
625                                 CONFIG_INFINIBAND_ISERT=
626                                 ;;
627                         --with-ehca-mod)
628                                 CONFIG_INFINIBAND_EHCA="m"
629                                 CONFIG_INFINIBAND_EHCA_SCALING="y"
630                                 add_conf "$ Load eHCA" "EHCA_LAOD=yes"
631                                 ;;
632                         --without-ehca-mod)
633                                 CONFIG_INFINIBAND_EHCA=
634                                 CONFIG_INFINIBAND_EHCA_SCALING=
635                                 ;;
636                         --with-rds-mod)
637                                 CONFIG_RDS="m"
638                                 CONFIG_RDS_RDMA="m"
639                                 CONFIG_RDS_TCP="m"
640                                 add_conf "# Load RDS module" "RDS_LOAD=no"
641                                 ;;
642                         --without-rds-mod)
643                                 CONFIG_RDS=
644                                 CONFIG_RDS_RDMA=
645                                 CONFIG_RDS_TCP=
646                                 ;;
647                         --with-rds_debug-mod)
648                                 CONFIG_RDS_DEBUG="y"
649                                 ;;
650                         --without-rds_debug-mod)
651                                 CONFIG_RDS_DEBUG=
652                                 ;;
653                         --with-madeye-mod)
654                                 CONFIG_INFINIBAND_MADEYE=m
655                                 ;;
656                         --without-madeye-mod)
657                                 CONFIG_INFINIBAND_MADEYE=
658                                 ;;
659                         --with-qlgc_vnic-mod)
660                                 CONFIG_INFINIBAND_QLGC_VNIC="m"
661                                 add_conf "# Load QLogic VNIC module" "QLGC_VNIC_LOAD=yes"
662                                 ;;
663                         --without-qlgc_vnic-mod)
664                                 CONFIG_INFINIBAND_QLGC_VNIC=
665                                 ;;
666                         --with-qlgc_vnic_stats-mod)
667                                 CONFIG_INFINIBAND_QLGC_VNIC_STATS="y"
668                                 ;;
669                         --without-qlgc_vnic_stats-mod)
670                                 CONFIG_INFINIBAND_QLGC_VNIC_STATS=
671                                 ;;
672                         --with-cxgb3-mod)
673                                 CONFIG_INFINIBAND_CXGB3="m"
674                                 CONFIG_CHELSIO_T3="m"
675                                 add_conf "# Load CXGB3 modules" "CXGB3_LOAD=yes"
676                                 ;;
677                         --without-cxgb3-mod)
678                                 CONFIG_INFINIBAND_CXGB3=
679                                 CONFIG_CHELSIO_T3=
680                                 ;;
681                         --with-cxgb3_debug-mod)
682                                 CONFIG_INFINIBAND_CXGB3_DEBUG="y"
683                                 ;;
684                         --without-cxgb3_debug-mod)
685                                 CONFIG_INFINIBAND_CXGB3_DEBUG=
686                                 ;;
687                         --with-cxgb4-mod)
688                                 CONFIG_INFINIBAND_CXGB4="m"
689                                 CONFIG_CHELSIO_T4="m"
690                                 add_conf "# Load CXGB4 modules" "CXGB4_LOAD=yes"
691                                 ;;
692                         --without-cxgb4-mod)
693                                 CONFIG_INFINIBAND_CXGB4=
694                                 CONFIG_CHELSIO_T4=
695                                 ;;
696                         --with-cxgb3i-mod)
697                                 CONFIG_SCSI_CXGB3_ISCSI="m"
698                                 ;;
699                         --without-cxgb3i-mod)
700                                 CONFIG_SCSI_CXGB3_ISCSI=
701                                 ;;
702                         --with-cxgb4i-mod)
703                                 CONFIG_SCSI_CXGB4_ISCSI="m"
704                                 ;;
705                         --without-cxgb4i-mod)
706                                 CONFIG_SCSI_CXGB4_ISCSI=
707                                 ;;
708                         --with-i40iw-mod)
709                                 CONFIG_INFINIBAND_I40IW="m"
710                                 CONFIG_I40E="m"
711                                 add_conf "# Load I40IW modules" "I40IW_LOAD=yes"
712                                 ;;
713                         --without-i40iw-mod)
714                                 CONFIG_INFINIBAND_I40IW=
715                                 CONFIG_I40E=
716                                 add_conf "# Load I40IW modules" "I40IW_LOAD=no"
717                                 ;;
718                         --with-nes-mod)
719                                 CONFIG_INFINIBAND_NES="m"
720                                 add_conf "# Load NES modules" "NES_LOAD=yes"
721                                 ;;
722                         --without-nes-mod)
723                                 CONFIG_INFINIBAND_NES=
724                                 ;;
725                         --with-nes_debug-mod)
726                                 CONFIG_INFINIBAND_NES_DEBUG="y"
727                                 ;;
728                         --without-nes_debug-mod)
729                                 CONFIG_INFINIBAND_NES_DEBUG=
730                                 ;;
731                         --with-ocrdma-mod)
732                                 CONFIG_INFINIBAND_OCRDMA="m"
733                                 CONFIG_BE2NET="m"
734                                 add_conf "# Load OCRDMA modules" "OCRDMA_LOAD=yes"
735                                 ;;
736                         --without-ocrdma-mod)
737                                 CONFIG_INFINIBAND_OCRDMA=
738                                 ;;
739                         --with-be2net-mod)
740                                 CONFIG_BE2NET="m"
741                                 ;;
742                         --without-be2net-mod)
743                                 CONFIG_BE2NET=
744                                 ;;
745                         --with-bnxt_re-mod)
746                                 CONFIG_INFINIBAND_BNXT_RE="m"
747                                 CONFIG_BNXT="m"
748                                 add_conf "# Load BNXT_RE modules" "BNXT_RE_LOAD=yes"
749                                 ;;
750                         --without-bnxt_re-mod)
751                                 CONFIG_INFINIBAND_BNXT_RE=
752                                 ;;
753                         --with-bnxt_en-mod)
754                                 CONFIG_BNXT="m"
755                                 CONFIG_BNXT_DCB="y"
756                                 ;;
757                         --without-bnxt_en-mod)
758                                 CONFIG_BNXT=
759                                 ;;
760                         --with-nvme_host-mod)
761                                 CONFIG_NVME_CORE="m"
762                                 CONFIG_BLK_DEV_NVME="m"
763                                 CONFIG_NVME_FABRICS="m"
764                                 CONFIG_NVME_FC="m"
765                                 CONFIG_NVME_RDMA="m"
766                                 CONFIG_NVME_MULTIPATH=
767                                 CONFIG_NVME_HOST_WITHOUT_FC=
768                                 ;;
769                         --without-nvme_host-mod)
770                                 CONFIG_NVME_CORE=
771                                 CONFIG_BLK_DEV_NVME=
772                                 CONFIG_NVME_FABRICS=
773                                 CONFIG_NVME_FC=
774                                 CONFIG_NVME_RDMA=
775                                 CONFIG_NVME_MULTIPATH=
776                                 CONFIG_NVME_HOST_WITHOUT_FC=
777                                 ;;
778                         --with-nvme_host-without-fc)
779                                 CONFIG_NVME_HOST_WITHOUT_FC="m"
780                                 CONFIG_NVME_CORE="m"
781                                 CONFIG_BLK_DEV_NVME="m"
782                                 CONFIG_NVME_FABRICS="m"
783                                 CONFIG_NVME_FC=
784                                 CONFIG_NVME_RDMA="m"
785                                 CONFIG_NVME_MULTIPATH=
786                                 CONFIG_NVME_TARGET=
787                                 CONFIG_NVME_TARGET_LOOP=
788                                 CONFIG_NVME_TARGET_RDMA=
789                                 CONFIG_NVME_TARGET_FC=
790                                 CONFIG_NVME_TARGET_FCLOOP=
791                                 ;;
792                         --without-nvme_host-without-fc)
793                                 CONFIG_NVME_HOST_WITHOUT_FC=
794                                 CONFIG_NVME_CORE=
795                                 CONFIG_BLK_DEV_NVME=
796                                 CONFIG_NVME_FABRICS=
797                                 CONFIG_NVME_FC=
798                                 CONFIG_NVME_RDMA=
799                                 CONFIG_NVME_MULTIPATH=
800                                 CONFIG_NVME_TARGET=
801                                 CONFIG_NVME_TARGET_LOOP=
802                                 CONFIG_NVME_TARGET_RDMA=
803                                 CONFIG_NVME_TARGET_FC=
804                                 CONFIG_NVME_TARGET_FCLOOP=
805                                 ;;
806                         --with-nvme_target-mod)
807                                 CONFIG_NVME_TARGET="m"
808                                 CONFIG_NVME_TARGET_LOOP="m"
809                                 CONFIG_NVME_TARGET_RDMA="m"
810                                 CONFIG_NVME_TARGET_FC="m"
811                                 CONFIG_NVME_TARGET_FCLOOP="m"
812                                 CONFIG_NVME_HOST_WITHOUT_FC=
813                                 ;;
814                         --without-nvme_target-mod)
815                                 CONFIG_NVME_TARGET=
816                                 CONFIG_NVME_TARGET_LOOP=
817                                 CONFIG_NVME_TARGET_RDMA=
818                                 CONFIG_NVME_TARGET_FC=
819                                 CONFIG_NVME_TARGET_FCLOOP=
820                                 CONFIG_NVME_HOST_WITHOUT_FC=
821                                 ;;
822                         --with-nfsrdma-mod)
823                                 CONFIG_SUNRPC_XPRT_RDMA="m"
824                                 CONFIG_SUNRPC_XPRT_RDMA_CLIENT="m"
825                                 CONFIG_SUNRPC_XPRT_RDMA_SERVER="m"
826                                 ;;
827                         --without-nfsrdma-mod)
828                                 CONFIG_SUNRPC_XPRT_RDMA=
829                                 CONFIG_SUNRPC_XPRT_RDMA_CLIENT=
830                                 CONFIG_SUNRPC_XPRT_RDMA_SERVER=
831                                 ;;
832                         --with-vmw_pvrdma-mod)
833                                 CONFIG_INFINIBAND_VMWARE_PVRDMA="m"
834                                 ;;
835                         --without-vmw_pvrdma-mod)
836                                 CONFIG_INFINIBAND_VMWARE_PVRDMA=
837                                 ;;
838                         --with-qed-mod)
839                                 CONFIG_QED="m"
840                                 ;;
841                         --without-qed-mod)
842                                 CONFIG_QED=
843                                 ;;
844                         --with-qede-mod)
845                                 CONFIG_QED="m"
846                                 CONFIG_QEDE="m"
847                                 ;;
848                         --without-qede-mod)
849                                 CONFIG_QED=
850                                 CONFIG_QEDE=
851                                 ;;
852                         --with-qedr-mod)
853                                 CONFIG_QED="m"
854                                 CONFIG_QED_LL2="y"
855                                 CONFIG_QED_RDMA="y"
856                                 CONFIG_QEDE="m"
857                                 CONFIG_INFINIBAND_QEDR="m"
858                                 CONFIG_QED_OOO="y"
859                                 ;;
860                         --without-qedr-mod)
861                                 CONFIG_QED=
862                                 CONFIG_QED_LL2=
863                                 CONFIG_QED_RDMA=
864                                 CONFIG_QEDE=
865                                 CONFIG_INFINIBAND_QEDR=
866                                 CONFIG_QED_OOO=
867                                 ;;
868                         --without-firmware-mod)
869                                 ;;
870
871                         -h | --help)
872                                 usage
873                                 exit 0
874                                 ;;
875                         --without*)
876                                 tmpconfig=`echo $1 | sed -e 's/--without/CONFIG/' -e 's/-/_/g' | tr '[:lower:]' '[:upper:]'`
877                                 eval export $tmpconfig=
878                                 ;;
879                         --with*=*)
880                                 tmpconfig=`echo $1 | cut -d '=' -f 1 | sed -e 's/--with/CONFIG/' -e 's/-/_/g' | tr '[:lower:]' '[:upper:]'`
881                                 eval export $tmpconfig=`expr "x$1" : 'x[^=]*=\(.*\)'`
882                                 ;;
883                         --with*)
884                                 tmpconfig=`echo $1 | sed -e 's/--with/CONFIG/' -e 's/-/_/g' | tr '[:lower:]' '[:upper:]'`
885                                 eval export $tmpconfig=y
886                                 ;;
887                         *)
888                                 echo
889                                 echo "Unsupported parameter $1"
890                                 echo
891                                 ;;
892                 esac
893                 shift
894
895         done
896
897         #Set default values
898         KVERSION=${KVERSION:-$(uname -r)}
899         MIN_KVERSION="3.10"
900         MODULES_DIR=${MODULES_DIR:-/lib/modules/${KVERSION}/updates}
901         KSRC=${KSRC:-/lib/modules/${KVERSION}/source}
902         KSRC_OBJ=${KSRC_OBJ:-/lib/modules/$KVERSION/build}
903
904         ARCH=${ARCH:-$(uname -m)}
905
906         case $KVERSION in
907                 *)
908                 CONFIG_COMPAT_RDMA=m
909                 ;;
910         esac
911
912
913         case $ARCH in
914                 ppc*)
915                         ARCH=powerpc
916                         ;;
917                 i?86)
918                         ARCH=i386
919                         ;;
920         esac
921
922         # Additional parameters to be passed to configure command
923         CWD=$(pwd)
924         CONFIG="configure.mk.kernel"
925         # ALL_CONFIGS - includes all used config macros
926         ALL_CONFIGS="allconfigs"
927
928         find $CWD -name Kconfig | xargs grep -h ^config | sed -e "s/config /CONFIG_/" | sort -n | uniq > $ALL_CONFIGS
929
930         if (/bin/ls -1 $KSRC_OBJ/include/*/autoconf.h 2>/dev/null | head -1 | grep -q generated); then
931                 AUTOCONF_PREFIX=generated
932         else
933                 AUTOCONF_PREFIX=linux
934         fi
935         mkdir -p ${CWD}/include/${AUTOCONF_PREFIX}
936         AUTOCONF_H="${CWD}/include/${AUTOCONF_PREFIX}/autoconf.h"
937
938         # disable unsupported modules on 32bit
939         if [ $ARCH != "x86_64" ]; then
940                 CONFIG_INFINIBAND_IPATH=
941                 CONFIG_INFINIBAND_QIB=
942                 CONFIG_INFINIBAND_RDMAVT=
943                 CONFIG_RDMA_RXE=
944                 CONFIG_INFINIBAND_VMWARE_PVRDMA=
945         fi
946
947         SKIP_AUTOCONF=${SKIP_AUTOCONF:-0}
948         FORCE_AUTOGEN=${FORCE_AUTOGEN:-0}
949
950         if [ "X${CONFIG_MLX4_EN}" == "Xm" ]; then
951                 check_autofconf CONFIG_DCB
952                 if [ X${CONFIG_DCB} == "X1" ]; then
953                         CONFIG_MLX4_EN_DCB=y
954                 fi
955         fi
956
957         if [ "X${CONFIG_BNXT}" == "Xm" ]; then
958                 check_autofconf CONFIG_DCB
959                 if [ X${CONFIG_DCB} == "X1" ]; then
960                         CONFIG_BNXT_DCB=y
961                 fi
962         fi
963
964         # Check for minimal supported kernel version
965         if ! check_kerver ${KVERSION} ${MIN_KVERSION}; then
966                 echo "Kernel version ${KVERSION} is less then supported kernel ${MIN_KVERSION}. Exiting..."
967                 exit 1
968         fi
969
970         if [ ! -e .backports_applied ]; then
971                 echo ".backports_applied does not exist. running ofed_patch.sh"
972                 ex ${CWD}/ofed_scripts/ofed_patch.sh ${ofed_patch_params}
973         fi
974
975         # Configfs requires CONFIGFS_FS to be enabled in the kernel
976         if [ "X${CONFIG_INFINIBAND_ADDR_TRANS}" == "Xy" ]; then
977                 check_autofconf CONFIGFS_FS
978                 if [ X${CONFIGFS_FS} == "X1" ]; then
979                         CONFIG_INFINIBAND_ADDR_TRANS_CONFIGFS=y
980                 fi
981         fi
982
983         check_autofconf CONFIG_NET_SWITCHDEV
984         if [ "X${CONFIG_NET_SWITCHDEV}" != "X1" ]; then
985                 CONFIG_MLX5_ESWITCH=
986         fi
987
988         # Create configure.mk
989         /bin/rm -f ${CWD}/${CONFIG}
990         cat >> ${CWD}/${CONFIG} << EOFCONFIG
991 # Current working directory
992 CWD=${CWD}
993
994 # Kernel level
995 KVERSION=${KVERSION}
996 ARCH=${ARCH}
997 MODULES_DIR=${MODULES_DIR}
998 KSRC=${KSRC}
999 KSRC_OBJ=${KSRC_OBJ}
1000 KLIB_BUILD=${KSRC_OBJ}
1001
1002 AUTOCONF_H=${AUTOCONF_H}
1003
1004 WITH_MAKE_PARAMS=${WITH_MAKE_PARAMS}
1005 EOFCONFIG
1006
1007         while read config
1008         do
1009                 eval echo $config=\$$config >> ${CONFIG}
1010         done < ${ALL_CONFIGS}
1011
1012         echo "Created ${CONFIG}:"
1013
1014         . ${CONFIG}
1015
1016         CONFIG_VALUES=`grep ^CONFIG ${CONFIG} | tr -s '\n' ' '`
1017         sed -e "s/@CONFIG_VALUES@/$CONFIG_VALUES/" makefile.in > makefile
1018
1019         # Create autoconf.h
1020         TMPAUTOCONF1=`mktemp $CWD/XXXXXX.autoconf1`
1021         TMPAUTOCONF2=`mktemp $CWD/XXXXXX.autoconf2`
1022         while read config
1023         do
1024                 val=`eval echo \\$$config`
1025                 case $val in
1026                         y|m)
1027                                 echo "#define $config 1" >> ${TMPAUTOCONF1}
1028                                 echo -e "#undef $config\n#define $config 1" >> ${TMPAUTOCONF2}
1029                                 ;;
1030                         *)
1031                                 echo "#undef $config" >> ${TMPAUTOCONF2}
1032                                 ;;
1033                 esac
1034         done < ${ALL_CONFIGS}
1035
1036         cat > ${AUTOCONF_H} << EOFAUTOCONF
1037 #ifndef __OFED_BUILD__
1038 #include_next <$AUTOCONF_PREFIX/autoconf.h>
1039
1040 EOFAUTOCONF
1041
1042         cat ${TMPAUTOCONF1} >> ${AUTOCONF_H}
1043         echo -e "\n#else\n" >> ${AUTOCONF_H}
1044         cat ${TMPAUTOCONF2} >> ${AUTOCONF_H}
1045         echo -e "\n#endif" >> ${AUTOCONF_H}
1046
1047         echo Created ${AUTOCONF_H}
1048         /bin/rm -f ${TMPAUTOCONF1}
1049         /bin/rm -f ${TMPAUTOCONF2}
1050
1051         if [ ! -x compat/autogen.sh ]; then
1052                 exit 0
1053         fi
1054
1055         if [ $SKIP_AUTOCONF -eq 0 ]; then
1056                 cd compat
1057                 if [[ ! -x configure || $FORCE_AUTOGEN -eq 1 ]]; then
1058                         ex ./autogen.sh
1059                 fi
1060                 ex ./configure --with-linux-obj=$KSRC_OBJ --with-linux=$KSRC
1061         fi
1062 }
1063
1064 main $@