Since there may be many commands we need to issue to load the NIC state, let's split them in individual functions
Signed-off-by: Eugenio Pérez <epere...@redhat.com> --- net/vhost-vdpa.c | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 97b658f412..1e0dbfcced 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -363,21 +363,10 @@ static ssize_t vhost_vdpa_net_cvq_add(VhostVDPAState *s, size_t out_len, return vhost_svq_poll(svq); } -static int vhost_vdpa_net_load(NetClientState *nc) +static int vhost_vdpa_net_load_mac(VhostVDPAState *s, + const VirtIONet *n) { - VhostVDPAState *s = DO_UPCAST(VhostVDPAState, nc, nc); - const struct vhost_vdpa *v = &s->vhost_vdpa; - const VirtIONet *n; - uint64_t features; - - assert(nc->info->type == NET_CLIENT_DRIVER_VHOST_VDPA); - - if (!v->shadow_vqs_enabled) { - return 0; - } - - n = VIRTIO_NET(v->dev->vdev); - features = n->parent_obj.guest_features; + uint64_t features = n->parent_obj.guest_features; if (features & BIT_ULL(VIRTIO_NET_F_CTRL_MAC_ADDR)) { const struct virtio_net_ctrl_hdr ctrl = { .class = VIRTIO_NET_CTRL_MAC, @@ -402,6 +391,28 @@ static int vhost_vdpa_net_load(NetClientState *nc) return 0; } +static int vhost_vdpa_net_load(NetClientState *nc) +{ + VhostVDPAState *s = DO_UPCAST(VhostVDPAState, nc, nc); + struct vhost_vdpa *v = &s->vhost_vdpa; + const VirtIONet *n; + int r; + + assert(nc->info->type == NET_CLIENT_DRIVER_VHOST_VDPA); + + if (!v->shadow_vqs_enabled) { + return 0; + } + + n = VIRTIO_NET(v->dev->vdev); + r = vhost_vdpa_net_load_mac(s, n); + if (unlikely(r < 0)) { + return r; + } + + return 0; +} + static NetClientInfo net_vhost_vdpa_cvq_info = { .type = NET_CLIENT_DRIVER_VHOST_VDPA, .size = sizeof(VhostVDPAState), -- 2.31.1