Example #1
0
static bool usdf_fabric_checkname(uint32_t version,
				  struct usd_device_attrs *dap, const char *hint)
{
	int ret;
	bool valid = false;
	char *reference;

	USDF_DBG("checking devname: version=%d, devname='%s'\n", version, hint);

	if (version) {
		ret = usdf_fabric_getname(version, dap, &reference);
		if (ret < 0)
			return false;

		if (strcmp(reference, hint) == 0) {
			valid = true;
		} else {
			USDF_DBG("hint %s failed to match %s\n", hint,
				 reference);
		}

		free(reference);
		return valid;
	}

	/* The hint string itself is kind of a version check, in pre-1.4 the
	* name was just the device name. In 1.4 and beyond, then name is
	* actually CIDR
	* notation.
	*/
	if (strstr(hint, "/"))
		return usdf_fabric_checkname(FI_VERSION(1, 4), dap, hint);

	return usdf_fabric_checkname(FI_VERSION(1, 3), dap, hint);
}
Example #2
0
Test(endpoint_info, info)
{
	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");
	cr_assert_eq(fi->ep_attr->type, FI_EP_RDM);
	cr_assert_eq(fi->next->ep_attr->type, FI_EP_DGRAM);
	cr_assert_eq(fi->next->next->ep_attr->type, FI_EP_MSG);

	fi_freeinfo(fi);

	hints->ep_attr->type = FI_EP_RDM;
	ret = fi_getinfo(FI_VERSION(1, 0), NULL, 0, 0, hints, &fi);
	cr_assert(!ret, "fi_getinfo");
	cr_assert_eq(fi->ep_attr->type, FI_EP_RDM);

	fi_freeinfo(fi);

	hints->ep_attr->type = FI_EP_DGRAM;
	ret = fi_getinfo(FI_VERSION(1, 0), NULL, 0, 0, hints, &fi);
	cr_assert(!ret, "fi_getinfo");
	cr_assert_eq(fi->ep_attr->type, FI_EP_DGRAM);

	fi_freeinfo(fi);
	fi_freeinfo(hints);
}
Example #3
0
/*
 * Note: the default addr_format is FI_ADDR_STR unless use_str_fmt is otherwise
 * set to false.
 */
void do_invalid_fi_getinfo(void)
{
	int i, ret;

	for (i = 0; i < NUMEPS; i++) {
		/*
		 * This test is to ensure that gni provider fails to provide
		 * info if the FI_ADDR_STR format is being used and both the
		 * node and service parameters are non-NULL.
		 *
		 * See the fi_getinfo man page DESCRIPTION section.
		 */
		ret = fi_getinfo(FI_VERSION(1, 5), "this is a test", "testing",
				 0, hints, &fi[i]);
		cr_assert(ret == -FI_ENODATA, "fi_getinfo returned: %s",
			  fi_strerror(-ret));

		fi_freeinfo(fi[i]);

		/*
		 * This test is to ensure that the gni provider does not allow
		 * FI_ADDR_STR to be used with api versions <= 1.5.
		 */
		ret = fi_getinfo(FI_VERSION(1, 0), NULL, NULL, 0, hints,
				 &fi[i]);
		cr_assert(ret == -FI_ENODATA, "fi_getinfo returned: %s",
			  fi_strerror(-ret));

		fi_freeinfo(fi[i]);
	}
}
Example #4
0
/* In pre-1.4 the domain name was NULL. This is unfortunate as it makes it
 * difficult to tell whether providing a name was intended. In this case, it can
 * be broken into 4 cases:
 *
 * 1. Version is greater than or equal to 1.4 and a non-NULL hint is provided.
 *    Just do a string compare.
 * 2. Version is greater than or equal to 1.4 and provided hint is NULL.  Treat
 *    this as _valid_ as it could be an application requesting a 1.4 domain name
 *    but not providing an explicit hint.
 * 3. Version is less than 1.4 and a name hint is provided.  This should always
 *    be _invalid_.
 * 4. Version is less than 1.4 and name hint is NULL. This will always be
 *    _valid_.
 */
