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)
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");
}
}
&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);
_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;
_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,
}
/* 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,
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,
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);
}
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),
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);
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;
_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 "
}
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 "
_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 "
}
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 "
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;
_WSACleanup();
exit(1);
}
+ if (ud_test)
+ goto bail;
+
if (do_immediate()) {
_WSACleanup();
exit(1);
_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;
}