示例#1
0
文件: kiro-server.c 项目: IMCG/kiro
static int
grant_client_access (struct rdma_cm_id *client, void *mem, size_t mem_size, guint type)
{
    struct kiro_connection_context *ctx = (struct kiro_connection_context *) (client->context);
    ctx->rdma_mr = (struct kiro_rdma_mem *)g_try_malloc0 (sizeof (struct kiro_rdma_mem));

    if (!ctx->rdma_mr) {
        g_critical ("Failed to allocate RDMA Memory Container: %s", strerror (errno));
        return -1;
    }

    ctx->rdma_mr->mem = mem;
    ctx->rdma_mr->size = mem_size;
    ctx->rdma_mr->mr = rdma_reg_read (client, ctx->rdma_mr->mem, ctx->rdma_mr->size);

    if (!ctx->rdma_mr->mr) {
        g_critical ("Failed to register RDMA Memory Region: %s", strerror (errno));
        kiro_destroy_rdma_memory (ctx->rdma_mr);
        return -1;
    }

    struct kiro_ctrl_msg *msg = (struct kiro_ctrl_msg *) (ctx->cf_mr_send->mem);

    msg->msg_type = type;
    msg->peer_mri = * (ctx->rdma_mr->mr);

    if (!send_msg (client, ctx->cf_mr_send)) {
        g_warning ("Failure while trying to post SEND: %s", strerror (errno));
        kiro_destroy_rdma_memory (ctx->rdma_mr);
        return -1;
    }

    g_debug ("RDMA MRI sent to client");
    return 0;
}
示例#2
0
void RDMAWriteSocket::setup_read_buf() { // only called on server side
    
    Config& config = Config::get_config();

    this->read_mr = rdma_reg_read(this->rsock->client_id, config.cache_addr, config.cache_size);
    if (this->read_mr == NULL) {
	delete this->rsock;
        perror("rdma_reg_read");
        exit(1);
    }
}