From d2dd61c0723c2235f73152bda6042c0df775bffb Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 22 Aug 2016 04:28:52 +0000 Subject: [PATCH] isert-scst, srpt: Fix build on systems with kernel >= 4.2.0 + MOFED 3.3 git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6973 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- iscsi-scst/Makefile | 7 +++++++ iscsi-scst/kernel/isert-scst/iser_rdma.c | 2 +- scripts/specialize-patch | 12 ++++++++++++ srpt/Makefile | 2 ++ srpt/src/ib_srpt.c | 3 ++- 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/iscsi-scst/Makefile b/iscsi-scst/Makefile index 745cad781..5cab2239d 100644 --- a/iscsi-scst/Makefile +++ b/iscsi-scst/Makefile @@ -76,9 +76,16 @@ ifeq ($(OFED_FLAVOR),MOFED) endif ifeq ($(MLNX_OFED_IB_RH_INSTALLED),true) + OFED_VERS=$(shell rpm -q --qf '%{version}\n' mlnx-ofa_kernel-devel \ + 2>/dev/null) OFED_CFLAGS:=-I/usr/src/ofa_kernel/default/include -include /usr/src/ofa_kernel/default/include/linux/compat-2.6.h ISER_SYMVERS:="$(ISER_SYMVERS) /usr/src/ofa_kernel/default/Module.symvers" endif + + # Make the version of the MOFED kernel package available to C source + # files such that it can be used in #ifdef statements where MOFED + # uses an older version of the RDMA API than the upstream kernel. + OFED_CFLAGS+=-DMOFED_MAJOR=$(shell echo $(OFED_VERS) | cut -f1 -d.) else # Whether or not the OFED kernel-ib-devel RPM has been installed. OFED_KERNEL_IB_DEVEL_RPM_INSTALLED:=$(shell if rpm -q kernel-ib-devel 2>/dev/null | grep -q $$(uname -r | sed 's/-/_/g'); then echo true; else echo false; fi) diff --git a/iscsi-scst/kernel/isert-scst/iser_rdma.c b/iscsi-scst/kernel/isert-scst/iser_rdma.c index 5796f3c85..b0172e7c7 100644 --- a/iscsi-scst/kernel/isert-scst/iser_rdma.c +++ b/iscsi-scst/kernel/isert-scst/iser_rdma.c @@ -1050,7 +1050,7 @@ static struct isert_device *isert_device_create(struct ib_device *ib_dev) goto fail_cq; } -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0) && \ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0) || defined(MOFED_MAJOR)) && \ !defined(IB_CREATE_CQ_HAS_INIT_ATTR) cq = ib_create_cq(ib_dev, isert_cq_comp_handler, diff --git a/scripts/specialize-patch b/scripts/specialize-patch index b10103849..493528002 100755 --- a/scripts/specialize-patch +++ b/scripts/specialize-patch @@ -114,6 +114,17 @@ function evaluate(stmnt, pattern, arg, op, result) { "(\\1) * 256 + (\\2)", "g", stmnt) } + if (MOFED_MAJOR == "") + { + gsub("defined\\(MOFED_MAJOR\\)", "0", stmnt) + gsub("MOFED_MAJOR", "", stmnt) + } + else + { + gsub("defined\\(MOFED_MAJOR\\)", "1", stmnt) + gsub("MOFED_MAJOR", MOFED_MAJOR, stmnt) + } + if (SCSI_EXEC_REQ_FIFO_DEFINED != "") { gsub("defined[[:blank:]]+SCSI_EXEC_REQ_FIFO_DEFINED", @@ -284,6 +295,7 @@ function handle_if(evaluated) || $0 ~ "RHEL_MAJOR" \ || $0 ~ "RHEL_MINOR" \ || $0 ~ "RHEL_RELEASE_CODE" \ + || $0 ~ "MOFED_MAJOR" \ || generating_upstream_patch_defined \ && $0 ~ "GENERATING_UPSTREAM_PATCH" \ || $0 ~ "CONFIG_TCP_ZERO_COPY_TRANSFER_COMPLETION_NOTIFICATION" \ diff --git a/srpt/Makefile b/srpt/Makefile index e224c4be4..cac01ccf1 100644 --- a/srpt/Makefile +++ b/srpt/Makefile @@ -65,7 +65,9 @@ ifeq ($(OFED_FLAVOR),MOFED) # header files use the LINUX_BACKPORT() macro without including # , include that header file explicitly. OFED_KERNEL_DIR:=/usr/src/ofa_kernel/default +OFED_VERS=$(shell rpm -q --qf '%{version}\n' mlnx-ofa_kernel-devel 2>/dev/null) OFED_CFLAGS:=-I$(OFED_KERNEL_DIR)/include -include linux/compat-2.6.h +OFED_CFLAGS+=-DMOFED_MAJOR=$(shell echo $(OFED_VERS) | cut -f1 -d.) else # OFED 1.5 OFED_KERNEL_DIR:=/usr/src/ofa_kernel diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index 18276851b..e8fce3d29 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -2223,7 +2223,8 @@ static int srpt_create_ch_ib(struct srpt_rdma_ch *ch) !defined(RHEL_RELEASE_CODE) ch->cq = ib_create_cq(sdev->device, srpt_completion, NULL, ch, ch->rq_size + srpt_sq_size); -#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0) && \ +#elif (LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0) || \ + defined(MOFED_MAJOR)) && \ !defined(IB_CREATE_CQ_HAS_INIT_ATTR) ch->cq = ib_create_cq(sdev->device, srpt_completion, NULL, ch, ch->rq_size + srpt_sq_size, ch->comp_vector);