Re: [Patch net-next v6 12/13] net: dsa: microchip: ptp: lan937x: add 2 step timestamping
From: Vladimir Oltean
Date: Tue Jan 03 2023 - 12:47:26 EST
On Mon, Jan 02, 2023 at 10:34:58AM +0530, Arun Ramadoss wrote:
> ---
> drivers/net/dsa/microchip/ksz_ptp.c | 37 ++++++++++++++++++++++++++++-
> 1 file changed, 36 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/dsa/microchip/ksz_ptp.c b/drivers/net/dsa/microchip/ksz_ptp.c
> index 2d52a3d4771e..c2d156002ee5 100644
> --- a/drivers/net/dsa/microchip/ksz_ptp.c
> +++ b/drivers/net/dsa/microchip/ksz_ptp.c
> @@ -283,6 +283,9 @@ int ksz_get_ts_info(struct dsa_switch *ds, int port, struct ethtool_ts_info *ts)
>
> ts->tx_types = BIT(HWTSTAMP_TX_OFF) | BIT(HWTSTAMP_TX_ONESTEP_P2P);
>
> + if (is_lan937x(dev))
> + ts->tx_types |= BIT(HWTSTAMP_TX_ON);
> +
> ts->rx_filters = BIT(HWTSTAMP_FILTER_NONE) |
> BIT(HWTSTAMP_FILTER_PTP_V2_L4_EVENT) |
> BIT(HWTSTAMP_FILTER_PTP_V2_L2_EVENT) |
> @@ -310,6 +313,8 @@ static int ksz_set_hwtstamp_config(struct ksz_device *dev,
> struct ksz_port *prt,
> struct hwtstamp_config *config)
> {
> + int ret;
> +
> if (config->flags)
> return -EINVAL;
>
> @@ -325,6 +330,25 @@ static int ksz_set_hwtstamp_config(struct ksz_device *dev,
> prt->ptpmsg_irq[KSZ_XDREQ_MSG].ts_en = 1;
> prt->ptpmsg_irq[KSZ_PDRES_MSG].ts_en = 0;
> prt->hwts_tx_en = true;
> +
> + ret = ksz_rmw16(dev, REG_PTP_MSG_CONF1, PTP_1STEP, PTP_1STEP);
> + if (ret)
> + return ret;
> +
> + break;
> + case HWTSTAMP_TX_ON:
> + if (!is_lan937x(dev))
> + return -ERANGE;
> +
> + prt->ptpmsg_irq[KSZ_SYNC_MSG].ts_en = 1;
> + prt->ptpmsg_irq[KSZ_XDREQ_MSG].ts_en = 1;
> + prt->ptpmsg_irq[KSZ_PDRES_MSG].ts_en = 1;
s/1/true/ please
> + prt->hwts_tx_en = true;
> +
> + ret = ksz_rmw16(dev, REG_PTP_MSG_CONF1, PTP_1STEP, 0);
> + if (ret)
> + return ret;
> +
> break;
> default:
> return -ERANGE;