[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH v5 19/23] vdpa: Add vhost_vdpa_start_control_svq
From: |
Eugenio Pérez |
Subject: |
[RFC PATCH v5 19/23] vdpa: Add vhost_vdpa_start_control_svq |
Date: |
Fri, 8 Apr 2022 15:34:11 +0200 |
This will send CVQ commands in the destination machine, seting up
everything o there is no guest-visible change.
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
net/vhost-vdpa.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 63 insertions(+)
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
index a83da4616c..09fcc4a88e 100644
--- a/net/vhost-vdpa.c
+++ b/net/vhost-vdpa.c
@@ -206,10 +206,73 @@ static ssize_t vhost_vdpa_receive(NetClientState *nc,
const uint8_t *buf,
return 0;
}
+static bool vhost_vdpa_start_control_svq(VhostShadowVirtqueue *svq,
+ VirtIODevice *vdev)
+{
+ VirtIONet *n = VIRTIO_NET(vdev);
+ uint64_t features = vdev->host_features;
+
+ if (features & BIT_ULL(VIRTIO_NET_F_CTRL_MAC_ADDR)) {
+ const struct virtio_net_ctrl_hdr ctrl = {
+ .class = VIRTIO_NET_CTRL_MAC,
+ .cmd = VIRTIO_NET_CTRL_MAC_ADDR_SET,
+ };
+ uint8_t mac[6];
+ const struct iovec data[] = {
+ {
+ .iov_base = (void *)&ctrl,
+ .iov_len = sizeof(ctrl),
+ },{
+ .iov_base = mac,
+ .iov_len = sizeof(mac),
+ },{
+ .iov_base = NULL,
+ .iov_len = sizeof(virtio_net_ctrl_ack),
+ }
+ };
+ bool ret;
+
+ /* TODO: Only best effort? */
+ memcpy(mac, n->mac, sizeof(mac));
+ ret = vhost_svq_inject(svq, data, 2, 1);
+ if (!ret) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+static void vhost_vdpa_start(NetClientState *nc)
+{
+ assert(nc->info->type == NET_CLIENT_DRIVER_VHOST_VDPA);
+ VhostVDPAState *s = DO_UPCAST(VhostVDPAState, nc, nc);
+ struct vhost_vdpa *v = &s->vhost_vdpa;
+ struct vhost_dev *dev = &s->vhost_net->dev;
+ VhostShadowVirtqueue *svq;
+
+ if (nc->is_datapath) {
+ /* This is not the cvq dev */
+ return;
+ }
+
+ if (dev->vq_index + dev->nvqs != dev->vq_index_end) {
+ return;
+ }
+
+ if (!v->shadow_vqs_enabled) {
+ return;
+ }
+
+ svq = g_ptr_array_index(v->shadow_vqs, 0);
+ vhost_vdpa_start_control_svq(svq, dev->vdev);
+}
+
static NetClientInfo net_vhost_vdpa_info = {
.type = NET_CLIENT_DRIVER_VHOST_VDPA,
.size = sizeof(VhostVDPAState),
.receive = vhost_vdpa_receive,
+ .start = vhost_vdpa_start,
.cleanup = vhost_vdpa_cleanup,
.has_vnet_hdr = vhost_vdpa_has_vnet_hdr,
.has_ufo = vhost_vdpa_has_ufo,
--
2.27.0
- [RFC PATCH v5 10/23] vdpa: Extract get features part from vhost_vdpa_get_max_queue_pairs, (continued)
- [RFC PATCH v5 10/23] vdpa: Extract get features part from vhost_vdpa_get_max_queue_pairs, Eugenio Pérez, 2022/04/08
- [RFC PATCH v5 11/23] virtio: Make virtqueue_alloc_element non-static, Eugenio Pérez, 2022/04/08
- [RFC PATCH v5 12/23] vhost: Add SVQElement, Eugenio Pérez, 2022/04/08
- [RFC PATCH v5 13/23] vhost: Add custom used buffer callback, Eugenio Pérez, 2022/04/08
- [RFC PATCH v5 15/23] vhost: Add vhost_iova_tree_find, Eugenio Pérez, 2022/04/08
- [RFC PATCH v5 14/23] vdpa: control virtqueue support on shadow virtqueue, Eugenio Pérez, 2022/04/08
- [RFC PATCH v5 16/23] vdpa: Add map/unmap operation callback to SVQ, Eugenio Pérez, 2022/04/08
- [RFC PATCH v5 17/23] vhost: Add vhost_svq_inject, Eugenio Pérez, 2022/04/08
- [RFC PATCH v5 18/23] vdpa: add NetClientState->start() callback, Eugenio Pérez, 2022/04/08
- [RFC PATCH v5 21/23] vhost: Make possible to check for device exclusive vq group, Eugenio Pérez, 2022/04/08
- [RFC PATCH v5 19/23] vdpa: Add vhost_vdpa_start_control_svq,
Eugenio Pérez <=
- [RFC PATCH v5 20/23] vhost: Update kernel headers, Eugenio Pérez, 2022/04/08
- [RFC PATCH v5 22/23] vdpa: Add asid attribute to vdpa device, Eugenio Pérez, 2022/04/08
- [RFC PATCH v5 23/23] vdpa: Add x-cvq-svq, Eugenio Pérez, 2022/04/08