Version: 1
-Previous: 40bb11680a462baf92ee1456b10c981d39f839cf
-Head: 2c9b375984328bcec7740fbbfaee1ef7c669dd41
+Previous: b2559f569de9eec5015d7cb9a21d367920505fbf
+Head: 8e00708e882239292492e13aa51c82042255933c
Applied:
- name2ip: ce45e1e38310d078ecb884c62c1e50249cf7a738
- refresh-temp: 2c9b375984328bcec7740fbbfaee1ef7c669dd41
+ name2ip: 8e00708e882239292492e13aa51c82042255933c
Unapplied:
addr_size: 8de02c47fbf595132105a7050ad6f755f49f9a7a
Hidden:
Bottom: e8b5bb1cf92f403d8767fc1d61cb8c538da64fe3
-Top: f2aca0319d2fae60371ce6d7217a564f5e363c3c
+Top: b51c859aabeb9d4834702625abd3bb4e7dff04cb
Author: Sean Hefty <sean.hefty@intel.com>
Date: 2011-04-04 17:29:06 -0700
union acm_ep_info info;
};
diff --git a/src/acm.c b/src/acm.c
-index 53a8e7b..de46dff 100644
+index 53a8e7b..19cf3f8 100644
--- a/src/acm.c
+++ b/src/acm.c
@@ -48,6 +48,7 @@
#define MAX_EP_ADDR 4
#define MAX_EP_MC 2
+@@ -786,6 +787,17 @@ static int acm_addr_index(struct acm_ep *ep, uint8_t *addr, uint8_t addr_type)
+ return -1;
+ }
+
++static int acm_type_index(struct acm_ep *ep, uint8_t addr_type)
++{
++ int i;
++
++ for (i = 0; i < MAX_EP_ADDR; i++) {
++ if (ep->addr_type[i] == addr_type)
++ return i;
++ }
++ return -1;
++}
++
+ static uint8_t
+ acm_record_acm_route(struct acm_ep *ep, struct acm_dest *dest)
+ {
+@@ -1149,8 +1161,11 @@ acm_process_addr_req(struct acm_ep *ep, struct ibv_wc *wc, struct acm_mad *mad)
+ }
+
+ addr_index = acm_addr_index(ep, rec->dest, rec->dest_type);
+- if (addr_index >= 0)
++ if (addr_index >= 0) {
+ dest->req_id = mad->tid;
++ if (rec->src_type != rec->dest_type)
++ acm_translate_rec_addr(ep, rec, &addr_index);
++ }
+
+ lock_acquire(&dest->lock);
+ acm_log(2, "dest state %d\n", dest->state);
+@@ -1779,6 +1794,48 @@ acm_get_port_ep(struct acm_port *port, struct acm_ep_addr_data *data)
+ return NULL;
+ }
+
++static int acm_translate_addr(struct acm_ep *ep, struct acm_ep_addr_data *data)
++{
++ int i;
++
++ for (i = 0; i < MAX_EP_ADDR; i++) {
++ if (ep->addr_type[i] == data->out_type) {
++ data->type = data->out_type;
++ data->info = ep->addr[i];
++ acm_format_name(2, log_data, sizeof log_data,
++ data->type, data->info.addr, sizeof data->info.addr);
++ acm_log(2, "translated addr %s\n", log_data);
++ return 0;
++ }
++ }
++
++ acm_format_name(1, log_data, sizeof log_data,
++ data->type, data->info.addr, sizeof data->info.addr);
++ acm_log(1, "no translation available for %s\n", log_data);
++ return -1;
++}
++
++static void acm_translate_rec_addr(struct acm_ep *ep, struct acm_resolve_rec *rec,
++ int *addr_index)
++{
++ int i;
++
++ i = acm_type_index(rec->src_type);
++ if (i < 0) {
++ acm_format_name(2, log_data, sizeof log_data,
++ rec->dest_type, rec->dest, sizeof rec->dest);
++ acm_log(0, "notice - no translation for %s\n", log_data);
++ return;
++ }
++
++ rec->dest_type = rec->src_type;
++ memcpy(rec->dest, ep->addr[i].addr, sizeof rec->dest);
++ *addr_index = i;
++ acm_format_name(2, log_data, sizeof log_data,
++ rec->dest_type, rec->dest, sizeof rec->dest);
++ acm_log(0, "translated address to %s\n", log_data);
++}
++
+ static struct acm_ep *
+ acm_get_ep(struct acm_ep_addr_data *data)
+ {
+@@ -1983,6 +2040,7 @@ acm_svr_verify_resolve(struct acm_resolve_msg *msg,
+ struct acm_ep_addr_data **saddr, struct acm_ep_addr_data **daddr)
+ {
+ struct acm_ep_addr_data *src = NULL, *dst = NULL;
++ struct acm_ep_addr_data *data;
+ int i, cnt;
+
+ if (msg->hdr.length < ACM_MSG_HDR_LENGTH) {
+@@ -1992,27 +2050,32 @@ acm_svr_verify_resolve(struct acm_resolve_msg *msg,
+
+ cnt = (msg->hdr.length - ACM_MSG_HDR_LENGTH) / ACM_MSG_EP_LENGTH;
+ for (i = 0; i < cnt; i++) {
+- if (msg->data[i].flags & ACM_EP_FLAG_SOURCE) {
++ data = &msg->data[i];
++ if (data->flags & ACM_EP_FLAG_SOURCE) {
+ if (src) {
+ acm_log(0, "ERROR - multiple sources specified\n");
+ return ACM_STATUS_ESRCADDR;
+ }
+- if (!msg->data[i].type || (msg->data[i].type >= ACM_ADDRESS_RESERVED)) {
++ if (!data->type || (data->type >= ACM_ADDRESS_RESERVED)) {
+ acm_log(0, "ERROR - unsupported source address type\n");
+ return ACM_STATUS_ESRCTYPE;
+ }
+- src = &msg->data[i];
++ src = data;
++ if (src->out_type && (src->out_type < ACM_ADDRESS_RESERVED))
++ msg->hdr.src_out = i;
+ }
+- if (msg->data[i].flags & ACM_EP_FLAG_DEST) {
++ if (data->flags & ACM_EP_FLAG_DEST) {
+ if (dst) {
+ acm_log(0, "ERROR - multiple destinations specified\n");
+ return ACM_STATUS_EDESTADDR;
+ }
+- if (!msg->data[i].type || (msg->data[i].type >= ACM_ADDRESS_RESERVED)) {
++ if (!data->type || (data->type >= ACM_ADDRESS_RESERVED)) {
+ acm_log(0, "ERROR - unsupported destination address type\n");
+ return ACM_STATUS_EDESTTYPE;
+ }
+- dst = &msg->data[i];
++ dst = data;
++ if (dst->out_type && (dst->out_type < ACM_ADDRESS_RESERVED))
++ msg->hdr.dst_out = i;
+ }
+ }
+
+@@ -2079,6 +2142,11 @@ acm_svr_resolve(struct acm_client *client, struct acm_resolve_msg *msg)
+ return acm_client_resolve_resp(client, msg, NULL, ACM_STATUS_ESRCADDR);
+ }
+
++ if (saddr->out_type && !acm_translate_addr(ep, saddr)) {
++ acm_log(0, "notice - cannot translate source address\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);
diff --git a/src/acme.c b/src/acme.c
index d42ba81..8138109 100644
--- a/src/acme.c
+++ /dev/null
-Bottom: f2aca0319d2fae60371ce6d7217a564f5e363c3c
-Top: b51c859aabeb9d4834702625abd3bb4e7dff04cb
-Author: Sean Hefty <sean.hefty@intel.com>
-Date: 2011-04-07 09:36:14 -0700
-
-Refresh of name2ip
-
----
-
-diff --git a/src/acm.c b/src/acm.c
-index de46dff..19cf3f8 100644
---- a/src/acm.c
-+++ b/src/acm.c
-@@ -787,6 +787,17 @@ static int acm_addr_index(struct acm_ep *ep, uint8_t *addr, uint8_t addr_type)
- return -1;
- }
-
-+static int acm_type_index(struct acm_ep *ep, uint8_t addr_type)
-+{
-+ int i;
-+
-+ for (i = 0; i < MAX_EP_ADDR; i++) {
-+ if (ep->addr_type[i] == addr_type)
-+ return i;
-+ }
-+ return -1;
-+}
-+
- static uint8_t
- acm_record_acm_route(struct acm_ep *ep, struct acm_dest *dest)
- {
-@@ -1150,8 +1161,11 @@ acm_process_addr_req(struct acm_ep *ep, struct ibv_wc *wc, struct acm_mad *mad)
- }
-
- addr_index = acm_addr_index(ep, rec->dest, rec->dest_type);
-- if (addr_index >= 0)
-+ if (addr_index >= 0) {
- dest->req_id = mad->tid;
-+ if (rec->src_type != rec->dest_type)
-+ acm_translate_rec_addr(ep, rec, &addr_index);
-+ }
-
- lock_acquire(&dest->lock);
- acm_log(2, "dest state %d\n", dest->state);
-@@ -1780,6 +1794,48 @@ acm_get_port_ep(struct acm_port *port, struct acm_ep_addr_data *data)
- return NULL;
- }
-
-+static int acm_translate_addr(struct acm_ep *ep, struct acm_ep_addr_data *data)
-+{
-+ int i;
-+
-+ for (i = 0; i < MAX_EP_ADDR; i++) {
-+ if (ep->addr_type[i] == data->out_type) {
-+ data->type = data->out_type;
-+ data->info = ep->addr[i];
-+ acm_format_name(2, log_data, sizeof log_data,
-+ data->type, data->info.addr, sizeof data->info.addr);
-+ acm_log(2, "translated addr %s\n", log_data);
-+ return 0;
-+ }
-+ }
-+
-+ acm_format_name(1, log_data, sizeof log_data,
-+ data->type, data->info.addr, sizeof data->info.addr);
-+ acm_log(1, "no translation available for %s\n", log_data);
-+ return -1;
-+}
-+
-+static void acm_translate_rec_addr(struct acm_ep *ep, struct acm_resolve_rec *rec,
-+ int *addr_index)
-+{
-+ int i;
-+
-+ i = acm_type_index(rec->src_type);
-+ if (i < 0) {
-+ acm_format_name(2, log_data, sizeof log_data,
-+ rec->dest_type, rec->dest, sizeof rec->dest);
-+ acm_log(0, "notice - no translation for %s\n", log_data);
-+ return;
-+ }
-+
-+ rec->dest_type = rec->src_type;
-+ memcpy(rec->dest, ep->addr[i].addr, sizeof rec->dest);
-+ *addr_index = i;
-+ acm_format_name(2, log_data, sizeof log_data,
-+ rec->dest_type, rec->dest, sizeof rec->dest);
-+ acm_log(0, "translated address to %s\n", log_data);
-+}
-+
- static struct acm_ep *
- acm_get_ep(struct acm_ep_addr_data *data)
- {
-@@ -1984,6 +2040,7 @@ acm_svr_verify_resolve(struct acm_resolve_msg *msg,
- struct acm_ep_addr_data **saddr, struct acm_ep_addr_data **daddr)
- {
- struct acm_ep_addr_data *src = NULL, *dst = NULL;
-+ struct acm_ep_addr_data *data;
- int i, cnt;
-
- if (msg->hdr.length < ACM_MSG_HDR_LENGTH) {
-@@ -1993,27 +2050,32 @@ acm_svr_verify_resolve(struct acm_resolve_msg *msg,
-
- cnt = (msg->hdr.length - ACM_MSG_HDR_LENGTH) / ACM_MSG_EP_LENGTH;
- for (i = 0; i < cnt; i++) {
-- if (msg->data[i].flags & ACM_EP_FLAG_SOURCE) {
-+ data = &msg->data[i];
-+ if (data->flags & ACM_EP_FLAG_SOURCE) {
- if (src) {
- acm_log(0, "ERROR - multiple sources specified\n");
- return ACM_STATUS_ESRCADDR;
- }
-- if (!msg->data[i].type || (msg->data[i].type >= ACM_ADDRESS_RESERVED)) {
-+ if (!data->type || (data->type >= ACM_ADDRESS_RESERVED)) {
- acm_log(0, "ERROR - unsupported source address type\n");
- return ACM_STATUS_ESRCTYPE;
- }
-- src = &msg->data[i];
-+ src = data;
-+ if (src->out_type && (src->out_type < ACM_ADDRESS_RESERVED))
-+ msg->hdr.src_out = i;
- }
-- if (msg->data[i].flags & ACM_EP_FLAG_DEST) {
-+ if (data->flags & ACM_EP_FLAG_DEST) {
- if (dst) {
- acm_log(0, "ERROR - multiple destinations specified\n");
- return ACM_STATUS_EDESTADDR;
- }
-- if (!msg->data[i].type || (msg->data[i].type >= ACM_ADDRESS_RESERVED)) {
-+ if (!data->type || (data->type >= ACM_ADDRESS_RESERVED)) {
- acm_log(0, "ERROR - unsupported destination address type\n");
- return ACM_STATUS_EDESTTYPE;
- }
-- dst = &msg->data[i];
-+ dst = data;
-+ if (dst->out_type && (dst->out_type < ACM_ADDRESS_RESERVED))
-+ msg->hdr.dst_out = i;
- }
- }
-
-@@ -2080,6 +2142,11 @@ acm_svr_resolve(struct acm_client *client, struct acm_resolve_msg *msg)
- return acm_client_resolve_resp(client, msg, NULL, ACM_STATUS_ESRCADDR);
- }
-
-+ if (saddr->out_type && !acm_translate_addr(ep, saddr)) {
-+ acm_log(0, "notice - cannot translate source address\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);