Ejemplo n.º 1
0
int ft_server_connect(void)
{
	struct fi_eq_cm_entry entry;
	uint32_t event;
	ssize_t rd;
	int ret;

	rd = fi_eq_sread(eq, &event, &entry, sizeof entry, -1, 0);
	if (rd != sizeof entry) {
		FT_PROCESS_EQ_ERR(rd, eq, "fi_eq_sread", "listen");
		return (int) rd;
	}

	fi = entry.info;
	if (event != FI_CONNREQ) {
		fprintf(stderr, "Unexpected CM event %d\n", event);
		ret = -FI_EOTHER;
		goto err;
	}

	ret = fi_domain(fabric, fi, &domain, NULL);
	if (ret) {
		FT_PRINTERR("fi_domain", ret);
		goto err;
	}

	ret = ft_alloc_active_res(fi);
	if (ret)
		goto err;

	ret = ft_init_ep();
	if (ret)
		goto err;

	ret = fi_accept(ep, NULL, 0);
	if (ret) {
		FT_PRINTERR("fi_accept", ret);
		goto err;
	}

	rd = fi_eq_sread(eq, &event, &entry, sizeof entry, -1, 0);
	if (rd != sizeof entry) {
		FT_PROCESS_EQ_ERR(rd, eq, "fi_eq_sread", "accept");
		ret = (int) rd;
		goto err;
	}

	if (event != FI_CONNECTED || entry.fid != &ep->fid) {
		fprintf(stderr, "Unexpected CM event %d fid %p (ep %p)\n",
			event, entry.fid, ep);
		ret = -FI_EOTHER;
		goto err;
	}

	return 0;

err:
	fi_reject(pep, fi->handle, NULL, 0);
	return ret;
}
Ejemplo n.º 2
0
void dg_setup(void)
{
	int ret = 0;
	char my_hostname[HOST_NAME_MAX];

	hints = fi_allocinfo();
	cr_assert(hints, "fi_allocinfo");

	hints->domain_attr->cq_data_size = 4;
	hints->mode = ~0;

	hints->fabric_attr->name = strdup("gni");

	ret = gethostname(my_hostname, sizeof(my_hostname));
	cr_assert(!ret, "gethostname");

	ret = fi_getinfo(FI_VERSION(1, 0), my_hostname, my_cdm_id, FI_SOURCE,
			 hints, &fi);
	cr_assert(!ret, "fi_getinfo");

	ret = fi_fabric(fi->fabric_attr, &fab, NULL);
	cr_assert(!ret, "fi_fabric");

	ret = fi_domain(fab, fi, &dom, NULL);
	cr_assert(!ret, "fi_domain");

	ret = fi_endpoint(dom, fi, &ep, NULL);
	cr_assert(!ret, "fi_endpoint");
}
Ejemplo n.º 3
0
void dg_setup_prog_manual(void)
{
	int ret = 0;

	hints = fi_allocinfo();
	cr_assert(hints, "fi_allocinfo");

	hints->domain_attr->cq_data_size = 4;
	hints->domain_attr->control_progress = FI_PROGRESS_MANUAL;
	hints->mode = ~0;

	hints->fabric_attr->name = strdup("gni");

	ret = fi_getinfo(FI_VERSION(1, 0), NULL, 0, 0, hints, &fi);
	cr_assert(!ret, "fi_getinfo");

	ret = fi_fabric(fi->fabric_attr, &fab, NULL);
	cr_assert(!ret, "fi_fabric");

	ret = fi_domain(fab, fi, &dom, NULL);
	cr_assert(!ret, "fi_domain");

	ret = fi_endpoint(dom, fi, &ep, NULL);
	cr_assert(!ret, "fi_endpoint");
}
Ejemplo n.º 4
0
static inline void cntr_setup_eps(void)
{
	int i, ret;
	struct fi_av_attr attr;

	hints = fi_allocinfo();
	cr_assert(hints, "fi_allocinfo");

	hints->domain_attr->cq_data_size = 4;
	hints->mode = ~0;

	hints->fabric_attr->name = strdup("gni");

	ret = fi_getinfo(FI_VERSION(1, 0), NULL, 0, 0, hints, &fi);
	cr_assert(!ret, "fi_getinfo");

	ret = fi_fabric(fi->fabric_attr, &fab, NULL);
	cr_assert(!ret, "fi_fabric");

	ret = fi_domain(fab, fi, &dom, NULL);
	cr_assert(!ret, "fi_domain");

	attr.type = FI_AV_MAP;
	attr.count = 16;

	ret = fi_av_open(dom, &attr, &av, NULL);
	cr_assert(!ret, "fi_av_open");

	for (i = 0; i < NUM_EPS; i++) {
		ret = fi_endpoint(dom, fi, &ep[i], NULL);
		cr_assert(!ret, "fi_endpoint");
	}
}
Ejemplo n.º 5
0
Test(domain, cache_flush_op)
{
	int i, ret;
	const int num_doms = 11;
	struct fid_domain *doms[num_doms];
	struct fi_gni_ops_domain *gni_domain_ops;
	struct fid_mr *mr;
	char *buf = calloc(1024, sizeof(char));

	cr_assert(buf);

	memset(doms, 0, num_doms*sizeof(struct fid_domain *));

	for (i = 0; i < num_doms; i++) {
		ret = fi_domain(fabric, fi, &doms[i], NULL);
		cr_assert(ret == FI_SUCCESS, "fi_domain");
		ret = fi_open_ops(&doms[i]->fid, FI_GNI_DOMAIN_OPS_1,
				  0, (void **) &gni_domain_ops, NULL);
		cr_assert(ret == FI_SUCCESS, "fi_open_ops");

		ret = fi_mr_reg(doms[i], buf, 1024, FI_READ, 0, 0, 0, &mr, NULL);
		cr_assert(ret == FI_SUCCESS, "fi_reg_mr");

		ret = fi_close(&mr->fid);
		cr_assert(ret == FI_SUCCESS, "fi_close mr");

		ret = gni_domain_ops->flush_cache(&doms[i]->fid);
		cr_assert(ret == FI_SUCCESS, "flush cache");

		ret = fi_close(&doms[i]->fid);
		cr_assert(ret == FI_SUCCESS, "fi_close domain");
	}

	free(buf);
}
Ejemplo n.º 6
0
Test(domain, many_domains)
{
	int i, ret;
	const int num_doms = 7919;
	struct fid_domain *doms[num_doms];
	struct gnix_fid_domain *gdom;
	struct gnix_fid_fabric *gfab;

	memset(doms, 0, num_doms*sizeof(struct fid_domain *));

	gfab = container_of(fabric, struct gnix_fid_fabric, fab_fid);
	for (i = 0; i < num_doms; i++) {
		ret = fi_domain(fabric, fi, &doms[i], NULL);
		cr_assert(ret == FI_SUCCESS, "fi_domain");
		gdom = container_of(doms[i], struct gnix_fid_domain,
				    domain_fid);
		cr_assert(gdom, "domain not allcoated");
		cr_assert(gdom->fabric == gfab, "Incorrect fabric");
		cr_assert(atomic_get(&gdom->ref_cnt.references) == 1,
				"Incorrect ref_cnt");

	}

	for (i = num_doms-1; i >= 0; i--) {
		ret = fi_close(&doms[i]->fid);
		cr_assert(ret == FI_SUCCESS, "fi_close domain");
	}

}
Ejemplo n.º 7
0
static int init_fabric(void)
{
	uint64_t flags = 0;
	char *node, *service;
	int ret;

	ret = ft_read_addr_opts(&node, &service, hints, &flags, &opts);
	if (ret)
		return ret;
	
	ret = fi_getinfo(FT_FIVERSION, node, service, flags, hints, &fi);
	if (ret) {
		FT_PRINTERR("fi_getinfo", ret);
		return ret;
	}

	// we use provider MR attributes and direct address (no offsets) 
	// for RMA calls
	if (!(fi->mode & FI_PROV_MR_ATTR))
		fi->mode |= FI_PROV_MR_ATTR;

	// get remote address
	if (opts.dst_addr) {
		addrlen = fi->dest_addrlen;
		remote_addr = malloc(addrlen);
		memcpy(remote_addr, fi->dest_addr, addrlen);
	}

	ret = fi_fabric(fi->fabric_attr, &fab, NULL);
	if (ret) {
		FT_PRINTERR("fi_fabric", ret);
		goto err0;
	}

	ret = fi_domain(fab, fi, &dom, NULL);
	if (ret) {
		FT_PRINTERR("fi_domain", ret);
		goto err1;
	}
	
	ret = alloc_ep_res(fi);
	if (ret)
		goto err3;

	ret = bind_ep_res();
	if (ret)
		goto err4;

	return 0;

err4:
	free_ep_res();
err3:
	fi_close(&dom->fid);
err1:
	fi_close(&fab->fid);
err0:
	return ret;
}
Ejemplo n.º 8
0
int cm_client_start_connect(void)
{
	int ret;
	struct sockaddr_in loc_sa;

	cm_local_ip(&loc_sa);

	cli_hints = fi_allocinfo();
	cli_hints->fabric_attr->name = strdup("gni");
	cli_hints->caps = GNIX_EP_PRIMARY_CAPS;
	cli_hints->ep_attr->type = FI_EP_MSG;
	cli_hints->domain_attr->mr_mode = GNIX_DEFAULT_MR_MODE;

	ret = fi_getinfo(fi_version(), inet_ntoa(loc_sa.sin_addr),
			 DEF_PORT, 0, cli_hints, &cli_fi);
	cr_assert(!ret);

	ret = fi_fabric(cli_fi->fabric_attr, &cli_fab, NULL);
	cr_assert(!ret);

	ret = fi_eq_open(cli_fab, &eq_attr, &cli_eq, NULL);
	cr_assert(!ret);

	ret = fi_domain(cli_fab, cli_fi, &cli_dom, NULL);
	cr_assert(!ret);

	ret = fi_endpoint(cli_dom, cli_fi, &cli_ep, NULL);
	cr_assert(!ret, "fi_endpoint");

	cq_attr.format = FI_CQ_FORMAT_TAGGED;
	cq_attr.size = 1024;
	cq_attr.wait_obj = 0;

	ret = fi_cq_open(cli_dom, &cq_attr, &cli_cq, &cli_cq);
	cr_assert(!ret);

	ret = fi_ep_bind(cli_ep, &cli_eq->fid, 0);
	cr_assert(!ret);

	ret = fi_ep_bind(cli_ep, &cli_cq->fid, FI_SEND | FI_RECV);
	cr_assert(!ret);

	ret = fi_enable(cli_ep);
	cr_assert(!ret);

	ret = fi_connect(cli_ep, cli_fi->dest_addr, cli_cm_in_data,
			 GNIX_CM_DATA_MAX_SIZE+1);
	cr_assert(ret == -FI_EINVAL);

	ret = fi_connect(cli_ep, cli_fi->dest_addr, cli_cm_in_data,
			 strlen(cli_cm_in_data));
	cr_assert(!ret);

	dbg_printf("Client connect complete.\n");

	return 0;
}
Ejemplo n.º 9
0
static int init_fabric(void)
{
	int ret;
	uint64_t flags = 0;

	/* Get fabric info */
	ret = fi_getinfo(CT_FIVERSION, NULL, NULL, flags, hints, &fi);
	if (ret) {
		ct_print_fi_error("fi_getinfo", ret);
		return ret;
	}

	/* Open fabric */
	ret = fi_fabric(fi->fabric_attr, &fab, NULL);
	if (ret) {
		ct_print_fi_error("fi_fabric", ret);
		goto err1;
	}

	/* Open domain */
	ret = fi_domain(fab, fi, &dom, NULL);
	if (ret) {
		ct_print_fi_error("fi_domain", ret);
		goto err2;
	}

	/* Open endpoint */
	ret = fi_endpoint(dom, fi, &ep, NULL);
	if (ret) {
		ct_print_fi_error("fi_endpoint", ret);
		goto err3;
	}

	/* Allocate endpoint resources */
	ret = alloc_ep_res();
	if (ret)
		goto err4;

	/* Bind EQs and AVs with endpoint */
	ret = bind_ep_res();
	if (ret)
		goto err5;

	return 0;

err5:
	free_ep_res();
err4:
	fi_close(&ep->fid);
err3:
	fi_close(&dom->fid);
err2:
	fi_close(&fab->fid);
err1:
	return ret;
}
Ejemplo n.º 10
0
static int client_connect(void)
{
	struct fi_eq_cm_entry entry;
	uint32_t event;
	ssize_t rd;
	int ret;

	ret = ft_getsrcaddr(opts.src_addr, opts.src_port, hints);
	if (ret)
		return ret;

	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 = fi_domain(fabric, fi, &domain, NULL);
	if (ret) {
		FT_PRINTERR("fi_domain", ret);
		return ret;
	}

	ret = alloc_ep_res(fi);
	if (ret)
		return ret;

	ret = ft_init_ep(buf);
	if (ret)
		return ret;

	ret = fi_connect(ep, fi->dest_addr, NULL, 0);
	if (ret) {
		FT_PRINTERR("fi_connect", ret);
		return ret;
	}

	rd = fi_eq_sread(eq, &event, &entry, sizeof entry, -1, 0);
	if (rd != sizeof entry) {
		FT_PROCESS_EQ_ERR(rd, eq, "fi_eq_sread", "connect");
		return (int) rd;
	}

	if (event != FI_CONNECTED || entry.fid != &ep->fid) {
		fprintf(stderr, "Unexpected CM event %d fid %p (ep %p)\n",
			event, entry.fid, ep);
		return -FI_EOTHER;
	}

	return 0;
}
Ejemplo n.º 11
0
static int init_fabric(void)
{
	char *node, *service;
	uint64_t flags = 0;
	int ret;

	ret = ft_read_addr_opts(&node, &service, hints, &flags, &opts);
	if (ret)
		return ret;

	/* Get fabric info */
	ret = fi_getinfo(FT_FIVERSION, node, service, flags, hints, &fi);
	if (ret) {
		FT_PRINTERR("fi_getinfo", ret);
		return ret;
	}

	/* Get remote address of the server */
	if (opts.dst_addr) {
		addrlen = fi->dest_addrlen;
		remote_addr = malloc(addrlen);
		memcpy(remote_addr, fi->dest_addr, addrlen);
	}

	ret = ft_open_fabric_res();
	if (ret)
		return ret;

	/* Open domain */
	ret = fi_domain(fabric, fi, &domain, NULL);
	if (ret) {
		FT_PRINTERR("fi_domain", ret);
		return ret;
	}

	ret = alloc_ep_res(fi);
	if (ret)
		return ret;

	ret = ft_init_ep(NULL);
	if (ret)
		return ret;

	if (opts.dst_addr) {
		/* Insert address to the AV and get the fabric address back */
		ret = fi_av_insert(av, remote_addr, 1, &remote_fi_addr, 0,
				&fi_ctx_av);
		if (ret != 1) {
			FT_PRINTERR("fi_av_insert", ret);
			return ret;
		}
	}

	return 0;
}
Ejemplo n.º 12
0
static inline int allocate_fabric_resources(struct fabric_info *info)
{
    int ret = 0;
    struct fi_av_attr   av_attr = {0};


    /* fabric domain: define domain of resources physical and logical*/
    ret = fi_fabric(info->p_info->fabric_attr, &shmem_transport_ofi_fabfd, NULL);
    if(ret!=0){
	OFI_ERRMSG("fabric initialization failed\n");
	return ret;
    }

    /*access domain: define communication resource limits/boundary within fabric domain */
    ret = fi_domain(shmem_transport_ofi_fabfd, info->p_info,
		    &shmem_transport_ofi_domainfd,NULL);
    if(ret!=0){
	OFI_ERRMSG("domain initialization failed\n");
	return ret;
    }

    /*transmit context: allocate one transmit context for this SHMEM PE
     * and share it across different multiple endpoints. Since we have only
     * one thread per PE, a single context is sufficient and allows more
     * more PEs/node (i.e. doesn't exhaust contexts)  */
    ret = fi_stx_context(shmem_transport_ofi_domainfd, NULL, /* TODO: fill tx_attr */
		    &shmem_transport_ofi_stx, NULL);
    if(ret!=0) {
	OFI_ERRMSG("stx context initialization failed\n");
	return ret;
    }

    /*AV table set-up for PE mapping*/

#ifdef USE_AV_MAP
    av_attr.type = FI_AV_MAP;
    addr_table   = (fi_addr_t*) malloc(info->npes * sizeof(fi_addr_t));
#else
    /* open Address Vector and bind the AV to the domain */
    av_attr.type = FI_AV_TABLE;
    addr_table   = NULL;
#endif

    ret = fi_av_open(shmem_transport_ofi_domainfd,
		    &av_attr,
		    &shmem_transport_ofi_avfd,
		    NULL);
    if(ret!=0){
	OFI_ERRMSG("av open failed\n");
	return ret;
    }

    return ret;
}
Ejemplo n.º 13
0
int rxm_domain_open(struct fid_fabric *fabric, struct fi_info *info,
		struct fid_domain **domain, void *context)
{
	int ret;
	struct rxm_domain *rxm_domain;
	struct rxm_fabric *rxm_fabric;
	struct fi_info *msg_info;

