From 30c6cdfbe7e8736ae70128928797502a28ab53d5 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 8 Nov 2019 20:40:51 +0000 Subject: [PATCH 1/3] ib_srpt: Detect SRP_DATA_DESC_IMM constant support at compile time This patch makes it possible to build the ib_srpt driver against a kernel before v4.21 + latest MOFED. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@8653 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- srpt/Makefile | 6 ++++++ srpt/conftest/srp_data_desc_imm/Makefile | 3 +++ srpt/conftest/srp_data_desc_imm/srp_data_desc_imm.c | 9 +++++++++ srpt/src/ib_srpt.h | 4 ++-- 4 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 srpt/conftest/srp_data_desc_imm/Makefile create mode 100644 srpt/conftest/srp_data_desc_imm/srp_data_desc_imm.c diff --git a/srpt/Makefile b/srpt/Makefile index 4eb0445bc..ced096d17 100644 --- a/srpt/Makefile +++ b/srpt/Makefile @@ -269,6 +269,12 @@ conftest/register_mad_agent/result-$(KVER).txt: \ echo "$(call run_conftest,register_mad_agent, \ -DREGISTER_MAD_AGENT_HAS_FLAGS_ARG)" >"$@" +conftest/srp_data_desc_imm/result-$(KVER).txt: \ + conftest/srp_data_desc_imm/srp_data_desc_imm.c \ + conftest/srp_data_desc_imm/Makefile + echo "$(call run_conftest_bool,srp_data_desc_imm, \ + HAVE_SRP_DATA_DESC_IMM)" >"$@" + conftest/srp_login_req_rdma/result-$(KVER).txt: \ conftest/srp_login_req_rdma/srp_login_req_rdma.c \ conftest/srp_login_req_rdma/Makefile diff --git a/srpt/conftest/srp_data_desc_imm/Makefile b/srpt/conftest/srp_data_desc_imm/Makefile new file mode 100644 index 000000000..f06df5a6e --- /dev/null +++ b/srpt/conftest/srp_data_desc_imm/Makefile @@ -0,0 +1,3 @@ +LINUXINCLUDE := $(PRE_CFLAGS) $(LINUXINCLUDE) + +obj-m += srp_data_desc_imm.o diff --git a/srpt/conftest/srp_data_desc_imm/srp_data_desc_imm.c b/srpt/conftest/srp_data_desc_imm/srp_data_desc_imm.c new file mode 100644 index 000000000..1dc977a66 --- /dev/null +++ b/srpt/conftest/srp_data_desc_imm/srp_data_desc_imm.c @@ -0,0 +1,9 @@ +#include +#include + +static int modinit(void) +{ + return SRP_DATA_DESC_IMM; +} + +module_init(modinit); diff --git a/srpt/src/ib_srpt.h b/srpt/src/ib_srpt.h index 59baafc00..2af8422ba 100644 --- a/srpt/src/ib_srpt.h +++ b/srpt/src/ib_srpt.h @@ -66,7 +66,7 @@ struct srpt_nexus; -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 21, 0) +#if !HAVE_SRP_DATA_DESC_IMM enum { SRP_DATA_DESC_IMM = 3, SRP_IMMED_REQUESTED = 0x80, @@ -164,7 +164,7 @@ enum { SRP_CMD_ORDERED_Q = 0x2, SRP_CMD_ACA = 0x4, -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 21, 0) +#if !HAVE_SRP_DATA_DESC_IMM SRP_LOGIN_RSP_MULTICHAN_NO_CHAN = 0x0, SRP_LOGIN_RSP_MULTICHAN_TERMINATED = 0x1, SRP_LOGIN_RSP_MULTICHAN_MAINTAINED = 0x2, From e634e03a78bc7815d0400d57f5e0025da4f78e56 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 8 Nov 2019 21:17:29 +0000 Subject: [PATCH 2/3] scripts/specialize-patch: Add support for HAVE_SRP_DATA_DESC_IMM git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@8654 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scripts/specialize-patch | 76 +++++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 36 deletions(-) diff --git a/scripts/specialize-patch b/scripts/specialize-patch index 7140aea85..26bd3dfc1 100755 --- a/scripts/specialize-patch +++ b/scripts/specialize-patch @@ -117,6 +117,9 @@ function evaluate(stmnt, pattern, arg, op, result) { gsub("HAVE_RDMA_QUERY_GID", "(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0))", stmnt) + gsub("HAVE_SRP_DATA_DESC_IMM", + "(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 21, 0))", stmnt) + gsub("HAVE_STRUCT_SRP_LOGIN_REQ_RDMA", "(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0))", stmnt) @@ -384,42 +387,43 @@ function handle_if(evaluated) { # Only act on preprocessor conditional expressions with regard to the Linux # kernel version, and do not interpret other expressions. - if ($0 ~ "LINUX_VERSION_CODE" \ - || $0 ~ "CONFIG_SCST_PROC" \ - || $0 ~ "CONFIG_SCST_STRICT_SERIALIZING" \ - || $0 ~ "CREATE_SEND_MAD_HAS_BASE_ARG" \ - || $0 ~ "ENABLE_NPIV" \ - || $0 ~ "FC_VPORT_CREATE_DEFINED" \ - || $0 ~ "HAVE_DEV_ATTR_MAX_RECV_SGE" \ - || $0 ~ "HAVE_DEV_ATTR_MAX_SEND_SGE" \ - || $0 ~ "HAVE_IB_DMA_MAP_OPS" \ - || $0 ~ "HAVE_IB_QUERY_DEVICE" \ - || $0 ~ "HAVE_IB_SET_CPI_RESP_TIME" \ - || $0 ~ "HAVE_RDMA_DESTROY_AH" \ - || $0 ~ "HAVE_RDMA_DESTROY_AH_WITH_FLAGS" \ - || $0 ~ "HAVE_RDMA_QUERY_GID" \ - || $0 ~ "HAVE_STRUCT_SRP_LOGIN_REQ_RDMA" \ - || $0 ~ "IB_CLIENT_REMOVE_TAKES_TWO_ARGS" \ - || $0 ~ "IB_CM_LISTEN_TAKES_FOURTH_ARG" \ - || $0 ~ "IB_CREATE_CQ_HAS_INIT_ATTR" \ - || $0 ~ "IB_PD_HAS_LOCAL_DMA_LKEY" \ - || $0 ~ "IB_QUERY_GID_HAS_ATTR_ARG" \ - || $0 ~ "INSIDE_KERNEL_TREE" \ - || $0 ~ "MAD_HANDLER_TAKES_SEND_BUF" \ - || $0 ~ "MOFED_MAJOR" \ - || $0 ~ "MOFED_MINOR" \ - || $0 ~ "RDMA_CREATE_ID_TAKES_NET_ARG" \ - || $0 ~ "REGISTER_MAD_AGENT_HAS_FLAGS_ARG" \ - || $0 ~ "RHEL_MAJOR" \ - || $0 ~ "RHEL_MINOR" \ - || $0 ~ "RHEL_RELEASE_CODE" \ - || $0 ~ "SOCK_RECVMSG_HAS_FOUR_ARGS" \ - || $0 ~ "UEK_KABI_RENAME" \ - || $0 ~ "USE_PRE_440_WR_STRUCTURE" \ - || generating_upstream_patch_defined \ - && $0 ~ "GENERATING_UPSTREAM_PATCH" \ - || $0 ~ "CONFIG_TCP_ZERO_COPY_TRANSFER_COMPLETION_NOTIFICATION" \ - || ($0 ~ "CONFIG_SCST_PROC" && config_scst_proc_undefined) \ + if ($0 ~ "LINUX_VERSION_CODE" \ + || $0 ~ "CONFIG_SCST_PROC" \ + || $0 ~ "CONFIG_SCST_STRICT_SERIALIZING" \ + || $0 ~ "CREATE_SEND_MAD_HAS_BASE_ARG" \ + || $0 ~ "ENABLE_NPIV" \ + || $0 ~ "FC_VPORT_CREATE_DEFINED" \ + || $0 ~ "HAVE_DEV_ATTR_MAX_RECV_SGE" \ + || $0 ~ "HAVE_DEV_ATTR_MAX_SEND_SGE" \ + || $0 ~ "HAVE_IB_DMA_MAP_OPS" \ + || $0 ~ "HAVE_IB_QUERY_DEVICE" \ + || $0 ~ "HAVE_IB_SET_CPI_RESP_TIME" \ + || $0 ~ "HAVE_RDMA_DESTROY_AH" \ + || $0 ~ "HAVE_RDMA_DESTROY_AH_WITH_FLAGS" \ + || $0 ~ "HAVE_RDMA_QUERY_GID" \ + || $0 ~ "HAVE_SRP_DATA_DESC_IMM" \ + || $0 ~ "HAVE_STRUCT_SRP_LOGIN_REQ_RDMA" \ + || $0 ~ "IB_CLIENT_REMOVE_TAKES_TWO_ARGS" \ + || $0 ~ "IB_CM_LISTEN_TAKES_FOURTH_ARG" \ + || $0 ~ "IB_CREATE_CQ_HAS_INIT_ATTR" \ + || $0 ~ "IB_PD_HAS_LOCAL_DMA_LKEY" \ + || $0 ~ "IB_QUERY_GID_HAS_ATTR_ARG" \ + || $0 ~ "INSIDE_KERNEL_TREE" \ + || $0 ~ "MAD_HANDLER_TAKES_SEND_BUF" \ + || $0 ~ "MOFED_MAJOR" \ + || $0 ~ "MOFED_MINOR" \ + || $0 ~ "RDMA_CREATE_ID_TAKES_NET_ARG" \ + || $0 ~ "REGISTER_MAD_AGENT_HAS_FLAGS_ARG" \ + || $0 ~ "RHEL_MAJOR" \ + || $0 ~ "RHEL_MINOR" \ + || $0 ~ "RHEL_RELEASE_CODE" \ + || $0 ~ "SOCK_RECVMSG_HAS_FOUR_ARGS" \ + || $0 ~ "UEK_KABI_RENAME" \ + || $0 ~ "USE_PRE_440_WR_STRUCTURE" \ + || generating_upstream_patch_defined \ + && $0 ~ "GENERATING_UPSTREAM_PATCH" \ + || $0 ~ "CONFIG_TCP_ZERO_COPY_TRANSFER_COMPLETION_NOTIFICATION" \ + || ($0 ~ "CONFIG_SCST_PROC" && config_scst_proc_undefined) \ || ($0 ~ "SCSI_EXEC_REQ_FIFO_DEFINED" && SCSI_EXEC_REQ_FIFO_DEFINED!="") \ || ($0 ~ "SCST_IO_CONTEXT" && SCST_IO_CONTEXT != "")) { From ac145e1cb6a5ea21671c3b8f6546948fda1d7c77 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 8 Nov 2019 21:28:37 +0000 Subject: [PATCH 3/3] ib_srpt: Detect ib_sg_dma_len() presence at compile time This patch makes it possible to build the ib_srpt driver against a kernel before v5.1 + latest MOFED. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@8655 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scripts/specialize-patch | 4 ++++ scst/include/backport.h | 5 ----- srpt/Makefile | 5 +++++ srpt/conftest/ib_sg_dma_len/Makefile | 3 +++ srpt/conftest/ib_sg_dma_len/ib_sg_dma_len.c | 11 +++++++++++ srpt/src/ib_srpt.h | 5 +++++ 6 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 srpt/conftest/ib_sg_dma_len/Makefile create mode 100644 srpt/conftest/ib_sg_dma_len/ib_sg_dma_len.c diff --git a/scripts/specialize-patch b/scripts/specialize-patch index 26bd3dfc1..e75c60c46 100755 --- a/scripts/specialize-patch +++ b/scripts/specialize-patch @@ -148,6 +148,9 @@ function evaluate(stmnt, pattern, arg, op, result) { gsub("defined\\(HAVE_IB_DMA_MAP_OPS\\)", "(LINUX_VERSION_CODE >= KERNEL_VERSION(0, 0, 0))", stmnt) + gsub("defined\\(HAVE_IB_SG_DMA_LEN\\)", + "(LINUX_VERSION_CODE < KERNEL_VERSION(5, 1, 0))", stmnt) + gsub("defined(ENABLE_NPIV)", 0, stmnt) gsub("defined(FC_VPORT_CREATE_DEFINED)", 0, stmnt) @@ -398,6 +401,7 @@ function handle_if(evaluated) || $0 ~ "HAVE_IB_DMA_MAP_OPS" \ || $0 ~ "HAVE_IB_QUERY_DEVICE" \ || $0 ~ "HAVE_IB_SET_CPI_RESP_TIME" \ + || $0 ~ "HAVE_IB_SG_DMA_LEN" \ || $0 ~ "HAVE_RDMA_DESTROY_AH" \ || $0 ~ "HAVE_RDMA_DESTROY_AH_WITH_FLAGS" \ || $0 ~ "HAVE_RDMA_QUERY_GID" \ diff --git a/scst/include/backport.h b/scst/include/backport.h index 7f8bb03a7..6df7ca081 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -1588,11 +1588,6 @@ static inline struct ib_pd *ib_alloc_pd_backport(struct ib_device *device) }) #endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0) -#define ib_sg_dma_len(dev, sg) sg_dma_len(sg) -#define ib_sg_dma_address(dev, sg) sg_dma_address(sg) -#endif - /* */ #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24) || \ diff --git a/srpt/Makefile b/srpt/Makefile index ced096d17..65d562afd 100644 --- a/srpt/Makefile +++ b/srpt/Makefile @@ -212,6 +212,11 @@ conftest/ib_set_cpi_resp_time/result-$(KVER).txt: \ echo "$(call run_conftest,ib_set_cpi_resp_time, \ -DHAVE_IB_SET_CPI_RESP_TIME)" >"$@" +conftest/ib_sg_dma_len/result-$(KVER).txt: \ + conftest/ib_sg_dma_len/ib_sg_dma_len.c \ + conftest/ib_sg_dma_len/Makefile + echo "$(call run_conftest_bool,ib_sg_dma_len,HAVE_IB_SG_DMA_LEN)" >"$@" + conftest/mad_handler_takes_send_buf/result-$(KVER).txt: \ conftest/mad_handler_takes_send_buf/mad_handler_takes_send_buf.c\ conftest/mad_handler_takes_send_buf/Makefile diff --git a/srpt/conftest/ib_sg_dma_len/Makefile b/srpt/conftest/ib_sg_dma_len/Makefile new file mode 100644 index 000000000..199542f31 --- /dev/null +++ b/srpt/conftest/ib_sg_dma_len/Makefile @@ -0,0 +1,3 @@ +LINUXINCLUDE := $(PRE_CFLAGS) $(LINUXINCLUDE) + +obj-m += ib_sg_dma_len.o diff --git a/srpt/conftest/ib_sg_dma_len/ib_sg_dma_len.c b/srpt/conftest/ib_sg_dma_len/ib_sg_dma_len.c new file mode 100644 index 000000000..4ac94b31c --- /dev/null +++ b/srpt/conftest/ib_sg_dma_len/ib_sg_dma_len.c @@ -0,0 +1,11 @@ +#include +#include + +#undef ib_sg_dma_len + +static int modinit(void) +{ + return ib_sg_dma_len != NULL; +} + +module_init(modinit); diff --git a/srpt/src/ib_srpt.h b/srpt/src/ib_srpt.h index 2af8422ba..ce680261a 100644 --- a/srpt/src/ib_srpt.h +++ b/srpt/src/ib_srpt.h @@ -66,6 +66,11 @@ struct srpt_nexus; +#if !HAVE_IB_SG_DMA_LEN +#define ib_sg_dma_len(dev, sg) sg_dma_len(sg) +#define ib_sg_dma_address(dev, sg) sg_dma_address(sg) +#endif + #if !HAVE_SRP_DATA_DESC_IMM enum { SRP_DATA_DESC_IMM = 3,