diff --git a/srpt/Makefile b/srpt/Makefile index 739c41316..b4d491e9e 100644 --- a/srpt/Makefile +++ b/srpt/Makefile @@ -87,23 +87,40 @@ OTHER_GOALS:=$(foreach goal,$(MAKECMDGOALS),$(subst all,,$(goal))) # echo:=$(shell echo 'OTHER_GOALS = $(OTHER_GOALS)' >&2) ifneq ("$(GOALS)","$(OTHER_GOALS)") run_conftest = $(shell if [ "0$(V)" -gt 0 ]; then output=/dev/stdout; else output=/dev/null; fi; if $(MAKE) -C $(KDIR) V=$(V) SUBDIRS="$(shell pwd)/conftest/$1" PRE_CFLAGS="-Werror $(OFED_CFLAGS)" 1>&2 2>$${output}; then echo "$2"; else echo "$3"; fi) +USE_PRE_440_WR_STRUCTURE := $(call run_conftest,use_pre_440_wr_structure,-DUSE_PRE_440_WR_STRUCTURE) CREATE_CQ_FLAG := $(call run_conftest,create_cq,-DIB_CREATE_CQ_HAS_INIT_ATTR) CREATE_SEND_MAD_AH_FLAG := $(call run_conftest,create_send_mad_ah,-DCREATE_SEND_MAD_HAS_AH_ARG) ifeq ($(CREATE_SEND_MAD_AH_FLAG),) CREATE_SEND_MAD_BASE_FLAG := $(call run_conftest,create_send_mad_base,-DCREATE_SEND_MAD_HAS_BASE_ARG) endif +CLIENT_REMOVE := $(call run_conftest,ib_client_remove,-DIB_CLIENT_REMOVE_TAKES_TWO_ARGS) +CM_LISTEN := $(call run_conftest,cm_listen,-DIB_CM_LISTEN_TAKES_FOURTH_ARG) +MAD_HANDLER_TAKES_SEND_BUF := $(call run_conftest,mad_handler_takes_send_buf,-DMAD_HANDLER_TAKES_SEND_BUF) HAVE_IB_DMA_MAP_OPS := $(call run_conftest,ib_dma_map_ops,-DHAVE_IB_DMA_MAP_OPS) +HAVE_IB_SET_CPI_RESP_TIME := $(call run_conftest,ib_set_cpi_resp_time,-DHAVE_IB_SET_CPI_RESP_TIME) GID_CHANGE_FLAG := $(call run_conftest,gid_change,-DHAVE_IB_EVENT_GID_CHANGE) +RDMA_CREATE_ID := $(call run_conftest,rdma_create_id_net,-DRDMA_CREATE_ID_TAKES_NET_ARG=1,-DRDMA_CREATE_ID_TAKES_NET_ARG=0) REGISTER_MAD_AGENT_FLAG := $(call run_conftest,register_mad_agent,-DREGISTER_MAD_AGENT_HAS_FLAGS_ARG) +QUERY_DEVICE := $(call run_conftest,query_device,-DHAVE_IB_QUERY_DEVICE) +QUERY_DEVICE_HAS_ATTR_ARG := $(call run_conftest,query_device_attr_arg,-DIB_QUERY_DEVICE_HAS_ATTR_ARG) QUERY_GID_FLAG := $(call run_conftest,query_gid,-DIB_QUERY_GID_HAS_ATTR_ARG) PRE_CFLAGS=$(OFED_CFLAGS) \ + $(USE_PRE_440_WR_STRUCTURE) \ + $(CLIENT_REMOVE) \ $(CREATE_CQ_FLAG) \ $(CREATE_SEND_MAD_AH_FLAG) \ $(CREATE_SEND_MAD_BASE_FLAG) \ + $(IB_CLIENT_REMOVE_TAKES_TWO_ARGS) \ + $(CM_LISTEN) \ + $(MAD_HANDLER_TAKES_SEND_BUF) \ $(HAVE_IB_DMA_MAP_OPS) \ + $(HAVE_IB_SET_CPI_RESP_TIME) \ $(GID_CHANGE_FLAG) \ + $(RDMA_CREATE_ID) \ $(REGISTER_MAD_AGENT_FLAG) \ $(QUERY_GID_FLAG) \ + $(QUERY_DEVICE) \ + $(QUERY_DEVICE_HAS_ATTR_ARG) \ -DOFED_FLAVOR=$(OFED_FLAVOR) endif diff --git a/srpt/conftest/cm_listen/Makefile b/srpt/conftest/cm_listen/Makefile new file mode 100644 index 000000000..e9f8cb9f7 --- /dev/null +++ b/srpt/conftest/cm_listen/Makefile @@ -0,0 +1,3 @@ +LINUXINCLUDE := $(PRE_CFLAGS) $(LINUXINCLUDE) + +obj-m += cm_listen.o diff --git a/srpt/conftest/cm_listen/cm_listen.c b/srpt/conftest/cm_listen/cm_listen.c new file mode 100644 index 000000000..f03fddabb --- /dev/null +++ b/srpt/conftest/cm_listen/cm_listen.c @@ -0,0 +1,9 @@ +#include +#include + +static int modinit(void) +{ + return ib_cm_listen(NULL, 0, 0, NULL); +} + +module_init(modinit); diff --git a/srpt/conftest/ib_client_remove/Makefile b/srpt/conftest/ib_client_remove/Makefile new file mode 100644 index 000000000..dbb92ba16 --- /dev/null +++ b/srpt/conftest/ib_client_remove/Makefile @@ -0,0 +1,3 @@ +LINUXINCLUDE := $(PRE_CFLAGS) $(LINUXINCLUDE) + +obj-m += ib_client_remove.o diff --git a/srpt/conftest/ib_client_remove/ib_client_remove.c b/srpt/conftest/ib_client_remove/ib_client_remove.c new file mode 100644 index 000000000..77cac3525 --- /dev/null +++ b/srpt/conftest/ib_client_remove/ib_client_remove.c @@ -0,0 +1,15 @@ +#include +#include + +static void client_remove(struct ib_device *dev, void *client_data) +{ +} + +static int modinit(void) +{ + struct ib_client c = { .remove = client_remove }; + + return (uintptr_t)c.remove; +} + +module_init(modinit); diff --git a/srpt/conftest/ib_set_cpi_resp_time/Makefile b/srpt/conftest/ib_set_cpi_resp_time/Makefile new file mode 100644 index 000000000..8ba270a73 --- /dev/null +++ b/srpt/conftest/ib_set_cpi_resp_time/Makefile @@ -0,0 +1,3 @@ +LINUXINCLUDE := $(PRE_CFLAGS) $(LINUXINCLUDE) + +obj-m += ib_set_cpi_resp_time.o diff --git a/srpt/conftest/ib_set_cpi_resp_time/ib_set_cpi_resp_time.c b/srpt/conftest/ib_set_cpi_resp_time/ib_set_cpi_resp_time.c new file mode 100644 index 000000000..eb544bd0f --- /dev/null +++ b/srpt/conftest/ib_set_cpi_resp_time/ib_set_cpi_resp_time.c @@ -0,0 +1,9 @@ +#include +#include + +static int modinit(void) +{ + return (uintptr_t)ib_set_cpi_resp_time; +} + +module_init(modinit); diff --git a/srpt/conftest/mad_handler_takes_send_buf/Makefile b/srpt/conftest/mad_handler_takes_send_buf/Makefile new file mode 100644 index 000000000..03f96f272 --- /dev/null +++ b/srpt/conftest/mad_handler_takes_send_buf/Makefile @@ -0,0 +1,3 @@ +LINUXINCLUDE := $(PRE_CFLAGS) $(LINUXINCLUDE) + +obj-m += mad_handler_takes_send_buf.o diff --git a/srpt/conftest/mad_handler_takes_send_buf/mad_handler_takes_send_buf.c b/srpt/conftest/mad_handler_takes_send_buf/mad_handler_takes_send_buf.c new file mode 100644 index 000000000..348d67121 --- /dev/null +++ b/srpt/conftest/mad_handler_takes_send_buf/mad_handler_takes_send_buf.c @@ -0,0 +1,17 @@ +#include +#include + +static void imrh(struct ib_mad_agent *mad_agent, + struct ib_mad_send_buf *send_buf, + struct ib_mad_recv_wc *mad_recv_wc) +{ +} + +static int modinit(void) +{ + ib_mad_recv_handler h = imrh; + + return !!h; +} + +module_init(modinit); diff --git a/srpt/conftest/query_device/Makefile b/srpt/conftest/query_device/Makefile new file mode 100644 index 000000000..7f907d2b3 --- /dev/null +++ b/srpt/conftest/query_device/Makefile @@ -0,0 +1,3 @@ +LINUXINCLUDE := $(PRE_CFLAGS) $(LINUXINCLUDE) + +obj-m += query_device.o diff --git a/srpt/conftest/query_device/query_device.c b/srpt/conftest/query_device/query_device.c new file mode 100644 index 000000000..b32717ce5 --- /dev/null +++ b/srpt/conftest/query_device/query_device.c @@ -0,0 +1,9 @@ +#include +#include + +static int modinit(void) +{ + return (uintptr_t)ib_query_device; +} + +module_init(modinit); diff --git a/srpt/conftest/query_device_attr_arg/Makefile b/srpt/conftest/query_device_attr_arg/Makefile new file mode 100644 index 000000000..1998c3bc1 --- /dev/null +++ b/srpt/conftest/query_device_attr_arg/Makefile @@ -0,0 +1,3 @@ +LINUXINCLUDE := $(PRE_CFLAGS) $(LINUXINCLUDE) + +obj-m += query_device_attr_arg.o diff --git a/srpt/conftest/query_device_attr_arg/query_device_attr_arg.c b/srpt/conftest/query_device_attr_arg/query_device_attr_arg.c new file mode 100644 index 000000000..339d155d4 --- /dev/null +++ b/srpt/conftest/query_device_attr_arg/query_device_attr_arg.c @@ -0,0 +1,9 @@ +#include +#include + +static int modinit(void) +{ + return ib_query_device(NULL, NULL); +} + +module_init(modinit); diff --git a/srpt/conftest/rdma_create_id_net/Makefile b/srpt/conftest/rdma_create_id_net/Makefile new file mode 100644 index 000000000..3b054d037 --- /dev/null +++ b/srpt/conftest/rdma_create_id_net/Makefile @@ -0,0 +1,3 @@ +LINUXINCLUDE := $(PRE_CFLAGS) $(LINUXINCLUDE) + +obj-m += rdma_create_id_net.o diff --git a/srpt/conftest/rdma_create_id_net/rdma_create_id_net.c b/srpt/conftest/rdma_create_id_net/rdma_create_id_net.c new file mode 100644 index 000000000..fd6b874d9 --- /dev/null +++ b/srpt/conftest/rdma_create_id_net/rdma_create_id_net.c @@ -0,0 +1,10 @@ +#include +#include + +static int modinit(void) +{ + return rdma_create_id(NULL, NULL, NULL, 0, 0) != NULL; + +} + +module_init(modinit); diff --git a/srpt/conftest/use_pre_440_wr_structure/Makefile b/srpt/conftest/use_pre_440_wr_structure/Makefile new file mode 100644 index 000000000..ea82d5d19 --- /dev/null +++ b/srpt/conftest/use_pre_440_wr_structure/Makefile @@ -0,0 +1,3 @@ +LINUXINCLUDE := $(PRE_CFLAGS) $(LINUXINCLUDE) + +obj-m += use_pre_440_wr_structure.o diff --git a/srpt/conftest/use_pre_440_wr_structure/use_pre_440_wr_structure.c b/srpt/conftest/use_pre_440_wr_structure/use_pre_440_wr_structure.c new file mode 100644 index 000000000..3205a489b --- /dev/null +++ b/srpt/conftest/use_pre_440_wr_structure/use_pre_440_wr_structure.c @@ -0,0 +1,11 @@ +#include +#include + +static int modinit(void) +{ + struct ib_send_wr wr = { }; + + return wr.wr.rdma.rkey; +} + +module_init(modinit); diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index a821b232b..5be9fff2b 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -418,7 +418,7 @@ static void srpt_get_class_port_info(struct ib_dm_mad *mad) memset(cif, 0, sizeof(*cif)); cif->base_version = 1; cif->class_version = 1; -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 7, 0) +#ifndef HAVE_IB_SET_CPI_RESP_TIME cif->resp_time_value = 20; #else ib_set_cpi_resp_time(cif, 20); @@ -598,7 +598,7 @@ static void srpt_mad_send_handler(struct ib_mad_agent *mad_agent, * srpt_mad_recv_handler() - MAD reception callback function. */ static void srpt_mad_recv_handler(struct ib_mad_agent *mad_agent, -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0) && !defined(MOFED_MAJOR) +#ifdef MAD_HANDLER_TAKES_SEND_BUF struct ib_mad_send_buf *send_buf, #endif struct ib_mad_recv_wc *mad_wc) @@ -3389,7 +3389,7 @@ static int srpt_perform_rdmas(struct srpt_rdma_ch *ch, struct srpt_send_ioctx *ioctx, scst_data_direction dir) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) || defined(MOFED_MAJOR) +#ifdef USE_PRE_440_WR_STRUCTURE struct ib_send_wr wr; #else struct ib_rdma_wr wr; @@ -3414,7 +3414,7 @@ static int srpt_perform_rdmas(struct srpt_rdma_ch *ch, memset(&wr, 0, sizeof(wr)); for (i = 0; i < n_rdma; ++i, ++riu) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) || defined(MOFED_MAJOR) +#ifdef USE_PRE_440_WR_STRUCTURE if (dir == SCST_DATA_READ) { wr.opcode = IB_WR_RDMA_WRITE; wr.wr_id = encode_wr_id(i == n_rdma - 1 ? @@ -3473,7 +3473,7 @@ static int srpt_perform_rdmas(struct srpt_rdma_ch *ch, pr_err("%s: ib_post_send() returned %d for %d/%d\n", __func__, ret, i, n_rdma); if (ret && i > 0) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) || defined(MOFED_MAJOR) +#ifdef USE_PRE_440_WR_STRUCTURE wr.num_sge = 0; wr.wr_id = encode_wr_id(SRPT_RDMA_ABORT, ioctx->ioctx.index); wr.send_flags = IB_SEND_SIGNALED; @@ -3500,7 +3500,7 @@ static int srpt_perform_rdmas(struct srpt_rdma_ch *ch, #endif pr_info("Waiting until RDMA abort finished [%d]\n", ioctx->ioctx.index); -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) || defined(MOFED_MAJOR) +#ifdef USE_PRE_440_WR_STRUCTURE while (ch->state < CH_DISCONNECTED && !ioctx->rdma_aborted) { pr_info("Waiting until RDMA abort finished [%d]\n", ioctx->ioctx.index); @@ -4341,7 +4341,7 @@ static void srpt_add_one(struct ib_device *device) sdev->device = device; -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0) || defined(MOFED_MAJOR) +#ifdef HAVE_IB_QUERY_DEVICE ret = ib_query_device(device, &sdev->dev_attr); if (ret) { pr_err("ib_query_device() failed: %d\n", ret); @@ -4459,7 +4459,7 @@ static void srpt_add_one(struct ib_device *device) * if this HCA is gone bad and replaced by different HCA */ ret = ib_cm_listen(sdev->cm_id, cpu_to_be64(srpt_service_guid), 0 -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0) || defined(MOFED_MAJOR) +#ifdef IB_CM_LISTEN_TAKES_FOURTH_ARG , NULL #endif ); @@ -4508,7 +4508,7 @@ err: /** * srpt_remove_one() - InfiniBand device removal callback function. */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0) || defined(MOFED_MAJOR) +#ifndef IB_CLIENT_REMOVE_TAKES_TWO_ARGS static void srpt_remove_one(struct ib_device *device) { void *client_data = ib_get_client_data(device, &srpt_client); @@ -4690,7 +4690,7 @@ static int __init srpt_init_module(void) (!defined(RHEL_MAJOR) || RHEL_MAJOR -0 < 6) rdma_cm_id = rdma_create_id(srpt_rdma_cm_handler, NULL, RDMA_PS_TCP); -#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) || defined(MOFED_MAJOR) +#elif !RDMA_CREATE_ID_TAKES_NET_ARG rdma_cm_id = rdma_create_id(srpt_rdma_cm_handler, NULL, RDMA_PS_TCP, IB_QPT_RC); #else