From ac0de9d4859710838bcd5f834787bc1932db8cf9 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 25 May 2020 18:19:45 +0000 Subject: [PATCH] ib_srpt: Limit the number of scatter/gather elements in RDMA READs to max_sge_rd Additionally, declare the max_sge_delta parameter obsolete. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@8983 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- srpt/README | 8 -------- srpt/src/ib_srpt.c | 46 ++-------------------------------------------- 2 files changed, 2 insertions(+), 52 deletions(-) diff --git a/srpt/README b/srpt/README index 9c6fe1f66..334fb5fcc 100644 --- a/srpt/README +++ b/srpt/README @@ -39,14 +39,6 @@ Building and installing the SRP target driver is possible as follows: The ib_srpt kernel module supports the following parameters: -* max_sge_delta (unsigned): Number to subtract from max_sge. Some but not - all HCA's allow to use up to max_sge S/G-list elements in RDMA - communication. The default value of this parameter is 3 and works with all - HCA's. If you know that the HCA's that are used by the ib_srpt driver allow - to use S/G-lists that are longer than max_sge - 3 then you can decrease this - parameter. Note: setting this parameter too low will cause SRP every login - to fail and will cause a message similar to the following to be logged on - the target system: "ib_srpt: RDMA t ... for idx ... failed with status 12". * rdma_cm_port (number) A 16-bit number that specifies the port number to be registered via the RDMA/CM. Must be specified to make communication over RoCE or iWARP diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index 1f3d31441..30820bfe7 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -166,7 +166,7 @@ MODULE_PARM_DESC(srpt_service_guid, static unsigned int max_sge_delta = 0; module_param(max_sge_delta, uint, 0444); -MODULE_PARM_DESC(max_sge_delta, "Number to subtract from max_sge."); +MODULE_PARM_DESC(max_sge_delta, "Number to subtract from max_sge (obsolete)."); /* * Note: changing any of the two constants below into SCST_CONTEXT_DIRECT is @@ -2340,49 +2340,6 @@ retry: #else ch->max_send_sge = sdev->dev_attr.max_sge; #endif - if (max_sge_delta == 0) { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0) - /* - * See also commit b9560a419bfd ("RDMA: Move driver_id into - * struct ib_device_ops") # v5.3. - */ - switch (sdev->device->ops.driver_id) { - case RDMA_DRIVER_MLX4: - /* - * The smallest max_sge_delta value that works with - * ConnectX-3 firmware version 2.42.5000. - */ - max_sge_delta = 2; - break; - case RDMA_DRIVER_MTHCA: - /* - * From the OFED release notes: In mem-free devices, RC - * QPs can be created with a maximum of (max_sge - 1) - * entries only. See also - * https://git.openfabrics.org/?p=compat-rdma/docs.git;a=blob;f=release_notes/mthca_release_notes.txt;h=40f3c4ea77a07fe5ded888b8417530471e89d87b;hb=1ebd1b1dd5b413be595a835bbcb644d2c8897f98. - */ - max_sge_delta = 1; - break; - default: - break; - } -#else - if (strncmp(dev_name(&sdev->device->dev), "mlx4_", 5) == 0) - max_sge_delta = 2; - else if (strncmp(dev_name(&sdev->device->dev), "mthca", 5) == 0) - max_sge_delta = 1; -#endif - pr_debug("max_sge_delta = %d\n", max_sge_delta); - } - /* - * For max_sge values > 2 * max_sge_delta, subtract max_sge_delta. For - * max_sge values < max_sge_delta, use max_sge. For intermediate - * max_sge values, use max_sge_delta. - */ - ch->max_send_sge -= - min_t(unsigned, max_sge_delta, - max_t(int, 0, - ch->max_send_sge - max_sge_delta)); qp_init->cap.max_send_sge = ch->max_send_sge; qp_init->cap.max_recv_sge = 1; if (sdev->use_srq) { @@ -3306,6 +3263,7 @@ static int srpt_map_sg_to_ib_sge(struct srpt_rdma_ch *ch, if (dir == SCST_DATA_WRITE) { scst_cmd_get_write_fields(cmd, &sg, &sg_cnt); WARN_ON(!sg); + max_sge = min(max_sge, ch->sport->sdev->dev_attr.max_sge_rd); } else { sg = scst_cmd_get_sg(cmd); sg_cnt = scst_cmd_get_sg_cnt(cmd);