bool usdf_domain_checkname(uint32_t version, struct usd_device_attrs *dap,
			   const char *hint)
{
	char *reference;
	bool valid;
	int ret;

	USDF_DBG("checking domain name: version=%d, domain name='%s'\n",
		 version, hint);

	if (version) {
		valid = false;

		ret = usdf_domain_getname(version, dap, &reference);
		if (ret < 0)
			return false;

		/* If the reference name exists, then this is version 1.4 or
		 * greater.
		 */
		if (reference) {
			if (hint) {
				/* Case 1 */
				valid = (strcmp(reference, hint) == 0);
			} else {
				/* Case 2 */
				valid = true;
			}
		} else {
			/* Case 3 & 4 */
			valid = (hint == NULL);
		}

		if (!valid)
			USDF_DBG("given hint %s does not match %s -- invalid\n",
				 hint, reference);

		free(reference);
		return valid;
	}

	/* If hint is non-NULL then assume the version is 1.4 if not provided.
	 */
	if (hint)
		return usdf_domain_checkname(FI_VERSION(1, 4), dap, hint);

	return usdf_domain_checkname(FI_VERSION(1, 3), dap, hint);
}
Example #5
0
static uint64_t ofi_get_info_caps(const struct fi_info *prov_info,
				  const struct fi_info *user_info,
				  uint32_t api_version)
{
	int prov_mode, user_mode;
	uint64_t caps;

	assert(user_info);

	caps = ofi_get_caps(prov_info->caps, user_info->caps, prov_info->caps);

	prov_mode = prov_info->domain_attr->mr_mode;

	if (!ofi_rma_target_allowed(caps) ||
	    !(prov_mode & OFI_MR_MODE_RMA_TARGET))
		return caps;

	if (!user_info->domain_attr)
		goto trim_caps;

	user_mode = user_info->domain_attr->mr_mode;

	if ((FI_VERSION_LT(api_version, FI_VERSION(1,5)) &&
	    (user_mode == FI_MR_UNSPEC)) ||
	    (user_mode == FI_MR_BASIC) ||
	    ((user_mode & prov_mode & OFI_MR_MODE_RMA_TARGET) == 
	     (prov_mode & OFI_MR_MODE_RMA_TARGET)))
		return caps;

trim_caps:
	return caps & ~(FI_REMOTE_WRITE | FI_REMOTE_READ);
}
Example #6
0
/*
 * Alter the returned fi_info based on the user hints.  We assume that
 * the hints have been validated and the starting fi_info is properly
 * configured by the provider.
 */
