From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
To: virtualization@lists.linux-foundation.org
Cc: edgar.iglesias@xilinx.com, linux@arm.linux.org.uk,
mst@redhat.com, michal.simek@xilinx.com, j.wu@xilinx.com
Subject: [RFC 1/4] virtio_ring: Break out vring descriptor setup code
Date: Fri, 1 May 2015 15:01:44 +1000 [thread overview]
Message-ID: <1430456507-26862-2-git-send-email-edgar.iglesias@gmail.com> (raw)
In-Reply-To: <1430456507-26862-1-git-send-email-edgar.iglesias@gmail.com>
From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
Break out descriptor setup into a separate inline function.
No functional change.
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
---
drivers/virtio/virtio_ring.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index 096b857..66d2cb9 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -120,6 +120,16 @@ static struct vring_desc *alloc_indirect(struct virtqueue *_vq,
return desc;
}
+static inline void vring_desc_set(struct virtio_device *vdev,
+ struct vring_desc *desc,
+ struct scatterlist *sg,
+ unsigned int flags)
+{
+ desc->flags = cpu_to_virtio16(vdev, flags);
+ desc->addr = cpu_to_virtio64(vdev, sg_phys(sg));
+ desc->len = cpu_to_virtio32(vdev, sg->length);
+}
+
static inline int virtqueue_add(struct virtqueue *_vq,
struct scatterlist *sgs[],
unsigned int total_sg,
@@ -205,18 +215,16 @@ static inline int virtqueue_add(struct virtqueue *_vq,
for (n = 0; n < out_sgs; n++) {
for (sg = sgs[n]; sg; sg = sg_next(sg)) {
- desc[i].flags = cpu_to_virtio16(_vq->vdev, VRING_DESC_F_NEXT);
- desc[i].addr = cpu_to_virtio64(_vq->vdev, sg_phys(sg));
- desc[i].len = cpu_to_virtio32(_vq->vdev, sg->length);
+ vring_desc_set(_vq->vdev, desc + i, sg,
+ VRING_DESC_F_NEXT);
prev = i;
i = virtio16_to_cpu(_vq->vdev, desc[i].next);
}
}
for (; n < (out_sgs + in_sgs); n++) {
for (sg = sgs[n]; sg; sg = sg_next(sg)) {
- desc[i].flags = cpu_to_virtio16(_vq->vdev, VRING_DESC_F_NEXT | VRING_DESC_F_WRITE);
- desc[i].addr = cpu_to_virtio64(_vq->vdev, sg_phys(sg));
- desc[i].len = cpu_to_virtio32(_vq->vdev, sg->length);
+ vring_desc_set(_vq->vdev, desc + i, sg,
+ VRING_DESC_F_NEXT | VRING_DESC_F_WRITE);
prev = i;
i = virtio16_to_cpu(_vq->vdev, desc[i].next);
}
--
1.9.1
next prev parent reply other threads:[~2015-05-01 5:01 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-01 5:01 [RFC 0/4] rpmsg: Fix init of DMA:able virtqueues Edgar E. Iglesias
2015-05-01 5:01 ` Edgar E. Iglesias [this message]
2015-05-01 5:01 ` [RFC 2/4] virtio_ring: Add option for DMA mapped sgs in virtqueue_add Edgar E. Iglesias
2015-05-01 5:01 ` [RFC 3/4] virtio: Add dma variants of virtqueue_add_in and outbuf Edgar E. Iglesias
2015-05-01 5:01 ` [RFC 4/4] rpmsg: DMA map sgs passed to virtio Edgar E. Iglesias
2015-05-06 6:21 ` Rusty Russell
2015-05-07 0:28 ` Edgar E. Iglesias
2015-05-16 9:32 ` Ohad Ben-Cohen
2015-06-23 5:17 ` Michael S. Tsirkin
2015-06-23 11:46 ` Edgar E. Iglesias
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=1430456507-26862-2-git-send-email-edgar.iglesias@gmail.com \
--to=edgar.iglesias@gmail.com \
--cc=edgar.iglesias@xilinx.com \
--cc=j.wu@xilinx.com \
--cc=linux@arm.linux.org.uk \
--cc=michal.simek@xilinx.com \
--cc=mst@redhat.com \
--cc=virtualization@lists.linux-foundation.org \
/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;
as well as URLs for NNTP newsgroup(s).