From nobody Wed Nov 27 20:40:59 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=1697644660; cv=none; d=zohomail.com; s=zohoarc; b=lcd885nh9DqbweVLOxYkuGUM2DN88eTPZt+GBLqqpAXGoOzB638x/9pJKbAZmXcMMdMhIymDX4sdIPOA1NNcebAkv6VM/QyyBSHrPSqUI4baX3SvkkdJ74PWaxmrxR7ptOHb9Qc6+EcOcmKPtu01+yTusEQYsjkcDracn7L3FSc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697644660; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=6rjIIhgIzngiZUO1BhT0Rp7HmlO6psOtfNInxxNDXLU=; b=M6q5Vhmvu9VfeBKjLPUw61rVRMYR8laAFhkYtAKtP8zE3ivTe7d53Z+eKl21KVQ4GYExG9EolQexUIEU4ZvqnzCz0rQGIFOOiL/LtMzxjxnisy9eUT1MMBd+7TiA62umsHzq+pv/IYOonsZs3KtnKTOR15RNEr8oK1A1PtSq6YA= 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 1697644660894659.9998026846818; Wed, 18 Oct 2023 08:57:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qt8ra-0003Zy-Rz; Wed, 18 Oct 2023 11:53:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qt8rZ-0003RX-LS for qemu-devel@nongnu.org; Wed, 18 Oct 2023 11:53:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qt8rX-0006LF-M7 for qemu-devel@nongnu.org; Wed, 18 Oct 2023 11:53:37 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-538-XgkZ2kQ5NfedsBdyyIWixg-1; Wed, 18 Oct 2023 11:53:33 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-32da8de4833so2418210f8f.3 for ; Wed, 18 Oct 2023 08:53:33 -0700 (PDT) Received: from redhat.com ([2a02:14f:1f2:2037:f34:d61b:7da0:a7be]) by smtp.gmail.com with ESMTPSA id j14-20020adfea4e000000b0032d81837433sm2444980wrn.30.2023.10.18.08.53.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 08:53:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697644414; 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=6rjIIhgIzngiZUO1BhT0Rp7HmlO6psOtfNInxxNDXLU=; b=eEFZcDUIFIHRZGkZZBPS5sFDM53Hd/P/UcGCS33bVGcPWPsmWLh3Pqygi0RLXNxwukuOCc 8e6B3Y6prqzb5sGaZez/8jU2l/uInkVUGkPNwM47ZFAInr6QAdkSEobqPH3V7MLM4QRI8Q xJBaX44WM3SjW6bE6Zc+HKzvXz1RYtM= X-MC-Unique: XgkZ2kQ5NfedsBdyyIWixg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697644411; x=1698249211; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6rjIIhgIzngiZUO1BhT0Rp7HmlO6psOtfNInxxNDXLU=; b=doksGyzig3XWk2C3jBqQ8Jhf9bdN05fuKbQ/UcL4GWxfasMmpMcll8MmYJfxIfKFeB K4HoVI4n7QCC85y9P28/v1TEJS8EHByCuhHN1dHqPCVC9/eYLiyX3Ph4FPKxixd/CFwO 2ORB78lIDTIx4UcYYDnsvT+rMqswE/Q7j6f1nn4WfmOmJyaGQ+jmktijzToghvvsHPiS 7Eb43mN7iDhVuDpOD7Jng4FulkNrDtADspUmLQxkSrle+2pcYrypenzJssrR5biA/9Aq 7ci7SQDkFjS3LI4UZT/VI5rneiP4LIDBj5ADP+KOl0uWcAE1YMjb0JPNQiA4MVgHGvo9 5SBA== X-Gm-Message-State: AOJu0Yyr+ScUdW791Y0wVh8GdL6hzc09TFLl6Dd0vG/X7g4+5OXGCzdc bDzFjeG86qryR4VjyEiEAT0j5qiLw/fYLT6Sx1aEIukcaMZ3o6Yx8ZyDMrR2k1RUsnDXxRacKE8 WX1OhT5IPYe3DIzdOs7GtN2P6qwdNV22ej1kmKjGj6h3U2mqRTPzBn07e5QW2sJrq6eBP+hc= X-Received: by 2002:a5d:6087:0:b0:323:306e:65cf with SMTP id w7-20020a5d6087000000b00323306e65cfmr4622349wrt.10.1697644411614; Wed, 18 Oct 2023 08:53:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGi4otNAw/xIqzs63sknX1uTSBu7b1L5gjjJ1+/FcQnseWgPmtfhWwaSgxeubrXIfcWr91dlw== X-Received: by 2002:a5d:6087:0:b0:323:306e:65cf with SMTP id w7-20020a5d6087000000b00323306e65cfmr4622332wrt.10.1697644411261; Wed, 18 Oct 2023 08:53:31 -0700 (PDT) Date: Wed, 18 Oct 2023 11:53:28 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hawkins Jiawei , Eugenio =?utf-8?B?UMOpcmV6?= , Jason Wang Subject: [PULL 03/83] vdpa: Check device ack in vhost_vdpa_net_load_rx_mode() Message-ID: <24e59cfe0cb53416b06c2c117bc22ff22dc54df3.1697644299.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1697644661861100001 From: Hawkins Jiawei Considering that vhost_vdpa_net_load_rx_mode() is only called within vhost_vdpa_net_load_rx() now, this patch refactors vhost_vdpa_net_load_rx_mode() to include a check for the device's ack, simplifying the code and improving its maintainability. Signed-off-by: Hawkins Jiawei Acked-by: Eugenio P=C3=A9rez Message-Id: <68811d52f96ae12d68f0d67d996ac1642a623943.1697165821.git.yin311= 49@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- net/vhost-vdpa.c | 76 ++++++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 45 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 86b8d31244..36a4e57c0d 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -827,14 +827,24 @@ static int vhost_vdpa_net_load_rx_mode(VhostVDPAState= *s, .iov_base =3D &on, .iov_len =3D sizeof(on), }; - return vhost_vdpa_net_load_cmd(s, VIRTIO_NET_CTRL_RX, - cmd, &data, 1); + ssize_t dev_written; + + dev_written =3D vhost_vdpa_net_load_cmd(s, VIRTIO_NET_CTRL_RX, + cmd, &data, 1); + if (unlikely(dev_written < 0)) { + return dev_written; + } + if (*s->status !=3D VIRTIO_NET_OK) { + return -EIO; + } + + return 0; } =20 static int vhost_vdpa_net_load_rx(VhostVDPAState *s, const VirtIONet *n) { - ssize_t dev_written; + ssize_t r; =20 if (!virtio_vdev_has_feature(&n->parent_obj, VIRTIO_NET_F_CTRL_RX)) { return 0; @@ -859,13 +869,9 @@ static int vhost_vdpa_net_load_rx(VhostVDPAState *s, * configuration only at live migration. */ if (!n->mac_table.uni_overflow && !n->promisc) { - dev_written =3D vhost_vdpa_net_load_rx_mode(s, - VIRTIO_NET_CTRL_RX_PROMISC, 0); - if (unlikely(dev_written < 0)) { - return dev_written; - } - if (*s->status !=3D VIRTIO_NET_OK) { - return -EIO; + r =3D vhost_vdpa_net_load_rx_mode(s, VIRTIO_NET_CTRL_RX_PROMISC, 0= ); + if (unlikely(r < 0)) { + return r; } } =20 @@ -887,13 +893,9 @@ static int vhost_vdpa_net_load_rx(VhostVDPAState *s, * configuration only at live migration. */ if (n->mac_table.multi_overflow || n->allmulti) { - dev_written =3D vhost_vdpa_net_load_rx_mode(s, - VIRTIO_NET_CTRL_RX_ALLMULTI, 1= ); - if (unlikely(dev_written < 0)) { - return dev_written; - } - if (*s->status !=3D VIRTIO_NET_OK) { - return -EIO; + r =3D vhost_vdpa_net_load_rx_mode(s, VIRTIO_NET_CTRL_RX_ALLMULTI, = 1); + if (unlikely(r < 0)) { + return r; } } =20 @@ -912,13 +914,9 @@ static int vhost_vdpa_net_load_rx(VhostVDPAState *s, * configuration only at live migration. */ if (n->alluni) { - dev_written =3D vhost_vdpa_net_load_rx_mode(s, - VIRTIO_NET_CTRL_RX_ALLUNI, 1); - if (dev_written < 0) { - return dev_written; - } - if (*s->status !=3D VIRTIO_NET_OK) { - return -EIO; + r =3D vhost_vdpa_net_load_rx_mode(s, VIRTIO_NET_CTRL_RX_ALLUNI, 1); + if (r < 0) { + return r; } } =20 @@ -933,13 +931,9 @@ static int vhost_vdpa_net_load_rx(VhostVDPAState *s, * configuration only at live migration. */ if (n->nomulti) { - dev_written =3D vhost_vdpa_net_load_rx_mode(s, - VIRTIO_NET_CTRL_RX_NOMULTI, 1); - if (dev_written < 0) { - return dev_written; - } - if (*s->status !=3D VIRTIO_NET_OK) { - return -EIO; + r =3D vhost_vdpa_net_load_rx_mode(s, VIRTIO_NET_CTRL_RX_NOMULTI, 1= ); + if (r < 0) { + return r; } } =20 @@ -954,13 +948,9 @@ static int vhost_vdpa_net_load_rx(VhostVDPAState *s, * configuration only at live migration. */ if (n->nouni) { - dev_written =3D vhost_vdpa_net_load_rx_mode(s, - VIRTIO_NET_CTRL_RX_NOUNI, 1); - if (dev_written < 0) { - return dev_written; - } - if (*s->status !=3D VIRTIO_NET_OK) { - return -EIO; + r =3D vhost_vdpa_net_load_rx_mode(s, VIRTIO_NET_CTRL_RX_NOUNI, 1); + if (r < 0) { + return r; } } =20 @@ -975,13 +965,9 @@ static int vhost_vdpa_net_load_rx(VhostVDPAState *s, * configuration only at live migration. */ if (n->nobcast) { - dev_written =3D vhost_vdpa_net_load_rx_mode(s, - VIRTIO_NET_CTRL_RX_NOBCAST, 1); - if (dev_written < 0) { - return dev_written; - } - if (*s->status !=3D VIRTIO_NET_OK) { - return -EIO; + r =3D vhost_vdpa_net_load_rx_mode(s, VIRTIO_NET_CTRL_RX_NOBCAST, 1= ); + if (r < 0) { + return r; } } =20 --=20 MST