85 lines
3.1 KiB
Diff
85 lines
3.1 KiB
Diff
From deaf4963449dd436d854c56969edc939d10a0311 Mon Sep 17 00:00:00 2001
|
|
From: Kamal Heib <kheib@redhat.com>
|
|
Date: Mon, 20 Apr 2026 14:56:34 -0400
|
|
Subject: [PATCH] net/mlx5: Refactor PTP clock devcom pairing
|
|
|
|
JIRA: https://redhat.atlassian.net/browse/RHEL-169055
|
|
|
|
commit cd36818c34ac5ff7f6a50ce88822c7bbb5ac9e0d
|
|
Author: Mark Bloch <mbloch@nvidia.com>
|
|
Date: Thu Oct 23 12:16:58 2025 +0300
|
|
|
|
net/mlx5: Refactor PTP clock devcom pairing
|
|
|
|
Refactor PTP clock device component pairing to use the clock identity
|
|
buffer instead of casting it to a u64 key. This change leverages the new
|
|
software system image GUID infrastructure.
|
|
|
|
Changes include:
|
|
- Pass identity buffer to mlx5_shared_clock_register().
|
|
- Use memcpy for identity buffer in devcom matching attributes.
|
|
- Remove intermediate u64 key conversion.
|
|
- Add BUILD_BUG_ON to ensure identity size fits in match key.
|
|
|
|
Signed-off-by: Mark Bloch <mbloch@nvidia.com>
|
|
Reviewed-by: Shay Drori <shayd@nvidia.com>
|
|
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
|
|
Link: https://patch.msgid.link/1761211020-925651-4-git-send-email-tariqt@nvidia.com
|
|
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
|
|
|
Signed-off-by: Kamal Heib <kheib@redhat.com>
|
|
|
|
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
|
|
index 29e7fa09c32c..0ba0ef8bae42 100644
|
|
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
|
|
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
|
|
@@ -1432,15 +1432,17 @@ static int mlx5_clock_alloc(struct mlx5_core_dev *mdev, bool shared)
|
|
return 0;
|
|
}
|
|
|
|
-static void mlx5_shared_clock_register(struct mlx5_core_dev *mdev, u64 key)
|
|
+static void mlx5_shared_clock_register(struct mlx5_core_dev *mdev,
|
|
+ u8 identity[MLX5_RT_CLOCK_IDENTITY_SIZE])
|
|
{
|
|
struct mlx5_core_dev *peer_dev, *next = NULL;
|
|
- struct mlx5_devcom_match_attr attr = {
|
|
- .key.val = key,
|
|
- };
|
|
+ struct mlx5_devcom_match_attr attr = {};
|
|
struct mlx5_devcom_comp_dev *compd;
|
|
struct mlx5_devcom_comp_dev *pos;
|
|
|
|
+ BUILD_BUG_ON(MLX5_RT_CLOCK_IDENTITY_SIZE > MLX5_DEVCOM_MATCH_KEY_MAX);
|
|
+ memcpy(attr.key.buf, identity, MLX5_RT_CLOCK_IDENTITY_SIZE);
|
|
+
|
|
compd = mlx5_devcom_register_component(mdev->priv.devc,
|
|
MLX5_DEVCOM_SHARED_CLOCK,
|
|
&attr, NULL, mdev);
|
|
@@ -1594,7 +1596,6 @@ int mlx5_init_clock(struct mlx5_core_dev *mdev)
|
|
{
|
|
u8 identity[MLX5_RT_CLOCK_IDENTITY_SIZE];
|
|
struct mlx5_clock_dev_state *clock_state;
|
|
- u64 key;
|
|
int err;
|
|
|
|
if (!MLX5_CAP_GEN(mdev, device_frequency_khz)) {
|
|
@@ -1610,12 +1611,10 @@ int mlx5_init_clock(struct mlx5_core_dev *mdev)
|
|
mdev->clock_state = clock_state;
|
|
|
|
if (MLX5_CAP_MCAM_REG3(mdev, mrtcq) && mlx5_real_time_mode(mdev)) {
|
|
- if (mlx5_clock_identity_get(mdev, identity)) {
|
|
+ if (mlx5_clock_identity_get(mdev, identity))
|
|
mlx5_core_warn(mdev, "failed to get rt clock identity, create ptp dev per function\n");
|
|
- } else {
|
|
- memcpy(&key, &identity, sizeof(key));
|
|
- mlx5_shared_clock_register(mdev, key);
|
|
- }
|
|
+ else
|
|
+ mlx5_shared_clock_register(mdev, identity);
|
|
}
|
|
|
|
if (!mdev->clock) {
|
|
--
|
|
2.50.1 (Apple Git-155)
|
|
|