From 69200308aa91120676b5fdaec91aa2f64ad5d526 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 7 Oct 2016 15:22:28 +0000 Subject: [PATCH] ib_srpt: Merge revisions 6932, 6969, 6970, 6973, 6976, 6978 and 6981 from trunk git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/3.2.x@6995 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 | 39 ++++++++++++------------ srpt/src/ib_srpt.h | 4 +-- 6 files changed, 44 insertions(+), 22 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 9a48679a2..65eba9816 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 e4cf61a4f..5ec3d7173 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -113,12 +113,12 @@ static u16 rdma_cm_port; module_param(rdma_cm_port, short, 0444); MODULE_PARM_DESC(rdma_cm_port, "Port number RDMA/CM will bind to."); -static unsigned srp_max_rdma_size = DEFAULT_MAX_RDMA_SIZE; +static unsigned int srp_max_rdma_size = DEFAULT_MAX_RDMA_SIZE; module_param(srp_max_rdma_size, int, 0644); MODULE_PARM_DESC(srp_max_rdma_size, "Maximum size of SRP RDMA transfers for new connections."); -static unsigned srp_max_req_size = DEFAULT_MAX_REQ_SIZE; +static unsigned int srp_max_req_size = DEFAULT_MAX_REQ_SIZE; module_param(srp_max_req_size, int, 0444); MODULE_PARM_DESC(srp_max_req_size, "Maximum size of SRP request messages in bytes."); @@ -181,7 +181,7 @@ MODULE_PARM_DESC(srpt_service_guid, "Using this value for ioc_guid, id_ext, and cm_listen_id" " instead of using the node_guid of the first HCA."); -static unsigned max_sge_delta = 3; +static unsigned int max_sge_delta = 3; module_param(max_sge_delta, uint, 0444); MODULE_PARM_DESC(max_sge_delta, "Number to subtract from max_sge."); @@ -599,7 +599,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) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0) && !defined(MOFED_MAJOR) struct ib_mad_send_buf *send_buf, #endif struct ib_mad_recv_wc *mad_wc) @@ -626,9 +626,8 @@ static void srpt_mad_recv_handler(struct ib_mad_agent *mad_agent, #endif 0, IB_MGMT_DEVICE_HDR, IB_MGMT_DEVICE_DATA, GFP_KERNEL -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) || \ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) && !defined(MOFED_MAJOR) || \ defined(CREATE_SEND_MAD_HAS_BASE_ARG) - , 0 #endif ); @@ -1059,7 +1058,7 @@ static int srpt_get_desc_tbl(struct srpt_recv_ioctx *recv_ioctx, { struct srp_indirect_buf *idb; struct srp_direct_buf *db; - unsigned add_cdb_offset; + unsigned int add_cdb_offset; int ret; u8 fmt; @@ -2223,7 +2222,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); @@ -2258,7 +2258,8 @@ static int srpt_create_ch_ib(struct srpt_rdma_ch *ch) */ ch->max_sge = sdev->dev_attr.max_sge - min(max_sge_delta, - max_t(unsigned, 0, sdev->dev_attr.max_sge - max_sge_delta)); + max_t(unsigned int, 0, + sdev->dev_attr.max_sge - max_sge_delta)); qp_init->cap.max_send_sge = ch->max_sge; qp_init->cap.max_recv_sge = ch->max_sge; if (sdev->use_srq) { @@ -3381,7 +3382,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) +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) || defined(MOFED_MAJOR) struct ib_send_wr wr; #else struct ib_rdma_wr wr; @@ -3406,7 +3407,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) +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) || defined(MOFED_MAJOR) if (dir == SCST_DATA_READ) { wr.opcode = IB_WR_RDMA_WRITE; wr.wr_id = encode_wr_id(i == n_rdma - 1 ? @@ -3465,7 +3466,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) +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) || defined(MOFED_MAJOR) wr.num_sge = 0; wr.wr_id = encode_wr_id(SRPT_RDMA_ABORT, ioctx->ioctx.index); wr.send_flags = IB_SEND_SIGNALED; @@ -3492,7 +3493,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) +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) || defined(MOFED_MAJOR) while (ch->state < CH_DISCONNECTED && !ioctx->rdma_aborted) { pr_info("Waiting until RDMA abort finished [%d]\n", ioctx->ioctx.index); @@ -4095,7 +4096,7 @@ static ssize_t show_port_id(struct kobject *kobj, struct kobj_attribute *attr, strcmp(sport->port_id, DEFAULT_SRPT_ID_STRING) ? SCST_SYSFS_KEY_MARK "\n" : ""); mutex_unlock(&sport->mutex); - + res = strlen(buf); out: @@ -4113,7 +4114,7 @@ static ssize_t store_port_id(struct kobject *kobj, struct kobj_attribute *attr, if (!sport) goto out; - + end = buf + count; while (end > buf && isspace(((unsigned char *)end)[-1])) --end; @@ -4328,7 +4329,7 @@ static void srpt_add_one(struct ib_device *device) sdev->device = device; -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0) +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0) || defined(MOFED_MAJOR) ret = ib_query_device(device, &sdev->dev_attr); if (ret) { pr_err("ib_query_device() failed: %d\n", ret); @@ -4416,7 +4417,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) +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0) || defined(MOFED_MAJOR) , NULL #endif ); @@ -4488,7 +4489,7 @@ err: /** * srpt_remove_one() - InfiniBand device removal callback function. */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0) +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0) || defined(MOFED_MAJOR) static void srpt_remove_one(struct ib_device *device) { void *client_data = ib_get_client_data(device, &srpt_client); @@ -4670,7 +4671,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) +#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) || defined(MOFED_MAJOR) rdma_cm_id = rdma_create_id(srpt_rdma_cm_handler, NULL, RDMA_PS_TCP, IB_QPT_RC); #else diff --git a/srpt/src/ib_srpt.h b/srpt/src/ib_srpt.h index 71f6319b8..70c2c1c4c 100644 --- a/srpt/src/ib_srpt.h +++ b/srpt/src/ib_srpt.h @@ -49,7 +49,7 @@ #include #endif #if defined(RHEL_MAJOR) && RHEL_MAJOR -0 == 5 -#define vlan_dev_vlan_id(dev) (panic("RHEL 5 misses vlan_dev_vlan_id()"),0) +#define vlan_dev_vlan_id(dev) (panic("RHEL 5 misses vlan_dev_vlan_id()"), 0) #endif #if defined(RHEL_MAJOR) && RHEL_MAJOR -0 <= 6 #define __ethtool_get_settings(dev, cmd) (panic("RHEL misses __ethtool_get_settings()"), 0) @@ -119,7 +119,7 @@ enum { SRP_LOGIN_RSP_MULTICHAN_MAINTAINED = 0x2, MIN_SRPT_SQ_SIZE = 16, - DEF_SRPT_SQ_SIZE = 4096, + DEF_SRPT_SQ_SIZE = 256, SRPT_RQ_SIZE = 128, MIN_SRPT_SRQ_SIZE = 4, DEFAULT_SRPT_SRQ_SIZE = 4095,