[RFC PATCH 04/12] vdpa: delay set_vring_ready after DRIVER_OK

2022-07-16 Thread Eugenio Pérez
configuration. To avoid that, we will not send vring_enable until all configuration is used by the device. As a first step, reverse the DRIVER_OK and SET_VRING_ENABLE steps. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-vdpa.c | 22 -- 1 file changed, 16 insertions(+), 6

[RFC PATCH 00/12] NIC vhost-vdpa state restore via Shadow CVQ

2022-07-16 Thread Eugenio Pérez
needs SVQ CVQ support [1] and fixes [2] to be applied. Thanks! [1] https://lists.nongnu.org/archive/html/qemu-devel/2022-07/msg02808.html [2] https://lists.nongnu.org/archive/html/qemu-devel/2022-07/msg02726.html Eugenio Pérez (12): vhost: Get vring base from vq, not svq vhost: Move SVQ queue

[RFC PATCH 09/12] vdpa: Extract vhost_vdpa_net_svq_add from vhost_vdpa_net_handle_ctrl_avail

2022-07-16 Thread Eugenio Pérez
So we can reuse to inject state messages. Signed-off-by: Eugenio Pérez --- net/vhost-vdpa.c | 89 +++- 1 file changed, 51 insertions(+), 38 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 211bd0468b..aaae51a778 100644 --- a/net

[RFC PATCH 03/12] vdpa: Small rename of error labels

2022-07-16 Thread Eugenio Pérez
So later patches are cleaner Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-vdpa.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 4458c8d23e..906c365036 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost

[RFC PATCH 01/12] vhost: Get vring base from vq, not svq

2022-07-16 Thread Eugenio Pérez
the device's used idx and check for the last avail idx. Since we cannot report in-flight descriptors with vdpa, let's rewind all of them. Fixes: 6d0b22266633 ("vdpa: Adapt vhost_vdpa_get_vring_base to SVQ") Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-vdpa.c | 8 +--- 1 file changed, 5

[RFC PATCH 02/12] vhost: Move SVQ queue rewind to the destination

2022-07-16 Thread Eugenio Pérez
Migration with SVQ already migrate the inflight descriptors, so the destination can perform the work. This makes easier to migrate between backends or to recover them in vhost devices that support set in flight descriptors. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-vdpa.c | 24

[PATCH v3 19/19] vdpa: Add x-svq to NetdevVhostVDPAOptions

2022-07-15 Thread Eugenio Pérez
Finally offering the possibility to enable SVQ from the command line. Signed-off-by: Eugenio Pérez Acked-by: Markus Armbruster --- qapi/net.json| 9 +- net/vhost-vdpa.c | 72 ++-- 2 files changed, 77 insertions(+), 4 deletions(-) diff --git

[PATCH v3 14/19] vdpa: Export vhost_vdpa_dma_map and unmap calls

2022-07-15 Thread Eugenio Pérez
Shadow CVQ will copy buffers on qemu VA, so we avoid TOCTOU attacks from the guest that could set a different state in qemu device model and vdpa device. To do so, it needs to be able to map these new buffers to the device. Signed-off-by: Eugenio Pérez Acked-by: Jason Wang --- include/hw

[PATCH v3 18/19] vdpa: Add device migration blocker

2022-07-15 Thread Eugenio Pérez
Since the vhost-vdpa device is exposing _F_LOG, adding a migration blocker if it uses CVQ. Signed-off-by: Eugenio Pérez --- include/hw/virtio/vhost-vdpa.h | 1 + hw/virtio/vhost-vdpa.c | 14 ++ 2 files changed, 15 insertions(+) diff --git a/include/hw/virtio/vhost-vdpa.h b

[PATCH v3 12/19] vhost: add vhost_svq_poll

2022-07-15 Thread Eugenio Pérez
It allows the Shadow Control VirtQueue to wait for the device to use the available buffers. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.h | 1 + hw/virtio/vhost-shadow-virtqueue.c | 22 ++ 2 files changed, 23 insertions(+) diff --git a/hw/virtio/vhost

[PATCH v3 15/19] vdpa: manual forward CVQ buffers

2022-07-15 Thread Eugenio Pérez
Do a simple forwarding of CVQ buffers, the same work SVQ could do but through callbacks. No functional change intended. Signed-off-by: Eugenio Pérez --- include/hw/virtio/vhost-vdpa.h | 3 ++ hw/virtio/vhost-vdpa.c | 3 +- net/vhost-vdpa.c | 58

[PATCH v3 16/19] vdpa: Buffer CVQ support on shadow virtqueue