	rxm_domain = calloc(1, sizeof(*rxm_domain));
	if (!rxm_domain)
		return -FI_ENOMEM;

	rxm_fabric = container_of(fabric, struct rxm_fabric, util_fabric.fabric_fid);

	ret = ofi_get_core_info(fabric->api_version, NULL, NULL, 0, &rxm_util_prov,
				info, rxm_info_to_core, &msg_info);
	if (ret)
		goto err1;

	/* Force core provider to supply MR key */
	if (FI_VERSION_LT(fabric->api_version, FI_VERSION(1, 5)))
		msg_info->domain_attr->mr_mode = FI_MR_BASIC;
	else
		msg_info->domain_attr->mr_mode |= FI_MR_PROV_KEY;

	ret = fi_domain(rxm_fabric->msg_fabric, msg_info,
			&rxm_domain->msg_domain, context);
	if (ret)
		goto err2;

	ret = ofi_domain_init(fabric, info, &rxm_domain->util_domain, context);
	if (ret) {
		goto err3;
	}

	*domain = &rxm_domain->util_domain.domain_fid;
	(*domain)->fid.ops = &rxm_domain_fi_ops;
	/* Replace MR ops set by ofi_domain_init() */
	(*domain)->mr = &rxm_domain_mr_ops;
	(*domain)->ops = &rxm_domain_ops;

