summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/kiro-client.c26
-rw-r--r--src/kiro-client.h93
-rw-r--r--src/kiro-rdma.h2
-rw-r--r--src/kiro-server.c13
-rw-r--r--src/kiro-server.h35
-rw-r--r--src/kiro-trb.h25
-rw-r--r--test/test-client-bandwidth.c5
-rw-r--r--test/test-client-latency.c1
-rw-r--r--test/test-server.c6
9 files changed, 179 insertions, 27 deletions
diff --git a/src/kiro-client.c b/src/kiro-client.c
index 12d4a45..8fa582b 100644
--- a/src/kiro-client.c
+++ b/src/kiro-client.c
@@ -85,6 +85,9 @@ kiro_client_init (KiroClient *self)
{
KiroClientPrivate *priv = KIRO_CLIENT_GET_PRIVATE (self);
memset (priv, 0, sizeof (&priv));
+
+ //Hack to make the 'unused function' from the kiro-rdma include go away...
+ kiro_attach_qp (NULL);
}
@@ -118,10 +121,15 @@ kiro_client_connect (KiroClient *self, const char *address, const char *port)
struct rdma_addrinfo hints, *res_addrinfo;
memset (&hints, 0, sizeof (hints));
-
hints.ai_port_space = RDMA_PS_IB;
- if (rdma_getaddrinfo (address, port, &hints, &res_addrinfo)) {
+ char *addr_c = g_strdup (address);
+ char *port_c = g_strdup (port);
+ int rtn = rdma_getaddrinfo (addr_c, port_c, &hints, &res_addrinfo);
+ g_free (addr_c);
+ g_free (port_c);
+
+ if (rtn) {
g_critical ("Failed to get address information for %s:%s : %s", address, port, strerror (errno));
return -1;
}
@@ -200,7 +208,7 @@ kiro_client_connect (KiroClient *self, const char *address, const char *port)
g_debug ("Got RDMI Access information from Server");
ctx->peer_mr = (((struct kiro_ctrl_msg *) (ctx->cf_mr_recv->mem))->peer_mri);
- g_debug ("Expected Memory Size is: %u", ctx->peer_mr.length);
+ g_debug ("Expected Memory Size is: %zu", ctx->peer_mr.length);
ctx->rdma_mr = kiro_create_rdma_memory (priv->conn->pd, ctx->peer_mr.length, IBV_ACCESS_LOCAL_WRITE);
if (!ctx->rdma_mr) {
@@ -228,12 +236,9 @@ kiro_client_sync (KiroClient *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)) {
+ if (rdma_post_read (priv->conn, priv->conn, ctx->rdma_mr->mem, ctx->peer_mr.length, ctx->rdma_mr->mr, 0, (uint64_t)ctx->peer_mr.addr, ctx->peer_mr.rkey)) {
g_critical ("Failed to RDMA_READ from server: %s", strerror (errno));
- rdma_disconnect (priv->conn);
- kiro_destroy_connection_context (&ctx);
- rdma_destroy_ep (priv->conn);
- return -1;
+ goto fail;
}
struct ibv_wc wc;
@@ -257,10 +262,7 @@ kiro_client_sync (KiroClient *self)
}
fail:
- rdma_disconnect (priv->conn);
- kiro_destroy_connection_context (&ctx);
- rdma_destroy_ep (priv->conn);
- priv->conn = NULL;
+ kiro_destroy_connection (&(priv->conn));
return -1;
}
diff --git a/src/kiro-client.h b/src/kiro-client.h
index 8e99877..9e9d3ef 100644
--- a/src/kiro-client.h
+++ b/src/kiro-client.h
@@ -70,20 +70,111 @@ struct _KiroClientClass {
/* GObject and GType functions */
+/**
+ * kiro_client_get_type: (skip)
+ * Returns: GType of #KiroClient
+ */
GType kiro_client_get_type (void);
+/**
+ * kiro_client_new - Creates a new #KiroClient
+ * Returns: (transfer full): A pointer to a new #KiroClient
+ * Description:
+ * Creates a new, unconnected #KiroClient and returns a pointer to it.
+ * See also:
+ * kiro_client_free, kiro_client_connect
+ */
KiroClient* kiro_client_new (void);
+/**
+ * kiro_client_free - 'Destroys' the given #KiroClient
+ * @client: (transfer none): The #KiroClient that is to be freed
+ * Description:
+ * Transitions the #KiroServer through all necessary shutdown routines and
+ * frees the object memory.
+ * Note:
+ * The memory content that has been transfered from the server is
+ * automatically freed when calling this function. If you want to continue
+ * using the memory after freeing the #KiroClient, make sure to memcpy() it
+ * first, using the informations obtained from kiro_client_get_memory() and
+ * kiro_client_get_memory_size().
+ * See also:
+ * kiro_client_new, kiro_client_connect
+ */
void kiro_client_free (KiroClient *client);
/* client functions */
+
+/**
+ * kiro_client_connect - Connect a #KiroClient to a Server
+ * @client: (transfer none): The #KiroClient to connect
+ * @dest_addr: (transfer none): The address of the target server
+ * @dest_port: (transfer none): The port of the target server
+ * Returns:
+ * 0 if the connection was successful, -1 in case of connection error
+ * Description:
+ * Connects the given #KiroClient to a KIRO server described by @dest_addr and
+ * @dest_port.
+ * Note:
+ * When building a connection to the server, memory for the transmission is
+ * created as well.
+ * See also:
+ * kiro_server_new
+ */
int kiro_client_connect (KiroClient *client, const char *dest_addr, const char *dest_port);
+/**
+ * kiro_client_sync - Read data from the connected server
+ * @client: (transfer none): The #KiroServer to use sync on
+ * Returns:
+ * 0 if successful, -1 in case of synchronisation error
+ * Description:
+ * This synchronizes the client with the server, clining the memory
+ * provided by the server to the local client. The memory can be accessed by
+ * using kiro_client_get_memory().
+ * Note:
+ * The server can send a 'reallocation' request to the client, forcing it to
+ * reallocate new memory with the next occurrence of kiro_client_sync(),
+ * freeing the old memory in the process.
+ *See also:
+ * kiro_client_get_memory, kiro_cient_connect
+ */
int kiro_client_sync (KiroClient *client);
-void *kiro_client_get_memory (KiroClient *client);
+/**
+ * kiro_client_get_memory - Return a pointer to the current client memory
+ * @client: (transfer none): The #KiroClient to get the memory from
+ * Returns: (transfer none):
+ * A pointer to the current memory of the client.
+ * Note:
+ * The server can instruct the client to reallocate memory on the next
+ * occurrence of kiro_client_sync(), freeing the old memory. Also, calling
+ * kiro_client_free() will free the client memory as well. If you need to
+ * make sure that the memory from the @client remains accessible after
+ * calling sync and/or free, you need to memcpy() the memory using the
+ * information from kiro_client_get_memory() and
+ * kiro_client_get_memory_size() first.
+ * The returned memory might under NO circumstances be freed by the user!
+ * See also:
+ * kiro_client_get_memory_size, kiro_client_sync
+ */
+void* kiro_client_get_memory (KiroClient *client);
+/**
+ * kiro_client_get_memory_size - Return the client memory size in bytes
+ * @client: (transfer none): The #KiroClient to get the memory size of
+ * Returns:
+ * The size of the given #KiroClient memory in bytes
+ * Description:
+ * Returns the size of the allocated memory of @client, in bytes.
+ * Note:
+ * The server can instruct the client to reallocate memroy on the next
+ * occurrence of kiro_server_sync(), freeing the old memory. This might also
+ * effect the respective memory size.
+ * See also:
+ * kiro_client_get_memory, kiro_client_sync
+ */
size_t kiro_client_get_memory_size (KiroClient *client);
G_END_DECLS
diff --git a/src/kiro-rdma.h b/src/kiro-rdma.h
index 9a3cbe8..af502ec 100644
--- a/src/kiro-rdma.h
+++ b/src/kiro-rdma.h
@@ -81,7 +81,7 @@ kiro_attach_qp (struct rdma_cm_id *id)
id->recv_cq = id->send_cq; //we use one shared completion queue
struct ibv_qp_init_attr qp_attr;
memset (&qp_attr, 0, sizeof (struct ibv_qp_init_attr));
- qp_attr.qp_context = (uintptr_t)id;
+ qp_attr.qp_context = (void *) (uintptr_t) id;
qp_attr.send_cq = id->send_cq;
qp_attr.recv_cq = id->recv_cq;
qp_attr.qp_type = IBV_QPT_RC;
diff --git a/src/kiro-server.c b/src/kiro-server.c
index b3c8516..91c86ec 100644
--- a/src/kiro-server.c
+++ b/src/kiro-server.c
@@ -288,7 +288,7 @@ event_loop (void *self)
int
-kiro_server_start (KiroServer *self, char *address, char *port, void *mem, size_t mem_size)
+kiro_server_start (KiroServer *self, const char *address, const char *port, void *mem, size_t mem_size)
{
KiroServerPrivate *priv = KIRO_SERVER_GET_PRIVATE (self);
@@ -307,7 +307,14 @@ kiro_server_start (KiroServer *self, char *address, char *port, void *mem, size_
hints.ai_port_space = RDMA_PS_IB;
hints.ai_flags = RAI_PASSIVE;
- if (rdma_getaddrinfo (address, port, &hints, &res_addrinfo)) {
+ char *addr_c = g_strdup (address);
+ char *port_c = g_strdup (port);
+
+ int rtn = rdma_getaddrinfo (addr_c, port_c, &hints, &res_addrinfo);
+ g_free (addr_c);
+ g_free (port_c);
+
+ if (rtn) {
g_critical ("Failed to create address information: %s", strerror (errno));
return -1;
}
@@ -371,6 +378,8 @@ kiro_server_start (KiroServer *self, char *address, char *port, void *mem, size_
static void
disconnect_client (gpointer data, gpointer user_data)
{
+ (void)user_data;
+
if (data) {
struct rdma_cm_id *id = (struct rdma_cm_id *)data;
struct kiro_connection_context *ctx = (struct kiro_connection_context *) (id->context);
diff --git a/src/kiro-server.h b/src/kiro-server.h
index 78b2cf4..7e42159 100644
--- a/src/kiro-server.h
+++ b/src/kiro-server.h
@@ -70,10 +70,36 @@ struct _KiroServerClass {
/* GObject and GType functions */
+
+/**
+ * kiro_server_get_type: (skip)
+ * Returns: GType of KiroServer
+ */
GType kiro_server_get_type (void);
-KiroServer *kiro_server_new (void);
+/**
+ * kiro_server_new - Creates a new #KiroServer
+ * Returns: (transfer full): A pointer to a new #KiroServer
+ * Description:
+ * Creates a new, unbound #KiroServer and returns a pointer to it.
+ * See also:
+ * kiro_server_start, kiro_server_free
+ */
+KiroServer* kiro_server_new (void);
+/**
+ * kiro_server_free - 'Destroys' the given #KiroServer
+ * @server: The #KiroServer that is to be freed
+ * Description:
+ * Transitions the #KiroServer through all necessary shutdown routines and
+ * frees the object memory.
+ * Note:
+ * The memory that is given to the server when calling kiro_server_start will
+ * NOT be freed! The user is responsible to free this memory, if no longer
+ * needed.
+ * See also:
+ * kiro_server_start, kiro_server_new
+ */
void kiro_server_free (KiroServer *server);
@@ -84,7 +110,7 @@ void kiro_server_free (KiroServer *server);
* @server: #KiroServer to perform the operation on
* @bind_addr: Local address to bind the server to
* @bind_port: Local port to listen for connections
- * @mem: Pointer to the memory that is to be provided
+ * @mem: (transfer none): Pointer to the memory that is to be provided
* @mem_size: Size in bytes of the given memory
* Description:
* Starts the #KiroServer to provide the given memory to any connecting
@@ -99,10 +125,9 @@ void kiro_server_free (KiroServer *server);
* and return the chosen port as return value.
* If server creation fails, -1 is returned instead.
* See also:
- * kiro_trb_reshape, kiro_trb_adopt,
- * kiro_trb_clone
+ * kiro_server_new,
*/
-int kiro_server_start (KiroServer *server, char *bind_addr, char *bind_port, void *mem, size_t mem_size);
+int kiro_server_start (KiroServer *server, const char *bind_addr, const char *bind_port, void *mem, size_t mem_size);
/**
* kiro_server_stop - Stops the server
diff --git a/src/kiro-trb.h b/src/kiro-trb.h
index ff8d418..806ad5e 100644
--- a/src/kiro-trb.h
+++ b/src/kiro-trb.h
@@ -78,10 +78,35 @@ struct KiroTrbInfo {
/* GObject and GType functions */
+/**
+ * kiro_trb_get_type: (skip)
+ * Returns: GType of #KiroTrb
+ */
GType kiro_trb_get_type (void);
+/**
+ * kiro_trb_new - Creates a new #KiroTrb
+ * Returns: (transfer full): A pointer to a new #KiroTrb
+ * Description:
+ * Creates a new, unshaped #KiroTrb and returns a pointer to it.
+ * See also:
+ * kiro_trb_free, kiro_trb_reshape
+ */
KiroTrb* kiro_trb_new (void);
+/**
+ * kiro_trb_free - 'Destroys' the given #KiroTrb
+ * @trb: (transfer none): The #KiroTrb that is to be freed
+ * Description:
+ * Clears all underlying memory and frees the object memory.
+ * Note:
+ * The internal memory is also freed when calling this function. If you want
+ * to continue using the raw @trb memory after call this function, you need to
+ * memcpy() its content using the information optained from
+ * kiro_trb_get_raw_buffer and kiro_trb_get_raw_size.
+ * See also:
+ * kiro_trb_new
+ */
void kiro_trb_free (KiroTrb *trb);
diff --git a/test/test-client-bandwidth.c b/test/test-client-bandwidth.c
index 8cf87d5..287584a 100644
--- a/test/test-client-bandwidth.c
+++ b/test/test-client-bandwidth.c
@@ -28,7 +28,8 @@ main ( int argc, char *argv[] )
GTimer *timer = g_timer_new ();
-while (1) {
+while (1) {
+ g_timer_reset (timer);
int i = 0;
while(i < 500) {
kiro_client_sync (client);
@@ -41,7 +42,7 @@ while (1) {
}
g_timer_stop (timer);
kiro_client_free (client);
- kiro_trb_free (client);
+ kiro_trb_free (trb);
return 0;
}
diff --git a/test/test-client-latency.c b/test/test-client-latency.c
index 47260b4..676dfe4 100644
--- a/test/test-client-latency.c
+++ b/test/test-client-latency.c
@@ -35,7 +35,6 @@ while (1) {
}
double elapsed = g_timer_elapsed (timer, NULL);
- size_t size = kiro_client_get_memory_size (client);
printf ("Average Latency: %fus\n", (elapsed/50000.)*1000*1000);
}
g_timer_stop (timer);
diff --git a/test/test-server.c b/test/test-server.c
index dc277d5..91a3db5 100644
--- a/test/test-server.c
+++ b/test/test-server.c
@@ -99,8 +99,8 @@ static const guint DIGIT_HEIGHT = 5;
static void
print_number (gchar *buffer, guint number, guint x, guint y, guint width)
{
- for (int i = 0; i < DIGIT_WIDTH; i++) {
- for (int j = 0; j < DIGIT_HEIGHT; j++) {
+ for (guint i = 0; i < DIGIT_WIDTH; i++) {
+ for (guint j = 0; j < DIGIT_HEIGHT; j++) {
char val = (char) g_digits[number][j * DIGIT_WIDTH + i];
if (val != 0x00) {
@@ -131,7 +131,7 @@ print_current_frame (gchar *buffer, guint number, guint width, guint height, GRa
//for every row again.
char default_line[width];
- for (int p = 0; p < width; p++) {
+ for (guint p = 0; p < width; p++) {
default_line[p] = (char) ((p * 256) / (width));
}