2022-07-15 Thread Eugenio Pérez
event will be raised. More cvq commands could be added here straightforwardly but they have not been tested. Signed-off-by: Eugenio Pérez --- net/vhost-vdpa.c | 211 +-- 1 file changed, 204 insertions(+), 7 deletions(-) diff --git a/net/vhost-vdpa.c b

[PATCH v3 10/19] vhost: add vhost_svq_push_elem

2022-07-15 Thread Eugenio Pérez
This function allows external SVQ users to return guest's available buffers. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.h | 3 +++ hw/virtio/vhost-shadow-virtqueue.c | 16 2 files changed, 19 insertions(+) diff --git a/hw/virtio/vhost-shadow-virtqueue.h

[PATCH v3 17/19] vdpa: Extract get features part from vhost_vdpa_get_max_queue_pairs

2022-07-15 Thread Eugenio Pérez
To know the device features is needed for CVQ SVQ, so SVQ knows if it can handle all commands or not. Extract from vhost_vdpa_get_max_queue_pairs so we can reuse it. Signed-off-by: Eugenio Pérez Acked-by: Jason Wang --- net/vhost-vdpa.c | 30 -- 1 file changed, 20

[PATCH v3 03/19] virtio-net: Expose ctrl virtqueue logic

2022-07-15 Thread Eugenio Pérez
This allows external vhost-net devices to modify the state of the VirtIO device model once the vhost-vdpa device has acknowledged the control commands. Signed-off-by: Eugenio Pérez --- include/hw/virtio/virtio-net.h | 4 ++ hw/net/virtio-net.c| 84

[PATCH v3 11/19] vhost: Expose vhost_svq_add

2022-07-15 Thread Eugenio Pérez
This allows external parts of SVQ to forward custom buffers to the device. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.h | 3 +++ hw/virtio/vhost-shadow-virtqueue.c | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/hw/virtio/vhost-shadow

[PATCH v3 08/19] vhost: Add SVQDescState

2022-07-15 Thread Eugenio Pérez
This will allow SVQ to add context to the different queue elements. This patch only store the actual element, no functional change intended. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.h | 8 ++-- hw/virtio/vhost-shadow-virtqueue.c | 16 2 files

[PATCH v3 09/19] vhost: Track number of descs in SVQDescState

2022-07-15 Thread Eugenio Pérez
A guest's buffer continuos on GPA may need multiple descriptors on qemu's VA, so SVQ should track its length sepparatedly. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.h | 6 ++ hw/virtio/vhost-shadow-virtqueue.c | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions

[PATCH v3 01/19] vhost: move descriptor translation to vhost_svq_vring_write_descs

2022-07-15 Thread Eugenio Pérez
It's done for both in and out descriptors so it's better placed here. Acked-by: Jason Wang Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.c | 38 +- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/hw/virtio/vhost-shadow-virtqueue.c

[PATCH v3 04/19] vhost: Reorder vhost_svq_kick

2022-07-15 Thread Eugenio Pérez
Future code needs to call it from vhost_svq_add. No functional change intended. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.c | 28 ++-- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio

[PATCH v3 07/19] vhost: Decouple vhost_svq_add from VirtQueueElement

2022-07-15 Thread Eugenio Pérez
. Signed-off-by: Eugenio Pérez Acked-by: Jason Wang --- hw/virtio/vhost-shadow-virtqueue.c | 33 -- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c index aee9891a67..b005a457c6 100644

[PATCH v3 02/19] virtio-net: Expose MAC_TABLE_ENTRIES

2022-07-15 Thread Eugenio Pérez
vhost-vdpa control virtqueue needs to know the maximum entries supported by the virtio-net device, so we know if it is possible to apply the filter. Signed-off-by: Eugenio Pérez --- include/hw/virtio/virtio-net.h | 3 +++ hw/net/virtio-net.c| 1 - 2 files changed, 3 insertions(+), 1

[PATCH v3 06/19] vhost: Check for queue full at vhost_svq_add

2022-07-15 Thread Eugenio Pérez
The series need to expose vhost_svq_add with full functionality, including checking for full queue. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.c | 59 +- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/hw/virtio/vhost-shadow

[PATCH v3 00/19] vdpa net devices Rx filter change notification with Shadow VQ

2022-07-15 Thread Eugenio Pérez
://patchwork.kernel.org/project/qemu-devel/cover/20220706184008.1649478-1-epere...@redhat.com/ Eugenio Pérez (19): vhost: move descriptor translation to vhost_svq_vring_write_descs virtio-net: Expose MAC_TABLE_ENTRIES virtio-net: Expose ctrl virtqueue logic vhost: Reorder vhost_svq_kick vhost: Move

[PATCH v3 05/19] vhost: Move vhost_svq_kick call to vhost_svq_add

