From patchwork Mon Jul 8 12:00:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dragos Tatulea X-Patchwork-Id: 13726511 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2052.outbound.protection.outlook.com [40.107.101.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E4285137905; Mon, 8 Jul 2024 12:02:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.101.52 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720440125; cv=fail; b=o678P4lHIjssdl2GDAGZ77eDKuYTrQWp7Ud0wmEvV65jaJaGsU2aLjBM6/OVJNGOoY0dGeOOAjye6gezTLErFd7920Lc7Vf73mZufvIPOqZ4r/niBsPzqdYPV52qLaIOfwX3Te/sFLnU1HxRlOUfz8bTIctlySJ0/4Vnu+FzCjU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720440125; c=relaxed/simple; bh=zbvR064F158vGkW71AjcuFOO/I2BUq0oz2eUDxbT+08=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=DJwPMTfAeBscBaQK6cZviNstuKlhCua2cvBuyuVCoY5ocsWCv/xbGymOxqAYxIjEnA6sciPlDR7/QZWIf8rc20Y7p+2qt6J9c3tA37iRkBlcFryAoDUJVCM1aEOo++6g9N+u3y/LQUFSZBsHhbanJzmsS6t24SW3YHMQkVScr98= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=suGpCmBb; arc=fail smtp.client-ip=40.107.101.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="suGpCmBb" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Usw8b+MpzurEVB777+oOmJWI+qZOrEs6/LrSITge46RJBbxpK2PXaQGmrWn1OsX2B++cTn7B+xpBpXhzfk+gHf30Gr6a020aJfAYo0usJ4TBd1ecsXfQkqIqMt1oQE9Osu2WxGf4dgoRDUvME9IdKA3CZ75ILXd25edIZS3YTk4X9IffUAj5szw/Tl89prY+FYTwqURpseQnoyekg/4HnNNzJ8m9P+Nzxn6k+3z9OWjzH4TnIvY/1kYnAT+gzSOtF3eB5ipp4YN84AmJOJECDHQ8j+tYaC7cEQjOY9tBEn4bj9esMcJYNCzXs5HISNWaiyZDgvAGENC/cnqLJhbIag== 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=49ogM+1PCvscEbo1kjuXz4sYCHgwi0TBWnBxosHTgS8=; b=C98JL7wYfRFsDCU6caVn6zMgJNOjh0xTzNoHrL5MULDOwe1QeTp0tV5br24W4zoflVT2ECLo5JXcw+nXZZJpZXAh8hQfkQ+gJNkPbxmmezFDji8NQnFMaPyEI5a5OFtpDs6jMdudlxlwlTNtCt+rAuTSX0Ve+nJFcAMxcd0JXaQ1uJ3vqi0Z+kX/wnjtUWqhcZktI1B3zvIr8OvG6PT5zPgyx37jg+aE+qlVTJTIht+jOkxJ2loDtJj7nNHfTQ7DIEHCjS1XV7l3hpGnM5d7p3oAVNBHyJjsFO8yvlodnbf7wxy8ZPZCKNJqGFA5IsSwHH4XPifVV/aSCsV8bXUqYA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=oracle.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) 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=49ogM+1PCvscEbo1kjuXz4sYCHgwi0TBWnBxosHTgS8=; b=suGpCmBbwjTmnsnNNGxuc5PD4PWV43u+OKIFkZi2Gafz+HNBe5pmJTfRH7IUZx+1cPYqkKqXENmtwRllBz8w/Dr6058U3iIiaYjRzUGyBZJ3KGdhj1HAmo9T4lhX9uZ3uwpXaDwLxjS61Psx8USpk9sIzeVkvPMenK9kSWvjnIRhJD0eykDUNjnWTwmfaq3hD3FsqTydm3atCa9Ubj4F3BE8Ss1vt3qrR7MIlaA1KEVRGJtaRah8XxpQrQ+/cIL+MHt/Zg/DytJ27GN6bLW1q+gLJVGSbGDC9kG/TByvydeHWAsMDigSU/fPi1pf36DiprLCfKzondXVigd4xgOuUw== Received: from BL1PR13CA0270.namprd13.prod.outlook.com (2603:10b6:208:2ba::35) by DS0PR12MB9273.namprd12.prod.outlook.com (2603:10b6:8:193::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.35; Mon, 8 Jul 2024 12:02:00 +0000 Received: from BL6PEPF0001AB73.namprd02.prod.outlook.com (2603:10b6:208:2ba:cafe::27) by BL1PR13CA0270.outlook.office365.com (2603:10b6:208:2ba::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.22 via Frontend Transport; Mon, 8 Jul 2024 12:02:00 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BL6PEPF0001AB73.mail.protection.outlook.com (10.167.242.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.17 via Frontend Transport; Mon, 8 Jul 2024 12:01:59 +0000 Received: from rnnvmail204.nvidia.com (10.129.68.6) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 8 Jul 2024 05:01:39 -0700 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail204.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 8 Jul 2024 05:01:39 -0700 Received: from dev-l-177.mtl.labs.mlnx (10.127.8.11) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Mon, 8 Jul 2024 05:01:35 -0700 From: Dragos Tatulea Date: Mon, 8 Jul 2024 15:00:34 +0300 Subject: [PATCH vhost v3 10/24] vdpa/mlx5: Add support for modifying the virtio_version VQ field Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240708-stage-vdpa-vq-precreate-v3-10-afe3c766e393@nvidia.com> References: <20240708-stage-vdpa-vq-precreate-v3-0-afe3c766e393@nvidia.com> In-Reply-To: <20240708-stage-vdpa-vq-precreate-v3-0-afe3c766e393@nvidia.com> To: "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?utf-8?q?Eugenio_P=C3=A9rez?= , Saeed Mahameed , Leon Romanovsky , Tariq Toukan , Si-Wei Liu CC: , , , , Dragos Tatulea , Cosmin Ratiu X-Mailer: b4 0.13.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB73:EE_|DS0PR12MB9273:EE_ X-MS-Office365-Filtering-Correlation-Id: b4a759f1-a5f5-4a46-00a7-08dc9f45c5e0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|376014|7416014|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?q?WJ8YhcgneBVrATEbjrxT5k5ogiQAtgp?= =?utf-8?q?EJAO677QOGl8ewXI9SqjinpudsZJaK43cLJooSWqidvL9K2RmwjrIZZJkqs3iIh1b?= =?utf-8?q?DNKzeZwwmMjltX/8cWHxkNm072+C6t4UWx4GXotC+QIfZnXNoEqCR7772EeblhoKl?= =?utf-8?q?B1Qxekz/8TWQdmAXiuny2EsAxlBM6KtQ8yIa5eM+oXZbRoY4tJfs158t0yFS8oWg6?= =?utf-8?q?TPhr3IquyN0owvb4Hp8ukbTPPAlFY6naGm2zehxr5v2RuI1+SGm5smW5LXQe9yjrs?= =?utf-8?q?z4YK9QIiomG48mvJb4RyOZKben5pbTN7CBtnOqEQlzj+ReiSycE2pUCngeigDOc8A?= =?utf-8?q?JqAdDKfHO8tZ9Ej7mlzN88KLbAMTJHJdcuuEyN5nKoYUchJiDB83/JK3jR6ahN76p?= =?utf-8?q?y6up7xjXX3m02GA04NeIxlVbNIVUa6Vj9DUehZ0pmXafY87uZM6lGidIjPwBQJt21?= =?utf-8?q?4iQyrCuXW9VoEOmNFjcscZuK8HipwdRKVDqPJVR5/d0fIvaAVVVDWrG9tWzlxTdUZ?= =?utf-8?q?0quDj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p?= X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230040)(82310400026)(1800799024)(376014)(7416014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2024 12:01:59.9244 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b4a759f1-a5f5-4a46-00a7-08dc9f45c5e0 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB73.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB9273 This is done in preparation for the pre-creation of hardware virtqueues at device add time. Signed-off-by: Dragos Tatulea Reviewed-by: Cosmin Ratiu --- drivers/vdpa/mlx5/net/mlx5_vnet.c | 16 ++++++++++++++++ include/linux/mlx5/mlx5_ifc_vdpa.h | 1 + 2 files changed, 17 insertions(+) diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c index 739c2886fc33..b104849f8477 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c @@ -1283,6 +1283,10 @@ static int modify_virtqueue(struct mlx5_vdpa_net *ndev, if (mvq->modified_fields & MLX5_VIRTQ_MODIFY_MASK_VIRTIO_Q_USED_IDX) MLX5_SET(virtio_net_q_object, obj_context, hw_used_index, mvq->used_idx); + if (mvq->modified_fields & MLX5_VIRTQ_MODIFY_MASK_QUEUE_VIRTIO_VERSION) + MLX5_SET(virtio_q, vq_ctx, virtio_version_1_0, + !!(ndev->mvdev.actual_features & BIT_ULL(VIRTIO_F_VERSION_1))); + if (mvq->modified_fields & MLX5_VIRTQ_MODIFY_MASK_VIRTIO_Q_MKEY) { vq_mr = mvdev->mr[mvdev->group2asid[MLX5_VDPA_DATAVQ_GROUP]]; @@ -2709,6 +2713,7 @@ static int mlx5_vdpa_set_driver_features(struct vdpa_device *vdev, u64 features) { struct mlx5_vdpa_dev *mvdev = to_mvdev(vdev); struct mlx5_vdpa_net *ndev = to_mlx5_vdpa_ndev(mvdev); + u64 old_features = mvdev->actual_features; int err; print_features(mvdev, features, true); @@ -2723,6 +2728,17 @@ static int mlx5_vdpa_set_driver_features(struct vdpa_device *vdev, u64 features) else ndev->rqt_size = 1; + /* Interested in changes of vq features only. */ + if (get_features(old_features) != get_features(mvdev->actual_features)) { + for (int i = 0; i < mvdev->max_vqs; ++i) { + struct mlx5_vdpa_virtqueue *mvq = &ndev->vqs[i]; + + mvq->modified_fields |= ( + MLX5_VIRTQ_MODIFY_MASK_QUEUE_VIRTIO_VERSION + ); + } + } + update_cvq_info(mvdev); return err; } diff --git a/include/linux/mlx5/mlx5_ifc_vdpa.h b/include/linux/mlx5/mlx5_ifc_vdpa.h index 40371c916cf9..34f27c01cec9 100644 --- a/include/linux/mlx5/mlx5_ifc_vdpa.h +++ b/include/linux/mlx5/mlx5_ifc_vdpa.h @@ -148,6 +148,7 @@ enum { MLX5_VIRTQ_MODIFY_MASK_VIRTIO_Q_ADDRS = (u64)1 << 6, MLX5_VIRTQ_MODIFY_MASK_VIRTIO_Q_AVAIL_IDX = (u64)1 << 7, MLX5_VIRTQ_MODIFY_MASK_VIRTIO_Q_USED_IDX = (u64)1 << 8, + MLX5_VIRTQ_MODIFY_MASK_QUEUE_VIRTIO_VERSION = (u64)1 << 10, MLX5_VIRTQ_MODIFY_MASK_VIRTIO_Q_MKEY = (u64)1 << 11, MLX5_VIRTQ_MODIFY_MASK_DESC_GROUP_MKEY = (u64)1 << 14, };