lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <45ebd2eb-9b09-43fa-a451-29299b33f06a@bootlin.com>
Date: Wed, 29 Oct 2025 20:28:51 +0100
From: Maxime Chevallier <maxime.chevallier@...tlin.com>
To: Inochi Amaoto <inochiama@...il.com>, Han Gao <rabenda.cn@...il.com>,
 Icenowy Zheng <uwu@...nowy.me>, Vivian Wang <wangruikang@...as.ac.cn>,
 Yao Zi <ziyao@...root.org>, Andrew Lunn <andrew+netdev@...n.ch>,
 "David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
 Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
 Rob Herring <robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>,
 Conor Dooley <conor+dt@...nel.org>, Chen Wang <unicorn_wang@...look.com>,
 Maxime Coquelin <mcoquelin.stm32@...il.com>,
 Alexandre Torgue <alexandre.torgue@...s.st.com>,
 Heiner Kallweit <hkallweit1@...il.com>, Russell King
 <linux@...linux.org.uk>, "Russell King (Oracle)" <rmk+kernel@...linux.org.uk>
Cc: netdev@...r.kernel.org, devicetree@...r.kernel.org,
 sophgo@...ts.linux.dev, linux-kernel@...r.kernel.org,
 linux-stm32@...md-mailman.stormreply.com,
 linux-arm-kernel@...ts.infradead.org, Yixun Lan <dlan@...too.org>,
 Longbin Li <looong.bin@...il.com>
Subject: Re: [PATCH v4 2/3] net: phy: Add helper for fixing RGMII PHY mode
 based on internal mac delay

Hi,

On 28/10/2025 01:38, Inochi Amaoto wrote:
> The "phy-mode" property of devicetree indicates whether the PCB has
> delay now, which means the mac needs to modify the PHY mode based
> on whether there is an internal delay in the mac.
> 
> This modification is similar for many ethernet drivers. To simplify
> code, define the helper phy_fix_phy_mode_for_mac_delays(speed, mac_txid,
> mac_rxid) to fix PHY mode based on whether mac adds internal delay.
> 
> Suggested-by: Russell King (Oracle) <linux@...linux.org.uk>
> Signed-off-by: Inochi Amaoto <inochiama@...il.com>

Name may be a bit long, but I'm not the best at naming stuff :)

I agree with the logic of that helper,

Reviewed-by: Maxime Chevallier <maxime.chevallier@...tlin.com>

Maxime

> ---
>  drivers/net/phy/phy-core.c | 43 ++++++++++++++++++++++++++++++++++++++
>  include/linux/phy.h        |  3 +++
>  2 files changed, 46 insertions(+)
> 
> diff --git a/drivers/net/phy/phy-core.c b/drivers/net/phy/phy-core.c
> index 605ca20ae192..4f258fb409da 100644
> --- a/drivers/net/phy/phy-core.c
> +++ b/drivers/net/phy/phy-core.c
> @@ -101,6 +101,49 @@ const char *phy_rate_matching_to_str(int rate_matching)
>  }
>  EXPORT_SYMBOL_GPL(phy_rate_matching_to_str);
>  
> +/**
> + * phy_fix_phy_mode_for_mac_delays - Convenience function for fixing PHY
> + * mode based on whether mac adds internal delay
> + *
> + * @interface: The current interface mode of the port
> + * @mac_txid: True if the mac adds internal tx delay
> + * @mac_rxid: True if the mac adds internal rx delay
> + *
> + * Return fixed PHY mode, or PHY_INTERFACE_MODE_NA if the interface can
> + * not apply the internal delay
> + */
> +phy_interface_t phy_fix_phy_mode_for_mac_delays(phy_interface_t interface,
> +						bool mac_txid, bool mac_rxid)
> +{
> +	if (!phy_interface_mode_is_rgmii(interface))
> +		return interface;
> +
> +	if (mac_txid && mac_rxid) {
> +		if (interface == PHY_INTERFACE_MODE_RGMII_ID)
> +			return PHY_INTERFACE_MODE_RGMII;
> +		return PHY_INTERFACE_MODE_NA;
> +	}
> +
> +	if (mac_txid) {
> +		if (interface == PHY_INTERFACE_MODE_RGMII_ID)
> +			return PHY_INTERFACE_MODE_RGMII_RXID;
> +		if (interface == PHY_INTERFACE_MODE_RGMII_TXID)
> +			return PHY_INTERFACE_MODE_RGMII;
> +		return PHY_INTERFACE_MODE_NA;
> +	}
> +
> +	if (mac_rxid) {
> +		if (interface == PHY_INTERFACE_MODE_RGMII_ID)
> +			return PHY_INTERFACE_MODE_RGMII_TXID;
> +		if (interface == PHY_INTERFACE_MODE_RGMII_RXID)
> +			return PHY_INTERFACE_MODE_RGMII;
> +		return PHY_INTERFACE_MODE_NA;
> +	}
> +
> +	return interface;
> +}
> +EXPORT_SYMBOL_GPL(phy_fix_phy_mode_for_mac_delays);
> +
>  /**
>   * phy_interface_num_ports - Return the number of links that can be carried by
>   *			     a given MAC-PHY physical link. Returns 0 if this is
> diff --git a/include/linux/phy.h b/include/linux/phy.h
> index 3c7634482356..0bc00a4cceb2 100644
> --- a/include/linux/phy.h
> +++ b/include/linux/phy.h
> @@ -1813,6 +1813,9 @@ static inline bool phy_is_pseudo_fixed_link(struct phy_device *phydev)
>  	return phydev->is_pseudo_fixed_link;
>  }
>  
> +phy_interface_t phy_fix_phy_mode_for_mac_delays(phy_interface_t interface,
> +						bool mac_txid, bool mac_rxid);
> +
>  int phy_save_page(struct phy_device *phydev);
>  int phy_select_page(struct phy_device *phydev, int page);
>  int phy_restore_page(struct phy_device *phydev, int oldpage, int ret);


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