[dpdk-dev] [PATCH v2 2/2] vhost: Add VHOST PMD

Tetsuya Mukawa mukawa at igel.co.jp
Fri Nov 6 04:54:34 CET 2015


On 2015/11/06 11:22, Yuanhan Liu wrote:
> On Mon, Nov 02, 2015 at 12:58:57PM +0900, Tetsuya Mukawa wrote:
> ...
>> +
>> +static uint16_t
>> +eth_vhost_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
>> +{
>> +	struct vhost_queue *r = q;
>> +	uint16_t nb_rx = 0;
>> +
>> +	if (unlikely(rte_atomic32_read(&r->allow_queuing) == 0))
>> +		return 0;
>> +
>> +	rte_atomic32_set(&r->while_queuing, 1);
>> +
>> +	if (unlikely(rte_atomic32_read(&r->allow_queuing) == 0))
>> +		goto out;
>> +
>> +	/* Dequeue packets from guest TX queue */
>> +	nb_rx = (uint16_t)rte_vhost_dequeue_burst(r->device,
>> +			VIRTIO_TXQ, r->mb_pool, bufs, nb_bufs);
>> +
>> +	r->rx_pkts += nb_rx;
>> +
>> +out:
>> +	rte_atomic32_set(&r->while_queuing, 0);
>> +
>> +	return nb_rx;
>> +}
>> +
>> +static uint16_t
>> +eth_vhost_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
>> +{
>> +	struct vhost_queue *r = q;
>> +	uint16_t i, nb_tx = 0;
>> +
>> +	if (unlikely(rte_atomic32_read(&r->allow_queuing) == 0))
>> +		return 0;
>> +
>> +	rte_atomic32_set(&r->while_queuing, 1);
>> +
>> +	if (unlikely(rte_atomic32_read(&r->allow_queuing) == 0))
>> +		goto out;
>> +
>> +	/* Enqueue packets to guest RX queue */
>> +	nb_tx = (uint16_t)rte_vhost_enqueue_burst(r->device,
>> +			VIRTIO_RXQ, bufs, nb_bufs);
>> +
> Michael, I'm wondering here might be the better place to do "automatic
> receive steering in multiqueue mode". I mean, as a library function,
> queueing/dequeueing packets to/from a specific virt queue is reasonable
> to me. It's upto the caller to pick the right queue, doing the queue
> steering.

Hi Liu,

Oops, I've found a bug here.
To support multiple queues in vhost PMD, I needed to store "queue_id" in
"vhost_queue" structure.
Then, I should call rte_vhost_enqueue_burst() with the value.

> As an eth dev, I guess that's the proper place to do things like that.
>
> Or, I'm thinking we could introduce another vhost function, for not
> breaking current API, to do that, returning the right queue, so that
> other applications (instead of the vhost pmd only) can use that as well.

I may not understand the steering function enough, but If we support the
steering function in vhost library or vhost PMD, how can we handle
"queue_id" parameter of TX functions?
Probably, we need to ignore the value In some cases.
This may confuse the users because they cannot observe the packets in
their specified queue.

So I guess it may be application responsibility to return packets to the
correct queue.
(But we should write a correct documentation about it)

> Tetsuya, just in case you missed the early discussion about automic
> receive steering, here is a link:
>
>   http://dpdk.org/ml/archives/dev/2015-October/025779.html
>

Thanks, I've checked it!

Tetsuya



More information about the dev mailing list