From patchwork Tue Apr 7 12:34:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Wang X-Patchwork-Id: 6169741 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 06F0F9F389 for ; Tue, 7 Apr 2015 12:34:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 07216202C8 for ; Tue, 7 Apr 2015 12:34:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 123DC20320 for ; Tue, 7 Apr 2015 12:34:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753528AbbDGMeK (ORCPT ); Tue, 7 Apr 2015 08:34:10 -0400 Received: from mail-wg0-f47.google.com ([74.125.82.47]:35483 "EHLO mail-wg0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753303AbbDGMeH (ORCPT ); Tue, 7 Apr 2015 08:34:07 -0400 Received: by wgyo15 with SMTP id o15so43521630wgy.2 for ; Tue, 07 Apr 2015 05:34:06 -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=vvndXtkDvETZmHBtEytq4B2Tgy+KyYKMjsAMLwLrs18=; b=F5Flmh8YUmXynX5qI44L8F1jPnVLuCe4NQQ+aQHHr2jG1xPqJHfkAxpAovoQjyiUF3 i88c6O5dLm22pM3zlMrcpj3XSrX5/Nvh+K7LhTn11Dt734SF+9GfIPw8eYvFaL6u4vnH QcKySXqTuUhkfinNAX2Fb3MhS49m+YUhSJTq6NgSVUYGhFPZPMaKcFZMOaXRxvyvi+y0 LNbQb4tN3gqOX9g99JrmfXFrLwv/x7gpKIfQbYJ2T29gFYvPi66SJu545WA3IkoUB/d9 m5L6uMHruCMYoldFHmKkqQlqYeOiiAJeX4pe1d/84/WPLgCVqr8Mp3A+CJ2bLQMJqhCr qXVQ== X-Gm-Message-State: ALoCoQnot3xxufKQxPAZpFmZVEsdA5PKvq4g0ms1I2/FALLzNpPrJMdg7ZMaTD45sBDtVZlimMm1 X-Received: by 10.181.13.16 with SMTP id eu16mr4362300wid.10.1428410046356; Tue, 07 Apr 2015 05:34:06 -0700 (PDT) Received: from [192.168.71.52] ([62.217.45.26]) by mx.google.com with ESMTPSA id w3sm10855562wiz.5.2015.04.07.05.34.02 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Apr 2015 05:34:05 -0700 (PDT) Message-ID: <5523CEBA.7010808@profitbricks.com> Date: Tue, 07 Apr 2015 14:34:02 +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 08/17] IB/Verbs: Use management helper cap_ipoib() for ipoib-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_ipoib() to help us check if the port of an IB device support IP over Infiniband. Reform ipoib_add_one() to fit per-port-check method better. Cc: Jason Gunthorpe Cc: Doug Ledford Cc: Ira Weiny Cc: Sean Hefty Signed-off-by: Michael Wang --- drivers/infiniband/ulp/ipoib/ipoib_main.c | 17 ++++++++++------- include/rdma/ib_verbs.h | 15 +++++++++++++++ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c index 58b5aa3..e36a926 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c @@ -1654,9 +1654,7 @@ static void ipoib_add_one(struct ib_device *device) struct net_device *dev; struct ipoib_dev_priv *priv; int s, e, p; - - if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB) - return; + int count = 0; dev_list = kmalloc(sizeof *dev_list, GFP_KERNEL); if (!dev_list) @@ -1673,13 +1671,21 @@ static void ipoib_add_one(struct ib_device *device) } for (p = s; p <= e; ++p) { - if (rdma_port_get_link_layer(device, p) != IB_LINK_LAYER_INFINIBAND) + if (!cap_ipoib(device, p)) continue; + dev = ipoib_add_port("ib%d", device, p); if (!IS_ERR(dev)) { priv = netdev_priv(dev); list_add_tail(&priv->list, dev_list); } + + count++; + } + + if (!count) { + kfree(dev_list); + return; } ib_set_client_data(device, &ipoib_client, dev_list); @@ -1690,9 +1696,6 @@ static void ipoib_remove_one(struct ib_device *device) struct ipoib_dev_priv *priv, *tmp; struct list_head *dev_list; - if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB) - return; - dev_list = ib_get_client_data(device, &ipoib_client); if (!dev_list) return; diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 5a5f6d5..9db8966 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -1848,6 +1848,21 @@ static inline int cap_ib_mcast(struct ib_device *device, u8 port_num) return cap_ib_sa(device, port_num); } +/** + * cap_ipoib - Check if the port of device has the capability + * IP over Infiniband. + * + * @device: Device to be checked + * @port_num: Port number of the device + * + * Return 0 when port of the device don't support + * IP over Infiniband. + */ +static inline int cap_ipoib(struct ib_device *device, u8 port_num) +{ + return rdma_transport_ib(device, port_num); +} + int ib_query_gid(struct ib_device *device, u8 port_num, int index, union ib_gid *gid);