int ft_post_send_atomic()

in fabtests/ubertest/xfer.c [379:531]


int ft_post_send_atomic(void)
{
	int ret, i;
	struct fi_msg_atomic msg;
	struct fi_rma_ioc rma_iov;
	size_t iov_count;
	struct fi_context *ctx = NULL;

	if (ft_generates_tx_comp()) {
 		ret = ft_get_ctx(&ft_tx_ctrl, &ctx);
 		if (ret)
 			return ret;
	}

	switch (test_info.class_function) {
	case FT_FUNC_ATOMICV:
		ft_format_iocs(ft_tx_ctrl.iov, &iov_count);
		ft_send_retry(ret, fi_atomicv, ft_tx_ctrl.ep, ft_atom_ctrl.ioc,
			ft_tx_ctrl.iov_desc, iov_count, ft_tx_ctrl.addr,
			ft_mr_ctrl.peer_mr_addr, ft_mr_ctrl.peer_mr_key,
			ft_atom_ctrl.datatype, ft_atom_ctrl.op, ctx);
		ft_next_iov_cnt(&ft_tx_ctrl, fabric_info->tx_attr->iov_limit);
		break;
	case FT_FUNC_ATOMICMSG:
		ft_format_iocs(ft_tx_ctrl.iov, &iov_count);
		msg.msg_iov = ft_atom_ctrl.ioc;
		msg.desc = ft_tx_ctrl.iov_desc;
		msg.iov_count = iov_count;
		msg.addr = ft_tx_ctrl.addr;
		msg.context = ctx;
		msg.data = ft_tx_ctrl.remote_cq_data;
		msg.op = ft_atom_ctrl.op;
		msg.datatype = ft_atom_ctrl.datatype;

		rma_iov.addr = ft_mr_ctrl.peer_mr_addr;
		rma_iov.key = ft_mr_ctrl.peer_mr_key;

		for (i = 0, rma_iov.count = 0; i < msg.iov_count; i++)
			rma_iov.count += ft_atom_ctrl.ioc[i].count;

		msg.rma_iov = &rma_iov;
		msg.rma_iov_count = 1;
		ft_send_retry(ret, fi_atomicmsg, ft_tx_ctrl.ep, &msg, test_info.msg_flags);
		ft_next_iov_cnt(&ft_tx_ctrl, fabric_info->tx_attr->iov_limit);
		break;
	case FT_FUNC_FETCH_ATOMIC:
		ft_send_retry(ret, fi_fetch_atomic, ft_tx_ctrl.ep,
			ft_tx_ctrl.buf, ft_atom_ctrl.count, ft_tx_ctrl.memdesc,
			ft_atom_ctrl.res_buf, ft_atom_ctrl.res_memdesc,
			ft_tx_ctrl.addr, ft_mr_ctrl.peer_mr_addr,
			ft_mr_ctrl.peer_mr_key, ft_atom_ctrl.datatype,
			ft_atom_ctrl.op, ctx);
		break;
	case FT_FUNC_FETCH_ATOMICV:
		ft_format_iocs(ft_tx_ctrl.iov, &iov_count);
		ft_send_retry(ret, fi_fetch_atomicv, ft_tx_ctrl.ep,
			ft_atom_ctrl.ioc, ft_tx_ctrl.iov_desc, iov_count,
			ft_atom_ctrl.res_ioc, ft_atom_ctrl.res_memdesc,
			iov_count, ft_tx_ctrl.addr, ft_mr_ctrl.peer_mr_addr,
			ft_mr_ctrl.peer_mr_key, ft_atom_ctrl.datatype,
			ft_atom_ctrl.op, ctx);
		ft_next_iov_cnt(&ft_tx_ctrl, fabric_info->tx_attr->iov_limit);
		break;
	case FT_FUNC_FETCH_ATOMICMSG:
		ft_format_iocs(ft_tx_ctrl.iov, &iov_count);
		msg.msg_iov = ft_atom_ctrl.ioc;
		msg.desc = ft_tx_ctrl.iov_desc;
		msg.iov_count = iov_count;
		msg.addr = ft_tx_ctrl.addr;
		msg.context = ctx;
		msg.data = ft_tx_ctrl.remote_cq_data;
		msg.op = ft_atom_ctrl.op;
		msg.datatype = ft_atom_ctrl.datatype;

		rma_iov.addr = ft_mr_ctrl.peer_mr_addr;
		rma_iov.key = ft_mr_ctrl.peer_mr_key;

		for (i = 0, rma_iov.count = 0; i < msg.iov_count; i++)
			rma_iov.count += ft_atom_ctrl.ioc[i].count;

		msg.rma_iov = &rma_iov;
		msg.rma_iov_count = 1;

		ft_send_retry(ret, fi_fetch_atomicmsg, ft_tx_ctrl.ep, &msg,
			ft_atom_ctrl.res_ioc, ft_atom_ctrl.res_memdesc,
			iov_count, test_info.msg_flags);
		ft_next_iov_cnt(&ft_tx_ctrl, fabric_info->tx_attr->iov_limit);
		break;
	case FT_FUNC_COMPARE_ATOMIC:
		ft_send_retry(ret, fi_compare_atomic, ft_tx_ctrl.ep,
			ft_tx_ctrl.buf, ft_atom_ctrl.count, ft_tx_ctrl.memdesc,
			ft_atom_ctrl.comp_buf, ft_atom_ctrl.comp_memdesc,
			ft_atom_ctrl.res_buf, ft_atom_ctrl.res_memdesc,
			ft_tx_ctrl.addr, ft_mr_ctrl.peer_mr_addr,
			ft_mr_ctrl.peer_mr_key, ft_atom_ctrl.datatype,
			ft_atom_ctrl.op, ctx);
		break;
	case FT_FUNC_COMPARE_ATOMICV:
		ft_format_iocs(ft_tx_ctrl.iov, &iov_count);
		ft_send_retry(ret, fi_compare_atomicv, ft_tx_ctrl.ep,
			ft_atom_ctrl.ioc, ft_tx_ctrl.iov_desc, iov_count,
			ft_atom_ctrl.comp_ioc, ft_atom_ctrl.comp_memdesc,
			iov_count, ft_atom_ctrl.res_ioc,
			ft_atom_ctrl.res_memdesc, iov_count, ft_tx_ctrl.addr,
			ft_mr_ctrl.peer_mr_addr, ft_mr_ctrl.peer_mr_key,
			ft_atom_ctrl.datatype, ft_atom_ctrl.op, ctx);
		ft_next_iov_cnt(&ft_tx_ctrl, fabric_info->tx_attr->iov_limit);
		break;
	case FT_FUNC_COMPARE_ATOMICMSG:
		ft_format_iocs(ft_tx_ctrl.iov, &iov_count);
		msg.msg_iov = ft_atom_ctrl.ioc;
		msg.desc = ft_tx_ctrl.iov_desc;
		msg.iov_count = iov_count;
		msg.addr = ft_tx_ctrl.addr;
		msg.context = ctx;
		msg.data = ft_tx_ctrl.remote_cq_data;
		msg.op = ft_atom_ctrl.op;
		msg.datatype = ft_atom_ctrl.datatype;

		rma_iov.addr = ft_mr_ctrl.peer_mr_addr;
		rma_iov.key = ft_mr_ctrl.peer_mr_key;

		for (i = 0, rma_iov.count = 0; i < msg.iov_count; i++)
			rma_iov.count += ft_atom_ctrl.ioc[i].count;

		msg.rma_iov = &rma_iov;
		msg.rma_iov_count = 1;

		ft_send_retry(ret, fi_compare_atomicmsg, ft_tx_ctrl.ep, &msg,
			ft_atom_ctrl.comp_ioc, ft_atom_ctrl.comp_memdesc, iov_count,
			ft_atom_ctrl.res_ioc, ft_atom_ctrl.res_memdesc,
			iov_count, test_info.msg_flags);
		ft_next_iov_cnt(&ft_tx_ctrl, fabric_info->tx_attr->iov_limit);
		break;
	case FT_FUNC_INJECT_ATOMIC:
		ft_send_retry(ret, fi_inject_atomic, ft_tx_ctrl.ep,
			ft_tx_ctrl.buf, ft_atom_ctrl.count, ft_tx_ctrl.addr, 
			ft_mr_ctrl.peer_mr_addr, ft_mr_ctrl.peer_mr_key,
			ft_atom_ctrl.datatype, ft_atom_ctrl.op);
		break;
	default:
		ft_send_retry(ret, fi_atomic, ft_tx_ctrl.ep, ft_tx_ctrl.buf,
				ft_atom_ctrl.count, ft_tx_ctrl.memdesc,
				ft_tx_ctrl.addr, ft_mr_ctrl.peer_mr_addr,
				ft_mr_ctrl.peer_mr_key, ft_atom_ctrl.datatype,
				ft_atom_ctrl.op, ctx);
	}

	if (ft_check_tx_completion())
		ft_tx_ctrl.credits--;

	return ret;
}