qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Cindy Lu <lulu@redhat.com>
To: lulu@redhat.com, mst@redhat.com, jasowang@redhat.com,
	qemu-devel@nongnu.org
Subject: [RFC 4/7] net/vhost-vdpa: Add the check for iommufd
Date: Wed,  3 May 2023 17:13:34 +0800	[thread overview]
Message-ID: <20230503091337.2130631-5-lulu@redhat.com> (raw)
In-Reply-To: <20230503091337.2130631-1-lulu@redhat.com>

Add the check for object iommufd, if the iommfd enabled.
pass the information to vhost_vdpa.
vhost_vdpa dev start will check this bool and connect
to the iommufd

Signed-off-by: Cindy Lu <lulu@redhat.com>
---
 net/vhost-vdpa.c | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
index 1a13a34d35..d4819c28e1 100644
--- a/net/vhost-vdpa.c
+++ b/net/vhost-vdpa.c
@@ -659,16 +659,12 @@ static const VhostShadowVirtqueueOps vhost_vdpa_net_svq_ops = {
     .avail_handler = vhost_vdpa_net_handle_ctrl_avail,
 };
 
-static NetClientState *net_vhost_vdpa_init(NetClientState *peer,
-                                       const char *device,
-                                       const char *name,
-                                       int vdpa_device_fd,
-                                       int queue_pair_index,
-                                       int nvqs,
-                                       bool is_datapath,
-                                       bool svq,
-                                       struct vhost_vdpa_iova_range iova_range,
-                                       VhostIOVATree *iova_tree)
+static NetClientState *
+net_vhost_vdpa_init(NetClientState *peer, const char *device, const char *name,
+                    int vdpa_device_fd, int queue_pair_index, int nvqs,
+                    bool is_datapath, bool svq, bool enable_iommufd,
+                    struct vhost_vdpa_iova_range iova_range,
+                    VhostIOVATree *iova_tree)
 {
     NetClientState *nc = NULL;
     VhostVDPAState *s;
@@ -691,6 +687,7 @@ static NetClientState *net_vhost_vdpa_init(NetClientState *peer,
     s->vhost_vdpa.iova_range = iova_range;
     s->vhost_vdpa.shadow_data = svq;
     s->vhost_vdpa.iova_tree = iova_tree;
+    s->vhost_vdpa.enable_iommufd = enable_iommufd;
     if (!is_datapath) {
         s->cvq_cmd_out_buffer = qemu_memalign(qemu_real_host_page_size(),
                                             vhost_vdpa_net_cvq_cmd_page_len());
@@ -793,6 +790,12 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
         }
     }
 
+    bool enable_iommufd = false;
+    if (opts->iommufd) {
+        enable_iommufd = true;
+        printf("[%s] %d called\n", __func__, __LINE__);
+    }
+
     r = vhost_vdpa_get_features(vdpa_device_fd, &features, errp);
     if (unlikely(r < 0)) {
         goto err;
@@ -825,15 +828,15 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
     for (i = 0; i < queue_pairs; i++) {
         ncs[i] = net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name,
                                      vdpa_device_fd, i, 2, true, opts->x_svq,
-                                     iova_range, iova_tree);
+                                     enable_iommufd, iova_range, iova_tree);
         if (!ncs[i])
             goto err;
     }
 
     if (has_cvq) {
-        nc = net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name,
-                                 vdpa_device_fd, i, 1, false,
-                                 opts->x_svq, iova_range, iova_tree);
+        nc = net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, vdpa_device_fd, i,
+                                 1, false, opts->x_svq, enable_iommufd,
+                                 iova_range, iova_tree);
         if (!nc)
             goto err;
     }
-- 
2.34.3



  parent reply	other threads:[~2023-05-03  9:17 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-03  9:13 [RFC 0/7] vhost-vdpa: add support for iommufd Cindy Lu
2023-05-03  9:13 ` [RFC 1/7] vhost: introduce new UAPI to support IOMMUFD Cindy Lu
2023-05-03  9:13 ` [RFC 2/7] qapi: support iommufd in vdpa Cindy Lu
2023-05-03  9:13 ` [RFC 3/7] virtio : add a ptr for vdpa_iommufd in VirtIODevice Cindy Lu
2023-05-03  9:13 ` Cindy Lu [this message]
2023-05-03  9:13 ` [RFC 5/7] vhost-vdpa: Add the iommufd support in the map/unmap function Cindy Lu
2023-05-03  9:13 ` [RFC 6/7] vhost-vdpa: init iommufd function in vhost_vdpa start Cindy Lu
2023-05-03  9:13 ` [RFC 7/7] vhost-vdpa-iommufd: Add iommufd support for vdpa Cindy Lu
2023-05-05  3:29 ` [RFC 0/7] vhost-vdpa: add support for iommufd Jason Wang
2023-05-05  6:29   ` Cindy Lu
2023-06-05  5:41     ` Michael S. Tsirkin
2023-06-05  8:04       ` Cindy Lu
2023-09-13 13:31 ` Michael S. Tsirkin
2023-09-14  5:44   ` Cindy Lu

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=20230503091337.2130631-5-lulu@redhat.com \
    --to=lulu@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=mst@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).