diff mbox

[3/4] cma: resolve to first active ib port

Message ID CAMGffEm408nbzSqo-uSQGekenZfOX+HOeheRg1tvVGT8Y1=2XQ@mail.gmail.com (mailing list archive)
State Changes Requested
Headers show

Commit Message

Jinpu Wang Dec. 12, 2016, 11:48 a.m. UTC
From 77323a633072966e358c8f684e5ff4b665a27881 Mon Sep 17 00:00:00 2001
From: Jack Wang <jinpu.wang@profitbricks.com>
Date: Mon, 12 Dec 2016 10:23:55 +0100
Subject: [PATCH 3/4] cma: resolve to first active ib port

When resolve addr if we don't give src addr, cma core will try to resolve to
ib device on itself, current logic is only check if it has same
subnet_prefix, which is not enough if we use default well known gid,
we should also check if port is active.

v3: use cached port_active state in ib_core.

Signed-off-by: Jack Wang <jinpu.wang@profitbricks.com>
Reviewed-by: Michael Wang <yun.wang@profitbricks.com>
---
 drivers/infiniband/core/cma.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

     cma_dev = NULL;
@@ -681,6 +682,8 @@ static int cma_resolve_ib_dev(struct
rdma_id_private *id_priv)
             if (ib_find_cached_pkey(cur_dev->device, p, pkey, &index))
                 continue;

+            if (ib_get_cached_port_state(cur_dev->device, p, &port_state))
+                continue;
             for (i = 0; !ib_get_cached_gid(cur_dev->device, p, i,
                                &gid, NULL);
                  i++) {
@@ -692,7 +695,8 @@ static int cma_resolve_ib_dev(struct
rdma_id_private *id_priv)
                 }

                 if (!cma_dev && (gid.global.subnet_prefix ==
-                         dgid->global.subnet_prefix)) {
+                    dgid->global.subnet_prefix) &&
+                    port_state == IB_PORT_ACTIVE) {
                     cma_dev = cur_dev;
                     sgid = gid;
                     id_priv->id.port_num = p;

Comments

Hefty, Sean Dec. 19, 2016, 5:29 p.m. UTC | #1
PiBXaGVuIHJlc29sdmUgYWRkciBpZiB3ZSBkb24ndCBnaXZlIHNyYyBhZGRyLCBjbWEgY29yZSB3
aWxsIHRyeSB0bw0KPiByZXNvbHZlIHRvDQo+IGliIGRldmljZSBvbiBpdHNlbGYsIGN1cnJlbnQg
bG9naWMgaXMgb25seSBjaGVjayBpZiBpdCBoYXMgc2FtZQ0KPiBzdWJuZXRfcHJlZml4LCB3aGlj
aCBpcyBub3QgZW5vdWdoIGlmIHdlIHVzZSBkZWZhdWx0IHdlbGwga25vd24gZ2lkLA0KPiB3ZSBz
aG91bGQgYWxzbyBjaGVjayBpZiBwb3J0IGlzIGFjdGl2ZS4NCj4gDQo+IHYzOiB1c2UgY2FjaGVk
IHBvcnRfYWN0aXZlIHN0YXRlIGluIGliX2NvcmUuDQo+IA0KPiBTaWduZWQtb2ZmLWJ5OiBKYWNr
IFdhbmcgPGppbnB1LndhbmdAcHJvZml0YnJpY2tzLmNvbT4NCj4gUmV2aWV3ZWQtYnk6IE1pY2hh
ZWwgV2FuZyA8eXVuLndhbmdAcHJvZml0YnJpY2tzLmNvbT4NCg0KQWNrZWQtYnk6IFNlYW4gSGVm
dHkgPHNlYW4uaGVmdHlAaW50ZWwuY29tPg0K
--
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
diff mbox

Patch

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 2a6fc47..3413aec 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -666,6 +666,7 @@  static int cma_resolve_ib_dev(struct
rdma_id_private *id_priv)
     union ib_gid gid, sgid, *dgid;
     u16 pkey, index;
     u8 p;
+    enum ib_port_state port_state;
     int i;