From patchwork Thu Apr 16 08:12:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Wang X-Patchwork-Id: 6224681 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 527019F1AC for ; Thu, 16 Apr 2015 08:13:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4DA86201C0 for ; Thu, 16 Apr 2015 08:13:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1B03020108 for ; Thu, 16 Apr 2015 08:13:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933841AbbDPINH (ORCPT ); Thu, 16 Apr 2015 04:13:07 -0400 Received: from mail-wi0-f170.google.com ([209.85.212.170]:36943 "EHLO mail-wi0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933628AbbDPIMu (ORCPT ); Thu, 16 Apr 2015 04:12:50 -0400 Received: by widdi4 with SMTP id di4so87876046wid.0 for ; Thu, 16 Apr 2015 01:12:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=A8L5VxdEVuKrm3VxvJ5THMXDLkESYUFmyVgYSiAfY8g=; b=Psv2jhZOyIYzb3M1mwRCjGdiSkOOyRCxsoaakxivahMiZW8f5cyhmmUcaocj50zBgq 9z6QJCFUK6S16bNKNw7070AEi7SuAXXCRdGZL1kZz8pDyFlNKTfDOsy/POUMN/oPG+dP 7XW4Tx7tXbkkjjdX1KGwtoa/n0rxVgnfsfcbHfRdrZZa09q9bvF0P6xY38Af2/17KPVZ 27HIKiedyjBGnUTux2y3OOp/nQMY+9qaNXqD915lFw0C/4HaKVLo9FDqT/ajINb9M5YE eqB8IKQxAKoRa2XTnSnIwTEyw2/pjdi8ri2l9Lc/0fynj3wWj5KKIDqmvCM6eRR+Wc5X oIlg== X-Gm-Message-State: ALoCoQnAVY1vEq4EfIKIiQvcoHOC5nHYk/SqCfOwNsxNyqB2bUOuaLjVReiQZogJk6Umj/NR4SNO X-Received: by 10.180.74.102 with SMTP id s6mr2729482wiv.37.1429171969242; Thu, 16 Apr 2015 01:12:49 -0700 (PDT) Received: from [192.168.71.52] ([62.217.45.26]) by mx.google.com with ESMTPSA id e18sm9262688wjz.27.2015.04.16.01.12.47 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Apr 2015 01:12:48 -0700 (PDT) Message-ID: <552F6EFE.70500@profitbricks.com> Date: Thu, 16 Apr 2015 10:12:46 +0200 From: Michael Wang User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Roland Dreier , Sean Hefty , Hal Rosenstock , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org CC: 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 , Doug Ledford , hal@dev.mellanox.co.il, Michael Wang Subject: [PATCH v4 20/27] IB/Verbs: Use management helper cap_ib_sa() References: <552F6CF2.4000606@profitbricks.com> In-Reply-To: <552F6CF2.4000606@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 cap_ib_sa() to help us check if the port of an IB device support Infiniband Subnet Administrator. Cc: Steve Wise Cc: Tom Talpey Cc: Jason Gunthorpe Cc: Doug Ledford Cc: Ira Weiny Cc: Sean Hefty 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 a6f1526..094816f 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -955,7 +955,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_tech_ib(id_priv->id.device, id_priv->id.port_num)) { + if (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); } @@ -1979,7 +1979,7 @@ int rdma_resolve_route(struct rdma_cm_id *id, int timeout_ms) return -EINVAL; atomic_inc(&id_priv->refcount); - if (rdma_tech_ib(id->device, id->port_num)) + if (cap_ib_sa(id->device, id->port_num)) ret = cma_resolve_ib_route(id_priv, timeout_ms); else if (rdma_tech_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 803ccf7..fc7e161 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_tech_ib(handler->device, port->port_num))) + if (WARN_ON(!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_tech_ib(device, i + 1)) + if (!cap_ib_sa(device, i + 1)) continue; sa_dev->port[i].sm_ah = NULL; @@ -1210,7 +1210,7 @@ static void ib_sa_add_one(struct ib_device *device) goto err; for (i = 0; i <= e - s; ++i) { - if (rdma_tech_ib(device, i + 1)) + if (cap_ib_sa(device, i + 1)) update_sm_ah(&sa_dev->port[i].update_task); } @@ -1218,7 +1218,7 @@ static void ib_sa_add_one(struct ib_device *device) err: while (--i >= 0) { - if (rdma_tech_ib(device, i + 1)) + if (cap_ib_sa(device, i + 1)) ib_unregister_mad_agent(sa_dev->port[i].agent); } @@ -1240,7 +1240,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_tech_ib(device, i + 1)) { + if (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 7331c6c..bed7957 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_tech_ib(ctx->cm_id->device, ctx->cm_id->port_num)) + if (cap_ib_sa(ctx->cm_id->device, ctx->cm_id->port_num)) ucma_copy_ib_route(&resp, &ctx->cm_id->route); else if (rdma_tech_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 e4999f6..3bfdf81 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -1833,6 +1833,21 @@ static inline int cap_iw_cm(struct ib_device *device, u8 port_num) return rdma_tech_iwarp(device, port_num); } +/** + * cap_ib_sa - Check if the port of device has the capability Infiniband + * Subnet Administrator. + * + * @device: Device to be checked + * @port_num: Port number of the device + * + * Return 0 when port of the device don't support Infiniband + * Subnet Administrator. + */ +static inline int cap_ib_sa(struct ib_device *device, u8 port_num) +{ + return rdma_tech_ib(device, port_num); +} + int ib_query_gid(struct ib_device *device, u8 port_num, int index, union ib_gid *gid);