diff options
author | Steven <sluong@cisco.com> | 2018-12-12 16:01:28 -0800 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2018-12-17 08:35:02 +0000 |
commit | 7bb27caf62f5fa942be68015aeb0543566d22371 (patch) | |
tree | 0c6cc026e2bcea835e2c61f5b4640055cea46ef5 /src/plugins/vmxnet3 | |
parent | 18f34a86a4904524f53fc2c3d9a68572f12b9ae7 (diff) |
vmxnet3: support clear hardware interface counters
Add clear hardware interface counters callback for vmxnet3 device. We take a
snap shot of the statistics in the callback. For the show hardware command,
we display the delta between the current statistics and the last snapshot.
Change-Id: Ie1389d2141f519300f427fe6ff2fdf97fd9e9378
Signed-off-by: Steven <sluong@cisco.com>
Diffstat (limited to 'src/plugins/vmxnet3')
-rw-r--r-- | src/plugins/vmxnet3/format.c | 60 | ||||
-rw-r--r-- | src/plugins/vmxnet3/vmxnet3.c | 18 | ||||
-rw-r--r-- | src/plugins/vmxnet3/vmxnet3.h | 2 |
3 files changed, 60 insertions, 20 deletions
diff --git a/src/plugins/vmxnet3/format.c b/src/plugins/vmxnet3/format.c index c1a74367436..eb213c96885 100644 --- a/src/plugins/vmxnet3/format.c +++ b/src/plugins/vmxnet3/format.c @@ -75,47 +75,67 @@ format_vmxnet3_device (u8 * s, va_list * args) s = format (s, "\n%UTX:", format_white_space, indent); s = format (s, "\n%U TSO packets %llu", - format_white_space, indent, q->tx.stats.tso_pkts); + format_white_space, indent, + q->tx.stats.tso_pkts - vd->tx_stats.tso_pkts); s = format (s, "\n%U TSO bytes %llu", - format_white_space, indent, q->tx.stats.tso_bytes); + format_white_space, indent, + q->tx.stats.tso_bytes - vd->tx_stats.tso_bytes); s = format (s, "\n%U ucast packets %llu", - format_white_space, indent, q->tx.stats.ucast_pkts); + format_white_space, indent, + q->tx.stats.ucast_pkts - vd->tx_stats.ucast_pkts); s = format (s, "\n%U ucast bytes %llu", - format_white_space, indent, q->tx.stats.ucast_bytes); + format_white_space, indent, + q->tx.stats.ucast_bytes - vd->tx_stats.ucast_bytes); s = format (s, "\n%U mcast packets %llu", - format_white_space, indent, q->tx.stats.mcast_pkts); + format_white_space, indent, + q->tx.stats.mcast_pkts - vd->tx_stats.mcast_pkts); s = format (s, "\n%U mcast bytes %llu", - format_white_space, indent, q->tx.stats.mcast_bytes); + format_white_space, indent, + q->tx.stats.mcast_bytes - vd->tx_stats.mcast_bytes); s = format (s, "\n%U bcast packets %llu", - format_white_space, indent, q->tx.stats.bcast_pkts); + format_white_space, indent, + q->tx.stats.bcast_pkts - vd->tx_stats.bcast_pkts); s = format (s, "\n%U bcast bytes %llu", - format_white_space, indent, q->tx.stats.bcast_bytes); + format_white_space, indent, + q->tx.stats.bcast_bytes - vd->tx_stats.bcast_bytes); s = format (s, "\n%U Errors packets %llu", - format_white_space, indent, q->tx.stats.error_pkts); + format_white_space, indent, + q->tx.stats.error_pkts - vd->tx_stats.error_pkts); s = format (s, "\n%U Discard packets %llu", - format_white_space, indent, q->tx.stats.discard_pkts); + format_white_space, indent, + q->tx.stats.discard_pkts - vd->tx_stats.discard_pkts); s = format (s, "\n%URX:", format_white_space, indent); s = format (s, "\n%U LRO packets %llu", - format_white_space, indent, q->rx.stats.lro_pkts); + format_white_space, indent, + q->rx.stats.lro_pkts - vd->rx_stats.lro_pkts); s = format (s, "\n%U LRO bytes %llu", - format_white_space, indent, q->rx.stats.lro_bytes); + format_white_space, indent, + q->rx.stats.lro_bytes - vd->rx_stats.lro_bytes); s = format (s, "\n%U ucast packets %llu", - format_white_space, indent, q->rx.stats.ucast_pkts); + format_white_space, indent, + q->rx.stats.ucast_pkts - vd->rx_stats.ucast_pkts); s = format (s, "\n%U ucast bytes %llu", - format_white_space, indent, q->rx.stats.ucast_bytes); + format_white_space, indent, + q->rx.stats.ucast_bytes - vd->rx_stats.ucast_bytes); s = format (s, "\n%U mcast packets %llu", - format_white_space, indent, q->rx.stats.mcast_pkts); + format_white_space, indent, + q->rx.stats.mcast_pkts - vd->rx_stats.mcast_pkts); s = format (s, "\n%U mcast bytes %llu", - format_white_space, indent, q->rx.stats.mcast_bytes); + format_white_space, indent, + q->rx.stats.mcast_bytes - vd->rx_stats.mcast_bytes); s = format (s, "\n%U bcast packets %llu", - format_white_space, indent, q->rx.stats.bcast_pkts); + format_white_space, indent, + q->rx.stats.bcast_pkts - vd->rx_stats.bcast_pkts); s = format (s, "\n%U bcast bytes %llu", - format_white_space, indent, q->rx.stats.bcast_bytes); + format_white_space, indent, + q->rx.stats.bcast_bytes - vd->rx_stats.bcast_bytes); s = format (s, "\n%U No Bufs %llu", - format_white_space, indent, q->rx.stats.nobuf_pkts); + format_white_space, indent, + q->rx.stats.nobuf_pkts - vd->rx_stats.nobuf_pkts); s = format (s, "\n%U Error packets %llu", - format_white_space, indent, q->rx.stats.error_pkts); + format_white_space, indent, + q->rx.stats.error_pkts - vd->rx_stats.error_pkts); return s; } diff --git a/src/plugins/vmxnet3/vmxnet3.c b/src/plugins/vmxnet3/vmxnet3.c index 08d4d5cea52..a5a62e99fe5 100644 --- a/src/plugins/vmxnet3/vmxnet3.c +++ b/src/plugins/vmxnet3/vmxnet3.c @@ -97,6 +97,23 @@ vmxnet3_set_interface_next_node (vnet_main_t * vnm, u32 hw_if_index, node_index); } +static void +vmxnet3_clear_hw_interface_counters (u32 instance) +{ + vmxnet3_main_t *vmxm = &vmxnet3_main; + vmxnet3_device_t *vd = pool_elt_at_index (vmxm->devices, instance); + vmxnet3_queues *q = &vd->dma->queues; + + /* + * Set the "last_cleared_stats" to the current stats, so that + * things appear to clear from a display perspective. + */ + vmxnet3_reg_write (vd, 1, VMXNET3_REG_CMD, VMXNET3_CMD_GET_STATS); + + clib_memcpy (&vd->tx_stats, &q->tx.stats, sizeof (vd->tx_stats)); + clib_memcpy (&vd->rx_stats, &q->rx.stats, sizeof (vd->rx_stats)); +} + static char *vmxnet3_tx_func_error_strings[] = { #define _(n,s) s, foreach_vmxnet3_tx_func_error @@ -110,6 +127,7 @@ VNET_DEVICE_CLASS (vmxnet3_device_class,) = .format_device = format_vmxnet3_device, .format_device_name = format_vmxnet3_device_name, .admin_up_down_function = vmxnet3_interface_admin_up_down, + .clear_counters = vmxnet3_clear_hw_interface_counters, .rx_mode_change_function = vmxnet3_interface_rx_mode_change, .rx_redirect_to_node = vmxnet3_set_interface_next_node, .tx_function_n_errors = VMXNET3_TX_N_ERROR, diff --git a/src/plugins/vmxnet3/vmxnet3.h b/src/plugins/vmxnet3/vmxnet3.h index a3306895ec0..3a40b0de49e 100644 --- a/src/plugins/vmxnet3/vmxnet3.h +++ b/src/plugins/vmxnet3/vmxnet3.h @@ -488,6 +488,8 @@ typedef struct vmxnet3_dma *dma; u32 link_speed; + vmxnet3_tx_stats tx_stats; + vmxnet3_rx_stats rx_stats; } vmxnet3_device_t; typedef struct |