[ofa-general] [PATCH 4/4] uDAPL v2 - IB UD extension - dtestx: add -d option to test new IB UD extension
Arlin Davis
arlin.r.davis at intel.com
Sun Jul 20 15:19:52 PDT 2008
modify dtestx to connect peer UD QP's and exchange/verify messages as an example for new extension.
Also add -b buf_size, -h server host, and -P provider name options to match dtest semantics.
Signed-off by: Arlin Davis ardavis at ichips.intel.com
---
test/dtest/dtestx.c | 177 +++++++++++++++++++++++++++++++++++---------------
1 files changed, 124 insertions(+), 53 deletions(-)
diff --git a/test/dtest/dtestx.c b/test/dtest/dtestx.c
index 1db60eb..fc3fc45 100755
--- a/test/dtest/dtestx.c
+++ b/test/dtest/dtestx.c
@@ -153,9 +153,22 @@ DAT_EVD_HANDLE con_evd = DAT_HANDLE_NULL;
DAT_EVD_HANDLE dto_evd = DAT_HANDLE_NULL;
DAT_PSP_HANDLE psp = DAT_HANDLE_NULL;
DAT_CR_HANDLE cr = DAT_HANDLE_NULL;
-int server;
-
-char *usage = "-s | hostname (default == -s)\n";
+int server = 1;
+int ud_test = 0;
+int buf_size = BUF_SIZE;
+int msg_size = sizeof(DAT_RMR_TRIPLET);
+char provider[64] = DAPL_PROVIDER;
+DAT_IB_ADDR_HANDLE remote_ah;
+
+void print_usage(void)
+{
+ printf("\n dtestx usage \n\n");
+ printf("u unreliable datagram test\n");
+ printf("b: buf length to allocate\n");
+ printf("h: hostname/address of server, specified on client\n");
+ printf("P: provider name (default = ofa-v2-ib0)\n");
+ printf("\n");
+}
#if defined(_WIN32) || defined(_WIN64)
static void sleep(int secs)
@@ -186,24 +199,25 @@ send_msg(
iov.virtual_address = (DAT_VADDR)data;
iov.segment_length = (DAT_VLEN)size;
- status = dat_ep_post_send(ep,
- 1,
- &iov,
- cookie,
- flags);
+ if (ud_test)
+ status = dat_ib_post_send_ud(ep, 1, &iov,
+ &remote_ah, cookie, flags);
+ else
+ status = dat_ep_post_send(ep, 1, &iov, cookie, flags);
+
_OK(status, "dat_ep_post_send");
- if (! (flags & DAT_COMPLETION_SUPPRESS_FLAG)) {
+ if (!(flags & DAT_COMPLETION_SUPPRESS_FLAG)) {
status = dat_evd_wait(dto_evd, DTO_TIMEOUT,
1, &event, &nmore);
_OK(status, "dat_evd_wait after dat_ep_post_send");
- if (event.event_number != DAT_DTO_COMPLETION_EVENT) {
+ if ((event.event_number != DAT_DTO_COMPLETION_EVENT) &&
+ (ud_test && event.event_number != DAT_IB_DTO_EVENT)) {
printf("unexpected event waiting for post_send "
"completion - 0x%x\n", event.event_number);
exit(1);
}
-
_OK(dto_event->status, "event status for post_send");
}
}
@@ -225,8 +239,11 @@ connect_ep(char *hostname)
&event.event_data.cr_arrival_event_data;
DAT_DTO_COMPLETION_EVENT_DATA *dto_event =
&event.event_data.dto_completion_event_data;
+ DAT_IB_EXTENSION_EVENT_DATA *ext_event =
+ (DAT_IB_EXTENSION_EVENT_DATA *)
+ &event.event_extension_data[0];
- status = dat_ia_open(DAPL_PROVIDER, 8, &async_evd, &ia);
+ status = dat_ia_open(provider, 8, &async_evd, &ia);
_OK(status, "dat_ia_open");
status = dat_pz_create(ia, &pz);
@@ -243,16 +260,24 @@ connect_ep(char *hostname)
_OK(status, "dat_evd_create DTO");
memset(&ep_attr, 0, sizeof(ep_attr));
- ep_attr.service_type = DAT_SERVICE_TYPE_RC;
- ep_attr.max_rdma_size = 0x10000;
+ if (ud_test) {
+ msg_size += 40;
+ ep_attr.service_type = DAT_IB_SERVICE_TYPE_UD;
+ ep_attr.max_message_size = buf_size;
+ ep_attr.max_rdma_read_in = 0;
+ ep_attr.max_rdma_read_out = 0;
+ } else {
+ ep_attr.service_type = DAT_SERVICE_TYPE_RC;
+ ep_attr.max_rdma_size = 0x10000;
+ ep_attr.max_rdma_read_in = 4;
+ ep_attr.max_rdma_read_out = 4;
+ }
ep_attr.qos = 0;
ep_attr.recv_completion_flags = 0;
ep_attr.max_recv_dtos = 10;
ep_attr.max_request_dtos = 10;
ep_attr.max_recv_iov = 1;
ep_attr.max_request_iov = 1;
- ep_attr.max_rdma_read_in = 4;
- ep_attr.max_rdma_read_out = 4;
ep_attr.request_completion_flags = DAT_COMPLETION_DEFAULT_FLAG;
ep_attr.ep_transport_specific_count = 0;
ep_attr.ep_transport_specific = NULL;
@@ -264,12 +289,12 @@ connect_ep(char *hostname)
_OK(status, "dat_ep_create");
for (i = 0; i < REG_MEM_COUNT; i++) {
- buf[ i ] = (DAT_RMR_TRIPLET*)malloc(BUF_SIZE);
+ buf[ i ] = (DAT_RMR_TRIPLET*)malloc(buf_size);
region.for_va = buf[ i ];
status = dat_lmr_create(ia,
DAT_MEM_TYPE_VIRTUAL,
region,
- BUF_SIZE,
+ buf_size,
pz,
DAT_MEM_PRIV_ALL_FLAG|
DAT_IB_MEM_PRIV_REMOTE_ATOMIC,
@@ -283,7 +308,7 @@ connect_ep(char *hostname)
}
/* register atomic return buffer for original data */
- atomic_buf = (DAT_UINT64*)malloc(BUF_SIZE);
+ atomic_buf = (DAT_UINT64*)malloc(BUF_SIZE_ATOMIC);
region.for_va = atomic_buf;
status = dat_lmr_create(ia,
DAT_MEM_TYPE_VIRTUAL,
@@ -304,7 +329,7 @@ connect_ep(char *hostname)
cookie.as_64 = i;
iov.lmr_context = lmr_context[ i ];
iov.virtual_address = (DAT_VADDR) buf[ i ];
- iov.segment_length = BUF_SIZE;
+ iov.segment_length = buf_size;
status = dat_ep_post_recv(ep,
1,
@@ -330,9 +355,11 @@ connect_ep(char *hostname)
status = dat_evd_wait(cr_evd, SERVER_TIMEOUT,
1, &event, &nmore);
_OK(status, "listen dat_evd_wait");
-
- if (event.event_number != DAT_CONNECTION_REQUEST_EVENT) {
- printf("unexpected event after dat_psp_create: 0x%x\n",
+
+ if (event.event_number != DAT_CONNECTION_REQUEST_EVENT &&
+ (ud_test && event.event_number !=
+ DAT_IB_UD_CONNECTION_REQUEST_EVENT)) {
+ printf("unexpected event, !conn request: 0x%x\n",
event.event_number);
exit(1);
}
@@ -377,22 +404,39 @@ connect_ep(char *hostname)
status = dat_evd_wait(con_evd, CONN_TIMEOUT, 1, &event, &nmore);
_OK(status, "connect dat_evd_wait");
- if (event.event_number != DAT_CONNECTION_EVENT_ESTABLISHED) {
- printf("unexpected event after dat_ep_connect: 0x%x\n",
+ if (event.event_number != DAT_CONNECTION_EVENT_ESTABLISHED &&
+ (ud_test && event.event_number !=
+ DAT_IB_UD_CONNECTION_EVENT_ESTABLISHED)) {
+ printf("unexpected event, !conn established: 0x%x\n",
event.event_number);
exit(1);
}
+ /* if UD get the AH for the sends */
+ if (ud_test) {
+ if (ext_event->type == DAT_IB_UD_REMOTE_AH) {
+ remote_ah = ext_event->remote_ah;
+ printf(" remote_ah: ah=%p, qpn=0x%x addr=%s\n",
+ remote_ah.ah, remote_ah.qpn,
+ inet_ntoa(((struct sockaddr_in *)
+ &remote_ah.ia_addr)->sin_addr));
+ } else {
+ printf("unexpected UD ext_event type: 0x%x\n",
+ ext_event->type);
+ exit(1);
+ }
+ }
+
printf("Connected!\n");
/*
* Setup our remote memory and tell the other side about it
* Swap to network order.
*/
- r_iov = (DAT_RMR_TRIPLET*)buf[SEND_BUF_INDEX];
- r_iov->rmr_context = hton32(rmr_context[RCV_RDMA_BUF_INDEX]);
+ r_iov = (DAT_RMR_TRIPLET*)buf[SEND_BUF_INDEX];
+ r_iov->rmr_context = hton32(rmr_context[RCV_RDMA_BUF_INDEX]);
r_iov->virtual_address = hton64((DAT_VADDR)buf[RCV_RDMA_BUF_INDEX]);
- r_iov->segment_length = hton32(BUF_SIZE);
+ r_iov->segment_length = hton32(buf_size);
printf("%d Send RMR msg to remote: r_key_ctx=0x%x,va=%p,len=0x%x\n",
getpid(), hton32(r_iov->rmr_context),
@@ -411,25 +455,30 @@ connect_ep(char *hostname)
status = dat_evd_wait(dto_evd, DTO_TIMEOUT, 1, &event, &nmore);
_OK(status, "dat_evd_wait after dat_ep_post_send");
- if (event.event_number != DAT_DTO_COMPLETION_EVENT) {
- printf("unexpected event waiting for RMR context - 0x%x\n",
- event.event_number);
+ if ((event.event_number != DAT_DTO_COMPLETION_EVENT) &&
+ (ud_test && event.event_number != DAT_IB_DTO_EVENT)) {
+ printf("unexpected event waiting for RMR context "
+ "- 0x%x\n", event.event_number);
exit(1);
}
+ _OK(dto_event->status, "event status for post_recv");
- _OK(dto_event->status, "event status for post_send");
- if ((dto_event->transfered_length != sizeof(DAT_RMR_TRIPLET)) ||
- (dto_event->user_cookie.as_64 != RECV_BUF_INDEX)) {
+ if (dto_event->transfered_length != msg_size ||
+ dto_event->user_cookie.as_64 != RECV_BUF_INDEX) {
printf("unexpected event data for receive: len=%d cookie=%d "
"expected %d/%d\n",
(int)dto_event->transfered_length,
(int)dto_event->user_cookie.as_64,
- sizeof(DAT_RMR_TRIPLET), RECV_BUF_INDEX);
+ msg_size, RECV_BUF_INDEX);
exit(1);
}
/* swap RMR,address info to host order */
- r_iov = (DAT_RMR_TRIPLET*)buf[RECV_BUF_INDEX];
+ if (ud_test)
+ r_iov = (DAT_RMR_TRIPLET*)((char*)buf[RECV_BUF_INDEX]+40);
+ else
+ r_iov = (DAT_RMR_TRIPLET*)buf[RECV_BUF_INDEX];
+
r_iov->rmr_context = ntoh32(r_iov->rmr_context);
r_iov->virtual_address = ntoh64(r_iov->virtual_address);
r_iov->segment_length = ntoh32(r_iov->segment_length);
@@ -525,7 +574,7 @@ do_immediate()
iov.lmr_context = lmr_context[SND_RDMA_BUF_INDEX];
iov.virtual_address = (DAT_VADDR) buf[SND_RDMA_BUF_INDEX];
- iov.segment_length = BUF_SIZE;
+ iov.segment_length = buf_size;
cookie.as_64 = 0x9999;
@@ -554,7 +603,7 @@ do_immediate()
_OK(dto_event->status, "DTO event status");
if (ext_event->type == DAT_IB_RDMA_WRITE_IMMED)
{
- if ((dto_event->transfered_length != BUF_SIZE) ||
+ if ((dto_event->transfered_length != buf_size) ||
(dto_event->user_cookie.as_64 != 0x9999))
{
printf("unexpected event data for rdma_write_immed: len=%d "
@@ -566,7 +615,7 @@ do_immediate()
}
else if (ext_event->type == DAT_IB_RDMA_WRITE_IMMED_DATA)
{
- if ((dto_event->transfered_length != BUF_SIZE) ||
+ if ((dto_event->transfered_length != buf_size) ||
(dto_event->user_cookie.as_64 != RECV_BUF_INDEX+1))
{
printf("unexpected event data of immediate write: len=%d "
@@ -603,7 +652,7 @@ do_immediate()
_OK(dto_event->status, "event status");
if (ext_event->type == DAT_IB_RDMA_WRITE_IMMED)
{
- if ((dto_event->transfered_length != BUF_SIZE) ||
+ if ((dto_event->transfered_length != buf_size) ||
(dto_event->user_cookie.as_64 != 0x9999))
{
printf("unexpected event data for rdma_write_immed: len=%d "
@@ -615,7 +664,7 @@ do_immediate()
}
else if (ext_event->type == DAT_IB_RDMA_WRITE_IMMED_DATA)
{
- if ((dto_event->transfered_length != BUF_SIZE) ||
+ if ((dto_event->transfered_length != buf_size) ||
(dto_event->user_cookie.as_64 != RECV_BUF_INDEX+1))
{
printf("unexpected event data of immediate write: len=%d "
@@ -904,25 +953,39 @@ do_fetch_add()
return(0);
}
+
int
main(int argc, char **argv)
{
char *hostname;
- int rc=0;
-
- if (argc > 2) {
- printf(usage);
- exit(1);
- }
-
- if ((argc == 1) || strcmp(argv[ 1 ], "-s") == 0)
+ int rc;
+
+ /* parse arguments */
+ while ((rc = getopt(argc, argv, "uh:b:P:")) != -1)
{
- server = 1;
- } else {
- server = 0;
- hostname = argv[ 1 ];
+ switch(rc)
+ {
+ case 'u':
+ ud_test = 1;
+ fflush(stdout);
+ break;
+ case 'h':
+ server = 0;
+ strcpy (hostname, optarg);
+ break;
+ case 'b':
+ buf_size = atoi(optarg);
+ break;
+ case 'P':
+ strcpy (provider, optarg);
+ break;
+ default:
+ print_usage();
+ exit(-12);
+ }
}
+
#if defined(_WIN32) || defined(_WIN64)
{
WSADATA wsaData;
@@ -944,6 +1007,9 @@ main(int argc, char **argv)
_WSACleanup();
exit(1);
}
+ if (ud_test)
+ goto bail;
+
if (do_immediate()) {
_WSACleanup();
exit(1);
@@ -956,7 +1022,12 @@ main(int argc, char **argv)
_WSACleanup();
exit(1);
}
+bail:
rc = disconnect_ep();
_WSACleanup();
+
+ if (!rc)
+ printf("\n IB extension test - %s test PASSED\n\n",
+ ud_test?"UD":"immed/atomic");
return rc;
}
--
1.5.2.5
More information about the general
mailing list