From: "Eugenio Pérez" <eperezma@redhat.com>
To: qemu-devel@nongnu.org
Cc: Laurent Vivier <lvivier@redhat.com>,
Parav Pandit <parav@mellanox.com>, Cindy Lu <lulu@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
Jason Wang <jasowang@redhat.com>,
Markus Armbruster <armbru@redhat.com>,
Gautam Dawar <gdawar@xilinx.com>,
Harpreet Singh Anand <hanand@xilinx.com>,
Peter Xu <peterx@redhat.com>, Eli Cohen <eli@mellanox.com>,
Liuxiangdong <liuxiangdong5@huawei.com>,
Zhu Lingshan <lingshan.zhu@intel.com>
Subject: [RFC PATCH v4 17/20] vdpa: Add vhost_vdpa_start_control_svq
Date: Thu, 31 Mar 2022 20:04:07 +0200 [thread overview]
Message-ID: <20220331180410.531837-18-eperezma@redhat.com> (raw)
In-Reply-To: <20220331180410.531837-1-eperezma@redhat.com>
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 585d2f60f8..6dc0ae8614 100644
--- a/net/vhost-vdpa.c
+++ b/net/vhost-vdpa.c
@@ -205,10 +205,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
next prev parent reply other threads:[~2022-03-31 18:25 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-31 18:03 [RFC PATCH v4 00/20] Net Control VQ support with asid in vDPA SVQ Eugenio Pérez
2022-03-31 18:03 ` [RFC PATCH v4 01/20] vhost: Fix bad return of descriptors Eugenio Pérez
2022-03-31 18:03 ` [RFC PATCH v4 02/20] util: Return void on iova_tree_remove Eugenio Pérez
2022-03-31 18:03 ` [RFC PATCH v4 03/20] vdpa: Add x-svq to NetdevVhostVDPAOptions Eugenio Pérez
2022-03-31 18:03 ` [RFC PATCH v4 04/20] vhost: move descriptor translation to vhost_svq_vring_write_descs Eugenio Pérez
2022-03-31 18:03 ` [RFC PATCH v4 05/20] vdpa: Fix index calculus at vhost_vdpa_svqs_start Eugenio Pérez
2022-03-31 18:03 ` [RFC PATCH v4 06/20] virtio-net: use g_memdup2() instead of unsafe g_memdup() Eugenio Pérez
2022-03-31 18:03 ` [RFC PATCH v4 07/20] virtio-net: Expose ctrl virtqueue logic Eugenio Pérez
2022-03-31 18:03 ` [RFC PATCH v4 08/20] vdpa: Extract get geatures part from vhost_vdpa_get_max_queue_pairs Eugenio Pérez
2022-03-31 18:03 ` [RFC PATCH v4 09/20] virtio: Make virtqueue_alloc_element non-static Eugenio Pérez
2022-03-31 18:04 ` [RFC PATCH v4 10/20] vhost: Add SVQElement Eugenio Pérez
2022-03-31 18:04 ` [RFC PATCH v4 11/20] vhost: Add custom used buffer callback Eugenio Pérez
2022-03-31 18:04 ` [RFC PATCH v4 12/20] vdpa: control virtqueue support on shadow virtqueue Eugenio Pérez
2022-03-31 18:04 ` [RFC PATCH v4 13/20] vhost: Add vhost_iova_tree_find Eugenio Pérez
2022-03-31 18:04 ` [RFC PATCH v4 14/20] vdpa: Add map/unmap operation callback to SVQ Eugenio Pérez
2022-03-31 18:04 ` [RFC PATCH v4 15/20] vhost: Add vhost_svq_inject Eugenio Pérez
2022-03-31 18:04 ` [RFC PATCH v4 16/20] vdpa: add NetClientState->start() callback Eugenio Pérez
2022-03-31 18:04 ` Eugenio Pérez [this message]
2022-03-31 18:04 ` [RFC PATCH v4 18/20] vhost: Update kernel headers Eugenio Pérez
2022-03-31 18:04 ` [RFC PATCH v4 19/20] vdpa: Add asid attribute to vdpa device Eugenio Pérez
2022-03-31 18:04 ` [RFC PATCH v4 20/20] vdpa: Add x-cvq-svq Eugenio Pérez
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220331180410.531837-18-eperezma@redhat.com \
--to=eperezma@redhat.com \
--cc=armbru@redhat.com \
--cc=eli@mellanox.com \
--cc=gdawar@xilinx.com \
--cc=hanand@xilinx.com \
--cc=jasowang@redhat.com \
--cc=lingshan.zhu@intel.com \
--cc=liuxiangdong5@huawei.com \
--cc=lulu@redhat.com \
--cc=lvivier@redhat.com \
--cc=mst@redhat.com \
--cc=parav@mellanox.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).