r8169: Add values missing in @get_stats64 from HW counters
authorCorinna Vinschen <vinschen@redhat.com>
Mon, 24 Aug 2015 10:52:39 +0000 (12:52 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 25 Aug 2015 23:02:35 +0000 (16:02 -0700)
commit6e85d5ad36a26debc23a9a865c029cbe242b2dc8
tree84accf6cb374c0a22f1abfb6524c141707ab7fdb
parentb01d04aa511b78c795dd258bf8689a421a6b4d0c
r8169: Add values missing in @get_stats64 from HW counters

The r8169 driver collects statistical information returned by
@get_stats64 by counting them in the driver itself, even though many
(but not all) of the values are already collected by tally counters
(TCs) in the NIC.  Some of these TC values are not returned by
@get_stats64.  Especially the received multicast packages are missing
from /proc/net/dev.

Rectify this by fetching the TCs and returning them from
rtl8169_get_stats64.

The counters collected in the driver obviously disappear as soon as the
driver is unloaded so after a driver is loaded the counters always start
at 0. The TCs on the other hand are only reset by a power cycle.  Without
further considerations the values collected by the driver would not match
up against the TC values.

This patch introduces a new function rtl8169_reset_counters which
resets the TCs.  Also, since rtl8169_reset_counters shares most of
its code with rtl8169_update_counters, refactor the shared code into
two new functions  rtl8169_map_counters and rtl8169_unmap_counters.

Unfortunately chip versions prior to RTL_GIGA_MAC_VER_19 don't allow
to reset the TCs programatically.  Therefore introduce an addition to
the rtl8169_private struct and a function rtl8169_init_counter_offsets
to store the TCs at first rtl_open.  Use these values as offsets in
rtl8169_get_stats64.  Propagate a failure to reset *and* update the
counters up to rtl_open and emit a warning message, if so.

Signed-off-by: Corinna Vinschen <vinschen@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/realtek/r8169.c