void ofi_alter_info(struct fi_info *info, const struct fi_info *hints,
		    uint32_t api_version)
{
	if (!hints)
		return;

	for (; info; info = info->next) {
		/* This should stay before call to fi_alter_domain_attr as
		 * the checks depend on unmodified provider mr_mode attr */
		info->caps = ofi_get_info_caps(info, hints, api_version);

		if ((info->domain_attr->mr_mode & FI_MR_LOCAL) &&
		    (FI_VERSION_LT(api_version, FI_VERSION(1, 5)) ||
		     (hints && hints->domain_attr &&
		      (hints->domain_attr->mr_mode & (FI_MR_BASIC | FI_MR_SCALABLE)))))
			info->mode |= FI_LOCAL_MR;

		info->handle = hints->handle;

		fi_alter_domain_attr(info->domain_attr, hints->domain_attr,
				     info->caps, api_version);
		fi_alter_ep_attr(info->ep_attr, hints->ep_attr, info->caps);
		fi_alter_rx_attr(info->rx_attr, hints->rx_attr, info->caps);
		fi_alter_tx_attr(info->tx_attr, hints->tx_attr, info->caps);
	}
}
Example #7
0
static void fi_alter_domain_attr(struct fi_domain_attr *attr,
				 const struct fi_domain_attr *hints,
				 uint64_t info_caps, uint32_t api_version)
{
	int hints_mr_mode;

	hints_mr_mode = hints ? hints->mr_mode : 0;
	if (hints_mr_mode & (FI_MR_BASIC | FI_MR_SCALABLE)) {
		attr->mr_mode = hints_mr_mode;
	} else if (FI_VERSION_LT(api_version, FI_VERSION(1, 5))) {
		attr->mr_mode = (attr->mr_mode && attr->mr_mode != FI_MR_SCALABLE) ?
				FI_MR_BASIC : FI_MR_SCALABLE;
	} else {
		if ((hints_mr_mode & attr->mr_mode) != attr->mr_mode) {
			attr->mr_mode = ofi_cap_mr_mode(info_caps,
						attr->mr_mode & hints_mr_mode);
		}
	}

	attr->caps = ofi_get_caps(info_caps, hints ? hints->caps : 0, attr->caps);
	if (!hints)
		return;

	if (hints->threading)
		attr->threading = hints->threading;
	if (hints->control_progress)
		attr->control_progress = hints->control_progress;
	if (hints->data_progress)
		attr->data_progress = hints->data_progress;
	if (hints->av_type)
		attr->av_type = hints->av_type;
}
Example #8
0
static int run(struct fi_info *hints, char *node, char *port)
{
	struct fi_info *info;
	int ret;
	uint64_t flags;

	flags = list_providers ? FI_PROV_ATTR_ONLY : 0;
	ret = fi_getinfo(FI_VERSION(FI_MAJOR_VERSION, FI_MINOR_VERSION),
			node, port, flags, hints, &info);
	if (ret) {
		fprintf(stderr, "fi_getinfo: %d\n", ret);
		return ret;
	}

	if (env)
		ret = print_vars();
	else if (verbose)
		ret = print_long_info(info);
	else if (list_providers)
		ret = print_providers(info);
	else
		ret = print_short_info(info);

	fi_freeinfo(info);
	return ret;
}
Example #9
0
static int usdf_fabric_getname(uint32_t version, struct usd_device_attrs *dap,
			       char **name)
{
	int ret = FI_SUCCESS;
	char *bufp = NULL;
	struct in_addr in;
	char *addrnetw;

	if (FI_VERSION_GE(version, FI_VERSION(1, 4))) {
		in.s_addr = dap->uda_ipaddr_be & dap->uda_netmask_be;
		addrnetw = inet_ntoa(in);
		ret = asprintf(&bufp, "%s/%d", addrnetw, dap->uda_prefixlen);
		if (ret < 0) {
			USDF_DBG(
			    "asprintf failed while creating fabric name\n");
			ret = -ENOMEM;
		}
	} else {
		bufp = strdup(dap->uda_devname);
		if (!bufp) {
			USDF_DBG("strdup failed while creating fabric name\n");
			ret = -errno;
		}
	}

	*name = bufp;

	return ret;
}
Example #10
0
/* A wrapper function to core utility function to check mr_mode bits.
 * We need to check some more things for backward compatibility.
 */
int usdf_check_mr_mode(uint32_t version, const struct fi_info *hints,
		       uint64_t prov_mode)
{
	int ret;

	ret = ofi_check_mr_mode(version, prov_mode,
				hints->domain_attr->mr_mode);

	/* If ofi_check_mr_mode fails. */
	if (ret) {
		/* Is it because the user give 0 as mr_mode? */
		if (hints->domain_attr->mr_mode == 0) {
			if (FI_VERSION_LT(version, FI_VERSION(1, 5))) {
				/* If the version is < 1.5, it is ok.
				 * We let this slide and catch it later on.
				 */
				return FI_SUCCESS;
			} else if (hints->mode & FI_LOCAL_MR) {
				/* If version is >= 1.5, we check fi_info mode
				 * for FI_LOCAL_MR for backward compatibility.
				 */
				return FI_SUCCESS;
			}
		}
	}

	return ret;
}
Example #11
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");
}
Example #12
0
/* Catch the version changes for domain_attr. */
int usdf_catch_dom_attr(uint32_t version, const struct fi_info *hints,
			struct fi_domain_attr *dom_attr)
{
	/* version 1.5 introduced new bits. If the user asked for older
	 * version, we can't return these new bits.
	 */
	if (FI_VERSION_LT(version, FI_VERSION(1, 5))) {
		/* We checked mr_mode compatibility before calling
		 * this function. This means it is safe to return
		 * 1.4 default mr_mode.
		 */
		dom_attr->mr_mode = FI_MR_BASIC;

		/* FI_REMOTE_COMM is introduced in 1.5. So don't return it. */
		dom_attr->caps &= ~FI_REMOTE_COMM;

		/* If FI_REMOTE_COMM is given for version < 1.5, fail. */
		if (hints && hints->domain_attr) {
			if (hints->domain_attr->caps == FI_REMOTE_COMM)
				return -FI_EBADFLAGS;
		}
	}

