[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201129171634.GD2234159@lunn.ch>
Date: Sun, 29 Nov 2020 18:16:34 +0100
From: Andrew Lunn <andrew@...n.ch>
To: Steen Hegelund <steen.hegelund@...rochip.com>
Cc: "David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Masahiro Yamada <masahiroy@...nel.org>,
Lars Povlsen <lars.povlsen@...rochip.com>,
Bjarni Jonasson <bjarni.jonasson@...rochip.com>,
Microchip Linux Driver Support <UNGLinuxDriver@...rochip.com>,
Alexandre Belloni <alexandre.belloni@...tlin.com>,
Microsemi List <microsemi@...ts.bootlin.com>,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [RFC PATCH 2/3] net: sparx5: Add Sparx5 switchdev driver
> 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
Powered by blists - more mailing lists