Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1115370rdb; Fri, 1 Dec 2023 07:27:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IFaf8XNbXfXLcBvt/YJN6ObMEtTF4LH3nGh8e1RBEv7AxzSXrRX3Ay16k+6OLZ//6gx6TV3 X-Received: by 2002:a17:90b:1c0b:b0:286:4fc9:b5f0 with SMTP id oc11-20020a17090b1c0b00b002864fc9b5f0mr5345791pjb.10.1701444428770; Fri, 01 Dec 2023 07:27:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1701444428; cv=pass; d=google.com; s=arc-20160816; b=Ui+doYZTxaJj9KXUu40ETsJDdf5KeSMpIr4lyVx66aWJW7KusaNkMIEYqpGe73ZGll QhfogJg0xMeoBFbQ4wE55jsbF68sCTfOtzAPGDR/jFq3drfOvUJzb997YOTKpMPvLoBr pnoFcVq9EbT9hd93iBrWyxgATI7c8maWqNHLrweS+Ft55vdq3Pqhl3yErgJrNKXbtcco FyAPcdF6qGuWPouTv5FftR2MPv0c3wcOodQQfowlRN3VHXt0Px6Q1CL+RX1+OILwoJUj rPc2Y+L5KJqlIqvyiCVUaamaxv65isHRNa2YFP3XguiLZ9H/xnb9i2+XwWIIdgtLU+QV UsYw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:in-reply-to :content-transfer-encoding:content-disposition:references:message-id :subject:cc:to:from:date:dkim-signature; bh=/HfbQe3DVIcBpWk5fwFs7qR+YU6lZ9oFZruAXg+ICt8=; fh=41fnZFKZTkGyiyaEjQbA8TW6wV5glY05ucYJV7J/LQk=; b=d+FdxBI/9fFpxU+tXZcXgMTKSSpSqxqo5EjviSh9MJUWWu4OhS9LHPpHP3GOr6FHIs uCiYncT7zVyp4P0NPA6MPwXk97q7t7VQWhPPbS7X8KDyB6drG3hQWru5JJmmRZSdTz6n unISRL2qvUDhoA7fCb8i/E7fvoxRPXFq6ZwAzqv/hDTK5FdIDyoPXy0dMHtFwjV8NuT6 Qy4DpfwUy+iQ/zNtmMvltYaeNvwTV+sc7HKSP9PoSSQ8Xekztzcdtn1FUDM0TCVtR5bN yL5nEy+ncJy1/OrGr9mmS+k3y3qhDYhf6HpawFTieBhgz6esIuhi4IM+N9D8KCqHgVie hL9g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=a9Q2SBIe; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id k37-20020a63ff25000000b005ad8009e304si3589341pgi.784.2023.12.01.07.27.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 07:27:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=a9Q2SBIe; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id B24B48374B9E; Fri, 1 Dec 2023 07:27:00 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379376AbjLAP0i (ORCPT + 99 others); Fri, 1 Dec 2023 10:26:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379357AbjLAP0g (ORCPT ); Fri, 1 Dec 2023 10:26:36 -0500 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2041.outbound.protection.outlook.com [40.107.244.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC01FB6; Fri, 1 Dec 2023 07:26:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hxmez6Uw3de9Fue8Lk4PIau9UVQ8IpcMO0Q4FQ22gHcBa0CAOoGd+L16oluO1LGMrq6JxUQ309FjqyS2kSOO00t46s3G2Xy+0J7rRjtMmRe4YJXm8SmipD+RhXXY3q+RmXEyxRgBfGYxv/sPdZVGVlSiUk+MeZ3IblqNxJIon/Tn5nuQ8OXml+PeaxKMwxuB1UPpUaCNrPiQKiiwXNn8KLGOYNAP/QLO86zd0wuVgdQRl8BD/f9bxEF7NM6yAQVhWgmbZNLjyz+tGDAGS802XeaAfJuzzDisUwRHfUWUwm6TfcY9aB8/WuBqHf6W3fW+dHuG1HPN6w8dtB7EFfcV1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/HfbQe3DVIcBpWk5fwFs7qR+YU6lZ9oFZruAXg+ICt8=; b=KOYF1lGBrtD/MDF9L6RoZVv8JpibLwng8LgV/dSGQ5f9gB1kWdCinTh40i4zPxeutPBX/GTg6T7TFMkoH5t+cBqqvoOoVEJD/568S0+mGcPqZ59fnqrsDKGfBY7h30BeVh8bU7FH9s9i687TDAX1a+wvgrJipdMnjh76evHBvNUMWtdIhTAu7u3h9NOyWmj9s10gVk1UoMrgP30g+dMVsBz5fCM083p2fsYQrazLo7Un1jky3GWubR/XMNGTbv/unQ1OLF7MzYRe0HAdP8Yu0rKzQufLsA/kDLaGMpi8LJ8wLO+mncMXZ1y2j3Ov/jMgtCK6hgT5aWSGG81RwefJQw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/HfbQe3DVIcBpWk5fwFs7qR+YU6lZ9oFZruAXg+ICt8=; b=a9Q2SBIejLcUFTnadp0fGVLd41qMnar7kmZ1R3vYrz4bseXUjGaPaRRAutosiJw1KsN/0KJSRwu0gqPYlQfNR/tYhVLwQNVaI/YSd2NCA576/z7ClF/brMOnXg+GPFDzE9q+5xPlystsTpifWD6RMoEDjGD4gS0aA1+eqIayKrv0H8HsugntF/9AUU4qOnyanZtvIeJEdUnRv/G+NuCvUdNtVXcVB34RBW4IlAM6uwkGQvsYKQzfxVqnFhyO9OZ9ZLO5n6px1gqQaAhsCIu6o1VPh5CRw5nPh5STqwU06uygc3EEM06MsXWn+i2Qf7PuZ8vv+Bg762eNgFZkwjBQqw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB5565.namprd12.prod.outlook.com (2603:10b6:5:1b6::13) by BL1PR12MB5377.namprd12.prod.outlook.com (2603:10b6:208:31f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.27; Fri, 1 Dec 2023 15:26:38 +0000 Received: from DM6PR12MB5565.namprd12.prod.outlook.com ([fe80::bd76:47ad:38a9:a258]) by DM6PR12MB5565.namprd12.prod.outlook.com ([fe80::bd76:47ad:38a9:a258%5]) with mapi id 15.20.7046.027; Fri, 1 Dec 2023 15:26:37 +0000 Date: Fri, 1 Dec 2023 16:26:31 +0100 From: Dragos Tatulea To: Eugenio Perez Martin Cc: "Michael S . Tsirkin" , Jason Wang , Si-Wei Liu , Saeed Mahameed , Leon Romanovsky , virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Parav Pandit , Xuan Zhuo Subject: Re: [PATCH vhost 3/7] vdpa/mlx5: Allow modifying multiple vq fields in one modify command Message-ID: References: <20231201104857.665737-1-dtatulea@nvidia.com> <20231201104857.665737-4-dtatulea@nvidia.com> Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-ClientProxiedBy: FR2P281CA0083.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:9b::7) To DM6PR12MB5565.namprd12.prod.outlook.com (2603:10b6:5:1b6::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR12MB5565:EE_|BL1PR12MB5377:EE_ X-MS-Office365-Filtering-Correlation-Id: 79d72bb2-493e-47fe-0611-08dbf281e8e8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Joo01kWsrXYQ4RC9vhWlPTeMBKz5nUnUWPDEypPBysCrwS6wZn9HhRFr37hMihcPBmC7Jc1bxFCDZYf2DfSGWAVjSuFyzhcdUP8JyRa2orc79kICpYAGoBIC02Noniyq3it4jff+DuN3QeQ/aGq2yR89no8pGVapNCcwGsPTTAb5vME8YmnVbG39jiTKEWVq6h3ZVQaK7uEclbGdJbvfV2L0HuaiMbvzZnw2W0tsyurKuJAGRXuc6rUkNF29eAHZfPmMvsK5tCQM2WfPYShF0RebqXXTObDA5lL4M/Ys5HuTn2bTRg/1/G2NkylJHAUD2Xw6cj6hDZ7uX4IMlwVkzRtIQRxIntYxMLS1mtvggN9k/enXhJkTHpSePYUxfMdudQ63qYFnWJdpmrVYfhiFQ6JMHoyyY6VPnftsxodPLF0Daa/l3JufmXC7qfskWvYeAaVprCghw8dsHkZsfuML4NeeJeTMEuqGA/JCr+sVa0cTCEVa2xlEV4FZtyK99qWLGcWW0TlKpWT6OSaE7nRh8lgTL1I+p/o/2aaRtMmS7JA/FOCzX510d15V0XtITqYa X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB5565.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(7916004)(136003)(396003)(376002)(346002)(366004)(39860400002)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(66899024)(83380400001)(38100700002)(33716001)(86362001)(66946007)(8936002)(8676002)(54906003)(4326008)(6916009)(66476007)(66556008)(316002)(5660300002)(2906002)(53546011)(6512007)(9686003)(478600001)(6486002)(6506007)(6666004)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Zk1oUDNSa0VmelNCVmY2VFEyVGE1R2MxT2x2RjdkeHU1MG9BRUV4WEcvb1g5?= =?utf-8?B?VWVQSExWS25aQ0xkaUU0TG9kZnhPMlVoaVF3bnVSSUVacFhRTkxzUGpCZVk3?= =?utf-8?B?Q0QyWFBsYW5DRXBpOVVtdGxYcFl6N1lBR3R5L3M2MVdZS0JqYVhPQ0ZqU0R5?= =?utf-8?B?Tk5TSHFoZlpmMmphZnNidS83US9FZ0cvVE1SVndsWDRLRXU1czlDeGcyc2RM?= =?utf-8?B?TWc5VGlUSlhRdk1sYmNYRHc5MG5oa2RhRG13aldqcTgyZXpBMjNsZXlDY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9wWWRieGlRWHdEeUVpQ0FlWTZvdWdIdmJKaGhmRGk0?= =?utf-8?B?UkZJL1RMSm9mWFhHTEZsN0hMcTZZMjFFQ0ltNnNscWVlZExiWlk3OGduZEFO?= =?utf-8?Q?uo57uYm57L8/CoYWv87rroY+6rwbpaTWwGZtDgG90SrN?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 79d72bb2-493e-47fe-0611-08dbf281e8e8 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB5565.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2023 15:26:37.6874 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: /xG8v0cvxRfLGrMcVd0quKeS6U+sS22PCYy3BXGh+ssi8VIjW18Hfd720wFXa1rmk/bK2ro+MAP2Tk5aKOAHOQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5377 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Fri, 01 Dec 2023 07:27:00 -0800 (PST) On 12/01, Eugenio Perez Martin wrote: > On Fri, Dec 1, 2023 at 11:49 AM Dragos Tatulea wrote: > > > > Add a bitmask variable that tracks hw vq field changes that > > are supposed to be modified on next hw vq change command. > > > > This will be useful to set multiple vq fields when resuming the vq. > > > > The state needs to remain as a parameter as it doesn't make sense to > > make it part of the vq struct: fw_state is updated only after a > > successful command. > > > > I don't get this paragraph, "modified_fields" is a member of > "mlx5_vdpa_virtqueue". Am I missing something? > I think this paragraph adds more confusion than clarification. I meant to say that the state argument from modified_virtqueue needs to remain there, as opposed to integrating it into the mlx5_vdpa_virtqueue struct. > > > Signed-off-by: Dragos Tatulea > > --- > > drivers/vdpa/mlx5/net/mlx5_vnet.c | 48 +++++++++++++++++++++++++------ > > 1 file changed, 40 insertions(+), 8 deletions(-) > > > > diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c > > index 12ac3397f39b..d06285e46fe2 100644 > > --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c > > +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c > > @@ -120,6 +120,9 @@ struct mlx5_vdpa_virtqueue { > > u16 avail_idx; > > u16 used_idx; > > int fw_state; > > + > > + u64 modified_fields; > > + > > struct msi_map map; > > > > /* keep last in the struct */ > > @@ -1181,7 +1184,19 @@ static bool is_valid_state_change(int oldstate, int newstate) > > } > > } > > > > -static int modify_virtqueue(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue *mvq, int state) > > +static bool modifiable_virtqueue_fields(struct mlx5_vdpa_virtqueue *mvq) > > +{ > > + /* Only state is always modifiable */ > > + if (mvq->modified_fields & ~MLX5_VIRTQ_MODIFY_MASK_STATE) > > + return mvq->fw_state == MLX5_VIRTIO_NET_Q_OBJECT_STATE_INIT || > > + mvq->fw_state == MLX5_VIRTIO_NET_Q_OBJECT_STATE_SUSPEND; > > + > > + return true; > > +} > > + > > +static int modify_virtqueue(struct mlx5_vdpa_net *ndev, > > + struct mlx5_vdpa_virtqueue *mvq, > > + int state) > > { > > int inlen = MLX5_ST_SZ_BYTES(modify_virtio_net_q_in); > > u32 out[MLX5_ST_SZ_DW(modify_virtio_net_q_out)] = {}; > > @@ -1193,6 +1208,9 @@ static int modify_virtqueue(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtque > > if (mvq->fw_state == MLX5_VIRTIO_NET_Q_OBJECT_NONE) > > return 0; > > > > + if (!modifiable_virtqueue_fields(mvq)) > > + return -EINVAL; > > + > > I'm ok with this change, but since modified_fields is (or will be) a > bitmap tracking changes to state, addresses, mkey, etc, doesn't have > more sense to check it like: > > if (modified_fields & 1< // perform change 1 > if (modified_fields & 1< // perform change 2 > if (modified_fields & 1< // perform change 13 > --- > > Instead of: > if (!modified_fields) > return > > if (modified_fields & 1< // perform change 1 > if (modified_fields & 1< // perform change 2 > > // perform change 3, no checking, as it is the only possible value of > modified_fields > --- > > Or am I missing something? > modifiable_virtqueue_fields() is meant to check that the modification is done only in the INIT or SUSPEND state of the queue. Or did I misunderstand your question? > The rest looks good to me. > Thanks for reviewing my patches Eugenio! > > if (!is_valid_state_change(mvq->fw_state, state)) > > return -EINVAL; > > > > @@ -1208,17 +1226,28 @@ static int modify_virtqueue(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtque > > MLX5_SET(general_obj_in_cmd_hdr, cmd_hdr, uid, ndev->mvdev.res.uid); > > > > obj_context = MLX5_ADDR_OF(modify_virtio_net_q_in, in, obj_context); > > - MLX5_SET64(virtio_net_q_object, obj_context, modify_field_select, > > - MLX5_VIRTQ_MODIFY_MASK_STATE); > > - MLX5_SET(virtio_net_q_object, obj_context, state, state); > > + if (mvq->modified_fields & MLX5_VIRTQ_MODIFY_MASK_STATE) > > + MLX5_SET(virtio_net_q_object, obj_context, state, state); > > + > > + MLX5_SET64(virtio_net_q_object, obj_context, modify_field_select, mvq->modified_fields); > > err = mlx5_cmd_exec(ndev->mvdev.mdev, in, inlen, out, sizeof(out)); > > kfree(in); > > if (!err) > > mvq->fw_state = state; > > > > + mvq->modified_fields = 0; > > + > > return err; > > } > > > > +static int modify_virtqueue_state(struct mlx5_vdpa_net *ndev, > > + struct mlx5_vdpa_virtqueue *mvq, > > + unsigned int state) > > +{ > > + mvq->modified_fields |= MLX5_VIRTQ_MODIFY_MASK_STATE; > > + return modify_virtqueue(ndev, mvq, state); > > +} > > + > > static int counter_set_alloc(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue *mvq) > > { > > u32 in[MLX5_ST_SZ_DW(create_virtio_q_counters_in)] = {}; > > @@ -1347,7 +1376,7 @@ static int setup_vq(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue *mvq) > > goto err_vq; > > > > if (mvq->ready) { > > - err = modify_virtqueue(ndev, mvq, MLX5_VIRTIO_NET_Q_OBJECT_STATE_RDY); > > + err = modify_virtqueue_state(ndev, mvq, MLX5_VIRTIO_NET_Q_OBJECT_STATE_RDY); > > if (err) { > > mlx5_vdpa_warn(&ndev->mvdev, "failed to modify to ready vq idx %d(%d)\n", > > idx, err); > > @@ -1382,7 +1411,7 @@ static void suspend_vq(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue *m > > if (mvq->fw_state != MLX5_VIRTIO_NET_Q_OBJECT_STATE_RDY) > > return; > > > > - if (modify_virtqueue(ndev, mvq, MLX5_VIRTIO_NET_Q_OBJECT_STATE_SUSPEND)) > > + if (modify_virtqueue_state(ndev, mvq, MLX5_VIRTIO_NET_Q_OBJECT_STATE_SUSPEND)) > > mlx5_vdpa_warn(&ndev->mvdev, "modify to suspend failed\n"); > > > > if (query_virtqueue(ndev, mvq, &attr)) { > > @@ -1407,6 +1436,7 @@ static void teardown_vq(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue * > > return; > > > > suspend_vq(ndev, mvq); > > + mvq->modified_fields = 0; > > destroy_virtqueue(ndev, mvq); > > dealloc_vector(ndev, mvq); > > counter_set_dealloc(ndev, mvq); > > @@ -2207,7 +2237,7 @@ static void mlx5_vdpa_set_vq_ready(struct vdpa_device *vdev, u16 idx, bool ready > > if (!ready) { > > suspend_vq(ndev, mvq); > > } else { > > - err = modify_virtqueue(ndev, mvq, MLX5_VIRTIO_NET_Q_OBJECT_STATE_RDY); > > + err = modify_virtqueue_state(ndev, mvq, MLX5_VIRTIO_NET_Q_OBJECT_STATE_RDY); > > if (err) { > > mlx5_vdpa_warn(mvdev, "modify VQ %d to ready failed (%d)\n", idx, err); > > ready = false; > > @@ -2804,8 +2834,10 @@ static void clear_vqs_ready(struct mlx5_vdpa_net *ndev) > > { > > int i; > > > > - for (i = 0; i < ndev->mvdev.max_vqs; i++) > > + for (i = 0; i < ndev->mvdev.max_vqs; i++) { > > ndev->vqs[i].ready = false; > > + ndev->vqs[i].modified_fields = 0; > > + } > > > > ndev->mvdev.cvq.ready = false; > > } > > -- > > 2.42.0 > > >