2022-07-15 Thread Eugenio Pérez
The series needs to expose vhost_svq_add with full functionality, including kick Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c index

[PATCH v3 13/19] vhost: Add svq avail_handler callback

2022-07-15 Thread Eugenio Pérez
it. The callback is also free to process the command by itself and use the element with svq_push. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.h | 31 +- hw/virtio/vhost-shadow-virtqueue.c | 14 -- hw/virtio/vhost-vdpa.c | 3

[PATCH 2/2] vhost: Move SVQ queue rewind to the destination

2022-07-15 Thread Eugenio Pérez
Migration with SVQ already migrate the inflight descriptors, so the destination can perform the work. This makes easier to migrate between backends or to recover them in vhost devices that support set in flight descriptors. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-vdpa.c | 24

[PATCH 0/2] vhost: Get vring base from vq, not svq

2022-07-15 Thread Eugenio Pérez
.) Eugenio Pérez (2): vhost: Get vring base from vq, not svq vhost: Move SVQ queue rewind to the destination hw/virtio/vhost-vdpa.c | 24 1 file changed, 12 insertions(+), 12 deletions(-) -- 2.31.1

[PATCH 1/2] vhost: Get vring base from vq, not svq

2022-07-15 Thread Eugenio Pérez
the device's used idx and check for the last avail idx. Since we cannot report in-flight descriptors with vdpa, let's rewind all of them. Fixes: 6d0b22266633 ("vdpa: Adapt vhost_vdpa_get_vring_base to SVQ") Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-vdpa.c | 8 +--- 1 file changed, 5

[RFC] vhost: Move svq avail handler to virtio_net_handle_ctrl

2022-07-14 Thread Eugenio Pérez
DO NOT MERGE THIS RFC ... so we can evaluate if it is worth to move. Answering [1]. It basically makes SVQ work in two different modes: * data virtqueues works with the SVQ loop, intercepting guest's kicks and device's call. * CVQ does not move to that. Instead - It "forbid" to vhost-dev to

[PATCH v2 04/19] vhost: Reorder vhost_svq_kick

2022-07-14 Thread Eugenio Pérez
Future code needs to call it from vhost_svq_add. No functional change intended. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.c | 28 ++-- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio

[PATCH v2 18/19] vdpa: Add device migration blocker

2022-07-14 Thread Eugenio Pérez
Since the vhost-vdpa device is exposing _F_LOG, adding a migration blocker if it uses CVQ. Signed-off-by: Eugenio Pérez --- include/hw/virtio/vhost-vdpa.h | 1 + hw/virtio/vhost-vdpa.c | 14 ++ 2 files changed, 15 insertions(+) diff --git a/include/hw/virtio/vhost-vdpa.h b

[PATCH v2 13/19] vhost: Add svq avail_handler callback

2022-07-14 Thread Eugenio Pérez
it. The callback is also free to process the command by itself and use the element with svq_push. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.h | 31 +- hw/virtio/vhost-shadow-virtqueue.c | 14 -- hw/virtio/vhost-vdpa.c | 3

[PATCH v2 19/19] vdpa: Add x-svq to NetdevVhostVDPAOptions

2022-07-14 Thread Eugenio Pérez
Finally offering the possibility to enable SVQ from the command line. Signed-off-by: Eugenio Pérez Acked-by: Markus Armbruster --- qapi/net.json| 9 +- net/vhost-vdpa.c | 72 ++-- 2 files changed, 77 insertions(+), 4 deletions(-) diff --git

[PATCH v2 15/19] vdpa: manual forward CVQ buffers

2022-07-14 Thread Eugenio Pérez
Do a simple forwarding of CVQ buffers, the same work SVQ could do but through callbacks. No functional change intended. Signed-off-by: Eugenio Pérez --- include/hw/virtio/vhost-vdpa.h | 3 ++ hw/virtio/vhost-vdpa.c | 3 +- net/vhost-vdpa.c | 58

[PATCH v2 12/19] vhost: add vhost_svq_poll

2022-07-14 Thread Eugenio Pérez
It allows the Shadow Control VirtQueue to wait for the device to use the available buffers. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.h | 1 + hw/virtio/vhost-shadow-virtqueue.c | 22 ++ 2 files changed, 23 insertions(+) diff --git a/hw/virtio/vhost

[PATCH v2 16/19] vdpa: Buffer CVQ support on shadow virtqueue

2022-07-14 Thread Eugenio Pérez
event will be raised. More cvq commands could be added here straightforwardly but they have not been tested. Signed-off-by: Eugenio Pérez --- net/vhost-vdpa.c | 211 +-- 1 file changed, 204 insertions(+), 7 deletions(-) diff --git a/net/vhost-vdpa.c b