	return FI_SUCCESS;
}
Example #13
0
void rdm_sr_bnd_ep_setup(void)
{
	int ret = 0, i = 0;
	char my_hostname[HOST_NAME_MAX];

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

	hints->domain_attr->cq_data_size = NUMEPS * 2;
	hints->mode = ~0;
	hints->fabric_attr->name = strdup("gni");

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

	for (; i < NUMEPS; i++) {
		ret = fi_getinfo(FI_VERSION(1, 0), my_hostname,
				 cdm_id[i], 0, hints, fi + i);
		cr_assert(!ret, "fi_getinfo");
	}

	using_bnd_ep = 1;

	rdm_sr_setup_common();
}
Example #14
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");
	}
}
Example #15
0
void ofi_eq_handle_err_entry(uint32_t api_version,
			     struct fi_eq_err_entry *err_entry,
			     struct fi_eq_err_entry *user_err_entry)
{
	if ((FI_VERSION_GE(api_version, FI_VERSION(1, 5)))
	    && user_err_entry->err_data && user_err_entry->err_data_size) {
		void *err_data = user_err_entry->err_data;
		size_t err_data_size = MIN(err_entry->err_data_size,
					   user_err_entry->err_data_size);

		memcpy(err_data, err_entry->err_data, err_data_size);

		*user_err_entry = *err_entry;
		user_err_entry->err_data = err_data;
		user_err_entry->err_data_size = err_data_size;

		free(err_entry->err_data);
		err_entry->err_data = NULL;
		err_entry->err_data_size = 0;
	} else {
		*user_err_entry = *err_entry;
	}

	err_entry->err = 0;
	err_entry->prov_errno = 0;
}
Example #16
0
static ssize_t
fi_ibv_eq_readerr(struct fid_eq *eq, struct fi_eq_err_entry *entry,
		  uint64_t flags)
{
	struct fi_ibv_eq *_eq;
	uint32_t api_version;
	void *err_data = NULL;
	size_t err_data_size = 0;

	_eq = container_of(eq, struct fi_ibv_eq, eq_fid.fid);
	if (!_eq->err.err)
		return 0;

	
	api_version = _eq->fab->util_fabric.fabric_fid.api_version;

	if ((FI_VERSION_GE(api_version, FI_VERSION(1, 5)))
		&& entry->err_data && entry->err_data_size) {
		err_data_size = MIN(entry->err_data_size, _eq->err.err_data_size);
		err_data = _eq->err.err_data;
	}

	*entry = _eq->err;
	if (err_data) {
		memcpy(entry->err_data, err_data, err_data_size);
		entry->err_data_size = err_data_size;
	}

	_eq->err.err = 0;
	_eq->err.prov_errno = 0;
	return sizeof(*entry);
}
Example #17
0
void rdm_sr_setup(bool is_noreg, enum fi_progress pm)
{
	int ret = 0, i = 0;

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

	hints->domain_attr->cq_data_size = NUMEPS * 2;
	hints->domain_attr->control_progress = pm;
	hints->domain_attr->data_progress = pm;
	hints->mode = ~0;
	hints->caps = is_noreg ? hints->caps : FI_SOURCE | FI_MSG;
	hints->fabric_attr->name = strdup("gni");

	/* Get info about fabric services with the provided hints */
	for (; i < NUMEPS; i++) {
		ret = fi_getinfo(FI_VERSION(1, 0), NULL, 0, 0, hints, &fi[i]);
		cr_assert(!ret, "fi_getinfo");
	}

	if (is_noreg)
		rdm_sr_setup_common_eps();
	else
		rdm_sr_setup_common();
}
Example #18
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");
}
Example #19
0
/* Catch the version changes for rx_attr. */
int usdf_catch_rx_attr(uint32_t version, const struct fi_rx_attr *rx_attr)
{
	/* In version < 1.5, FI_LOCAL_MR is required. */
	if (FI_VERSION_LT(version, FI_VERSION(1, 5))) {
		if ((rx_attr->mode & FI_LOCAL_MR) == 0)
			return -FI_ENODATA;
	}

	return FI_SUCCESS;
}
Example #20
0
int rxm_info_to_core(uint32_t version, struct fi_info *hints,
		     struct fi_info *core_info)
{
	core_info->caps = FI_MSG;

