From patchwork Tue Jan 5 14:26:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 7955391 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 69251BEEE5 for ; Tue, 5 Jan 2016 14:26:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3F7E82037F for ; Tue, 5 Jan 2016 14:26:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 001A22037E for ; Tue, 5 Jan 2016 14:26:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751188AbcAEO0a (ORCPT ); Tue, 5 Jan 2016 09:26:30 -0500 Received: from mail-bl2on0065.outbound.protection.outlook.com ([65.55.169.65]:59968 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751487AbcAEO02 (ORCPT ); Tue, 5 Jan 2016 09:26:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sandiskcorp.onmicrosoft.com; s=selector1-sandisk-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=JxT5LndvzavwZGy9oFkD00cGI3M1+u3+wCSPkOHr2j0=; b=ILFvHWayiUw17e9nQFq9m2wklrUIXqyylvwy70ev3/VjDFsphRUnDdojEKvoQY+DeGAWgnpZSNMfllWF+dmGvXNeJsoZV2cd5R+Jyb9L9XyIIAMx2sxNEhJKbe6wkOuKRSBbYwXEjxs+KdxrlhvMV4ape5tCjoK84pk5EN8AuRw= Received: from CY1PR0201CA0033.namprd02.prod.outlook.com (10.163.30.171) by BY2PR02MB299.namprd02.prod.outlook.com (10.141.140.22) with Microsoft SMTP Server (TLS) id 15.1.361.13; Tue, 5 Jan 2016 14:26:25 +0000 Received: from BL2FFO11FD011.protection.gbl (2a01:111:f400:7c09::170) by CY1PR0201CA0033.outlook.office365.com (2a01:111:e400:58b9::43) with Microsoft SMTP Server (TLS) id 15.1.361.13 via Frontend Transport; Tue, 5 Jan 2016 14:26:24 +0000 Authentication-Results: spf=pass (sender IP is 63.163.107.172) smtp.mailfrom=sandisk.com; redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=bestguesspass action=none header.from=sandisk.com; Received-SPF: Pass (protection.outlook.com: domain of sandisk.com designates 63.163.107.172 as permitted sender) receiver=protection.outlook.com; client-ip=63.163.107.172; helo=milsmgep11.sandisk.com; Received: from milsmgep11.sandisk.com (63.163.107.172) by BL2FFO11FD011.mail.protection.outlook.com (10.173.161.17) with Microsoft SMTP Server id 15.1.355.15 via Frontend Transport; Tue, 5 Jan 2016 14:26:24 +0000 Received: from MILHUBIP03.sdcorp.global.sandisk.com ( [172.22.12.162]) by milsmgep11.sandisk.com (Symantec Messaging Gateway) with SMTP id 85.A9.20094.092DB865; Tue, 5 Jan 2016 06:26:24 -0800 (PST) Received: from milsmgip12.sandisk.com (10.177.8.100) by MILHUBIP03.sdcorp.global.sandisk.com (10.177.9.96) with Microsoft SMTP Server id 14.3.248.2; Tue, 5 Jan 2016 06:26:24 -0800 X-AuditID: ac160a68-f79196d000004e7e-26-568bd2908f58 Received: from [10.50.231.71] ( [10.177.8.100]) by milsmgip12.sandisk.com (Symantec Messaging Gateway) with SMTP id 1F.EE.20697.E82DB865; Tue, 5 Jan 2016 06:26:23 -0800 (PST) Subject: [PATCH 12/15] IB/srpt: Eliminate srpt_find_channel() To: Doug Ledford References: <568BD0FC.70207@sandisk.com> CC: Christoph Hellwig , "linux-rdma@vger.kernel.org" From: Bart Van Assche Message-ID: <568BD28E.40302@sandisk.com> Date: Tue, 5 Jan 2016 15:26:22 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 In-Reply-To: <568BD0FC.70207@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrDLMWRmVeSWpSXmKPExsWyRoxnke6ES91hBovaOC1env/AarFy9VEm i2eHelkcmD1232xg83i/7yqbx+dNcgHMUVw2Kak5mWWpRfp2CVwZpyZkFlw0q1hy7gFjA+Mx nS5GTg4JAROJvRtPskLYYhIX7q1n62Lk4hASOMEocenNNVYIZzujxOOH7ewwHbc/3mACsYUE NjNKbPjIDWILC9hKrF70gA3EFhFQk9j0ahFQPQdQjYbEu61ZIGFmgXiJdZ/eMILYbAJGEt/e z2QBsXmBSmb+XA/WyiKgIvH63hywGlGBCIkfG5YwQtQISpyc+QSsnlNAU+J/6y6w8cxA9vpd +hDj5SW2v53DDHKyhMAiVokJzztYIM5Ulzi5ZD7TBEaRWUhGzUJon4WkfQEj8ypGsdzMnOLc 9NQCQ0O94sS8lMzibL3k/NxNjOA44MrYwbh1kvkhRgEORiUeXo6XXWFCrIllxZW5hxglOJiV RHhfH+kOE+JNSaysSi3Kjy8qzUktPsQozcGiJM5r3aIWJiSQnliSmp2aWpBaBJNl4uCUamAs yX/XVz2h/15w17uAxL+BB/cejmrkdnxSqbanQunlFuUDvoylUbGhd/o/T7g6VWdS6FOJrqqL c75Hztiy655vo0ek+NspHneC5mZd/HTjK89u6TCJzPmv5bj2hsbxzN/uYGN1ZYbZjY8//hfs SPusGK//4tnLialVulav5PM+qwoln91Z++aEEktxRqKhFnNRcSIADeBn938CAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMJMWRmVeSWpSXmKPExsXCtZEjRbf/UneYwfGLxhYvz39gtVi5+iiT xbNDvSwOzB67bzawebzfd5XN4/MmuQDmKC6blNSczLLUIn27BK6MUxMyCy6aVSw594CxgfGY ThcjJ4eEgInE7Y83mCBsMYkL99azdTFycQgJbGSUaNs+gRUkISxgK7F60QM2EFtEQE1i06tF 7F2MHEBFGhLvtmaBmMwC8RJ3O8HGsAkYSXx7P5MFxOYFqpj5cz1YJ4uAisTre3MYQWxRgQiJ HxuWMELUCEqcnPkErJ5TQFPif+sudhCbWUBd4s+8S8wQtrzE9rdzmCcw8s9C0jILSdksJGUL GJlXMYrlZuYU56ZnFhga6RUn5qVkFmfrJefnbmIEByNn1A7G6xPNDzEycXBKNTDWZB5mVedZ vSGPT03JYdLmmI63/RyvpDy2fHtkUSYYpyQl/yZaaYcKl/lP6VL50MzmWEYz1wy5UhWpOJVv OVkWf1oOh/D+Oy4Xc2zfuz131JVmtNnd7TvytkPmcc3d9afksvdz8qyR/nJSyHLjFWYVpdyY YwcKX+T1z9dKu90XZ+Nh9/y8mRJLcUaioRZzUXEiAApfdEf2AQAA X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD011; 1:3v2ptOHPWFobDEJjHVYxaYq5icbOZG77zfON+q3FIoCfMY3g/V2OqS8rHqKeSOqF5wQCSt8tJvKGMQf/x3g4dEtEuhfr6sff/slVeBd5eqwE2aSfxW1FNtojQqS0K63efHR+Z0/BKLrpPw4f3mKOTsawGXbNdm03oNUXgyNtH3xKg9eac98vo0HX3kfbIx/PgFpG4uo60j/+tHpE/9xqB4PL43/gbUWfS7IUR+8VnRwbiIhgiw9jxwfhtCAp/hPWuYVSzlOb/jgQFGL1axAGLaW/yGo6lBQG9KMHpi4OkhWBuYUy1a1ATII3BK1j6koHoHEcnafYx9k0UsClkJRBMg== X-Forefront-Antispam-Report: CIP:63.163.107.172; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(438002)(199003)(189002)(47776003)(50986999)(11100500001)(76176999)(5008740100001)(1220700001)(65956001)(106466001)(230700001)(65816999)(65806001)(83506001)(189998001)(1096002)(50466002)(586003)(33656002)(87936001)(4001350100001)(81156007)(19580395003)(54356999)(229853001)(5001960100002)(23676002)(86362001)(4326007)(64126003)(92566002)(97736004)(110136002)(36756003)(19580405001)(2950100001)(69596002)(77096005); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR02MB299; H:milsmgep11.sandisk.com; FPR:; SPF:Pass; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2PR02MB299; 2:yWsRNxfCYw7hAUuUa4JArjfQS0HxHw7RVjDEWifu81t229BXXdixDsDpF9RsSM2r1kygJRtkqcjdvsNcTesD1ku8KhWppi2TCt36JGAQsKgCyYEfPQvf0IfVRwLroC3kCODhFwva0ZrTziWAPF5VFw==; 3:cnERGX4M9LTaqOurgpFMRgB3utOT5NLhEb56fMNgTg9FkW2ldf1bl2F9mteuDCWWJgLw4wp92y49gH0+9UO0OUem2txtaJLi1btdo3DYaXUBuY6zx7QimtEH16vc5BqXMnHE3RRz8h57thXE4e4oWFmWPHRJ7bVhhSTvs0zxokXZu9jIC11ZUvbEra5p9zk9tImW4hCM1y42E1Nwab6cjGhKN3p8uFFeNxMSTcSrcHInieOq1GmbKN7iQBKnJ60xgdRZ2QTp50gEOZgN2eS4Eg==; 25:SPH3uWLcvOSXvYdDqQ3MnGRMo3nFDpukPYKvB1fFMRte4d31NymRP8YXsyXPiREiO7yBaCki8Rh/kAADPMVw/V6NDktvAucAx30wZVmwD23XVlCUKhAXWFJ4Xvzc+Hcsmnflh65+rEhySd970C427K+y7xZRMKG/Kws0cZbtZTNhjGbtTn5IVuKjJDvQMAV4EnXuRItt2v/0UDF60NdQbIRMaVkExF1YjkjgFf/xLBd7WP0ZEsMwLtwyc99EPvB2KVqIA1hvnV734xv9BMvORQ== X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501001); SRVR:BY2PR02MB299; X-Microsoft-Exchange-Diagnostics: 1; BY2PR02MB299; 20:oY/a4FYV1vjKGvfcPTHZzuRMnGoQZ6Dq/UgnVmofD1x3juxMpcC4qfWGvcPsarYBsAeif3qpTkBi0bS4HDarcceLiycYyh0azisZRosSf9Rq7pqGq0ksZV7l1p5xMu9wgbaPqDY75659bx6dLv4BN8mi1TYeMJeiMfsxtK76x2jCVl9sOmO2JHUODaEaMfMGNCgTsH1XP3bFpcsrcdUCxsQKt/u0hxIWxLB841MOf2ERKcJ8KZ9SIs7fr+iSt1HzCZ7+hgajcp6yR3gWdiFgEVjmB7JDePTY6Xma4i3uljKsl4WFH7Y06TFR1f1g9k9mWjNELmfTkl0HLiWmGtidYxAWL+hb28lSk1uY/IO7v3nDF6oPE5MmIS+Uj3BXA+dOmiBb+3iE2hpSLGg1bUMIkZtehzBJZG/3o0HDeusWYJg9/1dwXOAS0O5ljxVWwSdJ6L6irhkTiTxUWv2CP/g04vbZ33XXyvl85gJDLw1rYk9XgsoJRiHasuMTyrReulmz; 4:jCGXv+etbuN48nff4mIBNNnn/suu+XhV+Nh/3Tz3pDwNiW7ygh4LHfDG9xeE/7JgFSxOaoB7TW0vdAdQUQVsD3fp6Es2imj60TenLCDNc3mO3k4Nqx1h5HEFcySQEU5nEhhPfe+Gfc6vxe9iFh9C607qqrHY84PayDckwHlewg7P8JeMFZ0yzvbPIy3ga2nes9ZpKADscH5kQSZHyPkRnGE0Qpoqd0EgZaVHx5xi6vYZv/YLQD5PHloAhbsFWxH1mDdpi46veGZfzDpLLi2O3RVMzr02C3AKn+FokV2gq1/dgDYBQWDsfkdkwhiBUlcUB2Bgf63IhxHBQMosMRg5nT1Tjg5Yi2k2Y6ZI+dKm031HMd/E33wHvnttQi7WNjGyfzK7GKIKYa0M+tXWgZnJ3HqRLuxvSFKTXLeNd/T CTF6bzRRWEtCH5iTN89rH9+fP X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(42932892334569); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(520078)(8121501046)(5005006)(3002001)(10201501046); SRVR:BY2PR02MB299; BCL:0; PCL:0; RULEID:; SRVR:BY2PR02M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hv8u+qor37Q2AThazlxXD/djHxYj3p4JLOPeUkTCnCliNxnFAtFurS82Ssrw6KOk1MaUGpQawpLYDILjaF4BuRVnE+nKsOYgz5Oz8h//ddrwnfP3Zr43ueRwBkvcnV5b6o0xSv0IxxHWwDz8VbSqfRN5XZi00s+tAFiJMm1Bc8eMCULmoRit/NU7lWe+YWMk64Wmmr3XkGv/p2ChT0t0XJ8inzmNGGrlQRGKahHV4wDL6x6/7Tne2Jl16SVP SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2016 14:26:24.4568 (UTC) X-MS-Exchange-CrossTenant-Id: fcd9ea9c-ae8c-460c-ab3c-3db42d7ac64d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=fcd9ea9c-ae8c-460c-ab3c-3db42d7ac64d; Ip=[63.163.107.172]; Helo=[milsmgep11.sandisk.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR02MB299 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In the CM REQ message handler, store the channel pointer in cm_id->context such that the function srpt_find_channel() is no longer needed. Additionally, make the CM event messages more informative. Signed-off-by: Bart Van Assche Cc: Christoph Hellwig Reviewed-by: Christoph Hellwig Reviewed-by: Sagi Grimberg --- drivers/infiniband/ulp/srpt/ib_srpt.c | 113 +++++++++++++--------------------- 1 file changed, 43 insertions(+), 70 deletions(-) diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c index 2ae3c1b..6ec130d 100644 --- a/drivers/infiniband/ulp/srpt/ib_srpt.c +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c @@ -1893,25 +1893,14 @@ static int srpt_shutdown_session(struct se_session *se_sess) * ib_destroy_cm_id(), which locks the cm_id spinlock and hence waits until * this function has finished). */ -static void srpt_drain_channel(struct ib_cm_id *cm_id) +static void srpt_drain_channel(struct srpt_rdma_ch *ch) { - struct srpt_device *sdev; - struct srpt_rdma_ch *ch; int ret; bool do_reset = false; WARN_ON_ONCE(irqs_disabled()); - sdev = cm_id->context; - BUG_ON(!sdev); - spin_lock_irq(&sdev->spinlock); - list_for_each_entry(ch, &sdev->rch_list, list) { - if (ch->cm_id == cm_id) { - do_reset = srpt_set_ch_state(ch, CH_DRAINING); - break; - } - } - spin_unlock_irq(&sdev->spinlock); + do_reset = srpt_set_ch_state(ch, CH_DRAINING); if (do_reset) { if (ch->sess) @@ -1925,34 +1914,6 @@ static void srpt_drain_channel(struct ib_cm_id *cm_id) } /** - * srpt_find_channel() - Look up an RDMA channel. - * @cm_id: Pointer to the CM ID of the channel to be looked up. - * - * Return NULL if no matching RDMA channel has been found. - */ -static struct srpt_rdma_ch *srpt_find_channel(struct srpt_device *sdev, - struct ib_cm_id *cm_id) -{ - struct srpt_rdma_ch *ch; - bool found; - - WARN_ON_ONCE(irqs_disabled()); - BUG_ON(!sdev); - - found = false; - spin_lock_irq(&sdev->spinlock); - list_for_each_entry(ch, &sdev->rch_list, list) { - if (ch->cm_id == cm_id) { - found = true; - break; - } - } - spin_unlock_irq(&sdev->spinlock); - - return found ? ch : NULL; -} - -/** * srpt_release_channel() - Release channel resources. * * Schedules the actual release because: @@ -2160,6 +2121,7 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id, memcpy(ch->t_port_id, req->target_port_id, 16); ch->sport = &sdev->port[param->port - 1]; ch->cm_id = cm_id; + cm_id->context = ch; /* * Avoid QUEUE_FULL conditions by limiting the number of buffers used * for the SRP protocol to the command queue size. @@ -2304,10 +2266,23 @@ out: return ret; } -static void srpt_cm_rej_recv(struct ib_cm_id *cm_id) +static void srpt_cm_rej_recv(struct srpt_rdma_ch *ch, + enum ib_cm_rej_reason reason, + const u8 *private_data, + u8 private_data_len) { - pr_info("Received IB REJ for cm_id %p.\n", cm_id); - srpt_drain_channel(cm_id); + char *priv = kmalloc(private_data_len * 3 + 1, GFP_KERNEL); + int i; + + if (priv) { + priv[0] = '\0'; + for (i = 0; i < private_data_len; i++) + sprintf(priv + 3 * i, "%02x ", private_data[i]); + } + pr_info("Received CM REJ for ch %s-%d; reason %d; private data %s.\n", + ch->sess_name, ch->qp->qp_num, reason, priv ? : "(?)"); + kfree(priv); + srpt_drain_channel(ch); } /** @@ -2316,14 +2291,10 @@ static void srpt_cm_rej_recv(struct ib_cm_id *cm_id) * An IB_CM_RTU_RECEIVED message indicates that the connection is established * and that the recipient may begin transmitting (RTU = ready to use). */ -static void srpt_cm_rtu_recv(struct ib_cm_id *cm_id) +static void srpt_cm_rtu_recv(struct srpt_rdma_ch *ch) { - struct srpt_rdma_ch *ch; int ret; - ch = srpt_find_channel(cm_id->context, cm_id); - BUG_ON(!ch); - if (srpt_set_ch_state(ch, CH_LIVE)) { struct srpt_recv_ioctx *ioctx, *ioctx_tmp; @@ -2339,31 +2310,30 @@ static void srpt_cm_rtu_recv(struct ib_cm_id *cm_id) } } -static void srpt_cm_timewait_exit(struct ib_cm_id *cm_id) +static void srpt_cm_timewait_exit(struct srpt_rdma_ch *ch) { - pr_info("Received IB TimeWait exit for cm_id %p.\n", cm_id); - srpt_drain_channel(cm_id); + pr_info("Received CM TimeWait exit for ch %s-%d.\n", ch->sess_name, + ch->qp->qp_num); + srpt_drain_channel(ch); } -static void srpt_cm_rep_error(struct ib_cm_id *cm_id) +static void srpt_cm_rep_error(struct srpt_rdma_ch *ch) { - pr_info("Received IB REP error for cm_id %p.\n", cm_id); - srpt_drain_channel(cm_id); + pr_info("Received CM REP error for ch %s-%d.\n", ch->sess_name, + ch->qp->qp_num); + srpt_drain_channel(ch); } /** * srpt_cm_dreq_recv() - Process reception of a DREQ message. */ -static void srpt_cm_dreq_recv(struct ib_cm_id *cm_id) +static void srpt_cm_dreq_recv(struct srpt_rdma_ch *ch) { - struct srpt_rdma_ch *ch; unsigned long flags; bool send_drep = false; - ch = srpt_find_channel(cm_id->context, cm_id); - BUG_ON(!ch); - - pr_debug("cm_id= %p ch->state= %d\n", cm_id, ch->state); + pr_debug("ch %s-%d state %d\n", ch->sess_name, ch->qp->qp_num, + ch->state); spin_lock_irqsave(&ch->spinlock, flags); switch (ch->state) { @@ -2391,10 +2361,10 @@ static void srpt_cm_dreq_recv(struct ib_cm_id *cm_id) /** * srpt_cm_drep_recv() - Process reception of a DREP message. */ -static void srpt_cm_drep_recv(struct ib_cm_id *cm_id) +static void srpt_cm_drep_recv(struct srpt_rdma_ch *ch) { - pr_info("Received InfiniBand DREP message for cm_id %p.\n", cm_id); - srpt_drain_channel(cm_id); + pr_info("Received InfiniBand DREP message for cm_id %p.\n", ch->cm_id); + srpt_drain_channel(ch); } /** @@ -2409,6 +2379,7 @@ static void srpt_cm_drep_recv(struct ib_cm_id *cm_id) */ static int srpt_cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event) { + struct srpt_rdma_ch *ch = cm_id->context; int ret; ret = 0; @@ -2418,23 +2389,25 @@ static int srpt_cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event) event->private_data); break; case IB_CM_REJ_RECEIVED: - srpt_cm_rej_recv(cm_id); + srpt_cm_rej_recv(ch, event->param.rej_rcvd.reason, + event->private_data, + IB_CM_REJ_PRIVATE_DATA_SIZE); break; case IB_CM_RTU_RECEIVED: case IB_CM_USER_ESTABLISHED: - srpt_cm_rtu_recv(cm_id); + srpt_cm_rtu_recv(ch); break; case IB_CM_DREQ_RECEIVED: - srpt_cm_dreq_recv(cm_id); + srpt_cm_dreq_recv(ch); break; case IB_CM_DREP_RECEIVED: - srpt_cm_drep_recv(cm_id); + srpt_cm_drep_recv(ch); break; case IB_CM_TIMEWAIT_EXIT: - srpt_cm_timewait_exit(cm_id); + srpt_cm_timewait_exit(ch); break; case IB_CM_REP_ERROR: - srpt_cm_rep_error(cm_id); + srpt_cm_rep_error(ch); break; case IB_CM_DREQ_ERROR: pr_info("Received IB DREQ ERROR event.\n");