diff options
author | Timo Dritschler <timo.dritschler@kit.edu> | 2014-04-25 19:32:51 +0200 |
---|---|---|
committer | Timo Dritschler <timo.dritschler@kit.edu> | 2014-04-25 19:37:54 +0200 |
commit | 3405180e97cd6b4d4bef6fed2a7e666eb8126906 (patch) | |
tree | 0424d46f5a14c57686fecc8b46ad133f3e7ec5b8 /kiro-client.c | |
parent | 2b5ad5dfa5baa9a243051022510600fd8a82fd20 (diff) | |
download | kiro-3405180e97cd6b4d4bef6fed2a7e666eb8126906.tar.gz kiro-3405180e97cd6b4d4bef6fed2a7e666eb8126906.tar.bz2 kiro-3405180e97cd6b4d4bef6fed2a7e666eb8126906.tar.xz kiro-3405180e97cd6b4d4bef6fed2a7e666eb8126906.zip |
KIRO Server and Client now automatically exchange MRI on connect
Added 'kiro_client_sync' that RDMA-READs the KIRO-TRB from the server
Updated Makefile
Updated test-client
Diffstat (limited to 'kiro-client.c')
-rw-r--r-- | kiro-client.c | 81 |
1 files changed, 61 insertions, 20 deletions
diff --git a/kiro-client.c b/kiro-client.c index 41f4ff5..253251f 100644 --- a/kiro-client.c +++ b/kiro-client.c @@ -33,6 +33,7 @@ #include <glib.h> #include "kiro-client.h" #include "kiro-rdma.h" +#include "kiro-trb.h" #include <errno.h> @@ -50,8 +51,9 @@ struct _KiroClientPrivate { /* 'Real' private structures */ /* (Not accessible by properties) */ - struct rdma_event_channel *ec; // Main Event Channel - struct rdma_cm_id *conn; // Connection to the Server + struct rdma_event_channel *ec; // Main Event Channel + struct rdma_cm_id *conn; // Connection to the Server + KiroTrb *buffer; // Ring Buffer used to hold data from server }; @@ -64,12 +66,15 @@ static void kiro_client_init (KiroClient *self) { KiroClientPrivate *priv = KIRO_CLIENT_GET_PRIVATE(self); memset(priv, 0, sizeof(&priv)); + priv->buffer = g_object_new(KIRO_TYPE_TRB, NULL); } static void kiro_client_finalize (GObject *object) { - //PASS + KiroClient *self = KIRO_CLIENT(object); + KiroClientPrivate * priv = KIRO_CLIENT_GET_PRIVATE(self); + g_object_unref(priv->buffer); } static void @@ -162,38 +167,74 @@ int kiro_client_connect (KiroClient *self, char *address, char* port) rdma_destroy_ep(priv->conn); return -1; } + printf("Connected to server.\n"); - priv->ec = rdma_create_event_channel(); - int oldflags = fcntl (priv->ec->fd, F_GETFL, 0); - /* Only change the FD Mode if we were able to get its flags */ - if (oldflags >= 0) { - oldflags |= O_NONBLOCK; - /* Store modified flag word in the descriptor. */ - fcntl (priv->ec->fd, F_SETFL, oldflags); - } - if(rdma_migrate_id(priv->conn, priv->ec)) + + struct ibv_wc wc; + if(rdma_get_recv_comp(priv->conn, &wc) < 0) { - printf("Was unable to migrate connection to new Event Channel.\n"); + printf("Failure waiting for POST from server.\n"); rdma_disconnect(priv->conn); kiro_destroy_connection_context(ctx); rdma_destroy_ep(priv->conn); return -1; } + printf("Got Message from Server.\n"); + ctx->peer_mr = (((struct kiro_ctrl_msg *)(ctx->cf_mr_recv->mem))->peer_mri); + printf("Expected TRB Size is: %u\n",ctx->peer_mr.length); - //ToDo: - //Create TRB, request RDMA from Server, call kiro_client_sync, ???, Profit! - + ctx->rdma_mr = kiro_create_rdma_memory(priv->conn->pd, ctx->peer_mr.length, IBV_ACCESS_LOCAL_WRITE); + if(!ctx->rdma_mr) + { + printf("Failed to allocate memory for receive buffer.\n"); + rdma_disconnect(priv->conn); + kiro_destroy_connection_context(ctx); + rdma_destroy_ep(priv->conn); + return -1; + } + printf("Connection setup completed successfully!\n"); - printf("Connected to server.\n"); return 0; - } int kiro_client_sync (KiroClient *self) -{ - //PASS +{ + KiroClientPrivate *priv = KIRO_CLIENT_GET_PRIVATE(self); + struct kiro_connection_context *ctx = (struct kiro_connection_context *)priv->conn->context; + + if(rdma_post_read(priv->conn, priv->conn, ctx->rdma_mr->mem, ctx->peer_mr.length, ctx->rdma_mr->mr, 0, ctx->peer_mr.addr, ctx->peer_mr.rkey)) + { + printf("Failed to read from server.\n"); + rdma_disconnect(priv->conn); + kiro_destroy_connection_context(ctx); + rdma_destroy_ep(priv->conn); + return -1; + } + + struct ibv_wc wc; + if(rdma_get_send_comp(priv->conn, &wc) < 0) + { + printf("Failure reading from server.\n"); + rdma_disconnect(priv->conn); + kiro_destroy_connection_context(ctx); + rdma_destroy_ep(priv->conn); + return -1; + } + + if(!kiro_trb_is_setup(priv->buffer)) + { + //First time setup + kiro_trb_ingest(priv->buffer, ctx->rdma_mr->mem); + } + else + { + //Refresh + kiro_trb_refresh(priv->buffer); + } + + printf("Buffer successfully read from server.\n"); return 0; } |