virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: Shannon Nelson via Virtualization <virtualization@lists.linux-foundation.org>
To: <jasowang@redhat.com>, <mst@redhat.com>,
	<virtualization@lists.linux-foundation.org>
Cc: drivers@pensando.io
Subject: [PATCH v2 3/3] vhost_vdpa: support PACKED when setting-getting vring_base
Date: Mon, 24 Apr 2023 15:50:31 -0700	[thread overview]
Message-ID: <20230424225031.18947-4-shannon.nelson@amd.com> (raw)
In-Reply-To: <20230424225031.18947-1-shannon.nelson@amd.com>

Use the right structs for PACKED or split vqs when setting and
getting the vring base.

Signed-off-by: Shannon Nelson <shannon.nelson@amd.com>
---
 drivers/vhost/vdpa.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
index 599b8cc238c7..fe392b67d5be 100644
--- a/drivers/vhost/vdpa.c
+++ b/drivers/vhost/vdpa.c
@@ -585,7 +585,14 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,
 		if (r)
 			return r;
 
-		vq->last_avail_idx = vq_state.split.avail_index;
+		if (vhost_has_feature(vq, VIRTIO_F_RING_PACKED)) {
+			vq->last_avail_idx = vq_state.packed.last_avail_idx |
+					     (vq_state.packed.last_avail_counter << 15);
+			vq->last_used_idx = vq_state.packed.last_used_idx |
+					    (vq_state.packed.last_used_counter << 15);
+		} else {
+			vq->last_avail_idx = vq_state.split.avail_index;
+		}
 		break;
 	}
 
@@ -603,9 +610,15 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,
 		break;
 
 	case VHOST_SET_VRING_BASE:
-		vq_state.split.avail_index = vq->last_avail_idx;
-		if (ops->set_vq_state(vdpa, idx, &vq_state))
-			r = -EINVAL;
+		if (vhost_has_feature(vq, VIRTIO_F_RING_PACKED)) {
+			vq_state.packed.last_avail_idx = vq->last_avail_idx & 0x7fff;
+			vq_state.packed.last_avail_counter = !!(vq->last_avail_idx & 0x8000);
+			vq_state.packed.last_used_idx = vq->last_used_idx & 0x7fff;
+			vq_state.packed.last_used_counter = !!(vq->last_used_idx & 0x8000);
+		} else {
+			vq_state.split.avail_index = vq->last_avail_idx;
+		}
+		r = ops->set_vq_state(vdpa, idx, &vq_state);
 		break;
 
 	case VHOST_SET_VRING_CALL:
-- 
2.17.1

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

  parent reply	other threads:[~2023-04-24 22:50 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-24 22:50 [PATCH v2 0/3] vhost_vdpa: better PACKED support Shannon Nelson via Virtualization
2023-04-24 22:50 ` [PATCH v2 1/3] vhost_vdpa: tell vqs about the negotiated Shannon Nelson via Virtualization
2023-04-24 22:50 ` [PATCH v2 2/3] vhost: support PACKED when setting-getting vring_base Shannon Nelson via Virtualization
2023-04-25  6:01   ` Jason Wang
2023-05-09  8:46   ` Stefano Garzarella
2023-05-15 20:41     ` Shannon Nelson via Virtualization
2023-05-16  7:49       ` Stefano Garzarella
2023-05-16 18:26         ` Shannon Nelson via Virtualization
2023-05-17  5:26           ` Jason Wang
2023-05-17  7:00             ` Stefano Garzarella
2023-05-18  5:23               ` Jason Wang
2023-05-18  7:34                 ` Stefano Garzarella
2023-05-18  7:52                   ` Jason Wang
2023-05-18  8:38                     ` Michael S. Tsirkin
2023-05-18  8:59                       ` Jason Wang
2023-05-18  9:42                         ` Michael S. Tsirkin
2023-06-02 11:36                   ` Michael S. Tsirkin
2023-06-05  8:17                     ` Stefano Garzarella
2023-04-24 22:50 ` Shannon Nelson via Virtualization [this message]
2023-04-25  6:02   ` [PATCH v2 3/3] vhost_vdpa: " Jason Wang
2023-04-25  6:08 ` [PATCH v2 0/3] vhost_vdpa: better PACKED support Michael S. Tsirkin
2023-04-25 16:21   ` Shannon Nelson via Virtualization

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=20230424225031.18947-4-shannon.nelson@amd.com \
    --to=virtualization@lists.linux-foundation.org \
    --cc=drivers@pensando.io \
    --cc=jasowang@redhat.com \
    --cc=mst@redhat.com \
    --cc=shannon.nelson@amd.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;
as well as URLs for NNTP newsgroup(s).