summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorSi-Wei Liu <si-wei.liu@oracle.com>2024-02-14 03:27:54 -0800
committerMichael S. Tsirkin <mst@redhat.com>2024-03-12 17:56:55 -0400
commit77c3a336a44272e8a6e9b18c6b765f08aa84151f (patch)
tree2584a5118214c1065937802582299f6274eeb741
parentc812b0655f8ccd1def48f14b89cec07e8fb68d83 (diff)
downloadfocaccia-qemu-77c3a336a44272e8a6e9b18c6b765f08aa84151f.tar.gz
focaccia-qemu-77c3a336a44272e8a6e9b18c6b765f08aa84151f.zip
vdpa: factor out vhost_vdpa_net_get_nc_vdpa
Introduce new API. No functional change on existing API.

Message-Id: <1707910082-10243-5-git-send-email-si-wei.liu@oracle.com>
Reviewed-by: Eugenio Pérez <eperezma@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-rw-r--r--net/vhost-vdpa.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
index 1d9496cdd9..85efda9e67 100644
--- a/net/vhost-vdpa.c
+++ b/net/vhost-vdpa.c
@@ -288,13 +288,18 @@ static ssize_t vhost_vdpa_receive(NetClientState *nc, const uint8_t *buf,
 }
 
 
-/** From any vdpa net client, get the netclient of the first queue pair */
-static VhostVDPAState *vhost_vdpa_net_first_nc_vdpa(VhostVDPAState *s)
+/** From any vdpa net client, get the netclient of the i-th queue pair */
+static VhostVDPAState *vhost_vdpa_net_get_nc_vdpa(VhostVDPAState *s, int i)
 {
     NICState *nic = qemu_get_nic(s->nc.peer);
-    NetClientState *nc0 = qemu_get_peer(nic->ncs, 0);
+    NetClientState *nc_i = qemu_get_peer(nic->ncs, i);
+
+    return DO_UPCAST(VhostVDPAState, nc, nc_i);
+}
 
-    return DO_UPCAST(VhostVDPAState, nc, nc0);
+static VhostVDPAState *vhost_vdpa_net_first_nc_vdpa(VhostVDPAState *s)
+{
+    return vhost_vdpa_net_get_nc_vdpa(s, 0);
 }
 
 static void vhost_vdpa_net_log_global_enable(VhostVDPAState *s, bool enable)