[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v1 21/24] vfio-user: pci reset
From: |
John Johnson |
Subject: |
[PATCH v1 21/24] vfio-user: pci reset |
Date: |
Tue, 8 Nov 2022 15:13:43 -0800 |
Message to tell the server to reset the device.
Signed-off-by: Elena Ufimtseva <elena.ufimtseva@oracle.com>
Signed-off-by: John G Johnson <john.g.johnson@oracle.com>
Signed-off-by: Jagannathan Raman <jag.raman@oracle.com>
---
hw/vfio/pci.c | 15 +++++++++++++++
hw/vfio/user.c | 12 ++++++++++++
hw/vfio/user.h | 1 +
3 files changed, 28 insertions(+)
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 559b20d..005fcf8 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -3829,6 +3829,20 @@ static void vfio_user_instance_finalize(Object *obj)
}
}
+static void vfio_user_pci_reset(DeviceState *dev)
+{
+ VFIOPCIDevice *vdev = VFIO_PCI_BASE(dev);
+ VFIODevice *vbasedev = &vdev->vbasedev;
+
+ vfio_pci_pre_reset(vdev);
+
+ if (vbasedev->reset_works) {
+ vfio_user_reset(vbasedev->proxy);
+ }
+
+ vfio_pci_post_reset(vdev);
+}
+
static Property vfio_user_pci_dev_properties[] = {
DEFINE_PROP_STRING("socket", VFIOUserPCIDevice, sock_name),
DEFINE_PROP_BOOL("secure-dma", VFIOUserPCIDevice, secure_dma, false),
@@ -3842,6 +3856,7 @@ static void vfio_user_pci_dev_class_init(ObjectClass
*klass, void *data)
DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *pdc = PCI_DEVICE_CLASS(klass);
+ dc->reset = vfio_user_pci_reset;
device_class_set_props(dc, vfio_user_pci_dev_properties);
dc->desc = "VFIO over socket PCI device assignment";
pdc->realize = vfio_user_pci_realize;
diff --git a/hw/vfio/user.c b/hw/vfio/user.c
index 56b3616..ddf9e13 100644
--- a/hw/vfio/user.c
+++ b/hw/vfio/user.c
@@ -1580,6 +1580,18 @@ static int vfio_user_region_write(VFIOProxy *proxy,
uint8_t index, off_t offset,
return ret;
}
+void vfio_user_reset(VFIOProxy *proxy)
+{
+ VFIOUserHdr msg;
+
+ vfio_user_request_msg(&msg, VFIO_USER_DEVICE_RESET, sizeof(msg), 0);
+
+ vfio_user_send_wait(proxy, &msg, NULL, 0, false);
+ if (msg.flags & VFIO_USER_ERROR) {
+ error_printf("reset reply error %d\n", msg.error_reply);
+ }
+}
+
/*
* Socket-based io_ops
diff --git a/hw/vfio/user.h b/hw/vfio/user.h
index 18e3112..d88ffe5 100644
--- a/hw/vfio/user.h
+++ b/hw/vfio/user.h
@@ -96,6 +96,7 @@ int vfio_user_validate_version(VFIOProxy *proxy, Error
**errp);
void vfio_user_send_reply(VFIOProxy *proxy, VFIOUserHdr *hdr, int size);
void vfio_user_send_error(VFIOProxy *proxy, VFIOUserHdr *hdr, int error);
void vfio_user_putfds(VFIOUserMsg *msg);
+void vfio_user_reset(VFIOProxy *proxy);
extern VFIODevIO vfio_dev_io_sock;
extern VFIOContIO vfio_cont_io_sock;
--
1.8.3.1
- [PATCH v1 03/24] vfio-user: add container IO ops vector, (continued)
- [PATCH v1 03/24] vfio-user: add container IO ops vector, John Johnson, 2022/11/08
- [PATCH v1 02/24] vfio-user: add VFIO base abstract class, John Johnson, 2022/11/08
- [PATCH v1 10/24] vfio-user: get device info, John Johnson, 2022/11/08
- [PATCH v1 05/24] vfio-user: add device IO ops vector, John Johnson, 2022/11/08
- [PATCH v1 08/24] vfio-user: define socket receive functions, John Johnson, 2022/11/08
- [PATCH v1 01/24] vfio-user: introduce vfio-user protocol specification, John Johnson, 2022/11/08
- [PATCH v1 14/24] vfio-user: get and set IRQs, John Johnson, 2022/11/08
- [PATCH v1 17/24] vfio-user: dma map/unmap operations, John Johnson, 2022/11/08
- [PATCH v1 19/24] vfio-user: secure DMA support, John Johnson, 2022/11/08
- [PATCH v1 12/24] vfio-user: region read/write, John Johnson, 2022/11/08
- [PATCH v1 21/24] vfio-user: pci reset,
John Johnson <=
- [PATCH v1 07/24] vfio-user: connect vfio proxy to remote server, John Johnson, 2022/11/08
- [PATCH v1 16/24] vfio-user: proxy container connect/disconnect, John Johnson, 2022/11/08
- [PATCH v1 18/24] vfio-user: add dma_unmap_all, John Johnson, 2022/11/08
- [PATCH v1 22/24] vfio-user: add 'x-msg-timeout' option that specifies msg wait times, John Johnson, 2022/11/08
- [PATCH v1 20/24] vfio-user: dma read/write operations, John Johnson, 2022/11/08
- [PATCH v1 23/24] vfio-user: add coalesced posted writes, John Johnson, 2022/11/08
- [PATCH v1 15/24] vfio-user: forward msix BAR accesses to server, John Johnson, 2022/11/08
- [PATCH v1 13/24] vfio-user: pci_user_realize PCI setup, John Johnson, 2022/11/08
- [PATCH v1 11/24] vfio-user: get region info, John Johnson, 2022/11/08
- [PATCH v1 24/24] vfio-user: add trace points, John Johnson, 2022/11/08