	rxm_domain->mr_local = OFI_CHECK_MR_LOCAL(msg_info->domain_attr->mr_mode) &&
				!OFI_CHECK_MR_LOCAL(info->domain_attr->mr_mode);

	fi_freeinfo(msg_info);
	return 0;
err3:
	fi_close(&rxm_domain->msg_domain->fid);
err2:
	fi_freeinfo(msg_info);
err1:
	free(rxm_domain);
	return ret;
}
Ejemplo n.º 14
0
static int init_fabric(void)
{
	uint64_t flags = 0;
	char *node, *service;
	int ret;

	ret = ft_read_addr_opts(&node, &service, hints, &flags, &opts);
	if (ret)
		return ret;

	ret = fi_getinfo(FT_FIVERSION, node, service, flags, hints, &fi);
	if (ret) {
		FT_PRINTERR("fi_getinfo", ret);
		return ret;
	}

	/* Check the number of EPs supported by the provider */
	if (ep_cnt > fi->domain_attr->ep_cnt) {
		ep_cnt = fi->domain_attr->ep_cnt;
		fprintf(stderr, "Provider can support only %d of EPs\n", ep_cnt);
	}

	/* Get remote address */
	if (opts.dst_addr) {
		addrlen = fi->dest_addrlen;
		remote_addr = malloc(addrlen * ep_cnt);
		memcpy(remote_addr, fi->dest_addr, addrlen);
	}

	ret = ft_open_fabric_res();
	if (ret)
		return ret;

	ret = fi_domain(fabric, fi, &domain, NULL);
	if (ret) {
		FT_PRINTERR("fi_domain", ret);
		return ret;
	}

	fi->ep_attr->tx_ctx_cnt = FI_SHARED_CONTEXT;
	fi->ep_attr->rx_ctx_cnt = FI_SHARED_CONTEXT;

	ret = alloc_ep_res(fi);
	if (ret)
		return ret;

	ret = bind_ep_res();
	if (ret)
		return ret;

	return 0;
}
Ejemplo n.º 15
0
static int init_fabric(void)
{
	uint64_t flags = 0;
	char *node, *service;
	int ret;

	ret = ft_read_addr_opts(&node, &service, hints, &flags, &opts);
	if (ret)
		return ret;

	ret = fi_getinfo(FT_FIVERSION, node, service, flags, hints, &fi);
	if (ret) {
		FT_PRINTERR("fi_getinfo", ret);
		return ret;
	}

	/* check max msg size */
	max_inject_size = fi->tx_attr->inject_size;
	if ((opts.options & FT_OPT_SIZE) &&
	    (opts.transfer_size > max_inject_size)) {
		fprintf(stderr, "Msg size greater than max inject size\n");
		return -FI_EINVAL;
	}

	/* Get remote address */
	if (opts.dst_addr) {
		addrlen = fi->dest_addrlen;
		remote_addr = malloc(addrlen);
		memcpy(remote_addr, fi->dest_addr, addrlen);
	}

	ret = ft_open_fabric_res();
	if (ret)
		return ret;

	ret = fi_domain(fabric, fi, &domain, NULL);
	if (ret) {
		FT_PRINTERR("fi_domain", ret);
		return ret;
	}

	ret = alloc_ep_res(fi);
	if (ret)
		return ret;

	ret = ft_init_ep(NULL);
	if (ret)
		return ret;

	return 0;
}
Ejemplo n.º 16
0
int cm_server_accept(void)
{
	uint32_t event;
	ssize_t rd;
	int ret;
	struct fi_eq_cm_entry *entry;
	void *eqe_buf[EQE_SIZE] = {0};

	rd = fi_eq_sread(srv_eq, &event, &eqe_buf, EQE_SIZE, -1, 0);
	cr_assert(rd == (sizeof(*entry) + strlen(cli_cm_in_data)));
	cr_assert(event == FI_CONNREQ);

	entry = (struct fi_eq_cm_entry *)eqe_buf;
	cr_assert(!memcmp(cli_cm_in_data, entry->data,
			  strlen(cli_cm_in_data)));

	ret = fi_domain(srv_fab, entry->info, &srv_dom, NULL);
	cr_assert(!ret);

	ret = fi_endpoint(srv_dom, entry->info, &srv_ep, NULL);
	cr_assert(!ret, "fi_endpoint");

	fi_freeinfo(entry->info);

	cq_attr.format = FI_CQ_FORMAT_TAGGED;
	cq_attr.size = 1024;
	cq_attr.wait_obj = 0;

	ret = fi_cq_open(srv_dom, &cq_attr, &srv_cq, &srv_cq);
	cr_assert(!ret);

	ret = fi_ep_bind(srv_ep, &srv_eq->fid, 0);
	cr_assert(!ret);

	ret = fi_ep_bind(srv_ep, &srv_cq->fid, FI_SEND | FI_RECV);
	cr_assert(!ret);

	ret = fi_enable(srv_ep);
	cr_assert(!ret);

	ret = fi_accept(srv_ep, srv_cm_in_data, GNIX_CM_DATA_MAX_SIZE+1);
	cr_assert(ret == -FI_EINVAL);

	ret = fi_accept(srv_ep, srv_cm_in_data, strlen(srv_cm_in_data));
	cr_assert(!ret);

	dbg_printf("Server accept complete.\n");

	return 0;
}
Ejemplo n.º 17
0
/*
 * rpmem_fip_init_fabric_res -- (internal) initialize common fabric resources
 */
