Subject: Re: [RFC PATCH 2/3] net: sparx5: Add Sparx5 switchdev driver

From: Andrew Lunn <[email-masked]>
Date: Sun, 29 Nov 2020 18:16:34 +0100

> diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_ethtool.c b/drivers/net/ethernet/microchip/sparx5/sparx5_ethtool.c
> new file mode 100644
> index 000000000000..a91dd9532f1c
> --- /dev/null
> +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_ethtool.c
> @@ -0,0 +1,1027 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/* Microchip Sparx5 Switch driver
> + *
> + * Copyright (c) 2020 Microchip Technology Inc. and its subsidiaries.
> + */
> +
> +#include <linux/ethtool.h>
> +
> +#include "sparx5_main.h"
> +#include "sparx5_port.h"
> +
> +/* Add a potentially wrapping 32 bit value to a 64 bit counter */
> +static inline void sparx5_update_counter(u64 *cnt, u32 val)
> +{
> +	if (val < (*cnt & U32_MAX))
> +		*cnt += (u64)1 << 32; /* value has wrapped */
> +
> +	*cnt = (*cnt & ~(u64)U32_MAX) + val;
> +}

No inline functions in C files. Let the compiler decide.

And i now think i get what this is doing. But i'm surprised at the
hardware. Normally registers like this which are expected to wrap
around, reset to 0 on read.

	Andrew