Ejemplo n.º 1
0
/*---------------------------------------------------------------------------*/
static int on_response(struct xio_session *session,
		       struct xio_msg *msg,
		       int last_in_rxq,
		       void *cb_user_context)
{
	/* struct scatterlist	*sgl; */

	process_response(msg);

	/* message is no longer needed */
	xio_release_response(msg);

	nrecv++;

	msg_pool_put(pool, msg);

	if (test_config.finite_run) {
		if (nrecv ==  disconnect_nr) {
			xio_disconnect(g_connection);
			return 0;
		}

		if (nrecv > disconnect_nr)
			return 0;
	}

	/* reset message */
	msg->in.header.iov_base = NULL;
	msg->in.header.iov_len = 0;
	msg->in.data_tbl.nents = 0;

	/*
	sgl = msg->in.data_tbl.sgl;
	xio_tbl_set_nents(&msg->in.data_tbl, test_config.in_iov_len);
	sg_set_buf(sgl, NULL, ONE_MB);
	*/

	msg->sn = 0;

	/* recycle the message and fill new request */
	msg_build_out_sgl(&msg_params, msg,
		  test_config.hdr_len,
		  1, test_config.data_len);

	/* try to send it */
	if (xio_send_request(g_connection, msg) == -1) {
		if (xio_errno() != EAGAIN)
			pr_err("**** [%p] Error - xio_send_msg " \
					"failed %s\n",
					session,
					xio_strerror(xio_errno()));
		msg_pool_put(pool, msg);
		/* xio_assert(0); */
	}

	return 0;
}
Ejemplo n.º 2
0
/*---------------------------------------------------------------------------*/
static int on_message_delivered(struct xio_session *session,
				struct xio_msg *msg,
				int last_in_rxq,
				void *cb_user_context)
{
	struct ow_test_params *ow_params =
				(struct ow_test_params *)cb_user_context;
	struct xio_msg *new_msg;

	process_tx_message(ow_params, msg);
	ow_params->ndelivered++;

	/* can be safely returned to pool */
	msg_pool_put(ow_params->pool, msg);

	if (ow_params->finite_run) {
		if (ow_params->ndelivered == ow_params->disconnect_nr) {
			xio_disconnect(ow_params->conn);
			return 0;
		}

		if (ow_params->nsent == ow_params->disconnect_nr)
			return 0;
	}

	/* peek message from the pool */
	new_msg = msg_pool_get(ow_params->pool);
	if (new_msg == NULL) {
		printf("pool is empty\n");
		return 0;
	}

	/* assign buffers to the message */
	msg_write(&ow_params->msg_params, new_msg,
		  test_config.hdr_len,
		  1, test_config.data_len);

	/*
	 * ask for receipt since we need to put the message back
	 * to pool
	 */
	 new_msg->flags = XIO_MSG_FLAG_REQUEST_READ_RECEIPT;

	/* send it */
	if (xio_send_msg(ow_params->conn, new_msg) == -1) {
		if (xio_errno() != EAGAIN)
			printf("**** [%p] Error - xio_send_msg " \
					"failed. %s\n",
					session,
					xio_strerror(xio_errno()));
		msg_pool_put(ow_params->pool, new_msg);
		xio_assert(0);
	}
	ow_params->nsent++;

	return 0;
}
Ejemplo n.º 3
0
/*---------------------------------------------------------------------------*/
static int on_response(struct xio_session *session,
			struct xio_msg *msg,
			int last_in_rxq,
			void *cb_user_context)
{
	struct thread_data  *tdata = (struct thread_data *)cb_user_context;

	cycles_t rtt = (get_cycles()-(cycles_t)msg->user_context);

	if (tdata->do_stat) {
		if (rtt > tdata->stat.max_rtt)
			tdata->stat.max_rtt = rtt;
		if (rtt < tdata->stat.min_rtt)
			tdata->stat.min_rtt = rtt;
		tdata->stat.tot_rtt += rtt;
		tdata->stat.ccnt++;
	}

	tdata->rx_nr++;

	/* message is no longer needed */
	xio_release_response(msg);

	if (tdata->disconnect) {
		if (tdata->rx_nr == tdata->tx_nr)
			xio_disconnect(tdata->conn);
		else
			msg_pool_put(tdata->pool, msg);
		return 0;
	}

	/* reset message */
	msg->in.header.iov_len = 0;
	vmsg_sglist_set_nents(&msg->in, 0);

	msg->user_context = (void *)get_cycles();
	if (xio_send_request(tdata->conn, msg) == -1) {
		if (xio_errno() != EAGAIN)
			printf("**** [%p] Error - xio_send_request " \
					"failed %s\n",
					session,
					xio_strerror(xio_errno()));
		msg_pool_put(tdata->pool, msg);
		return 0;
	}
	if (tdata->do_stat)
		tdata->stat.scnt++;

	tdata->tx_nr++;

	return 0;
}
Ejemplo n.º 4
0
/*---------------------------------------------------------------------------*/
static int on_request(struct xio_session *session, struct xio_msg *req,
		      int more_in_batch, void *cb_user_context)
{
	struct xio_msg	*rsp;

	/* process request */
	process_request(req);

	/* alloc transaction */
	rsp	= msg_pool_get(pool);
	rsp->request		= req;
	rsp->more_in_batch	= 0;

	/* fill response */
	msg_write(&msg_params, rsp,
		  test_config.hdr_len,
		  1, test_config.data_len);

	if (xio_send_response(rsp) == -1) {
		printf("**** [%p] Error - xio_send_msg failed. %s\n",
		       session, xio_strerror(xio_errno()));
		msg_pool_put(pool, rsp);
	}

	return 0;
}
Ejemplo n.º 5
0
/*---------------------------------------------------------------------------*/
static int raio_handle_close_comp(void *prv_session_data,
				    void *prv_portal_data,
				    struct xio_msg *rsp)
{
	struct raio_io_portal_data *pd = prv_portal_data;
	int			    j;