	/* Support modes that ofi_rxm could handle */
	if (FI_VERSION_GE(version, FI_VERSION(1, 5)))
		core_info->domain_attr->mr_mode |= FI_MR_LOCAL;
	else
		core_info->mode |= (FI_LOCAL_MR | FI_RX_CQ_DATA);

	if (hints) {
		/* No fi_info modes apart from FI_LOCAL_MR, FI_RX_CQ_DATA
		 * can be passed along to the core provider */
		// core_info->mode |= hints->mode;
		if (hints->domain_attr) {
			if (FI_VERSION_GE(version, FI_VERSION(1, 5))) {
				/* Allow only those mr modes that can be
				 * passed along to the core provider */
				core_info->domain_attr->mr_mode |=
					hints->domain_attr->mr_mode &
					OFI_MR_BASIC_MAP;
			} else {
				core_info->domain_attr->mr_mode =
					hints->domain_attr->mr_mode;
			}
			core_info->domain_attr->caps |= hints->domain_attr->caps;
		}
	} else {
		/* Since hints is NULL fake support for FI_MR_BASIC to allow
		 * discovery of core providers like verbs which require it */
		if (FI_VERSION_GE(version, FI_VERSION(1, 5)))
			core_info->domain_attr->mr_mode |= OFI_MR_BASIC_MAP;
		else
			/* Specify FI_MR_UNSPEC so that providers that support
			 * FI_MR_SCALABLE aren't dropped */
			core_info->domain_attr->mr_mode = FI_MR_UNSPEC;
	}
	core_info->ep_attr->rx_ctx_cnt = FI_SHARED_CONTEXT;
	core_info->ep_attr->type = FI_EP_MSG;

	return 0;
}
Example #21
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;
}
Example #22
0
static int server_listen(void)
{
	struct fi_info *fi;
	int ret;

	ret = fi_getinfo(FI_VERSION(1, 0), src_addr, port, FI_SOURCE, &hints, &fi);
	if (ret) {
		printf("fi_getinfo %s\n", strerror(-ret));
		return ret;
	}

	cq_data_size = fi->domain_attr->cq_data_size;

	ret = fi_fabric(fi->fabric_attr, &fab, NULL);
	if (ret) {
		printf("fi_fabric %s\n", fi_strerror(-ret));
		goto err0;
	}

	ret = fi_passive_ep(fab, fi, &pep, NULL);
	if (ret) {
		printf("fi_passive_ep %s\n", fi_strerror(-ret));
		goto err1;
	}

	ret = alloc_cm_res();
	if (ret)
		goto err2;

	ret = fi_bind(&pep->fid, &cmeq->fid, 0);
	if (ret) {
		printf("fi_bind %s\n", fi_strerror(-ret));
		goto err3;
	}

	ret = fi_listen(pep);
	if (ret) {
		printf("fi_listen %s\n", fi_strerror(-ret));
		goto err3;
	}

	fi_freeinfo(fi);
	return 0;
err3:
	free_lres();
err2:
	fi_close(&pep->fid);
err1:
	fi_close(&fab->fid);
err0:
	fi_freeinfo(fi);
	return ret;
}
Example #23
0
static int rxm_getinfo(uint32_t version, const char *node, const char *service,
			uint64_t flags, struct fi_info *hints, struct fi_info **info)
{
	struct fi_info *cur, *dup;
	int ret;

	ret = ofix_getinfo(version, node, service, flags, &rxm_util_prov, hints,
			   rxm_info_to_core, rxm_info_to_rxm, info);
	if (ret)
		return ret;

	/* If app supports FI_MR_LOCAL, prioritize requiring it for
	 * better performance. */
	if (hints && hints->domain_attr &&
	    (RXM_MR_LOCAL(hints))) {
		for (cur = *info; cur; cur = cur->next) {
			if (!RXM_MR_LOCAL(cur))
				continue;
			if (!(dup = fi_dupinfo(cur))) {
				fi_freeinfo(*info);
				return -FI_ENOMEM;
			}
			if (FI_VERSION_LT(version, FI_VERSION(1, 5)))
				dup->mode &= ~FI_LOCAL_MR;
			else
				dup->domain_attr->mr_mode &= ~FI_MR_LOCAL;
			dup->next = cur->next;
			cur->next = dup;
			cur = dup;
		}
	} else {
		for (cur = *info; cur; cur = cur->next) {
			if (FI_VERSION_LT(version, FI_VERSION(1, 5)))
				cur->mode &= ~FI_LOCAL_MR;
			else
				cur->domain_attr->mr_mode &= ~FI_MR_LOCAL;
		}
	}
	return 0;
}
Example #24
0
/*
 * Providers should set v1.0 registration modes (FI_MR_BASIC and
 * FI_MR_SCALABLE) that they support, along with all required modes.
 */
