static int server_listen(size_t paramlen) { size_t expected; uint32_t event; int ret; expected = paramlen + sizeof(*entry); memset(entry, 0, expected); ret = fi_eq_sread(eq, &event, entry, expected, -1, 0); if (ret != expected) { FT_PROCESS_EQ_ERR(ret, eq, "fi_eq_sread", "listen"); return ret; } if (event != FI_CONNREQ) { FT_ERR("Unexpected CM event %d", event); return -FI_EOTHER; } ret = ft_check_buf(entry->data, paramlen); if (ret) return ret; fi = entry->info; return 0; }
static int client_expect_reject(size_t paramlen) { uint32_t event; int ret; ret = client_connect(paramlen); if (ret) { FT_PRINTERR("fi_connect", ret); return ret; } ret = fi_eq_sread(eq, &event, entry, sizeof(*entry), -1, 0); if (ret != -FI_EAVAIL) { FT_PROCESS_EQ_ERR(ret, eq, "fi_eq_sread", "connect"); return ret; } ret = fi_eq_readerr(eq, &err_entry, 0); if (ret != sizeof(err_entry)) { FT_EQ_ERR(eq, err_entry, NULL, 0); return err_entry.err; } if (err_entry.err != FI_ECONNREFUSED) return err_entry.err; /* Check data on FI_ECONNREFUSED error event. */ return ft_check_buf(err_entry.err_data, err_entry.err_data_size); }
static int client_expect_accept(size_t paramlen) { size_t expected; uint32_t event; int ret; expected = paramlen + sizeof(*entry); ret = client_connect(paramlen); if (ret) { FT_PRINTERR("fi_connect", ret); return ret; } ret = fi_eq_sread(eq, &event, entry, expected, -1, 0); if (ret != expected) { FT_PROCESS_EQ_ERR(ret, eq, "fi_eq_sread", "connect"); return ret; } if (event != FI_CONNECTED || entry->fid != &ep->fid) { FT_ERR("Unexpected CM event %d fid %p (ep %p)", event, entry->fid, ep); return -FI_EOTHER; } /* Check data on FI_CONNECTED event. */ ret = ft_check_buf(entry->data, paramlen); if (ret) return ret; fi_shutdown(ep, 0); return read_shutdown_event(); }
ssize_t ft_rx(size_t size) { ssize_t ret; ret = ft_get_rx_comp(rx_seq); if (ret) return ret; if (ft_check_opts(FT_OPT_VERIFY_DATA | FT_OPT_ACTIVE)) { ret = ft_check_buf((char *) rx_buf + ft_rx_prefix_size(), size); if (ret) return ret; } /* TODO: verify CQ data, if available */ ret = ft_post_rx(rx_size); return ret; }
static int do_transfers(void) { int i, ret; for (i = 0; i < num_eps; i++) { rx_buf = recv_bufs[i]; ret = ft_post_rx(eps[i], opts.transfer_size, &recv_ctx[i]); if (ret) return ret; } for (i = 0; i < num_eps; i++) { if (ft_check_opts(FT_OPT_VERIFY_DATA)) ft_fill_buf(send_bufs[i], opts.transfer_size); tx_buf = send_bufs[i]; ret = ft_post_tx(eps[i], remote_addr[i], opts.transfer_size, &send_ctx[i]); if (ret) return ret; } ret = ft_get_tx_comp(num_eps); if (ret < 0) return ret; ret = ft_get_rx_comp(num_eps); if (ret < 0) return ret; if (ft_check_opts(FT_OPT_VERIFY_DATA)) { for (i = 0; i < num_eps; i++) { ret = ft_check_buf(recv_bufs[i], opts.transfer_size); if (ret) return ret; } } for (i = 0; i < num_eps; i++) ft_finalize_ep(eps[i]); printf("PASSED multi ep\n"); return 0; }
ssize_t ft_rx(struct fid_ep *ep, size_t size) { ssize_t ret; ret = ft_get_rx_comp(rx_seq); if (ret) return ret; if (ft_check_opts(FT_OPT_VERIFY_DATA | FT_OPT_ACTIVE)) { ret = ft_check_buf((char *) rx_buf + ft_rx_prefix_size(), size); if (ret) return ret; } /* TODO: verify CQ data, if available */ /* Ignore the size arg. Post a buffer large enough to handle all message * sizes. ft_sync() makes use of ft_rx() and gets called in tests just before * message size is updated. The recvs posted are always for the next incoming * message */ ret = ft_post_rx(ep, rx_size, &rx_ctx); return ret; }
static int run_test_loop(void) { int ret = 0; uint64_t op_data = send_data ? opts.transfer_size : NO_CQ_DATA; uint64_t op_tag = 0x1234; char *op_buf; int i, j; for (i = 0; i < num_iters; i++) { for (j = 0; j < concurrent_msgs; j++) { op_buf = get_tx_buf(j); if (ft_check_opts(FT_OPT_VERIFY_DATA)) ft_fill_buf(op_buf + ft_tx_prefix_size(), opts.transfer_size); ret = ft_post_tx_buf(ep, remote_fi_addr, opts.transfer_size, op_data, &tx_ctx_arr[j], op_buf, mr_desc, op_tag); if (ret) { printf("ERROR send_msg returned %d\n", ret); return ret; } } ret = ft_sync(); if (ret) return ret; for (j = 0; j < concurrent_msgs; j++) { op_buf = get_rx_buf(j); ret = ft_post_rx_buf(ep, opts.transfer_size, &rx_ctx_arr[j], op_buf, mr_desc, op_tag); if (ret) { printf("ERROR recv_msg returned %d\n", ret); return ret; } } for (j = 0; j < concurrent_msgs; j++) { ret = wait_recvs(); if (ret < 1) return ret; } if (ft_check_opts(FT_OPT_VERIFY_DATA)) { for (j = 0; j < concurrent_msgs; j++) { op_buf = get_rx_buf(j); if (ft_check_buf(op_buf + ft_rx_prefix_size(), opts.transfer_size)) return -FI_EOTHER; } } for (j = 0; j < concurrent_msgs; j++) { ret = ft_get_tx_comp(tx_seq); if (ret) return ret; } if (i % 100 == 0) printf("PID %d GOOD iter %d/%ld completed\n", getpid(), i, num_iters); } (void) ft_sync(); printf("PID %d GOOD all done\n", getpid()); return ret; }