-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code of user-space daemon for exposing remote memory added. Sample ke…
…rnel module to use Leap functionality added.
- Loading branch information
Showing
8 changed files
with
1,206 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.PHONY: clean | ||
|
||
CFLAGS := -Wall -Werror -g | ||
LD := gcc | ||
LDLIBS := ${LDLIBS} -lrdmacm -libverbs -lpthread | ||
|
||
APPS := daemon | ||
|
||
all: ${APPS} | ||
|
||
daemon: rdma-common.o daemon.o | ||
${LD} -o $@ $^ ${LDLIBS} | ||
|
||
clean: | ||
rm -f *.o ${APPS} | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
/* | ||
* Infiniswap, remote memory paging over RDMA | ||
* Copyright 2017 University of Michigan, Ann Arbor | ||
* GPLv2 License | ||
*/ | ||
|
||
#include "rdma-common.h" | ||
|
||
static int on_connect_request(struct rdma_cm_id *id); | ||
static int on_connection(struct rdma_cm_id *id); | ||
static int on_disconnect(struct rdma_cm_id *id); | ||
static int on_event(struct rdma_cm_event *event); | ||
static void usage(const char *argv0); | ||
long page_size; | ||
int running; | ||
int main(int argc, char **argv) | ||
{ | ||
struct sockaddr_in6 addr; | ||
struct rdma_cm_event *event = NULL; | ||
struct rdma_cm_id *listener = NULL; | ||
struct rdma_event_channel *ec = NULL; | ||
uint16_t port = 0; | ||
pthread_t free_mem_thread; | ||
|
||
if (argc != 3) | ||
usage(argv[0]); | ||
page_size = sysconf(_SC_PAGE_SIZE); | ||
|
||
memset(&addr, 0, sizeof(addr)); | ||
addr.sin6_family = AF_INET6; | ||
inet_pton(AF_INET6, argv[1], &addr.sin6_addr); | ||
addr.sin6_port = htons(atoi(argv[2])); | ||
|
||
TEST_Z(ec = rdma_create_event_channel()); | ||
TEST_NZ(rdma_create_id(ec, &listener, NULL, RDMA_PS_TCP)); | ||
TEST_NZ(rdma_bind_addr(listener, (struct sockaddr *)&addr)); | ||
TEST_NZ(rdma_listen(listener, 10)); /* backlog=10 is arbitrary */ | ||
|
||
port = ntohs(rdma_get_src_port(listener)); | ||
|
||
printf("listening on port %d.\n", port); | ||
|
||
//free | ||
running = 1; | ||
TEST_NZ(pthread_create(&free_mem_thread, NULL, (void *)free_mem, NULL)); | ||
|
||
while (rdma_get_cm_event(ec, &event) == 0) { | ||
struct rdma_cm_event event_copy; | ||
|
||
memcpy(&event_copy, event, sizeof(*event)); | ||
rdma_ack_cm_event(event); | ||
|
||
if (on_event(&event_copy)) | ||
break; | ||
} | ||
|
||
rdma_destroy_id(listener); | ||
rdma_destroy_event_channel(ec); | ||
|
||
return 0; | ||
} | ||
|
||
int on_connect_request(struct rdma_cm_id *id) | ||
{ | ||
struct rdma_conn_param cm_params; | ||
|
||
printf("received connection request.\n"); | ||
build_connection(id); | ||
build_params(&cm_params); | ||
TEST_NZ(rdma_accept(id, &cm_params)); | ||
|
||
return 0; | ||
} | ||
|
||
int on_connection(struct rdma_cm_id *id) | ||
{ | ||
on_connect(id->context); | ||
|
||
printf("connection build\n"); | ||
/* J: only server send mr, client doesn't */ | ||
send_free_mem_size(id->context); | ||
|
||
return 0; | ||
} | ||
|
||
int on_disconnect(struct rdma_cm_id *id) | ||
{ | ||
printf("peer disconnected.\n"); | ||
|
||
destroy_connection(id->context); | ||
return 0; | ||
} | ||
|
||
int on_event(struct rdma_cm_event *event) | ||
{ | ||
int r = 0; | ||
|
||
if (event->event == RDMA_CM_EVENT_CONNECT_REQUEST) | ||
r = on_connect_request(event->id); | ||
else if (event->event == RDMA_CM_EVENT_ESTABLISHED) | ||
r = on_connection(event->id); | ||
else if (event->event == RDMA_CM_EVENT_DISCONNECTED) | ||
r = on_disconnect(event->id); | ||
else | ||
die("on_event: unknown event."); | ||
|
||
return r; | ||
} | ||
|
||
void usage(const char *argv0) | ||
{ | ||
fprintf(stderr, "usage: %s ip port\n", argv0); | ||
exit(1); | ||
} |
Oops, something went wrong.