static int client_setup(void) { size_t opt_size; int ret; /* Get fabric info */ ret = fi_getinfo(FT_FIVERSION, opts.dst_addr, opts.dst_port, 0, hints, &fi); if (ret) { FT_PRINTERR("fi_getinfo", ret); return ret; } ret = ft_open_fabric_res(); if (ret) return ret; ret = ft_alloc_active_res(fi); if (ret) return ret; ret = ft_enable_ep_recv(); if (ret) return ret; /* Get the maximum cm_size for this domain + endpoint combination */ opt_size = sizeof(opt_size); return fi_getopt(&ep->fid, FI_OPT_ENDPOINT, FI_OPT_CM_DATA_SIZE, &cm_data_size, &opt_size); }
static int init_fabric(void) { int ret; ret = ft_getinfo(hints, &fi); if (ret) return ret; ret = ft_open_fabric_res(); if (ret) return ret; ret = alloc_ep_res(fi); if (ret) return ret; ret = ft_enable_ep_recv(); if (ret) return ret; return 0; }
static int client_open_new_ep() { size_t opt_size; int ret; FT_CLOSE_FID(ep); ret = fi_endpoint(domain, fi, &ep, NULL); if (ret) { FT_PRINTERR("fi_endpoint", ret); return ret; } ret = ft_enable_ep_recv(); if (ret) return ret; /* Get the maximum cm_size for this domain + endpoint combination */ opt_size = sizeof(opt_size); return fi_getopt(&ep->fid, FI_OPT_ENDPOINT, FI_OPT_CM_DATA_SIZE, &cm_data_size, &opt_size); }
static int server_accept(size_t paramlen) { uint32_t event; int ret; ret = server_listen(paramlen); if (ret) return ret; ret = fi_domain(fabric, fi, &domain, NULL); if (ret) { FT_PRINTERR("fi_domain", ret); goto err; } ret = ft_alloc_active_res(fi); if (ret) { FT_PRINTERR("alloc_active_res", ret); goto err; } ret = ft_enable_ep_recv(); if (ret) { FT_PRINTERR("init_ep", ret); goto err; } /* Data will apppear on accept event on remote end. */ ft_fill_buf(cm_data, paramlen); /* Accept the incoming connection. Also transitions endpoint to active * state. */ ret = fi_accept(ep, cm_data, paramlen); if (ret) { FT_PRINTERR("fi_accept", ret); goto err; } /* Local FI_CONNECTED event does not have data associated. */ memset(entry, 0, sizeof(*entry)); ret = fi_eq_sread(eq, &event, entry, sizeof(*entry), -1, 0); if (ret != sizeof(*entry)) { FT_PROCESS_EQ_ERR(ret, eq, "fi_eq_sread", "accept"); goto err; } if (event != FI_CONNECTED || entry->fid != &ep->fid) { FT_ERR("Unexpected CM event %d fid %p (ep %p)", event, entry->fid, ep); ret = -FI_EOTHER; goto err; } fi_shutdown(ep, 0); ret = read_shutdown_event(); if (ret) goto err; FT_CLOSE_FID(ep); FT_CLOSE_FID(rxcq); FT_CLOSE_FID(txcq); FT_CLOSE_FID(rxcntr); FT_CLOSE_FID(txcntr); FT_CLOSE_FID(av); FT_CLOSE_FID(domain); return 0; err: fi_reject(pep, fi->handle, NULL, 0); return ret; }