From patchwork Wed Jan 3 21:39:34 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: 10143489 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 7A88C6063B 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 6DE6029361 for ; Wed, 3 Jan 2018 21:40:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 62DAF2936D; 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 D4A672936B for ; Wed, 3 Jan 2018 21:40:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751298AbeACVkE (ORCPT ); Wed, 3 Jan 2018 16:40:04 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:36547 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751295AbeACVjo (ORCPT ); Wed, 3 Jan 2018 16:39:44 -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=1515015584; x=1546551584; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=ePq+3AvW5d3FsubMWCf0iVcUDn9Y9Y5IFOhMCYiJdfs=; b=Cy3QFau7D+pl7st2qCB9zPg/PcsQvPgiv2dwIurhKjPlAAWLo+xutPq5 kQGIbfHiPJyidJYOqSzpO6/ootAthGx1pt++RpaT7bWI7sR8u8HXzDT6f jLoENlOZ/vDh+dWaQ7X0qhShJ8SDLQ1+YH9PRXBxKbsIIwsbOfKB21NzQ m8Pp57b2sdgUSZGHo3hRCgmeQGWNNzoXI40soYLwRaXExd3OBVWAGTj+R 9jVMZhYQfQoIM5+ehFEdjCX1+D6sjk3Wtif4PNZb/Jo3U0ilyvaHTZ78h STCZY1c0v3ih0zDi2iJBjNbYsGT++CVuNuVgkYdLG3NQ/o3qIRMBTM748 A==; X-IronPort-AV: E=Sophos;i="5.45,504,1508774400"; d="scan'208";a="68160083" 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 24/28] IB/srpt: Prepare RDMA/CM support Date: Wed, 3 Jan 2018 13:39:34 -0800 Message-Id: <20180103213938.11664-25-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 Introduce a union in struct srpt_rdma_ch for member variables that depend on the type of connection manager. Avoid that error messages report the IB/CM ID. Signed-off-by: Bart Van Assche --- drivers/infiniband/ulp/srpt/ib_srpt.c | 38 +++++++++++++++++------------------ drivers/infiniband/ulp/srpt/ib_srpt.h | 8 ++++++-- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c index b6544112a321..8c67cbff93b6 100644 --- a/drivers/infiniband/ulp/srpt/ib_srpt.c +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c @@ -209,12 +209,12 @@ static const char *get_ch_state_name(enum rdma_ch_state s) */ static void srpt_qp_event(struct ib_event *event, struct srpt_rdma_ch *ch) { - pr_debug("QP event %d on cm_id=%p sess_name=%s state=%d\n", - event->event, ch->cm_id, ch->sess_name, ch->state); + pr_debug("QP event %d on ch=%p sess_name=%s state=%d\n", + event->event, ch, ch->sess_name, ch->state); switch (event->event) { case IB_EVENT_COMM_EST: - ib_cm_notify(ch->cm_id, event->event); + ib_cm_notify(ch->ib_cm.cm_id, event->event); break; case IB_EVENT_QP_LAST_WQE_REACHED: pr_debug("%s-%d, state %s: received Last WQE event.\n", @@ -1043,7 +1043,7 @@ static int srpt_ch_qp_rtr(struct srpt_rdma_ch *ch, struct ib_qp *qp) int ret; qp_attr.qp_state = IB_QPS_RTR; - ret = ib_cm_init_qp_attr(ch->cm_id, &qp_attr, &attr_mask); + ret = ib_cm_init_qp_attr(ch->ib_cm.cm_id, &qp_attr, &attr_mask); if (ret) goto out; @@ -1073,7 +1073,7 @@ static int srpt_ch_qp_rts(struct srpt_rdma_ch *ch, struct ib_qp *qp) int ret; qp_attr.qp_state = IB_QPS_RTS; - ret = ib_cm_init_qp_attr(ch->cm_id, &qp_attr, &attr_mask); + ret = ib_cm_init_qp_attr(ch->ib_cm.cm_id, &qp_attr, &attr_mask); if (ret) goto out; @@ -1443,9 +1443,9 @@ static void srpt_handle_tsk_mgmt(struct srpt_rdma_ch *ch, srp_tsk = recv_ioctx->ioctx.buf; cmd = &send_ioctx->cmd; - pr_debug("recv tsk_mgmt fn %d for task_tag %lld and cmd tag %lld" - " cm_id %p sess %p\n", srp_tsk->tsk_mgmt_func, - srp_tsk->task_tag, srp_tsk->tag, ch->cm_id, ch->sess); + pr_debug("recv tsk_mgmt fn %d for task_tag %lld and cmd tag %lld ch %p sess %p\n", + srp_tsk->tsk_mgmt_func, srp_tsk->task_tag, srp_tsk->tag, ch, + ch->sess); srpt_set_cmd_state(send_ioctx, SRPT_STATE_MGMT); send_ioctx->cmd.tag = srp_tsk->tag; @@ -1683,9 +1683,9 @@ static int srpt_create_ch_ib(struct srpt_rdma_ch *ch) atomic_set(&ch->sq_wr_avail, qp_init->cap.max_send_wr); - pr_debug("%s: max_cqe= %d max_sge= %d sq_size = %d cm_id= %p\n", + pr_debug("%s: max_cqe= %d max_sge= %d sq_size = %d ch= %p\n", __func__, ch->cq->cqe, qp_init->cap.max_send_sge, - qp_init->cap.max_send_wr, ch->cm_id); + qp_init->cap.max_send_wr, ch); ret = srpt_init_ch_qp(ch, ch->qp); if (ret) @@ -1771,9 +1771,9 @@ static int srpt_disconnect_ch(struct srpt_rdma_ch *ch) if (!srpt_set_ch_state(ch, CH_DISCONNECTING)) return -ENOTCONN; - ret = ib_send_cm_dreq(ch->cm_id, NULL, 0); + ret = ib_send_cm_dreq(ch->ib_cm.cm_id, NULL, 0); if (ret < 0) - ret = ib_send_cm_drep(ch->cm_id, NULL, 0); + ret = ib_send_cm_drep(ch->ib_cm.cm_id, NULL, 0); if (ret < 0 && srpt_close_ch(ch)) ret = 0; @@ -1933,7 +1933,7 @@ static void srpt_release_channel_work(struct work_struct *w) transport_deregister_session(se_sess); ch->sess = NULL; - ib_destroy_cm_id(ch->cm_id); + ib_destroy_cm_id(ch->ib_cm.cm_id); srpt_destroy_ch_ib(ch); @@ -1973,7 +1973,7 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id, struct srp_login_rej *rej = NULL; struct ib_cm_rep_param *rep_param = NULL; struct srpt_rdma_ch *ch; - char *ini_guid, i_port_id[36]; + char *ini_id, i_port_id[36]; u32 it_iu_len; int i, ret; @@ -2045,7 +2045,7 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id, 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->cm_id = cm_id; + ch->ib_cm.cm_id = cm_id; cm_id->context = ch; /* * ch->rq_size should be at least as large as the initiator queue @@ -2096,7 +2096,7 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id, srpt_format_guid(ch->sess_name, sizeof(ch->sess_name), ¶m->primary_path->dgid.global.interface_id); - ini_guid = ch->sess_name; + ini_id = 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))); @@ -2105,7 +2105,7 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id, if (sport->port_guid_tpg.se_tpg_wwn) ch->sess = target_alloc_session(&sport->port_guid_tpg, 0, 0, - TARGET_PROT_NORMAL, ini_guid, + TARGET_PROT_NORMAL, ini_id, ch, NULL); if (sport->port_gid_tpg.se_tpg_wwn && IS_ERR_OR_NULL(ch->sess)) ch->sess = target_alloc_session(&sport->port_gid_tpg, 0, 0, @@ -2165,8 +2165,8 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id, goto destroy_ib; } - pr_debug("Establish connection sess=%p name=%s cm_id=%p\n", ch->sess, - ch->sess_name, ch->cm_id); + pr_debug("Establish connection sess=%p name=%s ch=%p\n", ch->sess, + ch->sess_name, ch); /* create srp_login_response */ rsp->opcode = SRP_LOGIN_RSP; diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.h b/drivers/infiniband/ulp/srpt/ib_srpt.h index 0ffb95cb117f..2e40e6574dca 100644 --- a/drivers/infiniband/ulp/srpt/ib_srpt.h +++ b/drivers/infiniband/ulp/srpt/ib_srpt.h @@ -243,8 +243,8 @@ enum rdma_ch_state { /** * struct srpt_rdma_ch - RDMA channel. * @nexus: I_T nexus this channel is associated with. - * @cm_id: IB CM ID associated with the channel. * @qp: IB queue pair used for communicating over this channel. + * @cm_id: IB CM ID associated with the channel. * @cq: IB completion queue for this channel. * @zw_cqe: Zero-length write CQE. * @rcu: RCU head. @@ -274,8 +274,12 @@ enum rdma_ch_state { */ struct srpt_rdma_ch { struct srpt_nexus *nexus; - struct ib_cm_id *cm_id; struct ib_qp *qp; + union { + struct { + struct ib_cm_id *cm_id; + } ib_cm; + }; struct ib_cq *cq; struct ib_cqe zw_cqe; struct rcu_head rcu;