[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RESEND Patch v1 33/37] vhost-pci-net: send the negotiated
From: |
Wei Wang |
Subject: |
[Qemu-devel] [RESEND Patch v1 33/37] vhost-pci-net: send the negotiated feature bits to the master |
Date: |
Mon, 19 Dec 2016 13:59:08 +0800 |
The slave actively sends the negotiated feature bits to the master.
"need_send" is used to detect if the 64-bit feature bits are ready to
be sent.
Signed-off-by: Wei Wang <address@hidden>
---
hw/net/vhost-pci-net.c | 13 +++++++++++++
hw/virtio/vhost-pci-slave.c | 21 +++++++++++++++++++++
include/hw/virtio/vhost-pci-slave.h | 2 ++
3 files changed, 36 insertions(+)
diff --git a/hw/net/vhost-pci-net.c b/hw/net/vhost-pci-net.c
index 5ad4a9f..8e30281 100644
--- a/hw/net/vhost-pci-net.c
+++ b/hw/net/vhost-pci-net.c
@@ -15,6 +15,7 @@
#include "qemu/osdep.h"
#include "qemu/iov.h"
+#include "qemu/error-report.h"
#include "hw/virtio/virtio-access.h"
#include "hw/virtio/vhost-pci-net.h"
@@ -139,6 +140,18 @@ static uint64_t vpnet_get_features(VirtIODevice *vdev,
uint64_t features,
static void vpnet_set_features(VirtIODevice *vdev, uint64_t features)
{
+ static bool need_send;
+ int ret;
+
+ if (need_send) {
+ need_send = 0;
+ ret = vp_slave_send_feature_bits(features);
+ if (ret < 0) {
+ error_report("failed to send feature bits to the master");
+ }
+ } else {
+ need_send = 1;
+ }
}
static void vpnet_get_config(VirtIODevice *vdev, uint8_t *config)
diff --git a/hw/virtio/vhost-pci-slave.c b/hw/virtio/vhost-pci-slave.c
index de08324..a966885 100644
--- a/hw/virtio/vhost-pci-slave.c
+++ b/hw/virtio/vhost-pci-slave.c
@@ -88,6 +88,27 @@ static void vp_slave_set_features(VhostUserMsg *msg)
& ~(1 << VHOST_USER_F_PROTOCOL_FEATURES);
}
+static int vp_slave_send_u64(int request, uint64_t u64)
+{
+ VhostUserMsg msg = {
+ .request = request,
+ .flags = VHOST_USER_VERSION,
+ .payload.u64 = u64,
+ .size = sizeof(msg.payload.u64),
+ };
+
+ if (vp_slave_write(&vp_slave->chr_be, &msg) < 0) {
+ return -1;
+ }
+
+ return 0;
+}
+
+int vp_slave_send_feature_bits(uint64_t features)
+{
+ return vp_slave_send_u64(VHOST_USER_SET_FEATURES, features);
+}
+
static DeviceState *virtio_to_pci_dev(VirtIODevice *vdev, uint16_t virtio_id)
{
DeviceState *qdev;
diff --git a/include/hw/virtio/vhost-pci-slave.h
b/include/hw/virtio/vhost-pci-slave.h
index 79e1ffd..e60580a 100644
--- a/include/hw/virtio/vhost-pci-slave.h
+++ b/include/hw/virtio/vhost-pci-slave.h
@@ -40,4 +40,6 @@ extern int vhost_pci_slave_init(QemuOpts *opts);
extern int vhost_pci_slave_cleanup(void);
+extern int vp_slave_send_feature_bits(uint64_t features);
+
#endif
--
2.7.4
- [Qemu-devel] [RESEND Patch v1 20/37] vhost-pci-slave/msg: VHOST_USER_SET_VRING_KICK, (continued)
- [Qemu-devel] [RESEND Patch v1 20/37] vhost-pci-slave/msg: VHOST_USER_SET_VRING_KICK, Wei Wang, 2016/12/19
- [Qemu-devel] [RESEND Patch v1 19/37] vhost-pci-slave/msg: VHOST_USER_SET_VRING_ADDR, Wei Wang, 2016/12/19
- [Qemu-devel] [RESEND Patch v1 23/37] vhost-pci-slave/msg: VHOST_USER_SET_LOG_BASE, Wei Wang, 2016/12/19
- [Qemu-devel] [RESEND Patch v1 24/37] vhost-pci-slave/msg: VHOST_USER_SET_LOG_FD, Wei Wang, 2016/12/19
- [Qemu-devel] [RESEND Patch v1 25/37] vhost-pci-slave/msg: VHOST_USER_SEND_RARP, Wei Wang, 2016/12/19
- [Qemu-devel] [RESEND Patch v1 26/37] vhost-pci-slave/msg: VHOST_USER_GET_VRING_BASE, Wei Wang, 2016/12/19
- [Qemu-devel] [RESEND Patch v1 28/37] vhost-pci-net: pass the mem and vring info to the driver, Wei Wang, 2016/12/19
- [Qemu-devel] [RESEND Patch v1 27/37] vhost-pci-net: pass the info collected by vp_slave to the device, Wei Wang, 2016/12/19
- [Qemu-devel] [RESEND Patch v1 29/37] vhost-pci-slave/msg: VHOST_USER_SET_VHOST_PCI (start), Wei Wang, 2016/12/19
- [Qemu-devel] [RESEND Patch v1 30/37] vhost-pci-slave/msg: VHOST_USER_SET_VHOST_PCI (stop), Wei Wang, 2016/12/19
- [Qemu-devel] [RESEND Patch v1 33/37] vhost-pci-net: send the negotiated feature bits to the master,
Wei Wang <=
- [Qemu-devel] [RESEND Patch v1 31/37] vhost-user/msg: send VHOST_USER_SET_VHOST_PCI (start/stop), Wei Wang, 2016/12/19
- [Qemu-devel] [RESEND Patch v1 32/37] vhost-user: add asynchronous read for the vhost-user master, Wei Wang, 2016/12/19
- [Qemu-devel] [RESEND Patch v1 34/37] vhost-pci-slave: add "peer_reset", Wei Wang, 2016/12/19
- [Qemu-devel] [RESEND Patch v1 35/37] vhost-pci-net: start the vhost-pci-net device, Wei Wang, 2016/12/19
- [Qemu-devel] [RESEND Patch v1 37/37] vl: enable vhost-pci-slave, Wei Wang, 2016/12/19
- [Qemu-devel] [RESEND Patch v1 36/37] vhost-user/msg: handling VHOST_USER_SET_FEATURES, Wei Wang, 2016/12/19
- Re: [Qemu-devel] [RESEND Patch v1 00/37] Implementation of vhost-pci for inter-vm commucation, no-reply, 2016/12/19
- Re: [Qemu-devel] [RESEND Patch v1 00/37] Implementation of vhost-pci for inter-vm commucation, Marc-André Lureau, 2016/12/19