Re: [PATCH net-next v3 09/12] net: dsa: microchip: ksz9477: initial hardware time stamping support

From: Vladimir Oltean
Date: Fri Nov 20 2020 - 18:28:09 EST


On Wed, Nov 18, 2020 at 09:30:10PM +0100, Christian Eggers wrote:
> Add control routines required for TX hardware time stamping.
>
> The KSZ9563 only supports one step time stamping
> (HWTSTAMP_TX_ONESTEP_P2P), which requires linuxptp-2.0 or later.
>
> Currently, only P2P delay measurement is supported. See patchwork
> discussion and comments in ksz9477_ptp_init() for details:
> https://patchwork.ozlabs.org/project/netdev/patch/20201019172435.4416-8-ceggers@xxxxxxx/
>
> Signed-off-by: Christian Eggers <ceggers@xxxxxxx>
> ---

Reviewed-by: Vladimir Oltean <olteanv@xxxxxxxxx>

> +static int ksz9477_set_hwtstamp_config(struct ksz_device *dev, int port,
> + struct hwtstamp_config *config)
> +{
> + struct ksz_port *prt = &dev->ports[port];
> +
> + /* reserved for future extensions */
> + if (config->flags)
> + return -EINVAL;
> +
> + switch (config->tx_type) {
> + case HWTSTAMP_TX_OFF:
> + prt->hwts_tx_en = false;
> + break;
> + case HWTSTAMP_TX_ONESTEP_P2P:
> + prt->hwts_tx_en = true;
> + break;
> + default:
> + return -ERANGE;
> + }
> +
> + switch (config->rx_filter) {
> + case HWTSTAMP_FILTER_NONE:
> + break;
> + case HWTSTAMP_FILTER_PTP_V2_L4_EVENT:
> + case HWTSTAMP_FILTER_PTP_V2_L4_SYNC:
> + config->rx_filter = HWTSTAMP_FILTER_PTP_V2_L4_EVENT;
> + break;
> + case HWTSTAMP_FILTER_PTP_V2_L2_EVENT:
> + case HWTSTAMP_FILTER_PTP_V2_L2_SYNC:
> + config->rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_EVENT;
> + break;
> + case HWTSTAMP_FILTER_PTP_V2_EVENT:
> + case HWTSTAMP_FILTER_PTP_V2_SYNC:
> + config->rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT;
> + break;
> + case HWTSTAMP_FILTER_ALL:

Putting anything in the same "case" statement as "default" is useless.

> + default:
> + config->rx_filter = HWTSTAMP_FILTER_NONE;
> + return -ERANGE;
> + }
> +
> + return 0;
> +}