[openib-general] Re: [PATCH] CMA: fix port 2 loopback problems
Sean Hefty
mshefty at ichips.intel.com
Thu May 25 14:36:27 PDT 2006
Roland, can you add this patch to for-2.6.18? This is needed to support
loopback if port 1 is down, but port 2 is up. (I'm guessing that it will apply
with some offset.)
> ---
>
> Fix CMA for loopback configurations: in cma_bind_loopback, make sure sa query is
> performed from an active port.
>
> Signed-off-by: Ali Ayoub <ali at mellanox.co.il>
> Signed-off-by: Michael S. Tsirkin <mst at mellanox.co.il>
Signed-off-by: Sean Hefty <sean.hefty at intel.com>
>
> Index: openib_gen2/drivers/infiniband/core/cma.c
> ===================================================================
> --- openib_gen2.orig/drivers/infiniband/core/cma.c 2006-05-25 16:40:46.000000000 +0300
> +++ openib_gen2/drivers/infiniband/core/cma.c 2006-05-25 19:27:19.000000000 +0300
> @@ -1272,28 +1272,39 @@ EXPORT_SYMBOL(rdma_resolve_route);
> static int cma_bind_loopback(struct rdma_id_private *id_priv)
> {
> struct cma_device *cma_dev;
> + struct ib_port_attr port_attr;
> union ib_gid *gid;
> u16 pkey;
> int ret;
> + u8 p;
>
> mutex_lock(&lock);
> - if (list_empty(&dev_list)) {
> + list_for_each_entry(cma_dev, &dev_list, list)
> + for (p = 1; p <= cma_dev->device->phys_port_cnt; ++p)
> + if (!ib_query_port (cma_dev->device, p, &port_attr) &&
> + port_attr.state == IB_PORT_ACTIVE)
> + goto port_found;
> +
> + if (!list_empty(&dev_list)) {
> + p = 1;
> + cma_dev = list_entry(dev_list.next, struct cma_device, list);
> + } else {
> ret = -ENODEV;
> goto out;
> }
>
> - cma_dev = list_entry(dev_list.next, struct cma_device, list);
> +port_found:
> gid = ib_addr_get_sgid(&id_priv->id.route.addr.dev_addr);
> - ret = ib_get_cached_gid(cma_dev->device, 1, 0, gid);
> + ret = ib_get_cached_gid(cma_dev->device, p, 0, gid);
> if (ret)
> goto out;
>
> - ret = ib_get_cached_pkey(cma_dev->device, 1, 0, &pkey);
> + ret = ib_get_cached_pkey(cma_dev->device, p, 0, &pkey);
> if (ret)
> goto out;
>
> ib_addr_set_pkey(&id_priv->id.route.addr.dev_addr, pkey);
> - id_priv->id.port_num = 1;
> + id_priv->id.port_num = p;
> cma_attach_to_dev(id_priv, cma_dev);
> out:
> mutex_unlock(&lock);
>
>
More information about the general
mailing list