int ofi_check_mr_mode(const struct fi_provider *prov, uint32_t api_version,
		      int prov_mode, const struct fi_info *user_info)
{
	int user_mode = user_info->domain_attr->mr_mode;
	int ret = -FI_ENODATA;

	if ((prov_mode & FI_MR_LOCAL) &&
	    !((user_info->mode & FI_LOCAL_MR) || (user_mode & FI_MR_LOCAL)))
		goto out;

	if (FI_VERSION_LT(api_version, FI_VERSION(1, 5))) {
		switch (user_mode) {
		case FI_MR_UNSPEC:
			if (!(prov_mode & (FI_MR_SCALABLE | FI_MR_BASIC)))
				goto out;
			break;
		case FI_MR_BASIC:
			if (!(prov_mode & FI_MR_BASIC))
				goto out;
			break;
		case FI_MR_SCALABLE:
			if (!(prov_mode & FI_MR_SCALABLE))
				goto out;
			break;
		default:
			goto out;
		}
	} else {
		if (user_mode & FI_MR_BASIC) {
			if ((user_mode & ~FI_MR_BASIC) ||
			    !(prov_mode & FI_MR_BASIC))
				goto out;
		} else if (user_mode & FI_MR_SCALABLE) {
			if ((user_mode & ~FI_MR_SCALABLE) ||
			    !(prov_mode & FI_MR_SCALABLE))
				goto out;
		} else {
			prov_mode = ofi_cap_mr_mode(user_info->caps, prov_mode);
			if ((user_mode & prov_mode) != prov_mode)
				goto out;
		}
	}

	ret = 0;
out:
	if (ret) {
		FI_INFO(prov, FI_LOG_CORE, "Invalid memory registration mode\n");
		FI_INFO_MR_MODE(prov, prov_mode, user_mode);
	}

	return ret;
}
Example #25
0
int sock_verify_fabric_attr(struct fi_fabric_attr *attr)
{
	if (!attr)
		return 0;

	if (attr->prov_version) {
		if (attr->prov_version !=
		   FI_VERSION(SOCK_MAJOR_VERSION, SOCK_MINOR_VERSION))
			return -FI_ENODATA;
	}

	return 0;
}
Example #26
0
static int server_listen(void)
{
	struct fi_info *fi;
	int ret;

	ret = fi_getinfo(FI_VERSION(1, 0), src_addr, port, 0, &hints, &fi);
	if (ret) {
		printf("fi_getinfo %s\n", strerror(-ret));
		return ret;
	}

	ret = fi_fabric(fi->fabric_attr, &fab, NULL);
	if (ret) {
		printf("fi_fabric %s\n", fi_strerror(-ret));
		goto err0;
	}

	ret = fi_pendpoint(fab, fi, &pep, NULL);
	if (ret) {
		printf("fi_endpoint %s\n", fi_strerror(-ret));
		goto err1;
	}

	ret = alloc_cm_res();
	if (ret)
		goto err2;

	ret = bind_fid(&pep->fid, &cmeq->fid, 0);
	if (ret)
		goto err3;

	ret = fi_listen(pep);
	if (ret) {
		printf("fi_listen %s\n", fi_strerror(-ret));
		goto err3;
	}

	fi_freeinfo(fi);
	return 0;
err3:
	free_lres();
err2:
	fi_close(&pep->fid);
err1:
	fi_close(&fab->fid);
err0:
	fi_freeinfo(fi);
	return ret;
}
Example #27
0
void _setup(void)
{
	int ret = 0;

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

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

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

	ret = fi_fabric(fi->fabric_attr, &fab, NULL);
	cr_assert_eq(ret, FI_SUCCESS, "fi_fabric failed.");
}
Example #28
0
static ssize_t
fi_ibv_cq_readerr(struct fid_cq *cq_fid, struct fi_cq_err_entry *entry,
		  uint64_t flags)
{
	struct fi_ibv_cq *cq;
	struct fi_ibv_wce *wce;
	struct slist_entry *slist_entry;
	uint32_t api_version;

	cq = container_of(cq_fid, struct fi_ibv_cq, util_cq.cq_fid);

	cq->util_cq.cq_fastlock_acquire(&cq->util_cq.cq_lock);
	if (slist_empty(&cq->wcq))
		goto err;

	wce = container_of(cq->wcq.head, struct fi_ibv_wce, entry);
	if (!wce->wc.status)
		goto err;

	api_version = cq->util_cq.domain->fabric->fabric_fid.api_version;

	slist_entry = slist_remove_head(&cq->wcq);
	cq->util_cq.cq_fastlock_release(&cq->util_cq.cq_lock);

	wce = container_of(slist_entry, struct fi_ibv_wce, entry);

	entry->op_context = (void *)(uintptr_t)wce->wc.wr_id;
	entry->err = EIO;
	entry->prov_errno = wce->wc.status;
	fi_ibv_handle_wc(&wce->wc, &entry->flags, &entry->len, &entry->data);

	if ((FI_VERSION_GE(api_version, FI_VERSION(1, 5))) &&
		entry->err_data && entry->err_data_size) {
		entry->err_data_size = MIN(entry->err_data_size,
			sizeof(wce->wc.vendor_err));
		memcpy(entry->err_data, &wce->wc.vendor_err, entry->err_data_size);
	} else {
		memcpy(&entry->err_data, &wce->wc.vendor_err,
			sizeof(wce->wc.vendor_err));
	}

	util_buf_release(cq->wce_pool, wce);
	return 1;
err:
	cq->util_cq.cq_fastlock_release(&cq->util_cq.cq_lock);
	return -FI_EAGAIN;
}
Example #29
0
int fi_fabric_1_0(struct fi_fabric_attr_1_0 *attr_1_0,
		  struct fid_fabric **fabric, void *context)
{
	struct fi_fabric_attr attr;

	if (!attr_1_0)
		return -FI_EINVAL;

	memcpy(&attr, attr_1_0, sizeof(*attr_1_0));

	/* Since the API version is not available in ABI 1.0, set the field to
	 * FI_VERSION(1, 0) for compatibility. The actual API version could be
	 * anywhere from FI_VERSION(1, 0) to FI_VERSION(1, 4).
	 */
	attr.api_version = FI_VERSION(1, 0);
	return fi_fabric(&attr, fabric, context);
}
Example #30
0
int usdf_domain_getname(uint32_t version, struct usd_device_attrs *dap,
			char **name)
{
	int ret = FI_SUCCESS;
	char *buf = NULL;

	if (FI_VERSION_GE(version, FI_VERSION(1, 4))) {
		buf = strdup(dap->uda_devname);
		if (!buf) {
			ret = -errno;
			USDF_DBG("strdup failed while creating domain name\n");
		}
	}

	*name = buf;
	return ret;
}