[PATCH v2 17/19] vdpa: Extract get features part from vhost_vdpa_get_max_queue_pairs

2022-07-14 Thread Eugenio Pérez
To know the device features is needed for CVQ SVQ, so SVQ knows if it can handle all commands or not. Extract from vhost_vdpa_get_max_queue_pairs so we can reuse it. Signed-off-by: Eugenio Pérez Acked-by: Jason Wang --- net/vhost-vdpa.c | 30 -- 1 file changed, 20

[PATCH v2 09/19] vhost: Track number of descs in SVQElement

2022-07-14 Thread Eugenio Pérez
Since CVQ will be able to modify elements, the number of descriptors in the guest may not match with the number of descriptors exposed. Track separately. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.h | 6 ++ hw/virtio/vhost-shadow-virtqueue.c | 10 +- 2 files

[PATCH v2 14/19] vdpa: Export vhost_vdpa_dma_map and unmap calls

2022-07-14 Thread Eugenio Pérez
Shadow CVQ will copy buffers on qemu VA, so we avoid TOCTOU attacks from the guest that could set a different state in qemu device model and vdpa device. To do so, it needs to be able to map these new buffers to the device. Signed-off-by: Eugenio Pérez Acked-by: Jason Wang --- include/hw

[PATCH v2 10/19] vhost: add vhost_svq_push_elem

2022-07-14 Thread Eugenio Pérez
This function allows external SVQ users to return guest's available buffers. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.h | 3 +++ hw/virtio/vhost-shadow-virtqueue.c | 16 2 files changed, 19 insertions(+) diff --git a/hw/virtio/vhost-shadow-virtqueue.h

[PATCH v2 05/19] vhost: Move vhost_svq_kick call to vhost_svq_add

2022-07-14 Thread Eugenio Pérez
The series needs to expose vhost_svq_add with full functionality, including kick Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c index

[PATCH v2 11/19] vhost: Expose vhost_svq_add

2022-07-14 Thread Eugenio Pérez
This allows external parts of SVQ to forward custom buffers to the device. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.h | 3 +++ hw/virtio/vhost-shadow-virtqueue.c | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/hw/virtio/vhost-shadow

[PATCH v2 08/19] vhost: Add SVQElement

2022-07-14 Thread Eugenio Pérez
This will allow SVQ to add context to the different queue elements. This patch only store the actual element, no functional change intended. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.h | 8 ++-- hw/virtio/vhost-shadow-virtqueue.c | 32

[PATCH v2 02/19] virtio-net: Expose MAC_TABLE_ENTRIES

2022-07-14 Thread Eugenio Pérez
vhost-vdpa control virtqueue needs to know the maximum entries supported by the virtio-net device, so we know if it is possible to apply the filter. Signed-off-by: Eugenio Pérez --- include/hw/virtio/virtio-net.h | 3 +++ hw/net/virtio-net.c| 1 - 2 files changed, 3 insertions(+), 1

[PATCH v2 00/19] vdpa net devices Rx filter change notification with Shadow VQ

2022-07-14 Thread Eugenio Pérez
/20220706184008.1649478-1-epere...@redhat.com/ Eugenio Pérez (19): vhost: move descriptor translation to vhost_svq_vring_write_descs virtio-net: Expose MAC_TABLE_ENTRIES virtio-net: Expose ctrl virtqueue logic vhost: Reorder vhost_svq_kick vhost: Move vhost_svq_kick call to vhost_svq_add vhost: Check

[PATCH v2 03/19] virtio-net: Expose ctrl virtqueue logic

2022-07-14 Thread Eugenio Pérez
This allows external vhost-net devices to modify the state of the VirtIO device model once the vhost-vdpa device has acknowledged the control commands. Signed-off-by: Eugenio Pérez --- include/hw/virtio/virtio-net.h | 4 ++ hw/net/virtio-net.c| 84

[PATCH v2 07/19] vhost: Decouple vhost_svq_add from VirtQueueElement

2022-07-14 Thread Eugenio Pérez
. Signed-off-by: Eugenio Pérez Acked-by: Jason Wang --- hw/virtio/vhost-shadow-virtqueue.c | 33 -- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c index aee9891a67..b005a457c6 100644

[PATCH v2 01/19] vhost: move descriptor translation to vhost_svq_vring_write_descs

2022-07-14 Thread Eugenio Pérez
It's done for both in and out descriptors so it's better placed here. Acked-by: Jason Wang Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.c | 38 +- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/hw/virtio/vhost-shadow-virtqueue.c

[PATCH v2 06/19] vhost: Check for queue full at vhost_svq_add

