From patchwork Tue May 5 12:50:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Wang X-Patchwork-Id: 6337641 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1DF02BEEE1 for ; Tue, 5 May 2015 12:53:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3113820266 for ; Tue, 5 May 2015 12:53:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 407C120149 for ; Tue, 5 May 2015 12:53:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758755AbbEEMw7 (ORCPT ); Tue, 5 May 2015 08:52:59 -0400 Received: from mail-wg0-f43.google.com ([74.125.82.43]:34817 "EHLO mail-wg0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758748AbbEEMvW (ORCPT ); Tue, 5 May 2015 08:51:22 -0400 Received: by wgyo15 with SMTP id o15so181790612wgy.2 for ; Tue, 05 May 2015 05:51:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=prjmceGzqLwAqC5uAN3chYHwFi2LVf34i3xoIVjpYIU=; b=ULwWT9YhnsT26xn+DAycfU0oEDQgxvhgHbjUNjfhQPN7TiYX15A7QtFc2z+nHIAA/a FaU+uXMK42fXcUZWAJj8/TV77fvOTkyYR5sRFxHK7gi5Ha1acxnTuSo20raeRstLNAAt CtMZF3MpCXGbHc0JFTUfr4ij3rmRbx+zEdJH+73GfwFSK6j1QwbWkfwIDLSaXGZKRly/ lzDE/AiNJPWYNWeFnWFBO5QXnnfJeznGLJYu+pT2IdxkdhXpmFiYBa9djsiqAGImENEv lyNe9nN5ykqIH/ppaEhQfVBZMXn8eMA9W/DmDrmmSR0/DkYyHJQ88/aGoN/tp2i4bup6 RuhQ== X-Gm-Message-State: ALoCoQmSteVBsxOMVvL1ZfiHAzMEWONU7wOX1Y5YTh+V8+TxHRHWkUwwd7+POifikfsAGXmtObho X-Received: by 10.194.6.37 with SMTP id x5mr52447263wjx.73.1430830279552; Tue, 05 May 2015 05:51:19 -0700 (PDT) Received: from ubuntu.pb.local ([62.217.45.26]) by mx.google.com with ESMTPSA id gs7sm16033234wib.10.2015.05.05.05.51.17 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 May 2015 05:51:18 -0700 (PDT) From: Michael Wang To: Roland Dreier , Sean Hefty , Hal Rosenstock , Doug Ledford , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Michael Wang , 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 , Devesh Sharma , Liran Liss , Dave Goodell Subject: [PATCH v8 20/23] IB/Verbs: Use management helper rdma_cap_ib_mcast() Date: Tue, 5 May 2015 14:50:37 +0200 Message-Id: <1430830240-32389-21-git-send-email-yun.wang@profitbricks.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1430830240-32389-1-git-send-email-yun.wang@profitbricks.com> References: <1430830240-32389-1-git-send-email-yun.wang@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 rdma_cap_ib_mcast() to help us check if the port of an IB device support Infiniband Multicast. 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 8def2f5..101e9cc 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -1007,7 +1007,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_protocol_ib(id_priv->cma_dev->device, + if (rdma_cap_ib_mcast(id_priv->cma_dev->device, id_priv->id.port_num)) { ib_sa_free_multicast(mc->multicast.ib); kfree(mc); @@ -3321,7 +3321,7 @@ int rdma_join_multicast(struct rdma_cm_id *id, struct sockaddr *addr, if (rdma_protocol_iboe(id->device, id->port_num)) { kref_init(&mc->mcref); ret = cma_iboe_join_multicast(id_priv, mc); - } else if (rdma_protocol_ib(id->device, id->port_num)) + } else if (rdma_cap_ib_mcast(id->device, id->port_num)) ret = cma_join_ib_multicast(id_priv, mc); else ret = -ENOSYS; @@ -3355,7 +3355,7 @@ void rdma_leave_multicast(struct rdma_cm_id *id, struct sockaddr *addr) BUG_ON(id_priv->cma_dev->device != id->device); - if (rdma_protocol_ib(id->device, id->port_num)) { + if (rdma_cap_ib_mcast(id->device, id->port_num)) { ib_sa_free_multicast(mc->multicast.ib); kfree(mc); } else if (rdma_protocol_iboe(id->device, id->port_num)) diff --git a/drivers/infiniband/core/multicast.c b/drivers/infiniband/core/multicast.c index b57ed03..605f20a 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_protocol_ib(dev->device, event->element.port_num))) + if (WARN_ON(!rdma_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_protocol_ib(device, dev->start_port + i)) + if (!rdma_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_protocol_ib(device, dev->start_port + i)) { + if (rdma_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 c3a561e8..6bbbc86 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -1849,6 +1849,21 @@ static inline bool rdma_cap_ib_sa(struct ib_device *device, u8 port_num) return rdma_protocol_ib(device, port_num); } +/** + * rdma_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 false when port of the device don't support Infiniband + * Multicast. + */ +static inline bool rdma_cap_ib_mcast(struct ib_device *device, u8 port_num) +{ + return rdma_cap_ib_sa(device, port_num); +} + int ib_query_gid(struct ib_device *device, u8 port_num, int index, union ib_gid *gid);