示例#1
0
static int
usdf_fill_info_rdm(
	struct fi_info *hints,
	struct sockaddr_in *src,
	struct sockaddr_in *dest,
	struct usd_device_attrs *dap,
	struct fi_info **fi_first,
	struct fi_info **fi_last)
{
	struct fi_info *fi;
	struct fi_fabric_attr *fattrp;
	uint32_t addr_format;
	int ret;

	fi = fi_allocinfo();
	if (fi == NULL) {
		ret = -FI_ENOMEM;
		goto fail;
	}

	fi->caps = USDF_RDM_CAPS;

	if (hints != NULL) {
		fi->mode = hints->mode & USDF_RDM_SUPP_MODE;
		addr_format = hints->addr_format;
		/* check that we are capable of what's requested */
		if ((hints->caps & ~USDF_RDM_CAPS) != 0) {
			ret = -FI_ENODATA;
			goto fail;
		}

		/* app must support these modes */
		if ((hints->mode & USDF_RDM_REQ_MODE) != USDF_RDM_REQ_MODE) {
			ret = -FI_ENODATA;
			goto fail;
		}

		fi->handle = hints->handle;
	} else {
		fi->mode = USDF_RDM_SUPP_MODE;
		addr_format = FI_FORMAT_UNSPEC;
	}
	fi->ep_attr->type = FI_EP_RDM;

	ret = usdf_fill_addr_info(fi, addr_format, src, dest, dap);
	if (ret != 0) {
		goto fail;
	}

	/* fabric attrs */
	fattrp = fi->fabric_attr;
	fattrp->name = strdup(dap->uda_devname);
	if (fattrp->name == NULL) {
		ret = -FI_ENOMEM;
		goto fail;
	}

	ret = usdf_rdm_fill_ep_attr(hints, fi, dap);
	if (ret)
		goto fail;

	ret = usdf_rdm_fill_dom_attr(hints, fi);
	if (ret)
		goto fail;

	ret = usdf_rdm_fill_tx_attr(hints, fi);
	if (ret)
		goto fail;

	ret = usdf_rdm_fill_rx_attr(hints, fi);
	if (ret)
		goto fail;

	/* add to tail of list */
	if (*fi_first == NULL) {
		*fi_first = fi;
	} else {
		(*fi_last)->next = fi;
	}
	*fi_last = fi;

	return 0;

fail:
	if (fi != NULL) {
		fi_freeinfo(fi);
	}
	return ret;
}
示例#2
0
static int
usdf_fill_info_rdm(
	struct fi_info *hints,
	struct sockaddr_in *src,
	struct sockaddr_in *dest,
	struct usd_device_attrs *dap,
	struct fi_info **fi_first,
	struct fi_info **fi_last)
{
	struct fi_info *fi;
	struct fi_fabric_attr *fattrp;
	struct fi_domain_attr *dattrp;
	struct fi_tx_attr *txattr;
	struct fi_rx_attr *rxattr;
	struct fi_ep_attr *eattrp;
	uint32_t addr_format;
	int ret;

	fi = fi_allocinfo();
	if (fi == NULL) {
		ret = -FI_ENOMEM;
		goto fail;
	}

	fi->caps = USDF_RDM_CAPS;

	if (hints != NULL) {
		fi->mode = hints->mode & USDF_RDM_SUPP_MODE;
		addr_format = hints->addr_format;
		/* check that we are capable of what's requested */
		if ((hints->caps & ~USDF_RDM_CAPS) != 0) {
			ret = -FI_ENODATA;
			goto fail;
		}

		/* app must support these modes */
		if ((hints->mode & USDF_RDM_REQ_MODE) != USDF_RDM_REQ_MODE) {
			ret = -FI_ENODATA;
			goto fail;
		}
	} else {
		fi->mode = USDF_RDM_SUPP_MODE;
		addr_format = FI_FORMAT_UNSPEC;
	}
	fi->ep_attr->type = FI_EP_RDM;

	ret = usdf_fill_addr_info(fi, addr_format, src, dest, dap);
	if (ret != 0) {
		goto fail;
	}

	/* fabric attrs */
	fattrp = fi->fabric_attr;
	fattrp->name = strdup(dap->uda_devname);
	if (fattrp->name == NULL) {
		ret = -FI_ENOMEM;
		goto fail;
	}

	/* TX attrs */
	txattr = fi->tx_attr;
	if (hints != NULL && hints->tx_attr != NULL) {
		*txattr = *hints->tx_attr;
	}
	usdf_rdm_fill_tx_attr(txattr);

