net/iavf: adjust CRC statistics calculation
authorHaiyue Wang <haiyue.wang@intel.com>
Fri, 15 Jan 2021 06:57:08 +0000 (14:57 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 19 Jan 2021 02:30:14 +0000 (03:30 +0100)
The AVF can support to enable / disable CRC strip, so it needs to adjust
the statistics calculation for ibytes according to offload setting.

Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
drivers/net/iavf/iavf_ethdev.c

index e22c62e..87e6062 100644 (file)
@@ -1413,6 +1413,9 @@ iavf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 
        ret = iavf_query_stats(adapter, &pstats);
        if (ret == 0) {
+               uint8_t crc_stats_len = (dev->data->dev_conf.rxmode.offloads &
+                                        DEV_RX_OFFLOAD_KEEP_CRC) ? 0 :
+                                        RTE_ETHER_CRC_LEN;
                iavf_update_stats(vsi, pstats);
                stats->ipackets = pstats->rx_unicast + pstats->rx_multicast +
                                pstats->rx_broadcast - pstats->rx_discards;
@@ -1421,7 +1424,7 @@ iavf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
                stats->imissed = pstats->rx_discards;
                stats->oerrors = pstats->tx_errors + pstats->tx_discards;
                stats->ibytes = pstats->rx_bytes;
-               stats->ibytes -= stats->ipackets * RTE_ETHER_CRC_LEN;
+               stats->ibytes -= stats->ipackets * crc_stats_len;
                stats->obytes = pstats->tx_bytes;
        } else {
                PMD_DRV_LOG(ERR, "Get statistics failed");