2022-07-14 Thread Eugenio Pérez
The series need to expose vhost_svq_add with full functionality, including checking for full queue. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.c | 59 +- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/hw/virtio/vhost-shadow

[PATCH] vdpa: Clean vhost_vdpa_dev_start(dev, false)

2022-07-12 Thread Eugenio Pérez
Return value is never checked and is a clean path, so assume success Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-vdpa.c | 33 ++--- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 66f054a12c

[PATCH] vhost: Return earlier if used buffers overrun SVQ flush

2022-07-12 Thread Eugenio Pérez
Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.c | 14 -- 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c index 56c96ebd13..9280285435 100644 --- a/hw/virtio/vhost-shadow-virtqueue.c +++ b

[PATCH 22/22] vdpa: Add x-svq to NetdevVhostVDPAOptions

2022-07-08 Thread Eugenio Pérez
Finally offering the possibility to enable SVQ from the command line. Signed-off-by: Eugenio Pérez --- qapi/net.json| 9 +- net/vhost-vdpa.c | 74 ++-- 2 files changed, 79 insertions(+), 4 deletions(-) diff --git a/qapi/net.json b/qapi

[PATCH 21/22] vdpa: Add device migration blocker

2022-07-08 Thread Eugenio Pérez
The device may need to add migration blockers. For example, if vdpa device uses features not compatible with migration. Add the possibility here. Signed-off-by: Eugenio Pérez --- include/hw/virtio/vhost-vdpa.h | 1 + hw/virtio/vhost-vdpa.c | 14 ++ 2 files changed, 15

[PATCH 14/22] vhost: Add custom used buffer callback

2022-07-08 Thread Eugenio Pérez
using vhost_svq_inject. An opaque data must be given with it, and its returned to the callback at used_handler call. In the case of networking, this will be used to inspect control virtqueue messages status from the device. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.h | 15

[PATCH 20/22] vdpa: Extract get features part from vhost_vdpa_get_max_queue_pairs

2022-07-08 Thread Eugenio Pérez
To know the device features is needed for CVQ SVQ, so SVQ knows if it can handle all commands or not. Extract from vhost_vdpa_get_max_queue_pairs so we can reuse it. Signed-off-by: Eugenio Pérez --- net/vhost-vdpa.c | 30 -- 1 file changed, 20 insertions(+), 10

[PATCH 19/22] vdpa: Buffer CVQ support on shadow virtqueue

2022-07-08 Thread Eugenio Pérez
driver changes MAC the virtio-net device model will be updated with the new one, and a rx filtering change event will be raised. Others cvq commands could be added here straightforwardly but they have been not tested. Signed-off-by: Eugenio Pérez --- net/vhost-vdpa.c | 334

[PATCH 18/22] vdpa: manual forward CVQ buffers

2022-07-08 Thread Eugenio Pérez
Do a simple forwarding of CVQ buffers, the same work SVQ could do but through callbacks. No functional change intended. Signed-off-by: Eugenio Pérez --- include/hw/virtio/vhost-vdpa.h | 3 ++ hw/virtio/vhost-vdpa.c | 3 +- net/vhost-vdpa.c | 59

[PATCH 15/22] vhost: Add svq avail_handler callback

2022-07-08 Thread Eugenio Pérez
it. The callback is also free to process the command by itself and use the element with svq_push. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.h | 23 ++- hw/virtio/vhost-shadow-virtqueue.c | 13 +++-- hw/virtio/vhost-vdpa.c | 2 +- 3 files

[PATCH 16/22] vhost: add detach SVQ operation

2022-07-08 Thread Eugenio Pérez
To notify the caller it needs to discard the element. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.h | 11 +++ hw/virtio/vhost-shadow-virtqueue.c | 11 ++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost-shadow-virtqueue.h b

[PATCH 17/22] vdpa: Export vhost_vdpa_dma_map and unmap calls

2022-07-08 Thread Eugenio Pérez
Shadow CVQ will copy buffers on qemu VA, so we avoid TOCTOU attacks that can set a different state in qemu device model and vdpa device. Signed-off-by: Eugenio Pérez --- include/hw/virtio/vhost-vdpa.h | 4 hw/virtio/vhost-vdpa.c | 7 +++ 2 files changed, 7 insertions(+), 4

[PATCH 11/22] vhost: add vhost_svq_push_elem

2022-07-08 Thread Eugenio Pérez
This function allows external SVQ users to return guest's available buffers. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.h | 2 ++ hw/virtio/vhost-shadow-virtqueue.c | 16 2 files changed, 18 insertions(+) diff --git a/hw/virtio/vhost-shadow-virtqueue.h

[PATCH 10/22] vdpa: Small rename of error labels

