]> git.openfabrics.org - ~shefty/ibacm.git/commitdiff
Allow user to preload address data without route data
authorSean Hefty <sean.hefty@intel.com>
Fri, 28 Jun 2013 17:55:36 +0000 (10:55 -0700)
committerSean Hefty <sean.hefty@intel.com>
Fri, 28 Jun 2013 17:55:36 +0000 (10:55 -0700)
ACM must load routing data (path records) before it can
preload address information.  Remove this order requirement.

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

index a57ab17313fcb93cc708d91a9cbcb6da742c8eee..7f926b4878852b728914509ecd19cacdcfc23e01 100644 (file)
--- a/src/acm.c
+++ b/src/acm.c
@@ -2812,7 +2812,7 @@ static void acm_parse_hosts_file(struct acm_ep *ep)
        char addr[INET6_ADDRSTRLEN], gid[INET6_ADDRSTRLEN];
        uint8_t name[ACM_MAX_ADDRESS];
        struct in6_addr ip_addr, ib_addr;
-       struct acm_dest *dest, *new_dest;
+       struct acm_dest *dest, *gid_dest;
        uint8_t addr_type;
 
        if (!(f = fopen(addr_data_file, "r"))) {
@@ -2832,39 +2832,46 @@ static void acm_parse_hosts_file(struct acm_ep *ep)
                        acm_log(0, "ERROR - %s is not IB GID\n", gid);
                        continue;
                }
-               if (inet_pton(AF_INET, addr, &ip_addr) > 0)
+               if (inet_pton(AF_INET, addr, &ip_addr) > 0) {
                        addr_type = ACM_ADDRESS_IP;
-               else if (inet_pton(AF_INET6, addr, &ip_addr) > 0)
+               } else if (inet_pton(AF_INET6, addr, &ip_addr) > 0) {
                        addr_type = ACM_ADDRESS_IP6;
-               else {
+               else {
                        acm_log(0, "ERROR - %s is not IP address\n", addr);
                        continue;
                }
 
-               memset(name, 0, ACM_MAX_ADDRESS);
-               memcpy(name, &ib_addr, sizeof(ib_addr));
-               dest = acm_get_dest(ep, ACM_ADDRESS_GID, name);
-               if (!dest) {
-                       acm_log(0, "ERROR - IB GID %s not found in cache\n", gid);
-                       continue;
-               }
-
                memset(name, 0, ACM_MAX_ADDRESS);
                if (addr_type == ACM_ADDRESS_IP)
                        memcpy(name, &ip_addr, 4);
                else
                        memcpy(name, &ip_addr, sizeof(ip_addr));
-               new_dest = acm_acquire_dest(ep, addr_type, name);
-               if (!new_dest) {
+               dest = acm_acquire_dest(ep, addr_type, name);
+               if (!dest) {
                        acm_log(0, "ERROR - unable to create dest %s\n", addr);
                        continue;
                }
-               new_dest->path = dest->path;
-               new_dest->remote_qpn = dest->remote_qpn;
-               new_dest->addr_timeout = dest->addr_timeout;
-               new_dest->route_timeout = dest->route_timeout;
-               new_dest->state = dest->state;
-               acm_put_dest(new_dest);
+
+               memset(name, 0, ACM_MAX_ADDRESS);
+               memcpy(name, &ib_addr, sizeof(ib_addr));
+               gid_dest = acm_get_dest(ep, ACM_ADDRESS_GID, name);
+               if (gid_dest) {
+                       dest->path = gid_dest->path;
+                       dest->state = ACM_READY;
+                       acm_put_dest(gid_dest);
+               } else {
+                       memcpy(&dest->path.dgid, &ib_addr, 16);
+                       //ibv_query_gid(ep->port->dev->verbs, ep->port->port_num,
+                       //              0, &dest->path.sgid);
+                       dest->path.slid = htons(ep->port->lid);
+                       dest->path.reversible_numpath = IBV_PATH_RECORD_REVERSIBLE;
+                       dest->path.pkey = htons(ep->pkey);
+                       dest->state = ACM_ADDR_RESOLVED;
+               }
+
+               dest->remote_qpn = 1;
+               dest->addr_timeout = time_stamp_min() + (unsigned) addr_timeout;
+               dest->route_timeout = time_stamp_min() + (unsigned) route_timeout;
                acm_put_dest(dest);
                acm_log(1, "added host %s address type %d IB GID %s\n",
                        addr, addr_type, gid);
@@ -2954,7 +2961,7 @@ static void acm_ep_preload(struct acm_ep *ep)
                        acm_log(0, "ERROR - failed to preload EP\n");
                break;
        default:
-               return;
+               break;
        }
 
        switch (addr_preload) {