mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Oleksij Rempel <o.rempel@pengutronix.de>
Cc: Heiner Kallweit <hkallweit1@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Jonathan Corbet <corbet@lwn.net>,
	kernel@pengutronix.de, linux-kernel@vger.kernel.org,
	netdev@vger.kernel.org, Russell King <linux@armlinux.org.uk>
Subject: Re: [PATCH net-next v2 3/3] phy: dp83td510: Utilize ALCD for cable length measurement when link is active
Date: Tue, 20 Aug 2024 18:49:00 +0200	[thread overview]
Message-ID: <a02698f3-94b6-4e6c-b13a-7fbeba2ce42f@lunn.ch> (raw)
In-Reply-To: <20240820101256.1506460-4-o.rempel@pengutronix.de>

On Tue, Aug 20, 2024 at 12:12:56PM +0200, Oleksij Rempel wrote:
> In industrial environments where 10BaseT1L PHYs are replacing existing
> field bus systems like CAN, it's often essential to retain the existing
> cable infrastructure. After installation, collecting metrics such as
> cable length is crucial for assessing the quality of the infrastructure.
> Traditionally, TDR (Time Domain Reflectometry) is used for this purpose.
> However, TDR requires interrupting the link, and if the link partner
> remains active, the TDR measurement will fail.
> 
> Unlike multi-pair systems, where TDR can be attempted during the MDI-X
> switching window, 10BaseT1L systems face greater challenges. The TDR
> sequence on 10BaseT1L is longer and coincides with uninterrupted
> autonegotiation pulses, making TDR impossible when the link partner is
> active.
> 
> The DP83TD510 PHY provides an alternative through ALCD (Active Link
> Cable Diagnostics), which allows for cable length measurement without
> disrupting an active link. Since a live link indicates no short or open
> cable states, ALCD can be used effectively to gather cable length
> information.
> 
> Enhance the dp83td510 driver by:
> - Leveraging ALCD to measure cable length when the link is active.
> - Bypassing TDR when a link is detected, as ALCD provides the required
>   information without disruption.
> 
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> ---
>  drivers/net/phy/dp83td510.c | 83 ++++++++++++++++++++++++++++++++++---
>  1 file changed, 77 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/phy/dp83td510.c b/drivers/net/phy/dp83td510.c
> index 551e37786c2da..10a46354ad2b8 100644
> --- a/drivers/net/phy/dp83td510.c
> +++ b/drivers/net/phy/dp83td510.c
> @@ -169,6 +169,10 @@ static const u16 dp83td510_mse_sqi_map[] = {
>  #define DP83TD510E_UNKN_030E				0x30e
>  #define DP83TD510E_030E_VAL				0x2520
>  
> +#define DP83TD510E_ALCD_STAT				0xa9f
> +#define DP83TD510E_ALCD_COMPLETE			BIT(15)
> +#define DP83TD510E_ALCD_CABLE_LENGTH			GENMASK(10, 0)
> +
>  static int dp83td510_config_intr(struct phy_device *phydev)
>  {
>  	int ret;
> @@ -327,6 +331,16 @@ static int dp83td510_cable_test_start(struct phy_device *phydev)
>  {
>  	int ret;
>  
> +	/* If link partner is active, we won't be able to use TDR, since
> +	 * we can't force link partner to be silent. The autonegotiation
> +	 * pulses will be too frequent and the TDR sequence will be
> +	 * too long. So, TDR will always fail. Since the link is established
> +	 * we already know that the cable is working, so we can get some
> +	 * extra information line the cable length using ALCD.
> +	 */
> +	if (phydev->link)
> +		return 0;
> +

> +static int dp83td510_cable_test_get_status(struct phy_device *phydev,
> +					   bool *finished)
> +{
> +	*finished = false;
> +
> +	if (!phydev->link)
> +		return dp83td510_cable_test_get_tdr_status(phydev, finished);
> +
> +	return dp83td510_cable_test_get_alcd_status(phydev, finished);

Sorry, missed this earlier. It seems like there is a race here. It
could be the cable test was started without link, but when phylib
polls a few seconds later link could of established. Will valid ALCD
results be returned?

	Andrew

  reply	other threads:[~2024-08-20 16:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-20 10:12 [PATCH net-next v2 0/3] Add ALCD Support to Cable Testing Interface Oleksij Rempel
2024-08-20 10:12 ` [PATCH net-next v2 1/3] ethtool: Extend cable testing interface with result source information Oleksij Rempel
2024-08-20 16:40   ` Andrew Lunn
2024-08-20 22:01   ` Jakub Kicinski
2024-08-20 10:12 ` [PATCH net-next v2 2/3] ethtool: Add support for specifying information source in cable test results Oleksij Rempel
2024-08-20 16:44   ` Andrew Lunn
2024-08-20 10:12 ` [PATCH net-next v2 3/3] phy: dp83td510: Utilize ALCD for cable length measurement when link is active Oleksij Rempel
2024-08-20 16:49   ` Andrew Lunn [this message]
2024-08-20 17:59     ` Oleksij Rempel

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=a02698f3-94b6-4e6c-b13a-7fbeba2ce42f@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=o.rempel@pengutronix.de \
    --cc=pabeni@redhat.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

all inboxes | Powered by JetHome®