From patchwork Wed Jan 3 21:39:35 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: 10143487 X-Patchwork-Delegate: dledford@redhat.com 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 3DF2F60594 for ; Wed, 3 Jan 2018 21:40:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3197A29361 for ; Wed, 3 Jan 2018 21:40:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 26BC729371; Wed, 3 Jan 2018 21:40:06 +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 A589429361 for ; Wed, 3 Jan 2018 21:40:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751297AbeACVkD (ORCPT ); Wed, 3 Jan 2018 16:40:03 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:21282 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751260AbeACVjp (ORCPT ); Wed, 3 Jan 2018 16:39:45 -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=1515015585; x=1546551585; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=EqNFJyy7/Hv3DoVCzj4E8zFQGbhU4/qsCf22qtod5lw=; b=eVNS98pk6UX9WtlXxPOz9oruI23GE0mdHO3FLUgXes6QWnLPAwOFirlq jbQmFlKPJOjx7sZZoDdtV34dGfZgBhtnV9nMpecZAd72uV68+t+CrzDI/ +EvvN3QYA7XRwSHUWf2eeg7jIJSxaMFWQ5Cg6RmdwpBJt8Sh06MoqQQcz AiJ4wEDgTD1RSkdL6Wb092JRKehGT0KywVzg0QZ4KI2zZ+4LwvWt5OTMP UQJ3PqXRkpc8iCO0DIJ3TCT8DNdb1XwPhEZ/bqcSTj5UqzHKm5VTdvIxA NsLPBFs24b/8ogBMjA+9MbQDrBX7A7pazhBstfdjOb88Gss8RzDnCZVPi A==; X-IronPort-AV: E=Sophos;i="5.45,504,1508774400"; d="scan'208";a="68160084" 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:42 +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:51 -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:42 -0800 From: Bart Van Assche To: Jason Gunthorpe Cc: Doug Ledford , linux-rdma@vger.kernel.org, Bart Van Assche Subject: [PATCH 25/28] IB/srpt: Move the code for parsing struct ib_cm_req_event_param Date: Wed, 3 Jan 2018 13:39:35 -0800 Message-Id: <20180103213938.11664-26-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 srpt_cm_req_recv() independent of the IB/CM and hence simplifies the patch that introduces RDMA/CM support. Signed-off-by: Bart Van Assche --- drivers/infiniband/ulp/srpt/ib_srpt.c | 48 +++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c index 8c67cbff93b6..e222794ec1aa 100644 --- a/drivers/infiniband/ulp/srpt/ib_srpt.c +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c @@ -1962,34 +1962,31 @@ static void srpt_release_channel_work(struct work_struct *w) * functions returns zero. Otherwise the caller remains the owner of cm_id. */ static int srpt_cm_req_recv(struct ib_cm_id *cm_id, - struct ib_cm_req_event_param *param, - void *private_data) + u8 port_num, __be16 pkey, + const struct srp_login_req *req, + const char *sess_name, const char *ini_id) { struct srpt_device *sdev = cm_id->context; - struct srpt_port *sport = &sdev->port[param->port - 1]; + struct srpt_port *sport = &sdev->port[port_num - 1]; struct srpt_nexus *nexus; - struct srp_login_req *req; struct srp_login_rsp *rsp = NULL; struct srp_login_rej *rej = NULL; struct ib_cm_rep_param *rep_param = NULL; struct srpt_rdma_ch *ch; - char *ini_id, i_port_id[36]; + char i_port_id[36]; u32 it_iu_len; int i, ret; WARN_ON_ONCE(irqs_disabled()); - if (WARN_ON(!sdev || !private_data)) + if (WARN_ON(!sdev || !req)) return -EINVAL; - req = (struct srp_login_req *)private_data; - it_iu_len = be32_to_cpu(req->req_it_iu_len); pr_info("Received SRP_LOGIN_REQ with i_port_id %pI6, t_port_id %pI6 and it_iu_len %d on port %d (guid=%pI6); pkey %#04x\n", req->initiator_port_id, req->target_port_id, it_iu_len, - param->port, &sport->gid, - be16_to_cpu(param->primary_path->pkey)); + port_num, &sport->gid, be16_to_cpu(pkey)); nexus = srpt_get_nexus(sport, req->initiator_port_id, req->target_port_id); @@ -2017,7 +2014,7 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id, if (!sport->enabled) { rej->reason = cpu_to_be32(SRP_LOGIN_REJ_INSUFFICIENT_RESOURCES); pr_info("rejected SRP_LOGIN_REQ because target port %s_%d has not yet been enabled\n", - sport->sdev->device->name, param->port); + sport->sdev->device->name, port_num); goto reject; } @@ -2040,11 +2037,11 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id, init_rcu_head(&ch->rcu); kref_init(&ch->kref); - ch->pkey = be16_to_cpu(param->primary_path->pkey); + ch->pkey = be16_to_cpu(pkey); ch->nexus = nexus; ch->zw_cqe.done = srpt_zerolength_write_done; INIT_WORK(&ch->release_work, srpt_release_channel_work); - ch->sport = &sdev->port[param->port - 1]; + ch->sport = sport; ch->ib_cm.cm_id = cm_id; cm_id->context = ch; /* @@ -2094,9 +2091,7 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id, goto free_recv_ring; } - srpt_format_guid(ch->sess_name, sizeof(ch->sess_name), - ¶m->primary_path->dgid.global.interface_id); - ini_id = ch->sess_name; + strlcpy(ch->sess_name, ini_id, sizeof(ch->sess_name)); snprintf(i_port_id, sizeof(i_port_id), "0x%016llx%016llx", be64_to_cpu(*(__be64 *)nexus->i_port_id), be64_to_cpu(*(__be64 *)(nexus->i_port_id + 8))); @@ -2150,7 +2145,7 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id, rej->reason = cpu_to_be32( SRP_LOGIN_REJ_INSUFFICIENT_RESOURCES); pr_info("rejected SRP_LOGIN_REQ because target %s_%d is not enabled\n", - sdev->device->name, param->port); + sdev->device->name, port_num); mutex_unlock(&sport->mutex); goto reject; } @@ -2253,6 +2248,21 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id, return ret; } +static int srpt_ib_cm_req_recv(struct ib_cm_id *cm_id, + struct ib_cm_req_event_param *param, + void *private_data) +{ + char sess_name[40], ini_id[40]; + + snprintf(sess_name, sizeof(sess_name), "%pI6", + ¶m->primary_path->dgid); + srpt_format_guid(ini_id, sizeof(ini_id), + ¶m->primary_path->dgid.global.interface_id); + + return srpt_cm_req_recv(cm_id, param->port, param->primary_path->pkey, + private_data, sess_name, ini_id); +} + static void srpt_cm_rej_recv(struct srpt_rdma_ch *ch, enum ib_cm_rej_reason reason, const u8 *private_data, @@ -2322,8 +2332,8 @@ static int srpt_cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event) ret = 0; switch (event->event) { case IB_CM_REQ_RECEIVED: - ret = srpt_cm_req_recv(cm_id, &event->param.req_rcvd, - event->private_data); + ret = srpt_ib_cm_req_recv(cm_id, &event->param.req_rcvd, + event->private_data); break; case IB_CM_REJ_RECEIVED: srpt_cm_rej_recv(ch, event->param.rej_rcvd.reason,