From patchwork Tue May 8 14:08:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Wise X-Patchwork-Id: 10386469 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 5ECA460353 for ; Tue, 8 May 2018 16:16:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4FE4328816 for ; Tue, 8 May 2018 16:16:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 444CC28FF7; Tue, 8 May 2018 16:16:03 +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=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 D680628816 for ; Tue, 8 May 2018 16:16:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751699AbeEHQQC (ORCPT ); Tue, 8 May 2018 12:16:02 -0400 Received: from 72-48-214-68.dyn.grandenetworks.net ([72.48.214.68]:52855 "EHLO smtp.opengridcomputing.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751273AbeEHQQB (ORCPT ); Tue, 8 May 2018 12:16:01 -0400 Received: by smtp.opengridcomputing.com (Postfix, from userid 503) id 5DC5C2B8E5; Tue, 8 May 2018 11:16:01 -0500 (CDT) Message-Id: <588779743ae374e1965d5c55ce93dd69e1a76ba8.1525795940.git.swise@opengridcomputing.com> In-Reply-To: References: From: Steve Wise Date: Tue, 8 May 2018 07:08:49 -0700 Subject: [RESEND] [PATCH rdma-next 2/5] RDMA/CMA: add rdma_iw_cm_id() and rdma_res_to_id() helpers To: jgg@mellanox.com, dledford@redhat.com Cc: leon@kernel.org, linux-rdma@vger.kernel.org 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 Add a helper function for iwarp drivers to be able to map an rdma_cm_id to an iw_cm_id. This is useful for dumping driver specific NLDEV/RESTRACK connection state. Add a helper to return the rdma_cm_id pointer from the rdma_restack pointer. This is needed for rdma drivers to map a res entry back to the public rdma_cm_id struct. Signed-off-by: Steve Wise --- drivers/infiniband/core/cma.c | 20 ++++++++++++++++++++ include/rdma/rdma_cm.h | 12 ++++++++++++ 2 files changed, 32 insertions(+) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 8c85b24..15e78b00 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -146,6 +146,26 @@ const void *rdma_consumer_reject_data(struct rdma_cm_id *id, } EXPORT_SYMBOL(rdma_consumer_reject_data); +struct iw_cm_id *rdma_iw_cm_id(struct rdma_cm_id *id) +{ + struct rdma_id_private *id_priv; + + id_priv = container_of(id, struct rdma_id_private, id); + if (id->device->node_type == RDMA_NODE_RNIC) + return id_priv->cm_id.iw; + return NULL; +} +EXPORT_SYMBOL(rdma_iw_cm_id); + +struct rdma_cm_id *rdma_res_to_id(struct rdma_restrack_entry *res) +{ + struct rdma_id_private *id_priv = + container_of(res, struct rdma_id_private, res); + + return &id_priv->id; +} +EXPORT_SYMBOL(rdma_res_to_id); + static void cma_add_one(struct ib_device *device); static void cma_remove_one(struct ib_device *device, void *client_data); diff --git a/include/rdma/rdma_cm.h b/include/rdma/rdma_cm.h index 6909347..e36d971 100644 --- a/include/rdma/rdma_cm.h +++ b/include/rdma/rdma_cm.h @@ -420,4 +420,16 @@ const void *rdma_consumer_reject_data(struct rdma_cm_id *id, void rdma_read_gids(struct rdma_cm_id *cm_id, union ib_gid *sgid, union ib_gid *dgid); +/** + * rdma_iw_cm_id() - return the iw_cm_id pointer for this cm_id. + * @id: Communication Identifier + */ +struct iw_cm_id *rdma_iw_cm_id(struct rdma_cm_id *cm_id); + +/** + * rdma_res_to_id() - return the rdma_cm_id pointer for this restrack. + * @res: rdma resource tracking entry pointer + */ +struct rdma_cm_id *rdma_res_to_id(struct rdma_restrack_entry *res); + #endif /* RDMA_CM_H */