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"))) {
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);
acm_log(0, "ERROR - failed to preload EP\n");
break;
default:
- return;
+ break;
}
switch (addr_preload) {