From patchwork Fri Mar 27 15:46:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Wang X-Patchwork-Id: 6108831 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 AD1399F350 for ; Fri, 27 Mar 2015 15:47:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AFD3920155 for ; Fri, 27 Mar 2015 15:47:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D356B2041E for ; Fri, 27 Mar 2015 15:47:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932271AbbC0PrI (ORCPT ); Fri, 27 Mar 2015 11:47:08 -0400 Received: from mail-wi0-f178.google.com ([209.85.212.178]:37613 "EHLO mail-wi0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932262AbbC0PrB (ORCPT ); Fri, 27 Mar 2015 11:47:01 -0400 Received: by wiaa2 with SMTP id a2so36751109wia.0 for ; Fri, 27 Mar 2015 08:46:59 -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=1WUTNZgqnvQ/aBCLu30stgRBesm/BLDDASIOoYlOboc=; b=Sbk+A/hbQAFLbs3WjO02j/RBEr0CWGMnBWmvzdiNCk+K/7M/aBTIlBZzIbG5JFAUH7 NmuiFCVlhGep9xq7x+HwQORDNKvLKkzH8sbNKoNeXhj3xq38ApCG0+nf8ldSwrldNEfz VwMPhJH+h6XmQSzWWGkFbf8jCKJ4MKMFXccm1xUpoqYIQFoynX9r/T9LPuMcn5barQ54 ThK0UK5nfZ0xCZzwXIN0VGO8MyT2GLnahVJ2ziK10mBseuhdKg2ByRr/Jxry6jec7QhX I75Xg9DsQKDZ2l6AmrpAUZ2ALIG1f+EH6oCP0nIzPpiZv1Wn5lVVRF4/R/irhnOR9EM2 dybg== X-Gm-Message-State: ALoCoQnbdAsFFfo7UiF5naNGo+LWr1CVwaY8lPhW3j0EUzRbwfbhYVzfX96FXJ3rXqCqjZNc8rNZ X-Received: by 10.180.24.65 with SMTP id s1mr57515920wif.30.1427471219814; Fri, 27 Mar 2015 08:46:59 -0700 (PDT) Received: from [192.168.71.52] ([62.217.45.26]) by mx.google.com with ESMTPSA id o10sm3956027wiy.18.2015.03.27.08.46.57 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Mar 2015 08:46:59 -0700 (PDT) Message-ID: <55157B71.6040505@profitbricks.com> Date: Fri, 27 Mar 2015 16:46:57 +0100 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 , Hal Rosenstock , Ira Weiny , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, netdev@vger.kernel.org CC: "J. Bruce Fields" , Trond Myklebust , "David S. Miller" , Or Gerlitz , Moni Shoua , PJ Waskiewicz , Tatyana Nikolova , Yan Burman , Jack Morgenstein , Bart Van Assche , Yann Droneaud , Colin Ian King , Majd Dibbiny , Jiri Kosina , Matan Barak , Alex Estrin , Doug Ledford , Eric Dumazet , Erez Shitrit , Sagi Grimberg , Haggai Eran , Shachar Raindel , Mike Marciniszyn , Steve Wise , Tom Tucker , Chuck Lever , Michael Wang Subject: [RFC PATCH 07/11] IB/Verbs: Use management helper has_mcast() and, cap_mcast() for mcast-check References: <551579CA.4030901@profitbricks.com> In-Reply-To: <551579CA.4030901@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 has_mcast() and cap_mcast() to help us check if an IB device or it's port support Multicast. Cc: Jason Gunthorpe Cc: Doug Ledford Cc: Ira Weiny Cc: Sean Hefty Signed-off-by: Michael Wang --- drivers/infiniband/core/cma.c | 2 +- drivers/infiniband/core/multicast.c | 8 ++++---- include/rdma/ib_verbs.h | 28 ++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 276fb76..cbbc85b 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -3398,7 +3398,7 @@ void rdma_leave_multicast(struct rdma_cm_id *id, struct sockaddr *addr) ib_detach_mcast(id->qp, &mc->multicast.ib->rec.mgid, be16_to_cpu(mc->multicast.ib->rec.mlid)); - if (rdma_transport_is_ib(id_priv->cma_dev->device)) { + if (has_mcast(id_priv->cma_dev->device)) { switch (rdma_port_get_link_layer(id->device, id->port_num)) { case IB_LINK_LAYER_INFINIBAND: ib_sa_free_multicast(mc->multicast.ib); diff --git a/drivers/infiniband/core/multicast.c b/drivers/infiniband/core/multicast.c index 17573ff..ffeaf27 100644 --- a/drivers/infiniband/core/multicast.c +++ b/drivers/infiniband/core/multicast.c @@ -780,7 +780,7 @@ static void mcast_event_handler(struct ib_event_handler *handler, int index; dev = container_of(handler, struct mcast_device, event_handler); - if (!rdma_port_ll_is_ib(dev->device, event->element.port_num)) + if (!cap_mcast(dev->device, event->element.port_num)) return; index = event->element.port_num - dev->start_port; @@ -807,7 +807,7 @@ static void mcast_add_one(struct ib_device *device) int i; int count = 0; - if (!rdma_transport_is_ib(device)) + if (!has_mcast(device)) return; dev = kmalloc(sizeof *dev + device->phys_port_cnt * sizeof *port, @@ -823,7 +823,7 @@ static void mcast_add_one(struct ib_device *device) } for (i = 0; i <= dev->end_port - dev->start_port; i++) { - if (!rdma_port_ll_is_ib(device, dev->start_port + i)) + if (!cap_mcast(device, dev->start_port + i)) continue; port = &dev->port[i]; port->dev = dev; @@ -861,7 +861,7 @@ static void mcast_remove_one(struct ib_device *device) flush_workqueue(mcast_wq); for (i = 0; i <= dev->end_port - dev->start_port; i++) { - if (rdma_port_ll_is_ib(device, dev->start_port + i)) { + if (cap_mcast(device, dev->start_port + i)) { port = &dev->port[i]; deref_port(port); wait_for_completion(&port->comp); diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index fa8ffa3..e796104 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -1823,6 +1823,19 @@ static inline int has_sa(struct ib_device *device) } /** + * has_mcast - Check if a device support Multicast. + * + * @device: Device to be checked + * + * Return 0 when a device has none port to support + * Multicast. + */ +static inline int has_mcast(struct ib_device *device) +{ + return rdma_transport_is_ib(device); +} + +/** * cap_smi - Check if the port of device has the capability * Subnet Management Interface. * @@ -1852,6 +1865,21 @@ static inline int cap_sa(struct ib_device *device, u8 port_num) return rdma_port_ll_is_ib(device, port_num); } +/** + * cap_mcast - Check if the port of device has the capability + * Multicast. + * + * @device: Device to be checked + * @port_num: Port number of the device + * + * Return 0 when port of the device don't support + * Multicast. + */ +static inline int cap_mcast(struct ib_device *device, u8 port_num) +{ + return rdma_port_ll_is_ib(device, port_num); +} + int ib_query_gid(struct ib_device *device, u8 port_num, int index, union ib_gid *gid);