[openib-general] [PATCH] CMA: fix port 2 loopback problems
Michael S. Tsirkin
mst at mellanox.co.il
Thu May 25 08:18:31 PDT 2006
Quoting r. Sean Hefty <mshefty at ichips.intel.com>:
> Until the underlying IB stack supports loopback connections on a non-active
> port, my thinking is to have the RDMA CM select the first active port when
> connecting in loopback.
OK. How's this?
---
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>
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);
--
MST
More information about the general
mailing list