]> git.openfabrics.org - ~shefty/ibacm.git/commitdiff
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:16:27 +0000 (10:16 -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>
Signed-off-by: Sean Hefty <sean.hefty@intel.com>
src/acm.c

index c1d6955c420d60ba743cac03ce349a2f4fe30531..2eb0e22a1f8e97e76e30e49c553878aa2271b802 100644 (file)
--- a/src/acm.c
+++ b/src/acm.c
@@ -120,7 +120,6 @@ struct acm_port {
        enum ibv_rate       rate;
        int                 subnet_timeout;
        int                 gid_cnt;
-       uint16_t            pkey_cnt;
        uint16_t            lid;
        uint16_t            lid_mask;
        uint8_t             port_num;
@@ -3192,11 +3191,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 +3208,12 @@ 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;
+               acm_ep_up(port, (uint16_t) i);
+       }
 
        acm_port_join(port);
        port->state = IBV_PORT_ACTIVE;