netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeed@kernel.org>
To: "David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Eric Dumazet <edumazet@google.com>
Cc: Saeed Mahameed <saeedm@nvidia.com>,
	netdev@vger.kernel.org, Tariq Toukan <tariqt@nvidia.com>,
	Rahul Rameshbabu <rrameshbabu@nvidia.com>,
	Gal Pressman <gal@nvidia.com>
Subject: [net-next 11/15] net/mlx5: Add firmware support for MTUTC scaled_ppm frequency adjustments
Date: Sat,  4 Feb 2023 02:08:50 -0800	[thread overview]
Message-ID: <20230204100854.388126-12-saeed@kernel.org> (raw)
In-Reply-To: <20230204100854.388126-1-saeed@kernel.org>

From: Rahul Rameshbabu <rrameshbabu@nvidia.com>

When device is capable of handling scaled ppm values for adjusting
frequency, conversion to ppb will not be done by the driver. Instead, the
scaled ppm value will be passed directly to the device for the frequency
adjustment operation.

Signed-off-by: Rahul Rameshbabu <rrameshbabu@nvidia.com>
Reviewed-by: Gal Pressman <gal@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 .../net/ethernet/mellanox/mlx5/core/lib/clock.c   | 15 ++++++++++++---
 include/linux/mlx5/mlx5_ifc.h                     | 12 ++++++++++--
 2 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
index 75510a12ab02..4c9a40211059 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
@@ -362,7 +362,7 @@ static int mlx5_ptp_adjphase(struct ptp_clock_info *ptp, s32 delta)
 	return mlx5_ptp_adjtime(ptp, delta);
 }
 
-static int mlx5_ptp_adjfreq_real_time(struct mlx5_core_dev *mdev, s32 freq)
+static int mlx5_ptp_freq_adj_real_time(struct mlx5_core_dev *mdev, long scaled_ppm)
 {
 	u32 in[MLX5_ST_SZ_DW(mtutc_reg)] = {};
 
@@ -370,7 +370,15 @@ static int mlx5_ptp_adjfreq_real_time(struct mlx5_core_dev *mdev, s32 freq)
 		return 0;
 
 	MLX5_SET(mtutc_reg, in, operation, MLX5_MTUTC_OPERATION_ADJUST_FREQ_UTC);
-	MLX5_SET(mtutc_reg, in, freq_adjustment, freq);
+
+	if (MLX5_CAP_MCAM_FEATURE(mdev, mtutc_freq_adj_units)) {
+		MLX5_SET(mtutc_reg, in, freq_adj_units,
+			 MLX5_MTUTC_FREQ_ADJ_UNITS_SCALED_PPM);
+		MLX5_SET(mtutc_reg, in, freq_adjustment, scaled_ppm);
+	} else {
+		MLX5_SET(mtutc_reg, in, freq_adj_units, MLX5_MTUTC_FREQ_ADJ_UNITS_PPB);
+		MLX5_SET(mtutc_reg, in, freq_adjustment, scaled_ppm_to_ppb(scaled_ppm));
+	}
 
 	return mlx5_set_mtutc(mdev, in, sizeof(in));
 }
@@ -385,7 +393,8 @@ static int mlx5_ptp_adjfine(struct ptp_clock_info *ptp, long scaled_ppm)
 	int err;
 
 	mdev = container_of(clock, struct mlx5_core_dev, clock);
-	err = mlx5_ptp_adjfreq_real_time(mdev, scaled_ppm_to_ppb(scaled_ppm));
+
+	err = mlx5_ptp_freq_adj_real_time(mdev, scaled_ppm);
 	if (err)
 		return err;
 
diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h
index 1b6201bb04c1..7cf6a78fea07 100644
--- a/include/linux/mlx5/mlx5_ifc.h
+++ b/include/linux/mlx5/mlx5_ifc.h
@@ -9925,6 +9925,11 @@ struct mlx5_ifc_mpegc_reg_bits {
 	u8         reserved_at_60[0x100];
 };
 