2022-07-08 Thread Eugenio Pérez
So later patches are cleaner Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-vdpa.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index d6ba4a492a..fccfc832ea 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost

[PATCH 06/22] vhost: Reorder vhost_svq_last_desc_of_chain

2022-07-08 Thread Eugenio Pérez
SVQ is going to store it in SVQElement, so we need it before add functions. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.c | 20 ++-- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow

[PATCH 13/22] vhost: add vhost_svq_poll

2022-07-08 Thread Eugenio Pérez
It allows the Shadow Control VirtQueue to wait the device to use the commands that restore the net device state after a live migration. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.h | 1 + hw/virtio/vhost-shadow-virtqueue.c | 54 -- 2 files

[PATCH 08/22] vhost: Move last chain id to SVQ element

2022-07-08 Thread Eugenio Pérez
We will allow SVQ user to store opaque data for each element, so its easier if we store this kind of information just at avail. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.h | 3 +++ hw/virtio/vhost-shadow-virtqueue.c | 14 -- 2 files changed, 11 insertions

[PATCH 12/22] vhost: Add vhost_svq_inject

2022-07-08 Thread Eugenio Pérez
This allows qemu to inject buffers to the device. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.h | 2 ++ hw/virtio/vhost-shadow-virtqueue.c | 37 ++ 2 files changed, 39 insertions(+) diff --git a/hw/virtio/vhost-shadow-virtqueue.h b/hw/virtio

[PATCH 03/22] vdpa: Clean vhost_vdpa_dev_start(dev, false)

2022-07-08 Thread Eugenio Pérez
Return value is never checked and is a clean path, so assume success Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-vdpa.c | 33 ++--- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 66f054a12c

[PATCH 09/22] vhost: Add opaque member to SVQElement

2022-07-08 Thread Eugenio Pérez
When qemu injects buffers to the vdpa device it will be used to maintain contextual data. If SVQ has no operation, it will be used to maintain the VirtQueueElement pointer. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.h | 3 ++- hw/virtio/vhost-shadow-virtqueue.c | 13

[PATCH 05/22] vhost: Decouple vhost_svq_add_split from VirtQueueElement

2022-07-08 Thread Eugenio Pérez
VirtQueueElement comes from the guest, but we're heading SVQ to be able to inject element without the guest's knowledge. To do so, make this accept sg buffers directly, instead of using VirtQueueElement. Add vhost_svq_add_element to maintain element convenience Signed-off-by: Eugenio Pérez

[PATCH 02/22] vhost: move descriptor translation to vhost_svq_vring_write_descs

2022-07-08 Thread Eugenio Pérez
It's done for both in and out descriptors so it's better placed here. Acked-by: Jason Wang Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.c | 38 +- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/hw/virtio/vhost-shadow-virtqueue.c

[PATCH 07/22] vhost: Add SVQElement

2022-07-08 Thread Eugenio Pérez
This will allow SVQ to add metadata to the different queue elements. To simplify changes, only store actual element at this patch. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.h | 8 -- hw/virtio/vhost-shadow-virtqueue.c | 41 -- 2 files

[PATCH 04/22] virtio-net: Expose ctrl virtqueue logic

2022-07-08 Thread Eugenio Pérez
This allows external vhost-net devices to modify the state of the VirtIO device model once vhost-vdpa device has acknowledge the control commands. Signed-off-by: Eugenio Pérez --- include/hw/virtio/virtio-net.h | 4 ++ hw/net/virtio-net.c| 84 -- 2

[PATCH 01/22] vhost: Return earlier if used buffers overrun

2022-07-08 Thread Eugenio Pérez
Previous function misses the just picked avail buffer from the queue. This way keeps blocking the used queue forever, but is cleaner to check before calling to vhost_svq_get_buf. Fixes: 100890f7cad50 ("vhost: Shadow virtqueue buffers forwarding") Acked-by: Jason Wang Signed-off-by: Eug

[PATCH 00/22] vdpa net devices Rx filter change notification with Shadow VQ

2022-07-08 Thread Eugenio Pérez
, using this work. Comments are welcome. [1] https://patchwork.kernel.org/project/qemu-devel/cover/20220706184008.1649478-1-epere...@redhat.com/ Eugenio Pérez (22): vhost: Return earlier if used buffers overrun vhost: move descriptor translation to vhost_svq_vring_write_descs vdpa: Clean

[RFC PATCH v9 18/23] vdpa: Export vhost_vdpa_dma_map and unmap calls

2022-07-06 Thread Eugenio Pérez
Shadow CVQ will copy buffers on qemu VA, so we avoid TOCTOU attacks that can set a different state in qemu device model and vdpa device. Signed-off-by: Eugenio Pérez --- include/hw/virtio/vhost-vdpa.h | 4 hw/virtio/vhost-vdpa.c | 7 +++ 2 files changed, 7 insertions(+), 4

