From patchwork Tue May 5 12:50:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Wang X-Patchwork-Id: 6337561 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 8B319BEEE1 for ; Tue, 5 May 2015 12:52:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9A7D220266 for ; Tue, 5 May 2015 12:52:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8574620149 for ; Tue, 5 May 2015 12:52:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758736AbbEEMvt (ORCPT ); Tue, 5 May 2015 08:51:49 -0400 Received: from mail-wi0-f180.google.com ([209.85.212.180]:38617 "EHLO mail-wi0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758693AbbEEMvT (ORCPT ); Tue, 5 May 2015 08:51:19 -0400 Received: by wiun10 with SMTP id n10so144990412wiu.1 for ; Tue, 05 May 2015 05:51:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gv1j2OIiqAZnDery5DjrjY6zQ93//nUoQTLuvM/dRb4=; b=RQkgpZ4TfyPiO78y/tBJR+Os2yO+2rY4PpahplSoXIeM5YDBDaUU+hILP7PFGKC4Ll AD0v9p55bz6F46Ug3DCnbQbRddqEBfMZehJuGlwAk96Qn7zGAxG1i+0pJm2Z+auYdKQ2 k8Mp/agHl4a3a6tfV+Y4/01tmlPEmeOj7zgtRgxWA1aI/fzU/MF7nl5o9oehRmBv0REn 3UIRemRyZP3oyFWWfhkBbWg76tessybLL1dXEJQsUxR56WZJMIyLgwtjFIIfR1CYKIL0 jU3XYDkE+vIcpor/vgFzfVdVYwKJrC77qr3Ah3IUX/SU2BJW+rqgRBcD9ougiEVVb/Mz y1XA== X-Gm-Message-State: ALoCoQlq5dB4CnPJwM/jk5YAreWRkeWkMGTwqkrFH7mThdUL9aYCfE7lk3Cy0+nB+RjSnz5/LcUn X-Received: by 10.180.74.102 with SMTP id s6mr3660775wiv.37.1430830277589; Tue, 05 May 2015 05:51:17 -0700 (PDT) Received: from ubuntu.pb.local ([62.217.45.26]) by mx.google.com with ESMTPSA id gs7sm16033234wib.10.2015.05.05.05.51.16 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 May 2015 05:51:16 -0700 (PDT) From: Michael Wang To: Roland Dreier , Sean Hefty , Hal Rosenstock , Doug Ledford , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Michael Wang , Tom Tucker , Steve Wise , Hoang-Nam Nguyen , Christoph Raisch , Mike Marciniszyn , Eli Cohen , Faisal Latif , Jack Morgenstein , Or Gerlitz , Haggai Eran , Ira Weiny , Tom Talpey , Jason Gunthorpe , Devesh Sharma , Liran Liss , Dave Goodell Subject: [PATCH v8 19/23] IB/Verbs: Use management helper rdma_cap_ib_sa() Date: Tue, 5 May 2015 14:50:36 +0200 Message-Id: <1430830240-32389-20-git-send-email-yun.wang@profitbricks.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1430830240-32389-1-git-send-email-yun.wang@profitbricks.com> References: <1430830240-32389-1-git-send-email-yun.wang@profitbricks.com> 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.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 Introduce helper rdma_cap_ib_sa() to help us check if the port of an IB device support Infiniband Subnet Administration. Signed-off-by: Michael Wang --- drivers/infiniband/core/cma.c | 4 ++-- drivers/infiniband/core/sa_query.c | 10 +++++----- drivers/infiniband/core/ucma.c | 2 +- include/rdma/ib_verbs.h | 15 +++++++++++++++ 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 0787035..8def2f5 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -933,7 +933,7 @@ static inline int cma_user_data_offset(struct rdma_id_private *id_priv) static void cma_cancel_route(struct rdma_id_private *id_priv) { - if (rdma_protocol_ib(id_priv->id.device, id_priv->id.port_num)) { + if (rdma_cap_ib_sa(id_priv->id.device, id_priv->id.port_num)) { if (id_priv->query) ib_sa_cancel_query(id_priv->query_id, id_priv->query); } @@ -1957,7 +1957,7 @@ int rdma_resolve_route(struct rdma_cm_id *id, int timeout_ms) return -EINVAL; atomic_inc(&id_priv->refcount); - if (rdma_protocol_ib(id->device, id->port_num)) + if (rdma_cap_ib_sa(id->device, id->port_num)) ret = cma_resolve_ib_route(id_priv, timeout_ms); else if (rdma_protocol_iboe(id->device, id->port_num)) ret = cma_resolve_iboe_route(id_priv); diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c index b115c28..30aa5e5 100644 --- a/drivers/infiniband/core/sa_query.c +++ b/drivers/infiniband/core/sa_query.c @@ -450,7 +450,7 @@ static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event struct ib_sa_port *port = &sa_dev->port[event->element.port_num - sa_dev->start_port]; - if (WARN_ON(!rdma_protocol_ib(handler->device, port->port_num))) + if (WARN_ON(!rdma_cap_ib_sa(handler->device, port->port_num))) return; spin_lock_irqsave(&port->ah_lock, flags); @@ -1173,7 +1173,7 @@ static void ib_sa_add_one(struct ib_device *device) for (i = 0; i <= e - s; ++i) { spin_lock_init(&sa_dev->port[i].ah_lock); - if (!rdma_protocol_ib(device, i + 1)) + if (!rdma_cap_ib_sa(device, i + 1)) continue; sa_dev->port[i].sm_ah = NULL; @@ -1208,7 +1208,7 @@ static void ib_sa_add_one(struct ib_device *device) goto err; for (i = 0; i <= e - s; ++i) { - if (rdma_protocol_ib(device, i + 1)) + if (rdma_cap_ib_sa(device, i + 1)) update_sm_ah(&sa_dev->port[i].update_task); } @@ -1216,7 +1216,7 @@ static void ib_sa_add_one(struct ib_device *device) err: while (--i >= 0) { - if (rdma_protocol_ib(device, i + 1)) + if (rdma_cap_ib_sa(device, i + 1)) ib_unregister_mad_agent(sa_dev->port[i].agent); } free: @@ -1237,7 +1237,7 @@ static void ib_sa_remove_one(struct ib_device *device) flush_workqueue(ib_wq); for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) { - if (rdma_protocol_ib(device, i + 1)) { + if (rdma_cap_ib_sa(device, i + 1)) { ib_unregister_mad_agent(sa_dev->port[i].agent); if (sa_dev->port[i].sm_ah) kref_put(&sa_dev->port[i].sm_ah->ref, free_sm_ah); diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c index dae7620..d42b816 100644 --- a/drivers/infiniband/core/ucma.c +++ b/drivers/infiniband/core/ucma.c @@ -723,7 +723,7 @@ static ssize_t ucma_query_route(struct ucma_file *file, resp.node_guid = (__force __u64) ctx->cm_id->device->node_guid; resp.port_num = ctx->cm_id->port_num; - if (rdma_protocol_ib(ctx->cm_id->device, ctx->cm_id->port_num)) + if (rdma_cap_ib_sa(ctx->cm_id->device, ctx->cm_id->port_num)) ucma_copy_ib_route(&resp, &ctx->cm_id->route); else if (rdma_protocol_iboe(ctx->cm_id->device, ctx->cm_id->port_num)) ucma_copy_iboe_route(&resp, &ctx->cm_id->route); diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index cc92a64..c3a561e8 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -1834,6 +1834,21 @@ static inline bool rdma_cap_iw_cm(struct ib_device *device, u8 port_num) return rdma_protocol_iwarp(device, port_num); } +/** + * rdma_cap_ib_sa - Check if the port of device has the capability Infiniband + * Subnet Administration. + * + * @device: Device to be checked + * @port_num: Port number of the device + * + * Return false when port of the device don't support Infiniband + * Subnet Administration. + */ +static inline bool rdma_cap_ib_sa(struct ib_device *device, u8 port_num) +{ + return rdma_protocol_ib(device, port_num); +} + int ib_query_gid(struct ib_device *device, u8 port_num, int index, union ib_gid *gid);