	if (pd->bs_dev) {
		raio_bs_close(pd->bs_dev);
		raio_bs_exit(pd->bs_dev);
		pd->bs_dev = NULL;
	}
	if (pd->io_us_free) {
		for (j = 0; j < pd->iodepth; j++)
			msg_pool_put(pd->rsp_pool, pd->io_us_free[j].rsp);
	}

	TAILQ_INIT(&pd->io_u_free_list);

	free(pd->io_us_free);
	pd->io_us_free = NULL;
	pd->io_u_free_nr = 0;
	msg_pool_delete(pd->rsp_pool);
	pd->rsp_pool = NULL;

	return 0;
}
Ejemplo n.º 6
0
/*---------------------------------------------------------------------------*/
static int on_send_response_complete(struct xio_session *session,
                                     struct xio_msg *msg,
                                     void *cb_prv_data)
{
    struct thread_data	*tdata = (struct thread_data *)cb_prv_data;
    struct server_data	*sdata  = tdata->sdata;

    tdata->ncomp++;

    /* can be safely freed */
    msg_pool_put(tdata->pool, msg);

    if (sdata->finite_run && tdata->ncomp == DISCONNECT_NR) {
        pthread_spin_lock(&sdata->lock);
        if (tdata->sdata->disconnected == 0) {
            int			i;

            sdata->disconnected = 1;
            pthread_spin_unlock(&sdata->lock);

            for (i = 0; i < sdata->tdata_nr; i++)
                if (sdata->tdata[i].connection)
                    xio_disconnect(sdata->tdata[i].connection);
        } else
            pthread_spin_unlock(&sdata->lock);
    }

    return 0;
}
Ejemplo n.º 7
0
/*---------------------------------------------------------------------------*/
static int on_request(struct xio_session *session,
			struct xio_msg *req,
			int more_in_batch,
			void *cb_prv_data)
{
	struct xio_msg	*rsp;

	if (req->status)
		printf("**** request completed with error. [%s]\n",
		       xio_strerror(req->status));

	/* process request */
	process_request(req);

	/* alloc transaction */
	rsp	= msg_pool_get(pool);

	rsp->request		= req;
	rsp->more_in_batch	= 0;

	/* fill response */
	msg_set(rsp, 0,
		test_config.hdr_len,
		test_config.data_len);

	if (xio_send_response(rsp) == -1) {
		printf("**** [%p] Error - xio_send_msg failed. %s\n",
		       session, xio_strerror(xio_errno()));
		msg_pool_put(pool, rsp);
	}

	return 0;
}
Ejemplo n.º 8
0
/*---------------------------------------------------------------------------*/
static int on_msg_error(struct xio_session *session,
			enum xio_status error,
			enum xio_msg_direction direction,
			struct xio_msg  *msg,
			void *cb_user_context)
{
	struct test_params *test_params = (struct test_params *)cb_user_context;

	if (direction == XIO_MSG_DIRECTION_OUT) {
		printf("**** [%p] message %lu failed. reason: %s\n",
		       session, msg->sn, xio_strerror(error));
	} else {
		xio_release_response(msg);
		printf("**** [%p] message %lu failed. reason: %s\n",
		       session, msg->request->sn, xio_strerror(error));
	}

	msg_pool_put(test_params->pool, msg);

	switch (error) {
	case XIO_E_MSG_FLUSHED:
		break;
	default:
		xio_disconnect(test_params->connection);
		break;
	};

	return 0;
}
Ejemplo n.º 9
0
/*---------------------------------------------------------------------------*/
static int on_request(struct xio_session *session, struct xio_msg *req,
		      int last_in_rxq, void *cb_prv_data)
{
	struct xio_msg	*rsp;

	/* process request */
	process_request(req);

	/* alloc transaction */
	rsp	= msg_pool_get(pool);

	rsp->request		= req;

	/* fill response */
	msg_build_out_sgl(&msg_params, rsp,
		  test_config.hdr_len,
		  1, test_config.data_len);

	if (xio_send_response(rsp) == -1) {
		printf("**** [%p] Error - xio_send_msg failed. %s\n",
		       session, xio_strerror(xio_errno()));
		msg_pool_put(pool, req);
		xio_assert(0);
	}

	return 0;
}
Ejemplo n.º 10
0
/*---------------------------------------------------------------------------*/
static int on_msg_error(struct xio_session *session,
                        enum xio_status error,
                        enum xio_msg_direction direction,
                        struct xio_msg  *msg,
                        void *cb_user_context)
{
    struct thread_data	*tdata = (struct thread_data *)cb_user_context;

    printf("**** [%p] message [%lu] failed. reason: %s\n",
           session, msg->request->sn, xio_strerror(error));

    msg_pool_put(tdata->pool, msg);

    switch (error) {
    case XIO_E_MSG_DISCARDED:
    case XIO_E_MSG_FLUSHED:
        break;
    default:
        /* need to send response here */
        xio_assert(0);
        break;
    };

    return 0;
}
Ejemplo n.º 11
0
/*---------------------------------------------------------------------------*/
static int on_request(struct xio_session *session,
			struct xio_msg *req,
			int more_in_batch,
			void *cb_prv_data)
{
	struct xio_msg		*rsp;
	struct thread_data	*tdata = cb_prv_data;

	/* alloc transaction */
	rsp	= msg_pool_get(tdata->pool);

	/* fill response */
	rsp->request		= req;
	rsp->more_in_batch	= more_in_batch;
	rsp->in.header.iov_len	= 0;
	rsp->out.header.iov_len = 0;
	vmsg_sglist_set_nents(&rsp->in, 0);

	if (tdata->user_param->verb == READ)
		vmsg_sglist_set_nents(&rsp->out, 0);

	if (xio_send_response(rsp) == -1) {
		printf("**** [%p] Error - xio_send_msg failed. %s\n",
		       session, xio_strerror(xio_errno()));
		msg_pool_put(tdata->pool, req);
	}


	return 0;
}
Ejemplo n.º 12
0
/*---------------------------------------------------------------------------*/
static int on_request(struct xio_session *session, struct xio_msg *req,
                      int last_in_rxq, void *cb_prv_data)
{
    struct xio_msg		*rsp;
    struct thread_data	*tdata = (struct thread_data *)cb_prv_data;

    /* process request */
    process_request(tdata, req);

    /* alloc transaction */
    rsp	= msg_pool_get(tdata->pool);

    rsp->request		= req;

    /* fill response */
    msg_build_out_sgl(&msg_prms, rsp,
                      test_config.hdr_len,
                      1, test_config.data_len);

    if (xio_send_response(rsp) == -1) {
        printf("**** [%p] Error - xio_send_msg failed. %s\n",
               session, xio_strerror(xio_errno()));
        msg_pool_put(tdata->pool, req);

        /* better to do disconnect */
        /*xio_disconnect(tdata->conn);*/
        xio_assert(0);
    }
    tdata->nsent++;

    return 0;
}
Ejemplo n.º 13
0
/*---------------------------------------------------------------------------*/
static int on_send_response_complete(struct xio_session *session,
			struct xio_msg *msg,
			void *cb_prv_data)
{
	/* can be safely freed */
	msg_pool_put(pool, msg);

	return 0;
}
Ejemplo n.º 14
0
/*---------------------------------------------------------------------------*/
static int on_message_delivered(struct xio_session *session,
                                struct xio_msg *msg,
                                int more_in_batch,
                                void *cb_user_context)
{
    struct xio_msg *new_msg;
    struct ow_test_params *ow_params = cb_user_context;

    ow_params->ndelivered++;

    /* can be safely freed */
    msg_pool_put(ow_params->pool, msg);

#if  TEST_DISCONNECT
    if (ow_params->ndelivered == DISCONNECT_NR) {
        xio_disconnect(ow_params->connection);
        return 0;
    }

    if (ow_params->nsent == DISCONNECT_NR)
        return 0;
#endif

    /* peek new message from the pool */
    new_msg	= msg_pool_get(ow_params->pool);

    new_msg->more_in_batch	= 0;

    /* fill response */
    msg_write(&ow_params->msg_params, new_msg,
              NULL, test_config.hdr_len,
              NULL, test_config.data_len);

    new_msg->flags = XIO_MSG_FLAG_REQUEST_READ_RECEIPT;
    if (xio_send_msg(ow_params->connection, new_msg) == -1) {
        printf("**** [%p] Error - xio_send_msg failed. %s\n",
               session, xio_strerror(xio_errno()));
        msg_pool_put(ow_params->pool, new_msg);
    }
    ow_params->nsent++;


    return 0;
}
Ejemplo n.º 15
0
/*---------------------------------------------------------------------------*/
static int on_message_delivered(struct xio_session *session,
			struct xio_msg *msg,
			int more_in_batch,
			void *cb_user_context)
{
	struct xio_msg *new_msg;

	process_tx_message(msg);

	/* can be safely returned to pool */
	msg_pool_put(pool, msg);


	/* peek message from the pool */
	new_msg = msg_pool_get(pool);
	if (new_msg == NULL) {
		printf("pool is empty\n");
		return 0;
	}

	/* assign buffers to the message */
	msg_write(new_msg,
		  NULL, test_config.hdr_len,
		  NULL, test_config.data_len);

	/*
	 * ask for receipt since we need to put the message back
	 * to pool
	 */
	 new_msg->flags = XIO_MSG_FLAG_REQUEST_READ_RECEIPT;

	/* send it */
	if (xio_send_msg(conn, new_msg) == -1) {
		if (xio_errno() != EAGAIN)
			printf("**** [%p] Error - xio_send_msg " \
					"failed. %s\n",
					session,
					xio_strerror(xio_errno()));
		msg_pool_put(pool, new_msg);
		return 0;
	}
	return 0;
}
/*---------------------------------------------------------------------------*/
static int on_msg_error(struct xio_session *session,
		enum xio_status error, struct xio_msg  *msg,
		void *cb_user_context)
{
	struct thread_data  *tdata = cb_user_context;

	msg_pool_put(tdata->pool, msg);

	return 0;
}
Ejemplo n.º 17
0
/*---------------------------------------------------------------------------*/
int on_msg_error(struct xio_session *session,
		 enum xio_status error, struct xio_msg  *msg,
		 void *cb_private_data)
{
	switch (msg->type) {
	case XIO_MSG_TYPE_REQ:
		printf("**** [%p] message [%lu] failed. reason: %s\n",
		       session, msg->sn, xio_strerror(error));
		msg_pool_put(pool, msg);
		switch (error) {
		case XIO_E_MSG_FLUSHED:
		case XIO_E_MSG_DISCARDED:
			break;
		default:
			xio_assert(0);
			break;
		};
		break;
	case XIO_MSG_TYPE_RSP:
		printf("**** [%p] message [%lu] failed. reason: %s\n",
		       session, msg->request->sn, xio_strerror(error));
		/* message is no longer needed */
		switch (error) {
		case XIO_E_MSG_FLUSHED:
			xio_release_response(msg);
			msg_pool_put(pool, msg);
			break;
		default:
			msg_pool_put(pool, msg);
			xio_assert(0);
			break;
		};
		break;
	default:
		printf("unknown message type : %d\n", msg->type);
		msg_pool_put(pool, msg);
		xio_assert(0);
		break;
	}

	return 0;
}
Ejemplo n.º 18
0
/*---------------------------------------------------------------------------*/
int on_msg_error(struct xio_session *session,
		enum xio_status error, struct xio_msg  *msg,
		void *cb_private_data)
{
	printf("**** [%p] message [%"PRIu64"] failed. reason: %s\n",
	       session, msg->sn, xio_strerror(error));

	msg_pool_put(pool, msg);

	return 0;
}
Ejemplo n.º 19
0
/*---------------------------------------------------------------------------*/
static int on_response(struct xio_session *session, struct xio_msg *rsp,
		       int more_in_batch, void *cb_user_context)
{
	struct xio_iovec_ex	*sglist;

	process_response(rsp);

	/* message is no longer needed */
	xio_release_response(rsp);

	nrecv++;
	if (test_config.finite_run) {
		if (nrecv == disconnect_nr) {
			xio_disconnect(conn);
			return 0;
		}

		if (nrecv > disconnect_nr || nsent == disconnect_nr)
			return 0;
	}

	/* reset message */
	rsp->in.header.iov_base = NULL;
	rsp->in.header.iov_len = 0;
	sglist = vmsg_sglist(&rsp->in);
	vmsg_sglist_set_nents(&rsp->in, 1);

	sglist[0].iov_base = NULL;
	sglist[0].iov_len  = ONE_MB;
	sglist[0].mr = NULL;

	rsp->sn = 0;
	rsp->more_in_batch = 0;
	do {
		/* recycle the message and fill new request */
		msg_write(&msg_params, rsp,
			  test_config.hdr_len,
			  1, test_config.data_len);

		/* try to send it */
		if (xio_send_request(conn, rsp) == -1) {
			if (xio_errno() != EAGAIN)
				printf("**** [%p] Error - xio_send_msg " \
				       "failed %s\n",
				       session,
				       xio_strerror(xio_errno()));
			msg_pool_put(pool, rsp);
			xio_assert(0);
		}
		nsent++;
	} while (0);

	return 0;
}
Ejemplo n.º 20
0
/*---------------------------------------------------------------------------*/
static int on_new_session(struct xio_session *session,
			struct xio_new_session_req *session_data,
			void *cb_prv_data)
{
	struct xio_msg	*req;
	int		i = 0;

	printf("**** [%p] on_new_session :%s:%d\n", session,
	       get_ip((struct sockaddr *)&session_data->src_addr),
	       get_port((struct sockaddr *)&session_data->src_addr));

	xio_accept(session, NULL, 0, NULL, 0);

	msg_pool_reset(pool);
	conn = xio_get_connection(session, ctx);

	printf("**** starting ...\n");
	while (1) {
		/* create transaction */
		req = msg_pool_get(pool);
		if (req == NULL)
			break;

		/* get pointers to internal buffers */
		req->in.header.iov_base = NULL;
		req->in.header.iov_len = 0;
		req->in.data_iovlen = 1;
		req->in.data_iov[0].iov_base = NULL;
		req->in.data_iov[0].iov_len  = ONE_MB;
		req->in.data_iov[0].mr = NULL;

		/* recycle the message and fill new request */
		msg_set(req, 1,
			test_config.hdr_len,
			test_config.data_len);

		/* try to send it */
		if (xio_send_request(conn, req) == -1) {
			printf("**** sent %d messages\n", i);
			if (xio_errno() != EAGAIN)
				printf("**** [%p] Error - xio_send_msg " \
				       "failed. %s\n",
					session,
					xio_strerror(xio_errno()));
			msg_pool_put(pool, req);
			return 0;
		}
		i++;
		if (i == 256)
			break;
	}

	return 0;
}
Ejemplo n.º 21
0
/*---------------------------------------------------------------------------*/
int on_msg_error(struct xio_session *session,
                 enum xio_status error, struct xio_msg  *msg,
                 void *cb_user_context)
{
    struct ow_test_params *ow_params = cb_user_context;

    printf("**** [%p] message [%"PRIu64"] failed. reason: %s\n",
           session, msg->sn, xio_strerror(error));

    msg_pool_put(ow_params->pool, msg);

    return 0;
}
Ejemplo n.º 22
0
/*---------------------------------------------------------------------------*/
int on_msg_error(struct xio_session *session,
		enum xio_status error, struct xio_msg  *msg,
		void *cb_prv_data)
{
	struct thread_data	*tdata = cb_prv_data;

	printf("**** [%p] message [%"PRIu64"] failed. reason: %s\n",
	       session, msg->request->sn, xio_strerror(error));

	msg_pool_put(tdata->pool, msg);

	return 0;
}
Ejemplo n.º 23
0
/*---------------------------------------------------------------------------*/
static int on_response(struct xio_session *session,
			struct xio_msg *msg,
			int more_in_batch,
			void *cb_user_context)
{
	process_response(msg);

	if (msg->status)
		printf("**** message completed with error. [%s]\n",
				xio_strerror(msg->status));

	/* message is no longer needed */
	xio_release_response(msg);


	/* reset message */
	msg->in.header.iov_base = NULL;
	msg->in.header.iov_len = 0;
	msg->in.data_iovlen = 1;
	msg->in.data_iov[0].iov_base = NULL;
	msg->in.data_iov[0].iov_len  = ONE_MB;
	msg->in.data_iov[0].mr = NULL;

	msg->sn = 0;
	msg->more_in_batch = 0;

	do {
		/* recycle the message and fill new request */
		msg_write(msg,
			  "hello world request header",
			  test_config.hdr_len,
			  "hello world request data",
			  test_config.data_len);

		/* try to send it */
		if (xio_send_request(conn, msg) == -1) {
			if (xio_errno() != EAGAIN)
				printf("**** [%p] Error - xio_send_msg " \
				       "failed %s\n",
				       session,
				       xio_strerror(xio_errno()));
			msg_pool_put(pool, msg);
			return 0;
		}
	} while (0);



	return 0;
}
Ejemplo n.º 24
0
/*---------------------------------------------------------------------------*/
int on_msg_error(struct xio_session *session,
		enum xio_status error, struct xio_msg  *msg,
		void *cb_private_data)
{
	if (msg->type == XIO_MSG_TYPE_RSP)
		printf("**** [%p] message [%"PRIu64"] failed. reason: %s\n",
		       session, msg->request->sn, xio_strerror(error));
	else
		printf("**** [%p] message [%"PRIu64"] failed. reason: %s\n",
		       session, msg->sn, xio_strerror(error));

	msg_pool_put(pool, msg);

	return 0;
}
Ejemplo n.º 25
0
/*---------------------------------------------------------------------------*/
static int on_new_session(struct xio_session *session,
                          struct xio_new_session_req *req,
                          void *cb_user_context)
{
    int			i = 0;
    struct ow_test_params	*ow_params = cb_user_context;
    struct xio_msg		*msg;

    printf("**** [%p] on_new_session :%s:%d\n", session,
           get_ip((struct sockaddr *)&req->src_addr),
           get_port((struct sockaddr *)&req->src_addr));

    xio_accept(session, NULL, 0, NULL, 0);

    if (ow_params->connection == NULL)
        ow_params->connection = xio_get_connection(session,
                                ow_params->ctx);

    for (i = 0; i < MAX_OUTSTANDING_REQS; i++) {
        /* pick message from the pool */
        msg = msg_pool_get(ow_params->pool);
        if (msg == NULL)
            break;

        /* assign buffers to the message */
        msg_write(&ow_params->msg_params, msg,
                  NULL, test_config.hdr_len,
                  NULL, test_config.data_len);

        /* ask for read receipt since the message needed to be
         * recycled to the pool */
        msg->flags = XIO_MSG_FLAG_REQUEST_READ_RECEIPT;

        /* send the message */
        if (xio_send_msg(ow_params->connection, msg) == -1) {
            printf("**** sent %d messages\n", i);
            if (xio_errno() != EAGAIN)
                printf("**** [%p] Error - xio_send_msg " \
                       "failed. %s\n",
                       session,
                       xio_strerror(xio_errno()));
            msg_pool_put(ow_params->pool, msg);
            return 0;
        }
        ow_params->nsent++;
    }
    return 0;
}
Ejemplo n.º 26
0
/*---------------------------------------------------------------------------*/
static int on_send_response_complete(struct xio_session *session,
			struct xio_msg *msg,
			void *cb_user_context)
{
	struct test_params *test_params = cb_user_context;

	test_params->ncomp++;

	/* can be safely freed */
	msg_pool_put(test_params->pool, msg);

#if  TEST_DISCONNECT
	if (test_params->ncomp == DISCONNECT_NR) {
		xio_disconnect(test_params->connection);
		return 0;
	}
#endif
	return 0;
}
Ejemplo n.º 27
0
/*---------------------------------------------------------------------------*/
static int on_connection_established(struct xio_connection *conn)
{
	struct xio_msg			*msg;

	pr_info("**** starting ...\n");

	/* create transaction */
	msg = msg_pool_get(pool);
	if (!msg)
		return 0;

	/* get pointers to internal buffers */
	msg->in.header.iov_base = NULL;
	msg->in.header.iov_len = 0;
	msg->in.data_tbl.nents = 0;

	/*
	   sglist = vmsg_sglist(&msg->in);
	   sglist[0].iov_base = NULL;
	   sglist[0].iov_len  = ONE_MB;
	   sglist[0].mr = NULL;
	   vmsg_sglist_set_nents(&msg->in, 1);
	   */

	/* recycle the message and fill new request */
	msg_build_out_sgl(&msg_params, msg, test_config.hdr_len, 1,
		  test_config.data_len);

	/* try to send it */
	if (xio_send_request(conn, msg) == -1) {
		pr_info("**** sent %d messages\n", 1);
		if (xio_errno() != EAGAIN)
			pr_info("**** [%p] Error - xio_send_msg " \
					"failed. %s\n",
					conn,
					xio_strerror(xio_errno()));
		msg_pool_put(pool, msg);
		xio_assert(0);
	}

	return 0;
}
Ejemplo n.º 28
0
/*---------------------------------------------------------------------------*/
static int on_msg_error(struct xio_session *session,
			enum xio_status error,
			enum xio_msg_direction direction,
			struct xio_msg  *msg,
			void *cb_user_context)
{
	pr_info("**** [%p] message [%llu] failed. reason: %s\n",
		session, msg->sn, xio_strerror(error));

	msg_pool_put(pool, msg);

	switch (error) {
	case XIO_E_MSG_FLUSHED:
		break;
	default:
		xio_disconnect(g_connection);
		break;
	};

	return 0;
}
Ejemplo n.º 29
0
/*---------------------------------------------------------------------------*/
static int on_request(struct xio_session *session,
			struct xio_msg *req,
			int more_in_batch,
			void *cb_user_context)
{
	struct xio_msg	*rsp;
	struct test_params *test_params = cb_user_context;

	if (req->status)
		printf("**** request completed with error. [%s]\n",
		       xio_strerror(req->status));

	/* process request */
	process_request(req);


	/* alloc transaction */
	rsp	= msg_pool_get(test_params->pool);

	rsp->request		= req;
	rsp->more_in_batch	= 0;

	/* fill response */
	msg_write(&test_params->msg_params, rsp,
		  NULL, test_config.hdr_len,
		  NULL, test_config.data_len);

	if (xio_send_response(rsp) == -1) {
		printf("**** [%p] Error - xio_send_msg failed. %s\n",
		       session, xio_strerror(xio_errno()));
		msg_pool_put(test_params->pool, req);
	}
	test_params->nsent++;


	return 0;
}
/*---------------------------------------------------------------------------*/
static void *worker_thread(void *data)
{
	struct thread_data	*tdata = data;
	cpu_set_t		cpuset;
	struct xio_msg		*msg;
	int			i;

	/* set affinity to thread */

	CPU_ZERO(&cpuset);
	CPU_SET(tdata->affinity, &cpuset);

	pthread_setaffinity_np(tdata->thread_id, sizeof(cpu_set_t), &cpuset);

	/* prepare data for the cuurent thread */
	tdata->pool = msg_pool_alloc(tdata->user_param->queue_depth);

	/* create thread context for the client */
	tdata->ctx = xio_context_create(NULL, tdata->user_param->poll_timeout,
					tdata->affinity);


	/* connect the session  */
	tdata->conn = xio_connect(tdata->session, tdata->ctx,
				  tdata->cid, NULL, tdata);

	if (tdata->data_len)
		tdata->xbuf = xio_alloc(tdata->data_len);

	for (i = 0;  i < tdata->user_param->queue_depth; i++) {
		/* create transaction */
		msg = msg_pool_get(tdata->pool);
		if (msg == NULL)
			break;

		/* get pointers to internal buffers */
		msg->in.header.iov_len = 0;
		msg->in.data_iovlen = 0;
		msg->out.header.iov_len = 0;
		if (tdata->data_len) {
			msg->out.data_iovlen		= 1;
			msg->out.data_iov[0].iov_base	= tdata->xbuf->addr;
			msg->out.data_iov[0].iov_len	= tdata->xbuf->length;
			msg->out.data_iov[0].mr		= tdata->xbuf->mr;
		} else {
			msg->out.data_iovlen = 0;
		}
		msg->user_context = (void *)get_cycles();
		/* send first message */
		if (xio_send_request(tdata->conn, msg) == -1) {
			if (xio_errno() != EAGAIN)
				printf("**** [%p] Error - xio_send_request " \
				       "failed. %s\n",
					tdata->session,
					xio_strerror(xio_errno()));
			msg_pool_put(tdata->pool, msg);
			return 0;
		}
		if (tdata->do_stat)
			tdata->stat.scnt++;
		tdata->tx_nr++;
	}

	/* the default xio supplied main loop */
	xio_context_run_loop(tdata->ctx, XIO_INFINITE);

	/* normal exit phase */

	if (tdata->pool)
		msg_pool_free(tdata->pool);

	if (tdata->xbuf)
		xio_free(&tdata->xbuf);


	/* free the context */
	xio_context_destroy(tdata->ctx);

	return NULL;
}