From: Hal Rosenstock Date: Tue, 6 Aug 2013 11:45:17 +0000 (-0400) Subject: [ibacm,2/8] acm.c: In acm_port_up, handle noncontiguous pkeys X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=c8289290b96d03e2ab3551121e5b290edd6a5038;p=~shefty%2Fibacm.git [ibacm,2/8] acm.c: In acm_port_up, handle noncontiguous pkeys 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 --- diff --git a/src/acm.c b/src/acm.c index c1d6955..2eb0e22 100644 --- 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;