public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Pierre Morel <pmorel@linux.ibm.com>
To: Andrew Jones <drjones@redhat.com>
Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, david@redhat.com,
	thuth@redhat.com, cohuck@redhat.com, imbrenda@linux.ibm.com
Subject: Re: [kvm-unit-tests PATCH 5/7] virtio: implement the virtio_add_inbuf routine
Date: Mon, 8 Nov 2021 13:36:46 +0100	[thread overview]
Message-ID: <5c073705-b6ca-e64d-31fa-1bd5aaedb45c@linux.ibm.com> (raw)
In-Reply-To: <20211103075131.xgnysvcfbal2r6z4@gator.home>



On 11/3/21 08:51, Andrew Jones wrote:
> On Fri, Aug 27, 2021 at 12:17:18PM +0200, Pierre Morel wrote:
>> To communicate in both directions with a VIRTIO device we need
>> to add the incoming communication to the VIRTIO level.
>>
>> Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
>> ---
>>   lib/virtio.c | 32 ++++++++++++++++++++++++++++++++
>>   lib/virtio.h |  2 ++
>>   2 files changed, 34 insertions(+)
>>
>> diff --git a/lib/virtio.c b/lib/virtio.c
>> index e10153b9..b84bc680 100644
>> --- a/lib/virtio.c
>> +++ b/lib/virtio.c
>> @@ -47,6 +47,38 @@ void vring_init_virtqueue(struct vring_virtqueue *vq, unsigned index,
>>   	vq->data[i] = NULL;
>>   }
>>   
>> +int virtqueue_add_inbuf(struct virtqueue *_vq, char *buf, unsigned int len)
>> +{
>> +	struct vring_virtqueue *vq = to_vvq(_vq);
>> +	unsigned int avail;
>> +	int head;
>> +
>> +	assert(buf);
>> +	assert(len);
>> +
>> +	if (!vq->vq.num_free)
>> +		return -1;
>> +
>> +	--vq->vq.num_free;
>> +
>> +	head = vq->free_head;
>> +
>> +	vq->vring.desc[head].flags = 0;
>> +	vq->vring.desc[head].addr = virt_to_phys(buf);
>> +	vq->vring.desc[head].len = len;
>> +
>> +	vq->free_head = vq->vring.desc[head].next;
>> +
>> +	vq->data[head] = buf;
>> +
>> +	avail = (vq->vring.avail->idx & (vq->vring.num - 1));
>> +	vq->vring.avail->ring[avail] = head;
>> +	wmb();	/* be sure to update the ring before updating the idx */
>> +	vq->vring.avail->idx++;
>> +	vq->num_added++;
>> +
>> +	return 0;
>> +}
>>   int virtqueue_add_outbuf(struct virtqueue *_vq, char *buf, unsigned int len)
>>   {
>>   	struct vring_virtqueue *vq = to_vvq(_vq);
>> diff --git a/lib/virtio.h b/lib/virtio.h
>> index 2c31fdc7..44b727f8 100644
>> --- a/lib/virtio.h
>> +++ b/lib/virtio.h
>> @@ -141,6 +141,8 @@ extern void vring_init_virtqueue(struct vring_virtqueue *vq, unsigned index,
>>   				 const char *name);
>>   extern int virtqueue_add_outbuf(struct virtqueue *vq, char *buf,
>>   				unsigned int len);
>> +extern int virtqueue_add_inbuf(struct virtqueue *vq, char *buf,
>> +			       unsigned int len);
>>   extern bool virtqueue_kick(struct virtqueue *vq);
>>   extern void detach_buf(struct vring_virtqueue *vq, unsigned head);
>>   extern void *virtqueue_get_buf(struct virtqueue *_vq, unsigned int *len);
>> -- 
>> 2.25.1
>>
> 
> Reviewed-by: Andrew Jones <drjones@redhat.com>
> 

Thanks,
Pierre


-- 
Pierre Morel
IBM Lab Boeblingen

  reply	other threads:[~2021-11-08 12:36 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-27 10:17 [kvm-unit-tests PATCH 0/7] Extending VIRTIO with a data transfer test Pierre Morel
2021-08-27 10:17 ` [kvm-unit-tests PATCH 1/7] arm: virtio: move VIRTIO transport initialization inside virtio-mmio Pierre Morel
2021-11-03  7:00   ` Thomas Huth
2021-11-03  7:41     ` Andrew Jones
2021-11-08 12:20       ` Pierre Morel
2021-08-27 10:17 ` [kvm-unit-tests PATCH 2/7] s390x: css: add callback for emnumeration Pierre Morel
2021-11-03  7:29   ` Thomas Huth
2021-11-08 12:21     ` Pierre Morel
2021-08-27 10:17 ` [kvm-unit-tests PATCH 3/7] s390x: virtio: CCW transport implementation Pierre Morel
2021-11-03  7:46   ` Andrew Jones
2021-11-08 12:35     ` Pierre Morel
2021-11-03  7:49   ` Thomas Huth
2021-11-08 12:34     ` Pierre Morel
2021-11-09  7:01       ` Thomas Huth
2021-11-09  8:51         ` Pierre Morel
2021-08-27 10:17 ` [kvm-unit-tests PATCH 4/7] s390x: css: registering IRQ Pierre Morel
2021-11-03  8:01   ` Thomas Huth
2021-11-08 12:36     ` Pierre Morel
2021-08-27 10:17 ` [kvm-unit-tests PATCH 5/7] virtio: implement the virtio_add_inbuf routine Pierre Morel
2021-11-03  7:51   ` Andrew Jones
2021-11-08 12:36     ` Pierre Morel [this message]
2021-08-27 10:17 ` [kvm-unit-tests PATCH 6/7] s390x: virtio tests setup Pierre Morel
2021-11-03  7:56   ` Andrew Jones
2021-11-03  8:14     ` Thomas Huth
2021-11-08 13:00       ` Pierre Morel
2021-11-09  7:10         ` Thomas Huth
2021-11-09  8:42           ` Andrew Jones
2021-11-09  9:01             ` Pierre Morel
2021-11-08 12:53     ` Pierre Morel
2021-08-27 10:17 ` [kvm-unit-tests PATCH 7/7] s390x: virtio data transfer Pierre Morel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5c073705-b6ca-e64d-31fa-1bd5aaedb45c@linux.ibm.com \
    --to=pmorel@linux.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=david@redhat.com \
    --cc=drjones@redhat.com \
    --cc=frankja@linux.ibm.com \
    --cc=imbrenda@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox