From patchwork Tue Apr 7 12:36:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Wang X-Patchwork-Id: 6169881 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 812EB9F2EC for ; Tue, 7 Apr 2015 12:37:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9DFFE202EC for ; Tue, 7 Apr 2015 12:37:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BEF8520353 for ; Tue, 7 Apr 2015 12:37:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753809AbbDGMgp (ORCPT ); Tue, 7 Apr 2015 08:36:45 -0400 Received: from mail-wg0-f49.google.com ([74.125.82.49]:36416 "EHLO mail-wg0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753797AbbDGMgj (ORCPT ); Tue, 7 Apr 2015 08:36:39 -0400 Received: by wgsk9 with SMTP id k9so31922327wgs.3 for ; Tue, 07 Apr 2015 05:36:37 -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=9UMCUDuqMTjKleS5LgHndVheJo5HzkQmd1tSLC9MiBw=; b=NNmsGhEvyDZG3sbNOZcPPCpTwdZJZIFYhcQ2HC6HsJT/5pfsFEuwD8rsSVbOREjHmq aOsa21zgWNEHbgnmB48Z7HRlQ1L5dHsRnWcTM2TwtBoWlVdyWSUZvRO+jHHfIpL09FWq qJwQLHV1BQJFUbDEtSPvFyMnlOP6ytKIARcPhOQAqdmt33NgQlxX2PWPXCFhK8pVkOTk 6j6enQiK9nDC5Pomndnq57K6E/p6mYn1rPm8hTKESPGw/qqytqmzIxVPU66qiDEpRD8M yjnGDZB60bA2j09XjVBDlNZF4BIS95uJuj+oW9cuV33/dRjkHTgk5ykJa1S8aWN7XICo 6GyA== X-Gm-Message-State: ALoCoQnJqn35XlJh1yggqqtislZQwGb3QOS2BGeU4B8JilwcvBx/LB2HAGP50VYsCn9QPLka1MnC X-Received: by 10.180.198.110 with SMTP id jb14mr4254790wic.57.1428410197331; Tue, 07 Apr 2015 05:36:37 -0700 (PDT) Received: from [192.168.71.52] ([62.217.45.26]) by mx.google.com with ESMTPSA id n3sm10775044wja.36.2015.04.07.05.36.34 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Apr 2015 05:36:36 -0700 (PDT) Message-ID: <5523CF52.4030606@profitbricks.com> Date: Tue, 07 Apr 2015 14:36:34 +0200 From: Michael Wang User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Roland Dreier , Sean Hefty , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, netdev@vger.kernel.org CC: Hal Rosenstock , Tom Tucker , Steve Wise , Hoang-Nam Nguyen , Christoph Raisch , Mike Marciniszyn , Eli Cohen , Faisal Latif , Upinder Malhi , Trond Myklebust , "J. Bruce Fields" , "David S. Miller" , Ira Weiny , PJ Waskiewicz , Tatyana Nikolova , Or Gerlitz , Jack Morgenstein , Haggai Eran , Ilya Nelkenbaum , Yann Droneaud , Bart Van Assche , Shachar Raindel , Sagi Grimberg , Devesh Sharma , Matan Barak , Moni Shoua , Jiri Kosina , Selvin Xavier , Mitesh Ahuja , Li RongQing , Rasmus Villemoes , Alex Estrin , Doug Ledford , Eric Dumazet , Erez Shitrit , Tom Gundersen , Chuck Lever , Michael Wang Subject: [PATCH v2 12/17] IB/Verbs: Use management helper cap_ib_cm_dev() for cm-device-check References: <5523CCD5.6030401@profitbricks.com> In-Reply-To: <5523CCD5.6030401@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_cm_dev() to help us check if any port of device has the capability Infiniband Communication Manager. 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 | 5 ++--- drivers/infiniband/core/ucm.c | 3 +-- include/rdma/ib_verbs.h | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index d570030..d8a8ea7 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -1625,8 +1625,7 @@ static void cma_listen_on_dev(struct rdma_id_private *id_priv, struct rdma_cm_id *id; int ret; - if (cma_family(id_priv) == AF_IB && - rdma_node_get_transport(cma_dev->device->node_type) != RDMA_TRANSPORT_IB) + if (cma_family(id_priv) == AF_IB && !cap_ib_cm_dev(cma_dev->device)) return; id = rdma_create_id(cma_listen_handler, id_priv, id_priv->id.ps, @@ -2028,7 +2027,7 @@ static int cma_bind_loopback(struct rdma_id_private *id_priv) mutex_lock(&lock); list_for_each_entry(cur_dev, &dev_list, list) { if (cma_family(id_priv) == AF_IB && - rdma_node_get_transport(cur_dev->device->node_type) != RDMA_TRANSPORT_IB) + !cap_ib_cm_dev(cur_dev->device)) continue; if (!cma_dev) diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c index f2f6393..065405e 100644 --- a/drivers/infiniband/core/ucm.c +++ b/drivers/infiniband/core/ucm.c @@ -1253,8 +1253,7 @@ static void ib_ucm_add_one(struct ib_device *device) dev_t base; struct ib_ucm_device *ucm_dev; - if (!device->alloc_ucontext || - rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB) + if (!device->alloc_ucontext || !cap_ib_cm_dev(device)) return; ucm_dev = kzalloc(sizeof *ucm_dev, GFP_KERNEL); diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index cae6f2d..2767a91 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -1819,6 +1819,26 @@ static inline int cap_ib_cm(struct ib_device *device, u8 port_num) } /** + * cap_ib_cm_dev - Check if any port of device has the capability Infiniband + * Communication Manager. + * + * @device: Device to be checked + * + * Return 0 when all port of the device don't support Infiniband + * Communication Manager. + */ +static inline int cap_ib_cm_dev(struct ib_device *device) +{ + int i; + + for (i = 1; i <= device->phys_port_cnt; i++) { + if (cap_ib_cm(device, i)) + return 1; + } + return 0; +} + +/** * cap_ib_sa - Check if the port of device has the capability Infiniband * Subnet Administrator. *