static int
rpmem_fip_init_fabric_res(struct rpmem_fip *fip)
{
	int ret;
	ret = fi_fabric(fip->fi->fabric_attr, &fip->fabric, NULL);
	if (ret) {
		RPMEM_FI_ERR(ret, "opening fabric domain");
		goto err_fi_fabric;
	}

	ret = fi_domain(fip->fabric, fip->fi, &fip->domain, NULL);
	if (ret) {
		RPMEM_FI_ERR(ret, "opening fabric access domain");
		goto err_fi_domain;
	}

	struct fi_eq_attr eq_attr = {
		.size = 0, /* use default value */
		.flags = 0,
		.wait_obj = FI_WAIT_UNSPEC,
		.signaling_vector = 0,
		.wait_set = NULL,
	};

	ret = fi_eq_open(fip->fabric, &eq_attr, &fip->eq, NULL);
	if (ret) {
		RPMEM_FI_ERR(ret, "opening event queue");
		goto err_eq_open;
	}

	return 0;
err_eq_open:
	RPMEM_FI_CLOSE(fip->domain, "closing fabric access domain");
err_fi_domain:
	RPMEM_FI_CLOSE(fip->fabric, "closing fabric domain");
err_fi_fabric:
	return ret;
}

/*
 * rpmem_fip_fini_fabric_res -- (internal) deinitialize common fabric resources
 */