+enum {
+	MLX5_MTUTC_FREQ_ADJ_UNITS_PPB          = 0x0,
+	MLX5_MTUTC_FREQ_ADJ_UNITS_SCALED_PPM   = 0x1,
+};
+
 enum {
 	MLX5_MTUTC_OPERATION_SET_TIME_IMMEDIATE   = 0x1,
 	MLX5_MTUTC_OPERATION_ADJUST_TIME          = 0x2,
@@ -9932,7 +9937,9 @@ enum {
 };
 
 struct mlx5_ifc_mtutc_reg_bits {
-	u8         reserved_at_0[0x1c];
+	u8         reserved_at_0[0x5];
+	u8         freq_adj_units[0x3];
+	u8         reserved_at_8[0x14];
 	u8         operation[0x4];
 
 	u8         freq_adjustment[0x20];
@@ -10005,7 +10012,8 @@ struct mlx5_ifc_pcam_reg_bits {
 };
 
 struct mlx5_ifc_mcam_enhanced_features_bits {
-	u8         reserved_at_0[0x51];
+	u8         reserved_at_0[0x50];
+	u8         mtutc_freq_adj_units[0x1];
 	u8         mtutc_time_adjustment_extended_range[0x1];
 	u8         reserved_at_52[0xb];
 	u8         mcia_32dwords[0x1];
-- 
2.39.1


  parent reply	other threads:[~2023-02-04 10:09 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-04 10:08 [pull request][net-next 00/15] mlx5 updates 2023-02-04 Saeed Mahameed
2023-02-04 10:08 ` [net-next 01/15] net/mlx5: Lag, Update multiport eswitch check to log an error Saeed Mahameed
2023-02-06  9:20   ` patchwork-bot+netdevbpf
2023-02-04 10:08 ` [net-next 02/15] net/mlx5: Lag, Use mlx5_lag_dev() instead of derefering pointers Saeed Mahameed
2023-02-04 10:08 ` [net-next 03/15] net/mlx5: Lag, Remove redundant bool allocation on the stack Saeed Mahameed
2023-02-04 10:08 ` [net-next 04/15] net/mlx5: Lag, Use flag to check for shared FDB mode Saeed Mahameed
2023-02-04 10:08 ` [net-next 05/15] net/mlx5: Lag, Move mpesw related definitions to mpesw.h Saeed Mahameed
2023-02-04 10:08 ` [net-next 06/15] net/mlx5: Separate mlx5 driver documentation into multiple pages Saeed Mahameed
2023-02-04 10:08 ` [net-next 07/15] net/mlx5: Update Kconfig parameter documentation Saeed Mahameed
2023-02-04 10:08 ` [net-next 08/15] net/mlx5: Document previously implemented mlx5 tracepoints Saeed Mahameed
2023-02-04 10:08 ` [net-next 09/15] net/mlx5: Add counter information to mlx5 driver documentation Saeed Mahameed
2023-02-04 10:08 ` [net-next 10/15] net/mlx5: Document support for RoCE HCA disablement capability Saeed Mahameed
2023-02-04 10:08 ` Saeed Mahameed [this message]
2023-02-04 10:08 ` [net-next 12/15] net/mlx5: Enhance debug print in page allocation failure Saeed Mahameed
2023-02-04 10:08 ` [net-next 13/15] net/mlx5e: IPoIB, Add support for XDR speed Saeed Mahameed
2023-02-04 10:08 ` [net-next 14/15] net/mlx5e: IPsec, support upper protocol selector field offload Saeed Mahameed
2023-02-04 10:08 ` [net-next 15/15] net/mlx5e: Trigger NAPI after activating an SQ Saeed Mahameed

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=20230204100854.388126-12-saeed@kernel.org \
    --to=saeed@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gal@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rrameshbabu@nvidia.com \
    --cc=saeedm@nvidia.com \
    --cc=tariqt@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;
as well as URLs for NNTP newsgroup(s).