From nobody Mon May 20 20:10:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664266308; cv=none; d=zohomail.com; s=zohoarc; b=Wjezf5U7kQ+IrAPxDxkugadQZ6jMhfdWLc4du5aGD4p66au+1o3Wki4sTeDy8jmQu8WX43xjHoAMLs4Snli0cedj2gARfssDCyJQFxSma3zoYYIkJ4BvH+rBQwrM/w/apLQeZAAtIOp9p3eJzxTnahsuRcwopq/kpxF3c+QX8UQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664266308; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=uiLtQ7op7uNuXOe4ggw13CBcCs3U+ChvC4yFgB0L8wc=; b=J355CZlDpperkHfDOWn3Wnzcd1uEk+7/l12pMwmW6vhS60kOmgDyHuadNOg9Yzlualz/JddbA0PM64PQMj2zQMeTPFUjNz2o6LbNQCevkK7KAqg/u/tc4u/4/faQKUmNO1j2j/Gz6jhZlHlwjUhNDzyvXakC4MgJGfg1jtzSR00= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664266308744385.7364396938117; Tue, 27 Sep 2022 01:11:48 -0700 (PDT) Received: from localhost ([::1]:46746 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od5gx-0003e6-0T for importer@patchew.org; Tue, 27 Sep 2022 04:11:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60390) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od537-0003Yr-3i for qemu-devel@nongnu.org; Tue, 27 Sep 2022 03:30:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:33165) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od533-0001hO-GS for qemu-devel@nongnu.org; Tue, 27 Sep 2022 03:30:34 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-92-gL7JNTJ0N1WjckI-YYsm_g-1; Tue, 27 Sep 2022 03:30:31 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ED8F638164CD; Tue, 27 Sep 2022 07:30:30 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-192.pek2.redhat.com [10.72.13.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 412952166B26; Tue, 27 Sep 2022 07:30:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664263832; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uiLtQ7op7uNuXOe4ggw13CBcCs3U+ChvC4yFgB0L8wc=; b=D/M+n7346p+znjzzsf+1FXY2FqlU9z41hTYYgrcKUBi0HlkEqnS5J5giwbt8v6Y4VanmbY LXiM376sMoHOOqWQWTMC/Ta/Ctw5XUcOi+B7lkzyuET1RjZ2sikzbo3DHcDyv05Jhmh0Ow 9cDEo9xU+09Z80z3Sp4GWV8NOM1+E4g= X-MC-Unique: gL7JNTJ0N1WjckI-YYsm_g-1 From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org, stefanha@redhat.com Cc: Ding Hui , Jason Wang Subject: [PULL 1/8] e1000e: set RX desc status with DD flag in a separate operation Date: Tue, 27 Sep 2022 15:30:15 +0800 Message-Id: <20220927073022.28378-2-jasowang@redhat.com> In-Reply-To: <20220927073022.28378-1-jasowang@redhat.com> References: <20220927073022.28378-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664266310697100001 Content-Type: text/plain; charset="utf-8" From: Ding Hui Like commit 034d00d48581 ("e1000: set RX descriptor status in a separate operation"), there is also same issue in e1000e, which would cause lost packets or stop sending packets to VM with DPDK. Do similar fix in e1000e. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/402 Signed-off-by: Ding Hui Signed-off-by: Jason Wang --- hw/net/e1000e_core.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++= +++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c index 82aa61f..fc9cdb4 100644 --- a/hw/net/e1000e_core.c +++ b/hw/net/e1000e_core.c @@ -1364,6 +1364,57 @@ struct NetRxPkt *pkt, const E1000E_RSSInfo *rss_info, } } =20 +static inline void +e1000e_pci_dma_write_rx_desc(E1000ECore *core, dma_addr_t addr, + uint8_t *desc, dma_addr_t len) +{ + PCIDevice *dev =3D core->owner; + + if (e1000e_rx_use_legacy_descriptor(core)) { + struct e1000_rx_desc *d =3D (struct e1000_rx_desc *) desc; + size_t offset =3D offsetof(struct e1000_rx_desc, status); + uint8_t status =3D d->status; + + d->status &=3D ~E1000_RXD_STAT_DD; + pci_dma_write(dev, addr, desc, len); + + if (status & E1000_RXD_STAT_DD) { + d->status =3D status; + pci_dma_write(dev, addr + offset, &status, sizeof(status)); + } + } else { + if (core->mac[RCTL] & E1000_RCTL_DTYP_PS) { + union e1000_rx_desc_packet_split *d =3D + (union e1000_rx_desc_packet_split *) desc; + size_t offset =3D offsetof(union e1000_rx_desc_packet_split, + wb.middle.status_error); + uint32_t status =3D d->wb.middle.status_error; + + d->wb.middle.status_error &=3D ~E1000_RXD_STAT_DD; + pci_dma_write(dev, addr, desc, len); + + if (status & E1000_RXD_STAT_DD) { + d->wb.middle.status_error =3D status; + pci_dma_write(dev, addr + offset, &status, sizeof(status)); + } + } else { + union e1000_rx_desc_extended *d =3D + (union e1000_rx_desc_extended *) desc; + size_t offset =3D offsetof(union e1000_rx_desc_extended, + wb.upper.status_error); + uint32_t status =3D d->wb.upper.status_error; + + d->wb.upper.status_error &=3D ~E1000_RXD_STAT_DD; + pci_dma_write(dev, addr, desc, len); + + if (status & E1000_RXD_STAT_DD) { + d->wb.upper.status_error =3D status; + pci_dma_write(dev, addr + offset, &status, sizeof(status)); + } + } + } +} + typedef struct e1000e_ba_state_st { uint16_t written[MAX_PS_BUFFERS]; uint8_t cur_idx; @@ -1600,7 +1651,7 @@ e1000e_write_packet_to_guest(E1000ECore *core, struct= NetRxPkt *pkt, =20 e1000e_write_rx_descr(core, desc, is_last ? core->rx_pkt : NULL, rss_info, do_ps ? ps_hdr_len : 0, &bastate.writ= ten); - pci_dma_write(d, base, &desc, core->rx_desc_len); + e1000e_pci_dma_write_rx_desc(core, base, desc, core->rx_desc_len); =20 e1000e_ring_advance(core, rxi, core->rx_desc_len / E1000_MIN_RX_DESC_LEN); --=20 2.7.4 From nobody Mon May 20 20:10:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664265576; cv=none; d=zohomail.com; s=zohoarc; b=PUNCoOUPN0AQ5rH1sfRMu+i94JdXZ0JhfCPmjkk3ZWvnRpBb0ZJNrVHpDvkoWQCUtZ4JAiuooKWxI18irsMkUN2VCPyt0zPajMpPr7KFLmg94K9GHa7qaayAPxYl27UUqy4666oOuEQ06Ff6LZ3e/n6LnFCgTX4wSWW7DEsy6gw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664265576; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=b5CT0z2HWjzrIlnQMdbwEix/LI0y6xGLoifOSrUKFs8=; b=jBQAY2ke0vWz6PFD28WzzHt19MQjgY0TSC1H9kxAR6dR1/VOLg23RICCAqFmkCcPfzNzLxFb3+Q6gyWAy560UAHtdFvQ3+AIb1fXRqlSt+8w1D7E8jPLDJ52yRnbOW97Yc/wt2DlfvOxR3qY1gL+rMQOdqrX4LASMIwy5dQgJpQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664265576654956.4348813477498; Tue, 27 Sep 2022 00:59:36 -0700 (PDT) Received: from localhost ([::1]:44654 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od5V6-00015n-H0 for importer@patchew.org; Tue, 27 Sep 2022 03:59:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51104) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od53A-0003a1-9t for qemu-devel@nongnu.org; Tue, 27 Sep 2022 03:30:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.145.221.124]:56438) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od538-0001hk-Ha for qemu-devel@nongnu.org; Tue, 27 Sep 2022 03:30:40 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-2-myZ5mWu0O1ecmwKW2Bl5Yg-1; Tue, 27 Sep 2022 03:30:34 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2F1E9299E752; Tue, 27 Sep 2022 07:30:34 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-192.pek2.redhat.com [10.72.13.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id AFD9C2166B26; Tue, 27 Sep 2022 07:30:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664263837; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=b5CT0z2HWjzrIlnQMdbwEix/LI0y6xGLoifOSrUKFs8=; b=QMlKHgv8l47HCaRx/DJnbUJKhfJbgA8Xd56Sd19AgRr2bQyIWuEJ1pq/uWmd39y4IztnzB EiIlOtrGdZmxnG8UZw1bmqrFlYSiN4aGU+IBG1WJt4yupjulbFGpEEHymUu3LU1X98LGF4 9UE6AiKAWn0QrR9jAwI3wiLUa0/BbNk= X-MC-Unique: myZ5mWu0O1ecmwKW2Bl5Yg-1 From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org, stefanha@redhat.com Cc: =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Jason Wang Subject: [PULL 2/8] vdpa: Make VhostVDPAState cvq_cmd_in_buffer control ack type Date: Tue, 27 Sep 2022 15:30:16 +0800 Message-Id: <20220927073022.28378-3-jasowang@redhat.com> In-Reply-To: <20220927073022.28378-1-jasowang@redhat.com> References: <20220927073022.28378-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: permerror client-ip=216.145.221.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_FAIL=0.001, SPF_HELO_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664265577655100001 From: Eugenio P=C3=A9rez This allows to simplify the code. Rename to status while we're at it. Signed-off-by: Eugenio P=C3=A9rez Signed-off-by: Jason Wang --- net/vhost-vdpa.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 6ce68fc..535315c 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -35,7 +35,9 @@ typedef struct VhostVDPAState { VHostNetState *vhost_net; =20 /* Control commands shadow buffers */ - void *cvq_cmd_out_buffer, *cvq_cmd_in_buffer; + void *cvq_cmd_out_buffer; + virtio_net_ctrl_ack *status; + bool started; } VhostVDPAState; =20 @@ -158,7 +160,7 @@ static void vhost_vdpa_cleanup(NetClientState *nc) struct vhost_dev *dev =3D &s->vhost_net->dev; =20 qemu_vfree(s->cvq_cmd_out_buffer); - qemu_vfree(s->cvq_cmd_in_buffer); + qemu_vfree(s->status); if (dev->vq_index + dev->nvqs =3D=3D dev->vq_index_end) { g_clear_pointer(&s->vhost_vdpa.iova_tree, vhost_iova_tree_delete); } @@ -310,7 +312,7 @@ static int vhost_vdpa_net_cvq_start(NetClientState *nc) return r; } =20 - r =3D vhost_vdpa_cvq_map_buf(&s->vhost_vdpa, s->cvq_cmd_in_buffer, + r =3D vhost_vdpa_cvq_map_buf(&s->vhost_vdpa, s->status, vhost_vdpa_net_cvq_cmd_page_len(), true); if (unlikely(r < 0)) { vhost_vdpa_cvq_unmap_buf(&s->vhost_vdpa, s->cvq_cmd_out_buffer); @@ -327,7 +329,7 @@ static void vhost_vdpa_net_cvq_stop(NetClientState *nc) =20 if (s->vhost_vdpa.shadow_vqs_enabled) { vhost_vdpa_cvq_unmap_buf(&s->vhost_vdpa, s->cvq_cmd_out_buffer); - vhost_vdpa_cvq_unmap_buf(&s->vhost_vdpa, s->cvq_cmd_in_buffer); + vhost_vdpa_cvq_unmap_buf(&s->vhost_vdpa, s->status); } } =20 @@ -340,7 +342,7 @@ static ssize_t vhost_vdpa_net_cvq_add(VhostVDPAState *s= , size_t out_len, .iov_len =3D out_len, }; const struct iovec in =3D { - .iov_base =3D s->cvq_cmd_in_buffer, + .iov_base =3D s->status, .iov_len =3D sizeof(virtio_net_ctrl_ack), }; VhostShadowVirtqueue *svq =3D g_ptr_array_index(s->vhost_vdpa.shadow_v= qs, 0); @@ -396,7 +398,7 @@ static int vhost_vdpa_net_load(NetClientState *nc) return dev_written; } =20 - return *((virtio_net_ctrl_ack *)s->cvq_cmd_in_buffer) !=3D VIRTIO_= NET_OK; + return *s->status !=3D VIRTIO_NET_OK; } =20 return 0; @@ -491,8 +493,7 @@ static int vhost_vdpa_net_handle_ctrl_avail(VhostShadow= Virtqueue *svq, goto out; } =20 - memcpy(&status, s->cvq_cmd_in_buffer, sizeof(status)); - if (status !=3D VIRTIO_NET_OK) { + if (*s->status !=3D VIRTIO_NET_OK) { return VIRTIO_NET_ERR; } =20 @@ -549,9 +550,9 @@ static NetClientState *net_vhost_vdpa_init(NetClientSta= te *peer, s->cvq_cmd_out_buffer =3D qemu_memalign(qemu_real_host_page_size(), vhost_vdpa_net_cvq_cmd_page_le= n()); memset(s->cvq_cmd_out_buffer, 0, vhost_vdpa_net_cvq_cmd_page_len()= ); - s->cvq_cmd_in_buffer =3D qemu_memalign(qemu_real_host_page_size(), - vhost_vdpa_net_cvq_cmd_page_le= n()); - memset(s->cvq_cmd_in_buffer, 0, vhost_vdpa_net_cvq_cmd_page_len()); + s->status =3D qemu_memalign(qemu_real_host_page_size(), + vhost_vdpa_net_cvq_cmd_page_len()); + memset(s->status, 0, vhost_vdpa_net_cvq_cmd_page_len()); =20 s->vhost_vdpa.shadow_vq_ops =3D &vhost_vdpa_net_svq_ops; s->vhost_vdpa.shadow_vq_ops_opaque =3D s; --=20 2.7.4 From nobody Mon May 20 20:10:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664266740; cv=none; d=zohomail.com; s=zohoarc; b=enx/VOGHX/B0Y4TbQP3pWS2q4ouelj4wM/sE0agOdaVfEYUxI817qZK5hsEYEKZtKZd7rm9B+rMBa4ZJWeA2TpoiCwubKdXnApAkkOa5C0EaLLtcJwbUSQD0ibM771vEXaf3PD9G5ZyfpfAxHJp+RSWoeU5wNcJOFZtfPi1eeA0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664266740; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JplQTJWTbG9gRV1fp7fRMpJe21kg973WGoQ0hw0mNG8=; b=K6xAC882r/Y9e7BlVDEtZINpsL2cf0ZcUDtAqvWhuF7j2gtzfjXNUtSoMlFgK8DAv9IrPrWeixRAMdokVp3RyIrVgmSHNEnrfSxxEf7EjPi1xy7cprl8PgURNgQLPq2Ipd+UrS11azb6Ja1Nq88ld0nabnYIk7NnNcVW3oukJMU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664266740596912.3627184919474; Tue, 27 Sep 2022 01:19:00 -0700 (PDT) Received: from localhost ([::1]:58690 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od5nv-0003jx-GP for importer@patchew.org; Tue, 27 Sep 2022 04:18:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51106) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od53E-0003bj-4G for qemu-devel@nongnu.org; Tue, 27 Sep 2022 03:30:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:42974) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od53C-0001iF-M5 for qemu-devel@nongnu.org; Tue, 27 Sep 2022 03:30:43 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-64-dDGj1lsXN6q34TV1XagkzQ-1; Tue, 27 Sep 2022 03:30:37 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 20F7285A583; Tue, 27 Sep 2022 07:30:37 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-192.pek2.redhat.com [10.72.13.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id CC6492166B26; Tue, 27 Sep 2022 07:30:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664263841; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JplQTJWTbG9gRV1fp7fRMpJe21kg973WGoQ0hw0mNG8=; b=JvPZLk0qJs+aNcD2F1IqdjGd0ristjhJaLjGHrK+ekCQWy4bNMPA0K2jHDqanmXQqrT+Se fdPJfYZDJFE2M52Gx8T16e3JqqlUKHNuG92MvKNytK51DEygOXOHuVC/3AjITywllYVro5 C+re+iboVhrvzCuQS3nZaqp+ph0zpYk= X-MC-Unique: dDGj1lsXN6q34TV1XagkzQ-1 From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org, stefanha@redhat.com Cc: =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Jason Wang Subject: [PULL 3/8] vdpa: extract vhost_vdpa_net_load_mac from vhost_vdpa_net_load Date: Tue, 27 Sep 2022 15:30:17 +0800 Message-Id: <20220927073022.28378-4-jasowang@redhat.com> In-Reply-To: <20220927073022.28378-1-jasowang@redhat.com> References: <20220927073022.28378-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664266741339100001 From: Eugenio P=C3=A9rez 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=C3=A9rez Signed-off-by: Jason Wang --- net/vhost-vdpa.c | 62 ++++++++++++++++++++++++++++++++++++----------------= ---- 1 file changed, 40 insertions(+), 22 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 535315c..e799e74 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -365,12 +365,47 @@ static ssize_t vhost_vdpa_net_cvq_add(VhostVDPAState = *s, size_t out_len, return vhost_svq_poll(svq); } =20 +static ssize_t vhost_vdpa_net_load_cmd(VhostVDPAState *s, uint8_t class, + uint8_t cmd, const void *data, + size_t data_size) +{ + const struct virtio_net_ctrl_hdr ctrl =3D { + .class =3D class, + .cmd =3D cmd, + }; + + assert(data_size < vhost_vdpa_net_cvq_cmd_page_len() - sizeof(ctrl)); + + memcpy(s->cvq_cmd_out_buffer, &ctrl, sizeof(ctrl)); + memcpy(s->cvq_cmd_out_buffer + sizeof(ctrl), data, data_size); + + return vhost_vdpa_net_cvq_add(s, sizeof(ctrl) + data_size, + sizeof(virtio_net_ctrl_ack)); +} + +static int vhost_vdpa_net_load_mac(VhostVDPAState *s, const VirtIONet *n) +{ + uint64_t features =3D n->parent_obj.guest_features; + if (features & BIT_ULL(VIRTIO_NET_F_CTRL_MAC_ADDR)) { + ssize_t dev_written =3D vhost_vdpa_net_load_cmd(s, VIRTIO_NET_CTRL= _MAC, + VIRTIO_NET_CTRL_MAC_ADDR= _SET, + n->mac, sizeof(n->mac)); + if (unlikely(dev_written < 0)) { + return dev_written; + } + + return *s->status !=3D VIRTIO_NET_OK; + } + + return 0; +} + static int vhost_vdpa_net_load(NetClientState *nc) { VhostVDPAState *s =3D DO_UPCAST(VhostVDPAState, nc, nc); - const struct vhost_vdpa *v =3D &s->vhost_vdpa; + struct vhost_vdpa *v =3D &s->vhost_vdpa; const VirtIONet *n; - uint64_t features; + int r; =20 assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); =20 @@ -379,26 +414,9 @@ static int vhost_vdpa_net_load(NetClientState *nc) } =20 n =3D VIRTIO_NET(v->dev->vdev); - features =3D n->parent_obj.guest_features; - if (features & BIT_ULL(VIRTIO_NET_F_CTRL_MAC_ADDR)) { - const struct virtio_net_ctrl_hdr ctrl =3D { - .class =3D VIRTIO_NET_CTRL_MAC, - .cmd =3D VIRTIO_NET_CTRL_MAC_ADDR_SET, - }; - char *cursor =3D s->cvq_cmd_out_buffer; - ssize_t dev_written; - - memcpy(cursor, &ctrl, sizeof(ctrl)); - cursor +=3D sizeof(ctrl); - memcpy(cursor, n->mac, sizeof(n->mac)); - - dev_written =3D vhost_vdpa_net_cvq_add(s, sizeof(ctrl) + sizeof(n-= >mac), - sizeof(virtio_net_ctrl_ack)); - if (unlikely(dev_written < 0)) { - return dev_written; - } - - return *s->status !=3D VIRTIO_NET_OK; + r =3D vhost_vdpa_net_load_mac(s, n); + if (unlikely(r < 0)) { + return r; } =20 return 0; --=20 2.7.4 From nobody Mon May 20 20:10:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664266464; cv=none; d=zohomail.com; s=zohoarc; b=jZ5k2+ml+ZpF7uH/ptg30U/B0SEfAt4r7CE8TxgiQJb7Z29aLoxTj4fM9eF5gdxbQmCCa1Xhxq5lYLDvhWX5O6FmF5y8M7k1iU87UttQ7xk3bBV75Iy6yHAOa/ZHxxs1H97YqSpDxT/AD5kAHvxA74Vx6FMNERqEPyfoRbR+xp4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664266464; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Wb0dSr/OJV8D95Ry+UtOY5KDQAddafisX+Dj9PUMKgg=; b=HgCctDyhiFau1+F88b/lzSEDN2abJMVTcUgwfAX+tPv3bWYAjgBD6YKnqCAlQyolObt2ywBsgBMaPOzQc8/5IZYB5/QVnTMGfzuALqmLz+uW/1Fc9SiEX2Ms7PZ8nL0xBk66YB/PqFjka9CQjYNqQ4/oQdCNesMgWVS2cbOvZM4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664266464290510.2914469775835; Tue, 27 Sep 2022 01:14:24 -0700 (PDT) Received: from localhost ([::1]:44582 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od5jT-0007m4-1x for importer@patchew.org; Tue, 27 Sep 2022 04:14:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51108) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od53E-0003bk-JQ for qemu-devel@nongnu.org; Tue, 27 Sep 2022 03:30:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:54918) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od53D-0001iJ-5t for qemu-devel@nongnu.org; Tue, 27 Sep 2022 03:30:44 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-651-_AD6oA41NeGT4t6nGoaXeQ-1; Tue, 27 Sep 2022 03:30:40 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 30E56811732; Tue, 27 Sep 2022 07:30:40 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-192.pek2.redhat.com [10.72.13.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id BD4CC2166B26; Tue, 27 Sep 2022 07:30:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664263842; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Wb0dSr/OJV8D95Ry+UtOY5KDQAddafisX+Dj9PUMKgg=; b=alPP9Wy2/NSq0ZGhW9DPY7bdKUwyBNqswNGmH2lkct2VMDw2xUw33hjpPVl7bnRb3JOkoN +7SEbuDNh8Iy1Xs+lmtAizUHvIlTSsRN681YV9xYVI2zvw6PylmHGkvx/WyfsyBrIhmnPj O5vztYJhQGoauu+9gjRR0wCpooKrR6k= X-MC-Unique: _AD6oA41NeGT4t6nGoaXeQ-1 From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org, stefanha@redhat.com Cc: =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Jason Wang Subject: [PULL 4/8] vdpa: Add vhost_vdpa_net_load_mq Date: Tue, 27 Sep 2022 15:30:18 +0800 Message-Id: <20220927073022.28378-5-jasowang@redhat.com> In-Reply-To: <20220927073022.28378-1-jasowang@redhat.com> References: <20220927073022.28378-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664266465698100001 From: Eugenio P=C3=A9rez Same way as with the MAC, restore the expected number of queues at device's start. Signed-off-by: Eugenio P=C3=A9rez Signed-off-by: Jason Wang --- net/vhost-vdpa.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index e799e74..3950e4f 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -400,6 +400,28 @@ static int vhost_vdpa_net_load_mac(VhostVDPAState *s, = const VirtIONet *n) return 0; } =20 +static int vhost_vdpa_net_load_mq(VhostVDPAState *s, + const VirtIONet *n) +{ + struct virtio_net_ctrl_mq mq; + uint64_t features =3D n->parent_obj.guest_features; + ssize_t dev_written; + + if (!(features & BIT_ULL(VIRTIO_NET_F_MQ))) { + return 0; + } + + mq.virtqueue_pairs =3D cpu_to_le16(n->curr_queue_pairs); + dev_written =3D vhost_vdpa_net_load_cmd(s, VIRTIO_NET_CTRL_MQ, + VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET,= &mq, + sizeof(mq)); + if (unlikely(dev_written < 0)) { + return dev_written; + } + + return *s->status !=3D VIRTIO_NET_OK; +} + static int vhost_vdpa_net_load(NetClientState *nc) { VhostVDPAState *s =3D DO_UPCAST(VhostVDPAState, nc, nc); @@ -418,6 +440,10 @@ static int vhost_vdpa_net_load(NetClientState *nc) if (unlikely(r < 0)) { return r; } + r =3D vhost_vdpa_net_load_mq(s, n); + if (unlikely(r)) { + return r; + } =20 return 0; } --=20 2.7.4 From nobody Mon May 20 20:10:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664265943; cv=none; d=zohomail.com; s=zohoarc; b=iPRqD0uyJsE0arc9Xt8QjmxmvjerRsu7BYOASKJFRvumvtqQjfkAKp9STzZHGXRnA0/rnSCPEr+eY/xlZEr5pOEmpZd6fszjK+bIK8pLCPY/zPuqVU/xxS601EGDNVBm6cG+eRll71ghiV5LI37EDTMI2ZUH6dPtgSWHvdGpKtA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664265943; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=uUpRueFXdUTQEFcImJve815g7+VAZ6OTmwxxO6AXHp0=; b=YyZD4HF6KsE5rv1/y/uKMEALkelLHV4lrSAdq4pAdziFq/22XqsN6CVvspHkTl/7H7S4T6PSN18MSxSTTjx3z7mfd3Q2ZTUQwppuJ6nM/V/FgumNZVDw/z+vc0vl7KyDFrAveyCR+WcEEjmyegGG//OuCnyjqsaeN7UuG+qUBV4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 166426594341421.224710246810446; Tue, 27 Sep 2022 01:05:43 -0700 (PDT) Received: from localhost ([::1]:39790 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od5b3-0006jd-Rq for importer@patchew.org; Tue, 27 Sep 2022 04:05:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54210) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od53J-0003hv-LN for qemu-devel@nongnu.org; Tue, 27 Sep 2022 03:30:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:45504) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od53I-0001ia-5b for qemu-devel@nongnu.org; Tue, 27 Sep 2022 03:30:49 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-627-YkfzPV_WMleQVkBrHeFq0A-1; Tue, 27 Sep 2022 03:30:44 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B678038164C4; Tue, 27 Sep 2022 07:30:43 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-192.pek2.redhat.com [10.72.13.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 687F02166B26; Tue, 27 Sep 2022 07:30:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664263847; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uUpRueFXdUTQEFcImJve815g7+VAZ6OTmwxxO6AXHp0=; b=JMkoyNcf5XIlQdQkg/h1DfD/zllz3wMzmDidCNngw7XCqrkpsyFBvUmzh8/msw3SDUWjIC 9ku8Pxv6jFqbFLmtCrbNErXRbWZY3GvfHHaamQQt2ioa0bhtyx/PSR11YB5sQwnXV3wz/b a4KWkAI+y/CuxG39Feo/ZO3M4DYj+Fw= X-MC-Unique: YkfzPV_WMleQVkBrHeFq0A-1 From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org, stefanha@redhat.com Cc: =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Jason Wang Subject: [PULL 5/8] vdpa: validate MQ CVQ commands Date: Tue, 27 Sep 2022 15:30:19 +0800 Message-Id: <20220927073022.28378-6-jasowang@redhat.com> In-Reply-To: <20220927073022.28378-1-jasowang@redhat.com> References: <20220927073022.28378-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664265944159100001 From: Eugenio P=C3=A9rez So we are sure we can update the device model properly before sending to the device. Signed-off-by: Eugenio P=C3=A9rez Signed-off-by: Jason Wang --- net/vhost-vdpa.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 3950e4f..c6cbe2f 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -486,6 +486,15 @@ static bool vhost_vdpa_net_cvq_validate_cmd(const void= *out_buf, size_t len) __func__, ctrl.cmd); }; break; + case VIRTIO_NET_CTRL_MQ: + switch (ctrl.cmd) { + case VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET: + return true; + default: + qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid mq cmd %u\n", + __func__, ctrl.cmd); + }; + break; default: qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid control class %u\n", __func__, ctrl.class); --=20 2.7.4 From nobody Mon May 20 20:10:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664264530; cv=none; d=zohomail.com; s=zohoarc; b=KBpXsehZz7vq9qFPZtDQ2cPXwJ1Beem/zoW5xAgZTBYJQ0LqswJzGcl6IEcMoOKnPHz/dC9kyfiulQA4A5vGEkfuNh0EapuRXvlZLS5l+KrBQNvNJpk/U9qsh9LwfnsYIMBsCc5MVcV0AB7+ms1YiWCwGDCigm8b5yqGpL1mziw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664264530; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FD975SYmlJwwhn9UZUoZj7/QsX5Joxs8qt+mys0CNx4=; b=QFVb5VqVvE4SzAuZQOYasN4sULol52psFLDYAkkpCX16MlIEUZ5L0XHnfWUqduPGyehQpkd2TPosS7SfPjGzvIH54oxsfM+V3/8wIhGVmVzrEaD2oW01MQ9QMYRo/dpTzFmgpgJpurC95zv/DN6QdMP+TfZnRC9nYV9NGpcUjfM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664264530176926.8753031400133; Tue, 27 Sep 2022 00:42:10 -0700 (PDT) Received: from localhost ([::1]:58774 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od5EG-0004bJ-5y for importer@patchew.org; Tue, 27 Sep 2022 03:42:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54212) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od53L-0003le-ET for qemu-devel@nongnu.org; Tue, 27 Sep 2022 03:30:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:25733) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od53J-0001ig-R5 for qemu-devel@nongnu.org; Tue, 27 Sep 2022 03:30:51 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-74-WQaxQZzbMrWIlvrf3fbbmg-1; Tue, 27 Sep 2022 03:30:47 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 48FAD185A78F; Tue, 27 Sep 2022 07:30:47 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-192.pek2.redhat.com [10.72.13.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5E62D2166B26; Tue, 27 Sep 2022 07:30:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664263849; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FD975SYmlJwwhn9UZUoZj7/QsX5Joxs8qt+mys0CNx4=; b=fChA/vDW6ngkftK9IEDnqGQl6vlGsjs+pCSIUXKEXjyHxY6WT4QoZ311y2MnH6+EAD6rq6 UL9zv1Fdrx3q6yprBjYcWBNIeBnq4q2V858sxZ+Q2IlZ+QJQpNe5f3rMlTwITAgnLhyT/a nKkOLjYAy1mneH9bR9KEsbutNh/j17U= X-MC-Unique: WQaxQZzbMrWIlvrf3fbbmg-1 From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org, stefanha@redhat.com Cc: =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Si-Wei Liu , Jason Wang Subject: [PULL 6/8] virtio-net: Update virtio-net curr_queue_pairs in vdpa backends Date: Tue, 27 Sep 2022 15:30:20 +0800 Message-Id: <20220927073022.28378-7-jasowang@redhat.com> In-Reply-To: <20220927073022.28378-1-jasowang@redhat.com> References: <20220927073022.28378-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664264530631100001 From: Eugenio P=C3=A9rez It was returned as error before. Instead of it, simply update the corresponding field so qemu can send it in the migration data. Signed-off-by: Eugenio P=C3=A9rez Acked-by: Si-Wei Liu Signed-off-by: Jason Wang --- hw/net/virtio-net.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index dd0d056..63a8332 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -1412,19 +1412,14 @@ static int virtio_net_handle_mq(VirtIONet *n, uint8= _t cmd, return VIRTIO_NET_ERR; } =20 - /* Avoid changing the number of queue_pairs for vdpa device in - * userspace handler. A future fix is needed to handle the mq - * change in userspace handler with vhost-vdpa. Let's disable - * the mq handling from userspace for now and only allow get - * done through the kernel. Ripples may be seen when falling - * back to userspace, but without doing it qemu process would - * crash on a recursive entry to virtio_net_set_status(). - */ + n->curr_queue_pairs =3D queue_pairs; if (nc->peer && nc->peer->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VD= PA) { - return VIRTIO_NET_ERR; + /* + * Avoid updating the backend for a vdpa device: We're only intere= sted + * in updating the device model queues. + */ + return VIRTIO_NET_OK; } - - n->curr_queue_pairs =3D queue_pairs; /* stop the backend before changing the number of queue_pairs to avoid= handling a * disabled queue */ virtio_net_set_status(vdev, vdev->status); --=20 2.7.4 From nobody Mon May 20 20:10:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664266971; cv=none; d=zohomail.com; s=zohoarc; b=mhGplq8GwsV6YjGlsaS5tG31+Wj/YqvOX5bkVBzjzZ8qpJAaE83q0+SUaWaGL93P+lFlunFb9/kQ8Bml832wcDG99wnr87H9Iou/QKWtBiYQrMJqqzYMid4588X1Nja3JehHx7l8m26StS6ZiKYhiN5jtMpQIWeL3VE2D29b/Aw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664266971; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=P7g8G1YItcbwTP6E0cjkw57zeCPwvQSamrD/R+qit9M=; b=CdmmiHsqsD7+hqITuU0PAuRpz9cOd6PyhHbuNQHprZcLmcJCxLbw0zDt0DLjOhsR2eRUSkJsAw/nWfEAgjcM7jo/5UqTLOD1oj7Uto42cXM1Qv0sGIP826pMOodXBqRFbmPpyDK1vwsA7tCJpjvGY5NmEesWk4mcoIXYqL/2aGk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664266971090780.7898730817432; Tue, 27 Sep 2022 01:22:51 -0700 (PDT) Received: from localhost ([::1]:57008 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od5re-0000hq-4c for importer@patchew.org; Tue, 27 Sep 2022 04:22:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34706) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od53Q-0003wX-Jq for qemu-devel@nongnu.org; Tue, 27 Sep 2022 03:30:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:21503) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od53P-0001kj-3l for qemu-devel@nongnu.org; Tue, 27 Sep 2022 03:30:56 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-37-HjNu0tO7PRKiheEZVDsiaw-1; Tue, 27 Sep 2022 03:30:51 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BC0FD29ABA31; Tue, 27 Sep 2022 07:30:50 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-192.pek2.redhat.com [10.72.13.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 005412166B2A; Tue, 27 Sep 2022 07:30:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664263854; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=P7g8G1YItcbwTP6E0cjkw57zeCPwvQSamrD/R+qit9M=; b=SaVwtqLeYldsIfwHUlwURYytbcBtU8DusB7TZoBAMEonaeV/J3ZRtQb5evfe8tZWopRfeM 53TvEEp3zLlGCc6VfKgSV2IHUo3AZpIXl+H/joGkdL8/j4FkXjcbCRypTp9ZbF9P4NUgGr 8gbwOBMC8yPjHBdr+iebYQxlKodazQU= X-MC-Unique: HjNu0tO7PRKiheEZVDsiaw-1 From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org, stefanha@redhat.com Cc: =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Jason Wang Subject: [PULL 7/8] vdpa: Allow MQ feature in SVQ Date: Tue, 27 Sep 2022 15:30:21 +0800 Message-Id: <20220927073022.28378-8-jasowang@redhat.com> In-Reply-To: <20220927073022.28378-1-jasowang@redhat.com> References: <20220927073022.28378-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664266972997100001 From: Eugenio P=C3=A9rez Finally enable SVQ with MQ feature. Signed-off-by: Eugenio P=C3=A9rez Signed-off-by: Jason Wang --- net/vhost-vdpa.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index c6cbe2f..4bc3fd0 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -94,6 +94,7 @@ static const uint64_t vdpa_svq_device_features =3D BIT_ULL(VIRTIO_NET_F_MRG_RXBUF) | BIT_ULL(VIRTIO_NET_F_STATUS) | BIT_ULL(VIRTIO_NET_F_CTRL_VQ) | + BIT_ULL(VIRTIO_NET_F_MQ) | BIT_ULL(VIRTIO_F_ANY_LAYOUT) | BIT_ULL(VIRTIO_NET_F_CTRL_MAC_ADDR) | BIT_ULL(VIRTIO_NET_F_RSC_EXT) | --=20 2.7.4 From nobody Mon May 20 20:10:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664267021; cv=none; d=zohomail.com; s=zohoarc; b=NRysWfMBhiPfQ6VShCHqs0+iy0AsBgY5D1i6RYn0PDO+XllYwhrT5HfAYvDmWcDBRPtQxYutggG7ok16f7JKLdIyuc0DqSw6lvpV/5EqvG/Jb1bHEUXGVK1stN8POmxQwv4+kIGuusTFEFKzj4L1XFpyHsj6kgC+cZrxJMEcLP8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664267021; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=72fe6pmcOVLG6dRHQG+0/KXd+hhvMVZPBOsQRMmfl+g=; b=RwGIOc1HR1g+0NlTEkrJ8zbHe7rngaHpr3w76CB4Q5IsVveMHuPSZ8gMjKFtMU/1wA9OFlHogfKUPMDWiz1P2KKVpUBxuk87RDfArNjxdhdveLuM2Q8CdiY6NWKu6tUs15JCLC43yJCpmLwQbxZGF/V/siM/EqY8AxXv5KI+ZFU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664267021972180.27367088065932; Tue, 27 Sep 2022 01:23:41 -0700 (PDT) Received: from localhost ([::1]:56236 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od5sR-0002n5-VC for importer@patchew.org; Tue, 27 Sep 2022 04:23:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34710) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od53V-000440-LR for qemu-devel@nongnu.org; Tue, 27 Sep 2022 03:31:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:45400) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od53T-0001l7-2M for qemu-devel@nongnu.org; Tue, 27 Sep 2022 03:31:01 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-269-VUBc3d7jMxqVjuPrVf7U7w-1; Tue, 27 Sep 2022 03:30:54 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 789431C0BDE8; Tue, 27 Sep 2022 07:30:54 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-192.pek2.redhat.com [10.72.13.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 661A52166B26; Tue, 27 Sep 2022 07:30:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664263858; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=72fe6pmcOVLG6dRHQG+0/KXd+hhvMVZPBOsQRMmfl+g=; b=XB6kmKls72jRjA9FKIhV8GF04sn3rgiw7ULrkYUmloV4jJZWvZW5CUNAz+lyd3nH7uk0qZ Qbrr8TnHUwC9Usp4jr0YSbAv5kVvsdgsN8P/zi36svpw0+PG2LWh4V+bY3Q1wRj9o/2KWR bmPhXxhZ02Uq8NsuzOiv1qgs+OwNcaI= X-MC-Unique: VUBc3d7jMxqVjuPrVf7U7w-1 From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org, stefanha@redhat.com Cc: lu zhipeng , Jason Wang Subject: [PULL 8/8] virtio: del net client if net_init_tap_one failed Date: Tue, 27 Sep 2022 15:30:22 +0800 Message-Id: <20220927073022.28378-9-jasowang@redhat.com> In-Reply-To: <20220927073022.28378-1-jasowang@redhat.com> References: <20220927073022.28378-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664267023219100001 Content-Type: text/plain; charset="utf-8" From: lu zhipeng If the net tap initializes successful, but failed during network card hot-plugging, the net-tap will remains, so cleanup. Signed-off-by: lu zhipeng Signed-off-by: Jason Wang --- net/tap.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/net/tap.c b/net/tap.c index b3ddfd4..e203d07 100644 --- a/net/tap.c +++ b/net/tap.c @@ -686,7 +686,7 @@ static void net_init_tap_one(const NetdevTapOptions *ta= p, NetClientState *peer, tap_set_sndbuf(s->fd, tap, &err); if (err) { error_propagate(errp, err); - return; + goto failed; } =20 if (tap->has_fd || tap->has_fds) { @@ -726,12 +726,12 @@ static void net_init_tap_one(const NetdevTapOptions *= tap, NetClientState *peer, } else { warn_report_err(err); } - return; + goto failed; } if (!g_unix_set_fd_nonblocking(vhostfd, true, NULL)) { error_setg_errno(errp, errno, "%s: Can't use file descript= or %d", name, fd); - return; + goto failed; } } else { vhostfd =3D open("/dev/vhost-net", O_RDWR); @@ -743,11 +743,11 @@ static void net_init_tap_one(const NetdevTapOptions *= tap, NetClientState *peer, warn_report("tap: open vhost char device failed: %s", strerror(errno)); } - return; + goto failed; } if (!g_unix_set_fd_nonblocking(vhostfd, true, NULL)) { error_setg_errno(errp, errno, "Failed to set FD nonblockin= g"); - return; + goto failed; } } options.opaque =3D (void *)(uintptr_t)vhostfd; @@ -760,11 +760,17 @@ static void net_init_tap_one(const NetdevTapOptions *= tap, NetClientState *peer, } else { warn_report(VHOST_NET_INIT_FAILED); } - return; + goto failed; } } else if (vhostfdname) { error_setg(errp, "vhostfd(s)=3D is not valid without vhost"); + goto failed; } + + return; + +failed: + qemu_del_net_client(&s->nc); } =20 static int get_fds(char *str, char *fds[], int max) --=20 2.7.4