Ejemplo n.º 1
0
static
void pscom_extoll_con_cleanup(pscom_con_t *con)
{
	psex_con_info_t *ci = con->arch.extoll.ci;
	if (!ci) return;

	psex_con_cleanup(ci);
	psex_con_free(ci);

	con->arch.extoll.ci = NULL;
}
Ejemplo n.º 2
0
int psex_con_init(psex_con_info_t *con_info, hca_info_t *hca_info, void *priv)
{
	unsigned int i;

	if (!hca_info) hca_info = &default_hca;
	memset(con_info, 0, sizeof(*con_info));

	con_info->hca_info = hca_info;

	con_info->send.bufs.mr = NULL;
	con_info->recv.bufs.mr = NULL;
	con_info->priv = priv;
	con_info->con_broken = 0;

	/*
	 *  Memory for send and receive bufs
	 */

	if (!psex_global_sendq) {
		if (psex_rma2_alloc(hca_info, PSEX_RMA2_MTU * psex_sendq_size,
				   &con_info->send.bufs))
			goto err_alloc;
	}
	con_info->send.pos = 0;

	if (psex_rma2_alloc(hca_info, PSEX_RMA2_MTU * psex_recvq_size,
			    &con_info->recv.bufs))
		goto err_alloc;

	/* Clear all receive magics */
	for (i = 0; i < psex_recvq_size; i++) {
		psex_msg_t *msg = ((psex_msg_t *)con_info->recv.bufs.ptr) + i;
		msg->tail.magic = PSEX_MAGIC_UNUSED;
	}

	con_info->remote_recv_pos = 0;
	con_info->recv.pos = 0;

	// Initialize receive tokens
	con_info->n_recv_toks = 0;
	con_info->n_tosend_toks = 0;

	// Initialize send tokens
	con_info->n_send_toks = psex_recvq_size; // #tokens = length of _receive_ queue!

	return 0;
	/* --- */
err_alloc:
	psex_con_cleanup(con_info);
	psex_dprint(1, "psex_con_init() : %s", psex_err_str);
	return -1;
}
Ejemplo n.º 3
0
static
int pscom_extoll_accept(pscom_con_t *con, int con_fd)
{
	int arch = PSCOM_ARCH_EXTOLL;
	psex_con_info_t *ci = psex_con_create();
	psex_info_msg_t msg;

	if (!ci) goto err_no_ci;
	if (psex_init()) goto out_noextoll;

	if (psex_con_init(ci, NULL, con)) goto dont_use; /* Initialize connection */

	/* step 1:  Yes, we talk extoll. */
	pscom_writeall(con_fd, &arch, sizeof(arch));

	/* step 2: Send Connection id's */
	psex_con_get_info_msg(ci, &msg);
	pscom_writeall(con_fd, &msg, sizeof(msg));

	/* step 3 : recv connection id's */
	if ((pscom_readall(con_fd, &msg, sizeof(msg)) != sizeof(msg)))
		goto err_remote;

	/* Connect */
	if (psex_con_connect(ci, &msg)) {
		/* ToDo: bad! How to inform the peer about the error? */
		DPRINT(0, "Extoll psex_con_connect() failed!");
		goto err_local;
	}

	pscom_extoll_con_init(con, con_fd, ci);

	return 1;
	/* --- */
err_local:
err_remote:
	if (ci) psex_con_cleanup(ci);
	if (ci) psex_con_free(ci);
	return 0;
	/* --- */
dont_use:
out_noextoll:
	psex_con_free(ci);
err_no_ci:
	arch = PSCOM_ARCH_ERROR;
	pscom_writeall(con_fd, &arch, sizeof(arch));
	return 0; /* Dont use extoll */
	/* --- */
}