	/* RX attrs */
	rxattr = fi->rx_attr;
	if (hints != NULL && hints->rx_attr != NULL) {
		*rxattr = *hints->rx_attr;
	}
	usdf_rdm_fill_rx_attr(rxattr);

	/* endpoint attrs */
	eattrp = fi->ep_attr;
	eattrp->max_msg_size = USDF_RDM_MAX_MSG;
	eattrp->protocol = FI_PROTO_RUDP;
	eattrp->tx_ctx_cnt = 1;
	eattrp->rx_ctx_cnt = 1;

	/* domain attrs */
	dattrp = fi->domain_attr;
	dattrp->threading = FI_THREAD_UNSPEC;
	dattrp->control_progress = FI_PROGRESS_AUTO;
	dattrp->data_progress = FI_PROGRESS_MANUAL;

	/* add to tail of list */
	if (*fi_first == NULL) {
		*fi_first = fi;
	} else {
		(*fi_last)->next = fi;
	}
	*fi_last = fi;

	return 0;

fail:
	if (fi != NULL) {
		fi_freeinfo(fi);
	}
	return ret;
}
示例#3
0
static int usdf_fill_info_rdm(
	uint32_t version,
	const struct fi_info *hints,
	void *src,
	void *dest,
	struct usd_device_attrs *dap,
	struct fi_info **fi_first,
	struct fi_info **fi_last)
{
	struct fi_info *fi;
	struct fi_fabric_attr *fattrp;
	uint32_t addr_format;
	int ret;

	fi = fi_allocinfo();
	if (fi == NULL) {
		ret = -FI_ENOMEM;
		goto fail;
	}

	fi->caps = USDF_RDM_CAPS;

	ret = validate_modebits(version, hints,
				  USDF_RDM_SUPP_MODE, &fi->mode);
	if (ret)
		goto fail;

	if (hints != NULL) {
		addr_format = hints->addr_format;
		/* check that we are capable of what's requested */
		if ((hints->caps & ~USDF_RDM_CAPS) != 0) {
			ret = -FI_ENODATA;
			goto fail;
		}

		fi->handle = hints->handle;
	} else {
		addr_format = FI_FORMAT_UNSPEC;
	}
	fi->ep_attr->type = FI_EP_RDM;

	ret = usdf_fill_addr_info(fi, addr_format, src, dest, dap);
	if (ret != 0) {
		goto fail;
	}

	/* fabric attrs */
	fattrp = fi->fabric_attr;
	ret = usdf_fabric_getname(version, dap, &fattrp->name);
	if (ret < 0 || fattrp->name == NULL) {
		ret = -FI_ENOMEM;
		goto fail;
	}

	ret = usdf_rdm_fill_ep_attr(hints, fi, dap);
	if (ret)
		goto fail;

	ret = usdf_rdm_fill_dom_attr(version, hints, fi, dap);
	if (ret)
		goto fail;

	ret = usdf_rdm_fill_tx_attr(version, hints, fi);
	if (ret)
		goto fail;

	ret = usdf_rdm_fill_rx_attr(version, hints, fi);
	if (ret)
		goto fail;

	ret = usdf_alloc_fid_nic(fi, dap);
	if (ret)
		goto fail;

	/* add to tail of list */
	if (*fi_first == NULL) {
		*fi_first = fi;
	} else {
		(*fi_last)->next = fi;
	}
	*fi_last = fi;

	return 0;

fail:
	if (fi != NULL) {
		fi_freeinfo(fi);
	}
	return ret;
}
示例#4
0
static int
usdf_fill_info_dgram(
	struct fi_info *hints,
	struct sockaddr_in *src,
	struct sockaddr_in *dest,
	struct usd_device_attrs *dap,
	struct fi_info **fi_first,
	struct fi_info **fi_last)
{
	struct fi_info *fi;
	struct fi_fabric_attr *fattrp;
	struct fi_domain_attr *dattrp;
	struct fi_tx_attr *txattr;
	struct fi_rx_attr *rxattr;
	struct fi_ep_attr *eattrp;
	uint32_t addr_format;
	size_t entries;
	int ret;

	fi = fi_allocinfo();
	if (fi == NULL) {
		ret = -FI_ENOMEM;
		goto fail;
	}

	fi->caps = USDF_DGRAM_CAPS;

