Re: [PATCH net-next v2 2/3] phy: Add Open Alliance helpers for the PHY framework

From: Marc Kleine-Budde
Date: Thu Aug 08 2024 - 09:12:08 EST


On 08.08.2024 15:08:32, Oleksij Rempel wrote:
> Introduce helper functions specific to Open Alliance diagnostics,
> integrating them into the PHY framework. Currently, these helpers
> are limited to 1000BaseT1 specific TDR functionality.
>
> Signed-off-by: Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx>
> ---
> drivers/net/phy/Makefile | 2 +-
> drivers/net/phy/open_alliance_helpers.c | 70 +++++++++++++++++++++++++
> include/linux/open_alliance_helpers.h | 47 +++++++++++++++++
> 3 files changed, 118 insertions(+), 1 deletion(-)
> create mode 100644 drivers/net/phy/open_alliance_helpers.c
> create mode 100644 include/linux/open_alliance_helpers.h
>
> diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
> index 202ed7f450da6..8a46a04af01a5 100644
> --- a/drivers/net/phy/Makefile
> +++ b/drivers/net/phy/Makefile
> @@ -2,7 +2,7 @@
> # Makefile for Linux PHY drivers
>
> libphy-y := phy.o phy-c45.o phy-core.o phy_device.o \
> - linkmode.o
> + linkmode.o open_alliance_helpers.o
> mdio-bus-y += mdio_bus.o mdio_device.o
>
> ifdef CONFIG_MDIO_DEVICE
> diff --git a/drivers/net/phy/open_alliance_helpers.c b/drivers/net/phy/open_alliance_helpers.c
> new file mode 100644
> index 0000000000000..eac1004c065ae
> --- /dev/null
> +++ b/drivers/net/phy/open_alliance_helpers.c
> @@ -0,0 +1,70 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * open_alliance_helpers.c - OPEN Alliance specific PHY diagnostic helpers
> + *
> + * This file contains helper functions for implementing advanced diagnostic
> + * features as specified by the OPEN Alliance for automotive Ethernet PHYs.
> + * These helpers include functionality for Time Delay Reflection (TDR), dynamic
> + * channel quality assessment, and other PHY diagnostics.
> + *
> + * For more information on the specifications, refer to the OPEN Alliance
> + * documentation: https://opensig.org/automotive-ethernet-specifications/
> + */
> +
> +#include <linux/ethtool_netlink.h>
> +#include <linux/open_alliance_helpers.h>
> +
> +/**
> + * oa_1000bt1_get_ethtool_cable_result_code - Convert TDR status to ethtool
> + * result code
> + * @reg_value: Value read from the TDR register
> + *
> + * This function takes a register value from the HDD.TDR register and converts
> + * the TDR status to the corresponding ethtool cable test result code.
> + *
> + * Return: The appropriate ethtool result code based on the TDR status
> + */
> +int oa_1000bt1_get_ethtool_cable_result_code(u16 reg_value)
> +{
> + u8 tdr_status = (reg_value & OA_1000BT1_HDD_TDR_STATUS_MASK) >> 4;
> + u8 dist_val = (reg_value & OA_1000BT1_HDD_TDR_DISTANCE_MASK) >> 8;

can you make use of FIELD_GET() here and in the other functions?

Marc

--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung Nürnberg | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |

Attachment: signature.asc
Description: PGP signature