Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965596AbbDVAKw (ORCPT ); Tue, 21 Apr 2015 20:10:52 -0400 Received: from mga14.intel.com ([192.55.52.115]:46481 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965244AbbDVAKr (ORCPT ); Tue, 21 Apr 2015 20:10:47 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,619,1422950400"; d="scan'208";a="717173606" Date: Tue, 21 Apr 2015 20:10:41 -0400 From: "ira.weiny" To: Michael Wang Cc: Roland Dreier , Sean Hefty , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, hal@dev.mellanox.co.il, Tom Tucker , Steve Wise , Hoang-Nam Nguyen , Christoph Raisch , Mike Marciniszyn , Eli Cohen , Faisal Latif , Jack Morgenstein , Or Gerlitz , Haggai Eran , Tom Talpey , Jason Gunthorpe , Doug Ledford Subject: Re: [PATCH v5 20/27] IB/Verbs: Use management helper cap_ib_sa() Message-ID: <20150422001040.GT15893@phlsvsds.ph.intel.com> References: <5534B8C9.506@profitbricks.com> <5534BB92.2000401@profitbricks.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5534BB92.2000401@profitbricks.com> User-Agent: Mutt/1.4.2.2i Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5421 Lines: 140 On Mon, Apr 20, 2015 at 10:40:50AM +0200, Michael Wang wrote: > > Introduce helper cap_ib_sa() to help us check if the port of an > IB device support Infiniband Subnet Administration. > > Cc: Hal Rosenstock > Cc: Steve Wise > Cc: Tom Talpey > Cc: Jason Gunthorpe > Cc: Doug Ledford > Cc: Ira Weiny > Cc: Sean Hefty > Signed-off-by: Michael Wang Reviewed-by: Ira Weiny > --- > drivers/infiniband/core/cma.c | 4 ++-- > drivers/infiniband/core/sa_query.c | 10 +++++----- > drivers/infiniband/core/ucma.c | 2 +- > include/rdma/ib_verbs.h | 15 +++++++++++++++ > 4 files changed, 23 insertions(+), 8 deletions(-) > > diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c > index dd37b4a..b92f81b 100644 > --- a/drivers/infiniband/core/cma.c > +++ b/drivers/infiniband/core/cma.c > @@ -954,7 +954,7 @@ static inline int cma_user_data_offset(struct rdma_id_private *id_priv) > > static void cma_cancel_route(struct rdma_id_private *id_priv) > { > - if (rdma_tech_ib(id_priv->id.device, id_priv->id.port_num)) { > + if (cap_ib_sa(id_priv->id.device, id_priv->id.port_num)) { > if (id_priv->query) > ib_sa_cancel_query(id_priv->query_id, id_priv->query); > } > @@ -1978,7 +1978,7 @@ int rdma_resolve_route(struct rdma_cm_id *id, int timeout_ms) > return -EINVAL; > > atomic_inc(&id_priv->refcount); > - if (rdma_tech_ib(id->device, id->port_num)) > + if (cap_ib_sa(id->device, id->port_num)) > ret = cma_resolve_ib_route(id_priv, timeout_ms); > else if (rdma_tech_iboe(id->device, id->port_num)) > ret = cma_resolve_iboe_route(id_priv); > diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c > index 60dc7aa..f14a66f 100644 > --- a/drivers/infiniband/core/sa_query.c > +++ b/drivers/infiniband/core/sa_query.c > @@ -450,7 +450,7 @@ static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event > struct ib_sa_port *port = > &sa_dev->port[event->element.port_num - sa_dev->start_port]; > > - if (WARN_ON(!rdma_tech_ib(handler->device, port->port_num))) > + if (WARN_ON(!cap_ib_sa(handler->device, port->port_num))) > return; > > spin_lock_irqsave(&port->ah_lock, flags); > @@ -1173,7 +1173,7 @@ static void ib_sa_add_one(struct ib_device *device) > > for (i = 0; i <= e - s; ++i) { > spin_lock_init(&sa_dev->port[i].ah_lock); > - if (!rdma_tech_ib(device, i + 1)) > + if (!cap_ib_sa(device, i + 1)) > continue; > > sa_dev->port[i].sm_ah = NULL; > @@ -1208,7 +1208,7 @@ static void ib_sa_add_one(struct ib_device *device) > goto err; > > for (i = 0; i <= e - s; ++i) { > - if (rdma_tech_ib(device, i + 1)) > + if (cap_ib_sa(device, i + 1)) > update_sm_ah(&sa_dev->port[i].update_task); > } > > @@ -1216,7 +1216,7 @@ static void ib_sa_add_one(struct ib_device *device) > > err: > while (--i >= 0) { > - if (rdma_tech_ib(device, i + 1)) > + if (cap_ib_sa(device, i + 1)) > ib_unregister_mad_agent(sa_dev->port[i].agent); > } > > @@ -1238,7 +1238,7 @@ static void ib_sa_remove_one(struct ib_device *device) > flush_workqueue(ib_wq); > > for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) { > - if (rdma_tech_ib(device, i + 1)) { > + if (cap_ib_sa(device, i + 1)) { > ib_unregister_mad_agent(sa_dev->port[i].agent); > if (sa_dev->port[i].sm_ah) > kref_put(&sa_dev->port[i].sm_ah->ref, free_sm_ah); > diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c > index 7331c6c..bed7957 100644 > --- a/drivers/infiniband/core/ucma.c > +++ b/drivers/infiniband/core/ucma.c > @@ -723,7 +723,7 @@ static ssize_t ucma_query_route(struct ucma_file *file, > resp.node_guid = (__force __u64) ctx->cm_id->device->node_guid; > resp.port_num = ctx->cm_id->port_num; > > - if (rdma_tech_ib(ctx->cm_id->device, ctx->cm_id->port_num)) > + if (cap_ib_sa(ctx->cm_id->device, ctx->cm_id->port_num)) > ucma_copy_ib_route(&resp, &ctx->cm_id->route); > else if (rdma_tech_iboe(ctx->cm_id->device, ctx->cm_id->port_num)) > ucma_copy_iboe_route(&resp, &ctx->cm_id->route); > diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h > index e4999f6..de3a168 100644 > --- a/include/rdma/ib_verbs.h > +++ b/include/rdma/ib_verbs.h > @@ -1833,6 +1833,21 @@ static inline int cap_iw_cm(struct ib_device *device, u8 port_num) > return rdma_tech_iwarp(device, port_num); > } > > +/** > + * cap_ib_sa - Check if the port of device has the capability Infiniband > + * Subnet Administration. > + * > + * @device: Device to be checked > + * @port_num: Port number of the device > + * > + * Return 0 when port of the device don't support Infiniband > + * Subnet Administration. > + */ > +static inline int cap_ib_sa(struct ib_device *device, u8 port_num) > +{ > + return rdma_tech_ib(device, port_num); > +} > + > int ib_query_gid(struct ib_device *device, > u8 port_num, int index, union ib_gid *gid); > > -- > 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/