	if (hints != NULL) {
		fi->mode = hints->mode & USDF_DGRAM_SUPP_MODE;
		addr_format = hints->addr_format;

		/* check that we are capable of what's requested */
		if ((hints->caps & ~USDF_DGRAM_CAPS) != 0) {
			ret = -FI_ENODATA;
			goto fail;
		}

		/* app must support these modes */
		if ((hints->mode & USDF_DGRAM_REQ_MODE) != USDF_DGRAM_REQ_MODE) {
			ret = -FI_ENODATA;
			goto fail;
		}
	} else {
		fi->mode = USDF_DGRAM_SUPP_MODE;
		addr_format = FI_FORMAT_UNSPEC;
	}
	fi->ep_attr->type = FI_EP_DGRAM;

	ret = usdf_fill_addr_info(fi, addr_format, src, dest, dap);
	if (ret != 0) {
		goto fail;
	}

	/* fabric attrs */
	fattrp = fi->fabric_attr;
	fattrp->name = strdup(dap->uda_devname);
	if (fattrp->name == NULL) {
		ret = -FI_ENOMEM;
		goto fail;
	}

	/* TX attrs */
	txattr = fi->tx_attr;
	txattr->iov_limit = USDF_DGRAM_DFLT_SGE;
	txattr->size = dap->uda_max_send_credits / USDF_DGRAM_DFLT_SGE;
	if (hints != NULL && hints->tx_attr != NULL) {
		if (hints->tx_attr->iov_limit > USDF_MSG_MAX_SGE) {
			ret = -FI_ENODATA;
			goto fail;
		}
		if (hints->tx_attr->iov_limit != 0) {
			txattr->iov_limit = hints->tx_attr->iov_limit;
			entries = hints->tx_attr->size * txattr->iov_limit;
			if (entries > dap->uda_max_send_credits) {
				ret = -FI_ENODATA;
				goto fail;
			} else if (entries == 0) {
				txattr->size = dap->uda_max_send_credits /
					txattr->iov_limit;
			} else {
				txattr->size = hints->tx_attr->size;
			}
		} else if (hints->tx_attr->size != 0) {
			txattr->size = hints->tx_attr->size;
			if (txattr->size > dap->uda_max_send_credits) {
				ret = -FI_ENODATA;
				goto fail;
			}
			entries = txattr->size * txattr->iov_limit;
			if (entries > dap->uda_max_send_credits) {
				txattr->iov_limit = dap->uda_max_send_credits /
					txattr->size;
			}
		}
	}

	/* RX attrs */
	rxattr = fi->rx_attr;
	rxattr->iov_limit = USDF_DGRAM_DFLT_SGE;
	rxattr->size = dap->uda_max_recv_credits / USDF_DGRAM_DFLT_SGE;
	if (hints != NULL && hints->rx_attr != NULL) {
		if (hints->rx_attr->iov_limit > USDF_MSG_MAX_SGE) {
			ret = -FI_ENODATA;
			goto fail;
		}
		if (hints->rx_attr->iov_limit != 0) {
			rxattr->iov_limit = hints->rx_attr->iov_limit;
			entries = hints->rx_attr->size * rxattr->iov_limit;
			if (entries > dap->uda_max_recv_credits) {
				ret = -FI_ENODATA;
				goto fail;
			} else if (entries == 0) {
				rxattr->size = dap->uda_max_recv_credits /
					rxattr->iov_limit;
			} else {
				rxattr->size = hints->rx_attr->size;
			}
		} else if (hints->rx_attr->size != 0) {
			rxattr->size = hints->rx_attr->size;
			if (rxattr->size > dap->uda_max_recv_credits) {
				ret = -FI_ENODATA;
				goto fail;
			}
			entries = rxattr->size * rxattr->iov_limit;
			if (entries > dap->uda_max_recv_credits) {
				rxattr->iov_limit = dap->uda_max_recv_credits /
					rxattr->size;
			}
		}
	}

	/* endpoint attrs */
	eattrp = fi->ep_attr;
	if (fi->mode & FI_MSG_PREFIX) {
		eattrp->msg_prefix_size = USDF_HDR_BUF_ENTRY;
	}
	eattrp->max_msg_size = dap->uda_mtu -
		sizeof(struct usd_udp_hdr);
	eattrp->protocol = FI_PROTO_UDP;
	eattrp->tx_ctx_cnt = 1;
	eattrp->rx_ctx_cnt = 1;

	/* domain attrs */
	dattrp = fi->domain_attr;
	dattrp->threading = FI_THREAD_UNSPEC;
	dattrp->control_progress = FI_PROGRESS_AUTO;
	dattrp->data_progress = FI_PROGRESS_MANUAL;

	/* add to tail of list */
	if (*fi_first == NULL) {
		*fi_first = fi;
	} else {
		(*fi_last)->next = fi;
	}
	*fi_last = fi;

	return 0;

fail:
	if (fi != NULL) {
		fi_freeinfo(fi);
	}
	return ret;
}