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: 6169731 Return-Path: X-Original-To: patchwork-linux-nfs@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 97FBB9F2EC for ; Tue, 7 Apr 2015 12:34:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0586020295 for ; Tue, 7 Apr 2015 12:34:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 43DBD202C8 for ; Tue, 7 Apr 2015 12:34:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753532AbbDGMeK (ORCPT ); Tue, 7 Apr 2015 08:34:10 -0400 Received: from mail-wi0-f174.google.com ([209.85.212.174]:33568 "EHLO mail-wi0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753173AbbDGMeH (ORCPT ); Tue, 7 Apr 2015 08:34:07 -0400 Received: by wiax7 with SMTP id x7so9725157wia.0 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=bNMiDFg22AuwgVgeny+/Uow1TqrcQQ0Ir8RMAalQjqmIu/gCRxqCNUeSMXGtjEDi3d iXEpDg8dmwz61Huu2N9AH+v47nzhgneycnW+Te8OuSKvzpRkuTWtqQeq3rYpietcAm2s rxTfnZGWfC0GQoA21hY0xYNOL3eVQLxxOWMrtpmx3nnK555e7wCCa5P2hr0C6QCGgY+H uC7GkNSdhbkGEMa6mcS+vm/72xgruRbqsQ3oWoipPths7t/0IRWziV9K6SA6xTBbuF+N CFSa/sfDWrFSiQkXcuhC7sus9Niray37VI7hG0zBtfoTZbB5r4cplVm2TfuN42VYVXV7 wNJw== X-Gm-Message-State: ALoCoQn1AdnUdbNAKuJHNWi7KLMCbaMKs08l9L6eK/KH4HzqglKDASSW/BOwE/7PKfSIsybAypQZ 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-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@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);