From nobody Wed Nov 27 19:46:09 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=1697644462; cv=none; d=zohomail.com; s=zohoarc; b=NaYu6wiFzE9vUJVK5/w9QKqpMDL4o4Wf292SvI/pEXbey/LLVbfVkVId00F3IHeQxBh22yheL6c44AJwIiLx9lR3jBH6uAktua/TeBYBpmBZxmpIw8y1+xBol4i29lplkeIFEDDyT62X5MS3gOEQ2ct1hDYahrxEYj/4tma2VqI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697644462; h=Content-Type: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=NnZ2s+L/b1HX9DHf9pBpEKpAVinEM8uC7IZ8jyp1dfs=; b=O/wEiT2lkED6Qc9lAFJo4r6tASVqdv+lj2I7fEvZlRahOmLjsKk7ieu3ZLodeMm0diZe6fryPb45CfzI0m2JpbVcOa2uL3kUTBXcHVQ3BKD3seP82CTejCV1LMEWlNMDot7tXU0ukETzrMlf3zArvZoXGrzYjtedajHWzKbSArg= 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 1697644462424645.2781062521028; Wed, 18 Oct 2023 08:54:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qt8s7-0006xN-S4; Wed, 18 Oct 2023 11:54:11 -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 1qt8s5-0006hz-97 for qemu-devel@nongnu.org; Wed, 18 Oct 2023 11:54:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qt8s3-0006Oj-10 for qemu-devel@nongnu.org; Wed, 18 Oct 2023 11:54:09 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-313-VDvMAh-BNgm6T2Ye7aKSqg-1; Wed, 18 Oct 2023 11:54:04 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-406710d9a4aso49922635e9.2 for ; Wed, 18 Oct 2023 08:54:04 -0700 (PDT) Received: from redhat.com ([2a02:14f:1f2:2037:f34:d61b:7da0:a7be]) by smtp.gmail.com with ESMTPSA id h17-20020a05600c499100b0040772138bb7sm1962949wmp.2.2023.10.18.08.54.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 08:54:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697644446; 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: in-reply-to:in-reply-to:references:references; bh=NnZ2s+L/b1HX9DHf9pBpEKpAVinEM8uC7IZ8jyp1dfs=; b=SFf8LXzzYnAJ3WAOczYKfwMEF0cklm5oWSsQ88ky9qKXUt0EyERmqfsFrt7vb//BeXOK9S MhOGXhxmbzeP7HY9/tv1x6o9XdoTxXruHMAlrV1KyuWw2/BMZbV8dwtYv1fIP67Zi+LgPc 8N5lohHwYex3P4kxLUddB86eNfbo0mU= X-MC-Unique: VDvMAh-BNgm6T2Ye7aKSqg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697644443; x=1698249243; h=in-reply-to: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=NnZ2s+L/b1HX9DHf9pBpEKpAVinEM8uC7IZ8jyp1dfs=; b=mbIVTWF1aanQAKfomHZQ0c5cz9Kj2BvSShNYZY1hGZrTmbgZRWTSS1bnYzAMHUnpmL 4VSxWWfS7vQhxH2GjkJK14rGIYa7ajHUyq67AfrkcH5X2aLu1vh10aVugA25GUWcgQm6 VqkZO/QKjRaS+PCy74g8d9r6QLqPKH6nVr3ijwbZWtdTxPi3CWdNdBUe41bQ5TBbh1nb PbKvhi0yjMABn1H/4xduhdctfmF41vufvJX9+EJrhTmm671DaifNwFcsG/KixNwdSryT XvQeC77HssEYvrwJb90qDpY6Q2nc+T/1L2kaFGBH3aEZZw20lG7ePsx72KJ9qnq/HcSq jANA== X-Gm-Message-State: AOJu0Ywe3dbV3kuV/YuiGdypYbNm5mNwShgApxn4P+lrh0oxw7OXyevC NIa4hFAqyA6HQS5nzJovKRWs6OW3aQ8gdB2KuOFc6rOOeFXW5tCpsxH4bGvdLoQ227JrvkXxTML bz7ctnQfBTKmbJF5DWGBpzaKfwAsENkcbRHuzTcHLFNXIkVWG6tOnBo8JxtZv0vbBczoctT8= X-Received: by 2002:a05:600c:1d22:b0:408:41b4:7fe0 with SMTP id l34-20020a05600c1d2200b0040841b47fe0mr540270wms.6.1697644442852; Wed, 18 Oct 2023 08:54:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGNNvqRufkYWgLCVMGAiH4zi1xx9tS7bzYRTiAW//xjGT/3weCrOaRyFc5BIYT1v4YpiRP3Vw== X-Received: by 2002:a05:600c:1d22:b0:408:41b4:7fe0 with SMTP id l34-20020a05600c1d2200b0040841b47fe0mr540257wms.6.1697644442550; Wed, 18 Oct 2023 08:54:02 -0700 (PDT) Date: Wed, 18 Oct 2023 11:53:58 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hawkins Jiawei , Jason Wang Subject: [PULL 11/83] vdpa: Restore receive-side scaling state Message-ID: <49f5836bacfb9d4bb96d29f16d04822d64e0ad52.1697644299.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline 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.129.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_H4=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: 1697644462968100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Hawkins Jiawei This patch reuses vhost_vdpa_net_load_rss() with some refactorings to restore the receive-side scaling state at device's startup. Signed-off-by: Hawkins Jiawei Message-Id: <47b17e160ba4e55b24790b7d73b22d2b437ebe3c.1693299194.git.yin311= 49@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- net/vhost-vdpa.c | 54 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index ef48b6e816..846457129d 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -851,17 +851,28 @@ static int vhost_vdpa_net_load_rss(VhostVDPAState *s,= const VirtIONet *n, =20 cfg.hash_types =3D cpu_to_le32(n->rss_data.hash_types); =20 - /* - * According to VirtIO standard, "Field reserved MUST contain zeroes. - * It is defined to make the structure to match the layout of - * virtio_net_rss_config structure, defined in 5.1.6.5.7.". - * - * Therefore, we need to zero the fields in struct virtio_net_rss_conf= ig, - * which corresponds the `reserved` field in - * struct virtio_net_hash_config. - */ - memset(&cfg.indirection_table_mask, 0, - sizeof_field(struct virtio_net_hash_config, reserved)); + if (do_rss) { + /* + * According to VirtIO standard, "Number of entries in indirection= _table + * is (indirection_table_mask + 1)". + */ + cfg.indirection_table_mask =3D cpu_to_le16(n->rss_data.indirection= s_len - + 1); + cfg.unclassified_queue =3D cpu_to_le16(n->rss_data.default_queue); + cfg.max_tx_vq =3D cpu_to_le16(n->curr_queue_pairs); + } else { + /* + * According to VirtIO standard, "Field reserved MUST contain zero= es. + * It is defined to make the structure to match the layout of + * virtio_net_rss_config structure, defined in 5.1.6.5.7.". + * + * Therefore, we need to zero the fields in + * struct virtio_net_rss_config, which corresponds the `reserved` = field + * in struct virtio_net_hash_config. + */ + memset(&cfg.indirection_table_mask, 0, + sizeof_field(struct virtio_net_hash_config, reserved)); + } =20 table =3D g_malloc_n(n->rss_data.indirections_len, sizeof(n->rss_data.indirections_table[0])); @@ -898,6 +909,7 @@ static int vhost_vdpa_net_load_rss(VhostVDPAState *s, c= onst VirtIONet *n, =20 r =3D vhost_vdpa_net_load_cmd(s, out_cursor, in_cursor, VIRTIO_NET_CTRL_MQ, + do_rss ? VIRTIO_NET_CTRL_MQ_RSS_CONFIG : VIRTIO_NET_CTRL_MQ_HASH_CONFIG, data, ARRAY_SIZE(data)); if (unlikely(r < 0)) { @@ -932,13 +944,19 @@ static int vhost_vdpa_net_load_mq(VhostVDPAState *s, return r; } =20 - if (!virtio_vdev_has_feature(&n->parent_obj, VIRTIO_NET_F_HASH_REPORT)= ) { - return 0; - } - - r =3D vhost_vdpa_net_load_rss(s, n, out_cursor, in_cursor, false); - if (unlikely(r < 0)) { - return r; + if (virtio_vdev_has_feature(&n->parent_obj, VIRTIO_NET_F_RSS)) { + /* load the receive-side scaling state */ + r =3D vhost_vdpa_net_load_rss(s, n, out_cursor, in_cursor, true); + if (unlikely(r < 0)) { + return r; + } + } else if (virtio_vdev_has_feature(&n->parent_obj, + VIRTIO_NET_F_HASH_REPORT)) { + /* load the hash calculation state */ + r =3D vhost_vdpa_net_load_rss(s, n, out_cursor, in_cursor, false); + if (unlikely(r < 0)) { + return r; + } } =20 return 0; --=20 MST