Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752334AbbDUGQV (ORCPT ); Tue, 21 Apr 2015 02:16:21 -0400 Received: from cmexedge2.emulex.com ([138.239.224.100]:38997 "EHLO CMEXEDGE2.ext.emulex.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751486AbbDUGQQ (ORCPT ); Tue, 21 Apr 2015 02:16:16 -0400 From: Devesh Sharma To: Michael Wang , Roland Dreier , Sean Hefty , "linux-rdma@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "hal@dev.mellanox.co.il" 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 Subject: RE: [PATCH v5 14/27] IB/Verbs: Reform cma_acquire_dev() Thread-Topic: [PATCH v5 14/27] IB/Verbs: Reform cma_acquire_dev() Thread-Index: AQHQe0Wd0Nig2Gx6zUG7rT9lfkSfoZ1W/nFw Date: Tue, 21 Apr 2015 06:15:48 +0000 Message-ID: References: <5534B8C9.506@profitbricks.com> <5534BAFF.5030107@profitbricks.com> In-Reply-To: <5534BAFF.5030107@profitbricks.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.226.252.225] Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by nfs id t3L6GQpX012174 Content-Length: 5326 Lines: 152 Looks good, I would like to test with ocrdma before confirming. > -----Original Message----- > From: linux-rdma-owner@vger.kernel.org [mailto:linux-rdma- > owner@vger.kernel.org] On Behalf Of Michael Wang > Sent: Monday, April 20, 2015 2:08 PM > To: Roland Dreier; Sean Hefty; linux-rdma@vger.kernel.org; linux- > kernel@vger.kernel.org; hal@dev.mellanox.co.il > 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; Doug Ledford > Subject: [PATCH v5 14/27] IB/Verbs: Reform cma_acquire_dev() > > > Reform cma_acquire_dev() with management helpers, introduce > cma_validate_port() to make the code more clean. > > 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 > --- > drivers/infiniband/core/cma.c | 68 +++++++++++++++++++++++++---------------- > -- > 1 file changed, 40 insertions(+), 28 deletions(-) > > diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c > index 6195bf6..44e7bb9 100644 > --- a/drivers/infiniband/core/cma.c > +++ b/drivers/infiniband/core/cma.c > @@ -370,18 +370,35 @@ static int cma_translate_addr(struct sockaddr *addr, > struct rdma_dev_addr *dev_a > return ret; > } > > +static inline int cma_validate_port(struct ib_device *device, u8 port, > + union ib_gid *gid, int dev_type) { > + u8 found_port; > + int ret = -ENODEV; > + > + if ((dev_type == ARPHRD_INFINIBAND) && !rdma_tech_ib(device, > port)) > + return ret; > + > + if ((dev_type != ARPHRD_INFINIBAND) && rdma_tech_ib(device, port)) > + return ret; > + > + ret = ib_find_cached_gid(device, gid, &found_port, NULL); > + if (port != found_port) > + return -ENODEV; > + > + return ret; > +} > + > static int cma_acquire_dev(struct rdma_id_private *id_priv, > struct rdma_id_private *listen_id_priv) { > struct rdma_dev_addr *dev_addr = &id_priv->id.route.addr.dev_addr; > struct cma_device *cma_dev; > - union ib_gid gid, iboe_gid; > + union ib_gid gid, iboe_gid, *gidp; > int ret = -ENODEV; > - u8 port, found_port; > - enum rdma_link_layer dev_ll = dev_addr->dev_type == > ARPHRD_INFINIBAND ? > - IB_LINK_LAYER_INFINIBAND : IB_LINK_LAYER_ETHERNET; > + u8 port; > > - if (dev_ll != IB_LINK_LAYER_INFINIBAND && > + if (dev_addr->dev_type != ARPHRD_INFINIBAND && > id_priv->id.ps == RDMA_PS_IPOIB) > return -EINVAL; > > @@ -391,41 +408,36 @@ static int cma_acquire_dev(struct rdma_id_private > *id_priv, > > memcpy(&gid, dev_addr->src_dev_addr + > rdma_addr_gid_offset(dev_addr), sizeof gid); > - if (listen_id_priv && > - rdma_port_get_link_layer(listen_id_priv->id.device, > - listen_id_priv->id.port_num) == dev_ll) { > + > + if (listen_id_priv) { > cma_dev = listen_id_priv->cma_dev; > port = listen_id_priv->id.port_num; > - if (rdma_node_get_transport(cma_dev->device->node_type) > == RDMA_TRANSPORT_IB && > - rdma_port_get_link_layer(cma_dev->device, port) == > IB_LINK_LAYER_ETHERNET) > - ret = ib_find_cached_gid(cma_dev->device, &iboe_gid, > - &found_port, NULL); > - else > - ret = ib_find_cached_gid(cma_dev->device, &gid, > - &found_port, NULL); > + gidp = rdma_tech_iboe(cma_dev->device, port) ? > + &iboe_gid : &gid; > > - if (!ret && (port == found_port)) { > - id_priv->id.port_num = found_port; > + ret = cma_validate_port(cma_dev->device, port, gidp, > + dev_addr->dev_type); > + if (!ret) { > + id_priv->id.port_num = port; > goto out; > } > } > + > list_for_each_entry(cma_dev, &dev_list, list) { > for (port = 1; port <= cma_dev->device->phys_port_cnt; ++port) > { > if (listen_id_priv && > listen_id_priv->cma_dev == cma_dev && > listen_id_priv->id.port_num == port) > continue; > - if (rdma_port_get_link_layer(cma_dev->device, port) > == dev_ll) { > - if (rdma_node_get_transport(cma_dev- > >device->node_type) == RDMA_TRANSPORT_IB && > - rdma_port_get_link_layer(cma_dev- > >device, port) == IB_LINK_LAYER_ETHERNET) > - ret = ib_find_cached_gid(cma_dev- > >device, &iboe_gid, &found_port, NULL); > - else > - ret = ib_find_cached_gid(cma_dev- > >device, &gid, &found_port, NULL); > - > - if (!ret && (port == found_port)) { > - id_priv->id.port_num = found_port; > - goto out; > - } > + > + gidp = rdma_tech_iboe(cma_dev->device, port) ? > + &iboe_gid : &gid; > + > + ret = cma_validate_port(cma_dev->device, port, gidp, > + dev_addr->dev_type); > + if (!ret) { > + id_priv->id.port_num = port; > + goto out; > } > } > } > -- > 2.1.0 > -- > To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body > of a message to majordomo@vger.kernel.org More majordomo info at > http://vger.kernel.org/majordomo-info.html ????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?