All of lore.kernel.org
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeedm@mellanox.com>
To: "David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org, Eran Ben Elisha <eranbe@mellanox.com>,
	Ariel Levkovich <lariel@mellanox.com>,
	Saeed Mahameed <saeedm@mellanox.com>
Subject: [net V2 07/11] net/mlx5: Verify Hardware supports requested ptp function on a given pin
Date: Tue, 28 Jul 2020 12:59:31 -0700	[thread overview]
Message-ID: <20200728195935.155604-8-saeedm@mellanox.com> (raw)
In-Reply-To: <20200728195935.155604-1-saeedm@mellanox.com>

From: Eran Ben Elisha <eranbe@mellanox.com>

Fix a bug where driver did not verify Hardware pin capabilities for
PTP functions.

Fixes: ee7f12205abc ("net/mlx5e: Implement 1PPS support")
Signed-off-by: Eran Ben Elisha <eranbe@mellanox.com>
Reviewed-by: Ariel Levkovich <lariel@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 .../ethernet/mellanox/mlx5/core/lib/clock.c   | 23 ++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
index c6967e1a560b7..284806e331bd8 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
@@ -408,10 +408,31 @@ static int mlx5_ptp_enable(struct ptp_clock_info *ptp,
 	return 0;
 }
 
+enum {
+	MLX5_MTPPS_REG_CAP_PIN_X_MODE_SUPPORT_PPS_IN = BIT(0),
+	MLX5_MTPPS_REG_CAP_PIN_X_MODE_SUPPORT_PPS_OUT = BIT(1),
+};
+
 static int mlx5_ptp_verify(struct ptp_clock_info *ptp, unsigned int pin,
 			   enum ptp_pin_function func, unsigned int chan)
 {
-	return (func == PTP_PF_PHYSYNC) ? -EOPNOTSUPP : 0;
+	struct mlx5_clock *clock = container_of(ptp, struct mlx5_clock,
+						ptp_info);
+
+	switch (func) {
+	case PTP_PF_NONE:
+		return 0;
+	case PTP_PF_EXTTS:
+		return !(clock->pps_info.pin_caps[pin] &
+			 MLX5_MTPPS_REG_CAP_PIN_X_MODE_SUPPORT_PPS_IN);
+	case PTP_PF_PEROUT:
+		return !(clock->pps_info.pin_caps[pin] &
+			 MLX5_MTPPS_REG_CAP_PIN_X_MODE_SUPPORT_PPS_OUT);
+	default:
+		return -EOPNOTSUPP;
+	}
+
+	return -EOPNOTSUPP;
 }
 
 static const struct ptp_clock_info mlx5_ptp_clock_info = {
-- 
2.26.2


  parent reply	other threads:[~2020-07-28 20:00 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-28 19:59 [pull request][net V2 00/11] mlx5 fixes-2020-07-28 Saeed Mahameed
2020-07-28 19:59 ` [net V2 01/11] net/mlx5: E-switch, Destroy TSAR when fail to enable the mode Saeed Mahameed
2020-07-28 19:59 ` [net V2 02/11] net/mlx5: E-switch, Destroy TSAR after reload interface Saeed Mahameed
2020-07-28 19:59 ` [net V2 03/11] net/mlx5: Fix forward to next namespace Saeed Mahameed
2020-07-28 19:59 ` [net V2 04/11] net/mlx5e: Fix error path of device attach Saeed Mahameed
2020-07-28 19:59 ` [net V2 05/11] net/mlx5e: Fix missing cleanup of ethtool steering during rep rx cleanup Saeed Mahameed
2020-07-28 19:59 ` [net V2 06/11] net/mlx5: Fix a bug of using ptp channel index as pin index Saeed Mahameed
2020-07-28 19:59 ` Saeed Mahameed [this message]
2020-07-28 20:20   ` [net V2 07/11] net/mlx5: Verify Hardware supports requested ptp function on a given pin Jakub Kicinski
2020-07-28 19:59 ` [net V2 08/11] net/mlx5e: Fix slab-out-of-bounds in mlx5e_rep_is_lag_netdev Saeed Mahameed
2020-07-28 19:59 ` [net V2 09/11] net/mlx5: Query PPS pin operational status before registering it Saeed Mahameed
2020-07-28 19:59 ` [net V2 10/11] net/mlx5e: Modify uplink state on interface up/down Saeed Mahameed
2020-07-29  6:17   ` Or Gerlitz
2020-07-29  6:38     ` Saeed Mahameed
2020-07-28 19:59 ` [net V2 11/11] net/mlx5e: Fix kernel crash when setting vf VLANID on a VF dev Saeed Mahameed
2020-07-28 20:22 ` [pull request][net V2 00/11] mlx5 fixes-2020-07-28 Jakub Kicinski
2020-07-28 23:59 ` David Miller

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=20200728195935.155604-8-saeedm@mellanox.com \
    --to=saeedm@mellanox.com \
    --cc=davem@davemloft.net \
    --cc=eranbe@mellanox.com \
    --cc=kuba@kernel.org \
    --cc=lariel@mellanox.com \
    --cc=netdev@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.