From patchwork Thu Apr 16 08:13:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Wang X-Patchwork-Id: 6224691 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 B2BCB9F1AC for ; Thu, 16 Apr 2015 08:14:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B3659201C0 for ; Thu, 16 Apr 2015 08:14:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9BE6420108 for ; Thu, 16 Apr 2015 08:14:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756877AbbDPINn (ORCPT ); Thu, 16 Apr 2015 04:13:43 -0400 Received: from mail-wi0-f180.google.com ([209.85.212.180]:37996 "EHLO mail-wi0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933864AbbDPINT (ORCPT ); Thu, 16 Apr 2015 04:13:19 -0400 Received: by wiun10 with SMTP id n10so87605696wiu.1 for ; Thu, 16 Apr 2015 01:13:17 -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=a8IN9nO64F8Iad9G0P1iXoDuBWEv5E0lkX3JumkgDMM=; b=To/boTaj2oE/AyDaekL62u2J65eyHVgdgIQKxGZkAlAXZlESZ3bpV7BjynGVB26bTR DgWYZsooGt8heAoSalYa/p3Uhhl76azLkXypaeJiG5Nv7o5C+FcuIMv2JYjH51hewbz2 vabbYnoaD9I7YXRzHsBz/hRTNpVTXiEIQuEW3kGWRVRb98SQ8/iu6NWUd+gmHUCae7q4 Nj5bYZnrnbwQFLrwvppSbl384Jg5P5nCY2j+UpyceumgCYO/Hs1M4q/e1PxjMteIaT95 1P3i3M8ZK37r4OWVxMx973V4KbHoFh7yC7usgDDXXVlvXL/VwnajyK0j0Ajqhqiy4pKG PGPg== X-Gm-Message-State: ALoCoQnrbtbMhyXTtTz5HbNzRMwJblhwKezBO0vmPs8Ki3lSu4mTRvPQS9mmYWGJ1MLW8O9pW1jQ X-Received: by 10.194.62.52 with SMTP id v20mr58326798wjr.137.1429171997369; Thu, 16 Apr 2015 01:13:17 -0700 (PDT) Received: from [192.168.71.52] ([62.217.45.26]) by mx.google.com with ESMTPSA id fl14sm9273501wjc.11.2015.04.16.01.13.15 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Apr 2015 01:13:16 -0700 (PDT) Message-ID: <552F6F1B.7040507@profitbricks.com> Date: Thu, 16 Apr 2015 10:13:15 +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 21/27] IB/Verbs: Use management helper cap_ib_mcast() 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_mcast() to help us check if the port of an IB device support Infiniband Multicast. 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 | 6 +++--- drivers/infiniband/core/multicast.c | 6 +++--- include/rdma/ib_verbs.h | 15 +++++++++++++++ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 094816f..0ae88dc 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -1029,7 +1029,7 @@ static void cma_leave_mc_groups(struct rdma_id_private *id_priv) mc = container_of(id_priv->mc_list.next, struct cma_multicast, list); list_del(&mc->list); - if (rdma_tech_ib(id_priv->cma_dev->device, + if (cap_ib_mcast(id_priv->cma_dev->device, id_priv->id.port_num)) { ib_sa_free_multicast(mc->multicast.ib); kfree(mc); @@ -3343,7 +3343,7 @@ int rdma_join_multicast(struct rdma_cm_id *id, struct sockaddr *addr, if (rdma_tech_iboe(id->device, id->port_num)) { kref_init(&mc->mcref); ret = cma_iboe_join_multicast(id_priv, mc); - } else if (rdma_tech_ib(id->device, id->port_num)) + } else if (cap_ib_mcast(id->device, id->port_num)) ret = cma_join_ib_multicast(id_priv, mc); else ret = -ENOSYS; @@ -3377,7 +3377,7 @@ void rdma_leave_multicast(struct rdma_cm_id *id, struct sockaddr *addr) BUG_ON(id_priv->cma_dev->device != id->device); - if (rdma_tech_ib(id->device, id->port_num)) { + if (cap_ib_mcast(id->device, id->port_num)) { ib_sa_free_multicast(mc->multicast.ib); kfree(mc); } else if (rdma_tech_iboe(id->device, diff --git a/drivers/infiniband/core/multicast.c b/drivers/infiniband/core/multicast.c index 24d93f5..bdc1880 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 (WARN_ON(!rdma_tech_ib(dev->device, event->element.port_num))) + if (WARN_ON(!cap_ib_mcast(dev->device, event->element.port_num))) return; index = event->element.port_num - dev->start_port; @@ -820,7 +820,7 @@ static void mcast_add_one(struct ib_device *device) } for (i = 0; i <= dev->end_port - dev->start_port; i++) { - if (!rdma_tech_ib(device, dev->start_port + i)) + if (!cap_ib_mcast(device, dev->start_port + i)) continue; port = &dev->port[i]; port->dev = dev; @@ -858,7 +858,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_tech_ib(device, dev->start_port + i)) { + if (cap_ib_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 3bfdf81..b2cee8d 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -1848,6 +1848,21 @@ static inline int cap_ib_sa(struct ib_device *device, u8 port_num) return rdma_tech_ib(device, port_num); } +/** + * cap_ib_mcast - Check if the port of device has the capability Infiniband + * Multicast. + * + * @device: Device to be checked + * @port_num: Port number of the device + * + * Return 0 when port of the device don't support Infiniband + * Multicast. + */ +static inline int cap_ib_mcast(struct ib_device *device, u8 port_num) +{ + return cap_ib_sa(device, port_num); +} + int ib_query_gid(struct ib_device *device, u8 port_num, int index, union ib_gid *gid);