]> git.openfabrics.org - ~shefty/ibacm.git/commitdiff
ibacm: Allow user to specify LIDs and/or GIDs when using PR lookups
authorSean Hefty <sean.hefty@intel.com>
Mon, 3 Oct 2011 19:40:16 +0000 (12:40 -0700)
committerSean Hefty <sean.hefty@intel.com>
Mon, 28 Nov 2011 20:24:24 +0000 (12:24 -0800)
Currently, we only allow a user to lookup data with path records
if the LIDs are provided.  Handle the case where the GIDs may be
provided instead.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
src/acm.c

index d47f9d683fa4f38ff353d8287866ff1e9ceceb39..906c9267e06822658dd3b2e8ce9527d2ad0676c5 100644 (file)
--- a/src/acm.c
+++ b/src/acm.c
@@ -949,9 +949,13 @@ acm_record_path_addr(struct acm_ep *ep, struct acm_dest *dest,
 {
        acm_log(2, "%s\n", dest->name);
        dest->path.pkey = htons(ep->pkey);
-       dest->path.sgid = path->sgid;
        dest->path.dgid = path->dgid;
-       dest->path.slid = path->slid;
+       if (path->slid || !ib_any_gid(&path->sgid)) {
+               dest->path.sgid = path->sgid;
+               dest->path.slid = path->slid;
+       } else {
+               dest->path.slid = ep->port->lid;
+       }
        dest->path.dlid = path->dlid;
        dest->state = ACM_ADDR_RESOLVED;
 }
@@ -1745,10 +1749,29 @@ static void acm_svr_accept(void)
 static int
 acm_is_path_from_port(struct acm_port *port, struct ibv_path_record *path)
 {
-       if (ib_any_gid(&path->sgid)) {
+       union ibv_gid gid;
+       uint8_t i;
+
+       if (!ib_any_gid(&path->sgid)) {
+               return (acm_gid_index(port, &path->sgid) < port->gid_cnt);
+       }
+
+       if (path->slid) {
                return (port->lid == (ntohs(path->slid) & port->lid_mask));
        }
-       return (acm_gid_index(port, &path->sgid) < port->gid_cnt);
+
+       if (acm_gid_index(port, &path->dgid) < port->gid_cnt) {
+               return 1;
+       }
+
+       for (i = 0; i < port->gid_cnt; i++) {
+               ibv_query_gid(port->dev->verbs, port->port_num, i, &gid);
+               if (gid.global.subnet_prefix == path->dgid.global.subnet_prefix) {
+                       return 1;
+               }
+       }
+
+       return 0;
 }
 
 static struct acm_ep *