From e2bea7436061ca2e7e14bfcfdc5870f2555c3965 Mon Sep 17 00:00:00 2001 From: Christian Ehrhardt Date: Mon, 15 Apr 2019 14:36:48 +0200 Subject: New upstream version 18.11.1 Change-Id: Ic52e74a9ed6f3ae06acea4a27357bd7153efc2a3 Signed-off-by: Christian Ehrhardt --- drivers/net/sfc/sfc_ethdev.c | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) (limited to 'drivers/net/sfc/sfc_ethdev.c') diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index 3886daf7..a7322a1e 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -503,6 +503,29 @@ sfc_tx_queue_release(void *queue) sfc_adapter_unlock(sa); } +/* + * Some statistics are computed as A - B where A and B each increase + * monotonically with some hardware counter(s) and the counters are read + * asynchronously. + * + * If packet X is counted in A, but not counted in B yet, computed value is + * greater than real. + * + * If packet X is not counted in A at the moment of reading the counter, + * but counted in B at the moment of reading the counter, computed value + * is less than real. + * + * However, counter which grows backward is worse evil than slightly wrong + * value. So, let's try to guarantee that it never happens except may be + * the case when the MAC stats are zeroed as a result of a NIC reset. + */ +static void +sfc_update_diff_stat(uint64_t *stat, uint64_t newval) +{ + if ((int64_t)(newval - *stat) > 0 || newval == 0) + *stat = newval; +} + static int sfc_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { @@ -537,11 +560,9 @@ sfc_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) mac_stats[EFX_MAC_VADAPTER_TX_UNICAST_BYTES] + mac_stats[EFX_MAC_VADAPTER_TX_MULTICAST_BYTES] + mac_stats[EFX_MAC_VADAPTER_TX_BROADCAST_BYTES]; - stats->imissed = mac_stats[EFX_MAC_VADAPTER_RX_OVERFLOW]; - stats->ierrors = mac_stats[EFX_MAC_VADAPTER_RX_BAD_PACKETS]; + stats->imissed = mac_stats[EFX_MAC_VADAPTER_RX_BAD_PACKETS]; stats->oerrors = mac_stats[EFX_MAC_VADAPTER_TX_BAD_PACKETS]; } else { - stats->ipackets = mac_stats[EFX_MAC_RX_PKTS]; stats->opackets = mac_stats[EFX_MAC_TX_PKTS]; stats->ibytes = mac_stats[EFX_MAC_RX_OCTETS]; stats->obytes = mac_stats[EFX_MAC_TX_OCTETS]; @@ -567,6 +588,13 @@ sfc_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) mac_stats[EFX_MAC_RX_ALIGN_ERRORS] + mac_stats[EFX_MAC_RX_JABBER_PKTS]; /* no oerrors counters supported on EF10 */ + + /* Exclude missed, errors and pauses from Rx packets */ + sfc_update_diff_stat(&port->ipackets, + mac_stats[EFX_MAC_RX_PKTS] - + mac_stats[EFX_MAC_RX_PAUSE_PKTS] - + stats->imissed - stats->ierrors); + stats->ipackets = port->ipackets; } unlock: @@ -1863,13 +1891,13 @@ sfc_eth_dev_secondary_set_ops(struct rte_eth_dev *dev) dp_rx = sfc_dp_find_rx_by_name(&sfc_dp_head, sa->dp_rx_name); if (dp_rx == NULL) { - sfc_err(sa, "cannot find %s Rx datapath", sa->dp_tx_name); + sfc_err(sa, "cannot find %s Rx datapath", sa->dp_rx_name); rc = ENOENT; goto fail_dp_rx; } if (~dp_rx->features & SFC_DP_RX_FEAT_MULTI_PROCESS) { sfc_err(sa, "%s Rx datapath does not support multi-process", - sa->dp_tx_name); + sa->dp_rx_name); rc = EINVAL; goto fail_dp_rx_multi_process; } -- cgit 1.2.3-korg