lkml.org 
[lkml]   [2020]   [Nov]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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

\
 
 \ /
  Last update: 2020-11-29 18:18    [W:0.297 / U:0.324 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site