[RFC PATCH v9 22/23] vdpa: Inject virtio-net mac address via CVQ at start

2022-07-06 Thread Eugenio Pérez
This is needed so the destination vdpa device see the same state a the guest set in the source. Signed-off-by: Eugenio Pérez --- net/vhost-vdpa.c | 49 +++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/net/vhost-vdpa.c b/net/vhost

[RFC PATCH v9 17/23] vhost: add detach SVQ operation

2022-07-06 Thread Eugenio Pérez
To notify the caller it needs to discard the element. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.h | 11 +++ hw/virtio/vhost-shadow-virtqueue.c | 11 ++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost-shadow-virtqueue.h b

[RFC PATCH v9 21/23] vdpa: Add vhost_vdpa_start_control_svq

2022-07-06 Thread Eugenio Pérez
As a first step we only enable CVQ first than others. Future patches add state restore. Signed-off-by: Eugenio Pérez --- net/vhost-vdpa.c | 19 +++ 1 file changed, 19 insertions(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index e415cc8de5..77d013833f 100644 --- a/net

[RFC PATCH v9 23/23] vdpa: Add x-svq to NetdevVhostVDPAOptions

2022-07-06 Thread Eugenio Pérez
Finally offering the possibility to enable SVQ from the command line. Signed-off-by: Eugenio Pérez --- qapi/net.json| 9 +- net/vhost-vdpa.c | 72 ++-- 2 files changed, 77 insertions(+), 4 deletions(-) diff --git a/qapi/net.json b/qapi

[RFC PATCH v9 15/23] vhost: Add custom used buffer callback

2022-07-06 Thread Eugenio Pérez
using vhost_svq_inject. An opaque data must be given with it, and its returned to the callback at used_handler call. In the case of networking, this will be used to inspect control virtqueue messages and to recover status injection at the first time. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost

[RFC PATCH v9 19/23] vdpa: Extract get features part from vhost_vdpa_get_max_queue_pairs

2022-07-06 Thread Eugenio Pérez
To know the device features is needed for CVQ SVQ, so SVQ knows if it can handle all commands or not. Extract from vhost_vdpa_get_max_queue_pairs so we can reuse it. Signed-off-by: Eugenio Pérez --- net/vhost-vdpa.c | 30 -- 1 file changed, 20 insertions(+), 10

[RFC PATCH v9 10/23] vhost: Reorder vhost_svq_last_desc_of_chain

2022-07-06 Thread Eugenio Pérez
SVQ is going to store it in SVQElement, so we need it before add functions. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.c | 20 ++-- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow

[RFC PATCH v9 16/23] vhost: Add svq avail_handler callback

2022-07-06 Thread Eugenio Pérez
it. The callback is also free to process the command by itself and use the element with svq_push. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.h | 16 hw/virtio/vhost-shadow-virtqueue.c | 8 +++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/hw

[RFC PATCH v9 14/23] vhost: add vhost_svq_poll

2022-07-06 Thread Eugenio Pérez
It allows the Shadow Control VirtQueue to wait the device to use the commands that restore the net device state after a live migration. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.h | 1 + hw/virtio/vhost-shadow-virtqueue.c | 54 -- 2 files

[RFC PATCH v9 12/23] vhost: Add opaque member to SVQElement

2022-07-06 Thread Eugenio Pérez
When qemu injects buffers to the vdpa device it will be used to maintain contextual data. If SVQ has no operation, it will be used to maintain the VirtQueueElement pointer. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.h | 3 ++- hw/virtio/vhost-shadow-virtqueue.c | 13

[RFC PATCH v9 03/23] vdpa: delay set_vring_ready after DRIVER_OK

2022-07-06 Thread Eugenio Pérez
configuration. To avoid that, we will not send vring_enable until all configuration is used by the device. As a first step, reverse the DRIVER_OK and SET_VRING_ENABLE steps. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-vdpa.c | 22 -- 1 file changed, 16 insertions(+), 6

[RFC PATCH v9 11/23] vhost: Move last chain id to SVQ element

2022-07-06 Thread Eugenio Pérez
We will allow SVQ user to store opaque data for each element, so its easier if we store this kind of information just at avail. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.h | 3 +++ hw/virtio/vhost-shadow-virtqueue.c | 14 -- 2 files changed, 11 insertions

[RFC PATCH v9 07/23] vhost: add vhost_svq_push_elem

2022-07-06 Thread Eugenio Pérez
This function allows external SVQ users to return guest's available buffers. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.h | 2 ++ hw/virtio/vhost-shadow-virtqueue.c | 16 2 files changed, 18 insertions(+) diff --git a/hw/virtio/vhost-shadow-virtqueue.h

[RFC PATCH v9 20/23] vdpa: Buffer CVQ support on shadow virtqueue

2022-07-06 Thread Eugenio Pérez
could be added here straightforwardly but they have been not tested. Signed-off-by: Eugenio Pérez --- include/hw/virtio/vhost-vdpa.h | 3 + hw/virtio/vhost-vdpa.c | 5 +- net/vhost-vdpa.c | 373 + 3 files changed, 379 insertions(+), 2

[RFC PATCH v9 09/23] vhost: Add SVQElement

2022-07-06 Thread Eugenio Pérez
This will allow SVQ to add metadata to the different queue elements. To simplify changes, only store actual element at this patch. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.h | 8 -- hw/virtio/vhost-shadow-virtqueue.c | 41 -- 2 files

[RFC PATCH v9 06/23] virtio-net: Expose ctrl virtqueue logic

2022-07-06 Thread Eugenio Pérez
This allows external vhost-net devices to modify the state of the VirtIO device model once vhost-vdpa device has acknowledge the control commands. Signed-off-by: Eugenio Pérez --- include/hw/virtio/virtio-net.h | 4 ++ hw/net/virtio-net.c| 84 -- 2

[RFC PATCH v9 02/23] vhost: move descriptor translation to vhost_svq_vring_write_descs

2022-07-06 Thread Eugenio Pérez
It's done for both in and out descriptors so it's better placed here. Acked-by: Jason Wang Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.c | 39 +- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/hw/virtio/vhost-shadow-virtqueue.c

[RFC PATCH v9 00/23] Net Control VQ support in SVQ

2022-07-06 Thread Eugenio Pérez
from rfc v3: * Fix bad returning of descriptors to SVQ list. Changes from rfc v2: * Fix use-after-free. Changes from rfc v1: * Rebase to latest master. * Configure ASID instead of assuming cvq asid != data vqs asid. * Update device model so (MAC) state can be migrated too. Eugenio Pérez (23

[RFC PATCH v9 13/23] vhost: Add vhost_svq_inject

2022-07-06 Thread Eugenio Pérez
This allows qemu to inject buffers to the device. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.h | 2 ++ hw/virtio/vhost-shadow-virtqueue.c | 34 ++ 2 files changed, 36 insertions(+) diff --git a/hw/virtio/vhost-shadow-virtqueue.h b/hw/virtio

[RFC PATCH v9 01/23] vhost: Return earlier if used buffers overrun

2022-07-06 Thread Eugenio Pérez
Previous function misses the just picked avail buffer from the queue. This way keeps blocking the used queue forever, but is cleaner to check before calling to vhost_svq_get_buf. Fixes: 100890f7cad50 ("vhost: Shadow virtqueue buffers forwarding") Signed-off-by: Eugenio Pérez --- hw/vi

[RFC PATCH v9 08/23] vhost: Decouple vhost_svq_add_split from VirtQueueElement

2022-07-06 Thread Eugenio Pérez
VirtQueueElement comes from the guest, but we're heading SVQ to be able to inject element without the guest's knowledge. To do so, make this accept sg buffers directly, instead of using VirtQueueElement. Add vhost_svq_add_element to maintain element convenience Signed-off-by: Eugenio Pérez

[RFC PATCH v9 05/23] vhost: Add ShadowVirtQueueStart operation

2022-07-06 Thread Eugenio Pérez
It allows to run commands at SVQ start. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.h | 18 +- hw/virtio/vhost-shadow-virtqueue.c | 8 +++- hw/virtio/vhost-vdpa.c | 17 - 3 files changed, 40 insertions(+), 3 deletions

[RFC PATCH v9 04/23] vhost: Get vring base from vq, not svq

2022-07-06 Thread Eugenio Pérez
The used idx used to match with this, but it will not match from the moment we introduce svq_inject. Rewind all the descriptors not used by vdpa device and get the vq state properly. Signed-off-by: Eugenio Pérez --- include/hw/virtio/virtio.h | 1 + hw/virtio/vhost-vdpa.c | 7 +++ hw

[RFC PATCH v8 21/21] vdpa: Add x-cvq-svq

2022-05-19 Thread Eugenio Pérez
This isolates shadow cvq in its own group. Signed-off-by: Eugenio Pérez --- qapi/net.json| 8 ++- net/vhost-vdpa.c | 134 --- 2 files changed, 133 insertions(+), 9 deletions(-) diff --git a/qapi/net.json b/qapi/net.json index cd7a1b32fe

<    3   4   5   6   7   8   9   10   11   12   >