From patchwork Mon Jun 17 15:07:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dragos Tatulea X-Patchwork-Id: 13700945 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2089.outbound.protection.outlook.com [40.107.95.89]) (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 DD62B153511; Mon, 17 Jun 2024 15:09:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.89 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718636969; cv=fail; b=MBg1XD8Y44o/aK39YvU5PpfSQMeu/DKO+St+iXboeKdGtNIpwp6+KIVnzWMV2Tvj3qBvssIbNq2xM9s4H0h8X5n2jDRY9MM4H8Z77mqa+QMRRjvwvCz/+3XUnkphmsSsqUWsSF2liI4+jPLeV/EpkzBsdfTXHmi4JWWrhklxJEI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718636969; c=relaxed/simple; bh=nGrkEuM6V+w5uB7BA28bNQiRi0JlbeBt8uw3GSdO/i4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=GJ7h1p5g/3zm/bCwzkCDoKxSRlvZbHehyUz07Fnzc47qg6/Q2NW+XxG4iHWRk8sHClTJvqr2NkeTRyNidmCwyOV8l2XU0MS1Mqc4IG3pnGzHivp82H2otXfjM5Mv9CvZqyf+LD4QR4eD5Dtb/yN2Uypo/bGmv6WSi9dML5kXxZQ= 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=ZhIk7L8C; arc=fail smtp.client-ip=40.107.95.89 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="ZhIk7L8C" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P7aV66aVW8/WiLJv2IC3pBuUg6oM8f/LV7Ui6nZ2PvSujXdBhPQ/j4x+bcCzq//LEQTY/u0Gw3qh39NteOMN0io0mf7IQoLv34DRY9fGqPjZOLlNzYZaLTj2y6KZ3mzC/EfSI53pP8xJX7PGusLmiMB6plvn7uS03A3bz4dzgF+aEhiYTRwxP0ZA9nD+N++TeK7xAGngNWZngsQ+gPN+qfKfLlB4zH6WHWJTA/okQdmbSHgH3JxiR6Bu5i5MUsDnGT4hRi4OjWdB1cjMAkOZwIG6BunUDwNNC9FtqskNtqONTQgS+ihkOUUBiZlHK6mRo8jD27y72Yeh8CGJtGq6MQ== 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=bBnCTbq4ZFBVLXlkrqTHPkFV/4UN4TiMr0Pk3hG0w2c=; b=PchHgmbvUi9WURRkamqO76XbqUo5NBVMn7WLBYQBShRvYGHUG1V0eZ+vMivkdz2zX3/vs5nhe7OQFRkZksaLDkS3tNtQEQcjoC9RliQghu610kLewPK1GMit/4jjWIbSbM2bcnzL/pD28PhKPMQe3rkPaziK93VATdfw13o+4zZngjlfJeZPXwXe6hP9F/Se+pZcLheNAKCK9z7LgzDI/GF2Lr8Y6JNuDEJiMgNuUUa6wl2lh2ZyB/bNguC36BE5DHRqKK3CwwJGCannVdiUDK+1yOO+G19AQqbWBZaZBOT+8CRlVETTfXeneHysf1+zJEh5A4CGwIW8KeCFw7K58w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=redhat.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=bBnCTbq4ZFBVLXlkrqTHPkFV/4UN4TiMr0Pk3hG0w2c=; b=ZhIk7L8CfkS3NK3FsqzafukzYEqBU+tSJI5460DhY5+4LxhllEGfoki/SsaUdA9XocEb6e7gCNL76xiJQZ1GW3/NiaBY4a0270VqHOYa/+XnOSrofrDb4bWqq/0dM+/HKeQbpqSyEto+dTl0SYthiMtWehwaBh34vqpwzOniTfnsp8TggWzwsh6TZuLjGrIdsBviZjfELKeyNJm91IqbqVbJ6ZGbdaddiLhedD9lNC/YwcmoAaYq1QvojT4ndIbLRL1TMLya+UYtj2eAsoiBMzZ8V/dSLfpZSQ+B0WmS9JMTpuY7XOYv5fex4apGBK0HkhmZPYNl8E9A9Fj+2z31sQ== Received: from SA1PR04CA0003.namprd04.prod.outlook.com (2603:10b6:806:2ce::7) by PH0PR12MB7930.namprd12.prod.outlook.com (2603:10b6:510:283::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.30; Mon, 17 Jun 2024 15:09:23 +0000 Received: from SA2PEPF00003AEA.namprd02.prod.outlook.com (2603:10b6:806:2ce:cafe::6b) by SA1PR04CA0003.outlook.office365.com (2603:10b6:806:2ce::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.30 via Frontend Transport; Mon, 17 Jun 2024 15:09:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) 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.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by SA2PEPF00003AEA.mail.protection.outlook.com (10.167.248.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.15 via Frontend Transport; Mon, 17 Jun 2024 15:09:23 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 17 Jun 2024 08:09:10 -0700 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 17 Jun 2024 08:09:10 -0700 Received: from dev-l-177.mtl.labs.mlnx (10.127.8.11) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Mon, 17 Jun 2024 08:09:07 -0700 From: Dragos Tatulea Date: Mon, 17 Jun 2024 18:07:55 +0300 Subject: [PATCH vhost 21/23] vdpa/mlx5: Re-create HW VQs under certain conditions Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240617-stage-vdpa-vq-precreate-v1-21-8c0483f0ca2a@nvidia.com> References: <20240617-stage-vdpa-vq-precreate-v1-0-8c0483f0ca2a@nvidia.com> In-Reply-To: <20240617-stage-vdpa-vq-precreate-v1-0-8c0483f0ca2a@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: SA2PEPF00003AEA:EE_|PH0PR12MB7930:EE_ X-MS-Office365-Filtering-Correlation-Id: 0f249845-61e2-4aa7-da77-08dc8edf78a0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230037|7416011|36860700010|376011|1800799021|82310400023; X-Microsoft-Antispam-Message-Info: =?utf-8?q?BCmAkK4AN/vOMg2jVJHR5Ox4KHHBjRY?= =?utf-8?q?vmN8ohaMoN3GaK/FtxFXZiQUorQvcsOFzsMbFU2jUeYA1hofvRThmbPHdCoxmMgy7?= =?utf-8?q?B2KFqldktnm5KSBbLuGedctY9kLkJIh5DBe7PC9uRAP0W4OodTHJB5lhdNPW9ReDu?= =?utf-8?q?RXZpE++0VfDTC+z3lV6uYA7NivUGCB1oLxZNmlvLzB163Bs6EiKFQZAwyPHlCoI8M?= =?utf-8?q?0/3mcJmo0cimW+VNLByA4RuR8VyqtSH1g+4GXBb56lXK7QwkMuA4UQz39PoHMOYnx?= =?utf-8?q?p6BHaYPuW2HYfkT4PGg8MSnj2/o2UEtxyHBBqO3Uwo0+cZMQJXT+ooS3kVIUYZzg0?= =?utf-8?q?hHbhr61FcBUnkPIRO5hxTu6W/kqfrsOEmNQRkp4KnHUgQ6ONMuVjvjg2OL9N9+AeG?= =?utf-8?q?msnYYMBJvKYBoKtf/ajsDxfStPT8OrA6/ViJY6tLjAO9MKYvX2EIY4PVvl2oBS+yf?= =?utf-8?q?CVhpXeWjYu3rhlWtPn74yDu6vESW2WBSOpvbG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D=3D?= X-Forefront-Antispam-Report: CIP:216.228.118.232;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge1.nvidia.com;CAT:NONE;SFS:(13230037)(7416011)(36860700010)(376011)(1800799021)(82310400023);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jun 2024 15:09:23.0551 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0f249845-61e2-4aa7-da77-08dc8edf78a0 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00003AEA.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7930 There are a few conditions under which the hardware VQs need a full teardown and setup: - VQ size changed to something else than default value. Hardware VQ size modification is not supported. - User turns off certain device features: mergeable buffers, checksum virtio 1.0 compliance. In these cases, the TIR and RQT need to be re-created. Add a needs_teardown configuration variable and set it when detecting the above scenarios. On next DRIVER_OK, the resources will be torn down first. Signed-off-by: Dragos Tatulea Reviewed-by: Cosmin Ratiu Acked-by: Eugenio PĂ©rez --- drivers/vdpa/mlx5/net/mlx5_vnet.c | 15 +++++++++++++++ drivers/vdpa/mlx5/net/mlx5_vnet.h | 1 + 2 files changed, 16 insertions(+) diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c index b2836fd3d1dd..d80d6b47da61 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c @@ -2390,6 +2390,7 @@ static void mlx5_vdpa_set_vq_num(struct vdpa_device *vdev, u16 idx, u32 num) } mvq = &ndev->vqs[idx]; + ndev->needs_teardown = num != mvq->num_ent; mvq->num_ent = num; } @@ -2800,6 +2801,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; + u64 diff_features; int err; print_features(mvdev, features, true); @@ -2822,6 +2824,14 @@ static int mlx5_vdpa_set_driver_features(struct vdpa_device *vdev, u64 features) } } + /* When below features diverge from initial device features, VQs need a full teardown. */ +#define NEEDS_TEARDOWN_MASK (BIT_ULL(VIRTIO_NET_F_MRG_RXBUF) | \ + BIT_ULL(VIRTIO_NET_F_CSUM) | \ + BIT_ULL(VIRTIO_F_VERSION_1)) + + diff_features = mvdev->mlx_features ^ mvdev->actual_features; + ndev->needs_teardown = !!(diff_features & NEEDS_TEARDOWN_MASK); + update_cvq_info(mvdev); return err; } @@ -3038,6 +3048,7 @@ static void teardown_vq_resources(struct mlx5_vdpa_net *ndev) destroy_rqt(ndev); teardown_virtqueues(ndev); ndev->setup = false; + ndev->needs_teardown = false; } static int setup_cvq_vring(struct mlx5_vdpa_dev *mvdev) @@ -3078,6 +3089,10 @@ static void mlx5_vdpa_set_status(struct vdpa_device *vdev, u8 status) goto err_setup; } register_link_notifier(ndev); + + if (ndev->needs_teardown) + teardown_vq_resources(ndev); + if (ndev->setup) { err = resume_vqs(ndev); if (err) { diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.h b/drivers/vdpa/mlx5/net/mlx5_vnet.h index 2ada29767cc5..da7318f82d2a 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.h +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.h @@ -56,6 +56,7 @@ struct mlx5_vdpa_net { struct dentry *rx_dent; struct dentry *rx_table_dent; bool setup; + bool needs_teardown; u32 cur_num_vqs; u32 rqt_size; u16 default_queue_size;