kernel/wr_pstats: support "zeroing" of counters.
By writing anything to a port file, you zero the counters for that
port. By writing to "info" or "description" you zero counters for
all ports.
Zeroing is performed by copying the current values to a new array,
and always subytracting that array to the current counter values.
No zeroing is performed for network statistics, that still reads
the "real" counters, featuring an overflow at 4G but no zeroing ever.
To simplify a little the code, I turned the one-dimensional array
with index arithmetics into a two-dimensional array, so the compiler
makes the math for us, transparently.
NOTE: the spinlock must be audited, we are not safe yet, not only
because of this patch.
Signed-off-by:
Alessandro Rubini <rubini@gnudd.com>
Please register or sign in to comment