From 940faa9ad4420a936f4c49cf71354b45b2a19236 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 2 Mar 2015 14:28:25 +0000 Subject: [PATCH] ib_srpt: Enable building against OFED headers without patching the build system Additionally, include the OFED flavor name in the ib_srpt version number. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6138 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scripts/run-regression-tests | 8 -------- srpt/Makefile | 15 ++++----------- srpt/README.ofed | 10 ---------- srpt/conftest/gid_change/Makefile | 2 ++ srpt/src/Makefile | 1 + srpt/src/ib_srpt.c | 2 +- 6 files changed, 8 insertions(+), 30 deletions(-) diff --git a/scripts/run-regression-tests b/scripts/run-regression-tests index f792254c4..96b7d74fc 100755 --- a/scripts/run-regression-tests +++ b/scripts/run-regression-tests @@ -278,14 +278,6 @@ CONFIG_TRACING CONFIG_X86_32 \ patch -p1 -f -s <"${p}" >>"${patchoutput}" 2>&1 done fi && - if [ -e $srcdir/srpt/patches/kernel-${kver}-pre-cflags.patch ]; then - echo "$srcdir/srpt/patches/kernel-${kver}-pre-cflags.patch ..." \ - >>"${patchoutput}" - patch -p1 -f -s <$srcdir/srpt/patches/kernel-${kver}-pre-cflags.patch \ - >>"${patchoutput}" - else - echo "srpt/patches/kernel-${kver}-pre-cflags.patch not found." - fi && make -s allmodconfig &>"${outputdir}/make-config-output.txt" && for c in $disable; do sed -i.tmp "s/^$c=[ym]\$/$c=n/" .config; done && make -s oldconfig &>/dev/null diff --git a/srpt/Makefile b/srpt/Makefile index 62e680454..79dafdeac 100644 --- a/srpt/Makefile +++ b/srpt/Makefile @@ -52,7 +52,7 @@ OFED_KERNEL_IB_RPM:=$(shell for r in mlnx-ofa_kernel compat-rdma kernel-ib; do r # Name of the OFED kernel development RPM. OFED_KERNEL_IB_DEVEL_RPM:=$(shell for r in mlnx-ofa_kernel-devel compat-rdma-devel kernel-ib-devel; do rpm -q $$r 2>/dev/null | grep -q "^$$r" && echo $$r && break; done) -OFED_FLAVOR=$(shell /usr/bin/ofed_info 2>/dev/null | head -n1 | sed -n 's/^\(MLNX_OFED\|OFED-internal\).*/MOFED/p;s/^OFED-.*/OFED/p') +OFED_FLAVOR=$(shell if [ -e /usr/bin/ofed_info ]; then /usr/bin/ofed_info 2>/dev/null | head -n1 | sed -n 's/^\(MLNX_OFED\|OFED-internal\).*/MOFED/p;s/^OFED-.*/OFED/p'; else echo in-tree; fi) ifneq ($(OFED_KERNEL_IB_RPM),) ifeq ($(OFED_KERNEL_IB_RPM),compat-rdma) @@ -77,15 +77,13 @@ endif OFED_MODULE_SYMVERS:=$(OFED_KERNEL_DIR)/$(MODULE_SYMVERS) endif -HAVE_KCFLAGS = $(shell $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd)/conftest/kcflags KCFLAGS=-DKCFLAGS_MACRO=1 >/dev/null 2>&1 && echo true || echo false) -HAVE_PRE_CFLAGS = $(shell $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd)/conftest/pre_cflags PRE_CFLAGS=-DPRE_CFLAGS_MACRO=1 >/dev/null 2>&1 && echo true || echo false) -AUTOCONF_FLAGS = $(shell $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd)/conftest/gid_change PRE_CFLAGS="$(OFED_CFLAGS)" >/dev/null 2>&1 && echo -DHAVE_IB_EVENT_GID_CHANGE) +AUTOCONF_FLAGS = $(shell $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd)/conftest/gid_change PRE_CFLAGS="$(OFED_CFLAGS)" >/dev/null 2>&1 && echo -DHAVE_IB_EVENT_GID_CHANGE) all: src/$(MODULE_SYMVERS) $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd)/src \ - PRE_CFLAGS="$(OFED_CFLAGS) $(AUTOCONF_FLAGS)" \ - KCFLAGS="$(AUTOCONF_FLAGS)" SCST_INC_DIR=$(SCST_INC_DIR) modules + PRE_CFLAGS="$(OFED_CFLAGS) $(AUTOCONF_FLAGS) -DOFED_FLAVOR=$(OFED_FLAVOR)" \ + SCST_INC_DIR=$(SCST_INC_DIR) modules install: all @[ -z "$(DESTDIR)$(INSTALL_MOD_PATH)" ] && \ @@ -102,11 +100,6 @@ uninstall: src/$(MODULE_SYMVERS): $(SCST_SYMVERS_DIR)/$(MODULE_SYMVERS) \ $(OFED_MODULE_SYMVERS) - @if [ "$(HAVE_KCFLAGS)" = false -a "$(HAVE_PRE_CFLAGS)" = false -a \ - -n "$(AUTOCONF_FLAGS)" ]; then \ - echo "Error: the kernel build system has not yet been patched.";\ - false; \ - fi @if [ -n "$(OFED_KERNEL_IB_RPM)" ]; then \ if [ -z "$(OFED_KERNEL_IB_DEVEL_RPM)" ]; then \ echo "Error: the OFED package $(OFED_KERNEL_IB_RPM)-devel has" \ diff --git a/srpt/README.ofed b/srpt/README.ofed index 788b8b941..e543200ea 100644 --- a/srpt/README.ofed +++ b/srpt/README.ofed @@ -55,16 +55,6 @@ Remove any distro-provided InfiniBand drivers: rm -rf /lib/modules/$(uname -r)/kernel/drivers/infiniband rm -rf /lib/modules/$(uname -r)/kernel/drivers/net/mlx4 -Now locate the file Makefile.lib and patch it such that it supports -the variable PRE_CFLAGS: - - if [ -e /lib/modules/$(uname -r)/build/scripts/Makefile.lib ]; then - cd /lib/modules/$(uname -r)/build - else - cd /usr/src/linux-$(uname -r | sed 's/\(-default\|-trace\|-xen\)$//;s/\.[0-9]\+\.[0-9]\+\.[0-9]\+\.PTF$//') - fi - patch -p1 < ${SCST_DIR}/srpt/patches/kernel-${KV}-pre-cflags.patch - Next, download and install the OFED package. Make sure to disable OFED's SRP target driver (srpt=n) and to enable at least the kernel-ib, kernel-ib-devel and SRP tools packages. An example: diff --git a/srpt/conftest/gid_change/Makefile b/srpt/conftest/gid_change/Makefile index e81c05753..ef14a136e 100644 --- a/srpt/conftest/gid_change/Makefile +++ b/srpt/conftest/gid_change/Makefile @@ -1 +1,3 @@ +LINUXINCLUDE := $(PRE_CFLAGS) $(LINUXINCLUDE) + obj-m += gid_change.o diff --git a/srpt/src/Makefile b/srpt/src/Makefile index 5850d0554..5beb4781c 100644 --- a/srpt/src/Makefile +++ b/srpt/src/Makefile @@ -1,3 +1,4 @@ +LINUXINCLUDE := $(PRE_CFLAGS) $(LINUXINCLUDE) EXTRA_CFLAGS += -I$(SCST_INC_DIR) -include $(SUBDIRS)/../build_mode diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index 581dd4cfd..6f8dfcae3 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -80,7 +80,7 @@ /* Name of this kernel module. */ #define DRV_NAME "ib_srpt" -#define DRV_VERSION "3.1.0-pre" +#define DRV_VERSION "3.1.0-pre#" __stringify(OFED_FLAVOR) #define DRV_RELDATE "(not yet released)" #if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING) /* Flags to be used in SCST debug tracing statements. */