2006-08-23 03:32:36 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2006 The University of Tennessee and The University
|
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2006-02-12 01:33:29 +00:00
|
|
|
#include "orte_config.h"
|
2005-07-03 23:31:27 +00:00
|
|
|
#include "opal/util/output.h"
|
2006-02-12 01:33:29 +00:00
|
|
|
#include "orte/mca/rml/rml.h"
|
|
|
|
#include "orte/mca/rml/rml_types.h"
|
|
|
|
#include "orte/mca/iof/base/base.h"
|
|
|
|
#include "orte/mca/iof/base/iof_base_header.h"
|
|
|
|
#include "orte/mca/iof/base/iof_base_endpoint.h"
|
|
|
|
#include "orte/mca/errmgr/errmgr.h"
|
2005-01-12 20:51:34 +00:00
|
|
|
#include "iof_proxy.h"
|
|
|
|
#include "iof_proxy_svc.h"
|
|
|
|
|
|
|
|
|
2005-01-13 15:27:28 +00:00
|
|
|
/*
|
|
|
|
* Local function prototypes.
|
2005-01-12 20:51:34 +00:00
|
|
|
*/
|
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
static void orte_iof_proxy_svc_msg(
|
|
|
|
const orte_process_name_t* src,
|
|
|
|
orte_iof_base_msg_header_t* msg,
|
2005-01-12 20:51:34 +00:00
|
|
|
unsigned char* data);
|
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
static void orte_iof_proxy_svc_ack(
|
|
|
|
const orte_process_name_t* src,
|
|
|
|
orte_iof_base_msg_header_t* msg);
|
2005-01-12 20:51:34 +00:00
|
|
|
|
|
|
|
|
2005-01-13 15:27:28 +00:00
|
|
|
/*
|
|
|
|
* Publish the availability of a local endpoint
|
|
|
|
* to the servver.
|
2005-01-12 20:51:34 +00:00
|
|
|
*/
|
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
int orte_iof_proxy_svc_publish(
|
|
|
|
const orte_process_name_t* name,
|
2005-01-12 20:51:34 +00:00
|
|
|
int tag)
|
|
|
|
{
|
2005-03-14 20:57:21 +00:00
|
|
|
orte_iof_base_header_t hdr;
|
2005-01-12 20:51:34 +00:00
|
|
|
struct iovec iov;
|
|
|
|
int rc;
|
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
hdr.hdr_common.hdr_type = ORTE_IOF_BASE_HDR_PUB;
|
2005-01-12 20:51:34 +00:00
|
|
|
hdr.hdr_common.hdr_status = 0;
|
|
|
|
hdr.hdr_pub.pub_name = *name;
|
2005-03-14 20:57:21 +00:00
|
|
|
hdr.hdr_pub.pub_proxy = *ORTE_RML_NAME_SELF;
|
|
|
|
hdr.hdr_pub.pub_mask = ORTE_NS_CMP_ALL;
|
2005-01-12 20:51:34 +00:00
|
|
|
hdr.hdr_pub.pub_tag = tag;
|
2005-03-14 20:57:21 +00:00
|
|
|
ORTE_IOF_BASE_HDR_PUB_NTOH(hdr.hdr_pub);
|
2005-01-12 20:51:34 +00:00
|
|
|
|
2006-08-23 03:32:36 +00:00
|
|
|
iov.iov_base = (IOVBASE_TYPE*)&hdr;
|
2005-01-12 20:51:34 +00:00
|
|
|
iov.iov_len = sizeof(hdr);
|
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
rc = orte_rml.send(
|
|
|
|
orte_iof_base.iof_service,
|
2005-01-12 20:51:34 +00:00
|
|
|
&iov,
|
|
|
|
1,
|
2005-03-14 20:57:21 +00:00
|
|
|
ORTE_RML_TAG_IOF_SVC,
|
2005-01-12 20:51:34 +00:00
|
|
|
0);
|
|
|
|
if(rc < 0) {
|
2005-03-29 19:40:38 +00:00
|
|
|
ORTE_ERROR_LOG(rc);
|
2005-01-12 20:51:34 +00:00
|
|
|
return rc;
|
|
|
|
}
|
2006-02-12 01:33:29 +00:00
|
|
|
return ORTE_SUCCESS;
|
2005-01-12 20:51:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-01-13 15:27:28 +00:00
|
|
|
/*
|
|
|
|
* Remove published endpoint from the server.
|
2005-01-12 20:51:34 +00:00
|
|
|
*/
|
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
int orte_iof_proxy_svc_unpublish(
|
|
|
|
const orte_process_name_t* name,
|
|
|
|
orte_ns_cmp_bitmask_t mask,
|
2005-01-12 20:51:34 +00:00
|
|
|
int tag)
|
|
|
|
{
|
2005-03-14 20:57:21 +00:00
|
|
|
orte_iof_base_header_t hdr;
|
2005-01-12 20:51:34 +00:00
|
|
|
struct iovec iov;
|
|
|
|
int rc;
|
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
hdr.hdr_common.hdr_type = ORTE_IOF_BASE_HDR_PUB;
|
2005-01-12 20:51:34 +00:00
|
|
|
hdr.hdr_common.hdr_status = 0;
|
|
|
|
hdr.hdr_pub.pub_name = *name;
|
2005-03-14 20:57:21 +00:00
|
|
|
hdr.hdr_pub.pub_proxy = *ORTE_RML_NAME_SELF;
|
2005-01-12 20:51:34 +00:00
|
|
|
hdr.hdr_pub.pub_mask = mask;
|
|
|
|
hdr.hdr_pub.pub_tag = tag;
|
2005-03-14 20:57:21 +00:00
|
|
|
ORTE_IOF_BASE_HDR_PUB_NTOH(hdr.hdr_pub);
|
2005-01-12 20:51:34 +00:00
|
|
|
|
2006-08-23 03:32:36 +00:00
|
|
|
iov.iov_base = (IOVBASE_TYPE*)&hdr;
|
2005-01-12 20:51:34 +00:00
|
|
|
iov.iov_len = sizeof(hdr);
|
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
rc = orte_rml.send(
|
|
|
|
orte_iof_base.iof_service,
|
2005-01-12 20:51:34 +00:00
|
|
|
&iov,
|
|
|
|
1,
|
2005-03-14 20:57:21 +00:00
|
|
|
ORTE_RML_TAG_IOF_SVC,
|
2005-01-12 20:51:34 +00:00
|
|
|
0);
|
|
|
|
if(rc < 0) {
|
2005-03-29 19:40:38 +00:00
|
|
|
ORTE_ERROR_LOG(rc);
|
2005-01-12 20:51:34 +00:00
|
|
|
return rc;
|
|
|
|
}
|
2006-02-12 01:33:29 +00:00
|
|
|
return ORTE_SUCCESS;
|
2005-01-12 20:51:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-01-13 15:27:28 +00:00
|
|
|
/*
|
|
|
|
* Subscribe one or more destination process(es) to
|
|
|
|
* one/more source process.
|
2005-01-12 20:51:34 +00:00
|
|
|
*/
|
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
int orte_iof_proxy_svc_subscribe(
|
|
|
|
const orte_process_name_t* src_name,
|
|
|
|
orte_ns_cmp_bitmask_t src_mask,
|
2005-01-12 20:51:34 +00:00
|
|
|
int src_tag,
|
2005-03-14 20:57:21 +00:00
|
|
|
const orte_process_name_t* dst_name,
|
|
|
|
orte_ns_cmp_bitmask_t dst_mask,
|
2005-01-12 20:51:34 +00:00
|
|
|
int dst_tag
|
|
|
|
)
|
|
|
|
{
|
2005-03-14 20:57:21 +00:00
|
|
|
orte_iof_base_header_t hdr;
|
2005-01-12 20:51:34 +00:00
|
|
|
struct iovec iov;
|
|
|
|
int rc;
|
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
hdr.hdr_common.hdr_type = ORTE_IOF_BASE_HDR_SUB;
|
2005-01-12 20:51:34 +00:00
|
|
|
hdr.hdr_common.hdr_status = 0;
|
|
|
|
hdr.hdr_sub.src_name = *src_name;
|
|
|
|
hdr.hdr_sub.src_mask = src_mask;
|
|
|
|
hdr.hdr_sub.src_tag = src_tag;
|
|
|
|
hdr.hdr_sub.dst_name = *dst_name;
|
|
|
|
hdr.hdr_sub.dst_mask = dst_mask;
|
|
|
|
hdr.hdr_sub.dst_tag = dst_tag;
|
2005-03-14 20:57:21 +00:00
|
|
|
ORTE_IOF_BASE_HDR_SUB_NTOH(hdr.hdr_sub);
|
2005-01-12 20:51:34 +00:00
|
|
|
|
2006-08-23 03:32:36 +00:00
|
|
|
iov.iov_base = (IOVBASE_TYPE*)&hdr;
|
2005-01-12 20:51:34 +00:00
|
|
|
iov.iov_len = sizeof(hdr);
|
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
rc = orte_rml.send(
|
|
|
|
orte_iof_base.iof_service,
|
2005-01-12 20:51:34 +00:00
|
|
|
&iov,
|
|
|
|
1,
|
2005-03-14 20:57:21 +00:00
|
|
|
ORTE_RML_TAG_IOF_SVC,
|
2005-01-12 20:51:34 +00:00
|
|
|
0);
|
|
|
|
if(rc < 0) {
|
2005-03-29 19:40:38 +00:00
|
|
|
ORTE_ERROR_LOG(rc);
|
2005-01-12 20:51:34 +00:00
|
|
|
return rc;
|
|
|
|
}
|
2006-02-12 01:33:29 +00:00
|
|
|
return ORTE_SUCCESS;
|
2005-01-12 20:51:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-01-13 15:27:28 +00:00
|
|
|
/*
|
|
|
|
* Remove subscription message from the server.
|
|
|
|
*/
|
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
int orte_iof_proxy_svc_unsubscribe(
|
|
|
|
const orte_process_name_t* src_name,
|
|
|
|
orte_ns_cmp_bitmask_t src_mask,
|
2005-01-12 20:51:34 +00:00
|
|
|
int src_tag,
|
2005-03-14 20:57:21 +00:00
|
|
|
const orte_process_name_t* dst_name,
|
|
|
|
orte_ns_cmp_bitmask_t dst_mask,
|
2005-01-12 20:51:34 +00:00
|
|
|
int dst_tag
|
|
|
|
)
|
|
|
|
{
|
2005-03-14 20:57:21 +00:00
|
|
|
orte_iof_base_header_t hdr;
|
2005-01-12 20:51:34 +00:00
|
|
|
struct iovec iov;
|
|
|
|
int rc;
|
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
hdr.hdr_common.hdr_type = ORTE_IOF_BASE_HDR_UNSUB;
|
2006-08-23 03:32:36 +00:00
|
|
|
hdr.hdr_common.hdr_reserve = (uint8_t)0;
|
|
|
|
hdr.hdr_common.hdr_status = (int16_t)0;
|
2005-01-12 20:51:34 +00:00
|
|
|
hdr.hdr_sub.src_name = *src_name;
|
|
|
|
hdr.hdr_sub.src_mask = src_mask;
|
|
|
|
hdr.hdr_sub.src_tag = src_tag;
|
|
|
|
hdr.hdr_sub.dst_name = *dst_name;
|
|
|
|
hdr.hdr_sub.dst_mask = dst_mask;
|
|
|
|
hdr.hdr_sub.dst_tag = dst_tag;
|
2005-03-14 20:57:21 +00:00
|
|
|
ORTE_IOF_BASE_HDR_SUB_NTOH(hdr.hdr_sub);
|
2005-01-12 20:51:34 +00:00
|
|
|
|
2006-08-23 03:32:36 +00:00
|
|
|
iov.iov_base = (IOVBASE_TYPE*)&hdr;
|
2005-01-12 20:51:34 +00:00
|
|
|
iov.iov_len = sizeof(hdr);
|
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
rc = orte_rml.send(
|
|
|
|
orte_iof_base.iof_service,
|
2005-01-12 20:51:34 +00:00
|
|
|
&iov,
|
|
|
|
1,
|
2005-03-14 20:57:21 +00:00
|
|
|
ORTE_RML_TAG_IOF_SVC,
|
2005-01-12 20:51:34 +00:00
|
|
|
0);
|
|
|
|
if(rc < 0) {
|
2005-03-29 19:40:38 +00:00
|
|
|
ORTE_ERROR_LOG(rc);
|
2005-01-12 20:51:34 +00:00
|
|
|
return rc;
|
|
|
|
}
|
2006-02-12 01:33:29 +00:00
|
|
|
return ORTE_SUCCESS;
|
2005-01-12 20:51:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-01-13 15:27:28 +00:00
|
|
|
/*
|
|
|
|
* Handle receipt of data/ack messages from the server
|
|
|
|
* and forward on to the appropriate endpoint.
|
|
|
|
*/
|
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
void orte_iof_proxy_svc_recv(
|
2005-01-12 20:51:34 +00:00
|
|
|
int status,
|
2005-03-14 20:57:21 +00:00
|
|
|
orte_process_name_t* src,
|
2005-01-12 20:51:34 +00:00
|
|
|
struct iovec* msg,
|
|
|
|
int count,
|
2005-03-14 20:57:21 +00:00
|
|
|
orte_rml_tag_t tag,
|
2005-01-12 20:51:34 +00:00
|
|
|
void* cbdata)
|
|
|
|
{
|
2005-03-14 20:57:21 +00:00
|
|
|
orte_iof_base_header_t* hdr = (orte_iof_base_header_t*)msg->iov_base;
|
2005-03-29 19:40:38 +00:00
|
|
|
if(NULL == msg->iov_base) {
|
2005-07-03 23:31:27 +00:00
|
|
|
opal_output(0, "orte_iof_proxy_svc_recv: invalid message\n");
|
2005-03-29 19:40:38 +00:00
|
|
|
return;
|
|
|
|
}
|
2005-01-12 20:51:34 +00:00
|
|
|
|
|
|
|
switch(hdr->hdr_common.hdr_type) {
|
2005-03-14 20:57:21 +00:00
|
|
|
case ORTE_IOF_BASE_HDR_MSG:
|
|
|
|
ORTE_IOF_BASE_HDR_MSG_NTOH(hdr->hdr_msg);
|
|
|
|
orte_iof_proxy_svc_msg(src,&hdr->hdr_msg,(unsigned char*)(hdr+1));
|
2005-01-12 20:51:34 +00:00
|
|
|
break;
|
2005-03-14 20:57:21 +00:00
|
|
|
case ORTE_IOF_BASE_HDR_ACK:
|
|
|
|
ORTE_IOF_BASE_HDR_MSG_NTOH(hdr->hdr_msg);
|
|
|
|
orte_iof_proxy_svc_ack(src,&hdr->hdr_msg);
|
2005-01-12 20:51:34 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
free(hdr);
|
|
|
|
|
|
|
|
/* repost receive */
|
|
|
|
mca_iof_proxy_component.proxy_iov[0].iov_base = NULL;
|
|
|
|
mca_iof_proxy_component.proxy_iov[0].iov_len = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-01-13 15:27:28 +00:00
|
|
|
/*
|
|
|
|
* Forward data message to the matching endpoint.
|
|
|
|
*/
|
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
static void orte_iof_proxy_svc_msg(
|
|
|
|
const orte_process_name_t* src,
|
|
|
|
orte_iof_base_msg_header_t* msg,
|
2005-01-12 20:51:34 +00:00
|
|
|
unsigned char* data)
|
|
|
|
{
|
2005-03-14 20:57:21 +00:00
|
|
|
orte_iof_base_endpoint_t* endpoint;
|
|
|
|
endpoint = orte_iof_base_endpoint_match(ORTE_RML_NAME_ANY, ORTE_NS_CMP_NONE, msg->msg_tag);
|
2005-01-12 20:51:34 +00:00
|
|
|
if(endpoint != NULL) {
|
2005-03-14 20:57:21 +00:00
|
|
|
orte_iof_base_endpoint_forward(endpoint,src,msg,data);
|
2005-01-12 20:51:34 +00:00
|
|
|
OBJ_RELEASE(endpoint);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2005-01-13 15:27:28 +00:00
|
|
|
* Forward ack message to the matching endpoint.
|
2005-01-12 20:51:34 +00:00
|
|
|
*/
|
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
static void orte_iof_proxy_svc_ack(
|
|
|
|
const orte_process_name_t* src,
|
|
|
|
orte_iof_base_msg_header_t* msg)
|
2005-01-12 20:51:34 +00:00
|
|
|
{
|
2005-03-14 20:57:21 +00:00
|
|
|
orte_iof_base_endpoint_t* endpoint;
|
|
|
|
endpoint = orte_iof_base_endpoint_match(&msg->msg_src, ORTE_NS_CMP_ALL, msg->msg_tag);
|
2005-01-12 20:51:34 +00:00
|
|
|
if(endpoint != NULL) {
|
2005-03-14 20:57:21 +00:00
|
|
|
orte_iof_base_endpoint_ack(endpoint,msg->msg_seq + msg->msg_len);
|
2005-01-12 20:51:34 +00:00
|
|
|
OBJ_RELEASE(endpoint);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|