From patchwork Wed Jan 3 21:39:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10143505 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9204860594 for ; Wed, 3 Jan 2018 21:40:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 859452936B for ; Wed, 3 Jan 2018 21:40:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7AC0529371; Wed, 3 Jan 2018 21:40:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF17B2936B for ; Wed, 3 Jan 2018 21:40:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751099AbeACVkN (ORCPT ); Wed, 3 Jan 2018 16:40:13 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:15633 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751134AbeACVjk (ORCPT ); Wed, 3 Jan 2018 16:39:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1515015580; x=1546551580; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=/soJriLxm61nev91CUfh4kytlXNd6zGSgtTv0tw+6C8=; b=YLIzEyBuRCUV0wpYwgFWO0kkGe1KdG31mnb62woTcaDYo+K//7pn3gpb W9LeQFuVFucb9Hsg+TMa1cB4TMFhoiRNCrqRhmyIl5O0rCX1pFzr3bK1V X1vdwaZQnIp4nRCvbh61Ijxxf48Tj+vIYDeROsZ2owbFHM0RRHm+WJ/a0 b2JtaH7koP76BLGxP7clWSIi1PDj15rEtUs/P1AdG4zKZbKSkZPT/iFBP tMgtIRHjkETo+H0Kl9n2BT9d29BUjCt7CVFDFVyi0be/97uKjzhBS3fsT rEgTqpUnOI7ScuPTVuOnoX8e4lV/qfP1dOh6tfUz5kOspS+mG7C620GDY g==; X-IronPort-AV: E=Sophos;i="5.45,504,1508774400"; d="scan'208";a="67691794" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 04 Jan 2018 05:39:39 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 03 Jan 2018 13:35:48 -0800 Received: from thinkpad-bart.sdcorp.global.sandisk.com (HELO thinkpad-bart.int.fusionio.com) ([10.11.171.236]) by uls-op-cesaip02.wdc.com with ESMTP; 03 Jan 2018 13:39:39 -0800 From: Bart Van Assche To: Jason Gunthorpe Cc: Doug Ledford , linux-rdma@vger.kernel.org, Bart Van Assche Subject: [PATCH 03/28] IB/srp: Refactor srp_send_req() Date: Wed, 3 Jan 2018 13:39:13 -0800 Message-Id: <20180103213938.11664-4-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180103213938.11664-1-bart.vanassche@wdc.com> References: <20180103213938.11664-1-bart.vanassche@wdc.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch does not change any functionality but makes the next patch in this series easier to read. Signed-off-by: Bart Van Assche --- drivers/infiniband/ulp/srp/ib_srp.c | 65 +++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index fec6e800adf4..9472f5989d27 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -738,35 +738,21 @@ static int srp_send_req(struct srp_rdma_ch *ch, bool multich) struct ib_cm_req_param param; struct srp_login_req priv; } *req = NULL; + char *ipi, *tpi; int status; - u8 subnet_timeout; - - subnet_timeout = srp_get_subnet_timeout(target->srp_host); req = kzalloc(sizeof *req, GFP_KERNEL); if (!req) return -ENOMEM; - req->param.primary_path = &ch->path; - req->param.alternate_path = NULL; - req->param.service_id = target->service_id; - req->param.qp_num = ch->qp->qp_num; - req->param.qp_type = ch->qp->qp_type; - req->param.private_data = &req->priv; - req->param.private_data_len = sizeof req->priv; req->param.flow_control = 1; - - get_random_bytes(&req->param.starting_psn, 4); - req->param.starting_psn &= 0xffffff; + req->param.retry_count = target->tl_retry_count; /* * Pick some arbitrary defaults here; we could make these * module parameters if anyone cared about setting them. */ req->param.responder_resources = 4; - req->param.remote_cm_response_timeout = subnet_timeout + 2; - req->param.local_cm_response_timeout = subnet_timeout + 2; - req->param.retry_count = target->tl_retry_count; req->param.rnr_retry_count = 7; req->param.max_cm_retries = 15; @@ -777,6 +763,28 @@ static int srp_send_req(struct srp_rdma_ch *ch, bool multich) SRP_BUF_FORMAT_INDIRECT); req->priv.req_flags = (multich ? SRP_MULTICHAN_MULTI : SRP_MULTICHAN_SINGLE); + + { + u8 subnet_timeout; + + subnet_timeout = srp_get_subnet_timeout(target->srp_host); + + req->param.primary_path = &ch->path; + req->param.alternate_path = NULL; + req->param.service_id = target->service_id; + get_random_bytes(&req->param.starting_psn, 4); + req->param.starting_psn &= 0xffffff; + req->param.qp_num = ch->qp->qp_num; + req->param.qp_type = ch->qp->qp_type; + req->param.local_cm_response_timeout = subnet_timeout + 2; + req->param.remote_cm_response_timeout = subnet_timeout + 2; + req->param.private_data = &req->priv; + req->param.private_data_len = sizeof(req->priv); + + ipi = req->priv.initiator_port_id; + tpi = req->priv.target_port_id; + } + /* * In the published SRP specification (draft rev. 16a), the * port identifier format is 8 bytes of ID extension followed @@ -787,19 +795,15 @@ static int srp_send_req(struct srp_rdma_ch *ch, bool multich) * recognized by the I/O Class they report. */ if (target->io_class == SRP_REV10_IB_IO_CLASS) { - memcpy(req->priv.initiator_port_id, - &target->sgid.global.interface_id, 8); - memcpy(req->priv.initiator_port_id + 8, - &target->initiator_ext, 8); - memcpy(req->priv.target_port_id, &target->ioc_guid, 8); - memcpy(req->priv.target_port_id + 8, &target->id_ext, 8); + memcpy(ipi, &target->sgid.global.interface_id, 8); + memcpy(ipi + 8, &target->initiator_ext, 8); + memcpy(tpi, &target->ioc_guid, 8); + memcpy(tpi + 8, &target->id_ext, 8); } else { - memcpy(req->priv.initiator_port_id, - &target->initiator_ext, 8); - memcpy(req->priv.initiator_port_id + 8, - &target->sgid.global.interface_id, 8); - memcpy(req->priv.target_port_id, &target->id_ext, 8); - memcpy(req->priv.target_port_id + 8, &target->ioc_guid, 8); + memcpy(ipi, &target->initiator_ext, 8); + memcpy(ipi + 8, &target->sgid.global.interface_id, 8); + memcpy(tpi, &target->id_ext, 8); + memcpy(tpi + 8, &target->ioc_guid, 8); } /* @@ -812,9 +816,8 @@ static int srp_send_req(struct srp_rdma_ch *ch, bool multich) PFX "Topspin/Cisco initiator port ID workaround " "activated for target GUID %016llx\n", be64_to_cpu(target->ioc_guid)); - memset(req->priv.initiator_port_id, 0, 8); - memcpy(req->priv.initiator_port_id + 8, - &target->srp_host->srp_dev->dev->node_guid, 8); + memset(ipi, 0, 8); + memcpy(ipi + 8, &target->srp_host->srp_dev->dev->node_guid, 8); } status = ib_send_cm_req(ch->cm_id, &req->param);