[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v2 32/44] vhost-vdpa: classify one time request
From: |
Michael S. Tsirkin |
Subject: |
[PULL v2 32/44] vhost-vdpa: classify one time request |
Date: |
Wed, 20 Oct 2021 06:20:43 -0400 |
From: Jason Wang <jasowang@redhat.com>
Vhost-vdpa uses one device multiqueue queue (pairs) model. So we need
to classify the one time request (e.g SET_OWNER) and make sure those
request were only called once per device.
This is used for multiqueue support.
Signed-off-by: Jason Wang <jasowang@redhat.com>
Message-Id: <20211020045600.16082-3-jasowang@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
include/hw/virtio/vhost-vdpa.h | 1 +
hw/virtio/vhost-vdpa.c | 53 ++++++++++++++++++++++++++++++----
2 files changed, 48 insertions(+), 6 deletions(-)
diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h
index c288cf7ecb..3ce79a646d 100644
--- a/include/hw/virtio/vhost-vdpa.h
+++ b/include/hw/virtio/vhost-vdpa.h
@@ -22,6 +22,7 @@ typedef struct VhostVDPAHostNotifier {
typedef struct vhost_vdpa {
int device_fd;
+ int index;
uint32_t msg_type;
bool iotlb_batch_begin_sent;
MemoryListener listener;
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index 47c48f4ba8..ceb53613ba 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -319,6 +319,13 @@ static void vhost_vdpa_get_iova_range(struct vhost_vdpa *v)
v->iova_range.last);
}
+static bool vhost_vdpa_one_time_request(struct vhost_dev *dev)
+{
+ struct vhost_vdpa *v = dev->opaque;
+
+ return v->index != 0;
+}
+
static int vhost_vdpa_init(struct vhost_dev *dev, void *opaque, Error **errp)
{
struct vhost_vdpa *v;
@@ -332,6 +339,11 @@ static int vhost_vdpa_init(struct vhost_dev *dev, void
*opaque, Error **errp)
v->msg_type = VHOST_IOTLB_MSG_V2;
vhost_vdpa_get_iova_range(v);
+
+ if (vhost_vdpa_one_time_request(dev)) {
+ return 0;
+ }
+
vhost_vdpa_add_status(dev, VIRTIO_CONFIG_S_ACKNOWLEDGE |
VIRTIO_CONFIG_S_DRIVER);
@@ -442,6 +454,10 @@ static int vhost_vdpa_memslots_limit(struct vhost_dev *dev)
static int vhost_vdpa_set_mem_table(struct vhost_dev *dev,
struct vhost_memory *mem)
{
+ if (vhost_vdpa_one_time_request(dev)) {
+ return 0;
+ }
+
trace_vhost_vdpa_set_mem_table(dev, mem->nregions, mem->padding);
if (trace_event_get_state_backends(TRACE_VHOST_VDPA_SET_MEM_TABLE) &&
trace_event_get_state_backends(TRACE_VHOST_VDPA_DUMP_REGIONS)) {
@@ -465,6 +481,11 @@ static int vhost_vdpa_set_features(struct vhost_dev *dev,
uint64_t features)
{
int ret;
+
+ if (vhost_vdpa_one_time_request(dev)) {
+ return 0;
+ }
+
trace_vhost_vdpa_set_features(dev, features);
ret = vhost_vdpa_call(dev, VHOST_SET_FEATURES, &features);
uint8_t status = 0;
@@ -489,9 +510,12 @@ static int vhost_vdpa_set_backend_cap(struct vhost_dev
*dev)
}
features &= f;
- r = vhost_vdpa_call(dev, VHOST_SET_BACKEND_FEATURES, &features);
- if (r) {
- return -EFAULT;
+
+ if (vhost_vdpa_one_time_request(dev)) {
+ r = vhost_vdpa_call(dev, VHOST_SET_BACKEND_FEATURES, &features);
+ if (r) {
+ return -EFAULT;
+ }
}
dev->backend_cap = features;
@@ -600,11 +624,21 @@ static int vhost_vdpa_dev_start(struct vhost_dev *dev,
bool started)
{
struct vhost_vdpa *v = dev->opaque;
trace_vhost_vdpa_dev_start(dev, started);
+
+ if (started) {
+ vhost_vdpa_host_notifiers_init(dev);
+ vhost_vdpa_set_vring_ready(dev);
+ } else {
+ vhost_vdpa_host_notifiers_uninit(dev, dev->nvqs);
+ }
+
+ if (vhost_vdpa_one_time_request(dev)) {
+ return 0;
+ }
+
if (started) {
uint8_t status = 0;
memory_listener_register(&v->listener, &address_space_memory);
- vhost_vdpa_host_notifiers_init(dev);
- vhost_vdpa_set_vring_ready(dev);
vhost_vdpa_add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK);
vhost_vdpa_call(dev, VHOST_VDPA_GET_STATUS, &status);
@@ -613,7 +647,6 @@ static int vhost_vdpa_dev_start(struct vhost_dev *dev, bool
started)
vhost_vdpa_reset_device(dev);
vhost_vdpa_add_status(dev, VIRTIO_CONFIG_S_ACKNOWLEDGE |
VIRTIO_CONFIG_S_DRIVER);
- vhost_vdpa_host_notifiers_uninit(dev, dev->nvqs);
memory_listener_unregister(&v->listener);
return 0;
@@ -623,6 +656,10 @@ static int vhost_vdpa_dev_start(struct vhost_dev *dev,
bool started)
static int vhost_vdpa_set_log_base(struct vhost_dev *dev, uint64_t base,
struct vhost_log *log)
{
+ if (vhost_vdpa_one_time_request(dev)) {
+ return 0;
+ }
+
trace_vhost_vdpa_set_log_base(dev, base, log->size, log->refcnt, log->fd,
log->log);
return vhost_vdpa_call(dev, VHOST_SET_LOG_BASE, &base);
@@ -688,6 +725,10 @@ static int vhost_vdpa_get_features(struct vhost_dev *dev,
static int vhost_vdpa_set_owner(struct vhost_dev *dev)
{
+ if (vhost_vdpa_one_time_request(dev)) {
+ return 0;
+ }
+
trace_vhost_vdpa_set_owner(dev);
return vhost_vdpa_call(dev, VHOST_SET_OWNER, NULL);
}
--
MST
- [PULL v2 18/44] vdpa: Check for iova range at mappings changes, (continued)
- [PULL v2 18/44] vdpa: Check for iova range at mappings changes, Michael S. Tsirkin, 2021/10/20
- [PULL v2 24/44] docs: Add documentation for vhost based RNG implementation, Michael S. Tsirkin, 2021/10/20
- [PULL v2 26/44] failover: fix a regression introduced by JSON'ification of -device, Michael S. Tsirkin, 2021/10/20
- [PULL v2 27/44] vhost-user-blk-test: pass vhost-user socket fds to QSD, Michael S. Tsirkin, 2021/10/20
- [PULL v2 25/44] vhost-user: fix duplicated notifier MR init, Michael S. Tsirkin, 2021/10/20
- [PULL v2 22/44] vhost-user-rng: Add vhost-user-rng implementation, Michael S. Tsirkin, 2021/10/20
- [PULL v2 29/44] rebuild-expected-aml.sh: allow partial target list, Michael S. Tsirkin, 2021/10/20
- [PULL v2 30/44] bios-tables-test: don't disassemble empty files, Michael S. Tsirkin, 2021/10/20
- [PULL v2 28/44] qdev/qbus: remove failover specific code, Michael S. Tsirkin, 2021/10/20
- [PULL v2 33/44] vhost-vdpa: prepare for the multiqueue support, Michael S. Tsirkin, 2021/10/20
- [PULL v2 32/44] vhost-vdpa: classify one time request,
Michael S. Tsirkin <=
- [PULL v2 34/44] vhost-vdpa: let net_vhost_vdpa_init() returns NetClientState *, Michael S. Tsirkin, 2021/10/20
- [PULL v2 31/44] vhost-vdpa: open device fd in net_init_vhost_vdpa(), Michael S. Tsirkin, 2021/10/20
- [PULL v2 36/44] vhost-net: control virtqueue support, Michael S. Tsirkin, 2021/10/20
- [PULL v2 35/44] net: introduce control client, Michael S. Tsirkin, 2021/10/20
- [PULL v2 37/44] virtio-net: use "queue_pairs" instead of "queues" when possible, Michael S. Tsirkin, 2021/10/20
- [PULL v2 38/44] vhost: record the last virtqueue index for the virtio device, Michael S. Tsirkin, 2021/10/20
- [PULL v2 39/44] virtio-net: vhost control virtqueue support, Michael S. Tsirkin, 2021/10/20
- [PULL v2 40/44] vhost-vdpa: multiqueue support, Michael S. Tsirkin, 2021/10/20
- [PULL v2 42/44] tests/acpi/bios-tables-test: add and allow changes to a new q35 DSDT table blob, Michael S. Tsirkin, 2021/10/20
- [PULL v2 41/44] pci: fix PCI resource reserve capability on BE, Michael S. Tsirkin, 2021/10/20