static void
rpmem_fip_fini_fabric_res(struct rpmem_fip *fip)
{
	RPMEM_FI_CLOSE(fip->eq, "closing event queue");
	RPMEM_FI_CLOSE(fip->domain, "closing fabric access domain");
	RPMEM_FI_CLOSE(fip->fabric, "closing fabric domain");
}
Ejemplo n.º 18
0
void vc_lookup_setup(int av_type, int av_size)
{
	int ret = 0;
	struct fi_av_attr attr;

	hints = fi_allocinfo();

	hints->mode = mode_bits;
	hints->domain_attr->mr_mode = GNIX_DEFAULT_MR_MODE;
	hints->fabric_attr->prov_name = strdup("gni");

	/* Create endpoint */
	ret = fi_getinfo(fi_version(), NULL, 0, 0, hints, &fi);
	cr_assert(!ret, "fi_getinfo");

	ret = fi_fabric(fi->fabric_attr, &fab, NULL);
	cr_assert(!ret, "fi_fabric");

	ret = fi_domain(fab, fi, &dom, NULL);
	cr_assert(!ret, "fi_domain");

	attr.type = av_type;
	attr.count = av_size;

	ret = fi_av_open(dom, &attr, &av, NULL);
	cr_assert(!ret, "fi_av_open");

	ret = fi_endpoint(dom, fi, &ep, NULL);
	cr_assert(!ret, "fi_endpoint");

	gnix_ep = container_of(ep, struct gnix_fid_ep, ep_fid);

	ret = fi_getname(&ep->fid, NULL, &ep_name_len);

	ret = fi_getname(&ep->fid, &ep_name, &ep_name_len);
	cr_assert(ret == FI_SUCCESS);

	ret = fi_ep_bind(ep, &av->fid, 0);
	cr_assert(!ret, "fi_ep_bind");

	ret = fi_enable(ep);
	cr_assert(!ret, "fi_ep_enable");

	fi_freeinfo(hints);
}
Ejemplo n.º 19
0
static void setup(void)
{
	int ret;

	hints = fi_allocinfo();
	cr_assert(hints, "fi_allocinfo");

	hints->fabric_attr->prov_name = strdup("gni");

	ret = fi_getinfo(FI_VERSION(1, 0), NULL, 0, 0, hints, &fi);
	cr_assert(!ret, "fi_getinfo");

	ret = fi_fabric(fi->fabric_attr, &fab, NULL);
	cr_assert(!ret, "fi_fabric");

	ret = fi_domain(fab, fi, &dom, NULL);
	cr_assert(!ret, "fi_domain");

}
Ejemplo n.º 20
0
static int ft_open_domain(void)
{
	int ret;

	if (domain) {
		if (fabric_info->domain_attr->domain &&
		    fabric_info->domain_attr->domain != domain) {
			fprintf(stderr, "Opened domain / domain_attr mismatch\n");
			return -FI_EDOMAIN;
		}
		return 0;
	}

	ret = fi_domain(fabric, fabric_info, &domain, NULL);
	if (ret)
		FT_PRINTERR("fi_domain", ret);

	return ret;
}
Ejemplo n.º 21
0
static int init_fabric(void)
{
	uint64_t flags = 0;
	char *node, *service;
	int ret;

	ret = ft_read_addr_opts(&node, &service, hints, &flags, &opts);
	if (ret)
		return ret;

	ret = fi_getinfo(FT_FIVERSION, node, service, flags, hints, &fi);
	if (ret) {
		FT_PRINTERR("fi_getinfo", ret);
		return ret;
	}

	/* Get remote address */
	if (opts.dst_addr) {
		addrlen = fi->dest_addrlen;
		remote_addr = malloc(addrlen);
		memcpy(remote_addr, fi->dest_addr, addrlen);
	}

	ret = ft_open_fabric_res();
	if (ret)
		return ret;

	ret = fi_domain(fabric, fi, &domain, NULL);
	if (ret) {
		FT_PRINTERR("fi_domain", ret);
		return ret;
	}

	ret = alloc_ep_res(fi);
	if (ret)
		return ret;

	ret = ft_init_ep(NULL);
	if (ret)
		return ret;

	return 0;
}
Ejemplo n.º 22
0
static void av_setup(void)
{
	int ret = 0;

	hints = fi_allocinfo();
	cr_assert(hints, "fi_allocinfo");

	hints->domain_attr->cq_data_size = 4;
	hints->mode = ~0;

	hints->fabric_attr->prov_name = strdup("gni");

	ret = fi_getinfo(FI_VERSION(1, 0), NULL, 0, 0, hints, &fi);
	cr_assert_eq(ret, FI_SUCCESS, "fi_getinfo");

	ret = fi_fabric(fi->fabric_attr, &fab, NULL);
	cr_assert_eq(ret, FI_SUCCESS, "fi_fabric");

	ret = fi_domain(fab, fi, &dom, NULL);
	cr_assert_eq(ret, FI_SUCCESS, "fi_domain");

}
Ejemplo n.º 23
0
static void _setup(uint32_t version)
{
	int ret;

	hints = fi_allocinfo();
	cr_assert(hints, "fi_allocinfo");

	if (FI_VERSION_LT(version, FI_VERSION(1, 5)))
		hints->domain_attr->mr_mode = FI_MR_BASIC;
	else
		hints->domain_attr->mr_mode = GNIX_DEFAULT_MR_MODE;
	hints->fabric_attr->prov_name = strdup("gni");

	ret = fi_getinfo(version, NULL, 0, 0, hints, &fi);
	cr_assert(!ret, "fi_getinfo");

	ret = fi_fabric(fi->fabric_attr, &fab, NULL);
	cr_assert(!ret, "fi_fabric");

	ret = fi_domain(fab, fi, &dom, NULL);
	cr_assert(!ret, "fi_domain");
}
Ejemplo n.º 24
0
Test(domain, invalid_open_ops)
{
	int ret;
	struct fid_domain *dom;
	struct fi_gni_ops_domain *gni_domain_ops;
	uint32_t val = 0;

	ret = fi_domain(fabric, fi, &dom, NULL);
	cr_assert(ret == FI_SUCCESS, "fi_domain");
	ret = fi_open_ops(&dom->fid, FI_GNI_DOMAIN_OPS_1,
			  0, (void **) &gni_domain_ops, NULL);
	cr_assert(ret == FI_SUCCESS, "fi_open_ops");

	ret = gni_domain_ops->get_val(&dom->fid, GNI_NUM_DOM_OPS, &val);
	cr_assert(ret == -FI_EINVAL, "get_val");

	ret = gni_domain_ops->set_val(&dom->fid, GNI_NUM_DOM_OPS, &val);
	cr_assert(ret == -FI_EINVAL, "set_val");

	ret = fi_close(&dom->fid);
	cr_assert(ret == FI_SUCCESS, "fi_close domain");
}
Ejemplo n.º 25
0
void setup(void)
{
	int ret = 0;

	hints = fi_allocinfo();
	cr_assert(hints, "fi_allocinfo");

	hints->domain_attr->cq_data_size = 4;
	hints->mode = ~0;

	hints->fabric_attr->name = strdup("gni");

	ret = fi_getinfo(FI_VERSION(1, 0), NULL, 0, 0, hints, &fi);
	cr_assert(!ret, "fi_getinfo");

	ret = fi_fabric(fi->fabric_attr, &fab, NULL);
	cr_assert(!ret, "fi_fabric");

	ret = fi_domain(fab, fi, &dom, NULL);
	cr_assert(!ret, "fi_domain");

	cq_attr.wait_obj = FI_WAIT_NONE;
}
Ejemplo n.º 26
0
static void setup_dom(enum fi_progress pm)
{
	int ret;

	hints = fi_allocinfo();
	cr_assert(hints, "fi_allocinfo");

	hints->domain_attr->data_progress = pm;

	hints->domain_attr->cq_data_size = 4;
	hints->mode = ~0;

	hints->fabric_attr->name = strdup("gni");

	ret = fi_getinfo(FI_VERSION(1, 0), NULL, 0, 0, hints, &fi);
	cr_assert(!ret, "fi_getinfo");

	ret = fi_fabric(fi->fabric_attr, &fab, NULL);
	cr_assert(!ret, "fi_fabric");

	ret = fi_domain(fab, fi, &dom, NULL);
	cr_assert(!ret, "fi_domain");

}
Ejemplo n.º 27
0
static void setup_dom(enum fi_progress pm)
{
	int ret;

	hints = fi_allocinfo();
	cr_assert(hints, "fi_allocinfo");

	hints->domain_attr->mr_mode = GNIX_DEFAULT_MR_MODE;
	hints->domain_attr->data_progress = pm;
	hints->domain_attr->cq_data_size = 4;
	hints->mode = mode_bits;

	hints->fabric_attr->prov_name = strdup("gni");

	ret = fi_getinfo(fi_version(), NULL, 0, 0, hints, &fi);
	cr_assert(!ret, "fi_getinfo");

	ret = fi_fabric(fi->fabric_attr, &fab, NULL);
	cr_assert(!ret, "fi_fabric");

	ret = fi_domain(fab, fi, &dom, NULL);
	cr_assert(!ret, "fi_domain");

}
Ejemplo n.º 28
0
int ft_open_fabric_res(void)
{
	int ret;

	ret = fi_fabric(fi->fabric_attr, &fabric, NULL);
	if (ret) {
		FT_PRINTERR("fi_fabric", ret);
		return ret;
	}

	ret = fi_eq_open(fabric, &eq_attr, &eq, NULL);
	if (ret) {
		FT_PRINTERR("fi_eq_open", ret);
		return ret;
	}

	ret = fi_domain(fabric, fi, &domain, NULL);
	if (ret) {
		FT_PRINTERR("fi_domain", ret);
		return ret;
	}

	return 0;
}
Ejemplo n.º 29
0
static void fas_ep_setup(void)
{
	int ret, i, j;
	size_t addrlen = 0;

	fas_setup_common(fi_version());
	ctx_cnt = MIN(ctx_cnt, fi[0]->domain_attr->rx_ctx_cnt);
	ctx_cnt = MIN(ctx_cnt, fi[0]->domain_attr->tx_ctx_cnt);

	for (i = 0; i < NUMEPS; i++) {
		fi[i]->ep_attr->tx_ctx_cnt = ctx_cnt;
		fi[i]->ep_attr->rx_ctx_cnt = ctx_cnt;

		ret = fi_domain(fab, fi[i], dom + i, NULL);
		cr_assert(!ret, "fi_domain returned: %s", fi_strerror(-ret));

		ret = fi_cntr_open(dom[i], &cntr_attr, send_cntr + i, 0);
		cr_assert(!ret, "fi_cntr_open returned: %s", fi_strerror(-ret));

		ret = fi_cntr_open(dom[i], &cntr_attr, recv_cntr + i, 0);
		cr_assert(!ret, "fi_cntr_open returned: %s", fi_strerror(-ret));

		switch (ep_type) {
		case EP:
			ret = fi_endpoint(dom[i], fi[i], ep + i, NULL);
			cr_assert(!ret, "fi_endpoint returned: %s",
				  fi_strerror(-ret));
			break;
		case SEP:
			ret = fi_scalable_ep(dom[i], fi[i], ep + i,
					     NULL);
			cr_assert(!ret, "fi_endpoint returned: %s",
				  fi_strerror(-ret));
			break;
		case PEP:
			ret = fi_passive_ep(fab, fi[i], pep + i,
					    NULL);
			cr_assert(!ret, "fi_endpoint returned: %s",
				  fi_strerror(-ret));
			ret = fi_getname(get_fid[ep_type](i), NULL,
					 &addrlen);
			if (use_str_fmt) {
				cr_assert(addrlen == GNIX_FI_ADDR_STR_LEN,
					  "fi_getname returned: %s",
					  fi_strerror(-ret));
			} else {
				cr_assert(addrlen ==
					  sizeof(struct gnix_ep_name),
					  "fi_getname returned: %s",
					  fi_strerror(-ret));
			}
			ep_name_len[i] = addrlen;
			continue;
		default:
			cr_assert_fail("Unknown endpoint type.");
		}

		ret = fi_av_open(dom[i], &attr, av + i, NULL);
		cr_assert(!ret, "fi_av_open returned: %s", fi_strerror(-ret));

		switch (ep_type) {
		case EP:
		case PEP:
			ret = fi_cq_open(dom[i], &cq_attr, msg_cq + i,
					 0);
			cr_assert(!ret, "fi_cq_open returned: %s",
				  fi_strerror(-ret));

			ret = fi_ep_bind(ep[i], &msg_cq[i]->fid,
					 FI_SEND | FI_RECV);
			cr_assert(!ret, "fi_ep_bind returned: %s",
				  fi_strerror(-ret));
			break;
		case SEP:
			dbg_printf(BLUE
					   "ctx_cnt = %d\n"
					   COLOR_RESET,
				   ctx_cnt);

			for (j = 0; j < ctx_cnt; j++) {
				ret = fi_tx_context(ep[i], j, NULL,
						    &tx_ep[i][j], NULL);
				cr_assert(!ret,
					  "fi_tx_context  returned: %s",
					  fi_strerror(-ret));

				ret = fi_cq_open(dom[i], &cq_attr,
						 &tx_cq[i][j],
						 NULL);
				cr_assert(!ret,
					  "fi_cq_open  returned: %s",
					  fi_strerror(-ret));

				ret = fi_rx_context(ep[i], j, NULL,
						    &rx_ep[i][j], NULL);
				cr_assert(!ret,
					  "fi_rx_context  returned: %s",
					  fi_strerror(-ret));

				ret = fi_cq_open(dom[i], &cq_attr,
						 &rx_cq[i][j],
						 NULL);
				cr_assert(!ret,
					  "fi_cq_open  returned: %s",
					  fi_strerror(-ret));
			}
			break;
		default:
			cr_assert_fail("Unknown endpoint type.");
		}

		ret = fi_getname(get_fid[ep_type](i), NULL, &addrlen);
		if (use_str_fmt) {
			cr_assert(addrlen > sizeof(struct gnix_ep_name),
				  "fi_getname returned: %s",
				  fi_strerror(-ret));
		} else {
			cr_assert(addrlen == sizeof(struct gnix_ep_name),
				  "fi_getname returned: %s",
				  fi_strerror(-ret));
		}

		ep_name[i] = malloc(addrlen);
		ep_name_len[i] = addrlen;

		dbg_printf(BLUE
				   "ep_name_len[%d] = %lu\n"
				   COLOR_RESET, i,
			   ep_name_len[i]);
		cr_assert(ep_name[i] != NULL, "malloc returned: %s",
			  strerror(errno));

		ret = fi_getname(get_fid[ep_type](i), ep_name[i], &addrlen);
		cr_assert(ret == FI_SUCCESS, "fi_getname returned: %s",
			  fi_strerror(-ret));
	}

	/* Just testing setname / getname for passive endpoints */
	if (ep_type == PEP)
		return;

	for (i = 0; i < NUMEPS; i++) {
		/*Insert all gni addresses into each av*/
		for (j = 0; j < NUMEPS; j++) {
			ret = fi_av_insert(av[i], ep_name[j], 1, &gni_addr[j],
					   0, NULL);
			cr_assert(ret == 1, "fi_av_insert returned: %s",
				  fi_strerror(-ret));
		}

		switch (ep_type) {
		case EP:
			ret = fi_ep_bind(ep[i], &av[i]->fid, 0);
			cr_assert(!ret, "fi_ep_bind returned: %s",
				  fi_strerror(-ret));

			ret = fi_ep_bind(ep[i], &send_cntr[i]->fid,
					 FI_SEND);
			cr_assert(!ret, "fi_ep_bind returned: %s",
				  fi_strerror(-ret));

			ret = fi_ep_bind(ep[i], &recv_cntr[i]->fid,
					 FI_RECV);
			cr_assert(!ret, "fi_ep_bind returned: %s",
				  fi_strerror(-ret));
			break;
		case SEP:
			ret = fi_scalable_ep_bind(ep[i], &av[i]->fid,
						  0);
			cr_assert(!ret,
				  "fi_scalable_ep_bind returned: %s",
				  fi_strerror(-ret));
			dbg_printf(BLUE
					   "ctx_cnt = %d\n"
					   COLOR_RESET,
				   ctx_cnt);
			for (j = 0; j < ctx_cnt; j++) {
				ret = fi_ep_bind(tx_ep[i][j],
						 &tx_cq[i][j]->fid,
						 FI_TRANSMIT);
				cr_assert(!ret,
					  "fi_ep_bind  returned: %s",
					  fi_strerror(-ret));

				ret = fi_ep_bind(tx_ep[i][j],
						 &send_cntr[i]->fid,
						 FI_SEND);
				cr_assert(!ret,
					  "fi_ep_bind  returned: %s",
					  fi_strerror(-ret));

				ret = fi_enable(tx_ep[i][j]);
				cr_assert(!ret,
					  "fi_enable  returned: %s",
					  fi_strerror(-ret));

				ret = fi_ep_bind(rx_ep[i][j],
						 &rx_cq[i][j]->fid,
						 FI_RECV);
				cr_assert(!ret,
					  "fi_ep_bind  returned: %s",
					  fi_strerror(-ret));

				ret = fi_ep_bind(rx_ep[i][j],
						 &recv_cntr[i]->fid,
						 FI_RECV);
				cr_assert(!ret,
					  "fi_ep_bind  returned: %s",
					  fi_strerror(-ret));

				ret = fi_enable(rx_ep[i][j]);
				cr_assert(!ret,
					  "fi_enable  returned: %s",
					  fi_strerror(-ret));

			}
			break;
		case PEP:
			break;
		default:
			cr_assert_fail("Unknown endpoint type.");
		}

		ret = fi_enable(ep[i]);
		cr_assert(!ret, "fi_ep_enable returned: %s", fi_strerror(-ret));

		if (ep_type != SEP) {
			ret = fi_enable(ep[i]);
			cr_assert_eq(ret, -FI_EOPBADSTATE,
				     "fi_enable returned: %s",
				     fi_strerror(-ret));
		}
	}
}
Ejemplo n.º 30
0
static int client_connect(void)
{
	struct fi_eq_cm_entry entry;
	uint32_t event;
	ssize_t rd;
	int ret;

	ret = fi_getinfo(FT_FIVERSION, opts.dst_addr, opts.dst_port, 0, hints, &fi);
	if (ret) {
		FT_PRINTERR("fi_getinfo", ret);
		return ret;
	}

	ret = fi_domain(fabric, fi, &domain, NULL);
	if (ret) {
		FT_PRINTERR("fi_domain", ret);
		return ret;
	}

	ret = check_address(&pep->fid, "fi_endpoint (pep)");
	if (ret)
		return ret;

	assert(fi->handle == &pep->fid);
	ret = ft_alloc_active_res(fi);
	if (ret)
		return ret;

	/* Close the passive endpoint that we "stole" the source address
	 * from */
	FT_CLOSE_FID(pep);

	ret = check_address(&ep->fid, "fi_endpoint (ep)");
	if (ret)
		return ret;

	ret = ft_init_ep();
	if (ret)
		return ret;

	/* Connect to server */
	ret = fi_connect(ep, fi->dest_addr, NULL, 0);
	if (ret) {
		FT_PRINTERR("fi_connect", ret);
		return ret;
	}

	/* Wait for the connection to be established */
	rd = fi_eq_sread(eq, &event, &entry, sizeof entry, -1, 0);
	if (rd != sizeof entry) {
		FT_PRINTERR("fi_eq_sread", rd);
		return (int) rd;
	}

	if (event != FI_CONNECTED || entry.fid != &ep->fid) {
		FT_ERR("Unexpected CM event %d fid %p (ep %p)\n", event, entry.fid, ep);
		return -FI_EOTHER;
	}

	ret = check_address(&ep->fid, "connect");
	if (ret) {
		return ret;
	}

	return 0;
}