+++ /dev/null
-Bottom: 8a0f1c3a954f8c19ea1185f654423ff1769e72c5
-Top: a15744a4e313a55d0b2bac2e14be1aed79ec75f5
-Author: Sean Hefty <sean.hefty@intel.com>
-Date: 2010-12-17 07:43:31 -0800
-
-Refresh of xref-lid
-
----
-
-diff --git a/src/acm.c b/src/acm.c
-index c08799e..5da4044 100644
---- a/src/acm.c
-+++ b/src/acm.c
-@@ -268,8 +268,13 @@ acm_format_name(int level, char *name, size_t name_size,
- break;
- case ACM_EP_INFO_PATH:
- path = (struct ibv_path_record *) addr;
-- sprintf(name, "SLID(%d) DLID(%d)",
-- ntohs(path->slid), ntohs(path->dlid));
-+ if (path->dlid) {
-+ sprintf(name, "SLID(%d) DLID(%d)",
-+ ntohs(path->slid), ntohs(path->dlid));
-+ } else {
-+ acm_format_name(level, name, name_size, ACM_ADDRESS_GID,
-+ &path->dgid, sizeof path->dgid);
-+ }
- break;
- case ACM_ADDRESS_LID:
- sprintf(name, "LID(%d)", *((uint16_t *) addr));
-@@ -731,9 +736,23 @@ static int acm_addr_index(struct acm_ep *ep, uint8_t *addr, uint8_t addr_type)
- static uint8_t
- acm_record_acm_route(struct acm_ep *ep, struct acm_dest *dest)
- {
-+ int i;
- uint8_t status;
-
- acm_log(2, "\n");
-+ for (i = 0; i < MAX_EP_ADDR; i++) {
-+ if (dest->mgid == ep->mc_dest[i].mgid)
-+ break;
-+ }
-+ if (i == MAX_EP_ADDR) {
-+ acm_log(0, "ERROR - cannot match mgid\n");
-+ return ACM_STATUS_EINVAL;
-+ }
-+
-+ dest->path = ep->mc_dest[i].path;
-+ dest->path.dgid = dest->av.grh.dgid;
-+ dest->path.dlid = htons(dest->av.dlid);
-+
- dest->ah = ibv_create_ah(ep->port->dev->pd, &dest->av);
- if (!dest->ah) {
- acm_log(0, "ERROR - failed to create ah\n");
-@@ -780,8 +799,7 @@ static uint8_t acm_resolve_path(struct acm_ep *ep, struct acm_dest *dest,
- acm_init_path_query(mad);
-
- memcpy(mad->data, &dest->path, sizeof(dest->path));
-- mad->comp_mask = IB_COMP_MASK_PR_DGID | IB_COMP_MASK_PR_SGID |
-- IB_COMP_MASK_PR_TCLASS | IB_COMP_MASK_PR_PKEY;
-+ mad->comp_mask = acm_path_comp_mask(&dest->path);
-
- dest->state = ACM_QUERY_ROUTE;
- acm_post_send(&ep->sa_queue, msg);
-@@ -809,16 +827,29 @@ acm_record_acm_addr(struct acm_ep *ep, struct acm_dest *dest, struct ibv_wc *wc,
- dest->av.grh.dgid = ((struct ibv_grh *) (uintptr_t) wc->wr_id)->sgid;
-
- dest->mgid = ep->mc_dest[index].mgid;
--
-- dest->path = ep->mc_dest[index].path;
-+ dest->path.sgid = ep->mc_dest[index].path.sgid;
- dest->path.dgid = dest->av.grh.dgid;
-- dest->path.dlid = htons(dest->av.dlid);
-+ dest->path.tclass = ep->mc_dest[index].path.tclass;
-+ dest->path.pkey = ep->mc_dest[index].path.pkey;
- dest->remote_qpn = wc->src_qp;
-
- dest->state = ACM_ADDR_RESOLVED;
- return ACM_STATUS_SUCCESS;
- }
-
-+static void
-+acm_record_path_addr(struct acm_ep *ep, struct acm_dest *dest,
-+ struct ibv_path_record *path)
-+{
-+ 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;
-+ dest->path.dlid = path->dlid;
-+ dest->state = ACM_ADDR_RESOLVED;
-+}
-+
- static uint8_t acm_validate_addr_req(struct acm_mad *mad)
- {
- struct acm_resolve_rec *rec;
-@@ -964,10 +995,12 @@ acm_dest_sa_resp(struct acm_send_msg *msg, struct ibv_wc *wc, struct acm_mad *ma
- if (!status) {
- memcpy(&dest->path, sa_mad->data, sizeof(dest->path));
- acm_init_path_av(msg->ep->port, dest);
-- dest->ah = ibv_create_ah(msg->ep->port->dev->pd, &dest->av);
-- if (!dest->ah) {
-- acm_log(0, "ERROR - failed to create ah\n");
-- status = ACM_STATUS_ENOMEM;
-+ if (dest->remote_qpn) {
-+ dest->ah = ibv_create_ah(msg->ep->port->dev->pd, &dest->av);
-+ if (!dest->ah) {
-+ acm_log(0, "ERROR - failed to create ah\n");
-+ status = ACM_STATUS_ENOMEM;
-+ }
- }
- }
- if (!status) {
-@@ -1318,9 +1351,9 @@ static uint64_t acm_path_comp_mask(struct ibv_path_record *path)
- acm_log(2, "\n");
- if (path->service_id)
- comp_mask |= IB_COMP_MASK_PR_SERVICE_ID;
-- if (path->dgid.global.interface_id || path->dgid.global.subnet_prefix)
-+ if (!ib_any_gid(&path->dgid))
- comp_mask |= IB_COMP_MASK_PR_DGID;
-- if (path->sgid.global.interface_id || path->sgid.global.subnet_prefix)
-+ if (!ib_any_gid(&path->sgid))
- comp_mask |= IB_COMP_MASK_PR_SGID;
- if (path->dlid)
- comp_mask |= IB_COMP_MASK_PR_DLID;
-@@ -1714,12 +1747,12 @@ static uint8_t acm_svr_query_sa(struct acm_ep *ep, struct acm_request *req)
- }
-
- static int
--acm_is_port_addr(struct acm_port *port, struct ibv_path_record *path)
-+acm_is_path_from_port(struct acm_port *port, struct ibv_path_record *path)
- {
-- if (path->slid) {
-- return (port->lid == (ntohs(path.slid) & ~((uint16_t) port->lid_mask)));
-+ if (ib_any_gid(&path->sgid)) {
-+ return (port->lid == (ntohs(path.slid) & port->lid_mask));
- }
--
-+ return (acm_gid_index(port, &path->sgid) < port->gid_cnt);
- }
-
- static struct acm_ep *
-@@ -1742,7 +1775,7 @@ acm_get_ep(struct acm_ep_addr_data *data)
- port = &dev->port[i];
-
- if (data->type == ACM_EP_INFO_PATH &&
-- port->lid != ntohs(data->info.path.slid))
-+ !acm_is_path_from_port(port, &data->info.path))
- continue;
-
- for (ep_entry = port->ep_list.Next; ep_entry != &port->ep_list;
-@@ -1752,8 +1785,10 @@ acm_get_ep(struct acm_ep_addr_data *data)
- if (ep->state != ACM_READY)
- continue;
-
-- if (data->type == ACM_EP_INFO_PATH)
-- return ep; // TODO: check pkey
-+ if ((data->type == ACM_EP_INFO_PATH) &&
-+ (!data->info.path.pkey ||
-+ (ntohs(data->info.path.pkey) == ep->pkey)))
-+ return ep;
-
- if (acm_addr_index(ep, data->info.addr,
- (uint8_t) data->type) >= 0)
-@@ -2090,26 +2125,23 @@ acm_svr_resolve_path(struct acm_client *client, struct acm_resolve_msg *msg)
- return acm_client_resolve_resp(client, msg, NULL, ACM_STATUS_EDESTADDR);
- }
-
-- ep = acm_get_ep(&msg->data[0]);
-- if (!ep) {
-- acm_log(0, "notice - unknown local end point\n");
-- return acm_client_resolve_resp(client, msg, NULL, ACM_STATUS_ESRCADDR);
-- }
--/*
- acm_format_name(2, log_data, sizeof log_data,
-- saddr->type, saddr->info.addr, sizeof saddr->info.addr);
-- acm_log(2, "src %s\n", log_data);
-- ep = acm_get_ep(saddr);
-+ ACM_EP_INFO_PATH, path, sizeof *path);
-+ acm_log(2, "path %s\n", log_data);
-+ ep = acm_get_ep(&msg->data[0]);
- if (!ep) {
- acm_log(0, "notice - unknown local end point\n");
- return acm_client_resolve_resp(client, msg, NULL, ACM_STATUS_ESRCADDR);
- }
-
-- acm_format_name(2, log_data, sizeof log_data,
-- daddr->type, daddr->info.addr, sizeof daddr->info.addr);
-- acm_log(2, "dest %s\n", log_data);
--
-- dest = acm_acquire_dest(ep, daddr->type, daddr->info.addr);
-+ memset(addr, 0, sizeof addr);
-+ if (path->dlid) {
-+ * ((uint16_t *) addr) = path->dlid;
-+ dest = acm_acquire_dest(ep, ACM_ADDRESS_LID, addr);
-+ } else {
-+ memcpy(addr, &path->dgid, sizeof path->dgid);
-+ dest = acm_acquire_dest(ep, ACM_ADDRESS_GID, addr);
-+ }
- if (!dest) {
- acm_log(0, "ERROR - unable to allocate destination in client request\n");
- return acm_client_resolve_resp(client, msg, NULL, ACM_STATUS_ENOMEM);
-@@ -2121,26 +2153,19 @@ acm_svr_resolve_path(struct acm_client *client, struct acm_resolve_msg *msg)
- acm_log(2, "request satisfied from local cache\n");
- status = ACM_STATUS_SUCCESS;
- break;
-+ case ACM_INIT:
-+ acm_log(2, "have path, bypassing address resolution");
-+ acm_record_path_addr(ep, dest, path);
-+ /* fall through */
- case ACM_ADDR_RESOLVED:
- acm_log(2, "have address, resolving route\n");
- status = acm_resolve_path(ep, dest, acm_dest_sa_resp);
- if (status) {
- break;
- }
-- goto queue;
-- case ACM_INIT:
-- acm_log(2, "sending resolve msg to dest\n");
-- status = acm_send_resolve(ep, dest, saddr);
-- if (status) {
-- break;
-- }
-- dest->state = ACM_QUERY_ADDR;
--*/
- /* fall through */
--/*
- default:
--queue:
-- if (daddr->flags & ACM_FLAGS_NODELAY) {
-+ if (msg->data[0].flags & ACM_FLAGS_NODELAY) {
- acm_log(2, "lookup initiated, but client wants no delay\n");
- status = ACM_STATUS_ENODATA;
- break;
-@@ -2155,7 +2180,6 @@ queue:
- }
- lock_release(&dest->lock);
- ret = acm_client_resolve_resp(client, msg, dest, status);
--*/
- put:
- acm_put_dest(dest);
- return ret;
Bottom: b2af32a606dc3c3e64f150250320dc7d52426926
-Top: 8a0f1c3a954f8c19ea1185f654423ff1769e72c5
+Top: a15744a4e313a55d0b2bac2e14be1aed79ec75f5
Author: Sean Hefty <sean.hefty@intel.com>
Date: 2010-12-13 10:35:40 -0800
-ibacm: cross-reference destination endpoints in LID map
+ibacm: add support for path lookup by LID/GID
-After resolving remote endpoint information, we record
-the destination data in a specific dest_map based on the
-destination's type. To support queries against cached
-data that uses alternate address information, such as
-LID or GID, also reference the destination in the LID
-dest_map. This allows us to find the destination based
-on LID, as well as the original address.
+Support caching path data by LID/GID. We limit data
+to one path per DLID/DGID.
Signed-off-by: Sean Hefty <sean.hefty@intel.com>
---
diff --git a/src/acm.c b/src/acm.c
-index e0f0b94..c08799e 100644
+index e0f0b94..5da4044 100644
--- a/src/acm.c
+++ b/src/acm.c
-@@ -280,6 +280,11 @@ acm_format_name(int level, char *name, size_t name_size,
+@@ -268,8 +268,13 @@ acm_format_name(int level, char *name, size_t name_size,
+ break;
+ case ACM_EP_INFO_PATH:
+ path = (struct ibv_path_record *) addr;
+- sprintf(name, "SLID(%d) DLID(%d)",
+- ntohs(path->slid), ntohs(path->dlid));
++ if (path->dlid) {
++ sprintf(name, "SLID(%d) DLID(%d)",
++ ntohs(path->slid), ntohs(path->dlid));
++ } else {
++ acm_format_name(level, name, name_size, ACM_ADDRESS_GID,
++ &path->dgid, sizeof path->dgid);
++ }
+ break;
+ case ACM_ADDRESS_LID:
+ sprintf(name, "LID(%d)", *((uint16_t *) addr));
+@@ -280,6 +285,11 @@ acm_format_name(int level, char *name, size_t name_size,
}
}
static int acm_compare_dest(const void *dest1, const void *dest2)
{
return memcmp(dest1, dest2, ACM_MAX_ADDRESS);
-@@ -1708,6 +1713,15 @@ static uint8_t acm_svr_query_sa(struct acm_ep *ep, struct acm_request *req)
+@@ -726,9 +736,23 @@ static int acm_addr_index(struct acm_ep *ep, uint8_t *addr, uint8_t addr_type)
+ static uint8_t
+ acm_record_acm_route(struct acm_ep *ep, struct acm_dest *dest)
+ {
++ int i;
+ uint8_t status;
+
+ acm_log(2, "\n");
++ for (i = 0; i < MAX_EP_ADDR; i++) {
++ if (dest->mgid == ep->mc_dest[i].mgid)
++ break;
++ }
++ if (i == MAX_EP_ADDR) {
++ acm_log(0, "ERROR - cannot match mgid\n");
++ return ACM_STATUS_EINVAL;
++ }
++
++ dest->path = ep->mc_dest[i].path;
++ dest->path.dgid = dest->av.grh.dgid;
++ dest->path.dlid = htons(dest->av.dlid);
++
+ dest->ah = ibv_create_ah(ep->port->dev->pd, &dest->av);
+ if (!dest->ah) {
+ acm_log(0, "ERROR - failed to create ah\n");
+@@ -775,8 +799,7 @@ static uint8_t acm_resolve_path(struct acm_ep *ep, struct acm_dest *dest,
+ acm_init_path_query(mad);
+
+ memcpy(mad->data, &dest->path, sizeof(dest->path));
+- mad->comp_mask = IB_COMP_MASK_PR_DGID | IB_COMP_MASK_PR_SGID |
+- IB_COMP_MASK_PR_TCLASS | IB_COMP_MASK_PR_PKEY;
++ mad->comp_mask = acm_path_comp_mask(&dest->path);
+
+ dest->state = ACM_QUERY_ROUTE;
+ acm_post_send(&ep->sa_queue, msg);
+@@ -804,16 +827,29 @@ acm_record_acm_addr(struct acm_ep *ep, struct acm_dest *dest, struct ibv_wc *wc,
+ dest->av.grh.dgid = ((struct ibv_grh *) (uintptr_t) wc->wr_id)->sgid;
+
+ dest->mgid = ep->mc_dest[index].mgid;
+-
+- dest->path = ep->mc_dest[index].path;
++ dest->path.sgid = ep->mc_dest[index].path.sgid;
+ dest->path.dgid = dest->av.grh.dgid;
+- dest->path.dlid = htons(dest->av.dlid);
++ dest->path.tclass = ep->mc_dest[index].path.tclass;
++ dest->path.pkey = ep->mc_dest[index].path.pkey;
+ dest->remote_qpn = wc->src_qp;
+
+ dest->state = ACM_ADDR_RESOLVED;
+ return ACM_STATUS_SUCCESS;
+ }
+
++static void
++acm_record_path_addr(struct acm_ep *ep, struct acm_dest *dest,
++ struct ibv_path_record *path)
++{
++ 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;
++ dest->path.dlid = path->dlid;
++ dest->state = ACM_ADDR_RESOLVED;
++}
++
+ static uint8_t acm_validate_addr_req(struct acm_mad *mad)
+ {
+ struct acm_resolve_rec *rec;
+@@ -959,10 +995,12 @@ acm_dest_sa_resp(struct acm_send_msg *msg, struct ibv_wc *wc, struct acm_mad *ma
+ if (!status) {
+ memcpy(&dest->path, sa_mad->data, sizeof(dest->path));
+ acm_init_path_av(msg->ep->port, dest);
+- dest->ah = ibv_create_ah(msg->ep->port->dev->pd, &dest->av);
+- if (!dest->ah) {
+- acm_log(0, "ERROR - failed to create ah\n");
+- status = ACM_STATUS_ENOMEM;
++ if (dest->remote_qpn) {
++ dest->ah = ibv_create_ah(msg->ep->port->dev->pd, &dest->av);
++ if (!dest->ah) {
++ acm_log(0, "ERROR - failed to create ah\n");
++ status = ACM_STATUS_ENOMEM;
++ }
+ }
+ }
+ if (!status) {
+@@ -1313,9 +1351,9 @@ static uint64_t acm_path_comp_mask(struct ibv_path_record *path)
+ acm_log(2, "\n");
+ if (path->service_id)
+ comp_mask |= IB_COMP_MASK_PR_SERVICE_ID;
+- if (path->dgid.global.interface_id || path->dgid.global.subnet_prefix)
++ if (!ib_any_gid(&path->dgid))
+ comp_mask |= IB_COMP_MASK_PR_DGID;
+- if (path->sgid.global.interface_id || path->sgid.global.subnet_prefix)
++ if (!ib_any_gid(&path->sgid))
+ comp_mask |= IB_COMP_MASK_PR_SGID;
+ if (path->dlid)
+ comp_mask |= IB_COMP_MASK_PR_DLID;
+@@ -1708,6 +1746,15 @@ static uint8_t acm_svr_query_sa(struct acm_ep *ep, struct acm_request *req)
return ACM_STATUS_SUCCESS;
}
+static int
-+acm_is_port_addr(struct acm_port *port, struct ibv_path_record *path)
++acm_is_path_from_port(struct acm_port *port, struct ibv_path_record *path)
+{
-+ if (path->slid) {
-+ return (port->lid == (ntohs(path.slid) & ~((uint16_t) port->lid_mask)));
++ if (ib_any_gid(&path->sgid)) {
++ return (port->lid == (ntohs(path.slid) & port->lid_mask));
+ }
-+
++ return (acm_gid_index(port, &path->sgid) < port->gid_cnt);
+}
+
static struct acm_ep *
acm_get_ep(struct acm_ep_addr_data *data)
{
-@@ -1768,12 +1782,6 @@ acm_svr_query(struct acm_client *client, struct acm_resolve_msg *msg)
+@@ -1728,7 +1775,7 @@ acm_get_ep(struct acm_ep_addr_data *data)
+ port = &dev->port[i];
+
+ if (data->type == ACM_EP_INFO_PATH &&
+- port->lid != ntohs(data->info.path.slid))
++ !acm_is_path_from_port(port, &data->info.path))
+ continue;
+
+ for (ep_entry = port->ep_list.Next; ep_entry != &port->ep_list;
+@@ -1738,8 +1785,10 @@ acm_get_ep(struct acm_ep_addr_data *data)
+ if (ep->state != ACM_READY)
+ continue;
+
+- if (data->type == ACM_EP_INFO_PATH)
+- return ep; // TODO: check pkey
++ if ((data->type == ACM_EP_INFO_PATH) &&
++ (!data->info.path.pkey ||
++ (ntohs(data->info.path.pkey) == ep->pkey)))
++ return ep;
+
+ if (acm_addr_index(ep, data->info.addr,
+ (uint8_t) data->type) >= 0)
+@@ -1768,12 +1817,6 @@ acm_svr_query(struct acm_client *client, struct acm_resolve_msg *msg)
goto resp;
}
ep = acm_get_ep(&msg->data[0]);
if (!ep) {
acm_log(1, "notice - could not find local end point\n");
-@@ -2060,6 +2068,99 @@ put:
+@@ -2060,6 +2103,88 @@ put:
return ret;
}
+ return acm_client_resolve_resp(client, msg, NULL, ACM_STATUS_EDESTADDR);
+ }
+
-+ ep = acm_get_ep(&msg->data[0]);
-+ if (!ep) {
-+ acm_log(0, "notice - unknown local end point\n");
-+ return acm_client_resolve_resp(client, msg, NULL, ACM_STATUS_ESRCADDR);
-+ }
-+/*
+ acm_format_name(2, log_data, sizeof log_data,
-+ saddr->type, saddr->info.addr, sizeof saddr->info.addr);
-+ acm_log(2, "src %s\n", log_data);
-+ ep = acm_get_ep(saddr);
++ ACM_EP_INFO_PATH, path, sizeof *path);
++ acm_log(2, "path %s\n", log_data);
++ ep = acm_get_ep(&msg->data[0]);
+ if (!ep) {
+ acm_log(0, "notice - unknown local end point\n");
+ return acm_client_resolve_resp(client, msg, NULL, ACM_STATUS_ESRCADDR);
+ }
+
-+ acm_format_name(2, log_data, sizeof log_data,
-+ daddr->type, daddr->info.addr, sizeof daddr->info.addr);
-+ acm_log(2, "dest %s\n", log_data);
-+
-+ dest = acm_acquire_dest(ep, daddr->type, daddr->info.addr);
++ memset(addr, 0, sizeof addr);
++ if (path->dlid) {
++ * ((uint16_t *) addr) = path->dlid;
++ dest = acm_acquire_dest(ep, ACM_ADDRESS_LID, addr);
++ } else {
++ memcpy(addr, &path->dgid, sizeof path->dgid);
++ dest = acm_acquire_dest(ep, ACM_ADDRESS_GID, addr);
++ }
+ if (!dest) {
+ acm_log(0, "ERROR - unable to allocate destination in client request\n");
+ return acm_client_resolve_resp(client, msg, NULL, ACM_STATUS_ENOMEM);
+ acm_log(2, "request satisfied from local cache\n");
+ status = ACM_STATUS_SUCCESS;
+ break;
++ case ACM_INIT:
++ acm_log(2, "have path, bypassing address resolution");
++ acm_record_path_addr(ep, dest, path);
++ /* fall through */
+ case ACM_ADDR_RESOLVED:
+ acm_log(2, "have address, resolving route\n");
+ status = acm_resolve_path(ep, dest, acm_dest_sa_resp);
+ if (status) {
+ break;
+ }
-+ goto queue;
-+ case ACM_INIT:
-+ acm_log(2, "sending resolve msg to dest\n");
-+ status = acm_send_resolve(ep, dest, saddr);
-+ if (status) {
-+ break;
-+ }
-+ dest->state = ACM_QUERY_ADDR;
-+*/
+ /* fall through */
-+/*
+ default:
-+queue:
-+ if (daddr->flags & ACM_FLAGS_NODELAY) {
++ if (msg->data[0].flags & ACM_FLAGS_NODELAY) {
+ acm_log(2, "lookup initiated, but client wants no delay\n");
+ status = ACM_STATUS_ENODATA;
+ break;
+ }
+ lock_release(&dest->lock);
+ ret = acm_client_resolve_resp(client, msg, dest, status);
-+*/
+put:
+ acm_put_dest(dest);
+ return ret;
static void acm_svr_receive(struct acm_client *client)
{
struct acm_msg msg;
-@@ -2085,7 +2186,11 @@ static void acm_svr_receive(struct acm_client *client)
+@@ -2085,7 +2210,11 @@ static void acm_svr_receive(struct acm_client *client)
}
if (resolve_msg->data[0].type == ACM_EP_INFO_PATH) {