Ejemplo n.º 1
0
/*---------------------------------------------------------------------------*/
na_return_t
NA_Mem_handle_create_segments(na_class_t *na_class, struct na_segment *segments,
        na_size_t segment_count, unsigned long flags,
        na_mem_handle_t *mem_handle)
{
    na_return_t ret = NA_SUCCESS;

    if (!na_class) {
        NA_LOG_ERROR("NULL NA class");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    if (!segments) {
        NA_LOG_ERROR("NULL pointer to segments");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    if (!segment_count) {
        NA_LOG_ERROR("NULL segment count");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    if (!na_class->mem_handle_create_segments) {
        NA_LOG_ERROR("mem_handle_create_segments plugin callback is not defined");
        ret = NA_PROTOCOL_ERROR;
        goto done;
    }

    ret = na_class->mem_handle_create_segments(na_class, segments,
            segment_count, flags, mem_handle);

done:
    return ret;
}
Ejemplo n.º 2
0
/*---------------------------------------------------------------------------*/
na_return_t
NA_Addr_to_string(na_class_t *na_class, char *buf, na_size_t *buf_size,
        na_addr_t addr)
{
    na_return_t ret = NA_SUCCESS;

    if (!na_class) {
        NA_LOG_ERROR("NULL NA class");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    /* buf can be NULL */
    if (!buf_size) {
        NA_LOG_ERROR("NULL buffer size");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    if (addr == NA_ADDR_NULL) {
        NA_LOG_ERROR("NULL addr");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    if (!na_class->addr_to_string) {
        NA_LOG_ERROR("addr_to_string plugin callback is not defined");
        ret = NA_PROTOCOL_ERROR;
        goto done;
    }

    ret = na_class->addr_to_string(na_class, buf, buf_size, addr);

done:
    return ret;
}
Ejemplo n.º 3
0
/*---------------------------------------------------------------------------*/
na_return_t
NA_Addr_self(na_class_t *na_class, na_addr_t *addr)
{
    na_return_t ret = NA_SUCCESS;

    if (!na_class) {
        NA_LOG_ERROR("NULL NA class");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    if (!addr) {
        NA_LOG_ERROR("NULL pointer to na_addr_t");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    if (!na_class->addr_self) {
        NA_LOG_ERROR("addr_self plugin callback is not defined");
        ret = NA_PROTOCOL_ERROR;
        goto done;
    }

    ret = na_class->addr_self(na_class, addr);

done:
    return ret;
}
Ejemplo n.º 4
0
/*---------------------------------------------------------------------------*/
na_return_t
NA_Cancel(na_class_t *na_class, na_context_t *context, na_op_id_t op_id)
{
    na_return_t ret = NA_SUCCESS;

    if (!na_class) {
        NA_LOG_ERROR("NULL NA class");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    if (!context) {
        NA_LOG_ERROR("NULL context");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    if (op_id == NA_OP_ID_NULL) {
        NA_LOG_ERROR("NULL operation ID");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    if (!na_class->cancel) {
        NA_LOG_ERROR("cancel plugin callback is not defined");
        ret = NA_PROTOCOL_ERROR;
        goto done;
    }

    ret = na_class->cancel(na_class, context, op_id);

done:
    return ret;
}
Ejemplo n.º 5
0
/*---------------------------------------------------------------------------*/
na_return_t
NA_Addr_dup(na_class_t *na_class, na_addr_t addr, na_addr_t *new_addr)
{
    na_return_t ret = NA_SUCCESS;

    if (!na_class) {
        NA_LOG_ERROR("NULL NA class");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    if (addr == NA_ADDR_NULL) {
        NA_LOG_ERROR("NULL addr");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    if (!new_addr) {
        NA_LOG_ERROR("NULL pointer to NA addr");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    if (!na_class->addr_dup) {
        NA_LOG_ERROR("addr_dup plugin callback is not defined");
        ret = NA_PROTOCOL_ERROR;
        goto done;
    }

    ret = na_class->addr_dup(na_class, addr, new_addr);

done:
    return ret;
}
Ejemplo n.º 6
0
/*---------------------------------------------------------------------------*/
na_return_t
NA_Mem_handle_create(na_class_t *na_class, void *buf, na_size_t buf_size,
        unsigned long flags, na_mem_handle_t *mem_handle)
{
    na_return_t ret = NA_SUCCESS;

    if (!na_class) {
        NA_LOG_ERROR("NULL NA class");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    if (!buf) {
        NA_LOG_ERROR("NULL buffer");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    if (!buf_size) {
        NA_LOG_ERROR("NULL buffer size");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    if (!na_class->mem_handle_create) {
        NA_LOG_ERROR("mem_handle_create plugin callback is not defined");
        ret = NA_PROTOCOL_ERROR;
        goto done;
    }

    ret = na_class->mem_handle_create(na_class, buf, buf_size, flags,
            mem_handle);

done:
    return ret;
}
Ejemplo n.º 7
0
/*---------------------------------------------------------------------------*/
na_return_t
NA_Mem_handle_free(na_class_t *na_class, na_mem_handle_t mem_handle)
{
    na_return_t ret = NA_SUCCESS;

    if (!na_class) {
        NA_LOG_ERROR("NULL NA class");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    if (mem_handle == NA_MEM_HANDLE_NULL) {
        NA_LOG_ERROR("NULL memory handle");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    if (!na_class->mem_handle_free) {
        NA_LOG_ERROR("mem_handle_free plugin callback is not defined");
        ret = NA_PROTOCOL_ERROR;
        goto done;
    }

    ret = na_class->mem_handle_free(na_class, mem_handle);

done:
    return ret;
}
Ejemplo n.º 8
0
/*---------------------------------------------------------------------------*/
na_class_t *
NA_Initialize(const char *info_string, na_bool_t listen)
{
    na_class_t *na_class = NULL;
    struct na_info *na_info = NULL;
    unsigned int plugin_index = 0;
    unsigned int plugin_count = 0;
    na_bool_t plugin_found = NA_FALSE;
    na_return_t ret;

    plugin_count = sizeof(na_class_info) / sizeof(na_class_info[0]) - 1;

    ret = na_info_parse(info_string, &na_info);
    if (ret != NA_SUCCESS) {
        NA_LOG_ERROR("Could not parse host string");
        goto done;
    }

#ifdef NA_DEBUG
    na_info_print(na_info);
#endif

    while (plugin_index < plugin_count) {
        na_bool_t verified = NA_FALSE;

        verified = na_class_info[plugin_index]->check_protocol(
                na_info->protocol_name);

        if (verified) {
            /* Take the first plugin that supports the protocol */
            if (!na_info->class_name) {
                plugin_found = NA_TRUE;
                break;
            }

            /* Otherwise try to use the plugin name */
            if (strcmp(na_class_info[plugin_index]->class_name,
                    na_info->class_name) == 0) {
                plugin_found = NA_TRUE;
                break;
            }
        }
        plugin_index++;
    }

    if (!plugin_found) {
        NA_LOG_ERROR("No suitable plugin was found");
        goto done;
    }

    /* Initialize lookup mutex */
    hg_thread_mutex_init(&na_addr_lookup_mutex_g);

    na_class = na_class_info[plugin_index]->initialize(na_info, listen);

done:
    na_info_free(na_info);
    return na_class;
}
Ejemplo n.º 9
0
/*---------------------------------------------------------------------------*/
na_return_t
NA_Addr_lookup(na_class_t *na_class, na_context_t *context, na_cb_t callback,
        void *arg, const char *name, na_op_id_t *op_id)
{
    char *name_string = NULL;
    char *short_name = NULL;
    na_op_id_t na_op_id;
    na_return_t ret = NA_SUCCESS;

    if (!na_class) {
        NA_LOG_ERROR("NULL NA class");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    if (!context) {
        NA_LOG_ERROR("NULL context");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    if (!name) {
        NA_LOG_ERROR("Lookup name is NULL");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    if (!na_class->addr_lookup) {
        NA_LOG_ERROR("addr_lookup plugin callback is not defined");
        ret = NA_PROTOCOL_ERROR;
        goto done;
    }

    /* Copy name and work from that */
    name_string = strdup(name);
    if (!name_string) {
        NA_LOG_ERROR("Could not duplicate string");
        ret = NA_NOMEM_ERROR;
        goto done;
    }

    /* If NA class name was specified, we can remove the name here:
     * ie. bmi+tcp://hostname:port -> tcp://hostname:port */
    if (strstr(name_string, "+") != NULL)
        strtok_r(name_string, "+", &short_name);
    else
        short_name = name_string;

    ret = na_class->addr_lookup(na_class, context, callback, arg, short_name,
            &na_op_id);
    if (ret != NA_SUCCESS) {
        goto done;
    }

    if (op_id && op_id != NA_OP_ID_IGNORE) *op_id = na_op_id;

done:
    free(name_string);
    return ret;
}
Ejemplo n.º 10
0
/*---------------------------------------------------------------------------*/
static na_return_t
na_test_send_finalize(struct na_test_lat_info *na_test_lat_info)
{
    char *send_buf = NULL, *recv_buf = NULL;
    void *send_buf_data, *recv_buf_data;
    hg_request_t *recv_request = NULL;
    na_size_t unexpected_header_size =
        NA_Msg_get_unexpected_header_size(na_test_lat_info->na_class);
    na_size_t buf_size =
        (unexpected_header_size) ? unexpected_header_size + 1 : 1;
    na_return_t ret = NA_SUCCESS;

    /* Prepare send_buf */
    send_buf = NA_Msg_buf_alloc(na_test_lat_info->na_class, buf_size,
        &send_buf_data);
    NA_Msg_init_unexpected(na_test_lat_info->na_class, send_buf, buf_size);

    /* Prepare recv buf */
    recv_buf = NA_Msg_buf_alloc(na_test_lat_info->na_class, buf_size,
        &recv_buf_data);
    memset(recv_buf, 0, buf_size);

    recv_request = hg_request_create(na_test_lat_info->request_class);

    /* Post recv */
    ret = NA_Msg_recv_expected(na_test_lat_info->na_class,
        na_test_lat_info->context, na_test_recv_expected_cb, recv_request,
        recv_buf, buf_size, recv_buf_data, na_test_lat_info->target_addr, 0,
        NA_TEST_TAG_DONE, NA_OP_ID_IGNORE);
    if (ret != NA_SUCCESS) {
        NA_LOG_ERROR("NA_Msg_recv_expected() failed");
        goto done;
    }

    /* Post send */
    ret = NA_Msg_send_unexpected(na_test_lat_info->na_class,
        na_test_lat_info->context, NULL, NULL, send_buf, buf_size,
        send_buf_data, na_test_lat_info->target_addr, 0, NA_TEST_TAG_DONE,
        NA_OP_ID_IGNORE);
    if (ret != NA_SUCCESS) {
        NA_LOG_ERROR("NA_Msg_send_unexpected() failed");
        goto done;
    }

    hg_request_wait(recv_request, NA_MAX_IDLE_TIME, NULL);

done:
    /* Clean up resources */
    hg_request_destroy(recv_request);
    NA_Msg_buf_free(na_test_lat_info->na_class, send_buf, send_buf_data);
    NA_Msg_buf_free(na_test_lat_info->na_class, recv_buf, recv_buf_data);
    return ret;
}
Ejemplo n.º 11
0
/*---------------------------------------------------------------------------*/
na_context_t *
NA_Context_create(na_class_t *na_class)
{
    na_return_t ret = NA_SUCCESS;
    struct na_private_context *na_private_context = NULL;

    if (!na_class) {
        NA_LOG_ERROR("NULL NA class");
        ret = NA_INVALID_PARAM;
        goto done;
    }

    na_private_context = (struct na_private_context *) malloc(
            sizeof(struct na_private_context));
    if (!na_private_context) {
        NA_LOG_ERROR("Could not allocate context");
        ret = NA_NOMEM_ERROR;
        goto done;
    }

    if (na_class->context_create) {
        ret = na_class->context_create(na_class,
                &na_private_context->context.plugin_context);
        if (ret != NA_SUCCESS) {
            goto done;
        }
    }

    /* Initialize completion queue */
    na_private_context->completion_queue = hg_queue_new();
    if (!na_private_context->completion_queue) {
        NA_LOG_ERROR("Could not create completion queue");
        ret = NA_NOMEM_ERROR;
        goto done;
    }

    /* Initialize completion queue mutex/cond */
    hg_thread_mutex_init(&na_private_context->completion_queue_mutex);
    hg_thread_cond_init(&na_private_context->completion_queue_cond);

    /* Initialize progress mutex/cond */
    hg_thread_mutex_init(&na_private_context->progress_mutex);
    hg_thread_cond_init(&na_private_context->progress_cond);
    na_private_context->progressing = NA_FALSE;

done:
    if (ret != NA_SUCCESS) {
        free(na_private_context);
        na_private_context = NULL;
    }
    return (na_context_t *) na_private_context;
}
Ejemplo n.º 12
0
/*---------------------------------------------------------------------------*/
na_return_t
NA_Context_destroy(na_class_t *na_class, na_context_t *context)
{
    struct na_private_context *na_private_context =
            (struct na_private_context *) context;
    na_return_t ret = NA_SUCCESS;

    if (!na_class) {
        NA_LOG_ERROR("NULL NA class");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    if (!context) goto done;

    /* Check that completion queue is empty now */
    hg_thread_mutex_lock(&na_private_context->completion_queue_mutex);

    if (!hg_queue_is_empty(na_private_context->completion_queue)) {
        NA_LOG_ERROR("Completion queue should be empty");
        ret = NA_PROTOCOL_ERROR;
        hg_thread_mutex_unlock(&na_private_context->completion_queue_mutex);
        goto done;
    }

    if (na_class->context_destroy) {
        ret = na_class->context_destroy(na_class,
                na_private_context->context.plugin_context);
        if (ret != NA_SUCCESS) {
            goto done;
        }
    }

    /* Destroy completion queue */
    hg_queue_free(na_private_context->completion_queue);
    na_private_context->completion_queue = NULL;

    hg_thread_mutex_unlock(&na_private_context->completion_queue_mutex);

    /* Destroy completion queue mutex/cond */
    hg_thread_mutex_destroy(&na_private_context->completion_queue_mutex);
    hg_thread_cond_destroy(&na_private_context->completion_queue_cond);

    /* Destroy progress mutex/cond */
    hg_thread_mutex_destroy(&na_private_context->progress_mutex);
    hg_thread_cond_destroy(&na_private_context->progress_cond);

    free(na_private_context);

done:
    return ret;
}
Ejemplo n.º 13
0
/*---------------------------------------------------------------------------*/
na_return_t
NA_Msg_recv_expected(na_class_t *na_class, na_context_t *context,
        na_cb_t callback, void *arg, void *buf, na_size_t buf_size,
        na_addr_t source, na_tag_t tag, na_op_id_t *op_id)
{
    na_op_id_t na_op_id;
    na_return_t ret;

    assert(na_class);

    if (!context) {
        NA_LOG_ERROR("NULL context");
        ret = NA_INVALID_PARAM;
        goto done;
    }

    ret = na_class->msg_recv_expected(na_class, context, callback, arg, buf,
            buf_size, source, tag, &na_op_id);
    if (ret != NA_SUCCESS) {
        goto done;
    }

    if (op_id && op_id != NA_OP_ID_IGNORE) *op_id = na_op_id;

done:
    return ret;
}
Ejemplo n.º 14
0
/*---------------------------------------------------------------------------*/
na_return_t
NA_Get(na_class_t *na_class, na_context_t *context, na_cb_t callback, void *arg,
        na_mem_handle_t local_mem_handle, na_offset_t local_offset,
        na_mem_handle_t remote_mem_handle, na_offset_t remote_offset,
        na_size_t data_size, na_addr_t remote_addr, na_op_id_t *op_id)
{
    na_op_id_t na_op_id;
    na_return_t ret;

    assert(na_class);

    if (!context) {
        NA_LOG_ERROR("NULL context");
        ret = NA_INVALID_PARAM;
        goto done;
    }

    ret = na_class->get(na_class, context, callback, arg, local_mem_handle,
            local_offset, remote_mem_handle, remote_offset, data_size,
            remote_addr, &na_op_id);
    if (ret != NA_SUCCESS) {
        goto done;
    }

    if (op_id && op_id != NA_OP_ID_IGNORE) *op_id = na_op_id;

done:
    return ret;
}
Ejemplo n.º 15
0
/*---------------------------------------------------------------------------*/
static na_return_t
na_test_target_lookup(struct na_test_lat_info *na_test_lat_info)
{
    struct na_test_target_lookup_arg request_args = { 0 };
    hg_request_t *request = NULL;
    na_return_t ret = NA_SUCCESS;

    request = hg_request_create(na_test_lat_info->request_class);
    request_args.addr_ptr = &na_test_lat_info->target_addr;
    request_args.request = request;

    /* Forward call to remote addr and get a new request */
    ret = NA_Addr_lookup(na_test_lat_info->na_class, na_test_lat_info->context,
        na_test_target_lookup_cb, &request_args,
        na_test_lat_info->na_test_info.target_name, NA_OP_ID_IGNORE);
    if (ret != NA_SUCCESS) {
        NA_LOG_ERROR("Could not lookup address");
        goto done;
    }

    /* Wait for request to be marked completed */
    hg_request_wait(request, NA_MAX_IDLE_TIME, NULL);

done:
    hg_request_destroy(request);
    return ret;
}
Ejemplo n.º 16
0
/*---------------------------------------------------------------------------*/
na_return_t
na_cb_completion_add(na_context_t *context,
        na_cb_t callback, struct na_cb_info *callback_info,
        na_plugin_cb_t plugin_callback, void *plugin_callback_args)
{
    struct na_private_context *na_private_context =
            (struct na_private_context *) context;
    na_return_t ret = NA_SUCCESS;
    struct na_cb_completion_data *completion_data = NULL;

    assert(context);

    completion_data = (struct na_cb_completion_data *)
            malloc(sizeof(struct na_cb_completion_data));
    if (!completion_data) {
        NA_LOG_ERROR("Could not allocate completion data struct");
        ret = NA_NOMEM_ERROR;
        goto done;
    }

    completion_data->callback = callback;
    completion_data->callback_info = callback_info;
    completion_data->plugin_callback = plugin_callback;
    completion_data->plugin_callback_args = plugin_callback_args;

    hg_thread_mutex_lock(&na_private_context->completion_queue_mutex);

    if (!hg_queue_push_head(na_private_context->completion_queue,
            (hg_queue_value_t) completion_data)) {
        NA_LOG_ERROR("Could not push completion data to completion queue");
        ret = NA_NOMEM_ERROR;
        hg_thread_mutex_unlock(
                &na_private_context->completion_queue_mutex);
        goto done;
    }

    /* Callback is pushed to the completion queue when something completes
     * so wake up anyone waiting in the trigger */
    hg_thread_cond_signal(&na_private_context->completion_queue_cond);

    hg_thread_mutex_unlock(&na_private_context->completion_queue_mutex);

done:
    return ret;
}
Ejemplo n.º 17
0
/*---------------------------------------------------------------------------*/
na_return_t
NA_Msg_recv_unexpected(na_class_t *na_class, na_context_t *context,
        na_cb_t callback, void *arg, void *buf, na_size_t buf_size,
        na_op_id_t *op_id)
{
    na_op_id_t na_op_id;
    na_return_t ret = NA_SUCCESS;

    if (!na_class) {
        NA_LOG_ERROR("NULL NA class");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    if (!context) {
        NA_LOG_ERROR("NULL context");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    if (!buf) {
        NA_LOG_ERROR("NULL buffer");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    if (!buf_size) {
        NA_LOG_ERROR("NULL buffer size");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    if (!na_class->msg_recv_unexpected) {
        NA_LOG_ERROR("msg_recv_unexpected plugin callback is not defined");
        ret = NA_PROTOCOL_ERROR;
        goto done;
    }

    ret = na_class->msg_recv_unexpected(na_class, context, callback, arg, buf,
            buf_size, &na_op_id);
    if (ret != NA_SUCCESS) {
        goto done;
    }

    if (op_id && op_id != NA_OP_ID_IGNORE) *op_id = na_op_id;

done:
    return ret;
}
Ejemplo n.º 18
0
/*---------------------------------------------------------------------------*/
na_bool_t
NA_Addr_is_self(na_class_t *na_class, na_addr_t addr)
{
    na_bool_t ret = NA_FALSE;

    if (!na_class) {
        NA_LOG_ERROR("NULL NA class");
        goto done;
    }
    if (!na_class->addr_is_self) {
        NA_LOG_ERROR("addr_is_self plugin callback is not defined");
        goto done;
    }

    ret = na_class->addr_is_self(na_class, addr);

done:
    return ret;
}
Ejemplo n.º 19
0
/*---------------------------------------------------------------------------*/
na_size_t
NA_Msg_get_max_unexpected_size(na_class_t *na_class)
{
    na_size_t ret = 0;

    if (!na_class) {
        NA_LOG_ERROR("NULL NA class");
        goto done;
    }
    if (!na_class->msg_get_max_unexpected_size) {
        NA_LOG_ERROR("msg_get_max_unexpected_size plugin callback is not defined");
        goto done;
    }

    ret = na_class->msg_get_max_unexpected_size(na_class);

done:
    return ret;
}
Ejemplo n.º 20
0
/*---------------------------------------------------------------------------*/
na_tag_t
NA_Msg_get_max_tag(na_class_t *na_class)
{
    na_tag_t ret = 0;

    if (!na_class) {
        NA_LOG_ERROR("NULL NA class");
        goto done;
    }
    if (!na_class->msg_get_max_tag) {
        NA_LOG_ERROR("msg_get_max_tag plugin callback is not defined");
        goto done;
    }

    ret = na_class->msg_get_max_tag(na_class);

done:
    return ret;
}
Ejemplo n.º 21
0
static int
ack_expected_recv_cb(const struct na_cb_info *callback_info)
{
    struct na_test_params *params = (struct na_test_params *) callback_info->arg;
    na_return_t ret = NA_SUCCESS;
    unsigned int i;
    na_bool_t error = 0;

    if (callback_info->ret != NA_SUCCESS) {
        return ret;
    }

    printf("Bulk transfer complete\n");

    /* Check bulk buf */
    for (i = 0; i < params->bulk_size; i++) {
        if (params->bulk_buf[i] != 0) {
            printf("Error detected in bulk transfer, bulk_buf[%u] = %u,\t"
                    " was expecting %d!\n", i, params->bulk_buf[i], 0);
            error = 1;
            break;
        }
    }
    if (!error) printf("Successfully reset %zu bytes!\n",
        (size_t) params->bulk_size * sizeof(int));

    ret = NA_Mem_deregister(params->na_class, params->local_mem_handle);
    if (ret != NA_SUCCESS) {
        NA_LOG_ERROR("Could not deregister memory");
        goto done;
    }

    ret = NA_Mem_handle_free(params->na_class, params->local_mem_handle);
    if (ret != NA_SUCCESS) {
        NA_LOG_ERROR("Could not free memory handle");
        goto done;
    }

    test_bulk_done_g = 1;

done:
    return ret;
}
Ejemplo n.º 22
0
/*---------------------------------------------------------------------------*/
na_return_t
NA_Get(na_class_t *na_class, na_context_t *context, na_cb_t callback, void *arg,
        na_mem_handle_t local_mem_handle, na_offset_t local_offset,
        na_mem_handle_t remote_mem_handle, na_offset_t remote_offset,
        na_size_t data_size, na_addr_t remote_addr, na_op_id_t *op_id)
{
    na_op_id_t na_op_id;
    na_return_t ret = NA_SUCCESS;

    if (!na_class) {
        NA_LOG_ERROR("NULL NA class");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    if (!context) {
        NA_LOG_ERROR("NULL context");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    if (local_mem_handle == NA_MEM_HANDLE_NULL) {
        NA_LOG_ERROR("NULL memory handle");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    if (remote_mem_handle == NA_MEM_HANDLE_NULL) {
        NA_LOG_ERROR("NULL memory handle");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    if (!data_size) {
        NA_LOG_ERROR("NULL data size");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    if (remote_addr == NA_ADDR_NULL) {
        NA_LOG_ERROR("NULL addr");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    if (!na_class->get) {
        NA_LOG_ERROR("get plugin callback is not defined");
        ret = NA_PROTOCOL_ERROR;
        goto done;
    }

    ret = na_class->get(na_class, context, callback, arg, local_mem_handle,
            local_offset, remote_mem_handle, remote_offset, data_size,
            remote_addr, &na_op_id);
    if (ret != NA_SUCCESS) {
        goto done;
    }

    if (op_id && op_id != NA_OP_ID_IGNORE) *op_id = na_op_id;

done:
    return ret;
}
Ejemplo n.º 23
0
/*---------------------------------------------------------------------------*/
void
na_test_get_config(char *addr_name, na_size_t len)
{
    FILE *config = NULL;

    config = fopen(MERCURY_TESTING_TEMP_DIRECTORY HG_TEST_CONFIG_FILE_NAME, "r");
    if (!config) {
        NA_LOG_ERROR("Could not open config file from: %s",
            MERCURY_TESTING_TEMP_DIRECTORY HG_TEST_CONFIG_FILE_NAME);
        exit(1);
    }
    if (fgets(addr_name, (int) len, config) == NULL) {
        NA_LOG_ERROR("Could not retrieve config name");
        fclose(config);
        exit(1);
    }
    /* This prevents retaining the newline, if any */
    addr_name[strlen(addr_name) - 1] = '\0';
    fclose(config);
}
Ejemplo n.º 24
0
/*---------------------------------------------------------------------------*/
na_size_t
NA_Mem_handle_get_serialize_size(na_class_t *na_class,
        na_mem_handle_t mem_handle)
{
    na_size_t ret = 0;

    if (!na_class) {
        NA_LOG_ERROR("NULL NA class");
        goto done;
    }
    /* mem_handle parameter is optional */
    if (!na_class->mem_handle_get_serialize_size) {
        NA_LOG_ERROR("mem_handle_get_serialize_size plugin callback is not defined");
        goto done;
    }

    ret = na_class->mem_handle_get_serialize_size(na_class, mem_handle);

done:
    return ret;
}
Ejemplo n.º 25
0
/*---------------------------------------------------------------------------*/
void
na_test_set_config(const char *addr_name)
{
    FILE *config = NULL;

    config = fopen(MERCURY_TESTING_TEMP_DIRECTORY HG_TEST_CONFIG_FILE_NAME, "w+");
    if (!config) {
        NA_LOG_ERROR("Could not open config file from: %s",
            MERCURY_TESTING_TEMP_DIRECTORY HG_TEST_CONFIG_FILE_NAME);
        exit(1);
    }
    fprintf(config, "%s\n", addr_name);
    fclose(config);
}
Ejemplo n.º 26
0
/*---------------------------------------------------------------------------*/
na_return_t
NA_Mem_handle_serialize(na_class_t *na_class, void *buf, na_size_t buf_size,
        na_mem_handle_t mem_handle)
{
    na_return_t ret = NA_SUCCESS;

    if (!na_class) {
        NA_LOG_ERROR("NULL NA class");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    if (!buf) {
        NA_LOG_ERROR("NULL buffer");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    if (!buf_size) {
        NA_LOG_ERROR("NULL buffer size");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    if (mem_handle == NA_MEM_HANDLE_NULL) {
        NA_LOG_ERROR("NULL memory handle");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    if (!na_class->mem_handle_serialize) {
        NA_LOG_ERROR("mem_handle_serialize plugin callback is not defined");
        ret = NA_PROTOCOL_ERROR;
        goto done;
    }

    ret = na_class->mem_handle_serialize(na_class, buf, buf_size, mem_handle);

done:
    return ret;
}
Ejemplo n.º 27
0
/*---------------------------------------------------------------------------*/
na_return_t
NA_Mem_handle_deserialize(na_class_t *na_class, na_mem_handle_t *mem_handle,
        const void *buf, na_size_t buf_size)
{
    na_return_t ret = NA_SUCCESS;

    if (!na_class) {
        NA_LOG_ERROR("NULL NA class");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    if (!mem_handle) {
        NA_LOG_ERROR("NULL pointer to memory handle");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    if (!buf) {
        NA_LOG_ERROR("NULL buffer");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    if (!buf_size) {
        NA_LOG_ERROR("NULL buffer size");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    if (!na_class->mem_handle_deserialize) {
        NA_LOG_ERROR("mem_handle_deserialize plugin callback is not defined");
        ret = NA_PROTOCOL_ERROR;
        goto done;
    }

    ret = na_class->mem_handle_deserialize(na_class, mem_handle, buf, buf_size);

done:
    return ret;
}
Ejemplo n.º 28
0
/* NA test routines */
static int
test_msg_forward(struct na_test_params *params)
{
    na_return_t na_ret;
    int ret = EXIT_SUCCESS;

    /* Send a message to addr */
    NA_Msg_init_unexpected(params->na_class, params->send_buf,
        params->send_buf_len);
    sprintf(params->send_buf +
        NA_Msg_get_unexpected_header_size(params->na_class), "Hello Server!");

    /* Preposting response */
    na_ret = NA_Msg_recv_expected(params->na_class, params->context,
        msg_expected_recv_cb, params, params->recv_buf, params->recv_buf_len,
        params->recv_buf_plugin_data, params->server_addr, 0,
        NA_TEST_SEND_TAG + 1, NA_OP_ID_IGNORE);
    if (na_ret != NA_SUCCESS) {
        NA_LOG_ERROR("Could not prepost recv of expected message");
        ret = EXIT_FAILURE;
        goto done;
    }

    na_ret = NA_Msg_send_unexpected(params->na_class, params->context,
        msg_unexpected_send_cb, params, params->send_buf, params->send_buf_len,
        params->send_buf_plugin_data, params->server_addr, 0, NA_TEST_SEND_TAG,
        NA_OP_ID_IGNORE);
    if (na_ret != NA_SUCCESS) {
        NA_LOG_ERROR("Could not start send of unexpected message");
        ret = EXIT_FAILURE;
        goto done;
    }

done:
    return ret;
}
Ejemplo n.º 29
0
/*---------------------------------------------------------------------------*/
na_return_t
NA_Mem_unpublish(na_class_t *na_class, na_mem_handle_t mem_handle)
{
    na_return_t ret = NA_SUCCESS;

    if (!na_class) {
        NA_LOG_ERROR("NULL NA class");
        ret = NA_INVALID_PARAM;
        goto done;
    }
    if (mem_handle == NA_MEM_HANDLE_NULL) {
        NA_LOG_ERROR("NULL memory handle");
        ret = NA_INVALID_PARAM;
        goto done;
    }

    if (na_class->mem_unpublish) {
        /* Optional */
        ret = na_class->mem_unpublish(na_class, mem_handle);
    }

done:
    return ret;
}
Ejemplo n.º 30
0
/*---------------------------------------------------------------------------*/
const char *
NA_Get_class_name(na_class_t *na_class)
{
    const char *ret = NULL;

    if (!na_class) {
        NA_LOG_ERROR("NULL NA class");
        goto done;
    }

    ret = na_class->class_name;

done:
    return ret;
}