]> git.openfabrics.org - ~shefty/ibacm.git/commitdiff
[ibacm,2/8] acm.c: In acm_port_up, handle noncontiguous pkeys
authorHal Rosenstock <hal@dev.mellanox.co.il>
Tue, 6 Aug 2013 11:45:17 +0000 (07:45 -0400)
committerSean Hefty <sean.hefty@intel.com>
Mon, 12 Aug 2013 17:11:04 +0000 (10:11 -0700)
There can be "holes" in pkey table although this is not usually the case
but since IBA spec allows for this, it should be handled.

Signed-off-by: Hal Rosenstock <hal@mellanox.com>
src/acm.c

index c1d6955c420d60ba743cac03ce349a2f4fe30531..54c4d6240fa7451f098cfccecf1def23a4fac97c 100644 (file)
--- a/src/acm.c
+++ b/src/acm.c
@@ -3192,11 +3192,6 @@ static void acm_port_up(struct acm_port *port)
                        break;
        }
 
-       for (port->pkey_cnt = 0;; port->pkey_cnt++) {
-               ret = ibv_query_pkey(port->dev->verbs, port->port_num, port->pkey_cnt, &pkey);
-               if (ret || !pkey)
-                       break;
-       }
        port->lid = attr.lid;
        port->lid_mask = 0xffff - ((1 << attr.lmc) - 1);
 
@@ -3214,8 +3209,13 @@ static void acm_port_up(struct acm_port *port)
                return;
 
        atomic_set(&port->sa_dest.refcnt, 1);
-       for (i = 0; i < port->pkey_cnt; i++)
-                acm_ep_up(port, (uint16_t) i);
+       for (i = 0; i < attr.pkey_tbl_len; i++) {
+               ret = ibv_query_pkey(port->dev->verbs, port->port_num, i, &pkey);
+               if (ret || !pkey)
+                       continue;
+               port->pkey_cnt++;
+               acm_ep_up(port, (uint16_t) i);
+       }
 
        acm_port_join(port);
        port->state = IBV_PORT_ACTIVE;