From: Tariq Toukan <tariqt@nvidia.com>
To: Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>
Cc: Saeed Mahameed <saeedm@nvidia.com>,
Leon Romanovsky <leon@kernel.org>,
Tariq Toukan <tariqt@nvidia.com>, Mark Bloch <mbloch@nvidia.com>,
<netdev@vger.kernel.org>, <linux-rdma@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, Gal Pressman <gal@nvidia.com>,
Moshe Shemesh <moshe@nvidia.com>, Shay Drori <shayd@nvidia.com>
Subject: [PATCH net-next 3/5] net/mlx5: Refactor PTP clock devcom pairing
Date: Thu, 23 Oct 2025 12:16:58 +0300 [thread overview]
Message-ID: <1761211020-925651-4-git-send-email-tariqt@nvidia.com> (raw)
In-Reply-To: <1761211020-925651-1-git-send-email-tariqt@nvidia.com>
From: Mark Bloch <mbloch@nvidia.com>
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>
---
.../ethernet/mellanox/mlx5/core/lib/clock.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
index d0ba83d77cd1..759033a18ad9 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.31.1
next prev parent reply other threads:[~2025-10-23 9:18 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-23 9:16 [PATCH net-next 0/5] net/mlx5: Add balance ID support for LAG multiplane groups Tariq Toukan
2025-10-23 9:16 ` [PATCH net-next 1/5] net/mlx5: Use common mlx5_same_hw_devs function Tariq Toukan
2025-10-23 9:16 ` [PATCH net-next 2/5] net/mlx5: Add software system image GUID infrastructure Tariq Toukan
2025-10-23 9:16 ` Tariq Toukan [this message]
2025-10-23 9:16 ` [PATCH net-next 4/5] net/mlx5: Refactor HCA cap 2 setting Tariq Toukan
2025-10-23 9:17 ` [PATCH net-next 5/5] net/mlx5: Add balance ID support for LAG multiplane groups Tariq Toukan
2025-10-25 23:59 ` [PATCH net-next 0/5] " Zhu Yanjun
2025-10-26 12:53 ` Tariq Toukan
2025-10-28 10:13 ` Paolo Abeni
2025-10-28 10:20 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1761211020-925651-4-git-send-email-tariqt@nvidia.com \
--to=tariqt@nvidia.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gal@nvidia.com \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=mbloch@nvidia.com \
--cc=moshe@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=saeedm@nvidia.com \
--cc=shayd@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox