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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>From 77323a633072966e358c8f684e5ff4b665a27881 Mon Sep 17 00:00:00 2001
From: Jack Wang <jinpu.wang@xxxxxxxxxxxxxxxx>
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@xxxxxxxxxxxxxxxx>
Reviewed-by: Michael Wang <yun.wang@xxxxxxxxxxxxxxxx>
---
 drivers/infiniband/core/cma.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

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;

     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;
-- 
2.7.4


-- 
Jinpu Wang
Linux Kernel Developer

ProfitBricks GmbH
Greifswalder Str. 207
D - 10405 Berlin

Tel:       +49 30 577 008  042
Fax:      +49 30 577 008 299
Email:    jinpu.wang@xxxxxxxxxxxxxxxx
URL:      https://www.profitbricks.de

Sitz der Gesellschaft: Berlin
Registergericht: Amtsgericht Charlottenburg, HRB 125506 B
Geschäftsführer: Achim Weiss
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux