From patchwork Wed Jun 26 10:26:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dragos Tatulea X-Patchwork-Id: 13712575 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2086.outbound.protection.outlook.com [40.107.236.86]) (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 095E6184124; Wed, 26 Jun 2024 10:27:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.86 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719397664; cv=fail; b=htEHiQfHsWUG4B0/tDm2WrZZ+YExYByX/0C2zSSUxaCf6Ie/VXcog8QeKq8qKbejaGUfVJGLCI3HhB5rSTHpe4N2+xVz631IoNcpOs17eAGGAr8BaOzjdK2hnQfbmIR4iYhoZ3S9WaKeQiJ5qKdDhanAoLusl/hxa77I2zXRNf0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719397664; c=relaxed/simple; bh=uZvmrWO/j45vltG/Nhcg7pY6TIaM60oqJNJMuTNAtUI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=LGr3rzIrdVzwL+cq22Bmh+guEolKYcpwOvFvlRj3UiWfhBxwfnUOSEF7yBsAYD4kAsUq70/ivRTfjUejcH6UV6QylNw/w2hM+l7Q7l5WPvsvMlzTlwAXcQR++jtGyIfzBnYi7jVWzV2DPWwkEDS3YzDSKYWzSkK5RZN4UzjXJIo= 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=rF91A+dB; arc=fail smtp.client-ip=40.107.236.86 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="rF91A+dB" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YrWckY95RFQASu/zbrCPniw3hHYEOr7r0ZmMNovGrxicT8fd2b8Ig+jb3jEFT2msDS2rhk7vPh9FgtJoXr5MhFak1TBb5iWK82aOEiSc1IlcQrDdK2TZS51t+fG4nx5NP9SbpXxXnV3sDjW5IFpFiMA36W75exiKd70xrPUWLwQT4FXofEtCA7GgRyN/a2/WjQ4Ozn98gg1O5E1tb5XOoFYo3+Fk+ERQ0CWzAw6AVUjjLEP5/hntb2flTvj1FurTI86+yF3keGgaKwhkByoJrLWGQ13uwqEAzrTE4wfPjVVfxfru5GtmUM720m+JD8m5pi9jVF3Iw5Z9I/qPIPJgxw== 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=WENTZBLDblOHFvxqPw/a/sE2ap9DMHK/kXfx3y8FtaA=; b=HFnHuIWbhJmdaJXR8A/y8UnpKd+fjZLbInC6/o2MTq5+wH6Yo4G3wle0uHxYYdUq+RiBK2ApSuTVI2uyvZNdCBF8ETmJuH/yAG7w7BkyfhIx1r6xir6CkQa4uolP9WyOIxAsUHrWYs6PXYS4OFFK0HMMUvceyuv37fTsBujjOymDW8VxECeJ0tHITN6z1d+yhn/5UWc01dZKfsVj2YjOGLKLXPg14jyasZvqAchFYVmeExt9Qdf7bvcnDjeiXQpI4iljIdIO5BWIOLsx99EiSQywrTPIpIcUws/iA1W7FAmxn7B5Ze2NKPYyH9G0MAko/wQoH6lUeCQiUqKx5aE6TQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=vger.kernel.org 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=WENTZBLDblOHFvxqPw/a/sE2ap9DMHK/kXfx3y8FtaA=; b=rF91A+dBkgfgJfyJuPjOoWgOMdsexESef3wcfEjVYRthfge8NRtUqYgF9JnSjDAdvcScKIOfPRnELHqhJnFxf4afsWjJecc/xXLA0z5kSrqq1ZMWqp+YtoJriYGXPh6OH3NCdrd4GAAuUFQzWRFI1qlzRBaz7yW3w7v/VVciKTmd4imN7yjJCHnWZe5kbzXb3vnWdlM/crtFL2aWoKFwZNXDndrZ9CgZf2FyEfRqFAR3lA35MUV3A4mRHuFkTzvtEBb5Pwp/S9GSx356sXKuSRKntGHQslieouS8a6e8J7GoNFhbs8LbuA74xqeKow0z1mjO43gJGk02+3YAvjR+Rw== Received: from BL1PR13CA0025.namprd13.prod.outlook.com (2603:10b6:208:256::30) by DS7PR12MB6069.namprd12.prod.outlook.com (2603:10b6:8:9f::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.32; Wed, 26 Jun 2024 10:27:39 +0000 Received: from BL6PEPF00020E65.namprd04.prod.outlook.com (2603:10b6:208:256:cafe::5c) by BL1PR13CA0025.outlook.office365.com (2603:10b6:208:256::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.22 via Frontend Transport; Wed, 26 Jun 2024 10:27:39 +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 BL6PEPF00020E65.mail.protection.outlook.com (10.167.249.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.15 via Frontend Transport; Wed, 26 Jun 2024 10:27:39 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) 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; Wed, 26 Jun 2024 03:27:27 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 26 Jun 2024 03:27:27 -0700 Received: from dev-l-177.mtl.labs.mlnx (10.127.8.11) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Wed, 26 Jun 2024 03:27:23 -0700 From: Dragos Tatulea Date: Wed, 26 Jun 2024 13:26:46 +0300 Subject: [PATCH vhost v2 10/24] vdpa/mlx5: Add support for modifying the virtio_version VQ field Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240626-stage-vdpa-vq-precreate-v2-10-560c491078df@nvidia.com> References: <20240626-stage-vdpa-vq-precreate-v2-0-560c491078df@nvidia.com> In-Reply-To: <20240626-stage-vdpa-vq-precreate-v2-0-560c491078df@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: BL6PEPF00020E65:EE_|DS7PR12MB6069:EE_ X-MS-Office365-Filtering-Correlation-Id: bdefe25e-b6b9-4796-b0b6-08dc95ca9aea X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230038|36860700011|376012|7416012|1800799022|82310400024; X-Microsoft-Antispam-Message-Info: =?utf-8?q?LeMgQxMPTIUQkiJT393knukObbwY1t2?= =?utf-8?q?lEZNq6CrsyJ8BCdqUFrN5gQKyNYh8djumM/sWAbZnbduS9W9UNih0/6DAv9UnhMFS?= =?utf-8?q?3ITlWPd3W4z+eswCjeqjz7Si5b61NowyeYn0Lt0M2i2FopBUX1cq0M7PuAc5tPpp2?= =?utf-8?q?72Kdc+hrPNXf4ik0i2E54bdGzpaD14vwj8A8lLq8GvOZXVHUHs99YOQVnWbo1EIEr?= =?utf-8?q?mNCdJx/RmJsIqKVwVSntyBx+WJcxhx0F+RTF2ZsyGqK72KpxLdY3X9aoWEgOkx1oT?= =?utf-8?q?aVT0GIBuJXWEePOpBy/NadGAmhj+coqNFtDrvglUXdEKt4bdav19PP4HvXHnNGm6c?= =?utf-8?q?0zsvEA27X8/OpT9YNoJm11x2WoZXXolVkicAj14M0ECA0z73yPkdcvDKhah7DiXIV?= =?utf-8?q?jyvA8amdKwl5KuD9kIayZZVN8tNuT40busgP2RE+xakXSzrvtJOS5KgORGT0BTc73?= =?utf-8?q?X5gxDn7HFjWuo3pgsbJTuvKd9Yz6/kM/cKENQ/oI8swZb9q8KRGqWY5owh2ROWiT0?= =?utf-8?q?g1h5J4C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V:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230038)(36860700011)(376012)(7416012)(1800799022)(82310400024);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jun 2024 10:27:39.2740 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bdefe25e-b6b9-4796-b0b6-08dc95ca9aea 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: BL6PEPF00020E65.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6069 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, };